@vpxa/kb 0.1.12 → 0.1.13

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 (54) hide show
  1. package/README.md +48 -37
  2. package/package.json +1 -1
  3. package/packages/analyzers/dist/entry-point-analyzer.d.ts +18 -0
  4. package/packages/analyzers/dist/entry-point-analyzer.js +6 -5
  5. package/packages/analyzers/dist/pattern-analyzer.js +1 -1
  6. package/packages/analyzers/dist/types.d.ts +1 -1
  7. package/packages/cli/dist/commands/init.d.ts +2 -1
  8. package/packages/cli/dist/commands/init.js +242 -183
  9. package/packages/cli/dist/commands/knowledge.js +1 -1
  10. package/packages/cli/dist/commands/system.js +6 -3
  11. package/packages/cli/dist/helpers.js +5 -3
  12. package/packages/core/dist/content-detector.d.ts +5 -1
  13. package/packages/core/dist/content-detector.js +1 -1
  14. package/packages/core/dist/index.d.ts +1 -1
  15. package/packages/core/dist/index.js +1 -1
  16. package/packages/core/dist/types.d.ts +2 -0
  17. package/packages/server/dist/server.js +1 -1
  18. package/packages/server/dist/tools/analyze.tools.js +3 -1
  19. package/packages/server/dist/tools/audit.tool.d.ts +5 -0
  20. package/packages/server/dist/tools/audit.tool.js +4 -0
  21. package/packages/server/dist/tools/replay.tool.js +4 -4
  22. package/packages/server/dist/tools/search.tool.js +18 -14
  23. package/packages/server/dist/tools/status.tool.js +3 -3
  24. package/packages/server/dist/tools/toolkit.tools.d.ts +1 -1
  25. package/packages/server/dist/tools/toolkit.tools.js +23 -20
  26. package/packages/store/dist/lance-store.js +1 -1
  27. package/packages/store/dist/store.interface.d.ts +2 -0
  28. package/packages/tools/dist/audit.d.ts +66 -0
  29. package/packages/tools/dist/audit.js +7 -0
  30. package/packages/tools/dist/check.d.ts +19 -0
  31. package/packages/tools/dist/check.js +2 -2
  32. package/packages/tools/dist/compact.d.ts +4 -2
  33. package/packages/tools/dist/compact.js +2 -2
  34. package/packages/tools/dist/dead-symbols.d.ts +9 -1
  35. package/packages/tools/dist/dead-symbols.js +2 -2
  36. package/packages/tools/dist/forge-classify.js +1 -1
  37. package/packages/tools/dist/guide.d.ts +23 -0
  38. package/packages/tools/dist/guide.js +1 -0
  39. package/packages/tools/dist/health.js +2 -1
  40. package/packages/tools/dist/index.d.ts +6 -2
  41. package/packages/tools/dist/index.js +1 -1
  42. package/packages/tools/dist/path-resolver.d.ts +12 -0
  43. package/packages/tools/dist/path-resolver.js +1 -0
  44. package/packages/tools/dist/replay.d.ts +1 -1
  45. package/packages/tools/dist/response-envelope.d.ts +41 -0
  46. package/packages/tools/dist/response-envelope.js +1 -0
  47. package/packages/tools/dist/scope-map.d.ts +2 -0
  48. package/packages/tools/dist/scope-map.js +1 -1
  49. package/packages/tools/dist/truncation.d.ts +9 -0
  50. package/packages/tools/dist/truncation.js +8 -8
  51. package/packages/tui/dist/App.js +109 -109
  52. package/packages/tui/dist/index.js +116 -116
  53. package/packages/tui/dist/panels/LogPanel.js +100 -100
  54. package/skills/knowledge-base/SKILL.md +19 -19
