@doingdev/opencode-claude-manager-plugin 0.1.26 → 0.1.27

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,13 +1,15 @@
1
1
  /**
2
- * Agent hierarchy configuration for the CTO Manager Engineer architecture.
2
+ * Agent hierarchy configuration for the CTO + Engineer Wrapper architecture.
3
3
  *
4
- * CTO (cto) direction-setting, orchestration, spawns managers
5
- * Manager (manager) — operates Claude Code engineer via persistent session
6
- * Engineer the Claude Code session itself (prompt only, no OpenCode agent)
4
+ * CTO (cto) main operator, directly controls Claude Code sessions
5
+ * Engineer Plan (engineer_plan) — thin subagent wrapper for read-only investigation
6
+ * Engineer Build (engineer_build) thin subagent wrapper for implementation tasks
7
+ * Engineer — the Claude Code session itself (prompt only, no OpenCode agent)
7
8
  */
8
9
  import type { ManagerPromptRegistry } from '../types/contracts.js';
9
10
  export declare const AGENT_CTO = "cto";
10
- export declare const AGENT_MANAGER = "manager";
11
+ export declare const AGENT_ENGINEER_PLAN = "engineer_plan";
12
+ export declare const AGENT_ENGINEER_BUILD = "engineer_build";
11
13
  /** All restricted tool IDs (union of engineer + git + approval) */
12
14
  export declare const ALL_RESTRICTED_TOOL_IDS: readonly ["engineer_send", "engineer_compact", "engineer_clear", "engineer_status", "engineer_metadata", "engineer_sessions", "engineer_runs", "git_diff", "git_commit", "git_reset", "approval_policy", "approval_decisions", "approval_update"];
13
15
  type ToolPermission = 'allow' | 'ask' | 'deny';
@@ -35,7 +37,14 @@ export declare function buildCtoAgentConfig(prompts: ManagerPromptRegistry): {
35
37
  permission: AgentPermission;
36
38
  prompt: string;
37
39
  };
