@specdest/devkit 0.2.2 → 0.3.0

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 (138) hide show
  1. package/README.md +15 -20
  2. package/package.json +4 -4
  3. package/src/canonical-project-operations.js +157 -0
  4. package/src/canonical-project.js +50 -0
  5. package/src/canonical-source.js +114 -0
  6. package/src/cli.js +2 -2
  7. package/src/git-catalog.js +105 -0
  8. package/src/index.js +6 -2
  9. package/src/project-operations.js +65 -6
  10. package/src/remote-installer.js +462 -0
  11. package/src/sync-core.js +20 -7
  12. package/catalog/README.md +0 -11
  13. package/catalog/modules/backend-convex/manifest.json +0 -14
  14. package/catalog/modules/backend-convex-expo/manifest.json +0 -11
  15. package/catalog/modules/backend-supabase/manifest.json +0 -15
  16. package/catalog/modules/backend-supabase-expo/manifest.json +0 -11
  17. package/catalog/modules/checker-runtime/config.ts +0 -25
  18. package/catalog/modules/checker-runtime/fs.ts +0 -48
  19. package/catalog/modules/checker-runtime/manifest.json +0 -29
  20. package/catalog/modules/checker-runtime/runtime.ts +0 -79
  21. package/catalog/modules/devflow/.agents/skills/devflow/SKILL.md +0 -33
  22. package/catalog/modules/devflow/.devflow.json +0 -10
  23. package/catalog/modules/devflow/manifest.json +0 -35
  24. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/SKILL.md +0 -85
  25. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/activeScenario.mjs +0 -130
  26. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs +0 -7
  27. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs +0 -36
  28. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/createActiveScenario.mjs +0 -143
  29. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs +0 -43
  30. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/prompt.mjs +0 -25
  31. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs +0 -66
  32. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs +0 -146
  33. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seed.mjs +0 -56
  34. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs +0 -6
  35. package/catalog/modules/e2e-playwright/docs/e2e-playwright/README.md +0 -103
  36. package/catalog/modules/e2e-playwright/manifest.json +0 -206
  37. package/catalog/modules/e2e-playwright/playwright.e2e.config.ts +0 -39
  38. package/catalog/modules/e2e-playwright/tests/e2e/support/e2ePlaywrightFlow.ts +0 -107
  39. package/catalog/modules/e2e-playwright/tests/e2e/support/fixtures.ts +0 -27
  40. package/catalog/modules/local-log/AGENTS.local-log.md +0 -13
  41. package/catalog/modules/local-log/docs/features/local-logging/README.md +0 -70
  42. package/catalog/modules/local-log/manifest.json +0 -39
  43. package/catalog/modules/local-log/tmp/logs/.gitignore +0 -2
  44. package/catalog/modules/local-log/tools/local-log/README.md +0 -47
  45. package/catalog/modules/local-log/tools/local-log/local-log.mjs +0 -241
  46. package/catalog/modules/stack-common-vite/manifest.json +0 -16
  47. package/catalog/modules/stack-expo-convex/manifest.json +0 -31
  48. package/catalog/modules/stack-expo-supabase/manifest.json +0 -44
  49. package/catalog/modules/stack-vite-convex/manifest.json +0 -32
  50. package/catalog/modules/stack-vite-supabase/manifest.json +0 -45
  51. package/catalog/rules/abac-permissions-convex/SKILL.md +0 -17
  52. package/catalog/rules/abac-permissions-convex/check.ts +0 -87
  53. package/catalog/rules/abac-permissions-convex/manifest.json +0 -33
  54. package/catalog/rules/abac-permissions-supabase/SKILL.md +0 -17
  55. package/catalog/rules/abac-permissions-supabase/check.ts +0 -87
  56. package/catalog/rules/abac-permissions-supabase/manifest.json +0 -33
  57. package/catalog/rules/convex-multi-presentation/SKILL.md +0 -47
  58. package/catalog/rules/convex-multi-presentation/check.ts +0 -205
  59. package/catalog/rules/convex-multi-presentation/manifest.json +0 -47
  60. package/catalog/rules/convex-multi-presentation/policy.ts +0 -261
  61. package/catalog/rules/design-rules/SKILL.md +0 -12
  62. package/catalog/rules/design-rules/check.ts +0 -84
  63. package/catalog/rules/design-rules/config.json +0 -5
  64. package/catalog/rules/design-rules/manifest.json +0 -38
  65. package/catalog/rules/e2e-test-rules/SKILL.md +0 -46
  66. package/catalog/rules/e2e-test-rules/check.ts +0 -145
  67. package/catalog/rules/e2e-test-rules/config.json +0 -32
  68. package/catalog/rules/e2e-test-rules/manifest.json +0 -38
  69. package/catalog/rules/error-handling-rules/SKILL.md +0 -21
  70. package/catalog/rules/error-handling-rules/check.ts +0 -73
  71. package/catalog/rules/error-handling-rules/manifest.json +0 -33
  72. package/catalog/rules/layers-and-contracts/SKILL.md +0 -36
  73. package/catalog/rules/layers-and-contracts/check.ts +0 -266
  74. package/catalog/rules/layers-and-contracts/manifest.json +0 -33
  75. package/catalog/rules/layers-and-contracts-convex/SKILL.md +0 -49
  76. package/catalog/rules/layers-and-contracts-convex/check.ts +0 -289
  77. package/catalog/rules/layers-and-contracts-convex/manifest.json +0 -38
  78. package/catalog/rules/layers-and-contracts-convex/policy.ts +0 -68
  79. package/catalog/rules/layers-and-contracts-supabase/SKILL.md +0 -52
  80. package/catalog/rules/layers-and-contracts-supabase/check.ts +0 -371
  81. package/catalog/rules/layers-and-contracts-supabase/manifest.json +0 -38
  82. package/catalog/rules/layers-and-contracts-supabase/policy.ts +0 -68
  83. package/catalog/rules/module-size-rules/SKILL.md +0 -5
  84. package/catalog/rules/module-size-rules/check.ts +0 -144
  85. package/catalog/rules/module-size-rules/config.json +0 -6
  86. package/catalog/rules/module-size-rules/manifest.json +0 -38
  87. package/catalog/rules/module-size-rules-convex/SKILL.md +0 -5
  88. package/catalog/rules/module-size-rules-convex/check.ts +0 -146
  89. package/catalog/rules/module-size-rules-convex/config.json +0 -6
  90. package/catalog/rules/module-size-rules-convex/manifest.json +0 -38
  91. package/catalog/rules/module-size-rules-supabase/SKILL.md +0 -5
  92. package/catalog/rules/module-size-rules-supabase/check.ts +0 -146
  93. package/catalog/rules/module-size-rules-supabase/config.json +0 -12
  94. package/catalog/rules/module-size-rules-supabase/manifest.json +0 -38
  95. package/catalog/rules/mutation-command-rules/SKILL.md +0 -15
  96. package/catalog/rules/mutation-command-rules/check.ts +0 -30
  97. package/catalog/rules/mutation-command-rules/config.json +0 -19
  98. package/catalog/rules/mutation-command-rules/manifest.json +0 -38
  99. package/catalog/rules/nearby-contracts/SKILL.md +0 -18
  100. package/catalog/rules/nearby-contracts/check.ts +0 -138
  101. package/catalog/rules/nearby-contracts/config.json +0 -10
  102. package/catalog/rules/nearby-contracts/manifest.json +0 -38
  103. package/catalog/rules/no-raw-click-buttons/SKILL.md +0 -5
  104. package/catalog/rules/no-raw-click-buttons/check.ts +0 -37
  105. package/catalog/rules/no-raw-click-buttons/manifest.json +0 -33
  106. package/catalog/rules/public-api-export-barrels/SKILL.md +0 -45
  107. package/catalog/rules/public-api-export-barrels/check.ts +0 -73
  108. package/catalog/rules/public-api-export-barrels/config.json +0 -4
  109. package/catalog/rules/public-api-export-barrels/manifest.json +0 -38
  110. package/catalog/rules/route-tree-fresh/SKILL.md +0 -16
  111. package/catalog/rules/route-tree-fresh/check.ts +0 -66
  112. package/catalog/rules/route-tree-fresh/manifest.json +0 -33
  113. package/catalog/rules/strict-typescript/SKILL.md +0 -3
  114. package/catalog/rules/strict-typescript/check.ts +0 -119
  115. package/catalog/rules/strict-typescript/manifest.json +0 -33
  116. package/catalog/rules/supabase-contracts/SKILL.md +0 -3
  117. package/catalog/rules/supabase-contracts/check.ts +0 -172
  118. package/catalog/rules/supabase-contracts/manifest.json +0 -33
  119. package/catalog/rules/supabase-declarative-schema/SKILL.md +0 -30
  120. package/catalog/rules/supabase-declarative-schema/check.ts +0 -262
  121. package/catalog/rules/supabase-declarative-schema/config.json +0 -8
  122. package/catalog/rules/supabase-declarative-schema/manifest.json +0 -38
  123. package/catalog/rules/tanstack-form-rules/SKILL.md +0 -11
  124. package/catalog/rules/tanstack-form-rules/check.ts +0 -58
  125. package/catalog/rules/tanstack-form-rules/manifest.json +0 -33
  126. package/catalog/rules/unit-test-rules/SKILL.md +0 -55
  127. package/catalog/rules/unit-test-rules/check.ts +0 -132
  128. package/catalog/rules/unit-test-rules/config.json +0 -22
  129. package/catalog/rules/unit-test-rules/manifest.json +0 -38
  130. package/catalog/rules/unit-test-rules-convex/SKILL.md +0 -41
  131. package/catalog/rules/unit-test-rules-convex/check.ts +0 -418
  132. package/catalog/rules/unit-test-rules-convex/manifest.json +0 -33
  133. package/catalog/rules/unit-test-rules-supabase/SKILL.md +0 -40
  134. package/catalog/rules/unit-test-rules-supabase/check.ts +0 -492
  135. package/catalog/rules/unit-test-rules-supabase/manifest.json +0 -33
  136. package/catalog/rules/workstation-controller-rules/SKILL.md +0 -22
  137. package/catalog/rules/workstation-controller-rules/check.ts +0 -108
  138. package/catalog/rules/workstation-controller-rules/manifest.json +0 -33
