zidane 5.4.0 → 5.4.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.
@@ -1,10 +1,10 @@
1
- import { a as multiEdit, c as grep, d as resolveOldString, f as styleReplacementForVia, i as readFile$1, l as glob, n as createSpawnTool, o as listFiles, r as shell, t as writeFile$1, u as edit } from "./tools-DKdyPoUf.js";
1
+ import { a as multiEdit, c as grep, d as resolveOldString, f as styleReplacementForVia, i as readFile$1, l as glob, n as createSpawnTool, o as listFiles, r as shell, t as writeFile$1, u as edit } from "./tools-PQH1Ge4M.js";
2
2
  import { s as errorMessage } from "./errors-Byb0F8B9.js";
3
3
  import { n as toolResultToText } from "./types-IcokUOyC.js";
4
4
  import { r as normalizeMcpServers } from "./mcp-DhmmJfxK.js";
5
5
  import { a as discoverSkills } from "./interpolate-ERgZUxgg.js";
6
6
  import { n as formatTokenUsage } from "./stats-DgOvY7wd.js";
7
- import { n as definePreset, t as composePresets } from "./presets-M8f6lDnW.js";
7
+ import { n as definePreset, t as composePresets } from "./presets-Ck4VusTo.js";
8
8
  import { a as writeFileAtomic, i as anthropic, n as openai, r as cerebras, t as openrouter } from "./providers-x3LZByR5.js";
9
9
  import { spawn } from "node:child_process";
10
10
  import { readdir, stat, writeFile } from "node:fs/promises";
@@ -2623,6 +2623,99 @@ function parseEditOutcomesFromResult(result) {
2623
2623
  return outcomes;
2624
2624
  }
