@markus-global/cli 0.11.2-rc.0 → 0.11.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/commands/start.js +5 -2
  2. package/dist/commands/start.js.map +1 -1
  3. package/dist/markus.mjs +1260 -1125
  4. package/dist/web-ui/assets/{CommentInput-Cqi5Hldw.js → CommentInput-C-niUbUY.js} +1 -1
  5. package/dist/web-ui/assets/{ContentRenderer-BAB3il9e.js → ContentRenderer-DxsnJJRX.js} +2 -2
  6. package/dist/web-ui/assets/{DeliverableShareModal-DJXkM66x.js → DeliverableShareModal-DV3TiZx0.js} +1 -1
  7. package/dist/web-ui/assets/{Deliverables-zKPxgZAN.js → Deliverables-tlLsJnxZ.js} +1 -1
  8. package/dist/web-ui/assets/{Notifications-HAycgg2x.js → Notifications-4KXYRdkr.js} +1 -1
  9. package/dist/web-ui/assets/{Search-SZuDcxy0.js → Search-CPFwZv1U.js} +1 -1
  10. package/dist/web-ui/assets/{Settings-CZgNsYSC.js → Settings-DIa-_qre.js} +6 -6
  11. package/dist/web-ui/assets/{Store-BS7VNrsr.js → Store-JWjwXfTU.js} +1 -1
  12. package/dist/web-ui/assets/Team-COBxn96h.js +84 -0
  13. package/dist/web-ui/assets/{Work-BN-LsW3k.js → Work-BScJUqWL.js} +1 -1
  14. package/dist/web-ui/assets/{arc-CsnWE2QW.js → arc-DPZmpo1U.js} +1 -1
  15. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CLek8I2z.js → architectureDiagram-3BPJPVTR-DlOs02JO.js} +1 -1
  16. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-jSgWEHN7.js → blockDiagram-GPEHLZMM-C7qsXNUe.js} +1 -1
  17. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BaC188UT.js → c4Diagram-AAUBKEIU-Drwp-rtM.js} +1 -1
  18. package/dist/web-ui/assets/channel-DCChB-1T.js +1 -0
  19. package/dist/web-ui/assets/{chunk-2J33WTMH-CdtP4-T4.js → chunk-2J33WTMH-VgR09Mqk.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-4BX2VUAB-BSgBKyC9.js → chunk-4BX2VUAB-CuwDpBRL.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-55IACEB6-XB_ZMqfw.js → chunk-55IACEB6-nC7YWJ_i.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-727SXJPM-YFPBFW4M.js → chunk-727SXJPM-Dw6mBsRE.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-AQP2D5EJ-CDbFN1Un.js → chunk-AQP2D5EJ-CPhNJbHl.js} +1 -1
  24. package/dist/web-ui/assets/{chunk-FMBD7UC4-BGKt8xP8.js → chunk-FMBD7UC4-AyhQakG8.js} +1 -1
  25. package/dist/web-ui/assets/{chunk-ND2GUHAM-DKicpX2b.js → chunk-ND2GUHAM-DgYemv8I.js} +1 -1
  26. package/dist/web-ui/assets/{chunk-QZHKN3VN-BD4tv8RZ.js → chunk-QZHKN3VN-CLdqxrFB.js} +1 -1
  27. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CrNiYfSI.js +1 -0
  28. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CrNiYfSI.js +1 -0
  29. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BjOoIarG.js → cose-bilkent-S5V4N54A-DrOgwDIH.js} +1 -1
  30. package/dist/web-ui/assets/{dagre-BM42HDAG-BWal5GOH.js → dagre-BM42HDAG-DhoJiA83.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-2AECGRRQ-CJj-CzRg.js → diagram-2AECGRRQ-BDILSgqK.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-5GNKFQAL-4IMjuEPm.js → diagram-5GNKFQAL-CeXywd1i.js} +1 -1
  33. package/dist/web-ui/assets/{diagram-KO2AKTUF-DQiRAfss.js → diagram-KO2AKTUF-Bi4RlMT0.js} +1 -1
  34. package/dist/web-ui/assets/{diagram-LMA3HP47-BMPvbEbY.js → diagram-LMA3HP47-Cw1yxk8b.js} +1 -1
  35. package/dist/web-ui/assets/{diagram-OG6HWLK6-D5_vmdXl.js → diagram-OG6HWLK6-Bl857da2.js} +1 -1
  36. package/dist/web-ui/assets/{docx-preview-Cdouj_6e.js → docx-preview-CjoUhrMq.js} +1 -1
  37. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DOnDuvXd.js → erDiagram-TEJ5UH35-DEiaMhuV.js} +1 -1
  38. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-DL6G76eC.js → flowDiagram-I6XJVG4X-BgKZhO0h.js} +1 -1
  39. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CwHnuRR8.js → ganttDiagram-6RSMTGT7-Dkx-EaS8.js} +1 -1
  40. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-BFUnsmW_.js → gitGraphDiagram-PVQCEYII-DXaQwA0y.js} +1 -1
  41. package/dist/web-ui/assets/{index-BSktaJwx.js → index-C_QhfMcC.js} +74 -74
  42. package/dist/web-ui/assets/index-DEN_qReg.css +1 -0
  43. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DhU1bQNw.js → infoDiagram-5YYISTIA-Dpx9IOkx.js} +1 -1
  44. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-o6ujfUJF.js → ishikawaDiagram-YF4QCWOH-BWqWgitQ.js} +1 -1
  45. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-Dx_SZ8zv.js → journeyDiagram-JHISSGLW-BBwIZ4k9.js} +1 -1
  46. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-D4BWXcIn.js → kanban-definition-UN3LZRKU-C_MRWV8R.js} +1 -1
  47. package/dist/web-ui/assets/{mermaid.core-BHDulYyB.js → mermaid.core-BMAh3nnq.js} +5 -5
  48. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BVy6py_h.js → mindmap-definition-RKZ34NQL-B6vJQcat.js} +1 -1
  49. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CUr5__J1.js → pieDiagram-4H26LBE5-BxdEttqt.js} +1 -1
  50. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-C5Owt_r4.js → quadrantDiagram-W4KKPZXB-gsNs2VfP.js} +1 -1
  51. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-Bb933lBb.js → requirementDiagram-4Y6WPE33-BSC9KvC2.js} +1 -1
  52. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CJq-boMJ.js → sankeyDiagram-5OEKKPKP-DktAZfe_.js} +1 -1
  53. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BP8L47v3.js → sequenceDiagram-3UESZ5HK-BIPt8kGU.js} +1 -1
  54. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-Byk9-Yrm.js → stateDiagram-AJRCARHV-DiXmJWB0.js} +1 -1
  55. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-COOgTXIX.js +1 -0
  56. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-2z8RR-l_.js → timeline-definition-PNZ67QCA-LRi7H35g.js} +1 -1
  57. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-CSwDDhHv.js → vennDiagram-CIIHVFJN-DWQ1I022.js} +1 -1
  58. package/dist/web-ui/assets/{wardley-L42UT6IY-DW30MdHd.js → wardley-L42UT6IY-BUb6dYqN.js} +1 -1
  59. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DUb2r21l.js → wardleyDiagram-YWT4CUSO-BYE1B3xT.js} +1 -1
  60. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-4DTcVUL8.js → xychartDiagram-2RQKCTM6-D-pS2-Sa.js} +1 -1
  61. package/dist/web-ui/index.html +2 -2
  62. package/docs/README.md +93 -0
  63. package/docs/api/api.md +353 -0
  64. package/docs/architecture/agent-runtime.md +341 -0
  65. package/docs/architecture/architecture-fragility.md +184 -0
  66. package/docs/architecture/architecture.md +938 -0
  67. package/docs/architecture/cognitive-architecture.md +322 -0
  68. package/docs/architecture/concurrent-processing.md +550 -0
  69. package/docs/architecture/frontend/team-chat.md +312 -0
  70. package/docs/architecture/learning-loop.md +340 -0
  71. package/docs/architecture/llm-provider-timeouts.md +60 -0
  72. package/docs/architecture/mailbox-system.md +1635 -0
  73. package/docs/architecture/memory-system.md +533 -0
  74. package/docs/architecture/prompt-engineering.md +1377 -0
  75. package/docs/architecture/state-machines.md +665 -0
  76. package/docs/architecture/state-ownership.md +83 -0
  77. package/docs/architecture/streaming-and-reattach.md +193 -0
  78. package/docs/architecture/tool-system.md +266 -0
  79. package/docs/design/deliverable-sharing.md +238 -0
  80. package/docs/guides/coding-tools.md +765 -0
  81. package/docs/guides/community.md +104 -0
  82. package/docs/guides/development.md +179 -0
  83. package/docs/guides/guide.md +362 -0
  84. package/docs/guides/release-and-distribution.md +165 -0
  85. package/docs/guides/remote-access.md +286 -0
  86. package/docs/guides/skill-ecosystem.md +129 -0
  87. package/docs/records/agent-platform-friction-2026-10.md +98 -0
  88. package/docs/records/animation-budget-focus-vs-visibility-2026-10-08.md +110 -0
  89. package/docs/records/audit-fixes-2026-09.md +173 -0
  90. package/docs/records/branch-consolidation.md +597 -0
  91. package/docs/records/file-edit-literal-replacement-fix.md +132 -0
  92. package/docs/records/message-stop-cancel-fix-plan.md +209 -0
  93. package/docs/records/platform-hardening-2026-10.md +1365 -0
  94. package/docs/records/session-identity-plan.md +130 -0
  95. package/docs/records/settings-model-routing-first-visit-fix.md +101 -0
  96. package/docs/records/team-chat-stream-transport-vs-turn-2026-10-08.md +152 -0
  97. package/package.json +2 -1
  98. package/templates/roles/HANDBOOK.md +12 -7
  99. package/dist/web-ui/assets/Team-B6vw2Oj5.js +0 -84
  100. package/dist/web-ui/assets/channel-CqbBz9iL.js +0 -1
  101. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DDQJP38f.js +0 -1
  102. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DDQJP38f.js +0 -1
  103. package/dist/web-ui/assets/index-3PQIqBtv.css +0 -1
  104. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CWa-Q2Gf.js +0 -1
