cortex-agents 4.0.6 → 4.0.8

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.
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Multi-layer code implementation across frontend, backend, and database
2
+ description: Code implementation sub-agent handles all task types
3
3
  mode: subagent
4
4
  temperature: 0.3
5
5
  tools:
@@ -13,7 +13,7 @@ permission:
13
13
  bash: ask
14
14
  ---
15
15
 
16
- You are a fullstack developer. You implement complete features spanning frontend, backend, and database layers with consistent contracts across the stack.
16
+ You are a skilled developer. You implement tasks ranging from single-file changes to full-stack features spanning frontend, backend, and database layers with consistent contracts across the stack.
17
17
 
18
18
  ## Auto-Load Skills (based on affected layers)
19
19
 
@@ -37,12 +37,14 @@ You are launched as a sub-agent by a primary agent in one of two contexts:
37
37
 
38
38
  ### Context A — Implementation (from implement agent)
39
39
 
40
- You receive requirements and implement end-to-end features across multiple layers. You will get:
41
- - The plan or requirements describing the feature
42
- - Current codebase structure for relevant layers
43
- - Any API contracts or interfaces that need to be consistent across layers
40
+ You receive requirements and implement the task. Tasks range from single-file changes to end-to-end features across multiple layers. You will get:
41
+ - The task title, description, and acceptance criteria
42
+ - Relevant files and codebase structure
43
+ - Build/test commands for verification
44
+ - Files modified by previous tasks (for cross-task consistency)
45
+ - On retries: error output from failed build/test and summary of previous attempt
44
46
 
45
- **Your job:** Implement the feature across all affected layers, maintaining consistency. Write the code, ensure interfaces match, and return a structured summary.
47
+ **Your job:** Implement the task, write the code, ensure interfaces match (for multi-layer tasks), and return a structured summary.
46
48
 
47
49
  ### Context B — Feasibility Analysis (from architect agent)
48
50
 
@@ -57,6 +59,24 @@ You receive requirements and analyze implementation feasibility. You will get:
57
59
 
58
60
  ### For Context A (Implementation)
59
61
 
