@cortex-agent/server 2026.5.19-3 → 2026.5.22
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 +5 -1
- package/defaults/config/thread-templates.json +65 -39
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +4 -4
- package/defaults/prompts/directives/coder-reviewer.md +9 -4
- package/defaults/prompts/directives/coder.md +10 -2
- package/dist/core/log.js +61 -12
- package/dist/core/status-format.js +1 -1
- package/dist/core/task-parser.d.ts +1 -1
- package/dist/core/task-parser.js +13 -6
- package/dist/core/types/thread-types.d.ts +4 -2
- package/dist/domain/costs/codex-usage-monitor.d.ts +1 -2
- package/dist/domain/costs/codex-usage-monitor.js +2 -2
- package/dist/domain/costs/cost-tracker.d.ts +2 -0
- package/dist/domain/costs/cost-tracker.js +4 -20
- package/dist/domain/costs/rate-limit-throttle.js +1 -4
- package/dist/domain/mcp/tools/context.d.ts +4 -2
- package/dist/domain/mcp/tools/context.js +7 -5
- package/dist/domain/mcp/tools/schedule.d.ts +1 -1
- package/dist/domain/mcp/tools/schedule.js +24 -20
- package/dist/domain/memory/index-regen.js +8 -5
- package/dist/domain/monitor/disk-monitor.js +1 -6
- package/dist/domain/projects/index.d.ts +2 -0
- package/dist/domain/projects/index.js +3 -0
- package/dist/domain/projects/project-store.d.ts +54 -0
- package/dist/domain/projects/project-store.js +194 -0
- package/dist/domain/projects/project-types.d.ts +11 -0
- package/dist/domain/projects/project-types.js +5 -0
- package/dist/domain/remote/client-hot-reload.d.ts +1 -0
- package/dist/domain/remote/client-hot-reload.js +284 -53
- package/dist/domain/scheduling/jobs/_shared.d.ts +1 -1
- package/dist/domain/scheduling/jobs/_shared.js +6 -5
- package/dist/domain/scheduling/jobs/memory-index-regen.js +2 -2
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +2 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +38 -36
- package/dist/domain/scheduling/jobs/sync-public.d.ts +1 -0
- package/dist/domain/scheduling/jobs/sync-public.js +34 -0
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +3 -7
- package/dist/domain/scheduling/jobs/target-dispatch.js +7 -9
- package/dist/domain/scheduling/jobs/task-archive.js +2 -2
- package/dist/domain/scheduling/jobs/task-dispatch.js +18 -16
- package/dist/domain/scheduling/runner.d.ts +1 -0
- package/dist/domain/scheduling/runner.js +2 -0
- package/dist/domain/scheduling/schedule-cli.d.ts +1 -0
- package/dist/domain/scheduling/schedule-cli.js +14 -14
- package/dist/domain/scheduling/schedule-command.js +45 -36
- package/dist/domain/scheduling/scheduler.d.ts +1 -1
- package/dist/domain/scheduling/scheduler.js +12 -11
- package/dist/domain/sessions/session-hooks.d.ts +10 -11
- package/dist/domain/sessions/session-hooks.js +26 -27
- package/dist/domain/sessions/session-registry.d.ts +10 -5
- package/dist/domain/sessions/session-registry.js +24 -9
- package/dist/domain/tasks/pending-tracker.js +8 -9
- package/dist/domain/tasks/system/task-cli.d.ts +2 -0
- package/dist/domain/tasks/system/task-cli.js +189 -29
- package/dist/domain/tasks/system/task-lifecycle-edit.js +3 -3
- package/dist/domain/threads/hook-runner.js +12 -7
- package/dist/domain/threads/runner.d.ts +3 -3
- package/dist/domain/threads/runner.js +30 -28
- package/dist/domain/threads/state-machine.d.ts +3 -0
- package/dist/domain/threads/state-machine.js +4 -0
- package/dist/entry/app.js +30 -9
- package/dist/entry/cli.js +19 -4
- package/dist/entry/daemon.js +28 -2
- package/dist/entry/startup-notify.js +8 -6
- package/dist/orchestration/agent-runner.js +19 -13
- package/dist/orchestration/durable-helpers.js +3 -2
- package/dist/orchestration/interactions/ask-user-question.d.ts +2 -3
- package/dist/orchestration/interactions/ask-user-question.js +5 -4
- package/dist/orchestration/interactions/interaction-handlers.js +8 -5
- package/dist/orchestration/interactions/plan-handler.js +3 -3
- package/dist/orchestration/lifecycle.js +43 -38
- package/dist/orchestration/routing/commands/cancel.js +9 -8
- package/dist/orchestration/routing/commands/channel.js +32 -26
- package/dist/orchestration/routing/commands/cost.js +5 -3
- package/dist/orchestration/routing/commands/device.js +2 -1
- package/dist/orchestration/routing/commands/dispatch.js +8 -7
- package/dist/orchestration/routing/commands/index.js +7 -4
- package/dist/orchestration/routing/commands/mode.js +24 -18
- package/dist/orchestration/routing/commands/nvtop.js +14 -12
- package/dist/orchestration/routing/commands/orient.js +2 -1
- package/dist/orchestration/routing/commands/schedule.js +2 -1
- package/dist/orchestration/routing/commands/sendfile.js +12 -9
- package/dist/orchestration/routing/commands/session.js +12 -10
- package/dist/orchestration/routing/commands/status.js +2 -2
- package/dist/orchestration/routing/commands/tail.js +10 -6
- package/dist/orchestration/routing/commands/task.js +5 -4
- package/dist/orchestration/routing/commands/thread-handlers.js +19 -12
- package/dist/orchestration/routing/hook-bridge-subscribers.js +15 -13
- package/dist/orchestration/status-helpers.d.ts +4 -5
- package/dist/orchestration/status-helpers.js +7 -8
- package/dist/orchestration/thread-executor.js +21 -12
- package/dist/platform/adapter.d.ts +13 -9
- package/dist/platform/adapter.js +1 -1
- package/dist/platform/adapters/feishu-output-stream.d.ts +27 -0
- package/dist/platform/adapters/feishu-output-stream.js +114 -0
- package/dist/platform/adapters/feishu.d.ts +16 -7
- package/dist/platform/adapters/feishu.js +64 -18
- package/dist/platform/adapters/index.d.ts +4 -1
- package/dist/platform/adapters/index.js +1 -1
- package/dist/platform/adapters/slack-output-stream.d.ts +55 -0
- package/dist/platform/{virtual-message.js → adapters/slack-output-stream.js} +98 -165
- package/dist/platform/adapters/slack-project-conduits.d.ts +9 -0
- package/dist/platform/adapters/slack-project-conduits.js +40 -0
- package/dist/platform/adapters/slack.d.ts +18 -8
- package/dist/platform/adapters/slack.js +82 -24
- package/dist/platform/index.d.ts +3 -2
- package/dist/platform/index.js +1 -1
- package/dist/platform/output-stream-chunk.d.ts +6 -0
- package/dist/platform/output-stream-chunk.js +45 -0
- package/dist/platform/output-stream-helpers.d.ts +6 -0
- package/dist/platform/output-stream-helpers.js +11 -0
- package/dist/platform/output-stream.d.ts +28 -0
- package/dist/platform/output-stream.js +4 -0
- package/dist/platform/testing.d.ts +41 -8
- package/dist/platform/testing.js +93 -11
- package/dist/platform/tool-trace.d.ts +9 -8
- package/dist/platform/tool-trace.js +19 -17
- package/dist/platform/types.d.ts +21 -1
- package/dist/platform/types.js +17 -1
- package/dist/store/channel-repo.d.ts +6 -0
- package/dist/store/channel-repo.js +9 -0
- package/dist/store/json-repository.js +12 -1
- package/dist/store/outbound-queue.d.ts +5 -4
- package/dist/store/outbound-queue.js +9 -6
- package/dist/store/schedule-repo.d.ts +9 -5
- package/dist/store/schedule-repo.js +59 -14
- package/dist/store/session-registry-repo.d.ts +36 -7
- package/dist/store/session-registry-repo.js +186 -25
- package/dist/store/thread-repo.d.ts +1 -0
- package/dist/store/thread-repo.js +8 -0
- package/package.json +1 -1
- package/dist/platform/virtual-message.d.ts +0 -68
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Cortex — Autonomous Project Owner
|
|
2
2
|
|
|
3
|
-
[中文文档](./docs/zh/)
|
|
3
|
+
[中文文档](./docs/zh/) | [Docs](https://fangxm233.github.io/cortex-agent/)
|
|
4
4
|
|
|
5
5
|
Cortex is an autonomous agent system for long-running projects. You give
|
|
6
6
|
it a mission with a success criterion, and it plans the work, dispatches
|
|
@@ -82,6 +82,10 @@ cortex start
|
|
|
82
82
|
Once running, message Cortex from Slack — it reads your project context,
|
|
83
83
|
plans the work, and dispatches agents automatically.
|
|
84
84
|
|
|
85
|
+
For a detailed step-by-step guide covering setup wizard prompts, what files
|
|
86
|
+
are created, and how to send your first message, see
|
|
87
|
+
[docs/quickstart.md](./docs/quickstart.md).
|
|
88
|
+
|
|
85
89
|
## How a project looks
|
|
86
90
|
|
|
87
91
|
Each project lives under `.cortex/context/projects/<name>/` with a
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"planner": {
|
|
76
76
|
"name": "planner",
|
|
77
|
-
"description": "Planner
|
|
77
|
+
"description": "Planner \u2014 draft plans and write to artifact",
|
|
78
78
|
"profile": "plan",
|
|
79
79
|
"persistSession": true,
|
|
80
80
|
"promptTemplate": "Write your plan to {{artifactPath}}.\n\nUser request:\n{{input}}",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
},
|
|
87
87
|
"reviewer": {
|
|
88
88
|
"name": "reviewer",
|
|
89
|
-
"description": "Reviewer
|
|
89
|
+
"description": "Reviewer \u2014 evaluate artifact content and give feedback, end with [APPROVED] or list Blockers",
|
|
90
90
|
"profile": "execute",
|
|
91
91
|
"persistSession": true,
|
|
92
92
|
"directive": "You are a strict reviewer. Evaluate the plan for correctness, completeness, and feasibility.",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
},
|
|
100
100
|
"plan-reviewer": {
|
|
101
101
|
"name": "plan-reviewer",
|
|
102
|
-
"description": "Plan Reviewer
|
|
102
|
+
"description": "Plan Reviewer \u2014 audit one phase's output against the external plan's acceptance criteria in the plan-gate template, issue Approve / Revise / Reject on the last line",
|
|
103
103
|
"profile": "execute",
|
|
104
104
|
"persistSession": false,
|
|
105
105
|
"directive": "file:plan-reviewer.md",
|
|
@@ -112,11 +112,11 @@
|
|
|
112
112
|
},
|
|
113
113
|
"plan-executor": {
|
|
114
114
|
"name": "plan-executor",
|
|
115
|
-
"description": "Plan Executor
|
|
115
|
+
"description": "Plan Executor \u2014 translate Plan Reviewer's verdict into task creation in the plan-gate template (Approve\u2192next phase / Revise\u2192patch+retry gate / Reject\u2192stop), do not modify plan file structure",
|
|
116
116
|
"profile": "plan",
|
|
117
117
|
"persistSession": false,
|
|
118
118
|
"directive": "file:plan-executor.md",
|
|
119
|
-
"promptTemplate": "Translate Plan Reviewer's verdict into operations per the plan-executor directive.\n\nPlan Reviewer's report (previous step):\n{{previousOutput}}\n\n---\n\nOriginal task / context:\n{{input}}\n\n---\n\nReviewer's full artifact is at {{artifactPath}}
|
|
119
|
+
"promptTemplate": "Translate Plan Reviewer's verdict into operations per the plan-executor directive.\n\nPlan Reviewer's report (previous step):\n{{previousOutput}}\n\n---\n\nOriginal task / context:\n{{input}}\n\n---\n\nReviewer's full artifact is at {{artifactPath}} \u2014 read it end-to-end first, extract the `Verdict:` word, then run the matching branch (Approve / Revise / Reject). All new tasks MUST carry `template:plan-gate` and full metadata; gate tasks always start `PLAN-GATE: `. Do NOT modify the plan file's structure or acceptance criteria.",
|
|
120
120
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
121
121
|
"pluginDirs": [
|
|
122
122
|
"plugins/cortex-stage-gate"
|
|
@@ -124,11 +124,11 @@
|
|
|
124
124
|
},
|
|
125
125
|
"milestone-reviewer": {
|
|
126
126
|
"name": "milestone-reviewer",
|
|
127
|
-
"description": "Milestone Reviewer
|
|
127
|
+
"description": "Milestone Reviewer \u2014 execute adversarial review in the milestone-gate template, check milestone output against roadmap.md success conditions, output Blocker / Nice-to-have, do not issue verdict (Director is responsible)",
|
|
128
128
|
"profile": "execute",
|
|
129
129
|
"persistSession": false,
|
|
130
130
|
"directive": "file:milestone-reviewer.md",
|
|
131
|
-
"promptTemplate": "Execute the milestone adversarial audit per the milestone-reviewer directive.\n\nTask / context:\n{{input}}\n\n---\n\nWrite the review to {{artifactPath}}. Cover every dimension the milestone's success criteria can be judged on. Each issue must carry a citation and a Blocker / Nice-to-have label. Do NOT issue a Director-style verdict
|
|
131
|
+
"promptTemplate": "Execute the milestone adversarial audit per the milestone-reviewer directive.\n\nTask / context:\n{{input}}\n\n---\n\nWrite the review to {{artifactPath}}. Cover every dimension the milestone's success criteria can be judged on. Each issue must carry a citation and a Blocker / Nice-to-have label. Do NOT issue a Director-style verdict \u2014 that belongs to Director.",
|
|
132
132
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
133
133
|
"pluginDirs": [
|
|
134
134
|
"plugins/cortex-common",
|
|
@@ -137,11 +137,11 @@
|
|
|
137
137
|
},
|
|
138
138
|
"director": {
|
|
139
139
|
"name": "director",
|
|
140
|
-
"description": "Project Director
|
|
140
|
+
"description": "Project Director \u2014 consume Milestone Reviewer report in the milestone-gate template and issue Proceed / Iterate / Pivot / Abort verdict; write result to artifact",
|
|
141
141
|
"profile": "execute",
|
|
142
142
|
"persistSession": false,
|
|
143
143
|
"directive": "file:director.md",
|
|
144
|
-
"promptTemplate": "Execute the milestone verdict per the director directive.\n\nMilestone Reviewer's report (previous step):\n{{previousOutput}}\n\n---\n\nOriginal task / context:\n{{input}}\n\n---\n\nReviewer's full artifact is at {{artifactPath}}
|
|
144
|
+
"promptTemplate": "Execute the milestone verdict per the director directive.\n\nMilestone Reviewer's report (previous step):\n{{previousOutput}}\n\n---\n\nOriginal task / context:\n{{input}}\n\n---\n\nReviewer's full artifact is at {{artifactPath}} \u2014 read it end-to-end first. Write your analysis and the final `Verdict:` line back to the same artifact. Artifact MUST agree on verdict word and top reasons.",
|
|
145
145
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
146
146
|
"pluginDirs": [
|
|
147
147
|
"plugins/cortex-common",
|
|
@@ -150,11 +150,11 @@
|
|
|
150
150
|
},
|
|
151
151
|
"milestone-executor": {
|
|
152
152
|
"name": "milestone-executor",
|
|
153
|
-
"description": "Milestone Executor
|
|
153
|
+
"description": "Milestone Executor \u2014 translate Director's verdict into roadmap updates and task creation in the milestone-gate template, all writes go to project files",
|
|
154
154
|
"profile": "plan",
|
|
155
155
|
"persistSession": false,
|
|
156
156
|
"directive": "file:milestone-executor.md",
|
|
157
|
-
"promptTemplate": "Translate Director's verdict into operations per the milestone-executor directive.\n\nDirector's analysis (previous step):\n{{previousOutput}}\n\n---\n\nOriginal task / context:\n{{input}}\n\n---\n\nDirector's full artifact is at {{artifactPath}}
|
|
157
|
+
"promptTemplate": "Translate Director's verdict into operations per the milestone-executor directive.\n\nDirector's analysis (previous step):\n{{previousOutput}}\n\n---\n\nOriginal task / context:\n{{input}}\n\n---\n\nDirector's full artifact is at {{artifactPath}} \u2014 read it end-to-end first and extract the `Verdict:` word. Then execute the matching branch (Proceed / Iterate / Pivot / Abort) per directive.",
|
|
158
158
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
159
159
|
"pluginDirs": [
|
|
160
160
|
"plugins/cortex-stage-gate"
|
|
@@ -162,20 +162,20 @@
|
|
|
162
162
|
},
|
|
163
163
|
"doc-writer": {
|
|
164
164
|
"name": "doc-writer",
|
|
165
|
-
"description": "Doc Writer
|
|
165
|
+
"description": "Doc Writer \u2014 general document producer, outputs structured documents such as status / digest / decision / report / knowledge entry, writes to project files",
|
|
166
166
|
"profile": "plan",
|
|
167
167
|
"persistSession": true,
|
|
168
168
|
"directive": "file:doc-writer.md",
|
|
169
169
|
"entryStage": "write",
|
|
170
170
|
"stages": {
|
|
171
171
|
"write": {
|
|
172
|
-
"description": "Initial writing pass
|
|
173
|
-
"promptTemplate": "Task:\n{{input}}\n\nProduce or update the document(s) per the doc-writer directive. After writing, append `## Write Summary (iteration 1)` to {{artifactPath}} listing each file you modified and the key changes. Do NOT write `[APPROVED]`
|
|
172
|
+
"description": "Initial writing pass \u2014 produce or update the target document, then summarize changes in the artifact.",
|
|
173
|
+
"promptTemplate": "Task:\n{{input}}\n\nProduce or update the document(s) per the doc-writer directive. After writing, append `## Write Summary (iteration 1)` to {{artifactPath}} listing each file you modified and the key changes. Do NOT write `[APPROVED]` \u2014 only the reviewer writes that."
|
|
174
174
|
},
|
|
175
175
|
"retry": {
|
|
176
176
|
"description": "After a blocking `## Review`: fix and append `## Write Summary (iteration N)` + `[REVISED]`.",
|
|
177
177
|
"continuesSession": true,
|
|
178
|
-
"promptTemplate": "The Reviewer's `## Review` has been written to {{artifactPath}}. First verify each Blocker against its cited source
|
|
178
|
+
"promptTemplate": "The Reviewer's `## Review` has been written to {{artifactPath}}. First verify each Blocker against its cited source \u2014 the Reviewer is not infallible. Then fix the document files per the feedback. When done, append `## Write Summary (iteration N)` and MUST write `[REVISED]` to {{artifactPath}} on its own line."
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
@@ -186,11 +186,11 @@
|
|
|
186
186
|
},
|
|
187
187
|
"doc-reviewer": {
|
|
188
188
|
"name": "doc-reviewer",
|
|
189
|
-
"description": "Doc Reviewer
|
|
189
|
+
"description": "Doc Reviewer \u2014 audit Doc Writer's changes to project documents, grade by original requirements + Blocker / Nice-to-have",
|
|
190
190
|
"profile": "execute",
|
|
191
191
|
"persistSession": true,
|
|
192
192
|
"directive": "file:doc-reviewer.md",
|
|
193
|
-
"promptTemplate": "Audit Doc Writer's project-file changes (changes by other agents in the same files may appear
|
|
193
|
+
"promptTemplate": "Audit Doc Writer's project-file changes (changes by other agents in the same files may appear \u2014 ignore those):\n{{modifiedFiles}}\n\nOriginal task:\n{{input}}\n\nApply the doc-reviewer directive and append your review to {{artifactPath}} under `## Review (iteration N)`. End the section with `[APPROVED]` if no Blockers remain; otherwise list the Blockers so Doc Writer can revise.",
|
|
194
194
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
195
195
|
"pluginDirs": [
|
|
196
196
|
"plugins/cortex-common",
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
},
|
|
200
200
|
"coder": {
|
|
201
201
|
"name": "coder",
|
|
202
|
-
"description": "Coder
|
|
202
|
+
"description": "Coder \u2014 code implementation executor. Works in multiple stages in the coder-review template: plan \u2192 implement \u2192 retry, driven by transition graph rather than artifact section inference",
|
|
203
203
|
"profile": "plan",
|
|
204
204
|
"persistSession": true,
|
|
205
205
|
"directive": "file:coder.md",
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
"implement": {
|
|
214
214
|
"description": "After `## Plan Review`: exit plan mode, implement, append `## Implementation Summary (iteration 1)`.",
|
|
215
215
|
"continuesSession": true,
|
|
216
|
-
"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]`
|
|
216
|
+
"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]` \u2014 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."
|
|
217
217
|
},
|
|
218
218
|
"retry": {
|
|
219
219
|
"description": "After a blocking `## Impl Review`: fix and append `## Implementation Summary (iteration 2)` + `[REVISED]`.",
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
},
|
|
230
230
|
"coder-reviewer": {
|
|
231
231
|
"name": "coder-reviewer",
|
|
232
|
-
"description": "Coder Reviewer
|
|
232
|
+
"description": "Coder Reviewer \u2014 works in two stages (planReview / implReview) in the coder-review template, transition graph determines stage rather than artifact inference",
|
|
233
233
|
"profile": "execute",
|
|
234
234
|
"persistSession": true,
|
|
235
235
|
"directive": "file:coder-reviewer.md",
|
|
@@ -237,13 +237,13 @@
|
|
|
237
237
|
"entryStage": "planReview",
|
|
238
238
|
"stages": {
|
|
239
239
|
"planReview": {
|
|
240
|
-
"description": "Read `## Plan` and append `## Plan Review (iteration N)`
|
|
241
|
-
"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
|
|
240
|
+
"description": "Read `## Plan` and append `## Plan Review (iteration N)` \u2014 no approval marker here.",
|
|
241
|
+
"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 \u2014 Coder decides per-Blocker what to accept/reject."
|
|
242
242
|
},
|
|
243
243
|
"implReview": {
|
|
244
|
-
"description": "Read `## Implementation Summary` + diff and append `## Impl Review (iteration M)`
|
|
244
|
+
"description": "Read `## Implementation Summary` + diff and append `## Impl Review (iteration M)` \u2014 must end with `[IMPL-APPROVED]` or list Blockers.",
|
|
245
245
|
"continuesSession": true,
|
|
246
|
-
"promptTemplate": "Audit Coder's project-file changes (changes by other agents in the same files may appear
|
|
246
|
+
"promptTemplate": "Audit Coder's project-file changes (changes by other agents in the same files may appear \u2014 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 \u2014 do not write [IMPL-APPROVED] until the full suite is green."
|
|
247
247
|
}
|
|
248
248
|
},
|
|
249
249
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
},
|
|
255
255
|
"executor": {
|
|
256
256
|
"name": "executor",
|
|
257
|
-
"description": "Executor
|
|
257
|
+
"description": "Executor \u2014 general task executor, performs assigned work (edit files, run commands, modify code, config changes, etc.), writes results to artifact. Stages: execute \u2192 retry",
|
|
258
258
|
"profile": "execute",
|
|
259
259
|
"persistSession": true,
|
|
260
260
|
"directive": "file:executor.md",
|
|
@@ -263,12 +263,12 @@
|
|
|
263
263
|
"stages": {
|
|
264
264
|
"execute": {
|
|
265
265
|
"description": "Execute the task, write ## Execute Summary to artifact",
|
|
266
|
-
"promptTemplate": "Task:\n{{input}}\n\nExecute the task per the executor directive. After completion, append `## Execute Summary (iteration 1)` to {{artifactPath}} listing what you did, what changed, and any decisions made. Do NOT write `[APPROVED]`
|
|
266
|
+
"promptTemplate": "Task:\n{{input}}\n\nExecute the task per the executor directive. After completion, append `## Execute Summary (iteration 1)` to {{artifactPath}} listing what you did, what changed, and any decisions made. Do NOT write `[APPROVED]` \u2014 only the reviewer writes that."
|
|
267
267
|
},
|
|
268
268
|
"retry": {
|
|
269
269
|
"description": "Address reviewer Blockers, write [REVISED] after fixing",
|
|
270
270
|
"continuesSession": true,
|
|
271
|
-
"promptTemplate": "The Reviewer's `## Review` has been written to {{artifactPath}}. First verify each Blocker against its cited source
|
|
271
|
+
"promptTemplate": "The Reviewer's `## Review` has been written to {{artifactPath}}. First verify each Blocker against its cited source \u2014 the Reviewer is not infallible. Fix the issues per the feedback. When done, append `## Execute Summary (iteration N)` and MUST write `[REVISED]` to {{artifactPath}} on its own line."
|
|
272
272
|
}
|
|
273
273
|
},
|
|
274
274
|
"tools": "Agent,Bash,Edit,Glob,Grep,Read,Skill,TaskStop,Write,WebFetch,WebSearch",
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
},
|
|
280
280
|
"executor-reviewer": {
|
|
281
281
|
"name": "executor-reviewer",
|
|
282
|
-
"description": "Executor Reviewer
|
|
282
|
+
"description": "Executor Reviewer \u2014 audit Executor's execution results, check correctness, completeness, and safety against task requirements + diff",
|
|
283
283
|
"profile": "execute",
|
|
284
284
|
"persistSession": true,
|
|
285
285
|
"directive": "file:executor-reviewer.md",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
},
|
|
306
306
|
"scheduler": {
|
|
307
307
|
"name": "scheduler",
|
|
308
|
-
"description": "Scheduled task
|
|
308
|
+
"description": "Scheduled task \u2014 single agent + onEnd hook (compound + git commit)",
|
|
309
309
|
"agents": [
|
|
310
310
|
"scheduler-main"
|
|
311
311
|
],
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
},
|
|
325
325
|
"plan-review": {
|
|
326
326
|
"name": "plan-review",
|
|
327
|
-
"description": "Plan-then-review (no execution): planner drafts
|
|
327
|
+
"description": "Plan-then-review (no execution): planner drafts \u2192 reviewer audits \u2192 END. Use this when you want a multi-step plan adversarially reviewed before committing to execution.",
|
|
328
328
|
"agents": [
|
|
329
329
|
"planner",
|
|
330
330
|
"reviewer"
|
|
@@ -343,7 +343,7 @@
|
|
|
343
343
|
},
|
|
344
344
|
"doc-review": {
|
|
345
345
|
"name": "doc-review",
|
|
346
|
-
"description": "Generic produce-then-audit for documents (status / digest / decision / report / knowledge entry). Stages: doc-writer(write)
|
|
346
|
+
"description": "Generic produce-then-audit for documents (status / digest / decision / report / knowledge entry). Stages: doc-writer(write) \u2192 doc-reviewer \u2192 (if not [APPROVED]) doc-writer(retry, write [REVISED] at end) \u2192 END",
|
|
347
347
|
"agents": [
|
|
348
348
|
"doc-writer",
|
|
349
349
|
"doc-reviewer"
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
},
|
|
390
390
|
"coder-review": {
|
|
391
391
|
"name": "coder-review",
|
|
392
|
-
"description": "Stage-driven coder loop: coder(plan)
|
|
392
|
+
"description": "Stage-driven coder loop: coder(plan) \u2192 coder(implement) \u2192 reviewer(implReview) \u2192 (if implReview lacks [IMPL-APPROVED]) coder(retry, write [REVISED] at end) \u2192 END. Each stage's prompt is selected by the transition graph in thread-engine, no longer inferred from artifact sections.",
|
|
393
393
|
"agents": [
|
|
394
394
|
"coder",
|
|
395
395
|
"coder-reviewer"
|
|
@@ -470,7 +470,7 @@
|
|
|
470
470
|
},
|
|
471
471
|
"milestone-gate": {
|
|
472
472
|
"name": "milestone-gate",
|
|
473
|
-
"description": "Milestone evaluation: adversarial review
|
|
473
|
+
"description": "Milestone evaluation: adversarial review \u2192 strategic verdict (Proceed/Iterate/Pivot/Abort) \u2192 operational follow-up. milestone-reviewer audits milestone output \u2192 director issues verdict \u2192 milestone-executor writes roadmap / creates next-phase tasks. Suitable for phase decisions in any mission-driven project.",
|
|
474
474
|
"agents": [
|
|
475
475
|
"milestone-reviewer",
|
|
476
476
|
"director",
|
|
@@ -506,12 +506,36 @@
|
|
|
506
506
|
},
|
|
507
507
|
"execute-review": {
|
|
508
508
|
"name": "execute-review",
|
|
509
|
-
"description": "Execute-then-review: executor executes task
|
|
510
|
-
"agents": [
|
|
509
|
+
"description": "Execute-then-review: executor executes task \u2192 executor-reviewer audits \u2192 at most 1 retry. Suitable for any verifiable task (code changes, config changes, file edits, script execution, etc.)",
|
|
510
|
+
"agents": [
|
|
511
|
+
"executor",
|
|
512
|
+
"executor-reviewer"
|
|
513
|
+
],
|
|
511
514
|
"transitions": [
|
|
512
|
-
{
|
|
513
|
-
|
|
514
|
-
|
|
515
|
+
{
|
|
516
|
+
"from": "executor:execute",
|
|
517
|
+
"to": "executor-reviewer",
|
|
518
|
+
"condition": {
|
|
519
|
+
"type": "always"
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
"from": "executor-reviewer",
|
|
524
|
+
"to": "executor:retry",
|
|
525
|
+
"condition": {
|
|
526
|
+
"type": "convergence",
|
|
527
|
+
"marker": "[APPROVED]",
|
|
528
|
+
"maxIterations": 1
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"from": "executor:retry",
|
|
533
|
+
"to": "executor-reviewer",
|
|
534
|
+
"condition": {
|
|
535
|
+
"type": "output_not_contains",
|
|
536
|
+
"pattern": "\\[REVISED\\]"
|
|
537
|
+
}
|
|
538
|
+
}
|
|
515
539
|
],
|
|
516
540
|
"entryAgent": "executor",
|
|
517
541
|
"entryStage": "execute",
|
|
@@ -519,7 +543,9 @@
|
|
|
519
543
|
"hooks": {
|
|
520
544
|
"onEnd": {
|
|
521
545
|
"command": "node ~/.cortex/hooks/post-task-hook.mjs",
|
|
522
|
-
"args": [
|
|
546
|
+
"args": [
|
|
547
|
+
"executor"
|
|
548
|
+
],
|
|
523
549
|
"timeout": 10000
|
|
524
550
|
}
|
|
525
551
|
}
|
|
@@ -35,7 +35,7 @@ Scheduled tasks allow Cortex to automatically execute messages at set times —
|
|
|
35
35
|
|
|
36
36
|
**Targets (where the fired task lands):**
|
|
37
37
|
- `fresh` *(default)* — new isolated thread + new session (current behavior; safest for unrelated tasks)
|
|
38
|
-
- `current-
|
|
38
|
+
- `current-project` — spawn a fresh session in the project (default for project-addressed schedules)
|
|
39
39
|
- `current-session` — reuse the current cortex-XXXX session (same conversation)
|
|
40
40
|
- `current-thread` — continue the current thread (only valid while it's running/waiting)
|
|
41
41
|
|
|
@@ -49,7 +49,7 @@ When you (the LLM) need to add or manage schedules from inside an agent session,
|
|
|
49
49
|
|
|
50
50
|
```
|
|
51
51
|
mcp__cortex__cortex_context()
|
|
52
|
-
→ {
|
|
52
|
+
→ { sessionId, sessionName, threadId, profile, project, backend, ... }
|
|
53
53
|
|
|
54
54
|
mcp__cortex__cortex_schedule_add({
|
|
55
55
|
type: 'interval' | 'daily' | 'weekly' | 'once',
|
|
@@ -58,7 +58,7 @@ mcp__cortex__cortex_schedule_add({
|
|
|
58
58
|
time?: '09:00', // for daily/weekly
|
|
59
59
|
dayOfWeek?: 'mon' | 0-6, // for weekly
|
|
60
60
|
delay?: '2h' | '90m', // for once
|
|
61
|
-
target?: 'fresh' | 'current-
|
|
61
|
+
target?: 'fresh' | 'current-project' | 'current-session' | 'current-thread' | { kind, ... },
|
|
62
62
|
fallback?: 'fresh' | 'skip' | 'wait', // when target session/thread is gone at fire time
|
|
63
63
|
profile?: 'fast-worker',
|
|
64
64
|
channel?: 'C123', // override; defaults to current context
|
|
@@ -74,7 +74,7 @@ mcp__cortex__cortex_schedule_resume({ id })
|
|
|
74
74
|
|
|
75
75
|
> User: "Remind me to run /orient every morning at 9, send results to current channel"
|
|
76
76
|
>
|
|
77
|
-
> Call `mcp__cortex__cortex_schedule_add({ type: 'daily', time: '09:00', message: '/orient', target: 'current-
|
|
77
|
+
> Call `mcp__cortex__cortex_schedule_add({ type: 'daily', time: '09:00', message: '/orient', target: 'current-project' })` — done. No need to call `cortex_context` first; the shorthand resolves automatically.
|
|
78
78
|
|
|
79
79
|
> User: "Report training status in this conversation after 30 minutes"
|
|
80
80
|
>
|
|
@@ -58,6 +58,9 @@ Severity: defects that can produce incorrect results, corrupt state, leak resour
|
|
|
58
58
|
### TDD discipline
|
|
59
59
|
Coder must land tests alongside (or before) the implementation, with coverage over the spec's happy path **and** edge cases (boundaries, empty/null inputs, error paths, concurrency hazards relevant to the diff); missing tests, tests that don't exercise the new control-flow paths, or untested edge cases called out by the spec are **Blockers**.
|
|
60
60
|
|
|
61
|
+
### Full-suite pass (non-negotiable)
|
|
62
|
+
Run the project's full test suite (`npm test` or equivalent). This includes not just unit tests but also architecture linters, integration tests, and regression suites. **Any test failure or architecture violation (e.g. dependency-cruiser error) is a Blocker.** Do not rely on Coder's claim that tests passed — run them yourself. If the suite had pre-existing failures before this invocation, verify that no NEW failures were introduced; new failures are Blockers regardless of pre-existing state.
|
|
63
|
+
|
|
61
64
|
### Git discipline
|
|
62
65
|
- Commits must land **before** the handoff boundary (before downstream consumers run it, before QA reviews, before the thread ends). Uncommitted changes at handoff are **Blockers**.
|
|
63
66
|
- Commit message should reference the spec identifier (task ID, issue reference) when one is clearly available; missing reference is a **Nice-to-have**.
|
|
@@ -71,10 +74,11 @@ Parameters, seeds, and data paths must live in committed files (config YAML, arg
|
|
|
71
74
|
1. Read the spec end-to-end.
|
|
72
75
|
2. Read the implementation summary (if one exists). Note declared commits and flagged ambiguities.
|
|
73
76
|
3. `git log --oneline <pre-SHA>..HEAD` and `git diff <pre-SHA>..HEAD` on the invocation's commits.
|
|
74
|
-
4.
|
|
75
|
-
5.
|
|
76
|
-
6.
|
|
77
|
-
7.
|
|
77
|
+
4. **Run the full test suite** (`npm test` or equivalent). Confirm that every stage passes: architecture linter, unit tests, integration tests, regression suite. If any test or lint stage fails, it is a Blocker — do not proceed to code review until Coder fixes it (or mark it as a pre-existing failure with evidence).
|
|
78
|
+
5. Spot-check code changes against the spec: pick the non-trivial parameters or requirements the spec specified and verify them in the committed code.
|
|
79
|
+
6. Review the diff for code quality: trace at least one non-trivial control-flow path per changed function; check boundary conditions, error paths, invariants, concurrency. Cite `file_path:line_number` for each concern.
|
|
80
|
+
7. Check commit messages for spec-identifier references.
|
|
81
|
+
8. Write the review artifact. Label every issue with severity and fix. In an Impl Review, finish with `[IMPL-APPROVED]` only if nothing Blocker-level remains. In a Plan Review, do not write any approval marker.
|
|
78
82
|
|
|
79
83
|
## Prohibited behaviors
|
|
80
84
|
- Do not modify code, the spec, or STATUS.md.
|
|
@@ -89,6 +93,7 @@ Parameters, seeds, and data paths must live in committed files (config YAML, arg
|
|
|
89
93
|
- **Runtime-only config tolerance**: accepting "the flags are in the commit message" as equivalent to in-repo config. They are not.
|
|
90
94
|
- **Bug-hunt skipping**: signing off on spec-match alone without tracing control-flow paths, boundary conditions, or error handling through the diff. Spec fidelity is not a correctness guarantee.
|
|
91
95
|
- **Cosmetic over substantive**: flooding the review with style nits while missing a logic bug. Lead with Blockers; Nice-to-have is secondary.
|
|
96
|
+
- **Test run omission**: signing off on an implementation without running the full test suite yourself. Coder's claim that tests pass is not evidence. Run `npm test` and check every stage. A dependency-cruiser error or a test regression that Coder missed is as much your failure as theirs.
|
|
92
97
|
|
|
93
98
|
# Reviewer / QA Relationship
|
|
94
99
|
|
|
@@ -41,6 +41,12 @@ Cortex optimizes **Quality > Cost > Speed**. For you, that means:
|
|
|
41
41
|
- Trivial glue code and obvious one-liners are exempt; use judgment but bias toward tests.
|
|
42
42
|
- Code that governs correctness (computation, data handling, seed handling) **requires** a test regardless.
|
|
43
43
|
|
|
44
|
+
### Full-suite pass (non-negotiable)
|
|
45
|
+
- After implementing and committing, run the project's full test suite (`npm test` or equivalent).
|
|
46
|
+
- The full suite includes unit tests, architecture linters (e.g. dependency-cruiser), integration tests, and regression suites. Every stage must pass.
|
|
47
|
+
- Do NOT commit or hand off until the full suite is green. A single red test or architecture violation means you are not done.
|
|
48
|
+
- If the test suite had pre-existing failures before your invocation, note them explicitly in the implementation summary; you must still verify that no NEW failures were introduced by your changes.
|
|
49
|
+
|
|
44
50
|
### Git discipline
|
|
45
51
|
- Commit your implementation **before** handing off (before downstream consumers run it, before QA reviews, before the thread hands back). The SHA must anchor the delivered code.
|
|
46
52
|
- Use clear commit messages that reference the spec identifier (task ID, issue reference, plan section).
|
|
@@ -59,9 +65,10 @@ Cortex optimizes **Quality > Cost > Speed**. For you, that means:
|
|
|
59
65
|
1. Read the spec end-to-end. List any ambiguities. If there are any, stop and escalate. Do not proceed on assumptions.
|
|
60
66
|
2. Read existing code that the implementation will touch. Understand before modifying.
|
|
61
67
|
3. Implement per spec. Use `/develop` for TDD on non-trivial logic.
|
|
62
|
-
4. Run
|
|
68
|
+
4. Run the **full test suite** (`npm test` or equivalent) locally; confirm every stage passes (architecture linter, unit tests, integration tests, regression suite). If it fails, fix before committing.
|
|
63
69
|
5. Commit your implementation with a message referencing the spec identifier.
|
|
64
|
-
6.
|
|
70
|
+
6. Run the full test suite one more time after committing to confirm the SHA is green.
|
|
71
|
+
7. Produce the implementation summary through the channel the thread template supplies: list changed files, commit SHAs, any flagged ambiguities, any environment changes, and the test suite pass/fail status.
|
|
65
72
|
|
|
66
73
|
## Prohibited behaviors
|
|
67
74
|
- Do not redesign the spec or rewrite acceptance criteria (the spec author's job).
|
|
@@ -76,6 +83,7 @@ Cortex optimizes **Quality > Cost > Speed**. For you, that means:
|
|
|
76
83
|
- **Hook bypass**: using `--no-verify` when a pre-commit hook blocks. Root-cause the failure; do not bypass.
|
|
77
84
|
- **Debug rabbit hole**: more than 3 iterations debugging the same failure without structured analysis. Invoke `/debug-campaign`.
|
|
78
85
|
- **Runtime-only config**: passing all the important knobs as CLI flags without landing defaults in the repo. Put them in a committed config.
|
|
86
|
+
- **Partial test pass**: running only unit tests for the changed module while skipping integration tests, regression suites, or architecture linters. The full suite (`npm test`) must pass.
|
|
79
87
|
|
|
80
88
|
# Reviewer / QA Relationship
|
|
81
89
|
|
package/dist/core/log.js
CHANGED
|
@@ -5,8 +5,17 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { LOGS_DIR } from './paths.js';
|
|
8
|
+
// Prevent EPIPE/SIGPIPE from killing the process when stderr/stdout is a broken
|
|
9
|
+
// pipe (e.g. terminal closed, journald restart, parent process exited).
|
|
10
|
+
// Without these listeners, Node throws EPIPE on write → if that write happens
|
|
11
|
+
// inside an uncaughtException handler, it causes a re-entrant crash loop that
|
|
12
|
+
// fills the log file and the disk.
|
|
13
|
+
process.stderr.on('error', () => { });
|
|
14
|
+
process.stdout.on('error', () => { });
|
|
8
15
|
// ── Config ──────────────────────────────────────────────
|
|
9
16
|
const RETENTION_DAYS = 14;
|
|
17
|
+
const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100 MB — rotate when exceeded
|
|
18
|
+
const MAX_ROTATED_FILES = 2; // keep up to .1.log, .2.log
|
|
10
19
|
// ── File sink (daily rotation) ──────────────────────────
|
|
11
20
|
let currentDate = '';
|
|
12
21
|
let stream = null;
|
|
@@ -32,8 +41,41 @@ function getStream() {
|
|
|
32
41
|
cleanOldLogs();
|
|
33
42
|
}
|
|
34
43
|
}
|
|
44
|
+
// Size-based rotation: if current file exceeds MAX_FILE_SIZE,
|
|
45
|
+
// rotate it and open a fresh one (same date tag).
|
|
46
|
+
if (stream.bytesWritten >= MAX_FILE_SIZE) {
|
|
47
|
+
stream.end();
|
|
48
|
+
stream = rotateLogFile(tag);
|
|
49
|
+
}
|
|
35
50
|
return stream;
|
|
36
51
|
}
|
|
52
|
+
/** Rotate the current day's log file: server-YYYYMMDD.log → .1.log → .2.log.
|
|
53
|
+
* Opens a fresh server-YYYYMMDD.log and returns the new stream. */
|
|
54
|
+
function rotateLogFile(tag) {
|
|
55
|
+
const base = path.join(LOGS_DIR, `server-${tag}`);
|
|
56
|
+
// Shift existing rotations: .1.log → .2.log (drop older if any)
|
|
57
|
+
for (let i = MAX_ROTATED_FILES; i >= 1; i--) {
|
|
58
|
+
const oldPath = `${base}.${i}.log`;
|
|
59
|
+
const newPath = `${base}.${i + 1}.log`;
|
|
60
|
+
try {
|
|
61
|
+
if (i === MAX_ROTATED_FILES) {
|
|
62
|
+
try {
|
|
63
|
+
fs.unlinkSync(newPath);
|
|
64
|
+
}
|
|
65
|
+
catch { /* doesn't exist */ }
|
|
66
|
+
}
|
|
67
|
+
fs.renameSync(oldPath, newPath);
|
|
68
|
+
}
|
|
69
|
+
catch { /* file may not exist */ }
|
|
70
|
+
}
|
|
71
|
+
// Rotate current to .1.log
|
|
72
|
+
try {
|
|
73
|
+
fs.renameSync(`${base}.log`, `${base}.1.log`);
|
|
74
|
+
}
|
|
75
|
+
catch { /* ignore */ }
|
|
76
|
+
// Open fresh log
|
|
77
|
+
return fs.createWriteStream(`${base}.log`, { flags: 'a' });
|
|
78
|
+
}
|
|
37
79
|
function cleanOldLogs() {
|
|
38
80
|
try {
|
|
39
81
|
const cutoff = Date.now() - RETENTION_DAYS * 86_400_000;
|
|
@@ -69,18 +111,25 @@ function formatArg(a) {
|
|
|
69
111
|
function write(level, mod, args) {
|
|
70
112
|
const ts = new Date().toLocaleTimeString('en-GB', { hour12: false });
|
|
71
113
|
const prefix = `[${mod} ${ts}]`;
|
|
72
|
-
// Console output
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
114
|
+
// Console output — wrapped so a broken pipe (EPIPE) on stderr/stdout doesn't
|
|
115
|
+
// crash the process. See also the stderr/stdout error listeners at the top of
|
|
116
|
+
// this file.
|
|
117
|
+
try {
|
|
118
|
+
switch (level) {
|
|
119
|
+
case 'ERROR':
|
|
120
|
+
console.error(prefix, ...args);
|
|
121
|
+
break;
|
|
122
|
+
case 'WARN':
|
|
123
|
+
console.warn(prefix, ...args);
|
|
124
|
+
break;
|
|
125
|
+
case 'DEBUG':
|
|
126
|
+
console.debug(prefix, ...args);
|
|
127
|
+
break;
|
|
128
|
+
default: console.log(prefix, ...args);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// stderr/stdout may be a broken pipe — ignore; file sink below still works
|
|
84
133
|
}
|
|
85
134
|
// File output
|
|
86
135
|
const line = `${prefix} ${level} ${args.map(formatArg).join(' ')}\n`;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { formatDurationCompact } from './utils.js';
|
|
6
6
|
export function computeElapsed(startTime) {
|
|
7
7
|
const elapsedS = (Date.now() - startTime) / 1000;
|
|
8
|
-
return { elapsedStr: elapsedS
|
|
8
|
+
return { elapsedStr: formatDurationCompact(elapsedS), elapsedS };
|
|
9
9
|
}
|
|
10
10
|
export function formatMetricsSuffix({ costUsd, numTurns }) {
|
|
11
11
|
const turnsStr = numTurns != null ? ` · ${numTurns} turns` : '';
|
|
@@ -52,7 +52,7 @@ declare function taskStatuses(task: Task, completedHashes?: Set<string> | null):
|
|
|
52
52
|
declare function taskTags(task: Task): Set<string>;
|
|
53
53
|
declare function filterTasks(tasks: Task[], args: any, completedHashes?: Set<string> | null): Task[];
|
|
54
54
|
declare function getTaskStatsFromTasks(tasks: Task[]): any;
|
|
55
|
-
declare function printTaskListToString(tasks: Task[], actionableHeader?: boolean): string;
|
|
55
|
+
declare function printTaskListToString(tasks: Task[], actionableHeader?: boolean, showDeps?: boolean): string;
|
|
56
56
|
declare function printStatsText(stats: any): string;
|
|
57
57
|
declare function showPayload(task: Task, tasks: Task[]): {
|
|
58
58
|
task: Task;
|
package/dist/core/task-parser.js
CHANGED
|
@@ -362,18 +362,25 @@ function formatTaskCompact(task, tags) {
|
|
|
362
362
|
const compactTags = tags.length > 0 ? ` (${tags.join(', ')})` : '';
|
|
363
363
|
return `${status}${idText} [${task.project}] ${task.text} [P:${task.priority}]${compactTags}`;
|
|
364
364
|
}
|
|
365
|
-
function printTaskListToString(tasks, actionableHeader = false) {
|
|
365
|
+
function printTaskListToString(tasks, actionableHeader = false, showDeps = false) {
|
|
366
366
|
const out = [];
|
|
367
367
|
if (actionableHeader) {
|
|
368
368
|
out.push('Actionable Tasks (sorted by priority)');
|
|
369
369
|
out.push('='.repeat(50));
|
|
370
370
|
}
|
|
371
|
-
for (const
|
|
371
|
+
for (const task of tasks) {
|
|
372
372
|
const tags = taskDisplayTags(task);
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
373
|
+
let line;
|
|
374
|
+
if (actionableHeader) {
|
|
375
|
+
line = formatTaskVerbose(task, tasks.indexOf(task), tags).join('\n');
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
line = formatTaskCompact(task, tags);
|
|
379
|
+
}
|
|
380
|
+
if (showDeps && task.depends_on.length > 0) {
|
|
381
|
+
line += ` → [${task.depends_on.join(', ')}]`;
|
|
382
|
+
}
|
|
383
|
+
out.push(line);
|
|
377
384
|
}
|
|
378
385
|
return out.join('\n');
|
|
379
386
|
}
|
|
@@ -175,6 +175,7 @@ export interface ThreadRecord {
|
|
|
175
175
|
templateName: string | null;
|
|
176
176
|
status: ThreadStatus;
|
|
177
177
|
channel: string;
|
|
178
|
+
projectId: string;
|
|
178
179
|
platformThreadId: string | null;
|
|
179
180
|
userMessage: string;
|
|
180
181
|
userMessageTs: string;
|
|
@@ -200,7 +201,6 @@ export interface ThreadRecord {
|
|
|
200
201
|
export interface ThreadMetadata {
|
|
201
202
|
scheduleTaskId?: string | null;
|
|
202
203
|
trigger?: string | null;
|
|
203
|
-
project?: string | null;
|
|
204
204
|
profileOverride?: string | null;
|
|
205
205
|
/** Messages buffered while a step was executing, to be included in the next step's prompt. */
|
|
206
206
|
pendingMessages?: string[];
|
|
@@ -217,10 +217,12 @@ export interface TransitionResult {
|
|
|
217
217
|
nextStage?: string | null;
|
|
218
218
|
reason: 'transition' | 'converged' | 'max_iterations' | 'cost_limit' | 'no_matching_transition';
|
|
219
219
|
}
|
|
220
|
-
import type { PlatformAdapter, MessageRef } from '../../platform/index.js';
|
|
220
|
+
import type { PlatformAdapter, MessageRef, Destination } from '../../platform/index.js';
|
|
221
221
|
export interface RunThreadOptions {
|
|
222
222
|
adapter: PlatformAdapter;
|
|
223
223
|
channel: string;
|
|
224
|
+
/** Destination for the thread's OutputStream. Caller must supply — never inferred. */
|
|
225
|
+
destination: Destination;
|
|
224
226
|
threadTs: string | null;
|
|
225
227
|
statusMsg: MessageRef | null;
|
|
226
228
|
startTime: number;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { PlatformAdapter } from '../../platform/adapter.js';
|
|
2
|
-
declare function maybeNotifyCodexLowUsage({ adapter,
|
|
2
|
+
declare function maybeNotifyCodexLowUsage({ adapter, result }: {
|
|
3
3
|
adapter: PlatformAdapter;
|
|
4
|
-
channel: string;
|
|
5
4
|
result: any;
|
|
6
5
|
}): Promise<void>;
|
|
7
6
|
export { maybeNotifyCodexLowUsage };
|