@specdest/devkit 0.1.3 → 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 "../shared/runtime.ts";
|
|
1
2
|
import { runtimeBoundarySchemaUsageViolations } from "./policy.ts";
|
|
2
3
|
|
|
3
4
|
// oxlint-disable no-console no-await-in-loop
|
|
@@ -6,7 +7,7 @@ const violations: string[] = [];
|
|
|
6
7
|
|
|
7
8
|
async function exists(path: string): Promise<boolean> {
|
|
8
9
|
try {
|
|
9
|
-
await
|
|
10
|
+
await runtime.stat(path);
|
|
10
11
|
return true;
|
|
11
12
|
} catch {
|
|
12
13
|
return false;
|
|
@@ -15,7 +16,7 @@ async function exists(path: string): Promise<boolean> {
|
|
|
15
16
|
|
|
16
17
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
17
18
|
try {
|
|
18
|
-
for await (const entry of
|
|
19
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
19
20
|
const path = `${dir}/${entry.name}`;
|
|
20
21
|
if (entry.isDirectory) yield* walk(path);
|
|
21
22
|
if (entry.isFile && /\.(ts|tsx)$/.test(entry.name)) yield path;
|
|
@@ -119,7 +120,7 @@ async function hasRouteLocalDataHooks(file: string): Promise<boolean> {
|
|
|
119
120
|
async function siblingPageControllerImportsDataHook(file: string): Promise<boolean> {
|
|
120
121
|
const controller = file.replace(/\.tsx$/, ".controller.ts");
|
|
121
122
|
if (!(await exists(controller))) return false;
|
|
122
|
-
const text = decoder.decode(await
|
|
123
|
+
const text = decoder.decode(await runtime.readFile(controller));
|
|
123
124
|
return importsDataHook(text);
|
|
124
125
|
}
|
|
125
126
|
|
|
@@ -138,7 +139,7 @@ async function requireRuntimeBoundarySchemaUsage(
|
|
|
138
139
|
const schemaFile = file.replace(/\.(ts|tsx)$/u, `.${kind}.schema.ts`);
|
|
139
140
|
if (!(await exists(schemaFile))) return;
|
|
140
141
|
const implementationName = baseName(file).replace(/\.(ts|tsx)$/u, "");
|
|
141
|
-
const schemaText = await
|
|
142
|
+
const schemaText = await runtime.readTextFile(schemaFile);
|
|
142
143
|
for (const violation of runtimeBoundarySchemaUsageViolations({
|
|
143
144
|
expectedImportSpec: `./${implementationName}.${kind}.schema`,
|
|
144
145
|
implementationText: text,
|
|
@@ -176,7 +177,7 @@ for await (const file of walk("src/routes")) {
|
|
|
176
177
|
if (file.endsWith(".form.schema.ts")) requireOperationSpecificFormName(file);
|
|
177
178
|
if (!implementationFile(file)) continue;
|
|
178
179
|
|
|
179
|
-
const text = decoder.decode(await
|
|
180
|
+
const text = decoder.decode(await runtime.readFile(file));
|
|
180
181
|
const specs = importSpecs(text);
|
|
181
182
|
|
|
182
183
|
for (const spec of specs) {
|
|
@@ -283,6 +284,6 @@ for await (const file of walk("src/routes")) {
|
|
|
283
284
|
|
|
284
285
|
if (violations.length) {
|
|
285
286
|
console.error(violations.join("\n"));
|
|
286
|
-
|
|
287
|
+
runtime.exit(1);
|
|
287
288
|
}
|
|
288
289
|
console.log("layers-and-contracts ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "layers-and-contracts-convex",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
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 backend rule: layers-and-contracts",
|
|
28
|
-
"body": "Use `.agents/skills/layers-and-contracts/SKILL.md` for this backend-specific rule. Run `
|
|
28
|
+
"body": "Use `.agents/skills/layers-and-contracts/SKILL.md` for this backend-specific rule. Run `node .agents/skills/layers-and-contracts/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/layers-and-contracts/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
import { runtimeBoundarySchemaUsageViolations } from "./policy.ts";
|
|
2
3
|
|
|
3
4
|
// oxlint-disable no-console no-await-in-loop
|
|
@@ -6,7 +7,7 @@ const violations: string[] = [];
|
|
|
6
7
|
|
|
7
8
|
async function exists(path: string): Promise<boolean> {
|
|
8
9
|
try {
|
|
9
|
-
await
|
|
10
|
+
await runtime.stat(path);
|
|
10
11
|
return true;
|
|
11
12
|
} catch {
|
|
12
13
|
return false;
|
|
@@ -15,7 +16,7 @@ async function exists(path: string): Promise<boolean> {
|
|
|
15
16
|
|
|
16
17
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
17
18
|
try {
|
|
18
|
-
for await (const entry of
|
|
19
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
19
20
|
const path = `${dir}/${entry.name}`;
|
|
20
21
|
if (entry.isDirectory) yield* walk(path);
|
|
21
22
|
if (entry.isFile && /\.(ts|tsx)$/.test(entry.name)) yield path;
|
|
@@ -174,7 +175,7 @@ async function requireRuntimeBoundarySchemaUsage(
|
|
|
174
175
|
const schemaFile = file.replace(/\.(ts|tsx)$/u, `.${kind}.schema.ts`);
|
|
175
176
|
if (!(await exists(schemaFile))) return;
|
|
176
177
|
const implementationName = baseName(file).replace(/\.(ts|tsx)$/u, "");
|
|
177
|
-
const schemaText = await
|
|
178
|
+
const schemaText = await runtime.readTextFile(schemaFile);
|
|
178
179
|
for (const violation of runtimeBoundarySchemaUsageViolations({
|
|
179
180
|
expectedImportSpec: `./${implementationName}.${kind}.schema`,
|
|
180
181
|
implementationText: text,
|
|
@@ -218,7 +219,7 @@ for await (const file of walk(routeRoot ?? "src/routes")) {
|
|
|
218
219
|
if (file.endsWith(".form.schema.ts")) requireOperationSpecificFormName(file);
|
|
219
220
|
if (!implementationFile(file)) continue;
|
|
220
221
|
|
|
221
|
-
const text = decoder.decode(await
|
|
222
|
+
const text = decoder.decode(await runtime.readFile(file));
|
|
222
223
|
const specs = importSpecs(text);
|
|
223
224
|
|
|
224
225
|
for (const spec of specs) {
|
|
@@ -319,7 +320,7 @@ for await (const file of walk(routeRoot ?? "src/routes")) {
|
|
|
319
320
|
for await (const file of walk("src/application")) {
|
|
320
321
|
if (!implementationFile(file)) continue;
|
|
321
322
|
|
|
322
|
-
const text = decoder.decode(await
|
|
323
|
+
const text = decoder.decode(await runtime.readFile(file));
|
|
323
324
|
forbid(/@\/routes\//.test(text), file, "application must not import route-layer code");
|
|
324
325
|
forbid(/@\/components\//.test(text), file, "application must not import UI components");
|
|
325
326
|
forbid(
|
|
@@ -344,7 +345,7 @@ for await (const file of walk("src/application")) {
|
|
|
344
345
|
for await (const file of walk("src/dal")) {
|
|
345
346
|
if (!implementationFile(file)) continue;
|
|
346
347
|
|
|
347
|
-
const text = decoder.decode(await
|
|
348
|
+
const text = decoder.decode(await runtime.readFile(file));
|
|
348
349
|
forbid(/@\/routes\//.test(text), file, "DAL must not import route-layer code");
|
|
349
350
|
forbid(/@\/components\//.test(text), file, "DAL must not import UI components");
|
|
350
351
|
|
|
@@ -365,6 +366,6 @@ for await (const file of walk("src/dal")) {
|
|
|
365
366
|
|
|
366
367
|
if (violations.length) {
|
|
367
368
|
console.error(violations.join("\n"));
|
|
368
|
-
|
|
369
|
+
runtime.exit(1);
|
|
369
370
|
}
|
|
370
371
|
console.log("layers-and-contracts ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "layers-and-contracts-supabase",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.7",
|
|
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 backend rule: layers-and-contracts",
|
|
28
|
-
"body": "Use `.agents/skills/layers-and-contracts/SKILL.md` for this backend-specific rule. Run `
|
|
28
|
+
"body": "Use `.agents/skills/layers-and-contracts/SKILL.md` for this backend-specific rule. Run `node .agents/skills/layers-and-contracts/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/layers-and-contracts/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
const textEncoder = new TextEncoder();
|
|
2
3
|
|
|
3
4
|
function writeLine(message: string): void {
|
|
4
|
-
|
|
5
|
+
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
function writeError(message: string): void {
|
|
8
|
-
|
|
9
|
+
runtime.stderr.writeSync(textEncoder.encode(`${message}\n`));
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
type ModuleSizeConfig = {
|
|
@@ -15,7 +16,7 @@ type ModuleSizeConfig = {
|
|
|
15
16
|
readonly ignoredGlobs?: readonly string[];
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const root =
|
|
19
|
+
const root = runtime.cwd();
|
|
19
20
|
const config = await readConfig();
|
|
20
21
|
const maxFileLines = Number(config.maxFileLines ?? 260);
|
|
21
22
|
const maxComponentLines = Number(config.maxComponentLines ?? 180);
|
|
@@ -36,7 +37,7 @@ const errors: string[] = [];
|
|
|
36
37
|
async function readConfig(): Promise<ModuleSizeConfig> {
|
|
37
38
|
try {
|
|
38
39
|
const parsed = JSON.parse(
|
|
39
|
-
await
|
|
40
|
+
await runtime.readTextFile(".agents/skills/module-size-rules/config.json"),
|
|
40
41
|
) as ModuleSizeConfig;
|
|
41
42
|
return parsed;
|
|
42
43
|
} catch {
|
|
@@ -111,7 +112,7 @@ function functionLineViolations(rel: string, text: string): string[] {
|
|
|
111
112
|
|
|
112
113
|
async function walk(dir: string): Promise<void> {
|
|
113
114
|
try {
|
|
114
|
-
for await (const ent of
|
|
115
|
+
for await (const ent of runtime.readDir(dir)) {
|
|
115
116
|
const p = `${dir}/${ent.name}`;
|
|
116
117
|
if (ent.isDirectory) {
|
|
117
118
|
if (!["node_modules", ".git", "dist", "coverage", "code-templates"].includes(ent.name)) {
|
|
@@ -120,7 +121,7 @@ async function walk(dir: string): Promise<void> {
|
|
|
120
121
|
} else if (/\.(ts|tsx)$/u.test(ent.name)) {
|
|
121
122
|
const rel = toRelative(p);
|
|
122
123
|
if (shouldIgnore(rel)) continue;
|
|
123
|
-
const text = await
|
|
124
|
+
const text = await runtime.readTextFile(p);
|
|
124
125
|
const lines = text.split(/\r?\n/u).length;
|
|
125
126
|
const limit = rel.endsWith(".tsx") ? maxComponentLines : maxFileLines;
|
|
126
127
|
if (lines > limit) {
|
|
@@ -130,7 +131,7 @@ async function walk(dir: string): Promise<void> {
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
} catch (error) {
|
|
133
|
-
if (!(error instanceof
|
|
134
|
+
if (!(error instanceof runtime.errors.NotFound)) throw error;
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -138,6 +139,6 @@ await walk(`${root}/src`);
|
|
|
138
139
|
await walk(`${root}/.agents/skills`);
|
|
139
140
|
if (errors.length > 0) {
|
|
140
141
|
writeError(errors.join("\n"));
|
|
141
|
-
|
|
142
|
+
runtime.exit(1);
|
|
142
143
|
}
|
|
143
144
|
writeLine("module-size-rules ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "module-size-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: module-size-rules",
|
|
28
|
-
"body": "Use `.agents/skills/module-size-rules/SKILL.md` when working in this rule area. Run `
|
|
28
|
+
"body": "Use `.agents/skills/module-size-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/module-size-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/module-size-rules/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
const textEncoder = new TextEncoder();
|
|
2
3
|
|
|
3
4
|
function writeLine(message: string): void {
|
|
4
|
-
|
|
5
|
+
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
function writeError(message: string): void {
|
|
8
|
-
|
|
9
|
+
runtime.stderr.writeSync(textEncoder.encode(`${message}\n`));
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
type ModuleSizeConfig = {
|
|
@@ -15,7 +16,7 @@ type ModuleSizeConfig = {
|
|
|
15
16
|
readonly ignoredGlobs?: readonly string[];
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const root =
|
|
19
|
+
const root = runtime.cwd();
|
|
19
20
|
const config = await readConfig();
|
|
20
21
|
const maxFileLines = Number(config.maxFileLines ?? 260);
|
|
21
22
|
const maxComponentLines = Number(config.maxComponentLines ?? 180);
|
|
@@ -37,7 +38,7 @@ const errors: string[] = [];
|
|
|
37
38
|
async function readConfig(): Promise<ModuleSizeConfig> {
|
|
38
39
|
try {
|
|
39
40
|
const parsed = JSON.parse(
|
|
40
|
-
await
|
|
41
|
+
await runtime.readTextFile(".agents/skills/module-size-rules/config.json"),
|
|
41
42
|
) as ModuleSizeConfig;
|
|
42
43
|
return parsed;
|
|
43
44
|
} catch {
|
|
@@ -112,7 +113,7 @@ function functionLineViolations(rel: string, text: string): string[] {
|
|
|
112
113
|
|
|
113
114
|
async function walk(dir: string): Promise<void> {
|
|
114
115
|
try {
|
|
115
|
-
for await (const ent of
|
|
116
|
+
for await (const ent of runtime.readDir(dir)) {
|
|
116
117
|
const p = `${dir}/${ent.name}`;
|
|
117
118
|
if (ent.isDirectory) {
|
|
118
119
|
if (!["node_modules", ".git", "dist", "coverage", "code-templates"].includes(ent.name)) {
|
|
@@ -121,7 +122,7 @@ async function walk(dir: string): Promise<void> {
|
|
|
121
122
|
} else if (/\.(ts|tsx)$/u.test(ent.name)) {
|
|
122
123
|
const rel = toRelative(p);
|
|
123
124
|
if (shouldIgnore(rel)) continue;
|
|
124
|
-
const text = await
|
|
125
|
+
const text = await runtime.readTextFile(p);
|
|
125
126
|
const lines = text.split(/\r?\n/u).length;
|
|
126
127
|
const limit = rel.endsWith(".tsx") ? maxComponentLines : maxFileLines;
|
|
127
128
|
if (lines > limit) {
|
|
@@ -131,7 +132,7 @@ async function walk(dir: string): Promise<void> {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
} catch (error) {
|
|
134
|
-
if (!(error instanceof
|
|
135
|
+
if (!(error instanceof runtime.errors.NotFound)) throw error;
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -140,6 +141,6 @@ await walk(`${root}/convex`);
|
|
|
140
141
|
await walk(`${root}/.agents/skills`);
|
|
141
142
|
if (errors.length > 0) {
|
|
142
143
|
writeError(errors.join("\n"));
|
|
143
|
-
|
|
144
|
+
runtime.exit(1);
|
|
144
145
|
}
|
|
145
146
|
writeLine("module-size-rules ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "module-size-rules-convex",
|
|
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 backend rule: module-size-rules",
|
|
28
|
-
"body": "Use `.agents/skills/module-size-rules/SKILL.md` for this backend-specific rule. Run `
|
|
28
|
+
"body": "Use `.agents/skills/module-size-rules/SKILL.md` for this backend-specific rule. Run `node .agents/skills/module-size-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/module-size-rules/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
const textEncoder = new TextEncoder();
|
|
2
3
|
|
|
3
4
|
function writeLine(message: string): void {
|
|
4
|
-
|
|
5
|
+
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
function writeError(message: string): void {
|
|
8
|
-
|
|
9
|
+
runtime.stderr.writeSync(textEncoder.encode(`${message}\n`));
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
type ModuleSizeConfig = {
|
|
@@ -15,7 +16,7 @@ type ModuleSizeConfig = {
|
|
|
15
16
|
readonly ignoredGlobs?: readonly string[];
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const root =
|
|
19
|
+
const root = runtime.cwd();
|
|
19
20
|
const config = await readConfig();
|
|
20
21
|
const maxFileLines = Number(config.maxFileLines ?? 260);
|
|
21
22
|
const maxComponentLines = Number(config.maxComponentLines ?? 180);
|
|
@@ -38,7 +39,7 @@ const errors: string[] = [];
|
|
|
38
39
|
async function readConfig(): Promise<ModuleSizeConfig> {
|
|
39
40
|
try {
|
|
40
41
|
const parsed = JSON.parse(
|
|
41
|
-
await
|
|
42
|
+
await runtime.readTextFile(".agents/skills/module-size-rules/config.json"),
|
|
42
43
|
) as ModuleSizeConfig;
|
|
43
44
|
return parsed;
|
|
44
45
|
} catch {
|
|
@@ -113,7 +114,7 @@ function functionLineViolations(rel: string, text: string): string[] {
|
|
|
113
114
|
|
|
114
115
|
async function walk(dir: string): Promise<void> {
|
|
115
116
|
try {
|
|
116
|
-
for await (const ent of
|
|
117
|
+
for await (const ent of runtime.readDir(dir)) {
|
|
117
118
|
const p = `${dir}/${ent.name}`;
|
|
118
119
|
if (ent.isDirectory) {
|
|
119
120
|
if (!["node_modules", ".git", "dist", "coverage", "code-templates"].includes(ent.name)) {
|
|
@@ -122,7 +123,7 @@ async function walk(dir: string): Promise<void> {
|
|
|
122
123
|
} else if (/\.(ts|tsx)$/u.test(ent.name)) {
|
|
123
124
|
const rel = toRelative(p);
|
|
124
125
|
if (shouldIgnore(rel)) continue;
|
|
125
|
-
const text = await
|
|
126
|
+
const text = await runtime.readTextFile(p);
|
|
126
127
|
const lines = text.split(/\r?\n/u).length;
|
|
127
128
|
const limit = rel.endsWith(".tsx") ? maxComponentLines : maxFileLines;
|
|
128
129
|
if (lines > limit) {
|
|
@@ -132,7 +133,7 @@ async function walk(dir: string): Promise<void> {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
} catch (error) {
|
|
135
|
-
if (!(error instanceof
|
|
136
|
+
if (!(error instanceof runtime.errors.NotFound)) throw error;
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -140,6 +141,6 @@ await walk(`${root}/src`);
|
|
|
140
141
|
await walk(`${root}/.agents/skills`);
|
|
141
142
|
if (errors.length > 0) {
|
|
142
143
|
writeError(errors.join("\n"));
|
|
143
|
-
|
|
144
|
+
runtime.exit(1);
|
|
144
145
|
}
|
|
145
146
|
writeLine("module-size-rules ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "module-size-rules-supabase",
|
|
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 backend rule: module-size-rules",
|
|
28
|
-
"body": "Use `.agents/skills/module-size-rules/SKILL.md` for this backend-specific rule. Run `
|
|
28
|
+
"body": "Use `.agents/skills/module-size-rules/SKILL.md` for this backend-specific rule. Run `node .agents/skills/module-size-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/module-size-rules/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
import { assertSchemaVersion, readSkillConfig } from "../shared/config.ts";
|
|
2
3
|
import { exists } from "../shared/fs.ts";
|
|
3
4
|
|
|
@@ -12,7 +13,7 @@ for (const boundary of config.boundaries) {
|
|
|
12
13
|
violations.push(`${boundary.file}: configured mutation boundary is missing`);
|
|
13
14
|
continue;
|
|
14
15
|
}
|
|
15
|
-
const text = await
|
|
16
|
+
const text = await runtime.readTextFile(path);
|
|
16
17
|
for (const marker of boundary.requiredMarkers ?? [])
|
|
17
18
|
if (!text.includes(marker))
|
|
18
19
|
violations.push(
|
|
@@ -26,4 +27,4 @@ for (const boundary of config.boundaries) {
|
|
|
26
27
|
}
|
|
27
28
|
console.log(`# mutation command rule violations: ${violations.length}`);
|
|
28
29
|
for (const violation of violations) console.log(`- ${violation}`);
|
|
29
|
-
if (violations.length > 0)
|
|
30
|
+
if (violations.length > 0) runtime.exit(1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "mutation-command-rules",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
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: mutation-command-rules",
|
|
28
|
-
"body": "Use `.agents/skills/mutation-command-rules/SKILL.md` when working in this rule area. Run `
|
|
28
|
+
"body": "Use `.agents/skills/mutation-command-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/mutation-command-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/mutation-command-rules/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -12,7 +12,7 @@ Boundary-specific contracts such as `*.input.schema.ts`, `*.output.schema.ts`, `
|
|
|
12
12
|
## Check
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
|
|
15
|
+
node .agents/skills/nearby-contracts/check.ts
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Configuration lives in `./config.json` in this skill folder. Keep exceptions explicit and small.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
const textEncoder = new TextEncoder();
|
|
2
3
|
|
|
3
4
|
function writeLine(message: string): void {
|
|
4
|
-
|
|
5
|
+
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
@@ -13,7 +14,7 @@ type NearbyContractsConfig = {
|
|
|
13
14
|
readonly exclude?: readonly string[];
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const root = path.resolve(
|
|
17
|
+
const root = path.resolve(runtime.args[0] || runtime.cwd());
|
|
17
18
|
const skillDir = path.dirname(new URL(import.meta.url).pathname);
|
|
18
19
|
const configPath = path.join(skillDir, "config.json");
|
|
19
20
|
const config = readConfig(configPath);
|
|
@@ -132,6 +133,6 @@ for (const file of files) {
|
|
|
132
133
|
|
|
133
134
|
if (violations.length) {
|
|
134
135
|
writeLine(violations.join("\n"));
|
|
135
|
-
|
|
136
|
+
runtime.exit(1);
|
|
136
137
|
}
|
|
137
138
|
writeLine("nearby-contracts ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "nearby-contracts",
|
|
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: nearby-contracts",
|
|
28
|
-
"body": "Use `.agents/skills/nearby-contracts/SKILL.md` when working in this rule area. Run `
|
|
28
|
+
"body": "Use `.agents/skills/nearby-contracts/SKILL.md` when working in this rule area. Run `node .agents/skills/nearby-contracts/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/nearby-contracts/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
import { walk } from "../shared/fs.ts";
|
|
2
3
|
|
|
3
4
|
const allowedFiles = new Set(["src/components/ui/button.tsx"]);
|
|
@@ -16,7 +17,7 @@ const files = (await walk("src")).map((file) => `src/${file}`).filter(shouldChec
|
|
|
16
17
|
const violations: string[] = [];
|
|
17
18
|
|
|
18
19
|
for (const file of files) {
|
|
19
|
-
const text = await
|
|
20
|
+
const text = await runtime.readTextFile(file);
|
|
20
21
|
const lines = text.split("\n");
|
|
21
22
|
lines.forEach((line, index) => {
|
|
22
23
|
if (/<button(\s|>|$)/.test(line)) {
|
|
@@ -30,7 +31,7 @@ for (const file of files) {
|
|
|
30
31
|
if (violations.length > 0) {
|
|
31
32
|
console.error(`# raw button violations: ${violations.length}`);
|
|
32
33
|
console.error(violations.join("\n"));
|
|
33
|
-
|
|
34
|
+
runtime.exit(1);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
console.log("no-raw-click-buttons ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "no-raw-click-buttons",
|
|
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: no-raw-click-buttons",
|
|
23
|
-
"body": "Use `.agents/skills/no-raw-click-buttons/SKILL.md` when working in this rule area. Run `
|
|
23
|
+
"body": "Use `.agents/skills/no-raw-click-buttons/SKILL.md` when working in this rule area. Run `node .agents/skills/no-raw-click-buttons/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/no-raw-click-buttons/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
const textEncoder = new TextEncoder();
|
|
2
3
|
function writeLine(message: string): void {
|
|
3
|
-
|
|
4
|
+
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
4
5
|
}
|
|
5
6
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
|
|
8
|
-
const root = path.resolve(
|
|
9
|
+
const root = path.resolve(runtime.args[0] || runtime.cwd());
|
|
9
10
|
const configFile = path.join(path.dirname(new URL(import.meta.url).pathname), "config.json");
|
|
10
11
|
const skip = new Set([".git", "code-templates", "node_modules", "dist", "build", "coverage"]);
|
|
11
12
|
|