@vpxa/aikit 0.1.378 → 0.1.380

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/package.json +1 -1
  2. package/packages/claude-desktop/dist/manifest.json +1 -1
  3. package/packages/cli/dist/index.js +3 -3
  4. package/packages/cli/dist/{init-gDbVIWiP.js → init-BTsNYC02.js} +1 -1
  5. package/packages/cli/dist/{templates-BPC4t5yz.js → templates-CRs_gkfS.js} +13 -12
  6. package/packages/core/dist/index.d.ts +30 -10
  7. package/packages/core/dist/index.js +1 -1
  8. package/packages/server/dist/bin.js +1 -1
  9. package/packages/server/dist/config-Bz8Uyzuq.js +2 -0
  10. package/packages/server/dist/config-DZskEKrY.js +1 -0
  11. package/packages/server/dist/dashboard-static-NghHzTNh.js +1 -0
  12. package/packages/server/dist/dashboard-static-gAOiHHqI.js +2 -0
  13. package/packages/server/dist/index.js +1 -1
  14. package/packages/server/dist/register-tools-Dgu64Px5.js +3034 -0
  15. package/packages/server/dist/register-tools-jgdif5r4.js +3035 -0
  16. package/packages/server/dist/server-BmVdf84Q.js +26 -0
  17. package/packages/server/dist/server-C43D7SrT.js +27 -0
  18. package/packages/server/dist/server-http-BCpGwi0k.js +1 -0
  19. package/packages/server/dist/server-http-YQ9jxThI.js +2 -0
  20. package/packages/server/dist/server-stdio-3hhuJU8B.js +2 -0
  21. package/packages/server/dist/server-stdio-CuLAgQjc.js +1 -0
  22. package/packages/server/dist/settings-static-DcTUiqr7.js +1 -0
  23. package/packages/server/dist/settings-static-PjpMR9Q7.js +2 -0
  24. package/packages/server/dist/startup-maintenance-B4xWqEjc.js +20 -0
  25. package/packages/server/dist/startup-maintenance-BnTozHs1.js +21 -0
  26. package/packages/tools/dist/index.d.ts +135 -203
  27. package/packages/tools/dist/index.js +129 -120
  28. package/scaffold/dist/adapters/_shared.mjs +12 -11
  29. package/scaffold/dist/adapters/claude-code.mjs +7 -7
  30. package/scaffold/dist/adapters/copilot.mjs +12 -12
  31. package/scaffold/dist/adapters/hermes.mjs +1 -1
  32. package/scaffold/dist/definitions/bodies.mjs +1 -1
  33. package/scaffold/dist/definitions/protocols.mjs +1 -1
  34. package/scaffold/dist/definitions/skills/present.mjs +8 -5
  35. package/scaffold/dist/definitions/tools.mjs +1 -1
  36. package/scaffold/general/hooks/scripts/__tests__/bash-guard.test.mjs +214 -0
  37. package/scaffold/general/hooks/scripts/__tests__/read-size-guard.test.mjs +183 -0
  38. package/scaffold/general/hooks/scripts/bash-guard.mjs +6 -0
  39. package/packages/server/dist/config-B4klhHVp.js +0 -2
  40. package/packages/server/dist/config-D3rRPB9X.js +0 -1
  41. package/packages/server/dist/dashboard-static-Dw7Nsq4f.js +0 -1
  42. package/packages/server/dist/dashboard-static-dPnij4uF.js +0 -2
  43. package/packages/server/dist/evolution-BX_zTSdj.js +0 -2
  44. package/packages/server/dist/evolution-DWaEE6XW.js +0 -3
  45. package/packages/server/dist/prelude-C4z3H1li.js +0 -1
  46. package/packages/server/dist/prelude-WsqQzR-u.js +0 -2
  47. package/packages/server/dist/promotion-DRnRfteq.js +0 -3
  48. package/packages/server/dist/promotion-DzVLWVtx.js +0 -2
  49. package/packages/server/dist/repair-json-B6Q_HRoP.js +0 -3
  50. package/packages/server/dist/repair-json-D4mft_HA.js +0 -4
  51. package/packages/server/dist/resolve-sibling-BmZ7AxaA.js +0 -1
  52. package/packages/server/dist/resolve-sibling-DrGKPpb0.js +0 -2
  53. package/packages/server/dist/rolldown-runtime-yuFVEuWy.js +0 -2
  54. package/packages/server/dist/sampling-Bpwc-4Jr.js +0 -2
  55. package/packages/server/dist/sampling-CfLD3fM_.js +0 -1
  56. package/packages/server/dist/server-D2a5Rjgk.js +0 -3084
  57. package/packages/server/dist/server-http-B841uX1k.js +0 -2
  58. package/packages/server/dist/server-http-tZxvg5ke.js +0 -1
  59. package/packages/server/dist/server-jZ_r6xLb.js +0 -3083
  60. package/packages/server/dist/server-stdio-B22xZT0d.js +0 -2
  61. package/packages/server/dist/server-stdio-DpGfc6DI.js +0 -1
  62. package/packages/server/dist/settings-static-BpQgaMRs.js +0 -1
  63. package/packages/server/dist/settings-static-MepJZjer.js +0 -2
  64. package/packages/server/dist/startup-maintenance-BPrX5-1U.js +0 -2
  65. package/packages/server/dist/startup-maintenance-CT6Z3734.js +0 -1
  66. package/packages/server/dist/supersession-CWEne3av.js +0 -2
  67. package/packages/server/dist/supersession-DO_ZROFl.js +0 -3
  68. package/packages/server/dist/version-check-C7xqQr9o.js +0 -1
  69. package/packages/server/dist/version-check-CH5SIhnq.js +0 -2
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{r as e}from"./bin.js";import{n as t,t as n}from"./startup-maintenance-BPrX5-1U.js";import{t as r}from"./repair-json-D4mft_HA.js";import{createLogger as i,serializeError as a,setDetailedErrorLoggingEnabled as o}from"../../core/dist/index.js";const s=i(`server`);var c=class{buffer;append(e){this.buffer=this.buffer?Buffer.concat([this.buffer,e]):e}readMessage(){if(!this.buffer)return null;for(let e=0;e<this.buffer.length;e++){if(this.buffer[e]!==10)continue;let t=this.buffer.toString(`utf8`,0,e).replace(/\r$/,``),n=e+1;try{let e=JSON.parse(t);return this.buffer=this.buffer.subarray(n),e}catch{try{let e=r(t);return s.warn(`JSON parse failed on MCP message — repair succeeded`,{preview:t.slice(0,80)}),this.buffer=this.buffer.subarray(n),e}catch{}}}return null}clear(){this.buffer=void 0}};async function l(r){let[{loadConfig:i,reconfigureForWorkspace:l,resolveIndexMode:u},{createLazyServer:d},{checkForUpdates:f,autoUpgradeScaffold:p},{RootsListChangedNotificationSchema:m}]=await Promise.all([import(`./config-B4klhHVp.js`),import(`./server-D2a5Rjgk.js`),import(`./version-check-CH5SIhnq.js`),import(`@modelcontextprotocol/sdk/types.js`)]),h=i();o(h.logging?.errorDetails===!0),h.configError&&s.warn(`Config load failure`,{error:h.configError}),s.info(`Config loaded`,{sourceCount:h.sources.length,storePath:h.store.path}),p(),setInterval(f,1440*60*1e3).unref();let g=u(h),_=d(h,g),{server:v,startInit:y,ready:b,runInitialIndex:x}=_,{StdioServerTransport:S}=await import(`@modelcontextprotocol/sdk/server/stdio.js`),C=new S;if(typeof C._readBuffer?.readMessage!=`function`)throw Error(`Cannot install JSON repair: StdioServerTransport._readBuffer has unexpected shape`);C._readBuffer=new c,s.debug(`JSON repair installed on stdio transport`),await v.connect(C),s.debug(`MCP server started`,{transport:`stdio`}),await e({config:h,indexMode:g,log:s,rootsChangedNotificationSchema:m,reconfigureForWorkspace:l,runInitialIndex:x,server:v,startInit:y,version:r});let w=null,T=null,E=!1,D=async e=>{E||(E=!0,s.info(`Shutdown signal received`,{signal:e}),w&&=(clearTimeout(w),null),T?.stop(),await import(`../../tools/dist/index.js`).then(({processStopAll:e})=>e()).catch(()=>{}),await C.close().catch(()=>void 0),await v.close().catch(()=>void 0),_.aikit&&await Promise.all([_.aikit.embedder.shutdown?.().catch(()=>{})??Promise.resolve(),_.aikit.graphStore.close().catch(()=>{}),_.aikit.closeStateStore?.().catch(()=>{})??Promise.resolve(),_.aikit.store.close().catch(()=>{})]),process.exit(0))},O=()=>{w&&clearTimeout(w),w=setTimeout(async()=>{s.info(`Auto-shutdown: no activity for 30 minutes — releasing resources`);try{let e=_.aikit;e&&(e.embedder.shutdown?.().catch(()=>{}),e.store.releaseMemory?.(),e.graphStore.releaseMemory?.())}catch(e){s.warn(`Resource release failed during shutdown`,a(e))}},18e5),w.unref&&w.unref()};O(),process.stdin.on(`data`,()=>O()),process.stdin.on(`end`,()=>void D(`stdin-end`)),process.stdin.on(`close`,()=>void D(`stdin-close`)),process.stdin.on(`error`,()=>void D(`stdin-error`)),process.on(`SIGINT`,()=>void D(`SIGINT`)),process.on(`SIGTERM`,()=>void D(`SIGTERM`)),b.catch(e=>{s.error(`Initialization failed — server will continue with limited tools`,t(r,e))}),g===`smart`?b.then(async()=>{try{if(!_.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(_.aikit.indexer,h,_.aikit.store);T=t;let n=_.aikit.store;t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),_.setSmartScheduler(t),s.debug(`Smart index scheduler started (stdio mode)`)}catch(e){s.error(`Failed to start smart index scheduler`,t(r,e))}}).catch(e=>s.error(`AI Kit init failed for smart scheduler`,t(r,e))):s.warn(`Initial full indexing skipped; use aikit_reindex to index manually`,{indexMode:g}),n(b,()=>_.aikit?{curated:_.aikit.curated,stateStore:_.aikit.stateStore}:null,r)}export{l as startStdioMode};
@@ -1 +0,0 @@
1
- import{n as e}from"./workspace-bootstrap-DTnTU8p2.js";import{n as t,t as n}from"./startup-maintenance-CT6Z3734.js";import{t as r}from"./repair-json-B6Q_HRoP.js";import{createLogger as i,serializeError as a,setDetailedErrorLoggingEnabled as o}from"../../core/dist/index.js";const s=i(`server`);var c=class{buffer;append(e){this.buffer=this.buffer?Buffer.concat([this.buffer,e]):e}readMessage(){if(!this.buffer)return null;for(let e=0;e<this.buffer.length;e++){if(this.buffer[e]!==10)continue;let t=this.buffer.toString(`utf8`,0,e).replace(/\r$/,``),n=e+1;try{let e=JSON.parse(t);return this.buffer=this.buffer.subarray(n),e}catch{try{let e=r(t);return s.warn(`JSON parse failed on MCP message — repair succeeded`,{preview:t.slice(0,80)}),this.buffer=this.buffer.subarray(n),e}catch{}}}return null}clear(){this.buffer=void 0}};async function l(r){let[{loadConfig:i,reconfigureForWorkspace:l,resolveIndexMode:u},{createLazyServer:d},{checkForUpdates:f,autoUpgradeScaffold:p},{RootsListChangedNotificationSchema:m}]=await Promise.all([import(`./config-D3rRPB9X.js`),import(`./server-jZ_r6xLb.js`),import(`./version-check-C7xqQr9o.js`),import(`@modelcontextprotocol/sdk/types.js`)]),h=i();o(h.logging?.errorDetails===!0),h.configError&&s.warn(`Config load failure`,{error:h.configError}),s.info(`Config loaded`,{sourceCount:h.sources.length,storePath:h.store.path}),p(),setInterval(f,1440*60*1e3).unref();let g=u(h),_=d(h,g),{server:v,startInit:y,ready:b,runInitialIndex:x}=_,{StdioServerTransport:S}=await import(`@modelcontextprotocol/sdk/server/stdio.js`),C=new S;if(typeof C._readBuffer?.readMessage!=`function`)throw Error(`Cannot install JSON repair: StdioServerTransport._readBuffer has unexpected shape`);C._readBuffer=new c,s.debug(`JSON repair installed on stdio transport`),await v.connect(C),s.debug(`MCP server started`,{transport:`stdio`}),await e({config:h,indexMode:g,log:s,rootsChangedNotificationSchema:m,reconfigureForWorkspace:l,runInitialIndex:x,server:v,startInit:y,version:r});let w=null,T=null,E=!1,D=async e=>{E||(E=!0,s.info(`Shutdown signal received`,{signal:e}),w&&=(clearTimeout(w),null),T?.stop(),await import(`../../tools/dist/index.js`).then(({processStopAll:e})=>e()).catch(()=>{}),await C.close().catch(()=>void 0),await v.close().catch(()=>void 0),_.aikit&&await Promise.all([_.aikit.embedder.shutdown?.().catch(()=>{})??Promise.resolve(),_.aikit.graphStore.close().catch(()=>{}),_.aikit.closeStateStore?.().catch(()=>{})??Promise.resolve(),_.aikit.store.close().catch(()=>{})]),process.exit(0))},O=()=>{w&&clearTimeout(w),w=setTimeout(async()=>{s.info(`Auto-shutdown: no activity for 30 minutes — releasing resources`);try{let e=_.aikit;e&&(e.embedder.shutdown?.().catch(()=>{}),e.store.releaseMemory?.(),e.graphStore.releaseMemory?.())}catch(e){s.warn(`Resource release failed during shutdown`,a(e))}},18e5),w.unref&&w.unref()};O(),process.stdin.on(`data`,()=>O()),process.stdin.on(`end`,()=>void D(`stdin-end`)),process.stdin.on(`close`,()=>void D(`stdin-close`)),process.stdin.on(`error`,()=>void D(`stdin-error`)),process.on(`SIGINT`,()=>void D(`SIGINT`)),process.on(`SIGTERM`,()=>void D(`SIGTERM`)),b.catch(e=>{s.error(`Initialization failed — server will continue with limited tools`,t(r,e))}),g===`smart`?b.then(async()=>{try{if(!_.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(_.aikit.indexer,h,_.aikit.store);T=t;let n=_.aikit.store;t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),_.setSmartScheduler(t),s.debug(`Smart index scheduler started (stdio mode)`)}catch(e){s.error(`Failed to start smart index scheduler`,t(r,e))}}).catch(e=>s.error(`AI Kit init failed for smart scheduler`,t(r,e))):s.warn(`Initial full indexing skipped; use aikit_reindex to index manually`,{indexMode:g}),n(b,()=>_.aikit?{curated:_.aikit.curated,stateStore:_.aikit.stateStore}:null,r)}export{l as startStdioMode};
@@ -1 +0,0 @@
1
- import{t as e}from"./resolve-sibling-BmZ7AxaA.js";import{fileURLToPath as t}from"node:url";import{createReadStream as n,existsSync as r,statSync as i}from"node:fs";import{dirname as a,extname as o,join as s,resolve as c,sep as l}from"node:path";const u=import.meta.dirname??a(t(import.meta.url)),d={".html":`text/html`,".js":`application/javascript`,".css":`text/css`,".json":`application/json`,".png":`image/png`,".svg":`image/svg+xml`,".ico":`image/x-icon`,".woff":`font/woff`,".woff2":`font/woff2`};function f(t){return t?s(t,`..`,`..`,`settings-ui`,`dist`):e(`settings-ui`)??s(u,`..`,`..`,`settings-ui`,`dist`)}function p(e,t){let n=t.replace(/^\/settings\/?/,``)||`index.html`;if(n.startsWith(`api/`)||n===`api`)return{kind:`not-found`};try{n=decodeURIComponent(n)}catch{}let a=c(e,n);if(!(a===e||a.startsWith(`${e}${l}`)))return{kind:`forbidden`};try{if(i(a).isFile())return{kind:`file`,path:a,contentType:d[o(a)]??`application/octet-stream`}}catch{}let u=s(e,`index.html`);return r(u)?{kind:`spa`,path:u,contentType:`text/html`}:{kind:`not-found`}}function m(e,t,i){return r(t)?(e.get(`/settings{/*path}`,(e,r)=>{let i=p(t,e.path);if(i.kind===`forbidden`){r.status(403).end(`Forbidden`);return}if(i.kind===`not-found`){r.status(404).end(`Not found`);return}r.setHeader(`Content-Type`,i.contentType),i.kind===`file`&&/\.[a-f0-9]{8,}\.(js|css)$/i.test(i.path)?r.setHeader(`Cache-Control`,`public, max-age=31536000, immutable`):r.setHeader(`Cache-Control`,`no-cache`),n(i.path).pipe(r)}),i.info(`Settings UI available`,{url:`/settings/`,dir:t}),!0):!1}export{m as registerSettingsRoutes,f as resolveSettingsDir,p as resolveSettingsRequest};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{t as e}from"./resolve-sibling-DrGKPpb0.js";import{fileURLToPath as t}from"node:url";import{createReadStream as n,existsSync as r,statSync as i}from"node:fs";import{dirname as a,extname as o,join as s,resolve as c,sep as l}from"node:path";const u=import.meta.dirname??a(t(import.meta.url)),d={".html":`text/html`,".js":`application/javascript`,".css":`text/css`,".json":`application/json`,".png":`image/png`,".svg":`image/svg+xml`,".ico":`image/x-icon`,".woff":`font/woff`,".woff2":`font/woff2`};function f(t){return t?s(t,`..`,`..`,`settings-ui`,`dist`):e(`settings-ui`)??s(u,`..`,`..`,`settings-ui`,`dist`)}function p(e,t){let n=t.replace(/^\/settings\/?/,``)||`index.html`;if(n.startsWith(`api/`)||n===`api`)return{kind:`not-found`};try{n=decodeURIComponent(n)}catch{}let a=c(e,n);if(!(a===e||a.startsWith(`${e}${l}`)))return{kind:`forbidden`};try{if(i(a).isFile())return{kind:`file`,path:a,contentType:d[o(a)]??`application/octet-stream`}}catch{}let u=s(e,`index.html`);return r(u)?{kind:`spa`,path:u,contentType:`text/html`}:{kind:`not-found`}}function m(e,t,i){return r(t)?(e.get(`/settings{/*path}`,(e,r)=>{let i=p(t,e.path);if(i.kind===`forbidden`){r.status(403).end(`Forbidden`);return}if(i.kind===`not-found`){r.status(404).end(`Not found`);return}r.setHeader(`Content-Type`,i.contentType),i.kind===`file`&&/\.[a-f0-9]{8,}\.(js|css)$/i.test(i.path)?r.setHeader(`Cache-Control`,`public, max-age=31536000, immutable`):r.setHeader(`Cache-Control`,`no-cache`),n(i.path).pipe(r)}),i.info(`Settings UI available`,{url:`/settings/`,dir:t}),!0):!1}export{m as registerSettingsRoutes,f as resolveSettingsDir,p as resolveSettingsRequest};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{t as e}from"./bin.js";import{createLogger as t,serializeError as n}from"../../core/dist/index.js";const r=t(`server`);function i(e,t){return t?{version:e,...n(t)}:{version:e}}function a(t,a,o){t.then(async()=>{try{let{markPromoteRun:t,markPruneRun:n,prune:i,shouldRunStartupPrune:o,shouldRunWeeklyPromote:s}=await import(`../../tools/dist/index.js`),c=a();if(!c)return;try{let{readdirSync:e,rmSync:t,statSync:n,existsSync:i}=await import(`node:fs`),{join:a}=await import(`node:path`),{homedir:o}=await import(`node:os`),s=a(o(),`.aikit`,`workspaces`);if(i(s)){let o=Date.now(),c=e(s,{withFileTypes:!0}),l=0;for(let e of c){if(!e.isDirectory())continue;let r=a(s,e.name);try{if(o-n(r).mtimeMs<2592e6)continue;let e=a(r,`store`,`aikit.db`);if(!i(e)){t(r,{recursive:!0,force:!0}),l++;continue}n(e).size<1024&&(t(r,{recursive:!0,force:!0}),l++)}catch{}}l>0&&r.info(`Workspace directory GC complete`,{directoriesRemoved:l,directoriesRemaining:c.length-l})}}catch{}if(o()){let e=await i({});n(),e.totalBytesFreed>0&&r.info(`Storage maintenance complete`,{forgeOrphans:e.forgeGroundOrphans.count,legacyLance:e.legacyLance.count,bytesFreed:e.totalBytesFreed});let{groupLessons:t,pruneLessons:a}=await import(`./evolution-DWaEE6XW.js`).then(e=>e.t),o=await a(c.curated,c.stateStore,{dryRun:!1});o.pruned.length>0&&r.info(`Startup lesson prune complete`,{pruned:o.pruned.length});let s=await t(c.curated,c.stateStore,{dryRun:!1});(s.groupsCreated>0||s.lessonsGrouped>0)&&r.info(`Startup lesson grouping complete`,{groupsCreated:s.groupsCreated,lessonsGrouped:s.lessonsGrouped})}if(s()){let{DEFAULT_PROMOTE_CONFIG:n,collectWorkspaceLessons:i,getGlobalCuratedDir:a,promoteLessons:o,scanForDuplicates:s}=await import(`./promotion-DRnRfteq.js`).then(e=>e.o),l=c.curated,u=new e(a(),l.store,l.embedder),d=await i(),f={...n,dryRun:!1},p=await o(s(d,f),u,f);t(),p.promoted.length>0&&r.info(`Weekly lesson promotion complete`,{promoted:p.promoted.length,candidates:p.candidates.length})}}catch(e){r.warn(`Startup maintenance failed (non-critical)`,i(o,e))}}).catch(e=>r.warn(`Startup maintenance failed`,n(e)))}export{i as n,a as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./curated-manager-CBKTmAjM.js";import{createLogger as t,serializeError as n}from"../../core/dist/index.js";const r=t(`server`);function i(e,t){return t?{version:e,...n(t)}:{version:e}}function a(t,a,o){t.then(async()=>{try{let{markPromoteRun:t,markPruneRun:n,prune:i,shouldRunStartupPrune:o,shouldRunWeeklyPromote:s}=await import(`../../tools/dist/index.js`),c=a();if(!c)return;try{let{readdirSync:e,rmSync:t,statSync:n,existsSync:i}=await import(`node:fs`),{join:a}=await import(`node:path`),{homedir:o}=await import(`node:os`),s=a(o(),`.aikit`,`workspaces`);if(i(s)){let o=Date.now(),c=e(s,{withFileTypes:!0}),l=0;for(let e of c){if(!e.isDirectory())continue;let r=a(s,e.name);try{if(o-n(r).mtimeMs<2592e6)continue;let e=a(r,`store`,`aikit.db`);if(!i(e)){t(r,{recursive:!0,force:!0}),l++;continue}n(e).size<1024&&(t(r,{recursive:!0,force:!0}),l++)}catch{}}l>0&&r.info(`Workspace directory GC complete`,{directoriesRemoved:l,directoriesRemaining:c.length-l})}}catch{}if(o()){let e=await i({});n(),e.totalBytesFreed>0&&r.info(`Storage maintenance complete`,{forgeOrphans:e.forgeGroundOrphans.count,legacyLance:e.legacyLance.count,bytesFreed:e.totalBytesFreed});let{groupLessons:t,pruneLessons:a}=await import(`./evolution-BX_zTSdj.js`).then(e=>e.t),o=await a(c.curated,c.stateStore,{dryRun:!1});o.pruned.length>0&&r.info(`Startup lesson prune complete`,{pruned:o.pruned.length});let s=await t(c.curated,c.stateStore,{dryRun:!1});(s.groupsCreated>0||s.lessonsGrouped>0)&&r.info(`Startup lesson grouping complete`,{groupsCreated:s.groupsCreated,lessonsGrouped:s.lessonsGrouped})}if(s()){let{DEFAULT_PROMOTE_CONFIG:n,collectWorkspaceLessons:i,getGlobalCuratedDir:a,promoteLessons:o,scanForDuplicates:s}=await import(`./promotion-DzVLWVtx.js`).then(e=>e.o),l=c.curated,u=new e(a(),l.store,l.embedder),d=await i(),f={...n,dryRun:!1},p=await o(s(d,f),u,f);t(),p.promoted.length>0&&r.info(`Weekly lesson promotion complete`,{promoted:p.promoted.length,candidates:p.candidates.length})}}catch(e){r.warn(`Startup maintenance failed (non-critical)`,i(o,e))}}).catch(e=>r.warn(`Startup maintenance failed`,n(e)))}export{i as n,a as t};
@@ -1,2 +0,0 @@
1
- const e={confirmIncrement:10,contradictDecrement:20,weeklyDecay:2,implicitUseIncrement:3,staleThreshold:30,staleDays:21,decayFloor:10,autoArchiveDays:30,archiveThreshold:20},t=`lesson:auto-archive`;function n(t){return{confirmIncrement:Math.max(0,Math.trunc(t?.confirmIncrement??e.confirmIncrement)),contradictDecrement:Math.max(0,Math.trunc(t?.contradictDecrement??e.contradictDecrement)),weeklyDecay:Math.max(0,Math.trunc(t?.weeklyDecay??e.weeklyDecay)),implicitUseIncrement:Math.max(0,Math.trunc(t?.implicitUseIncrement??e.implicitUseIncrement)),staleThreshold:Math.min(100,Math.max(0,Math.trunc(t?.staleThreshold??e.staleThreshold))),staleDays:Math.max(1,Math.trunc(t?.staleDays??e.staleDays)),decayFloor:Math.min(100,Math.max(0,Math.trunc(t?.decayFloor??e.decayFloor))),autoArchiveDays:Math.max(1,Math.trunc(t?.autoArchiveDays??e.autoArchiveDays)),archiveThreshold:Math.min(100,Math.max(0,Math.trunc(t?.archiveThreshold??e.archiveThreshold)))}}function r(e){return[`## Lesson: ${e.title}`,``,`**Confidence:** ${e.confidence}/100`,``,`### Context`,e.context,``,`### Insight`,e.insight,``,`### Evidence`,e.evidence].join(`
2
- `)}function i(e){let t=e.match(/^## Lesson:\s+(.+)$/m),n=e.match(/\*\*Confidence:\*\*\s+(\d+)\/100/),r=e.match(/### Context\r?\n([\s\S]*?)(?=\r?\n### |$)/),i=e.match(/### Insight\r?\n([\s\S]*?)(?=\r?\n### |$)/),a=e.match(/### Evidence\r?\n([\s\S]*?)(?=\r?\n### |$)/);return{title:t?.[1]?.trim(),confidence:n?Number(n[1]):void 0,context:r?.[1]?.trim(),insight:i?.[1]?.trim(),evidence:a?.[1]?.trim()}}function a(e,t){let n=Math.min(100,Math.max(0,Math.trunc(t)));return/\*\*Confidence:\*\*/.test(e)?e.replace(/\*\*Confidence:\*\*\s+\d+\/100/,`**Confidence:** ${n}/100`):e.match(/^(## Lesson:[^\r\n]*)(\r?\n)/)?e.replace(/^(## Lesson:[^\r\n]*)(\r?\n)/,`$1$2$2**Confidence:** ${n}/100$2$2`):`**Confidence:** ${n}/100\n\n${e}`}function o(t,r,i=e){let a=n(i);return r===`confirm`?Math.min(100,t+a.confirmIncrement):Math.max(0,t-a.contradictDecrement)}function s(t,r,i,a=e,o=Date.now()){let s=n(a),c=!!r,l=r?new Date(r):new Date(i),u=Math.max(0,o-l.getTime());c||(u=Math.min(u,336*60*60*1e3));let d=u/(10080*60*1e3),f=Math.floor(d)*s.weeklyDecay;return Math.max(s.decayFloor,t-f)}function c(t,r=e,i=Date.now()){let a=n(r);if(s(t.confidence,t.lastAccessedAt,t.createdAt,r,i)>=a.staleThreshold)return!1;let o=t.lastAccessedAt?new Date(t.lastAccessedAt):new Date(t.createdAt);return Math.max(0,i-o.getTime())/(1e3*60*60*24)>=a.staleDays}function l(t,r=e,i=Date.now()){let a=n(r);if(s(t.confidence,t.lastAccessedAt,t.createdAt,r,i)>=a.archiveThreshold)return!1;let o=t.lastAccessedAt?new Date(t.lastAccessedAt):new Date(t.createdAt);return Math.max(0,i-o.getTime())/(1e3*60*60*24)>=a.autoArchiveDays}const u={threshold:.7,maxCompare:50,autoThreshold:.95};function d(e){let t=Math.min(1,Math.max(0,e?.threshold??u.threshold)),n=Math.min(1,Math.max(t,e?.autoThreshold??u.autoThreshold));return{threshold:t,maxCompare:Math.max(1,Math.trunc(e?.maxCompare??u.maxCompare)),autoThreshold:n}}function f(e){let t=e.toLowerCase().match(/[a-z0-9]{2,}/g)??[];return new Set(t)}function p(e,t){let n=f(e),r=f(t);if(n.size===0&&r.size===0)return 1;if(n.size===0||r.size===0)return 0;let i=new Set([...n].filter(e=>r.has(e))),a=new Set([...n,...r]);return i.size/a.size}function m(e,t,n=u){let r=d(n);return t.slice(0,r.maxCompare).map(t=>({entryId:t.id,title:t.title,similarity:p(e,t.content),path:t.path})).filter(e=>e.similarity>=r.threshold).sort((e,t)=>t.similarity-e.similarity)}function h(e,t,n){e.memoryMetaCreate(t),e.memoryMetaSetSuperseded(t,n)}export{d as a,o as c,c as d,i as f,l as h,h as i,s as l,a as m,m as n,e as o,n as p,p as r,t as s,u as t,r as u};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- const e={confirmIncrement:10,contradictDecrement:20,weeklyDecay:2,implicitUseIncrement:3,staleThreshold:30,staleDays:21,decayFloor:10,autoArchiveDays:30,archiveThreshold:20},t=`lesson:auto-archive`;function n(t){return{confirmIncrement:Math.max(0,Math.trunc(t?.confirmIncrement??e.confirmIncrement)),contradictDecrement:Math.max(0,Math.trunc(t?.contradictDecrement??e.contradictDecrement)),weeklyDecay:Math.max(0,Math.trunc(t?.weeklyDecay??e.weeklyDecay)),implicitUseIncrement:Math.max(0,Math.trunc(t?.implicitUseIncrement??e.implicitUseIncrement)),staleThreshold:Math.min(100,Math.max(0,Math.trunc(t?.staleThreshold??e.staleThreshold))),staleDays:Math.max(1,Math.trunc(t?.staleDays??e.staleDays)),decayFloor:Math.min(100,Math.max(0,Math.trunc(t?.decayFloor??e.decayFloor))),autoArchiveDays:Math.max(1,Math.trunc(t?.autoArchiveDays??e.autoArchiveDays)),archiveThreshold:Math.min(100,Math.max(0,Math.trunc(t?.archiveThreshold??e.archiveThreshold)))}}function r(e){return[`## Lesson: ${e.title}`,``,`**Confidence:** ${e.confidence}/100`,``,`### Context`,e.context,``,`### Insight`,e.insight,``,`### Evidence`,e.evidence].join(`
3
- `)}function i(e){let t=e.match(/^## Lesson:\s+(.+)$/m),n=e.match(/\*\*Confidence:\*\*\s+(\d+)\/100/),r=e.match(/### Context\r?\n([\s\S]*?)(?=\r?\n### |$)/),i=e.match(/### Insight\r?\n([\s\S]*?)(?=\r?\n### |$)/),a=e.match(/### Evidence\r?\n([\s\S]*?)(?=\r?\n### |$)/);return{title:t?.[1]?.trim(),confidence:n?Number(n[1]):void 0,context:r?.[1]?.trim(),insight:i?.[1]?.trim(),evidence:a?.[1]?.trim()}}function a(e,t){let n=Math.min(100,Math.max(0,Math.trunc(t)));return/\*\*Confidence:\*\*/.test(e)?e.replace(/\*\*Confidence:\*\*\s+\d+\/100/,`**Confidence:** ${n}/100`):e.match(/^(## Lesson:[^\r\n]*)(\r?\n)/)?e.replace(/^(## Lesson:[^\r\n]*)(\r?\n)/,`$1$2$2**Confidence:** ${n}/100$2$2`):`**Confidence:** ${n}/100\n\n${e}`}function o(t,r,i=e){let a=n(i);return r===`confirm`?Math.min(100,t+a.confirmIncrement):Math.max(0,t-a.contradictDecrement)}function s(t,r,i,a=e,o=Date.now()){let s=n(a),c=!!r,l=r?new Date(r):new Date(i),u=Math.max(0,o-l.getTime());c||(u=Math.min(u,336*60*60*1e3));let d=u/(10080*60*1e3),f=Math.floor(d)*s.weeklyDecay;return Math.max(s.decayFloor,t-f)}function c(t,r=e,i=Date.now()){let a=n(r);if(s(t.confidence,t.lastAccessedAt,t.createdAt,r,i)>=a.staleThreshold)return!1;let o=t.lastAccessedAt?new Date(t.lastAccessedAt):new Date(t.createdAt);return Math.max(0,i-o.getTime())/(1e3*60*60*24)>=a.staleDays}function l(t,r=e,i=Date.now()){let a=n(r);if(s(t.confidence,t.lastAccessedAt,t.createdAt,r,i)>=a.archiveThreshold)return!1;let o=t.lastAccessedAt?new Date(t.lastAccessedAt):new Date(t.createdAt);return Math.max(0,i-o.getTime())/(1e3*60*60*24)>=a.autoArchiveDays}const u={threshold:.7,maxCompare:50,autoThreshold:.95};function d(e){let t=Math.min(1,Math.max(0,e?.threshold??u.threshold)),n=Math.min(1,Math.max(t,e?.autoThreshold??u.autoThreshold));return{threshold:t,maxCompare:Math.max(1,Math.trunc(e?.maxCompare??u.maxCompare)),autoThreshold:n}}function f(e){let t=e.toLowerCase().match(/[a-z0-9]{2,}/g)??[];return new Set(t)}function p(e,t){let n=f(e),r=f(t);if(n.size===0&&r.size===0)return 1;if(n.size===0||r.size===0)return 0;let i=new Set([...n].filter(e=>r.has(e))),a=new Set([...n,...r]);return i.size/a.size}function m(e,t,n=u){let r=d(n);return t.slice(0,r.maxCompare).map(t=>({entryId:t.id,title:t.title,similarity:p(e,t.content),path:t.path})).filter(e=>e.similarity>=r.threshold).sort((e,t)=>t.similarity-e.similarity)}function h(e,t,n){e.memoryMetaCreate(t),e.memoryMetaSetSuperseded(t,n)}export{d as a,o as c,c as d,i as f,l as h,h as i,s as l,a as m,m as n,e as o,n as p,p as r,t as s,u as t,r as u};
@@ -1 +0,0 @@
1
- import{fileURLToPath as e}from"node:url";import{INSTALL_ARGS as t,cleanupOldVersions as n,createLogger as r,safeCwd as i}from"../../core/dist/index.js";import{existsSync as a,mkdirSync as o,readFileSync as s,renameSync as c,rmSync as l,unlinkSync as u,writeFileSync as d}from"node:fs";import{dirname as f,join as p,resolve as m}from"node:path";import{execFile as h,execSync as g,spawn as _}from"node:child_process";import{homedir as v}from"node:os";const y=`@vpxa/aikit`,b=`https://registry.npmjs.org/${y}/latest`,x=r(`server`);function S(){let t=f(e(import.meta.url));return[m(t,`..`,`..`,`..`,`bin`,`aikit.mjs`),m(t,`..`,`bin`,`aikit.mjs`),...process.argv[1]?[m(f(process.argv[1]),`aikit.mjs`)]:[]].find(e=>a(e))??null}const C=p(v(),`.aikit`),w=p(C,`current-version.json`),T=p(C,`versions`),E=/^\d+\.\d+\.\d+(-[\w.+]+)?(\+[\w.]+)?$/;function D(e){if(!E.test(e))throw Error(`Invalid semver version: ${JSON.stringify(e)}`)}function O(){let t=m(f(e(import.meta.url)),`..`,`..`,`..`,`package.json`);try{return JSON.parse(s(t,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}}function k(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 A(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function j(e){if(!a(e))return;for(let t=1;t<=2;t++)try{l(e,{recursive:!0,force:!0});return}catch(n){if(!(n.code===`EPERM`||n.code===`EBUSY`||/EPERM|permission denied/i.test(String(n)))){x.debug(`Failed to remove directory`,{path:e,error:n instanceof Error?n.message:String(n),attempt:t});return}}let t=`${e}.orphaned.${Date.now()}`;try{c(e,t),x.debug(`Renamed locked directory to ${t} — deferred cleanup`);try{l(t,{recursive:!0,force:!0})}catch{}}catch(t){x.debug(`Failed to rename locked directory`,{path:e,error:t instanceof Error?t.message:String(t)})}}async function M(e){D(e);let n=`v${e}`,r=p(T,`${n}-staging`),i=p(T,n);try{j(r),o(r,{recursive:!0}),g(`tar -xzf "${g(`npm pack ${y}@${e} 2>${process.platform===`win32`?`NUL`:`/dev/null`}`,{cwd:r,encoding:`utf-8`,timeout:6e4,windowsHide:!0}).trim()}"`,{cwd:r,encoding:`utf-8`,stdio:`pipe`,timeout:3e4,windowsHide:!0});let n=p(r,`package`);g(`npm ${t.join(` `)}`,{cwd:n,encoding:`utf-8`,stdio:`pipe`,timeout:12e4,windowsHide:!0});let s=p(n,`packages`,`server`,`dist`,`bin.js`);if(!a(s))throw Error(`Server entry not found at ${s}`);if(!a(p(n,`node_modules`)))throw Error(`node_modules not found — npm install may have failed`);a(i)&&l(i,{recursive:!0,force:!0}),c(n,i);let u=`${w}.tmp`;d(u,JSON.stringify({version:e,installedAt:new Date().toISOString()},null,2)),c(u,w),P(e)}finally{j(r)}}function N(e){x.debug(`Updated to v${e}. Restarting server...`),setTimeout(()=>{process.exit(0)},300).unref()}function P(e){n(T,e??O())}async function F(){try{let e=s(w,`utf-8`),{version:t}=JSON.parse(e),n=await fetch(b,{signal:AbortSignal.timeout(1e4)});if(!n.ok)return;let r=(await n.json()).version;if(!r||r===t||!A(r,t))return;if(a(p(T,`v${r}`))){let e=`${w}.tmp`;d(e,JSON.stringify({version:r,installedAt:new Date().toISOString()},null,2)),c(e,w),x.debug(`Re-activated existing version v${r} — no download needed`),N(r);return}x.debug(`New version available: ${r}. Installing...`),await M(r),N(r)}catch(e){x.error(`Background update check failed: ${e instanceof Error?e.message:String(e)}`)}}let I=null;function L(){return I||(I=R().finally(()=>{I=null}),I)}async function R(){if(a(w)){await F();return}let e=O();try{let t=await fetch(b,{signal:AbortSignal.timeout(1e4)});if(!t.ok)return;let n=(await t.json()).version;if(!n)return;if(k(e,n)<0){x.debug(`Newer version available — installing`,{currentVersion:e,latestVersion:n});try{await M(n),N(n)}catch(e){x.warn(`Auto-install failed`,{error:e instanceof Error?e.message:String(e),latestVersion:n})}}}catch{}}function z(){try{let e=m(v(),`.copilot`,`.aikit-scaffold.json`);return a(e)?JSON.parse(s(e,`utf-8`)).version??null:null}catch{return null}}function B(){try{let e=i();if(!e)return null;let t=m(e,`.github`,`.aikit-scaffold.json`);return a(t)?JSON.parse(s(t,`utf-8`)).version??null:null}catch{return null}}let V=`idle`,H=null,U=null,W=!1;function G(){return{state:V,error:H}}function K(){V=`idle`,H=null}function q(){try{let e=O();if(L(),!W){W=!0;try{let e=S();e&&_(process.execPath,[e,`migrate-launcher`],{cwd:v(),stdio:`ignore`,timeout:15e3,windowsHide:!0}).unref()}catch{}try{let e=m(v(),`.claude`,`mcp.json`);a(e)&&JSON.parse(s(e,`utf-8`))?.mcpServers?.[`AI Kit`]&&u(e)}catch{}}let t=z(),n=B();if(!(t!=null&&t!==e)&&!(n!=null&&n!==e)||(U!==e&&(K(),U=e),V!==`idle`))return;V=`pending`,H=null,x.debug(`Scaffold version mismatch — auto-upgrading`,{serverVersion:e,userScaffoldVersion:t,workspaceScaffoldVersion:n});let r=S();if(!r){V=`failed`,H=`aikit CLI binary not found`,x.warn(`Cannot auto-upgrade: aikit CLI binary not found`);return}let i=v();h(process.execPath,[r,`upgrade`],{cwd:i,timeout:3e4,windowsHide:!0},(t,n,a)=>{t?(V=`failed`,H=t.message,x.warn(`Auto-upgrade failed`,{error:t.message,stack:t.stack,code:t.code,stdout:n?.slice(0,500),stderr:a?.slice(0,500),cwd:i,binPath:r,platform:process.platform})):(V=`success`,H=null,x.debug(`Auto-upgrade completed to version ${e}`))}).unref()}catch(e){V=`failed`,H=e instanceof Error?e.message:String(e),x.warn(`Auto-upgrade check failed`,{error:H})}}export{q as autoUpgradeScaffold,L as checkForUpdates,P as cleanupOldVersions,O as getCurrentVersion,G as getUpgradeState};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{fileURLToPath as e}from"node:url";import{INSTALL_ARGS as t,cleanupOldVersions as n,createLogger as r,safeCwd as i}from"../../core/dist/index.js";import{existsSync as a,mkdirSync as o,readFileSync as s,renameSync as c,rmSync as l,unlinkSync as u,writeFileSync as d}from"node:fs";import{dirname as f,join as p,resolve as m}from"node:path";import{homedir as h}from"node:os";import{execFile as g,execSync as _,spawn as v}from"node:child_process";const y=`@vpxa/aikit`,b=`https://registry.npmjs.org/${y}/latest`,x=r(`server`);function S(){let t=f(e(import.meta.url));return[m(t,`..`,`..`,`..`,`bin`,`aikit.mjs`),m(t,`..`,`bin`,`aikit.mjs`),...process.argv[1]?[m(f(process.argv[1]),`aikit.mjs`)]:[]].find(e=>a(e))??null}const C=p(h(),`.aikit`),w=p(C,`current-version.json`),T=p(C,`versions`),E=/^\d+\.\d+\.\d+(-[\w.+]+)?(\+[\w.]+)?$/;function D(e){if(!E.test(e))throw Error(`Invalid semver version: ${JSON.stringify(e)}`)}function O(){let t=m(f(e(import.meta.url)),`..`,`..`,`..`,`package.json`);try{return JSON.parse(s(t,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}}function k(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 A(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function j(e){if(!a(e))return;for(let t=1;t<=2;t++)try{l(e,{recursive:!0,force:!0});return}catch(n){if(!(n.code===`EPERM`||n.code===`EBUSY`||/EPERM|permission denied/i.test(String(n)))){x.debug(`Failed to remove directory`,{path:e,error:n instanceof Error?n.message:String(n),attempt:t});return}}let t=`${e}.orphaned.${Date.now()}`;try{c(e,t),x.debug(`Renamed locked directory to ${t} — deferred cleanup`);try{l(t,{recursive:!0,force:!0})}catch{}}catch(t){x.debug(`Failed to rename locked directory`,{path:e,error:t instanceof Error?t.message:String(t)})}}async function M(e){D(e);let n=`v${e}`,r=p(T,`${n}-staging`),i=p(T,n);try{j(r),o(r,{recursive:!0}),_(`tar -xzf "${_(`npm pack ${y}@${e} 2>${process.platform===`win32`?`NUL`:`/dev/null`}`,{cwd:r,encoding:`utf-8`,timeout:6e4,windowsHide:!0}).trim()}"`,{cwd:r,encoding:`utf-8`,stdio:`pipe`,timeout:3e4,windowsHide:!0});let n=p(r,`package`);_(`npm ${t.join(` `)}`,{cwd:n,encoding:`utf-8`,stdio:`pipe`,timeout:12e4,windowsHide:!0});let s=p(n,`packages`,`server`,`dist`,`bin.js`);if(!a(s))throw Error(`Server entry not found at ${s}`);if(!a(p(n,`node_modules`)))throw Error(`node_modules not found — npm install may have failed`);a(i)&&l(i,{recursive:!0,force:!0}),c(n,i);let u=`${w}.tmp`;d(u,JSON.stringify({version:e,installedAt:new Date().toISOString()},null,2)),c(u,w),P(e)}finally{j(r)}}function N(e){x.debug(`Updated to v${e}. Restarting server...`),setTimeout(()=>{process.exit(0)},300).unref()}function P(e){n(T,e??O())}async function F(){try{let e=s(w,`utf-8`),{version:t}=JSON.parse(e),n=await fetch(b,{signal:AbortSignal.timeout(1e4)});if(!n.ok)return;let r=(await n.json()).version;if(!r||r===t||!A(r,t))return;if(a(p(T,`v${r}`))){let e=`${w}.tmp`;d(e,JSON.stringify({version:r,installedAt:new Date().toISOString()},null,2)),c(e,w),x.debug(`Re-activated existing version v${r} — no download needed`),N(r);return}x.debug(`New version available: ${r}. Installing...`),await M(r),N(r)}catch(e){x.error(`Background update check failed: ${e instanceof Error?e.message:String(e)}`)}}let I=null;function L(){return I||(I=R().finally(()=>{I=null}),I)}async function R(){if(a(w)){await F();return}let e=O();try{let t=await fetch(b,{signal:AbortSignal.timeout(1e4)});if(!t.ok)return;let n=(await t.json()).version;if(!n)return;if(k(e,n)<0){x.debug(`Newer version available — installing`,{currentVersion:e,latestVersion:n});try{await M(n),N(n)}catch(e){x.warn(`Auto-install failed`,{error:e instanceof Error?e.message:String(e),latestVersion:n})}}}catch{}}function z(){try{let e=m(h(),`.copilot`,`.aikit-scaffold.json`);return a(e)?JSON.parse(s(e,`utf-8`)).version??null:null}catch{return null}}function B(){try{let e=i();if(!e)return null;let t=m(e,`.github`,`.aikit-scaffold.json`);return a(t)?JSON.parse(s(t,`utf-8`)).version??null:null}catch{return null}}let V=`idle`,H=null,U=null,W=!1;function G(){return{state:V,error:H}}function K(){V=`idle`,H=null}function q(){try{let e=O();if(L(),!W){W=!0;try{let e=S();e&&v(process.execPath,[e,`migrate-launcher`],{cwd:h(),stdio:`ignore`,timeout:15e3,windowsHide:!0}).unref()}catch{}try{let e=m(h(),`.claude`,`mcp.json`);a(e)&&JSON.parse(s(e,`utf-8`))?.mcpServers?.[`AI Kit`]&&u(e)}catch{}}let t=z(),n=B();if(!(t!=null&&t!==e)&&!(n!=null&&n!==e)||(U!==e&&(K(),U=e),V!==`idle`))return;V=`pending`,H=null,x.debug(`Scaffold version mismatch — auto-upgrading`,{serverVersion:e,userScaffoldVersion:t,workspaceScaffoldVersion:n});let r=S();if(!r){V=`failed`,H=`aikit CLI binary not found`,x.warn(`Cannot auto-upgrade: aikit CLI binary not found`);return}let i=h();g(process.execPath,[r,`upgrade`],{cwd:i,timeout:3e4,windowsHide:!0},(t,n,a)=>{t?(V=`failed`,H=t.message,x.warn(`Auto-upgrade failed`,{error:t.message,stack:t.stack,code:t.code,stdout:n?.slice(0,500),stderr:a?.slice(0,500),cwd:i,binPath:r,platform:process.platform})):(V=`success`,H=null,x.debug(`Auto-upgrade completed to version ${e}`))}).unref()}catch(e){V=`failed`,H=e instanceof Error?e.message:String(e),x.warn(`Auto-upgrade check failed`,{error:H})}}export{q as autoUpgradeScaffold,L as checkForUpdates,P as cleanupOldVersions,O as getCurrentVersion,G as getUpgradeState};