@@ -0,0 +1,765 @@
1
+ # Coding Tools Integration
2
+
3
+ > Last updated: 2026-06
4
+ >
5
+ > **Status — agent tools disabled (2026-08):** `invoke_coding_tool` and `coding_tool_apply` are not currently registered on agents. `registerCodingTools()` in `packages/core/src/agent-manager.ts` returns early (temporary disable), so no `codingTools` setting will surface them. The adapters, handlers, config keys, REST endpoints, and Settings UI documented below remain implemented.
6
+
7
+ Technical reference for Markus's external coding tool integration — delegating hands-on programming work to Claude Code, Codex, and Cursor Agent while keeping task context, progress, and governance inside Markus.
8
+
9
+ ---
10
+
11
+ ## Table of Contents
12
+
13
+ - [Overview](#overview)
14
+ - [Architecture](#architecture)
15
+ - [Supported Tools](#supported-tools)
16
+ - [Configuration](#configuration)
17
+ - [Usage Guide](#usage-guide)
18
+ - [For Agents](#for-agents)
19
+ - [For External Tools](#for-external-tools)
20
+ - [For Users](#for-users)
21
+ - [Developing New Adapters](#developing-new-adapters)
22
+ - [Skills](#skills)
23
+ - [API Reference](#api-reference)
24
+ - [Troubleshooting](#troubleshooting)
25
+
26
+ ---
27
+
28
+ ## Overview
29
+
30
+ Markus agents orchestrate work — scoping tasks, coordinating dependencies, and reviewing deliverables. For substantial code changes, agents can delegate implementation to specialized external CLIs rather than editing files directly.
31
+
32
+ The Coding Tools integration provides:
33
+
34
+ - **Unified invocation** — one agent tool (`invoke_coding_tool`) for all supported CLIs
35
+ - **Context injection** — task, requirement, project, and dependency data written into tool-native config files before execution
36
+ - **Streaming progress** — stdout parsed into structured events surfaced to the agent in real time
37
+ - **Change application** — `coding_tool_apply` commits tool-produced diffs via git
38
+ - **Bidirectional reporting** — external tools report progress back through Markus CLI commands
39
+ - **Settings UI** — detect, enable, and configure tools from the Web UI
40
+
41
+ **When to use coding tools vs direct editing:**
42
+
43
+ | Use coding tools | Edit directly (`file_edit`, `shell_execute`) |
44
+ |---|---|
45
+ | Multi-file refactors, broad exploration | Small, well-known diffs (1–2 files) |
46
+ | Autonomous edit → test → fix loops | Configuration, docs, non-code work |
47
+ | Large implementation surface with clear acceptance criteria | Fine-grained control over every change |
48
+
49
+ Coding tools are **opt-in**. Set `codingTools.enabled: true` in `markus.json` (or via Settings → Coding Tools) before agents receive `invoke_coding_tool` and `coding_tool_apply` — though as of 2026-08 those tools are disabled at the runtime level (see the status note above), so the setting alone will not surface them.
50
+
51
+ ---
52
+
53
+ ## Architecture
54
+
55
+ ### Component Map
56
+
57
+ ```
58
+ ┌─────────────────────────────────────────────────────────────────────┐
59
+ │ Agent Runtime (@markus/core) │
60
+ │ ┌──────────────────┐ ┌──────────────────────────────────────┐ │
61
+ │ │ Tool Handlers │───▶│ CodingToolRuntime │ │
62
+ │ │ invoke_coding_ │ │ 1. Create session │ │
63
+ │ │ tool │ │ 2. injectContext() │ │
64
+ │ │ coding_tool_ │ │ 3. adapter.buildArgs() │ │
65
+ │ │ apply │ │ 4. spawn CLI, stream stdout │ │
66
+ │ └──────────────────┘ │ 5. adapter.parseOutput() / extractCost│ │
67
+ │ └──────────────┬───────────────────────┘ │
68
+ └─────────────────────────────────────────┼──────────────────────────┘
69
+ │
70
+ ┌───────────────────────────┼───────────────────────────┐
71
+ │ │ │
72
+ ┌────────▼────────┐ ┌─────────▼─────────┐ ┌────────▼────────┐
73
+ │ Tool Adapters │ │ Context Injector │ │ Quality Verifier│
74
+ │ claude-code │ │ CLAUDE.md │ │ detectProjectType│
75
+ │ codex │ │ .cursor/rules/ │ │ runTests │
76
+ │ cursor-agent │ │ .agent_context/ │ │ (utility module) │
77
+ └────────┬────────┘ └───────────────────┘ └─────────────────┘
78
+ │
79
+ ┌────────▼────────┐ ┌───────────────────┐ ┌─────────────────┐
80
+ │ External CLIs │ │ Markus CLI │ │ API Server │
81
+ │ claude / codex │◀─────▶│ task show/context │◀─────▶│ GET /tasks/:id/ │
82
+ │ / cursor │ │ progress / note │ │ context │
83
+ └─────────────────┘ └───────────────────┘ └─────────────────┘
84
+ ```
85
+
86
+ ### Package Layout
87
+
88
+ | Path | Role |
89
+ |---|---|
90
+ | `packages/shared/src/types/coding-tool.ts` | Type contracts (`ToolAdapter`, `CodingToolSession`, `TaskContextResponse`, etc.) |
91
+ | `packages/core/src/coding-tools/adapters/` | Per-tool adapters (detect, args, parse, cost) |
92
+ | `packages/core/src/coding-tools/runtime.ts` | Session lifecycle and CLI spawning |
93
+ | `packages/core/src/coding-tools/context-injector.ts` | Writes tool-specific context files |
94
+ | `packages/core/src/coding-tools/quality-verifier.ts` | Project type detection and test runner |
95
+ | `packages/core/src/coding-tools/handlers.ts` | `invoke_coding_tool` / `coding_tool_apply` handlers |
96
+ | `packages/cli/src/commands/task.ts` | CLI for external tools to query and report |
97
+ | `packages/org-manager/src/api-server.ts` | `/api/tasks/:id/context`, `/api/settings/coding-tools` |
98
+ | `packages/web-ui/src/pages/CodingToolsSettings.tsx` | Admin settings UI |
99
+ | `templates/skills/coding-tools/` | Agent skill documentation |
100
+
101
+ ### Execution Flow
102
+
103
+ 1. Agent receives a coding task and calls `invoke_coding_tool` with `tool`, `prompt`, `workdir`, and optionally `task_id`.
104
+ 2. Handler selects the adapter, verifies the CLI is installed (`adapter.detect()`), and fetches task context (when `getTaskContext` is configured).
105
+ 3. `CodingToolRuntime.execute()` creates a session, calls `injectContext()` to write context files, builds CLI args via the adapter, and spawns the process.
106
+ 4. Each stdout line is parsed by `adapter.parseOutput()` into `CodingToolEvent` objects; progress and file-edit events stream back to the agent.
107
+ 5. On process exit, the adapter extracts cost data (when available) and the session transitions to `completed` or `failed`.
108
+ 6. Agent reviews the result, then calls `coding_tool_apply` to stage and commit changes.
109
+
110
+ ### Session States
111
+
112
+ | Status | Meaning |
113
+ |---|---|
114
+ | `created` | Session record initialized |
115
+ | `context_injected` | Context files written to workdir |
116
+ | `running` | CLI process active |
117
+ | `completed` | Exit code 0 |
118
+ | `failed` | Non-zero exit or error |
119
+ | `cancelled` | Manually cancelled via `runtime.cancel()` |
120
+ | `timeout` | Exceeded configured `timeoutMs` |
121
+
122
+ ---
123
+
124
+ ## Supported Tools
125
+
126
+ ### Claude Code
127
+
128
+ | Property | Value |
129
+ |---|---|
130
+ | Tool name | `claude-code` |
131
+ | Binary | `claude` |
132
+ | Install | `npm install -g @anthropic-ai/claude-code` |
133
+ | Auth | Anthropic API key (`ANTHROPIC_API_KEY`), custom endpoint (`ANTHROPIC_BASE_URL`), or Claude subscription via CLI login |
134
+
135
+ Markus invokes:
136
+
137
+ ```bash
138
+ claude --print --output-format stream-json --verbose --max-turns 50 --permission-mode bypassPermissions "<prompt>"
139
+ ```
140
+
141
+ - **stream-json** output enables structured progress parsing and cost extraction from `result` events.
142
+ - **`--permission-mode bypassPermissions`** is required because `--print` mode has no interactive stdin for approval prompts. Markus-level approval is handled separately via the `approvalRequired` config flag.
143
+ - **Context file:** `CLAUDE.md` in the repository root.
144
+ - **Best for:** Complex refactors, multi-file changes, sustained codebase exploration.
145
+ - **Cost tracking:** Yes — input/output tokens, cache stats, and `cost_usd` from result events.
146
+
147
+ ### Codex
148
+
149
+ | Property | Value |
150
+ |---|---|
151
+ | Tool name | `codex` |
152
+ | Binary | `codex` |
153
+ | Install | `npm install -g @openai/codex` |
154
+ | Auth | `codex login`, or `CODEX_API_KEY` env var for non-interactive mode |
155
+
156
+ Markus invokes:
157
+
158
+ ```bash
159
+ codex exec --full-auto --json --skip-git-repo-check "<prompt>"
160
+ ```
161
+
162
+ - **`exec --full-auto`** runs in non-interactive mode with automatic approval for all edits and commands.
163
+ - **`--json`** emits JSONL events for structured progress parsing.
164
+ - **`--skip-git-repo-check`** allows running outside strict git repo requirements.
165
+ - **Context file:** `.agent_context/task_context.md` (alongside any existing `AGENTS.md`).
166
+ - **Best for:** Quick fixes, targeted patches, fast iteration.
167
+ - **Cost tracking:** Not currently extracted from output.
168
+ - **Note:** `OPENAI_BASE_URL` env var is deprecated. Custom endpoints require `~/.codex/config.toml` configuration.
169
+
170
+ ### Cursor Agent
171
+
172
+ | Property | Value |
173
+ |---|---|
174
+ | Tool name | `cursor-agent` |
175
+ | Binary | `cursor` |
176
+ | Install | [cursor.com/downloads](https://cursor.com/downloads), then run `cursor agent install-shell-integration` |
177
+ | Auth | Cursor account via `cursor agent login`, or `CURSOR_API_KEY` env var |
178
+
179
+ Markus invokes:
180
+
181
+ ```bash
182
+ cursor agent --print --output-format stream-json --workspace <workdir> --trust --force "<prompt>"
183
+ ```
184
+
185
+ - **`--print`** runs in non-interactive mode.
186
+ - **`--output-format stream-json`** emits structured JSON events for progress parsing.
187
+ - **`--trust --force`** auto-trusts the workspace without prompting.
188
+ - **Context file:** `.cursor/rules/markus-task.mdc` (alongside permanent project rules).
189
+ - **Best for:** Repos with `.cursor/rules`, IDE-integrated conventions.
190
+ - **Cost tracking:** May include tokens in result events.
191
+ - **Note:** The CLI's `--model` flag only accepts CLI-specific models (`auto`, `composer-2.5`, etc.). Cursor Cloud API models (Claude, GPT) are not available via the local CLI.
192
+
193
+ ### Version Requirements
194
+
195
+ Markus detects tools via `which <binary>` and optionally reads `<binary> --version`. There is no enforced minimum version — use the latest stable release of each CLI. Run `markus doctor` to verify installation.
196
+
197
+ ---
198
+
199
+ ## Configuration
200
+
201
+ ### markus.json
202
+
203
+ ```json
204
+ {
205
+ "codingTools": {
206
+ "enabled": true,
207
+ "tools": {
208
+ "claude-code": {
209
+ "enabled": true,
210
+ "timeoutMs": 1800000,
211
+ "defaultModel": "sonnet",
212
+ "maxBudgetPerSessionUsd": 5,
213
+ "approvalRequired": false
214
+ },
215
+ "codex": {
216
+ "enabled": true,
217
+ "timeoutMs": 1800000
218
+ },
219
+ "cursor-agent": {
220
+ "enabled": true,
221
+ "timeoutMs": 600000
222
+ }
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ | Field | Description | Default |
229
+ |---|---|---|
230
+ | `enabled` | Master switch — when `false`, agents do not receive coding tool handlers | `false` |
231
+ | `tools.<name>.enabled` | Per-tool enable flag (persisted; used in Settings UI) | `true` |
232
+ | `tools.<name>.timeoutMs` | Max execution time in milliseconds | `600000` (10 min) |
233
+ | `tools.<name>.defaultArgs` | Extra CLI arguments appended by the adapter | `[]` |
234
+ | `tools.<name>.binaryPath` | Override binary path (detection still uses `binaryName`) | auto-detected |
235
+ | `tools.<name>.defaultModel` | Default model for the tool (agent can override per invocation) | tool's own default |
236
+ | `tools.<name>.maxBudgetPerSessionUsd` | Hard budget cap per invocation (Claude Code only, via `--max-budget-usd`) | none |
237
+ | `tools.<name>.approvalRequired` | Agent must get user approval before each invocation | `false` |
238
+
239
+ Configuration is loaded at startup (`markus start`) and can be updated live via the Settings UI (`POST /api/settings/coding-tools`). Changes take effect immediately without restart.
240
+
241
+ ### Environment Variables
242
+
243
+ Injected into external tool processes by the context injector:
244
+
245
+ | Variable | Set when | Purpose |
246
+ |---|---|---|
247
+ | `MARKUS_API_URL` | `serverUrl` configured | Base URL for API calls from within the tool session |
248
+ | `MARKUS_TASK_ID` | Task context available | Current task ID |
249
+ | `MARKUS_CLI` | CLI path configured | Path to `markus` binary for progress reporting |
250
+
251
+ CLI global options (for external tools calling Markus):
252
+
253
+ | Variable / Flag | Purpose |
254
+ |---|---|
255
+ | `MARKUS_API_URL` / `-s, --server <url>` | API server URL (default: `http://localhost:8056`) |
256
+ | `-k, --api-key <key>` | Authentication |
257
+ | `--json` | Machine-readable JSON output |
258
+
259
+ Tool-specific credentials are configured in each CLI's own auth flow — **not** managed in the Markus Settings UI:
260
+
261
+ - **Claude Code:** `ANTHROPIC_API_KEY` env var, `ANTHROPIC_BASE_URL` for custom endpoints, or `claude` interactive login
262
+ - **Codex:** `codex login`, or `CODEX_API_KEY` env var for non-interactive mode. Custom endpoints via `~/.codex/config.toml` (the `OPENAI_BASE_URL` env var is deprecated and no longer supported)
263
+ - **Cursor:** `cursor agent login` browser auth, or `CURSOR_API_KEY` env var
264
+
265
+ ---
266
+
267
+ ## Usage Guide
268
+
269
+ ### For Agents
270
+
271
+ Agents with the `coding-tools` skill (or the `coding` tool group activated) receive two tools:
272
+
273
+ #### `invoke_coding_tool`
274
+
275
+ ```json
276
+ {
277
+ "tool": "claude-code",
278
+ "prompt": "Implement JWT auth middleware in src/auth/. Run tests when done.",
279
+ "workdir": "/absolute/path/to/repo",
280
+ "task_id": "task-abc123"
281
+ }
282
+ ```
283
+
284
+ | Parameter | Required | Description |
285
+ |---|---|---|
286
+ | `tool` | Yes | `claude-code`, `codex`, or `cursor-agent` |
287
+ | `prompt` | Yes | Instruction sent to the external CLI |
288
+ | `workdir` | Yes | Absolute path to the repository root |
289
+ | `task_id` | No | Enables full task context injection |
290
+
291
+ **Response shape:**
292
+
293
+ ```json
294
+ {
295
+ "status": "success",
296
+ "sessionId": "uuid",
297
+ "tool": "claude-code",
298
+ "result": {
299
+ "success": true,
300
+ "summary": "Tool completed successfully",
301
+ "rawOutput": "...",
302
+ "exitCode": 0
303
+ },
304
+ "cost": {
305
+ "inputTokens": 5000,
306
+ "outputTokens": 1200,
307
+ "estimatedCostUsd": 0.12,
308
+ "source": "tool_output"
309
+ }
310
+ }
311
+ ```
312
+
313
+ Progress events (`file_edit`, `progress`) stream to the agent during execution via the tool output callback.
314
+
315
+ #### `coding_tool_apply`
316
+
317
+ ```json
318
+ {
319
+ "session_id": "uuid-from-invoke-response",
320
+ "workdir": "/absolute/path/to/repo",
321
+ "commit_message": "feat: add JWT auth middleware"
322
+ }
323
+ ```
324
+
325
+ Stages all changes (`git add -A`) and creates a commit. Returns `{ status: "success", commitLog: "..." }` or an error if git operations fail.
326
+
327
+ #### Prompt Guidelines
328
+
329
+ 1. State the **goal** and acceptance criteria.
330
+ 2. Define **scope** — directories/files in and out of bounds.
331
+ 3. List **constraints** — patterns, coding standards, test commands.
332
+ 4. Specify **verification** — how to confirm success.
333
+ 5. Keep each invocation focused — one coherent unit of work.
334
+
335
+ Always pass `task_id` when working on an assigned Markus task so context injection includes requirement, project, and dependency data.
336
+
337
+ #### Tool Selection
338
+
339
+ | Scenario | Tool |
340
+ |---|---|
341
+ | Large multi-package refactor | `claude-code` |
342
+ | One-file bug fix | `codex` |
343
+ | Repo with `.cursor/rules` | `cursor-agent` |
344
+ | Need cost/token visibility | `claude-code` |
345
+
346
+ ### For External Tools
347
+
348
+ External CLIs running inside a Markus session can query task state and report progress using the Markus CLI. Context files injected before execution include these commands.
349
+
350
+ #### Task Commands
351
+
352
+ ```bash
353
+ # View task details
354
+ markus task show <id>
355
+
356
+ # Full composite context (task + requirement + project + dependencies)
357
+ markus task context <id>
358
+
359
+ # List tasks (with filters)
360
+ markus task list --status in_progress --project <projectId>
361
+
362
+ # View dependency graph
363
+ markus task deps <id>
364
+
365
+ # Report progress (posted as a task comment)
366
+ markus task progress <id> -t "50% done — auth middleware implemented" --percent 50
367
+
368
+ # Add a note or comment
369
+ markus task note <id> -t "Found edge case in token refresh"
370
+ markus task comment <id> -t "Same as note — alias command"
371
+ ```
372
+
373
+ Add `--json` for machine-readable output:
374
+
375
+ ```bash
376
+ markus --json task context <id>
377
+ ```
378
+
379
+ #### Requirement and Project Commands
380
+
381
+ ```bash
382
+ markus requirement show <id>
383
+ markus requirement list --project <projectId>
384
+ markus req list # alias
385
+
386
+ markus project show <id>
387
+ markus project list
388
+ ```
389
+
390
+ #### CLI Exit Codes
391
+
392
+ | Code | Meaning |
393
+ |---|---|
394
+ | `0` | Success |
395
+ | `1` | User error (bad args, not found) |
396
+ | `2` | Server error |
397
+ | `3` | Network error |
398
+
399
+ ### For Users
400
+
401
+ #### Enabling Coding Tools
402
+
403
+ 1. Open **Settings → Coding Tools** (admin only).
404
+ 2. Toggle **Enable coding tools** globally.
405
+ 3. For each tool, expand the card to review detection status and toggle enable/disable.
406
+ 4. Use **Test Configuration** to verify the tool actually works (runs a real test prompt).
407
+ 5. Optionally configure default model, timeout, budget cap, and CLI arguments.
408
+
409
+ Changes auto-save and apply immediately to the running agent manager.
410
+
411
+ #### Detection and Testing
412
+
413
+ - **Auto-detection:** On page load, Markus checks if CLIs are installed and authenticated. Results are cached for 24 hours with silent background refresh.
414
+ - **Test button:** Runs the actual CLI with a minimal prompt to verify end-to-end connectivity (not just env var checks). If the test succeeds, the status badge updates to "Ready" immediately.
415
+ - **Re-detect button:** Force-refreshes all tools' installation and auth status.
416
+ - **CLI:** Run `markus doctor` — the "Coding Tools" section reports each binary's path or install hint.
417
+
418
+ Detection checks system environment variables first (`ANTHROPIC_API_KEY`, `CODEX_API_KEY`, `CURSOR_API_KEY`), then falls back to CLI auth commands. This ensures tools authenticated via env vars are correctly detected as ready.
419
+
420
+ #### CodingToolCard (Web UI)
421
+
422
+ The `CodingToolCard` component displays active coding tool sessions in the agent execution view:
423
+
424
+ - Tool badge (Claude Code / Codex / Cursor)
425
+ - Session status pipeline: Created → Context injected → Running → Completed/Failed
426
+ - Progress message, duration, and cost (when available)
427
+ - Diff stats and modified files on completion
428
+
429
+ #### Troubleshooting Quick Checks
430
+
431
+ 1. `markus doctor` — are CLIs installed and on PATH?
432
+ 2. Settings → Coding Tools — is global enable on?
433
+ 3. Agent role — does the agent have the `coding-tools` skill?
434
+ 4. `markus.json` — is `codingTools.enabled` true?
435
+ 5. Restart Markus after config changes if tools don't appear.
436
+
437
+ ---
438
+
439
+ ## Developing New Adapters
440
+
441
+ To add support for a new external coding CLI:
442
+
443
+ ### 1. Extend Types
444
+
445
+ Add the tool name to `CodingToolName` in `packages/shared/src/types/coding-tool.ts`:
446
+
447
+ ```typescript
448
+ export type CodingToolName = 'claude-code' | 'codex' | 'cursor-agent' | 'my-tool';
449
+ ```
450
+
451
+ Update `isCodingToolName()` accordingly.
452
+
453
+ ### 2. Implement ToolAdapter
454
+
455
+ Create `packages/core/src/coding-tools/adapters/my-tool-adapter.ts`:
456
+
457
+ ```typescript
458
+ import type { ToolAdapter, ToolAdapterDetectResult, ToolAdapterBuildArgsResult, CodingToolConfig, CodingToolEvent, ToolCostReport } from '@markus/shared';
459
+
460
+ export class MyToolAdapter implements ToolAdapter {
461
+ readonly name = 'my-tool' as const;
462
+ readonly displayName = 'My Tool';
463
+ readonly binaryName = 'my-tool-cli';
464
+
465
+ async detect(): Promise<ToolAdapterDetectResult> {
466
+ // execSync('which my-tool-cli') — return { available, version, path, installHint }
467
+ }
468
+
469
+ buildArgs(opts: { prompt: string; workdir: string; config?: CodingToolConfig }): ToolAdapterBuildArgsResult {
470
+ // Return { args: [...], env: {...} }
471
+ }
472
+
473
+ parseOutput(line: string): CodingToolEvent | null {
474
+ // Parse one stdout line → CodingToolEvent or null
475
+ }
476
+
477
+ extractCost(output: string): ToolCostReport | null {
478
+ // Best-effort cost extraction from full output
479
+ }
480
+ }
481
+ ```
482
+
483
+ ### 3. Register the Adapter
484
+
485
+ In `packages/core/src/coding-tools/adapters/index.ts`:
486
+
487
+ ```typescript
488
+ const adapters: Record<CodingToolName, () => ToolAdapter> = {
489
+ // ...existing
490
+ 'my-tool': () => new MyToolAdapter(),
491
+ };
492
+ ```
493
+
494
+ ### 4. Add Context Injection Path
495
+
496
+ In `packages/core/src/coding-tools/context-injector.ts`, add a branch in `injectContext()` for where the new tool reads project context (e.g., a config file or directory the tool natively supports).
497
+
498
+ ### 5. Wire Configuration and UI
499
+
500
+ - Add the tool name to detection lists in `api-server.ts` (`/api/settings/coding-tools`) and `doctor.ts`.
501
+ - Add UI metadata in `CodingToolsSettings.tsx` and locale strings.
502
+ - Add the tool to the `invoke_coding_tool` input schema enum in `handlers.ts`.
503
+
504
+ ### 6. Create a Skill
505
+
506
+ Add `templates/skills/my-tool/SKILL.md` and `skill.json` documenting tool-specific usage for agents.
507
+
508
+ ### 7. Test
509
+
510
+ Follow patterns in `packages/core/test/coding-tools/` — adapter unit tests, handler tests with mocked spawn, and integration tests for config loading.
511
+
512
+ ### ToolAdapter Interface Reference
513
+
514
+ ```typescript
515
+ interface ToolAdapter {
516
+ readonly name: CodingToolName;
517
+ readonly displayName: string;
518
+ readonly binaryName: string;
519
+
520
+ detect(): Promise<ToolAdapterDetectResult>;
521
+ buildArgs(opts: { prompt: string; workdir: string; config?: CodingToolConfig }): ToolAdapterBuildArgsResult;
522
+ parseOutput(line: string): CodingToolEvent | null;
523
+ extractCost(output: string): ToolCostReport | null;
524
+ }
525
+ ```
526
+
527
+ Event types: `progress`, `tool_use`, `file_edit`, `test_run`, `error`, `cost_update`, `completed`.
528
+
529
+ ---
530
+
531
+ ## Skills
532
+
533
+ Markus ships skill packages under `templates/skills/` that teach agents how to use coding tools effectively.
534
+
535
+ | Skill | Purpose | Agents |
536
+ |---|---|---|
537
+ | `coding-tools` | General workflow — when to delegate, invoke/apply, error handling, progress reporting | architect, ai-engineer, data-engineer, sre |
538
+ | `claude-code` | Claude Code specifics — stream-json, CLAUDE.md, cost tracking, retry strategies | loaded on demand via `discover_tools` |
539
+ | `codex` | Codex specifics — full-auto mode, AGENTS.md, sandbox behavior | loaded on demand |
540
+ | `cursor-agent` | Cursor specifics — `.cursor/rules`, working directory setup | loaded on demand |
541
+
542
+ ### Installing Skills
543
+
544
+ Skills are installed like any Markus skill — via the Web UI skill manager or the Secretary agent's `package_install` tool. Role templates reference skills in `agent.json`:
545
+
546
+ ```json
547
+ {
548
+ "skills": ["coding-tools"]
549
+ }
550
+ ```
551
+
552
+ ### Customizing Skills
553
+
554
+ Copy a skill directory to your organization's skills path and edit `SKILL.md`. Skills are injected into context files when `getSkills` is configured on the coding tool handler. Tool-specific skills can also be loaded dynamically:
555
+
556
+ ```
557
+ discover_tools({ name: ["claude-code"] })
558
+ ```
559
+
560
+ ### Tool Group Activation
561
+
562
+ The `coding` tool group in `packages/core/src/tool-selector.ts` auto-activates `invoke_coding_tool` and `coding_tool_apply` when conversation keywords match (e.g., "refactor", "implement", "debug", "claude code").
563
+
564
+ ---
565
+
566
+ ## API Reference
567
+
568
+ ### Task Context
569
+
570
+ **`GET /api/tasks/:id/context`**
571
+
572
+ Returns composite context for a task — used by the context injector and available to external tools via CLI.
573
+
574
+ **Response:** `TaskContextResponse`
575
+
576
+ ```typescript
577
+ {
578
+ task: {
579
+ id: string;
580
+ title: string;
581
+ description: string;
582
+ status: TaskStatus;
583
+ priority: TaskPriority;
584
+ subtasks: Array<{ id: string; title: string; status: string }>;
585
+ notes?: string[];
586
+ deliverables?: TaskDeliverable[];
587
+ completionSummary?: string;
588
+ assignedAgentId: string;
589
+ reviewerId: string;
590
+ executionRound: number;
591
+ createdAt: string;
592
+ updatedAt: string;
593
+ };
594
+ requirement?: { id: string; title: string; description: string; status: string };
595
+ project?: {
596
+ id: string;
597
+ name: string;
598
+ description: string;
599
+ repositories: Array<{ url?: string; localPath?: string; role?: string }>;
600
+ };
601
+ upstream: Array<{ id: string; title: string; status: TaskStatus; notes?: string[]; completionSummary?: string; deliverables?: TaskDeliverable[] }>;
602
+ downstream: Array<{ id: string; title: string; status: TaskStatus }>;
603
+ }
604
+ ```
605
+
606
+ **Errors:** `404` if task not found, `500` on server failure.
607
+
608
+ ### Coding Tools Settings
609
+
610
+ **`GET /api/settings/coding-tools`**
611
+
612
+ Returns current configuration:
613
+
614
+ ```json
615
+ {
616
+ "enabled": true,
617
+ "tools": {
618
+ "claude-code": { "tool": "claude-code", "enabled": true, "timeoutMs": 600000, "defaultArgs": [] },
619
+ "codex": { "tool": "codex", "enabled": true, "timeoutMs": 600000, "defaultArgs": [] },
620
+ "cursor-agent": { "tool": "cursor-agent", "enabled": false, "timeoutMs": 600000, "defaultArgs": [] }
621
+ }
622
+ }
623
+ ```
624
+
625
+ **`POST /api/settings/coding-tools`** (auth required)
626
+
627
+ Update configuration. Body: `{ enabled: boolean, tools: { "<name>": { enabled?, binaryPath?, defaultArgs?, timeoutMs?, defaultModel?, maxBudgetPerSessionUsd?, approvalRequired? } } }`.
628
+
629
+ **`GET /api/settings/coding-tools/detect/:tool`**
630
+
631
+ Detect a single tool. Returns installation, version, and authentication status.
632
+
633
+ **`POST /api/settings/coding-tools/:tool/test`** (auth required)
634
+
635
+ Run a real test against the tool CLI to verify end-to-end connectivity. Returns `{ success, detail?, error? }`.
636
+
637
+ **`GET /api/settings/coding-tools/detect`**
638
+
639
+ Detect installed CLIs:
640
+
641
+ ```json
642
+ {
643
+ "tools": [
644
+ { "name": "claude-code", "displayName": "Claude Code", "binaryName": "claude", "available": true, "path": "/usr/local/bin/claude", "version": "1.0.0", "installHint": "npm install -g @anthropic-ai/claude-code" }
645
+ ]
646
+ }
647
+ ```
648
+
649
+ ### Related Task Endpoints
650
+
651
+ | Method | Path | Used by |
652
+ |---|---|---|
653
+ | `GET` | `/api/tasks/:id` | `markus task show` |
654
+ | `GET` | `/api/tasks/:id/dependents` | `markus task deps` |
655
+ | `POST` | `/api/tasks/:id/comments` | `markus task note/progress/comment` |
656
+ | `GET` | `/api/requirements/:id` | `markus requirement show` |
657
+ | `GET` | `/api/projects/:id` | `markus project show` |
658
+
659
+ ### Core Types
660
+
661
+ All coding tool types live in `packages/shared/src/types/coding-tool.ts`:
662
+
663
+ - `CodingToolName`, `CodingToolConfig`, `CodingToolSession`, `CodingToolResult`
664
+ - `CodingToolEvent`, `ToolCostReport`, `TestResult`
665
+ - `ToolAdapter`, `TaskContextResponse`
666
+ - `CliResponse`, `CLI_EXIT_CODES`
667
+
668
+ ### Handler Options (Internal)
669
+
670
+ `CodingToolHandlerOptions` in `handlers.ts`:
671
+
672
+ | Option | Purpose |
673
+ |---|---|
674
+ | `getTaskContext(taskId)` | Fetch `TaskContextResponse` for context injection |
675
+ | `configs` | Per-tool `CodingToolConfig` from `markus.json` |
676
+ | `markusCli` | Path injected as `MARKUS_CLI` env var |
677
+ | `serverUrl` | Injected as `MARKUS_API_URL` env var |
678
+ | `getSkills(toolName)` | Skills appended to injected context files |
679
+
680
+ ---
681
+
682
+ ## Troubleshooting
683
+
684
+ ### Tool Not Installed
685
+
686
+ **Symptom:** `invoke_coding_tool` returns `{ error: "Claude Code is not installed...", installHint: "..." }`.
687
+
688
+ **Fix:** Install the CLI per the install hint. Run `markus doctor` to verify. Ensure the binary is on the agent process PATH (same environment as `markus start`).
689
+
690
+ ### Coding Tools Not Available to Agents
691
+
692
+ **Symptom:** Agent doesn't have `invoke_coding_tool` in its tool list.
693
+
694
+ **Checks:**
695
+ 1. `codingTools.enabled` must be `true` in `markus.json` or Settings UI.
696
+ 2. Restart or save settings to reload agent manager config.
697
+ 3. Agent role must include the `coding-tools` skill or trigger the `coding` tool group.
698
+
699
+ ### Timeout
700
+
701
+ **Symptom:** Session status `timeout`, error mentions exceeded `timeoutMs`.
702
+
703
+ **Fix:** Increase `timeoutMs` for the tool in Settings (default 600000 ms). Split large tasks into smaller focused invocations.
704
+
705
+ ### Empty or Minimal Context Injection
706
+
707
+ **Symptom:** Injected `CLAUDE.md` contains only the prompt, missing requirement/project/deps.
708
+
709
+ **Cause:** `task_id` was passed but full context wasn't fetched. The handler supports a `getTaskContext` callback; when unavailable, it falls back to a minimal stub.
710
+
711
+ **Fix:** Ensure the task exists and use `markus task context <id>` to verify the API returns full data. External tools can always fetch context directly via CLI.
712
+
713
+ ### Context File Overwrites
714
+
715
+ **Symptom:** Existing `CLAUDE.md` or project rules modified unexpectedly.
716
+
717
+ **Cause:** Markus writes ephemeral context files before each invocation (`CLAUDE.md`, `.cursor/rules/markus-task.mdc`, `.agent_context/task_context.md`).
718
+
719
+ **Fix:** Keep permanent project guidance in dedicated files (e.g., `.cursor/rules/coding-standards.mdc`, `AGENTS.md`). Markus task context goes in the tool-specific injected file. Review diffs before applying with `coding_tool_apply`.
720
+
721
+ ### Apply Failures
722
+
723
+ **Symptom:** `coding_tool_apply` returns `{ error: "Failed to apply changes: ..." }`.
724
+
725
+ **Checks:**
726
+ 1. `workdir` must be a git repository.
727
+ 2. Run `git status` manually — resolve conflicts or untracked issues.
728
+ 3. Ensure there are actual changes to commit.
729
+
730
+ ### No Cost Data
731
+
732
+ **Symptom:** `cost` field is null or missing.
733
+
734
+ **Cause:** Only Claude Code's stream-json `result` events provide token/cost data. Codex and Cursor adapters return `null` from `extractCost()`.
735
+
736
+ ### Progress Not Streaming
737
+
738
+ **Symptom:** Agent sees only start/end messages, no intermediate updates.
739
+
740
+ **Cause:** Tool output format may not match adapter parsing. Claude Code stream-json provides the richest events; Codex and Cursor emit simpler text lines.
741
+
742
+ **Fix:** Check `result.rawOutput` in the response for the full truncated stdout (max 50 KB).
743
+
744
+ ### External CLI Can't Reach Markus API
745
+
746
+ **Symptom:** `markus task` commands fail with network errors from inside a tool session.
747
+
748
+ **Checks:**
749
+ 1. `MARKUS_API_URL` env var is set (via context injection when server URL is configured).
750
+ 2. API server is running and reachable from the tool's environment.
751
+ 3. Authenticate CLI with `-k, --api-key` or login if required.
752
+
753
+ ### Quality Verifier Not Running Automatically
754
+
755
+ **Symptom:** `result.testResult` is never populated.
756
+
757
+ **Cause:** `detectProjectType()` and `runTests()` are exported utilities but are not yet wired into `CodingToolRuntime.execute()`. Agents should run tests explicitly via prompts or `shell_execute` after tool completion.
758
+
759
+ ---
760
+
761
+ ## Related Documentation
762
+
763
+ - [Architecture](../architecture/architecture.md) — overall platform architecture
764
+ - [API Reference](../api/api.md) — full REST API
765
+ - [User Guide](./guide.md) — setup and Web UI usage