@specdest/devkit 0.2.1 → 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 +69 -9
  10. package/src/remote-installer.js +462 -0
  11. package/src/sync-core.js +26 -10
  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 -28
  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,261 +0,0 @@
1
- export type BackendLayer = "api" | "application" | "domain" | "dal" | "integration";
2
-
3
- export function normalizePath(file: string): string {
4
- return file.replaceAll("\\", "/").replace(/^\.\//u, "");
5
- }
6
-
7
- export function backendLayer(file: string): BackendLayer | null {
8
- const path = normalizePath(file);
9
- if (!path.startsWith("convex/") || path.startsWith("convex/_generated/")) return null;
10
- if (path.startsWith("convex/application/")) return "application";
11
- if (path.startsWith("convex/domain/")) return "domain";
12
- if (path.startsWith("convex/dal/")) return "dal";
13
- if (path.startsWith("convex/integrations/")) return "integration";
14
- if (/^convex\/[^/]+\.ts$/u.test(path) && !/[\\/](schema|model)\.ts$/u.test(path)) return "api";
15
- return null;
16
- }
17
-
18
- export function isInternalBackendImplementation(file: string): boolean {
19
- return normalizePath(file).split("/").includes("internal");
20
- }
21
-
22
- export function isConvexFrameworkPlumbing(file: string): boolean {
23
- const path = normalizePath(file);
24
- return (
25
- path === "convex/convex.config.ts" ||
26
- path === "convex/migrations.ts" ||
27
- path === "convex/schema.ts" ||
28
- path.startsWith("convex/schema/")
29
- );
30
- }
31
-
32
- function dirname(file: string): string[] {
33
- return normalizePath(file).split("/").slice(0, -1);
34
- }
35
-
36
- export function resolveImportPath(file: string, spec: string): string | null {
37
- if (spec.startsWith("@/")) return `src/${spec.slice(2)}`;
38
- if (!spec.startsWith(".")) return null;
39
- const parts = dirname(file);
40
- for (const part of spec.split("/")) {
41
- if (!part || part === ".") continue;
42
- if (part === "..") parts.pop();
43
- else parts.push(part);
44
- }
45
- return parts.join("/");
46
- }
47
-
48
- export function importSpecs(source: string): string[] {
49
- const specs: string[] = [];
50
- for (const match of source.matchAll(/\bfrom\s+["']([^"']+)["']/gu)) specs.push(match[1] ?? "");
51
- for (const match of source.matchAll(/\bimport\s*\(\s*["']([^"']+)["']\s*\)/gu))
52
- specs.push(match[1] ?? "");
53
- return specs;
54
- }
55
-
56
- const allowedBackendEdges = new Set([
57
- "api>api",
58
- "api>application",
59
- "application>application",
60
- "application>domain",
61
- "application>dal",
62
- "application>integration",
63
- "domain>domain",
64
- "dal>dal",
65
- "dal>domain",
66
- "integration>integration",
67
- "integration>domain",
68
- ]);
69
-
70
- export function backendImportViolation(file: string, spec: string): string | null {
71
- const from = backendLayer(file);
72
- if (!from) return null;
73
- const resolved = resolveImportPath(file, spec);
74
- if (!resolved?.startsWith("convex/")) return null;
75
- if (resolved.startsWith("convex/_generated/")) {
76
- if (from === "api" || from === "dal") return null;
77
- return `${from} must not import Convex runtime/generated modules directly`;
78
- }
79
- if (resolved === "convex/schema" || resolved === "convex/schema.ts")
80
- return `${from} must not import the database schema module`;
81
- const targetPath = resolved.endsWith(".ts") ? resolved : `${resolved}.ts`;
82
- const to = backendLayer(targetPath);
83
- if (!to) return `${from} must not import unclassified Convex backend code: ${spec}`;
84
- if (from === "api" && isInternalBackendImplementation(targetPath))
85
- return "public API must delegate through an application boundary facade, not application internals";
86
- if (allowedBackendEdges.has(`${from}>${to}`)) return null;
87
- return `${from} must not import ${to}; allowed flow is API -> Application -> Domain/DAL or Integration`;
88
- }
89
-
90
- export function frontendBackendImportViolation(file: string, spec: string): string | null {
91
- const path = normalizePath(file);
92
- if (!path.startsWith("src/")) return null;
93
- const resolved = resolveImportPath(file, spec);
94
- if (resolved?.startsWith("convex/_generated/api")) return null;
95
- if (resolved?.startsWith("convex/"))
96
- return `presentation/client code must not import Convex backend files directly: ${spec}`;
97
- if (
98
- /^@\/.*(?:application|domain|dal|integrations)\//u.test(spec) &&
99
- !spec.startsWith("@/integrations/convex/")
100
- ) {
101
- return `presentation/client code must not bypass the shared Convex public API: ${spec}`;
102
- }
103
- return null;
104
- }
105
-
106
- export function forbiddenRuntimeViolations(file: string, source: string): string[] {
107
- const layer = backendLayer(file);
108
- if (!layer) return [];
109
- const findings: string[] = [];
110
- if (layer !== "dal" && /\b(?:ctx|context)\.db\b/u.test(source))
111
- findings.push(`${layer} must not access ctx.db; DB access belongs in convex/dal`);
112
- if (layer !== "integration" && /\bfetch\s*\(/u.test(source))
113
- findings.push(`${layer} must not call fetch; network providers belong in convex/integrations`);
114
- if (
115
- layer !== "api" &&
116
- /\b(?:query|mutation|action|internalQuery|internalMutation|internalAction)\s*\(\s*\{/u.test(
117
- source,
118
- )
119
- )
120
- findings.push(`${layer} must not register Convex public/runtime functions`);
121
- return findings;
122
- }
123
-
124
- function matchingBrace(source: string, openIndex: number): number {
125
- let depth = 0;
126
- let quote: string | null = null;
127
- let escaped = false;
128
- for (let index = openIndex; index < source.length; index += 1) {
129
- const char = source[index] ?? "";
130
- if (quote) {
131
- if (escaped) escaped = false;
132
- else if (char === "\\") escaped = true;
133
- else if (char === quote) quote = null;
134
- continue;
135
- }
136
- if (char === '"' || char === "'" || char === "`") {
137
- quote = char;
138
- continue;
139
- }
140
- if (char === "{") depth += 1;
141
- if (char === "}") {
142
- depth -= 1;
143
- if (depth === 0) return index;
144
- }
145
- }
146
- return -1;
147
- }
148
-
149
- export type PublicFunctionContract = {
150
- readonly name: string;
151
- readonly kind: string;
152
- readonly body: string;
153
- };
154
- export function publicConvexFunctions(source: string): PublicFunctionContract[] {
155
- const result: PublicFunctionContract[] = [];
156
- const pattern = /export\s+const\s+(\w+)\s*=\s*(query|mutation|action)\s*\(\s*\{/gu;
157
- for (const match of source.matchAll(pattern)) {
158
- const whole = match[0] ?? "";
159
- const open = (match.index ?? 0) + whole.lastIndexOf("{");
160
- const close = matchingBrace(source, open);
161
- if (close === -1) continue;
162
- result.push({
163
- name: match[1] ?? "unknown",
164
- kind: match[2] ?? "unknown",
165
- body: source.slice(open + 1, close),
166
- });
167
- }
168
- return result;
169
- }
170
-
171
- export function publicFunctionContractViolations(source: string): string[] {
172
- const findings: string[] = [];
173
- for (const fn of publicConvexFunctions(source)) {
174
- if (!/(?:^|[,\n])\s*args\s*:/u.test(fn.body))
175
- findings.push(`${fn.name}: public Convex ${fn.kind} must declare args`);
176
- if (!/(?:^|[,\n])\s*returns\s*:/u.test(fn.body))
177
- findings.push(`${fn.name}: public Convex ${fn.kind} must declare returns`);
178
- }
179
- return findings;
180
- }
181
-
182
- export function boundaryTestQualityViolations(source: string): string[] {
183
- const findings: string[] = [];
184
- if (!/from\s+["']convex-test["']/u.test(source) || !/\bconvexTest\s*\(/u.test(source))
185
- findings.push("boundary test must execute through convex-test");
186
- if (!/\bt\.(?:query|mutation|action)\s*\(/u.test(source))
187
- findings.push("boundary test must invoke a Convex endpoint");
188
- return findings;
189
- }
190
-
191
- export function identityOutputMapperViolations(source: string): string[] {
192
- const findings: string[] = [];
193
- const pattern =
194
- /function\s+(\w*(?:view|value|output|dto)\w*)\s*\(\s*(\w+)\s*:[^)]+\)\s*\{\s*return\s+\2\s*;\s*\}/giu;
195
- for (const match of source.matchAll(pattern))
196
- findings.push(
197
- `${match[1]}: output mapper must explicitly construct the public contract; identity mappers can leak persistence fields`,
198
- );
199
- return findings;
200
- }
201
-
202
- export function schemaTechnologyViolations(file: string, source: string): string[] {
203
- const path = normalizePath(file);
204
- const findings: string[] = [];
205
- const internalConvex =
206
- path.startsWith("convex/application/") ||
207
- path.startsWith("convex/domain/") ||
208
- path.startsWith("convex/dal/");
209
- if (internalConvex && /from\s+["']zod["']/u.test(source))
210
- findings.push("Convex-internal contracts must use v validators, not Zod");
211
- if (/\b(?:zodToConvex|convexToZod|zodToV|vToZod)\b/u.test(source))
212
- findings.push(
213
- "schema conversion between Zod and Convex validators is forbidden; map values explicitly",
214
- );
215
- return findings;
216
- }
217
-
218
- const internalPackageAllowlist: Readonly<Record<BackendLayer, readonly string[]>> = {
219
- api: ["convex/values", "convex/server"],
220
- application: ["convex/values"],
221
- domain: [],
222
- dal: ["convex/values"],
223
- integration: ["zod"],
224
- };
225
-
226
- export function backendExternalImportViolation(file: string, spec: string): string | null {
227
- const layer = backendLayer(file);
228
- if (!layer || spec.startsWith(".") || spec.startsWith("@/")) return null;
229
- if (spec.startsWith("convex/_generated/")) return null;
230
- if (
231
- internalPackageAllowlist[layer].some(
232
- (allowed) => spec === allowed || spec.startsWith(`${allowed}/`),
233
- )
234
- )
235
- return null;
236
- if (layer === "integration") return null;
237
- return `${layer} must not import external package ${spec}; provider/runtime dependencies belong in convex/integrations`;
238
- }
239
-
240
- export function publicApiLogicViolations(source: string): string[] {
241
- const findings: string[] = [];
242
- for (const fn of publicConvexFunctions(source)) {
243
- const businessSyntax = [
244
- /\bif\s*\(/u,
245
- /\bfor\s*\(/u,
246
- /\bwhile\s*\(/u,
247
- /\bswitch\s*\(/u,
248
- /\.(?:map|filter|reduce|sort)\s*\(/u,
249
- /\.trim\s*\(/u,
250
- /\bMath\./u,
251
- /\bcrypto\./u,
252
- /\bnew\s+(?:Map|Set)\b/u,
253
- ];
254
- if (businessSyntax.some((pattern) => pattern.test(fn.body))) {
255
- findings.push(
256
- `${fn.name}: public Convex handler contains business/transformation logic; delegate it to application/domain`,
257
- );
258
- }
259
- }
260
- return findings;
261
- }
@@ -1,12 +0,0 @@
1
- # Design rules
2
-
3
- Use the local `DESIGN.md` and shadcn-style baseline. Keep operational UI
4
- mobile-first, thin, dense, readable, and responsive. Prefer slim controls,
5
- icon buttons, compact rows, and minimal spacing.
6
-
7
- Design-critical shells and pages must keep Storybook stories with `play` tests
8
- so visual contracts are exercised during `nps test.storybook`.
9
-
10
- Project-specific visual contracts live in
11
- `.agents/skills/design-rules/config.json`. Keep that config strict and explicit;
12
- do not hardcode product route paths in reusable boilerplate.
@@ -1,84 +0,0 @@
1
- import { runtime } from "../shared/runtime.ts";
2
- // oxlint-disable no-console no-await-in-loop
3
- const violations: string[] = [];
4
-
5
- type StoryContract = {
6
- readonly component: string;
7
- readonly story: string;
8
- readonly reason: string;
9
- };
10
-
11
- type DesignRulesConfig = {
12
- readonly schemaVersion: number;
13
- readonly requiredFiles?: readonly string[];
14
- readonly requiredStoryContracts?: readonly StoryContract[];
15
- };
16
-
17
- const defaultConfig: DesignRulesConfig = {
18
- schemaVersion: 1,
19
- requiredFiles: ["DESIGN.md", "components.json"],
20
- requiredStoryContracts: [],
21
- };
22
-
23
- async function exists(path: string): Promise<boolean> {
24
- try {
25
- await runtime.stat(path);
26
- return true;
27
- } catch {
28
- return false;
29
- }
30
- }
31
-
32
- async function readConfig(): Promise<DesignRulesConfig> {
33
- const configPath = new URL("./config.json", import.meta.url).pathname;
34
- try {
35
- const parsed = JSON.parse(await runtime.readTextFile(configPath)) as DesignRulesConfig;
36
- return {
37
- schemaVersion: parsed.schemaVersion,
38
- requiredFiles: parsed.requiredFiles ?? defaultConfig.requiredFiles,
39
- requiredStoryContracts: parsed.requiredStoryContracts ?? [],
40
- };
41
- } catch {
42
- return defaultConfig;
43
- }
44
- }
45
-
46
- function hasPlayTest(storyText: string): boolean {
47
- return /\bplay\s*:/u.test(storyText) || /\.play\s*=/u.test(storyText);
48
- }
49
-
50
- const config = await readConfig();
51
-
52
- if (config.schemaVersion !== 1) {
53
- violations.push(".agents/skills/design-rules/config.json: schemaVersion must be 1");
54
- }
55
-
56
- for (const path of config.requiredFiles ?? []) {
57
- if (!(await exists(path))) {
58
- violations.push(`missing design baseline file: ${path}`);
59
- }
60
- }
61
-
62
- for (const contract of config.requiredStoryContracts ?? []) {
63
- if (!(await exists(contract.component))) {
64
- violations.push(
65
- `${contract.component}: missing design-critical component (${contract.reason})`,
66
- );
67
- }
68
- if (!(await exists(contract.story))) {
69
- violations.push(`${contract.component}: missing ${contract.story} (${contract.reason})`);
70
- continue;
71
- }
72
-
73
- const storyText = await runtime.readTextFile(contract.story);
74
- if (!hasPlayTest(storyText)) {
75
- violations.push(`${contract.story}: missing Storybook play test (${contract.reason})`);
76
- }
77
- }
78
-
79
- if (violations.length) {
80
- console.error(violations.join("\n"));
81
- runtime.exit(1);
82
- }
83
-
84
- console.log("design-rules ok");
@@ -1,5 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "requiredFiles": ["DESIGN.md", "components.json"],
4
- "requiredStoryContracts": []
5
- }
@@ -1,38 +0,0 @@
1
- {
2
- "id": "design-rules",
3
- "kind": "rule",
4
- "version": "1.0.3",
5
- "requires": [
6
- "checker-runtime"
7
- ],
8
- "artifacts": [
9
- {
10
- "kind": "managed-file",
11
- "path": ".agents/skills/design-rules/SKILL.md",
12
- "source": "SKILL.md"
13
- },
14
- {
15
- "kind": "managed-file",
16
- "path": ".agents/skills/design-rules/check.ts",
17
- "source": "check.ts"
18
- },
19
- {
20
- "kind": "scaffold",
21
- "path": ".agents/skills/design-rules/config.json",
22
- "source": "config.json"
23
- },
24
- {
25
- "kind": "shared-markdown-section",
26
- "path": "AGENTS.md",
27
- "heading": "## Specdest rule: design-rules",
28
- "body": "Use `.agents/skills/design-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/design-rules/check.ts` before handoff."
29
- }
30
- ],
31
- "obsolete": [],
32
- "check": {
33
- "command": [
34
- "node",
35
- ".agents/skills/design-rules/check.ts"
36
- ]
37
- }
38
- }
@@ -1,46 +0,0 @@
1
- ---
2
- name: e2e-test-rules
3
- description: General rules for deterministic E2E tests, stable selectors, safe URLs, and failure artifacts.
4
- ---
5
-
6
- # E2E test rules
7
-
8
- Use this skill before adding or changing browser, device, or full-flow E2E tests.
9
-
10
- ## Rules
11
-
12
- - E2E tests must exercise user-visible flows and business-visible outcomes.
13
- - The repository quality gate must run the configured E2E suite; browser tests may not be optional/decorative.
14
- - Critical E2E specs configured by the project must exist and stay in the quality gate.
15
- - Playwright config references such as `globalSetup` must resolve to real files.
16
- - Prefer deterministic local component/browser fixtures over stale mocks of an application transport that has changed.
17
- - Use stable selectors, accessible labels, or explicit test ids.
18
- - Do not use arbitrary sleeps such as `page.waitForTimeout`.
19
- - Do not call production APIs or hardcode production URLs.
20
- - Use a configured base URL, preferably from environment.
21
- - Keep traces, screenshots, and videos enabled on failure when using Playwright.
22
- - Keep seed/reset/login setup deterministic and documented.
23
- - Destructive local reset flows must require an explicit environment flag.
24
-
25
- ## Project-specific TODO
26
-
27
- - List allowed test domains.
28
- - Define the seed/reset command.
29
- - Define the login/auth helper.
30
- - Define the stable selector convention.
31
- - Decide which browsers/devices are required.
32
- - Decide artifact retention for screenshots, videos, traces, and reports.
33
-
34
- ## Check
35
-
36
- Run before handoff:
37
-
38
- ```bash
39
- nps lint
40
- ```
41
-
42
- Direct checker:
43
-
44
- ```bash
45
- node .agents/skills/e2e-test-rules/check.ts
46
- ```
@@ -1,145 +0,0 @@
1
- import { runtime } from "../shared/runtime.ts";
2
- // oxlint-disable no-console no-await-in-loop
3
- import { assertSchemaVersion, readSkillConfig } from "../shared/config.ts";
4
- import { exists, walk } from "../shared/fs.ts";
5
-
6
- type Config = {
7
- schemaVersion: number;
8
- e2eRoots?: string[];
9
- playwrightConfigs?: string[];
10
- requiredDocs?: string[];
11
- allowedUrlPatterns?: string[];
12
- forbiddenPatterns?: string[];
13
- ignoredDirectories?: string[];
14
- requiredCriticalSpecs?: string[];
15
- qualityGateFile?: string;
16
- qualityGateMarkers?: string[];
17
- requiredConfigMarkers?: string[];
18
- };
19
-
20
- const { config, root } = await readSkillConfig<Config>(import.meta.url);
21
- assertSchemaVersion(config.schemaVersion);
22
-
23
- const ignoredDirectories = new Set(config.ignoredDirectories ?? []);
24
- const e2eRoots = config.e2eRoots ?? ["tests/e2e"];
25
- const playwrightConfigs = config.playwrightConfigs ?? [
26
- "playwright.e2e.config.ts",
27
- "playwright.config.ts",
28
- ];
29
- const requiredDocs = config.requiredDocs ?? ["docs/testing/e2e.md"];
30
- const forbiddenPatterns = config.forbiddenPatterns ?? [
31
- "page.waitForTimeout(",
32
- "waitForTimeout(",
33
- "sleep(",
34
- ];
35
- const allowedUrlPatterns = config.allowedUrlPatterns ?? ["http://localhost", "http://127.0.0.1"];
36
- const requiredCriticalSpecs = config.requiredCriticalSpecs ?? [];
37
- const qualityGateFile = config.qualityGateFile;
38
- const qualityGateMarkers = config.qualityGateMarkers ?? [];
39
- const requiredConfigMarkers = config.requiredConfigMarkers ?? [];
40
- const checkedFilePattern = /\.(ts|tsx|js|jsx|mjs|cjs|yaml|yml)$/;
41
- const urlPattern = /https?:\/\/[^\s"'`)]+/g;
42
-
43
- function isAllowedUrl(url: string): boolean {
44
- return allowedUrlPatterns.some((pattern) => url.startsWith(pattern));
45
- }
46
-
47
- const violations: string[] = [];
48
- const e2eFiles: string[] = [];
49
- for (const e2eRoot of e2eRoots) {
50
- e2eFiles.push(
51
- ...(
52
- await walk(`${root}/${e2eRoot}`, {
53
- ignoredDirectories,
54
- relativeDirectory: e2eRoot,
55
- })
56
- ).filter((file) => checkedFilePattern.test(file)),
57
- );
58
- }
59
-
60
- for (const file of e2eFiles.toSorted()) {
61
- const text = await runtime.readTextFile(`${root}/${file}`);
62
- for (const pattern of forbiddenPatterns) {
63
- if (text.includes(pattern)) {
64
- violations.push(`${file}: E2E test contains forbidden pattern ${JSON.stringify(pattern)}`);
65
- }
66
- }
67
- for (const match of text.matchAll(urlPattern)) {
68
- const url = match[0];
69
- if (!isAllowedUrl(url)) {
70
- violations.push(`${file}: E2E test contains non-local URL ${url}`);
71
- }
72
- }
73
- }
74
-
75
- const presentConfigs: string[] = [];
76
- for (const relativePath of playwrightConfigs) {
77
- if (await exists(`${root}/${relativePath}`)) {
78
- presentConfigs.push(relativePath);
79
- }
80
- }
81
-
82
- for (const relativePath of presentConfigs) {
83
- const text = await runtime.readTextFile(`${root}/${relativePath}`);
84
- for (const marker of requiredConfigMarkers) {
85
- if (!text.includes(marker)) {
86
- violations.push(
87
- `${relativePath}: Playwright config is missing required marker ${JSON.stringify(marker)}`,
88
- );
89
- }
90
- }
91
- const globalSetupMatch = text.match(/globalSetup:\s*["']([^"']+)["']/);
92
- if (
93
- globalSetupMatch?.[1] &&
94
- !(await exists(`${root}/${globalSetupMatch[1].replace(/^\.\//, "")}`))
95
- ) {
96
- violations.push(
97
- `${relativePath}: configured globalSetup file does not exist: ${globalSetupMatch[1]}`,
98
- );
99
- }
100
- if (!text.includes("trace:") || !text.includes("retain-on-failure")) {
101
- violations.push(`${relativePath}: Playwright config must retain traces on failure`);
102
- }
103
- if (!text.includes("screenshot:") || !text.includes("only-on-failure")) {
104
- violations.push(`${relativePath}: Playwright config must capture screenshots on failure`);
105
- }
106
- if (!text.includes("video:") || !text.includes("retain-on-failure")) {
107
- violations.push(`${relativePath}: Playwright config must retain videos on failure`);
108
- }
109
- if (!text.includes("baseURL") || !text.includes("E2E_BASE_URL")) {
110
- violations.push(`${relativePath}: Playwright config must use configured E2E_BASE_URL baseURL`);
111
- }
112
- }
113
-
114
- for (const spec of requiredCriticalSpecs) {
115
- if (!(await exists(`${root}/${spec}`))) {
116
- violations.push(`${spec}: required critical E2E spec is missing`);
117
- }
118
- }
119
-
120
- if (qualityGateFile) {
121
- if (!(await exists(`${root}/${qualityGateFile}`))) {
122
- violations.push(`${qualityGateFile}: configured quality gate file is missing`);
123
- } else {
124
- const qualityGateText = await runtime.readTextFile(`${root}/${qualityGateFile}`);
125
- for (const marker of qualityGateMarkers) {
126
- if (!qualityGateText.includes(marker)) {
127
- violations.push(
128
- `${qualityGateFile}: quality gate is missing required E2E marker ${JSON.stringify(marker)}`,
129
- );
130
- }
131
- }
132
- }
133
- }
134
-
135
- if (e2eFiles.length > 0 || presentConfigs.length > 0) {
136
- for (const doc of requiredDocs) {
137
- if (!(await exists(`${root}/${doc}`))) {
138
- violations.push(`${doc}: missing E2E testing documentation/TODO`);
139
- }
140
- }
141
- }
142
-
143
- console.log(`# e2e test rule violations: ${violations.length}`);
144
- for (const violation of violations) console.log(`- ${violation}`);
145
- if (violations.length > 0) runtime.exit(1);
@@ -1,32 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "e2eRoots": ["tests/e2e"],
4
- "playwrightConfigs": ["playwright.e2e.config.ts", "playwright.config.ts"],
5
- "allowedUrlPatterns": [
6
- "http://localhost",
7
- "http://127.0.0.1",
8
- "https://localhost",
9
- "https://127.0.0.1"
10
- ],
11
- "forbiddenPatterns": [
12
- "page.waitForTimeout(",
13
- "waitForTimeout(",
14
- "sleep(",
15
- "https://prod",
16
- "http://prod"
17
- ],
18
- "ignoredDirectories": [
19
- ".git",
20
- "code-templates",
21
- "node_modules",
22
- "dist",
23
- "build",
24
- "coverage",
25
- "playwright-report",
26
- "test-results"
27
- ],
28
- "requiredConfigMarkers": ["webServer:"],
29
- "requiredDocs": [],
30
- "requiredCriticalSpecs": [],
31
- "qualityGateMarkers": []
32
- }
@@ -1,38 +0,0 @@
1
- {
2
- "id": "e2e-test-rules",
3
- "kind": "rule",
4
- "version": "1.0.4",
5
- "requires": [
6
- "checker-runtime"
7
- ],
8
- "artifacts": [
9
- {
10
- "kind": "managed-file",
11
- "path": ".agents/skills/e2e-test-rules/SKILL.md",
12
- "source": "SKILL.md"
13
- },
14
- {
15
- "kind": "managed-file",
16
- "path": ".agents/skills/e2e-test-rules/check.ts",
17
- "source": "check.ts"
18
- },
19
- {
20
- "kind": "scaffold",
21
- "path": ".agents/skills/e2e-test-rules/config.json",
22
- "source": "config.json"
23
- },
24
- {
25
- "kind": "shared-markdown-section",
26
- "path": "AGENTS.md",
27
- "heading": "## Specdest rule: e2e-test-rules",
28
- "body": "Use `.agents/skills/e2e-test-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/e2e-test-rules/check.ts` before handoff."
29
- }
30
- ],
31
- "obsolete": [],
32
- "check": {
33
- "command": [
34
- "node",
35
- ".agents/skills/e2e-test-rules/check.ts"
36
- ]
37
- }
38
- }
@@ -1,21 +0,0 @@
1
- # Error handling rules
2
-
3
- Use this skill when adding or changing application error handling.
4
-
5
- ## Rules
6
-
7
- - Do not use `throw new Error()` in `src/**` application code.
8
- - Use `raise(ERROR_CODE)` from `@/shared/errors/raise` for app-owned errors.
9
- - Keep error codes in `src/shared/errors/error-catalog.ts` TypeScript-safe.
10
- - User-facing messages must be Japanese in production.
11
- - Production public responses must not include raw stack traces, database
12
- errors, tokens, request bodies, or internal file paths.
13
- - Expected errors should normally have `reportToSentry: false`.
14
- - Unknown/system errors should normalize to `INTERNAL_ERROR` and report.
15
- - Do not add project-specific business error codes to this template.
16
-
17
- ## Allowed exceptions
18
-
19
- - `src/shared/errors/**` may construct `AppError` internally.
20
- - Tests may use raw `Error` objects to assert normalization.
21
- - TanStack Router redirect throws are allowed.