@serjm/deepseek-code 0.4.5 → 0.4.6

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 (49) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/api/index.d.ts +2 -6
  3. package/dist/api/index.d.ts.map +1 -1
  4. package/dist/api/index.js +14 -39
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/config/defaults.d.ts +9 -0
  7. package/dist/config/defaults.d.ts.map +1 -1
  8. package/dist/config/defaults.js +18 -0
  9. package/dist/config/defaults.js.map +1 -1
  10. package/dist/core/agent-loop.d.ts +16 -5
  11. package/dist/core/agent-loop.d.ts.map +1 -1
  12. package/dist/core/agent-loop.js +156 -17
  13. package/dist/core/agent-loop.js.map +1 -1
  14. package/dist/core/mcp-tools.d.ts +15 -0
  15. package/dist/core/mcp-tools.d.ts.map +1 -0
  16. package/dist/core/mcp-tools.js +94 -0
  17. package/dist/core/mcp-tools.js.map +1 -0
  18. package/dist/core/metrics.d.ts +6 -1
  19. package/dist/core/metrics.d.ts.map +1 -1
  20. package/dist/core/metrics.js +17 -4
  21. package/dist/core/metrics.js.map +1 -1
  22. package/dist/tools/bash.d.ts.map +1 -1
  23. package/dist/tools/bash.js +83 -68
  24. package/dist/tools/bash.js.map +1 -1
  25. package/dist/tools/chrome-manager.d.ts.map +1 -1
  26. package/dist/tools/chrome-manager.js +5 -2
  27. package/dist/tools/chrome-manager.js.map +1 -1
  28. package/dist/tools/chrome.d.ts.map +1 -1
  29. package/dist/tools/chrome.js +8 -3
  30. package/dist/tools/chrome.js.map +1 -1
  31. package/dist/tools/process-manager.d.ts +17 -0
  32. package/dist/tools/process-manager.d.ts.map +1 -0
  33. package/dist/tools/process-manager.js +94 -0
  34. package/dist/tools/process-manager.js.map +1 -0
  35. package/dist/tools/read.d.ts.map +1 -1
  36. package/dist/tools/read.js +14 -11
  37. package/dist/tools/read.js.map +1 -1
  38. package/dist/tools/shell.d.ts +20 -0
  39. package/dist/tools/shell.d.ts.map +1 -0
  40. package/dist/tools/shell.js +100 -0
  41. package/dist/tools/shell.js.map +1 -0
  42. package/dist/tools/types.d.ts +6 -0
  43. package/dist/tools/types.d.ts.map +1 -1
  44. package/dist/tools/types.js +9 -1
  45. package/dist/tools/types.js.map +1 -1
  46. package/dist/ui/app.d.ts.map +1 -1
  47. package/dist/ui/app.js +12 -38
  48. package/dist/ui/app.js.map +1 -1
  49. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.6 — Real-Project Agent Hardening
4
+
5
+ Stabilization driven by running the agent on real, large Windows projects.
6
+
7
+ ### Fixed
8
+ - **Windows shell is now consistent.** All commands run through one resolved shell — Windows PowerShell by default, with a cmd.exe fallback when PowerShell is unavailable (`DEEPSEEK_CODE_SHELL` overrides). This ends the "wrote PowerShell, ran under cmd.exe" failures that produced junk like a literal `$null` file, and the system prompt now states the exact active dialect so the agent stops brute-forcing command variants.
9
+ - **Image content no longer bricks the session.** The DeepSeek API accepts only text; a single `image_url` block in history made every later request fail with `400 unknown variant image_url`. All message content is now flattened to text before sending; image paste is a no-op with a notice; `read_file` returns metadata for binary images (and SVG source / extracted PDF text) instead of inlining base64.
10
+ - **Correct context window and pricing.** The context window is the real **1M tokens** for V4 models (was hardcoded 128k), so auto-compaction no longer fires ~8× too early; cost/token accounting verified against the official pricing page.
11
+ - **Auto-compaction keeps the original task and recent messages** instead of collapsing history to a lone summary (a driver of the agent "remembering" planned work as done).
12
+ - **Browser reuses a single tab** by default instead of opening a new tab per navigation; screenshots are saved for the user and clearly flagged as non-viewable by the model (verify via DOM/`eval`/console).
13
+
14
+ ### Added
15
+ - **Background processes** for `run_shell_command` (`background`, `wait_for_port`, `stop_pid`): start a dev/preview server without hanging, wait for its port, then stop it (whole process tree). Orphans are killed on exit.
16
+ - **Verified-state ledger**: a tool-derived summary of what was actually done (files changed, ok/failed counts) is injected at follow-ups and after compaction, plus a rule that an iteration counts as done only if this run contains its tool calls — guarding against narrating un-done work.
17
+ - Honest-reporting rules: separate the final check result from earlier failed attempts; "could not run X" is reported as Not checked, not as a project defect.
18
+ - MCP: connected MCP tools are callable by the agent; shared-hub project_id auto-derived from cwd; dsc identity stamped on hub writes.
19
+
20
+ ### Changed
21
+ - **Ctrl+C** now exits only on a double press (with a hint on the first) and never aborts the running agent — aborting was what dropped the process to the shell on Windows. To steer the agent mid-run, type a follow-up (it is queued into the active run).
22
+
23
+ ### Known Issues
24
+ - The agent does not always reach for `background:true` on the first try for a dev server (it may run it blocking once and hit a timeout before recovering).
25
+ - This model has no vision: screenshots are saved for the user but verified by the agent via DOM/console, not visually.
26
+
3
27
  ## 0.4.5 — TUI Stabilization, Multimodal & Pipeline
