@vpxa/kb 0.1.23 → 0.1.24

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 (39) hide show
  1. package/package.json +1 -1
  2. package/packages/server/dist/config.js +1 -1
  3. package/packages/server/dist/index.js +1 -1
  4. package/packages/server/dist/prompts.js +2 -1
  5. package/packages/server/dist/server.js +3 -1
  6. package/packages/server/dist/tool-metadata.js +1 -1
  7. package/packages/server/dist/tools/analyze.tools.js +1 -1
  8. package/packages/server/dist/tools/bridge.tools.js +1 -1
  9. package/packages/server/dist/tools/context.tools.js +4 -4
  10. package/packages/server/dist/tools/execution.tools.js +3 -2
  11. package/packages/server/dist/tools/forge.tools.js +2 -2
  12. package/packages/server/dist/tools/forget.tool.js +1 -1
  13. package/packages/server/dist/tools/infra.tools.js +2 -2
  14. package/packages/server/dist/tools/list.tool.js +2 -2
  15. package/packages/server/dist/tools/lookup.tool.js +1 -1
  16. package/packages/server/dist/tools/manipulation.tools.js +2 -2
  17. package/packages/server/dist/tools/onboard.tool.js +2 -2
  18. package/packages/server/dist/tools/persistence.tools.js +4 -4
  19. package/packages/server/dist/tools/policy.tools.js +3 -2
  20. package/packages/server/dist/tools/produce.tool.js +1 -1
  21. package/packages/server/dist/tools/read.tool.js +1 -1
  22. package/packages/server/dist/tools/reindex.tool.js +1 -1
  23. package/packages/server/dist/tools/remember.tool.js +1 -1
  24. package/packages/server/dist/tools/replay.tool.js +1 -1
  25. package/packages/server/dist/tools/search.tool.js +1 -1
  26. package/packages/server/dist/tools/toolkit.tools.js +11 -11
  27. package/packages/server/dist/tools/update.tool.js +1 -1
  28. package/packages/server/dist/tools/utility.tools.js +8 -8
  29. package/packages/store/dist/lance-store.d.ts +1 -0
  30. package/packages/store/dist/lance-store.js +1 -1
  31. package/packages/tools/dist/audit.js +1 -1
  32. package/packages/tools/dist/check.js +1 -1
  33. package/packages/tools/dist/compact.js +2 -2
  34. package/packages/tools/dist/eval.js +2 -2
  35. package/packages/tools/dist/file-summary.js +2 -2
  36. package/packages/tools/dist/queue.js +1 -1
  37. package/packages/tools/dist/symbol.js +1 -1
  38. package/packages/tools/dist/test-run.d.ts +3 -1
  39. package/packages/tools/dist/test-run.js +1 -1
