@vibgrate/cli 2026.801.1 → 2026.803.3

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.
Files changed (110) hide show
  1. package/dist/agent-JTA4YWMQ.js +24 -0
  2. package/dist/{agent-4DAECASW.js.map → agent-JTA4YWMQ.js.map} +1 -1
  3. package/dist/baseline-2V7PKA7Q.js +9 -0
  4. package/dist/{baseline-4BDH4F2W.js.map → baseline-2V7PKA7Q.js.map} +1 -1
  5. package/dist/{chunk-76TDXGGF.js → chunk-3Q3ZXJZP.js} +218 -51
  6. package/dist/chunk-3Q3ZXJZP.js.map +1 -0
  7. package/dist/{chunk-G7W4MFPZ.js → chunk-4ACXDVON.js} +4 -4
  8. package/dist/{chunk-G7W4MFPZ.js.map → chunk-4ACXDVON.js.map} +1 -1
  9. package/dist/{chunk-E6H2F2XF.js → chunk-6DFV4WCQ.js} +3 -3
  10. package/dist/{chunk-E6H2F2XF.js.map → chunk-6DFV4WCQ.js.map} +1 -1
  11. package/dist/{chunk-FF5ZQ6KI.js → chunk-6JP7HGIF.js} +4 -4
  12. package/dist/{chunk-FF5ZQ6KI.js.map → chunk-6JP7HGIF.js.map} +1 -1
  13. package/dist/chunk-7KNFG44U.js +6 -0
  14. package/dist/{chunk-TGDHOAXX.js.map → chunk-7KNFG44U.js.map} +1 -1
  15. package/dist/{chunk-T6DRYOMT.js → chunk-CPLG4GFB.js} +4 -4
  16. package/dist/{chunk-T6DRYOMT.js.map → chunk-CPLG4GFB.js.map} +1 -1
  17. package/dist/{chunk-SDG242R4.js → chunk-HC44772H.js} +132 -365
  18. package/dist/chunk-HC44772H.js.map +1 -0
  19. package/dist/{chunk-MPP4S4OE.js → chunk-K6Q6HTFD.js} +32 -11
  20. package/dist/chunk-K6Q6HTFD.js.map +1 -0
  21. package/dist/{chunk-7G5S5KZN.js → chunk-KUZLILN3.js} +16 -3
  22. package/dist/chunk-KUZLILN3.js.map +1 -0
  23. package/dist/{chunk-XEJJGDGX.js → chunk-KYX2YCXT.js} +134 -9
  24. package/dist/chunk-KYX2YCXT.js.map +1 -0
  25. package/dist/{chunk-V2QK3IUY.js → chunk-L5PUNO3T.js} +4 -4
  26. package/dist/{chunk-V2QK3IUY.js.map → chunk-L5PUNO3T.js.map} +1 -1
  27. package/dist/{chunk-7PVCHLR2.js → chunk-M452MRWI.js} +109 -10
  28. package/dist/chunk-M452MRWI.js.map +1 -0
  29. package/dist/{chunk-WIDZ5IE7.js → chunk-M7773OUN.js} +14 -7
  30. package/dist/chunk-M7773OUN.js.map +1 -0
  31. package/dist/{chunk-XRN7DQGR.js → chunk-NJFQCDGA.js} +3 -3
  32. package/dist/{chunk-XRN7DQGR.js.map → chunk-NJFQCDGA.js.map} +1 -1
  33. package/dist/{chunk-BNEHDLVZ.js → chunk-NSWEJPLV.js} +129 -20
  34. package/dist/chunk-NSWEJPLV.js.map +1 -0
  35. package/dist/{chunk-JLWI2JGA.js → chunk-NUZM7UOR.js} +117 -6
  36. package/dist/chunk-NUZM7UOR.js.map +1 -0
  37. package/dist/{chunk-B3OMGYZZ.js → chunk-PXM3VZYR.js} +4 -4
  38. package/dist/{chunk-B3OMGYZZ.js.map → chunk-PXM3VZYR.js.map} +1 -1
  39. package/dist/chunk-QMME6TB4.js +457 -0
  40. package/dist/chunk-QMME6TB4.js.map +1 -0
  41. package/dist/{chunk-G25STLE7.js → chunk-SJFBXCII.js} +30 -3
  42. package/dist/chunk-SJFBXCII.js.map +1 -0
  43. package/dist/{chunk-A43I2AJ4.js → chunk-TM5XQY3L.js} +3 -3
  44. package/dist/{chunk-A43I2AJ4.js.map → chunk-TM5XQY3L.js.map} +1 -1
  45. package/dist/{chunk-KL65SSR7.js → chunk-TNADGCOX.js} +323 -152
  46. package/dist/chunk-TNADGCOX.js.map +1 -0
  47. package/dist/{chunk-V3X3DBZL.js → chunk-UXR7FBE3.js} +6 -6
  48. package/dist/{chunk-V3X3DBZL.js.map → chunk-UXR7FBE3.js.map} +1 -1
  49. package/dist/{chunk-IPICO2RV.js → chunk-VIWZ4QT7.js} +14 -3
  50. package/dist/chunk-VIWZ4QT7.js.map +1 -0
  51. package/dist/{chunk-IRCYOTRG.js → chunk-WGPS3NZQ.js} +240 -13
  52. package/dist/chunk-WGPS3NZQ.js.map +1 -0
  53. package/dist/{chunk-I6RBAIS3.js → chunk-XK5LKOBF.js} +4 -4
  54. package/dist/{chunk-I6RBAIS3.js.map → chunk-XK5LKOBF.js.map} +1 -1
  55. package/dist/cli.js +796 -359
  56. package/dist/cli.js.map +1 -1
  57. package/dist/ensure-map-TAVYMPEG.js +29 -0
  58. package/dist/{ensure-map-SMWHKOUY.js.map → ensure-map-TAVYMPEG.js.map} +1 -1
  59. package/dist/{graph-backend-I4I72J4W.js → graph-backend-WF4LGBGD.js} +5 -5
  60. package/dist/{graph-backend-I4I72J4W.js.map → graph-backend-WF4LGBGD.js.map} +1 -1
  61. package/dist/index.d.ts +143 -7
  62. package/dist/index.js +17 -16
  63. package/dist/index.js.map +1 -1
  64. package/dist/{interactive-TMQR6TXM.js → interactive-6PN237LX.js} +49 -32
  65. package/dist/interactive-6PN237LX.js.map +1 -0
  66. package/dist/load-T2FOJUPI.js +10 -0
  67. package/dist/{load-E3OTM7BS.js.map → load-T2FOJUPI.js.map} +1 -1
  68. package/dist/model-manager-GJ2YSTSK.js +1 -1
  69. package/dist/{run-outcome-QWLNBASF.js → run-outcome-AMIKAASL.js} +6 -6
  70. package/dist/{run-outcome-QWLNBASF.js.map → run-outcome-AMIKAASL.js.map} +1 -1
  71. package/dist/runtime-session-QAVOPSSH.js +20 -0
  72. package/dist/{runtime-session-UQ7UVAPL.js.map → runtime-session-QAVOPSSH.js.map} +1 -1
  73. package/dist/session-SCHQQTHN.js +15 -0
  74. package/dist/{session-MG6BJVAG.js.map → session-SCHQQTHN.js.map} +1 -1
  75. package/dist/session-store-F7NX7SZN.js +4 -0
  76. package/dist/{session-store-SQECEXUU.js.map → session-store-F7NX7SZN.js.map} +1 -1
  77. package/dist/{stream-json-GM44SP7L.js → stream-json-A6K2MONY.js} +48 -16
  78. package/dist/stream-json-A6K2MONY.js.map +1 -0
  79. package/dist/{vg-mcp-bridge-3WFC7LGE.js → vg-mcp-bridge-3TSFOL4V.js} +13 -11
  80. package/dist/vg-mcp-bridge-3TSFOL4V.js.map +1 -0
  81. package/dist/{vgd-ZUSBEVUL.js → vgd-B67JCNJP.js} +9 -9
  82. package/dist/vgd-B67JCNJP.js.map +1 -0
  83. package/package.json +1 -1
  84. package/dist/agent-4DAECASW.js +0 -22
  85. package/dist/baseline-4BDH4F2W.js +0 -9
  86. package/dist/chunk-76TDXGGF.js.map +0 -1
  87. package/dist/chunk-7G5S5KZN.js.map +0 -1
  88. package/dist/chunk-7PVCHLR2.js.map +0 -1
  89. package/dist/chunk-BNEHDLVZ.js.map +0 -1
  90. package/dist/chunk-G25STLE7.js.map +0 -1
  91. package/dist/chunk-IPICO2RV.js.map +0 -1
  92. package/dist/chunk-IRCYOTRG.js.map +0 -1
  93. package/dist/chunk-JLWI2JGA.js.map +0 -1
  94. package/dist/chunk-KL65SSR7.js.map +0 -1
  95. package/dist/chunk-MPP4S4OE.js.map +0 -1
  96. package/dist/chunk-SDG242R4.js.map +0 -1
  97. package/dist/chunk-TGDHOAXX.js +0 -6
  98. package/dist/chunk-WIDZ5IE7.js.map +0 -1
  99. package/dist/chunk-XEJJGDGX.js.map +0 -1
  100. package/dist/chunk-ZKNB4YH4.js +0 -102
  101. package/dist/chunk-ZKNB4YH4.js.map +0 -1
  102. package/dist/ensure-map-SMWHKOUY.js +0 -28
  103. package/dist/interactive-TMQR6TXM.js.map +0 -1
  104. package/dist/load-E3OTM7BS.js +0 -10
  105. package/dist/runtime-session-UQ7UVAPL.js +0 -20
  106. package/dist/session-MG6BJVAG.js +0 -13
  107. package/dist/session-store-SQECEXUU.js +0 -4
  108. package/dist/stream-json-GM44SP7L.js.map +0 -1
  109. package/dist/vg-mcp-bridge-3WFC7LGE.js.map +0 -1
  110. package/dist/vgd-ZUSBEVUL.js.map +0 -1
