sillyspec 3.26.9 → 3.26.11
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/.claude/skills/sillyspec-archive/SKILL.md +85 -85
- package/.claude/skills/sillyspec-brainstorm/SKILL.md +114 -114
- package/.claude/skills/sillyspec-commit/SKILL.md +109 -109
- package/.claude/skills/sillyspec-continue/SKILL.md +45 -45
- package/.claude/skills/sillyspec-doctor/SKILL.md +76 -76
- package/.claude/skills/sillyspec-execute/SKILL.md +200 -200
- package/.claude/skills/sillyspec-explore/SKILL.md +95 -95
- package/.claude/skills/sillyspec-knowledge/SKILL.md +269 -269
- package/.claude/skills/sillyspec-plan/SKILL.md +148 -148
- package/.claude/skills/sillyspec-quick/SKILL.md +111 -111
- package/.claude/skills/sillyspec-resume/SKILL.md +68 -68
- package/.claude/skills/sillyspec-scan/SKILL.md +79 -79
- package/.claude/skills/sillyspec-state/SKILL.md +64 -64
- package/.claude/skills/sillyspec-status/SKILL.md +54 -54
- package/.claude/skills/sillyspec-verify/SKILL.md +83 -81
- package/.claude/skills/sillyspec-workspace/SKILL.md +169 -169
- package/.gitattributes +2 -0
- package/.husky/pre-push +20 -20
- package/.npmrc-publish +2 -0
- package/README.md +201 -201
- package/SKILL.md +90 -90
- package/package.json +39 -39
- package/packages/dashboard/dist/assets/index-Bq_Z2hne.js +7446 -7446
- package/packages/dashboard/dist/assets/index-O2W5RV4z.css +1 -1
- package/packages/dashboard/dist/index.html +16 -16
- package/packages/dashboard/package.json +25 -25
- package/packages/dashboard/server/executor.js +86 -86
- package/packages/dashboard/server/index.js +601 -601
- package/packages/dashboard/server/parser.js +526 -526
- package/src/change-risk-profile.js +254 -254
- package/src/classify-change.js +109 -109
- package/src/config-schema.js +310 -310
- package/src/contract-matrix.js +379 -379
- package/src/db.js +350 -350
- package/src/dispatch/backends/local-agent.js +155 -155
- package/src/dispatch/backends/sillyhub-mcp.js +245 -245
- package/src/dispatch/probe.js +210 -210
- package/src/dispatch/strategy.js +121 -121
- package/src/docs-check.js +131 -4
- package/src/doctor-diagnostics.js +711 -711
- package/src/endpoint-extractor.js +401 -401
- package/src/fs-atomic.js +69 -69
- package/src/git-helper.js +79 -79
- package/src/hooks/claude-pre-tool-use.cjs +125 -125
- package/src/hooks/worktree-guard.js +848 -848
- package/src/index.js +90 -8
- package/src/init.js +623 -623
- package/src/knowledge-match.js +130 -130
- package/src/local-detect.js +120 -120
- package/src/machine-interface.js +543 -543
- package/src/migrate.js +127 -127
- package/src/progress/change-registry.js +297 -260
- package/src/progress/consistency-doctor.js +355 -355
- package/src/progress/shared.js +36 -36
- package/src/progress/stage-machine.js +29 -1
- package/src/progress/step-store.js +261 -261
- package/src/progress.js +1131 -1127
- package/src/quicklog.js +693 -675
- package/src/review-tier.js +77 -77
- package/src/run/command.js +1385 -1364
- package/src/run/complete-handlers.js +198 -9
- package/src/run/complete.js +225 -24
- package/src/run/concurrent-detect.js +22 -0
- package/src/run/gates.js +755 -755
- package/src/run/prompt.js +761 -721
- package/src/run/quick-audit.js +155 -146
- package/src/run/shared.js +1268 -1197
- package/src/run/stage.js +487 -479
- package/src/scan-postcheck.js +371 -371
- package/src/setup.js +416 -416
- package/src/sillyhub-mcp/client.js +529 -529
- package/src/spec-sync.js +323 -0
- package/src/stage-contract.js +897 -897
- package/src/stage-review.js +549 -549
- package/src/stages/archive.js +155 -154
- package/src/stages/brainstorm-auto.js +236 -236
- package/src/stages/brainstorm.js +596 -597
- package/src/stages/cmd-existence.js +145 -145
- package/src/stages/doctor.js +371 -371
- package/src/stages/execute.js +1003 -991
- package/src/stages/explore.js +34 -34
- package/src/stages/index.js +29 -29
- package/src/stages/knowledge.js +498 -498
- package/src/stages/plan-postcheck.js +1302 -1281
- package/src/stages/plan.js +625 -604
- package/src/stages/quick.js +151 -143
- package/src/stages/scan.js +606 -605
- package/src/stages/status.js +64 -64
- package/src/stages/verify.js +264 -261
- package/src/sync.js +1223 -1125
- package/src/task-review.js +1019 -1019
- package/src/verify-postcheck.js +1186 -1186
- package/src/workflow.js +600 -600
- package/src/worktree-apply.js +1213 -1136
- package/src/worktree-deps.js +353 -353
- package/src/worktree.js +1481 -1437
- package/templates/workflows/archive-impact.yaml +79 -79
- package/templates/workflows/scan-docs.yaml +132 -132
package/src/run/stage.js
CHANGED
|
@@ -1,479 +1,487 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* run/stage.js(W6 Step8b 从 run.js 抽出)。
|
|
3
|
-
*
|
|
4
|
-
* `run <stage>` 默认路径的执行主干(runStage)+ 其私有 helper:
|
|
5
|
-
* - runStage:输出当前 step prompt(重 execute/scan/quick 启动期副作用——worktree 创建、
|
|
6
|
-
* executeRunId 固定、scanProfile 裁剪、quick baseline 录入、plan design 契约校验、noAI 步骤代理)
|
|
7
|
-
* - autoDetectChange:唯一变更目录时自动设置 currentChange(runStage 私有)
|
|
8
|
-
* - executePlanPostcheck:noAI planPostcheck 步骤代理(runStage 私有)
|
|
9
|
-
* - ensureDepsFreshness:execute 入口已存在 worktree 时 deps 自检重供给(runStage 私有)
|
|
10
|
-
*
|
|
11
|
-
* 安全锚:run.js 始终 barrel。runStage 由 run.js import 回来(无 test 直接 import,无需 re-export)。
|
|
12
|
-
* checkApproval(runStage + runAutoMode 共用)已先下沉 shared.js(Step8a),避免 command/stage 环依赖。
|
|
13
|
-
*
|
|
14
|
-
* 路径修正(相对 src/run/):
|
|
15
|
-
* - 动态 import './worktree.js' / './task-review.js' / './stages/plan.js' /
|
|
16
|
-
* './stages/plan-postcheck.js' / './worktree-deps.js' → '../'(src/ 下退一层)
|
|
17
|
-
* - 'child_process'(execSync)裸模块名不变
|
|
18
|
-
*/
|
|
19
|
-
import { join, dirname } from 'node:path'
|
|
20
|
-
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
21
|
-
import { writeAtomicSync } from '../fs-atomic.js'
|
|
22
|
-
import { resolveSpecDir, resolveChangeDir, resolveRuntimeRoot, resolveQuickSessionsDir, triggerSync, safeGit, parsePorcelainPath, formatWaitOptions, checkApproval, getStageSteps } from './shared.js'
|
|
23
|
-
import { computeScanProfile, applyScanProfileSteps, executeScanPreflight, executeScanPostcheck } from './scan-profile.js'
|
|
24
|
-
import { outputStep } from './prompt.js'
|
|
25
|
-
import { allocateQuicklogEntry, deriveTitleFromLinkedChange, sanitizeDesc } from '../quicklog.js'
|
|
26
|
-
import { createHash } from 'node:crypto'
|
|
27
|
-
import { checkTransition } from '../stage-contract.js'
|
|
28
|
-
import { AUXILIARY_STAGES } from '../constants.js'
|
|
29
|
-
import { completeStageGates } from './gates.js'
|
|
30
|
-
|
|
31
|
-
export async function runStage(pm, progress, stageName, cwd, changeName, skipApproval = false, platformOpts = {}, quickOpts = {}) {
|
|
32
|
-
const specBase = platformOpts.specRoot || join(cwd, '.sillyspec')
|
|
33
|
-
// 状态转换校验
|
|
34
|
-
const prevStage = progress.currentStage || ''
|
|
35
|
-
// task-07: 提取 prevStage 的 stageData,传给 checkTransition 检测 failed_post_check 门控
|
|
36
|
-
const fromStageData = (progress.stages && prevStage && progress.stages[prevStage]) || undefined
|
|
37
|
-
const transition = checkTransition(prevStage, stageName, fromStageData ? { fromStageData } : {})
|
|
38
|
-
if (!transition.allowed) {
|
|
39
|
-
console.error(`❌ 阶段转换不允许: ${prevStage || '(起始)'} → ${stageName}`)
|
|
40
|
-
console.error(` 原因: ${transition.reason}`)
|
|
41
|
-
console.error(` 提示: 使用 --skip-approval 绕过(需明确意图)`)
|
|
42
|
-
if (!skipApproval) {
|
|
43
|
-
process.exit(1)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// execute 阶段启动前检查审批
|
|
48
|
-
if (stageName === 'execute' && !skipApproval) {
|
|
49
|
-
const approval = await checkApproval(cwd, changeName, platformOpts)
|
|
50
|
-
if (approval) {
|
|
51
|
-
if (approval.status === 'rejected') {
|
|
52
|
-
console.error(`❌ 变更 ${changeName} 的执行已被拒绝:${approval.reason || '无原因'}`)
|
|
53
|
-
process.exit(1)
|
|
54
|
-
}
|
|
55
|
-
if (approval.status === 'pending') {
|
|
56
|
-
console.log(`⏳ 变更 ${changeName} 的执行审批待处理中...`)
|
|
57
|
-
console.log(' 提示:使用 --skip-approval 跳过审批检查')
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// execute 阶段:CLI 自动创建 worktree(不等 AI agent)
|
|
63
|
-
if (stageName === 'execute' && changeName) {
|
|
64
|
-
const effectiveChange = changeName
|
|
65
|
-
const { WorktreeManager } = await import('../worktree.js')
|
|
66
|
-
const wm = new WorktreeManager({ cwd })
|
|
67
|
-
const existingMeta = wm.getMeta(effectiveChange)
|
|
68
|
-
if (existingMeta) {
|
|
69
|
-
console.log(`🔗 worktree 已存在: ${existingMeta.worktreePath} (${existingMeta.mode})`)
|
|
70
|
-
} else {
|
|
71
|
-
try {
|
|
72
|
-
const result = wm.create(effectiveChange)
|
|
73
|
-
console.log(`🔗 worktree 已创建: ${result.worktreePath} (分支: ${result.branch}, 模式: ${result.mode})`)
|
|
74
|
-
} catch (e) {
|
|
75
|
-
console.error(`❌ worktree 创建失败: ${e.message}`)
|
|
76
|
-
console.error(` 修复建议:`)
|
|
77
|
-
console.error(` 1. 运行 sillyspec worktree doctor --fix 检查并修复 worktree 状态`)
|
|
78
|
-
console.error(` 2. 或手动清理残留:git worktree prune && git branch -D sillyspec/${effectiveChange}`)
|
|
79
|
-
console.error(` 3. 必要时删除残留目录 .sillyspec/.runtime/worktrees/${effectiveChange}/ 后重试`)
|
|
80
|
-
process.exit(1)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// 入口 deps 自检(D-002):已存在 worktree(create short-circuit 不供给)时重供给
|
|
84
|
-
if (existingMeta) {
|
|
85
|
-
const execSpecBase = platformOpts?.specRoot || join(cwd, '.sillyspec')
|
|
86
|
-
await ensureDepsFreshness(cwd, effectiveChange, execSpecBase, existingMeta)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// ── execute 阶段启动时固定 executeRunId(绑定变更名,避免跨变更复用) ──
|
|
91
|
-
let currentExecuteRunId = null
|
|
92
|
-
if (stageName === 'execute') {
|
|
93
|
-
const { generateExecuteRunId, isValidExecuteRunId } = await import('../task-review.js')
|
|
94
|
-
const execSpecBase = platformOpts?.specRoot || join(cwd, '.sillyspec')
|
|
95
|
-
const runtimeRoot = resolveRuntimeRoot(platformOpts, execSpecBase)
|
|
96
|
-
const runIdFile = join(runtimeRoot, `current-execute-run-id-${changeName}`)
|
|
97
|
-
mkdirSync(runtimeRoot, { recursive: true })
|
|
98
|
-
// 优先读取已有的变更专属标记文件(agent 可写内容,格式校验防注入/穿越,非法视为缺失重生成)
|
|
99
|
-
try {
|
|
100
|
-
if (existsSync(runIdFile)) {
|
|
101
|
-
const c = readFileSync(runIdFile, 'utf8').trim()
|
|
102
|
-
if (c && !isValidExecuteRunId(c)) {
|
|
103
|
-
console.warn(`⚠️ execute run marker 内容非法(期望 exec-YYYY-MM-DD-HHMMSS,实得 ${JSON.stringify(c.slice(0, 60))}),重新生成`)
|
|
104
|
-
} else {
|
|
105
|
-
currentExecuteRunId = c
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
} catch {}
|
|
109
|
-
if (!currentExecuteRunId) {
|
|
110
|
-
currentExecuteRunId = generateExecuteRunId()
|
|
111
|
-
// D-001#1 主写入点:mkdir execute-runs/<runId>/tasks 先于 marker(不变量:marker 在则目录在,
|
|
112
|
-
// archive 完成度扫描/漂移兜底不再落到「有 marker 无目录」的空 run)。失败直接 throw——execute
|
|
113
|
-
// 启动即失败优于事后 review 错配(调用方 runCommand 冒到 CLI 顶层 exit 1,给出修复指引)。
|
|
114
|
-
try {
|
|
115
|
-
mkdirSync(join(runtimeRoot, 'execute-runs', currentExecuteRunId, 'tasks'), { recursive: true })
|
|
116
|
-
} catch (e) {
|
|
117
|
-
throw new Error(`execute run 目录创建失败(${join(runtimeRoot, 'execute-runs', currentExecuteRunId)}): ${e.message};` +
|
|
118
|
-
`请检查该路径是否为普通文件/只读,清理后重跑(sillyspec run execute --change ${changeName} --skip-approval)`)
|
|
119
|
-
}
|
|
120
|
-
writeFileSync(runIdFile, currentExecuteRunId + '\n')
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 自动探测 currentChange
|
|
125
|
-
if (autoDetectChange(progress, cwd)) {
|
|
126
|
-
progress.lastActive = new Date().toLocaleString('zh-CN', { hour12: false })
|
|
127
|
-
pm._write(cwd, progress, changeName)
|
|
128
|
-
triggerSync(cwd, changeName, platformOpts)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const stageData = progress.stages[stageName]
|
|
132
|
-
if (!stageData || !stageData.steps) {
|
|
133
|
-
console.error(`❌ 阶段 ${stageName} 未初始化`)
|
|
134
|
-
process.exit(1)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// 用户显式调用 sillyspec run <stage>:把它标记为当前阶段
|
|
138
|
-
// (D-003@v1:auxiliary 阶段不写 currentStage,避免 scan/quick/explore/archive/status/doctor
|
|
139
|
-
// 执行后污染主流程当前阶段;lastActive 心跳与 pm._write/triggerSync 照常)
|
|
140
|
-
if (progress.currentStage !== stageName) {
|
|
141
|
-
if (!AUXILIARY_STAGES.includes(stageName)) {
|
|
142
|
-
progress.currentStage = stageName
|
|
143
|
-
}
|
|
144
|
-
progress.lastActive = new Date().toLocaleString('zh-CN',{hour12:false})
|
|
145
|
-
pm._write(cwd, progress, changeName)
|
|
146
|
-
triggerSync(cwd, changeName, platformOpts)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const steps = stageData.steps
|
|
150
|
-
// ── 检查是否有 waiting step 需要先处理 ──
|
|
151
|
-
const waitingIdx = steps.findIndex(s => s.status === 'waiting')
|
|
152
|
-
if (waitingIdx !== -1) {
|
|
153
|
-
const ws = steps[waitingIdx]
|
|
154
|
-
console.error(`\n⏸️ Step ${waitingIdx + 1}/${steps.length} 正在等待用户输入:${ws.name}`)
|
|
155
|
-
if (ws.waitReason) console.error(` 原因:${ws.waitReason}`)
|
|
156
|
-
if (ws.waitOptions) console.error(` 选项:${formatWaitOptions(ws.waitOptions)}`)
|
|
157
|
-
console.error(`\n 普通运行无法跳过等待中的步骤。请先处理:`)
|
|
158
|
-
console.error(` sillyspec run ${stageName} --continue --answer "你的选择"${changeName ? ` --change ${changeName}` : ''}`)
|
|
159
|
-
process.exit(1)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
let currentIdx = steps.findIndex(s => s.status !== 'completed' && s.status !== 'skipped')
|
|
163
|
-
|
|
164
|
-
// stale 步骤视为可执行(等同于 pending)
|
|
165
|
-
if (currentIdx !== -1 && steps[currentIdx].status === 'stale') {
|
|
166
|
-
steps[currentIdx].status = 'pending'
|
|
167
|
-
pm._write(cwd, progress, changeName)
|
|
168
|
-
triggerSync(cwd, changeName, platformOpts)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// ── scanProfile: 根据 project 规模动态裁剪步骤 ──
|
|
172
|
-
let scanProfile = null
|
|
173
|
-
if (stageName === 'scan' && steps.length > 0 && currentIdx === 0) {
|
|
174
|
-
scanProfile = computeScanProfile(cwd, platformOpts)
|
|
175
|
-
console.log(`\n📊 Scan Profile: ${scanProfile.mode} (原因: ${scanProfile.reason})`)
|
|
176
|
-
if (scanProfile.mode !== 'deep') {
|
|
177
|
-
applyScanProfileSteps(stageData, scanProfile, cwd, platformOpts)
|
|
178
|
-
// 步骤被裁剪后 currentIdx 需要重新计算
|
|
179
|
-
currentIdx = 0
|
|
180
|
-
}
|
|
181
|
-
// 保存 profile 供后续 postcheck 使用
|
|
182
|
-
stageData.scanProfile = scanProfile
|
|
183
|
-
pm._write(cwd, progress, changeName)
|
|
184
|
-
} else if (stageName === 'scan' && stageData.scanProfile) {
|
|
185
|
-
scanProfile = stageData.scanProfile
|
|
186
|
-
}
|
|
187
|
-
if (scanProfile) platformOpts.scanProfile = scanProfile
|
|
188
|
-
|
|
189
|
-
if (stageName === 'scan') {
|
|
190
|
-
try {
|
|
191
|
-
const gitResult = safeGit(cwd, ['rev-parse', 'HEAD'])
|
|
192
|
-
const scanGuard = {
|
|
193
|
-
name_zh: '扫描守卫',
|
|
194
|
-
sourceCommit: gitResult.value,
|
|
195
|
-
sourceCommitError: gitResult.error,
|
|
196
|
-
startedAt: new Date().toISOString(),
|
|
197
|
-
forceRescan: quickOpts?.isForceRescan || false,
|
|
198
|
-
}
|
|
199
|
-
const guardFile = join(specBase, '.runtime', 'scan-guard.json')
|
|
200
|
-
mkdirSync(dirname(guardFile), { recursive: true })
|
|
201
|
-
writeFileSync(guardFile, JSON.stringify(scanGuard, null, 2) + '\n')
|
|
202
|
-
if (scanGuard.forceRescan) {
|
|
203
|
-
console.log('🛡️ scan 覆盖保护已记录: --force-rescan 已开启')
|
|
204
|
-
} else {
|
|
205
|
-
console.log('🛡️ scan 覆盖保护已记录: existing scan docs require current source_commit/updated_at')
|
|
206
|
-
}
|
|
207
|
-
} catch (e) {
|
|
208
|
-
console.warn(`⚠️ scan 覆盖保护记录失败: ${e.message}`)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (currentIdx === -1) {
|
|
213
|
-
// 所有步骤已 completed/skipped,但阶段未盖到 completed —— 这是上次最后一步完成后、
|
|
214
|
-
// stage 升级事务未提交的崩溃中间态(正常完成会被上方 stageStatus==='completed' 守卫拦下)。
|
|
215
|
-
// 旧逻辑无条件清空 steps 为 pending 会丢掉已完成的进度且不可恢复。改为走正式
|
|
216
|
-
// completeStage:产物齐则补盖完成戳,不齐则给出 actionable 提示,永不静默清空步骤。
|
|
217
|
-
console.log(`\nℹ️ ${stageName} 所有步骤已完成,但阶段未标记完成(上次可能中断)。尝试补盖完成戳…`)
|
|
218
|
-
pm.completeStage(cwd, stageName, changeName)
|
|
219
|
-
const after = pm.read(cwd, changeName)
|
|
220
|
-
if (after?.stages?.[stageName]?.status === 'completed') {
|
|
221
|
-
console.log(` ✅ 已补盖完成戳。下一步: sillyspec run <下一阶段>,或 sillyspec run ${stageName} --status 查看。`)
|
|
222
|
-
process.exit(0)
|
|
223
|
-
}
|
|
224
|
-
// completeStage 已打印产物校验失败的明细;这里只补充恢复指引
|
|
225
|
-
console.error(`\n ⚠️ 已保留步骤进度(未清空)。修复产物后重跑,或:`)
|
|
226
|
-
console.error(` - 重新开始: sillyspec run ${stageName} --reset`)
|
|
227
|
-
console.error(` - 强制补盖: sillyspec progress complete-stage ${stageName}${changeName ? ` --change ${changeName}` : ''} --force`)
|
|
228
|
-
process.exit(1)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// quick 阶段:记录 baselineFiles + 分配 ql-ID(CLI 接管 QUICKLOG 写入)
|
|
232
|
-
// 幂等判据是 session guard.json 文件(跨进程可靠),不是 progress.quickGuard
|
|
233
|
-
// (D-003@v1:顶层 quickGuard 不跨进程持久化;agent 在 step 间用 `run quick` 取下一步
|
|
234
|
-
// prompt 时每个新进程都进此块,按文件判幂等才不会重复分配 ql-ID / 重复写条目)。
|
|
235
|
-
if (stageName === 'quick') {
|
|
236
|
-
// quick-sessions 目录经 resolveQuickSessionsDir 单一解析(multi-agent-review Q4):
|
|
237
|
-
// 平台模式 runtimeRoot 与 specBase/.runtime 不同时,写/读须对齐,否则 guard 写一处、收尾读另一处。
|
|
238
|
-
const sessionGuardDir = join(resolveQuickSessionsDir(platformOpts, specBase), changeName)
|
|
239
|
-
const guardFile = join(sessionGuardDir, 'guard.json')
|
|
240
|
-
let existingGuard = null
|
|
241
|
-
try {
|
|
242
|
-
if (existsSync(guardFile)) existingGuard = JSON.parse(readFileSync(guardFile, 'utf8'))
|
|
243
|
-
} catch {}
|
|
244
|
-
if (existingGuard) {
|
|
245
|
-
// 跨进程重入:复用已分配的 ql-ID,跳过 baseline 重捕与分配(幂等)
|
|
246
|
-
progress.quickGuard = existingGuard
|
|
247
|
-
} else {
|
|
248
|
-
// baseline 采集用 safeGit(带 -c safe.directory,避免 linked worktree/容器异 uid/Windows 挂载点
|
|
249
|
-
// 下裸 `git status` 抛错)。safeGit 已消除 safe.directory 类失败;若仍失败(真非 git 目录等),
|
|
250
|
-
// 不硬阻断 quick 启动(平台模式/非 git 目录仍需渲染 step prompt),但 fail-visible:大声 warn +
|
|
251
|
-
// baseline 置空。--done 时 auditQuickCompletion 的 safeGit 同样失败 → blocked,故不存在「静默
|
|
252
|
-
// 完成」路径(multi-agent-review Q3)。
|
|
253
|
-
const statusResult = safeGit(cwd, ['status', '--porcelain'], { trim: false })
|
|
254
|
-
if (statusResult.error) {
|
|
255
|
-
console.warn(`⚠️ quick baseline 采集失败(git status): ${statusResult.error}`)
|
|
256
|
-
console.warn(` baseline 置空;--done 审计将因 git 不可用而阻断(无静默完成路径)。`)
|
|
257
|
-
console.warn(` 排查:仓库 safe.directory 配置 / 非 git 目录。`)
|
|
258
|
-
}
|
|
259
|
-
try {
|
|
260
|
-
const gitStatus = statusResult.value || ''
|
|
261
|
-
// 记录全部预存脏文件(含 untracked + .sillyspec/ 路径)。quick 会话期间自身写入的元数据
|
|
262
|
-
// (quicklog/.runtime/modules/_module-map 等)由 auditQuickCompletion 的 isQuickMetadata 精确豁免,
|
|
263
|
-
// 不需要这里粗放过滤 .sillyspec/——旧过滤致预存 untracked .sillyspec/changes/ 不进 baseline,
|
|
264
|
-
// 却在 audit 被当「危险(.sillyspec/)+新增」误判永久 blocked(ql-20260713-002-7628 修复)。
|
|
265
|
-
const baselineFiles = gitStatus
|
|
266
|
-
.split('\n').filter(Boolean)
|
|
267
|
-
.map(line => parsePorcelainPath(line))
|
|
268
|
-
.filter(Boolean)
|
|
269
|
-
const allowedFiles = quickOpts?.quickFiles || []
|
|
270
|
-
const allowNew = quickOpts?.isAllowNew || false
|
|
271
|
-
const allowDelete = quickOpts?.isAllowDelete || false
|
|
272
|
-
const forceBaseline = quickOpts?.isForceBaseline || false
|
|
273
|
-
const linkedChanges = Array.isArray(quickOpts?.linkedChanges) ? quickOpts.linkedChanges : []
|
|
274
|
-
// CLI 接管:分配 ql-ID + 写 QUICKLOG「进行中」条目 + 关联 tasks.md(持锁、当天唯一)
|
|
275
|
-
const gitUser = safeGit(cwd, ['config', 'user.name']).value || 'unknown'
|
|
276
|
-
// 标题回退:启动 quick 不带 --input 时,从关联变更的 proposal/design 提取语义标题,
|
|
277
|
-
// 避免 QUICKLOG/tasks.md 落 (quick 任务) 占位(deriveTitleFromLinkedChange 读不到则空→sanitizeDesc 回退占位)。
|
|
278
|
-
let quickDesc = quickOpts?.taskDescription || ''
|
|
279
|
-
if (!quickDesc && linkedChanges.length > 0) {
|
|
280
|
-
quickDesc = deriveTitleFromLinkedChange(specBase, linkedChanges[0])
|
|
281
|
-
}
|
|
282
|
-
const { qlId } = await allocateQuicklogEntry(specBase, gitUser, {
|
|
283
|
-
description: quickDesc,
|
|
284
|
-
linkedChanges,
|
|
285
|
-
allowedFiles,
|
|
286
|
-
})
|
|
287
|
-
progress.quickGuard = {
|
|
288
|
-
sessionId: changeName,
|
|
289
|
-
// 锚定创建时的 specBase(坑 quick-cwd-drift-splits-specdir):sessionId 全局复用但
|
|
290
|
-
// guard 按 specDir 落盘,记下归属让漂移可自证(detectQuickSessionDrift 靠目录定位即可,
|
|
291
|
-
// 此字段供诊断/未来一致性校验)。
|
|
292
|
-
specDir: specBase,
|
|
293
|
-
name_zh: '快速任务守卫',
|
|
294
|
-
baselineCommit: safeGit(cwd, ['rev-parse', 'HEAD']).value,
|
|
295
|
-
baselineFiles,
|
|
296
|
-
allowedFiles,
|
|
297
|
-
// task-01: 录每个 allowedFile 内容 sha256,供 --done auditQuickCompletion 检测同文件并发
|
|
298
|
-
// (allowedFile 在 baseline 且当前 hash ≠ 此值 = 我也改了 → 同文件并发 warn)。文件不存在/读失败跳过。
|
|
299
|
-
allowedFilesHash: Object.fromEntries(allowedFiles.flatMap(f => {
|
|
300
|
-
try { return [[f, createHash('sha256').update(readFileSync(join(cwd, f))).digest('hex')]] }
|
|
301
|
-
catch { return [] }
|
|
302
|
-
})),
|
|
303
|
-
allowNew,
|
|
304
|
-
allowDelete,
|
|
305
|
-
forceBaseline,
|
|
306
|
-
linkedChanges,
|
|
307
|
-
quicklogId: qlId,
|
|
308
|
-
startedAt: new Date().toISOString(),
|
|
309
|
-
}
|
|
310
|
-
// 写入 .runtime/quick-sessions/<sessionId>/guard.json 供 worktree-guard hook 读取
|
|
311
|
-
// (D-002:按 session 存,多会话各自 guard 不互覆盖。runStage 作用域内 sessionId == changeName == quick-<uuid8>,见 §4.4/4.5)
|
|
312
|
-
mkdirSync(sessionGuardDir, { recursive: true })
|
|
313
|
-
writeAtomicSync(guardFile, JSON.stringify(progress.quickGuard, null, 2))
|
|
314
|
-
const parts = [`${baselineFiles.length} 个已有脏文件`]
|
|
315
|
-
if (allowedFiles.length > 0) parts.push(`${allowedFiles.length} 个 allowedFiles`)
|
|
316
|
-
if (allowNew) parts.push('允许新增文件')
|
|
317
|
-
if (allowDelete) parts.push('允许删除文件')
|
|
318
|
-
console.log(`🛡️ quick 变更边界已记录: ${parts.join(', ')}`)
|
|
319
|
-
console.log(`📝 QUICKLOG 条目已创建: ${qlId}`)
|
|
320
|
-
// 回填 DB changes 行的 title + quicklog_id,让 quick-<hex> 可读、DB↔QUICKLOG 可对账。
|
|
321
|
-
// title 用 quickDesc(任务描述或关联变更标题)经 sanitizeDesc 压一行限长,与 QUICKLOG 条目标题同源。
|
|
322
|
-
try {
|
|
323
|
-
pm.updateChangeMeta(cwd, changeName, { title: sanitizeDesc(quickDesc), quicklogId: qlId });
|
|
324
|
-
} catch { /* 回填失败不阻断 quick 启动 */ }
|
|
325
|
-
pm._write(cwd, progress, changeName)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (
|
|
341
|
-
const
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
console.
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
stageData.steps
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
|
|
1
|
+
/**
|
|
2
|
+
* run/stage.js(W6 Step8b 从 run.js 抽出)。
|
|
3
|
+
*
|
|
4
|
+
* `run <stage>` 默认路径的执行主干(runStage)+ 其私有 helper:
|
|
5
|
+
* - runStage:输出当前 step prompt(重 execute/scan/quick 启动期副作用——worktree 创建、
|
|
6
|
+
* executeRunId 固定、scanProfile 裁剪、quick baseline 录入、plan design 契约校验、noAI 步骤代理)
|
|
7
|
+
* - autoDetectChange:唯一变更目录时自动设置 currentChange(runStage 私有)
|
|
8
|
+
* - executePlanPostcheck:noAI planPostcheck 步骤代理(runStage 私有)
|
|
9
|
+
* - ensureDepsFreshness:execute 入口已存在 worktree 时 deps 自检重供给(runStage 私有)
|
|
10
|
+
*
|
|
11
|
+
* 安全锚:run.js 始终 barrel。runStage 由 run.js import 回来(无 test 直接 import,无需 re-export)。
|
|
12
|
+
* checkApproval(runStage + runAutoMode 共用)已先下沉 shared.js(Step8a),避免 command/stage 环依赖。
|
|
13
|
+
*
|
|
14
|
+
* 路径修正(相对 src/run/):
|
|
15
|
+
* - 动态 import './worktree.js' / './task-review.js' / './stages/plan.js' /
|
|
16
|
+
* './stages/plan-postcheck.js' / './worktree-deps.js' → '../'(src/ 下退一层)
|
|
17
|
+
* - 'child_process'(execSync)裸模块名不变
|
|
18
|
+
*/
|
|
19
|
+
import { join, dirname } from 'node:path'
|
|
20
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'
|
|
21
|
+
import { writeAtomicSync } from '../fs-atomic.js'
|
|
22
|
+
import { resolveSpecDir, resolveChangeDir, resolveRuntimeRoot, resolveQuickSessionsDir, triggerSync, safeGit, parsePorcelainPath, formatWaitOptions, checkApproval, getStageSteps } from './shared.js'
|
|
23
|
+
import { computeScanProfile, applyScanProfileSteps, executeScanPreflight, executeScanPostcheck } from './scan-profile.js'
|
|
24
|
+
import { outputStep } from './prompt.js'
|
|
25
|
+
import { allocateQuicklogEntry, deriveTitleFromLinkedChange, sanitizeDesc } from '../quicklog.js'
|
|
26
|
+
import { createHash } from 'node:crypto'
|
|
27
|
+
import { checkTransition } from '../stage-contract.js'
|
|
28
|
+
import { AUXILIARY_STAGES } from '../constants.js'
|
|
29
|
+
import { completeStageGates } from './gates.js'
|
|
30
|
+
|
|
31
|
+
export async function runStage(pm, progress, stageName, cwd, changeName, skipApproval = false, platformOpts = {}, quickOpts = {}) {
|
|
32
|
+
const specBase = platformOpts.specRoot || join(cwd, '.sillyspec')
|
|
33
|
+
// 状态转换校验
|
|
34
|
+
const prevStage = progress.currentStage || ''
|
|
35
|
+
// task-07: 提取 prevStage 的 stageData,传给 checkTransition 检测 failed_post_check 门控
|
|
36
|
+
const fromStageData = (progress.stages && prevStage && progress.stages[prevStage]) || undefined
|
|
37
|
+
const transition = checkTransition(prevStage, stageName, fromStageData ? { fromStageData } : {})
|
|
38
|
+
if (!transition.allowed) {
|
|
39
|
+
console.error(`❌ 阶段转换不允许: ${prevStage || '(起始)'} → ${stageName}`)
|
|
40
|
+
console.error(` 原因: ${transition.reason}`)
|
|
41
|
+
console.error(` 提示: 使用 --skip-approval 绕过(需明确意图)`)
|
|
42
|
+
if (!skipApproval) {
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// execute 阶段启动前检查审批
|
|
48
|
+
if (stageName === 'execute' && !skipApproval) {
|
|
49
|
+
const approval = await checkApproval(cwd, changeName, platformOpts)
|
|
50
|
+
if (approval) {
|
|
51
|
+
if (approval.status === 'rejected') {
|
|
52
|
+
console.error(`❌ 变更 ${changeName} 的执行已被拒绝:${approval.reason || '无原因'}`)
|
|
53
|
+
process.exit(1)
|
|
54
|
+
}
|
|
55
|
+
if (approval.status === 'pending') {
|
|
56
|
+
console.log(`⏳ 变更 ${changeName} 的执行审批待处理中...`)
|
|
57
|
+
console.log(' 提示:使用 --skip-approval 跳过审批检查')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// execute 阶段:CLI 自动创建 worktree(不等 AI agent)
|
|
63
|
+
if (stageName === 'execute' && changeName) {
|
|
64
|
+
const effectiveChange = changeName
|
|
65
|
+
const { WorktreeManager } = await import('../worktree.js')
|
|
66
|
+
const wm = new WorktreeManager({ cwd })
|
|
67
|
+
const existingMeta = wm.getMeta(effectiveChange)
|
|
68
|
+
if (existingMeta) {
|
|
69
|
+
console.log(`🔗 worktree 已存在: ${existingMeta.worktreePath} (${existingMeta.mode})`)
|
|
70
|
+
} else {
|
|
71
|
+
try {
|
|
72
|
+
const result = wm.create(effectiveChange)
|
|
73
|
+
console.log(`🔗 worktree 已创建: ${result.worktreePath} (分支: ${result.branch}, 模式: ${result.mode})`)
|
|
74
|
+
} catch (e) {
|
|
75
|
+
console.error(`❌ worktree 创建失败: ${e.message}`)
|
|
76
|
+
console.error(` 修复建议:`)
|
|
77
|
+
console.error(` 1. 运行 sillyspec worktree doctor --fix 检查并修复 worktree 状态`)
|
|
78
|
+
console.error(` 2. 或手动清理残留:git worktree prune && git branch -D sillyspec/${effectiveChange}`)
|
|
79
|
+
console.error(` 3. 必要时删除残留目录 .sillyspec/.runtime/worktrees/${effectiveChange}/ 后重试`)
|
|
80
|
+
process.exit(1)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// 入口 deps 自检(D-002):已存在 worktree(create short-circuit 不供给)时重供给
|
|
84
|
+
if (existingMeta) {
|
|
85
|
+
const execSpecBase = platformOpts?.specRoot || join(cwd, '.sillyspec')
|
|
86
|
+
await ensureDepsFreshness(cwd, effectiveChange, execSpecBase, existingMeta)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ── execute 阶段启动时固定 executeRunId(绑定变更名,避免跨变更复用) ──
|
|
91
|
+
let currentExecuteRunId = null
|
|
92
|
+
if (stageName === 'execute') {
|
|
93
|
+
const { generateExecuteRunId, isValidExecuteRunId } = await import('../task-review.js')
|
|
94
|
+
const execSpecBase = platformOpts?.specRoot || join(cwd, '.sillyspec')
|
|
95
|
+
const runtimeRoot = resolveRuntimeRoot(platformOpts, execSpecBase)
|
|
96
|
+
const runIdFile = join(runtimeRoot, `current-execute-run-id-${changeName}`)
|
|
97
|
+
mkdirSync(runtimeRoot, { recursive: true })
|
|
98
|
+
// 优先读取已有的变更专属标记文件(agent 可写内容,格式校验防注入/穿越,非法视为缺失重生成)
|
|
99
|
+
try {
|
|
100
|
+
if (existsSync(runIdFile)) {
|
|
101
|
+
const c = readFileSync(runIdFile, 'utf8').trim()
|
|
102
|
+
if (c && !isValidExecuteRunId(c)) {
|
|
103
|
+
console.warn(`⚠️ execute run marker 内容非法(期望 exec-YYYY-MM-DD-HHMMSS,实得 ${JSON.stringify(c.slice(0, 60))}),重新生成`)
|
|
104
|
+
} else {
|
|
105
|
+
currentExecuteRunId = c
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} catch {}
|
|
109
|
+
if (!currentExecuteRunId) {
|
|
110
|
+
currentExecuteRunId = generateExecuteRunId()
|
|
111
|
+
// D-001#1 主写入点:mkdir execute-runs/<runId>/tasks 先于 marker(不变量:marker 在则目录在,
|
|
112
|
+
// archive 完成度扫描/漂移兜底不再落到「有 marker 无目录」的空 run)。失败直接 throw——execute
|
|
113
|
+
// 启动即失败优于事后 review 错配(调用方 runCommand 冒到 CLI 顶层 exit 1,给出修复指引)。
|
|
114
|
+
try {
|
|
115
|
+
mkdirSync(join(runtimeRoot, 'execute-runs', currentExecuteRunId, 'tasks'), { recursive: true })
|
|
116
|
+
} catch (e) {
|
|
117
|
+
throw new Error(`execute run 目录创建失败(${join(runtimeRoot, 'execute-runs', currentExecuteRunId)}): ${e.message};` +
|
|
118
|
+
`请检查该路径是否为普通文件/只读,清理后重跑(sillyspec run execute --change ${changeName} --skip-approval)`)
|
|
119
|
+
}
|
|
120
|
+
writeFileSync(runIdFile, currentExecuteRunId + '\n')
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 自动探测 currentChange
|
|
125
|
+
if (autoDetectChange(progress, cwd)) {
|
|
126
|
+
progress.lastActive = new Date().toLocaleString('zh-CN', { hour12: false })
|
|
127
|
+
pm._write(cwd, progress, changeName)
|
|
128
|
+
triggerSync(cwd, changeName, platformOpts)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const stageData = progress.stages[stageName]
|
|
132
|
+
if (!stageData || !stageData.steps) {
|
|
133
|
+
console.error(`❌ 阶段 ${stageName} 未初始化`)
|
|
134
|
+
process.exit(1)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 用户显式调用 sillyspec run <stage>:把它标记为当前阶段
|
|
138
|
+
// (D-003@v1:auxiliary 阶段不写 currentStage,避免 scan/quick/explore/archive/status/doctor
|
|
139
|
+
// 执行后污染主流程当前阶段;lastActive 心跳与 pm._write/triggerSync 照常)
|
|
140
|
+
if (progress.currentStage !== stageName) {
|
|
141
|
+
if (!AUXILIARY_STAGES.includes(stageName)) {
|
|
142
|
+
progress.currentStage = stageName
|
|
143
|
+
}
|
|
144
|
+
progress.lastActive = new Date().toLocaleString('zh-CN',{hour12:false})
|
|
145
|
+
pm._write(cwd, progress, changeName)
|
|
146
|
+
triggerSync(cwd, changeName, platformOpts)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const steps = stageData.steps
|
|
150
|
+
// ── 检查是否有 waiting step 需要先处理 ──
|
|
151
|
+
const waitingIdx = steps.findIndex(s => s.status === 'waiting')
|
|
152
|
+
if (waitingIdx !== -1) {
|
|
153
|
+
const ws = steps[waitingIdx]
|
|
154
|
+
console.error(`\n⏸️ Step ${waitingIdx + 1}/${steps.length} 正在等待用户输入:${ws.name}`)
|
|
155
|
+
if (ws.waitReason) console.error(` 原因:${ws.waitReason}`)
|
|
156
|
+
if (ws.waitOptions) console.error(` 选项:${formatWaitOptions(ws.waitOptions)}`)
|
|
157
|
+
console.error(`\n 普通运行无法跳过等待中的步骤。请先处理:`)
|
|
158
|
+
console.error(` sillyspec run ${stageName} --continue --answer "你的选择"${changeName ? ` --change ${changeName}` : ''}`)
|
|
159
|
+
process.exit(1)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let currentIdx = steps.findIndex(s => s.status !== 'completed' && s.status !== 'skipped')
|
|
163
|
+
|
|
164
|
+
// stale 步骤视为可执行(等同于 pending)
|
|
165
|
+
if (currentIdx !== -1 && steps[currentIdx].status === 'stale') {
|
|
166
|
+
steps[currentIdx].status = 'pending'
|
|
167
|
+
pm._write(cwd, progress, changeName)
|
|
168
|
+
triggerSync(cwd, changeName, platformOpts)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ── scanProfile: 根据 project 规模动态裁剪步骤 ──
|
|
172
|
+
let scanProfile = null
|
|
173
|
+
if (stageName === 'scan' && steps.length > 0 && currentIdx === 0) {
|
|
174
|
+
scanProfile = computeScanProfile(cwd, platformOpts)
|
|
175
|
+
console.log(`\n📊 Scan Profile: ${scanProfile.mode} (原因: ${scanProfile.reason})`)
|
|
176
|
+
if (scanProfile.mode !== 'deep') {
|
|
177
|
+
applyScanProfileSteps(stageData, scanProfile, cwd, platformOpts)
|
|
178
|
+
// 步骤被裁剪后 currentIdx 需要重新计算
|
|
179
|
+
currentIdx = 0
|
|
180
|
+
}
|
|
181
|
+
// 保存 profile 供后续 postcheck 使用
|
|
182
|
+
stageData.scanProfile = scanProfile
|
|
183
|
+
pm._write(cwd, progress, changeName)
|
|
184
|
+
} else if (stageName === 'scan' && stageData.scanProfile) {
|
|
185
|
+
scanProfile = stageData.scanProfile
|
|
186
|
+
}
|
|
187
|
+
if (scanProfile) platformOpts.scanProfile = scanProfile
|
|
188
|
+
|
|
189
|
+
if (stageName === 'scan') {
|
|
190
|
+
try {
|
|
191
|
+
const gitResult = safeGit(cwd, ['rev-parse', 'HEAD'])
|
|
192
|
+
const scanGuard = {
|
|
193
|
+
name_zh: '扫描守卫',
|
|
194
|
+
sourceCommit: gitResult.value,
|
|
195
|
+
sourceCommitError: gitResult.error,
|
|
196
|
+
startedAt: new Date().toISOString(),
|
|
197
|
+
forceRescan: quickOpts?.isForceRescan || false,
|
|
198
|
+
}
|
|
199
|
+
const guardFile = join(specBase, '.runtime', 'scan-guard.json')
|
|
200
|
+
mkdirSync(dirname(guardFile), { recursive: true })
|
|
201
|
+
writeFileSync(guardFile, JSON.stringify(scanGuard, null, 2) + '\n')
|
|
202
|
+
if (scanGuard.forceRescan) {
|
|
203
|
+
console.log('🛡️ scan 覆盖保护已记录: --force-rescan 已开启')
|
|
204
|
+
} else {
|
|
205
|
+
console.log('🛡️ scan 覆盖保护已记录: existing scan docs require current source_commit/updated_at')
|
|
206
|
+
}
|
|
207
|
+
} catch (e) {
|
|
208
|
+
console.warn(`⚠️ scan 覆盖保护记录失败: ${e.message}`)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (currentIdx === -1) {
|
|
213
|
+
// 所有步骤已 completed/skipped,但阶段未盖到 completed —— 这是上次最后一步完成后、
|
|
214
|
+
// stage 升级事务未提交的崩溃中间态(正常完成会被上方 stageStatus==='completed' 守卫拦下)。
|
|
215
|
+
// 旧逻辑无条件清空 steps 为 pending 会丢掉已完成的进度且不可恢复。改为走正式
|
|
216
|
+
// completeStage:产物齐则补盖完成戳,不齐则给出 actionable 提示,永不静默清空步骤。
|
|
217
|
+
console.log(`\nℹ️ ${stageName} 所有步骤已完成,但阶段未标记完成(上次可能中断)。尝试补盖完成戳…`)
|
|
218
|
+
pm.completeStage(cwd, stageName, changeName)
|
|
219
|
+
const after = pm.read(cwd, changeName)
|
|
220
|
+
if (after?.stages?.[stageName]?.status === 'completed') {
|
|
221
|
+
console.log(` ✅ 已补盖完成戳。下一步: sillyspec run <下一阶段>,或 sillyspec run ${stageName} --status 查看。`)
|
|
222
|
+
process.exit(0)
|
|
223
|
+
}
|
|
224
|
+
// completeStage 已打印产物校验失败的明细;这里只补充恢复指引
|
|
225
|
+
console.error(`\n ⚠️ 已保留步骤进度(未清空)。修复产物后重跑,或:`)
|
|
226
|
+
console.error(` - 重新开始: sillyspec run ${stageName} --reset`)
|
|
227
|
+
console.error(` - 强制补盖: sillyspec progress complete-stage ${stageName}${changeName ? ` --change ${changeName}` : ''} --force`)
|
|
228
|
+
process.exit(1)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// quick 阶段:记录 baselineFiles + 分配 ql-ID(CLI 接管 QUICKLOG 写入)
|
|
232
|
+
// 幂等判据是 session guard.json 文件(跨进程可靠),不是 progress.quickGuard
|
|
233
|
+
// (D-003@v1:顶层 quickGuard 不跨进程持久化;agent 在 step 间用 `run quick` 取下一步
|
|
234
|
+
// prompt 时每个新进程都进此块,按文件判幂等才不会重复分配 ql-ID / 重复写条目)。
|
|
235
|
+
if (stageName === 'quick') {
|
|
236
|
+
// quick-sessions 目录经 resolveQuickSessionsDir 单一解析(multi-agent-review Q4):
|
|
237
|
+
// 平台模式 runtimeRoot 与 specBase/.runtime 不同时,写/读须对齐,否则 guard 写一处、收尾读另一处。
|
|
238
|
+
const sessionGuardDir = join(resolveQuickSessionsDir(platformOpts, specBase), changeName)
|
|
239
|
+
const guardFile = join(sessionGuardDir, 'guard.json')
|
|
240
|
+
let existingGuard = null
|
|
241
|
+
try {
|
|
242
|
+
if (existsSync(guardFile)) existingGuard = JSON.parse(readFileSync(guardFile, 'utf8'))
|
|
243
|
+
} catch {}
|
|
244
|
+
if (existingGuard) {
|
|
245
|
+
// 跨进程重入:复用已分配的 ql-ID,跳过 baseline 重捕与分配(幂等)
|
|
246
|
+
progress.quickGuard = existingGuard
|
|
247
|
+
} else {
|
|
248
|
+
// baseline 采集用 safeGit(带 -c safe.directory,避免 linked worktree/容器异 uid/Windows 挂载点
|
|
249
|
+
// 下裸 `git status` 抛错)。safeGit 已消除 safe.directory 类失败;若仍失败(真非 git 目录等),
|
|
250
|
+
// 不硬阻断 quick 启动(平台模式/非 git 目录仍需渲染 step prompt),但 fail-visible:大声 warn +
|
|
251
|
+
// baseline 置空。--done 时 auditQuickCompletion 的 safeGit 同样失败 → blocked,故不存在「静默
|
|
252
|
+
// 完成」路径(multi-agent-review Q3)。
|
|
253
|
+
const statusResult = safeGit(cwd, ['status', '--porcelain'], { trim: false })
|
|
254
|
+
if (statusResult.error) {
|
|
255
|
+
console.warn(`⚠️ quick baseline 采集失败(git status): ${statusResult.error}`)
|
|
256
|
+
console.warn(` baseline 置空;--done 审计将因 git 不可用而阻断(无静默完成路径)。`)
|
|
257
|
+
console.warn(` 排查:仓库 safe.directory 配置 / 非 git 目录。`)
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
const gitStatus = statusResult.value || ''
|
|
261
|
+
// 记录全部预存脏文件(含 untracked + .sillyspec/ 路径)。quick 会话期间自身写入的元数据
|
|
262
|
+
// (quicklog/.runtime/modules/_module-map 等)由 auditQuickCompletion 的 isQuickMetadata 精确豁免,
|
|
263
|
+
// 不需要这里粗放过滤 .sillyspec/——旧过滤致预存 untracked .sillyspec/changes/ 不进 baseline,
|
|
264
|
+
// 却在 audit 被当「危险(.sillyspec/)+新增」误判永久 blocked(ql-20260713-002-7628 修复)。
|
|
265
|
+
const baselineFiles = gitStatus
|
|
266
|
+
.split('\n').filter(Boolean)
|
|
267
|
+
.map(line => parsePorcelainPath(line))
|
|
268
|
+
.filter(Boolean)
|
|
269
|
+
const allowedFiles = quickOpts?.quickFiles || []
|
|
270
|
+
const allowNew = quickOpts?.isAllowNew || false
|
|
271
|
+
const allowDelete = quickOpts?.isAllowDelete || false
|
|
272
|
+
const forceBaseline = quickOpts?.isForceBaseline || false
|
|
273
|
+
const linkedChanges = Array.isArray(quickOpts?.linkedChanges) ? quickOpts.linkedChanges : []
|
|
274
|
+
// CLI 接管:分配 ql-ID + 写 QUICKLOG「进行中」条目 + 关联 tasks.md(持锁、当天唯一)
|
|
275
|
+
const gitUser = safeGit(cwd, ['config', 'user.name']).value || 'unknown'
|
|
276
|
+
// 标题回退:启动 quick 不带 --input 时,从关联变更的 proposal/design 提取语义标题,
|
|
277
|
+
// 避免 QUICKLOG/tasks.md 落 (quick 任务) 占位(deriveTitleFromLinkedChange 读不到则空→sanitizeDesc 回退占位)。
|
|
278
|
+
let quickDesc = quickOpts?.taskDescription || ''
|
|
279
|
+
if (!quickDesc && linkedChanges.length > 0) {
|
|
280
|
+
quickDesc = deriveTitleFromLinkedChange(specBase, linkedChanges[0])
|
|
281
|
+
}
|
|
282
|
+
const { qlId } = await allocateQuicklogEntry(specBase, gitUser, {
|
|
283
|
+
description: quickDesc,
|
|
284
|
+
linkedChanges,
|
|
285
|
+
allowedFiles,
|
|
286
|
+
})
|
|
287
|
+
progress.quickGuard = {
|
|
288
|
+
sessionId: changeName,
|
|
289
|
+
// 锚定创建时的 specBase(坑 quick-cwd-drift-splits-specdir):sessionId 全局复用但
|
|
290
|
+
// guard 按 specDir 落盘,记下归属让漂移可自证(detectQuickSessionDrift 靠目录定位即可,
|
|
291
|
+
// 此字段供诊断/未来一致性校验)。
|
|
292
|
+
specDir: specBase,
|
|
293
|
+
name_zh: '快速任务守卫',
|
|
294
|
+
baselineCommit: safeGit(cwd, ['rev-parse', 'HEAD']).value,
|
|
295
|
+
baselineFiles,
|
|
296
|
+
allowedFiles,
|
|
297
|
+
// task-01: 录每个 allowedFile 内容 sha256,供 --done auditQuickCompletion 检测同文件并发
|
|
298
|
+
// (allowedFile 在 baseline 且当前 hash ≠ 此值 = 我也改了 → 同文件并发 warn)。文件不存在/读失败跳过。
|
|
299
|
+
allowedFilesHash: Object.fromEntries(allowedFiles.flatMap(f => {
|
|
300
|
+
try { return [[f, createHash('sha256').update(readFileSync(join(cwd, f))).digest('hex')]] }
|
|
301
|
+
catch { return [] }
|
|
302
|
+
})),
|
|
303
|
+
allowNew,
|
|
304
|
+
allowDelete,
|
|
305
|
+
forceBaseline,
|
|
306
|
+
linkedChanges,
|
|
307
|
+
quicklogId: qlId,
|
|
308
|
+
startedAt: new Date().toISOString(),
|
|
309
|
+
}
|
|
310
|
+
// 写入 .runtime/quick-sessions/<sessionId>/guard.json 供 worktree-guard hook 读取
|
|
311
|
+
// (D-002:按 session 存,多会话各自 guard 不互覆盖。runStage 作用域内 sessionId == changeName == quick-<uuid8>,见 §4.4/4.5)
|
|
312
|
+
mkdirSync(sessionGuardDir, { recursive: true })
|
|
313
|
+
writeAtomicSync(guardFile, JSON.stringify(progress.quickGuard, null, 2))
|
|
314
|
+
const parts = [`${baselineFiles.length} 个已有脏文件`]
|
|
315
|
+
if (allowedFiles.length > 0) parts.push(`${allowedFiles.length} 个 allowedFiles`)
|
|
316
|
+
if (allowNew) parts.push('允许新增文件')
|
|
317
|
+
if (allowDelete) parts.push('允许删除文件')
|
|
318
|
+
console.log(`🛡️ quick 变更边界已记录: ${parts.join(', ')}`)
|
|
319
|
+
console.log(`📝 QUICKLOG 条目已创建: ${qlId}`)
|
|
320
|
+
// 回填 DB changes 行的 title + quicklog_id,让 quick-<hex> 可读、DB↔QUICKLOG 可对账。
|
|
321
|
+
// title 用 quickDesc(任务描述或关联变更标题)经 sanitizeDesc 压一行限长,与 QUICKLOG 条目标题同源。
|
|
322
|
+
try {
|
|
323
|
+
pm.updateChangeMeta(cwd, changeName, { title: sanitizeDesc(quickDesc), quicklogId: qlId });
|
|
324
|
+
} catch { /* 回填失败不阻断 quick 启动 */ }
|
|
325
|
+
pm._write(cwd, progress, changeName)
|
|
326
|
+
// ql-20260819-009:起步即推「进行中」占位条目到平台。runStage 前段三处 triggerSync
|
|
327
|
+
// (autoDetectChange / currentStage 切换 / stale 复位)全在本块之前执行——「进行中」骨架
|
|
328
|
+
// 此前要等第一次 --done 才上平台,平台快速修复列表存在起步盲窗。此刻骨架已分配 + 进度已
|
|
329
|
+
// 落盘,补一次 triggerSync 立即推 QUICKLOG(quick-<hex8> 会话自动降级 syncSpecTreeOnly
|
|
330
|
+
// 只推 spec 树;未连接平台静默跳过、8s 熔断 best-effort,均不阻断 quick 启动)。平台派发
|
|
331
|
+
// (claim)模式起步同样走 runStage 本块,一处插入全覆盖;guard 已存在的跨进程重入走上方
|
|
332
|
+
// existingGuard 分支跳过本块,条目已在平台,不重复推。
|
|
333
|
+
triggerSync(cwd, changeName, platformOpts)
|
|
334
|
+
} catch (e) {
|
|
335
|
+
console.warn(`⚠️ baseline 记录失败: ${e.message}`)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (currentIdx > 0) {
|
|
341
|
+
const completed = currentIdx
|
|
342
|
+
const total = steps.length
|
|
343
|
+
console.log(`⚠️ ${stageName} 已进行到第 ${currentIdx + 1}/${total} 步(前 ${completed} 步已完成)。`)
|
|
344
|
+
console.log(` 继续执行将从中断处恢复,用 --reset 可重新开始。\n`)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// ── Brainstorm → Plan Contract:plan 启动前校验 design.md ──
|
|
348
|
+
if (stageName === 'plan' && currentIdx === 0) {
|
|
349
|
+
const changeDir = resolveChangeDir(cwd, progress, platformOpts?.specRoot || null)
|
|
350
|
+
const designPath = changeDir ? join(changeDir, 'design.md') : null
|
|
351
|
+
if (designPath && existsSync(designPath)) {
|
|
352
|
+
const { validateDesignForPlan } = await import('../stages/plan.js')
|
|
353
|
+
const designContent = readFileSync(designPath, 'utf8')
|
|
354
|
+
const designValidation = validateDesignForPlan(designContent)
|
|
355
|
+
if (!designValidation.ok) {
|
|
356
|
+
console.error(`\n❌ Brainstorm → Plan Contract 校验失败:`)
|
|
357
|
+
for (const err of designValidation.errors) console.error(` - ${err}`)
|
|
358
|
+
console.error(`\n design.md 不满足 plan 契约,请先修复后重试。`)
|
|
359
|
+
console.error(` 提示:sillyspec run brainstorm --reopen --from-step <步骤> 修订设计文档`)
|
|
360
|
+
process.exit(1)
|
|
361
|
+
}
|
|
362
|
+
if (designValidation.warnings.length > 0) {
|
|
363
|
+
console.log(`⚠️ Design contract 警告(不阻断):`)
|
|
364
|
+
for (const w of designValidation.warnings) console.log(` - ${w}`)
|
|
365
|
+
console.log()
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const defSteps = await getStageSteps(stageName, cwd, progress, platformOpts?.specRoot || null)
|
|
371
|
+
if (defSteps && defSteps[currentIdx]) {
|
|
372
|
+
// noAI 步骤自动完成(CLI-only,不需要 Agent 参与)
|
|
373
|
+
if (defSteps[currentIdx].noAI || stageData.steps[currentIdx]?.noAI) {
|
|
374
|
+
const stepName = defSteps[currentIdx].name
|
|
375
|
+
const cliAction = defSteps[currentIdx]._cliAction || stageData.steps[currentIdx]?._cliAction
|
|
376
|
+
console.log(`⚙️ Step ${currentIdx + 1}/${stageData.steps.length}: ${stepName}(CLI 自动执行,无需 Agent)`)
|
|
377
|
+
if (cliAction === 'scanPreflight') {
|
|
378
|
+
await executeScanPreflight(cwd, platformOpts, scanProfile)
|
|
379
|
+
} else if (cliAction === 'scanPostcheck') {
|
|
380
|
+
await executeScanPostcheck(cwd, platformOpts, scanProfile)
|
|
381
|
+
} else if (cliAction === 'planPostcheck') {
|
|
382
|
+
await executePlanPostcheck(cwd, platformOpts, progress)
|
|
383
|
+
}
|
|
384
|
+
stageData.steps[currentIdx].status = 'completed'
|
|
385
|
+
stageData.steps[currentIdx].completedAt = new Date().toLocaleString('zh-CN', { hour12: false })
|
|
386
|
+
pm._write(cwd, progress, changeName)
|
|
387
|
+
// 自动前进到下一步
|
|
388
|
+
const nextIdx = stageData.steps.findIndex(s => s.status === 'pending' || s.status === 'in-progress')
|
|
389
|
+
if (nextIdx !== -1 && defSteps[nextIdx]) {
|
|
390
|
+
console.log('')
|
|
391
|
+
await outputStep(stageName, nextIdx, defSteps, cwd, changeName, progress.project || null, platformOpts)
|
|
392
|
+
} else {
|
|
393
|
+
// 所有步骤完成
|
|
394
|
+
stageData.status = 'completed'
|
|
395
|
+
stageData.completedAt = new Date().toLocaleString('zh-CN', { hour12: false })
|
|
396
|
+
// persist _write 移到 completeStageGates 成功之后(task-02 / review-2026-08-09 #2):gate 异常/失败 → rollback 回 in-progress 落盘,此处未到 _write,DB 不留假 completed。
|
|
397
|
+
// 阶段完成收尾共享管线(noAI 末步核心修复 S1:plan postcheck independent-tier review verdict=fail /
|
|
398
|
+
// 平台 scan manifest 此前被绕过)。gate 失败已 rollback 为 in-progress,early-return(不 fall through 到末尾 return)。
|
|
399
|
+
const _stageGatesResult = await completeStageGates({ stageName, cwd, changeName, platformOpts, specBase, progress, pm, stageData, steps, currentIdx, outputText: null })
|
|
400
|
+
// task-04 / A5:gate 失败(stageCompleted===false)设进程退出码 1(与 completeStep/continueStep 同语义)。
|
|
401
|
+
if (_stageGatesResult?.stageCompleted === false) process.exitCode = 1
|
|
402
|
+
if (_stageGatesResult) return _stageGatesResult
|
|
403
|
+
// gate 全过:persist completed(task-02 移后;此处无 triggerSync,与同文件 noAI 末步语义一致)。
|
|
404
|
+
pm._write(cwd, progress, changeName)
|
|
405
|
+
console.log(`\n✅ ${stageName} 阶段全部完成。`)
|
|
406
|
+
}
|
|
407
|
+
return
|
|
408
|
+
}
|
|
409
|
+
await outputStep(stageName, currentIdx, defSteps, cwd, changeName, progress.project || null, platformOpts)
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* 自动探测并设置 currentChange(唯一变更目录时)
|
|
420
|
+
* @returns {boolean} 是否设置了 currentChange
|
|
421
|
+
*/
|
|
422
|
+
function autoDetectChange(progress, cwd, specDir = null) {
|
|
423
|
+
if (progress.currentChange) return false
|
|
424
|
+
const changesDir = join(specDir || resolveSpecDir(cwd), 'changes')
|
|
425
|
+
if (!existsSync(changesDir)) return false
|
|
426
|
+
const entries = readdirSync(changesDir, { withFileTypes: true })
|
|
427
|
+
.filter(e => e.isDirectory() && e.name !== 'archive')
|
|
428
|
+
if (entries.length === 1) {
|
|
429
|
+
progress.currentChange = entries[0].name
|
|
430
|
+
return true
|
|
431
|
+
}
|
|
432
|
+
return false
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Plan postcheck 的执行代理:委托给 plan-postcheck.js 模块
|
|
438
|
+
*/
|
|
439
|
+
async function executePlanPostcheck(cwd, platformOpts, progress) {
|
|
440
|
+
// resolveChangeDir 从 ./shared.js 导入(W6 Step1 抽出的纯函数,原 run.js 本地函数);历史上曾误从 ./modules.js
|
|
441
|
+
// 导入(该模块未导出此函数,得到 undefined),导致 plan-postcheck.js:388 抛
|
|
442
|
+
// "resolveChangeDir is not a function"。详见 docs/sillyspec/plan-postcheck-resolvechangedir-not-a-function.md
|
|
443
|
+
const { executePlanPostcheck: runPostcheck } = await import('../stages/plan-postcheck.js')
|
|
444
|
+
await runPostcheck({
|
|
445
|
+
cwd,
|
|
446
|
+
specRoot: platformOpts?.specRoot,
|
|
447
|
+
resolveChangeDir,
|
|
448
|
+
progress
|
|
449
|
+
})
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* execute 入口 deps 自检(D-002,change 2026-06-28-worktree-deps-provision)。
|
|
456
|
+
* 已存在 worktree(create short-circuit 不供给)时,校验 deps 状态缺失/漂移 → 触发 provisionDeps 重供给并写回 meta。
|
|
457
|
+
*
|
|
458
|
+
* 判定改调共享 checkDepsFreshness(H1,change 2026-08-05-tooling-feedback-fixes task-04):
|
|
459
|
+
* - status ∈ {missing, stale, main-drift, failed} → 触发重供给(main-drift 为新增主仓 lockfile 漂移触发)
|
|
460
|
+
* - status === fresh → 跳过
|
|
461
|
+
* 行为与原内联 noStatus/missing/stale 三判定等价(provisionDeps 调用 / meta 写回不变),新增 main-drift 触发。
|
|
462
|
+
*/
|
|
463
|
+
async function ensureDepsFreshness(cwd, changeName, specBase, worktreeMeta) {
|
|
464
|
+
if (!worktreeMeta || !worktreeMeta.worktreePath) return
|
|
465
|
+
const { provisionDeps, checkDepsFreshness } = await import('../worktree-deps.js')
|
|
466
|
+
const wtPath = worktreeMeta.worktreePath
|
|
467
|
+
const fresh = checkDepsFreshness(worktreeMeta, wtPath, cwd)
|
|
468
|
+
if (fresh.status === 'fresh') return
|
|
469
|
+
const reason = fresh.detail || fresh.status
|
|
470
|
+
console.log(`🔄 worktree deps 自检:${reason}(depsStatus=${worktreeMeta.depsStatus || 'unknown'}),重新供给...`)
|
|
471
|
+
let deps = {}
|
|
472
|
+
try {
|
|
473
|
+
deps = provisionDeps(wtPath, cwd, { specBase }) || {}
|
|
474
|
+
} catch (e) {
|
|
475
|
+
deps = { depsStatus: 'failed', depsError: `provisionDeps crashed: ${e.message}` }
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
const { WorktreeManager } = await import('../worktree.js')
|
|
479
|
+
const metaPath = join(new WorktreeManager({ cwd }).getWorktreePath(changeName), 'meta.json')
|
|
480
|
+
const updated = { ...worktreeMeta, ...deps }
|
|
481
|
+
writeAtomicSync(metaPath, JSON.stringify(updated, null, 2) + '\n')
|
|
482
|
+
console.log(`✅ deps 重新供给完成:depsStatus=${deps.depsStatus}`)
|
|
483
|
+
} catch (e) {
|
|
484
|
+
console.warn(`⚠️ deps meta 写回失败:${e.message}`)
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|