@doingdev/opencode-claude-manager-plugin 0.1.20 → 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.
- package/README.md +40 -129
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -4
- package/dist/plugin/orchestrator.plugin.d.ts +14 -0
- package/dist/plugin/orchestrator.plugin.js +108 -0
- package/dist/prompts/registry.d.ts +8 -2
- package/dist/prompts/registry.js +30 -159
- package/dist/safety/bash-safety.d.ts +21 -0
- package/dist/safety/bash-safety.js +62 -0
- package/package.json +3 -6
- package/dist/claude/claude-agent-sdk-adapter.d.ts +0 -27
- package/dist/claude/claude-agent-sdk-adapter.js +0 -520
- package/dist/claude/claude-session.service.d.ts +0 -15
- package/dist/claude/claude-session.service.js +0 -23
- package/dist/claude/delegated-can-use-tool.d.ts +0 -7
- package/dist/claude/delegated-can-use-tool.js +0 -178
- package/dist/claude/session-live-tailer.d.ts +0 -51
- package/dist/claude/session-live-tailer.js +0 -269
- package/dist/claude/tool-approval-manager.d.ts +0 -27
- package/dist/claude/tool-approval-manager.js +0 -238
- package/dist/manager/context-tracker.d.ts +0 -33
- package/dist/manager/context-tracker.js +0 -108
- package/dist/manager/git-operations.d.ts +0 -12
- package/dist/manager/git-operations.js +0 -76
- package/dist/manager/manager-orchestrator.d.ts +0 -17
- package/dist/manager/manager-orchestrator.js +0 -178
- package/dist/manager/parallel-session-job-manager.d.ts +0 -49
- package/dist/manager/parallel-session-job-manager.js +0 -177
- package/dist/manager/persistent-manager.d.ts +0 -74
- package/dist/manager/persistent-manager.js +0 -167
- package/dist/manager/session-controller.d.ts +0 -45
- package/dist/manager/session-controller.js +0 -147
- package/dist/manager/task-planner.d.ts +0 -5
- package/dist/manager/task-planner.js +0 -15
- package/dist/metadata/claude-metadata.service.d.ts +0 -12
- package/dist/metadata/claude-metadata.service.js +0 -38
- package/dist/metadata/repo-claude-config-reader.d.ts +0 -7
- package/dist/metadata/repo-claude-config-reader.js +0 -154
- package/dist/plugin/claude-code-permission-bridge.d.ts +0 -15
- package/dist/plugin/claude-code-permission-bridge.js +0 -184
- package/dist/plugin/claude-manager.plugin.d.ts +0 -2
- package/dist/plugin/claude-manager.plugin.js +0 -627
- package/dist/plugin/service-factory.d.ts +0 -12
- package/dist/plugin/service-factory.js +0 -41
- package/dist/state/file-run-state-store.d.ts +0 -14
- package/dist/state/file-run-state-store.js +0 -87
- package/dist/state/transcript-store.d.ts +0 -15
- package/dist/state/transcript-store.js +0 -44
- package/dist/types/contracts.d.ts +0 -215
- package/dist/types/contracts.js +0 -1
- package/dist/util/fs-helpers.d.ts +0 -2
- package/dist/util/fs-helpers.js +0 -12
- package/dist/util/transcript-append.d.ts +0 -7
- package/dist/util/transcript-append.js +0 -29
- package/dist/worktree/worktree-coordinator.d.ts +0 -21
- package/dist/worktree/worktree-coordinator.js +0 -64
package/README.md
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
# OpenCode Claude
|
|
1
|
+
# OpenCode Claude Code Subagents Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Thin OpenCode orchestrator plugin with Claude Code specialist subagents.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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.
|
|
18
27
|
|
|
19
28
|
## Requirements
|
|
20
29
|
|
|
21
30
|
- Node `22+`
|
|
22
31
|
- OpenCode with plugin loading enabled
|
|
23
|
-
-
|
|
32
|
+
- Claude Code available on the machine (the `ai-sdk-provider-claude-code` provider connects to it)
|
|
24
33
|
|
|
25
34
|
## Installation
|
|
26
35
|
|
|
27
|
-
Install from the npm registry:
|
|
28
|
-
|
|
29
36
|
```bash
|
|
30
37
|
pnpm add @doingdev/opencode-claude-manager-plugin
|
|
31
38
|
```
|
|
32
39
|
|
|
33
|
-
Or for local development
|
|
40
|
+
Or for local development:
|
|
34
41
|
|
|
35
42
|
```bash
|
|
36
43
|
pnpm install
|
|
@@ -39,89 +46,38 @@ pnpm run build
|
|
|
39
46
|
|
|
40
47
|
## OpenCode Config
|
|
41
48
|
|
|
42
|
-
Add the plugin to your OpenCode config:
|
|
43
|
-
|
|
44
49
|
```json
|
|
45
50
|
{
|
|
46
51
|
"plugin": ["@doingdev/opencode-claude-manager-plugin"]
|
|
47
52
|
}
|
|
48
53
|
```
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
## OpenCode tools
|
|
53
|
-
|
|
54
|
-
### Session management
|
|
55
|
-
|
|
56
|
-
- `claude_manager_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
|
-
- `claude_manager_compact` — compress the active session context while preserving session state. Use before clearing when context is high but salvageable.
|
|
63
|
-
- `claude_manager_clear` — drop the active session entirely; next send starts fresh.
|
|
64
|
-
- `claude_manager_status` — get current session health: context %, turns, cost, session ID.
|
|
65
|
-
|
|
66
|
-
### Git operations
|
|
67
|
-
|
|
68
|
-
- `claude_manager_git_diff` — review all uncommitted changes (staged + unstaged).
|
|
69
|
-
- `claude_manager_git_commit` — stage all changes and commit with a message.
|
|
70
|
-
- `claude_manager_git_reset` — hard reset + clean (destructive).
|
|
55
|
+
## Agents
|
|
71
56
|
|
|
72
|
-
|
|
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 |
|
|
73
64
|
|
|
74
|
-
|
|
75
|
-
- `claude_manager_sessions` — list Claude sessions or inspect a saved transcript.
|
|
76
|
-
- `claude_manager_runs` — list or inspect persisted manager run records (may be empty if tasks were sent directly via `claude_manager_send` rather than the run-tracking path).
|
|
77
|
-
|
|
78
|
-
### Tool approval
|
|
79
|
-
|
|
80
|
-
- `claude_manager_approval_policy` — view the current tool approval policy.
|
|
81
|
-
- `claude_manager_approval_decisions` — view recent tool approval decisions.
|
|
82
|
-
- `claude_manager_approval_update` — add/remove rules, change default action, or enable/disable approval.
|
|
83
|
-
|
|
84
|
-
## Plugin-provided agents and commands
|
|
85
|
-
|
|
86
|
-
When the plugin loads successfully, it also injects config entries through the OpenCode plugin `config` hook.
|
|
87
|
-
|
|
88
|
-
- Primary agent: `claude-manager`
|
|
89
|
-
- Subagent: `claude-manager-research`
|
|
90
|
-
- Commands: `/claude-metadata`, `/claude-run`, `/claude-sessions`
|
|
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 `claude_manager_metadata`.
|
|
99
|
-
2. Delegate work with `claude_manager_send`.
|
|
100
|
-
3. Review changes with `claude_manager_git_diff`, then commit or reset.
|
|
101
|
-
4. Inspect saved Claude history with `claude_manager_sessions` or prior orchestration records with `claude_manager_runs`.
|
|
102
|
-
|
|
103
|
-
Example tasks:
|
|
104
|
-
|
|
105
|
-
```text
|
|
106
|
-
Use claude_manager_send to implement the new validation logic in src/auth.ts, then review with claude_manager_git_diff.
|
|
107
|
-
```
|
|
65
|
+
## Bash Safety
|
|
108
66
|
|
|
109
|
-
|
|
67
|
+
A minimal safety layer enforces deny rules via the `permission.ask` hook:
|
|
110
68
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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.)
|
|
114
73
|
|
|
115
|
-
|
|
74
|
+
## Limitations
|
|
116
75
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
```
|
|
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.
|
|
120
78
|
|
|
121
79
|
## Local Development
|
|
122
80
|
|
|
123
|
-
Clone the repo and run:
|
|
124
|
-
|
|
125
81
|
```bash
|
|
126
82
|
pnpm install
|
|
127
83
|
pnpm run lint
|
|
@@ -130,54 +86,9 @@ pnpm run test
|
|
|
130
86
|
pnpm run build
|
|
131
87
|
```
|
|
132
88
|
|
|
133
|
-
The compiled plugin output is written to `dist/`.
|
|
134
|
-
|
|
135
89
|
## Publishing
|
|
136
90
|
|
|
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.
|
|
91
|
+
This package is configured for the npm scope `@doingdev`. See the GitHub Actions workflow for automated publishing via npm trusted publishing.
|
|
181
92
|
|
|
182
93
|
## Scripts
|
|
183
94
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from '@opencode-ai/plugin';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
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 {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
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
|
-
|
|
2
|
-
|
|
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
|
+
};
|
package/dist/prompts/registry.js
CHANGED
|
@@ -1,166 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'
|
|
7
|
-
'',
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
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%: use claude_manager_compact to reclaim context if the session',
|
|
76
|
-
' still has useful state. Only clear if compaction is insufficient.',
|
|
77
|
-
'- Over 85%: clear the session immediately.',
|
|
78
|
-
'Use freshSession:true on claude_manager_send when switching to an unrelated',
|
|
79
|
-
'task or when the session context is contaminated. Prefer this over a manual',
|
|
80
|
-
'clear+send sequence — it is atomic and self-documenting.',
|
|
81
|
-
'',
|
|
82
|
-
'## Model and effort selection',
|
|
83
|
-
'Choose model and effort deliberately before each delegation:',
|
|
84
|
-
'- claude-opus-4-6 + high effort: default for most coding tasks.',
|
|
85
|
-
'- claude-sonnet-4-6 or claude-sonnet-4-5: faster/lighter work (simple renames,',
|
|
86
|
-
' formatting, test scaffolding, quick investigations).',
|
|
87
|
-
'- effort "medium": acceptable for lighter tasks that do not require deep reasoning.',
|
|
88
|
-
'- effort "max": reserve for unusually hard problems (complex refactors,',
|
|
89
|
-
' subtle concurrency bugs, large cross-cutting changes).',
|
|
90
|
-
"- Do not use Haiku for this plugin's coding-agent role.",
|
|
91
|
-
'',
|
|
92
|
-
'## Plan mode',
|
|
93
|
-
'When delegating with mode:"plan", Claude Code returns a read-only',
|
|
94
|
-
'implementation plan. The plan MUST be returned inline in the assistant',
|
|
95
|
-
'response — do NOT write plan artifacts to disk, create files, or rely on',
|
|
96
|
-
'ExitPlanMode. Treat the returned finalText as the plan. If the plan is',
|
|
97
|
-
'acceptable, switch to mode:"free" and delegate the implementation steps.',
|
|
98
|
-
'',
|
|
99
|
-
'## Tools reference',
|
|
100
|
-
'todowrite / todoread — OpenCode session todo list (track multi-step work)',
|
|
101
|
-
'question — OpenCode user prompt with options (clarify trade-offs)',
|
|
102
|
-
'claude_manager_send — send instruction (creates or resumes session)',
|
|
103
|
-
' freshSession:true — clear session first (use for unrelated tasks)',
|
|
104
|
-
' model / effort — choose deliberately (see "Model and effort selection")',
|
|
105
|
-
'claude_manager_compact — compress session context (preserves session state)',
|
|
106
|
-
'claude_manager_git_diff — review all uncommitted changes',
|
|
107
|
-
'claude_manager_git_commit — stage all + commit',
|
|
108
|
-
'claude_manager_git_reset — hard reset + clean (destructive)',
|
|
109
|
-
'claude_manager_clear — drop session, next send starts fresh',
|
|
110
|
-
'claude_manager_status — context health snapshot',
|
|
111
|
-
'claude_manager_metadata — inspect repo Claude config',
|
|
112
|
-
'claude_manager_sessions — list sessions or read transcripts',
|
|
113
|
-
'claude_manager_runs — list or inspect run records',
|
|
114
|
-
'',
|
|
115
|
-
'## Autonomy blockers — surface these to the user',
|
|
116
|
-
'Be candid about what you cannot do autonomously:',
|
|
117
|
-
'- Credentials, API keys, or secrets you do not have.',
|
|
118
|
-
'- Architectural decisions with trade-offs the user should weigh.',
|
|
119
|
-
'- Destructive actions on shared state (deploy, publish, force-push).',
|
|
120
|
-
'- Access to external services or environments you cannot reach.',
|
|
121
|
-
'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.',
|
|
122
19
|
].join('\n'),
|
|
123
|
-
|
|
124
|
-
'You are
|
|
125
|
-
'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.',
|
|
126
22
|
'',
|
|
127
|
-
'
|
|
128
|
-
'-
|
|
129
|
-
'-
|
|
130
|
-
'-
|
|
131
|
-
|
|
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.',
|
|
132
30
|
'',
|
|
133
|
-
'
|
|
134
|
-
'-
|
|
135
|
-
'- When creating or modifying code, consider edge cases and error handling.',
|
|
136
|
-
'- When modifying existing code, preserve surrounding style and structure.',
|
|
137
|
-
'- 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.',
|
|
138
33
|
'- Run tests/lint/typecheck when instructed; report exact output on failure.',
|
|
139
|
-
'',
|
|
140
|
-
'## Git boundary — do NOT run these commands:',
|
|
141
|
-
'git commit, git push, git reset, git checkout, git stash.',
|
|
142
|
-
'The operator manages all git operations externally.',
|
|
143
|
-
'',
|
|
144
|
-
'## Reporting',
|
|
34
|
+
'- Do NOT run git commit, git push, git reset, git checkout, or git stash.',
|
|
145
35
|
'- End with a brief verification summary: what was done, what was verified.',
|
|
146
|
-
'- Report blockers immediately with specifics: file, line, error message.',
|
|
147
|
-
'- If a task is partially complete, state exactly what remains.',
|
|
148
36
|
].join('\n'),
|
|
149
|
-
modePrefixes: {
|
|
150
|
-
plan: [
|
|
151
|
-
'[PLAN MODE] You are in read-only planning mode. Do NOT create or edit any files.',
|
|
152
|
-
'Do NOT use ExitPlanMode or write plan artifacts to disk.',
|
|
153
|
-
'Use read, grep, glob, and search tools only.',
|
|
154
|
-
'Analyze the codebase and produce a detailed implementation plan:',
|
|
155
|
-
'files to change, functions to modify, new files to create, test strategy,',
|
|
156
|
-
'and potential risks. End with a numbered step-by-step plan.',
|
|
157
|
-
'Return the entire plan inline in your response text.',
|
|
158
|
-
].join(' '),
|
|
159
|
-
free: '',
|
|
160
|
-
},
|
|
161
|
-
contextWarnings: {
|
|
162
|
-
moderate: 'Session context is filling up ({percent}% estimated). Consider whether a fresh session would be more efficient.',
|
|
163
|
-
high: 'Session context is heavy ({percent}% estimated, {turns} turns, ${cost}). Start a new session or compact first.',
|
|
164
|
-
critical: 'Session context is near capacity ({percent}% estimated). Clear the session immediately before continuing.',
|
|
165
|
-
},
|
|
166
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;
|