@@ -1 +1,2 @@
1
- import{existsSync as n,readFileSync as p}from"node:fs";import{join as o,resolve as w}from"node:path";function N(d){const a=w(d??process.cwd()),s=[],g=o(a,"package.json");if(n(g)){s.push({name:"package.json",status:"pass",message:"Found"});try{const e=JSON.parse(p(g,"utf-8"));e.name?s.push({name:"package.name",status:"pass",message:e.name}):s.push({name:"package.name",status:"warn",message:"Missing package name"});const i=e.scripts??{};for(const t of["build","test","lint"])i[t]?s.push({name:`script:${t}`,status:"pass",message:i[t]}):s.push({name:`script:${t}`,status:"warn",message:`No "${t}" script defined`});e.type==="module"?s.push({name:"esm",status:"pass",message:'ESM ("type": "module")'}):e.type==="commonjs"?s.push({name:"esm",status:"pass",message:'CJS ("type": "commonjs")'}):s.push({name:"esm",status:"warn",message:'No "type" field \u2014 defaults to CJS'}),e.engines?.node?s.push({name:"engines.node",status:"pass",message:e.engines.node}):s.push({name:"engines.node",status:"warn",message:"No Node.js engine constraint"})}catch{s.push({name:"package.json",status:"fail",message:"Failed to parse package.json"})}}else s.push({name:"package.json",status:"fail",message:"Missing \u2014 not a Node.js project"});const f=o(a,"tsconfig.json");n(f)?s.push({name:"tsconfig.json",status:"pass",message:"Found"}):s.push({name:"tsconfig.json",status:"warn",message:"Missing"});const l=o(a,".gitignore");if(n(l)){const e=p(l,"utf-8"),i=e.includes("node_modules"),t=e.includes("dist");i&&t?s.push({name:".gitignore",status:"pass",message:"Includes node_modules and dist"}):s.push({name:".gitignore",status:"warn",message:`Missing: ${i?"":"node_modules "}${t?"":"dist"}`.trim()})}else s.push({name:".gitignore",status:"warn",message:"Missing"});const r=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"].find(e=>n(o(a,e)));r?s.push({name:"lockfile",status:"pass",message:r}):s.push({name:"lockfile",status:"warn",message:"No lock file found"});const h=o(a,"README.md");if(n(h)){const e=p(h,"utf-8").length;s.push({name:"README.md",status:e>100?"pass":"warn",message:e>100?`Found (${e} chars)`:"Found but very short"})}else s.push({name:"README.md",status:"warn",message:"Missing"});n(o(a,"LICENSE"))||n(o(a,"LICENSE.md"))?s.push({name:"LICENSE",status:"pass",message:"Found"}):s.push({name:"LICENSE",status:"warn",message:"Missing"});const m=s.length,u=s.filter(e=>e.status==="pass").length,c=s.filter(e=>e.status==="fail").length,k=Math.round(u/m*100),j=c>0?`${c} critical issue(s), ${m-u-c} warning(s)`:m-u>0?`${m-u} warning(s)`:"All checks passed";return{path:a,checks:s,score:k,summary:j}}export{N as health};
1
+ import{existsSync as m,readdirSync as $,readFileSync as d,statSync as j}from"node:fs";import{extname as v,join as c,relative as M,resolve as S}from"node:path";function D(p){const e=S(p??process.cwd()),s=[],r=c(e,"package.json");if(m(r)){s.push({name:"package.json",status:"pass",message:"Found"});try{const t=JSON.parse(d(r,"utf-8"));t.name?s.push({name:"package.name",status:"pass",message:t.name}):s.push({name:"package.name",status:"warn",message:"Missing package name"});const u=t.scripts??{};for(const g of["build","test","lint"])u[g]?s.push({name:`script:${g}`,status:"pass",message:u[g]}):s.push({name:`script:${g}`,status:"warn",message:`No "${g}" script defined`});t.type==="module"?s.push({name:"esm",status:"pass",message:'ESM ("type": "module")'}):t.type==="commonjs"?s.push({name:"esm",status:"pass",message:'CJS ("type": "commonjs")'}):s.push({name:"esm",status:"warn",message:'No "type" field \u2014 defaults to CJS'}),t.engines?.node?s.push({name:"engines.node",status:"pass",message:t.engines.node}):s.push({name:"engines.node",status:"warn",message:"No Node.js engine constraint"})}catch{s.push({name:"package.json",status:"fail",message:"Failed to parse package.json"})}}else s.push({name:"package.json",status:"fail",message:"Missing \u2014 not a Node.js project"});const i=c(e,"tsconfig.json");m(i)?s.push({name:"tsconfig.json",status:"pass",message:"Found"}):s.push({name:"tsconfig.json",status:"warn",message:"Missing"});const n=c(e,".gitignore");if(m(n)){const t=d(n,"utf-8"),u=t.includes("node_modules"),g=t.includes("dist");u&&g?s.push({name:".gitignore",status:"pass",message:"Includes node_modules and dist"}):s.push({name:".gitignore",status:"warn",message:`Missing: ${u?"":"node_modules "}${g?"":"dist"}`.trim()})}else s.push({name:".gitignore",status:"warn",message:"Missing"});const o=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"].find(t=>m(c(e,t)));o?s.push({name:"lockfile",status:"pass",message:o}):s.push({name:"lockfile",status:"warn",message:"No lock file found"});const l=c(e,"README.md");if(m(l)){const t=d(l,"utf-8").length;s.push({name:"README.md",status:t>100?"pass":"warn",message:t>100?`Found (${t} chars)`:"Found but very short"})}else s.push({name:"README.md",status:"warn",message:"Missing"});if(m(c(e,"LICENSE"))||m(c(e,"LICENSE.md"))?s.push({name:"LICENSE",status:"pass",message:"Found"}):s.push({name:"LICENSE",status:"warn",message:"Missing"}),m(i))try{const u=d(i,"utf-8").replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");JSON.parse(u).compilerOptions?.strict===!0?s.push({name:"typescript.strict",status:"pass",message:"strict: true"}):s.push({name:"typescript.strict",status:"warn",message:"strict mode not enabled in tsconfig.json"})}catch{}if(m(r))try{const t=JSON.parse(d(r,"utf-8"));t.exports?s.push({name:"package.exports",status:"pass",message:"Has exports field"}):t.workspaces||m(c(e,"pnpm-workspace.yaml"))||s.push({name:"package.exports",status:"warn",message:"Missing \u2014 consider adding exports field for explicit public API"});const u=P(e,t);u.length>0&&_(e,u,s)}catch{}const f=c(e,"dist"),h=c(e,"src");if(m(f)&&m(h))try{const t=j(f).mtimeMs;x(h)>t?s.push({name:"build.freshness",status:"warn",message:"Source files are newer than dist/ \u2014 rebuild may be needed"}):s.push({name:"build.freshness",status:"pass",message:"Build output is fresh"})}catch{}if(m(h)){const t=F(h);if(t.length===0)s.push({name:"circular_deps",status:"pass",message:"No circular imports detected"});else{const u=t.slice(0,3).map(g=>g.join(" \u2192 "));s.push({name:"circular_deps",status:"warn",message:`${t.length} circular import(s): ${u.join("; ")}${t.length>3?` (+${t.length-3} more)`:""}`})}}const w=s.length,k=s.filter(t=>t.status==="pass").length,y=s.filter(t=>t.status==="fail").length,N=Math.round(k/w*100),b=y>0?`${y} critical issue(s), ${w-k-y} warning(s)`:w-k>0?`${w-k} warning(s)`:"All checks passed";return{path:e,checks:s,score:N,summary:b}}function P(p,e){const s=[];Array.isArray(e.workspaces)?s.push(...e.workspaces):e.workspaces&&typeof e.workspaces=="object"&&Array.isArray(e.workspaces.packages)&&s.push(...e.workspaces.packages);const r=c(p,"pnpm-workspace.yaml");if(m(r)){const n=d(r,"utf-8");for(const a of n.split(`
2
+ `)){const o=a.match(/^\s*-\s+['"]?([^'"#\s]+)['"]?\s*$/);o&&s.push(o[1])}}const i=[];for(const n of s)if(n.endsWith("/*")||n.endsWith("/**")){const a=c(p,n.replace(/\/\*+$/,""));if(m(a))try{for(const o of $(a,{withFileTypes:!0}))o.isDirectory()&&m(c(a,o.name,"package.json"))&&i.push(c(a,o.name))}catch{}}else{const a=c(p,n);m(c(a,"package.json"))&&i.push(a)}return i}function _(p,e,s){let r=0,i=0;const n=new Map;for(const a of e)try{const o=JSON.parse(d(c(a,"package.json"),"utf-8"));o.scripts?.test||r++,!o.exports&&!o.main&&i++;const l={...o.dependencies,...o.devDependencies};for(const f of Object.values(l))if(typeof f=="string"&&f.startsWith("workspace:")){const h=f.startsWith("workspace:*")?"workspace:*":f.startsWith("workspace:^")?"workspace:^":"workspace:~";n.set(h,(n.get(h)??0)+1)}}catch{}if(r>0?s.push({name:"workspace.test-scripts",status:"warn",message:`${r}/${e.length} workspace packages missing test script`}):s.push({name:"workspace.test-scripts",status:"pass",message:`All ${e.length} workspace packages have test scripts`}),i>0?s.push({name:"workspace.exports",status:"warn",message:`${i}/${e.length} packages missing exports field`}):e.length>0&&s.push({name:"workspace.exports",status:"pass",message:`All ${e.length} packages have exports or main field`}),n.size>1){const a=[...n.entries()].map(([o,l])=>`${o} (${l})`).join(", ");s.push({name:"workspace.protocol",status:"warn",message:`Mixed workspace protocols: ${a} \u2014 consider standardizing`})}else if(n.size===1){const[a]=n.keys();s.push({name:"workspace.protocol",status:"pass",message:`Consistent workspace protocol: ${a}`})}}function x(p){let e=0;try{for(const s of $(p,{withFileTypes:!0})){if(s.name.startsWith(".")||s.name==="node_modules")continue;const r=c(p,s.name);s.isDirectory()?e=Math.max(e,x(r)):e=Math.max(e,j(r).mtimeMs)}}catch{}return e}const A=/(?:import|export)\s+.*?from\s+['"](\.[^'"]+)['"]/g,C=new Set([".ts",".tsx",".mts"]);function F(p){const e=new Map;E(p,p,e);const s=[],r=new Set,i=new Set;function n(a,o){if(i.has(a)){const l=o.indexOf(a);l>=0&&s.push(o.slice(l).concat(a));return}if(!r.has(a)){r.add(a),i.add(a),o.push(a);for(const l of e.get(a)??[])n(l,o);o.pop(),i.delete(a)}}for(const a of e.keys())n(a,[]);return s}function E(p,e,s){let r;try{r=$(p)}catch{return}for(const i of r){if(i.startsWith(".")||i==="node_modules"||i==="__tests__")continue;const n=c(p,i);try{if(j(n).isDirectory())E(n,e,s);else if(C.has(v(i))){const o=M(e,n).replace(/\\/g,"/"),l=d(n,"utf-8"),f=[];for(const h of l.matchAll(A)){const w=h[1],k=I(p,w,e);k&&f.push(k)}s.set(o,f)}}catch{}}}function I(p,e,s){const r=S(p,e);for(const i of[".ts",".tsx",".mts",".js",".mjs",""]){const n=i?r.replace(/\.[^.]+$/,"")+i:r;return M(s,n).replace(/\\/g,"/").replace(/\.js$/,".ts").replace(/\.mjs$/,".mts")}return null}export{D as health};
@@ -1,6 +1,7 @@
1
+ export { type AuditCheck, type AuditData, type AuditOptions, type AuditRecommendation, audit, } from './audit.js';
1
2
  export { type BatchOperation, type BatchOptions, type BatchResult, batch, } from './batch.js';
