cortex-agents 3.4.0 → 4.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 (48) hide show
  1. package/.opencode/agents/architect.md +81 -89
  2. package/.opencode/agents/audit.md +57 -188
  3. package/.opencode/agents/{crosslayer.md → coder.md} +8 -52
  4. package/.opencode/agents/debug.md +151 -0
  5. package/.opencode/agents/devops.md +142 -0
  6. package/.opencode/agents/docs-writer.md +195 -0
  7. package/.opencode/agents/fix.md +118 -189
  8. package/.opencode/agents/implement.md +114 -74
  9. package/.opencode/agents/perf.md +151 -0
  10. package/.opencode/agents/refactor.md +163 -0
  11. package/.opencode/agents/{guard.md → security.md} +20 -85
  12. package/.opencode/agents/testing.md +115 -0
  13. package/.opencode/skills/data-engineering/SKILL.md +221 -0
  14. package/.opencode/skills/monitoring-observability/SKILL.md +251 -0
  15. package/README.md +302 -287
  16. package/dist/cli.js +6 -9
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +26 -28
  19. package/dist/registry.d.ts +4 -4
  20. package/dist/registry.d.ts.map +1 -1
  21. package/dist/registry.js +6 -6
  22. package/dist/tools/branch.d.ts +2 -2
  23. package/dist/tools/docs.d.ts +2 -2
  24. package/dist/tools/github.d.ts +3 -3
  25. package/dist/tools/plan.d.ts +28 -4
  26. package/dist/tools/plan.d.ts.map +1 -1
  27. package/dist/tools/plan.js +232 -4
  28. package/dist/tools/quality-gate.d.ts +28 -0
  29. package/dist/tools/quality-gate.d.ts.map +1 -0
  30. package/dist/tools/quality-gate.js +233 -0
  31. package/dist/tools/repl.d.ts +5 -0
  32. package/dist/tools/repl.d.ts.map +1 -1
  33. package/dist/tools/repl.js +58 -7
  34. package/dist/tools/worktree.d.ts +5 -32
  35. package/dist/tools/worktree.d.ts.map +1 -1
  36. package/dist/tools/worktree.js +75 -458
  37. package/dist/utils/change-scope.d.ts +33 -0
  38. package/dist/utils/change-scope.d.ts.map +1 -0
  39. package/dist/utils/change-scope.js +198 -0
  40. package/dist/utils/plan-extract.d.ts +21 -0
  41. package/dist/utils/plan-extract.d.ts.map +1 -1
  42. package/dist/utils/plan-extract.js +65 -0
  43. package/dist/utils/repl.d.ts +31 -0
  44. package/dist/utils/repl.d.ts.map +1 -1
  45. package/dist/utils/repl.js +126 -13
  46. package/package.json +1 -1
  47. package/.opencode/agents/qa.md +0 -265
  48. package/.opencode/agents/ship.md +0 -249
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="https://img.shields.io/badge/cortex-agents-111?style=for-the-badge&labelColor=111&color=4d96ff" alt="cortex-agents" height="40">
3
3
  </p>
4
4
 
5
- <h3 align="center">Supercharge OpenCode with structured workflows, intelligent agents, and automated development practices.</h3>
5
+ <h3 align="center">Structured AI development workflows for <a href="https://opencode.ai">OpenCode</a>.<br>Plan. Build. Ship. With discipline.</h3>
6
6
 
7
7
  <p align="center">
8
8
  <a href="https://www.npmjs.com/package/cortex-agents"><img src="https://img.shields.io/npm/v/cortex-agents.svg?style=flat-square&color=4d96ff" alt="npm version"></a>
@@ -12,238 +12,242 @@
12
12
  </p>
13
13
 
14
14
  <p align="center">
15
- <a href="#-quick-start">Quick Start</a>&nbsp;&nbsp;|&nbsp;&nbsp;
16
- <a href="#-what-it-does">What It Does</a>&nbsp;&nbsp;|&nbsp;&nbsp;
17
- <a href="#-agents">Agents</a>&nbsp;&nbsp;|&nbsp;&nbsp;
18
- <a href="#-tools">Tools</a>&nbsp;&nbsp;|&nbsp;&nbsp;
19
- <a href="#-skills">Skills</a>&nbsp;&nbsp;|&nbsp;&nbsp;
15
+ <a href="#-quick-start">Quick Start</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;
16
+ <a href="#-architecture">Architecture</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;
17
+ <a href="#-agents">Agents</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;
18
+ <a href="#-tools">Tools</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;
19
+ <a href="#-skills">Skills</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;
20
20
  <a href="#-contributing">Contributing</a>
21
21
  </p>
22
22
 
23
- <br>
24
-
25
23
  ---
26
24
 
27
- <br>
28
-
29
25
  ## Why Cortex Agents?
30
26
 
31
27
  AI coding assistants are powerful, but without structure they produce inconsistent results. **Cortex Agents** adds the missing layer: a complete development workflow that turns OpenCode into a disciplined engineering partner.
32
28
 
33
- - **Before**: AI writes code wherever, no branching discipline, no documentation, no plan.
34
- - **After**: AI checks git status, asks about branching strategy, loads implementation plans, creates docs with architecture diagrams, commits cleanly, and opens PRs.
29
+ ```
30
+ Before After
31
+ ────── ─────
32
+ AI writes code wherever AI checks git status first
33
+ No branching discipline Creates worktrees/branches automatically
34
+ No documentation Generates docs with mermaid diagrams
35
+ No quality checks Runs parallel quality gates (6 sub-agents)
36
+ No plan, no traceability Plans with acceptance criteria, ships PRs
37
+ ```
35
38
 
