@winspan/claude-forge 8.51.1 → 8.54.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.
Files changed (409) hide show
  1. package/DEVELOPMENT.md +290 -221
  2. package/README.md +50 -8
  3. package/dist/cli/commands/skills.d.ts.map +1 -1
  4. package/dist/cli/commands/skills.js +121 -2
  5. package/dist/cli/commands/skills.js.map +1 -1
  6. package/dist/cli/init/hook-manager.d.ts +1 -1
  7. package/dist/cli/init/hook-manager.d.ts.map +1 -1
  8. package/dist/cli/init/hook-manager.js +1 -0
  9. package/dist/cli/init/hook-manager.js.map +1 -1
  10. package/dist/core/constants.d.ts +2 -0
  11. package/dist/core/constants.d.ts.map +1 -1
  12. package/dist/core/constants.js +4 -0
  13. package/dist/core/constants.js.map +1 -1
  14. package/dist/core/storage/events.d.ts.map +1 -1
  15. package/dist/core/storage/events.js +0 -1
  16. package/dist/core/storage/events.js.map +1 -1
  17. package/dist/core/storage/maintenance.d.ts +25 -3
  18. package/dist/core/storage/maintenance.d.ts.map +1 -1
  19. package/dist/core/storage/maintenance.js +33 -4
  20. package/dist/core/storage/maintenance.js.map +1 -1
  21. package/dist/core/storage/routing.d.ts +4 -0
  22. package/dist/core/storage/routing.d.ts.map +1 -1
  23. package/dist/core/storage/routing.js +10 -4
  24. package/dist/core/storage/routing.js.map +1 -1
  25. package/dist/core/storage/sessions.d.ts +17 -0
  26. package/dist/core/storage/sessions.d.ts.map +1 -1
  27. package/dist/core/storage/sessions.js +64 -0
  28. package/dist/core/storage/sessions.js.map +1 -1
  29. package/dist/core/storage/skills.d.ts +4 -0
  30. package/dist/core/storage/skills.d.ts.map +1 -1
  31. package/dist/core/storage/skills.js +10 -2
  32. package/dist/core/storage/skills.js.map +1 -1
  33. package/dist/core/storage/sqlite.d.ts +5 -0
  34. package/dist/core/storage/sqlite.d.ts.map +1 -1
  35. package/dist/core/storage/sqlite.js +6 -0
  36. package/dist/core/storage/sqlite.js.map +1 -1
  37. package/dist/core/storage/tasks.d.ts.map +1 -1
  38. package/dist/core/storage/tasks.js +2 -0
  39. package/dist/core/storage/tasks.js.map +1 -1
  40. package/dist/core/types.d.ts +7 -0
  41. package/dist/core/types.d.ts.map +1 -1
  42. package/dist/daemon/index.d.ts.map +1 -1
  43. package/dist/daemon/index.js +30 -5
  44. package/dist/daemon/index.js.map +1 -1
  45. package/dist/daemon/skill-sync.d.ts +21 -0
  46. package/dist/daemon/skill-sync.d.ts.map +1 -0
  47. package/dist/daemon/skill-sync.js +75 -0
  48. package/dist/daemon/skill-sync.js.map +1 -0
  49. package/dist/hooks/notification.sh +1 -1
  50. package/dist/hooks/post-tool-use.sh +1 -1
  51. package/dist/hooks/pre-tool-use.sh +1 -1
  52. package/dist/hooks/stop.sh +1 -1
  53. package/dist/hooks/user-prompt-submit.sh +1 -1
  54. package/dist/skills/official/code-simplifier.md +37 -1
  55. package/dist/skills/official/find-skills.md +120 -1
  56. package/dist/skills/official/official-api-design.md +14 -1
  57. package/dist/skills/official/official-architecture-decision.md +22 -1
  58. package/dist/skills/official/official-db-schema-design.md +19 -1
  59. package/dist/skills/official/official-debug.md +9 -1
  60. package/dist/skills/official/official-pr-review.md +1 -1
  61. package/dist/skills/official/official-security-hardening.md +7 -1
  62. package/dist/skills/official/planning-with-files.md +206 -2
  63. package/dist/skills/official/ui-ux-pro-max.md +88 -1
  64. package/dist/skills/official/webapp-testing.md +85 -1
  65. package/dist/skills/registry.d.ts +1 -1
  66. package/dist/skills/registry.d.ts.map +1 -1
  67. package/dist/skills/registry.js +15 -4
  68. package/dist/skills/registry.js.map +1 -1
  69. package/dist/skills/semantic-matcher.d.ts +4 -3
  70. package/dist/skills/semantic-matcher.d.ts.map +1 -1
  71. package/dist/skills/semantic-matcher.js +20 -22
  72. package/dist/skills/semantic-matcher.js.map +1 -1
  73. package/dist/skills/upgrade-engine.d.ts +93 -0
  74. package/dist/skills/upgrade-engine.d.ts.map +1 -0
  75. package/dist/skills/upgrade-engine.js +447 -0
  76. package/dist/skills/upgrade-engine.js.map +1 -0
  77. package/dist/skills/upgrade-prompt.d.ts +20 -0
  78. package/dist/skills/upgrade-prompt.d.ts.map +1 -0
  79. package/dist/skills/upgrade-prompt.js +75 -0
  80. package/dist/skills/upgrade-prompt.js.map +1 -0
  81. package/dist/web/analytics/weekly-report.d.ts.map +1 -1
  82. package/dist/web/analytics/weekly-report.js +21 -29
  83. package/dist/web/analytics/weekly-report.js.map +1 -1
  84. package/dist/web/routes/patch.d.ts.map +1 -1
  85. package/dist/web/routes/patch.js +32 -2
  86. package/dist/web/routes/patch.js.map +1 -1
  87. package/dist/web/routes/sessions.d.ts.map +1 -1
  88. package/dist/web/routes/sessions.js +9 -7
  89. package/dist/web/routes/sessions.js.map +1 -1
  90. package/dist/web/routes/trace.d.ts.map +1 -1
  91. package/dist/web/routes/trace.js +2 -3
  92. package/dist/web/routes/trace.js.map +1 -1
  93. package/dist/web/server.d.ts.map +1 -1
  94. package/dist/web/server.js +3 -2
  95. package/dist/web/server.js.map +1 -1
  96. package/package.json +12 -2
  97. package/scripts/postinstall.cjs +21 -0
  98. package/.claude/CLAUDE.md +0 -17
  99. package/.eslintrc.js +0 -23
  100. package/.prettierrc +0 -8
  101. package/ARCHITECTURE_ISSUES.md +0 -249
  102. package/CLAUDE.md +0 -265
  103. package/CLAUDE.md.backup +0 -488
  104. package/docs/concurrent-agents.md +0 -129
  105. package/docs/design/architecture-review-20260516.md +0 -232
  106. package/docs/design/fix-skills-data-and-set-leak-spec-20260516-1300.md +0 -219
  107. package/docs/design/h1-storage-aggregation-spec-20260518-1121.md +0 -299
  108. package/docs/design/h2-getdatabase-encapsulation-spec-20260518-1450.md +0 -191
  109. package/docs/design/h3-fallback-removal-spec-20260518-1245.md +0 -76
  110. package/docs/design/h4-index-dedup-spec-20260518-1230.md +0 -109
  111. package/docs/design/h6-services-migration-spec-20260518-1355.md +0 -82
  112. package/docs/design/hook-failure-queue-spec-20260516-1530.md +0 -204
  113. package/docs/design/l1-swarm-protocol-extract-spec-20260518-1605.md +0 -106
  114. package/docs/design/m10-forge-paths-spec-20260518-1320.md +0 -121
  115. package/docs/design/m2-m3-tool-input-spec-20260518-1425.md +0 -131
  116. package/docs/design/m7-routing-event-association-spec-20260518-1545.md +0 -103
  117. package/docs/design/project-path-gitroot-spec-20260518-1715.md +0 -134
  118. package/docs/design/refactor-phase1-spec-20260515-1600.md +0 -543
  119. package/docs/design/refactor-phase2-spec-20260515-1700.md +0 -424
  120. package/docs/design/task-active-gc-spec-20260518-1745.md +0 -146
  121. package/docs/design/tasks-list-filter-pagination-spec-20260518-0930.md +0 -208
  122. package/docs/implementation/fix-skills-data-and-set-leak-changelog-20260516-1300.md +0 -104
  123. package/docs/implementation/h1-storage-aggregation-changelog-20260518-1121.md +0 -82
  124. package/docs/implementation/h2-final-changelog-20260518-1530.md +0 -61
  125. package/docs/implementation/h2-phase1-safety-net-changelog-20260518-1450.md +0 -70
  126. package/docs/implementation/h2-phase2-operations-changelog-20260518-1450.md +0 -120
  127. package/docs/implementation/h2-phase3-callsites-changelog-20260518-1450.md +0 -71
  128. package/docs/implementation/h3-fallback-removal-changelog-20260518-1245.md +0 -71
  129. package/docs/implementation/h4-index-dedup-changelog-20260518-1230.md +0 -60
  130. package/docs/implementation/h6-services-migration-changelog-20260518-1355.md +0 -46
  131. package/docs/implementation/h7-m9-defaults-changelog-20260518-1300.md +0 -46
  132. package/docs/implementation/hook-failure-queue-changelog-20260516-1530.md +0 -196
  133. package/docs/implementation/hotfix-daemon-event-reject-20260516-1430.md +0 -56
  134. package/docs/implementation/l1-swarm-protocol-extract-changelog-20260518-1605.md +0 -45
  135. package/docs/implementation/l3-l4-daemon-perf-changelog-20260518-1410.md +0 -63
  136. package/docs/implementation/l6-l8-final-cleanup-changelog-20260518-1640.md +0 -38
  137. package/docs/implementation/m1-m4-m5-l7-cleanup-changelog-20260518-1310.md +0 -58
  138. package/docs/implementation/m10-forge-paths-changelog-20260518-1320.md +0 -60
  139. package/docs/implementation/m2-m3-tool-input-changelog-20260518-1425.md +0 -43
  140. package/docs/implementation/m6-m8-naming-shutdown-changelog-20260518-1340.md +0 -56
  141. package/docs/implementation/m7-routing-association-changelog-20260518-1545.md +0 -69
  142. package/docs/implementation/project-path-gitroot-changelog-20260518-1715.md +0 -63
  143. package/docs/implementation/refactor-phase1-changelog-20260515-1630.md +0 -354
  144. package/docs/implementation/refactor-phase2-changelog-20260515-1705.md +0 -421
  145. package/docs/implementation/task-active-gc-changelog-20260518-1745.md +0 -35
  146. package/docs/implementation/task-title-summary-changelog-20260518-1130.md +0 -39
  147. package/docs/implementation/tasks-detail-back-loses-filters-changelog-20260518-1100.md +0 -22
  148. package/docs/implementation/tasks-list-filter-pagination-changelog-20260518-0930.md +0 -72
  149. package/docs/implementation/tasks-page-white-screen-hotfix-changelog-20260518-1015.md +0 -56
  150. package/docs/reviews/claudemd-template-sync.md +0 -54
  151. package/docs/reviews/task-title-summary.md +0 -92
  152. package/docs/reviews/tasks-detail-back-loses-filters.md +0 -58
  153. package/docs/reviews/tasks-filter-pagination.md +0 -80
  154. package/docs/reviews/tasks-page-white-screen-hotfix.md +0 -126
  155. package/docs/ruflo-learning-strategy.md +0 -322
  156. package/docs/skills-deduplication-analysis.md +0 -83
  157. package/docs/skills-multiformat-support.md +0 -177
  158. package/docs/skills-third-party.md +0 -183
  159. package/docs/testing/tasks-filter-pagination-test-report.md +0 -86
  160. package/forge +0 -321
  161. package/playwright.config.ts +0 -40
  162. package/scripts/demo-v2.ts +0 -91
  163. package/scripts/dev-daemon.sh +0 -232
  164. package/scripts/dev-web.ts +0 -109
  165. package/scripts/e2e-mcp-link.ts +0 -423
  166. package/scripts/e2e-methodology-quality.ts +0 -253
  167. package/scripts/e2e-routing.ts +0 -456
  168. package/scripts/e2e-user-methodology.ts +0 -326
  169. package/scripts/e2e-web-workflows.ts +0 -299
  170. package/scripts/migrate-legacy-to-dynamic.sql +0 -108
  171. package/scripts/regenerate-execution-docs.ts +0 -116
  172. package/scripts/sync-agent-skills.ts +0 -193
  173. package/scripts/test-hook.sh +0 -71
  174. package/scripts/verify-skill-loading.ts +0 -62
  175. package/src/claudemd/claudemd-generator.ts +0 -568
  176. package/src/claudemd/convention-extractor.ts +0 -69
  177. package/src/claudemd/index.ts +0 -35
  178. package/src/claudemd/persona-manager.ts +0 -88
  179. package/src/claudemd/resume-manager.ts +0 -236
  180. package/src/claudemd/tech-detector.ts +0 -220
  181. package/src/claudemd/templates/swarm-protocol.md +0 -222
  182. package/src/cli/commands/claudemd.ts +0 -84
  183. package/src/cli/commands/config.ts +0 -46
  184. package/src/cli/commands/daemon.ts +0 -310
  185. package/src/cli/commands/executions.ts +0 -115
  186. package/src/cli/commands/init.ts +0 -204
  187. package/src/cli/commands/logs.ts +0 -181
  188. package/src/cli/commands/mcp.ts +0 -242
  189. package/src/cli/commands/menu.ts +0 -357
  190. package/src/cli/commands/skills.ts +0 -185
  191. package/src/cli/commands/stats.ts +0 -73
  192. package/src/cli/commands/status.ts +0 -69
  193. package/src/cli/commands/template.ts +0 -77
  194. package/src/cli/commands/trace.ts +0 -148
  195. package/src/cli/index.ts +0 -42
  196. package/src/cli/init/hook-manager.ts +0 -132
  197. package/src/core/ai/provider.ts +0 -308
  198. package/src/core/ai/types.ts +0 -51
  199. package/src/core/config.ts +0 -124
  200. package/src/core/constants.ts +0 -62
  201. package/src/core/event-fields.ts +0 -32
  202. package/src/core/queue/index.ts +0 -192
  203. package/src/core/storage/base.ts +0 -302
  204. package/src/core/storage/events.ts +0 -434
  205. package/src/core/storage/injections.ts +0 -78
  206. package/src/core/storage/maintenance.ts +0 -59
  207. package/src/core/storage/migrations/002_add_skill_tracking.sql +0 -6
  208. package/src/core/storage/migrations/003_add_skill_invocations.sql +0 -23
  209. package/src/core/storage/performance-indexes.sql +0 -23
  210. package/src/core/storage/routing.ts +0 -322
  211. package/src/core/storage/rows.ts +0 -112
  212. package/src/core/storage/schema.sql +0 -224
  213. package/src/core/storage/sessions.ts +0 -168
  214. package/src/core/storage/skills.ts +0 -233
  215. package/src/core/storage/sqlite.ts +0 -293
  216. package/src/core/storage/tasks.ts +0 -318
  217. package/src/core/storage/token-usage.ts +0 -93
  218. package/src/core/types.ts +0 -181
  219. package/src/core/utils/error-handler.ts +0 -257
  220. package/src/core/utils/forge-resume-block.ts +0 -74
  221. package/src/core/utils/format.ts +0 -69
  222. package/src/core/utils/git.ts +0 -23
  223. package/src/core/utils/logger.ts +0 -134
  224. package/src/core/utils/lru-cache.ts +0 -54
  225. package/src/core/utils/path.ts +0 -19
  226. package/src/core/utils/session.ts +0 -26
  227. package/src/core/utils/time.ts +0 -37
  228. package/src/core/utils/token-tracker.ts +0 -97
  229. package/src/daemon/event-parser.ts +0 -36
  230. package/src/daemon/handlers/history-exporter.ts +0 -117
  231. package/src/daemon/handlers/post-tool-use.ts +0 -54
  232. package/src/daemon/handlers/stop.ts +0 -208
  233. package/src/daemon/handlers/user-prompt.ts +0 -178
  234. package/src/daemon/hook-sync.ts +0 -91
  235. package/src/daemon/index.ts +0 -302
  236. package/src/daemon/launchd/com.claude-forge.daemon.plist.template +0 -47
  237. package/src/daemon/launchd-installer.ts +0 -260
  238. package/src/daemon/lifecycle.ts +0 -128
  239. package/src/daemon/router.ts +0 -40
  240. package/src/daemon/server.ts +0 -196
  241. package/src/daemon/services/task-segmenter.ts +0 -112
  242. package/src/hooks/hook-lib.sh +0 -118
  243. package/src/hooks/notification.sh +0 -35
  244. package/src/hooks/post-tool-use.sh +0 -61
  245. package/src/hooks/pre-tool-use.sh +0 -63
  246. package/src/hooks/stop.sh +0 -43
  247. package/src/hooks/user-prompt-submit.sh +0 -69
  248. package/src/mcp/server.ts +0 -322
  249. package/src/skills/index.ts +0 -2
  250. package/src/skills/invocation-guard.ts +0 -177
  251. package/src/skills/matcher.ts +0 -148
  252. package/src/skills/official/code-simplifier.md +0 -16
  253. package/src/skills/official/find-skills.md +0 -23
  254. package/src/skills/official/official-api-design.md +0 -17
  255. package/src/skills/official/official-architecture-decision.md +0 -20
  256. package/src/skills/official/official-bmad.md +0 -118
  257. package/src/skills/official/official-db-schema-design.md +0 -16
  258. package/src/skills/official/official-debug.md +0 -17
  259. package/src/skills/official/official-doc-driven.md +0 -31
  260. package/src/skills/official/official-harness-engineering.md +0 -108
  261. package/src/skills/official/official-performance-optimization.md +0 -30
  262. package/src/skills/official/official-pr-review.md +0 -35
  263. package/src/skills/official/official-release-checklist.md +0 -30
  264. package/src/skills/official/official-security-hardening.md +0 -26
  265. package/src/skills/official/official-spec-driven-design.md +0 -31
  266. package/src/skills/official/planning-with-files.md +0 -37
  267. package/src/skills/official/ui-ux-pro-max.md +0 -18
  268. package/src/skills/official/webapp-testing.md +0 -12
  269. package/src/skills/official-skills.ts +0 -89
  270. package/src/skills/registry.ts +0 -355
  271. package/src/skills/semantic-matcher.ts +0 -231
  272. package/src/skills/tools/pipeline-suggest.ts +0 -226
  273. package/src/skills/tools/skill-invoke.ts +0 -168
  274. package/src/skills/tools/skill-list.ts +0 -59
  275. package/src/templates/go.yaml +0 -53
  276. package/src/templates/python.yaml +0 -59
  277. package/src/templates/react.yaml +0 -55
  278. package/src/templates/template-manager.ts +0 -170
  279. package/src/web/analytics/anti-pattern-detector.ts +0 -367
  280. package/src/web/analytics/drift-detector.ts +0 -219
  281. package/src/web/analytics/weekly-report.ts +0 -431
  282. package/src/web/auth-middleware.ts +0 -54
  283. package/src/web/routes/_helpers.ts +0 -34
  284. package/src/web/routes/ai.ts +0 -204
  285. package/src/web/routes/auth.ts +0 -22
  286. package/src/web/routes/drift.ts +0 -25
  287. package/src/web/routes/error-handler.ts +0 -120
  288. package/src/web/routes/events.ts +0 -47
  289. package/src/web/routes/insights.ts +0 -43
  290. package/src/web/routes/patch.ts +0 -117
  291. package/src/web/routes/reports.ts +0 -34
  292. package/src/web/routes/rules.ts +0 -76
  293. package/src/web/routes/sessions.ts +0 -250
  294. package/src/web/routes/skill-stats.ts +0 -92
  295. package/src/web/routes/skills.ts +0 -350
  296. package/src/web/routes/static.ts +0 -67
  297. package/src/web/routes/stats.ts +0 -50
  298. package/src/web/routes/status.ts +0 -30
  299. package/src/web/routes/tasks.ts +0 -193
  300. package/src/web/routes/token-usage.ts +0 -20
  301. package/src/web/routes/trace.ts +0 -126
  302. package/src/web/routes/types.ts +0 -57
  303. package/src/web/server.ts +0 -134
  304. package/src/web/ssrf-guard.ts +0 -112
  305. package/src/web/static/index.html +0 -3251
  306. package/src/web/static/vendor/chart.umd.min.js +0 -20
  307. package/tests/e2e/dashboard.spec.ts +0 -205
  308. package/tests/e2e/routing-skill-e2e.test.ts +0 -39
  309. package/tests/helpers/mock-ai.ts +0 -92
  310. package/tests/helpers/mock-storage.ts +0 -159
  311. package/tests/integration/claudemd-generator.test.ts +0 -90
  312. package/tests/integration/queue-replay.integration.test.ts +0 -193
  313. package/tests/integration/tasks-filter.integration.test.ts +0 -154
  314. package/tests/integration/web-analytics.integration.test.ts +0 -133
  315. package/tests/integration/web-stats.integration.test.ts +0 -135
  316. package/tests/integration/web-trace.integration.test.ts +0 -175
  317. package/tests/performance/database.benchmark.ts +0 -161
  318. package/tests/semantic-matcher.test.ts +0 -99
  319. package/tests/skill-matcher.test.ts +0 -110
  320. package/tests/unit/ai-provider-retry.test.ts +0 -194
  321. package/tests/unit/ai-provider-vision.test.ts +0 -224
  322. package/tests/unit/claudemd-generator.test.ts +0 -68
  323. package/tests/unit/cli-mcp.test.ts +0 -141
  324. package/tests/unit/core/forge-paths.test.ts +0 -99
  325. package/tests/unit/daemon/hook-sync.test.ts +0 -71
  326. package/tests/unit/daemon/post-tool-use.test.ts +0 -121
  327. package/tests/unit/daemon/stop-handler-behavior-summary.test.ts +0 -202
  328. package/tests/unit/daemon/task-segmenter-recover.test.ts +0 -84
  329. package/tests/unit/event-fields.test.ts +0 -88
  330. package/tests/unit/event-parser.test.ts +0 -55
  331. package/tests/unit/handlers.test.ts +0 -171
  332. package/tests/unit/hooks/resolve-project-path.test.ts +0 -122
  333. package/tests/unit/invocation-guard.test.ts +0 -125
  334. package/tests/unit/queue.test.ts +0 -272
  335. package/tests/unit/router.test.ts +0 -138
  336. package/tests/unit/security.test.ts +0 -128
  337. package/tests/unit/skill-invocations-workflow.test.ts +0 -495
  338. package/tests/unit/skill-registry.test.ts +0 -94
  339. package/tests/unit/skills/invocation-guard-ttl.test.ts +0 -211
  340. package/tests/unit/skills/official-skills-loader.test.ts +0 -126
  341. package/tests/unit/skills/registry-multiformat.test.ts +0 -92
  342. package/tests/unit/socket-server.test.ts +0 -183
  343. package/tests/unit/storage/event-operations-aggregates.test.ts +0 -342
  344. package/tests/unit/storage/migration-idempotent.test.ts +0 -304
  345. package/tests/unit/storage/routing-aggregates.test.ts +0 -276
  346. package/tests/unit/storage/routing.test.ts +0 -117
  347. package/tests/unit/storage/schema-missing.test.ts +0 -81
  348. package/tests/unit/storage/session-operations-aggregates.test.ts +0 -120
  349. package/tests/unit/storage/sessions-aggregate.test.ts +0 -435
  350. package/tests/unit/storage/skill-operations-counts.test.ts +0 -106
  351. package/tests/unit/storage/skills-aggregates.test.ts +0 -104
  352. package/tests/unit/storage/sqlite-refactor-harness.test.ts +0 -314
  353. package/tests/unit/storage/task-operations-counts.test.ts +0 -46
  354. package/tests/unit/storage/tasks-getById.test.ts +0 -343
  355. package/tests/unit/storage/tasks-stale-gc.test.ts +0 -86
  356. package/tests/unit/storage.test.ts +0 -172
  357. package/tests/unit/token-usage.test.ts +0 -144
  358. package/tests/unit/type-guards.test.ts +0 -201
  359. package/tests/unit/utils/format.test.ts +0 -189
  360. package/tests/unit/utils/session.test.ts +0 -89
  361. package/tests/unit/utils/time.test.ts +0 -112
  362. package/tests/unit/web/navigation-back-contract.test.ts +0 -134
  363. package/tests/unit/web/routes-auth.test.ts +0 -93
  364. package/tests/unit/web/routes-events.test.ts +0 -101
  365. package/tests/unit/web/routes-rules.test.ts +0 -182
  366. package/tests/unit/web/routes-sessions.test.ts +0 -181
  367. package/tests/unit/web/routes-skill-stats.test.ts +0 -179
  368. package/tests/unit/web/routes-stats.test.ts +0 -92
  369. package/tests/unit/web/routes-tasks.test.ts +0 -385
  370. package/tests/unit/web/task-title-contract.test.ts +0 -210
  371. package/tests/unit/web/tasks-component-contract.test.ts +0 -179
  372. package/tsconfig.json +0 -22
  373. package/vitest.config.ts +0 -21
  374. package/vitest.integration.config.ts +0 -16
  375. package/web/CLAUDE.md +0 -20
  376. package/web/index.html +0 -13
  377. package/web/package-lock.json +0 -4854
  378. package/web/package.json +0 -35
  379. package/web/postcss.config.js +0 -6
  380. package/web/src/App.tsx +0 -110
  381. package/web/src/components/CodeBlock.tsx +0 -31
  382. package/web/src/components/Confirm.tsx +0 -96
  383. package/web/src/components/Drawer.tsx +0 -60
  384. package/web/src/components/Layout.tsx +0 -145
  385. package/web/src/components/MarkdownRenderer.tsx +0 -77
  386. package/web/src/components/SearchInput.tsx +0 -31
  387. package/web/src/components/SessionDetailContent.tsx +0 -157
  388. package/web/src/components/Toast.tsx +0 -92
  389. package/web/src/index.css +0 -19
  390. package/web/src/main.tsx +0 -31
  391. package/web/src/pages/AIConfig.tsx +0 -233
  392. package/web/src/pages/Dashboard.tsx +0 -572
  393. package/web/src/pages/Events.tsx +0 -271
  394. package/web/src/pages/Reports.tsx +0 -428
  395. package/web/src/pages/SessionDetail.tsx +0 -162
  396. package/web/src/pages/Sessions.tsx +0 -205
  397. package/web/src/pages/Skills.tsx +0 -180
  398. package/web/src/pages/TaskDetail.tsx +0 -515
  399. package/web/src/pages/Tasks.tsx +0 -415
  400. package/web/src/utils/auth.ts +0 -59
  401. package/web/src/utils/export.ts +0 -54
  402. package/web/src/utils/navigation.ts +0 -25
  403. package/web/src/utils/task-title.ts +0 -49
  404. package/web/src/utils/time.ts +0 -13
  405. package/web/tailwind.config.js +0 -11
  406. package/web/tsconfig.json +0 -21
  407. package/web/tsconfig.node.json +0 -10
  408. package/web/vite.config.ts +0 -76
  409. package/winspan-claude-forge-8.43.0.tgz +0 -0
