sillyspec 3.11.3 → 3.11.4
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/package.json +1 -1
- package/src/run.js +50 -0
package/package.json
CHANGED
package/src/run.js
CHANGED
|
@@ -377,6 +377,53 @@ function validateMetadata(cwd, stageName) {
|
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
/**
|
|
381
|
+
* 验证关键文件是否存在于正确的变更目录下
|
|
382
|
+
* 防止 AI 将文件写到错误的路径
|
|
383
|
+
*/
|
|
384
|
+
function validateFileLocations(cwd, stageName, progress, changeName) {
|
|
385
|
+
const effectiveChange = changeName || progress.currentChange
|
|
386
|
+
if (!effectiveChange) return
|
|
387
|
+
|
|
388
|
+
const changeDir = join(cwd, '.sillyspec', 'changes', effectiveChange)
|
|
389
|
+
if (!existsSync(changeDir)) return
|
|
390
|
+
|
|
391
|
+
// 每个阶段完成后预期存在的文件
|
|
392
|
+
const expectedFiles = {
|
|
393
|
+
propose: ['proposal.md', 'design.md', 'requirements.md', 'tasks.md'],
|
|
394
|
+
plan: ['plan.md'],
|
|
395
|
+
verify: ['verify-result.md'],
|
|
396
|
+
archive: ['module-impact.md'],
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const expected = expectedFiles[stageName]
|
|
400
|
+
if (!expected) return
|
|
401
|
+
|
|
402
|
+
const missing = []
|
|
403
|
+
for (const file of expected) {
|
|
404
|
+
if (!existsSync(join(changeDir, file))) {
|
|
405
|
+
missing.push(file)
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (missing.length > 0) {
|
|
410
|
+
console.log(`\n⚠️ 文件位置验证:以下文件未在变更目录中找到`)
|
|
411
|
+
console.log(` 变更目录:${changeDir.replace(cwd + '/', '')}/`)
|
|
412
|
+
for (const f of missing) {
|
|
413
|
+
// 检查是否写到了错误的位置
|
|
414
|
+
const wrongPath = join(cwd, '.sillyspec', 'changes', 'change', effectiveChange, f)
|
|
415
|
+
if (existsSync(wrongPath)) {
|
|
416
|
+
console.log(` ❌ ${f} — 不存在,但发现了错误路径:${wrongPath.replace(cwd + '/', '')}`)
|
|
417
|
+
console.log(` 提示:应该写入 ${changeDir.replace(cwd + '/', '')}/${f}`)
|
|
418
|
+
} else {
|
|
419
|
+
console.log(` ⬜ ${f} — 未找到(该阶段可能未产出此文件)`)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
} else {
|
|
423
|
+
console.log(`\n✅ 文件位置验证:所有 ${expected.length} 个预期文件均在变更目录中`)
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
380
427
|
async function completeStep(pm, progress, stageName, cwd, outputText, inputText = null, options = {}) {
|
|
381
428
|
const { printNext = true, confirm = false, changeName } = options
|
|
382
429
|
const stageData = progress.stages[stageName]
|
|
@@ -453,6 +500,9 @@ async function completeStep(pm, progress, stageName, cwd, outputText, inputText
|
|
|
453
500
|
|
|
454
501
|
validateMetadata(cwd, stageName)
|
|
455
502
|
|
|
503
|
+
// 验证关键文件是否在正确的变更目录下
|
|
504
|
+
validateFileLocations(cwd, stageName, progress, changeName)
|
|
505
|
+
|
|
456
506
|
// archive 阶段确认归档
|
|
457
507
|
if (stageName === 'archive' && steps[currentIdx]?.name === '确认归档') {
|
|
458
508
|
if (confirm) {
|