@specdest/devkit 0.1.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 (137) hide show
  1. package/catalog/README.md +11 -0
  2. package/catalog/modules/backend-convex/manifest.json +14 -0
  3. package/catalog/modules/backend-convex-expo/manifest.json +11 -0
  4. package/catalog/modules/backend-supabase/manifest.json +15 -0
  5. package/catalog/modules/backend-supabase-expo/manifest.json +11 -0
  6. package/catalog/modules/checker-runtime/config.ts +24 -0
  7. package/catalog/modules/checker-runtime/fs.ts +47 -0
  8. package/catalog/modules/checker-runtime/manifest.json +23 -0
  9. package/catalog/modules/devflow/.agents/skills/devflow/SKILL.md +33 -0
  10. package/catalog/modules/devflow/.devflow.json +10 -0
  11. package/catalog/modules/devflow/manifest.json +35 -0
  12. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/SKILL.md +85 -0
  13. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/activeScenario.mjs +130 -0
  14. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs +7 -0
  15. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs +36 -0
  16. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/createActiveScenario.mjs +143 -0
  17. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs +43 -0
  18. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/prompt.mjs +25 -0
  19. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs +66 -0
  20. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs +146 -0
  21. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seed.mjs +56 -0
  22. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs +6 -0
  23. package/catalog/modules/e2e-playwright/docs/e2e-playwright/README.md +103 -0
  24. package/catalog/modules/e2e-playwright/manifest.json +206 -0
  25. package/catalog/modules/e2e-playwright/playwright.e2e.config.ts +39 -0
  26. package/catalog/modules/e2e-playwright/tests/e2e/support/e2ePlaywrightFlow.ts +107 -0
  27. package/catalog/modules/e2e-playwright/tests/e2e/support/fixtures.ts +27 -0
  28. package/catalog/modules/local-log/AGENTS.local-log.md +13 -0
  29. package/catalog/modules/local-log/docs/features/local-logging/README.md +70 -0
  30. package/catalog/modules/local-log/manifest.json +39 -0
  31. package/catalog/modules/local-log/tmp/logs/.gitignore +2 -0
  32. package/catalog/modules/local-log/tools/local-log/README.md +47 -0
  33. package/catalog/modules/local-log/tools/local-log/local-log.mjs +241 -0
  34. package/catalog/modules/stack-common-vite/manifest.json +16 -0
  35. package/catalog/modules/stack-expo-convex/manifest.json +31 -0
  36. package/catalog/modules/stack-expo-supabase/manifest.json +44 -0
  37. package/catalog/modules/stack-vite-convex/manifest.json +32 -0
  38. package/catalog/modules/stack-vite-supabase/manifest.json +45 -0
  39. package/catalog/rules/abac-permissions-convex/SKILL.md +17 -0
  40. package/catalog/rules/abac-permissions-convex/check.ts +86 -0
  41. package/catalog/rules/abac-permissions-convex/manifest.json +35 -0
  42. package/catalog/rules/abac-permissions-supabase/SKILL.md +17 -0
  43. package/catalog/rules/abac-permissions-supabase/check.ts +86 -0
  44. package/catalog/rules/abac-permissions-supabase/manifest.json +35 -0
  45. package/catalog/rules/convex-multi-presentation/SKILL.md +48 -0
  46. package/catalog/rules/convex-multi-presentation/boundary-test-baseline.json +3 -0
  47. package/catalog/rules/convex-multi-presentation/check.ts +271 -0
  48. package/catalog/rules/convex-multi-presentation/manifest.json +45 -0
  49. package/catalog/rules/convex-multi-presentation/policy.ts +261 -0
  50. package/catalog/rules/design-rules/SKILL.md +12 -0
  51. package/catalog/rules/design-rules/check.ts +83 -0
  52. package/catalog/rules/design-rules/config.json +5 -0
  53. package/catalog/rules/design-rules/manifest.json +40 -0
  54. package/catalog/rules/e2e-test-rules/SKILL.md +46 -0
  55. package/catalog/rules/e2e-test-rules/check.ts +144 -0
  56. package/catalog/rules/e2e-test-rules/config.json +32 -0
  57. package/catalog/rules/e2e-test-rules/manifest.json +40 -0
  58. package/catalog/rules/error-handling-rules/SKILL.md +21 -0
  59. package/catalog/rules/error-handling-rules/check.ts +72 -0
  60. package/catalog/rules/error-handling-rules/manifest.json +35 -0
  61. package/catalog/rules/layers-and-contracts/SKILL.md +36 -0
  62. package/catalog/rules/layers-and-contracts/check.ts +265 -0
  63. package/catalog/rules/layers-and-contracts/manifest.json +35 -0
  64. package/catalog/rules/layers-and-contracts-convex/SKILL.md +49 -0
  65. package/catalog/rules/layers-and-contracts-convex/check.ts +288 -0
  66. package/catalog/rules/layers-and-contracts-convex/manifest.json +40 -0
  67. package/catalog/rules/layers-and-contracts-convex/policy.ts +68 -0
  68. package/catalog/rules/layers-and-contracts-supabase/SKILL.md +52 -0
  69. package/catalog/rules/layers-and-contracts-supabase/check.ts +370 -0
  70. package/catalog/rules/layers-and-contracts-supabase/manifest.json +40 -0
  71. package/catalog/rules/layers-and-contracts-supabase/policy.ts +68 -0
  72. package/catalog/rules/module-size-rules/SKILL.md +5 -0
  73. package/catalog/rules/module-size-rules/check.ts +143 -0
  74. package/catalog/rules/module-size-rules/config.json +6 -0
  75. package/catalog/rules/module-size-rules/manifest.json +40 -0
  76. package/catalog/rules/module-size-rules-convex/SKILL.md +5 -0
  77. package/catalog/rules/module-size-rules-convex/check.ts +145 -0
  78. package/catalog/rules/module-size-rules-convex/config.json +6 -0
  79. package/catalog/rules/module-size-rules-convex/manifest.json +40 -0
  80. package/catalog/rules/module-size-rules-supabase/SKILL.md +5 -0
  81. package/catalog/rules/module-size-rules-supabase/check.ts +145 -0
  82. package/catalog/rules/module-size-rules-supabase/config.json +12 -0
  83. package/catalog/rules/module-size-rules-supabase/manifest.json +40 -0
  84. package/catalog/rules/mutation-command-rules/SKILL.md +15 -0
  85. package/catalog/rules/mutation-command-rules/check.ts +29 -0
  86. package/catalog/rules/mutation-command-rules/config.json +19 -0
  87. package/catalog/rules/mutation-command-rules/manifest.json +40 -0
  88. package/catalog/rules/nearby-contracts/SKILL.md +18 -0
  89. package/catalog/rules/nearby-contracts/check.ts +137 -0
  90. package/catalog/rules/nearby-contracts/config.json +10 -0
  91. package/catalog/rules/nearby-contracts/manifest.json +40 -0
  92. package/catalog/rules/no-raw-click-buttons/SKILL.md +5 -0
  93. package/catalog/rules/no-raw-click-buttons/check.ts +36 -0
  94. package/catalog/rules/no-raw-click-buttons/manifest.json +35 -0
  95. package/catalog/rules/public-api-export-barrels/SKILL.md +45 -0
  96. package/catalog/rules/public-api-export-barrels/check.ts +72 -0
  97. package/catalog/rules/public-api-export-barrels/config.json +4 -0
  98. package/catalog/rules/public-api-export-barrels/manifest.json +40 -0
  99. package/catalog/rules/route-tree-fresh/SKILL.md +16 -0
  100. package/catalog/rules/route-tree-fresh/check.ts +64 -0
  101. package/catalog/rules/route-tree-fresh/manifest.json +35 -0
  102. package/catalog/rules/strict-typescript/SKILL.md +3 -0
  103. package/catalog/rules/strict-typescript/check.ts +111 -0
  104. package/catalog/rules/strict-typescript/manifest.json +35 -0
  105. package/catalog/rules/supabase-contracts/SKILL.md +3 -0
  106. package/catalog/rules/supabase-contracts/check.ts +171 -0
  107. package/catalog/rules/supabase-contracts/manifest.json +35 -0
  108. package/catalog/rules/supabase-declarative-schema/SKILL.md +30 -0
  109. package/catalog/rules/supabase-declarative-schema/check.ts +261 -0
  110. package/catalog/rules/supabase-declarative-schema/config.json +8 -0
  111. package/catalog/rules/supabase-declarative-schema/manifest.json +40 -0
  112. package/catalog/rules/tanstack-form-rules/SKILL.md +11 -0
  113. package/catalog/rules/tanstack-form-rules/check.ts +57 -0
  114. package/catalog/rules/tanstack-form-rules/manifest.json +35 -0
  115. package/catalog/rules/unit-test-rules/SKILL.md +55 -0
  116. package/catalog/rules/unit-test-rules/check.ts +131 -0
  117. package/catalog/rules/unit-test-rules/config.json +22 -0
  118. package/catalog/rules/unit-test-rules/manifest.json +40 -0
  119. package/catalog/rules/unit-test-rules-convex/SKILL.md +41 -0
  120. package/catalog/rules/unit-test-rules-convex/check.ts +417 -0
  121. package/catalog/rules/unit-test-rules-convex/manifest.json +35 -0
  122. package/catalog/rules/unit-test-rules-supabase/SKILL.md +40 -0
  123. package/catalog/rules/unit-test-rules-supabase/check.ts +491 -0
  124. package/catalog/rules/unit-test-rules-supabase/manifest.json +35 -0
  125. package/catalog/rules/workstation-controller-rules/SKILL.md +22 -0
  126. package/catalog/rules/workstation-controller-rules/check.ts +107 -0
  127. package/catalog/rules/workstation-controller-rules/manifest.json +35 -0
  128. package/package.json +22 -0
  129. package/src/catalog-snapshot.js +39 -0
  130. package/src/catalog.js +117 -0
  131. package/src/cli.js +11 -0
  132. package/src/index.js +30 -0
  133. package/src/installer-primitives.js +198 -0
  134. package/src/project-operations.js +126 -0
  135. package/src/setup-requirements.js +82 -0
  136. package/src/shared-file.js +131 -0
  137. package/src/sync-core.js +276 -0
