cortex-agents 2.3.1 → 3.4.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} +69 -15
- package/.opencode/agents/{fullstack.md → crosslayer.md} +2 -2
- package/.opencode/agents/{debug.md → fix.md} +11 -9
- package/.opencode/agents/{security.md → guard.md} +1 -1
- package/.opencode/agents/{build.md → implement.md} +121 -22
- package/.opencode/agents/{testing.md → qa.md} +1 -1
- package/.opencode/agents/{devops.md → ship.md} +1 -1
- package/README.md +107 -31
- package/dist/cli.js +87 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -7
- package/dist/registry.d.ts +8 -3
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +16 -2
- package/dist/tools/cortex.d.ts +2 -2
- package/dist/tools/cortex.js +7 -7
- 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/repl.d.ts +50 -0
- package/dist/tools/repl.d.ts.map +1 -0
- package/dist/tools/repl.js +240 -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.map +1 -1
- package/dist/tools/worktree.js +22 -11
- 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 +7 -0
- package/dist/utils/plan-extract.d.ts.map +1 -1
- package/dist/utils/plan-extract.js +25 -1
- package/dist/utils/repl.d.ts +114 -0
- package/dist/utils/repl.d.ts.map +1 -0
- package/dist/utils/repl.js +434 -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/dist/plugin.d.ts +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js +0 -4
- /package/.opencode/agents/{review.md → audit.md} +0 -0
package/README.md
CHANGED
|
@@ -43,7 +43,9 @@ npx cortex-agents configure # Pick your models interactively
|
|
|
43
43
|
# Restart OpenCode - done.
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
That's it. Your OpenCode session now has 8 specialized agents,
|
|
46
|
+
That's it. Your OpenCode session now has 8 specialized agents, 32 tools, and 14 domain skills.
|
|
47
|
+
|
|
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`.
|
|
47
49
|
|
|
48
50
|
<br>
|
|
49
51
|
|
|
@@ -56,10 +58,10 @@ Cortex agents follow a structured workflow from planning through to PR:
|
|
|
56
58
|
```
|
|
57
59
|
You: "Add user authentication"
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
saves to .cortex/plans/ "Plan saved. Switch to
|
|
61
|
+
Architect Agent reads codebase, creates plan with mermaid diagrams
|
|
62
|
+
saves to .cortex/plans/ "Plan saved. Switch to Implement?"
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
Implement Agent loads plan, checks git status
|
|
63
65
|
"You're on main. Create a branch two-step prompt: strategy -> execution
|
|
64
66
|
or worktree?"
|
|
65
67
|
creates feature/user-auth implements following the plan
|
|
@@ -72,13 +74,19 @@ Create isolated development environments and launch them instantly:
|
|
|
72
74
|
|
|
73
75
|
| Mode | What Happens |
|
|
74
76
|
|------|-------------|
|
|
77
|
+
| **IDE Terminal** | Opens in your detected IDE (VS Code, Cursor, Windsurf, Zed) with integrated terminal |
|
|
75
78
|
| **New Terminal** | Opens a new terminal tab with OpenCode pre-configured in the worktree |
|
|
76
79
|
| **In-App PTY** | Spawns an embedded terminal inside your current OpenCode session |
|
|
77
80
|
| **Background** | AI implements headlessly while you keep working - toast notifications on completion |
|
|
78
81
|
|
|
79
82
|
Plans are automatically propagated into the worktree's `.cortex/plans/` so the new session has full context.
|
|
80
83
|
|
|
81
|
-
**
|
|
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.
|
|
82
90
|
|
|
83
91
|
### Task Finalizer
|
|
84
92
|
|
|
@@ -116,10 +124,10 @@ Handle complex, multi-step work. Use your best model.
|
|
|
116
124
|
|
|
117
125
|
| Agent | Role | Superpower |
|
|
118
126
|
|-------|------|-----------|
|
|
119
|
-
| **
|
|
120
|
-
| **
|
|
121
|
-
| **
|
|
122
|
-
| **
|
|
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) |
|
|
123
131
|
|
|
124
132
|
### Subagents
|
|
125
133
|
|
|
@@ -127,10 +135,10 @@ Focused specialists launched **automatically** as parallel quality gates. Each a
|
|
|
127
135
|
|
|
128
136
|
| Agent | Role | Auto-Loads Skill | Triggered By |
|
|
129
137
|
|-------|------|-----------------|-------------|
|
|
130
|
-
| **@
|
|
131
|
-
| **@
|
|
132
|
-
| **@
|
|
133
|
-
| **@
|
|
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) |
|
|
134
142
|
|
|
135
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
144
|
|
|
@@ -139,7 +147,7 @@ Subagents return **structured reports** with severity levels (`BLOCKING`, `CRITI
|
|
|
139
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:
|
|
140
148
|
|
|
141
149
|
```
|
|
142
|
-
|
|
150
|
+
Implement Agent detects: package.json has React + Express + Prisma
|
|
143
151
|
→ auto-loads: frontend-development, backend-development, database-design, api-design
|
|
144
152
|
→ implements with deep framework-specific knowledge
|
|
145
153
|
```
|
|
@@ -148,7 +156,7 @@ Build Agent detects: package.json has React + Express + Prisma
|
|
|
148
156
|
|
|
149
157
|
## Tools
|
|
150
158
|
|
|
151
|
-
|
|
159
|
+
32 tools bundled and auto-registered. No configuration needed.
|
|
152
160
|
|
|
153
161
|
<table>
|
|
154
162
|
<tr><td width="50%">
|
|
@@ -167,6 +175,7 @@ Build Agent detects: package.json has React + Express + Prisma
|
|
|
167
175
|
- `plan_save` / `plan_load` / `plan_list` / `plan_delete`
|
|
168
176
|
- `session_save` / `session_list` / `session_load`
|
|
169
177
|
- `cortex_init` / `cortex_status` / `cortex_configure`
|
|
178
|
+
- `detect_environment` - Detect IDE/terminal for contextual launch options
|
|
170
179
|
|
|
171
180
|
</td></tr>
|
|
172
181
|
<tr><td width="50%">
|
|
@@ -183,9 +192,31 @@ Build Agent detects: package.json has React + Express + Prisma
|
|
|
183
192
|
- `task_finalize` - Stage, commit, push, create PR
|
|
184
193
|
- Auto-detects worktree (targets main)
|
|
185
194
|
- Auto-populates PR from `.cortex/plans/`
|
|
195
|
+
- Auto-links issues via `Closes #N` from plan metadata
|
|
186
196
|
- Warns if docs are missing
|
|
187
197
|
- `cortex_configure` - Set models from within an agent session
|
|
188
198
|
|
|
199
|
+
</td></tr>
|
|
200
|
+
<tr><td colspan="2">
|
|
201
|
+
|
|
202
|
+
**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
|
|
206
|
+
|
|
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
|
+
|
|
209
|
+
</td></tr>
|
|
210
|
+
<tr><td colspan="2">
|
|
211
|
+
|
|
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
|
|
217
|
+
|
|
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.
|
|
219
|
+
|
|
189
220
|
</td></tr>
|
|
190
221
|
</table>
|
|
191
222
|
|
|
@@ -273,8 +304,9 @@ Per-project config takes priority. Team members get the same model settings when
|
|
|
273
304
|
your-project/
|
|
274
305
|
.cortex/ Project context (auto-initialized)
|
|
275
306
|
config.json Configuration
|
|
276
|
-
plans/ Implementation plans (
|
|
307
|
+
plans/ Implementation plans (gitignored)
|
|
277
308
|
sessions/ Session summaries (gitignored)
|
|
309
|
+
repl-state.json REPL loop progress (gitignored, auto-managed)
|
|
278
310
|
.opencode/
|
|
279
311
|
models.json Per-project model config (git tracked)
|
|
280
312
|
.worktrees/ Git worktrees (gitignored)
|
|
@@ -305,9 +337,9 @@ npx cortex-agents status # Show installation and model sta
|
|
|
305
337
|
|
|
306
338
|
## How It Works
|
|
307
339
|
|
|
308
|
-
### The
|
|
340
|
+
### The Implement Agent Workflow
|
|
309
341
|
|
|
310
|
-
Every time the
|
|
342
|
+
Every time the implement agent starts, it follows a structured pre-implementation checklist:
|
|
311
343
|
|
|
312
344
|
```
|
|
313
345
|
Step 1 branch_status Am I on a protected branch?
|
|
@@ -316,8 +348,14 @@ Step 3 plan_list / plan_load Is there a plan for this work?
|
|
|
316
348
|
Step 4 Ask: strategy Worktree (recommended) or branch?
|
|
317
349
|
Step 4b Ask: launch mode Terminal tab (recommended) / stay / PTY / background?
|
|
318
350
|
Step 5 Execute Create worktree/branch, auto-detect terminal
|
|
319
|
-
Step 6
|
|
320
|
-
|
|
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)
|
|
321
359
|
Step 8 Ask: documentation Decision doc / feature doc / flow doc?
|
|
322
360
|
Step 9 session_save Record what was done and why
|
|
323
361
|
Step 10 task_finalize Commit, push, create PR
|
|
@@ -328,45 +366,83 @@ This isn't just documentation - it's enforced by the agent's instructions. The A
|
|
|
328
366
|
|
|
329
367
|
### Sub-Agent Quality Gates
|
|
330
368
|
|
|
331
|
-
After implementation (Step 7), the
|
|
369
|
+
After implementation (Step 7), the implement agent **automatically** launches sub-agents in parallel as quality gates:
|
|
332
370
|
|
|
333
371
|
```
|
|
334
|
-
|
|
372
|
+
Implement Agent completes implementation
|
|
335
373
|
|
|
|
336
374
|
+-- launches in parallel (single message) --+
|
|
337
375
|
| |
|
|
338
376
|
v v
|
|
339
|
-
@
|
|
377
|
+
@qa @guard
|
|
340
378
|
Writes unit tests OWASP audit
|
|
341
379
|
Runs test suite Secrets scan
|
|
342
380
|
Reports coverage Severity ratings
|
|
343
381
|
Returns: PASS/FAIL Returns: PASS/FAIL
|
|
344
382
|
| |
|
|
345
|
-
|
|
383
|
+
+------ results reviewed by Implement ------+
|
|
346
384
|
|
|
|
347
385
|
v
|
|
348
386
|
Quality Gate Summary included in PR body
|
|
349
387
|
```
|
|
350
388
|
|
|
351
|
-
The
|
|
389
|
+
The fix agent uses the same pattern: `@qa` for regression tests (always) and `@guard` when the fix touches sensitive code.
|
|
352
390
|
|
|
353
391
|
Sub-agents use **structured return contracts** so results are actionable:
|
|
354
392
|
- `BLOCKING` / `CRITICAL` / `HIGH` findings block finalization
|
|
355
393
|
- `MEDIUM` findings are noted in the PR body
|
|
356
394
|
- `LOW` findings are deferred
|
|
357
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
|
+
|
|
358
434
|
### Agent Handover
|
|
359
435
|
|
|
360
436
|
When agents switch, a toast notification tells you what mode you're in:
|
|
361
437
|
|
|
362
438
|
```
|
|
363
|
-
Agent:
|
|
364
|
-
Agent:
|
|
365
|
-
Agent:
|
|
366
|
-
Agent:
|
|
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
|
|
367
443
|
```
|
|
368
444
|
|
|
369
|
-
The
|
|
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.
|
|
370
446
|
|
|
371
447
|
<br>
|
|
372
448
|
|
|
@@ -375,7 +451,7 @@ The Plan agent creates plans with mermaid diagrams and hands off to Build. Build
|
|
|
375
451
|
- [OpenCode](https://opencode.ai) >= 1.0.0
|
|
376
452
|
- Node.js >= 18.0.0
|
|
377
453
|
- Git (for branch/worktree features)
|
|
378
|
-
- [GitHub CLI](https://cli.github.com/) (optional, for `task_finalize` PR creation)
|
|
454
|
+
- [GitHub CLI](https://cli.github.com/) (optional, for `task_finalize` PR creation and `github_*` tools)
|
|
379
455
|
|
|
380
456
|
<br>
|
|
381
457
|
|
package/dist/cli.js
CHANGED
|
@@ -3,8 +3,8 @@ import * as fs from "fs";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import prompts from "prompts";
|
|
6
|
-
import { PRIMARY_AGENTS, SUBAGENTS, ALL_AGENTS, getPrimaryChoices, getSubagentChoices, } from "./registry.js";
|
|
7
|
-
const VERSION = "
|
|
6
|
+
import { PRIMARY_AGENTS, SUBAGENTS, ALL_AGENTS, DISABLED_BUILTIN_AGENTS, STALE_AGENT_FILES, getPrimaryChoices, getSubagentChoices, } from "./registry.js";
|
|
7
|
+
const VERSION = "3.4.0";
|
|
8
8
|
const PLUGIN_NAME = "cortex-agents";
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
@@ -138,6 +138,23 @@ function installAgentsAndSkills(targetDir) {
|
|
|
138
138
|
console.log(` Installed ${count} skills -> ${skillsDest}`);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
+
function cleanupStaleAgents(globalDir) {
|
|
142
|
+
const agentsDir = path.join(globalDir, "agents");
|
|
143
|
+
if (!fs.existsSync(agentsDir))
|
|
144
|
+
return;
|
|
145
|
+
for (const file of STALE_AGENT_FILES) {
|
|
146
|
+
const filePath = path.join(agentsDir, file);
|
|
147
|
+
try {
|
|
148
|
+
if (fs.existsSync(filePath)) {
|
|
149
|
+
fs.unlinkSync(filePath);
|
|
150
|
+
console.log(` Cleaned up stale agent: ${file}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
console.warn(` Warning: Could not remove stale agent ${file}: ${err.message}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
141
158
|
function removeAgentsAndSkills(targetDir) {
|
|
142
159
|
const agentsSrc = path.join(PACKAGE_OPENCODE_DIR, "agents");
|
|
143
160
|
const skillsSrc = path.join(PACKAGE_OPENCODE_DIR, "skills");
|
|
@@ -173,9 +190,15 @@ function install() {
|
|
|
173
190
|
fs.mkdirSync(globalDir, { recursive: true });
|
|
174
191
|
}
|
|
175
192
|
const globalPath = path.join(globalDir, "opencode.json");
|
|
193
|
+
const disabledAgents = {};
|
|
194
|
+
for (const name of DISABLED_BUILTIN_AGENTS) {
|
|
195
|
+
disabledAgents[name] = { disable: true };
|
|
196
|
+
}
|
|
176
197
|
const newConfig = {
|
|
177
198
|
$schema: "https://opencode.ai/config.json",
|
|
178
199
|
plugin: [PLUGIN_NAME],
|
|
200
|
+
default_agent: "architect",
|
|
201
|
+
agent: disabledAgents,
|
|
179
202
|
};
|
|
180
203
|
writeConfig(globalPath, newConfig);
|
|
181
204
|
console.log(`Created config: ${globalPath}`);
|
|
@@ -187,16 +210,26 @@ function install() {
|
|
|
187
210
|
config.plugin = [];
|
|
188
211
|
if (!config.plugin.includes(PLUGIN_NAME)) {
|
|
189
212
|
config.plugin.push(PLUGIN_NAME);
|
|
190
|
-
writeConfig(configInfo.path, config);
|
|
191
|
-
console.log(`Added plugin to config: ${configInfo.path}\n`);
|
|
192
213
|
}
|
|
193
|
-
|
|
194
|
-
|
|
214
|
+
// Disable built-in agents that cortex-agents replaces
|
|
215
|
+
if (!config.agent)
|
|
216
|
+
config.agent = {};
|
|
217
|
+
for (const name of DISABLED_BUILTIN_AGENTS) {
|
|
218
|
+
if (!config.agent[name])
|
|
219
|
+
config.agent[name] = {};
|
|
220
|
+
config.agent[name].disable = true;
|
|
195
221
|
}
|
|
222
|
+
// Set default_agent, clean legacy camelCase key
|
|
223
|
+
config.default_agent = "architect";
|
|
224
|
+
delete config.defaultAgent;
|
|
225
|
+
writeConfig(configInfo.path, config);
|
|
226
|
+
console.log(`Updated config: ${configInfo.path}\n`);
|
|
196
227
|
}
|
|
197
228
|
// Copy agents and skills into the global opencode config dir
|
|
198
229
|
console.log("Installing agents and skills...");
|
|
199
230
|
installAgentsAndSkills(globalDir);
|
|
231
|
+
// Clean up stale agent files from previous cortex-agents versions
|
|
232
|
+
cleanupStaleAgents(globalDir);
|
|
200
233
|
// Sync per-project models if .opencode/models.json exists
|
|
201
234
|
if (hasProjectModelsConfig()) {
|
|
202
235
|
console.log("\nPer-project model config found (.opencode/models.json)");
|
|
@@ -233,11 +266,23 @@ function uninstall() {
|
|
|
233
266
|
}
|
|
234
267
|
}
|
|
235
268
|
}
|
|
269
|
+
// Re-enable built-in agents
|
|
270
|
+
for (const name of DISABLED_BUILTIN_AGENTS) {
|
|
271
|
+
if (config.agent[name]) {
|
|
272
|
+
delete config.agent[name].disable;
|
|
273
|
+
if (Object.keys(config.agent[name]).length === 0) {
|
|
274
|
+
delete config.agent[name];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
236
278
|
// Clean up empty agent object
|
|
237
279
|
if (Object.keys(config.agent).length === 0) {
|
|
238
280
|
delete config.agent;
|
|
239
281
|
}
|
|
240
282
|
}
|
|
283
|
+
// Remove default_agent + clean legacy key
|
|
284
|
+
delete config.default_agent;
|
|
285
|
+
delete config.defaultAgent;
|
|
241
286
|
writeConfig(configInfo.path, config);
|
|
242
287
|
// Remove agents and skills
|
|
243
288
|
const globalDir = getGlobalDir();
|
|
@@ -276,6 +321,12 @@ async function configure() {
|
|
|
276
321
|
config.plugin = [];
|
|
277
322
|
config.plugin.push(PLUGIN_NAME);
|
|
278
323
|
}
|
|
324
|
+
// Set default agent to architect (planning-first workflow)
|
|
325
|
+
if (!config.default_agent) {
|
|
326
|
+
config.default_agent = "architect";
|
|
327
|
+
}
|
|
328
|
+
// Clean legacy camelCase key
|
|
329
|
+
delete config.defaultAgent;
|
|
279
330
|
// ── Primary model selection ────────────────────────────────
|
|
280
331
|
const { primary, subagent } = await promptModelSelection();
|
|
281
332
|
// ── Write config ───────────────────────────────────────────
|
|
@@ -283,6 +334,14 @@ async function configure() {
|
|
|
283
334
|
// Per-project: write .opencode/models.json + sync to local opencode.json
|
|
284
335
|
writeProjectModels(primary, subagent);
|
|
285
336
|
syncProjectModelsToConfig();
|
|
337
|
+
// Ensure default agent is set in local opencode.json
|
|
338
|
+
const localConfig = readConfig(path.join(process.cwd(), "opencode.json"));
|
|
339
|
+
if (!localConfig.default_agent) {
|
|
340
|
+
localConfig.default_agent = "architect";
|
|
341
|
+
}
|
|
342
|
+
// Clean legacy camelCase key
|
|
343
|
+
delete localConfig.defaultAgent;
|
|
344
|
+
writeConfig(path.join(process.cwd(), "opencode.json"), localConfig);
|
|
286
345
|
const modelsPath = getProjectModelsPath();
|
|
287
346
|
const localConfigPath = path.join(process.cwd(), "opencode.json");
|
|
288
347
|
console.log("━".repeat(50));
|
|
@@ -304,6 +363,12 @@ async function configure() {
|
|
|
304
363
|
config.agent[name] = {};
|
|
305
364
|
config.agent[name].model = subagent;
|
|
306
365
|
}
|
|
366
|
+
// Re-assert disable entries for built-in agents
|
|
367
|
+
for (const name of DISABLED_BUILTIN_AGENTS) {
|
|
368
|
+
if (!config.agent[name])
|
|
369
|
+
config.agent[name] = {};
|
|
370
|
+
config.agent[name].disable = true;
|
|
371
|
+
}
|
|
307
372
|
const targetPath = configInfo?.path || path.join(getGlobalDir(), "opencode.json");
|
|
308
373
|
writeConfig(targetPath, config);
|
|
309
374
|
console.log("━".repeat(50));
|
|
@@ -330,7 +395,7 @@ async function promptModelSelection() {
|
|
|
330
395
|
description: "provider/model format",
|
|
331
396
|
value: "__custom__",
|
|
332
397
|
});
|
|
333
|
-
console.log("Primary agents (
|
|
398
|
+
console.log("Primary agents (implement, architect, fix, audit) handle complex tasks.\nUse your best available model.\n");
|
|
334
399
|
const { primaryModel } = await prompts({
|
|
335
400
|
type: "select",
|
|
336
401
|
name: "primaryModel",
|
|
@@ -364,7 +429,7 @@ async function promptModelSelection() {
|
|
|
364
429
|
description: "provider/model format",
|
|
365
430
|
value: "__custom__",
|
|
366
431
|
});
|
|
367
|
-
console.log("Subagents (
|
|
432
|
+
console.log("Subagents (crosslayer, qa, guard, ship) handle focused tasks.\nA faster/cheaper model works great here.\n");
|
|
368
433
|
const { subagentModel } = await prompts({
|
|
369
434
|
type: "select",
|
|
370
435
|
name: "subagentModel",
|
|
@@ -566,18 +631,20 @@ EXAMPLES:
|
|
|
566
631
|
npx ${PLUGIN_NAME} status # Check status
|
|
567
632
|
|
|
568
633
|
AGENTS:
|
|
569
|
-
Primary (
|
|
634
|
+
Primary (implement, architect, fix, audit):
|
|
570
635
|
Handle complex tasks — select your best model.
|
|
571
636
|
|
|
572
|
-
Subagents (
|
|
637
|
+
Subagents (crosslayer, qa, guard, ship):
|
|
573
638
|
Handle focused tasks — a fast/cheap model works great.
|
|
574
639
|
|
|
575
|
-
TOOLS (
|
|
640
|
+
TOOLS (32):
|
|
576
641
|
cortex_init, cortex_status .cortex directory management
|
|
577
642
|
cortex_configure Per-project model configuration
|
|
578
643
|
worktree_create, worktree_list Git worktree management
|
|
579
644
|
worktree_remove, worktree_open
|
|
580
645
|
worktree_launch Launch worktree (terminal/PTY/background)
|
|
646
|
+
detect_environment Detect IDE/terminal for launch options
|
|
647
|
+
get_environment_info Quick environment info for agents
|
|
581
648
|
branch_create, branch_status Git branch operations
|
|
582
649
|
branch_switch
|
|
583
650
|
plan_save, plan_list Plan persistence
|
|
@@ -587,13 +654,17 @@ TOOLS (23):
|
|
|
587
654
|
docs_init, docs_save Mermaid documentation
|
|
588
655
|
docs_list, docs_index
|
|
589
656
|
task_finalize Commit, push, and create PR
|
|
657
|
+
github_status, github_issues GitHub issue and project browsing
|
|
658
|
+
github_projects
|
|
659
|
+
repl_init, repl_status Iterative task-by-task implementation loop
|
|
660
|
+
repl_report, repl_summary
|
|
590
661
|
|
|
591
662
|
SKILLS (14):
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
663
|
+
frontend-development, backend-development, mobile-development,
|
|
664
|
+
desktop-development, database-design, api-design,
|
|
665
|
+
architecture-patterns, design-patterns, testing-strategies,
|
|
666
|
+
security-hardening, deployment-automation, performance-optimization,
|
|
667
|
+
code-quality, git-workflow
|
|
597
668
|
`);
|
|
598
669
|
}
|
|
599
670
|
// ─── CLI Entry Point ─────────────────────────────────────────────────────────
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAiLlD,eAAO,MAAM,YAAY,EAAE,MAsK1B,CAAC;AAGF,eAAe,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,15 +6,19 @@ import * as plan from "./tools/plan";
|
|
|
6
6
|
import * as session from "./tools/session";
|
|
7
7
|
import * as docs from "./tools/docs";
|
|
8
8
|
import * as task from "./tools/task";
|
|
9
|
+
import * as environment from "./tools/environment";
|
|
10
|
+
import * as github from "./tools/github";
|
|
11
|
+
import * as repl from "./tools/repl";
|
|
9
12
|
// ─── Agent Descriptions (for handover toasts) ───────────────────────────────
|
|
10
13
|
const AGENT_DESCRIPTIONS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
implement: "Development mode — ready to implement",
|
|
15
|
+
architect: "Planning mode — read-only analysis",
|
|
16
|
+
fix: "Debug mode — troubleshooting and fixes",
|
|
17
|
+
audit: "Review mode — code quality assessment",
|
|
18
|
+
crosslayer: "Crosslayer subagent — end-to-end implementation",
|
|
19
|
+
qa: "QA subagent — writing tests",
|
|
20
|
+
guard: "Security subagent — vulnerability audit",
|
|
21
|
+
ship: "DevOps subagent — CI/CD and deployment",
|
|
18
22
|
};
|
|
19
23
|
const TOOL_NOTIFICATIONS = {
|
|
20
24
|
task_finalize: {
|
|
@@ -79,6 +83,30 @@ const TOOL_NOTIFICATIONS = {
|
|
|
79
83
|
.split("\n")[0]
|
|
80
84
|
.substring(0, 100),
|
|
81
85
|
},
|
|
86
|
+
github_status: {
|
|
87
|
+
successTitle: "GitHub Connected",
|
|
88
|
+
successMsg: (_args, output) => {
|
|
89
|
+
const repoMatch = output.match(/Repository:\s+(.+)/);
|
|
90
|
+
return repoMatch ? `Connected to ${repoMatch[1].substring(0, 100)}` : "GitHub CLI available";
|
|
91
|
+
},
|
|
92
|
+
errorTitle: "GitHub Not Available",
|
|
93
|
+
errorMsg: (_, out) => out
|
|
94
|
+
.replace(/^✗\s*/, "")
|
|
95
|
+
.split("\n")[0]
|
|
96
|
+
.substring(0, 100),
|
|
97
|
+
},
|
|
98
|
+
repl_init: {
|
|
99
|
+
successTitle: "REPL Loop Started",
|
|
100
|
+
successMsg: (args) => `${(args.planFilename ?? "Plan").split("/").pop()?.substring(0, 40)} — tasks loaded`,
|
|
101
|
+
errorTitle: "REPL Init Failed",
|
|
102
|
+
errorMsg: (_, out) => out.substring(0, 100),
|
|
103
|
+
},
|
|
104
|
+
repl_report: {
|
|
105
|
+
successTitle: "Task Update",
|
|
106
|
+
successMsg: (args) => `Result: ${args.result ?? "reported"}`,
|
|
107
|
+
errorTitle: "Report Failed",
|
|
108
|
+
errorMsg: (_, out) => out.substring(0, 100),
|
|
109
|
+
},
|
|
82
110
|
};
|
|
83
111
|
// ─── Error Message Extraction ────────────────────────────────────────────────
|
|
84
112
|
//
|
|
@@ -138,6 +166,18 @@ export const CortexPlugin = async (ctx) => {
|
|
|
138
166
|
docs_index: docs.index,
|
|
139
167
|
// Task tools - finalize workflow (commit, push, PR)
|
|
140
168
|
task_finalize: task.finalize,
|
|
169
|
+
// Environment tools - IDE/terminal detection for contextual options
|
|
170
|
+
detect_environment: environment.detectEnvironment,
|
|
171
|
+
get_environment_info: environment.getEnvironmentInfo,
|
|
172
|
+
// GitHub integration tools - work item listing, issue selection, project boards
|
|
173
|
+
github_status: github.status,
|
|
174
|
+
github_issues: github.issues,
|
|
175
|
+
github_projects: github.projects,
|
|
176
|
+
// REPL loop tools - iterative task-by-task implementation
|
|
177
|
+
repl_init: repl.init,
|
|
178
|
+
repl_status: repl.status,
|
|
179
|
+
repl_report: repl.report,
|
|
180
|
+
repl_summary: repl.summary,
|
|
141
181
|
},
|
|
142
182
|
// ── Post-execution toast notifications ────────────────────────────────
|
|
143
183
|
//
|
package/dist/registry.d.ts
CHANGED
|
@@ -19,11 +19,16 @@ export interface ModelEntry {
|
|
|
19
19
|
}
|
|
20
20
|
export declare const MODEL_REGISTRY: ModelEntry[];
|
|
21
21
|
/** Primary agents receive the best available model */
|
|
22
|
-
export declare const PRIMARY_AGENTS: readonly ["
|
|
22
|
+
export declare const PRIMARY_AGENTS: readonly ["implement", "architect", "fix", "audit"];
|
|
23
23
|
/** Subagents receive a fast/cost-effective model */
|
|
24
|
-
export declare const SUBAGENTS: readonly ["
|
|
24
|
+
export declare const SUBAGENTS: readonly ["crosslayer", "qa", "guard", "ship"];
|
|
25
25
|
/** All agent names combined */
|
|
26
|
-
export declare const ALL_AGENTS: readonly ["
|
|
26
|
+
export declare const ALL_AGENTS: readonly ["implement", "architect", "fix", "audit", "crosslayer", "qa", "guard", "ship"];
|
|
27
|
+
/** OpenCode built-in agents disabled when cortex-agents is installed.
|
|
28
|
+
* Replaced by cortex equivalents: build → implement, plan → architect */
|
|
29
|
+
export declare const DISABLED_BUILTIN_AGENTS: readonly ["build", "plan"];
|
|
30
|
+
/** Old agent files to clean up from previous cortex-agents versions */
|
|
31
|
+
export declare const STALE_AGENT_FILES: readonly ["build.md", "plan.md", "debug.md", "review.md", "fullstack.md", "testing.md", "security.md", "devops.md"];
|
|
27
32
|
/**
|
|
28
33
|
* Build the interactive choices list for primary model selection.
|
|
29
34
|
* Shows premium and standard tier models (excluding fast).
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IACtC,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,UAAU,EAuGtC,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IACtC,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,UAAU,EAuGtC,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,cAAc,qDAAsD,CAAC;AAElF,oDAAoD;AACpD,eAAO,MAAM,SAAS,gDAAiD,CAAC;AAExE,+BAA+B;AAC/B,eAAO,MAAM,UAAU,0FAA6C,CAAC;AAErE;0EAC0E;AAC1E,eAAO,MAAM,uBAAuB,4BAA6B,CAAC;AAElE,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,qHASpB,CAAC;AAEX;;;GAGG;AACH,wBAAgB,iBAAiB;;;;IAMhC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM;;;;IAcxD"}
|
package/dist/registry.js
CHANGED
|
@@ -105,11 +105,25 @@ export const MODEL_REGISTRY = [
|
|
|
105
105
|
},
|
|
106
106
|
];
|
|
107
107
|
/** Primary agents receive the best available model */
|
|
108
|
-
export const PRIMARY_AGENTS = ["
|
|
108
|
+
export const PRIMARY_AGENTS = ["implement", "architect", "fix", "audit"];
|
|
109
109
|
/** Subagents receive a fast/cost-effective model */
|
|
110
|
-
export const SUBAGENTS = ["
|
|
110
|
+
export const SUBAGENTS = ["crosslayer", "qa", "guard", "ship"];
|
|
111
111
|
/** All agent names combined */
|
|
112
112
|
export const ALL_AGENTS = [...PRIMARY_AGENTS, ...SUBAGENTS];
|
|
113
|
+
/** OpenCode built-in agents disabled when cortex-agents is installed.
|
|
114
|
+
* Replaced by cortex equivalents: build → implement, plan → architect */
|
|
115
|
+
export const DISABLED_BUILTIN_AGENTS = ["build", "plan"];
|
|
116
|
+
/** Old agent files to clean up from previous cortex-agents versions */
|
|
117
|
+
export const STALE_AGENT_FILES = [
|
|
118
|
+
"build.md",
|
|
119
|
+
"plan.md",
|
|
120
|
+
"debug.md",
|
|
121
|
+
"review.md",
|
|
122
|
+
"fullstack.md",
|
|
123
|
+
"testing.md",
|
|
124
|
+
"security.md",
|
|
125
|
+
"devops.md",
|
|
126
|
+
];
|
|
113
127
|
/**
|
|
114
128
|
* Build the interactive choices list for primary model selection.
|
|
115
129
|
* Shows premium and standard tier models (excluding fast).
|
package/dist/tools/cortex.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare const status: {
|
|
|
12
12
|
/**
|
|
13
13
|
* cortex_configure — Write per-project model configuration to ./opencode.json.
|
|
14
14
|
*
|
|
15
|
-
* Accepts a primary model (for
|
|
16
|
-
* (for
|
|
15
|
+
* Accepts a primary model (for implement/architect/fix/audit) and a subagent model
|
|
16
|
+
* (for crosslayer/qa/guard/ship). Merges into any existing
|
|
17
17
|
* opencode.json at the project root, preserving other settings.
|
|
18
18
|
*/
|
|
19
19
|
export declare const configure: {
|