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 命令
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
此命令在您的项目中初始化或更新 BMad-Method (V6)。
|
|
4
4
|
|
|
5
5
|
## 当调用此命令时:
|
|
6
6
|
|
|
7
|
-
1. 检查
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
10
|
-
4.
|
|
7
|
+
1. 检查 `_bmad/` 目录是否存在,判断 BMad V6 是否已安装
|
|
8
|
+
2. 检查是否存在旧版 V4 安装(`.bmad-core` 或 `.bmad-method` 目录)
|
|
9
|
+
3. 新安装执行:`npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language Chinese --document-output-language Chinese --yes`
|
|
10
|
+
4. 已安装则执行:`npx bmad-method install --directory . --action quick-update --yes`
|
|
11
|
+
5. 修复安装器 bug:将 `{output_folder}` 重命名为 `_bmad-output`(Beta 已知问题)
|
|
12
|
+
6. 自动更新 `.gitignore`(移除 V4 条目,添加 V6 条目)
|
|
13
|
+
7. 显示安装结果并提示用户后续操作
|
|
11
14
|
|
|
12
15
|
## 实现
|
|
13
16
|
|
|
@@ -16,140 +19,237 @@ 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
|
+
// 需要从 .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 产物
|
|
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 条目
|
|
31
|
+
const V6_GITIGNORE_ENTRIES = [
|
|
32
|
+
'_bmad/',
|
|
33
|
+
'_bmad-output/',
|
|
34
|
+
]
|
|
46
35
|
|
|
47
|
-
//
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log(' 1. 选择 "Upgrade BMad core" (升级 BMad 核心)')
|
|
52
|
-
console.log(' 2. 选择 "Backup and overwrite modified files" (备份并覆盖修改的文件)')
|
|
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
|
+
// 修复安装器 bug: {output_folder} 未解析为 _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
|
-
// 检查是否已安装并获取版本
|
|
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 不存在,直接重命名
|
|
45
|
+
fs.renameSync(buggyPath, correctPath)
|
|
46
|
+
console.log(' ✅ {output_folder} → _bmad-output/ (重命名)')
|
|
47
|
+
} else {
|
|
48
|
+
// _bmad-output 已存在,合并子目录后删除
|
|
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(` ✅ 移动 ${entry.name} → _bmad-output/`)
|
|
76
56
|
}
|
|
57
|
+
}
|
|
58
|
+
fs.rmSync(buggyPath, { recursive: true, force: true })
|
|
59
|
+
console.log(' ✅ 已删除多余的 {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
|
+
// 移除 V4 旧条目
|
|
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(` 🗑️ 移除旧条目: ${trimmed}`)
|
|
85
|
+
changed = true
|
|
89
86
|
}
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
return !isLegacy
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// 添加 V6 新条目
|
|
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(` ✅ 添加新条目: ${entry}`)
|
|
101
|
+
changed = true
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
|
|
95
|
-
if (
|
|
105
|
+
if (!changed) {
|
|
106
|
+
console.log(' ℹ️ .gitignore 已是最新,无需更新')
|
|
96
107
|
return
|
|
97
108
|
}
|
|
98
109
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
console.log('📋 使用自动化安装 (expect 工具可用)')
|
|
107
|
-
installWithExpect()
|
|
108
|
-
} else {
|
|
109
|
-
fallbackInstallation()
|
|
110
|
+
// 构建新内容
|
|
111
|
+
let result = filtered.join('\n')
|
|
112
|
+
|
|
113
|
+
if (newEntries.length > 0) {
|
|
114
|
+
// 确保末尾有换行,然后添加 BMad 区块
|
|
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
|
+
}
|
|
111
121
|
|
|
122
|
+
fs.writeFileSync(gitignorePath, result, 'utf8')
|
|
123
|
+
console.log(` 📝 .gitignore 已${exists ? '更新' : '创建'}`)
|
|
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
|
+
// 检查旧版 V4 安装
|
|
133
|
+
const hasLegacyCore = fs.existsSync(legacyCorePath)
|
|
134
|
+
const hasLegacyMethod = fs.existsSync(legacyMethodPath)
|
|
135
|
+
|
|
136
|
+
if (hasLegacyCore || hasLegacyMethod) {
|
|
137
|
+
console.log('⚠️ 检测到旧版 BMad V4 安装:')
|
|
138
|
+
if (hasLegacyCore) console.log(' • .bmad-core/ (V4 核心目录)')
|
|
139
|
+
if (hasLegacyMethod) console.log(' • .bmad-method/ (V4 方法目录)')
|
|
140
|
+
console.log('')
|
|
141
|
+
console.log('📌 V6 安装器会自动处理旧版迁移,请在安装过程中按提示操作。')
|
|
142
|
+
console.log(' 详情参考:https://bmad-code-org.github.io/BMAD-METHOD/docs/how-to/upgrade-to-v6')
|
|
143
|
+
console.log('')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 检查 V6 是否已安装
|
|
147
|
+
const hasV6 = fs.existsSync(bmadV6Path)
|
|
148
|
+
|
|
149
|
+
// 构建非交互式安装命令
|
|
150
|
+
let installCmd
|
|
151
|
+
if (hasV6) {
|
|
152
|
+
console.log('🔄 检测到已有 BMad V6 安装,将执行快速更新...')
|
|
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('🚀 正在初始化 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 Chinese',
|
|
169
|
+
'--document-output-language Chinese',
|
|
170
|
+
'--yes',
|
|
171
|
+
].join(' ')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 执行安装
|
|
175
|
+
try {
|
|
176
|
+
console.log(`📋 执行: ${installCmd}`)
|
|
112
177
|
console.log('')
|
|
113
|
-
|
|
178
|
+
execSync(installCmd, {
|
|
179
|
+
stdio: 'inherit',
|
|
180
|
+
cwd: cwd,
|
|
181
|
+
shell: true
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
console.log('')
|
|
185
|
+
console.log('✅ BMad-Method V6 安装/更新完成!')
|
|
114
186
|
console.log('')
|
|
115
187
|
console.log('═══════════════════════════════════════════════════════════════')
|
|
116
|
-
console.log('📌 重要提示:请重启
|
|
188
|
+
console.log('📌 重要提示:请重启 AI IDE 以加载 BMad 扩展')
|
|
117
189
|
console.log('═══════════════════════════════════════════════════════════════')
|
|
118
190
|
console.log('')
|
|
119
|
-
|
|
120
|
-
console.log('
|
|
121
|
-
|
|
191
|
+
// 修复 {output_folder} bug (v6.0.0-Beta.8)
|
|
192
|
+
console.log('🔧 检查安装器已知问题...')
|
|
193
|
+
try {
|
|
194
|
+
const fixed = fixOutputFolderBug(cwd)
|
|
195
|
+
if (!fixed) console.log(' ℹ️ 无需修复')
|
|
196
|
+
} catch (err) {
|
|
197
|
+
console.log(` ⚠️ 修复 {output_folder} 失败: ${err.message}`)
|
|
198
|
+
console.log(' 请手动将 {output_folder}/ 重命名为 _bmad-output/')
|
|
199
|
+
}
|
|
200
|
+
console.log('')
|
|
201
|
+
|
|
202
|
+
console.log('📂 V6 目录结构:')
|
|
203
|
+
console.log(' • _bmad/ — agents、workflows、tasks 和配置')
|
|
204
|
+
console.log(' • _bmad-output/ — 生成的工件输出目录')
|
|
122
205
|
console.log('')
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
console.log('
|
|
126
|
-
|
|
127
|
-
|
|
206
|
+
|
|
207
|
+
// 自动更新 .gitignore
|
|
208
|
+
console.log('🔧 更新 .gitignore...')
|
|
209
|
+
try {
|
|
210
|
+
updateGitignore(cwd)
|
|
211
|
+
} catch (err) {
|
|
212
|
+
console.log(' ⚠️ 自动更新 .gitignore 失败,请手动添加 _bmad/ 和 _bmad-output/')
|
|
213
|
+
}
|
|
128
214
|
console.log('')
|
|
129
215
|
console.log('🚀 快速开始:')
|
|
130
|
-
console.log(' 1. 重启
|
|
131
|
-
console.log(' 2.
|
|
132
|
-
console.log('
|
|
133
|
-
console.log(' 这将启动 BMad 工作流引导系统')
|
|
216
|
+
console.log(' 1. 重启 AI IDE')
|
|
217
|
+
console.log(' 2. 运行 /bmad-help 获取引导和下一步建议')
|
|
218
|
+
console.log(' 3. 输入 /bmad 并使用自动补全浏览可用命令')
|
|
134
219
|
console.log('')
|
|
135
|
-
console.log('💡
|
|
136
|
-
console.log('
|
|
220
|
+
console.log('💡 常用工作流:')
|
|
221
|
+
console.log(' • /bmad-help — 交互式帮助')
|
|
222
|
+
console.log(' • /bmad-bmm-create-prd — 创建产品需求文档')
|
|
223
|
+
console.log(' • /bmad-bmm-create-architecture — 创建架构文档')
|
|
224
|
+
console.log(' • /bmad-bmm-create-epics-and-stories — 创建史诗和用户故事')
|
|
225
|
+
console.log(' • /bmad-bmm-sprint-planning — 初始化 Sprint 计划')
|
|
226
|
+
console.log(' • /bmad-bmm-dev-story — 实现用户故事')
|
|
227
|
+
|
|
228
|
+
// 清理旧版 V4 IDE 命令提醒
|
|
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('⚠️ 检测到旧版 V4 IDE 命令,建议手动删除:')
|
|
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(' 新的 V6 命令已安装在 .claude/commands/bmad/ 下')
|
|
237
|
+
}
|
|
137
238
|
}
|
|
138
239
|
catch (error) {
|
|
139
240
|
console.error('❌ 安装失败:', error.message)
|
|
140
241
|
console.log('')
|
|
141
242
|
console.log('🛠️ 手动安装指南:')
|
|
142
|
-
console.log('
|
|
143
|
-
console.log('
|
|
144
|
-
console.log('')
|
|
145
|
-
console.log('
|
|
146
|
-
console.log('
|
|
147
|
-
console.log('
|
|
243
|
+
console.log(' 1. 确保已安装 Node.js 20+')
|
|
244
|
+
console.log(' 2. 非交互式安装:')
|
|
245
|
+
console.log(' npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language Chinese --document-output-language Chinese --yes')
|
|
246
|
+
console.log(' 3. 快速更新已有安装:')
|
|
247
|
+
console.log(' npx bmad-method install --directory . --action quick-update --yes')
|
|
248
|
+
console.log(' 4. 或交互式安装:')
|
|
249
|
+
console.log(' npx bmad-method install')
|
|
148
250
|
console.log('')
|
|
149
|
-
console.log('
|
|
150
|
-
console.log('
|
|
151
|
-
console.log(' • Ubuntu: sudo apt-get install expect')
|
|
152
|
-
console.log(' • CentOS: sudo yum install expect')
|
|
251
|
+
console.log('📖 详细文档:')
|
|
252
|
+
console.log(' https://bmad-code-org.github.io/BMAD-METHOD/docs/how-to/install-bmad')
|
|
153
253
|
}
|
|
154
254
|
}
|
|
155
255
|
|
|
@@ -167,6 +267,9 @@ initBmad()
|
|
|
167
267
|
|
|
168
268
|
此命令将:
|
|
169
269
|
|
|
170
|
-
1.
|
|
171
|
-
2.
|
|
172
|
-
3.
|
|
270
|
+
1. 检测现有安装状态(V6 / V4 旧版 / 未安装)
|
|
271
|
+
2. 新安装:`npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language Chinese --document-output-language Chinese --yes`
|
|
272
|
+
3. 已安装:`npx bmad-method install --directory . --action quick-update --yes`
|
|
273
|
+
4. 修复 `{output_folder}` → `_bmad-output` 安装器 bug
|
|
274
|
+
5. 自动更新 `.gitignore`(清理旧条目,添加 V6 条目)
|
|
275
|
+
6. 提供后续步骤建议
|