@@ -0,0 +1,45 @@
1
+ {
2
+ "id": "convex-multi-presentation",
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/convex-multi-presentation/SKILL.md",
12
+ "source": "SKILL.md"
13
+ },
14
+ {
15
+ "kind": "scaffold",
16
+ "path": ".agents/skills/convex-multi-presentation/boundary-test-baseline.json",
17
+ "source": "boundary-test-baseline.json"
18
+ },
19
+ {
20
+ "kind": "managed-file",
21
+ "path": ".agents/skills/convex-multi-presentation/check.ts",
22
+ "source": "check.ts"
23
+ },
24
+ {
25
+ "kind": "managed-file",
26
+ "path": ".agents/skills/convex-multi-presentation/policy.ts",
27
+ "source": "policy.ts"
28
+ },
29
+ {
30
+ "kind": "shared-markdown-section",
31
+ "path": "AGENTS.md",
32
+ "heading": "## Specdest rule: convex-multi-presentation",
33
+ "body": "Use `.agents/skills/convex-multi-presentation/SKILL.md` when working in this rule area. Run `deno run --allow-read .agents/skills/convex-multi-presentation/check.ts` before handoff."
34
+ }
35
+ ],
36
+ "obsolete": [],
37
+ "check": {
38
+ "command": [
39
+ "deno",
40
+ "run",
41
+ "--allow-read",
42
+ ".agents/skills/convex-multi-presentation/check.ts"
43
+ ]
44
+ }
45
+ }
@@ -0,0 +1,261 @@
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
+ }
@@ -0,0 +1,12 @@
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.
@@ -0,0 +1,83 @@
1
+ // oxlint-disable no-console no-await-in-loop
2
+ const violations: string[] = [];
3
+
4
+ type StoryContract = {
5
+ readonly component: string;
6
+ readonly story: string;
7
+ readonly reason: string;
8
+ };
9
+
10
+ type DesignRulesConfig = {
11
+ readonly schemaVersion: number;
12
+ readonly requiredFiles?: readonly string[];
13
+ readonly requiredStoryContracts?: readonly StoryContract[];
14
+ };
15
+
16
+ const defaultConfig: DesignRulesConfig = {
17
+ schemaVersion: 1,
18
+ requiredFiles: ["DESIGN.md", "components.json"],
19
+ requiredStoryContracts: [],
20
+ };
21
+
22
+ async function exists(path: string): Promise<boolean> {
23
+ try {
24
+ await Deno.stat(path);
25
+ return true;
26
+ } catch {
27
+ return false;
28
+ }
29
+ }
30
+
31
+ async function readConfig(): Promise<DesignRulesConfig> {
32
+ const configPath = new URL("./config.json", import.meta.url).pathname;
33
+ try {
34
+ const parsed = JSON.parse(await Deno.readTextFile(configPath)) as DesignRulesConfig;
35
+ return {
36
+ schemaVersion: parsed.schemaVersion,
37
+ requiredFiles: parsed.requiredFiles ?? defaultConfig.requiredFiles,
38
+ requiredStoryContracts: parsed.requiredStoryContracts ?? [],
39
+ };
40
+ } catch {
41
+ return defaultConfig;
42
+ }
43
+ }
44
+
45
+ function hasPlayTest(storyText: string): boolean {
46
+ return /\bplay\s*:/u.test(storyText) || /\.play\s*=/u.test(storyText);
47
+ }
48
+
49
+ const config = await readConfig();
50
+
51
+ if (config.schemaVersion !== 1) {
52
+ violations.push(".agents/skills/design-rules/config.json: schemaVersion must be 1");
53
+ }
54
+
55
+ for (const path of config.requiredFiles ?? []) {
56
+ if (!(await exists(path))) {
57
+ violations.push(`missing design baseline file: ${path}`);
58
+ }
59
+ }
60
+
61
+ for (const contract of config.requiredStoryContracts ?? []) {
62
+ if (!(await exists(contract.component))) {
63
+ violations.push(
64
+ `${contract.component}: missing design-critical component (${contract.reason})`,
65
+ );
66
+ }
67
+ if (!(await exists(contract.story))) {
68
+ violations.push(`${contract.component}: missing ${contract.story} (${contract.reason})`);
69
+ continue;
70
+ }
71
+
72
+ const storyText = await Deno.readTextFile(contract.story);
73
+ if (!hasPlayTest(storyText)) {
74
+ violations.push(`${contract.story}: missing Storybook play test (${contract.reason})`);
75
+ }
76
+ }
77
+
78
+ if (violations.length) {
79
+ console.error(violations.join("\n"));
80
+ Deno.exit(1);
81
+ }
82
+
83
+ console.log("design-rules ok");
@@ -0,0 +1,5 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "requiredFiles": ["DESIGN.md", "components.json"],
4
+ "requiredStoryContracts": []
5
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "id": "design-rules",
3
+ "kind": "rule",
4
+ "version": "1.0.2",
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 `deno run --allow-read .agents/skills/design-rules/check.ts` before handoff."
29
+ }
30
+ ],
31
+ "obsolete": [],
32
+ "check": {
33
+ "command": [
34
+ "deno",
35
+ "run",
36
+ "--allow-read",
37
+ ".agents/skills/design-rules/check.ts"
38
+ ]
39
+ }
40
+ }
@@ -0,0 +1,46 @@
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
+ deno run --allow-read .agents/skills/e2e-test-rules/check.ts
46
+ ```
@@ -0,0 +1,144 @@
1
+ // oxlint-disable no-console no-await-in-loop
2
+ import { assertSchemaVersion, readSkillConfig } from "../shared/config.ts";
3
+ import { exists, walk } from "../shared/fs.ts";
4
+
5
+ type Config = {
6
+ schemaVersion: number;
7
+ e2eRoots?: string[];
8
+ playwrightConfigs?: string[];
9
+ requiredDocs?: string[];
10
+ allowedUrlPatterns?: string[];
11
+ forbiddenPatterns?: string[];
12
+ ignoredDirectories?: string[];
13
+ requiredCriticalSpecs?: string[];
14
+ qualityGateFile?: string;
15
+ qualityGateMarkers?: string[];
16
+ requiredConfigMarkers?: string[];
17
+ };
18
+
19
+ const { config, root } = await readSkillConfig<Config>(import.meta.url);
20
+ assertSchemaVersion(config.schemaVersion);
21
+
22
+ const ignoredDirectories = new Set(config.ignoredDirectories ?? []);
23
+ const e2eRoots = config.e2eRoots ?? ["tests/e2e"];
24
+ const playwrightConfigs = config.playwrightConfigs ?? [
25
+ "playwright.e2e.config.ts",
26
+ "playwright.config.ts",
27
+ ];
28
+ const requiredDocs = config.requiredDocs ?? ["docs/testing/e2e.md"];
29
+ const forbiddenPatterns = config.forbiddenPatterns ?? [
30
+ "page.waitForTimeout(",
31
+ "waitForTimeout(",
32
+ "sleep(",
33
+ ];
34
+ const allowedUrlPatterns = config.allowedUrlPatterns ?? ["http://localhost", "http://127.0.0.1"];
35
+ const requiredCriticalSpecs = config.requiredCriticalSpecs ?? [];
36
+ const qualityGateFile = config.qualityGateFile;
37
+ const qualityGateMarkers = config.qualityGateMarkers ?? [];
38
+ const requiredConfigMarkers = config.requiredConfigMarkers ?? [];
39
+ const checkedFilePattern = /\.(ts|tsx|js|jsx|mjs|cjs|yaml|yml)$/;
40
+ const urlPattern = /https?:\/\/[^\s"'`)]+/g;
41
+
42
+ function isAllowedUrl(url: string): boolean {
43
+ return allowedUrlPatterns.some((pattern) => url.startsWith(pattern));
44
+ }
45
+
46
+ const violations: string[] = [];
47
+ const e2eFiles: string[] = [];
48
+ for (const e2eRoot of e2eRoots) {
49
+ e2eFiles.push(
50
+ ...(
51
+ await walk(`${root}/${e2eRoot}`, {
52
+ ignoredDirectories,
53
+ relativeDirectory: e2eRoot,
54
+ })
55
+ ).filter((file) => checkedFilePattern.test(file)),
56
+ );
57
+ }
58
+
59
+ for (const file of e2eFiles.toSorted()) {
60
+ const text = await Deno.readTextFile(`${root}/${file}`);
61
+ for (const pattern of forbiddenPatterns) {
62
+ if (text.includes(pattern)) {
63
+ violations.push(`${file}: E2E test contains forbidden pattern ${JSON.stringify(pattern)}`);
64
+ }
65
+ }
66
+ for (const match of text.matchAll(urlPattern)) {
67
+ const url = match[0];
68
+ if (!isAllowedUrl(url)) {
69
+ violations.push(`${file}: E2E test contains non-local URL ${url}`);
70
+ }
71
+ }
72
+ }
73
+
74
+ const presentConfigs: string[] = [];
75
+ for (const relativePath of playwrightConfigs) {
76
+ if (await exists(`${root}/${relativePath}`)) {
77
+ presentConfigs.push(relativePath);
78
+ }
79
+ }
80
+
81
+ for (const relativePath of presentConfigs) {
82
+ const text = await Deno.readTextFile(`${root}/${relativePath}`);
83
+ for (const marker of requiredConfigMarkers) {
84
+ if (!text.includes(marker)) {
85
+ violations.push(
86
+ `${relativePath}: Playwright config is missing required marker ${JSON.stringify(marker)}`,
87
+ );
88
+ }
89
+ }
90
+ const globalSetupMatch = text.match(/globalSetup:\s*["']([^"']+)["']/);
91
+ if (
92
+ globalSetupMatch?.[1] &&
93
+ !(await exists(`${root}/${globalSetupMatch[1].replace(/^\.\//, "")}`))
94
+ ) {
95
+ violations.push(
96
+ `${relativePath}: configured globalSetup file does not exist: ${globalSetupMatch[1]}`,
97
+ );
98
+ }
99
+ if (!text.includes("trace:") || !text.includes("retain-on-failure")) {
100
+ violations.push(`${relativePath}: Playwright config must retain traces on failure`);
101
+ }
102
+ if (!text.includes("screenshot:") || !text.includes("only-on-failure")) {
103
+ violations.push(`${relativePath}: Playwright config must capture screenshots on failure`);
104
+ }
105
+ if (!text.includes("video:") || !text.includes("retain-on-failure")) {
106
+ violations.push(`${relativePath}: Playwright config must retain videos on failure`);
107
+ }
108
+ if (!text.includes("baseURL") || !text.includes("E2E_BASE_URL")) {
109
+ violations.push(`${relativePath}: Playwright config must use configured E2E_BASE_URL baseURL`);
110
+ }
111
+ }
112
+
113
+ for (const spec of requiredCriticalSpecs) {
114
+ if (!(await exists(`${root}/${spec}`))) {
115
+ violations.push(`${spec}: required critical E2E spec is missing`);
116
+ }
117
+ }
118
+
119
+ if (qualityGateFile) {
120
+ if (!(await exists(`${root}/${qualityGateFile}`))) {
121
+ violations.push(`${qualityGateFile}: configured quality gate file is missing`);
122
+ } else {
123
+ const qualityGateText = await Deno.readTextFile(`${root}/${qualityGateFile}`);
124
+ for (const marker of qualityGateMarkers) {
125
+ if (!qualityGateText.includes(marker)) {
126
+ violations.push(
127
+ `${qualityGateFile}: quality gate is missing required E2E marker ${JSON.stringify(marker)}`,
128
+ );
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ if (e2eFiles.length > 0 || presentConfigs.length > 0) {
135
+ for (const doc of requiredDocs) {
136
+ if (!(await exists(`${root}/${doc}`))) {
137
+ violations.push(`${doc}: missing E2E testing documentation/TODO`);
138
+ }
139
+ }
140
+ }
141
+
142
+ console.log(`# e2e test rule violations: ${violations.length}`);
143
+ for (const violation of violations) console.log(`- ${violation}`);
144
+ if (violations.length > 0) Deno.exit(1);
@@ -0,0 +1,32 @@
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
+ }