create-relkit 0.7.6 → 0.7.8

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.
Files changed (46) hide show
  1. package/dist/create-capabilities.js +6 -6
  2. package/dist/create-capabilities.types.d.ts +2 -2
  3. package/dist/create-capabilities.types.d.ts.map +1 -1
  4. package/dist/render-database-sources.d.ts.map +1 -1
  5. package/dist/render-database-sources.js +4 -3
  6. package/dist/render-database-sources.js.map +1 -1
  7. package/dist/render-database.d.ts.map +1 -1
  8. package/dist/render-database.js +2 -3
  9. package/dist/render-database.js.map +1 -1
  10. package/dist/templates/default/README.md +1 -1
  11. package/dist/templates/default/v1/agent/.agents/skills/relkit/SKILL.md +17 -1
  12. package/dist/templates/default/v1/agent/.agents/skills/relkit/references/cli.md +7 -0
  13. package/dist/templates/default/v1/agent/.agents/skills/relkit/references/data-apis.md +16 -0
  14. package/dist/templates/default/v1/agent/.agents/skills/relkit/references/domain-apis.md +20 -1
  15. package/dist/templates/default/v1/agent/gitignore +1 -4
  16. package/dist/templates/default/v1/agent/package.json +4 -4
  17. package/dist/templates/default/v1/agent/tsconfig.json +1 -1
  18. package/dist/templates/default/v1/api/.agents/skills/relkit/SKILL.md +17 -1
  19. package/dist/templates/default/v1/api/.agents/skills/relkit/references/cli.md +7 -0
  20. package/dist/templates/default/v1/api/.agents/skills/relkit/references/data-apis.md +16 -0
  21. package/dist/templates/default/v1/api/.agents/skills/relkit/references/domain-apis.md +20 -1
  22. package/dist/templates/default/v1/api/gitignore +1 -4
  23. package/dist/templates/default/v1/api/package.json +3 -3
  24. package/dist/templates/default/v1/api/tsconfig.json +1 -1
  25. package/dist/templates/default/v1/fullstack/.agents/skills/relkit/SKILL.md +17 -1
  26. package/dist/templates/default/v1/fullstack/.agents/skills/relkit/references/cli.md +7 -0
  27. package/dist/templates/default/v1/fullstack/.agents/skills/relkit/references/data-apis.md +16 -0
  28. package/dist/templates/default/v1/fullstack/.agents/skills/relkit/references/domain-apis.md +20 -1
  29. package/dist/templates/default/v1/fullstack/gitignore +3 -1
  30. package/dist/templates/default/v1/fullstack/package.json +5 -5
  31. package/dist/templates/default/v1/fullstack/tsconfig.json +1 -1
  32. package/dist/templates/default/v1/minimal/.agents/skills/relkit/SKILL.md +17 -1
  33. package/dist/templates/default/v1/minimal/.agents/skills/relkit/references/cli.md +7 -0
  34. package/dist/templates/default/v1/minimal/.agents/skills/relkit/references/data-apis.md +16 -0
  35. package/dist/templates/default/v1/minimal/.agents/skills/relkit/references/domain-apis.md +20 -1
  36. package/dist/templates/default/v1/minimal/gitignore +1 -4
  37. package/dist/templates/default/v1/minimal/package.json +3 -3
  38. package/dist/templates/default/v1/minimal/tsconfig.json +1 -1
  39. package/dist/templates/default/v1/tasks/.agents/skills/relkit/SKILL.md +17 -1
  40. package/dist/templates/default/v1/tasks/.agents/skills/relkit/references/cli.md +7 -0
  41. package/dist/templates/default/v1/tasks/.agents/skills/relkit/references/data-apis.md +16 -0
  42. package/dist/templates/default/v1/tasks/.agents/skills/relkit/references/domain-apis.md +20 -1
  43. package/dist/templates/default/v1/tasks/gitignore +1 -4
  44. package/dist/templates/default/v1/tasks/package.json +3 -3
  45. package/dist/templates/default/v1/tasks/tsconfig.json +1 -1
  46. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Packaged creation support is an allow-list backed by reference-host evidence.
2
+ * Packaged creation support is an allow-list backed by exact packed readiness evidence.
3
3
  * Candidate literals remain parseable so explicit unsupported requests can return
4
4
  * a precise pre-staging diagnostic instead of masquerading as syntax errors.
5
5
  */
@@ -13,16 +13,16 @@ const entries = Object.freeze([
13
13
  deploy: "none",
14
14
  examples: true,
15
15
  identity: Object.freeze({
16
- release: "0.7.6",
16
+ release: "0.7.8",
17
17
  bun: "1.3.10",
18
18
  typescript: "5.9.3",
19
19
  packageCatalogDigest: "ac7c2f56e61fca5ab890775cf4c483722cb590e488ee7fc4741224cbb4f50ccd",
20
20
  template: "default/v1/minimal",
21
21
  snapshotProtocol: 1,
22
22
  }),
23
- templateDigest: "f72fded9c0ceccefc8140e3104ab4a0eabb8f7f92283ec0ff5237f0a772dd0ef",
24
- freshEvidence: "docs/evidence/create-capabilities/0.7.6/fresh.json",
25
- restartEvidence: "docs/evidence/create-capabilities/0.7.6/restart.json",
23
+ templateDigest: "579d32ffc180edbf06bb6656099882285cc0d4795601557efdee86d1b470212a",
24
+ freshEvidence: "docs/evidence/create-capabilities/0.7.8/fresh.json",
25
+ restartEvidence: "docs/evidence/create-capabilities/0.7.8/restart.json",
26
26
  }),
27
27
  ]);
