sillyspec 3.27.5 → 3.27.6

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.
Files changed (194) hide show
  1. package/.worktrees/8d2d0392/.claude/skills/sillyspec-archive/SKILL.md +87 -0
  2. package/.worktrees/8d2d0392/.claude/skills/sillyspec-auto/SKILL.md +93 -0
  3. package/.worktrees/8d2d0392/.claude/skills/sillyspec-brainstorm/SKILL.md +114 -0
  4. package/.worktrees/8d2d0392/.claude/skills/sillyspec-commit/SKILL.md +67 -0
  5. package/.worktrees/8d2d0392/.claude/skills/sillyspec-continue/SKILL.md +47 -0
  6. package/.worktrees/8d2d0392/.claude/skills/sillyspec-doctor/SKILL.md +76 -0
  7. package/.worktrees/8d2d0392/.claude/skills/sillyspec-execute/SKILL.md +214 -0
  8. package/.worktrees/8d2d0392/.claude/skills/sillyspec-explore/SKILL.md +102 -0
  9. package/.worktrees/8d2d0392/.claude/skills/sillyspec-export/SKILL.md +57 -0
  10. package/.worktrees/8d2d0392/.claude/skills/sillyspec-init/SKILL.md +177 -0
  11. package/.worktrees/8d2d0392/.claude/skills/sillyspec-knowledge/SKILL.md +270 -0
  12. package/.worktrees/8d2d0392/.claude/skills/sillyspec-plan/SKILL.md +156 -0
  13. package/.worktrees/8d2d0392/.claude/skills/sillyspec-propose/SKILL.md +87 -0
  14. package/.worktrees/8d2d0392/.claude/skills/sillyspec-quick/SKILL.md +116 -0
  15. package/.worktrees/8d2d0392/.claude/skills/sillyspec-resume/SKILL.md +70 -0
  16. package/.worktrees/8d2d0392/.claude/skills/sillyspec-scan/SKILL.md +79 -0
  17. package/.worktrees/8d2d0392/.claude/skills/sillyspec-state/SKILL.md +64 -0
  18. package/.worktrees/8d2d0392/.claude/skills/sillyspec-status/SKILL.md +54 -0
  19. package/.worktrees/8d2d0392/.claude/skills/sillyspec-verify/SKILL.md +87 -0
  20. package/.worktrees/8d2d0392/.claude/skills/sillyspec-workspace/SKILL.md +175 -0
  21. package/.worktrees/8d2d0392/.claude/skills/verify-per-user/SKILL.md +6 -0
  22. package/.worktrees/8d2d0392/.gitattributes +2 -0
  23. package/.worktrees/8d2d0392/.husky/pre-push +20 -0
  24. package/.worktrees/8d2d0392/README.md +203 -0
  25. package/.worktrees/8d2d0392/SKILL.md +91 -0
  26. package/.worktrees/8d2d0392/architecture-analysis.md +448 -0
  27. package/.worktrees/8d2d0392/bin/sillyspec.js +2 -0
  28. package/.worktrees/8d2d0392/eval/README.md +86 -0
  29. package/.worktrees/8d2d0392/eval/eval.config.json +28 -0
  30. package/.worktrees/8d2d0392/eval/lib/adapters/cli.mjs +63 -0
  31. package/.worktrees/8d2d0392/eval/lib/adapters/dryrun.mjs +27 -0
  32. package/.worktrees/8d2d0392/eval/lib/config.mjs +82 -0
  33. package/.worktrees/8d2d0392/eval/lib/db.mjs +76 -0
  34. package/.worktrees/8d2d0392/eval/lib/report.mjs +120 -0
  35. package/.worktrees/8d2d0392/eval/lib/runner.mjs +157 -0
  36. package/.worktrees/8d2d0392/eval/lib/tasks.mjs +73 -0
  37. package/.worktrees/8d2d0392/eval/lib/util.mjs +107 -0
  38. package/.worktrees/8d2d0392/eval/lib/workdir.mjs +30 -0
  39. package/.worktrees/8d2d0392/eval/run.mjs +83 -0
  40. package/.worktrees/8d2d0392/eval/tasks/001-slugify/files/package.json +6 -0
  41. package/.worktrees/8d2d0392/eval/tasks/001-slugify/solution/src/slugify.mjs +26 -0
  42. package/.worktrees/8d2d0392/eval/tasks/001-slugify/task.json +6 -0
  43. package/.worktrees/8d2d0392/eval/tasks/001-slugify/verify.mjs +28 -0
  44. package/.worktrees/8d2d0392/eval/tasks/002-each-day/files/package.json +6 -0
  45. package/.worktrees/8d2d0392/eval/tasks/002-each-day/files/src/dates.mjs +4 -0
  46. package/.worktrees/8d2d0392/eval/tasks/002-each-day/solution/src/dates.mjs +30 -0
  47. package/.worktrees/8d2d0392/eval/tasks/002-each-day/task.json +6 -0
  48. package/.worktrees/8d2d0392/eval/tasks/002-each-day/verify.mjs +31 -0
  49. package/.worktrees/8d2d0392/eval/tasks/003-word-report/files/data/notes.txt +5 -0
  50. package/.worktrees/8d2d0392/eval/tasks/003-word-report/files/package.json +6 -0
  51. package/.worktrees/8d2d0392/eval/tasks/003-word-report/solution/bin/report.mjs +36 -0
  52. package/.worktrees/8d2d0392/eval/tasks/003-word-report/task.json +6 -0
  53. package/.worktrees/8d2d0392/eval/tasks/003-word-report/verify.mjs +38 -0
  54. package/.worktrees/8d2d0392/logo.jpg +0 -0
  55. package/.worktrees/8d2d0392/package-lock.json +977 -0
  56. package/.worktrees/8d2d0392/package.json +41 -0
  57. package/.worktrees/8d2d0392/packages/dashboard/dist/assets/index-Bq_Z2hne.js +7446 -0
  58. package/.worktrees/8d2d0392/packages/dashboard/dist/assets/index-O2W5RV4z.css +1 -0
  59. package/.worktrees/8d2d0392/packages/dashboard/dist/favicon.jpg +0 -0
  60. package/.worktrees/8d2d0392/packages/dashboard/dist/index.html +16 -0
  61. package/.worktrees/8d2d0392/packages/dashboard/dist/logo.jpg +0 -0
  62. package/.worktrees/8d2d0392/packages/dashboard/dist/prototype-dashboard.html +836 -0
  63. package/.worktrees/8d2d0392/packages/dashboard/dist/prototype-overview.html +256 -0
  64. package/.worktrees/8d2d0392/packages/dashboard/package.json +25 -0
  65. package/.worktrees/8d2d0392/packages/dashboard/server/executor.js +95 -0
  66. package/.worktrees/8d2d0392/packages/dashboard/server/index.js +679 -0
  67. package/.worktrees/8d2d0392/packages/dashboard/server/parser.js +526 -0
  68. package/.worktrees/8d2d0392/packages/dashboard/server/watcher.js +357 -0
  69. package/.worktrees/8d2d0392/src/agent-session-log.js +803 -0
  70. package/.worktrees/8d2d0392/src/change-list.js +290 -0
  71. package/.worktrees/8d2d0392/src/change-risk-profile.js +339 -0
  72. package/.worktrees/8d2d0392/src/check-primitives.js +65 -0
  73. package/.worktrees/8d2d0392/src/classify-change.js +109 -0
  74. package/.worktrees/8d2d0392/src/commit-suggest.js +202 -0
  75. package/.worktrees/8d2d0392/src/config-cat.js +88 -0
  76. package/.worktrees/8d2d0392/src/config-schema.js +328 -0
  77. package/.worktrees/8d2d0392/src/constants.js +97 -0
  78. package/.worktrees/8d2d0392/src/contract-matrix.js +533 -0
  79. package/.worktrees/8d2d0392/src/datetime.js +20 -0
  80. package/.worktrees/8d2d0392/src/db-engine.js +55 -0
  81. package/.worktrees/8d2d0392/src/db.js +381 -0
  82. package/.worktrees/8d2d0392/src/decision-distill.js +517 -0
  83. package/.worktrees/8d2d0392/src/dispatch/backends/local-agent.js +155 -0
  84. package/.worktrees/8d2d0392/src/dispatch/backends/sillyhub-mcp.js +245 -0
  85. package/.worktrees/8d2d0392/src/dispatch/probe.js +246 -0
  86. package/.worktrees/8d2d0392/src/dispatch/strategy.js +121 -0
  87. package/.worktrees/8d2d0392/src/docs-check.js +825 -0
  88. package/.worktrees/8d2d0392/src/docs-debt.js +393 -0
  89. package/.worktrees/8d2d0392/src/docs-gate.js +107 -0
  90. package/.worktrees/8d2d0392/src/doctor-diagnostics.js +1099 -0
  91. package/.worktrees/8d2d0392/src/endpoint-extractor.js +409 -0
  92. package/.worktrees/8d2d0392/src/foreign-declared.js +78 -0
  93. package/.worktrees/8d2d0392/src/fs-atomic.js +73 -0
  94. package/.worktrees/8d2d0392/src/git-helper.js +150 -0
  95. package/.worktrees/8d2d0392/src/hooks/claude-pre-tool-use.cjs +130 -0
  96. package/.worktrees/8d2d0392/src/hooks/worktree-guard.js +892 -0
  97. package/.worktrees/8d2d0392/src/index.js +2854 -0
  98. package/.worktrees/8d2d0392/src/init.js +626 -0
  99. package/.worktrees/8d2d0392/src/knowledge-match.js +231 -0
  100. package/.worktrees/8d2d0392/src/local-detect.js +128 -0
  101. package/.worktrees/8d2d0392/src/local-register.js +104 -0
  102. package/.worktrees/8d2d0392/src/machine-interface.js +543 -0
  103. package/.worktrees/8d2d0392/src/migrate.js +127 -0
  104. package/.worktrees/8d2d0392/src/module-impact.js +166 -0
  105. package/.worktrees/8d2d0392/src/module-resolve.js +222 -0
  106. package/.worktrees/8d2d0392/src/modules.js +580 -0
  107. package/.worktrees/8d2d0392/src/plan-adopt-waves.js +126 -0
  108. package/.worktrees/8d2d0392/src/progress/change-registry.js +336 -0
  109. package/.worktrees/8d2d0392/src/progress/consistency-doctor.js +355 -0
  110. package/.worktrees/8d2d0392/src/progress/shared.js +36 -0
  111. package/.worktrees/8d2d0392/src/progress/stage-machine.js +594 -0
  112. package/.worktrees/8d2d0392/src/progress/step-store.js +265 -0
  113. package/.worktrees/8d2d0392/src/progress.js +1304 -0
  114. package/.worktrees/8d2d0392/src/quick-recommend.js +115 -0
  115. package/.worktrees/8d2d0392/src/quicklog.js +883 -0
  116. package/.worktrees/8d2d0392/src/review-tier.js +77 -0
  117. package/.worktrees/8d2d0392/src/run/command.js +1641 -0
  118. package/.worktrees/8d2d0392/src/run/complete-handlers.js +1552 -0
  119. package/.worktrees/8d2d0392/src/run/complete.js +1259 -0
  120. package/.worktrees/8d2d0392/src/run/concurrent-detect.js +156 -0
  121. package/.worktrees/8d2d0392/src/run/gates.js +1094 -0
  122. package/.worktrees/8d2d0392/src/run/multi-repo-context.js +208 -0
  123. package/.worktrees/8d2d0392/src/run/next.js +128 -0
  124. package/.worktrees/8d2d0392/src/run/prompt.js +843 -0
  125. package/.worktrees/8d2d0392/src/run/quick-audit.js +186 -0
  126. package/.worktrees/8d2d0392/src/run/scan-profile.js +269 -0
  127. package/.worktrees/8d2d0392/src/run/shared.js +1562 -0
  128. package/.worktrees/8d2d0392/src/run/stage.js +587 -0
  129. package/.worktrees/8d2d0392/src/run.js +23 -0
  130. package/.worktrees/8d2d0392/src/scan-diff.js +388 -0
  131. package/.worktrees/8d2d0392/src/scan-postcheck.js +524 -0
  132. package/.worktrees/8d2d0392/src/scan-staleness.js +95 -0
  133. package/.worktrees/8d2d0392/src/setup.js +414 -0
  134. package/.worktrees/8d2d0392/src/sillyhub-mcp/client.js +597 -0
  135. package/.worktrees/8d2d0392/src/sillyhub-mcp/config.js +62 -0
  136. package/.worktrees/8d2d0392/src/spec-dir-typo.js +50 -0
  137. package/.worktrees/8d2d0392/src/spec-sync.js +358 -0
  138. package/.worktrees/8d2d0392/src/stage-contract-engine.js +171 -0
  139. package/.worktrees/8d2d0392/src/stage-contract-spec.js +551 -0
  140. package/.worktrees/8d2d0392/src/stage-contract.js +948 -0
  141. package/.worktrees/8d2d0392/src/stage-review.js +597 -0
  142. package/.worktrees/8d2d0392/src/stages/archive.js +199 -0
  143. package/.worktrees/8d2d0392/src/stages/brainstorm-auto.js +285 -0
  144. package/.worktrees/8d2d0392/src/stages/brainstorm.js +624 -0
  145. package/.worktrees/8d2d0392/src/stages/cmd-existence.js +145 -0
  146. package/.worktrees/8d2d0392/src/stages/doctor.js +540 -0
  147. package/.worktrees/8d2d0392/src/stages/execute.js +1277 -0
  148. package/.worktrees/8d2d0392/src/stages/explore.js +43 -0
  149. package/.worktrees/8d2d0392/src/stages/index.js +29 -0
  150. package/.worktrees/8d2d0392/src/stages/knowledge.js +514 -0
  151. package/.worktrees/8d2d0392/src/stages/plan-postcheck.js +1398 -0
  152. package/.worktrees/8d2d0392/src/stages/plan.js +651 -0
  153. package/.worktrees/8d2d0392/src/stages/quick.js +167 -0
  154. package/.worktrees/8d2d0392/src/stages/scan.js +608 -0
  155. package/.worktrees/8d2d0392/src/stages/status.js +64 -0
  156. package/.worktrees/8d2d0392/src/stages/verify.js +246 -0
  157. package/.worktrees/8d2d0392/src/sync.js +1470 -0
  158. package/.worktrees/8d2d0392/src/task-review.js +1498 -0
  159. package/.worktrees/8d2d0392/src/taskcard-placeholders.js +21 -0
  160. package/.worktrees/8d2d0392/src/taskcard.js +217 -0
  161. package/.worktrees/8d2d0392/src/verify-postcheck.js +1718 -0
  162. package/.worktrees/8d2d0392/src/verify-probes.js +327 -0
  163. package/.worktrees/8d2d0392/src/version.js +19 -0
  164. package/.worktrees/8d2d0392/src/workflow.js +600 -0
  165. package/.worktrees/8d2d0392/src/workspace.js +125 -0
  166. package/.worktrees/8d2d0392/src/worktree-apply.js +1611 -0
  167. package/.worktrees/8d2d0392/src/worktree-deps.js +576 -0
  168. package/.worktrees/8d2d0392/src/worktree.js +1838 -0
  169. package/.worktrees/8d2d0392/templates/claude-instruction.md +23 -0
  170. package/.worktrees/8d2d0392/templates/prompts/taskcard-rules.md +29 -0
  171. package/.worktrees/8d2d0392/templates/prompts/testcase-design.md +12 -0
  172. package/.worktrees/8d2d0392/templates/prompts/verify-probes.md +32 -0
  173. package/.worktrees/8d2d0392/templates/workflows/archive-impact.yaml +79 -0
  174. package/.worktrees/8d2d0392/templates/workflows/scan-docs.yaml +132 -0
  175. package/architecture-analysis.md +448 -0
  176. package/package.json +1 -1
  177. package/src/contract-matrix.js +1 -1
  178. package/src/endpoint-extractor.js +41 -52
  179. package/src/foreign-declared.js +78 -1
  180. package/src/index.js +9 -7
  181. package/src/run/command.js +2 -1
  182. package/src/run/gates.js +17 -0
  183. package/src/run/stage.js +8 -5
  184. package/src/stage-contract-spec.js +1 -1
  185. package/src/stages/brainstorm-auto.js +43 -1
  186. package/src/stages/brainstorm.js +2 -0
  187. package/src/stages/plan.js +8 -4
  188. package/src/stages/verify.js +1 -1
  189. package/src/taskcard.js +33 -0
  190. package/src/verify-probes.js +27 -6
  191. package/src/worktree-apply.js +451 -286
  192. package/src/worktree-deps.js +93 -1
  193. package/src/worktree.js +84 -19
  194. package/templates/prompts/taskcard-rules.md +1 -1
