@cortex-agent/server 2026.6.22 → 2026.7.30
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/README.md +25 -13
- package/defaults/.claude/settings.json +4 -0
- package/defaults/config/CORTEX.md +9 -0
- package/defaults/config/hooks/01-sensitive-file-edit.json +11 -0
- package/defaults/config/hooks/02-tasks-yaml-guard.json +11 -0
- package/defaults/config/hooks/03-ask-user-question-hook.json +19 -0
- package/defaults/config/hooks/04-exit-plan-mode-hook.json +19 -0
- package/defaults/config/hooks/05-memory-ref-tracker.json +10 -0
- package/defaults/config/hooks/06-rules-loader.json +10 -0
- package/defaults/config/hooks/07-session-activity-tracker.json +10 -0
- package/defaults/config/hooks/08-cortex-md-injector-post-tool.json +10 -0
- package/defaults/config/hooks/09-permission-request-auto-allow.json +11 -0
- package/defaults/config/hooks/10-cortex-md-injector-session-start.json +10 -0
- package/defaults/config/hooks/11-task-status-check.json +14 -0
- package/defaults/config/hooks/12-session-new-hook.json +11 -0
- package/defaults/config/hooks/CORTEX.md +18 -0
- package/defaults/config/thread-templates/agents/coder-reviewer.json +25 -0
- package/defaults/config/thread-templates/agents/coder.json +30 -0
- package/defaults/config/thread-templates/agents/direct-review.json +17 -0
- package/defaults/config/thread-templates/agents/direct-web.json +16 -0
- package/defaults/config/thread-templates/agents/direct.json +16 -0
- package/defaults/config/thread-templates/agents/director.json +14 -0
- package/defaults/config/thread-templates/agents/doc-reviewer.json +14 -0
- package/defaults/config/thread-templates/agents/doc-writer.json +25 -0
- package/defaults/config/thread-templates/agents/executor-reviewer.json +14 -0
- package/defaults/config/thread-templates/agents/executor.json +25 -0
- package/defaults/config/thread-templates/agents/main.json +16 -0
- package/defaults/config/thread-templates/agents/manager.json +17 -0
- package/defaults/config/thread-templates/agents/scheduler-main.json +16 -0
- package/defaults/config/thread-templates/shells/worker-review.json +19 -0
- package/defaults/config/thread-templates/templates/coder-review.json +53 -0
- package/defaults/config/thread-templates/templates/default.json +10 -0
- package/defaults/config/thread-templates/templates/doc-review.json +6 -0
- package/defaults/config/thread-templates/templates/execute-review.json +6 -0
- package/defaults/config/thread-templates/templates/manager.json +11 -0
- package/defaults/config/thread-templates/templates/scheduler.json +19 -0
- package/defaults/context/decisions/DR-0012.md +1 -1
- package/defaults/context/user/CORTEX.md +2 -2
- package/defaults/gitignore +3 -0
- package/defaults/hooks/CORTEX.md +18 -0
- package/defaults/hooks/ask-user-question-hook.mjs +1 -0
- package/defaults/hooks/cortex-hook-api.mjs +84 -0
- package/defaults/hooks/cortex-md-injector.mjs +99 -49
- package/defaults/hooks/exit-plan-mode-hook.mjs +1 -0
- package/defaults/hooks/memory-ref-tracker.mjs +1 -0
- package/defaults/hooks/new-session-hook.mjs +1 -0
- package/defaults/hooks/post-task-hook.mjs +1 -0
- package/defaults/hooks/rules-loader.mjs +1 -0
- package/defaults/hooks/sensitive-file-edit.mjs +1 -0
- package/defaults/hooks/session-activity-tracker.mjs +8 -100
- package/defaults/hooks/task-status-check.mjs +10 -10
- package/defaults/hooks/tasks-yaml-guard.mjs +1 -0
- package/defaults/mcp-config-web.json +11 -0
- package/defaults/pi/agents/explore.md +9 -0
- package/defaults/pi/agents/general-purpose.md +6 -0
- package/defaults/pi/agents/plan.md +9 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +2 -2
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +33 -0
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +2 -2
- package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +16 -16
- package/defaults/plugins/cortex-common/skills/execute-method/SKILL.md +53 -0
- package/defaults/plugins/cortex-common/skills/execute-review-rubric/SKILL.md +102 -0
- package/defaults/plugins/cortex-common/skills/manager-method/SKILL.md +67 -0
- package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +3 -3
- package/defaults/plugins/cortex-feishu/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-feishu/skills/feishu-doc/SKILL.md +163 -0
- package/defaults/plugins/cortex-feishu/skills/feishu-doc/scripts/ensure-lark-cli.sh +53 -0
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +2 -2
- package/defaults/plugins/cortex-stage-gate/skills/director-method/SKILL.md +54 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +132 -112
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +17 -10
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +2 -2
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +1 -1
- package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +2 -2
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +66 -17
- package/defaults/prompts/directives/coder-reviewer.md +6 -6
- package/defaults/prompts/directives/coder.md +4 -29
- package/defaults/prompts/directives/director.md +4 -17
- package/defaults/prompts/directives/doc-reviewer.md +2 -35
- package/defaults/prompts/directives/doc-writer.md +2 -7
- package/defaults/prompts/directives/executor-reviewer.md +2 -39
- package/defaults/prompts/directives/executor.md +2 -7
- package/defaults/prompts/directives/manager.md +12 -27
- package/defaults/prompts/systemPrompts/coder.md +1 -1
- package/defaults/prompts/systemPrompts/direct.md +1 -1
- package/defaults/prompts/systemPrompts/web.md +5 -0
- package/defaults/prompts/systemPrompts/worker.md +1 -1
- package/dist/agent-adapter/bg-wait.d.ts +44 -0
- package/dist/agent-adapter/bg-wait.js +197 -0
- package/dist/agent-adapter/capabilities.d.ts +7 -1
- package/dist/agent-adapter/capabilities.js +18 -9
- package/dist/agent-adapter/claude/adapter-tui.d.ts +14 -0
- package/dist/agent-adapter/claude/adapter-tui.js +16 -0
- package/dist/agent-adapter/claude/adapter.d.ts +89 -5
- package/dist/agent-adapter/claude/adapter.js +410 -40
- package/dist/agent-adapter/claude/bg-task-tracker.d.ts +23 -8
- package/dist/agent-adapter/claude/bg-task-tracker.js +48 -19
- package/dist/agent-adapter/claude/compact-window.d.ts +9 -0
- package/dist/agent-adapter/claude/compact-window.js +46 -0
- package/dist/agent-adapter/claude/context-usage.d.ts +28 -0
- package/dist/agent-adapter/claude/context-usage.js +177 -0
- package/dist/agent-adapter/claude/defaults.d.ts +17 -3
- package/dist/agent-adapter/claude/defaults.js +25 -9
- package/dist/agent-adapter/claude/event-parser.d.ts +30 -0
- package/dist/agent-adapter/claude/event-parser.js +68 -4
- package/dist/agent-adapter/claude/hooks-builder.d.ts +23 -23
- package/dist/agent-adapter/claude/hooks-builder.js +63 -7
- package/dist/agent-adapter/claude/spawn-args.d.ts +25 -6
- package/dist/agent-adapter/claude/spawn-args.js +62 -22
- package/dist/agent-adapter/index.js +2 -4
- package/dist/agent-adapter/normalize/event-types.d.ts +8 -1
- package/dist/agent-adapter/normalize/event-types.js +1 -1
- package/dist/agent-adapter/normalize/tool-names.js +0 -9
- package/dist/agent-adapter/pi/adapter.d.ts +3 -33
- package/dist/agent-adapter/pi/adapter.js +461 -229
- package/dist/agent-adapter/pi/agent-dir.d.ts +6 -0
- package/dist/agent-adapter/pi/agent-dir.js +24 -14
- package/dist/agent-adapter/pi/defaults.d.ts +4 -0
- package/dist/agent-adapter/pi/defaults.js +11 -0
- package/dist/agent-adapter/pi/discovery.d.ts +4 -0
- package/dist/agent-adapter/pi/discovery.js +63 -0
- package/dist/agent-adapter/pi/event-parser.d.ts +13 -2
- package/dist/agent-adapter/pi/event-parser.js +139 -69
- package/dist/agent-adapter/pi/hook-bridge.d.ts +13 -28
- package/dist/agent-adapter/pi/hook-bridge.js +272 -167
- package/dist/agent-adapter/pi/mcp-bridge-logic.d.ts +24 -0
- package/dist/agent-adapter/pi/mcp-bridge-logic.js +39 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +13 -35
- package/dist/agent-adapter/pi/mcp-bridge.js +147 -137
- package/dist/agent-adapter/pi/pi-ext-types.d.ts +30 -0
- package/dist/agent-adapter/pi/pi-ext-types.js +2 -2
- package/dist/agent-adapter/pi/session-support.d.ts +96 -0
- package/dist/agent-adapter/pi/session-support.js +213 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +15 -0
- package/dist/agent-adapter/pi/spawn-args.js +46 -3
- package/dist/agent-adapter/pi/subagent.d.ts +68 -0
- package/dist/agent-adapter/pi/subagent.js +521 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +1 -13
- package/dist/agent-adapter/pi/tool-shims.js +182 -198
- package/dist/agent-adapter/pi/web-fetch.d.ts +13 -0
- package/dist/agent-adapter/pi/web-fetch.js +201 -0
- package/dist/agent-adapter/pi/web-search.d.ts +9 -0
- package/dist/agent-adapter/pi/web-search.js +513 -0
- package/dist/agent-adapter/types.d.ts +61 -10
- package/dist/agent-adapter/types.js +4 -4
- package/dist/core/atomic-write.d.ts +3 -5
- package/dist/core/atomic-write.js +26 -12
- package/dist/core/bg-held-sessions.d.ts +35 -0
- package/dist/core/bg-held-sessions.js +79 -0
- package/dist/core/calver.d.ts +1 -0
- package/dist/core/calver.js +29 -0
- package/dist/core/config-generator.d.ts +13 -2
- package/dist/core/config-generator.js +55 -5
- package/dist/core/debug-mode.d.ts +14 -0
- package/dist/core/debug-mode.js +32 -0
- package/dist/core/gateway-generator.js +15 -11
- package/dist/core/hook-bus.d.ts +23 -0
- package/dist/core/hook-bus.js +111 -0
- package/dist/core/hook-exec.d.ts +15 -0
- package/dist/core/hook-exec.js +90 -0
- package/dist/core/icons.d.ts +2 -0
- package/dist/core/icons.js +2 -0
- package/dist/core/locales/en.d.ts +30 -7
- package/dist/core/locales/en.js +4 -1
- package/dist/core/locales/slices/commands.d.ts +12 -2
- package/dist/core/locales/slices/commands.js +31 -7
- package/dist/core/locales/slices/init.d.ts +1 -1
- package/dist/core/locales/slices/init.js +2 -2
- package/dist/core/locales/slices/interactions.d.ts +6 -0
- package/dist/core/locales/slices/interactions.js +14 -0
- package/dist/core/locales/slices/status.d.ts +7 -3
- package/dist/core/locales/slices/status.js +16 -8
- package/dist/core/log.js +4 -3
- package/dist/core/paths.d.ts +9 -0
- package/dist/core/paths.js +20 -1
- package/dist/core/profile-generator.d.ts +2 -2
- package/dist/core/profile-generator.js +6 -9
- package/dist/core/running-executions.d.ts +10 -1
- package/dist/core/running-executions.js +10 -0
- package/dist/core/status-format.d.ts +14 -0
- package/dist/core/status-format.js +23 -1
- package/dist/core/task-node.d.ts +7 -0
- package/dist/core/task-node.js +29 -0
- package/dist/core/types/agent-types.d.ts +23 -2
- package/dist/core/types/agent-types.js +2 -2
- package/dist/core/types/thread-types.d.ts +90 -15
- package/dist/core/types/thread-types.js +3 -3
- package/dist/core/utils.d.ts +2 -2
- package/dist/core/utils.js +3 -3
- package/dist/domain/agents/config.d.ts +6 -5
- package/dist/domain/agents/config.js +17 -5
- package/dist/domain/agents/facade.d.ts +74 -10
- package/dist/domain/agents/facade.js +333 -62
- package/dist/domain/agents/index.d.ts +1 -0
- package/dist/domain/agents/index.js +1 -0
- package/dist/domain/agents/profile-manager.d.ts +14 -7
- package/dist/domain/agents/profile-manager.js +23 -7
- package/dist/domain/agents/profile-switch.d.ts +53 -0
- package/dist/domain/agents/profile-switch.js +79 -0
- package/dist/domain/costs/cost-tracker.d.ts +21 -1
- package/dist/domain/costs/cost-tracker.js +54 -26
- package/dist/domain/costs/gateway-manager.js +5 -3
- package/dist/domain/costs/rate-limit-throttle.d.ts +44 -19
- package/dist/domain/costs/rate-limit-throttle.js +331 -103
- package/dist/domain/costs/resume-registry.d.ts +17 -9
- package/dist/domain/costs/resume-registry.js +63 -8
- package/dist/domain/executions/log-tailer.d.ts +71 -0
- package/dist/domain/executions/log-tailer.js +195 -0
- package/dist/domain/executions/registry.d.ts +10 -1
- package/dist/domain/executions/registry.js +14 -0
- package/dist/domain/hooks/hook-view.d.ts +22 -0
- package/dist/domain/hooks/hook-view.js +38 -0
- package/dist/domain/mcp/core-server.d.ts +0 -1
- package/dist/domain/mcp/core-server.js +8 -40
- package/dist/domain/mcp/feishu/file.js +1 -11
- package/dist/domain/mcp/feishu/index.d.ts +0 -2
- package/dist/domain/mcp/feishu/index.js +5 -56
- package/dist/domain/mcp/feishu-server.d.ts +0 -1
- package/dist/domain/mcp/feishu-server.js +5 -6
- package/dist/domain/mcp/manager-qa-server.d.ts +1 -0
- package/dist/domain/mcp/manager-qa-server.js +23 -0
- package/dist/domain/mcp/server.d.ts +0 -1
- package/dist/domain/mcp/server.js +5 -31
- package/dist/domain/mcp/slack-server.d.ts +0 -1
- package/dist/domain/mcp/slack-server.js +3 -5
- package/dist/domain/mcp/tasks-server.d.ts +1 -0
- package/dist/domain/mcp/tasks-server.js +23 -0
- package/dist/domain/mcp/thread-server.d.ts +1 -0
- package/dist/domain/mcp/thread-server.js +25 -0
- package/dist/domain/mcp/tools/context.d.ts +3 -10
- package/dist/domain/mcp/tools/context.js +13 -29
- package/dist/domain/mcp/tools/manager-qa.d.ts +2 -1
- package/dist/domain/mcp/tools/manager-qa.js +49 -53
- package/dist/domain/mcp/tools/schedule.d.ts +1 -2
- package/dist/domain/mcp/tools/schedule.js +7 -10
- package/dist/domain/mcp/tools/slack.d.ts +0 -1
- package/dist/domain/mcp/tools/slack.js +2 -13
- package/dist/domain/mcp/tools/task-ops.js +10 -137
- package/dist/domain/mcp/tools/thread-ops.js +6 -11
- package/dist/domain/mcp/tools/tui-ask.d.ts +2 -0
- package/dist/domain/mcp/tools/tui-ask.js +8 -0
- package/dist/domain/mcp/tools/ui-file.d.ts +2 -0
- package/dist/domain/mcp/tools/ui-file.js +49 -0
- package/dist/domain/mcp/tui-server.d.ts +0 -1
- package/dist/domain/mcp/tui-server.js +39 -24
- package/dist/domain/mcp/web-server.d.ts +1 -0
- package/dist/domain/mcp/web-server.js +25 -0
- package/dist/domain/memory/cortex-md-injector.d.ts +4 -10
- package/dist/domain/memory/cortex-md-injector.js +113 -77
- package/dist/domain/memory/cortex-md-scanner.d.ts +1 -0
- package/dist/domain/memory/cortex-md-scanner.js +5 -2
- package/dist/domain/memory/skill-scanner.d.ts +3 -1
- package/dist/domain/memory/skill-scanner.js +8 -12
- package/dist/domain/memory/user-context.d.ts +6 -5
- package/dist/domain/memory/user-context.js +12 -7
- package/dist/domain/monitor/disk-monitor.js +2 -3
- package/dist/domain/projects/index.d.ts +1 -0
- package/dist/domain/projects/project-store.d.ts +18 -0
- package/dist/domain/projects/project-store.js +39 -3
- package/dist/domain/remote/client-hot-reload.d.ts +9 -2
- package/dist/domain/remote/client-hot-reload.js +81 -9
- package/dist/domain/remote/client-manager.d.ts +15 -1
- package/dist/domain/remote/client-manager.js +75 -11
- package/dist/domain/remote/cortex-client.js +6 -48
- package/dist/domain/scheduling/job-registry.d.ts +0 -2
- package/dist/domain/scheduling/job-registry.js +2 -6
- package/dist/domain/scheduling/jobs/_shared.d.ts +5 -1
- package/dist/domain/scheduling/jobs/_shared.js +2 -1
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.d.ts +1 -0
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.js +78 -0
- package/dist/domain/scheduling/jobs/scheduled-task.js +1 -3
- package/dist/domain/scheduling/jobs/task-dispatch.js +40 -31
- package/dist/domain/scheduling/scheduler.d.ts +0 -10
- package/dist/domain/scheduling/scheduler.js +9 -9
- package/dist/domain/sessions/session-hooks.d.ts +38 -15
- package/dist/domain/sessions/session-hooks.js +128 -122
- package/dist/domain/sessions/session-lifecycle.d.ts +38 -1
- package/dist/domain/sessions/session-lifecycle.js +41 -4
- package/dist/domain/sessions/session-registry.d.ts +3 -1
- package/dist/domain/system/doctor.d.ts +63 -0
- package/dist/domain/system/doctor.js +359 -0
- package/dist/domain/system/server-update-check.d.ts +2 -1
- package/dist/domain/system/server-update-check.js +7 -26
- package/dist/domain/system/system-notice.d.ts +18 -0
- package/dist/domain/system/system-notice.js +34 -0
- package/dist/domain/tasks/acceptance-ledger.d.ts +31 -0
- package/dist/domain/tasks/acceptance-ledger.js +83 -0
- package/dist/domain/tasks/claim-recovery.d.ts +10 -0
- package/dist/domain/tasks/claim-recovery.js +64 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +19 -0
- package/dist/domain/tasks/dispatcher.js +1 -3
- package/dist/domain/tasks/mutator.d.ts +7 -1
- package/dist/domain/tasks/mutator.js +55 -3
- package/dist/domain/tasks/recommendation/extractor.js +3 -3
- package/dist/domain/tasks/system/cortex-run.js +0 -0
- package/dist/domain/tasks/system/task-cli.d.ts +2 -0
- package/dist/domain/tasks/system/task-cli.js +37 -7
- package/dist/domain/tasks/system/task-completion.js +148 -42
- package/dist/domain/tasks/system/task-lifecycle-edit.js +3 -0
- package/dist/domain/tasks/system/task-state.d.ts +10 -1
- package/dist/domain/tasks/system/task-state.js +31 -1
- package/dist/domain/threads/artifact-io.d.ts +3 -15
- package/dist/domain/threads/artifact-io.js +13 -119
- package/dist/domain/threads/hook-runner.d.ts +7 -2
- package/dist/domain/threads/hook-runner.js +68 -85
- package/dist/domain/threads/index.js +6 -1
- package/dist/domain/threads/prompt-builder.d.ts +14 -4
- package/dist/domain/threads/prompt-builder.js +38 -20
- package/dist/domain/threads/runner.d.ts +19 -5
- package/dist/domain/threads/runner.js +238 -82
- package/dist/domain/threads/shell-templates.d.ts +9 -0
- package/dist/domain/threads/shell-templates.js +117 -0
- package/dist/domain/threads/state-machine.d.ts +35 -7
- package/dist/domain/threads/state-machine.js +170 -29
- package/dist/domain/threads/template-loader.d.ts +15 -7
- package/dist/domain/threads/template-loader.js +204 -87
- package/dist/domain/threads/thread-transcript.d.ts +47 -0
- package/dist/domain/threads/thread-transcript.js +64 -0
- package/dist/domain/threads/utils.d.ts +8 -1
- package/dist/domain/threads/utils.js +17 -1
- package/dist/domain/tui-session/tui-session-service.js +9 -16
- package/dist/domain/tui-session/types.d.ts +12 -0
- package/dist/domain/ui-service/app-router.d.ts +670 -0
- package/dist/domain/ui-service/app-router.js +195 -0
- package/dist/domain/ui-service/index.d.ts +1 -1
- package/dist/domain/ui-service/input-schemas.d.ts +644 -0
- package/dist/domain/ui-service/input-schemas.js +385 -0
- package/dist/domain/ui-service/mutate/approvals.d.ts +31 -0
- package/dist/domain/ui-service/mutate/approvals.js +140 -0
- package/dist/domain/ui-service/mutate/config.d.ts +16 -0
- package/dist/domain/ui-service/mutate/config.js +72 -0
- package/dist/domain/ui-service/mutate/hooks.d.ts +16 -0
- package/dist/domain/ui-service/mutate/hooks.js +138 -0
- package/dist/domain/ui-service/mutate/issues.d.ts +18 -0
- package/dist/domain/ui-service/mutate/issues.js +111 -0
- package/dist/domain/ui-service/mutate/notes.d.ts +6 -0
- package/dist/domain/ui-service/mutate/notes.js +36 -0
- package/dist/domain/ui-service/mutate/projects.d.ts +4 -0
- package/dist/domain/ui-service/mutate/projects.js +10 -0
- package/dist/domain/ui-service/mutate/schedules.d.ts +2 -1
- package/dist/domain/ui-service/mutate/schedules.js +57 -3
- package/dist/domain/ui-service/mutate/sessions.d.ts +11 -0
- package/dist/domain/ui-service/mutate/sessions.js +198 -0
- package/dist/domain/ui-service/mutate/system.d.ts +2 -0
- package/dist/domain/ui-service/mutate/system.js +97 -0
- package/dist/domain/ui-service/query/approvals.d.ts +10 -0
- package/dist/domain/ui-service/query/approvals.js +109 -0
- package/dist/domain/ui-service/query/config.d.ts +8 -0
- package/dist/domain/ui-service/query/config.js +138 -0
- package/dist/domain/ui-service/query/executions.d.ts +2 -1
- package/dist/domain/ui-service/query/executions.js +47 -3
- package/dist/domain/ui-service/query/hooks.d.ts +7 -0
- package/dist/domain/ui-service/query/hooks.js +110 -0
- package/dist/domain/ui-service/query/issues.d.ts +14 -0
- package/dist/domain/ui-service/query/issues.js +85 -0
- package/dist/domain/ui-service/query/machines.d.ts +2 -0
- package/dist/domain/ui-service/query/machines.js +39 -0
- package/dist/domain/ui-service/query/memory.d.ts +5 -0
- package/dist/domain/ui-service/query/memory.js +199 -0
- package/dist/domain/ui-service/query/notes.d.ts +3 -0
- package/dist/domain/ui-service/query/notes.js +18 -0
- package/dist/domain/ui-service/query/schedules.js +1 -0
- package/dist/domain/ui-service/query/sessions.d.ts +3 -1
- package/dist/domain/ui-service/query/sessions.js +227 -15
- package/dist/domain/ui-service/query/skills.d.ts +2 -0
- package/dist/domain/ui-service/query/skills.js +14 -0
- package/dist/domain/ui-service/query/system.d.ts +3 -0
- package/dist/domain/ui-service/query/system.js +132 -0
- package/dist/domain/ui-service/query/task-verification.d.ts +2 -0
- package/dist/domain/ui-service/query/task-verification.js +60 -0
- package/dist/domain/ui-service/query/tasks.d.ts +1 -0
- package/dist/domain/ui-service/query/tasks.js +24 -16
- package/dist/domain/ui-service/query/thread-templates.d.ts +8 -0
- package/dist/domain/ui-service/query/thread-templates.js +54 -0
- package/dist/domain/ui-service/query/threads.d.ts +2 -1
- package/dist/domain/ui-service/query/threads.js +213 -4
- package/dist/domain/ui-service/subscribe.js +27 -1
- package/dist/domain/ui-service/trpc.d.ts +13 -0
- package/dist/domain/ui-service/trpc.js +12 -0
- package/dist/domain/ui-service/types.d.ts +1266 -4
- package/dist/domain/ui-service/types.js +4 -4
- package/dist/domain/ui-service/ui-service.d.ts +2 -1
- package/dist/domain/ui-service/ui-service.js +112 -10
- package/dist/entry/app.js +307 -36
- package/dist/entry/cli.js +10 -0
- package/dist/entry/daemon-notice.d.ts +17 -0
- package/dist/entry/daemon-notice.js +26 -0
- package/dist/entry/daemon.d.ts +23 -1
- package/dist/entry/daemon.js +126 -41
- package/dist/entry/doctor-cli.d.ts +12 -0
- package/dist/entry/doctor-cli.js +76 -0
- package/dist/entry/hook-cli.d.ts +18 -0
- package/dist/entry/hook-cli.js +468 -0
- package/dist/entry/init.js +22 -18
- package/dist/entry/start-ui-http.d.ts +44 -0
- package/dist/entry/start-ui-http.js +289 -0
- package/dist/entry/startup-notify.js +5 -9
- package/dist/entry/ui-http-gate.d.ts +11 -0
- package/dist/entry/ui-http-gate.js +29 -0
- package/dist/events/event-bus.d.ts +7 -2
- package/dist/events/event-bus.js +5 -2
- package/dist/events/event-logger.js +14 -0
- package/dist/events/event-types.d.ts +110 -0
- package/dist/events/event-types.js +3 -3
- package/dist/hooks/ask-user-question-hook.mjs +1 -0
- package/dist/hooks/cortex-hook-api.mjs +84 -0
- package/dist/hooks/cortex-md-injector.mjs +99 -49
- package/dist/hooks/exit-plan-mode-hook.mjs +1 -0
- package/dist/hooks/memory-ref-tracker.mjs +1 -0
- package/dist/hooks/new-session-hook.mjs +1 -0
- package/dist/hooks/post-task-hook.mjs +1 -0
- package/dist/hooks/rules-loader.mjs +1 -0
- package/dist/hooks/sensitive-file-edit.mjs +1 -0
- package/dist/hooks/session-activity-tracker.mjs +8 -100
- package/dist/hooks/task-status-check.mjs +10 -10
- package/dist/hooks/tasks-yaml-guard.mjs +1 -0
- package/dist/orchestration/agent-file-send.d.ts +54 -0
- package/dist/orchestration/agent-file-send.js +110 -0
- package/dist/orchestration/agent-runner.d.ts +49 -0
- package/dist/orchestration/agent-runner.js +368 -55
- package/dist/orchestration/bg-continuation.d.ts +51 -9
- package/dist/orchestration/bg-continuation.js +53 -15
- package/dist/orchestration/bg-wait-guard.d.ts +28 -0
- package/dist/orchestration/bg-wait-guard.js +73 -0
- package/dist/orchestration/conduit-queue.d.ts +2 -0
- package/dist/orchestration/conduit-queue.js +14 -1
- package/dist/orchestration/conversation-runner.d.ts +37 -5
- package/dist/orchestration/conversation-runner.js +71 -13
- package/dist/orchestration/delta-coalescer.d.ts +69 -0
- package/dist/orchestration/delta-coalescer.js +128 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +11 -3
- package/dist/orchestration/interactions/ask-user-question.js +27 -3
- package/dist/orchestration/interactions/interaction-handlers.js +11 -36
- package/dist/orchestration/interactions/interaction-records.d.ts +59 -0
- package/dist/orchestration/interactions/interaction-records.js +156 -0
- package/dist/orchestration/interactions/plan-approvals.d.ts +5 -0
- package/dist/orchestration/interactions/plan-approvals.js +8 -0
- package/dist/orchestration/interactions/plan-response.d.ts +8 -0
- package/dist/orchestration/interactions/plan-response.js +37 -0
- package/dist/orchestration/lifecycle.d.ts +10 -4
- package/dist/orchestration/lifecycle.js +155 -60
- package/dist/orchestration/manager-qa.d.ts +15 -4
- package/dist/orchestration/manager-qa.js +43 -37
- package/dist/orchestration/mid-turn-inject.d.ts +105 -0
- package/dist/orchestration/mid-turn-inject.js +298 -0
- package/dist/orchestration/pending-injection-recovery.d.ts +35 -0
- package/dist/orchestration/pending-injection-recovery.js +92 -0
- package/dist/orchestration/resume-dispatcher.d.ts +26 -4
- package/dist/orchestration/resume-dispatcher.js +89 -43
- package/dist/orchestration/routing/commands/cancel.d.ts +26 -0
- package/dist/orchestration/routing/commands/cancel.js +64 -18
- package/dist/orchestration/routing/commands/compact.d.ts +10 -0
- package/dist/orchestration/routing/commands/compact.js +26 -0
- package/dist/orchestration/routing/commands/index.d.ts +2 -0
- package/dist/orchestration/routing/commands/index.js +9 -0
- package/dist/orchestration/routing/commands/mode.js +24 -11
- package/dist/orchestration/routing/commands/restart.d.ts +22 -0
- package/dist/orchestration/routing/commands/restart.js +49 -0
- package/dist/orchestration/routing/commands/session.js +4 -0
- package/dist/orchestration/routing/commands/status.js +5 -0
- package/dist/orchestration/routing/edit-handler.js +1 -1
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +2 -1
- package/dist/orchestration/routing/hook-bridge-subscribers.js +45 -4
- package/dist/orchestration/routing/hook-bridge.d.ts +10 -3
- package/dist/orchestration/routing/hook-bridge.js +26 -14
- package/dist/orchestration/routing/webhook.js +110 -19
- package/dist/orchestration/session-compact.d.ts +58 -0
- package/dist/orchestration/session-compact.js +82 -0
- package/dist/orchestration/session-events.d.ts +111 -0
- package/dist/orchestration/session-events.js +113 -0
- package/dist/orchestration/session-rewind.d.ts +72 -0
- package/dist/orchestration/session-rewind.js +104 -0
- package/dist/orchestration/session-send.d.ts +19 -0
- package/dist/orchestration/session-send.js +39 -0
- package/dist/orchestration/status-helpers.d.ts +4 -0
- package/dist/orchestration/status-helpers.js +18 -0
- package/dist/orchestration/thread-callback.d.ts +75 -3
- package/dist/orchestration/thread-callback.js +329 -74
- package/dist/orchestration/thread-executor.d.ts +1 -0
- package/dist/orchestration/thread-executor.js +23 -31
- package/dist/orchestration/web-bg-hold.d.ts +52 -0
- package/dist/orchestration/web-bg-hold.js +105 -0
- package/dist/platform/adapter.d.ts +3 -0
- package/dist/platform/adapter.js +2 -2
- package/dist/platform/adapters/composite-adapter.d.ts +6 -1
- package/dist/platform/adapters/composite-adapter.js +64 -4
- package/dist/platform/adapters/feishu.d.ts +6 -1
- package/dist/platform/adapters/feishu.js +52 -12
- package/dist/platform/adapters/slack.d.ts +2 -1
- package/dist/platform/adapters/slack.js +41 -9
- package/dist/platform/adapters/tui/index.d.ts +1 -1
- package/dist/platform/adapters/tui/ports.d.ts +8 -7
- package/dist/platform/adapters/tui/tui-gateway.d.ts +7 -0
- package/dist/platform/adapters/tui/tui-gateway.js +48 -5
- package/dist/platform/adapters/tui/tui-transcript.js +17 -29
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/platform/interactive-builder.d.ts +7 -0
- package/dist/platform/interactive-builder.js +22 -2
- package/dist/platform/testing.d.ts +5 -0
- package/dist/platform/testing.js +7 -2
- package/dist/platform/tui/protocol.d.ts +0 -2
- package/dist/platform/tui/protocol.js +4 -53
- package/dist/platform/types.d.ts +12 -0
- package/dist/platform/types.js +5 -0
- package/dist/platform/ui-http/access-jwt.d.ts +28 -0
- package/dist/platform/ui-http/access-jwt.js +67 -0
- package/dist/platform/ui-http/app-update.d.ts +58 -0
- package/dist/platform/ui-http/app-update.js +155 -0
- package/dist/platform/ui-http/ui-http-server.d.ts +56 -0
- package/dist/platform/ui-http/ui-http-server.js +231 -0
- package/dist/platform/ui-http/ui-ota.d.ts +20 -0
- package/dist/platform/ui-http/ui-ota.js +128 -0
- package/dist/platform/ui-http/zip-writer.d.ts +13 -0
- package/dist/platform/ui-http/zip-writer.js +102 -0
- package/dist/platform/utils/reaction-diagnostics.d.ts +4 -0
- package/dist/platform/utils/reaction-diagnostics.js +23 -0
- package/dist/store/conversation-history-repo.d.ts +243 -0
- package/dist/store/conversation-history-repo.js +399 -0
- package/dist/store/execution-repo.d.ts +19 -1
- package/dist/store/execution-repo.js +18 -1
- package/dist/store/hook-registry.d.ts +83 -0
- package/dist/store/hook-registry.js +318 -0
- package/dist/store/hook-sync.d.ts +12 -16
- package/dist/store/hook-sync.js +169 -70
- package/dist/store/hook-writer.d.ts +49 -0
- package/dist/store/hook-writer.js +132 -0
- package/dist/store/outbound-queue.d.ts +8 -0
- package/dist/store/outbound-queue.js +24 -3
- package/dist/store/pending-injection-repo.d.ts +30 -0
- package/dist/store/pending-injection-repo.js +51 -0
- package/dist/store/plugin-sync.d.ts +21 -0
- package/dist/store/plugin-sync.js +119 -0
- package/dist/store/profile-repo.d.ts +2 -1
- package/dist/store/profile-repo.js +6 -11
- package/dist/store/project-notes-repo.d.ts +27 -0
- package/dist/store/project-notes-repo.js +214 -0
- package/dist/store/provider-state-repo.d.ts +18 -0
- package/dist/store/provider-state-repo.js +107 -0
- package/dist/store/schedule-repo.d.ts +0 -21
- package/dist/store/schedule-repo.js +4 -25
- package/dist/store/session-registry-repo.d.ts +47 -1
- package/dist/store/session-registry-repo.js +71 -3
- package/dist/store/version-migrations.d.ts +11 -0
- package/dist/store/version-migrations.js +286 -9
- package/dist/tui/App.js +219 -27
- package/dist/tui/components/Dashboard.d.ts +3 -1
- package/dist/tui/components/Dashboard.js +31 -12
- package/dist/tui/components/DashboardCostTab.js +17 -2
- package/dist/tui/components/DashboardExecutionsTab.js +21 -1
- package/dist/tui/components/DashboardSchedulesTab.js +8 -3
- package/dist/tui/components/DashboardTasksTab.js +11 -6
- package/dist/tui/components/DashboardThreadsTab.js +20 -2
- package/dist/tui/components/InputBox.d.ts +17 -1
- package/dist/tui/components/InputBox.js +263 -8
- package/dist/tui/components/Notifications.js +7 -2
- package/dist/tui/components/ProjectSwitcher.js +7 -2
- package/dist/tui/components/SessionPicker.js +10 -1
- package/dist/tui/components/SidePanel.d.ts +3 -1
- package/dist/tui/components/SidePanel.js +4 -2
- package/dist/tui/components/SlashMenu.d.ts +8 -0
- package/dist/tui/components/SlashMenu.js +14 -0
- package/dist/tui/components/StatusLine.d.ts +12 -3
- package/dist/tui/components/StatusLine.js +29 -10
- package/dist/tui/components/Transcript.d.ts +9 -0
- package/dist/tui/components/Transcript.js +131 -26
- package/dist/tui/components/dashboard-constants.d.ts +1 -0
- package/dist/tui/components/dashboard-constants.js +7 -0
- package/dist/tui/hooks/useKeybindings.d.ts +1 -0
- package/dist/tui/hooks/useKeybindings.js +9 -14
- package/dist/tui/hooks/useMouseHandler.d.ts +17 -0
- package/dist/tui/hooks/useMouseHandler.js +103 -0
- package/dist/tui/hooks/useTranscript.d.ts +7 -2
- package/dist/tui/hooks/useTranscript.js +76 -57
- package/dist/tui/index.js +106 -10
- package/dist/tui/logic.d.ts +146 -2
- package/dist/tui/logic.js +411 -6
- package/dist/tui/raf-batch.d.ts +33 -0
- package/dist/tui/raf-batch.js +103 -0
- package/dist/tui/render/inline-markdown.d.ts +22 -0
- package/dist/tui/render/inline-markdown.js +99 -0
- package/dist/tui/render/rich-blocks.js +10 -8
- package/dist/tui/render-output.d.ts +46 -0
- package/dist/tui/render-output.js +86 -0
- package/dist/tui/slash-commands.d.ts +21 -0
- package/dist/tui/slash-commands.js +73 -0
- package/dist/tui/turn-status.d.ts +10 -0
- package/dist/tui/turn-status.js +53 -0
- package/package.json +17 -7
- package/web/dist/apple-touch-icon.png +0 -0
- package/web/dist/assets/index-B19jLgji.js +138 -0
- package/web/dist/assets/index-BuFyPyRW.css +1 -0
- package/web/dist/assets/index-DCgngTJG.js +1 -0
- package/web/dist/assets/pdf-worker-DIEXcFxP.js +55 -0
- package/web/dist/assets/pdf.worker.min-DqNZU1-t.js +53 -0
- package/web/dist/favicon-32.png +0 -0
- package/web/dist/favicon.svg +7 -0
- package/web/dist/index.html +37 -0
- package/defaults/config/session-hooks.json +0 -7
- package/defaults/config/thread-templates.json +0 -594
- package/defaults/prompts/directives/milestone-executor.md +0 -119
- package/defaults/prompts/directives/milestone-reviewer.md +0 -108
- package/defaults/prompts/directives/plan-executor.md +0 -121
- package/defaults/prompts/directives/plan-reviewer.md +0 -99
- package/dist/agent-adapter/codex/adapter.d.ts +0 -42
- package/dist/agent-adapter/codex/adapter.js +0 -916
- package/dist/agent-adapter/codex/event-parser.d.ts +0 -17
- package/dist/agent-adapter/codex/event-parser.js +0 -41
- package/dist/agent-adapter/codex/spawn-args.d.ts +0 -6
- package/dist/agent-adapter/codex/spawn-args.js +0 -30
- package/dist/domain/costs/codex-event-format.d.ts +0 -4
- package/dist/domain/costs/codex-event-format.js +0 -66
- package/dist/domain/costs/codex-usage-monitor.d.ts +0 -6
- package/dist/domain/costs/codex-usage-monitor.js +0 -73
- package/dist/domain/costs/rate-limit-parser.d.ts +0 -11
- package/dist/domain/costs/rate-limit-parser.js +0 -87
- package/dist/domain/mcp/feishu/bitable.d.ts +0 -3
- package/dist/domain/mcp/feishu/bitable.js +0 -168
- package/dist/domain/mcp/feishu/block-types.d.ts +0 -44
- package/dist/domain/mcp/feishu/block-types.js +0 -127
- package/dist/domain/mcp/feishu/blocks-to-text.d.ts +0 -19
- package/dist/domain/mcp/feishu/blocks-to-text.js +0 -43
- package/dist/domain/mcp/feishu/docx.d.ts +0 -3
- package/dist/domain/mcp/feishu/docx.js +0 -163
- package/dist/domain/mcp/feishu/drive.d.ts +0 -23
- package/dist/domain/mcp/feishu/drive.js +0 -66
- package/dist/domain/mcp/feishu/markdown-to-blocks.d.ts +0 -40
- package/dist/domain/mcp/feishu/markdown-to-blocks.js +0 -191
- package/dist/domain/mcp/feishu/sheets.d.ts +0 -3
- package/dist/domain/mcp/feishu/sheets.js +0 -119
- package/dist/domain/mcp/feishu/wiki.d.ts +0 -3
- package/dist/domain/mcp/feishu/wiki.js +0 -77
- package/dist/tui/components/Header.d.ts +0 -11
- package/dist/tui/components/Header.js +0 -5
- package/dist/tui/components/MessageRow.d.ts +0 -7
- package/dist/tui/components/MessageRow.js +0 -10
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
// input:
|
|
2
|
-
// output:
|
|
3
|
-
// pos:
|
|
4
|
-
//
|
|
5
|
-
// runs pending migrations in version order. Supports JSON (parse/serialize) and text
|
|
6
|
-
// (raw string, e.g. markdown system prompts) migrations. Idempotent and crash-safe
|
|
7
|
-
// via atomicWrite.
|
|
8
|
-
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
1
|
+
// input: versions, user config, provider state, defaults
|
|
2
|
+
// output: Versioned and collision-safe startup migrations
|
|
3
|
+
// pos: Migrates user-owned files during server startup
|
|
4
|
+
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
9
5
|
import * as path from 'node:path';
|
|
10
6
|
import * as fs from 'node:fs/promises';
|
|
11
7
|
import * as os from 'node:os';
|
|
@@ -13,6 +9,8 @@ import { CORTEX_VERSION, CORTEX_DOCS_URL } from '../core/version.js';
|
|
|
13
9
|
import { DATA_DIR, DEFAULTS_DIR } from '../core/paths.js';
|
|
14
10
|
import { atomicWrite } from '../core/atomic-write.js';
|
|
15
11
|
import { createLogger } from '../core/log.js';
|
|
12
|
+
import { validateHookEntry } from './hook-registry.js';
|
|
13
|
+
import { migrateProviderStateFromSchedules } from './provider-state-repo.js';
|
|
16
14
|
const log = createLogger('version-migrations');
|
|
17
15
|
// ── CalVer comparison ──────────────────────────────────────────
|
|
18
16
|
// CalVer format: YYYY.M.D (no zero-padding, e.g. 2026.5.23).
|
|
@@ -60,6 +58,82 @@ export function upsertMarkerBlock(content, block) {
|
|
|
60
58
|
const trimmed = content.replace(/\s+$/, '');
|
|
61
59
|
return `${trimmed}\n\n${block}\n`;
|
|
62
60
|
}
|
|
61
|
+
/** Apply an ordered list of literal `[from, to]` replacements, each only when `from`
|
|
62
|
+
* is present in the content. Used by text migrations that neutralize opinionated or
|
|
63
|
+
* project-specific phrasing in shipped default prompts (e.g. a hard TDD mandate, a
|
|
64
|
+
* hardcoded `npm test`, a named lint tool) on existing installs whose prompt copies
|
|
65
|
+
* predate the edit. Idempotent provided no `to` re-introduces another rule's `from`:
|
|
66
|
+
* once replaced the `from` is gone, so re-runs are no-ops. A prompt the user has
|
|
67
|
+
* customized away from the shipped wording simply won't match and is left untouched,
|
|
68
|
+
* preserving their edits. */
|
|
69
|
+
export function applyReplacements(content, pairs) {
|
|
70
|
+
let out = content;
|
|
71
|
+
for (const [from, to] of pairs) {
|
|
72
|
+
if (out.includes(from))
|
|
73
|
+
out = out.split(from).join(to);
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
// ── Directive-prompt neutralization tables (text migrations) ───
|
|
78
|
+
// The shipped coder / coder-reviewer directives baked in three non-portable
|
|
79
|
+
// assumptions that leaked Cortex's own toolchain into every install: a hard
|
|
80
|
+
// "TDD is non-negotiable" mandate, `npm test` as THE test command, and the
|
|
81
|
+
// dependency-cruiser linter named by brand. These tables rewrite that wording
|
|
82
|
+
// to be project-agnostic (test only if the project has a suite; use the project's
|
|
83
|
+
// own command; speak of lint/architecture checks generically). git-commit
|
|
84
|
+
// discipline is intentionally left in place — it is core to the Coder role's
|
|
85
|
+
// deliverable contract, not a personal preference.
|
|
86
|
+
const CODER_DIRECTIVE_REPLACEMENTS = [
|
|
87
|
+
[
|
|
88
|
+
'TDD, reading before editing, and not improvising on ambiguous specs are cheaper than a re-run.',
|
|
89
|
+
'Testing, reading before editing, and not improvising on ambiguous specs are cheaper than a re-run.',
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
'### TDD via `/develop`\n- Before implementing non-trivial logic, write a failing test.\n- Run the test, confirm it fails, implement, confirm it passes.\n- Trivial glue code and obvious one-liners are exempt; use judgment but bias toward tests.\n- Code that governs correctness (computation, data handling, seed handling) **requires** a test regardless.',
|
|
93
|
+
'### Testing\n- Follow the project\'s existing testing practice. If the project has a test setup, add or update tests covering the logic you change. If the project practices test-driven development, write the failing test first, confirm it fails, implement, then confirm it passes.\n- Code that governs correctness (computation, data handling, seed handling) should be tested whenever the project provides a way to test it. Trivial glue code and obvious one-liners are exempt.\n- If the project has no test harness, verify by the means it already uses; do not scaffold a test framework unless the spec asks for it.',
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
'### Full-suite pass (non-negotiable)\n- After implementing and committing, run the project\'s full test suite (`npm test` or equivalent).\n- The full suite includes unit tests, architecture linters (e.g. dependency-cruiser), integration tests, and regression suites. Every stage must pass.\n- Do NOT commit or hand off until the full suite is green. A single red test or architecture violation means you are not done.\n- If the test suite had pre-existing failures before your invocation, note them explicitly in the implementation summary; you must still verify that no NEW failures were introduced by your changes.',
|
|
97
|
+
'### Full-suite pass\n- If the project has a test suite, run it after implementing and committing, using whatever command the project defines (e.g. `npm test`, `pytest`, `make test`).\n- Run every stage the project configures — unit tests, linters or architecture checks, integration tests, regression suites. Every configured stage must pass.\n- Do NOT commit or hand off until the suite is green. A single red test or lint violation means you are not done.\n- If the suite had pre-existing failures before your invocation, note them explicitly in the implementation summary; you must still verify that no NEW failures were introduced by your changes.',
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
'3. Implement per spec. Use `/develop` for TDD on non-trivial logic.',
|
|
101
|
+
'3. Implement per spec. If the project practices TDD, use `/develop` to drive it on non-trivial logic.',
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
'4. Run the **full test suite** (`npm test` or equivalent) locally; confirm every stage passes (architecture linter, unit tests, integration tests, regression suite). If it fails, fix before committing.',
|
|
105
|
+
'4. If the project has a test suite, run it locally with the project\'s own command; confirm every configured stage passes (linters or architecture checks, unit tests, integration tests, regression suite). If it fails, fix before committing.',
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
'6. Run the full test suite one more time after committing to confirm the SHA is green.',
|
|
109
|
+
'6. If the project has a test suite, run it once more after committing to confirm the SHA is green.',
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
'- **Partial test pass**: running only unit tests for the changed module while skipping integration tests, regression suites, or architecture linters. The full suite (`npm test`) must pass.',
|
|
113
|
+
'- **Partial test pass**: running only unit tests for the changed module while skipping integration tests, regression suites, or lint/architecture checks the project configures. The project\'s full suite must pass when one exists.',
|
|
114
|
+
],
|
|
115
|
+
];
|
|
116
|
+
const CODER_REVIEWER_DIRECTIVE_REPLACEMENTS = [
|
|
117
|
+
[
|
|
118
|
+
'### TDD discipline\nCoder must land tests alongside (or before) the implementation, with coverage over the spec\'s happy path **and** edge cases (boundaries, empty/null inputs, error paths, concurrency hazards relevant to the diff); missing tests, tests that don\'t exercise the new control-flow paths, or untested edge cases called out by the spec are **Blockers**.',
|
|
119
|
+
'### Test discipline\nWhen the project has a test setup, Coder must land tests alongside (or before) the implementation, with coverage over the spec\'s happy path **and** edge cases (boundaries, empty/null inputs, error paths, concurrency hazards relevant to the diff); missing tests, tests that don\'t exercise the new control-flow paths, or untested edge cases called out by the spec are **Blockers**. If the project has no test harness, verify correctness by the means the project already uses and do not treat the absence of tests as a Blocker.',
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
'### Full-suite pass (non-negotiable)\nRun the project\'s full test suite (`npm test` or equivalent). This includes not just unit tests but also architecture linters, integration tests, and regression suites. **Any test failure or architecture violation (e.g. dependency-cruiser error) is a Blocker.** Do not rely on Coder\'s claim that tests passed — run them yourself. If the suite had pre-existing failures before this invocation, verify that no NEW failures were introduced; new failures are Blockers regardless of pre-existing state.',
|
|
123
|
+
'### Full-suite pass\nIf the project has a test suite, run it using the project\'s own command (e.g. `npm test`, `pytest`, `make test`). This includes not just unit tests but also any linters or architecture checks, integration tests, and regression suites the project configures. **Any test failure or lint/architecture violation is a Blocker.** Do not rely on Coder\'s claim that tests passed — run them yourself. If the suite had pre-existing failures before this invocation, verify that no NEW failures were introduced; new failures are Blockers regardless of pre-existing state.',
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
'4. **Run the full test suite** (`npm test` or equivalent). Confirm that every stage passes: architecture linter, unit tests, integration tests, regression suite. If any test or lint stage fails, it is a Blocker — do not proceed to code review until Coder fixes it (or mark it as a pre-existing failure with evidence).',
|
|
127
|
+
'4. **If the project has a test suite, run it** with the project\'s own command. Confirm that every configured stage passes: linters or architecture checks, unit tests, integration tests, regression suite. If any test or lint stage fails, it is a Blocker — do not proceed to code review until Coder fixes it (or mark it as a pre-existing failure with evidence).',
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
'- **Test run omission**: signing off on an implementation without running the full test suite yourself. Coder\'s claim that tests pass is not evidence. Run `npm test` and check every stage. A dependency-cruiser error or a test regression that Coder missed is as much your failure as theirs.',
|
|
131
|
+
'- **Test run omission**: signing off on an implementation without running the project\'s test suite yourself when one exists. Coder\'s claim that tests pass is not evidence. Run the suite and check every stage. A lint/architecture error or a test regression that Coder missed is as much your failure as theirs.',
|
|
132
|
+
],
|
|
133
|
+
];
|
|
134
|
+
const PI_SUBAGENT_ROLE_REPLACEMENTS = [
|
|
135
|
+
['subagent_type=Explore', 'subagent_type=explore'],
|
|
136
|
+
];
|
|
63
137
|
// ── Registry ───────────────────────────────────────────────────
|
|
64
138
|
// Add new migrations here. The runner groups them by filePath and applies
|
|
65
139
|
// pending ones in version-ascending order.
|
|
@@ -220,6 +294,48 @@ const migrations = [
|
|
|
220
294
|
return upsertMarkerBlock(data, DOCS_BLOCK);
|
|
221
295
|
},
|
|
222
296
|
})),
|
|
297
|
+
// M5: De-personalize the coder / coder-reviewer directives. The shipped wording
|
|
298
|
+
// hardcoded Cortex's own toolchain (a non-negotiable TDD mandate, `npm test` as THE
|
|
299
|
+
// test command, the dependency-cruiser linter by name) — fine for this repo, wrong as
|
|
300
|
+
// a default for every install. These two text migrations rewrite the user-owned prompt
|
|
301
|
+
// copies under DATA_DIR/prompts/directives to project-agnostic phrasing. Idempotent via
|
|
302
|
+
// applyReplacements (already-rewritten or user-customized copies don't match → no-op),
|
|
303
|
+
// and missing files skip gracefully via ENOENT in the runner.
|
|
304
|
+
{
|
|
305
|
+
filePath: 'prompts/directives/coder.md',
|
|
306
|
+
version: '2026.6.22-2',
|
|
307
|
+
format: 'text',
|
|
308
|
+
migrate(data) {
|
|
309
|
+
if (typeof data !== 'string')
|
|
310
|
+
return data;
|
|
311
|
+
return applyReplacements(data, CODER_DIRECTIVE_REPLACEMENTS);
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
filePath: 'prompts/directives/coder-reviewer.md',
|
|
316
|
+
version: '2026.6.22-2',
|
|
317
|
+
format: 'text',
|
|
318
|
+
migrate(data) {
|
|
319
|
+
if (typeof data !== 'string')
|
|
320
|
+
return data;
|
|
321
|
+
return applyReplacements(data, CODER_REVIEWER_DIRECTIVE_REPLACEMENTS);
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
// M6: Match existing prompt copies to PI's lowercase default role name.
|
|
325
|
+
...[
|
|
326
|
+
'prompts/systemPrompts/direct.md',
|
|
327
|
+
'prompts/systemPrompts/worker.md',
|
|
328
|
+
'prompts/systemPrompts/coder.md',
|
|
329
|
+
].map((filePath) => ({
|
|
330
|
+
filePath,
|
|
331
|
+
version: '2026.6.24',
|
|
332
|
+
format: 'text',
|
|
333
|
+
migrate(data) {
|
|
334
|
+
if (typeof data !== 'string')
|
|
335
|
+
return data;
|
|
336
|
+
return applyReplacements(data, PI_SUBAGENT_ROLE_REPLACEMENTS);
|
|
337
|
+
},
|
|
338
|
+
})),
|
|
223
339
|
];
|
|
224
340
|
// ── Versions file I/O ──────────────────────────────────────────
|
|
225
341
|
async function loadVersionsFrom(filePath) {
|
|
@@ -283,6 +399,10 @@ export async function runMigrations(opts = {}) {
|
|
|
283
399
|
const dataDir = opts.dataDir ?? DATA_DIR;
|
|
284
400
|
const defaultsDir = opts.defaultsDir ?? DEFAULTS_DIR;
|
|
285
401
|
const storeDir = opts.storeDir ?? path.join(dataDir, 'data');
|
|
402
|
+
await migrateProviderStateFromSchedules(dataDir).catch((error) => {
|
|
403
|
+
log.warn(`Could not migrate legacy provider state: ${error.message}`);
|
|
404
|
+
});
|
|
405
|
+
await migrateSessionHooksToRegistry(dataDir);
|
|
286
406
|
const versionsFile = path.join(storeDir, 'versions.json');
|
|
287
407
|
const versions = await loadVersionsFrom(versionsFile);
|
|
288
408
|
// Group migrations by filePath
|
|
@@ -357,7 +477,164 @@ export async function runMigrations(opts = {}) {
|
|
|
357
477
|
}
|
|
358
478
|
await saveVersionsTo(versionsFile, versions);
|
|
359
479
|
}
|
|
360
|
-
|
|
480
|
+
const SESSION_HOOK_DESTINATIONS = {
|
|
481
|
+
onNew: {
|
|
482
|
+
file: '12-session-new-hook.json',
|
|
483
|
+
id: 'session-new-hook',
|
|
484
|
+
event: 'cortex:session.new',
|
|
485
|
+
},
|
|
486
|
+
onMessageEnd: {
|
|
487
|
+
file: '13-session-message-end-hook.json',
|
|
488
|
+
id: 'session-message-end-hook',
|
|
489
|
+
event: 'cortex:session.messageEnd',
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
function parseLegacyArgs(value) {
|
|
493
|
+
if (value === undefined)
|
|
494
|
+
return [];
|
|
495
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === 'string')) {
|
|
496
|
+
throw new Error('legacy session hook args must be strings');
|
|
497
|
+
}
|
|
498
|
+
return value;
|
|
499
|
+
}
|
|
500
|
+
function parseLegacyTimeout(value) {
|
|
501
|
+
if (value === undefined)
|
|
502
|
+
return 60_000;
|
|
503
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) {
|
|
504
|
+
throw new Error('legacy session hook timeout must be positive');
|
|
505
|
+
}
|
|
506
|
+
return value;
|
|
507
|
+
}
|
|
508
|
+
function parseLegacyHook(value) {
|
|
509
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
510
|
+
throw new Error('legacy session hook must be an object');
|
|
511
|
+
}
|
|
512
|
+
const raw = value;
|
|
513
|
+
const command = typeof raw.command === 'string' && raw.command.trim() ? raw.command : undefined;
|
|
514
|
+
const script = typeof raw.script === 'string' && raw.script.trim() ? raw.script : undefined;
|
|
515
|
+
if ((command === undefined) === (script === undefined)) {
|
|
516
|
+
throw new Error('legacy session hook needs exactly one command or script');
|
|
517
|
+
}
|
|
518
|
+
return {
|
|
519
|
+
command,
|
|
520
|
+
script,
|
|
521
|
+
args: parseLegacyArgs(raw.args),
|
|
522
|
+
timeout: parseLegacyTimeout(raw.timeout),
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function shellQuote(value) {
|
|
526
|
+
return `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
527
|
+
}
|
|
528
|
+
function normalizedScript(script) {
|
|
529
|
+
return script.trim().replace(/^(?:\.\/)?hooks[\\/]/, '');
|
|
530
|
+
}
|
|
531
|
+
function scriptFromCommand(command, args) {
|
|
532
|
+
if (args.length > 0)
|
|
533
|
+
return null;
|
|
534
|
+
const match = command.trim().match(/^node\s+(?:\.\/)?hooks[\\/]([^\s'"]+)$/);
|
|
535
|
+
return match?.[1] ?? null;
|
|
536
|
+
}
|
|
537
|
+
function commandWithArgs(command, args) {
|
|
538
|
+
if (args.length === 0)
|
|
539
|
+
return command;
|
|
540
|
+
return `${command} ${args.map(shellQuote).join(' ')}`;
|
|
541
|
+
}
|
|
542
|
+
function normalizeLegacyRun(config) {
|
|
543
|
+
const timeout = config.timeout / 1_000;
|
|
544
|
+
if (config.script) {
|
|
545
|
+
const script = normalizedScript(config.script);
|
|
546
|
+
if (config.args.length === 0)
|
|
547
|
+
return { script, timeout };
|
|
548
|
+
const command = commandWithArgs(`node ${shellQuote(`hooks/${script}`)}`, config.args);
|
|
549
|
+
return { command, timeout };
|
|
550
|
+
}
|
|
551
|
+
const command = config.command;
|
|
552
|
+
const script = scriptFromCommand(command, config.args);
|
|
553
|
+
return script ? { script, timeout } : { command: commandWithArgs(command, config.args), timeout };
|
|
554
|
+
}
|
|
555
|
+
function migratedSessionHook(name, value) {
|
|
556
|
+
const target = SESSION_HOOK_DESTINATIONS[name];
|
|
557
|
+
return validateHookEntry({
|
|
558
|
+
id: target.id,
|
|
559
|
+
event: target.event,
|
|
560
|
+
run: normalizeLegacyRun(parseLegacyHook(value)),
|
|
561
|
+
result: 'stdout-as-prompt',
|
|
562
|
+
enabled: true,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
function disabledOnNewHook() {
|
|
566
|
+
return validateHookEntry({
|
|
567
|
+
id: 'session-new-hook',
|
|
568
|
+
event: 'cortex:session.new',
|
|
569
|
+
run: { script: 'new-session-hook.mjs', timeout: 60 },
|
|
570
|
+
result: 'stdout-as-prompt',
|
|
571
|
+
enabled: false,
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function sessionHookMigrationEntries(config) {
|
|
575
|
+
const entries = [];
|
|
576
|
+
const onNew = Object.hasOwn(config, 'onNew')
|
|
577
|
+
? migratedSessionHook('onNew', config.onNew)
|
|
578
|
+
: disabledOnNewHook();
|
|
579
|
+
entries.push([SESSION_HOOK_DESTINATIONS.onNew.file, onNew]);
|
|
580
|
+
if (Object.hasOwn(config, 'onMessageEnd')) {
|
|
581
|
+
entries.push([
|
|
582
|
+
SESSION_HOOK_DESTINATIONS.onMessageEnd.file,
|
|
583
|
+
migratedSessionHook('onMessageEnd', config.onMessageEnd),
|
|
584
|
+
]);
|
|
585
|
+
}
|
|
586
|
+
return entries;
|
|
587
|
+
}
|
|
588
|
+
async function hasCompatibleSessionHookEntry(filePath, expectedEvent) {
|
|
589
|
+
try {
|
|
590
|
+
const raw = await fs.readFile(filePath, 'utf8');
|
|
591
|
+
const existing = validateHookEntry(JSON.parse(raw));
|
|
592
|
+
if (existing.event !== expectedEvent) {
|
|
593
|
+
throw new Error(`registry destination belongs to ${existing.event}`);
|
|
594
|
+
}
|
|
595
|
+
return true;
|
|
596
|
+
}
|
|
597
|
+
catch (error) {
|
|
598
|
+
if (error.code === 'ENOENT')
|
|
599
|
+
return false;
|
|
600
|
+
throw error;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
async function writeSessionHookEntry(filePath, entry) {
|
|
604
|
+
if (await hasCompatibleSessionHookEntry(filePath, entry.event))
|
|
605
|
+
return;
|
|
606
|
+
await atomicWrite(filePath, `${JSON.stringify(entry, null, 2)}\n`);
|
|
607
|
+
}
|
|
608
|
+
/** Move the retired singular session hook config into declarative registry files. */
|
|
609
|
+
export async function migrateSessionHooksToRegistry(dataDir) {
|
|
610
|
+
const source = path.join(dataDir, 'config', 'session-hooks.json');
|
|
611
|
+
let raw;
|
|
612
|
+
try {
|
|
613
|
+
raw = await fs.readFile(source, 'utf8');
|
|
614
|
+
}
|
|
615
|
+
catch (error) {
|
|
616
|
+
if (error.code === 'ENOENT')
|
|
617
|
+
return;
|
|
618
|
+
log.warn(`Could not read legacy session hooks: ${error.message}`);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
try {
|
|
622
|
+
const parsed = JSON.parse(raw);
|
|
623
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
624
|
+
throw new Error('legacy session hook config must be an object');
|
|
625
|
+
}
|
|
626
|
+
const registryDir = path.join(dataDir, 'config', 'hooks');
|
|
627
|
+
await fs.mkdir(registryDir, { recursive: true });
|
|
628
|
+
for (const [file, entry] of sessionHookMigrationEntries(parsed)) {
|
|
629
|
+
await writeSessionHookEntry(path.join(registryDir, file), entry);
|
|
630
|
+
}
|
|
631
|
+
await fs.unlink(source);
|
|
632
|
+
log.info('Migrated legacy session hooks into the hook registry');
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
log.warn(`Could not migrate legacy session hooks: ${error.message}`);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
361
638
|
/**
|
|
362
639
|
* Migrate config.yaml from CORTEX_HOME/config/ (wrong location before 2026.6.11)
|
|
363
640
|
* to ~/.aistatus/config.yaml (correct location read by aistatus).
|