36
- <br>
39
+ ---
37
40
 
38
41
  ## Quick Start
39
42
 
40
43
  ```bash
41
44
  npx cortex-agents install # Add plugin + agents + skills
42
45
  npx cortex-agents configure # Pick your models interactively
43
- # Restart OpenCode - done.
46
+ # Restart OpenCode done.
44
47
  ```
45
48
 
46
- That's it. Your OpenCode session now has 8 specialized agents, 32 tools, and 14 domain skills.
49
+ Your OpenCode session now has **12 specialized agents**, **33 tools**, and **16 domain skills**.
47
50
 
48
- > **Built-in Agent Replacement** — When installed, cortex-agents automatically disables OpenCode's native `build` and `plan` agents (replaced by `implement` and `architect`). The `architect` agent becomes the default, promoting a planning-first workflow. Native agents are fully restored on `uninstall`.
51
+ > **Built-in Agent Replacement** — Cortex automatically disables OpenCode's native `build` and `plan` agents (replaced by `implement` and `architect`). The `architect` agent becomes the default, promoting a planning-first workflow. Native agents are fully restored on `uninstall`.
49
52
 
50
- <br>
53
+ ---
51
54
 
52
- ## What It Does
55
+ ## Architecture
53
56
 
54
- ### Plan, Build, Ship
57
+ ### Agent Hierarchy
55
58
 
56
- Cortex agents follow a structured workflow from planning through to PR:
59
+ ```
60
+ User Request
61
+ |
62
+ v
63
+ Architect (read-only planning)
64
+ |
65
+ |-- read-only analysis -----> @security @coder @perf
66
+ |
67
+ v
68
+ Implement / Fix (execution)
69
+ |
70
+ |-- REPL Loop (task-by-task) --> build + test per task
71
+ |
72
+ v
73
+ Quality Gate (two-phase)
74
+ |
75
+ |-- Phase 1 (parallel, scope-based):
76
+ | @testing @security @audit @docs-writer @devops @perf
77
+ |
78
+ |-- Phase 2 (cross-agent):
79
+ | @testing reacts to @security findings
80
+ |
81
+ v
82
+ quality_gate_summary --> GO / NO-GO / GO-WITH-WARNINGS
83
+ |
84
+ v
85
+ Fix blockers --> task_finalize --> PR
86
+ ```
87
+
88
+ ### The Workflow
57
89
 
58
90
  ```
59
91
  You: "Add user authentication"
60
92
 
61
93
  Architect Agent reads codebase, creates plan with mermaid diagrams
62
- saves to .cortex/plans/ "Plan saved. Switch to Implement?"
94
+ saves to .cortex/plans/ commits plan to feature branch
95
+ "Plan committed. Switch to offers worktree or branch
96
+ Implement?"
63
97
 
64
98
  Implement Agent loads plan, checks git status
65
- "You're on main. Create a branch two-step prompt: strategy -> execution
66
- or worktree?"
67
- creates feature/user-auth implements following the plan
68
- "Ready to finalize?" stages, commits, pushes, opens PR
69
- ```
70
-
71
- ### Worktree Launcher
72
-
73
- Create isolated development environments and launch them instantly:
74
-
75
- | Mode | What Happens |
76
- |------|-------------|
77
- | **IDE Terminal** | Opens in your detected IDE (VS Code, Cursor, Windsurf, Zed) with integrated terminal |
78
- | **New Terminal** | Opens a new terminal tab with OpenCode pre-configured in the worktree |
79
- | **In-App PTY** | Spawns an embedded terminal inside your current OpenCode session |
80
- | **Background** | AI implements headlessly while you keep working - toast notifications on completion |
81
-
82
- Plans are automatically propagated into the worktree's `.cortex/plans/` so the new session has full context.
83
-
84
- **IDE-Aware Launch Options** — The launcher detects your development environment and offers contextual options:
85
- - **VS Code / Cursor / Windsurf / Zed**: "Open in [IDE] (Recommended)" as the first option
86
- - **JetBrains IDEs**: Terminal tab with manual IDE opening instructions
87
- - **Terminal only**: Standard terminal tab options
88
-
89
- **Cross-platform terminal support** via the terminal driver system — automatically detects and integrates with VS Code, Cursor, Windsurf, Zed, JetBrains IDEs, tmux, iTerm2, Terminal.app, kitty, wezterm, Konsole, and GNOME Terminal. Tabs opened by the launcher are tracked and automatically closed when the worktree is removed.
90
-
91
- ### Task Finalizer
92
-
93
- One tool to close the loop:
94
-
95
- ```
96
- task_finalize
97
- git add -A
98
- git commit -m "feat: add user auth"
99
- git push -u origin feature/user-auth
100
- gh pr create --base main auto-detected if in worktree
101
- PR body auto-populated from .cortex/plans/
102
- "PR created! Clean up worktree?"
99
+ repl_init parses tasks + ACs iterates task-by-task with build+test
100
+ Quality Gate → 6 agents in parallel testing + security + audit + docs + devops + perf
101
+ quality_gate_summary → GO aggregates findings, recommends go/no-go
102
+ task_finalize stages, commits, pushes, opens PR
103
103
  ```
104
104
 
105
- ### Auto-Prompted Documentation
105
+ ### Scope-Based Quality Gate
106
106
 
107
- After every task, agents prompt you to document what you built:
107
+ Not every change needs a full audit. The quality gate scales with risk:
108
108
 
