vigiles 2.0.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/.claude/settings.json +46 -0
- package/.claude/settings.local.json +8 -0
- package/.claude-plugin/hooks/post-edit.sh +34 -0
- package/.claude-plugin/hooks/pre-edit.sh +40 -0
- package/.claude-plugin/hooks/session-start.sh +38 -0
- package/.claude-plugin/marketplace.json +14 -0
- package/.claude-plugin/plugin.json +47 -0
- package/.github/workflows/ci.yml +81 -0
- package/.prettierignore +1 -0
- package/.vigiles/generated.d.ts +205 -0
- package/CLAUDE.md +95 -0
- package/CLAUDE.md.spec.ts +142 -0
- package/CONTRIBUTING.md +121 -0
- package/LICENSE +21 -0
- package/README.md +377 -0
- package/action.yml +25 -0
- package/dist/action.d.ts +7 -0
- package/dist/action.d.ts.map +1 -0
- package/dist/action.js +180 -0
- package/dist/action.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1267 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.test.d.ts +2 -0
- package/dist/cli.test.d.ts.map +1 -0
- package/dist/cli.test.js +650 -0
- package/dist/cli.test.js.map +1 -0
- package/dist/compile.d.ts +101 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +503 -0
- package/dist/compile.js.map +1 -0
- package/dist/evolve.d.ts +132 -0
- package/dist/evolve.d.ts.map +1 -0
- package/dist/evolve.js +599 -0
- package/dist/evolve.js.map +1 -0
- package/dist/freshness.d.ts +67 -0
- package/dist/freshness.d.ts.map +1 -0
- package/dist/freshness.js +244 -0
- package/dist/freshness.js.map +1 -0
- package/dist/freshness.test.d.ts +2 -0
- package/dist/freshness.test.d.ts.map +1 -0
- package/dist/freshness.test.js +356 -0
- package/dist/freshness.test.js.map +1 -0
- package/dist/generate-types.d.ts +34 -0
- package/dist/generate-types.d.ts.map +1 -0
- package/dist/generate-types.js +381 -0
- package/dist/generate-types.js.map +1 -0
- package/dist/inline.d.ts +58 -0
- package/dist/inline.d.ts.map +1 -0
- package/dist/inline.js +142 -0
- package/dist/inline.js.map +1 -0
- package/dist/inline.test.d.ts +5 -0
- package/dist/inline.test.d.ts.map +1 -0
- package/dist/inline.test.js +152 -0
- package/dist/inline.test.js.map +1 -0
- package/dist/linters.d.ts +38 -0
- package/dist/linters.d.ts.map +1 -0
- package/dist/linters.js +588 -0
- package/dist/linters.js.map +1 -0
- package/dist/proofs.d.ts +272 -0
- package/dist/proofs.d.ts.map +1 -0
- package/dist/proofs.js +622 -0
- package/dist/proofs.js.map +1 -0
- package/dist/proofs.test.d.ts +9 -0
- package/dist/proofs.test.d.ts.map +1 -0
- package/dist/proofs.test.js +952 -0
- package/dist/proofs.test.js.map +1 -0
- package/dist/spec.d.ts +258 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +113 -0
- package/dist/spec.js.map +1 -0
- package/dist/spec.test.d.ts +2 -0
- package/dist/spec.test.d.ts.map +1 -0
- package/dist/spec.test.js +1222 -0
- package/dist/spec.test.js.map +1 -0
- package/dist/types.d.ts +101 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +10 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +286 -0
- package/dist/validate.js.map +1 -0
- package/dist/validate.test.d.ts +2 -0
- package/dist/validate.test.d.ts.map +1 -0
- package/dist/validate.test.js +531 -0
- package/dist/validate.test.js.map +1 -0
- package/docs/agent-setup.md +85 -0
- package/docs/agent-workflows.md +103 -0
- package/docs/comparison.md +71 -0
- package/docs/freshness.md +124 -0
- package/docs/inline-mode.md +119 -0
- package/docs/linter-support.md +166 -0
- package/docs/spec-format.md +194 -0
- package/eslint.config.mjs +79 -0
- package/examples/CLAUDE.md +54 -0
- package/examples/CLAUDE.md.spec.ts +65 -0
- package/examples/SKILL.md +50 -0
- package/examples/SKILL.md.spec.ts +57 -0
- package/fixtures/example-project/CLAUDE.md +11 -0
- package/fixtures/example-project/package.json +9 -0
- package/fixtures/example-project/src/index.ts +3 -0
- package/fixtures/example-project/src/utils.test.ts +2 -0
- package/fixtures/example-project/src/utils.ts +3 -0
- package/logo.png +0 -0
- package/package.json +42 -0
- package/research/adoption-strategy.md +111 -0
- package/research/agent-integration.md +145 -0
- package/research/ai-code-quality.md +197 -0
- package/research/code-search-for-agents.md +313 -0
- package/research/competitive-landscape.md +163 -0
- package/research/doc-freshness.md +516 -0
- package/research/executable-specs.md +368 -0
- package/research/feature-ideas.md +464 -0
- package/research/formal-proofs-for-agents.md +338 -0
- package/research/fp-for-agent-harness.md +150 -0
- package/research/fp-for-deterministic-ai.md +131 -0
- package/research/self-evolving-specs.md +298 -0
- package/schemas/claude-md-strict.yml +18 -0
- package/schemas/claude-md.yml +6 -0
- package/schemas/skill-strict.yml +12 -0
- package/schemas/skill.yml +5 -0
- package/skills/audit-feedback-loop/SKILL.md +76 -0
- package/skills/edit-spec/SKILL.md +131 -0
- package/skills/enforce-rules-format/SKILL.md +71 -0
- package/skills/generate-logo/SKILL.md +102 -0
- package/skills/generate-rule/SKILL.md +90 -0
- package/skills/linter-docs/clippy.md +241 -0
- package/skills/linter-docs/eslint.md +384 -0
- package/skills/linter-docs/pylint.md +288 -0
- package/skills/linter-docs/rubocop.md +277 -0
- package/skills/linter-docs/ruff.md +187 -0
- package/skills/linter-docs/stylelint.md +247 -0
- package/skills/migrate-to-spec/SKILL.md +124 -0
- package/skills/pr-to-lint-rule/SKILL.md +97 -0
- package/skills/strengthen/SKILL.md +168 -0
- package/src/action.ts +214 -0
- package/src/cli.test.ts +914 -0
- package/src/cli.ts +1631 -0
- package/src/compile.ts +691 -0
- package/src/evolve.ts +781 -0
- package/src/freshness.test.ts +449 -0
- package/src/freshness.ts +299 -0
- package/src/generate-types.ts +448 -0
- package/src/inline.test.ts +206 -0
- package/src/inline.ts +164 -0
- package/src/linters.ts +739 -0
- package/src/proofs.test.ts +1314 -0
- package/src/proofs.ts +849 -0
- package/src/spec.test.ts +1471 -0
- package/src/spec.ts +427 -0
- package/src/types.ts +117 -0
- package/src/validate.test.ts +701 -0
- package/src/validate.ts +381 -0
- package/tsconfig.json +23 -0
package/src/action.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Action entry point for vigiles.
|
|
3
|
+
*
|
|
4
|
+
* Runs `compile` or `audit` depending on the action input.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { writeFileSync, existsSync } from "node:fs";
|
|
8
|
+
import { resolve } from "node:path";
|
|
9
|
+
import { spawnSync } from "node:child_process";
|
|
10
|
+
import { globSync } from "glob";
|
|
11
|
+
|
|
12
|
+
import { compileClaude, compileSkill, addHash } from "./compile.js";
|
|
13
|
+
import type { ClaudeSpec, SkillSpec } from "./spec.js";
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Read action inputs
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const command = process.env["INPUT_COMMAND"] ?? "audit";
|
|
20
|
+
const pathsInput = process.env["INPUT_PATHS"];
|
|
21
|
+
const maxRulesInput =
|
|
22
|
+
process.env["INPUT_MAX-RULES"] ?? process.env["INPUT_MAX_RULES"];
|
|
23
|
+
const catalogOnly =
|
|
24
|
+
(process.env["INPUT_CATALOG-ONLY"] ??
|
|
25
|
+
process.env["INPUT_CATALOG_ONLY"] ??
|
|
26
|
+
"false") === "true";
|
|
27
|
+
|
|
28
|
+
const maxRules = maxRulesInput ? Number(maxRulesInput) : undefined;
|
|
29
|
+
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Spec loading (from compiled dist/)
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
async function loadSpec(
|
|
35
|
+
specPath: string,
|
|
36
|
+
): Promise<ClaudeSpec | SkillSpec | null> {
|
|
37
|
+
// Try several resolution strategies:
|
|
38
|
+
// 1. Replace /src/ with /dist/ (standard TS project layout)
|
|
39
|
+
// 2. Look under dist/ directly (root-level specs like CLAUDE.md.spec.ts)
|
|
40
|
+
// 3. Use the .js extension in-place (pre-compiled specs)
|
|
41
|
+
const jsName = specPath.replace(/\.ts$/, ".js");
|
|
42
|
+
const candidates = [
|
|
43
|
+
resolve(process.cwd(), jsName.replace(/\/src\//, "/dist/")),
|
|
44
|
+
resolve(process.cwd(), "dist", jsName),
|
|
45
|
+
resolve(process.cwd(), jsName),
|
|
46
|
+
];
|
|
47
|
+
// Deduplicate (candidate 1 and 3 may match when there's no /src/)
|
|
48
|
+
const unique = [...new Set(candidates)];
|
|
49
|
+
|
|
50
|
+
for (const distPath of unique) {
|
|
51
|
+
if (!existsSync(distPath)) continue;
|
|
52
|
+
try {
|
|
53
|
+
const mod = (await import(distPath)) as {
|
|
54
|
+
default: ClaudeSpec | SkillSpec | { default: ClaudeSpec | SkillSpec };
|
|
55
|
+
};
|
|
56
|
+
// CJS modules (TypeScript with module: "Node16", no "type":
|
|
57
|
+
// "module") produce `exports["default"] = spec`, so dynamic
|
|
58
|
+
// import wraps it as `{ default: { default: spec } }`. Unwrap
|
|
59
|
+
// the double-default when present.
|
|
60
|
+
const raw = mod.default;
|
|
61
|
+
if (raw && typeof raw === "object" && "default" in raw) {
|
|
62
|
+
return (raw as { default: ClaudeSpec | SkillSpec }).default;
|
|
63
|
+
}
|
|
64
|
+
return raw;
|
|
65
|
+
} catch {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Commands
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
async function runCompile(): Promise<boolean> {
|
|
77
|
+
const specs = pathsInput
|
|
78
|
+
? pathsInput
|
|
79
|
+
.split(",")
|
|
80
|
+
.map((p) => p.trim())
|
|
81
|
+
.filter(Boolean)
|
|
82
|
+
: globSync("**/*.spec.ts", { ignore: ["node_modules/**", "dist/**"] });
|
|
83
|
+
|
|
84
|
+
if (specs.length === 0) {
|
|
85
|
+
console.log("No .spec.ts files found.");
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let allValid = true;
|
|
90
|
+
const basePath = process.cwd();
|
|
91
|
+
|
|
92
|
+
for (const specPath of specs) {
|
|
93
|
+
const spec = await loadSpec(specPath);
|
|
94
|
+
if (!spec) {
|
|
95
|
+
console.log(`::error file=${specPath}::Failed to load spec`);
|
|
96
|
+
allValid = false;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (spec._specType === "claude") {
|
|
101
|
+
const primaryOutput = specPath.replace(/\.spec\.ts$/, "");
|
|
102
|
+
const { markdown, errors, targets } = compileClaude(spec, {
|
|
103
|
+
basePath,
|
|
104
|
+
specFile: specPath,
|
|
105
|
+
maxRules,
|
|
106
|
+
catalogOnly,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (errors.length > 0) {
|
|
110
|
+
for (const err of errors) {
|
|
111
|
+
console.log(`::error file=${specPath}::${err.message}`);
|
|
112
|
+
}
|
|
113
|
+
allValid = false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Write primary target
|
|
117
|
+
writeFileSync(resolve(basePath, primaryOutput), markdown);
|
|
118
|
+
const outputNames = [primaryOutput];
|
|
119
|
+
|
|
120
|
+
// Write additional targets with swapped heading + recomputed hash
|
|
121
|
+
for (const t of targets.slice(1)) {
|
|
122
|
+
const body = markdown
|
|
123
|
+
.replace(/^<!-- vigiles:[^\n]+\n\n?/, "")
|
|
124
|
+
.replace(/^# [^\n]+/, `# ${t}`);
|
|
125
|
+
const additional = addHash(body, specPath);
|
|
126
|
+
const dir = primaryOutput.substring(
|
|
127
|
+
0,
|
|
128
|
+
primaryOutput.lastIndexOf("/") + 1,
|
|
129
|
+
);
|
|
130
|
+
const targetPath = dir + t;
|
|
131
|
+
writeFileSync(resolve(basePath, targetPath), additional);
|
|
132
|
+
outputNames.push(targetPath);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.log(`Compiled: ${specPath} → ${outputNames.join(", ")}`);
|
|
136
|
+
} else if (spec._specType === "skill") {
|
|
137
|
+
const outputPath = specPath.replace(/\.spec\.ts$/, "");
|
|
138
|
+
const { markdown, errors } = compileSkill(spec, {
|
|
139
|
+
basePath,
|
|
140
|
+
specFile: specPath,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
if (errors.length > 0) {
|
|
144
|
+
for (const err of errors) {
|
|
145
|
+
console.log(`::error file=${specPath}::${err.message}`);
|
|
146
|
+
}
|
|
147
|
+
allValid = false;
|
|
148
|
+
}
|
|
149
|
+
writeFileSync(resolve(basePath, outputPath), markdown);
|
|
150
|
+
console.log(`Compiled: ${specPath} → ${outputPath}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return allValid;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function runAudit(): boolean {
|
|
158
|
+
// Delegate to the CLI so the action always runs the full audit flow
|
|
159
|
+
// (hash verification, spec validation, duplicate detection, coverage
|
|
160
|
+
// report, strengthen suggestions). Previously this only ran
|
|
161
|
+
// checkFileHash, which silently skipped everything else.
|
|
162
|
+
const files = pathsInput
|
|
163
|
+
? pathsInput
|
|
164
|
+
.split(",")
|
|
165
|
+
.map((p) => p.trim())
|
|
166
|
+
.filter(Boolean)
|
|
167
|
+
: [];
|
|
168
|
+
|
|
169
|
+
const cliPath = resolve(__dirname, "cli.js");
|
|
170
|
+
const args = ["audit", ...files];
|
|
171
|
+
const result = spawnSync(process.execPath, [cliPath, ...args], {
|
|
172
|
+
stdio: "inherit",
|
|
173
|
+
env: {
|
|
174
|
+
...process.env,
|
|
175
|
+
// Ensure the CLI emits GitHub annotations during the action run
|
|
176
|
+
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS ?? "true",
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (result.error) {
|
|
181
|
+
console.log(
|
|
182
|
+
`::error::Failed to run vigiles audit: ${result.error.message}`,
|
|
183
|
+
);
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Exit codes: 0 clean, 1 warnings, 2 hard errors.
|
|
188
|
+
return result.status === 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
// Main
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
void (async () => {
|
|
196
|
+
let valid: boolean;
|
|
197
|
+
if (command === "compile") {
|
|
198
|
+
valid = await runCompile();
|
|
199
|
+
} else if (command === "audit") {
|
|
200
|
+
valid = runAudit();
|
|
201
|
+
} else {
|
|
202
|
+
console.log(
|
|
203
|
+
`::error::Unknown vigiles command "${command}". Valid commands: compile, audit.`,
|
|
204
|
+
);
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
console.log(`::set-output name=valid::${String(valid)}`);
|
|
209
|
+
|
|
210
|
+
if (!valid) {
|
|
211
|
+
console.log("::error::vigiles failed — see errors above");
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
})();
|