@mdsohail99/opencode-agent-teams 2.0.1 → 2.1.1

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/bin/cli.js CHANGED
@@ -71,7 +71,7 @@ function getStatus(globalMode = true) {
71
71
  configExists = true
72
72
  try {
73
73
  const parsed = JSON.parse(fs.readFileSync(configPath, "utf-8"))
74
- subagentDepth = parsed.subagent_depth ?? null
74
+ subagentDepth = parsed.experimental?.subagent_depth ?? parsed.subagent_depth ?? null
75
75
  if (Array.isArray(parsed.plugins)) {
76
76
  isPluginRegistered = parsed.plugins.some(
77
77
  (p) => typeof p === "string" && (p.includes("agent-teams") || p.includes("orchestration"))
@@ -112,7 +112,9 @@ async function doInstall(globalMode = true) {
112
112
 
113
113
  let config = {
114
114
  $schema: "https://opencode.ai/config.json",
115
- subagent_depth: 2,
115
+ experimental: {
116
+ subagent_depth: 2,
117
+ },
116
118
  plugins: [],
117
119
  }
118
120
 
@@ -124,22 +126,33 @@ async function doInstall(globalMode = true) {
124
126
  }
125
127
  }
126
128
 
127
- config.subagent_depth = 2
129
+ delete config.subagent_depth
130
+ if (!config.experimental || typeof config.experimental !== "object") {
131
+ config.experimental = {}
132
+ }
133
+ config.experimental.subagent_depth = 2
128
134
 
129
- const pluginRef = fs.existsSync(path.join(rootDir, "src", "index.ts"))
135
+ const isLocalDev = fs.existsSync(path.join(rootDir, ".git"))
136
+ const pluginRef = isLocalDev
130
137
  ? rootDir.replace(/\\/g, "/")
131
138
  : "@mdsohail99/opencode-agent-teams"
132
139
 
133
140
  if (!Array.isArray(config.plugins)) {
134
141
  config.plugins = []
135
142
  }
143
+ // Clean up any stale or temporary npx cache paths
144
+ config.plugins = config.plugins.filter((p) => {
145
+ if (typeof p !== "string") return true
146
+ if (p.includes("_npx") && p.includes("opencode-agent-teams")) return false
147
+ return true
148
+ })
136
149
  if (!config.plugins.includes(pluginRef)) {
137
150
  config.plugins.push(pluginRef)
138
151
  }
139
152
 
140
153
  fs.mkdirSync(path.dirname(configPath), { recursive: true })
141
154
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8")
142
- console.log(` ${c.green}✓${c.reset} Configured opencode.json (subagent_depth: 2, plugin: ${pluginRef})`)
155
+ console.log(` ${c.green}✓${c.reset} Configured opencode.json (experimental.subagent_depth: 2, plugin: ${pluginRef})`)
143
156
 
144
157
  const shippedAgents = getShippedAgents()
145
158
  if (shippedAgents.length > 0) {
@@ -154,7 +167,7 @@ async function doInstall(globalMode = true) {
154
167
 
155
168
  fs.writeFileSync(
156
169
  manifestPath,
157
- JSON.stringify({ plugin: "@mdsohail99/opencode-agent-teams", version: "2.0.0", files: installedList }, null, 2),
170
+ JSON.stringify({ plugin: "@mdsohail99/opencode-agent-teams", version: "2.1.0", files: installedList }, null, 2),
158
171
  "utf-8"
159
172
  )
160
173
  console.log(` ${c.green}✓${c.reset} Installed ${installedList.length} curated agents into ${agentsTargetDir}`)
@@ -306,6 +319,7 @@ const isLocal = args.includes("--local") || args.includes("-l")
306
319
  const isGlobal = !isLocal
307
320
  const isHelp = args.includes("--help") || args.includes("-h")
308
321
  const isStatus = args.includes("status") || args.includes("--status")
322
+ const isMenu = args.includes("menu") || args.includes("--menu")
309
323
  const isInstallExplicit = args.includes("install") || args.includes("--install")
310
324
 
311
325
  if (isHelp) {
@@ -314,6 +328,7 @@ Agent-Teams v2 CLI for OpenCode
314
328
 
315
329
  Usage:
316
330
  npx @mdsohail99/opencode-agent-teams Launch interactive menu (default)
331
+ npx @mdsohail99/opencode-agent-teams menu Launch interactive menu explicitly
317
332
  npx @mdsohail99/opencode-agent-teams install [options] Install Agent-Teams plugin and agents
318
333
  npx @mdsohail99/opencode-agent-teams uninstall [options] Uninstall Agent-Teams cleanly
319
334
  npx @mdsohail99/opencode-agent-teams status Inspect current status
@@ -331,6 +346,11 @@ if (isStatus) {
331
346
  process.exit(0)
332
347
  }
333
348
 
349
+ if (isMenu) {
350
+ await runInteractiveMenu()
351
+ process.exit(0)
352
+ }
353
+
334
354
  if (isUninstallCommand) {
335
355
  await doUninstall(isGlobal)
336
356
  process.exit(0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdsohail99/opencode-agent-teams",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Native Agent-Teams orchestration plugin for OpenCode v2",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,10 +25,10 @@
25
25
  "node": ">=20.19"
26
26
  },
27
27
  "dependencies": {
28
- "@opencode/client": "2.1.1",
29
- "@opencode/plugin": "2.1.1",
30
- "@opencode/schema": "2.1.1",
31
- "effect": "4.0.1"
28
+ "@opencode/client": "2.3.2",
29
+ "@opencode/plugin": "2.3.2",
30
+ "@opencode/schema": "2.3.2",
31
+ "effect": "4.1.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^24.12.2",
package/src/index.ts CHANGED
@@ -24,7 +24,8 @@ The swarm is organized into departments led by Orchestrators (Backend, Frontend,
24
24
  `
25
25
 
26
26
  /**
27
- * Ensures subagent_depth: 2 is present in an opencode.json configuration file.
27
+ * Ensures experimental.subagent_depth: 2 is present in an opencode.json configuration file
28
+ * and removes any deprecated top-level subagent_depth.
28
29
  */
29
30
  function ensureSubagentDepth(filePath: string) {
30
31
  try {
@@ -32,8 +33,20 @@ function ensureSubagentDepth(filePath: string) {
32
33
  const raw = fs.readFileSync(filePath, "utf-8")
33
34
  const parsed = JSON.parse(raw)
34
35
  if (typeof parsed === "object" && parsed !== null) {
35
- if (!parsed.subagent_depth || parsed.subagent_depth < 2) {
36
- parsed.subagent_depth = 2
36
+ let changed = false
37
+ if ("subagent_depth" in parsed) {
38
+ delete parsed.subagent_depth
39
+ changed = true
40
+ }
41
+ if (!parsed.experimental || typeof parsed.experimental !== "object") {
42
+ parsed.experimental = {}
43
+ changed = true
44
+ }
45
+ if (!parsed.experimental.subagent_depth || parsed.experimental.subagent_depth < 2) {
46
+ parsed.experimental.subagent_depth = 2
47
+ changed = true
48
+ }
49
+ if (changed) {
37
50
  fs.writeFileSync(filePath, JSON.stringify(parsed, null, 2), "utf-8")
38
51
  }
39
52
  }
@@ -46,10 +59,15 @@ function ensureSubagentDepth(filePath: string) {
46
59
  export default Plugin.define({
47
60
  id: "agent-teams",
48
61
  async setup(ctx: Plugin.Context) {
49
- // 0. Auto-ensure subagent_depth: 2 in local and config-dir opencode.json
62
+ // 0. Auto-ensure experimental.subagent_depth: 2 in local and config-dir opencode.json
50
63
  ensureSubagentDepth(path.resolve(process.cwd(), "opencode.json"))
51
64
  if (process.env.OPENCODE_CONFIG_DIR) {
52
65
  ensureSubagentDepth(path.join(process.env.OPENCODE_CONFIG_DIR, "opencode.json"))
66
+ } else {
67
+ const homeDir = process.env.USERPROFILE || process.env.HOME || ""
68
+ if (homeDir) {
69
+ ensureSubagentDepth(path.join(homeDir, ".config", "opencode", "opencode.json"))
70
+ }
53
71
  }
54
72
 
55
73
  // 1. Register Swarm Tools (team_delegate, team_status, team_broadcast, team_terminate)
@@ -15,7 +15,7 @@ export const DelegateInput = Schema.Struct({
15
15
  description: "Detailed instructions and requirements for the teammate",
16
16
  }),
17
17
  worktree: Schema.optional(Schema.Boolean).annotate({
18
- description: "Whether to run this task in an isolated git worktree to prevent concurrent write collisions (default: true)",
18
+ description: "Whether to run this task in an isolated git worktree (default: false; pass true for tasks modifying files concurrently)",
19
19
  }),
20
20
  })
21
21
 
@@ -40,7 +40,7 @@ export function createDelegateTool(ctx: Plugin.Context) {
40
40
  ) => {
41
41
  const taskId = crypto.randomUUID().slice(0, 8)
42
42
  const baseDir = process.cwd()
43
- const useWorktree = input.worktree !== false
43
+ const useWorktree = input.worktree === true
44
44
  const targetAgentId = normalizeAgentId(input.agent_type)
45
45
 
46
46
  let sandbox: WorktreeSandbox | undefined
@@ -106,7 +106,34 @@ export function createDelegateTool(ctx: Plugin.Context) {
106
106
  let deliverableText =
107
107
  (promptResult as any)?.text ||
108
108
  (promptResult as any)?.content ||
109
- "Task execution dispatched."
109
+ ""
110
+
111
+ // Inspect session context for the final assistant deliverable text
112
+ if (ctx.session?.context) {
113
+ try {
114
+ const messages = await ctx.session.context({ sessionID: sessionId } as any)
115
+ if (Array.isArray(messages)) {
116
+ for (let i = messages.length - 1; i >= 0; i--) {
117
+ const msg = messages[i]
118
+ if (msg?.type === "assistant" && Array.isArray(msg.content)) {
119
+ const textParts = msg.content
120
+ .filter((p: any) => p?.type === "text" && typeof p?.text === "string")
121
+ .map((p: any) => p.text)
122
+ if (textParts.length > 0) {
123
+ deliverableText = textParts.join("\n")
124
+ break
125
+ }
126
+ }
127
+ }
128
+ }
129
+ } catch {
130
+ // Non-fatal fallback
131
+ }
132
+ }
133
+
134
+ if (!deliverableText) {
135
+ deliverableText = `Task executed by ${targetAgentId} in session ${sessionId}.`
136
+ }
110
137
 
111
138
  // If a worktree was used, reconcile and merge changes back to base branch
112
139
  let reconcileNotice = ""