@doingdev/opencode-claude-manager-plugin 0.1.22 → 0.1.26
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/README.md +129 -40
- package/dist/claude/claude-agent-sdk-adapter.d.ts +27 -0
- package/dist/claude/claude-agent-sdk-adapter.js +520 -0
- package/dist/claude/claude-session.service.d.ts +15 -0
- package/dist/claude/claude-session.service.js +23 -0
- package/dist/claude/session-live-tailer.d.ts +51 -0
- package/dist/claude/session-live-tailer.js +269 -0
- package/dist/claude/tool-approval-manager.d.ts +27 -0
- package/dist/claude/tool-approval-manager.js +238 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.js +4 -5
- package/dist/manager/context-tracker.d.ts +33 -0
- package/dist/manager/context-tracker.js +108 -0
- package/dist/manager/git-operations.d.ts +12 -0
- package/dist/manager/git-operations.js +76 -0
- package/dist/manager/persistent-manager.d.ts +74 -0
- package/dist/manager/persistent-manager.js +167 -0
- package/dist/manager/session-controller.d.ts +45 -0
- package/dist/manager/session-controller.js +147 -0
- package/dist/metadata/claude-metadata.service.d.ts +12 -0
- package/dist/metadata/claude-metadata.service.js +38 -0
- package/dist/metadata/repo-claude-config-reader.d.ts +7 -0
- package/dist/metadata/repo-claude-config-reader.js +154 -0
- package/dist/plugin/agent-hierarchy.d.ts +47 -0
- package/dist/plugin/agent-hierarchy.js +110 -0
- package/dist/plugin/claude-manager.plugin.d.ts +2 -0
- package/dist/plugin/claude-manager.plugin.js +490 -0
- package/dist/plugin/orchestrator.plugin.js +4 -2
- package/dist/plugin/service-factory.d.ts +12 -0
- package/dist/plugin/service-factory.js +41 -0
- package/dist/prompts/registry.d.ts +2 -8
- package/dist/prompts/registry.js +203 -29
- package/dist/state/file-run-state-store.d.ts +14 -0
- package/dist/state/file-run-state-store.js +87 -0
- package/dist/state/transcript-store.d.ts +15 -0
- package/dist/state/transcript-store.js +44 -0
- package/dist/types/contracts.d.ts +216 -0
- package/dist/types/contracts.js +1 -0
- package/dist/util/fs-helpers.d.ts +2 -0
- package/dist/util/fs-helpers.js +12 -0
- package/dist/util/transcript-append.d.ts +7 -0
- package/dist/util/transcript-append.js +29 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,43 +1,36 @@
|
|
|
1
|
-
# OpenCode Claude
|
|
1
|
+
# OpenCode Claude Manager Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package provides an OpenCode plugin that lets an OpenCode-side agent hierarchy orchestrate Claude Code sessions through a stable local bridge.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
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 delegating work to Claude Code sessions, managing session lifecycle (compact, clear, fresh start), reviewing changes via git, and inspecting session history.
|
|
8
8
|
|
|
9
|
-
|
|
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).
|
|
9
|
+
## Features
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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.
|
|
11
|
+
- Runs Claude Code tasks from OpenCode through `@anthropic-ai/claude-agent-sdk`.
|
|
12
|
+
- Persistent sessions with `freshSession`, model, and effort controls for safe task isolation.
|
|
13
|
+
- Context lifecycle: compact (preserve state) or clear (start fresh).
|
|
14
|
+
- Discovers repo-local Claude metadata from `.claude/skills`, `.claude/commands`, `CLAUDE.md`, and settings hooks.
|
|
15
|
+
- Git integration: diff, commit, and reset from the manager layer.
|
|
16
|
+
- Tool approval policy for governing which Claude Code tools are allowed.
|
|
17
|
+
- Optionally persists manager run records under `.claude-manager/runs` for post-hoc inspection (populated when tasks are executed through the run-tracking path).
|
|
27
18
|
|
|
28
19
|
## Requirements
|
|
29
20
|
|
|
30
21
|
- Node `22+`
|
|
31
22
|
- OpenCode with plugin loading enabled
|
|
32
|
-
- Claude Code
|
|
23
|
+
- Access to Claude Code / Claude Agent SDK on the machine where OpenCode is running
|
|
33
24
|
|
|
34
25
|
## Installation
|
|
35
26
|
|
|
27
|
+
Install from the npm registry:
|
|
28
|
+
|
|
36
29
|
```bash
|
|
37
30
|
pnpm add @doingdev/opencode-claude-manager-plugin
|
|
38
31
|
```
|
|
39
32
|
|
|
40
|
-
Or for local development:
|
|
33
|
+
Or for local development in this repo:
|
|
41
34
|
|
|
42
35
|
```bash
|
|
43
36
|
pnpm install
|
|
@@ -46,38 +39,89 @@ pnpm run build
|
|
|
46
39
|
|
|
47
40
|
## OpenCode Config
|
|
48
41
|
|
|
42
|
+
Add the plugin to your OpenCode config:
|
|
43
|
+
|
|
49
44
|
```json
|
|
50
45
|
{
|
|
51
46
|
"plugin": ["@doingdev/opencode-claude-manager-plugin"]
|
|
52
47
|
}
|
|
53
48
|
```
|
|
54
49
|
|
|
55
|
-
|
|
50
|
+
If you are testing locally, point OpenCode at the local package or plugin file using your normal local plugin workflow.
|
|
56
51
|
|
|
57
|
-
|
|
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 |
|
|
52
|
+
## OpenCode tools
|
|
64
53
|
|
|
65
|
-
|
|
54
|
+
### Engineer session
|
|
66
55
|
|
|
67
|
-
|
|
56
|
+
- `engineer_send` — send a message to the persistent Claude Code session. Auto-creates on first call, resumes on subsequent calls.
|
|
57
|
+
- `message` (required) — the instruction to send.
|
|
58
|
+
- `mode` — `"plan"` (read-only investigation) or `"free"` (default, normal execution with edits).
|
|
59
|
+
- `freshSession` — set to `true` to clear the active session before sending. Use when switching to an unrelated task or when context is contaminated.
|
|
60
|
+
- `model` — `"claude-opus-4-6"` (default, recommended for most coding work), `"claude-sonnet-4-6"`, or `"claude-sonnet-4-5"` (faster/lighter tasks).
|
|
61
|
+
- `effort` — `"high"` (default), `"medium"` (lighter tasks), `"low"`, or `"max"` (especially hard problems).
|
|
62
|
+
- `engineer_compact` — compress the active session context while preserving session state. Use before clearing when context is high but salvageable.
|
|
63
|
+
- `engineer_clear` — drop the active session entirely; next send starts fresh.
|
|
64
|
+
- `engineer_status` — get current session health: context %, turns, cost, session ID.
|
|
68
65
|
|
|
69
|
-
|
|
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
|
+
### Git operations
|
|
73
67
|
|
|
74
|
-
|
|
68
|
+
- `git_diff` — review all uncommitted changes (staged + unstaged).
|
|
69
|
+
- `git_commit` — stage all changes and commit with a message.
|
|
70
|
+
- `git_reset` — hard reset + clean (destructive).
|
|
71
|
+
|
|
72
|
+
### Inspection
|
|
73
|
+
|
|
74
|
+
- `engineer_metadata` — inspect available Claude commands, skills, hooks, and settings.
|
|
75
|
+
- `engineer_sessions` — list Claude sessions or inspect a saved transcript.
|
|
76
|
+
- `engineer_runs` — list or inspect persisted manager run records (may be empty if tasks were sent directly via `engineer_send` rather than the run-tracking path).
|
|
77
|
+
|
|
78
|
+
### Tool approval
|
|
79
|
+
|
|
80
|
+
- `approval_policy` — view the current tool approval policy.
|
|
81
|
+
- `approval_decisions` — view recent tool approval decisions.
|
|
82
|
+
- `approval_update` — add/remove rules, change default action, or enable/disable approval.
|
|
83
|
+
|
|
84
|
+
## Agent hierarchy
|
|
85
|
+
|
|
86
|
+
The plugin registers a CTO → Manager → Engineer hierarchy through the OpenCode plugin `config` hook:
|
|
87
|
+
|
|
88
|
+
- **`cto`** (primary agent) — sets direction and orchestrates work by spawning `manager` subagents. Has read/search/web tools but does NOT operate Claude Code directly.
|
|
89
|
+
- **`manager`** (subagent) — operates a Claude Code engineer through a persistent session. Has the full tool surface (`engineer_*`, `git_*`, `approval_*`) plus read/search/web tools for investigation.
|
|
90
|
+
- **Engineer** — the Claude Code persistent session itself (not an OpenCode agent). Receives instructions from the manager, executes code changes, and reports results.
|
|
91
|
+
|
|
92
|
+
These are added to OpenCode config at runtime by the plugin, so they do not require separate manual `opencode.json` entries.
|
|
93
|
+
|
|
94
|
+
## Quick Start
|
|
95
|
+
|
|
96
|
+
Typical flow inside OpenCode:
|
|
97
|
+
|
|
98
|
+
1. Inspect Claude capabilities with `engineer_metadata`.
|
|
99
|
+
2. Delegate work with `engineer_send`.
|
|
100
|
+
3. Review changes with `git_diff`, then commit or reset.
|
|
101
|
+
4. Inspect saved Claude history with `engineer_sessions` or prior orchestration records with `engineer_runs`.
|
|
102
|
+
|
|
103
|
+
Example tasks:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
Use engineer_send to implement the new validation logic in src/auth.ts, then review with git_diff.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Start a fresh session for an unrelated task:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
Use engineer_send with freshSession:true to investigate the failing CI test in test/api.test.ts using mode:"plan".
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Reclaim context mid-session:
|
|
75
116
|
|
|
76
|
-
|
|
77
|
-
|
|
117
|
+
```text
|
|
118
|
+
Use engineer_compact to free up context, then continue with the next implementation step.
|
|
119
|
+
```
|
|
78
120
|
|
|
79
121
|
## Local Development
|
|
80
122
|
|
|
123
|
+
Clone the repo and run:
|
|
124
|
+
|
|
81
125
|
```bash
|
|
82
126
|
pnpm install
|
|
83
127
|
pnpm run lint
|
|
@@ -86,9 +130,54 @@ pnpm run test
|
|
|
86
130
|
pnpm run build
|
|
87
131
|
```
|
|
88
132
|
|
|
133
|
+
The compiled plugin output is written to `dist/`.
|
|
134
|
+
|
|
89
135
|
## Publishing
|
|
90
136
|
|
|
91
|
-
This package is configured for the npm scope `@doingdev`.
|
|
137
|
+
This package is configured for the npm scope `@doingdev`.
|
|
138
|
+
|
|
139
|
+
This repository uses npm trusted publishing with GitHub Actions OIDC, so you do not need an `NPM_TOKEN` secret once npm is configured correctly.
|
|
140
|
+
|
|
141
|
+
Before the first automated publish, configure npm trusted publishing for `@doingdev/opencode-claude-manager-plugin` on npmjs.com:
|
|
142
|
+
|
|
143
|
+
1. Open the package settings on npmjs.com.
|
|
144
|
+
2. Go to the `Trusted Publisher` section.
|
|
145
|
+
3. Choose `GitHub Actions`.
|
|
146
|
+
4. Set the GitHub owner/user to your account or org.
|
|
147
|
+
5. Set the repository name.
|
|
148
|
+
6. Set the workflow filename to `publish.yml`.
|
|
149
|
+
7. Leave the environment name empty unless you later add a GitHub Actions environment back to the workflow.
|
|
150
|
+
|
|
151
|
+
Notes for trusted publishing:
|
|
152
|
+
|
|
153
|
+
- npm trusted publishing requires GitHub-hosted runners.
|
|
154
|
+
- npm recommends Node `22.14.0+` with npm CLI `11.5.1+`; the workflows use Node `24`.
|
|
155
|
+
- Provenance is generated automatically by npm for trusted publishes from public GitHub repositories.
|
|
156
|
+
|
|
157
|
+
Release flow:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pnpm login
|
|
161
|
+
pnpm whoami
|
|
162
|
+
pnpm version patch
|
|
163
|
+
pnpm run lint
|
|
164
|
+
pnpm run typecheck
|
|
165
|
+
pnpm run test
|
|
166
|
+
pnpm run build
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Then publish from GitHub by either:
|
|
170
|
+
|
|
171
|
+
- creating a GitHub Release, or
|
|
172
|
+
- running the `Publish` workflow manually from the Actions tab
|
|
173
|
+
|
|
174
|
+
After trusted publishing is working, you can tighten npm package security by disabling token-based publishing for the package in npm settings.
|
|
175
|
+
|
|
176
|
+
## Limitations
|
|
177
|
+
|
|
178
|
+
- Claude slash commands and skills come primarily from filesystem discovery; SDK probing is available but optional.
|
|
179
|
+
- Session state is local to the repo under `.claude-manager/` and is ignored by git.
|
|
180
|
+
- Context tracking is heuristic-based; actual SDK context usage may differ slightly.
|
|
92
181
|
|
|
93
182
|
## Scripts
|
|
94
183
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Options, type Query, type SDKSessionInfo, type SessionMessage, type SettingSource } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import type { ClaudeCapabilitySnapshot, ClaudeSessionEvent, ClaudeSessionRunResult, ClaudeSessionSummary, ClaudeSessionTranscriptMessage, RunClaudeSessionInput } from '../types/contracts.js';
|
|
3
|
+
import type { ToolApprovalManager } from './tool-approval-manager.js';
|
|
4
|
+
export type ClaudeSessionEventHandler = (event: ClaudeSessionEvent) => void | Promise<void>;
|
|
5
|
+
interface ClaudeAgentSdkFacade {
|
|
6
|
+
query(params: {
|
|
7
|
+
prompt: string;
|
|
8
|
+
options?: Options;
|
|
9
|
+
}): Query;
|
|
10
|
+
listSessions(options?: {
|
|
11
|
+
dir?: string;
|
|
12
|
+
}): Promise<SDKSessionInfo[]>;
|
|
13
|
+
getSessionMessages(sessionId: string, options?: {
|
|
14
|
+
dir?: string;
|
|
15
|
+
}): Promise<SessionMessage[]>;
|
|
16
|
+
}
|
|
17
|
+
export declare class ClaudeAgentSdkAdapter {
|
|
18
|
+
private readonly sdkFacade;
|
|
19
|
+
private readonly approvalManager?;
|
|
20
|
+
constructor(sdkFacade?: ClaudeAgentSdkFacade, approvalManager?: ToolApprovalManager | undefined);
|
|
21
|
+
runSession(input: RunClaudeSessionInput, onEvent?: ClaudeSessionEventHandler): Promise<ClaudeSessionRunResult>;
|
|
22
|
+
listSavedSessions(cwd?: string): Promise<ClaudeSessionSummary[]>;
|
|
23
|
+
getTranscript(sessionId: string, cwd?: string): Promise<ClaudeSessionTranscriptMessage[]>;
|
|
24
|
+
probeCapabilities(cwd: string, settingSources?: SettingSource[]): Promise<ClaudeCapabilitySnapshot>;
|
|
25
|
+
private buildOptions;
|
|
26
|
+
}
|
|
27
|
+
export {};
|