@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
|
@@ -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
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "public-api-export-barrels",
|
|
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 rule: public-api-export-barrels",
|
|
28
|
-
"body": "Use `.agents/skills/public-api-export-barrels/SKILL.md` when working in this rule area. Run `
|
|
28
|
+
"body": "Use `.agents/skills/public-api-export-barrels/SKILL.md` when working in this rule area. Run `node .agents/skills/public-api-export-barrels/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/public-api-export-barrels/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -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 && /\.tsx?$/.test(entry.name)) yield path;
|
|
@@ -23,23 +24,24 @@ async function* walk(dir: string): AsyncGenerator<string> {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
const usesTanstackFileRoutes =
|
|
27
|
+
const usesTanstackFileRoutes =
|
|
28
|
+
(await exists("src/routes")) || (await exists("src/routeTree.gen.ts"));
|
|
27
29
|
|
|
28
30
|
if (!usesTanstackFileRoutes) {
|
|
29
31
|
console.log("route-tree-fresh not applicable");
|
|
30
|
-
|
|
32
|
+
runtime.exit(0);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
if (!(await exists("src/routeTree.gen.ts"))) {
|
|
34
36
|
violations.push("missing generated route tree: src/routeTree.gen.ts");
|
|
35
37
|
} else {
|
|
36
|
-
const routeTree = decoder.decode(await
|
|
38
|
+
const routeTree = decoder.decode(await runtime.readFile("src/routeTree.gen.ts"));
|
|
37
39
|
|
|
38
40
|
for await (const file of walk("src/routes")) {
|
|
39
41
|
if (file.includes("/-components/")) continue;
|
|
40
42
|
if (!file.endsWith(".tsx")) continue;
|
|
41
43
|
|
|
42
|
-
const text = decoder.decode(await
|
|
44
|
+
const text = decoder.decode(await runtime.readFile(file));
|
|
43
45
|
const match = text.match(/createFileRoute\(["']([^"']+)["']\)/u);
|
|
44
46
|
if (!match) continue;
|
|
45
47
|
|
|
@@ -55,7 +57,7 @@ if (!(await exists("src/routeTree.gen.ts"))) {
|
|
|
55
57
|
|
|
56
58
|
if (violations.length) {
|
|
57
59
|
console.error(violations.join("\n"));
|
|
58
|
-
|
|
60
|
+
runtime.exit(1);
|
|
59
61
|
}
|
|
60
62
|
console.log("route-tree-fresh ok");
|
|
61
63
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "route-tree-fresh",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
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: route-tree-fresh",
|
|
23
|
-
"body": "Use `.agents/skills/route-tree-fresh/SKILL.md` when working in this rule area. Run `
|
|
23
|
+
"body": "Use `.agents/skills/route-tree-fresh/SKILL.md` when working in this rule area. Run `node .agents/skills/route-tree-fresh/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/route-tree-fresh/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop
|
|
2
3
|
const violations: string[] = [];
|
|
3
4
|
|
|
4
5
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
5
6
|
try {
|
|
6
|
-
for await (const entry of
|
|
7
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
7
8
|
const path = `${dir}/${entry.name}`;
|
|
8
9
|
if (entry.isDirectory) yield* walk(path);
|
|
9
10
|
if (entry.isFile && /\.(ts|tsx)$/u.test(entry.name)) yield path;
|
|
@@ -26,7 +27,6 @@ function isTestOrStory(file: string): boolean {
|
|
|
26
27
|
);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
30
|
function stripComments(text: string): string {
|
|
31
31
|
let result = "";
|
|
32
32
|
let index = 0;
|
|
@@ -45,14 +45,17 @@ function stripComments(text: string): string {
|
|
|
45
45
|
index += 1;
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
|
-
if (char === "
|
|
48
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
49
49
|
quote = char;
|
|
50
50
|
result += char;
|
|
51
51
|
index += 1;
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
if (char === "/" && next === "/") {
|
|
55
|
-
while (index < text.length && text[index] !== "\n") {
|
|
55
|
+
while (index < text.length && text[index] !== "\n") {
|
|
56
|
+
result += " ";
|
|
57
|
+
index += 1;
|
|
58
|
+
}
|
|
56
59
|
continue;
|
|
57
60
|
}
|
|
58
61
|
if (char === "/" && next === "*") {
|
|
@@ -62,7 +65,10 @@ function stripComments(text: string): string {
|
|
|
62
65
|
result += text[index] === "\n" ? "\n" : " ";
|
|
63
66
|
index += 1;
|
|
64
67
|
}
|
|
65
|
-
if (index < text.length) {
|
|
68
|
+
if (index < text.length) {
|
|
69
|
+
result += " ";
|
|
70
|
+
index += 2;
|
|
71
|
+
}
|
|
66
72
|
continue;
|
|
67
73
|
}
|
|
68
74
|
result += char;
|
|
@@ -86,7 +92,7 @@ function checkBoundarySchemaTypes(file: string, text: string): void {
|
|
|
86
92
|
|
|
87
93
|
for await (const file of walk("src")) {
|
|
88
94
|
if (isIgnored(file)) continue;
|
|
89
|
-
const text = await
|
|
95
|
+
const text = await runtime.readTextFile(file);
|
|
90
96
|
const source = stripComments(text);
|
|
91
97
|
checkBoundarySchemaTypes(file, source);
|
|
92
98
|
if (isTestOrStory(file)) continue;
|
|
@@ -99,13 +105,15 @@ for await (const file of walk("src")) {
|
|
|
99
105
|
if (/!\./u.test(source) || /!;/u.test(source)) {
|
|
100
106
|
violations.push(`${file}: avoid non-null assertions`);
|
|
101
107
|
}
|
|
102
|
-
for (const match of source.matchAll(
|
|
108
|
+
for (const match of source.matchAll(
|
|
109
|
+
/\bas\s+(any|unknown|never)\b|\bas\s+unknown\s+as\b|<any>/gu,
|
|
110
|
+
)) {
|
|
103
111
|
violations.push(`${file}:${lineNumber(text, match.index ?? 0)} avoid unsafe casts`);
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
if (violations.length) {
|
|
108
116
|
console.error(violations.join("\n"));
|
|
109
|
-
|
|
117
|
+
runtime.exit(1);
|
|
110
118
|
}
|
|
111
119
|
console.log("strict-typescript ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "strict-typescript",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
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: strict-typescript",
|
|
23
|
-
"body": "Use `.agents/skills/strict-typescript/SKILL.md` when working in this rule area. Run `
|
|
23
|
+
"body": "Use `.agents/skills/strict-typescript/SKILL.md` when working in this rule area. Run `node .agents/skills/strict-typescript/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/strict-typescript/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
|
const required = [
|
|
3
4
|
"src/__generated__/database.ts",
|
|
@@ -16,7 +17,7 @@ const sharedPairs = [
|
|
|
16
17
|
const missing: string[] = [];
|
|
17
18
|
for (const path of required) {
|
|
18
19
|
try {
|
|
19
|
-
await
|
|
20
|
+
await runtime.stat(path);
|
|
20
21
|
} catch {
|
|
21
22
|
missing.push(path);
|
|
22
23
|
}
|
|
@@ -25,8 +26,8 @@ for (const path of required) {
|
|
|
25
26
|
const mismatches: string[] = [];
|
|
26
27
|
for (const [left, right] of sharedPairs) {
|
|
27
28
|
try {
|
|
28
|
-
const leftText = await
|
|
29
|
-
const rightText = await
|
|
29
|
+
const leftText = await runtime.readTextFile(left);
|
|
30
|
+
const rightText = await runtime.readTextFile(right);
|
|
30
31
|
if (leftText !== rightText) mismatches.push(`${left} != ${right}`);
|
|
31
32
|
} catch {
|
|
32
33
|
// Missing files are reported above.
|
|
@@ -59,14 +60,14 @@ if (missing.length || mismatches.length || incompleteSchemas.length || missingDa
|
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
console.error(parts.join("\n"));
|
|
62
|
-
|
|
63
|
+
runtime.exit(1);
|
|
63
64
|
}
|
|
64
65
|
console.log("supabase-contracts ok");
|
|
65
66
|
|
|
66
67
|
async function findIncompleteGeneratedSchemas(): Promise<string[]> {
|
|
67
68
|
try {
|
|
68
|
-
const databaseText = await
|
|
69
|
-
const schemaText = await
|
|
69
|
+
const databaseText = await runtime.readTextFile("src/__generated__/database.ts");
|
|
70
|
+
const schemaText = await runtime.readTextFile("src/__generated__/schema.ts");
|
|
70
71
|
const tableNames = getPublicTableNames(databaseText);
|
|
71
72
|
const missingExports: string[] = [];
|
|
72
73
|
for (const tableName of tableNames) {
|
|
@@ -85,13 +86,13 @@ async function findIncompleteGeneratedSchemas(): Promise<string[]> {
|
|
|
85
86
|
|
|
86
87
|
async function findMissingDalTables(): Promise<string[]> {
|
|
87
88
|
try {
|
|
88
|
-
const databaseText = await
|
|
89
|
+
const databaseText = await runtime.readTextFile("src/__generated__/database.ts");
|
|
89
90
|
const tableNames = new Set(getAllTableNames(databaseText));
|
|
90
91
|
const violations: string[] = [];
|
|
91
92
|
for await (const file of walk("src/dal")) {
|
|
92
93
|
if (!file.endsWith(".ts")) continue;
|
|
93
94
|
if (file.endsWith(".test.ts")) continue;
|
|
94
|
-
const text = await
|
|
95
|
+
const text = await runtime.readTextFile(file);
|
|
95
96
|
for (const tableName of getDalFromTableNames(text)) {
|
|
96
97
|
if (!tableNames.has(tableName)) {
|
|
97
98
|
violations.push(
|
|
@@ -122,7 +123,7 @@ function getDalFromTableNames(text: string): string[] {
|
|
|
122
123
|
|
|
123
124
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
124
125
|
try {
|
|
125
|
-
for await (const entry of
|
|
126
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
126
127
|
const path = `${dir}/${entry.name}`;
|
|
127
128
|
if (entry.isDirectory) yield* walk(path);
|
|
128
129
|
if (entry.isFile) yield path;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "supabase-contracts",
|
|
3
3
|
"kind": "rule",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
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: supabase-contracts",
|
|
23
|
-
"body": "Use `.agents/skills/supabase-contracts/SKILL.md` for this backend-specific rule. Run `
|
|
23
|
+
"body": "Use `.agents/skills/supabase-contracts/SKILL.md` for this backend-specific rule. Run `node .agents/skills/supabase-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/supabase-contracts/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|
|
@@ -24,7 +24,7 @@ Use this skill before adding, changing, or reviewing Supabase schema, generated
|
|
|
24
24
|
## Check
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
|
|
27
|
+
node .agents/skills/supabase-declarative-schema/check.ts
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Configuration lives in `./config.json` in this skill folder. Keep exceptions explicit and small.
|
|
@@ -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
|
|
|
@@ -10,7 +11,7 @@ type DeclarativeSchemaConfig = {
|
|
|
10
11
|
|
|
11
12
|
async function readText(path: string): Promise<string | null> {
|
|
12
13
|
try {
|
|
13
|
-
return await
|
|
14
|
+
return await runtime.readTextFile(path);
|
|
14
15
|
} catch {
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
@@ -18,7 +19,7 @@ async function readText(path: string): Promise<string | null> {
|
|
|
18
19
|
|
|
19
20
|
async function exists(path: string): Promise<boolean> {
|
|
20
21
|
try {
|
|
21
|
-
await
|
|
22
|
+
await runtime.stat(path);
|
|
22
23
|
return true;
|
|
23
24
|
} catch {
|
|
24
25
|
return false;
|
|
@@ -27,7 +28,7 @@ async function exists(path: string): Promise<boolean> {
|
|
|
27
28
|
|
|
28
29
|
async function* walk(dir: string): AsyncGenerator<string> {
|
|
29
30
|
try {
|
|
30
|
-
for await (const entry of
|
|
31
|
+
for await (const entry of runtime.readDir(dir)) {
|
|
31
32
|
const path = `${dir}/${entry.name}`;
|
|
32
33
|
if (entry.isDirectory) yield* walk(path);
|
|
33
34
|
if (entry.isFile) yield path;
|
|
@@ -255,7 +256,7 @@ if (!packageScripts) {
|
|
|
255
256
|
if (violations.length) {
|
|
256
257
|
console.error(`# supabase-declarative-schema violations: ${violations.length}`);
|
|
257
258
|
for (const violation of violations) console.error(`- ${violation}`);
|
|
258
|
-
|
|
259
|
+
runtime.exit(1);
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
console.log("supabase-declarative-schema ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "supabase-declarative-schema",
|
|
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 backend rule: supabase-declarative-schema",
|
|
28
|
-
"body": "Use `.agents/skills/supabase-declarative-schema/SKILL.md` for this backend-specific rule. Run `
|
|
28
|
+
"body": "Use `.agents/skills/supabase-declarative-schema/SKILL.md` for this backend-specific rule. Run `node .agents/skills/supabase-declarative-schema/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/supabase-declarative-schema/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|
|
@@ -5,7 +5,7 @@ Use TanStack Form for submitting route forms and form value state. Do not replac
|
|
|
5
5
|
Before changing route forms, inspect this skill and run:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
node .agents/skills/tanstack-form-rules/check.ts
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Fix violations in application code separately from Devkit `sync`.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
// oxlint-disable no-console no-await-in-loop
|
|
2
3
|
import { walk } from "../shared/fs.ts";
|
|
3
4
|
|
|
@@ -24,7 +25,7 @@ const files = (await walk("src/routes")).map((file) => `src/routes/${file}`).fil
|
|
|
24
25
|
const violations: string[] = [];
|
|
25
26
|
|
|
26
27
|
for (const file of files) {
|
|
27
|
-
const text = await
|
|
28
|
+
const text = await runtime.readTextFile(file);
|
|
28
29
|
if (/new\s+FormData\s*\(/u.test(text)) {
|
|
29
30
|
for (const match of text.matchAll(/new\s+FormData\s*\(/gu)) {
|
|
30
31
|
violations.push(
|
|
@@ -52,6 +53,6 @@ for (const file of files) {
|
|
|
52
53
|
if (violations.length > 0) {
|
|
53
54
|
console.error(`# tanstack form rule violations: ${violations.length}`);
|
|
54
55
|
console.error(violations.join("\n"));
|
|
55
|
-
|
|
56
|
+
runtime.exit(1);
|
|
56
57
|
}
|
|
57
58
|
console.log("tanstack-form-rules ok");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "tanstack-form-rules",
|
|
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: tanstack-form-rules",
|
|
23
|
-
"body": "Use `.agents/skills/tanstack-form-rules/SKILL.md` when working in this rule area. Run `
|
|
23
|
+
"body": "Use `.agents/skills/tanstack-form-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/tanstack-form-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/tanstack-form-rules/check.ts"
|
|
33
31
|
]
|
|
34
32
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runtime } from "../shared/runtime.ts";
|
|
1
2
|
import { assertSchemaVersion, readSkillConfig } from "../shared/config.ts";
|
|
2
3
|
import { exists, normalizePath, walk } from "../shared/fs.ts";
|
|
3
4
|
|
|
@@ -50,9 +51,9 @@ function isUnitTest(file: string): boolean {
|
|
|
50
51
|
|
|
51
52
|
async function readJsonFile(path: string): Promise<Record<string, unknown> | null> {
|
|
52
53
|
try {
|
|
53
|
-
return JSON.parse(await
|
|
54
|
+
return JSON.parse(await runtime.readTextFile(path)) as Record<string, unknown>;
|
|
54
55
|
} catch (error) {
|
|
55
|
-
if (error instanceof
|
|
56
|
+
if (error instanceof runtime.errors.NotFound) return null;
|
|
56
57
|
throw error;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -80,7 +81,7 @@ for (const file of [...allowedRootTests].sort()) {
|
|
|
80
81
|
|
|
81
82
|
for (const file of files.filter(isUnitTest).sort()) {
|
|
82
83
|
if (allowedForbiddenPatternFiles.has(file)) continue;
|
|
83
|
-
const text = await
|
|
84
|
+
const text = await runtime.readTextFile(`${root}/${file}`);
|
|
84
85
|
for (const pattern of forbiddenUnitTestPatterns) {
|
|
85
86
|
if (text.includes(pattern)) {
|
|
86
87
|
violations.push(`${file}: unit test contains forbidden pattern ${JSON.stringify(pattern)}`);
|
|
@@ -97,7 +98,7 @@ for (const owner of config.requiredCriticalOwnerTests ?? []) {
|
|
|
97
98
|
violations.push(`${owner.test}: critical source ${owner.source} requires this owner test`);
|
|
98
99
|
continue;
|
|
99
100
|
}
|
|
100
|
-
const text = await
|
|
101
|
+
const text = await runtime.readTextFile(`${root}/${owner.test}`);
|
|
101
102
|
for (const marker of owner.markers ?? [])
|
|
102
103
|
if (!text.includes(marker))
|
|
103
104
|
violations.push(
|
|
@@ -128,4 +129,4 @@ if (config.requireCoverageScript ?? true) {
|
|
|
128
129
|
|
|
129
130
|
console.log(`# unit test rule violations: ${violations.length}`);
|
|
130
131
|
for (const violation of violations) console.log(`- ${violation}`);
|
|
131
|
-
if (violations.length > 0)
|
|
132
|
+
if (violations.length > 0) runtime.exit(1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "unit-test-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: unit-test-rules",
|
|
28
|
-
"body": "Use `.agents/skills/unit-test-rules/SKILL.md` when working in this rule area. Run `
|
|
28
|
+
"body": "Use `.agents/skills/unit-test-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/unit-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/unit-test-rules/check.ts"
|
|
38
36
|
]
|
|
39
37
|
}
|