@doingdev/opencode-claude-manager-plugin 0.1.19 → 0.1.21

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.
Files changed (54) hide show
  1. package/README.md +40 -89
  2. package/dist/index.d.ts +5 -4
  3. package/dist/index.js +5 -4
  4. package/dist/plugin/orchestrator.plugin.d.ts +14 -0
  5. package/dist/plugin/orchestrator.plugin.js +108 -0
  6. package/dist/prompts/registry.d.ts +8 -2
  7. package/dist/prompts/registry.js +30 -133
  8. package/dist/safety/bash-safety.d.ts +21 -0
  9. package/dist/safety/bash-safety.js +62 -0
  10. package/package.json +3 -6
  11. package/dist/claude/claude-agent-sdk-adapter.d.ts +0 -27
  12. package/dist/claude/claude-agent-sdk-adapter.js +0 -520
  13. package/dist/claude/claude-session.service.d.ts +0 -15
  14. package/dist/claude/claude-session.service.js +0 -23
  15. package/dist/claude/delegated-can-use-tool.d.ts +0 -7
  16. package/dist/claude/delegated-can-use-tool.js +0 -178
  17. package/dist/claude/session-live-tailer.d.ts +0 -51
  18. package/dist/claude/session-live-tailer.js +0 -269
  19. package/dist/claude/tool-approval-manager.d.ts +0 -27
  20. package/dist/claude/tool-approval-manager.js +0 -238
  21. package/dist/manager/context-tracker.d.ts +0 -33
  22. package/dist/manager/context-tracker.js +0 -108
  23. package/dist/manager/git-operations.d.ts +0 -12
  24. package/dist/manager/git-operations.js +0 -76
  25. package/dist/manager/manager-orchestrator.d.ts +0 -17
  26. package/dist/manager/manager-orchestrator.js +0 -178
  27. package/dist/manager/persistent-manager.d.ts +0 -73
  28. package/dist/manager/persistent-manager.js +0 -167
  29. package/dist/manager/session-controller.d.ts +0 -45
  30. package/dist/manager/session-controller.js +0 -147
  31. package/dist/manager/task-planner.d.ts +0 -5
  32. package/dist/manager/task-planner.js +0 -15
  33. package/dist/metadata/claude-metadata.service.d.ts +0 -12
  34. package/dist/metadata/claude-metadata.service.js +0 -38
  35. package/dist/metadata/repo-claude-config-reader.d.ts +0 -7
  36. package/dist/metadata/repo-claude-config-reader.js +0 -154
  37. package/dist/plugin/claude-code-permission-bridge.d.ts +0 -15
  38. package/dist/plugin/claude-code-permission-bridge.js +0 -184
  39. package/dist/plugin/claude-manager.plugin.d.ts +0 -2
  40. package/dist/plugin/claude-manager.plugin.js +0 -578
  41. package/dist/plugin/service-factory.d.ts +0 -12
  42. package/dist/plugin/service-factory.js +0 -41
  43. package/dist/state/file-run-state-store.d.ts +0 -14
  44. package/dist/state/file-run-state-store.js +0 -87
  45. package/dist/state/transcript-store.d.ts +0 -15
  46. package/dist/state/transcript-store.js +0 -44
  47. package/dist/types/contracts.d.ts +0 -215
  48. package/dist/types/contracts.js +0 -1
  49. package/dist/util/fs-helpers.d.ts +0 -2
  50. package/dist/util/fs-helpers.js +0 -12
  51. package/dist/util/transcript-append.d.ts +0 -7
  52. package/dist/util/transcript-append.js +0 -29
  53. package/dist/worktree/worktree-coordinator.d.ts +0 -21
  54. package/dist/worktree/worktree-coordinator.js +0 -64
package/README.md CHANGED
@@ -1,34 +1,43 @@
1
- # OpenCode Claude Manager Plugin
1
+ # OpenCode Claude Code Subagents Plugin
2
2
 
3
- This package provides an OpenCode plugin that lets an OpenCode-side manager agent orchestrate Claude Code sessions through a stable local bridge.
3
+ Thin OpenCode orchestrator plugin with Claude Code specialist subagents.
4
4
 
5
5
  ## Overview
6
6
 
