create-nifra 0.1.0-alpha.6 → 0.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +21 -10
- package/dist/agents.js.map +1 -1
- package/package.json +1 -1
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAc,KAAK,QAAQ,EAAiB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAc,KAAK,QAAQ,EAAiB,MAAM,SAAS,CAAA;AAsQlE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAA;IACtB,mFAAmF;IACnF,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;CAC3B;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAuBtD"}
|
package/dist/agents.js
CHANGED
|
@@ -49,10 +49,14 @@ Rules an agent must follow:
|
|
|
49
49
|
- **Lock the output shape with \`response\` (no drift).** Add \`{ response: t.object({...}) }\` to a route:
|
|
50
50
|
the handler's return is type-checked against it, and the typed client sees exactly that shape. One
|
|
51
51
|
contract, both sides — the frontend physically can't drift from the backend's output.
|
|
52
|
-
- **Data-or-error routes:
|
|
53
|
-
\`
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
- **Data-or-error routes: set the status with \`c.set.status\`, then read the error off \`res.error\` (NOT \`res.data\`).**
|
|
53
|
+
The typed client maps \`res.ok\` to the HTTP status. A route that does \`c.set.status = 404; return { ok: false,
|
|
54
|
+
error: "not_found" }\` arrives at the client as \`res.ok === false\`, \`res.data === null\`, and the body on
|
|
55
|
+
\`res.error\` (\`res.error.error === "not_found"\`). So branch on \`res.ok\` FIRST, then read \`res.data\` on success
|
|
56
|
+
or \`res.error\` on failure — never assert a 4xx onto \`res.data\`. Declaring the error arm in \`response\`
|
|
57
|
+
(\`t.union([Item, t.object({ ok: t.literal(false), error: t.string() })])\`) documents the shape and keeps the
|
|
58
|
+
success \`res.data\` precise, but a 4xx still surfaces via \`res.error\`. Do NOT return a raw \`Response\` just to
|
|
59
|
+
set an error status.
|
|
56
60
|
- **Raw \`Response\` is for redirects / streams / files** (\`Response.redirect(url, 302)\`, a file body, an
|
|
57
61
|
SSE stream). The typed client infers \`res.data: never\` on such a route and \`nifra check\` emits a
|
|
58
62
|
non-blocking \`response-route\` warning — both are EXPECTED there, not defects.
|
|
@@ -229,14 +233,21 @@ const COMMANDS = {
|
|
|
229
233
|
- \`nifra check\` — typecheck + typed-client lint (run before you call work done)`,
|
|
230
234
|
site: `- \`bun install\` — install dependencies
|
|
231
235
|
- \`nifra dev\` — true-HMR dev server
|
|
232
|
-
- \`nifra build\` — content-hashed client bundle + manifest
|
|
233
|
-
- \`nifra start\` — serve the built app (SSR)
|
|
234
|
-
- \`nifra check\` — typecheck + typed-client lint (run before you call work done)
|
|
236
|
+
- \`nifra build\` — content-hashed client bundle + manifest (local build)
|
|
237
|
+
- \`nifra start\` — serve the built app (SSR) — pairs with \`nifra build\`
|
|
238
|
+
- \`nifra check\` — typecheck + typed-client lint (run before you call work done)
|
|
239
|
+
|
|
240
|
+
For a local production run use \`nifra build && nifra start\` (or \`bun run build:bun && bun run start\`). NOTE:
|
|
241
|
+
the bare \`bun run build\` script targets **Cloudflare Pages for DEPLOY** (emits \`dist/\`, a different layout)
|
|
242
|
+
— it does NOT pair with \`nifra start\`/\`bun run start\` (which serve \`dist-bun/\`). Don't mix the two.`,
|
|
235
243
|
isr: `- \`bun install\` — install dependencies
|
|
236
244
|
- \`nifra dev\` — true-HMR dev server
|
|
237
|
-
- \`nifra build\` —
|
|
238
|
-
- \`nifra start\` — serve the built app (SSR + ISR cache)
|
|
239
|
-
- \`nifra check\` — typecheck + typed-client lint (run before you call work done)
|
|
245
|
+
- \`nifra build\` — content-hashed client bundle + manifest (local build)
|
|
246
|
+
- \`nifra start\` — serve the built app (SSR + ISR cache) — pairs with \`nifra build\`
|
|
247
|
+
- \`nifra check\` — typecheck + typed-client lint (run before you call work done)
|
|
248
|
+
|
|
249
|
+
For a local production run use \`nifra build && nifra start\`. NOTE: the bare \`bun run build\` script targets
|
|
250
|
+
**Cloudflare Pages for DEPLOY** (\`dist/\`) and does NOT pair with \`nifra start\` — don't mix the two.`,
|
|
240
251
|
};
|
|
241
252
|
/** The agent's stop condition — what makes the anti-drift guarantees actually fire. */
|
|
242
253
|
const DONE = `## Definition of done — run \`nifra check\`
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGnD,OAAO,EAAE,UAAU,EAAgC,MAAM,SAAS,CAAA;AAElE,MAAM,eAAe,GAAwC;IAC3D,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,GAAG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