4
28
 
5
29
  ### Added
@@ -77,10 +77,6 @@ export declare class DeepSeekAPI {
77
77
  */
78
78
  getEmbedding(text: string): Promise<number[]>;
79
79
  }
80
- /**
81
- * Convert a string that contains data: URLs into ContentBlock[] for vision models.
82
- * If no data: URLs found, returns the original string.
83
- * Used to upgrade read_file output (images/PDF as base64) into multimodal input.
84
- */
85
- export declare function dataUrlsToContentBlocks(text: string): string | ContentBlock[];
80
+ /** Flatten string|ContentBlock[] to a plain string (image blocks → placeholder). */
81
+ export declare function flattenContent(content: string | ContentBlock[]): string;
86
82
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,YAAY,EAAE,UAAU,EAAE,CAAA;AAE1B,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,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M,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;CACpD;AAOD,qBAAa,kBAAmB,SAAQ,KAAK;gBAC9B,SAAS,EAAE,MAAM;CAI/B;AAyBD,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAQ;gBAEf,MAAM,EAAE,cAAc;IAS3B,UAAU,CAChB,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,CAAC,EAAE,UAAU,EAAE,GACnB,cAAc,CAAC,WAAW,CAAC;IAuJ9B;;;OAGG;IACG,IAAI,CACR,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,CAAC,EAAE,UAAU,EAAE,GACnB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;IAmDxG,+DAA+D;IACzD,WAAW,IAAK,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAiBjE;;OAEG;IACG,YAAY,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAOrD;AA2CD,oFAAoF;AACpF,wBAAgB,cAAc,CAAE,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,GAAG,MAAM,CAKxE"}
package/dist/api/index.js CHANGED
@@ -247,37 +247,6 @@ export class DeepSeekAPI {
247
247
  }
248
248
  }
249
249
  // ─── Helper functions ────────────────────────────────────────────────────────
250
- /**
251
- * Convert a string that contains data: URLs into ContentBlock[] for vision models.
252
- * If no data: URLs found, returns the original string.
253
- * Used to upgrade read_file output (images/PDF as base64) into multimodal input.
254
- */
255
- export function dataUrlsToContentBlocks(text) {
256
- const DATA_URL_RE = /!?\[.*?\]\(data:([^;]+);base64,([^)]+)\)/g;
257
- const blocks = [];
258
- let lastIndex = 0;
259
- let match;
260
- while ((match = DATA_URL_RE.exec(text)) !== null) {
261
- if (match.index > lastIndex) {
262
- blocks.push({ type: 'text', text: text.slice(lastIndex, match.index).trim() || '\n' });
263
- }
264
- const mime = match[1];
265
- const b64 = match[2];
266
- blocks.push({ type: 'image_url', image_url: { url: `data:${mime};base64,${b64}` } });
267
- lastIndex = match.index + match[0].length;
268
- }
269
- if (blocks.length === 0)
270
- return text;
271
- if (lastIndex < text.length) {
272
- const remaining = text.slice(lastIndex).trim();
273
- if (remaining)
274
- blocks.push({ type: 'text', text: remaining });
275
- }
276
- if (!blocks.some(b => b.type === 'text')) {
277
- blocks.unshift({ type: 'text', text: 'Analyze the following image(s):' });
278
- }
279
- return blocks;
280
- }
281
250
  /**
282
251
  * Build OpenAI-compatible message array from our internal ChatMessage format.
283
252
  * Handles both string content and ContentBlock[] (for vision/multimodal models).
@@ -305,19 +274,25 @@ function buildMessages(messages) {
305
274
  })),
306
275
  };
307
276
  }
308
- // Content can be string or ContentBlock[] (for vision/multimodal messages)
309
- if (typeof m.content === 'string') {
310
- return {
311
- role: m.role,
312
- content: m.content,
313
- };
314
- }
277
+ // The DeepSeek API only accepts text content it rejects `image_url`
278
+ // content blocks ("unknown variant image_url"), and a single such block
279
+ // anywhere in history makes EVERY subsequent request fail with 400. So we
280
+ // always flatten content to a plain string here; image blocks become a text
281
+ // placeholder rather than bricking the conversation.
315
282
  return {
316
283
  role: m.role,
317
- content: m.content,
284
+ content: flattenContent(m.content),
318
285
  };
319
286
  });
320
287
  }
288
+ /** Flatten string|ContentBlock[] to a plain string (image blocks → placeholder). */
289
+ export function flattenContent(content) {
290
+ if (typeof content === 'string')
291
+ return content;
292
+ return content
293
+ .map(b => b.type === 'text' ? b.text : '[image omitted — this model has no vision support]')
294
+ .join('\n');
295
+ }
321
296
  /**
322
297
  * Safely parse JSON string, returning empty object on failure.
323
298
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAsD3B,gBAAgB;AAEhB,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAC5B,MAAM,uBAAuB,GAAG,MAAM,CAAA;AAEtC,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAa,SAAiB;QAC5B,KAAK,CAAC,wCAAwC,SAAS,GAAG,IAAI,GAAG,CAAC,CAAA;QAClE,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AAED,SAAS,KAAK,CAAE,EAAU;IACxB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AACxD,CAAC;AAED,SAAS,WAAW,CAAE,GAAY;IAChC,MAAM,GAAG,GAAG,MAAM,CAAE,GAA6B,EAAE,OAAO,IAAI,GAAG,CAAC,CAAA;IAClE,OAAO,2DAA2D,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9E,CAAC;AAED,KAAK,UAAU,SAAS,CAAK,EAAoB;IAC/C,IAAI,OAAgB,CAAA;IACpB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAAC;QAC/D,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAA;QACnB,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,OAAO,GAAG,GAAG,CAAA;YACb,IAAI,OAAO,KAAK,kBAAkB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;gBAAE,MAAM,GAAG,CAAA;YAClE,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE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E,OAAgC;IAC9D,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAA;IAC/C,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oDAAoD,CAAC;SAC3F,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAE,GAAW;IACjC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B,CAAA;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAE,GAAY;IACrC,MAAM,KAAK,GAAG,GAA4C,CAAA;IAC1D,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;IACtC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,GAAG,CAAC,CAAA;IAC7C,OAAO,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACxD,CAAC"}
@@ -31,6 +31,15 @@ export declare const MODEL_PRICING: Record<string, {
31
31
  cacheMissInputPer1M: number;
32
32
  outputPer1M: number;
33
33
  }>;
34
+ /**
35
+ * Context window per model, in tokens. All DeepSeek V4 models (and the legacy
36
+ * aliases) have a 1M-token window per the official pricing page (2026-06-11).
37
+ * The old hardcoded 128k undercounted by ~8x, which both misreported ctx% and
38
+ * fired auto-compaction far too early.
39
+ */
40
+ export declare const MODEL_CONTEXT_WINDOW: Record<string, number>;
41
+ /** Context window for a model, with a conservative fallback for unknown ids. */
42
+ export declare function contextWindowFor(model: string): number;
34
43
  export interface ModelInfo {
35
44
  id: string;
36
45
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAA;AAErE,eAAO,MAAM,cAAc,EAAE,cAoB5B,CAAA;AAED,eAAO,MAAM,gBAAgB,kBAAkB,CAAA;AAC/C,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,kBAAkB,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAK1H,CAAA;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,EAWtC,CAAA"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,c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AAA"}
@@ -21,12 +21,30 @@ Guidelines:
21
21
  };