7
- Use this when you want OpenCode to act as a manager over Claude Code instead of talking to Claude directly. The plugin gives OpenCode a stable tool surface for discovering Claude metadata, delegating work to Claude sessions, and splitting tasks into subagents (all using the same working directory).
7
+ This plugin turns OpenCode into a lightweight orchestrator that delegates coding work to Claude Code specialists. Instead of a monolithic manager with custom tools, it registers:
8
8
 
9
- ## Features
9
+ - **1 orchestrator agent** (`opencode-orchestrator`) — runs on the user's default OpenCode model, gathers context, and delegates to specialists.
10
+ - **4 Claude Code subagents** — planning and build specialists, each available in Opus and Sonnet variants.
11
+ - **1 provider** (`claude-code`) — backed by [`ai-sdk-provider-claude-code`](https://ai-sdk.dev/providers/community-providers/claude-code).
10
12
 
11
- - Runs Claude Code tasks from OpenCode through `@anthropic-ai/claude-agent-sdk`.
12
- - Discovers repo-local Claude metadata from `.claude/skills`, `.claude/commands`, `CLAUDE.md`, and settings hooks.
13
- - Splits multi-step tasks into subagents that run sequentially in the same repository directory.
14
- - Persists manager runs under `.claude-manager/runs` so sessions can be inspected later.
15
- - Exposes manager-facing tools instead of relying on undocumented plugin-defined slash commands.
13
+ No custom tools are exposed. The orchestrator uses only OpenCode's built-in tools (read, grep, glob, list, webfetch, question, todowrite, todoread, task) and delegates actual coding to Claude Code subagents.
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ User → OpenCode Orchestrator (user's model)
19
+ ├── claude-code-planning-opus (claude-code/opus)
20
+ ├── claude-code-planning-sonnet (claude-code/sonnet)
21
+ ├── claude-code-build-opus (claude-code/opus)
22
+ └── claude-code-build-sonnet (claude-code/sonnet)
23
+ ```
24
+
25
+ **Planning agents** are positioned for investigation, architecture, and plans.
26
+ **Build agents** are positioned for implementation, testing, and validation.
16
27
 
17
28
  ## Requirements
18
29
 
19
30
  - Node `22+`
20
31
  - OpenCode with plugin loading enabled
21
- - Access to Claude Code / Claude Agent SDK on the machine where OpenCode is running
32
+ - Claude Code available on the machine (the `ai-sdk-provider-claude-code` provider connects to it)
22
33
 
23
34
  ## Installation
24
35
 
25
- Install from the npm registry:
26
-
27
36
  ```bash
28
37
  pnpm add @doingdev/opencode-claude-manager-plugin
29
38
  ```
30
39
 
31
- Or for local development in this repo:
40
+ Or for local development:
32
41
 
33
42
  ```bash
34
43
  pnpm install
@@ -37,51 +46,38 @@ pnpm run build
37
46
 
38
47
  ## OpenCode Config
39
48
 
40
- Add the plugin to your OpenCode config:
41
-
42
49
  ```json
43
50
  {
44
51
  "plugin": ["@doingdev/opencode-claude-manager-plugin"]
45
52
  }
46
53
  ```
47
54
 
48
- If you are testing locally, point OpenCode at the local package or plugin file using your normal local plugin workflow.
49
-
50
- ## OpenCode tools
51
-
52
- - `claude_manager_run` - run a task through Claude with optional splitting into subagents; returns a compact output summary and a `runId` for deeper inspection
53
- - `claude_manager_metadata` - inspect available Claude commands, skills, hooks, and settings
54
- - `claude_manager_sessions` - list Claude sessions or inspect a saved transcript
55
- - `claude_manager_runs` - inspect persisted manager run records
55
+ ## Agents
56
56
 
57
- ## Plugin-provided agents and commands
57
+ | Agent | Model | Mode | Role |
58
+ | ----------------------------- | -------------------- | -------- | --------------------------------------------------------- |
59
+ | `opencode-orchestrator` | user's default | primary | CTO-level orchestrator; gathers context, delegates coding |
60
+ | `claude-code-planning-opus` | `claude-code/opus` | subagent | Investigation, architecture, planning |
61
+ | `claude-code-planning-sonnet` | `claude-code/sonnet` | subagent | Lighter investigation and planning |
62
+ | `claude-code-build-opus` | `claude-code/opus` | subagent | Implementation and validation |
63
+ | `claude-code-build-sonnet` | `claude-code/sonnet` | subagent | Lighter implementation tasks |
58
64
 
59
- When the plugin loads successfully, it also injects config entries through the OpenCode plugin `config` hook.
65
+ ## Bash Safety
60
66
 
61
- - Primary agent: `claude-manager`
62
- - Subagent: `claude-manager-research`
63
- - Commands: `/claude-metadata`, `/claude-run`, `/claude-sessions`
67
+ A minimal safety layer enforces deny rules via the `permission.ask` hook:
64
68
 
65
- These are added to OpenCode config at runtime by the plugin, so they do not require separate manual `opencode.json` entries.
69
+ - `rm -rf /` denied
70
+ - `git push --force` — denied
71
+ - `git reset --hard` — denied
72
+ - All other bash commands — allowed (including `pnpm test`, `pnpm lint`, `pnpm build`, etc.)
66
73
 
67
- ## Quick Start
68
-
69
- Typical flow inside OpenCode:
70
-
71
- 1. Inspect Claude capabilities with `claude_manager_metadata`.
72
- 2. Delegate work with `claude_manager_run`.
73
- 3. Inspect saved Claude history with `claude_manager_sessions` or prior orchestration records with `claude_manager_runs`.
74
-
75
- Example task:
74
+ ## Limitations
76
75
 
77
- ```text
78
- Use claude_manager_run to split this implementation into subagents and summarize the final result.
79
- ```
76
+ - Claude Code `effort` is not currently configurable through OpenCode provider/model options. The subagent prompts compensate by setting high-quality expectations directly.
77
+ - The `ai-sdk-provider-claude-code` community provider must be available for the Claude Code subagents to function.
80
78
 
81
79
  ## Local Development
82
80
 
83
- Clone the repo and run:
84
-
85
81
  ```bash
86
82
  pnpm install
87
83
  pnpm run lint
@@ -90,54 +86,9 @@ pnpm run test
90
86
  pnpm run build
91
87
  ```
92
88
 
93
- The compiled plugin output is written to `dist/`.
94
-
95
89
  ## Publishing
96
90
 
97
- This package is configured for the npm scope `@doingdev`.
98
-
99
- This repository uses npm trusted publishing with GitHub Actions OIDC, so you do not need an `NPM_TOKEN` secret once npm is configured correctly.
100
-
101
- Before the first automated publish, configure npm trusted publishing for `@doingdev/opencode-claude-manager-plugin` on npmjs.com:
102
-
103
- 1. Open the package settings on npmjs.com.
104
- 2. Go to the `Trusted Publisher` section.
105
- 3. Choose `GitHub Actions`.
106
- 4. Set the GitHub owner/user to your account or org.
107
- 5. Set the repository name.
108
- 6. Set the workflow filename to `publish.yml`.
109
- 7. Leave the environment name empty unless you later add a GitHub Actions environment back to the workflow.
110
-
111
- Notes for trusted publishing:
112
-
113
- - npm trusted publishing requires GitHub-hosted runners.
114
- - npm recommends Node `22.14.0+` with npm CLI `11.5.1+`; the workflows use Node `24`.
115
- - Provenance is generated automatically by npm for trusted publishes from public GitHub repositories.
116
-
117
- Release flow:
118
-
119
- ```bash
120
- pnpm login
121
- pnpm whoami
122
- pnpm version patch
123
- pnpm run lint
124
- pnpm run typecheck
125
- pnpm run test
126
- pnpm run build
127
- ```
128
-
129
- Then publish from GitHub by either:
130
-
131
- - creating a GitHub Release, or
132
- - running the `Publish` workflow manually from the Actions tab
133
-
134
- After trusted publishing is working, you can tighten npm package security by disabling token-based publishing for the package in npm settings.
135
-
136
- ## Limitations
137
-
138
- - Claude slash commands and skills come primarily from filesystem discovery; SDK probing is available but optional.
139
- - Multiple subagents share one working directory and run one after another to avoid overlapping edits.
140
- - Run state is local to the repo under `.claude-manager/` and is ignored by git.
91
+ This package is configured for the npm scope `@doingdev`. See the GitHub Actions workflow for automated publishing via npm trusted publishing.
141
92
 
142
93
  ## Scripts
143
94
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Plugin } from '@opencode-ai/plugin';
2
- import { ClaudeManagerPlugin } from './plugin/claude-manager.plugin.js';
3
- export type { ClaudeCapabilitySnapshot, ClaudeMetadataSnapshot, ClaudeSessionRunResult, ClaudeSessionSummary, ClaudeSessionTranscriptMessage, ManagerPromptRegistry, RunClaudeSessionInput, SessionContextSnapshot, GitDiffResult, GitOperationResult, PersistentRunRecord, PersistentRunResult, ActiveSessionState, ContextWarningLevel, SessionMode, LiveTailEvent, ToolOutputPreview, ToolApprovalRule, ToolApprovalPolicy, ToolApprovalDecision, } from './types/contracts.js';
4
- export { SessionLiveTailer } from './claude/session-live-tailer.js';
5
- export { ClaudeManagerPlugin };
2
+ import { OrchestratorPlugin } from './plugin/orchestrator.plugin.js';
3
+ export { OrchestratorPlugin };
4
+ export { evaluateBashCommand, extractBashCommand, } from './safety/bash-safety.js';
5
+ export type { BashSafetyResult } from './safety/bash-safety.js';
6
+ export { prompts } from './prompts/registry.js';
6
7
  export declare const plugin: Plugin;
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { ClaudeManagerPlugin } from './plugin/claude-manager.plugin.js';
2
- export { SessionLiveTailer } from './claude/session-live-tailer.js';
3
- export { ClaudeManagerPlugin };
4
- export const plugin = ClaudeManagerPlugin;
1
+ import { OrchestratorPlugin } from './plugin/orchestrator.plugin.js';
2
+ export { OrchestratorPlugin };
3
+ export { evaluateBashCommand, extractBashCommand, } from './safety/bash-safety.js';
4
+ export { prompts } from './prompts/registry.js';
5
+ export const plugin = OrchestratorPlugin;
@@ -0,0 +1,14 @@
1
+ import type { Plugin } from '@opencode-ai/plugin';
2
+ /**
3
+ * Thin OpenCode orchestrator plugin with Claude Code specialist subagents.
4
+ *
5
+ * - Registers `claude-code` provider via ai-sdk-provider-claude-code.
6
+ * - Creates one orchestrator agent (uses the user's default OpenCode model).
7
+ * - Creates 4 Claude Code subagents: planning + build × opus + sonnet.
8
+ * - Enforces bash safety via the permission.ask hook.
9
+ *
10
+ * NOTE: Claude Code `effort` is not configurable through OpenCode provider/model
11
+ * options at this time. The subagent prompts compensate by setting high-quality
12
+ * expectations directly.
13
+ */
14
+ export declare const OrchestratorPlugin: Plugin;
@@ -0,0 +1,108 @@
1
+ import { prompts } from '../prompts/registry.js';
2
+ import { evaluateBashCommand, extractBashCommand, } from '../safety/bash-safety.js';
3
+ /**
4
+ * Thin OpenCode orchestrator plugin with Claude Code specialist subagents.
5
+ *
6
+ * - Registers `claude-code` provider via ai-sdk-provider-claude-code.
7
+ * - Creates one orchestrator agent (uses the user's default OpenCode model).
8
+ * - Creates 4 Claude Code subagents: planning + build × opus + sonnet.
9
+ * - Enforces bash safety via the permission.ask hook.
10
+ *
11
+ * NOTE: Claude Code `effort` is not configurable through OpenCode provider/model
12
+ * options at this time. The subagent prompts compensate by setting high-quality
13
+ * expectations directly.
14
+ */
15
+ export const OrchestratorPlugin = async () => {
16
+ return {
17
+ config: async (config) => {
18
+ config.provider ??= {};
19
+ config.agent ??= {};
20
+ // ── Provider ──────────────────────────────────────────────────────
21
+ config.provider['claude-code'] ??= {
22
+ npm: 'ai-sdk-provider-claude-code',
23
+ models: {
24
+ opus: {
25
+ id: 'opus',
26
+ name: 'Claude Code Opus 4.6',
27
+ },
28
+ sonnet: {
29
+ id: 'sonnet',
30
+ name: 'Claude Code Sonnet 4.6',
31
+ },
32
+ },
33
+ };
34
+ // ── Orchestrator (uses user's default model — no model set) ───────
35
+ config.agent['opencode-orchestrator'] ??= {
36
+ description: 'CTO-level orchestrator that gathers context and delegates coding to Claude Code specialists.',
37
+ mode: 'primary',
38
+ color: '#D97757',
39
+ prompt: prompts.orchestrator,
40
+ permission: {
41
+ '*': 'deny',
42
+ read: 'allow',
43
+ grep: 'allow',
44
+ glob: 'allow',
45
+ list: 'allow',
46
+ webfetch: 'allow',
47
+ question: 'allow',
48
+ todowrite: 'allow',
49
+ todoread: 'allow',
50
+ task: 'allow',
51
+ bash: 'deny',
52
+ edit: 'deny',
53
+ skill: 'deny',
54
+ },
55
+ };
56
+ // ── Planning subagents ────────────────────────────────────────────
57
+ const claudeCodePermissions = {
58
+ '*': 'allow',
59
+ bash: 'allow',
60
+ };
61
+ config.agent['claude-code-planning-opus'] ??= {
62
+ description: 'Claude Code Opus specialist for investigation, architecture, and planning.',
63
+ model: 'claude-code/opus',
64
+ mode: 'subagent',
65
+ color: 'info',
66
+ prompt: prompts.planningAgent,
67
+ permission: { ...claudeCodePermissions },
68
+ };
69
+ config.agent['claude-code-planning-sonnet'] ??= {
70
+ description: 'Claude Code Sonnet specialist for lighter investigation and planning.',
71
+ model: 'claude-code/sonnet',
72
+ mode: 'subagent',
73
+ color: 'info',
74
+ prompt: prompts.planningAgent,
75
+ permission: { ...claudeCodePermissions },
76
+ };
77
+ // ── Build subagents ───────────────────────────────────────────────
78
+ config.agent['claude-code-build-opus'] ??= {
79
+ description: 'Claude Code Opus specialist for implementation and validation.',
80
+ model: 'claude-code/opus',
81
+ mode: 'subagent',
82
+ color: 'success',
83
+ prompt: prompts.buildAgent,
84
+ permission: { ...claudeCodePermissions },
85
+ };
86
+ config.agent['claude-code-build-sonnet'] ??= {
87
+ description: 'Claude Code Sonnet specialist for lighter implementation tasks.',
88
+ model: 'claude-code/sonnet',
89
+ mode: 'subagent',
90
+ color: 'success',
91
+ prompt: prompts.buildAgent,
92
+ permission: { ...claudeCodePermissions },
93
+ };
94
+ },
95
+ // ── Bash safety via permission.ask hook ────────────────────────────
96
+ // Handles both v1 Permission ({ type, pattern }) and v2 PermissionRequest
97
+ // ({ permission, patterns }) via runtime narrowing in extractBashCommand.
98
+ 'permission.ask': async (input, output) => {
99
+ const command = extractBashCommand(input);
100
+ if (command === null)
101
+ return;
102
+ const result = evaluateBashCommand(command);
103
+ if (!result.allowed) {
104
+ output.status = 'deny';
105
+ }
106
+ },
107
+ };
108
+ };
@@ -1,2 +1,8 @@
1
- import type { ManagerPromptRegistry } from '../types/contracts.js';
2
- export declare const managerPromptRegistry: ManagerPromptRegistry;
1
+ /**
2
+ * Agent prompt registry for the orchestrator + Claude Code subagent architecture.
3
+ */
4
+ export declare const prompts: {
5
+ orchestrator: string;
6
+ planningAgent: string;
7
+ buildAgent: string;
8
+ };
@@ -1,140 +1,37 @@
1
- export const managerPromptRegistry = {
2
- managerSystemPrompt: [
3
- 'You are a senior IC operating Claude Code through a persistent session.',
4
- 'Your job is to make Claude Code do the work — not to write code yourself.',
5
- 'Think like a staff engineer: correctness, maintainability, tests, rollback safety,',
6
- 'and clear communication to the user.',
7
- '',
8
- '## Decision loop',
9
- 'On every turn, choose exactly one action:',
10
- ' investigate read files, grep, search the codebase to build context',
11
- ' delegate — send a focused instruction to Claude Code via claude_manager_send',
12
- ' review — run claude_manager_git_diff to inspect what changed',
13
- ' validate — tell Claude Code to run tests, lint, or typecheck',
14
- ' commit — checkpoint good work with claude_manager_git_commit',
15
- ' correct — send a targeted fix instruction (never "try again")',
16
- ' reset — discard bad work with claude_manager_git_reset',
17
- ' ask — use the question tool for structured choices, or one narrow text question',
18
- '',
19
- 'Default order: investigate → delegate → review → validate → commit.',
20
- 'Skip steps only when you have strong evidence they are unnecessary.',
21
- '',
22
- '## Before you delegate',
23
- '1. Read the relevant files yourself (you have read, grep, glob).',
24
- ' For broad investigations, scope them narrowly or use subagents to avoid',
25
- ' polluting your own context with excessive file contents.',
26
- '2. Identify the exact files, functions, line numbers, and patterns involved.',
27
- '3. Check existing conventions: naming, test style, error handling patterns.',
28
- '4. Craft an instruction that a senior engineer would find unambiguous.',
29
- ' Bad: "Fix the auth bug"',
30
- ' Good: "In src/auth/session.ts, the `validateToken` function (line 42)',
31
- ' throws on expired tokens instead of returning null. Change it to',
32
- ' return null and update the caller in src/routes/login.ts:87."',
33
- '',
34
- '## After delegation — mandatory review',
35
- 'Never claim success without evidence:',
36
- '1. claude_manager_git_diff — read the actual diff, not just the summary.',
37
- '2. Verify the diff matches what you asked for. Check for:',
38
- ' - Unintended changes or regressions',
39
- ' - Missing test updates',
40
- ' - Style violations against repo conventions',
41
- '3. If changes look correct, tell Claude Code to run tests/lint/typecheck.',
42
- '4. Only commit after verification passes.',
43
- '5. If the diff is wrong: send a specific correction or reset.',
44
- '',
45
- '## Handling ambiguity',
46
- 'When requirements are unclear:',
47
- '1. First, try to resolve it yourself — read code, check tests, grep for usage.',
48
- '2. If ambiguity remains, ask the user ONE specific question.',
49
- ' Prefer the question tool when discrete options exist (OpenCode shows choices in the UI).',
50
- ' Bad: "What should I do?"',
51
- ' Good: "The `UserService` has both `deactivate()` and `softDelete()` —',
52
- ' should the new endpoint use deactivation (reversible) or',
53
- ' soft-delete (audit-logged)?"',
54
- '3. Never block on multiple questions at once.',
55
- '',
56
- '## Correction and recovery',
57
- 'If Claude Code produces wrong output:',
58
- '1. First correction: send a specific, targeted fix instruction.',
59
- '2. Second correction on the same issue: reset, clear the session,',
60
- ' and rewrite the prompt incorporating lessons from both failures.',
61
- 'Never send three corrections for the same problem in one session.',
62
- '',
63
- '## Multi-step tasks',
64
- '- Use todowrite / todoread to track steps in OpenCode; keep items concrete and few.',
65
- '- Decompose large tasks into sequential focused instructions.',
66
- '- Commit after each successful step (checkpoint for rollback).',
67
- '- Tell Claude Code to use subagents for independent parallel work.',
68
- '- For complex design decisions, tell Claude Code to "think hard".',
69
- '- Prefer small diffs — they are easier to review and safer to ship.',
70
- '',
71
- '## Context management',
72
- 'Check the context snapshot returned by each send:',
73
- '- Under 50%: proceed freely.',
74
- '- 50–70%: finish current step, then evaluate if a fresh session is needed.',
75
- '- Over 70%: compact or clear before sending heavy instructions.',
76
- '- Over 85%: clear the session immediately.',
77
- '',
78
- '## Tools reference',
79
- 'todowrite / todoread — OpenCode session todo list (track multi-step work)',
80
- 'question — OpenCode user prompt with options (clarify trade-offs)',
81
- 'claude_manager_send — send instruction (creates or resumes session)',
82
- 'claude_manager_git_diff — review all uncommitted changes',
83
- 'claude_manager_git_commit — stage all + commit',
84
- 'claude_manager_git_reset — hard reset + clean (destructive)',
85
- 'claude_manager_clear — drop session, next send starts fresh',
86
- 'claude_manager_status — context health snapshot',
87
- 'claude_manager_metadata — inspect repo Claude config',
88
- 'claude_manager_sessions — list sessions or read transcripts',
89
- 'claude_manager_runs — list or inspect run records',
90
- '',
91
- '## Autonomy blockers — surface these to the user',
92
- 'Be candid about what you cannot do autonomously:',
93
- '- Credentials, API keys, or secrets you do not have.',
94
- '- Architectural decisions with trade-offs the user should weigh.',
95
- '- Destructive actions on shared state (deploy, publish, force-push).',
96
- '- Access to external services or environments you cannot reach.',
97
- 'State the blocker, what you need, and a concrete suggestion to unblock.',
1
+ /**
2
+ * Agent prompt registry for the orchestrator + Claude Code subagent architecture.
3
+ */
4
+ export const prompts = {
5
+ orchestrator: [
6
+ 'You are the orchestrator — a CTO-level proxy for the user.',
7
+ 'Your job is to gather minimal context, then delegate coding work to specialist Claude Code agents.',
8
+ '',
9
+ '## Rules',
10
+ '- Do NOT write or edit code yourself unless the user explicitly asks you to.',
11
+ '- Read files, search, and plan to understand the task, then delegate.',
12
+ '- Use planning agents (claude-code-planning-opus/sonnet) for investigation, architecture, and plans.',
13
+ '- Use build agents (claude-code-build-opus/sonnet) for implementation and validation.',
14
+ '- Run specialists in parallel when tasks are independent.',
15
+ '- Compare outputs from multiple specialists when the choice matters.',
16
+ '- Keep delegations focused: one clear objective per specialist call.',
17
+ '- Track multi-step work with todowrite/todoread.',
18
+ '- Ask the user (via question tool) when trade-offs need human judgment.',
98
19
  ].join('\n'),
99
- claudeCodeSessionPrompt: [
100
- 'You are directed by an expert automated operator.',
101
- 'Treat each message as a precise instruction from a senior engineer.',
20
+ planningAgent: [
21
+ 'You are a planning specialist. Investigate, analyze architecture, and produce implementation plans.',
102
22
  '',
103
- '## Execution rules',
104
- '- Execute instructions directly. Do not ask for clarification.',
105
- '- Be concise no preamble, no restating the task.',
106
- '- Prefer targeted file reads over reading entire files.',
107
- '- Use the Agent tool for independent parallel work.',
23
+ '- Read code, grep, search — build full context before answering.',
24
+ '- Produce concrete plans: files to change, functions to modify, test strategy, risks.',
25
+ '- Do NOT edit files or run destructive commands unless explicitly asked.',
26
+ '- Be concise. End with a numbered action plan.',
27
+ ].join('\n'),
28
+ buildAgent: [
29
+ 'You are a build specialist. Implement, test, and validate changes.',
108
30
  '',
109
- '## Quality expectations',
110
- '- Follow existing repo conventions (naming, style, patterns).',
111
- '- When creating or modifying code, consider edge cases and error handling.',
112
- '- When modifying existing code, preserve surrounding style and structure.',
113
- '- If asked to implement a feature, include relevant tests unless told otherwise.',
31
+ '- Execute instructions precisely. Follow existing repo conventions.',
32
+ '- Consider edge cases and include relevant tests.',
114
33
  '- Run tests/lint/typecheck when instructed; report exact output on failure.',
115
- '',
116
- '## Git boundary — do NOT run these commands:',
117
- 'git commit, git push, git reset, git checkout, git stash.',
118
- 'The operator manages all git operations externally.',
119
- '',
120
- '## Reporting',
34
+ '- Do NOT run git commit, git push, git reset, git checkout, or git stash.',
121
35
  '- End with a brief verification summary: what was done, what was verified.',
122
- '- Report blockers immediately with specifics: file, line, error message.',
123
- '- If a task is partially complete, state exactly what remains.',
124
36
  ].join('\n'),
125
- modePrefixes: {
126
- plan: [
127
- '[PLAN MODE] You are in read-only planning mode. Do NOT create or edit any files.',
128
- 'Use read, grep, glob, and search tools only.',
129
- 'Analyze the codebase and produce a detailed implementation plan:',
130
- 'files to change, functions to modify, new files to create, test strategy,',
131
- 'and potential risks. End with a numbered step-by-step plan.',
132
- ].join(' '),
133
- free: '',
134
- },
135
- contextWarnings: {
136
- moderate: 'Session context is filling up ({percent}% estimated). Consider whether a fresh session would be more efficient.',
137
- high: 'Session context is heavy ({percent}% estimated, {turns} turns, ${cost}). Start a new session or compact first.',
138
- critical: 'Session context is near capacity ({percent}% estimated). Clear the session immediately before continuing.',
139
- },
140
37
  };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Minimal bash command safety layer.
3
+ * Denies known-dangerous patterns; allows everything else.
4
+ */
5
+ export type BashSafetyResult = {
6
+ allowed: true;
7
+ } | {
8
+ allowed: false;
9
+ reason: string;
10
+ };
11
+ export declare function evaluateBashCommand(command: string): BashSafetyResult;
12
+ /**
13
+ * Extract the bash command string from a permission hook input,
14
+ * handling both SDK payload shapes:
15
+ *
16
+ * v1 Permission: { type: string, pattern?: string | string[], metadata }
17
+ * v2 PermissionRequest: { permission: string, patterns: string[], metadata }
18
+ *
19
+ * Returns `null` when the input is not a bash permission request.
20
+ */
21
+ export declare function extractBashCommand(input: Record<string, unknown>): string | null;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Minimal bash command safety layer.
3
+ * Denies known-dangerous patterns; allows everything else.
4
+ */
5
+ const DENY_PATTERNS = [
6
+ { pattern: 'rm -rf /', reason: 'Destructive: rm -rf / is not allowed.' },
7
+ {
8
+ pattern: 'git push --force',
9
+ reason: 'Force push is not allowed.',
10
+ },
11
+ {
12
+ pattern: 'git reset --hard',
13
+ reason: 'git reset --hard is not allowed. Use a safer alternative.',
14
+ },
15
+ ];
16
+ export function evaluateBashCommand(command) {
17
+ for (const { pattern, reason } of DENY_PATTERNS) {
18
+ if (command.includes(pattern)) {
19
+ return { allowed: false, reason };
20
+ }
21
+ }
22
+ return { allowed: true };
23
+ }
24
+ /**
25
+ * Extract the bash command string from a permission hook input,
26
+ * handling both SDK payload shapes:
27
+ *
28
+ * v1 Permission: { type: string, pattern?: string | string[], metadata }
29
+ * v2 PermissionRequest: { permission: string, patterns: string[], metadata }
30
+ *
31
+ * Returns `null` when the input is not a bash permission request.
32
+ */
33
+ export function extractBashCommand(input) {
34
+ // Determine the permission kind from whichever field is present.
35
+ const kind = typeof input['permission'] === 'string'
36
+ ? input['permission']
37
+ : typeof input['type'] === 'string'
38
+ ? input['type']
39
+ : null;
40
+ if (kind !== 'bash')
41
+ return null;
42
+ // Prefer an explicit command in metadata regardless of shape.
43
+ const meta = input['metadata'];
44
+ if (meta !== null && typeof meta === 'object' && !Array.isArray(meta)) {
45
+ const cmd = meta['command'];
46
+ if (typeof cmd === 'string' && cmd.length > 0)
47
+ return cmd;
48
+ }
49
+ // v2: patterns is always string[]
50
+ const patterns = input['patterns'];
51
+ if (Array.isArray(patterns) && patterns.length > 0) {
52
+ return patterns.join(' ');
53
+ }
54
+ // v1: pattern may be string or string[]
55
+ const pattern = input['pattern'];
56
+ if (typeof pattern === 'string' && pattern.length > 0)
57
+ return pattern;
58
+ if (Array.isArray(pattern) && pattern.length > 0) {
59
+ return pattern.join(' ');
60
+ }
61
+ return null;
62
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@doingdev/opencode-claude-manager-plugin",
3
- "version": "0.1.19",
4
- "description": "OpenCode plugin that orchestrates Claude Code sessions.",
3
+ "version": "0.1.21",
4
+ "description": "Thin OpenCode orchestrator plugin with Claude Code specialist subagents.",
5
5
  "keywords": [
6
6
  "opencode",
7
7
  "plugin",
@@ -29,10 +29,7 @@
29
29
  "node": ">=22.0.0"
30
30
  },
31
31
  "dependencies": {
32
- "@anthropic-ai/claude-agent-sdk": "^0.2.81",
33
- "@opencode-ai/plugin": "^1.2.27",
34
- "json5": "^2.2.3",
35
- "zod": "^4.1.8"
32
+ "@opencode-ai/plugin": "^1.2.27"
36
33
  },
37
34
  "devDependencies": {
38
35
  "@eslint/js": "^9.22.0",