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/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 = "4.0.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 (architect, implement, fix) 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 (debug, coder, testing, security, devops, audit) 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,17 @@ EXAMPLES:
|
|
|
566
631
|
npx ${PLUGIN_NAME} status # Check status
|
|
567
632
|
|
|
568
633
|
AGENTS:
|
|
569
|
-
Primary (
|
|
634
|
+
Primary (architect, implement, fix):
|
|
570
635
|
Handle complex tasks — select your best model.
|
|
571
636
|
|
|
572
|
-
Subagents (
|
|
637
|
+
Subagents (debug, coder, testing, security, devops, audit):
|
|
573
638
|
Handle focused tasks — a fast/cheap model works great.
|
|
574
639
|
|
|
575
|
-
TOOLS (
|
|
640
|
+
TOOLS (29):
|
|
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
|
-
worktree_launch Launch worktree (terminal/PTY/background)
|
|
581
645
|
branch_create, branch_status Git branch operations
|
|
582
646
|
branch_switch
|
|
583
647
|
plan_save, plan_list Plan persistence
|
|
@@ -587,13 +651,17 @@ TOOLS (23):
|
|
|
587
651
|
docs_init, docs_save Mermaid documentation
|
|
588
652
|
docs_list, docs_index
|
|
589
653
|
task_finalize Commit, push, and create PR
|
|
654
|
+
github_status, github_issues GitHub issue and project browsing
|
|
655
|
+
github_projects
|
|
656
|
+
repl_init, repl_status Iterative task-by-task implementation loop
|
|
657
|
+
repl_report, repl_summary
|
|
590
658
|
|
|
591
659
|
SKILLS (14):
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
660
|
+
frontend-development, backend-development, mobile-development,
|
|
661
|
+
desktop-development, database-design, api-design,
|
|
662
|
+
architecture-patterns, design-patterns, testing-strategies,
|
|
663
|
+
security-hardening, deployment-automation, performance-optimization,
|
|
664
|
+
code-quality, git-workflow
|
|
597
665
|
`);
|
|
598
666
|
}
|
|
599
667
|
// ─── 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;AA+LlD,eAAO,MAAM,YAAY,EAAE,MAkJ1B,CAAC;AAGF,eAAe,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,15 +6,23 @@ 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 github from "./tools/github";
|
|
10
|
+
import * as repl from "./tools/repl";
|
|
11
|
+
import * as qualityGate from "./tools/quality-gate";
|
|
9
12
|
// ─── Agent Descriptions (for handover toasts) ───────────────────────────────
|
|
10
13
|
const AGENT_DESCRIPTIONS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
implement: "Development mode — ready to implement",
|
|
15
|
+
architect: "Planning mode — read-only analysis",
|
|
16
|
+
fix: "Quick fix mode — fast turnaround",
|
|
17
|
+
debug: "Debug subagent — root cause analysis",
|
|
18
|
+
coder: "Coder subagent — multi-layer implementation",
|
|
15
19
|
testing: "Testing subagent — writing tests",
|
|
16
20
|
security: "Security subagent — vulnerability audit",
|
|
17
21
|
devops: "DevOps subagent — CI/CD and deployment",
|
|
22
|
+
audit: "Audit subagent — code quality assessment",
|
|
23
|
+
refactor: "Refactor subagent — behavior-preserving restructuring",
|
|
24
|
+
"docs-writer": "Docs subagent — documentation generation",
|
|
25
|
+
perf: "Perf subagent — performance analysis",
|
|
18
26
|
};
|
|
19
27
|
const TOOL_NOTIFICATIONS = {
|
|
20
28
|
task_finalize: {
|
|
@@ -40,6 +48,7 @@ const TOOL_NOTIFICATIONS = {
|
|
|
40
48
|
errorTitle: "Plan Delete Failed",
|
|
41
49
|
errorMsg: (_, out) => out.substring(0, 100),
|
|
42
50
|
},
|
|
51
|
+
// plan_commit — excluded: uses factory-based toasts in createCommit()
|
|
43
52
|
session_save: {
|
|
44
53
|
successTitle: "Session Saved",
|
|
45
54
|
successMsg: () => "Session summary recorded",
|
|
@@ -79,6 +88,40 @@ const TOOL_NOTIFICATIONS = {
|
|
|
79
88
|
.split("\n")[0]
|
|
80
89
|
.substring(0, 100),
|
|
81
90
|
},
|
|
91
|
+
github_status: {
|
|
92
|
+
successTitle: "GitHub Connected",
|
|
93
|
+
successMsg: (_args, output) => {
|
|
94
|
+
const repoMatch = output.match(/Repository:\s+(.+)/);
|
|
95
|
+
return repoMatch ? `Connected to ${repoMatch[1].substring(0, 100)}` : "GitHub CLI available";
|
|
96
|
+
},
|
|
97
|
+
errorTitle: "GitHub Not Available",
|
|
98
|
+
errorMsg: (_, out) => out
|
|
99
|
+
.replace(/^✗\s*/, "")
|
|
100
|
+
.split("\n")[0]
|
|
101
|
+
.substring(0, 100),
|
|
102
|
+
},
|
|
103
|
+
repl_init: {
|
|
104
|
+
successTitle: "REPL Loop Started",
|
|
105
|
+
successMsg: (args) => `${(args.planFilename ?? "Plan").split("/").pop()?.substring(0, 40)} — tasks loaded`,
|
|
106
|
+
errorTitle: "REPL Init Failed",
|
|
107
|
+
errorMsg: (_, out) => out.substring(0, 100),
|
|
108
|
+
},
|
|
109
|
+
repl_report: {
|
|
110
|
+
successTitle: "Task Update",
|
|
111
|
+
successMsg: (args) => `Result: ${args.result ?? "reported"}`,
|
|
112
|
+
errorTitle: "Report Failed",
|
|
113
|
+
errorMsg: (_, out) => out.substring(0, 100),
|
|
114
|
+
},
|
|
115
|
+
quality_gate_summary: {
|
|
116
|
+
successTitle: "Quality Gate",
|
|
117
|
+
successMsg: (_args, output) => {
|
|
118
|
+
const recMatch = output.match(/\*\*Recommendation:\s*(GO|NO-GO|GO-WITH-WARNINGS)\*\*/);
|
|
119
|
+
return recMatch ? `Recommendation: ${recMatch[1]}` : "Summary generated";
|
|
120
|
+
},
|
|
121
|
+
errorTitle: "Quality Gate Failed",
|
|
122
|
+
errorMsg: (_, out) => out.substring(0, 100),
|
|
123
|
+
successDuration: 5000,
|
|
124
|
+
},
|
|
82
125
|
};
|
|
83
126
|
// ─── Error Message Extraction ────────────────────────────────────────────────
|
|
84
127
|
//
|
|
@@ -117,7 +160,6 @@ export const CortexPlugin = async (ctx) => {
|
|
|
117
160
|
worktree_list: worktree.list,
|
|
118
161
|
worktree_remove: worktree.createRemove(ctx.client),
|
|
119
162
|
worktree_open: worktree.open,
|
|
120
|
-
worktree_launch: worktree.createLaunch(ctx.client, ctx.$),
|
|
121
163
|
// Branch tools - git branch operations (factory for toast notifications)
|
|
122
164
|
branch_create: branch.createCreate(ctx.client),
|
|
123
165
|
branch_status: branch.status,
|
|
@@ -127,6 +169,7 @@ export const CortexPlugin = async (ctx) => {
|
|
|
127
169
|
plan_list: plan.list,
|
|
128
170
|
plan_load: plan.load,
|
|
129
171
|
plan_delete: plan.delete_,
|
|
172
|
+
plan_commit: plan.createCommit(ctx.client),
|
|
130
173
|
// Session tools - session summaries with decisions
|
|
131
174
|
session_save: session.save,
|
|
132
175
|
session_list: session.list,
|
|
@@ -138,6 +181,18 @@ export const CortexPlugin = async (ctx) => {
|
|
|
138
181
|
docs_index: docs.index,
|
|
139
182
|
// Task tools - finalize workflow (commit, push, PR)
|
|
140
183
|
task_finalize: task.finalize,
|
|
184
|
+
// GitHub integration tools - work item listing, issue selection, project boards
|
|
185
|
+
github_status: github.status,
|
|
186
|
+
github_issues: github.issues,
|
|
187
|
+
github_projects: github.projects,
|
|
188
|
+
// REPL loop tools - iterative task-by-task implementation
|
|
189
|
+
repl_init: repl.init,
|
|
190
|
+
repl_status: repl.status,
|
|
191
|
+
repl_report: repl.report,
|
|
192
|
+
repl_resume: repl.resume,
|
|
193
|
+
repl_summary: repl.summary,
|
|
194
|
+
// Quality gate aggregation tool
|
|
195
|
+
quality_gate_summary: qualityGate.qualityGateSummary,
|
|
141
196
|
},
|
|
142
197
|
// ── Post-execution toast notifications ────────────────────────────────
|
|
143
198
|
//
|
|
@@ -216,23 +271,6 @@ export const CortexPlugin = async (ctx) => {
|
|
|
216
271
|
},
|
|
217
272
|
});
|
|
218
273
|
}
|
|
219
|
-
// PTY exited notifications (relevant for worktree terminal sessions)
|
|
220
|
-
if (event.type === "pty.exited") {
|
|
221
|
-
const rawExitCode = event.properties.exitCode;
|
|
222
|
-
const exitCode = typeof rawExitCode === "number" && Number.isInteger(rawExitCode)
|
|
223
|
-
? rawExitCode
|
|
224
|
-
: -1;
|
|
225
|
-
await ctx.client.tui.showToast({
|
|
226
|
-
body: {
|
|
227
|
-
title: "Terminal Exited",
|
|
228
|
-
message: exitCode === 0
|
|
229
|
-
? "Terminal session completed successfully"
|
|
230
|
-
: `Terminal exited with code ${exitCode}`,
|
|
231
|
-
variant: exitCode === 0 ? "success" : "warning",
|
|
232
|
-
duration: exitCode === 0 ? 4000 : 8000,
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
274
|
}
|
|
237
275
|
catch {
|
|
238
276
|
// Toast failure is non-fatal — silently ignore
|
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 ["architect", "implement", "fix"];
|
|
23
23
|
/** Subagents receive a fast/cost-effective model */
|
|
24
|
-
export declare const SUBAGENTS: readonly ["
|
|
24
|
+
export declare const SUBAGENTS: readonly ["debug", "coder", "testing", "security", "devops", "audit", "refactor", "docs-writer", "perf"];
|
|
25
25
|
/** All agent names combined */
|
|
26
|
-
export declare const ALL_AGENTS: readonly ["
|
|
26
|
+
export declare const ALL_AGENTS: readonly ["architect", "implement", "fix", "debug", "coder", "testing", "security", "devops", "audit", "refactor", "docs-writer", "perf"];
|
|
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", "review.md", "fullstack.md", "crosslayer.md", "qa.md", "guard.md", "ship.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,4CAA6C,CAAC;AAEzE,oDAAoD;AACpD,eAAO,MAAM,SAAS,0GAA2G,CAAC;AAElI,+BAA+B;AAC/B,eAAO,MAAM,UAAU,2IAA6C,CAAC;AAErE;0EAC0E;AAC1E,eAAO,MAAM,uBAAuB,4BAA6B,CAAC;AAElE,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,gHASpB,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 = ["architect", "implement", "fix"];
|
|
109
109
|
/** Subagents receive a fast/cost-effective model */
|
|
110
|
-
export const SUBAGENTS = ["
|
|
110
|
+
export const SUBAGENTS = ["debug", "coder", "testing", "security", "devops", "audit", "refactor", "docs-writer", "perf"];
|
|
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
|
+
"review.md",
|
|
121
|
+
"fullstack.md",
|
|
122
|
+
"crosslayer.md",
|
|
123
|
+
"qa.md",
|
|
124
|
+
"guard.md",
|
|
125
|
+
"ship.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/branch.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export declare function createCreate(client: Client): {
|
|
|
9
9
|
args: {
|
|
10
10
|
name: import("zod").ZodString;
|
|
11
11
|
type: import("zod").ZodEnum<{
|
|
12
|
+
refactor: "refactor";
|
|
12
13
|
feature: "feature";
|
|
13
14
|
bugfix: "bugfix";
|
|
14
15
|
hotfix: "hotfix";
|
|
15
|
-
refactor: "refactor";
|
|
16
16
|
docs: "docs";
|
|
17
17
|
test: "test";
|
|
18
18
|
chore: "chore";
|
|
@@ -20,7 +20,7 @@ export declare function createCreate(client: Client): {
|
|
|
20
20
|
};
|
|
21
21
|
execute(args: {
|
|
22
22
|
name: string;
|
|
23
|
-
type: "
|
|
23
|
+
type: "refactor" | "feature" | "bugfix" | "hotfix" | "docs" | "test" | "chore";
|
|
24
24
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
25
25
|
};
|
|
26
26
|
export declare const status: {
|
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: {
|
package/dist/tools/cortex.js
CHANGED
|
@@ -151,13 +151,13 @@ Plans: ${planCount}`;
|
|
|
151
151
|
/**
|
|
152
152
|
* cortex_configure — Write per-project model configuration to ./opencode.json.
|
|
153
153
|
*
|
|
154
|
-
* Accepts a primary model (for
|
|
155
|
-
* (for
|
|
154
|
+
* Accepts a primary model (for implement/architect/fix/audit) and a subagent model
|
|
155
|
+
* (for crosslayer/qa/guard/ship). Merges into any existing
|
|
156
156
|
* opencode.json at the project root, preserving other settings.
|
|
157
157
|
*/
|
|
158
158
|
export const configure = tool({
|
|
159
159
|
description: "Save per-project model configuration to ./opencode.json. " +
|
|
160
|
-
"Sets the model for primary agents (
|
|
160
|
+
"Sets the model for primary agents (implement, architect, fix, audit) and subagents (crosslayer, qa, guard, ship). " +
|
|
161
161
|
"Available models — Premium: " +
|
|
162
162
|
MODEL_REGISTRY.filter((m) => m.tier === "premium")
|
|
163
163
|
.map((m) => `${m.name} (${m.id})`)
|
|
@@ -174,10 +174,10 @@ export const configure = tool({
|
|
|
174
174
|
args: {
|
|
175
175
|
primaryModel: z
|
|
176
176
|
.string()
|
|
177
|
-
.describe("Model ID for primary agents (
|
|
177
|
+
.describe("Model ID for primary agents (implement, architect, fix, audit). Format: provider/model-name"),
|
|
178
178
|
subagentModel: z
|
|
179
179
|
.string()
|
|
180
|
-
.describe("Model ID for subagents (
|
|
180
|
+
.describe("Model ID for subagents (crosslayer, qa, guard, ship). Format: provider/model-name"),
|
|
181
181
|
},
|
|
182
182
|
async execute(args, context) {
|
|
183
183
|
const configPath = path.join(context.worktree, "opencode.json");
|
|
@@ -246,10 +246,10 @@ export const configure = tool({
|
|
|
246
246
|
return `✓ Model configuration saved to:
|
|
247
247
|
${savedTo}
|
|
248
248
|
|
|
249
|
-
Primary agents (
|
|
249
|
+
Primary agents (implement, architect, fix, audit):
|
|
250
250
|
→ ${primaryDisplay} (${args.primaryModel})
|
|
251
251
|
|
|
252
|
-
Subagents (
|
|
252
|
+
Subagents (crosslayer, qa, guard, ship):
|
|
253
253
|
→ ${subagentDisplay} (${args.subagentModel})
|
|
254
254
|
|
|
255
255
|
Restart OpenCode to apply changes.`;
|
package/dist/tools/docs.d.ts
CHANGED
|
@@ -35,13 +35,13 @@ export declare const list: {
|
|
|
35
35
|
args: {
|
|
36
36
|
type: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
37
37
|
feature: "feature";
|
|
38
|
-
all: "all";
|
|
39
38
|
decision: "decision";
|
|
39
|
+
all: "all";
|
|
40
40
|
flow: "flow";
|
|
41
41
|
}>>;
|
|
42
42
|
};
|
|
43
43
|
execute(args: {
|
|
44
|
-
type?: "feature" | "
|
|
44
|
+
type?: "feature" | "decision" | "all" | "flow" | undefined;
|
|
45
45
|
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
46
46
|
};
|
|
47
47
|
export declare const index: {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Detection Tool
|
|
3
|
+
*
|
|
4
|
+
* Provides agents with information about the current development environment
|
|
5
|
+
* (IDE, terminal, editor) to offer contextually appropriate worktree launch options.
|
|
6
|
+
*
|
|
7
|
+
* Uses two detection systems:
|
|
8
|
+
* - IDE detection (ide.ts) — for "Open in IDE" options
|
|
9
|
+
* - Terminal detection (terminal.ts) — for "Open in terminal tab" options
|
|
10
|
+
*
|
|
11
|
+
* The terminal detection uses a multi-strategy chain:
|
|
12
|
+
* 1. Environment variables (fast, synchronous)
|
|
13
|
+
* 2. Process-tree walk (finds terminal in parent processes)
|
|
14
|
+
* 3. Frontmost app detection (macOS only)
|
|
15
|
+
* 4. User preference (.cortex/config.json)
|
|
16
|
+
*/
|
|
17
|
+
export declare const detectEnvironment: {
|
|
18
|
+
description: string;
|
|
19
|
+
args: {};
|
|
20
|
+
execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Quick environment check tool for agents.
|
|
24
|
+
* Returns a simplified response for quick decision-making.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getEnvironmentInfo: {
|
|
27
|
+
description: string;
|
|
28
|
+
args: {};
|
|
29
|
+
execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/tools/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,eAAO,MAAM,iBAAiB;;;;CAgD5B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;CA4B7B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Detection Tool
|
|
3
|
+
*
|
|
4
|
+
* Provides agents with information about the current development environment
|
|
5
|
+
* (IDE, terminal, editor) to offer contextually appropriate worktree launch options.
|
|
6
|
+
*
|
|
7
|
+
* Uses two detection systems:
|
|
8
|
+
* - IDE detection (ide.ts) — for "Open in IDE" options
|
|
9
|
+
* - Terminal detection (terminal.ts) — for "Open in terminal tab" options
|
|
10
|
+
*
|
|
11
|
+
* The terminal detection uses a multi-strategy chain:
|
|
12
|
+
* 1. Environment variables (fast, synchronous)
|
|
13
|
+
* 2. Process-tree walk (finds terminal in parent processes)
|
|
14
|
+
* 3. Frontmost app detection (macOS only)
|
|
15
|
+
* 4. User preference (.cortex/config.json)
|
|
16
|
+
*/
|
|
17
|
+
import { tool } from "@opencode-ai/plugin";
|
|
18
|
+
import { detectIDEWithCLICheck, formatEnvironmentReport, generateEnvironmentRecommendations } from "../utils/ide.js";
|
|
19
|
+
import { detectDriver, detectTerminalDriver } from "../utils/terminal.js";
|
|
20
|
+
export const detectEnvironment = tool({
|
|
21
|
+
description: "Detect the current development environment (IDE, terminal, editor) " +
|
|
22
|
+
"to offer contextually appropriate worktree launch options. " +
|
|
23
|
+
"Returns environment info and recommended launch options.",
|
|
24
|
+
args: {},
|
|
25
|
+
async execute(args, context) {
|
|
26
|
+
// Use async detection that verifies CLI availability in PATH
|
|
27
|
+
const ide = await detectIDEWithCLICheck();
|
|
28
|
+
const ideDriver = detectDriver();
|
|
29
|
+
// Multi-strategy terminal detection (the one used for "Open in terminal tab")
|
|
30
|
+
const terminalDetection = await detectTerminalDriver(context.worktree);
|
|
31
|
+
// Format the report (now includes CLI availability status)
|
|
32
|
+
const report = formatEnvironmentReport(ide, terminalDetection.driver.name);
|
|
33
|
+
// Add CLI status section
|
|
34
|
+
const additionalInfo = [];
|
|
35
|
+
additionalInfo.push(``, `### CLI Status`, ``);
|
|
36
|
+
additionalInfo.push(`- IDE: ${ide.name}`);
|
|
37
|
+
additionalInfo.push(`- IDE Driver: ${ideDriver.name}`);
|
|
38
|
+
additionalInfo.push(`- Terminal Emulator: **${terminalDetection.driver.name}**`);
|
|
39
|
+
additionalInfo.push(`- Platform: ${process.platform}`);
|
|
40
|
+
if (ide.cliBinary) {
|
|
41
|
+
if (ide.cliAvailable) {
|
|
42
|
+
additionalInfo.push(`- CLI: \`${ide.cliBinary}\` available in PATH`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
additionalInfo.push(`- CLI: \`${ide.cliBinary}\` **NOT found** in PATH`);
|
|
46
|
+
if (ide.cliInstallHint) {
|
|
47
|
+
additionalInfo.push(`- Fix: ${ide.cliInstallHint}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Terminal detection details
|
|
52
|
+
additionalInfo.push(``, `### Terminal Detection`, ``);
|
|
53
|
+
additionalInfo.push(`- Strategy: **${terminalDetection.strategy}**`);
|
|
54
|
+
if (terminalDetection.detail) {
|
|
55
|
+
additionalInfo.push(`- Detail: ${terminalDetection.detail}`);
|
|
56
|
+
}
|
|
57
|
+
additionalInfo.push(`- Driver: ${terminalDetection.driver.name}`);
|
|
58
|
+
additionalInfo.push(``);
|
|
59
|
+
additionalInfo.push(`When "Open in terminal tab" is selected, a new tab will open in **${terminalDetection.driver.name}**.`);
|
|
60
|
+
return report + additionalInfo.join("\n");
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Quick environment check tool for agents.
|
|
65
|
+
* Returns a simplified response for quick decision-making.
|
|
66
|
+
*/
|
|
67
|
+
export const getEnvironmentInfo = tool({
|
|
68
|
+
description: "Get quick environment info for deciding worktree launch options. " +
|
|
69
|
+
"Returns IDE type, terminal name, and whether to offer IDE-specific options.",
|
|
70
|
+
args: {},
|
|
71
|
+
async execute(args, context) {
|
|
72
|
+
const ide = await detectIDEWithCLICheck();
|
|
73
|
+
const terminalDetection = await detectTerminalDriver(context.worktree);
|
|
74
|
+
return JSON.stringify({
|
|
75
|
+
ide: {
|
|
76
|
+
type: ide.type,
|
|
77
|
+
name: ide.name,
|
|
78
|
+
hasIntegratedTerminal: ide.hasIntegratedTerminal,
|
|
79
|
+
canOpenInWindow: ide.canOpenInWindow,
|
|
80
|
+
cliAvailable: ide.cliAvailable,
|
|
81
|
+
cliBinary: ide.cliBinary,
|
|
82
|
+
cliInstallHint: ide.cliInstallHint,
|
|
83
|
+
},
|
|
84
|
+
terminal: {
|
|
85
|
+
name: terminalDetection.driver.name,
|
|
86
|
+
detectionStrategy: terminalDetection.strategy,
|
|
87
|
+
detectionDetail: terminalDetection.detail,
|
|
88
|
+
},
|
|
89
|
+
platform: process.platform,
|
|
90
|
+
recommendations: generateEnvironmentRecommendations(ide),
|
|
91
|
+
}, null, 2);
|
|
92
|
+
},
|
|
93
|
+
});
|