@linghun/tui 0.1.2 → 0.1.4

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 (117) hide show
  1. package/dist/background-control-runtime.js +37 -37
  2. package/dist/cache-command-runtime.js +3 -3
  3. package/dist/capability-runtime.js +24 -24
  4. package/dist/{chunk-QD4SCW4A.js → chunk-2JFSRRK7.js} +21 -21
  5. package/dist/{chunk-PPUOHBAK.js → chunk-2JZBPXHF.js} +15 -15
  6. package/dist/{chunk-7BHMBWG2.js → chunk-33WA4BDG.js} +4 -4
  7. package/dist/{chunk-YKOXJQGX.js → chunk-3KRRVLS4.js} +111 -3
  8. package/dist/{chunk-42ZZUF7P.js → chunk-6C32YAB5.js} +17 -5
  9. package/dist/{chunk-OSFBVVEP.js → chunk-7ODJHN53.js} +2 -2
  10. package/dist/{chunk-6DBBXNEG.js → chunk-7VGFNZPN.js} +38 -2
  11. package/dist/{chunk-3PG7I3LA.js → chunk-AFNWUI6R.js} +1 -1
  12. package/dist/{chunk-YMEMN5FG.js → chunk-BRNV6757.js} +1 -1
  13. package/dist/{chunk-CJRJR7TP.js → chunk-CL3U56EI.js} +2 -2
  14. package/dist/{chunk-HPIHFENG.js → chunk-HMGGPN4J.js} +1 -1
  15. package/dist/{chunk-HZ5XNKWS.js → chunk-HMGYFENJ.js} +1 -1
  16. package/dist/{chunk-HPQ2IHOW.js → chunk-IU7NZO6B.js} +3 -3
  17. package/dist/{chunk-3LT6OWQ2.js → chunk-IWBV4CEI.js} +1 -1
  18. package/dist/{chunk-YDTJ7UBG.js → chunk-JMUAQUQQ.js} +1 -1
  19. package/dist/{chunk-NK4NMYF5.js → chunk-JY2DO7OF.js} +127 -12
  20. package/dist/{chunk-X7E34LKV.js → chunk-KI7NO6IF.js} +219 -8
  21. package/dist/{chunk-UIKN3CDF.js → chunk-NMOVU75L.js} +1 -1
  22. package/dist/{chunk-ZJDPYOTK.js → chunk-NR3MFRPO.js} +2 -2
  23. package/dist/{chunk-WXTHKLNH.js → chunk-OI5TZ37D.js} +27 -0
  24. package/dist/{chunk-DIDRFIIW.js → chunk-OMWSM2DA.js} +1 -1
  25. package/dist/{chunk-HGCTHBUY.js → chunk-PHPEPZAA.js} +1 -1
  26. package/dist/{chunk-EKYXI6C7.js → chunk-R7BB45CP.js} +1 -1
  27. package/dist/{chunk-7R4YXN7Z.js → chunk-RKFC3V6A.js} +178 -67
  28. package/dist/{chunk-PBIPV4LD.js → chunk-RMXEIZYR.js} +1 -1
  29. package/dist/{chunk-4TO2LDMP.js → chunk-SEVD3KES.js} +2 -2
  30. package/dist/{chunk-AGI6GFFL.js → chunk-T2V2USR3.js} +2 -2
  31. package/dist/{chunk-3MRYQO7X.js → chunk-T7LHFTVM.js} +3 -3
  32. package/dist/{chunk-7RZE45OT.js → chunk-UN3MMVE4.js} +1 -1
  33. package/dist/{chunk-LBC75QAB.js → chunk-UUWG4VXV.js} +10 -4
  34. package/dist/{chunk-FGGY5KNM.js → chunk-UYEVRXUA.js} +3 -3
  35. package/dist/{chunk-O2U4XQVM.js → chunk-UYU4QN3P.js} +1 -1
  36. package/dist/{chunk-J6CYFWSW.js → chunk-VDQTNA4W.js} +20 -1
  37. package/dist/{chunk-RDGM4RUE.js → chunk-VZFP7NWI.js} +1 -1
  38. package/dist/{chunk-7ZMDQZ22.js → chunk-W6O7KDNM.js} +1 -1
  39. package/dist/{chunk-2YL5VKJ5.js → chunk-WO56RSMP.js} +1 -1
  40. package/dist/{chunk-YLOJWSHB.js → chunk-WRVHCSM2.js} +25 -9
  41. package/dist/{chunk-5IFNLTOF.js → chunk-WXQSF2AS.js} +3 -3
  42. package/dist/{chunk-JY3LI63F.js → chunk-YGXPS5F2.js} +1 -1
  43. package/dist/{chunk-ZF36LULR.js → chunk-ZNAYWBBI.js} +2 -2
  44. package/dist/command-panel-runtime.js +23 -23
  45. package/dist/compact-cache-command-runtime.js +37 -37
  46. package/dist/compact-preflight-runtime.js +12 -12
  47. package/dist/connector-runtime.js +25 -25
  48. package/dist/deferred-tools-catalog.d.ts +2 -1
  49. package/dist/deferred-tools-catalog.d.ts.map +1 -1
  50. package/dist/deferred-tools-catalog.js +3 -1
  51. package/dist/details-status-runtime.js +23 -23
  52. package/dist/evidence-runtime.d.ts.map +1 -1
  53. package/dist/evidence-runtime.js +7 -6
  54. package/dist/extension-command-runtime.js +5 -5
  55. package/dist/extension-slash-runtime.js +24 -24
  56. package/dist/failure-learning-command-runtime.js +24 -24
  57. package/dist/final-answer-gate.d.ts.map +1 -1
  58. package/dist/final-answer-gate.js +2 -2
  59. package/dist/git-command-runtime.js +24 -24
  60. package/dist/handoff-session-runtime.js +3 -3
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +103 -45
  63. package/dist/job-agent-command-runtime.js +23 -23
  64. package/dist/job-runtime.js +4 -4
  65. package/dist/mcp-index-command-runtime.js +3 -3
  66. package/dist/mcp-index-runtime.d.ts +8 -0
  67. package/dist/mcp-index-runtime.d.ts.map +1 -1
  68. package/dist/mcp-index-runtime.js +28 -26
  69. package/dist/mcp-stdio-runtime.js +2 -2
  70. package/dist/memory-command-runtime.js +24 -24
  71. package/dist/model-command-runtime.js +24 -24
  72. package/dist/model-doctor-runtime.d.ts +1 -0
  73. package/dist/model-doctor-runtime.d.ts.map +1 -1
  74. package/dist/model-doctor-runtime.js +1 -1
  75. package/dist/model-loop-runtime.d.ts +15 -1
  76. package/dist/model-loop-runtime.d.ts.map +1 -1
  77. package/dist/model-loop-runtime.js +29 -1
  78. package/dist/model-prompt-runtime.d.ts.map +1 -1
  79. package/dist/model-prompt-runtime.js +5 -5
  80. package/dist/model-stream-runtime.d.ts.map +1 -1
  81. package/dist/model-stream-runtime.js +37 -37
  82. package/dist/model-tool-runtime.d.ts +7 -0
  83. package/dist/model-tool-runtime.d.ts.map +1 -1
  84. package/dist/model-tool-runtime.js +39 -37
  85. package/dist/permission-approval-runtime.js +37 -37
  86. package/dist/permission-continuation-runtime.d.ts.map +1 -1
  87. package/dist/permission-continuation-runtime.js +2 -2
  88. package/dist/process-command-runtime.js +2 -2
  89. package/dist/process-guard.d.ts +3 -0
  90. package/dist/process-guard.d.ts.map +1 -1
  91. package/dist/process-guard.js +5 -1
  92. package/dist/provider-loop-runtime.js +3 -3
  93. package/dist/remote-command-runtime.js +24 -24
  94. package/dist/runner-runtime.js +3 -3
  95. package/dist/shell/components/ProductBlock.js +2 -2
  96. package/dist/shell/components/ShellApp.js +12 -12
  97. package/dist/shell/ink-renderer.js +12 -12
  98. package/dist/shell/view-model.js +6 -6
  99. package/dist/slash-command-runtime.js +37 -37
  100. package/dist/terminal-readiness-runtime.js +3 -3
  101. package/dist/tool-output-presenter.d.ts +1 -0
  102. package/dist/tool-output-presenter.d.ts.map +1 -1
  103. package/dist/tool-output-presenter.js +3 -1
  104. package/dist/tui-agent-job-runtime.js +8 -8
  105. package/dist/tui-context-runtime.d.ts +2 -0
  106. package/dist/tui-context-runtime.d.ts.map +1 -1
  107. package/dist/tui-context-runtime.js +3 -3
  108. package/dist/tui-data-types.d.ts +1 -0
  109. package/dist/tui-data-types.d.ts.map +1 -1
  110. package/dist/tui-details-runtime.js +5 -5
  111. package/dist/tui-model-runtime.js +2 -2
  112. package/dist/tui-output-surface.js +7 -7
  113. package/dist/tui-permission-runtime.js +3 -3
  114. package/dist/verification-command-runtime.js +9 -9
  115. package/dist/workflow-command-runtime.js +23 -23
  116. package/package.json +5 -5
  117. package/dist/{chunk-Z265MCGC.js → chunk-VWEAK3UV.js} +3 -3