109
- | Type | What's Generated | Includes |
110
- |------|-----------------|----------|
111
- | **Decision** | Architecture Decision Record | Mermaid graph comparing options |
112
- | **Feature** | Feature documentation | Mermaid component diagram |
113
- | **Flow** | Process/data flow doc | Mermaid sequence diagram |
109
+ | Scope | Criteria | Sub-Agents Launched |
110
+ |-------|----------|-------------------|
111
+ | **Trivial** | Docs, comments, formatting | `@docs-writer` only (or skip) |
112
+ | **Low** | Tests, config files | `@testing` |
113
+ | **Standard** | Normal code changes | `@testing` + `@security` + `@audit` + `@docs-writer` |
114
+ | **High** | Auth, payments, crypto, infra, DB migrations | All 6: `@testing` + `@security` + `@audit` + `@docs-writer` + `@devops` + `@perf` |
114
115
 
115
- All docs are saved to `docs/` with an auto-generated `INDEX.md`.
116
-
117
- <br>
116
+ ---
118
117
 
119
118
  ## Agents
120
119
 
121
- ### Primary Agents
120
+ ### Primary Agents (3)
122
121
 
123
122
  Handle complex, multi-step work. Use your best model.
124
123
 
125
- | Agent | Role | Superpower |
126
- |-------|------|-----------|
127
- | **implement** | Full-access development | Skill-aware implementation, worktree launcher, quality gates, task finalizer |
128
- | **architect** | Read-only analysis | Architectural plans with mermaid diagrams, NFR analysis, hands off to implement |
129
- | **fix** | Deep troubleshooting | Performance debugging, distributed tracing, hotfix workflow |
130
- | **audit** | Code quality assessment | Tech debt scoring, pattern review, refactoring advisor (read-only) |
124
+ | Agent | Role | Key Capabilities |
125
+ |-------|------|-----------------|
126
+ | **architect** | Read-only analysis & planning | Plans with mermaid diagrams, acceptance criteria, NFR analysis. Commits plans to branches. Delegates read-only analysis to `@security`, `@coder`, `@perf`. |
127
+ | **implement** | Full-access development | Skill-aware implementation, REPL loop with ACs, two-phase quality gate, parallel sub-agent orchestration, task finalizer. |
128
+ | **fix** | Quick turnaround bug fixes | Rapid diagnosis, scope-based quality gate, optional REPL loop. Delegates deep debugging to `@debug`. |
131
129
 
132
- ### Subagents
130
+ ### Sub-Agents (9)
133
131
 
134
- Focused specialists launched **automatically** as parallel quality gates. Each auto-loads its core domain skill for deeper analysis. Use a fast/cheap model.
132
+ Focused specialists launched **automatically** by primary agents. Each auto-loads domain skills for deeper analysis. Use a fast/cheap model.
135
133
 
136
134
  | Agent | Role | Auto-Loads Skill | Triggered By |
137
135
  |-------|------|-----------------|-------------|
138
- | **@qa** | Writes tests, runs suite, reports coverage | `testing-strategies` | Implement (always), Fix (always) |
139
- | **@guard** | OWASP audit, secrets scan, code-level fix patches | `security-hardening` | Implement (always), Fix (if security-relevant) |
140
- | **@crosslayer** | Cross-layer implementation + feasibility analysis | Per-layer skills | Implement (multi-layer features), Architect (analysis) |
141
- | **@ship** | CI/CD validation, IaC review, deployment strategy | `deployment-automation` | Implement (when CI/Docker/infra files change) |
142
-
143
- Subagents return **structured reports** with severity levels (`BLOCKING`, `CRITICAL`, `HIGH`, `MEDIUM`, `LOW`) that the orchestrating agent uses to decide whether to proceed or fix issues first.
136
+ | **@testing** | Test writing, suite execution, coverage | `testing-strategies` | Implement (standard+high), Fix (low+standard+high) |
137
+ | **@security** | OWASP audit, secrets scan, threat modeling | `security-hardening` | Implement (standard+high), Fix (standard+high), Architect (read-only) |
138
+ | **@audit** | Code quality, tech debt, pattern review | `code-quality` | Implement (standard+high) |
139
+ | **@docs-writer** | Auto-documentation generation | | Implement (standard+high) |
140
+ | **@perf** | Complexity analysis, N+1 detection, bundle impact | `performance-optimization` | Implement (high), Fix (high), Architect (read-only) |
141
+ | **@devops** | CI/CD validation, IaC review | `deployment-automation` | Implement (high, or infra files changed) |
142
+ | **@coder** | Cross-layer implementation, feasibility | Per-layer skills | Implement (3+ layers), Architect (feasibility analysis) |
143
+ | **@refactor** | Behavior-preserving restructuring | `design-patterns` + `code-quality` | Implement (refactor plans) |
144
+ | **@debug** | Root cause analysis, troubleshooting | `testing-strategies` | Fix (complex issues) |
145
+
146
+ Sub-agents return **structured reports** with severity levels (`BLOCKING`, `CRITICAL`, `HIGH`, `MEDIUM`, `LOW`) that the orchestrating agent uses to decide whether to proceed or fix issues first.
144
147
 
145
148
  ### Skill Routing
146
149
 
147
- All agents detect the project's technology stack and **automatically load relevant skills** before working. This turns the 14 domain skills from passive knowledge into active intelligence:
150
+ All agents detect the project's technology stack and **automatically load relevant skills** before working:
148
151
 
149
152
  ```
150
153
  Implement Agent detects: package.json has React + Express + Prisma
151
- auto-loads: frontend-development, backend-development, database-design, api-design
152
- implements with deep framework-specific knowledge
154
+ -> auto-loads: frontend-development, backend-development, database-design, api-design
155
+ -> implements with deep framework-specific knowledge
153
156
  ```
