@vpxa/aikit 0.1.181 → 0.1.184

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/aikit",
3
- "version": "0.1.181",
3
+ "version": "0.1.184",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -193,13 +193,13 @@ ${h}
193
193
  border-radius: var(--dt-radius-lg);
194
194
  background: var(--dt-bg-secondary);
195
195
  color: var(--dt-text-primary);
196
- box-shadow: 0 0 0 1px var(--dt-glow-purple);
197
196
  }
198
197
 
199
198
  .bk-code code {
200
199
  font-family: var(--dt-font-mono);
201
200
  font-size: var(--dt-font-size-sm);
202
201
  line-height: 1.6;
202
+ tab-size: 2;
203
203
  }
204
204
  `,comparison:`
205
205
  .bk-comparison {
@@ -952,6 +952,22 @@ ${h}
952
952
  font-family: var(--dt-font-mono);
953
953
  font-size: var(--dt-font-size-sm);
954
954
  line-height: 1.6;
955
+ white-space: pre;
956
+ }
957
+
958
+ .bk-mermaid[data-mini-mermaid-rendered] {
959
+ background: transparent;
960
+ border-color: transparent;
961
+ box-shadow: none;
962
+ padding: var(--dt-space-2);
963
+ font-family: inherit;
964
+ white-space: normal;
965
+ text-align: center;
966
+ }
967
+
968
+ .bk-mermaid[data-mini-mermaid-rendered] svg {
969
+ max-width: 100%;
970
+ height: auto;
955
971
  }
956
972
  `,metrics:`
