mova-claude-import 0.1.1 → 0.1.2
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 +68 -4
- package/control_surface_exclusions_v0.json +8 -0
- package/dist/anthropic_profile_v0.d.ts +1 -1
- package/dist/anthropic_profile_v0.js +1 -0
- package/dist/cli.js +206 -23
- package/dist/control_apply_v0.d.ts +5 -1
- package/dist/control_apply_v0.js +125 -8
- package/dist/control_check_v0.d.ts +1 -0
- package/dist/control_check_v0.js +194 -23
- package/dist/control_prefill_v0.js +128 -9
- package/dist/control_surface_coverage_v0.d.ts +22 -0
- package/dist/control_surface_coverage_v0.js +128 -0
- package/dist/control_v0.d.ts +149 -0
- package/dist/control_v0.js +360 -0
- package/dist/control_v0_schema.d.ts +6 -0
- package/dist/control_v0_schema.js +19 -0
- package/dist/init_v0.d.ts +6 -1
- package/dist/init_v0.js +41 -1
- package/dist/observability_writer_v0.d.ts +1 -0
- package/dist/observability_writer_v0.js +157 -0
- package/dist/observe_v0.d.ts +8 -0
- package/dist/observe_v0.js +57 -0
- package/dist/presets_v0.d.ts +11 -0
- package/dist/presets_v0.js +49 -0
- package/dist/redaction.js +5 -1
- package/dist/run_import.js +111 -26
- package/docs/CLAUDE_CONTROL_SURFACE_MAP_v0.md +78 -0
- package/docs/OPERATOR_GUIDE_v0.md +11 -0
- package/fixtures/pos/basic/mova/control_v0.json +93 -0
- package/fixtures/pos/claude_code_demo_full/.claude/agents/code-reviewer.md +13 -0
- package/fixtures/pos/claude_code_demo_full/.claude/agents/github-workflow.md +10 -0
- package/fixtures/pos/claude_code_demo_full/.claude/commands/code-quality.md +8 -0
- package/fixtures/pos/claude_code_demo_full/.claude/commands/docs-sync.md +8 -0
- package/fixtures/pos/claude_code_demo_full/.claude/commands/onboard.md +8 -0
- package/fixtures/pos/claude_code_demo_full/.claude/commands/pr-review.md +10 -0
- package/fixtures/pos/claude_code_demo_full/.claude/commands/pr-summary.md +8 -0
- package/fixtures/pos/claude_code_demo_full/.claude/commands/ticket.md +10 -0
- package/fixtures/pos/claude_code_demo_full/.claude/hooks/skill-eval.js +13 -0
- package/fixtures/pos/claude_code_demo_full/.claude/hooks/skill-eval.sh +15 -0
- package/fixtures/pos/claude_code_demo_full/.claude/hooks/skill-rules.json +21 -0
- package/fixtures/pos/claude_code_demo_full/.claude/hooks/skill-rules.schema.json +24 -0
- package/fixtures/pos/claude_code_demo_full/.claude/rules/code-style.md +5 -0
- package/fixtures/pos/claude_code_demo_full/.claude/rules/security.md +5 -0
- package/fixtures/pos/claude_code_demo_full/.claude/settings.json +102 -0
- package/fixtures/pos/claude_code_demo_full/.claude/settings.md +6 -0
- package/fixtures/pos/claude_code_demo_full/.claude/skills/core-components/SKILL.md +9 -0
- package/fixtures/pos/claude_code_demo_full/.claude/skills/formik-patterns/SKILL.md +9 -0
- package/fixtures/pos/claude_code_demo_full/.claude/skills/graphql-schema/SKILL.md +10 -0
- package/fixtures/pos/claude_code_demo_full/.claude/skills/react-ui-patterns/SKILL.md +10 -0
- package/fixtures/pos/claude_code_demo_full/.claude/skills/systematic-debugging/SKILL.md +9 -0
- package/fixtures/pos/claude_code_demo_full/.claude/skills/testing-patterns/SKILL.md +10 -0
- package/fixtures/pos/claude_code_demo_full/.github/workflows/pr-claude-code-review.yml +14 -0
- package/fixtures/pos/claude_code_demo_full/.github/workflows/scheduled-claude-code-dependency-audit.yml +14 -0
- package/fixtures/pos/claude_code_demo_full/.github/workflows/scheduled-claude-code-docs-sync.yml +14 -0
- package/fixtures/pos/claude_code_demo_full/.github/workflows/scheduled-claude-code-quality.yml +14 -0
- package/fixtures/pos/claude_code_demo_full/.mcp.json +44 -0
- package/fixtures/pos/claude_code_demo_full/CLAUDE.md +28 -0
- package/fixtures/pos/control_basic_project/mova/control_v0.json +93 -0
- package/fixtures/pos/observability_basic/CLAUDE.md +3 -0
- package/{.tmp_test_zip/out1 → fixtures/pos/preset_safe_observable_v0}/.mcp.json +3 -3
- package/fixtures/pos/preset_safe_observable_v0/CLAUDE.md +3 -0
- package/package.json +2 -1
- package/presets/safe_observable_v0/assets/.claude/agents/code-reviewer.md +9 -0
- package/presets/safe_observable_v0/assets/.claude/commands/finish.md +9 -0
- package/presets/safe_observable_v0/assets/.claude/commands/start.md +9 -0
- package/presets/safe_observable_v0/assets/.claude/hooks/skill-eval.js +15 -0
- package/presets/safe_observable_v0/assets/.claude/hooks/skill-eval.sh +17 -0
- package/presets/safe_observable_v0/assets/.claude/hooks/skill-rules.json +26 -0
- package/presets/safe_observable_v0/assets/.claude/rules/code-style.md +6 -0
- package/presets/safe_observable_v0/assets/.claude/rules/security.md +6 -0
- package/presets/safe_observable_v0/assets/.claude/skills/git-workflow/SKILL.md +9 -0
- package/presets/safe_observable_v0/assets/.claude/skills/security-basics/SKILL.md +9 -0
- package/presets/safe_observable_v0/assets/.claude/skills/systematic-debugging/SKILL.md +9 -0
- package/presets/safe_observable_v0/assets/.claude/skills/testing-patterns/SKILL.md +9 -0
- package/presets/safe_observable_v0/control_v0.json +214 -0
- package/schemas/mova.control_v0.schema.json +252 -0
- package/src/anthropic_profile_v0.ts +1 -0
- package/src/cli.ts +194 -23
- package/src/control_apply_v0.ts +131 -8
- package/src/control_check_v0.ts +203 -23
- package/src/control_prefill_v0.ts +136 -8
- package/src/control_surface_coverage_v0.ts +164 -0
- package/src/control_v0.ts +808 -0
- package/src/control_v0_schema.ts +26 -0
- package/src/init_v0.ts +48 -1
- package/src/observability_writer_v0.ts +157 -0
- package/src/observe_v0.ts +64 -0
- package/src/presets_v0.ts +55 -0
- package/src/redaction.ts +6 -1
- package/src/run_import.ts +132 -26
- package/test/control_demo_full_roundtrip.test.js +92 -0
- package/test/control_surface_coverage_v0.test.js +36 -0
- package/test/control_v0_schema_validation.test.js +69 -0
- package/test/init_v0.test.js +9 -0
- package/test/observability_writer_v0.test.js +59 -0
- package/test/preset_safe_observable_v0.test.js +55 -0
- package/test/profile_v0_output.test.js +1 -0
- package/test/scaffold_v0_output.test.js +1 -0
- package/tools/control_surface_coverage_v0.mjs +27 -0
- package/tools/smoke_v0.mjs +33 -0
- package/.tmp_test_control_apply/proj/.claude/agents/example_agent.md +0 -3
- package/.tmp_test_control_apply/proj/.claude/commands/example_command.md +0 -3
- package/.tmp_test_control_apply/proj/.claude/hooks/example_hook.sh +0 -2
- package/.tmp_test_control_apply/proj/.claude/output-styles/example_style.md +0 -3
- package/.tmp_test_control_apply/proj/.claude/settings.json +0 -30
- package/.tmp_test_control_apply/proj/.claude/settings.local.example.json +0 -3
- package/.tmp_test_control_apply/proj/.mcp.json +0 -3
- package/.tmp_test_control_apply/proj/CLAUDE.md +0 -13
- package/.tmp_test_control_apply/proj/MOVA.md +0 -3
- package/.tmp_test_control_check/proj/.mcp.json +0 -1
- package/.tmp_test_control_check/proj/CLAUDE.md +0 -1
- package/.tmp_test_control_prefill/out1/claude_control_profile_v0.json +0 -114
- package/.tmp_test_control_prefill/out1/prefill_report_v0.json +0 -13
- package/.tmp_test_control_prefill/out2/claude_control_profile_v0.json +0 -114
- package/.tmp_test_control_prefill/out2/prefill_report_v0.json +0 -13
- package/.tmp_test_overlay/proj/.claude/skills/a.md +0 -1
- package/.tmp_test_overlay/proj/.mcp.json +0 -1
- package/.tmp_test_overlay/proj/CLAUDE.md +0 -1
- package/.tmp_test_profile/proj/.claude/skills/a.md +0 -1
- package/.tmp_test_profile/proj/.mcp.json +0 -1
- package/.tmp_test_profile/proj/CLAUDE.md +0 -1
- package/.tmp_test_scaffold_apply/proj/.claude/agents/example_agent.md +0 -3
- package/.tmp_test_scaffold_apply/proj/.claude/commands/example_command.md +0 -3
- package/.tmp_test_scaffold_apply/proj/.claude/hooks/example_hook.sh +0 -2
- package/.tmp_test_scaffold_apply/proj/.claude/output-styles/example_style.md +0 -3
- package/.tmp_test_scaffold_apply/proj/.claude/settings.json +0 -30
- package/.tmp_test_scaffold_apply/proj/.claude/settings.local.example.json +0 -3
- package/.tmp_test_scaffold_apply/proj/.mcp.json +0 -3
- package/.tmp_test_scaffold_apply/proj/CLAUDE.md +0 -13
- package/.tmp_test_scaffold_apply/proj/MOVA.md +0 -3
- package/.tmp_test_strict/mova/claude_import/v0/VERSION.json +0 -10
- package/.tmp_test_strict/mova/claude_import/v0/episode_import_run.json +0 -20
- package/.tmp_test_strict/mova/claude_import/v0/import_manifest.json +0 -20
- package/.tmp_test_strict/mova/claude_import/v0/input_policy_report_v0.json +0 -32
- package/.tmp_test_zip/out1/.claude/agents/example_agent.md +0 -3
- package/.tmp_test_zip/out1/.claude/commands/example_command.md +0 -3
- package/.tmp_test_zip/out1/.claude/commands/mova_context.md +0 -4
- package/.tmp_test_zip/out1/.claude/commands/mova_lint.md +0 -4
- package/.tmp_test_zip/out1/.claude/commands/mova_proof.md +0 -6
- package/.tmp_test_zip/out1/.claude/hooks/example_hook.sh +0 -2
- package/.tmp_test_zip/out1/.claude/output-styles/example_style.md +0 -3
- package/.tmp_test_zip/out1/.claude/settings.json +0 -30
- package/.tmp_test_zip/out1/.claude/settings.local.example.json +0 -3
- package/.tmp_test_zip/out1/.claude/skills/a/SKILL.md +0 -1
- package/.tmp_test_zip/out1/.claude/skills/mova-control-v0/SKILL.md +0 -11
- package/.tmp_test_zip/out1/.claude/skills/mova-layer-v0/SKILL.md +0 -8
- package/.tmp_test_zip/out1/CLAUDE.md +0 -4
- package/.tmp_test_zip/out1/MOVA.md +0 -10
- package/.tmp_test_zip/out1/export.zip +0 -0
- package/.tmp_test_zip/out1/mova/claude_import/v0/VERSION.json +0 -10
- package/.tmp_test_zip/out1/mova/claude_import/v0/contracts/instruction_profile_v0.json +0 -8
- package/.tmp_test_zip/out1/mova/claude_import/v0/contracts/mcp_servers_v0.json +0 -4
- package/.tmp_test_zip/out1/mova/claude_import/v0/contracts/skills_catalog_v0.json +0 -11
- package/.tmp_test_zip/out1/mova/claude_import/v0/episode_import_run.json +0 -80
- package/.tmp_test_zip/out1/mova/claude_import/v0/export_manifest_v0.json +0 -32
- package/.tmp_test_zip/out1/mova/claude_import/v0/import_manifest.json +0 -33
- package/.tmp_test_zip/out1/mova/claude_import/v0/input_policy_report_v0.json +0 -38
- package/.tmp_test_zip/out1/mova/claude_import/v0/lint_report_v0.json +0 -6
- package/.tmp_test_zip/out1/mova/claude_import/v0/redaction_report.json +0 -4
- package/.tmp_test_zip/out2/.claude/agents/example_agent.md +0 -3
- package/.tmp_test_zip/out2/.claude/commands/example_command.md +0 -3
- package/.tmp_test_zip/out2/.claude/commands/mova_context.md +0 -4
- package/.tmp_test_zip/out2/.claude/commands/mova_lint.md +0 -4
- package/.tmp_test_zip/out2/.claude/commands/mova_proof.md +0 -6
- package/.tmp_test_zip/out2/.claude/hooks/example_hook.sh +0 -2
- package/.tmp_test_zip/out2/.claude/output-styles/example_style.md +0 -3
- package/.tmp_test_zip/out2/.claude/settings.json +0 -30
- package/.tmp_test_zip/out2/.claude/settings.local.example.json +0 -3
- package/.tmp_test_zip/out2/.claude/skills/a/SKILL.md +0 -1
- package/.tmp_test_zip/out2/.claude/skills/mova-control-v0/SKILL.md +0 -11
- package/.tmp_test_zip/out2/.claude/skills/mova-layer-v0/SKILL.md +0 -8
- package/.tmp_test_zip/out2/.mcp.json +0 -3
- package/.tmp_test_zip/out2/CLAUDE.md +0 -4
- package/.tmp_test_zip/out2/MOVA.md +0 -10
- package/.tmp_test_zip/out2/export.zip +0 -0
- package/.tmp_test_zip/out2/mova/claude_import/v0/VERSION.json +0 -10
- package/.tmp_test_zip/out2/mova/claude_import/v0/contracts/instruction_profile_v0.json +0 -8
- package/.tmp_test_zip/out2/mova/claude_import/v0/contracts/mcp_servers_v0.json +0 -4
- package/.tmp_test_zip/out2/mova/claude_import/v0/contracts/skills_catalog_v0.json +0 -11
- package/.tmp_test_zip/out2/mova/claude_import/v0/episode_import_run.json +0 -80
- package/.tmp_test_zip/out2/mova/claude_import/v0/export_manifest_v0.json +0 -32
- package/.tmp_test_zip/out2/mova/claude_import/v0/import_manifest.json +0 -33
- package/.tmp_test_zip/out2/mova/claude_import/v0/input_policy_report_v0.json +0 -38
- package/.tmp_test_zip/out2/mova/claude_import/v0/lint_report_v0.json +0 -6
- package/.tmp_test_zip/out2/mova/claude_import/v0/redaction_report.json +0 -4
- package/.tmp_test_zip/proj/.claude/skills/a.md +0 -1
- package/.tmp_test_zip/proj/.mcp.json +0 -1
- package/.tmp_test_zip/proj/CLAUDE.md +0 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { stableStringify } from "./stable_json.js";
|
|
4
|
+
import { normalizeControlV0 } from "./control_v0.js";
|
|
5
|
+
|
|
6
|
+
type CoverageExclusion = {
|
|
7
|
+
pattern: string;
|
|
8
|
+
reason: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type CoverageReport = {
|
|
12
|
+
profile_version: "v0";
|
|
13
|
+
showcase_root: string;
|
|
14
|
+
control_path: string;
|
|
15
|
+
total_surface_files: number;
|
|
16
|
+
excluded: Array<{ pattern: string; reason: string; matches: number }>;
|
|
17
|
+
covered_count: number;
|
|
18
|
+
coverage_percent: number;
|
|
19
|
+
missing: string[];
|
|
20
|
+
covered: string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function toPosix(p: string): string {
|
|
24
|
+
return p.replace(/\\/g, "/");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function exists(p: string): Promise<boolean> {
|
|
28
|
+
try {
|
|
29
|
+
await fs.stat(p);
|
|
30
|
+
return true;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function listFilesRec(dir: string): Promise<string[]> {
|
|
37
|
+
const out: string[] = [];
|
|
38
|
+
const stack = [dir];
|
|
39
|
+
while (stack.length) {
|
|
40
|
+
const current = stack.pop()!;
|
|
41
|
+
const entries = await fs.readdir(current, { withFileTypes: true });
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
const abs = path.join(current, entry.name);
|
|
44
|
+
if (entry.isDirectory()) stack.push(abs);
|
|
45
|
+
else if (entry.isFile()) out.push(abs);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function globToRegex(pattern: string): RegExp {
|
|
52
|
+
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
53
|
+
const regex = escaped.replace(/\\\*\\\*/g, ".*").replace(/\\\*/g, "[^/]*");
|
|
54
|
+
return new RegExp(`^${regex}$`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function applyExclusions(files: string[], exclusions: CoverageExclusion[]) {
|
|
58
|
+
const excludedMatches: Array<{ pattern: string; reason: string; matches: number }> = [];
|
|
59
|
+
const keep = new Set(files);
|
|
60
|
+
for (const ex of exclusions) {
|
|
61
|
+
const regex = globToRegex(ex.pattern);
|
|
62
|
+
let matches = 0;
|
|
63
|
+
for (const file of files) {
|
|
64
|
+
if (regex.test(file)) {
|
|
65
|
+
if (keep.delete(file)) matches++;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
excludedMatches.push({ pattern: ex.pattern, reason: ex.reason, matches });
|
|
69
|
+
}
|
|
70
|
+
return { remaining: Array.from(keep).sort(), excludedMatches };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function readJson(p: string) {
|
|
74
|
+
const raw = await fs.readFile(p, "utf8");
|
|
75
|
+
return JSON.parse(raw);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function runControlSurfaceCoverageV0(params: {
|
|
79
|
+
showcaseRoot: string;
|
|
80
|
+
controlPath: string;
|
|
81
|
+
exclusionsPath: string;
|
|
82
|
+
reportPath: string;
|
|
83
|
+
}): Promise<CoverageReport> {
|
|
84
|
+
const showcaseRoot = path.resolve(params.showcaseRoot);
|
|
85
|
+
const controlPath = path.resolve(params.controlPath);
|
|
86
|
+
const exclusionsPath = path.resolve(params.exclusionsPath);
|
|
87
|
+
const reportPath = path.resolve(params.reportPath);
|
|
88
|
+
|
|
89
|
+
const roots = [
|
|
90
|
+
path.join(showcaseRoot, "CLAUDE.md"),
|
|
91
|
+
path.join(showcaseRoot, ".mcp.json"),
|
|
92
|
+
path.join(showcaseRoot, ".claude"),
|
|
93
|
+
path.join(showcaseRoot, ".github", "workflows"),
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const surfaceFiles: string[] = [];
|
|
97
|
+
for (const root of roots) {
|
|
98
|
+
if (!(await exists(root))) continue;
|
|
99
|
+
const stat = await fs.stat(root);
|
|
100
|
+
if (stat.isFile()) {
|
|
101
|
+
surfaceFiles.push(root);
|
|
102
|
+
} else if (stat.isDirectory()) {
|
|
103
|
+
const files = await listFilesRec(root);
|
|
104
|
+
surfaceFiles.push(...files);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const surfaceRel = surfaceFiles.map((p) => toPosix(path.relative(showcaseRoot, p))).sort();
|
|
109
|
+
|
|
110
|
+
const controlRaw = await readJson(controlPath);
|
|
111
|
+
const control = normalizeControlV0(controlRaw).control;
|
|
112
|
+
|
|
113
|
+
const covered = new Set<string>([
|
|
114
|
+
"CLAUDE.md",
|
|
115
|
+
".mcp.json",
|
|
116
|
+
".claude/settings.json",
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
const assets = [
|
|
120
|
+
...control.assets.skills,
|
|
121
|
+
...control.assets.agents,
|
|
122
|
+
...control.assets.commands,
|
|
123
|
+
...control.assets.rules,
|
|
124
|
+
...control.assets.hooks,
|
|
125
|
+
...control.assets.workflows,
|
|
126
|
+
...control.assets.docs,
|
|
127
|
+
...control.assets.dotfiles,
|
|
128
|
+
...control.assets.schemas,
|
|
129
|
+
];
|
|
130
|
+
for (const asset of assets) {
|
|
131
|
+
covered.add(toPosix(asset.path));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (control.lsp.managed) {
|
|
135
|
+
covered.add(toPosix(control.lsp.config_path));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const exclusions = (await readJson(exclusionsPath))?.exclusions ?? [];
|
|
139
|
+
const { remaining, excludedMatches } = applyExclusions(surfaceRel, exclusions);
|
|
140
|
+
|
|
141
|
+
const missing = remaining.filter((p) => !covered.has(p));
|
|
142
|
+
const coveredList = remaining.filter((p) => covered.has(p));
|
|
143
|
+
|
|
144
|
+
const total = remaining.length;
|
|
145
|
+
const coveredCount = coveredList.length;
|
|
146
|
+
const coveragePercent = total === 0 ? 100 : Math.round((coveredCount / total) * 100);
|
|
147
|
+
|
|
148
|
+
const report: CoverageReport = {
|
|
149
|
+
profile_version: "v0",
|
|
150
|
+
showcase_root: showcaseRoot,
|
|
151
|
+
control_path: controlPath,
|
|
152
|
+
total_surface_files: total,
|
|
153
|
+
excluded: excludedMatches,
|
|
154
|
+
covered_count: coveredCount,
|
|
155
|
+
coverage_percent: coveragePercent,
|
|
156
|
+
missing,
|
|
157
|
+
covered: coveredList,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
await fs.mkdir(path.dirname(reportPath), { recursive: true });
|
|
161
|
+
await fs.writeFile(reportPath, stableStringify(report) + "\n", "utf8");
|
|
162
|
+
|
|
163
|
+
return report;
|
|
164
|
+
}
|