@phuc1403/musketeer 0.9.0 → 0.10.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/INSTALLATION.md +52 -52
- package/bin/musketeer.js +168 -168
- package/package.json +48 -48
- package/src/dotnet-scaffold-copier.js +79 -79
- package/src/provisioner/detect.js +93 -93
- package/src/self-update.js +77 -77
- package/template/.claude/agents/git-manager.md +18 -18
- package/template/.claude/agents/hallmark-auditor.md +78 -78
- package/template/.claude/agents/researcher.md +33 -33
- package/template/.claude/hooks/block-unsafe-adr-title.cjs +85 -85
- package/template/.claude/hooks/init-adr-dir.cjs +173 -173
- package/template/.claude/hooks/inject-adr-flags.cjs +94 -94
- package/template/.claude/hooks/lib/adr/command-scan.cjs +115 -115
- package/template/.claude/hooks/lib/characteristics/checker.cjs +357 -357
- package/template/.claude/hooks/lib/git-info-cache.cjs +191 -191
- package/template/.claude/hooks/sync-adr-toc.cjs +146 -146
- package/template/.claude/hooks/usage-quota-cache-refresh.cjs +166 -166
- package/template/.claude/hooks/validate-characteristics-hook.cjs +66 -66
- package/template/.claude/hooks/validate-cml-hook.js +145 -145
- package/template/.claude/skills/adr-writer/SKILL.md +48 -48
- package/template/.claude/skills/adr-writer/references/adr-example.md +35 -35
- package/template/.claude/skills/architecture-characteristic-writer/SKILL.md +215 -215
- package/template/.claude/skills/architecture-characteristic-writer/assets/worksheet-template.md +29 -29
- package/template/.claude/skills/architecture-characteristic-writer/references/characteristics-catalog.md +40 -40
- package/template/.claude/skills/architecture-characteristic-writer/scripts/ranking-table.cjs +171 -171
- package/template/.claude/skills/context-map/SKILL.md +80 -80
- package/template/.claude/skills/context-map/example.cml +106 -106
- package/template/.claude/skills/context-map/reference/Bounded Context/Bounded Context.md +40 -40
- package/template/.claude/skills/context-map/reference/Bounded Context/businessModel.md +5 -5
- package/template/.claude/skills/context-map/reference/Bounded Context/domainVisionStatement.md +2 -2
- package/template/.claude/skills/context-map/reference/Bounded Context/evolution.md +5 -5
- package/template/.claude/skills/context-map/reference/Bounded Context/implementationTechnology.md +1 -1
- package/template/.claude/skills/context-map/reference/Bounded Context/implements.md +1 -1
- package/template/.claude/skills/context-map/reference/Bounded Context/knowledgeLevel.md +4 -4
- package/template/.claude/skills/context-map/reference/Bounded Context/realizes.md +9 -9
- package/template/.claude/skills/context-map/reference/Bounded Context/refines.md +10 -10
- package/template/.claude/skills/context-map/reference/Bounded Context/responsibilities.md +26 -26
- package/template/.claude/skills/context-map/reference/Bounded Context/type.md +23 -23
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Anticorruption Layer.md +5 -5
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Bounded Context Relationship.md +12 -12
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Conformist.md +5 -5
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Customer-Supplier (C-S).md +22 -22
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Open Host Service.md +4 -4
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Partnership (P).md +13 -13
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Published Language.md +4 -4
- package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Shared Kernel (SK).md +12 -12
- package/template/.claude/skills/context-map/reference/Context Map.md +62 -62
- package/template/.claude/skills/context-map/reference/Domain/Domain.md +30 -30
- package/template/.claude/skills/context-map/reference/Domain/supports.md +33 -33
- package/template/.claude/skills/context-map/reference/Domain/type.md +3 -3
- package/template/.claude/skills/context-map/reference/Semantic Rules.md +32 -32
- package/template/.claude/skills/hallmark/SKILL.md +552 -552
- package/template/.claude/skills/hallmark/references/anti-patterns.md +412 -412
- package/template/.claude/skills/hallmark/references/assets.md +406 -406
- package/template/.claude/skills/hallmark/references/color.md +95 -95
- package/template/.claude/skills/hallmark/references/component-cookbook.md +256 -256
- package/template/.claude/skills/hallmark/references/components/c1-outlined-chip.md +12 -12
- package/template/.claude/skills/hallmark/references/components/c2-inline-form-as-cta.md +16 -16
- package/template/.claude/skills/hallmark/references/components/c3-typographic-link.md +8 -8
- package/template/.claude/skills/hallmark/references/components/c4-sticky-bottom-bar.md +16 -16
- package/template/.claude/skills/hallmark/references/components/f1-bento-grid.md +20 -20
- package/template/.claude/skills/hallmark/references/components/f2-sticky-scroll-stack.md +20 -20
- package/template/.claude/skills/hallmark/references/components/f3-tabular-spec-sheet.md +11 -11
- package/template/.claude/skills/hallmark/references/components/f4-step-sequence.md +11 -11
- package/template/.claude/skills/hallmark/references/components/f5-annotated-screenshot.md +11 -11
- package/template/.claude/skills/hallmark/references/components/f6-product-card-grid.md +41 -41
- package/template/.claude/skills/hallmark/references/components/ft1-mast-headed.md +13 -13
- package/template/.claude/skills/hallmark/references/components/ft2-inline-rule-single-line.md +10 -10
- package/template/.claude/skills/hallmark/references/components/ft3-index-style-category-list.md +12 -12
- package/template/.claude/skills/hallmark/references/components/ft4-dense-typographic.md +10 -10
- package/template/.claude/skills/hallmark/references/components/ft5-statement.md +21 -21
- package/template/.claude/skills/hallmark/references/components/ft6-letter-close.md +19 -19
- package/template/.claude/skills/hallmark/references/components/ft7-newsletter-first.md +27 -27
- package/template/.claude/skills/hallmark/references/components/ft8-marquee-scroll.md +25 -25
- package/template/.claude/skills/hallmark/references/components/h1-marquee.md +15 -15
- package/template/.claude/skills/hallmark/references/components/h2-split-diptych.md +15 -15
- package/template/.claude/skills/hallmark/references/components/h3-quote-led.md +11 -11
- package/template/.claude/skills/hallmark/references/components/h4-stat-led.md +14 -14
- package/template/.claude/skills/hallmark/references/components/h5-letter-hero.md +11 -11
- package/template/.claude/skills/hallmark/references/components/h6-photographic-fold.md +16 -16
- package/template/.claude/skills/hallmark/references/components/h7-demo-video-clipped-by-viewport-edge.md +27 -27
- package/template/.claude/skills/hallmark/references/components/h8-mockup-split-browser-framed.md +23 -23
- package/template/.claude/skills/hallmark/references/components/h9-custom-illustration-centerpiece.md +27 -27
- package/template/.claude/skills/hallmark/references/components/n1-wordmark-2-links.md +12 -12
- package/template/.claude/skills/hallmark/references/components/n10-floating-on-scroll-morph.md +19 -19
- package/template/.claude/skills/hallmark/references/components/n2-floating-chip.md +14 -14
- package/template/.claude/skills/hallmark/references/components/n3-side-rail.md +14 -14
- package/template/.claude/skills/hallmark/references/components/n4-hidden-behind-k.md +9 -9
- package/template/.claude/skills/hallmark/references/components/n5-floating-pill.md +28 -28
- package/template/.claude/skills/hallmark/references/components/n6-newspaper-masthead.md +24 -24
- package/template/.claude/skills/hallmark/references/components/n7-brutal-slab.md +22 -22
- package/template/.claude/skills/hallmark/references/components/n8-terminal-command.md +21 -21
- package/template/.claude/skills/hallmark/references/components/n9-edge-aligned-minimal.md +17 -17
- package/template/.claude/skills/hallmark/references/components/s1-left-margin-numbered.md +15 -15
- package/template/.claude/skills/hallmark/references/components/s2-hanging.md +13 -13
- package/template/.claude/skills/hallmark/references/components/s3-sticky-pinned.md +19 -19
- package/template/.claude/skills/hallmark/references/components/s4-inline-no-break.md +11 -11
- package/template/.claude/skills/hallmark/references/components/s5-bottom-anchored.md +13 -13
- package/template/.claude/skills/hallmark/references/components/t1-pull-quote-with-marginalia.md +12 -12
- package/template/.claude/skills/hallmark/references/components/t2-logo-wall-hairline.md +19 -19
- package/template/.claude/skills/hallmark/references/components/t3-single-huge-quote.md +11 -11
- package/template/.claude/skills/hallmark/references/components/t4-numbered-stat-strip.md +14 -14
- package/template/.claude/skills/hallmark/references/contract.md +24 -24
- package/template/.claude/skills/hallmark/references/copy.md +182 -182
- package/template/.claude/skills/hallmark/references/custom-craft.md +626 -626
- package/template/.claude/skills/hallmark/references/custom-theme.md +329 -329
- package/template/.claude/skills/hallmark/references/design-md.md +116 -116
- package/template/.claude/skills/hallmark/references/export-formats.md +328 -328
- package/template/.claude/skills/hallmark/references/floating-nav.md +89 -89
- package/template/.claude/skills/hallmark/references/genres/atmospheric.md +65 -65
- package/template/.claude/skills/hallmark/references/genres/editorial.md +70 -70
- package/template/.claude/skills/hallmark/references/genres/modern-minimal.md +67 -67
- package/template/.claude/skills/hallmark/references/genres/playful.md +65 -65
- package/template/.claude/skills/hallmark/references/hero-enrichment.md +474 -474
- package/template/.claude/skills/hallmark/references/imagery-kit.md +170 -170
- package/template/.claude/skills/hallmark/references/interaction-and-states.md +207 -207
- package/template/.claude/skills/hallmark/references/layout-and-space.md +111 -111
- package/template/.claude/skills/hallmark/references/macrostructures/01-bento-grid.md +35 -35
- package/template/.claude/skills/hallmark/references/macrostructures/02-long-document.md +34 -34
- package/template/.claude/skills/hallmark/references/macrostructures/03-marquee-hero.md +31 -31
- package/template/.claude/skills/hallmark/references/macrostructures/04-stat-led.md +32 -32
- package/template/.claude/skills/hallmark/references/macrostructures/05-workbench.md +32 -32
- package/template/.claude/skills/hallmark/references/macrostructures/06-conversational-faq.md +33 -33
- package/template/.claude/skills/hallmark/references/macrostructures/07-manifesto.md +32 -32
- package/template/.claude/skills/hallmark/references/macrostructures/08-photographic.md +34 -34
- package/template/.claude/skills/hallmark/references/macrostructures/09-quote-led.md +32 -32
- package/template/.claude/skills/hallmark/references/macrostructures/10-specimen.md +32 -32
- package/template/.claude/skills/hallmark/references/macrostructures/11-catalogue.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/12-letter.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/13-index-first.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/14-narrative-workflow.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/15-split-studio.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/16-feature-stack.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/17-type-specimen.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/18-portfolio-grid.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/19-map-diagram.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/20-ecosystem-index.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures/21-component-playground.md +23 -23
- package/template/.claude/skills/hallmark/references/macrostructures.md +89 -89
- package/template/.claude/skills/hallmark/references/microinteractions.md +260 -260
- package/template/.claude/skills/hallmark/references/motion.md +109 -109
- package/template/.claude/skills/hallmark/references/preview-examples.md +49 -49
- package/template/.claude/skills/hallmark/references/responsive.md +138 -138
- package/template/.claude/skills/hallmark/references/slop-test.md +205 -205
- package/template/.claude/skills/hallmark/references/structure.md +164 -164
- package/template/.claude/skills/hallmark/references/study.md +511 -511
- package/template/.claude/skills/hallmark/references/typography.md +243 -243
- package/template/.claude/skills/hallmark/references/verbs/audit.md +25 -25
- package/template/.claude/skills/hallmark/references/verbs/redesign.md +269 -269
- package/template/.claude/skills/hallmark-loop/SKILL.md +105 -105
- package/template/.claude/skills/hallmark-loop/references/auditor-call.md +60 -60
- package/template/.claude/skills/hallmark-loop/references/capture.md +78 -78
- package/template/.claude/skills/hallmark-loop/references/loop-control.md +79 -79
- package/template/.claude/skills/handoff/SKILL.md +15 -15
- package/template/.claude/skills/knowledge-crunching/SKILL.md +94 -94
- package/template/.claude/skills/research/SKILL.md +69 -69
- package/template/.claude/skills/tdd/SKILL.md +142 -142
- package/template/.claude/skills/tdd/deep-modules.md +15 -15
- package/template/.claude/skills/tdd/interface-design.md +31 -31
- package/template/.claude/skills/tdd/mocking.md +59 -59
- package/template/.claude/skills/tdd/refactoring.md +10 -10
- package/template/.claude/skills/tdd/tests.md +61 -61
- package/template/.claude/statusline.cjs +100 -37
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// PostToolUse validation hook for Context Mapper `.cml` files (cross-platform).
|
|
3
|
-
//
|
|
4
|
-
// .claude/settings.json calls this as `node validate-cml-hook.js` after every
|
|
5
|
-
// Write/Edit. It
|
|
6
|
-
// reads the PostToolUse payload from stdin, and if the edited file is a .cml,
|
|
7
|
-
// validates it with the Context Mapper CLI and speaks the hook exit-code
|
|
8
|
-
// contract:
|
|
9
|
-
// exit 0 -> ok (stdout shown in transcript)
|
|
10
|
-
// exit 2 -> blocking error (stderr fed back to Claude to fix)
|
|
11
|
-
// A non-.cml edit / missing file / unparseable payload all exit 0.
|
|
12
|
-
//
|
|
13
|
-
// Bootstrap installs Context Mapper CLI 6.12+ into ~/.context-mapper-cli/ (Java
|
|
14
|
-
// 8+ required) on first run. The run path is unified (java -classpath <lib>/*
|
|
15
|
-
// MainClass); only archive extraction branches by platform. Override the
|
|
16
|
-
// install location with CONTEXT_MAPPER_HOME.
|
|
17
|
-
|
|
18
|
-
const os = require('os');
|
|
19
|
-
const path = require('path');
|
|
20
|
-
const fs = require('fs');
|
|
21
|
-
const { spawnSync } = require('child_process');
|
|
22
|
-
|
|
23
|
-
const VERSION = '6.12.0';
|
|
24
|
-
const MAIN_CLASS = 'org.contextmapper.cli.ContextMapperCLI';
|
|
25
|
-
const isWin = process.platform === 'win32';
|
|
26
|
-
const installDir = process.env.CONTEXT_MAPPER_HOME || path.join(os.homedir(), '.context-mapper-cli');
|
|
27
|
-
const distDir = path.join(installDir, `context-mapper-cli-${VERSION}`);
|
|
28
|
-
const libDir = path.join(distDir, 'lib');
|
|
29
|
-
|
|
30
|
-
function fail(code, msg) {
|
|
31
|
-
process.stderr.write(msg + '\n');
|
|
32
|
-
process.exit(code);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function isInstalled() {
|
|
36
|
-
try {
|
|
37
|
-
return fs.readdirSync(libDir).some((f) => f.endsWith('.jar'));
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function hasJava() {
|
|
44
|
-
const r = spawnSync('java', ['-version'], { stdio: 'ignore' });
|
|
45
|
-
return !r.error && r.status === 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function bootstrap() {
|
|
49
|
-
if (!hasJava()) fail(2, 'Java 8+ is required (e.g. Temurin LTS). Install Java, then retry.');
|
|
50
|
-
|
|
51
|
-
process.stderr.write(`Bootstrapping Context Mapper CLI ${VERSION} into ${installDir} ...\n`);
|
|
52
|
-
fs.mkdirSync(installDir, { recursive: true });
|
|
53
|
-
|
|
54
|
-
// Extraction must be platform-specific: Windows `tar` (Git's GNU tar) cannot
|
|
55
|
-
// read .zip and mangles `C:\` paths as remote host:path, so we use the .zip +
|
|
56
|
-
// Expand-Archive there, and the .tar + `tar` on macOS/Linux. The run path
|
|
57
|
-
// (java -classpath) stays unified.
|
|
58
|
-
const ext = isWin ? 'zip' : 'tar';
|
|
59
|
-
const archive = path.join(installDir, `cli-${VERSION}.${ext}`);
|
|
60
|
-
const url = `https://repo1.maven.org/maven2/org/contextmapper/context-mapper-cli/${VERSION}/context-mapper-cli-${VERSION}.${ext}`;
|
|
61
|
-
|
|
62
|
-
let res;
|
|
63
|
-
try {
|
|
64
|
-
res = await fetch(url);
|
|
65
|
-
} catch (e) {
|
|
66
|
-
fail(3, `Download failed: ${e.message}\nURL: ${url}`);
|
|
67
|
-
}
|
|
68
|
-
if (!res.ok) fail(3, `Download failed: HTTP ${res.status}\nURL: ${url}`);
|
|
69
|
-
fs.writeFileSync(archive, Buffer.from(await res.arrayBuffer()));
|
|
70
|
-
|
|
71
|
-
const ex = isWin
|
|
72
|
-
? spawnSync('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
|
|
73
|
-
`Expand-Archive -LiteralPath '${archive}' -DestinationPath '${installDir}' -Force`], { stdio: 'inherit' })
|
|
74
|
-
: spawnSync('tar', ['-xf', archive, '-C', installDir], { stdio: 'inherit' });
|
|
75
|
-
if (ex.error || ex.status !== 0) {
|
|
76
|
-
fail(4, `Extraction failed. Inspect ${installDir} manually.`);
|
|
77
|
-
}
|
|
78
|
-
fs.rmSync(archive, { force: true });
|
|
79
|
-
|
|
80
|
-
if (!isInstalled()) fail(4, `Bootstrap failed: no jars under ${libDir} after extract. Inspect ${installDir} manually.`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Run the CLI's main class and capture its output. The JVM expands the `lib/*`
|
|
84
|
-
// wildcard itself, so we pass it as one literal classpath entry (no shell -> no
|
|
85
|
-
// shell glob expansion).
|
|
86
|
-
function runJava(args, cwd) {
|
|
87
|
-
const classpath = path.join(libDir, '*');
|
|
88
|
-
const res = spawnSync('java', ['-classpath', classpath, MAIN_CLASS, ...args], {
|
|
89
|
-
cwd,
|
|
90
|
-
stdio: 'pipe',
|
|
91
|
-
encoding: 'utf8',
|
|
92
|
-
});
|
|
93
|
-
if (res.error) {
|
|
94
|
-
if (res.error.code === 'ENOENT') fail(2, 'Java 8+ is required (e.g. Temurin LTS). Install Java, then retry.');
|
|
95
|
-
fail(1, `Failed to launch java: ${res.error.message}`);
|
|
96
|
-
}
|
|
97
|
-
return res;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// --- Hook mode: validate the .cml named in a PostToolUse stdin payload -------
|
|
101
|
-
function runHook() {
|
|
102
|
-
let raw = '';
|
|
103
|
-
try {
|
|
104
|
-
raw = fs.readFileSync(0, 'utf8'); // fd 0 = stdin
|
|
105
|
-
} catch {
|
|
106
|
-
process.exit(0);
|
|
107
|
-
}
|
|
108
|
-
if (!raw.trim()) process.exit(0);
|
|
109
|
-
|
|
110
|
-
let payload;
|
|
111
|
-
try {
|
|
112
|
-
payload = JSON.parse(raw);
|
|
113
|
-
} catch {
|
|
114
|
-
process.exit(0); // nothing actionable
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const filePath = payload?.tool_input?.file_path;
|
|
118
|
-
if (!filePath || !/\.cml$/i.test(filePath) || !fs.existsSync(filePath)) {
|
|
119
|
-
process.exit(0);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const name = path.basename(filePath);
|
|
123
|
-
// cwd = the file's directory so the bare filename resolves (relative-path gotcha).
|
|
124
|
-
const res = runJava(['validate', '-i', name], path.dirname(filePath));
|
|
125
|
-
const output = `${res.stdout || ''}${res.stderr || ''}`.trim();
|
|
126
|
-
|
|
127
|
-
// Two failure modes: parse failures throw a Java exception and exit non-zero;
|
|
128
|
-
// semantic-validation failures print uppercase "ERROR ..." lines (possibly
|
|
129
|
-
// while still exiting 0). Match ERROR case-sensitively so the success line
|
|
130
|
-
// ("...without errors.") is not a false positive; WARNING lines (intentional
|
|
131
|
-
// ACL, or JVM sun.misc.Unsafe deprecation noise) are allowed.
|
|
132
|
-
const hasErrorLine = output.split(/\r?\n/).some((l) => /ERROR/.test(l));
|
|
133
|
-
|
|
134
|
-
if (res.status !== 0 || hasErrorLine) {
|
|
135
|
-
process.stderr.write(`CML validation FAILED for ${name}\n${output}\n`);
|
|
136
|
-
process.exit(2);
|
|
137
|
-
}
|
|
138
|
-
process.stdout.write(`CML validation passed for ${name}\n${output}\n`);
|
|
139
|
-
process.exit(0);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
(async () => {
|
|
143
|
-
if (!isInstalled()) await bootstrap();
|
|
144
|
-
runHook();
|
|
145
|
-
})();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// PostToolUse validation hook for Context Mapper `.cml` files (cross-platform).
|
|
3
|
+
//
|
|
4
|
+
// .claude/settings.json calls this as `node validate-cml-hook.js` after every
|
|
5
|
+
// Write/Edit. It
|
|
6
|
+
// reads the PostToolUse payload from stdin, and if the edited file is a .cml,
|
|
7
|
+
// validates it with the Context Mapper CLI and speaks the hook exit-code
|
|
8
|
+
// contract:
|
|
9
|
+
// exit 0 -> ok (stdout shown in transcript)
|
|
10
|
+
// exit 2 -> blocking error (stderr fed back to Claude to fix)
|
|
11
|
+
// A non-.cml edit / missing file / unparseable payload all exit 0.
|
|
12
|
+
//
|
|
13
|
+
// Bootstrap installs Context Mapper CLI 6.12+ into ~/.context-mapper-cli/ (Java
|
|
14
|
+
// 8+ required) on first run. The run path is unified (java -classpath <lib>/*
|
|
15
|
+
// MainClass); only archive extraction branches by platform. Override the
|
|
16
|
+
// install location with CONTEXT_MAPPER_HOME.
|
|
17
|
+
|
|
18
|
+
const os = require('os');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const { spawnSync } = require('child_process');
|
|
22
|
+
|
|
23
|
+
const VERSION = '6.12.0';
|
|
24
|
+
const MAIN_CLASS = 'org.contextmapper.cli.ContextMapperCLI';
|
|
25
|
+
const isWin = process.platform === 'win32';
|
|
26
|
+
const installDir = process.env.CONTEXT_MAPPER_HOME || path.join(os.homedir(), '.context-mapper-cli');
|
|
27
|
+
const distDir = path.join(installDir, `context-mapper-cli-${VERSION}`);
|
|
28
|
+
const libDir = path.join(distDir, 'lib');
|
|
29
|
+
|
|
30
|
+
function fail(code, msg) {
|
|
31
|
+
process.stderr.write(msg + '\n');
|
|
32
|
+
process.exit(code);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isInstalled() {
|
|
36
|
+
try {
|
|
37
|
+
return fs.readdirSync(libDir).some((f) => f.endsWith('.jar'));
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function hasJava() {
|
|
44
|
+
const r = spawnSync('java', ['-version'], { stdio: 'ignore' });
|
|
45
|
+
return !r.error && r.status === 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function bootstrap() {
|
|
49
|
+
if (!hasJava()) fail(2, 'Java 8+ is required (e.g. Temurin LTS). Install Java, then retry.');
|
|
50
|
+
|
|
51
|
+
process.stderr.write(`Bootstrapping Context Mapper CLI ${VERSION} into ${installDir} ...\n`);
|
|
52
|
+
fs.mkdirSync(installDir, { recursive: true });
|
|
53
|
+
|
|
54
|
+
// Extraction must be platform-specific: Windows `tar` (Git's GNU tar) cannot
|
|
55
|
+
// read .zip and mangles `C:\` paths as remote host:path, so we use the .zip +
|
|
56
|
+
// Expand-Archive there, and the .tar + `tar` on macOS/Linux. The run path
|
|
57
|
+
// (java -classpath) stays unified.
|
|
58
|
+
const ext = isWin ? 'zip' : 'tar';
|
|
59
|
+
const archive = path.join(installDir, `cli-${VERSION}.${ext}`);
|
|
60
|
+
const url = `https://repo1.maven.org/maven2/org/contextmapper/context-mapper-cli/${VERSION}/context-mapper-cli-${VERSION}.${ext}`;
|
|
61
|
+
|
|
62
|
+
let res;
|
|
63
|
+
try {
|
|
64
|
+
res = await fetch(url);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
fail(3, `Download failed: ${e.message}\nURL: ${url}`);
|
|
67
|
+
}
|
|
68
|
+
if (!res.ok) fail(3, `Download failed: HTTP ${res.status}\nURL: ${url}`);
|
|
69
|
+
fs.writeFileSync(archive, Buffer.from(await res.arrayBuffer()));
|
|
70
|
+
|
|
71
|
+
const ex = isWin
|
|
72
|
+
? spawnSync('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
|
|
73
|
+
`Expand-Archive -LiteralPath '${archive}' -DestinationPath '${installDir}' -Force`], { stdio: 'inherit' })
|
|
74
|
+
: spawnSync('tar', ['-xf', archive, '-C', installDir], { stdio: 'inherit' });
|
|
75
|
+
if (ex.error || ex.status !== 0) {
|
|
76
|
+
fail(4, `Extraction failed. Inspect ${installDir} manually.`);
|
|
77
|
+
}
|
|
78
|
+
fs.rmSync(archive, { force: true });
|
|
79
|
+
|
|
80
|
+
if (!isInstalled()) fail(4, `Bootstrap failed: no jars under ${libDir} after extract. Inspect ${installDir} manually.`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Run the CLI's main class and capture its output. The JVM expands the `lib/*`
|
|
84
|
+
// wildcard itself, so we pass it as one literal classpath entry (no shell -> no
|
|
85
|
+
// shell glob expansion).
|
|
86
|
+
function runJava(args, cwd) {
|
|
87
|
+
const classpath = path.join(libDir, '*');
|
|
88
|
+
const res = spawnSync('java', ['-classpath', classpath, MAIN_CLASS, ...args], {
|
|
89
|
+
cwd,
|
|
90
|
+
stdio: 'pipe',
|
|
91
|
+
encoding: 'utf8',
|
|
92
|
+
});
|
|
93
|
+
if (res.error) {
|
|
94
|
+
if (res.error.code === 'ENOENT') fail(2, 'Java 8+ is required (e.g. Temurin LTS). Install Java, then retry.');
|
|
95
|
+
fail(1, `Failed to launch java: ${res.error.message}`);
|
|
96
|
+
}
|
|
97
|
+
return res;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// --- Hook mode: validate the .cml named in a PostToolUse stdin payload -------
|
|
101
|
+
function runHook() {
|
|
102
|
+
let raw = '';
|
|
103
|
+
try {
|
|
104
|
+
raw = fs.readFileSync(0, 'utf8'); // fd 0 = stdin
|
|
105
|
+
} catch {
|
|
106
|
+
process.exit(0);
|
|
107
|
+
}
|
|
108
|
+
if (!raw.trim()) process.exit(0);
|
|
109
|
+
|
|
110
|
+
let payload;
|
|
111
|
+
try {
|
|
112
|
+
payload = JSON.parse(raw);
|
|
113
|
+
} catch {
|
|
114
|
+
process.exit(0); // nothing actionable
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const filePath = payload?.tool_input?.file_path;
|
|
118
|
+
if (!filePath || !/\.cml$/i.test(filePath) || !fs.existsSync(filePath)) {
|
|
119
|
+
process.exit(0);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const name = path.basename(filePath);
|
|
123
|
+
// cwd = the file's directory so the bare filename resolves (relative-path gotcha).
|
|
124
|
+
const res = runJava(['validate', '-i', name], path.dirname(filePath));
|
|
125
|
+
const output = `${res.stdout || ''}${res.stderr || ''}`.trim();
|
|
126
|
+
|
|
127
|
+
// Two failure modes: parse failures throw a Java exception and exit non-zero;
|
|
128
|
+
// semantic-validation failures print uppercase "ERROR ..." lines (possibly
|
|
129
|
+
// while still exiting 0). Match ERROR case-sensitively so the success line
|
|
130
|
+
// ("...without errors.") is not a false positive; WARNING lines (intentional
|
|
131
|
+
// ACL, or JVM sun.misc.Unsafe deprecation noise) are allowed.
|
|
132
|
+
const hasErrorLine = output.split(/\r?\n/).some((l) => /ERROR/.test(l));
|
|
133
|
+
|
|
134
|
+
if (res.status !== 0 || hasErrorLine) {
|
|
135
|
+
process.stderr.write(`CML validation FAILED for ${name}\n${output}\n`);
|
|
136
|
+
process.exit(2);
|
|
137
|
+
}
|
|
138
|
+
process.stdout.write(`CML validation passed for ${name}\n${output}\n`);
|
|
139
|
+
process.exit(0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
(async () => {
|
|
143
|
+
if (!isInstalled()) await bootstrap();
|
|
144
|
+
runHook();
|
|
145
|
+
})();
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: adr-writer
|
|
3
|
-
description: Write and manage Architecture Decision Records (ADRs) following structured methodology with proper numbering, status tracking, governance, and conversational writing style.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# ADR Writer
|
|
7
|
-
|
|
8
|
-
Write Architecture Decision Records — the log of "architecturally significant" decisions affecting structure, non-functional characteristics, dependencies, interfaces, or construction techniques.
|
|
9
|
-
|
|
10
|
-
**Scope:** Create, update, and supersede ADRs. Does NOT implement the decisions themselves.
|
|
11
|
-
|
|
12
|
-
## Workflow
|
|
13
|
-
|
|
14
|
-
1. **Read the context.** `docs/architecture-characteristics.md` — every Decision is justified against these, with trade-offs framed as which are favored vs. sacrificed. If it is missing, read `.claude/skills/architecture-characteristic-writer/SKILL.md` and use its questions to gather the driving characteristics from the user before going on. Then read `docs/adr/README.md` for the decisions already recorded — one ADR's Consequences are often the next one's Context.
|
|
15
|
-
|
|
16
|
-
2. **Research before suggesting** — REQUIRED whenever a technology, vendor, product, version, or price is in play. Invoke `/research`; never propose options from memory, it goes stale. Confirm each option still exists and is supported today. Report in one pass, source and verdict per option.
|
|
17
|
-
|
|
18
|
-
3. **Challenge the proposal — be harsh.** REQUIRED whenever the user proposes a specific option. Do not rubber-stamp it:
|
|
19
|
-
- **State why** — the concrete reasons, not familiarity or preference.
|
|
20
|
-
- **Score it against each driving and implicit characteristic** — does it *serve*, *ignore*, or *actively harm* it?
|
|
21
|
-
- **Give a verdict** — suitable / suitable-with-trade-offs / unsuitable. If it conflicts with a driving characteristic, say so plainly and recommend the better fit, even when that is not what was asked for.
|
|
22
|
-
- Continue only once it survives, or the user overrides knowing the trade-off — record that override as a Consequence.
|
|
23
|
-
|
|
24
|
-
4. **Create the file.** From the repo root:
|
|
25
|
-
```bash
|
|
26
|
-
adr new -q -- "Use X for Z"
|
|
27
|
-
```
|
|
28
|
-
- `-q` is required on every call. Without it an ambiguous `-s` prompts on stdin and hangs the session; with it, that case errors instead.
|
|
29
|
-
- `adr new` prints nothing. Run `adr list` (last line is the new file) or read `docs/adr/README.md` — never guess the number or slug.
|
|
30
|
-
- Never use uppercase `STATUS` in a title. It is substituted after the title is inserted, so "Use STATUS codes" silently becomes "Use Accepted codes" and leaves the real Status unset. Lowercase is fine.
|
|
31
|
-
- Superseding — always the full padded stem, never a bare number. `-s` matches by substring: with `-q` an *ambiguous* match errors, but a single *wrong* match still succeeds silently. Writes the cross-link into both ADRs' `## Status`:
|
|
32
|
-
```bash
|
|
33
|
-
adr new -q -s 0002-use-mysql-for-persistence -- "…"
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
5. **Write the ADR.** Replace every `{…}` placeholder — nothing else. `adr new` has already written the number, title, `Accepted` status, and any supersede/link lines; leave all of them alone. Section Guidance below covers what each section needs. An Accepted ADR is immutable — to change it, write a new ADR that supersedes it.
|
|
37
|
-
|
|
38
|
-
## Writing Style
|
|
39
|
-
|
|
40
|
-
- **Calibrate against `references/adr-example.md`** — re-read it before drafting; it is the target for terseness. Cut any section markedly longer than its equivalent.
|
|
41
|
-
- **Match `references/adr-template.md` exactly.** Use only the sections it defines. No invented sections or fields; research citations go inline in the Decision.
|
|
42
|
-
|
|
43
|
-
## Section Guidance
|
|
44
|
-
|
|
45
|
-
- **Title** — reveal the *decision*, not the topic: "Use X for Z". Bad: "Gmail Polling for Ingestion". Good: "Use Cloud Scheduler Polling for Gmail Ingestion".
|
|
46
|
-
- **Context** — value-neutral, tensions explicit. No alternatives here, and no notes about what is *not* being decided.
|
|
47
|
-
- **Decision** — record the WHY, not the HOW — omit libraries, drivers, and wiring.
|
|
48
|
-
- **Consequences** — both `### Positive` and `### Negative` required. Consider team, infrastructure, cost, and one-way doors.
|
|
1
|
+
---
|
|
2
|
+
name: adr-writer
|
|
3
|
+
description: Write and manage Architecture Decision Records (ADRs) following structured methodology with proper numbering, status tracking, governance, and conversational writing style.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ADR Writer
|
|
7
|
+
|
|
8
|
+
Write Architecture Decision Records — the log of "architecturally significant" decisions affecting structure, non-functional characteristics, dependencies, interfaces, or construction techniques.
|
|
9
|
+
|
|
10
|
+
**Scope:** Create, update, and supersede ADRs. Does NOT implement the decisions themselves.
|
|
11
|
+
|
|
12
|
+
## Workflow
|
|
13
|
+
|
|
14
|
+
1. **Read the context.** `docs/architecture-characteristics.md` — every Decision is justified against these, with trade-offs framed as which are favored vs. sacrificed. If it is missing, read `.claude/skills/architecture-characteristic-writer/SKILL.md` and use its questions to gather the driving characteristics from the user before going on. Then read `docs/adr/README.md` for the decisions already recorded — one ADR's Consequences are often the next one's Context.
|
|
15
|
+
|
|
16
|
+
2. **Research before suggesting** — REQUIRED whenever a technology, vendor, product, version, or price is in play. Invoke `/research`; never propose options from memory, it goes stale. Confirm each option still exists and is supported today. Report in one pass, source and verdict per option.
|
|
17
|
+
|
|
18
|
+
3. **Challenge the proposal — be harsh.** REQUIRED whenever the user proposes a specific option. Do not rubber-stamp it:
|
|
19
|
+
- **State why** — the concrete reasons, not familiarity or preference.
|
|
20
|
+
- **Score it against each driving and implicit characteristic** — does it *serve*, *ignore*, or *actively harm* it?
|
|
21
|
+
- **Give a verdict** — suitable / suitable-with-trade-offs / unsuitable. If it conflicts with a driving characteristic, say so plainly and recommend the better fit, even when that is not what was asked for.
|
|
22
|
+
- Continue only once it survives, or the user overrides knowing the trade-off — record that override as a Consequence.
|
|
23
|
+
|
|
24
|
+
4. **Create the file.** From the repo root:
|
|
25
|
+
```bash
|
|
26
|
+
adr new -q -- "Use X for Z"
|
|
27
|
+
```
|
|
28
|
+
- `-q` is required on every call. Without it an ambiguous `-s` prompts on stdin and hangs the session; with it, that case errors instead.
|
|
29
|
+
- `adr new` prints nothing. Run `adr list` (last line is the new file) or read `docs/adr/README.md` — never guess the number or slug.
|
|
30
|
+
- Never use uppercase `STATUS` in a title. It is substituted after the title is inserted, so "Use STATUS codes" silently becomes "Use Accepted codes" and leaves the real Status unset. Lowercase is fine.
|
|
31
|
+
- Superseding — always the full padded stem, never a bare number. `-s` matches by substring: with `-q` an *ambiguous* match errors, but a single *wrong* match still succeeds silently. Writes the cross-link into both ADRs' `## Status`:
|
|
32
|
+
```bash
|
|
33
|
+
adr new -q -s 0002-use-mysql-for-persistence -- "…"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
5. **Write the ADR.** Replace every `{…}` placeholder — nothing else. `adr new` has already written the number, title, `Accepted` status, and any supersede/link lines; leave all of them alone. Section Guidance below covers what each section needs. An Accepted ADR is immutable — to change it, write a new ADR that supersedes it.
|
|
37
|
+
|
|
38
|
+
## Writing Style
|
|
39
|
+
|
|
40
|
+
- **Calibrate against `references/adr-example.md`** — re-read it before drafting; it is the target for terseness. Cut any section markedly longer than its equivalent.
|
|
41
|
+
- **Match `references/adr-template.md` exactly.** Use only the sections it defines. No invented sections or fields; research citations go inline in the Decision.
|
|
42
|
+
|
|
43
|
+
## Section Guidance
|
|
44
|
+
|
|
45
|
+
- **Title** — reveal the *decision*, not the topic: "Use X for Z". Bad: "Gmail Polling for Ingestion". Good: "Use Cloud Scheduler Polling for Gmail Ingestion".
|
|
46
|
+
- **Context** — value-neutral, tensions explicit. No alternatives here, and no notes about what is *not* being decided.
|
|
47
|
+
- **Decision** — record the WHY, not the HOW — omit libraries, drivers, and wiring.
|
|
48
|
+
- **Consequences** — both `### Positive` and `### Negative` required. Consider team, infrastructure, cost, and one-way doors.
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# ADR Example
|
|
2
|
-
|
|
3
|
-
Reference example of a well-written ADR.
|
|
4
|
-
|
|
5
|
-
Filename: docs/adr/0012-use-of-queues-for-asynchronous-messaging-between-order-and-downstream-services.md — heading number unpadded, filename four-digit padded.
|
|
6
|
-
|
|
7
|
-
```markdown
|
|
8
|
-
# 12: Use of Queues for Asynchronous Messaging Between Order and Downstream Services
|
|
9
|
-
|
|
10
|
-
## Status
|
|
11
|
-
Accepted
|
|
12
|
-
|
|
13
|
-
## Context
|
|
14
|
-
The trading service must inform downstream services (namely the notification and analytics services, for now) about new items available for sale and about all transactions. This can be done through synchronous messaging (using REST) or asynchronous messaging (using queues or topics).
|
|
15
|
-
|
|
16
|
-
## Decision
|
|
17
|
-
We will use queues for asynchronous messaging between the trading and downstream services.
|
|
18
|
-
|
|
19
|
-
Using queues makes the system more extensible, since each queue can deliver a different kind of message. Furthermore, since the trading service is acutely aware of any and all subscribers, adding a new consumer involves modifying it — which improves the security of the system.
|
|
20
|
-
|
|
21
|
-
## Consequences
|
|
22
|
-
|
|
23
|
-
### Positive
|
|
24
|
-
- System is more extensible via separate queues per message type
|
|
25
|
-
- Security improved — trading service controls subscriber access
|
|
26
|
-
|
|
27
|
-
### Negative
|
|
28
|
-
- Higher degree of coupling between services
|
|
29
|
-
- Queuing infrastructure must be provisioned and clustered for HA
|
|
30
|
-
- Adding new downstream services requires modifications to trading service
|
|
31
|
-
|
|
32
|
-
## Governance
|
|
33
|
-
- Code reviews on all queue consumer/producer changes
|
|
34
|
-
- Infrastructure monitoring for queue health and message delivery
|
|
35
|
-
|
|
1
|
+
# ADR Example
|
|
2
|
+
|
|
3
|
+
Reference example of a well-written ADR.
|
|
4
|
+
|
|
5
|
+
Filename: docs/adr/0012-use-of-queues-for-asynchronous-messaging-between-order-and-downstream-services.md — heading number unpadded, filename four-digit padded.
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
# 12: Use of Queues for Asynchronous Messaging Between Order and Downstream Services
|
|
9
|
+
|
|
10
|
+
## Status
|
|
11
|
+
Accepted
|
|
12
|
+
|
|
13
|
+
## Context
|
|
14
|
+
The trading service must inform downstream services (namely the notification and analytics services, for now) about new items available for sale and about all transactions. This can be done through synchronous messaging (using REST) or asynchronous messaging (using queues or topics).
|
|
15
|
+
|
|
16
|
+
## Decision
|
|
17
|
+
We will use queues for asynchronous messaging between the trading and downstream services.
|
|
18
|
+
|
|
19
|
+
Using queues makes the system more extensible, since each queue can deliver a different kind of message. Furthermore, since the trading service is acutely aware of any and all subscribers, adding a new consumer involves modifying it — which improves the security of the system.
|
|
20
|
+
|
|
21
|
+
## Consequences
|
|
22
|
+
|
|
23
|
+
### Positive
|
|
24
|
+
- System is more extensible via separate queues per message type
|
|
25
|
+
- Security improved — trading service controls subscriber access
|
|
26
|
+
|
|
27
|
+
### Negative
|
|
28
|
+
- Higher degree of coupling between services
|
|
29
|
+
- Queuing infrastructure must be provisioned and clustered for HA
|
|
30
|
+
- Adding new downstream services requires modifications to trading service
|
|
31
|
+
|
|
32
|
+
## Governance
|
|
33
|
+
- Code reviews on all queue consumer/producer changes
|
|
34
|
+
- Infrastructure monitoring for queue health and message delivery
|
|
35
|
+
|