@vpxa/aikit 0.1.9 → 0.1.11

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 (93) hide show
  1. package/package.json +1 -1
  2. package/packages/indexer/dist/smart-index-scheduler.js +1 -1
  3. package/packages/server/dist/compression-interceptor.d.ts +12 -0
  4. package/packages/server/dist/compression-interceptor.js +1 -0
  5. package/packages/server/dist/server.js +2 -2
  6. package/packages/server/dist/tools/analyze.tools.js +3 -3
  7. package/packages/server/dist/tools/flow.tools.js +1 -1
  8. package/packages/server/dist/tools/onboard.tool.js +1 -1
  9. package/packages/server/dist/tools/present/templates.js +6 -6
  10. package/packages/server/dist/tools/present/tool.js +1 -1
  11. package/packages/server/dist/tools/search.tool.js +2 -2
  12. package/packages/store/dist/lance-store.js +1 -1
  13. package/packages/tools/dist/compact.d.ts +6 -0
  14. package/packages/tools/dist/compact.js +2 -2
  15. package/packages/tools/dist/compress-output.d.ts +38 -0
  16. package/packages/tools/dist/compress-output.js +1 -0
  17. package/packages/tools/dist/compression/delta-cache.d.ts +29 -0
  18. package/packages/tools/dist/compression/delta-cache.js +1 -0
  19. package/packages/tools/dist/compression/engine.d.ts +34 -0
  20. package/packages/tools/dist/compression/engine.js +4 -0
  21. package/packages/tools/dist/compression/litm.d.ts +20 -0
  22. package/packages/tools/dist/compression/litm.js +1 -0
  23. package/packages/tools/dist/compression/mmr.d.ts +24 -0
  24. package/packages/tools/dist/compression/mmr.js +1 -0
  25. package/packages/tools/dist/compression/rules/docker.d.ts +11 -0
  26. package/packages/tools/dist/compression/rules/docker.js +3 -0
  27. package/packages/tools/dist/compression/rules/generic.d.ts +11 -0
  28. package/packages/tools/dist/compression/rules/generic.js +3 -0
  29. package/packages/tools/dist/compression/rules/git.d.ts +11 -0
  30. package/packages/tools/dist/compression/rules/git.js +3 -0
  31. package/packages/tools/dist/compression/rules/index.d.ts +14 -0
  32. package/packages/tools/dist/compression/rules/index.js +1 -0
  33. package/packages/tools/dist/compression/rules/kubectl.d.ts +11 -0
  34. package/packages/tools/dist/compression/rules/kubectl.js +3 -0
  35. package/packages/tools/dist/compression/rules/lint.d.ts +11 -0
  36. package/packages/tools/dist/compression/rules/lint.js +3 -0
  37. package/packages/tools/dist/compression/rules/npm.d.ts +11 -0
  38. package/packages/tools/dist/compression/rules/npm.js +3 -0
  39. package/packages/tools/dist/compression/rules/test-runner.d.ts +11 -0
  40. package/packages/tools/dist/compression/rules/test-runner.js +3 -0
  41. package/packages/tools/dist/compression/scoring.d.ts +26 -0
  42. package/packages/tools/dist/compression/scoring.js +1 -0
  43. package/packages/tools/dist/compression/types.d.ts +61 -0
  44. package/packages/tools/dist/compression/types.js +1 -0
  45. package/packages/tools/dist/digest.d.ts +5 -0
  46. package/packages/tools/dist/digest.js +4 -4
  47. package/packages/tools/dist/index.d.ts +5 -1
  48. package/packages/tools/dist/index.js +1 -1
  49. package/packages/tools/dist/parse-output.d.ts +3 -1
  50. package/packages/tools/dist/parse-output.js +1 -1
  51. package/packages/tools/dist/truncation.d.ts +34 -1
  52. package/packages/tools/dist/truncation.js +10 -6
  53. package/packages/tui/dist/{App-DpjN3iS-.js → App-D8fednPY.js} +1 -1
  54. package/packages/tui/dist/App.js +1 -1
  55. package/packages/tui/dist/{CuratedPanel-BIamXLNy.js → CuratedPanel-BwkPKdX4.js} +1 -1
  56. package/packages/tui/dist/LogPanel-C6KagE0H.js +3320 -0
  57. package/packages/tui/dist/{SearchPanel-CpJGczAc.js → SearchPanel-BbvCaco0.js} +1 -1
  58. package/packages/tui/dist/{StatusPanel-BAbUxyqQ.js → StatusPanel-BFshFJU9.js} +1 -1
  59. package/packages/tui/dist/chunk-BSngPjfM.js +2 -0
  60. package/packages/tui/dist/{devtools-DMOZMn70.js → devtools-owCrRz12.js} +2 -2
  61. package/packages/tui/dist/hooks/useKBClient.js +1 -1
  62. package/packages/tui/dist/hooks/usePolling.js +1 -1
  63. package/packages/tui/dist/index.js +1 -1
  64. package/packages/tui/dist/{jsx-runtime-y6Gdq5PZ.js → jsx-runtime-B_2ewjsM.js} +7 -7
  65. package/packages/tui/dist/panels/CuratedPanel.js +1 -1
  66. package/packages/tui/dist/panels/LogPanel.js +1 -1
  67. package/packages/tui/dist/panels/SearchPanel.js +1 -1
  68. package/packages/tui/dist/panels/StatusPanel.js +1 -1
  69. package/packages/tui/dist/{react-D__J1GQe.js → react-sYq8CyFO.js} +1 -1
  70. package/packages/tui/dist/{useKBClient-C35iA4uG.js → useKBClient-BkBffCdd.js} +1 -1
  71. package/packages/tui/dist/{usePolling-BbjnRWgx.js → usePolling-D3y7u5cZ.js} +1 -1
  72. package/scaffold/adapters/copilot.mjs +4 -1
  73. package/scaffold/definitions/agents.mjs +32 -8
  74. package/scaffold/definitions/bodies.mjs +6 -2
  75. package/scaffold/definitions/protocols.mjs +12 -0
  76. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +7 -0
  77. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +7 -0
  78. package/scaffold/general/agents/Debugger.agent.md +7 -0
  79. package/scaffold/general/agents/Documenter.agent.md +1 -0
  80. package/scaffold/general/agents/Explorer.agent.md +6 -0
  81. package/scaffold/general/agents/Frontend.agent.md +9 -0
  82. package/scaffold/general/agents/Implementer.agent.md +7 -0
  83. package/scaffold/general/agents/Orchestrator.agent.md +35 -51
  84. package/scaffold/general/agents/README.md +3 -3
  85. package/scaffold/general/agents/Refactor.agent.md +1 -0
  86. package/scaffold/general/agents/Researcher-Beta.agent.md +2 -2
  87. package/scaffold/general/agents/Researcher-Delta.agent.md +2 -2
  88. package/scaffold/general/agents/Researcher-Gamma.agent.md +2 -2
  89. package/scaffold/general/agents/Security.agent.md +7 -0
  90. package/scaffold/general/agents/_shared/code-agent-base.md +38 -18
  91. package/scaffold/general/skills/aikit/SKILL.md +73 -1
  92. package/packages/tui/dist/LogPanel-Db-SeZhR.js +0 -3
  93. package/packages/tui/dist/chunk-D6axbAb-.js +0 -2