@@ -1,208 +0,0 @@
1
- # Tasks 列表筛选 + 分页 — 设计 Spec
2
-
3
- **日期**: 2026-05-18
4
- **状态**: Draft(待用户 review)
5
-
6
- ---
7
-
8
- ## 工作流路径
9
-
10
- **hybrid-feature-with-safety**
11
-
12
- **理由**:`src/web/routes/` 有 19 个路由文件,`tests/unit/web/` 仅 6 个测试文件,覆盖率约 **32%**(低于 50% 阈值)。实现阶段每个后端改动文件均需配套新增/扩展测试用例。前端为单 HTML 文件无组件测试,route + storage 层必须达到 80% 分支覆盖。
13
-
14
- ---
15
-
16
- ## 1. 目标 + 成功标准
17
-
18
- 让 `GET /api/tasks` 支持完整服务端筛选与分页;前端 tasks 视图新增筛选栏 + 分页组件,URL 同步状态。
19
-
20
- ### 验收用例
21
-
22
- | # | 场景 | 期望 |
23
- |---|------|------|
24
- | A1 | `GET /api/tasks?limit=10&offset=0` | `{ items: [...10], total, has_more }` |
25
- | A2 | `GET /api/tasks?project=/path/foo` | 仅返回该 project_path 的 tasks |
26
- | A3 | `?project=a&project=b` | 两个项目 OR 关系 |
27
- | A4 | `?from=2026-01-01T00:00:00Z&to=2026-01-31T23:59:59Z` | start_time 范围过滤 |
28
- | A5 | `?search=重构` | title LIKE `%重构%` |
29
- | A6 | `?limit=201` | clamp 到 200 |
30
- | A7 | 前端选「24h」+ 搜索「build」 | URL: `?range=24h&search=build&page=1`,刷新保留 |
31
- | A8 | 点「下一页」 | offset 递增,total 不变 |
32
-
33
- **非目标**:FTS5 全文检索、status 多选、修改 `/api/tasks/:taskId` 详情接口。
34
-
35
- ---
36
-
37
- ## 2. 后端设计
38
-
39
- ### 2.1 Route 层 `src/web/routes/tasks.ts`
40
-
41
- **已有**:`limit`(默认 20)、`session`
42
- **待加**:`offset`、`project`(多值)、`from`、`to`、`search`,返回结构升级
43
-
44
- ```
45
- QueryParams (Zod):
46
- limit: number, default 50, max 200, min 1
47
- offset: number, default 0, min 0
48
- project: string | string[] // 多值
49
- from/to: ISO 8601 string, optional
50
- search: string, optional, maxLength 100
51
- session: string, optional // 保留
52
- ```
53
-
54
- 返回从 `Task[]` 升级为 `{ items, total, has_more }`。**破坏性变更**:内部 dashboard 无外部消费者,可接受。
55
-
56
- ### 2.2 Storage 层 `src/core/storage/tasks.ts`
57
-
58
- **关键挑战**:`tasks` 表无 `project_path` 字段,需 JOIN `sessions` 表。
59
-
60
- ```sql
61
- -- 数据查询
62
- SELECT t.*, s.project_path
63
- FROM tasks t
64
- JOIN sessions s ON t.session_id = s.session_id
65
- WHERE
66
- [t.session_id = ?]
67
- [AND s.project_path IN (?, ?)]
68
- [AND t.start_time >= ?]
69
- [AND t.start_time <= ?]
70
- [AND t.title LIKE ?]
71
- ORDER BY t.start_time DESC
72
- LIMIT ? OFFSET ?;
73
-
74
- -- 总数查询:复用相同 WHERE,不带 LIMIT/OFFSET
75
- SELECT COUNT(*) FROM tasks t JOIN sessions s ON t.session_id = s.session_id WHERE [...];
76
- ```
77
-
78
- `TaskRecord` 新增可选字段 `project_path?: string`。
79
-
80
- ### 2.3 索引评估
81
-
82
- | 查询 | 现有 | 是否够 |
83
- |------|------|--------|
84
- | `ORDER BY start_time DESC` | `idx_tasks_start_time` | ✅ |
85
- | `WHERE session_id = ?` | `idx_tasks_session` | ✅ |
86
- | `WHERE s.project_path IN (...)` | `idx_sessions_project` | ✅ |
87
- | `WHERE t.title LIKE '%xxx%'` | 无 | ❌ 全表扫描,但数据量 <10k,可接受 |
88
- | `WHERE start_time BETWEEN ?` | `idx_tasks_start_time` | ✅ 范围扫描 |
89
-
90
- **新增**:`CREATE INDEX idx_tasks_start_time_session ON tasks(start_time DESC, session_id)`。
91
- **不引入 FTS5**(复杂度不值)。
92
-
93
- ### 2.4 新 Endpoint `GET /api/tasks/projects`
94
-
95
- 前端项目下拉需要"所有项目"列表:
96
-
97
- ```sql
98
- SELECT DISTINCT s.project_path FROM sessions s JOIN tasks t ON t.session_id = s.session_id;
99
- ```
100
-
101
- ---
102
-
103
- ## 3. 前端设计
104
-
105
- ### ⚠️ 重要发现
106
-
107
- 调研显示前端是**原生 HTML + Vanilla JS**(`src/web/static/index.html` 单文件),不是 CLAUDE.md 描述的 React/Vite。当前页面切换通过 `nav(pageName)` + `id="page-xxx"` div 控制。
108
-
109
- > **请用户确认**:(a) spec 按 Vanilla JS 实施(与现状一致);(b) 顺手迁移到 React(额外大改);(c) CLAUDE.md 该改技术栈描述
110
-
111
- ### 3.2 新增 `#page-tasks` 视图
112
-
113
- Sidebar 加 "Tasks" 导航项。
114
-
115
- ```
116
- page-tasks
117
- ├── .toolbar
118
- │ ├── #tasks-project-filter (多选 select)
119
- │ ├── #tasks-range-filter (1h/24h/7d/自定义)
120
- │ ├── #tasks-date-from/to (datetime-local,自定义时显示)
121
- │ └── #tasks-search (300ms 防抖)
122
- ├── <table id="tasks-table"> 时间 / 标题 / 项目 / 状态 / 事件数
123
- └── .pagination-bar
124
- ├── "共 N 条,第 X-Y"
125
- ├── 每页 [20/50/100]
126
- └── [上一页] [下一页]
127
- ```
128
-
129
- ### 3.3 URL 状态同步
130
-
131
- `URLSearchParams` + `history.pushState`:
132
-
133
- | URL | 控件 |
134
- |-----|------|
135
- | `project` | 多选下拉(可重复) |
136
- | `range` | 1h/24h/7d/custom |
137
- | `from`/`to` | 自定义时间 |
138
- | `search` | 搜索框 |
139
- | `page` | offset = (page-1) * limit |
140
- | `size` | 20/50/100 |
141
-
142
- ### 3.4 防抖
143
-
144
- 搜索框 `oninput` → setTimeout 300ms → `loadTasks()`,每次键入重置。
145
-
146
- ---
147
-
148
- ## 4. 改动文件清单
149
-
150
- | 文件 | 改动 | 行数 |
151
- |------|------|------|
152
- | `src/core/storage/tasks.ts` | 扩展 filter + COUNT + project_path | +40 |
153
- | `src/core/storage/schema.sql` | 加复合索引 | +2 |
154
- | `src/web/routes/tasks.ts` | Zod 解析 + 多参数 + 返回结构 + `/projects` 子路由 | +50 |
155
- | `src/web/static/index.html` | `#page-tasks` 视图 + JS 函数 + URL 同步 + 防抖 | +200 |
156
- | `tests/unit/web/routes-tasks.test.ts` | 扩展参数组合用例 | +80 |
157
-
158
- ---
159
-
160
- ## 5. 风险点
161
-
162
- | 风险 | 缓解 |
163
- |------|------|
164
- | tasks 无 project_path,需 JOIN sessions | `TaskRecord` 加可选 `project_path?` |
165
- | 项目下拉数据来源 | 新增 `/api/tasks/projects` |
166
- | project_path 太长(绝对路径) | 截断显示最后 2 段,title 属性放完整 |
167
- | 返回结构破坏性变更 | 搜 index.html 所有 `/api/tasks` 调用点同步更新 |
168
- | LIKE 性能 | <10k 行可接受,不引入 FTS5 |
169
- | 前端无组件测试 | 仅 route 集成测试,前端 E2E 手工 |
170
-
171
- ---
172
-
173
- ## 6. 测试策略
174
-
175
- ### 单元测试 `tests/unit/web/routes-tasks.test.ts`
176
-
177
- - `project` 单值/多值(OR)
178
- - `from`/`to` 边界
179
- - `search` LIKE 匹配(SQLite ASCII 不区分大小写)
180
- - `limit` clamp
181
- - `offset` 分页 + `has_more` 准确
182
- - 返回结构 schema
183
- - `GET /api/tasks/projects` 去重
184
-
185
- ### 集成测试
186
-
187
- 新建 `tests/integration/tasks-filter.test.ts`,真实 SQLite 验证 JOIN + COUNT。
188
-
189
- ### 前端 E2E
190
-
191
- 按 A1-A8 在 dashboard 手工验证 + 截图。
192
-
193
- ---
194
-
195
- ## 7. 执行步骤(自底向上)
196
-
197
- 1. `schema.sql` — 加索引 `idx_tasks_start_time_session`
198
- 2. `storage/tasks.ts` — 扩 filter / JOIN / COUNT / project_path
199
- 3. Storage 单元测试
200
- 4. `routes/tasks.ts` — Zod + 多参数 + 返回结构 + `/projects`
201
- 5. Route 单元测试
202
- 6. `index.html` — `#page-tasks` 视图 + JS + URL 同步 + 防抖
203
- 7. `npm test` + `npx tsc --noEmit`
204
- 8. 按 A1-A8 手工验收
205
-
206
- ---
207
-
208
- **Hybrid-feature-with-safety 工作流**:先 safety-net(扩展 routes-tasks 现有测试,锁定旧 `Task[]` 返回行为)→ design → implement → test → review
@@ -1,104 +0,0 @@
1
- # Changelog: Official Skills 数据分离 + UserPromptHandler Set 内存泄漏修复
2
-
3
- **日期**: 2026-05-16
4
- **Spec**: `docs/design/fix-skills-data-and-set-leak-spec-20260516-1300.md`
5
-
6
- ---
7
-
8
- ## 实际改动文件清单
9
-
10
- ### 新建文件
11
-
12
- | 文件路径 | 行数 | 说明 |
13
- |----------|------|------|
14
- | `src/skills/official/official-harness-engineering.md` | 91 | Harness Engineering 方法论 |
15
- | `src/skills/official/official-spec-driven-design.md` | 28 | Spec-Driven Design |
16
- | `src/skills/official/official-architecture-decision.md` | 22 | ADR 模板(截断版,与原始 content 一致)|
17
- | `src/skills/official/official-api-design.md` | 19 | API 设计规范(截断版)|
18
- | `src/skills/official/official-db-schema-design.md` | 19 | DB Schema 设计(截断版)|
19
- | `src/skills/official/official-pr-review.md` | 32 | PR 审查清单(截断版)|
20
- | `src/skills/official/official-debug.md` | 18 | 调试工作流(截断版)|
21
- | `src/skills/official/official-performance-optimization.md` | 30 | 性能优化 |
22
- | `src/skills/official/official-security-hardening.md` | 27 | 安全加固(截断版)|
23
- | `src/skills/official/official-release-checklist.md` | 30 | 发布清单 |
24
- | `src/skills/official/official-doc-driven.md` | 28 | 文档驱动开发 |
25
- | `src/skills/official/planning-with-files.md` | 35 | Manus 风格任务规划(截断版)|
26
- | `src/skills/official/code-simplifier.md` | 17 | 代码简化(截断版)|
27
- | `src/skills/official/find-skills.md` | 24 | 技能发现(截断版)|
28
- | `src/skills/official/webapp-testing.md` | 12 | Web 应用测试(截断版)|
29
- | `src/skills/official/ui-ux-pro-max.md` | 19 | UI/UX 设计工具(截断版)|
30
- | `src/skills/official/official-bmad.md` | 90 | BMAD 方法论 |
31
- | `tests/unit/skills/official-skills-loader.test.ts` | 113 | loadOfficialSkills 单元测试(7 个 case)|
32
-
33
- ### 修改文件
34
-
35
- | 文件路径 | 改动 | 说明 |
36
- |----------|------|------|
37
- | `src/skills/official-skills.ts` | -700行 +73行 | 删除 OFFICIAL_SKILLS 数组;保留 OfficialSkill 接口和 OFFICIAL_SKILL_KEYWORDS;新增 loadOfficialSkills(builtinDir) |
38
- | `src/skills/registry.ts` | +30行 | 新增 resolveBuiltinDir(); scan() 第 1 段改用 loadOfficialSkills; import 更新 |
39
- | `src/cli/commands/skills.ts` | +7行 | 移除 OFFICIAL_SKILLS import;新增 resolveBuiltinDir(); syncSkills 改用 loadOfficialSkills |
40
- | `src/daemon/handlers/user-prompt.ts` | +40行 | Set 改 Map<string,number>; 新增 MAX_INJECTION_KEYS=1000; hasInjected/markInjected 私有方法; clearSession 公共方法 |
41
- | `src/daemon/handlers/stop.ts` | +15行 | import UserPromptHandler 类型; 构造函数增加可选参数 userPromptHandler; Step 5 调用 clearSession |
42
- | `src/daemon/index.ts` | +5行 | 将 userPromptHandler 实例传入 StopHandler 构造函数 |
43
- | `package.json` | +1行 | build 脚本追加 `mkdir -p dist/skills/official && cp src/skills/official/*.md dist/skills/official/` |
44
- | `tests/unit/skill-registry.test.ts` | +2行 | 断言数量从 >= 16 改为 >= 17(两处) |
45
- | `tests/unit/handlers.test.ts` | +92行 | 新增 3 个 UserPromptHandler 测试 case |
46
-
47
- ---
48
-
49
- ## 与 Spec 的偏差
50
-
51
- ### 偏差 1:Skill 数量是 17,不是 19
52
- Spec 说"共 19 个 skill",但 `OFFICIAL_SKILLS` 数组实际只有 17 个条目(缺少 `official-tdd` 和 `official-refactor`,这两个仅在 `OFFICIAL_SKILL_KEYWORDS` 中有 keyword 映射但没有对应的 skill 定义)。实际创建了 17 个 `.md` 文件。测试断言改为 `>= 17`。
53
-
54
- ### 偏差 2:部分 skill 内容截断
55
- 原始 `OFFICIAL_SKILLS` 数组中有 11 个 skill 的 `content` 字段以 `\`` 结尾(截断的 template literal)。这是源码的现有状态(非本次引入)。`.md` 文件完整保留了这些截断内容,与原有行为一致。这些截断是原始数据的一部分,不影响 skill 加载逻辑。
56
-
57
- ### 偏差 3:registry.ts 中 skill 的 path 字段构造
58
- Spec 建议使用 `resolveBuiltinDir() + '/' + officialSkill.name + '.md'` 作为路径。实际实现中每次调用 `resolveBuiltinDir()` 会重新计算,考虑到这是纯计算无副作用,对性能无影响。若有性能顾虑可缓存该值(已注释在代码中作为 TODO)。
59
-
60
- ### 偏差 4:loadOfficialSkills content 字段包含完整文件(含 frontmatter)
61
- Spec 中未明确 `content` 字段是否包含 frontmatter。registry 的现有用户 skill 逻辑(`body.trim()`)只包含 body。为保持与原有 OFFICIAL_SKILLS 行为一致(原 content 字段包含 frontmatter),`loadOfficialSkills` 返回的 `content` 字段设为完整文件内容(`raw`),而非仅 body。这样 skill 注入时内容与之前完全一致。
62
-
63
- ---
64
-
65
- ## 测试结果
66
-
67
- ### 执行的测试
68
- ```
69
- npx vitest run tests/unit/skill-registry.test.ts --reporter=verbose
70
- npx vitest run tests/unit/skills/ --reporter=verbose
71
- npx vitest run tests/unit/handlers.test.ts --reporter=verbose
72
- npx tsc --noEmit
73
- npm test -- --reporter=dot
74
- ```
75
-
76
- ### 结果汇总
77
-
78
- | 测试文件 | 状态 | 测试数 |
79
- |----------|------|--------|
80
- | `tests/unit/skill-registry.test.ts` | 全部通过 | 6/6 |
81
- | `tests/unit/skills/registry-multiformat.test.ts` | 全部通过 | 27/27 |
82
- | `tests/unit/skills/official-skills-loader.test.ts` | 全部通过 | 7/7 |
83
- | `tests/unit/handlers.test.ts` | 全部通过 | 7/7(新增 3 个)|
84
- | `tests/unit/skills/invocation-guard-ttl.test.ts` | 全部通过 | — |
85
- | TypeScript (`tsc --noEmit`) | 无错误 | — |
86
- | 全量测试 (`npm test`) | 291/294 通过 | 2 文件失败 |
87
-
88
- ### 预存在的失败(与本次改动无关)
89
- - `tests/unit/web/routes-tasks.test.ts`(2 个 case 失败):UUID 格式验证错误,与 storage 层有关
90
- - `tests/unit/storage/sqlite-refactor-harness.test.ts`(1 个 case 失败):`linkEventToTask` 相关,与 storage 层有关
91
-
92
- 注:这两个测试文件在本次改动前就已失败(baseline 状态:3 文件 / 10 个 case 失败;本次改动后:2 文件 / 3 个 case 失败,即我们的改动无意中修复了 skill-registry 相关的计数断言问题)。
93
-
94
- ---
95
-
96
- ## 已知风险 / TODO
97
-
98
- 1. **content 字段含 frontmatter**:registry 的用户 skill 加载使用 `body.trim()`(不含 frontmatter),而 official skill 的 `content` 现在是完整文件内容(含 frontmatter)。两者行为不一致,但与原始 OFFICIAL_SKILLS 数组保持了向后兼容。如需统一,可在后续 PR 中对齐。
99
-
100
- 2. **部分 skill 内容截断**:11 个 skill 的 body 内容被截断(原始代码如此)。这不是本次引入的问题。如需完整内容,需要重新补全对应的 `.md` 文件。
101
-
102
- 3. **syncSkills 命令的 version 比较**:`skills sync` 命令从 `.md` frontmatter 读取版本号做比较。对于截断的 skill,version 字段在 frontmatter 中完整保留,此功能不受影响。
103
-
104
- 4. **resolveBuiltinDir 每次重新计算**:scan() 中多次调用 resolveBuiltinDir(),可以在 scan 开始时缓存到局部变量(低优先级优化)。
@@ -1,82 +0,0 @@
1
- # H1 实施 Changelog
2
-
3
- **Date**: 2026-05-18 11:21
4
- **Spec**: `docs/design/h1-storage-aggregation-spec-20260518-1121.md`
5
- **Status**: 完成
6
-
7
- ## 完成清单
8
-
9
- - [x] Storage 新方法(7 个):
10
- - `aggregateRoutingStats({ since_ts, project_path? })` → `RoutingOperations`
11
- - `aggregateRoutingTrendByDay({ since_ts })` → `RoutingOperations`
12
- - `aggregateSkillInvocationsBySkill({ since, limit? })` → `SkillOperations`
13
- - `getTask(taskId)` → `TaskOperations`
14
- - `queryEventsByTaskId(taskId, opts?)` → `TaskOperations`
15
- - `queryInjectionsByTaskId(taskId)` → `TaskOperations`
16
- - `querySkillInvocationsByTaskWindow(taskId, now_ms?)` → `TaskOperations`
17
- - [x] sqlite.ts facade 转发已加(7 个方法)
18
- - [x] 索引新增:`idx_routing_events_type_ts` (schema.sql + base.ts runMigrations 同步)
19
- - [x] Storage 单元测试(3 文件):
20
- - `tests/unit/storage/routing-aggregates.test.ts`
21
- - `tests/unit/storage/skills-aggregates.test.ts`
22
- - `tests/unit/storage/tasks-getById-aggregates.test.ts`
23
- - [x] Routes 改造(3 文件):
24
- - `src/web/routes/rules.ts` — hit-rate 改用 `aggregateRoutingStats` + `aggregateSkillInvocationsBySkill`
25
- - `src/web/routes/skill-stats.ts` — 5 个 endpoint 全部下沉到 SQL 聚合
26
- - `src/web/routes/tasks.ts` — `/:taskId` PK 直查 + JOIN
27
- - [x] 路由测试新增:`tests/unit/web/routes-rules.test.ts`(之前缺口)
28
-
29
- ## 关键代码定位
30
-
31
- ### Storage 新方法
32
- - `src/core/storage/routing.ts` — `aggregateRoutingStats`、`aggregateRoutingTrendByDay`(4 条独立 prepared statement 走索引;trend 用 `strftime('%Y-%m-%d', ts/1000, 'unixepoch')`)
33
- - `src/core/storage/skills.ts` — `aggregateSkillInvocationsBySkill`(按 `total DESC`)
34
- - `src/core/storage/tasks.ts` — `getTask` / `queryEventsByTaskId` / `queryInjectionsByTaskId` / `querySkillInvocationsByTaskWindow`(后者用 `task_events` JOIN + `tasks.start_time/end_time` 转 ms 做窗口过滤)
35
- - `src/core/storage/sqlite.ts` — facade 转发 7 个方法
36
- - `src/core/storage/schema.sql` 末尾 + `src/core/storage/base.ts` runMigrations — `idx_routing_events_type_ts ON routing_events(routed_to_type, ts DESC)`
37
-
38
- ### Route 改造点
39
- - `src/web/routes/rules.ts` — `queryRoutingEvents{limit:100000}` + `querySkillInvocations{limit:100000}` JS reduce → `aggregateRoutingStats` + `aggregateSkillInvocationsBySkill`
40
- - `src/web/routes/skill-stats.ts:16` — `/distribution`:`agg.by_type` + 三桶兜底
41
- - `src/web/routes/skill-stats.ts:33` — `/frequency`:`agg.by_skill_routed.map(...)`
42
- - `src/web/routes/skill-stats.ts:43` — `/trend`:`aggregateRoutingTrendByDay` + JS skillRate 计算
43
- - `src/web/routes/skill-stats.ts:59` — `/invocations`:`aggregateSkillInvocationsBySkill`,`total` 改为 sum 行 total
44
- - `src/web/routes/skill-stats.ts:76` — `/api/routing/stats`:`agg.obeyed/total/by_agent`
45
- - `src/web/routes/tasks.ts:59` — `/:taskId`:`getTask` + `queryEventsByTaskId` + `queryInjectionsByTaskId` + `querySkillInvocationsByTaskWindow` 取代旧四段全表扫
46
-
47
- ## 测试结果
48
-
49
- | 维度 | 数值 |
50
- |------|------|
51
- | storage + web unit | 171 通过 / 1 失败(pre-existing) |
52
- | 全量 `npm test` | **417 通过 / 1 失败 / 418 总** |
53
- | `npx tsc --noEmit` | **0 errors** |
54
-
55
- ### Pre-existing failure(与 H1 无关,main 分支既有)
56
- - `tests/unit/storage/sqlite-refactor-harness.test.ts > Task Operations > linkEventToTask associates events with tasks`
57
- - 报错:`Invalid event data: ... event_id Invalid uuid`
58
- - 原因:测试中传入的 `event_id` 不是 UUID 格式,与 `events.ts:73` 的 zod 校验不兼容
59
- - 在 main 分支同样 fail,**未在本次任务范围**,未修
60
-
61
- ## 超出 spec 的改动
62
-
63
- 无。所有改动均严格按 spec 第 3 节执行。响应字段结构未变更(前端 React 组件契约保持):
64
- - `/distribution` → `{ windowHours, distribution: [{type, count}] }` ✓
65
- - `/frequency` → `{ windowHours, frequency: [{name, count}] }` ✓
66
- - `/trend` → `{ windowHours, trend: [{day, skillRate}] }` ✓
67
- - `/invocations` → `{ days, total, invocations: [{skill_id, total, success, failed}] }` ✓
68
- - `/api/routing/stats` → `{ days, total, agentCalls, noAgent, agentRate, byAgent }` ✓
69
- - `/api/tasks/:taskId` → `{ task, userPrompts, injections, timeline, skillInvocations, artifacts }` ✓
70
-
71
- 注:`/invocations` 的 `total` 字段语义不变(旧实现是 `invocations.length` = 原始记录数;新实现是 `sum(rows.total)` = 同样的原始记录数,因 GROUP BY skill_id 后各 group total 之和等于总行数)。
72
-
73
- ## 已知问题
74
-
75
- - **Pre-existing**:`sqlite-refactor-harness.test.ts > linkEventToTask` — 与 H1 无关,main 分支同样失败。
76
- - 无其它已知问题。
77
-
78
- ## 回滚提示
79
-
80
- 纯增量改动。如需回滚:
81
- - revert `src/web/routes/{rules,skill-stats,tasks}.ts` 即可恢复旧行为
82
- - storage 新方法和索引保留无害(无人调用即无副作用)
@@ -1,61 +0,0 @@
1
- # H2 完整实施 Changelog
2
-
3
- **Date**: 2026-05-18
4
- **Spec**: `docs/design/h2-getdatabase-encapsulation-spec-20260518-1450.md`
5
- **Status**: 全 4 Phase 完成
6
- **Workflow**: refactor-safe(safety-net → 新方法 → 替换 → 收尾)
7
-
8
- ## 四阶段 commit 索引
9
-
10
- | Phase | Commit | 内容 |
11
- |---|---|---|
12
- | 1 | `0b494ed` | safety-net 17 test cases(web-stats / web-trace / stop-handler / web-analytics 增强) |
13
- | 2 | (上一 commit) | 20 个 Operations 新方法 + 44 个单测 + facade 转发 |
14
- | 3 | `bf3eb39` | 7 个调用方文件替换 db.prepare() → facade |
15
- | 4 | (本 commit) | getDatabase jsdoc 警告 + 总 changelog |
16
-
17
- ## 累计影响
18
-
19
- - **改动 13 个 src 文件,新增 12 个测试文件**
20
- - **消除 27 处越权 SQL 直写**(spec 调研时 25 处 + 主线程封闭性扫描补 cli/commands/trace.ts 3 处)
21
- - **新增 20 个 Operations 方法**:EventOperations × 11 + SessionOperations × 4 + TaskOperations × 1 + SkillOperations × 4
22
- - **新增 61 个测试用例**:safety-net 17 + Operations 单测 44
23
-
24
- ## 命名固化(H1 → H2 一致)
25
-
26
- - `aggregate*` 聚合(GROUP BY 类)
27
- - `count*` 计数
28
- - `query*` 列表查询
29
- - `get*` 单条查询
30
-
31
- ## 关键决策
32
-
33
- 1. **getDatabase 保留 public**(不改 protected):架构非继承关系,protected 收益小风险大;改用 jsdoc `@internal` 标注 + CLAUDE.md 工作流提醒
34
- 2. **SQL 行为零变更**:所有 SQL 直接搬入 Operations,不做"优化",保证 safety-net 测试零回归
35
- 3. **`LIKE '%error%'` 失败检测保留原 3 个 OR 条件**:与生产匹配
36
- 4. **Phase 2 偏差**:`aggregateToolUsage` 缺 `until` 参数 → Phase 3 改用 `queryEventsByTimeRange + 内存聚合` 兜底,保留 `[since, until)` 语义
37
-
38
- ## 测试结果(最终)
39
-
40
- - safety-net 集成测试:17/17 ✓
41
- - Operations 单测:44/44 ✓
42
- - 现有回归:541/542 通过
43
- - **唯一失败**:pre-existing `linkEventToTask` (Zod UUID 校验,与 H2 无关)
44
- - `npx tsc --noEmit`: 0 errors
45
-
46
- ## 残留 `db.prepare` 检查
47
-
48
- ```bash
49
- $ grep -rn "db\.prepare" src/web/ src/cli/commands/trace.ts src/daemon/handlers/ --include="*.ts" | grep -v ".test."
50
- src/web/routes/stats.ts:7: * H2 Phase 3: 替换原 db.prepare 直写 SQL 为 SQLiteStorage facade 聚合方法。
51
- src/web/routes/trace.ts:95: // H2 Phase 3: 改用 facade 聚合方法,消除 db.prepare 直写。
52
- src/daemon/handlers/stop.ts:151: // H2 Phase 3: 改用 facade 聚合方法,消除 db.prepare 直写。
53
- ```
54
-
55
- **3 处均为注释**,无 SQL 直写。
56
-
57
- ## 后续 follow-up
58
-
59
- - **可选**:补完 `aggregateToolUsage` 的 `until` 参数支持,weekly-report 改回单条 SQL
60
- - **可选**:ESLint 规则禁止 `web/routes/` `web/analytics/` `daemon/handlers/` import storage 后调用 `getDatabase()`
61
- - **不建议**:把 `getDatabase` 改 protected(架构非继承)
@@ -1,70 +0,0 @@
1
- # H2 Phase 1 safety-net Changelog
2
-
3
- **Date**: 2026-05-18 14:50
4
- **Spec**: docs/design/h2-getdatabase-encapsulation-spec-20260518-1450.md
5
- **Status**: Phase 1 完成(Phase 2-4 待后续)
6
-
7
- ## 完成清单
8
-
9
- - [x] web-stats 集成测试 (`tests/integration/web-stats.integration.test.ts`, 4 cases)
10
- - [x] web-trace 集成测试 (`tests/integration/web-trace.integration.test.ts`, 6 cases — 全分支覆盖)
11
- - [x] stop-handler-behavior-summary 单测 (`tests/unit/daemon/stop-handler-behavior-summary.test.ts`, 5 cases)
12
- - [x] web-analytics 集成测试增强 (+2 value-level cases)
13
-
14
- ## 关键代码定位
15
-
16
- | 测试文件 | 行号 | 内容 |
17
- |---|---|---|
18
- | `tests/integration/web-stats.integration.test.ts:38` | empty database 200 shape |
19
- | `tests/integration/web-stats.integration.test.ts:60` | totalEvents/totalSessions/toolUsage 聚合 |
20
- | `tests/integration/web-stats.integration.test.ts:83` | dailyActivity 字段形状 |
21
- | `tests/integration/web-stats.integration.test.ts:103` | skillInvocations 计数 |
22
- | `tests/integration/web-trace.integration.test.ts:84-118` | 4 个 4xx 错误分支 |
23
- | `tests/integration/web-trace.integration.test.ts:120-130` | 200 + 空 sessions[](无 git note)|
24
- | `tests/integration/web-trace.integration.test.ts:132-167` | 200 + 完整 session 详情(含 event_breakdown)|
25
- | `tests/unit/daemon/stop-handler-behavior-summary.test.ts:69` | 无事件时不附加 summary |
26
- | `tests/unit/daemon/stop-handler-behavior-summary.test.ts:82` | tool-only summary |
27
- | `tests/unit/daemon/stop-handler-behavior-summary.test.ts:110` | Agent 委托计数 + agent 名 |
28
- | `tests/unit/daemon/stop-handler-behavior-summary.test.ts:141` | skill 调用计数 |
29
- | `tests/unit/daemon/stop-handler-behavior-summary.test.ts:169` | session 隔离(不串扰)|
30
- | `tests/integration/web-analytics.integration.test.ts:92` | weekly report value 断言 |
31
- | `tests/integration/web-analytics.integration.test.ts:107` | insights summary.total = patterns.length |
32
-
33
- ## 测试结果
34
-
35
- - **新增/增强 safety-net 测试**: 17 passed (4 stats + 6 trace + 5 stop + 2 analytics 增强)
36
- - **跨 Phase 1 范围全量**:
37
- - `tests/integration/` + `tests/unit/daemon/`: 33 / 33 passed
38
- - **tsc**: 0 errors
39
- - **npm test 全量**: 497 / 498 passed (1 failed = pre-existing `linkEventToTask`)
40
-
41
- ## 实施决策
42
-
43
- 1. **trace 测试覆盖方案**:采用方案 A(tmp git repo)。在 `os.tmpdir()` 用 `execFileSync('git', ...)` 创建真实仓库 + 两次 commit + `git notes add`,覆盖:
44
- - 缺 `?project` query → 400
45
- - 相对路径 → 400
46
- - 非 git 目录 → 400
47
- - commit 不存在 → 404
48
- - HEAD 有 commit 但无 note → 200 + 空 sessions[]
49
- - 有 forge-session note + storage 有对应 events → 200 + 完整 session 详情(event_breakdown 等)
50
- - **覆盖度高于 spec 最低要求**(spec 只要求 commit 不存在 4xx + 无 note 空 sessions 两条),实际跑得快且稳定。
51
- 2. **stop-handler 测试路径调整**:spec 写 `src/tests/stop-handler-behavior-summary.test.ts`,但 `vitest.config.ts` 只包含 `tests/unit/**` 与 `tests/integration/**`。如放到 `src/tests/` 会被 collect 排除导致永远不跑。改放到 `tests/unit/daemon/stop-handler-behavior-summary.test.ts` 以确保实际生效,已在测试文件顶部 NOTE 注释中说明决策。
52
- 3. **`generateBehaviorSummary` 私有方法访问**:经由 `handle()` 入口 + mock `ResumeManager.save` 捕获最终 resume content 进行断言。比反射访问私有方法更接近生产实际路径,且更稳健。
53
- 4. **web-analytics 增强保守原则**:只加 2 个新 case(weekly value + insights consistency),不重写既有 shape 断言。所有原 case 仍保留并通过。
54
- 5. **fixture 时间戳策略**:weekly-report 按 ISO week 范围过滤事件,所以 fixture 用 `new Date().toISOString()`(当下时间)确保进入 `weekOffset: 0` 窗口;stats endpoint 用 `date('now', '-7 days')`,同样满足。
55
-
56
- ## 待 Phase 2 处理
57
-
58
- 下一步 Phase 2(新增 ~20 个 Operations 方法)的提示:
59
-
60
- - Phase 2 应在 `src/core/storage/{events,sessions,tasks,skills}.ts` 加方法,**不删旧 SQL**,并行存在。
61
- - Phase 2 同时增加 4 个新单测文件:`tests/unit/storage/{event,session,skill}-operations-aggregates.test.ts`(spec 表 116 行所列)。
62
- - Phase 3 才会替换调用方(每文件 1 commit),届时本 Phase 1 的 safety-net 会兜底回归。
63
- - Phase 4 给 `getDatabase()` 加 jsdoc `@internal` 警告。
64
- - 改造涉及 `daemon/handlers/stop.ts` 时,本次新加的 `stop-handler-behavior-summary.test.ts` 5 个 case 是关键回归依据。
65
- - trace 测试包含一次真实 `git init`,单测耗时 ~600ms,未来 Phase 2/3 增加新测试时不必再做 git 操作。
66
-
67
- ## 已知问题
68
-
69
- - **pre-existing 失败**:`SQLiteStorage - Characterization Tests (Pre-Refactor) > Task Operations > linkEventToTask associates events with tasks` —— Zod uuid 校验失败,与本 Phase 1 改动无关,按纪律不修。
70
- - **未覆盖**:`cli/commands/trace.ts` 3 段 SQL 暂无对应集成测试(spec 第 71 行已标注"可补")。Phase 2/3 替换 CLI trace 时可考虑加 CLI smoke test,或先依赖 web-trace 同模式断言间接保护。
@@ -1,120 +0,0 @@
1
- # H2 Phase 2 Operations 新方法 Changelog
2
-
3
- **Date**: 2026-05-18 14:50 (Phase 2)
4
- **Spec**: docs/design/h2-getdatabase-encapsulation-spec-20260518-1450.md
5
- **Status**: Phase 2 完成(Phase 3 待替换调用方)
6
-
7
- ## 完成清单
8
-
9
- - [x] EventOperations 11 方法(events.ts)
10
- - [x] SessionOperations 4 方法(sessions.ts)
11
- - [x] TaskOperations 1 方法(tasks.ts)
12
- - [x] SkillOperations 4 方法(skills.ts)
13
- - [x] sqlite.ts facade 转发(20 个方法)
14
- - [x] 4 文件单测(44 个 case 全过)
15
- - [x] tsc 通过 0 errors
16
- - [x] 旧 SQL 并行存在(Phase 3 才替换)
17
-
18
- ## 新增方法清单
19
-
20
- ### EventOperations(src/core/storage/events.ts:179-358)
21
-
22
- | 方法 | SQL 来源 |
23
- |---|---|
24
- | `countAllEvents()` | stats.ts:13 |
25
- | `aggregateToolUsage({ since?, limit?, hook_type? })` | stats.ts:17-21 + weekly-report.ts:214-222 |
26
- | `aggregateDailyEventCounts({ since, until? })` | stats.ts:28-33 |
27
- | `aggregateHookTypeBySession(session_id)` | trace.ts:106-109 + cli/trace.ts:115 |
28
- | `aggregateAgentTypeBySession(session_id)` | trace.ts:111-116 + cli/trace.ts:124 + stop.ts:163-168 |
29
- | `aggregateToolUsageBySession(session_id)` | stop.ts:154-158 |
30
- | `countActiveDays({ since, until? })` | drift-detector.ts:154-157 |
31
- | `aggregateOverviewByRange({ since, until })` | weekly-report.ts:100-109 |
32
- | `queryDistinctProjects({ since, until })` | weekly-report.ts:111-116 |
33
- | `aggregateToolFailureRate({ since, until })` | weekly-report.ts:228-244(保留 3 OR LIKE 分支) |
34
- | `queryFileEditInputs({ since, until, tool_names })` | weekly-report.ts:261-268(内部 IN 展开) |
35
- | `queryEventsByTimeRange({ since, until? })` | anti-pattern-detector.ts:83-86 |
36
-
37
- ### SessionOperations(src/core/storage/sessions.ts:107-178)
38
-
39
- | 方法 | SQL 来源 |
40
- |---|---|
41
- | `countAllSessions()` | stats.ts:14 |
42
- | `aggregateDailySessionCounts({ since, until? })` | stats.ts:35-40 |
43
- | `querySessionsByTimeRange({ since, until? })` | anti-pattern-detector.ts:104-114 |
44
- | `countSessionsByRange({ since, until? })` | drift-detector.ts:185-187 |
45
-
46
- ### TaskOperations(src/core/storage/tasks.ts:120-131)
47
-
48
- | 方法 | SQL 来源 |
49
- |---|---|
50
- | `countTasksByRange({ since, until? })` | drift-detector.ts:190-192 + weekly-report.ts:118-122 |
51
-
52
- ### SkillOperations(src/core/storage/skills.ts:203-232)
53
-
54
- | 方法 | SQL 来源 |
55
- |---|---|
56
- | `countAllSkillInvocations()` | stats.ts:50 |
57
- | `countSkillInvocationsBySession(session_id)` | stop.ts:176-178 |
58
- | `countDistinctSkillsSince(since_ms)` | drift-detector.ts:125-128 |
59
- | `queryDistinctSkillIdsBySession(session_id)` | trace.ts:118-120 + cli/trace.ts:135 |
60
-
61
- ### sqlite.ts facade(src/core/storage/sqlite.ts:94-160)
62
-
63
- 20 个方法签名严格按 spec,全部 `delegate to this.events / this.sessions / this.tasks / this.skills`。
64
-
65
- ## 关键代码定位
66
-
67
- - `src/core/storage/events.ts:179-358` — EventOperations 11 新方法
68
- - `src/core/storage/sessions.ts:107-178` — SessionOperations 4 新方法
69
- - `src/core/storage/tasks.ts:120-131` — TaskOperations countTasksByRange
70
- - `src/core/storage/skills.ts:203-232` — SkillOperations 4 新方法
71
- - `src/core/storage/sqlite.ts:94-160` — facade 转发段
72
-
73
- ## 测试结果
74
-
75
- - 新增单测: **44 passed / 44**
76
- - event-operations-aggregates.test.ts: 23 tests
77
- - session-operations-aggregates.test.ts: 9 tests
78
- - task-operations-counts.test.ts: 3 tests
79
- - skill-operations-counts.test.ts: 9 tests
80
- - 旧 storage 测试回归: 通过(除 pre-existing failure)
81
- - tsc: **0 errors**
82
- - npm test: **541 passed / 542**(仅 pre-existing `linkEventToTask` 失败)
83
-
84
- ## 实施决策
85
-
86
- 1. **LIKE '%error%' 失败检测保持原 SQL 三个 OR 分支**
87
- - `tool_output LIKE '%"error"%' OR LIKE '%"is_error":true%' OR LIKE '%"isError":true%'`
88
- - 测试覆盖三种 tool_output JSON 形态,确认全部命中
89
-
90
- 2. **时间区间统一 `[since, until)` 半开半闭语义**
91
- - 调用方负责 ISO 字符串构造(`new Date(since).toISOString()`)
92
- - until 一律 `<`(与 weekly-report.ts 原 `start_time < ?` 一致)
93
- - 与 stats.ts 原 `date('now', '-7 days')` 语义不同:新方法不再隐含 now(),调用方计算
94
-
95
- 3. **`queryFileEditInputs` 内部展开 placeholders**
96
- - tool_names 通过参数注入,避免外部拼 SQL
97
- - 空 list 直接返回空数组(避免 `IN ()` SQL 错误)
98
-
99
- 4. **`aggregateToolUsage` 合并 stats / weekly-report 两个用例**
100
- - 通过 `hook_type` 可选过滤 + `since` 可选过滤兼顾两种调用
101
- - `tool_name IS NOT NULL AND tool_name != ''` 始终生效(stats.ts 原行为)
102
-
103
- 5. **`aggregateAgentTypeBySession` 与 `aggregateToolUsageBySession` 分离**
104
- - 前者 `tool_name IN ('Agent','Task')` + json_extract subagent_type(stop.ts:163 / trace.ts:111)
105
- - 后者纯 `tool_name IS NOT NULL`(stop.ts:154)
106
- - 两段语义不同,分别封装
107
-
108
- ## 待 Phase 3 处理
109
-
110
- - 替换 src/web/routes/stats.ts(5 段 SQL)
111
- - 替换 src/web/routes/trace.ts(3 段 SQL)
112
- - 替换 src/cli/commands/trace.ts(3 段 SQL)
113
- - 替换 src/daemon/handlers/stop.ts:154-178(3 段 SQL)
114
- - 替换 src/web/analytics/drift-detector.ts(4 段 SQL)
115
- - 替换 src/web/analytics/weekly-report.ts(6 段 SQL)
116
- - 替换 src/web/analytics/anti-pattern-detector.ts(2 段 SQL)
117
-
118
- ## 已知问题
119
-
120
- - `tests/unit/storage/sqlite-refactor-harness.test.ts > linkEventToTask` pre-existing 失败(与 Phase 2 改动无关,event_id 未传 UUID 导致 zod schema 拒收)