@winspan/claude-forge 8.50.6 → 8.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +7 -7
- package/dist/claudemd/claudemd-generator.d.ts.map +1 -1
- package/dist/claudemd/claudemd-generator.js +27 -237
- package/dist/claudemd/claudemd-generator.js.map +1 -1
- package/dist/claudemd/resume-manager.js +1 -1
- package/dist/claudemd/resume-manager.js.map +1 -1
- package/dist/claudemd/templates/swarm-protocol.md +222 -0
- package/dist/cli/commands/daemon.js +6 -6
- package/dist/cli/commands/daemon.js.map +1 -1
- package/dist/cli/commands/executions.d.ts.map +1 -1
- package/dist/cli/commands/executions.js +4 -3
- package/dist/cli/commands/executions.js.map +1 -1
- package/dist/cli/commands/init.js +2 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/logs.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +3 -5
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/menu.d.ts.map +1 -1
- package/dist/cli/commands/menu.js +4 -3
- package/dist/cli/commands/menu.js.map +1 -1
- package/dist/cli/commands/stats.d.ts.map +1 -1
- package/dist/cli/commands/stats.js +2 -3
- package/dist/cli/commands/stats.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/trace.d.ts.map +1 -1
- package/dist/cli/commands/trace.js +11 -23
- package/dist/cli/commands/trace.js.map +1 -1
- package/dist/cli/init/hook-manager.d.ts.map +1 -1
- package/dist/cli/init/hook-manager.js +2 -2
- package/dist/cli/init/hook-manager.js.map +1 -1
- package/dist/core/ai/provider.js +2 -2
- package/dist/core/ai/provider.js.map +1 -1
- package/dist/core/constants.d.ts +12 -1
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +15 -1
- package/dist/core/constants.js.map +1 -1
- package/dist/core/event-fields.d.ts +16 -0
- package/dist/core/event-fields.d.ts.map +1 -0
- package/dist/core/event-fields.js +19 -0
- package/dist/core/event-fields.js.map +1 -0
- package/dist/core/queue/index.d.ts.map +1 -1
- package/dist/core/queue/index.js +3 -4
- package/dist/core/queue/index.js.map +1 -1
- package/dist/core/storage/base.d.ts +36 -3
- package/dist/core/storage/base.d.ts.map +1 -1
- package/dist/core/storage/base.js +101 -58
- package/dist/core/storage/base.js.map +1 -1
- package/dist/core/storage/events.d.ts +92 -3
- package/dist/core/storage/events.d.ts.map +1 -1
- package/dist/core/storage/events.js +147 -0
- package/dist/core/storage/events.js.map +1 -1
- package/dist/core/storage/routing.d.ts +54 -1
- package/dist/core/storage/routing.d.ts.map +1 -1
- package/dist/core/storage/routing.js +99 -1
- package/dist/core/storage/routing.js.map +1 -1
- package/dist/core/storage/schema.sql +12 -2
- package/dist/core/storage/sessions.d.ts +20 -0
- package/dist/core/storage/sessions.d.ts.map +1 -1
- package/dist/core/storage/sessions.js +59 -0
- package/dist/core/storage/sessions.js.map +1 -1
- package/dist/core/storage/skills.d.ts +23 -0
- package/dist/core/storage/skills.d.ts.map +1 -1
- package/dist/core/storage/skills.js +47 -0
- package/dist/core/storage/skills.js.map +1 -1
- package/dist/core/storage/sqlite.d.ts +35 -2
- package/dist/core/storage/sqlite.d.ts.map +1 -1
- package/dist/core/storage/sqlite.js +93 -4
- package/dist/core/storage/sqlite.js.map +1 -1
- package/dist/core/storage/tasks.d.ts +49 -0
- package/dist/core/storage/tasks.d.ts.map +1 -1
- package/dist/core/storage/tasks.js +143 -1
- package/dist/core/storage/tasks.js.map +1 -1
- package/dist/core/storage/token-usage.d.ts +1 -1
- package/dist/core/storage/token-usage.d.ts.map +1 -1
- package/dist/core/storage/token-usage.js +1 -1
- package/dist/core/storage/token-usage.js.map +1 -1
- package/dist/core/types.d.ts +24 -3
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/utils/error-handler.d.ts.map +1 -1
- package/dist/core/utils/error-handler.js +3 -2
- package/dist/core/utils/error-handler.js.map +1 -1
- package/dist/core/utils/git.d.ts +10 -0
- package/dist/core/utils/git.d.ts.map +1 -0
- package/dist/core/utils/git.js +24 -0
- package/dist/core/utils/git.js.map +1 -0
- package/dist/core/utils/logger.d.ts.map +1 -1
- package/dist/core/utils/logger.js +15 -1
- package/dist/core/utils/logger.js.map +1 -1
- package/dist/core/utils/lru-cache.d.ts +1 -0
- package/dist/core/utils/lru-cache.d.ts.map +1 -1
- package/dist/core/utils/lru-cache.js +3 -0
- package/dist/core/utils/lru-cache.js.map +1 -1
- package/dist/core/utils/token-tracker.js +1 -1
- package/dist/core/utils/token-tracker.js.map +1 -1
- package/dist/daemon/event-parser.d.ts.map +1 -1
- package/dist/daemon/event-parser.js +2 -1
- package/dist/daemon/event-parser.js.map +1 -1
- package/dist/daemon/handlers/history-exporter.js.map +1 -1
- package/dist/daemon/handlers/post-tool-use.d.ts.map +1 -1
- package/dist/daemon/handlers/post-tool-use.js +7 -3
- package/dist/daemon/handlers/post-tool-use.js.map +1 -1
- package/dist/daemon/handlers/stop.d.ts +4 -0
- package/dist/daemon/handlers/stop.d.ts.map +1 -1
- package/dist/daemon/handlers/stop.js +23 -35
- package/dist/daemon/handlers/stop.js.map +1 -1
- package/dist/daemon/handlers/user-prompt.d.ts +3 -3
- package/dist/daemon/handlers/user-prompt.d.ts.map +1 -1
- package/dist/daemon/handlers/user-prompt.js +12 -22
- package/dist/daemon/handlers/user-prompt.js.map +1 -1
- package/dist/daemon/hook-sync.d.ts +17 -0
- package/dist/daemon/hook-sync.d.ts.map +1 -0
- package/dist/daemon/hook-sync.js +74 -0
- package/dist/daemon/hook-sync.js.map +1 -0
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +33 -9
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/lifecycle.js +3 -4
- package/dist/daemon/lifecycle.js.map +1 -1
- package/dist/daemon/server.d.ts +6 -4
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +76 -85
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/services/task-segmenter.js +1 -1
- package/dist/daemon/services/task-segmenter.js.map +1 -1
- package/dist/hooks/hook-lib.sh +37 -0
- package/dist/hooks/notification.sh +2 -2
- package/dist/hooks/post-tool-use.sh +2 -2
- package/dist/hooks/pre-tool-use.sh +2 -2
- package/dist/hooks/stop.sh +9 -6
- package/dist/hooks/user-prompt-submit.sh +2 -2
- package/dist/{daemon/services → web/analytics}/anti-pattern-detector.d.ts +3 -4
- package/dist/web/analytics/anti-pattern-detector.d.ts.map +1 -0
- package/dist/{daemon/services → web/analytics}/anti-pattern-detector.js +7 -46
- package/dist/{daemon/services → web/analytics}/anti-pattern-detector.js.map +1 -1
- package/dist/web/analytics/drift-detector.d.ts.map +1 -0
- package/dist/{daemon/services → web/analytics}/drift-detector.js +10 -13
- package/dist/web/analytics/drift-detector.js.map +1 -0
- package/dist/web/analytics/weekly-report.d.ts.map +1 -0
- package/dist/{daemon/services → web/analytics}/weekly-report.js +51 -50
- package/dist/web/analytics/weekly-report.js.map +1 -0
- package/dist/web/auth-middleware.d.ts.map +1 -1
- package/dist/web/auth-middleware.js +1 -2
- package/dist/web/auth-middleware.js.map +1 -1
- package/dist/web/routes/_helpers.d.ts +16 -0
- package/dist/web/routes/_helpers.d.ts.map +1 -0
- package/dist/web/routes/_helpers.js +32 -0
- package/dist/web/routes/_helpers.js.map +1 -0
- package/dist/web/routes/drift.js +1 -1
- package/dist/web/routes/drift.js.map +1 -1
- package/dist/web/routes/insights.js +1 -1
- package/dist/web/routes/insights.js.map +1 -1
- package/dist/web/routes/reports.js +1 -1
- package/dist/web/routes/reports.js.map +1 -1
- package/dist/web/routes/rules.d.ts +3 -0
- package/dist/web/routes/rules.d.ts.map +1 -1
- package/dist/web/routes/rules.js +28 -52
- package/dist/web/routes/rules.js.map +1 -1
- package/dist/web/routes/sessions.d.ts.map +1 -1
- package/dist/web/routes/sessions.js +16 -30
- package/dist/web/routes/sessions.js.map +1 -1
- package/dist/web/routes/skill-stats.d.ts +2 -0
- package/dist/web/routes/skill-stats.d.ts.map +1 -1
- package/dist/web/routes/skill-stats.js +28 -64
- package/dist/web/routes/skill-stats.js.map +1 -1
- package/dist/web/routes/skills.d.ts.map +1 -1
- package/dist/web/routes/skills.js +5 -4
- package/dist/web/routes/skills.js.map +1 -1
- package/dist/web/routes/stats.d.ts +4 -0
- package/dist/web/routes/stats.d.ts.map +1 -1
- package/dist/web/routes/stats.js +19 -21
- package/dist/web/routes/stats.js.map +1 -1
- package/dist/web/routes/tasks.d.ts.map +1 -1
- package/dist/web/routes/tasks.js +17 -42
- package/dist/web/routes/tasks.js.map +1 -1
- package/dist/web/routes/trace.d.ts.map +1 -1
- package/dist/web/routes/trace.js +7 -17
- package/dist/web/routes/trace.js.map +1 -1
- package/dist/web/routes/types.d.ts.map +1 -1
- package/dist/web/routes/types.js +4 -3
- package/dist/web/routes/types.js.map +1 -1
- package/dist/web/static/assets/{AIConfig-BQCAQE9D.js → AIConfig-CdDWzJyO.js} +2 -2
- package/dist/web/static/assets/{AIConfig-BQCAQE9D.js.map → AIConfig-CdDWzJyO.js.map} +1 -1
- package/dist/web/static/assets/{Dashboard-D7Bo6Kan.js → Dashboard-CoEmmIDt.js} +2 -2
- package/dist/web/static/assets/{Dashboard-D7Bo6Kan.js.map → Dashboard-CoEmmIDt.js.map} +1 -1
- package/dist/web/static/assets/{Drawer-BeHRQxUS.js → Drawer-DdRTzlLB.js} +2 -2
- package/dist/web/static/assets/{Drawer-BeHRQxUS.js.map → Drawer-DdRTzlLB.js.map} +1 -1
- package/dist/web/static/assets/{Events-K_tCY2ti.js → Events-DrIq1SUS.js} +2 -2
- package/dist/web/static/assets/{Events-K_tCY2ti.js.map → Events-DrIq1SUS.js.map} +1 -1
- package/dist/web/static/assets/{Reports-BJCmBnc_.js → Reports-DFBM3MDK.js} +2 -2
- package/dist/web/static/assets/{Reports-BJCmBnc_.js.map → Reports-DFBM3MDK.js.map} +1 -1
- package/dist/web/static/assets/{SearchInput-BX2KhMkw.js → SearchInput-qCj_jAcf.js} +2 -2
- package/dist/web/static/assets/{SearchInput-BX2KhMkw.js.map → SearchInput-qCj_jAcf.js.map} +1 -1
- package/dist/web/static/assets/{SessionDetail-Bkr-kC7V.js → SessionDetail-CCzwdoT7.js} +2 -2
- package/dist/web/static/assets/{SessionDetail-Bkr-kC7V.js.map → SessionDetail-CCzwdoT7.js.map} +1 -1
- package/dist/web/static/assets/{Sessions-Chx9OCLH.js → Sessions-FfLYkAw9.js} +2 -2
- package/dist/web/static/assets/{Sessions-Chx9OCLH.js.map → Sessions-FfLYkAw9.js.map} +1 -1
- package/dist/web/static/assets/{Skills-O0GT1i7m.js → Skills-C8Gvs3Qa.js} +2 -2
- package/dist/web/static/assets/{Skills-O0GT1i7m.js.map → Skills-C8Gvs3Qa.js.map} +1 -1
- package/dist/web/static/assets/TaskDetail-BS8pYhaR.js +2 -0
- package/dist/web/static/assets/TaskDetail-BS8pYhaR.js.map +1 -0
- package/dist/web/static/assets/Tasks-CyuhizG8.js +2 -0
- package/dist/web/static/assets/Tasks-CyuhizG8.js.map +1 -0
- package/dist/web/static/assets/index-CBX47X8l.js +3 -0
- package/dist/web/static/assets/{index-DxIbmNmr.js.map → index-CBX47X8l.js.map} +1 -1
- package/dist/web/static/assets/index-DjIoMdoR.css +1 -0
- package/dist/web/static/assets/{lucide-fJlPI3H7.js → lucide-Bs_edTLa.js} +44 -39
- package/dist/web/static/assets/lucide-Bs_edTLa.js.map +1 -0
- package/dist/web/static/assets/react-router-r79dBVy4.js +20 -0
- package/dist/web/static/assets/{react-router-I-HqunH7.js.map → react-router-r79dBVy4.js.map} +1 -1
- package/dist/web/static/assets/task-title-BhOcemuR.js +2 -0
- package/dist/web/static/assets/task-title-BhOcemuR.js.map +1 -0
- package/dist/web/static/index.html +4 -4
- package/docs/design/h1-storage-aggregation-spec-20260518-1121.md +299 -0
- package/docs/design/h2-getdatabase-encapsulation-spec-20260518-1450.md +191 -0
- package/docs/design/h3-fallback-removal-spec-20260518-1245.md +76 -0
- package/docs/design/h4-index-dedup-spec-20260518-1230.md +109 -0
- package/docs/design/h6-services-migration-spec-20260518-1355.md +82 -0
- package/docs/design/l1-swarm-protocol-extract-spec-20260518-1605.md +106 -0
- package/docs/design/m10-forge-paths-spec-20260518-1320.md +121 -0
- package/docs/design/m2-m3-tool-input-spec-20260518-1425.md +131 -0
- package/docs/design/m7-routing-event-association-spec-20260518-1545.md +103 -0
- package/docs/design/project-path-gitroot-spec-20260518-1715.md +134 -0
- package/docs/design/task-active-gc-spec-20260518-1745.md +146 -0
- package/docs/implementation/h1-storage-aggregation-changelog-20260518-1121.md +82 -0
- package/docs/implementation/h2-final-changelog-20260518-1530.md +61 -0
- package/docs/implementation/h2-phase1-safety-net-changelog-20260518-1450.md +70 -0
- package/docs/implementation/h2-phase2-operations-changelog-20260518-1450.md +120 -0
- package/docs/implementation/h2-phase3-callsites-changelog-20260518-1450.md +71 -0
- package/docs/implementation/h3-fallback-removal-changelog-20260518-1245.md +71 -0
- package/docs/implementation/h4-index-dedup-changelog-20260518-1230.md +60 -0
- package/docs/implementation/h6-services-migration-changelog-20260518-1355.md +46 -0
- package/docs/implementation/h7-m9-defaults-changelog-20260518-1300.md +46 -0
- package/docs/implementation/l1-swarm-protocol-extract-changelog-20260518-1605.md +45 -0
- package/docs/implementation/l3-l4-daemon-perf-changelog-20260518-1410.md +63 -0
- package/docs/implementation/l6-l8-final-cleanup-changelog-20260518-1640.md +38 -0
- package/docs/implementation/m1-m4-m5-l7-cleanup-changelog-20260518-1310.md +58 -0
- package/docs/implementation/m10-forge-paths-changelog-20260518-1320.md +60 -0
- package/docs/implementation/m2-m3-tool-input-changelog-20260518-1425.md +43 -0
- package/docs/implementation/m6-m8-naming-shutdown-changelog-20260518-1340.md +56 -0
- package/docs/implementation/m7-routing-association-changelog-20260518-1545.md +69 -0
- package/docs/implementation/project-path-gitroot-changelog-20260518-1715.md +63 -0
- package/docs/implementation/task-active-gc-changelog-20260518-1745.md +35 -0
- package/docs/implementation/task-title-summary-changelog-20260518-1130.md +39 -0
- package/docs/implementation/tasks-detail-back-loses-filters-changelog-20260518-1100.md +22 -0
- package/docs/implementation/tasks-page-white-screen-hotfix-changelog-20260518-1015.md +56 -0
- package/docs/reviews/task-title-summary.md +92 -0
- package/docs/reviews/tasks-detail-back-loses-filters.md +58 -0
- package/docs/reviews/tasks-page-white-screen-hotfix.md +126 -0
- package/package.json +2 -2
- package/src/claudemd/claudemd-generator.ts +29 -238
- package/src/claudemd/resume-manager.ts +1 -1
- package/src/claudemd/templates/swarm-protocol.md +222 -0
- package/src/cli/commands/daemon.ts +6 -6
- package/src/cli/commands/executions.ts +4 -3
- package/src/cli/commands/init.ts +2 -2
- package/src/cli/commands/logs.ts +1 -1
- package/src/cli/commands/mcp.ts +3 -5
- package/src/cli/commands/menu.ts +4 -3
- package/src/cli/commands/stats.ts +2 -3
- package/src/cli/commands/status.ts +2 -2
- package/src/cli/commands/trace.ts +10 -26
- package/src/cli/init/hook-manager.ts +2 -2
- package/src/core/ai/provider.ts +2 -2
- package/src/core/constants.ts +18 -1
- package/src/core/event-fields.ts +32 -0
- package/src/core/queue/index.ts +3 -4
- package/src/core/storage/base.ts +132 -56
- package/src/core/storage/events.ts +183 -4
- package/src/core/storage/routing.ts +129 -1
- package/src/core/storage/schema.sql +12 -2
- package/src/core/storage/sessions.ts +64 -0
- package/src/core/storage/skills.ts +69 -0
- package/src/core/storage/sqlite.ts +103 -4
- package/src/core/storage/tasks.ts +149 -1
- package/src/core/storage/token-usage.ts +1 -1
- package/src/core/types.ts +30 -3
- package/src/core/utils/error-handler.ts +3 -2
- package/src/core/utils/git.ts +23 -0
- package/src/core/utils/logger.ts +16 -1
- package/src/core/utils/lru-cache.ts +4 -0
- package/src/core/utils/token-tracker.ts +1 -1
- package/src/daemon/event-parser.ts +4 -3
- package/src/daemon/handlers/history-exporter.ts +1 -1
- package/src/daemon/handlers/post-tool-use.ts +7 -3
- package/src/daemon/handlers/stop.ts +32 -39
- package/src/daemon/handlers/user-prompt.ts +12 -22
- package/src/daemon/hook-sync.ts +91 -0
- package/src/daemon/index.ts +34 -10
- package/src/daemon/lifecycle.ts +3 -3
- package/src/daemon/server.ts +76 -89
- package/src/daemon/services/task-segmenter.ts +1 -1
- package/src/hooks/hook-lib.sh +37 -0
- package/src/hooks/notification.sh +2 -2
- package/src/hooks/post-tool-use.sh +2 -2
- package/src/hooks/pre-tool-use.sh +2 -2
- package/src/hooks/stop.sh +9 -6
- package/src/hooks/user-prompt-submit.sh +2 -2
- package/src/{daemon/services → web/analytics}/anti-pattern-detector.ts +9 -54
- package/src/{daemon/services → web/analytics}/drift-detector.ts +10 -23
- package/src/{daemon/services → web/analytics}/weekly-report.ts +52 -75
- package/src/web/auth-middleware.ts +1 -2
- package/src/web/routes/_helpers.ts +34 -0
- package/src/web/routes/drift.ts +1 -1
- package/src/web/routes/insights.ts +1 -1
- package/src/web/routes/reports.ts +1 -1
- package/src/web/routes/rules.ts +31 -56
- package/src/web/routes/sessions.ts +18 -30
- package/src/web/routes/skill-stats.ts +29 -69
- package/src/web/routes/skills.ts +5 -4
- package/src/web/routes/stats.ts +19 -29
- package/src/web/routes/tasks.ts +17 -42
- package/src/web/routes/trace.ts +7 -19
- package/src/web/routes/types.ts +4 -3
- package/tests/integration/claudemd-generator.test.ts +90 -0
- package/tests/integration/web-analytics.integration.test.ts +133 -0
- package/tests/integration/web-stats.integration.test.ts +135 -0
- package/tests/integration/web-trace.integration.test.ts +175 -0
- package/tests/unit/core/forge-paths.test.ts +99 -0
- package/tests/unit/daemon/hook-sync.test.ts +71 -0
- package/tests/unit/daemon/post-tool-use.test.ts +121 -0
- package/tests/unit/daemon/stop-handler-behavior-summary.test.ts +202 -0
- package/tests/unit/daemon/task-segmenter-recover.test.ts +84 -0
- package/tests/unit/event-fields.test.ts +88 -0
- package/tests/unit/event-parser.test.ts +55 -0
- package/tests/unit/hooks/resolve-project-path.test.ts +122 -0
- package/tests/unit/socket-server.test.ts +183 -0
- package/tests/unit/storage/event-operations-aggregates.test.ts +342 -0
- package/tests/unit/storage/migration-idempotent.test.ts +304 -0
- package/tests/unit/storage/routing-aggregates.test.ts +276 -0
- package/tests/unit/storage/routing.test.ts +117 -0
- package/tests/unit/storage/schema-missing.test.ts +81 -0
- package/tests/unit/storage/session-operations-aggregates.test.ts +120 -0
- package/tests/unit/storage/skill-operations-counts.test.ts +106 -0
- package/tests/unit/storage/skills-aggregates.test.ts +104 -0
- package/tests/unit/storage/sqlite-refactor-harness.test.ts +3 -3
- package/tests/unit/storage/task-operations-counts.test.ts +46 -0
- package/tests/unit/storage/tasks-getById.test.ts +343 -0
- package/tests/unit/storage/tasks-stale-gc.test.ts +86 -0
- package/tests/unit/token-usage.test.ts +6 -6
- package/tests/unit/web/navigation-back-contract.test.ts +134 -0
- package/tests/unit/web/routes-rules.test.ts +182 -0
- package/tests/unit/web/routes-tasks.test.ts +34 -0
- package/tests/unit/web/task-title-contract.test.ts +210 -0
- package/tests/unit/web/tasks-component-contract.test.ts +179 -0
- package/vitest.config.ts +1 -1
- package/web/src/pages/TaskDetail.tsx +9 -5
- package/web/src/pages/Tasks.tsx +315 -50
- package/web/src/utils/navigation.ts +25 -0
- package/web/src/utils/task-title.ts +49 -0
- package/dist/daemon/services/anti-pattern-detector.d.ts.map +0 -1
- package/dist/daemon/services/drift-detector.d.ts.map +0 -1
- package/dist/daemon/services/drift-detector.js.map +0 -1
- package/dist/daemon/services/weekly-report.d.ts.map +0 -1
- package/dist/daemon/services/weekly-report.js.map +0 -1
- package/dist/web/static/assets/TaskDetail-5SR8zGzv.js +0 -2
- package/dist/web/static/assets/TaskDetail-5SR8zGzv.js.map +0 -1
- package/dist/web/static/assets/Tasks-DCgDqvOZ.js +0 -2
- package/dist/web/static/assets/Tasks-DCgDqvOZ.js.map +0 -1
- package/dist/web/static/assets/index-D8AKj26b.css +0 -1
- package/dist/web/static/assets/index-DxIbmNmr.js +0 -3
- package/dist/web/static/assets/lucide-fJlPI3H7.js.map +0 -1
- package/dist/web/static/assets/react-router-I-HqunH7.js +0 -20
- /package/dist/{daemon/services → web/analytics}/drift-detector.d.ts +0 -0
- /package/dist/{daemon/services → web/analytics}/weekly-report.d.ts +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H3: schema.sql 缺失时 fail-fast
|
|
3
|
+
*
|
|
4
|
+
* 覆盖 base.ts::initSchema 的两个分支:
|
|
5
|
+
* 1. schema.sql 存在 → 正常初始化 8 张表
|
|
6
|
+
* 2. schema.sql 缺失 → 立即抛 Error,不再走旧 inline fallback(events 表不会被创建)
|
|
7
|
+
*
|
|
8
|
+
* case 2 的实现:用 vi.doMock + 动态 import,对 'node:fs' 的 existsSync 做选择性 mock —
|
|
9
|
+
* 只让 schema.sql 路径返回 false,其他路径保留真实行为(避免破坏 mkdirSync 的目录检查)。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
13
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
14
|
+
import { tmpdir } from 'node:os';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import Database from 'better-sqlite3';
|
|
17
|
+
|
|
18
|
+
describe('H3: schema.sql missing fail-fast', () => {
|
|
19
|
+
let tmp: string;
|
|
20
|
+
let dbPath: string;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
tmp = mkdtempSync(join(tmpdir(), 'forge-h3-schema-missing-'));
|
|
24
|
+
dbPath = join(tmp, 'data.db');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
vi.resetModules();
|
|
29
|
+
vi.restoreAllMocks();
|
|
30
|
+
vi.doUnmock('node:fs');
|
|
31
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('case 1: schema.sql 存在 → 正常初始化,sessions 表已创建', async () => {
|
|
35
|
+
const { SQLiteStorage } = await import('../../../src/core/storage/sqlite.js');
|
|
36
|
+
const storage = new SQLiteStorage(dbPath);
|
|
37
|
+
const db = storage.getDatabase();
|
|
38
|
+
|
|
39
|
+
const row = db
|
|
40
|
+
.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='sessions'`)
|
|
41
|
+
.get();
|
|
42
|
+
expect(row).toBeTruthy();
|
|
43
|
+
|
|
44
|
+
storage.close();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('case 2: schema.sql 缺失 → 抛 Error,且未创建任何业务表(确认不走旧 fallback)', async () => {
|
|
48
|
+
vi.resetModules();
|
|
49
|
+
|
|
50
|
+
// 选择性 mock:只让 schema.sql 返回 false,其余路径保留真实 fs 行为
|
|
51
|
+
vi.doMock('node:fs', async () => {
|
|
52
|
+
const realFs = await vi.importActual<typeof import('node:fs')>('node:fs');
|
|
53
|
+
return {
|
|
54
|
+
...realFs,
|
|
55
|
+
existsSync: (p: import('node:fs').PathLike) => {
|
|
56
|
+
const s = typeof p === 'string' ? p : p.toString();
|
|
57
|
+
if (s.endsWith('schema.sql')) return false;
|
|
58
|
+
return realFs.existsSync(p);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const { SQLiteStorage } = await import('../../../src/core/storage/sqlite.js');
|
|
64
|
+
expect(() => new SQLiteStorage(dbPath)).toThrow(/schema\.sql not found/);
|
|
65
|
+
|
|
66
|
+
// 验证未走旧 inline fallback:events 表不应存在
|
|
67
|
+
const raw = new Database(dbPath);
|
|
68
|
+
const eventsRow = raw
|
|
69
|
+
.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='events'`)
|
|
70
|
+
.get();
|
|
71
|
+
expect(eventsRow).toBeFalsy();
|
|
72
|
+
|
|
73
|
+
// sessions 表也不存在(schema.sql 完全没跑)
|
|
74
|
+
const sessionsRow = raw
|
|
75
|
+
.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='sessions'`)
|
|
76
|
+
.get();
|
|
77
|
+
expect(sessionsRow).toBeFalsy();
|
|
78
|
+
|
|
79
|
+
raw.close();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H2: SessionOperations 新增 aggregate / count / query 方法测试
|
|
3
|
+
*
|
|
4
|
+
* 覆盖 4 个方法:
|
|
5
|
+
* countAllSessions
|
|
6
|
+
* aggregateDailySessionCounts
|
|
7
|
+
* querySessionsByTimeRange
|
|
8
|
+
* countSessionsByRange
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
12
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { SQLiteStorage } from '../../../src/core/storage/sqlite.js';
|
|
16
|
+
import type { ForgeEvent } from '../../../src/core/types.js';
|
|
17
|
+
|
|
18
|
+
describe('SessionOperations H2 aggregates', () => {
|
|
19
|
+
let tmp: string;
|
|
20
|
+
let storage: SQLiteStorage;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
tmp = mkdtempSync(join(tmpdir(), 'forge-h2-sessions-'));
|
|
24
|
+
storage = new SQLiteStorage(join(tmp, 'data.db'));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
try { storage.close(); } catch { /* ignore */ }
|
|
29
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function makeEvent(overrides: Partial<ForgeEvent>): ForgeEvent {
|
|
33
|
+
return {
|
|
34
|
+
session_id: 's1',
|
|
35
|
+
project_path: '/tmp/proj',
|
|
36
|
+
timestamp: '2026-05-10T10:00:00.000Z',
|
|
37
|
+
hook_type: 'UserPromptSubmit',
|
|
38
|
+
user_prompt: 'hello',
|
|
39
|
+
...overrides,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('countAllSessions', () => {
|
|
44
|
+
it('空表返回 0', () => {
|
|
45
|
+
expect(storage.countAllSessions()).toBe(0);
|
|
46
|
+
});
|
|
47
|
+
it('多 session 返回总数', () => {
|
|
48
|
+
storage.writeEvent(makeEvent({ session_id: 'a' }));
|
|
49
|
+
storage.writeEvent(makeEvent({ session_id: 'b' }));
|
|
50
|
+
storage.writeEvent(makeEvent({ session_id: 'a' })); // same session, upsert
|
|
51
|
+
expect(storage.countAllSessions()).toBe(2);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('aggregateDailySessionCounts', () => {
|
|
56
|
+
it('按 date(start_time) 分组', () => {
|
|
57
|
+
storage.writeEvent(makeEvent({ session_id: 'a', timestamp: '2026-05-10T10:00:00.000Z' }));
|
|
58
|
+
storage.writeEvent(makeEvent({ session_id: 'b', timestamp: '2026-05-10T15:00:00.000Z' }));
|
|
59
|
+
storage.writeEvent(makeEvent({ session_id: 'c', timestamp: '2026-05-11T10:00:00.000Z' }));
|
|
60
|
+
const r = storage.aggregateDailySessionCounts({ since: '2026-05-01T00:00:00.000Z' });
|
|
61
|
+
expect(r).toEqual([
|
|
62
|
+
{ date: '2026-05-10', count: 2 },
|
|
63
|
+
{ date: '2026-05-11', count: 1 },
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
it('until 过滤排除上界', () => {
|
|
67
|
+
storage.writeEvent(makeEvent({ session_id: 'a', timestamp: '2026-05-10T10:00:00.000Z' }));
|
|
68
|
+
storage.writeEvent(makeEvent({ session_id: 'b', timestamp: '2026-05-20T10:00:00.000Z' }));
|
|
69
|
+
const r = storage.aggregateDailySessionCounts({
|
|
70
|
+
since: '2026-05-01T00:00:00.000Z',
|
|
71
|
+
until: '2026-05-15T00:00:00.000Z',
|
|
72
|
+
});
|
|
73
|
+
expect(r).toEqual([{ date: '2026-05-10', count: 1 }]);
|
|
74
|
+
});
|
|
75
|
+
it('空返回空数组', () => {
|
|
76
|
+
expect(storage.aggregateDailySessionCounts({ since: '2026-05-01T00:00:00.000Z' })).toEqual([]);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('querySessionsByTimeRange', () => {
|
|
81
|
+
it('按 start_time DESC,区间过滤', () => {
|
|
82
|
+
storage.writeEvent(makeEvent({ session_id: 'old', timestamp: '2026-05-01T10:00:00.000Z' }));
|
|
83
|
+
storage.writeEvent(makeEvent({ session_id: 'mid', timestamp: '2026-05-10T10:00:00.000Z' }));
|
|
84
|
+
storage.writeEvent(makeEvent({ session_id: 'new', timestamp: '2026-05-15T10:00:00.000Z' }));
|
|
85
|
+
const r = storage.querySessionsByTimeRange({ since: '2026-05-05T00:00:00.000Z' });
|
|
86
|
+
expect(r.length).toBe(2);
|
|
87
|
+
expect(r[0].session_id).toBe('new');
|
|
88
|
+
expect(r[1].session_id).toBe('mid');
|
|
89
|
+
});
|
|
90
|
+
it('暴露 first_prompt 字段', () => {
|
|
91
|
+
storage.writeEvent(makeEvent({
|
|
92
|
+
session_id: 'a',
|
|
93
|
+
timestamp: '2026-05-10T10:00:00.000Z',
|
|
94
|
+
user_prompt: 'hello world',
|
|
95
|
+
}));
|
|
96
|
+
const r = storage.querySessionsByTimeRange({ since: '2026-05-01T00:00:00.000Z' });
|
|
97
|
+
expect(r[0].first_prompt).toBe('hello world');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('countSessionsByRange', () => {
|
|
102
|
+
it('空表返回 0', () => {
|
|
103
|
+
expect(storage.countSessionsByRange({ since: '2026-05-01T00:00:00.000Z' })).toBe(0);
|
|
104
|
+
});
|
|
105
|
+
it('区间内 session 计数', () => {
|
|
106
|
+
storage.writeEvent(makeEvent({ session_id: 'a', timestamp: '2026-05-01T10:00:00.000Z' }));
|
|
107
|
+
storage.writeEvent(makeEvent({ session_id: 'b', timestamp: '2026-05-10T10:00:00.000Z' }));
|
|
108
|
+
storage.writeEvent(makeEvent({ session_id: 'c', timestamp: '2026-05-20T10:00:00.000Z' }));
|
|
109
|
+
expect(storage.countSessionsByRange({
|
|
110
|
+
since: '2026-05-05T00:00:00.000Z',
|
|
111
|
+
until: '2026-05-15T00:00:00.000Z',
|
|
112
|
+
})).toBe(1);
|
|
113
|
+
});
|
|
114
|
+
it('无 until 不限上界', () => {
|
|
115
|
+
storage.writeEvent(makeEvent({ session_id: 'a', timestamp: '2026-05-10T10:00:00.000Z' }));
|
|
116
|
+
storage.writeEvent(makeEvent({ session_id: 'b', timestamp: '2026-05-20T10:00:00.000Z' }));
|
|
117
|
+
expect(storage.countSessionsByRange({ since: '2026-05-01T00:00:00.000Z' })).toBe(2);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H2: SkillOperations 新增 count / query 方法测试
|
|
3
|
+
*
|
|
4
|
+
* 覆盖 4 个方法:
|
|
5
|
+
* countAllSkillInvocations
|
|
6
|
+
* countSkillInvocationsBySession
|
|
7
|
+
* countDistinctSkillsSince
|
|
8
|
+
* queryDistinctSkillIdsBySession
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
12
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { SQLiteStorage } from '../../../src/core/storage/sqlite.js';
|
|
16
|
+
import type { SkillInvocationRow } from '../../../src/core/storage/rows.js';
|
|
17
|
+
|
|
18
|
+
describe('SkillOperations H2 counts', () => {
|
|
19
|
+
let tmp: string;
|
|
20
|
+
let storage: SQLiteStorage;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
tmp = mkdtempSync(join(tmpdir(), 'forge-h2-skills-'));
|
|
24
|
+
storage = new SQLiteStorage(join(tmp, 'data.db'));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
try { storage.close(); } catch { /* ignore */ }
|
|
29
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function makeInv(overrides: Partial<SkillInvocationRow>): Omit<SkillInvocationRow, 'created_at'> {
|
|
33
|
+
return {
|
|
34
|
+
id: `inv-${Math.random().toString(36).slice(2, 10)}`,
|
|
35
|
+
route_request_id: null,
|
|
36
|
+
session_id: 's1',
|
|
37
|
+
agent_id: null,
|
|
38
|
+
skill_id: 'skill-a',
|
|
39
|
+
invocation_type: 'manual',
|
|
40
|
+
reason: null,
|
|
41
|
+
workflow: null,
|
|
42
|
+
phase: null,
|
|
43
|
+
feature_slug: null,
|
|
44
|
+
artifact_path: null,
|
|
45
|
+
depth: 0,
|
|
46
|
+
success: 1,
|
|
47
|
+
error: null,
|
|
48
|
+
timestamp: Date.now(),
|
|
49
|
+
...overrides,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe('countAllSkillInvocations', () => {
|
|
54
|
+
it('空表返回 0', () => {
|
|
55
|
+
expect(storage.countAllSkillInvocations()).toBe(0);
|
|
56
|
+
});
|
|
57
|
+
it('多条返回总数', () => {
|
|
58
|
+
storage.writeSkillInvocation(makeInv({ id: 'a' }));
|
|
59
|
+
storage.writeSkillInvocation(makeInv({ id: 'b' }));
|
|
60
|
+
storage.writeSkillInvocation(makeInv({ id: 'c' }));
|
|
61
|
+
expect(storage.countAllSkillInvocations()).toBe(3);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('countSkillInvocationsBySession', () => {
|
|
66
|
+
it('未匹配 session 返回 0', () => {
|
|
67
|
+
expect(storage.countSkillInvocationsBySession('nope')).toBe(0);
|
|
68
|
+
});
|
|
69
|
+
it('按 session_id 计数', () => {
|
|
70
|
+
storage.writeSkillInvocation(makeInv({ id: 'a', session_id: 's1' }));
|
|
71
|
+
storage.writeSkillInvocation(makeInv({ id: 'b', session_id: 's1' }));
|
|
72
|
+
storage.writeSkillInvocation(makeInv({ id: 'c', session_id: 's2' }));
|
|
73
|
+
expect(storage.countSkillInvocationsBySession('s1')).toBe(2);
|
|
74
|
+
expect(storage.countSkillInvocationsBySession('s2')).toBe(1);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('countDistinctSkillsSince', () => {
|
|
79
|
+
it('空表返回 0', () => {
|
|
80
|
+
expect(storage.countDistinctSkillsSince(0)).toBe(0);
|
|
81
|
+
});
|
|
82
|
+
it('distinct skill_id 计数,since 过滤', () => {
|
|
83
|
+
const now = Date.now();
|
|
84
|
+
storage.writeSkillInvocation(makeInv({ id: 'a', skill_id: 'x', timestamp: now }));
|
|
85
|
+
storage.writeSkillInvocation(makeInv({ id: 'b', skill_id: 'x', timestamp: now }));
|
|
86
|
+
storage.writeSkillInvocation(makeInv({ id: 'c', skill_id: 'y', timestamp: now }));
|
|
87
|
+
storage.writeSkillInvocation(makeInv({ id: 'd', skill_id: 'z', timestamp: now - 1_000_000 }));
|
|
88
|
+
expect(storage.countDistinctSkillsSince(now)).toBe(2); // x, y
|
|
89
|
+
expect(storage.countDistinctSkillsSince(0)).toBe(3); // x, y, z
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('queryDistinctSkillIdsBySession', () => {
|
|
94
|
+
it('未匹配返回空', () => {
|
|
95
|
+
expect(storage.queryDistinctSkillIdsBySession('nope')).toEqual([]);
|
|
96
|
+
});
|
|
97
|
+
it('按 session 返回 distinct skill_id', () => {
|
|
98
|
+
storage.writeSkillInvocation(makeInv({ id: 'a', session_id: 's1', skill_id: 'x' }));
|
|
99
|
+
storage.writeSkillInvocation(makeInv({ id: 'b', session_id: 's1', skill_id: 'x' }));
|
|
100
|
+
storage.writeSkillInvocation(makeInv({ id: 'c', session_id: 's1', skill_id: 'y' }));
|
|
101
|
+
storage.writeSkillInvocation(makeInv({ id: 'd', session_id: 's2', skill_id: 'z' }));
|
|
102
|
+
const r = storage.queryDistinctSkillIdsBySession('s1');
|
|
103
|
+
expect(r.sort()).toEqual(['x', 'y']);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H1 storage aggregates: skill_invocations
|
|
3
|
+
*
|
|
4
|
+
* 覆盖:
|
|
5
|
+
* - 空表返回 []
|
|
6
|
+
* - success=1/0 分别计数
|
|
7
|
+
* - 按 total 降序
|
|
8
|
+
* - since 过滤边界
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
12
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { SQLiteStorage } from '../../../src/core/storage/sqlite.js';
|
|
16
|
+
|
|
17
|
+
const SESSION = 'sess-s';
|
|
18
|
+
|
|
19
|
+
function makeInv(overrides: {
|
|
20
|
+
id: string;
|
|
21
|
+
skill_id: string;
|
|
22
|
+
success: 0 | 1;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
error?: string | null;
|
|
25
|
+
}) {
|
|
26
|
+
return {
|
|
27
|
+
id: overrides.id,
|
|
28
|
+
route_request_id: null,
|
|
29
|
+
session_id: SESSION,
|
|
30
|
+
agent_id: null,
|
|
31
|
+
skill_id: overrides.skill_id,
|
|
32
|
+
invocation_type: 'dynamic' as const,
|
|
33
|
+
reason: null,
|
|
34
|
+
workflow: null,
|
|
35
|
+
phase: null,
|
|
36
|
+
feature_slug: null,
|
|
37
|
+
artifact_path: null,
|
|
38
|
+
depth: 0,
|
|
39
|
+
success: overrides.success,
|
|
40
|
+
error: overrides.error ?? null,
|
|
41
|
+
timestamp: overrides.timestamp,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('storage.aggregateSkillInvocationsBySkill', () => {
|
|
46
|
+
let tmp: string;
|
|
47
|
+
let storage: SQLiteStorage;
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
tmp = mkdtempSync(join(tmpdir(), 'forge-h1-skills-'));
|
|
51
|
+
storage = new SQLiteStorage(join(tmp, 'data.db'));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterEach(() => {
|
|
55
|
+
try { storage.close(); } catch { /* ignore */ }
|
|
56
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('空表返回 []', () => {
|
|
60
|
+
expect(storage.aggregateSkillInvocationsBySkill({ since: 0 })).toEqual([]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('success=1/0 分别计数;按 total 降序', () => {
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
// tdd: 2 success + 1 failed = 3
|
|
66
|
+
storage.writeSkillInvocation(makeInv({ id: 'i1', skill_id: 'tdd', success: 1, timestamp: now }));
|
|
67
|
+
storage.writeSkillInvocation(makeInv({ id: 'i2', skill_id: 'tdd', success: 1, timestamp: now }));
|
|
68
|
+
storage.writeSkillInvocation(makeInv({ id: 'i3', skill_id: 'tdd', success: 0, timestamp: now, error: 'boom' }));
|
|
69
|
+
// debug: 1 success
|
|
70
|
+
storage.writeSkillInvocation(makeInv({ id: 'i4', skill_id: 'debug', success: 1, timestamp: now }));
|
|
71
|
+
|
|
72
|
+
const r = storage.aggregateSkillInvocationsBySkill({ since: 0 });
|
|
73
|
+
expect(r).toHaveLength(2);
|
|
74
|
+
// 排序:tdd 3 > debug 1
|
|
75
|
+
expect(r[0]).toEqual({ skill_id: 'tdd', total: 3, success: 2, failed: 1 });
|
|
76
|
+
expect(r[1]).toEqual({ skill_id: 'debug', total: 1, success: 1, failed: 0 });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('since 过滤(旧 invocation 被排除)', () => {
|
|
80
|
+
const old = Date.now() - 10 * 24 * 3600 * 1000;
|
|
81
|
+
const fresh = Date.now();
|
|
82
|
+
storage.writeSkillInvocation(makeInv({ id: 'old', skill_id: 'tdd', success: 1, timestamp: old }));
|
|
83
|
+
storage.writeSkillInvocation(makeInv({ id: 'new', skill_id: 'tdd', success: 1, timestamp: fresh }));
|
|
84
|
+
|
|
85
|
+
const sevenDaysAgo = Date.now() - 7 * 24 * 3600 * 1000;
|
|
86
|
+
const r = storage.aggregateSkillInvocationsBySkill({ since: sevenDaysAgo });
|
|
87
|
+
expect(r).toHaveLength(1);
|
|
88
|
+
expect(r[0]).toEqual({ skill_id: 'tdd', total: 1, success: 1, failed: 0 });
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('since 边界:>= 通过', () => {
|
|
92
|
+
storage.writeSkillInvocation(makeInv({ id: 'b1', skill_id: 'tdd', success: 1, timestamp: 1000 }));
|
|
93
|
+
storage.writeSkillInvocation(makeInv({ id: 'b2', skill_id: 'tdd', success: 1, timestamp: 2000 }));
|
|
94
|
+
|
|
95
|
+
const r1 = storage.aggregateSkillInvocationsBySkill({ since: 2000 });
|
|
96
|
+
expect(r1[0].total).toBe(1);
|
|
97
|
+
|
|
98
|
+
const r2 = storage.aggregateSkillInvocationsBySkill({ since: 1000 });
|
|
99
|
+
expect(r2[0].total).toBe(2);
|
|
100
|
+
|
|
101
|
+
const r3 = storage.aggregateSkillInvocationsBySkill({ since: 2001 });
|
|
102
|
+
expect(r3).toEqual([]);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -228,8 +228,8 @@ describe('SQLiteStorage - Characterization Tests (Pre-Refactor)', () => {
|
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
describe('Token Usage Operations', () => {
|
|
231
|
-
it('
|
|
232
|
-
storage.
|
|
231
|
+
it('writeTokenUsage and getTokenUsageBySession work correctly', () => {
|
|
232
|
+
storage.writeTokenUsage({
|
|
233
233
|
session_id: 'session-1',
|
|
234
234
|
input_tokens: 100,
|
|
235
235
|
output_tokens: 50,
|
|
@@ -243,7 +243,7 @@ describe('SQLiteStorage - Characterization Tests (Pre-Refactor)', () => {
|
|
|
243
243
|
});
|
|
244
244
|
|
|
245
245
|
it('listTokenUsage returns usage records', () => {
|
|
246
|
-
storage.
|
|
246
|
+
storage.writeTokenUsage({
|
|
247
247
|
session_id: 'session-1',
|
|
248
248
|
input_tokens: 100,
|
|
249
249
|
output_tokens: 50,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H2: TaskOperations 新增 countTasksByRange 方法测试
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
6
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
7
|
+
import { tmpdir } from 'node:os';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { SQLiteStorage } from '../../../src/core/storage/sqlite.js';
|
|
10
|
+
|
|
11
|
+
describe('TaskOperations H2: countTasksByRange', () => {
|
|
12
|
+
let tmp: string;
|
|
13
|
+
let storage: SQLiteStorage;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
tmp = mkdtempSync(join(tmpdir(), 'forge-h2-tasks-'));
|
|
17
|
+
storage = new SQLiteStorage(join(tmp, 'data.db'));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
try { storage.close(); } catch { /* ignore */ }
|
|
22
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('空表返回 0', () => {
|
|
26
|
+
expect(storage.countTasksByRange({ since: '2026-05-01T00:00:00.000Z' })).toBe(0);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('按 start_time 区间过滤', () => {
|
|
30
|
+
storage.writeTask({ id: 't1', session_id: 's1', title: 'old', start_time: '2026-05-01T10:00:00.000Z' });
|
|
31
|
+
storage.writeTask({ id: 't2', session_id: 's1', title: 'mid', start_time: '2026-05-10T10:00:00.000Z' });
|
|
32
|
+
storage.writeTask({ id: 't3', session_id: 's1', title: 'new', start_time: '2026-05-20T10:00:00.000Z' });
|
|
33
|
+
|
|
34
|
+
expect(storage.countTasksByRange({
|
|
35
|
+
since: '2026-05-05T00:00:00.000Z',
|
|
36
|
+
until: '2026-05-15T00:00:00.000Z',
|
|
37
|
+
})).toBe(1);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('无 until 不限上界', () => {
|
|
41
|
+
storage.writeTask({ id: 't1', session_id: 's1', title: 'a', start_time: '2026-05-10T10:00:00.000Z' });
|
|
42
|
+
storage.writeTask({ id: 't2', session_id: 's1', title: 'b', start_time: '2026-05-20T10:00:00.000Z' });
|
|
43
|
+
|
|
44
|
+
expect(storage.countTasksByRange({ since: '2026-05-01T00:00:00.000Z' })).toBe(2);
|
|
45
|
+
});
|
|
46
|
+
});
|