@@ -0,0 +1,20 @@
1
+ //#region packages/tools/src/compression/litm.d.ts
2
+ /**
3
+ * LITM-aware block positioning for multi-source digest.
4
+ * Liu et al. TACL 2024: LLMs attend more to start and end positions.
5
+ * Re-orders source blocks so highest-relevance sources appear at edges.
6
+ */
7
+ interface ScoredBlock {
8
+ id: string;
9
+ text: string;
10
+ /** Maximum segment score for this source block */
11
+ maxScore: number;
12
+ }
13
+ /**
14
+ * Reorder source blocks using bookend (U-curve) positioning.
15
+ * Highest-scoring blocks placed at start and end positions.
16
+ * Input order is preserved for blocks with equal scores.
17
+ */
18
+ declare function reorderBlocksLITM(blocks: ScoredBlock[]): ScoredBlock[];
19
+ //#endregion
20
+ export { ScoredBlock, reorderBlocksLITM };
@@ -0,0 +1 @@
1
+ function e(e){if(e.length<=2)return e;let t=[...e].sort((e,t)=>t.maxScore-e.maxScore),n=Array(t.length),r=0,i=t.length-1;for(let e=0;e<t.length;e++)e%2==0?n[r++]=t[e]:n[i--]=t[e];return n}export{e as reorderBlocksLITM};
@@ -0,0 +1,24 @@
1
+ //#region packages/tools/src/compression/mmr.d.ts
2
+ /**
3
+ * MMR (Maximal Marginal Relevance) deduplication for digest segments.
4
+ * Prevents near-identical segments from consuming budget.
5
+ * Uses bigram Jaccard similarity for fast structural comparison.
6
+ */
7
+ interface MMRCandidate {
8
+ index: number;
9
+ text: string;
10
+ /** Query relevance score (0-1) */
11
+ relevance: number;
12
+ }
13
+ /**
14
+ * Select segments using MMR to balance relevance and diversity.
15
+ *
16
+ * @param candidates - Segments with their relevance scores
17
+ * @param lambda - Trade-off: 1.0 = pure relevance, 0.0 = pure diversity (default: 0.7)
18
+ * @param maxItems - Maximum items to select (default: all)
19
+ * @param safetyThreshold - Segments above this relevance are always kept (default: 0.8)
20
+ * @returns Selected candidates in MMR order
21
+ */
22
+ declare function mmrSelect(candidates: MMRCandidate[], lambda?: number, maxItems?: number, safetyThreshold?: number): MMRCandidate[];
23
+ //#endregion
24
+ export { MMRCandidate, mmrSelect };
@@ -0,0 +1 @@
1
+ function e(e){let t=new Set,n=e.toLowerCase().replace(/\s+/g,` `);for(let e=0;e<n.length-1;e++)t.add(n.slice(e,e+2));return t}function t(e,t){if(e.size===0&&t.size===0)return 1;let n=0;for(let r of e)t.has(r)&&n++;let r=e.size+t.size-n;return r===0?0:n/r}function n(n,r=.7,i,a=.8){if(n.length===0)return[];let o=i??n.length,s=[],c=[],l=new Set(n.map((e,t)=>t)),u=n.map(t=>e(t.text));for(;s.length<o&&l.size>0;){let e=-1,i=-1/0;for(let o of l){let l=n[o];if(l.relevance>=a&&s.length===0){e=o;break}let d=0;for(let e of c){let n=t(u[o],e);n>d&&(d=n)}let f=r*l.relevance-(1-r)*d;f>i&&(i=f,e=o)}if(e===-1)break;s.push(n[e]),c.push(u[e]),l.delete(e)}return s}export{n as mmrSelect};
@@ -0,0 +1,11 @@
1
+ import { CompressionRule } from "../types.js";
2
+
3
+ //#region packages/tools/src/compression/rules/docker.d.ts
4
+ /**
5
+ * Compression rule for Docker build/run output.
6
+ * Preserves: build errors, final image info, layer cache hits.
7
+ * Collapses: download progress, intermediate steps.
8
+ */
9
+ declare const dockerRule: CompressionRule;
10
+ //#endregion
11
+ export { dockerRule };
@@ -0,0 +1,3 @@
1
+ const e={name:`docker`,toolPatterns:[`docker`],priority:8,match(e){return e.tool===`docker`},compress(e){let t=e.text.split(`
2
+ `),n=[],r=0,i=0;for(let e of t){if(e.match(/^(ERROR|error|Error|WARNING|SECURITY)/i)||e.includes(`failed`)){n.push(e);continue}if(e.match(/^Step \d+\/\d+\s*:/)){n.push(e);continue}if(e.match(/^\s*(FROM|RUN|COPY|ADD|WORKDIR|ENV|EXPOSE|CMD|ENTRYPOINT)\s/i)){n.push(e);continue}if(e.includes(`CACHED`)||e.includes(`Using cache`)){r++;continue}if(e.match(/^[a-f0-9]+:\s*(Pull|Download|Extract|Waiting|Verifying)/)){i++;continue}if(e.match(/^(Successfully|sha256:|REPOSITORY|IMAGE ID|CONTAINER ID)/)){n.push(e);continue}if(e.match(/^\S{12}\s+\S+/)&&!e.match(/^[a-f0-9]+:/)){n.push(e);continue}e.match(/^#\d+\s/)&&n.push(e)}return r>0&&n.push(`[${r} cached layers]`),i>0&&n.push(`[${i} download/extract operations]`),n.join(`
3
+ `)}};export{e as dockerRule};
@@ -0,0 +1,11 @@
1
+ import { CompressionRule } from "../types.js";
2
+
3
+ //#region packages/tools/src/compression/rules/generic.d.ts
4
+ /**
5
+ * Generic compression rule — lowest priority fallback.
6
+ * Handles: dedup repeated lines, collapse blank lines, smart truncation.
7
+ * Applied when no specific tool rule matches.
8
+ */
9
+ declare const genericRule: CompressionRule;
10
+ //#endregion
11
+ export { genericRule };
@@ -0,0 +1,3 @@
1
+ const e={name:`generic`,toolPatterns:[/.*/],priority:0,match(e){return e.tool===`unknown`||!e.tool},compress(e){let t=e.text.split(`
2
+ `),n=[],r=``,i=0,a=0;for(let e of t){let t=e.trim();if(t===``){a++,a<=1&&n.push(``);continue}if(a=0,t===r.trim()){i++;continue}i>0&&(n.push(` [repeated ${i} more times]`),i=0),r=e,n.push(e)}return i>0&&n.push(` [repeated ${i} more times]`),n.join(`
3
+ `)}};export{e as genericRule};
@@ -0,0 +1,11 @@
1
+ import { CompressionRule } from "../types.js";
2
+
3
+ //#region packages/tools/src/compression/rules/git.d.ts
4
+ /**
5
+ * Compression rule for git diff and git log output.
6
+ * Preserves: file list, +/- stats, error messages.
7
+ * Collapses: hunk bodies, repeated context lines.
8
+ */
9
+ declare const gitRule: CompressionRule;
10
+ //#endregion
11
+ export { gitRule };
@@ -0,0 +1,3 @@
1
+ const e={name:`git`,toolPatterns:[`git`,`git-status`],priority:10,match(e){return e.tool===`git`||e.tool===`git-status`},compress(e){let t=e.text.split(`
2
+ `),n=[],r=!1,i=0,a=0,o=``;for(let s of t){if(s.startsWith(`diff --git`)||s.startsWith(`---`)||s.startsWith(`+++`)){r&&(i>0||a>0)&&n.push(` [${i}+ ${a}- lines in ${o}]`),r=!1,i=0,a=0,n.push(s),s.startsWith(`diff --git`)&&(o=s.replace(/^diff --git a\/\S+ b\//,``));continue}if(s.startsWith(`@@`)){r&&(i>0||a>0)&&n.push(` [${i}+ ${a}- lines]`),r=!0,i=0,a=0,n.push(s);continue}if(e.tool===`git-status`){n.push(s);continue}if(r){s.startsWith(`+`)?i++:s.startsWith(`-`)&&a++;continue}if(s.startsWith(`commit `)||s.startsWith(`Author:`)||s.startsWith(`Date:`)||s.startsWith(`On branch`)||s.match(/^\s*\d+ file/)||s.match(/insertion|deletion/)){n.push(s);continue}if(s.startsWith(`error:`)||s.startsWith(`fatal:`)||s.startsWith(`warning:`)){n.push(s);continue}/^\s{4}\S/.test(s)&&n.push(s)}return r&&(i>0||a>0)&&n.push(` [${i}+ ${a}- lines in ${o}]`),n.join(`
3
+ `)}};export{e as gitRule};
@@ -0,0 +1,14 @@
1
+ import { CompressionRule } from "../types.js";
2
+ import { dockerRule } from "./docker.js";
3
+ import { genericRule } from "./generic.js";
4
+ import { gitRule } from "./git.js";
5
+ import { kubectlRule } from "./kubectl.js";
6
+ import { lintRule } from "./lint.js";
7
+ import { npmRule } from "./npm.js";
8
+ import { testRunnerRule } from "./test-runner.js";
9
+
10
+ //#region packages/tools/src/compression/rules/index.d.ts
11
+ /** All built-in compression rules */
12
+ declare const allRules: CompressionRule[];
13
+ //#endregion
14
+ export { allRules, dockerRule, genericRule, gitRule, kubectlRule, lintRule, npmRule, testRunnerRule };
@@ -0,0 +1 @@
1
+ import{registerRules as e}from"../engine.js";import{dockerRule as t}from"./docker.js";import{genericRule as n}from"./generic.js";import{gitRule as r}from"./git.js";import{kubectlRule as i}from"./kubectl.js";import{lintRule as a}from"./lint.js";import{npmRule as o}from"./npm.js";import{testRunnerRule as s}from"./test-runner.js";const c=[r,o,s,a,t,i,n];e(c);export{c as allRules,t as dockerRule,n as genericRule,r as gitRule,i as kubectlRule,a as lintRule,o as npmRule,s as testRunnerRule};
@@ -0,0 +1,11 @@
1
+ import { CompressionRule } from "../types.js";
2
+
3
+ //#region packages/tools/src/compression/rules/kubectl.d.ts
4
+ /**
5
+ * Compression rule for kubectl/Kubernetes output.
6
+ * Preserves: pod statuses, error events, resource summaries.
7
+ * Collapses: normal events, verbose resource details.
8
+ */
9
+ declare const kubectlRule: CompressionRule;
10
+ //#endregion
11
+ export { kubectlRule };
@@ -0,0 +1,3 @@
1
+ const e={name:`kubectl`,toolPatterns:[`kubectl`,`k8s`],priority:8,match(e){return e.tool===`kubectl`},compress(e){let t=e.text.split(`
2
+ `),n=[],r=0;for(let e of t){if(e.match(/^(NAME|NAMESPACE|LAST SEEN|TYPE)\s+/)){n.push(e);continue}if(e.match(/\b(Warning|Error|Failed|CrashLoopBackOff|OOMKilled|Evicted|Pending)\b/i)){n.push(e);continue}if(e.match(/^\S+\s+\d+\/\d+\s+(Running|Error|CrashLoop|Pending|Completed|Terminating)/)){n.push(e);continue}if(e.match(/^\d+[smhd]\s+.*Normal\s/)){r++;continue}e.match(/^\S+\s+/)&&e.trim().length>0&&n.push(e)}return r>0&&n.push(`[${r} normal events]`),n.join(`
3
+ `)}};export{e as kubectlRule};
@@ -0,0 +1,11 @@
1
+ import { CompressionRule } from "../types.js";
2
+
3
+ //#region packages/tools/src/compression/rules/lint.d.ts
4
+ /**
5
+ * Compression rule for linter output (ESLint, Biome, tsc errors, etc.).
6
+ * Preserves: error locations, error messages grouped by severity.
7
+ * Collapses: passing files, verbose context.
8
+ */
9
+ declare const lintRule: CompressionRule;
10
+ //#endregion
11
+ export { lintRule };
@@ -0,0 +1,3 @@
1
+ const e={name:`lint`,toolPatterns:[`lint`,`tsc`,`eslint`,`biome`],priority:10,match(e){return e.tool===`lint`||e.tool===`tsc`},compress(e){let t=e.text.split(`
2
+ `),n=[],r=[],i=0;for(let e of t){if(e.match(/:\d+:\d+\s+error\b/i)||e.match(/^error\s+TS\d+/)){n.push(e);continue}if(e.match(/:\d+:\d+\s+warning\b/i)||e.match(/^warning\s+TS\d+/)){r.push(e);continue}if(e.match(/:\d+:\d+\s+(info|hint)\b/i)){i++;continue}if(e.match(/Found \d+|✖\s+\d+|errors?\s+and\s+\d+\s+warning|problems?.*error/i)){n.push(e);continue}e.match(/^\s*\d+ error/)&&n.push(e)}let a=[];return n.length>0&&(a.push(`=== ERRORS (${n.length}) ===`),a.push(...n.slice(0,30)),n.length>30&&a.push(`[${n.length-30} more errors]`)),r.length>0&&(a.push(`=== WARNINGS (${r.length}) ===`),a.push(...r.slice(0,10)),r.length>10&&a.push(`[${r.length-10} more warnings]`)),i>0&&a.push(`[${i} info/hint messages]`),a.length===0&&a.push(`[No errors or warnings found]`),a.join(`
3
+ `)}};export{e as lintRule};
@@ -0,0 +1,11 @@
1
+ import { CompressionRule } from "../types.js";
2
+
3
+ //#region packages/tools/src/compression/rules/npm.d.ts
4
+ /**
5
+ * Compression rule for npm/pnpm/yarn output.
6
+ * Preserves: errors, warnings summary, added/removed counts.
7
+ * Collapses: progress bars, individual package names, verbose logs.
8
+ */
9
+ declare const npmRule: CompressionRule;
10
+ //#endregion
11
+ export { npmRule };
@@ -0,0 +1,3 @@
1
+ const e={name:`npm`,toolPatterns:[`npm`,`pnpm`,`yarn`],priority:10,match(e){return e.tool===`npm`||e.tool===`pnpm`},compress(e){let t=e.text.split(`
2
+ `),n=[],r=0,i=0,a=[];for(let e of t){if(e.includes(`ERR!`)||e.startsWith(`npm error`)||e.includes(`ERESOLVE`)){a.push(e);continue}if(e.includes(`npm warn`)||e.includes(`WARN`)){r++,r<=3&&n.push(e);continue}if(e.includes(`notice`)){i++;continue}if(!(e.includes(`timing`)||e.includes(`http fetch`)||/^\s*$/.test(e))){if(e.match(/^(added|removed|changed|up to date|audited|found \d+)/)){n.push(e);continue}if(e.match(/^(Packages:|Progress:|Done in|dependencies:)/)){n.push(e);continue}e.match(/^(>|\$)\s/)&&n.push(e)}}return r>3&&n.push(`[${r-3} more warnings]`),i>0&&n.push(`[${i} notices]`),a.length>0&&(n.unshift(`=== ERRORS ===`),n.splice(1,0,...a)),n.join(`
3
+ `)}};export{e as npmRule};
@@ -0,0 +1,11 @@
1
+ import { CompressionRule } from "../types.js";
2
+
3
+ //#region packages/tools/src/compression/rules/test-runner.d.ts
4
+ /**
5
+ * Compression rule for test runner output (vitest, jest, mocha, etc.).
6
+ * Preserves: test failures with stack traces, summary line.
7
+ * Collapses: passing tests into count, verbose watch output.
8
+ */
9
+ declare const testRunnerRule: CompressionRule;
10
+ //#endregion
11
+ export { testRunnerRule };
@@ -0,0 +1,3 @@
1
+ const e={name:`test-runner`,toolPatterns:[`test-runner`,`vitest`,`jest`,`mocha`],priority:10,match(e){return e.tool===`test-runner`},compress(e){let t=e.text.split(`
2
+ `),n=[],r=0,i=!1,a=[];for(let e of t){if(e.match(/Tests?\s+\d+\s+(passed|failed)|Test Suites:|test.*files?|Duration/i)){n.push(e);continue}if(e.match(/^(FAIL|✗|×|✖)\s/)||e.match(/^\s*(FAIL|Error|AssertionError)/)){i&&a.length>0&&n.push(...a),i=!0,a=[e];continue}if(i){if(e.match(/^\s+(at\s|Expected|Received|>\s|\d+\s*\||⎯|─)/)||e.trim().length===0){a.length<12&&a.push(e);continue}n.push(...a),i=!1,a=[]}if(e.match(/^(PASS|✓|✔|√)\s/)||e.match(/^\s*✓\s/)){r++;continue}if(e.match(/^\s*(PASS|FAIL|RUN)\s+\S+\.(test|spec)\./)){n.push(e);continue}e.match(/^(Rerun|Watch|press|Waiting|stdout)/)||e.trim()}return i&&a.length>0&&n.push(...a),r>0&&n.unshift(`[${r} tests passed]`),n.join(`
3
+ `)}};export{e as testRunnerRule};
@@ -0,0 +1,26 @@
1
+ //#region packages/tools/src/compression/scoring.d.ts
2
+ /**
3
+ * Score a line of text by BPE token density (surprise).
4
+ * Higher score = more information-dense content.
5
+ * Range: 0.0 to 1.0
6
+ */
7
+ declare function bpeSurprise(line: string): number;
8
+ /**
9
+ * Score text lines with composite BPE surprise scoring.
10
+ * Combines token density with rare token frequency.
11
+ *
12
+ * @param lines - Array of text lines to score
13
+ * @returns Array of scores (0.0 to 1.0) in same order as input
14
+ */
15
+ declare function scoreLines(lines: string[]): number[];
16
+ /**
17
+ * Fallback scoring using Shannon character entropy.
18
+ * Used when BPE tokenizer is unavailable.
19
+ */
20
+ declare function shannonEntropy(text: string): number;
21
+ /**
22
+ * Score a single line with fallback to entropy if BPE fails.
23
+ */
24
+ declare function scoreLine(line: string): number;
25
+ //#endregion
26
+ export { bpeSurprise, scoreLine, scoreLines, shannonEntropy };
@@ -0,0 +1 @@
1
+ import{encode as e}from"gpt-tokenizer/model/gpt-4o";const t=.6;function n(n){if(!n||n.length===0)return 0;let r=e(n),i=n.length;return i===0?0:Math.min(r.length/i,t)/t}function r(n){if(n.length===0)return[];let r=new Map,i=[];for(let t of n){let n=e(t);i.push(n);for(let e of n)r.set(e,(r.get(e)??0)+1)}let a=[];for(let e=0;e<n.length;e++){let o=n[e],s=i[e];if(!o||s.length===0){a.push(0);continue}let c=Math.min(s.length/o.length,t)/t,l=0;for(let e of s)(r.get(e)??0)===1&&l++;let u=l/s.length,d=.6*c+.4*u;a.push(Math.min(d,1))}return a}function i(e){if(!e||e.length===0)return 0;let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let n=0,r=e.length;for(let e of t.values()){let t=e/r;t>0&&(n-=t*Math.log2(t))}return Math.min(n/6.6,1)}function a(e){try{return n(e)}catch{return i(e)}}export{n as bpeSurprise,a as scoreLine,r as scoreLines,i as shannonEntropy};
@@ -0,0 +1,61 @@
1
+ //#region packages/tools/src/compression/types.d.ts
2
+ /**
3
+ * Compression mode determines how aggressively output is compressed.
4
+ */
5
+ type CompressionMode = 'structural' | 'heuristic' | 'aggressive';
6
+ /**
7
+ * Context provided to compression rules for matching and processing.
8
+ */
9
+ interface CompressionContext {
10
+ /** Raw output text (ANSI already stripped) */
11
+ text: string;
12
+ /** Detected tool/source (e.g., 'git', 'npm', 'vitest', 'docker') */
13
+ tool: string;
14
+ /** Compression mode */
15
+ mode: CompressionMode;
16
+ /** Maximum output characters */
17
+ maxChars: number;
18
+ /** Original character count before any processing */
19
+ originalChars: number;
20
+ }
21
+ /**
22
+ * Result from applying a compression rule.
23
+ */
24
+ interface CompressionResult {
25
+ /** Compressed text */
26
+ text: string;
27
+ /** Original character count */
28
+ originalChars: number;
29
+ /** Compressed character count */
30
+ compressedChars: number;
31
+ /** Compression ratio (compressed / original) */
32
+ ratio: number;
33
+ /** Which rule was applied */
34
+ rule: string;
35
+ /** Detected tool */
36
+ tool: string;
37
+ /** Metadata about the compression */
38
+ _meta: {
39
+ truncated: boolean;
40
+ mode: CompressionMode;
41
+ sectionsKept?: number;
42
+ sectionsTotal?: number;
43
+ };
44
+ }
45
+ /**
46
+ * A compression rule that can match and process specific output formats.
47
+ */
48
+ interface CompressionRule {
49
+ /** Unique rule name */
50
+ name: string;
51
+ /** Tool patterns this rule handles (regex or string) */
52
+ toolPatterns: (string | RegExp)[];
53
+ /** Priority (higher = checked first, default 0) */
54
+ priority: number;
55
+ /** Test if this rule can handle the given context */
56
+ match(ctx: CompressionContext): boolean;
57
+ /** Apply compression and return result text */
58
+ compress(ctx: CompressionContext): string;
59
+ }
60
+ //#endregion
61
+ export { CompressionContext, CompressionMode, CompressionResult, CompressionRule };
@@ -0,0 +1 @@
1
+ export{};
@@ -20,6 +20,11 @@ interface DigestOptions {
20
20
  pinFields?: string[];
21
21
  /** Segmentation strategy (default: 'paragraph') */
22
22
  segmentation?: 'paragraph' | 'sentence' | 'line';
23
+ /**
24
+ * Enable MMR deduplication across segments (default: true).
25
+ * Prevents near-identical segments from consuming budget.
26
+ */
27
+ dedup?: boolean;
23
28
  }
24
29
  interface DigestFieldEntry {
25
30
  sourceId: string;
@@ -1,6 +1,6 @@
1
- import{cosineSimilarity as e,estimateTokens as t,segment as n}from"./text-utils.js";const r=[`status`,`files`,`decisions`,`blockers`,`artifacts`,`next`],i={status:/\b(?:status|result)\s*[:=]/i,files:/\b(?:files?|modified|created|deleted)\s*[:=]/i,artifacts:/\b(?:artifacts?)\s*[:=]/i,decisions:/\b(?:decisions?|decided|chose|selected)\s*[:=]/i,blockers:/\b(?:blockers?|blocked|blocking)\s*[:=]/i,next:/\b(?:next\s*(?:steps?|actions?)|todo|follow.up)\s*[:=]/i},a={status:/(?:^|\b)(?:status|result)\s*[:=]\s*(.+)$/i,files:/(?:^|\b)(?:files?|modified|created|deleted)\s*[:=]\s*(.+)$/i,artifacts:/(?:^|\b)(?:artifacts?)\s*[:=]\s*(.+)$/i,decisions:/(?:^|\b)(?:decisions?|decided|chose|selected)\s*[:=]\s*(.+)$/i,blockers:/(?:^|\b)(?:blockers?|blocked|blocking)\s*[:=]\s*(.+)$/i,next:/(?:^|\b)(?:next\s*(?:steps?|actions?)|todo|follow.up)\s*[:=]\s*(.+)$/i},o=/\b(?:APPROVED|NEEDS_REVISION|BLOCKED|SUCCESS|PARTIAL|FAILED|ESCALATE)\b/i,s=.01;function c(e){let t=e??[...r];return[...new Set(t.map(e=>e.toLowerCase()))]}function l(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?1:e}function u(e,t){let n=new Set;for(let r of t)i[r]?.test(e)&&n.add(r);return t.includes(`status`)&&o.test(e)&&n.add(`status`),[...n]}function d(e,t){let n=t.split(`
2
- `).map(e=>e.trim()).filter(e=>e.length>0);for(let t of n){let n=a[e]?.exec(t);if(n?.[1])return n[1].trim();if(e===`status`){let e=t.match(o);if(e)return e[0]}}return t.trim()}function f(e,t,n,r){e[t]||(e[t]=[]),e[t].push({sourceId:n,value:r})}function p(e,t,r,i){return e.map(e=>{let a=n(e.text,t).map((t,n)=>{let a=u(t,r);for(let n of a)f(i,n,e.id,d(n,t));return{index:n,text:t,pinnedFields:a,score:0}}),o=a.filter(e=>e.pinnedFields.length>0).reduce((e,t)=>e+t.text.length,0),s=a.filter(e=>e.pinnedFields.length===0).reduce((e,t)=>e+t.text.length,0);return{id:e.id,originalText:e.text,weight:l(e.weight),segments:a,pinnedChars:o,nonPinnedChars:s}})}function m(e,t){let n=new Map(e.map(e=>[e.id,0])),r=Math.max(0,t),i=e.filter(e=>e.nonPinnedChars>0);for(;r>s&&i.length>0;){let e=i.reduce((e,t)=>e+t.weight,0),t=0,a=[];for(let o of i){let i=n.get(o.id)??0,c=o.nonPinnedChars-i;if(c<=s)continue;let l=r*(o.weight/e),u=Math.min(l,c);n.set(o.id,i+u),t+=u,c-u>s&&a.push(o)}if(t<=s)break;r-=t,i=a}return n}function h(e){return e.map(e=>`[${e.id}]\n${e.text}`).join(`
1
+ import{cosineSimilarity as e,estimateTokens as t,segment as n}from"./text-utils.js";import{reorderBlocksLITM as r}from"./compression/litm.js";import{mmrSelect as i}from"./compression/mmr.js";const a=[`status`,`files`,`decisions`,`blockers`,`artifacts`,`next`],o={status:/\b(?:status|result)\s*[:=]/i,files:/\b(?:files?|modified|created|deleted)\s*[:=]/i,artifacts:/\b(?:artifacts?)\s*[:=]/i,decisions:/\b(?:decisions?|decided|chose|selected)\s*[:=]/i,blockers:/\b(?:blockers?|blocked|blocking)\s*[:=]/i,next:/\b(?:next\s*(?:steps?|actions?)|todo|follow.up)\s*[:=]/i},s={status:/(?:^|\b)(?:status|result)\s*[:=]\s*(.+)$/i,files:/(?:^|\b)(?:files?|modified|created|deleted)\s*[:=]\s*(.+)$/i,artifacts:/(?:^|\b)(?:artifacts?)\s*[:=]\s*(.+)$/i,decisions:/(?:^|\b)(?:decisions?|decided|chose|selected)\s*[:=]\s*(.+)$/i,blockers:/(?:^|\b)(?:blockers?|blocked|blocking)\s*[:=]\s*(.+)$/i,next:/(?:^|\b)(?:next\s*(?:steps?|actions?)|todo|follow.up)\s*[:=]\s*(.+)$/i},c=/\b(?:APPROVED|NEEDS_REVISION|BLOCKED|SUCCESS|PARTIAL|FAILED|ESCALATE)\b/i,l=.01;function u(e){let t=e??[...a];return[...new Set(t.map(e=>e.toLowerCase()))]}function d(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?1:e}function f(e,t){let n=new Set;for(let r of t)o[r]?.test(e)&&n.add(r);return t.includes(`status`)&&c.test(e)&&n.add(`status`),[...n]}function p(e,t){let n=t.split(`
2
+ `).map(e=>e.trim()).filter(e=>e.length>0);for(let t of n){let n=s[e]?.exec(t);if(n?.[1])return n[1].trim();if(e===`status`){let e=t.match(c);if(e)return e[0]}}return t.trim()}function m(e,t,n,r){e[t]||(e[t]=[]),e[t].push({sourceId:n,value:r})}function h(e,t,r,i){return e.map(e=>{let a=n(e.text,t).map((t,n)=>{let a=f(t,r);for(let n of a)m(i,n,e.id,p(n,t));return{index:n,text:t,pinnedFields:a,score:0}}),o=a.filter(e=>e.pinnedFields.length>0).reduce((e,t)=>e+t.text.length,0),s=a.filter(e=>e.pinnedFields.length===0).reduce((e,t)=>e+t.text.length,0);return{id:e.id,originalText:e.text,weight:d(e.weight),segments:a,pinnedChars:o,nonPinnedChars:s}})}function g(e,t){let n=new Map(e.map(e=>[e.id,0])),r=Math.max(0,t),i=e.filter(e=>e.nonPinnedChars>0);for(;r>l&&i.length>0;){let e=i.reduce((e,t)=>e+t.weight,0),t=0,a=[];for(let o of i){let i=n.get(o.id)??0,s=o.nonPinnedChars-i;if(s<=l)continue;let c=r*(o.weight/e),u=Math.min(c,s);n.set(o.id,i+u),t+=u,s-u>l&&a.push(o)}if(t<=l)break;r-=t,i=a}return n}function _(e){return e.map(e=>`[${e.id}]\n${e.text}`).join(`
3
3
 
4
- `)}function g(e,t){return e===0?0:t/e}async function _(n,r){let{sources:i,query:a,maxChars:o=4e3,pinFields:l,segmentation:u=`paragraph`}=r,d={},f=p(i,u,c(l),d),_=i.reduce((e,t)=>e+t.text.length,0);if(_<=o){let e=f.filter(e=>e.originalText.trim().length>0).map(e=>({id:e.id,text:e.originalText})),t=f.map(e=>({id:e.id,originalChars:e.originalText.length,keptChars:e.originalText.length,segmentsKept:e.segments.length,segmentsTotal:e.segments.length}));return{text:h(e),fields:d,sourceStats:t,totalOriginalChars:_,totalCompressedChars:_,ratio:_===0?0:1}}let v=await n.embedQuery(a);for(let t of f)for(let r of t.segments)r.pinnedFields.length>0||(r.score=e(v,await n.embed(r.text)));let y=m(f,o-f.reduce((e,t)=>e+t.pinnedChars,0)),b=[],x=[],S=0;for(let e of f){let n=y.get(e.id)??0,r=new Map,i=0,a=e.segments.filter(e=>e.pinnedFields.length===0).sort((e,n)=>n.score-e.score||t(e.text)-t(n.text)||e.index-n.index),o;for(let e of a){let t=n-i;if(t<=s)break;if(e.text.length<=t+s){r.set(e.index,e.text),i+=e.text.length;continue}o||=e}let c=Math.floor(n-i);if(o&&c>0){let e=o.text.slice(0,c).trimEnd();e.length>0&&(r.set(o.index,e),i+=e.length)}let l=e.segments.filter(e=>e.pinnedFields.length>0||r.has(e.index)).map(e=>({index:e.index,text:r.get(e.index)??e.text})),u=l.reduce((e,t)=>e+t.text.length,0);b.push({id:e.id,originalChars:e.originalText.length,keptChars:u,segmentsKept:l.length,segmentsTotal:e.segments.length}),S+=u,l.length!==0&&x.push({id:e.id,text:l.map(e=>e.text).join(`
4
+ `)}function v(e,t){return e===0?0:t/e}async function y(n,a){let{sources:o,query:s,maxChars:c=4e3,pinFields:d,segmentation:f=`paragraph`}=a,p={},m=h(o,f,u(d),p),y=o.reduce((e,t)=>e+t.text.length,0);if(y<=c){let e=m.filter(e=>e.originalText.trim().length>0).map(e=>({id:e.id,text:e.originalText})),t=m.map(e=>({id:e.id,originalChars:e.originalText.length,keptChars:e.originalText.length,segmentsKept:e.segments.length,segmentsTotal:e.segments.length}));return{text:_(e),fields:p,sourceStats:t,totalOriginalChars:y,totalCompressedChars:y,ratio:y===0?0:1}}let b=await n.embedQuery(s);for(let t of m)for(let r of t.segments)r.pinnedFields.length>0||(r.score=e(b,await n.embed(r.text)));let x=g(m,c-m.reduce((e,t)=>e+t.pinnedChars,0)),S=[],C=[],w=0;for(let e of m){let n=x.get(e.id)??0,r=new Map,o=0,s=e.segments.filter(e=>e.pinnedFields.length===0).sort((e,n)=>n.score-e.score||t(e.text)-t(n.text)||e.index-n.index);if(a.dedup!==!1&&s.length>1){let e=i(s.map(e=>({index:e.index,text:e.text,relevance:e.score}))),t=new Set(e.map(e=>e.index));s=s.filter(e=>t.has(e.index))}let c;for(let e of s){let t=n-o;if(t<=l)break;if(e.text.length<=t+l){r.set(e.index,e.text),o+=e.text.length;continue}c||=e}let u=Math.floor(n-o);if(c&&u>0){let e=c.text.slice(0,u).trimEnd();e.length>0&&(r.set(c.index,e),o+=e.length)}let d=e.segments.filter(e=>e.pinnedFields.length>0||r.has(e.index)).map(e=>({index:e.index,text:r.get(e.index)??e.text})),f=d.reduce((e,t)=>e+t.text.length,0);S.push({id:e.id,originalChars:e.originalText.length,keptChars:f,segmentsKept:d.length,segmentsTotal:e.segments.length}),w+=f,d.length!==0&&C.push({id:e.id,text:d.map(e=>e.text).join(`
5
5
 
6
- `)})}return{text:h(x),fields:d,sourceStats:b,totalOriginalChars:_,totalCompressedChars:S,ratio:g(_,S)}}export{_ as digest};
6
+ `)})}return{text:_(r(C.map(e=>{let t=m.find(t=>t.id===e.id),n=t?Math.max(0,...t.segments.map(e=>e.score)):0;return{...e,maxScore:n}}))),fields:p,sourceStats:S,totalOriginalChars:y,totalCompressedChars:w,ratio:v(y,w)}}export{y as digest};
@@ -8,6 +8,10 @@ import { Checkpoint, checkpointLatest, checkpointList, checkpointLoad, checkpoin
8
8
  import { CodemodChange, CodemodOptions, CodemodResult, CodemodRule, codemod } from "./codemod.js";
9
9
  import { FileCache, FileCacheEntry, FileCacheStats } from "./file-cache.js";
10
10
  import { CompactOptions, CompactResult, compact } from "./compact.js";
11
+ import { CompressionContext, CompressionMode, CompressionResult, CompressionRule } from "./compression/types.js";
12
+ import { compressOutput, detectOutputTool, getRegisteredRules, registerRule, registerRules } from "./compression/engine.js";
13
+ import { CompressOutputOptions, compressTerminalOutput } from "./compress-output.js";
14
+ import { bpeSurprise, scoreLine, scoreLines, shannonEntropy } from "./compression/scoring.js";
11
15
  import { TransformOptions, TransformResult, dataTransform } from "./data-transform.js";
12
16
  import { DeadSymbol, DeadSymbolOptions, DeadSymbolResult, findDeadSymbols } from "./dead-symbols.js";
13
17
  import { DelegateOptions, DelegateResult, delegate, delegateListModels } from "./delegate.js";
@@ -54,4 +58,4 @@ import { WatchEvent, WatchHandle, WatchOptions, watchList, watchStart, watchStop
54
58
  import { WebFetchMode, WebFetchOptions, WebFetchResult, webFetch } from "./web-fetch.js";
55
59
  import { WebSearchOptions, WebSearchResult, WebSearchResultItem, parseSearchResults, webSearch } from "./web-search.js";
56
60
  import { Workset, addToWorkset, deleteWorkset, getWorkset, listWorksets, removeFromWorkset, saveWorkset } from "./workset.js";
57
- export { type AuditCheck, type AuditData, type AuditOptions, type AuditRecommendation, type BatchOperation, type BatchOptions, type BatchResult, type ChangelogEntry, type ChangelogFormat, type ChangelogOptions, type ChangelogResult, type CheckOptions, type CheckResult, type CheckSummaryResult, type Checkpoint, type ClassifyTrigger, type CodemodChange, type CodemodOptions, type CodemodResult, type CodemodRule, type CompactOptions, type CompactResult, type ConstraintRef, type DeadSymbol, type DeadSymbolOptions, type DeadSymbolResult, type DelegateOptions, type DelegateResult, type DiffChange, type DiffFile, type DiffHunk, type DiffParseOptions, type DigestFieldEntry, type DigestOptions, type DigestResult, type DigestSource, type DogfoodLogEntry, type DogfoodLogGroupedEntry, type DogfoodLogOptions, type DogfoodLogResult, type EncodeOperation, type EncodeOptions, type EncodeResult, type EnvInfoOptions, type EnvInfoResult, type EvalOptions, type EvalResult, type EvidenceEntry, type EvidenceMapAction, type EvidenceMapResult, type EvidenceMapState, type EvidenceStatus, type Example, FileCache, type FileCacheEntry, type FileCacheStats, type FileMetrics, type FileSummaryOptions, type FileSummaryResult, type FindExamplesOptions, type FindExamplesResult, type FindOptions, type FindResult, type FindResults, type ForgeClassifyCeremony, type ForgeClassifyOptions, type ForgeClassifyResult, type ForgeGroundOptions, type ForgeGroundResult, type ForgeTier, type GateDecision, type GateResult, type GitContextOptions, type GitContextResult, type GraphAugmentOptions, type GraphAugmentedResult, type GraphQueryOptions, type GraphQueryResult, type GuideRecommendation, type GuideResult, type HealthCheck, type HealthResult, type HttpMethod, type HttpRequestOptions, type HttpRequestResult, type KBError, type KBErrorCode, type KBNextHint, type KBResponse, type KBResponseMeta, type LaneDiffEntry, type LaneDiffResult, type LaneMergeResult, type LaneMeta, type ManagedProcess, type MeasureOptions, type MeasureResult, type OnboardMode, type OnboardOptions, type OnboardResult, type OnboardStepResult, type ParsedError, type ParsedGitStatus, type ParsedOutput, type ParsedTestResult, type ParsedTestSummary, type QueueItem, type QueueState, type RegexTestOptions, type RegexTestResult, type RenameChange, type RenameOptions, type RenameResult, type ReplayEntry, type ReplayOptions, type RestorePoint, type SafetyGate, type SafetyGateResult, type SchemaValidateOptions, type SchemaValidateResult, type ScopeMapEntry, type ScopeMapOptions, type ScopeMapResult, type Snippet, type SnippetAction, type SnippetOptions, type SnippetResult, type StashEntry, type StratumCard, type StratumCardOptions, type StratumCardResult, type SymbolGraphContext, type SymbolInfo, type SymbolOptions, type TestRunOptions, type TestRunResult, type TimeOptions, type TimeResult, type TraceNode, type TraceOptions, type TraceResult, type TransformOptions, type TransformResult, type TypedUnknownSeed, type UnknownType, type ValidationError, type WatchEvent, type WatchHandle, type WatchOptions, type WebFetchMode, type WebFetchOptions, type WebFetchResult, type WebSearchOptions, type WebSearchResult, type WebSearchResultItem, type Workset, addToWorkset, analyzeFile, audit, autoClaimTestFailures, batch, bookendReorder, changelog, check, checkpointLatest, checkpointList, checkpointLoad, checkpointSave, classifyExitCode, codemod, compact, cosineSimilarity, createRestorePoint, dataTransform, delegate, delegateListModels, deleteWorkset, diffParse, digest, dogfoodLog, encode, envInfo, errorResponse, escapeRegExp, estimateTokens, evaluate, evidenceMap, fileSummary, find, findDeadSymbols, findExamples, forgeClassify, forgeGround, formatChangelog, getWorkset, gitContext, graphAugmentSearch, graphQuery, guide, headTailTruncate, health, httpRequest, laneCreate, laneDiff, laneDiscard, laneList, laneMerge, laneStatus, listRestorePoints, listWorksets, measure, okResponse, onboard, paragraphTruncate, parseBiome, parseGitStatus, parseOutput, parseSearchResults, parseTsc, parseVitest, processList, processLogs, processStart, processStatus, processStop, queueClear, queueCreate, queueDelete, queueDone, queueFail, queueGet, queueList, queueNext, queuePush, regexTest, removeFromWorkset, rename, replayAppend, replayCapture, replayClear, replayList, replayTrim, resolvePath, restoreFromPoint, saveWorkset, schemaValidate, scopeMap, segment, snippet, stashClear, stashDelete, stashGet, stashList, stashSet, stratumCard, summarizeCheckResult, symbol, testRun, timeUtils, trace, truncateToTokenBudget, watchList, watchStart, watchStop, webFetch, webSearch };
61
+ export { type AuditCheck, type AuditData, type AuditOptions, type AuditRecommendation, type BatchOperation, type BatchOptions, type BatchResult, type ChangelogEntry, type ChangelogFormat, type ChangelogOptions, type ChangelogResult, type CheckOptions, type CheckResult, type CheckSummaryResult, type Checkpoint, type ClassifyTrigger, type CodemodChange, type CodemodOptions, type CodemodResult, type CodemodRule, type CompactOptions, type CompactResult, type CompressOutputOptions, type CompressionContext, type CompressionMode, type CompressionResult, type CompressionRule, type ConstraintRef, type DeadSymbol, type DeadSymbolOptions, type DeadSymbolResult, type DelegateOptions, type DelegateResult, type DiffChange, type DiffFile, type DiffHunk, type DiffParseOptions, type DigestFieldEntry, type DigestOptions, type DigestResult, type DigestSource, type DogfoodLogEntry, type DogfoodLogGroupedEntry, type DogfoodLogOptions, type DogfoodLogResult, type EncodeOperation, type EncodeOptions, type EncodeResult, type EnvInfoOptions, type EnvInfoResult, type EvalOptions, type EvalResult, type EvidenceEntry, type EvidenceMapAction, type EvidenceMapResult, type EvidenceMapState, type EvidenceStatus, type Example, FileCache, type FileCacheEntry, type FileCacheStats, type FileMetrics, type FileSummaryOptions, type FileSummaryResult, type FindExamplesOptions, type FindExamplesResult, type FindOptions, type FindResult, type FindResults, type ForgeClassifyCeremony, type ForgeClassifyOptions, type ForgeClassifyResult, type ForgeGroundOptions, type ForgeGroundResult, type ForgeTier, type GateDecision, type GateResult, type GitContextOptions, type GitContextResult, type GraphAugmentOptions, type GraphAugmentedResult, type GraphQueryOptions, type GraphQueryResult, type GuideRecommendation, type GuideResult, type HealthCheck, type HealthResult, type HttpMethod, type HttpRequestOptions, type HttpRequestResult, type KBError, type KBErrorCode, type KBNextHint, type KBResponse, type KBResponseMeta, type LaneDiffEntry, type LaneDiffResult, type LaneMergeResult, type LaneMeta, type ManagedProcess, type MeasureOptions, type MeasureResult, type OnboardMode, type OnboardOptions, type OnboardResult, type OnboardStepResult, type ParsedError, type ParsedGitStatus, type ParsedOutput, type ParsedTestResult, type ParsedTestSummary, type QueueItem, type QueueState, type RegexTestOptions, type RegexTestResult, type RenameChange, type RenameOptions, type RenameResult, type ReplayEntry, type ReplayOptions, type RestorePoint, type SafetyGate, type SafetyGateResult, type SchemaValidateOptions, type SchemaValidateResult, type ScopeMapEntry, type ScopeMapOptions, type ScopeMapResult, type Snippet, type SnippetAction, type SnippetOptions, type SnippetResult, type StashEntry, type StratumCard, type StratumCardOptions, type StratumCardResult, type SymbolGraphContext, type SymbolInfo, type SymbolOptions, type TestRunOptions, type TestRunResult, type TimeOptions, type TimeResult, type TraceNode, type TraceOptions, type TraceResult, type TransformOptions, type TransformResult, type TypedUnknownSeed, type UnknownType, type ValidationError, type WatchEvent, type WatchHandle, type WatchOptions, type WebFetchMode, type WebFetchOptions, type WebFetchResult, type WebSearchOptions, type WebSearchResult, type WebSearchResultItem, type Workset, addToWorkset, analyzeFile, audit, autoClaimTestFailures, batch, bookendReorder, bpeSurprise, changelog, check, checkpointLatest, checkpointList, checkpointLoad, checkpointSave, classifyExitCode, codemod, compact, compressOutput, compressTerminalOutput, cosineSimilarity, createRestorePoint, dataTransform, delegate, delegateListModels, deleteWorkset, detectOutputTool, diffParse, digest, dogfoodLog, encode, envInfo, errorResponse, escapeRegExp, estimateTokens, evaluate, evidenceMap, fileSummary, find, findDeadSymbols, findExamples, forgeClassify, forgeGround, formatChangelog, getRegisteredRules, getWorkset, gitContext, graphAugmentSearch, graphQuery, guide, headTailTruncate, health, httpRequest, laneCreate, laneDiff, laneDiscard, laneList, laneMerge, laneStatus, listRestorePoints, listWorksets, measure, okResponse, onboard, paragraphTruncate, parseBiome, parseGitStatus, parseOutput, parseSearchResults, parseTsc, parseVitest, processList, processLogs, processStart, processStatus, processStop, queueClear, queueCreate, queueDelete, queueDone, queueFail, queueGet, queueList, queueNext, queuePush, regexTest, registerRule, registerRules, removeFromWorkset, rename, replayAppend, replayCapture, replayClear, replayList, replayTrim, resolvePath, restoreFromPoint, saveWorkset, schemaValidate, scopeMap, scoreLine, scoreLines, segment, shannonEntropy, snippet, stashClear, stashDelete, stashGet, stashList, stashSet, stratumCard, summarizeCheckResult, symbol, testRun, timeUtils, trace, truncateToTokenBudget, watchList, watchStart, watchStop, webFetch, webSearch };
@@ -1 +1 @@
1
- import{parseBiome as e,parseGitStatus as t,parseOutput as n,parseTsc as r,parseVitest as i}from"./parse-output.js";import{check as a,summarizeCheckResult as o}from"./check.js";import{escapeRegExp as s}from"./regex-utils.js";import{findDeadSymbols as c}from"./dead-symbols.js";import{health as l}from"./health.js";import{resolvePath as u}from"./path-resolver.js";import{bookendReorder as d,cosineSimilarity as f,estimateTokens as p,segment as m}from"./text-utils.js";import{errorResponse as h,okResponse as g}from"./response-envelope.js";import{audit as _}from"./audit.js";import{batch as v}from"./batch.js";import{changelog as y,formatChangelog as b}from"./changelog.js";import{checkpointLatest as x,checkpointList as S,checkpointLoad as C,checkpointSave as w}from"./checkpoint.js";import{createRestorePoint as T,listRestorePoints as E,restoreFromPoint as D}from"./restore-points.js";import{codemod as O}from"./codemod.js";import{compact as k}from"./compact.js";import{dataTransform as A}from"./data-transform.js";import{delegate as j,delegateListModels as M}from"./delegate.js";import{diffParse as N}from"./diff-parse.js";import{digest as P}from"./digest.js";import{dogfoodLog as F}from"./dogfood-log.js";import{encode as I}from"./encode.js";import{envInfo as L}from"./env-info.js";import{evaluate as R}from"./eval.js";import{autoClaimTestFailures as z,evidenceMap as B}from"./evidence-map.js";import{FileCache as V}from"./file-cache.js";import{fileSummary as H}from"./file-summary.js";import{findExamples as U}from"./find-examples.js";import{find as W}from"./find.js";import{forgeClassify as G}from"./forge-classify.js";import{scopeMap as K}from"./scope-map.js";import{forgeGround as q}from"./forge-ground.js";import{gitContext as J}from"./git-context.js";import{graphAugmentSearch as Y,graphQuery as X}from"./graph-query.js";import{guide as Z}from"./guide.js";import{headTailTruncate as Q,paragraphTruncate as $,truncateToTokenBudget as ee}from"./truncation.js";import{httpRequest as te}from"./http-request.js";import{laneCreate as ne,laneDiff as re,laneDiscard as ie,laneList as ae,laneMerge as oe,laneStatus as se}from"./lane.js";import{analyzeFile as ce,measure as le}from"./measure.js";import{onboard as ue}from"./onboard.js";import{processList as de,processLogs as fe,processStart as pe,processStatus as me,processStop as he}from"./process-manager.js";import{queueClear as ge,queueCreate as _e,queueDelete as ve,queueDone as ye,queueFail as be,queueGet as xe,queueList as Se,queueNext as Ce,queuePush as we}from"./queue.js";import{regexTest as Te}from"./regex-test.js";import{rename as Ee}from"./rename.js";import{replayAppend as De,replayCapture as Oe,replayClear as ke,replayList as Ae,replayTrim as je}from"./replay.js";import{schemaValidate as Me}from"./schema-validate.js";import{snippet as Ne}from"./snippet.js";import{stashClear as Pe,stashDelete as Fe,stashGet as Ie,stashList as Le,stashSet as Re}from"./stash.js";import{stratumCard as ze}from"./stratum-card.js";import{symbol as Be}from"./symbol.js";import{classifyExitCode as Ve,testRun as He}from"./test-run.js";import{timeUtils as Ue}from"./time-utils.js";import{trace as We}from"./trace.js";import{watchList as Ge,watchStart as Ke,watchStop as qe}from"./watch.js";import{webFetch as Je}from"./web-fetch.js";import{parseSearchResults as Ye,webSearch as Xe}from"./web-search.js";import{addToWorkset as Ze,deleteWorkset as Qe,getWorkset as $e,listWorksets as et,removeFromWorkset as tt,saveWorkset as nt}from"./workset.js";export{V as FileCache,Ze as addToWorkset,ce as analyzeFile,_ as audit,z as autoClaimTestFailures,v as batch,d as bookendReorder,y as changelog,a as check,x as checkpointLatest,S as checkpointList,C as checkpointLoad,w as checkpointSave,Ve as classifyExitCode,O as codemod,k as compact,f as cosineSimilarity,T as createRestorePoint,A as dataTransform,j as delegate,M as delegateListModels,Qe as deleteWorkset,N as diffParse,P as digest,F as dogfoodLog,I as encode,L as envInfo,h as errorResponse,s as escapeRegExp,p as estimateTokens,R as evaluate,B as evidenceMap,H as fileSummary,W as find,c as findDeadSymbols,U as findExamples,G as forgeClassify,q as forgeGround,b as formatChangelog,$e as getWorkset,J as gitContext,Y as graphAugmentSearch,X as graphQuery,Z as guide,Q as headTailTruncate,l as health,te as httpRequest,ne as laneCreate,re as laneDiff,ie as laneDiscard,ae as laneList,oe as laneMerge,se as laneStatus,E as listRestorePoints,et as listWorksets,le as measure,g as okResponse,ue as onboard,$ as paragraphTruncate,e as parseBiome,t as parseGitStatus,n as parseOutput,Ye as parseSearchResults,r as parseTsc,i as parseVitest,de as processList,fe as processLogs,pe as processStart,me as processStatus,he as processStop,ge as queueClear,_e as queueCreate,ve as queueDelete,ye as queueDone,be as queueFail,xe as queueGet,Se as queueList,Ce as queueNext,we as queuePush,Te as regexTest,tt as removeFromWorkset,Ee as rename,De as replayAppend,Oe as replayCapture,ke as replayClear,Ae as replayList,je as replayTrim,u as resolvePath,D as restoreFromPoint,nt as saveWorkset,Me as schemaValidate,K as scopeMap,m as segment,Ne as snippet,Pe as stashClear,Fe as stashDelete,Ie as stashGet,Le as stashList,Re as stashSet,ze as stratumCard,o as summarizeCheckResult,Be as symbol,He as testRun,Ue as timeUtils,We as trace,ee as truncateToTokenBudget,Ge as watchList,Ke as watchStart,qe as watchStop,Je as webFetch,Xe as webSearch};
1
+ import{parseBiome as e,parseGitStatus as t,parseOutput as n,parseTsc as r,parseVitest as i}from"./parse-output.js";import{check as a,summarizeCheckResult as o}from"./check.js";import{escapeRegExp as s}from"./regex-utils.js";import{findDeadSymbols as c}from"./dead-symbols.js";import{health as l}from"./health.js";import{resolvePath as u}from"./path-resolver.js";import{bookendReorder as d,cosineSimilarity as f,estimateTokens as p,segment as m}from"./text-utils.js";import{errorResponse as h,okResponse as g}from"./response-envelope.js";import{audit as _}from"./audit.js";import{batch as v}from"./batch.js";import{changelog as y,formatChangelog as b}from"./changelog.js";import{checkpointLatest as x,checkpointList as S,checkpointLoad as C,checkpointSave as w}from"./checkpoint.js";import{createRestorePoint as T,listRestorePoints as E,restoreFromPoint as D}from"./restore-points.js";import{codemod as O}from"./codemod.js";import{bpeSurprise as k,scoreLine as A,scoreLines as j,shannonEntropy as M}from"./compression/scoring.js";import{compact as N}from"./compact.js";import{compressOutput as P,detectOutputTool as F,getRegisteredRules as I,registerRule as L,registerRules as R}from"./compression/engine.js";import{compressTerminalOutput as z}from"./compress-output.js";import{dataTransform as B}from"./data-transform.js";import{delegate as V,delegateListModels as H}from"./delegate.js";import{diffParse as U}from"./diff-parse.js";import{digest as W}from"./digest.js";import{dogfoodLog as G}from"./dogfood-log.js";import{encode as K}from"./encode.js";import{envInfo as q}from"./env-info.js";import{evaluate as J}from"./eval.js";import{autoClaimTestFailures as Y,evidenceMap as X}from"./evidence-map.js";import{FileCache as Z}from"./file-cache.js";import{fileSummary as Q}from"./file-summary.js";import{findExamples as $}from"./find-examples.js";import{find as ee}from"./find.js";import{forgeClassify as te}from"./forge-classify.js";import{scopeMap as ne}from"./scope-map.js";import{forgeGround as re}from"./forge-ground.js";import{gitContext as ie}from"./git-context.js";import{graphAugmentSearch as ae,graphQuery as oe}from"./graph-query.js";import{guide as se}from"./guide.js";import{headTailTruncate as ce,paragraphTruncate as le,truncateToTokenBudget as ue}from"./truncation.js";import{httpRequest as de}from"./http-request.js";import{laneCreate as fe,laneDiff as pe,laneDiscard as me,laneList as he,laneMerge as ge,laneStatus as _e}from"./lane.js";import{analyzeFile as ve,measure as ye}from"./measure.js";import{onboard as be}from"./onboard.js";import{processList as xe,processLogs as Se,processStart as Ce,processStatus as we,processStop as Te}from"./process-manager.js";import{queueClear as Ee,queueCreate as De,queueDelete as Oe,queueDone as ke,queueFail as Ae,queueGet as je,queueList as Me,queueNext as Ne,queuePush as Pe}from"./queue.js";import{regexTest as Fe}from"./regex-test.js";import{rename as Ie}from"./rename.js";import{replayAppend as Le,replayCapture as Re,replayClear as ze,replayList as Be,replayTrim as Ve}from"./replay.js";import{schemaValidate as He}from"./schema-validate.js";import{snippet as Ue}from"./snippet.js";import{stashClear as We,stashDelete as Ge,stashGet as Ke,stashList as qe,stashSet as Je}from"./stash.js";import{stratumCard as Ye}from"./stratum-card.js";import{symbol as Xe}from"./symbol.js";import{classifyExitCode as Ze,testRun as Qe}from"./test-run.js";import{timeUtils as $e}from"./time-utils.js";import{trace as et}from"./trace.js";import{watchList as tt,watchStart as nt,watchStop as rt}from"./watch.js";import{webFetch as it}from"./web-fetch.js";import{parseSearchResults as at,webSearch as ot}from"./web-search.js";import{addToWorkset as st,deleteWorkset as ct,getWorkset as lt,listWorksets as ut,removeFromWorkset as dt,saveWorkset as ft}from"./workset.js";export{Z as FileCache,st as addToWorkset,ve as analyzeFile,_ as audit,Y as autoClaimTestFailures,v as batch,d as bookendReorder,k as bpeSurprise,y as changelog,a as check,x as checkpointLatest,S as checkpointList,C as checkpointLoad,w as checkpointSave,Ze as classifyExitCode,O as codemod,N as compact,P as compressOutput,z as compressTerminalOutput,f as cosineSimilarity,T as createRestorePoint,B as dataTransform,V as delegate,H as delegateListModels,ct as deleteWorkset,F as detectOutputTool,U as diffParse,W as digest,G as dogfoodLog,K as encode,q as envInfo,h as errorResponse,s as escapeRegExp,p as estimateTokens,J as evaluate,X as evidenceMap,Q as fileSummary,ee as find,c as findDeadSymbols,$ as findExamples,te as forgeClassify,re as forgeGround,b as formatChangelog,I as getRegisteredRules,lt as getWorkset,ie as gitContext,ae as graphAugmentSearch,oe as graphQuery,se as guide,ce as headTailTruncate,l as health,de as httpRequest,fe as laneCreate,pe as laneDiff,me as laneDiscard,he as laneList,ge as laneMerge,_e as laneStatus,E as listRestorePoints,ut as listWorksets,ye as measure,g as okResponse,be as onboard,le as paragraphTruncate,e as parseBiome,t as parseGitStatus,n as parseOutput,at as parseSearchResults,r as parseTsc,i as parseVitest,xe as processList,Se as processLogs,Ce as processStart,we as processStatus,Te as processStop,Ee as queueClear,De as queueCreate,Oe as queueDelete,ke as queueDone,Ae as queueFail,je as queueGet,Me as queueList,Ne as queueNext,Pe as queuePush,Fe as regexTest,L as registerRule,R as registerRules,dt as removeFromWorkset,Ie as rename,Le as replayAppend,Re as replayCapture,ze as replayClear,Be as replayList,Ve as replayTrim,u as resolvePath,D as restoreFromPoint,ft as saveWorkset,He as schemaValidate,ne as scopeMap,A as scoreLine,j as scoreLines,m as segment,M as shannonEntropy,Ue as snippet,We as stashClear,Ge as stashDelete,Ke as stashGet,qe as stashList,Je as stashSet,Ye as stratumCard,o as summarizeCheckResult,Xe as symbol,Qe as testRun,$e as timeUtils,et as trace,ue as truncateToTokenBudget,tt as watchList,nt as watchStart,rt as watchStop,it as webFetch,ot as webSearch};
@@ -59,6 +59,8 @@ type ParsedOutput = {
59
59
  * Example line: `src/foo.ts(10,5): error TS2339: Property 'x' does not exist`
60
60
  */
61
61
  declare function parseTsc(output: string): ParsedError[];
62
+ /** Strip ANSI escape codes from terminal output */
63
+ declare function stripAnsi(text: string): string;
62
64
  /**
63
65
  * Parse vitest run output into structured test results.
64
66
  */
@@ -79,4 +81,4 @@ declare function parseGitStatus(output: string): ParsedGitStatus;
79
81
  */
80
82
  declare function parseOutput(output: string, tool?: string): ParsedOutput;
81
83
  //#endregion
82
- export { ParsedError, ParsedGitStatus, ParsedOutput, ParsedTestResult, ParsedTestSummary, parseBiome, parseGitStatus, parseOutput, parseTsc, parseVitest };
84
+ export { ParsedError, ParsedGitStatus, ParsedOutput, ParsedTestResult, ParsedTestSummary, parseBiome, parseGitStatus, parseOutput, parseTsc, parseVitest, stripAnsi };
@@ -1,2 +1,2 @@
1
1
  function e(e){let t=[];for(let n of e.matchAll(/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+(TS\d+):\s+(.+)$/gm))t.push({file:n[1],line:Number.parseInt(n[2],10),column:Number.parseInt(n[3],10),severity:n[4],code:n[5],message:n[6]});if(t.length===0)for(let n of e.matchAll(/^(.+?):(\d+):(\d+)\s+-\s+(error|warning)\s+(TS\d+):\s+(.+)$/gm))t.push({file:n[1],line:Number.parseInt(n[2],10),column:Number.parseInt(n[3],10),severity:n[4],code:n[5],message:n[6]});return t}function t(e){return e.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,``)}function n(e){let n=t(e),r=[];for(let e of n.matchAll(/^\s*([✓✕×-])\s+(.+?)(?:\s+(\d+)ms)?$/gm)){let t=e[1],n=t===`✓`?`pass`:t===`-`?`skip`:`fail`;r.push({name:e[2].trim(),status:n,duration:e[3]?Number.parseInt(e[3],10):void 0})}for(let e of n.matchAll(/^\s*([✓✕×])\s+(\S+\.test\.\w+)\s+\((\d+)\s+tests?\)\s*(\d+ms)?$/gm)){let t=e[1]===`✓`?`pass`:`fail`;r.push({name:e[2],file:e[2],status:t,duration:e[4]?Number.parseInt(e[4],10):void 0})}let i=/Tests\s+(?:(\d+)\s+passed)?(?:\s*\|\s*)?(?:(\d+)\s+failed)?(?:\s*\|\s*)?(?:(\d+)\s+skipped)?\s*\((\d+)\)/.exec(n),a=i?Number.parseInt(i[1]??`0`,10):r.filter(e=>e.status===`pass`).length,o=i?Number.parseInt(i[2]??`0`,10):r.filter(e=>e.status===`fail`).length,s=i?Number.parseInt(i[3]??`0`,10):r.filter(e=>e.status===`skip`).length,c=/Duration\s+(\d+(?:\.\d+)?)(?:ms|s)/.exec(n),l=c?c[0].includes(`s`)&&!c[0].includes(`ms`)?Number.parseFloat(c[1])*1e3:Number.parseFloat(c[1]):void 0,u=/Test Files\s+(\d+)\s+passed/.exec(n);return{tests:r,passed:a,failed:o,skipped:s,duration:l,suites:u?Number.parseInt(u[1],10):void 0}}function r(e){let t=[];for(let n of e.matchAll(/^(.+?):(\d+):(\d+)\s+([\w/]+)\s+━+$/gm)){let r=n[1],i=Number.parseInt(n[2],10),a=Number.parseInt(n[3],10),o=n[4],s=e.slice((n.index??0)+n[0].length,(n.index??0)+n[0].length+500),c=/^\s*[×!i]\s+(.+)$/m.exec(s),l=c?c[1].trim():o,u=o.includes(`lint`)?`warning`:`error`;t.push({file:r,line:i,column:a,severity:u,code:o,message:l})}return t}function i(e){let t=[],n=[],r=[],i;for(let o of e.split(`
2
- `)){if(!o)continue;if(o.startsWith(`## `)){i=o.slice(3).split(`...`)[0];continue}let e=o[0],s=o[1],c=o.slice(3).trim();e===`?`&&s===`?`?r.push(c):(e!==` `&&e!==`?`&&t.push({status:a(e),file:c}),s!==` `&&s!==`?`&&n.push({status:a(s),file:c}))}return{staged:t,unstaged:n,untracked:r,branch:i}}function a(e){return{M:`modified`,A:`added`,D:`deleted`,R:`renamed`,C:`copied`,U:`unmerged`}[e]??e}function o(t,a){let o=a??s(t);switch(o){case`tsc`:return{tool:`tsc`,errors:e(t)};case`vitest`:return{tool:`vitest`,summary:n(t)};case`biome`:return{tool:`biome`,errors:r(t)};case`git-status`:return{tool:`git-status`,status:i(t)};default:throw Error(`Unknown tool: ${o}. Supported: tsc, vitest, biome, git-status`)}}function s(e){return e.includes(`error TS`)||/\(\d+,\d+\):\s+error/.test(e)?`tsc`:e.includes(`vitest`)||e.includes(`Test Files`)||e.includes(`✓`)?`vitest`:e.includes(`biome`)||/\w+\/\w+\s+━+/.test(e)?`biome`:/^##\s/.test(e)||/^[MADRCU?! ]{2}\s/.test(e)?`git-status`:`unknown`}export{r as parseBiome,i as parseGitStatus,o as parseOutput,e as parseTsc,n as parseVitest};
2
+ `)){if(!o)continue;if(o.startsWith(`## `)){i=o.slice(3).split(`...`)[0];continue}let e=o[0],s=o[1],c=o.slice(3).trim();e===`?`&&s===`?`?r.push(c):(e!==` `&&e!==`?`&&t.push({status:a(e),file:c}),s!==` `&&s!==`?`&&n.push({status:a(s),file:c}))}return{staged:t,unstaged:n,untracked:r,branch:i}}function a(e){return{M:`modified`,A:`added`,D:`deleted`,R:`renamed`,C:`copied`,U:`unmerged`}[e]??e}function o(t,a){let o=a??s(t);switch(o){case`tsc`:return{tool:`tsc`,errors:e(t)};case`vitest`:return{tool:`vitest`,summary:n(t)};case`biome`:return{tool:`biome`,errors:r(t)};case`git-status`:return{tool:`git-status`,status:i(t)};default:throw Error(`Unknown tool: ${o}. Supported: tsc, vitest, biome, git-status`)}}function s(e){return e.includes(`error TS`)||/\(\d+,\d+\):\s+error/.test(e)?`tsc`:e.includes(`vitest`)||e.includes(`Test Files`)||e.includes(`✓`)?`vitest`:e.includes(`biome`)||/\w+\/\w+\s+━+/.test(e)?`biome`:/^##\s/.test(e)||/^[MADRCU?! ]{2}\s/.test(e)?`git-status`:`unknown`}export{r as parseBiome,i as parseGitStatus,o as parseOutput,e as parseTsc,n as parseVitest,t as stripAnsi};
@@ -5,6 +5,26 @@
5
5
  * Head/tail split: preserves both the beginning (context/setup) and
6
6
  * end (errors/results/stack traces) of content. Snaps to line boundaries.
7
7
  */
8
+ /** Metadata about truncation for transparency */
9
+ interface TruncationMeta {
10
+ /** Whether the text was actually truncated */
11
+ truncated: boolean;
12
+ /** Original character count before truncation */
13
+ originalChars: number;
14
+ /** Character count after truncation */
15
+ truncatedChars: number;
16
+ /** Number of lines/paragraphs omitted */
17
+ omittedCount: number;
18
+ /** Type of truncation applied */
19
+ strategy: 'head-tail' | 'paragraph' | 'token-budget' | 'none';
20
+ }
21
+ /** Result of a truncation operation with metadata */
22
+ interface TruncationResult {
23
+ /** The truncated text */
24
+ text: string;
25
+ /** Truncation metadata for transparency */
26
+ _meta: TruncationMeta;
27
+ }
8
28
  /**
9
29
  * Truncate text keeping both head and tail portions.
10
30
  * Critical for process output where errors appear at the end.
@@ -29,5 +49,18 @@ declare function paragraphTruncate(text: string, maxLen: number): string;
29
49
  * @returns Original text if within budget, or truncated with notice
30
50
  */
31
51
  declare function truncateToTokenBudget(text: string, maxTokens: number): string;
52
+ /**
53
+ * Head-tail truncation with metadata.
54
+ * Same as headTailTruncate but returns a TruncationResult with _meta.
55
+ */
56
+ declare function headTailTruncateWithMeta(text: string, maxLen: number, headRatio?: number): TruncationResult;
57
+ /**
58
+ * Paragraph truncation with metadata.
59
+ */
60
+ declare function paragraphTruncateWithMeta(text: string, maxLen: number): TruncationResult;
61
+ /**
62
+ * Token-budget truncation with metadata.
63
+ */
64
+ declare function truncateToTokenBudgetWithMeta(text: string, maxTokens: number): TruncationResult;
32
65
  //#endregion
33
- export { headTailTruncate, paragraphTruncate, truncateToTokenBudget };
66
+ export { TruncationMeta, TruncationResult, headTailTruncate, headTailTruncateWithMeta, paragraphTruncate, paragraphTruncateWithMeta, truncateToTokenBudget, truncateToTokenBudgetWithMeta };
@@ -1,7 +1,11 @@
1
- function e(e,t,n=.6){if(e.length<=t)return e;let r=Math.max(0,t-120),i=Math.floor(r*n),a=r-i,o=e.slice(0,i),s=o.lastIndexOf(`
2
- `),c=s>0?o.slice(0,s):o,l=e.length-a,u=e.slice(l),d=u.indexOf(`
3
- `),f=d>=0?u.slice(d+1):u,p=e.length-c.length-f.length,m=1,h=c.length,g=e.length-f.length;for(let t=h;t<g;t++)e.charCodeAt(t)===10&&m++;return`${c}\n\n[… ${m} lines / ${(p/1024).toFixed(1)}KB truncated — showing first ${c.split(`
4
- `).length} + last ${f.split(`
5
- `).length} lines]\n\n${f}`}function t(e,t){if(e.length<=t)return e;let n=Math.max(0,t-200),r=e.slice(n,t).lastIndexOf(`
1
+ import{estimateTokens as e}from"./text-utils.js";const t=.6;function n(e,n,r=t){if(e.length<=n)return e;let i=Math.max(0,n-120),a=Math.floor(i*r),o=i-a,s=e.slice(0,a),c=s.lastIndexOf(`
2
+ `),l=c>0?s.slice(0,c):s,u=e.length-o,d=e.slice(u),f=d.indexOf(`
3
+ `),p=f>=0?d.slice(f+1):d,m=e.length-l.length-p.length,h=1,g=l.length,_=e.length-p.length;for(let t=g;t<_;t++)e.charCodeAt(t)===10&&h++;return`${l}\n\n[… ${h} lines / ${(m/1024).toFixed(1)}KB truncated — showing first ${l.split(`
4
+ `).length} + last ${p.split(`
5
+ `).length} lines]\n\n${p}`}function r(e,t){if(e.length<=t)return e;let n=Math.max(0,t-200),r=e.slice(n,t).lastIndexOf(`
6
6
 
7
- `),i=r>=0?n+r:t,a=e.slice(0,i).trimEnd(),o=Math.round(i/e.length*100);return`${a}\n\n---\n*[Truncated at ${i.toLocaleString()} chars — ${o}% of original content]*`}function n(t,n){let r=n*4;return t.length<=r?t:e(t,r)}export{e as headTailTruncate,t as paragraphTruncate,n as truncateToTokenBudget};
7
+ `),i=r>=0?n+r:t,a=e.slice(0,i).trimEnd(),o=Math.round(i/e.length*100);return`${a}\n\n---\n*[Truncated at ${i.toLocaleString()} chars — ${o}% of original content]*`}function i(e,t){let r=t*4;return e.length<=r?e:n(e,r)}function a(e,r,i=t){if(e.length<=r)return{text:e,_meta:{truncated:!1,originalChars:e.length,truncatedChars:e.length,omittedCount:0,strategy:`none`}};let a=Math.max(0,r-120),o=Math.floor(a*i),s=a-o,c=e.slice(0,o),l=c.lastIndexOf(`
8
+ `),u=l>0?c.slice(0,l):c,d=e.length-s,f=e.slice(d),p=f.indexOf(`
9
+ `),m=p>=0?f.slice(p+1):f,h=1,g=u.length,_=e.length-m.length;for(let t=g;t<_;t++)e.charCodeAt(t)===10&&h++;let v=n(e,r,i);return{text:v,_meta:{truncated:!0,originalChars:e.length,truncatedChars:v.length,omittedCount:h,strategy:`head-tail`}}}function o(e,t){if(e.length<=t)return{text:e,_meta:{truncated:!1,originalChars:e.length,truncatedChars:e.length,omittedCount:0,strategy:`none`}};let n=Math.max(0,t-200),i=e.slice(n,t).lastIndexOf(`
10
+
11
+ `),a=i>=0?n+i:t,o=e.split(/\n\s*\n/),s=e.slice(0,a).trimEnd(),c=s.length===0?0:s.split(/\n\s*\n/).length,l=r(e,t);return{text:l,_meta:{truncated:!0,originalChars:e.length,truncatedChars:l.length,omittedCount:Math.max(0,o.length-c),strategy:`paragraph`}}}function s(t,n){if(e(t)<=n)return{text:t,_meta:{truncated:!1,originalChars:t.length,truncatedChars:t.length,omittedCount:0,strategy:`none`}};let r=a(t,n*4);return{text:r.text,_meta:{...r._meta,strategy:`token-budget`}}}export{n as headTailTruncate,a as headTailTruncateWithMeta,r as paragraphTruncate,o as paragraphTruncateWithMeta,i as truncateToTokenBudget,s as truncateToTokenBudgetWithMeta};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import{r as e}from"./chunk-D6axbAb-.js";import{t}from"./react-D__J1GQe.js";import{a as n,i as r,n as i,t as a}from"./jsx-runtime-y6Gdq5PZ.js";import{t as o}from"./useKBClient-C35iA4uG.js";import{t as s}from"./StatusPanel-BAbUxyqQ.js";import{t as c}from"./SearchPanel-CpJGczAc.js";import{t as l}from"./CuratedPanel-BIamXLNy.js";import{t as u}from"./LogPanel-Db-SeZhR.js";var d=e(t()),f=a();const p=[`status`,`search`,`curated`,`log`];function m({client:e}){let[t,a]=(0,d.useState)(`status`);return i((e,n)=>{n.tab&&a(p[(p.indexOf(t)+1)%p.length]),e===`1`&&a(`status`),e===`2`&&a(`search`),e===`3`&&a(`curated`),e===`4`&&a(`log`)}),(0,f.jsx)(o,{value:e,children:(0,f.jsxs)(n,{flexDirection:`column`,width:`100%`,children:[(0,f.jsxs)(n,{borderStyle:`single`,paddingX:1,children:[(0,f.jsx)(r,{bold:!0,color:`cyan`,children:`AI Kit Dashboard`}),(0,f.jsx)(r,{children:` │ `}),p.map(e=>(0,f.jsxs)(d.Fragment,{children:[(0,f.jsxs)(r,{color:e===t?`green`:`gray`,bold:e===t,children:[`[`,p.indexOf(e)+1,`] `,e]}),(0,f.jsx)(r,{children:` `})]},e)),(0,f.jsx)(r,{color:`gray`,children:` │ Tab: switch │ Ctrl+C: quit`})]}),(0,f.jsxs)(n,{flexGrow:1,minHeight:10,children:[t===`status`&&(0,f.jsx)(s,{}),t===`search`&&(0,f.jsx)(c,{}),t===`curated`&&(0,f.jsx)(l,{}),t===`log`&&(0,f.jsx)(u,{})]})]})})}export{m as t};
2
+ import{i as e}from"./chunk-BSngPjfM.js";import{t}from"./react-sYq8CyFO.js";import{a as n,i as r,n as i,t as a}from"./jsx-runtime-B_2ewjsM.js";import{t as o}from"./useKBClient-BkBffCdd.js";import{t as s}from"./StatusPanel-BFshFJU9.js";import{t as c}from"./SearchPanel-BbvCaco0.js";import{t as l}from"./CuratedPanel-BwkPKdX4.js";import{t as u}from"./LogPanel-C6KagE0H.js";var d=e(t()),f=a();const p=[`status`,`search`,`curated`,`log`];function m({client:e}){let[t,a]=(0,d.useState)(`status`);return i((e,n)=>{n.tab&&a(p[(p.indexOf(t)+1)%p.length]),e===`1`&&a(`status`),e===`2`&&a(`search`),e===`3`&&a(`curated`),e===`4`&&a(`log`)}),(0,f.jsx)(o,{value:e,children:(0,f.jsxs)(n,{flexDirection:`column`,width:`100%`,children:[(0,f.jsxs)(n,{borderStyle:`single`,paddingX:1,children:[(0,f.jsx)(r,{bold:!0,color:`cyan`,children:`AI Kit Dashboard`}),(0,f.jsx)(r,{children:` │ `}),p.map(e=>(0,f.jsxs)(d.Fragment,{children:[(0,f.jsxs)(r,{color:e===t?`green`:`gray`,bold:e===t,children:[`[`,p.indexOf(e)+1,`] `,e]}),(0,f.jsx)(r,{children:` `})]},e)),(0,f.jsx)(r,{color:`gray`,children:` │ Tab: switch │ Ctrl+C: quit`})]}),(0,f.jsxs)(n,{flexGrow:1,minHeight:10,children:[t===`status`&&(0,f.jsx)(s,{}),t===`search`&&(0,f.jsx)(c,{}),t===`curated`&&(0,f.jsx)(l,{}),t===`log`&&(0,f.jsx)(u,{})]})]})})}export{m as t};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import{t as e}from"./App-DpjN3iS-.js";export{e as App};
2
+ import{t as e}from"./App-D8fednPY.js";export{e as App};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import"./chunk-D6axbAb-.js";import{t as e}from"./react-D__J1GQe.js";import{a as t,i as n,t as r}from"./jsx-runtime-y6Gdq5PZ.js";import{n as i}from"./useKBClient-C35iA4uG.js";import{t as a}from"./usePolling-BbjnRWgx.js";e();var o=r();function s(){let e=i(),{data:r,error:s}=a(()=>e.listKnowledge(),1e4);return(0,o.jsxs)(t,{flexDirection:`column`,borderStyle:`round`,paddingX:1,children:[(0,o.jsx)(n,{bold:!0,color:`cyan`,children:`Curated Knowledge`}),(0,o.jsx)(n,{children:` `}),s&&(0,o.jsxs)(n,{color:`red`,children:[`Error: `,s.message]}),r&&r.length===0&&!s&&(0,o.jsx)(n,{color:`gray`,children:`No curated entries found`}),r?.map(e=>(0,o.jsxs)(n,{children:[(0,o.jsx)(n,{color:`magenta`,children:`•`}),` `,e.title,` `,(0,o.jsxs)(n,{color:`gray`,children:[`(`,e.category,`)`]})]},e.path)),!r&&!s&&(0,o.jsx)(n,{color:`yellow`,children:`Loading…`}),(0,o.jsx)(n,{children:` `}),(0,o.jsx)(n,{color:`gray`,children:`Refreshes every 10s`})]})}export{s as t};
2
+ import"./chunk-BSngPjfM.js";import{t as e}from"./react-sYq8CyFO.js";import{a as t,i as n,t as r}from"./jsx-runtime-B_2ewjsM.js";import{n as i}from"./useKBClient-BkBffCdd.js";import{t as a}from"./usePolling-D3y7u5cZ.js";e();var o=r();function s(){let e=i(),{data:r,error:s}=a(()=>e.listKnowledge(),1e4);return(0,o.jsxs)(t,{flexDirection:`column`,borderStyle:`round`,paddingX:1,children:[(0,o.jsx)(n,{bold:!0,color:`cyan`,children:`Curated Knowledge`}),(0,o.jsx)(n,{children:` `}),s&&(0,o.jsxs)(n,{color:`red`,children:[`Error: `,s.message]}),r&&r.length===0&&!s&&(0,o.jsx)(n,{color:`gray`,children:`No curated entries found`}),r?.map(e=>(0,o.jsxs)(n,{children:[(0,o.jsx)(n,{color:`magenta`,children:`•`}),` `,e.title,` `,(0,o.jsxs)(n,{color:`gray`,children:[`(`,e.category,`)`]})]},e.path)),!r&&!s&&(0,o.jsx)(n,{color:`yellow`,children:`Loading…`}),(0,o.jsx)(n,{children:` `}),(0,o.jsx)(n,{color:`gray`,children:`Refreshes every 10s`})]})}export{s as t};