kortext 2.2.3 → 3.0.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 (208) hide show
  1. package/AGENTS.md +0 -4
  2. package/CHANGELOG.md +81 -0
  3. package/LICENSE +21 -0
  4. package/README.md +145 -55
  5. package/USER-GUIDE.md +505 -0
  6. package/bin/kortext.js +23 -0
  7. package/bin/kortext.ts +377 -0
  8. package/dist/bin/kortext.js +346 -0
  9. package/dist/bin/kortext.js.map +1 -0
  10. package/dist/mcp/index.js +4 -0
  11. package/dist/mcp/index.js.map +1 -0
  12. package/dist/mcp/server.js +553 -0
  13. package/dist/mcp/server.js.map +1 -0
  14. package/dist/mcp/sse.js +38 -0
  15. package/dist/mcp/sse.js.map +1 -0
  16. package/dist/mcp/stdio.js +44 -0
  17. package/dist/mcp/stdio.js.map +1 -0
  18. package/dist/server/cli/cleanup.js +73 -0
  19. package/dist/server/cli/cleanup.js.map +1 -0
  20. package/dist/server/cli/commands.js +73 -0
  21. package/dist/server/cli/commands.js.map +1 -0
  22. package/dist/server/cli/doctor.js +118 -0
  23. package/dist/server/cli/doctor.js.map +1 -0
  24. package/dist/server/cli/executor-factory.js +39 -0
  25. package/dist/server/cli/executor-factory.js.map +1 -0
  26. package/dist/server/cli/init.js +121 -0
  27. package/dist/server/cli/init.js.map +1 -0
  28. package/dist/server/cli/logs.js +28 -0
  29. package/dist/server/cli/logs.js.map +1 -0
  30. package/dist/server/cli/serve.js +72 -0
  31. package/dist/server/cli/serve.js.map +1 -0
  32. package/dist/server/config/env.js +12 -0
  33. package/dist/server/config/env.js.map +1 -0
  34. package/dist/server/db/client.js +32 -0
  35. package/dist/server/db/client.js.map +1 -0
  36. package/dist/server/db/json.js +21 -0
  37. package/dist/server/db/json.js.map +1 -0
  38. package/dist/server/db/migrate.js +70 -0
  39. package/dist/server/db/migrate.js.map +1 -0
  40. package/dist/server/db/migrations/001_init.sql +243 -0
  41. package/dist/server/db/repositories/audit-log.js +58 -0
  42. package/dist/server/db/repositories/audit-log.js.map +1 -0
  43. package/dist/server/db/repositories/backlog.js +96 -0
  44. package/dist/server/db/repositories/backlog.js.map +1 -0
  45. package/dist/server/db/repositories/contexts.js +54 -0
  46. package/dist/server/db/repositories/contexts.js.map +1 -0
  47. package/dist/server/db/repositories/decisions.js +71 -0
  48. package/dist/server/db/repositories/decisions.js.map +1 -0
  49. package/dist/server/db/repositories/handovers.js +53 -0
  50. package/dist/server/db/repositories/handovers.js.map +1 -0
  51. package/dist/server/db/repositories/index.js +30 -0
  52. package/dist/server/db/repositories/index.js.map +1 -0
  53. package/dist/server/db/repositories/locks.js +59 -0
  54. package/dist/server/db/repositories/locks.js.map +1 -0
  55. package/dist/server/db/repositories/notifications.js +63 -0
  56. package/dist/server/db/repositories/notifications.js.map +1 -0
  57. package/dist/server/db/repositories/pending-questions.js +63 -0
  58. package/dist/server/db/repositories/pending-questions.js.map +1 -0
  59. package/dist/server/db/repositories/runs.js +138 -0
  60. package/dist/server/db/repositories/runs.js.map +1 -0
  61. package/dist/server/db/repositories/runtime-artifacts.js +39 -0
  62. package/dist/server/db/repositories/runtime-artifacts.js.map +1 -0
  63. package/dist/server/db/repositories/secrets.js +65 -0
  64. package/dist/server/db/repositories/secrets.js.map +1 -0
  65. package/dist/server/db/repositories/sessions.js +48 -0
  66. package/dist/server/db/repositories/sessions.js.map +1 -0
  67. package/dist/server/db/schemas.js +308 -0
  68. package/dist/server/db/schemas.js.map +1 -0
  69. package/dist/server/engine/consistency.js +25 -0
  70. package/dist/server/engine/consistency.js.map +1 -0
  71. package/dist/server/engine/dag.js +86 -0
  72. package/dist/server/engine/dag.js.map +1 -0
  73. package/dist/server/engine/executor.js +2 -0
  74. package/dist/server/engine/executor.js.map +1 -0
  75. package/dist/server/engine/executors/claude-cli-executor.js +83 -0
  76. package/dist/server/engine/executors/claude-cli-executor.js.map +1 -0
  77. package/dist/server/engine/executors/cli-spawn.js +127 -0
  78. package/dist/server/engine/executors/cli-spawn.js.map +1 -0
  79. package/dist/server/engine/executors/codex-cli-executor.js +69 -0
  80. package/dist/server/engine/executors/codex-cli-executor.js.map +1 -0
  81. package/dist/server/engine/executors/gemini-cli-executor.js +69 -0
  82. package/dist/server/engine/executors/gemini-cli-executor.js.map +1 -0
  83. package/dist/server/engine/executors/mock-executor.js +52 -0
  84. package/dist/server/engine/executors/mock-executor.js.map +1 -0
  85. package/dist/server/engine/executors/persona-routed-executor.js +17 -0
  86. package/dist/server/engine/executors/persona-routed-executor.js.map +1 -0
  87. package/dist/server/engine/gate-enforcer.js +75 -0
  88. package/dist/server/engine/gate-enforcer.js.map +1 -0
  89. package/dist/server/engine/git-commit.js +42 -0
  90. package/dist/server/engine/git-commit.js.map +1 -0
  91. package/dist/server/engine/handover.js +120 -0
  92. package/dist/server/engine/handover.js.map +1 -0
  93. package/dist/server/engine/item-lifecycle.js +74 -0
  94. package/dist/server/engine/item-lifecycle.js.map +1 -0
  95. package/dist/server/engine/persona-registry.js +108 -0
  96. package/dist/server/engine/persona-registry.js.map +1 -0
  97. package/dist/server/engine/worker-pool.js +324 -0
  98. package/dist/server/engine/worker-pool.js.map +1 -0
  99. package/dist/server/engine/workflow-loader.js +55 -0
  100. package/dist/server/engine/workflow-loader.js.map +1 -0
  101. package/dist/server/engine/workflow-parser.js +158 -0
  102. package/dist/server/engine/workflow-parser.js.map +1 -0
  103. package/dist/server/engine/worktree.js +176 -0
  104. package/dist/server/engine/worktree.js.map +1 -0
  105. package/dist/server/index.js +99 -0
  106. package/dist/server/index.js.map +1 -0
  107. package/dist/server/notifications/dispatcher.js +60 -0
  108. package/dist/server/notifications/dispatcher.js.map +1 -0
  109. package/dist/server/notifications/slack.js +37 -0
  110. package/dist/server/notifications/slack.js.map +1 -0
  111. package/dist/server/notifications/telegram.js +33 -0
  112. package/dist/server/notifications/telegram.js.map +1 -0
  113. package/dist/server/orchestrator/approval-queue.js +83 -0
  114. package/dist/server/orchestrator/approval-queue.js.map +1 -0
  115. package/dist/server/orchestrator/blueprint-watcher.js +94 -0
  116. package/dist/server/orchestrator/blueprint-watcher.js.map +1 -0
  117. package/dist/server/orchestrator/orchestrator.js +283 -0
  118. package/dist/server/orchestrator/orchestrator.js.map +1 -0
  119. package/dist/server/orchestrator/pipeline-chainer.js +96 -0
  120. package/dist/server/orchestrator/pipeline-chainer.js.map +1 -0
  121. package/dist/server/orchestrator/resume.js +36 -0
  122. package/dist/server/orchestrator/resume.js.map +1 -0
  123. package/dist/server/routes/approvals.js +52 -0
  124. package/dist/server/routes/approvals.js.map +1 -0
  125. package/dist/server/routes/backlog.js +44 -0
  126. package/dist/server/routes/backlog.js.map +1 -0
  127. package/dist/server/routes/db-info.js +21 -0
  128. package/dist/server/routes/db-info.js.map +1 -0
  129. package/dist/server/routes/docs.js +70 -0
  130. package/dist/server/routes/docs.js.map +1 -0
  131. package/dist/server/routes/doctor.js +19 -0
  132. package/dist/server/routes/doctor.js.map +1 -0
  133. package/dist/server/routes/handovers.js +25 -0
  134. package/dist/server/routes/handovers.js.map +1 -0
  135. package/dist/server/routes/health.js +11 -0
  136. package/dist/server/routes/health.js.map +1 -0
  137. package/dist/server/routes/personas.js +96 -0
  138. package/dist/server/routes/personas.js.map +1 -0
  139. package/dist/server/routes/runs.js +41 -0
  140. package/dist/server/routes/runs.js.map +1 -0
  141. package/dist/server/routes/workflows.js +38 -0
  142. package/dist/server/routes/workflows.js.map +1 -0
  143. package/dist/server/safety/harmful-output-filter.js +40 -0
  144. package/dist/server/safety/harmful-output-filter.js.map +1 -0
  145. package/dist/server/safety/secret-scanner.js +169 -0
  146. package/dist/server/safety/secret-scanner.js.map +1 -0
  147. package/dist/server/services/markdown-sync.js +101 -0
  148. package/dist/server/services/markdown-sync.js.map +1 -0
  149. package/dist/web/assets/index-B80d5ZPZ.js +75 -0
  150. package/dist/web/assets/index-B80d5ZPZ.js.map +1 -0
  151. package/dist/web/assets/index-Bge5Gzqv.css +1 -0
  152. package/dist/web/index.html +13 -0
  153. package/docs/architecture.md +413 -0
  154. package/package.json +83 -11
  155. package/scripts/copy-migrations.mjs +29 -0
  156. package/workspace/.locks/workspace_handover.md.lock +3 -0
  157. package/hooks/audit-logger.sh +0 -25
  158. package/hooks/auto-locker.sh +0 -74
  159. package/hooks/auto-unlocker.sh +0 -17
  160. package/hooks/backlog-sync-guard.sh +0 -12
  161. package/hooks/branch-guard.sh +0 -32
  162. package/hooks/commit-msg-guard.sh +0 -43
  163. package/hooks/git-pre-commit.sh +0 -76
  164. package/hooks/git-pre-push.sh +0 -17
  165. package/hooks/handover-guard.sh +0 -33
  166. package/hooks/kortext-init.sh +0 -194
  167. package/hooks/kortext-lib.sh +0 -151
  168. package/hooks/lint-guard.sh +0 -50
  169. package/hooks/secret-scanner.sh +0 -89
  170. package/hooks/size-guard.sh +0 -48
  171. package/hooks/snapshot-guard.sh +0 -39
  172. package/hooks/write-guard.sh +0 -77
  173. package/scripts/kortext-backlog-add.py +0 -123
  174. package/scripts/kortext-backlog-health.py +0 -112
  175. package/scripts/kortext-backlog-sync.py +0 -117
  176. package/scripts/kortext-bulk-plan.py +0 -63
  177. package/scripts/kortext-cli.py +0 -376
  178. package/scripts/kortext-consistency-check.py +0 -74
  179. package/scripts/kortext-context-check.py +0 -146
  180. package/scripts/kortext-handover.py +0 -107
  181. package/scripts/kortext-item-check.py +0 -61
  182. package/scripts/kortext-item-start.py +0 -70
  183. package/scripts/kortext-item-transition.py +0 -78
  184. package/scripts/kortext-lock.py +0 -174
  185. package/scripts/kortext-session-start.py +0 -127
  186. package/scripts/lock_kortext.sh +0 -34
  187. package/settings/.claude-settings.template.json +0 -48
  188. package/settings/CHANGELOG.md +0 -176
  189. package/settings/INTEGRATION-MAP.md +0 -276
  190. package/settings/README.md +0 -255
  191. package/settings/USER-GUIDE.md +0 -502
  192. package/settings/VERSION +0 -1
  193. package/settings/config.md +0 -8
  194. package/settings/runtime-adapters.md +0 -104
  195. package/skills/backend-developer/.gitkeep +0 -0
  196. package/skills/compliance-expert/.gitkeep +0 -0
  197. package/skills/copywriter/.gitkeep +0 -0
  198. package/skills/db-admin/.gitkeep +0 -0
  199. package/skills/delivery-manager/.gitkeep +0 -0
  200. package/skills/designer/.gitkeep +0 -0
  201. package/skills/devops-engineer/.gitkeep +0 -0
  202. package/skills/engineering-manager/.gitkeep +0 -0
  203. package/skills/frontend-developer/.gitkeep +0 -0
  204. package/skills/growth-expert/.gitkeep +0 -0
  205. package/skills/operation-manager/.gitkeep +0 -0
  206. package/skills/product-manager/.gitkeep +0 -0
  207. package/skills/qa-engineer/.gitkeep +0 -0
  208. package/skills/security-engineer/.gitkeep +0 -0
