@khalilgharbaoui/opencode-claude-code-plugin 0.53.0 → 0.53.1

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 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((claim) => claim.agent === agent && claim.prompt === prompt);
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 index = claims.findIndex(
2817
- (claim2) => claim2.parentSessionId === input.parentSessionId && claim2.agent === input.agent && claim2.prompt === input.prompt
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);