cortex-agents 2.1.0 → 2.3.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/build.md +179 -21
- package/.opencode/agents/debug.md +97 -11
- package/.opencode/agents/devops.md +75 -7
- package/.opencode/agents/fullstack.md +89 -1
- package/.opencode/agents/plan.md +83 -6
- package/.opencode/agents/security.md +60 -1
- package/.opencode/agents/testing.md +45 -1
- package/README.md +292 -356
- package/dist/cli.js +230 -65
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/tools/branch.d.ts +7 -1
- package/dist/tools/branch.d.ts.map +1 -1
- package/dist/tools/branch.js +88 -53
- package/dist/tools/cortex.d.ts +19 -0
- package/dist/tools/cortex.d.ts.map +1 -1
- package/dist/tools/cortex.js +110 -1
- package/dist/tools/session.d.ts.map +1 -1
- package/dist/tools/session.js +3 -1
- package/dist/tools/task.d.ts +20 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +310 -0
- package/dist/tools/worktree.d.ts +42 -2
- package/dist/tools/worktree.d.ts.map +1 -1
- package/dist/tools/worktree.js +573 -98
- package/dist/utils/plan-extract.d.ts +37 -0
- package/dist/utils/plan-extract.d.ts.map +1 -0
- package/dist/utils/plan-extract.js +137 -0
- package/dist/utils/propagate.d.ts +22 -0
- package/dist/utils/propagate.d.ts.map +1 -0
- package/dist/utils/propagate.js +64 -0
- package/dist/utils/shell.d.ts +53 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +118 -0
- package/dist/utils/terminal.d.ts +66 -0
- package/dist/utils/terminal.d.ts.map +1 -0
- package/dist/utils/terminal.js +627 -0
- package/dist/utils/worktree-detect.d.ts +20 -0
- package/dist/utils/worktree-detect.d.ts.map +1 -0
- package/dist/utils/worktree-detect.js +43 -0
- package/package.json +13 -9
package/README.md
CHANGED
|
@@ -1,486 +1,422 @@
|
|
|
1
|
-
# cortex-agents
|
|
2
|
-
|
|
3
1
|
<p align="center">
|
|
4
|
-
<
|
|
2
|
+
<img src="https://img.shields.io/badge/cortex-agents-111?style=for-the-badge&labelColor=111&color=4d96ff" alt="cortex-agents" height="40">
|
|
5
3
|
</p>
|
|
6
4
|
|
|
5
|
+
<h3 align="center">Supercharge OpenCode with structured workflows, intelligent agents, and automated development practices.</h3>
|
|
6
|
+
|
|
7
7
|
<p align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/cortex-agents">
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<a href="https://
|
|
12
|
-
<img src="https://img.shields.io/npm/dm/cortex-agents.svg?style=flat-square" alt="npm downloads">
|
|
13
|
-
</a>
|
|
14
|
-
<a href="https://github.com/your-org/cortex-agents/blob/main/LICENSE">
|
|
15
|
-
<img src="https://img.shields.io/npm/l/cortex-agents.svg?style=flat-square" alt="license">
|
|
16
|
-
</a>
|
|
17
|
-
<a href="https://opencode.ai">
|
|
18
|
-
<img src="https://img.shields.io/badge/OpenCode-Plugin-blue?style=flat-square" alt="OpenCode Plugin">
|
|
19
|
-
</a>
|
|
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>
|
|
9
|
+
<a href="https://www.npmjs.com/package/cortex-agents"><img src="https://img.shields.io/npm/dm/cortex-agents.svg?style=flat-square&color=6bcb77" alt="npm downloads"></a>
|
|
10
|
+
<a href="https://github.com/ps-carvalho/cortex-agents/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/cortex-agents.svg?style=flat-square&color=ffd93d" alt="license"></a>
|
|
11
|
+
<a href="https://opencode.ai"><img src="https://img.shields.io/badge/OpenCode-Plugin-4d96ff?style=flat-square" alt="OpenCode Plugin"></a>
|
|
20
12
|
</p>
|
|
21
13
|
|
|
22
14
|
<p align="center">
|
|
23
|
-
<a href="
|
|
24
|
-
<a href="
|
|
25
|
-
<a href="
|
|
26
|
-
<a href="
|
|
27
|
-
<a href="
|
|
28
|
-
<a href="
|
|
15
|
+
<a href="#-quick-start">Quick Start</a> |
|
|
16
|
+
<a href="#-what-it-does">What It Does</a> |
|
|
17
|
+
<a href="#-agents">Agents</a> |
|
|
18
|
+
<a href="#-tools">Tools</a> |
|
|
19
|
+
<a href="#-skills">Skills</a> |
|
|
20
|
+
<a href="#-contributing">Contributing</a>
|
|
29
21
|
</p>
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Quick Start
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# 1. Install the plugin
|
|
37
|
-
npx cortex-agents install
|
|
38
|
-
|
|
39
|
-
# 2. Choose your models interactively
|
|
40
|
-
npx cortex-agents configure
|
|
41
|
-
|
|
42
|
-
# 3. Restart OpenCode — done!
|
|
43
|
-
```
|
|
23
|
+
<br>
|
|
44
24
|
|
|
45
25
|
---
|
|
46
26
|
|
|
47
|
-
|
|
27
|
+
<br>
|
|
48
28
|
|
|
49
|
-
|
|
29
|
+
## Why Cortex Agents?
|
|
50
30
|
|
|
51
|
-
|
|
52
|
-
npx cortex-agents configure
|
|
53
|
-
```
|
|
31
|
+
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.
|
|
54
32
|
|
|
55
|
-
|
|
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.
|
|
56
35
|
|
|
57
|
-
|
|
58
|
-
2. **Subagent model** — for `fullstack`, `testing`, `security`, and `devops` agents (focused tasks)
|
|
36
|
+
<br>
|
|
59
37
|
|
|
60
|
-
|
|
38
|
+
## Quick Start
|
|
61
39
|
|
|
40
|
+
```bash
|
|
41
|
+
npx cortex-agents install # Add plugin + agents + skills
|
|
42
|
+
npx cortex-agents configure # Pick your models interactively
|
|
43
|
+
# Restart OpenCode - done.
|
|
62
44
|
```
|
|
63
|
-
$ npx cortex-agents configure
|
|
64
|
-
|
|
65
|
-
🔧 Cortex Agents — Model Configuration
|
|
66
45
|
|
|
67
|
-
|
|
68
|
-
Use your best available model.
|
|
46
|
+
That's it. Your OpenCode session now has 7 specialized agents, 23 tools, and 14 domain skills.
|
|
69
47
|
|
|
70
|
-
|
|
71
|
-
❯ Claude Sonnet 4 (anthropic) Best balance of intelligence and speed
|
|
72
|
-
Claude Opus 4 (anthropic) Most capable, best for complex architecture
|
|
73
|
-
GPT-4.1 (openai) Fast multimodal model
|
|
74
|
-
o3 (openai) Advanced reasoning model
|
|
75
|
-
Gemini 2.5 Pro (google) Large context window, strong reasoning
|
|
76
|
-
Kimi K2P5 (kimi) Optimized for code generation
|
|
77
|
-
Enter custom model ID
|
|
48
|
+
<br>
|
|
78
49
|
|
|
79
|
-
|
|
50
|
+
## What It Does
|
|
80
51
|
|
|
81
|
-
|
|
82
|
-
❯ Claude 3.5 Haiku (anthropic) Fast and cost-effective for focused tasks
|
|
83
|
-
o4 Mini (openai) Fast reasoning, cost-effective
|
|
84
|
-
Gemini 2.5 Flash (google) Fast and efficient
|
|
85
|
-
Same as primary
|
|
86
|
-
Enter custom model ID
|
|
52
|
+
### Plan, Build, Ship
|
|
87
53
|
|
|
88
|
-
|
|
54
|
+
Cortex agents follow a structured workflow from planning through to PR:
|
|
89
55
|
|
|
90
|
-
✓ Configuration saved to ~/.config/opencode/opencode.json
|
|
91
56
|
```
|
|
57
|
+
You: "Add user authentication"
|
|
92
58
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
| Provider | Premium | Standard | Fast |
|
|
96
|
-
|----------|---------|----------|------|
|
|
97
|
-
| **Anthropic** | Claude Opus 4 | Claude Sonnet 4 | Claude 3.5 Haiku |
|
|
98
|
-
| **OpenAI** | o3 | GPT-4.1 | o4 Mini |
|
|
99
|
-
| **Google** | Gemini 2.5 Pro | — | Gemini 2.5 Flash |
|
|
100
|
-
| **xAI** | Grok 3 | — | Grok 3 Mini |
|
|
101
|
-
| **DeepSeek** | DeepSeek R1 | — | DeepSeek Chat |
|
|
102
|
-
| **Kimi** | — | Kimi K2P5 | — |
|
|
59
|
+
Plan Agent reads codebase, creates plan with mermaid diagrams
|
|
60
|
+
saves to .cortex/plans/ "Plan saved. Switch to Build?"
|
|
103
61
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# Change models at any time
|
|
110
|
-
npx cortex-agents configure
|
|
111
|
-
|
|
112
|
-
# Reset to OpenCode defaults (removes model config)
|
|
113
|
-
npx cortex-agents configure --reset
|
|
62
|
+
Build Agent loads plan, checks git status
|
|
63
|
+
"You're on main. Create a branch two-step prompt: strategy -> execution
|
|
64
|
+
or worktree?"
|
|
65
|
+
creates feature/user-auth implements following the plan
|
|
66
|
+
"Ready to finalize?" stages, commits, pushes, opens PR
|
|
114
67
|
```
|
|
115
68
|
|
|
116
|
-
|
|
69
|
+
### Worktree Launcher
|
|
117
70
|
|
|
118
|
-
|
|
71
|
+
Create isolated development environments and launch them instantly:
|
|
119
72
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- 📋 **Plan Persistence** — Save implementation plans with mermaid diagrams to `.cortex/plans/`
|
|
126
|
-
- 📝 **Session Management** — Record key decisions and context in `.cortex/sessions/`
|
|
127
|
-
- 🔄 **Pre-Implementation Workflow** — Agents ask about branch/worktree strategy before making changes
|
|
128
|
-
- 🎯 **Agent Handoff** — Seamless transition between Plan → Build → Debug agents
|
|
129
|
-
- 📚 **Skills System** — Domain-specific knowledge for web dev, testing, security, and more
|
|
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 |
|
|
130
78
|
|
|
131
|
-
|
|
79
|
+
Plans are automatically propagated into the worktree's `.cortex/plans/` so the new session has full context.
|
|
132
80
|
|
|
133
|
-
|
|
81
|
+
**Cross-platform terminal support** via the terminal driver system — automatically detects and integrates with 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.
|
|
134
82
|
|
|
135
|
-
###
|
|
83
|
+
### Task Finalizer
|
|
136
84
|
|
|
137
|
-
|
|
85
|
+
One tool to close the loop:
|
|
138
86
|
|
|
139
|
-
```json
|
|
140
|
-
{
|
|
141
|
-
"$schema": "https://opencode.ai/config.json",
|
|
142
|
-
"plugin": ["cortex-agents"]
|
|
143
|
-
}
|
|
144
87
|
```
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
### Option 2: Use the CLI Helper
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
# Install and configure
|
|
156
|
-
npx cortex-agents install
|
|
157
|
-
npx cortex-agents configure
|
|
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?"
|
|
158
95
|
```
|
|
159
96
|
|
|
160
|
-
###
|
|
97
|
+
### Auto-Prompted Documentation
|
|
161
98
|
|
|
162
|
-
|
|
163
|
-
npm install -g cortex-agents
|
|
164
|
-
cortex-agents install
|
|
165
|
-
cortex-agents configure
|
|
166
|
-
```
|
|
99
|
+
After every task, agents prompt you to document what you built:
|
|
167
100
|
|
|
168
|
-
|
|
101
|
+
| Type | What's Generated | Includes |
|
|
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 |
|
|
169
106
|
|
|
170
|
-
|
|
107
|
+
All docs are saved to `docs/` with an auto-generated `INDEX.md`.
|
|
171
108
|
|
|
172
|
-
|
|
173
|
-
npx cortex-agents install # Add plugin to opencode.json
|
|
174
|
-
npx cortex-agents configure # Interactive model selection
|
|
175
|
-
npx cortex-agents configure --reset # Reset to OpenCode default models
|
|
176
|
-
npx cortex-agents uninstall # Remove plugin, agents, skills, and model config
|
|
177
|
-
npx cortex-agents status # Show installation and model status
|
|
178
|
-
npx cortex-agents help # Show help
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
---
|
|
109
|
+
<br>
|
|
182
110
|
|
|
183
111
|
## Agents
|
|
184
112
|
|
|
185
113
|
### Primary Agents
|
|
186
114
|
|
|
187
|
-
|
|
115
|
+
Handle complex, multi-step work. Use your best model.
|
|
188
116
|
|
|
189
|
-
| Agent |
|
|
190
|
-
|
|
191
|
-
| **build** | Full-access development
|
|
192
|
-
| **plan** | Read-only analysis
|
|
193
|
-
| **debug** | Deep troubleshooting
|
|
117
|
+
| Agent | Role | Superpower |
|
|
118
|
+
|-------|------|-----------|
|
|
119
|
+
| **build** | Full-access development | Two-step branching strategy, worktree launcher, task finalizer, docs prompting |
|
|
120
|
+
| **plan** | Read-only analysis | Creates implementation plans with mermaid diagrams, hands off to build |
|
|
121
|
+
| **debug** | Deep troubleshooting | Full bash/edit access with hotfix workflow |
|
|
194
122
|
|
|
195
|
-
### Subagents
|
|
196
|
-
|
|
197
|
-
These agents handle focused tasks and use your **subagent model**:
|
|
198
|
-
|
|
199
|
-
| Agent | Description |
|
|
200
|
-
|-------|-------------|
|
|
201
|
-
| **@fullstack** | End-to-end feature implementation across frontend and backend |
|
|
202
|
-
| **@testing** | Test writing, coverage analysis, and test strategy |
|
|
203
|
-
| **@security** | Security audit and vulnerability detection |
|
|
204
|
-
| **@devops** | CI/CD pipelines and deployment automation |
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## Tools
|
|
123
|
+
### Subagents
|
|
209
124
|
|
|
210
|
-
|
|
125
|
+
Focused specialists launched **automatically** as parallel quality gates. Use a fast/cheap model.
|
|
211
126
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
127
|
+
| Agent | Role | Triggered By |
|
|
128
|
+
|-------|------|-------------|
|
|
129
|
+
| **@testing** | Writes tests, runs suite, reports coverage gaps | Build (always), Debug (always) |
|
|
130
|
+
| **@security** | OWASP audit, secrets scan, severity-rated findings | Build (always), Debug (if security-relevant) |
|
|
131
|
+
| **@fullstack** | End-to-end implementation + feasibility analysis | Build (multi-layer features), Plan (analysis) |
|
|
132
|
+
| **@devops** | Config validation, CI/CD best practices | Build (when CI/Docker/infra files change) |
|
|
215
133
|
|
|
216
|
-
|
|
217
|
-
- `worktree_create <name> <type>` - Create worktree in `../.worktrees/`
|
|
218
|
-
- `worktree_list` - List all worktrees
|
|
219
|
-
- `worktree_remove <name>` - Remove worktree (after merging)
|
|
220
|
-
- `worktree_open <name>` - Get command to open terminal in worktree
|
|
134
|
+
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.
|
|
221
135
|
|
|
222
|
-
|
|
223
|
-
- `branch_create <name> <type>` - Create feature/bugfix/hotfix/refactor/docs/test branch
|
|
224
|
-
- `branch_status` - Get current branch, check for uncommitted changes, detect protected branches
|
|
225
|
-
- `branch_switch <branch>` - Switch to existing branch
|
|
136
|
+
<br>
|
|
226
137
|
|
|
227
|
-
|
|
228
|
-
- `plan_save <title> <type> <content>` - Save plan to `.cortex/plans/`
|
|
229
|
-
- `plan_list [type]` - List saved plans (optionally filter by type)
|
|
230
|
-
- `plan_load <filename>` - Load a plan
|
|
231
|
-
- `plan_delete <filename>` - Delete a plan
|
|
138
|
+
## Tools
|
|
232
139
|
|
|
233
|
-
|
|
234
|
-
- `session_save <summary> [decisions]` - Save session summary with key decisions
|
|
235
|
-
- `session_list [limit]` - List recent sessions
|
|
236
|
-
- `session_load <filename>` - Load a session summary
|
|
140
|
+
23 tools bundled and auto-registered. No configuration needed.
|
|
237
141
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
- `docs_save <title> <type> <content>` - Save a documentation file with mermaid diagrams
|
|
241
|
-
- `docs_list [type]` - List documentation files (filter by decision, feature, flow, or all)
|
|
242
|
-
- `docs_index` - Rebuild `docs/INDEX.md` with links to all docs (auto-called by `docs_save`)
|
|
142
|
+
<table>
|
|
143
|
+
<tr><td width="50%">
|
|
243
144
|
|
|
244
|
-
|
|
145
|
+
**Git Workflow**
|
|
146
|
+
- `branch_status` - Current branch + change detection
|
|
147
|
+
- `branch_create` - Convention-named branches (with toast notifications)
|
|
148
|
+
- `branch_switch` - Safe branch switching
|
|
149
|
+
- `worktree_create` - Isolated worktree in `.worktrees/` (with toast notifications)
|
|
150
|
+
- `worktree_launch` - Launch worktree (terminal/PTY/background)
|
|
151
|
+
- `worktree_list` / `worktree_remove` / `worktree_open`
|
|
245
152
|
|
|
246
|
-
|
|
153
|
+
</td><td width="50%">
|
|
247
154
|
|
|
248
|
-
|
|
155
|
+
**Planning & Sessions**
|
|
156
|
+
- `plan_save` / `plan_load` / `plan_list` / `plan_delete`
|
|
157
|
+
- `session_save` / `session_list` / `session_load`
|
|
158
|
+
- `cortex_init` / `cortex_status` / `cortex_configure`
|
|
249
159
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
│ Agent: build │
|
|
253
|
-
│ Development mode — ready to │
|
|
254
|
-
│ implement │
|
|
255
|
-
└──────────────────────────────────┘
|
|
256
|
-
```
|
|
160
|
+
</td></tr>
|
|
161
|
+
<tr><td width="50%">
|
|
257
162
|
|
|
258
|
-
|
|
163
|
+
**Documentation**
|
|
164
|
+
- `docs_init` - Set up `docs/` structure
|
|
165
|
+
- `docs_save` - Save doc with mermaid diagrams
|
|
166
|
+
- `docs_list` - Browse all docs
|
|
167
|
+
- `docs_index` - Rebuild `docs/INDEX.md`
|
|
259
168
|
|
|
260
|
-
|
|
169
|
+
</td><td width="50%">
|
|
261
170
|
|
|
262
|
-
|
|
171
|
+
**Finalization & Config**
|
|
172
|
+
- `task_finalize` - Stage, commit, push, create PR
|
|
173
|
+
- Auto-detects worktree (targets main)
|
|
174
|
+
- Auto-populates PR from `.cortex/plans/`
|
|
175
|
+
- Warns if docs are missing
|
|
176
|
+
- `cortex_configure` - Set models from within an agent session
|
|
263
177
|
|
|
264
|
-
|
|
178
|
+
</td></tr>
|
|
179
|
+
</table>
|
|
265
180
|
|
|
266
|
-
>
|
|
181
|
+
<br>
|
|
267
182
|
|
|
268
|
-
|
|
183
|
+
## Skills
|
|
269
184
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
|
273
|
-
|
|
274
|
-
| **
|
|
185
|
+
14 domain-specific skill packs loaded on demand via the `skill` tool:
|
|
186
|
+
|
|
187
|
+
| Skill | Covers |
|
|
188
|
+
|-------|--------|
|
|
189
|
+
| **frontend-development** | React, Vue, Svelte, CSS architecture, accessibility |
|
|
190
|
+
| **backend-development** | API design, middleware, auth, caching, queue systems |
|
|
191
|
+
| **mobile-development** | React Native, Flutter, native iOS/Android patterns |
|
|
192
|
+
| **desktop-development** | Electron, Tauri, native desktop application patterns |
|
|
193
|
+
| **database-design** | Schema design, migrations, indexing, query optimization |
|
|
194
|
+
| **api-design** | REST, GraphQL, gRPC, versioning, documentation |
|
|
195
|
+
| **testing-strategies** | Unit, integration, E2E, TDD, coverage strategies |
|
|
196
|
+
| **security-hardening** | OWASP, auth/authz, input validation, secure coding |
|
|
197
|
+
| **deployment-automation** | CI/CD, Docker, Kubernetes, cloud deployment |
|
|
198
|
+
| **architecture-patterns** | Microservices, monorepo, event-driven, CQRS |
|
|
199
|
+
| **design-patterns** | GoF patterns, SOLID principles, DDD |
|
|
200
|
+
| **performance-optimization** | Profiling, caching, lazy loading, bundle optimization |
|
|
201
|
+
| **code-quality** | Refactoring, linting, code review, maintainability |
|
|
202
|
+
| **git-workflow** | Branching strategies, worktrees, rebase vs merge |
|
|
203
|
+
|
|
204
|
+
<br>
|
|
275
205
|
|
|
276
|
-
|
|
206
|
+
## Model Configuration
|
|
277
207
|
|
|
278
|
-
|
|
208
|
+
Cortex agents are **model-agnostic**. Configure globally or per-project:
|
|
279
209
|
|
|
280
|
-
```
|
|
281
|
-
|
|
210
|
+
```bash
|
|
211
|
+
npx cortex-agents configure # Global (all projects)
|
|
212
|
+
npx cortex-agents configure --project # Per-project (saves to .opencode/models.json)
|
|
282
213
|
```
|
|
283
214
|
|
|
284
|
-
This creates:
|
|
285
|
-
|
|
286
215
|
```
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
216
|
+
? Select model for PRIMARY agents:
|
|
217
|
+
Claude Sonnet 4 (anthropic) Best balance of intelligence and speed
|
|
218
|
+
Claude Opus 4 (anthropic) Most capable, best for complex architecture
|
|
219
|
+
GPT-4.1 (openai) Fast multimodal model
|
|
220
|
+
Gemini 2.5 Pro (google) Large context window, strong reasoning
|
|
221
|
+
Kimi K2P5 (kimi) Optimized for code generation
|
|
222
|
+
Enter custom model ID
|
|
223
|
+
|
|
224
|
+
? Select model for SUBAGENTS:
|
|
225
|
+
Claude 3.5 Haiku (anthropic) Fast and cost-effective
|
|
226
|
+
o4 Mini (openai) Fast reasoning, cost-effective
|
|
227
|
+
Gemini 2.5 Flash (google) Fast and efficient
|
|
228
|
+
Same as primary
|
|
292
229
|
```
|
|
293
230
|
|
|
294
|
-
###
|
|
231
|
+
### In-Agent Configuration
|
|
295
232
|
|
|
296
|
-
|
|
297
|
-
---
|
|
298
|
-
title: "Use OAuth2 for Authentication"
|
|
299
|
-
type: decision
|
|
300
|
-
date: 2026-02-22T10:30:00.000Z
|
|
301
|
-
status: accepted
|
|
302
|
-
tags: ["auth", "security"]
|
|
303
|
-
related_files: ["src/auth.ts", "src/middleware/jwt.ts"]
|
|
304
|
-
---
|
|
233
|
+
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.
|
|
305
234
|
|
|
306
|
-
|
|
235
|
+
### Per-Project vs Global
|
|
307
236
|
|
|
308
|
-
|
|
309
|
-
|
|
237
|
+
| Scope | Where | Use Case |
|
|
238
|
+
|-------|-------|----------|
|
|
239
|
+
| **Global** | `~/.config/opencode/opencode.json` | Default for all projects |
|
|
240
|
+
| **Per-project** | `.opencode/models.json` + `opencode.json` | Different models for different repos |
|
|
310
241
|
|
|
311
|
-
|
|
312
|
-
Use OAuth2 with JWT tokens for stateless authentication.
|
|
242
|
+
Per-project config takes priority. Team members get the same model settings when they clone the repo (`.opencode/models.json` is git-tracked).
|
|
313
243
|
|
|
314
|
-
|
|
244
|
+
### Supported Providers
|
|
315
245
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
246
|
+
| Provider | Premium | Standard | Fast |
|
|
247
|
+
|----------|---------|----------|------|
|
|
248
|
+
| **Anthropic** | Claude Opus 4 | Claude Sonnet 4 | Claude 3.5 Haiku |
|
|
249
|
+
| **OpenAI** | o3 | GPT-4.1 | o4 Mini |
|
|
250
|
+
| **Google** | Gemini 2.5 Pro | - | Gemini 2.5 Flash |
|
|
251
|
+
| **xAI** | Grok 3 | - | Grok 3 Mini |
|
|
252
|
+
| **DeepSeek** | DeepSeek R1 | - | DeepSeek Chat |
|
|
253
|
+
| **Kimi** | - | Kimi K2P5 | - |
|
|
322
254
|
|
|
323
|
-
|
|
255
|
+
> Don't see your provider? Select **"Enter custom model ID"** and type any `provider/model` string.
|
|
324
256
|
|
|
325
|
-
|
|
326
|
-
- All API endpoints require JWT validation middleware
|
|
327
|
-
- Token refresh logic needed on the frontend
|
|
328
|
-
```
|
|
257
|
+
<br>
|
|
329
258
|
|
|
330
|
-
|
|
259
|
+
## Project Structure
|
|
331
260
|
|
|
332
|
-
|
|
261
|
+
```
|
|
262
|
+
your-project/
|
|
263
|
+
.cortex/ Project context (auto-initialized)
|
|
264
|
+
config.json Configuration
|
|
265
|
+
plans/ Implementation plans (git tracked)
|
|
266
|
+
sessions/ Session summaries (gitignored)
|
|
267
|
+
.opencode/
|
|
268
|
+
models.json Per-project model config (git tracked)
|
|
269
|
+
.worktrees/ Git worktrees (gitignored)
|
|
270
|
+
feature-auth/ Isolated development copy
|
|
271
|
+
bugfix-login/
|
|
272
|
+
docs/ Documentation (git tracked)
|
|
273
|
+
INDEX.md Auto-generated index
|
|
274
|
+
decisions/ Architecture Decision Records
|
|
275
|
+
features/ Feature docs with diagrams
|
|
276
|
+
flows/ Process/data flow docs
|
|
277
|
+
```
|
|
333
278
|
|
|
334
|
-
|
|
335
|
-
# Project Documentation
|
|
279
|
+
<br>
|
|
336
280
|
|
|
337
|
-
|
|
281
|
+
## CLI Reference
|
|
338
282
|
|
|
339
|
-
|
|
283
|
+
```bash
|
|
284
|
+
npx cortex-agents install # Install plugin, agents, and skills
|
|
285
|
+
npx cortex-agents configure # Global model selection
|
|
286
|
+
npx cortex-agents configure --project # Per-project model selection
|
|
287
|
+
npx cortex-agents configure --reset # Reset global models
|
|
288
|
+
npx cortex-agents configure --project --reset # Reset per-project models
|
|
289
|
+
npx cortex-agents uninstall # Clean removal of everything
|
|
290
|
+
npx cortex-agents status # Show installation and model status
|
|
291
|
+
```
|
|
340
292
|
|
|
341
|
-
|
|
342
|
-
|------|-------|--------|------|
|
|
343
|
-
| 2026-02-22 | [Use OAuth2](decisions/2026-02-22-use-oauth2.md) | accepted | auth, security |
|
|
293
|
+
<br>
|
|
344
294
|
|
|
345
|
-
##
|
|
295
|
+
## How It Works
|
|
346
296
|
|
|
347
|
-
|
|
348
|
-
|------|-------|--------|------|
|
|
349
|
-
| 2026-02-22 | [User Auth](features/2026-02-22-user-auth.md) | implemented | auth |
|
|
297
|
+
### The Build Agent Workflow
|
|
350
298
|
|
|
351
|
-
|
|
299
|
+
Every time the build agent starts, it follows a structured pre-implementation checklist:
|
|
352
300
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
301
|
+
```
|
|
302
|
+
Step 1 branch_status Am I on a protected branch?
|
|
303
|
+
Step 2 cortex_status Is .cortex initialized? Offer model config if new project.
|
|
304
|
+
Step 3 plan_list / plan_load Is there a plan for this work?
|
|
305
|
+
Step 4 Ask: strategy Worktree (recommended) or branch?
|
|
306
|
+
Step 4b Ask: launch mode Terminal tab (recommended) / stay / PTY / background?
|
|
307
|
+
Step 5 Execute Create worktree/branch, auto-detect terminal
|
|
308
|
+
Step 6 Implement Write code following the plan
|
|
309
|
+
Step 7 Quality Gate Launch @testing + @security in parallel
|
|
310
|
+
Step 8 Ask: documentation Decision doc / feature doc / flow doc?
|
|
311
|
+
Step 9 session_save Record what was done and why
|
|
312
|
+
Step 10 task_finalize Commit, push, create PR
|
|
313
|
+
Step 11 Ask: cleanup Remove worktree + close terminal tab? (if applicable)
|
|
356
314
|
```
|
|
357
315
|
|
|
358
|
-
|
|
316
|
+
This isn't just documentation - it's enforced by the agent's instructions. The AI follows this workflow every time.
|
|
359
317
|
|
|
360
|
-
|
|
318
|
+
### Sub-Agent Quality Gates
|
|
361
319
|
|
|
362
|
-
|
|
320
|
+
After implementation (Step 7), the build agent **automatically** launches sub-agents in parallel as quality gates:
|
|
363
321
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
|
367
|
-
|
|
368
|
-
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
322
|
+
```
|
|
323
|
+
Build Agent completes implementation
|
|
324
|
+
|
|
|
325
|
+
+-- launches in parallel (single message) --+
|
|
326
|
+
| |
|
|
327
|
+
v v
|
|
328
|
+
@testing @security
|
|
329
|
+
Writes unit tests OWASP audit
|
|
330
|
+
Runs test suite Secrets scan
|
|
331
|
+
Reports coverage Severity ratings
|
|
332
|
+
Returns: PASS/FAIL Returns: PASS/FAIL
|
|
333
|
+
| |
|
|
334
|
+
+-------- results reviewed by Build ---------+
|
|
335
|
+
|
|
|
336
|
+
v
|
|
337
|
+
Quality Gate Summary included in PR body
|
|
338
|
+
```
|
|
372
339
|
|
|
373
|
-
|
|
340
|
+
The debug agent uses the same pattern: `@testing` for regression tests (always) and `@security` when the fix touches sensitive code.
|
|
341
|
+
|
|
342
|
+
Sub-agents use **structured return contracts** so results are actionable:
|
|
343
|
+
- `BLOCKING` / `CRITICAL` / `HIGH` findings block finalization
|
|
344
|
+
- `MEDIUM` findings are noted in the PR body
|
|
345
|
+
- `LOW` findings are deferred
|
|
374
346
|
|
|
375
|
-
|
|
347
|
+
### Agent Handover
|
|
376
348
|
|
|
377
|
-
|
|
349
|
+
When agents switch, a toast notification tells you what mode you're in:
|
|
378
350
|
|
|
379
351
|
```
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
├── Analyzes codebase structure
|
|
384
|
-
├── Creates implementation plan with mermaid diagrams
|
|
385
|
-
├── Saves to .cortex/plans/2024-02-22-feature-user-auth.md
|
|
386
|
-
└── Asks: "Plan saved. Switch to Build agent?"
|
|
387
|
-
|
|
388
|
-
User: "Yes"
|
|
389
|
-
|
|
390
|
-
Build Agent: 🔔 Toast: "Agent: build — Development mode"
|
|
391
|
-
├── Loads plan from .cortex/plans/
|
|
392
|
-
├── Checks git status (detects protected branch)
|
|
393
|
-
├── Asks: "Create branch or worktree?"
|
|
394
|
-
├── Creates feature/user-authentication
|
|
395
|
-
├── Implements following the plan
|
|
396
|
-
├── Saves session summary with key decisions
|
|
397
|
-
├── Asks: "Update project documentation?"
|
|
398
|
-
└── Saves feature doc with mermaid architecture diagram
|
|
352
|
+
Agent: build Development mode - ready to implement
|
|
353
|
+
Agent: plan Planning mode - read-only analysis
|
|
354
|
+
Agent: debug Debug mode - troubleshooting and fixes
|
|
399
355
|
```
|
|
400
356
|
|
|
401
|
-
|
|
357
|
+
The Plan agent creates plans with mermaid diagrams and hands off to Build. Build loads the plan and implements it. If something breaks, Debug takes over with full access.
|
|
402
358
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
### opencode.json (after running `configure`)
|
|
406
|
-
|
|
407
|
-
```json
|
|
408
|
-
{
|
|
409
|
-
"$schema": "https://opencode.ai/config.json",
|
|
410
|
-
"plugin": ["cortex-agents"],
|
|
411
|
-
"agent": {
|
|
412
|
-
"build": { "model": "anthropic/claude-sonnet-4-20250514" },
|
|
413
|
-
"plan": { "model": "anthropic/claude-sonnet-4-20250514" },
|
|
414
|
-
"debug": { "model": "anthropic/claude-sonnet-4-20250514" },
|
|
415
|
-
"fullstack": { "model": "anthropic/claude-haiku-3.5" },
|
|
416
|
-
"testing": { "model": "anthropic/claude-haiku-3.5" },
|
|
417
|
-
"security": { "model": "anthropic/claude-haiku-3.5" },
|
|
418
|
-
"devops": { "model": "anthropic/claude-haiku-3.5" }
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
```
|
|
359
|
+
<br>
|
|
422
360
|
|
|
423
|
-
|
|
361
|
+
## Requirements
|
|
424
362
|
|
|
425
|
-
|
|
363
|
+
- [OpenCode](https://opencode.ai) >= 1.0.0
|
|
364
|
+
- Node.js >= 18.0.0
|
|
365
|
+
- Git (for branch/worktree features)
|
|
366
|
+
- [GitHub CLI](https://cli.github.com/) (optional, for `task_finalize` PR creation)
|
|
426
367
|
|
|
427
|
-
|
|
428
|
-
<project-root>/
|
|
429
|
-
├── .cortex/
|
|
430
|
-
│ ├── config.json # Project configuration
|
|
431
|
-
│ ├── .gitignore # Ignores sessions/, keeps plans/
|
|
432
|
-
│ ├── plans/ # Implementation plans (git tracked)
|
|
433
|
-
│ │ └── YYYY-MM-DD-type-slug.md
|
|
434
|
-
│ └── sessions/ # Session summaries (gitignored)
|
|
435
|
-
│ └── YYYY-MM-DD-session-id.md
|
|
436
|
-
└── docs/ # Project documentation (git tracked)
|
|
437
|
-
├── INDEX.md # Auto-generated index
|
|
438
|
-
├── decisions/ # Architecture Decision Records
|
|
439
|
-
├── features/ # Feature docs with diagrams
|
|
440
|
-
└── flows/ # Process/data flow docs
|
|
441
|
-
```
|
|
368
|
+
<br>
|
|
442
369
|
|
|
443
|
-
|
|
370
|
+
## Contributing
|
|
444
371
|
|
|
445
|
-
|
|
372
|
+
Contributions are welcome! This is an Apache-2.0 licensed project and we'd love your help.
|
|
446
373
|
|
|
447
|
-
|
|
448
|
-
|------|--------|---------|
|
|
449
|
-
| Feature | `feature/` | `feature/user-authentication` |
|
|
450
|
-
| Bugfix | `bugfix/` | `bugfix/login-validation` |
|
|
451
|
-
| Hotfix | `hotfix/` | `hotfix/security-patch` |
|
|
452
|
-
| Refactor | `refactor/` | `refactor/api-cleanup` |
|
|
453
|
-
| Docs | `docs/` | `docs/api-reference` |
|
|
454
|
-
| Test | `test/` | `test/e2e-coverage` |
|
|
374
|
+
### Getting Started
|
|
455
375
|
|
|
456
|
-
|
|
376
|
+
```bash
|
|
377
|
+
git clone https://github.com/ps-carvalho/cortex-agents.git
|
|
378
|
+
cd cortex-agents
|
|
379
|
+
npm install
|
|
380
|
+
npm run build
|
|
381
|
+
```
|
|
457
382
|
|
|
458
|
-
|
|
383
|
+
### Development Workflow
|
|
459
384
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
385
|
+
```bash
|
|
386
|
+
# Link for local testing
|
|
387
|
+
npm link
|
|
388
|
+
cd ~/.config/opencode && npm link cortex-agents
|
|
463
389
|
|
|
464
|
-
|
|
390
|
+
# Make changes, rebuild, restart OpenCode
|
|
391
|
+
npm run build
|
|
465
392
|
|
|
466
|
-
|
|
393
|
+
# Unlink when done
|
|
394
|
+
cd ~/.config/opencode && npm unlink cortex-agents && npm install
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### What We're Looking For
|
|
467
398
|
|
|
468
|
-
|
|
399
|
+
- **New skills** - Domain-specific knowledge packs (e.g., Rust, Go, DevOps for AWS)
|
|
400
|
+
- **New agents** - Specialized agents (e.g., reviewer, migration, docs-writer)
|
|
401
|
+
- **Terminal drivers** - Improve detection/support for additional terminal emulators
|
|
402
|
+
- **Tool improvements** - Better PR templates, test runners, linter integration
|
|
403
|
+
- **Bug fixes** - Anything that doesn't work as expected
|
|
404
|
+
|
|
405
|
+
### Submitting Changes
|
|
469
406
|
|
|
470
407
|
1. Fork the repository
|
|
471
|
-
2. Create your
|
|
472
|
-
3. Commit
|
|
473
|
-
4. Push
|
|
474
|
-
5. Open a Pull Request
|
|
408
|
+
2. Create your branch (`git checkout -b feature/amazing-feature`)
|
|
409
|
+
3. Commit with conventional format (`git commit -m 'feat: add amazing feature'`)
|
|
410
|
+
4. Push and open a Pull Request
|
|
475
411
|
|
|
476
|
-
|
|
412
|
+
<br>
|
|
477
413
|
|
|
478
414
|
## License
|
|
479
415
|
|
|
480
|
-
[Apache-2.0](LICENSE)
|
|
416
|
+
[Apache-2.0](LICENSE)
|
|
481
417
|
|
|
482
|
-
|
|
418
|
+
<br>
|
|
483
419
|
|
|
484
420
|
<p align="center">
|
|
485
|
-
Built for the <a href="https://opencode.ai">OpenCode</a> community
|
|
421
|
+
<sub>Built for the <a href="https://opencode.ai">OpenCode</a> community</sub>
|
|
486
422
|
</p>
|