@specdest/devkit 0.2.2 → 0.3.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/README.md +15 -20
- package/package.json +4 -4
- package/src/canonical-project-operations.js +157 -0
- package/src/canonical-project.js +50 -0
- package/src/canonical-source.js +114 -0
- package/src/cli.js +2 -2
- package/src/git-catalog.js +105 -0
- package/src/index.js +6 -2
- package/src/project-operations.js +65 -6
- package/src/remote-installer.js +462 -0
- package/src/sync-core.js +20 -7
- package/catalog/README.md +0 -11
- package/catalog/modules/backend-convex/manifest.json +0 -14
- package/catalog/modules/backend-convex-expo/manifest.json +0 -11
- package/catalog/modules/backend-supabase/manifest.json +0 -15
- package/catalog/modules/backend-supabase-expo/manifest.json +0 -11
- package/catalog/modules/checker-runtime/config.ts +0 -25
- package/catalog/modules/checker-runtime/fs.ts +0 -48
- package/catalog/modules/checker-runtime/manifest.json +0 -29
- package/catalog/modules/checker-runtime/runtime.ts +0 -79
- package/catalog/modules/devflow/.agents/skills/devflow/SKILL.md +0 -33
- package/catalog/modules/devflow/.devflow.json +0 -10
- package/catalog/modules/devflow/manifest.json +0 -35
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/SKILL.md +0 -85
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/activeScenario.mjs +0 -130
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs +0 -7
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs +0 -36
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/createActiveScenario.mjs +0 -143
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs +0 -43
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/prompt.mjs +0 -25
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs +0 -66
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs +0 -146
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seed.mjs +0 -56
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs +0 -6
- package/catalog/modules/e2e-playwright/docs/e2e-playwright/README.md +0 -103
- package/catalog/modules/e2e-playwright/manifest.json +0 -206
- package/catalog/modules/e2e-playwright/playwright.e2e.config.ts +0 -39
- package/catalog/modules/e2e-playwright/tests/e2e/support/e2ePlaywrightFlow.ts +0 -107
- package/catalog/modules/e2e-playwright/tests/e2e/support/fixtures.ts +0 -27
- package/catalog/modules/local-log/AGENTS.local-log.md +0 -13
- package/catalog/modules/local-log/docs/features/local-logging/README.md +0 -70
- package/catalog/modules/local-log/manifest.json +0 -39
- package/catalog/modules/local-log/tmp/logs/.gitignore +0 -2
- package/catalog/modules/local-log/tools/local-log/README.md +0 -47
- package/catalog/modules/local-log/tools/local-log/local-log.mjs +0 -241
- package/catalog/modules/stack-common-vite/manifest.json +0 -16
- package/catalog/modules/stack-expo-convex/manifest.json +0 -31
- package/catalog/modules/stack-expo-supabase/manifest.json +0 -44
- package/catalog/modules/stack-vite-convex/manifest.json +0 -32
- package/catalog/modules/stack-vite-supabase/manifest.json +0 -45
- package/catalog/rules/abac-permissions-convex/SKILL.md +0 -17
- package/catalog/rules/abac-permissions-convex/check.ts +0 -87
- package/catalog/rules/abac-permissions-convex/manifest.json +0 -33
- package/catalog/rules/abac-permissions-supabase/SKILL.md +0 -17
- package/catalog/rules/abac-permissions-supabase/check.ts +0 -87
- package/catalog/rules/abac-permissions-supabase/manifest.json +0 -33
- package/catalog/rules/convex-multi-presentation/SKILL.md +0 -47
- package/catalog/rules/convex-multi-presentation/check.ts +0 -205
- package/catalog/rules/convex-multi-presentation/manifest.json +0 -47
- package/catalog/rules/convex-multi-presentation/policy.ts +0 -261
- package/catalog/rules/design-rules/SKILL.md +0 -12
- package/catalog/rules/design-rules/check.ts +0 -84
- package/catalog/rules/design-rules/config.json +0 -5
- package/catalog/rules/design-rules/manifest.json +0 -38
- package/catalog/rules/e2e-test-rules/SKILL.md +0 -46
- package/catalog/rules/e2e-test-rules/check.ts +0 -145
- package/catalog/rules/e2e-test-rules/config.json +0 -32
- package/catalog/rules/e2e-test-rules/manifest.json +0 -38
- package/catalog/rules/error-handling-rules/SKILL.md +0 -21
- package/catalog/rules/error-handling-rules/check.ts +0 -73
- package/catalog/rules/error-handling-rules/manifest.json +0 -33
- package/catalog/rules/layers-and-contracts/SKILL.md +0 -36
- package/catalog/rules/layers-and-contracts/check.ts +0 -266
- package/catalog/rules/layers-and-contracts/manifest.json +0 -33
- package/catalog/rules/layers-and-contracts-convex/SKILL.md +0 -49
- package/catalog/rules/layers-and-contracts-convex/check.ts +0 -289
- package/catalog/rules/layers-and-contracts-convex/manifest.json +0 -38
- package/catalog/rules/layers-and-contracts-convex/policy.ts +0 -68
- package/catalog/rules/layers-and-contracts-supabase/SKILL.md +0 -52
- package/catalog/rules/layers-and-contracts-supabase/check.ts +0 -371
- package/catalog/rules/layers-and-contracts-supabase/manifest.json +0 -38
- package/catalog/rules/layers-and-contracts-supabase/policy.ts +0 -68
- package/catalog/rules/module-size-rules/SKILL.md +0 -5
- package/catalog/rules/module-size-rules/check.ts +0 -144
- package/catalog/rules/module-size-rules/config.json +0 -6
- package/catalog/rules/module-size-rules/manifest.json +0 -38
- package/catalog/rules/module-size-rules-convex/SKILL.md +0 -5
- package/catalog/rules/module-size-rules-convex/check.ts +0 -146
- package/catalog/rules/module-size-rules-convex/config.json +0 -6
- package/catalog/rules/module-size-rules-convex/manifest.json +0 -38
- package/catalog/rules/module-size-rules-supabase/SKILL.md +0 -5
- package/catalog/rules/module-size-rules-supabase/check.ts +0 -146
- package/catalog/rules/module-size-rules-supabase/config.json +0 -12
- package/catalog/rules/module-size-rules-supabase/manifest.json +0 -38
- package/catalog/rules/mutation-command-rules/SKILL.md +0 -15
- package/catalog/rules/mutation-command-rules/check.ts +0 -30
- package/catalog/rules/mutation-command-rules/config.json +0 -19
- package/catalog/rules/mutation-command-rules/manifest.json +0 -38
- package/catalog/rules/nearby-contracts/SKILL.md +0 -18
- package/catalog/rules/nearby-contracts/check.ts +0 -138
- package/catalog/rules/nearby-contracts/config.json +0 -10
- package/catalog/rules/nearby-contracts/manifest.json +0 -38
- package/catalog/rules/no-raw-click-buttons/SKILL.md +0 -5
- package/catalog/rules/no-raw-click-buttons/check.ts +0 -37
- package/catalog/rules/no-raw-click-buttons/manifest.json +0 -33
- package/catalog/rules/public-api-export-barrels/SKILL.md +0 -45
- package/catalog/rules/public-api-export-barrels/check.ts +0 -73
- package/catalog/rules/public-api-export-barrels/config.json +0 -4
- package/catalog/rules/public-api-export-barrels/manifest.json +0 -38
- package/catalog/rules/route-tree-fresh/SKILL.md +0 -16
- package/catalog/rules/route-tree-fresh/check.ts +0 -66
- package/catalog/rules/route-tree-fresh/manifest.json +0 -33
- package/catalog/rules/strict-typescript/SKILL.md +0 -3
- package/catalog/rules/strict-typescript/check.ts +0 -119
- package/catalog/rules/strict-typescript/manifest.json +0 -33
- package/catalog/rules/supabase-contracts/SKILL.md +0 -3
- package/catalog/rules/supabase-contracts/check.ts +0 -172
- package/catalog/rules/supabase-contracts/manifest.json +0 -33
- package/catalog/rules/supabase-declarative-schema/SKILL.md +0 -30
- package/catalog/rules/supabase-declarative-schema/check.ts +0 -262
- package/catalog/rules/supabase-declarative-schema/config.json +0 -8
- package/catalog/rules/supabase-declarative-schema/manifest.json +0 -38
- package/catalog/rules/tanstack-form-rules/SKILL.md +0 -11
- package/catalog/rules/tanstack-form-rules/check.ts +0 -58
- package/catalog/rules/tanstack-form-rules/manifest.json +0 -33
- package/catalog/rules/unit-test-rules/SKILL.md +0 -55
- package/catalog/rules/unit-test-rules/check.ts +0 -132
- package/catalog/rules/unit-test-rules/config.json +0 -22
- package/catalog/rules/unit-test-rules/manifest.json +0 -38
- package/catalog/rules/unit-test-rules-convex/SKILL.md +0 -41
- package/catalog/rules/unit-test-rules-convex/check.ts +0 -418
- package/catalog/rules/unit-test-rules-convex/manifest.json +0 -33
- package/catalog/rules/unit-test-rules-supabase/SKILL.md +0 -40
- package/catalog/rules/unit-test-rules-supabase/check.ts +0 -492
- package/catalog/rules/unit-test-rules-supabase/manifest.json +0 -33
- package/catalog/rules/workstation-controller-rules/SKILL.md +0 -22
- package/catalog/rules/workstation-controller-rules/check.ts +0 -108
- package/catalog/rules/workstation-controller-rules/manifest.json +0 -33
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
const textEncoder = new TextEncoder();
|
|
3
|
-
|
|
4
|
-
function writeLine(message: string): void {
|
|
5
|
-
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function writeError(message: string): void {
|
|
9
|
-
runtime.stderr.writeSync(textEncoder.encode(`${message}\n`));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type ModuleSizeConfig = {
|
|
13
|
-
readonly maxFileLines?: number;
|
|
14
|
-
readonly maxComponentLines?: number;
|
|
15
|
-
readonly maxFunctionLines?: number;
|
|
16
|
-
readonly ignoredGlobs?: readonly string[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const root = runtime.cwd();
|
|
20
|
-
const config = await readConfig();
|
|
21
|
-
const maxFileLines = Number(config.maxFileLines ?? 260);
|
|
22
|
-
const maxComponentLines = Number(config.maxComponentLines ?? 180);
|
|
23
|
-
const maxFunctionLines = Number(config.maxFunctionLines ?? 80);
|
|
24
|
-
const ignored = [
|
|
25
|
-
"src/routeTree.gen.ts",
|
|
26
|
-
"src/__generated__/**",
|
|
27
|
-
"src/test/**",
|
|
28
|
-
"convex/_generated/**",
|
|
29
|
-
".agents/skills/**",
|
|
30
|
-
"code-templates/**",
|
|
31
|
-
"node_modules/**",
|
|
32
|
-
"dist/**",
|
|
33
|
-
"coverage/**",
|
|
34
|
-
...(config.ignoredGlobs ?? []),
|
|
35
|
-
];
|
|
36
|
-
const errors: string[] = [];
|
|
37
|
-
|
|
38
|
-
async function readConfig(): Promise<ModuleSizeConfig> {
|
|
39
|
-
try {
|
|
40
|
-
const parsed = JSON.parse(
|
|
41
|
-
await runtime.readTextFile(".agents/skills/module-size-rules/config.json"),
|
|
42
|
-
) as ModuleSizeConfig;
|
|
43
|
-
return parsed;
|
|
44
|
-
} catch {
|
|
45
|
-
return {};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function toRelative(path: string): string {
|
|
50
|
-
return path.replace(`${root}/`, "").split("\\").join("/");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function matchesGlobish(rel: string, pattern: string): boolean {
|
|
54
|
-
const normalized = pattern.replaceAll("\\", "/");
|
|
55
|
-
if (normalized.endsWith("/**")) {
|
|
56
|
-
const prefix = normalized.slice(0, -3);
|
|
57
|
-
return rel === prefix || rel.startsWith(`${prefix}/`);
|
|
58
|
-
}
|
|
59
|
-
if (normalized.startsWith("**/")) {
|
|
60
|
-
const suffix = normalized.slice(3);
|
|
61
|
-
return rel === suffix || rel.endsWith(`/${suffix}`);
|
|
62
|
-
}
|
|
63
|
-
return rel === normalized || rel.endsWith(normalized);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function shouldIgnore(rel: string): boolean {
|
|
67
|
-
return (
|
|
68
|
-
ignored.some((item) => matchesGlobish(rel, item)) ||
|
|
69
|
-
rel.endsWith(".config.ts") ||
|
|
70
|
-
rel.endsWith(".config.mjs") ||
|
|
71
|
-
rel.endsWith(".test.ts") ||
|
|
72
|
-
rel.endsWith(".test.tsx") ||
|
|
73
|
-
rel.endsWith(".stories.tsx") ||
|
|
74
|
-
rel.endsWith(".generated.ts") ||
|
|
75
|
-
rel.endsWith(".generated.tsx")
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function functionLineViolations(rel: string, text: string): string[] {
|
|
80
|
-
const lines = text.split(/\r?\n/u);
|
|
81
|
-
const violations: string[] = [];
|
|
82
|
-
const startPattern =
|
|
83
|
-
/^\s*(?:export\s+)?(?:async\s+)?function\s+[A-Za-z0-9_$]+\s*\(|^\s*(?:const|let|var)\s+[A-Za-z0-9_$]+\s*=\s*(?:async\s*)?\([^)]*\)\s*=>\s*\{/u;
|
|
84
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
85
|
-
const line = lines[index] ?? "";
|
|
86
|
-
if (!startPattern.test(line)) continue;
|
|
87
|
-
let depth = 0;
|
|
88
|
-
let sawBrace = false;
|
|
89
|
-
for (let cursor = index; cursor < lines.length; cursor += 1) {
|
|
90
|
-
for (const char of lines[cursor] ?? "") {
|
|
91
|
-
if (char === "{") {
|
|
92
|
-
depth += 1;
|
|
93
|
-
sawBrace = true;
|
|
94
|
-
}
|
|
95
|
-
if (char === "}") depth -= 1;
|
|
96
|
-
}
|
|
97
|
-
if (sawBrace && depth <= 0) {
|
|
98
|
-
const length = cursor - index + 1;
|
|
99
|
-
if (length > maxFunctionLines) {
|
|
100
|
-
violations.push(
|
|
101
|
-
`${rel}:${
|
|
102
|
-
index + 1
|
|
103
|
-
} function has ${length} lines, exceeds limit ${maxFunctionLines}. Split responsibilities.`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
index = cursor;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return violations;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async function walk(dir: string): Promise<void> {
|
|
115
|
-
try {
|
|
116
|
-
for await (const ent of runtime.readDir(dir)) {
|
|
117
|
-
const p = `${dir}/${ent.name}`;
|
|
118
|
-
if (ent.isDirectory) {
|
|
119
|
-
if (!["node_modules", ".git", "dist", "coverage", "code-templates"].includes(ent.name)) {
|
|
120
|
-
await walk(p);
|
|
121
|
-
}
|
|
122
|
-
} else if (/\.(ts|tsx)$/u.test(ent.name)) {
|
|
123
|
-
const rel = toRelative(p);
|
|
124
|
-
if (shouldIgnore(rel)) continue;
|
|
125
|
-
const text = await runtime.readTextFile(p);
|
|
126
|
-
const lines = text.split(/\r?\n/u).length;
|
|
127
|
-
const limit = rel.endsWith(".tsx") ? maxComponentLines : maxFileLines;
|
|
128
|
-
if (lines > limit) {
|
|
129
|
-
errors.push(`${rel}: ${lines} lines exceeds limit ${limit}. Split responsibilities.`);
|
|
130
|
-
}
|
|
131
|
-
errors.push(...functionLineViolations(rel, text));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
} catch (error) {
|
|
135
|
-
if (!(error instanceof runtime.errors.NotFound)) throw error;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
await walk(`${root}/src`);
|
|
140
|
-
await walk(`${root}/convex`);
|
|
141
|
-
await walk(`${root}/.agents/skills`);
|
|
142
|
-
if (errors.length > 0) {
|
|
143
|
-
writeError(errors.join("\n"));
|
|
144
|
-
runtime.exit(1);
|
|
145
|
-
}
|
|
146
|
-
writeLine("module-size-rules ok");
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "module-size-rules-convex",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.4",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/module-size-rules/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/module-size-rules/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "scaffold",
|
|
21
|
-
"path": ".agents/skills/module-size-rules/config.json",
|
|
22
|
-
"source": "config.json"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"kind": "shared-markdown-section",
|
|
26
|
-
"path": "AGENTS.md",
|
|
27
|
-
"heading": "## Specdest backend rule: module-size-rules",
|
|
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
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"obsolete": [],
|
|
32
|
-
"check": {
|
|
33
|
-
"command": [
|
|
34
|
-
"node",
|
|
35
|
-
".agents/skills/module-size-rules/check.ts"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
const textEncoder = new TextEncoder();
|
|
3
|
-
|
|
4
|
-
function writeLine(message: string): void {
|
|
5
|
-
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function writeError(message: string): void {
|
|
9
|
-
runtime.stderr.writeSync(textEncoder.encode(`${message}\n`));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type ModuleSizeConfig = {
|
|
13
|
-
readonly maxFileLines?: number;
|
|
14
|
-
readonly maxComponentLines?: number;
|
|
15
|
-
readonly maxFunctionLines?: number;
|
|
16
|
-
readonly ignoredGlobs?: readonly string[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const root = runtime.cwd();
|
|
20
|
-
const config = await readConfig();
|
|
21
|
-
const maxFileLines = Number(config.maxFileLines ?? 260);
|
|
22
|
-
const maxComponentLines = Number(config.maxComponentLines ?? 180);
|
|
23
|
-
const maxFunctionLines = Number(config.maxFunctionLines ?? 80);
|
|
24
|
-
const ignored = [
|
|
25
|
-
"src/routeTree.gen.ts",
|
|
26
|
-
"src/__generated__/**",
|
|
27
|
-
"src/test/**",
|
|
28
|
-
"src/components/ui/**",
|
|
29
|
-
"supabase/**",
|
|
30
|
-
".agents/skills/**",
|
|
31
|
-
"code-templates/**",
|
|
32
|
-
"node_modules/**",
|
|
33
|
-
"dist/**",
|
|
34
|
-
"coverage/**",
|
|
35
|
-
...(config.ignoredGlobs ?? []),
|
|
36
|
-
];
|
|
37
|
-
const errors: string[] = [];
|
|
38
|
-
|
|
39
|
-
async function readConfig(): Promise<ModuleSizeConfig> {
|
|
40
|
-
try {
|
|
41
|
-
const parsed = JSON.parse(
|
|
42
|
-
await runtime.readTextFile(".agents/skills/module-size-rules/config.json"),
|
|
43
|
-
) as ModuleSizeConfig;
|
|
44
|
-
return parsed;
|
|
45
|
-
} catch {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function toRelative(path: string): string {
|
|
51
|
-
return path.replace(`${root}/`, "").split("\\").join("/");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function matchesGlobish(rel: string, pattern: string): boolean {
|
|
55
|
-
const normalized = pattern.replaceAll("\\", "/");
|
|
56
|
-
if (normalized.endsWith("/**")) {
|
|
57
|
-
const prefix = normalized.slice(0, -3);
|
|
58
|
-
return rel === prefix || rel.startsWith(`${prefix}/`);
|
|
59
|
-
}
|
|
60
|
-
if (normalized.startsWith("**/")) {
|
|
61
|
-
const suffix = normalized.slice(3);
|
|
62
|
-
return rel === suffix || rel.endsWith(`/${suffix}`);
|
|
63
|
-
}
|
|
64
|
-
return rel === normalized || rel.endsWith(normalized);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function shouldIgnore(rel: string): boolean {
|
|
68
|
-
return (
|
|
69
|
-
ignored.some((item) => matchesGlobish(rel, item)) ||
|
|
70
|
-
rel.endsWith(".config.ts") ||
|
|
71
|
-
rel.endsWith(".config.mjs") ||
|
|
72
|
-
rel.endsWith(".test.ts") ||
|
|
73
|
-
rel.endsWith(".test.tsx") ||
|
|
74
|
-
rel.endsWith(".stories.tsx") ||
|
|
75
|
-
rel.endsWith(".generated.ts") ||
|
|
76
|
-
rel.endsWith(".generated.tsx")
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function functionLineViolations(rel: string, text: string): string[] {
|
|
81
|
-
const lines = text.split(/\r?\n/u);
|
|
82
|
-
const violations: string[] = [];
|
|
83
|
-
const startPattern =
|
|
84
|
-
/^\s*(?:export\s+)?(?:async\s+)?function\s+[A-Za-z0-9_$]+\s*\(|^\s*(?:const|let|var)\s+[A-Za-z0-9_$]+\s*=\s*(?:async\s*)?\([^)]*\)\s*=>\s*\{/u;
|
|
85
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
86
|
-
const line = lines[index] ?? "";
|
|
87
|
-
if (!startPattern.test(line)) continue;
|
|
88
|
-
let depth = 0;
|
|
89
|
-
let sawBrace = false;
|
|
90
|
-
for (let cursor = index; cursor < lines.length; cursor += 1) {
|
|
91
|
-
for (const char of lines[cursor] ?? "") {
|
|
92
|
-
if (char === "{") {
|
|
93
|
-
depth += 1;
|
|
94
|
-
sawBrace = true;
|
|
95
|
-
}
|
|
96
|
-
if (char === "}") depth -= 1;
|
|
97
|
-
}
|
|
98
|
-
if (sawBrace && depth <= 0) {
|
|
99
|
-
const length = cursor - index + 1;
|
|
100
|
-
if (length > maxFunctionLines) {
|
|
101
|
-
violations.push(
|
|
102
|
-
`${rel}:${
|
|
103
|
-
index + 1
|
|
104
|
-
} function has ${length} lines, exceeds limit ${maxFunctionLines}. Split responsibilities.`,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
index = cursor;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return violations;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function walk(dir: string): Promise<void> {
|
|
116
|
-
try {
|
|
117
|
-
for await (const ent of runtime.readDir(dir)) {
|
|
118
|
-
const p = `${dir}/${ent.name}`;
|
|
119
|
-
if (ent.isDirectory) {
|
|
120
|
-
if (!["node_modules", ".git", "dist", "coverage", "code-templates"].includes(ent.name)) {
|
|
121
|
-
await walk(p);
|
|
122
|
-
}
|
|
123
|
-
} else if (/\.(ts|tsx)$/u.test(ent.name)) {
|
|
124
|
-
const rel = toRelative(p);
|
|
125
|
-
if (shouldIgnore(rel)) continue;
|
|
126
|
-
const text = await runtime.readTextFile(p);
|
|
127
|
-
const lines = text.split(/\r?\n/u).length;
|
|
128
|
-
const limit = rel.endsWith(".tsx") ? maxComponentLines : maxFileLines;
|
|
129
|
-
if (lines > limit) {
|
|
130
|
-
errors.push(`${rel}: ${lines} lines exceeds limit ${limit}. Split responsibilities.`);
|
|
131
|
-
}
|
|
132
|
-
errors.push(...functionLineViolations(rel, text));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
} catch (error) {
|
|
136
|
-
if (!(error instanceof runtime.errors.NotFound)) throw error;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
await walk(`${root}/src`);
|
|
141
|
-
await walk(`${root}/.agents/skills`);
|
|
142
|
-
if (errors.length > 0) {
|
|
143
|
-
writeError(errors.join("\n"));
|
|
144
|
-
runtime.exit(1);
|
|
145
|
-
}
|
|
146
|
-
writeLine("module-size-rules ok");
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "module-size-rules-supabase",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.4",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/module-size-rules/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/module-size-rules/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "scaffold",
|
|
21
|
-
"path": ".agents/skills/module-size-rules/config.json",
|
|
22
|
-
"source": "config.json"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"kind": "shared-markdown-section",
|
|
26
|
-
"path": "AGENTS.md",
|
|
27
|
-
"heading": "## Specdest backend rule: module-size-rules",
|
|
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
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"obsolete": [],
|
|
32
|
-
"check": {
|
|
33
|
-
"command": [
|
|
34
|
-
"node",
|
|
35
|
-
".agents/skills/module-size-rules/check.ts"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: mutation-command-rules
|
|
3
|
-
description: Rules for safe presentation-to-mutation command boundaries and stateful UI persistence.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Mutation command rules
|
|
7
|
-
|
|
8
|
-
- Query/read DTOs and persisted entities must never be passed directly to a mutation.
|
|
9
|
-
- Mutations fed from read models must construct explicit write commands containing only accepted fields.
|
|
10
|
-
- Runtime validation must execute at presentation mutation boundaries; TypeScript structural compatibility is not a runtime contract.
|
|
11
|
-
- Persistence-only fields such as ownership ids and server timestamps must not cross back unless explicitly owned by the mutation.
|
|
12
|
-
- Stateful UI libraries emit programmatic, initialization, responsive, and user events; persist only events proven to represent user intent.
|
|
13
|
-
- Automatic responsive layout changes must not overwrite canonical persisted layout unless explicitly designed to do so.
|
|
14
|
-
- Prefer drag/resize completion events over generic change events when available.
|
|
15
|
-
- Critical boundaries in `config.json` must satisfy required markers and reject configured unsafe patterns.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
import { assertSchemaVersion, readSkillConfig } from "../shared/config.ts";
|
|
3
|
-
import { exists } from "../shared/fs.ts";
|
|
4
|
-
|
|
5
|
-
type Boundary = { file: string; requiredMarkers?: string[]; forbiddenPatterns?: string[] };
|
|
6
|
-
type Config = { schemaVersion: number; boundaries: Boundary[] };
|
|
7
|
-
const { config, root } = await readSkillConfig<Config>(import.meta.url);
|
|
8
|
-
assertSchemaVersion(config.schemaVersion);
|
|
9
|
-
const violations: string[] = [];
|
|
10
|
-
for (const boundary of config.boundaries) {
|
|
11
|
-
const path = `${root}/${boundary.file}`;
|
|
12
|
-
if (!(await exists(path))) {
|
|
13
|
-
violations.push(`${boundary.file}: configured mutation boundary is missing`);
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
const text = await runtime.readTextFile(path);
|
|
17
|
-
for (const marker of boundary.requiredMarkers ?? [])
|
|
18
|
-
if (!text.includes(marker))
|
|
19
|
-
violations.push(
|
|
20
|
-
`${boundary.file}: missing required mutation-boundary marker ${JSON.stringify(marker)}`,
|
|
21
|
-
);
|
|
22
|
-
for (const pattern of boundary.forbiddenPatterns ?? [])
|
|
23
|
-
if (text.includes(pattern))
|
|
24
|
-
violations.push(
|
|
25
|
-
`${boundary.file}: contains unsafe mutation-boundary pattern ${JSON.stringify(pattern)}`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
console.log(`# mutation command rule violations: ${violations.length}`);
|
|
29
|
-
for (const violation of violations) console.log(`- ${violation}`);
|
|
30
|
-
if (violations.length > 0) runtime.exit(1);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": 1,
|
|
3
|
-
"boundaries": [
|
|
4
|
-
{
|
|
5
|
-
"file": "src/routes/dashboard/-components/data-hooks/useDashboard.ts",
|
|
6
|
-
"requiredMarkers": ["dashboardWidgetSaveCommandSchema.parse"],
|
|
7
|
-
"forbiddenPatterns": ["saveMutation({ sessionToken, boardSlug, widget })"]
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"file": "src/routes/dashboard/-components/ui/DashboardGrid.tsx",
|
|
11
|
-
"requiredMarkers": [
|
|
12
|
-
"toDashboardWidgetSaveCommand",
|
|
13
|
-
"grid.on(\"dragstop\"",
|
|
14
|
-
"grid.on(\"resizestop\""
|
|
15
|
-
],
|
|
16
|
-
"forbiddenPatterns": ["grid.on(\"change\""]
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "mutation-command-rules",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.1",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/mutation-command-rules/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/mutation-command-rules/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "managed-file",
|
|
21
|
-
"path": ".agents/skills/mutation-command-rules/config.json",
|
|
22
|
-
"source": "config.json"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"kind": "shared-markdown-section",
|
|
26
|
-
"path": "AGENTS.md",
|
|
27
|
-
"heading": "## Specdest rule: mutation-command-rules",
|
|
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
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"obsolete": [],
|
|
32
|
-
"check": {
|
|
33
|
-
"command": [
|
|
34
|
-
"node",
|
|
35
|
-
".agents/skills/mutation-command-rules/check.ts"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: nearby-contracts
|
|
3
|
-
description: Rules and checker for keeping contracts near the code they validate.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Nearby contract files
|
|
7
|
-
|
|
8
|
-
Use this skill before adding, changing, or reviewing related rule-owned code.
|
|
9
|
-
|
|
10
|
-
Boundary-specific contracts such as `*.input.schema.ts`, `*.output.schema.ts`, `*.callbackInput.schema.ts`, and `*.contract.ts` must live beside the implementation they validate. Generic domain, form, and route/search schemas are not boundary contracts merely because they end in `*.schema.ts`.
|
|
11
|
-
|
|
12
|
-
## Check
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
node .agents/skills/nearby-contracts/check.ts
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Configuration lives in `./config.json` in this skill folder. Keep exceptions explicit and small.
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
const textEncoder = new TextEncoder();
|
|
3
|
-
|
|
4
|
-
function writeLine(message: string): void {
|
|
5
|
-
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
9
|
-
import path from "node:path";
|
|
10
|
-
|
|
11
|
-
type NearbyContractsConfig = {
|
|
12
|
-
readonly schemaVersion: number;
|
|
13
|
-
readonly contractSuffixes?: readonly string[];
|
|
14
|
-
readonly exclude?: readonly string[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const root = path.resolve(runtime.args[0] || runtime.cwd());
|
|
18
|
-
const skillDir = path.dirname(new URL(import.meta.url).pathname);
|
|
19
|
-
const configPath = path.join(skillDir, "config.json");
|
|
20
|
-
const config = readConfig(configPath);
|
|
21
|
-
const skipDirs = new Set([
|
|
22
|
-
".git",
|
|
23
|
-
"code-templates",
|
|
24
|
-
"node_modules",
|
|
25
|
-
"dist",
|
|
26
|
-
"build",
|
|
27
|
-
"coverage",
|
|
28
|
-
".next",
|
|
29
|
-
".turbo",
|
|
30
|
-
".vite",
|
|
31
|
-
]);
|
|
32
|
-
const contractSuffixes = Array.isArray(config.contractSuffixes)
|
|
33
|
-
? config.contractSuffixes.map(String)
|
|
34
|
-
: [".input.schema.ts", ".output.schema.ts", ".callbackInput.schema.ts", ".contract.ts"];
|
|
35
|
-
const excludePatterns = Array.isArray(config.exclude) ? config.exclude.map(String) : [];
|
|
36
|
-
|
|
37
|
-
function readConfig(filePath: string): NearbyContractsConfig {
|
|
38
|
-
if (!existsSync(filePath)) return { schemaVersion: 1 };
|
|
39
|
-
const parsed = JSON.parse(readFileSync(filePath, "utf8")) as NearbyContractsConfig;
|
|
40
|
-
if (parsed.schemaVersion !== 1) {
|
|
41
|
-
throw new Error(".agents/skills/nearby-contracts/config.json schemaVersion must be 1");
|
|
42
|
-
}
|
|
43
|
-
return parsed;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function toPosix(value: string): string {
|
|
47
|
-
return value.split(path.sep).join("/");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function rel(file: string): string {
|
|
51
|
-
return toPosix(path.relative(root, file));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function matchesConfiguredExclude(relativePath: string): boolean {
|
|
55
|
-
return excludePatterns.some((pattern) => {
|
|
56
|
-
const normalized = pattern.replaceAll("\\", "/");
|
|
57
|
-
if (normalized.startsWith("**/") && normalized.endsWith("/**")) {
|
|
58
|
-
const segment = normalized.slice(3, -3);
|
|
59
|
-
return relativePath === segment || relativePath.includes(`/${segment}/`);
|
|
60
|
-
}
|
|
61
|
-
if (normalized.endsWith("/**")) {
|
|
62
|
-
const prefix = normalized.slice(0, -3);
|
|
63
|
-
return relativePath === prefix || relativePath.startsWith(`${prefix}/`);
|
|
64
|
-
}
|
|
65
|
-
return relativePath === normalized;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function walk(dir: string, out: string[] = []): string[] {
|
|
70
|
-
if (!existsSync(dir)) return out;
|
|
71
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
72
|
-
const full = path.join(dir, entry.name);
|
|
73
|
-
const relative = rel(full);
|
|
74
|
-
if (entry.isDirectory()) {
|
|
75
|
-
if (!skipDirs.has(entry.name) && !matchesConfiguredExclude(relative)) {
|
|
76
|
-
walk(full, out);
|
|
77
|
-
}
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (!matchesConfiguredExclude(relative)) out.push(full);
|
|
81
|
-
}
|
|
82
|
-
return out;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function isCode(file: string): boolean {
|
|
86
|
-
return /\.[cm]?[jt]sx?$/u.test(file);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function implementationBaseForContract(file: string, relativePath: string): string | null {
|
|
90
|
-
if (!contractSuffixes.some((suffix) => relativePath.endsWith(suffix))) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
return file
|
|
94
|
-
.replace(/\.(input|output|form|callbackInput)\.schema\.ts$/u, "")
|
|
95
|
-
.replace(/\.(schema|contract)\.[^.]+$/u, "");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function hasImplementationFor(base: string): boolean {
|
|
99
|
-
return [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"].some((suffix) =>
|
|
100
|
-
existsSync(`${base}${suffix}`),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function hasSameDirectoryConsumer(file: string): boolean {
|
|
105
|
-
const directory = path.dirname(file);
|
|
106
|
-
const importBase = `./${path.basename(file).replace(/\.[^.]+$/u, "")}`;
|
|
107
|
-
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
108
|
-
if (!entry.isFile()) continue;
|
|
109
|
-
const candidate = path.join(directory, entry.name);
|
|
110
|
-
if (candidate === file || !isCode(candidate)) continue;
|
|
111
|
-
const text = readFileSync(candidate, "utf8");
|
|
112
|
-
if (text.includes(`from '${importBase}'`) || text.includes(`from "${importBase}"`)) return true;
|
|
113
|
-
}
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const violations: string[] = [];
|
|
118
|
-
const files = walk(root)
|
|
119
|
-
.filter(isCode)
|
|
120
|
-
.filter((file) => !rel(file).startsWith(".agents/skills/"));
|
|
121
|
-
|
|
122
|
-
for (const file of files) {
|
|
123
|
-
const relative = rel(file);
|
|
124
|
-
const implementationBase = implementationBaseForContract(file, relative);
|
|
125
|
-
if (
|
|
126
|
-
implementationBase &&
|
|
127
|
-
!hasImplementationFor(implementationBase) &&
|
|
128
|
-
!hasSameDirectoryConsumer(file)
|
|
129
|
-
) {
|
|
130
|
-
violations.push(`${relative}: contract file must live beside its implementation file`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (violations.length) {
|
|
135
|
-
writeLine(violations.join("\n"));
|
|
136
|
-
runtime.exit(1);
|
|
137
|
-
}
|
|
138
|
-
writeLine("nearby-contracts ok");
|