@khalilgharbaoui/opencode-claude-code-plugin 0.63.0 → 0.63.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 +69 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/claude-code-plugin/SKILL.md +1 -1
package/dist/index.js
CHANGED
|
@@ -8429,7 +8429,39 @@ function transferClaudeSession(fromKey, toKey) {
|
|
|
8429
8429
|
function effortSessionKey(baseKey, effort) {
|
|
8430
8430
|
return effort ? `${baseKey}::effort=${effort}` : baseKey;
|
|
8431
8431
|
}
|
|
8432
|
-
function
|
|
8432
|
+
function spawnIdentity(key) {
|
|
8433
|
+
const parts = key.split("::");
|
|
8434
|
+
if (parts.length > 1 && parts[parts.length - 1].startsWith("effort=")) parts.pop();
|
|
8435
|
+
const last = parts.length - 1;
|
|
8436
|
+
if (parts[last].startsWith("context=")) {
|
|
8437
|
+
try {
|
|
8438
|
+
const context = JSON.parse(parts[last].slice("context=".length));
|
|
8439
|
+
if (Array.isArray(context)) parts[last] = `context=${JSON.stringify(context.slice(0, 2))}`;
|
|
8440
|
+
} catch {
|
|
8441
|
+
}
|
|
8442
|
+
}
|
|
8443
|
+
return parts.join("::");
|
|
8444
|
+
}
|
|
8445
|
+
function spawnHasPendingWork(key) {
|
|
8446
|
+
const active = activeProcesses.get(key);
|
|
8447
|
+
return !!(getPendingProxyCalls(key).length || hasExitPlanModeQuestions(key) || active?.pendingProxyCompletions?.size || active && (active.lineEmitter.listenerCount("line") > 0 || isSideQuestionPending(active)));
|
|
8448
|
+
}
|
|
8449
|
+
function conversationIdentity(key) {
|
|
8450
|
+
const parts = spawnIdentity(key).split("::");
|
|
8451
|
+
if (parts.length !== 5 || parts[2] === "compaction" || parts[3] === "default") return void 0;
|
|
8452
|
+
parts[1] = parts[1].replace(/^[^@]*/, "*");
|
|
8453
|
+
return parts.join("::");
|
|
8454
|
+
}
|
|
8455
|
+
function findBusySpawnVariant(requestedKey) {
|
|
8456
|
+
const identity = conversationIdentity(requestedKey);
|
|
8457
|
+
if (!identity || spawnHasPendingWork(requestedKey)) return void 0;
|
|
8458
|
+
for (const key of /* @__PURE__ */ new Set([...activeProcesses.keys(), ...claudeSessions.keys()])) {
|
|
8459
|
+
if (key === requestedKey || conversationIdentity(key) !== identity) continue;
|
|
8460
|
+
if (spawnHasPendingWork(key)) return key;
|
|
8461
|
+
}
|
|
8462
|
+
return void 0;
|
|
8463
|
+
}
|
|
8464
|
+
function invalidateOtherSpawnVariants(currentKey, options = {}) {
|
|
8433
8465
|
const levels = [
|
|
8434
8466
|
void 0,
|
|
8435
8467
|
"minimal",
|
|
@@ -8439,19 +8471,26 @@ function invalidateOtherEffortSessions(baseKey, effort) {
|
|
|
8439
8471
|
"xhigh",
|
|
8440
8472
|
"max"
|
|
8441
8473
|
];
|
|
8442
|
-
const
|
|
8474
|
+
const baseKey = currentKey.replace(/::effort=[a-z]+$/, "");
|
|
8475
|
+
const identity = spawnIdentity(currentKey);
|
|
8476
|
+
const staleKeys = [
|
|
8477
|
+
.../* @__PURE__ */ new Set([
|
|
8478
|
+
...[...claudeSessions.keys()].reverse(),
|
|
8479
|
+
...levels.map((level) => effortSessionKey(baseKey, level)),
|
|
8480
|
+
...activeProcesses.keys()
|
|
8481
|
+
])
|
|
8482
|
+
].filter((key) => key !== currentKey && spawnIdentity(key) === identity);
|
|
8443
8483
|
for (const key of staleKeys) {
|
|
8444
|
-
|
|
8445
|
-
if (getPendingProxyCalls(key).length || hasExitPlanModeQuestions(key) || active?.pendingProxyCompletions?.size || active && (active.lineEmitter.listenerCount("line") > 0 || isSideQuestionPending(active))) {
|
|
8484
|
+
if (spawnHasPendingWork(key)) {
|
|
8446
8485
|
throw new Error(
|
|
8447
|
-
"Cannot change reasoning effort while
|
|
8486
|
+
"Cannot change reasoning effort, prompt cache TTL, maxTurns or maxBudgetUsd while this conversation's previous claude process has pending work. Finish that work under its original settings first."
|
|
8448
8487
|
);
|
|
8449
8488
|
}
|
|
8450
8489
|
}
|
|
8451
|
-
const
|
|
8490
|
+
const carry = options.carryConversation !== false;
|
|
8452
8491
|
for (const key of staleKeys) {
|
|
8453
8492
|
deleteActiveProcess(key);
|
|
8454
|
-
if (transferClaudeSession(key, currentKey)) {
|
|
8493
|
+
if (carry && transferClaudeSession(key, currentKey)) {
|
|
8455
8494
|
clearCompression(key);
|
|
8456
8495
|
clearBackgroundTasks(key);
|
|
8457
8496
|
continue;
|
|
@@ -9313,6 +9352,7 @@ var PLUGIN_LOG_MESSAGES = /* @__PURE__ */ new Set([
|
|
|
9313
9352
|
"falling back to the next model in the chain",
|
|
9314
9353
|
"fast mode is in cooldown after a rate limit; this turn runs at standard speed and is billed at standard Opus rates, not the fast price shown in the model picker.",
|
|
9315
9354
|
"file part without data, skipping",
|
|
9355
|
+
"finishing the turn in progress under its original settings",
|
|
9316
9356
|
"forkSessions is on but this claude CLI has no --fork-session; replaying the conversation instead",
|
|
9317
9357
|
"forking the parent conversation's claude session instead of replaying it",
|
|
9318
9358
|
"holding a subagent dispatch for the operator's answer",
|
|
@@ -18372,7 +18412,15 @@ var ClaudeCodeLanguageModel = class {
|
|
|
18372
18412
|
cwd,
|
|
18373
18413
|
`${effectiveModelId}::${scope}::${affinity}::context=${JSON.stringify(context)}`
|
|
18374
18414
|
);
|
|
18375
|
-
const
|
|
18415
|
+
const requestedKey = effortSessionKey(baseKey, reasoningEffort);
|
|
18416
|
+
const busyVariant = compactionMode ? void 0 : findBusySpawnVariant(requestedKey);
|
|
18417
|
+
if (busyVariant) {
|
|
18418
|
+
log.notice("finishing the turn in progress under its original settings", {
|
|
18419
|
+
sessionKey: busyVariant,
|
|
18420
|
+
requestedKey
|
|
18421
|
+
});
|
|
18422
|
+
}
|
|
18423
|
+
const sk = compactionMode ? sessionKey(cwd, `${effectiveModelId}::compaction::${affinity}`) : busyVariant ?? requestedKey;
|
|
18376
18424
|
const toUsage2 = this.toUsage.bind(this);
|
|
18377
18425
|
const toFinishReason2 = this.toFinishReason.bind(this);
|
|
18378
18426
|
const handleControlRequest2 = this.handleControlRequest.bind(this);
|
|
@@ -18582,14 +18630,20 @@ var ClaudeCodeLanguageModel = class {
|
|
|
18582
18630
|
});
|
|
18583
18631
|
}
|
|
18584
18632
|
}
|
|
18585
|
-
if (!compactionMode)
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
model: stripAccountSuffix(failover.modelId),
|
|
18589
|
-
effort: reasoningEffort,
|
|
18590
|
-
account: (this.config.failoverAccounts?.length ?? 0) > 1 ? failover.target ?? sourceAccount : void 0,
|
|
18591
|
-
agent: this.getOpencodeAgent(options)
|
|
18633
|
+
if (!compactionMode) {
|
|
18634
|
+
invalidateOtherSpawnVariants(sk, {
|
|
18635
|
+
carryConversation: this.config.resumeAcrossModelChanges !== false
|
|
18592
18636
|
});
|
|
18637
|
+
}
|
|
18638
|
+
if (!compactionMode && affinity !== "default") {
|
|
18639
|
+
if (!busyVariant) {
|
|
18640
|
+
recordSessionSpawn(affinity, {
|
|
18641
|
+
model: stripAccountSuffix(failover.modelId),
|
|
18642
|
+
effort: reasoningEffort,
|
|
18643
|
+
account: (this.config.failoverAccounts?.length ?? 0) > 1 ? failover.target ?? sourceAccount : void 0,
|
|
18644
|
+
agent: this.getOpencodeAgent(options)
|
|
18645
|
+
});
|
|
18646
|
+
}
|
|
18593
18647
|
const parked = new Set(getPendingProxyCalls(sk).map((call) => call.toolCallId));
|
|
18594
18648
|
if (startsTurn(options.prompt, parked)) {
|
|
18595
18649
|
markTurnStart(sk, {
|