38
- export declare function buildManagerAgentConfig(prompts: ManagerPromptRegistry): {
40
+ export declare function buildEngineerPlanAgentConfig(prompts: ManagerPromptRegistry): {
41
+ description: string;
42
+ mode: "subagent";
43
+ color: string;
44
+ permission: AgentPermission;
45
+ prompt: string;
46
+ };
47
+ export declare function buildEngineerBuildAgentConfig(prompts: ManagerPromptRegistry): {
39
48
  description: string;
40
49
  mode: "subagent";
41
50
  color: string;
@@ -1,15 +1,17 @@
1
1
  /**
2
- * Agent hierarchy configuration for the CTO Manager Engineer architecture.
2
+ * Agent hierarchy configuration for the CTO + Engineer Wrapper architecture.
3
3
  *
4
- * CTO (cto) direction-setting, orchestration, spawns managers
5
- * Manager (manager) — operates Claude Code engineer via persistent session
6
- * Engineer the Claude Code session itself (prompt only, no OpenCode agent)
4
+ * CTO (cto) main operator, directly controls Claude Code sessions
5
+ * Engineer Plan (engineer_plan) — thin subagent wrapper for read-only investigation
6
+ * Engineer Build (engineer_build) thin subagent wrapper for implementation tasks
7
+ * Engineer — the Claude Code session itself (prompt only, no OpenCode agent)
7
8
  */
8
9
  // ---------------------------------------------------------------------------
9
10
  // Agent names
10
11
  // ---------------------------------------------------------------------------
11
12
  export const AGENT_CTO = 'cto';
12
- export const AGENT_MANAGER = 'manager';
13
+ export const AGENT_ENGINEER_PLAN = 'engineer_plan';
14
+ export const AGENT_ENGINEER_BUILD = 'engineer_build';
13
15
  // ---------------------------------------------------------------------------
14
16
  // Tool IDs — grouped by domain
15
17
  // ---------------------------------------------------------------------------
@@ -37,6 +39,8 @@ export const ALL_RESTRICTED_TOOL_IDS = [
37
39
  ...GIT_TOOL_IDS,
38
40
  ...APPROVAL_TOOL_IDS,
39
41
  ];
42
+ /** Tools available to engineer wrapper subagents (thin wrappers around Claude Code) */
43
+ const ENGINEER_WRAPPER_TOOL_IDS = ['engineer_send', 'engineer_status'];
40
44
  // ---------------------------------------------------------------------------
41
45
  // Shared read-only tool permissions
42
46
  // ---------------------------------------------------------------------------
@@ -54,27 +58,31 @@ const READONLY_TOOLS = {
54
58
  // ---------------------------------------------------------------------------
55
59
  // Permission builders
56
60
  // ---------------------------------------------------------------------------
57
- /** CTO: orchestration onlyexplicitly denies every restricted tool, no edit, no bash. */
61
+ /** CTO: full operatorall restricted tools + read-only codebase tools. No edit, no bash. */
58
62
  function buildCtoPermissions() {
59
- const denied = {};
63
+ const allowed = {};
60
64
  for (const toolId of ALL_RESTRICTED_TOOL_IDS) {
61
- denied[toolId] = 'deny';
65
+ allowed[toolId] = 'allow';
62
66
  }
63
67
  return {
64
68
  '*': 'deny',
65
69
  ...READONLY_TOOLS,
66
- ...denied,
70
+ ...allowed,
67
71
  };
68
72
  }
69
- /** Manager: full restricted tool surface + read-only codebase tools. No edit, no bash. */
70
- function buildManagerPermissions() {
71
- const allowed = {};
73
+ /** Engineer wrapper: only engineer_send + engineer_status. Everything else denied. */
74
+ function buildEngineerWrapperPermissions() {
75
+ const denied = {};
72
76
  for (const toolId of ALL_RESTRICTED_TOOL_IDS) {
77
+ denied[toolId] = 'deny';
78
+ }
79
+ const allowed = {};
80
+ for (const toolId of ENGINEER_WRAPPER_TOOL_IDS) {
73
81
  allowed[toolId] = 'allow';
74
82
  }
75
83
  return {
76
84
  '*': 'deny',
77
- ...READONLY_TOOLS,
85
+ ...denied,
78
86
  ...allowed,
79
87
  };
80
88
  }
@@ -83,20 +91,29 @@ function buildManagerPermissions() {
83
91
  // ---------------------------------------------------------------------------
84
92
  export function buildCtoAgentConfig(prompts) {
85
93
  return {
86
- description: 'CTO agent that sets direction and orchestrates work by spawning manager subagents. Does not operate Claude Code directly.',
94
+ description: 'CTO agent that directly operates Claude Code, gathers information, investigates, reviews, and commits. Can spawn engineer wrappers for parallel or isolated work.',
87
95
  mode: 'primary',
88
96
  color: '#D97757',
89
97
  permission: buildCtoPermissions(),
90
98
  prompt: prompts.ctoSystemPrompt,
91
99
  };
92
100
  }
93
- export function buildManagerAgentConfig(prompts) {
101
+ export function buildEngineerPlanAgentConfig(prompts) {
102
+ return {
103
+ description: 'Thin wrapper that sends a read-only investigation task to Claude Code in plan mode and returns the result.',
104
+ mode: 'subagent',
105
+ color: '#D97757',
106
+ permission: buildEngineerWrapperPermissions(),
107
+ prompt: prompts.engineerPlanPrompt,
108
+ };
109
+ }
110
+ export function buildEngineerBuildAgentConfig(prompts) {
94
111
  return {
95
- description: 'Manager agent that operates Claude Code through a persistent session, reviews work via git diff, and commits/resets changes.',
112
+ description: 'Thin wrapper that sends an implementation task to Claude Code in free mode and returns the result.',
96
113
  mode: 'subagent',
97
114
  color: '#D97757',
98
- permission: buildManagerPermissions(),
99
- prompt: prompts.managerSystemPrompt,
115
+ permission: buildEngineerWrapperPermissions(),
116
+ prompt: prompts.engineerBuildPrompt,
100
117
  };
101
118
  }
102
119
  // ---------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  import { tool } from '@opencode-ai/plugin';
2
2
  import { managerPromptRegistry } from '../prompts/registry.js';
3
- import { AGENT_CTO, AGENT_MANAGER, buildCtoAgentConfig, buildManagerAgentConfig, denyRestrictedToolsGlobally, } from './agent-hierarchy.js';
3
+ import { AGENT_CTO, AGENT_ENGINEER_BUILD, AGENT_ENGINEER_PLAN, buildCtoAgentConfig, buildEngineerBuildAgentConfig, buildEngineerPlanAgentConfig, denyRestrictedToolsGlobally, } from './agent-hierarchy.js';
4
4
  import { getOrCreatePluginServices } from './service-factory.js';
5
5
  export const ClaudeManagerPlugin = async ({ worktree }) => {
6
6
  const services = getOrCreatePluginServices(worktree);
@@ -10,7 +10,8 @@ export const ClaudeManagerPlugin = async ({ worktree }) => {
10
10
  config.permission ??= {};
11
11
  denyRestrictedToolsGlobally(config.permission);
12
12
  config.agent[AGENT_CTO] ??= buildCtoAgentConfig(managerPromptRegistry);
13
- config.agent[AGENT_MANAGER] ??= buildManagerAgentConfig(managerPromptRegistry);
13
+ config.agent[AGENT_ENGINEER_PLAN] ??= buildEngineerPlanAgentConfig(managerPromptRegistry);
14
+ config.agent[AGENT_ENGINEER_BUILD] ??= buildEngineerBuildAgentConfig(managerPromptRegistry);
14
15
  },
15
16
  tool: {
16
17
  engineer_send: tool({
@@ -1,55 +1,19 @@
1
1
  export const managerPromptRegistry = {
2
2
  ctoSystemPrompt: [
3
- 'You are the CTO — you set direction and orchestrate, but you never execute directly.',
3
+ 'You are the CTO — a top 0.001% Claude Code operator.',
4
+ 'You directly operate Claude Code through a persistent session, gather information,',
5
+ 'investigate code, review diffs, and commit changes. You can also spawn thin',
6
+ 'engineer wrapper subagents for parallel or isolated work.',
4
7
  '',
5
8
  '## Your role',
6
- "- Analyze the user's request and break it into focused slices of work.",
7
- '- Spawn one or more `manager` subagents, each with a clear, scoped objective.',
8
- '- Each `manager` has its own Claude Code persistent session and can investigate,',
9
- ' delegate to the engineer, review diffs, and commit.',
10
- '- Review subagent results and synthesize them for the user.',
11
- '',
12
- '## What you can do',
13
- '- Read files, grep, and search the codebase to understand the problem.',
14
- '- Use webfetch / websearch for external context.',
15
- '- Use todowrite / todoread to track high-level progress.',
16
- '- Ask the user structured questions when decisions require their input.',
17
- '',
18
- '## What you must NOT do',
19
- '- Do NOT call any engineer_*, git_*, or approval_* tools. You do not operate Claude Code directly.',
20
- '- Do NOT edit files, run bash commands, or make code changes yourself.',
21
- '- Do NOT micro-manage subagents — give them clear objectives and let them execute.',
22
- '',
23
- '## Spawning subagents',
24
- '- Spawn a `manager` subagent for each independent slice of work.',
25
- '- If slices are independent, spawn them in parallel.',
26
- '- Provide each subagent with:',
27
- ' 1. A clear, scoped objective.',
28
- ' 2. Relevant file paths, function names, and context you gathered.',
29
- ' 3. Success criteria so the subagent knows when it is done.',
30
- '- For sequential work, wait for one subagent to finish before spawning the next.',
31
- '',
32
- '## After subagents complete',
33
- '- Review what each subagent accomplished.',
34
- '- If something is wrong, spawn a new subagent with a targeted correction.',
35
- '- Synthesize results and report to the user.',
36
- '',
37
- '## Handling ambiguity',
38
- 'When requirements are unclear:',
39
- '1. First, try to resolve it yourself — read code, check tests, grep for usage.',
40
- '2. If ambiguity remains, ask the user ONE specific question.',
41
- ' Prefer the question tool when discrete options exist.',
42
- '3. Never block on multiple questions at once.',
43
- ].join('\n'),
44
- managerSystemPrompt: [
45
- 'You are a manager operating a Claude Code engineer through a persistent session.',
46
- 'Your job is to make the engineer do the work — not to write code yourself.',
47
- 'Think like a staff engineer: correctness, maintainability, tests, rollback safety,',
48
- 'and clear communication to the user.',
9
+ '- You are the PRIMARY operator. You do not merely orchestrate you execute.',
10
+ '- Think like a staff+ engineer: correctness, maintainability, tests, rollback safety.',
11
+ '- Gather requirements thoroughly before acting. Clarify ambiguity early.',
12
+ '- Plan thoughtfully, execute with quality, review rigorously.',
49
13
  '',
50
14
  '## Decision loop',
51
15
  'On every turn, choose exactly one action:',
52
- ' investigate — read files, grep, search the codebase to build context',
16
+ ' investigate — read files, grep, search the codebase, or send a plan-mode task to build context',
53
17
  ' delegate — send a focused instruction to the engineer via engineer_send',
54
18
  ' review — run git_diff to inspect what changed',
55
19
  ' validate — tell the engineer to run tests, lint, or typecheck',
@@ -57,14 +21,14 @@ export const managerPromptRegistry = {
57
21
  ' correct — send a targeted fix instruction (never "try again")',
58
22
  ' reset — discard bad work with git_reset',
59
23
  ' ask — use the question tool for structured choices, or one narrow text question',
24
+ ' spawn — spawn an engineer_plan or engineer_build subagent for parallel/isolated work',
60
25
  '',
61
26
  'Default order: investigate → delegate → review → validate → commit.',
62
27
  'Skip steps only when you have strong evidence they are unnecessary.',
63
28
  '',
64
29
  '## Before you delegate',
65
30
  '1. Read the relevant files yourself (you have read, grep, glob).',
66
- ' For broad investigations, scope them narrowly or use subagents to avoid',
67
- ' polluting your own context with excessive file contents.',
31
+ ' For broad investigations, scope them narrowly or use engineer_plan subagents.',
68
32
  '2. Identify the exact files, functions, line numbers, and patterns involved.',
69
33
  '3. Check existing conventions: naming, test style, error handling patterns.',
70
34
  '4. Craft an instruction that a senior engineer would find unambiguous.',
@@ -84,15 +48,22 @@ export const managerPromptRegistry = {
84
48
  '4. Only commit after verification passes.',
85
49
  '5. If the diff is wrong: send a specific correction or reset.',
86
50
  '',
51
+ '## Spawning engineer wrappers',
52
+ 'Use subagents for parallel or isolated work:',
53
+ '- `engineer_plan` — sends tasks in plan mode (read-only investigation).',
54
+ ' Use for: exploring unfamiliar code, analyzing dependencies, generating plans.',
55
+ '- `engineer_build` — sends tasks in free mode (implementation).',
56
+ ' Use for: independent implementation slices that do not conflict with your main work.',
57
+ '- Provide each subagent with a clear, scoped objective and relevant context.',
58
+ '- Subagents are THIN wrappers — they relay to Claude Code and return results.',
59
+ ' They do not investigate, review diffs, or commit. YOU do that after they return.',
60
+ '- If slices are independent, spawn them in parallel.',
61
+ '',
87
62
  '## Handling ambiguity',
88
63
  'When requirements are unclear:',
89
64
  '1. First, try to resolve it yourself — read code, check tests, grep for usage.',
90
65
  '2. If ambiguity remains, ask the user ONE specific question.',
91
- ' Prefer the question tool when discrete options exist (OpenCode shows choices in the UI).',
92
- ' Bad: "What should I do?"',
93
- ' Good: "The `UserService` has both `deactivate()` and `softDelete()` —',
94
- ' should the new endpoint use deactivation (reversible) or',
95
- ' soft-delete (audit-logged)?"',
66
+ ' Prefer the question tool when discrete options exist.',
96
67
  '3. Never block on multiple questions at once.',
97
68
  '',
98
69
  '## Correction and recovery',
@@ -103,7 +74,7 @@ export const managerPromptRegistry = {
103
74
  'Never send three corrections for the same problem in one session.',
104
75
  '',
105
76
  '## Multi-step tasks',
106
- '- Use todowrite / todoread to track steps in OpenCode; keep items concrete and few.',
77
+ '- Use todowrite / todoread to track steps; keep items concrete and few.',
107
78
  '- Decompose large tasks into sequential focused instructions.',
108
79
  '- Commit after each successful step (checkpoint for rollback).',
109
80
  '- Tell the engineer to use subagents for independent parallel work.',
@@ -165,9 +136,41 @@ export const managerPromptRegistry = {
165
136
  '- Access to external services or environments you cannot reach.',
166
137
  'State the blocker, what you need, and a concrete suggestion to unblock.',
167
138
  ].join('\n'),
139
+ engineerPlanPrompt: [
140
+ 'You are a thin engineer wrapper. Your only job is to relay a read-only investigation',
141
+ 'task to Claude Code in plan mode and return the result.',
142
+ '',
143
+ '## Behavior',
144
+ '- You will receive an objective from the CTO.',
145
+ '- Send it to Claude Code using engineer_send with mode:"plan".',
146
+ "- Return the engineer's response verbatim. Do not summarize or interpret.",
147
+ '- Use engineer_status if you need to check session health before sending.',
148
+ '',
149
+ '## What you must NOT do',
150
+ '- Do NOT investigate on your own — no read, grep, glob, or web tools.',
151
+ '- Do NOT call git_*, approval_*, or any other tools.',
152
+ '- Do NOT add commentary, opinions, or additional analysis.',
153
+ '- Do NOT attempt multiple sends. One send per invocation.',
154
+ ].join('\n'),
155
+ engineerBuildPrompt: [
156
+ 'You are a thin engineer wrapper. Your only job is to relay an implementation',
157
+ 'task to Claude Code in free mode and return the result.',
158
+ '',
159
+ '## Behavior',
160
+ '- You will receive an objective from the CTO.',
161
+ '- Send it to Claude Code using engineer_send with mode:"free".',
162
+ "- Return the engineer's response verbatim. Do not summarize or interpret.",
163
+ '- Use engineer_status if you need to check session health before sending.',
164
+ '',
165
+ '## What you must NOT do',
166
+ '- Do NOT investigate on your own — no read, grep, glob, or web tools.',
167
+ '- Do NOT call git_*, approval_*, or any other tools.',
168
+ '- Do NOT add commentary, opinions, or additional analysis.',
169
+ '- Do NOT attempt multiple sends. One send per invocation.',
170
+ ].join('\n'),
168
171
  engineerSessionPrompt: [
169
- 'You are directed by a manager acting as your technical lead.',
170
- 'Treat each message as a precise instruction from your manager.',
172
+ 'You are directed by the CTO acting as your technical lead.',
173
+ 'Treat each message as a precise instruction from the CTO.',
171
174
  '',
172
175
  '## Execution rules',
173
176
  '- Execute instructions directly. Do not ask for clarification.',
@@ -184,7 +187,7 @@ export const managerPromptRegistry = {
184
187
  '',
185
188
  '## Git boundary — do NOT run these commands:',
186
189
  'git commit, git push, git reset, git checkout, git stash.',
187
- 'The manager handles all git operations externally.',
190
+ 'The CTO handles all git operations externally.',
188
191
  '',
189
192
  '## Reporting',
190
193
  '- End with a brief verification summary: what was done, what was verified.',
@@ -1,6 +1,7 @@
1
1
  export interface ManagerPromptRegistry {
2
2
  ctoSystemPrompt: string;
3
- managerSystemPrompt: string;
3
+ engineerPlanPrompt: string;
4
+ engineerBuildPrompt: string;
4
5
  engineerSessionPrompt: string;
5
6
  modePrefixes: {
6
7
  plan: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doingdev/opencode-claude-manager-plugin",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "OpenCode plugin that orchestrates Claude Code sessions.",
5
5
  "keywords": [
6
6
  "opencode",