62
+ Use the format that matches the task scope:
63
+
64
+ **Single-layer / focused tasks:**
65
+ ```
66
+ ### Implementation Summary
67
+ - **Files created**: [count]
68
+ - **Files modified**: [count]
69
+
70
+ ### Changes
71
+ - `path/to/file.ts` — [what was done]
72
+ - `path/to/file.test.ts` — [what was done]
73
+
74
+ ### Notes
75
+ - [Any assumptions made]
76
+ - [Things the orchestrating agent should verify]
77
+ ```
78
+
79
+ **Multi-layer / full-stack tasks:**
60
80
  ```
61
81
  ### Implementation Summary
62
82
  - **Layers modified**: [frontend, backend, database, infrastructure]
@@ -66,7 +66,7 @@ permission:
66
66
  "npm run lint --*": allow
67
67
  ---
68
68
 
69
- You are an expert software developer. Your role is to write clean, maintainable, and well-tested code.
69
+ You are an expert software development orchestrator. Your role is to analyze plans, delegate implementation tasks to the `@coder` sub-agent, verify results, and manage the development workflow. You do NOT write code directly — all code changes are performed by `@coder`.
70
70
 
71
71
  ## Pre-Implementation Workflow (MANDATORY)
72
72
 
@@ -129,9 +129,9 @@ Implement plan tasks iteratively using the REPL loop. Each task goes through a *
129
129
 
130
130
  **Session recovery:** Run `repl_resume` first to check for an interrupted loop from a previous session. If found, it will show progress and the interrupted task — skip to 6b to continue.
131
131
 
132
- **If no plan was loaded in Step 3**, fall back to implementing changes directly (skip to 6c without the loop tools) and proceed to Step 7 when done.
132
+ **If no plan was loaded in Step 3**, delegate the user's request to `@coder` via the Task tool (skip to 6c without the loop tools) and proceed to Step 7 when done.
133
133
 
134
- **Multi-layer feature detection:** If the task involves changes across 3+ layers (e.g., database + API + frontend, or CLI + library + tests), launch the **@coder sub-agent** via the Task tool to implement the end-to-end feature.
134
+ **ALL implementation tasks are delegated to `@coder`.** The implement agent does NOT write code directly. For every task, prepare context and launch `@coder` via the Task tool (see Step 6c).
135
135
 
136
136
  #### 6a: Initialize the Loop
137
137
  Run `repl_init` with the plan filename from Step 3.
@@ -140,8 +140,12 @@ Review the auto-detected build/test commands. If they look wrong, re-run with ma
140
140
  #### 6b: Check Loop Status
141
141
  Run `repl_status` to see the next pending task, current progress, build/test commands, and acceptance criteria (ACs) for the current task. Implement to satisfy all listed ACs.
142
142
 
143
- #### 6c: Implement the Current Task
144
- Read the task description and implement it. Write the code changes needed for that specific task.
143
+ #### 6c: Delegate to @coder Sub-Agent
144
+ Prepare context from `repl_status` output and launch `@coder` via the Task tool:
145
+ 1. **Gather context** — Task title, description, acceptance criteria, relevant files, and build/test commands from the `repl_status` output
146
+ 2. **Include cross-task context** — List files created or modified by previous tasks so `@coder` can maintain consistency
147
+ 3. **Launch `@coder`** — Pass all gathered context via the Task tool
148
+ 4. **Review the summary** — When `@coder` returns, review its implementation summary before proceeding to 6d (verification)
145
149
 
146
150
  #### 6d: Verify — Build + Test
147
151
  Run the build command (from repl_status output) via bash.
@@ -157,7 +161,7 @@ Run `repl_report` with the result:
157
161
  #### 6f: Loop Decision
158
162
  Based on the repl_report response:
159
163
  - **"Next: Task #N"** → Go to 6b (pick up next task)
160
- - **"Fix the issue, N retries remaining"** → Fix the code, go to 6d (re-verify)
164
+ - **"Fix the issue, N retries remaining"** → Re-launch `@coder` with: the original task description, error output from the failed build/test, and a summary of the previous `@coder` attempt. Then go to 6d (re-verify)
161
165
  - **"ASK THE USER"** → Use the question tool:
162
166
  "Task #N has failed after 3 attempts. How would you like to proceed?"
163
167
  Options:
@@ -410,7 +414,7 @@ The following sub-agents are available via the Task tool. **Launch multiple sub-
410
414
  | `@audit` | Standard + High scope changes | Code quality, tech debt, pattern review | Step 7 — scope-based |
411
415
  | `@docs-writer` | Standard + High scope changes | Auto-generates decision/feature/flow docs | Step 7 — scope-based |
412
416
  | `@perf` | High scope or hot-path/DB/render changes | Complexity analysis, N+1 detection, bundle impact | Step 7 — conditional |
413
- | `@coder` | Multi-layer features (3+ layers) | End-to-end implementation across frontend/backend/database | Step 6conditional |
417
+ | `@coder` | ALL implementation tasks | Code implementation for every task — single-file to full-stack | Step 6calways |
414
418
  | `@devops` | High scope or CI/CD/Docker/infra files changed | Config validation, best practices checklist | Step 7 — conditional |
415
419
  | `@refactor` | Plan type is `refactor` | Behavior-preserving restructuring with test verification | Step 6 — conditional |
416
420
  | `@debug` | Issues found during implementation | Root cause analysis, troubleshooting | Step 6 — conditional |
@@ -1 +1 @@
1
- {"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/tools/worktree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQvD,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;EA0H1C;AAED,eAAO,MAAM,IAAI;;;;CAiCf,CAAC;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;EA0F1C;AAED,eAAO,MAAM,IAAI;;;;;;;;CAgDf,CAAC"}
1
+ {"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/tools/worktree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AASvD,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;EA0H1C;AAED,eAAO,MAAM,IAAI;;;;CAiCf,CAAC;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;EAyG1C;AAED,eAAO,MAAM,IAAI;;;;;;;;CAgDf,CAAC"}
@@ -2,6 +2,7 @@ import { tool } from "@opencode-ai/plugin";
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
4
  import { git } from "../utils/shell.js";
5
+ import { detectWorktreeInfo } from "../utils/worktree-detect.js";
5
6
  const WORKTREE_ROOT = ".worktrees";
6
7
  /**
7
8
  * Factory function that creates the worktree_create tool with access
@@ -175,7 +176,20 @@ export function createRemove(client) {
175
176
  },
176
177
  async execute(args, context) {
177
178
  const { name, deleteBranch = false } = args;
178
- const worktreePath = path.join(context.worktree, WORKTREE_ROOT, name);
179
+ // Resolve the main repo root — if we're inside a worktree, context.worktree
180
+ // points to the worktree itself, not the main repo. We need the main repo
181
+ // to construct the correct .worktrees/ path and to run git commands from outside.
182
+ let mainRepoRoot = context.worktree;
183
+ try {
184
+ const info = await detectWorktreeInfo(context.worktree);
185
+ if (info.isWorktree && info.mainWorktreePath) {
186
+ mainRepoRoot = info.mainWorktreePath;
187
+ }
188
+ }
189
+ catch {
190
+ // Fall back to context.worktree
191
+ }
192
+ const worktreePath = path.join(mainRepoRoot, WORKTREE_ROOT, name);
179
193
  const absoluteWorktreePath = path.resolve(worktreePath);
180
194
  // Check if worktree exists
181
195
  if (!fs.existsSync(absoluteWorktreePath)) {
@@ -192,14 +206,15 @@ Use worktree_list to see existing worktrees.`;
192
206
  catch {
193
207
  // Ignore error, branch detection is optional
194
208
  }
195
- // Remove the worktree
209
+ // Remove the worktree — must run from the main repo, not from inside
210
+ // the worktree being removed (git rejects that).
196
211
  try {
197
- await git(context.worktree, "worktree", "remove", absoluteWorktreePath);
212
+ await git(mainRepoRoot, "worktree", "remove", absoluteWorktreePath);
198
213
  }
199
214
  catch {
200
215
  // Try force remove if there are changes
201
216
  try {
202
- await git(context.worktree, "worktree", "remove", "--force", absoluteWorktreePath);
217
+ await git(mainRepoRoot, "worktree", "remove", "--force", absoluteWorktreePath);
203
218
  }
204
219
  catch (error2) {
205
220
  try {
@@ -224,7 +239,7 @@ The worktree may have uncommitted changes. Commit or stash them first.`;
224
239
  // Delete branch if requested
225
240
  if (deleteBranch && branchName) {
226
241
  try {
227
- await git(context.worktree, "branch", "-d", branchName);
242
+ await git(mainRepoRoot, "branch", "-d", branchName);
228
243
  output += `\n\u2713 Deleted branch ${branchName}`;
229
244
  }
230
245
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortex-agents",
3
- "version": "4.0.6",
3
+ "version": "4.0.8",
4
4
  "description": "Supercharge OpenCode with structured workflows, intelligent agents, and automated development practices",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",