@phuc1403/musketeer 0.4.0 → 0.6.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 +47 -32
- package/README.md +49 -49
- package/bin/musketeer.js +168 -79
- package/manifest.json +303 -292
- package/package.json +46 -46
- package/src/dotnet-scaffold-copier.js +72 -72
- package/src/provisioner/detect.js +113 -93
- package/src/self-update.js +77 -73
- package/template/.claude/hooks/block-unsafe-adr-title.cjs +72 -70
- package/template/.claude/hooks/init-adr-dir.cjs +153 -110
- package/template/.claude/hooks/inject-adr-env.cjs +83 -82
- package/template/.claude/hooks/lib/adr/command-scan.cjs +107 -0
- package/template/.claude/hooks/lib/characteristics/checker.cjs +357 -0
- package/template/.claude/hooks/sync-adr-toc.cjs +111 -111
- package/template/.claude/hooks/validate-characteristics-hook.cjs +66 -0
- package/template/.claude/skills/architecture-characteristic-writer/SKILL.md +197 -99
- package/template/.claude/skills/architecture-characteristic-writer/assets/worksheet-template.md +18 -29
- package/template/.claude/skills/architecture-characteristic-writer/references/characteristics-catalog.md +22 -88
- package/template/.claude/skills/architecture-characteristic-writer/scripts/ranking-table.cjs +171 -0
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/Debug/net10.0/__SolutionName__.Api.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/Debug/net10.0/__SolutionName__.Api.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/Debug/net10.0/__SolutionName__.Application.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/Debug/net10.0/__SolutionName__.Application.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/Debug/net10.0/__SolutionName__.Domain.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/Debug/net10.0/__SolutionName__.Domain.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/Debug/net10.0/__SolutionName__.Infrastructure.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/Debug/net10.0/__SolutionName__.Infrastructure.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/Debug/net10.0/__SolutionName__.Api.Tests.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/Debug/net10.0/__SolutionName__.Api.Tests.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/Debug/net10.0/__SolutionName__.Application.Tests.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/Debug/net10.0/__SolutionName__.Application.Tests.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/Debug/net10.0/__SolutionName__.Domain.Tests.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/Debug/net10.0/__SolutionName__.Domain.Tests.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/Debug/net10.0/__SolutionName__.Infrastructure.Tests.AssemblyInfo.cs +1 -1
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/Debug/net10.0/__SolutionName__.Infrastructure.Tests.AssemblyInfoInputs.cache +1 -1
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/Debug/net10.0/__SolutionName__.Api.assets.cache +0 -0
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/__SolutionName__.Api.csproj.nuget.dgspec.json +0 -1536
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/__SolutionName__.Api.csproj.nuget.g.props +0 -16
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/__SolutionName__.Api.csproj.nuget.g.targets +0 -2
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/project.assets.json +0 -559
- package/template/dotnet-scaffold/src/__SolutionName__.Api/obj/project.nuget.cache +0 -8
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/Debug/net10.0/__SolutionName__.Application.assets.cache +0 -0
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/__SolutionName__.Application.csproj.nuget.dgspec.json +0 -690
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/__SolutionName__.Application.csproj.nuget.g.props +0 -16
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/__SolutionName__.Application.csproj.nuget.g.targets +0 -2
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/project.assets.json +0 -376
- package/template/dotnet-scaffold/src/__SolutionName__.Application/obj/project.nuget.cache +0 -8
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/Debug/net10.0/__SolutionName__.Domain.assets.cache +0 -0
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/__SolutionName__.Domain.csproj.nuget.dgspec.json +0 -347
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/__SolutionName__.Domain.csproj.nuget.g.props +0 -16
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/__SolutionName__.Domain.csproj.nuget.g.targets +0 -2
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/project.assets.json +0 -353
- package/template/dotnet-scaffold/src/__SolutionName__.Domain/obj/project.nuget.cache +0 -8
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/Debug/net10.0/__SolutionName__.Infrastructure.assets.cache +0 -0
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/Debug/net10.0/__SolutionName__.Infrastructure.csproj.AssemblyReference.cache +0 -0
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/__SolutionName__.Infrastructure.csproj.nuget.dgspec.json +0 -1047
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/__SolutionName__.Infrastructure.csproj.nuget.g.props +0 -16
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/__SolutionName__.Infrastructure.csproj.nuget.g.targets +0 -7
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/project.assets.json +0 -858
- package/template/dotnet-scaffold/src/__SolutionName__.Infrastructure/obj/project.nuget.cache +0 -17
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/bin/Debug/net10.0/.msCoverageSourceRootsMapping___SolutionName__.Api.Tests +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/Debug/net10.0/__SolutionName__.Api.Tests.assets.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/Debug/net10.0/__SolutionName__.Api.Tests.csproj.AssemblyReference.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/__SolutionName__.Api.Tests.csproj.nuget.dgspec.json +0 -1908
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/__SolutionName__.Api.Tests.csproj.nuget.g.props +0 -27
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/__SolutionName__.Api.Tests.csproj.nuget.g.targets +0 -16
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/project.assets.json +0 -3283
- package/template/dotnet-scaffold/tests/__SolutionName__.Api.Tests/obj/project.nuget.cache +0 -60
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/bin/Debug/net10.0/.msCoverageSourceRootsMapping___SolutionName__.Application.Tests +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/Debug/net10.0/__SolutionName__.Application.Tests.assets.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/Debug/net10.0/__SolutionName__.Application.Tests.csproj.AssemblyReference.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/__SolutionName__.Application.Tests.csproj.nuget.dgspec.json +0 -1055
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/__SolutionName__.Application.Tests.csproj.nuget.g.props +0 -26
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/__SolutionName__.Application.Tests.csproj.nuget.g.targets +0 -11
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/project.assets.json +0 -1662
- package/template/dotnet-scaffold/tests/__SolutionName__.Application.Tests/obj/project.nuget.cache +0 -30
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/bin/Debug/net10.0/.msCoverageSourceRootsMapping___SolutionName__.Domain.Tests +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/Debug/net10.0/__SolutionName__.Domain.Tests.assets.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/Debug/net10.0/__SolutionName__.Domain.Tests.csproj.AssemblyReference.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/__SolutionName__.Domain.Tests.csproj.nuget.dgspec.json +0 -712
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/__SolutionName__.Domain.Tests.csproj.nuget.g.props +0 -26
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/__SolutionName__.Domain.Tests.csproj.nuget.g.targets +0 -11
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/project.assets.json +0 -1644
- package/template/dotnet-scaffold/tests/__SolutionName__.Domain.Tests/obj/project.nuget.cache +0 -30
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/bin/Debug/net10.0/.msCoverageSourceRootsMapping___SolutionName__.Infrastructure.Tests +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/Debug/net10.0/__SolutionName__.Infrastructure.Tests.assets.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/Debug/net10.0/__SolutionName__.Infrastructure.Tests.csproj.AssemblyReference.cache +0 -0
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/__SolutionName__.Infrastructure.Tests.csproj.nuget.dgspec.json +0 -1412
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/__SolutionName__.Infrastructure.Tests.csproj.nuget.g.props +0 -26
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/__SolutionName__.Infrastructure.Tests.csproj.nuget.g.targets +0 -13
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/project.assets.json +0 -2130
- package/template/dotnet-scaffold/tests/__SolutionName__.Infrastructure.Tests/obj/project.nuget.cache +0 -38
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@phuc1403/musketeer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Distributable custom Claude Code harness — one declarative command scaffolds a curated company of musketeers (skills/agents/hooks) into any project's .claude/.",
|
|
5
|
-
"type": "commonjs",
|
|
6
|
-
"bin": {
|
|
7
|
-
"musketeer": "bin/musketeer.js"
|
|
8
|
-
},
|
|
9
|
-
"engines": {
|
|
10
|
-
"node": ">=18"
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"test": "node --test"
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"bin",
|
|
17
|
-
"src",
|
|
18
|
-
"manifest.json",
|
|
19
|
-
"template",
|
|
20
|
-
"README.md",
|
|
21
|
-
"INSTALLATION.md",
|
|
22
|
-
"LICENSE"
|
|
23
|
-
],
|
|
24
|
-
"keywords": [
|
|
25
|
-
"claude",
|
|
26
|
-
"claude-code",
|
|
27
|
-
"harness",
|
|
28
|
-
"scaffolder",
|
|
29
|
-
"cli",
|
|
30
|
-
"skills",
|
|
31
|
-
"agents",
|
|
32
|
-
"hooks"
|
|
33
|
-
],
|
|
34
|
-
"license": "MIT",
|
|
35
|
-
"repository": {
|
|
36
|
-
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/phamhongphuc1403/musketeer.git"
|
|
38
|
-
},
|
|
39
|
-
"bugs": {
|
|
40
|
-
"url": "https://github.com/phamhongphuc1403/musketeer/issues"
|
|
41
|
-
},
|
|
42
|
-
"homepage": "https://github.com/phamhongphuc1403/musketeer#readme",
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@clack/prompts": "^0.7.0"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@phuc1403/musketeer",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Distributable custom Claude Code harness — one declarative command scaffolds a curated company of musketeers (skills/agents/hooks) into any project's .claude/.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"musketeer": "bin/musketeer.js"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=18"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "node --test"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"bin",
|
|
17
|
+
"src",
|
|
18
|
+
"manifest.json",
|
|
19
|
+
"template",
|
|
20
|
+
"README.md",
|
|
21
|
+
"INSTALLATION.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"claude",
|
|
26
|
+
"claude-code",
|
|
27
|
+
"harness",
|
|
28
|
+
"scaffolder",
|
|
29
|
+
"cli",
|
|
30
|
+
"skills",
|
|
31
|
+
"agents",
|
|
32
|
+
"hooks"
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/phamhongphuc1403/musketeer.git"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/phamhongphuc1403/musketeer/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/phamhongphuc1403/musketeer#readme",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@clack/prompts": "^0.7.0"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
function containedPath(root, candidate) {
|
|
7
|
-
const resolvedRoot = path.resolve(root);
|
|
8
|
-
const resolved = path.resolve(candidate);
|
|
9
|
-
if (resolved !== resolvedRoot && !resolved.startsWith(resolvedRoot + path.sep)) return null;
|
|
10
|
-
return resolved;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function substitute(text, token, replacement) {
|
|
14
|
-
return text.split(token).join(replacement);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Recursively copy every file under srcDir into stagingDir, substituting
|
|
19
|
-
* `token` with `replacement` in both path segments and file contents. Every
|
|
20
|
-
* computed destination path is validated to stay under `stagingDir` — rejects
|
|
21
|
-
* (throws) rather than writing outside it.
|
|
22
|
-
* @param {string} srcDir
|
|
23
|
-
* @param {string} stagingDir
|
|
24
|
-
* @param {string} token
|
|
25
|
-
* @param {string} replacement
|
|
26
|
-
*/
|
|
27
|
-
function copyTemplateWithTokenSubstitution(srcDir, stagingDir, token, replacement) {
|
|
28
|
-
walk(srcDir, stagingDir, stagingDir, token, replacement);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function walk(currentSrc, currentDest, stagingRoot, token, replacement) {
|
|
32
|
-
const entries = fs.readdirSync(currentSrc, { withFileTypes: true });
|
|
33
|
-
for (const entry of entries) {
|
|
34
|
-
const substitutedName = substitute(entry.name, token, replacement);
|
|
35
|
-
const srcPath = path.join(currentSrc, entry.name);
|
|
36
|
-
const destPath = containedPath(stagingRoot, path.join(currentDest, substitutedName));
|
|
37
|
-
if (!destPath) {
|
|
38
|
-
throw new Error(`copyTemplateWithTokenSubstitution: computed path escapes staging dir: "${substitutedName}"`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (entry.isDirectory()) {
|
|
42
|
-
fs.mkdirSync(destPath, { recursive: true });
|
|
43
|
-
walk(srcPath, destPath, stagingRoot, token, replacement);
|
|
44
|
-
} else if (entry.isFile()) {
|
|
45
|
-
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
46
|
-
const content = fs.readFileSync(srcPath, 'utf8');
|
|
47
|
-
fs.writeFileSync(destPath, substitute(content, token, replacement), 'utf8');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Move every top-level entry from stagingDir into projectDir. Pre-checks all
|
|
54
|
-
* names for collisions before moving any of them, then moves each via
|
|
55
|
-
* fs.renameSync (atomic per entry on the same filesystem). Throws instead of
|
|
56
|
-
* silently overwriting if a destination name already exists.
|
|
57
|
-
* @param {string} stagingDir
|
|
58
|
-
* @param {string} projectDir
|
|
59
|
-
*/
|
|
60
|
-
function promoteStagedScaffold(stagingDir, projectDir) {
|
|
61
|
-
const entries = fs.readdirSync(stagingDir, { withFileTypes: true });
|
|
62
|
-
for (const entry of entries) {
|
|
63
|
-
if (fs.existsSync(path.join(projectDir, entry.name))) {
|
|
64
|
-
throw new Error(`promoteStagedScaffold: "${entry.name}" already exists at destination`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
for (const entry of entries) {
|
|
68
|
-
fs.renameSync(path.join(stagingDir, entry.name), path.join(projectDir, entry.name));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
module.exports = { copyTemplateWithTokenSubstitution, promoteStagedScaffold };
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
function containedPath(root, candidate) {
|
|
7
|
+
const resolvedRoot = path.resolve(root);
|
|
8
|
+
const resolved = path.resolve(candidate);
|
|
9
|
+
if (resolved !== resolvedRoot && !resolved.startsWith(resolvedRoot + path.sep)) return null;
|
|
10
|
+
return resolved;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function substitute(text, token, replacement) {
|
|
14
|
+
return text.split(token).join(replacement);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Recursively copy every file under srcDir into stagingDir, substituting
|
|
19
|
+
* `token` with `replacement` in both path segments and file contents. Every
|
|
20
|
+
* computed destination path is validated to stay under `stagingDir` — rejects
|
|
21
|
+
* (throws) rather than writing outside it.
|
|
22
|
+
* @param {string} srcDir
|
|
23
|
+
* @param {string} stagingDir
|
|
24
|
+
* @param {string} token
|
|
25
|
+
* @param {string} replacement
|
|
26
|
+
*/
|
|
27
|
+
function copyTemplateWithTokenSubstitution(srcDir, stagingDir, token, replacement) {
|
|
28
|
+
walk(srcDir, stagingDir, stagingDir, token, replacement);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function walk(currentSrc, currentDest, stagingRoot, token, replacement) {
|
|
32
|
+
const entries = fs.readdirSync(currentSrc, { withFileTypes: true });
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
const substitutedName = substitute(entry.name, token, replacement);
|
|
35
|
+
const srcPath = path.join(currentSrc, entry.name);
|
|
36
|
+
const destPath = containedPath(stagingRoot, path.join(currentDest, substitutedName));
|
|
37
|
+
if (!destPath) {
|
|
38
|
+
throw new Error(`copyTemplateWithTokenSubstitution: computed path escapes staging dir: "${substitutedName}"`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (entry.isDirectory()) {
|
|
42
|
+
fs.mkdirSync(destPath, { recursive: true });
|
|
43
|
+
walk(srcPath, destPath, stagingRoot, token, replacement);
|
|
44
|
+
} else if (entry.isFile()) {
|
|
45
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
46
|
+
const content = fs.readFileSync(srcPath, 'utf8');
|
|
47
|
+
fs.writeFileSync(destPath, substitute(content, token, replacement), 'utf8');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Move every top-level entry from stagingDir into projectDir. Pre-checks all
|
|
54
|
+
* names for collisions before moving any of them, then moves each via
|
|
55
|
+
* fs.renameSync (atomic per entry on the same filesystem). Throws instead of
|
|
56
|
+
* silently overwriting if a destination name already exists.
|
|
57
|
+
* @param {string} stagingDir
|
|
58
|
+
* @param {string} projectDir
|
|
59
|
+
*/
|
|
60
|
+
function promoteStagedScaffold(stagingDir, projectDir) {
|
|
61
|
+
const entries = fs.readdirSync(stagingDir, { withFileTypes: true });
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (fs.existsSync(path.join(projectDir, entry.name))) {
|
|
64
|
+
throw new Error(`promoteStagedScaffold: "${entry.name}" already exists at destination`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
fs.renameSync(path.join(stagingDir, entry.name), path.join(projectDir, entry.name));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = { copyTemplateWithTokenSubstitution, promoteStagedScaffold };
|
|
@@ -1,93 +1,113 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const { spawnSync } = require('child_process');
|
|
6
|
-
|
|
7
|
-
// Map of secret prereq name → environment variable that satisfies it.
|
|
8
|
-
const SECRET_ENV = { 'anthropic-api-key': 'ANTHROPIC_API_KEY' };
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Default command runner. Captures stdout+stderr (java prints version to stderr)
|
|
12
|
-
* and never throws. Tests inject their own `ctx.run` to avoid touching the host.
|
|
13
|
-
* @param {string} cmd
|
|
14
|
-
* @returns {{code:number, stdout:string, stderr:string}}
|
|
15
|
-
*/
|
|
16
|
-
function defaultRun(cmd) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
// Map of secret prereq name → environment variable that satisfies it.
|
|
8
|
+
const SECRET_ENV = { 'anthropic-api-key': 'ANTHROPIC_API_KEY' };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Default command runner. Captures stdout+stderr (java prints version to stderr)
|
|
12
|
+
* and never throws. Tests inject their own `ctx.run` to avoid touching the host.
|
|
13
|
+
* @param {string} cmd
|
|
14
|
+
* @returns {{code:number, stdout:string, stderr:string}}
|
|
15
|
+
*/
|
|
16
|
+
function defaultRun(cmd) {
|
|
17
|
+
// An array is an argv, spawned without a shell. Windows quoting cannot be
|
|
18
|
+
// trusted to survive a nested `bash -lc "..."` inside cmd.exe, so probes that
|
|
19
|
+
// need a shell of their own pass their arguments already separated.
|
|
20
|
+
const r = Array.isArray(cmd)
|
|
21
|
+
? spawnSync(cmd[0], cmd.slice(1), { encoding: 'utf8', windowsHide: true })
|
|
22
|
+
: spawnSync(cmd, { shell: true, encoding: 'utf8', windowsHide: true });
|
|
23
|
+
return {
|
|
24
|
+
code: typeof r.status === 'number' ? r.status : 1,
|
|
25
|
+
stdout: r.stdout || '',
|
|
26
|
+
stderr: r.stderr || '',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Probe for a prereq whose manifest entry sets `detectShell: "bash"`.
|
|
32
|
+
* adr-tools ships as bash scripts living in Git's own `usr/bin`, which Windows
|
|
33
|
+
* cannot see or execute: `adr config` fails there while working fine in Git
|
|
34
|
+
* Bash. Probing through the same shell the ADR hooks use stops muster reporting
|
|
35
|
+
* a tool that is installed as missing.
|
|
36
|
+
* @param {string} detect
|
|
37
|
+
* @returns {string[]} argv
|
|
38
|
+
*/
|
|
39
|
+
function bashProbe(detect) {
|
|
40
|
+
return [process.env.CLAUDE_CODE_GIT_BASH_PATH || 'bash', '-lc', detect];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Extract a numeric version tuple from arbitrary command output. */
|
|
44
|
+
function parseVersion(text) {
|
|
45
|
+
const m = String(text).match(/(\d+)(?:\.(\d+))?(?:\.(\d+))?/);
|
|
46
|
+
if (!m) return null;
|
|
47
|
+
return [Number(m[1] || 0), Number(m[2] || 0), Number(m[3] || 0)];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** found >= min ? (min may be "18" or "3.8") */
|
|
51
|
+
function versionGte(found, min) {
|
|
52
|
+
if (!found) return false;
|
|
53
|
+
const want = parseVersion(min) || [0, 0, 0];
|
|
54
|
+
for (let i = 0; i < 3; i++) {
|
|
55
|
+
if (found[i] > want[i]) return true;
|
|
56
|
+
if (found[i] < want[i]) return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Detect whether a single prereq is satisfied. Detection NEVER mutates the host.
|
|
63
|
+
* @param {string} name prereq id
|
|
64
|
+
* @param {object} prereq manifest prereq entry
|
|
65
|
+
* @param {object} ctx { run, platform, projectDir }
|
|
66
|
+
* @returns {{name:string, present:boolean, version:?string, reason:string}}
|
|
67
|
+
*/
|
|
68
|
+
function detectPrereq(name, prereq, ctx) {
|
|
69
|
+
const run = ctx.run || defaultRun;
|
|
70
|
+
|
|
71
|
+
switch (prereq.kind) {
|
|
72
|
+
case 'secret': {
|
|
73
|
+
const envVar = SECRET_ENV[name];
|
|
74
|
+
const present = !!(envVar && process.env[envVar]);
|
|
75
|
+
return { name, present, version: null, reason: present ? `${envVar} set` : `${envVar} unset` };
|
|
76
|
+
}
|
|
77
|
+
case 'venv': {
|
|
78
|
+
const dir = path.join(ctx.projectDir, '.claude', 'skills', '.venv');
|
|
79
|
+
const present = fs.existsSync(dir);
|
|
80
|
+
return { name, present, version: null, reason: present ? 'venv exists' : 'venv missing' };
|
|
81
|
+
}
|
|
82
|
+
case 'mcp': {
|
|
83
|
+
const r = run('claude mcp list');
|
|
84
|
+
const present = r.code === 0 && /playwright/i.test(r.stdout + r.stderr);
|
|
85
|
+
return { name, present, version: null, reason: present ? 'mcp registered' : 'mcp not registered' };
|
|
86
|
+
}
|
|
87
|
+
case 'note':
|
|
88
|
+
// Nothing to probe directly; satisfied iff its `needs` are (handled by caller).
|
|
89
|
+
return { name, present: false, version: null, reason: 'note (self-bootstrap)' };
|
|
90
|
+
default: {
|
|
91
|
+
// package
|
|
92
|
+
if (!prereq.detect) return { name, present: false, version: null, reason: 'no detect command' };
|
|
93
|
+
let r = run(prereq.detectShell === 'bash' ? bashProbe(prereq.detect) : prereq.detect);
|
|
94
|
+
// A shell-script tool invisible to Windows still answers through Git Bash.
|
|
95
|
+
if (r.code !== 0 && prereq.detectShell === 'bash') r = run(prereq.detect);
|
|
96
|
+
if (r.code !== 0 && name === 'python') r = run('python3 --version'); // unix fallback
|
|
97
|
+
const out = r.stdout + r.stderr;
|
|
98
|
+
const ver = parseVersion(out);
|
|
99
|
+
if (r.code !== 0) return { name, present: false, version: null, reason: 'not found' };
|
|
100
|
+
if (prereq.minVersion && !versionGte(ver, prereq.minVersion)) {
|
|
101
|
+
return {
|
|
102
|
+
name,
|
|
103
|
+
present: false,
|
|
104
|
+
version: ver ? ver.join('.') : null,
|
|
105
|
+
reason: `version ${ver ? ver.join('.') : '?'} < required ${prereq.minVersion}`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return { name, present: true, version: ver ? ver.join('.') : null, reason: 'present' };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = { detectPrereq, parseVersion, versionGte, defaultRun, bashProbe, SECRET_ENV };
|
package/src/self-update.js
CHANGED
|
@@ -1,73 +1,77 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Self-update gate for `musketeer muster`. Before the picker applies the bundled
|
|
4
|
-
// template, make sure the CLI is at the latest PUBLISHED version — otherwise
|
|
5
|
-
// "muster" would refresh installed skills to a stale package's template.
|
|
6
|
-
//
|
|
7
|
-
// When behind: promote (npm i -g @latest), then re-exec `musketeer muster` so the
|
|
8
|
-
// picker runs under the freshly-installed template. A running Node process can't
|
|
9
|
-
// reliably hot-swap its own package files mid-run, so re-exec is the safe path.
|
|
10
|
-
//
|
|
11
|
-
// Guards:
|
|
12
|
-
// MUSKETEER_REEXEC=1 set on the child so it never re-checks (no loop)
|
|
13
|
-
// MUSKETEER_NO_SELF_UPDATE=1 user opt-out (offline / pinned version)
|
|
14
|
-
|
|
15
|
-
const { spawnSync } = require('child_process');
|
|
16
|
-
const { fetchLatest, compareVersions, defaultRun } = require('./promote');
|
|
17
|
-
const pkg = require('../package.json');
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Decide whether muster should self-update first. Pure — injectable exec/env.
|
|
21
|
-
* @param {{exec?:Function, current?:string, name?:string, env?:object}} [o]
|
|
22
|
-
* @returns {{action:'proceed'|'update', latest:?string}}
|
|
23
|
-
*/
|
|
24
|
-
function decide(o = {}) {
|
|
25
|
-
const exec = o.exec || defaultRun;
|
|
26
|
-
const current = o.current || pkg.version;
|
|
27
|
-
const name = o.name || pkg.name;
|
|
28
|
-
const env = o.env || process.env;
|
|
29
|
-
|
|
30
|
-
if (env.MUSKETEER_REEXEC === '1' || env.MUSKETEER_NO_SELF_UPDATE === '1') {
|
|
31
|
-
return { action: 'proceed', latest: null };
|
|
32
|
-
}
|
|
33
|
-
const latest = fetchLatest(exec, name);
|
|
34
|
-
if (!latest) return { action: 'proceed', latest: null }; // offline / unknown — proceed as-is
|
|
35
|
-
if (compareVersions(latest, current) <= 0) return { action: 'proceed', latest }; // already latest
|
|
36
|
-
return { action: 'update', latest };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Ensure the CLI is latest before muster applies the template.
|
|
41
|
-
* @param {object} [io] injectable { log, exec, spawn, env, name, current } for tests
|
|
42
|
-
* @returns {?number} an exit code if it re-exec'd a fresh muster (caller should
|
|
43
|
-
* exit with it); null to mean "proceed in-process".
|
|
44
|
-
*/
|
|
45
|
-
function ensureLatest(io = {}) {
|
|
46
|
-
const log = io.log || ((m) => process.stdout.write(m + '\n'));
|
|
47
|
-
const exec = io.exec || defaultRun;
|
|
48
|
-
const spawn = io.spawn || spawnSync;
|
|
49
|
-
const env = io.env || process.env;
|
|
50
|
-
const name = io.name || pkg.name;
|
|
51
|
-
const current = io.current || pkg.version;
|
|
52
|
-
|
|
53
|
-
const d = decide({ exec, current, name, env });
|
|
54
|
-
if (d.action === 'proceed') return null;
|
|
55
|
-
|
|
56
|
-
log(`Updating musketeer ${current} → ${d.latest} before muster…`);
|
|
57
|
-
const ins = exec(`npm i -g ${name}@latest`);
|
|
58
|
-
if (ins.code !== 0) {
|
|
59
|
-
log('Self-update failed — continuing with the current version.');
|
|
60
|
-
if (ins.stderr) log(ins.stderr.trim());
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Re-exec the now-latest binary's muster, inheriting the TTY for the picker.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Self-update gate for `musketeer muster`. Before the picker applies the bundled
|
|
4
|
+
// template, make sure the CLI is at the latest PUBLISHED version — otherwise
|
|
5
|
+
// "muster" would refresh installed skills to a stale package's template.
|
|
6
|
+
//
|
|
7
|
+
// When behind: promote (npm i -g @latest), then re-exec `musketeer muster` so the
|
|
8
|
+
// picker runs under the freshly-installed template. A running Node process can't
|
|
9
|
+
// reliably hot-swap its own package files mid-run, so re-exec is the safe path.
|
|
10
|
+
//
|
|
11
|
+
// Guards:
|
|
12
|
+
// MUSKETEER_REEXEC=1 set on the child so it never re-checks (no loop)
|
|
13
|
+
// MUSKETEER_NO_SELF_UPDATE=1 user opt-out (offline / pinned version)
|
|
14
|
+
|
|
15
|
+
const { spawnSync } = require('child_process');
|
|
16
|
+
const { fetchLatest, compareVersions, defaultRun } = require('./promote');
|
|
17
|
+
const pkg = require('../package.json');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Decide whether muster should self-update first. Pure — injectable exec/env.
|
|
21
|
+
* @param {{exec?:Function, current?:string, name?:string, env?:object}} [o]
|
|
22
|
+
* @returns {{action:'proceed'|'update', latest:?string}}
|
|
23
|
+
*/
|
|
24
|
+
function decide(o = {}) {
|
|
25
|
+
const exec = o.exec || defaultRun;
|
|
26
|
+
const current = o.current || pkg.version;
|
|
27
|
+
const name = o.name || pkg.name;
|
|
28
|
+
const env = o.env || process.env;
|
|
29
|
+
|
|
30
|
+
if (env.MUSKETEER_REEXEC === '1' || env.MUSKETEER_NO_SELF_UPDATE === '1') {
|
|
31
|
+
return { action: 'proceed', latest: null };
|
|
32
|
+
}
|
|
33
|
+
const latest = fetchLatest(exec, name);
|
|
34
|
+
if (!latest) return { action: 'proceed', latest: null }; // offline / unknown — proceed as-is
|
|
35
|
+
if (compareVersions(latest, current) <= 0) return { action: 'proceed', latest }; // already latest
|
|
36
|
+
return { action: 'update', latest };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Ensure the CLI is latest before muster applies the template.
|
|
41
|
+
* @param {object} [io] injectable { log, exec, spawn, env, name, current } for tests
|
|
42
|
+
* @returns {?number} an exit code if it re-exec'd a fresh muster (caller should
|
|
43
|
+
* exit with it); null to mean "proceed in-process".
|
|
44
|
+
*/
|
|
45
|
+
function ensureLatest(io = {}) {
|
|
46
|
+
const log = io.log || ((m) => process.stdout.write(m + '\n'));
|
|
47
|
+
const exec = io.exec || defaultRun;
|
|
48
|
+
const spawn = io.spawn || spawnSync;
|
|
49
|
+
const env = io.env || process.env;
|
|
50
|
+
const name = io.name || pkg.name;
|
|
51
|
+
const current = io.current || pkg.version;
|
|
52
|
+
|
|
53
|
+
const d = decide({ exec, current, name, env });
|
|
54
|
+
if (d.action === 'proceed') return null;
|
|
55
|
+
|
|
56
|
+
log(`Updating musketeer ${current} → ${d.latest} before muster…`);
|
|
57
|
+
const ins = exec(`npm i -g ${name}@latest`);
|
|
58
|
+
if (ins.code !== 0) {
|
|
59
|
+
log('Self-update failed — continuing with the current version.');
|
|
60
|
+
if (ins.stderr) log(ins.stderr.trim());
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Re-exec the now-latest binary's muster, inheriting the TTY for the picker.
|
|
65
|
+
// The caller's flags come along: dropping them here would send a scripted
|
|
66
|
+
// `muster --keep` back to the interactive picker, which is the one place it
|
|
67
|
+
// cannot run.
|
|
68
|
+
const args = io.args || [];
|
|
69
|
+
const r = spawn('musketeer', ['muster', ...args], {
|
|
70
|
+
stdio: 'inherit',
|
|
71
|
+
shell: true,
|
|
72
|
+
env: { ...env, MUSKETEER_REEXEC: '1' },
|
|
73
|
+
});
|
|
74
|
+
return typeof r.status === 'number' ? r.status : 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { decide, ensureLatest };
|