28
28
  export const CREATE_CAPABILITY_TABLE = Object.freeze({
@@ -92,7 +92,7 @@ function supportedTuples(identity) {
92
92
  }
93
93
  /**
94
94
  * Compares all mandatory tool identity fields without ignoring patch versions.
95
- * @param left - Recorded reference-host identity.
95
+ * @param left - Recorded certification identity.
96
96
  * @param right - Current executing identity.
97
97
  * @returns Whether every mandatory field matches.
98
98
  */
@@ -1,4 +1,4 @@
1
- /** Describes exact creation tuples and their reference-host package, tool and template evidence identities. */
1
+ /** Describes exact creation tuples and their recorded package, tool and template evidence identities. */
2
2
  import type { CreateOptions } from "./options.js";
3
3
  /** Complete public creation combination; absence of jobs preserves the native no-jobs option. */
4
4
  export interface CreateCapabilityTuple {
@@ -30,7 +30,7 @@ export interface CreateCapabilityIdentity {
30
30
  }
31
31
  /** Offered tuple backed by complete fresh and restart measurements for its template bytes. */
32
32
  export interface CreateCapabilityEvidence extends CreateCapabilityTuple {
33
- /** Exact tool and package catalog identity measured by the reference host. */
33
+ /** Exact tool and package catalog identity measured by the recorded certification host. */
34
34
  readonly identity: CreateCapabilityIdentity;
35
35
  /** SHA-256 over ordered template paths and their complete bytes. */
36
36
  readonly templateDigest: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create-capabilities.types.d.ts","sourceRoot":"","sources":["../src/create-capabilities.types.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,OAAO,KAAK,EAAE,aAAa,EAAE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AC;CACnC;AAED,8FAA8F;AAC9F,MAAM,WAAW,wBAAyB,SAAQ,qBAAqB;IACrE,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IAC5C,oEAAoE;IACpE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,oFAAoF;AACpF,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render-database-sources.d.ts","sourceRoot":"","sources":["../src/render-database-sources.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAiBtE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CA0BlE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAkBxF"}
1
+ {"version":3,"file":"render-database-sources.d.ts","sourceRoot":"","sources":["../src/render-database-sources.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAiBtE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CA0BlE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAkBxF"}
@@ -1,3 +1,4 @@
1
+ import { dirname } from "node:path";
1
2
  /**
2
3
  * Renders database Service Source as source text without executing user modules.
3
4
  * @param dialect - Supported database dialect.
@@ -6,9 +7,9 @@
6
7
  export function databaseServiceSource(dialect) {
7
8
  const sqlite = dialect === "sqlite";
8
9
  const client = sqlite
9
- ? `const sqlite = new Database(env.DATABASE_PATH);\n return drizzle({ client: sqlite });`
10
+ ? `const path = env.DATABASE_PATH;\n if (!path) throw new Error("DATABASE_PATH is required");\n mkdirSync(dirname(path), { recursive: true });\n const sqlite = new Database(path);\n return drizzle({ client: sqlite });`
10
11
  : `const url = env.DATABASE_URL;\n if (!url) throw new Error("DATABASE_URL is required");\n return drizzle.${dialect === "postgresql" ? "postgres" : "mysql"}(url);`;
11
- return `${sqlite ? `import { Database } from "bun:sqlite";\n` : ""}import { defineDrizzleService } from "@relkit/drizzle";
12
+ return `${sqlite ? `import { Database } from "bun:sqlite";\nimport { mkdirSync } from "node:fs";\nimport { dirname } from "node:path";\n` : ""}import { defineDrizzleService } from "@relkit/drizzle";
12
13
  import { drizzle } from "drizzle-orm/${sqlite ? "bun-sqlite" : "bun-sql"}";
13
14
  import * as schema from "./schema/index.js";
14
15
 
@@ -73,7 +74,7 @@ if (${value} === undefined || ${value}.trim() === ""${invalid}) {
73
74
  export default defineConfig({
74
75
  schema: "./${schemaPath}",
75
76
  dialect: "${dialect}",
76
- out: "./drizzle",
77
+ out: "./${dirname(dirname(schemaPath))}/migrations",
77
78
  dbCredentials: { url: ${value} },
78
79
  });
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,KAAK,QAAQ,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,OAAO;;QAED,KAAK,kBAAkB,QAAQ;MACjC,KAAK,qBAAqB,KAAK,iBAAiB,OAAO;yBACpC,QAAQ;;;;eAIlB,UAAU;cACX,OAAO;YACT,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;0BACd,KAAK;;CAE9B,CAAC;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render-database.d.ts","sourceRoot":"","sources":["../src/render-database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAuC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAShD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;mGA4DhC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GACjD,OAAO,CAAC,gBAAgB,CAAC,CAE3B"}
1
+ {"version":3,"file":"render-database.d.ts","sourceRoot":"","sources":["../src/render-database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAuC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAShD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;mGA2DhC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GACjD,OAAO,CAAC,gBAAgB,CAAC,CAE3B"}
@@ -35,10 +35,9 @@ export const renderDatabaseEffect = Effect.fn("Scaffold.renderDatabase")(functio
35
35
  yield* builder.dependencyEffect(dependency);
36
36
  }
37
37
  yield* builder.scriptEffect("db:generate", "bun --bun drizzle-kit generate");
38
- yield* builder.scriptEffect("db:migrate", "bun --bun drizzle-kit migrate");
39
- yield* builder.gitignoreEffect("/drizzle/");
38
+ yield* builder.scriptEffect("db:migrate", "relkit db migrate");
40
39
  if (request.dialect === "sqlite") {
41
- yield* ensureEnvironmentEffect(builder, "DATABASE_PATH", `env.string().default("./app.sqlite")`, "./app.sqlite");
40
+ yield* ensureEnvironmentEffect(builder, "DATABASE_PATH", `env.string().default("./.relkit/state/app.sqlite")`, "./.relkit/state/app.sqlite");
42
41
  yield* builder.gitignoreEffect("*.sqlite");
43
42
  yield* builder.gitignoreEffect("*.sqlite-*");
44
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"render-database.js","sourceRoot":"","sources":["../src/render-database.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,E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;QAC/C,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,UAAU;QACnB,EAAE,EAAE,UAAU;KACf,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AAC/D,CAAC,EACD,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,yBAAyB,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAC7F,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAoB,EACpB,OAAkD;IAElD,OAAO,mBAAmB,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC"}
@@ -8,6 +8,6 @@ scaffolder:
8
8
  - `agent` — the minimal example plus a read-only tool and agent descriptor.
9
9
 
10
10
  Each variant is self-contained and can be copied as a project root. It uses
11
- the current checked-in RelKit package version (`0.7.6`), Bun `1.3.10`, and
11
+ the current checked-in RelKit package version (`0.7.8`), Bun `1.3.10`, and
12
12
  TypeScript `5.9.3`. The generator owns project-name substitution and later
13
13
  installation/Git behavior.
@@ -7,6 +7,20 @@ description: Build or extend a RELKIT CLI-generated application using its instal
7
7
 
8
8
  Run commands from the generated application's root, where `relkit.config.ts` and `package.json` live. Use `bun run relkit` to invoke the project's installed CLI. Check `bun run relkit <command> --help` before relying on an option, especially after a dependency upgrade.
9
9
 
10
+ ## Understand the requested work
11
+
12
+ Infer the intent from the request; do not ask the user to classify it.
13
+
14
+ - For a feature, establish the problem, scope, expected behavior and acceptance criteria. Explain a short implementation and verification plan before editing, then proceed with the authorized work.
15
+ - For a bug, establish expected versus actual behavior, attempt reproduction, and trace the affected execution path. Distinguish a confirmed cause from a hypothesis, and explain the proposed fix and verification before editing. Report unavailable reproduction honestly.
16
+ - For a discussion, explain options, tradeoffs and a recommendation without changing files. For mixed requests, keep the discussion portion read-only and implement only the requested work.
17
+
18
+ Before scaffolding a new app, establish the database engine and driver (or an explicit no-database choice) and whether authentication is needed. Ask missing choices together before writing files. Reuse supplied choices and existing project decisions; do not restart onboarding for an unrelated bug or small change. If requested auth needs persistence but the user chose no database, explain and resolve that conflict before scaffolding. Use supported create/add options; do not invent database/auth creation flags or change headless defaults.
19
+
20
+ Recommend optional modules only when they solve a concrete part of this task: for example, realtime for live order status or a bucket for uploads. Explain the benefit and ask for a selection when the capability was not requested. For an explicitly requested capability, resolve only missing provider/configuration decisions. Check installed CLI help and declarations for support; explain unavailable options before editing. A plan is not another permission gate for work already authorized.
21
+
22
+ Default to backend work. Do not introduce frontend pages, app.js, assets.css or demo interfaces unless requested. Preserve existing frontend files, explicitly selected fullstack functionality and the framework Inspector. For users and orders, define separate resource endpoints with explicit input/output contracts, validation and applicable authorization; avoid a public table dispatcher controlled by an entity parameter. Internal tables and infrastructure services need no public endpoint. Preserve intentional protocol handlers such as the Better Auth mount and shared internal helpers.
23
+
10
24
  ## Source placement
11
25
 
12
26
  New projects place every generic, database, and auth boundary at `src/services/<name>/service.ts`. Keep its functions, events, tasks, jobs, tools, agents, channels, schemas, resources, helpers, and assets under that service. Routes live at `src/routes`; configuration support and environment contracts live at `src/platform`. Application descriptors use plain TypeScript and supported public APIs; Effect imports are not required.
@@ -45,4 +59,6 @@ Read only the reference relevant to the requested change. These examples describ
45
59
 
46
60
  ## Verify the result
47
61
 
48
- Review the CLI's created and updated files, warnings, and next steps. Run `bun run check`, `bun run typecheck`, and focused tests after editing. For HTTP work, exercise the route itself; a direct function test does not cover request mapping. Database and auth work also needs the reported environment and migration steps before runtime verification.
62
+ Review the CLI's created and updated files, warnings, next steps and final diff. Run focused checks after logical changes. Before completion, run applicable check, typecheck, build, unit/integration tests and existing relevant end-to-end coverage. Inspect package.json for actual script names. For HTTP work, test the route's status/body, valid and invalid input, and denied and allowed access where relevant; a direct function test does not cover request mapping or the complete flow. Replay the original bug through the boundary that failed. Backend/API tests do not require an unsolicited frontend.
63
+
64
+ Database/auth changes also need explicit environment setup and migration steps from [the data reference](references/data-apis.md), followed by persistence/session/authorization verification. Stop all test-owned servers and clients. Report what changed, exact verification performed, and every failed, skipped or blocked check with its effect on confidence. Written code or passing unit tests alone is not fully verified delivery when affected runtime behavior remains untested.
@@ -24,6 +24,13 @@ These examples use the local binary through `bun run relkit`. The installed CLI'
24
24
 
25
25
  Database `--dialect` and auth `--database-dialect` also accept `postgresql` and `mysql`. Auth's `--base-path` changes the default `/api/auth` mount. The CLI adds dependencies and an environment example as needed, but it does not apply database migrations or populate secrets. Follow the scaffold's reported next steps after reviewing the schema and environment values.
26
26
 
27
+ Run `bun run db:generate`, review tracked SQL/metadata under the database service's
28
+ `migrations` directory, then explicitly run `bun run db:migrate`. The latter uses
29
+ installed `relkit db migrate`, defaulting to root `drizzle.config.ts`; select another
30
+ with `bun run relkit db migrate --config <path>`. Configuration owns the target,
31
+ history and supported log settings; relative paths use the app root. No copied
32
+ runner is needed. See [database tooling](data-apis.md) for environment and failure behavior.
33
+
27
34
  ## Other add kinds
28
35
 
29
36
  Run `bun run relkit add <kind> --help` for each kind's flags and requirements:
@@ -30,6 +30,22 @@ export default defineDrizzleService({
30
30
 
31
31
  Open the native connection in the `client({ env })` factory and close it with `dispose` when needed. Discovery does not run the factory. Generate and review migrations with the installed Drizzle tooling; service creation does not create tables or apply migrations. After `bun run check`, generated context declarations provide typed `context.database`.
32
32
 
33
+ ## Version and apply migration source
34
+
35
+ New grouped scaffolds configure `src/services/database/migrations` beside the database service and schema. Keep SQL and required Drizzle metadata in Git, outside ignored `.relkit/`. One shared database has one ordered history, including authentication tables; do not create separate histories for business services. Existing flat apps retain their selected database service directory.
36
+
37
+ Set the required environment in the application root's `.env` or shell, then run:
38
+
39
+ ```sh
40
+ bun run db:generate
41
+ # Review the generated SQL and metadata before applying them.
42
+ bun run db:migrate
43
+ ```
44
+
45
+ `db:generate` uses the installed Drizzle Kit. `db:migrate` invokes installed RELKIT tooling, `relkit db migrate`, without copying a runner into the app. Root `drizzle.config.ts` explicitly owns dialect, schema, migration output, connection and supported log options. To select another config, use `bun run relkit db migrate --config configs/database.ts`; relative output/database paths still use the application root. Keep delegated PostgreSQL/MySQL config deterministic because Kit loads it again. Existing shell variables take precedence over Bun's normal dotenv loading; `.env.example` is documentation only.
46
+
47
+ Migration applies pending SQL only when explicitly invoked; scaffolding and service startup do not apply it, generate secrets or open the database. SQLite uses the Bun-native driver. PostgreSQL/MySQL delegate to the app's installed Kit under Bun. Missing/empty/incompatible history requires generation or a compatible ORM/Kit pair, not a reset or fallback directory. Review failures before another manual run: SQL is not automatically retried, and dialect-specific partial DDL is not guaranteed to roll back. Keep the generated dependency patch and registration while required by the installed release.
48
+
33
49
  ## `defineBetterAuthService`
34
50
 
35
51
  ```ts
@@ -31,6 +31,8 @@ export default defineService({ functions: { greet } });
31
31
 
32
32
  The service also accepts `events`, `tasks`, and `jobs` maps. Its members appear directly as `service.greet`; there is no `service.functions.greet` namespace. Membership makes a function available across domains, but does not create an HTTP route or grant authorization.
33
33
 
34
+ Each `service.ts` constructs and exports exactly one runtime service value. Keep ordinary helpers and error descriptors inside their owning domain; expose callable operations through the service's `functions` map. Do not re-export helpers or descriptors from a specialized database or auth `service.ts`.
35
+
34
36
  Within a domain, import a sibling function directly. Across domains and from routes, import the other domain's `service.ts`. Invoke a function descriptor with `await service.greet.invoke(input)`; do not call its handler directly. Leave an internal function out of the service map. Tools, agents, caches, buckets, and event-only functions are not service members.
35
37
 
36
38
  ## `defineEvent` and `defineEventFunction`
@@ -89,4 +91,21 @@ export default defineError({
89
91
  });
90
92
  ```
91
93
 
92
- Declare only expected failures callers should handle on a function. Use the route layer for HTTP-specific request mapping and middleware.
94
+ Declare only expected failures callers should handle on a function. Return each declared error through the public `fail` helper so it appears in the inferred handler result; throwing a declared error from an ordinary helper does not satisfy that contract. Use the route layer for HTTP-specific request mapping and middleware.
95
+
96
+ ```ts
97
+ import { defineFunction, fail } from "@relkit/app/functions";
98
+ import { z } from "@relkit/app/schema";
99
+ import AuthenticationRequired from "../errors/authentication-required.error.js";
100
+
101
+ export default defineFunction({
102
+ input: z.object({}),
103
+ output: z.object({ id: z.string() }),
104
+ errors: [AuthenticationRequired],
105
+ handler: async (_input, context) => {
106
+ const session = await context.auth.getSession();
107
+ if (session === null) return fail(AuthenticationRequired, {});
108
+ return { id: session.user.id };
109
+ },
110
+ });
111
+ ```
@@ -2,9 +2,6 @@ node_modules/
2
2
  .env
3
3
  .env.*
4
4
  !.env.example
5
- .relkit/generated/
6
- .relkit/build/
7
- .relkit/state/
8
- .relkit/observability/
5
+ .relkit/
9
6
  coverage/
10
7
  dist/
@@ -16,15 +16,15 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@langchain/langgraph": "1.4.14",
19
- "@relkit/app": "0.7.6",
20
- "@relkit/local": "0.7.6",
19
+ "@relkit/app": "0.7.8",
20
+ "@relkit/local": "0.7.8",
21
21
  "effect": "4.0.1",
22
22
  "langchain": "1.5.10"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/bun": "1.3.10",
26
- "@relkit/cli": "0.7.6",
27
- "@relkit/testing": "0.7.6",
26
+ "@relkit/cli": "0.7.8",
27
+ "@relkit/testing": "0.7.8",
28
28
  "typescript": "5.9.3"
29
29
  }
30
30
  }
@@ -19,7 +19,7 @@
19
19
  "skipLibCheck": true,
20
20
  "forceConsistentCasingInFileNames": true
21
21
  },
22
- "files": [".relkit/generated/route-module-checks.ts"],
22
+ "files": [".relkit/generated/route-module-checks.ts", ".relkit/generated/context-registry.d.ts"],
23
23
  "include": ["src/**/*.ts", "tests/**/*.ts", "relkit.config.ts"],
24
24
  "exclude": ["node_modules", ".relkit"]
25
25
  }
@@ -7,6 +7,20 @@ description: Build or extend a RELKIT CLI-generated application using its instal
7
7
 
8
8
  Run commands from the generated application's root, where `relkit.config.ts` and `package.json` live. Use `bun run relkit` to invoke the project's installed CLI. Check `bun run relkit <command> --help` before relying on an option, especially after a dependency upgrade.
9
9
 
10
+ ## Understand the requested work
11
+
12
+ Infer the intent from the request; do not ask the user to classify it.
13
+
14
+ - For a feature, establish the problem, scope, expected behavior and acceptance criteria. Explain a short implementation and verification plan before editing, then proceed with the authorized work.
15
+ - For a bug, establish expected versus actual behavior, attempt reproduction, and trace the affected execution path. Distinguish a confirmed cause from a hypothesis, and explain the proposed fix and verification before editing. Report unavailable reproduction honestly.
16
+ - For a discussion, explain options, tradeoffs and a recommendation without changing files. For mixed requests, keep the discussion portion read-only and implement only the requested work.
17
+
18
+ Before scaffolding a new app, establish the database engine and driver (or an explicit no-database choice) and whether authentication is needed. Ask missing choices together before writing files. Reuse supplied choices and existing project decisions; do not restart onboarding for an unrelated bug or small change. If requested auth needs persistence but the user chose no database, explain and resolve that conflict before scaffolding. Use supported create/add options; do not invent database/auth creation flags or change headless defaults.
19
+
20
+ Recommend optional modules only when they solve a concrete part of this task: for example, realtime for live order status or a bucket for uploads. Explain the benefit and ask for a selection when the capability was not requested. For an explicitly requested capability, resolve only missing provider/configuration decisions. Check installed CLI help and declarations for support; explain unavailable options before editing. A plan is not another permission gate for work already authorized.
21
+
22
+ Default to backend work. Do not introduce frontend pages, app.js, assets.css or demo interfaces unless requested. Preserve existing frontend files, explicitly selected fullstack functionality and the framework Inspector. For users and orders, define separate resource endpoints with explicit input/output contracts, validation and applicable authorization; avoid a public table dispatcher controlled by an entity parameter. Internal tables and infrastructure services need no public endpoint. Preserve intentional protocol handlers such as the Better Auth mount and shared internal helpers.
23
+
10
24
  ## Source placement
11
25
 
12
26
  New projects place every generic, database, and auth boundary at `src/services/<name>/service.ts`. Keep its functions, events, tasks, jobs, tools, agents, channels, schemas, resources, helpers, and assets under that service. Routes live at `src/routes`; configuration support and environment contracts live at `src/platform`. Application descriptors use plain TypeScript and supported public APIs; Effect imports are not required.
@@ -45,4 +59,6 @@ Read only the reference relevant to the requested change. These examples describ
45
59
 
46
60
  ## Verify the result
47
61
 
48
- Review the CLI's created and updated files, warnings, and next steps. Run `bun run check`, `bun run typecheck`, and focused tests after editing. For HTTP work, exercise the route itself; a direct function test does not cover request mapping. Database and auth work also needs the reported environment and migration steps before runtime verification.
62
+ Review the CLI's created and updated files, warnings, next steps and final diff. Run focused checks after logical changes. Before completion, run applicable check, typecheck, build, unit/integration tests and existing relevant end-to-end coverage. Inspect package.json for actual script names. For HTTP work, test the route's status/body, valid and invalid input, and denied and allowed access where relevant; a direct function test does not cover request mapping or the complete flow. Replay the original bug through the boundary that failed. Backend/API tests do not require an unsolicited frontend.
63
+
64
+ Database/auth changes also need explicit environment setup and migration steps from [the data reference](references/data-apis.md), followed by persistence/session/authorization verification. Stop all test-owned servers and clients. Report what changed, exact verification performed, and every failed, skipped or blocked check with its effect on confidence. Written code or passing unit tests alone is not fully verified delivery when affected runtime behavior remains untested.
@@ -24,6 +24,13 @@ These examples use the local binary through `bun run relkit`. The installed CLI'
24
24
 
25
25
  Database `--dialect` and auth `--database-dialect` also accept `postgresql` and `mysql`. Auth's `--base-path` changes the default `/api/auth` mount. The CLI adds dependencies and an environment example as needed, but it does not apply database migrations or populate secrets. Follow the scaffold's reported next steps after reviewing the schema and environment values.
26
26
 
27
+ Run `bun run db:generate`, review tracked SQL/metadata under the database service's
28
+ `migrations` directory, then explicitly run `bun run db:migrate`. The latter uses
29
+ installed `relkit db migrate`, defaulting to root `drizzle.config.ts`; select another
30
+ with `bun run relkit db migrate --config <path>`. Configuration owns the target,
31
+ history and supported log settings; relative paths use the app root. No copied
32
+ runner is needed. See [database tooling](data-apis.md) for environment and failure behavior.
33
+
27
34
  ## Other add kinds
28
35
 
29
36
  Run `bun run relkit add <kind> --help` for each kind's flags and requirements:
@@ -30,6 +30,22 @@ export default defineDrizzleService({
30
30
 
31
31
  Open the native connection in the `client({ env })` factory and close it with `dispose` when needed. Discovery does not run the factory. Generate and review migrations with the installed Drizzle tooling; service creation does not create tables or apply migrations. After `bun run check`, generated context declarations provide typed `context.database`.
32
32
 
33
+ ## Version and apply migration source
34
+
35
+ New grouped scaffolds configure `src/services/database/migrations` beside the database service and schema. Keep SQL and required Drizzle metadata in Git, outside ignored `.relkit/`. One shared database has one ordered history, including authentication tables; do not create separate histories for business services. Existing flat apps retain their selected database service directory.
36
+
37
+ Set the required environment in the application root's `.env` or shell, then run:
38
+
39
+ ```sh
40
+ bun run db:generate
41
+ # Review the generated SQL and metadata before applying them.
42
+ bun run db:migrate
43
+ ```
44
+
45
+ `db:generate` uses the installed Drizzle Kit. `db:migrate` invokes installed RELKIT tooling, `relkit db migrate`, without copying a runner into the app. Root `drizzle.config.ts` explicitly owns dialect, schema, migration output, connection and supported log options. To select another config, use `bun run relkit db migrate --config configs/database.ts`; relative output/database paths still use the application root. Keep delegated PostgreSQL/MySQL config deterministic because Kit loads it again. Existing shell variables take precedence over Bun's normal dotenv loading; `.env.example` is documentation only.
46
+
47
+ Migration applies pending SQL only when explicitly invoked; scaffolding and service startup do not apply it, generate secrets or open the database. SQLite uses the Bun-native driver. PostgreSQL/MySQL delegate to the app's installed Kit under Bun. Missing/empty/incompatible history requires generation or a compatible ORM/Kit pair, not a reset or fallback directory. Review failures before another manual run: SQL is not automatically retried, and dialect-specific partial DDL is not guaranteed to roll back. Keep the generated dependency patch and registration while required by the installed release.
48
+
33
49
  ## `defineBetterAuthService`
34
50
 
35
51
  ```ts
@@ -31,6 +31,8 @@ export default defineService({ functions: { greet } });
31
31
 
32
32
  The service also accepts `events`, `tasks`, and `jobs` maps. Its members appear directly as `service.greet`; there is no `service.functions.greet` namespace. Membership makes a function available across domains, but does not create an HTTP route or grant authorization.
33
33
 
34
+ Each `service.ts` constructs and exports exactly one runtime service value. Keep ordinary helpers and error descriptors inside their owning domain; expose callable operations through the service's `functions` map. Do not re-export helpers or descriptors from a specialized database or auth `service.ts`.
35
+
34
36
  Within a domain, import a sibling function directly. Across domains and from routes, import the other domain's `service.ts`. Invoke a function descriptor with `await service.greet.invoke(input)`; do not call its handler directly. Leave an internal function out of the service map. Tools, agents, caches, buckets, and event-only functions are not service members.
35
37
 
36
38
  ## `defineEvent` and `defineEventFunction`
@@ -89,4 +91,21 @@ export default defineError({
89
91
  });
90
92
  ```
91
93
 
92
- Declare only expected failures callers should handle on a function. Use the route layer for HTTP-specific request mapping and middleware.
94
+ Declare only expected failures callers should handle on a function. Return each declared error through the public `fail` helper so it appears in the inferred handler result; throwing a declared error from an ordinary helper does not satisfy that contract. Use the route layer for HTTP-specific request mapping and middleware.
95
+
96
+ ```ts
97
+ import { defineFunction, fail } from "@relkit/app/functions";
98
+ import { z } from "@relkit/app/schema";
99
+ import AuthenticationRequired from "../errors/authentication-required.error.js";
100
+
101
+ export default defineFunction({
102
+ input: z.object({}),
103
+ output: z.object({ id: z.string() }),
104
+ errors: [AuthenticationRequired],
105
+ handler: async (_input, context) => {
106
+ const session = await context.auth.getSession();
107
+ if (session === null) return fail(AuthenticationRequired, {});
108
+ return { id: session.user.id };
109
+ },
110
+ });
111
+ ```
@@ -2,9 +2,6 @@ node_modules/
2
2
  .env
3
3
  .env.*
4
4
  !.env.example
5
- .relkit/generated/
6
- .relkit/build/
7
- .relkit/state/
8
- .relkit/observability/
5
+ .relkit/
9
6
  coverage/
10
7
  dist/
@@ -15,13 +15,13 @@
15
15
  "graph": "relkit graph print"
16
16
  },
17
17
  "dependencies": {
18
- "@relkit/app": "0.7.6",
18
+ "@relkit/app": "0.7.8",
19
19
  "effect": "4.0.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/bun": "1.3.10",
23
- "@relkit/cli": "0.7.6",
24
- "@relkit/testing": "0.7.6",
23
+ "@relkit/cli": "0.7.8",
24
+ "@relkit/testing": "0.7.8",
25
25
  "typescript": "5.9.3"
26
26
  }
27
27
  }
@@ -19,7 +19,7 @@
19
19
  "skipLibCheck": true,
20
20
  "forceConsistentCasingInFileNames": true
21
21
  },
22
- "files": [".relkit/generated/route-module-checks.ts"],
22
+ "files": [".relkit/generated/route-module-checks.ts", ".relkit/generated/context-registry.d.ts"],
23
23
  "include": ["src/**/*.ts", "tests/**/*.ts", "relkit.config.ts"],
24
24
  "exclude": ["node_modules", ".relkit"]
25
25
  }
@@ -7,6 +7,20 @@ description: Build or extend a RELKIT CLI-generated application using its instal
7
7
 
8
8
  Run commands from the generated application's root, where `relkit.config.ts` and `package.json` live. Use `bun run relkit` to invoke the project's installed CLI. Check `bun run relkit <command> --help` before relying on an option, especially after a dependency upgrade.
9
9
 
10
+ ## Understand the requested work
11
+
12
+ Infer the intent from the request; do not ask the user to classify it.
13
+
14
+ - For a feature, establish the problem, scope, expected behavior and acceptance criteria. Explain a short implementation and verification plan before editing, then proceed with the authorized work.
15
+ - For a bug, establish expected versus actual behavior, attempt reproduction, and trace the affected execution path. Distinguish a confirmed cause from a hypothesis, and explain the proposed fix and verification before editing. Report unavailable reproduction honestly.
16
+ - For a discussion, explain options, tradeoffs and a recommendation without changing files. For mixed requests, keep the discussion portion read-only and implement only the requested work.
17
+
18
+ Before scaffolding a new app, establish the database engine and driver (or an explicit no-database choice) and whether authentication is needed. Ask missing choices together before writing files. Reuse supplied choices and existing project decisions; do not restart onboarding for an unrelated bug or small change. If requested auth needs persistence but the user chose no database, explain and resolve that conflict before scaffolding. Use supported create/add options; do not invent database/auth creation flags or change headless defaults.
19
+
20
+ Recommend optional modules only when they solve a concrete part of this task: for example, realtime for live order status or a bucket for uploads. Explain the benefit and ask for a selection when the capability was not requested. For an explicitly requested capability, resolve only missing provider/configuration decisions. Check installed CLI help and declarations for support; explain unavailable options before editing. A plan is not another permission gate for work already authorized.
21
+
22
+ Default to backend work. Do not introduce frontend pages, app.js, assets.css or demo interfaces unless requested. Preserve existing frontend files, explicitly selected fullstack functionality and the framework Inspector. For users and orders, define separate resource endpoints with explicit input/output contracts, validation and applicable authorization; avoid a public table dispatcher controlled by an entity parameter. Internal tables and infrastructure services need no public endpoint. Preserve intentional protocol handlers such as the Better Auth mount and shared internal helpers.
23
+
10
24
  ## Source placement
11
25
 
12
26
  New projects place every generic, database, and auth boundary at `src/services/<name>/service.ts`. Keep its functions, events, tasks, jobs, tools, agents, channels, schemas, resources, helpers, and assets under that service. Routes live at `src/routes`; configuration support and environment contracts live at `src/platform`. Application descriptors use plain TypeScript and supported public APIs; Effect imports are not required.
@@ -45,4 +59,6 @@ Read only the reference relevant to the requested change. These examples describ
45
59
 
46
60
  ## Verify the result
47
61
 
48
- Review the CLI's created and updated files, warnings, and next steps. Run `bun run check`, `bun run typecheck`, and focused tests after editing. For HTTP work, exercise the route itself; a direct function test does not cover request mapping. Database and auth work also needs the reported environment and migration steps before runtime verification.
62
+ Review the CLI's created and updated files, warnings, next steps and final diff. Run focused checks after logical changes. Before completion, run applicable check, typecheck, build, unit/integration tests and existing relevant end-to-end coverage. Inspect package.json for actual script names. For HTTP work, test the route's status/body, valid and invalid input, and denied and allowed access where relevant; a direct function test does not cover request mapping or the complete flow. Replay the original bug through the boundary that failed. Backend/API tests do not require an unsolicited frontend.
63
+
64
+ Database/auth changes also need explicit environment setup and migration steps from [the data reference](references/data-apis.md), followed by persistence/session/authorization verification. Stop all test-owned servers and clients. Report what changed, exact verification performed, and every failed, skipped or blocked check with its effect on confidence. Written code or passing unit tests alone is not fully verified delivery when affected runtime behavior remains untested.
@@ -24,6 +24,13 @@ These examples use the local binary through `bun run relkit`. The installed CLI'
24
24
 
25
25
  Database `--dialect` and auth `--database-dialect` also accept `postgresql` and `mysql`. Auth's `--base-path` changes the default `/api/auth` mount. The CLI adds dependencies and an environment example as needed, but it does not apply database migrations or populate secrets. Follow the scaffold's reported next steps after reviewing the schema and environment values.
26
26
 
27
+ Run `bun run db:generate`, review tracked SQL/metadata under the database service's
28
+ `migrations` directory, then explicitly run `bun run db:migrate`. The latter uses
29
+ installed `relkit db migrate`, defaulting to root `drizzle.config.ts`; select another
30
+ with `bun run relkit db migrate --config <path>`. Configuration owns the target,
31
+ history and supported log settings; relative paths use the app root. No copied
32
+ runner is needed. See [database tooling](data-apis.md) for environment and failure behavior.
33
+
27
34
  ## Other add kinds
28
35
 
29
36
  Run `bun run relkit add <kind> --help` for each kind's flags and requirements:
@@ -30,6 +30,22 @@ export default defineDrizzleService({
30
30
 
31
31
  Open the native connection in the `client({ env })` factory and close it with `dispose` when needed. Discovery does not run the factory. Generate and review migrations with the installed Drizzle tooling; service creation does not create tables or apply migrations. After `bun run check`, generated context declarations provide typed `context.database`.
32
32
 
33
+ ## Version and apply migration source
34
+
35
+ New grouped scaffolds configure `src/services/database/migrations` beside the database service and schema. Keep SQL and required Drizzle metadata in Git, outside ignored `.relkit/`. One shared database has one ordered history, including authentication tables; do not create separate histories for business services. Existing flat apps retain their selected database service directory.
36
+
37
+ Set the required environment in the application root's `.env` or shell, then run:
38
+
39
+ ```sh
40
+ bun run db:generate
41
+ # Review the generated SQL and metadata before applying them.
42
+ bun run db:migrate
43
+ ```
44
+
45
+ `db:generate` uses the installed Drizzle Kit. `db:migrate` invokes installed RELKIT tooling, `relkit db migrate`, without copying a runner into the app. Root `drizzle.config.ts` explicitly owns dialect, schema, migration output, connection and supported log options. To select another config, use `bun run relkit db migrate --config configs/database.ts`; relative output/database paths still use the application root. Keep delegated PostgreSQL/MySQL config deterministic because Kit loads it again. Existing shell variables take precedence over Bun's normal dotenv loading; `.env.example` is documentation only.
46
+
47
+ Migration applies pending SQL only when explicitly invoked; scaffolding and service startup do not apply it, generate secrets or open the database. SQLite uses the Bun-native driver. PostgreSQL/MySQL delegate to the app's installed Kit under Bun. Missing/empty/incompatible history requires generation or a compatible ORM/Kit pair, not a reset or fallback directory. Review failures before another manual run: SQL is not automatically retried, and dialect-specific partial DDL is not guaranteed to roll back. Keep the generated dependency patch and registration while required by the installed release.
48
+
33
49
  ## `defineBetterAuthService`
34
50
 
35
51
  ```ts
@@ -31,6 +31,8 @@ export default defineService({ functions: { greet } });
31
31
 
32
32
  The service also accepts `events`, `tasks`, and `jobs` maps. Its members appear directly as `service.greet`; there is no `service.functions.greet` namespace. Membership makes a function available across domains, but does not create an HTTP route or grant authorization.
33
33
 
34
+ Each `service.ts` constructs and exports exactly one runtime service value. Keep ordinary helpers and error descriptors inside their owning domain; expose callable operations through the service's `functions` map. Do not re-export helpers or descriptors from a specialized database or auth `service.ts`.
35
+
34
36
  Within a domain, import a sibling function directly. Across domains and from routes, import the other domain's `service.ts`. Invoke a function descriptor with `await service.greet.invoke(input)`; do not call its handler directly. Leave an internal function out of the service map. Tools, agents, caches, buckets, and event-only functions are not service members.
35
37
 
36
38
  ## `defineEvent` and `defineEventFunction`
@@ -89,4 +91,21 @@ export default defineError({
89
91
  });
90
92
  ```
91
93
 
92
- Declare only expected failures callers should handle on a function. Use the route layer for HTTP-specific request mapping and middleware.
94
+ Declare only expected failures callers should handle on a function. Return each declared error through the public `fail` helper so it appears in the inferred handler result; throwing a declared error from an ordinary helper does not satisfy that contract. Use the route layer for HTTP-specific request mapping and middleware.
95
+
96
+ ```ts
97
+ import { defineFunction, fail } from "@relkit/app/functions";
98
+ import { z } from "@relkit/app/schema";
99
+ import AuthenticationRequired from "../errors/authentication-required.error.js";
100
+
101
+ export default defineFunction({
102
+ input: z.object({}),
103
+ output: z.object({ id: z.string() }),
104
+ errors: [AuthenticationRequired],
105
+ handler: async (_input, context) => {
106
+ const session = await context.auth.getSession();
107
+ if (session === null) return fail(AuthenticationRequired, {});
108
+ return { id: session.user.id };
109
+ },
110
+ });
111
+ ```
@@ -1,4 +1,6 @@
1
1
  node_modules
2
2
  .next
3
- .relkit
3
+ .relkit/
4
4
  .env
5
+ .env.*
6
+ !.env.example
@@ -15,9 +15,9 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@langchain/langgraph": "1.4.14",
18
- "@relkit/app": "0.7.6",
19
- "@relkit/client": "0.7.6",
20
- "@relkit/local": "0.7.6",
18
+ "@relkit/app": "0.7.8",
19
+ "@relkit/client": "0.7.8",
20
+ "@relkit/local": "0.7.8",
21
21
  "@tanstack/react-query": "5.102.3",
22
22
  "effect": "4.0.1",
23
23
  "langchain": "1.5.10",
@@ -26,8 +26,8 @@
26
26
  "react-dom": "19.2.8"
27
27
  },
28
28
  "devDependencies": {
29
- "@relkit/cli": "0.7.6",
30
- "@relkit/testing": "0.7.6",
29
+ "@relkit/cli": "0.7.8",
30
+ "@relkit/testing": "0.7.8",
31
31
  "@types/bun": "1.3.10",
32
32
  "@types/react": "19.2.18",
33
33
  "@types/react-dom": "19.2.7",
@@ -18,7 +18,7 @@
18
18
  "noEmit": true,
19
19
  "skipLibCheck": true
20
20
  },
21
- "files": [".relkit/generated/route-module-checks.ts"],
21
+ "files": [".relkit/generated/route-module-checks.ts", ".relkit/generated/context-registry.d.ts"],
22
22
  "include": ["src/**/*.ts", "tests/**/*.ts", "relkit.config.ts"],
23
23
  "exclude": ["node_modules", ".relkit", "web"]
24
24
  }
@@ -7,6 +7,20 @@ description: Build or extend a RELKIT CLI-generated application using its instal
7
7
 
8
8
  Run commands from the generated application's root, where `relkit.config.ts` and `package.json` live. Use `bun run relkit` to invoke the project's installed CLI. Check `bun run relkit <command> --help` before relying on an option, especially after a dependency upgrade.
9
9
 
10
+ ## Understand the requested work
11
+
12
+ Infer the intent from the request; do not ask the user to classify it.
13
+
14
+ - For a feature, establish the problem, scope, expected behavior and acceptance criteria. Explain a short implementation and verification plan before editing, then proceed with the authorized work.
15
+ - For a bug, establish expected versus actual behavior, attempt reproduction, and trace the affected execution path. Distinguish a confirmed cause from a hypothesis, and explain the proposed fix and verification before editing. Report unavailable reproduction honestly.
16
+ - For a discussion, explain options, tradeoffs and a recommendation without changing files. For mixed requests, keep the discussion portion read-only and implement only the requested work.
17
+
18
+ Before scaffolding a new app, establish the database engine and driver (or an explicit no-database choice) and whether authentication is needed. Ask missing choices together before writing files. Reuse supplied choices and existing project decisions; do not restart onboarding for an unrelated bug or small change. If requested auth needs persistence but the user chose no database, explain and resolve that conflict before scaffolding. Use supported create/add options; do not invent database/auth creation flags or change headless defaults.
19
+
20
+ Recommend optional modules only when they solve a concrete part of this task: for example, realtime for live order status or a bucket for uploads. Explain the benefit and ask for a selection when the capability was not requested. For an explicitly requested capability, resolve only missing provider/configuration decisions. Check installed CLI help and declarations for support; explain unavailable options before editing. A plan is not another permission gate for work already authorized.
21
+
22
+ Default to backend work. Do not introduce frontend pages, app.js, assets.css or demo interfaces unless requested. Preserve existing frontend files, explicitly selected fullstack functionality and the framework Inspector. For users and orders, define separate resource endpoints with explicit input/output contracts, validation and applicable authorization; avoid a public table dispatcher controlled by an entity parameter. Internal tables and infrastructure services need no public endpoint. Preserve intentional protocol handlers such as the Better Auth mount and shared internal helpers.
23
+
10
24
  ## Source placement
11
25
 
12
26
  New projects place every generic, database, and auth boundary at `src/services/<name>/service.ts`. Keep its functions, events, tasks, jobs, tools, agents, channels, schemas, resources, helpers, and assets under that service. Routes live at `src/routes`; configuration support and environment contracts live at `src/platform`. Application descriptors use plain TypeScript and supported public APIs; Effect imports are not required.
@@ -45,4 +59,6 @@ Read only the reference relevant to the requested change. These examples describ
45
59
 
46
60
  ## Verify the result
47
61
 
48
- Review the CLI's created and updated files, warnings, and next steps. Run `bun run check`, `bun run typecheck`, and focused tests after editing. For HTTP work, exercise the route itself; a direct function test does not cover request mapping. Database and auth work also needs the reported environment and migration steps before runtime verification.
62
+ Review the CLI's created and updated files, warnings, next steps and final diff. Run focused checks after logical changes. Before completion, run applicable check, typecheck, build, unit/integration tests and existing relevant end-to-end coverage. Inspect package.json for actual script names. For HTTP work, test the route's status/body, valid and invalid input, and denied and allowed access where relevant; a direct function test does not cover request mapping or the complete flow. Replay the original bug through the boundary that failed. Backend/API tests do not require an unsolicited frontend.
63
+
64
+ Database/auth changes also need explicit environment setup and migration steps from [the data reference](references/data-apis.md), followed by persistence/session/authorization verification. Stop all test-owned servers and clients. Report what changed, exact verification performed, and every failed, skipped or blocked check with its effect on confidence. Written code or passing unit tests alone is not fully verified delivery when affected runtime behavior remains untested.
@@ -24,6 +24,13 @@ These examples use the local binary through `bun run relkit`. The installed CLI'
24
24
 
25
25
  Database `--dialect` and auth `--database-dialect` also accept `postgresql` and `mysql`. Auth's `--base-path` changes the default `/api/auth` mount. The CLI adds dependencies and an environment example as needed, but it does not apply database migrations or populate secrets. Follow the scaffold's reported next steps after reviewing the schema and environment values.
26
26
 
27
+ Run `bun run db:generate`, review tracked SQL/metadata under the database service's
28
+ `migrations` directory, then explicitly run `bun run db:migrate`. The latter uses
29
+ installed `relkit db migrate`, defaulting to root `drizzle.config.ts`; select another
30
+ with `bun run relkit db migrate --config <path>`. Configuration owns the target,
31
+ history and supported log settings; relative paths use the app root. No copied
32
+ runner is needed. See [database tooling](data-apis.md) for environment and failure behavior.
33
+
27
34
  ## Other add kinds
28
35
 
29
36
  Run `bun run relkit add <kind> --help` for each kind's flags and requirements:
@@ -30,6 +30,22 @@ export default defineDrizzleService({
30
30
 
31
31
  Open the native connection in the `client({ env })` factory and close it with `dispose` when needed. Discovery does not run the factory. Generate and review migrations with the installed Drizzle tooling; service creation does not create tables or apply migrations. After `bun run check`, generated context declarations provide typed `context.database`.
32
32
 
33
+ ## Version and apply migration source
34
+
35
+ New grouped scaffolds configure `src/services/database/migrations` beside the database service and schema. Keep SQL and required Drizzle metadata in Git, outside ignored `.relkit/`. One shared database has one ordered history, including authentication tables; do not create separate histories for business services. Existing flat apps retain their selected database service directory.
36
+
37
+ Set the required environment in the application root's `.env` or shell, then run:
38
+
39
+ ```sh
40
+ bun run db:generate
41
+ # Review the generated SQL and metadata before applying them.
42
+ bun run db:migrate
43
+ ```
44
+
45
+ `db:generate` uses the installed Drizzle Kit. `db:migrate` invokes installed RELKIT tooling, `relkit db migrate`, without copying a runner into the app. Root `drizzle.config.ts` explicitly owns dialect, schema, migration output, connection and supported log options. To select another config, use `bun run relkit db migrate --config configs/database.ts`; relative output/database paths still use the application root. Keep delegated PostgreSQL/MySQL config deterministic because Kit loads it again. Existing shell variables take precedence over Bun's normal dotenv loading; `.env.example` is documentation only.
46
+
47
+ Migration applies pending SQL only when explicitly invoked; scaffolding and service startup do not apply it, generate secrets or open the database. SQLite uses the Bun-native driver. PostgreSQL/MySQL delegate to the app's installed Kit under Bun. Missing/empty/incompatible history requires generation or a compatible ORM/Kit pair, not a reset or fallback directory. Review failures before another manual run: SQL is not automatically retried, and dialect-specific partial DDL is not guaranteed to roll back. Keep the generated dependency patch and registration while required by the installed release.
48
+
33
49
  ## `defineBetterAuthService`
34
50
 
35
51
  ```ts
@@ -31,6 +31,8 @@ export default defineService({ functions: { greet } });
31
31
 
32
32
  The service also accepts `events`, `tasks`, and `jobs` maps. Its members appear directly as `service.greet`; there is no `service.functions.greet` namespace. Membership makes a function available across domains, but does not create an HTTP route or grant authorization.
33
33
 
34
+ Each `service.ts` constructs and exports exactly one runtime service value. Keep ordinary helpers and error descriptors inside their owning domain; expose callable operations through the service's `functions` map. Do not re-export helpers or descriptors from a specialized database or auth `service.ts`.
35
+
34
36
  Within a domain, import a sibling function directly. Across domains and from routes, import the other domain's `service.ts`. Invoke a function descriptor with `await service.greet.invoke(input)`; do not call its handler directly. Leave an internal function out of the service map. Tools, agents, caches, buckets, and event-only functions are not service members.
35
37
 
36
38
  ## `defineEvent` and `defineEventFunction`
@@ -89,4 +91,21 @@ export default defineError({
89
91
  });
90
92
  ```
91
93
 
92
- Declare only expected failures callers should handle on a function. Use the route layer for HTTP-specific request mapping and middleware.
94
+ Declare only expected failures callers should handle on a function. Return each declared error through the public `fail` helper so it appears in the inferred handler result; throwing a declared error from an ordinary helper does not satisfy that contract. Use the route layer for HTTP-specific request mapping and middleware.
95
+
96
+ ```ts
97
+ import { defineFunction, fail } from "@relkit/app/functions";
98
+ import { z } from "@relkit/app/schema";
99
+ import AuthenticationRequired from "../errors/authentication-required.error.js";
100
+
101
+ export default defineFunction({
102
+ input: z.object({}),
103
+ output: z.object({ id: z.string() }),
104
+ errors: [AuthenticationRequired],
105
+ handler: async (_input, context) => {
106
+ const session = await context.auth.getSession();
107
+ if (session === null) return fail(AuthenticationRequired, {});
108
+ return { id: session.user.id };
109
+ },
110
+ });
111
+ ```
@@ -2,9 +2,6 @@ node_modules/
2
2
  .env
3
3
  .env.*
4
4
  !.env.example
5
- .relkit/generated/
6
- .relkit/build/
7
- .relkit/state/
8
- .relkit/observability/
5
+ .relkit/
9
6
  coverage/
10
7
  dist/
@@ -15,13 +15,13 @@
15
15
  "graph": "relkit graph print"
16
16
  },
17
17
  "dependencies": {
18
- "@relkit/app": "0.7.6",
18
+ "@relkit/app": "0.7.8",
19
19
  "effect": "4.0.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/bun": "1.3.10",
23
- "@relkit/cli": "0.7.6",
24
- "@relkit/testing": "0.7.6",
23
+ "@relkit/cli": "0.7.8",
24
+ "@relkit/testing": "0.7.8",
25
25
  "typescript": "5.9.3"
26
26
  }
27
27
  }
@@ -19,7 +19,7 @@
19
19
  "skipLibCheck": true,
20
20
  "forceConsistentCasingInFileNames": true
21
21
  },
22
- "files": [".relkit/generated/route-module-checks.ts"],
22
+ "files": [".relkit/generated/route-module-checks.ts", ".relkit/generated/context-registry.d.ts"],
23
23
  "include": ["src/**/*.ts", "tests/**/*.ts", "relkit.config.ts"],
24
24
  "exclude": ["node_modules", ".relkit"]
25
25
  }