22
22
  export const CONFIG_FILE_NAME = 'settings.json';
23
23
  export const CONFIG_DIR_NAME = '.deepseek-code';
24
+ // Verified against https://api-docs.deepseek.com/quick_start/pricing (2026-06-11).
25
+ // Legacy deepseek-chat/reasoner are aliases of v4-flash (deprecated 2026-07-24).
24
26
  export const MODEL_PRICING = {
25
27
  'deepseek-chat': { cacheHitInputPer1M: 0.0028, cacheMissInputPer1M: 0.14, outputPer1M: 0.28 },
26
28
  'deepseek-reasoner': { cacheHitInputPer1M: 0.0028, cacheMissInputPer1M: 0.14, outputPer1M: 0.28 },
27
29
  'deepseek-v4-flash': { cacheHitInputPer1M: 0.0028, cacheMissInputPer1M: 0.14, outputPer1M: 0.28 },
28
30
  'deepseek-v4-pro': { cacheHitInputPer1M: 0.003625, cacheMissInputPer1M: 0.435, outputPer1M: 0.87 },
29
31
  };
32
+ /**
33
+ * Context window per model, in tokens. All DeepSeek V4 models (and the legacy
34
+ * aliases) have a 1M-token window per the official pricing page (2026-06-11).
35
+ * The old hardcoded 128k undercounted by ~8x, which both misreported ctx% and
36
+ * fired auto-compaction far too early.
37
+ */
38
+ export const MODEL_CONTEXT_WINDOW = {
39
+ 'deepseek-chat': 1_000_000,
40
+ 'deepseek-reasoner': 1_000_000,
41
+ 'deepseek-v4-flash': 1_000_000,
42
+ 'deepseek-v4-pro': 1_000_000,
43
+ };
44
+ /** Context window for a model, with a conservative fallback for unknown ids. */
45
+ export function contextWindowFor(model) {
46
+ return MODEL_CONTEXT_WINDOW[model] ?? 128_000;
47
+ }
30
48
  export const DEEPSEEK_MODELS = [
31
49
  {
32
50
  id: 'deepseek-v4-flash',
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,iBAAiB;IACxB,Y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EAAE,4EAA4E;KAC1F;CACF,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { type ChatMessage } from '../api/index.js';
2
2
  import { type ApprovalRequirement, type TaskBudget } from '../tools/types.js';
3
- import type { DeepSeekConfig, ApprovalMode } from '../config/defaults.js';
3
+ import { type DeepSeekConfig, type ApprovalMode } from '../config/defaults.js';
4
4
  import { EventEmitter } from 'node:events';
5
5
  import { MetricsCollector } from './metrics.js';
6
6
  export interface AgentLoopOptions {
@@ -79,10 +79,7 @@ export interface ToolResultEvent {
79
79
  durationMs: number;
80
80
  error?: string;
81
81
  }
82
- /**
83
- * Build a dynamic system prompt with project context.
84
- */
85
- export declare function buildSystemPrompt(cwd?: string, approvalMode?: ApprovalMode): string;
82
+ export declare function buildSystemPrompt(cwd?: string, approvalMode?: ApprovalMode, model?: string): string;
86
83
  /**
87
84
  * AgentLoop — manages the "request → tool call → result → next request" cycle.
88
85
  *
@@ -115,10 +112,24 @@ export declare class AgentLoop extends EventEmitter {
115
112
  * Does NOT start a new loop or reset state.
116
113
  */
117
114
  addUserFollowUp(content: string): void;
115
+ /**
116
+ * Compact, tool-derived summary of what was REALLY done in this run: files
117
+ * actually written/edited (verified by the tools) and tool-call counts.
118
+ * Injected at grounding points (after auto-compaction, with follow-ups) so the
119
+ * model cannot drift into claiming work that has no tool calls behind it.
120
+ */
121
+ private buildVerifiedLedger;
118
122
  /**
119
123
  * Set approval mode — updates which tools are available and rebuilds system prompt.
120
124
  */
121
125
  setApprovalMode(mode: ApprovalMode): void;
126
+ /**
127
+ * Built-in tools for the current mode plus any connected MCP tools.
128
+ * MCP servers connect asynchronously at startup, so this is recomputed at the
129
+ * start of each loop. Plan mode stays read-only and excludes MCP tools; a
130
+ * name clash resolves in favor of the built-in tool.
131
+ */
132
+ private buildActiveTools;
122
133
  /**
123
134
  * Run the agent loop with a user prompt.
124
135
  * Returns the final assistant response text.
@@ -1 +1 @@
1
- {"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../src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VzB,wEAAwE;IACxE,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,qBAAqB;YAOf,gBAAgB;IAsG9B,OAAO,CAAC,sBAAsB;IAa9B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAoC1B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAWvB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAgD9B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAQvB,kBAAkB;IAClB,OAAO,CAAC,cAAc;IAQtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;YACW,WAAW;IAuCzB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;CA6BzB"}
@@ -1,6 +1,9 @@
1
1
  import { DeepSeekAPI } from '../api/index.js';
2
2
  import { toOpenAITools, sanitizeArgs } from '../tools/types.js';
3
3
  import { getDefaultTools, getToolsForMode } from '../tools/registry.js';
4
+ import { getMcpToolDefinitions, projectIdFromCwd } from './mcp-tools.js';
5
+ import { resolveWindowsShell } from '../tools/shell.js';
6
+ import { contextWindowFor } from '../config/defaults.js';
4
7
  import { EventEmitter } from 'node:events';
5
8
  import { i18n } from './i18n.js';
6
9
  import { readFileSync, readdirSync, existsSync } from 'node:fs';
@@ -18,7 +21,43 @@ const DEFAULT_AUTO_COMPACT = {
18
21
  /**
19
22
  * Build a dynamic system prompt with project context.
20
23
  */
21
- export function buildSystemPrompt(cwd, approvalMode) {
24
+ const NO_BRUTE_FORCE = '- **Do NOT brute-force command variants.** If a command fails, read the actual error and fix the real cause, then issue ONE corrected command. Never spray permutations (cmd /c …, chcp, node.exe vs npx, env-prefix variants) hoping one works — that just fills the log with failures.';
25
+ const NO_BROAD_KILL = "- Never use broad process-kill commands such as `taskkill /F /IM node.exe`, `Stop-Process -Name node`, `pkill node`, or `killall node`. They can terminate the agent, the user's IDE terminal, and unrelated dev servers. Stop only a specific process you started and can identify by PID.";
26
+ /**
27
+ * Shell guidance that matches the shell `run_shell_command` actually uses, so the
28
+ * model writes the correct dialect instead of guessing (and brute-forcing).
29
+ */
30
+ function buildShellPolicySection() {
31
+ if (platform() !== 'win32') {
32
+ return `## Shell Policy
33
+ - \`run_shell_command\` runs through your system shell (\`/bin/sh\`). Standard POSIX syntax works: \`&&\`, \`||\`, \`$VAR\`, pipes, redirects.
34
+ - Prefer the built-in tools over shell for inspection: \`read_file\`, \`grep_search\`, \`glob\`.
35
+ ${NO_BRUTE_FORCE}
36
+ ${NO_BROAD_KILL}`;
37
+ }
38
+ if (resolveWindowsShell() === 'cmd') {
39
+ return `## Windows Shell Policy
40
+ - On this machine \`run_shell_command\` runs through **cmd.exe** (PowerShell was unavailable or \`DEEPSEEK_CODE_SHELL=cmd\`). Write cmd syntax — NOT PowerShell.
41
+ - Chain with \`&&\` (next only on success) or \`&\` (always). Environment variables: \`%VAR%\`; set inline with \`set VAR=value&& <command>\`.
42
+ - Do NOT use PowerShell syntax here (\`$env:\`, \`;\` as a separator, \`> $null\`, cmdlets) — it fails under cmd and can create junk files like a literal \`$null\`.
43
+ - Unix tools do NOT exist (\`sed\`, \`head\`, \`tail\`, \`grep\`, \`cat\`, \`ls\`, \`rm\`, \`touch\`, \`xargs\`). Use \`findstr\`, \`type\`, \`dir\`, \`del\`, or the \`read_file\`/\`grep_search\`/\`glob\` tools.
44
+ - Never use \`mkdir -p\` (creates a literal \`-p\` directory); use \`mkdir <path>\`.
45
+ - Prefer the built-in tools over shell for inspection: \`read_file\`, \`grep_search\`, \`glob\`.
46
+ ${NO_BRUTE_FORCE}
47
+ ${NO_BROAD_KILL}`;
48
+ }
49
+ return `## Windows Shell Policy
50
+ - On Windows, \`run_shell_command\` runs through **Windows PowerShell 5.1** (a single, predictable shell — never cmd.exe). Write every command in PowerShell syntax. \`npm\`, \`node\`, \`git\`, \`npx\` run normally inside it.
51
+ - **No \`&&\` or \`||\`** — PowerShell 5.1 does not support them (it is a parse error). Run sequentially with \`;\`. To run B only if A succeeded: \`A; if ($?) { B }\`. Example: \`npm run build; if ($?) { npm test }\` — NOT \`npm run build && npm test\`.
52
+ - **Environment variables**: read with \`$env:NAME\`, set inline with \`$env:NAME='value'; <command>\`. There is no \`VAR=value cmd\` prefix and no \`set VAR=...\`.
53
+ - **Redirects work as PowerShell**: \`> $null\`, \`2>$null\`, \`*> out.txt\` are valid here.
54
+ - These are PowerShell aliases and work fine: \`cat\`, \`ls\`, \`rm\`, \`cp\`, \`mv\`, \`echo\`, \`pwd\`. These do NOT exist (use the noted replacement): \`sed\`, \`head\` (→ \`Get-Content -TotalCount n\`), \`tail\` (→ \`Get-Content -Tail n\`), \`grep\` (→ \`grep_search\` tool or \`Select-String\`), \`xargs\`, \`touch\` (→ \`New-Item\`).
55
+ - Never use \`mkdir -p\` (the \`-p\` is not a PowerShell parameter). Use \`New-Item -ItemType Directory -Force <path>\`.
56
+ - Prefer the built-in tools over shell for inspection: \`read_file\` for file content, \`grep_search\` for text search, \`glob\` for file discovery.
57
+ ${NO_BRUTE_FORCE}
58
+ ${NO_BROAD_KILL}`;
59
+ }
60
+ export function buildSystemPrompt(cwd, approvalMode, model) {
22
61
  const osInfo = `${type()} ${release()} (${platform()})`;
23
62
  let projectInfo = '';
24
63
  if (cwd) {
@@ -82,15 +121,39 @@ export function buildSystemPrompt(cwd, approvalMode) {
82
121
  '',
83
122
  ...toolListLines,
84
123
  ].join('\n');
124
+ // Shared Context Hub / external MCP tools. Plan mode is read-only and does not
125
+ // expose them, so only advertise when they are actually active.
126
+ let mcpSection = '';
127
+ if (mode !== 'plan') {
128
+ const mcpTools = getMcpToolDefinitions();
129
+ if (mcpTools.length > 0) {
130
+ const mcpToolLines = mcpTools.map(def => ` - \`${def.tool.name}\` — ${def.tool.description}`);
131
+ const hubProjectId = cwd ? projectIdFromCwd(cwd) : '';
132
+ const orientation = mcpTools.some(def => def.tool.name === 'workspace_resume')
133
+ ? `\n- If a \`workspace_resume\` tool is available, call it ONCE at the start of a new task to load project memory, open/handed-off tasks, and recent sessions in a single token-budgeted call — prefer it over reading many files just to get oriented.${hubProjectId ? ` This project's hub \`project_id\` is \`${hubProjectId}\` — pass it as the \`project_id\` argument (same id for memory/task tools).` : ''}`
134
+ : '';
135
+ const identity = `provider="deepseek", client="dsc"${model ? `, model="${model}"` : ''}`;
136
+ mcpSection = [
137
+ '\n## Shared Context Hub (MCP)',
138
+ 'External MCP tools are connected — shared memory and a task queue used by other agents working on the same projects.' + orientation,
139
+ '- Use `task_list`/`task_claim` to pick up work handed off by another agent, and `session_log`/`memory_write` to record durable outcomes for the next agent.',
140
+ `- Identify yourself when writing to the hub so the shared history shows who did the work: call \`session_log\` with ${identity}; set \`surface="dsc"\` on \`memory_write\`.`,
141
+ '- These tools are real and callable like any other; do not claim you used them without an actual tool call.',
142
+ 'Connected MCP tools:',
143
+ ...mcpToolLines,
144
+ ].join('\n');
145
+ }
146
+ }
85
147
  let responseLanguage = 'English';
86
148
  if (locale === 'ru')
87
149
  responseLanguage = 'Russian';
88
150
  if (locale === 'zh')
89
151
  responseLanguage = 'Chinese';
90
152
  const languageSection = `\n## Language\n- Respond in ${responseLanguage} unless the user explicitly asks otherwise.`;
153
+ const shellPolicySection = buildShellPolicySection();
91
154
  return `You are DeepSeek Code, an AI-powered CLI agent for software development.
92
155
 
93
- You have access to a set of tools that allow you to read, write, and edit files, run shell commands, search code, and use a real browser when rendered UI or web behavior matters.${projectInfo}${capabilitiesSection}${languageSection}
156
+ You have access to a set of tools that allow you to read, write, and edit files, run shell commands, search code, and use a real browser when rendered UI or web behavior matters.${projectInfo}${capabilitiesSection}${mcpSection}${languageSection}
94
157
 
95
158
  ## Guidelines
96
159
  1. **Plan first** — Before making changes, explore the codebase to understand the context.
@@ -115,16 +178,13 @@ When you need to run multiple tools, call them one at a time and wait for result
115
178
  - If the user intended a different folder, ask them to restart/open the CLI in that folder or confirm the correct workspace.
116
179
  - Avoid generating project files through ad-hoc scripts such as \`gen_helper.py\`, \`diag.py\`, or \`fix_pkg.py\`. Use the file tools for file content and remove any temporary helper before the final report.
117
180
 
118
- ## Windows Shell Policy
119
- - The OS is listed in Project Context. If it is Windows or \`win32\`, write shell commands for PowerShell/cmd compatibility.
120
- - On Windows, do not assume Unix tools exist. Avoid \`sed\`, \`head\`, \`tail\`, \`cat\`, \`grep\`, \`find\`, \`xargs\`, \`rm\`, \`touch\`, or Bash-specific syntax unless you first verified the command exists.
121
- - On Windows, never use \`mkdir -p\`; it can create a literal \`-p\` directory. Use \`New-Item -ItemType Directory -Force <path>\` or \`mkdir <path>\` without \`-p\`.
122
- - Prefer built-in tools over shell for repository inspection: use \`read_file\` for file content, \`grep_search\` for text search, and \`glob\` for file discovery.
123
- - For Windows shell reads, prefer PowerShell commands such as \`Get-Content\`, \`Select-String\`, \`Get-ChildItem\`, \`Test-Path\`, \`Remove-Item\`, and \`New-Item\`.
124
- - The shell tool automatically runs recognized PowerShell cmdlets through PowerShell on Windows. Plain commands such as \`npm\`, \`node\`, \`git\`, and \`npx\` run normally.
125
- - Do not mix Bash/cmd chaining syntax with PowerShell cmdlets in the same command. Avoid \`cd path && Remove-Item ...\`; use separate tool calls or PowerShell-compatible \`Set-Location path; Remove-Item ...\` with explicit error checks.
126
- - If a command fails because of shell incompatibility, retry with an OS-compatible command and report the failed attempt honestly.
127
- - Never use broad process-kill commands such as \`taskkill /F /IM node.exe\`, \`Stop-Process -Name node\`, \`pkill node\`, or \`killall node\`. They can terminate the agent, the user's IDE terminal, and unrelated dev servers. Stop only a specific process you started and can identify by PID.
181
+ ${shellPolicySection}
182
+
183
+ ## Long-Running Processes (dev/preview servers, watchers)
184
+ - A dev/preview server (e.g. \`npm run dev\`, \`nuxt dev\`, \`vite\`) does NOT exit never run it as a normal blocking command, it will hang and hit the timeout.
185
+ - Start it with \`run_shell_command\` using \`background: true\`. To then verify the app, pass \`wait_for_port: <port>\` in the same call it returns once the port is accepting connections (or reports it never became ready). Do NOT open the browser before the port is ready (that causes ERR_CONNECTION_REFUSED).
186
+ - Correct flow for a browser check: (1) \`run_shell_command\` with \`background:true, wait_for_port:3000\`; (2) use the \`chrome\` tool to open \`http://localhost:3000\` and inspect; (3) \`run_shell_command\` with \`stop_pid:<pid>\` to stop the server. Always stop a background process you started.
187
+ - If \`wait_for_port\` reports the port never opened, the server failed to start read the returned output, fix the cause, and report it; do not pretend the page rendered.
128
188
 
129
189
  ## Important
130
190
  - ALWAYS use absolute paths when referring to files. The project root is \`${cwd || 'the current working directory'}\`.
@@ -137,6 +197,7 @@ When you need to run multiple tools, call them one at a time and wait for result
137
197
  - **CRITICAL: No post-factum reports without tool calls.** If Tool uses is 0 in the current response, do not claim "I checked the log", "I reviewed the previous run", "step X was successful", or any other retrospective analysis. You may only say: "I did not perform a check right now. Based on visible context I can assume..." Always separate findings into: **Verified** (confirmed by actual tool calls this turn), **Assumption** (inferred from visible context), **Not checked** (not examined this turn). Do not write "successful" for a step that was not actually executed or has no saved result. Use the \`/last-browser-test\` command to retrieve the last saved browser test report — do not reconstruct it from memory.
138
198
 
139
199
  ## Honest Reporting
200
+ - **An iteration/step counts as done ONLY if THIS run contains the tool calls that did it.** Narrating "Iteration N complete, files created, committed" in a turn with no corresponding write_file/edit/shell calls is fabrication. If you only planned or described work, say "planned, not yet executed". When a \`[verified-state]\` ledger appears in context, treat it as the single source of truth about what this run has actually done.
140
201
  - Do not claim files were changed unless tool results include changed=true or files=\`<list>\`.
141
202
  - Do not claim a change was verified unless tool results include verified=true.
142
203
  - Do not claim tests/checks passed unless you actually ran the command and saw success.
@@ -152,13 +213,15 @@ When you need to run multiple tools, call them one at a time and wait for result
152
213
  - Explain whether each failure was **critical** (blocked the task goal) or **non-critical** (retried successfully, fallback worked, or unrelated to the task).
153
214
  - Do not write "all checks passed" or "everything succeeded" if there were failed tool calls, unless you clearly separate successful required checks from non-critical failed attempts.
154
215
  - If a failed command was retried successfully, say so explicitly (e.g., "first attempt failed, retry succeeded").
216
+ - **Separate the FINAL result from the attempts to reach it.** A clean final result (e.g. "lint: 0 errors") describes only the last run. If earlier commands/attempts failed, do NOT present the whole run as clean — say e.g. "lint passed on the 2nd attempt; 1st failed: <reason>". Writing "0 errors" while hiding several failed attempts before it is dishonest. With failed attempts present, the verdict is at best **Partial**.
217
+ - **"Could not run" is NOT "broken".** If you could not execute a check in your environment (command/tool unavailable, permission denied, a shell error on your side), report it as **Not checked — could not run \`<X>\`: <reason>**. Do NOT report your own inability to run a tool as a defect or failure of the project being worked on.
155
218
  - If a failed command produced a temporary file or other side effect, clean it up or mention it in the report.
156
219
 
157
220
  ## Execution Policy
158
221
  1. **Minimal reading**: for a small task, first locate the target with as few reads as possible. Usually 1-2 read_file calls and 1 edit is enough. Do not run a broad grep/glob if you already know the file.
159
222
  2. **Do not repeat identical tool calls**: do not call read_file/grep_search/glob with the same arguments twice unless you have reason to believe the file changed.
160
223
  3. **Checks**: run lint/typecheck/build/test only after making changes. Do not run the same check multiple times without a new edit. If you did not run a check, do not claim it passed.
161
- 4. **Temporary files**: do not create lint_out.txt, test_out.txt, err.txt, temp/debug scripts, one-off files like "1", or scratch files unnecessarily. Prefer command output in the tool result over redirected files. If you created a temporary file, remove it before the final report. Before the final report, check the working tree or otherwise verify no junk temp files remain. If cleanup failed or was not checked, say so explicitly.
224
+ 4. **Temporary files**: do not create lint_out.txt, test_out.txt, err.txt, temp/debug scripts, one-off files like "1", or scratch files unnecessarily. **Never redirect a command's output to a file just to read it back** (e.g. \`eslint . > lint-output.txt\`) — the tool already returns stdout/stderr to you, so the file is pure junk. If you created a temporary file, remove it before the final report. Before the final report, check the working tree or otherwise verify no junk temp files remain. If cleanup failed or was not checked, say so explicitly.
162
225
  5. **Report**: the final report must match the real tool results. Only mention what you actually read, changed, or verified. If no files were changed, explicitly say "No files changed". If there were errors, report them — do not hide them.
163
226
  6. **Stop**: when the goal is achieved and checks are done — stop. Do not continue looking for extra issues without the user asking. Do not refactor beyond the task scope.
164
227
 
@@ -218,7 +281,8 @@ export class AgentLoop extends EventEmitter {
218
281
  super();
219
282
  this.api = new DeepSeekAPI(config);
220
283
  this.model = config.model;
221
- const defaultSystemPrompt = buildSystemPrompt(options.cwd || process.cwd(), options.approvalMode);
284
+ this.metrics.setContextWindow(contextWindowFor(this.model));
285
+ const defaultSystemPrompt = buildSystemPrompt(options.cwd || process.cwd(), options.approvalMode, this.model);
222
286
  this.options = {
223
287
  maxIterations: DEFAULT_MAX_ITERATIONS,
224
288
  toolTimeout: 30000,
@@ -267,11 +331,36 @@ export class AgentLoop extends EventEmitter {
267
331
  if (!trimmed)
268
332
  return;
269
333
  this.followUpSeq++;
334
+ // Attach the verified-state ledger so the model stays grounded in what was
335
+ // ACTUALLY done (it tends to narrate planned iterations as completed during
336
+ // very long runs).
270
337
  this.messages.push({
271
338
  role: 'user',
272
- content: `User follow-up while task was running:\n${trimmed}`,
339
+ content: `User follow-up while task was running:\n${trimmed}\n\n${this.buildVerifiedLedger()}`,
273
340
  });
274
341
  }
342
+ /**
343
+ * Compact, tool-derived summary of what was REALLY done in this run: files
344
+ * actually written/edited (verified by the tools) and tool-call counts.
345
+ * Injected at grounding points (after auto-compaction, with follow-ups) so the
346
+ * model cannot drift into claiming work that has no tool calls behind it.
347
+ */
348
+ buildVerifiedLedger() {
349
+ const calls = [...this.toolCallHistory.values()];
350
+ const changedFiles = new Set();
351
+ for (const call of calls) {
352
+ if (call.changed && call.changedFiles) {
353
+ for (const file of call.changedFiles)
354
+ changedFiles.add(file);
355
+ }
356
+ }
357
+ const completed = calls.filter(c => c.status === 'completed').length;
358
+ const failed = calls.filter(c => c.status === 'failed' || c.status === 'rejected').length;
359
+ const filesList = changedFiles.size > 0
360
+ ? [...changedFiles].slice(0, 40).join(', ') + (changedFiles.size > 40 ? ` … +${changedFiles.size - 40} more` : '')
361
+ : '(none)';
362
+ return `[verified-state] Tool calls so far in THIS run: ${completed} ok, ${failed} failed. Files actually changed (tool-verified): ${filesList}. Anything not listed here was NOT done in this run — do not claim it as completed; verify with git/glob before claiming prior work.`;
363
+ }
275
364
  /**
276
365
  * Set approval mode — updates which tools are available and rebuilds system prompt.
277
366
  */
@@ -279,13 +368,27 @@ export class AgentLoop extends EventEmitter {
279
368
  this.options.approvalMode = mode;
280
369
  this.tools = getToolsForMode(mode);
281
370
  // Rebuild system prompt with updated mode info
282
- this.options.systemPrompt = buildSystemPrompt(this.options.cwd, mode);
371
+ this.options.systemPrompt = buildSystemPrompt(this.options.cwd, mode, this.model);
283
372
  // Update the system message if it exists
284
373
  const sysIdx = this.messages.findIndex(m => m.role === 'system');
285
374
  if (sysIdx !== -1) {
286
375
  this.messages[sysIdx] = { role: 'system', content: this.options.systemPrompt };
287
376
  }
288
377
  }
378
+ /**
379
+ * Built-in tools for the current mode plus any connected MCP tools.
380
+ * MCP servers connect asynchronously at startup, so this is recomputed at the
381
+ * start of each loop. Plan mode stays read-only and excludes MCP tools; a
382
+ * name clash resolves in favor of the built-in tool.
383
+ */
384
+ buildActiveTools() {
385
+ const base = getToolsForMode(this.options.approvalMode);
386
+ if (this.options.approvalMode === 'plan')
387
+ return base;
388
+ const taken = new Set(base.map(t => t.tool.name));
389
+ const mcp = getMcpToolDefinitions().filter(t => !taken.has(t.tool.name));
390
+ return [...base, ...mcp];
391
+ }
289
392
  /**
290
393
  * Run the agent loop with a user prompt.
291
394
  * Returns the final assistant response text.
@@ -313,6 +416,14 @@ export class AgentLoop extends EventEmitter {
313
416
  * Uses streaming for real-time text output via onStreamChunk callback.
314
417
  */
315
418
  async executeLoop() {
419
+ // Refresh tools and system prompt so MCP servers that finished connecting
420
+ // after this loop was constructed are reflected in both.
421
+ this.tools = this.buildActiveTools();
422
+ const sysIdx = this.messages.findIndex(m => m.role === 'system');
423
+ if (sysIdx !== -1) {
424
+ this.options.systemPrompt = buildSystemPrompt(this.options.cwd, this.options.approvalMode, this.model);
425
+ this.messages[sysIdx] = { role: 'system', content: this.options.systemPrompt };
426
+ }
316
427
  const openAITools = toOpenAITools(this.tools);
317
428
  // Capture git baseline before session starts
318
429
  this.metrics.captureGitBaseline(this.options.cwd);
@@ -662,12 +773,40 @@ export class AgentLoop extends EventEmitter {
662
773
  beforeMessages,
663
774
  });
664
775
  const systemMsg = this.messages.find(m => m.role === 'system');
776
+ // BUG FIX: previously the whole history was replaced by [system, summary],
777
+ // silently dropping both the original task text and the recent messages
778
+ // that keepRecentMessages promised to keep. Continuing from a lossy
779
+ // summary alone is how the model drifts into claiming un-done work.
780
+ // Keep: the original user task verbatim + the recent tail.
781
+ const firstUserMsg = this.messages.find(m => m.role === 'user');
782
+ let taskText = '';
783
+ if (firstUserMsg) {
784
+ taskText = typeof firstUserMsg.content === 'string'
785
+ ? firstUserMsg.content
786
+ : firstUserMsg.content.filter(b => b.type === 'text').map(b => b.text).join('\n');
787
+ }
788
+ const taskMsg = taskText
789
+ ? {
790
+ role: 'user',
791
+ content: `**Original task (verbatim, pre-compaction):**\n${taskText.length > 6000 ? taskText.slice(0, 6000) + '\n…[truncated]' : taskText}`,
792
+ }
793
+ : null;
794
+ // Recent tail, trimmed so it does not start with an orphan tool message
795
+ // (a tool result must follow its assistant tool_calls message).
796
+ const tail = this.messages.slice(-compact.keepRecentMessages).filter(m => m.role !== 'system');
797
+ while (tail.length > 0 && tail[0].role === 'tool')
798
+ tail.shift();
665
799
  this.messages = [
666
800
  ...(systemMsg ? [systemMsg] : []),
801
+ ...(taskMsg ? [taskMsg] : []),
667
802
  {
668
803
  role: 'assistant',
669
- content: `**Context Auto-Compacted**\n\nOriginal messages: ${beforeMessages}\nPrevious context: ${contextPercent}% of window\n\n${summary}`,
804
+ // The summary is lossy after compaction the model is prone to
805
+ // "remembering" planned work as done. Pin the tool-verified ledger
806
+ // right next to it so reality stays in context.
807
+ content: `**Context Auto-Compacted**\n\nOriginal messages: ${beforeMessages}\nPrevious context: ${contextPercent}% of window\n\n${summary}\n\n${this.buildVerifiedLedger()}`,
670
808
  },
809
+ ...tail,
671
810
  ];
672
811
  this.lastCompactedAtMessageCount = this.messages.length;
673
812
  this.options.onCompactEnd({