cortex-agents 2.3.1 → 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.
- package/.opencode/agents/{plan.md → architect.md} +104 -58
- package/.opencode/agents/audit.md +183 -0
- package/.opencode/agents/{fullstack.md → coder.md} +10 -54
- package/.opencode/agents/debug.md +76 -201
- package/.opencode/agents/devops.md +16 -123
- package/.opencode/agents/docs-writer.md +195 -0
- package/.opencode/agents/fix.md +207 -0
- package/.opencode/agents/implement.md +433 -0
- package/.opencode/agents/perf.md +151 -0
- package/.opencode/agents/refactor.md +163 -0
- package/.opencode/agents/security.md +20 -85
- package/.opencode/agents/testing.md +1 -151
- package/.opencode/skills/data-engineering/SKILL.md +221 -0
- package/.opencode/skills/monitoring-observability/SKILL.md +251 -0
- package/README.md +315 -224
- package/dist/cli.js +85 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -22
- package/dist/registry.d.ts +8 -3
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +16 -2
- package/dist/tools/branch.d.ts +2 -2
- package/dist/tools/cortex.d.ts +2 -2
- package/dist/tools/cortex.js +7 -7
- package/dist/tools/docs.d.ts +2 -2
- package/dist/tools/environment.d.ts +31 -0
- package/dist/tools/environment.d.ts.map +1 -0
- package/dist/tools/environment.js +93 -0
- package/dist/tools/github.d.ts +42 -0
- package/dist/tools/github.d.ts.map +1 -0
- package/dist/tools/github.js +200 -0
- package/dist/tools/plan.d.ts +28 -4
- package/dist/tools/plan.d.ts.map +1 -1
- package/dist/tools/plan.js +232 -4
- package/dist/tools/quality-gate.d.ts +28 -0
- package/dist/tools/quality-gate.d.ts.map +1 -0
- package/dist/tools/quality-gate.js +233 -0
- package/dist/tools/repl.d.ts +55 -0
- package/dist/tools/repl.d.ts.map +1 -0
- package/dist/tools/repl.js +291 -0
- package/dist/tools/task.d.ts +2 -0
- package/dist/tools/task.d.ts.map +1 -1
- package/dist/tools/task.js +25 -30
- package/dist/tools/worktree.d.ts +5 -32
- package/dist/tools/worktree.d.ts.map +1 -1
- package/dist/tools/worktree.js +75 -447
- package/dist/utils/change-scope.d.ts +33 -0
- package/dist/utils/change-scope.d.ts.map +1 -0
- package/dist/utils/change-scope.js +198 -0
- package/dist/utils/github.d.ts +104 -0
- package/dist/utils/github.d.ts.map +1 -0
- package/dist/utils/github.js +243 -0
- package/dist/utils/ide.d.ts +76 -0
- package/dist/utils/ide.d.ts.map +1 -0
- package/dist/utils/ide.js +307 -0
- package/dist/utils/plan-extract.d.ts +28 -0
- package/dist/utils/plan-extract.d.ts.map +1 -1
- package/dist/utils/plan-extract.js +90 -1
- package/dist/utils/repl.d.ts +145 -0
- package/dist/utils/repl.d.ts.map +1 -0
- package/dist/utils/repl.js +547 -0
- package/dist/utils/terminal.d.ts +53 -1
- package/dist/utils/terminal.d.ts.map +1 -1
- package/dist/utils/terminal.js +642 -5
- package/package.json +1 -1
- package/.opencode/agents/build.md +0 -294
- package/.opencode/agents/review.md +0 -314
- package/dist/plugin.d.ts +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js +0 -4
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">
|
|
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,159 +12,170 @@
|
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<p align="center">
|
|
15
|
-
<a href="#-quick-start">Quick Start</a>  
|
|
16
|
-
<a href="#-
|
|
17
|
-
<a href="#-agents">Agents</a>  
|
|
18
|
-
<a href="#-tools">Tools</a>  
|
|
19
|
-
<a href="#-skills">Skills</a>  
|
|
15
|
+
<a href="#-quick-start">Quick Start</a> •
|
|
16
|
+
<a href="#-architecture">Architecture</a> •
|
|
17
|
+
<a href="#-agents">Agents</a> •
|
|
18
|
+
<a href="#-tools">Tools</a> •
|
|
19
|
+
<a href="#-skills">Skills</a> •
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
|
46
|
+
# Restart OpenCode — done.
|
|
44
47
|
```
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
Your OpenCode session now has **12 specialized agents**, **33 tools**, and **16 domain skills**.
|
|
47
50
|
|
|
48
|
-
|
|
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
|
-
|
|
53
|
+
---
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
## Architecture
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
### Agent Hierarchy
|
|
55
58
|
|
|
56
59
|
```
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
67
86
|
```
|
|
68
87
|
|
|
69
|
-
###
|
|
70
|
-
|
|
71
|
-
Create isolated development environments and launch them instantly:
|
|
72
|
-
|
|
73
|
-
| Mode | What Happens |
|
|
74
|
-
|------|-------------|
|
|
75
|
-
| **New Terminal** | Opens a new terminal tab with OpenCode pre-configured in the worktree |
|
|
76
|
-
| **In-App PTY** | Spawns an embedded terminal inside your current OpenCode session |
|
|
77
|
-
| **Background** | AI implements headlessly while you keep working - toast notifications on completion |
|
|
78
|
-
|
|
79
|
-
Plans are automatically propagated into the worktree's `.cortex/plans/` so the new session has full context.
|
|
88
|
+
### The Workflow
|
|
80
89
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
### Task Finalizer
|
|
90
|
+
```
|
|
91
|
+
You: "Add user authentication"
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
Architect Agent reads codebase, creates plan with mermaid diagrams
|
|
94
|
+
saves to .cortex/plans/ commits plan to feature branch
|
|
95
|
+
"Plan committed. Switch to offers worktree or branch
|
|
96
|
+
Implement?"
|
|
86
97
|
|
|
98
|
+
Implement Agent loads plan, checks git status
|
|
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
|
|
87
103
|
```
|
|
88
|
-
task_finalize
|
|
89
|
-
git add -A
|
|
90
|
-
git commit -m "feat: add user auth"
|
|
91
|
-
git push -u origin feature/user-auth
|
|
92
|
-
gh pr create --base main auto-detected if in worktree
|
|
93
|
-
PR body auto-populated from .cortex/plans/
|
|
94
|
-
"PR created! Clean up worktree?"
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Auto-Prompted Documentation
|
|
98
104
|
|
|
99
|
-
|
|
105
|
+
### Scope-Based Quality Gate
|
|
100
106
|
|
|
101
|
-
|
|
102
|
-
|------|-----------------|----------|
|
|
103
|
-
| **Decision** | Architecture Decision Record | Mermaid graph comparing options |
|
|
104
|
-
| **Feature** | Feature documentation | Mermaid component diagram |
|
|
105
|
-
| **Flow** | Process/data flow doc | Mermaid sequence diagram |
|
|
107
|
+
Not every change needs a full audit. The quality gate scales with risk:
|
|
106
108
|
|
|
107
|
-
|
|
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` |
|
|
108
115
|
|
|
109
|
-
|
|
116
|
+
---
|
|
110
117
|
|
|
111
118
|
## Agents
|
|
112
119
|
|
|
113
|
-
### Primary Agents
|
|
120
|
+
### Primary Agents (3)
|
|
114
121
|
|
|
115
122
|
Handle complex, multi-step work. Use your best model.
|
|
116
123
|
|
|
117
|
-
| Agent | Role |
|
|
118
|
-
|
|
119
|
-
| **
|
|
120
|
-
| **
|
|
121
|
-
| **
|
|
122
|
-
| **review** | 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`. |
|
|
123
129
|
|
|
124
|
-
###
|
|
130
|
+
### Sub-Agents (9)
|
|
125
131
|
|
|
126
|
-
Focused specialists launched **automatically**
|
|
132
|
+
Focused specialists launched **automatically** by primary agents. Each auto-loads domain skills for deeper analysis. Use a fast/cheap model.
|
|
127
133
|
|
|
128
134
|
| Agent | Role | Auto-Loads Skill | Triggered By |
|
|
129
135
|
|-------|------|-----------------|-------------|
|
|
130
|
-
| **@testing** |
|
|
131
|
-
| **@security** | OWASP audit, secrets scan,
|
|
132
|
-
| **@
|
|
133
|
-
| **@
|
|
134
|
-
|
|
135
|
-
|
|
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.
|
|
136
147
|
|
|
137
148
|
### Skill Routing
|
|
138
149
|
|
|
139
|
-
All agents detect the project's technology stack and **automatically load relevant skills** before working
|
|
150
|
+
All agents detect the project's technology stack and **automatically load relevant skills** before working:
|
|
140
151
|
|
|
141
152
|
```
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
Implement Agent detects: package.json has React + Express + Prisma
|
|
154
|
+
-> auto-loads: frontend-development, backend-development, database-design, api-design
|
|
155
|
+
-> implements with deep framework-specific knowledge
|
|
145
156
|
```
|
|
146
157
|
|
|
147
|
-
|
|
158
|
+
---
|
|
148
159
|
|
|
149
160
|
## Tools
|
|
150
161
|
|
|
151
|
-
|
|
162
|
+
33 tools bundled and auto-registered. No configuration needed.
|
|
152
163
|
|
|
153
164
|
<table>
|
|
154
165
|
<tr><td width="50%">
|
|
155
166
|
|
|
156
167
|
**Git Workflow**
|
|
157
|
-
- `branch_status`
|
|
158
|
-
- `branch_create`
|
|
159
|
-
- `branch_switch`
|
|
160
|
-
- `worktree_create`
|
|
161
|
-
- `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/`
|
|
162
172
|
- `worktree_list` / `worktree_remove` / `worktree_open`
|
|
163
173
|
|
|
164
174
|
</td><td width="50%">
|
|
165
175
|
|
|
166
176
|
**Planning & Sessions**
|
|
167
177
|
- `plan_save` / `plan_load` / `plan_list` / `plan_delete`
|
|
178
|
+
- `plan_commit` — Commit plan to feature branch
|
|
168
179
|
- `session_save` / `session_list` / `session_load`
|
|
169
180
|
- `cortex_init` / `cortex_status` / `cortex_configure`
|
|
170
181
|
|
|
@@ -172,47 +183,71 @@ Build Agent detects: package.json has React + Express + Prisma
|
|
|
172
183
|
<tr><td width="50%">
|
|
173
184
|
|
|
174
185
|
**Documentation**
|
|
175
|
-
- `docs_init`
|
|
176
|
-
- `docs_save`
|
|
177
|
-
- `docs_list`
|
|
178
|
-
- `docs_index`
|
|
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`
|
|
179
190
|
|
|
180
191
|
</td><td width="50%">
|
|
181
192
|
|
|
182
|
-
**Finalization
|
|
183
|
-
- `task_finalize`
|
|
193
|
+
**Finalization**
|
|
194
|
+
- `task_finalize` — Stage, commit, push, create PR
|
|
184
195
|
- Auto-detects worktree (targets main)
|
|
185
196
|
- Auto-populates PR from `.cortex/plans/`
|
|
186
|
-
-
|
|
187
|
-
- `
|
|
197
|
+
- Auto-links issues via `Closes #N`
|
|
198
|
+
- `quality_gate_summary` — Aggregate sub-agent findings, GO/NO-GO recommendation
|
|
199
|
+
|
|
200
|
+
</td></tr>
|
|
201
|
+
<tr><td colspan="2">
|
|
202
|
+
|
|
203
|
+
**GitHub Integration**
|
|
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
|
|
207
|
+
|
|
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.
|
|
209
|
+
|
|
210
|
+
</td></tr>
|
|
211
|
+
<tr><td colspan="2">
|
|
212
|
+
|
|
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
|
|
219
|
+
|
|
220
|
+
State persists to `.cortex/repl-state.json` — survives context compaction, session restarts, and agent switches.
|
|
188
221
|
|
|
189
222
|
</td></tr>
|
|
190
223
|
</table>
|
|
191
224
|
|
|
192
|
-
|
|
225
|
+
---
|
|
193
226
|
|
|
194
227
|
## Skills
|
|
195
228
|
|
|
196
|
-
|
|
229
|
+
16 domain-specific skill packs loaded on demand:
|
|
197
230
|
|
|
198
231
|
| Skill | Covers |
|
|
199
232
|
|-------|--------|
|
|
200
|
-
|
|
|
201
|
-
|
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
|
|
|
207
|
-
|
|
|
208
|
-
|
|
|
209
|
-
|
|
|
210
|
-
|
|
|
211
|
-
|
|
|
212
|
-
|
|
|
213
|
-
|
|
|
214
|
-
|
|
215
|
-
|
|
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
|
+
---
|
|
216
251
|
|
|
217
252
|
## Model Configuration
|
|
218
253
|
|
|
@@ -224,7 +259,7 @@ npx cortex-agents configure --project # Per-project (saves to .opencode/models.
|
|
|
224
259
|
```
|
|
225
260
|
|
|
226
261
|
```
|
|
227
|
-
? Select model for PRIMARY agents:
|
|
262
|
+
? Select model for PRIMARY agents (architect, implement, fix):
|
|
228
263
|
Claude Sonnet 4 (anthropic) Best balance of intelligence and speed
|
|
229
264
|
Claude Opus 4 (anthropic) Most capable, best for complex architecture
|
|
230
265
|
GPT-4.1 (openai) Fast multimodal model
|
|
@@ -232,40 +267,97 @@ npx cortex-agents configure --project # Per-project (saves to .opencode/models.
|
|
|
232
267
|
Kimi K2P5 (kimi) Optimized for code generation
|
|
233
268
|
Enter custom model ID
|
|
234
269
|
|
|
235
|
-
? Select model for SUBAGENTS:
|
|
270
|
+
? Select model for SUBAGENTS (debug, coder, testing, security, devops, audit, ...):
|
|
236
271
|
Claude 3.5 Haiku (anthropic) Fast and cost-effective
|
|
237
272
|
o4 Mini (openai) Fast reasoning, cost-effective
|
|
238
273
|
Gemini 2.5 Flash (google) Fast and efficient
|
|
239
274
|
Same as primary
|
|
240
275
|
```
|
|
241
276
|
|
|
242
|
-
|
|
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
|
+
---
|
|
243
282
|
|
|
244
|
-
|
|
283
|
+
## How It Works
|
|
245
284
|
|
|
246
|
-
###
|
|
285
|
+
### Implement Agent — Step by Step
|
|
247
286
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
+
```
|
|
252
311
|
|
|
253
|
-
|
|
312
|
+
### REPL Loop Example
|
|
254
313
|
|
|
255
|
-
|
|
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
|
|
319
|
+
|
|
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
|
+
...
|
|
340
|
+
|
|
341
|
+
repl_summary -> Markdown table for PR body
|
|
342
|
+
```
|
|
256
343
|
|
|
257
|
-
|
|
258
|
-
|----------|---------|----------|------|
|
|
259
|
-
| **Anthropic** | Claude Opus 4 | Claude Sonnet 4 | Claude 3.5 Haiku |
|
|
260
|
-
| **OpenAI** | o3 | GPT-4.1 | o4 Mini |
|
|
261
|
-
| **Google** | Gemini 2.5 Pro | - | Gemini 2.5 Flash |
|
|
262
|
-
| **xAI** | Grok 3 | - | Grok 3 Mini |
|
|
263
|
-
| **DeepSeek** | DeepSeek R1 | - | DeepSeek Chat |
|
|
264
|
-
| **Kimi** | - | Kimi K2P5 | - |
|
|
344
|
+
### Quality Gate Example
|
|
265
345
|
|
|
266
|
-
|
|
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
|
+
```
|
|
267
359
|
|
|
268
|
-
|
|
360
|
+
---
|
|
269
361
|
|
|
270
362
|
## Project Structure
|
|
271
363
|
|
|
@@ -273,11 +365,13 @@ Per-project config takes priority. Team members get the same model settings when
|
|
|
273
365
|
your-project/
|
|
274
366
|
.cortex/ Project context (auto-initialized)
|
|
275
367
|
config.json Configuration
|
|
276
|
-
plans/ Implementation plans
|
|
277
|
-
sessions/ Session summaries
|
|
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
|
|
278
372
|
.opencode/
|
|
279
373
|
models.json Per-project model config (git tracked)
|
|
280
|
-
.worktrees/ Git worktrees
|
|
374
|
+
.worktrees/ Git worktrees
|
|
281
375
|
feature-auth/ Isolated development copy
|
|
282
376
|
bugfix-login/
|
|
283
377
|
docs/ Documentation (git tracked)
|
|
@@ -287,7 +381,7 @@ your-project/
|
|
|
287
381
|
flows/ Process/data flow docs
|
|
288
382
|
```
|
|
289
383
|
|
|
290
|
-
|
|
384
|
+
---
|
|
291
385
|
|
|
292
386
|
## CLI Reference
|
|
293
387
|
|
|
@@ -301,87 +395,20 @@ npx cortex-agents uninstall # Clean removal of everything
|
|
|
301
395
|
npx cortex-agents status # Show installation and model status
|
|
302
396
|
```
|
|
303
397
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
## How It Works
|
|
307
|
-
|
|
308
|
-
### The Build Agent Workflow
|
|
309
|
-
|
|
310
|
-
Every time the build agent starts, it follows a structured pre-implementation checklist:
|
|
311
|
-
|
|
312
|
-
```
|
|
313
|
-
Step 1 branch_status Am I on a protected branch?
|
|
314
|
-
Step 2 cortex_status Is .cortex initialized? Offer model config if new project.
|
|
315
|
-
Step 3 plan_list / plan_load Is there a plan for this work?
|
|
316
|
-
Step 4 Ask: strategy Worktree (recommended) or branch?
|
|
317
|
-
Step 4b Ask: launch mode Terminal tab (recommended) / stay / PTY / background?
|
|
318
|
-
Step 5 Execute Create worktree/branch, auto-detect terminal
|
|
319
|
-
Step 6 Implement Write code following the plan
|
|
320
|
-
Step 7 Quality Gate Launch @testing + @security in parallel
|
|
321
|
-
Step 8 Ask: documentation Decision doc / feature doc / flow doc?
|
|
322
|
-
Step 9 session_save Record what was done and why
|
|
323
|
-
Step 10 task_finalize Commit, push, create PR
|
|
324
|
-
Step 11 Ask: cleanup Remove worktree + close terminal tab? (if applicable)
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
This isn't just documentation - it's enforced by the agent's instructions. The AI follows this workflow every time.
|
|
328
|
-
|
|
329
|
-
### Sub-Agent Quality Gates
|
|
330
|
-
|
|
331
|
-
After implementation (Step 7), the build agent **automatically** launches sub-agents in parallel as quality gates:
|
|
332
|
-
|
|
333
|
-
```
|
|
334
|
-
Build Agent completes implementation
|
|
335
|
-
|
|
|
336
|
-
+-- launches in parallel (single message) --+
|
|
337
|
-
| |
|
|
338
|
-
v v
|
|
339
|
-
@testing @security
|
|
340
|
-
Writes unit tests OWASP audit
|
|
341
|
-
Runs test suite Secrets scan
|
|
342
|
-
Reports coverage Severity ratings
|
|
343
|
-
Returns: PASS/FAIL Returns: PASS/FAIL
|
|
344
|
-
| |
|
|
345
|
-
+-------- results reviewed by Build ---------+
|
|
346
|
-
|
|
|
347
|
-
v
|
|
348
|
-
Quality Gate Summary included in PR body
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
The debug agent uses the same pattern: `@testing` for regression tests (always) and `@security` when the fix touches sensitive code.
|
|
352
|
-
|
|
353
|
-
Sub-agents use **structured return contracts** so results are actionable:
|
|
354
|
-
- `BLOCKING` / `CRITICAL` / `HIGH` findings block finalization
|
|
355
|
-
- `MEDIUM` findings are noted in the PR body
|
|
356
|
-
- `LOW` findings are deferred
|
|
357
|
-
|
|
358
|
-
### Agent Handover
|
|
359
|
-
|
|
360
|
-
When agents switch, a toast notification tells you what mode you're in:
|
|
361
|
-
|
|
362
|
-
```
|
|
363
|
-
Agent: build Development mode - ready to implement
|
|
364
|
-
Agent: plan Planning mode - read-only analysis
|
|
365
|
-
Agent: debug Debug mode - troubleshooting and fixes
|
|
366
|
-
Agent: review Review mode - code quality assessment
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
The Plan agent creates plans with mermaid diagrams and hands off to Build. Build loads the plan, detects the tech stack, loads relevant skills, and implements. If something breaks, Debug takes over with performance debugging tools. Review provides code quality assessment and tech debt analysis on demand.
|
|
370
|
-
|
|
371
|
-
<br>
|
|
398
|
+
---
|
|
372
399
|
|
|
373
400
|
## Requirements
|
|
374
401
|
|
|
375
402
|
- [OpenCode](https://opencode.ai) >= 1.0.0
|
|
376
403
|
- Node.js >= 18.0.0
|
|
377
404
|
- Git (for branch/worktree features)
|
|
378
|
-
- [GitHub CLI](https://cli.github.com/) (optional
|
|
405
|
+
- [GitHub CLI](https://cli.github.com/) (optional — for PR creation and issue integration)
|
|
379
406
|
|
|
380
|
-
|
|
407
|
+
---
|
|
381
408
|
|
|
382
409
|
## Contributing
|
|
383
410
|
|
|
384
|
-
|
|
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.
|
|
385
412
|
|
|
386
413
|
### Getting Started
|
|
387
414
|
|
|
@@ -390,45 +417,109 @@ git clone https://github.com/ps-carvalho/cortex-agents.git
|
|
|
390
417
|
cd cortex-agents
|
|
391
418
|
npm install
|
|
392
419
|
npm run build
|
|
420
|
+
npm test # 447 tests, all should pass
|
|
393
421
|
```
|
|
394
422
|
|
|
395
|
-
### Development
|
|
423
|
+
### Local Development
|
|
396
424
|
|
|
397
425
|
```bash
|
|
398
|
-
# Link for local testing
|
|
426
|
+
# Link for local testing with OpenCode
|
|
399
427
|
npm link
|
|
400
428
|
cd ~/.config/opencode && npm link cortex-agents
|
|
401
429
|
|
|
402
|
-
#
|
|
430
|
+
# Edit, rebuild, restart OpenCode to test
|
|
403
431
|
npm run build
|
|
404
432
|
|
|
405
433
|
# Unlink when done
|
|
406
434
|
cd ~/.config/opencode && npm unlink cortex-agents && npm install
|
|
407
435
|
```
|
|
408
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
|
+
|
|
409
468
|
### What We're Looking For
|
|
410
469
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
|
416
493
|
|
|
417
494
|
### Submitting Changes
|
|
418
495
|
|
|
419
496
|
1. Fork the repository
|
|
420
497
|
2. Create your branch (`git checkout -b feature/amazing-feature`)
|
|
421
|
-
3.
|
|
422
|
-
4.
|
|
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
|
|
423
502
|
|
|
424
|
-
|
|
503
|
+
### Commit Convention
|
|
425
504
|
|
|
426
|
-
|
|
505
|
+
We use [Conventional Commits](https://www.conventionalcommits.org/):
|
|
427
506
|
|
|
428
|
-
|
|
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
|
|
429
519
|
|
|
430
|
-
|
|
520
|
+
[Apache-2.0](LICENSE) — use it, modify it, ship it.
|
|
431
521
|
|
|
432
522
|
<p align="center">
|
|
523
|
+
<br>
|
|
433
524
|
<sub>Built for the <a href="https://opencode.ai">OpenCode</a> community</sub>
|
|
434
525
|
</p>
|