2
3
  export { type ChangelogEntry, type ChangelogFormat, type ChangelogOptions, type ChangelogResult, changelog, formatChangelog, } from './changelog.js';
3
- export { type CheckOptions, type CheckResult, check } from './check.js';
4
+ export { type CheckOptions, type CheckResult, type CheckSummaryResult, check, summarizeCheckResult, } from './check.js';
4
5
  export { type Checkpoint, checkpointLatest, checkpointList, checkpointLoad, checkpointSave, } from './checkpoint.js';
5
6
  export { type CodemodChange, type CodemodOptions, type CodemodResult, type CodemodRule, codemod, } from './codemod.js';
6
7
  export { type CompactOptions, type CompactResult, compact } from './compact.js';
@@ -20,17 +21,20 @@ export { type ClassifyTrigger, type ForgeClassifyCeremony, type ForgeClassifyOpt
20
21
  export { type ConstraintRef, type ForgeGroundOptions, type ForgeGroundResult, forgeGround, } from './forge-ground.js';
21
22
  export { type GitContextOptions, type GitContextResult, gitContext, } from './git-context.js';
22
23
  export { type GraphAugmentedResult, type GraphAugmentOptions, type GraphQueryOptions, type GraphQueryResult, graphAugmentSearch, graphQuery, } from './graph-query.js';
24
+ export { type GuideRecommendation, type GuideResult, guide } from './guide.js';
23
25
  export { type HealthCheck, type HealthResult, health, } from './health.js';
24
26
  export { type HttpMethod, type HttpRequestOptions, type HttpRequestResult, httpRequest, } from './http-request.js';
25
27
  export { type LaneDiffEntry, type LaneDiffResult, type LaneMergeResult, type LaneMeta, laneCreate, laneDiff, laneDiscard, laneList, laneMerge, laneStatus, } from './lane.js';
26
28
  export { analyzeFile, type FileMetrics, type MeasureOptions, type MeasureResult, measure, } from './measure.js';
27
29
  export { type OnboardMode, type OnboardOptions, type OnboardResult, type OnboardStepResult, onboard, } from './onboard.js';
28
30
  export { type ParsedError, type ParsedGitStatus, type ParsedOutput, type ParsedTestResult, type ParsedTestSummary, parseBiome, parseGitStatus, parseOutput, parseTsc, parseVitest, } from './parse-output.js';
31
+ export { resolvePath } from './path-resolver.js';
29
32
  export { type ManagedProcess, processList, processLogs, processStart, processStatus, processStop, } from './process-manager.js';
30
33
  export { type QueueItem, type QueueState, queueClear, queueCreate, queueDelete, queueDone, queueFail, queueGet, queueList, queueNext, queuePush, } from './queue.js';
31
34
  export { type RegexTestOptions, type RegexTestResult, regexTest, } from './regex-test.js';
32
35
  export { type RenameChange, type RenameOptions, type RenameResult, rename, } from './rename.js';
33
36
  export { type ReplayEntry, type ReplayOptions, replayAppend, replayCapture, replayClear, replayList, replayTrim, } from './replay.js';
37
+ export { errorResponse, type KBError, type KBErrorCode, type KBNextHint, type KBResponse, type KBResponseMeta, okResponse, } from './response-envelope.js';
34
38
  export { type SchemaValidateOptions, type SchemaValidateResult, schemaValidate, type ValidationError, } from './schema-validate.js';
35
39
  export { type ScopeMapEntry, type ScopeMapOptions, type ScopeMapResult, scopeMap, } from './scope-map.js';
36
40
  export { type Snippet, type SnippetAction, type SnippetOptions, type SnippetResult, snippet, } from './snippet.js';
@@ -41,7 +45,7 @@ export { classifyExitCode, type TestRunOptions, type TestRunResult, testRun } fr
41
45
  export { cosineSimilarity, estimateTokens, segment, } from './text-utils.js';
42
46
  export { type TimeOptions, type TimeResult, timeUtils, } from './time-utils.js';
43
47
  export { type TraceNode, type TraceOptions, type TraceResult, trace } from './trace.js';
44
- export { headTailTruncate, paragraphTruncate } from './truncation.js';
48
+ export { headTailTruncate, paragraphTruncate, truncateToTokenBudget } from './truncation.js';
45
49
  export { type WatchEvent, type WatchHandle, type WatchOptions, watchList, watchStart, watchStop, } from './watch.js';
46
50
  export { type WebFetchMode, type WebFetchOptions, type WebFetchResult, webFetch, } from './web-fetch.js';
47
51
  export { parseSearchResults, type WebSearchOptions, type WebSearchResult, type WebSearchResultItem, webSearch, } from './web-search.js';
@@ -1 +1 @@
1
- import{batch as p}from"./batch.js";import{changelog as r,formatChangelog as s}from"./changelog.js";import{check as y}from"./check.js";import{checkpointLatest as i,checkpointList as l,checkpointLoad as u,checkpointSave as m}from"./checkpoint.js";import{codemod as c}from"./codemod.js";import{compact as h}from"./compact.js";import{dataTransform as R}from"./data-transform.js";import{findDeadSymbols as O}from"./dead-symbols.js";import{delegate as C,delegateListModels as E}from"./delegate.js";import{diffParse as F}from"./diff-parse.js";import{digest as b}from"./digest.js";import{encode as M}from"./encode.js";import{envInfo as W}from"./env-info.js";import{evaluate as L}from"./eval.js";import{evidenceMap as P}from"./evidence-map.js";import{fileSummary as H}from"./file-summary.js";import{find as I}from"./find.js";import{findExamples as V}from"./find-examples.js";import{forgeClassify as U}from"./forge-classify.js";import{forgeGround as z}from"./forge-ground.js";import{gitContext as J}from"./git-context.js";import{graphAugmentSearch as X,graphQuery as Y}from"./graph-query.js";import{health as _}from"./health.js";import{httpRequest as ee}from"./http-request.js";import{laneCreate as pe,laneDiff as oe,laneDiscard as re,laneList as se,laneMerge as ae,laneStatus as ye}from"./lane.js";import{analyzeFile as ie,measure as le}from"./measure.js";import{onboard as me}from"./onboard.js";import{parseBiome as ce,parseGitStatus as de,parseOutput as he,parseTsc as xe,parseVitest as Re}from"./parse-output.js";import{processList as Oe,processLogs as Se,processStart as Ce,processStatus as Ee,processStop as Te}from"./process-manager.js";import{queueClear as De,queueCreate as be,queueDelete as ke,queueDone as Me,queueFail as ve,queueGet as We,queueList as Ge,queueNext as Le,queuePush as qe}from"./queue.js";import{regexTest as we}from"./regex-test.js";import{rename as Ae}from"./rename.js";import{replayAppend as Qe,replayCapture as Ve,replayClear as Be,replayList as Ue,replayTrim as Ne}from"./replay.js";import{schemaValidate as je}from"./schema-validate.js";import{scopeMap as Ke}from"./scope-map.js";import{snippet as Ye}from"./snippet.js";import{stashClear as _e,stashDelete as $e,stashGet as et,stashList as tt,stashSet as pt}from"./stash.js";import{stratumCard as rt}from"./stratum-card.js";import{symbol as at}from"./symbol.js";import{classifyExitCode as nt,testRun as it}from"./test-run.js";import{cosineSimilarity as ut,estimateTokens as mt,segment as ft}from"./text-utils.js";import{timeUtils as dt}from"./time-utils.js";import{trace as xt}from"./trace.js";import{headTailTruncate as gt,paragraphTruncate as Ot}from"./truncation.js";import{watchList as Ct,watchStart as Et,watchStop as Tt}from"./watch.js";import{webFetch as Dt}from"./web-fetch.js";import{parseSearchResults as kt,webSearch as Mt}from"./web-search.js";import{addToWorkset as Wt,deleteWorkset as Gt,getWorkset as Lt,listWorksets as qt,removeFromWorkset as Pt,saveWorkset as wt}from"./workset.js";export{Wt as addToWorkset,ie as analyzeFile,p as batch,r as changelog,y as check,i as checkpointLatest,l as checkpointList,u as checkpointLoad,m as checkpointSave,nt as classifyExitCode,c as codemod,h as compact,ut as cosineSimilarity,R as dataTransform,C as delegate,E as delegateListModels,Gt as deleteWorkset,F as diffParse,b as digest,M as encode,W as envInfo,mt as estimateTokens,L as evaluate,P as evidenceMap,H as fileSummary,I as find,O as findDeadSymbols,V as findExamples,U as forgeClassify,z as forgeGround,s as formatChangelog,Lt as getWorkset,J as gitContext,X as graphAugmentSearch,Y as graphQuery,gt as headTailTruncate,_ as health,ee as httpRequest,pe as laneCreate,oe as laneDiff,re as laneDiscard,se as laneList,ae as laneMerge,ye as laneStatus,qt as listWorksets,le as measure,me as onboard,Ot as paragraphTruncate,ce as parseBiome,de as parseGitStatus,he as parseOutput,kt as parseSearchResults,xe as parseTsc,Re as parseVitest,Oe as processList,Se as processLogs,Ce as processStart,Ee as processStatus,Te as processStop,De as queueClear,be as queueCreate,ke as queueDelete,Me as queueDone,ve as queueFail,We as queueGet,Ge as queueList,Le as queueNext,qe as queuePush,we as regexTest,Pt as removeFromWorkset,Ae as rename,Qe as replayAppend,Ve as replayCapture,Be as replayClear,Ue as replayList,Ne as replayTrim,wt as saveWorkset,je as schemaValidate,Ke as scopeMap,ft as segment,Ye as snippet,_e as stashClear,$e as stashDelete,et as stashGet,tt as stashList,pt as stashSet,rt as stratumCard,at as symbol,it as testRun,dt as timeUtils,xt as trace,Ct as watchList,Et as watchStart,Tt as watchStop,Dt as webFetch,Mt as webSearch};
1
+ import{audit as p}from"./audit.js";import{batch as r}from"./batch.js";import{changelog as a,formatChangelog as y}from"./changelog.js";import{check as i,summarizeCheckResult as u}from"./check.js";import{checkpointLatest as m,checkpointList as d,checkpointLoad as f,checkpointSave as c}from"./checkpoint.js";import{codemod as h}from"./codemod.js";import{compact as g}from"./compact.js";import{dataTransform as S}from"./data-transform.js";import{findDeadSymbols as E}from"./dead-symbols.js";import{delegate as k,delegateListModels as F}from"./delegate.js";import{diffParse as b}from"./diff-parse.js";import{digest as v}from"./digest.js";import{encode as W}from"./encode.js";import{envInfo as q}from"./env-info.js";import{evaluate as B}from"./eval.js";import{evidenceMap as H}from"./evidence-map.js";import{fileSummary as I}from"./file-summary.js";import{find as Q}from"./find.js";import{findExamples as N}from"./find-examples.js";import{forgeClassify as z}from"./forge-classify.js";import{forgeGround as J}from"./forge-ground.js";import{gitContext as Y}from"./git-context.js";import{graphAugmentSearch as _,graphQuery as $}from"./graph-query.js";import{guide as te}from"./guide.js";import{health as oe}from"./health.js";import{httpRequest as se}from"./http-request.js";import{laneCreate as ye,laneDiff as ne,laneDiscard as ie,laneList as ue,laneMerge as le,laneStatus as me}from"./lane.js";import{analyzeFile as fe,measure as ce}from"./measure.js";import{onboard as he}from"./onboard.js";import{parseBiome as ge,parseGitStatus as Oe,parseOutput as Se,parseTsc as Ce,parseVitest as Ee}from"./parse-output.js";import{resolvePath as ke}from"./path-resolver.js";import{processList as De,processLogs as be,processStart as Me,processStatus as ve,processStop as Ge}from"./process-manager.js";import{queueClear as Le,queueCreate as qe,queueDelete as Ae,queueDone as Be,queueFail as Pe,queueGet as He,queueList as we,queueNext as Ie,queuePush as Ke}from"./queue.js";import{regexTest as Ve}from"./regex-test.js";import{rename as Ue}from"./rename.js";import{replayAppend as je,replayCapture as Je,replayClear as Xe,replayList as Ye,replayTrim as Ze}from"./replay.js";import{errorResponse as $e,okResponse as et}from"./response-envelope.js";import{schemaValidate as pt}from"./schema-validate.js";import{scopeMap as rt}from"./scope-map.js";import{snippet as at}from"./snippet.js";import{stashClear as nt,stashDelete as it,stashGet as ut,stashList as lt,stashSet as mt}from"./stash.js";import{stratumCard as ft}from"./stratum-card.js";import{symbol as Rt}from"./symbol.js";import{classifyExitCode as xt,testRun as gt}from"./test-run.js";import{cosineSimilarity as St,estimateTokens as Ct,segment as Et}from"./text-utils.js";import{timeUtils as kt}from"./time-utils.js";import{trace as Dt}from"./trace.js";import{headTailTruncate as Mt,paragraphTruncate as vt,truncateToTokenBudget as Gt}from"./truncation.js";import{watchList as Lt,watchStart as qt,watchStop as At}from"./watch.js";import{webFetch as Pt}from"./web-fetch.js";import{parseSearchResults as wt,webSearch as It}from"./web-search.js";import{addToWorkset as Qt,deleteWorkset as Vt,getWorkset as Nt,listWorksets as Ut,removeFromWorkset as zt,saveWorkset as jt}from"./workset.js";export{Qt as addToWorkset,fe as analyzeFile,p as audit,r as batch,a as changelog,i as check,m as checkpointLatest,d as checkpointList,f as checkpointLoad,c as checkpointSave,xt as classifyExitCode,h as codemod,g as compact,St as cosineSimilarity,S as dataTransform,k as delegate,F as delegateListModels,Vt as deleteWorkset,b as diffParse,v as digest,W as encode,q as envInfo,$e as errorResponse,Ct as estimateTokens,B as evaluate,H as evidenceMap,I as fileSummary,Q as find,E as findDeadSymbols,N as findExamples,z as forgeClassify,J as forgeGround,y as formatChangelog,Nt as getWorkset,Y as gitContext,_ as graphAugmentSearch,$ as graphQuery,te as guide,Mt as headTailTruncate,oe as health,se as httpRequest,ye as laneCreate,ne as laneDiff,ie as laneDiscard,ue as laneList,le as laneMerge,me as laneStatus,Ut as listWorksets,ce as measure,et as okResponse,he as onboard,vt as paragraphTruncate,ge as parseBiome,Oe as parseGitStatus,Se as parseOutput,wt as parseSearchResults,Ce as parseTsc,Ee as parseVitest,De as processList,be as processLogs,Me as processStart,ve as processStatus,Ge as processStop,Le as queueClear,qe as queueCreate,Ae as queueDelete,Be as queueDone,Pe as queueFail,He as queueGet,we as queueList,Ie as queueNext,Ke as queuePush,Ve as regexTest,zt as removeFromWorkset,Ue as rename,je as replayAppend,Je as replayCapture,Xe as replayClear,Ye as replayList,Ze as replayTrim,ke as resolvePath,jt as saveWorkset,pt as schemaValidate,rt as scopeMap,Et as segment,at as snippet,nt as stashClear,it as stashDelete,ut as stashGet,lt as stashList,mt as stashSet,ft as stratumCard,u as summarizeCheckResult,Rt as symbol,gt as testRun,kt as timeUtils,Dt as trace,Gt as truncateToTokenBudget,Lt as watchList,qt as watchStart,At as watchStop,Pt as webFetch,It as webSearch};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared path resolver for MCP tools (E-014).
3
+ * Provides consistent path resolution across all tools.
4
+ */
5
+ /**
6
+ * Resolve a user-supplied path to an absolute path.
7
+ * - Absolute paths are returned as-is
8
+ * - Relative paths are resolved against the server's cwd
9
+ * - '.' and empty/undefined default to cwd
10
+ */
11
+ export declare function resolvePath(input?: string): string;
12
+ //# sourceMappingURL=path-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ import{isAbsolute as e,resolve as s}from"node:path";function t(r){return!r||r==="."?process.cwd():e(r)?r:s(process.cwd(),r)}export{t as resolvePath};
@@ -2,7 +2,7 @@
2
2
  * Replay — append-only audit trail of tool/CLI invocations.
3
3
  *
4
4
  * Captures tool name, arguments (redacted), duration, and result summary
5
- * to `.kb-state/replay.jsonl`. Used by `kb replay` CLI, `kb_replay_list` MCP,
5
+ * to `.kb-state/replay.jsonl`. Used by `kb replay` CLI, `kb_replay` MCP tool,
6
6
  * and the TUI log panel.
7
7
  */
8
8
  export interface ReplayEntry {
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Standardized response envelope for KB tools (E-009).
3
+ * New tools should return KBResponse<T>. Existing tools can adopt gradually.
4
+ */
5
+ export interface KBNextHint {
6
+ tool: string;
7
+ reason: string;
8
+ suggested_args?: Record<string, unknown>;
9
+ }
10
+ export interface KBError {
11
+ code: KBErrorCode;
12
+ category: 'input' | 'runtime' | 'dependency' | 'timeout' | 'not_found';
13
+ retryable: boolean;
14
+ message: string;
15
+ suggestion?: string;
16
+ }
17
+ export type KBErrorCode = 'SYMBOL_NOT_FOUND' | 'INDEX_STALE' | 'TREE_SITTER_UNAVAILABLE' | 'PARSE_FAILED' | 'BUDGET_EXCEEDED' | 'PATH_NOT_FOUND' | 'EMBEDDING_COLD_START' | 'ANALYSIS_FAILED';
18
+ export interface KBResponseMeta {
19
+ durationMs: number;
20
+ tokensEstimate: number;
21
+ detail: 'summary' | 'errors' | 'full';
22
+ cached: boolean;
23
+ truncated: boolean;
24
+ caveats?: string[];
25
+ }
26
+ export interface KBResponse<T> {
27
+ ok: boolean;
28
+ tool: string;
29
+ summary: string;
30
+ data?: T;
31
+ meta: KBResponseMeta;
32
+ next?: KBNextHint[];
33
+ error?: KBError;
34
+ }
35
+ /** Create a success response. */
36
+ export declare function okResponse<T>(tool: string, summary: string, data: T, meta: Partial<KBResponseMeta> & {
37
+ durationMs: number;
38
+ }, next?: KBNextHint[]): KBResponse<T>;
39
+ /** Create an error response. */
40
+ export declare function errorResponse(tool: string, error: KBError, durationMs: number): KBResponse<never>;
41
+ //# sourceMappingURL=response-envelope.d.ts.map
@@ -0,0 +1 @@
1
+ import{estimateTokens as n}from"./text-utils.js";function u(s,r,t,e,o){const a=typeof t=="string"?t:JSON.stringify(t);return{ok:!0,tool:s,summary:r,data:t,meta:{durationMs:e.durationMs,tokensEstimate:e.tokensEstimate??n(a),detail:e.detail??"summary",cached:e.cached??!1,truncated:e.truncated??!1,...e.caveats?.length?{caveats:e.caveats}:{}},next:o}}function c(s,r,t){return{ok:!1,tool:s,summary:r.message,meta:{durationMs:t,tokensEstimate:n(r.message),detail:"summary",cached:!1,truncated:!1},error:r}}export{c as errorResponse,u as okResponse};
@@ -44,6 +44,8 @@ export interface ScopeMapResult {
44
44
  totalEstimatedTokens: number;
45
45
  /** Suggested reading order (file paths) */
46
46
  readingOrder: string[];
47
+ /** Suggested compact/file_summary commands to reduce context */
48
+ compactCommands: string[];
47
49
  }
48
50
  /**
49
51
  * Generate a task-scoped reading plan.
@@ -1 +1 @@
1
- function M(c){return Math.ceil(c.length/4)}async function T(c,h,u){const{task:d,maxFiles:m=15,contentType:l,origin:g}=u,f=await c.embed(d),S={limit:m*3,contentType:l,origin:g},x=await h.search(f,S),s=new Map;for(const e of x){const t=e.record.sourcePath,r=s.get(t);r?(r.chunks.push(e),r.totalChars+=e.record.content.length,r.maxScore=Math.max(r.maxScore,e.score)):s.set(t,{chunks:[e],totalChars:e.record.content.length,maxScore:e.score})}const o=[...s.entries()].sort(([,e],[,t])=>t.maxScore-e.maxScore).slice(0,m).map(([e,{chunks:t,maxScore:r}])=>{const a=t.sort((n,p)=>n.record.startLine-p.record.startLine).map(n=>({start:n.record.startLine,end:n.record.endLine,heading:n.record.headingPath})),i=t.sort((n,p)=>p.score-n.score)[0],b=i.record.headingPath?`Matches: ${i.record.headingPath}`:`Contains relevant ${i.record.contentType} content`;return{path:e,reason:b,estimatedTokens:0,relevance:r,focusRanges:a}});for(const e of o){const t=s.get(e.path);t&&(e.estimatedTokens=M(t.chunks.map(r=>r.record.content).join("")))}const y=o.reduce((e,t)=>e+t.estimatedTokens,0),k=[...o].sort((e,t)=>{const r=e.path.includes("config")||e.path.includes("types")?-1:0,a=t.path.includes("config")||t.path.includes("types")?-1:0;return r!==a?r-a:t.relevance-e.relevance}).map(e=>e.path);return{task:d,files:o,totalEstimatedTokens:y,readingOrder:k}}export{T as scopeMap};
1
+ function C(c){return Math.ceil(c.length/4)}async function E(c,u,l){const{task:i,maxFiles:h=15,contentType:g,origin:f}=l,k=await c.embed(i),S={limit:h*3,contentType:g,origin:f},y=await u.search(k,S),o=new Map;for(const e of y){const t=e.record.sourcePath,n=o.get(t);n?(n.chunks.push(e),n.totalChars+=e.record.content.length,n.maxScore=Math.max(n.maxScore,e.score)):o.set(t,{chunks:[e],totalChars:e.record.content.length,maxScore:e.score})}const s=[...o.entries()].sort(([,e],[,t])=>t.maxScore-e.maxScore).slice(0,h).map(([e,{chunks:t,maxScore:n}])=>{const a=t.sort((r,m)=>r.record.startLine-m.record.startLine).map(r=>({start:r.record.startLine,end:r.record.endLine,heading:r.record.headingPath})),d=t.sort((r,m)=>m.score-r.score)[0],T=d.record.headingPath?`Matches: ${d.record.headingPath}`:`Contains relevant ${d.record.contentType} content`;return{path:e,reason:T,estimatedTokens:0,relevance:n,focusRanges:a}});for(const e of s){const t=o.get(e.path);t&&(e.estimatedTokens=C(t.chunks.map(n=>n.record.content).join("")))}const x=s.reduce((e,t)=>e+t.estimatedTokens,0),b=[...s].sort((e,t)=>{const n=e.path.includes("config")||e.path.includes("types")?-1:0,a=t.path.includes("config")||t.path.includes("types")?-1:0;return n!==a?n-a:t.relevance-e.relevance}).map(e=>e.path),M=100,p=[];for(const e of s)e.estimatedTokens<=M?p.push(`kb_file_summary({ path: "${e.path}" }) \u2192 ~${e.estimatedTokens} tokens`):p.push(`kb_compact({ path: "${e.path}", query: "${i}" }) \u2192 ~${Math.ceil(e.estimatedTokens/5)} tokens`);return{task:i,files:s,totalEstimatedTokens:x,readingOrder:b,compactCommands:p}}export{E as scopeMap};
@@ -19,4 +19,13 @@ export declare function headTailTruncate(text: string, maxLen: number, headRatio
19
19
  * Best for web content and markdown where structure is at the top.
20
20
  */
21
21
  export declare function paragraphTruncate(text: string, maxLen: number): string;
22
+ /**
23
+ * Truncate text to fit within a token budget.
24
+ * Uses ~4 chars/token approximation. Snaps to line boundaries.
25
+ *
26
+ * @param text - Full text to truncate
27
+ * @param maxTokens - Maximum token count
28
+ * @returns Original text if within budget, or truncated with notice
29
+ */
30
+ export declare function truncateToTokenBudget(text: string, maxTokens: number): string;
22
31
  //# sourceMappingURL=truncation.d.ts.map
@@ -1,14 +1,14 @@
1
- const T=.6;function m(t,n,c=.6){if(t.length<=n)return t;const o=Math.max(0,n-120),e=Math.floor(o*c),a=o-e,s=t.slice(0,e),h=s.lastIndexOf(`
2
- `),i=h>0?s.slice(0,h):s,p=t.length-a,l=t.slice(p),d=l.indexOf(`
3
- `),r=d>=0?l.slice(d+1):l,$=t.length-i.length-r.length;let u=1;const B=i.length,R=t.length-r.length;for(let g=B;g<R;g++)t.charCodeAt(g)===10&&u++;return`${i}
1
+ const R=.6;function m(n,t,e=.6){if(n.length<=t)return n;const r=Math.max(0,t-120),o=Math.floor(r*e),a=r-o,s=n.slice(0,o),h=s.lastIndexOf(`
2
+ `),i=h>0?s.slice(0,h):s,p=n.length-a,l=n.slice(p),u=l.indexOf(`
3
+ `),c=u>=0?l.slice(u+1):l,$=n.length-i.length-c.length;let d=1;const B=i.length,T=n.length-c.length;for(let g=B;g<T;g++)n.charCodeAt(g)===10&&d++;return`${i}
4
4
 
5
- [\u2026 ${u} lines / ${($/1024).toFixed(1)}KB truncated \u2014 showing first ${i.split(`
6
- `).length} + last ${r.split(`
5
+ [\u2026 ${d} lines / ${($/1024).toFixed(1)}KB truncated \u2014 showing first ${i.split(`
6
+ `).length} + last ${c.split(`
7
7
  `).length} lines]
8
8
 
9
- ${r}`}function A(t,n){if(t.length<=n)return t;const c=Math.max(0,n-200),o=t.slice(c,n).lastIndexOf(`
9
+ ${c}`}function A(n,t){if(n.length<=t)return n;const e=Math.max(0,t-200),r=n.slice(e,t).lastIndexOf(`
10
10
 
11
- `),e=o>=0?c+o:n,a=t.slice(0,e).trimEnd(),s=Math.round(e/t.length*100);return`${a}
11
+ `),o=r>=0?e+r:t,a=n.slice(0,o).trimEnd(),s=Math.round(o/n.length*100);return`${a}
12
12
 
13
13
  ---
14
- *[Truncated at ${e.toLocaleString()} chars \u2014 ${s}% of original content]*`}export{m as headTailTruncate,A as paragraphTruncate};
14
+ *[Truncated at ${o.toLocaleString()} chars \u2014 ${s}% of original content]*`}function C(n,t){const e=t*4;return n.length<=e?n:m(n,e)}export{m as headTailTruncate,A as paragraphTruncate,C as truncateToTokenBudget};