@specdest/devkit 0.2.2 → 0.3.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 +17 -18
- package/package.json +4 -4
- package/src/canonical-project-operations.js +164 -0
- package/src/canonical-project.js +78 -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 +478 -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,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");
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "nearby-contracts",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.3",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/nearby-contracts/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/nearby-contracts/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "managed-file",
|
|
21
|
-
"path": ".agents/skills/nearby-contracts/config.json",
|
|
22
|
-
"source": "config.json"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"kind": "shared-markdown-section",
|
|
26
|
-
"path": "AGENTS.md",
|
|
27
|
-
"heading": "## Specdest rule: nearby-contracts",
|
|
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
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"obsolete": [],
|
|
32
|
-
"check": {
|
|
33
|
-
"command": [
|
|
34
|
-
"node",
|
|
35
|
-
".agents/skills/nearby-contracts/check.ts"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
import { walk } from "../shared/fs.ts";
|
|
3
|
-
|
|
4
|
-
const allowedFiles = new Set(["src/components/ui/button.tsx"]);
|
|
5
|
-
const ignoredSuffixes = [".test.tsx", ".stories.tsx"];
|
|
6
|
-
|
|
7
|
-
function shouldCheck(file: string): boolean {
|
|
8
|
-
return (
|
|
9
|
-
file.startsWith("src/") &&
|
|
10
|
-
file.endsWith(".tsx") &&
|
|
11
|
-
!allowedFiles.has(file) &&
|
|
12
|
-
!ignoredSuffixes.some((suffix) => file.endsWith(suffix))
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const files = (await walk("src")).map((file) => `src/${file}`).filter(shouldCheck);
|
|
17
|
-
const violations: string[] = [];
|
|
18
|
-
|
|
19
|
-
for (const file of files) {
|
|
20
|
-
const text = await runtime.readTextFile(file);
|
|
21
|
-
const lines = text.split("\n");
|
|
22
|
-
lines.forEach((line, index) => {
|
|
23
|
-
if (/<button(\s|>|$)/.test(line)) {
|
|
24
|
-
violations.push(
|
|
25
|
-
`${file}:${index + 1}: raw <button> is forbidden; use Button or ConfirmButton`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (violations.length > 0) {
|
|
32
|
-
console.error(`# raw button violations: ${violations.length}`);
|
|
33
|
-
console.error(violations.join("\n"));
|
|
34
|
-
runtime.exit(1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log("no-raw-click-buttons ok");
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "no-raw-click-buttons",
|
|
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/no-raw-click-buttons/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/no-raw-click-buttons/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "shared-markdown-section",
|
|
21
|
-
"path": "AGENTS.md",
|
|
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 `node .agents/skills/no-raw-click-buttons/check.ts` before handoff."
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"obsolete": [],
|
|
27
|
-
"check": {
|
|
28
|
-
"command": [
|
|
29
|
-
"node",
|
|
30
|
-
".agents/skills/no-raw-click-buttons/check.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: public-api-export-barrels
|
|
3
|
-
description: Rules for approving and checking public API export barrel files.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Approved public API export barrels
|
|
7
|
-
|
|
8
|
-
Use this skill before adding, changing, or reviewing export barrel files.
|
|
9
|
-
|
|
10
|
-
## Rule
|
|
11
|
-
|
|
12
|
-
Barrel files are public API boundaries. Do not add `index.ts`, `index.tsx`, `index.js`, or `index.jsx` files that re-export modules unless the file is intentionally approved in project configuration.
|
|
13
|
-
|
|
14
|
-
## Approval config
|
|
15
|
-
|
|
16
|
-
Approved barrels live in `.agents/skills/public-api-export-barrels/config.json`:
|
|
17
|
-
|
|
18
|
-
```json
|
|
19
|
-
{
|
|
20
|
-
"schemaVersion": 1,
|
|
21
|
-
"allowedBarrels": ["src/features/user/index.ts"]
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Use project-relative POSIX paths. Keep the list small and intentional.
|
|
26
|
-
|
|
27
|
-
## Check
|
|
28
|
-
|
|
29
|
-
Run before handoff:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
nps lint
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Direct checker:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
node .agents/skills/public-api-export-barrels/check.ts
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Fix violations
|
|
42
|
-
|
|
43
|
-
- Prefer direct imports from the source module.
|
|
44
|
-
- Keep a barrel only when it is the documented public API for a package, feature, or boundary.
|
|
45
|
-
- Add the barrel path to `.agents/skills/public-api-export-barrels/config.json` only after the public API decision is explicit.
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
const textEncoder = new TextEncoder();
|
|
3
|
-
function writeLine(message: string): void {
|
|
4
|
-
runtime.stdout.writeSync(textEncoder.encode(`${message}\n`));
|
|
5
|
-
}
|
|
6
|
-
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
|
|
9
|
-
const root = path.resolve(runtime.args[0] || runtime.cwd());
|
|
10
|
-
const configFile = path.join(path.dirname(new URL(import.meta.url).pathname), "config.json");
|
|
11
|
-
const skip = new Set([".git", "code-templates", "node_modules", "dist", "build", "coverage"]);
|
|
12
|
-
|
|
13
|
-
function rel(file: string): string {
|
|
14
|
-
return path.relative(root, file).split(path.sep).join("/");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Config = { readonly schemaVersion: 1; readonly allowedBarrels: readonly string[] };
|
|
18
|
-
|
|
19
|
-
function readConfig(): Config {
|
|
20
|
-
if (!existsSync(configFile)) return { schemaVersion: 1, allowedBarrels: [] };
|
|
21
|
-
const config = JSON.parse(readFileSync(configFile, "utf8")) as {
|
|
22
|
-
schemaVersion?: unknown;
|
|
23
|
-
allowedBarrels?: unknown;
|
|
24
|
-
};
|
|
25
|
-
if (config.schemaVersion !== 1)
|
|
26
|
-
throw new Error(".agents/skills/public-api-export-barrels/config.json schemaVersion must be 1");
|
|
27
|
-
if (!Array.isArray(config.allowedBarrels))
|
|
28
|
-
throw new Error(
|
|
29
|
-
".agents/skills/public-api-export-barrels/config.json allowedBarrels must be an array",
|
|
30
|
-
);
|
|
31
|
-
return { schemaVersion: 1, allowedBarrels: config.allowedBarrels as string[] };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function walk(dir: string, out: string[] = []): string[] {
|
|
35
|
-
if (!existsSync(dir)) return out;
|
|
36
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
37
|
-
const full = path.join(dir, entry.name);
|
|
38
|
-
if (entry.isDirectory()) {
|
|
39
|
-
if (!skip.has(entry.name)) walk(full, out);
|
|
40
|
-
} else if (
|
|
41
|
-
[
|
|
42
|
-
"index.ts",
|
|
43
|
-
"index.tsx",
|
|
44
|
-
"index.js",
|
|
45
|
-
"index.jsx",
|
|
46
|
-
"index.mts",
|
|
47
|
-
"index.cts",
|
|
48
|
-
"index.mjs",
|
|
49
|
-
"index.cjs",
|
|
50
|
-
].includes(entry.name)
|
|
51
|
-
) {
|
|
52
|
-
out.push(full);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return out;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function hasReExport(file: string): boolean {
|
|
59
|
-
return readFileSync(file, "utf8")
|
|
60
|
-
.split("\n")
|
|
61
|
-
.some((line) => line.trim().startsWith("export *") || line.trim().startsWith("export {"));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const allowed = new Set(
|
|
65
|
-
readConfig().allowedBarrels.map((item: string) => item.replaceAll("\\", "/")),
|
|
66
|
-
);
|
|
67
|
-
const failures = walk(root)
|
|
68
|
-
.map(rel)
|
|
69
|
-
.filter((file) => hasReExport(path.join(root, file)) && !allowed.has(file));
|
|
70
|
-
|
|
71
|
-
writeLine(`# public API export barrel violations: ${failures.length}`);
|
|
72
|
-
for (const file of failures) writeLine(`- ${file}: unapproved export barrel`);
|
|
73
|
-
if (failures.length > 0) throw new Error("Unapproved export barrels found");
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "public-api-export-barrels",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.2",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/public-api-export-barrels/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/public-api-export-barrels/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "scaffold",
|
|
21
|
-
"path": ".agents/skills/public-api-export-barrels/config.json",
|
|
22
|
-
"source": "config.json"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"kind": "shared-markdown-section",
|
|
26
|
-
"path": "AGENTS.md",
|
|
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 `node .agents/skills/public-api-export-barrels/check.ts` before handoff."
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"obsolete": [],
|
|
32
|
-
"check": {
|
|
33
|
-
"command": [
|
|
34
|
-
"node",
|
|
35
|
-
".agents/skills/public-api-export-barrels/check.ts"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Route tree freshness
|
|
2
|
-
|
|
3
|
-
Use this skill when adding, removing, or renaming TanStack Router route files.
|
|
4
|
-
|
|
5
|
-
## Rules
|
|
6
|
-
|
|
7
|
-
- `src/routeTree.gen.ts` must exist.
|
|
8
|
-
- Every route file that calls `createFileRoute("...")` must have its route id
|
|
9
|
-
present in `src/routeTree.gen.ts`.
|
|
10
|
-
- Regenerate the route tree after changing `src/routes/**`.
|
|
11
|
-
|
|
12
|
-
## Script wiring
|
|
13
|
-
|
|
14
|
-
Run `nps lint.routeTreeFresh` for this checker directly. It is also part of
|
|
15
|
-
`nps lint.raw`, so `nps lint`, `nps check`, and the generated Husky pre-commit
|
|
16
|
-
hook enforce this rule.
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { runtime } from "../shared/runtime.ts";
|
|
2
|
-
// oxlint-disable no-console no-await-in-loop
|
|
3
|
-
const decoder = new TextDecoder();
|
|
4
|
-
const violations: string[] = [];
|
|
5
|
-
|
|
6
|
-
async function exists(path: string): Promise<boolean> {
|
|
7
|
-
try {
|
|
8
|
-
await runtime.stat(path);
|
|
9
|
-
return true;
|
|
10
|
-
} catch {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function* walk(dir: string): AsyncGenerator<string> {
|
|
16
|
-
try {
|
|
17
|
-
for await (const entry of runtime.readDir(dir)) {
|
|
18
|
-
const path = `${dir}/${entry.name}`;
|
|
19
|
-
if (entry.isDirectory) yield* walk(path);
|
|
20
|
-
if (entry.isFile && /\.tsx?$/.test(entry.name)) yield path;
|
|
21
|
-
}
|
|
22
|
-
} catch {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const usesTanstackFileRoutes =
|
|
28
|
-
(await exists("src/routes")) || (await exists("src/routeTree.gen.ts"));
|
|
29
|
-
|
|
30
|
-
if (!usesTanstackFileRoutes) {
|
|
31
|
-
console.log("route-tree-fresh not applicable");
|
|
32
|
-
runtime.exit(0);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!(await exists("src/routeTree.gen.ts"))) {
|
|
36
|
-
violations.push("missing generated route tree: src/routeTree.gen.ts");
|
|
37
|
-
} else {
|
|
38
|
-
const routeTree = decoder.decode(await runtime.readFile("src/routeTree.gen.ts"));
|
|
39
|
-
|
|
40
|
-
for await (const file of walk("src/routes")) {
|
|
41
|
-
if (file.includes("/-components/")) continue;
|
|
42
|
-
if (!file.endsWith(".tsx")) continue;
|
|
43
|
-
|
|
44
|
-
const text = decoder.decode(await runtime.readFile(file));
|
|
45
|
-
const match = text.match(/createFileRoute\(["']([^"']+)["']\)/u);
|
|
46
|
-
if (!match) continue;
|
|
47
|
-
|
|
48
|
-
const routeId = match[1];
|
|
49
|
-
const routeIdPattern = new RegExp(escapeRegExp(routeId), "u");
|
|
50
|
-
if (!routeIdPattern.test(routeTree)) {
|
|
51
|
-
violations.push(
|
|
52
|
-
`${file}: route id ${routeId} is missing from src/routeTree.gen.ts; regenerate routes`,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (violations.length) {
|
|
59
|
-
console.error(violations.join("\n"));
|
|
60
|
-
runtime.exit(1);
|
|
61
|
-
}
|
|
62
|
-
console.log("route-tree-fresh ok");
|
|
63
|
-
|
|
64
|
-
function escapeRegExp(value: string): string {
|
|
65
|
-
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
66
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "route-tree-fresh",
|
|
3
|
-
"kind": "rule",
|
|
4
|
-
"version": "1.0.2",
|
|
5
|
-
"requires": [
|
|
6
|
-
"checker-runtime"
|
|
7
|
-
],
|
|
8
|
-
"artifacts": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "managed-file",
|
|
11
|
-
"path": ".agents/skills/route-tree-fresh/SKILL.md",
|
|
12
|
-
"source": "SKILL.md"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "managed-file",
|
|
16
|
-
"path": ".agents/skills/route-tree-fresh/check.ts",
|
|
17
|
-
"source": "check.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"kind": "shared-markdown-section",
|
|
21
|
-
"path": "AGENTS.md",
|
|
22
|
-
"heading": "## Specdest rule: route-tree-fresh",
|
|
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
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"obsolete": [],
|
|
27
|
-
"check": {
|
|
28
|
-
"command": [
|
|
29
|
-
"node",
|
|
30
|
-
".agents/skills/route-tree-fresh/check.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|