You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(rpc): rename schema builder to simple-schema; use it in plugins; docs use valibot
- Rename devframe/utils/schema -> devframe/utils/simple-schema and rename
the exported type DevframeSchema -> SimpleSchema. The builder is now
explicitly documented as discouraged for app code (a minimal, best-effort
validator for devframe's own first-party packages).
- Extend the builder with record/union/literal and make object() infer
optional keys for optional() fields (matching valibot/zod).
- Migrate the built-in plugins (assets, og, terminals) off valibot onto
devframe/utils/simple-schema, and drop valibot from their dependencies.
- Docs: never reference the built-in builder; all schema examples use
valibot with an explicit install hint (npm i valibot).
BREAKING CHANGE: devframe/utils/schema is renamed to
devframe/utils/simple-schema and its exported type DevframeSchema is
renamed to SimpleSchema.
@@ -77,14 +77,14 @@ Use `static` for data collected once during `setup` and shipped to read-only sta
77
77
78
78
Handlers accept any serializable arguments. Declare `args` schemas — any [Standard Schema](https://standardschema.dev/) validator (valibot, zod, arktype, …) — and each argument is validated at the boundary before the handler runs; a mismatch is rejected with a coded diagnostic. Validation guards the payload without rewriting it, so extra object fields the schema doesn't mention still reach the handler.
79
79
80
-
Devframe forces no validator on you. Bring the one you already use, or reach for the built-in zero-dependency builder at `devframe/utils/schema` (imported as `s` below):
80
+
Devframe forces no validator on you: bring whichever [Standard Schema](https://standardschema.dev/) validator you prefer (valibot, zod, arktype) and install it yourself. The examples here use valibot (`npm i valibot`):
Prefer a single object argument (`args: [s.object({ ... })]`) over positional args — property names are self-describing and agents/IDEs work best with object shapes.
97
+
Prefer a single object argument (`args: [v.object({ ... })]`) over positional args — property names are self-describing and agents/IDEs work best with object shapes.
98
98
99
99
> [!WARNING]
100
100
> Declared `args`/`returns` schemas are enforced at runtime — a call whose arguments, or a handler whose return value, fail the schema is rejected with `DF0043` / `DF0044`. Make sure each schema matches what the function actually accepts and returns; a schema stricter than reality will now reject calls that previously ran.
For flags that are specific to your tool, declare them with any [Standard Schema](https://standardschema.dev/) validator (valibot below, or zod / arktype / devframe's built-in `s`) so they're validated at parse time and typed at the call site:
171
+
For flags that are specific to your tool, declare them with any [Standard Schema](https://standardschema.dev/) validator (valibot below — `npm i valibot` — or zod / arktype) so they're validated at parse time and typed at the call site:
|`KnownEditor`| — | type | — | Union of `KNOWN_EDITORS`. |
30
30
31
-
Both functions are `action`-type RPCs returning `void` and declare their arguments with devframe's built-in zero-dependency `s` builder from `devframe/utils/schema`— `openInEditor`'s `editor` argument is `s.optional(s.picklist(KNOWN_EDITORS))`, so a value outside `KNOWN_EDITORS` fails validation rather than reaching the underlying `launch-editor` process spawn. Both handlers dynamically `import()` their underlying `devframe/utils/*` implementation, so the `launch-editor` and `open` dependencies only load when the recipe actually runs.
31
+
Both functions are `action`-type RPCs returning `void`, and their arguments are schema-validated — `openInEditor`'s `editor` argument is restricted to `KNOWN_EDITORS`, so a value outside that list fails validation rather than reaching the underlying `launch-editor` process spawn. Both handlers dynamically `import()` their underlying `devframe/utils/*` implementation, so the `launch-editor` and `open` dependencies only load when the recipe actually runs.
32
32
33
33
The `devframe/recipes/open-helpers` entry (`openHelpers`) remains as a deprecated alias for this module — new code should import `commonRpcFunctions` from `devframe/recipes/common-rpc-functions`.
0 commit comments