zcf 3.6.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/chunks/api-providers.mjs +54 -20
- package/dist/chunks/codex-config-switch.mjs +3 -34
- package/dist/chunks/simple-config.mjs +102 -38
- package/dist/i18n/locales/en/codex.json +1 -2
- package/dist/i18n/locales/en/configuration.json +3 -0
- package/dist/i18n/locales/zh-CN/codex.json +1 -2
- package/dist/i18n/locales/zh-CN/configuration.json +3 -0
- package/package.json +1 -1
- package/templates/claude-code/common/settings.json +12 -2
- package/templates/claude-code/en/workflow/bmad/commands/bmad-init.md +225 -115
- package/templates/claude-code/zh-CN/workflow/bmad/commands/bmad-init.md +214 -111
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# /bmad-init Command
|
|
2
2
|
|
|
3
|
-
This command initializes BMad
|
|
3
|
+
This command initializes or updates BMad-Method (V6) in your project.
|
|
4
4
|
|
|
5
5
|
## When this command is invoked:
|
|
6
6
|
|
|
7
|
-
1. Check if BMad is already installed
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
10
|
-
4.
|
|
7
|
+
1. Check if `_bmad/` directory exists to determine if BMad V6 is already installed
|
|
8
|
+
2. Check for legacy V4 installations (`.bmad-core` or `.bmad-method` directories)
|
|
9
|
+
3. Fresh install executes: `npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language English --document-output-language English --yes`
|
|
10
|
+
4. Existing install executes: `npx bmad-method install --directory . --action quick-update --yes`
|
|
11
|
+
5. Fix installer bug: rename `{output_folder}` to `_bmad-output` (Beta known issue)
|
|
12
|
+
6. Automatically update `.gitignore` (remove V4 entries, add V6 entries)
|
|
13
|
+
7. Display installation results and prompt user for next steps
|
|
11
14
|
|
|
12
15
|
## Implementation
|
|
13
16
|
|
|
@@ -16,150 +19,257 @@ const { execSync } = require('node:child_process')
|
|
|
16
19
|
const fs = require('node:fs')
|
|
17
20
|
const path = require('node:path')
|
|
18
21
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}
|
|
22
|
+
// Legacy entries to clean from .gitignore
|
|
23
|
+
const LEGACY_GITIGNORE_ENTRIES = [
|
|
24
|
+
'.bmad-core',
|
|
25
|
+
'.bmad-method',
|
|
26
|
+
'.claude/commands/BMad',
|
|
27
|
+
'{output_folder}', // v6.0.0-Beta.8 bug artifact
|
|
28
|
+
]
|
|
28
29
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
send "1\\r"
|
|
35
|
-
expect "How would you like to proceed?"
|
|
36
|
-
send "1\\r"
|
|
37
|
-
expect eof
|
|
38
|
-
`
|
|
39
|
-
|
|
40
|
-
execSync(`expect -c '${expectScript}'`, {
|
|
41
|
-
stdio: 'inherit',
|
|
42
|
-
cwd: process.cwd(),
|
|
43
|
-
shell: true
|
|
44
|
-
})
|
|
45
|
-
}
|
|
30
|
+
// V6 .gitignore entries
|
|
31
|
+
const V6_GITIGNORE_ENTRIES = [
|
|
32
|
+
'_bmad/',
|
|
33
|
+
'_bmad-output/',
|
|
34
|
+
]
|
|
46
35
|
|
|
47
|
-
//
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log(' 1. Choose "Upgrade BMad core" when prompted')
|
|
52
|
-
console.log(' 2. Choose "Backup and overwrite modified files" when prompted')
|
|
53
|
-
console.log('')
|
|
54
|
-
|
|
55
|
-
execSync('npx bmad-method@latest install -f -d . -i claude-code', {
|
|
56
|
-
stdio: 'inherit',
|
|
57
|
-
cwd: process.cwd(),
|
|
58
|
-
shell: true
|
|
59
|
-
})
|
|
60
|
-
}
|
|
36
|
+
// Fix installer bug: {output_folder} not resolved to _bmad-output (v6.0.0-Beta.8)
|
|
37
|
+
function fixOutputFolderBug(cwd) {
|
|
38
|
+
const buggyPath = path.join(cwd, '{output_folder}')
|
|
39
|
+
const correctPath = path.join(cwd, '_bmad-output')
|
|
61
40
|
|
|
62
|
-
|
|
63
|
-
// Check if already installed and get version
|
|
64
|
-
const manifestPath = path.join(process.cwd(), '.bmad-core', 'install-manifest.yaml')
|
|
65
|
-
let needsInstall = true
|
|
66
|
-
let currentVersion = null
|
|
41
|
+
if (!fs.existsSync(buggyPath)) return false
|
|
67
42
|
|
|
68
|
-
if (fs.existsSync(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
43
|
+
if (!fs.existsSync(correctPath)) {
|
|
44
|
+
// _bmad-output doesn't exist, simply rename
|
|
45
|
+
fs.renameSync(buggyPath, correctPath)
|
|
46
|
+
console.log(' ✅ {output_folder} → _bmad-output/ (renamed)')
|
|
47
|
+
} else {
|
|
48
|
+
// _bmad-output already exists, merge subdirectories then delete
|
|
49
|
+
const entries = fs.readdirSync(buggyPath, { withFileTypes: true })
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
const src = path.join(buggyPath, entry.name)
|
|
52
|
+
const dest = path.join(correctPath, entry.name)
|
|
53
|
+
if (!fs.existsSync(dest)) {
|
|
54
|
+
fs.renameSync(src, dest)
|
|
55
|
+
console.log(` ✅ Moved ${entry.name} → _bmad-output/`)
|
|
76
56
|
}
|
|
57
|
+
}
|
|
58
|
+
fs.rmSync(buggyPath, { recursive: true, force: true })
|
|
59
|
+
console.log(' ✅ Removed redundant {output_folder}/')
|
|
60
|
+
}
|
|
61
|
+
return true
|
|
62
|
+
}
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
function updateGitignore(cwd) {
|
|
65
|
+
const gitignorePath = path.join(cwd, '.gitignore')
|
|
66
|
+
let content = ''
|
|
67
|
+
let exists = false
|
|
80
68
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
if (fs.existsSync(gitignorePath)) {
|
|
70
|
+
content = fs.readFileSync(gitignorePath, 'utf8')
|
|
71
|
+
exists = true
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const lines = content.split('\n')
|
|
75
|
+
let changed = false
|
|
76
|
+
|
|
77
|
+
// Remove V4 legacy entries
|
|
78
|
+
const filtered = lines.filter(line => {
|
|
79
|
+
const trimmed = line.trim()
|
|
80
|
+
const isLegacy = LEGACY_GITIGNORE_ENTRIES.some(entry =>
|
|
81
|
+
trimmed === entry || trimmed === entry + '/' || trimmed === '/' + entry
|
|
82
|
+
)
|
|
83
|
+
if (isLegacy) {
|
|
84
|
+
console.log(` 🗑️ Removing legacy entry: ${trimmed}`)
|
|
85
|
+
changed = true
|
|
89
86
|
}
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
return !isLegacy
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// Add V6 entries
|
|
91
|
+
const newEntries = []
|
|
92
|
+
for (const entry of V6_GITIGNORE_ENTRIES) {
|
|
93
|
+
const entryBase = entry.replace(/\/$/, '')
|
|
94
|
+
const alreadyExists = filtered.some(line => {
|
|
95
|
+
const trimmed = line.trim()
|
|
96
|
+
return trimmed === entry || trimmed === entryBase || trimmed === '/' + entryBase
|
|
97
|
+
})
|
|
98
|
+
if (!alreadyExists) {
|
|
99
|
+
newEntries.push(entry)
|
|
100
|
+
console.log(` ✅ Adding new entry: ${entry}`)
|
|
101
|
+
changed = true
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
|
|
95
|
-
if (
|
|
105
|
+
if (!changed) {
|
|
106
|
+
console.log(' ℹ️ .gitignore is up to date, no changes needed')
|
|
96
107
|
return
|
|
97
108
|
}
|
|
98
109
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
console.log('📋 Using automated installation (expect tool available)')
|
|
107
|
-
installWithExpect()
|
|
108
|
-
} else {
|
|
109
|
-
fallbackInstallation()
|
|
110
|
+
// Build new content
|
|
111
|
+
let result = filtered.join('\n')
|
|
112
|
+
|
|
113
|
+
if (newEntries.length > 0) {
|
|
114
|
+
// Ensure trailing newline, then add BMad section
|
|
115
|
+
if (result.length > 0 && !result.endsWith('\n')) {
|
|
116
|
+
result += '\n'
|
|
110
117
|
}
|
|
118
|
+
result += '\n# BMad Method V6\n'
|
|
119
|
+
result += newEntries.join('\n') + '\n'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fs.writeFileSync(gitignorePath, result, 'utf8')
|
|
123
|
+
console.log(` 📝 .gitignore ${exists ? 'updated' : 'created'}`)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function initBmad() {
|
|
127
|
+
const cwd = process.cwd()
|
|
128
|
+
const bmadV6Path = path.join(cwd, '_bmad')
|
|
129
|
+
const legacyCorePath = path.join(cwd, '.bmad-core')
|
|
130
|
+
const legacyMethodPath = path.join(cwd, '.bmad-method')
|
|
131
|
+
|
|
132
|
+
// Check for legacy V4 installation
|
|
133
|
+
const hasLegacyCore = fs.existsSync(legacyCorePath)
|
|
134
|
+
const hasLegacyMethod = fs.existsSync(legacyMethodPath)
|
|
111
135
|
|
|
136
|
+
if (hasLegacyCore || hasLegacyMethod) {
|
|
137
|
+
console.log('⚠️ Legacy BMad V4 installation detected:')
|
|
138
|
+
if (hasLegacyCore) console.log(' • .bmad-core/ (V4 core directory)')
|
|
139
|
+
if (hasLegacyMethod) console.log(' • .bmad-method/ (V4 method directory)')
|
|
112
140
|
console.log('')
|
|
113
|
-
console.log('
|
|
141
|
+
console.log('📌 The V6 installer will handle legacy migration automatically. Follow the prompts during installation.')
|
|
142
|
+
console.log(' Details: https://bmad-code-org.github.io/BMAD-METHOD/docs/how-to/upgrade-to-v6')
|
|
143
|
+
console.log('')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Check if V6 is already installed
|
|
147
|
+
const hasV6 = fs.existsSync(bmadV6Path)
|
|
148
|
+
|
|
149
|
+
// Build non-interactive install command
|
|
150
|
+
let installCmd
|
|
151
|
+
if (hasV6) {
|
|
152
|
+
console.log('🔄 Existing BMad V6 installation detected, performing quick update...')
|
|
153
|
+
console.log('')
|
|
154
|
+
installCmd = [
|
|
155
|
+
'npx bmad-method install',
|
|
156
|
+
'--directory .',
|
|
157
|
+
'--action quick-update',
|
|
158
|
+
'--yes',
|
|
159
|
+
].join(' ')
|
|
160
|
+
} else {
|
|
161
|
+
console.log('🚀 Initializing BMad-Method V6...')
|
|
162
|
+
console.log('')
|
|
163
|
+
installCmd = [
|
|
164
|
+
'npx bmad-method install',
|
|
165
|
+
'--directory .',
|
|
166
|
+
'--modules bmm',
|
|
167
|
+
'--tools claude-code',
|
|
168
|
+
'--communication-language English',
|
|
169
|
+
'--document-output-language English',
|
|
170
|
+
'--yes',
|
|
171
|
+
].join(' ')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Execute installation
|
|
175
|
+
try {
|
|
176
|
+
console.log(`📋 Executing: ${installCmd}`)
|
|
177
|
+
console.log('')
|
|
178
|
+
execSync(installCmd, {
|
|
179
|
+
stdio: 'inherit',
|
|
180
|
+
cwd: cwd,
|
|
181
|
+
shell: true
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
console.log('')
|
|
185
|
+
console.log('✅ BMad-Method V6 installation/update complete!')
|
|
114
186
|
console.log('')
|
|
115
187
|
console.log('═══════════════════════════════════════════════════════════════')
|
|
116
|
-
console.log('📌 IMPORTANT: Please restart
|
|
188
|
+
console.log('📌 IMPORTANT: Please restart your AI IDE to load BMad extensions')
|
|
117
189
|
console.log('═══════════════════════════════════════════════════════════════')
|
|
118
190
|
console.log('')
|
|
119
|
-
|
|
120
|
-
console.log('
|
|
121
|
-
|
|
191
|
+
// Fix {output_folder} bug (v6.0.0-Beta.8)
|
|
192
|
+
console.log('🔧 Checking for known installer issues...')
|
|
193
|
+
try {
|
|
194
|
+
const fixed = fixOutputFolderBug(cwd)
|
|
195
|
+
if (!fixed) console.log(' ℹ️ No fixes needed')
|
|
196
|
+
} catch (err) {
|
|
197
|
+
console.log(` ⚠️ Failed to fix {output_folder}: ${err.message}`)
|
|
198
|
+
console.log(' Please manually rename {output_folder}/ to _bmad-output/')
|
|
199
|
+
}
|
|
122
200
|
console.log('')
|
|
123
|
-
|
|
124
|
-
console.log('
|
|
125
|
-
console.log('
|
|
126
|
-
console.log('
|
|
127
|
-
console.log(' • docs/')
|
|
201
|
+
|
|
202
|
+
console.log('📂 V6 Directory Structure:')
|
|
203
|
+
console.log(' • _bmad/ — agents, workflows, tasks, and configuration')
|
|
204
|
+
console.log(' • _bmad-output/ — generated artifact output directory')
|
|
128
205
|
console.log('')
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
console.log('
|
|
132
|
-
|
|
133
|
-
|
|
206
|
+
|
|
207
|
+
// Automatically update .gitignore
|
|
208
|
+
console.log('🔧 Updating .gitignore...')
|
|
209
|
+
try {
|
|
210
|
+
updateGitignore(cwd)
|
|
211
|
+
} catch (err) {
|
|
212
|
+
console.log(' ⚠️ Failed to automatically update .gitignore, please manually add _bmad/ and _bmad-output/')
|
|
213
|
+
}
|
|
134
214
|
console.log('')
|
|
135
|
-
console.log('
|
|
136
|
-
console.log('
|
|
215
|
+
console.log('🚀 Quick Start:')
|
|
216
|
+
console.log(' 1. Restart your AI IDE')
|
|
217
|
+
console.log(' 2. Run /bmad-help for guidance and next step suggestions')
|
|
218
|
+
console.log(' 3. Type /bmad and use autocomplete to browse available commands')
|
|
219
|
+
console.log('')
|
|
220
|
+
console.log('💡 Common Workflows:')
|
|
221
|
+
console.log(' • /bmad-help — Interactive help')
|
|
222
|
+
console.log(' • /bmad-bmm-create-prd — Create Product Requirements Document')
|
|
223
|
+
console.log(' • /bmad-bmm-create-architecture — Create Architecture Document')
|
|
224
|
+
console.log(' • /bmad-bmm-create-epics-and-stories — Create Epics and User Stories')
|
|
225
|
+
console.log(' • /bmad-bmm-sprint-planning — Initialize Sprint Planning')
|
|
226
|
+
console.log(' • /bmad-bmm-dev-story — Implement User Story')
|
|
227
|
+
|
|
228
|
+
// Legacy V4 IDE command cleanup reminder
|
|
229
|
+
const legacyClaudeAgents = path.join(cwd, '.claude', 'commands', 'BMad', 'agents')
|
|
230
|
+
const legacyClaudeTasks = path.join(cwd, '.claude', 'commands', 'BMad', 'tasks')
|
|
231
|
+
if (fs.existsSync(legacyClaudeAgents) || fs.existsSync(legacyClaudeTasks)) {
|
|
232
|
+
console.log('')
|
|
233
|
+
console.log('⚠️ Legacy V4 IDE commands detected, consider removing manually:')
|
|
234
|
+
if (fs.existsSync(legacyClaudeAgents)) console.log(' • .claude/commands/BMad/agents/')
|
|
235
|
+
if (fs.existsSync(legacyClaudeTasks)) console.log(' • .claude/commands/BMad/tasks/')
|
|
236
|
+
console.log(' New V6 commands are installed under .claude/commands/bmad/')
|
|
237
|
+
}
|
|
137
238
|
}
|
|
138
239
|
catch (error) {
|
|
139
240
|
console.error('❌ Installation failed:', error.message)
|
|
140
241
|
console.log('')
|
|
141
242
|
console.log('🛠️ Manual Installation Guide:')
|
|
142
|
-
console.log('
|
|
143
|
-
console.log('
|
|
243
|
+
console.log(' 1. Ensure Node.js 20+ is installed')
|
|
244
|
+
console.log(' 2. Non-interactive install:')
|
|
245
|
+
console.log(' npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language English --document-output-language English --yes')
|
|
246
|
+
console.log(' 3. Quick update existing installation:')
|
|
247
|
+
console.log(' npx bmad-method install --directory . --action quick-update --yes')
|
|
248
|
+
console.log(' 4. Or interactive install:')
|
|
249
|
+
console.log(' npx bmad-method install')
|
|
144
250
|
console.log('')
|
|
145
|
-
console.log('
|
|
146
|
-
console.log('
|
|
147
|
-
console.log(' 2. When asked "How would you like to proceed?", choose "Backup and overwrite"')
|
|
148
|
-
console.log('')
|
|
149
|
-
console.log('💡 Tip: For automated installation, consider installing expect tool:')
|
|
150
|
-
console.log(' • macOS: brew install expect')
|
|
151
|
-
console.log(' • Ubuntu: sudo apt-get install expect')
|
|
152
|
-
console.log(' • CentOS: sudo yum install expect')
|
|
251
|
+
console.log('📖 Documentation:')
|
|
252
|
+
console.log(' https://bmad-code-org.github.io/BMAD-METHOD/docs/how-to/install-bmad')
|
|
153
253
|
}
|
|
154
254
|
}
|
|
155
255
|
|
|
156
|
-
// Execute
|
|
256
|
+
// Execute initialization
|
|
157
257
|
initBmad()
|
|
158
258
|
```
|
|
159
259
|
|
|
160
|
-
##
|
|
260
|
+
## Usage
|
|
261
|
+
|
|
262
|
+
Simply type in Claude Code:
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
/bmad-init
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
This command will:
|
|
161
269
|
|
|
162
|
-
|
|
163
|
-
-
|
|
164
|
-
|
|
165
|
-
|
|
270
|
+
1. Detect current installation status (V6 / V4 legacy / not installed)
|
|
271
|
+
2. Fresh install: non-interactively execute `npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language English --document-output-language English --yes`
|
|
272
|
+
3. Existing install: execute `npx bmad-method install --directory . --action quick-update --yes`
|
|
273
|
+
4. Fix `{output_folder}` → `_bmad-output` installer bug
|
|
274
|
+
5. Automatically update `.gitignore` (clean up legacy entries, add V6 entries)
|
|
275
|
+
6. Provide next step suggestions
|