@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.
- package/README.md +40 -89
- 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 -133
- 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/persistent-manager.d.ts +0 -73
- 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 -578
- 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
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridges Claude Agent SDK tool permission prompts to OpenCode `ToolContext.ask`.
|
|
3
|
-
* Serializes concurrent asks: parallel manager sub-sessions share one OpenCode tool context.
|
|
4
|
-
*
|
|
5
|
-
* AskUserQuestion: OpenCode `ask` does not return selected labels. After approval we return
|
|
6
|
-
* allow with answers set to each question's first option label so the session can proceed;
|
|
7
|
-
* the UI should still show full choices — users needing a different option should answer via
|
|
8
|
-
* the primary agent and re-run.
|
|
9
|
-
*/
|
|
10
|
-
export function createClaudeCodePermissionBridge(context) {
|
|
11
|
-
const queue = createPermissionAskQueue();
|
|
12
|
-
return {
|
|
13
|
-
createCanUseTool(scope) {
|
|
14
|
-
return (toolName, input, options) => queue.enqueue(() => bridgeCanUseTool(context, scope, toolName, input, options));
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function createPermissionAskQueue() {
|
|
19
|
-
let chain = Promise.resolve();
|
|
20
|
-
return {
|
|
21
|
-
enqueue(operation) {
|
|
22
|
-
const resultPromise = chain
|
|
23
|
-
.catch(() => undefined)
|
|
24
|
-
.then(operation);
|
|
25
|
-
chain = resultPromise.then(() => undefined, () => undefined);
|
|
26
|
-
return resultPromise;
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
async function bridgeCanUseTool(context, scope, toolName, input, options) {
|
|
31
|
-
if (options.signal.aborted) {
|
|
32
|
-
return {
|
|
33
|
-
behavior: 'deny',
|
|
34
|
-
message: 'Permission request aborted.',
|
|
35
|
-
toolUseID: options.toolUseID,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
if (toolName === 'AskUserQuestion') {
|
|
39
|
-
return handleAskUserQuestion(context, scope, input, options);
|
|
40
|
-
}
|
|
41
|
-
const permission = mapClaudeToolToOpenCodePermission(toolName);
|
|
42
|
-
const patterns = derivePatterns(toolName, input);
|
|
43
|
-
const metadata = buildMetadata(scope, toolName, input, options);
|
|
44
|
-
try {
|
|
45
|
-
await context.ask({
|
|
46
|
-
permission,
|
|
47
|
-
patterns,
|
|
48
|
-
always: [],
|
|
49
|
-
metadata,
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
behavior: 'allow',
|
|
53
|
-
updatedInput: input,
|
|
54
|
-
toolUseID: options.toolUseID,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
return {
|
|
59
|
-
behavior: 'deny',
|
|
60
|
-
message: error instanceof Error
|
|
61
|
-
? error.message
|
|
62
|
-
: 'OpenCode permission request was rejected or failed.',
|
|
63
|
-
toolUseID: options.toolUseID,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
async function handleAskUserQuestion(context, scope, input, options) {
|
|
68
|
-
const questions = input.questions;
|
|
69
|
-
if (!Array.isArray(questions) || questions.length === 0) {
|
|
70
|
-
return {
|
|
71
|
-
behavior: 'deny',
|
|
72
|
-
message: 'AskUserQuestion invoked without a valid questions array.',
|
|
73
|
-
toolUseID: options.toolUseID,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const metadata = {
|
|
77
|
-
...buildMetadata(scope, 'AskUserQuestion', input, options),
|
|
78
|
-
questions,
|
|
79
|
-
note: 'Claude Code AskUserQuestion: approving proceeds with the first listed option per question unless the host supplies structured replies.',
|
|
80
|
-
};
|
|
81
|
-
try {
|
|
82
|
-
await context.ask({
|
|
83
|
-
permission: 'question',
|
|
84
|
-
patterns: [],
|
|
85
|
-
always: [],
|
|
86
|
-
metadata,
|
|
87
|
-
});
|
|
88
|
-
const answers = buildDefaultAskUserQuestionAnswers(questions);
|
|
89
|
-
return {
|
|
90
|
-
behavior: 'allow',
|
|
91
|
-
updatedInput: {
|
|
92
|
-
...input,
|
|
93
|
-
questions,
|
|
94
|
-
answers,
|
|
95
|
-
},
|
|
96
|
-
toolUseID: options.toolUseID,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
return {
|
|
101
|
-
behavior: 'deny',
|
|
102
|
-
message: error instanceof Error
|
|
103
|
-
? error.message
|
|
104
|
-
: 'OpenCode declined or failed the clarifying-question prompt.',
|
|
105
|
-
toolUseID: options.toolUseID,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function buildDefaultAskUserQuestionAnswers(questions) {
|
|
110
|
-
const answers = {};
|
|
111
|
-
for (const raw of questions) {
|
|
112
|
-
if (!raw || typeof raw !== 'object') {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const entry = raw;
|
|
116
|
-
const questionText = typeof entry.question === 'string' ? entry.question : '';
|
|
117
|
-
if (!questionText) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
const options = Array.isArray(entry.options) ? entry.options : [];
|
|
121
|
-
const first = options[0];
|
|
122
|
-
const label = first &&
|
|
123
|
-
typeof first === 'object' &&
|
|
124
|
-
first !== null &&
|
|
125
|
-
typeof first.label === 'string'
|
|
126
|
-
? first.label
|
|
127
|
-
: 'Default';
|
|
128
|
-
answers[questionText] = label;
|
|
129
|
-
}
|
|
130
|
-
return answers;
|
|
131
|
-
}
|
|
132
|
-
function mapClaudeToolToOpenCodePermission(toolName) {
|
|
133
|
-
switch (toolName) {
|
|
134
|
-
case 'Read':
|
|
135
|
-
return 'read';
|
|
136
|
-
case 'Write':
|
|
137
|
-
case 'Edit':
|
|
138
|
-
case 'NotebookEdit':
|
|
139
|
-
return 'edit';
|
|
140
|
-
case 'Bash':
|
|
141
|
-
return 'bash';
|
|
142
|
-
case 'Glob':
|
|
143
|
-
return 'glob';
|
|
144
|
-
case 'Grep':
|
|
145
|
-
return 'grep';
|
|
146
|
-
case 'Task':
|
|
147
|
-
case 'Agent':
|
|
148
|
-
return 'task';
|
|
149
|
-
case 'WebFetch':
|
|
150
|
-
return 'webfetch';
|
|
151
|
-
case 'WebSearch':
|
|
152
|
-
return 'websearch';
|
|
153
|
-
default:
|
|
154
|
-
return 'bash';
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function derivePatterns(toolName, input) {
|
|
158
|
-
const filePath = input.file_path ?? input.path;
|
|
159
|
-
if (typeof filePath === 'string' && filePath.length > 0) {
|
|
160
|
-
return [filePath];
|
|
161
|
-
}
|
|
162
|
-
if (toolName === 'Bash' && typeof input.command === 'string') {
|
|
163
|
-
return [input.command];
|
|
164
|
-
}
|
|
165
|
-
return [];
|
|
166
|
-
}
|
|
167
|
-
function buildMetadata(scope, toolName, input, options) {
|
|
168
|
-
return {
|
|
169
|
-
source: 'claude_code',
|
|
170
|
-
managerRunId: scope.runId,
|
|
171
|
-
managerPlanId: scope.planId,
|
|
172
|
-
managerPlanTitle: scope.planTitle,
|
|
173
|
-
claudeTool: toolName,
|
|
174
|
-
toolInput: input,
|
|
175
|
-
toolUseID: options.toolUseID,
|
|
176
|
-
agentID: options.agentID,
|
|
177
|
-
title: options.title,
|
|
178
|
-
displayName: options.displayName,
|
|
179
|
-
description: options.description,
|
|
180
|
-
blockedPath: options.blockedPath,
|
|
181
|
-
decisionReason: options.decisionReason,
|
|
182
|
-
sdkSuggestions: options.suggestions,
|
|
183
|
-
};
|
|
184
|
-
}
|