@@ -7,6 +7,20 @@ description: Build or extend a RELKIT CLI-generated application using its instal
7
7
 
8
8
  Run commands from the generated application's root, where `relkit.config.ts` and `package.json` live. Use `bun run relkit` to invoke the project's installed CLI. Check `bun run relkit <command> --help` before relying on an option, especially after a dependency upgrade.
9
9
 
10
+ ## Understand the requested work
11
+
12
+ Infer the intent from the request; do not ask the user to classify it.
13
+
14
+ - For a feature, establish the problem, scope, expected behavior and acceptance criteria. Explain a short implementation and verification plan before editing, then proceed with the authorized work.
15
+ - For a bug, establish expected versus actual behavior, attempt reproduction, and trace the affected execution path. Distinguish a confirmed cause from a hypothesis, and explain the proposed fix and verification before editing. Report unavailable reproduction honestly.
16
+ - For a discussion, explain options, tradeoffs and a recommendation without changing files. For mixed requests, keep the discussion portion read-only and implement only the requested work.
17
+
18
+ Before scaffolding a new app, establish the database engine and driver (or an explicit no-database choice) and whether authentication is needed. Ask missing choices together before writing files. Reuse supplied choices and existing project decisions; do not restart onboarding for an unrelated bug or small change. If requested auth needs persistence but the user chose no database, explain and resolve that conflict before scaffolding. Use supported create/add options; do not invent database/auth creation flags or change headless defaults.
19
+
20
+ Recommend optional modules only when they solve a concrete part of this task: for example, realtime for live order status or a bucket for uploads. Explain the benefit and ask for a selection when the capability was not requested. For an explicitly requested capability, resolve only missing provider/configuration decisions. Check installed CLI help and declarations for support; explain unavailable options before editing. A plan is not another permission gate for work already authorized.
21
+
22
+ Default to backend work. Do not introduce frontend pages, app.js, assets.css or demo interfaces unless requested. Preserve existing frontend files, explicitly selected fullstack functionality and the framework Inspector. For users and orders, define separate resource endpoints with explicit input/output contracts, validation and applicable authorization; avoid a public table dispatcher controlled by an entity parameter. Internal tables and infrastructure services need no public endpoint. Preserve intentional protocol handlers such as the Better Auth mount and shared internal helpers.
23
+
10
24
  ## Source placement