154
157
 
155
- <br>
158
+ ---
156
159
 
157
160
  ## Tools
158
161
 
159
- 32 tools bundled and auto-registered. No configuration needed.
162
+ 33 tools bundled and auto-registered. No configuration needed.
160
163
 
161
164
  <table>
162
165
  <tr><td width="50%">
163
166
 
164
167
  **Git Workflow**
165
- - `branch_status` - Current branch + change detection
166
- - `branch_create` - Convention-named branches (with toast notifications)
167
- - `branch_switch` - Safe branch switching
168
- - `worktree_create` - Isolated worktree in `.worktrees/` (with toast notifications)
169
- - `worktree_launch` - Launch worktree (terminal/PTY/background)
168
+ - `branch_status` Current branch + change detection
169
+ - `branch_create` Convention-named branches (with toast)
170
+ - `branch_switch` Safe branch switching
171
+ - `worktree_create` Isolated worktree in `.worktrees/`
170
172
  - `worktree_list` / `worktree_remove` / `worktree_open`
171
173
 
172
174
  </td><td width="50%">
173
175
 
174
176
  **Planning & Sessions**
175
177
  - `plan_save` / `plan_load` / `plan_list` / `plan_delete`
178
+ - `plan_commit` — Commit plan to feature branch
176
179
  - `session_save` / `session_list` / `session_load`
177
180
  - `cortex_init` / `cortex_status` / `cortex_configure`
178
- - `detect_environment` - Detect IDE/terminal for contextual launch options
179
181
 
180
182
  </td></tr>
181
183
  <tr><td width="50%">
182
184
 
183
185
  **Documentation**
184
- - `docs_init` - Set up `docs/` structure
185
- - `docs_save` - Save doc with mermaid diagrams
186
- - `docs_list` - Browse all docs
187
- - `docs_index` - Rebuild `docs/INDEX.md`
186
+ - `docs_init` Set up `docs/` structure
187
+ - `docs_save` Save doc with mermaid diagrams
188
+ - `docs_list` Browse all docs
189
+ - `docs_index` Rebuild `docs/INDEX.md`
188
190
 
189
191
  </td><td width="50%">
190
192
 
191
- **Finalization & Config**
192
- - `task_finalize` - Stage, commit, push, create PR
193
+ **Finalization**
194
+ - `task_finalize` Stage, commit, push, create PR
193
195
  - Auto-detects worktree (targets main)
194
196
  - Auto-populates PR from `.cortex/plans/`
195
- - Auto-links issues via `Closes #N` from plan metadata
196
- - Warns if docs are missing
197
- - `cortex_configure` - Set models from within an agent session
197
+ - Auto-links issues via `Closes #N`
198
+ - `quality_gate_summary` Aggregate sub-agent findings, GO/NO-GO recommendation
198
199
 
199
200
  </td></tr>
200
201
  <tr><td colspan="2">
201
202
 
202
203
  **GitHub Integration**
203
- - `github_status` - Check `gh` CLI availability, authentication, and detect GitHub Projects
204
- - `github_issues` - List/filter repo issues by state, labels, milestone, assignee
205
- - `github_projects` - List GitHub Project boards and their work items
204
+ - `github_status` Check `gh` CLI availability, auth, and detect projects
205
+ - `github_issues` List/filter repo issues by state, labels, milestone, assignee
206
+ - `github_projects` List GitHub Project boards and their work items
206
207
 
207
- The architect agent uses these tools to browse your backlog and seed plans from real GitHub issues. Issue numbers are stored in plan frontmatter (`issues: [42, 51]`) and automatically appended as `Closes #N` to the PR body when `task_finalize` runs — GitHub auto-closes the issues when the PR merges. Supports both github.com and GitHub Enterprise Server URLs.
208
+ The architect uses these to browse your backlog and seed plans from real issues. Issue numbers stored in plan frontmatter (`issues: [42, 51]`) are automatically appended as `Closes #N` to the PR body.
208
209
 
209
210
  </td></tr>
210
211
  <tr><td colspan="2">
211
212
 
212
- **REPL Loop** (Iterative Task-by-Task Implementation)
213
- - `repl_init` - Initialize a loop from a plan (parses tasks, auto-detects build/test commands)
214
- - `repl_status` - Get current progress, active task, retry counts (auto-advances to next task)
215
- - `repl_report` - Report task outcome (`pass`/`fail`/`skip`) with auto-retry and escalation
216
- - `repl_summary` - Generate markdown summary table for PR body
213
+ **REPL Loop** Iterative task-by-task implementation
214
+ - `repl_init` Initialize loop from plan (parses tasks + ACs, auto-detects build/test)
215
+ - `repl_status` Current progress, active task with ACs, retry counts
216
+ - `repl_report` Report outcome (`pass`/`fail`/`skip`) with auto-retry and escalation
217
+ - `repl_resume` Detect and resume interrupted loop from previous session
218
+ - `repl_summary` — Markdown results table with AC satisfaction for PR body
217
219
 
218
- The implement agent uses these tools to work through plan tasks one at a time, running build+test verification after each task. Failed tasks are automatically retried (up to a configurable limit) before escalating to the user. State is persisted to `.cortex/repl-state.json` so progress survives context compaction and session restarts.
220
+ State persists to `.cortex/repl-state.json` survives context compaction, session restarts, and agent switches.
219
221
 
220
222
  </td></tr>
221
223
  </table>
222
224
 
223
- <br>
225
+ ---
224
226
 
225
227
  ## Skills
226
228
 
227
- 14 domain-specific skill packs loaded on demand via the `skill` tool:
229
+ 16 domain-specific skill packs loaded on demand:
228
230
 