@@ -1,3 +1,3 @@
1
- import{cosineSimilarity as e,segment as t}from"./text-utils.js";import{readFile as n}from"node:fs/promises";async function r(r,i){let{query:a,maxChars:o=3e3,minScore:s=.3,segmentation:c=`paragraph`}=i,l;if(i.text)l=i.text;else if(i.path)l=i.cache?(await i.cache.get(i.path)).content:await n(i.path,`utf-8`);else throw Error(`Either "text" or "path" must be provided`);if(l.length<=o)return{text:l,originalChars:l.length,compressedChars:l.length,ratio:1,segmentsKept:1,segmentsTotal:1};let u=t(l,c);if(u.length===0)return{text:``,originalChars:l.length,compressedChars:0,ratio:0,segmentsKept:0,segmentsTotal:0};let d=await r.embed(a),f=[];for(let t=0;t<u.length;t++){let n=e(d,await r.embed(u[t]));f.push({text:u[t],score:n,index:t})}let p=f.filter(e=>e.score>=s).sort((e,t)=>t.score-e.score),m=[],h=0;for(let e of p){if(h+e.text.length>o){h===0&&(m.push({...e,text:e.text.slice(0,o)}),h=o);break}m.push(e),h+=e.text.length+2}m.sort((e,t)=>e.index-t.index);let g=m.map(e=>e.text).join(`
1
+ import{cosineSimilarity as e,segment as t}from"./text-utils.js";import{readFile as n,stat as r}from"node:fs/promises";async function i(i,a){let{query:o,maxChars:s=3e3,minScore:c=.3,segmentation:l=`paragraph`}=a,u;if(a.text)u=a.text;else if(a.path){let e;try{e=await r(a.path)}catch(e){let t=e.code;throw t===`ENOENT`?Error(`File not found: ${a.path}. Check the path and try again.`):t===`EACCES`||t===`EPERM`?Error(`Permission denied reading ${a.path}. The file exists but is not accessible.`):e}if(e.size>1e7)throw Error(`File too large (${(e.size/1e6).toFixed(1)}MB). compact supports files up to 10MB. Consider splitting or using search instead.`);u=a.cache?(await a.cache.get(a.path)).content:await n(a.path,`utf-8`)}else throw Error(`Either "text" or "path" must be provided`);if(u.length<=s)return{text:u,originalChars:u.length,compressedChars:u.length,ratio:1,segmentsKept:1,segmentsTotal:1};let d=t(u,l);if(d.length===0)return{text:``,originalChars:u.length,compressedChars:0,ratio:0,segmentsKept:0,segmentsTotal:0};let f=await i.embed(o),p=[];for(let t=0;t<d.length;t++){let n=e(f,await i.embed(d[t]));p.push({text:d[t],score:n,index:t})}let m=p.filter(e=>e.score>=c).sort((e,t)=>t.score-e.score),h=[],g=0;for(let e of m){if(g+e.text.length>s){g===0&&(h.push({...e,text:e.text.slice(0,s)}),g=s);break}h.push(e),g+=e.text.length+2}h.sort((e,t)=>e.index-t.index);let _=h.map(e=>e.text).join(`
2
2
 
3
- `);return{text:g,originalChars:l.length,compressedChars:g.length,ratio:g.length/l.length,segmentsKept:m.length,segmentsTotal:u.length}}export{r as compact};
3
+ `);return{text:_,originalChars:u.length,compressedChars:_.length,ratio:_.length/u.length,segmentsKept:h.length,segmentsTotal:d.length}}export{i as compact};
@@ -1,2 +1,2 @@
1
- import e from"node:vm";function t(t){let{code:i,lang:a=`js`,timeout:o=5e3}=t,s=Date.now();try{let t=a===`ts`?r(i):i,c=[],l={console:{log:(...e)=>c.push(e.map(String).join(` `)),error:(...e)=>c.push(`[error] ${e.map(String).join(` `)}`),warn:(...e)=>c.push(`[warn] ${e.map(String).join(` `)}`)},setTimeout:void 0,setInterval:void 0,setImmediate:void 0,fetch:void 0,process:void 0,require:void 0,JSON,Math,Date,Array,Object,String,Number,Boolean,Map,Set,RegExp,Error,Promise,parseInt,parseFloat,isNaN,isFinite},u=e.createContext(l,{codeGeneration:{strings:!1,wasm:!1}}),d=e.runInContext(t,u,{timeout:o});return{success:!0,output:c.length>0?c.join(`
2
- `)+(d===void 0?``:`\n→ ${n(d)}`):d===void 0?`(no output)`:n(d),durationMs:Date.now()-s}}catch(e){return{success:!1,output:``,error:e.message,durationMs:Date.now()-s}}}function n(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function r(e){return e.replace(/^\s*import\s+type\s+.*?;\s*$/gm,``).replace(/^\s*(?:export\s+)?interface\s+\w+[^{]*\{[\s\S]*?^\s*}\s*$/gm,``).replace(/^\s*(?:export\s+)?type\s+\w+\s*=.*?;\s*$/gm,``).replace(/([,(]\s*[A-Za-z_$][\w$]*)\s*:\s*[^,)=\n]+/g,`$1`).replace(/\)\s*:\s*[^={\n]+(?=\s*(?:=>|\{))/g,`)`).replace(/\s+as\s+[A-Za-z_$][\w$<>,[\]|&\s.]*/g,``).replace(/<(?:[A-Za-z_$][\w$]*\s*,?\s*)+>(?=\s*\()/g,``)}export{t as evaluate};
1
+ import e from"node:vm";function t(t){let{code:i,lang:a=`js`,timeout:o=5e3}=t,s=Math.min(Math.max(o,100),1e4),c=Date.now();try{let t=a===`ts`?r(i):i,o=[],l={console:{log:(...e)=>o.push(e.map(String).join(` `)),error:(...e)=>o.push(`[error] ${e.map(String).join(` `)}`),warn:(...e)=>o.push(`[warn] ${e.map(String).join(` `)}`)},setTimeout:void 0,setInterval:void 0,setImmediate:void 0,fetch:void 0,process:void 0,require:void 0,JSON,Math,Date,Array,Object,String,Number,Boolean,Map,Set,RegExp,Error,Promise,parseInt,parseFloat,isNaN,isFinite},u=e.createContext(l,{codeGeneration:{strings:!1,wasm:!1}}),d=e.runInContext(t,u,{timeout:s});return{success:!0,output:o.length>0?o.join(`
2
+ `)+(d===void 0?``:`\n→ ${n(d)}`):d===void 0?`(no output)`:n(d),durationMs:Date.now()-c}}catch(e){return{success:!1,output:``,error:e.message,durationMs:Date.now()-c}}}function n(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function r(e){return e.replace(/^\s*import\s+type\s+.*?;\s*$/gm,``).replace(/^\s*(?:export\s+)?interface\s+\w+[^{]*\{[\s\S]*?^\s*}\s*$/gm,``).replace(/^\s*(?:export\s+)?type\s+\w+\s*=.*?;\s*$/gm,``).replace(/([,(]\s*[A-Za-z_$][\w$]*)\s*:\s*[^,)=\n]+/g,`$1`).replace(/\)\s*:\s*[^={\n]+(?=\s*(?:=>|\{))/g,`)`).replace(/\s+as\s+[A-Za-z_$][\w$<>,[\]|&\s.]*/g,``).replace(/<(?:[A-Za-z_$][\w$]*\s*,?\s*)+>(?=\s*\()/g,``)}export{t as evaluate};
@@ -1,2 +1,2 @@
1
- import{readFile as e}from"node:fs/promises";import{extname as t}from"node:path";import{SUPPORTED_EXTENSIONS as n,WasmRuntime as r,extractCalls as i,extractImports as a,extractSymbols as o}from"../../chunker/dist/index.js";async function s(i){let{path:a,previewLines:o=3}=i,s=i.content??await e(a,`utf-8`),u=s.split(`
2
- `),d=a.split(`.`).pop()??``,f=t(a);return r.get()&&n.has(f)?c(a,s,u,d,f):l(a,s,u,d)}async function c(e,t,n,r,s){let[c,l,d]=await Promise.all([o(t,s,e),a(t,s,e),i(t,s,e).catch(()=>[])]),f=l.map(e=>`import ${e.specifiers.length>0?`{ ${e.specifiers.join(`, `)} }`:`*`} from '${e.source}'`),p=[],m=[],h=[],g=[],_=[];for(let e of c)switch(e.exported&&p.push(e.name),e.kind){case`function`:case`method`:m.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`class`:h.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`interface`:g.push({name:e.name,line:e.line,exported:e.exported});break;case`type`:_.push({name:e.name,line:e.line,exported:e.exported});break}let v=l.map(e=>({source:e.source,specifiers:e.specifiers,isExternal:e.isExternal})),y=d.map(e=>({caller:e.callerName,callee:e.calleeName,line:e.line}));return{path:e,lines:n.length,language:u(r),imports:f,exports:p,functions:m,classes:h,interfaces:g,types:_,importDetails:v,callEdges:y.length>0?y:void 0,estimatedTokens:Math.ceil(t.length/4)}}function l(e,t,n,r){let i=[],a=[],o=[],s=[],c=[],l=[];for(let e=0;e<n.length;e+=1){let t=n[e],r=e+1;if(/^import\s+.+/.test(t)){i.push(t.trim());continue}let u=t.match(/^export\s+(?:async\s+)?function\s+(\w+)/);if(u){o.push({name:u[1],line:r,exported:!0}),a.push(u[1]);continue}let d=t.match(/^(?:async\s+)?function\s+(\w+)/);if(d){o.push({name:d[1],line:r,exported:!1});continue}let f=t.match(/^(export\s+)?const\s+(\w+)\s*=.*(?:=>|\bfunction\b)/);if(f){let e=!!f[1];o.push({name:f[2],line:r,exported:e}),e&&a.push(f[2]);continue}let p=t.match(/^export\s+const\s+(\w+)\s*=/);if(p){a.push(p[1]);continue}let m=t.match(/^(export\s+)?(?:abstract\s+)?class\s+(\w+)/);if(m){let e=!!m[1];s.push({name:m[2],line:r,exported:e}),e&&a.push(m[2]);continue}let h=t.match(/^(export\s+)?interface\s+(\w+)/);if(h){let e=!!h[1];c.push({name:h[2],line:r,exported:e}),e&&a.push(h[2]);continue}let g=t.match(/^(export\s+)?type\s+(\w+)/);if(g){let e=!!g[1];l.push({name:g[2],line:r,exported:e}),e&&a.push(g[2]);continue}let _=t.match(/^export\s+\{(.+)\}/);if(_){let e=_[1].split(`,`).map(e=>e.trim().split(/\s+as\s+/).pop()?.trim()??``).filter(Boolean);a.push(...e)}}return{path:e,lines:n.length,language:u(r),imports:i,exports:a,functions:o,classes:s,interfaces:c,types:l,estimatedTokens:Math.ceil(t.length/4)}}function u(e){return{ts:`typescript`,tsx:`typescript-jsx`,js:`javascript`,jsx:`javascript-jsx`,py:`python`,rs:`rust`,go:`go`,java:`java`,rb:`ruby`,md:`markdown`,json:`json`,yaml:`yaml`,yml:`yaml`,css:`css`,html:`html`,sh:`shell`,bash:`shell`}[e]??e}export{s as fileSummary};
1
+ import{readFile as e,stat as t}from"node:fs/promises";import{extname as n}from"node:path";import{SUPPORTED_EXTENSIONS as r,WasmRuntime as i,extractCalls as a,extractImports as o,extractSymbols as s}from"../../chunker/dist/index.js";async function c(a){let{path:o,previewLines:s=3}=a;if(!a.content){let e;try{e=await t(o)}catch(e){let t=e.code;throw t===`ENOENT`?Error(`File not found: ${o}. Check the path and try again.`):t===`EACCES`||t===`EPERM`?Error(`Permission denied reading ${o}. The file exists but is not accessible.`):e}if(e.size>1e7)throw Error(`File too large (${(e.size/1e6).toFixed(1)}MB). file_summary supports files up to 10MB. Use search or compact with a query instead.`)}let c=a.content??await e(o,`utf-8`),d=c.split(`
2
+ `),f=o.split(`.`).pop()??``,p=n(o);return i.get()&&r.has(p)?l(o,c,d,f,p):u(o,c,d,f)}async function l(e,t,n,r,i){let[c,l,u]=await Promise.all([s(t,i,e),o(t,i,e),a(t,i,e).catch(()=>[])]),f=l.map(e=>`import ${e.specifiers.length>0?`{ ${e.specifiers.join(`, `)} }`:`*`} from '${e.source}'`),p=[],m=[],h=[],g=[],_=[];for(let e of c)switch(e.exported&&p.push(e.name),e.kind){case`function`:case`method`:m.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`class`:h.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`interface`:g.push({name:e.name,line:e.line,exported:e.exported});break;case`type`:_.push({name:e.name,line:e.line,exported:e.exported});break}let v=l.map(e=>({source:e.source,specifiers:e.specifiers,isExternal:e.isExternal})),y=u.map(e=>({caller:e.callerName,callee:e.calleeName,line:e.line}));return{path:e,lines:n.length,language:d(r),imports:f,exports:p,functions:m,classes:h,interfaces:g,types:_,importDetails:v,callEdges:y.length>0?y:void 0,estimatedTokens:Math.ceil(t.length/4)}}function u(e,t,n,r){let i=[],a=[],o=[],s=[],c=[],l=[];for(let e=0;e<n.length;e+=1){let t=n[e],r=e+1;if(/^import\s+.+/.test(t)){i.push(t.trim());continue}let u=t.match(/^export\s+(?:async\s+)?function\s+(\w+)/);if(u){o.push({name:u[1],line:r,exported:!0}),a.push(u[1]);continue}let d=t.match(/^(?:async\s+)?function\s+(\w+)/);if(d){o.push({name:d[1],line:r,exported:!1});continue}let f=t.match(/^(export\s+)?const\s+(\w+)\s*=.*(?:=>|\bfunction\b)/);if(f){let e=!!f[1];o.push({name:f[2],line:r,exported:e}),e&&a.push(f[2]);continue}let p=t.match(/^export\s+const\s+(\w+)\s*=/);if(p){a.push(p[1]);continue}let m=t.match(/^(export\s+)?(?:abstract\s+)?class\s+(\w+)/);if(m){let e=!!m[1];s.push({name:m[2],line:r,exported:e}),e&&a.push(m[2]);continue}let h=t.match(/^(export\s+)?interface\s+(\w+)/);if(h){let e=!!h[1];c.push({name:h[2],line:r,exported:e}),e&&a.push(h[2]);continue}let g=t.match(/^(export\s+)?type\s+(\w+)/);if(g){let e=!!g[1];l.push({name:g[2],line:r,exported:e}),e&&a.push(g[2]);continue}let _=t.match(/^export\s+\{(.+)\}/);if(_){let e=_[1].split(`,`).map(e=>e.trim().split(/\s+as\s+/).pop()?.trim()??``).filter(Boolean);a.push(...e)}}return{path:e,lines:n.length,language:d(r),imports:i,exports:a,functions:o,classes:s,interfaces:c,types:l,estimatedTokens:Math.ceil(t.length/4)}}function d(e){return{ts:`typescript`,tsx:`typescript-jsx`,js:`javascript`,jsx:`javascript-jsx`,py:`python`,rs:`rust`,go:`go`,java:`java`,rb:`ruby`,md:`markdown`,json:`json`,yaml:`yaml`,yml:`yaml`,css:`css`,html:`html`,sh:`shell`,bash:`shell`}[e]??e}export{c as fileSummary};
@@ -1 +1 @@
1
- import{dirname as e,resolve as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,writeFileSync as a}from"node:fs";import{KB_PATHS as o}from"../../core/dist/index.js";const s=o.state;function c(e){return t(e??process.cwd(),s,`queue.json`)}function l(e){let t=c(e);if(!n(t))return{};try{return JSON.parse(i(t,`utf-8`))}catch{return{}}}function u(t,i){let o=c(i),s=e(o);n(s)||r(s,{recursive:!0}),a(o,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function d(){return`q_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`}function f(e,t){let n=l(t);if(n[e])throw Error(`Queue "${e}" already exists`);let r={name:e,items:[]};return n[e]=r,u(n,t),r}function p(e,t,n,r){let i=l(r);i[e]||(i[e]={name:e,items:[]});let a=new Date().toISOString(),o={id:d(),title:t,status:`pending`,data:n,createdAt:a,updatedAt:a};return i[e].items.push(o),u(i,r),o}function m(e,t){let n=l(t),r=n[e];if(!r)throw Error(`Queue "${e}" does not exist`);let i=r.items.find(e=>e.status===`pending`);return i?(i.status=`in-progress`,i.updatedAt=new Date().toISOString(),u(n,t),i):null}function h(e,t,n){let r=l(n),i=r[e];if(!i)throw Error(`Queue "${e}" does not exist`);let a=i.items.find(e=>e.id===t);if(!a)throw Error(`Item "${t}" not found in queue "${e}"`);return a.status=`done`,a.updatedAt=new Date().toISOString(),u(r,n),a}function g(e,t,n,r){let i=l(r),a=i[e];if(!a)throw Error(`Queue "${e}" does not exist`);let o=a.items.find(e=>e.id===t);if(!o)throw Error(`Item "${t}" not found in queue "${e}"`);return o.status=`failed`,o.error=n,o.updatedAt=new Date().toISOString(),u(i,r),o}function _(e,t){return l(t)[e]??null}function v(e){let t=l(e);return Object.values(t).map(e=>({name:e.name,pending:e.items.filter(e=>e.status===`pending`).length,done:e.items.filter(e=>e.status===`done`).length,failed:e.items.filter(e=>e.status===`failed`).length,total:e.items.length}))}function y(e,t){let n=l(t),r=n[e];if(!r)throw Error(`Queue "${e}" does not exist`);let i=r.items.length;r.items=r.items.filter(e=>e.status===`pending`||e.status===`in-progress`);let a=i-r.items.length;return u(n,t),a}function b(e,t){let n=l(t);return n[e]?(delete n[e],u(n,t),!0):!1}export{y as queueClear,f as queueCreate,b as queueDelete,h as queueDone,g as queueFail,_ as queueGet,v as queueList,m as queueNext,p as queuePush};
1
+ import{dirname as e,resolve as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,writeFileSync as a}from"node:fs";import{KB_PATHS as o}from"../../core/dist/index.js";const s=o.state;function c(e){return t(e??process.cwd(),s,`queue.json`)}function l(e){let t=c(e);if(!n(t))return{};try{return JSON.parse(i(t,`utf-8`))}catch{return{}}}function u(t,i){let o=c(i),s=e(o);n(s)||r(s,{recursive:!0}),a(o,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function d(){return`q_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`}function f(e,t){let n=l(t);if(n[e])throw Error(`Queue "${e}" already exists`);let r={name:e,items:[]};return n[e]=r,u(n,t),r}function p(e,t,n,r){let i=l(r);i[e]||(i[e]={name:e,items:[]});let a=new Date().toISOString(),o={id:d(),title:t,status:`pending`,data:n,createdAt:a,updatedAt:a};if(i[e].items.length>=500)throw Error(`Queue "${e}" has reached the maximum of 500 items. Clear completed items with queue({ action: "clear" }) before adding more.`);return i[e].items.push(o),u(i,r),o}function m(e,t){let n=l(t),r=n[e];if(!r)throw Error(`Queue "${e}" does not exist`);let i=r.items.find(e=>e.status===`pending`);return i?(i.status=`in-progress`,i.updatedAt=new Date().toISOString(),u(n,t),i):null}function h(e,t,n){let r=l(n),i=r[e];if(!i)throw Error(`Queue "${e}" does not exist`);let a=i.items.find(e=>e.id===t);if(!a)throw Error(`Item "${t}" not found in queue "${e}"`);return a.status=`done`,a.updatedAt=new Date().toISOString(),u(r,n),a}function g(e,t,n,r){let i=l(r),a=i[e];if(!a)throw Error(`Queue "${e}" does not exist`);let o=a.items.find(e=>e.id===t);if(!o)throw Error(`Item "${t}" not found in queue "${e}"`);return o.status=`failed`,o.error=n,o.updatedAt=new Date().toISOString(),u(i,r),o}function _(e,t){return l(t)[e]??null}function v(e){let t=l(e);return Object.values(t).map(e=>({name:e.name,pending:e.items.filter(e=>e.status===`pending`).length,done:e.items.filter(e=>e.status===`done`).length,failed:e.items.filter(e=>e.status===`failed`).length,total:e.items.length}))}function y(e,t){let n=l(t),r=n[e];if(!r)throw Error(`Queue "${e}" does not exist`);let i=r.items.length;r.items=r.items.filter(e=>e.status===`pending`||e.status===`in-progress`);let a=i-r.items.length;return u(n,t),a}function b(e,t){let n=l(t);return n[e]?(delete n[e],u(n,t),!0):!1}export{y as queueClear,f as queueCreate,b as queueDelete,h as queueDone,g as queueFail,_ as queueGet,v as queueList,m as queueNext,p as queuePush};
@@ -1,3 +1,3 @@
1
1
  import{extname as e}from"node:path";import{SUPPORTED_EXTENSIONS as t,WasmRuntime as n,extractSymbols as r,resolveScopes as i}from"../../chunker/dist/index.js";function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}async function o(o,s,c){let{name:l,limit:u=20,graphStore:d}=c,f=o.embedQuery?.bind(o)??o.embed.bind(o),p=[`export function ${l}`,`export class ${l}`,`export const ${l}`,`export interface ${l}`,`export type ${l}`,`export enum ${l}`].join(` | `),m=await s.search(await f(p),{limit:u*2}),h=RegExp(`^export\\s+(?:default\\s+)?(?:async\\s+)?(?:function|class|const|let|interface|type|enum)\\s+${a(l)}\\b`,`m`),g;for(let i of m){if(!h.test(i.record.content))continue;let a=i.record.content.match(/export\s+(?:default\s+)?(?:async\s+)?(\w+)/)?.[1]??`unknown`;g={path:i.record.sourcePath,line:i.record.startLine,kind:a};let o=e(i.record.sourcePath);if(n.get()&&t.has(o))try{let e=(await r(i.record.content,o,i.record.sourcePath)).find(e=>e.name===l&&e.exported);e&&(g.kind=e.kind,e.signature&&(g.signature=e.signature))}catch{}break}let _=RegExp(`import\\s+.*\\b${a(l)}\\b.*from\\s+`,`m`),v=await s.search(await f(`import ${l} from`),{limit:u*3}),y=[],b=new Set;for(let e of v){let t=e.record.content.split(`
2
- `);for(let n=0;n<t.length;n++){let r=t[n];if(!_.test(r))continue;let i=`${e.record.sourcePath}:${r.trim()}`;b.has(i)||(b.add(i),y.push({path:e.record.sourcePath,line:e.record.startLine+n,importStatement:r.trim()}))}}let x=RegExp(`\\b${a(l)}\\b`),S=await s.search(await f(l),{limit:u*3}),C=[],w=new Set;for(let r of S){if(g&&r.record.sourcePath===g.path)continue;let a=r.record.content.split(`
2
+ `);for(let n=0;n<t.length;n++){let r=t[n];if(!_.test(r))continue;let i=`${e.record.sourcePath}:${r.trim()}`;b.has(i)||(b.add(i),y.push({path:e.record.sourcePath,line:e.record.startLine+n,importStatement:r.trim()}))}}let x=RegExp(`\\b${a(l)}\\b`),S=await s.search(await f(l),{limit:u*3}),C=[],w=new Set;for(let r of S){if(C.length>=u)break;if(g&&r.record.sourcePath===g.path)continue;let a=r.record.content.split(`
3
3
  `);for(let o=0;o<a.length;o++){let s=a[o];if(!x.test(s)||_.test(s))continue;let c=`${r.record.sourcePath}:${r.record.startLine+o}`;if(w.has(c))continue;w.add(c);let l,u=e(r.record.sourcePath);if(n.get()&&t.has(u))try{let e=await i(r.record.content,u,o+1);e.length>0&&(l=e[0].name)}catch{}C.push({path:r.record.sourcePath,line:r.record.startLine+o,context:s.trim().slice(0,120),scope:l});break}}let T;if(d)try{let e={importedByModules:[],siblingSymbols:[]},t=await d.findNodes({namePattern:l});if(t.length>0){let n=t[0];n.sourcePath?e.definingModule=n.sourcePath:g&&(e.definingModule=g.path);let r=await d.getNeighbors(n.id,{direction:`incoming`,edgeType:`imports`});for(let t of r.nodes)e.importedByModules.push(t.sourcePath??t.name);if(e.definingModule){let t=await d.findNodes({sourcePath:e.definingModule});for(let n of t)n.name!==l&&n.type!==`module`&&e.siblingSymbols.push(`${n.type}:${n.name}`);e.siblingSymbols=e.siblingSymbols.slice(0,15)}}(e.definingModule||e.importedByModules.length>0||e.siblingSymbols.length>0)&&(T=e)}catch{}return{name:l,definedIn:g,importedBy:y.slice(0,u),referencedIn:C.slice(0,u),graphContext:T}}export{o as symbol};
@@ -6,11 +6,13 @@ interface TestRunOptions {
6
6
  cwd?: string;
7
7
  timeout?: number;
8
8
  grep?: string;
9
+ /** Include full raw output in result (default: false to save tokens) */
10
+ includeRaw?: boolean;
9
11
  }
10
12
  interface TestRunResult {
11
13
  summary: ParsedTestSummary;
12
14
  passed: boolean;
13
- raw: string;
15
+ raw?: string;
14
16
  durationMs: number;
15
17
  }
16
18
  declare function testRun(options?: TestRunOptions): Promise<TestRunResult>;
@@ -1,2 +1,2 @@
1
- import{parseVitest as e}from"./parse-output.js";import{exec as t}from"node:child_process";import{promisify as n}from"node:util";const r=n(t);let i=0;async function a(e={}){if(i>=2)throw Error(`Too many concurrent test runs (max 2). Try again later.`);i++;try{return await o(e)}finally{i--}}async function o(t){let n=t.cwd??process.cwd(),i=t.timeout??6e4,a=Date.now(),o=[`vitest`,`run`,`--reporter=verbose`,`--no-color`];t.files?.length&&o.push(...t.files),t.grep&&o.push(`--testNamePattern`,t.grep);try{let{stdout:t}=await r(`npx ${o.join(` `)}`,{cwd:n,timeout:i}),s=t.toString(),c=e(s);return{summary:c,passed:c.failed===0,raw:s,durationMs:Date.now()-a}}catch(t){let n=s(t);return{summary:e(n),passed:!1,raw:n,durationMs:Date.now()-a}}}function s(e){let t=e;return[t.stdout?.toString()??``,t.stderr?.toString()??``].filter(Boolean).join(`
1
+ import{parseVitest as e}from"./parse-output.js";import{exec as t}from"node:child_process";import{promisify as n}from"node:util";const r=n(t);let i=0;async function a(e={}){if(i>=2)throw Error(`Too many concurrent test runs (max 2). Try again later.`);i++;try{return await o(e)}finally{i--}}async function o(t){let n=t.cwd??process.cwd(),i=t.timeout??6e4,a=Date.now(),o=[`vitest`,`run`,`--reporter=verbose`,`--no-color`];t.files?.length&&o.push(...t.files),t.grep&&o.push(`--testNamePattern`,t.grep);try{let{stdout:s}=await r(`npx ${o.join(` `)}`,{cwd:n,timeout:i}),c=s.toString(),l=e(c);return{summary:l,passed:l.failed===0,...t.includeRaw&&{raw:c},durationMs:Date.now()-a}}catch(n){let r=s(n);return{summary:e(r),passed:!1,...t.includeRaw&&{raw:r},durationMs:Date.now()-a}}}function s(e){let t=e;return[t.stdout?.toString()??``,t.stderr?.toString()??``].filter(Boolean).join(`
2
2
  `).trim()||t.message||`Test run failed`}function c(e,t,n){if(e===0)return{isError:!1};if(e===1&&n){if(/\b(grep|rg|ripgrep|ag|ack|findstr)\b/i.test(n))return{isError:!1,reason:`grep: no matches (exit 1 is normal)`};if(/\bdiff\b/i.test(n))return{isError:!1,reason:`diff: files differ (exit 1 is normal)`}}return{isError:!0}}export{c as classifyExitCode,a as testRun};