@vpxa/aikit 0.1.382 → 0.1.384

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 (23) hide show
  1. package/package.json +1 -1
  2. package/packages/claude-desktop/dist/manifest.json +1 -1
  3. package/packages/server/dist/bin.js +1 -1
  4. package/packages/server/dist/{config-CQKoGfwD.js → config-BS9mkd50.js} +1 -1
  5. package/packages/server/dist/{config-DX1KYSbN.js → config-CkXCQx7E.js} +1 -1
  6. package/packages/server/dist/{dashboard-static-DdsIJd-u.js → dashboard-static-CVRj5Cbv.js} +1 -1
  7. package/packages/server/dist/{dashboard-static-C6RP0VA7.js → dashboard-static-q97RHnd3.js} +1 -1
  8. package/packages/server/dist/index.js +1 -1
  9. package/packages/server/dist/{register-tools-C49Lkpvq.js → register-tools-CCDtIMgE.js} +149 -149
  10. package/packages/server/dist/{register-tools-i_1kjBhi.js → register-tools-DLj1eMq3.js} +144 -144
  11. package/packages/server/dist/{server-CTUxU4KX.js → server-B6YroA9y.js} +2 -2
  12. package/packages/server/dist/{server-Dm2u4PSm.js → server-QCZQCfjf.js} +2 -2
  13. package/packages/server/dist/{server-http-DcgFpWra.js → server-http-agZcmQoQ.js} +1 -1
  14. package/packages/server/dist/{server-http-D8Wemu8Y.js → server-http-tJ-qTrTX.js} +1 -1
  15. package/packages/server/dist/{server-stdio-Bpoo8KOT.js → server-stdio-B0CPUULy.js} +1 -1
  16. package/packages/server/dist/{server-stdio-CskpvBew.js → server-stdio-BpzUm6FP.js} +1 -1
  17. package/packages/server/dist/{settings-static-C0oT3Ctk.js → settings-static-HY0egyKG.js} +1 -1
  18. package/packages/server/dist/{settings-static-DVMG47Oh.js → settings-static-VnUkp9iU.js} +1 -1
  19. package/packages/server/dist/startup-maintenance-D7tKqECM.js +21 -0
  20. package/packages/server/dist/{startup-maintenance-kHH8tjds.js → startup-maintenance-QrloHssd.js} +6 -6
  21. package/packages/tools/dist/index.d.ts +41 -2
  22. package/packages/tools/dist/index.js +105 -106
  23. package/packages/server/dist/startup-maintenance-cbRSFMY5.js +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/aikit",
3
- "version": "0.1.382",
3
+ "version": "0.1.384",
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",
@@ -2,7 +2,7 @@
2
2
  "manifest_version": "0.3",
3
3
  "name": "aikit",
4
4
  "display_name": "AI Kit",
