aegiscode 5.1.3 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1059,7 +1059,7 @@ ${N}`,metadata:{serverName:I,toolName:G.name,mcpResult:n}}}catch(n){let Z=n.mess
|
|
|
1059
1059
|
`;await dn.appendFile(this.filePath,G,"utf-8")}async appendBatch(I){if(I.length===0)return;await dn.mkdir(q_.dirname(this.filePath),{recursive:!0});let G=I.map(c=>JSON.stringify(c)).join(`
|
|
1060
1060
|
`)+`
|
|
1061
1061
|
`;await dn.appendFile(this.filePath,G,"utf-8")}async readAll(){if(!this.exists())return[];let G=(await dn.readFile(this.filePath,"utf-8")).split(`
|
|
1062
|
-
`).filter(e=>e.trim().length>0),c=[];for(let e of G)try{c.push(JSON.parse(e))}catch{console.warn(`[JSONLStore] \u89E3\u6790 JSON \u884C\u5931\u8D25: ${e.substring(0,100)}...`)}return c}async readStream(I){return new Promise((G,c)=>{if(!this.exists()){G();return}let e=Ptl(this.filePath,{encoding:"utf-8"}),t=_tl({input:e,crlfDelay:Number.POSITIVE_INFINITY}),a=async n=>{let Z=n.trim();if(Z.length!==0)try{let N=JSON.parse(Z);await I(N)}catch{console.warn(`[JSONLStore] \u89E3\u6790\u5931\u8D25: ${Z.substring(0,50)}...`)}};t.on("line",n=>{a(n).catch(c)}),t.on("close",()=>G()),t.on("error",c),e.on("error",c)})}async readLast(I){return(await this.readAll()).slice(-I)}async filter(I){return(await this.readAll()).filter(I)}async count(){if(!this.exists())return 0;let I=0;return await this.readStream(()=>{I++}),I}async readAfterCompaction(){let I=await this.readAll(),G=-1;for(let c=I.length-1;c>=0;c--)if(I[c].subtype==="compact_boundary"){G=c;break}return G===-1?I:I.slice(G)}async clear(){this.exists()&&await dn.writeFile(this.filePath,"","utf-8")}async delete(){this.exists()&&await dn.unlink(this.filePath)}async getFileSize(){return this.exists()?(await dn.stat(this.filePath)).size:0}}});var qvI={};qG(qvI,{default:()=>$_});var $_,__=L(()=>{$_={name:"aegiscode",version:"5.1.
|
|
1062
|
+
`).filter(e=>e.trim().length>0),c=[];for(let e of G)try{c.push(JSON.parse(e))}catch{console.warn(`[JSONLStore] \u89E3\u6790 JSON \u884C\u5931\u8D25: ${e.substring(0,100)}...`)}return c}async readStream(I){return new Promise((G,c)=>{if(!this.exists()){G();return}let e=Ptl(this.filePath,{encoding:"utf-8"}),t=_tl({input:e,crlfDelay:Number.POSITIVE_INFINITY}),a=async n=>{let Z=n.trim();if(Z.length!==0)try{let N=JSON.parse(Z);await I(N)}catch{console.warn(`[JSONLStore] \u89E3\u6790\u5931\u8D25: ${Z.substring(0,50)}...`)}};t.on("line",n=>{a(n).catch(c)}),t.on("close",()=>G()),t.on("error",c),e.on("error",c)})}async readLast(I){return(await this.readAll()).slice(-I)}async filter(I){return(await this.readAll()).filter(I)}async count(){if(!this.exists())return 0;let I=0;return await this.readStream(()=>{I++}),I}async readAfterCompaction(){let I=await this.readAll(),G=-1;for(let c=I.length-1;c>=0;c--)if(I[c].subtype==="compact_boundary"){G=c;break}return G===-1?I:I.slice(G)}async clear(){this.exists()&&await dn.writeFile(this.filePath,"","utf-8")}async delete(){this.exists()&&await dn.unlink(this.filePath)}async getFileSize(){return this.exists()?(await dn.stat(this.filePath)).size:0}}});var qvI={};qG(qvI,{default:()=>$_});var $_,__=L(()=>{$_={name:"aegiscode",version:"5.1.4",description:"AEGIS CLI \u2014 AI-powered coding assistant",type:"module",bin:{aegis:"bin/cli.js","aegis-cli":"bin/cli.js",aegiscli:"bin/cli.js",aegiscode:"bin/cli.js"},scripts:{preinstall:"node scripts/ensure-node-version.mjs",build:"node esbuild.mjs","build:publish":"npm run build && node scripts/make-bin.mjs",dev:"NODE_NO_WARNINGS=1 tsx src/main.tsx",start:"node --no-deprecation dist/main.js",typecheck:"tsc --noEmit","test:prompts":"tsx src/prompts/test.ts","test:tools":"tsx src/tools/test.ts","test:pipeline":"tsx src/tools/execution/test.ts","test:context":"tsx src/context/test.ts","test:mcp":"tsx src/mcp/test.ts","test:store":"tsx src/store/test.ts"},keywords:["cli","ai","coding-agent","llm","openai","gpt","claude","copilot","assistant","terminal","developer-tools"],author:"Niklas Borneklint",license:"MIT",repository:{type:"git",url:"git+https://github.com/aegisinfo/aegiscode.git"},homepage:"https://github.com/aegisinfo/aegiscode#readme",bugs:{url:"https://github.com/aegisinfo/aegiscode/issues"},files:["bin/","scripts/","README.md","LICENSE"],engines:{node:">=18.0.0"},dependencies:{"@huggingface/transformers":"^3.8.1","@modelcontextprotocol/sdk":"^1.25.3",chalk:"^5.4.1",dotenv:"^17.4.2","fuse.js":"^7.4.1",glob:"^13.0.0",ink:"^7.0.5","ink-text-input":"^6.0.0","js-tiktoken":"^1.0.21",lowlight:"^3.3.0",minimatch:"^10.1.1",nanoid:"^5.1.6",openai:"^4.77.0",react:"^19.2.7","react-dom":"^19.2.7","sql.js":"^1.14.1","string-width":"^7.2.0",uuid:"^14.0.0",yaml:"^2.8.2",yargs:"^17.7.2",zod:"^3.24.2","zod-to-json-schema":"^3.25.1",zustand:"^5.0.14"},devDependencies:{"@types/node":"^22.19.19","@types/react":"^19.2.17","@types/sql.js":"^1.4.11","@types/yargs":"^17.0.35",esbuild:"^0.28.0",tsx:"^4.22.4",typescript:"^5.7.2"},overrides:{"string-width":"^7.2.0","slice-ansi":"^7.1.2","cli-truncate":"^4.0.0","cli-boxes":"^3.0.0"}}});var PvI,GV,_vI=L(async()=>{"use strict";is();P_();vg();PvI="0.1.0";try{PvI=(await Promise.resolve().then(()=>(__(),qvI))).default.version||"0.1.0"}catch{}GV=class{projectPath;maxSessions;version;constructor(I=process.cwd(),G=100){this.projectPath=I,this.maxSessions=G,this.version=PvI}getStore(I){let G=Qg(this.projectPath,I);return new lV(G)}async saveMessage(I,G,c,e=null,t){let a=this.getStore(I),n={uuid:_c(),parentUuid:e,sessionId:I,timestamp:new Date().toISOString(),type:G,cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:G,content:c,...t||{}}};return await a.append(n),n.uuid}async saveToolUse(I,G,c,e,t=null){let a=this.getStore(I),n={uuid:_c(),parentUuid:t,sessionId:I,timestamp:new Date().toISOString(),type:"tool_use",cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:"assistant",content:""},tool:{id:G,name:c,input:e}};return await a.append(n),n.uuid}async saveToolResult(I,G,c,e,t=null){let a=this.getStore(I),n={uuid:_c(),parentUuid:t,sessionId:I,timestamp:new Date().toISOString(),type:"tool_result",cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:"assistant",content:""},toolResult:{id:G,output:c,error:e}};return await a.append(n),n.uuid}async saveCompaction(I,G,c,e=null){let t=this.getStore(I),a={uuid:_c(),parentUuid:e,sessionId:I,timestamp:new Date().toISOString(),type:"system",subtype:"compact_boundary",cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:"system",content:"=== \u4E0A\u4E0B\u6587\u538B\u7F29\u8FB9\u754C ==="},compactMetadata:c};await t.append(a);let n={uuid:_c(),parentUuid:a.uuid,sessionId:I,timestamp:new Date().toISOString(),type:"user",isCompactSummary:!0,cwd:this.projectPath,version:this.version,message:{role:"user",content:G},compactMetadata:c};return await t.append(n),n.uuid}async loadSession(I){let G=this.getStore(I);if(!G.exists())return null;let c=await G.readAll();if(c.length===0)return null;let e=c[0];return{sessionId:I,preferences:{},startTime:new Date(e.timestamp).getTime()}}async loadConversation(I){let G=this.getStore(I);if(!G.exists())return null;let c=await G.readAfterCompaction(),e=[],t=0;for(let a of c){let n=new Date(a.timestamp).getTime();n>t&&(t=n),a.subtype!=="compact_boundary"&&(a.type==="user"||a.type==="assistant"||a.type==="system")&&e.push({id:a.uuid,role:a.message.role,content:typeof a.message.content=="string"?a.message.content:JSON.stringify(a.message.content),timestamp:n,metadata:a.isCompactSummary?{isCompactSummary:!0}:void 0})}return{messages:e,topics:[],lastActivity:t}}async listSessions(){let{readdir:I}=await import("node:fs/promises"),{getProjectStoragePath:G}=await Promise.resolve().then(()=>(vg(),nrI)),c=G(this.projectPath);try{return(await I(c)).filter(t=>t.endsWith(".jsonl")).map(t=>t.replace(".jsonl",""))}catch{return[]}}async deleteSession(I){await this.getStore(I).delete()}async getSessionStats(I){let G=this.getStore(I);if(!G.exists())return null;let c=await G.readAll(),e=await G.getFileSize();return c.length===0?{messageCount:0,fileSize:e,createdAt:null,lastUpdatedAt:null}:{messageCount:c.length,fileSize:e,createdAt:new Date(c[0].timestamp),lastUpdatedAt:new Date(c[c.length-1].timestamp)}}}});var cV,$vI=L(()=>{"use strict";cV=class{cache=new Map;maxSize;defaultTtl;constructor(I=100,G=300*1e3){this.maxSize=I,this.defaultTtl=G}set(I,G,c){this.cache.size>=this.maxSize&&!this.cache.has(I)&&this.evictLRU();let e=Date.now();this.cache.set(I,{value:G,createdAt:e,lastAccessedAt:e,ttl:c??this.defaultTtl})}get(I){let G=this.cache.get(I);if(!G)return;let c=Date.now();if(c-G.createdAt>G.ttl){this.cache.delete(I);return}return G.lastAccessedAt=c,G.value}has(I){let G=this.cache.get(I);return G?Date.now()-G.createdAt>G.ttl?(this.cache.delete(I),!1):!0:!1}delete(I){return this.cache.delete(I)}async getOrSet(I,G,c){let e=this.get(I);if(e!==void 0)return e;let t=await G();return this.set(I,t,c),t}evictLRU(){let I=null,G=1/0;for(let[c,e]of this.cache)e.lastAccessedAt<G&&(G=e.lastAccessedAt,I=c);I&&this.cache.delete(I)}cleanup(){let I=Date.now(),G=0;for(let[c,e]of this.cache)I-e.createdAt>e.ttl&&(this.cache.delete(c),G++);return G}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return Array.from(this.cache.keys())}getStats(){return{size:this.cache.size,maxSize:this.maxSize}}}});var I$=L(async()=>{"use strict";TvI();await _vI();$vI();P_();vg()});import*as lA from"node:fs/promises";import{existsSync as l$}from"node:fs";import*as qo from"node:path";var eV,G$=L(()=>{"use strict";eV=class{static MAX_FILES=5;static MAX_LINES_PER_FILE=1e3;static MAX_CHARS_PER_FILE=5e4;static analyzeFiles(I){let G=new Map;return I.forEach((c,e)=>{if(c.content){let t=typeof c.content=="string"?c.content:JSON.stringify(c.content);this.extractFilePathsFromContent(t).forEach(n=>{this.updateFileReference(G,n,e,!1)})}if(c.tool_calls&&Array.isArray(c.tool_calls))for(let t of c.tool_calls){let a=this.extractFilePathsFromToolCall(t),n=["Write","Edit"].includes(t.function?.name||"");a.forEach(Z=>{this.updateFileReference(G,Z,e,n)})}}),Array.from(G.values()).filter(c=>this.isValidFilePath(c.path)).sort((c,e)=>c.wasModified!==e.wasModified?c.wasModified?-1:1:c.mentions!==e.mentions?e.mentions-c.mentions:e.lastMentioned-c.lastMentioned).slice(0,this.MAX_FILES)}static extractFilePathsFromContent(I){let G=[],c=[/(?:^|\s|["'`])(\/?(?:[\w.-]+\/)+[\w.-]+\.[a-zA-Z]{1,10})(?:\s|$|["'`]|:)/gm,/(?:^|\s|["'`])(\.\/(?:[\w.-]+\/)*[\w.-]+\.[a-zA-Z]{1,10})(?:\s|$|["'`]|:)/gm,/```\d+:\d+:([\w./-]+)/gm];for(let e of c){let t;for(;(t=e.exec(I))!==null;){let a=t[1];a&&!G.includes(a)&&G.push(a)}}return G}static extractFilePathsFromToolCall(I){let G=[],c=I.function?.name,e={};try{typeof I.function?.arguments=="string"?e=JSON.parse(I.function.arguments):I.function?.arguments&&(e=I.function.arguments)}catch{return G}if(["Read","Write","Edit","Glob","Grep","NotebookEdit"].includes(c||"")){let a=["file_path","path","notebook_path","filePath"];for(let n of a)e[n]&&typeof e[n]=="string"&&G.push(e[n])}return G}static updateFileReference(I,G,c,e){let t=I.get(G);t?(t.mentions++,t.lastMentioned=Math.max(t.lastMentioned,c),t.wasModified=t.wasModified||e):I.set(G,{path:G,mentions:1,lastMentioned:c,wasModified:e})}static isValidFilePath(I){let G=[/^https?:\/\//,/^node_modules\//,/^\.git\//,/\.(png|jpg|jpeg|gif|svg|ico|webp|mp4|mp3|wav|pdf|zip|tar|gz)$/i];for(let c of G)if(c.test(I))return!1;try{let c=qo.isAbsolute(I)?I:qo.join(process.cwd(),I);return l$(c)}catch{return!1}}static async readFilesContent(I){let G=[];for(let c of I)try{let e=qo.isAbsolute(c)?c:qo.join(process.cwd(),c);if(!l$(e))continue;let t=await lA.readFile(e,"utf-8"),a=t.split(`
|
|
1063
1063
|
`),n=!1,Z=t;a.length>this.MAX_LINES_PER_FILE&&(Z=a.slice(0,this.MAX_LINES_PER_FILE).join(`
|
|
1064
1064
|
`),n=!0),Z.length>this.MAX_CHARS_PER_FILE&&(Z=Z.substring(0,this.MAX_CHARS_PER_FILE),n=!0),n&&(Z+=`
|
|
1065
1065
|
|