@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.
- package/README.md +15 -20
- package/package.json +4 -4
- package/src/canonical-project-operations.js +157 -0
- package/src/canonical-project.js +50 -0
- package/src/canonical-source.js +114 -0
- package/src/cli.js +2 -2
- package/src/git-catalog.js +105 -0
- package/src/index.js +6 -2
- package/src/project-operations.js +65 -6
- package/src/remote-installer.js +462 -0
- package/src/sync-core.js +20 -7
- package/catalog/README.md +0 -11
- package/catalog/modules/backend-convex/manifest.json +0 -14
- package/catalog/modules/backend-convex-expo/manifest.json +0 -11
- package/catalog/modules/backend-supabase/manifest.json +0 -15
- package/catalog/modules/backend-supabase-expo/manifest.json +0 -11
- package/catalog/modules/checker-runtime/config.ts +0 -25
- package/catalog/modules/checker-runtime/fs.ts +0 -48
- package/catalog/modules/checker-runtime/manifest.json +0 -29
- package/catalog/modules/checker-runtime/runtime.ts +0 -79
- package/catalog/modules/devflow/.agents/skills/devflow/SKILL.md +0 -33
- package/catalog/modules/devflow/.devflow.json +0 -10
- package/catalog/modules/devflow/manifest.json +0 -35
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/SKILL.md +0 -85
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/activeScenario.mjs +0 -130
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs +0 -7
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs +0 -36
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/createActiveScenario.mjs +0 -143
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs +0 -43
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/prompt.mjs +0 -25
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs +0 -66
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs +0 -146
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seed.mjs +0 -56
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs +0 -6
- package/catalog/modules/e2e-playwright/docs/e2e-playwright/README.md +0 -103
- package/catalog/modules/e2e-playwright/manifest.json +0 -206
- package/catalog/modules/e2e-playwright/playwright.e2e.config.ts +0 -39
- package/catalog/modules/e2e-playwright/tests/e2e/support/e2ePlaywrightFlow.ts +0 -107
- package/catalog/modules/e2e-playwright/tests/e2e/support/fixtures.ts +0 -27
- package/catalog/modules/local-log/AGENTS.local-log.md +0 -13
- package/catalog/modules/local-log/docs/features/local-logging/README.md +0 -70
- package/catalog/modules/local-log/manifest.json +0 -39
- package/catalog/modules/local-log/tmp/logs/.gitignore +0 -2
- package/catalog/modules/local-log/tools/local-log/README.md +0 -47
- package/catalog/modules/local-log/tools/local-log/local-log.mjs +0 -241
- package/catalog/modules/stack-common-vite/manifest.json +0 -16
- package/catalog/modules/stack-expo-convex/manifest.json +0 -31
- package/catalog/modules/stack-expo-supabase/manifest.json +0 -44
- package/catalog/modules/stack-vite-convex/manifest.json +0 -32
- package/catalog/modules/stack-vite-supabase/manifest.json +0 -45
- package/catalog/rules/abac-permissions-convex/SKILL.md +0 -17
- package/catalog/rules/abac-permissions-convex/check.ts +0 -87
- package/catalog/rules/abac-permissions-convex/manifest.json +0 -33
- package/catalog/rules/abac-permissions-supabase/SKILL.md +0 -17
- package/catalog/rules/abac-permissions-supabase/check.ts +0 -87
- package/catalog/rules/abac-permissions-supabase/manifest.json +0 -33
- package/catalog/rules/convex-multi-presentation/SKILL.md +0 -47
- package/catalog/rules/convex-multi-presentation/check.ts +0 -205
- package/catalog/rules/convex-multi-presentation/manifest.json +0 -47
- package/catalog/rules/convex-multi-presentation/policy.ts +0 -261
- package/catalog/rules/design-rules/SKILL.md +0 -12
- package/catalog/rules/design-rules/check.ts +0 -84
- package/catalog/rules/design-rules/config.json +0 -5
- package/catalog/rules/design-rules/manifest.json +0 -38
- package/catalog/rules/e2e-test-rules/SKILL.md +0 -46
- package/catalog/rules/e2e-test-rules/check.ts +0 -145
- package/catalog/rules/e2e-test-rules/config.json +0 -32
- package/catalog/rules/e2e-test-rules/manifest.json +0 -38
- package/catalog/rules/error-handling-rules/SKILL.md +0 -21
- package/catalog/rules/error-handling-rules/check.ts +0 -73
- package/catalog/rules/error-handling-rules/manifest.json +0 -33
- package/catalog/rules/layers-and-contracts/SKILL.md +0 -36
- package/catalog/rules/layers-and-contracts/check.ts +0 -266
- package/catalog/rules/layers-and-contracts/manifest.json +0 -33
- package/catalog/rules/layers-and-contracts-convex/SKILL.md +0 -49
- package/catalog/rules/layers-and-contracts-convex/check.ts +0 -289
- package/catalog/rules/layers-and-contracts-convex/manifest.json +0 -38
- package/catalog/rules/layers-and-contracts-convex/policy.ts +0 -68
- package/catalog/rules/layers-and-contracts-supabase/SKILL.md +0 -52
- package/catalog/rules/layers-and-contracts-supabase/check.ts +0 -371
- package/catalog/rules/layers-and-contracts-supabase/manifest.json +0 -38
- package/catalog/rules/layers-and-contracts-supabase/policy.ts +0 -68
- package/catalog/rules/module-size-rules/SKILL.md +0 -5
- package/catalog/rules/module-size-rules/check.ts +0 -144
- package/catalog/rules/module-size-rules/config.json +0 -6
- package/catalog/rules/module-size-rules/manifest.json +0 -38
- package/catalog/rules/module-size-rules-convex/SKILL.md +0 -5
- package/catalog/rules/module-size-rules-convex/check.ts +0 -146
- package/catalog/rules/module-size-rules-convex/config.json +0 -6
- package/catalog/rules/module-size-rules-convex/manifest.json +0 -38
- package/catalog/rules/module-size-rules-supabase/SKILL.md +0 -5
- package/catalog/rules/module-size-rules-supabase/check.ts +0 -146
- package/catalog/rules/module-size-rules-supabase/config.json +0 -12
- package/catalog/rules/module-size-rules-supabase/manifest.json +0 -38
- package/catalog/rules/mutation-command-rules/SKILL.md +0 -15
- package/catalog/rules/mutation-command-rules/check.ts +0 -30
- package/catalog/rules/mutation-command-rules/config.json +0 -19
- package/catalog/rules/mutation-command-rules/manifest.json +0 -38
- package/catalog/rules/nearby-contracts/SKILL.md +0 -18
- package/catalog/rules/nearby-contracts/check.ts +0 -138
- package/catalog/rules/nearby-contracts/config.json +0 -10
- package/catalog/rules/nearby-contracts/manifest.json +0 -38
- package/catalog/rules/no-raw-click-buttons/SKILL.md +0 -5
- package/catalog/rules/no-raw-click-buttons/check.ts +0 -37
- package/catalog/rules/no-raw-click-buttons/manifest.json +0 -33
- package/catalog/rules/public-api-export-barrels/SKILL.md +0 -45
- package/catalog/rules/public-api-export-barrels/check.ts +0 -73
- package/catalog/rules/public-api-export-barrels/config.json +0 -4
- package/catalog/rules/public-api-export-barrels/manifest.json +0 -38
- package/catalog/rules/route-tree-fresh/SKILL.md +0 -16
- package/catalog/rules/route-tree-fresh/check.ts +0 -66
- package/catalog/rules/route-tree-fresh/manifest.json +0 -33
- package/catalog/rules/strict-typescript/SKILL.md +0 -3
- package/catalog/rules/strict-typescript/check.ts +0 -119
- package/catalog/rules/strict-typescript/manifest.json +0 -33
- package/catalog/rules/supabase-contracts/SKILL.md +0 -3
- package/catalog/rules/supabase-contracts/check.ts +0 -172
- package/catalog/rules/supabase-contracts/manifest.json +0 -33
- package/catalog/rules/supabase-declarative-schema/SKILL.md +0 -30
- package/catalog/rules/supabase-declarative-schema/check.ts +0 -262
- package/catalog/rules/supabase-declarative-schema/config.json +0 -8
- package/catalog/rules/supabase-declarative-schema/manifest.json +0 -38
- package/catalog/rules/tanstack-form-rules/SKILL.md +0 -11
- package/catalog/rules/tanstack-form-rules/check.ts +0 -58
- package/catalog/rules/tanstack-form-rules/manifest.json +0 -33
- package/catalog/rules/unit-test-rules/SKILL.md +0 -55
- package/catalog/rules/unit-test-rules/check.ts +0 -132
- package/catalog/rules/unit-test-rules/config.json +0 -22
- package/catalog/rules/unit-test-rules/manifest.json +0 -38
- package/catalog/rules/unit-test-rules-convex/SKILL.md +0 -41
- package/catalog/rules/unit-test-rules-convex/check.ts +0 -418
- package/catalog/rules/unit-test-rules-convex/manifest.json +0 -33
- package/catalog/rules/unit-test-rules-supabase/SKILL.md +0 -40
- package/catalog/rules/unit-test-rules-supabase/check.ts +0 -492
- package/catalog/rules/unit-test-rules-supabase/manifest.json +0 -33
- package/catalog/rules/workstation-controller-rules/SKILL.md +0 -22
- package/catalog/rules/workstation-controller-rules/check.ts +0 -108
- package/catalog/rules/workstation-controller-rules/manifest.json +0 -33
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
// oxlint-disable no-console no-await-in-loop
|
|
3
|
-
const violations: string[] = [];
|
|
4
|
-
const requiredDataDisplayStories = ["Empty", "Loading", "MinimumData", "FullData"] as const;
|
|
5
|
-
const requiredFormStories = [
|
|
6
|
-
{ name: "EmptyDisplay", label: "empty display", submitsValues: false },
|
|
7
|
-
{ name: "EmptySubmit", label: "empty submit", submitsValues: true, expectedSubmitCount: 0 },
|
|
8
|
-
{
|
|
9
|
-
name: "MinimalRightDataSubmit",
|
|
10
|
-
label: "minimal right data submit",
|
|
11
|
-
submitsValues: true,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
name: "AllFieldRightDataSubmit",
|
|
15
|
-
label: "all field right data submit",
|
|
16
|
-
submitsValues: true,
|
|
17
|
-
expectedSubmitCount: 1,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "AllFieldBadDataSubmit",
|
|
21
|
-
label: "all field bad data submit",
|
|
22
|
-
submitsValues: true,
|
|
23
|
-
expectedSubmitCount: 0,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "FullInitialValueDisplay",
|
|
27
|
-
label: "full initial value display",
|
|
28
|
-
submitsValues: false,
|
|
29
|
-
},
|
|
30
|
-
] as const;
|
|
31
|
-
const zodSchemaFactories = [
|
|
32
|
-
"object",
|
|
33
|
-
"string",
|
|
34
|
-
"number",
|
|
35
|
-
"boolean",
|
|
36
|
-
"array",
|
|
37
|
-
"enum",
|
|
38
|
-
"union",
|
|
39
|
-
"discriminatedUnion",
|
|
40
|
-
"record",
|
|
41
|
-
"tuple",
|
|
42
|
-
"literal",
|
|
43
|
-
"nativeEnum",
|
|
44
|
-
"date",
|
|
45
|
-
"coerce",
|
|
46
|
-
"preprocess",
|
|
47
|
-
"custom",
|
|
48
|
-
"instanceof",
|
|
49
|
-
"promise",
|
|
50
|
-
"map",
|
|
51
|
-
"set",
|
|
52
|
-
"bigint",
|
|
53
|
-
"any",
|
|
54
|
-
"unknown",
|
|
55
|
-
"never",
|
|
56
|
-
] as const;
|
|
57
|
-
|
|
58
|
-
async function exists(path: string): Promise<boolean> {
|
|
59
|
-
try {
|
|
60
|
-
await runtime.stat(path);
|
|
61
|
-
return true;
|
|
62
|
-
} catch {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function* walk(dir: string): AsyncGenerator<string> {
|
|
68
|
-
try {
|
|
69
|
-
for await (const entry of runtime.readDir(dir)) {
|
|
70
|
-
const path = dir + "/" + entry.name;
|
|
71
|
-
if (entry.isDirectory) yield* walk(path);
|
|
72
|
-
if (entry.isFile) yield path;
|
|
73
|
-
}
|
|
74
|
-
} catch {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function isImplementation(file: string): boolean {
|
|
80
|
-
return (
|
|
81
|
-
/\.(ts|tsx)$/.test(file) &&
|
|
82
|
-
!file.endsWith(".test.ts") &&
|
|
83
|
-
!file.endsWith(".test.tsx") &&
|
|
84
|
-
!file.endsWith(".stories.tsx") &&
|
|
85
|
-
!file.endsWith(".input.schema.ts") &&
|
|
86
|
-
!file.endsWith(".output.schema.ts") &&
|
|
87
|
-
!file.endsWith(".callbackInput.schema.ts") &&
|
|
88
|
-
!file.endsWith(".form.schema.ts") &&
|
|
89
|
-
!file.endsWith(".schema.ts") &&
|
|
90
|
-
!file.endsWith(".contract.ts") &&
|
|
91
|
-
!file.endsWith("routeTree.gen.ts")
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function baseName(file: string): string {
|
|
96
|
-
return file.split("/").at(-1) ?? file;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function exportsNamedFunctionOrConst(file: string, source: string): boolean {
|
|
100
|
-
const name = baseName(file).replace(/\.(ts|tsx)$/u, "");
|
|
101
|
-
return new RegExp(`export\\s+(?:async\\s+)?(?:function|const)\\s+${name}\\b`, "u").test(source);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function isUiComponentBoundary(file: string, source: string): boolean {
|
|
105
|
-
const isRouteUi = /\/[-_]components\/ui\//u.test(file);
|
|
106
|
-
const isSharedUi = file.startsWith("src/components/general/");
|
|
107
|
-
if ((!isRouteUi && !isSharedUi) || !file.endsWith(".tsx") || !isImplementation(file))
|
|
108
|
-
return false;
|
|
109
|
-
const name = baseName(file).replace(/\.tsx$/u, "");
|
|
110
|
-
return /^[A-Z][A-Za-z0-9]*$/u.test(name) && exportsNamedFunctionOrConst(file, source);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function exportsHook(file: string, source: string): boolean {
|
|
114
|
-
const name = baseName(file).replace(/\.(ts|tsx)$/u, "");
|
|
115
|
-
if (!/^use[A-Z0-9]/u.test(name)) return false;
|
|
116
|
-
return exportsNamedFunctionOrConst(file, source);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function importsApplication(source: string): boolean {
|
|
120
|
-
return (
|
|
121
|
-
/from\s+["']@\/application\//u.test(source) || /import\(["']@\/application\//u.test(source)
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function importsDal(source: string): boolean {
|
|
126
|
-
return /from\s+["']@\/dal\//u.test(source) || /import\(["']@\/dal\//u.test(source);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function isUiHookBoundary(file: string, source: string): boolean {
|
|
130
|
-
return /\/[-_]components\/ui-hooks\//u.test(file) && exportsHook(file, source);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function isDataHookBoundary(file: string, source: string): boolean {
|
|
134
|
-
if (!/\/[-_]components\/data-hooks\//u.test(file)) return false;
|
|
135
|
-
return exportsHook(file, source) || importsApplication(source) || importsDal(source);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function isDalOperationBoundary(file: string): boolean {
|
|
139
|
-
if (
|
|
140
|
-
!file.startsWith("src/dal/") ||
|
|
141
|
-
(!file.includes("/queries/") && !file.includes("/mutations/"))
|
|
142
|
-
)
|
|
143
|
-
return false;
|
|
144
|
-
if (file.includes("-architecture-fixture/")) return false;
|
|
145
|
-
const name = baseName(file);
|
|
146
|
-
if (/\.(?:good|bad)\.(?:ts|tsx)$/u.test(name)) return false;
|
|
147
|
-
if (/Wrappers?\.(?:ts|tsx)$/u.test(name)) return false;
|
|
148
|
-
return isImplementation(file);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function isContainerComponentBoundary(file: string, source: string): boolean {
|
|
152
|
-
if (
|
|
153
|
-
!/\/[-_]components\/container\//u.test(file) ||
|
|
154
|
-
!file.endsWith(".tsx") ||
|
|
155
|
-
!isImplementation(file)
|
|
156
|
-
)
|
|
157
|
-
return false;
|
|
158
|
-
const name = baseName(file).replace(/\.tsx$/u, "");
|
|
159
|
-
return /^[A-Z][A-Za-z0-9]*$/u.test(name) && exportsNamedFunctionOrConst(file, source);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function isPageDataDisplayUi(file: string, source: string): boolean {
|
|
163
|
-
if (!/^src\/(?:routes|pages)\//u.test(file) || !/\/[-_]components\/ui\//u.test(file)) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
const displaysCollection =
|
|
167
|
-
/\bdata\./u.test(source) ||
|
|
168
|
-
/\bitems\./u.test(source) ||
|
|
169
|
-
/\brows\./u.test(source) ||
|
|
170
|
-
source.includes("<table");
|
|
171
|
-
const ownsLoadingState = /\b(?:isLoading|loading)\b/u.test(source);
|
|
172
|
-
return displaysCollection && ownsLoadingState;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function isPageFormUi(file: string, source: string): boolean {
|
|
176
|
-
return (
|
|
177
|
-
/^src\/(?:routes|pages)\//u.test(file) &&
|
|
178
|
-
/\/[-_]components\/ui\//u.test(file) &&
|
|
179
|
-
/<form[\s>]/u.test(source)
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function hasStoryExport(storyText: string, storyName: string): boolean {
|
|
184
|
-
return storyText.includes(`export const ${storyName}`);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function storyExportBlock(storyText: string, storyName: string): string | null {
|
|
188
|
-
const start = storyText.indexOf(`export const ${storyName}`);
|
|
189
|
-
if (start < 0) return null;
|
|
190
|
-
const rest = storyText.slice(start + `export const ${storyName}`.length);
|
|
191
|
-
const next = rest.search(/\nexport const \w+\b|\nexport default\b/u);
|
|
192
|
-
return next < 0
|
|
193
|
-
? storyText.slice(start)
|
|
194
|
-
: storyText.slice(start, start + `export const ${storyName}`.length + next);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function storyPathFor(file: string): string {
|
|
198
|
-
return file.replace(/\.tsx$/, ".stories.tsx");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function inputSchemaPathFor(file: string): string {
|
|
202
|
-
return file.replace(/\.tsx$/, ".input.schema.ts");
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function hasVisiblePlayAssertion(storyText: string): boolean {
|
|
206
|
-
return (
|
|
207
|
-
storyText.includes("expect(") &&
|
|
208
|
-
(storyText.includes("getByRole(") ||
|
|
209
|
-
storyText.includes("findByRole(") ||
|
|
210
|
-
storyText.includes("getByText(") ||
|
|
211
|
-
storyText.includes("findByText(") ||
|
|
212
|
-
storyText.includes("getByLabelText(") ||
|
|
213
|
-
storyText.includes("findByLabelText(") ||
|
|
214
|
-
storyText.includes("getByPlaceholderText(") ||
|
|
215
|
-
storyText.includes("findByPlaceholderText(") ||
|
|
216
|
-
storyText.includes("getByTestId(") ||
|
|
217
|
-
storyText.includes("findByTestId("))
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function importsZod(text: string): boolean {
|
|
222
|
-
return /from\s+["']zod["']/u.test(text);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function definesLocalZodSchema(text: string): boolean {
|
|
226
|
-
return zodSchemaFactories.some((factory) =>
|
|
227
|
-
new RegExp(`\\bz\\.${factory}\\s*\\(`, "u").test(text),
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function schemaImportSpecs(text: string): string[] {
|
|
232
|
-
const specs: string[] = [];
|
|
233
|
-
for (const match of text.matchAll(/from\s+["']([^"']*\.schema)["']/gu)) {
|
|
234
|
-
if (match[1]) specs.push(match[1]);
|
|
235
|
-
}
|
|
236
|
-
for (const match of text.matchAll(/import\(["']([^"']*\.schema)["']\)/gu)) {
|
|
237
|
-
if (match[1]) specs.push(match[1]);
|
|
238
|
-
}
|
|
239
|
-
return specs;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function isStorybookOnlySchemaSpec(spec: string): boolean {
|
|
243
|
-
return (
|
|
244
|
-
spec.includes("story.schema") ||
|
|
245
|
-
spec.includes("stories.schema") ||
|
|
246
|
-
spec.includes("storybook.schema") ||
|
|
247
|
-
spec.includes("__stories__") ||
|
|
248
|
-
spec.includes("storybook/")
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function importsProductionSchema(text: string): boolean {
|
|
253
|
-
return schemaImportSpecs(text).some(
|
|
254
|
-
(spec) => spec.length > 0 && !isStorybookOnlySchemaSpec(spec),
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function importsStorybookOnlySchema(text: string): boolean {
|
|
259
|
-
return schemaImportSpecs(text).some((spec) => spec.length > 0 && isStorybookOnlySchemaSpec(spec));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function usesSchemaParse(text: string): boolean {
|
|
263
|
-
return (
|
|
264
|
-
/\b\w*schema\w*\.(safeParse|parse)\s*\(/iu.test(text) ||
|
|
265
|
-
/\b\w*Schema\w*\.(safeParse|parse)\s*\(/u.test(text)
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function hasSchemaBackedArgs(storyText: string): boolean {
|
|
270
|
-
return importsProductionSchema(storyText) && usesSchemaParse(storyText);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function hasStoryPlay(storyText: string, storyName: string, storyBlock: string): boolean {
|
|
274
|
-
return /\bplay\s*:/u.test(storyBlock) || storyText.includes(`${storyName}.play`);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function hasSubmitInteraction(storyBlock: string): boolean {
|
|
278
|
-
return (
|
|
279
|
-
/\buserEvent\b/u.test(storyBlock) &&
|
|
280
|
-
/\.(click|type|clear|selectOptions|keyboard)\s*\(/u.test(storyBlock)
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function hasExactSubmitValueAssertion(storyBlock: string): boolean {
|
|
285
|
-
return (
|
|
286
|
-
/\btoStrictEqual\s*\(/u.test(storyBlock) || /\btoHaveBeenCalledWith\s*\(/u.test(storyBlock)
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function hasLenientValueMatcher(storyBlock: string): boolean {
|
|
291
|
-
return (
|
|
292
|
-
/\b(objectContaining|arrayContaining)\s*\(/u.test(storyBlock) ||
|
|
293
|
-
/\bexpect\.(any|anything)\s*\(/u.test(storyBlock)
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function testPathFor(file: string): string {
|
|
298
|
-
return file.replace(/\.(ts|tsx)$/, ".test.$1");
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function basenameWithoutExtension(file: string): string {
|
|
302
|
-
return (
|
|
303
|
-
file
|
|
304
|
-
.split("/")
|
|
305
|
-
.at(-1)
|
|
306
|
-
?.replace(/\.(ts|tsx)$/, "") ?? file
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async function readAllTests(root: string): Promise<string> {
|
|
311
|
-
const texts: string[] = [];
|
|
312
|
-
for await (const file of walk(root)) {
|
|
313
|
-
if (file.endsWith(".test.ts") || file.endsWith(".test.tsx")) {
|
|
314
|
-
texts.push(await runtime.readTextFile(file));
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return texts.join("\n");
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (!(await exists("src"))) violations.push("missing src directory");
|
|
321
|
-
if (!(await exists(".storybook/main.ts"))) {
|
|
322
|
-
violations.push("missing Storybook config: .storybook/main.ts");
|
|
323
|
-
}
|
|
324
|
-
if (!(await exists(".storybook/vitest.setup.ts"))) {
|
|
325
|
-
violations.push("missing Storybook Vitest setup: .storybook/vitest.setup.ts");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const routeRoot = (await exists("src/routes")) ? "src/routes" : "src/pages";
|
|
329
|
-
const routeTests = await readAllTests(routeRoot);
|
|
330
|
-
const dalTests = await readAllTests("src/dal");
|
|
331
|
-
const sharedTests = await readAllTests("src/test");
|
|
332
|
-
const hasDynamicDalBehaviorSuite =
|
|
333
|
-
/import\.meta\.glob\s*\(/u.test(sharedTests) &&
|
|
334
|
-
/\/src\/dal\/\*\*/u.test(sharedTests) &&
|
|
335
|
-
/(?:queries,mutations|queries\|mutations|queries.*mutations)/su.test(sharedTests) &&
|
|
336
|
-
/(?:Reflect\.apply|implementations\[|module\[)/u.test(sharedTests) &&
|
|
337
|
-
/(?:safeParse|\.parse\s*\()/u.test(sharedTests);
|
|
338
|
-
|
|
339
|
-
for await (const file of walk("src")) {
|
|
340
|
-
const sourceText = isImplementation(file) ? await runtime.readTextFile(file) : "";
|
|
341
|
-
|
|
342
|
-
if (isUiComponentBoundary(file, sourceText)) {
|
|
343
|
-
const storyPath = storyPathFor(file);
|
|
344
|
-
if (!(await exists(storyPath))) {
|
|
345
|
-
violations.push(file + ": UI components must have a colocated Storybook story: " + storyPath);
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
const storyText = await runtime.readTextFile(storyPath);
|
|
350
|
-
if (importsZod(storyText) || definesLocalZodSchema(storyText)) {
|
|
351
|
-
violations.push(
|
|
352
|
-
storyPath +
|
|
353
|
-
": Storybook stories must use real production Zod schemas; do not import zod or define story-local schemas",
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
if (importsStorybookOnlySchema(storyText)) {
|
|
357
|
-
violations.push(
|
|
358
|
-
storyPath + ": Storybook stories must not import storybook-only schema files",
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
if (!/\bplay\s*:/u.test(storyText) && !/\.play\s*=/u.test(storyText)) {
|
|
362
|
-
violations.push(storyPath + ": Storybook stories must include a play test");
|
|
363
|
-
}
|
|
364
|
-
if (/story contract|placeholder story/iu.test(storyText)) {
|
|
365
|
-
violations.push(
|
|
366
|
-
storyPath + ": Storybook stories must render the real UI, not a placeholder contract",
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
if (!hasVisiblePlayAssertion(storyText)) {
|
|
370
|
-
violations.push(
|
|
371
|
-
storyPath + ": Storybook play tests must assert visible UI with Testing Library queries",
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
if (isPageDataDisplayUi(file, sourceText)) {
|
|
375
|
-
const missingStories = requiredDataDisplayStories.filter(
|
|
376
|
-
(storyName) => !hasStoryExport(storyText, storyName),
|
|
377
|
-
);
|
|
378
|
-
if (missingStories.length > 0) {
|
|
379
|
-
violations.push(
|
|
380
|
-
storyPath +
|
|
381
|
-
": data display UI stories must export Empty, Loading, MinimumData, and FullData. Missing: " +
|
|
382
|
-
missingStories.join(", "),
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (await exists(inputSchemaPathFor(file))) {
|
|
387
|
-
if (!hasSchemaBackedArgs(storyText)) {
|
|
388
|
-
violations.push(
|
|
389
|
-
storyPath +
|
|
390
|
-
": Storybook stories for schema-backed UI must import a production schema and parse args or fixtures through it",
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
if (isPageFormUi(file, sourceText) && sourceText.includes("<DevFormFillButtons")) {
|
|
395
|
-
for (const contract of requiredFormStories) {
|
|
396
|
-
const storyBlock = storyExportBlock(storyText, contract.name);
|
|
397
|
-
if (!storyBlock) {
|
|
398
|
-
violations.push(
|
|
399
|
-
storyPath +
|
|
400
|
-
`: page-local form stories must export ${contract.name} (${contract.label})`,
|
|
401
|
-
);
|
|
402
|
-
continue;
|
|
403
|
-
}
|
|
404
|
-
if (!hasStoryPlay(storyText, contract.name, storyBlock)) {
|
|
405
|
-
violations.push(
|
|
406
|
-
storyPath + `: ${contract.name} must include its own Storybook play test`,
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
if (!contract.submitsValues) continue;
|
|
410
|
-
if (!hasSubmitInteraction(storyBlock)) {
|
|
411
|
-
violations.push(
|
|
412
|
-
storyPath + `: ${contract.name} must submit through a userEvent play interaction`,
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
const expectedSubmitCount =
|
|
416
|
-
"expectedSubmitCount" in contract ? contract.expectedSubmitCount : 1;
|
|
417
|
-
const callCountPattern = new RegExp(
|
|
418
|
-
`\\btoHaveBeenCalledTimes\\s*\\(\\s*${expectedSubmitCount}\\s*\\)`,
|
|
419
|
-
"u",
|
|
420
|
-
);
|
|
421
|
-
if (!callCountPattern.test(storyBlock)) {
|
|
422
|
-
violations.push(
|
|
423
|
-
storyPath +
|
|
424
|
-
(expectedSubmitCount === 0
|
|
425
|
-
? `: ${contract.name}: invalid form stories must assert zero submit calls`
|
|
426
|
-
: `: ${contract.name} must assert exactly one submit call`),
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
if (expectedSubmitCount === 1 && !hasExactSubmitValueAssertion(storyBlock)) {
|
|
430
|
-
violations.push(
|
|
431
|
-
storyPath +
|
|
432
|
-
`: ${contract.name} must assert exact submitted values with toStrictEqual or toHaveBeenCalledWith`,
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
if (hasLenientValueMatcher(storyBlock)) {
|
|
436
|
-
violations.push(
|
|
437
|
-
storyPath +
|
|
438
|
-
`: ${contract.name} must not use lenient value matchers for submitted values`,
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if (!isImplementation(file)) continue;
|
|
446
|
-
|
|
447
|
-
if (isContainerComponentBoundary(file, sourceText)) {
|
|
448
|
-
const testPath = testPathFor(file);
|
|
449
|
-
const boundaryTestPath = file.replace(/\.tsx$/u, ".boundary.test.tsx");
|
|
450
|
-
if (!(await exists(testPath)) && !(await exists(boundaryTestPath))) {
|
|
451
|
-
violations.push(
|
|
452
|
-
file +
|
|
453
|
-
": container components must have a colocated unit/component test: " +
|
|
454
|
-
testPath +
|
|
455
|
-
" or " +
|
|
456
|
-
boundaryTestPath,
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
if (isUiHookBoundary(file, sourceText)) {
|
|
462
|
-
const testPaths = [
|
|
463
|
-
file.replace(/\.(?:ts|tsx)$/u, ".test.ts"),
|
|
464
|
-
file.replace(/\.(?:ts|tsx)$/u, ".test.tsx"),
|
|
465
|
-
];
|
|
466
|
-
if (!(await exists(testPaths[0])) && !(await exists(testPaths[1]))) {
|
|
467
|
-
violations.push(
|
|
468
|
-
file + ": UI hooks must have a colocated unit test: " + testPaths.join(" or "),
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
if (isDataHookBoundary(file, sourceText)) {
|
|
474
|
-
const name = basenameWithoutExtension(file);
|
|
475
|
-
if (!routeTests.includes(name)) {
|
|
476
|
-
violations.push(file + ": data hooks must be referenced by a route-layer unit test");
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if (isDalOperationBoundary(file)) {
|
|
481
|
-
const name = basenameWithoutExtension(file);
|
|
482
|
-
if (!hasDynamicDalBehaviorSuite && !dalTests.includes(name)) {
|
|
483
|
-
violations.push(file + ": DAL operations must be referenced by DAL unit or contract tests");
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if (violations.length) {
|
|
489
|
-
console.error(violations.join("\n"));
|
|
490
|
-
runtime.exit(1);
|
|
491
|
-
}
|
|
492
|
-
console.log("unit-test-rules ok");
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "unit-test-rules-supabase",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.8",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/unit-test-rules/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/unit-test-rules/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "shared-markdown-section",
|
|
21
|
-
"path": "AGENTS.md",
|
|
22
|
-
"heading": "## Specdest backend rule: unit-test-rules",
|
|
23
|
-
"body": "Use `.agents/skills/unit-test-rules/SKILL.md` for this backend-specific rule. Run `node .agents/skills/unit-test-rules/check.ts` before handoff."
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"obsolete": [],
|
|
27
|
-
"check": {
|
|
28
|
-
"command": [
|
|
29
|
-
"node",
|
|
30
|
-
".agents/skills/unit-test-rules/check.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Workstation controller rules
|
|
2
|
-
|
|
3
|
-
Use this skill when editing the Deno workstation controller, its launch service, browser clients, or operation contracts.
|
|
4
|
-
|
|
5
|
-
## Required architecture
|
|
6
|
-
|
|
7
|
-
The workstation controller is a local-machine execution surface. It must bind to `127.0.0.1` only and expose a small HTTP API. Do not add public routing, connector authentication, proxy discovery, or remote-host publication.
|
|
8
|
-
|
|
9
|
-
Every privileged operation must have an explicit input/output contract, an access class (`read`, `write`, or `owner`), and Convex authorization before execution.
|
|
10
|
-
|
|
11
|
-
## Execution rules
|
|
12
|
-
|
|
13
|
-
- Authenticate browser requests with the current Convex session token.
|
|
14
|
-
- Do not trust CORS, `Origin`, or `Referer` as authorization.
|
|
15
|
-
- Do not execute shell strings or invoke `bash -c`, `sh -c`, or `shell: true`.
|
|
16
|
-
- Use fixed binaries with argv arrays.
|
|
17
|
-
- Keep local process/file access isolated from React UI code.
|
|
18
|
-
- Keep controller endpoints narrow: status, service lifecycle, and code-template operations.
|
|
19
|
-
|
|
20
|
-
## Required checks
|
|
21
|
-
|
|
22
|
-
Run `pnpm nps lint.workstationControllerRules` and `pnpm nps test.contract` before handoff.
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
// oxlint-disable no-console
|
|
3
|
-
import { walk } from "../shared/fs.ts";
|
|
4
|
-
|
|
5
|
-
const controllerFile = "tools/workstation-controller.ts";
|
|
6
|
-
const serviceFile = "tools/workstation-controller-service.ts";
|
|
7
|
-
const packageScriptsFile = "package-scripts.yml";
|
|
8
|
-
const violations: string[] = [];
|
|
9
|
-
|
|
10
|
-
async function readText(path: string) {
|
|
11
|
-
try {
|
|
12
|
-
return await runtime.readTextFile(path);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
if (error instanceof runtime.errors.NotFound) {
|
|
15
|
-
violations.push(`${path}: required workstation controller file is missing`);
|
|
16
|
-
return "";
|
|
17
|
-
}
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function requireMatch(text: string, pattern: RegExp, message: string) {
|
|
23
|
-
if (!pattern.test(text)) violations.push(message);
|
|
24
|
-
}
|
|
25
|
-
function forbidMatch(text: string, pattern: RegExp, message: string) {
|
|
26
|
-
if (pattern.test(text)) violations.push(message);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function controllerFiles() {
|
|
30
|
-
const modularFiles = (await walk("tools/workstation-controller")).map(
|
|
31
|
-
(file) => `tools/workstation-controller/${file}`,
|
|
32
|
-
);
|
|
33
|
-
return [controllerFile, serviceFile, ...modularFiles].filter(
|
|
34
|
-
(file) => file.endsWith(".ts") && !file.endsWith(".test.ts"),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function checkLocalTransport() {
|
|
39
|
-
const source = await readText(controllerFile);
|
|
40
|
-
requireMatch(
|
|
41
|
-
source,
|
|
42
|
-
/const HOST = "127\.0\.0\.1"/u,
|
|
43
|
-
`${controllerFile}: controller must bind to localhost only`,
|
|
44
|
-
);
|
|
45
|
-
requireMatch(
|
|
46
|
-
source,
|
|
47
|
-
/url\.pathname === "\/status"/u,
|
|
48
|
-
`${controllerFile}: status endpoint is required`,
|
|
49
|
-
);
|
|
50
|
-
requireMatch(
|
|
51
|
-
source,
|
|
52
|
-
/url\.pathname === "\/service"/u,
|
|
53
|
-
`${controllerFile}: service endpoint is required`,
|
|
54
|
-
);
|
|
55
|
-
requireMatch(
|
|
56
|
-
source,
|
|
57
|
-
/url\.pathname === "\/code-template"/u,
|
|
58
|
-
`${controllerFile}: code-template endpoint is required`,
|
|
59
|
-
);
|
|
60
|
-
requireMatch(source, /authenticate\(request\)/u, `${controllerFile}: requests must authenticate`);
|
|
61
|
-
requireMatch(
|
|
62
|
-
source,
|
|
63
|
-
/auth:authorizeWorkstationControllerTool/u,
|
|
64
|
-
`${controllerFile}: actions must use Convex authorization`,
|
|
65
|
-
);
|
|
66
|
-
forbidMatch(
|
|
67
|
-
source,
|
|
68
|
-
/oauth|well-known|x-forwarded|public-routing|CONNECTOR_|publicUrl|public_url/iu,
|
|
69
|
-
`${controllerFile}: public routing or connector auth is forbidden`,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function checkCommandSafety() {
|
|
74
|
-
for (const file of await controllerFiles()) {
|
|
75
|
-
const source = await readText(file);
|
|
76
|
-
forbidMatch(
|
|
77
|
-
source,
|
|
78
|
-
/new\s+Deno\.Command\(\s*["'](?:bash|sh)["']/u,
|
|
79
|
-
`${file}: runtime.Command must not spawn bash/sh`,
|
|
80
|
-
);
|
|
81
|
-
forbidMatch(source, /args:\s*\[\s*["']-c["']/u, `${file}: shell command -c args are forbidden`);
|
|
82
|
-
forbidMatch(source, /shell:\s*true/u, `${file}: shell: true is forbidden`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async function checkLintWiring() {
|
|
87
|
-
const scripts = await readText(packageScriptsFile);
|
|
88
|
-
requireMatch(
|
|
89
|
-
scripts,
|
|
90
|
-
/workstationControllerRules/u,
|
|
91
|
-
`${packageScriptsFile}: define workstationControllerRules lint script`,
|
|
92
|
-
);
|
|
93
|
-
requireMatch(
|
|
94
|
-
scripts,
|
|
95
|
-
/\.agents\/skills\/workstation-controller-rules\/check\.ts/u,
|
|
96
|
-
`${packageScriptsFile}: wire workstation controller checker`,
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
await checkLocalTransport();
|
|
101
|
-
await checkCommandSafety();
|
|
102
|
-
await checkLintWiring();
|
|
103
|
-
if (violations.length) {
|
|
104
|
-
console.error(`# workstation controller rule violations: ${violations.length}`);
|
|
105
|
-
console.error(violations.join("\n"));
|
|
106
|
-
runtime.exit(1);
|
|
107
|
-
}
|
|
108
|
-
console.log("workstation-controller-rules ok");
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "workstation-controller-rules",
|
|
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/workstation-controller-rules/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/workstation-controller-rules/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "shared-markdown-section",
|
|
21
|
-
"path": "AGENTS.md",
|
|
22
|
-
"heading": "## Specdest rule: workstation-controller-rules",
|
|
23
|
-
"body": "Use `.agents/skills/workstation-controller-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/workstation-controller-rules/check.ts` before handoff."
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"obsolete": [],
|
|
27
|
-
"check": {
|
|
28
|
-
"command": [
|
|
29
|
-
"node",
|
|
30
|
-
".agents/skills/workstation-controller-rules/check.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|