@vpxa/kb 0.1.31 → 0.1.33
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.
- package/package.json +1 -1
- package/packages/analyzers/dist/diagram-generator.js +2 -2
- package/packages/analyzers/dist/pattern-analyzer.js +1 -1
- package/packages/analyzers/dist/regex-call-graph.js +1 -1
- package/packages/cli/dist/commands/init/constants.d.ts +2 -0
- package/packages/cli/dist/commands/init/constants.js +1 -1
- package/packages/cli/dist/commands/init/index.d.ts +9 -1
- package/packages/cli/dist/commands/init/index.js +1 -1
- package/packages/cli/dist/commands/upgrade.js +1 -1
- package/packages/present/dist/index.html +321 -22
- package/packages/server/dist/output-schemas.d.ts +1 -0
- package/packages/server/dist/output-schemas.js +1 -1
- package/packages/server/dist/server.js +2 -2
- package/packages/server/dist/tools/context.tools.d.ts +2 -2
- package/packages/server/dist/tools/context.tools.js +9 -9
- package/packages/server/dist/tools/onboard.tool.js +2 -2
- package/packages/server/dist/tools/present/browser.d.ts +4 -0
- package/packages/server/dist/tools/present/browser.js +93 -0
- package/packages/server/dist/tools/present/helpers.d.ts +13 -0
- package/packages/server/dist/tools/present/helpers.js +1 -0
- package/packages/server/dist/tools/present/html.d.ts +18 -0
- package/packages/server/dist/tools/present/html.js +5 -0
- package/packages/server/dist/tools/present/index.d.ts +2 -0
- package/packages/server/dist/tools/present/index.js +1 -0
- package/packages/server/dist/tools/present/markdown.d.ts +17 -0
- package/packages/server/dist/tools/present/markdown.js +8 -0
- package/packages/server/dist/tools/present/templates.d.ts +14 -0
- package/packages/server/dist/tools/present/templates.js +472 -0
- package/packages/server/dist/tools/present/tool.d.ts +23 -0
- package/packages/server/dist/tools/present/tool.js +19 -0
- package/packages/server/dist/tools/present.tool.d.ts +1 -6
- package/packages/server/dist/tools/present.tool.js +1 -114
- package/packages/server/dist/tools/status.tool.d.ts +2 -1
- package/packages/server/dist/tools/status.tool.js +3 -3
- package/packages/server/dist/version-check.d.ts +12 -1
- package/packages/server/dist/version-check.js +1 -1
- package/packages/tools/dist/compact.js +1 -1
- package/packages/tools/dist/file-cache.js +3 -3
- package/packages/tools/dist/file-summary.js +1 -1
- package/packages/tools/dist/guide.js +1 -1
- package/packages/tools/dist/onboard.d.ts +7 -0
- package/packages/tools/dist/onboard.js +4 -4
- package/scaffold/adapters/copilot.mjs +4 -3
- package/scaffold/definitions/tools.mjs +3 -2
- package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +1 -1
- package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +1 -1
- package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +1 -1
- package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +1 -1
- package/scaffold/general/agents/Debugger.agent.md +1 -1
- package/scaffold/general/agents/Documenter.agent.md +1 -1
- package/scaffold/general/agents/Explorer.agent.md +1 -1
- package/scaffold/general/agents/Frontend.agent.md +1 -1
- package/scaffold/general/agents/Implementer.agent.md +1 -1
- package/scaffold/general/agents/Orchestrator.agent.md +1 -1
- package/scaffold/general/agents/Planner.agent.md +1 -1
- package/scaffold/general/agents/Refactor.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Alpha.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Beta.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Delta.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Gamma.agent.md +1 -1
- package/scaffold/general/agents/Security.agent.md +1 -1
- package/skills/present/SKILL.md +283 -12
|
@@ -1,114 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
- "html" (default): Rich markdown in chat + embedded UIResource for MCP-UI hosts. Actions shown as numbered choices.
|
|
3
|
-
- "browser": Rich markdown in chat + opens beautiful themed dashboard in the browser. When actions are provided, the browser shows interactive buttons and the tool blocks until the user clicks, returning their selection.`),title:h.string().optional().describe(`Optional heading`),content:h.any().describe(`Content to present. Accepts: markdown string, array of objects (→ table), { nodes, edges } (→ mermaid graph), typed blocks [{ type, value }], or any JSON (→ tree).`),actions:h.array(O).optional().describe(`Interactive actions (buttons/selects). In html mode, shown as numbered choices. In browser mode, rendered as clickable buttons and the tool blocks until user clicks.`)};let A=!1;function j(t,n){let r=e(`present`);A||=(b(t,`KB Present App`,w,{description:`Rich interactive content viewer for KB tools`},async()=>({contents:[{uri:w,mimeType:y,text:D()}]})),!0),x(t,`present`,{title:r.title,description:`Present content to the user in the best format. Two modes:
|
|
4
|
-
- "html" (default): Rich markdown in chat + embedded UIResource. Actions shown as numbered choices for display.
|
|
5
|
-
- "browser": Rich markdown in chat + serves a themed dashboard on a local URL that auto-opens in your system browser. If openBrowserPage is available, also call it with the returned URL. When actions are provided, browser shows interactive buttons and the tool blocks until user clicks.
|
|
6
|
-
Use "html" for in-chat display. Use "browser" for visual dashboards and when you need interactive user input back.
|
|
7
|
-
After calling present with format "browser", extract the URL from the response and call openBrowserPage({ url }) to open it in VS Code.`,annotations:r.annotations,inputSchema:k,_meta:{ui:{resourceUri:w}}},async({format:e,title:t,content:r,actions:i})=>(e??`html`)===`browser`?await N(t,r,i,n):J(t,r,i))}let M=null;process.on(`exit`,()=>{if(M){try{M.close()}catch{}M=null}});async function N(e,t,n,r){let i=P(e,t),a=q(e,t,n),o,s,c=Array.isArray(n)?n:[],l=``;try{M&&=(M.close(),null),c.length>0&&(o=new Promise(e=>{s=e})),l=await new Promise((e,t)=>{let n=_((e,t)=>{if(e.method===`POST`&&e.url===`/callback`){let n=``;e.on(`data`,e=>{n+=e.toString()}),e.on(`end`,()=>{t.writeHead(200,{"Content-Type":`application/json`,"Access-Control-Allow-Origin":`*`}),t.end(`{"ok":true}`);try{let e=JSON.parse(n);s?.(e)}catch{}});return}if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}t.writeHead(200,{"Content-Type":`text/html; charset=utf-8`}),t.end(a)});n.listen(0,`127.0.0.1`,()=>{let r=n.address();typeof r==`object`&&r?(M=n,e(`http://127.0.0.1:${r.port}`)):t(Error(`Failed to start present server`))}),setTimeout(()=>{n.close(),M===n&&(M=null)},300*1e3).unref()});try{g(process.platform===`win32`?`start "" "${l}"`:process.platform===`darwin`?`open "${l}"`:`xdg-open "${l}"`)}catch{}}catch{}let u=v({uri:`ui://kb/present-static.html`,content:{type:`rawHtml`,htmlString:a},encoding:`text`,adapters:{mcpApps:{enabled:!0}}}),d=l?`${i}\n\n---\n🌐 **Dashboard opened in browser:** ${l}`:i;if(c.length>0&&r?.available&&o)try{let e=await Promise.race([o,new Promise((e,t)=>setTimeout(()=>t(Error(`timeout`)),300*1e3))]);return{content:[{type:`text`,text:`${d}\n\n✅ **Selected:** ${e.actionId} = \`${e.value}\``},u]}}catch{return{content:[{type:`text`,text:`${d}\n\n⚠️ *No selection received (timed out).*`},u]}}return{content:[{type:`text`,text:d},u]}}function P(e,t){let n=[];if(e&&n.push(`# ${e}\n`),typeof t==`string`)n.push(t);else if(Array.isArray(t))if(t.length===0)n.push(`*(empty)*`);else if(Z(t[0]))for(let e of t)n.push(F(e));else if(typeof t[0]==`object`&&t[0]!==null)n.push(I(t));else for(let e of t)n.push(`- ${String(e)}`);else if(typeof t==`object`&&t){let e=t;Array.isArray(e.nodes)&&Array.isArray(e.edges)?n.push(R(e)):Array.isArray(e.metrics)?n.push(L(e.metrics)):n.push(z(e))}else n.push(String(t));return n.join(`
|
|
8
|
-
`)}function F(e){let t=[];switch(e.title&&t.push(`## ${e.title}\n`),e.type){case`markdown`:t.push(String(e.value??``));break;case`code`:t.push(`\`\`\`${e.language??``}\n${String(e.value??``)}\n\`\`\``);break;case`mermaid`:t.push(`\`\`\`mermaid\n${String(e.value??``)}\n\`\`\``);break;case`table`:Array.isArray(e.value)&&t.push(I(e.value));break;case`metrics`:Array.isArray(e.value)&&t.push(L(e.value));break;case`graph`:e.value&&typeof e.value==`object`&&t.push(R(e.value));break;case`cards`:if(Array.isArray(e.value))for(let n of e.value)t.push(`### ${n.title??`Card`}`),(n.body||n.description)&&t.push(String(n.body??n.description)),(n.badge||n.status)&&t.push(`> **${n.badge??n.status}**`),t.push(``);break;case`tree`:e.value&&typeof e.value==`object`&&t.push(z(e.value));break;case`chart`:{let n=e.value;n?.data&&Array.isArray(n.data)&&t.push(`*${String(n.chartType??`chart`)} chart — ${n.data.length} data points*`);break}case`timeline`:{let n=e.value;if(n?.items)for(let e of n.items){let n=e.status===`done`?`✅`:e.status===`active`?`🔄`:e.status===`error`?`❌`:`⬜`;t.push(`${n} **${e.title}**${e.description?` — ${e.description}`:``}`)}break}case`checklist`:{let n=e.value;if(n?.items)for(let e of n.items)t.push(`- [${e.checked?`x`:` `}] ${e.label}${e.note?` — ${e.note}`:``}`);break}case`comparison`:{let n=e.value;if(n?.columns&&n.columns.length>0){let e=Math.max(...n.columns.map(e=>e.items?.length??0)),r=n.columns.map(e=>e.title);t.push(`| ${r.join(` | `)} |`),t.push(`| ${r.map(()=>`---`).join(` | `)} |`);for(let r=0;r<e;r++)t.push(`| ${n.columns.map(e=>e.items?.[r]??``).join(` | `)} |`)}break}case`status-board`:{let n=e.value;if(n?.items)for(let e of n.items){let n=e.status===`success`?`🟢`:e.status===`warning`?`🟡`:e.status===`error`?`🔴`:e.status===`info`?`🔵`:`⚪`;t.push(`${n} **${e.label}**${e.detail?` — ${e.detail}`:``}`)}break}case`prompt`:{let n=e.value;n?.question&&(t.push(`> **${n.question}**`),n.context&&t.push(`> ${n.context}`));break}case`progress`:{let n=e.value;if(n?.items)for(let e of n.items){let n=e.max??100,r=n>0?Math.round(e.value/n*100):0,i=`█`.repeat(Math.round(r/5))+`░`.repeat(20-Math.round(r/5));t.push(`${e.label}: ${i} ${r}%`)}break}case`text`:t.push(String(e.value??``));break;case`heading`:t.push(`## ${String(e.value??``)}\n`);break;case`separator`:t.push(`---
|
|
9
|
-
`);break;default:t.push(JSON.stringify(e.value,null,2))}return t.push(``),t.join(`
|
|
10
|
-
`)}function I(e){if(e.length===0)return`*(empty table)*`;let t=Object.keys(e[0]),n=[];n.push(`| ${t.join(` | `)} |`),n.push(`| ${t.map(()=>`---`).join(` | `)} |`);for(let r of e)n.push(`| ${t.map(e=>String(r[e]??``)).join(` | `)} |`);return n.join(`
|
|
11
|
-
`)}function L(e){return e.map(e=>`- **${e.label}**: ${e.value}`).join(`
|
|
12
|
-
`)}function R(e){let t=["```mermaid",`graph LR`];for(let n of e.nodes){let e=X(String(n.id??n.name??``)),r=String(n.label??n.name??e);t.push(` ${e}["${r}"]`)}for(let n of e.edges){let e=X(String(n.source??n.from??``)),r=X(String(n.target??n.to??``)),i=n.label?`|${String(n.label)}|`:``;t.push(` ${e} -->${i} ${r}`)}return t.push("```"),t.join(`
|
|
13
|
-
`)}function z(e,t=0){let n=` `.repeat(t),r=[];for(let[i,a]of Object.entries(e))typeof a==`object`&&a&&!Array.isArray(a)?(r.push(`${n}- **${i}**:`),r.push(z(a,t+1))):r.push(`${n}- **${i}**: ${Y(a)}`);return r.join(`
|
|
14
|
-
`)}function B(e,n){let r=[];if(e&&r.push(`<h1>${t(e)}</h1>`),typeof n==`string`)r.push(`<div class="md-content">${S.parse(n)}</div>`);else if(Array.isArray(n))if(n.length===0)r.push(`<p><em>empty</em></p>`);else if(Z(n[0]))for(let e of n)r.push(V(e));else typeof n[0]==`object`&&n[0]!==null?r.push(H(n)):r.push(`<ul>${n.map(e=>`<li>${t(String(e))}</li>`).join(``)}</ul>`);else if(typeof n==`object`&&n){let e=n;Array.isArray(e.metrics)?r.push(U(e.metrics)):Array.isArray(e.nodes)&&Array.isArray(e.edges)?(r.push(`<pre class="mermaid">${t(K(e))}</pre>`),r.push(`<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"><\/script>`),r.push(`<script>mermaid.run();<\/script>`)):r.push(G(e))}else r.push(`<p>${t(String(n))}</p>`);return r.join(`
|
|
15
|
-
`)}function V(e){let l=[];switch(e.title&&l.push(`<h2>${t(e.title)}</h2>`),e.type){case`markdown`:l.push(`<div class="md-content">${S.parse(String(e.value??``))}</div>`);break;case`code`:l.push(`<pre><code>${t(String(e.value??``))}</code></pre>`);break;case`mermaid`:l.push(`<pre class="mermaid">${t(String(e.value??``))}</pre>`);break;case`table`:if(Array.isArray(e.value)){let t=e.value;if(t.length>0&&Array.isArray(t[0])){let e=t,n=e[0].map(String),r=e.slice(1).map(e=>Object.fromEntries(n.map((t,n)=>[t,e[n]])));l.push(H(r))}else l.push(H(t))}break;case`metrics`:{let t;Array.isArray(e.value)?t=e.value:e.value&&typeof e.value==`object`&&(t=Object.entries(e.value).map(([e,t])=>({label:e,value:String(t)}))),t&&l.push(U(t))}break;case`cards`:Array.isArray(e.value)&&l.push(W(e.value));break;case`tree`:e.value&&typeof e.value==`object`&&l.push(G(e.value));break;case`graph`:e.value&&typeof e.value==`object`&&l.push(`<pre class="mermaid">${t(K(e.value))}</pre>`);break;case`chart`:{let t=e.value;if(t&&!t.chartType&&t.type&&Array.isArray(t.labels)&&Array.isArray(t.datasets)){let n=t.labels,r=t.datasets,i=r.map((e,t)=>e.label??`series${t+1}`),a=n.map((e,t)=>{let n={_label:e};return r.forEach((e,r)=>{n[i[r]]=e.data[t]??0}),n}),o={type:`chart`,title:e.title,value:{chartType:String(t.type),data:a,xKey:`_label`,yKeys:i}};l.push(c(o))}else l.push(c(e));break}case`timeline`:{let t=e.value;Array.isArray(t)&&(t={items:t.map(e=>({title:String(e.event??e.title??``),phase:e.date==null?e.phase==null?void 0:String(e.phase):String(e.date),description:e.description==null?void 0:String(e.description),status:e.status??`done`}))}),t&&l.push(s(t));break}case`checklist`:e.value&&l.push(n(e.value));break;case`comparison`:e.value&&l.push(r(e.value));break;case`status-board`:e.value&&l.push(o(e.value));break;case`prompt`:e.value&&l.push(a(e.value));break;case`progress`:e.value&&l.push(i(e.value));break;case`text`:l.push(`<div class="md-content">${S.parse(String(e.value??``))}</div>`);break;case`heading`:l.push(`<h2>${t(String(e.value??``))}</h2>`);break;case`separator`:l.push(`<hr class="separator">`);break;default:l.push(`<pre>${t(JSON.stringify(e.value,null,2))}</pre>`)}return l.join(`
|
|
16
|
-
`)}function H(e){if(e.length===0)return`<p><em>empty table</em></p>`;let n=Object.keys(e[0]);return`<div class="table-wrap"><table><thead><tr>${n.map(e=>`<th>${t(e)}</th>`).join(``)}</tr></thead><tbody>${e.map(e=>`<tr>${n.map(n=>`<td>${t(String(e[n]??``))}</td>`).join(``)}</tr>`).join(`
|
|
17
|
-
`)}</tbody></table></div>`}function U(e){return`<div class="metric-grid">${e.map(e=>`<div class="metric"><div class="metric-value">${t(String(e.value))}</div><div class="metric-label">${t(e.label)}</div></div>`).join(``)}</div>`}function W(e){return`<div class="card-grid">${e.map(e=>{let n=[`<div class="card">`];return e.title&&n.push(`<div class="card-title">${t(String(e.title))}</div>`),(e.body||e.description)&&n.push(`<div class="card-body">${t(String(e.body??e.description))}</div>`),(e.badge||e.status)&&n.push(`<span class="badge">${t(String(e.badge??e.status))}</span>`),n.push(`</div>`),n.join(``)}).join(``)}</div>`}function G(e){let n=[];for(let[r,i]of Object.entries(e))typeof i==`object`&&i&&!Array.isArray(i)?n.push(`<div class="tree-node"><span class="tree-key">${t(r)}:</span><div class="tree-children">${G(i)}</div></div>`):n.push(`<div class="tree-node"><span class="tree-key">${t(r)}:</span> ${t(Y(i))}</div>`);return n.join(``)}function K(e){let t=[`graph LR`];for(let n of e.nodes){let e=X(String(n.id??n.name??``)),r=String(n.label??n.name??e);t.push(` ${e}["${r}"]`)}for(let n of e.edges){let e=X(String(n.source??n.from??``)),r=X(String(n.target??n.to??``)),i=n.label?`|${String(n.label)}|`:``;t.push(` ${e} -->${i} ${r}`)}return t.join(`
|
|
18
|
-
`)}function q(e,n,r){let i=B(e,n);return`<!DOCTYPE html>
|
|
19
|
-
<html lang="en">
|
|
20
|
-
<head>
|
|
21
|
-
<meta charset="UTF-8">
|
|
22
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
23
|
-
<title>${t(e??`KB Dashboard`)}</title>
|
|
24
|
-
${l}
|
|
25
|
-
<style>${u()}</style>
|
|
26
|
-
</head>
|
|
27
|
-
<body>
|
|
28
|
-
<div class="dashboard">
|
|
29
|
-
<div class="header">
|
|
30
|
-
<h1>${t(e??`KB Dashboard`)}</h1>
|
|
31
|
-
<div class="subtitle">Knowledge Base</div>
|
|
32
|
-
</div>
|
|
33
|
-
${i}
|
|
34
|
-
${(()=>{let e=Array.isArray(r)?r:[];return e.length===0?``:`
|
|
35
|
-
<div class="actions-bar">
|
|
36
|
-
<h2>Actions</h2>
|
|
37
|
-
<div class="actions-grid">${e.map(e=>{let n=String(e.id??``);if(e.type===`select`&&Array.isArray(e.options)){let r=e.options.map(e=>{let n=typeof e==`string`?e:e.label;return`<option value="${t(typeof e==`string`?e:e.value)}">${t(n)}</option>`}).join(``);return`<div class="action-group"><label>${t(String(e.label??``))}</label><select data-action-id="${t(n)}" onchange="sendCallback(${t(JSON.stringify(n))},this.value)">${r}</select></div>`}return`<button class="action-btn action-${String(e.variant??`default`)}" onclick="sendCallback(${t(JSON.stringify(n))},'clicked')">${t(String(e.label??``))}</button>`}).join(`
|
|
38
|
-
`)}</div>
|
|
39
|
-
<div id="action-feedback" class="action-feedback"></div>
|
|
40
|
-
</div>
|
|
41
|
-
<script>
|
|
42
|
-
let _cbSent=false;
|
|
43
|
-
function sendCallback(actionId,value){
|
|
44
|
-
if(_cbSent)return;
|
|
45
|
-
_cbSent=true;
|
|
46
|
-
document.querySelectorAll('.action-btn,.action-group select').forEach(el=>{el.disabled=true;el.style.opacity='0.5'});
|
|
47
|
-
const fb=document.getElementById('action-feedback');
|
|
48
|
-
fb.textContent='⏳ Sending selection: '+actionId+' = '+value;
|
|
49
|
-
fb.className='action-feedback sent';
|
|
50
|
-
fetch('/callback',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({actionId,value})})
|
|
51
|
-
.then(()=>{
|
|
52
|
-
fb.textContent='✓ Selection sent: '+actionId+' = '+value;
|
|
53
|
-
})
|
|
54
|
-
.catch(e=>{
|
|
55
|
-
fb.textContent='✗ Callback failed — '+e.message;
|
|
56
|
-
fb.style.color='var(--error)';
|
|
57
|
-
_cbSent=false;
|
|
58
|
-
document.querySelectorAll('.action-btn,.action-group select').forEach(el=>{el.disabled=false;el.style.opacity='1'});
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
<\/script>`})()}
|
|
62
|
-
<div class="footer">KB MCP Server · Generated ${new Date().toLocaleString()}</div>
|
|
63
|
-
</div>
|
|
64
|
-
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"><\/script>
|
|
65
|
-
<script>
|
|
66
|
-
// Mermaid initialization
|
|
67
|
-
if(document.querySelector('.mermaid'))mermaid.initialize({theme:'dark',startOnLoad:true});
|
|
68
|
-
|
|
69
|
-
// Table sorting
|
|
70
|
-
document.querySelectorAll('table').forEach(table=>{
|
|
71
|
-
const headers=table.querySelectorAll('th');
|
|
72
|
-
headers.forEach((th,i)=>{
|
|
73
|
-
let asc=true;
|
|
74
|
-
th.addEventListener('click',()=>{
|
|
75
|
-
const tbody=table.querySelector('tbody')||table;
|
|
76
|
-
const rows=[...tbody.querySelectorAll('tr')].filter(r=>r.querySelector('td'));
|
|
77
|
-
rows.sort((a,b)=>{
|
|
78
|
-
const at=(a.cells[i]?.textContent||'').trim();
|
|
79
|
-
const bt=(b.cells[i]?.textContent||'').trim();
|
|
80
|
-
return asc?at.localeCompare(bt,undefined,{numeric:true}):bt.localeCompare(at,undefined,{numeric:true});
|
|
81
|
-
});
|
|
82
|
-
rows.forEach(r=>tbody.appendChild(r));
|
|
83
|
-
asc=!asc;
|
|
84
|
-
headers.forEach(h=>h.style.color='');
|
|
85
|
-
th.style.color='var(--primary)';
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// Table search/filter
|
|
91
|
-
document.querySelectorAll('.table-wrap').forEach(wrap=>{
|
|
92
|
-
const table=wrap.querySelector('table');
|
|
93
|
-
if(!table||table.querySelectorAll('tr').length<5)return;
|
|
94
|
-
const bar=document.createElement('div');
|
|
95
|
-
bar.className='search-bar';
|
|
96
|
-
const input=document.createElement('input');
|
|
97
|
-
input.placeholder='Filter rows...';
|
|
98
|
-
const count=document.createElement('span');
|
|
99
|
-
count.className='count';
|
|
100
|
-
bar.appendChild(input);bar.appendChild(count);
|
|
101
|
-
wrap.parentNode.insertBefore(bar,wrap);
|
|
102
|
-
const rows=[...table.querySelectorAll('tbody tr, tr')].filter(r=>r.querySelector('td'));
|
|
103
|
-
const updateCount=()=>{const v=rows.filter(r=>r.style.display!=='none').length;count.textContent=v+'/'+rows.length};
|
|
104
|
-
updateCount();
|
|
105
|
-
input.addEventListener('input',()=>{
|
|
106
|
-
const q=input.value.toLowerCase();
|
|
107
|
-
rows.forEach(r=>{r.style.display=r.textContent.toLowerCase().includes(q)?'':'none'});
|
|
108
|
-
updateCount();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
<\/script>
|
|
112
|
-
</body>
|
|
113
|
-
</html>`}function J(e,t,n){let r=Array.isArray(n)?n:[],i=[];if(e&&i.push(`## ${e}\n`),Array.isArray(t)){for(let e of t)if(e&&typeof e==`object`&&typeof e.type==`string`)if(e.type===`metrics`&&e.value&&typeof e.value==`object`){let t=e.value;i.push(Object.entries(t).map(([e,t])=>`**${e}**: ${String(t)}`).join(` · `))}else e.type===`text`&&typeof e.value==`string`?i.push(e.value):i.push(`*${e.type}${e.title?`: ${String(e.title)}`:``}*`)}else typeof t==`string`&&i.push(t);if(r.length>0){i.push(``);for(let e=0;e<r.length;e++){let t=r[e],n=typeof t.label==`string`?t.label:`Action ${e+1}`;if(t.type===`select`&&Array.isArray(t.options)){let r=t.options.map(e=>typeof e==`string`?e:e.label).join(`, `);i.push(`${e+1}. **${n}** — choose: ${r}`)}else i.push(`${e+1}. **${n}**`)}}let a={title:e,content:t};return r.length>0&&(a.actions=r),{content:[{type:`text`,text:i.join(`
|
|
114
|
-
`)}],structuredContent:a}}function Y(e){return e==null?`null`:Array.isArray(e)?`[${e.map(Y).join(`, `)}]`:String(e)}function X(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function Z(e){return typeof e==`object`&&!!e&&`type`in e&&`value`in e}export{j as registerPresentTool};
|
|
1
|
+
import{registerPresentTool as e}from"./present/tool.js";import"./present/index.js";export{e as registerPresentTool};
|
|
@@ -9,6 +9,7 @@ interface OnboardState {
|
|
|
9
9
|
onboardTimestamp?: string;
|
|
10
10
|
}
|
|
11
11
|
declare function getScaffoldVersion(): string | null;
|
|
12
|
+
declare function getWorkspaceScaffoldVersion(): string | null;
|
|
12
13
|
/**
|
|
13
14
|
* Lightweight status tool registered during init — returns version info
|
|
14
15
|
* without needing the KB store, graph, or curated manager.
|
|
@@ -16,4 +17,4 @@ declare function getScaffoldVersion(): string | null;
|
|
|
16
17
|
declare function registerEarlyStatusTool(server: McpServer): void;
|
|
17
18
|
declare function registerStatusTool(server: McpServer, store: IKnowledgeStore, graphStore?: IGraphStore, curated?: CuratedKnowledgeManager, onboardState?: OnboardState, config?: KBConfig): void;
|
|
18
19
|
//#endregion
|
|
19
|
-
export { OnboardState, getScaffoldVersion, registerEarlyStatusTool, registerStatusTool };
|
|
20
|
+
export { OnboardState, getScaffoldVersion, getWorkspaceScaffoldVersion, registerEarlyStatusTool, registerStatusTool };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{getGcStatus as e}from"../auto-gc.js";import{getToolTelemetry as t}from"../replay-interceptor.js";import{getToolMeta as n}from"../tool-metadata.js";import{StatusOutputSchema as r}from"../output-schemas.js";import{getCurrentVersion as
|
|
2
|
-
`)}],structuredContent:
|
|
3
|
-
`),
|
|
1
|
+
import{getGcStatus as e}from"../auto-gc.js";import{getToolTelemetry as t}from"../replay-interceptor.js";import{getToolMeta as n}from"../tool-metadata.js";import{StatusOutputSchema as r}from"../output-schemas.js";import{autoUpgradeScaffold as i,getCurrentVersion as a,getUpgradeState as o}from"../version-check.js";import{existsSync as s,readFileSync as c,statSync as l}from"node:fs";import{resolve as u}from"node:path";import{KB_PATHS as d,createLogger as f,serializeError as p}from"../../../core/dist/index.js";import{WasmRuntime as m}from"../../../chunker/dist/index.js";import{homedir as h}from"node:os";const g=f(`tools`);function _(e,t,n,r=4e3){let i,a=new Promise(e=>{i=setTimeout(()=>{g.warn(`Status sub-operation "${n}" timed out after ${r}ms`),e({value:t,timedOut:!0})},r)});return Promise.race([e.then(e=>(clearTimeout(i),{value:e,timedOut:!1}),e=>(clearTimeout(i),g.warn(`Status sub-operation "${n}" failed: ${e instanceof Error?e.message:String(e)}`),{value:t,timedOut:!1})),a])}function v(){try{let e=u(h(),`.copilot`,`.kb-scaffold.json`);return s(e)?JSON.parse(c(e,`utf-8`)).version??null:null}catch{return null}}function y(){try{let e=u(process.cwd(),`.github`,`.kb-scaffold.json`);return s(e)?JSON.parse(c(e,`utf-8`)).version??null:null}catch{return null}}function b(e){let t=n(`status`);e.registerTool(`status`,{title:t.title,description:`Get the current status and statistics of the knowledge base index.`,outputSchema:r,annotations:t.annotations},async()=>{let e=a(),t=v(),n=y(),r=t!=null&&t!==e,s=n!=null&&n!==e,c=[`## Knowledge Base Status`,``,`⏳ **KB is initializing** — index stats will be available shortly.`,``,`### Runtime`,`- **Tree-sitter (WASM)**: ${m.get()?`✅ Available (AST analysis)`:`⚠ Unavailable (regex fallback)`}`,``,`### Version`,`- **Server**: ${e}`,`- **Scaffold (user)**: ${t??`not installed`}`,`- **Scaffold (workspace)**: ${n??`not installed`}`];if(r||s){let a=o(),l=[];r&&l.push(`user scaffold v${t}`),s&&l.push(`workspace scaffold v${n}`);let u=l.join(`, `);a.state===`success`?c.push(``,`### ✅ Upgrade Applied`,`- Server v${e} — ${u} auto-upgraded successfully.`,`- _Restart the MCP server to use the updated version._`):a.state===`pending`?c.push(``,`### ⏳ Upgrade In Progress`,`- Server v${e} ≠ ${u}`,`- Auto-upgrade is running in the background…`):a.state===`failed`?(i(),c.push(``,`### ⬆ Upgrade Available (auto-upgrade failed, retrying)`,`- Server v${e} ≠ ${u}`,`- Error: ${a.error??`unknown`}`)):(i(),c.push(``,`### ⬆ Upgrade Available`,`- Server v${e} ≠ ${u}`,`- Auto-upgrade triggered — check again shortly.`))}let l={totalRecords:0,totalFiles:0,lastIndexedAt:null,onboarded:!1,onboardDir:``,contentTypes:{},wasmAvailable:!!m.get(),graphStats:null,curatedCount:0,serverVersion:e,scaffoldVersion:t??null,workspaceScaffoldVersion:n??null,upgradeAvailable:r||s};return{content:[{type:`text`,text:c.join(`
|
|
2
|
+
`)}],structuredContent:l}})}function x(c,f,h,b,x,S){let C=n(`status`);c.registerTool(`status`,{title:C.title,description:`Get the current status and statistics of the knowledge base index.`,outputSchema:r,annotations:C.annotations},async()=>{let n=[];try{let r=await _(f.getStats(),{totalRecords:0,totalFiles:0,lastIndexedAt:null,contentTypeBreakdown:{}},`store.getStats`),c=r.value;r.timedOut&&n.push(`⚠ Index stats timed out — values may be incomplete`);let p=await _(f.listSourcePaths(),[],`store.listSourcePaths`),g=p.value;p.timedOut&&n.push(`⚠ File listing timed out`);let C=null,w=0,T=[`## Knowledge Base Status`,``,`- **Total Records**: ${c.totalRecords}`,`- **Total Files**: ${c.totalFiles}`,`- **Last Indexed**: ${c.lastIndexedAt??`Never`}`,``,`### Content Types`,...Object.entries(c.contentTypeBreakdown).map(([e,t])=>`- ${e}: ${t}`),``,`### Indexed Files`,...g.slice(0,50).map(e=>`- ${e}`),g.length>50?`\n... and ${g.length-50} more files`:``];if(h)try{let e=await _(h.getStats(),{nodeCount:0,edgeCount:0,nodeTypes:{},edgeTypes:{}},`graphStore.getStats`);if(e.timedOut)n.push(`⚠ Graph stats timed out`),T.push(``,`### Knowledge Graph`,`- Graph stats timed out`);else{let t=e.value;C={nodes:t.nodeCount,edges:t.edgeCount},T.push(``,`### Knowledge Graph`,`- **Nodes**: ${t.nodeCount}`,`- **Edges**: ${t.edgeCount}`,...Object.entries(t.nodeTypes).map(([e,t])=>` - ${e}: ${t}`));try{let e=await _(h.validate(),{valid:!0,danglingEdges:[],orphanNodes:[],stats:{nodeCount:0,edgeCount:0,nodeTypes:{},edgeTypes:{}}},`graphStore.validate`);if(!e.timedOut){let t=e.value;t.valid||T.push(`- **⚠ Integrity Issues**: ${t.danglingEdges.length} dangling edges`),t.orphanNodes.length>0&&T.push(`- **Orphan nodes**: ${t.orphanNodes.length}`)}}catch{}}}catch{T.push(``,`### Knowledge Graph`,`- Graph store unavailable`)}let E=S?.onboardDir??u(process.cwd(),d.aiKb),D=s(E),O=x?.onboardComplete??D;if(T.push(``,`### Onboard Status`,O?`- ✅ Complete${x?.onboardTimestamp?` (last: ${x.onboardTimestamp})`:``}`:'- ❌ Not run — call `onboard({ path: "." })` to analyze the codebase',`- **Onboard Directory**: \`${E}\``),b)try{let e=await _(b.list(),[],`curated.list`);if(e.timedOut)n.push(`⚠ Curated knowledge listing timed out`),T.push(``,`### Curated Knowledge`,`- Listing timed out`);else{let t=e.value;w=t.length,T.push(``,`### Curated Knowledge`,t.length>0?`- ${t.length} entries`:"- Empty — use `remember()` to persist decisions")}}catch{T.push(``,`### Curated Knowledge`,`- Unable to read curated entries`)}let k=0;if(c.lastIndexedAt){k=new Date(c.lastIndexedAt).getTime();let e=(Date.now()-k)/(1e3*60*60);T.push(``,`### Index Freshness`,e>24?`- ⚠ Last indexed ${Math.floor(e)}h ago — may be stale. Run \`reindex({})\``:`- ✅ Last indexed ${e<1?`less than 1h`:`${Math.floor(e)}h`} ago`)}{try{let e=u(process.cwd(),d.data,`stash`);if(s(e)){let t=l(e).mtimeMs;t>k&&(k=t)}}catch{}let e=[];if(b)try{let t=w>0?await b.list():[];for(let e of t){let t=new Date(e.updated||e.created).getTime();t>k&&(k=t)}e.push(...t.sort((e,t)=>new Date(t.updated).getTime()-new Date(e.updated).getTime()).slice(0,5))}catch{}let t=k>0?Date.now()-k:0;if(t>=144e5){let n=Math.floor(t/36e5);if(T.push(``,`### 🌅 Session Briefing`,`_${n}+ hours since last activity — here's what to pick up:_`,``),e.length>0){T.push(`**Recent decisions/notes:**`);for(let t of e)T.push(`- **${t.title}** (${t.category??`note`}) — ${(t.contentPreview??``).slice(0,80)}…`)}T.push(``,`**Suggested next steps:**`,'- `search({ query: "SESSION CHECKPOINT", origin: "curated" })` — find your last checkpoint',"- `restore({})` — resume from a saved checkpoint","- `list()` — browse all stored knowledge")}}T.push(``,`### Runtime`,`- **Tree-sitter (WASM)**: ${m.get()?`✅ Available (AST analysis)`:`⚠ Unavailable (regex fallback)`}`);let A=v(),j=y(),M=a(),N=A!=null&&A!==M,P=j!=null&&j!==M;if(N||P){let e=o(),t=[];N&&t.push(`user scaffold v${A}`),P&&t.push(`workspace scaffold v${j}`);let n=t.join(`, `);e.state===`success`?T.push(``,`### ✅ Upgrade Applied`,`- Server v${M} — ${n} auto-upgraded successfully.`,`- _Restart the MCP server to use the updated version._`):e.state===`pending`?T.push(``,`### ⏳ Upgrade In Progress`,`- Server v${M} ≠ ${n}`,`- Auto-upgrade is running in the background…`):e.state===`failed`?(i(),T.push(``,`### ⬆ Upgrade Available (auto-upgrade failed, retrying)`,`- Server v${M} ≠ ${n}`,`- Error: ${e.error??`unknown`}`)):(i(),T.push(``,`### ⬆ Upgrade Available`,`- Server v${M} ≠ ${n}`,`- Auto-upgrade triggered — check again shortly.`))}n.length>0&&T.push(``,`### ⚠ Warnings`,...n.map(e=>`- ${e}`));let F=t();if(F.length>0){let e=F.sort((e,t)=>t.callCount-e.callCount);T.push(``,`### Tool Usage This Session`,``),T.push(`| Tool | Calls | Tokens In | Tokens Out | Errors | Avg Latency |`),T.push(`|------|-------|-----------|------------|--------|-------------|`);for(let t of e.slice(0,15)){let e=Math.round(t.totalInputChars/4),n=Math.round(t.totalOutputChars/4),r=Math.round(t.totalDurationMs/t.callCount);T.push(`| ${t.tool} | ${t.callCount} | ${e.toLocaleString()} | ${n.toLocaleString()} | ${t.errorCount} | ${r}ms |`)}}let I=e();if(I.bufferSize>=10){let e=I.state===`healthy`?`🟢`:I.state===`degraded`?`🔴`:`🟡`;T.push(``,`### Auto-GC: ${e} ${I.state}`),T.push(`- p95 latency: ${I.p95}ms | buffer: ${I.bufferSize} samples`),I.gcCount>0&&T.push(`- GC cycles triggered: ${I.gcCount}`)}let L=T.join(`
|
|
3
|
+
`),R={totalRecords:c.totalRecords,totalFiles:c.totalFiles,lastIndexedAt:c.lastIndexedAt??null,onboarded:O,onboardDir:E,contentTypes:c.contentTypeBreakdown,wasmAvailable:!!m.get(),graphStats:C,curatedCount:w,serverVersion:M,scaffoldVersion:A??null,workspaceScaffoldVersion:j??null,upgradeAvailable:N||P};return{content:[{type:`text`,text:L+"\n\n---\n_Next: Use `search` to query indexed content, `graph(stats)` to explore the knowledge graph, or `reindex` to refresh the index._"}],structuredContent:R}}catch(e){return g.error(`Status failed`,p(e)),{content:[{type:`text`,text:`Status check failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{v as getScaffoldVersion,y as getWorkspaceScaffoldVersion,b as registerEarlyStatusTool,x as registerStatusTool};
|
|
@@ -10,12 +10,23 @@ declare function getCurrentVersion(): string;
|
|
|
10
10
|
* This is fire-and-forget — it never throws and never blocks startup.
|
|
11
11
|
*/
|
|
12
12
|
declare function checkForUpdates(): void;
|
|
13
|
+
/** Upgrade state visible to other modules (e.g. the status tool). */
|
|
14
|
+
type UpgradeState = 'idle' | 'pending' | 'success' | 'failed';
|
|
15
|
+
/** Return the current auto-upgrade state. */
|
|
16
|
+
declare function getUpgradeState(): {
|
|
17
|
+
state: UpgradeState;
|
|
18
|
+
error: string | null;
|
|
19
|
+
};
|
|
13
20
|
/**
|
|
14
21
|
* Auto-upgrade scaffold files when the running server version differs from
|
|
15
22
|
* the installed scaffold version. This is fire-and-forget — it never throws
|
|
16
23
|
* and never blocks startup. The upgrade process runs in a detached child so
|
|
17
24
|
* the MCP server stays responsive.
|
|
25
|
+
*
|
|
26
|
+
* State is tracked via `getUpgradeState()` so the status tool can report
|
|
27
|
+
* whether the upgrade is pending, succeeded, or failed without asking the
|
|
28
|
+
* LLM to run a terminal command.
|
|
18
29
|
*/
|
|
19
30
|
declare function autoUpgradeScaffold(): void;
|
|
20
31
|
//#endregion
|
|
21
|
-
export { autoUpgradeScaffold, checkForUpdates, getCurrentVersion };
|
|
32
|
+
export { UpgradeState, autoUpgradeScaffold, checkForUpdates, getCurrentVersion, getUpgradeState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{createLogger as a}from"../../core/dist/index.js";import{execFile as o}from"node:child_process";import{homedir as s}from"node:os";const c=a(`server`);function l(){let e=r(n(i(import.meta.url)),`..`,`..`,`..`,`package.json`);try{return JSON.parse(t(e,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}}function u(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t>0?1:-1}return 0}function d(){let e=l();fetch(`https://registry.npmjs.org/@vpxa/kb/latest`,{signal:AbortSignal.timeout(5e3)}).then(e=>{if(e.ok)return e.json()}).then(t=>{if(!t||typeof t!=`object`)return;let n=t.version;n&&u(e,n)<0&&c.warn(`Update available`,{currentVersion:e,latestVersion:n,updateCommand:`kb upgrade`})}).catch(()=>{})}function f(){try{let n=r(s(),`.copilot`,`.kb-scaffold.json`);return e(n)?JSON.parse(t(n,`utf-8`)).version??null:null}catch{return null}}function p(){try{let t=l(),a=f();if(a
|
|
1
|
+
import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{createLogger as a}from"../../core/dist/index.js";import{execFile as o}from"node:child_process";import{homedir as s}from"node:os";const c=a(`server`);function l(){let e=r(n(i(import.meta.url)),`..`,`..`,`..`,`package.json`);try{return JSON.parse(t(e,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}}function u(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t>0?1:-1}return 0}function d(){let e=l();fetch(`https://registry.npmjs.org/@vpxa/kb/latest`,{signal:AbortSignal.timeout(5e3)}).then(e=>{if(e.ok)return e.json()}).then(t=>{if(!t||typeof t!=`object`)return;let n=t.version;n&&u(e,n)<0&&c.warn(`Update available`,{currentVersion:e,latestVersion:n,updateCommand:`kb upgrade`})}).catch(()=>{})}function f(){try{let n=r(s(),`.copilot`,`.kb-scaffold.json`);return e(n)?JSON.parse(t(n,`utf-8`)).version??null:null}catch{return null}}function p(){try{let n=r(process.cwd(),`.github`,`.kb-scaffold.json`);return e(n)?JSON.parse(t(n,`utf-8`)).version??null:null}catch{return null}}let m=`idle`,h=null;function g(){return{state:m,error:h}}function _(){try{let t=l(),a=f(),s=p();if(!(a!=null&&a!==t)&&!(s!=null&&s!==t)||m===`pending`||m===`success`)return;m=`pending`,h=null,c.info(`Scaffold version mismatch — auto-upgrading`,{serverVersion:t,userScaffoldVersion:a,workspaceScaffoldVersion:s});let u=r(n(i(import.meta.url)),`..`,`..`,`..`,`bin`,`kb.mjs`);if(!e(u)){m=`failed`,h=`kb CLI binary not found at ${u}`,c.warn(`Cannot auto-upgrade: kb CLI binary not found`,{binPath:u});return}o(process.execPath,[u,`upgrade`],{timeout:3e4,windowsHide:!0},(e,t,n)=>{e?(m=`failed`,h=e.message,c.warn(`Auto-upgrade failed`,{error:e.message,stderr:n?.slice(0,500)})):(m=`success`,h=null,c.info(`Auto-upgrade complete`))}).unref()}catch(e){m=`failed`,h=e instanceof Error?e.message:String(e),c.warn(`Auto-upgrade check failed`,{error:h})}}export{_ as autoUpgradeScaffold,d as checkForUpdates,l as getCurrentVersion,g as getUpgradeState};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{bookendReorder as e,cosineSimilarity as t,segment as n}from"./text-utils.js";import{readFile as r,stat as i}from"node:fs/promises";async function a(a,o){let{query:s,maxChars:c=3e3,minScore:l=.3,segmentation:u=`paragraph`}=o,d=o.tokenBudget?o.tokenBudget*4:c,f;if(o.text)f=o.text;else if(o.path){let e;try{e=await i(o.path)}catch(e){let t=e.code;throw t===`ENOENT`?Error(`File not found: ${o.path}. Check the path and try again.`):t===`EACCES`||t===`EPERM`?Error(`Permission denied reading ${o.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.`);f=o.cache?(await o.cache.get(o.path)).content:await r(o.path,`utf-8`)}else throw Error(`Either "text" or "path" must be provided`);if(f.length<=d)return{text:f,originalChars:f.length,compressedChars:f.length,ratio:1,segmentsKept:1,segmentsTotal:1};let p=n(f,u);if(p.length===0)return{text:``,originalChars:f.length,compressedChars:0,ratio:0,segmentsKept:0,segmentsTotal:0};let m=await a.embed(s),h=[];for(let e=0;e<p.length;e++){let n=t(m,await a.embed(p[e]));h.push({text:p[e],score:n,index:e})}let g=h.filter(e=>e.score>=l).sort((e,t)=>t.score-e.score),_=[],v=0;for(let e of g){if(v+e.text.length>d){v===0&&(_.push({...e,text:e.text.slice(0,d)}),v=d);break}_.push(e),v+=e.text.length+2}let y=e(_.sort((e,t)=>t.score-e.score)).map(e=>e.text).join(`
|
|
1
|
+
import{bookendReorder as e,cosineSimilarity as t,segment as n}from"./text-utils.js";import{readFile as r,stat as i}from"node:fs/promises";async function a(a,o){let{query:s,maxChars:c=3e3,minScore:l=.3,segmentation:u=`paragraph`}=o,d=o.tokenBudget?o.tokenBudget*4:c,f;if(o.text)f=o.text;else if(o.path){let e;try{e=await i(o.path)}catch(e){let t=e.code;throw t===`ENOENT`?Error(`File not found: ${o.path}. Check the path and try again.`):t===`EACCES`||t===`EPERM`?Error(`Permission denied reading ${o.path}. The file exists but is not accessible.`):e}if(e.isDirectory())throw Error(`Path is a directory: ${o.path}. compact requires a file path, not a directory. Use analyze_structure or find to explore directories.`);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.`);f=o.cache?(await o.cache.get(o.path)).content:await r(o.path,`utf-8`)}else throw Error(`Either "text" or "path" must be provided`);if(f.length<=d)return{text:f,originalChars:f.length,compressedChars:f.length,ratio:1,segmentsKept:1,segmentsTotal:1};let p=n(f,u);if(p.length===0)return{text:``,originalChars:f.length,compressedChars:0,ratio:0,segmentsKept:0,segmentsTotal:0};let m=await a.embed(s),h=[];for(let e=0;e<p.length;e++){let n=t(m,await a.embed(p[e]));h.push({text:p[e],score:n,index:e})}let g=h.filter(e=>e.score>=l).sort((e,t)=>t.score-e.score),_=[],v=0;for(let e of g){if(v+e.text.length>d){v===0&&(_.push({...e,text:e.text.slice(0,d)}),v=d);break}_.push(e),v+=e.text.length+2}let y=e(_.sort((e,t)=>t.score-e.score)).map(e=>e.text).join(`
|
|
2
2
|
|
|
3
3
|
`);return{text:y,originalChars:f.length,compressedChars:y.length,ratio:y.length/f.length,segmentsKept:_.length,segmentsTotal:p.length}}export{a as compact};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{estimateTokens as e}from"./text-utils.js";import{readFile as t,stat as n}from"node:fs/promises";import{resolve as r}from"node:path";import{createHash as i}from"node:crypto";var a=class i{cache=new Map;totalReads=0;cacheHits=0;static MAX_ENTRIES=500;async get(a){let s=r(a);this.totalReads++;let c=
|
|
2
|
-
`).length,a=e(n);return
|
|
3
|
-
`).length,
|
|
1
|
+
import{estimateTokens as e}from"./text-utils.js";import{readFile as t,stat as n}from"node:fs/promises";import{resolve as r}from"node:path";import{createHash as i}from"node:crypto";var a=class i{cache=new Map;totalReads=0;cacheHits=0;static MAX_ENTRIES=500;async get(a){let s=r(a);this.totalReads++;let c=await n(s);if(c.isDirectory())throw Error(`Path is a directory: ${a}. Expected a file path, not a directory. Use analyze_structure or find to explore directories.`);let l=c.mtimeMs,u=this.cache.get(s);if(u){if(u.mtimeMs===l)return this.cacheHits++,u.hitCount++,{content:u.content,hash:u.hash,lines:u.lines,estimatedTokens:u.estimatedTokens,hitCount:u.hitCount,changed:!1};let n=await t(s,`utf-8`),r=o(n);if(r===u.hash)return this.cacheHits++,u.hitCount++,u.mtimeMs=l,{content:u.content,hash:u.hash,lines:u.lines,estimatedTokens:u.estimatedTokens,hitCount:u.hitCount,changed:!1};let i=n.split(`
|
|
2
|
+
`).length,a=e(n);return u.content=n,u.hash=r,u.lines=i,u.estimatedTokens=a,u.hitCount++,u.mtimeMs=l,{content:n,hash:r,lines:i,estimatedTokens:a,hitCount:u.hitCount,changed:!0}}let d=await t(s,`utf-8`),f=o(d),p=d.split(`
|
|
3
|
+
`).length,m=e(d);if(this.cache.set(s,{content:d,hash:f,lines:p,estimatedTokens:m,hitCount:1,mtimeMs:l}),this.cache.size>i.MAX_ENTRIES){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}return{content:d,hash:f,lines:p,estimatedTokens:m,hitCount:1,changed:!0}}invalidate(e){return this.cache.delete(r(e))}clear(){let e=this.cache.size;return this.cache.clear(),e}stats(){return{totalReads:this.totalReads,cacheHits:this.cacheHits,filesTracked:this.cache.size}}};function o(e){return i(`sha256`).update(e).digest(`hex`)}export{a as FileCache};
|
|
@@ -1,2 +1,2 @@
|
|
|
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(`
|
|
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.isDirectory())throw Error(`Path is a directory: ${o}. file_summary requires a file path, not a directory. Use analyze_structure or find to explore directories.`);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
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
|
-
const e=[{name:`onboard`,description:`First-time codebase exploration and understanding`,keywords:[`onboard`,`new project`,`understand`,`explore`,`first time`,`getting started`,`learn`,`overview`],tools:[{tool:`status`,reason:`Check index health and record count`,order:1},{tool:`onboard`,reason:`Run all analysis tools in one command`,order:2,suggestedArgs:{path:`.`}},{tool:`search`,reason:`Find specific topics of interest`,order:3},{tool:`graph`,reason:`Explore module relationships`,order:4,suggestedArgs:{action:`stats`}}]},{name:`audit`,description:`Assess project health, quality, and structure`,keywords:[`audit`,`health`,`quality`,`assess`,`review project`,`check quality`,`code quality`,`tech debt`],tools:[{tool:`status`,reason:`Check index freshness`,order:1},{tool:`audit`,reason:`Unified audit report with score and recommendations`,order:2,suggestedArgs:{detail:`summary`}},{tool:`check`,reason:`Typecheck + lint validation`,order:3},{tool:`health`,reason:`Detailed health checks on package.json, tsconfig, etc.`,order:4}]},{name:`bugfix`,description:`Diagnose and fix a bug or failing test`,keywords:[`bug`,`fix`,`debug`,`error`,`failing`,`broken`,`crash`,`wrong`,`issue`,`problem`,`not working`],tools:[{tool:`parse_output`,reason:`Parse error output from build tools (tsc, vitest, biome)`,order:1},{tool:`symbol`,reason:`Find definition and all references of the failing symbol`,order:2},{tool:`trace`,reason:`Trace call chain backward from the failure point`,order:3,suggestedArgs:{direction:`backward`}},{tool:`search`,reason:`Search for related patterns or similar fixes`,order:4},{tool:`test_run`,reason:`Re-run tests after fix`,order:5}]},{name:`implement`,description:`Add a new feature or implement a change`,keywords:[`implement`,`add feature`,`new feature`,`build`,`create`,`add`,`develop`,`write code`],tools:[{tool:`scope_map`,reason:`Generate a reading plan for affected files`,order:1},{tool:`search`,reason:`Find related patterns and prior art`,order:2},{tool:`find`,reason:`Find usage examples of similar patterns`,order:3,suggestedArgs:{mode:`examples`}},{tool:`check`,reason:`Validate after implementation`,order:4},{tool:`test_run`,reason:`Run tests to verify`,order:5},{tool:`blast_radius`,reason:`Check impact of changes`,order:6}]},{name:`refactor`,description:`Restructure or clean up existing code`,keywords:[`refactor`,`restructure`,`clean up`,`reorganize`,`rename`,`move`,`extract`,`DRY`,`dead code`],tools:[{tool:`dead_symbols`,reason:`Find unused exports to remove`,order:1},{tool:`symbol`,reason:`Find all references before renaming`,order:2},{tool:`blast_radius`,reason:`Assess impact before making changes`,order:3},{tool:`rename`,reason:`Safe cross-file rename`,order:4},{tool:`check`,reason:`Validate after refactoring`,order:5},{tool:`test_run`,reason:`Ensure no regressions`,order:6}]},{name:`search`,description:`Find specific code, patterns, or information`,keywords:[`find`,`search`,`where`,`locate`,`look for`,`grep`,`which file`,`how does`],tools:[{tool:`search`,reason:`Hybrid semantic + keyword search`,order:1},{tool:`find`,reason:`Federated search with glob and regex`,order:2},{tool:`symbol`,reason:`Resolve a specific symbol definition and references`,order:3},{tool:`graph`,reason:`Explore entity relationships`,order:4,suggestedArgs:{action:`neighbors`}}]},{name:`context`,description:`Compress or manage context for efficient LLM interaction`,keywords:[`context`,`compress`,`summarize`,`too long`,`token`,`budget`,`reduce`,`compact`],tools:[{tool:`file_summary`,reason:`Quick structural overview without reading full file`,order:1},{tool:`compact`,reason:`Compress file to relevant sections`,order:2,suggestedArgs:{segmentation:`paragraph`}},{tool:`digest`,reason:`Compress multiple sources into budgeted summary`,order:3},{tool:`stratum_card`,reason:`Generate reusable context cards`,order:4}]},{name:`memory`,description:`Manage persistent knowledge across sessions`,keywords:[`memory`,`remember`,`persist`,`save`,`recall`,`decision`,`convention`,`session`,`checkpoint`],tools:[{tool:`list`,reason:`See all stored knowledge entries`,order:1},{tool:`search`,reason:`Search curated knowledge`,order:2,suggestedArgs:{origin:`curated`}},{tool:`remember`,reason:`Store a new decision or pattern`,order:3},{tool:`checkpoint`,reason:`Save/restore session progress`,order:4},{tool:`stash`,reason:`Temporary key-value storage within session`,order:5}]},{name:`validate`,description:`Run checks, tests, and validation`,keywords:[`validate`,`check`,`test`,`lint`,`typecheck`,`verify`,`CI`,`pass`,`run tests`],tools:[{tool:`check`,reason:`Typecheck + lint in one call`,order:1,suggestedArgs:{detail:`errors`}},{tool:`test_run`,reason:`Run tests with structured output`,order:2},{tool:`health`,reason:`Project health assessment`,order:3}]},{name:`analyze`,description:`Deep analysis of codebase structure, dependencies, or patterns`,keywords:[`analyze`,`dependency`,`structure`,`pattern`,`architecture`,`diagram`,`entry point`,`import`],tools:[{tool:`analyze_structure`,reason:`Project structure overview`,order:1},{tool:`analyze_dependencies`,reason:`Dependency graph and analysis`,order:2},{tool:`analyze_patterns`,reason:`Detect code patterns and conventions`,order:3},{tool:`analyze_entry_points`,reason:`Find handlers, exports, and entry points`,order:4},{tool:`analyze_diagram`,reason:`Generate Mermaid diagrams`,order:5}]}];function t(t,n=5){let r=t.toLowerCase(),i=e.map(e=>{let t=0;for(let n of e.keywords)r.includes(n)&&(t+=n.includes(` `)?2:1);return{workflow:e,score:t}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),a=e.find(e=>e.name===`search`)??e[0],o=i[0]?.workflow??a,s=i.slice(1,4).map(e=>e.workflow.name).filter(e=>e!==o.name);return{workflow:o.name,description:o.description,tools:o.tools.slice(0,n),alternativeWorkflows:s}}export{t as guide};
|
|
1
|
+
const e=[{name:`onboard`,description:`First-time codebase exploration and understanding`,keywords:[`onboard`,`new project`,`understand`,`explore`,`first time`,`getting started`,`learn`,`overview`],tools:[{tool:`status`,reason:`Check index health and record count`,order:1},{tool:`onboard`,reason:`Run all analysis tools in one command`,order:2,suggestedArgs:{path:`.`}},{tool:`search`,reason:`Find specific topics of interest`,order:3},{tool:`graph`,reason:`Explore module relationships`,order:4,suggestedArgs:{action:`stats`}}]},{name:`audit`,description:`Assess project health, quality, and structure`,keywords:[`audit`,`health`,`quality`,`assess`,`review project`,`check quality`,`code quality`,`tech debt`],tools:[{tool:`status`,reason:`Check index freshness`,order:1},{tool:`audit`,reason:`Unified audit report with score and recommendations`,order:2,suggestedArgs:{detail:`summary`}},{tool:`check`,reason:`Typecheck + lint validation`,order:3},{tool:`health`,reason:`Detailed health checks on package.json, tsconfig, etc.`,order:4}]},{name:`bugfix`,description:`Diagnose and fix a bug or failing test`,keywords:[`bug`,`fix`,`debug`,`error`,`failing`,`broken`,`crash`,`wrong`,`issue`,`problem`,`not working`],tools:[{tool:`parse_output`,reason:`Parse error output from build tools (tsc, vitest, biome)`,order:1},{tool:`symbol`,reason:`Find definition and all references of the failing symbol`,order:2},{tool:`trace`,reason:`Trace call chain backward from the failure point`,order:3,suggestedArgs:{direction:`backward`}},{tool:`search`,reason:`Search for related patterns or similar fixes`,order:4},{tool:`test_run`,reason:`Re-run tests after fix`,order:5}]},{name:`implement`,description:`Add a new feature or implement a change`,keywords:[`implement`,`add feature`,`new feature`,`build`,`create`,`add`,`develop`,`write code`],tools:[{tool:`scope_map`,reason:`Generate a reading plan for affected files`,order:1},{tool:`search`,reason:`Find related patterns and prior art`,order:2},{tool:`find`,reason:`Find usage examples of similar patterns`,order:3,suggestedArgs:{mode:`examples`}},{tool:`check`,reason:`Validate after implementation`,order:4},{tool:`test_run`,reason:`Run tests to verify`,order:5},{tool:`blast_radius`,reason:`Check impact of changes`,order:6}]},{name:`refactor`,description:`Restructure or clean up existing code`,keywords:[`refactor`,`restructure`,`clean up`,`reorganize`,`rename`,`move`,`extract`,`DRY`,`dead code`],tools:[{tool:`dead_symbols`,reason:`Find unused exports to remove`,order:1},{tool:`symbol`,reason:`Find all references before renaming`,order:2},{tool:`blast_radius`,reason:`Assess impact before making changes`,order:3},{tool:`rename`,reason:`Safe cross-file rename`,order:4},{tool:`check`,reason:`Validate after refactoring`,order:5},{tool:`test_run`,reason:`Ensure no regressions`,order:6}]},{name:`search`,description:`Find specific code, patterns, or information`,keywords:[`find`,`search`,`where`,`locate`,`look for`,`grep`,`which file`,`how does`],tools:[{tool:`search`,reason:`Hybrid semantic + keyword search`,order:1},{tool:`find`,reason:`Federated search with glob and regex`,order:2},{tool:`symbol`,reason:`Resolve a specific symbol definition and references`,order:3},{tool:`graph`,reason:`Explore entity relationships`,order:4,suggestedArgs:{action:`neighbors`}}]},{name:`context`,description:`Compress or manage context for efficient LLM interaction`,keywords:[`context`,`compress`,`summarize`,`too long`,`token`,`budget`,`reduce`,`compact`],tools:[{tool:`file_summary`,reason:`Quick structural overview without reading full file`,order:1},{tool:`compact`,reason:`Compress file to relevant sections`,order:2,suggestedArgs:{segmentation:`paragraph`}},{tool:`digest`,reason:`Compress multiple sources into budgeted summary`,order:3},{tool:`stratum_card`,reason:`Generate reusable context cards`,order:4}]},{name:`memory`,description:`Manage persistent knowledge across sessions`,keywords:[`memory`,`remember`,`persist`,`save`,`recall`,`decision`,`convention`,`session`,`checkpoint`],tools:[{tool:`list`,reason:`See all stored knowledge entries`,order:1},{tool:`search`,reason:`Search curated knowledge`,order:2,suggestedArgs:{origin:`curated`}},{tool:`remember`,reason:`Store a new decision or pattern`,order:3},{tool:`checkpoint`,reason:`Save/restore session progress`,order:4},{tool:`stash`,reason:`Temporary key-value storage within session`,order:5}]},{name:`validate`,description:`Run checks, tests, and validation`,keywords:[`validate`,`check`,`test`,`lint`,`typecheck`,`verify`,`CI`,`pass`,`run tests`],tools:[{tool:`check`,reason:`Typecheck + lint in one call`,order:1,suggestedArgs:{detail:`errors`}},{tool:`test_run`,reason:`Run tests with structured output`,order:2},{tool:`health`,reason:`Project health assessment`,order:3}]},{name:`analyze`,description:`Deep analysis of codebase structure, dependencies, or patterns`,keywords:[`analyze`,`dependency`,`structure`,`pattern`,`architecture`,`diagram`,`entry point`,`import`],tools:[{tool:`analyze_structure`,reason:`Project structure overview`,order:1},{tool:`analyze_dependencies`,reason:`Dependency graph and analysis`,order:2},{tool:`analyze_patterns`,reason:`Detect code patterns and conventions`,order:3},{tool:`analyze_entry_points`,reason:`Find handlers, exports, and entry points`,order:4},{tool:`analyze_diagram`,reason:`Generate Mermaid diagrams`,order:5}]},{name:`upgrade`,description:`Update KB agents, prompts, skills, and scaffold to the latest version (user-level and workspace-level)`,keywords:[`upgrade`,`update`,`version`,`scaffold`,`outdated`,`mismatch`,`deploy`,`install`,`refresh`],tools:[{tool:`status`,reason:`Check current versions and detect mismatches — auto-triggers upgrade when a version mismatch is found`,order:1},{tool:`reindex`,reason:`Refresh the index after the upgrade completes`,order:2},{tool:`produce_knowledge`,reason:`Regenerate codebase analysis with updated tooling`,order:3,suggestedArgs:{path:`.`}}]}];function t(t,n=5){let r=t.toLowerCase(),i=e.map(e=>{let t=0;for(let n of e.keywords)r.includes(n)&&(t+=n.includes(` `)?2:1);return{workflow:e,score:t}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),a=e.find(e=>e.name===`search`)??e[0],o=i[0]?.workflow??a,s=i.slice(1,4).map(e=>e.workflow.name).filter(e=>e!==o.name);return{workflow:o.name,description:o.description,tools:o.tools.slice(0,n),alternativeWorkflows:s}}export{t as guide};
|
|
@@ -34,6 +34,13 @@ interface OnboardResult {
|
|
|
34
34
|
outDir?: string;
|
|
35
35
|
/** Total duration in ms */
|
|
36
36
|
totalDurationMs: number;
|
|
37
|
+
/** Auto-generated knowledge entries for curated store persistence */
|
|
38
|
+
autoRemember?: Array<{
|
|
39
|
+
title: string;
|
|
40
|
+
content: string;
|
|
41
|
+
category: string;
|
|
42
|
+
tags: string[];
|
|
43
|
+
}>;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Run all onboarding analyses in parallel and return combined results.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{extractConfigValues as e}from"./config-extractor.js";import{buildDiagrams as t}from"./diagram-builder.js";import{buildCodeMap as n,buildSynthesisGuide as r}from"./synthesis-engine.js";import{DependencyAnalyzer as i,DiagramGenerator as a,EntryPointAnalyzer as o,PatternAnalyzer as
|
|
1
|
+
import{extractConfigValues as e}from"./config-extractor.js";import{buildDiagrams as t}from"./diagram-builder.js";import{buildCodeMap as n,buildSynthesisGuide as r}from"./synthesis-engine.js";import{DependencyAnalyzer as i,DiagramGenerator as a,EntryPointAnalyzer as o,PatternAnalyzer as ee,StructureAnalyzer as s,SymbolAnalyzer as c,extractRegexCallGraph as l,extractTsCallGraph as u}from"../../analyzers/dist/index.js";import{basename as d,join as f,resolve as p}from"node:path";import{existsSync as m,mkdirSync as h,readdirSync as g,rmSync as _,writeFileSync as v}from"node:fs";import{KB_PATHS as y}from"../../core/dist/index.js";const b={structure:`Project Structure`,dependencies:`Dependencies`,"entry-points":`Entry Points`,symbols:`Symbols`,patterns:`Patterns`,diagram:`C4 Container Diagram`,"code-map":`Code Map (Module Graph)`,"config-values":`Configuration Values`,"synthesis-guide":`Synthesis Guide`,"api-surface":`API Surface`,"type-inventory":`Type Inventory`};function x(e){let t=e.get(`symbols`);if(!t?.symbols?.length)return`# API Surface
|
|
2
2
|
|
|
3
3
|
*No symbol data available.*
|
|
4
4
|
`;let n=t.symbols.filter(e=>e.exported);if(n.length===0)return`# API Surface
|
|
@@ -6,7 +6,7 @@ import{extractConfigValues as e}from"./config-extractor.js";import{buildDiagrams
|
|
|
6
6
|
*No exported symbols found.*
|
|
7
7
|
`;let r=new Map;for(let e of n){let t=r.get(e.filePath)??[];t.push(e),r.set(e.filePath,t)}let i=[`# API Surface
|
|
8
8
|
`];for(let[e,t]of[...r.entries()].sort(([e],[t])=>e.localeCompare(t))){i.push(`## ${e}\n`);for(let e of t){e.decorators?.length&&i.push(e.decorators.join(` `));let t=e.signature??``,n=e.returnType?`: ${e.returnType}`:``;if(e.kind===`function`||e.kind===`method`)i.push(`### \`${e.name}${t}${n}\``);else if(e.kind===`class`)i.push(`### class \`${e.name}\`${t?` ${t}`:``}`);else if(e.kind===`interface`||e.kind===`type`){let t=e.typeBody?` ${e.typeBody}`:``;i.push(`### ${e.kind} \`${e.name}\`${t}`)}else i.push(`### ${e.kind} \`${e.name}\`${t?`: ${t}`:``}`);e.jsdoc&&i.push(`> ${e.jsdoc}`),i.push(``)}}let a=i.join(`
|
|
9
|
-
`);return a.length>1e5?`${a.slice(0,1e5)}\n\n*[truncated]*`:a}function
|
|
9
|
+
`);return a.length>1e5?`${a.slice(0,1e5)}\n\n*[truncated]*`:a}function S(e){let t=e.get(`symbols`);if(!t?.symbols?.length)return`# Type Inventory
|
|
10
10
|
|
|
11
11
|
*No symbol data available.*
|
|
12
12
|
`;let n=t.symbols.filter(e=>e.exported&&(e.kind===`interface`||e.kind===`type`||e.kind===`enum`));if(n.length===0)return`# Type Inventory
|
|
@@ -14,5 +14,5 @@ import{extractConfigValues as e}from"./config-extractor.js";import{buildDiagrams
|
|
|
14
14
|
*No exported types/interfaces found.*
|
|
15
15
|
`;let r=new Map;for(let e of n){let t=r.get(e.filePath)??[];t.push(e),r.set(e.filePath,t)}let i=[`# Type Inventory
|
|
16
16
|
`];for(let[e,t]of[...r.entries()].sort(([e],[t])=>e.localeCompare(t))){i.push(`## ${e}\n`);for(let e of t){let t=e.typeBody??`*body not available*`;e.jsdoc&&i.push(`> ${e.jsdoc}`),i.push(`### ${e.kind} \`${e.name}\``),i.push("```"),i.push(t),i.push("```\n")}}let a=i.join(`
|
|
17
|
-
`);return a.length>1e5?`${a.slice(0,1e5)}\n\n*[truncated]*`:a}async function
|
|
18
|
-
`),`utf-8`)}return{
|
|
17
|
+
`);return a.length>1e5?`${a.slice(0,1e5)}\n\n*[truncated]*`:a}async function C(C){let w=Date.now(),T=p(C.path),E=d(T),D=C.mode??`generate`,O=C.outDir??f(T,y.aiKb),k=new s,A=new i,j=new c,M=new ee,N=new o,P=new a,F=[{name:`structure`,fn:()=>k.analyze(T,{format:`markdown`,maxDepth:3,sourceOnly:!0})},{name:`dependencies`,fn:()=>A.analyze(T,{format:`markdown`})},{name:`entry-points`,fn:()=>N.analyze(T)},{name:`symbols`,fn:()=>j.analyze(T,{format:`markdown`})},{name:`patterns`,fn:()=>M.analyze(T)},{name:`diagram`,fn:()=>P.analyze(T,{diagramType:`architecture`})}],I=await Promise.allSettled(F.map(async e=>{let t=Date.now(),n=await e.fn();return{name:e.name,result:n,durationMs:Date.now()-t}})),L=[],R=new Map,z=new Map;for(let e of I)if(e.status===`fulfilled`){let{name:t,result:n,durationMs:r}=e.value,i=n;L.push({name:t,status:`success`,output:i.output,durationMs:r}),R.set(t,i.output),z.set(t,i.data)}else{let t=e.reason,n=F[I.indexOf(e)].name;L.push({name:n,status:`failed`,output:``,durationMs:0,error:t.message})}let B=Date.now(),V=null;try{let e=await u(T);if((!e||e.edges.length===0)&&(e=await l(T)),e&&e.edges.length>0){V=new Map;for(let t of e.edges){let e=V.get(t.from);e||(e=new Map,V.set(t.from,e));let n=e.get(t.to);if(n)for(let e of t.symbols)n.includes(e)||n.push(e);else e.set(t.to,[...t.symbols])}}}catch{}let H=Date.now()-B,U=Date.now(),W=n(z,E,V),G=Date.now()-U+H;if(L.push({name:`code-map`,status:`success`,output:W,durationMs:G}),R.set(`code-map`,W),V&&V.size>0){let e=t(V,z,E),n=L.find(e=>e.name===`diagram`);n&&(n.output=e,R.set(`diagram`,e))}let K=Date.now(),q=await e(T,E),J=Date.now()-K;L.push({name:`config-values`,status:`success`,output:q,durationMs:J}),R.set(`config-values`,q);let Y=r(L,D,E,z);L.push({name:`synthesis-guide`,status:`success`,output:Y,durationMs:0}),R.set(`synthesis-guide`,Y);let X=x(z);L.push({name:`api-surface`,status:`success`,output:X,durationMs:0}),R.set(`api-surface`,X);let Z=S(z);if(L.push({name:`type-inventory`,status:`success`,output:Z,durationMs:0}),R.set(`type-inventory`,Z),D===`generate`){if(m(O))for(let e of g(O))(e.endsWith(`.md`)||e.endsWith(`.json`))&&_(f(O,e),{force:!0});h(O,{recursive:!0});let e=new Date().toISOString();for(let[t,n]of R){let r=f(O,`${t}.md`),i=n.replaceAll(T,E);v(r,`<!-- Generated: ${e} -->\n<!-- Project: ${E} -->\n<!-- Source: ${T} -->\n\n`+i,`utf-8`)}let t=[`<!-- Generated: ${e} -->`,`<!-- Project: ${E} -->`,`<!-- Source: ${T} -->`,``,`# ${E} — Codebase Knowledge`,``,`## Contents`,``];for(let e of L){let n=`${e.name}.md`,r=b[e.name]??e.name,i=e.status===`success`?`✓`:`✗`,a=e.durationMs>0?` (${e.durationMs}ms)`:``;t.push(`- ${i} [${r}](./${n})${a}`)}t.push(``),v(f(O,`README.md`),t.join(`
|
|
18
|
+
`),`utf-8`)}let Q=[];Q.push({title:`Onboard: ${E} project overview`,content:Y.slice(0,2e3),category:`conventions`,tags:[`onboard`,`project-overview`,E]});let $=L.find(e=>e.name===`patterns`);return $?.status===`success`&&$.output&&Q.push({title:`Onboard: ${E} detected patterns`,content:$.output.slice(0,1500),category:`patterns`,tags:[`onboard`,`patterns`,E]}),q&&Q.push({title:`Onboard: ${E} config and commands`,content:q.slice(0,1500),category:`conventions`,tags:[`onboard`,`config`,`commands`,E]}),{path:T,mode:D,steps:L,outDir:D===`generate`?O:void 0,totalDurationMs:Date.now()-w,autoRemember:Q}}export{C as onboard};
|
|
@@ -35,7 +35,7 @@ const COPILOT_TOOL_MAP = {
|
|
|
35
35
|
createFile: 'edit/createFile',
|
|
36
36
|
editFiles: 'edit/editFiles',
|
|
37
37
|
search: 'search/changes, search/codebase, search/usages',
|
|
38
|
-
web: 'web/fetch, web/githubRepo
|
|
38
|
+
web: 'web/fetch, web/githubRepo',
|
|
39
39
|
todo: 'todo',
|
|
40
40
|
memory: 'vscode/memory',
|
|
41
41
|
runCommand: 'vscode/runCommand',
|
|
@@ -46,8 +46,9 @@ const COPILOT_TOOL_MAP = {
|
|
|
46
46
|
fileSearch: 'search/fileSearch',
|
|
47
47
|
listDir: 'search/listDirectory',
|
|
48
48
|
textSearch: 'search/textSearch',
|
|
49
|
-
|
|
50
|
-
browser:
|
|
49
|
+
searchSubagent: 'search/searchSubagent',
|
|
50
|
+
browser:
|
|
51
|
+
'browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog',
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
function buildToolsYaml(toolRole) {
|
|
@@ -106,7 +106,7 @@ export const KB_TOOLS = [
|
|
|
106
106
|
* fileSearch — search by filename
|
|
107
107
|
* listDir — list directory
|
|
108
108
|
* textSearch — text search
|
|
109
|
-
*
|
|
109
|
+
* searchSubagent — search via subagent
|
|
110
110
|
*/
|
|
111
111
|
export const IDE_CAPABILITIES = {
|
|
112
112
|
orchestrator: [
|
|
@@ -126,7 +126,7 @@ export const IDE_CAPABILITIES = {
|
|
|
126
126
|
'search',
|
|
127
127
|
'web',
|
|
128
128
|
'todo',
|
|
129
|
-
'
|
|
129
|
+
'searchSubagent',
|
|
130
130
|
'textSearch',
|
|
131
131
|
'browser',
|
|
132
132
|
],
|
|
@@ -197,6 +197,7 @@ export const IDE_CAPABILITIES = {
|
|
|
197
197
|
'search',
|
|
198
198
|
'web',
|
|
199
199
|
'todo',
|
|
200
|
+
'searchSubagent',
|
|
200
201
|
'browser',
|
|
201
202
|
],
|
|
202
203
|
security: ['terminal', 'problems', 'readFile', 'subagent', 'search', 'web', 'browser'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Primary architecture reviewer'
|
|
3
3
|
argument-hint: Files, PR, or subsystem to architecture-review
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: GPT-5.4 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Architecture reviewer variant — different LLM perspective for dual review'
|
|
3
3
|
argument-hint: Files, PR, or subsystem to architecture-review
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: Claude Opus 4.6 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Primary code reviewer'
|
|
3
3
|
argument-hint: File path, PR, or code to review
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: GPT-5.4 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Code reviewer variant — different LLM perspective for dual review'
|
|
3
3
|
argument-hint: File path, PR, or code to review
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: Claude Opus 4.6 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Expert debugger that diagnoses issues, traces errors, and provides solutions'
|
|
3
3
|
argument-hint: Error message, stack trace, or description of issue
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalSelection, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, browser
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalSelection, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: Claude Opus 4.6 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Documentation specialist that creates and maintains comprehensive project documentation'
|
|
3
3
|
argument-hint: Component, API, feature, or area to document
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: GPT-5.4 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Rapid codebase exploration to find files, usages, dependencies, and structural context'
|
|
3
3
|
argument-hint: Find files, usages, and context related to: {topic or goal}
|
|
4
|
-
tools: [read/problems, read/readFile, search/changes, search/codebase, search/usages, search/fileSearch, search/listDirectory, search/textSearch, browser
|
|
4
|
+
tools: [read/problems, read/readFile, search/changes, search/codebase, search/usages, search/fileSearch, search/listDirectory, search/textSearch, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: Gemini 3 Flash (Preview) (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'UI/UX specialist for React, styling, responsive design, and frontend implementation'
|
|
3
3
|
argument-hint: UI component, styling task, or frontend feature
|
|
4
|
-
tools: [execute/createAndRunTask, execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, todo, browser
|
|
4
|
+
tools: [execute/createAndRunTask, execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, todo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: Gemini 3.1 Pro (Preview) (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Persistent implementation agent that writes code following TDD practices until all tasks are complete'
|
|
3
3
|
argument-hint: Implementation task, feature, or phase from plan
|
|
4
|
-
tools: [execute/createAndRunTask, execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, todo, browser
|
|
4
|
+
tools: [execute/createAndRunTask, execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, todo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: GPT-5.4 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Master conductor that orchestrates the full development lifecycle: Planning → Implementation → Review → Recovery → Commit'
|
|
3
|
-
tools: [vscode/memory, vscode/runCommand, vscode/switchAgent, execute/killTerminal, execute/createAndRunTask, execute/runInTerminal, read/terminalSelection, read/terminalLastCommand, read/problems, read/readFile, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
3
|
+
tools: [vscode/memory, vscode/runCommand, vscode/switchAgent, execute/killTerminal, execute/createAndRunTask, execute/runInTerminal, read/terminalSelection, read/terminalLastCommand, read/problems, read/readFile, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, todo, search/searchSubagent, search/textSearch, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
4
4
|
model: Claude Opus 4.6 (copilot)
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Autonomous planner that researches codebases and writes comprehensive TDD implementation plans'
|
|
3
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
3
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/createFile, edit/editFiles, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, todo, search/searchSubagent, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
4
4
|
model: Claude Opus 4.6 (copilot)
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Code refactoring specialist that improves structure, readability, and maintainability'
|
|
3
3
|
argument-hint: Code, component, or pattern to refactor
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/editFiles, search/changes, search/codebase, search/usages, browser
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, edit/editFiles, search/changes, search/codebase, search/usages, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: GPT-5.4 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: 'Primary deep research agent — also serves as default Researcher'
|
|
3
3
|
argument-hint: Research question, problem statement, or subsystem to investigate
|
|
4
|
-
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo,
|
|
4
|
+
tools: [execute/runInTerminal, read/problems, read/readFile, read/terminalLastCommand, agent/runSubagent, search/changes, search/codebase, search/usages, web/fetch, web/githubRepo, browser/openBrowserPage, browser/readPage, browser/screenshotPage, browser/navigatePage, browser/clickElement, browser/dragElement, browser/hoverElement, browser/typeInPage, browser/runPlaywrightCode, browser/handleDialog, knowledge-base/*]
|
|
5
5
|
model: Claude Opus 4.6 (copilot)
|
|
6
6
|
---
|
|
7
7
|
|