@@ -1,13 +1,14 @@
1
1
  import { secretEgressRefusal, isSecretPath, secretRefusal, redactText } from './chunk-543E6WDJ.js';
2
- import { buildAgentMessages, redactSecrets, unifiedDiff, applyEdit } from './chunk-G25STLE7.js';
3
- import { localGraphBackend } from './chunk-A43I2AJ4.js';
2
+ import { buildAgentMessages, redactSecrets, unifiedDiff, applyEdit } from './chunk-SJFBXCII.js';
3
+ import { localGraphBackend } from './chunk-TM5XQY3L.js';
4
4
  import { buildIdentifierTrieFromGraph, KvBlockRegistry, graphDraftCandidates, extractIdentifiers, scanIdentifiersAgainstTrie } from './chunk-5HYCB55P.js';
5
- import { summarizeCapsule, CAPSULE_RANKING_VERSION, buildCodeContext, buildTaskCapsule, capsuleToCodeContext, recordCliCall, CLI_TOOL_ALIASES } from './chunk-MPP4S4OE.js';
6
- import { resolve } from './chunk-IPICO2RV.js';
7
- import { searchSymbols, resolveLib, loadCatalog, readDoc, localPackageDocs, resolveVersion } from './chunk-I6RBAIS3.js';
5
+ import { summarizeCapsule, CAPSULE_RANKING_VERSION, buildCodeContext, buildTaskCapsule, capsuleToCodeContext, recordCliCall, CLI_TOOL_ALIASES } from './chunk-K6Q6HTFD.js';
6
+ import { resolve } from './chunk-VIWZ4QT7.js';
7
+ import { searchSymbols, resolveLib, loadCatalog, readDoc, localPackageDocs, resolveVersion } from './chunk-XK5LKOBF.js';
8
8
  import { resolveOne } from './chunk-J7LKEB2R.js';
