@winspan/claude-forge 8.53.2 → 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 (390) 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 +7 -3
  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/storage/events.d.ts.map +1 -1
  11. package/dist/core/storage/events.js +0 -1
  12. package/dist/core/storage/events.js.map +1 -1
  13. package/dist/core/storage/maintenance.d.ts +25 -3
  14. package/dist/core/storage/maintenance.d.ts.map +1 -1
  15. package/dist/core/storage/maintenance.js +33 -4
  16. package/dist/core/storage/maintenance.js.map +1 -1
  17. package/dist/core/storage/routing.d.ts +4 -0
  18. package/dist/core/storage/routing.d.ts.map +1 -1
  19. package/dist/core/storage/routing.js +10 -4
  20. package/dist/core/storage/routing.js.map +1 -1
  21. package/dist/core/storage/sessions.d.ts +17 -0
  22. package/dist/core/storage/sessions.d.ts.map +1 -1
  23. package/dist/core/storage/sessions.js +64 -0
  24. package/dist/core/storage/sessions.js.map +1 -1
  25. package/dist/core/storage/skills.d.ts +4 -0
  26. package/dist/core/storage/skills.d.ts.map +1 -1
  27. package/dist/core/storage/skills.js +10 -2
  28. package/dist/core/storage/skills.js.map +1 -1
  29. package/dist/core/storage/sqlite.d.ts +5 -0
  30. package/dist/core/storage/sqlite.d.ts.map +1 -1
  31. package/dist/core/storage/sqlite.js +6 -0
  32. package/dist/core/storage/sqlite.js.map +1 -1
  33. package/dist/core/storage/tasks.d.ts.map +1 -1
  34. package/dist/core/storage/tasks.js +2 -0
  35. package/dist/core/storage/tasks.js.map +1 -1
  36. package/dist/core/types.d.ts +7 -0
  37. package/dist/core/types.d.ts.map +1 -1
  38. package/dist/daemon/index.d.ts.map +1 -1
  39. package/dist/daemon/index.js +19 -4
  40. package/dist/daemon/index.js.map +1 -1
  41. package/dist/skills/registry.d.ts.map +1 -1
  42. package/dist/skills/registry.js +13 -2
  43. package/dist/skills/registry.js.map +1 -1
  44. package/dist/skills/semantic-matcher.d.ts +2 -2
  45. package/dist/skills/semantic-matcher.d.ts.map +1 -1
  46. package/dist/skills/semantic-matcher.js +14 -19
  47. package/dist/skills/semantic-matcher.js.map +1 -1
  48. package/dist/skills/upgrade-engine.d.ts +3 -1
  49. package/dist/skills/upgrade-engine.d.ts.map +1 -1
  50. package/dist/skills/upgrade-engine.js +25 -14
  51. package/dist/skills/upgrade-engine.js.map +1 -1
  52. package/dist/web/analytics/weekly-report.d.ts.map +1 -1
  53. package/dist/web/analytics/weekly-report.js +21 -29
  54. package/dist/web/analytics/weekly-report.js.map +1 -1
  55. package/dist/web/routes/patch.d.ts.map +1 -1
  56. package/dist/web/routes/patch.js +32 -2
  57. package/dist/web/routes/patch.js.map +1 -1
  58. package/dist/web/routes/sessions.d.ts.map +1 -1
  59. package/dist/web/routes/sessions.js +9 -7
  60. package/dist/web/routes/sessions.js.map +1 -1
  61. package/dist/web/routes/trace.d.ts.map +1 -1
  62. package/dist/web/routes/trace.js +2 -3
  63. package/dist/web/routes/trace.js.map +1 -1
  64. package/dist/web/server.d.ts.map +1 -1
  65. package/dist/web/server.js +3 -2
  66. package/dist/web/server.js.map +1 -1
  67. package/package.json +12 -2
  68. package/scripts/postinstall.cjs +21 -0
  69. package/.claude/CLAUDE.md +0 -17
  70. package/.eslintrc.js +0 -23
  71. package/.prettierrc +0 -8
  72. package/ARCHITECTURE_ISSUES.md +0 -249
  73. package/CLAUDE.md +0 -265
  74. package/CLAUDE.md.backup +0 -488
  75. package/docs/concurrent-agents.md +0 -129
  76. package/docs/design/architecture-review-20260516.md +0 -232
  77. package/docs/design/fix-skills-data-and-set-leak-spec-20260516-1300.md +0 -219
  78. package/docs/design/h1-storage-aggregation-spec-20260518-1121.md +0 -299
  79. package/docs/design/h2-getdatabase-encapsulation-spec-20260518-1450.md +0 -191
  80. package/docs/design/h3-fallback-removal-spec-20260518-1245.md +0 -76
  81. package/docs/design/h4-index-dedup-spec-20260518-1230.md +0 -109
  82. package/docs/design/h6-services-migration-spec-20260518-1355.md +0 -82
  83. package/docs/design/hook-failure-queue-spec-20260516-1530.md +0 -204
  84. package/docs/design/l1-swarm-protocol-extract-spec-20260518-1605.md +0 -106
  85. package/docs/design/m10-forge-paths-spec-20260518-1320.md +0 -121
  86. package/docs/design/m2-m3-tool-input-spec-20260518-1425.md +0 -131
  87. package/docs/design/m7-routing-event-association-spec-20260518-1545.md +0 -103
  88. package/docs/design/project-path-gitroot-spec-20260518-1715.md +0 -134
  89. package/docs/design/refactor-phase1-spec-20260515-1600.md +0 -543
  90. package/docs/design/refactor-phase2-spec-20260515-1700.md +0 -424
  91. package/docs/design/skill-ai-upgrade-spec-20260518-1930.md +0 -297
  92. package/docs/design/task-active-gc-spec-20260518-1745.md +0 -146
  93. package/docs/design/tasks-list-filter-pagination-spec-20260518-0930.md +0 -208
  94. package/docs/implementation/daemon-skill-sync-changelog-20260518-2000.md +0 -22
  95. package/docs/implementation/fix-skills-data-and-set-leak-changelog-20260516-1300.md +0 -104
  96. package/docs/implementation/h1-storage-aggregation-changelog-20260518-1121.md +0 -82
  97. package/docs/implementation/h2-final-changelog-20260518-1530.md +0 -61
  98. package/docs/implementation/h2-phase1-safety-net-changelog-20260518-1450.md +0 -70
  99. package/docs/implementation/h2-phase2-operations-changelog-20260518-1450.md +0 -120
  100. package/docs/implementation/h2-phase3-callsites-changelog-20260518-1450.md +0 -71
  101. package/docs/implementation/h3-fallback-removal-changelog-20260518-1245.md +0 -71
  102. package/docs/implementation/h4-index-dedup-changelog-20260518-1230.md +0 -60
  103. package/docs/implementation/h6-services-migration-changelog-20260518-1355.md +0 -46
  104. package/docs/implementation/h7-m9-defaults-changelog-20260518-1300.md +0 -46
  105. package/docs/implementation/hook-failure-queue-changelog-20260516-1530.md +0 -196
  106. package/docs/implementation/hotfix-daemon-event-reject-20260516-1430.md +0 -56
  107. package/docs/implementation/l1-swarm-protocol-extract-changelog-20260518-1605.md +0 -45
  108. package/docs/implementation/l3-l4-daemon-perf-changelog-20260518-1410.md +0 -63
  109. package/docs/implementation/l6-l8-final-cleanup-changelog-20260518-1640.md +0 -38
  110. package/docs/implementation/m1-m4-m5-l7-cleanup-changelog-20260518-1310.md +0 -58
  111. package/docs/implementation/m10-forge-paths-changelog-20260518-1320.md +0 -60
  112. package/docs/implementation/m2-m3-tool-input-changelog-20260518-1425.md +0 -43
  113. package/docs/implementation/m6-m8-naming-shutdown-changelog-20260518-1340.md +0 -56
  114. package/docs/implementation/m7-routing-association-changelog-20260518-1545.md +0 -69
  115. package/docs/implementation/project-path-gitroot-changelog-20260518-1715.md +0 -63
  116. package/docs/implementation/refactor-phase1-changelog-20260515-1630.md +0 -354
  117. package/docs/implementation/refactor-phase2-changelog-20260515-1705.md +0 -421
  118. package/docs/implementation/skill-ai-upgrade-changelog-20260518-1930.md +0 -49
  119. package/docs/implementation/task-active-gc-changelog-20260518-1745.md +0 -35
  120. package/docs/implementation/task-title-summary-changelog-20260518-1130.md +0 -39
  121. package/docs/implementation/tasks-detail-back-loses-filters-changelog-20260518-1100.md +0 -22
  122. package/docs/implementation/tasks-list-filter-pagination-changelog-20260518-0930.md +0 -72
  123. package/docs/implementation/tasks-page-white-screen-hotfix-changelog-20260518-1015.md +0 -56
  124. package/docs/reviews/claudemd-template-sync.md +0 -54
  125. package/docs/reviews/task-title-summary.md +0 -92
  126. package/docs/reviews/tasks-detail-back-loses-filters.md +0 -58
  127. package/docs/reviews/tasks-filter-pagination.md +0 -80
  128. package/docs/reviews/tasks-page-white-screen-hotfix.md +0 -126
  129. package/docs/ruflo-learning-strategy.md +0 -322
  130. package/docs/skills-deduplication-analysis.md +0 -83
  131. package/docs/skills-multiformat-support.md +0 -177
  132. package/docs/skills-third-party.md +0 -183
  133. package/docs/testing/tasks-filter-pagination-test-report.md +0 -86
  134. package/forge +0 -321
  135. package/playwright.config.ts +0 -40
  136. package/scripts/demo-v2.ts +0 -91
  137. package/scripts/dev-daemon.sh +0 -232
  138. package/scripts/dev-web.ts +0 -109
  139. package/scripts/e2e-mcp-link.ts +0 -423
  140. package/scripts/e2e-methodology-quality.ts +0 -253
  141. package/scripts/e2e-routing.ts +0 -456
  142. package/scripts/e2e-user-methodology.ts +0 -326
  143. package/scripts/e2e-web-workflows.ts +0 -299
  144. package/scripts/migrate-legacy-to-dynamic.sql +0 -108
  145. package/scripts/regenerate-execution-docs.ts +0 -116
  146. package/scripts/sync-agent-skills.ts +0 -193
  147. package/scripts/test-hook.sh +0 -71
  148. package/scripts/verify-skill-loading.ts +0 -62
  149. package/src/claudemd/claudemd-generator.ts +0 -568
  150. package/src/claudemd/convention-extractor.ts +0 -69
  151. package/src/claudemd/index.ts +0 -35
  152. package/src/claudemd/persona-manager.ts +0 -88
  153. package/src/claudemd/resume-manager.ts +0 -236
  154. package/src/claudemd/tech-detector.ts +0 -220
  155. package/src/claudemd/templates/swarm-protocol.md +0 -222
  156. package/src/cli/commands/claudemd.ts +0 -84
  157. package/src/cli/commands/config.ts +0 -46
  158. package/src/cli/commands/daemon.ts +0 -310
  159. package/src/cli/commands/executions.ts +0 -115
  160. package/src/cli/commands/init.ts +0 -204
  161. package/src/cli/commands/logs.ts +0 -181
  162. package/src/cli/commands/mcp.ts +0 -242
  163. package/src/cli/commands/menu.ts +0 -357
  164. package/src/cli/commands/skills.ts +0 -328
  165. package/src/cli/commands/stats.ts +0 -73
  166. package/src/cli/commands/status.ts +0 -69
  167. package/src/cli/commands/template.ts +0 -77
  168. package/src/cli/commands/trace.ts +0 -148
  169. package/src/cli/index.ts +0 -42
  170. package/src/cli/init/hook-manager.ts +0 -132
  171. package/src/core/ai/provider.ts +0 -308
  172. package/src/core/ai/types.ts +0 -51
  173. package/src/core/config.ts +0 -124
  174. package/src/core/constants.ts +0 -67
  175. package/src/core/event-fields.ts +0 -32
  176. package/src/core/queue/index.ts +0 -192
  177. package/src/core/storage/base.ts +0 -302
  178. package/src/core/storage/events.ts +0 -434
  179. package/src/core/storage/injections.ts +0 -78
  180. package/src/core/storage/maintenance.ts +0 -59
  181. package/src/core/storage/migrations/002_add_skill_tracking.sql +0 -6
  182. package/src/core/storage/migrations/003_add_skill_invocations.sql +0 -23
  183. package/src/core/storage/performance-indexes.sql +0 -23
  184. package/src/core/storage/routing.ts +0 -322
  185. package/src/core/storage/rows.ts +0 -112
  186. package/src/core/storage/schema.sql +0 -224
  187. package/src/core/storage/sessions.ts +0 -168
  188. package/src/core/storage/skills.ts +0 -233
  189. package/src/core/storage/sqlite.ts +0 -293
  190. package/src/core/storage/tasks.ts +0 -318
  191. package/src/core/storage/token-usage.ts +0 -93
  192. package/src/core/types.ts +0 -181
  193. package/src/core/utils/error-handler.ts +0 -257
  194. package/src/core/utils/forge-resume-block.ts +0 -74
  195. package/src/core/utils/format.ts +0 -69
  196. package/src/core/utils/git.ts +0 -23
  197. package/src/core/utils/logger.ts +0 -134
  198. package/src/core/utils/lru-cache.ts +0 -54
  199. package/src/core/utils/path.ts +0 -19
  200. package/src/core/utils/session.ts +0 -26
  201. package/src/core/utils/time.ts +0 -37
  202. package/src/core/utils/token-tracker.ts +0 -97
  203. package/src/daemon/event-parser.ts +0 -36
  204. package/src/daemon/handlers/history-exporter.ts +0 -117
  205. package/src/daemon/handlers/post-tool-use.ts +0 -54
  206. package/src/daemon/handlers/stop.ts +0 -208
  207. package/src/daemon/handlers/user-prompt.ts +0 -178
  208. package/src/daemon/hook-sync.ts +0 -91
  209. package/src/daemon/index.ts +0 -312
  210. package/src/daemon/launchd/com.claude-forge.daemon.plist.template +0 -47
  211. package/src/daemon/launchd-installer.ts +0 -260
  212. package/src/daemon/lifecycle.ts +0 -128
  213. package/src/daemon/router.ts +0 -40
  214. package/src/daemon/server.ts +0 -196
  215. package/src/daemon/services/task-segmenter.ts +0 -112
  216. package/src/daemon/skill-sync.ts +0 -88
  217. package/src/hooks/hook-lib.sh +0 -118
  218. package/src/hooks/notification.sh +0 -35
  219. package/src/hooks/post-tool-use.sh +0 -61
  220. package/src/hooks/pre-tool-use.sh +0 -63
  221. package/src/hooks/stop.sh +0 -43
  222. package/src/hooks/user-prompt-submit.sh +0 -69
  223. package/src/mcp/server.ts +0 -322
  224. package/src/skills/index.ts +0 -2
  225. package/src/skills/invocation-guard.ts +0 -177
  226. package/src/skills/matcher.ts +0 -148
  227. package/src/skills/official/code-simplifier.md +0 -52
  228. package/src/skills/official/find-skills.md +0 -142
  229. package/src/skills/official/official-api-design.md +0 -30
  230. package/src/skills/official/official-architecture-decision.md +0 -41
  231. package/src/skills/official/official-bmad.md +0 -118
  232. package/src/skills/official/official-db-schema-design.md +0 -34
  233. package/src/skills/official/official-debug.md +0 -25
  234. package/src/skills/official/official-doc-driven.md +0 -31
  235. package/src/skills/official/official-harness-engineering.md +0 -108
  236. package/src/skills/official/official-performance-optimization.md +0 -30
  237. package/src/skills/official/official-pr-review.md +0 -35
  238. package/src/skills/official/official-release-checklist.md +0 -30
  239. package/src/skills/official/official-security-hardening.md +0 -32
  240. package/src/skills/official/official-spec-driven-design.md +0 -31
  241. package/src/skills/official/planning-with-files.md +0 -241
  242. package/src/skills/official/ui-ux-pro-max.md +0 -105
  243. package/src/skills/official/webapp-testing.md +0 -96
  244. package/src/skills/official-skills.ts +0 -89
  245. package/src/skills/registry.ts +0 -355
  246. package/src/skills/semantic-matcher.ts +0 -234
  247. package/src/skills/tools/pipeline-suggest.ts +0 -226
  248. package/src/skills/tools/skill-invoke.ts +0 -168
  249. package/src/skills/tools/skill-list.ts +0 -59
  250. package/src/skills/upgrade-engine.ts +0 -541
  251. package/src/skills/upgrade-prompt.ts +0 -84
  252. package/src/templates/go.yaml +0 -53
  253. package/src/templates/python.yaml +0 -59
  254. package/src/templates/react.yaml +0 -55
  255. package/src/templates/template-manager.ts +0 -170
  256. package/src/web/analytics/anti-pattern-detector.ts +0 -367
  257. package/src/web/analytics/drift-detector.ts +0 -219
  258. package/src/web/analytics/weekly-report.ts +0 -431
  259. package/src/web/auth-middleware.ts +0 -54
  260. package/src/web/routes/_helpers.ts +0 -34
  261. package/src/web/routes/ai.ts +0 -204
  262. package/src/web/routes/auth.ts +0 -22
  263. package/src/web/routes/drift.ts +0 -25
  264. package/src/web/routes/error-handler.ts +0 -120
  265. package/src/web/routes/events.ts +0 -47
  266. package/src/web/routes/insights.ts +0 -43
  267. package/src/web/routes/patch.ts +0 -117
  268. package/src/web/routes/reports.ts +0 -34
  269. package/src/web/routes/rules.ts +0 -76
  270. package/src/web/routes/sessions.ts +0 -250
  271. package/src/web/routes/skill-stats.ts +0 -92
  272. package/src/web/routes/skills.ts +0 -350
  273. package/src/web/routes/static.ts +0 -67
  274. package/src/web/routes/stats.ts +0 -50
  275. package/src/web/routes/status.ts +0 -30
  276. package/src/web/routes/tasks.ts +0 -193
  277. package/src/web/routes/token-usage.ts +0 -20
  278. package/src/web/routes/trace.ts +0 -126
  279. package/src/web/routes/types.ts +0 -57
  280. package/src/web/server.ts +0 -134
  281. package/src/web/ssrf-guard.ts +0 -112
  282. package/src/web/static/index.html +0 -3251
  283. package/src/web/static/vendor/chart.umd.min.js +0 -20
  284. package/tests/e2e/dashboard.spec.ts +0 -205
  285. package/tests/e2e/routing-skill-e2e.test.ts +0 -39
  286. package/tests/helpers/mock-ai.ts +0 -92
  287. package/tests/helpers/mock-storage.ts +0 -159
  288. package/tests/integration/claudemd-generator.test.ts +0 -90
  289. package/tests/integration/queue-replay.integration.test.ts +0 -193
  290. package/tests/integration/tasks-filter.integration.test.ts +0 -154
  291. package/tests/integration/web-analytics.integration.test.ts +0 -133
  292. package/tests/integration/web-stats.integration.test.ts +0 -135
  293. package/tests/integration/web-trace.integration.test.ts +0 -175
  294. package/tests/performance/database.benchmark.ts +0 -161
  295. package/tests/semantic-matcher.test.ts +0 -99
  296. package/tests/skill-matcher.test.ts +0 -110
  297. package/tests/unit/ai-provider-retry.test.ts +0 -194
  298. package/tests/unit/ai-provider-vision.test.ts +0 -224
  299. package/tests/unit/claudemd-generator.test.ts +0 -68
  300. package/tests/unit/cli-mcp.test.ts +0 -141
  301. package/tests/unit/core/forge-paths.test.ts +0 -99
  302. package/tests/unit/daemon/hook-sync.test.ts +0 -71
  303. package/tests/unit/daemon/post-tool-use.test.ts +0 -121
  304. package/tests/unit/daemon/skill-sync.test.ts +0 -75
  305. package/tests/unit/daemon/stop-handler-behavior-summary.test.ts +0 -202
  306. package/tests/unit/daemon/task-segmenter-recover.test.ts +0 -84
  307. package/tests/unit/event-fields.test.ts +0 -88
  308. package/tests/unit/event-parser.test.ts +0 -55
  309. package/tests/unit/handlers.test.ts +0 -171
  310. package/tests/unit/hooks/resolve-project-path.test.ts +0 -122
  311. package/tests/unit/invocation-guard.test.ts +0 -125
  312. package/tests/unit/queue.test.ts +0 -272
  313. package/tests/unit/router.test.ts +0 -138
  314. package/tests/unit/security.test.ts +0 -128
  315. package/tests/unit/skill-invocations-workflow.test.ts +0 -495
  316. package/tests/unit/skill-registry.test.ts +0 -94
  317. package/tests/unit/skills/invocation-guard-ttl.test.ts +0 -211
  318. package/tests/unit/skills/official-skills-loader.test.ts +0 -126
  319. package/tests/unit/skills/registry-multiformat.test.ts +0 -92
  320. package/tests/unit/skills/upgrade-engine-parse.test.ts +0 -138
  321. package/tests/unit/skills/upgrade-engine.test.ts +0 -401
  322. package/tests/unit/skills/upgrade-prompt.test.ts +0 -89
  323. package/tests/unit/socket-server.test.ts +0 -183
  324. package/tests/unit/storage/event-operations-aggregates.test.ts +0 -342
  325. package/tests/unit/storage/migration-idempotent.test.ts +0 -304
  326. package/tests/unit/storage/routing-aggregates.test.ts +0 -276
  327. package/tests/unit/storage/routing.test.ts +0 -117
  328. package/tests/unit/storage/schema-missing.test.ts +0 -81
  329. package/tests/unit/storage/session-operations-aggregates.test.ts +0 -120
  330. package/tests/unit/storage/sessions-aggregate.test.ts +0 -435
  331. package/tests/unit/storage/skill-operations-counts.test.ts +0 -106
  332. package/tests/unit/storage/skills-aggregates.test.ts +0 -104
  333. package/tests/unit/storage/sqlite-refactor-harness.test.ts +0 -314
  334. package/tests/unit/storage/task-operations-counts.test.ts +0 -46
  335. package/tests/unit/storage/tasks-getById.test.ts +0 -343
  336. package/tests/unit/storage/tasks-stale-gc.test.ts +0 -86
  337. package/tests/unit/storage.test.ts +0 -172
  338. package/tests/unit/token-usage.test.ts +0 -144
  339. package/tests/unit/type-guards.test.ts +0 -201
  340. package/tests/unit/utils/format.test.ts +0 -189
  341. package/tests/unit/utils/session.test.ts +0 -89
  342. package/tests/unit/utils/time.test.ts +0 -112
  343. package/tests/unit/web/navigation-back-contract.test.ts +0 -134
  344. package/tests/unit/web/routes-auth.test.ts +0 -93
  345. package/tests/unit/web/routes-events.test.ts +0 -101
  346. package/tests/unit/web/routes-rules.test.ts +0 -182
  347. package/tests/unit/web/routes-sessions.test.ts +0 -181
  348. package/tests/unit/web/routes-skill-stats.test.ts +0 -179
  349. package/tests/unit/web/routes-stats.test.ts +0 -92
  350. package/tests/unit/web/routes-tasks.test.ts +0 -385
  351. package/tests/unit/web/task-title-contract.test.ts +0 -210
  352. package/tests/unit/web/tasks-component-contract.test.ts +0 -179
  353. package/tsconfig.json +0 -22
  354. package/vitest.config.ts +0 -21
  355. package/vitest.integration.config.ts +0 -16
  356. package/web/CLAUDE.md +0 -20
  357. package/web/index.html +0 -13
  358. package/web/package-lock.json +0 -4854
  359. package/web/package.json +0 -35
  360. package/web/postcss.config.js +0 -6
  361. package/web/src/App.tsx +0 -110
  362. package/web/src/components/CodeBlock.tsx +0 -31
  363. package/web/src/components/Confirm.tsx +0 -96
  364. package/web/src/components/Drawer.tsx +0 -60
  365. package/web/src/components/Layout.tsx +0 -145
  366. package/web/src/components/MarkdownRenderer.tsx +0 -77
  367. package/web/src/components/SearchInput.tsx +0 -31
  368. package/web/src/components/SessionDetailContent.tsx +0 -157
  369. package/web/src/components/Toast.tsx +0 -92
  370. package/web/src/index.css +0 -19
  371. package/web/src/main.tsx +0 -31
  372. package/web/src/pages/AIConfig.tsx +0 -233
  373. package/web/src/pages/Dashboard.tsx +0 -572
  374. package/web/src/pages/Events.tsx +0 -271
  375. package/web/src/pages/Reports.tsx +0 -428
  376. package/web/src/pages/SessionDetail.tsx +0 -162
  377. package/web/src/pages/Sessions.tsx +0 -205
  378. package/web/src/pages/Skills.tsx +0 -180
  379. package/web/src/pages/TaskDetail.tsx +0 -515
  380. package/web/src/pages/Tasks.tsx +0 -415
  381. package/web/src/utils/auth.ts +0 -59
  382. package/web/src/utils/export.ts +0 -54
  383. package/web/src/utils/navigation.ts +0 -25
  384. package/web/src/utils/task-title.ts +0 -49
  385. package/web/src/utils/time.ts +0 -13
  386. package/web/tailwind.config.js +0 -11
  387. package/web/tsconfig.json +0 -21
  388. package/web/tsconfig.node.json +0 -10
  389. package/web/vite.config.ts +0 -76
  390. package/winspan-claude-forge-8.43.0.tgz +0 -0
