@specdest/devkit 0.1.3 → 0.2.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 +28 -0
- package/catalog/modules/checker-runtime/config.ts +4 -3
- package/catalog/modules/checker-runtime/fs.ts +4 -3
- package/catalog/modules/checker-runtime/manifest.json +6 -1
- package/catalog/modules/checker-runtime/runtime.ts +79 -0
- package/catalog/rules/abac-permissions-convex/check.ts +4 -3
- package/catalog/rules/abac-permissions-convex/manifest.json +3 -5
- package/catalog/rules/abac-permissions-supabase/check.ts +4 -3
- package/catalog/rules/abac-permissions-supabase/manifest.json +3 -5
- package/catalog/rules/convex-multi-presentation/SKILL.md +1 -2
- package/catalog/rules/convex-multi-presentation/check.ts +14 -80
- package/catalog/rules/convex-multi-presentation/manifest.json +13 -11
- package/catalog/rules/design-rules/check.ts +5 -4
- package/catalog/rules/design-rules/manifest.json +3 -5
- package/catalog/rules/e2e-test-rules/SKILL.md +1 -1
- package/catalog/rules/e2e-test-rules/check.ts +5 -4
- package/catalog/rules/e2e-test-rules/manifest.json +3 -5
- package/catalog/rules/error-handling-rules/check.ts +4 -3
- package/catalog/rules/error-handling-rules/manifest.json +3 -5
- package/catalog/rules/layers-and-contracts/check.ts +6 -5
- package/catalog/rules/layers-and-contracts/manifest.json +3 -5
- package/catalog/rules/layers-and-contracts-convex/check.ts +7 -6
- package/catalog/rules/layers-and-contracts-convex/manifest.json +3 -5
- package/catalog/rules/layers-and-contracts-supabase/check.ts +8 -7
- package/catalog/rules/layers-and-contracts-supabase/manifest.json +3 -5
- package/catalog/rules/module-size-rules/check.ts +9 -8
- package/catalog/rules/module-size-rules/manifest.json +3 -5
- package/catalog/rules/module-size-rules-convex/check.ts +9 -8
- package/catalog/rules/module-size-rules-convex/manifest.json +3 -5
- package/catalog/rules/module-size-rules-supabase/check.ts +9 -8
- package/catalog/rules/module-size-rules-supabase/manifest.json +3 -5
- package/catalog/rules/mutation-command-rules/check.ts +3 -2
- package/catalog/rules/mutation-command-rules/manifest.json +3 -5
- package/catalog/rules/nearby-contracts/SKILL.md +1 -1
- package/catalog/rules/nearby-contracts/check.ts +4 -3
- package/catalog/rules/nearby-contracts/manifest.json +3 -5
- package/catalog/rules/no-raw-click-buttons/check.ts +3 -2
- package/catalog/rules/no-raw-click-buttons/manifest.json +3 -5
- package/catalog/rules/public-api-export-barrels/SKILL.md +1 -1
- package/catalog/rules/public-api-export-barrels/check.ts +3 -2
- package/catalog/rules/public-api-export-barrels/manifest.json +3 -5
- package/catalog/rules/route-tree-fresh/check.ts +9 -7
- package/catalog/rules/route-tree-fresh/manifest.json +3 -5
- package/catalog/rules/strict-typescript/check.ts +16 -8
- package/catalog/rules/strict-typescript/manifest.json +3 -5
- package/catalog/rules/supabase-contracts/check.ts +10 -9
- package/catalog/rules/supabase-contracts/manifest.json +3 -5
- package/catalog/rules/supabase-declarative-schema/SKILL.md +1 -1
- package/catalog/rules/supabase-declarative-schema/check.ts +5 -4
- package/catalog/rules/supabase-declarative-schema/manifest.json +3 -5
- package/catalog/rules/tanstack-form-rules/SKILL.md +1 -1
- package/catalog/rules/tanstack-form-rules/check.ts +3 -2
- package/catalog/rules/tanstack-form-rules/manifest.json +3 -5
- package/catalog/rules/unit-test-rules/SKILL.md +1 -1
- package/catalog/rules/unit-test-rules/check.ts +6 -5
- package/catalog/rules/unit-test-rules/manifest.json +3 -5
- package/catalog/rules/unit-test-rules-convex/check.ts +8 -7
- package/catalog/rules/unit-test-rules-convex/manifest.json +3 -5
- package/catalog/rules/unit-test-rules-supabase/check.ts +7 -6
- package/catalog/rules/unit-test-rules-supabase/manifest.json +3 -5
- package/catalog/rules/workstation-controller-rules/check.ts +5 -4
- package/catalog/rules/workstation-controller-rules/manifest.json +3 -5
- package/package.json +20 -2
- package/src/project-operations.js +17 -14
- package/src/sync-core.js +78 -8
- package/catalog/rules/convex-multi-presentation/boundary-test-baseline.json +0 -3
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Specdest Devkit
|
|
2
|
+
|
|
3
|
+
Canonical engineering standards, reusable modules, installers, migrations, checkers, and CLI for Specdest projects.
|
|
4
|
+
|
|
5
|
+
## CLI
|
|
6
|
+
|
|
7
|
+
The publishable package is `@specdest/devkit` and exposes the `specdest` binary.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
specdest install <rule-or-module>
|
|
11
|
+
specdest status
|
|
12
|
+
specdest sync
|
|
13
|
+
specdest check
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The core command surface is implemented. Deferred convenience commands such as `fix` and module add/remove/list are intentionally excluded until real usage justifies them.
|
|
17
|
+
|
|
18
|
+
## Workspace
|
|
19
|
+
|
|
20
|
+
- repository root: publishable `@specdest/devkit` package and CLI
|
|
21
|
+
- `docs`: canonical architecture/implementation documentation
|
|
22
|
+
- `scripts`: repository validation helpers
|
|
23
|
+
|
|
24
|
+
Operational install, controller/GitHub authentication, npm Trusted Publishing, Base publication configuration, release verification, and recovery procedures are documented in [`docs/operations.md`](docs/operations.md).
|
|
25
|
+
|
|
26
|
+
Releases publish one tested immutable bundle: the npm tarball, catalog snapshot, release metadata, and checksums. npm publication and Base catalog propagation are separate: a Base outage cannot turn an already-published npm version into a failed release, and propagation can be retried independently.
|
|
27
|
+
|
|
28
|
+
Devkit is Node 24+ only. Rule checkers are strict TypeScript executed directly by Node; Deno and auxiliary TypeScript runtimes are intentionally not required.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "./runtime.ts";
|
|
1
2
|
// fallow-ignore-next-line complexity
|
|
2
3
|
function configPathFromArgs(args: string[], defaultUrl: URL): string | URL {
|
|
3
4
|
const configArgIndex = args.indexOf("--config");
|
|
@@ -9,13 +10,13 @@ function configPathFromArgs(args: string[], defaultUrl: URL): string | URL {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
async function readConfig<T>(args: string[], defaultUrl: URL): Promise<T> {
|
|
12
|
-
return JSON.parse(await
|
|
13
|
+
return JSON.parse(await runtime.readTextFile(configPathFromArgs(args, defaultUrl))) as T;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export async function readSkillConfig<T>(moduleUrl: string): Promise<{ config: T; root: string }> {
|
|
16
17
|
return {
|
|
17
|
-
config: await readConfig<T>(
|
|
18
|
-
root:
|
|
18
|
+
config: await readConfig<T>(runtime.args, new URL("./config.json", moduleUrl)),
|
|
19
|
+
root: runtime.cwd(),
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "./runtime.ts";
|
|
1
2
|
export function normalizePath(value: string): string {
|
|
2
3
|
return value.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
3
4
|
}
|
|
@@ -10,10 +11,10 @@ function isIgnoredDirectory(relativePath: string, ignoredDirectories: Set<string
|
|
|
10
11
|
|
|
11
12
|
export async function exists(path: string): Promise<boolean> {
|
|
12
13
|
try {
|
|
13
|
-
await
|
|
14
|
+
await runtime.stat(path);
|
|
14
15
|
return true;
|
|
15
16
|
} catch (error) {
|
|
16
|
-
if (error instanceof
|
|
17
|
+
if (error instanceof runtime.errors.NotFound) return false;
|
|
17
18
|
throw error;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -27,7 +28,7 @@ export async function walk(
|
|
|
27
28
|
if (isIgnoredDirectory(relativeDirectory, ignoredDirectories) || !(await exists(directory)))
|
|
28
29
|
return [];
|
|
29
30
|
const entries: string[] = [];
|
|
30
|
-
for await (const entry of
|
|
31
|
+
for await (const entry of runtime.readDir(directory)) {
|
|
31
32
|
const relativePath = normalizePath(
|
|
32
33
|
relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name,
|
|
33
34
|
);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "checker-runtime",
|
|
3
3
|
"kind": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"artifacts": [
|
|
6
|
+
{
|
|
7
|
+
"kind": "managed-file",
|
|
8
|
+
"path": ".agents/skills/shared/runtime.ts",
|
|
9
|
+
"source": "runtime.ts"
|
|
10
|
+
},
|
|
6
11
|
{
|
|
7
12
|
"kind": "managed-file",
|
|
8
13
|
"path": ".agents/skills/shared/fs.ts",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { readFile as readFileNode, readdir, stat as statNode } from "node:fs/promises";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
|
|
4
|
+
export class NotFoundError extends Error {
|
|
5
|
+
constructor(path: string) {
|
|
6
|
+
super(`No such file or directory: ${path}`);
|
|
7
|
+
this.name = "NotFoundError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function translateNotFound(error: unknown, path: string): never {
|
|
12
|
+
if (
|
|
13
|
+
error instanceof Error &&
|
|
14
|
+
"code" in error &&
|
|
15
|
+
(error as NodeJS.ErrnoException).code === "ENOENT"
|
|
16
|
+
) {
|
|
17
|
+
throw new NotFoundError(path);
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function stat(path: string) {
|
|
23
|
+
try {
|
|
24
|
+
return await statNode(path);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return translateNotFound(error, path);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function readFile(path: string | URL): Promise<Uint8Array> {
|
|
31
|
+
try {
|
|
32
|
+
return await readFileNode(path);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return translateNotFound(error, String(path));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function readTextFile(path: string | URL): Promise<string> {
|
|
39
|
+
try {
|
|
40
|
+
return await readFileNode(path, "utf8");
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return translateNotFound(error, String(path));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function* readDir(path: string) {
|
|
47
|
+
let entries;
|
|
48
|
+
try {
|
|
49
|
+
entries = await readdir(path, { withFileTypes: true });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return translateNotFound(error, path);
|
|
52
|
+
}
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
yield {
|
|
55
|
+
name: entry.name,
|
|
56
|
+
isFile: entry.isFile(),
|
|
57
|
+
isDirectory: entry.isDirectory(),
|
|
58
|
+
isSymlink: entry.isSymbolicLink(),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function writeSync(stream: NodeJS.WriteStream, data: Uint8Array): number {
|
|
64
|
+
stream.write(data);
|
|
65
|
+
return data.byteLength;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const runtime = {
|
|
69
|
+
args: process.argv.slice(2),
|
|
70
|
+
cwd: () => process.cwd(),
|
|
71
|
+
exit: (code = 0): never => process.exit(code),
|
|
72
|
+
stat,
|
|
73
|
+
readFile,
|
|
74
|
+
readTextFile,
|
|
75
|
+
readDir,
|
|
76
|
+
stdout: { writeSync: (data: Uint8Array) => writeSync(process.stdout, data) },
|
|
77
|
+
stderr: { writeSync: (data: Uint8Array) => writeSync(process.stderr, data) },
|
|
78
|
+
errors: { NotFound: NotFoundError },
|
|
79
|
+
} as const;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop no-useless-concat no-useless-escape
|
|
2
3
|
const violations: string[] = [];
|
|
3
4
|
const authorityColumn = "ro" + "le";
|
|
@@ -7,7 +8,7 @@ const targetMetadataKey = "target_app_" + "metadata";
|
|
|
7
8
|
|
|
8
9
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
9
10
|
try {
|
|
10
|
-
for await (const entry of
|
|
11
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
11
12
|
const path = `${dir}/${entry.name}`;
|
|
12
13
|
if (entry.isDirectory) yield* walk(path);
|
|
13
14
|
if (entry.isFile && /\.(ts|tsx|sql|mjs|js)$/.test(entry.name)) yield path;
|
|
@@ -50,7 +51,7 @@ function readsRoleMetadata(text: string): boolean {
|
|
|
50
51
|
|
|
51
52
|
for await (const file of walk(".")) {
|
|
52
53
|
if (isIgnored(file)) continue;
|
|
53
|
-
const text = await
|
|
54
|
+
const text = await runtime.readTextFile(file);
|
|
54
55
|
const lower = text.toLowerCase();
|
|
55
56
|
|
|
56
57
|
const profileTableStatement = statements(text).find((statement) =>
|
|
@@ -81,6 +82,6 @@ for await (const file of walk(".")) {
|
|
|
81
82
|
|
|
82
83
|
if (violations.length) {
|
|
83
84
|
console.error(violations.join("\n"));
|
|
84
|
-
|
|
85
|
+
runtime.exit(1);
|
|
85
86
|
}
|
|
86
87
|
console.log("abac-permissions ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "abac-permissions-convex",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"requires": [
|
|
6
6
|
"checker-runtime"
|
|
7
7
|
],
|
|
@@ -20,15 +20,13 @@
|
|
|
20
20
|
"kind": "shared-markdown-section",
|
|
21
21
|
"path": "AGENTS.md",
|
|
22
22
|
"heading": "## Specdest backend rule: abac-permissions",
|
|
23
|
-
"body": "Use `.agents/skills/abac-permissions/SKILL.md` for this backend-specific rule. Run `
|
|
23
|
+
"body": "Use `.agents/skills/abac-permissions/SKILL.md` for this backend-specific rule. Run `node .agents/skills/abac-permissions/check.ts` before handoff."
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
26
|
"obsolete": [],
|
|
27
27
|
"check": {
|
|
28
28
|
"command": [
|
|
29
|
-
"
|
|
30
|
-
"run",
|
|
31
|
-
"--allow-read",
|
|
29
|
+
"node",
|
|
32
30
|
".agents/skills/abac-permissions/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop no-useless-concat no-useless-escape
|
|
2
3
|
const violations: string[] = [];
|
|
3
4
|
const authorityColumn = "ro" + "le";
|
|
@@ -7,7 +8,7 @@ const targetMetadataKey = "target_app_" + "metadata";
|
|
|
7
8
|
|
|
8
9
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
9
10
|
try {
|
|
10
|
-
for await (const entry of
|
|
11
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
11
12
|
const path = `${dir}/${entry.name}`;
|
|
12
13
|
if (entry.isDirectory) yield* walk(path);
|
|
13
14
|
if (entry.isFile && /\.(ts|tsx|sql|mjs|js)$/.test(entry.name)) yield path;
|
|
@@ -50,7 +51,7 @@ function readsRoleMetadata(text: string): boolean {
|
|
|
50
51
|
|
|
51
52
|
for await (const file of walk(".")) {
|
|
52
53
|
if (isIgnored(file)) continue;
|
|
53
|
-
const text = await
|
|
54
|
+
const text = await runtime.readTextFile(file);
|
|
54
55
|
const lower = text.toLowerCase();
|
|
55
56
|
|
|
56
57
|
const profileTableStatement = statements(text).find((statement) =>
|
|
@@ -81,6 +82,6 @@ for await (const file of walk(".")) {
|
|
|
81
82
|
|
|
82
83
|
if (violations.length) {
|
|
83
84
|
console.error(violations.join("\n"));
|
|
84
|
-
|
|
85
|
+
runtime.exit(1);
|
|
85
86
|
}
|
|
86
87
|
console.log("abac-permissions ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "abac-permissions-supabase",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"requires": [
|
|
6
6
|
"checker-runtime"
|
|
7
7
|
],
|
|
@@ -20,15 +20,13 @@
|
|
|
20
20
|
"kind": "shared-markdown-section",
|
|
21
21
|
"path": "AGENTS.md",
|
|
22
22
|
"heading": "## Specdest backend rule: abac-permissions",
|
|
23
|
-
"body": "Use `.agents/skills/abac-permissions/SKILL.md` for this backend-specific rule. Run `
|
|
23
|
+
"body": "Use `.agents/skills/abac-permissions/SKILL.md` for this backend-specific rule. Run `node .agents/skills/abac-permissions/check.ts` before handoff."
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
26
|
"obsolete": [],
|
|
27
27
|
"check": {
|
|
28
28
|
"command": [
|
|
29
|
-
"
|
|
30
|
-
"run",
|
|
31
|
-
"--allow-read",
|
|
29
|
+
"node",
|
|
32
30
|
".agents/skills/abac-permissions/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|
|
@@ -39,8 +39,7 @@ Rules:
|
|
|
39
39
|
- DAL and provider adapters need focused boundary/contract tests.
|
|
40
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
41
|
- Public-output mappers must explicitly construct their DTO; identity mappers are forbidden because structural typing can otherwise leak persistence-only fields.
|
|
42
|
-
-
|
|
43
|
-
- Architecture enforcement has no inline suppression mechanism. Existing migration debt, when unavoidable, is tracked only in the explicit architecture baseline and new debt is rejected.
|
|
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.
|
|
44
43
|
- `nps lint.convexArchitecture` is mandatory in the normal lint gate.
|
|
45
44
|
- `nps typecheck.convex` must typecheck the Convex backend independently.
|
|
46
45
|
- Oxc must lint frontend, backend, architecture rules, tests, and scripts.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop
|
|
2
3
|
import {
|
|
3
4
|
backendExternalImportViolation,
|
|
@@ -27,7 +28,7 @@ const forbiddenBaseMcpPaths = [
|
|
|
27
28
|
|
|
28
29
|
async function exists(path: string): Promise<boolean> {
|
|
29
30
|
try {
|
|
30
|
-
await
|
|
31
|
+
await runtime.stat(path);
|
|
31
32
|
return true;
|
|
32
33
|
} catch {
|
|
33
34
|
return false;
|
|
@@ -36,7 +37,7 @@ async function exists(path: string): Promise<boolean> {
|
|
|
36
37
|
|
|
37
38
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
38
39
|
try {
|
|
39
|
-
for await (const entry of
|
|
40
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
40
41
|
const path = `${dir}/${entry.name}`;
|
|
41
42
|
if (entry.isDirectory && entry.name !== "_generated") yield* walk(path);
|
|
42
43
|
if (entry.isFile && /\.(ts|tsx)$/u.test(entry.name)) yield normalizePath(path);
|
|
@@ -61,7 +62,7 @@ async function requireSibling(file: string, suffix: string, reason: string): Pro
|
|
|
61
62
|
|
|
62
63
|
async function verifyContractFile(path: string, technology: "convex" | "zod"): Promise<void> {
|
|
63
64
|
if (!(await exists(path))) return;
|
|
64
|
-
const source = decoder.decode(await
|
|
65
|
+
const source = decoder.decode(await runtime.readFile(path));
|
|
65
66
|
if (technology === "convex") {
|
|
66
67
|
if (!/from\s+["']convex\/values["']/u.test(source) || !/\bv\./u.test(source)) {
|
|
67
68
|
add(path, "Convex contract must define a v validator");
|
|
@@ -93,7 +94,7 @@ async function verifyBackendBoundaryFiles(file: string): Promise<void> {
|
|
|
93
94
|
if (layer === "domain")
|
|
94
95
|
await requireSibling(file, ".test.ts", "domain rules require pure unit tests");
|
|
95
96
|
if (layer === "integration") {
|
|
96
|
-
const source = decoder.decode(await
|
|
97
|
+
const source = decoder.decode(await runtime.readFile(file));
|
|
97
98
|
await requireSibling(file, ".input.schema.ts", "provider adapters require Zod input contracts");
|
|
98
99
|
await requireSibling(
|
|
99
100
|
file,
|
|
@@ -116,7 +117,7 @@ async function verifyBackendBoundaryFiles(file: string): Promise<void> {
|
|
|
116
117
|
|
|
117
118
|
for await (const file of walk("src")) {
|
|
118
119
|
if (!productionFile(file)) continue;
|
|
119
|
-
const source = decoder.decode(await
|
|
120
|
+
const source = decoder.decode(await runtime.readFile(file));
|
|
120
121
|
for (const spec of importSpecs(source)) {
|
|
121
122
|
const violation = frontendBackendImportViolation(file, spec);
|
|
122
123
|
if (violation) add(file, violation);
|
|
@@ -134,7 +135,7 @@ for await (const file of walk("src")) {
|
|
|
134
135
|
|
|
135
136
|
for await (const file of walk("convex")) {
|
|
136
137
|
if (!productionFile(file) || isConvexFrameworkPlumbing(file)) continue;
|
|
137
|
-
const source = decoder.decode(await
|
|
138
|
+
const source = decoder.decode(await runtime.readFile(file));
|
|
138
139
|
const layer = backendLayer(file);
|
|
139
140
|
if (layer) {
|
|
140
141
|
for (const spec of importSpecs(source)) {
|
|
@@ -172,7 +173,7 @@ for await (const file of walk("convex")) {
|
|
|
172
173
|
);
|
|
173
174
|
const boundaryFile = file.replace(/\.ts$/u, ".boundary.test.ts");
|
|
174
175
|
if (await exists(boundaryFile)) {
|
|
175
|
-
const boundarySource = decoder.decode(await
|
|
176
|
+
const boundarySource = decoder.decode(await runtime.readFile(boundaryFile));
|
|
176
177
|
for (const violation of boundaryTestQualityViolations(boundarySource))
|
|
177
178
|
add(boundaryFile, violation);
|
|
178
179
|
}
|
|
@@ -183,7 +184,7 @@ for await (const file of walk("convex")) {
|
|
|
183
184
|
for (const root of ["src", "convex"]) {
|
|
184
185
|
for await (const file of walk(root)) {
|
|
185
186
|
if (!productionFile(file)) continue;
|
|
186
|
-
const source = decoder.decode(await
|
|
187
|
+
const source = decoder.decode(await runtime.readFile(file));
|
|
187
188
|
if (/\b(?:zodToConvex|convexToZod|zodToV|vToZod)\b/u.test(source)) {
|
|
188
189
|
add(file, "schema converters are forbidden; validate then explicitly map values");
|
|
189
190
|
}
|
|
@@ -195,77 +196,10 @@ for (const path of forbiddenBaseMcpPaths) {
|
|
|
195
196
|
add(path, "Base MCP must be hosted only at Convex /mcp; duplicate local MCP path is forbidden");
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
const boundaryDebtPath = ".agents/skills/convex-multi-presentation/boundary-test-baseline.json";
|
|
199
|
-
const boundaryDebtCeiling = 44;
|
|
200
|
-
let boundaryDebt = new Set<string>();
|
|
201
|
-
let boundaryDebtHasDuplicates = false;
|
|
202
|
-
if (await exists(boundaryDebtPath)) {
|
|
203
|
-
const parsed = JSON.parse(decoder.decode(await Deno.readFile(boundaryDebtPath))) as {
|
|
204
|
-
readonly findings?: readonly string[];
|
|
205
|
-
};
|
|
206
|
-
const debtFindings = parsed.findings ?? [];
|
|
207
|
-
boundaryDebt = new Set(debtFindings);
|
|
208
|
-
boundaryDebtHasDuplicates = boundaryDebt.size !== debtFindings.length;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const baselinePath = ".agents/skills/convex-multi-presentation/legacy-baseline.json";
|
|
212
|
-
const strict = Deno.args.includes("--strict");
|
|
213
|
-
const legacyBaselineCeiling = 87;
|
|
214
|
-
let baseline = new Set<string>();
|
|
215
|
-
let baselineHasDuplicates = false;
|
|
216
|
-
if (!strict && (await exists(baselinePath))) {
|
|
217
|
-
const parsed = JSON.parse(decoder.decode(await Deno.readFile(baselinePath))) as {
|
|
218
|
-
readonly findings?: readonly string[];
|
|
219
|
-
};
|
|
220
|
-
const baselineFindings = parsed.findings ?? [];
|
|
221
|
-
baseline = new Set(baselineFindings);
|
|
222
|
-
baselineHasDuplicates = baseline.size !== baselineFindings.length;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
199
|
const uniqueFindings = [...new Set(findings)].toSorted();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
? []
|
|
231
|
-
: [...baseline].filter((finding) => !uniqueFindings.includes(finding)).toSorted();
|
|
232
|
-
const staleBoundaryDebt = strict
|
|
233
|
-
? []
|
|
234
|
-
: [...boundaryDebt].filter((finding) => !uniqueFindings.includes(finding)).toSorted();
|
|
235
|
-
const baselineGrew = !strict && baseline.size > legacyBaselineCeiling;
|
|
236
|
-
const boundaryDebtGrew = !strict && boundaryDebt.size > boundaryDebtCeiling;
|
|
237
|
-
|
|
238
|
-
if (baselineGrew)
|
|
239
|
-
console.error(
|
|
240
|
-
`legacy convex architecture baseline may not grow beyond ${legacyBaselineCeiling}; found ${baseline.size}`,
|
|
241
|
-
);
|
|
242
|
-
if (baselineHasDuplicates)
|
|
243
|
-
console.error("legacy convex architecture baseline contains duplicate findings");
|
|
244
|
-
if (boundaryDebtGrew)
|
|
245
|
-
console.error(
|
|
246
|
-
`boundary-test baseline may not grow beyond ${boundaryDebtCeiling}; found ${boundaryDebt.size}`,
|
|
247
|
-
);
|
|
248
|
-
if (boundaryDebtHasDuplicates) console.error("boundary-test baseline contains duplicate findings");
|
|
249
|
-
if (staleBaseline.length)
|
|
250
|
-
console.error(
|
|
251
|
-
"stale convex architecture baseline entries must be removed:\n" + staleBaseline.join("\n"),
|
|
252
|
-
);
|
|
253
|
-
if (staleBoundaryDebt.length)
|
|
254
|
-
console.error(
|
|
255
|
-
"stale boundary-test baseline entries must be removed:\n" + staleBoundaryDebt.join("\n"),
|
|
256
|
-
);
|
|
257
|
-
if (newFindings.length) console.error(newFindings.join("\n"));
|
|
258
|
-
if (
|
|
259
|
-
baselineGrew ||
|
|
260
|
-
baselineHasDuplicates ||
|
|
261
|
-
staleBaseline.length ||
|
|
262
|
-
staleBoundaryDebt.length ||
|
|
263
|
-
newFindings.length
|
|
264
|
-
)
|
|
265
|
-
Deno.exit(1);
|
|
200
|
+
if (uniqueFindings.length) {
|
|
201
|
+
console.error(uniqueFindings.join("\n"));
|
|
202
|
+
runtime.exit(1);
|
|
203
|
+
}
|
|
266
204
|
|
|
267
|
-
|
|
268
|
-
console.log(
|
|
269
|
-
`convex-multi-presentation ok (${baseline.size} tracked legacy findings; --strict reports all)`,
|
|
270
|
-
);
|
|
271
|
-
else console.log("convex-multi-presentation ok");
|
|
205
|
+
console.log("convex-multi-presentation ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "convex-multi-presentation",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"requires": [
|
|
6
6
|
"checker-runtime"
|
|
7
7
|
],
|
|
@@ -11,11 +11,6 @@
|
|
|
11
11
|
"path": ".agents/skills/convex-multi-presentation/SKILL.md",
|
|
12
12
|
"source": "SKILL.md"
|
|
13
13
|
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "scaffold",
|
|
16
|
-
"path": ".agents/skills/convex-multi-presentation/boundary-test-baseline.json",
|
|
17
|
-
"source": "boundary-test-baseline.json"
|
|
18
|
-
},
|
|
19
14
|
{
|
|
20
15
|
"kind": "managed-file",
|
|
21
16
|
"path": ".agents/skills/convex-multi-presentation/check.ts",
|
|
@@ -30,15 +25,22 @@
|
|
|
30
25
|
"kind": "shared-markdown-section",
|
|
31
26
|
"path": "AGENTS.md",
|
|
32
27
|
"heading": "## Specdest rule: convex-multi-presentation",
|
|
33
|
-
"body": "Use `.agents/skills/convex-multi-presentation/SKILL.md` when working in this rule area. Run `
|
|
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"
|
|
34
39
|
}
|
|
35
40
|
],
|
|
36
|
-
"obsolete": [],
|
|
37
41
|
"check": {
|
|
38
42
|
"command": [
|
|
39
|
-
"
|
|
40
|
-
"run",
|
|
41
|
-
"--allow-read",
|
|
43
|
+
"node",
|
|
42
44
|
".agents/skills/convex-multi-presentation/check.ts"
|
|
43
45
|
]
|
|
44
46
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop
|
|
2
3
|
const violations: string[] = [];
|
|
3
4
|
|
|
@@ -21,7 +22,7 @@ const defaultConfig: DesignRulesConfig = {
|
|
|
21
22
|
|
|
22
23
|
async function exists(path: string): Promise<boolean> {
|
|
23
24
|
try {
|
|
24
|
-
await
|
|
25
|
+
await runtime.stat(path);
|
|
25
26
|
return true;
|
|
26
27
|
} catch {
|
|
27
28
|
return false;
|
|
@@ -31,7 +32,7 @@ async function exists(path: string): Promise<boolean> {
|
|
|
31
32
|
async function readConfig(): Promise<DesignRulesConfig> {
|
|
32
33
|
const configPath = new URL("./config.json", import.meta.url).pathname;
|
|
33
34
|
try {
|
|
34
|
-
const parsed = JSON.parse(await
|
|
35
|
+
const parsed = JSON.parse(await runtime.readTextFile(configPath)) as DesignRulesConfig;
|
|
35
36
|
return {
|
|
36
37
|
schemaVersion: parsed.schemaVersion,
|
|
37
38
|
requiredFiles: parsed.requiredFiles ?? defaultConfig.requiredFiles,
|
|
@@ -69,7 +70,7 @@ for (const contract of config.requiredStoryContracts ?? []) {
|
|
|
69
70
|
continue;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
const storyText = await
|
|
73
|
+
const storyText = await runtime.readTextFile(contract.story);
|
|
73
74
|
if (!hasPlayTest(storyText)) {
|
|
74
75
|
violations.push(`${contract.story}: missing Storybook play test (${contract.reason})`);
|
|
75
76
|
}
|
|
@@ -77,7 +78,7 @@ for (const contract of config.requiredStoryContracts ?? []) {
|
|
|
77
78
|
|
|
78
79
|
if (violations.length) {
|
|
79
80
|
console.error(violations.join("\n"));
|
|
80
|
-
|
|
81
|
+
runtime.exit(1);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
console.log("design-rules ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "design-rules",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"requires": [
|
|
6
6
|
"checker-runtime"
|
|
7
7
|
],
|
|
@@ -25,15 +25,13 @@
|
|
|
25
25
|
"kind": "shared-markdown-section",
|
|
26
26
|
"path": "AGENTS.md",
|
|
27
27
|
"heading": "## Specdest rule: design-rules",
|
|
28
|
-
"body": "Use `.agents/skills/design-rules/SKILL.md` when working in this rule area. Run `
|
|
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
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"obsolete": [],
|
|
32
32
|
"check": {
|
|
33
33
|
"command": [
|
|
34
|
-
"
|
|
35
|
-
"run",
|
|
36
|
-
"--allow-read",
|
|
34
|
+
"node",
|
|
37
35
|
".agents/skills/design-rules/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop
|
|
2
3
|
import { assertSchemaVersion, readSkillConfig } from "../shared/config.ts";
|
|
3
4
|
import { exists, walk } from "../shared/fs.ts";
|
|
@@ -57,7 +58,7 @@ for (const e2eRoot of e2eRoots) {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
for (const file of e2eFiles.toSorted()) {
|
|
60
|
-
const text = await
|
|
61
|
+
const text = await runtime.readTextFile(`${root}/${file}`);
|
|
61
62
|
for (const pattern of forbiddenPatterns) {
|
|
62
63
|
if (text.includes(pattern)) {
|
|
63
64
|
violations.push(`${file}: E2E test contains forbidden pattern ${JSON.stringify(pattern)}`);
|
|
@@ -79,7 +80,7 @@ for (const relativePath of playwrightConfigs) {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
for (const relativePath of presentConfigs) {
|
|
82
|
-
const text = await
|
|
83
|
+
const text = await runtime.readTextFile(`${root}/${relativePath}`);
|
|
83
84
|
for (const marker of requiredConfigMarkers) {
|
|
84
85
|
if (!text.includes(marker)) {
|
|
85
86
|
violations.push(
|
|
@@ -120,7 +121,7 @@ if (qualityGateFile) {
|
|
|
120
121
|
if (!(await exists(`${root}/${qualityGateFile}`))) {
|
|
121
122
|
violations.push(`${qualityGateFile}: configured quality gate file is missing`);
|
|
122
123
|
} else {
|
|
123
|
-
const qualityGateText = await
|
|
124
|
+
const qualityGateText = await runtime.readTextFile(`${root}/${qualityGateFile}`);
|
|
124
125
|
for (const marker of qualityGateMarkers) {
|
|
125
126
|
if (!qualityGateText.includes(marker)) {
|
|
126
127
|
violations.push(
|
|
@@ -141,4 +142,4 @@ if (e2eFiles.length > 0 || presentConfigs.length > 0) {
|
|
|
141
142
|
|
|
142
143
|
console.log(`# e2e test rule violations: ${violations.length}`);
|
|
143
144
|
for (const violation of violations) console.log(`- ${violation}`);
|
|
144
|
-
if (violations.length > 0)
|
|
145
|
+
if (violations.length > 0) runtime.exit(1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "e2e-test-rules",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"requires": [
|
|
6
6
|
"checker-runtime"
|
|
7
7
|
],
|
|
@@ -25,15 +25,13 @@
|
|
|
25
25
|
"kind": "shared-markdown-section",
|
|
26
26
|
"path": "AGENTS.md",
|
|
27
27
|
"heading": "## Specdest rule: e2e-test-rules",
|
|
28
|
-
"body": "Use `.agents/skills/e2e-test-rules/SKILL.md` when working in this rule area. Run `
|
|
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
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"obsolete": [],
|
|
32
32
|
"check": {
|
|
33
33
|
"command": [
|
|
34
|
-
"
|
|
35
|
-
"run",
|
|
36
|
-
"--allow-read",
|
|
34
|
+
"node",
|
|
37
35
|
".agents/skills/e2e-test-rules/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|