2625
2625
  /**
2626
+ * Strip the first `<edit-outcomes>…</edit-outcomes>` block out of a tool
2627
+ * result body, returning the surrounding text. Used by the
2628
+ * `tool:transform` hook to peel a body-emitted annotation before
2629
+ * re-appending the merged (approval ∪ body) version — otherwise the
2630
+ * result would carry two annotation blocks and
2631
+ * {@link parseEditOutcomesFromResult} would only see the first.
2632
+ *
2633
+ * Anchored on the same `\n<edit-outcomes>\n` / start-of-string newline
2634
+ * shape the parser uses, so prose that incidentally mentions
2635
+ * `<edit-outcomes>` (e.g. a model summarizing its own format) isn't
2636
+ * mistakenly stripped. Trims a single leading `\n\n` separator when
2637
+ * present so successive strips don't leave dangling blank lines.
2638
+ * Idempotent on inputs that don't contain a properly-anchored block.
2639
+ */
2640
+ function stripEditOutcomesAnnotation(text) {
2641
+ const newlineNeedle = `\n${ANNOTATION_OPEN}\n`;
2642
+ const newlineIdx = text.indexOf(newlineNeedle);
2643
+ let openIdx;
2644
+ if (newlineIdx >= 0) openIdx = newlineIdx + 1;
2645
+ else if (text.startsWith(`${ANNOTATION_OPEN}\n`)) openIdx = 0;
2646
+ else return text;
2647
+ const closeIdx = text.indexOf(ANNOTATION_CLOSE, openIdx);
2648
+ if (closeIdx < 0) return text;
2649
+ const blockEnd = closeIdx + 16;
2650
+ const sepStart = openIdx >= 2 && text.slice(openIdx - 2, openIdx) === "\n\n" ? openIdx - 2 : openIdx;
2651
+ return text.slice(0, sepStart) + text.slice(blockEnd);
2652
+ }
2653
+ /**
2654
+ * Merge body-side outcomes (keyed against the approved subset the tool
2655
+ * actually ran on, in subset-position order) into approval-side outcomes
2656
+ * (1:1 with the model's ORIGINAL `edits` list, with `denied` entries for
2657
+ * every hunk the user dropped).
2658
+ *
2659
+ * Algorithm: walk the approval array; every `applied` placeholder
2660
+ * corresponds to one approved hunk that the body ran. Consume body's
2661
+ * outcomes in order against those placeholders. Non-`applied` approval
2662
+ * entries (`denied`, `skipped`) stay untouched — they describe gate-
2663
+ * level decisions the body never saw.
2664
+ *
2665
+ * Pure. Returns a fresh array; never mutates either input.
2666
+ *
2667
+ * Edge cases:
2668
+ * - `body` is empty / shorter than the approved count → remaining
2669
+ * approval `applied` placeholders stay as `applied` (the body ran
2670
+ * happily; absence of a body entry means nothing failed).
2671
+ * - `body` longer than approved count → trailing body entries are
2672
+ * ignored. Shouldn't happen in practice (body sees the rebound
2673
+ * subset), but the guard keeps the merge total-pure.
2674
+ */
2675
+ function mergeApprovalAndBodyOutcomes(approval, body) {
2676
+ if (!body || body.length === 0) return approval.slice();
2677
+ const out = [];
2678
+ let bi = 0;
2679
+ for (const entry of approval) if (entry.kind === "applied" && bi < body.length) {
2680
+ out.push(body[bi]);
2681
+ bi++;
2682
+ } else out.push(entry);
2683
+ return out;
2684
+ }
2685
+ /**
2686
+ * Rewrite a `multi_edit` body header so the totals reflect the model's
2687
+ * ORIGINAL edit list (the merged outcomes count) instead of the subset
2688
+ * the body actually saw after gate rebinding. Without this, a partially
2689
+ * approved call surfaces a misleading `applied 2 of 2 edits` (subset
2690
+ * counts) on the wire even when the original was `applied 2 of 3`.
2691
+ *
2692
+ * Three body-side shapes are handled (matching `multi_edit`'s emit):
2693
+ * 1. `Edited <path>: applied N edits (R replacements).`
2694
+ * 2. `Edited <path>: applied N of M edits (R replacements).`
2695
+ * 3. `multi_edit error: no edits applied to <path> (M attempted).`
2696
+ *
2697
+ * The replacements count is preserved verbatim — it's a body-side stat
2698
+ * the chat layer can't recompute. When the first line doesn't look like
2699
+ * any of the three shapes (e.g. an unrelated error preamble bubbled up),
2700
+ * the text is returned unchanged.
2701
+ */
2702
+ function rewriteMultiEditHeader(text, merged, path) {
2703
+ const newlineIdx = text.indexOf("\n");
2704
+ const firstLine = newlineIdx < 0 ? text : text.slice(0, newlineIdx);
2705
+ const rest = newlineIdx < 0 ? "" : text.slice(newlineIdx);
2706
+ const successMatch = firstLine.match(/^Edited .+: applied \d+(?: of \d+)? edits? \((\d+) replacement/);
2707
+ const isFailedShape = firstLine.startsWith("multi_edit error: no edits applied to ") && firstLine.endsWith(" attempted).");
2708
+ if (!successMatch && !isFailedShape) return text;
2709
+ const replacements = successMatch ? Number.parseInt(successMatch[1], 10) || 0 : 0;
2710
+ const applied = summarizeOutcomes(merged).applied;
2711
+ const total = merged.length;
2712
+ let newHeader;
2713
+ if (applied === total) newHeader = `Edited ${path}: applied ${total} edit${total === 1 ? "" : "s"} (${replacements} replacement${replacements === 1 ? "" : "s"}).`;
2714
+ else if (applied > 0) newHeader = `Edited ${path}: applied ${applied} of ${total} edits (${replacements} replacement${replacements === 1 ? "" : "s"}).`;
2715
+ else newHeader = `multi_edit error: no edits applied to ${path} (${total} attempted).`;
2716
+ return newHeader + rest;
2717
+ }
2718
+ /**
2626
2719
  * Aggregate counts for the transcript's summary badge (`3 applied · 1
2627
2720
  * denied · 1 skipped`). Exported so renderers don't reimplement the
2628
2721
  * tally. Pure / O(n).
@@ -3272,6 +3365,37 @@ function toolCallPreview(name, input) {
3272
3365
  const args = JSON.stringify(input);
3273
3366
  return args && args !== "{}" ? `${name}(${args})` : name;
3274
3367
  }
3368
+ /**
3369
+ * Update the trailing `'tool'` event matching `callId` so its
3370
+ * `edit.outcomes` reflects the canonical merged outcomes the chat
3371
+ * layer's `tool:transform` hook just computed. Without this, the live
3372
+ * diff badges stay frozen at whatever the gate set (approval-side
3373
+ * outcomes) and never reflect body-side failures from `multi_edit`'s
3374
+ * best-effort run — only a session reload re-attaches the merged
3375
+ * outcomes via {@link eventsFromTurns}.
3376
+ *
3377
+ * Walks back-to-front because the matching event is overwhelmingly the
3378
+ * most recent (we're updating right after the body returned). Returns
3379
+ * the same reference when no match is found (or the event already
3380
+ * carries the target outcomes), so React skips the re-render.
3381
+ */
3382
+ function updateToolEventOutcomes(events, callId, outcomes) {
3383
+ for (let i = events.length - 1; i >= 0; i--) {
3384
+ const e = events[i];
3385
+ if (e.kind !== "tool" || e.callId !== callId || !e.edit) continue;
3386
+ if (e.edit.outcomes === outcomes) return events;
3387
+ const next = events.slice();
3388
+ next[i] = {
3389
+ ...e,
3390
+ edit: {
3391
+ ...e.edit,
3392
+ outcomes
3393
+ }
3394
+ };
3395
+ return next;
3396
+ }
3397
+ return events;
3398
+ }
3275
3399
  /** Render tool output as plain text, whether it's a string or structured content. */
3276
3400
  function toolResultText(output) {
3277
3401
  return typeof output === "string" ? output : toolResultToText(output);
@@ -7934,6 +8058,6 @@ function countNeighbors(turnIds, turnId) {
7934
8058
  };
7935
8059
  }
7936
8060
  //#endregion
7937
- export { useMcpAuthDispatch as $, bootTick as $n, TOKEN_DISCIPLINE_DOCTRINE as $r, isVisible as $t, getSafelist as A, KEYBINDING_DEF_BY_ACTION as An, TODOREAD_TOOL as Ar, clampFps as At, supportsOAuth as B, uniqueSkillNamesFromReferences as Bn, pruneTodosByRun as Br, CATPPUCCIN_MOCHA as Bt, resolveSessionExportTarget as C, maskToOutcomeKinds as Cn, BUILTIN_AGENTS as Cr, shortId as Ct, useSafeModeQueue as D, findGitRoot$1 as Dn, accentColor as Dr, SETTINGS_CHOICES as Dt, useSafeModeActions as E, summarizeOutcomes as En, PLAN_AGENT as Er, DEFAULT_SETTINGS as Et, suggestSafelistEntry as F, parseBindingSpec as Fn, createTodoTools as Fr, resolveTheme as Ft, defaultMcpsConfigPaths as G, collectReferences as Gn, COMMUNICATION_DOCTRINE as Gr, ConfigProvider as Gt, filterModelCatalog as H, createFilesCompletionProvider as Hn, setTodosForRun as Hr, DiscoveryProvider as Ht, writeProjects as I, readKeybindings as In, getArchivedTodosForRun as Ir, VAPORWAVE_THEME as It, projectUserPaths as J, useCompletion as Jn, INTERACTION_GUIDANCE as Jr, createStateStore as Jt, discoverProjectMcps as K, findActiveTrigger as Kn, DOING_TASKS_DOCTRINE as Kr, useConfig as Kt, splitPromptSegments as L, stripJsonComments as Ln, getTodosForRun as Lr, CATPPUCCIN_FRAPPE as Lt, matchesSafelistEntry as M, keybindingsPath as Mn, TODOWRITE_TOOL as Mr, BUILTIN_THEMES as Mt, projectsFilePath as N, matchesBinding as Nn, TODO_STATUS_GLYPHS as Nr, DEFAULT_THEME as Nt, IMPLICITLY_SAFE_TOOLS as O, DEFAULT_KEYBINDINGS as On, resolveAgentId as Or, SETTINGS_TOGGLES as Ot, readProjects as P, mergeKeybindings as Pn, TODO_WRITE_COUNTS_METADATA_KEY as Pr, resolveChipColor as Pt, McpAuthProvider as Q, bootProfileEnabled as Qn, SUBAGENT_GUIDANCE as Qr, isTurnHighlighted as Qt, formatPathForCwd as R, SKILLS_TRIGGER as Rn, isTodoTool as Rr, CATPPUCCIN_LATTE as Rt, renderSession as S, buildEditOutcomesAnnotation as Sn, BUILD_AGENT as Sr, fmtTokens as St, SafeModeProvider as T, resolveApprovalForPayload as Tn, DEFAULT_PERSIST_EXCLUDE_TOOLS as Tr, useEnabledToggleSet as Tt, indexOfEntry as U, uniqueFilesFromReferences as Un, useActiveTodos as Ur, useDiscovery as Ut, buildModelCatalog as V, FILES_TRIGGER as Vn, selectActiveTodos as Vr, createDiscoverySlot as Vt, buildMcpServers as W, applyInsert as Wn, ACTIONS_WITH_CARE_DOCTRINE as Wr, useDiscoveryOptional as Wt, mcpCredentialsPath as X, buildLinearRamp as Xn, PLAN_MODE_DOCTRINE as Xr, eventsFromTurns as Xt, createFileMcpCredentialStore as Y, blendHsl as Yn, INTERACTION_GUIDANCE_NO_PROMPTS as Yr, deriveSessionTitle as Yt, patchMcpCredential as Z, tryOpenBrowser as Zn, PLAN_MODE_DOCTRINE_NO_PROMPTS as Zr, isEditErrorResult as Zt, turnContextSize as _, extractEditPayload as _n, modelSupportsReasoning as _r, truncateTrailing as _t, computeTurnAnchors as a, selectableTurnIds as an, readProviderCredential as ar, InteractionsProvider as at, defaultSkillScanPaths as b, splitLines as bn, openrouterDescriptor as br, ageString as bt, formatToolCall as c, titleFromTurns as cn, writeCredentials as cr, createInteractionTools as ct, useSelectStyle as d, turnSelectionOwnership as dn, anthropicDescriptor as dr, pendingInteractionsFromTurns as dt, buildBuildSystem as ei, lastContextSizeFromTurns as en, shouldAutoCompact as er, useMcpAuthState as et, useSurfaces as f, applyEditPayload as fn, cerebrasDescriptor as fr, serializeInteractionResponse as ft, finalizeStreamingMarkdownForOwner as g, computeLineDiff as gn, getModelInfo as gr, hintsLength as gt, finalizeStreamingMarkdown as h, computeInlineDiff as hn, getContextWindow as hr, clipHintsToWidth as ht, turnAsText as i, saveState as in, readCredentials as ir, ASK_USER_TOOL as it, isOnSafelist as j, ensureKeybindingsFile as jn, TODOS_METADATA_KEY as jr, useSettings as jt, addToSafelist as k, KEYBINDING_DEFS as kn, singleAgentRegistry as kr, SettingsProvider as kt, ThemeProvider as l, toolCallPreview as ln, BUILTIN_PROVIDERS as lr, isInteractionTool as lt, useTheme as m, buildUnifiedDiff as mn, effectiveContextWindow as mr, useInteractionsQueue as mt, deleteTurnSafely as n, envSection as ni, loadState as nn, applyApiKeyEnv as nr, reduceMcpAuth as nt, TOOL_DISPLAY as o, stripSpawnTokensLine as on, removeProviderCredential as or, PRESENT_PLAN_TOOL as ot, useSyntaxStyles as p, buildContextualDiff as pn, credKeyOf as pr, useInteractionsActions as pt, parseMcpsFile as q, mergeReferences as qn, IDENTITY_PREFIX as qr, resolveConfig as qt, truncateTurnsAt as r, marginTopFor as rn, credentialsPath as rr, splitMarkdownCodeBlocks as rt, displayNameFor as s, sumRunCosts as sn, setProviderCredential as sr, buildResumedToolResultsTurn as st, countNeighbors as t, buildPlanSystem as ti, listSessionMeta as tn, detectAuth as tr, getMcpAuthStatus as tt, useColors as u, toolResultText as un, OUTPUT_RESERVE_TOKENS as ur, makeRequestInteraction as ut, useStreamBuffer as v, filetypeFromPath as vn, modelsForDescriptor as vr, cleanTitle as vt, writeSessionExport as w, parseEditOutcomesFromResult as wn, DEFAULT_AGENT_ID as wr, listProjectFiles as wt, discoverProjectSkills as x, tokenize as xn, piIdOf as xr, compactPath as xt, buildSkillsConfig as y, previewEditPayload as yn, openaiDescriptor as yr, generateSessionTitle as yt, runOAuthLogin as z, createSkillsCompletionProvider as zn, pickActiveRunId as zr, CATPPUCCIN_MACCHIATO as zt };
8061
+ export { useMcpAuthDispatch as $, blendHsl as $n, INTERACTION_GUIDANCE_NO_PROMPTS as $r, isVisible as $t, getSafelist as A, summarizeOutcomes as An, PLAN_AGENT as Ar, clampFps as At, supportsOAuth as B, readKeybindings as Bn, getArchivedTodosForRun as Br, CATPPUCCIN_MOCHA as Bt, resolveSessionExportTarget as C, buildEditOutcomesAnnotation as Cn, openaiDescriptor as Cr, shortId as Ct, useSafeModeQueue as D, resolveApprovalForPayload as Dn, BUILTIN_AGENTS as Dr, SETTINGS_CHOICES as Dt, useSafeModeActions as E, parseEditOutcomesFromResult as En, BUILD_AGENT as Er, DEFAULT_SETTINGS as Et, suggestSafelistEntry as F, ensureKeybindingsFile as Fn, TODOS_METADATA_KEY as Fr, resolveTheme as Ft, defaultMcpsConfigPaths as G, FILES_TRIGGER as Gn, selectActiveTodos as Gr, ConfigProvider as Gt, filterModelCatalog as H, SKILLS_TRIGGER as Hn, isTodoTool as Hr, DiscoveryProvider as Ht, writeProjects as I, keybindingsPath as In, TODOWRITE_TOOL as Ir, VAPORWAVE_THEME as It, projectUserPaths as J, applyInsert as Jn, ACTIONS_WITH_CARE_DOCTRINE as Jr, createStateStore as Jt, discoverProjectMcps as K, createFilesCompletionProvider as Kn, setTodosForRun as Kr, useConfig as Kt, splitPromptSegments as L, matchesBinding as Ln, TODO_STATUS_GLYPHS as Lr, CATPPUCCIN_FRAPPE as Lt, matchesSafelistEntry as M, DEFAULT_KEYBINDINGS as Mn, resolveAgentId as Mr, BUILTIN_THEMES as Mt, projectsFilePath as N, KEYBINDING_DEFS as Nn, singleAgentRegistry as Nr, DEFAULT_THEME as Nt, IMPLICITLY_SAFE_TOOLS as O, rewriteMultiEditHeader as On, DEFAULT_AGENT_ID as Or, SETTINGS_TOGGLES as Ot, readProjects as P, KEYBINDING_DEF_BY_ACTION as Pn, TODOREAD_TOOL as Pr, resolveChipColor as Pt, McpAuthProvider as Q, useCompletion as Qn, INTERACTION_GUIDANCE as Qr, isTurnHighlighted as Qt, formatPathForCwd as R, mergeKeybindings as Rn, TODO_WRITE_COUNTS_METADATA_KEY as Rr, CATPPUCCIN_LATTE as Rt, renderSession as S, tokenize as Sn, modelsForDescriptor as Sr, fmtTokens as St, SafeModeProvider as T, mergeApprovalAndBodyOutcomes as Tn, piIdOf as Tr, useEnabledToggleSet as Tt, indexOfEntry as U, createSkillsCompletionProvider as Un, pickActiveRunId as Ur, useDiscovery as Ut, buildModelCatalog as V, stripJsonComments as Vn, getTodosForRun as Vr, createDiscoverySlot as Vt, buildMcpServers as W, uniqueSkillNamesFromReferences as Wn, pruneTodosByRun as Wr, useDiscoveryOptional as Wt, mcpCredentialsPath as X, findActiveTrigger as Xn, DOING_TASKS_DOCTRINE as Xr, eventsFromTurns as Xt, createFileMcpCredentialStore as Y, collectReferences as Yn, COMMUNICATION_DOCTRINE as Yr, deriveSessionTitle as Yt, patchMcpCredential as Z, mergeReferences as Zn, IDENTITY_PREFIX as Zr, isEditErrorResult as Zt, turnContextSize as _, computeLineDiff as _n, credKeyOf as _r, truncateTrailing as _t, computeTurnAnchors as a, buildPlanSystem as ai, selectableTurnIds as an, detectAuth as ar, InteractionsProvider as at, defaultSkillScanPaths as b, previewEditPayload as bn, getModelInfo as br, ageString as bt, formatToolCall as c, titleFromTurns as cn, readCredentials as cr, createInteractionTools as ct, useSelectStyle as d, turnSelectionOwnership as dn, setProviderCredential as dr, pendingInteractionsFromTurns as dt, PLAN_MODE_DOCTRINE as ei, lastContextSizeFromTurns as en, buildLinearRamp as er, useMcpAuthState as et, useSurfaces as f, updateToolEventOutcomes as fn, writeCredentials as fr, serializeInteractionResponse as ft, finalizeStreamingMarkdownForOwner as g, computeInlineDiff as gn, cerebrasDescriptor as gr, hintsLength as gt, finalizeStreamingMarkdown as h, buildUnifiedDiff as hn, anthropicDescriptor as hr, clipHintsToWidth as ht, turnAsText as i, buildBuildSystem as ii, saveState as in, shouldAutoCompact as ir, ASK_USER_TOOL as it, isOnSafelist as j, findGitRoot$1 as jn, accentColor as jr, useSettings as jt, addToSafelist as k, stripEditOutcomesAnnotation as kn, DEFAULT_PERSIST_EXCLUDE_TOOLS as kr, SettingsProvider as kt, ThemeProvider as l, toolCallPreview as ln, readProviderCredential as lr, isInteractionTool as lt, useTheme as m, buildContextualDiff as mn, OUTPUT_RESERVE_TOKENS as mr, useInteractionsQueue as mt, deleteTurnSafely as n, SUBAGENT_GUIDANCE as ni, loadState as nn, bootProfileEnabled as nr, reduceMcpAuth as nt, TOOL_DISPLAY as o, envSection as oi, stripSpawnTokensLine as on, applyApiKeyEnv as or, PRESENT_PLAN_TOOL as ot, useSyntaxStyles as p, applyEditPayload as pn, BUILTIN_PROVIDERS as pr, useInteractionsActions as pt, parseMcpsFile as q, uniqueFilesFromReferences as qn, useActiveTodos as qr, resolveConfig as qt, truncateTurnsAt as r, TOKEN_DISCIPLINE_DOCTRINE as ri, marginTopFor as rn, bootTick as rr, splitMarkdownCodeBlocks as rt, displayNameFor as s, sumRunCosts as sn, credentialsPath as sr, buildResumedToolResultsTurn as st, countNeighbors as t, PLAN_MODE_DOCTRINE_NO_PROMPTS as ti, listSessionMeta as tn, tryOpenBrowser as tr, getMcpAuthStatus as tt, useColors as u, toolResultText as un, removeProviderCredential as ur, makeRequestInteraction as ut, useStreamBuffer as v, extractEditPayload as vn, effectiveContextWindow as vr, cleanTitle as vt, writeSessionExport as w, maskToOutcomeKinds as wn, openrouterDescriptor as wr, listProjectFiles as wt, discoverProjectSkills as x, splitLines as xn, modelSupportsReasoning as xr, compactPath as xt, buildSkillsConfig as y, filetypeFromPath as yn, getContextWindow as yr, generateSessionTitle as yt, runOAuthLogin as z, parseBindingSpec as zn, createTodoTools as zr, CATPPUCCIN_MACCHIATO as zt };
7938
8062
 
7939
- //# sourceMappingURL=turn-operations-DDokWR8p.js.map
8063
+ //# sourceMappingURL=turn-operations-Bqs4YbbH.js.map