@khalilgharbaoui/opencode-claude-code-plugin 0.53.0 → 0.53.2
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/dist/index.js +40 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/claude-code-plugin/SKILL.md +6 -2
package/dist/index.js
CHANGED
|
@@ -2774,6 +2774,12 @@ var MAX_CLAIMS = 512;
|
|
|
2774
2774
|
var claims = [];
|
|
2775
2775
|
var sessionChoices = /* @__PURE__ */ new Map();
|
|
2776
2776
|
var MAX_SESSION_CHOICES = 512;
|
|
2777
|
+
function promptMatchesClaim(claimPrompt, childPrompt) {
|
|
2778
|
+
if (childPrompt === claimPrompt) return true;
|
|
2779
|
+
if (claimPrompt.length === 0) return false;
|
|
2780
|
+
return childPrompt.endsWith(`
|
|
2781
|
+
${claimPrompt}`);
|
|
2782
|
+
}
|
|
2777
2783
|
function pruneClaims(now) {
|
|
2778
2784
|
for (let i = claims.length - 1; i >= 0; i--) {
|
|
2779
2785
|
if (now - claims[i].createdAt > CLAIM_TTL_MS) claims.splice(i, 1);
|
|
@@ -2804,7 +2810,9 @@ function lookupSessionChoice(sessionId) {
|
|
|
2804
2810
|
function hasCandidateClaim(agent, prompt, now = Date.now()) {
|
|
2805
2811
|
if (!agent || prompt === void 0) return false;
|
|
2806
2812
|
pruneClaims(now);
|
|
2807
|
-
return claims.some(
|
|
2813
|
+
return claims.some(
|
|
2814
|
+
(claim) => claim.agent === agent && promptMatchesClaim(claim.prompt, prompt)
|
|
2815
|
+
);
|
|
2808
2816
|
}
|
|
2809
2817
|
function claimDispatchChoice(input) {
|
|
2810
2818
|
const existing = sessionChoices.get(input.sessionId);
|
|
@@ -2813,9 +2821,14 @@ function claimDispatchChoice(input) {
|
|
|
2813
2821
|
return void 0;
|
|
2814
2822
|
}
|
|
2815
2823
|
pruneClaims(input.now ?? Date.now());
|
|
2816
|
-
const
|
|
2817
|
-
|
|
2818
|
-
);
|
|
2824
|
+
const belongsHere = (claim2) => claim2.parentSessionId === input.parentSessionId && claim2.agent === input.agent;
|
|
2825
|
+
const childPrompt = input.prompt;
|
|
2826
|
+
let index = claims.findIndex((claim2) => belongsHere(claim2) && claim2.prompt === childPrompt);
|
|
2827
|
+
if (index === -1) {
|
|
2828
|
+
index = claims.findIndex(
|
|
2829
|
+
(claim2) => belongsHere(claim2) && promptMatchesClaim(claim2.prompt, childPrompt)
|
|
2830
|
+
);
|
|
2831
|
+
}
|
|
2819
2832
|
if (index === -1) return void 0;
|
|
2820
2833
|
const [claim] = claims.splice(index, 1);
|
|
2821
2834
|
sessionChoices.set(input.sessionId, claim.choice);
|
|
@@ -4031,7 +4044,13 @@ var TASK_INPUT_PROPERTIES = {
|
|
|
4031
4044
|
},
|
|
4032
4045
|
background: {
|
|
4033
4046
|
type: "boolean",
|
|
4034
|
-
|
|
4047
|
+
// Both majors, for the reason the `task_id` field names both: a model
|
|
4048
|
+
// told to look for only V1's envelope finds nothing on opencode 2, where
|
|
4049
|
+
// a background dispatch answers in prose, and then has no task_id to pass
|
|
4050
|
+
// to task_status or task_cancel. This constant is shared by `task` and by
|
|
4051
|
+
// every `task_batch` item and is built with no dialect in hand, so it
|
|
4052
|
+
// names both rather than being rewritten per host.
|
|
4053
|
+
description: 'Run the subagent in the background and return immediately instead of its answer: opencode 1.x answers with a `<task id="..." state="running">` envelope, opencode 2 with `The subagent is working in the background (sessionID: ses_...)`. You are notified automatically when it completes. Do NOT sleep, poll or proactively check on its progress.'
|
|
4035
4054
|
}
|
|
4036
4055
|
};
|
|
4037
4056
|
var TASK_INPUT_PROPERTIES_NO_BACKGROUND = Object.fromEntries(
|
|
@@ -12107,6 +12126,17 @@ This opencode host runs background subagents, so \`mcp__opencode_proxy__task\` t
|
|
|
12107
12126
|
- After starting one, keep working on something that does not overlap it, then end your turn normally. When the subagent finishes, opencode delivers its result into this conversation as a new message on its own. Do not sleep, poll, or ask the operator to wait.
|
|
12108
12127
|
- The \`id\` in that envelope is the task_id. \`mcp__opencode_proxy__task_status\` reads a result back if the automatic delivery did not arrive (an interrupted or errored turn); \`mcp__opencode_proxy__task_cancel\` stops a background subagent you no longer want. Neither is a progress poll.
|
|
12109
12128
|
- Foreground is still the default and still the right choice when you need the answer before you can continue. Use background only for work that genuinely runs alongside yours.`;
|
|
12129
|
+
var BACKGROUND_SUBAGENT_HINT_V2 = `## Background subagents
|
|
12130
|
+
|
|
12131
|
+
This opencode host runs background subagents, so \`mcp__opencode_proxy__task\` takes \`background: true\`.
|
|
12132
|
+
|
|
12133
|
+
- A background dispatch returns at once with \`The subagent is working in the background (sessionID: ses_...)\` instead of the subagent's answer. That is success, not a truncated result.
|
|
12134
|
+
- After starting one, keep working on something that does not overlap it, then end your turn normally. When the subagent finishes, opencode delivers its result into this conversation on its own, as a \`<subagent sessionID="..." state="completed">\` message. Do not sleep, poll, or ask the operator to wait.
|
|
12135
|
+
- That \`sessionID\` is the task_id. \`mcp__opencode_proxy__task_status\` reads a result back if the automatic delivery did not arrive (an interrupted or errored turn); \`mcp__opencode_proxy__task_cancel\` stops a background subagent you no longer want. Neither is a progress poll.
|
|
12136
|
+
- Foreground is still the default and still the right choice when you need the answer before you can continue. Use background only for work that genuinely runs alongside yours.`;
|
|
12137
|
+
function backgroundSubagentHint(dialect) {
|
|
12138
|
+
return dialect === "v2" ? BACKGROUND_SUBAGENT_HINT_V2 : BACKGROUND_SUBAGENT_HINT;
|
|
12139
|
+
}
|
|
12110
12140
|
var QUESTION_PROXY_HINT = `## Asking the operator questions
|
|
12111
12141
|
|
|
12112
12142
|
Structured questions in this environment go through exactly one tool: \`mcp__opencode_proxy__question\`.
|
|
@@ -15992,6 +16022,7 @@ var ClaudeCodeLanguageModel = class {
|
|
|
15992
16022
|
};
|
|
15993
16023
|
let enrichedProxy = resolvedProxy;
|
|
15994
16024
|
let backgroundSubagentsSupported = false;
|
|
16025
|
+
const hostDialect = self.config.hostApi === "v2" ? "v2" : "v1";
|
|
15995
16026
|
if (enrichedProxy && taskProxyEnabled) {
|
|
15996
16027
|
enrichedProxy = overlayTaskProxyDescription(
|
|
15997
16028
|
enrichedProxy,
|
|
@@ -16006,7 +16037,6 @@ var ClaudeCodeLanguageModel = class {
|
|
|
16006
16037
|
)
|
|
16007
16038
|
)
|
|
16008
16039
|
});
|
|
16009
|
-
const hostDialect = self.config.hostApi === "v2" ? "v2" : "v1";
|
|
16010
16040
|
backgroundSubagentsSupported = liveTaskSupportsBackground(
|
|
16011
16041
|
liveToolInfo.taskParameters,
|
|
16012
16042
|
hostDialect
|
|
@@ -16083,6 +16113,7 @@ var ClaudeCodeLanguageModel = class {
|
|
|
16083
16113
|
excludeServers,
|
|
16084
16114
|
taskProxyEnabled,
|
|
16085
16115
|
backgroundSubagentsSupported,
|
|
16116
|
+
hostDialect,
|
|
16086
16117
|
questionProxyActive,
|
|
16087
16118
|
opencodeToolDefs,
|
|
16088
16119
|
pluginCompressEnabled,
|
|
@@ -16148,7 +16179,7 @@ var ClaudeCodeLanguageModel = class {
|
|
|
16148
16179
|
// dispatch instead of calling the proxy (h #g74).
|
|
16149
16180
|
[
|
|
16150
16181
|
...wiring.taskProxyEnabled ? [SUBAGENT_DISPATCH_HINT] : [],
|
|
16151
|
-
...wiring.backgroundSubagentsSupported ? [
|
|
16182
|
+
...wiring.backgroundSubagentsSupported ? [backgroundSubagentHint(wiring.hostDialect)] : [],
|
|
16152
16183
|
...wiring.questionProxyActive ? [QUESTION_PROXY_HINT] : []
|
|
16153
16184
|
],
|
|
16154
16185
|
{
|
|
@@ -16262,6 +16293,7 @@ var ClaudeCodeLanguageModel = class {
|
|
|
16262
16293
|
excludeServers,
|
|
16263
16294
|
taskProxyEnabled,
|
|
16264
16295
|
backgroundSubagentsSupported,
|
|
16296
|
+
hostDialect,
|
|
16265
16297
|
questionProxyActive,
|
|
16266
16298
|
opencodeToolDefs,
|
|
16267
16299
|
pluginCompressEnabled,
|
|
@@ -16279,7 +16311,7 @@ var ClaudeCodeLanguageModel = class {
|
|
|
16279
16311
|
[
|
|
16280
16312
|
...extractSystemMessages(options.prompt),
|
|
16281
16313
|
...taskProxyEnabled ? [SUBAGENT_DISPATCH_HINT] : [],
|
|
16282
|
-
...backgroundSubagentsSupported ? [
|
|
16314
|
+
...backgroundSubagentsSupported ? [backgroundSubagentHint(hostDialect)] : [],
|
|
16283
16315
|
...questionProxyActive ? [QUESTION_PROXY_HINT] : [],
|
|
16284
16316
|
...self.config.hostApi === "v2" && options.tools?.some((t) => t.name === "execute") ? [codeModeProxyHint(opencodeToolDefs.some((t) => t.name === "execute"))] : []
|
|
16285
16317
|
],
|