bmad-cybersec 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,483 @@
1
+ # BMAD-CYBER NPX Installer
2
+
3
+ **One-command installation for BMAD-CYBER framework**
4
+
5
+ ```bash
6
+ npx bmad-cyber install
7
+ ```
8
+
9
+ ## Overview
10
+
11
+ The NPX installer provides a streamlined way to add BMAD-CYBER framework to any existing project without manual file copying or complex setup procedures.
12
+
13
+ ## Installation Methods
14
+
15
+ ### Quick Install (Recommended)
16
+
17
+ ```bash
18
+ # Install latest release to current directory
19
+ npx bmad-cyber install
20
+
21
+ # Install to a specific directory
22
+ npx bmad-cyber install ./my-project
23
+
24
+ # Install specific version
25
+ npx bmad-cyber install --version v2.0.0
26
+ ```
27
+
28
+ ### From Git (Development)
29
+
30
+ ```bash
31
+ # Install from main branch
32
+ npx bmad-cyber install --from-git
33
+
34
+ # Install from specific branch
35
+ npx bmad-cyber install --from-git --branch develop
36
+ ```
37
+
38
+ ### Non-Interactive Mode
39
+
40
+ ```bash
41
+ # Skip all prompts and use defaults
42
+ npx bmad-cyber install --yes
43
+
44
+ # Force overwrite existing files
45
+ npx bmad-cyber install --force
46
+ ```
47
+
48
+ ## Command Reference
49
+
50
+ ### `install` Command
51
+
52
+ Installs BMAD-CYBER framework files to a target directory.
53
+
54
+ ```
55
+ npx bmad-cyber install [target-dir] [options]
56
+ ```
57
+
58
+ **Arguments:**
59
+ - `target-dir` - Target directory (defaults to current directory)
60
+
61
+ **Options:**
62
+ | Option | Description |
63
+ |--------|-------------|
64
+ | `-v, --version <tag>` | Install specific version (e.g., `v2.0.0`) |
65
+ | `--from-git` | Clone from Git instead of downloading release |
66
+ | `--branch <name>` | Git branch to clone (default: `main`) |
67
+ | `--force` | Overwrite existing files without prompting |
68
+ | `--yes, -y` | Skip confirmation prompts |
69
+ | `--dry-run` | Preview files without installing |
70
+ | `--with-docs` | Include documentation files |
71
+ | `--with-dev` | Include development tools |
72
+ | `--verbose` | Enable verbose logging |
73
+
74
+ **Examples:**
75
+
76
+ ```bash
77
+ # Preview what would be installed
78
+ npx bmad-cyber install --dry-run
79
+
80
+ # Install with documentation
81
+ npx bmad-cyber install --with-docs
82
+
83
+ # CI/CD installation (non-interactive)
84
+ npx bmad-cyber install --yes --force
85
+ ```
86
+
87
+ ### `version` Command
88
+
89
+ Display the installer version.
90
+
91
+ ```bash
92
+ npx bmad-cyber --version
93
+ ```
94
+
95
+ ### `help` Command
96
+
97
+ Display help information.
98
+
99
+ ```bash
100
+ npx bmad-cyber --help
101
+ npx bmad-cyber install --help
102
+ ```
103
+
104
+ ## What Gets Installed
105
+
106
+ ### Core Files (Always)
107
+ - `_bmad/` - BMAD agent configurations and workflows
108
+ - `.claude/` - Claude Code MCP configuration
109
+ - `src/utility/tools/` - Framework utility scripts
110
+ - `CLAUDE.md` - Project instructions for Claude
111
+
112
+ ### Optional Files
113
+ - `Docs/` - Documentation (with `--with-docs`)
114
+ - `dev-tools/` - Development utilities (with `--with-dev`)
115
+
116
+ ### Excluded Files (Never Installed)
117
+ - `.git/` - Git repository data
118
+ - `node_modules/` - Dependencies
119
+ - `*.test.js`, `*.spec.js` - Test files
120
+ - `coverage/` - Code coverage data
121
+ - `.github/` - GitHub workflows
122
+
123
+ ### Package.json Updates
124
+ The installer automatically merges BMAD dependencies into your `package.json`:
125
+
126
+ **Scripts added:**
127
+ ```json
128
+ {
129
+ "scripts": {
130
+ "bmad:setup": "node src/utility/tools/setup-wizard/index.js",
131
+ "bmad:modules": "node src/utility/tools/module-selector/index.js",
132
+ "bmad:security": "node src/utility/tools/security-config/index.js",
133
+ "bmad:llm": "node src/utility/tools/llm-setup/index.js",
134
+ "bmad:health": "node src/utility/tools/health-check/index.js"
135
+ }
136
+ }
137
+ ```
138
+
139
+ **Dependencies added:**
140
+ - `chalk` - Terminal styling
141
+ - `inquirer` - Interactive prompts
142
+ - `zod` - Schema validation
143
+ - `commander` - CLI framework
144
+ - `ora` - Terminal spinners
145
+
146
+ ## Troubleshooting
147
+
148
+ ### Installation Issues
149
+
150
+ #### "Release not found" Error
151
+
152
+ ```
153
+ Error: Release v99.99.99 not found
154
+ ```
155
+
156
+ **Cause:** The specified version doesn't exist.
157
+
158
+ **Solution:**
159
+ 1. Check available releases: https://github.com/SchenLong/BMAD-CYBERSEC/releases
160
+ 2. Use `latest` or omit version flag for latest release
161
+ 3. Verify the version tag format (e.g., `v2.0.0` not `2.0.0`)
162
+
163
+ #### "GitHub API rate limit exceeded" Error
164
+
165
+ ```
166
+ Error: GitHub API rate limit exceeded. Set GITHUB_TOKEN or try again later.
167
+ ```
168
+
169
+ **Cause:** Too many requests to GitHub API without authentication.
170
+
171
+ **Solutions:**
172
+ 1. Wait 1 hour for rate limit reset
173
+ 2. Set a GitHub token:
174
+ ```bash
175
+ export GITHUB_TOKEN=your_personal_access_token
176
+ npx bmad-cyber install
177
+ ```
178
+ 3. Use Git clone method instead:
179
+ ```bash
180
+ npx bmad-cyber install --from-git
181
+ ```
182
+
183
+ #### "Checksum verification failed" Error
184
+
185
+ ```
186
+ Error: Checksum verification failed. File may be corrupted.
187
+ ```
188
+
189
+ **Cause:** Downloaded file doesn't match expected checksum.
190
+
191
+ **Solutions:**
192
+ 1. Retry the installation (network issue):
193
+ ```bash
194
+ npx bmad-cyber install
195
+ ```
196
+ 2. Clear npm cache and retry:
197
+ ```bash
198
+ npm cache clean --force
199
+ npx bmad-cyber install
200
+ ```
201
+ 3. Use Git clone as fallback:
202
+ ```bash
203
+ npx bmad-cyber install --from-git
204
+ ```
205
+
206
+ #### "Git is not installed" Error
207
+
208
+ ```
209
+ Error: Git is not installed or not in PATH.
210
+ ```
211
+
212
+ **Cause:** Using `--from-git` without Git installed.
213
+
214
+ **Solutions:**
215
+ 1. Install Git: https://git-scm.com/downloads
216
+ 2. Use release download method (without `--from-git`):
217
+ ```bash
218
+ npx bmad-cyber install
219
+ ```
220
+
221
+ #### "Download failed: 500" Error
222
+
223
+ ```
224
+ Error: Download failed: 500
225
+ ```
226
+
227
+ **Cause:** GitHub server error.
228
+
229
+ **Solutions:**
230
+ 1. Wait a few minutes and retry
231
+ 2. Check GitHub status: https://www.githubstatus.com/
232
+ 3. Use Git clone as fallback:
233
+ ```bash
234
+ npx bmad-cyber install --from-git
235
+ ```
236
+
237
+ ### File Conflict Issues
238
+
239
+ #### Existing Files Would Be Overwritten
240
+
241
+ ```
242
+ Found 5 existing files that would be overwritten:
243
+ - _bmad/core/config.yaml
244
+ - .claude/settings.json
245
+ ...
246
+ ```
247
+
248
+ **Options:**
249
+ 1. **Overwrite all** - Replace all existing files
250
+ 2. **Skip existing** - Only install new files
251
+ 3. **Cancel** - Abort installation
252
+
253
+ **To avoid prompt:**
254
+ ```bash
255
+ # Skip existing files automatically
256
+ npx bmad-cyber install --yes
257
+
258
+ # Overwrite all files automatically
259
+ npx bmad-cyber install --force
260
+ ```
261
+
262
+ ### Package.json Issues
263
+
264
+ #### Backup Created But Installation Failed
265
+
266
+ If you see a backup file like `package.json.backup.1706547200000`:
267
+
268
+ 1. Your original `package.json` is safe in the backup
269
+ 2. To restore:
270
+ ```bash
271
+ cp package.json.backup.* package.json
272
+ ```
273
+
274
+ #### Merge Conflicts with Existing Dependencies
275
+
276
+ The installer preserves your existing dependency versions. If you need BMAD's exact versions:
277
+
278
+ 1. Check the diff shown during installation
279
+ 2. Manually update versions in `package.json` if needed
280
+ 3. Run `npm install` to update
281
+
282
+ ### Network Issues
283
+
284
+ #### Slow Download or Timeout
285
+
286
+ ```bash
287
+ # Increase timeout (default is 2 minutes for git clone)
288
+ npx bmad-cyber install --from-git
289
+
290
+ # Or use release download which has automatic retries
291
+ npx bmad-cyber install
292
+ ```
293
+
294
+ #### Behind Corporate Proxy
295
+
296
+ ```bash
297
+ # Configure npm proxy
298
+ npm config set proxy http://proxy.company.com:8080
299
+ npm config set https-proxy http://proxy.company.com:8080
300
+
301
+ # Then install
302
+ npx bmad-cyber install
303
+ ```
304
+
305
+ ### Environment Issues
306
+
307
+ #### Node.js Version Too Old
308
+
309
+ ```
310
+ Error: BMAD-CYBER requires Node.js >= 18.0.0
311
+ ```
312
+
313
+ **Solution:** Upgrade Node.js to version 18 or later:
314
+ - https://nodejs.org/
315
+ - Using nvm: `nvm install 18 && nvm use 18`
316
+
317
+ #### Permission Denied
318
+
319
+ ```
320
+ Error: EACCES: permission denied
321
+ ```
322
+
323
+ **Solutions:**
324
+ 1. Don't use `sudo` with npm/npx
325
+ 2. Fix npm permissions: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
326
+ 3. Install to a directory you own:
327
+ ```bash
328
+ npx bmad-cyber install ~/my-project
329
+ ```
330
+
331
+ ### Getting More Information
332
+
333
+ #### Enable Verbose Logging
334
+
335
+ ```bash
336
+ npx bmad-cyber install --verbose
337
+ ```
338
+
339
+ This shows:
340
+ - Detailed progress information
341
+ - File-by-file extraction
342
+ - Network request details
343
+
344
+ #### Preview Before Installing
345
+
346
+ ```bash
347
+ npx bmad-cyber install --dry-run
348
+ ```
349
+
350
+ This shows:
351
+ - All files that would be extracted
352
+ - Changes to package.json
353
+ - No actual modifications made
354
+
355
+ ## Security
356
+
357
+ ### For Maintainers
358
+
359
+ #### NPM Publishing Requirements
360
+
361
+ **Two-Factor Authentication (2FA) is REQUIRED** for publishing to npm.
362
+
363
+ Before publishing any release:
364
+ 1. Enable 2FA on your npm account: https://docs.npmjs.com/configuring-two-factor-authentication
365
+ 2. Use an authentication app (not SMS) for security
366
+ 3. The npm account must have **publish** 2FA level enabled
367
+
368
+ ```bash
369
+ # Verify 2FA is enabled before publishing
370
+ npm profile get
371
+
372
+ # Should show:
373
+ # two-factor auth: auth-and-writes
374
+ ```
375
+
376
+ #### Token Security
377
+
378
+ - NPM tokens are stored in GitHub Secrets (never in code)
379
+ - Tokens are never logged or displayed in workflow outputs
380
+ - Use scoped tokens with minimal permissions
381
+ - Rotate tokens periodically (recommended: every 90 days)
382
+
383
+ #### Release Signing
384
+
385
+ All releases include:
386
+ - SHA256 checksums for tarball verification
387
+ - Provenance attestation via `--provenance` flag
388
+ - Git tags for version tracking
389
+
390
+ ### For Users
391
+
392
+ #### Download Verification
393
+
394
+ The installer automatically verifies downloads:
395
+ - **Mandatory checksum verification** - all downloads are validated against SHA256 checksums
396
+ - **HTTPS only** - all network requests use secure connections
397
+ - **Trusted hosts only** - downloads restricted to github.com domains
398
+
399
+ #### Safe Installation Practices
400
+
401
+ ```bash
402
+ # Always verify the package source
403
+ npm view bmad-cyber
404
+
405
+ # Check package integrity
406
+ npm audit
407
+
408
+ # Review what will be installed before proceeding
409
+ npx bmad-cyber install --dry-run
410
+ ```
411
+
412
+ #### Reporting Security Issues
413
+
414
+ For security vulnerabilities, please:
415
+ 1. **DO NOT** create a public GitHub issue
416
+ 2. Email security concerns to the maintainers directly
417
+ 3. Include reproduction steps and impact assessment
418
+
419
+ ---
420
+
421
+ ## Development
422
+
423
+ ### Running Tests
424
+
425
+ ```bash
426
+ cd tools/npx
427
+ npm install
428
+ npm test
429
+ ```
430
+
431
+ ### Test Coverage
432
+
433
+ ```bash
434
+ npm run test:coverage
435
+ ```
436
+
437
+ Coverage thresholds: 80% for lines, functions, branches, and statements.
438
+
439
+ ### Project Structure
440
+
441
+ ```
442
+ tools/npx/
443
+ ├── cli.js # CLI entry point
444
+ ├── index.js # Main export
445
+ ├── commands/
446
+ │ └── install.js # Install command implementation
447
+ ├── lib/
448
+ │ ├── config.js # Configuration constants
449
+ │ ├── downloader.js # GitHub release downloader
450
+ │ ├── extractor.js # Tarball extraction
451
+ │ ├── git-clone.js # Git clone functionality
452
+ │ ├── logger.js # Logging utilities
453
+ │ ├── package-merger.js # Package.json merging
454
+ │ └── utils.js # Helper utilities
455
+ ├── __tests__/
456
+ │ ├── downloader.test.js
457
+ │ ├── extractor.test.js
458
+ │ ├── git-clone.test.js
459
+ │ ├── install.e2e.test.js
460
+ │ ├── package-merger.test.js
461
+ │ └── fixtures/
462
+ ├── scripts/
463
+ │ └── postinstall.js # Post-installation script
464
+ ├── package.json
465
+ ├── vitest.config.js
466
+ └── README.md
467
+ ```
468
+
469
+ ## Support
470
+
471
+ For issues with the NPX installer:
472
+ 1. Check this troubleshooting guide
473
+ 2. Search existing issues: https://github.com/SchenLong/BMAD-CYBERSEC/issues
474
+ 3. Create a new issue with:
475
+ - Node.js version (`node --version`)
476
+ - npm version (`npm --version`)
477
+ - Operating system
478
+ - Full error message
479
+ - Command used
480
+
481
+ ## License
482
+
483
+ MIT License - See [LICENSE](../../LICENSE) for details.
package/cli.js ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import { versionCommand } from './commands/version.js';
5
+ import { installCommand } from './commands/install.js';
6
+ import { updateCommand } from './commands/update.js';
7
+ import { CONFIG } from './lib/config.js';
8
+
9
+ // Check Node.js version
10
+ const nodeVersion = parseInt(process.version.slice(1).split('.')[0], 10);
11
+ if (nodeVersion < 18) {
12
+ console.error(`Error: Node.js 18+ required. Current version: ${process.version}`);
13
+ process.exit(1);
14
+ }
15
+
16
+ const program = new Command();
17
+
18
+ program
19
+ .name('bmad-cyber')
20
+ .description('Install and manage BMAD-CYBER operations framework')
21
+ .version(CONFIG.VERSION);
22
+
23
+ program
24
+ .command('install')
25
+ .description('Install BMAD-CYBER framework')
26
+ .option('-v, --version <tag>', 'Install specific version', 'latest')
27
+ .option('-b, --branch <name>', 'Install from specific branch')
28
+ .option('--from-git', 'Clone from git instead of release')
29
+ .option('--modules <list>', 'Pre-select modules (comma-separated)')
30
+ .option('--security-tier <tier>', 'Pre-select security tier')
31
+ .option('-y, --yes', 'Accept all defaults')
32
+ .option('--skip-wizard', 'Skip the setup wizard')
33
+ .option('--skip-npm-install', 'Skip npm install')
34
+ .option('--with-docs', 'Include documentation')
35
+ .option('--with-dev', 'Include development tools')
36
+ .option('--force', 'Overwrite existing files')
37
+ .option('--dry-run', 'Show what would be installed')
38
+ .action((options) => {
39
+ installCommand(options);
40
+ });
41
+
42
+ program
43
+ .command('update')
44
+ .description('Update existing BMAD-CYBER installation')
45
+ .option('-v, --version <tag>', 'Update to specific version')
46
+ .option('--check', 'Only check for updates')
47
+ .option('--force', 'Clean reinstall')
48
+ .option('--with-docs', 'Include documentation in update')
49
+ .option('--with-dev', 'Include development tools in update')
50
+ .action((options) => {
51
+ updateCommand(options);
52
+ });
53
+
54
+ program
55
+ .command('version')
56
+ .description('Display version information')
57
+ .action(versionCommand);
58
+
59
+ // Handle unknown commands
60
+ program.on('command:*', () => {
61
+ console.error(`Unknown command: ${program.args.join(' ')}`);
62
+ program.help();
63
+ process.exit(1);
64
+ });
65
+
66
+ // Handle graceful shutdown
67
+ process.on('SIGINT', () => {
68
+ console.log('\nInstallation cancelled.');
69
+ process.exit(130);
70
+ });
71
+
72
+ // Show help if no args
73
+ if (process.argv.length === 2) {
74
+ program.help();
75
+ }
76
+
77
+ program.parse();