229
231
  | Skill | Covers |
230
232
  |-------|--------|
231
- | **frontend-development** | React, Vue, Svelte, CSS architecture, accessibility |
232
- | **backend-development** | API design, middleware, auth, caching, queue systems |
233
- | **mobile-development** | React Native, Flutter, native iOS/Android patterns |
234
- | **desktop-development** | Electron, Tauri, native desktop application patterns |
235
- | **database-design** | Schema design, migrations, indexing, query optimization |
236
- | **api-design** | REST, GraphQL, gRPC, versioning, documentation |
237
- | **testing-strategies** | Unit, integration, E2E, TDD, coverage strategies |
238
- | **security-hardening** | OWASP, auth/authz, input validation, secure coding |
239
- | **deployment-automation** | CI/CD, Docker, Kubernetes, cloud deployment |
240
- | **architecture-patterns** | Microservices, monorepo, event-driven, CQRS |
241
- | **design-patterns** | GoF patterns, SOLID principles, DDD |
242
- | **performance-optimization** | Profiling, caching, lazy loading, bundle optimization |
243
- | **code-quality** | Refactoring, linting, code review, maintainability |
244
- | **git-workflow** | Branching strategies, worktrees, rebase vs merge |
245
-
246
- <br>
233
+ | `frontend-development` | React, Vue, Svelte, CSS architecture, accessibility |
234
+ | `backend-development` | API design, middleware, auth, caching, queue systems |
235
+ | `mobile-development` | React Native, Flutter, native iOS/Android patterns |
236
+ | `desktop-development` | Electron, Tauri, native desktop application patterns |
237
+ | `database-design` | Schema design, migrations, indexing, query optimization |
238
+ | `api-design` | REST, GraphQL, gRPC, versioning, documentation |
239
+ | `testing-strategies` | Unit, integration, E2E, TDD, coverage strategies |
240
+ | `security-hardening` | OWASP, auth/authz, input validation, secure coding |
241
+ | `deployment-automation` | CI/CD, Docker, Kubernetes, cloud deployment |
242
+ | `architecture-patterns` | Microservices, monorepo, event-driven, CQRS |
243
+ | `design-patterns` | GoF patterns, SOLID principles, DDD |
244
+ | `performance-optimization` | Profiling, caching, lazy loading, bundle optimization |
245
+ | `code-quality` | Refactoring, linting, code review, maintainability |
246
+ | `git-workflow` | Branching strategies, worktrees, rebase vs merge |
247
+ | `monitoring-observability` | Structured logging, metrics, distributed tracing, health checks |
248
+ | `data-engineering` | ETL pipelines, data validation, streaming, message queues, partitioning |
249
+
250
+ ---
247
251
 
248
252
  ## Model Configuration
249
253
 
@@ -255,7 +259,7 @@ npx cortex-agents configure --project # Per-project (saves to .opencode/models.
255
259
  ```
256
260
 
257
261
  ```
258
- ? Select model for PRIMARY agents:
262
+ ? Select model for PRIMARY agents (architect, implement, fix):
259
263
  Claude Sonnet 4 (anthropic) Best balance of intelligence and speed
260
264
  Claude Opus 4 (anthropic) Most capable, best for complex architecture
261
265
  GPT-4.1 (openai) Fast multimodal model
@@ -263,40 +267,97 @@ npx cortex-agents configure --project # Per-project (saves to .opencode/models.
263
267
  Kimi K2P5 (kimi) Optimized for code generation
264
268
  Enter custom model ID
265
269
 
266
- ? Select model for SUBAGENTS:
270
+ ? Select model for SUBAGENTS (debug, coder, testing, security, devops, audit, ...):
267
271
  Claude 3.5 Haiku (anthropic) Fast and cost-effective
268
272
  o4 Mini (openai) Fast reasoning, cost-effective
269
273
  Gemini 2.5 Flash (google) Fast and efficient
270
274
  Same as primary
271
275
  ```
272
276
 
273
- ### In-Agent Configuration
277
+ Agents can also configure models mid-session via `cortex_configure` — no need to leave OpenCode.
278
+
279
+ > Don't see your provider in the picker? Select **"Enter custom model ID"** and type any `provider/model` string.
280
+
281
+ ---
282
+
283
+ ## How It Works
284
+
285
+ ### Implement Agent — Step by Step
274
286
 
275
- Agents can also configure models during a session via the `cortex_configure` tool — no need to leave OpenCode. The agent will prompt you to select models when `.cortex/` is first initialized.
287
+ ```
288
+ Step 1 branch_status Am I on a protected branch?
289
+ Step 2 cortex_status Is .cortex initialized?
290
+ Step 3 plan_list / plan_load Is there a plan for this work?
291
+ Step 4 Ask: strategy Worktree (recommended) or branch?
292
+ Step 5 Execute Create worktree/branch
293
+ Step 6 REPL Loop repl_init -> iterate tasks one-by-one
294
+ 6a repl_init Parse tasks + ACs, detect build/test commands
295
+ 6b repl_status Get current task with ACs, auto-advance
296
+ 6c Implement task Write code to satisfy acceptance criteria
297
+ 6d Build + test Run detected build/test commands
298
+ 6e repl_report Report pass/fail/skip -> auto-advance or retry
299
+ 6f Loop Repeat 6b-6e until all tasks complete
300
+ Step 7 Quality Gate Two-phase sub-agent review (scope-based)
301
+ 7a repl_summary Generate loop results
302
+ 7b Assess scope Classify changed files by risk tier
303
+ 7c Phase 1 Launch sub-agents in parallel
304
+ 7d Phase 2 Cross-agent reactions (@testing <- @security)
305
+ 7e quality_gate_summary Aggregate findings -> GO / NO-GO
306
+ Step 8 Documentation Review @docs-writer output or prompt user
307
+ Step 9 session_save Record what was done and why
308
+ Step 10 task_finalize Commit, push, create PR (with quality gate in body)
309
+ Step 11 Cleanup Remove worktree if applicable
310
+ ```
276
311
 
277
- ### Per-Project vs Global
312
+ ### REPL Loop Example
278
313
 
279
- | Scope | Where | Use Case |
280
- |-------|-------|----------|
281
- | **Global** | `~/.config/opencode/opencode.json` | Default for all projects |
282
- | **Per-project** | `.opencode/models.json` + `opencode.json` | Different models for different repos |
314
+ ```
315
+ repl_init("my-plan.md")
316
+ -> Parses tasks (- [ ] checkboxes) with ACs (- AC: lines)
317
+ -> Auto-detects: npm run build, npx vitest run
318
+ -> Creates .cortex/repl-state.json
283
319
 
