@mdsohail99/opencode-agent-teams 2.0.1 → 2.1.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/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,7 +126,11 @@ 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
135
  const pluginRef = fs.existsSync(path.join(rootDir, "src", "index.ts"))
130
136
  ? rootDir.replace(/\\/g, "/")
@@ -139,7 +145,7 @@ async function doInstall(globalMode = true) {
139
145
 
140
146
  fs.mkdirSync(path.dirname(configPath), { recursive: true })
141
147
  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})`)
148
+ console.log(` ${c.green}✓${c.reset} Configured opencode.json (experimental.subagent_depth: 2, plugin: ${pluginRef})`)
143
149
 
144
150
  const shippedAgents = getShippedAgents()
145
151
  if (shippedAgents.length > 0) {
@@ -154,7 +160,7 @@ async function doInstall(globalMode = true) {
154
160
 
155
161
  fs.writeFileSync(
156
162
  manifestPath,
157
- JSON.stringify({ plugin: "@mdsohail99/opencode-agent-teams", version: "2.0.0", files: installedList }, null, 2),
163
+ JSON.stringify({ plugin: "@mdsohail99/opencode-agent-teams", version: "2.1.0", files: installedList }, null, 2),
158
164
  "utf-8"
159
165
  )
160
166
  console.log(` ${c.green}✓${c.reset} Installed ${installedList.length} curated agents into ${agentsTargetDir}`)
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.0",
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 = ""