@cortex-agent/server 2026.7.30 → 2026.8.3-2
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 +1 -1
- package/defaults/CORTEX.md +1 -0
- package/defaults/config/CORTEX.md +2 -1
- package/defaults/config/hooks/13-status-md-guard.json +11 -0
- package/defaults/config/hooks/CORTEX.md +1 -0
- package/defaults/config/mcp-config-empty.json +3 -0
- package/defaults/config/thread-templates/agents/benchmark-coder.json +22 -0
- package/defaults/config/thread-templates/agents/benchmark-reviewer.json +22 -0
- package/defaults/config/thread-templates/agents/coder-reviewer.json +4 -9
- package/defaults/config/thread-templates/agents/coder.json +4 -14
- package/defaults/config/thread-templates/templates/benchmark-coder-review.json +37 -0
- package/defaults/config/thread-templates/templates/coder-review.json +3 -27
- package/defaults/context/projects/CORTEX.md +1 -1
- package/defaults/data/schedules.json +12 -0
- package/defaults/hooks/CORTEX.md +1 -0
- package/defaults/hooks/new-session-hook.mjs +2 -2
- package/defaults/hooks/status-md-guard.mjs +193 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +28 -2
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +1 -1
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +4 -2
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +1 -1
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-stage-gate/skills/director-method/SKILL.md +1 -1
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +1 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +2 -2
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +11 -8
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +1 -1
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +13 -16
- package/defaults/prompts/directives/coder-reviewer.md +24 -20
- package/defaults/prompts/directives/coder.md +4 -5
- package/defaults/prompts/directives/director.md +4 -10
- package/defaults/prompts/directives/manager.md +9 -10
- package/defaults/prompts/systemPrompts/worker.md +2 -2
- package/defaults/rules/cortex-md.md +31 -0
- package/defaults/rules/experiment-format.md +8 -1
- package/defaults/rules/issues-md.md +10 -9
- package/defaults/rules/meta-conventions.md +5 -4
- package/defaults/rules/mission-md.md +2 -1
- package/defaults/rules/status-md.md +39 -21
- package/dist/agent-adapter/bg-wait.d.ts +10 -12
- package/dist/agent-adapter/bg-wait.js +209 -129
- package/dist/agent-adapter/claude/adapter-tui.d.ts +3 -1
- package/dist/agent-adapter/claude/adapter-tui.js +8 -5
- package/dist/agent-adapter/claude/adapter.d.ts +43 -14
- package/dist/agent-adapter/claude/adapter.js +276 -161
- package/dist/agent-adapter/claude/defaults.d.ts +2 -0
- package/dist/agent-adapter/claude/defaults.js +5 -5
- package/dist/agent-adapter/claude/event-parser.d.ts +3 -8
- package/dist/agent-adapter/claude/event-parser.js +28 -31
- package/dist/agent-adapter/claude/hooks-builder.js +4 -3
- package/dist/agent-adapter/claude/jsonl-tail.js +54 -35
- package/dist/agent-adapter/claude/spawn-args.d.ts +15 -12
- package/dist/agent-adapter/claude/spawn-args.js +44 -38
- package/dist/agent-adapter/claude/tmux-control.d.ts +4 -17
- package/dist/agent-adapter/claude/tmux-control.js +39 -32
- package/dist/agent-adapter/event-tee.d.ts +19 -0
- package/dist/agent-adapter/event-tee.js +145 -0
- package/dist/agent-adapter/index.d.ts +1 -0
- package/dist/agent-adapter/index.js +7 -3
- package/dist/agent-adapter/normalize/event-types.d.ts +17 -9
- package/dist/agent-adapter/normalize/event-types.js +4 -4
- package/dist/agent-adapter/pi/adapter.d.ts +16 -4
- package/dist/agent-adapter/pi/adapter.js +69 -36
- package/dist/agent-adapter/pi/discovery.d.ts +19 -3
- package/dist/agent-adapter/pi/discovery.js +81 -43
- package/dist/agent-adapter/pi/event-parser.js +4 -2
- package/dist/agent-adapter/pi/spawn-args.d.ts +2 -4
- package/dist/agent-adapter/pi/spawn-args.js +6 -5
- package/dist/agent-adapter/types.d.ts +43 -2
- package/dist/agent-adapter/types.js +8 -4
- package/dist/core/atomic-write.d.ts +6 -1
- package/dist/core/atomic-write.js +183 -7
- package/dist/core/cli-utils.d.ts +15 -2
- package/dist/core/cli-utils.js +46 -41
- package/dist/core/config-generator.d.ts +4 -0
- package/dist/core/config-generator.js +34 -21
- package/dist/core/json-repository.d.ts +4 -0
- package/dist/core/json-repository.js +6 -3
- package/dist/core/locales/en.d.ts +94 -0
- package/dist/core/locales/slices/commands.d.ts +76 -0
- package/dist/core/locales/slices/commands.js +155 -1
- package/dist/core/locales/slices/status.d.ts +18 -0
- package/dist/core/locales/slices/status.js +43 -2
- package/dist/core/log.d.ts +5 -0
- package/dist/core/log.js +25 -23
- package/dist/core/pi-session-filename.d.ts +2 -0
- package/dist/core/pi-session-filename.js +18 -0
- package/dist/core/resume-reminder.d.ts +5 -0
- package/dist/core/resume-reminder.js +18 -0
- package/dist/core/runtime-env.d.ts +1 -0
- package/dist/core/runtime-env.js +15 -0
- package/dist/core/settings-migration.d.ts +5 -0
- package/dist/core/settings-migration.js +128 -0
- package/dist/core/settings-spec.d.ts +174 -0
- package/dist/core/settings-spec.js +150 -0
- package/dist/core/settings.d.ts +10 -0
- package/dist/core/settings.js +235 -0
- package/dist/core/task-parser.d.ts +11 -1
- package/dist/core/task-parser.js +34 -3
- package/dist/core/types/agent-types.d.ts +19 -0
- package/dist/core/types/agent-types.js +1 -1
- package/dist/core/types/thread-types.d.ts +48 -3
- package/dist/core/types/thread-types.js +2 -2
- package/dist/core/utils.d.ts +21 -1
- package/dist/core/utils.js +37 -1
- package/dist/domain/agent-run/access-probe-cli.d.ts +7 -0
- package/dist/domain/agent-run/access-probe-cli.js +139 -0
- package/dist/domain/agent-run/access-probe-policy.d.ts +61 -0
- package/dist/domain/agent-run/access-probe-policy.js +614 -0
- package/dist/domain/agent-run/access-probe.d.ts +21 -0
- package/dist/domain/agent-run/access-probe.js +194 -0
- package/dist/domain/agent-run/agent-run-cli.d.ts +19 -0
- package/dist/domain/agent-run/agent-run-cli.js +171 -0
- package/dist/domain/agent-run/atif.d.ts +54 -0
- package/dist/domain/agent-run/atif.js +211 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.d.ts +32 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.js +616 -0
- package/dist/domain/agent-run/benchmark-thread-identity.d.ts +34 -0
- package/dist/domain/agent-run/benchmark-thread-identity.js +106 -0
- package/dist/domain/agent-run/identity.d.ts +62 -0
- package/dist/domain/agent-run/identity.js +118 -0
- package/dist/domain/agent-run/journal.d.ts +51 -0
- package/dist/domain/agent-run/journal.js +259 -0
- package/dist/domain/agent-run/manifest-contract.d.ts +44 -0
- package/dist/domain/agent-run/manifest-contract.js +134 -0
- package/dist/domain/agent-run/manifest.d.ts +51 -0
- package/dist/domain/agent-run/manifest.js +801 -0
- package/dist/domain/agent-run/pinned-node-process.d.ts +35 -0
- package/dist/domain/agent-run/pinned-node-process.js +206 -0
- package/dist/domain/agent-run/role-surface.d.ts +4 -0
- package/dist/domain/agent-run/role-surface.js +99 -0
- package/dist/domain/agent-run/run-config.d.ts +22 -0
- package/dist/domain/agent-run/run-config.js +135 -0
- package/dist/domain/agent-run/runner.d.ts +7 -0
- package/dist/domain/agent-run/runner.js +518 -0
- package/dist/domain/agent-run/supervisor.d.ts +78 -0
- package/dist/domain/agent-run/supervisor.js +425 -0
- package/dist/domain/agent-run/trajectory-merge-cli.d.ts +11 -0
- package/dist/domain/agent-run/trajectory-merge-cli.js +111 -0
- package/dist/domain/agent-run/trajectory-merge.d.ts +39 -0
- package/dist/domain/agent-run/trajectory-merge.js +505 -0
- package/dist/domain/agents/config.d.ts +10 -0
- package/dist/domain/agents/config.js +149 -44
- package/dist/domain/agents/facade.d.ts +42 -7
- package/dist/domain/agents/facade.js +174 -170
- package/dist/domain/agents/provider-run-lifecycle.d.ts +18 -0
- package/dist/domain/agents/provider-run-lifecycle.js +60 -0
- package/dist/domain/auth/auth-events.d.ts +18 -0
- package/dist/domain/auth/auth-events.js +38 -0
- package/dist/domain/auth/auth-format.d.ts +2 -0
- package/dist/domain/auth/auth-format.js +58 -0
- package/dist/domain/auth/auth-status.d.ts +61 -0
- package/dist/domain/auth/auth-status.js +304 -0
- package/dist/domain/auth/auth-watch.d.ts +16 -0
- package/dist/domain/auth/auth-watch.js +125 -0
- package/dist/domain/auth/cc-login.d.ts +7 -0
- package/dist/domain/auth/cc-login.js +16 -0
- package/dist/domain/auth/cc-subscription.d.ts +38 -0
- package/dist/domain/auth/cc-subscription.js +204 -0
- package/dist/domain/auth/index.d.ts +12 -0
- package/dist/domain/auth/index.js +16 -0
- package/dist/domain/auth/login-flow.d.ts +120 -0
- package/dist/domain/auth/login-flow.js +253 -0
- package/dist/domain/auth/login-service.d.ts +32 -0
- package/dist/domain/auth/login-service.js +97 -0
- package/dist/domain/auth/logout.d.ts +32 -0
- package/dist/domain/auth/logout.js +123 -0
- package/dist/domain/auth/pi-login.d.ts +36 -0
- package/dist/domain/auth/pi-login.js +72 -0
- package/dist/domain/auth/pi-oauth.d.ts +36 -0
- package/dist/domain/auth/pi-oauth.js +84 -0
- package/dist/domain/auth/pi-runtime.d.ts +72 -0
- package/dist/domain/auth/pi-runtime.js +86 -0
- package/dist/domain/mcp/benchmark-thread-server.d.ts +1 -0
- package/dist/domain/mcp/benchmark-thread-server.js +26 -0
- package/dist/domain/mcp/tools/benchmark-thread-run.d.ts +23 -0
- package/dist/domain/mcp/tools/benchmark-thread-run.js +146 -0
- package/dist/domain/memory/user-context.js +6 -8
- package/dist/domain/monitor/disk-monitor.js +47 -16
- package/dist/domain/projects/project-store.js +23 -6
- package/dist/domain/remote/client-hot-reload.d.ts +9 -1
- package/dist/domain/remote/client-hot-reload.js +60 -12
- package/dist/domain/remote/client-manager.js +12 -6
- package/dist/domain/scheduling/jobs/auth-expiry-scan.d.ts +14 -0
- package/dist/domain/scheduling/jobs/auth-expiry-scan.js +86 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +36 -40
- package/dist/domain/scheduling/runner.d.ts +2 -0
- package/dist/domain/scheduling/runner.js +7 -4
- package/dist/domain/sessions/session-backup.d.ts +14 -20
- package/dist/domain/sessions/session-backup.js +57 -68
- package/dist/domain/system/doctor.d.ts +4 -0
- package/dist/domain/system/doctor.js +113 -28
- package/dist/domain/system/install-cli.js +8 -3
- package/dist/domain/system/server-update-check.js +7 -5
- package/dist/domain/system/system-notice.d.ts +3 -1
- package/dist/domain/system/system-notice.js +6 -11
- package/dist/domain/tasks/archiver.d.ts +1 -0
- package/dist/domain/tasks/archiver.js +13 -7
- package/dist/domain/tasks/claim-recovery.d.ts +3 -3
- package/dist/domain/tasks/claim-recovery.js +12 -8
- package/dist/domain/tasks/dispatch-utils.d.ts +15 -14
- package/dist/domain/tasks/dispatch-utils.js +22 -18
- package/dist/domain/tasks/dispatcher.d.ts +1 -0
- package/dist/domain/tasks/dispatcher.js +9 -5
- package/dist/domain/tasks/mutator.d.ts +21 -11
- package/dist/domain/tasks/mutator.js +30 -24
- package/dist/domain/tasks/pending-tracker.d.ts +5 -2
- package/dist/domain/tasks/pending-tracker.js +11 -5
- package/dist/domain/tasks/system/cortex-run.d.ts +2 -1
- package/dist/domain/tasks/system/cortex-run.js +24 -4
- package/dist/domain/tasks/system/task-cli.d.ts +1 -0
- package/dist/domain/tasks/system/task-cli.js +72 -22
- package/dist/domain/tasks/system/task-completion.d.ts +19 -2
- package/dist/domain/tasks/system/task-completion.js +31 -17
- package/dist/domain/tasks/system/task-file-input.d.ts +10 -0
- package/dist/domain/tasks/system/task-file-input.js +57 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +9 -9
- package/dist/domain/tasks/system/task-id-utils.js +13 -4
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +6 -2
- package/dist/domain/tasks/system/task-lifecycle-edit.js +200 -6
- package/dist/domain/tasks/system/task-lock.js +19 -5
- package/dist/domain/tasks/system/task-mutations.d.ts +22 -12
- package/dist/domain/tasks/system/task-mutations.js +28 -4
- package/dist/domain/tasks/system/task-process.js +10 -8
- package/dist/domain/tasks/system/task-state.d.ts +65 -11
- package/dist/domain/tasks/system/task-state.js +86 -13
- package/dist/domain/threads/local-runtime-deps.d.ts +32 -0
- package/dist/domain/threads/local-runtime-deps.js +91 -0
- package/dist/domain/threads/local-runtime-scope.d.ts +6 -0
- package/dist/domain/threads/local-runtime-scope.js +12 -0
- package/dist/domain/threads/pending-user-inputs.d.ts +3 -0
- package/dist/domain/threads/pending-user-inputs.js +37 -0
- package/dist/domain/threads/prompt-builder.d.ts +12 -1
- package/dist/domain/threads/prompt-builder.js +73 -26
- package/dist/domain/threads/runner.d.ts +15 -3
- package/dist/domain/threads/runner.js +261 -105
- package/dist/domain/threads/state-machine.d.ts +1 -1
- package/dist/domain/threads/state-machine.js +17 -8
- package/dist/domain/ui-service/app-router.d.ts +86 -6
- package/dist/domain/ui-service/app-router.js +171 -133
- package/dist/domain/ui-service/input-schemas.d.ts +132 -10
- package/dist/domain/ui-service/input-schemas.js +59 -5
- package/dist/domain/ui-service/mutate/approvals.d.ts +2 -1
- package/dist/domain/ui-service/mutate/approvals.js +2 -1
- package/dist/domain/ui-service/mutate/auth.d.ts +6 -0
- package/dist/domain/ui-service/mutate/auth.js +83 -0
- package/dist/domain/ui-service/mutate/config.js +11 -10
- package/dist/domain/ui-service/query/approvals.js +3 -0
- package/dist/domain/ui-service/query/auth.d.ts +6 -0
- package/dist/domain/ui-service/query/auth.js +12 -0
- package/dist/domain/ui-service/query/config.d.ts +5 -5
- package/dist/domain/ui-service/query/config.js +27 -17
- package/dist/domain/ui-service/query/tasks.d.ts +1 -1
- package/dist/domain/ui-service/query/tasks.js +69 -30
- package/dist/domain/ui-service/query/threads.js +3 -3
- package/dist/domain/ui-service/types.d.ts +67 -8
- package/dist/domain/ui-service/types.js +2 -2
- package/dist/domain/ui-service/ui-service.js +16 -2
- package/dist/entry/admin-channel-hot-reload.d.ts +4 -0
- package/dist/entry/admin-channel-hot-reload.js +22 -0
- package/dist/entry/app.js +38 -38
- package/dist/entry/auth-cli.d.ts +10 -0
- package/dist/entry/auth-cli.js +52 -0
- package/dist/entry/cli-help.d.ts +5 -0
- package/dist/entry/cli-help.js +130 -0
- package/dist/entry/cli.d.ts +5 -5
- package/dist/entry/cli.js +174 -248
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +204 -103
- package/dist/entry/draft-attachments.d.ts +8 -0
- package/dist/entry/draft-attachments.js +83 -0
- package/dist/entry/feishu-login.d.ts +2 -6
- package/dist/entry/feishu-login.js +16 -21
- package/dist/entry/init.js +6 -4
- package/dist/entry/start-ui-http.d.ts +2 -8
- package/dist/entry/start-ui-http.js +7 -34
- package/dist/events/event-logger.js +11 -13
- package/dist/events/event-types.d.ts +19 -1
- package/dist/events/event-types.js +3 -3
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +3 -3
- package/dist/hooks/new-session-hook.mjs +2 -2
- package/dist/hooks/status-md-guard.mjs +193 -0
- package/dist/orchestration/agent-file-send.js +44 -14
- package/dist/orchestration/agent-runner.d.ts +7 -3
- package/dist/orchestration/agent-runner.js +65 -41
- package/dist/orchestration/conversation-runner.d.ts +5 -1
- package/dist/orchestration/conversation-runner.js +16 -7
- package/dist/orchestration/lifecycle.d.ts +23 -1
- package/dist/orchestration/lifecycle.js +103 -40
- package/dist/orchestration/mid-turn-inject.d.ts +2 -0
- package/dist/orchestration/mid-turn-inject.js +29 -13
- package/dist/orchestration/resume-dispatcher.d.ts +3 -5
- package/dist/orchestration/resume-dispatcher.js +9 -17
- package/dist/orchestration/routing/commands/index.d.ts +4 -1
- package/dist/orchestration/routing/commands/index.js +83 -61
- package/dist/orchestration/routing/commands/login-notice.d.ts +21 -0
- package/dist/orchestration/routing/commands/login-notice.js +97 -0
- package/dist/orchestration/routing/commands/login.d.ts +12 -0
- package/dist/orchestration/routing/commands/login.js +555 -0
- package/dist/orchestration/routing/commands/status.js +45 -59
- package/dist/orchestration/routing/edit-handler.d.ts +5 -0
- package/dist/orchestration/routing/edit-handler.js +127 -73
- package/dist/orchestration/routing/webhook.js +5 -4
- package/dist/orchestration/session-rewind.d.ts +5 -1
- package/dist/orchestration/session-rewind.js +106 -62
- package/dist/orchestration/session-send.d.ts +2 -0
- package/dist/orchestration/session-send.js +5 -6
- package/dist/orchestration/status-helpers.d.ts +1 -2
- package/dist/orchestration/status-helpers.js +7 -10
- package/dist/orchestration/thread-callback.d.ts +19 -11
- package/dist/orchestration/thread-callback.js +132 -61
- package/dist/orchestration/thread-executor.js +37 -27
- package/dist/orchestration/turn-mutation-lock.d.ts +3 -0
- package/dist/orchestration/turn-mutation-lock.js +36 -0
- package/dist/orchestration/turn-notify.d.ts +2 -5
- package/dist/orchestration/turn-notify.js +9 -21
- package/dist/platform/adapter.d.ts +1 -0
- package/dist/platform/adapter.js +2 -2
- package/dist/platform/adapters/composite-adapter.d.ts +2 -0
- package/dist/platform/adapters/composite-adapter.js +13 -3
- package/dist/platform/adapters/feishu.d.ts +2 -4
- package/dist/platform/adapters/feishu.js +38 -59
- package/dist/platform/adapters/index.d.ts +1 -1
- package/dist/platform/adapters/index.js +13 -12
- package/dist/platform/adapters/slack.d.ts +1 -1
- package/dist/platform/adapters/slack.js +12 -35
- package/dist/platform/index.d.ts +2 -1
- package/dist/platform/index.js +3 -3
- package/dist/platform/testing.d.ts +1 -0
- package/dist/platform/testing.js +13 -4
- package/dist/platform/tool-trace.js +6 -11
- package/dist/platform/ui-http/ui-http-server.d.ts +1 -1
- package/dist/platform/ui-http/ui-http-server.js +6 -18
- package/dist/store/execution-repo.d.ts +17 -1
- package/dist/store/execution-repo.js +55 -4
- package/dist/store/prompt-migration-replacements.d.ts +4 -0
- package/dist/store/prompt-migration-replacements.js +149 -0
- package/dist/store/thread-repo.d.ts +15 -4
- package/dist/store/thread-repo.js +61 -24
- package/dist/store/version-migrations.js +36 -1
- package/native/cortex-supervisor/dist/build-manifest.json +22 -0
- package/native/cortex-supervisor/dist/cortex-supervisor +0 -0
- package/package.json +5 -2
- package/web/dist/assets/index-XqBCYtkw.js +139 -0
- package/web/dist/assets/index-zpf3OSKC.css +1 -0
- package/web/dist/index.html +2 -2
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.d.ts +0 -1
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.js +0 -78
- package/web/dist/assets/index-B19jLgji.js +0 -138
- package/web/dist/assets/index-BuFyPyRW.css +0 -1
package/README.md
CHANGED
|
@@ -145,7 +145,7 @@ variable reference, file layout, and precedence rules are in
|
|
|
145
145
|
| [Desktop & Android Apps](./docs/desktop-app.md) | Native installation, connection, downloads, and updates |
|
|
146
146
|
| [Browser Access](./docs/browser-access.md) | Web workbench authentication and deployment |
|
|
147
147
|
| [Slack Setup](./docs/slack-setup.md) | App creation, token collection, Socket Mode, scopes |
|
|
148
|
-
| [Configuration](./docs/configuration.md) | Full `.env` reference, `profiles.json`, file layout, hot-reload |
|
|
148
|
+
| [Configuration](./docs/configuration.md) | Full `.env` and `config/settings.json` reference, `profiles.json`, file layout, hot-reload |
|
|
149
149
|
| [CLI Reference](./docs/cli-reference.md) | `cortex`, `cortex-task`, `cortex-run` — every subcommand and flag |
|
|
150
150
|
| [Backends](./docs/backends.md) | Claude Code vs PI, feature matrix, fallback, cost reporting |
|
|
151
151
|
| [Architecture](./docs/architecture.md) | Server layers, WS protocol, event bus |
|
package/defaults/CORTEX.md
CHANGED
|
@@ -4,6 +4,7 @@ This is your Cortex data directory. Cortex is an autonomous agent system for lon
|
|
|
4
4
|
|
|
5
5
|
## Directory Structure
|
|
6
6
|
|
|
7
|
+
- `config/` — Shipped budgets, hooks, MCP isolation, and thread templates, including the hook-free benchmark coder-review roles
|
|
7
8
|
- `data/` — Persistent store for JSON state & config files
|
|
8
9
|
- `logs/` — Runtime logs
|
|
9
10
|
- `tmp/` — Workspace for thread artifacts and tool results
|
|
@@ -6,4 +6,5 @@ Shipped configuration scaffold for budgets, registry hooks, and thread templates
|
|
|
6
6
|
|---|---|---|
|
|
7
7
|
| budget.json | config | Seeds budget limits |
|
|
8
8
|
| hooks/ | subdir | Declares managed registry hooks |
|
|
9
|
-
|
|
|
9
|
+
| mcp-config-empty.json | config | Provides immutable strict empty MCP surface |
|
|
10
|
+
| thread-templates/ | subdir | Defines loops with reviewer-owned task completion |
|
|
@@ -16,3 +16,4 @@ Managed declarative hooks shipped into the user hook registry.
|
|
|
16
16
|
| 10-cortex-md-injector-session-start.json | context | Injects context at session start |
|
|
17
17
|
| 11-task-status-check.json | thread | Checks task state when dispatch threads end |
|
|
18
18
|
| 12-session-new-hook.json | session | Flushes memory before starting a new session |
|
|
19
|
+
| 13-status-md-guard.json | guard | Enforces STATUS.md register size caps |
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "benchmark-coder",
|
|
3
|
+
"description": "Benchmark Coder — implements a task directly in an isolated task workspace",
|
|
4
|
+
"profile": "__active__",
|
|
5
|
+
"persistSession": true,
|
|
6
|
+
"directive": "You are the benchmark coder. Work directly in the current task workspace, implement only the requested change, and verify the affected behavior with targeted checks. Do not assume the workspace is a git repository.",
|
|
7
|
+
"systemPrompt": "You are a code implementer operating in an isolated benchmark task workspace. Make the smallest correct change for the task and avoid unrelated refactors.",
|
|
8
|
+
"entryStage": "implement",
|
|
9
|
+
"stages": {
|
|
10
|
+
"implement": {
|
|
11
|
+
"description": "Inspect the task workspace, implement the requested change, and record a concise handoff.",
|
|
12
|
+
"promptTemplate": "Task:\n{{input}}\n\nInspect the current task workspace and implement the requested change. Run targeted verification for the affected behavior. Do not assume git, commits, or a repository-wide test command exists. When finished, append a concise implementation handoff to {{artifactPath}} for the reviewer. Do not write the reviewer approval token."
|
|
13
|
+
},
|
|
14
|
+
"retry": {
|
|
15
|
+
"description": "Address the first audit's blockers and record the revision.",
|
|
16
|
+
"continuesSession": true,
|
|
17
|
+
"promptTemplate": "Read the latest reviewer audit in {{artifactPath}}. Re-check each blocker against the current task workspace, fix only confirmed blockers, and run targeted verification for the revised behavior. Append a concise retry handoff to {{artifactPath}}. Do not write the reviewer approval token."
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"tools": "Bash,Read,Write,Edit,Glob,Grep,TodoWrite,Skill",
|
|
21
|
+
"mcpComposition": "none"
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "benchmark-reviewer",
|
|
3
|
+
"description": "Benchmark Reviewer — audits task-workspace changes without modifying them",
|
|
4
|
+
"profile": "__active__",
|
|
5
|
+
"persistSession": true,
|
|
6
|
+
"directive": "You are the benchmark reviewer. Independently inspect the current task workspace and verify the implementation without modifying project files. Report only evidence-backed blockers.",
|
|
7
|
+
"systemPrompt": "You are a read-only implementation auditor in an isolated benchmark task workspace. Inspect the implementation and run focused checks; write review findings only to the thread artifact.",
|
|
8
|
+
"entryStage": "audit",
|
|
9
|
+
"stages": {
|
|
10
|
+
"audit": {
|
|
11
|
+
"description": "Audit the first implementation and either approve it or identify blockers.",
|
|
12
|
+
"promptTemplate": "Original task:\n{{input}}\n\nRead {{artifactPath}}, inspect the current task workspace, and run targeted verification for the changed behavior. Do not modify any workspace file. The only file you may write is {{artifactPath}}. Append a concise implementation audit with evidence. If the implementation satisfies the task, end with `[IMPL-APPROVED]`. Otherwise list only actionable blockers and do not include the approval token anywhere."
|
|
13
|
+
},
|
|
14
|
+
"finalAudit": {
|
|
15
|
+
"description": "Audit the retry and provide the terminal review.",
|
|
16
|
+
"continuesSession": true,
|
|
17
|
+
"promptTemplate": "Read the retry handoff in {{artifactPath}}, inspect the current task workspace again, and run targeted verification for the revised behavior. Do not modify any workspace file. The only file you may write is {{artifactPath}}. Append a final audit with evidence. If the implementation now satisfies the task, end with `[IMPL-APPROVED]`. Otherwise list the remaining blockers without the approval token; this is the final audit."
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"tools": "Bash,Read,Write,Edit,Glob,Grep,TodoWrite,Skill",
|
|
21
|
+
"mcpComposition": "none"
|
|
22
|
+
}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coder-reviewer",
|
|
3
|
-
"description": "Coder Reviewer —
|
|
3
|
+
"description": "Coder Reviewer — runs the `implReview` stage of the coder-review template, auditing Coder's implementation and landing the fixes for the Blockers it finds",
|
|
4
4
|
"profile": "execute",
|
|
5
5
|
"persistSession": true,
|
|
6
6
|
"directive": "file:coder-reviewer.md",
|
|
7
7
|
"systemPrompt": "file:coder.md",
|
|
8
|
-
"entryStage": "
|
|
8
|
+
"entryStage": "implReview",
|
|
9
9
|
"stages": {
|
|
10
|
-
"planReview": {
|
|
11
|
-
"description": "Read `## Plan` and append `## Plan Review (iteration N)` — no approval marker here.",
|
|
12
|
-
"promptTemplate": "Task:\n{{input}}\n\nRead {{artifactPath}} end-to-end and review the latest `## Plan (iteration N)` section. Confirm Coder only touched the artifact file (no premature implementation). Append `## Plan Review (iteration N)` to {{artifactPath}}. Do NOT write any approval marker in Plan Review — Coder decides per-Blocker what to accept/reject."
|
|
13
|
-
},
|
|
14
10
|
"implReview": {
|
|
15
|
-
"description": "
|
|
16
|
-
"
|
|
17
|
-
"promptTemplate": "Original task:\n{{input}}\n\nAudit Coder's project-file changes (changes by other agents in the same files may appear — ignore those):\n{{modifiedFiles}}\n\nRead the latest `## Implementation Summary (iteration M)` in {{artifactPath}} (and the following `## Response to Impl Review` if present). Append `## Impl Review (iteration M)` to {{artifactPath}}. **Remember: you MUST write your review to {{artifactPath}}.** If approved, end with `[IMPL-APPROVED]`; otherwise list the Blockers. Coder gets only 1 retry after the first block; beyond that the pipeline ends. Do not fabricate approval markers.\n\nBefore writing your review, run the project's full test suite (`npm test` or equivalent). Check that every stage passes: architecture linter, unit tests, integration tests. Any failure is a Blocker — do not write [IMPL-APPROVED] until the full suite is green."
|
|
11
|
+
"description": "Audit `## Implementation Summary` + diff, fix every Blocker, and append `## Impl Review`.",
|
|
12
|
+
"promptTemplate": "Original task:\n{{input}}\n\nAudit Coder's project-file changes (changes by other agents in the same files may appear — ignore those):\n{{modifiedFiles}}\n\nRead the `## Implementation Summary` in {{artifactPath}} and audit the implementation against the task. Run the project's full test suite (`npm test` or equivalent) yourself and check that every stage passes: architecture linter, unit tests, integration tests.\n\nYou are the last step of this pipeline — fix every Blocker you find rather than returning it. Re-verify each Blocker against its cited source first, keep the fix minimal and scoped to that Blocker, cover it with a test where the project allows, re-run the suite, and commit. Then append `## Impl Review` to {{artifactPath}}, listing each issue with its citation, severity, and disposition: fixed (with the fixing commit's short SHA) or left open (with the reason). **Remember: you MUST write your review to {{artifactPath}}.** Task lifecycle ownership in `coder-review`: when `CORTEX_TASK_ID` is set, you alone own the task's final lifecycle transition. After all fixes are committed, the review is written, and verification passes, verify every `done_when` condition from the original task. If all are satisfied, run the exact `cortex-task complete` command from the original task's `## When Done` section with a note citing the review and verification evidence. Never complete the task while any Blocker remains open; use the original task's block or unclaim instructions instead."
|
|
18
13
|
}
|
|
19
14
|
},
|
|
20
15
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coder",
|
|
3
|
-
"description": "Coder — code implementation executor.
|
|
3
|
+
"description": "Coder — code implementation executor. Runs the `implement` stage of the coder-review template, implementing the task directly from the task description",
|
|
4
4
|
"profile": "plan",
|
|
5
5
|
"persistSession": true,
|
|
6
6
|
"directive": "file:coder.md",
|
|
7
7
|
"systemPrompt": "file:coder.md",
|
|
8
|
-
"entryStage": "
|
|
8
|
+
"entryStage": "implement",
|
|
9
9
|
"stages": {
|
|
10
|
-
"plan": {
|
|
11
|
-
"description": "Draft the implementation plan under `## Plan (iteration 1)`.",
|
|
12
|
-
"promptTemplate": "Task:\n{{input}}\n\nDraft your implementation plan under a new `## Plan (iteration 1)` section into {{artifactPath}}. You MUST DO NOT implement yet. JUST WRITE THE PLAN."
|
|
13
|
-
},
|
|
14
10
|
"implement": {
|
|
15
|
-
"description": "
|
|
16
|
-
"
|
|
17
|
-
"promptTemplate": "Begin implementation. When done, append `## Implementation Summary (iteration 1)` to the end of the artifact, listing changed files, commit short-SHAs, flagged ambiguities, env changes, and accept/reject with rationale for each plan-review item. Do NOT write `[IMPL-APPROVED]` — only the reviewer writes that. After committing, run the full test suite (`npm test` or equivalent) and confirm every stage passes before writing your summary."
|
|
18
|
-
},
|
|
19
|
-
"retry": {
|
|
20
|
-
"description": "After a blocking `## Impl Review`: fix and append `## Implementation Summary (iteration 2)` + `[REVISED]`.",
|
|
21
|
-
"continuesSession": true,
|
|
22
|
-
"promptTemplate": "The latest `## Impl Review` did not provide `[IMPL-APPROVED]`. Re-verify each Blocker against its cited source, then fix the code per the feedback. When finished revising, MUST write `[REVISED]` to {{artifactPath}} on its own line."
|
|
11
|
+
"description": "Implement the task and append `## Implementation Summary`.",
|
|
12
|
+
"promptTemplate": "Task:\n{{input}}\n\nImplement this task. When done, append `## Implementation Summary` to {{artifactPath}}, listing changed files, commit short-SHAs, flagged ambiguities, and env changes. After committing, run the full test suite (`npm test` or equivalent) and confirm every stage passes before writing your summary. Task lifecycle ownership in `coder-review`: when `CORTEX_TASK_ID` is set, do not run `cortex-task complete` or otherwise mark the owning task done. The final reviewer owns the task's completion after independent verification; leave it claimed and hand off through the artifact."
|
|
23
13
|
}
|
|
24
14
|
},
|
|
25
15
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "benchmark-coder-review",
|
|
3
|
+
"description": "Hook-free benchmark loop: coder implement, reviewer audit, one conditional coder retry, and reviewer final audit",
|
|
4
|
+
"agents": [
|
|
5
|
+
"benchmark-coder",
|
|
6
|
+
"benchmark-reviewer"
|
|
7
|
+
],
|
|
8
|
+
"transitions": [
|
|
9
|
+
{
|
|
10
|
+
"from": "benchmark-coder:implement",
|
|
11
|
+
"to": "benchmark-reviewer:audit",
|
|
12
|
+
"condition": {
|
|
13
|
+
"type": "always"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"from": "benchmark-reviewer:audit",
|
|
18
|
+
"to": "benchmark-coder:retry",
|
|
19
|
+
"condition": {
|
|
20
|
+
"type": "convergence",
|
|
21
|
+
"marker": "[IMPL-APPROVED]",
|
|
22
|
+
"maxIterations": 1
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"from": "benchmark-coder:retry",
|
|
27
|
+
"to": "benchmark-reviewer:finalAudit",
|
|
28
|
+
"condition": {
|
|
29
|
+
"type": "always"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"entryAgent": "benchmark-coder",
|
|
34
|
+
"entryStage": "implement",
|
|
35
|
+
"maxTotalSteps": 4,
|
|
36
|
+
"disableHooks": true
|
|
37
|
+
}
|
|
@@ -1,46 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coder-review",
|
|
3
|
-
"description": "Stage-driven coder loop: coder(
|
|
3
|
+
"description": "Stage-driven coder loop: coder(implement) → coder-reviewer(implReview) → END. Coder implements the task directly; the reviewer audits the result and lands the fixes for what it finds. Each stage's prompt is selected by the transition graph in thread-engine.",
|
|
4
4
|
"agents": [
|
|
5
5
|
"coder",
|
|
6
6
|
"coder-reviewer"
|
|
7
7
|
],
|
|
8
8
|
"transitions": [
|
|
9
|
-
{
|
|
10
|
-
"from": "coder:plan",
|
|
11
|
-
"to": "coder:implement",
|
|
12
|
-
"condition": {
|
|
13
|
-
"type": "always"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
9
|
{
|
|
17
10
|
"from": "coder:implement",
|
|
18
11
|
"to": "coder-reviewer:implReview",
|
|
19
12
|
"condition": {
|
|
20
13
|
"type": "always"
|
|
21
14
|
}
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"from": "coder-reviewer:implReview",
|
|
25
|
-
"to": "coder:retry",
|
|
26
|
-
"condition": {
|
|
27
|
-
"type": "convergence",
|
|
28
|
-
"marker": "[IMPL-APPROVED]",
|
|
29
|
-
"maxIterations": 1
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"from": "coder:retry",
|
|
34
|
-
"to": "coder-reviewer:implReview",
|
|
35
|
-
"condition": {
|
|
36
|
-
"type": "output_not_contains",
|
|
37
|
-
"pattern": "\\[REVISED\\]"
|
|
38
|
-
}
|
|
39
15
|
}
|
|
40
16
|
],
|
|
41
17
|
"entryAgent": "coder",
|
|
42
|
-
"entryStage": "
|
|
43
|
-
"maxTotalSteps":
|
|
18
|
+
"entryStage": "implement",
|
|
19
|
+
"maxTotalSteps": 4,
|
|
44
20
|
"hooks": {
|
|
45
21
|
"onEnd": {
|
|
46
22
|
"command": "node ~/.cortex/hooks/post-task-hook.mjs",
|
|
@@ -13,7 +13,7 @@ One subdirectory per active project.
|
|
|
13
13
|
| File | Type | Purpose |
|
|
14
14
|
|------|------|---------|
|
|
15
15
|
| `TASKS.yaml` | Append + in-place edit | Structured task queue, machine-readable. New tasks appended, tags/completion status edited in-place (use `cortex-task` CLI, do not manually edit) |
|
|
16
|
-
| `STATUS.md` | Overwrite |
|
|
16
|
+
| `STATUS.md` | Overwrite | Present-tense state register: overwritten when the project situation changes (hard cap 80 lines AND 6KB; see rules/status-md.md) |
|
|
17
17
|
| `ISSUES.md` | Append | Record issues affecting work efficiency |
|
|
18
18
|
| `experiments/` | Atomic file | One `.md` file per experiment (YAML frontmatter + body), `index.md` auto-generated |
|
|
19
19
|
| `knowledge/` | Atomic file | One `.md` file per knowledge entry, `index.md` auto-generated |
|
|
@@ -47,6 +47,18 @@
|
|
|
47
47
|
"target": { "kind": "fresh" },
|
|
48
48
|
"isPaused": false,
|
|
49
49
|
"createdAt": 0
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "seed0005",
|
|
53
|
+
"type": "daily",
|
|
54
|
+
"time": "08:30",
|
|
55
|
+
"dispatchType": "auth-expiry-scan",
|
|
56
|
+
"message": "Daily auth expiry scan at 08:30 local time: warn before daytime use while avoiding midnight maintenance activity.",
|
|
57
|
+
"channel": "__ADMIN_CHANNEL__",
|
|
58
|
+
"profile": null,
|
|
59
|
+
"target": { "kind": "fresh" },
|
|
60
|
+
"isPaused": false,
|
|
61
|
+
"createdAt": 0
|
|
50
62
|
}
|
|
51
63
|
]
|
|
52
64
|
}
|
package/defaults/hooks/CORTEX.md
CHANGED
|
@@ -14,5 +14,6 @@ Managed hook scripts deployed into the runtime hook directory.
|
|
|
14
14
|
| rules-loader.mjs | loader | Loads matching rules after file reads |
|
|
15
15
|
| sensitive-file-edit.mjs | guard | Handles protected configuration edits |
|
|
16
16
|
| session-activity-tracker.mjs | tracker | Records session tool activity |
|
|
17
|
+
| status-md-guard.mjs | guard | Enforces STATUS.md register size caps |
|
|
17
18
|
| task-status-check.mjs | thread | Checks dispatched task state at thread end |
|
|
18
19
|
| tasks-yaml-guard.mjs | guard | Protects task queue edits |
|
|
@@ -49,13 +49,13 @@ Did this session produce findings, decisions, or changes that future sessions ne
|
|
|
49
49
|
Examples of what to record:
|
|
50
50
|
- A new experiment was launched → update STATUS.md with what's running
|
|
51
51
|
- A non-obvious fact was discovered ("the dataset is on gpu-server at /data/xxx") → create a K-NNN.md entry so it's indexed
|
|
52
|
-
- External resource locations → "The paper source is at ~/papers/conference2026/", "Training data lives on gpu-server:/datasets/dataset-v3/", "Reference implementation at https://github.com/xxx/yyy" — record
|
|
52
|
+
- External resource locations → "The paper source is at ~/papers/conference2026/", "Training data lives on gpu-server:/datasets/dataset-v3/", "Reference implementation at https://github.com/xxx/yyy" — record as a knowledge entry (K-NNN); durable facts do not go in STATUS.md
|
|
53
53
|
- A recurring friction was encountered ("the GPU on local always OOMs with batch_size > 32") → append to ISSUES.md
|
|
54
54
|
- A design decision was made → add to decisions/ directory
|
|
55
55
|
- A new project dependency or constraint was discovered → update STATUS.md
|
|
56
56
|
|
|
57
57
|
File update rules you MUST respect:
|
|
58
|
-
- **STATUS.md** —
|
|
58
|
+
- **STATUS.md** — state register (hard cap 80 lines AND 6KB): replace stale lines with the latest state, never append; one line + pointer per change, details live in EXP/K/tasks-archive; adding a line requires checking which old lines expired
|
|
59
59
|
- **ISSUES.md** — append mode: add new entries at the end, keep history
|
|
60
60
|
- **knowledge/K-NNN.md** — atomic: one file per knowledge entry, with YAML frontmatter
|
|
61
61
|
- **knowledge/index.md, experiments/index.md, patterns/index.md** — AUTO-GENERATED, do NOT edit manually
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @cortex-hook-version 2026.8.2
|
|
3
|
+
// input: stdin JSON — Claude Code PreToolUse event payload
|
|
4
|
+
// output: stdout JSON — { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision, permissionDecisionReason }, systemMessage? }
|
|
5
|
+
// pos: PreToolUse hook — intercepts Edit/Write on size-capped context files and
|
|
6
|
+
// enforces their caps (limit table below; rules/status-md.md, rules/issues-md.md,
|
|
7
|
+
// rules/cortex-md.md): deny writes whose result exceeds the caps, unless the
|
|
8
|
+
// write shrinks an already-over-limit file (so cleanup stays possible); warn
|
|
9
|
+
// when approaching the cap. Guarded files:
|
|
10
|
+
// context/projects/<p>/STATUS.md — 80 lines / 6KB (state register)
|
|
11
|
+
// context/projects/<p>/ISSUES.md — 80 lines / 6KB (friction log)
|
|
12
|
+
// CORTEX.md anywhere under a context/ tree — 120 lines / 8KB (injected index)
|
|
13
|
+
// >>> If I am updated, be sure to update my header comment and the CORTEX.md in the same folder <<<
|
|
14
|
+
|
|
15
|
+
import { readFileSync, existsSync } from 'fs';
|
|
16
|
+
import { resolve, sep } from 'path';
|
|
17
|
+
|
|
18
|
+
// ── Constants ──
|
|
19
|
+
|
|
20
|
+
const TOOLS = new Set(['Edit', 'Write']);
|
|
21
|
+
|
|
22
|
+
/** .../context/projects/<name>/<file> */
|
|
23
|
+
function isProjectRootFile(parts, fileName) {
|
|
24
|
+
if (parts[parts.length - 1] !== fileName) return false;
|
|
25
|
+
const projectsIdx = parts.length - 3;
|
|
26
|
+
const contextIdx = parts.length - 4;
|
|
27
|
+
return projectsIdx > 0 && parts[projectsIdx] === 'projects' && parts[contextIdx] === 'context';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const LIMIT_RULES = [
|
|
31
|
+
{
|
|
32
|
+
name: 'STATUS.md',
|
|
33
|
+
ruleFile: 'rules/status-md.md',
|
|
34
|
+
matches: (parts) => isProjectRootFile(parts, 'STATUS.md'),
|
|
35
|
+
maxLines: 80,
|
|
36
|
+
maxBytes: 6 * 1024,
|
|
37
|
+
warnLines: 60,
|
|
38
|
+
warnBytes: 4 * 1024,
|
|
39
|
+
capLabel: '80 lines AND 6KB',
|
|
40
|
+
trimAdvice: [
|
|
41
|
+
'STATUS is a state register, not a changelog. Trim before writing:',
|
|
42
|
+
'- delete entries that no longer affect decisions (their content already lives in tasks-archive / git / EXP records),',
|
|
43
|
+
'- compress each bullet to one line + pointer (task-id / EXP-NNN / K-NNN / DR-NNNN / commit SHA),',
|
|
44
|
+
'- move completion reports to the task note, durable facts to knowledge entries, verdict analysis to the gate artifact.',
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'ISSUES.md',
|
|
49
|
+
ruleFile: 'rules/issues-md.md',
|
|
50
|
+
matches: (parts) => isProjectRootFile(parts, 'ISSUES.md'),
|
|
51
|
+
maxLines: 80,
|
|
52
|
+
maxBytes: 6 * 1024,
|
|
53
|
+
warnLines: 60,
|
|
54
|
+
warnBytes: 4 * 1024,
|
|
55
|
+
capLabel: '80 lines AND 6KB',
|
|
56
|
+
trimAdvice: [
|
|
57
|
+
'ISSUES.md is a friction log with <=4-line entries. Trim before writing:',
|
|
58
|
+
'- delete resolved entries outright (no changelog),',
|
|
59
|
+
'- compress each entry to symptom + one-line root cause + pointer (K-NNN / task artifact / EXP-NNN / file:line),',
|
|
60
|
+
'- merge same-cause frictions into one entry.',
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'CORTEX.md',
|
|
65
|
+
ruleFile: 'rules/cortex-md.md',
|
|
66
|
+
matches: (parts) => parts[parts.length - 1] === 'CORTEX.md' && parts.includes('context'),
|
|
67
|
+
maxLines: 120,
|
|
68
|
+
maxBytes: 8 * 1024,
|
|
69
|
+
warnLines: 90,
|
|
70
|
+
warnBytes: 6656,
|
|
71
|
+
capLabel: '120 lines AND 8KB',
|
|
72
|
+
trimAdvice: [
|
|
73
|
+
'CORTEX.md is an injected index (truncated at 9500 chars): it answers "what is here, where to look", not the content itself. Trim before writing:',
|
|
74
|
+
'- collapse atomic directories (experiments/ knowledge/ patterns/ decisions/) to one line each pointing at their index.md,',
|
|
75
|
+
'- entry summaries already live in the atomic files and their auto-generated index.md — never duplicate them here,',
|
|
76
|
+
'- keep each index line to one sentence + pointer (<=200 chars).',
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
// ── Helpers ──
|
|
82
|
+
|
|
83
|
+
function countLines(content) {
|
|
84
|
+
if (content === '') return 0;
|
|
85
|
+
const chunks = content.split('\n');
|
|
86
|
+
return chunks[chunks.length - 1] === '' ? chunks.length - 1 : chunks.length;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Compute the content the tool call would leave on disk, or null when indeterminable. */
|
|
90
|
+
function proposedContent(toolName, toolInput, currentContent) {
|
|
91
|
+
if (toolName === 'Write') return typeof toolInput.content === 'string' ? toolInput.content : null;
|
|
92
|
+
// Edit
|
|
93
|
+
const oldString = toolInput.old_string;
|
|
94
|
+
const newString = toolInput.new_string;
|
|
95
|
+
if (typeof oldString !== 'string' || typeof newString !== 'string') return null;
|
|
96
|
+
if (currentContent === null || !currentContent.includes(oldString)) return null; // tool will fail on its own
|
|
97
|
+
return toolInput.replace_all
|
|
98
|
+
? currentContent.split(oldString).join(newString)
|
|
99
|
+
: currentContent.replace(oldString, newString);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function denyReason(rule, lineCount, byteCount) {
|
|
103
|
+
return [
|
|
104
|
+
`${rule.name} write rejected: the result would be ${lineCount} lines / ${byteCount} bytes — the hard cap is ${rule.capLabel} (${rule.ruleFile}).`,
|
|
105
|
+
'',
|
|
106
|
+
...rule.trimAdvice,
|
|
107
|
+
'',
|
|
108
|
+
'Writes that shrink an already-over-limit file are allowed — reduce the size, then write.',
|
|
109
|
+
].join('\n');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ── Main ──
|
|
113
|
+
|
|
114
|
+
function main() {
|
|
115
|
+
let input = '';
|
|
116
|
+
try {
|
|
117
|
+
input = readFileSync(0, 'utf8');
|
|
118
|
+
} catch {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!input.trim()) return;
|
|
122
|
+
|
|
123
|
+
let payload;
|
|
124
|
+
try {
|
|
125
|
+
payload = JSON.parse(input);
|
|
126
|
+
} catch {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!TOOLS.has(payload.tool_name)) return;
|
|
131
|
+
|
|
132
|
+
const toolInput = payload.tool_input || {};
|
|
133
|
+
const filePath = toolInput.file_path || '';
|
|
134
|
+
if (!filePath) return;
|
|
135
|
+
|
|
136
|
+
const cwd = payload.cwd || process.cwd();
|
|
137
|
+
const parts = resolve(cwd, filePath).split(sep);
|
|
138
|
+
const rule = LIMIT_RULES.find((r) => r.matches(parts));
|
|
139
|
+
if (!rule) return;
|
|
140
|
+
|
|
141
|
+
const absPath = resolve(cwd, filePath);
|
|
142
|
+
let currentContent = null;
|
|
143
|
+
if (existsSync(absPath)) {
|
|
144
|
+
try {
|
|
145
|
+
currentContent = readFileSync(absPath, 'utf8');
|
|
146
|
+
} catch {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const proposed = proposedContent(payload.tool_name, toolInput, currentContent);
|
|
152
|
+
if (proposed === null) return;
|
|
153
|
+
|
|
154
|
+
const lineCount = countLines(proposed);
|
|
155
|
+
const byteCount = Buffer.byteLength(proposed, 'utf8');
|
|
156
|
+
const currentBytes = currentContent === null ? null : Buffer.byteLength(currentContent, 'utf8');
|
|
157
|
+
|
|
158
|
+
if (lineCount > rule.maxLines || byteCount > rule.maxBytes) {
|
|
159
|
+
// Shrink exception: an over-limit file may be reduced step by step.
|
|
160
|
+
if (currentBytes !== null && byteCount < currentBytes) {
|
|
161
|
+
process.stdout.write(JSON.stringify({
|
|
162
|
+
hookSpecificOutput: {
|
|
163
|
+
hookEventName: 'PreToolUse',
|
|
164
|
+
permissionDecision: 'allow',
|
|
165
|
+
permissionDecisionReason: `Still over the ${rule.name} cap (${lineCount} lines / ${byteCount} bytes > ${rule.capLabel}) but shrinking — keep trimming to within the limit.`,
|
|
166
|
+
},
|
|
167
|
+
systemMessage: `${rule.name} is still over the ${rule.capLabel} cap (${lineCount} lines / ${byteCount} bytes). This write shrinks it and is allowed — keep trimming.`,
|
|
168
|
+
}));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
process.stdout.write(JSON.stringify({
|
|
172
|
+
hookSpecificOutput: {
|
|
173
|
+
hookEventName: 'PreToolUse',
|
|
174
|
+
permissionDecision: 'deny',
|
|
175
|
+
permissionDecisionReason: denyReason(rule, lineCount, byteCount),
|
|
176
|
+
},
|
|
177
|
+
}));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (lineCount >= rule.warnLines || byteCount >= rule.warnBytes) {
|
|
182
|
+
process.stdout.write(JSON.stringify({
|
|
183
|
+
hookSpecificOutput: {
|
|
184
|
+
hookEventName: 'PreToolUse',
|
|
185
|
+
permissionDecision: 'allow',
|
|
186
|
+
permissionDecisionReason: `${rule.name} approaching its cap (${lineCount} lines / ${byteCount} bytes; hard cap ${rule.capLabel}) — trim proactively.`,
|
|
187
|
+
},
|
|
188
|
+
systemMessage: `${rule.name} is approaching its cap (${lineCount} lines / ${byteCount} bytes; hard cap ${rule.capLabel}). Trim proactively (${rule.ruleFile}).`,
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
main();
|
|
@@ -40,6 +40,32 @@ Wrote code before writing a test? Delete the code. Write the test. Watch it fail
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
+
## What to Test — and What Not To
|
|
44
|
+
|
|
45
|
+
TDD mandates a failing test first; this section governs which tests are worth writing at all. A test earns its place by being able to fail on a real bug: **if you cannot name the bug that would make it fail, do not write it.**
|
|
46
|
+
|
|
47
|
+
Test these (behavior the suite must own):
|
|
48
|
+
- Behavior contracts at module boundaries: inputs → outputs/effects.
|
|
49
|
+
- State machines and lifecycle transitions, including illegal-transition rejections.
|
|
50
|
+
- Persistence and concurrency: atomic writes, mutex serialization, recovery paths.
|
|
51
|
+
- Protocol/format translation: adapter normalization, parsers, serializers.
|
|
52
|
+
- Error paths that guard real regressions.
|
|
53
|
+
- Anything that runs unattended.
|
|
54
|
+
|
|
55
|
+
Do NOT write:
|
|
56
|
+
- Assertions restating constants or config literals back at themselves. If the shape is the contract, collapse to one whole-object equality.
|
|
57
|
+
- Verbatim help/usage text matching — test routing and exit codes instead.
|
|
58
|
+
- Tests of a test double's trivial surface, or of third-party library behavior.
|
|
59
|
+
- Higher-layer re-assertions of values a lower layer already pins (a view re-asserting vm output; a CLI re-proving the mutator's semantics). The higher layer tests only what it adds: argv parsing, exit codes, routing, render slots — plus ONE thin wiring round-trip.
|
|
60
|
+
- Local re-implementations of production logic asserted against themselves — such tests cannot fail.
|
|
61
|
+
|
|
62
|
+
Placement and cost discipline:
|
|
63
|
+
- One behavior, one test, at the lowest layer that owns the logic.
|
|
64
|
+
- Extend the module's existing test file; a new file is for a new module.
|
|
65
|
+
- Prefer fake timers or bounded polls on observable state over fixed real sleeps; never bind fixed ports; a per-test mkdtemp is fine, but do not spawn subprocesses or listeners when a direct call exercises the same contract.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
43
69
|
## Mode: Feature
|
|
44
70
|
|
|
45
71
|
### Step 1: Understand
|
|
@@ -74,7 +100,7 @@ Wrote code before writing a test? Delete the code. Write the test. Watch it fail
|
|
|
74
100
|
|
|
75
101
|
### Step 5: Document
|
|
76
102
|
|
|
77
|
-
1. If the change
|
|
103
|
+
1. If the change altered the project's situation (unblocked something, introduced a blocker, changed the next step), update the relevant STATUS.md register — one line + pointer, not a change note.
|
|
78
104
|
2. If a design decision was made, check whether a Decision Record is warranted.
|
|
79
105
|
3. If you modified a convention or rule that appears in multiple documents, propagate the change.
|
|
80
106
|
|
|
@@ -173,7 +199,7 @@ When implementing against a specification (an experiment protocol or a scoped ta
|
|
|
173
199
|
|
|
174
200
|
### Commit & handoff
|
|
175
201
|
- Commit **before** handing off (before downstream execution, before review, before the thread hands back). The SHA anchors the delivered code.
|
|
176
|
-
-
|
|
202
|
+
- Task/spec identifiers belong in commit subjects only when repository policy permits. Repository-local privacy rules take precedence; omission required by such a rule is compliant, and attribution must instead use the implementation SHA in the summary/artifact.
|
|
177
203
|
- Do not amend or force-push shared branches without explicit user authorization; do not bypass pre-commit hooks (`--no-verify`); do not hardcode secrets in committed files.
|
|
178
204
|
- Produce an implementation summary: changed files, commit SHAs, flagged ambiguities, environment changes, and test-suite pass/fail status.
|
|
179
205
|
|
|
@@ -146,7 +146,7 @@ Scan active project `experiments/index.md` for unresolved questions:
|
|
|
146
146
|
| Untestable hypothesis | "cannot be tested", "future work" | "Under what conditions does H hold?" |
|
|
147
147
|
| Methodology confound | "asymmetric setup", "confound" | "How to disentangle X from Y?" |
|
|
148
148
|
|
|
149
|
-
Also check STATUS.md for unresolved
|
|
149
|
+
Also check STATUS.md's Next Step / Blockers & Pending Decisions sections for unresolved items that imply investigation needs. Generate follow-up tasks in TASKS.yaml if none exist for identified questions.
|
|
150
150
|
|
|
151
151
|
**Part B: Parameter-tuning pattern detection**
|
|
152
152
|
|
|
@@ -46,7 +46,7 @@ Answer each question. If yes, note what to update:
|
|
|
46
46
|
→ Note the technique for potential reuse
|
|
47
47
|
|
|
48
48
|
3. **Workaround worth noting?** (non-obvious trick, configuration quirk)
|
|
49
|
-
→ Add to
|
|
49
|
+
→ Add to task note; promote to a knowledge entry (K-NNN) if reusable — not STATUS.md
|
|
50
50
|
|
|
51
51
|
4. **Task description miss something?** (prerequisite not listed, scope underestimated)
|
|
52
52
|
→ Note for future task writing improvement
|
|
@@ -66,11 +66,13 @@ If you completed an experiment/analysis, scan results for:
|
|
|
66
66
|
|
|
67
67
|
### Step 4: Act on findings
|
|
68
68
|
|
|
69
|
+
For task creation, use the Write tool to stage a JSON object at a per-session unique path and run `cortex-task add --task-file <unique-path>`; never use a shared staging filename or place task text, why, or done-when in shell arguments.
|
|
70
|
+
|
|
69
71
|
For each compound opportunity:
|
|
70
72
|
|
|
71
73
|
| Type | Action |
|
|
72
74
|
|------|--------|
|
|
73
|
-
| Small update (1-3 lines) | Apply directly to file (
|
|
75
|
+
| Small update (1-3 lines) | Apply directly to file (task note, ISSUES.md; STATUS.md only if the project situation changed — replace stale lines, never append) |
|
|
74
76
|
| Larger change | Create task in TASKS.md with provenance |
|
|
75
77
|
| Process improvement | Note in task completion output for orchestrator |
|
|
76
78
|
|
|
@@ -73,7 +73,7 @@ If the failure mode involves model capability limitations (ungrounded generation
|
|
|
73
73
|
|
|
74
74
|
1. As a new knowledge entry (knowledge/K-NNN.md) in the relevant project
|
|
75
75
|
2. In the postmortem itself with evidence and mitigation
|
|
76
|
-
3. In the relevant project's STATUS.md
|
|
76
|
+
3. In the relevant project's STATUS.md under Blockers & Pending Decisions — one line + pointer to the K-entry, and only if it constrains current work
|
|
77
77
|
|
|
78
78
|
Skip this step only if the root cause is entirely at non-model layers.
|
|
79
79
|
|
|
@@ -44,7 +44,7 @@ Progress is not completion. Completion is defined only by the criteria declared
|
|
|
44
44
|
3. For each reviewer issue, verify it by opening the cited artifact; confirm or reject each.
|
|
45
45
|
4. Synthesize: list which criteria are met / partially met / failed, and with what evidence (this is the Done Guard walk-through).
|
|
46
46
|
5. Choose exactly one verdict. Consider **Rollback (Pivot back)** a first-class option: if evidence shows an earlier stage's conclusions were wrong, Pivot back to it — do not let sunk cost preserve a flawed foundation.
|
|
47
|
-
6. Write the artifact (prose-first, citations embedded),
|
|
47
|
+
6. Write the artifact (prose-first, citations embedded), replace STATUS.md's gate pointer line (`Milestone <N> gate (<date>): <verdict> → <artifact path>`), exit. The verdict and analysis live only in the artifact; STATUS.md carries nothing but the matching pointer line.
|
|
48
48
|
|
|
49
49
|
## Drift patterns to avoid
|
|
50
50
|
|