package/USER-GUIDE.md ADDED
@@ -0,0 +1,505 @@
1
+ # Kortext User Guide
2
+
3
+ This guide is for the **person running Kortext on a project** — not the
4
+ person hacking on Kortext itself. It assumes you can use a terminal, but not
5
+ that you know TypeScript.
6
+
7
+ For the architecture under the hood, see [docs/architecture.md](./docs/architecture.md).
8
+
9
+ ## Table of contents
10
+
11
+ 1. [The mental model](#the-mental-model)
12
+ 2. [Setup](#setup)
13
+ 3. [Writing a blueprint](#writing-a-blueprint)
14
+ 4. [Starting the runtime](#starting-the-runtime)
15
+ 5. [The dashboard, screen by screen](#the-dashboard-screen-by-screen)
16
+ 6. [Approving and rejecting agent decisions](#approving-and-rejecting-agent-decisions)
17
+ 7. [Editing personas and workflows](#editing-personas-and-workflows)
18
+ 8. [Using Kortext from Claude Code or Cursor (MCP)](#using-kortext-from-claude-code-or-cursor-mcp)
19
+ 9. [Notifications (Slack, Telegram)](#notifications-slack-telegram)
20
+ 10. [CLI cheat sheet](#cli-cheat-sheet)
21
+ 11. [Troubleshooting](#troubleshooting)
22
+
23
+ ---
24
+
25
+ ## The mental model
26
+
27
+ Kortext sits between **you** and a team of AI agents. You give it three
28
+ things:
29
+
30
+ 1. **A blueprint** — what you want to build, who it's for, what success looks
31
+ like. Plain markdown.
32
+ 2. **Personas** (preloaded by `kortext init`) — 14 roles like `+architect`,
33
+ `+developer`, `+reviewer`, `+pm`. Each has its own system prompt.
34
+ 3. **Workflows** (also preloaded) — 12 pipelines like `analysis`, `planning`,
35
+ `development`, `testing`, `deployment`. Each is a DAG of steps, with each
36
+ step assigned to a persona.
37
+
38
+ You flip `status: approved` on the blueprint. The orchestrator triggers the
39
+ first workflow. Each step picks the right persona, opens a git worktree,
40
+ calls the right CLI (Claude Code / Codex / Gemini), captures the output,
41
+ runs safety checks, and either advances or pauses for your approval at a
42
+ gate.
43
+
44
+ You watch the dashboard, answer the prompts that surface, and merge what
45
+ ships. The agents handle the rest.
46
+
47
+ ---
48
+
49
+ ## Setup
50
+
51
+ ### Install
52
+
53
+ ```bash
54
+ npm install -g kortext
55
+ kortext --version # → 3.0.0
56
+ ```
57
+
58
+ ### Initialize a project
59
+
60
+ ```bash
61
+ mkdir my-product
62
+ cd my-product
63
+ git init
64
+ kortext init
65
+ ```
66
+
67
+ `kortext init` is idempotent — every file is created only if missing. Re-run
68
+ it safely. If you really want to overwrite local edits with shipped
69
+ templates, use `kortext init --force`.
70
+
71
+ After init you'll have:
72
+
73
+ ```
74
+ my-product/
75
+ ├── .kortext/
76
+ │ ├── kortext.db # SQLite state
77
+ │ └── worktrees/ # per-run git worktrees
78
+ ├── workspace/references/blueprint.md # ← edit this
79
+ ├── agents/*.md # 14 persona definitions
80
+ ├── workflows/*.md # 12 workflow pipelines
81
+ ├── rules/ # behavior, branching, commands
82
+ └── AGENTS.md # pointer file for AI runtimes
83
+ ```
84
+
85
+ ### Install at least one AI CLI
86
+
87
+ Kortext can drive Claude Code, Codex, or Gemini CLI. Install whichever you
88
+ have access to:
89
+
90
+ ```bash
91
+ # Claude Code
92
+ npm install -g @anthropic/claude-code
93
+
94
+ # (Codex / Gemini — follow their respective install instructions)
95
+ ```
96
+
97
+ Verify the binary is on your `$PATH`:
98
+
99
+ ```bash
100
+ which claude # or: which codex / which gemini
101
+ ```
102
+
103
+ If none is installed, you can still smoke-test the pipeline with the mock
104
+ executor — see [Troubleshooting](#troubleshooting).
105
+
106
+ ---
107
+
108
+ ## Writing a blueprint
109
+
110
+ The blueprint lives at `workspace/references/blueprint.md`. Its YAML
111
+ frontmatter holds the lifecycle flag; the body holds the human content.
112
+
113
+ ```markdown
114
+ ---
115
+ status: draft
116
+ project: Acme CRM
117
+ owner: +eray
118
+ ---
119
+
120
+ # Blueprint — Acme CRM
121
+
122
+ ## What we're building
123
+ A B2B CRM for small sales teams. Auth via Auth0, billing via Stripe.
124
+
125
+ ## Personas
126
+ - Sales rep — tracks pipeline, logs calls
127
+ - Sales manager — sees team performance
128
+
129
+ ## Success
130
+ - 100 pilot users in 30 days
131
+ - 80% week-2 retention
132
+
133
+ ## Tech constraints
134
+ - Next.js 15, Node 22, PostgreSQL 16
135
+ - Hosted on Vercel
136
+ ```
137
+
138
+ When you're ready, change the frontmatter:
139
+
140
+ ```diff
141
+ - status: draft
142
+ + status: approved
143
+ ```
144
+
145
+ Save the file. The orchestrator picks up the change within a few seconds
146
+ and triggers the first workflow.
147
+
148
+ > You can also approve from the dashboard (Board view → "Approve blueprint")
149
+ > or via the MCP tool `approve_blueprint`. All three paths write the same
150
+ > frontmatter.
151
+
152
+ ---
153
+
154
+ ## Starting the runtime
155
+
156
+ ```bash
157
+ kortext serve
158
+ ```
159
+
160
+ This starts:
161
+
162
+ - **Backend** on `http://localhost:3200` (Express + SQLite)
163
+ - **Dashboard** on `http://localhost:5173` (Vite + React)
164
+
165
+ In production builds, both are served on the same port:
166
+
167
+ ```bash
168
+ npm run build
169
+ kortext serve --mode=prod
170
+ ```
171
+
172
+ Pick a different port with `--port=8080`. Backend port is also configurable
173
+ via `KORTEXT_PORT=8080`.
174
+
175
+ Stop everything with `Ctrl-C`. Kortext propagates SIGINT to the child
176
+ processes, so neither the backend nor the dashboard is left running.
177
+
178
+ ---
179
+
180
+ ## The dashboard, screen by screen
181
+
182
+ Open `http://localhost:5173`.
183
+
184
+ ### Dashboard
185
+
186
+ Live runs (refreshes every 3 seconds) and the doctor badge (refreshes every
187
+ 10 seconds). The doctor badge turns red if any consistency check fails —
188
+ click it to see why.
189
+
190
+ ### Board
191
+
192
+ Backlog items grouped by status (To do · In progress · Blocked · Review ·
193
+ Done). Click an item to open its detail drawer; the **Approve blueprint**
194
+ button appears here when the blueprint is in draft.
195
+
196
+ ### Memory
197
+
198
+ The `workspace/memory/` markdown files (decisions, learned, handovers),
199
+ rendered safely (marked + DOMPurify). Read-only.
200
+
201
+ ### Reports
202
+
203
+ Generated artifacts under `workspace/reports/`. Each report has a markdown
204
+ body and is linked to a run via `runtime_artifacts`.
205
+
206
+ ### References
207
+
208
+ Your `workspace/references/*.md` — the blueprint, ADRs, anything else you
209
+ add. Same allow-listed `/api/docs/:scope` route as Memory and Reports.
210
+
211
+ ### Settings
212
+
213
+ Eight sub-panes. The two you'll touch most:
214
+
215
+ - **Agents** — inline markdown editor for personas. Edit, save, see the
216
+ registry hot-reload. Validate-before-write means a broken edit is rejected
217
+ before the file is touched.
218
+ - **Workflows** — read-only for now (UI editing lands in v3.1+). Use your
219
+ editor for the markdown.
220
+
221
+ ### Overlays
222
+
223
+ - **Bell** (top right) — pending questions. Red dot when something needs
224
+ you. Click for the popup.
225
+ - **Toasts** — auto-dismiss after 8 seconds. Shows new approvals as they
226
+ arrive.
227
+ - **Terminal panel** (`>_` toggle, top right) — bottom drawer. Live step
228
+ output for runs in progress.
229
+ - **Timeline drawer** (right edge) — reverse-chronological runs and
230
+ handovers.
231
+
232
+ ---
233
+
234
+ ## Approving and rejecting agent decisions
235
+
236
+ Gates appear when a workflow hits a step marked `gate: true` in the
237
+ workflow markdown. The step pauses, a row appears in `pending_questions`,
238
+ the bell turns red, and a toast pops.
239
+
240
+ **To approve:**
241
+
242
+ - **Dashboard:** click the bell → "Approve" → optional comment → submit.
243
+ - **CLI:** `kortext approve <run-id>` (with an optional message).
244
+ - **MCP:** call `respond_to_question` with `{ decision: "approve" }`.
245
+
246
+ The run resumes from the same git worktree, picks up where it paused, and
247
+ continues.
248
+
249
+ **To reject:**
250
+
251
+ - **Dashboard:** click the bell → "Reject" → reason → submit.
252
+ - **CLI:** `kortext approve <run-id> rejected: <reason>`.
253
+ - **MCP:** call `respond_to_question` with `{ decision: "reject", reason }`.
254
+
255
+ A rejected run flips to `cancelled` with `error_message: rejected: <reason>`.
256
+ The worktree is moved to quarantine for postmortem. Nothing else
257
+ downstream runs.
258
+
259
+ > **Tip:** if you're not sure what the gate is asking, click into the run
260
+ > from the Dashboard. The drawer shows the step log, the persona's
261
+ > reasoning, and the proposed next action.
262
+
263
+ ---
264
+
265
+ ## Editing personas and workflows
266
+
267
+ ### Personas
268
+
269
+ ```
270
+ agents/+architect.md
271
+ agents/+developer.md
272
+
273
+ ```
274
+
275
+ Each file is markdown with YAML frontmatter:
276
+
277
+ ```markdown
278
+ ---
279
+ handle: +developer
280
+ model: claude-sonnet-4
281
+ executor: claude
282
+ escalate_to: [+architect, +prime]
283
+ ---
284
+
285
+ # +developer
286
+
287
+ You are a senior software engineer …
288
+ ```
289
+
290
+ Edit either in your editor or in **Settings → Agents** in the dashboard. The
291
+ registry hot-reloads — no restart needed. The `executor:` field decides
292
+ which CLI runs steps assigned to this persona.
293
+
294
+ ### Workflows
295
+
296
+ ```
297
+ workflows/01-analysis.md
298
+ workflows/02-planning.md
299
+
300
+ ```
301
+
302
+ Each is a step list with declared inputs / outputs. The engine builds the
303
+ DAG from `outputs:` → `inputs:` matching; you don't write dependencies by
304
+ hand.
305
+
306
+ ```markdown
307
+ ---
308
+ id: planning
309
+ nextWorkflowId: development
310
+ gates:
311
+ - after: spec_review
312
+ ---
313
+
314
+ ## Steps
315
+
316
+ ### gather_requirements
317
+ - persona: +pm
318
+ - inputs: [blueprint.md]
319
+ - outputs: [requirements.md]
320
+
321
+ ### draft_spec
322
+ - persona: +architect
323
+ - inputs: [requirements.md]
324
+ - outputs: [spec.md]
325
+
326
+ ### spec_review
327
+ - persona: +reviewer
328
+ - inputs: [spec.md]
329
+ - outputs: [review.md]
330
+ - gate: true
331
+ ```
332
+
333
+ The `gate: true` line is what pauses the run for your approval.
334
+
335
+ ---
336
+
337
+ ## Using Kortext from Claude Code or Cursor (MCP)
338
+
339
+ Add Kortext as an MCP server:
340
+
341
+ ```bash
342
+ # Claude Code
343
+ claude mcp add kortext -- npx kortext mcp
344
+
345
+ # Cursor — add to ~/.cursor/mcp.json
346
+ {
347
+ "mcpServers": {
348
+ "kortext": {
349
+ "command": "npx",
350
+ "args": ["kortext", "mcp"]
351
+ }
352
+ }
353
+ }
354
+ ```
355
+
356
+ The 15 tools you'll have access to:
357
+
358
+ | Group | Tools |
359
+ |---|---|
360
+ | **Workflow** | `list_workflows`, `list_personas`, `list_pipelines`, `get_pipeline`, `start_pipeline` |
361
+ | **Backlog** | `list_backlog`, `add_backlog_item`, `transition_item` |
362
+ | **Approval** | `list_pending_questions`, `respond_to_question` |
363
+ | **Context** | `get_context`, `handover`, `get_logs` |
364
+ | **Blueprint** | `read_blueprint`, `approve_blueprint` |
365
+ | **Health** | `get_runtime_status` |
366
+
367
+ From inside Claude Code:
368
+
369
+ > Use the `kortext` MCP server: list pending questions, summarize them, and
370
+ > approve any that look safe to me.
371
+
372
+ ---
373
+
374
+ ## Notifications (Slack, Telegram)
375
+
376
+ Set environment variables, then restart `kortext serve`:
377
+
378
+ ```bash
379
+ # Slack
380
+ export SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T.../B.../...
381
+
382
+ # Telegram
383
+ export TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
384
+ export TELEGRAM_CHAT_ID=-100123456789
385
+ ```
386
+
387
+ The dispatcher posts on:
388
+
389
+ - Blueprint approval
390
+ - Pipeline start / completion
391
+ - Step failure
392
+ - Pending question waiting for `+prime` (you)
393
+
394
+ Notifications are deduplicated by `(channel, kind, resource_id)` — restarting
395
+ the runtime won't replay every old event.
396
+
397
+ ---
398
+
399
+ ## CLI cheat sheet
400
+
401
+ ```bash
402
+ kortext init [--force] # scaffold project
403
+ kortext serve [--mode=…] [--port=N] # backend + dashboard
404
+ kortext start <workflow-id> [--executor=mock|claude|codex|gemini]
405
+ kortext approve <run-id> [answer] # respond to a pending question
406
+ kortext status # recent runs + open questions
407
+ kortext logs [--limit=N] [--actor=…] [--action=…] [--resource-type/-id=…]
408
+ kortext cleanup [--quarantine-older-than=Nd] [--branches] [--dry-run]
409
+ kortext doctor # workflow / persona / lock consistency
410
+ kortext mcp # stdio MCP server
411
+ kortext --help | --version
412
+ ```
413
+
414
+ ---
415
+
416
+ ## Troubleshooting
417
+
418
+ ### "Blueprint approved but nothing happened"
419
+
420
+ - Check `workspace/references/blueprint.md` frontmatter — the orchestrator
421
+ parses `status:` from YAML, not from a markdown comment.
422
+ - Tail the logs: `kortext logs --action=blueprint.watcher --limit=20`.
423
+ - Confirm the runtime is actually running: `curl localhost:3200/api/health`.
424
+
425
+ ### "A run is stuck in `running` after I restarted the backend"
426
+
427
+ That run is **orphaned**. On the next server boot the resume layer marks it
428
+ `cancelled` with `error_message: orphaned: server restarted` and lets you
429
+ retry it from the same worktree:
430
+
431
+ ```bash
432
+ # Find the orphaned run
433
+ kortext status
434
+ # Retry it
435
+ kortext start <workflow-id> --retry <run-id>
436
+ ```
437
+
438
+ ### "I want to dry-run without burning AI tokens"
439
+
440
+ ```bash
441
+ kortext start <workflow-id> --executor=mock
442
+ ```
443
+
444
+ Mock executor runs everything in-process, fills in placeholder outputs, and
445
+ exercises the worker pool, gate, safety, and approval surfaces without
446
+ calling any real CLI.
447
+
448
+ ### "Worktrees are piling up in `.kortext/worktrees/`"
449
+
450
+ Failed runs intentionally leave their worktree under
451
+ `.kortext/worktrees/quarantine/run-<id>-<timestamp>/` plus the
452
+ `kortext/run-<id>` branch — for postmortem. Once you've reviewed them, clean
453
+ up:
454
+
455
+ ```bash
456
+ # Preview
457
+ kortext cleanup --quarantine-older-than=7d --branches --dry-run
458
+ # Actually delete
459
+ kortext cleanup --quarantine-older-than=7d --branches
460
+ ```
461
+
462
+ ### "The dashboard shows stale data"
463
+
464
+ Polling is 3s for runs and 10s for the doctor. A hard reload
465
+ (`Cmd-Shift-R` / `Ctrl-Shift-R`) clears the TanStack Router cache too — use
466
+ that after any router-shape changes.
467
+
468
+ ### "MCP stdio server is dropping the connection"
469
+
470
+ The stdio transport uses **stdout for JSONRPC frames**. A single rogue
471
+ `console.log` anywhere in the server tree breaks the protocol. v3 patches
472
+ this at startup (`bin/kortext.ts mcp` re-routes `console.log` →
473
+ `console.error`), but a downstream library that writes to stdout directly
474
+ can still break it. Run with `KORTEXT_MCP_DEBUG=1` to see stderr in the
475
+ host's log.
476
+
477
+ ### "`npx kortext` is slow to start"
478
+
479
+ In dev (no `dist/` present), `bin/kortext.js` falls back to `tsx`, which
480
+ adds a ~200ms hop. After `npm run build` the shim prefers the compiled
481
+ `dist/bin/kortext.js` and skips the hop. CI publishes pre-built artifacts,
482
+ so installed users always get the fast path.
483
+
484
+ ### "Where's the database?"
485
+
486
+ `.kortext/kortext.db`. Set `KORTEXT_DB_PATH` to override. The schema is
487
+ documented in [docs/architecture.md](./docs/architecture.md).
488
+
489
+ ### "I edited a persona but the change didn't apply"
490
+
491
+ The PersonaRegistry mutates its map in-place — readers see the new content
492
+ immediately. If you suspect a stale cache, hit `GET /api/personas/<handle>`
493
+ and confirm the body matches the file. If it does, the runtime has the
494
+ update; if it doesn't, your edit failed validation (the PUT route
495
+ validates parsing before writing).
496
+
497
+ ---
498
+
499
+ ## Where next
500
+
501
+ - [Architecture](./docs/architecture.md) — schema, engine internals
502
+ - [Changelog](./CHANGELOG.md) — release notes
503
+
504
+ For bug reports and feature requests, open an issue on
505
+ [GitHub](https://github.com/erayendes/kortext/issues).
package/bin/kortext.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ // Dual-mode entry: prefer the compiled JS when `dist/bin/kortext.js` is
3
+ // present (production install via `npm run build`), fall back to tsx in
4
+ // development so contributors can `npx kortext …` against source.
5
+ import { existsSync } from 'node:fs';
6
+ import { spawnSync } from 'node:child_process';
7
+ import { fileURLToPath, pathToFileURL } from 'node:url';
8
+ import { dirname, resolve } from 'node:path';
9
+
10
+ const here = dirname(fileURLToPath(import.meta.url));
11
+ const compiled = resolve(here, '..', 'dist', 'bin', 'kortext.js');
12
+
13
+ if (existsSync(compiled)) {
14
+ // Run in-process — no tsx hop, no extra startup cost.
15
+ await import(pathToFileURL(compiled).href);
16
+ } else {
17
+ const tsEntry = resolve(here, 'kortext.ts');
18
+ const result = spawnSync('npx', ['tsx', tsEntry, ...process.argv.slice(2)], {
19
+ stdio: 'inherit',
20
+ shell: false,
21
+ });
22
+ process.exit(result.status ?? 1);
23
+ }