284
- Per-project config takes priority. Team members get the same model settings when they clone the repo (`.opencode/models.json` is git-tracked).
320
+ Loop:
321
+ repl_status -> "Task #1: Implement user model"
322
+ AC: User model has name, email, password
323
+ AC: Email validation rejects malformed addresses
324
+ [implement task]
325
+ [run build + tests]
326
+ repl_report(pass, "42 tests pass")
327
+ -> "Task #1 PASSED (1st attempt)"
328
+ -> "Next: Task #2"
329
+
330
+ repl_status -> "Task #2: Add API endpoints"
331
+ [implement task]
332
+ [run build + tests]
333
+ repl_report(fail, "POST /users 500")
334
+ -> "Task #2 FAILED (attempt 1/3)"
335
+ -> "Fix and retry. 2 retries remaining."
336
+ [fix issue, re-run tests]
337
+ repl_report(pass, "All green")
338
+ -> "Task #2 PASSED (2nd attempt)"
339
+ ...
285
340
 
286
- ### Supported Providers
341
+ repl_summary -> Markdown table for PR body
342
+ ```
287
343
 
288
- | Provider | Premium | Standard | Fast |
289
- |----------|---------|----------|------|
290
- | **Anthropic** | Claude Opus 4 | Claude Sonnet 4 | Claude 3.5 Haiku |
291
- | **OpenAI** | o3 | GPT-4.1 | o4 Mini |
292
- | **Google** | Gemini 2.5 Pro | - | Gemini 2.5 Flash |
293
- | **xAI** | Grok 3 | - | Grok 3 Mini |
294
- | **DeepSeek** | DeepSeek R1 | - | DeepSeek Chat |
295
- | **Kimi** | - | Kimi K2P5 | - |
344
+ ### Quality Gate Example
296
345
 
297
- > Don't see your provider? Select **"Enter custom model ID"** and type any `provider/model` string.
346
+ ```
347
+ quality_gate_summary receives reports from 6 agents:
348
+ @testing: PASS — 12 tests written, all passing
349
+ @security: PASS WITH WARNINGS — 1 medium finding (XSS in tooltip)
350
+ @audit: PASS — score A, no critical issues
351
+ @docs-writer: 1 feature doc created
352
+ @devops: N/A
353
+ @perf: PASS — no regressions, all O(n) or better
354
+
355
+ -> Recommendation: GO-WITH-WARNINGS
356
+ -> Blocker: none
357
+ -> PR body section auto-generated
358
+ ```
298
359
 
299
- <br>
360
+ ---
300
361
 
301
362
  ## Project Structure
302
363
 
@@ -304,12 +365,13 @@ Per-project config takes priority. Team members get the same model settings when
304
365
  your-project/
305
366
  .cortex/ Project context (auto-initialized)
306
367
  config.json Configuration
307
- plans/ Implementation plans (gitignored)
308
- sessions/ Session summaries (gitignored)
309
- repl-state.json REPL loop progress (gitignored, auto-managed)
368
+ plans/ Implementation plans
369
+ sessions/ Session summaries
370
+ repl-state.json REPL loop progress (auto-managed)
371
+ quality-gate.json Last quality gate results
310
372
  .opencode/
311
373
  models.json Per-project model config (git tracked)
312
- .worktrees/ Git worktrees (gitignored)
374
+ .worktrees/ Git worktrees
313
375
  feature-auth/ Isolated development copy
314
376
  bugfix-login/
315
377
  docs/ Documentation (git tracked)
@@ -319,7 +381,7 @@ your-project/
319
381
  flows/ Process/data flow docs
320
382
  ```
321
383
 
322
- <br>
384
+ ---
323
385
 
324
386
  ## CLI Reference
325
387
 
@@ -333,131 +395,20 @@ npx cortex-agents uninstall # Clean removal of everything
333
395
  npx cortex-agents status # Show installation and model status
