@specdest/devkit 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/check.ts +13 -12
- package/catalog/rules/convex-multi-presentation/manifest.json +3 -5
- 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 +1 -1
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -200,7 +201,7 @@ const boundaryDebtCeiling = 44;
|
|
|
200
201
|
let boundaryDebt = new Set<string>();
|
|
201
202
|
let boundaryDebtHasDuplicates = false;
|
|
202
203
|
if (await exists(boundaryDebtPath)) {
|
|
203
|
-
const parsed = JSON.parse(decoder.decode(await
|
|
204
|
+
const parsed = JSON.parse(decoder.decode(await runtime.readFile(boundaryDebtPath))) as {
|
|
204
205
|
readonly findings?: readonly string[];
|
|
205
206
|
};
|
|
206
207
|
const debtFindings = parsed.findings ?? [];
|
|
@@ -209,12 +210,12 @@ if (await exists(boundaryDebtPath)) {
|
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
const baselinePath = ".agents/skills/convex-multi-presentation/legacy-baseline.json";
|
|
212
|
-
const strict =
|
|
213
|
+
const strict = runtime.args.includes("--strict");
|
|
213
214
|
const legacyBaselineCeiling = 87;
|
|
214
215
|
let baseline = new Set<string>();
|
|
215
216
|
let baselineHasDuplicates = false;
|
|
216
217
|
if (!strict && (await exists(baselinePath))) {
|
|
217
|
-
const parsed = JSON.parse(decoder.decode(await
|
|
218
|
+
const parsed = JSON.parse(decoder.decode(await runtime.readFile(baselinePath))) as {
|
|
218
219
|
readonly findings?: readonly string[];
|
|
219
220
|
};
|
|
220
221
|
const baselineFindings = parsed.findings ?? [];
|
|
@@ -262,7 +263,7 @@ if (
|
|
|
262
263
|
staleBoundaryDebt.length ||
|
|
263
264
|
newFindings.length
|
|
264
265
|
)
|
|
265
|
-
|
|
266
|
+
runtime.exit(1);
|
|
266
267
|
|
|
267
268
|
if (baseline.size)
|
|
268
269
|
console.log(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "convex-multi-presentation",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"requires": [
|
|
6
6
|
"checker-runtime"
|
|
7
7
|
],
|
|
@@ -30,15 +30,13 @@
|
|
|
30
30
|
"kind": "shared-markdown-section",
|
|
31
31
|
"path": "AGENTS.md",
|
|
32
32
|
"heading": "## Specdest rule: convex-multi-presentation",
|
|
33
|
-
"body": "Use `.agents/skills/convex-multi-presentation/SKILL.md` when working in this rule area. Run `
|
|
33
|
+
"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."
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
36
|
"obsolete": [],
|
|
37
37
|
"check": {
|
|
38
38
|
"command": [
|
|
39
|
-
"
|
|
40
|
-
"run",
|
|
41
|
-
"--allow-read",
|
|
39
|
+
"node",
|
|
42
40
|
".agents/skills/convex-multi-presentation/check.ts"
|
|
43
41
|
]
|
|
44
42
|
}
|
|
@@ -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
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop
|
|
2
3
|
const decoder = new TextDecoder();
|
|
3
4
|
const violations: string[] = [];
|
|
@@ -14,7 +15,7 @@ const sourceDirectories = ["src"];
|
|
|
14
15
|
|
|
15
16
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
16
17
|
try {
|
|
17
|
-
for await (const entry of
|
|
18
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
18
19
|
const path = `${dir}/${entry.name}`;
|
|
19
20
|
if (ignoredDirectories.some((ignored) => path.startsWith(ignored))) {
|
|
20
21
|
continue;
|
|
@@ -47,7 +48,7 @@ function lineNumber(text: string, index: number): number {
|
|
|
47
48
|
for (const dir of sourceDirectories) {
|
|
48
49
|
for await (const file of walk(dir)) {
|
|
49
50
|
if (isAllowedRawErrorFile(file)) continue;
|
|
50
|
-
const text = decoder.decode(await
|
|
51
|
+
const text = decoder.decode(await runtime.readFile(file));
|
|
51
52
|
const rawErrorPattern = /throw\s+new\s+Error\s*\(/gu;
|
|
52
53
|
for (const match of text.matchAll(rawErrorPattern)) {
|
|
53
54
|
violations.push(
|
|
@@ -67,6 +68,6 @@ for (const dir of sourceDirectories) {
|
|
|
67
68
|
|
|
68
69
|
if (violations.length) {
|
|
69
70
|
console.error(violations.join("\n"));
|
|
70
|
-
|
|
71
|
+
runtime.exit(1);
|
|
71
72
|
}
|
|
72
73
|
console.log("error-handling-rules ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "error-handling-rules",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
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 rule: error-handling-rules",
|
|
23
|
-
"body": "Use `.agents/skills/error-handling-rules/SKILL.md` when working in this rule area. Run `
|
|
23
|
+
"body": "Use `.agents/skills/error-handling-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/error-handling-rules/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/error-handling-rules/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop
|
|
2
3
|
const decoder = new TextDecoder();
|
|
3
4
|
const violations: string[] = [];
|
|
4
5
|
|
|
5
6
|
async function exists(path: string): Promise<boolean> {
|
|
6
7
|
try {
|
|
7
|
-
await
|
|
8
|
+
await runtime.stat(path);
|
|
8
9
|
return true;
|
|
9
10
|
} catch {
|
|
10
11
|
return false;
|
|
@@ -13,7 +14,7 @@ async function exists(path: string): Promise<boolean> {
|
|
|
13
14
|
|
|
14
15
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
15
16
|
try {
|
|
16
|
-
for await (const entry of
|
|
17
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
17
18
|
const path = `${dir}/${entry.name}`;
|
|
18
19
|
if (entry.isDirectory) yield* walk(path);
|
|
19
20
|
if (entry.isFile && /\.(ts|tsx)$/.test(entry.name)) yield path;
|
|
@@ -117,7 +118,7 @@ async function hasRouteLocalDataHooks(file: string): Promise<boolean> {
|
|
|
117
118
|
async function siblingPageControllerImportsDataHook(file: string): Promise<boolean> {
|
|
118
119
|
const controller = file.replace(/\.tsx$/, ".controller.ts");
|
|
119
120
|
if (!(await exists(controller))) return false;
|
|
120
|
-
const text = decoder.decode(await
|
|
121
|
+
const text = decoder.decode(await runtime.readFile(controller));
|
|
121
122
|
return importsDataHook(text);
|
|
122
123
|
}
|
|
123
124
|
|
|
@@ -155,7 +156,7 @@ for await (const file of walk("src/routes")) {
|
|
|
155
156
|
if (file.endsWith(".form.schema.ts")) requireOperationSpecificFormName(file);
|
|
156
157
|
if (!implementationFile(file)) continue;
|
|
157
158
|
|
|
158
|
-
const text = decoder.decode(await
|
|
159
|
+
const text = decoder.decode(await runtime.readFile(file));
|
|
159
160
|
const specs = importSpecs(text);
|
|
160
161
|
|
|
161
162
|
for (const spec of specs) {
|
|
@@ -260,6 +261,6 @@ for await (const file of walk("src/routes")) {
|
|
|
260
261
|
|
|
261
262
|
if (violations.length) {
|
|
262
263
|
console.error(violations.join("\n"));
|
|
263
|
-
|
|
264
|
+
runtime.exit(1);
|
|
264
265
|
}
|
|
265
266
|
console.log("layers-and-contracts ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "layers-and-contracts",
|
|
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 rule: layers-and-contracts",
|
|
23
|
-
"body": "Use `.agents/skills/layers-and-contracts/SKILL.md` when working in this rule area. Run `
|
|
23
|
+
"body": "Use `.agents/skills/layers-and-contracts/SKILL.md` when working in this rule area. Run `node .agents/skills/layers-and-contracts/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/layers-and-contracts/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|