bmad-plus 0.12.1 → 0.13.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/CHANGELOG.md +637 -580
- package/README.md +123 -120
- package/osint-agent-package/agents/osint-investigator.md +12 -0
- package/osint-agent-package/skills/bmad-osint-investigate/osint/SKILL.md +491 -482
- package/osint-agent-package/skills/bmad-osint-investigate/osint/assets/dossier-template.md +126 -126
- package/osint-agent-package/skills/bmad-osint-investigate/osint/assets/lawful-basis-record.md +48 -48
- package/osint-agent-package/skills/bmad-osint-investigate/osint/references/content-extraction.md +100 -100
- package/osint-agent-package/skills/bmad-osint-investigate/osint/references/gdpr-osint.md +48 -48
- package/osint-agent-package/skills/bmad-osint-investigate/osint/references/platforms.md +130 -130
- package/osint-agent-package/skills/bmad-osint-investigate/osint/references/psychoprofile.md +69 -69
- package/osint-agent-package/skills/bmad-osint-investigate/osint/references/tools.md +281 -281
- package/osint-agent-package/skills/bmad-osint-investigate/osint/scripts/mcp-client.py +136 -136
- package/package.json +106 -91
- package/readme-international/README.de.md +625 -594
- package/readme-international/README.es.md +642 -611
- package/readme-international/README.fr.md +640 -609
- package/src/bmad-plus/agents/agent-orchestrator/SKILL.md +2 -0
- package/src/bmad-plus/agents/agent-shadow/SKILL.md +18 -0
- package/src/bmad-plus/data/role-triggers.yaml +52 -0
- package/src/bmad-plus/module.yaml +333 -283
- package/src/bmad-plus/packs/pack-animated/animated-website-agent.md +325 -325
- package/src/bmad-plus/packs/pack-animated/templates/animated-website-workflow.md +55 -55
- package/src/bmad-plus/packs/pack-backup/backup-agent.md +71 -71
- package/src/bmad-plus/packs/pack-backup/templates/backup-workflow.md +51 -51
- package/src/bmad-plus/packs/pack-dev-studio/README.md +162 -162
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/analyst-agent.md +73 -73
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/document-project.md +61 -61
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/domain-research.md +95 -95
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/market-research.md +95 -95
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/prfaq.md +134 -134
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/product-brief.md +80 -80
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/tech-writer-agent.md +73 -73
- package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/technical-research.md +95 -95
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/architect-agent.md +73 -73
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/create-architecture.md +73 -73
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/create-epics-stories.md +92 -92
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/generate-project-context.md +80 -80
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/implementation-readiness.md +90 -90
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-01-init.md +153 -153
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-01b-continue.md +173 -173
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-02-context.md +224 -224
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-03-starter.md +329 -329
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-04-decisions.md +318 -318
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-05-patterns.md +359 -359
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-06-structure.md +379 -379
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-07-validation.md +361 -361
- package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-08-complete.md +81 -81
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/checkpoint-preview.md +67 -67
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-01-gather-context.md +85 -85
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-02-review.md +35 -35
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-03-triage.md +49 -49
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-04-present.md +131 -131
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review.md +89 -89
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/correct-course.md +300 -300
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/create-story.md +428 -428
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-agent.md +73 -73
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-story-checklist.md +80 -80
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-story.md +484 -484
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/investigate.md +193 -193
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/qa-e2e-tests.md +175 -175
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/quick-dev.md +110 -110
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/retrospective.md +1511 -1511
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/sprint-planning.md +298 -298
- package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/sprint-status.md +296 -296
- package/src/bmad-plus/packs/pack-dev-studio/categories/planning/create-prd.md +29 -29
- package/src/bmad-plus/packs/pack-dev-studio/categories/planning/create-ux-design.md +74 -74
- package/src/bmad-plus/packs/pack-dev-studio/categories/planning/edit-prd.md +29 -29
- package/src/bmad-plus/packs/pack-dev-studio/categories/planning/pm-agent.md +73 -73
- package/src/bmad-plus/packs/pack-dev-studio/categories/planning/prd.md +89 -89
- package/src/bmad-plus/packs/pack-dev-studio/categories/planning/ux-designer-agent.md +73 -73
- package/src/bmad-plus/packs/pack-dev-studio/categories/planning/validate-prd.md +29 -29
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/advanced-elicitation.md +141 -141
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/adversarial-review.md +37 -37
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/bmad-help.md +75 -75
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/brainstorming.md +6 -6
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/customize.md +110 -110
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/distillator.md +176 -176
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/edge-case-hunter.md +67 -67
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/editorial-review-prose.md +86 -86
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/editorial-review-structure.md +179 -179
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/index-docs.md +66 -66
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/party-mode.md +127 -127
- package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/shard-doc.md +105 -105
- package/src/bmad-plus/packs/pack-dev-studio/dev-studio-orchestrator.md +120 -120
- package/src/bmad-plus/packs/pack-dev-studio/shared/architecture-decision-template.md +12 -12
- package/src/bmad-plus/packs/pack-dev-studio/shared/bwml-spec.md +328 -328
- package/src/bmad-plus/packs/pack-dev-studio/shared/module-help.csv +32 -32
- package/src/bmad-plus/packs/pack-dev-studio/upstream-sync.yaml +81 -81
- package/src/bmad-plus/packs/pack-seo/SKILL.md +171 -171
- package/src/bmad-plus/packs/pack-seo/checklist.md +140 -140
- package/src/bmad-plus/packs/pack-seo/pagespeed-playbook.md +320 -320
- package/src/bmad-plus/packs/pack-seo/ref/audit-schema.json +187 -187
- package/src/bmad-plus/packs/pack-seo/ref/cwv-thresholds.md +87 -87
- package/src/bmad-plus/packs/pack-seo/ref/eeat-criteria.md +123 -123
- package/src/bmad-plus/packs/pack-seo/ref/geo-signals.md +167 -167
- package/src/bmad-plus/packs/pack-seo/ref/hreflang-rules.md +153 -153
- package/src/bmad-plus/packs/pack-seo/ref/quality-gates.md +133 -133
- package/src/bmad-plus/packs/pack-seo/ref/schema-catalog.md +91 -91
- package/src/bmad-plus/packs/pack-seo/ref/schema-templates.json +356 -356
- package/src/bmad-plus/packs/pack-seo/requirements.txt +17 -0
- package/src/bmad-plus/packs/pack-seo/scripts/seo_apis.py +456 -0
- package/src/bmad-plus/packs/pack-seo/scripts/seo_crawl.py +359 -0
- package/src/bmad-plus/packs/pack-seo/scripts/seo_fetch.py +303 -0
- package/src/bmad-plus/packs/pack-seo/scripts/seo_parse.py +255 -0
- package/src/bmad-plus/packs/pack-seo/scripts/seo_report.py +409 -0
- package/src/bmad-plus/packs/pack-seo/scripts/seo_screenshot.py +202 -0
- package/src/bmad-plus/packs/pack-seo/seo-chief.md +294 -294
- package/src/bmad-plus/packs/pack-seo/seo-judge.md +241 -241
- package/src/bmad-plus/packs/pack-seo/seo-scout.md +171 -171
- package/src/bmad-plus/packs/pack-seo/templates/seo-audit-workflow.md +241 -241
- package/src/bmad-plus/packs/pack-shield/README.md +6 -6
- package/src/bmad-plus/packs/pack-shield/SKILL.md +2 -2
- package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/csrd-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/section508-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/wcag-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/ai-governance/eu-ai-act-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/ai-governance/iso42001-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/ai-governance/nist-ai-rmf-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/cis-controls-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/ism-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/iso27001-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nis2-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nist-800-53-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nist-csf-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/defense-export/cmmc-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/defense-export/ear-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/defense-export/itar-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/defense-export/tsa-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/dora-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/fedramp-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/hipaa-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/pci-dss-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/soc2-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/swift-csp-agent.md +11 -11
- package/src/bmad-plus/packs/pack-shield/shield-orchestrator.md +1 -1
- package/src/bmad-plus/skills/bmad-plus-autopilot/SKILL.md +1 -1
- package/tools/bmad-plus-npx.js +4 -2
- package/tools/build/adapters.config.js +60 -51
- package/tools/build/check-counts.js +626 -0
- package/tools/build/check-install-contract.js +298 -0
- package/tools/build/generate-adapters.js +252 -56
- package/tools/build/generate.js +187 -10
- package/tools/build/generated-adapters/.codex/AGENTS.md +20 -7
- package/tools/build/generated-adapters/.cursor/rules/bmad-plus.mdc +20 -7
- package/tools/build/generated-adapters/.opencode/AGENTS.md +20 -7
- package/tools/build/generated-adapters/AGENTS.md +20 -7
- package/tools/build/generated-adapters/CLAUDE.md +20 -7
- package/tools/build/generated-adapters/CONVENTIONS.md +20 -7
- package/tools/build/generated-adapters/GEMINI.md +20 -7
- package/tools/build/module.template.yaml +82 -0
- package/tools/cli/bmad-plus-cli.js +16 -1
- package/tools/cli/commands/autoconfig.js +470 -470
- package/tools/cli/commands/doctor.js +205 -233
- package/tools/cli/commands/install.js +543 -501
- package/tools/cli/commands/memory-journal-cmd.js +311 -311
- package/tools/cli/commands/memory.js +195 -195
- package/tools/cli/commands/scan.js +348 -348
- package/tools/cli/commands/uninstall.js +209 -101
- package/tools/cli/commands/update-check.js +31 -0
- package/tools/cli/commands/update-policy.js +39 -0
- package/tools/cli/commands/update.js +123 -134
- package/tools/cli/i18n.js +905 -845
- package/tools/cli/lib/README-memory-journal.md +125 -125
- package/tools/cli/lib/ide-config.js +10 -259
- package/tools/cli/lib/install-manifest.js +17 -0
- package/tools/cli/lib/installed-adapters.js +89 -0
- package/tools/cli/lib/npm-runner.js +177 -0
- package/tools/cli/lib/pack-copy.js +62 -66
- package/tools/cli/lib/packs.js +437 -3
- package/tools/cli/lib/python-provision.js +508 -508
- package/tools/cli/lib/stack-detect.js +102 -102
- package/tools/cli/lib/update-check.js +153 -0
- package/tools/cli/lib/update-dispatch.js +182 -0
- package/tools/cli/lib/update-policy.js +90 -0
- package/tools/cli/lib/update-transaction.js +334 -0
- package/tools/cli/lib/validate.js +50 -50
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/** Run npm through Node with bounded output and no shell interpolation. */
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const childProcess = require('node:child_process');
|
|
5
|
+
|
|
6
|
+
function resolveNpmCli({
|
|
7
|
+
env = process.env,
|
|
8
|
+
execPath = process.execPath,
|
|
9
|
+
platform = process.platform,
|
|
10
|
+
realpath = fs.realpathSync,
|
|
11
|
+
isFile = (file) => fs.statSync(file).isFile(),
|
|
12
|
+
} = {}) {
|
|
13
|
+
const paths = platform === 'win32' ? path.win32 : path.posix;
|
|
14
|
+
const searchPath = Object.entries(env).find(([key]) => key.toLowerCase() === 'path')?.[1] || '';
|
|
15
|
+
const directories = searchPath.split(platform === 'win32' ? ';' : ':').filter(Boolean);
|
|
16
|
+
const nodeDir = paths.dirname(execPath);
|
|
17
|
+
const candidates = [
|
|
18
|
+
env.npm_execpath,
|
|
19
|
+
paths.join(nodeDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
20
|
+
paths.resolve(nodeDir, '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
21
|
+
...directories.flatMap((dir) => [
|
|
22
|
+
paths.join(dir, 'npm'),
|
|
23
|
+
paths.join(dir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
24
|
+
]),
|
|
25
|
+
];
|
|
26
|
+
for (const candidate of candidates) {
|
|
27
|
+
if (!candidate) continue;
|
|
28
|
+
try {
|
|
29
|
+
const resolved = realpath(candidate);
|
|
30
|
+
if (paths.basename(resolved).toLowerCase() === 'npm-cli.js' && isFile(resolved))
|
|
31
|
+
return resolved;
|
|
32
|
+
} catch {
|
|
33
|
+
/* Try the next standard npm installation location. */
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
throw new Error('npm-cli.js was not found. Install Node.js with npm or repair its PATH.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Injectable process boundary; tests never need to fetch a package. */
|
|
40
|
+
function createNpmRunner({
|
|
41
|
+
spawn = childProcess.spawn,
|
|
42
|
+
resolveCli = resolveNpmCli,
|
|
43
|
+
platform = process.platform,
|
|
44
|
+
execPath = process.execPath,
|
|
45
|
+
kill = process.kill.bind(process),
|
|
46
|
+
} = {}) {
|
|
47
|
+
return async function runNpm(
|
|
48
|
+
args,
|
|
49
|
+
{ cwd, timeout = 6000, env = process.env, maxBuffer = 1024 * 1024, signal } = {}
|
|
50
|
+
) {
|
|
51
|
+
if (!Array.isArray(args) || args.some((arg) => typeof arg !== 'string' || arg.includes('\0'))) {
|
|
52
|
+
throw new Error('npm arguments must be an array of strings without NUL bytes.');
|
|
53
|
+
}
|
|
54
|
+
if (
|
|
55
|
+
!Number.isSafeInteger(timeout) ||
|
|
56
|
+
timeout <= 0 ||
|
|
57
|
+
!Number.isSafeInteger(maxBuffer) ||
|
|
58
|
+
maxBuffer <= 0
|
|
59
|
+
) {
|
|
60
|
+
throw new Error('npm timeout and maxBuffer must be positive integers.');
|
|
61
|
+
}
|
|
62
|
+
if (signal?.aborted)
|
|
63
|
+
throw Object.assign(new Error('npm operation was cancelled.'), { code: 'ABORT_ERR' });
|
|
64
|
+
const cli = resolveCli({ env, execPath, platform });
|
|
65
|
+
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
let child;
|
|
68
|
+
try {
|
|
69
|
+
child = spawn(execPath, [cli, ...args], {
|
|
70
|
+
cwd,
|
|
71
|
+
env,
|
|
72
|
+
shell: false,
|
|
73
|
+
windowsHide: true,
|
|
74
|
+
detached: platform !== 'win32',
|
|
75
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
76
|
+
});
|
|
77
|
+
} catch (error) {
|
|
78
|
+
reject(new Error('Could not start npm.', { cause: error }));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let settled = false;
|
|
82
|
+
let bytes = 0;
|
|
83
|
+
const stdout = [];
|
|
84
|
+
const stderr = [];
|
|
85
|
+
let timer;
|
|
86
|
+
const finish = (error, output) => {
|
|
87
|
+
if (settled) return;
|
|
88
|
+
settled = true;
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
signal?.removeEventListener('abort', abort);
|
|
91
|
+
if (error) {
|
|
92
|
+
error.stdout = Buffer.concat(stdout).toString('utf8');
|
|
93
|
+
error.stderr = Buffer.concat(stderr).toString('utf8');
|
|
94
|
+
const diagnostic = [error.stdout.trim(), error.stderr.trim()].filter(Boolean).join('\n');
|
|
95
|
+
if (diagnostic) error.message += '\n' + diagnostic;
|
|
96
|
+
reject(error);
|
|
97
|
+
} else resolve(output);
|
|
98
|
+
};
|
|
99
|
+
const killChild = () => {
|
|
100
|
+
try {
|
|
101
|
+
child.kill('SIGKILL');
|
|
102
|
+
} catch {
|
|
103
|
+
/* The process may already have exited. */
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const stop = () => {
|
|
107
|
+
if (!Number.isInteger(child.pid) || child.pid <= 0) return killChild();
|
|
108
|
+
if (platform !== 'win32') {
|
|
109
|
+
// A detached npm owns this process group, including its updater child.
|
|
110
|
+
try {
|
|
111
|
+
kill(-child.pid, 'SIGKILL');
|
|
112
|
+
} catch {
|
|
113
|
+
killChild();
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const terminator = spawn('taskkill.exe', ['/pid', String(child.pid), '/t', '/f'], {
|
|
119
|
+
shell: false,
|
|
120
|
+
windowsHide: true,
|
|
121
|
+
stdio: 'ignore',
|
|
122
|
+
env,
|
|
123
|
+
});
|
|
124
|
+
terminator.once('error', killChild);
|
|
125
|
+
terminator.once('close', (code) => {
|
|
126
|
+
if (code !== 0) killChild();
|
|
127
|
+
});
|
|
128
|
+
} catch {
|
|
129
|
+
killChild();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const cancel = (message, code) => {
|
|
133
|
+
if (settled) return;
|
|
134
|
+
stop();
|
|
135
|
+
finish(Object.assign(new Error(message), { code }));
|
|
136
|
+
};
|
|
137
|
+
const abort = () =>
|
|
138
|
+
cancel('npm operation was cancelled; child termination requested.', 'ABORT_ERR');
|
|
139
|
+
const collect = (chunk, save) => {
|
|
140
|
+
if (settled) return;
|
|
141
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
142
|
+
bytes += buffer.length;
|
|
143
|
+
if (bytes > maxBuffer)
|
|
144
|
+
return cancel('npm output exceeded the configured buffer limit.', 'ENOBUFS');
|
|
145
|
+
(save ? stdout : stderr).push(buffer);
|
|
146
|
+
};
|
|
147
|
+
child.stdout.on('data', (chunk) => collect(chunk, true));
|
|
148
|
+
child.stderr.on('data', (chunk) => collect(chunk, false));
|
|
149
|
+
child.once('error', (error) => finish(new Error('Could not run npm.', { cause: error })));
|
|
150
|
+
child.once('close', (code, exitSignal) => {
|
|
151
|
+
if (code !== 0 || exitSignal) {
|
|
152
|
+
finish(
|
|
153
|
+
Object.assign(new Error(`npm exited unsuccessfully (${exitSignal || code}).`), {
|
|
154
|
+
code: 'NPM_EXIT',
|
|
155
|
+
exitCode: code,
|
|
156
|
+
signal: exitSignal,
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
} else finish(null, Buffer.concat(stdout).toString('utf8'));
|
|
160
|
+
});
|
|
161
|
+
timer = setTimeout(
|
|
162
|
+
() =>
|
|
163
|
+
cancel(
|
|
164
|
+
`npm exceeded its ${timeout} ms deadline; child termination requested.`,
|
|
165
|
+
'ETIMEDOUT'
|
|
166
|
+
),
|
|
167
|
+
timeout
|
|
168
|
+
);
|
|
169
|
+
timer.unref?.();
|
|
170
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
171
|
+
if (signal?.aborted) abort();
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const runNpm = createNpmRunner();
|
|
177
|
+
module.exports = { runNpm, resolveNpmCli, createNpmRunner };
|
|
@@ -1,84 +1,80 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Extracted duplicate file-copy loops from install.js and update.js.
|
|
4
|
-
*
|
|
2
|
+
* Shared deterministic pack enumeration and conservative installation copying.
|
|
5
3
|
* Author: Laurent Rochetta
|
|
6
4
|
*/
|
|
7
|
-
|
|
8
5
|
const path = require('node:path');
|
|
9
6
|
const fs = require('node:fs');
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Copy files for a single pack definition into the target directories.
|
|
14
|
-
*
|
|
15
|
-
* @param {object} opts
|
|
16
|
-
* @param {string} opts.bmadSrc - Path to src/bmad-plus/
|
|
17
|
-
* @param {string} opts.targetAgentsDir - Destination for agents / skills
|
|
18
|
-
* @param {string} opts.targetDataDir - Destination for data files
|
|
19
|
-
* @param {string} opts.projectRoot - Project root (for external package resolution)
|
|
20
|
-
* @param {object} opts.pack - Pack definition from PACKS
|
|
21
|
-
* @returns {{ copiedAgents: number, copiedSkills: number, copiedFiles: number }}
|
|
22
|
-
*/
|
|
23
|
-
function copyPackFiles({ bmadSrc, targetAgentsDir, targetDataDir, projectRoot, pack }) {
|
|
24
|
-
let copiedAgents = 0;
|
|
25
|
-
let copiedSkills = 0;
|
|
26
|
-
let copiedFiles = 0;
|
|
7
|
+
const crypto = require('node:crypto');
|
|
8
|
+
const { safeTarget } = require('../../build/generate-adapters');
|
|
27
9
|
|
|
28
|
-
|
|
10
|
+
const fileHash = content => crypto.createHash('sha256').update(content).digest('hex');
|
|
29
11
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
function listPackFiles({ bmadSrc, targetAgentsDir, targetDataDir, projectRoot, pack }) {
|
|
13
|
+
const result = { copiedAgents: 0, copiedSkills: 0, copiedFiles: 0, files: [] };
|
|
14
|
+
if (!pack) return result;
|
|
15
|
+
function walk(source, target) {
|
|
16
|
+
let stat;
|
|
17
|
+
try { stat = fs.lstatSync(source); } catch (error) {
|
|
18
|
+
if (error.code === 'ENOENT') return false;
|
|
19
|
+
throw error;
|
|
37
20
|
}
|
|
21
|
+
if (stat.isSymbolicLink()) throw new Error('Pack source is a symbolic link: ' + source);
|
|
22
|
+
if (stat.isDirectory()) {
|
|
23
|
+
for (const name of fs.readdirSync(source).sort()) walk(path.join(source, name), path.join(target, name));
|
|
24
|
+
} else if (stat.isFile()) {
|
|
25
|
+
result.files.push({ source, target });
|
|
26
|
+
} else throw new Error('Pack source is not a regular file: ' + source);
|
|
27
|
+
return true;
|
|
38
28
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (const skill of (pack.skills || [])) {
|
|
42
|
-
const src = path.join(bmadSrc, 'skills', skill);
|
|
43
|
-
const dest = path.join(targetAgentsDir, skill);
|
|
44
|
-
if (fs.existsSync(src)) {
|
|
45
|
-
fsExtra.copySync(src, dest, { overwrite: true });
|
|
46
|
-
copiedSkills++;
|
|
47
|
-
}
|
|
29
|
+
for (const name of pack.agents || []) {
|
|
30
|
+
if (walk(path.join(bmadSrc, 'agents', name), path.join(targetAgentsDir, name))) result.copiedAgents++;
|
|
48
31
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
for (const dataFile of (pack.data || [])) {
|
|
52
|
-
const src = path.join(bmadSrc, 'data', dataFile);
|
|
53
|
-
const dest = path.join(targetDataDir, dataFile);
|
|
54
|
-
if (fs.existsSync(src)) {
|
|
55
|
-
fsExtra.copySync(src, dest, { overwrite: true });
|
|
56
|
-
copiedFiles++;
|
|
57
|
-
}
|
|
32
|
+
for (const name of pack.skills || []) {
|
|
33
|
+
if (walk(path.join(bmadSrc, 'skills', name), path.join(targetAgentsDir, name))) result.copiedSkills++;
|
|
58
34
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
35
|
+
for (const name of pack.data || []) {
|
|
36
|
+
if (walk(path.join(bmadSrc, 'data', name), path.join(targetDataDir, name))) result.copiedFiles++;
|
|
37
|
+
}
|
|
38
|
+
if (pack.externalPackage && walk(path.join(projectRoot, pack.externalPackage, 'skills'), targetAgentsDir)) result.copiedSkills++;
|
|
39
|
+
if (pack.packDir && walk(path.join(bmadSrc, pack.packSrcDir || 'agents', pack.packDir), path.join(targetAgentsDir, pack.packDir))) {
|
|
40
|
+
result.copiedAgents++;
|
|
41
|
+
result.copiedFiles++;
|
|
67
42
|
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
68
45
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
46
|
+
function copyManagedFile({ source, target, projectDir, inventory, previousInventory = {}, onConflict = () => {} }) {
|
|
47
|
+
const file = path.relative(projectDir, target).split(path.sep).join('/');
|
|
48
|
+
safeTarget(projectDir, file);
|
|
49
|
+
const sourceStat = fs.lstatSync(source);
|
|
50
|
+
if (!sourceStat.isFile() || sourceStat.isSymbolicLink()) throw new Error('Pack source is not a regular file: ' + source);
|
|
51
|
+
const content = fs.readFileSync(source);
|
|
52
|
+
const hash = fileHash(content);
|
|
53
|
+
if (fs.existsSync(target)) {
|
|
54
|
+
const existingHash = fileHash(fs.readFileSync(target));
|
|
55
|
+
if (existingHash === hash) {
|
|
56
|
+
if (inventory) inventory[file] = hash;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (previousInventory[file] !== existingHash) {
|
|
60
|
+
if (inventory && previousInventory[file]) inventory[file] = previousInventory[file];
|
|
61
|
+
onConflict(file);
|
|
62
|
+
return false;
|
|
78
63
|
}
|
|
79
64
|
}
|
|
65
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
66
|
+
safeTarget(projectDir, file);
|
|
67
|
+
fs.writeFileSync(target, content, { mode: sourceStat.mode });
|
|
68
|
+
if (inventory) inventory[file] = hash;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
80
71
|
|
|
81
|
-
|
|
72
|
+
function copyPackFiles(options) {
|
|
73
|
+
const { files, ...counts } = listPackFiles(options);
|
|
74
|
+
const projectDir = options.projectDir || path.dirname(options.targetAgentsDir);
|
|
75
|
+
for (const { target } of files) safeTarget(projectDir, path.relative(projectDir, target).split(path.sep).join('/'));
|
|
76
|
+
for (const entry of files) copyManagedFile({ ...options, ...entry, projectDir });
|
|
77
|
+
return counts;
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
module.exports = { copyPackFiles };
|
|
80
|
+
module.exports = { copyPackFiles, listPackFiles, copyManagedFile, fileHash };
|