@vpxa/aikit 0.1.234 → 0.1.236

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.
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as e,t}from"./retention-C3tsarCT.js";import{o as n,t as r}from"./supersession-DO_ZROFl.js";import{existsSync as i,readFileSync as a,writeFileSync as o}from"node:fs";import{dirname as s,resolve as c}from"node:path";import{fileURLToPath as l}from"node:url";import{AIKIT_PATHS as u,EMBEDDING_DEFAULTS as d,createLogger as f,getPartitionDir as p,isUserInstalled as m,registerWorkspace as h,serializeError as g}from"../../core/dist/index.js";const _=s(l(import.meta.url)),v=f(`server`),y=[`auto`,`manual`,`smart`],b={model:d.model,dimensions:d.dimensions,childProcess:!0,idleTimeoutMs:6e4};function x(e){return typeof e==`string`&&y.includes(e)}function S(e,t,n){let r=c(e),i=c(t);if(!r.startsWith(i))throw Error(`Config ${n} path escapes workspace root: ${e} is not under ${t}`);return r}function C(e){let t=process.env.AIKIT_INDEX_MODE;if(x(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 w(){let o=process.env.AIKIT_CONFIG_PATH??(i(c(process.cwd(),`aikit.config.json`))?c(process.cwd(),`aikit.config.json`):c(_,`..`,`..`,`..`,`aikit.config.json`));try{if(!i(o))return v.info(`No config file found, using defaults`,{configPath:o}),E();let l=a(o,`utf-8`),d=JSON.parse(l);if(d.embedding={...b,...d.embedding},d.memory={retention:{...t,...d.memory?.retention},lessons:{...n,...d.memory?.lessons},consolidation:{...e,...d.memory?.consolidation},supersession:{...r,...d.memory?.supersession}},!d.sources||!Array.isArray(d.sources)||d.sources.length===0)throw Error(`Config must have at least one source`);if(!d.store?.path)throw Error(`Config must specify store.path`);if(d.autoIndex!==void 0&&typeof d.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(d.indexMode!==void 0&&!x(d.indexMode))throw Error(`Config indexMode must be one of: ${y.join(`, `)}`);let f=s(o);return d.sources=d.sources.map(e=>({...e,path:S(c(f,e.path),f,`source`)})),d.store.path=S(c(f,d.store.path),f,`store`),d.curated=d.curated??{path:u.aiCurated},d.curated.path=S(c(f,d.curated.path),f,`curated`),O(d,f),D(d,o),d.indexMode=C(d),d}catch(e){return v.error(`Failed to load config`,{configPath:o,...g(e)}),v.warn(`Falling back to default configuration`,{configPath:o}),E()}}const T=[`.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 E(){let i=process.env.AIKIT_WORKSPACE_ROOT??process.cwd(),a={sources:[{path:i,excludePatterns:[...T]}],serverName:`aikit`,indexing:{chunkSize:1500,chunkOverlap:200,minChunkSize:100},embedding:{...b},store:{backend:`sqlite-vec`,path:c(i,u.data)},curated:{path:c(i,u.aiCurated)},memory:{retention:{...t},lessons:{...n},consolidation:{...e},supersession:{...r}},onboardDir:c(i,u.aiContext),stateDir:c(i,u.state)};return O(a,i),a.indexMode=C(a),a}function D(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 T)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{o(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),v.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){v.warn(`Failed to write upgraded config`,{configPath:t,...g(e)})}return e}function O(e,t){if(!m())return;let n=h(t);e.store.path=c(p(n.partition)),e.onboardDir=c(p(n.partition),`onboard`),e.stateDir=c(p(n.partition),`state`),e.curated={path:c(p(n.partition),`curated`)}}function k(e,t){if(!i(t))throw Error(`Workspace root does not exist: ${t}`);v.info(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),v.info(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){v.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...g(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],e.store.path=c(t,u.data),e.curated={path:c(t,u.aiCurated)},e.onboardDir=c(t,u.aiContext),e.stateDir=c(t,u.state),O(e,t)}export{T as DEFAULT_EXCLUDE_PATTERNS,w as loadConfig,k as reconfigureForWorkspace,C as resolveIndexMode};
@@ -1 +0,0 @@
1
- import{a as e,t}from"./retention-B4ITAs7F.js";import{o as n,t as r}from"./supersession-CWEne3av.js";import{existsSync as i,readFileSync as a,writeFileSync as o}from"node:fs";import{dirname as s,resolve as c}from"node:path";import{fileURLToPath as l}from"node:url";import{AIKIT_PATHS as u,EMBEDDING_DEFAULTS as d,createLogger as f,getPartitionDir as p,isUserInstalled as m,registerWorkspace as h,serializeError as g}from"../../core/dist/index.js";const _=s(l(import.meta.url)),v=f(`server`),y=[`auto`,`manual`,`smart`],b={model:d.model,dimensions:d.dimensions,childProcess:!0,idleTimeoutMs:6e4};function x(e){return typeof e==`string`&&y.includes(e)}function S(e,t,n){let r=c(e),i=c(t);if(!r.startsWith(i))throw Error(`Config ${n} path escapes workspace root: ${e} is not under ${t}`);return r}function C(e){let t=process.env.AIKIT_INDEX_MODE;if(x(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 w(){let o=process.env.AIKIT_CONFIG_PATH??(i(c(process.cwd(),`aikit.config.json`))?c(process.cwd(),`aikit.config.json`):c(_,`..`,`..`,`..`,`aikit.config.json`));try{if(!i(o))return v.info(`No config file found, using defaults`,{configPath:o}),E();let l=a(o,`utf-8`),d=JSON.parse(l);if(d.embedding={...b,...d.embedding},d.memory={retention:{...t,...d.memory?.retention},lessons:{...n,...d.memory?.lessons},consolidation:{...e,...d.memory?.consolidation},supersession:{...r,...d.memory?.supersession}},!d.sources||!Array.isArray(d.sources)||d.sources.length===0)throw Error(`Config must have at least one source`);if(!d.store?.path)throw Error(`Config must specify store.path`);if(d.autoIndex!==void 0&&typeof d.autoIndex!=`boolean`)throw Error(`Config autoIndex must be a boolean`);if(d.indexMode!==void 0&&!x(d.indexMode))throw Error(`Config indexMode must be one of: ${y.join(`, `)}`);let f=s(o);return d.sources=d.sources.map(e=>({...e,path:S(c(f,e.path),f,`source`)})),d.store.path=S(c(f,d.store.path),f,`store`),d.curated=d.curated??{path:u.aiCurated},d.curated.path=S(c(f,d.curated.path),f,`curated`),O(d,f),D(d,o),d.indexMode=C(d),d}catch(e){return v.error(`Failed to load config`,{configPath:o,...g(e)}),v.warn(`Falling back to default configuration`,{configPath:o}),E()}}const T=[`.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 E(){let i=process.env.AIKIT_WORKSPACE_ROOT??process.cwd(),a={sources:[{path:i,excludePatterns:[...T]}],serverName:`aikit`,indexing:{chunkSize:1500,chunkOverlap:200,minChunkSize:100},embedding:{...b},store:{backend:`sqlite-vec`,path:c(i,u.data)},curated:{path:c(i,u.aiCurated)},memory:{retention:{...t},lessons:{...n},consolidation:{...e},supersession:{...r}},onboardDir:c(i,u.aiContext),stateDir:c(i,u.state)};return O(a,i),a.indexMode=C(a),a}function D(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 T)e.has(n)||t.excludePatterns.push(n)}e.configVersion=1;try{o(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`),v.info(`Config auto-upgraded`,{from:n,to:1,configPath:t})}catch(e){v.warn(`Failed to write upgraded config`,{configPath:t,...g(e)})}return e}function O(e,t){if(!m())return;let n=h(t);e.store.path=c(p(n.partition)),e.onboardDir=c(p(n.partition),`onboard`),e.stateDir=c(p(n.partition),`state`),e.curated={path:c(p(n.partition),`curated`)}}function k(e,t){if(!i(t))throw Error(`Workspace root does not exist: ${t}`);v.info(`Reconfiguring for workspace root`,{workspaceRoot:t});try{process.chdir(t),v.info(`Changed process cwd to workspace root`,{cwd:process.cwd()})}catch(e){v.warn(`Failed to chdir to workspace root`,{workspaceRoot:t,...g(e)})}e.sources=[{path:t,excludePatterns:e.sources[0]?.excludePatterns??[`node_modules/**`,`dist/**`,`.git/**`,`coverage/**`,`*.lock`,`pnpm-lock.yaml`]}],e.store.path=c(t,u.data),e.curated={path:c(t,u.aiCurated)},e.onboardDir=c(t,u.aiContext),e.stateDir=c(t,u.state),O(e,t)}export{T as DEFAULT_EXCLUDE_PATTERNS,w as loadConfig,k as reconfigureForWorkspace,C as resolveIndexMode};