334
396
  ```
335
397
 
336
- <br>
337
-
338
- ## How It Works
339
-
340
- ### The Implement Agent Workflow
341
-
342
- Every time the implement agent starts, it follows a structured pre-implementation checklist:
343
-
344
- ```
345
- Step 1 branch_status Am I on a protected branch?
346
- Step 2 cortex_status Is .cortex initialized? Offer model config if new project.
347
- Step 3 plan_list / plan_load Is there a plan for this work?
348
- Step 4 Ask: strategy Worktree (recommended) or branch?
349
- Step 4b Ask: launch mode Terminal tab (recommended) / stay / PTY / background?
350
- Step 5 Execute Create worktree/branch, auto-detect terminal
351
- Step 6 REPL Loop If plan loaded: repl_init → iterate tasks one-by-one
352
- 6a repl_init Parse plan tasks, auto-detect build/test commands
353
- 6b repl_status Get current task, auto-advance from pending
354
- 6c Implement task Write code for the current task only
355
- 6d Build + test Run detected build/test commands
356
- 6e repl_report Report pass/fail/skip → auto-advance or retry
357
- 6f Repeat 6b-6e Until all tasks done or user intervenes
358
- Step 7 Quality Gate Launch @qa + @guard in parallel (includes repl_summary)
359
- Step 8 Ask: documentation Decision doc / feature doc / flow doc?
360
- Step 9 session_save Record what was done and why
361
- Step 10 task_finalize Commit, push, create PR
362
- Step 11 Ask: cleanup Remove worktree + close terminal tab? (if applicable)
363
- ```
364
-
365
- This isn't just documentation - it's enforced by the agent's instructions. The AI follows this workflow every time.
366
-
367
- ### Sub-Agent Quality Gates
368
-
369
- After implementation (Step 7), the implement agent **automatically** launches sub-agents in parallel as quality gates:
370
-
371
- ```
372
- Implement Agent completes implementation
373
- |
374
- +-- launches in parallel (single message) --+
375
- | |
376
- v v
377
- @qa @guard
378
- Writes unit tests OWASP audit
379
- Runs test suite Secrets scan
380
- Reports coverage Severity ratings
381
- Returns: PASS/FAIL Returns: PASS/FAIL
382
- | |
383
- +------ results reviewed by Implement ------+
384
- |
385
- v
386
- Quality Gate Summary included in PR body
387
- ```
388
-
389
- The fix agent uses the same pattern: `@qa` for regression tests (always) and `@guard` when the fix touches sensitive code.
390
-
391
- Sub-agents use **structured return contracts** so results are actionable:
392
- - `BLOCKING` / `CRITICAL` / `HIGH` findings block finalization
393
- - `MEDIUM` findings are noted in the PR body
394
- - `LOW` findings are deferred
395
-
396
- ### REPL Loop (Iterative Implementation)
397
-
398
- When a plan is loaded, the implement agent activates a **Read-Eval-Print Loop** that works through tasks one at a time with build+test verification after each:
399
-
400
- ```
401
- repl_init("my-plan.md")
402
- → Parses plan tasks (- [ ] checkboxes)
403
- → Auto-detects: npm run build, npx vitest run (vitest)
404
- → Creates .cortex/repl-state.json
405
-
406
- Loop:
407
- repl_status → "Task #1: Implement user model"
408
- [agent implements task]
409
- [agent runs build + tests]
410
- repl_report(pass, "42 tests pass") → "✓ Task #1 PASSED (1st attempt)"
411
- → "→ Next: Task #2"
412
-
413
- repl_status → "Task #2: Add API endpoints"
414
- [agent implements task]
415
- [agent runs build + tests]
416
- repl_report(fail, "POST /users 500") → "⚠ Task #2 FAILED (attempt 1/3)"
417
- → "Fix and retry. 2 retries remaining."
418
- [agent fixes the issue]
419
- [agent runs build + tests]
420
- repl_report(pass, "All green") → "✓ Task #2 PASSED (2nd attempt)"
421
- → "→ Next: Task #3"
422
- ...
423
-
424
- repl_summary → Markdown table for PR body
425
- ```
426
-
427
- **Key behaviors:**
428
- - **Opt-in**: Only activates when a plan is loaded. No-plan sessions use the standard linear workflow.
429
- - **Auto-detection**: Scans `package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `Makefile`, `mix.exs` for build/test/lint commands.
430
- - **Retry with escalation**: Failed tasks retry up to `maxRetries` (default: 3) before asking the user how to proceed.
431
- - **Persistent state**: Progress saved to `.cortex/repl-state.json` — survives context compaction, session restarts, and agent switches.
432
- - **Skip support**: Tasks can be skipped with a reason, which is tracked in the summary.
433
-
434
- ### Agent Handover
435
-
436
- When agents switch, a toast notification tells you what mode you're in:
437
-
438
- ```
439
- Agent: implement Development mode - ready to implement
440
- Agent: architect Planning mode - read-only analysis
441
- Agent: fix Debug mode - troubleshooting and fixes
442
- Agent: audit Review mode - code quality assessment
443
- ```
444
-
445
- The Architect agent creates plans with mermaid diagrams and hands off to Implement. Implement loads the plan, detects the tech stack, loads relevant skills, and implements. If something breaks, Fix takes over with performance debugging tools. Audit provides code quality assessment and tech debt analysis on demand.
446
-
447
- <br>
398
+ ---
448
399
 
449
400
  ## Requirements
450
401
 