11
25
 
12
26
  New projects place every generic, database, and auth boundary at `src/services/<name>/service.ts`. Keep its functions, events, tasks, jobs, tools, agents, channels, schemas, resources, helpers, and assets under that service. Routes live at `src/routes`; configuration support and environment contracts live at `src/platform`. Application descriptors use plain TypeScript and supported public APIs; Effect imports are not required.
@@ -45,4 +59,6 @@ Read only the reference relevant to the requested change. These examples describ
45
59
 
46
60
  ## Verify the result
47
61
 
48
- Review the CLI's created and updated files, warnings, and next steps. Run `bun run check`, `bun run typecheck`, and focused tests after editing. For HTTP work, exercise the route itself; a direct function test does not cover request mapping. Database and auth work also needs the reported environment and migration steps before runtime verification.
62
+ Review the CLI's created and updated files, warnings, next steps and final diff. Run focused checks after logical changes. Before completion, run applicable check, typecheck, build, unit/integration tests and existing relevant end-to-end coverage. Inspect package.json for actual script names. For HTTP work, test the route's status/body, valid and invalid input, and denied and allowed access where relevant; a direct function test does not cover request mapping or the complete flow. Replay the original bug through the boundary that failed. Backend/API tests do not require an unsolicited frontend.
63
+
64
+ Database/auth changes also need explicit environment setup and migration steps from [the data reference](references/data-apis.md), followed by persistence/session/authorization verification. Stop all test-owned servers and clients. Report what changed, exact verification performed, and every failed, skipped or blocked check with its effect on confidence. Written code or passing unit tests alone is not fully verified delivery when affected runtime behavior remains untested.
@@ -24,6 +24,13 @@ These examples use the local binary through `bun run relkit`. The installed CLI'
24
24
 
