@cortex-agent/server 2026.5.19-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/defaults/.claude/settings.json +13 -0
- package/defaults/CORTEX.md +15 -0
- package/defaults/config/budget.json +4 -0
- package/defaults/config/session-hooks.json +7 -0
- package/defaults/config/thread-templates.json +528 -0
- package/defaults/context/CORTEX.md +40 -0
- package/defaults/context/decisions/DR-0012.md +54 -0
- package/defaults/context/ideas/CORTEX.md +10 -0
- package/defaults/context/projects/CORTEX.md +25 -0
- package/defaults/context/scans/CORTEX.md +13 -0
- package/defaults/context/user/CORTEX.md +21 -0
- package/defaults/data/schedules.json +52 -0
- package/defaults/gitignore +44 -0
- package/defaults/hooks/ask-user-question-hook.mjs +66 -0
- package/defaults/hooks/cortex-md-injector.mjs +237 -0
- package/defaults/hooks/exit-plan-mode-hook.mjs +84 -0
- package/defaults/hooks/memory-ref-tracker.mjs +154 -0
- package/defaults/hooks/new-session-hook.mjs +83 -0
- package/defaults/hooks/post-task-hook.mjs +63 -0
- package/defaults/hooks/rules-loader.mjs +212 -0
- package/defaults/hooks/sensitive-file-edit.mjs +84 -0
- package/defaults/hooks/session-activity-tracker.mjs +254 -0
- package/defaults/hooks/task-status-check.mjs +218 -0
- package/defaults/hooks/tasks-yaml-guard.mjs +230 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +208 -0
- package/defaults/plugins/cortex-coder/skills/code-standards/SKILL.md +146 -0
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +164 -0
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +349 -0
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +104 -0
- package/defaults/plugins/cortex-common/skills/critique/SKILL.md +88 -0
- package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +508 -0
- package/defaults/plugins/cortex-common/skills/diagnose/SKILL.md +169 -0
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +135 -0
- package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +183 -0
- package/defaults/plugins/cortex-common/skills/synthesize/SKILL.md +120 -0
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +89 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +163 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +425 -0
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-system/skills/approval/SKILL.md +84 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +199 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/SKILL.md +201 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/extract_session.py +165 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/scan_logs.py +402 -0
- package/defaults/plugins/cortex-system/skills/evolve/SKILL.md +115 -0
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +262 -0
- package/defaults/plugins/cortex-system/skills/gravity/SKILL.md +125 -0
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +310 -0
- package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +85 -0
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +167 -0
- package/defaults/plugins/cortex-system/skills/refresh-skills/SKILL.md +153 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +209 -0
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +478 -0
- package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +95 -0
- package/defaults/prompts/directives/coder-reviewer.md +106 -0
- package/defaults/prompts/directives/coder.md +90 -0
- package/defaults/prompts/directives/director.md +97 -0
- package/defaults/prompts/directives/doc-reviewer.md +93 -0
- package/defaults/prompts/directives/doc-writer.md +85 -0
- package/defaults/prompts/directives/executor-reviewer.md +96 -0
- package/defaults/prompts/directives/executor.md +85 -0
- package/defaults/prompts/directives/milestone-executor.md +119 -0
- package/defaults/prompts/directives/milestone-reviewer.md +108 -0
- package/defaults/prompts/directives/plan-executor.md +121 -0
- package/defaults/prompts/directives/plan-reviewer.md +99 -0
- package/defaults/prompts/systemPrompts/coder.md +64 -0
- package/defaults/prompts/systemPrompts/direct.md +92 -0
- package/defaults/prompts/systemPrompts/web-opus-4-6.md +68 -0
- package/defaults/prompts/systemPrompts/web-sonnet-4-6.md +76 -0
- package/defaults/prompts/systemPrompts/web.md +50 -0
- package/defaults/prompts/systemPrompts/worker.md +67 -0
- package/defaults/rules/correction-propagation.md +31 -0
- package/defaults/rules/decision-records.md +49 -0
- package/defaults/rules/experiment-format.md +165 -0
- package/defaults/rules/issues-md.md +37 -0
- package/defaults/rules/meta-conventions.md +45 -0
- package/defaults/rules/mission-md.md +47 -0
- package/defaults/rules/overview-md.md +41 -0
- package/defaults/rules/roadmap-md.md +55 -0
- package/defaults/rules/status-md.md +49 -0
- package/defaults/rules/task-system.md +53 -0
- package/dist/agent-adapter/capabilities.d.ts +12 -0
- package/dist/agent-adapter/capabilities.js +52 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +140 -0
- package/dist/agent-adapter/claude/adapter-tui.js +422 -0
- package/dist/agent-adapter/claude/adapter.d.ts +85 -0
- package/dist/agent-adapter/claude/adapter.js +771 -0
- package/dist/agent-adapter/claude/cost-from-usage.d.ts +62 -0
- package/dist/agent-adapter/claude/cost-from-usage.js +97 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +49 -0
- package/dist/agent-adapter/claude/event-parser.d.ts +28 -0
- package/dist/agent-adapter/claude/event-parser.js +173 -0
- package/dist/agent-adapter/claude/hooks-builder.d.ts +36 -0
- package/dist/agent-adapter/claude/hooks-builder.js +57 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +68 -0
- package/dist/agent-adapter/claude/jsonl-tail.js +344 -0
- package/dist/agent-adapter/claude/spawn-args.d.ts +38 -0
- package/dist/agent-adapter/claude/spawn-args.js +83 -0
- package/dist/agent-adapter/claude/tmux-control.d.ts +69 -0
- package/dist/agent-adapter/claude/tmux-control.js +127 -0
- package/dist/agent-adapter/claude/tool-summarizers.d.ts +2 -0
- package/dist/agent-adapter/claude/tool-summarizers.js +24 -0
- package/dist/agent-adapter/codex/adapter.d.ts +42 -0
- package/dist/agent-adapter/codex/adapter.js +916 -0
- package/dist/agent-adapter/codex/event-parser.d.ts +17 -0
- package/dist/agent-adapter/codex/event-parser.js +41 -0
- package/dist/agent-adapter/codex/spawn-args.d.ts +6 -0
- package/dist/agent-adapter/codex/spawn-args.js +30 -0
- package/dist/agent-adapter/index.d.ts +8 -0
- package/dist/agent-adapter/index.js +33 -0
- package/dist/agent-adapter/normalize/event-stream.d.ts +6 -0
- package/dist/agent-adapter/normalize/event-stream.js +47 -0
- package/dist/agent-adapter/normalize/event-types.d.ts +58 -0
- package/dist/agent-adapter/normalize/event-types.js +5 -0
- package/dist/agent-adapter/normalize/hooks.d.ts +26 -0
- package/dist/agent-adapter/normalize/hooks.js +5 -0
- package/dist/agent-adapter/normalize/prompt-builder.d.ts +6 -0
- package/dist/agent-adapter/normalize/prompt-builder.js +23 -0
- package/dist/agent-adapter/normalize/tool-names.d.ts +6 -0
- package/dist/agent-adapter/normalize/tool-names.js +73 -0
- package/dist/agent-adapter/pi/adapter.d.ts +60 -0
- package/dist/agent-adapter/pi/adapter.js +626 -0
- package/dist/agent-adapter/pi/agent-dir.d.ts +11 -0
- package/dist/agent-adapter/pi/agent-dir.js +34 -0
- package/dist/agent-adapter/pi/event-parser.d.ts +26 -0
- package/dist/agent-adapter/pi/event-parser.js +313 -0
- package/dist/agent-adapter/pi/framing.d.ts +6 -0
- package/dist/agent-adapter/pi/framing.js +35 -0
- package/dist/agent-adapter/pi/hook-bridge.d.ts +59 -0
- package/dist/agent-adapter/pi/hook-bridge.js +233 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +26 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +140 -0
- package/dist/agent-adapter/pi/pi-ext-types.d.ts +90 -0
- package/dist/agent-adapter/pi/pi-ext-types.js +5 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +20 -0
- package/dist/agent-adapter/pi/spawn-args.js +54 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +2 -0
- package/dist/agent-adapter/pi/tool-shims.js +181 -0
- package/dist/agent-adapter/types.d.ts +94 -0
- package/dist/agent-adapter/types.js +5 -0
- package/dist/core/async-mutex.d.ts +6 -0
- package/dist/core/async-mutex.js +36 -0
- package/dist/core/cli-utils.d.ts +37 -0
- package/dist/core/cli-utils.js +69 -0
- package/dist/core/config-generator.d.ts +9 -0
- package/dist/core/config-generator.js +58 -0
- package/dist/core/gateway-generator.d.ts +46 -0
- package/dist/core/gateway-generator.js +336 -0
- package/dist/core/log.d.ts +7 -0
- package/dist/core/log.js +103 -0
- package/dist/core/paths.d.ts +32 -0
- package/dist/core/paths.js +49 -0
- package/dist/core/profile-generator.d.ts +65 -0
- package/dist/core/profile-generator.js +310 -0
- package/dist/core/running-executions.d.ts +88 -0
- package/dist/core/running-executions.js +186 -0
- package/dist/core/status-format.d.ts +18 -0
- package/dist/core/status-format.js +31 -0
- package/dist/core/task-parser.d.ts +69 -0
- package/dist/core/task-parser.js +423 -0
- package/dist/core/types/agent-types.d.ts +31 -0
- package/dist/core/types/agent-types.js +5 -0
- package/dist/core/types/thread-types.d.ts +261 -0
- package/dist/core/types/thread-types.js +5 -0
- package/dist/core/utils.d.ts +29 -0
- package/dist/core/utils.js +98 -0
- package/dist/core/version.d.ts +3 -0
- package/dist/core/version.js +12 -0
- package/dist/domain/agents/config.d.ts +58 -0
- package/dist/domain/agents/config.js +313 -0
- package/dist/domain/agents/facade.d.ts +52 -0
- package/dist/domain/agents/facade.js +264 -0
- package/dist/domain/agents/index.d.ts +2 -0
- package/dist/domain/agents/index.js +4 -0
- package/dist/domain/agents/profile-manager.d.ts +54 -0
- package/dist/domain/agents/profile-manager.js +161 -0
- package/dist/domain/costs/codex-event-format.d.ts +4 -0
- package/dist/domain/costs/codex-event-format.js +66 -0
- package/dist/domain/costs/codex-usage-monitor.d.ts +7 -0
- package/dist/domain/costs/codex-usage-monitor.js +72 -0
- package/dist/domain/costs/cost-tracker.d.ts +115 -0
- package/dist/domain/costs/cost-tracker.js +327 -0
- package/dist/domain/costs/gateway-manager.d.ts +6 -0
- package/dist/domain/costs/gateway-manager.js +228 -0
- package/dist/domain/costs/rate-limit-parser.d.ts +11 -0
- package/dist/domain/costs/rate-limit-parser.js +87 -0
- package/dist/domain/costs/rate-limit-throttle.d.ts +32 -0
- package/dist/domain/costs/rate-limit-throttle.js +129 -0
- package/dist/domain/executions/registry.d.ts +20 -0
- package/dist/domain/executions/registry.js +124 -0
- package/dist/domain/mcp/core-server.d.ts +2 -0
- package/dist/domain/mcp/core-server.js +34 -0
- package/dist/domain/mcp/server.d.ts +3 -0
- package/dist/domain/mcp/server.js +78 -0
- package/dist/domain/mcp/tools/context.d.ts +23 -0
- package/dist/domain/mcp/tools/context.js +51 -0
- package/dist/domain/mcp/tools/cortex-md.d.ts +17 -0
- package/dist/domain/mcp/tools/cortex-md.js +36 -0
- package/dist/domain/mcp/tools/cost.d.ts +2 -0
- package/dist/domain/mcp/tools/cost.js +54 -0
- package/dist/domain/mcp/tools/executions.d.ts +2 -0
- package/dist/domain/mcp/tools/executions.js +94 -0
- package/dist/domain/mcp/tools/schedule.d.ts +23 -0
- package/dist/domain/mcp/tools/schedule.js +245 -0
- package/dist/domain/mcp/tools/slack.d.ts +21 -0
- package/dist/domain/mcp/tools/slack.js +124 -0
- package/dist/domain/mcp/tools/task-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/task-ops.js +509 -0
- package/dist/domain/mcp/tools/tui-ask.d.ts +31 -0
- package/dist/domain/mcp/tools/tui-ask.js +108 -0
- package/dist/domain/mcp/tools/tui-plan.d.ts +28 -0
- package/dist/domain/mcp/tools/tui-plan.js +118 -0
- package/dist/domain/mcp/tui-server.d.ts +2 -0
- package/dist/domain/mcp/tui-server.js +69 -0
- package/dist/domain/memory/consolidate.d.ts +55 -0
- package/dist/domain/memory/consolidate.js +471 -0
- package/dist/domain/memory/cortex-md-injector.d.ts +30 -0
- package/dist/domain/memory/cortex-md-injector.js +123 -0
- package/dist/domain/memory/cortex-md-scanner.d.ts +9 -0
- package/dist/domain/memory/cortex-md-scanner.js +67 -0
- package/dist/domain/memory/index-regen.d.ts +19 -0
- package/dist/domain/memory/index-regen.js +398 -0
- package/dist/domain/memory/rules-loader.d.ts +27 -0
- package/dist/domain/memory/rules-loader.js +97 -0
- package/dist/domain/memory/skill-scanner.d.ts +5 -0
- package/dist/domain/memory/skill-scanner.js +132 -0
- package/dist/domain/memory/user-context.d.ts +5 -0
- package/dist/domain/memory/user-context.js +34 -0
- package/dist/domain/memory/watcher.d.ts +2 -0
- package/dist/domain/memory/watcher.js +81 -0
- package/dist/domain/monitor/disk-monitor.d.ts +20 -0
- package/dist/domain/monitor/disk-monitor.js +97 -0
- package/dist/domain/monitor/gpu-monitor.d.ts +26 -0
- package/dist/domain/monitor/gpu-monitor.js +135 -0
- package/dist/domain/remote/client-bootstrap.d.ts +1 -0
- package/dist/domain/remote/client-bootstrap.js +139 -0
- package/dist/domain/remote/client-hot-reload.d.ts +18 -0
- package/dist/domain/remote/client-hot-reload.js +142 -0
- package/dist/domain/remote/client-manager.d.ts +50 -0
- package/dist/domain/remote/client-manager.js +452 -0
- package/dist/domain/remote/cortex-client.d.ts +1 -0
- package/dist/domain/remote/cortex-client.js +704 -0
- package/dist/domain/scheduling/job-registry.d.ts +31 -0
- package/dist/domain/scheduling/job-registry.js +34 -0
- package/dist/domain/scheduling/jobs/_shared.d.ts +14 -0
- package/dist/domain/scheduling/jobs/_shared.js +45 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.d.ts +1 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.js +16 -0
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +11 -0
- package/dist/domain/scheduling/jobs/scheduled-task.js +186 -0
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +41 -0
- package/dist/domain/scheduling/jobs/target-dispatch.js +48 -0
- package/dist/domain/scheduling/jobs/task-archive.d.ts +1 -0
- package/dist/domain/scheduling/jobs/task-archive.js +19 -0
- package/dist/domain/scheduling/jobs/task-dispatch.d.ts +12 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +214 -0
- package/dist/domain/scheduling/runner.d.ts +13 -0
- package/dist/domain/scheduling/runner.js +24 -0
- package/dist/domain/scheduling/schedule-cli.d.ts +16 -0
- package/dist/domain/scheduling/schedule-cli.js +268 -0
- package/dist/domain/scheduling/schedule-command.d.ts +4 -0
- package/dist/domain/scheduling/schedule-command.js +274 -0
- package/dist/domain/scheduling/scheduler.d.ts +86 -0
- package/dist/domain/scheduling/scheduler.js +544 -0
- package/dist/domain/sessions/session-backup.d.ts +49 -0
- package/dist/domain/sessions/session-backup.js +217 -0
- package/dist/domain/sessions/session-hooks.d.ts +103 -0
- package/dist/domain/sessions/session-hooks.js +311 -0
- package/dist/domain/sessions/session-registry.d.ts +21 -0
- package/dist/domain/sessions/session-registry.js +31 -0
- package/dist/domain/sessions/session.d.ts +3 -0
- package/dist/domain/sessions/session.js +14 -0
- package/dist/domain/tasks/archiver.d.ts +9 -0
- package/dist/domain/tasks/archiver.js +123 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +37 -0
- package/dist/domain/tasks/dispatch-utils.js +143 -0
- package/dist/domain/tasks/dispatcher.d.ts +48 -0
- package/dist/domain/tasks/dispatcher.js +285 -0
- package/dist/domain/tasks/lint.d.ts +12 -0
- package/dist/domain/tasks/lint.js +102 -0
- package/dist/domain/tasks/mutator.d.ts +21 -0
- package/dist/domain/tasks/mutator.js +208 -0
- package/dist/domain/tasks/parser.d.ts +1 -0
- package/dist/domain/tasks/parser.js +6 -0
- package/dist/domain/tasks/pending-tracker.d.ts +67 -0
- package/dist/domain/tasks/pending-tracker.js +163 -0
- package/dist/domain/tasks/recommendation/extractor.d.ts +12 -0
- package/dist/domain/tasks/recommendation/extractor.js +563 -0
- package/dist/domain/tasks/recommendation/patterns.d.ts +11 -0
- package/dist/domain/tasks/recommendation/patterns.js +99 -0
- package/dist/domain/tasks/recommendation/types.d.ts +67 -0
- package/dist/domain/tasks/recommendation/types.js +5 -0
- package/dist/domain/tasks/store.d.ts +1 -0
- package/dist/domain/tasks/store.js +3 -0
- package/dist/domain/tasks/system/cortex-run.d.ts +24 -0
- package/dist/domain/tasks/system/cortex-run.js +342 -0
- package/dist/domain/tasks/system/task-cli.d.ts +49 -0
- package/dist/domain/tasks/system/task-cli.js +664 -0
- package/dist/domain/tasks/system/task-completion.d.ts +22 -0
- package/dist/domain/tasks/system/task-completion.js +89 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +24 -0
- package/dist/domain/tasks/system/task-id-utils.js +84 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +34 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.js +208 -0
- package/dist/domain/tasks/system/task-lock.d.ts +25 -0
- package/dist/domain/tasks/system/task-lock.js +139 -0
- package/dist/domain/tasks/system/task-mutations.d.ts +31 -0
- package/dist/domain/tasks/system/task-mutations.js +110 -0
- package/dist/domain/tasks/system/task-process.d.ts +37 -0
- package/dist/domain/tasks/system/task-process.js +119 -0
- package/dist/domain/tasks/system/task-state.d.ts +70 -0
- package/dist/domain/tasks/system/task-state.js +176 -0
- package/dist/domain/threads/artifact-io.d.ts +18 -0
- package/dist/domain/threads/artifact-io.js +182 -0
- package/dist/domain/threads/auto-thread.d.ts +3 -0
- package/dist/domain/threads/auto-thread.js +19 -0
- package/dist/domain/threads/hook-runner.d.ts +4 -0
- package/dist/domain/threads/hook-runner.js +250 -0
- package/dist/domain/threads/index.d.ts +5 -0
- package/dist/domain/threads/index.js +7 -0
- package/dist/domain/threads/prompt-builder.d.ts +25 -0
- package/dist/domain/threads/prompt-builder.js +176 -0
- package/dist/domain/threads/runner.d.ts +83 -0
- package/dist/domain/threads/runner.js +434 -0
- package/dist/domain/threads/state-machine.d.ts +61 -0
- package/dist/domain/threads/state-machine.js +440 -0
- package/dist/domain/threads/template-loader.d.ts +20 -0
- package/dist/domain/threads/template-loader.js +189 -0
- package/dist/domain/threads/template-resolver.d.ts +1 -0
- package/dist/domain/threads/template-resolver.js +95 -0
- package/dist/domain/threads/utils.d.ts +19 -0
- package/dist/domain/threads/utils.js +49 -0
- package/dist/entry/app.d.ts +1 -0
- package/dist/entry/app.js +234 -0
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +254 -0
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +521 -0
- package/dist/entry/init.d.ts +93 -0
- package/dist/entry/init.js +1299 -0
- package/dist/entry/startup-helpers.d.ts +2 -0
- package/dist/entry/startup-helpers.js +56 -0
- package/dist/entry/startup-notify.d.ts +10 -0
- package/dist/entry/startup-notify.js +20 -0
- package/dist/events/event-bus.d.ts +42 -0
- package/dist/events/event-bus.js +84 -0
- package/dist/events/event-logger.d.ts +12 -0
- package/dist/events/event-logger.js +135 -0
- package/dist/events/event-replay.d.ts +1 -0
- package/dist/events/event-replay.js +51 -0
- package/dist/events/event-types.d.ts +145 -0
- package/dist/events/event-types.js +5 -0
- package/dist/events/index.d.ts +5 -0
- package/dist/events/index.js +6 -0
- package/dist/hooks/ask-user-question-hook.mjs +66 -0
- package/dist/hooks/cortex-md-injector.mjs +237 -0
- package/dist/hooks/exit-plan-mode-hook.mjs +84 -0
- package/dist/hooks/memory-ref-tracker.mjs +154 -0
- package/dist/hooks/new-session-hook.mjs +83 -0
- package/dist/hooks/post-task-hook.mjs +63 -0
- package/dist/hooks/rules-loader.mjs +212 -0
- package/dist/hooks/sensitive-file-edit.mjs +84 -0
- package/dist/hooks/session-activity-tracker.mjs +254 -0
- package/dist/hooks/task-status-check.mjs +218 -0
- package/dist/hooks/tasks-yaml-guard.mjs +230 -0
- package/dist/orchestration/agent-runner.d.ts +72 -0
- package/dist/orchestration/agent-runner.js +289 -0
- package/dist/orchestration/busy-tracker.d.ts +12 -0
- package/dist/orchestration/busy-tracker.js +35 -0
- package/dist/orchestration/channel-queue.d.ts +18 -0
- package/dist/orchestration/channel-queue.js +32 -0
- package/dist/orchestration/dispatch-reconciler.d.ts +1 -0
- package/dist/orchestration/dispatch-reconciler.js +16 -0
- package/dist/orchestration/durable-helpers.d.ts +4 -0
- package/dist/orchestration/durable-helpers.js +42 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +32 -0
- package/dist/orchestration/interactions/ask-user-question.js +182 -0
- package/dist/orchestration/interactions/command-action-router.d.ts +47 -0
- package/dist/orchestration/interactions/command-action-router.js +91 -0
- package/dist/orchestration/interactions/interaction-handlers.d.ts +5 -0
- package/dist/orchestration/interactions/interaction-handlers.js +279 -0
- package/dist/orchestration/interactions/plan-approvals.d.ts +47 -0
- package/dist/orchestration/interactions/plan-approvals.js +77 -0
- package/dist/orchestration/interactions/plan-handler.d.ts +6 -0
- package/dist/orchestration/interactions/plan-handler.js +12 -0
- package/dist/orchestration/lifecycle.d.ts +50 -0
- package/dist/orchestration/lifecycle.js +308 -0
- package/dist/orchestration/orchestrator.d.ts +29 -0
- package/dist/orchestration/orchestrator.js +25 -0
- package/dist/orchestration/routing/commands/cancel.d.ts +10 -0
- package/dist/orchestration/routing/commands/cancel.js +136 -0
- package/dist/orchestration/routing/commands/channel.d.ts +11 -0
- package/dist/orchestration/routing/commands/channel.js +219 -0
- package/dist/orchestration/routing/commands/command-context.d.ts +29 -0
- package/dist/orchestration/routing/commands/command-context.js +4 -0
- package/dist/orchestration/routing/commands/cost.d.ts +3 -0
- package/dist/orchestration/routing/commands/cost.js +22 -0
- package/dist/orchestration/routing/commands/device.d.ts +6 -0
- package/dist/orchestration/routing/commands/device.js +83 -0
- package/dist/orchestration/routing/commands/dispatch.d.ts +2 -0
- package/dist/orchestration/routing/commands/dispatch.js +49 -0
- package/dist/orchestration/routing/commands/index.d.ts +15 -0
- package/dist/orchestration/routing/commands/index.js +130 -0
- package/dist/orchestration/routing/commands/mode.d.ts +13 -0
- package/dist/orchestration/routing/commands/mode.js +290 -0
- package/dist/orchestration/routing/commands/nvtop.d.ts +3 -0
- package/dist/orchestration/routing/commands/nvtop.js +103 -0
- package/dist/orchestration/routing/commands/orient.d.ts +2 -0
- package/dist/orchestration/routing/commands/orient.js +3 -0
- package/dist/orchestration/routing/commands/schedule.d.ts +4 -0
- package/dist/orchestration/routing/commands/schedule.js +132 -0
- package/dist/orchestration/routing/commands/sendfile.d.ts +2 -0
- package/dist/orchestration/routing/commands/sendfile.js +92 -0
- package/dist/orchestration/routing/commands/session.d.ts +9 -0
- package/dist/orchestration/routing/commands/session.js +153 -0
- package/dist/orchestration/routing/commands/status.d.ts +7 -0
- package/dist/orchestration/routing/commands/status.js +180 -0
- package/dist/orchestration/routing/commands/tail.d.ts +2 -0
- package/dist/orchestration/routing/commands/tail.js +73 -0
- package/dist/orchestration/routing/commands/task.d.ts +6 -0
- package/dist/orchestration/routing/commands/task.js +142 -0
- package/dist/orchestration/routing/commands/thread-handlers.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread-handlers.js +138 -0
- package/dist/orchestration/routing/commands/thread.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread.js +2 -0
- package/dist/orchestration/routing/edit-handler.d.ts +24 -0
- package/dist/orchestration/routing/edit-handler.js +161 -0
- package/dist/orchestration/routing/file-handler.d.ts +6 -0
- package/dist/orchestration/routing/file-handler.js +23 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +4 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.js +79 -0
- package/dist/orchestration/routing/hook-bridge.d.ts +30 -0
- package/dist/orchestration/routing/hook-bridge.js +112 -0
- package/dist/orchestration/routing/message-router.d.ts +6 -0
- package/dist/orchestration/routing/message-router.js +70 -0
- package/dist/orchestration/routing/webhook.d.ts +10 -0
- package/dist/orchestration/routing/webhook.js +239 -0
- package/dist/orchestration/status-helpers.d.ts +66 -0
- package/dist/orchestration/status-helpers.js +222 -0
- package/dist/orchestration/superseded-edits.d.ts +22 -0
- package/dist/orchestration/superseded-edits.js +31 -0
- package/dist/orchestration/thread-executor.d.ts +31 -0
- package/dist/orchestration/thread-executor.js +234 -0
- package/dist/platform/adapter.d.ts +28 -0
- package/dist/platform/adapter.js +5 -0
- package/dist/platform/adapters/feishu.d.ts +66 -0
- package/dist/platform/adapters/feishu.js +558 -0
- package/dist/platform/adapters/index.d.ts +16 -0
- package/dist/platform/adapters/index.js +65 -0
- package/dist/platform/adapters/slack.d.ts +90 -0
- package/dist/platform/adapters/slack.js +630 -0
- package/dist/platform/index.d.ts +12 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/interactive-builder.d.ts +27 -0
- package/dist/platform/interactive-builder.js +120 -0
- package/dist/platform/testing.d.ts +100 -0
- package/dist/platform/testing.js +190 -0
- package/dist/platform/tool-trace.d.ts +33 -0
- package/dist/platform/tool-trace.js +165 -0
- package/dist/platform/types.d.ts +176 -0
- package/dist/platform/types.js +5 -0
- package/dist/platform/utils/rate-limiter.d.ts +92 -0
- package/dist/platform/utils/rate-limiter.js +213 -0
- package/dist/platform/virtual-message.d.ts +68 -0
- package/dist/platform/virtual-message.js +464 -0
- package/dist/store/atomic-write.d.ts +6 -0
- package/dist/store/atomic-write.js +18 -0
- package/dist/store/channel-repo.d.ts +21 -0
- package/dist/store/channel-repo.js +55 -0
- package/dist/store/conversation-ledger-repo.d.ts +86 -0
- package/dist/store/conversation-ledger-repo.js +220 -0
- package/dist/store/cost-repo.d.ts +57 -0
- package/dist/store/cost-repo.js +135 -0
- package/dist/store/execution-repo.d.ts +172 -0
- package/dist/store/execution-repo.js +343 -0
- package/dist/store/in-memory-repository.d.ts +14 -0
- package/dist/store/in-memory-repository.js +31 -0
- package/dist/store/json-repository.d.ts +51 -0
- package/dist/store/json-repository.js +118 -0
- package/dist/store/outbound-queue.d.ts +65 -0
- package/dist/store/outbound-queue.js +269 -0
- package/dist/store/profile-repo.d.ts +36 -0
- package/dist/store/profile-repo.js +144 -0
- package/dist/store/project-dir-repo.d.ts +22 -0
- package/dist/store/project-dir-repo.js +60 -0
- package/dist/store/schedule-repo.d.ts +92 -0
- package/dist/store/schedule-repo.js +88 -0
- package/dist/store/session-registry-repo.d.ts +38 -0
- package/dist/store/session-registry-repo.js +96 -0
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +56 -0
- package/dist/store/task-repo.d.ts +41 -0
- package/dist/store/task-repo.js +137 -0
- package/dist/store/thread-repo.d.ts +50 -0
- package/dist/store/thread-repo.js +190 -0
- package/package.json +58 -0
- package/scripts/postinstall-restart-trigger.mjs +39 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: client-manage
|
|
3
|
+
description: "Use when creating, deploying, updating, or troubleshooting cortex-client instances on remote devices"
|
|
4
|
+
author: Cortex
|
|
5
|
+
version: 1.1.0
|
|
6
|
+
allowed-tools:
|
|
7
|
+
- Read
|
|
8
|
+
- Write
|
|
9
|
+
- Edit
|
|
10
|
+
- Bash
|
|
11
|
+
- mcp__cortex-core__remote_bash
|
|
12
|
+
- mcp__cortex-core__remote_read
|
|
13
|
+
- mcp__cortex-core__remote_write
|
|
14
|
+
- mcp__cortex-core__remote_edit
|
|
15
|
+
- mcp__cortex-core__remote_glob
|
|
16
|
+
- mcp__cortex-core__remote_grep
|
|
17
|
+
date: 2026-05-03
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Client Manage
|
|
21
|
+
|
|
22
|
+
You are Cortex. You manage remote `cortex-client` instances that run on registered devices. The client connects to the server via WebSocket and executes commands (bash, read, write, edit, glob, grep) on behalf of the server.
|
|
23
|
+
|
|
24
|
+
The server (`client-manager.ts`) starts clients automatically. Your job is to ensure each device has a working client installation **and a reachable network path** back to the server.
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
cortex-agent-server ──SSH──► starts cortex-client on remote device
|
|
30
|
+
▲ │
|
|
31
|
+
│ WebSocket ws://<serverHost>:3002 │
|
|
32
|
+
└────────────────────────────────────┘
|
|
33
|
+
(client initiates this connection back to server)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Critical:** The WebSocket connection is initiated FROM the remote device TO the server. The `serverHost` in the config MUST be an IP the remote device can reach. The server's SSH access to the device is separate — it's used for lifecycle management (start/kill/update) but not for the real-time command channel.
|
|
37
|
+
|
|
38
|
+
## Config File
|
|
39
|
+
|
|
40
|
+
`~/.cortex/config/cortex-client.json`:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"serverHost": "<reachable-ip>",
|
|
45
|
+
"serverPort": 3002,
|
|
46
|
+
"deviceName": "<device-name>"
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- `serverHost` — The IP the client connects TO. **Must be reachable from the remote device.** Use Tailscale IP when available (`tailscale ip -4` on server), LAN IP for devices on same subnet, `127.0.0.1` for same-machine.
|
|
51
|
+
- `serverPort` — Usually `3002`.
|
|
52
|
+
- `deviceName` — Must match the name in `machines.json` on the server.
|
|
53
|
+
|
|
54
|
+
**This config file is managed by you (LLM).** The server never writes it. Server only starts/kills the client process.
|
|
55
|
+
|
|
56
|
+
## Connectivity — The Most Important Part
|
|
57
|
+
|
|
58
|
+
The bidirectional path must work:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
server → remote: SSH (server starts/kills/updates client)
|
|
62
|
+
remote → server: WebSocket to <serverHost>:3002 (client connects back)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Verify the Return Path
|
|
66
|
+
|
|
67
|
+
When bootstrapping a new device or debugging connection issues, ALWAYS verify the remote device can reach the server's WebSocket port:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
ssh user@host "timeout 3 bash -c 'echo > /dev/tcp/<serverHost>/3002' 2>&1 && echo REACHABLE || echo UNREACHABLE"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### How to Fix Connectivity
|
|
74
|
+
|
|
75
|
+
| Situation | Fix |
|
|
76
|
+
|-----------|-----|
|
|
77
|
+
| Same LAN, unreachable | Check firewall: `sudo ufw allow 3002` on server |
|
|
78
|
+
| Different network | Use Tailscale IP (works through NAT) |
|
|
79
|
+
| STCP tunnel only | Use Tailscale or set up reverse SSH: `ssh -R 3002:localhost:3002 user@host` on server |
|
|
80
|
+
| Tailscale but unreachable | `tailscale status` — ensure both devices are connected, check ACLs |
|
|
81
|
+
| Can SSH but can't TCP | SSH works on port 22 only. Either open port 3002 or use Tailscale/reverse tunnel |
|
|
82
|
+
|
|
83
|
+
### Determine the Right serverHost
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# On the server, get candidate IPs:
|
|
87
|
+
tailscale ip -4 # Tailscale CGNAT (works everywhere) — PREFERRED
|
|
88
|
+
hostname -I | awk '{print $1}' # Primary LAN IP
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Test each candidate from the remote device. Use the first one that works.
|
|
92
|
+
|
|
93
|
+
## Device Reference
|
|
94
|
+
|
|
95
|
+
Read `machines.json` on the server for the current device list. Key fields per device:
|
|
96
|
+
|
|
97
|
+
- `ssh` — How the server reaches this device (empty = local)
|
|
98
|
+
- `cortexPath` — Path to user's workspace on the device
|
|
99
|
+
- `gpuCount` — Number of GPUs
|
|
100
|
+
- `win` — `true` for Windows
|
|
101
|
+
|
|
102
|
+
## Bootstrap — New Device
|
|
103
|
+
|
|
104
|
+
### 1. Register in machines.json
|
|
105
|
+
|
|
106
|
+
Edit `machines.json` on the server to add the device entry.
|
|
107
|
+
|
|
108
|
+
### 2. Install cortex-client
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Build from source
|
|
112
|
+
cd <cortex-repo>/client && npm run build && npm pack
|
|
113
|
+
|
|
114
|
+
# Transfer and install
|
|
115
|
+
scp cortex-agent-client-*.tgz user@host:~/
|
|
116
|
+
ssh user@host "npm install -g ./cortex-agent-client-*.tgz"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 3. Write the config
|
|
120
|
+
|
|
121
|
+
First, determine the correct `serverHost` (see Connectivity section above). Then write:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
ssh user@host 'mkdir -p ~/.cortex/config && cat > ~/.cortex/config/cortex-client.json << EOF
|
|
125
|
+
{
|
|
126
|
+
"serverHost": "<REACHABLE_IP>",
|
|
127
|
+
"serverPort": 3002,
|
|
128
|
+
"deviceName": "<device-name>"
|
|
129
|
+
}
|
|
130
|
+
EOF'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Or use `mcp__cortex-core__remote_write` if the device is already reachable via another client.
|
|
134
|
+
|
|
135
|
+
### 4. Verify connectivity
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
ssh user@host "timeout 3 bash -c 'echo > /dev/tcp/<serverHost>/3002' 2>&1 && echo REACHABLE || echo UNREACHABLE"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 5. Restart the server
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
touch <cortex-repo>/agent-server/.restart
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The server will pick up the new device and start the client automatically.
|
|
148
|
+
|
|
149
|
+
## Maintenance
|
|
150
|
+
|
|
151
|
+
### Check if a client is online
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
mcp__cortex-core__remote_bash({ device: "<device-name>", command: "hostname" })
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
"Device is not online" means the client is down or disconnected.
|
|
158
|
+
|
|
159
|
+
### View client logs
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
ssh user@host "tail -20 ~/.cortex/logs/client-\$(date +%Y%m%d).log"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Update cortex-client
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Update and restart
|
|
169
|
+
ssh user@host "npm update -g @cortex-agent/client && pkill -f 'node.*cortex-client'"
|
|
170
|
+
# Server's client-manager will restart it automatically via scheduleRestart()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Edit the config
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
mcp__cortex-core__remote_edit({
|
|
177
|
+
device: "<device-name>",
|
|
178
|
+
file_path: "~/.cortex/config/cortex-client.json",
|
|
179
|
+
old_string: "\"serverHost\": \"<old-ip>\"",
|
|
180
|
+
new_string: "\"serverHost\": \"<new-ip>\""
|
|
181
|
+
})
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
After editing, kill the client — server will restart it:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
ssh user@host "pkill -f 'node.*cortex-client'"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Troubleshooting
|
|
191
|
+
|
|
192
|
+
| Symptom | Likely Cause | Check |
|
|
193
|
+
|---------|-------------|-------|
|
|
194
|
+
| "Device is not online" | Client process died | `ssh user@host "pgrep -f cortex-client"` |
|
|
195
|
+
| Client exits on start | Config missing or bad serverHost | Check `~/.cortex/config/cortex-client.json` exists and serverHost is reachable |
|
|
196
|
+
| "Device already connected" | Stale process | `ssh user@host "pkill -f cortex-client"`, server will restart |
|
|
197
|
+
| WebSocket connect EHOSTUNREACH | Wrong serverHost | Verify with `/dev/tcp` test, fix the IP |
|
|
198
|
+
| Exit code 127 | cortex-client binary not on PATH | `ssh user@host "which cortex-client"`, reinstall with `npm i -g` |
|
|
199
|
+
| Server can't SSH to device | SSH key or tunnel issue | `ssh user@host hostname` from server |
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Please update me when files in this folder change.
|
|
2
|
+
|
|
3
|
+
Deep-retrospective skill: mines historical Claude Code logs and synthesizes patterns across sessions.
|
|
4
|
+
|
|
5
|
+
| filename | role | function |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `SKILL.md` | documentation | Defines trigger conditions, workflow, and output |
|
|
8
|
+
| `scripts/` | subdirectory | Log scanning and session extraction scripts |
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deep-retrospective
|
|
3
|
+
description: Use when reviewing multi-day work across past Claude Code sessions, extracting reusable patterns from historical logs, or asking what was learned about a topic over time.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Write
|
|
7
|
+
- Edit
|
|
8
|
+
- Bash
|
|
9
|
+
- Grep
|
|
10
|
+
- Glob
|
|
11
|
+
- Agent
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Deep Retrospective
|
|
15
|
+
|
|
16
|
+
Mine historical Claude Code conversation logs to extract cross-session knowledge that no
|
|
17
|
+
single session could reveal: iterative patterns, recurring bugs, evolving solutions, and
|
|
18
|
+
methodology that emerged across multiple work sessions.
|
|
19
|
+
|
|
20
|
+
## When to Use
|
|
21
|
+
|
|
22
|
+
- After a multi-day effort (video production, training pipeline, debugging saga)
|
|
23
|
+
- When the user says "what did we learn about X over the past few days"
|
|
24
|
+
- When you want to generalize a workflow into a skill or knowledge entry based on actual experience
|
|
25
|
+
- Periodic review of accumulated work to find patterns worth codifying
|
|
26
|
+
|
|
27
|
+
## How It Differs From `/compound`
|
|
28
|
+
|
|
29
|
+
| | compound | deep-retrospective |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| **Scope** | Current session only | Multiple sessions across days/weeks |
|
|
32
|
+
| **Input** | Conversation context in memory | JSONL log files on disk |
|
|
33
|
+
| **Strength** | Captures fresh insights in the moment | Reveals cross-session patterns and evolution |
|
|
34
|
+
| **Output** | Knowledge entries (knowledge/K-NNN.md), conventions | Methodology, code templates, workflow skills |
|
|
35
|
+
| **When** | End of a productive session | After a multi-day effort completes |
|
|
36
|
+
|
|
37
|
+
They are complementary: `/compound` captures in the moment, `/deep-retrospective` finds what
|
|
38
|
+
emerged across sessions that no single session could see.
|
|
39
|
+
|
|
40
|
+
## The Process
|
|
41
|
+
|
|
42
|
+
### Step 1: Scope the Retrospective
|
|
43
|
+
|
|
44
|
+
Identify:
|
|
45
|
+
- **Time range**: which dates to scan (e.g., "March 1-3")
|
|
46
|
+
- **Topic**: keywords to filter by (e.g., "video, compose, render")
|
|
47
|
+
- **Goal**: what kind of output (knowledge entry (knowledge/K-NNN.md)? skill? code template? methodology doc?)
|
|
48
|
+
|
|
49
|
+
### Step 2: Scan Logs
|
|
50
|
+
|
|
51
|
+
Use the bundled scanner to find relevant sessions:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python3 .claude/skills/deep-retrospective/scripts/scan_logs.py \
|
|
55
|
+
--from 2026-03-01 --to 2026-03-03 \
|
|
56
|
+
--keywords "video,compose,render,wall,grid"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This scans all JSONL files in the resolved Claude Code project log directory for the current repo (derived from the project path unless `--log-dir` overrides it), filters by
|
|
60
|
+
date range and keywords, and ranks sessions by relevance. Output includes:
|
|
61
|
+
- Session IDs and paths
|
|
62
|
+
- Size and message count
|
|
63
|
+
- Keyword hit counts per session
|
|
64
|
+
- Subagent log paths
|
|
65
|
+
|
|
66
|
+
### Step 3: Extract Conversations
|
|
67
|
+
|
|
68
|
+
For each relevant session, extract readable conversation:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
python3 .claude/skills/deep-retrospective/scripts/extract_session.py \
|
|
72
|
+
<session_path.jsonl> \
|
|
73
|
+
--keywords "video,render" \
|
|
74
|
+
--context 2 \
|
|
75
|
+
--max-lines 500
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This converts JSONL into readable `USER/ASST` dialogue with tool call summaries,
|
|
79
|
+
filtered to keyword-relevant segments with context windows.
|
|
80
|
+
|
|
81
|
+
**Subagent scaling**: For ≤5 relevant sessions, process sequentially (one extract call each).
|
|
82
|
+
For >5 sessions, launch subagents in parallel — group 2-3 sessions per subagent to balance
|
|
83
|
+
parallelism vs overhead. Each subagent extracts keyword-relevant segments and returns a
|
|
84
|
+
structured summary.
|
|
85
|
+
|
|
86
|
+
### Step 4: Analyze Patterns
|
|
87
|
+
|
|
88
|
+
Read the extracted conversations looking for these cross-session signals:
|
|
89
|
+
|
|
90
|
+
**Iteration patterns** — The same problem being attacked across multiple sessions:
|
|
91
|
+
- Bug fixed, reappeared, fixed differently → the final fix is the knowledge
|
|
92
|
+
- Approach tried, failed, replaced → the failure reason + replacement is the knowledge
|
|
93
|
+
- Design decision made, then revised → the revision reason is the knowledge
|
|
94
|
+
|
|
95
|
+
**Workflow evolution** — How the process changed over time:
|
|
96
|
+
- Session 1: manual steps → Session 3: automated script → the automation is the knowledge
|
|
97
|
+
- Early sessions: lots of trial-and-error → Later: systematic approach → the method is the knowledge
|
|
98
|
+
|
|
99
|
+
**Recurring friction** — Same class of problem across sessions:
|
|
100
|
+
- Name mismatches every time assets are collected → naming convention is the knowledge
|
|
101
|
+
- Grid computation bugs in every render iteration → grid math pattern is the knowledge
|
|
102
|
+
|
|
103
|
+
**User corrections** — Where the user redirected or corrected:
|
|
104
|
+
- "That's not why we crop — it's to zoom in on the subject" → corrected understanding is the knowledge
|
|
105
|
+
- "Don't hardcode this" → parameterization principle is the knowledge
|
|
106
|
+
|
|
107
|
+
### Step 5: Synthesize Output
|
|
108
|
+
|
|
109
|
+
Based on what patterns were found, produce the appropriate output.
|
|
110
|
+
|
|
111
|
+
**All retrospective reports must be written to `context/retrospectives/`**:
|
|
112
|
+
- File naming: `YYYY-MM-DD-<topic>.md` (date = execution date, topic = keyword)
|
|
113
|
+
- Update `context/retrospectives/CORTEX.md` index with new entry
|
|
114
|
+
- This is the persistent record — even if the output also creates K-entries or skills
|
|
115
|
+
|
|
116
|
+
**Report structure** (see `context/retrospectives/2026-03-04-video-compose.md` as example):
|
|
117
|
+
|
|
118
|
+
```markdown
|
|
119
|
+
# Retrospective: <Topic>
|
|
120
|
+
|
|
121
|
+
> Extraction date: YYYY-MM-DD
|
|
122
|
+
> Source: Claude Code conversation logs for date range (N sessions, ~X MB)
|
|
123
|
+
> Project: <project name>
|
|
124
|
+
> Output: <what was produced — K-entries, skills, templates>
|
|
125
|
+
|
|
126
|
+
## Background
|
|
127
|
+
<Why this retrospective was triggered>
|
|
128
|
+
|
|
129
|
+
## Cross-Session Pattern Discoveries
|
|
130
|
+
### Pattern 1: <Pattern name>
|
|
131
|
+
<Evidence from logs + extracted knowledge>
|
|
132
|
+
|
|
133
|
+
### Pattern N: ...
|
|
134
|
+
|
|
135
|
+
## Outputs
|
|
136
|
+
<List of concrete outputs: K-entries added, skills created, templates written>
|
|
137
|
+
|
|
138
|
+
## Methodology Reflection
|
|
139
|
+
<Meta-observations about the retrospective process itself>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Additional outputs** (alongside the report):
|
|
143
|
+
|
|
144
|
+
**Knowledge entry** (for a single insight):
|
|
145
|
+
- Create a new knowledge entry in the relevant project's `knowledge/K-NNN.md`
|
|
146
|
+
- Cross-project methodology → create a new entry in `cortex-self/knowledge/K-NNN.md`
|
|
147
|
+
- Include: evidence (which sessions), verification date
|
|
148
|
+
|
|
149
|
+
**Skill** (for a repeatable workflow):
|
|
150
|
+
- Create via skill-creator
|
|
151
|
+
- Include code templates in `references/` extracted from actual working code
|
|
152
|
+
- Generalize: strip project-specific details, keep the battle-tested patterns
|
|
153
|
+
|
|
154
|
+
**Code templates** (for reusable code patterns):
|
|
155
|
+
- Extract the final working version of key functions
|
|
156
|
+
- Remove project-specific names/paths, add parameters
|
|
157
|
+
- Add comments explaining why each pattern exists (the "why" comes from the iteration history)
|
|
158
|
+
|
|
159
|
+
### Step 6: Validate and Commit
|
|
160
|
+
|
|
161
|
+
Before finalizing, cross-check:
|
|
162
|
+
- [ ] Every claim traces to a specific session/commit (not invented)
|
|
163
|
+
- [ ] Code templates actually come from working code (not theoretical)
|
|
164
|
+
- [ ] Generalizations don't lose essential details
|
|
165
|
+
- [ ] User corrections are incorporated (not the pre-correction version)
|
|
166
|
+
- [ ] Report written to `context/retrospectives/YYYY-MM-DD-<topic>.md`
|
|
167
|
+
- [ ] `context/retrospectives/CORTEX.md` index updated
|
|
168
|
+
- [ ] Git commit with all changes
|
|
169
|
+
|
|
170
|
+
## Log File Format
|
|
171
|
+
|
|
172
|
+
Claude Code stores logs in `~/.claude/projects/<project-slug>/`:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
<session-uuid>.jsonl — main conversation log
|
|
176
|
+
<session-uuid>/subagents/ — subagent conversation logs
|
|
177
|
+
agent-<id>.jsonl
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Each JSONL line is a record with:
|
|
181
|
+
- `type`: "user" | "assistant" | "queue-operation"
|
|
182
|
+
- `message.role`: "user" | "assistant"
|
|
183
|
+
- `message.content`: string or array of content blocks
|
|
184
|
+
- `{type: "text", text: "..."}` — conversation text
|
|
185
|
+
- `{type: "tool_use", name: "...", input: {...}}` — tool calls
|
|
186
|
+
- `{type: "tool_result", content: "..."}` — tool outputs
|
|
187
|
+
- `timestamp`: ISO 8601
|
|
188
|
+
- `sessionId`: UUID
|
|
189
|
+
|
|
190
|
+
## Tips
|
|
191
|
+
|
|
192
|
+
- **Start with scan, not grep**: The scanner scores relevance across files. Raw grep
|
|
193
|
+
returns too many false positives from tool outputs and code snippets.
|
|
194
|
+
- **Subagents for parallel extraction**: For 5+ sessions, launch one subagent per file.
|
|
195
|
+
Each extracts keywords + context, returns a summary. Much faster than sequential reads.
|
|
196
|
+
- **Focus on deltas, not states**: The most valuable knowledge is what *changed* between
|
|
197
|
+
iterations. "We switched from X to Y because Z" is more useful than "we use Y."
|
|
198
|
+
- **User corrections are gold**: When the user says "no, that's not right, it's actually..."
|
|
199
|
+
— that correction often reveals the most non-obvious knowledge.
|
|
200
|
+
- **Git log supplements JSONL**: `git log --oneline --since="2026-03-01" --until="2026-03-04"`
|
|
201
|
+
shows what was actually committed. Correlate with conversation to understand why.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Please update me when files in this folder change.
|
|
2
|
+
|
|
3
|
+
Session scanning and extraction scripts for deep-retrospective, processing Claude Code JSONL logs.
|
|
4
|
+
|
|
5
|
+
| filename | role | function |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `scan_logs.py` | scanning | Sort sessions by keyword and downweight already-covered dates |
|
|
8
|
+
| `extract_session.py` | extraction | Convert JSONL sessions to text with tool summaries |
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# input: Claude Code session JSONL path plus optional keywords/max-lines CLI args
|
|
3
|
+
# output: filtered readable conversation text printed to stdout
|
|
4
|
+
# pos: provides single-session extraction for deep-retrospective, converting JSONL logs into readable snippets for analysis
|
|
5
|
+
# >>> If I am updated, be sure to update my header comment and the CORTEX.md in the same folder <<<
|
|
6
|
+
"""
|
|
7
|
+
Extract readable conversation from a Claude Code session log.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
python extract_session.py <session_path> [--keywords "video,render"] [--max-lines 500]
|
|
11
|
+
|
|
12
|
+
Output: Filtered, readable conversation text to stdout.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import json
|
|
17
|
+
import argparse
|
|
18
|
+
import textwrap
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def extract_text(record):
|
|
22
|
+
"""Extract readable text from a log record."""
|
|
23
|
+
msg = record.get("message")
|
|
24
|
+
if not msg:
|
|
25
|
+
content = record.get("content", "")
|
|
26
|
+
if content and record.get("type") == "queue-operation":
|
|
27
|
+
return f"[queue:{record.get('operation','')}] {content}"
|
|
28
|
+
return ""
|
|
29
|
+
|
|
30
|
+
content = msg.get("content", "")
|
|
31
|
+
if isinstance(content, str):
|
|
32
|
+
return content
|
|
33
|
+
|
|
34
|
+
if isinstance(content, list):
|
|
35
|
+
parts = []
|
|
36
|
+
for item in content:
|
|
37
|
+
if not isinstance(item, dict):
|
|
38
|
+
continue
|
|
39
|
+
t = item.get("type", "")
|
|
40
|
+
if t == "text":
|
|
41
|
+
parts.append(item.get("text", ""))
|
|
42
|
+
elif t == "tool_use":
|
|
43
|
+
name = item.get("name", "unknown")
|
|
44
|
+
inp = item.get("input", {})
|
|
45
|
+
# Summarize tool calls
|
|
46
|
+
summary_parts = []
|
|
47
|
+
for k, v in inp.items():
|
|
48
|
+
if isinstance(v, str):
|
|
49
|
+
if len(v) > 200:
|
|
50
|
+
v = v[:200] + "..."
|
|
51
|
+
summary_parts.append(f"{k}={v}")
|
|
52
|
+
parts.append(
|
|
53
|
+
f"[tool:{name}] {'; '.join(summary_parts)}"
|
|
54
|
+
)
|
|
55
|
+
elif t == "tool_result":
|
|
56
|
+
sub = item.get("content", "")
|
|
57
|
+
if isinstance(sub, str) and len(sub) > 0:
|
|
58
|
+
if len(sub) > 500:
|
|
59
|
+
sub = sub[:500] + "..."
|
|
60
|
+
parts.append(f"[result] {sub}")
|
|
61
|
+
elif isinstance(sub, list):
|
|
62
|
+
for s in sub:
|
|
63
|
+
if isinstance(s, dict) and s.get("text"):
|
|
64
|
+
text = s["text"]
|
|
65
|
+
if len(text) > 500:
|
|
66
|
+
text = text[:500] + "..."
|
|
67
|
+
parts.append(f"[result] {text}")
|
|
68
|
+
return "\n".join(parts)
|
|
69
|
+
return ""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def main():
|
|
73
|
+
parser = argparse.ArgumentParser(
|
|
74
|
+
description="Extract readable conversation from a session log"
|
|
75
|
+
)
|
|
76
|
+
parser.add_argument("session_path", help="Path to .jsonl file")
|
|
77
|
+
parser.add_argument(
|
|
78
|
+
"--keywords",
|
|
79
|
+
help="Only show messages containing these keywords (comma-separated)"
|
|
80
|
+
)
|
|
81
|
+
parser.add_argument(
|
|
82
|
+
"--max-lines", type=int, default=0,
|
|
83
|
+
help="Max output lines (0=unlimited)"
|
|
84
|
+
)
|
|
85
|
+
parser.add_argument(
|
|
86
|
+
"--context", type=int, default=2,
|
|
87
|
+
help="Messages of context around keyword matches"
|
|
88
|
+
)
|
|
89
|
+
args = parser.parse_args()
|
|
90
|
+
|
|
91
|
+
keywords = None
|
|
92
|
+
if args.keywords:
|
|
93
|
+
keywords = [
|
|
94
|
+
k.strip().lower() for k in args.keywords.split(",")
|
|
95
|
+
if k.strip()
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
# Parse all messages
|
|
99
|
+
messages = []
|
|
100
|
+
with open(args.session_path, encoding="utf-8", errors="replace") as f:
|
|
101
|
+
for line in f:
|
|
102
|
+
try:
|
|
103
|
+
record = json.loads(line)
|
|
104
|
+
except json.JSONDecodeError:
|
|
105
|
+
continue
|
|
106
|
+
|
|
107
|
+
msg_type = record.get("type", "")
|
|
108
|
+
if msg_type not in ("user", "assistant"):
|
|
109
|
+
continue
|
|
110
|
+
|
|
111
|
+
text = extract_text(record)
|
|
112
|
+
if not text or len(text.strip()) < 5:
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
ts = record.get("timestamp", "")
|
|
116
|
+
if "T" in ts:
|
|
117
|
+
ts = ts.split("T")[1][:8]
|
|
118
|
+
|
|
119
|
+
messages.append({
|
|
120
|
+
"type": msg_type,
|
|
121
|
+
"time": ts,
|
|
122
|
+
"text": text,
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
# Filter by keywords if specified
|
|
126
|
+
if keywords:
|
|
127
|
+
matched_indices = set()
|
|
128
|
+
for i, msg in enumerate(messages):
|
|
129
|
+
text_lower = msg["text"].lower()
|
|
130
|
+
if any(kw in text_lower for kw in keywords):
|
|
131
|
+
# Add context window
|
|
132
|
+
for j in range(
|
|
133
|
+
max(0, i - args.context),
|
|
134
|
+
min(len(messages), i + args.context + 1)
|
|
135
|
+
):
|
|
136
|
+
matched_indices.add(j)
|
|
137
|
+
messages = [
|
|
138
|
+
messages[i] for i in sorted(matched_indices)
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
# Output
|
|
142
|
+
line_count = 0
|
|
143
|
+
for msg in messages:
|
|
144
|
+
role = "USER" if msg["type"] == "user" else "ASST"
|
|
145
|
+
header = f"--- [{msg['time']}] {role} ---"
|
|
146
|
+
print(header)
|
|
147
|
+
line_count += 1
|
|
148
|
+
|
|
149
|
+
text = msg["text"]
|
|
150
|
+
if args.max_lines and line_count + text.count("\n") > args.max_lines:
|
|
151
|
+
remaining = args.max_lines - line_count
|
|
152
|
+
lines = text.split("\n")[:remaining]
|
|
153
|
+
print("\n".join(lines))
|
|
154
|
+
print(f"\n... (truncated, {len(messages)} messages total)")
|
|
155
|
+
break
|
|
156
|
+
|
|
157
|
+
print(text)
|
|
158
|
+
line_count += text.count("\n") + 1
|
|
159
|
+
print()
|
|
160
|
+
|
|
161
|
+
print(f"\n=== {len(messages)} messages extracted ===")
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if __name__ == "__main__":
|
|
165
|
+
main()
|