@specdest/devkit 0.2.2 → 0.3.1
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 +17 -18
- package/package.json +4 -4
- package/src/canonical-project-operations.js +164 -0
- package/src/canonical-project.js +78 -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 +478 -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,47 +0,0 @@
|
|
|
1
|
-
# Convex multi-presentation architecture
|
|
2
|
-
|
|
3
|
-
Base uses one Convex backend for every presentation adapter.
|
|
4
|
-
|
|
5
|
-
Required dependency flow:
|
|
6
|
-
|
|
7
|
-
`Web / CLI / Zora / MCP -> Convex public API -> Application -> Domain/DAL or Integrations`
|
|
8
|
-
|
|
9
|
-
Rules:
|
|
10
|
-
|
|
11
|
-
- Presentation adapters contain transport, interaction, rendering, and presentation mapping only. Business rules belong in the backend.
|
|
12
|
-
- Base has exactly one MCP presentation: the Convex-hosted `/mcp` endpoint. Do not add a controller-hosted Base Todo MCP server, stdio adapter, or second Base MCP transport.
|
|
13
|
-
- Web React may use `useQuery`, `useMutation`, and `useAction` only in route-local data hooks. CLI, Zora, and MCP use a Convex client adapter against the same public API.
|
|
14
|
-
- Presentation code must never import Convex backend application, domain, DAL, or provider integration modules directly.
|
|
15
|
-
- Root `convex/*.ts` public function modules are transport adapters. They validate `args` and `returns` and delegate to application use cases.
|
|
16
|
-
- Public Convex handlers must not query `ctx.db`, call external providers, or contain reusable business rules.
|
|
17
|
-
- `convex/application/**` owns use-case orchestration. Boundary façade modules own the reusable input/output contracts and focused use-case tests. Implementation-only splits belong under `convex/application/**/internal/`; they inherit the façade boundary and must never be imported directly by public API modules. Application code may depend on domain, DAL persistence, and provider interfaces in `convex/integrations/**`, never presentation or raw Convex DB primitives directly.
|
|
18
|
-
- `convex/domain/**` owns pure business rules and must not depend on Convex runtime, DB, network, application, DAL, or integrations.
|
|
19
|
-
- `convex/dal/**` is persistence only: it owns Convex DB persistence, DB primitives must not escape it, and it must never proxy/re-export network providers.
|
|
20
|
-
- `convex/integrations/**` owns external providers such as GitHub, Google Calendar, Notion, and Todoist. Application use cases call these adapters directly; provider payloads must be mapped into application models before crossing the public API.
|
|
21
|
-
- Dependency direction is one way. No upward imports and no layer skipping.
|
|
22
|
-
|
|
23
|
-
## Contracts
|
|
24
|
-
|
|
25
|
-
- Convex `v` validators are canonical for Convex-native API and application contracts.
|
|
26
|
-
- Every public `query`, `mutation`, or `action` must declare both `args` and `returns`.
|
|
27
|
-
- Application boundary values use reusable `v` validators and `Infer<typeof validator>` types. Do not hand-write duplicate boundary object types.
|
|
28
|
-
- Do not maintain equivalent Zod and Convex schemas or add automatic `v <-> Zod` converters.
|
|
29
|
-
- Zod is reserved for non-Convex untrusted data: external HTTP/provider payloads, environment/config input, and presentation forms when appropriate.
|
|
30
|
-
- External provider payloads are Zod-validated, then explicitly mapped as values into internal application models.
|
|
31
|
-
- Provider-specific payload types must not leak into application or domain code.
|
|
32
|
-
- Small internal helpers and implementation splits under an `internal/` directory do not need standalone runtime contract files; their boundary façade remains responsible for contracts and focused tests.
|
|
33
|
-
- `convex/schema.ts` may compose schema fragments from `convex/schema/**`; those fragments are Convex framework plumbing, not application/DAL boundaries.
|
|
34
|
-
|
|
35
|
-
## Testing and enforcement
|
|
36
|
-
|
|
37
|
-
- Application use cases must be independently unit-testable with only immediate DAL/domain dependencies mocked.
|
|
38
|
-
- Domain rules must have pure unit tests.
|
|
39
|
-
- DAL and provider adapters need focused boundary/contract tests.
|
|
40
|
-
- Public Convex functions need boundary tests executed through `convex-test` for accepted args, rejected invalid args, and validated returns. Export-only smoke tests do not satisfy this rule.
|
|
41
|
-
- Public-output mappers must explicitly construct their DTO; identity mappers are forbidden because structural typing can otherwise leak persistence-only fields.
|
|
42
|
-
- Architecture enforcement has no suppression or baseline mechanism. Existing project debt must be fixed or explicitly tracked outside the checker; new violations always fail.
|
|
43
|
-
- `nps lint.convexArchitecture` is mandatory in the normal lint gate.
|
|
44
|
-
- `nps typecheck.convex` must typecheck the Convex backend independently.
|
|
45
|
-
- Oxc must lint frontend, backend, architecture rules, tests, and scripts.
|
|
46
|
-
|
|
47
|
-
- Base has exactly one MCP presentation: the Convex-hosted `/mcp` endpoint. Do not add or restore a controller-hosted Todo MCP server or tunnel. The external ChatGPT connector label may be `base_mcp`; treat that as a client-side name only, not a separate architecture path.
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
// oxlint-disable no-console no-await-in-loop
|
|
3
|
-
import {
|
|
4
|
-
backendExternalImportViolation,
|
|
5
|
-
boundaryTestQualityViolations,
|
|
6
|
-
backendImportViolation,
|
|
7
|
-
backendLayer,
|
|
8
|
-
forbiddenRuntimeViolations,
|
|
9
|
-
frontendBackendImportViolation,
|
|
10
|
-
identityOutputMapperViolations,
|
|
11
|
-
importSpecs,
|
|
12
|
-
isConvexFrameworkPlumbing,
|
|
13
|
-
isInternalBackendImplementation,
|
|
14
|
-
normalizePath,
|
|
15
|
-
publicApiLogicViolations,
|
|
16
|
-
publicFunctionContractViolations,
|
|
17
|
-
publicConvexFunctions,
|
|
18
|
-
schemaTechnologyViolations,
|
|
19
|
-
} from "./policy.ts";
|
|
20
|
-
|
|
21
|
-
const decoder = new TextDecoder();
|
|
22
|
-
const findings: string[] = [];
|
|
23
|
-
const forbiddenBaseMcpPaths = [
|
|
24
|
-
"scripts/backend/todo-mcp-server.ts",
|
|
25
|
-
"scripts/backend/todo-mcp-protocol.ts",
|
|
26
|
-
"scripts/backend/todo-mcp-client.ts",
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
async function exists(path: string): Promise<boolean> {
|
|
30
|
-
try {
|
|
31
|
-
await runtime.stat(path);
|
|
32
|
-
return true;
|
|
33
|
-
} catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function* walk(dir: string): AsyncGenerator<string> {
|
|
39
|
-
try {
|
|
40
|
-
for await (const entry of runtime.readDir(dir)) {
|
|
41
|
-
const path = `${dir}/${entry.name}`;
|
|
42
|
-
if (entry.isDirectory && entry.name !== "_generated") yield* walk(path);
|
|
43
|
-
if (entry.isFile && /\.(ts|tsx)$/u.test(entry.name)) yield normalizePath(path);
|
|
44
|
-
}
|
|
45
|
-
} catch {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function productionFile(file: string): boolean {
|
|
51
|
-
return /\.(ts|tsx)$/u.test(file) && !/\.(test|stories|mock)\.(ts|tsx)$/u.test(file);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function add(file: string, message: string): void {
|
|
55
|
-
findings.push(`${file}: ${message}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function requireSibling(file: string, suffix: string, reason: string): Promise<void> {
|
|
59
|
-
const sibling = file.replace(/\.tsx?$/u, suffix);
|
|
60
|
-
if (!(await exists(sibling))) add(file, `${reason}: missing ${sibling}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function verifyContractFile(path: string, technology: "convex" | "zod"): Promise<void> {
|
|
64
|
-
if (!(await exists(path))) return;
|
|
65
|
-
const source = decoder.decode(await runtime.readFile(path));
|
|
66
|
-
if (technology === "convex") {
|
|
67
|
-
if (!/from\s+["']convex\/values["']/u.test(source) || !/\bv\./u.test(source)) {
|
|
68
|
-
add(path, "Convex contract must define a v validator");
|
|
69
|
-
}
|
|
70
|
-
if (!/\bInfer\s*</u.test(source))
|
|
71
|
-
add(path, "Convex boundary type must derive with Infer<typeof validator>");
|
|
72
|
-
if (/from\s+["']zod["']/u.test(source))
|
|
73
|
-
add(path, "Convex contract must not duplicate itself in Zod");
|
|
74
|
-
} else {
|
|
75
|
-
if (!/from\s+["']zod["']/u.test(source) || !/\bz\./u.test(source))
|
|
76
|
-
add(path, "external provider contract must use Zod");
|
|
77
|
-
if (!/\bz\.infer\s*</u.test(source))
|
|
78
|
-
add(path, "external provider boundary type must derive with z.infer");
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async function verifyBackendBoundaryFiles(file: string): Promise<void> {
|
|
83
|
-
const layer = backendLayer(file);
|
|
84
|
-
if (!layer || !productionFile(file)) return;
|
|
85
|
-
if (isInternalBackendImplementation(file)) return;
|
|
86
|
-
if (/\.(input|output)(?:\.schema)?\.ts$/u.test(file)) return;
|
|
87
|
-
if (layer === "application" || layer === "dal") {
|
|
88
|
-
await requireSibling(file, ".input.ts", `${layer} operations require an input contract`);
|
|
89
|
-
await requireSibling(file, ".output.ts", `${layer} operations require an output contract`);
|
|
90
|
-
await requireSibling(file, ".test.ts", `${layer} operations require a focused unit test`);
|
|
91
|
-
await verifyContractFile(file.replace(/\.ts$/u, ".input.ts"), "convex");
|
|
92
|
-
await verifyContractFile(file.replace(/\.ts$/u, ".output.ts"), "convex");
|
|
93
|
-
}
|
|
94
|
-
if (layer === "domain")
|
|
95
|
-
await requireSibling(file, ".test.ts", "domain rules require pure unit tests");
|
|
96
|
-
if (layer === "integration") {
|
|
97
|
-
const source = decoder.decode(await runtime.readFile(file));
|
|
98
|
-
await requireSibling(file, ".input.schema.ts", "provider adapters require Zod input contracts");
|
|
99
|
-
await requireSibling(
|
|
100
|
-
file,
|
|
101
|
-
".output.schema.ts",
|
|
102
|
-
"provider adapters require Zod output contracts",
|
|
103
|
-
);
|
|
104
|
-
await requireSibling(file, ".test.ts", "provider adapters require focused contract tests");
|
|
105
|
-
await verifyContractFile(file.replace(/\.ts$/u, ".input.schema.ts"), "zod");
|
|
106
|
-
await verifyContractFile(file.replace(/\.ts$/u, ".output.schema.ts"), "zod");
|
|
107
|
-
if (!/from\s+["'][^"']+\.input\.schema["']/u.test(source))
|
|
108
|
-
add(file, "provider adapter must import its input Zod contract");
|
|
109
|
-
if (!/from\s+["'][^"']+\.output\.schema["']/u.test(source))
|
|
110
|
-
add(file, "provider adapter must import its output Zod contract");
|
|
111
|
-
if (!/\w+InputSchema\.(?:parse|safeParse)\s*\(/u.test(source))
|
|
112
|
-
add(file, "provider adapter must execute its input Zod contract");
|
|
113
|
-
if (!/\w+OutputSchema\.(?:parse|safeParse)\s*\(/u.test(source))
|
|
114
|
-
add(file, "provider adapter must execute its output Zod contract on external data");
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
for await (const file of walk("src")) {
|
|
119
|
-
if (!productionFile(file)) continue;
|
|
120
|
-
const source = decoder.decode(await runtime.readFile(file));
|
|
121
|
-
for (const spec of importSpecs(source)) {
|
|
122
|
-
const violation = frontendBackendImportViolation(file, spec);
|
|
123
|
-
if (violation) add(file, violation);
|
|
124
|
-
}
|
|
125
|
-
const importsConvexHooks =
|
|
126
|
-
/from\s+["']convex\/react["']/u.test(source) &&
|
|
127
|
-
/\buse(?:Query|Mutation|Action)\b/u.test(source);
|
|
128
|
-
const allowedHookOwner =
|
|
129
|
-
file.includes("/-components/data-hooks/") ||
|
|
130
|
-
file === "src/main.tsx" ||
|
|
131
|
-
file.startsWith("src/integrations/convex/");
|
|
132
|
-
if (importsConvexHooks && !allowedHookOwner)
|
|
133
|
-
add(file, "Convex React query/mutation/action hooks belong only in web data-hooks");
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
for await (const file of walk("convex")) {
|
|
137
|
-
if (!productionFile(file) || isConvexFrameworkPlumbing(file)) continue;
|
|
138
|
-
const source = decoder.decode(await runtime.readFile(file));
|
|
139
|
-
const layer = backendLayer(file);
|
|
140
|
-
if (layer) {
|
|
141
|
-
for (const spec of importSpecs(source)) {
|
|
142
|
-
const violation = backendImportViolation(file, spec);
|
|
143
|
-
if (violation) add(file, violation);
|
|
144
|
-
const externalViolation = backendExternalImportViolation(file, spec);
|
|
145
|
-
if (externalViolation) add(file, externalViolation);
|
|
146
|
-
}
|
|
147
|
-
for (const violation of forbiddenRuntimeViolations(file, source)) add(file, violation);
|
|
148
|
-
for (const violation of schemaTechnologyViolations(file, source)) add(file, violation);
|
|
149
|
-
if (layer === "application")
|
|
150
|
-
for (const violation of identityOutputMapperViolations(source)) add(file, violation);
|
|
151
|
-
await verifyBackendBoundaryFiles(file);
|
|
152
|
-
}
|
|
153
|
-
if (!layer)
|
|
154
|
-
add(
|
|
155
|
-
file,
|
|
156
|
-
"unclassified Convex backend module; move code into application/domain/dal/integrations or a public API module",
|
|
157
|
-
);
|
|
158
|
-
if (layer === "api") {
|
|
159
|
-
const functions = publicConvexFunctions(source);
|
|
160
|
-
for (const violation of publicFunctionContractViolations(source)) add(file, violation);
|
|
161
|
-
for (const violation of publicApiLogicViolations(source)) add(file, violation);
|
|
162
|
-
if (
|
|
163
|
-
functions.length > 0 &&
|
|
164
|
-
!importSpecs(source).some((spec) => spec.includes("/application/"))
|
|
165
|
-
) {
|
|
166
|
-
add(file, "public Convex API modules must delegate to convex/application use cases");
|
|
167
|
-
}
|
|
168
|
-
if (functions.length > 0) {
|
|
169
|
-
await requireSibling(
|
|
170
|
-
file,
|
|
171
|
-
".boundary.test.ts",
|
|
172
|
-
"public Convex API modules require boundary tests",
|
|
173
|
-
);
|
|
174
|
-
const boundaryFile = file.replace(/\.ts$/u, ".boundary.test.ts");
|
|
175
|
-
if (await exists(boundaryFile)) {
|
|
176
|
-
const boundarySource = decoder.decode(await runtime.readFile(boundaryFile));
|
|
177
|
-
for (const violation of boundaryTestQualityViolations(boundarySource))
|
|
178
|
-
add(boundaryFile, violation);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
for (const root of ["src", "convex"]) {
|
|
185
|
-
for await (const file of walk(root)) {
|
|
186
|
-
if (!productionFile(file)) continue;
|
|
187
|
-
const source = decoder.decode(await runtime.readFile(file));
|
|
188
|
-
if (/\b(?:zodToConvex|convexToZod|zodToV|vToZod)\b/u.test(source)) {
|
|
189
|
-
add(file, "schema converters are forbidden; validate then explicitly map values");
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
for (const path of forbiddenBaseMcpPaths) {
|
|
195
|
-
if (await exists(path))
|
|
196
|
-
add(path, "Base MCP must be hosted only at Convex /mcp; duplicate local MCP path is forbidden");
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const uniqueFindings = [...new Set(findings)].toSorted();
|
|
200
|
-
if (uniqueFindings.length) {
|
|
201
|
-
console.error(uniqueFindings.join("\n"));
|
|
202
|
-
runtime.exit(1);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
console.log("convex-multi-presentation ok");
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "convex-multi-presentation",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.5",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/convex-multi-presentation/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/convex-multi-presentation/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "managed-file",
|
|
21
|
-
"path": ".agents/skills/convex-multi-presentation/policy.ts",
|
|
22
|
-
"source": "policy.ts"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"kind": "shared-markdown-section",
|
|
26
|
-
"path": "AGENTS.md",
|
|
27
|
-
"heading": "## Specdest rule: convex-multi-presentation",
|
|
28
|
-
"body": "Use `.agents/skills/convex-multi-presentation/SKILL.md` when working in this rule area. Run `node .agents/skills/convex-multi-presentation/check.ts` before handoff."
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"obsolete": [
|
|
32
|
-
{
|
|
33
|
-
"kind": "file",
|
|
34
|
-
"path": ".agents/skills/convex-multi-presentation/boundary-test-baseline.json"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"kind": "file",
|
|
38
|
-
"path": ".agents/skills/convex-multi-presentation/legacy-baseline.json"
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"check": {
|
|
42
|
-
"command": [
|
|
43
|
-
"node",
|
|
44
|
-
".agents/skills/convex-multi-presentation/check.ts"
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -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");
|