@winspan/claude-forge 8.54.3 → 9.2.0
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/DEVELOPMENT.md +649 -33
- package/README.md +155 -17
- package/dist/catalogs/agents.json +72 -0
- package/dist/catalogs/skills.json +194 -0
- package/dist/claudemd/claudemd-generator.d.ts +45 -45
- package/dist/claudemd/claudemd-generator.d.ts.map +1 -1
- package/dist/claudemd/claudemd-generator.js +128 -449
- package/dist/claudemd/claudemd-generator.js.map +1 -1
- package/dist/claudemd/index.d.ts +14 -4
- package/dist/claudemd/index.d.ts.map +1 -1
- package/dist/claudemd/index.js +15 -4
- package/dist/claudemd/index.js.map +1 -1
- package/dist/claudemd/resume-manager.d.ts.map +1 -1
- package/dist/claudemd/resume-manager.js +37 -9
- package/dist/claudemd/resume-manager.js.map +1 -1
- package/dist/claudemd/templates/swarm-protocol.md +35 -186
- package/dist/claudemd/violations-manager.d.ts +40 -0
- package/dist/claudemd/violations-manager.d.ts.map +1 -0
- package/dist/claudemd/violations-manager.js +106 -0
- package/dist/claudemd/violations-manager.js.map +1 -0
- package/dist/cli/commands/admin.d.ts +15 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +177 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cli/commands/agents.d.ts +18 -0
- package/dist/cli/commands/agents.d.ts.map +1 -0
- package/dist/cli/commands/agents.js +160 -0
- package/dist/cli/commands/agents.js.map +1 -0
- package/dist/cli/commands/bypass.d.ts +18 -0
- package/dist/cli/commands/bypass.d.ts.map +1 -0
- package/dist/cli/commands/bypass.js +87 -0
- package/dist/cli/commands/bypass.js.map +1 -0
- package/dist/cli/commands/claudemd.d.ts +60 -0
- package/dist/cli/commands/claudemd.d.ts.map +1 -1
- package/dist/cli/commands/claudemd.js +174 -37
- package/dist/cli/commands/claudemd.js.map +1 -1
- package/dist/cli/commands/config.d.ts.map +1 -1
- package/dist/cli/commands/config.js +94 -1
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/daemon.d.ts +39 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -1
- package/dist/cli/commands/daemon.js +167 -20
- package/dist/cli/commands/daemon.js.map +1 -1
- package/dist/cli/commands/decisions.d.ts +129 -0
- package/dist/cli/commands/decisions.d.ts.map +1 -0
- package/dist/cli/commands/decisions.js +669 -0
- package/dist/cli/commands/decisions.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +29 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +124 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/entropy.d.ts +35 -0
- package/dist/cli/commands/entropy.d.ts.map +1 -0
- package/dist/cli/commands/entropy.js +121 -0
- package/dist/cli/commands/entropy.js.map +1 -0
- package/dist/cli/commands/executions.d.ts +1 -0
- package/dist/cli/commands/executions.d.ts.map +1 -1
- package/dist/cli/commands/executions.js +10 -1
- package/dist/cli/commands/executions.js.map +1 -1
- package/dist/cli/commands/fix.d.ts +31 -0
- package/dist/cli/commands/fix.d.ts.map +1 -0
- package/dist/cli/commands/fix.js +108 -0
- package/dist/cli/commands/fix.js.map +1 -0
- package/dist/cli/commands/governance.d.ts +21 -0
- package/dist/cli/commands/governance.d.ts.map +1 -0
- package/dist/cli/commands/governance.js +60 -0
- package/dist/cli/commands/governance.js.map +1 -0
- package/dist/cli/commands/init.d.ts +27 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +158 -146
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/insights-goal-check.d.ts +50 -0
- package/dist/cli/commands/insights-goal-check.d.ts.map +1 -0
- package/dist/cli/commands/insights-goal-check.js +318 -0
- package/dist/cli/commands/insights-goal-check.js.map +1 -0
- package/dist/cli/commands/insights.d.ts +15 -0
- package/dist/cli/commands/insights.d.ts.map +1 -0
- package/dist/cli/commands/insights.js +127 -0
- package/dist/cli/commands/insights.js.map +1 -0
- package/dist/cli/commands/knowledge.d.ts +66 -0
- package/dist/cli/commands/knowledge.d.ts.map +1 -0
- package/dist/cli/commands/knowledge.js +897 -0
- package/dist/cli/commands/knowledge.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +0 -12
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +11 -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 +10 -184
- package/dist/cli/commands/menu.js.map +1 -1
- package/dist/cli/commands/project.d.ts +98 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/project.js +382 -0
- package/dist/cli/commands/project.js.map +1 -0
- package/dist/cli/commands/skills.d.ts.map +1 -1
- package/dist/cli/commands/skills.js +14 -128
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/commands/spec.d.ts +40 -0
- package/dist/cli/commands/spec.d.ts.map +1 -0
- package/dist/cli/commands/spec.js +49 -0
- package/dist/cli/commands/spec.js.map +1 -0
- package/dist/cli/commands/stats.d.ts.map +1 -1
- package/dist/cli/commands/stats.js +3 -2
- package/dist/cli/commands/stats.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +17 -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 +4 -9
- package/dist/cli/commands/trace.js.map +1 -1
- package/dist/cli/commands/violations.d.ts +14 -0
- package/dist/cli/commands/violations.d.ts.map +1 -0
- package/dist/cli/commands/violations.js +43 -0
- package/dist/cli/commands/violations.js.map +1 -0
- package/dist/cli/index.js +26 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/hook-manager.d.ts +1 -1
- package/dist/cli/init/hook-manager.d.ts.map +1 -1
- package/dist/cli/init/hook-manager.js +6 -0
- package/dist/cli/init/hook-manager.js.map +1 -1
- package/dist/cli/utils/resolve-session.d.ts +32 -0
- package/dist/cli/utils/resolve-session.d.ts.map +1 -0
- package/dist/cli/utils/resolve-session.js +39 -0
- package/dist/cli/utils/resolve-session.js.map +1 -0
- package/dist/core/config.d.ts +4 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +11 -23
- package/dist/core/config.js.map +1 -1
- package/dist/core/constants.d.ts +14 -13
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +20 -13
- package/dist/core/constants.js.map +1 -1
- package/dist/core/diagnostics/checks.d.ts +151 -0
- package/dist/core/diagnostics/checks.d.ts.map +1 -0
- package/dist/core/diagnostics/checks.js +765 -0
- package/dist/core/diagnostics/checks.js.map +1 -0
- package/dist/core/diagnostics/daemon-status.d.ts +77 -0
- package/dist/core/diagnostics/daemon-status.d.ts.map +1 -0
- package/dist/core/diagnostics/daemon-status.js +113 -0
- package/dist/core/diagnostics/daemon-status.js.map +1 -0
- package/dist/core/diagnostics/entropy-checks.d.ts +82 -0
- package/dist/core/diagnostics/entropy-checks.d.ts.map +1 -0
- package/dist/core/diagnostics/entropy-checks.js +395 -0
- package/dist/core/diagnostics/entropy-checks.js.map +1 -0
- package/dist/core/diagnostics/fix-runner.d.ts +54 -0
- package/dist/core/diagnostics/fix-runner.d.ts.map +1 -0
- package/dist/core/diagnostics/fix-runner.js +90 -0
- package/dist/core/diagnostics/fix-runner.js.map +1 -0
- package/dist/core/diagnostics/knip-runner.d.ts +49 -0
- package/dist/core/diagnostics/knip-runner.d.ts.map +1 -0
- package/dist/core/diagnostics/knip-runner.js +100 -0
- package/dist/core/diagnostics/knip-runner.js.map +1 -0
- package/dist/core/diagnostics/markers.d.ts +96 -0
- package/dist/core/diagnostics/markers.d.ts.map +1 -0
- package/dist/core/diagnostics/markers.js +153 -0
- package/dist/core/diagnostics/markers.js.map +1 -0
- package/dist/core/governance/global-inject.d.ts +60 -0
- package/dist/core/governance/global-inject.d.ts.map +1 -0
- package/dist/core/governance/global-inject.js +129 -0
- package/dist/core/governance/global-inject.js.map +1 -0
- package/dist/core/queue/index.d.ts +16 -3
- package/dist/core/queue/index.d.ts.map +1 -1
- package/dist/core/queue/index.js +14 -3
- package/dist/core/queue/index.js.map +1 -1
- package/dist/core/storage/base.d.ts +158 -0
- package/dist/core/storage/base.d.ts.map +1 -1
- package/dist/core/storage/base.js +570 -0
- package/dist/core/storage/base.js.map +1 -1
- package/dist/core/storage/codec/tool-input-codec.d.ts +93 -0
- package/dist/core/storage/codec/tool-input-codec.d.ts.map +1 -0
- package/dist/core/storage/codec/tool-input-codec.js +159 -0
- package/dist/core/storage/codec/tool-input-codec.js.map +1 -0
- package/dist/core/storage/decisions.d.ts +362 -0
- package/dist/core/storage/decisions.d.ts.map +1 -0
- package/dist/core/storage/decisions.js +502 -0
- package/dist/core/storage/decisions.js.map +1 -0
- package/dist/core/storage/events.d.ts +112 -8
- package/dist/core/storage/events.d.ts.map +1 -1
- package/dist/core/storage/events.js +390 -39
- package/dist/core/storage/events.js.map +1 -1
- package/dist/core/storage/feedback.d.ts +131 -0
- package/dist/core/storage/feedback.d.ts.map +1 -0
- package/dist/core/storage/feedback.js +187 -0
- package/dist/core/storage/feedback.js.map +1 -0
- package/dist/core/storage/forge-config.d.ts +40 -0
- package/dist/core/storage/forge-config.d.ts.map +1 -0
- package/dist/core/storage/forge-config.js +65 -0
- package/dist/core/storage/forge-config.js.map +1 -0
- package/dist/core/storage/injections.d.ts +28 -0
- package/dist/core/storage/injections.d.ts.map +1 -1
- package/dist/core/storage/injections.js +62 -5
- package/dist/core/storage/injections.js.map +1 -1
- package/dist/core/storage/knowledge.d.ts +106 -0
- package/dist/core/storage/knowledge.d.ts.map +1 -0
- package/dist/core/storage/knowledge.js +202 -0
- package/dist/core/storage/knowledge.js.map +1 -0
- package/dist/core/storage/maintenance.d.ts +36 -9
- package/dist/core/storage/maintenance.d.ts.map +1 -1
- package/dist/core/storage/maintenance.js +56 -24
- package/dist/core/storage/maintenance.js.map +1 -1
- package/dist/core/storage/pipeline-rollup.d.ts +117 -0
- package/dist/core/storage/pipeline-rollup.d.ts.map +1 -0
- package/dist/core/storage/pipeline-rollup.js +471 -0
- package/dist/core/storage/pipeline-rollup.js.map +1 -0
- package/dist/core/storage/routing.d.ts +16 -3
- package/dist/core/storage/routing.d.ts.map +1 -1
- package/dist/core/storage/routing.js +39 -8
- package/dist/core/storage/routing.js.map +1 -1
- package/dist/core/storage/rows.d.ts +50 -7
- package/dist/core/storage/rows.d.ts.map +1 -1
- package/dist/core/storage/schema.sql +302 -23
- package/dist/core/storage/sessions.d.ts +136 -0
- package/dist/core/storage/sessions.d.ts.map +1 -1
- package/dist/core/storage/sessions.js +351 -15
- package/dist/core/storage/sessions.js.map +1 -1
- package/dist/core/storage/skills.d.ts +1 -0
- package/dist/core/storage/skills.d.ts.map +1 -1
- package/dist/core/storage/skills.js +21 -6
- package/dist/core/storage/skills.js.map +1 -1
- package/dist/core/storage/sqlite.d.ts +253 -20
- package/dist/core/storage/sqlite.d.ts.map +1 -1
- package/dist/core/storage/sqlite.js +425 -16
- package/dist/core/storage/sqlite.js.map +1 -1
- package/dist/core/storage/tasks.d.ts +474 -2
- package/dist/core/storage/tasks.d.ts.map +1 -1
- package/dist/core/storage/tasks.js +1213 -18
- package/dist/core/storage/tasks.js.map +1 -1
- package/dist/core/storage/tool-intercepts.d.ts +69 -0
- package/dist/core/storage/tool-intercepts.d.ts.map +1 -0
- package/dist/core/storage/tool-intercepts.js +116 -0
- package/dist/core/storage/tool-intercepts.js.map +1 -0
- package/dist/core/storage/workflow-recommendations.d.ts +124 -0
- package/dist/core/storage/workflow-recommendations.d.ts.map +1 -0
- package/dist/core/storage/workflow-recommendations.js +274 -0
- package/dist/core/storage/workflow-recommendations.js.map +1 -0
- package/dist/core/types.d.ts +112 -17
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +12 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/utils/backup.d.ts +81 -0
- package/dist/core/utils/backup.d.ts.map +1 -0
- package/dist/core/utils/backup.js +98 -0
- package/dist/core/utils/backup.js.map +1 -0
- package/dist/core/utils/binary-paths.d.ts +92 -0
- package/dist/core/utils/binary-paths.d.ts.map +1 -0
- package/dist/core/utils/binary-paths.js +166 -0
- package/dist/core/utils/binary-paths.js.map +1 -0
- package/dist/core/utils/bypass-token.d.ts +75 -0
- package/dist/core/utils/bypass-token.d.ts.map +1 -0
- package/dist/core/utils/bypass-token.js +133 -0
- package/dist/core/utils/bypass-token.js.map +1 -0
- package/dist/core/utils/cc-builtin-agents.d.ts +3 -0
- package/dist/core/utils/cc-builtin-agents.d.ts.map +1 -0
- package/dist/core/utils/cc-builtin-agents.js +29 -0
- package/dist/core/utils/cc-builtin-agents.js.map +1 -0
- package/dist/core/utils/claude-cli-spawn.d.ts +106 -0
- package/dist/core/utils/claude-cli-spawn.d.ts.map +1 -0
- package/dist/core/utils/claude-cli-spawn.js +219 -0
- package/dist/core/utils/claude-cli-spawn.js.map +1 -0
- package/dist/core/utils/forge-resume-block.d.ts.map +1 -1
- package/dist/core/utils/forge-resume-block.js +3 -2
- package/dist/core/utils/forge-resume-block.js.map +1 -1
- package/dist/core/utils/logger.d.ts +15 -3
- package/dist/core/utils/logger.d.ts.map +1 -1
- package/dist/core/utils/logger.js +20 -2
- package/dist/core/utils/logger.js.map +1 -1
- package/dist/core/utils/noise-prompt.d.ts +97 -0
- package/dist/core/utils/noise-prompt.d.ts.map +1 -0
- package/dist/core/utils/noise-prompt.js +127 -0
- package/dist/core/utils/noise-prompt.js.map +1 -0
- package/dist/core/utils/path.d.ts +0 -4
- package/dist/core/utils/path.d.ts.map +1 -1
- package/dist/core/utils/path.js +0 -7
- package/dist/core/utils/path.js.map +1 -1
- package/dist/core/utils/time.d.ts +41 -0
- package/dist/core/utils/time.d.ts.map +1 -1
- package/dist/core/utils/time.js +114 -0
- package/dist/core/utils/time.js.map +1 -1
- package/dist/daemon/agent-sync.d.ts +24 -0
- package/dist/daemon/agent-sync.d.ts.map +1 -0
- package/dist/daemon/agent-sync.js +114 -0
- package/dist/daemon/agent-sync.js.map +1 -0
- package/dist/daemon/config-store.d.ts +55 -0
- package/dist/daemon/config-store.d.ts.map +1 -0
- package/dist/daemon/config-store.js +137 -0
- package/dist/daemon/config-store.js.map +1 -0
- package/dist/daemon/event-parser.d.ts +22 -0
- package/dist/daemon/event-parser.d.ts.map +1 -1
- package/dist/daemon/event-parser.js +49 -3
- package/dist/daemon/event-parser.js.map +1 -1
- package/dist/daemon/handlers/history-exporter.d.ts.map +1 -1
- package/dist/daemon/handlers/history-exporter.js +9 -8
- package/dist/daemon/handlers/history-exporter.js.map +1 -1
- package/dist/daemon/handlers/post-tool-use.d.ts +58 -4
- package/dist/daemon/handlers/post-tool-use.d.ts.map +1 -1
- package/dist/daemon/handlers/post-tool-use.js +261 -8
- package/dist/daemon/handlers/post-tool-use.js.map +1 -1
- package/dist/daemon/handlers/pre-tool-use.d.ts +156 -0
- package/dist/daemon/handlers/pre-tool-use.d.ts.map +1 -0
- package/dist/daemon/handlers/pre-tool-use.js +585 -0
- package/dist/daemon/handlers/pre-tool-use.js.map +1 -0
- package/dist/daemon/handlers/stop.d.ts +35 -7
- package/dist/daemon/handlers/stop.d.ts.map +1 -1
- package/dist/daemon/handlers/stop.js +157 -8
- package/dist/daemon/handlers/stop.js.map +1 -1
- package/dist/daemon/handlers/user-prompt.d.ts +36 -14
- package/dist/daemon/handlers/user-prompt.d.ts.map +1 -1
- package/dist/daemon/handlers/user-prompt.js +135 -48
- package/dist/daemon/handlers/user-prompt.js.map +1 -1
- package/dist/daemon/hook-sync.d.ts.map +1 -1
- package/dist/daemon/hook-sync.js +2 -1
- package/dist/daemon/hook-sync.js.map +1 -1
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +471 -43
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/lifecycle.d.ts +48 -1
- package/dist/daemon/lifecycle.d.ts.map +1 -1
- package/dist/daemon/lifecycle.js +98 -2
- package/dist/daemon/lifecycle.js.map +1 -1
- package/dist/daemon/router.d.ts +4 -1
- package/dist/daemon/router.d.ts.map +1 -1
- package/dist/daemon/router.js +4 -2
- package/dist/daemon/router.js.map +1 -1
- package/dist/daemon/rules/defaults.d.ts +20 -0
- package/dist/daemon/rules/defaults.d.ts.map +1 -0
- package/dist/daemon/rules/defaults.js +692 -0
- package/dist/daemon/rules/defaults.js.map +1 -0
- package/dist/daemon/rules/registry.d.ts +47 -0
- package/dist/daemon/rules/registry.d.ts.map +1 -0
- package/dist/daemon/rules/registry.js +84 -0
- package/dist/daemon/rules/registry.js.map +1 -0
- package/dist/daemon/rules/types.d.ts +170 -0
- package/dist/daemon/rules/types.d.ts.map +1 -0
- package/dist/daemon/rules/types.js +15 -0
- package/dist/daemon/rules/types.js.map +1 -0
- package/dist/daemon/rules/whitelist.d.ts +101 -0
- package/dist/daemon/rules/whitelist.d.ts.map +1 -0
- package/dist/daemon/rules/whitelist.js +210 -0
- package/dist/daemon/rules/whitelist.js.map +1 -0
- package/dist/daemon/rules/workflow-defaults.d.ts +52 -0
- package/dist/daemon/rules/workflow-defaults.d.ts.map +1 -0
- package/dist/daemon/rules/workflow-defaults.js +521 -0
- package/dist/daemon/rules/workflow-defaults.js.map +1 -0
- package/dist/daemon/server.d.ts +11 -1
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +7 -1
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/services/context-injector.d.ts +34 -0
- package/dist/daemon/services/context-injector.d.ts.map +1 -0
- package/dist/daemon/services/context-injector.js +61 -0
- package/dist/daemon/services/context-injector.js.map +1 -0
- package/dist/daemon/services/decision-hint.d.ts +203 -0
- package/dist/daemon/services/decision-hint.d.ts.map +1 -0
- package/dist/daemon/services/decision-hint.js +487 -0
- package/dist/daemon/services/decision-hint.js.map +1 -0
- package/dist/daemon/services/event-ttl-sweep.d.ts +86 -0
- package/dist/daemon/services/event-ttl-sweep.d.ts.map +1 -0
- package/dist/daemon/services/event-ttl-sweep.js +123 -0
- package/dist/daemon/services/event-ttl-sweep.js.map +1 -0
- package/dist/daemon/services/experience-extractor.d.ts +67 -0
- package/dist/daemon/services/experience-extractor.d.ts.map +1 -0
- package/dist/daemon/services/experience-extractor.js +323 -0
- package/dist/daemon/services/experience-extractor.js.map +1 -0
- package/dist/daemon/services/feedback-aggregator.d.ts +179 -0
- package/dist/daemon/services/feedback-aggregator.d.ts.map +1 -0
- package/dist/daemon/services/feedback-aggregator.js +455 -0
- package/dist/daemon/services/feedback-aggregator.js.map +1 -0
- package/dist/daemon/services/heartbeat-writer.d.ts +55 -0
- package/dist/daemon/services/heartbeat-writer.d.ts.map +1 -0
- package/dist/daemon/services/heartbeat-writer.js +111 -0
- package/dist/daemon/services/heartbeat-writer.js.map +1 -0
- package/dist/daemon/services/idle-session-sweeper.d.ts +61 -0
- package/dist/daemon/services/idle-session-sweeper.d.ts.map +1 -0
- package/dist/daemon/services/idle-session-sweeper.js +94 -0
- package/dist/daemon/services/idle-session-sweeper.js.map +1 -0
- package/dist/daemon/services/idle-task-budget.d.ts +50 -0
- package/dist/daemon/services/idle-task-budget.d.ts.map +1 -0
- package/dist/daemon/services/idle-task-budget.js +72 -0
- package/dist/daemon/services/idle-task-budget.js.map +1 -0
- package/dist/daemon/services/intercept-revive.d.ts +60 -0
- package/dist/daemon/services/intercept-revive.d.ts.map +1 -0
- package/dist/daemon/services/intercept-revive.js +86 -0
- package/dist/daemon/services/intercept-revive.js.map +1 -0
- package/dist/daemon/services/intercept-rollback-guard.d.ts +105 -0
- package/dist/daemon/services/intercept-rollback-guard.d.ts.map +1 -0
- package/dist/daemon/services/intercept-rollback-guard.js +152 -0
- package/dist/daemon/services/intercept-rollback-guard.js.map +1 -0
- package/dist/daemon/services/intercept-timeout-sweeper.d.ts +58 -0
- package/dist/daemon/services/intercept-timeout-sweeper.d.ts.map +1 -0
- package/dist/daemon/services/intercept-timeout-sweeper.js +83 -0
- package/dist/daemon/services/intercept-timeout-sweeper.js.map +1 -0
- package/dist/daemon/services/kb-injector.d.ts +57 -0
- package/dist/daemon/services/kb-injector.d.ts.map +1 -0
- package/dist/daemon/services/kb-injector.js +140 -0
- package/dist/daemon/services/kb-injector.js.map +1 -0
- package/dist/daemon/services/outcome-classification-service.d.ts +49 -0
- package/dist/daemon/services/outcome-classification-service.d.ts.map +1 -0
- package/dist/daemon/services/outcome-classification-service.js +214 -0
- package/dist/daemon/services/outcome-classification-service.js.map +1 -0
- package/dist/daemon/services/outcome-classifier.d.ts +136 -0
- package/dist/daemon/services/outcome-classifier.d.ts.map +1 -0
- package/dist/daemon/services/outcome-classifier.js +178 -0
- package/dist/daemon/services/outcome-classifier.js.map +1 -0
- package/dist/daemon/services/outcome-nudge.d.ts +107 -0
- package/dist/daemon/services/outcome-nudge.d.ts.map +1 -0
- package/dist/daemon/services/outcome-nudge.js +242 -0
- package/dist/daemon/services/outcome-nudge.js.map +1 -0
- package/dist/daemon/services/spec-approval.d.ts +127 -0
- package/dist/daemon/services/spec-approval.d.ts.map +1 -0
- package/dist/daemon/services/spec-approval.js +216 -0
- package/dist/daemon/services/spec-approval.js.map +1 -0
- package/dist/daemon/services/spec-gate.d.ts +54 -0
- package/dist/daemon/services/spec-gate.d.ts.map +1 -0
- package/dist/daemon/services/spec-gate.js +113 -0
- package/dist/daemon/services/spec-gate.js.map +1 -0
- package/dist/daemon/services/task-boundary-classifier.d.ts +78 -0
- package/dist/daemon/services/task-boundary-classifier.d.ts.map +1 -0
- package/dist/daemon/services/task-boundary-classifier.js +202 -0
- package/dist/daemon/services/task-boundary-classifier.js.map +1 -0
- package/dist/daemon/services/task-segmenter.d.ts +219 -1
- package/dist/daemon/services/task-segmenter.d.ts.map +1 -1
- package/dist/daemon/services/task-segmenter.js +481 -17
- package/dist/daemon/services/task-segmenter.js.map +1 -1
- package/dist/daemon/services/violation-reporter.d.ts +130 -0
- package/dist/daemon/services/violation-reporter.d.ts.map +1 -0
- package/dist/daemon/services/violation-reporter.js +339 -0
- package/dist/daemon/services/violation-reporter.js.map +1 -0
- package/dist/daemon/skill-sync.d.ts +7 -2
- package/dist/daemon/skill-sync.d.ts.map +1 -1
- package/dist/daemon/skill-sync.js +114 -9
- package/dist/daemon/skill-sync.js.map +1 -1
- package/dist/daemon/templates/agents/claudemd-writer.md +101 -0
- package/dist/daemon/templates/agents/coder.md +105 -0
- package/dist/daemon/templates/agents/decision-maker.md +460 -0
- package/dist/daemon/templates/agents/doc-reviewer.md +115 -0
- package/dist/daemon/templates/agents/harness-debug-full.md +114 -0
- package/dist/daemon/templates/agents/harness-hotfix.md +99 -0
- package/dist/daemon/templates/agents/hybrid-feature-with-safety.md +104 -0
- package/dist/daemon/templates/agents/knowledge-builder.md +119 -0
- package/dist/daemon/templates/agents/patch-applier.md +144 -0
- package/dist/daemon/templates/agents/planner.md +165 -0
- package/dist/daemon/templates/agents/refactor-specialist.md +98 -0
- package/dist/daemon/templates/agents/skill-distiller.md +113 -0
- package/dist/daemon/templates/agents/task-boundary-classifier.md +64 -0
- package/dist/daemon/templates/agents/verify-agent.md +136 -0
- package/dist/daemon/utils/inject-block.d.ts +39 -0
- package/dist/daemon/utils/inject-block.d.ts.map +1 -0
- package/dist/daemon/utils/inject-block.js +25 -0
- package/dist/daemon/utils/inject-block.js.map +1 -0
- package/dist/hooks/hook-lib.sh +8 -0
- package/dist/hooks/notification.sh +19 -8
- package/dist/hooks/post-tool-use.sh +41 -23
- package/dist/hooks/pre-tool-use.sh +54 -23
- package/dist/hooks/session-start.sh +68 -0
- package/dist/hooks/stop.sh +24 -10
- package/dist/hooks/user-prompt-submit.sh +37 -21
- package/dist/knowledge/adapters/go-adapter.d.ts +65 -0
- package/dist/knowledge/adapters/go-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/go-adapter.js +294 -0
- package/dist/knowledge/adapters/go-adapter.js.map +1 -0
- package/dist/knowledge/adapters/index.d.ts +41 -0
- package/dist/knowledge/adapters/index.d.ts.map +1 -0
- package/dist/knowledge/adapters/index.js +71 -0
- package/dist/knowledge/adapters/index.js.map +1 -0
- package/dist/knowledge/adapters/java-adapter.d.ts +66 -0
- package/dist/knowledge/adapters/java-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/java-adapter.js +260 -0
- package/dist/knowledge/adapters/java-adapter.js.map +1 -0
- package/dist/knowledge/adapters/js-vue-adapter.d.ts +56 -0
- package/dist/knowledge/adapters/js-vue-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/js-vue-adapter.js +203 -0
- package/dist/knowledge/adapters/js-vue-adapter.js.map +1 -0
- package/dist/knowledge/adapters/kotlin-adapter.d.ts +55 -0
- package/dist/knowledge/adapters/kotlin-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/kotlin-adapter.js +209 -0
- package/dist/knowledge/adapters/kotlin-adapter.js.map +1 -0
- package/dist/knowledge/adapters/monorepo-adapter.d.ts +77 -0
- package/dist/knowledge/adapters/monorepo-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/monorepo-adapter.js +170 -0
- package/dist/knowledge/adapters/monorepo-adapter.js.map +1 -0
- package/dist/knowledge/adapters/python-adapter.d.ts +89 -0
- package/dist/knowledge/adapters/python-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/python-adapter.js +358 -0
- package/dist/knowledge/adapters/python-adapter.js.map +1 -0
- package/dist/knowledge/adapters/rust-adapter.d.ts +73 -0
- package/dist/knowledge/adapters/rust-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/rust-adapter.js +329 -0
- package/dist/knowledge/adapters/rust-adapter.js.map +1 -0
- package/dist/knowledge/adapters/types.d.ts +99 -0
- package/dist/knowledge/adapters/types.d.ts.map +1 -0
- package/dist/knowledge/adapters/types.js +17 -0
- package/dist/knowledge/adapters/types.js.map +1 -0
- package/dist/knowledge/adapters/typescript-adapter.d.ts +57 -0
- package/dist/knowledge/adapters/typescript-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/typescript-adapter.js +171 -0
- package/dist/knowledge/adapters/typescript-adapter.js.map +1 -0
- package/dist/knowledge/audit-applier.d.ts +70 -0
- package/dist/knowledge/audit-applier.d.ts.map +1 -0
- package/dist/knowledge/audit-applier.js +251 -0
- package/dist/knowledge/audit-applier.js.map +1 -0
- package/dist/knowledge/builder.d.ts +261 -0
- package/dist/knowledge/builder.d.ts.map +1 -0
- package/dist/knowledge/builder.js +937 -0
- package/dist/knowledge/builder.js.map +1 -0
- package/dist/knowledge/cli-provider.d.ts +151 -0
- package/dist/knowledge/cli-provider.d.ts.map +1 -0
- package/dist/knowledge/cli-provider.js +313 -0
- package/dist/knowledge/cli-provider.js.map +1 -0
- package/dist/knowledge/constants.d.ts +73 -0
- package/dist/knowledge/constants.d.ts.map +1 -0
- package/dist/knowledge/constants.js +93 -0
- package/dist/knowledge/constants.js.map +1 -0
- package/dist/knowledge/cross-module.d.ts +139 -0
- package/dist/knowledge/cross-module.d.ts.map +1 -0
- package/dist/knowledge/cross-module.js +370 -0
- package/dist/knowledge/cross-module.js.map +1 -0
- package/dist/knowledge/git-hooks.d.ts +67 -0
- package/dist/knowledge/git-hooks.d.ts.map +1 -0
- package/dist/knowledge/git-hooks.js +258 -0
- package/dist/knowledge/git-hooks.js.map +1 -0
- package/dist/knowledge/module-hash.d.ts +88 -0
- package/dist/knowledge/module-hash.d.ts.map +1 -0
- package/dist/knowledge/module-hash.js +162 -0
- package/dist/knowledge/module-hash.js.map +1 -0
- package/dist/knowledge/project-detector.d.ts +101 -0
- package/dist/knowledge/project-detector.d.ts.map +1 -0
- package/dist/knowledge/project-detector.js +223 -0
- package/dist/knowledge/project-detector.js.map +1 -0
- package/dist/knowledge/prompt.d.ts +228 -0
- package/dist/knowledge/prompt.d.ts.map +1 -0
- package/dist/knowledge/prompt.js +404 -0
- package/dist/knowledge/prompt.js.map +1 -0
- package/dist/knowledge/query.d.ts +105 -0
- package/dist/knowledge/query.d.ts.map +1 -0
- package/dist/knowledge/query.js +341 -0
- package/dist/knowledge/query.js.map +1 -0
- package/dist/knowledge/repo-map.d.ts +91 -0
- package/dist/knowledge/repo-map.d.ts.map +1 -0
- package/dist/knowledge/repo-map.js +408 -0
- package/dist/knowledge/repo-map.js.map +1 -0
- package/dist/knowledge/tools/index.d.ts +14 -0
- package/dist/knowledge/tools/index.d.ts.map +1 -0
- package/dist/knowledge/tools/index.js +11 -0
- package/dist/knowledge/tools/index.js.map +1 -0
- package/dist/knowledge/tools/knowledge-get-page.d.ts +46 -0
- package/dist/knowledge/tools/knowledge-get-page.d.ts.map +1 -0
- package/dist/knowledge/tools/knowledge-get-page.js +101 -0
- package/dist/knowledge/tools/knowledge-get-page.js.map +1 -0
- package/dist/knowledge/tools/knowledge-query.d.ts +77 -0
- package/dist/knowledge/tools/knowledge-query.d.ts.map +1 -0
- package/dist/knowledge/tools/knowledge-query.js +104 -0
- package/dist/knowledge/tools/knowledge-query.js.map +1 -0
- package/dist/knowledge/tools/repo-map-lookup.d.ts +45 -0
- package/dist/knowledge/tools/repo-map-lookup.d.ts.map +1 -0
- package/dist/knowledge/tools/repo-map-lookup.js +82 -0
- package/dist/knowledge/tools/repo-map-lookup.js.map +1 -0
- package/dist/knowledge/types.d.ts +269 -0
- package/dist/knowledge/types.d.ts.map +1 -0
- package/dist/knowledge/types.js +10 -0
- package/dist/knowledge/types.js.map +1 -0
- package/dist/knowledge/validator.d.ts +90 -0
- package/dist/knowledge/validator.d.ts.map +1 -0
- package/dist/knowledge/validator.js +288 -0
- package/dist/knowledge/validator.js.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +222 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/skills/builtin-skills.d.ts +35 -0
- package/dist/skills/builtin-skills.d.ts.map +1 -0
- package/dist/skills/builtin-skills.js +68 -0
- package/dist/skills/builtin-skills.js.map +1 -0
- package/dist/skills/distill/attribution.d.ts +59 -0
- package/dist/skills/distill/attribution.d.ts.map +1 -0
- package/dist/skills/distill/attribution.js +101 -0
- package/dist/skills/distill/attribution.js.map +1 -0
- package/dist/skills/distill/claude-cli-resolver.d.ts +26 -0
- package/dist/skills/distill/claude-cli-resolver.d.ts.map +1 -0
- package/dist/skills/distill/claude-cli-resolver.js +115 -0
- package/dist/skills/distill/claude-cli-resolver.js.map +1 -0
- package/dist/skills/distill/distiller.d.ts +161 -0
- package/dist/skills/distill/distiller.d.ts.map +1 -0
- package/dist/skills/distill/distiller.js +461 -0
- package/dist/skills/distill/distiller.js.map +1 -0
- package/dist/skills/distill/index.d.ts +223 -0
- package/dist/skills/distill/index.d.ts.map +1 -0
- package/dist/skills/distill/index.js +466 -0
- package/dist/skills/distill/index.js.map +1 -0
- package/dist/skills/distill/project-anchor-guard.d.ts +116 -0
- package/dist/skills/distill/project-anchor-guard.d.ts.map +1 -0
- package/dist/skills/distill/project-anchor-guard.js +334 -0
- package/dist/skills/distill/project-anchor-guard.js.map +1 -0
- package/dist/skills/distill/topic-deduper.d.ts +77 -0
- package/dist/skills/distill/topic-deduper.d.ts.map +1 -0
- package/dist/skills/distill/topic-deduper.js +119 -0
- package/dist/skills/distill/topic-deduper.js.map +1 -0
- package/dist/skills/distill/upstream-fetcher.d.ts +71 -0
- package/dist/skills/distill/upstream-fetcher.d.ts.map +1 -0
- package/dist/skills/distill/upstream-fetcher.js +202 -0
- package/dist/skills/distill/upstream-fetcher.js.map +1 -0
- package/dist/skills/distilled/distilled-api-design.md +491 -0
- package/dist/skills/distilled/distilled-architecture-decision.md +173 -0
- package/dist/skills/distilled/distilled-creator.md +178 -0
- package/dist/skills/distilled/distilled-db-schema-design.md +245 -0
- package/dist/skills/distilled/distilled-defi-amm-security.md +293 -0
- package/dist/skills/distilled/distilled-executing-plans.md +113 -0
- package/dist/skills/distilled/distilled-harness-engineering.md +242 -0
- package/dist/skills/distilled/distilled-karpathy-guidelines.md +104 -0
- package/dist/skills/distilled/distilled-performance-optimization.md +175 -0
- package/dist/skills/distilled/distilled-spec-driven-design.md +193 -0
- package/dist/skills/distilled/distilled-systematic-debugging.md +306 -0
- package/dist/skills/distilled/distilled-verification-before-completion.md +203 -0
- package/dist/skills/keyword-score.d.ts +29 -0
- package/dist/skills/keyword-score.d.ts.map +1 -0
- package/dist/skills/keyword-score.js +54 -0
- package/dist/skills/keyword-score.js.map +1 -0
- package/dist/skills/registry.d.ts +64 -20
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +102 -105
- package/dist/skills/registry.js.map +1 -1
- package/dist/skills/tools/pipeline-suggest.js +14 -14
- package/dist/skills/tools/skill-invoke.d.ts +1 -1
- package/dist/skills/tools/skill-invoke.js +1 -1
- package/dist/web/routes/agent-content.d.ts +30 -0
- package/dist/web/routes/agent-content.d.ts.map +1 -0
- package/dist/web/routes/agent-content.js +139 -0
- package/dist/web/routes/agent-content.js.map +1 -0
- package/dist/web/routes/decisions.d.ts +15 -0
- package/dist/web/routes/decisions.d.ts.map +1 -0
- package/dist/web/routes/decisions.js +181 -0
- package/dist/web/routes/decisions.js.map +1 -0
- package/dist/web/routes/diagnostics.d.ts +61 -0
- package/dist/web/routes/diagnostics.d.ts.map +1 -0
- package/dist/web/routes/diagnostics.js +203 -0
- package/dist/web/routes/diagnostics.js.map +1 -0
- package/dist/web/routes/events.d.ts.map +1 -1
- package/dist/web/routes/events.js +24 -0
- package/dist/web/routes/events.js.map +1 -1
- package/dist/web/routes/health.d.ts +33 -0
- package/dist/web/routes/health.d.ts.map +1 -0
- package/dist/web/routes/health.js +37 -0
- package/dist/web/routes/health.js.map +1 -0
- package/dist/web/routes/insights.d.ts +0 -5
- package/dist/web/routes/insights.d.ts.map +1 -1
- package/dist/web/routes/insights.js +783 -2
- package/dist/web/routes/insights.js.map +1 -1
- package/dist/web/routes/knowledge.d.ts +16 -0
- package/dist/web/routes/knowledge.d.ts.map +1 -0
- package/dist/web/routes/knowledge.js +661 -0
- package/dist/web/routes/knowledge.js.map +1 -0
- package/dist/web/routes/patch.d.ts +60 -1
- package/dist/web/routes/patch.d.ts.map +1 -1
- package/dist/web/routes/patch.js +170 -64
- package/dist/web/routes/patch.js.map +1 -1
- package/dist/web/routes/pipeline.d.ts +37 -0
- package/dist/web/routes/pipeline.d.ts.map +1 -0
- package/dist/web/routes/pipeline.js +149 -0
- package/dist/web/routes/pipeline.js.map +1 -0
- package/dist/web/routes/rules.d.ts.map +1 -1
- package/dist/web/routes/rules.js +6 -1
- 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 +9 -1
- package/dist/web/routes/sessions.js.map +1 -1
- package/dist/web/routes/skill-content.d.ts +30 -0
- package/dist/web/routes/skill-content.d.ts.map +1 -0
- package/dist/web/routes/skill-content.js +117 -0
- package/dist/web/routes/skill-content.js.map +1 -0
- package/dist/web/routes/skills-distill.d.ts +29 -0
- package/dist/web/routes/skills-distill.d.ts.map +1 -0
- package/dist/web/routes/skills-distill.js +552 -0
- package/dist/web/routes/skills-distill.js.map +1 -0
- package/dist/web/routes/skills.js +7 -7
- package/dist/web/routes/skills.js.map +1 -1
- package/dist/web/routes/task-timeline.d.ts +102 -0
- package/dist/web/routes/task-timeline.d.ts.map +1 -0
- package/dist/web/routes/task-timeline.js +274 -0
- package/dist/web/routes/task-timeline.js.map +1 -0
- package/dist/web/routes/tasks.d.ts.map +1 -1
- package/dist/web/routes/tasks.js +355 -8
- 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 +3 -2
- package/dist/web/routes/trace.js.map +1 -1
- package/dist/web/routes/types.d.ts +0 -4
- package/dist/web/routes/types.d.ts.map +1 -1
- package/dist/web/routes/types.js +1 -1
- package/dist/web/routes/types.js.map +1 -1
- package/dist/web/routes/violations.d.ts +14 -0
- package/dist/web/routes/violations.d.ts.map +1 -0
- package/dist/web/routes/violations.js +111 -0
- package/dist/web/routes/violations.js.map +1 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +79 -19
- package/dist/web/server.js.map +1 -1
- package/dist/web/services/build-manager.d.ts +72 -0
- package/dist/web/services/build-manager.d.ts.map +1 -0
- package/dist/web/services/build-manager.js +189 -0
- package/dist/web/services/build-manager.js.map +1 -0
- package/dist/web/services/distill-manager.d.ts +125 -0
- package/dist/web/services/distill-manager.d.ts.map +1 -0
- package/dist/web/services/distill-manager.js +308 -0
- package/dist/web/services/distill-manager.js.map +1 -0
- package/dist/web/static/assets/AgentContentPage-DkeRNxok.js +2 -0
- package/dist/web/static/assets/AgentContentPage-DkeRNxok.js.map +1 -0
- package/dist/web/static/assets/AgentDelegationTable-ByBa0x1l.js +2 -0
- package/dist/web/static/assets/AgentDelegationTable-ByBa0x1l.js.map +1 -0
- package/dist/web/static/assets/ContextInsightsPage-oUk7_I8u.js +3 -0
- package/dist/web/static/assets/ContextInsightsPage-oUk7_I8u.js.map +1 -0
- package/dist/web/static/assets/DaemonHealthPage-DG2fyOP7.js +2 -0
- package/dist/web/static/assets/DaemonHealthPage-DG2fyOP7.js.map +1 -0
- package/dist/web/static/assets/DecisionsPage-CMAPEnKb.js +2 -0
- package/dist/web/static/assets/DecisionsPage-CMAPEnKb.js.map +1 -0
- package/dist/web/static/assets/DiagnosticsPage-DQd-Zm4r.js +2 -0
- package/dist/web/static/assets/DiagnosticsPage-DQd-Zm4r.js.map +1 -0
- package/dist/web/static/assets/DriftTab-DqpepOhI.js +2 -0
- package/dist/web/static/assets/DriftTab-DqpepOhI.js.map +1 -0
- package/dist/web/static/assets/HealthHomePage-CN6zNIie.js +3 -0
- package/dist/web/static/assets/HealthHomePage-CN6zNIie.js.map +1 -0
- package/dist/web/static/assets/KbHitRateTable-ByEIWujF.js +2 -0
- package/dist/web/static/assets/KbHitRateTable-ByEIWujF.js.map +1 -0
- package/dist/web/static/assets/MarkdownRenderer-DZmTl-8J.js +3 -0
- package/dist/web/static/assets/MarkdownRenderer-DZmTl-8J.js.map +1 -0
- package/dist/web/static/assets/NotFound-BQPh0vaF.js +2 -0
- package/dist/web/static/assets/NotFound-BQPh0vaF.js.map +1 -0
- package/dist/web/static/assets/ProjectSwitcher-D3lZMFd3.js +2 -0
- package/dist/web/static/assets/ProjectSwitcher-D3lZMFd3.js.map +1 -0
- package/dist/web/static/assets/SettingsPage-oLJBNzQj.js +2 -0
- package/dist/web/static/assets/SettingsPage-oLJBNzQj.js.map +1 -0
- package/dist/web/static/assets/SkillContentPage-DK5rgfgw.js +2 -0
- package/dist/web/static/assets/SkillContentPage-DK5rgfgw.js.map +1 -0
- package/dist/web/static/assets/SkillStatsTable-DYMzjEUV.js +2 -0
- package/dist/web/static/assets/SkillStatsTable-DYMzjEUV.js.map +1 -0
- package/dist/web/static/assets/SkillsDistillTab-C7qaG8q3.js +2 -0
- package/dist/web/static/assets/SkillsDistillTab-C7qaG8q3.js.map +1 -0
- package/dist/web/static/assets/TasksHubPage-03wsRRsJ.js +6 -0
- package/dist/web/static/assets/TasksHubPage-03wsRRsJ.js.map +1 -0
- package/dist/web/static/assets/ViolationsPage-DSiLr-9O.js +3 -0
- package/dist/web/static/assets/ViolationsPage-DSiLr-9O.js.map +1 -0
- package/dist/web/static/assets/arco-Bhi3a6Qp.js +14 -0
- package/dist/web/static/assets/arco-Bhi3a6Qp.js.map +1 -0
- package/dist/web/static/assets/arco-DFQA6dO_.css +1 -0
- package/dist/web/static/assets/charts-BuHQWDbQ.js +37 -0
- package/dist/web/static/assets/charts-BuHQWDbQ.js.map +1 -0
- package/dist/web/static/assets/date-fns-sbWH3_uq.js +2 -0
- package/dist/web/static/assets/date-fns-sbWH3_uq.js.map +1 -0
- package/dist/web/static/assets/index-7bl3kbcx.css +1 -0
- package/dist/web/static/assets/index-BIYnq1Dx.js +4 -0
- package/dist/web/static/assets/index-BIYnq1Dx.js.map +1 -0
- package/dist/web/static/assets/lucide-CnlPQoG8.js +72 -0
- package/dist/web/static/assets/lucide-CnlPQoG8.js.map +1 -0
- package/dist/web/static/assets/outcome-DUn1NjlC.js +2 -0
- package/dist/web/static/assets/outcome-DUn1NjlC.js.map +1 -0
- package/dist/web/static/assets/query-S6X1S7K9.js +2 -0
- package/dist/web/static/assets/{query-C99w429o.js.map → query-S6X1S7K9.js.map} +1 -1
- package/dist/web/static/assets/{react-router-r79dBVy4.js → react-router-JVUrkhdd.js} +3 -3
- package/dist/web/static/assets/{react-router-r79dBVy4.js.map → react-router-JVUrkhdd.js.map} +1 -1
- package/dist/web/static/assets/react-vendor-tkvCrao7.js +57 -0
- package/dist/web/static/assets/react-vendor-tkvCrao7.js.map +1 -0
- package/dist/web/static/assets/syntax-highlighter-BkZfCDsz.js +6 -0
- package/dist/web/static/assets/syntax-highlighter-BkZfCDsz.js.map +1 -0
- package/dist/web/static/assets/useTabsParam-k8qte_0C.js +2 -0
- package/dist/web/static/assets/useTabsParam-k8qte_0C.js.map +1 -0
- package/dist/web/static/assets/vendor-DWgdB1eY.js +65 -0
- package/dist/web/static/assets/vendor-DWgdB1eY.js.map +1 -0
- package/dist/web/static/index.html +12 -8
- package/package.json +14 -3
- package/dist/core/ai/provider.d.ts +0 -63
- package/dist/core/ai/provider.d.ts.map +0 -1
- package/dist/core/ai/provider.js +0 -241
- package/dist/core/ai/provider.js.map +0 -1
- package/dist/core/ai/types.d.ts +0 -43
- package/dist/core/ai/types.d.ts.map +0 -1
- package/dist/core/ai/types.js +0 -5
- package/dist/core/ai/types.js.map +0 -1
- package/dist/core/storage/token-usage.d.ts +0 -36
- package/dist/core/storage/token-usage.d.ts.map +0 -1
- package/dist/core/storage/token-usage.js +0 -59
- package/dist/core/storage/token-usage.js.map +0 -1
- package/dist/core/utils/token-tracker.d.ts +0 -39
- package/dist/core/utils/token-tracker.d.ts.map +0 -1
- package/dist/core/utils/token-tracker.js +0 -69
- package/dist/core/utils/token-tracker.js.map +0 -1
- package/dist/skills/index.d.ts +0 -3
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/index.js +0 -3
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/matcher.d.ts +0 -26
- package/dist/skills/matcher.d.ts.map +0 -1
- package/dist/skills/matcher.js +0 -113
- package/dist/skills/matcher.js.map +0 -1
- package/dist/skills/official/code-simplifier.md +0 -52
- package/dist/skills/official/find-skills.md +0 -142
- package/dist/skills/official/official-api-design.md +0 -30
- package/dist/skills/official/official-architecture-decision.md +0 -41
- package/dist/skills/official/official-bmad.md +0 -118
- package/dist/skills/official/official-db-schema-design.md +0 -34
- package/dist/skills/official/official-debug.md +0 -25
- package/dist/skills/official/official-doc-driven.md +0 -31
- package/dist/skills/official/official-harness-engineering.md +0 -108
- package/dist/skills/official/official-performance-optimization.md +0 -30
- package/dist/skills/official/official-pr-review.md +0 -35
- package/dist/skills/official/official-release-checklist.md +0 -30
- package/dist/skills/official/official-security-hardening.md +0 -32
- package/dist/skills/official/official-spec-driven-design.md +0 -31
- package/dist/skills/official/planning-with-files.md +0 -241
- package/dist/skills/official/ui-ux-pro-max.md +0 -105
- package/dist/skills/official/webapp-testing.md +0 -96
- package/dist/skills/official-skills.d.ts +0 -26
- package/dist/skills/official-skills.d.ts.map +0 -1
- package/dist/skills/official-skills.js +0 -73
- package/dist/skills/official-skills.js.map +0 -1
- package/dist/skills/semantic-matcher.d.ts +0 -60
- package/dist/skills/semantic-matcher.d.ts.map +0 -1
- package/dist/skills/semantic-matcher.js +0 -192
- package/dist/skills/semantic-matcher.js.map +0 -1
- package/dist/skills/upgrade-engine.d.ts +0 -93
- package/dist/skills/upgrade-engine.d.ts.map +0 -1
- package/dist/skills/upgrade-engine.js +0 -447
- package/dist/skills/upgrade-engine.js.map +0 -1
- package/dist/skills/upgrade-prompt.d.ts +0 -20
- package/dist/skills/upgrade-prompt.d.ts.map +0 -1
- package/dist/skills/upgrade-prompt.js +0 -75
- package/dist/skills/upgrade-prompt.js.map +0 -1
- package/dist/web/routes/ai.d.ts +0 -10
- package/dist/web/routes/ai.d.ts.map +0 -1
- package/dist/web/routes/ai.js +0 -186
- package/dist/web/routes/ai.js.map +0 -1
- package/dist/web/routes/token-usage.d.ts +0 -7
- package/dist/web/routes/token-usage.d.ts.map +0 -1
- package/dist/web/routes/token-usage.js +0 -18
- package/dist/web/routes/token-usage.js.map +0 -1
- package/dist/web/ssrf-guard.d.ts +0 -35
- package/dist/web/ssrf-guard.d.ts.map +0 -1
- package/dist/web/ssrf-guard.js +0 -93
- package/dist/web/ssrf-guard.js.map +0 -1
- package/dist/web/static/assets/AIConfig-CdDWzJyO.js +0 -2
- package/dist/web/static/assets/AIConfig-CdDWzJyO.js.map +0 -1
- package/dist/web/static/assets/Dashboard-CoEmmIDt.js +0 -2
- package/dist/web/static/assets/Dashboard-CoEmmIDt.js.map +0 -1
- package/dist/web/static/assets/Drawer-DdRTzlLB.js +0 -2
- package/dist/web/static/assets/Drawer-DdRTzlLB.js.map +0 -1
- package/dist/web/static/assets/Events-DrIq1SUS.js +0 -2
- package/dist/web/static/assets/Events-DrIq1SUS.js.map +0 -1
- package/dist/web/static/assets/Reports-DFBM3MDK.js +0 -2
- package/dist/web/static/assets/Reports-DFBM3MDK.js.map +0 -1
- package/dist/web/static/assets/SearchInput-qCj_jAcf.js +0 -2
- package/dist/web/static/assets/SearchInput-qCj_jAcf.js.map +0 -1
- package/dist/web/static/assets/SessionDetail-CCzwdoT7.js +0 -2
- package/dist/web/static/assets/SessionDetail-CCzwdoT7.js.map +0 -1
- package/dist/web/static/assets/Sessions-FfLYkAw9.js +0 -2
- package/dist/web/static/assets/Sessions-FfLYkAw9.js.map +0 -1
- package/dist/web/static/assets/Skills-C8Gvs3Qa.js +0 -2
- package/dist/web/static/assets/Skills-C8Gvs3Qa.js.map +0 -1
- package/dist/web/static/assets/TaskDetail-BS8pYhaR.js +0 -2
- package/dist/web/static/assets/TaskDetail-BS8pYhaR.js.map +0 -1
- package/dist/web/static/assets/Tasks-CyuhizG8.js +0 -2
- package/dist/web/static/assets/Tasks-CyuhizG8.js.map +0 -1
- package/dist/web/static/assets/charts-CLrM0_uM.js +0 -37
- package/dist/web/static/assets/charts-CLrM0_uM.js.map +0 -1
- package/dist/web/static/assets/date-fns-CZ_bHujz.js +0 -2
- package/dist/web/static/assets/date-fns-CZ_bHujz.js.map +0 -1
- package/dist/web/static/assets/export-L_VBD2p1.js +0 -4
- package/dist/web/static/assets/export-L_VBD2p1.js.map +0 -1
- package/dist/web/static/assets/index-CBX47X8l.js +0 -3
- package/dist/web/static/assets/index-CBX47X8l.js.map +0 -1
- package/dist/web/static/assets/index-DjIoMdoR.css +0 -1
- package/dist/web/static/assets/lucide-Bs_edTLa.js +0 -232
- package/dist/web/static/assets/lucide-Bs_edTLa.js.map +0 -1
- package/dist/web/static/assets/query-C99w429o.js +0 -2
- package/dist/web/static/assets/react-vendor-CSp-GLFF.js +0 -49
- package/dist/web/static/assets/react-vendor-CSp-GLFF.js.map +0 -1
- package/dist/web/static/assets/syntax-highlighter-44FakypI.js +0 -9
- package/dist/web/static/assets/syntax-highlighter-44FakypI.js.map +0 -1
- package/dist/web/static/assets/task-title-BhOcemuR.js +0 -2
- package/dist/web/static/assets/task-title-BhOcemuR.js.map +0 -1
- package/dist/web/static/assets/time-Bxuk0M-C.js +0 -2
- package/dist/web/static/assets/time-Bxuk0M-C.js.map +0 -1
- package/dist/web/static/assets/vendor-CMMjVdZs.js +0 -64
- package/dist/web/static/assets/vendor-CMMjVdZs.js.map +0 -1
|
@@ -25,6 +25,20 @@ export class SQLiteBase {
|
|
|
25
25
|
mkdirSync(dir, { recursive: true });
|
|
26
26
|
}
|
|
27
27
|
this.db = new Database(dbPath);
|
|
28
|
+
// ── Bootstrap PRAGMAs ─────────────────────────────────────────────────
|
|
29
|
+
//
|
|
30
|
+
// auto_vacuum MUST be set BEFORE any table is created on a new DB
|
|
31
|
+
// (SQLite requirement: see https://sqlite.org/pragma.html#pragma_auto_vacuum).
|
|
32
|
+
// On a fresh DB this sets the persistent header bit; on an existing DB it
|
|
33
|
+
// is a no-op and the conversion has to happen via VACUUM (handled below
|
|
34
|
+
// in `migrateAutoVacuumIfNeeded`).
|
|
35
|
+
//
|
|
36
|
+
// INCREMENTAL (=2) means free pages are kept on a freelist instead of
|
|
37
|
+
// being released at the OS level, and the daemon's TTL sweep can call
|
|
38
|
+
// `PRAGMA incremental_vacuum(N)` to reclaim N pages at a time without
|
|
39
|
+
// a full-table VACUUM. NONE (=0, the prior default) caused freelist
|
|
40
|
+
// growth on every TTL sweep with no way to shrink the on-disk file.
|
|
41
|
+
this.db.pragma('auto_vacuum = INCREMENTAL');
|
|
28
42
|
// WAL mode optimization for better concurrency
|
|
29
43
|
this.db.pragma('journal_mode = WAL');
|
|
30
44
|
this.db.pragma('synchronous = NORMAL');
|
|
@@ -48,6 +62,73 @@ export class SQLiteBase {
|
|
|
48
62
|
this.initSchema();
|
|
49
63
|
this.runIndexMigrations();
|
|
50
64
|
this.runPostMigrations();
|
|
65
|
+
this.migrateAutoVacuumIfNeeded();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* One-shot migration: convert auto_vacuum from NONE (0) to INCREMENTAL (2)
|
|
69
|
+
* on existing DBs.
|
|
70
|
+
*
|
|
71
|
+
* Why this exists
|
|
72
|
+
* ---------------
|
|
73
|
+
* Setting `PRAGMA auto_vacuum = INCREMENTAL` in the constructor only takes
|
|
74
|
+
* effect on a *new* DB (before any table is created). On an existing DB it
|
|
75
|
+
* silently no-ops, so we must detect mode=0 and run a one-time `VACUUM`
|
|
76
|
+
* (which rewrites the whole file and flips the persistent header bit).
|
|
77
|
+
*
|
|
78
|
+
* Cost: O(DB size). For a 269 MB DB this is a few seconds of writer-lock.
|
|
79
|
+
* We log around it so an operator notices.
|
|
80
|
+
*
|
|
81
|
+
* Idempotent: after the first successful run, `auto_vacuum` reads as 2 and
|
|
82
|
+
* the migration short-circuits.
|
|
83
|
+
*
|
|
84
|
+
* Errors are warn-logged and swallowed — daemon startup must not fail.
|
|
85
|
+
* Worst case the DB stays on auto_vacuum=0 and the incremental_vacuum calls
|
|
86
|
+
* elsewhere become no-ops; freelist still grows but nothing breaks.
|
|
87
|
+
*/
|
|
88
|
+
migrateAutoVacuumIfNeeded() {
|
|
89
|
+
try {
|
|
90
|
+
const current = this.db.pragma('auto_vacuum', { simple: true });
|
|
91
|
+
if (Number(current) === 2)
|
|
92
|
+
return; // already INCREMENTAL — done
|
|
93
|
+
logger.info(`[SQLiteStorage] migration: converting auto_vacuum ${current} → INCREMENTAL (2) via VACUUM (one-shot; may take seconds on large DBs)`);
|
|
94
|
+
const startMs = Date.now();
|
|
95
|
+
// Setting + VACUUM is the documented way to migrate. Both must execute
|
|
96
|
+
// outside any transaction; the constructor's caller has no open tx so
|
|
97
|
+
// we're safe.
|
|
98
|
+
this.db.pragma('auto_vacuum = INCREMENTAL');
|
|
99
|
+
this.db.exec('VACUUM');
|
|
100
|
+
const elapsedMs = Date.now() - startMs;
|
|
101
|
+
const after = this.db.pragma('auto_vacuum', { simple: true });
|
|
102
|
+
logger.info(`[SQLiteStorage] migration: auto_vacuum is now ${after} (took ${elapsedMs}ms)`);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
logger.warn(`[SQLiteStorage] migrateAutoVacuumIfNeeded failed: ${err}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reclaim up to `maxPages` free pages from the auto_vacuum=INCREMENTAL
|
|
110
|
+
* freelist back to the OS. Returns the number of pages reclaimed.
|
|
111
|
+
*
|
|
112
|
+
* Called by the event-ttl-sweep service after TTL deletes accumulate free
|
|
113
|
+
* pages. Safe to call when auto_vacuum != INCREMENTAL — SQLite just returns
|
|
114
|
+
* 0 pages reclaimed.
|
|
115
|
+
*
|
|
116
|
+
* NOTE: not on the public SQLiteStorage facade by default — the daemon
|
|
117
|
+
* calls through `MaintenanceOperations.incrementalVacuum`. Kept here as a
|
|
118
|
+
* protected helper so any *Operations subclass can invoke it.
|
|
119
|
+
*/
|
|
120
|
+
incrementalVacuumPages(maxPages) {
|
|
121
|
+
const before = this.db.pragma('freelist_count', { simple: true });
|
|
122
|
+
try {
|
|
123
|
+
this.db.exec(`PRAGMA incremental_vacuum(${Math.max(0, Math.floor(maxPages))})`);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
logger.warn(`[SQLiteStorage] incremental_vacuum(${maxPages}) failed: ${err}`);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
const after = this.db.pragma('freelist_count', { simple: true });
|
|
130
|
+
const reclaimed = Math.max(0, Number(before) - Number(after));
|
|
131
|
+
return reclaimed;
|
|
51
132
|
}
|
|
52
133
|
initSchema() {
|
|
53
134
|
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
@@ -135,6 +216,99 @@ export class SQLiteBase {
|
|
|
135
216
|
this.addColumnIfMissing('skill_invocations', 'phase', 'TEXT');
|
|
136
217
|
this.addColumnIfMissing('skill_invocations', 'feature_slug', 'TEXT');
|
|
137
218
|
this.addColumnIfMissing('skill_invocations', 'artifact_path', 'TEXT');
|
|
219
|
+
// Outcome instrumentation (v9.x). NOTE: SQLite ALTER TABLE ADD COLUMN can
|
|
220
|
+
// only add CHECK constraints that don't reference other rows — the
|
|
221
|
+
// outcome CHECK is therefore embedded in the column type clause below.
|
|
222
|
+
// spec 1100 Option C (2026-06-02): when ADDED on a fresh-ish legacy DB the
|
|
223
|
+
// column gets the RELAXED non-empty CHECK (matches schema.sql). DBs that
|
|
224
|
+
// already have the column with the OLD enum CHECK are widened in-place by
|
|
225
|
+
// rebuildOutcomeCheckIfNeeded (runPostMigrations).
|
|
226
|
+
this.addColumnIfMissing('sessions', 'outcome', `TEXT CHECK(outcome IS NULL OR length(outcome) > 0)`);
|
|
227
|
+
this.addColumnIfMissing('sessions', 'outcome_reason', 'TEXT');
|
|
228
|
+
this.addColumnIfMissing('sessions', 'commit_count', 'INTEGER DEFAULT 0');
|
|
229
|
+
this.addColumnIfMissing('sessions', 'reverted_commits', 'INTEGER DEFAULT 0');
|
|
230
|
+
this.addColumnIfMissing('sessions', 'user_violation_count', 'INTEGER DEFAULT 0');
|
|
231
|
+
this.addColumnIfMissing('sessions', 'classified_at', 'TEXT');
|
|
232
|
+
// Phase 2 metrics rollup (master roadmap §2): per-session counters.
|
|
233
|
+
// Default 0 keeps existing analytics queries (SUM/AVG) honest on legacy
|
|
234
|
+
// rows; back-fill happens at Stop time by classifyAndPersistOutcome.
|
|
235
|
+
this.addColumnIfMissing('sessions', 'intercept_count', 'INTEGER DEFAULT 0');
|
|
236
|
+
this.addColumnIfMissing('sessions', 'kb_inject_count', 'INTEGER DEFAULT 0');
|
|
237
|
+
this.addColumnIfMissing('sessions', 'skill_match_count', 'INTEGER DEFAULT 0');
|
|
238
|
+
// spec 1100 Option C (2026-06-02): relaxed CHECK (see sessions.outcome).
|
|
239
|
+
this.addColumnIfMissing('tasks', 'outcome', `TEXT CHECK(outcome IS NULL OR length(outcome) > 0)`);
|
|
240
|
+
this.addColumnIfMissing('tasks', 'outcome_reason', 'TEXT');
|
|
241
|
+
this.addColumnIfMissing('tasks', 'commit_count', 'INTEGER DEFAULT 0');
|
|
242
|
+
this.addColumnIfMissing('tasks', 'reverted_commits', 'INTEGER DEFAULT 0');
|
|
243
|
+
this.addColumnIfMissing('tasks', 'user_violation_count', 'INTEGER DEFAULT 0');
|
|
244
|
+
this.addColumnIfMissing('tasks', 'classified_at', 'TEXT');
|
|
245
|
+
// decision 265f59d5 (2026-06-08): LLM task-boundary classifier idempotency
|
|
246
|
+
// marker. Stamped on a task row when the async classifier (Option A) has
|
|
247
|
+
// already run for the prompt that minted it, so a re-delivered / replayed
|
|
248
|
+
// event never re-spawns claude or re-attributes the same prompt twice.
|
|
249
|
+
// Nullable TEXT (ISO timestamp); NULL = not yet classified.
|
|
250
|
+
this.addColumnIfMissing('tasks', 'llm_classified_at', 'TEXT');
|
|
251
|
+
// Task-tracking overhaul (2026-05-27): write-time noise classification.
|
|
252
|
+
// ALTER ADD COLUMN cannot enforce NOT NULL without a DEFAULT on legacy
|
|
253
|
+
// rows — DEFAULT 0 keeps existing data intact. The post-migration
|
|
254
|
+
// backfill (backfillTasksIsNoiseIfNeeded) flips matching rows to 1.
|
|
255
|
+
this.addColumnIfMissing('tasks', 'is_noise', 'INTEGER NOT NULL DEFAULT 0');
|
|
256
|
+
// spec b1480935 (2026-06-01): task_kind successor column. SQLite ALTER
|
|
257
|
+
// TABLE ADD COLUMN with NOT NULL DEFAULT 'user' back-fills every legacy
|
|
258
|
+
// row to 'user' atomically; the post-migration backfill
|
|
259
|
+
// (backfillTasksTaskKindIfNeeded) then promotes envelope/system rows
|
|
260
|
+
// to their granular kind via title-prefix sniff. The CHECK constraint
|
|
261
|
+
// here is the same one schema.sql declares for fresh DBs.
|
|
262
|
+
this.addColumnIfMissing('tasks', 'task_kind', `TEXT NOT NULL DEFAULT 'user' CHECK(task_kind IN ('user','agent-callback','image','system'))`);
|
|
263
|
+
// C1 (spec 0854, 2026-06-02): the pending_specs table was retired and is
|
|
264
|
+
// DROPped by schema.sql. Its former `source` column migration + spec_path
|
|
265
|
+
// index migration were removed here — schema.sql runs AFTER these column
|
|
266
|
+
// migrations, so any addColumn/createIndex targeting pending_specs would
|
|
267
|
+
// hit a non-existent table on fresh DBs.
|
|
268
|
+
// v9.x MVP1: KB injection metadata column. Stores JSON array of KB hits
|
|
269
|
+
// (page name + score + refs) for the 'UserPromptSubmitHandler:kb' source.
|
|
270
|
+
this.addColumnIfMissing('injections', 'metadata_json', 'TEXT');
|
|
271
|
+
// F3 (audit-20260522 migration 009): writer-side tool_output 50KB truncation
|
|
272
|
+
// marker. Legacy rows default to 0 (full content preserved).
|
|
273
|
+
this.addColumnIfMissing('events', 'tool_output_truncated', 'INTEGER DEFAULT 0');
|
|
274
|
+
// decision-flow-overhaul (2026-05-28): link routing rows back to the decision
|
|
275
|
+
// that triggered the spawn. Both columns default NULL (additive).
|
|
276
|
+
this.addColumnIfMissing('routing_events', 'decision_id', 'TEXT');
|
|
277
|
+
this.addColumnIfMissing('routing_events', 'spawn_id', 'TEXT');
|
|
278
|
+
// decision-flow-overhaul (2026-05-28): update pending_specs.source CHECK to
|
|
279
|
+
// include 'decision'. SQLite does NOT support altering CHECK constraints on
|
|
280
|
+
// existing columns via ALTER TABLE, so for existing DBs the guard lives in
|
|
281
|
+
// application code (DecisionStore) rather than the schema. New DBs get the
|
|
282
|
+
// full CHECK via schema.sql CREATE TABLE.
|
|
283
|
+
// (no ALTER needed — addColumnIfMissing does nothing for existing columns)
|
|
284
|
+
// spec 1200 (2026-05-28): decision-maker recommended_agents/skills columns.
|
|
285
|
+
// Additive — existing rows get NULL by default.
|
|
286
|
+
this.addColumnIfMissing('decisions', 'recommended_agents', 'TEXT');
|
|
287
|
+
this.addColumnIfMissing('decisions', 'recommended_skills', 'TEXT');
|
|
288
|
+
// Option B (decision b95e0956, 2026-05-29) bypass-governance fields.
|
|
289
|
+
// bypass_flag=1 marks decisions resolved without a decision-maker spawn
|
|
290
|
+
// trace; bypass_reason holds the operator-supplied justification.
|
|
291
|
+
// Existing rows default to 0 / NULL — preserves legacy contract.
|
|
292
|
+
this.addColumnIfMissing('decisions', 'bypass_flag', 'INTEGER NOT NULL DEFAULT 0');
|
|
293
|
+
this.addColumnIfMissing('decisions', 'bypass_reason', 'TEXT');
|
|
294
|
+
// C1 (2026-06-02): unified approval subsystem. decisions absorbs the
|
|
295
|
+
// retired pending_specs table — kind distinguishes daemon-minted decision
|
|
296
|
+
// rows ('decision') from externally-registered spec rows ('spec'). The
|
|
297
|
+
// CHECK constraint lives in schema.sql for new DBs; legacy DBs get the
|
|
298
|
+
// column without the CHECK (enforced in app code), mirroring the existing
|
|
299
|
+
// status-CHECK migration note above. Existing rows default to 'decision'.
|
|
300
|
+
this.addColumnIfMissing('decisions', 'kind', "TEXT NOT NULL DEFAULT 'decision'");
|
|
301
|
+
this.addColumnIfMissing('decisions', 'spec_source', 'TEXT');
|
|
302
|
+
this.addColumnIfMissing('decisions', 'spec_intent_json', 'TEXT');
|
|
303
|
+
// decision-maker optimization Batch 1.1 (decision a5d5a85b, 2026-06-02):
|
|
304
|
+
// implementation-outcome column. NOTE: outcome (success|failed|partial) is
|
|
305
|
+
// the *implementation result* and is INDEPENDENT of status (the approval
|
|
306
|
+
// lifecycle pending/resolved/bypassed/expired). Mirrors the sessions/tasks
|
|
307
|
+
// outcome column convention (base.ts above). The enum is enforced in app
|
|
308
|
+
// code (writeDecisionOutcome); the column-level CHECK only guards non-empty
|
|
309
|
+
// — matching the relaxed sessions/tasks outcome CHECK so a future enum
|
|
310
|
+
// extension needs no in-place rebuild. Existing rows default to NULL.
|
|
311
|
+
this.addColumnIfMissing('decisions', 'outcome', `TEXT CHECK(outcome IS NULL OR length(outcome) > 0)`);
|
|
138
312
|
}
|
|
139
313
|
/**
|
|
140
314
|
* Index migrations run AFTER initSchema(). Each call is guarded by hasIndex
|
|
@@ -153,17 +327,45 @@ export class SQLiteBase {
|
|
|
153
327
|
this.createIndexIfMissing('idx_events_session_ts', `CREATE INDEX IF NOT EXISTS idx_events_session_ts ON events(session_id, timestamp DESC)`);
|
|
154
328
|
this.createIndexIfMissing('idx_routing_events_session_ts', `CREATE INDEX IF NOT EXISTS idx_routing_events_session_ts ON routing_events(session_id, ts DESC)`);
|
|
155
329
|
this.createIndexIfMissing('idx_skill_invocations_session_ts', `CREATE INDEX IF NOT EXISTS idx_skill_invocations_session_ts ON skill_invocations(session_id, timestamp DESC)`);
|
|
330
|
+
// spec b1480935 (2026-06-01): task_kind index for hot WHERE filters.
|
|
331
|
+
this.createIndexIfMissing('idx_tasks_kind', `CREATE INDEX IF NOT EXISTS idx_tasks_kind ON tasks(task_kind)`);
|
|
156
332
|
// Phase 1 Refactor: Additional performance indexes
|
|
157
333
|
this.createIndexIfMissing('idx_routing_events_obeyed_ts', `CREATE INDEX IF NOT EXISTS idx_routing_events_obeyed_ts ON routing_events(obeyed, ts DESC)`);
|
|
158
334
|
this.createIndexIfMissing('idx_events_session_hook', `CREATE INDEX IF NOT EXISTS idx_events_session_hook ON events(session_id, hook_type, timestamp DESC)`);
|
|
159
335
|
this.createIndexIfMissing('idx_injections_session_handler', `CREATE INDEX IF NOT EXISTS idx_injections_session_handler ON injections(session_id, source_handler)`);
|
|
160
336
|
this.createIndexIfMissing('idx_routing_events_type_ts', `CREATE INDEX IF NOT EXISTS idx_routing_events_type_ts ON routing_events(routed_to_type, ts DESC)`);
|
|
337
|
+
// Outcome instrumentation indexes (v9.x)
|
|
338
|
+
this.createIndexIfMissing('idx_sessions_outcome', `CREATE INDEX IF NOT EXISTS idx_sessions_outcome ON sessions(outcome)`);
|
|
339
|
+
this.createIndexIfMissing('idx_sessions_project_outcome', `CREATE INDEX IF NOT EXISTS idx_sessions_project_outcome ON sessions(project_path, outcome)`);
|
|
340
|
+
this.createIndexIfMissing('idx_tasks_session_outcome', `CREATE INDEX IF NOT EXISTS idx_tasks_session_outcome ON tasks(session_id, outcome)`);
|
|
341
|
+
// C1 (spec 0854, 2026-06-02): pending_specs.spec_path UNIQUE index removed
|
|
342
|
+
// — the table is retired/DROPped by schema.sql. Its dedup role now lives on
|
|
343
|
+
// decisions (idx_decisions_approval_token + app-level findSpecByPath probe).
|
|
344
|
+
// decision-flow-overhaul (2026-05-28): index for decision → spawn JOIN.
|
|
345
|
+
this.createIndexIfMissing('idx_routing_decision', `CREATE INDEX IF NOT EXISTS idx_routing_decision ON routing_events(decision_id)`);
|
|
346
|
+
// decision-flow-overhaul (2026-05-28): indexes for decisions table (new DBs
|
|
347
|
+
// get these via schema.sql; legacy DBs need the migration guard here).
|
|
348
|
+
this.createIndexIfMissing('idx_decisions_session', `CREATE INDEX IF NOT EXISTS idx_decisions_session ON decisions(session_id, created_at DESC)`);
|
|
349
|
+
this.createIndexIfMissing('idx_decisions_status', `CREATE INDEX IF NOT EXISTS idx_decisions_status ON decisions(status, expires_at)`);
|
|
350
|
+
this.createIndexIfMissing('idx_decisions_trigger', `CREATE INDEX IF NOT EXISTS idx_decisions_trigger ON decisions(trigger_event_id)`);
|
|
351
|
+
// C1 (2026-06-02): spec-kind row lookups + partial-unique approval_token.
|
|
352
|
+
// New DBs get these via schema.sql; legacy DBs need the migration guard.
|
|
353
|
+
this.createIndexIfMissing('idx_decisions_kind_session', `CREATE INDEX IF NOT EXISTS idx_decisions_kind_session ON decisions(kind, session_id, status)`);
|
|
354
|
+
this.createIndexIfMissing('idx_decisions_approval_token', `CREATE UNIQUE INDEX IF NOT EXISTS idx_decisions_approval_token ON decisions(approval_token) WHERE approval_token IS NOT NULL`);
|
|
161
355
|
}
|
|
162
356
|
/**
|
|
163
357
|
* One-shot data migrations + deprecated table cleanup.
|
|
164
358
|
*/
|
|
165
359
|
runPostMigrations() {
|
|
166
360
|
this.backfillSessionsIfNeeded();
|
|
361
|
+
this.rebuildWorkflowRecommendationsCheckIfNeeded();
|
|
362
|
+
this.rebuildOutcomeCheckIfNeeded();
|
|
363
|
+
this.dropDeadKbQueryLogColumnsIfNeeded();
|
|
364
|
+
this.dropTokenUsageIfNeeded();
|
|
365
|
+
this.dropRoutingIsForcedIfNeeded();
|
|
366
|
+
this.backfillRoutingRoutedToTypePending();
|
|
367
|
+
this.backfillTasksIsNoiseIfNeeded();
|
|
368
|
+
this.backfillTasksTaskKindIfNeeded();
|
|
167
369
|
const deprecatedTables = [
|
|
168
370
|
'quality_issues', 'distill_results', 'v2_decisions',
|
|
169
371
|
'v2_tool_events', 'experiment_assignments', 'routing_rule_states',
|
|
@@ -175,6 +377,374 @@ export class SQLiteBase {
|
|
|
175
377
|
catch { /* ignore */ }
|
|
176
378
|
}
|
|
177
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* Task-tracking overhaul (2026-05-27): one-shot back-fill of `tasks.is_noise`
|
|
382
|
+
* from existing title heuristics. Idempotent — runs every startup but the
|
|
383
|
+
* WHERE clause restricts to rows that don't yet match the new state. We do
|
|
384
|
+
* NOT include the semantic blocklist ('批准', 'approve', '好', 'ok', '可以'
|
|
385
|
+
* …) intentionally; those are real human acknowledgements and the Bug 1
|
|
386
|
+
* spec-approval path now absorbs them — see spec § 3.2.
|
|
387
|
+
*
|
|
388
|
+
* Backfill only sets is_noise=1; rows already marked stay marked. We never
|
|
389
|
+
* flip 1→0 here (a future writer change could reclassify a legacy noise
|
|
390
|
+
* row; that case is best handled by a one-shot script, not boot-time).
|
|
391
|
+
*
|
|
392
|
+
* Errors are warn-logged and swallowed — daemon startup must not fail on
|
|
393
|
+
* data backfill. Worst case the column stays 0 and the Web filter shows
|
|
394
|
+
* extra rows (which the user can spot and report).
|
|
395
|
+
*/
|
|
396
|
+
backfillTasksIsNoiseIfNeeded() {
|
|
397
|
+
if (!this.hasTable('tasks'))
|
|
398
|
+
return;
|
|
399
|
+
if (!this.hasColumn('tasks', 'is_noise'))
|
|
400
|
+
return;
|
|
401
|
+
try {
|
|
402
|
+
// Spec § 3.2 + § R1: backfill is intentionally CONSERVATIVE — we flip
|
|
403
|
+
// envelope / single-word slash / sub-3-char titles, but EXEMPT the
|
|
404
|
+
// semantic blocklist ('批准', 'approve', '好', 'ok', '可以', '同意', …).
|
|
405
|
+
// Those titles are real human acknowledgements that historically got
|
|
406
|
+
// mis-classified as user task starts; the Web should now SHOW them
|
|
407
|
+
// (so the user sees how many "approve" replies were silently dropped
|
|
408
|
+
// pre-Bug-1 fix). Going forward, SpecGate.handleApproval intercepts
|
|
409
|
+
// them BEFORE TaskSegmenter runs so they never reach createTask.
|
|
410
|
+
const res = this.db
|
|
411
|
+
.prepare(`UPDATE tasks SET is_noise = 1
|
|
412
|
+
WHERE is_noise = 0
|
|
413
|
+
AND LOWER(trim(title)) NOT IN
|
|
414
|
+
('批准', '同意', 'approve', '好', '好的', '嗯', 'ok', 'okay',
|
|
415
|
+
'可以', '是', '是的', '继续', '停', 'stop', 'yes', 'no')
|
|
416
|
+
AND (
|
|
417
|
+
length(trim(title)) < 3
|
|
418
|
+
OR title LIKE '<task-notification>%'
|
|
419
|
+
OR title LIKE '<system-reminder>%'
|
|
420
|
+
OR title LIKE '<local-command-stdout>%'
|
|
421
|
+
OR title LIKE '<command-message>%'
|
|
422
|
+
OR title LIKE '<command-name>%'
|
|
423
|
+
OR title LIKE '[Image #%'
|
|
424
|
+
OR (substr(title, 1, 1) = '/' AND instr(title, ' ') = 0)
|
|
425
|
+
)`)
|
|
426
|
+
.run();
|
|
427
|
+
if (res.changes > 0) {
|
|
428
|
+
logger.info(`[SQLiteStorage] migration: backfilled tasks.is_noise=1 on ${res.changes} rows`);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
catch (err) {
|
|
432
|
+
logger.warn(`[SQLiteStorage] migration: backfillTasksIsNoiseIfNeeded failed: ${err}`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* spec b1480935 (2026-06-01 Option A § OQ Q3): one-shot back-fill of
|
|
437
|
+
* `tasks.task_kind` from existing title prefixes. The is_noise column
|
|
438
|
+
* is deprecated but we keep its backfill running first so legacy rows
|
|
439
|
+
* still have a usable filter signal during the transition window.
|
|
440
|
+
*
|
|
441
|
+
* Mapping (mirrors NOISE_PREFIX_TO_KIND in core/utils/noise-prompt.ts):
|
|
442
|
+
* - title LIKE '<task-notification>%' → 'agent-callback'
|
|
443
|
+
* - title LIKE '[Image #%' → 'image'
|
|
444
|
+
* - title LIKE '<system-reminder>%' / '<local-command-stdout>%' /
|
|
445
|
+
* '<command-message>%' / '<command-name>%' → 'system'
|
|
446
|
+
* - everything else → stays 'user' (default)
|
|
447
|
+
*
|
|
448
|
+
* Idempotent: WHERE task_kind = 'user' AND title LIKE ... so a second
|
|
449
|
+
* boot only touches rows that haven't been promoted yet. We never demote
|
|
450
|
+
* (1→0 for is_noise had the same invariant) — a row already classified as
|
|
451
|
+
* 'agent-callback' stays put even if a future writer would have called it
|
|
452
|
+
* 'system'.
|
|
453
|
+
*
|
|
454
|
+
* Errors are warn-logged and swallowed — daemon startup must not fail on
|
|
455
|
+
* a backfill. Worst case the column stays 'user' on a few legacy envelopes
|
|
456
|
+
* and they surface in the default Web view (cosmetic only).
|
|
457
|
+
*/
|
|
458
|
+
backfillTasksTaskKindIfNeeded() {
|
|
459
|
+
if (!this.hasTable('tasks'))
|
|
460
|
+
return;
|
|
461
|
+
if (!this.hasColumn('tasks', 'task_kind'))
|
|
462
|
+
return;
|
|
463
|
+
try {
|
|
464
|
+
// Each kind gets its own UPDATE so we can log per-bucket counts (helpful
|
|
465
|
+
// diagnostic when a user reports "why did 50 rows just turn grey?").
|
|
466
|
+
// Using a single CASE WHEN would collapse the count to one line.
|
|
467
|
+
const updates = [
|
|
468
|
+
{ kind: 'agent-callback', like: '<task-notification>%' },
|
|
469
|
+
{ kind: 'image', like: '[Image #%' },
|
|
470
|
+
{ kind: 'system', like: '<system-reminder>%' },
|
|
471
|
+
{ kind: 'system', like: '<local-command-stdout>%' },
|
|
472
|
+
{ kind: 'system', like: '<command-message>%' },
|
|
473
|
+
{ kind: 'system', like: '<command-name>%' },
|
|
474
|
+
];
|
|
475
|
+
let total = 0;
|
|
476
|
+
for (const { kind, like } of updates) {
|
|
477
|
+
const res = this.db
|
|
478
|
+
.prepare(`UPDATE tasks SET task_kind = ?
|
|
479
|
+
WHERE task_kind = 'user' AND title LIKE ?`)
|
|
480
|
+
.run(kind, like);
|
|
481
|
+
total += res.changes;
|
|
482
|
+
}
|
|
483
|
+
if (total > 0) {
|
|
484
|
+
logger.info(`[SQLiteStorage] migration: backfilled tasks.task_kind on ${total} rows`);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
catch (err) {
|
|
488
|
+
logger.warn(`[SQLiteStorage] migration: backfillTasksTaskKindIfNeeded failed: ${err}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Migration (Spec 2 § B1): drop the rerank-related columns from
|
|
493
|
+
* `kb_query_log` (strategy / rerank_cache_hit / rerank_failed) and the
|
|
494
|
+
* compound index that referenced `strategy`. Idempotent — new DBs created
|
|
495
|
+
* from the current schema.sql skip this entirely; legacy DBs lose the dead
|
|
496
|
+
* columns on next boot.
|
|
497
|
+
*
|
|
498
|
+
* SQLite ≥ 3.35 supports ALTER TABLE DROP COLUMN; better-sqlite3 12.x ships
|
|
499
|
+
* 3.46 so we use that directly. Errors are warn-logged but never thrown —
|
|
500
|
+
* worst case the columns linger and the writer just stops populating them.
|
|
501
|
+
*/
|
|
502
|
+
dropDeadKbQueryLogColumnsIfNeeded() {
|
|
503
|
+
if (!this.hasTable('kb_query_log'))
|
|
504
|
+
return;
|
|
505
|
+
try {
|
|
506
|
+
// Drop the index first (still references `strategy`).
|
|
507
|
+
this.db.exec(`DROP INDEX IF EXISTS idx_kb_query_log_project_strategy`);
|
|
508
|
+
}
|
|
509
|
+
catch (err) {
|
|
510
|
+
logger.warn(`[SQLiteStorage] migration: drop idx_kb_query_log_project_strategy failed: ${err}`);
|
|
511
|
+
}
|
|
512
|
+
for (const col of ['strategy', 'rerank_cache_hit', 'rerank_failed']) {
|
|
513
|
+
if (!this.hasColumn('kb_query_log', col))
|
|
514
|
+
continue;
|
|
515
|
+
try {
|
|
516
|
+
this.db.exec(`ALTER TABLE kb_query_log DROP COLUMN ${col}`);
|
|
517
|
+
logger.info(`[SQLiteStorage] migration: dropped kb_query_log.${col}`);
|
|
518
|
+
}
|
|
519
|
+
catch (err) {
|
|
520
|
+
logger.warn(`[SQLiteStorage] migration: drop kb_query_log.${col} failed: ${err}`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Migration (Spec 2 § B2): drop the unused `token_usage` table + indexes.
|
|
526
|
+
* 7d evidence showed 0 rows; the only "live" writer path was never wired
|
|
527
|
+
* through TokenTracker, so deleting is safe. Idempotent — DROP TABLE IF
|
|
528
|
+
* EXISTS noops on new DBs (schema.sql no longer declares the table).
|
|
529
|
+
*/
|
|
530
|
+
dropTokenUsageIfNeeded() {
|
|
531
|
+
try {
|
|
532
|
+
this.db.exec(`DROP INDEX IF EXISTS idx_token_usage_session`);
|
|
533
|
+
this.db.exec(`DROP INDEX IF EXISTS idx_token_usage_timestamp`);
|
|
534
|
+
this.db.exec(`DROP TABLE IF EXISTS token_usage`);
|
|
535
|
+
}
|
|
536
|
+
catch (err) {
|
|
537
|
+
logger.warn(`[SQLiteStorage] migration: drop token_usage failed: ${err}`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Migration (Spec 2 § B3): drop `routing_events.is_forced`. 7d evidence
|
|
542
|
+
* showed 0 rows with is_forced=1 — the field was reserved for a feature
|
|
543
|
+
* (forced/fallback routing) that was never wired. ALTER TABLE DROP COLUMN
|
|
544
|
+
* lands the column removal in-place; SQLite ≥ 3.35 required.
|
|
545
|
+
*/
|
|
546
|
+
dropRoutingIsForcedIfNeeded() {
|
|
547
|
+
if (!this.hasTable('routing_events'))
|
|
548
|
+
return;
|
|
549
|
+
if (!this.hasColumn('routing_events', 'is_forced'))
|
|
550
|
+
return;
|
|
551
|
+
try {
|
|
552
|
+
this.db.exec(`ALTER TABLE routing_events DROP COLUMN is_forced`);
|
|
553
|
+
logger.info(`[SQLiteStorage] migration: dropped routing_events.is_forced`);
|
|
554
|
+
}
|
|
555
|
+
catch (err) {
|
|
556
|
+
logger.warn(`[SQLiteStorage] migration: drop routing_events.is_forced failed: ${err}`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Migration (Spec 2 § B4): backfill `routing_events.routed_to_type='pending'`
|
|
561
|
+
* for the historical rows that user-prompt.ts wrote with NULL placeholder.
|
|
562
|
+
* 7d evidence showed 297/555 (54%) rows had NULL; with the new write-side
|
|
563
|
+
* default already minting 'pending', this one-shot UPDATE realigns history.
|
|
564
|
+
*/
|
|
565
|
+
backfillRoutingRoutedToTypePending() {
|
|
566
|
+
if (!this.hasTable('routing_events'))
|
|
567
|
+
return;
|
|
568
|
+
try {
|
|
569
|
+
const res = this.db
|
|
570
|
+
.prepare(`UPDATE routing_events SET routed_to_type='pending' WHERE routed_to_type IS NULL`)
|
|
571
|
+
.run();
|
|
572
|
+
if (res.changes > 0) {
|
|
573
|
+
logger.info(`[SQLiteStorage] migration: backfilled routed_to_type='pending' on ${res.changes} rows`);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
catch (err) {
|
|
577
|
+
logger.warn(`[SQLiteStorage] migration: backfill routed_to_type='pending' failed: ${err}`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Migration 010: widen workflow_recommendations.outcome CHECK to include
|
|
582
|
+
* 'partial_accepted'. SQLite cannot ALTER a CHECK constraint in place — we
|
|
583
|
+
* detect legacy tables (CHECK string does NOT contain 'partial_accepted')
|
|
584
|
+
* and rebuild via temp-table copy/drop/rename. Idempotent — new DBs
|
|
585
|
+
* already created by schema.sql carry the new CHECK and skip.
|
|
586
|
+
*
|
|
587
|
+
* Errors are warn-logged but never thrown — daemon startup must not fail
|
|
588
|
+
* on a migration; worst case the new outcome value just gets rejected at
|
|
589
|
+
* write time and the calling code's try/catch swallows it (writes here are
|
|
590
|
+
* fire-and-forget observability).
|
|
591
|
+
*/
|
|
592
|
+
rebuildWorkflowRecommendationsCheckIfNeeded() {
|
|
593
|
+
if (!this.hasTable('workflow_recommendations'))
|
|
594
|
+
return;
|
|
595
|
+
try {
|
|
596
|
+
const sqlRow = this.db
|
|
597
|
+
.prepare(`SELECT sql FROM sqlite_master WHERE type='table' AND name='workflow_recommendations'`)
|
|
598
|
+
.get();
|
|
599
|
+
if (!sqlRow || !sqlRow.sql)
|
|
600
|
+
return;
|
|
601
|
+
if (sqlRow.sql.includes('partial_accepted'))
|
|
602
|
+
return; // already widened
|
|
603
|
+
logger.info('[SQLiteStorage] migration 010: widening workflow_recommendations.outcome CHECK to include partial_accepted');
|
|
604
|
+
const rebuild = this.db.transaction(() => {
|
|
605
|
+
// 1) create the new table with widened CHECK
|
|
606
|
+
this.db.exec(`
|
|
607
|
+
CREATE TABLE workflow_recommendations_new (
|
|
608
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
609
|
+
session_id TEXT NOT NULL,
|
|
610
|
+
timestamp TEXT NOT NULL,
|
|
611
|
+
rule_id TEXT NOT NULL,
|
|
612
|
+
matched_keywords TEXT,
|
|
613
|
+
recommended_workflow TEXT NOT NULL,
|
|
614
|
+
recommended_agent_type TEXT NOT NULL,
|
|
615
|
+
reason TEXT,
|
|
616
|
+
outcome TEXT CHECK(outcome IS NULL OR outcome IN ('pending','accepted','partial_accepted','rejected','ignored','bypassed')),
|
|
617
|
+
outcome_at TEXT,
|
|
618
|
+
source TEXT DEFAULT 'workflow_classifier',
|
|
619
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
620
|
+
);
|
|
621
|
+
`);
|
|
622
|
+
// 2) copy rows preserving id
|
|
623
|
+
this.db.exec(`
|
|
624
|
+
INSERT INTO workflow_recommendations_new (
|
|
625
|
+
id, session_id, timestamp, rule_id, matched_keywords,
|
|
626
|
+
recommended_workflow, recommended_agent_type, reason,
|
|
627
|
+
outcome, outcome_at, source, created_at
|
|
628
|
+
)
|
|
629
|
+
SELECT id, session_id, timestamp, rule_id, matched_keywords,
|
|
630
|
+
recommended_workflow, recommended_agent_type, reason,
|
|
631
|
+
outcome, outcome_at, source, created_at
|
|
632
|
+
FROM workflow_recommendations;
|
|
633
|
+
`);
|
|
634
|
+
// 3) drop old + rename new (indexes auto-dropped with table; recreated below)
|
|
635
|
+
this.db.exec(`DROP TABLE workflow_recommendations;`);
|
|
636
|
+
this.db.exec(`ALTER TABLE workflow_recommendations_new RENAME TO workflow_recommendations;`);
|
|
637
|
+
// 4) recreate indexes (mirrors schema.sql lines 378-379)
|
|
638
|
+
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_workflow_rec_session ON workflow_recommendations(session_id, outcome);`);
|
|
639
|
+
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_workflow_rec_ts ON workflow_recommendations(timestamp DESC);`);
|
|
640
|
+
});
|
|
641
|
+
rebuild();
|
|
642
|
+
logger.info('[SQLiteStorage] migration 010: workflow_recommendations rebuild complete');
|
|
643
|
+
}
|
|
644
|
+
catch (err) {
|
|
645
|
+
logger.warn(`[SQLiteStorage] migration 010: rebuild failed: ${err}`);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Migration 011 (spec 1100 Option C, 2026-06-02): widen the `outcome` CHECK
|
|
650
|
+
* on `sessions` + `tasks` from the fixed value enum
|
|
651
|
+
* `IN ('success','partial','failed','abandoned')` to a non-empty-string
|
|
652
|
+
* guard `length(outcome) > 0`. This lets the classifier emit the new
|
|
653
|
+
* `answered` outcome (and any future value) WITHOUT a table rebuild per
|
|
654
|
+
* value. The rebuild here is the ONE-TIME widening for existing live DBs.
|
|
655
|
+
*
|
|
656
|
+
* Why a rebuild: SQLite cannot ALTER a CHECK constraint in place. We mirror
|
|
657
|
+
* the migration-010 pattern: CREATE *_new → INSERT SELECT → DROP old →
|
|
658
|
+
* RENAME → recreate indexes.
|
|
659
|
+
*
|
|
660
|
+
* Robustness choices:
|
|
661
|
+
* - **Idempotent**: detected by sniffing the stored CREATE TABLE `sql`. If
|
|
662
|
+
* it no longer contains the old enum fragment (`outcome IN (`) we skip —
|
|
663
|
+
* a second boot is a no-op. New DBs created from current schema.sql carry
|
|
664
|
+
* the relaxed CHECK already and skip.
|
|
665
|
+
* - **Data-preserving**: we don't hand-write the new column list. We take
|
|
666
|
+
* the table's existing CREATE statement and string-replace ONLY the
|
|
667
|
+
* outcome CHECK fragment, so every column (incl. migration-added ones
|
|
668
|
+
* like task_kind / intercept_count) is preserved verbatim, then copy all
|
|
669
|
+
* rows with `INSERT INTO new SELECT * FROM old`.
|
|
670
|
+
* - **Index-preserving**: we snapshot every non-autoindex on the table
|
|
671
|
+
* from sqlite_master BEFORE the drop and replay each `sql` after rename.
|
|
672
|
+
* - **FK-safe**: tasks is referenced by task_events(task_id) FK. We run the
|
|
673
|
+
* whole rebuild inside a transaction with foreign_keys temporarily OFF so
|
|
674
|
+
* the DROP/RENAME doesn't cascade-delete task_events rows. (PRAGMA
|
|
675
|
+
* foreign_keys is a no-op inside a transaction in SQLite, so we toggle it
|
|
676
|
+
* around the transaction.)
|
|
677
|
+
*
|
|
678
|
+
* Errors are warn-logged, never thrown — daemon startup must not fail. Worst
|
|
679
|
+
* case the old enum CHECK lingers and writing `answered` is rejected at write
|
|
680
|
+
* time (callers swallow the throw); the operator can re-run after the next
|
|
681
|
+
* build.
|
|
682
|
+
*/
|
|
683
|
+
rebuildOutcomeCheckIfNeeded() {
|
|
684
|
+
for (const table of ['sessions', 'tasks']) {
|
|
685
|
+
try {
|
|
686
|
+
if (!this.hasTable(table))
|
|
687
|
+
continue;
|
|
688
|
+
const sqlRow = this.db
|
|
689
|
+
.prepare(`SELECT sql FROM sqlite_master WHERE type='table' AND name=?`)
|
|
690
|
+
.get(table);
|
|
691
|
+
if (!sqlRow || !sqlRow.sql)
|
|
692
|
+
continue;
|
|
693
|
+
// Detect the OLD enum CHECK. The relaxed form uses `length(outcome)`,
|
|
694
|
+
// so the presence of `outcome IN (` is the legacy marker.
|
|
695
|
+
if (!/outcome\s+IN\s*\(/i.test(sqlRow.sql))
|
|
696
|
+
continue; // already widened
|
|
697
|
+
logger.info(`[SQLiteStorage] migration 011: widening ${table}.outcome CHECK (enum → non-empty) via table rebuild`);
|
|
698
|
+
// Build the new CREATE statement by replacing the legacy outcome CHECK
|
|
699
|
+
// fragment in-place. Two known shapes (sessions vs tasks columns differ
|
|
700
|
+
// but the outcome CHECK fragment is identical):
|
|
701
|
+
// outcome TEXT CHECK(outcome IS NULL OR outcome IN ('success', 'partial', 'failed', 'abandoned'))
|
|
702
|
+
const newTableName = `${table}_oc_new`;
|
|
703
|
+
const newCreate = sqlRow.sql
|
|
704
|
+
.replace(/outcome\s+TEXT\s+CHECK\s*\(\s*outcome\s+IS\s+NULL\s+OR\s+outcome\s+IN\s*\([^)]*\)\s*\)/i, 'outcome TEXT CHECK(outcome IS NULL OR length(outcome) > 0)')
|
|
705
|
+
// Point the CREATE at the temp table name. The original name appears
|
|
706
|
+
// right after CREATE TABLE (optionally quoted) — replace the FIRST
|
|
707
|
+
// occurrence only.
|
|
708
|
+
.replace(new RegExp(`CREATE\\s+TABLE\\s+(?:IF\\s+NOT\\s+EXISTS\\s+)?["'\`]?${table}["'\`]?`, 'i'), `CREATE TABLE ${newTableName}`);
|
|
709
|
+
if (newCreate === sqlRow.sql || newCreate.includes(`outcome IN (`)) {
|
|
710
|
+
logger.warn(`[SQLiteStorage] migration 011: could not rewrite ${table}.outcome CHECK (unexpected DDL shape) — skipping`);
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
// Snapshot user indexes on the table (skip auto-indexes which have NULL sql).
|
|
714
|
+
const indexRows = this.db
|
|
715
|
+
.prepare(`SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name=? AND sql IS NOT NULL`)
|
|
716
|
+
.all(table);
|
|
717
|
+
// task_events FK references tasks(id); toggle FK enforcement off around
|
|
718
|
+
// the transaction so DROP TABLE tasks doesn't cascade.
|
|
719
|
+
const fkOn = this.db.pragma('foreign_keys', { simple: true });
|
|
720
|
+
if (Number(fkOn) === 1)
|
|
721
|
+
this.db.pragma('foreign_keys = OFF');
|
|
722
|
+
try {
|
|
723
|
+
const rebuild = this.db.transaction(() => {
|
|
724
|
+
this.db.exec(newCreate);
|
|
725
|
+
this.db.exec(`INSERT INTO ${newTableName} SELECT * FROM ${table};`);
|
|
726
|
+
this.db.exec(`DROP TABLE ${table};`);
|
|
727
|
+
this.db.exec(`ALTER TABLE ${newTableName} RENAME TO ${table};`);
|
|
728
|
+
for (const idx of indexRows) {
|
|
729
|
+
// idx.sql is the original CREATE INDEX — replay verbatim. Make it
|
|
730
|
+
// idempotent in case schema.sql already recreated it on this boot.
|
|
731
|
+
const ddl = idx.sql.replace(/CREATE\s+(UNIQUE\s+)?INDEX\s+/i, (m) => /IF\s+NOT\s+EXISTS/i.test(idx.sql) ? m : `${m}IF NOT EXISTS `);
|
|
732
|
+
this.db.exec(ddl);
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
rebuild();
|
|
736
|
+
}
|
|
737
|
+
finally {
|
|
738
|
+
if (Number(fkOn) === 1)
|
|
739
|
+
this.db.pragma('foreign_keys = ON');
|
|
740
|
+
}
|
|
741
|
+
logger.info(`[SQLiteStorage] migration 011: ${table}.outcome CHECK widened`);
|
|
742
|
+
}
|
|
743
|
+
catch (err) {
|
|
744
|
+
logger.warn(`[SQLiteStorage] migration 011: ${table} rebuild failed: ${err}`);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
178
748
|
/**
|
|
179
749
|
* 将 events 表按 session_id 聚合回填到 sessions 表,仅在 sessions 尚未对齐
|
|
180
750
|
* (没有任何一行带 first_prompt)时触发。
|