5
- "version": "0.1.382",
5
+ "version": "0.1.384",
6
6
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
7
7
  "author": {
8
8
  "name": "AnVPX",
@@ -5,4 +5,4 @@ import{fileURLToPath as e,pathToFileURL as t}from"node:url";import{parseArgs as
5
5
  `).length,fileHash:this.hash(e.content),indexedAt:t,origin:`curated`,tags:e.frontmatter.tags,category:e.frontmatter.category,version:e.frontmatter.version}});try{return await this.store.upsert(i,r),e.length}catch(t){z.error(`Failed to upsert curated batch`,{batchSize:e.length,...o(t)});for(let t of e)n.push(`${t.relativePath}: upsert failed`);return 0}}catch(r){if(e.length===1)return z.error(`Failed to embed curated item`,{relativePath:e[0].relativePath,...o(r)}),n.push(`${e[0].relativePath}: reindex failed`),0;z.warn(`Curated embed batch failed, retrying with smaller chunks`,{batchSize:e.length,...o(r)});let i=Math.ceil(e.length/2),a=e.slice(0,i),s=e.slice(i);return await this.embedAndUpsertBatch(a,t,n)+await this.embedAndUpsertBatch(s,t,n)}}gitCommitKnowledge(e,t,n){try{if(!b(this.curatedDir))return;let r=this.knowledgeRefForPath(e);if(!r)return;x(r,`entry.md`,t,n,this.curatedDir)}catch{}}gitDeleteKnowledgeRef(e){try{if(!b(this.curatedDir))return;let t=this.knowledgeRefForPath(e);if(!t)return;S([`update-ref`,`-d`,t],this.curatedDir)}catch{}}knowledgeRefForPath(e){let t=e.replace(/\.md$/,``).split(`/`).map(e=>C(e)).join(`/`);return t.split(`/`).every(e=>y.test(e))?`${R}/${t}`:null}async indexCuratedFile(e,t,n){let r=await this.embedder.embed(t),i=`.ai/curated/${e}`,a=new Date().toISOString(),o={id:this.hashId(i,0),content:t,sourcePath:i,contentType:`curated-knowledge`,headingPath:n.title,chunkIndex:0,totalChunks:1,startLine:1,endLine:t.split(`
6
6
  `).length,fileHash:this.hash(t),indexedAt:a,origin:`curated`,tags:n.tags,category:n.category,version:n.version};await this.store.upsert([o],[r])}async indexCuratedFileBestEffort(e,t,n,i){if(r.instance().isDegraded(`embedder`)){z.debug(`Skipping vector indexing — embedder degraded`,{relativePath:e,operation:i,subsystem:`embedder`});return}try{await this.indexCuratedFile(e,t,n)}catch(t){z.warn(`Curated file persisted but vector indexing deferred`,{relativePath:e,operation:i,...o(t)})}}async discoverCategories(){return this.adapter.listDirectories()}guardPath(e){let t=e.replace(/^\.ai\/curated\//,``);if(t.endsWith(`.md`)||(t+=`.md`),t.includes(`..`)||l(t))throw Error(`Invalid path: ${t}. Must be relative within .ai/curated/ directory.`);let n=t.split(`/`)[0];return this.validateCategoryName(n),t}validateCategoryName(e){if(!/^[a-z][a-z0-9-]*$/.test(e))throw Error(`Invalid category name: "${e}". Must be lowercase kebab-case (e.g., "decisions", "api-contracts").`)}validateContentSize(e){if(Buffer.byteLength(e,`utf-8`)>L)throw Error(`Content exceeds maximum size of ${L/1024}KB`)}slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,80)}normalizeTags(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}sameTags(e,t){if(e.length!==t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}ensureCategoryPath(e,t){if(!e.startsWith(`${t}/`))throw Error(`Curated path "${e}" must stay within category "${t}"`)}async uniqueRelativePath(e,t){let n=`${e}/${t}.md`;if(!await this.adapter.exists(n))return n;for(let n=2;n<=100;n++){let r=`${e}/${t}-${n}.md`;if(!await this.adapter.exists(r))return r}throw Error(`Too many entries with slug "${t}" in category "${e}"`)}hash(e){return v(`sha256`).update(e).digest(`hex`).slice(0,16)}hashId(e,t){return this.hash(`${e}::${t}`)}serializeFile(e,t){return`${[`---`,`title: "${t.title.replace(/"/g,`\\"`)}"`,`category: ${t.category}`,`tags: [${t.tags.map(e=>`"${e}"`).join(`, `)}]`,`created: ${t.created}`,`updated: ${t.updated}`,`version: ${t.version}`,`origin: ${t.origin}`,`changelog:`,...t.changelog.map(e=>` - version: ${e.version}\n date: ${e.date}\n reason: "${e.reason.replace(/"/g,`\\"`)}"`),`---`].join(`
7
7
  `)}\n\n${e}\n`}parseFile(e){let t=e.match(/^---\n([\s\S]*?)\n---\n\n?([\s\S]*)$/);if(!t)return{frontmatter:{title:`Untitled`,category:`notes`,tags:[],created:``,updated:``,version:1,origin:`curated`,changelog:[]},content:e};let n=t[1],r=t[2].trim(),i={},a=[],o=n.split(`
8
- `),s=!1,c={};for(let e of o){if(/^changelog:\s*$/.test(e)){s=!0;continue}if(s){let t=e.match(/^\s+-\s+version:\s*(\d+)$/);if(t){c.version!=null&&a.push(c),c={version:parseInt(t[1],10)};continue}let n=e.match(/^\s+date:\s*(.+)$/);if(n){c.date=n[1].trim();continue}let r=e.match(/^\s+reason:\s*"?(.*?)"?\s*$/);if(r){c.reason=r[1];continue}/^\w/.test(e)&&(s=!1,c.version!=null&&a.push(c),c={});continue}let t=e.match(/^(\w+):\s*(.*)$/);if(t){let e=t[1],n=t[2];typeof n==`string`&&n.startsWith(`[`)&&n.endsWith(`]`)?n=n.slice(1,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)).filter(e=>e.length>0):typeof n==`string`&&/^\d+$/.test(n)?n=parseInt(n,10):typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1)),i[e]=n}}return c.version!=null&&a.push(c),{frontmatter:{title:i.title??`Untitled`,category:i.category??`notes`,tags:i.tags??[],created:i.created??``,updated:i.updated??``,version:i.version??1,origin:`curated`,changelog:a},content:r}}};const V=i(`server`);function H(e,t){return t?{version:e,...o(t)}:{version:e}}function U(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function W(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===t(e).href}catch{return!1}}function G(){return W()?n({allowPositionals:!0,options:{transport:{type:`string`,default:U()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:U(),port:process.env.AIKIT_PORT??`3210`}}async function K(){let e=t=>{t.name===`ExperimentalWarning`&&t.message.includes(`SQLite`)||(process.off(`warning`,e),process.emitWarning(t),process.on(`warning`,e))};process.on(`warning`,e);let t=w(),n=G();if(process.on(`unhandledRejection`,e=>{V.error(`Unhandled rejection`,H(t,e))}),process.on(`uncaughtException`,e=>{V.error(`Uncaught exception — exiting`,H(t,e)),process.exit(1)}),V.info(`Starting MCP AI Kit server`,{version:t}),n.transport===`http`){let{startHttpMode:e}=await import(`./server-http-D8Wemu8Y.js`);await e(t,n.port)}else{let{startStdioMode:e}=await import(`./server-stdio-Bpoo8KOT.js`);await e(t)}}K();export{T as a,k as i,I as n,E as o,F as r,O as s,B as t};
8
+ `),s=!1,c={};for(let e of o){if(/^changelog:\s*$/.test(e)){s=!0;continue}if(s){let t=e.match(/^\s+-\s+version:\s*(\d+)$/);if(t){c.version!=null&&a.push(c),c={version:parseInt(t[1],10)};continue}let n=e.match(/^\s+date:\s*(.+)$/);if(n){c.date=n[1].trim();continue}let r=e.match(/^\s+reason:\s*"?(.*?)"?\s*$/);if(r){c.reason=r[1];continue}/^\w/.test(e)&&(s=!1,c.version!=null&&a.push(c),c={});continue}let t=e.match(/^(\w+):\s*(.*)$/);if(t){let e=t[1],n=t[2];typeof n==`string`&&n.startsWith(`[`)&&n.endsWith(`]`)?n=n.slice(1,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)).filter(e=>e.length>0):typeof n==`string`&&/^\d+$/.test(n)?n=parseInt(n,10):typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1)),i[e]=n}}return c.version!=null&&a.push(c),{frontmatter:{title:i.title??`Untitled`,category:i.category??`notes`,tags:i.tags??[],created:i.created??``,updated:i.updated??``,version:i.version??1,origin:`curated`,changelog:a},content:r}}};const V=i(`server`);function H(e,t){return t?{version:e,...o(t)}:{version:e}}function U(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function W(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===t(e).href}catch{return!1}}function G(){return W()?n({allowPositionals:!0,options:{transport:{type:`string`,default:U()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:U(),port:process.env.AIKIT_PORT??`3210`}}async function K(){let e=t=>{t.name===`ExperimentalWarning`&&t.message.includes(`SQLite`)||(process.off(`warning`,e),process.emitWarning(t),process.on(`warning`,e))};process.on(`warning`,e);let t=w(),n=G();if(process.on(`unhandledRejection`,e=>{V.error(`Unhandled rejection`,H(t,e))}),process.on(`uncaughtException`,e=>{V.error(`Uncaught exception — exiting`,H(t,e)),process.exit(1)}),V.info(`Starting MCP AI Kit server`,{version:t}),n.transport===`http`){let{startHttpMode:e}=await import(`./server-http-tJ-qTrTX.js`);await e(t,n.port)}else{let{startStdioMode:e}=await import(`./server-stdio-B0CPUULy.js`);await e(t)}}K();export{T as a,k as i,I as n,E as o,F as r,O as s,B as t};
@@ -1 +1 @@
1
- import{D as e,I as t,K as n,M as r}from"./startup-maintenance-kHH8tjds.js";import{fileURLToPath as i}from"node:url";import{AIKIT_RUNTIME_PATHS as a,DEFAULT_SERVER_NAME as o,EMBEDDING_DEFAULTS as s,computePartitionKey as c,createLogger as l,getPartitionDir as u,migrateLegacyWorkspaceLayout as d,safeCwd as f,serializeError as p}from"../../core/dist/index.js";import{existsSync as m,mkdirSync as h,readFileSync as g,writeFileSync as _}from"node:fs";import{dirname as v,isAbsolute as y,relative as b,resolve as x}from"node:path";import{homedir as S}from"node:os";const C=v(i(import.meta.url)),w=l(`server`),T=[`auto`,`manual`,`smart`],E={model:s.model,dimensions:s.dimensions,childProcess:!0,idleTimeoutMs:3e5};function D(e){return typeof e==`string`&&T.includes(e)}function O(e,t,n){let r=x(e),i=b(x(t),r);if(i.startsWith(`..`)||y(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function k(e,t){let n=x(e),r=b(x(t),n);return!(r.startsWith(`..`)||y(r))}function A(e){return u(c(e))}function j(e,t,n,r,i){let a=r?x(t,r):t;if(!n)return O(a,t,i);let o=x(e,n);return k(o,t)?r&&x(o)===x(t)?O(a,t,i):O(o,t,i):O(a,t,i)}function M(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir,e.skillDir];for(let e of t)e&&h(e,{recursive:!0})}function N(e,t){d(t);let n=A(t);e.store={...e.store,path:j(t,n,e.store?.path,a.data,`store`)},e.curated={...e.curated,path:j(t,n,e.curated?.path,a.curated,`curated`)},e.onboardDir=j(t,n,e.onboardDir,a.onboard,`onboard`),e.stateDir=j(t,n,e.stateDir,a.state,`state`),e.skillDir=j(t,n,e.skillDir,a.skills,`skillDir`)}function P(e){let t=process.env.AIKIT_INDEX_MODE;if(D(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function F(){let i=f(),a=process.env.AIKIT_CONFIG_PATH??(i&&m(x(i,`aikit.config.json`))?x(i,`aikit.config.json`):x(C,`..`,`..`,`..`,`aikit.config.json`));try{if(!m(a))return w.info(`No config file found, using defaults`,{configPath:a}),L();let i=g(a,`utf-8`),o=JSON.parse(i),s={...E,...o.embedding};if(o.embedding=s,o.memory={retention:{...r,...o.memory?.retention},lessons:{...t,...o.memory?.lessons},consolidation:{...n,...o.memory?.consolidation},supersession:{...e,...o.memory?.supersession}},o.logging?.errorDetails!==void 0&&typeof o.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(o.logging={errorDetails:o.logging?.errorDetails===!0},!o.sources||!Array.isArray(o.sources)||o.sources.length===0)throw Error(`Config must have at least one source`);if(!o.store?.path)throw Error(`Config must specify store.path`);if(o.autoIndex!==void 0&&typeof o.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(o.indexMode!==void 0&&!D(o.indexMode))throw Error(`Config indexMode must be one of: ${T.join(`, `)}`);if(typeof s.model!=`string`||s.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(s.nativeDim!==void 0&&(!Number.isInteger(s.nativeDim)||s.nativeDim<=0))throw Error(`Config embedding.nativeDim must be a positive integer`);if(s.dimensions!==void 0&&(!Number.isInteger(s.dimensions)||s.dimensions<=0))throw Error(`Config embedding.dimensions must be a positive integer`);if(s.dimensions!==void 0&&s.nativeDim!==void 0&&s.dimensions>s.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(s.queryPrefix!==void 0&&typeof s.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let c=v(a);return o.sources=o.sources.map(e=>({...e,path:O(x(c,e.path),c,`source`)})),R(o,a),N(o,c),o.layeredKnowledge===void 0&&(o.layeredKnowledge=process.env.AIKIT_LAYERED_KNOWLEDGE===`true`),o.indexMode=P(o),o}catch(e){let t=`Failed to load config from ${a}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),w.error(`Failed to load config`,{configPath:a,...p(e)}),w.warn(`Falling back to default configuration`,{configPath:a});let n=L();return n.configError=t,n}}const I=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function L(){let i=process.env.AIKIT_WORKSPACE_ROOT??f()??S(),s=A(i),c={sources:[{path:i,excludePatterns:[...I]}],serverName:o,indexing:{chunkSize:800,chunkOverlap:150,minChunkSize:100},embedding:{...E},store:{backend:`sqlite-vec`,path:x(s,a.data)},curated:{path:x(s,a.curated)},memory:{retention:{...r},lessons:{...t},consolidation:{...n},supersession:{...e}},logging:{errorDetails:!1},onboardDir:x(s,a.onboard),stateDir:x(s,a.state)};return c.indexMode=P(c),c}function R(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of I)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{_(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),w.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){w.warn(`Failed to write upgraded config`,{configPath:t,...p(e)})}return e}function z(e,t){if(!m(t))throw Error(`Workspace root does not exist: ${t}`);d(t),w.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),w.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){w.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...p(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],N(e,t),M(e)}export{I as DEFAULT_EXCLUDE_PATTERNS,F as loadConfig,z as reconfigureForWorkspace,P as resolveIndexMode};
1
+ import{D as e,I as t,K as n,M as r}from"./startup-maintenance-QrloHssd.js";import{fileURLToPath as i}from"node:url";import{AIKIT_RUNTIME_PATHS as a,DEFAULT_SERVER_NAME as o,EMBEDDING_DEFAULTS as s,computePartitionKey as c,createLogger as l,getPartitionDir as u,migrateLegacyWorkspaceLayout as d,safeCwd as f,serializeError as p}from"../../core/dist/index.js";import{existsSync as m,mkdirSync as h,readFileSync as g,writeFileSync as _}from"node:fs";import{dirname as v,isAbsolute as y,relative as b,resolve as x}from"node:path";import{homedir as S}from"node:os";const C=v(i(import.meta.url)),w=l(`server`),T=[`auto`,`manual`,`smart`],E={model:s.model,dimensions:s.dimensions,childProcess:!0,idleTimeoutMs:3e5};function D(e){return typeof e==`string`&&T.includes(e)}function O(e,t,n){let r=x(e),i=b(x(t),r);if(i.startsWith(`..`)||y(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function k(e,t){let n=x(e),r=b(x(t),n);return!(r.startsWith(`..`)||y(r))}function A(e){return u(c(e))}function j(e,t,n,r,i){let a=r?x(t,r):t;if(!n)return O(a,t,i);let o=x(e,n);return k(o,t)?r&&x(o)===x(t)?O(a,t,i):O(o,t,i):O(a,t,i)}function M(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir,e.skillDir];for(let e of t)e&&h(e,{recursive:!0})}function N(e,t){d(t);let n=A(t);e.store={...e.store,path:j(t,n,e.store?.path,a.data,`store`)},e.curated={...e.curated,path:j(t,n,e.curated?.path,a.curated,`curated`)},e.onboardDir=j(t,n,e.onboardDir,a.onboard,`onboard`),e.stateDir=j(t,n,e.stateDir,a.state,`state`),e.skillDir=j(t,n,e.skillDir,a.skills,`skillDir`)}function P(e){let t=process.env.AIKIT_INDEX_MODE;if(D(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function F(){let i=f(),a=process.env.AIKIT_CONFIG_PATH??(i&&m(x(i,`aikit.config.json`))?x(i,`aikit.config.json`):x(C,`..`,`..`,`..`,`aikit.config.json`));try{if(!m(a))return w.info(`No config file found, using defaults`,{configPath:a}),L();let i=g(a,`utf-8`),o=JSON.parse(i),s={...E,...o.embedding};if(o.embedding=s,o.memory={retention:{...r,...o.memory?.retention},lessons:{...t,...o.memory?.lessons},consolidation:{...n,...o.memory?.consolidation},supersession:{...e,...o.memory?.supersession}},o.logging?.errorDetails!==void 0&&typeof o.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(o.logging={errorDetails:o.logging?.errorDetails===!0},!o.sources||!Array.isArray(o.sources)||o.sources.length===0)throw Error(`Config must have at least one source`);if(!o.store?.path)throw Error(`Config must specify store.path`);if(o.autoIndex!==void 0&&typeof o.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(o.indexMode!==void 0&&!D(o.indexMode))throw Error(`Config indexMode must be one of: ${T.join(`, `)}`);if(typeof s.model!=`string`||s.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(s.nativeDim!==void 0&&(!Number.isInteger(s.nativeDim)||s.nativeDim<=0))throw Error(`Config embedding.nativeDim must be a positive integer`);if(s.dimensions!==void 0&&(!Number.isInteger(s.dimensions)||s.dimensions<=0))throw Error(`Config embedding.dimensions must be a positive integer`);if(s.dimensions!==void 0&&s.nativeDim!==void 0&&s.dimensions>s.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(s.queryPrefix!==void 0&&typeof s.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let c=v(a);return o.sources=o.sources.map(e=>({...e,path:O(x(c,e.path),c,`source`)})),R(o,a),N(o,c),o.layeredKnowledge===void 0&&(o.layeredKnowledge=process.env.AIKIT_LAYERED_KNOWLEDGE===`true`),o.indexMode=P(o),o}catch(e){let t=`Failed to load config from ${a}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),w.error(`Failed to load config`,{configPath:a,...p(e)}),w.warn(`Falling back to default configuration`,{configPath:a});let n=L();return n.configError=t,n}}const I=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function L(){let i=process.env.AIKIT_WORKSPACE_ROOT??f()??S(),s=A(i),c={sources:[{path:i,excludePatterns:[...I]}],serverName:o,indexing:{chunkSize:800,chunkOverlap:150,minChunkSize:100},embedding:{...E},store:{backend:`sqlite-vec`,path:x(s,a.data)},curated:{path:x(s,a.curated)},memory:{retention:{...r},lessons:{...t},consolidation:{...n},supersession:{...e}},logging:{errorDetails:!1},onboardDir:x(s,a.onboard),stateDir:x(s,a.state)};return c.indexMode=P(c),c}function R(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of I)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{_(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),w.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){w.warn(`Failed to write upgraded config`,{configPath:t,...p(e)})}return e}function z(e,t){if(!m(t))throw Error(`Workspace root does not exist: ${t}`);d(t),w.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),w.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){w.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...p(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],N(e,t),M(e)}export{I as DEFAULT_EXCLUDE_PATTERNS,F as loadConfig,z as reconfigureForWorkspace,P as resolveIndexMode};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{D as e,I as t,K as n,M as r}from"./startup-maintenance-cbRSFMY5.js";import{fileURLToPath as i}from"node:url";import{AIKIT_RUNTIME_PATHS as a,DEFAULT_SERVER_NAME as o,EMBEDDING_DEFAULTS as s,computePartitionKey as c,createLogger as l,getPartitionDir as u,migrateLegacyWorkspaceLayout as d,safeCwd as f,serializeError as p}from"../../core/dist/index.js";import{existsSync as m,mkdirSync as h,readFileSync as g,writeFileSync as _}from"node:fs";import{dirname as v,isAbsolute as y,relative as b,resolve as x}from"node:path";import{homedir as S}from"node:os";const C=v(i(import.meta.url)),w=l(`server`),T=[`auto`,`manual`,`smart`],E={model:s.model,dimensions:s.dimensions,childProcess:!0,idleTimeoutMs:3e5};function D(e){return typeof e==`string`&&T.includes(e)}function O(e,t,n){let r=x(e),i=b(x(t),r);if(i.startsWith(`..`)||y(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function k(e,t){let n=x(e),r=b(x(t),n);return!(r.startsWith(`..`)||y(r))}function A(e){return u(c(e))}function j(e,t,n,r,i){let a=r?x(t,r):t;if(!n)return O(a,t,i);let o=x(e,n);return k(o,t)?r&&x(o)===x(t)?O(a,t,i):O(o,t,i):O(a,t,i)}function M(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir,e.skillDir];for(let e of t)e&&h(e,{recursive:!0})}function N(e,t){d(t);let n=A(t);e.store={...e.store,path:j(t,n,e.store?.path,a.data,`store`)},e.curated={...e.curated,path:j(t,n,e.curated?.path,a.curated,`curated`)},e.onboardDir=j(t,n,e.onboardDir,a.onboard,`onboard`),e.stateDir=j(t,n,e.stateDir,a.state,`state`),e.skillDir=j(t,n,e.skillDir,a.skills,`skillDir`)}function P(e){let t=process.env.AIKIT_INDEX_MODE;if(D(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function F(){let i=f(),a=process.env.AIKIT_CONFIG_PATH??(i&&m(x(i,`aikit.config.json`))?x(i,`aikit.config.json`):x(C,`..`,`..`,`..`,`aikit.config.json`));try{if(!m(a))return w.info(`No config file found, using defaults`,{configPath:a}),L();let i=g(a,`utf-8`),o=JSON.parse(i),s={...E,...o.embedding};if(o.embedding=s,o.memory={retention:{...r,...o.memory?.retention},lessons:{...t,...o.memory?.lessons},consolidation:{...n,...o.memory?.consolidation},supersession:{...e,...o.memory?.supersession}},o.logging?.errorDetails!==void 0&&typeof o.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(o.logging={errorDetails:o.logging?.errorDetails===!0},!o.sources||!Array.isArray(o.sources)||o.sources.length===0)throw Error(`Config must have at least one source`);if(!o.store?.path)throw Error(`Config must specify store.path`);if(o.autoIndex!==void 0&&typeof o.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(o.indexMode!==void 0&&!D(o.indexMode))throw Error(`Config indexMode must be one of: ${T.join(`, `)}`);if(typeof s.model!=`string`||s.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(s.nativeDim!==void 0&&(!Number.isInteger(s.nativeDim)||s.nativeDim<=0))throw Error(`Config embedding.nativeDim must be a positive integer`);if(s.dimensions!==void 0&&(!Number.isInteger(s.dimensions)||s.dimensions<=0))throw Error(`Config embedding.dimensions must be a positive integer`);if(s.dimensions!==void 0&&s.nativeDim!==void 0&&s.dimensions>s.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(s.queryPrefix!==void 0&&typeof s.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let c=v(a);return o.sources=o.sources.map(e=>({...e,path:O(x(c,e.path),c,`source`)})),R(o,a),N(o,c),o.layeredKnowledge===void 0&&(o.layeredKnowledge=process.env.AIKIT_LAYERED_KNOWLEDGE===`true`),o.indexMode=P(o),o}catch(e){let t=`Failed to load config from ${a}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),w.error(`Failed to load config`,{configPath:a,...p(e)}),w.warn(`Falling back to default configuration`,{configPath:a});let n=L();return n.configError=t,n}}const I=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function L(){let i=process.env.AIKIT_WORKSPACE_ROOT??f()??S(),s=A(i),c={sources:[{path:i,excludePatterns:[...I]}],serverName:o,indexing:{chunkSize:800,chunkOverlap:150,minChunkSize:100},embedding:{...E},store:{backend:`sqlite-vec`,path:x(s,a.data)},curated:{path:x(s,a.curated)},memory:{retention:{...r},lessons:{...t},consolidation:{...n},supersession:{...e}},logging:{errorDetails:!1},onboardDir:x(s,a.onboard),stateDir:x(s,a.state)};return c.indexMode=P(c),c}function R(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of I)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{_(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),w.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){w.warn(`Failed to write upgraded config`,{configPath:t,...p(e)})}return e}function z(e,t){if(!m(t))throw Error(`Workspace root does not exist: ${t}`);d(t),w.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),w.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){w.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...p(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],N(e,t),M(e)}export{I as DEFAULT_EXCLUDE_PATTERNS,F as loadConfig,z as reconfigureForWorkspace,P as resolveIndexMode};
2
+ import{D as e,I as t,K as n,M as r}from"./startup-maintenance-D7tKqECM.js";import{fileURLToPath as i}from"node:url";import{AIKIT_RUNTIME_PATHS as a,DEFAULT_SERVER_NAME as o,EMBEDDING_DEFAULTS as s,computePartitionKey as c,createLogger as l,getPartitionDir as u,migrateLegacyWorkspaceLayout as d,safeCwd as f,serializeError as p}from"../../core/dist/index.js";import{existsSync as m,mkdirSync as h,readFileSync as g,writeFileSync as _}from"node:fs";import{dirname as v,isAbsolute as y,relative as b,resolve as x}from"node:path";import{homedir as S}from"node:os";const C=v(i(import.meta.url)),w=l(`server`),T=[`auto`,`manual`,`smart`],E={model:s.model,dimensions:s.dimensions,childProcess:!0,idleTimeoutMs:3e5};function D(e){return typeof e==`string`&&T.includes(e)}function O(e,t,n){let r=x(e),i=b(x(t),r);if(i.startsWith(`..`)||y(i))throw Error(`Config ${n} path escapes allowed root: ${e} is not under ${t}`);return r}function k(e,t){let n=x(e),r=b(x(t),n);return!(r.startsWith(`..`)||y(r))}function A(e){return u(c(e))}function j(e,t,n,r,i){let a=r?x(t,r):t;if(!n)return O(a,t,i);let o=x(e,n);return k(o,t)?r&&x(o)===x(t)?O(a,t,i):O(o,t,i):O(a,t,i)}function M(e){let t=[e.store?.path,e.curated?.path,e.onboardDir,e.stateDir,e.skillDir];for(let e of t)e&&h(e,{recursive:!0})}function N(e,t){d(t);let n=A(t);e.store={...e.store,path:j(t,n,e.store?.path,a.data,`store`)},e.curated={...e.curated,path:j(t,n,e.curated?.path,a.curated,`curated`)},e.onboardDir=j(t,n,e.onboardDir,a.onboard,`onboard`),e.stateDir=j(t,n,e.stateDir,a.state,`state`),e.skillDir=j(t,n,e.skillDir,a.skills,`skillDir`)}function P(e){let t=process.env.AIKIT_INDEX_MODE;if(D(t))return t;if(e.indexMode)return e.indexMode;let n=process.env.AIKIT_AUTO_INDEX;return n===void 0?e.autoIndex===void 0?`smart`:e.autoIndex?`auto`:`manual`:n===`true`?`auto`:`manual`}function F(){let i=f(),a=process.env.AIKIT_CONFIG_PATH??(i&&m(x(i,`aikit.config.json`))?x(i,`aikit.config.json`):x(C,`..`,`..`,`..`,`aikit.config.json`));try{if(!m(a))return w.info(`No config file found, using defaults`,{configPath:a}),L();let i=g(a,`utf-8`),o=JSON.parse(i),s={...E,...o.embedding};if(o.embedding=s,o.memory={retention:{...r,...o.memory?.retention},lessons:{...t,...o.memory?.lessons},consolidation:{...n,...o.memory?.consolidation},supersession:{...e,...o.memory?.supersession}},o.logging?.errorDetails!==void 0&&typeof o.logging.errorDetails!=`boolean`)throw Error(`Config logging.errorDetails must be a boolean`);if(o.logging={errorDetails:o.logging?.errorDetails===!0},!o.sources||!Array.isArray(o.sources)||o.sources.length===0)throw Error(`Config must have at least one source`);if(!o.store?.path)throw Error(`Config must specify store.path`);if(o.autoIndex!==void 0&&typeof o.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(o.indexMode!==void 0&&!D(o.indexMode))throw Error(`Config indexMode must be one of: ${T.join(`, `)}`);if(typeof s.model!=`string`||s.model.trim()===``)throw Error(`Config embedding.model must be a non-empty string`);if(s.nativeDim!==void 0&&(!Number.isInteger(s.nativeDim)||s.nativeDim<=0))throw Error(`Config embedding.nativeDim must be a positive integer`);if(s.dimensions!==void 0&&(!Number.isInteger(s.dimensions)||s.dimensions<=0))throw Error(`Config embedding.dimensions must be a positive integer`);if(s.dimensions!==void 0&&s.nativeDim!==void 0&&s.dimensions>s.nativeDim)throw Error(`Config embedding.dimensions must not exceed embedding.nativeDim`);if(s.queryPrefix!==void 0&&typeof s.queryPrefix!=`string`)throw Error(`Config embedding.queryPrefix must be a string`);let c=v(a);return o.sources=o.sources.map(e=>({...e,path:O(x(c,e.path),c,`source`)})),R(o,a),N(o,c),o.layeredKnowledge===void 0&&(o.layeredKnowledge=process.env.AIKIT_LAYERED_KNOWLEDGE===`true`),o.indexMode=P(o),o}catch(e){let t=`Failed to load config from ${a}. ${e instanceof Error?e.message:String(e)}`;console.error(`\n ⚠ CONFIG ERROR — ${t}\n Check that the file exists, is valid JSON, and all required fields are present.\n`),w.error(`Failed to load config`,{configPath:a,...p(e)}),w.warn(`Falling back to default configuration`,{configPath:a});let n=L();return n.configError=t,n}}const I=[`.git/**`,`**/node_modules/**`,`*.lock`,`pnpm-lock.yaml`,`package-lock.json`,`**/dist/**`,`**/build/**`,`**/out/**`,`**/.output/**`,`**/cdk.out/**`,`**/.next/**`,`**/.nuxt/**`,`**/.vercel/**`,`**/.serverless/**`,`**/.turbo/**`,`**/.cache/**`,`**/.parcel-cache/**`,`**/coverage/**`,`**/.terraform/**`,`**/__pycache__/**`,`**/.venv/**`,`**/.docusaurus/**`,`**/.temp/**`,`**/tmp/**`];function L(){let i=process.env.AIKIT_WORKSPACE_ROOT??f()??S(),s=A(i),c={sources:[{path:i,excludePatterns:[...I]}],serverName:o,indexing:{chunkSize:800,chunkOverlap:150,minChunkSize:100},embedding:{...E},store:{backend:`sqlite-vec`,path:x(s,a.data)},curated:{path:x(s,a.curated)},memory:{retention:{...r},lessons:{...t},consolidation:{...n},supersession:{...e}},logging:{errorDetails:!1},onboardDir:x(s,a.onboard),stateDir:x(s,a.state)};return c.indexMode=P(c),c}function R(e,t){let n=e.configVersion??0;if(n>=1)return e;if(n<1)for(let t of e.sources){t.excludePatterns=t.excludePatterns??[];let e=new Set(t.excludePatterns);for(let n of I)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{_(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),w.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){w.warn(`Failed to write upgraded config`,{configPath:t,...p(e)})}return e}function z(e,t){if(!m(t))throw Error(`Workspace root does not exist: ${t}`);d(t),w.debug(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),w.debug(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){w.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...p(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],N(e,t),M(e)}export{I as DEFAULT_EXCLUDE_PATTERNS,F as loadConfig,z as reconfigureForWorkspace,P as resolveIndexMode};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{w as e}from"./startup-maintenance-cbRSFMY5.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,`..`,`..`,`dashboard`,`dist`):e(`dashboard`)??s(u,`..`,`..`,`dashboard`,`dist`)}function p(e,t){let n=t.replace(/^\/_dashboard\/?/,``)||`index.html`;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(`/_dashboard{/*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(`Dashboard available`,{url:`/_dashboard/`,dir:t}),!0):!1}export{m as registerDashboardRoutes,f as resolveDashboardDir,p as resolveDashboardRequest};
2
+ import{w as e}from"./startup-maintenance-D7tKqECM.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,`..`,`..`,`dashboard`,`dist`):e(`dashboard`)??s(u,`..`,`..`,`dashboard`,`dist`)}function p(e,t){let n=t.replace(/^\/_dashboard\/?/,``)||`index.html`;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(`/_dashboard{/*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(`Dashboard available`,{url:`/_dashboard/`,dir:t}),!0):!1}export{m as registerDashboardRoutes,f as resolveDashboardDir,p as resolveDashboardRequest};
@@ -1 +1 @@
1
- import{w as e}from"./startup-maintenance-kHH8tjds.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,`..`,`..`,`dashboard`,`dist`):e(`dashboard`)??s(u,`..`,`..`,`dashboard`,`dist`)}function p(e,t){let n=t.replace(/^\/_dashboard\/?/,``)||`index.html`;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(`/_dashboard{/*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(`Dashboard available`,{url:`/_dashboard/`,dir:t}),!0):!1}export{m as registerDashboardRoutes,f as resolveDashboardDir,p as resolveDashboardRequest};
1
+ import{w as e}from"./startup-maintenance-QrloHssd.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,`..`,`..`,`dashboard`,`dist`):e(`dashboard`)??s(u,`..`,`..`,`dashboard`,`dist`)}function p(e,t){let n=t.replace(/^\/_dashboard\/?/,``)||`index.html`;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(`/_dashboard{/*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(`Dashboard available`,{url:`/_dashboard/`,dir:t}),!0):!1}export{m as registerDashboardRoutes,f as resolveDashboardDir,p as resolveDashboardRequest};
@@ -351,4 +351,4 @@ svg text{fill:var(--body);font-family:var(--sans);font-size:12px}
351
351
  <\/script>
352
352
  </body>
353
353
  </html>`}const U=`<!-- DIAGRAM:SVG -->`;function W(e){let t=e.indexOf(U);if(t===-1)return null;let n=t+20,r=e.indexOf(U,n);if(r===-1)return null;let i=e.slice(n,r).trim();if(i.startsWith(`<svg`))return i;let a=e.slice(Math.max(0,t),r+20),o=a.match(/viewBox="([^"]+)"/),s=o?o[1]:`0 0 1200 800`,c=a.match(/width="(\d+)"/),l=c?c[1]:`1200`,u=a.match(/height="(\d+)"/);return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${s}" width="${l}" height="${u?u[1]:`800`}">`,` <defs>`,` <style>`,` text { font-family: system-ui, -apple-system, sans-serif; }`,` .title { font-size: 20px; font-weight: 600; fill: #fff; }`,` .subtitle { font-size: 14px; fill: #94a3b8; }`,` </style>`,` </defs>`,i,`</svg>`].join(`
354
- `)}function he(e){let t=e.match(/<title>([^<]+)<\/title>/);return t?t[1]:`diagram`}async function ge(e,t,n){let r=m(n);await h(r,{recursive:!0});let i=he(e).replace(/[^a-zA-Z0-9\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).toLowerCase().slice(0,80)||`diagram`,a=p(r,`${i}.html`);await g(a,e,`utf-8`);let o=null,s=W(e);s&&(o=p(r,`${i}.svg`),await g(o,s,`utf-8`));let c=null;return t&&(c=p(r,`${i}.md`),await g(c,t,`utf-8`)),{htmlPath:a,svgPath:o,mdPath:c}}const G=10*1024*1024,K=2e3;function _e(e){try{return JSON.stringify(e)}catch{return``}}function ve(e){switch(e.diagram_type){case`architecture`:return ae(e);case`workflow`:return H(e);case`sequence`:return R(e);case`dataflow`:return ce(e);case`lifecycle`:return P(e)}}function q(e,t={}){Y(e);let n=J(e);if(n.length>0)throw Error(`Diagram validation failed: ${n.join(`; `)}`);let r=t.title??e.meta.title,i=t.subtitle??e.meta.subtitle,a=t.dualOutput??!0,{svg:o,cardsHtml:s,detailData:c}=ve(e),l=c&&Object.keys(c).length>0?`\n<script id="diagram-node-data" type="application/json">${_e(c)}<\/script>`:``,u=e.meta?.palette===`warm`?`warm`:`technical`;return{html:me().replaceAll(`[TITLE]`,X(r)).replaceAll(`[SUBTITLE]`,X(i??``)).replaceAll(`[PALETTE]`,u===`warm`?` data-palette="warm"`:``).replaceAll(`<!-- DIAGRAM:SVG -->`,o).replaceAll(`<!-- DIAGRAM:CARDS -->`,s).replace(`</body>`,`${l}\n</body>`),markdown:a?_(e):void 0}}function ye(e,t={}){return q(e,{...t,dualOutput:!1}).html}function be(e){return _(e)}function xe(e){try{return Y(e),J(e)}catch(e){return[e.message]}}function J(e){if(!e||typeof e!=`object`)return[`Input must be an object`];if(!e.diagram_type)return[`Missing diagram_type`];if(!e.meta?.title)return[`meta.title is required`];if(e.schema_version!==1)return[`schema_version must be 1`];let t=e.diagram_type,n=e,r=n.components??n.nodes??n.participants??n.states??[],i=n.connections??n.edges??n.messages??n.flows??n.transitions??[],a=new Set(r.map(e=>e.id));if(a.size!==r.length)return[`${t}: Node/component IDs must be unique`];for(let e of i){if(e.from&&!a.has(e.from))return[`${t}: Edge references unknown source "${e.from}"`];if(e.to&&!a.has(e.to))return[`${t}: Edge references unknown target "${e.to}"`]}return[]}function Y(e){let t=JSON.stringify(e),n=Buffer.byteLength(t,`utf-8`);if(n>G)throw Error(`Input too large: ${(n/1024/1024).toFixed(1)}MB (max ${G/1024/1024}MB)`);let r=e,i=r.components??r.nodes??r.participants??[];if(i.length>500)throw Error(`Too many components/nodes: ${i.length} (max 500)`);let a=r.connections??r.edges??r.messages??r.flows??r.transitions??[];if(a.length>K)throw Error(`Too many edges/connections: ${a.length} (max ${K})`)}function Se(e){return e.replace(/[^a-zA-Z0-9-_]/g,`_`).toLowerCase().slice(0,120)}function X(e){let t={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};return String(e??``).replace(/[&<>"']/g,e=>t[e]??e)}const Z=d(`server`);function Q(e,t){return t?{version:e,...f(t)}:{version:e}}function $(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function Ce(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===l(e).href}catch{return!1}}function we(){return Ce()?u({allowPositionals:!0,options:{transport:{type:`string`,default:$()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:$(),port:process.env.AIKIT_PORT??`3210`}}async function Te(){let e=t=>{t.name===`ExperimentalWarning`&&t.message.includes(`SQLite`)||(process.off(`warning`,e),process.emitWarning(t),process.on(`warning`,e))};process.on(`warning`,e);let n=t(),r=we();if(process.on(`unhandledRejection`,e=>{Z.error(`Unhandled rejection`,Q(n,e))}),process.on(`uncaughtException`,e=>{Z.error(`Uncaught exception — exiting`,Q(n,e)),process.exit(1)}),Z.info(`Starting MCP AI Kit server`,{version:n}),r.transport===`http`){let{startHttpMode:e}=await import(`./server-http-DcgFpWra.js`);await e(n,r.port)}else{let{startStdioMode:e}=await import(`./server-stdio-CskpvBew.js`);await e(n)}}export{c as CuratedKnowledgeManager,s as applyWorkspaceRoots,a as bootstrapWorkspaceRoots,i as createSlidingWindowRateLimiter,ge as exportDiagram,W as extractSvg,n as getSessionIdHeader,Te as main,r as readPositiveIntEnv,t as readVersion,ye as renderHtml,be as renderMd,q as renderToResult,e as resolveCorsOrigin,Se as sanitizeTitle,o as selectWorkspaceRoot,xe as validate};
354
+ `)}function he(e){let t=e.match(/<title>([^<]+)<\/title>/);return t?t[1]:`diagram`}async function ge(e,t,n){let r=m(n);await h(r,{recursive:!0});let i=he(e).replace(/[^a-zA-Z0-9\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).toLowerCase().slice(0,80)||`diagram`,a=p(r,`${i}.html`);await g(a,e,`utf-8`);let o=null,s=W(e);s&&(o=p(r,`${i}.svg`),await g(o,s,`utf-8`));let c=null;return t&&(c=p(r,`${i}.md`),await g(c,t,`utf-8`)),{htmlPath:a,svgPath:o,mdPath:c}}const G=10*1024*1024,K=2e3;function _e(e){try{return JSON.stringify(e)}catch{return``}}function ve(e){switch(e.diagram_type){case`architecture`:return ae(e);case`workflow`:return H(e);case`sequence`:return R(e);case`dataflow`:return ce(e);case`lifecycle`:return P(e)}}function q(e,t={}){Y(e);let n=J(e);if(n.length>0)throw Error(`Diagram validation failed: ${n.join(`; `)}`);let r=t.title??e.meta.title,i=t.subtitle??e.meta.subtitle,a=t.dualOutput??!0,{svg:o,cardsHtml:s,detailData:c}=ve(e),l=c&&Object.keys(c).length>0?`\n<script id="diagram-node-data" type="application/json">${_e(c)}<\/script>`:``,u=e.meta?.palette===`warm`?`warm`:`technical`;return{html:me().replaceAll(`[TITLE]`,X(r)).replaceAll(`[SUBTITLE]`,X(i??``)).replaceAll(`[PALETTE]`,u===`warm`?` data-palette="warm"`:``).replaceAll(`<!-- DIAGRAM:SVG -->`,o).replaceAll(`<!-- DIAGRAM:CARDS -->`,s).replace(`</body>`,`${l}\n</body>`),markdown:a?_(e):void 0}}function ye(e,t={}){return q(e,{...t,dualOutput:!1}).html}function be(e){return _(e)}function xe(e){try{return Y(e),J(e)}catch(e){return[e.message]}}function J(e){if(!e||typeof e!=`object`)return[`Input must be an object`];if(!e.diagram_type)return[`Missing diagram_type`];if(!e.meta?.title)return[`meta.title is required`];if(e.schema_version!==1)return[`schema_version must be 1`];let t=e.diagram_type,n=e,r=n.components??n.nodes??n.participants??n.states??[],i=n.connections??n.edges??n.messages??n.flows??n.transitions??[],a=new Set(r.map(e=>e.id));if(a.size!==r.length)return[`${t}: Node/component IDs must be unique`];for(let e of i){if(e.from&&!a.has(e.from))return[`${t}: Edge references unknown source "${e.from}"`];if(e.to&&!a.has(e.to))return[`${t}: Edge references unknown target "${e.to}"`]}return[]}function Y(e){let t=JSON.stringify(e),n=Buffer.byteLength(t,`utf-8`);if(n>G)throw Error(`Input too large: ${(n/1024/1024).toFixed(1)}MB (max ${G/1024/1024}MB)`);let r=e,i=r.components??r.nodes??r.participants??[];if(i.length>500)throw Error(`Too many components/nodes: ${i.length} (max 500)`);let a=r.connections??r.edges??r.messages??r.flows??r.transitions??[];if(a.length>K)throw Error(`Too many edges/connections: ${a.length} (max ${K})`)}function Se(e){return e.replace(/[^a-zA-Z0-9-_]/g,`_`).toLowerCase().slice(0,120)}function X(e){let t={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};return String(e??``).replace(/[&<>"']/g,e=>t[e]??e)}const Z=d(`server`);function Q(e,t){return t?{version:e,...f(t)}:{version:e}}function $(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}function Ce(){let e=process.argv[1];if(!e)return!1;try{return import.meta.url===l(e).href}catch{return!1}}function we(){return Ce()?u({allowPositionals:!0,options:{transport:{type:`string`,default:$()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}).values:{transport:$(),port:process.env.AIKIT_PORT??`3210`}}async function Te(){let e=t=>{t.name===`ExperimentalWarning`&&t.message.includes(`SQLite`)||(process.off(`warning`,e),process.emitWarning(t),process.on(`warning`,e))};process.on(`warning`,e);let n=t(),r=we();if(process.on(`unhandledRejection`,e=>{Z.error(`Unhandled rejection`,Q(n,e))}),process.on(`uncaughtException`,e=>{Z.error(`Uncaught exception — exiting`,Q(n,e)),process.exit(1)}),Z.info(`Starting MCP AI Kit server`,{version:n}),r.transport===`http`){let{startHttpMode:e}=await import(`./server-http-agZcmQoQ.js`);await e(n,r.port)}else{let{startStdioMode:e}=await import(`./server-stdio-BpzUm6FP.js`);await e(n)}}export{c as CuratedKnowledgeManager,s as applyWorkspaceRoots,a as bootstrapWorkspaceRoots,i as createSlidingWindowRateLimiter,ge as exportDiagram,W as extractSvg,n as getSessionIdHeader,Te as main,r as readPositiveIntEnv,t as readVersion,ye as renderHtml,be as renderMd,q as renderToResult,e as resolveCorsOrigin,Se as sanitizeTitle,o as selectWorkspaceRoot,xe as validate};