@@ -0,0 +1,125 @@
1
+ /**
2
+ * workspace.js — `sillyspec workspace add/remove/status` 的多项目工作区管理
3
+ * (2026-08-21 agent-手工产出审计第四批 C-1)。
4
+ *
5
+ * workspace skill 此前纯手写:`.sillyspec/projects/<name>.yaml` 5 字段 YAML 手编、remove 手删
6
+ * 文件手 commit、status 用 bash for-loop + grep/sed 解析 YAML 逐项目 cd 探测——skill 明言
7
+ * 「CLI 没有 workspace 命令」。本模块命令化全部机械面:
8
+ * - add:YAML 外科写入(name/path/status 必填 + role/repo 可选追加,已有字段保留)、路径校验
9
+ * - remove:删 yaml(--commit 时顺带 git add 该删除)
10
+ * - status:逐项目探测(yaml 解析 + .sillyspec 产物存在性),输出 skill 原格式的三态表
11
+ * init 语义对齐(skill L75):init 只写 name/path/status 三字段,role/repo 是 add 专属追加。
12
+ */
13
+ import { existsSync, readFileSync, writeFileSync, unlinkSync, readdirSync, mkdirSync } from 'fs'
14
+ import { join, basename, resolve } from 'path'
15
+ import { resolveSpecDir } from './run/shared.js'
16
+
17
+ function parseSimpleYaml(text) {
18
+ const out = {}
19
+ for (const line of String(text || '').split('\n')) {
20
+ const m = line.match(/^([A-Za-z0-9_]+):\s*(.*)$/)
21
+ if (m) out[m[1]] = m[2].trim()
22
+ }
23
+ return out
24
+ }
25
+
26
+ function readProjectYaml(specBase, name) {
27
+ const p = join(specBase, 'projects', `${name}.yaml`)
28
+ if (!existsSync(p)) return null
29
+ return parseSimpleYaml(readFileSync(p, 'utf8'))
30
+ }
31
+
32
+ /**
33
+ * 新增/更新子项目登记。
34
+ * @param {{ cwd: string, name: string, path: string, role?: string|null, repo?: string|null, specDir?: string|null }} opts
35
+ * @returns {{ file: string, created: boolean, fieldsKept: string[] }}
36
+ * @throws {Error} name 非法 / path 不存在
37
+ */
38
+ export function workspaceAdd({ cwd, name, path: projPath, role = null, repo = null, specDir = null }) {
39
+ if (!name || !/^[A-Za-z0-9_.\-]+$/.test(name)) {
40
+ throw new Error(`子项目名非法: "${name}"(限字母数字 . _ -,作 yaml 文件名)`)
41
+ }
42
+ const specBase = resolveSpecDir(cwd, { specDir })
43
+ const abs = resolve(cwd, projPath)
44
+ if (!existsSync(abs)) {
45
+ throw new Error(`路径不存在: ${abs}`)
46
+ }
47
+ const yamlPath = join(specBase, 'projects', `${name}.yaml`)
48
+ const existed = existsSync(yamlPath)
49
+ const prev = existed ? parseSimpleYaml(readFileSync(yamlPath, 'utf8')) : {}
50
+ // init 三字段 + add 追加字段;已有值优先保留(幂等重跑不覆盖手调内容)
51
+ const fields = {
52
+ name,
53
+ path: projPath.replace(/\\/g, '/'),
54
+ status: prev.status || 'active',
55
+ }
56
+ if (role) fields.role = role
57
+ else if (prev.role) fields.role = prev.role
58
+ if (repo) fields.repo = repo
59
+ else if (prev.repo) fields.repo = prev.repo
60
+ const fieldsKept = Object.keys(prev).filter(k => fields[k] === prev[k] && k !== 'name' && k !== 'path')
61
+ mkdirSync(join(specBase, 'projects'), { recursive: true })
62
+ // 追加不认识的手写字段(防整文件重序列化丢内容)
63
+ for (const k of Object.keys(prev)) {
64
+ if (!(k in fields)) fields[k] = prev[k]
65
+ }
66
+ const text = Object.entries(fields).map(([k, v]) => `${k}: ${v}`).join('\n') + '\n'
67
+ writeFileSync(yamlPath, text)
68
+ return { file: yamlPath, created: !existed, fieldsKept }
69
+ }
70
+
71
+ /**
72
+ * 移除子项目登记(删 yaml;git add 由调用方/CLI 层做)。
73
+ * @returns {{ file: string }} @throws {Error} 不存在
74
+ */
75
+ export function workspaceRemove({ cwd, name, specDir = null }) {
76
+ const specBase = resolveSpecDir(cwd, { specDir })
77
+ const yamlPath = join(specBase, 'projects', `${name}.yaml`)
78
+ if (!existsSync(yamlPath)) throw new Error(`子项目不存在: ${yamlPath}`)
79
+ unlinkSync(yamlPath)
80
+ return { file: yamlPath }
81
+ }
82
+
83
+ /**
84
+ * 工作区状态探测(skill 3d 的命令化):逐项目 yaml 解析 + 三态探测。
85
+ * @returns {{ projects: Array<{name, path, role, state, detail}>, sharedDocs: string[] }}
86
+ * state ∈ initialized(有 .sillyspec)/ scanned(docs/<name>/scan 有文档)/ unregistered(无 .sillyspec)
87
+ */
88
+ export function workspaceStatus({ cwd, specDir = null }) {
89
+ const specBase = resolveSpecDir(cwd, { specDir })
90
+ const projects = []
91
+ const projDir = join(specBase, 'projects')
92
+ if (existsSync(projDir)) {
93
+ for (const f of readdirSync(projDir).filter(f => f.endsWith('.yaml')).sort()) {
94
+ const y = parseSimpleYaml(readFileSync(join(projDir, f), 'utf8'))
95
+ const name = y.name || basename(f, '.yaml')
96
+ const projAbs = resolve(cwd, y.path || '.')
97
+ let state
98
+ let detail
99
+ if (!existsSync(projAbs)) {
100
+ state = 'missing'
101
+ detail = '路径不存在(yaml 的 path 失效)'
102
+ } else if (!existsSync(join(projAbs, '.sillyspec'))) {
103
+ state = 'unregistered'
104
+ detail = '未初始化(无 .sillyspec)'
105
+ } else {
106
+ const scanDir = join(projAbs, '.sillyspec', 'docs', name, 'scan')
107
+ let scanCount = 0
108
+ try { scanCount = readdirSync(scanDir).filter(x => x.endsWith('.md')).length } catch {}
109
+ if (scanCount > 0) {
110
+ state = 'scanned'
111
+ detail = `已扫描(${scanCount} 份文档)`
112
+ } else {
113
+ state = 'initialized'
114
+ detail = '已初始化(未扫描)'
115
+ }
116
+ }
117
+ projects.push({ name, path: y.path || '?', role: y.role || '', state, detail })
118
+ }
119
+ }
120
+ let sharedDocs = []
121
+ try {
122
+ sharedDocs = readdirSync(join(specBase, 'shared')).filter(f => f.endsWith('.md')).sort()
123
+ } catch {}
124
+ return { projects, sharedDocs }
125
+ }