@@ -5,14 +5,14 @@ import {
5
5
  isPotentiallyMutatingMcpTool,
6
6
  runMcpStdioToolCall,
7
7
  runMcpStdioToolList
8
- } from "./chunk-DIDRFIIW.js";
8
+ } from "./chunk-OMWSM2DA.js";
9
9
  import {
10
10
  buildIndexStatusPanel,
11
11
  buildMcpStatusPanel,
12
12
  formatIndexRefreshSummary,
13
13
  formatIndexStatus,
14
14
  formatMcpStatus
15
- } from "./chunk-O2U4XQVM.js";
15
+ } from "./chunk-UYU4QN3P.js";
16
16
  import {
17
17
  runMcpSseToolCall
18
18
  } from "./chunk-BNC4F63N.js";
@@ -26,14 +26,14 @@ import {
26
26
  } from "./chunk-6CHUZ2NF.js";
27
27
  import {
28
28
  showCommandPanel
29
- } from "./chunk-PPUOHBAK.js";
29
+ } from "./chunk-2JZBPXHF.js";
30
30
  import {
31
31
  writeDiagnosticLine
32
- } from "./chunk-HPIHFENG.js";
32
+ } from "./chunk-HMGGPN4J.js";
33
33
  import {
34
34
  redactedPath,
35
35
  runCommandCapture
36
- } from "./chunk-HZ5XNKWS.js";
36
+ } from "./chunk-HMGYFENJ.js";
37
37
  import {
38
38
  findDeferredTool,
39
39
  getCodebaseMemoryToolRisk,
@@ -44,7 +44,7 @@ import {
44
44
  searchDeferredTools,
45
45
  summarizeDeferredToolMatch,
46
46
  validateCodebaseMemoryToolExecution
47
- } from "./chunk-6DBBXNEG.js";
47
+ } from "./chunk-7VGFNZPN.js";
48
48
  import {
49
49
  findCurrentIndexProject,
50
50
  readLocalIndexArtifactState
@@ -65,6 +65,7 @@ import {
65
65
  } from "./chunk-UGYFQF6M.js";
66
66
 
67
67
  // src/mcp-index-runtime.ts
68
+ import { spawn } from "child_process";
68
69
  import { randomUUID } from "crypto";
69
70
  import { readFile } from "fs/promises";
70
71
  import { delimiter, dirname, join, resolve } from "path";
@@ -79,6 +80,7 @@ var CODEBASE_MEMORY_COMMAND = "codebase-memory-mcp";
79
80
  var CODEBASE_MEMORY_ENV = "LINGHUN_CODEBASE_MEMORY_MCP";
80
81
  var CLI_BUNDLED_ROOT_ENV = "LINGHUN_CLI_BUNDLED_ROOT";
81
82
  var CODEBASE_MEMORY_BUNDLED_ENV = "LINGHUN_CODEBASE_MEMORY_BUNDLED_DIR";
83
+ var PRE_ENGINE_BUNDLED_ENV = "LINGHUN_PRE_ENGINE_BUNDLED_DIR";
82
84
  var CODEBASE_MEMORY_BUNDLED_PLATFORM_ARCHES = /* @__PURE__ */ new Set([
83
85
  "win32-x64",
84
86
  "linux-x64",
@@ -422,6 +424,153 @@ function getCodebaseMemoryPlatformArch() {
422
424
  }
423
425
  return `${process.platform}-${process.arch}`;
424
426
  }
427
+ var PRE_ENGINE_COMMAND = "linghun-pre-engine";
428
+ var PreEngineDaemon = class {
429
+ constructor(binary, cwd) {
430
+ this.binary = binary;
431
+ this.cwd = cwd;
432
+ }
433
+ binary;
434
+ cwd;
435
+ proc = null;
436
+ queue = Promise.resolve();
437
+ idleTimer = null;
438
+ msgId = 1;
439
+ call(toolName, args) {
440
+ return new Promise((resolve2, reject) => {
441
+ this.queue = this.queue.then(() => this._doCall(toolName, args).then(resolve2, reject)).catch(() => {
442
+ });
443
+ });
444
+ }
445
+ _ensureProc() {
446
+ if (this.proc) return Promise.resolve(this.proc);
447
+ const proc = spawn(this.binary, [], { cwd: this.cwd, stdio: ["pipe", "pipe", "pipe"] });
448
+ this.proc = proc;
449
+ proc.on("exit", () => {
450
+ if (this.proc === proc) this.proc = null;
451
+ });
452
+ return new Promise((resolve2) => {
453
+ let buf = "";
454
+ const onData = (chunk) => {
455
+ buf += chunk.toString();
456
+ const lines = buf.split("\n");
457
+ buf = lines.pop() ?? "";
458
+ for (const line of lines) {
459
+ if (!line.trim()) continue;
460
+ try {
461
+ const msg = JSON.parse(line);
462
+ if (msg.id === 0) {
463
+ proc.stdout.off("data", onData);
464
+ proc.stdin.write(
465
+ JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized", params: {} }) + "\n"
466
+ );
467
+ resolve2(proc);
468
+ }
469
+ } catch {
470
+ }
471
+ }
472
+ };
473
+ proc.stdout.on("data", onData);
474
+ proc.stdin.write(
475
+ JSON.stringify({ jsonrpc: "2.0", id: 0, method: "initialize", params: { rootUri: this.cwd } }) + "\n"
476
+ );
477
+ });
478
+ }
479
+ _doCall(toolName, args) {
480
+ this._resetIdle();
481
+ return this._ensureProc().then(
482
+ (proc) => new Promise((resolve2) => {
483
+ const id = this.msgId++;
484
+ let buf = "";
485
+ const cleanup = () => {
486
+ proc.stdout.off("data", onData);
487
+ proc.off("exit", onExit);
488
+ };
489
+ const onExit = () => {
490
+ cleanup();
491
+ resolve2({ ok: false, summary: "pre-engine process exited unexpectedly" });
492
+ };
493
+ const onData = (chunk) => {
494
+ buf += chunk.toString();
495
+ const lines = buf.split("\n");
496
+ buf = lines.pop() ?? "";
497
+ for (const line of lines) {
498
+ if (!line.trim()) continue;
499
+ try {
500
+ const msg = JSON.parse(line);
501
+ if (msg.id === id) {
502
+ cleanup();
503
+ if (msg.error) {
504
+ resolve2({ ok: false, summary: msg.error.message ?? String(msg.error) });
505
+ } else {
506
+ const content = msg.result?.content;
507
+ const text = Array.isArray(content) ? content.map((c) => c.text ?? "").join("") : "";
508
+ resolve2({ ok: true, summary: text, data: msg.result });
509
+ }
510
+ }
511
+ } catch {
512
+ }
513
+ }
514
+ };
515
+ proc.stdout.on("data", onData);
516
+ proc.on("exit", onExit);
517
+ proc.stdin.write(
518
+ JSON.stringify({
519
+ jsonrpc: "2.0",
520
+ id,
521
+ method: "tools/call",
522
+ params: { name: toolName, arguments: args }
523
+ }) + "\n"
524
+ );
525
+ })
526
+ );
527
+ }
528
+ _resetIdle() {
529
+ if (this.idleTimer) clearTimeout(this.idleTimer);
530
+ this.idleTimer = setTimeout(() => {
531
+ this.proc?.kill();
532
+ this.proc = null;
533
+ }, 3e4);
534
+ }
535
+ };
536
+ var _preEngineDaemons = /* @__PURE__ */ new Map();
537
+ function getOrCreatePreEngineDaemon(binary, cwd) {
538
+ const key = `${binary}\0${cwd}`;
539
+ let d = _preEngineDaemons.get(key);
540
+ if (!d) {
541
+ d = new PreEngineDaemon(binary, cwd);
542
+ _preEngineDaemons.set(key, d);
543
+ }
544
+ return d;
545
+ }
546
+ async function resolvePreEngineBinary() {
547
+ const platformArch = `${process.platform}-${process.arch}`;
548
+ const fileName = platformArch.startsWith("win32") ? `${PRE_ENGINE_COMMAND}.exe` : PRE_ENGINE_COMMAND;
549
+ const roots = [];
550
+ if (process.env[PRE_ENGINE_BUNDLED_ENV]) {
551
+ roots.push(process.env[PRE_ENGINE_BUNDLED_ENV]);
552
+ }
553
+ if (process.env[CLI_BUNDLED_ROOT_ENV]) {
554
+ roots.push(join(process.env[CLI_BUNDLED_ROOT_ENV], "pre-engine"));
555
+ }
556
+ const moduleDir = dirname(fileURLToPath(import.meta.url));
557
+ roots.push(join(moduleDir, "..", "bundled", "pre-engine"));
558
+ roots.push(join(moduleDir, "bundled", "pre-engine"));
559
+ for (const root of roots) {
560
+ const candidate = join(root, platformArch, fileName);
561
+ if (await pathExists(candidate)) {
562
+ return candidate;
563
+ }
564
+ }
565
+ const pathDirs = (process.env.PATH ?? "").split(delimiter).filter(Boolean);
566
+ for (const dir of pathDirs) {
567
+ const candidate = join(dir, fileName);
568
+ if (await pathExists(candidate)) {
569
+ return candidate;
570
+ }
571
+ }
572
+ return void 0;
573
+ }
425
574
  async function findPathCodebaseMemoryBinary() {
426
575
  const pathDirs = (process.env.PATH ?? "").split(delimiter).filter(Boolean);
427
576
  const candidates = pathDirs.map((dir) => join(dir, CODEBASE_MEMORY_COMMAND));
@@ -1034,15 +1183,54 @@ async function runCodebaseMemoryCli(context, tool, input, cwd, timeoutMs = 3e4)
1034
1183
  function executeSearchExtraTools(query, context) {
1035
1184
  const all = listDeferredTools(context);
1036
1185
  const filtered = searchDeferredTools(query, all);
1186
+ const recommendedNext = recommendDeferredToolCall(query, context, filtered);
1037
1187
  for (const tool of filtered) {
1038
1188
  context.discoveredDeferredToolNames.add(tool.name);
1039
1189
  }
1190
+ const recommendationText = recommendedNext ? ` Recommended next: ExecuteExtraTool(${recommendedNext.tool_name}, ${JSON.stringify({
1191
+ params: recommendedNext.params
1192
+ })}) because ${recommendedNext.reason}.` : "";
1040
1193
  return {
1041
1194
  ok: true,
1042
- text: `SearchExtraTools matched ${filtered.length}/${all.length} deferred tools (query=${JSON.stringify(query)}).`,
1043
- data: { matches: filtered.map(summarizeDeferredToolMatch), total: filtered.length }
1195
+ text: `SearchExtraTools matched ${filtered.length}/${all.length} deferred tools (query=${JSON.stringify(query)}).${recommendationText}`,
1196
+ data: { matches: filtered.map(summarizeDeferredToolMatch), total: filtered.length, recommendedNext }
1044
1197
  };
1045
1198
  }
1199
+ function recommendDeferredToolCall(query, context, matches) {
1200
+ const has = (name) => matches.some((tool) => tool.name === name && tool.executable);
1201
+ const task = query.trim();
1202
+ if (context.index.status === "ready" && context.index.projectName) {
1203
+ if (has("get_architecture")) {
1204
+ return {
1205
+ tool_name: "get_architecture",
1206
+ params: { project: context.index.projectName },
1207
+ reason: "codebase-memory index is ready, so index-backed architecture is the broad repository discovery step"
1208
+ };
1209
+ }
1210
+ if (task && has("search_code")) {
1211
+ return {
1212
+ tool_name: "search_code",
1213
+ params: { project: context.index.projectName, pattern: task },
1214
+ reason: "codebase-memory index is ready, so indexed search should narrow the repository scope before AST precision"
1215
+ };
1216
+ }
1217
+ if (task && has("search_graph")) {
1218
+ return {
1219
+ tool_name: "search_graph",
1220
+ params: { project: context.index.projectName, query: task },
1221
+ reason: "codebase-memory index is ready, so graph search should narrow related symbols before AST precision"
1222
+ };
1223
+ }
1224
+ }
1225
+ if (task && has("pre_plan")) {
1226
+ return {
1227
+ tool_name: "pre_plan",
1228
+ params: { task },
1229
+ reason: "the codebase index is not ready, so pre-engine should provide the first structured repository-analysis pass"
1230
+ };
1231
+ }
1232
+ return void 0;
1233
+ }
1046
1234
  async function executeExtraTool(args, context) {
1047
1235
  if (typeof args.tool_name !== "string" || args.tool_name.trim() === "") {
1048
1236
  return {
@@ -1102,6 +1290,28 @@ async function executeExtraTool(args, context) {
1102
1290
  data: cliResult.data
1103
1291
  };
1104
1292
  }
1293
+ if (target.kind === "pre-engine") {
1294
+ const binary = await resolvePreEngineBinary();
1295
+ if (!binary) {
1296
+ return {
1297
+ ok: false,
1298
+ text: `ExecuteExtraTool(pre-engine:${target.name}) \u5931\u8D25\uFF1A\u627E\u4E0D\u5230 linghun-pre-engine \u4E8C\u8FDB\u5236\u6587\u4EF6\uFF08bundled \u6216 PATH \u5747\u672A\u547D\u4E2D\uFF09\u3002`
1299
+ };
1300
+ }
1301
+ const daemon = getOrCreatePreEngineDaemon(binary, context.projectPath);
1302
+ const result = await daemon.call(target.name, params);
1303
+ if (!result.ok) {
1304
+ return {
1305
+ ok: false,
1306
+ text: `ExecuteExtraTool(pre-engine:${target.name}) \u5931\u8D25\uFF1A${result.summary}`
1307
+ };
1308
+ }
1309
+ return {
1310
+ ok: true,
1311
+ text: `ExecuteExtraTool(pre-engine:${target.name}) \u5B8C\u6210\u3002`,
1312
+ data: result.data
1313
+ };
1314
+ }
1105
1315
  if (target.kind === "mcp") {
1106
1316
  const parsed = parseMcpDeferredToolName(target.name);
1107
1317
  if (!parsed) {
@@ -1169,6 +1379,7 @@ export {
1169
1379
  findBundledCodebaseMemoryBinary,
1170
1380
  getBundledCodebaseMemoryRoots,
1171
1381
  getCodebaseMemoryPlatformArch,
1382
+ resolvePreEngineBinary,
1172
1383
  findPathCodebaseMemoryBinary,
1173
1384
  findCodebaseMemoryBinaryCandidate,
1174
1385
  probeCodebaseMemoryBinary,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formatApprovedRunnerSpecLine
3
- } from "./chunk-YDTJ7UBG.js";
3
+ } from "./chunk-JMUAQUQQ.js";
4
4
  import {
5
5
  formatJobNextAction,
6
6
  formatJobRunnerInline,
@@ -27,11 +27,11 @@ import {
27
27
  } from "./chunk-CFXB5SE5.js";
28
28
  import {
29
29
  showCommandPanel
30
- } from "./chunk-PPUOHBAK.js";
30
+ } from "./chunk-2JZBPXHF.js";
31
31
  import {
32
32
  redactRemoteSummary,
33
33
  remoteTranscriptSummary
34
- } from "./chunk-42ZZUF7P.js";
34
+ } from "./chunk-6C32YAB5.js";
35
35
  import {
36
36
  applyRemoteSessionDisables,
37
37
  createRemoteState
@@ -2,6 +2,8 @@
2
2
  var TODO_OUTPUT_ITEM_LIMIT = 8;
3
3
  var BASH_TAIL_LINE_LIMIT = 0;
4
4
  var PRIMARY_PREVIEW_LINE_CAP = 5;
5
+ var DIAGNOSTICS_SUMMARY_LIMIT = 3;
6
+ var DIAGNOSTICS_EVIDENCE_LIMIT = 120;
5
7
  var RAW_TOOL_USE_PATTERNS = [
6
8
  /<tool_use(?:_error)?\b[\s\S]*?<\/tool_use(?:_error)?>/giu,
7
9
  /<tool_use(?:_error)?\b[^>]*\/>/giu,
@@ -62,12 +64,36 @@ function formatToolOutput(name, output, language, evidenceId) {
62
64
  if (layered.preview) {
63
65
  lines.push(layered.preview);
64
66
  }
67
+ const diagnostics = formatToolDiagnosticsSummary(output);
68
+ if (diagnostics) {
69
+ lines.push(diagnostics);
70
+ }
65
71
  const bashEnd = formatBashEndSummary(name, output, language);
66
72
  if (bashEnd) {
67
73
  lines.push(bashEnd);
68
74
  }
69
75
  return lines.join("\n");
70
76
  }
77
+ function formatToolDiagnosticsSummary(output) {
78
+ const metadata = output.data && typeof output.data === "object" ? output.data : void 0;
79
+ const diagnostics = Array.isArray(metadata?.diagnostics) ? metadata.diagnostics : [];
80
+ const lines = diagnostics.map(formatCompactDiagnosticLine).filter((line) => Boolean(line)).slice(0, DIAGNOSTICS_SUMMARY_LIMIT);
81
+ if (lines.length === 0) return void 0;
82
+ return ["Linghun diagnostics:", ...lines].join("\n");
83
+ }
84
+ function formatCompactDiagnosticLine(value) {
85
+ if (!value || typeof value !== "object") return void 0;
86
+ const record = value;
87
+ const type = typeof record.type === "string" ? record.type.trim() : "";
88
+ const evidence = typeof record.evidence === "string" ? record.evidence.trim() : "";
89
+ if (!type || !evidence) return void 0;
90
+ return `- ${type}: ${compactDiagnosticEvidence(evidence)}`;
91
+ }
92
+ function compactDiagnosticEvidence(value) {
93
+ const singleLine = value.replace(/\s+/gu, " ").trim();
94
+ if (singleLine.length <= DIAGNOSTICS_EVIDENCE_LIMIT) return singleLine;
95
+ return `${singleLine.slice(0, DIAGNOSTICS_EVIDENCE_LIMIT - 3)}...`;
96
+ }
71
97
  function formatPrimaryToolLead(name, output, layered, language) {
72
98
  const metadata = output.data && typeof output.data === "object" ? output.data : void 0;
73
99
  const count = readNumber(metadata, "count");
@@ -589,6 +615,7 @@ function looksLikeMojibake(text) {
589
615
  export {
590
616
  createLayeredToolOutput,
591
617
  formatToolOutput,
618
+ formatToolDiagnosticsSummary,
592
619
  formatToolStart,
593
620
  sanitizeAssistantPrimaryText,
594
621
  sanitizeAssistantPrimaryTextWithMetadata,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProcessGuard
3
- } from "./chunk-J6CYFWSW.js";
3
+ } from "./chunk-VDQTNA4W.js";
4
4
  import {
5
5
  sanitizeDiagnosticText
6
6
  } from "./chunk-UGYFQF6M.js";
@@ -4,7 +4,7 @@ import {
4
4
  formatPermissionSummary,
5
5
  getHardDenyReason,
6
6
  isPlanAllowedTool
7
- } from "./chunk-42ZZUF7P.js";
7
+ } from "./chunk-6C32YAB5.js";
8
8
  import {
9
9
  classifyToolRequest
10
10
  } from "./chunk-LHHKPGLX.js";
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-VIJ7GDKI.js";
28
28
  import {
29
29
  sanitizeMainScreenLeakage
30
- } from "./chunk-YLOJWSHB.js";
30
+ } from "./chunk-WRVHCSM2.js";
31
31
  import {
32
32
  SLASH_COMMAND_REGISTRY
33
33
  } from "./chunk-PGNALDEH.js";