@@ -1,73 +0,0 @@
1
- import { runtime } from "../shared/runtime.ts";
2
- // oxlint-disable no-console no-await-in-loop
3
- const decoder = new TextDecoder();
4
- const violations: string[] = [];
5
-
6
- const allowedRawErrorDirectories = ["src/shared/errors/"];
7
- const ignoredDirectories = [
8
- "node_modules/",
9
- "dist/",
10
- "coverage/",
11
- "src/routeTree.gen.ts",
12
- "src/__generated__/",
13
- ];
14
- const sourceDirectories = ["src"];
15
-
16
- async function* walk(dir: string): AsyncGenerator<string> {
17
- try {
18
- for await (const entry of runtime.readDir(dir)) {
19
- const path = `${dir}/${entry.name}`;
20
- if (ignoredDirectories.some((ignored) => path.startsWith(ignored))) {
21
- continue;
22
- }
23
- if (entry.isDirectory) yield* walk(path);
24
- if (entry.isFile && /\.(ts|tsx)$/.test(entry.name)) yield path;
25
- }
26
- } catch {
27
- return;
28
- }
29
- }
30
-
31
- function isTestFile(file: string): boolean {
32
- return (
33
- /\.(test|spec|stories)\.(ts|tsx)$/.test(file) ||
34
- file.includes("/tests/") ||
35
- file.startsWith("src/test/") ||
36
- file.includes("/storybook/")
37
- );
38
- }
39
-
40
- function isAllowedRawErrorFile(file: string): boolean {
41
- return isTestFile(file) || allowedRawErrorDirectories.some((dir) => file.startsWith(dir));
42
- }
43
-
44
- function lineNumber(text: string, index: number): number {
45
- return text.slice(0, index).split("\n").length;
46
- }
47
-
48
- for (const dir of sourceDirectories) {
49
- for await (const file of walk(dir)) {
50
- if (isAllowedRawErrorFile(file)) continue;
51
- const text = decoder.decode(await runtime.readFile(file));
52
- const rawErrorPattern = /throw\s+new\s+Error\s*\(/gu;
53
- for (const match of text.matchAll(rawErrorPattern)) {
54
- violations.push(
55
- `${file}:${lineNumber(
56
- text,
57
- match.index ?? 0,
58
- )} use raise(ERROR_CODE) instead of throw new Error()`,
59
- );
60
- }
61
-
62
- const literalThrowPattern = /throw\s+(["'`])/gu;
63
- for (const match of text.matchAll(literalThrowPattern)) {
64
- violations.push(`${file}:${lineNumber(text, match.index ?? 0)} do not throw string literals`);
65
- }
66
- }
67
- }
68
-
69
- if (violations.length) {
70
- console.error(violations.join("\n"));
71
- runtime.exit(1);
72
- }
73
- console.log("error-handling-rules ok");
@@ -1,33 +0,0 @@
1
- {
2
- "id": "error-handling-rules",
3
- "kind": "rule",
4
- "version": "1.0.5",
5
- "requires": [
6
- "checker-runtime"
7
- ],
8
- "artifacts": [
9
- {
10
- "kind": "managed-file",
11
- "path": ".agents/skills/error-handling-rules/SKILL.md",
12
- "source": "SKILL.md"
13
- },
14
- {
15
- "kind": "managed-file",
16
- "path": ".agents/skills/error-handling-rules/check.ts",
17
- "source": "check.ts"
18
- },
19
- {
20
- "kind": "shared-markdown-section",
21
- "path": "AGENTS.md",
22
- "heading": "## Specdest rule: error-handling-rules",
23
- "body": "Use `.agents/skills/error-handling-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/error-handling-rules/check.ts` before handoff."
24
- }
25
- ],
26
- "obsolete": [],
27
- "check": {
28
- "command": [
29
- "node",
30
- ".agents/skills/error-handling-rules/check.ts"
31
- ]
32
- }
33
- }
@@ -1,36 +0,0 @@
1
- # Layers and contracts
2
-
3
- Use page-local architecture for route work.
4
-
5
- Required shape:
6
-
7
- - routes own URL params/search and render containers
8
- - containers orchestrate hooks and UI only
9
- - UI renders visible elements only
10
- - UI-hooks own form/behavior mapping
11
- - data-hooks call Convex React hooks and map page data contracts
12
- - data-hooks call only the shared public Convex API; backend business logic must not leak into presentation
13
- - Convex backend layering is governed by `.agents/skills/convex-multi-presentation/SKILL.md` (`API -> Application -> Domain/DAL -> integrations/DB`)
14
-
15
- Enforced guardrails:
16
-
17
- - route, container, UI, and UI-hook files must not import legacy `@/dal`
18
- - data-hooks must call Convex through `useQuery`, `useMutation`, or `useAction` from `convex/react`
19
- - data-hooks must not import UI or container layers
20
- - placeholder/static page data belongs in UI-hooks or presentation view-models, not data-hooks
21
-
22
- Boundary files use Zod schemas:
23
-
24
- - `*.input.schema.ts`
25
- - `*.output.schema.ts`
26
- - `*.form.schema.ts`
27
-
28
- Types at boundaries must be inferred from Zod schemas with `z.infer<typeof schema>`.
29
-
30
- Form contract rules:
31
-
32
- - Shared visual form UI is allowed when create/new and edit pages intentionally look the same.
33
- - Do not share create/new and edit form contracts blindly. Each operation must choose an explicit schema/hook, such as `useResourceCreateForm.form.schema.ts` and `useResourceEditForm.form.schema.ts`, or clearly named equivalents.
34
- - Shared base schemas are allowed only for common fields. Compose create/edit schemas from the base so divergent rules stay visible.
35
- - Containers must choose the create/edit form contract explicitly before calling the mutation.
36
- - Numeric-only fields must use a numeric form control that prevents/sanitizes non-digit input before validation and before network submission. Keep database constraints mirrored in form schemas so invalid values do not rely on backend errors for normal feedback.
@@ -1,266 +0,0 @@
1
- import { runtime } from "../shared/runtime.ts";
2
- // oxlint-disable no-console no-await-in-loop
3
- const decoder = new TextDecoder();
4
- const violations: string[] = [];
5
-
6
- async function exists(path: string): Promise<boolean> {
7
- try {
8
- await runtime.stat(path);
9
- return true;
10
- } catch {
11
- return false;
12
- }
13
- }
14
-
15
- async function* walk(dir: string): AsyncGenerator<string> {
16
- try {
17
- for await (const entry of runtime.readDir(dir)) {
18
- const path = `${dir}/${entry.name}`;
19
- if (entry.isDirectory) yield* walk(path);
20
- if (entry.isFile && /\.(ts|tsx)$/.test(entry.name)) yield path;
21
- }
22
- } catch {
23
- return;
24
- }
25
- }
26
-
27
- function implementationFile(file: string): boolean {
28
- return (
29
- /\.(ts|tsx)$/.test(file) &&
30
- !file.endsWith(".test.ts") &&
31
- !file.endsWith(".test.tsx") &&
32
- !file.endsWith(".stories.tsx") &&
33
- !file.endsWith(".input.schema.ts") &&
34
- !file.endsWith(".output.schema.ts") &&
35
- !file.endsWith(".callbackInput.schema.ts") &&
36
- !file.endsWith(".form.schema.ts")
37
- );
38
- }
39
-
40
- function importsLegacyDal(text: string): boolean {
41
- return /from\s+["']@\/dal\//.test(text) || /import\(["']@\/dal\//.test(text);
42
- }
43
-
44
- function importsConvexReactHook(text: string): boolean {
45
- return /from\s+["']convex\/react["']/.test(text) && /\buse(Query|Mutation|Action)\b/.test(text);
46
- }
47
-
48
- function importsRouteLayer(text: string, layer: string): boolean {
49
- return new RegExp(`/-components/${layer}/`).test(text);
50
- }
51
-
52
- function importsDataHook(text: string): boolean {
53
- return text.includes("../data-hooks/") || text.includes("/-components/data-hooks/");
54
- }
55
-
56
- function isRouteFile(file: string): boolean {
57
- return file.startsWith("src/routes/") && !file.includes("/-components/");
58
- }
59
-
60
- function isPageContainer(file: string): boolean {
61
- return file.includes("/-components/container/") && file.endsWith("Page.tsx");
62
- }
63
-
64
- function importSpecs(text: string): string[] {
65
- const specs: string[] = [];
66
- for (const match of text.matchAll(/from\s+["']([^"']+)["']/gu)) {
67
- specs.push(match[1] ?? "");
68
- }
69
- for (const match of text.matchAll(/import\(["']([^"']+)["']\)/gu)) {
70
- specs.push(match[1] ?? "");
71
- }
72
- return specs;
73
- }
74
-
75
- function routeComponentRoot(file: string): string | null {
76
- const marker = "/-components/";
77
- const index = file.indexOf(marker);
78
- if (index === -1) return null;
79
- return file.slice(0, index);
80
- }
81
-
82
- function resolvesToDifferentRouteComponentRoot(file: string, spec: string): boolean {
83
- if (!spec.startsWith(".")) return false;
84
- const fromRoot = routeComponentRoot(file);
85
- if (!fromRoot) return false;
86
- const base = file.split("/").slice(0, -1);
87
- for (const part of spec.split("/")) {
88
- if (part === "." || part === "") continue;
89
- if (part === "..") base.pop();
90
- else base.push(part);
91
- }
92
- const target = base.join("/");
93
- if (!target.includes("/-components/")) return false;
94
- const targetRoot = routeComponentRoot(target);
95
- if (!targetRoot) return false;
96
- if (targetRoot === fromRoot) return false;
97
- if (fromRoot.startsWith(`${targetRoot}/`)) return false;
98
- return true;
99
- }
100
-
101
- function baseName(file: string): string {
102
- return file.split("/").at(-1) ?? file;
103
- }
104
-
105
- function routeComponentRootForFile(file: string): string | null {
106
- const marker = "/-components/";
107
- const index = file.indexOf(marker);
108
- if (index === -1) return null;
109
- return file.slice(0, index);
110
- }
111
-
112
- async function hasRouteLocalDataHooks(file: string): Promise<boolean> {
113
- const root = routeComponentRootForFile(file);
114
- if (!root) return false;
115
- return await exists(`${root}/-components/data-hooks`);
116
- }
117
-
118
- async function siblingPageControllerImportsDataHook(file: string): Promise<boolean> {
119
- const controller = file.replace(/\.tsx$/, ".controller.ts");
120
- if (!(await exists(controller))) return false;
121
- const text = decoder.decode(await runtime.readFile(controller));
122
- return importsDataHook(text);
123
- }
124
-
125
- async function requireSibling(file: string, suffix: string, message: string): Promise<void> {
126
- const sibling = file.replace(/\.(ts|tsx)$/, suffix);
127
- if (!(await exists(sibling))) {
128
- violations.push(`${file}: ${message}: ${sibling}`);
129
- }
130
- }
131
-
132
- function forbid(condition: boolean, file: string, message: string): void {
133
- if (condition) violations.push(`${file}: ${message}`);
134
- }
135
-
136
- function requireOperationSpecificFormName(file: string): void {
137
- if (file.includes("/new/-components/ui-hooks/") && !/Create/.test(baseName(file))) {
138
- violations.push(
139
- `${file}: new/create form hooks and schemas must be explicitly named for create contracts`,
140
- );
141
- }
142
- if (file.includes("/edit/-components/ui-hooks/") && !/Edit/.test(baseName(file))) {
143
- violations.push(
144
- `${file}: edit form hooks and schemas must be explicitly named for edit contracts`,
145
- );
146
- }
147
- }
148
-
149
- for (const required of ["src/routes", "src/routeTree.gen.ts"]) {
150
- if (!(await exists(required))) {
151
- violations.push(`missing required architecture path: ${required}`);
152
- }
153
- }
154
-
155
- for await (const file of walk("src/routes")) {
156
- if (file.endsWith(".form.schema.ts")) requireOperationSpecificFormName(file);
157
- if (!implementationFile(file)) continue;
158
-
159
- const text = decoder.decode(await runtime.readFile(file));
160
- const specs = importSpecs(text);
161
-
162
- for (const spec of specs) {
163
- forbid(
164
- resolvesToDifferentRouteComponentRoot(file, spec),
165
- file,
166
- `route-local components must not import another route's -components tree: ${spec}`,
167
- );
168
- }
169
-
170
- forbid(
171
- isRouteFile(file) && importsLegacyDal(text),
172
- file,
173
- "route files must not import legacy @/dal",
174
- );
175
- forbid(
176
- file.includes("/-components/container/") && importsLegacyDal(text),
177
- file,
178
- "containers must not import legacy @/dal",
179
- );
180
- forbid(
181
- file.includes("/-components/ui/") && importsLegacyDal(text),
182
- file,
183
- "UI must not import legacy @/dal",
184
- );
185
- forbid(
186
- file.includes("/-components/ui-hooks/") && importsLegacyDal(text),
187
- file,
188
- "UI hooks must not import legacy @/dal",
189
- );
190
- forbid(
191
- file.includes("/-components/ui-hooks/") && importsRouteLayer(text, "data-hooks"),
192
- file,
193
- "UI hooks must not import data hooks",
194
- );
195
- forbid(
196
- file.includes("/-components/ui-hooks/") && importsRouteLayer(text, "ui"),
197
- file,
198
- "UI hooks must not import UI components",
199
- );
200
- forbid(
201
- file.includes("/-components/ui-hooks/") && importsRouteLayer(text, "container"),
202
- file,
203
- "UI hooks must not import containers",
204
- );
205
- forbid(
206
- file.includes("/-components/ui/") && importsRouteLayer(text, "data-hooks"),
207
- file,
208
- "UI must not import data hooks",
209
- );
210
- forbid(
211
- file.includes("/-components/ui/") && importsRouteLayer(text, "container"),
212
- file,
213
- "UI must not import containers",
214
- );
215
- forbid(
216
- file.includes("/-components/data-hooks/") && importsRouteLayer(text, "ui-hooks"),
217
- file,
218
- "data hooks must not import UI hooks",
219
- );
220
- forbid(
221
- isPageContainer(file) &&
222
- (await hasRouteLocalDataHooks(file)) &&
223
- !importsDataHook(text) &&
224
- !(await siblingPageControllerImportsDataHook(file)),
225
- file,
226
- "page containers must use data hooks when the page owns data hooks",
227
- );
228
-
229
- if (file.includes("/-components/ui-hooks/")) {
230
- await requireSibling(file, ".form.schema.ts", "ui hooks must declare form schema contracts");
231
- requireOperationSpecificFormName(file);
232
- }
233
- if (file.includes("/-components/ui/") && file.endsWith(".tsx")) {
234
- await requireSibling(
235
- file,
236
- ".input.schema.ts",
237
- "UI components must declare input schema contracts",
238
- );
239
- }
240
- if (file.includes("/-components/data-hooks/")) {
241
- await requireSibling(
242
- file,
243
- ".input.schema.ts",
244
- "data hooks must declare input schema contracts",
245
- );
246
- await requireSibling(
247
- file,
248
- ".output.schema.ts",
249
- "data hooks must declare output schema contracts",
250
- );
251
- forbid(
252
- !importsConvexReactHook(text),
253
- file,
254
- "data hooks must call Convex React hooks through convex/react imports",
255
- );
256
- forbid(importsLegacyDal(text), file, "data hooks must not import legacy @/dal");
257
- forbid(importsRouteLayer(text, "ui"), file, "data hooks must not import UI components");
258
- forbid(importsRouteLayer(text, "container"), file, "data hooks must not import containers");
259
- }
260
- }
261
-
262
- if (violations.length) {
263
- console.error(violations.join("\n"));
264
- runtime.exit(1);
265
- }
266
- console.log("layers-and-contracts ok");
@@ -1,33 +0,0 @@
1
- {
2
- "id": "layers-and-contracts",
3
- "kind": "rule",
4
- "version": "1.0.1",
5
- "requires": [
6
- "checker-runtime"
7
- ],
8
- "artifacts": [
9
- {
10
- "kind": "managed-file",
11
- "path": ".agents/skills/layers-and-contracts/SKILL.md",
12
- "source": "SKILL.md"
13
- },
14
- {
15
- "kind": "managed-file",
16
- "path": ".agents/skills/layers-and-contracts/check.ts",
17
- "source": "check.ts"
18
- },
19
- {
20
- "kind": "shared-markdown-section",
21
- "path": "AGENTS.md",
22
- "heading": "## Specdest rule: layers-and-contracts",
23
- "body": "Use `.agents/skills/layers-and-contracts/SKILL.md` when working in this rule area. Run `node .agents/skills/layers-and-contracts/check.ts` before handoff."
24
- }
25
- ],
26
- "obsolete": [],
27
- "check": {
28
- "command": [
29
- "node",
30
- ".agents/skills/layers-and-contracts/check.ts"
31
- ]
32
- }
33
- }
@@ -1,49 +0,0 @@
1
- # Layers and contracts
2
-
3
- Use page-local architecture for route work.
4
-
5
- Required shape:
6
-
7
- - routes own URL params/search and render containers
8
- - containers orchestrate hooks and UI only
9
- - UI renders visible elements only
10
- - UI-hooks own form/behavior mapping
11
- - data-hooks call Convex React hooks and map page data contracts
12
- - Convex backend owns database/API payload conversion
13
-
14
- Enforced guardrails:
15
-
16
- - route, container, UI, and UI-hook files must not import legacy `@/dal`
17
- - data-hooks must call Convex through `useQuery`, `useMutation`, or `useAction` from `convex/react`
18
- - data-hooks must not import UI or container layers
19
- - placeholder/static page data belongs in UI-hooks or presentation view-models, not data-hooks
20
-
21
- ## Runtime boundary execution rule
22
-
23
- A declared boundary contract must execute at runtime; a schema file or inferred TypeScript type alone is not enforcement.
24
-
25
- - Data-hook implementations must import and call `.parse(...)` on their primary sibling `*InputSchema` and `*OutputSchema`.
26
- - Convex backend functions must keep Convex `args` and `returns` validators; Zod data-hook contracts validate the frontend boundary and do not replace Convex validators.
27
- - Pass-through values follow the same rule as transformed values. There is no pass-through exception.
28
- - Nested helper schemas are enforced through the primary schema that composes them; they are not separate layer boundaries.
29
- - Type-only imports do not satisfy runtime enforcement. The schema value itself must be imported.
30
- - Loading, skipped, or absent query states may remain outside a successful output schema, but every present successful value must be parsed.
31
- - Form and callback-input boundaries continue to use their specialized nearby schema rules.
32
-
33
- `runLayerContractChain` is test-only. Use it in contract integration tests to verify that real output schemas and production mappings are compatible with the next layer's input schema. Do not use it to orchestrate production behavior.
34
-
35
- Boundary files use Zod schemas:
36
-
37
- - `*.input.schema.ts`
38
- - `*.output.schema.ts`
39
- - `*.form.schema.ts`
40
-
41
- Types at boundaries must be inferred from Zod schemas with `z.infer<typeof schema>`.
42
-
43
- Form contract rules:
44
-
45
- - Shared visual form UI is allowed when create/new and edit pages intentionally look the same.
46
- - Do not share create/new and edit form contracts blindly. Each operation must choose an explicit schema/hook, such as `useResourceCreateForm.form.schema.ts` and `useResourceEditForm.form.schema.ts`, or clearly named equivalents.
47
- - Shared base schemas are allowed only for common fields. Compose create/edit schemas from the base so divergent rules stay visible.
48
- - Containers must choose the create/edit form contract explicitly before calling the mutation.
49
- - Numeric-only fields must use a numeric form control that prevents/sanitizes non-digit input before validation and before network submission. Keep database constraints mirrored in form schemas so invalid values do not rely on backend errors for normal feedback.