@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
|
@@ -0,0 +1,897 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file knowledge.ts
|
|
3
|
+
* CLI commands for the v9.0 Knowledge Base (KB) subsystem.
|
|
4
|
+
*
|
|
5
|
+
* Commands registered under `cf knowledge` (alias: `cf kb`):
|
|
6
|
+
* init — One-shot: build + apply + install git hook (recommended for new projects)
|
|
7
|
+
* build — Compile KB from source (dry-run by default)
|
|
8
|
+
* update — Incremental rebuild based on git diff
|
|
9
|
+
* query — Keyword + repo-map search
|
|
10
|
+
* fetch — Format KB hits as a ready-to-paste Markdown prompt block
|
|
11
|
+
* list — List all KB pages
|
|
12
|
+
* audit — Validate all page refs
|
|
13
|
+
* clean — Delete KB directory and uninstall git hook
|
|
14
|
+
* rollback — Restore from a backup timestamp
|
|
15
|
+
* hook-status — Show git hook installation state
|
|
16
|
+
*/
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import { execSync } from 'node:child_process';
|
|
20
|
+
import chalk from 'chalk';
|
|
21
|
+
import { buildKnowledge } from '../../knowledge/builder.js';
|
|
22
|
+
import { KbBlockMissingError } from '../../knowledge/cli-provider.js';
|
|
23
|
+
import { ClaudeCliMissingError, ClaudeCliExitError, ClaudeCliTimeoutError, ClaudeCliCancelledError, } from '../../core/utils/claude-cli-spawn.js';
|
|
24
|
+
import { queryKnowledge, listKnowledge, isKnowledgeBuilt } from '../../knowledge/query.js';
|
|
25
|
+
import { installGitHook, uninstallGitHook, getHookStatus } from '../../knowledge/git-hooks.js';
|
|
26
|
+
import { validatePage } from '../../knowledge/validator.js';
|
|
27
|
+
import { loadRepoMap } from '../../knowledge/repo-map.js';
|
|
28
|
+
import { applyAuditResult, deriveAuditStatus, } from '../../knowledge/audit-applier.js';
|
|
29
|
+
import * as K from '../../knowledge/constants.js';
|
|
30
|
+
import { detectMonorepo, listCandidateSubdirs } from '../../knowledge/project-detector.js';
|
|
31
|
+
import { getAdapter } from '../../knowledge/adapters/index.js';
|
|
32
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
33
|
+
// Friendly error reporter (shared by build/init/update action handlers)
|
|
34
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
35
|
+
/**
|
|
36
|
+
* Map the errors that `buildKnowledge` (via `CliKnowledgeProvider`) can raise
|
|
37
|
+
* into operator-friendly stderr output. Pattern-matches the typed errors from
|
|
38
|
+
* `claude-cli-spawn` + `cli-provider` so the user sees actionable hints
|
|
39
|
+
* instead of raw stack traces.
|
|
40
|
+
*
|
|
41
|
+
* Falls back to the legacy `console.error(label, err.message)` shape for any
|
|
42
|
+
* unrecognised error, preserving R-A behaviour for unknown failure modes.
|
|
43
|
+
*/
|
|
44
|
+
function reportKnowledgeBuildError(label, err) {
|
|
45
|
+
if (err instanceof ClaudeCliMissingError) {
|
|
46
|
+
console.error(chalk.red(label), err.message);
|
|
47
|
+
console.error(chalk.dim('Install Claude Code: https://docs.anthropic.com/en/docs/claude-code or `npm i -g @anthropic-ai/claude-code`.'));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (err instanceof ClaudeCliCancelledError) {
|
|
51
|
+
console.error(chalk.yellow('[cf knowledge] cancelled.'));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (err instanceof ClaudeCliTimeoutError) {
|
|
55
|
+
console.error(chalk.red(label), `claude CLI timeout after ${err.timeoutMs}ms. Re-run with a faster network or split into smaller modules.`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (err instanceof ClaudeCliExitError) {
|
|
59
|
+
console.error(chalk.red(label), `claude CLI exit ${err.exitCode}: ${err.stderrSnippet}`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (err instanceof KbBlockMissingError) {
|
|
63
|
+
console.error(chalk.red(label), err.message);
|
|
64
|
+
console.error(chalk.dim('The knowledge-builder agent returned text but no `---KB---...---END---` envelope. This usually means the agent is on an older revision; pull the latest `.claude/agents/knowledge-builder.md` and retry.'));
|
|
65
|
+
console.error(chalk.dim(`Snippet: ${err.rawSnippet}`));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
console.error(chalk.red(label), err instanceof Error ? err.message : String(err));
|
|
69
|
+
}
|
|
70
|
+
async function buildCmd(options) {
|
|
71
|
+
console.log(chalk.cyan('Building knowledge base...'));
|
|
72
|
+
const buildOptions = {
|
|
73
|
+
apply: !!options.apply,
|
|
74
|
+
force: !!options.force,
|
|
75
|
+
modules: options.module ? [options.module] : undefined,
|
|
76
|
+
skipCrossModule: !!options.skipCrossModule,
|
|
77
|
+
};
|
|
78
|
+
const result = await buildKnowledge(buildOptions);
|
|
79
|
+
const { built, cached, total, crossModuleBuilt, crossModuleCached } = result.stats;
|
|
80
|
+
console.log(chalk.green(`✓ ${built} built, ${cached} cached (${total} total)`));
|
|
81
|
+
if (!options.skipCrossModule) {
|
|
82
|
+
const moduleBuilt = built - (crossModuleBuilt ?? 0);
|
|
83
|
+
const moduleCached = cached - (crossModuleCached ?? 0);
|
|
84
|
+
console.log(chalk.dim(` ├─ Module pages: ${moduleBuilt} built, ${moduleCached} cached`));
|
|
85
|
+
console.log(chalk.dim(` └─ Cross-module pages: ${crossModuleBuilt ?? 0} built, ${crossModuleCached ?? 0} cached`));
|
|
86
|
+
}
|
|
87
|
+
console.log(`Report: ${result.reportPath}`);
|
|
88
|
+
if (result.mode === 'dry-run') {
|
|
89
|
+
console.log(chalk.yellow('\nNext: review the report, then run:'));
|
|
90
|
+
console.log(chalk.bold(' cf knowledge build --apply'));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (result.appliedTo) {
|
|
94
|
+
console.log(chalk.green(`✓ Applied to ${result.appliedTo}`));
|
|
95
|
+
}
|
|
96
|
+
// KB-ADR-006: auto-install git hook on first --apply
|
|
97
|
+
const installResult = installGitHook({ silent: true });
|
|
98
|
+
switch (installResult.action) {
|
|
99
|
+
case 'created':
|
|
100
|
+
console.log(chalk.green('✓ git post-commit hook installed (auto-update on commit)'));
|
|
101
|
+
break;
|
|
102
|
+
case 'appended':
|
|
103
|
+
console.log(chalk.green('✓ cf section appended to existing hook (user hook preserved)'));
|
|
104
|
+
break;
|
|
105
|
+
case 'already-installed':
|
|
106
|
+
console.log(chalk.dim('i cf hook already present'));
|
|
107
|
+
break;
|
|
108
|
+
case 'skipped-non-git':
|
|
109
|
+
console.log(chalk.yellow("i Not a git repo, KB auto-update disabled. Use 'cf knowledge update' manually."));
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
console.log(chalk.dim("\nTip: add `.forge-knowledge/backups/` to .gitignore if you don't want to track them."));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Spec ed8cf2db §5: exposed so `cf project init` can directly drive the same
|
|
117
|
+
* one-shot KB build path without spawning a child `cf knowledge init`
|
|
118
|
+
* subprocess.
|
|
119
|
+
*
|
|
120
|
+
* Spec 2026-06-04/1200 (decision e0eb1695): no longer `process.exit(1)` on an
|
|
121
|
+
* unsupported project type. Monorepo roots build a single aggregate KB;
|
|
122
|
+
* true-generic projects return `{ skipped: 'generic' }` so the caller can mark
|
|
123
|
+
* the step `skipped` and exit 0.
|
|
124
|
+
*/
|
|
125
|
+
export async function initCmd(options) {
|
|
126
|
+
const projectRoot = process.cwd();
|
|
127
|
+
// ── Pre-check 1: Check if project is supported by adapter system ───────
|
|
128
|
+
//
|
|
129
|
+
// Band-aid + monorepo resolution (spec 2026-06-04/1200, decision e0eb1695):
|
|
130
|
+
// - single-language adapter matches → continue (unchanged path)
|
|
131
|
+
// - no root adapter but ≥2 sub-projects each have one → monorepo. Print the
|
|
132
|
+
// detected sub-projects and continue; `buildKnowledge` constructs the
|
|
133
|
+
// `MonorepoAdapter` internally (one KB at the monorepo root).
|
|
134
|
+
// - no root adapter and no sub-projects (true-generic) → warn + RETURN
|
|
135
|
+
// (NO `process.exit(1)`). The caller (`cf project init`) sees a clean
|
|
136
|
+
// resolve and marks the knowledge step `skipped`, exit 0.
|
|
137
|
+
const adapter = getAdapter(projectRoot);
|
|
138
|
+
if (!adapter) {
|
|
139
|
+
const monorepoInfo = detectMonorepo(projectRoot);
|
|
140
|
+
if (monorepoInfo) {
|
|
141
|
+
console.log(chalk.dim(`Detected monorepo with ${monorepoInfo.subprojects.length} sub-projects: ` +
|
|
142
|
+
monorepoInfo.subprojects.map((s) => s.name).join(', ')));
|
|
143
|
+
// adapter (MonorepoAdapter) is created inside buildKnowledge — no exit.
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const subdirs = listCandidateSubdirs(projectRoot);
|
|
147
|
+
console.warn(chalk.yellow('⚠ No supported project type detected (generic project). ' +
|
|
148
|
+
'Knowledge base skipped.'));
|
|
149
|
+
console.warn(chalk.gray('Hint: cd into a sub-project and run `cf project init`, or use a ' +
|
|
150
|
+
'supported manifest (package.json / pom.xml / build.gradle / ' +
|
|
151
|
+
'pyproject.toml / go.mod / Cargo.toml).\n' +
|
|
152
|
+
`Sub-directories found: ${subdirs.length > 0 ? subdirs.join(', ') : 'none'}`));
|
|
153
|
+
return { skipped: 'generic' }; // graceful skip — no process.exit(1)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
console.log(chalk.dim(`Detected ${adapter.name} project`));
|
|
158
|
+
}
|
|
159
|
+
// ── Pre-check 2: KB already initialized? ───────────────────────────────
|
|
160
|
+
if (isKnowledgeBuilt() && !options.force) {
|
|
161
|
+
console.error(chalk.red('Knowledge base already initialized at .forge-knowledge/'));
|
|
162
|
+
console.error(chalk.gray('Use `cf knowledge init --force` to rebuild, or `cf knowledge clean --confirm` first.'));
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
// ── Pre-check 3: REMOVED (sub-spec B, decision f5a5b030) ──────────────
|
|
166
|
+
// The legacy `config.ai.api_key` / `ANTHROPIC_API_KEY` probe is gone. The
|
|
167
|
+
// CLI delegates straight to `buildKnowledge()`, which spawns the
|
|
168
|
+
// `knowledge-builder` agent via `CliKnowledgeProvider`. Any subprocess
|
|
169
|
+
// failures (CLI missing, exit, timeout, envelope missing) bubble up and
|
|
170
|
+
// are mapped to friendly stderr output by `reportKnowledgeBuildError`.
|
|
171
|
+
// ── Build & apply ──────────────────────────────────────────────────────
|
|
172
|
+
console.log(chalk.cyan('Initializing knowledge base...'));
|
|
173
|
+
const result = await buildKnowledge({
|
|
174
|
+
apply: true,
|
|
175
|
+
force: !!options.force,
|
|
176
|
+
skipCrossModule: !!options.skipCrossModule,
|
|
177
|
+
});
|
|
178
|
+
// ── Install git hook (unless --no-hook) ────────────────────────────────
|
|
179
|
+
// commander's `--no-hook` flag sets `options.hook === false`. Default = true.
|
|
180
|
+
const shouldInstallHook = options.hook !== false;
|
|
181
|
+
let hookInstalled = false;
|
|
182
|
+
let hookAlreadyPresent = false;
|
|
183
|
+
let hookSkippedNonGit = false;
|
|
184
|
+
if (shouldInstallHook) {
|
|
185
|
+
try {
|
|
186
|
+
const hookResult = installGitHook({ silent: true });
|
|
187
|
+
switch (hookResult.action) {
|
|
188
|
+
case 'created':
|
|
189
|
+
case 'appended':
|
|
190
|
+
hookInstalled = true;
|
|
191
|
+
break;
|
|
192
|
+
case 'already-installed':
|
|
193
|
+
hookAlreadyPresent = true;
|
|
194
|
+
break;
|
|
195
|
+
case 'skipped-non-git':
|
|
196
|
+
hookSkippedNonGit = true;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
console.log(chalk.yellow(`⚠ Could not install git hook: ${err instanceof Error ? err.message : String(err)}`));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// ── Friendly summary ───────────────────────────────────────────────────
|
|
205
|
+
const { built, cached, total } = result.stats;
|
|
206
|
+
console.log('');
|
|
207
|
+
console.log(chalk.green(`✓ Knowledge base initialized at .forge-knowledge/`));
|
|
208
|
+
console.log(chalk.green(`✓ Built ${built}, cached ${cached}, total ${total} pages`));
|
|
209
|
+
if (hookInstalled) {
|
|
210
|
+
console.log(chalk.green('✓ Git post-commit hook installed'));
|
|
211
|
+
}
|
|
212
|
+
else if (hookAlreadyPresent) {
|
|
213
|
+
console.log(chalk.dim(' Git hook already installed'));
|
|
214
|
+
}
|
|
215
|
+
else if (hookSkippedNonGit) {
|
|
216
|
+
console.log(chalk.dim(' Not a git repo — skipped post-commit hook install'));
|
|
217
|
+
}
|
|
218
|
+
else if (!shouldInstallHook) {
|
|
219
|
+
console.log(chalk.dim(' Git hook install skipped (--no-hook)'));
|
|
220
|
+
}
|
|
221
|
+
console.log('');
|
|
222
|
+
console.log(chalk.bold('Next steps:'));
|
|
223
|
+
console.log(chalk.gray(' cf knowledge query <topic> # Search KB'));
|
|
224
|
+
console.log(chalk.gray(' cf knowledge list # List all pages'));
|
|
225
|
+
console.log(chalk.gray(' cf knowledge audit # Validate refs'));
|
|
226
|
+
}
|
|
227
|
+
async function updateCmd(options) {
|
|
228
|
+
if (!isKnowledgeBuilt()) {
|
|
229
|
+
console.error(chalk.red('Knowledge base not built yet. Run: cf knowledge build --apply'));
|
|
230
|
+
process.exit(1);
|
|
231
|
+
}
|
|
232
|
+
let modulesToUpdate = options.module ? [options.module] : undefined;
|
|
233
|
+
if (!modulesToUpdate) {
|
|
234
|
+
try {
|
|
235
|
+
const diffOutput = execSync('git diff --name-only HEAD~1 HEAD -- src/', {
|
|
236
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
237
|
+
}).toString();
|
|
238
|
+
const changedFiles = diffOutput.trim().split('\n').filter(Boolean);
|
|
239
|
+
const moduleSet = new Set();
|
|
240
|
+
for (const f of changedFiles) {
|
|
241
|
+
const m = f.match(/^src\/([^/]+)\//);
|
|
242
|
+
if (m)
|
|
243
|
+
moduleSet.add(m[1]);
|
|
244
|
+
}
|
|
245
|
+
modulesToUpdate = [...moduleSet];
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
console.error(chalk.yellow('git diff failed — falling back to full rebuild'));
|
|
249
|
+
modulesToUpdate = undefined;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (modulesToUpdate && modulesToUpdate.length === 0) {
|
|
253
|
+
console.log(chalk.dim('No src/ modules affected by recent commits'));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
console.log(chalk.cyan(`Updating modules: ${modulesToUpdate ? modulesToUpdate.join(', ') : 'ALL'}`));
|
|
257
|
+
await buildKnowledge({ apply: true, modules: modulesToUpdate, force: !!options.force });
|
|
258
|
+
console.log(chalk.green('✓ Update complete'));
|
|
259
|
+
}
|
|
260
|
+
async function queryCmd(topic, options) {
|
|
261
|
+
if (!isKnowledgeBuilt()) {
|
|
262
|
+
console.error(chalk.red('Knowledge base not built yet. Run: cf knowledge build --apply'));
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
const maxResults = options.max ? parseInt(options.max, 10) : 3;
|
|
266
|
+
const queryOptions = { maxResults };
|
|
267
|
+
const result = await queryKnowledge(topic, queryOptions);
|
|
268
|
+
if (options.json) {
|
|
269
|
+
console.log(JSON.stringify(result, null, 2));
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const pagesScanned = 'total_pages_scanned' in result ? result.total_pages_scanned : '?';
|
|
273
|
+
console.log(chalk.bold(`\nQuery: "${topic}"`));
|
|
274
|
+
console.log(chalk.dim(`Scanned ${pagesScanned} pages, found ${result.pages.length} hits\n`));
|
|
275
|
+
if (result.pages.length === 0) {
|
|
276
|
+
console.log(chalk.yellow('No matching pages found.'));
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
for (const hit of result.pages) {
|
|
280
|
+
console.log(chalk.cyan(`## ${hit.page.name} (score: ${hit.score})`));
|
|
281
|
+
console.log(chalk.dim(` matched: ${hit.matched_keywords.join(', ')} in ${hit.matched_in.join(', ')}`));
|
|
282
|
+
const preview = hit.page.content.substring(0, 300);
|
|
283
|
+
const ellipsis = hit.page.content.length > 300 ? '...' : '';
|
|
284
|
+
console.log(`${preview}${ellipsis}`);
|
|
285
|
+
console.log();
|
|
286
|
+
}
|
|
287
|
+
if (result.repo_map_hits &&
|
|
288
|
+
Array.isArray(result.repo_map_hits) &&
|
|
289
|
+
result.repo_map_hits.length > 0) {
|
|
290
|
+
console.log(chalk.bold('Symbol hits:'));
|
|
291
|
+
for (const s of result.repo_map_hits.slice(0, 5)) {
|
|
292
|
+
console.log(` - ${s.name} (${s.file}:${s.line})`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/** Maximum characters to keep from a page's overview section. */
|
|
297
|
+
const FETCH_OVERVIEW_MAX_CHARS = 200;
|
|
298
|
+
/** Maximum number of key-file lines to surface per page. */
|
|
299
|
+
const FETCH_KEY_FILES_PER_PAGE = 5;
|
|
300
|
+
/** Maximum number of repo-map symbol hits to surface in the trailer. */
|
|
301
|
+
const FETCH_REPO_MAP_MAX = 5;
|
|
302
|
+
/**
|
|
303
|
+
* Pull a short overview blurb out of a KB page's markdown body.
|
|
304
|
+
*
|
|
305
|
+
* Strategy:
|
|
306
|
+
* 1. Prefer the body of a `## 概述` (or `## Overview`) section, stopping at
|
|
307
|
+
* the next `## ` heading.
|
|
308
|
+
* 2. Fall back to the first non-metadata paragraph (skip `# title` and the
|
|
309
|
+
* `> Generated:` line).
|
|
310
|
+
* 3. Truncate to `FETCH_OVERVIEW_MAX_CHARS` with an ellipsis when needed.
|
|
311
|
+
*/
|
|
312
|
+
function extractOverview(content) {
|
|
313
|
+
const lines = content.split('\n');
|
|
314
|
+
// ── Try the dedicated 概述/Overview section first ──────────────────────────
|
|
315
|
+
const headerIdx = lines.findIndex((l) => /^##\s+(概述|Overview)\b/i.test(l));
|
|
316
|
+
if (headerIdx !== -1) {
|
|
317
|
+
const body = [];
|
|
318
|
+
for (let i = headerIdx + 1; i < lines.length; i++) {
|
|
319
|
+
if (lines[i].startsWith('## '))
|
|
320
|
+
break;
|
|
321
|
+
body.push(lines[i]);
|
|
322
|
+
}
|
|
323
|
+
const text = body.join(' ').replace(/\s+/g, ' ').trim();
|
|
324
|
+
if (text.length > 0)
|
|
325
|
+
return truncate(text, FETCH_OVERVIEW_MAX_CHARS);
|
|
326
|
+
}
|
|
327
|
+
// ── Fallback: first prose paragraph after the metadata block ──────────────
|
|
328
|
+
for (const line of lines) {
|
|
329
|
+
const trimmed = line.trim();
|
|
330
|
+
if (!trimmed)
|
|
331
|
+
continue;
|
|
332
|
+
if (trimmed.startsWith('#'))
|
|
333
|
+
continue;
|
|
334
|
+
if (trimmed.startsWith('>'))
|
|
335
|
+
continue;
|
|
336
|
+
return truncate(trimmed, FETCH_OVERVIEW_MAX_CHARS);
|
|
337
|
+
}
|
|
338
|
+
return '';
|
|
339
|
+
}
|
|
340
|
+
function truncate(s, max) {
|
|
341
|
+
if (s.length <= max)
|
|
342
|
+
return s;
|
|
343
|
+
return `${s.slice(0, max).trimEnd()}...`;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Pick a small set of representative `file:line — symbol` lines from a page's
|
|
347
|
+
* refs. Refs are deduplicated by `file:lineStart` and refs carrying a symbol
|
|
348
|
+
* are preferred over plain ranges.
|
|
349
|
+
*/
|
|
350
|
+
function formatKeyFiles(refs) {
|
|
351
|
+
const seen = new Set();
|
|
352
|
+
const ordered = [];
|
|
353
|
+
// Pass 1: refs with symbols (most informative).
|
|
354
|
+
for (const r of refs) {
|
|
355
|
+
if (!r.symbol)
|
|
356
|
+
continue;
|
|
357
|
+
const key = `${r.file}:${r.lineStart}`;
|
|
358
|
+
if (seen.has(key))
|
|
359
|
+
continue;
|
|
360
|
+
seen.add(key);
|
|
361
|
+
ordered.push(r);
|
|
362
|
+
if (ordered.length >= FETCH_KEY_FILES_PER_PAGE)
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
// Pass 2: fill remaining slots with non-symbol refs.
|
|
366
|
+
if (ordered.length < FETCH_KEY_FILES_PER_PAGE) {
|
|
367
|
+
for (const r of refs) {
|
|
368
|
+
if (r.symbol)
|
|
369
|
+
continue;
|
|
370
|
+
const key = `${r.file}:${r.lineStart}`;
|
|
371
|
+
if (seen.has(key))
|
|
372
|
+
continue;
|
|
373
|
+
seen.add(key);
|
|
374
|
+
ordered.push(r);
|
|
375
|
+
if (ordered.length >= FETCH_KEY_FILES_PER_PAGE)
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return ordered.map((r) => {
|
|
380
|
+
const loc = `\`${r.file}:${r.lineStart}\``;
|
|
381
|
+
return r.symbol ? `- ${loc} — \`${r.symbol}\`` : `- ${loc}`;
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Render a `QueryResultExtended` as a Markdown block ready to paste into an
|
|
386
|
+
* agent prompt. Public for unit testing; not re-exported from index.
|
|
387
|
+
*/
|
|
388
|
+
export function formatFetchPrompt(result) {
|
|
389
|
+
const parts = ['## 项目背景(来自 .forge-knowledge/)', ''];
|
|
390
|
+
for (const hit of result.pages) {
|
|
391
|
+
const matched = hit.matched_keywords.length > 0
|
|
392
|
+
? `, matched: ${hit.matched_keywords.join(', ')}`
|
|
393
|
+
: '';
|
|
394
|
+
parts.push(`### ${hit.page.name} (score: ${hit.score}${matched})`);
|
|
395
|
+
parts.push('');
|
|
396
|
+
const overview = extractOverview(hit.page.content);
|
|
397
|
+
if (overview) {
|
|
398
|
+
parts.push(overview);
|
|
399
|
+
parts.push('');
|
|
400
|
+
}
|
|
401
|
+
const keyFiles = formatKeyFiles(hit.page.refs);
|
|
402
|
+
if (keyFiles.length > 0) {
|
|
403
|
+
parts.push('**关键文件**:');
|
|
404
|
+
parts.push(...keyFiles);
|
|
405
|
+
parts.push('');
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (result.repo_map_hits && result.repo_map_hits.length > 0) {
|
|
409
|
+
parts.push(`**Repo-map 命中(symbols 含 '${result.query}')**:`);
|
|
410
|
+
for (const s of result.repo_map_hits.slice(0, FETCH_REPO_MAP_MAX)) {
|
|
411
|
+
parts.push(`- \`${s.file}:${s.line}\` — \`${s.name}\``);
|
|
412
|
+
}
|
|
413
|
+
parts.push('');
|
|
414
|
+
}
|
|
415
|
+
// Trim trailing empty lines for tidy output.
|
|
416
|
+
while (parts.length > 0 && parts[parts.length - 1] === '')
|
|
417
|
+
parts.pop();
|
|
418
|
+
return parts.join('\n');
|
|
419
|
+
}
|
|
420
|
+
async function fetchCmd(topic, options) {
|
|
421
|
+
if (!isKnowledgeBuilt()) {
|
|
422
|
+
console.error(chalk.red('Knowledge base not built yet. Run: cf knowledge build --apply'));
|
|
423
|
+
process.exit(1);
|
|
424
|
+
}
|
|
425
|
+
const format = options.format ?? 'prompt';
|
|
426
|
+
if (format !== 'prompt' && format !== 'json') {
|
|
427
|
+
console.error(chalk.red(`Invalid --format: "${format}" (expected "prompt" or "json")`));
|
|
428
|
+
process.exit(1);
|
|
429
|
+
}
|
|
430
|
+
const maxResults = options.max ? parseInt(options.max, 10) : 3;
|
|
431
|
+
const queryOptions = { maxResults };
|
|
432
|
+
const result = await queryKnowledge(topic, queryOptions);
|
|
433
|
+
if (format === 'json') {
|
|
434
|
+
console.log(JSON.stringify(result, null, 2));
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
// Prompt format
|
|
438
|
+
const hasPages = result.pages.length > 0;
|
|
439
|
+
const hasRepoMap = !!(result.repo_map_hits && result.repo_map_hits.length > 0);
|
|
440
|
+
if (!hasPages && !hasRepoMap) {
|
|
441
|
+
console.error(chalk.yellow(`No matches found for "${topic}". Try simpler keywords.`));
|
|
442
|
+
process.exit(1);
|
|
443
|
+
}
|
|
444
|
+
console.log(formatFetchPrompt(result));
|
|
445
|
+
}
|
|
446
|
+
async function listCmd(options) {
|
|
447
|
+
if (!isKnowledgeBuilt()) {
|
|
448
|
+
console.log(chalk.yellow('No knowledge pages found. Run: cf knowledge build --apply'));
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const pages = await listKnowledge();
|
|
452
|
+
if (options.json) {
|
|
453
|
+
console.log(JSON.stringify(pages.map((p) => ({
|
|
454
|
+
name: p.name,
|
|
455
|
+
title: p.title,
|
|
456
|
+
refs: p.refs.length,
|
|
457
|
+
kind: p.name.includes('/') ? 'module' : 'cross',
|
|
458
|
+
})), null, 2));
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (pages.length === 0) {
|
|
462
|
+
console.log(chalk.yellow('No knowledge pages found. Run: cf knowledge build --apply'));
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
// Sort: cross-module pages first (alpha), then module pages (alpha).
|
|
466
|
+
const sorted = [...pages].sort((a, b) => {
|
|
467
|
+
const aCross = !a.name.includes('/');
|
|
468
|
+
const bCross = !b.name.includes('/');
|
|
469
|
+
if (aCross !== bCross)
|
|
470
|
+
return aCross ? -1 : 1;
|
|
471
|
+
return a.name.localeCompare(b.name);
|
|
472
|
+
});
|
|
473
|
+
for (const p of sorted) {
|
|
474
|
+
const isCross = !p.name.includes('/');
|
|
475
|
+
const tag = isCross ? chalk.magenta('[cross] ') : chalk.blue('[module]');
|
|
476
|
+
const refsCol = isCross ? '' : ` (${p.refs.length} refs)`;
|
|
477
|
+
console.log(`${tag} ${chalk.cyan(p.name)}: ${p.title}${refsCol}`);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
async function auditCmd(options) {
|
|
481
|
+
if (!isKnowledgeBuilt()) {
|
|
482
|
+
console.error(chalk.red('Knowledge base not built yet. Run: cf knowledge build --apply'));
|
|
483
|
+
process.exit(1);
|
|
484
|
+
}
|
|
485
|
+
const pages = await listKnowledge();
|
|
486
|
+
if (pages.length === 0) {
|
|
487
|
+
console.log(chalk.yellow('No knowledge pages to audit.'));
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
const kbDir = path.join(process.cwd(), K.KB_DIRNAME);
|
|
491
|
+
const repoMap = loadRepoMap(kbDir);
|
|
492
|
+
let totalRefs = 0;
|
|
493
|
+
let validRefs = 0;
|
|
494
|
+
let staleRefs = 0;
|
|
495
|
+
let errorCount = 0;
|
|
496
|
+
const auditResults = [];
|
|
497
|
+
for (const page of pages) {
|
|
498
|
+
const result = validatePage(page, { repoMap: repoMap?.symbols });
|
|
499
|
+
totalRefs += result.refsTotal;
|
|
500
|
+
validRefs += result.refsValid;
|
|
501
|
+
const status = deriveAuditStatus(result.issues);
|
|
502
|
+
auditResults.push({ name: page.name, status, issues: result.issues });
|
|
503
|
+
const isCross = !page.name.includes('/');
|
|
504
|
+
if (!result.valid) {
|
|
505
|
+
errorCount++;
|
|
506
|
+
console.log(chalk.yellow(`⚠ ${page.name}: ${result.issues.length} issues`));
|
|
507
|
+
for (const issue of result.issues) {
|
|
508
|
+
const icon = issue.severity === 'error' ? chalk.red('✗') : chalk.yellow('⚠');
|
|
509
|
+
console.log(` ${icon} ${issue.msg}`);
|
|
510
|
+
if (issue.severity === 'warn')
|
|
511
|
+
staleRefs++;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
else if (isCross && result.refsTotal === 0) {
|
|
515
|
+
console.log(chalk.green(`✓ ${page.name}`) +
|
|
516
|
+
chalk.gray(' (cross-module, no refs to validate)'));
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
console.log(chalk.green(`✓ ${page.name}`));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
console.log(chalk.bold(`\nTotal: ${validRefs}/${totalRefs} refs valid, ${staleRefs} stale, ${errorCount} pages with errors`));
|
|
523
|
+
if (options.fix) {
|
|
524
|
+
try {
|
|
525
|
+
const sourceHash = getGitShortHash();
|
|
526
|
+
const outcome = applyAuditResult({
|
|
527
|
+
kbDir,
|
|
528
|
+
results: auditResults,
|
|
529
|
+
sourceHash,
|
|
530
|
+
now: new Date(),
|
|
531
|
+
});
|
|
532
|
+
if (outcome.metaUpdated) {
|
|
533
|
+
console.log(chalk.green(`\n✓ Audit results written to ${path.relative(process.cwd(), outcome.metaPath)}`));
|
|
534
|
+
}
|
|
535
|
+
if (outcome.logAppended) {
|
|
536
|
+
console.log(chalk.green(`✓ Audit log appended at ${path.relative(process.cwd(), outcome.logPath)}`));
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
catch (err) {
|
|
540
|
+
console.error(chalk.red('Audit fix failed:'), err instanceof Error ? err.message : String(err));
|
|
541
|
+
process.exit(1);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
else if (staleRefs > 0 || errorCount > 0) {
|
|
545
|
+
console.log(chalk.yellow('\nRun with --fix to record this audit'));
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function getGitShortHash() {
|
|
549
|
+
try {
|
|
550
|
+
return execSync('git rev-parse --short HEAD', {
|
|
551
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
552
|
+
})
|
|
553
|
+
.toString()
|
|
554
|
+
.trim();
|
|
555
|
+
}
|
|
556
|
+
catch {
|
|
557
|
+
return 'no-git';
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* `cf kb fix [--dry-run]` — Detect broken (`source_hash === 'build-failed'`) and
|
|
562
|
+
* orphan (on-disk page without meta.json entry) module pages, then rebuild them.
|
|
563
|
+
*
|
|
564
|
+
* Contract: spec docs/design/2026-06-01/1451-kb-data-fix-spec.md §5.3.
|
|
565
|
+
*
|
|
566
|
+
* Out of scope: stale/error audit_status (use `cf kb audit --fix`).
|
|
567
|
+
*/
|
|
568
|
+
export async function fixCmd(options) {
|
|
569
|
+
if (!isKnowledgeBuilt()) {
|
|
570
|
+
console.error(chalk.red('Knowledge base not built yet. Run: cf knowledge build --apply'));
|
|
571
|
+
process.exit(1);
|
|
572
|
+
}
|
|
573
|
+
const kbDir = path.join(process.cwd(), K.KB_DIRNAME);
|
|
574
|
+
const metaPath = path.join(kbDir, '.meta.json');
|
|
575
|
+
const modulesDir = path.join(kbDir, K.KB_MODULES_DIR);
|
|
576
|
+
// ── 1. Read meta.json ─────────────────────────────────────────────────────
|
|
577
|
+
let meta = { pages: {} };
|
|
578
|
+
try {
|
|
579
|
+
if (fs.existsSync(metaPath)) {
|
|
580
|
+
const raw = fs.readFileSync(metaPath, 'utf8');
|
|
581
|
+
meta = JSON.parse(raw);
|
|
582
|
+
if (!meta.pages)
|
|
583
|
+
meta.pages = {};
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
catch (err) {
|
|
587
|
+
console.error(chalk.red('Failed to read .meta.json:'), err instanceof Error ? err.message : String(err));
|
|
588
|
+
process.exit(1);
|
|
589
|
+
}
|
|
590
|
+
const pagesBefore = Object.keys(meta.pages).length;
|
|
591
|
+
const toFix = [];
|
|
592
|
+
// 2a. build-failed entries
|
|
593
|
+
for (const [pageKey, entry] of Object.entries(meta.pages)) {
|
|
594
|
+
if (entry?.source_hash === 'build-failed') {
|
|
595
|
+
const m = pageKey.match(/^modules\/(.+)\.md$/);
|
|
596
|
+
if (m) {
|
|
597
|
+
toFix.push({
|
|
598
|
+
page: pageKey,
|
|
599
|
+
module: m[1],
|
|
600
|
+
reason: 'build-failed (last LLM call errored)',
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
// 2b. orphans (on-disk module page without meta entry)
|
|
606
|
+
if (fs.existsSync(modulesDir)) {
|
|
607
|
+
const onDisk = fs
|
|
608
|
+
.readdirSync(modulesDir)
|
|
609
|
+
.filter((f) => f.endsWith('.md'));
|
|
610
|
+
for (const file of onDisk) {
|
|
611
|
+
const pageKey = `modules/${file}`;
|
|
612
|
+
const moduleName = file.replace(/\.md$/, '');
|
|
613
|
+
if (!meta.pages[pageKey]) {
|
|
614
|
+
// Skip if already counted as build-failed above (defensive — shouldn't
|
|
615
|
+
// happen since build-failed entries live IN meta.pages by definition).
|
|
616
|
+
if (toFix.some((e) => e.page === pageKey))
|
|
617
|
+
continue;
|
|
618
|
+
toFix.push({
|
|
619
|
+
page: pageKey,
|
|
620
|
+
module: moduleName,
|
|
621
|
+
reason: 'orphan (on disk, not in meta.json)',
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
// ── 3. Report ──────────────────────────────────────────────────────────────
|
|
627
|
+
if (toFix.length === 0) {
|
|
628
|
+
console.log(chalk.green('✅ KB is healthy. 0 pages to fix.'));
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
console.log(chalk.bold(`\nTo fix (${toFix.length} pages):`));
|
|
632
|
+
for (const entry of toFix) {
|
|
633
|
+
console.log(` ${entry.page.padEnd(28)} — ${entry.reason}`);
|
|
634
|
+
}
|
|
635
|
+
if (options.dryRun) {
|
|
636
|
+
console.log(chalk.dim(`\nUse 'cf kb fix' (without --dry-run) to rebuild.`));
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
// ── 4. Real run: invoke buildKnowledge once with module list ─────────────
|
|
640
|
+
const modules = [...new Set(toFix.map((e) => e.module))];
|
|
641
|
+
console.log('');
|
|
642
|
+
console.log(chalk.cyan(`Rebuilding ${modules.length} module(s): ${modules.join(', ')}`));
|
|
643
|
+
try {
|
|
644
|
+
await buildKnowledge({ modules, force: true, apply: true });
|
|
645
|
+
}
|
|
646
|
+
catch (err) {
|
|
647
|
+
reportKnowledgeBuildError('Fix failed:', err);
|
|
648
|
+
process.exit(1);
|
|
649
|
+
}
|
|
650
|
+
// ── 5. Completion print ───────────────────────────────────────────────────
|
|
651
|
+
let pagesAfter = pagesBefore;
|
|
652
|
+
try {
|
|
653
|
+
if (fs.existsSync(metaPath)) {
|
|
654
|
+
const raw = fs.readFileSync(metaPath, 'utf8');
|
|
655
|
+
const updated = JSON.parse(raw);
|
|
656
|
+
pagesAfter = Object.keys(updated.pages ?? {}).length;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
catch {
|
|
660
|
+
// Non-fatal — print without delta.
|
|
661
|
+
}
|
|
662
|
+
console.log('');
|
|
663
|
+
console.log(chalk.green(`✅ Fixed ${modules.length} pages: ${modules.join(', ')}`));
|
|
664
|
+
if (pagesAfter !== pagesBefore) {
|
|
665
|
+
console.log(chalk.dim(`meta.json pages: ${pagesBefore} → ${pagesAfter}`));
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
async function cleanCmd(options) {
|
|
669
|
+
const kbDir = path.join(process.cwd(), K.KB_DIRNAME);
|
|
670
|
+
if (!fs.existsSync(kbDir)) {
|
|
671
|
+
console.log(chalk.yellow('No knowledge base found — nothing to clean'));
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
if (!options.confirm) {
|
|
675
|
+
console.log(chalk.red(`Will delete: ${kbDir}`));
|
|
676
|
+
console.log(chalk.red('Will also uninstall the git post-commit hook.'));
|
|
677
|
+
console.log(chalk.red('\nRun with --confirm to proceed.'));
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
fs.rmSync(kbDir, { recursive: true, force: true });
|
|
681
|
+
console.log(chalk.green(`✓ Removed ${kbDir}`));
|
|
682
|
+
const uninstallResult = uninstallGitHook({ silent: true });
|
|
683
|
+
switch (uninstallResult.action) {
|
|
684
|
+
case 'removed':
|
|
685
|
+
if (uninstallResult.preservedUserContent) {
|
|
686
|
+
console.log(chalk.green('✓ git hook uninstalled (user hook content preserved)'));
|
|
687
|
+
}
|
|
688
|
+
else {
|
|
689
|
+
console.log(chalk.green('✓ git hook file removed (no remaining user content)'));
|
|
690
|
+
}
|
|
691
|
+
break;
|
|
692
|
+
case 'not-installed':
|
|
693
|
+
console.log(chalk.dim('i No git hook to uninstall'));
|
|
694
|
+
break;
|
|
695
|
+
case 'skipped-no-cf-section':
|
|
696
|
+
console.log(chalk.yellow('⚠ git hook exists but has no cf section — left untouched'));
|
|
697
|
+
break;
|
|
698
|
+
case 'skipped-non-git':
|
|
699
|
+
console.log(chalk.dim('i Not a git repo — nothing to uninstall'));
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
704
|
+
// rollback
|
|
705
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
706
|
+
async function rollbackCmd(ts) {
|
|
707
|
+
const backupDir = path.join(process.cwd(), K.KB_DIRNAME, K.KB_BACKUPS_DIR, ts);
|
|
708
|
+
if (!fs.existsSync(backupDir)) {
|
|
709
|
+
console.error(chalk.red(`Backup not found: ${backupDir}`));
|
|
710
|
+
console.error(chalk.dim(`Available backups:\n ${listBackups(path.join(process.cwd(), K.KB_DIRNAME, K.KB_BACKUPS_DIR))}`));
|
|
711
|
+
process.exit(1);
|
|
712
|
+
}
|
|
713
|
+
const srcModulesBackup = path.join(backupDir, 'modules');
|
|
714
|
+
const hasModulesBackup = fs.existsSync(srcModulesBackup);
|
|
715
|
+
// v9.2: cross-module root pages — only rollback what exists in the snapshot.
|
|
716
|
+
const crossNames = ['overview.md', 'architecture.md', 'decisions.md', 'glossary.md', 'tech-stack.md'];
|
|
717
|
+
const crossBackupPresent = crossNames.filter((n) => fs.existsSync(path.join(backupDir, n)));
|
|
718
|
+
if (!hasModulesBackup && crossBackupPresent.length === 0) {
|
|
719
|
+
console.error(chalk.red(`Backup is empty (no modules/ or cross-module pages): ${backupDir}`));
|
|
720
|
+
process.exit(1);
|
|
721
|
+
}
|
|
722
|
+
if (hasModulesBackup) {
|
|
723
|
+
const modulesDir = path.join(process.cwd(), K.KB_DIRNAME, K.KB_MODULES_DIR);
|
|
724
|
+
if (fs.existsSync(modulesDir)) {
|
|
725
|
+
fs.rmSync(modulesDir, { recursive: true, force: true });
|
|
726
|
+
}
|
|
727
|
+
fs.cpSync(srcModulesBackup, modulesDir, { recursive: true });
|
|
728
|
+
}
|
|
729
|
+
for (const name of crossBackupPresent) {
|
|
730
|
+
const srcBackup = path.join(backupDir, name);
|
|
731
|
+
const dst = path.join(process.cwd(), K.KB_DIRNAME, name);
|
|
732
|
+
fs.copyFileSync(srcBackup, dst);
|
|
733
|
+
}
|
|
734
|
+
console.log(chalk.green(`✓ Rolled back to backup: ${ts}` +
|
|
735
|
+
(crossBackupPresent.length > 0
|
|
736
|
+
? ` (modules${hasModulesBackup ? '/' : ' skipped'} + ${crossBackupPresent.length} cross-module page${crossBackupPresent.length > 1 ? 's' : ''})`
|
|
737
|
+
: '')));
|
|
738
|
+
}
|
|
739
|
+
function listBackups(backupsDir) {
|
|
740
|
+
if (!fs.existsSync(backupsDir))
|
|
741
|
+
return '(none)';
|
|
742
|
+
const entries = fs.readdirSync(backupsDir).sort().reverse();
|
|
743
|
+
return entries.length > 0 ? entries.join('\n ') : '(none)';
|
|
744
|
+
}
|
|
745
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
746
|
+
// hook-status
|
|
747
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
748
|
+
async function hookStatusCmd() {
|
|
749
|
+
const status = getHookStatus();
|
|
750
|
+
if (!status.isGitRepo) {
|
|
751
|
+
console.log(chalk.yellow('Not a git repository — git hook is not applicable'));
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (status.installed) {
|
|
755
|
+
console.log(chalk.green(`✓ cf hook installed: ${status.hookPath}`));
|
|
756
|
+
if (status.userHasOwnHook) {
|
|
757
|
+
console.log(chalk.dim(' (user has own hook content too — coexisting)'));
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
console.log(chalk.yellow('✗ cf hook NOT installed'));
|
|
762
|
+
console.log(` Path: ${status.hookPath ?? 'N/A'}`);
|
|
763
|
+
if (status.userHasOwnHook) {
|
|
764
|
+
console.log(chalk.dim(' (user has own hook content — no cf section yet)'));
|
|
765
|
+
}
|
|
766
|
+
console.log(chalk.dim('\n Run: cf knowledge build --apply to auto-install'));
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
770
|
+
// Registration
|
|
771
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
772
|
+
function registerSubcommands(knowledge) {
|
|
773
|
+
knowledge
|
|
774
|
+
.command('build')
|
|
775
|
+
.description('Compile knowledge base from source (default: dry-run)')
|
|
776
|
+
.option('--apply', 'Write pages to .forge-knowledge/ and install git hook')
|
|
777
|
+
.option('--force', 'Force rebuild ignoring source_hash cache')
|
|
778
|
+
.option('--module <name>', 'Build only a specific src/ module')
|
|
779
|
+
.option('--skip-cross-module', 'Skip overview/architecture/decisions/glossary/tech-stack pages')
|
|
780
|
+
.action((options) => {
|
|
781
|
+
buildCmd(options).catch((err) => {
|
|
782
|
+
reportKnowledgeBuildError('Build failed:', err);
|
|
783
|
+
process.exit(1);
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
knowledge
|
|
787
|
+
.command('init')
|
|
788
|
+
.description('Initialize knowledge base in current project (build + apply + git hook in one shot)')
|
|
789
|
+
.option('--force', 'Force rebuild even if KB already exists')
|
|
790
|
+
.option('--skip-cross-module', 'Skip overview/architecture/decisions/glossary/tech-stack pages')
|
|
791
|
+
.option('--no-hook', 'Do not install the git post-commit hook')
|
|
792
|
+
.action((options) => {
|
|
793
|
+
initCmd(options).catch((err) => {
|
|
794
|
+
reportKnowledgeBuildError('Init failed:', err);
|
|
795
|
+
process.exit(1);
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
knowledge
|
|
799
|
+
.command('update')
|
|
800
|
+
.description('Incremental update based on git diff (requires prior build --apply)')
|
|
801
|
+
.option('--module <name>', 'Update only a specific src/ module')
|
|
802
|
+
.option('--force', 'Bypass module hash cache and rebuild every affected module')
|
|
803
|
+
.action((options) => {
|
|
804
|
+
updateCmd(options).catch((err) => {
|
|
805
|
+
reportKnowledgeBuildError('Update failed:', err);
|
|
806
|
+
process.exit(1);
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
knowledge
|
|
810
|
+
.command('query <topic>')
|
|
811
|
+
.description('Keyword search across knowledge pages and repo-map symbols')
|
|
812
|
+
.option('--max <N>', 'Maximum number of result pages', '3')
|
|
813
|
+
.option('--json', 'Output results as JSON')
|
|
814
|
+
.action((topic, options) => {
|
|
815
|
+
queryCmd(topic, options).catch((err) => {
|
|
816
|
+
console.error(chalk.red('Query failed:'), err instanceof Error ? err.message : String(err));
|
|
817
|
+
process.exit(1);
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
knowledge
|
|
821
|
+
.command('fetch <topic>')
|
|
822
|
+
.description('Format KB hits as a Markdown prompt block ready to paste into a sub-agent')
|
|
823
|
+
.option('--max <N>', 'Maximum number of result pages', '3')
|
|
824
|
+
.option('--format <prompt|json>', 'Output format: "prompt" (Markdown, default) or "json"', 'prompt')
|
|
825
|
+
.action((topic, options) => {
|
|
826
|
+
fetchCmd(topic, options).catch((err) => {
|
|
827
|
+
console.error(chalk.red('Fetch failed:'), err instanceof Error ? err.message : String(err));
|
|
828
|
+
process.exit(1);
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
knowledge
|
|
832
|
+
.command('list')
|
|
833
|
+
.description('List all compiled knowledge pages')
|
|
834
|
+
.option('--json', 'Output as JSON')
|
|
835
|
+
.action((options) => {
|
|
836
|
+
listCmd(options).catch((err) => {
|
|
837
|
+
console.error(chalk.red('List failed:'), err instanceof Error ? err.message : String(err));
|
|
838
|
+
process.exit(1);
|
|
839
|
+
});
|
|
840
|
+
});
|
|
841
|
+
knowledge
|
|
842
|
+
.command('audit')
|
|
843
|
+
.description('Validate all page refs against current source tree')
|
|
844
|
+
.option('--fix', 'Mark audit_status in meta.json and write .audit-log.md')
|
|
845
|
+
.action((options) => {
|
|
846
|
+
auditCmd(options).catch((err) => {
|
|
847
|
+
console.error(chalk.red('Audit failed:'), err instanceof Error ? err.message : String(err));
|
|
848
|
+
process.exit(1);
|
|
849
|
+
});
|
|
850
|
+
});
|
|
851
|
+
knowledge
|
|
852
|
+
.command('fix')
|
|
853
|
+
.description('Detect and rebuild broken/orphan KB pages (one-shot maintenance)')
|
|
854
|
+
.option('--dry-run', 'List broken pages without rebuilding')
|
|
855
|
+
.action((options) => {
|
|
856
|
+
fixCmd(options).catch((err) => {
|
|
857
|
+
reportKnowledgeBuildError('Fix failed:', err);
|
|
858
|
+
process.exit(1);
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
knowledge
|
|
862
|
+
.command('clean')
|
|
863
|
+
.description('Delete .forge-knowledge/ and uninstall git hook')
|
|
864
|
+
.option('--confirm', 'Required to proceed (prevents accidental deletion)')
|
|
865
|
+
.action((options) => {
|
|
866
|
+
cleanCmd(options).catch((err) => {
|
|
867
|
+
console.error(chalk.red('Clean failed:'), err instanceof Error ? err.message : String(err));
|
|
868
|
+
process.exit(1);
|
|
869
|
+
});
|
|
870
|
+
});
|
|
871
|
+
knowledge
|
|
872
|
+
.command('rollback <ts>')
|
|
873
|
+
.description('Restore pages from a backup snapshot (e.g. 20260519-1500)')
|
|
874
|
+
.action((ts) => {
|
|
875
|
+
rollbackCmd(ts).catch((err) => {
|
|
876
|
+
console.error(chalk.red('Rollback failed:'), err instanceof Error ? err.message : String(err));
|
|
877
|
+
process.exit(1);
|
|
878
|
+
});
|
|
879
|
+
});
|
|
880
|
+
knowledge
|
|
881
|
+
.command('hook-status')
|
|
882
|
+
.description('Show git post-commit hook installation status')
|
|
883
|
+
.action(() => {
|
|
884
|
+
hookStatusCmd().catch((err) => {
|
|
885
|
+
console.error(chalk.red('hook-status failed:'), err instanceof Error ? err.message : String(err));
|
|
886
|
+
process.exit(1);
|
|
887
|
+
});
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
export function register(program) {
|
|
891
|
+
const knowledge = program
|
|
892
|
+
.command('knowledge')
|
|
893
|
+
.alias('kb')
|
|
894
|
+
.description('Project knowledge base — build / update / query / audit (v9.0)');
|
|
895
|
+
registerSubcommands(knowledge);
|
|
896
|
+
}
|
|
897
|
+
//# sourceMappingURL=knowledge.js.map
|