25
25
  Database `--dialect` and auth `--database-dialect` also accept `postgresql` and `mysql`. Auth's `--base-path` changes the default `/api/auth` mount. The CLI adds dependencies and an environment example as needed, but it does not apply database migrations or populate secrets. Follow the scaffold's reported next steps after reviewing the schema and environment values.
26
26
 
27
+ Run `bun run db:generate`, review tracked SQL/metadata under the database service's
28
+ `migrations` directory, then explicitly run `bun run db:migrate`. The latter uses
29
+ installed `relkit db migrate`, defaulting to root `drizzle.config.ts`; select another
30
+ with `bun run relkit db migrate --config <path>`. Configuration owns the target,
31
+ history and supported log settings; relative paths use the app root. No copied
32
+ runner is needed. See [database tooling](data-apis.md) for environment and failure behavior.
33
+
27
34
  ## Other add kinds
28
35
 
29
36
  Run `bun run relkit add <kind> --help` for each kind's flags and requirements:
@@ -30,6 +30,22 @@ export default defineDrizzleService({
30
30
 
31
31
  Open the native connection in the `client({ env })` factory and close it with `dispose` when needed. Discovery does not run the factory. Generate and review migrations with the installed Drizzle tooling; service creation does not create tables or apply migrations. After `bun run check`, generated context declarations provide typed `context.database`.
32
32
 
33
+ ## Version and apply migration source
34
+
35
+ New grouped scaffolds configure `src/services/database/migrations` beside the database service and schema. Keep SQL and required Drizzle metadata in Git, outside ignored `.relkit/`. One shared database has one ordered history, including authentication tables; do not create separate histories for business services. Existing flat apps retain their selected database service directory.
36
+
37
+ Set the required environment in the application root's `.env` or shell, then run:
38
+
39
+ ```sh
40
+ bun run db:generate
41
+ # Review the generated SQL and metadata before applying them.
42
+ bun run db:migrate
43
+ ```
44
+
45
+ `db:generate` uses the installed Drizzle Kit. `db:migrate` invokes installed RELKIT tooling, `relkit db migrate`, without copying a runner into the app. Root `drizzle.config.ts` explicitly owns dialect, schema, migration output, connection and supported log options. To select another config, use `bun run relkit db migrate --config configs/database.ts`; relative output/database paths still use the application root. Keep delegated PostgreSQL/MySQL config deterministic because Kit loads it again. Existing shell variables take precedence over Bun's normal dotenv loading; `.env.example` is documentation only.
46
+
47
+ Migration applies pending SQL only when explicitly invoked; scaffolding and service startup do not apply it, generate secrets or open the database. SQLite uses the Bun-native driver. PostgreSQL/MySQL delegate to the app's installed Kit under Bun. Missing/empty/incompatible history requires generation or a compatible ORM/Kit pair, not a reset or fallback directory. Review failures before another manual run: SQL is not automatically retried, and dialect-specific partial DDL is not guaranteed to roll back. Keep the generated dependency patch and registration while required by the installed release.
48
+
33
49
  ## `defineBetterAuthService`
34
50
 
35
51
  ```ts
@@ -31,6 +31,8 @@ export default defineService({ functions: { greet } });
31
31
 
32
32
  The service also accepts `events`, `tasks`, and `jobs` maps. Its members appear directly as `service.greet`; there is no `service.functions.greet` namespace. Membership makes a function available across domains, but does not create an HTTP route or grant authorization.
33
33
 
34
+ Each `service.ts` constructs and exports exactly one runtime service value. Keep ordinary helpers and error descriptors inside their owning domain; expose callable operations through the service's `functions` map. Do not re-export helpers or descriptors from a specialized database or auth `service.ts`.
35
+
34
36
  Within a domain, import a sibling function directly. Across domains and from routes, import the other domain's `service.ts`. Invoke a function descriptor with `await service.greet.invoke(input)`; do not call its handler directly. Leave an internal function out of the service map. Tools, agents, caches, buckets, and event-only functions are not service members.
35
37
 
36
38
  ## `defineEvent` and `defineEventFunction`
@@ -89,4 +91,21 @@ export default defineError({
89
91
  });
90
92
  ```
91
93
 
92
- Declare only expected failures callers should handle on a function. Use the route layer for HTTP-specific request mapping and middleware.
94
+ Declare only expected failures callers should handle on a function. Return each declared error through the public `fail` helper so it appears in the inferred handler result; throwing a declared error from an ordinary helper does not satisfy that contract. Use the route layer for HTTP-specific request mapping and middleware.
95
+
96
+ ```ts
97
+ import { defineFunction, fail } from "@relkit/app/functions";
98
+ import { z } from "@relkit/app/schema";
99
+ import AuthenticationRequired from "../errors/authentication-required.error.js";
100
+
101
+ export default defineFunction({
102
+ input: z.object({}),
103
+ output: z.object({ id: z.string() }),
104
+ errors: [AuthenticationRequired],
105
+ handler: async (_input, context) => {
106
+ const session = await context.auth.getSession();
107
+ if (session === null) return fail(AuthenticationRequired, {});
108
+ return { id: session.user.id };
109
+ },
110
+ });
111
+ ```
@@ -2,9 +2,6 @@ node_modules/
2
2
  .env
3
3
  .env.*
4
4
  !.env.example
5
- .relkit/generated/
6
- .relkit/build/
7
- .relkit/state/
8
- .relkit/observability/
5
+ .relkit/
9
6
  coverage/
10
7
  dist/
@@ -13,13 +13,13 @@
13
13
  "jobs:trigger": "relkit jobs trigger --job exportOrders --input-file examples/export-orders.json --operation-id example-trigger"
14
14
  },
15
15
  "dependencies": {
16
- "@relkit/app": "0.7.6",
16
+ "@relkit/app": "0.7.8",
17
17
  "effect": "4.0.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/bun": "1.3.10",
21
- "@relkit/cli": "0.7.6",
22
- "@relkit/testing": "0.7.6",
21
+ "@relkit/cli": "0.7.8",
22
+ "@relkit/testing": "0.7.8",
23
23
  "typescript": "5.9.3"
24
24
  }
25
25
  }
@@ -13,6 +13,6 @@
13
13
  "baseUrl": ".",
14
14
  "paths": { "@app/*": ["src/*"] }
15
15
  },
16
- "files": [".relkit/generated/route-module-checks.ts"],
16
+ "files": [".relkit/generated/route-module-checks.ts", ".relkit/generated/context-registry.d.ts"],
17
17
  "include": ["src", "tests", "examples"]
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-relkit",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "Create a RELKIT application from a supported project template.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@clack/prompts": "1.7.0",
47
- "@relkit/compiler": "0.7.6",
47
+ "@relkit/compiler": "0.7.8",
48
48
  "typescript": "5.9.3",
49
49
  "effect": "4.0.1",
50
- "@relkit/contracts": "0.7.6"
50
+ "@relkit/contracts": "0.7.8"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@effect/vitest": "4.0.1",