9
- import { isLocateOnlyInstruction, extractLiteralNeedles, impactOf } from './chunk-SDG242R4.js';
9
+ import { isLocateOnlyInstruction, extractLiteralNeedles, impactOf } from './chunk-HC44772H.js';
10
10
  import { parseSource, langForExtension } from './chunk-UTNNGKKX.js';
11
+ import { analyzeQuestion, loadTopicTags } from './chunk-3Q3ZXJZP.js';
11
12
  import { repositoryIdFromRoot } from './chunk-BWPBB45M.js';
12
13
  import { hashString, canonicalize } from './chunk-JFGYT6BI.js';
13
14
  import { spawnSync } from 'child_process';
@@ -1992,12 +1993,124 @@ function sanitizeAgentDisplayText(text) {
1992
1993
  return t;
1993
1994
  }
1994
1995
 
1996
+ // src/code/model-capabilities.ts
1997
+ var VISION_YES = [
1998
+ /gpt-4o/,
1999
+ /gpt-4\.1/,
2000
+ /gpt-5/,
2001
+ /^o[34]/,
2002
+ // OpenAI multimodal families
2003
+ /claude/,
2004
+ // Claude 3+ are all vision-capable
2005
+ /gemini/,
2006
+ /gemma-?3/,
2007
+ // Google
2008
+ /llava/,
2009
+ /vision/,
2010
+ /-vl\b/,
2011
+ /-vl-/,
2012
+ /qwen.*vl/,
2013
+ // open vision families / naming markers
2014
+ /pixtral/,
2015
+ /moondream/,
2016
+ /minicpm-v/,
2017
+ /bakllava/,
2018
+ /cogvlm/,
2019
+ /internvl/,
2020
+ /phi-?4-multimodal/
2021
+ ];
2022
+ var VISION_NO = [
2023
+ /deepseek/,
2024
+ // DeepSeek chat/coder/r1 lines are text-only
2025
+ /codestral/,
2026
+ /starcoder/,
2027
+ /codegemma/,
2028
+ /codellama/,
2029
+ /code-?llama/,
2030
+ /qwen.*coder/,
2031
+ /devstral/,
2032
+ /^(mistral|mixtral)(?!.*(pixtral|medium-3|small-3\.1))/,
2033
+ // classic Mistral text models
2034
+ /phi-?[123]\b/,
2035
+ /granite(?!.*vision)/,
2036
+ /command-r(?!.*vision)/,
2037
+ /stablelm/,
2038
+ /tinyllama/,
2039
+ /smollm(?!.*v)/,
2040
+ /^llama-?[12]/,
2041
+ /llama-?3(\.[01])?(?!.*vision)/
2042
+ // Llama ≤3.1 text-only; 3.2-vision matches VISION_YES first
2043
+ ];
2044
+ var TOOLS_YES = [
2045
+ /gpt-4/,
2046
+ /gpt-5/,
2047
+ /^o[134]/,
2048
+ /claude/,
2049
+ /gemini/,
2050
+ /grok/,
2051
+ /deepseek-(chat|v3)/,
2052
+ /kimi/,
2053
+ /qwen-?[23]/,
2054
+ /qwen.*(coder|instruct)/,
2055
+ /llama-?3\.[13]/,
2056
+ /llama-?4/,
2057
+ /mistral-(small|medium|large)/,
2058
+ /devstral/,
2059
+ /command-r/,
2060
+ /glm-?4/,
2061
+ /minimax/,
2062
+ /hermes/
2063
+ // Hermes models are tool-call trained
2064
+ ];
2065
+ var TOOLS_NO = [
2066
+ /phi-?[12]\b/,
2067
+ /tinyllama/,
2068
+ /stablelm/,
2069
+ /smollm/,
2070
+ /starcoder/,
2071
+ /codellama/,
2072
+ /codegemma/,
2073
+ /gemma\b/,
2074
+ /gemma-?[12]\b/,
2075
+ // Gemma 1/2 have no tool support; Gemma 3 is unreliable but attempts it
2076
+ /moondream/,
2077
+ /llava/,
2078
+ // pure-vision chat models
2079
+ /-base\b/,
2080
+ /-base-/
2081
+ // base (non-instruct) checkpoints never tool-call
2082
+ ];
2083
+ function match(rules, id) {
2084
+ return rules.some((r) => r.test(id));
2085
+ }
2086
+ function lookupModelCapabilities(model, overrides) {
2087
+ const id = (model ?? "").trim().toLowerCase();
2088
+ const result = { nativeTools: null, vision: null };
2089
+ if (!id) return result;
2090
+ if (match(VISION_YES, id)) result.vision = true;
2091
+ else if (match(VISION_NO, id)) result.vision = false;
2092
+ if (match(TOOLS_NO, id)) result.nativeTools = false;
2093
+ else if (match(TOOLS_YES, id)) result.nativeTools = true;
2094
+ if (overrides) {
2095
+ for (const [key, caps] of Object.entries(overrides)) {
2096
+ const k = key.trim().toLowerCase();
2097
+ if (!k) continue;
2098
+ if (id === k || id.includes(k)) {
2099
+ if (caps.nativeTools !== void 0) result.nativeTools = caps.nativeTools;
2100
+ if (caps.vision !== void 0) result.vision = caps.vision;
2101
+ }
2102
+ }
2103
+ }
2104
+ return result;
2105
+ }
2106
+
1995
2107
  // src/code/agent.ts