@@ -1,350 +0,0 @@
1
- import type { Application } from 'express';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { homedir } from 'os';
5
- import { logger } from '../../core/utils/logger.js';
6
- import type { RouteContext } from './types.js';
7
- import { FORGE_PATHS } from '../../core/constants.js';
8
-
9
- /**
10
- * /api/skills/* — list, read, update, version, rollback.
11
- *
12
- * Supports both flat `<name>.md` and directory-style `<name>/SKILL.md` layouts.
13
- * Prefers the registry when available so built-in skills resolve correctly.
14
- */
15
- export function registerSkillsRoutes(app: Application, ctx: RouteContext): void {
16
- const skillRegistry = ctx.skillRegistry;
17
-
18
- // GET /api/skills — list all skills (official + user; supports flat & directory formats)
19
- app.get('/api/skills', (_req, res) => {
20
- try {
21
- if (skillRegistry) {
22
- // Preferred path: reuse SkillRegistry (handles flat .md and <name>/SKILL.md)
23
- const skills = skillRegistry.getAll().map(s => ({
24
- name: s.name,
25
- id: s.id,
26
- description: s.description ?? '',
27
- keywords: s.keywords,
28
- path: s.path,
29
- isOfficial: s.isOfficial === true,
30
- source: s.isOfficial ? 'official' : 'user',
31
- }));
32
- res.json({ skills });
33
- return;
34
- }
35
-
36
- // Fallback: scan directly if registry not injected
37
- const skillsDir = path.join(homedir(), '.claude', 'skills');
38
- const skills: Array<{
39
- name: string;
40
- id: string;
41
- description: string;
42
- keywords: string[];
43
- path: string;
44
- isOfficial: boolean;
45
- source: 'official' | 'user';
46
- }> = [];
47
-
48
- if (fs.existsSync(skillsDir)) {
49
- const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
50
- for (const entry of entries) {
51
- let filePath: string | null = null;
52
- let id: string;
53
-
54
- if (entry.isFile() && entry.name.endsWith('.md')) {
55
- filePath = path.join(skillsDir, entry.name);
56
- id = entry.name.replace(/\.md$/, '');
57
- } else if (entry.isDirectory() || entry.isSymbolicLink()) {
58
- const skillMd = path.join(skillsDir, entry.name, 'SKILL.md');
59
- if (!fs.existsSync(skillMd)) continue;
60
- filePath = skillMd;
61
- id = entry.name;
62
- } else {
63
- continue;
64
- }
65
-
66
- try {
67
- const content = fs.readFileSync(filePath, 'utf-8');
68
- const match = content.match(/^---\n([\s\S]*?)\n---/);
69
- let description = '';
70
- const keywords: string[] = [];
71
- if (match) {
72
- const fm = match[1];
73
- const descMatch = fm.match(/description:\s*["']?([^"'\n]+)["']?/);
74
- description = descMatch?.[1]?.trim() || '';
75
- }
76
- skills.push({
77
- name: id,
78
- id,
79
- description,
80
- keywords,
81
- path: filePath,
82
- isOfficial: false,
83
- source: 'user',
84
- });
85
- } catch (err) {
86
- logger.warn(`[Web] Failed to read skill ${id}: ${err}`);
87
- }
88
- }
89
- }
90
-
91
- res.json({ skills });
92
- } catch (err) {
93
- logger.warn(`[Web] Failed to list skills: ${err}`);
94
- res.status(500).json({ error: String(err) });
95
- }
96
- });
97
-
98
- // GET /api/skills/:name — get skill details (supports flat & directory formats)
99
- app.get('/api/skills/:name', (req, res) => {
100
- try {
101
- const { name } = req.params;
102
-
103
- // Security: prevent path traversal attacks
104
- if (!name || name.includes('/') || name.includes('\\') || name.includes('..')) {
105
- res.status(400).json({ error: 'Invalid skill name' });
106
- return;
107
- }
108
-
109
- if (skillRegistry) {
110
- const skill = skillRegistry.getAll().find(s => s.id === name || s.name === name);
111
- if (skill) {
112
- if (skill.path === '<built-in>') {
113
- res.json({
114
- name: skill.name,
115
- id: skill.id,
116
- description: skill.description ?? '',
117
- keywords: skill.keywords,
118
- isOfficial: true,
119
- source: 'official',
120
- content: skill.content,
121
- });
122
- return;
123
- }
124
- // For user skills, fall through to disk read so edits show latest content
125
- if (fs.existsSync(skill.path)) {
126
- const content = fs.readFileSync(skill.path, 'utf-8');
127
- res.json({
128
- name: skill.name,
129
- id: skill.id,
130
- description: skill.description ?? '',
131
- keywords: skill.keywords,
132
- isOfficial: false,
133
- source: 'user',
134
- path: skill.path,
135
- content,
136
- });
137
- return;
138
- }
139
- }
140
- }
141
-
142
- // Fallback: try flat .md then <name>/SKILL.md
143
- const skillsDir = path.join(homedir(), '.claude', 'skills');
144
- const flatPath = path.join(skillsDir, `${name}.md`);
145
- const dirPath = path.join(skillsDir, name, 'SKILL.md');
146
- const filePath = fs.existsSync(flatPath)
147
- ? flatPath
148
- : fs.existsSync(dirPath)
149
- ? dirPath
150
- : null;
151
-
152
- if (!filePath) {
153
- res.status(404).json({ error: 'Skill not found' });
154
- return;
155
- }
156
-
157
- const content = fs.readFileSync(filePath, 'utf-8');
158
- const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
159
- if (!match) {
160
- res.json({ name, id: name, content, path: filePath });
161
- return;
162
- }
163
-
164
- const fm = match[1];
165
- const descMatch = fm.match(/description:\s*["']?([^"'\n]+)["']?/);
166
- const verMatch = fm.match(/version:\s*["']?([^"'\n]+)["']?/);
167
- const sourceMatch = fm.match(/source:\s*["']?([^"'\n]+)["']?/);
168
-
169
- res.json({
170
- name,
171
- id: name,
172
- description: descMatch?.[1]?.trim() || '',
173
- version: verMatch?.[1],
174
- source: sourceMatch?.[1] || 'user',
175
- path: filePath,
176
- content,
177
- });
178
- } catch (err) {
179
- logger.warn(`[Web] Failed to get skill ${req.params.name}: ${err}`);
180
- res.status(500).json({ error: String(err) });
181
- }
182
- });
183
-
184
- // PUT /api/skills/:name — update skill content
185
- app.put('/api/skills/:name', (req, res) => {
186
- try {
187
- const { name } = req.params;
188
- const { content } = req.body;
189
-
190
- // Security: prevent path traversal attacks
191
- if (!name || name.includes('/') || name.includes('\\') || name.includes('..')) {
192
- res.status(400).json({ error: 'Invalid skill name' });
193
- return;
194
- }
195
-
196
- if (!content || typeof content !== 'string') {
197
- res.status(400).json({ error: 'Missing content' });
198
- return;
199
- }
200
-
201
- const skillsDir = path.join(homedir(), '.claude', 'skills');
202
- const filePath = path.join(skillsDir, `${name}.md`);
203
-
204
- if (!fs.existsSync(filePath)) {
205
- res.status(404).json({ error: 'Skill not found' });
206
- return;
207
- }
208
-
209
- const backupDir = FORGE_PATHS.backups('skills');
210
- fs.mkdirSync(backupDir, { recursive: true });
211
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
212
- const backupPath = path.join(backupDir, `${name}-${timestamp}.md`);
213
- fs.copyFileSync(filePath, backupPath);
214
-
215
- fs.writeFileSync(filePath, content, 'utf-8');
216
- logger.info(`[Web] Updated skill ${name} (backup: ${backupPath})`);
217
-
218
- res.json({ success: true, backup: backupPath });
219
- } catch (err) {
220
- logger.warn(`[Web] Failed to update skill ${req.params.name}: ${err}`);
221
- res.status(500).json({ error: String(err) });
222
- }
223
- });
224
-
225
- // GET /api/skills/:name/versions — list backup versions
226
- app.get('/api/skills/:name/versions', (req, res) => {
227
- try {
228
- const { name } = req.params;
229
-
230
- // Security: prevent path traversal attacks
231
- if (!name || name.includes('/') || name.includes('\\') || name.includes('..')) {
232
- res.status(400).json({ error: 'Invalid skill name' });
233
- return;
234
- }
235
-
236
- const backupDir = FORGE_PATHS.backups('skills');
237
-
238
- if (!fs.existsSync(backupDir)) {
239
- res.json({ versions: [] });
240
- return;
241
- }
242
-
243
- const files = fs.readdirSync(backupDir)
244
- .filter(f => f.startsWith(`${name}-`) && f.endsWith('.md'))
245
- .map(f => {
246
- const filePath = path.join(backupDir, f);
247
- const stats = fs.statSync(filePath);
248
- const timestampMatch = f.match(/-(\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z)\.md$/);
249
- return {
250
- filename: f,
251
- timestamp: timestampMatch ? timestampMatch[1].replace(/-/g, ':').replace(/T(\d{2}):(\d{2}):(\d{2})/, 'T$1:$2:$3') : '',
252
- size: stats.size,
253
- mtime: stats.mtime.toISOString(),
254
- };
255
- })
256
- .sort((a, b) => new Date(b.mtime).getTime() - new Date(a.mtime).getTime());
257
-
258
- res.json({ versions: files });
259
- } catch (err) {
260
- logger.warn(`[Web] Failed to list skill versions: ${err}`);
261
- res.status(500).json({ error: String(err) });
262
- }
263
- });
264
-
265
- // GET /api/skills/:name/versions/:timestamp — get specific version content
266
- app.get('/api/skills/:name/versions/:timestamp', (req, res) => {
267
- try {
268
- const { name, timestamp } = req.params;
269
-
270
- // Security: prevent path traversal attacks
271
- if (!name || name.includes('/') || name.includes('\\') || name.includes('..')) {
272
- res.status(400).json({ error: 'Invalid skill name' });
273
- return;
274
- }
275
- if (!timestamp || timestamp.includes('/') || timestamp.includes('\\') || timestamp.includes('..')) {
276
- res.status(400).json({ error: 'Invalid timestamp' });
277
- return;
278
- }
279
-
280
- const backupDir = FORGE_PATHS.backups('skills');
281
- const filename = `${name}-${timestamp}.md`;
282
- const filePath = path.join(backupDir, filename);
283
-
284
- if (!fs.existsSync(filePath)) {
285
- res.status(404).json({ error: 'Version not found' });
286
- return;
287
- }
288
-
289
- const content = fs.readFileSync(filePath, 'utf-8');
290
- res.json({ content });
291
- } catch (err) {
292
- logger.warn(`[Web] Failed to get skill version: ${err}`);
293
- res.status(500).json({ error: String(err) });
294
- }
295
- });
296
-
297
- // POST /api/skills/:name/rollback — rollback to a specific version
298
- app.post('/api/skills/:name/rollback', (req, res) => {
299
- try {
300
- const { name } = req.params;
301
- const { timestamp } = req.body;
302
-
303
- // Security: prevent path traversal attacks
304
- if (!name || name.includes('/') || name.includes('\\') || name.includes('..')) {
305
- res.status(400).json({ error: 'Invalid skill name' });
306
- return;
307
- }
308
-
309
- if (!timestamp) {
310
- res.status(400).json({ error: 'Missing timestamp' });
311
- return;
312
- }
313
-
314
- // Security: validate timestamp format
315
- if (timestamp.includes('/') || timestamp.includes('\\') || timestamp.includes('..')) {
316
- res.status(400).json({ error: 'Invalid timestamp' });
317
- return;
318
- }
319
-
320
- const skillsDir = path.join(homedir(), '.claude', 'skills');
321
- const currentPath = path.join(skillsDir, `${name}.md`);
322
- const backupDir = FORGE_PATHS.backups('skills');
323
- const versionPath = path.join(backupDir, `${name}-${timestamp}.md`);
324
-
325
- if (!fs.existsSync(currentPath)) {
326
- res.status(404).json({ error: 'Skill not found' });
327
- return;
328
- }
329
-
330
- if (!fs.existsSync(versionPath)) {
331
- res.status(404).json({ error: 'Version not found' });
332
- return;
333
- }
334
-
335
- fs.mkdirSync(backupDir, { recursive: true });
336
- const rollbackTimestamp = new Date().toISOString().replace(/[:.]/g, '-');
337
- const rollbackBackupPath = path.join(backupDir, `${name}-${rollbackTimestamp}.md`);
338
- fs.copyFileSync(currentPath, rollbackBackupPath);
339
-
340
- const versionContent = fs.readFileSync(versionPath, 'utf-8');
341
- fs.writeFileSync(currentPath, versionContent, 'utf-8');
342
-
343
- logger.info(`[Web] Rolled back skill ${name} to ${timestamp} (backup: ${rollbackBackupPath})`);
344
- res.json({ success: true, backup: rollbackBackupPath });
345
- } catch (err) {
346
- logger.warn(`[Web] Failed to rollback skill: ${err}`);
347
- res.status(500).json({ error: String(err) });
348
- }
349
- });
350
- }
@@ -1,67 +0,0 @@
1
- import express from 'express';
2
- import type { Application } from 'express';
3
- import fs from 'fs';
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
6
- import { logger } from '../../core/utils/logger.js';
7
- import type { RouteContext } from './types.js';
8
-
9
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
-
11
- function findStaticDir(): string | null {
12
- const candidates = [
13
- path.join(__dirname, '..', 'static'), // dist/web/routes -> dist/web/static
14
- path.join(__dirname, '../../..', 'src/web/static'), // dev: src/web/routes -> src/web/static
15
- ];
16
- return candidates.find(d => fs.existsSync(d)) ?? null;
17
- }
18
-
19
- /**
20
- * Static assets — Vite-built UI + cache headers + SPA fallback.
21
- *
22
- * index.html: no-cache (always fetch latest, avoids stale UI after deploy)
23
- * /assets/*: immutable, content-hashed, safe to cache for a year.
24
- *
25
- * SPA fallback MUST be registered last so it doesn't shadow any API route;
26
- * that constraint is enforced by splitting into `registerStaticAssets` (runs
27
- * early, sets up express.static) and `registerStaticFallback` (runs last).
28
- */
29
- export function registerStaticAssets(app: Application, _ctx: RouteContext): void {
30
- const staticDir = findStaticDir();
31
- if (!staticDir) {
32
- logger.warn('[Web] Static directory not found; UI will not be served.');
33
- return;
34
- }
35
-
36
- app.use(express.static(staticDir, {
37
- setHeaders: (res, filePath) => {
38
- if (filePath.endsWith('index.html')) {
39
- res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
40
- res.setHeader('Pragma', 'no-cache');
41
- res.setHeader('Expires', '0');
42
- } else if (filePath.includes('/assets/')) {
43
- res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
44
- }
45
- },
46
- }));
47
-
48
- app.get('/', (_req, res) => {
49
- res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
50
- res.sendFile('index.html', { root: staticDir });
51
- });
52
-
53
- logger.info(`[Web] Serving static files from ${staticDir}`);
54
- }
55
-
56
- /**
57
- * SPA catch-all — must be registered last. Routes any non-/api path to
58
- * index.html so the frontend router handles deep links on refresh.
59
- */
60
- export function registerStaticFallback(app: Application, _ctx: RouteContext): void {
61
- const staticDir = findStaticDir();
62
- if (!staticDir) return;
63
- app.get(/^(?!\/api).*$/, (_req, res) => {
64
- res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
65
- res.sendFile('index.html', { root: staticDir });
66
- });
67
- }
@@ -1,50 +0,0 @@
1
- import type { Application } from 'express';
2
- import type { RouteContext } from './types.js';
3
-
4
- /**
5
- * /api/stats — System-wide statistics for the Dashboard.
6
- *
7
- * H2 Phase 3: 替换原 db.prepare 直写 SQL 为 SQLiteStorage facade 聚合方法。
8
- * 响应 shape 保持不变(前端契约):totalSessions / totalEvents / toolUsage /
9
- * dailyActivity / skillInvocations。
10
- */
11
- export function registerStatsRoutes(app: Application, ctx: RouteContext): void {
12
- const { storage } = ctx;
13
-
14
- app.get('/api/stats', (_req, res) => {
15
- const totalEvents = storage.countAllEvents();
16
- const totalSessions = storage.countAllSessions();
17
-
18
- // Tool usage distribution (top 15)
19
- const toolRows = storage.aggregateToolUsage({ limit: 15 });
20
- const toolUsage: Record<string, number> = {};
21
- for (const r of toolRows) {
22
- toolUsage[r.tool_name] = r.count;
23
- }
24
-
25
- // Daily activity (last 7 days)
26
- // 旧 SQL: timestamp >= date('now', '-7 days')
27
- // 新口径:调用方计算 ISO 字符串,传给 facade。
28
- const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
29
- const dailyRows = storage.aggregateDailyEventCounts({ since: sevenDaysAgo });
30
- const sessionDailyRows = storage.aggregateDailySessionCounts({ since: sevenDaysAgo });
31
-
32
- const sessionMap = new Map(sessionDailyRows.map(r => [r.date, r.count]));
33
- const dailyActivity = dailyRows.map(r => ({
34
- date: r.date,
35
- eventCount: r.count,
36
- sessionCount: sessionMap.get(r.date) || 0,
37
- }));
38
-
39
- // Skill invocation count
40
- const skillCount = storage.countAllSkillInvocations();
41
-
42
- res.json({
43
- totalSessions,
44
- totalEvents,
45
- toolUsage,
46
- dailyActivity,
47
- skillInvocations: skillCount,
48
- });
49
- });
50
- }
@@ -1,30 +0,0 @@
1
- import type { Application } from 'express';
2
- import type { RouteContext } from './types.js';
3
-
4
- /**
5
- * Status / health endpoints for the daemon and background worker.
6
- */
7
- export function registerStatusRoutes(app: Application, ctx: RouteContext): void {
8
- const { storage } = ctx;
9
-
10
- // Worker auth probe: legacy endpoint kept for UI backwards-compat.
11
- // The background worker subsystem was removed alongside the methodology
12
- // system (v8.36.0 hard deprecation B.1); the probe now always reports
13
- // unavailable so the UI hides background-mode affordances.
14
- app.get('/api/worker-auth-status', (_req, res) => {
15
- res.json({
16
- available: false,
17
- reason: 'background worker subsystem removed (methodology deprecation)',
18
- });
19
- });
20
-
21
- // Dashboard: daemon status
22
- app.get('/api/status', (_req, res) => {
23
- res.json({
24
- pid: process.pid,
25
- uptime: process.uptime(),
26
- memory: process.memoryUsage(),
27
- eventCount: storage.countEvents(),
28
- });
29
- });
30
- }
@@ -1,193 +0,0 @@
1
- import { z } from 'zod';
2
- import type { Application } from 'express';
3
- import type { RouteContext } from './types.js';
4
- import { truncateField } from './_helpers.js';
5
- import { getFilePath, getUserPrompt } from '../../core/event-fields.js';
6
-
7
- /**
8
- * /api/tasks — Task execution view.
9
- *
10
- * Provides a complete view of a task's execution process:
11
- * - GET /api/tasks — list + filter + paginate tasks
12
- * - GET /api/tasks/projects — distinct project paths that have tasks
13
- * - GET /api/tasks/:taskId — full execution detail for a single task
14
- */
15
-
16
- const TaskListQuery = z.object({
17
- limit: z.coerce.number().int().min(1).default(50).transform(v => Math.min(v, 200)),
18
- offset: z.coerce.number().int().min(0).default(0),
19
- /** multi-value: ?project=/a&project=/b OR ?project=/a */
20
- project: z.union([z.string(), z.array(z.string())]).optional(),
21
- from: z.string().optional(),
22
- to: z.string().optional(),
23
- search: z.string().max(100).optional(),
24
- session: z.string().optional(),
25
- });
26
-
27
- export function registerTasksRoutes(app: Application, ctx: RouteContext): void {
28
- const { storage } = ctx;
29
-
30
- // ── GET /api/tasks/projects — distinct project paths ──────────────────────
31
- // Must be registered BEFORE /:taskId to avoid 'projects' being treated as an id.
32
- app.get('/api/tasks/projects', (_req, res) => {
33
- const projects = storage.queryTaskProjects();
34
- res.json(projects);
35
- });
36
-
37
- // ── GET /api/tasks — paginated + filtered list ─────────────────────────────
38
- app.get('/api/tasks', (req, res) => {
39
- const parsed = TaskListQuery.safeParse(req.query);
40
- if (!parsed.success) {
41
- res.status(400).json({ error: 'Invalid query parameters', details: parsed.error.flatten() });
42
- return;
43
- }
44
-
45
- const { limit, offset, project, from, to, search, session } = parsed.data;
46
-
47
- const result = storage.queryTasksFiltered({
48
- limit,
49
- offset,
50
- project,
51
- from,
52
- to,
53
- search,
54
- session_id: session,
55
- });
56
-
57
- res.json(result);
58
- });
59
-
60
- // ── GET /api/tasks/:taskId — full execution detail ─────────────────────────
61
- app.get('/api/tasks/:taskId', (req, res) => {
62
- const taskId = req.params.taskId;
63
-
64
- // H1: PK direct fetch (was: queryTasks({limit:5000}).find)
65
- const task = storage.getTask(taskId);
66
- if (!task) {
67
- res.status(404).json({ error: 'Task not found' });
68
- return;
69
- }
70
-
71
- // H1: JOIN task_events (was: queryEvents({limit:5000}) + Set.has filter)
72
- const taskEvents = storage.queryEventsByTaskId(taskId, { limit: 5000 });
73
-
74
- // ── Injections ──────────────────────────────────────────────────────
75
- // H1: JOIN task_events (was: queryInjections({limit:500}) + Set.has filter)
76
- const allInjections = storage.queryInjectionsByTaskId(taskId);
77
- const injections = allInjections
78
- .map(inj => ({
79
- id: inj.id,
80
- timestamp: inj.timestamp,
81
- source_handler: inj.source_handler,
82
- injection_type: inj.injection_type,
83
- content: inj.content.slice(0, 1000),
84
- content_length: inj.content.length,
85
- truncated: inj.content.length > 1000,
86
- }));
87
-
88
- // ── Timeline ────────────────────────────────────────────────────────
89
- const timeline = taskEvents
90
- .filter(e => e.tool_name && (e.hook_type === 'PreToolUse' || e.hook_type === 'PostToolUse'))
91
- .reduce<Array<{
92
- timestamp: string;
93
- tool_name: string;
94
- hook_type: string;
95
- input: unknown;
96
- output: unknown;
97
- is_agent_call: boolean;
98
- agent_detail?: { subagent_type?: string; name?: string; prompt?: string };
99
- }>>((acc, e) => {
100
- // Deduplicate: only keep PreToolUse entries (PostToolUse is supplementary)
101
- if (e.hook_type === 'PostToolUse') {
102
- // Attach output to the matching PreToolUse entry if exists
103
- const pre = acc.find(
104
- a => a.tool_name === e.tool_name && !a.output && a.timestamp <= e.timestamp,
105
- );
106
- if (pre) {
107
- pre.output = truncateField(e.tool_output);
108
- }
109
- return acc;
110
- }
111
-
112
- const toolInput = e.tool_input ?? null;
113
- const isAgentCall = e.tool_name === 'Agent' || e.tool_name === 'Task';
114
-
115
- const entry: (typeof acc)[number] = {
116
- timestamp: e.timestamp,
117
- tool_name: e.tool_name!,
118
- hook_type: e.hook_type,
119
- input: truncateField(toolInput),
120
- output: truncateField(e.tool_output),
121
- is_agent_call: isAgentCall,
122
- };
123
-
124
- if (isAgentCall && toolInput) {
125
- entry.agent_detail = {
126
- subagent_type: typeof toolInput.subagent_type === 'string' ? toolInput.subagent_type : undefined,
127
- name: typeof toolInput.name === 'string' ? toolInput.name : undefined,
128
- prompt: typeof toolInput.prompt === 'string'
129
- ? toolInput.prompt
130
- : undefined,
131
- };
132
- }
133
-
134
- acc.push(entry);
135
- return acc;
136
- }, []);
137
-
138
- // ── Skill Invocations ───────────────────────────────────────────────
139
- // H1: SQL window filter (was: querySkillInvocations({limit:200}) + JS time filter)
140
- const allSkillInvocations = storage.querySkillInvocationsByTaskWindow(taskId);
141
-
142
- const skillInvocations = allSkillInvocations
143
- .map(si => ({
144
- id: si.id,
145
- skill_id: si.skill_id,
146
- agent_id: si.agent_id,
147
- invocation_type: si.invocation_type,
148
- reason: si.reason,
149
- workflow: si.workflow,
150
- phase: si.phase,
151
- feature_slug: si.feature_slug,
152
- success: si.success === 1,
153
- error: si.error,
154
- timestamp: si.timestamp,
155
- }));
156
-
157
- // ── Artifacts ───────────────────────────────────────────────────────
158
- const artifacts = [...new Set(
159
- taskEvents
160
- .filter(e =>
161
- (e.tool_name === 'Edit' || e.tool_name === 'Write') &&
162
- getFilePath(e),
163
- )
164
- .map(e => getFilePath(e)!),
165
- )];
166
-
167
- // ── User Prompts ────────────────────────────────────────────────────
168
- const userPrompts = taskEvents
169
- .filter(e => e.hook_type === 'UserPromptSubmit' && getUserPrompt(e))
170
- .map(e => ({
171
- timestamp: e.timestamp,
172
- content: getUserPrompt(e),
173
- }));
174
-
175
- res.json({
176
- task: {
177
- id: task.id,
178
- session_id: task.session_id,
179
- title: task.title,
180
- description: task.description,
181
- start_time: task.start_time,
182
- end_time: task.end_time,
183
- status: task.status,
184
- event_count: task.event_count,
185
- },
186
- userPrompts,
187
- injections,
188
- timeline,
189
- skillInvocations,
190
- artifacts,
191
- });
192
- });
193
- }