sillyspec 3.20.2 → 3.20.3
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 +1 -5
- package/.claude/skills/sillyspec-auto/SKILL.md +2 -8
- package/.claude/skills/sillyspec-brainstorm/SKILL.md +1 -28
- package/.claude/skills/sillyspec-commit/SKILL.md +3 -4
- package/.claude/skills/sillyspec-continue/SKILL.md +4 -5
- package/.claude/skills/sillyspec-doctor/SKILL.md +3 -12
- package/.claude/skills/sillyspec-execute/SKILL.md +2 -15
- package/.claude/skills/sillyspec-explore/SKILL.md +1 -14
- package/.claude/skills/sillyspec-plan/SKILL.md +36 -5
- package/.claude/skills/sillyspec-propose/SKILL.md +0 -4
- package/.claude/skills/sillyspec-quick/SKILL.md +1 -5
- package/.claude/skills/sillyspec-resume/SKILL.md +66 -23
- package/.claude/skills/sillyspec-scan/SKILL.md +1 -5
- package/.claude/skills/sillyspec-state/SKILL.md +8 -8
- package/.claude/skills/sillyspec-status/SKILL.md +1 -5
- package/.claude/skills/sillyspec-verify/SKILL.md +1 -5
- package/.claude/skills/sillyspec-workspace/SKILL.md +3 -11
- package/.sillyspec/changes/archive/2026-04-08-derive-state/design.md +97 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/plan.md +51 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/proposal.md +29 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/requirements.md +34 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/tasks.md +13 -0
- package/.sillyspec/changes/archive/2026-04-08-derive-state/verify-result.md +43 -0
- package/.sillyspec/changes/auto-mode/design.md +50 -0
- package/.sillyspec/changes/auto-mode/proposal.md +19 -0
- package/.sillyspec/changes/auto-mode/requirements.md +21 -0
- package/.sillyspec/changes/auto-mode/tasks.md +7 -0
- package/.sillyspec/changes/brainstorm-archive/2026-04-05-dashboard-design.md +206 -0
- package/.sillyspec/changes/brainstorm-archive/2026-04-05-unified-docs-design.md +199 -0
- package/.sillyspec/changes/dashboard/design.md +219 -0
- package/.sillyspec/changes/dashboard/design.md.braindraft +206 -0
- package/.sillyspec/changes/run-command-design/design.md +1230 -0
- package/.sillyspec/changes/unified-docs-design/design.md +199 -0
- package/.sillyspec/docs/sillyspec/scan/.gitkeep +0 -0
- package/.sillyspec/knowledge/INDEX.md +8 -0
- package/.sillyspec/knowledge/uncategorized.md +3 -0
- package/.sillyspec/plans/2026-04-05-dashboard.md +737 -0
- package/.sillyspec/projects/sillyspec.yaml +3 -0
- package/README.md +11 -13
- package/SKILL.md +40 -44
- package/dist/steps/brainstorm/01-load-context.md +30 -0
- package/dist/steps/brainstorm/02-reuse-check.md +6 -0
- package/dist/steps/brainstorm/03-prototype-analysis.md +11 -0
- package/dist/steps/brainstorm/04-module-split.md +23 -0
- package/dist/steps/brainstorm/05-dialog-explore.md +8 -0
- package/dist/steps/brainstorm/06-propose-approaches.md +3 -0
- package/dist/steps/brainstorm/07-present-design.md +3 -0
- package/dist/steps/brainstorm/08-write-design.md +21 -0
- package/dist/steps/brainstorm/09-self-review.md +15 -0
- package/dist/steps/brainstorm/10-user-confirm.md +3 -0
- package/dist/steps/brainstorm/11-output-spec.md +7 -0
- package/dist/steps/brainstorm/manifest.yaml +26 -0
- package/dist/steps/execute/01-load-context.md +41 -0
- package/dist/steps/execute/02-scan-conventions.md +47 -0
- package/dist/steps/execute/03-skill-mcp.md +19 -0
- package/dist/steps/execute/04-assign-task.md +22 -0
- package/dist/steps/execute/04b-prompt-template.md +54 -0
- package/dist/steps/execute/05-write-test.md +7 -0
- package/dist/steps/execute/06-write-code.md +8 -0
- package/dist/steps/execute/07-run-test.md +26 -0
- package/dist/steps/execute/08-fix-issues.md +28 -0
- package/dist/steps/execute/09-next-task.md +33 -0
- package/dist/steps/execute/manifest.yaml +28 -0
- package/dist/steps/plan/01-load-context.md +22 -0
- package/dist/steps/plan/02-anchor-confirm.md +1 -0
- package/dist/steps/plan/03-expand-tasks.md +33 -0
- package/dist/steps/plan/04-mark-order.md +15 -0
- package/dist/steps/plan/05-e2e-planning.md +17 -0
- package/dist/steps/plan/06-self-check.md +16 -0
- package/dist/steps/plan/07-save.md +1 -0
- package/dist/steps/plan/manifest.yaml +18 -0
- package/dist/steps/scan/01-env-detect.md +51 -0
- package/dist/steps/scan/02-tech-stack.md +16 -0
- package/dist/steps/scan/03-conventions.md +16 -0
- package/dist/steps/scan/04-structure.md +19 -0
- package/dist/steps/scan/05-quality.md +18 -0
- package/dist/steps/scan/06-complete.md +49 -0
- package/dist/steps/scan/manifest.yaml +16 -0
- package/dist/steps/verify/01-load-specs.md +28 -0
- package/dist/steps/verify/02-check-tasks.md +1 -0
- package/dist/steps/verify/03-check-design.md +6 -0
- package/dist/steps/verify/04-run-tests.md +7 -0
- package/dist/steps/verify/05-e2e-tests.md +27 -0
- package/dist/steps/verify/05b-e2e-fix.md +33 -0
- package/dist/steps/verify/06-code-quality.md +25 -0
- package/dist/steps/verify/07-lint-check.md +27 -0
- package/dist/steps/verify/08-output-report.md +14 -0
- package/dist/steps/verify/manifest.yaml +22 -0
- package/package.json +1 -7
- package/packages/dashboard/dist/assets/{index-Bq_Z2hne.js → index-D1EVTLmc.js} +1264 -1264
- package/packages/dashboard/dist/assets/index-DGe8CqeP.css +1 -0
- package/packages/dashboard/dist/index.html +2 -2
- package/packages/dashboard/package-lock.json +6 -6
- package/packages/dashboard/server/executor.js +1 -1
- package/packages/dashboard/server/index.js +18 -98
- package/packages/dashboard/server/parser.js +71 -139
- package/packages/dashboard/server/watcher.js +6 -14
- package/packages/dashboard/src/App.vue +185 -418
- package/packages/dashboard/src/components/ActionBar.vue +1 -10
- package/packages/dashboard/src/components/CommandPalette.vue +1 -5
- package/packages/dashboard/src/components/DocPreview.vue +8 -105
- package/packages/dashboard/src/components/DocTree.vue +19 -75
- package/packages/dashboard/src/components/PipelineStage.vue +2 -22
- package/packages/dashboard/src/components/PipelineView.vue +5 -32
- package/packages/dashboard/src/components/ProjectOverview.vue +139 -113
- package/packages/dashboard/src/components/StageBadge.vue +3 -17
- package/packages/dashboard/src/components/StepCard.vue +2 -7
- package/packages/dashboard/src/composables/useDashboard.js +0 -28
- package/src/derive.js +147 -0
- package/src/index.js +40 -688
- package/src/init.js +63 -119
- package/src/migrate.js +7 -7
- package/src/progress.js +248 -1474
- package/src/run.js +302 -3008
- package/src/setup.js +64 -2
- package/src/stages/archive.js +17 -123
- package/src/stages/brainstorm.js +48 -454
- package/src/stages/doctor.js +46 -99
- package/src/stages/execute.js +59 -420
- package/src/stages/index.js +18 -12
- package/src/stages/plan.js +189 -492
- package/src/stages/propose.js +11 -70
- package/src/stages/quick.js +13 -52
- package/src/stages/scan.js +68 -485
- package/src/stages/status.js +1 -1
- package/src/stages/verify.js +16 -203
- package/src/step.js +543 -0
- package/.claude/skills/sillyspec-knowledge/SKILL.md +0 -270
- package/.husky/pre-push +0 -13
- package/CLAUDE.md +0 -18
- package/docs/brainstorm-plan-contract.md +0 -64
- package/docs/plan-execute-contract.md +0 -123
- package/docs/platform-scan-protocol.md +0 -298
- package/docs/revision-mode.md +0 -115
- package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +0 -99
- package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +0 -218
- package/docs/sillyspec/file-lifecycle/stage-artifacts.md +0 -167
- package/docs/sillyspec/file-lifecycle/storage-and-state.md +0 -148
- package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +0 -193
- package/docs/sillyspec/file-lifecycle.md +0 -125
- package/docs/workflow-contract-regression.md +0 -106
- package/docs/worktree-isolation.md +0 -252
- package/packages/dashboard/dist/assets/index-O2W5RV4z.css +0 -1
- package/packages/dashboard/dist/prototype-dashboard.html +0 -836
- package/packages/dashboard/dist/prototype-overview.html +0 -256
- package/packages/dashboard/public/prototype-dashboard.html +0 -836
- package/packages/dashboard/public/prototype-overview.html +0 -256
- package/packages/dashboard/src/components/HResizeHandle.vue +0 -48
- package/packages/dashboard/src/components/ProjectCard.vue +0 -187
- package/packages/dashboard/src/components/VResizeHandle.vue +0 -61
- package/packages/dashboard/src/composables/useLayout.js +0 -131
- package/src/brainstorm-postcheck.js +0 -158
- package/src/change-list.js +0 -52
- package/src/change-risk-profile.js +0 -352
- package/src/classify-change.js +0 -73
- package/src/constants.js +0 -70
- package/src/contract-matrix.js +0 -278
- package/src/db.js +0 -201
- package/src/endpoint-extractor.js +0 -315
- package/src/hooks/claude-pre-tool-use.cjs +0 -125
- package/src/hooks/worktree-guard.js +0 -761
- package/src/knowledge-match.js +0 -130
- package/src/modules.js +0 -482
- package/src/scan-postcheck.js +0 -383
- package/src/stage-contract.js +0 -700
- package/src/stages/brainstorm-auto.js +0 -229
- package/src/stages/explore.js +0 -34
- package/src/stages/knowledge.js +0 -498
- package/src/stages/plan-postcheck.js +0 -513
- package/src/sync.js +0 -497
- package/src/task-review.js +0 -346
- package/src/workflow.js +0 -785
- package/src/worktree-apply.js +0 -549
- package/src/worktree.js +0 -932
- package/templates/workflows/archive-impact.yaml +0 -79
- package/templates/workflows/scan-docs.yaml +0 -132
- package/test/brainstorm-plan-contract.test.mjs +0 -273
- package/test/check-syntax.mjs +0 -26
- package/test/cli-top-level-aliases.test.mjs +0 -174
- package/test/contract-artifacts.test.mjs +0 -323
- package/test/decision-supersede.test.mjs +0 -277
- package/test/knowledge-match.test.mjs +0 -231
- package/test/plan-execute-contract.test.mjs +0 -330
- package/test/plan-optimization.test.mjs +0 -572
- package/test/platform-artifacts.test.mjs +0 -190
- package/test/platform-failure-samples.test.mjs +0 -199
- package/test/platform-recovery-chain.test.mjs +0 -179
- package/test/platform-recovery.test.mjs +0 -167
- package/test/platform-scan-p0.test.mjs +0 -175
- package/test/revision-v1.test.mjs +0 -1145
- package/test/run-sanitize-project-name.test.mjs +0 -51
- package/test/run-scan-postcheck-fail.test.mjs +0 -64
- package/test/run-scan-project-parse.test.mjs +0 -200
- package/test/run-tests.mjs +0 -48
- package/test/scan-docs-yaml-placeholders.test.mjs +0 -84
- package/test/scan-knowledge.test.mjs +0 -175
- package/test/scan-paths.test.mjs +0 -68
- package/test/scan-postcheck-project-priority.test.mjs +0 -85
- package/test/scan-postcheck.test.mjs +0 -197
- package/test/scan-workflow-anyfailed-block.test.mjs +0 -52
- package/test/spec-dir.test.mjs +0 -206
- package/test/stage-contract-failed-post-check.test.mjs +0 -102
- package/test/stage-contract.test.mjs +0 -299
- package/test/stage-definitions.test.mjs +0 -39
- package/test/wait-gates.test.mjs +0 -501
- package/test/workflow-spec-base.test.mjs +0 -142
- package/test/worktree-guard.test.mjs +0 -136
- package/test/worktree-native-overlay.test.mjs +0 -188
package/test/scan-paths.test.mjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 防回归测试:scan.js 中不允许硬编码 .sillyspec/docs/<project>/ 作为写入路径
|
|
3
|
-
* 所有正式文档路径必须使用 {DOCS_ROOT} 占位符
|
|
4
|
-
*/
|
|
5
|
-
import { readFileSync } from 'fs'
|
|
6
|
-
import { join, dirname } from 'path'
|
|
7
|
-
import { fileURLToPath } from 'url'
|
|
8
|
-
|
|
9
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
10
|
-
const scanPath = join(__dirname, '..', 'src', 'stages', 'scan.js')
|
|
11
|
-
const content = readFileSync(scanPath, 'utf8')
|
|
12
|
-
|
|
13
|
-
const banned = [
|
|
14
|
-
'.sillyspec/docs/<project>/scan/',
|
|
15
|
-
'.sillyspec/docs/<project>/modules/',
|
|
16
|
-
'.sillyspec/docs/<project>/flows/',
|
|
17
|
-
'.sillyspec/docs/<project>/glossary.md',
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
const required = [
|
|
21
|
-
'{DOCS_ROOT}/scan/',
|
|
22
|
-
'{DOCS_ROOT}/modules/',
|
|
23
|
-
'{DOCS_ROOT}/flows/',
|
|
24
|
-
]
|
|
25
|
-
|
|
26
|
-
let failed = false
|
|
27
|
-
|
|
28
|
-
// 禁止硬编码路径
|
|
29
|
-
for (const pattern of banned) {
|
|
30
|
-
if (content.includes(pattern)) {
|
|
31
|
-
console.error(`❌ FAIL: scan.js 仍包含硬编码路径 "${pattern}"`)
|
|
32
|
-
failed = true
|
|
33
|
-
} else {
|
|
34
|
-
console.log(`✅ PASS: 不包含 "${pattern}"`)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 必须包含占位符
|
|
39
|
-
for (const pattern of required) {
|
|
40
|
-
if (content.includes(pattern)) {
|
|
41
|
-
console.log(`✅ PASS: 包含占位符 "${pattern}"`)
|
|
42
|
-
} else {
|
|
43
|
-
console.error(`❌ FAIL: scan.js 缺少占位符 "${pattern}"`)
|
|
44
|
-
failed = true
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 禁止硬编码 projects 路径
|
|
49
|
-
if (content.includes('.sillyspec/projects/')) {
|
|
50
|
-
console.error('❌ FAIL: scan.js 仍包含硬编码 ".sillyspec/projects/"')
|
|
51
|
-
failed = true
|
|
52
|
-
} else {
|
|
53
|
-
console.log('✅ PASS: 不包含 ".sillyspec/projects/"')
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (content.includes('{PROJECTS_ROOT}/')) {
|
|
57
|
-
console.log('✅ PASS: 包含占位符 "{PROJECTS_ROOT}/"')
|
|
58
|
-
} else {
|
|
59
|
-
console.error('❌ FAIL: scan.js 缺少占位符 "{PROJECTS_ROOT}/"')
|
|
60
|
-
failed = true
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (failed) {
|
|
64
|
-
console.error('\n💥 有测试失败!scan.js 路径占位符可能被回退为硬编码。')
|
|
65
|
-
throw new Error("test failed")
|
|
66
|
-
} else {
|
|
67
|
-
console.log('\n✅ 全部通过 — scan.js 路径占位符防回归测试 OK')
|
|
68
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* task-05: run.js post-check 项目名优先级链
|
|
3
|
-
*
|
|
4
|
-
* 覆盖 AC-04/05/06/10: currentProjectName 优先级 =
|
|
5
|
-
* progress.project (dbProjectName) > change.project > steps[idx].project > name 正则 > null
|
|
6
|
-
*
|
|
7
|
-
* 由于 runStage 是大函数,这里用源码字符串校验关键优先级链顺序,
|
|
8
|
-
* 并通过控制台 fixture 模拟实际行为。
|
|
9
|
-
*/
|
|
10
|
-
import { readFileSync } from 'fs'
|
|
11
|
-
import { join, dirname } from 'path'
|
|
12
|
-
import { fileURLToPath } from 'url'
|
|
13
|
-
|
|
14
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
15
|
-
const runPath = join(__dirname, '..', 'src', 'run.js')
|
|
16
|
-
const src = readFileSync(runPath, 'utf8')
|
|
17
|
-
|
|
18
|
-
let passed = 0
|
|
19
|
-
let failed = 0
|
|
20
|
-
function assert (cond, msg) {
|
|
21
|
-
if (cond) { console.log(`✅ PASS: ${msg}`); passed++ }
|
|
22
|
-
else { console.error(`❌ FAIL: ${msg}`); failed++ }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// AC-10: 定位 workflow post_check 段的 currentProjectName 赋值
|
|
26
|
-
console.log('=== AC-10: currentProjectName 优先级链 ===')
|
|
27
|
-
|
|
28
|
-
// 锚点:workflow post_check 段特征字符串
|
|
29
|
-
const anchor = src.indexOf("Workflow post_check:scan 深度扫描完成后自动检查产物")
|
|
30
|
-
assert(anchor > 0, '找到 workflow post_check scan 锚点')
|
|
31
|
-
|
|
32
|
-
// 取该段后 2000 字符内的 currentProjectName 赋值块
|
|
33
|
-
const tail = src.slice(anchor, anchor + 3000)
|
|
34
|
-
const assignStart = tail.indexOf('const currentProjectName')
|
|
35
|
-
assert(assignStart > 0, 'post_check 段含 currentProjectName 赋值')
|
|
36
|
-
|
|
37
|
-
// 赋值块(到下一行 const 或 let 前)
|
|
38
|
-
const assignBlock = tail.slice(assignStart, assignStart + 600)
|
|
39
|
-
|
|
40
|
-
// 验证优先级链:progress.project 必须在 steps[idx].project 之前出现
|
|
41
|
-
const ppPos = assignBlock.indexOf('progress.project')
|
|
42
|
-
const stepsPos = assignBlock.indexOf('steps[currentIdx].project')
|
|
43
|
-
assert(ppPos > 0 && stepsPos > 0, 'currentProjectName 链含 progress.project + steps[currentIdx].project')
|
|
44
|
-
assert(ppPos < stepsPos,
|
|
45
|
-
`优先级正确:progress.project (pos=${ppPos}) 在 steps[idx].project (pos=${stepsPos}) 之前`)
|
|
46
|
-
|
|
47
|
-
// 验证保留兜底:name 正则提取
|
|
48
|
-
assert(/\[([^\]]+)\]\s*\$\//.test(assignBlock) || /\\\[/i.test(assignBlock),
|
|
49
|
-
'保留兜底:steps[idx].name 正则提取仍存在')
|
|
50
|
-
|
|
51
|
-
// AC-05/06: 行为模拟 — 优先级链实际执行结果
|
|
52
|
-
console.log('\n=== AC-05/06: 优先级链行为模拟 ===')
|
|
53
|
-
// 复刻 run.js:2650 修正后的优先级链
|
|
54
|
-
function pickProjectName (progressProject, changeProject, stepProject, stepName) {
|
|
55
|
-
return progressProject
|
|
56
|
-
|| changeProject
|
|
57
|
-
|| stepProject
|
|
58
|
-
|| (stepName && (stepName.match(/\[([^\]]+)\]\s*$/) || [])[1])
|
|
59
|
-
|| null
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// AC-05: progress.project='myaaa' 优先于 steps[idx].project='frontend'
|
|
63
|
-
const r1 = pickProjectName('myaaa', undefined, 'frontend', '深度扫描 [frontend]')
|
|
64
|
-
assert(r1 === 'myaaa', `AC-05: progress.project='myaaa' 优先 → ${r1}`)
|
|
65
|
-
|
|
66
|
-
// AC-06: progress.project 缺失 → 回退 steps[idx].project
|
|
67
|
-
const r2 = pickProjectName(undefined, undefined, 'frontend', '深度扫描 [frontend]')
|
|
68
|
-
assert(r2 === 'frontend', `AC-06: 兜底 steps[idx].project='frontend' → ${r2}`)
|
|
69
|
-
|
|
70
|
-
// 兜底 2: progress/change/step.project 均缺 → name 正则
|
|
71
|
-
const r3 = pickProjectName(undefined, undefined, undefined, '深度扫描 [backend]')
|
|
72
|
-
assert(r3 === 'backend', `兜底 name 正则提取 → ${r3}`)
|
|
73
|
-
|
|
74
|
-
// 全 null
|
|
75
|
-
const r4 = pickProjectName(undefined, undefined, undefined, '深度扫描')
|
|
76
|
-
assert(r4 === null, `全缺 → null(检查所有项目分支)`)
|
|
77
|
-
|
|
78
|
-
// change.project 优先于 steps[idx].project(progress.project 缺失时)
|
|
79
|
-
const r5 = pickProjectName(undefined, 'myaaa', 'frontend', '深度扫描 [frontend]')
|
|
80
|
-
assert(r5 === 'myaaa', `change.project='myaaa' 优先于 steps[idx].project='frontend' → ${r5}`)
|
|
81
|
-
|
|
82
|
-
console.log(`\n${'='.repeat(50)}`)
|
|
83
|
-
console.log(`✅ 通过: ${passed} ❌ 失败: ${failed}`)
|
|
84
|
-
console.log(`${'='.repeat(50)}`)
|
|
85
|
-
if (failed > 0) process.exit(1)
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scan-postcheck.test.mjs — CLI 层 post-check 测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { join, resolve, dirname, basename } from 'path'
|
|
6
|
-
import { existsSync, mkdirSync, writeFileSync, rmSync } from 'fs'
|
|
7
|
-
import { fileURLToPath, pathToFileURL } from 'url'
|
|
8
|
-
import { tmpdir } from 'os'
|
|
9
|
-
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
11
|
-
const __dirname = dirname(__filename)
|
|
12
|
-
const root = resolve(__dirname, '..')
|
|
13
|
-
|
|
14
|
-
const { runScanPostCheck } = await import(pathToFileURL(join(root, 'src', 'scan-postcheck.js')).href)
|
|
15
|
-
|
|
16
|
-
let passed = 0, failed = 0
|
|
17
|
-
|
|
18
|
-
function assert(cond, msg) {
|
|
19
|
-
if (cond) { console.log(` ✅ PASS: ${msg}`); passed++ }
|
|
20
|
-
else { console.log(` ❌ FAIL: ${msg}`); failed++ }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function setup(name) {
|
|
24
|
-
const cwd = join(tmpdir(), `pc-${name}`)
|
|
25
|
-
mkdirSync(cwd, { recursive: true })
|
|
26
|
-
return cwd
|
|
27
|
-
}
|
|
28
|
-
function specSetup(name) {
|
|
29
|
-
const d = join(tmpdir(), `pc-${name}-spec`)
|
|
30
|
-
mkdirSync(d, { recursive: true })
|
|
31
|
-
return d
|
|
32
|
-
}
|
|
33
|
-
function clean(...dirs) { for (const d of dirs) try { rmSync(d, { recursive: true, force: true }) } catch {} }
|
|
34
|
-
|
|
35
|
-
const DOCS = ['ARCHITECTURE.md','CONVENTIONS.md','STRUCTURE.md','INTEGRATIONS.md','TESTING.md','CONCERNS.md','PROJECT.md']
|
|
36
|
-
|
|
37
|
-
// 写入全部 7 份文档,项目名 = basename(cwd)
|
|
38
|
-
function writeFull(cwd, specDir) {
|
|
39
|
-
const proj = basename(cwd)
|
|
40
|
-
for (const d of DOCS) {
|
|
41
|
-
const p = join(specDir, 'docs', proj, 'scan', d)
|
|
42
|
-
mkdirSync(dirname(p), { recursive: true })
|
|
43
|
-
writeFileSync(p, 'author: bot\ncreated_at: 2026-06-08 10:00:00\n# doc\n')
|
|
44
|
-
}
|
|
45
|
-
// knowledge 目录 + INDEX.md(scan 已产出知识)
|
|
46
|
-
mkdirSync(join(specDir, 'knowledge'), { recursive: true })
|
|
47
|
-
writeFileSync(join(specDir, 'knowledge', 'INDEX.md'), '# Knowledge Index\n')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// 写入前 N 份文档
|
|
51
|
-
function writeN(cwd, specDir, n) {
|
|
52
|
-
const proj = basename(cwd)
|
|
53
|
-
for (let i = 0; i < n; i++) {
|
|
54
|
-
const p = join(specDir, 'docs', proj, 'scan', DOCS[i])
|
|
55
|
-
mkdirSync(dirname(p), { recursive: true })
|
|
56
|
-
writeFileSync(p, 'author: bot\ncreated_at: 2026-06-08 10:00:00\n# doc\n')
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ── 1: source_root 有文档 → failed ──
|
|
61
|
-
console.log('\n=== Test 1: source_root 泄漏 → failed_post_check ===')
|
|
62
|
-
{
|
|
63
|
-
const cwd = setup('t1'), spec = specSetup('t1')
|
|
64
|
-
const proj = basename(cwd)
|
|
65
|
-
mkdirSync(join(cwd, '.sillyspec/docs', proj, 'scan'), { recursive: true })
|
|
66
|
-
writeFileSync(join(cwd, '.sillyspec/docs', proj, 'scan', 'ARCHITECTURE.md'), '# leak')
|
|
67
|
-
const r = runScanPostCheck({ cwd, specDir: spec })
|
|
68
|
-
assert(r.status === 'failed_post_check', `状态: ${r.status}`)
|
|
69
|
-
assert(r.checks.some(c => c.name === 'source_root_docs_leak'), `source_root_docs_leak`)
|
|
70
|
-
clean(cwd, spec)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ── 2: spec 无文档 → failed ──
|
|
74
|
-
console.log('\n=== Test 2: spec 无文档 → failed_post_check ===')
|
|
75
|
-
{
|
|
76
|
-
const cwd = setup('t2'), spec = specSetup('t2')
|
|
77
|
-
const r = runScanPostCheck({ cwd, specDir: spec })
|
|
78
|
-
assert(r.status === 'failed_post_check', `状态: ${r.status}`)
|
|
79
|
-
assert(r.checks.some(c => c.name === 'all_docs_missing'), `all_docs_missing`)
|
|
80
|
-
clean(cwd, spec)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ── 3: 缺部分 required 文档 → failed ──
|
|
84
|
-
console.log('\n=== Test 3: 部分缺失 → failed_post_check ===')
|
|
85
|
-
{
|
|
86
|
-
const cwd = setup('t3'), spec = specSetup('t3')
|
|
87
|
-
writeN(cwd, spec, 6)
|
|
88
|
-
const r = runScanPostCheck({ cwd, specDir: spec })
|
|
89
|
-
assert(r.status === 'failed_post_check', `状态: ${r.status}`)
|
|
90
|
-
assert(r.checks.some(c => c.name === 'partial_docs_missing'), `partial_docs_missing`)
|
|
91
|
-
clean(cwd, spec)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// ── 4: local.yaml 命令不存在 → warnings ──
|
|
95
|
-
console.log('\n=== Test 4: local.yaml 命令不存在 → completed_with_warnings ===')
|
|
96
|
-
{
|
|
97
|
-
const cwd = setup('t4'), spec = specSetup('t4')
|
|
98
|
-
writeFull(cwd, spec)
|
|
99
|
-
writeFileSync(join(spec, 'local.yaml'),
|
|
100
|
-
'project:\n type: nodejs\ncommands:\n build: "npm run build"\n test: "npm run test"\n lint: "npm run lint"\n')
|
|
101
|
-
writeFileSync(join(cwd, 'package.json'), '{"name":"t4","scripts":{"start":"node server.js"}}')
|
|
102
|
-
const r = runScanPostCheck({ cwd, specDir: spec })
|
|
103
|
-
assert(r.status === 'completed_with_warnings', `状态: ${r.status}`)
|
|
104
|
-
assert(r.checks.some(c => c.name === 'local_config_invalid'), `local_config_invalid`)
|
|
105
|
-
clean(cwd, spec)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ── 5-8: AI 输出错误标记 → warnings ──
|
|
109
|
-
// 注意:tool_use_error 和 fallback 已移除(agent 描述性文本正常提及不应触发)
|
|
110
|
-
const errorCases = [
|
|
111
|
-
{ id: 'e6', name: 'API Error 529', output: 'API Error 529 server overloaded. API Error 529 retry failed' },
|
|
112
|
-
{ id: 'e7', name: 'rate_limit', output: 'rate limit exhausted, rate limit exhausted again' },
|
|
113
|
-
]
|
|
114
|
-
for (const ec of errorCases) {
|
|
115
|
-
console.log(`\n=== Test: ${ec.name} → completed_with_warnings ===`)
|
|
116
|
-
const cwd = setup(ec.id), spec = specSetup(ec.id)
|
|
117
|
-
writeFull(cwd, spec)
|
|
118
|
-
const r = runScanPostCheck({ cwd, specDir: spec, outputText: ec.output })
|
|
119
|
-
assert(r.status === 'completed_with_warnings', `${ec.name}: 状态 ${r.status}`)
|
|
120
|
-
clean(cwd, spec)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ── tool_use_error / fallback 不再触发 warning(描述性文本正常提及) ──
|
|
124
|
-
const noWarnCases = [
|
|
125
|
-
{ id: 'e5', name: 'tool_use_error', output: 'tool_use_error: file not found' },
|
|
126
|
-
{ id: 'e8', name: 'fallback', output: '作为 fallback 方案,跳过了这个步骤' },
|
|
127
|
-
]
|
|
128
|
-
for (const ec of noWarnCases) {
|
|
129
|
-
console.log(`\n=== Test: ${ec.name} → 不触发 warning ===`)
|
|
130
|
-
const cwd = setup(ec.id), spec = specSetup(ec.id)
|
|
131
|
-
writeFull(cwd, spec)
|
|
132
|
-
const r = runScanPostCheck({ cwd, specDir: spec, outputText: ec.output })
|
|
133
|
-
assert(!r.checks.some(c => c.name === 'tool_use_error' || c.name === 'fallback_or_skip'),
|
|
134
|
-
`${ec.name}: 不应有 tool_use_error/fallback_or_skip warning`)
|
|
135
|
-
clean(cwd, spec)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ── 9: 文档缺 header → warnings ──
|
|
139
|
-
console.log('\n=== Test 9: 文档缺 header → completed_with_warnings ===')
|
|
140
|
-
{
|
|
141
|
-
const cwd = setup('t9'), spec = specSetup('t9')
|
|
142
|
-
const proj = basename(cwd)
|
|
143
|
-
for (const d of DOCS) {
|
|
144
|
-
const p = join(spec, 'docs', proj, 'scan', d)
|
|
145
|
-
mkdirSync(dirname(p), { recursive: true })
|
|
146
|
-
writeFileSync(p, '# no header\n')
|
|
147
|
-
}
|
|
148
|
-
const r = runScanPostCheck({ cwd, specDir: spec })
|
|
149
|
-
assert(r.status === 'completed_with_warnings', `状态: ${r.status}`)
|
|
150
|
-
assert(r.checks.some(c => c.name === 'docs_missing_header'), `docs_missing_header`)
|
|
151
|
-
clean(cwd, spec)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// ── 10: 全部通过 → success ──
|
|
155
|
-
console.log('\n=== Test 10: 全部通过 → success ===')
|
|
156
|
-
{
|
|
157
|
-
const cwd = setup('t10'), spec = specSetup('t10')
|
|
158
|
-
writeFull(cwd, spec)
|
|
159
|
-
const r = runScanPostCheck({ cwd, specDir: spec, outputText: 'done' })
|
|
160
|
-
assert(r.status === 'success', `状态: ${r.status}`)
|
|
161
|
-
assert(r.checks.length === 0, `checks.length=0`)
|
|
162
|
-
clean(cwd, spec)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ── 11: 非平台模式 ──
|
|
166
|
-
console.log('\n=== Test 11: 非平台模式 ===')
|
|
167
|
-
{
|
|
168
|
-
const cwd = setup('t11')
|
|
169
|
-
const proj = basename(cwd)
|
|
170
|
-
for (let i = 0; i < 5; i++) {
|
|
171
|
-
const p = join(cwd, '.sillyspec', 'docs', proj, 'scan', DOCS[i])
|
|
172
|
-
mkdirSync(dirname(p), { recursive: true })
|
|
173
|
-
writeFileSync(p, 'author: bot\ncreated_at: now\n# doc\n')
|
|
174
|
-
}
|
|
175
|
-
const r = runScanPostCheck({ cwd, specDir: null })
|
|
176
|
-
assert(r.status === 'completed_with_warnings', `非平台: ${r.status}`)
|
|
177
|
-
assert(!r.checks.some(c => c.name === 'source_root_docs_leak'), `无 source_root_leak`)
|
|
178
|
-
clean(cwd)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// ── 12: 多问题 failed 优先 ──
|
|
182
|
-
console.log('\n=== Test 12: failed 优先 ===')
|
|
183
|
-
{
|
|
184
|
-
const cwd = setup('t12'), spec = specSetup('t12')
|
|
185
|
-
const proj = basename(cwd)
|
|
186
|
-
mkdirSync(join(cwd, '.sillyspec/docs', proj, 'scan'), { recursive: true })
|
|
187
|
-
writeFileSync(join(cwd, '.sillyspec/docs', proj, 'scan', 'ARCHITECTURE.md'), '# leak')
|
|
188
|
-
writeN(cwd, spec, 3)
|
|
189
|
-
const r = runScanPostCheck({ cwd, specDir: spec })
|
|
190
|
-
assert(r.status === 'failed_post_check', `failed 优先: ${r.status}`)
|
|
191
|
-
clean(cwd, spec)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
console.log(`\n${'='.repeat(50)}`)
|
|
195
|
-
console.log(`✅ 通过: ${passed} ❌ 失败: ${failed}`)
|
|
196
|
-
console.log(`${'='.repeat(50)}`)
|
|
197
|
-
if (failed > 0) throw new Error(`${failed} test(s) failed`)
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* task-07: run.js workflow post_check anyFailed 阻断
|
|
3
|
-
*
|
|
4
|
-
* 覆盖:
|
|
5
|
-
* - AC: workflow post_check anyFailed 时返回 { stageCompleted:false, currentIdx, nextPendingIdx: currentIdx }
|
|
6
|
-
* (与 task-06 平台模式 scan-postcheck 失败分支 return 结构对齐)
|
|
7
|
-
*
|
|
8
|
-
* 用源码字符串匹配 + 行为模拟。
|
|
9
|
-
*/
|
|
10
|
-
import { readFileSync } from 'fs'
|
|
11
|
-
import { join, dirname } from 'path'
|
|
12
|
-
import { fileURLToPath } from 'url'
|
|
13
|
-
|
|
14
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
15
|
-
const runPath = join(__dirname, '..', 'src', 'run.js')
|
|
16
|
-
const src = readFileSync(runPath, 'utf8')
|
|
17
|
-
|
|
18
|
-
let passed = 0
|
|
19
|
-
let failed = 0
|
|
20
|
-
function assert (cond, msg) {
|
|
21
|
-
if (cond) { console.log(`✅ PASS: ${msg}`); passed++ }
|
|
22
|
-
else { console.error(`❌ FAIL: ${msg}`); failed++ }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
console.log('=== workflow post_check anyFailed 阻断 ===')
|
|
26
|
-
|
|
27
|
-
// 锚点:scan 深度扫描 workflow post_check 段
|
|
28
|
-
const anchor = src.indexOf('if (anyFailed)')
|
|
29
|
-
assert(anchor > 0, '找到 if (anyFailed) 锚点')
|
|
30
|
-
|
|
31
|
-
// 取该 if 块前后 500 字符(向前找变量声明,向后找 return)
|
|
32
|
-
const tail = src.slice(anchor, anchor + 500)
|
|
33
|
-
|
|
34
|
-
// 必须有 return { stageCompleted: false ... }
|
|
35
|
-
assert(/return\s*\{\s*stageCompleted:\s*false/.test(tail),
|
|
36
|
-
'anyFailed 分支含 return { stageCompleted: false }')
|
|
37
|
-
|
|
38
|
-
// 必须有 nextPendingIdx: currentIdx
|
|
39
|
-
assert(/nextPendingIdx:\s*currentIdx/.test(tail),
|
|
40
|
-
'anyFailed 分支返回 nextPendingIdx: currentIdx')
|
|
41
|
-
|
|
42
|
-
// 必须有 currentIdx(保持当前 step 不推进)
|
|
43
|
-
assert(/currentIdx/.test(tail), 'anyFailed 分支保留 currentIdx 字段')
|
|
44
|
-
|
|
45
|
-
// 必须有 console.log 警告(保留用户可见提示)
|
|
46
|
-
assert(/console\.log/.test(tail) && /存在检查失败项|重试提示/.test(src.slice(anchor - 200, anchor + 300)),
|
|
47
|
-
'anyFailed 分支保留 console.log 用户提示')
|
|
48
|
-
|
|
49
|
-
console.log(`\n${'='.repeat(50)}`)
|
|
50
|
-
console.log(`✅ 通过: ${passed} ❌ 失败: ${failed}`)
|
|
51
|
-
console.log(`${'='.repeat(50)}`)
|
|
52
|
-
if (failed > 0) process.exit(1)
|
package/test/spec-dir.test.mjs
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* --spec-dir 功能测试
|
|
3
|
-
*
|
|
4
|
-
* 测试点:
|
|
5
|
-
* 1. ProgressManager 外部 specDir 路径正确
|
|
6
|
-
* 2. init 外部 specDir 不污染源码
|
|
7
|
-
* 3. 默认模式不受影响
|
|
8
|
-
* 4. 平台模式 prompt 注入(scan/brainstorm/plan/execute/verify/quick)
|
|
9
|
-
* 5. 非 platform 模式占位符替换(无 undefined/null)
|
|
10
|
-
* 6. --spec-dir 与 --spec-root 兼容
|
|
11
|
-
* 7. progress 使用外部 specDir
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { join, resolve, basename, dirname } from 'path'
|
|
15
|
-
import { existsSync, mkdirSync, writeFileSync, rmSync } from 'fs'
|
|
16
|
-
import { fileURLToPath, pathToFileURL } from 'url'
|
|
17
|
-
import { execSync } from 'child_process'
|
|
18
|
-
import { tmpdir } from 'os'
|
|
19
|
-
|
|
20
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
21
|
-
const __dirname = dirname(__filename)
|
|
22
|
-
const root = resolve(__dirname, '..')
|
|
23
|
-
const binCLI = join(root, 'bin', 'sillyspec.js')
|
|
24
|
-
|
|
25
|
-
function imp(path) {
|
|
26
|
-
return import(pathToFileURL(path).href)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let passed = 0
|
|
30
|
-
let failed = 0
|
|
31
|
-
|
|
32
|
-
function assert(condition, msg) {
|
|
33
|
-
if (condition) {
|
|
34
|
-
console.log(` ✅ PASS: ${msg}`)
|
|
35
|
-
passed++
|
|
36
|
-
} else {
|
|
37
|
-
console.log(` ❌ FAIL: ${msg}`)
|
|
38
|
-
failed++
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function tmpDir(name) {
|
|
43
|
-
const dir = join(tmpdir(), `spec-dir-test-${name}-${Date.now()}`)
|
|
44
|
-
mkdirSync(dir, { recursive: true })
|
|
45
|
-
return dir
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function cleanup(dir) {
|
|
49
|
-
try { rmSync(dir, { recursive: true, force: true }) } catch {}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function run(cmd) {
|
|
53
|
-
return execSync(cmd, { encoding: 'utf8', timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'] })
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ── Test 1: ProgressManager 外部 specDir ──
|
|
57
|
-
console.log('\n=== Test 1: ProgressManager 外部 specDir ===')
|
|
58
|
-
{
|
|
59
|
-
const { ProgressManager } = await imp(join(root, 'src', 'progress.js'))
|
|
60
|
-
const tmp = tmpDir('pm')
|
|
61
|
-
const specDir = join(tmp, 'external-spec')
|
|
62
|
-
|
|
63
|
-
const pm = new ProgressManager({ specDir })
|
|
64
|
-
assert(pm._getSpecDir(tmp) === specDir, `_getSpecDir 返回自定义路径`)
|
|
65
|
-
|
|
66
|
-
// 无自定义 specDir 时,resolveSpecDir 会向上查找 .sillyspec 目录
|
|
67
|
-
// 在测试环境中可能命中上层已有的 .sillyspec,所以只检查返回值是否有效路径
|
|
68
|
-
const pm2 = new ProgressManager()
|
|
69
|
-
const resolved = pm2._getSpecDir(tmp)
|
|
70
|
-
assert(typeof resolved === 'string' && resolved.length > 0 && resolved.endsWith('.sillyspec'),
|
|
71
|
-
`_getSpecDir 无自定义时返回有效 .sillyspec 路径 (got: ${resolved})`)
|
|
72
|
-
|
|
73
|
-
assert(pm._runtimePath(tmp) === join(specDir, '.runtime'), `_runtimePath 基于 specDir`)
|
|
74
|
-
assert(pm._changePath(tmp, 'c') === join(specDir, 'changes', 'c'), `_changePath 基于 specDir`)
|
|
75
|
-
|
|
76
|
-
// 外部 specDir 时 _ensureGitignore 应跳过
|
|
77
|
-
const gitignoreResult = pm._ensureGitignore(tmp)
|
|
78
|
-
assert(gitignoreResult === undefined, `外部 specDir 时 _ensureGitignore 跳过`)
|
|
79
|
-
|
|
80
|
-
cleanup(tmp)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ── Test 2: init 外部 specDir 不污染源码 ──
|
|
84
|
-
console.log('\n=== Test 2: init 外部 specDir 不污染源码 ===')
|
|
85
|
-
{
|
|
86
|
-
const { cmdInit } = await imp(join(root, 'src', 'init.js'))
|
|
87
|
-
const projectDir = tmpDir('project')
|
|
88
|
-
const specDir = tmpDir('spec')
|
|
89
|
-
|
|
90
|
-
await cmdInit(projectDir, { specDir })
|
|
91
|
-
|
|
92
|
-
assert(!existsSync(join(projectDir, '.sillyspec')), '源码目录不含 .sillyspec')
|
|
93
|
-
assert(!existsSync(join(projectDir, '.gitignore')), '外部 specDir 时不创建 .gitignore')
|
|
94
|
-
assert(existsSync(join(specDir, 'projects')), `specDir/projects 存在`)
|
|
95
|
-
assert(existsSync(join(specDir, 'docs')), `specDir/docs 存在`)
|
|
96
|
-
assert(existsSync(join(specDir, '.runtime', 'sillyspec.db')), `specDir/.runtime/sillyspec.db 存在`)
|
|
97
|
-
assert(existsSync(join(specDir, 'workflows')), `specDir/workflows 存在`)
|
|
98
|
-
assert(existsSync(join(projectDir, '.claude')), `源码目录 .claude 存在(工具指令)`)
|
|
99
|
-
|
|
100
|
-
cleanup(projectDir)
|
|
101
|
-
cleanup(specDir)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// ── Test 3: 默认模式不受影响 ──
|
|
105
|
-
console.log('\n=== Test 3: 默认模式不受影响 ===')
|
|
106
|
-
{
|
|
107
|
-
const { cmdInit } = await imp(join(root, 'src', 'init.js'))
|
|
108
|
-
const projectDir = tmpDir('default')
|
|
109
|
-
|
|
110
|
-
await cmdInit(projectDir, {})
|
|
111
|
-
|
|
112
|
-
assert(existsSync(join(projectDir, '.sillyspec')), '默认模式创建 .sillyspec 在项目内')
|
|
113
|
-
assert(existsSync(join(projectDir, '.sillyspec', '.runtime', 'sillyspec.db')), '默认模式 DB 在项目内')
|
|
114
|
-
assert(existsSync(join(projectDir, '.gitignore')), '默认模式创建 .gitignore')
|
|
115
|
-
|
|
116
|
-
cleanup(projectDir)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ── Test 4: 平台模式 prompt 注入(多 stage) ──
|
|
120
|
-
console.log('\n=== Test 4: 平台模式 prompt 注入 ===')
|
|
121
|
-
{
|
|
122
|
-
const projectDir = tmpDir('prompt-p')
|
|
123
|
-
const specDir = tmpDir('prompt-s')
|
|
124
|
-
|
|
125
|
-
run(`node "${binCLI}" init "${projectDir}" --spec-dir "${specDir}"`)
|
|
126
|
-
|
|
127
|
-
// execute 阶段会自动创建 worktree,在非 git 环境下会失败,跳过
|
|
128
|
-
const stages = ['scan', 'brainstorm', 'plan', 'verify', 'quick']
|
|
129
|
-
for (const stage of stages) {
|
|
130
|
-
const output = run(`node "${binCLI}" --dir "${projectDir}" --spec-dir "${specDir}" run ${stage} --skip-approval`)
|
|
131
|
-
assert(output.includes('平台模式'), `${stage}: 包含平台模式指令`)
|
|
132
|
-
assert(output.includes(`规范目录(specDir): \`${specDir}\``), `${stage}: 包含正确的 specDir 路径`)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// scan 额外检查
|
|
136
|
-
const scanOutput = run(`node "${binCLI}" --dir "${projectDir}" --spec-dir "${specDir}" run scan`)
|
|
137
|
-
assert(scanOutput.includes('严禁写入源码目录'), 'scan: 包含严禁写入源码目录')
|
|
138
|
-
assert(scanOutput.includes('Write 工具失败时,不允许'), 'scan: 包含 Write 工具规则')
|
|
139
|
-
assert(scanOutput.includes('变更目录'), 'scan: 包含变更目录')
|
|
140
|
-
|
|
141
|
-
cleanup(projectDir)
|
|
142
|
-
cleanup(specDir)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ── Test 5: 非 platform 模式占位符替换 ──
|
|
146
|
-
console.log('\n=== Test 5: 非 platform 模式占位符替换 ===')
|
|
147
|
-
{
|
|
148
|
-
const projectDir = tmpDir('noplatform')
|
|
149
|
-
|
|
150
|
-
run(`node "${binCLI}" init "${projectDir}"`)
|
|
151
|
-
|
|
152
|
-
const output = run(`node "${binCLI}" --dir "${projectDir}" run scan`)
|
|
153
|
-
|
|
154
|
-
assert(!output.includes('平台模式 — 写入路径约束'), '非 platform 模式不含平台指令')
|
|
155
|
-
assert(!output.includes('{DOCS_ROOT}'), '{DOCS_ROOT} 被正确替换')
|
|
156
|
-
assert(!output.includes('undefined'), '输出不含 undefined 路径')
|
|
157
|
-
assert(!output.includes('null/.sillyspec'), '输出不含 null 路径')
|
|
158
|
-
|
|
159
|
-
cleanup(projectDir)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ── Test 6: --spec-root 兼容 ──
|
|
163
|
-
console.log('\n=== Test 6: --spec-root 兼容 ===')
|
|
164
|
-
{
|
|
165
|
-
const projectDir = tmpDir('compat-p')
|
|
166
|
-
const specDir = tmpDir('compat-s')
|
|
167
|
-
|
|
168
|
-
run(`node "${binCLI}" init "${projectDir}" --spec-dir "${specDir}"`)
|
|
169
|
-
|
|
170
|
-
const output = run(`node "${binCLI}" --dir "${projectDir}" run scan --spec-root "${specDir}"`)
|
|
171
|
-
assert(output.includes('平台模式'), '--spec-root 兼容:仍触发平台模式指令')
|
|
172
|
-
|
|
173
|
-
cleanup(projectDir)
|
|
174
|
-
cleanup(specDir)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// ── Test 7: progress 使用外部 specDir ──
|
|
178
|
-
console.log('\n=== Test 7: progress 使用外部 specDir ===')
|
|
179
|
-
{
|
|
180
|
-
const { ProgressManager } = await imp(join(root, 'src', 'progress.js'))
|
|
181
|
-
const projectDir = tmpDir('progress-p')
|
|
182
|
-
const specDir = tmpDir('progress-s')
|
|
183
|
-
|
|
184
|
-
const pm = new ProgressManager({ specDir })
|
|
185
|
-
await pm.init(projectDir)
|
|
186
|
-
|
|
187
|
-
assert(existsSync(join(specDir, '.runtime', 'sillyspec.db')), 'DB 创建在外部 specDir')
|
|
188
|
-
assert(!existsSync(join(projectDir, '.sillyspec')), '源码目录不含 .sillyspec')
|
|
189
|
-
|
|
190
|
-
await pm.initChange(projectDir, 'test-change')
|
|
191
|
-
assert(existsSync(join(specDir, 'changes', 'test-change')), 'changes 创建在外部 specDir')
|
|
192
|
-
|
|
193
|
-
const progress = await pm.read(projectDir, 'test-change')
|
|
194
|
-
assert(progress !== null, '能从外部 specDir 读取 progress')
|
|
195
|
-
assert(progress.currentChange === 'test-change', `currentChange 正确`)
|
|
196
|
-
|
|
197
|
-
cleanup(projectDir)
|
|
198
|
-
cleanup(specDir)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// ── 汇总 ──
|
|
202
|
-
console.log(`\n${'='.repeat(50)}`)
|
|
203
|
-
console.log(`✅ 通过: ${passed} ❌ 失败: ${failed}`)
|
|
204
|
-
console.log(`${'='.repeat(50)}`)
|
|
205
|
-
|
|
206
|
-
if (failed > 0) throw new Error(`${failed} test(s) failed`)
|