451
402
  - [OpenCode](https://opencode.ai) >= 1.0.0
452
403
  - Node.js >= 18.0.0
453
404
  - Git (for branch/worktree features)
454
- - [GitHub CLI](https://cli.github.com/) (optional, for `task_finalize` PR creation and `github_*` tools)
405
+ - [GitHub CLI](https://cli.github.com/) (optional for PR creation and issue integration)
455
406
 
456
- <br>
407
+ ---
457
408
 
458
409
  ## Contributing
459
410
 
460
- Contributions are welcome! This is an Apache-2.0 licensed project and we'd love your help.
411
+ We welcome contributions of all sizes. Whether it's a typo fix, a new skill pack, or a whole new agent — we appreciate it.
461
412
 
462
413
  ### Getting Started
463
414
 
@@ -466,45 +417,109 @@ git clone https://github.com/ps-carvalho/cortex-agents.git
466
417
  cd cortex-agents
467
418
  npm install
468
419
  npm run build
420
+ npm test # 447 tests, all should pass
469
421
  ```
470
422
 
471
- ### Development Workflow
423
+ ### Local Development
472
424
 
473
425
  ```bash
474
- # Link for local testing
426
+ # Link for local testing with OpenCode
475
427
  npm link
476
428
  cd ~/.config/opencode && npm link cortex-agents
477
429
 
478
- # Make changes, rebuild, restart OpenCode
430
+ # Edit, rebuild, restart OpenCode to test
479
431
  npm run build
480
432
 
481
433
  # Unlink when done
482
434
  cd ~/.config/opencode && npm unlink cortex-agents && npm install
483
435
  ```
484
436
 
437
+ ### Project Layout
438
+
439
+ ```
440
+ src/
441
+ index.ts Plugin entry point, tool registration, event hooks
442
+ registry.ts Agent/model registry constants
443
+ cli.ts CLI (install, configure, uninstall, status)
444
+ tools/
445
+ repl.ts REPL loop tools (init, status, report, resume, summary)
446
+ quality-gate.ts Quality gate aggregation tool
447
+ cortex.ts Project initialization tools
448
+ worktree.ts Git worktree tools
449
+ branch.ts Git branch tools
450
+ plan.ts Plan persistence tools
451
+ session.ts Session summary tools
452
+ docs.ts Documentation tools
453
+ task.ts Task finalization tool
454
+ github.ts GitHub integration tools
455
+ utils/
456
+ repl.ts REPL state management, command detection, formatting
457
+ change-scope.ts Risk-based file classification
458
+ plan-extract.ts Plan parsing utilities
459
+ shell.ts Shell command helpers
460
+ github.ts GitHub API helpers
461
+ worktree-detect.ts Worktree detection
462
+ __tests__/ Test files mirror src/ structure
463
+ .opencode/
464
+ agents/ 12 agent definition files (.md frontmatter)
465
+ skills/ 16 skill pack directories (SKILL.md each)
466
+ ```
467
+
485
468
  ### What We're Looking For
486
469
 
487
- - **New skills** - Domain-specific knowledge packs (e.g., Rust, Go, DevOps for AWS)
488
- - **New agents** - Specialized agents (e.g., reviewer, migration, docs-writer)
489
- - **Terminal drivers** - Improve detection/support for additional terminal emulators
490
- - **Tool improvements** - Better PR templates, test runners, linter integration
491
- - **Bug fixes** - Anything that doesn't work as expected
470
+ | Type | Examples | Difficulty |
471
+ |------|----------|-----------|
472
+ | **New skills** | Rust, Go, AWS, Terraform, GraphQL | Easy — add a `SKILL.md` file |
473
+ | **New agents** | Reviewer, migration specialist, API designer | Medium — agent `.md` + registry update |
474
+ | **Tool improvements** | Better PR templates, test runners, linter integration | Medium — TypeScript + tests |
475
+ | **Quality gate enhancements** | New parsers for agent report formats, smarter severity mapping | Medium |
476
+ | **Bug fixes** | Anything that doesn't work as expected | Varies |
477
+ | **Documentation** | Guides, examples, tutorials | Easy |
478
+
479
+ ### Adding a New Skill
480
+
481
+ 1. Create `.opencode/skills/your-skill/SKILL.md` with frontmatter (`name`, `description`, `license`, `compatibility`)
482
+ 2. Write the skill content — patterns, checklists, examples
483
+ 3. Update the skill count in tests if applicable
484
+ 4. Submit a PR
485
+
486
+ ### Adding a New Agent
487
+
488
+ 1. Create `.opencode/agents/your-agent.md` with frontmatter (`description`, `mode`, `temperature`, `tools`, `permission`)
489
+ 2. Add the agent name to `SUBAGENTS` or `PRIMARY_AGENTS` in `src/registry.ts`
490
+ 3. Add an agent description in `AGENT_DESCRIPTIONS` in `src/index.ts`
491
+ 4. Update test expectations in `src/__tests__/registry.test.ts`
492
+ 5. Submit a PR
492
493
 
493
494
  ### Submitting Changes
494
495
 
495
496
  1. Fork the repository
496
497
  2. Create your branch (`git checkout -b feature/amazing-feature`)
497
- 3. Commit with conventional format (`git commit -m 'feat: add amazing feature'`)
498
- 4. Push and open a Pull Request
498
+ 3. Write tests for new functionality
499
+ 4. Ensure all tests pass (`npm test`) and the build is clean (`npm run build`)
500
+ 5. Commit with conventional format (`feat:`, `fix:`, `docs:`, `chore:`)
501
+ 6. Push and open a Pull Request
499
502
 
500
- <br>
503
+ ### Commit Convention
501
504
 
502
- ## License
505
+ We use [Conventional Commits](https://www.conventionalcommits.org/):
503
506
 
504
- [Apache-2.0](LICENSE)
507
+ ```
508
+ feat: add new capability
509
+ fix: correct a bug
510
+ docs: update documentation
511
+ chore: maintenance, dependencies
512
+ refactor: code restructuring without behavior change
513
+ test: add or update tests
514
+ ```
515
+
516
+ ---
517
+
518
+ ## License
505
519
 
506
- <br>
520
+ [Apache-2.0](LICENSE) — use it, modify it, ship it.
507
521
 
508
522
  <p align="center">
523
+ <br>
509
524
  <sub>Built for the <a href="https://opencode.ai">OpenCode</a> community</sub>
510
525
  </p>