957
973
  .bk-metrics {
@@ -1651,6 +1667,7 @@ html[data-theme='dark'] .aikit-theme-toggle-icon--moon {
1651
1667
 
1652
1668
  html {
1653
1669
  font-size: 16px;
1670
+ height: 100%;
1654
1671
  }
1655
1672
 
1656
1673
  body {
@@ -1658,6 +1675,7 @@ body {
1658
1675
  display: flex;
1659
1676
  flex-direction: column;
1660
1677
  min-height: 100vh;
1678
+ height: 100%;
1661
1679
  background: var(--dt-bg-canvas, var(--dt-bg-primary));
1662
1680
  color: var(--dt-text-primary);
1663
1681
  font-family: var(--dt-font-sans);
@@ -1672,6 +1690,10 @@ main {
1672
1690
  flex-direction: column;
1673
1691
  gap: var(--dt-space-6);
1674
1692
  }
1693
+
1694
+ main > * {
1695
+ flex-shrink: 0;
1696
+ }
1675
1697
  `,O,...(Array.isArray(t)?t:typeof t==`string`?[t]:[]).filter(e=>e.trim().length>0)].join(`
1676
1698
  `);return[` <style>${e}</style>`,` <style>${n}</style>`].join(`
1677
1699
  `)}function Hn(e){let t=Object.entries(b).map(([e,t])=>` ${e}: ${t};`).join(`
@@ -563,13 +563,13 @@
563
563
  border-radius: var(--dt-radius-lg);
564
564
  background: var(--dt-bg-secondary);
565
565
  color: var(--dt-text-primary);
566
- box-shadow: 0 0 0 1px var(--dt-glow-purple);
567
566
  }
568
567
 
569
568
  .bk-code code {
570
569
  font-family: var(--dt-font-mono);
571
570
  font-size: var(--dt-font-size-sm);
572
571
  line-height: 1.6;
572
+ tab-size: 2;
573
573
  }
574
574
  `;function ue(e,t){let n=e.language?` language-${o(String(e.language))}`:``,r=e.value??``,a=typeof r==`object`&&r?JSON.stringify(r,null,2):String(r);return`<pre class="bk-code"><code class="${n.trim()}">${i(a)}</code></pre>`}function de(e){let t=c(e);return Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.columns)?t.columns:[]}var fe=`
575
575
  .bk-comparison {
@@ -1346,6 +1346,22 @@ ${He}
1346
1346
  font-family: var(--dt-font-mono);
1347
1347
  font-size: var(--dt-font-size-sm);
1348
1348
  line-height: 1.6;
1349
+ white-space: pre;
1350
+ }
1351
+
1352
+ .bk-mermaid[data-mini-mermaid-rendered] {
1353
+ background: transparent;
1354
+ border-color: transparent;
1355
+ box-shadow: none;
1356
+ padding: var(--dt-space-2);
1357
+ font-family: inherit;
1358
+ white-space: normal;
1359
+ text-align: center;
1360
+ }
1361
+
1362
+ .bk-mermaid[data-mini-mermaid-rendered] svg {
1363
+ max-width: 100%;
1364
+ height: auto;
1349
1365
  }
1350
1366
  `;function gt(e,t){return`<pre class="bk-mermaid mermaid">${i(String(e.value??``))}</pre>`}function _t(e){if(e==null||e===``)return``;let t=s(e),n=Number(String(e).replace(/[^0-9.-]/g,``));return`<span class="bk-metric-trend">${Number.isNaN(n)?``:n>0?`↑ `:n<0?`↓ `:`→ `}${i(t)}</span>`}var vt=`
1351
1367
  .bk-metrics {
@@ -1 +1 @@
1
- import{t as e}from"./curated-manager-BnP6VqvL.js";import{randomUUID as t}from"node:crypto";import{readFileSync as n}from"node:fs";import{dirname as r,resolve as i}from"node:path";import{fileURLToPath as a,pathToFileURL as o}from"node:url";import{parseArgs as s}from"node:util";import{createLogger as c,serializeError as l}from"../../core/dist/index.js";var u=class{stateStore;options;gcTimer=null;constructor(e,t={}){this.stateStore=e,this.options=t}onSessionStart(e,t){this.stateStore.sessionCreate(e,t)}onSessionActivity(e){this.stateStore.sessionTouch(e)}onSessionEnd(e){this.stateStore.sessionDelete(e)}startGC(){if(this.gcTimer)return;let e=(this.options.gcIntervalMinutes??5)*60*1e3;this.gcTimer=setInterval(()=>{this.runGC()},e),this.gcTimer.unref()}runGC(){let e=this.options.staleTimeoutMinutes??30;return this.stateStore.sessionDeleteStale(e)}stop(){this.gcTimer&&=(clearInterval(this.gcTimer),null)}getActiveSessions(){return this.stateStore.sessionList().length}};const d=r(a(import.meta.url)),f=(()=>{try{let e=i(d,`..`,`..`,`..`,`package.json`);return JSON.parse(n(e,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}})(),p=c(`server`);function m(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}const h=(()=>{let e=process.argv[1];if(!e)return!1;try{return import.meta.url===o(e).href}catch{return!1}})();function g(e){let t=e.headers[`mcp-session-id`];return Array.isArray(t)?t[0]:t}const{values:_}=h?s({allowPositionals:!0,options:{transport:{type:`string`,default:m()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}):{values:{transport:m(),port:process.env.AIKIT_PORT??`3210`}};async function v(){if(process.on(`unhandledRejection`,e=>{p.error(`Unhandled rejection`,l(e))}),process.on(`uncaughtException`,e=>{p.error(`Uncaught exception — exiting`,l(e)),process.exit(1)}),p.info(`Starting MCP AI Kit server`,{version:f}),_.transport===`http`){let[{default:e},{loadConfig:n,resolveIndexMode:r},{registerDashboardRoutes:i,resolveDashboardDir:a},{registerSettingsRoutes:o,resolveSettingsDir:s},{createSettingsRouter:c},{authMiddleware:d,getOrCreateToken:f}]=await Promise.all([import(`express`),import(`./config-DAnAxrUW.js`),import(`./dashboard-static-CnXafYTs.js`),import(`./settings-static-BkVLqWOr.js`),import(`./routes-CR3fI-HJ.js`),import(`./auth-BfqgawfR.js`).then(e=>e.t)]),m=n();p.info(`Config loaded`,{sourceCount:m.sources.length,storePath:m.store.path});let h=e();h.use(e.json());let v=Number(_.port);h.use((e,t,n)=>{if(t.setHeader(`Access-Control-Allow-Origin`,process.env.AIKIT_CORS_ORIGIN??`http://localhost:${v}`),t.setHeader(`Access-Control-Allow-Methods`,`GET, POST, PUT, PATCH, DELETE, OPTIONS`),t.setHeader(`Access-Control-Allow-Headers`,`Content-Type, Authorization, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID`),t.setHeader(`Access-Control-Expose-Headers`,`Mcp-Session-Id`),e.method===`OPTIONS`){t.status(204).end();return}n()});let y=f();console.error(`[aikit] Auth token: ~/.aikit/token`),h.use(d(y)),i(h,a(),p);let b=new Date().toISOString();h.use(`/settings/api`,c({log:p,mcpInfo:()=>({transport:`http`,port:v,pid:process.pid,startedAt:b})})),o(h,s(),p),h.get(`/health`,(e,t)=>{t.json({status:`ok`})});let x=!1,S=null,C=null,w=null,T=null,E=null,D=null,O=Promise.resolve(),k=async(e,n)=>{if(!x||!w||!T){n.status(503).json({jsonrpc:`2.0`,error:{code:-32603,message:`Server initializing — please retry in a few seconds`},id:null});return}let r=O,i;O=new Promise(e=>{i=e}),await r;try{let r=g(e);if(!E){if(r){n.status(404).json({jsonrpc:`2.0`,error:{code:-32001,message:`Session not found`},id:null});return}let e=new T({sessionIdGenerator:()=>t(),onsessioninitialized:async e=>{D=e,C?.onSessionStart(e,{transport:`http`})},onsessionclosed:async e=>{e&&C?.onSessionEnd(e),D=null}});e.onclose=()=>{E===e&&(E=null),D===e.sessionId&&(D=null)},E=e,await w.connect(e)}let i=E;await i.handleRequest(e,n,e.body),e.method!==`DELETE`&&(!r&&i.sessionId?(D=i.sessionId,C?.onSessionStart(i.sessionId,{transport:`http`}),C?.onSessionActivity(i.sessionId)):r&&C?.onSessionActivity(r))}catch(e){if(p.error(`MCP handler error`,l(e)),!n.headersSent){let t=e instanceof Error?e.message:String(e),r=t.includes(`Not Acceptable`);n.status(r?406:500).json({jsonrpc:`2.0`,error:{code:r?-32e3:-32603,message:r?t:`Internal server error`},id:null})}}finally{i()}};h.post(`/mcp`,k),h.get(`/mcp`,k),h.delete(`/mcp`,k);let A=h.listen(v,`127.0.0.1`,()=>{p.info(`MCP server listening`,{url:`http://127.0.0.1:${v}/mcp`,port:v}),setTimeout(async()=>{try{let[{createLazyServer:e,ALL_TOOL_NAMES:t},{StreamableHTTPServerTransport:n},{checkForUpdates:i,autoUpgradeScaffold:a}]=await Promise.all([import(`./server-tzRu5ODc.js`),import(`@modelcontextprotocol/sdk/server/streamableHttp.js`),import(`./version-check-BgHzxxCW.js`)]);i(),a();let o=r(m),s=e(m,o);w=s.server,T=n,x=!0,p.info(`MCP server configured (lazy — AI Kit initializing in background)`,{toolCount:t.length,resourceCount:2}),s.startInit(),s.ready.then(()=>{if(!s.aikit)throw Error(`AI Kit components are not available after initialization`);C=new u(s.aikit.stateStore),C.startGC(),D&&(C.onSessionStart(D,{transport:`http`}),C.onSessionActivity(D))}).catch(e=>p.error(`Failed to start session manager`,l(e))),o===`auto`?s.ready.then(async()=>{try{let e=m.sources.map(e=>e.path).join(`, `);p.info(`Running initial index`,{sourcePaths:e}),await s.runInitialIndex(),p.info(`Initial index complete`)}catch(e){p.error(`Initial index failed; will retry on aikit_reindex`,l(e))}}).catch(e=>p.error(`AI Kit init or indexing failed`,l(e))):o===`smart`?s.ready.then(async()=>{try{if(!s.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(s.aikit.indexer,m,s.aikit.store),n=s.aikit.store;S=t,t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),s.setSmartScheduler(t),p.info(`Smart index scheduler started (HTTP mode)`)}catch(e){p.error(`Failed to start smart index scheduler`,l(e))}}).catch(e=>p.error(`AI Kit initialization failed`,l(e))):(s.ready.catch(e=>p.error(`AI Kit initialization failed`,l(e))),p.info(`Initial full indexing skipped in HTTP mode`,{indexMode:o}))}catch(e){p.error(`Failed to load server modules`,l(e))}},100)}),j=async e=>{p.info(`Shutdown signal received`,{signal:e}),S?.stop(),C?.stop(),D&&C?.onSessionEnd(D),E&&(await E.close().catch(()=>void 0),E=null,D=null),A.close(),w&&await w.close(),process.exit(0)};process.on(`SIGINT`,()=>j(`SIGINT`)),process.on(`SIGTERM`,()=>j(`SIGTERM`))}else{let[{loadConfig:e,reconfigureForWorkspace:t,resolveIndexMode:n},{createLazyServer:r},{checkForUpdates:i,autoUpgradeScaffold:o},{RootsListChangedNotificationSchema:s}]=await Promise.all([import(`./config-DAnAxrUW.js`),import(`./server-tzRu5ODc.js`),import(`./version-check-BgHzxxCW.js`),import(`@modelcontextprotocol/sdk/types.js`)]),c=e();p.info(`Config loaded`,{sourceCount:c.sources.length,storePath:c.store.path}),i(),o();let u=n(c),d=r(c,u),{server:f,startInit:m,ready:h,runInitialIndex:g}=d,{StdioServerTransport:_}=await import(`@modelcontextprotocol/sdk/server/stdio.js`),v=new _;await f.connect(v),p.info(`MCP server started`,{transport:`stdio`});let y=e=>{if(e.length===0)return!1;let n=e[0].uri,r=n.startsWith(`file://`)?a(n):n;return p.info(`MCP roots resolved`,{rootUri:n,rootPath:r,rootCount:e.length}),t(c,r),c.allRoots=e.map(e=>{let t=e.uri;return t.startsWith(`file://`)?a(t):t}),!0},b=!1;try{b=y((await f.server.listRoots()).roots),b||p.info(`No MCP roots yet; waiting for roots/list_changed notification`)}catch(e){p.warn(`MCP roots/list not supported by client; using cwd fallback`,{cwd:process.cwd(),...l(e)}),b=!0}b||=await new Promise(e=>{let t=setTimeout(()=>{p.warn(`Timed out waiting for MCP roots/list_changed; using cwd fallback`,{cwd:process.cwd()}),e(!1)},5e3);f.server.setNotificationHandler(s,async()=>{clearTimeout(t);try{e(y((await f.server.listRoots()).roots))}catch(t){p.warn(`roots/list retry failed after notification`,l(t)),e(!1)}})}),m();let x=null,S=()=>{x&&clearTimeout(x),x=setTimeout(async()=>{p.info(`Auto-shutdown: no activity for 30 minutes — shutting down gracefully`);try{let e=d.aikit;e&&await Promise.all([e.embedder.shutdown?.().catch(()=>{})??Promise.resolve(),e.graphStore.close().catch(()=>{}),e.store.close().catch(()=>{})])}catch{}process.exit(0)},18e5),x.unref&&x.unref()};S(),process.stdin.on(`data`,()=>S()),h.catch(e=>{p.error(`Initialization failed — server will continue with limited tools`,l(e))}),u===`auto`?g().catch(e=>p.error(`Initial index failed`,l(e))):u===`smart`?h.then(async()=>{try{if(!d.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(d.aikit.indexer,c,d.aikit.store),n=d.aikit.store;t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),d.setSmartScheduler(t),p.info(`Smart index scheduler started (stdio mode)`)}catch(e){p.error(`Failed to start smart index scheduler`,l(e))}}).catch(e=>p.error(`AI Kit init failed for smart scheduler`,l(e))):p.warn(`Initial full indexing skipped; use aikit_reindex to index manually`,{indexMode:u})}}v().catch(e=>{p.error(`Fatal error`,l(e)),process.exit(1)});export{e as CuratedKnowledgeManager};
1
+ import{t as e}from"./curated-manager-BnP6VqvL.js";import{randomUUID as t}from"node:crypto";import{readFileSync as n}from"node:fs";import{dirname as r,resolve as i}from"node:path";import{fileURLToPath as a,pathToFileURL as o}from"node:url";import{parseArgs as s}from"node:util";import{createLogger as c,serializeError as l}from"../../core/dist/index.js";var u=class{stateStore;options;gcTimer=null;constructor(e,t={}){this.stateStore=e,this.options=t}onSessionStart(e,t){this.stateStore.sessionCreate(e,t)}onSessionActivity(e){this.stateStore.sessionTouch(e)}onSessionEnd(e){this.stateStore.sessionDelete(e)}startGC(){if(this.gcTimer)return;let e=(this.options.gcIntervalMinutes??5)*60*1e3;this.gcTimer=setInterval(()=>{this.runGC()},e),this.gcTimer.unref()}runGC(){let e=this.options.staleTimeoutMinutes??30;return this.stateStore.sessionDeleteStale(e)}stop(){this.gcTimer&&=(clearInterval(this.gcTimer),null)}getActiveSessions(){return this.stateStore.sessionList().length}};const d=r(a(import.meta.url)),f=(()=>{try{let e=i(d,`..`,`..`,`..`,`package.json`);return JSON.parse(n(e,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}})(),p=c(`server`);function m(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}const h=(()=>{let e=process.argv[1];if(!e)return!1;try{return import.meta.url===o(e).href}catch{return!1}})();function g(e){let t=e.headers[`mcp-session-id`];return Array.isArray(t)?t[0]:t}const{values:_}=h?s({allowPositionals:!0,options:{transport:{type:`string`,default:m()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}):{values:{transport:m(),port:process.env.AIKIT_PORT??`3210`}};async function v(){if(process.on(`unhandledRejection`,e=>{p.error(`Unhandled rejection`,l(e))}),process.on(`uncaughtException`,e=>{p.error(`Uncaught exception — exiting`,l(e)),process.exit(1)}),p.info(`Starting MCP AI Kit server`,{version:f}),_.transport===`http`){let[{default:e},{loadConfig:n,resolveIndexMode:r},{registerDashboardRoutes:i,resolveDashboardDir:a},{registerSettingsRoutes:o,resolveSettingsDir:s},{createSettingsRouter:c},{authMiddleware:d,getOrCreateToken:f}]=await Promise.all([import(`express`),import(`./config-DAnAxrUW.js`),import(`./dashboard-static-CnXafYTs.js`),import(`./settings-static-BkVLqWOr.js`),import(`./routes-CR3fI-HJ.js`),import(`./auth-BfqgawfR.js`).then(e=>e.t)]),m=n();p.info(`Config loaded`,{sourceCount:m.sources.length,storePath:m.store.path});let h=e();h.use(e.json());let v=Number(_.port);h.use((e,t,n)=>{if(t.setHeader(`Access-Control-Allow-Origin`,process.env.AIKIT_CORS_ORIGIN??`http://localhost:${v}`),t.setHeader(`Access-Control-Allow-Methods`,`GET, POST, PUT, PATCH, DELETE, OPTIONS`),t.setHeader(`Access-Control-Allow-Headers`,`Content-Type, Authorization, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID`),t.setHeader(`Access-Control-Expose-Headers`,`Mcp-Session-Id`),e.method===`OPTIONS`){t.status(204).end();return}n()});let y=f();console.error(`[aikit] Auth token: ~/.aikit/token`),h.use(d(y)),i(h,a(),p);let b=new Date().toISOString();h.use(`/settings/api`,c({log:p,mcpInfo:()=>({transport:`http`,port:v,pid:process.pid,startedAt:b})})),o(h,s(),p),h.get(`/health`,(e,t)=>{t.json({status:`ok`})});let x=!1,S=null,C=null,w=null,T=null,E=null,D=null,O=Promise.resolve(),k=async(e,n)=>{if(!x||!w||!T){n.status(503).json({jsonrpc:`2.0`,error:{code:-32603,message:`Server initializing — please retry in a few seconds`},id:null});return}let r=O,i;O=new Promise(e=>{i=e}),await r;try{let r=g(e);if(!E){if(r){n.status(404).json({jsonrpc:`2.0`,error:{code:-32001,message:`Session not found`},id:null});return}let e=new T({sessionIdGenerator:()=>t(),onsessioninitialized:async e=>{D=e,C?.onSessionStart(e,{transport:`http`})},onsessionclosed:async e=>{e&&C?.onSessionEnd(e),D=null}});e.onclose=()=>{E===e&&(E=null),D===e.sessionId&&(D=null)},E=e,await w.connect(e)}let i=E;await i.handleRequest(e,n,e.body),e.method!==`DELETE`&&(!r&&i.sessionId?(D=i.sessionId,C?.onSessionStart(i.sessionId,{transport:`http`}),C?.onSessionActivity(i.sessionId)):r&&C?.onSessionActivity(r))}catch(e){if(p.error(`MCP handler error`,l(e)),!n.headersSent){let t=e instanceof Error?e.message:String(e),r=t.includes(`Not Acceptable`);n.status(r?406:500).json({jsonrpc:`2.0`,error:{code:r?-32e3:-32603,message:r?t:`Internal server error`},id:null})}}finally{i()}};h.post(`/mcp`,k),h.get(`/mcp`,k),h.delete(`/mcp`,k);let A=h.listen(v,`127.0.0.1`,()=>{p.info(`MCP server listening`,{url:`http://127.0.0.1:${v}/mcp`,port:v}),setTimeout(async()=>{try{let[{createLazyServer:e,ALL_TOOL_NAMES:t},{StreamableHTTPServerTransport:n},{checkForUpdates:i,autoUpgradeScaffold:a}]=await Promise.all([import(`./server-TZDCpgEd.js`),import(`@modelcontextprotocol/sdk/server/streamableHttp.js`),import(`./version-check-BgHzxxCW.js`)]);i(),a();let o=r(m),s=e(m,o);w=s.server,T=n,x=!0,p.info(`MCP server configured (lazy — AI Kit initializing in background)`,{toolCount:t.length,resourceCount:2}),s.startInit(),s.ready.then(()=>{if(!s.aikit)throw Error(`AI Kit components are not available after initialization`);C=new u(s.aikit.stateStore),C.startGC(),D&&(C.onSessionStart(D,{transport:`http`}),C.onSessionActivity(D))}).catch(e=>p.error(`Failed to start session manager`,l(e))),o===`auto`?s.ready.then(async()=>{try{let e=m.sources.map(e=>e.path).join(`, `);p.info(`Running initial index`,{sourcePaths:e}),await s.runInitialIndex(),p.info(`Initial index complete`)}catch(e){p.error(`Initial index failed; will retry on aikit_reindex`,l(e))}}).catch(e=>p.error(`AI Kit init or indexing failed`,l(e))):o===`smart`?s.ready.then(async()=>{try{if(!s.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(s.aikit.indexer,m,s.aikit.store),n=s.aikit.store;S=t,t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),s.setSmartScheduler(t),p.info(`Smart index scheduler started (HTTP mode)`)}catch(e){p.error(`Failed to start smart index scheduler`,l(e))}}).catch(e=>p.error(`AI Kit initialization failed`,l(e))):(s.ready.catch(e=>p.error(`AI Kit initialization failed`,l(e))),p.info(`Initial full indexing skipped in HTTP mode`,{indexMode:o}))}catch(e){p.error(`Failed to load server modules`,l(e))}},100)}),j=async e=>{p.info(`Shutdown signal received`,{signal:e}),S?.stop(),C?.stop(),D&&C?.onSessionEnd(D),E&&(await E.close().catch(()=>void 0),E=null,D=null),A.close(),w&&await w.close(),process.exit(0)};process.on(`SIGINT`,()=>j(`SIGINT`)),process.on(`SIGTERM`,()=>j(`SIGTERM`))}else{let[{loadConfig:e,reconfigureForWorkspace:t,resolveIndexMode:n},{createLazyServer:r},{checkForUpdates:i,autoUpgradeScaffold:o},{RootsListChangedNotificationSchema:s}]=await Promise.all([import(`./config-DAnAxrUW.js`),import(`./server-TZDCpgEd.js`),import(`./version-check-BgHzxxCW.js`),import(`@modelcontextprotocol/sdk/types.js`)]),c=e();p.info(`Config loaded`,{sourceCount:c.sources.length,storePath:c.store.path}),i(),o();let u=n(c),d=r(c,u),{server:f,startInit:m,ready:h,runInitialIndex:g}=d,{StdioServerTransport:_}=await import(`@modelcontextprotocol/sdk/server/stdio.js`),v=new _;await f.connect(v),p.info(`MCP server started`,{transport:`stdio`});let y=e=>{if(e.length===0)return!1;let n=e[0].uri,r=n.startsWith(`file://`)?a(n):n;return p.info(`MCP roots resolved`,{rootUri:n,rootPath:r,rootCount:e.length}),t(c,r),c.allRoots=e.map(e=>{let t=e.uri;return t.startsWith(`file://`)?a(t):t}),!0},b=!1;try{b=y((await f.server.listRoots()).roots),b||p.info(`No MCP roots yet; waiting for roots/list_changed notification`)}catch(e){p.warn(`MCP roots/list not supported by client; using cwd fallback`,{cwd:process.cwd(),...l(e)}),b=!0}b||=await new Promise(e=>{let t=setTimeout(()=>{p.warn(`Timed out waiting for MCP roots/list_changed; using cwd fallback`,{cwd:process.cwd()}),e(!1)},5e3);f.server.setNotificationHandler(s,async()=>{clearTimeout(t);try{e(y((await f.server.listRoots()).roots))}catch(t){p.warn(`roots/list retry failed after notification`,l(t)),e(!1)}})}),m();let x=null,S=()=>{x&&clearTimeout(x),x=setTimeout(async()=>{p.info(`Auto-shutdown: no activity for 30 minutes — shutting down gracefully`);try{let e=d.aikit;e&&await Promise.all([e.embedder.shutdown?.().catch(()=>{})??Promise.resolve(),e.graphStore.close().catch(()=>{}),e.store.close().catch(()=>{})])}catch{}process.exit(0)},18e5),x.unref&&x.unref()};S(),process.stdin.on(`data`,()=>S()),h.catch(e=>{p.error(`Initialization failed — server will continue with limited tools`,l(e))}),u===`auto`?g().catch(e=>p.error(`Initial index failed`,l(e))):u===`smart`?h.then(async()=>{try{if(!d.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(d.aikit.indexer,c,d.aikit.store),n=d.aikit.store;t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),d.setSmartScheduler(t),p.info(`Smart index scheduler started (stdio mode)`)}catch(e){p.error(`Failed to start smart index scheduler`,l(e))}}).catch(e=>p.error(`AI Kit init failed for smart scheduler`,l(e))):p.warn(`Initial full indexing skipped; use aikit_reindex to index manually`,{indexMode:u})}}v().catch(e=>{p.error(`Fatal error`,l(e)),process.exit(1)});export{e as CuratedKnowledgeManager};
@@ -2635,7 +2635,7 @@ Complements: \`symbol\` (single lookup), \`trace\` (call-chain AST), \`blast_rad
2635
2635
  }
2636
2636
  mermaid.initialize({ startOnLoad: false, theme: theme });
2637
2637
  mermaid.run();
2638
- };`,onload:`window.__aikit_initMermaid&&window.__aikit_initMermaid()`,local:{route:`/vendor/mermaid.min.js`,getSource:Wd()}},Kd=new Map([[`mermaid`,Gd]]);function qd(e,t){if(!e?.length)return;let n=[];for(let r of e){let e=Kd.get(r);if(e){if(t===`browser`){n.push({inlineSource:e.inlineSource});continue}if(t===`mcp-app`){n.push({inlineSource:e.inlineSource});continue}n.push({src:e.cdn,initScript:e.initScript,onload:e.onload})}}return n.length>0?n:void 0}function Jd(){let e=[];for(let t of Kd.values())t.local&&e.push({route:t.local.route,getSource:t.local.getSource,cdn:t.cdn});return e}const Yd=300*1e3;let X=null;process.on(`exit`,()=>{let e=X;if(e){try{e.close()}catch{}X=null}});function Xd(e){let t=typeof e.description==`string`&&e.description.trim().length>0?`<p class="present-surface-description">${J(e.description)}</p>`:``;return[`<h1 class="present-surface-title">${J(e.title)}</h1>`,t].filter(Boolean).join(`
2638
+ };`,onload:`window.__aikit_initMermaid&&window.__aikit_initMermaid()`,local:{route:`/vendor/mermaid.min.js`,getSource:Wd()}},Kd=new Map([[`mermaid`,Gd]]);function qd(e,t){if(!e?.length)return;let n=[];for(let r of e){let e=Kd.get(r);if(e){if(t===`browser`){n.push({inlineSource:e.inlineSource,onload:e.onload});continue}if(t===`mcp-app`){n.push({inlineSource:e.inlineSource,onload:e.onload});continue}n.push({src:e.cdn,initScript:e.initScript,onload:e.onload})}}return n.length>0?n:void 0}function Jd(){let e=[];for(let t of Kd.values())t.local&&e.push({route:t.local.route,getSource:t.local.getSource,cdn:t.cdn});return e}const Yd=300*1e3;let X=null;process.on(`exit`,()=>{let e=X;if(e){try{e.close()}catch{}X=null}});function Xd(e){let t=typeof e.description==`string`&&e.description.trim().length>0?`<p class="present-surface-description">${J(e.description)}</p>`:``;return[`<h1 class="present-surface-title">${J(e.title)}</h1>`,t].filter(Boolean).join(`
2639
2639
  `)}function Zd(e,t){return e.length===0?``:`
2640
2640
  <section class="present-surface-actions">
2641
2641
  <div class="present-action-bar">${e.map(e=>{let t=J(e.id),n=J(e.label);return e.type===`select`||e.type===`multi-select`?`<label class="present-action-field"><span>${n}</span><select data-action-id="${t}"${e.type===`multi-select`?` multiple`:``}>${(e.options??[]).map(e=>`<option value="${J(e.value)}">${J(e.label)}</option>`).join(``)}</select></label>`:`<button type="button" class="present-action-btn present-action-${J(e.variant??`default`)}" data-action-id="${t}" data-action-label="${n}">${n}</button>`}).join(``)}</div>