@vpxa/aikit 0.1.246 → 0.1.248

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