1996
2108
  var DEFAULT_MAX_STEPS = 24;
1997
2109
  var DEFAULT_CONTEXT_BUDGET = 16e3;
1998
2110
  var KEEP_ROUNDS = 8;
1999
2111
  var NUDGE_AT = 3;
2000
2112
  var STOP_AT = 5;
2113
+ var EMPTY_REPLY_RETRIES = 2;
2001
2114
  async function runAgent(options) {
2002
2115
  const { root, instruction, providers } = options;
2003
2116
  let graph = options.graph;
@@ -2038,11 +2151,27 @@ async function runAgent(options) {
2038
2151
  const advancedMode = options.advancedMode ?? true;
2039
2152
  const discoveryGate = createDiscoveryGateState();
2040
2153
  const allTools = [...AGENT_TOOLS, ...options.externalTools?.specs ?? []];
2041
- const built = buildAgentContext(graph, instruction, { ...options, fsImpl, budget });
2154
+ const relevance = await analyzeQuestion(instruction);
2155
+ const topicTags = relevance ? await loadTopicTags(graph, options.root) : null;
2156
+ const built = buildAgentContext(graph, instruction, { ...options, fsImpl, budget, relevance, topicTags });
2042
2157
  const context = built.context;
2043
2158
  let capsule = built.capsule;
2044
2159
  const useLadder = options.verifyLadder ?? !!capsule;
2045
2160
  const messages = buildAgentMessages(context);
2161
+ if (options.images?.length) {
2162
+ const caps = lookupModelCapabilities(providers[0]?.model);
2163
+ if (caps.vision === false) {
2164
+ onEvent({
2165
+ type: "notice",
2166
+ text: `${providers[0]?.model ?? "the selected model"} cannot view images \u2014 attached image(s) are referenced by name/path only. Pick a vision-capable model to have it read the pixels.`
2167
+ });
2168
+ } else {
2169
+ const last = messages[messages.length - 1];
2170
+ if (last?.role === "user") {
2171
+ messages[messages.length - 1] = { ...last, images: options.images };
2172
+ }
2173
+ }
2174
+ }
2046
2175
  if (options.projectRules) {
2047
2176
  messages.push({ role: "user", content: options.projectRules });
2048
2177
  }
@@ -2055,6 +2184,7 @@ async function runAgent(options) {
2055
2184
  const spans = buildSpanIndex(graph);
2056
2185
  const changes = [];
2057
2186
  const repeats = /* @__PURE__ */ new Map();
2187
+ let emptyReplies = 0;
2058
2188
  let recordedSearch = false;
2059
2189
  let commandCount = 0;
2060
2190
  let verifyRounds = verifyConfig?.maxRounds ?? 2;
@@ -2126,6 +2256,7 @@ async function runAgent(options) {
2126
2256
  return "file" in action && action.file ? [action.file] : [];
2127
2257
  };
2128
2258
  const approveAndCheckpoint = async (action) => {
2259
+ if (options.plan) return false;
2129
2260
  const approved = await options.approve(action);
2130
2261
  if (!approved || !options.checkpoint) return approved;
2131
2262
  const files = actionFiles(action);
@@ -2174,6 +2305,9 @@ async function runAgent(options) {
2174
2305
  const nextCapsule = buildTaskCapsule(session.graph, instruction, {
2175
2306
  budget,
2176
2307
  files: options.files,
2308
+ relevance,
2309
+ topicTags,
2310
+ priorInstruction: options.priorInstruction,
2177
2311
  readFile: (rel) => fsImpl.read(rel),
2178
2312
  repositoryId: repositoryIdFromRoot(root),
2179
2313
  provenance: {
@@ -2353,7 +2487,12 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
2353
2487
  }
2354
2488
  currentStep = step;
2355
2489
  onEvent({ type: "step", n: step });
2356
- const compacted = compact(messages, contextBudget, changes);
2490
+ const compacted = options.llmCompaction ? await compactWithModel(
2491
+ messages,
2492
+ contextBudget,
2493
+ changes,
2494
+ (transcript) => summarizeForCompaction(providers, transcript)
2495
+ ) : compact(messages, contextBudget, changes);
2357
2496
  if (compacted.droppedRounds > 0) {
2358
2497
  messages.length = 0;
2359
2498
  messages.push(...compacted.messages);
@@ -2405,8 +2544,21 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
2405
2544
  if (isUserFacingProse(displayText)) {
2406
2545
  return finish("finished", displayText, step);
2407
2546
  }
2408
- return finish("no-tools", displayText || "done", step);
2547
+ emptyReplies++;
2548
+ if (emptyReplies <= EMPTY_REPLY_RETRIES && step < maxSteps) {
2549
+ messages.push({
2550
+ role: "user",
2551
+ content: displayText.trim().length === 0 ? "Your last reply was empty. Either call a tool to keep working, or answer the task in plain Markdown now." : "Your last reply was neither a tool call nor a readable answer. Do not emit raw JSON or templates \u2014 call a tool, or answer the task in plain Markdown."
2552
+ });
2553
+ continue;
2554
+ }
2555
+ return finish(
2556
+ "no-tools",
2557
+ displayText || `The model (${providerInfo.model}) returned no usable output after ${emptyReplies} attempt(s). Try a stronger model, or re-ask with a more specific instruction.`,
2558
+ step
2559
+ );
2409
2560
  }
2561
+ emptyReplies = 0;
2410
2562
  messages.push({ role: "assistant", content: result.text, toolCalls });
2411
2563
  for (const call of toolCalls) {
2412
2564
  onEvent({ type: "tool-call", name: call.name, args: call.arguments });
@@ -2510,15 +2662,90 @@ function compact(messages, budget, changes) {
2510
2662
  };
2511
2663
  return { messages: [...head, note, ...kept], droppedRounds: dropped.length };
2512
2664
  }
2665
+ var COMPACTION_PROMPT = [
2666
+ "Summarize the following coding-agent transcript into a compact checkpoint the agent can resume from.",
2667
+ "Cover, as short labelled lines: Objective; Key findings/decisions; Files read or changed (with paths);",
2668
+ "Current state; Next steps. Under 250 words. Plain text only \u2014 no code blocks, no tool syntax."
2669
+ ].join(" ");
2670
+ function renderDroppedRounds(rounds) {
2671
+ const lines = [];
2672
+ for (const round2 of rounds) {
2673
+ for (const m of round2) {
2674
+ if (m.role === "assistant") {
2675
+ if (m.content?.trim()) lines.push(`assistant: ${m.content.trim().slice(0, 400)}`);
2676
+ for (const t of m.toolCalls ?? []) {
2677
+ lines.push(`tool-call: ${t.name}(${JSON.stringify(t.arguments).slice(0, 200)})`);
2678
+ }
2679
+ } else if (m.role === "tool") {
2680
+ lines.push(`tool-result[${m.name}]: ${m.content.split("\n")[0].slice(0, 300)}`);
2681
+ } else if (m.role === "user") {
2682
+ lines.push(`user: ${m.content.trim().slice(0, 300)}`);
2683
+ }
2684
+ }
2685
+ }
2686
+ return lines.join("\n").slice(0, 24e3);
2687
+ }
2688
+ async function summarizeForCompaction(providers, transcript) {
2689
+ const provider = providers[0];
2690
+ if (!provider) return null;
2691
+ const r = await provider.chat(
2692
+ [
2693
+ { role: "system", content: COMPACTION_PROMPT },
2694
+ { role: "user", content: transcript }
2695
+ ],
2696
+ { temperature: 0, maxTokens: 512, timeoutMs: 6e4 }
2697
+ );
2698
+ return (r.text ?? "").trim() || null;
2699
+ }
2700
+ function isUsableSummary(text) {
2701
+ const t = (text ?? "").trim();
2702
+ return !!t && !t.startsWith("{") && !t.includes("<tool_call>");
2703
+ }
2704
+ async function compactWithModel(messages, budget, changes, summarize) {
2705
+ const deterministic = compact(messages, budget, changes);
2706
+ if (deterministic.droppedRounds === 0) return deterministic;
2707
+ const head = messages.slice(0, 3);
2708
+ const body = messages.slice(3);
2709
+ const rounds = [];
2710
+ for (const m of body) {
2711
+ if (m.role === "assistant" || rounds.length === 0) rounds.push([m]);
2712
+ else rounds[rounds.length - 1].push(m);
2713
+ }
2714
+ const dropped = rounds.slice(0, rounds.length - KEEP_ROUNDS);
2715
+ const kept = rounds.slice(-KEEP_ROUNDS).flat();
2716
+ let summary = null;
2717
+ try {
2718
+ summary = await summarize(renderDroppedRounds(dropped));
2719
+ } catch {
2720
+ summary = null;
2721
+ }
2722
+ if (!isUsableSummary(summary)) return deterministic;
2723
+ const filesChanged = [...new Set(changes.map((c) => c.file))];
2724
+ const note = {
2725
+ role: "user",
2726
+ content: `[Earlier steps were compacted to save context. Checkpoint summary:
2727
+ ${summary.trim().slice(0, 4e3)}
2728
+ ${filesChanged.length ? `Files changed so far: ${filesChanged.join(", ")}. ` : ""}Continue the task.]`
2729
+ };
2730
+ return { messages: [...head, note, ...kept], droppedRounds: dropped.length };
2731
+ }
2513
2732
  function buildAgentContext(graph, instruction, options) {
2514
2733
  const budget = options.budget ?? 3e3;
2515
2734
  const files = options.files;
2735
+ const relevance = options.relevance;
2736
+ const topicTags = options.topicTags;
2516
2737
  if (!options.capsule) {
2517
- return { context: buildCodeContext(graph, instruction, { budget, files }), capsule: null };
2738
+ return {
2739
+ context: buildCodeContext(graph, instruction, { budget, files, relevance, topicTags, priorInstruction: options.priorInstruction }),
2740
+ capsule: null
2741
+ };
2518
2742
  }
2519
2743
  const capsule = buildTaskCapsule(graph, instruction, {
2520
2744
  budget,
2521
2745
  files,
2746
+ relevance,
2747
+ topicTags,
2748
+ priorInstruction: options.priorInstruction,
2522
2749
  readFile: (rel) => options.fsImpl.read(rel),
2523
2750
  repositoryId: repositoryIdFromRoot(options.root),
2524
2751
  extraPinnedFacts: options.extraPinnedFacts,
@@ -2609,6 +2836,6 @@ function buildSpanIndex(graph) {
2609
2836
  return map;
2610
2837
  }
2611
2838
 
2612
- export { CONTEXT_POLICY_VERSION, DISCOVERY_TOOLS, MUTATION_TOOLS, compact, computeFcsReport, createTrajectoryCollector, renderFcsReportMarkdown, runAgent };
2613
- //# sourceMappingURL=chunk-IRCYOTRG.js.map
2614
- //# sourceMappingURL=chunk-IRCYOTRG.js.map
2839
+ export { CONTEXT_POLICY_VERSION, DISCOVERY_TOOLS, MUTATION_TOOLS, compact, compactWithModel, computeFcsReport, createTrajectoryCollector, lookupModelCapabilities, renderFcsReportMarkdown, runAgent };
2840
+ //# sourceMappingURL=chunk-WGPS3NZQ.js.map
2841
+ //# sourceMappingURL=chunk-WGPS3NZQ.js.map