@aiiware/aii 0.2.5 → 0.2.6

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 (2) hide show
  1. package/bin/aii +6 -6
  2. package/package.json +1 -1
package/bin/aii CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @aiiware/aii v0.2.5
3
+ * @aiiware/aii v0.2.6
4
4
  *
5
5
  * AI-powered CLI assistant for terminal productivity
6
6
  *
@@ -35,7 +35,7 @@ Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,o=>{let
35
35
  ${t}
36
36
  </context>
37
37
 
38
- ${e}`:e}});var XE=_(Qf=>{"use strict";Object.defineProperty(Qf,"__esModule",{value:!0});Qf.createParser=YE;Qf.parseArgs=Fz;var JE=KE(),HE=Xf(),Nz="0.2.5";function YE(){let t=new JE.Command;return t.name("aii").description("AI-powered CLI assistant").version(Nz,"-V, --version","Show version number").helpOption(!1).enablePositionalOptions().argument("[query...]","Natural language query").option("--clean","Clean output mode (just the result)").option("--standard","Standard output mode (result + metrics)").option("--thinking","Thinking mode (full reasoning)").option("-v, --verbose","Verbose output (alias for --thinking)").option("-d, --debug","Debug output").option("--model <model>","Override LLM model").option("--host <host>","API server host:port").option("-y, --yes","Auto-confirm shell commands").option("--offline","Offline mode (no web/MCP)").option("-i, --interactive","Interactive chat mode").option("-c, --continue-chat <id>","Continue chat session").option("-n, --new-chat","Force new chat session").option("--auto","Auto mode - auto-approve all actions").option("-q, --quiet","Quiet mode - minimal output").option("--no-colors","Disable colored output").option("--no-emojis","Disable emoji icons").option("--no-animations","Disable animations").option("--no-streaming","Disable streaming").option("--show-tokens","Show token usage").option("--show-cost","Show cost estimates").option("-h, --help","Show help"),t.command("config").description("Configuration management").argument("[action]","Action: init, show, validate, set").argument("[key]","Config key (for set)").argument("[value]","Config value (for set)").action(()=>{}),t.command("mcp").description("MCP server management").argument("[action]","Action: list, add, remove, status, etc.").argument("[rest...]","Server name and arguments").passThroughOptions().action(()=>{}),t.command("prompt").description("Prompt library").argument("[action]","Action: list, show, use, create").argument("[rest...]","Prompt name and arguments").allowUnknownOption().action(()=>{}),t.command("stats").description("Usage statistics").argument("[type]","Type: models, cost").action(()=>{}),t.command("history").description("Chat history").argument("[action]","Action: list, search, export, delete").argument("[query]","Search query or ID").action(()=>{}),t.command("doctor").description("System health check").action(()=>{}),t.command("chat").description("Interactive chat mode").action(()=>{}),t.command("agent").description("Interactive agent mode with tool execution").argument("[query...]","Optional query (non-interactive if provided)").action(()=>{}),t.command("run").description("Run domain-specific operations").argument("<operation>","Operation (e.g., git commit)").argument("[args...]","Additional arguments").allowUnknownOption().action(()=>{}),t.command("help").description("display help for command").argument("[command]","Command to show help for").action(()=>{}),t.command("version").description("Show version number").action(()=>{}),t}async function Fz(t){let e=YE();e.exitOverride(),e.configureOutput({writeErr:()=>{}});let r="query",n,i=[];try{e.parse(t),i=e.args;let c=e.args[0];c&&["config","mcp","prompt","stats","history","doctor","chat","run","help","version","agent"].includes(c)&&(r=c,n=e.args[1],i=e.args.slice(2))}catch(c){c instanceof JE.CommanderError&&(c.code==="commander.version"||c.code==="commander.helpDisplayed")&&process.exit(0),i=t.slice(2)}let o=e.opts(),s={clean:o.clean??!1,standard:o.standard??!1,thinking:o.thinking??!1,verbose:o.verbose??!1,debug:o.debug??!1,model:o.model,host:o.host,yes:o.yes??!1,offline:o.offline??!1,interactive:o.interactive??!1,continueChat:o.continueChat,newChat:o.newChat??!1,auto:o.auto??!1,quiet:o.quiet??!1,noColors:!o.colors,noEmojis:!o.emojis,noAnimations:!o.animations,noStreaming:!o.streaming,showTokens:o.showTokens??!1,showCost:o.showCost??!1,help:o.help??!1,version:o.version??!1},a;(0,HE.hasStdinInput)()&&(a=await(0,HE.readStdin)()),(r==="chat"||s.interactive)&&(r="agent"),r==="query"&&!i.length&&!a&&(r="agent");let u;if(r==="query"&&i.length>0)u=i.join(" ");else if(r==="agent"){let c=[];n&&c.push(n),i.length>0&&c.push(...i),c.length>0&&(u=c.join(" "))}return{command:r,subcommand:n,args:i,flags:s,stdinContent:a,query:u}}});var Hc=_(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.COMMAND_TIERS=nn.DEFAULT_OUTPUT_MODES=nn.CommandTier=void 0;nn.resolveOutputMode=Rz;var Sr;(function(t){t[t.LOCAL=1]="LOCAL",t[t.SERVER=2]="SERVER"})(Sr||(nn.CommandTier=Sr={}));nn.DEFAULT_OUTPUT_MODES={translate:"clean",shell:"clean",shell_generate:"clean",mcp:"standard",explain:"standard",code_generate:"standard",code_review:"standard",summarize:"standard",research:"standard",_default:"standard"};function Rz(t,e,r,n){return t.clean?"clean":t.thinking||t.verbose?"thinking":t.standard?"standard":e&&r?.[e]?r[e]:e&&nn.DEFAULT_OUTPUT_MODES[e]?nn.DEFAULT_OUTPUT_MODES[e]:n||nn.DEFAULT_OUTPUT_MODES._default}nn.COMMAND_TIERS={config:Sr.LOCAL,help:Sr.LOCAL,version:Sr.LOCAL,doctor:Sr.LOCAL,mcp:Sr.LOCAL,prompt:Sr.LOCAL,stats:Sr.LOCAL,history:Sr.LOCAL,query:Sr.SERVER,chat:Sr.SERVER,run:Sr.SERVER,agent:Sr.SERVER}});var QE=_(Fy=>{"use strict";Object.defineProperty(Fy,"__esModule",{value:!0});Fy.routeCommand=xz;var xr=Hc();function xz(t){let e=xr.COMMAND_TIERS[t.command]??xr.CommandTier.SERVER;switch(t.command){case"config":return qz(t);case"mcp":return Lz(t);case"prompt":return Zz(t);case"stats":return Uz(t);case"history":return zz(t);case"doctor":return{tier:xr.CommandTier.LOCAL,handler:"doctor",params:{}};case"chat":return{tier:xr.CommandTier.SERVER,handler:"chat",params:{continueChat:t.flags.continueChat}};case"run":return Bz(t);case"agent":return{tier:xr.CommandTier.SERVER,handler:"agent",params:{interactive:!t.query}};case"help":return{tier:xr.CommandTier.LOCAL,handler:"help",params:{command:t.subcommand}};case"version":return{tier:xr.CommandTier.LOCAL,handler:"version",params:{}};case"query":default:return{tier:e,handler:"query",params:{query:t.query,stdinContent:t.stdinContent}}}}function qz(t){let e=t.subcommand??t.args[0]??"show";return{tier:xr.CommandTier.LOCAL,handler:`config:${e}`,params:{key:t.args[0],value:t.args[1]}}}function Lz(t){let e=t.subcommand??t.args[0]??"list";return{tier:xr.CommandTier.LOCAL,handler:`mcp:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function Zz(t){let e=t.subcommand??t.args[0]??"list";return{tier:xr.CommandTier.LOCAL,handler:`prompt:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function Uz(t){let e=t.subcommand??t.args[0];return{tier:xr.CommandTier.LOCAL,handler:e?`stats:${e}`:"stats",params:{}}}function zz(t){let e=t.subcommand??t.args[0]??"list";return{tier:xr.CommandTier.LOCAL,handler:`history:${e}`,params:{query:t.args[0],id:t.args[0]}}}function Bz(t){let e=[];t.subcommand&&e.push(t.subcommand);let r=t.args.filter(i=>!i.startsWith("-"));e.push(...r);let n=e.join(" ");return{tier:xr.CommandTier.SERVER,handler:"run",params:{operation:n}}}});var Fe=_(Ut=>{"use strict";var Ry=Symbol.for("yaml.alias"),eC=Symbol.for("yaml.document"),eh=Symbol.for("yaml.map"),tC=Symbol.for("yaml.pair"),xy=Symbol.for("yaml.scalar"),th=Symbol.for("yaml.seq"),Eo=Symbol.for("yaml.node.type"),Vz=t=>!!t&&typeof t=="object"&&t[Eo]===Ry,Wz=t=>!!t&&typeof t=="object"&&t[Eo]===eC,Kz=t=>!!t&&typeof t=="object"&&t[Eo]===eh,Gz=t=>!!t&&typeof t=="object"&&t[Eo]===tC,rC=t=>!!t&&typeof t=="object"&&t[Eo]===xy,Hz=t=>!!t&&typeof t=="object"&&t[Eo]===th;function nC(t){if(t&&typeof t=="object")switch(t[Eo]){case eh:case th:return!0}return!1}function Jz(t){if(t&&typeof t=="object")switch(t[Eo]){case Ry:case eh:case xy:case th:return!0}return!1}var Yz=t=>(rC(t)||nC(t))&&!!t.anchor;Ut.ALIAS=Ry;Ut.DOC=eC;Ut.MAP=eh;Ut.NODE_TYPE=Eo;Ut.PAIR=tC;Ut.SCALAR=xy;Ut.SEQ=th;Ut.hasAnchor=Yz;Ut.isAlias=Vz;Ut.isCollection=nC;Ut.isDocument=Wz;Ut.isMap=Kz;Ut.isNode=Jz;Ut.isPair=Gz;Ut.isScalar=rC;Ut.isSeq=Hz});var Jc=_(qy=>{"use strict";var kt=Fe(),$r=Symbol("break visit"),iC=Symbol("skip children"),yi=Symbol("remove node");function rh(t,e){let r=oC(e);kt.isDocument(t)?fu(null,t.contents,r,Object.freeze([t]))===yi&&(t.contents=null):fu(null,t,r,Object.freeze([]))}rh.BREAK=$r;rh.SKIP=iC;rh.REMOVE=yi;function fu(t,e,r,n){let i=sC(t,e,r,n);if(kt.isNode(i)||kt.isPair(i))return aC(t,n,i),fu(t,i,r,n);if(typeof i!="symbol"){if(kt.isCollection(e)){n=Object.freeze(n.concat(e));for(let o=0;o<e.items.length;++o){let s=fu(o,e.items[o],r,n);if(typeof s=="number")o=s-1;else{if(s===$r)return $r;s===yi&&(e.items.splice(o,1),o-=1)}}}else if(kt.isPair(e)){n=Object.freeze(n.concat(e));let o=fu("key",e.key,r,n);if(o===$r)return $r;o===yi&&(e.key=null);let s=fu("value",e.value,r,n);if(s===$r)return $r;s===yi&&(e.value=null)}}return i}async function nh(t,e){let r=oC(e);kt.isDocument(t)?await hu(null,t.contents,r,Object.freeze([t]))===yi&&(t.contents=null):await hu(null,t,r,Object.freeze([]))}nh.BREAK=$r;nh.SKIP=iC;nh.REMOVE=yi;async function hu(t,e,r,n){let i=await sC(t,e,r,n);if(kt.isNode(i)||kt.isPair(i))return aC(t,n,i),hu(t,i,r,n);if(typeof i!="symbol"){if(kt.isCollection(e)){n=Object.freeze(n.concat(e));for(let o=0;o<e.items.length;++o){let s=await hu(o,e.items[o],r,n);if(typeof s=="number")o=s-1;else{if(s===$r)return $r;s===yi&&(e.items.splice(o,1),o-=1)}}}else if(kt.isPair(e)){n=Object.freeze(n.concat(e));let o=await hu("key",e.key,r,n);if(o===$r)return $r;o===yi&&(e.key=null);let s=await hu("value",e.value,r,n);if(s===$r)return $r;s===yi&&(e.value=null)}}return i}function oC(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function sC(t,e,r,n){if(typeof r=="function")return r(t,e,n);if(kt.isMap(e))return r.Map?.(t,e,n);if(kt.isSeq(e))return r.Seq?.(t,e,n);if(kt.isPair(e))return r.Pair?.(t,e,n);if(kt.isScalar(e))return r.Scalar?.(t,e,n);if(kt.isAlias(e))return r.Alias?.(t,e,n)}function aC(t,e,r){let n=e[e.length-1];if(kt.isCollection(n))n.items[t]=r;else if(kt.isPair(n))t==="key"?n.key=r:n.value=r;else if(kt.isDocument(n))n.contents=r;else{let i=kt.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}qy.visit=rh;qy.visitAsync=nh});var Ly=_(cC=>{"use strict";var uC=Fe(),Xz=Jc(),Qz={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},e4=t=>t.replace(/[!,[\]{}]/g,e=>Qz[e]),Yc=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[o,s]=n;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[o]=n;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return r(6,`Unsupported YAML version ${o}`,s),!1}}default:return r(0,`Unknown directive ${i}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);return s==="!"||s==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),s)}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||r(`The ${e} tag has no suffix`);let o=this.tags[n];if(o)try{return o+decodeURIComponent(i)}catch(s){return r(String(s)),null}return n==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,n]of Object.entries(this.tags))if(e.startsWith(n))return r+e4(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&uC.isNode(e.contents)){let o={};Xz.visit(e.contents,(s,a)=>{uC.isNode(a)&&a.tag&&(o[a.tag]=!0)}),i=Object.keys(o)}else i=[];for(let[o,s]of n)o==="!!"&&s==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(s)))&&r.push(`%TAG ${o} ${s}`);return r.join(`
38
+ ${e}`:e}});var XE=_(Qf=>{"use strict";Object.defineProperty(Qf,"__esModule",{value:!0});Qf.createParser=YE;Qf.parseArgs=Fz;var JE=KE(),HE=Xf(),Nz="0.2.6";function YE(){let t=new JE.Command;return t.name("aii").description("AI-powered CLI assistant").version(Nz,"-V, --version","Show version number").helpOption(!1).enablePositionalOptions().argument("[query...]","Natural language query").option("--clean","Clean output mode (just the result)").option("--standard","Standard output mode (result + metrics)").option("--thinking","Thinking mode (full reasoning)").option("-v, --verbose","Verbose output (alias for --thinking)").option("-d, --debug","Debug output").option("--model <model>","Override LLM model").option("--host <host>","API server host:port").option("-y, --yes","Auto-confirm shell commands").option("--offline","Offline mode (no web/MCP)").option("-i, --interactive","Interactive chat mode").option("-c, --continue-chat <id>","Continue chat session").option("-n, --new-chat","Force new chat session").option("--auto","Auto mode - auto-approve all actions").option("-q, --quiet","Quiet mode - minimal output").option("--no-colors","Disable colored output").option("--no-emojis","Disable emoji icons").option("--no-animations","Disable animations").option("--no-streaming","Disable streaming").option("--show-tokens","Show token usage").option("--show-cost","Show cost estimates").option("-h, --help","Show help"),t.command("config").description("Configuration management").argument("[action]","Action: init, show, validate, set").argument("[key]","Config key (for set)").argument("[value]","Config value (for set)").action(()=>{}),t.command("mcp").description("MCP server management").argument("[action]","Action: list, add, remove, status, etc.").argument("[rest...]","Server name and arguments").passThroughOptions().action(()=>{}),t.command("prompt").description("Prompt library").argument("[action]","Action: list, show, use, create").argument("[rest...]","Prompt name and arguments").allowUnknownOption().action(()=>{}),t.command("stats").description("Usage statistics").argument("[type]","Type: models, cost").action(()=>{}),t.command("history").description("Chat history").argument("[action]","Action: list, search, export, delete").argument("[query]","Search query or ID").action(()=>{}),t.command("doctor").description("System health check").action(()=>{}),t.command("chat").description("Interactive chat mode").action(()=>{}),t.command("agent").description("Interactive agent mode with tool execution").argument("[query...]","Optional query (non-interactive if provided)").action(()=>{}),t.command("run").description("Run domain-specific operations").argument("<operation>","Operation (e.g., git commit)").argument("[args...]","Additional arguments").allowUnknownOption().action(()=>{}),t.command("help").description("display help for command").argument("[command]","Command to show help for").action(()=>{}),t.command("version").description("Show version number").action(()=>{}),t}async function Fz(t){let e=YE();e.exitOverride(),e.configureOutput({writeErr:()=>{}});let r="query",n,i=[];try{e.parse(t),i=e.args;let c=e.args[0];c&&["config","mcp","prompt","stats","history","doctor","chat","run","help","version","agent"].includes(c)&&(r=c,n=e.args[1],i=e.args.slice(2))}catch(c){c instanceof JE.CommanderError&&(c.code==="commander.version"||c.code==="commander.helpDisplayed")&&process.exit(0),i=t.slice(2)}let o=e.opts(),s={clean:o.clean??!1,standard:o.standard??!1,thinking:o.thinking??!1,verbose:o.verbose??!1,debug:o.debug??!1,model:o.model,host:o.host,yes:o.yes??!1,offline:o.offline??!1,interactive:o.interactive??!1,continueChat:o.continueChat,newChat:o.newChat??!1,auto:o.auto??!1,quiet:o.quiet??!1,noColors:!o.colors,noEmojis:!o.emojis,noAnimations:!o.animations,noStreaming:!o.streaming,showTokens:o.showTokens??!1,showCost:o.showCost??!1,help:o.help??!1,version:o.version??!1},a;(0,HE.hasStdinInput)()&&(a=await(0,HE.readStdin)()),(r==="chat"||s.interactive)&&(r="agent"),r==="query"&&!i.length&&!a&&(r="agent");let u;if(r==="query"&&i.length>0)u=i.join(" ");else if(r==="agent"){let c=[];n&&c.push(n),i.length>0&&c.push(...i),c.length>0&&(u=c.join(" "))}return{command:r,subcommand:n,args:i,flags:s,stdinContent:a,query:u}}});var Hc=_(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.COMMAND_TIERS=nn.DEFAULT_OUTPUT_MODES=nn.CommandTier=void 0;nn.resolveOutputMode=Rz;var Sr;(function(t){t[t.LOCAL=1]="LOCAL",t[t.SERVER=2]="SERVER"})(Sr||(nn.CommandTier=Sr={}));nn.DEFAULT_OUTPUT_MODES={translate:"clean",shell:"clean",shell_generate:"clean",mcp:"standard",explain:"standard",code_generate:"standard",code_review:"standard",summarize:"standard",research:"standard",_default:"standard"};function Rz(t,e,r,n){return t.clean?"clean":t.thinking||t.verbose?"thinking":t.standard?"standard":e&&r?.[e]?r[e]:e&&nn.DEFAULT_OUTPUT_MODES[e]?nn.DEFAULT_OUTPUT_MODES[e]:n||nn.DEFAULT_OUTPUT_MODES._default}nn.COMMAND_TIERS={config:Sr.LOCAL,help:Sr.LOCAL,version:Sr.LOCAL,doctor:Sr.LOCAL,mcp:Sr.LOCAL,prompt:Sr.LOCAL,stats:Sr.LOCAL,history:Sr.LOCAL,query:Sr.SERVER,chat:Sr.SERVER,run:Sr.SERVER,agent:Sr.SERVER}});var QE=_(Fy=>{"use strict";Object.defineProperty(Fy,"__esModule",{value:!0});Fy.routeCommand=xz;var xr=Hc();function xz(t){let e=xr.COMMAND_TIERS[t.command]??xr.CommandTier.SERVER;switch(t.command){case"config":return qz(t);case"mcp":return Lz(t);case"prompt":return Zz(t);case"stats":return Uz(t);case"history":return zz(t);case"doctor":return{tier:xr.CommandTier.LOCAL,handler:"doctor",params:{}};case"chat":return{tier:xr.CommandTier.SERVER,handler:"chat",params:{continueChat:t.flags.continueChat}};case"run":return Bz(t);case"agent":return{tier:xr.CommandTier.SERVER,handler:"agent",params:{interactive:!t.query}};case"help":return{tier:xr.CommandTier.LOCAL,handler:"help",params:{command:t.subcommand}};case"version":return{tier:xr.CommandTier.LOCAL,handler:"version",params:{}};case"query":default:return{tier:e,handler:"query",params:{query:t.query,stdinContent:t.stdinContent}}}}function qz(t){let e=t.subcommand??t.args[0]??"show";return{tier:xr.CommandTier.LOCAL,handler:`config:${e}`,params:{key:t.args[0],value:t.args[1]}}}function Lz(t){let e=t.subcommand??t.args[0]??"list";return{tier:xr.CommandTier.LOCAL,handler:`mcp:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function Zz(t){let e=t.subcommand??t.args[0]??"list";return{tier:xr.CommandTier.LOCAL,handler:`prompt:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function Uz(t){let e=t.subcommand??t.args[0];return{tier:xr.CommandTier.LOCAL,handler:e?`stats:${e}`:"stats",params:{}}}function zz(t){let e=t.subcommand??t.args[0]??"list";return{tier:xr.CommandTier.LOCAL,handler:`history:${e}`,params:{query:t.args[0],id:t.args[0]}}}function Bz(t){let e=[];t.subcommand&&e.push(t.subcommand);let r=t.args.filter(i=>!i.startsWith("-"));e.push(...r);let n=e.join(" ");return{tier:xr.CommandTier.SERVER,handler:"run",params:{operation:n}}}});var Fe=_(Ut=>{"use strict";var Ry=Symbol.for("yaml.alias"),eC=Symbol.for("yaml.document"),eh=Symbol.for("yaml.map"),tC=Symbol.for("yaml.pair"),xy=Symbol.for("yaml.scalar"),th=Symbol.for("yaml.seq"),Eo=Symbol.for("yaml.node.type"),Vz=t=>!!t&&typeof t=="object"&&t[Eo]===Ry,Wz=t=>!!t&&typeof t=="object"&&t[Eo]===eC,Kz=t=>!!t&&typeof t=="object"&&t[Eo]===eh,Gz=t=>!!t&&typeof t=="object"&&t[Eo]===tC,rC=t=>!!t&&typeof t=="object"&&t[Eo]===xy,Hz=t=>!!t&&typeof t=="object"&&t[Eo]===th;function nC(t){if(t&&typeof t=="object")switch(t[Eo]){case eh:case th:return!0}return!1}function Jz(t){if(t&&typeof t=="object")switch(t[Eo]){case Ry:case eh:case xy:case th:return!0}return!1}var Yz=t=>(rC(t)||nC(t))&&!!t.anchor;Ut.ALIAS=Ry;Ut.DOC=eC;Ut.MAP=eh;Ut.NODE_TYPE=Eo;Ut.PAIR=tC;Ut.SCALAR=xy;Ut.SEQ=th;Ut.hasAnchor=Yz;Ut.isAlias=Vz;Ut.isCollection=nC;Ut.isDocument=Wz;Ut.isMap=Kz;Ut.isNode=Jz;Ut.isPair=Gz;Ut.isScalar=rC;Ut.isSeq=Hz});var Jc=_(qy=>{"use strict";var kt=Fe(),$r=Symbol("break visit"),iC=Symbol("skip children"),yi=Symbol("remove node");function rh(t,e){let r=oC(e);kt.isDocument(t)?fu(null,t.contents,r,Object.freeze([t]))===yi&&(t.contents=null):fu(null,t,r,Object.freeze([]))}rh.BREAK=$r;rh.SKIP=iC;rh.REMOVE=yi;function fu(t,e,r,n){let i=sC(t,e,r,n);if(kt.isNode(i)||kt.isPair(i))return aC(t,n,i),fu(t,i,r,n);if(typeof i!="symbol"){if(kt.isCollection(e)){n=Object.freeze(n.concat(e));for(let o=0;o<e.items.length;++o){let s=fu(o,e.items[o],r,n);if(typeof s=="number")o=s-1;else{if(s===$r)return $r;s===yi&&(e.items.splice(o,1),o-=1)}}}else if(kt.isPair(e)){n=Object.freeze(n.concat(e));let o=fu("key",e.key,r,n);if(o===$r)return $r;o===yi&&(e.key=null);let s=fu("value",e.value,r,n);if(s===$r)return $r;s===yi&&(e.value=null)}}return i}async function nh(t,e){let r=oC(e);kt.isDocument(t)?await hu(null,t.contents,r,Object.freeze([t]))===yi&&(t.contents=null):await hu(null,t,r,Object.freeze([]))}nh.BREAK=$r;nh.SKIP=iC;nh.REMOVE=yi;async function hu(t,e,r,n){let i=await sC(t,e,r,n);if(kt.isNode(i)||kt.isPair(i))return aC(t,n,i),hu(t,i,r,n);if(typeof i!="symbol"){if(kt.isCollection(e)){n=Object.freeze(n.concat(e));for(let o=0;o<e.items.length;++o){let s=await hu(o,e.items[o],r,n);if(typeof s=="number")o=s-1;else{if(s===$r)return $r;s===yi&&(e.items.splice(o,1),o-=1)}}}else if(kt.isPair(e)){n=Object.freeze(n.concat(e));let o=await hu("key",e.key,r,n);if(o===$r)return $r;o===yi&&(e.key=null);let s=await hu("value",e.value,r,n);if(s===$r)return $r;s===yi&&(e.value=null)}}return i}function oC(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function sC(t,e,r,n){if(typeof r=="function")return r(t,e,n);if(kt.isMap(e))return r.Map?.(t,e,n);if(kt.isSeq(e))return r.Seq?.(t,e,n);if(kt.isPair(e))return r.Pair?.(t,e,n);if(kt.isScalar(e))return r.Scalar?.(t,e,n);if(kt.isAlias(e))return r.Alias?.(t,e,n)}function aC(t,e,r){let n=e[e.length-1];if(kt.isCollection(n))n.items[t]=r;else if(kt.isPair(n))t==="key"?n.key=r:n.value=r;else if(kt.isDocument(n))n.contents=r;else{let i=kt.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}qy.visit=rh;qy.visitAsync=nh});var Ly=_(cC=>{"use strict";var uC=Fe(),Xz=Jc(),Qz={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},e4=t=>t.replace(/[!,[\]{}]/g,e=>Qz[e]),Yc=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[o,s]=n;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[o]=n;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return r(6,`Unsupported YAML version ${o}`,s),!1}}default:return r(0,`Unknown directive ${i}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);return s==="!"||s==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),s)}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||r(`The ${e} tag has no suffix`);let o=this.tags[n];if(o)try{return o+decodeURIComponent(i)}catch(s){return r(String(s)),null}return n==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,n]of Object.entries(this.tags))if(e.startsWith(n))return r+e4(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&uC.isNode(e.contents)){let o={};Xz.visit(e.contents,(s,a)=>{uC.isNode(a)&&a.tag&&(o[a.tag]=!0)}),i=Object.keys(o)}else i=[];for(let[o,s]of n)o==="!!"&&s==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(s)))&&r.push(`%TAG ${o} ${s}`);return r.join(`
39
39
  `)}};Yc.defaultYaml={explicit:!1,version:"1.2"};Yc.defaultTags={"!!":"tag:yaml.org,2002:"};cC.Directives=Yc});var ih=_(Xc=>{"use strict";var lC=Fe(),t4=Jc();function r4(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function dC(t){let e=new Set;return t4.visit(t,{Value(r,n){n.anchor&&e.add(n.anchor)}}),e}function fC(t,e){for(let r=1;;++r){let n=`${t}${r}`;if(!e.has(n))return n}}function n4(t,e){let r=[],n=new Map,i=null;return{onAnchor:o=>{r.push(o),i??(i=dC(t));let s=fC(e,i);return i.add(s),s},setAnchors:()=>{for(let o of r){let s=n.get(o);if(typeof s=="object"&&s.anchor&&(lC.isScalar(s.node)||lC.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:n}}Xc.anchorIsValid=r4;Xc.anchorNames=dC;Xc.createNodeAnchors=n4;Xc.findNewAnchor=fC});var Zy=_(hC=>{"use strict";function Qc(t,e,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,o=n.length;i<o;++i){let s=n[i],a=Qc(t,n,String(i),s);a===void 0?delete n[i]:a!==s&&(n[i]=a)}else if(n instanceof Map)for(let i of Array.from(n.keys())){let o=n.get(i),s=Qc(t,n,i,o);s===void 0?n.delete(i):s!==o&&n.set(i,s)}else if(n instanceof Set)for(let i of Array.from(n)){let o=Qc(t,n,i,i);o===void 0?n.delete(i):o!==i&&(n.delete(i),n.add(o))}else for(let[i,o]of Object.entries(n)){let s=Qc(t,n,i,o);s===void 0?delete n[i]:s!==o&&(n[i]=s)}return t.call(e,r,n)}hC.applyReviver=Qc});var ts=_(mC=>{"use strict";var i4=Fe();function pC(t,e,r){if(Array.isArray(t))return t.map((n,i)=>pC(n,String(i),r));if(t&&typeof t.toJSON=="function"){if(!r||!i4.hasAnchor(t))return t.toJSON(e,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(t,n),r.onCreate=o=>{n.res=o,delete r.onCreate};let i=t.toJSON(e,r);return r.onCreate&&r.onCreate(i),i}return typeof t=="bigint"&&!r?.keep?Number(t):t}mC.toJS=pC});var oh=_(_C=>{"use strict";var o4=Zy(),gC=Fe(),s4=ts(),Uy=class{constructor(e){Object.defineProperty(this,gC.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:o}={}){if(!gC.isDocument(e))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=s4.toJS(this,"",s);if(typeof i=="function")for(let{count:u,res:c}of s.anchors.values())i(c,u);return typeof o=="function"?o4.applyReviver(o,{"":a},"",a):a}};_C.NodeBase=Uy});var el=_(yC=>{"use strict";var a4=ih(),u4=Jc(),pu=Fe(),c4=oh(),l4=ts(),zy=class extends c4.NodeBase{constructor(e){super(pu.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],u4.visit(e,{Node:(o,s)=>{(pu.isAlias(s)||pu.hasAnchor(s))&&n.push(s)}}),r&&(r.aliasResolveCache=n));let i;for(let o of n){if(o===this)break;o.anchor===this.source&&(i=o)}return i}toJSON(e,r){if(!r)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:o}=r,s=this.resolve(i,r);if(!s){let u=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(u)}let a=n.get(s);if(a||(l4.toJS(s,null,r),a=n.get(s)),a?.res===void 0){let u="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(u)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=sh(i,s,n)),a.count*a.aliasCount>o)){let u="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(u)}return a.res}toString(e,r,n){let i=`*${this.source}`;if(e){if(a4.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${i} `}return i}};function sh(t,e,r){if(pu.isAlias(e)){let n=e.resolve(t),i=r&&n&&r.get(n);return i?i.count*i.aliasCount:0}else if(pu.isCollection(e)){let n=0;for(let i of e.items){let o=sh(t,i,r);o>n&&(n=o)}return n}else if(pu.isPair(e)){let n=sh(t,e.key,r),i=sh(t,e.value,r);return Math.max(n,i)}return 1}yC.Alias=zy});var Ct=_(By=>{"use strict";var d4=Fe(),f4=oh(),h4=ts(),p4=t=>!t||typeof t!="function"&&typeof t!="object",rs=class extends f4.NodeBase{constructor(e){super(d4.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:h4.toJS(this.value,e,r)}toString(){return String(this.value)}};rs.BLOCK_FOLDED="BLOCK_FOLDED";rs.BLOCK_LITERAL="BLOCK_LITERAL";rs.PLAIN="PLAIN";rs.QUOTE_DOUBLE="QUOTE_DOUBLE";rs.QUOTE_SINGLE="QUOTE_SINGLE";By.Scalar=rs;By.isScalarValue=p4});var tl=_(bC=>{"use strict";var m4=el(),Hs=Fe(),vC=Ct(),g4="tag:yaml.org,2002:";function _4(t,e,r){if(e){let n=r.filter(o=>o.tag===e),i=n.find(o=>!o.format)??n[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return r.find(n=>n.identify?.(t)&&!n.format)}function y4(t,e,r){if(Hs.isDocument(t)&&(t=t.contents),Hs.isNode(t))return t;if(Hs.isPair(t)){let d=r.schema[Hs.MAP].createNode?.(r.schema,null,r);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:n,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=r,u;if(n&&t&&typeof t=="object"){if(u=a.get(t),u)return u.anchor??(u.anchor=i(t)),new m4.Alias(u.anchor);u={anchor:null,node:null},a.set(t,u)}e?.startsWith("!!")&&(e=g4+e.slice(2));let c=_4(t,e,s.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new vC.Scalar(t);return u&&(u.node=d),d}c=t instanceof Map?s[Hs.MAP]:Symbol.iterator in Object(t)?s[Hs.SEQ]:s[Hs.MAP]}o&&(o(c),delete r.onTagObj);let l=c?.createNode?c.createNode(r.schema,t,r):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(r.schema,t,r):new vC.Scalar(t);return e?l.tag=e:c.default||(l.tag=c.tag),u&&(u.node=l),l}bC.createNode=y4});var uh=_(ah=>{"use strict";var v4=tl(),vi=Fe(),b4=oh();function Vy(t,e,r){let n=r;for(let i=e.length-1;i>=0;--i){let o=e[i];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=n,n=s}else n=new Map([[o,n]])}return v4.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var SC=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Wy=class extends b4.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(n=>vi.isNode(n)||vi.isPair(n)?n.clone(e):n),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(SC(e))this.add(r);else{let[n,...i]=e,o=this.get(n,!0);if(vi.isCollection(o))o.addIn(i,r);else if(o===void 0&&this.schema)this.set(n,Vy(this.schema,i,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){let[r,...n]=e;if(n.length===0)return this.delete(r);let i=this.get(r,!0);if(vi.isCollection(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(e,r){let[n,...i]=e,o=this.get(n,!0);return i.length===0?!r&&vi.isScalar(o)?o.value:o:vi.isCollection(o)?o.getIn(i,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!vi.isPair(r))return!1;let n=r.value;return n==null||e&&vi.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[r,...n]=e;if(n.length===0)return this.has(r);let i=this.get(r,!0);return vi.isCollection(i)?i.hasIn(n):!1}setIn(e,r){let[n,...i]=e;if(i.length===0)this.set(n,r);else{let o=this.get(n,!0);if(vi.isCollection(o))o.setIn(i,r);else if(o===void 0&&this.schema)this.set(n,Vy(this.schema,i,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}};ah.Collection=Wy;ah.collectionFromPath=Vy;ah.isEmptyPath=SC});var rl=_(ch=>{"use strict";var S4=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Ky(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var $4=(t,e,r)=>t.endsWith(`
40
40
  `)?Ky(r,e):r.includes(`
41
41
  `)?`
@@ -235,7 +235,7 @@ ${e}`,Dye=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Pye=Obj
235
235
  `)}formatExecutionSummary(e){let r=[];if(e.function_name&&r.push(`${this.emoji("\u{1F527} ")}${e.function_name}`),e.model&&r.push(`${this.emoji("\u{1F916} ")}${e.model}`),e.tokens_in!==void 0||e.tokens_out!==void 0){let i=e.tokens_in??0,o=e.tokens_out??0;r.push(`${this.emoji("\u{1F522} ")}${i}\u2197 ${o}\u2198`)}if(e.cost!==void 0&&r.push(`${this.emoji("\u{1F4B0} ")}$${e.cost.toFixed(6)}`),e.execution_time!==void 0&&r.push(`${this.emoji("\u26A1 ")}${e.execution_time.toFixed(1)}s`),r.length===0)return"";let n=r.join(" \u2022 ");return this.color(n,ar.default.dim)}formatError(e){let r=[];return r.push(this.color(`${this.emoji("\u274C ")}${e.message}`,ar.default.red)),e.suggestions&&e.suggestions.length>0&&(r.push(""),r.push(this.color(`${this.emoji("\u{1F4A1} ")}Solutions:`,ar.default.yellow)),e.suggestions.forEach((n,i)=>{r.push(this.color(` ${i+1}. ${n}`,ar.default.gray))})),r.join(`
236
236
  `)}formatConfig(e){let r=[];r.push(this.color(`${this.emoji("\u{1F4CB} ")}Current AII Configuration:`,ar.default.cyan)),r.push(`- Config file: ${e.configFile}`),r.push(`- Storage path: ${e.storagePath}`),e.apiUrl&&r.push(`- Aii Server: ${e.apiUrl}`);let n=e.hasApiKey?this.color("\u2713",ar.default.green):this.color("\u2717",ar.default.red);if(r.push(`- LLM provider: ${e.provider} (${e.model}) - ${n}`),e.webSearch){let i=e.webSearch.enabled?this.color("\u2713",ar.default.green):this.color("\u2717",ar.default.red);r.push(`- Web search: ${e.webSearch.provider??"none"} - ${i}`)}return e.issues&&e.issues.length>0&&r.push(`- Configuration issues: ${e.issues.length}`),r.join(`
237
237
  `)}formatHealthCheck(e){let r=[];r.push(this.color(`${this.emoji("\u{1F3E5} ")}AII Health Check`,ar.default.cyan)),r.push("");for(let o of e){let s,a;switch(o.status){case"ok":s="\u2713",a=ar.default.green;break;case"warn":s="\u26A0",a=ar.default.yellow;break;case"error":s="\u2717",a=ar.default.red;break}let u=this.color(s,a),c=this.color(o.message,a);r.push(` ${u} ${o.name.padEnd(20)} ${c}`)}let n=e.some(o=>o.status==="error"),i=e.some(o=>o.status==="warn");return r.push(""),n?r.push(this.color(`${this.emoji("\u274C ")}Some checks failed!`,ar.default.red)):i?r.push(this.color(`${this.emoji("\u26A0\uFE0F ")}All checks passed with warnings`,ar.default.yellow)):r.push(this.color(`${this.emoji("\u2705 ")}All checks passed!`,ar.default.green)),r.join(`
238
- `)}};eu.OutputFormatter=N_;function Kye(t={}){return new N_(t)}});var R_=_(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});F_.inferProviderFromModel=r2;F_.resolveProvider=Hye;var Gye=[{provider:"anthropic",patterns:[/^claude-/,/^claude$/i]},{provider:"openai",patterns:[/^gpt-/,/^o1-/,/^o3-/,/^chatgpt-/,/^text-davinci/]},{provider:"gemini",patterns:[/^gemini-/,/^gemini$/i]},{provider:"deepseek",patterns:[/^deepseek-/,/^deepseek$/i]},{provider:"moonshot",patterns:[/^kimi-/,/^moonshot-/,/^moonshot$/i]},{provider:"zai",patterns:[/^glm-/,/^glm$/i,/^chatglm/i]}];function r2(t){if(!t)return;let e=t.toLowerCase();for(let{provider:r,patterns:n}of Gye)for(let i of n)if(i.test(e))return r}function Hye(t,e){return t?r2(t)??e:e}});var o2=_(ur=>{"use strict";var Jye=ur&&ur.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Yye=ur&&ur.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),kO=ur&&ur.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Jye(r,e,n[i]);return Yye(r,e),r}}();Object.defineProperty(ur,"__esModule",{value:!0});ur.loadCurrentConversation=tve;ur.createNewConversation=MO;ur.saveConversation=AO;ur.setCurrentConversation=i2;ur.addMessage=rve;ur.clearCurrentConversation=nve;ur.getConversationHistoryForAPI=ive;ur.listConversations=ove;var bo=kO(require("fs")),x_=kO(require("path")),Xye=kO(require("os")),Nc=x_.join(Xye.homedir(),".aii","conversations"),IO=x_.join(Nc,"current.json");function Sf(){bo.existsSync(Nc)||bo.mkdirSync(Nc,{recursive:!0})}function Qye(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function eve(t){let r=t.trim().replace(/\s+/g," ");return r.length>50&&(r=r.substring(0,50).trim()+"..."),r}function n2(t){return x_.join(Nc,`${t}.json`)}function tve(){Sf();try{if(bo.existsSync(IO)){let t=bo.readFileSync(IO,"utf-8"),e=JSON.parse(t),r=n2(e.id);if(bo.existsSync(r)){let n=bo.readFileSync(r,"utf-8");return JSON.parse(n)}}}catch{}return MO()}function MO(){Sf();let t={id:Qye(),title:"New Conversation",messages:[],createdAt:Date.now(),updatedAt:Date.now()};return AO(t),i2(t.id),t}function AO(t){if(Sf(),t.title==="New Conversation"&&t.messages.length>0){let r=t.messages.find(n=>n.role==="user");r&&(t.title=eve(r.content))}t.updatedAt=Date.now();let e=n2(t.id);bo.writeFileSync(e,JSON.stringify(t,null,2),"utf-8")}function i2(t){Sf(),bo.writeFileSync(IO,JSON.stringify({id:t}),"utf-8")}function rve(t,e,r){t.messages.push({role:e,content:r,timestamp:Date.now()}),AO(t)}function nve(){return MO()}function ive(t){return t.messages.map(e=>({role:e.role,content:e.content}))}function ove(){Sf();let t=[];try{let e=bo.readdirSync(Nc);for(let r of e)if(r.endsWith(".json")&&r!=="current.json")try{let n=bo.readFileSync(x_.join(Nc,r),"utf-8");t.push(JSON.parse(n))}catch{}}catch{}return t.sort((e,r)=>r.updatedAt-e.updatedAt)}});var NO=_(Hr=>{"use strict";var sve=Hr&&Hr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),ave=Hr&&Hr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),uve=Hr&&Hr.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&sve(r,e,n[i]);return ave(r,e),r}}(),cve=Hr&&Hr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.InteractiveChatSession=void 0;Hr.handleChat=_ve;var lve=uve(require("readline")),s2=cve((St(),Et(Tt))),dve=Ic(),fve=Mc(),hve=Ac(),pve=zs(),a2=jo(),mve=R_(),$f=o2(),gve="0.2.5",q_=class{configManager;parsed;running=!1;conversation;stats;formatter;constructor(e,r){this.parsed=e,this.configManager=r,this.conversation=(0,$f.loadCurrentConversation)(),this.stats={startTime:Date.now(),totalRequests:0,cumulativeTokens:0,cumulativeCost:0},this.formatter=(0,pve.createFormatter)({colors:!e.flags.noColors,emojis:!e.flags.noEmojis})}async start(){for(this.running=!0,this.displayWelcome();this.running;)try{let e=await this.getUserInput();if(!e.trim()||await this.handleSpecialCommands(e))continue;this.conversation.messages.push({role:"user",content:e,timestamp:Date.now()}),(0,$f.saveConversation)(this.conversation),await this.processWithContext(e)}catch(e){if(e instanceof Error&&e.message==="EXIT")break;if(e instanceof Error&&e.message==="INTERRUPTED"){console.log(`
238
+ `)}};eu.OutputFormatter=N_;function Kye(t={}){return new N_(t)}});var R_=_(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});F_.inferProviderFromModel=r2;F_.resolveProvider=Hye;var Gye=[{provider:"anthropic",patterns:[/^claude-/,/^claude$/i]},{provider:"openai",patterns:[/^gpt-/,/^o1-/,/^o3-/,/^chatgpt-/,/^text-davinci/]},{provider:"gemini",patterns:[/^gemini-/,/^gemini$/i]},{provider:"deepseek",patterns:[/^deepseek-/,/^deepseek$/i]},{provider:"moonshot",patterns:[/^kimi-/,/^moonshot-/,/^moonshot$/i]},{provider:"zai",patterns:[/^glm-/,/^glm$/i,/^chatglm/i]}];function r2(t){if(!t)return;let e=t.toLowerCase();for(let{provider:r,patterns:n}of Gye)for(let i of n)if(i.test(e))return r}function Hye(t,e){return t?r2(t)??e:e}});var o2=_(ur=>{"use strict";var Jye=ur&&ur.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Yye=ur&&ur.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),kO=ur&&ur.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Jye(r,e,n[i]);return Yye(r,e),r}}();Object.defineProperty(ur,"__esModule",{value:!0});ur.loadCurrentConversation=tve;ur.createNewConversation=MO;ur.saveConversation=AO;ur.setCurrentConversation=i2;ur.addMessage=rve;ur.clearCurrentConversation=nve;ur.getConversationHistoryForAPI=ive;ur.listConversations=ove;var bo=kO(require("fs")),x_=kO(require("path")),Xye=kO(require("os")),Nc=x_.join(Xye.homedir(),".aii","conversations"),IO=x_.join(Nc,"current.json");function Sf(){bo.existsSync(Nc)||bo.mkdirSync(Nc,{recursive:!0})}function Qye(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function eve(t){let r=t.trim().replace(/\s+/g," ");return r.length>50&&(r=r.substring(0,50).trim()+"..."),r}function n2(t){return x_.join(Nc,`${t}.json`)}function tve(){Sf();try{if(bo.existsSync(IO)){let t=bo.readFileSync(IO,"utf-8"),e=JSON.parse(t),r=n2(e.id);if(bo.existsSync(r)){let n=bo.readFileSync(r,"utf-8");return JSON.parse(n)}}}catch{}return MO()}function MO(){Sf();let t={id:Qye(),title:"New Conversation",messages:[],createdAt:Date.now(),updatedAt:Date.now()};return AO(t),i2(t.id),t}function AO(t){if(Sf(),t.title==="New Conversation"&&t.messages.length>0){let r=t.messages.find(n=>n.role==="user");r&&(t.title=eve(r.content))}t.updatedAt=Date.now();let e=n2(t.id);bo.writeFileSync(e,JSON.stringify(t,null,2),"utf-8")}function i2(t){Sf(),bo.writeFileSync(IO,JSON.stringify({id:t}),"utf-8")}function rve(t,e,r){t.messages.push({role:e,content:r,timestamp:Date.now()}),AO(t)}function nve(){return MO()}function ive(t){return t.messages.map(e=>({role:e.role,content:e.content}))}function ove(){Sf();let t=[];try{let e=bo.readdirSync(Nc);for(let r of e)if(r.endsWith(".json")&&r!=="current.json")try{let n=bo.readFileSync(x_.join(Nc,r),"utf-8");t.push(JSON.parse(n))}catch{}}catch{}return t.sort((e,r)=>r.updatedAt-e.updatedAt)}});var NO=_(Hr=>{"use strict";var sve=Hr&&Hr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),ave=Hr&&Hr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),uve=Hr&&Hr.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&sve(r,e,n[i]);return ave(r,e),r}}(),cve=Hr&&Hr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.InteractiveChatSession=void 0;Hr.handleChat=_ve;var lve=uve(require("readline")),s2=cve((St(),Et(Tt))),dve=Ic(),fve=Mc(),hve=Ac(),pve=zs(),a2=jo(),mve=R_(),$f=o2(),gve="0.2.6",q_=class{configManager;parsed;running=!1;conversation;stats;formatter;constructor(e,r){this.parsed=e,this.configManager=r,this.conversation=(0,$f.loadCurrentConversation)(),this.stats={startTime:Date.now(),totalRequests:0,cumulativeTokens:0,cumulativeCost:0},this.formatter=(0,pve.createFormatter)({colors:!e.flags.noColors,emojis:!e.flags.noEmojis})}async start(){for(this.running=!0,this.displayWelcome();this.running;)try{let e=await this.getUserInput();if(!e.trim()||await this.handleSpecialCommands(e))continue;this.conversation.messages.push({role:"user",content:e,timestamp:Date.now()}),(0,$f.saveConversation)(this.conversation),await this.processWithContext(e)}catch(e){if(e instanceof Error&&e.message==="EXIT")break;if(e instanceof Error&&e.message==="INTERRUPTED"){console.log(`
239
239
  \u26A0\uFE0F Interrupted. Type /exit to quit or continue chatting.`);continue}console.error(s2.default.red(`
240
240
  \u274C Error: ${e instanceof Error?e.message:String(e)}`)),this.conversation.messages.length>0&&this.conversation.messages[this.conversation.messages.length-1].role==="user"&&(this.conversation.messages.pop(),(0,$f.saveConversation)(this.conversation))}}displayWelcome(){console.log("\u{1F916} Entering interactive mode."),console.log(""),console.log("Controls:"),console.log(" \u2022 Enter - Send message"),console.log(" \u2022 End with \\ - Multi-line mode"),console.log(" \u2022 /exit - Quit chat"),console.log(" \u2022 /help - Show all commands"),console.log("")}getUserInput(){return new Promise((e,r)=>{let n=lve.createInterface({input:process.stdin,output:process.stdout}),i=[],o=!1,s=()=>{o=!0,n.close()},a=u=>{n.question(u,c=>{if(i.length===0&&c.trim().startsWith("/")){s(),e(c.trim());return}c.endsWith("\\")?(i.push(c.slice(0,-1)),a(" ")):(i.push(c),s(),e(i.join(`
241
241
  `).trim()))})};n.on("SIGINT",()=>{s(),r(new Error("INTERRUPTED"))}),n.on("close",()=>{o||r(new Error("EXIT"))}),a("> ")})}async handleSpecialCommands(e){let r=e.trim().toLowerCase();if(r.startsWith("/"))r=r.slice(1);else return!1;switch(r){case"exit":case"quit":return await this.handleExit(),!0;case"help":return this.displayHelp(),!0;case"clear":case"new":return this.clearConversation(),!0;case"history":return this.displayConversationHistory(),!0;case"stats":return this.displayStats(),!0;case"version":return this.displayVersion(),!0;default:return console.log(s2.default.yellow(`Unknown command: /${r}. Type /help for available commands.`)),console.log(""),!0}}async processWithContext(e){let r=await this.configManager.load(),n=this.configManager.validate();if(!n.valid)throw new a2.ConfigError(n.issues.join(", "));let o=this.configManager.getServerApiKey()||"aii_sk_7WyvfQ0PRzufJ1G66Qn8Sm4gW9Tealpo6vOWDDUeiv4",s=this.parsed.flags.model??r.llm.model,a=(0,mve.resolveProvider)(this.parsed.flags.model,r.llm.provider),u=this.configManager.getApiKey(a);if(!u)throw new a2.AuthError(`Missing API key for provider: ${a}`);this.stats.totalRequests++;let c=(0,fve.createSpinner)(!this.parsed.flags.noAnimations);c.start("");let l=(0,hve.createStreamingFormatter)({spinner:c,enabled:!this.parsed.flags.noStreaming}),d=this.conversation.messages.slice(-21,-1).map($=>({role:$.role,content:$.content})),f={api_key:o,system_prompt:null,user_prompt:e,user_message:e,output_mode:"CLEAN",streaming:!this.parsed.flags.noStreaming,model:s,llm_provider:a,llm_api_key:u,provider_api_key:u,client_type:"cli",offline:this.parsed.flags.offline,conversation_history:d.length>0?d:void 0},g=this.parsed.flags.host?`http://${this.parsed.flags.host}`:r.api.url,p=new dve.AiiWebSocketClient({url:g}),m="",v=!1;try{let $=await p.executeRequest(f,{onToken:P=>{m+=P,v=!0,l.onToken(P)}});l.flush();let w=$.result||m;!v&&w&&console.log(w),console.log(""),$.metadata&&this.displayExecutionSummary($.metadata),w&&(this.conversation.messages.push({role:"assistant",content:w,timestamp:Date.now()}),(0,$f.saveConversation)(this.conversation))}catch($){throw c.stop(!0),$}finally{p.disconnect()}}displayExecutionSummary(e){let r=e.cost||0,n=e.tokens_in||0,i=e.tokens_out||0,o=n+i;this.stats.cumulativeTokens+=o,this.stats.cumulativeCost+=r,console.log(this.formatter.formatExecutionSummary({model:e.model,tokens_in:n,tokens_out:i,cost:r,execution_time:e.execution_time})),console.log("")}clearConversation(){this.conversation=(0,$f.clearCurrentConversation)(),console.clear(),this.displayWelcome()}displayConversationHistory(){if(this.conversation.messages.length===0){console.log(`
@@ -383,7 +383,7 @@ ${r.yellow("EXAMPLES:")}
383
383
  ${r.yellow("CONFIG FILE:")}
384
384
  ~/.aii/config.yaml Main configuration
385
385
  ~/.aii/secrets.yaml API keys (secure storage)
386
- `)}});var p2=_(Jo=>{"use strict";var abe=Jo&&Jo.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),ube=Jo&&Jo.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),cbe=Jo&&Jo.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&abe(r,e,n[i]);return ube(r,e),r}}();Object.defineProperty(Jo,"__esModule",{value:!0});Jo.handleDoctor=dbe;var ZO=cbe(require("fs")),lbe=zs();async function dbe(t,e){let r=(0,lbe.createFormatter)({colors:!t.flags.noColors,emojis:!t.flags.noEmojis}),n=[];e.configExists()?n.push({name:"Configuration file",status:"ok",message:"Found"}):n.push({name:"Configuration file",status:"warn",message:"Not found (using defaults)"});let i=await e.load(),o=e.getApiKey();if(o){let f=hbe(o);n.push({name:"LLM Model",status:"ok",message:`${i.llm.model}@${i.llm.provider} (${f})`})}else n.push({name:"LLM Model",status:"error",message:`Not configured for ${i.llm.provider}`});let s=await fbe(i.api.url);n.push({name:"AII Server",status:s.ok?"ok":"error",message:s.message});let a=`${e.getConfigDir()}/mcp_servers.json`;if(ZO.existsSync(a))try{let f=ZO.readFileSync(a,"utf-8"),g=JSON.parse(f),p=Object.keys(g.mcpServers??{}).length;p>0?n.push({name:"MCP Servers",status:"ok",message:`${p} configured`}):n.push({name:"MCP Servers",status:"warn",message:"Not configured"})}catch{n.push({name:"MCP Servers",status:"warn",message:"Invalid config"})}else n.push({name:"MCP Servers",status:"warn",message:"Not configured"});let u=e.getConfigDir();ZO.existsSync(u)?n.push({name:"Storage Directory",status:"ok",message:u}):n.push({name:"Storage Directory",status:"warn",message:"Not created"});let c=process.version;parseInt(c.slice(1).split(".")[0],10)>=18?n.push({name:"Node.js Version",status:"ok",message:c}):n.push({name:"Node.js Version",status:"error",message:`${c} (requires >= 18)`}),console.log(r.formatHealthCheck(n)),n.some(f=>f.status==="error")&&process.exit(1)}async function fbe(t){try{let e=new AbortController,r=setTimeout(()=>e.abort(),3e3),n=await fetch(`${t}/api/status`,{signal:e.signal});if(clearTimeout(r),n.ok){let i=new URL(t);return{ok:!0,message:`Running at ${i.hostname}:${i.port||26169}`}}else return{ok:!1,message:`Not responding (${n.status})`}}catch(e){return e instanceof Error&&e.name==="AbortError"?{ok:!1,message:"Connection timeout"}:{ok:!1,message:"Not running"}}}function hbe(t){return t.length<=10?"***":t.slice(0,6)+"..."+t.slice(-4)}});var g2=_(Fc=>{"use strict";var pbe=Fc&&Fc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Fc,"__esModule",{value:!0});Fc.handleHelp=gbe;Fc.handleVersion=_be;var mbe=pbe((St(),Et(Tt))),m2="0.2.5";function gbe(t){let r=!t.flags.noColors?mbe.default:{cyan:n=>n,yellow:n=>n,gray:n=>n,green:n=>n};console.log(`
386
+ `)}});var p2=_(Jo=>{"use strict";var abe=Jo&&Jo.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),ube=Jo&&Jo.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),cbe=Jo&&Jo.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&abe(r,e,n[i]);return ube(r,e),r}}();Object.defineProperty(Jo,"__esModule",{value:!0});Jo.handleDoctor=dbe;var ZO=cbe(require("fs")),lbe=zs();async function dbe(t,e){let r=(0,lbe.createFormatter)({colors:!t.flags.noColors,emojis:!t.flags.noEmojis}),n=[];e.configExists()?n.push({name:"Configuration file",status:"ok",message:"Found"}):n.push({name:"Configuration file",status:"warn",message:"Not found (using defaults)"});let i=await e.load(),o=e.getApiKey();if(o){let f=hbe(o);n.push({name:"LLM Model",status:"ok",message:`${i.llm.model}@${i.llm.provider} (${f})`})}else n.push({name:"LLM Model",status:"error",message:`Not configured for ${i.llm.provider}`});let s=await fbe(i.api.url);n.push({name:"AII Server",status:s.ok?"ok":"error",message:s.message});let a=`${e.getConfigDir()}/mcp_servers.json`;if(ZO.existsSync(a))try{let f=ZO.readFileSync(a,"utf-8"),g=JSON.parse(f),p=Object.keys(g.mcpServers??{}).length;p>0?n.push({name:"MCP Servers",status:"ok",message:`${p} configured`}):n.push({name:"MCP Servers",status:"warn",message:"Not configured"})}catch{n.push({name:"MCP Servers",status:"warn",message:"Invalid config"})}else n.push({name:"MCP Servers",status:"warn",message:"Not configured"});let u=e.getConfigDir();ZO.existsSync(u)?n.push({name:"Storage Directory",status:"ok",message:u}):n.push({name:"Storage Directory",status:"warn",message:"Not created"});let c=process.version;parseInt(c.slice(1).split(".")[0],10)>=18?n.push({name:"Node.js Version",status:"ok",message:c}):n.push({name:"Node.js Version",status:"error",message:`${c} (requires >= 18)`}),console.log(r.formatHealthCheck(n)),n.some(f=>f.status==="error")&&process.exit(1)}async function fbe(t){try{let e=new AbortController,r=setTimeout(()=>e.abort(),3e3),n=await fetch(`${t}/api/status`,{signal:e.signal});if(clearTimeout(r),n.ok){let i=new URL(t);return{ok:!0,message:`Running at ${i.hostname}:${i.port||26169}`}}else return{ok:!1,message:`Not responding (${n.status})`}}catch(e){return e instanceof Error&&e.name==="AbortError"?{ok:!1,message:"Connection timeout"}:{ok:!1,message:"Not running"}}}function hbe(t){return t.length<=10?"***":t.slice(0,6)+"..."+t.slice(-4)}});var g2=_(Fc=>{"use strict";var pbe=Fc&&Fc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Fc,"__esModule",{value:!0});Fc.handleHelp=gbe;Fc.handleVersion=_be;var mbe=pbe((St(),Et(Tt))),m2="0.2.6";function gbe(t){let r=!t.flags.noColors?mbe.default:{cyan:n=>n,yellow:n=>n,gray:n=>n,green:n=>n};console.log(`
387
387
  ${r.cyan("AII")} - AI-powered CLI assistant v${m2}
388
388
 
389
389
  ${r.yellow("USAGE:")}
@@ -488,7 +488,7 @@ ${r.yellow("IN-SESSION COMMANDS:")}
488
488
 
489
489
  ${r.yellow("DOCUMENTATION:")}
490
490
  https://aiiware.com/docs
491
- `)}function _be(){console.log(m2)}});var U_=_(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0});Of.createSession=ybe;Of.serializeSession=bbe;Of.deserializeSession=Sbe;function ybe(t={}){let e=new Date;return{id:vbe(),projectPath:t.projectPath??process.cwd(),createdAt:e,updatedAt:e,messages:[],model:t.model??"claude-sonnet-4",provider:t.provider??"anthropic",permissionCache:new Map,fileChanges:[],stats:{startTime:Date.now(),totalTurns:0,tokensIn:0,tokensOut:0,totalCost:0,toolCalls:0,filesModified:0},mode:t.mode??"interactive"}}function vbe(){let t=Date.now().toString(36),e=Math.random().toString(36).slice(2,9);return`session_${t}_${e}`}function bbe(t){return{id:t.id,projectPath:t.projectPath,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),messages:t.messages,model:t.model,provider:t.provider,permissionCache:Array.from(t.permissionCache.entries()),fileChanges:t.fileChanges,stats:t.stats,mode:t.mode}}function Sbe(t){return{id:t.id,projectPath:t.projectPath,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),messages:t.messages,model:t.model,provider:t.provider??"anthropic",permissionCache:new Map(t.permissionCache),fileChanges:t.fileChanges,stats:t.stats,mode:t.mode}}});var xc=_(N=>{"use strict";var $be=N&&N.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(N,"__esModule",{value:!0});N.colors=N.VERSION=void 0;N.printLogo=wbe;N.printPrompt=Dbe;N.printAction=Pbe;N.printToolComplete=Obe;N.printToolFailed=Ebe;N.printToolResultBox=Cbe;N.printSuccess=Tbe;N.printWarning=jbe;N.printError=Ibe;N.printDivider=v2;N.printHeader=kbe;N.getActionIndicator=Mbe;N.formatPath=Abe;N.formatCode=Nbe;N.printPermissionPrompt=Fbe;N.printModelInfo=Rbe;N.printTokenUsage=xbe;N.shortenPath=qbe;N.padEndAnsi=Lbe;N.printWelcomeBanner=Zbe;N.printInputBox=Ube;N.printContextLine=zbe;N.getModeDisplay=b2;N.printStatusBar=Bbe;N.printInputBoxTop=Vbe;N.printInputBoxBottom=Wbe;N.getPromptWithHint=Kbe;N.printExitSummary=Hbe;var _t=$be((St(),Et(Tt)));N.VERSION="0.2.5";var y2=[" \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u255A\u2550\u255D \u255A\u2550\u255D","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2557 \u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551","\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D"];N.colors={logo:_t.default.cyan.bold,prompt:_t.default.cyan.bold,model:_t.default.cyan,success:_t.default.green,warning:_t.default.yellow,error:_t.default.red,thinking:_t.default.dim.cyan,filePath:_t.default.blue,code:_t.default.white,muted:_t.default.gray,dim:_t.default.dim,safe:_t.default.green,risky:_t.default.yellow,destructive:_t.default.red,border:_t.default.cyan,bannerBorder:_t.default.cyan};function wbe(t=N.VERSION){console.log(N.colors.logo(y2)+N.colors.dim(` v${t}`))}function Dbe(t="> "){process.stdout.write(N.colors.prompt(t))}function Pbe(t,e,r=console.log){r(N.colors.dim("\u25CB ")+_t.default.white(t)+" "+N.colors.filePath(e))}function Obe(t,e,r=console.log){r(N.colors.success("\u2713 ")+_t.default.white(t)+" "+N.colors.filePath(e))}function Ebe(t,e,r,n=console.log){n(N.colors.error("\u2717 ")+_t.default.white(t)+" "+N.colors.filePath(e)),r&&n(N.colors.dim(" \u2192 ")+N.colors.error(r))}function Cbe(t,e,r,n=!0,i,o=console.log){let s=process.stdout.columns||80,a=s,u=a-4;process.env.AII_DEBUG&&console.error(`[DEBUG] termWidth=${s}, boxWidth=${a}, innerWidth=${u}`);let c=v=>v.replace(/\x1b\[[0-9;]*m/g,""),l=_t.default.dim.cyan,d=v=>{let w=c(v).replace(/\t/g," "),P=w.length>u?w.slice(0,u-3)+"...":w,T=u-P.length;return l("\u2502")+" "+P+" ".repeat(T)+" "+l("\u2502")},g=` ${n?N.colors.success("\u2713"):N.colors.error("\u2717")} ${_t.default.bold(t)} `,p=3+t.length+1,m=a-3-p;if(o(l("\u250C\u2500")+g+l("\u2500".repeat(Math.max(0,m))+"\u2510")),i){let v=`${e} - ${i}`;o(d(v))}else o(d(e));if(r&&r.length>0){o(l("\u251C"+"\u2500".repeat(a-2)+"\u2524"));let v=20,$=r.slice(0,v);for(let w of $)o(d(w));if(r.length>v){let w=`... +${r.length-v} more lines`;o(d(w))}}o(l("\u2514"+"\u2500".repeat(a-2)+"\u2518"))}function Tbe(t){console.log(N.colors.success("\u2713 ")+t)}function jbe(t){console.log(N.colors.warning("\u26A0 ")+t)}function Ibe(t){console.log(N.colors.error("\u2717 ")+t)}function v2(t=60){console.log(N.colors.dim("\u2500".repeat(t)))}function kbe(t){console.log(N.colors.logo(t)),v2(t.length)}function Mbe(t){return N.colors.thinking(`[${t}]`)}function Abe(t){let e=process.env.HOME??process.env.USERPROFILE??"";return e&&t.startsWith(e)?N.colors.filePath("~"+t.slice(e.length)):N.colors.filePath(t)}function Nbe(t){return N.colors.code(t)}function Fbe(t,e){let r=" Permission Required ",n="(y)es / (n)o / (a)lways / (s)ession",i=`Aii wants to run: ${t}`,o=60,s=process.stdout.columns||80,a=Math.min(s-2,120),u=[i.length+4,e.length+4,n.length+4],c=Math.max(...u),l=Math.max(o,Math.min(c,a)),d=Math.max(0,l-3-r.length),f=l-2,g=m=>m.replace(/\x1b\[[0-9;]*m/g,""),p=(m,v)=>{let $=v??g(m),w=m,P=$.length,T=f-1;if(P>T){let F=$.slice(0,T-3)+"...";w=m===$?F:N.colors.dim(F),P=F.length}let C=Math.max(0,f-P-1);return N.colors.warning("\u2502")+" "+w+" ".repeat(C)+N.colors.warning("\u2502")};console.log(""),console.log(N.colors.warning("\u250C\u2500"+r+"\u2500".repeat(d)+"\u2510")),console.log(p("")),console.log(p(`Aii wants to run: ${_t.default.bold(t)}`,i)),console.log(p(N.colors.dim(e),e)),console.log(p("")),console.log(p(N.colors.prompt(n),n)),console.log(N.colors.warning("\u2514"+"\u2500".repeat(l-2)+"\u2518"))}function Rbe(t,e){let r=e?N.colors.dim(` (${e})`):"";console.log(`Model: ${N.colors.model(t)}${r}`)}function xbe(t,e,r){let n=`${N.colors.dim("Tokens:")} ${t} in / ${e} out`;r!==void 0&&(n+=` ${N.colors.dim("\u2022")} $${r.toFixed(4)}`),console.log(N.colors.dim(n))}function Rc(){return process.stdout.columns||80}function qbe(t,e=40){let r=process.env.HOME??process.env.USERPROFILE??"",n=t;if(r&&t.startsWith(r)&&(n="~"+t.slice(r.length)),n.length<=e)return n;let i=n.split("/").filter(s=>s.length>0);if(i.length>=2){let s=i.slice(-2).join("/");if(s.length<=e-4)return".../"+s}return".../"+(i[i.length-1]||i[i.length-2])}function UO(t){return t.replace(/\x1b\[[0-9;]*m/g,"").length}function Lbe(t,e){let r=UO(t),n=Math.max(0,e-r);return t+" ".repeat(n)}function Zbe(t){let e=Rc(),r=Math.min(e,90),n=r-5,i=Math.floor(n*.42),o=n-i,s=$=>$.replace(/\x1b\[[0-9;]*m/g,"").length,a=($,w)=>{let P=s($);return $+" ".repeat(Math.max(0,w-P))},u=y2.map($=>N.colors.logo($)),c=N.colors.success("Tips for getting started"),l="Ask questions, edit files, or run commands.",d="Be specific for the best results.",f=N.colors.dim("/help")+" for more information.",g=[];g.push({left:"",right:c});for(let $=0;$<6;$++){let w=u[$]||"",P="";$===0&&(P=l),$===1&&(P=d),$===2&&(P=f),g.push({left:w,right:P})}let p=` Aii CLI v${N.VERSION} `,m=p.length,v=r-4-m;console.log(N.colors.bannerBorder("\u250C\u2500")+_t.default.bold.white(p)+N.colors.bannerBorder("\u2500".repeat(Math.max(0,v)))+N.colors.bannerBorder("\u2500\u2510"));for(let $ of g){let w=a($.left,i),P=a($.right,o);console.log(N.colors.bannerBorder("\u2502")+" "+w+N.colors.bannerBorder("\u2502")+" "+P+N.colors.bannerBorder("\u2502"))}console.log(N.colors.bannerBorder("\u2514"+"\u2500".repeat(r-2)+"\u2518"))}function Ube(){let t=Math.min(Rc()-2,80);console.log(N.colors.dim("\u250C"+"\u2500".repeat(t)+"\u2510")),console.log(N.colors.dim("\u2502 ")+N.colors.prompt("> ")+N.colors.dim("Type your message or @path/to/file")+N.colors.dim(" ".repeat(Math.max(0,t-36)))+N.colors.dim("\u2502")),console.log(N.colors.dim("\u2514"+"\u2500".repeat(t)+"\u2518"))}function zbe(t){let e=[];t.tools&&t.tools>0&&e.push(`${t.tools} tool${t.tools>1?"s":""}`);let r=t.mcpServers??0;r>0&&e.push(`${r} MCP server${r>1?"s":""}`),t.contextFiles&&t.contextFiles>0&&e.push(`${t.contextFiles} context file${t.contextFiles>1?"s":""}`),e.length>0&&console.log(N.colors.dim("Using: ")+N.colors.dim(e.join(" | ")))}function b2(t){switch(t){case"auto":return N.colors.warning("Auto");case"plan":return N.colors.thinking("Plan");case"interactive":default:return N.colors.success("Normal")}}function Bbe(t){let e=Rc(),r=N.colors.filePath(t.projectPath);t.branch&&(r+=N.colors.dim(` (${t.branch})`));let n=t.model.replace("claude-","").replace("deepseek-","").replace("-latest",""),i=b2(t.mode)+N.colors.dim(" (")+N.colors.model(n)+N.colors.dim(")");t.memoryMB!==void 0&&(i+=N.colors.dim(" | ")+N.colors.dim(`${t.memoryMB.toFixed(1)} MB`));let o=UO(r),s=UO(i),a=Math.max(1,e-o-s-2);console.log(r+" ".repeat(a)+i)}function Vbe(){let t=Math.min(Rc(),100);console.log(N.colors.dim("\u250C"+"\u2500".repeat(t-2)+"\u2510"))}function Wbe(){let t=Math.min(Rc(),100);console.log(N.colors.dim("\u2514"+"\u2500".repeat(t-2)+"\u2518"))}function Kbe(t=!0){return t?N.colors.prompt("> ")+N.colors.dim("Type your message..."):N.colors.prompt("> ")}function Gbe(t){if(t<60)return`${t}s`;let e=Math.floor(t/60),r=t%60;return r>0?`${e}m ${r}s`:`${e}m`}function _2(t){return t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Hbe(t){let e=Rc(),r=Math.min(e-2,76),n=r-4,i=(f,g)=>{let p=f.replace(/\x1b\[[0-9;]*m/g,"").length;return f+" ".repeat(Math.max(0,g-p))},o=f=>N.colors.border("\u2502")+" "+i(f,n)+" "+N.colors.border("\u2502"),s=(f,g,p,m)=>{let v=Math.floor(n/2),$=N.colors.dim(f.padEnd(15))+g,w=N.colors.dim(p.padEnd(15))+m;return o(i($,v)+w)},a=Gbe(t.durationSeconds),u=_2(t.tokensIn),c=_2(t.tokensOut),l=`$${t.totalCost.toFixed(4)}`,d=`${t.provider}/${t.model.replace("claude-","").replace("-latest","")}`;console.log(""),console.log(N.colors.border("\u250C"+"\u2500".repeat(r-2)+"\u2510")),console.log(o(_t.default.cyan.bold("Agent powering down. Goodbye!"))),console.log(N.colors.border("\u251C"+"\u2500".repeat(r-2)+"\u2524")),console.log(o(N.colors.success("Session Summary"))),console.log(o(N.colors.dim("\u2500".repeat(15)))),console.log(s("Duration",a,"Tool Calls",t.toolCalls.toString())),console.log(s("Turns",t.turns.toString(),"Files Modified",t.filesModified.toString())),console.log(o("")),console.log(o(N.colors.success("Token Usage"))),console.log(o(N.colors.dim("\u2500".repeat(11)))),console.log(s("Input",u,"Output",c)),console.log(o(N.colors.dim("Cost".padEnd(15))+l)),console.log(o("")),console.log(o(N.colors.dim("Model: ")+N.colors.model(d))),console.log(N.colors.border("\u2514"+"\u2500".repeat(r-2)+"\u2518")),console.log("")}});var zO=_(tu=>{"use strict";var Jbe=tu&&tu.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(tu,"__esModule",{value:!0});tu.CommandMenu=void 0;tu.createCommandMenu=Ybe;var Ef=Jbe((St(),Et(Tt))),qc=xc(),z_=class{commands=[];filteredCommands=[];selectedIndex=0;isVisible=!1;linesDrawn=0;lastOffset=0;maxVisibleItems=8;spaceCreated=!1;lastMenuLines=0;constructor(e){this.commands=e,this.filteredCommands=e}setCommands(e){this.commands=e,this.filter("")}filter(e){let r=e.startsWith("/")?e.slice(1).toLowerCase():e.toLowerCase();r?this.filteredCommands=this.commands.filter(n=>!!(n.name.toLowerCase().startsWith(r)||n.aliases?.some(i=>i.toLowerCase().startsWith(r)))):this.filteredCommands=this.commands,this.selectedIndex=0}moveUp(){this.filteredCommands.length!==0&&(this.selectedIndex=(this.selectedIndex-1+this.filteredCommands.length)%this.filteredCommands.length)}moveDown(){this.filteredCommands.length!==0&&(this.selectedIndex=(this.selectedIndex+1)%this.filteredCommands.length)}getSelected(){return this.filteredCommands[this.selectedIndex]??null}getFilteredCount(){return this.filteredCommands.length}getIsVisible(){return this.isVisible}show(){this.isVisible=!0,this.selectedIndex=0}hide(e){this.isVisible&&(this.isVisible=!1,this.clear(),e!==void 0&&e>0&&process.stdout.write(`\x1B[${e}G`))}clear(){if(this.linesDrawn>0&&this.spaceCreated){process.stdout.write(`\x1B[${this.lastOffset}B`),process.stdout.write("\r");for(let r=0;r<this.linesDrawn;r++)process.stdout.write("\x1B[2K"),r<this.linesDrawn-1&&(process.stdout.write("\x1B[1B"),process.stdout.write("\r"));let e=this.lastOffset+this.linesDrawn-1;process.stdout.write(`\x1B[${e}A`),process.stdout.write("\r"),this.linesDrawn=0}this.spaceCreated=!1,this.lastMenuLines=0}draw(e,r){if(!this.isVisible||this.filteredCommands.length===0){this.clear(),r!==void 0&&r>0&&process.stdout.write(`\x1B[${r}G`);return}let n=process.stdout.columns||80,i=Math.min(60,n-4),o=Math.min(this.maxVisibleItems,this.filteredCommands.length),s=0;this.selectedIndex>=o&&(s=this.selectedIndex-o+1);let a=Math.min(s+o,this.filteredCommands.length),u=this.filteredCommands.length>o,c=2+(a-s)+(u?1:0);if(!this.spaceCreated||this.lastMenuLines!==c||this.lastOffset!==e){this.spaceCreated&&this.clear(),this.lastOffset=e,this.lastMenuLines=c,process.stdout.write(`\x1B[${e}B`),process.stdout.write("\r");for(let g=0;g<c;g++)process.stdout.write(`
491
+ `)}function _be(){console.log(m2)}});var U_=_(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0});Of.createSession=ybe;Of.serializeSession=bbe;Of.deserializeSession=Sbe;function ybe(t={}){let e=new Date;return{id:vbe(),projectPath:t.projectPath??process.cwd(),createdAt:e,updatedAt:e,messages:[],model:t.model??"claude-sonnet-4",provider:t.provider??"anthropic",permissionCache:new Map,fileChanges:[],stats:{startTime:Date.now(),totalTurns:0,tokensIn:0,tokensOut:0,totalCost:0,toolCalls:0,filesModified:0},mode:t.mode??"interactive"}}function vbe(){let t=Date.now().toString(36),e=Math.random().toString(36).slice(2,9);return`session_${t}_${e}`}function bbe(t){return{id:t.id,projectPath:t.projectPath,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),messages:t.messages,model:t.model,provider:t.provider,permissionCache:Array.from(t.permissionCache.entries()),fileChanges:t.fileChanges,stats:t.stats,mode:t.mode}}function Sbe(t){return{id:t.id,projectPath:t.projectPath,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),messages:t.messages,model:t.model,provider:t.provider??"anthropic",permissionCache:new Map(t.permissionCache),fileChanges:t.fileChanges,stats:t.stats,mode:t.mode}}});var xc=_(N=>{"use strict";var $be=N&&N.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(N,"__esModule",{value:!0});N.colors=N.VERSION=void 0;N.printLogo=wbe;N.printPrompt=Dbe;N.printAction=Pbe;N.printToolComplete=Obe;N.printToolFailed=Ebe;N.printToolResultBox=Cbe;N.printSuccess=Tbe;N.printWarning=jbe;N.printError=Ibe;N.printDivider=v2;N.printHeader=kbe;N.getActionIndicator=Mbe;N.formatPath=Abe;N.formatCode=Nbe;N.printPermissionPrompt=Fbe;N.printModelInfo=Rbe;N.printTokenUsage=xbe;N.shortenPath=qbe;N.padEndAnsi=Lbe;N.printWelcomeBanner=Zbe;N.printInputBox=Ube;N.printContextLine=zbe;N.getModeDisplay=b2;N.printStatusBar=Bbe;N.printInputBoxTop=Vbe;N.printInputBoxBottom=Wbe;N.getPromptWithHint=Kbe;N.printExitSummary=Hbe;var _t=$be((St(),Et(Tt)));N.VERSION="0.2.6";var y2=[" \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u255A\u2550\u255D \u255A\u2550\u255D","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2557 \u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551","\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D"];N.colors={logo:_t.default.cyan.bold,prompt:_t.default.cyan.bold,model:_t.default.cyan,success:_t.default.green,warning:_t.default.yellow,error:_t.default.red,thinking:_t.default.dim.cyan,filePath:_t.default.blue,code:_t.default.white,muted:_t.default.gray,dim:_t.default.dim,safe:_t.default.green,risky:_t.default.yellow,destructive:_t.default.red,border:_t.default.cyan,bannerBorder:_t.default.cyan};function wbe(t=N.VERSION){console.log(N.colors.logo(y2)+N.colors.dim(` v${t}`))}function Dbe(t="> "){process.stdout.write(N.colors.prompt(t))}function Pbe(t,e,r=console.log){r(N.colors.dim("\u25CB ")+_t.default.white(t)+" "+N.colors.filePath(e))}function Obe(t,e,r=console.log){r(N.colors.success("\u2713 ")+_t.default.white(t)+" "+N.colors.filePath(e))}function Ebe(t,e,r,n=console.log){n(N.colors.error("\u2717 ")+_t.default.white(t)+" "+N.colors.filePath(e)),r&&n(N.colors.dim(" \u2192 ")+N.colors.error(r))}function Cbe(t,e,r,n=!0,i,o=console.log){let s=process.stdout.columns||80,a=s,u=a-4;process.env.AII_DEBUG&&console.error(`[DEBUG] termWidth=${s}, boxWidth=${a}, innerWidth=${u}`);let c=v=>v.replace(/\x1b\[[0-9;]*m/g,""),l=_t.default.dim.cyan,d=v=>{let w=c(v).replace(/\t/g," "),P=w.length>u?w.slice(0,u-3)+"...":w,T=u-P.length;return l("\u2502")+" "+P+" ".repeat(T)+" "+l("\u2502")},g=` ${n?N.colors.success("\u2713"):N.colors.error("\u2717")} ${_t.default.bold(t)} `,p=3+t.length+1,m=a-3-p;if(o(l("\u250C\u2500")+g+l("\u2500".repeat(Math.max(0,m))+"\u2510")),i){let v=`${e} - ${i}`;o(d(v))}else o(d(e));if(r&&r.length>0){o(l("\u251C"+"\u2500".repeat(a-2)+"\u2524"));let v=20,$=r.slice(0,v);for(let w of $)o(d(w));if(r.length>v){let w=`... +${r.length-v} more lines`;o(d(w))}}o(l("\u2514"+"\u2500".repeat(a-2)+"\u2518"))}function Tbe(t){console.log(N.colors.success("\u2713 ")+t)}function jbe(t){console.log(N.colors.warning("\u26A0 ")+t)}function Ibe(t){console.log(N.colors.error("\u2717 ")+t)}function v2(t=60){console.log(N.colors.dim("\u2500".repeat(t)))}function kbe(t){console.log(N.colors.logo(t)),v2(t.length)}function Mbe(t){return N.colors.thinking(`[${t}]`)}function Abe(t){let e=process.env.HOME??process.env.USERPROFILE??"";return e&&t.startsWith(e)?N.colors.filePath("~"+t.slice(e.length)):N.colors.filePath(t)}function Nbe(t){return N.colors.code(t)}function Fbe(t,e){let r=" Permission Required ",n="(y)es / (n)o / (a)lways / (s)ession",i=`Aii wants to run: ${t}`,o=60,s=process.stdout.columns||80,a=Math.min(s-2,120),u=[i.length+4,e.length+4,n.length+4],c=Math.max(...u),l=Math.max(o,Math.min(c,a)),d=Math.max(0,l-3-r.length),f=l-2,g=m=>m.replace(/\x1b\[[0-9;]*m/g,""),p=(m,v)=>{let $=v??g(m),w=m,P=$.length,T=f-1;if(P>T){let F=$.slice(0,T-3)+"...";w=m===$?F:N.colors.dim(F),P=F.length}let C=Math.max(0,f-P-1);return N.colors.warning("\u2502")+" "+w+" ".repeat(C)+N.colors.warning("\u2502")};console.log(""),console.log(N.colors.warning("\u250C\u2500"+r+"\u2500".repeat(d)+"\u2510")),console.log(p("")),console.log(p(`Aii wants to run: ${_t.default.bold(t)}`,i)),console.log(p(N.colors.dim(e),e)),console.log(p("")),console.log(p(N.colors.prompt(n),n)),console.log(N.colors.warning("\u2514"+"\u2500".repeat(l-2)+"\u2518"))}function Rbe(t,e){let r=e?N.colors.dim(` (${e})`):"";console.log(`Model: ${N.colors.model(t)}${r}`)}function xbe(t,e,r){let n=`${N.colors.dim("Tokens:")} ${t} in / ${e} out`;r!==void 0&&(n+=` ${N.colors.dim("\u2022")} $${r.toFixed(4)}`),console.log(N.colors.dim(n))}function Rc(){return process.stdout.columns||80}function qbe(t,e=40){let r=process.env.HOME??process.env.USERPROFILE??"",n=t;if(r&&t.startsWith(r)&&(n="~"+t.slice(r.length)),n.length<=e)return n;let i=n.split("/").filter(s=>s.length>0);if(i.length>=2){let s=i.slice(-2).join("/");if(s.length<=e-4)return".../"+s}return".../"+(i[i.length-1]||i[i.length-2])}function UO(t){return t.replace(/\x1b\[[0-9;]*m/g,"").length}function Lbe(t,e){let r=UO(t),n=Math.max(0,e-r);return t+" ".repeat(n)}function Zbe(t){let e=Rc(),r=Math.min(e,90),n=r-5,i=Math.floor(n*.42),o=n-i,s=$=>$.replace(/\x1b\[[0-9;]*m/g,"").length,a=($,w)=>{let P=s($);return $+" ".repeat(Math.max(0,w-P))},u=y2.map($=>N.colors.logo($)),c=N.colors.success("Tips for getting started"),l="Ask questions, edit files, or run commands.",d="Be specific for the best results.",f=N.colors.dim("/help")+" for more information.",g=[];g.push({left:"",right:c});for(let $=0;$<6;$++){let w=u[$]||"",P="";$===0&&(P=l),$===1&&(P=d),$===2&&(P=f),g.push({left:w,right:P})}let p=` Aii CLI v${N.VERSION} `,m=p.length,v=r-4-m;console.log(N.colors.bannerBorder("\u250C\u2500")+_t.default.bold.white(p)+N.colors.bannerBorder("\u2500".repeat(Math.max(0,v)))+N.colors.bannerBorder("\u2500\u2510"));for(let $ of g){let w=a($.left,i),P=a($.right,o);console.log(N.colors.bannerBorder("\u2502")+" "+w+N.colors.bannerBorder("\u2502")+" "+P+N.colors.bannerBorder("\u2502"))}console.log(N.colors.bannerBorder("\u2514"+"\u2500".repeat(r-2)+"\u2518"))}function Ube(){let t=Math.min(Rc()-2,80);console.log(N.colors.dim("\u250C"+"\u2500".repeat(t)+"\u2510")),console.log(N.colors.dim("\u2502 ")+N.colors.prompt("> ")+N.colors.dim("Type your message or @path/to/file")+N.colors.dim(" ".repeat(Math.max(0,t-36)))+N.colors.dim("\u2502")),console.log(N.colors.dim("\u2514"+"\u2500".repeat(t)+"\u2518"))}function zbe(t){let e=[];t.tools&&t.tools>0&&e.push(`${t.tools} tool${t.tools>1?"s":""}`);let r=t.mcpServers??0;r>0&&e.push(`${r} MCP server${r>1?"s":""}`),t.contextFiles&&t.contextFiles>0&&e.push(`${t.contextFiles} context file${t.contextFiles>1?"s":""}`),e.length>0&&console.log(N.colors.dim("Using: ")+N.colors.dim(e.join(" | ")))}function b2(t){switch(t){case"auto":return N.colors.warning("Auto");case"plan":return N.colors.thinking("Plan");case"interactive":default:return N.colors.success("Normal")}}function Bbe(t){let e=Rc(),r=N.colors.filePath(t.projectPath);t.branch&&(r+=N.colors.dim(` (${t.branch})`));let n=t.model.replace("claude-","").replace("deepseek-","").replace("-latest",""),i=b2(t.mode)+N.colors.dim(" (")+N.colors.model(n)+N.colors.dim(")");t.memoryMB!==void 0&&(i+=N.colors.dim(" | ")+N.colors.dim(`${t.memoryMB.toFixed(1)} MB`));let o=UO(r),s=UO(i),a=Math.max(1,e-o-s-2);console.log(r+" ".repeat(a)+i)}function Vbe(){let t=Math.min(Rc(),100);console.log(N.colors.dim("\u250C"+"\u2500".repeat(t-2)+"\u2510"))}function Wbe(){let t=Math.min(Rc(),100);console.log(N.colors.dim("\u2514"+"\u2500".repeat(t-2)+"\u2518"))}function Kbe(t=!0){return t?N.colors.prompt("> ")+N.colors.dim("Type your message..."):N.colors.prompt("> ")}function Gbe(t){if(t<60)return`${t}s`;let e=Math.floor(t/60),r=t%60;return r>0?`${e}m ${r}s`:`${e}m`}function _2(t){return t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Hbe(t){let e=Rc(),r=Math.min(e-2,76),n=r-4,i=(f,g)=>{let p=f.replace(/\x1b\[[0-9;]*m/g,"").length;return f+" ".repeat(Math.max(0,g-p))},o=f=>N.colors.border("\u2502")+" "+i(f,n)+" "+N.colors.border("\u2502"),s=(f,g,p,m)=>{let v=Math.floor(n/2),$=N.colors.dim(f.padEnd(15))+g,w=N.colors.dim(p.padEnd(15))+m;return o(i($,v)+w)},a=Gbe(t.durationSeconds),u=_2(t.tokensIn),c=_2(t.tokensOut),l=`$${t.totalCost.toFixed(4)}`,d=`${t.provider}/${t.model.replace("claude-","").replace("-latest","")}`;console.log(""),console.log(N.colors.border("\u250C"+"\u2500".repeat(r-2)+"\u2510")),console.log(o(_t.default.cyan.bold("Agent powering down. Goodbye!"))),console.log(N.colors.border("\u251C"+"\u2500".repeat(r-2)+"\u2524")),console.log(o(N.colors.success("Session Summary"))),console.log(o(N.colors.dim("\u2500".repeat(15)))),console.log(s("Duration",a,"Tool Calls",t.toolCalls.toString())),console.log(s("Turns",t.turns.toString(),"Files Modified",t.filesModified.toString())),console.log(o("")),console.log(o(N.colors.success("Token Usage"))),console.log(o(N.colors.dim("\u2500".repeat(11)))),console.log(s("Input",u,"Output",c)),console.log(o(N.colors.dim("Cost".padEnd(15))+l)),console.log(o("")),console.log(o(N.colors.dim("Model: ")+N.colors.model(d))),console.log(N.colors.border("\u2514"+"\u2500".repeat(r-2)+"\u2518")),console.log("")}});var zO=_(tu=>{"use strict";var Jbe=tu&&tu.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(tu,"__esModule",{value:!0});tu.CommandMenu=void 0;tu.createCommandMenu=Ybe;var Ef=Jbe((St(),Et(Tt))),qc=xc(),z_=class{commands=[];filteredCommands=[];selectedIndex=0;isVisible=!1;linesDrawn=0;lastOffset=0;maxVisibleItems=8;spaceCreated=!1;lastMenuLines=0;constructor(e){this.commands=e,this.filteredCommands=e}setCommands(e){this.commands=e,this.filter("")}filter(e){let r=e.startsWith("/")?e.slice(1).toLowerCase():e.toLowerCase();r?this.filteredCommands=this.commands.filter(n=>!!(n.name.toLowerCase().startsWith(r)||n.aliases?.some(i=>i.toLowerCase().startsWith(r)))):this.filteredCommands=this.commands,this.selectedIndex=0}moveUp(){this.filteredCommands.length!==0&&(this.selectedIndex=(this.selectedIndex-1+this.filteredCommands.length)%this.filteredCommands.length)}moveDown(){this.filteredCommands.length!==0&&(this.selectedIndex=(this.selectedIndex+1)%this.filteredCommands.length)}getSelected(){return this.filteredCommands[this.selectedIndex]??null}getFilteredCount(){return this.filteredCommands.length}getIsVisible(){return this.isVisible}show(){this.isVisible=!0,this.selectedIndex=0}hide(e){this.isVisible&&(this.isVisible=!1,this.clear(),e!==void 0&&e>0&&process.stdout.write(`\x1B[${e}G`))}clear(){if(this.linesDrawn>0&&this.spaceCreated){process.stdout.write(`\x1B[${this.lastOffset}B`),process.stdout.write("\r");for(let r=0;r<this.linesDrawn;r++)process.stdout.write("\x1B[2K"),r<this.linesDrawn-1&&(process.stdout.write("\x1B[1B"),process.stdout.write("\r"));let e=this.lastOffset+this.linesDrawn-1;process.stdout.write(`\x1B[${e}A`),process.stdout.write("\r"),this.linesDrawn=0}this.spaceCreated=!1,this.lastMenuLines=0}draw(e,r){if(!this.isVisible||this.filteredCommands.length===0){this.clear(),r!==void 0&&r>0&&process.stdout.write(`\x1B[${r}G`);return}let n=process.stdout.columns||80,i=Math.min(60,n-4),o=Math.min(this.maxVisibleItems,this.filteredCommands.length),s=0;this.selectedIndex>=o&&(s=this.selectedIndex-o+1);let a=Math.min(s+o,this.filteredCommands.length),u=this.filteredCommands.length>o,c=2+(a-s)+(u?1:0);if(!this.spaceCreated||this.lastMenuLines!==c||this.lastOffset!==e){this.spaceCreated&&this.clear(),this.lastOffset=e,this.lastMenuLines=c,process.stdout.write(`\x1B[${e}B`),process.stdout.write("\r");for(let g=0;g<c;g++)process.stdout.write(`
492
492
  `);process.stdout.write(`\x1B[${c}A`),process.stdout.write("\r"),this.spaceCreated=!0}else process.stdout.write(`\x1B[${e}B`),process.stdout.write("\r");this.linesDrawn=0;let d=this.renderLines(i);for(let g=0;g<d.length;g++)process.stdout.write("\x1B[2K"),process.stdout.write(d[g]),this.linesDrawn++,g<d.length-1&&(process.stdout.write("\x1B[1B"),process.stdout.write("\r"));let f=e+c-1;process.stdout.write(`\x1B[${f}A`),r!==void 0&&r>0?process.stdout.write(`\x1B[${r}G`):process.stdout.write("\r")}renderLines(e){if(!this.isVisible||this.filteredCommands.length===0)return[];let r=[],n=Math.min(60,e-4),i=Math.min(this.maxVisibleItems,this.filteredCommands.length),o=0;this.selectedIndex>=i&&(o=this.selectedIndex-i+1);let s=Math.min(o+i,this.filteredCommands.length),a=this.filteredCommands.length>i,u=` Commands (${this.filteredCommands.length}) `,c=Math.max(0,n-u.length-2);r.push(qc.colors.border("\u250C\u2500"+u+"\u2500".repeat(c)+"\u2510"));for(let f=o;f<s;f++){let g=this.filteredCommands[f],p=f===this.selectedIndex,m=`/${g.name}`,v=g.description,$=n-m.length-6,w=v.length>$?v.slice(0,$-1)+"\u2026":v,P="";if(p){let T=X=>Ef.default.bgCyan.black(X);P=T(` /${g.name}`)+T(` ${w}`);let C=m.length+w.length+3,F=Math.max(0,n-C-2);P+=Ef.default.bgCyan(" ".repeat(F))}else{P=` ${Ef.default.cyan(m)} ${Ef.default.dim(w)}`;let T=m.length+w.length+3,C=Math.max(0,n-T-2);P+=" ".repeat(C)}r.push(qc.colors.border("\u2502")+P+qc.colors.border("\u2502"))}if(a){let f=o>0?"\u25B2":" ",g=s<this.filteredCommands.length?"\u25BC":" ",p=` ${f} ${this.selectedIndex+1}/${this.filteredCommands.length} ${g}`,m=Math.max(0,n-p.length-2);r.push(qc.colors.border("\u2502")+Ef.default.dim(p)+" ".repeat(m)+qc.colors.border("\u2502"))}let l="\u2191\u2193 navigate \u2022 Enter select \u2022 Esc cancel",d=Math.max(0,n-l.length-2);return r.push(qc.colors.border("\u2514\u2500"+l+"\u2500".repeat(d)+"\u2518")),r}};tu.CommandMenu=z_;function Ybe(t){return new z_(t)}});var Tf=_(Bs=>{"use strict";var Xbe=Bs&&Bs.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Bs,"__esModule",{value:!0});Bs.PersistentUI=void 0;Bs.getPersistentUI=e0e;Bs.createPersistentUI=t0e;var yt=Xbe((St(),Et(Tt))),Qbe=zO(),Lc=yt.default.cyan,S2="Type your message or @path/to/file",Cf=class{isActive=!1;context;currentStatus="";linesDrawn=0;inputBuffer="";cursorIndex=0;inputHandler=null;isInputActive=!1;commandMenu=null;slashCommands=[];showSlashCommandWarning=!1;streamingFooterDrawn=!1;streamingContentBuffer="";streamingContentLines=0;lastFooterHeight=0;setContext(e){this.context=e}setSlashCommands(e){this.slashCommands=e,this.commandMenu&&this.commandMenu.setCommands(e)}getAndClearBuffer(){let e=this.inputBuffer;return this.inputBuffer="",e}hasBufferedInput(){return this.inputBuffer.length>0}getTerminalWidth(){return process.stdout.columns||80}formatModelName(){if(!this.context)return"";let e=this.context.model||"";return this.context.provider==="anthropic"&&e.startsWith("claude-")&&(e=e.slice(7)),e.replace(/-latest$/,"")}formatStatusBar(e){if(!this.context)return"";let r=this.context,n=process.env.HOME??process.env.USERPROFILE??"",i=r.projectPath;n&&r.projectPath.startsWith(n)&&(i="~"+r.projectPath.slice(n.length));let o=yt.default.blue(i);r.branch&&(o+=yt.default.dim(` (${r.branch})`));let s=r.model||"",a=`${r.provider}-`;if(s.startsWith(a)){let $=s.slice(a.length);($.length>5||$.includes("-"))&&(s=$)}r.provider==="anthropic"&&s.startsWith("claude-")&&(s=s.slice(7)),s=s.replace(/-latest$/,"");let u=r.mode==="auto"?yt.default.yellow:r.mode==="plan"?yt.default.cyan:yt.default.green,c=(r.mode||"").toLowerCase(),l=c==="interactive"||c==="normal"?"Normal":r.mode?r.mode.charAt(0).toUpperCase()+r.mode.slice(1):"Unknown",d=`${r.provider}/${s}`,f=u(l)+yt.default.dim(" (")+yt.default.cyan(d)+yt.default.dim(")"),g=$=>$.replace(/\x1b\[[0-9;]*m/g,"").length,p=g(o),m=g(f),v=Math.max(1,e-p-m);return o+" ".repeat(v)+f}buildStatusLine(e){let r=this.context?yt.default.dim(` (${this.context.provider}/${this.formatModelName()})`):"";return` ${yt.default.cyan(e)}${r} ${yt.default.dim("[esc to cancel]")}`}buildInputBox(){let e=this.getTerminalWidth(),r="> ",n=r.length,i=Math.max(0,e-2),o=Lc("\u250C"+"\u2500".repeat(i)+"\u2510"),s=Lc("\u2514"+"\u2500".repeat(i)+"\u2518"),a=e-4-n,u;if(this.inputBuffer.length>0){let l=this.inputBuffer.substring(0,a-1),d=l.split(""),f=[],g=this.cursorIndex===l.length;for(let $=0;$<l.length;$++)$===this.cursorIndex?f.push(yt.default.inverse(d[$])):f.push(d[$]);g&&f.push(yt.default.cyan("\u2588"));let p=f.join(""),m=l.length+(g?1:0),v=Math.max(0,a-m);u=Lc("\u2502")+" "+yt.default.cyan.bold(r)+p+" ".repeat(v)+" "+Lc("\u2502")}else{let c=S2.length,l=Math.max(0,a-2-c);u=Lc("\u2502")+" "+yt.default.cyan.bold(r)+yt.default.dim("\u2588")+" "+yt.default.dim(S2)+" ".repeat(l)+" "+Lc("\u2502")}return[o,u,s,this.buildFooterStatusLine()]}activate(){this.isActive||(this.isActive=!0,this.linesDrawn=0,this.inputBuffer="",this.cursorIndex=0,process.stdout.write("\x1B[?25l"))}deactivate(){this.isActive&&(this.stopInputCapture(),this.clearUI(),this.isActive=!1,this.linesDrawn=0,this.currentStatus="",process.stdout.write("\x1B[?25h"))}startInputCapture(){if(this.isInputActive||!process.stdin.isTTY)return;this.isInputActive=!0,this.cursorIndex=this.inputBuffer.length;let r=this.getTerminalWidth()-8;this.inputHandler=n=>{let i=n.toString();this.slashCommands.length>0&&!this.commandMenu&&(this.commandMenu=new Qbe.CommandMenu(this.slashCommands));let o=()=>5+this.cursorIndex,s=()=>{if(this.commandMenu)if(this.inputBuffer.startsWith("/"))this.commandMenu.getIsVisible()||this.commandMenu.show(),this.commandMenu.filter(this.inputBuffer),this.redrawMenu();else{let a=this.commandMenu.getIsVisible();this.commandMenu.hide(o()),a?this.redrawMenu():process.stdout.write("\x1B[2B")}};if(this.showSlashCommandWarning=!1,i.startsWith("\x1B")){if(i==="\x1B"){if(this.commandMenu?.getIsVisible()){this.commandMenu.hide(o()),this.redrawMenu();return}this.redrawInputLine();return}if(i==="\x1B[A"&&this.commandMenu?.getIsVisible()){this.commandMenu.moveUp(),this.redrawMenu();return}if(i==="\x1B[B"&&this.commandMenu?.getIsVisible()){this.commandMenu.moveDown(),this.redrawMenu();return}if(i==="\x1B[D"){this.cursorIndex=Math.max(0,this.cursorIndex-1),this.redrawInputLine();return}if(i==="\x1B[C"){this.cursorIndex=Math.min(this.inputBuffer.length,this.cursorIndex+1),this.redrawInputLine();return}return}if(i!==""){if(i==="\r"||i===`
493
493
  `){if(this.commandMenu?.getIsVisible()){let a=this.commandMenu.getSelected();if(a&&a){this.inputBuffer="/"+a.name,this.cursorIndex=this.inputBuffer.length,this.commandMenu.hide(o()),this.redrawInputLine();return}return}if(this.inputBuffer.trim().startsWith("/")){this.showSlashCommandWarning=!0,this.redrawInputLine();return}return}if(i===" "&&this.commandMenu?.getIsVisible()){let a=this.commandMenu.getSelected();if(a&&a){this.inputBuffer="/"+a.name+" ",this.cursorIndex=this.inputBuffer.length,this.commandMenu.hide(o()),this.redrawInputLine();return}return}if(i==="\x7F"||i==="\b"){if(this.inputBuffer.length>0&&this.cursorIndex>0){let a=this.inputBuffer.slice(0,this.cursorIndex-1),u=this.inputBuffer.slice(this.cursorIndex);this.inputBuffer=a+u,this.cursorIndex--,this.redrawInputLine(),s()}return}for(let a of i)if(a>=" "&&a<="~"&&this.inputBuffer.length<r){let u=this.inputBuffer.slice(0,this.cursorIndex),c=this.inputBuffer.slice(this.cursorIndex);this.inputBuffer=u+a+c,this.cursorIndex++}this.redrawInputLine(),s()}},this.inputHandler&&process.stdin.on("data",this.inputHandler)}stopInputCapture(){this.isInputActive&&(this.isInputActive=!1,this.inputHandler&&(process.stdin.removeListener("data",this.inputHandler),this.inputHandler=null))}redrawInputLine(){if(this.linesDrawn===0)return;let r=2+this.getMenuHeight();process.stdout.write("\x1B7"),process.stdout.write(`\x1B[${r+2}A`),process.stdout.write("\r\x1B[2K"),process.stdout.write(this.getWarningLine()),process.stdout.write("\x1B[2B"),process.stdout.write("\r\x1B[2K"),process.stdout.write(this.buildInputBox()[1]),process.stdout.write("\x1B8")}getMenuHeight(){if(!this.commandMenu||!this.commandMenu.getIsVisible())return 0;let e=this.getTerminalWidth();return this.commandMenu.renderLines(e).length}redrawMenu(){if(!this.commandMenu)return;let e=this.getTerminalWidth(),r=this.commandMenu.renderLines(e),n=4;this.lastFooterHeight>0?process.stdout.write(`\x1B[${this.lastFooterHeight}A`):process.stdout.write("\x1B[4A"),process.stdout.write("\r"),process.stdout.write(`\x1B[${n}B`);for(let o of r)process.stdout.write(`
494
494
  \x1B[2K`+o);process.stdout.write("\x1B[0J");let i=r.length;this.lastFooterHeight=n+i}clearUI(){if(this.linesDrawn>0){for(let e=0;e<this.linesDrawn;e++)process.stdout.write("\x1B[1A"),process.stdout.write("\x1B[2K");process.stdout.write("\r"),this.linesDrawn=0,process.stdout.write("\x1B[?25h")}}clearStatus(){this.isActive&&this.clearUI()}updateStatus(e){if(this.isActive){if(this.currentStatus=e,this.streamingFooterDrawn){this.redrawBufferAndFooter();return}this.linesDrawn>0&&(process.stdout.write("\x1B7"),process.stdout.write(`\x1B[${this.linesDrawn}A`),process.stdout.write("\r\x1B[2K"),process.stdout.write(this.buildStatusLine(e)),process.stdout.write("\x1B8"))}}drawInitial(e){this.isActive&&(this.currentStatus=e,this.linesDrawn===0&&this.drawUI(e))}drawUI(e){let r=this.getTerminalWidth();process.stdout.write("\x1B[?25l");let n=this.buildStatusLine(e),i=this.buildInputBox(),o=this.formatStatusBar(r);process.stdout.write("\r"),process.stdout.write(n+`
@@ -1031,7 +1031,7 @@ Prompt validation coming soon.
1031
1031
  \u274C Missing prompt name`),console.error(` Usage: aii prompt use <name> [--vars]
1032
1032
  `),process.exit(1)),await Jwe(t,r,n,c);break;case"validate":r||(console.error(`
1033
1033
  \u274C Missing file path`),console.error(` Usage: aii prompt validate <file>
1034
- `),process.exit(1)),await Ywe(t,r);break;case"help":case"--help":case"-h":default:Kwe(!t.flags.noColors);break}}});var rz=_(tn=>{"use strict";var Qwe=tn&&tn.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),eDe=tn&&tn.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Qwe(e,t,r)};Object.defineProperty(tn,"__esModule",{value:!0});tn.loadPrompt=tn.listPrompts=tn.handlePrompt=void 0;var tDe=ez();Object.defineProperty(tn,"handlePrompt",{enumerable:!0,get:function(){return tDe.handlePrompt}});var tz=TE();Object.defineProperty(tn,"listPrompts",{enumerable:!0,get:function(){return tz.listPrompts}});Object.defineProperty(tn,"loadPrompt",{enumerable:!0,get:function(){return tz.loadPrompt}});eDe(jE(),tn)});var iz=_(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.AiiServerManager=At.DEFAULT_PORT=void 0;At.ensureAiiServer=aDe;var Qo=require("child_process"),nz=require("fs"),rDe=require("os"),nDe=require("path"),iDe="aiiware/aii-server:latest",oDe="aii-server";At.DEFAULT_PORT=26169;var Ks="v0.3.17",cu="https://aiiware.short.gy/server.sh",yy=class t{port;host;containerName;image;configDir;constructor(e=At.DEFAULT_PORT){this.port=e,this.host="127.0.0.1",this.containerName=oDe,this.image=iDe,this.configDir=(0,nDe.join)((0,rDe.homedir)(),".aii")}isDockerAvailable(){try{return(0,Qo.execSync)("docker info",{stdio:"pipe",timeout:5e3}),!0}catch{return!1}}isContainerExists(){try{return(0,Qo.execSync)(`docker container inspect ${this.containerName}`,{stdio:"pipe",timeout:5e3}),!0}catch{return!1}}isContainerRunning(){try{return(0,Qo.execSync)(`docker container inspect -f "{{.State.Running}}" ${this.containerName}`,{stdio:"pipe",timeout:5e3,encoding:"utf-8"}).trim()==="true"}catch{return!1}}async isServerHealthy(){try{let e=new AbortController,r=setTimeout(()=>e.abort(),2e3),n=await fetch(`http://${this.host}:${this.port}/health`,{signal:e.signal});return clearTimeout(r),n.ok}catch{return!1}}async getServerVersion(){try{let e=new AbortController,r=setTimeout(()=>e.abort(),2e3),n=await fetch(`http://${this.host}:${this.port}/v0/status`,{signal:e.signal});return clearTimeout(r),n.ok&&(await n.json()).version||null}catch{return null}}static isVersionBelow(e,r){try{let n=e?.replace(/^v/,"")||"0.0.0",i=r?.replace(/^v/,"")||"0.0.0",o=n.split(".").map(Number),s=i.split(".").map(Number),a=Math.max(o.length,s.length);for(;o.length<a;)o.push(0);for(;s.length<a;)s.push(0);for(let u=0;u<a;u++){if(o[u]<s[u])return!0;if(o[u]>s[u])return!1}return!1}catch{return!1}}async checkServerAtPort(e){try{let r=new AbortController,n=setTimeout(()=>r.abort(),2e3),i=await fetch(`http://${this.host}:${e}/health`,{signal:r.signal});if(clearTimeout(n),!i.ok)return{isCompatible:!1,version:null};let o=new AbortController,s=setTimeout(()=>o.abort(),2e3),a=await fetch(`http://${this.host}:${e}/v0/status`,{signal:o.signal});if(clearTimeout(s),a.ok){let c=(await a.json()).version||null;return c?{isCompatible:!t.isVersionBelow(c,Ks),version:c}:{isCompatible:!0,version:null}}return{isCompatible:!0,version:null}}catch{return{isCompatible:!1,version:null}}}getContainerHostPort(){try{let e=(0,Qo.execSync)(`docker inspect --format='{{(index (index .NetworkSettings.Ports "26169/tcp") 0).HostPort}}' ${this.containerName}`,{stdio:"pipe",timeout:5e3,encoding:"utf-8"}),r=parseInt(e.trim(),10);return isNaN(r)?null:r}catch{return null}}async scanForServer(e=At.DEFAULT_PORT,r=10){for(let n=0;n<r;n++){let i=e+n,{isCompatible:o}=await this.checkServerAtPort(i);if(o)return i}return null}startContainer(){try{return(0,Qo.execSync)(`docker start ${this.containerName}`,{stdio:"pipe",timeout:3e4}),!0}catch{return!1}}stopContainer(){try{return(0,Qo.execSync)(`docker stop ${this.containerName}`,{stdio:"pipe",timeout:3e4}),!0}catch{return!1}}getContainerLogs(e=50){try{return(0,Qo.execSync)(`docker logs --tail ${e} ${this.containerName}`,{stdio:"pipe",timeout:1e4,encoding:"utf-8"})}catch{return""}}async waitForHealthy(e=3e4){let r=Date.now(),n=!1,i=()=>{n=!0,process.exit(130)};process.on("SIGINT",i);try{for(;Date.now()-r<e&&!n;){if(await this.isServerHealthy())return!0;await new Promise(o=>setTimeout(o,500))}return!1}finally{process.removeListener("SIGINT",i)}}async runInstallScript(e=!0){return new Promise(r=>{e&&console.log(` Running: curl -fsSL ${cu} | bash
1034
+ `),process.exit(1)),await Ywe(t,r);break;case"help":case"--help":case"-h":default:Kwe(!t.flags.noColors);break}}});var rz=_(tn=>{"use strict";var Qwe=tn&&tn.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),eDe=tn&&tn.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Qwe(e,t,r)};Object.defineProperty(tn,"__esModule",{value:!0});tn.loadPrompt=tn.listPrompts=tn.handlePrompt=void 0;var tDe=ez();Object.defineProperty(tn,"handlePrompt",{enumerable:!0,get:function(){return tDe.handlePrompt}});var tz=TE();Object.defineProperty(tn,"listPrompts",{enumerable:!0,get:function(){return tz.listPrompts}});Object.defineProperty(tn,"loadPrompt",{enumerable:!0,get:function(){return tz.loadPrompt}});eDe(jE(),tn)});var iz=_(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.AiiServerManager=At.DEFAULT_PORT=void 0;At.ensureAiiServer=aDe;var Qo=require("child_process"),nz=require("fs"),rDe=require("os"),nDe=require("path"),iDe="aiiware/aii-server:latest",oDe="aii-server";At.DEFAULT_PORT=26169;var Ks="v0.3.18",cu="https://aiiware.short.gy/server.sh",yy=class t{port;host;containerName;image;configDir;constructor(e=At.DEFAULT_PORT){this.port=e,this.host="127.0.0.1",this.containerName=oDe,this.image=iDe,this.configDir=(0,nDe.join)((0,rDe.homedir)(),".aii")}isDockerAvailable(){try{return(0,Qo.execSync)("docker info",{stdio:"pipe",timeout:5e3}),!0}catch{return!1}}isContainerExists(){try{return(0,Qo.execSync)(`docker container inspect ${this.containerName}`,{stdio:"pipe",timeout:5e3}),!0}catch{return!1}}isContainerRunning(){try{return(0,Qo.execSync)(`docker container inspect -f "{{.State.Running}}" ${this.containerName}`,{stdio:"pipe",timeout:5e3,encoding:"utf-8"}).trim()==="true"}catch{return!1}}async isServerHealthy(){try{let e=new AbortController,r=setTimeout(()=>e.abort(),2e3),n=await fetch(`http://${this.host}:${this.port}/health`,{signal:e.signal});return clearTimeout(r),n.ok}catch{return!1}}async getServerVersion(){try{let e=new AbortController,r=setTimeout(()=>e.abort(),2e3),n=await fetch(`http://${this.host}:${this.port}/v0/status`,{signal:e.signal});return clearTimeout(r),n.ok&&(await n.json()).version||null}catch{return null}}static isVersionBelow(e,r){try{let n=e?.replace(/^v/,"")||"0.0.0",i=r?.replace(/^v/,"")||"0.0.0",o=n.split(".").map(Number),s=i.split(".").map(Number),a=Math.max(o.length,s.length);for(;o.length<a;)o.push(0);for(;s.length<a;)s.push(0);for(let u=0;u<a;u++){if(o[u]<s[u])return!0;if(o[u]>s[u])return!1}return!1}catch{return!1}}async checkServerAtPort(e){try{let r=new AbortController,n=setTimeout(()=>r.abort(),2e3),i=await fetch(`http://${this.host}:${e}/health`,{signal:r.signal});if(clearTimeout(n),!i.ok)return{isCompatible:!1,version:null};let o=new AbortController,s=setTimeout(()=>o.abort(),2e3),a=await fetch(`http://${this.host}:${e}/v0/status`,{signal:o.signal});if(clearTimeout(s),a.ok){let c=(await a.json()).version||null;return c?{isCompatible:!t.isVersionBelow(c,Ks),version:c}:{isCompatible:!0,version:null}}return{isCompatible:!0,version:null}}catch{return{isCompatible:!1,version:null}}}getContainerHostPort(){try{let e=(0,Qo.execSync)(`docker inspect --format='{{(index (index .NetworkSettings.Ports "26169/tcp") 0).HostPort}}' ${this.containerName}`,{stdio:"pipe",timeout:5e3,encoding:"utf-8"}),r=parseInt(e.trim(),10);return isNaN(r)?null:r}catch{return null}}async scanForServer(e=At.DEFAULT_PORT,r=10){for(let n=0;n<r;n++){let i=e+n,{isCompatible:o}=await this.checkServerAtPort(i);if(o)return i}return null}startContainer(){try{return(0,Qo.execSync)(`docker start ${this.containerName}`,{stdio:"pipe",timeout:3e4}),!0}catch{return!1}}stopContainer(){try{return(0,Qo.execSync)(`docker stop ${this.containerName}`,{stdio:"pipe",timeout:3e4}),!0}catch{return!1}}getContainerLogs(e=50){try{return(0,Qo.execSync)(`docker logs --tail ${e} ${this.containerName}`,{stdio:"pipe",timeout:1e4,encoding:"utf-8"})}catch{return""}}async waitForHealthy(e=3e4){let r=Date.now(),n=!1,i=()=>{n=!0,process.exit(130)};process.on("SIGINT",i);try{for(;Date.now()-r<e&&!n;){if(await this.isServerHealthy())return!0;await new Promise(o=>setTimeout(o,500))}return!1}finally{process.removeListener("SIGINT",i)}}async runInstallScript(e=!0){return new Promise(r=>{e&&console.log(` Running: curl -fsSL ${cu} | bash
1035
1035
  `);let n=(0,Qo.spawn)("bash",["-c",`curl -fsSL ${cu} | bash`],{stdio:e?["pipe","inherit","inherit"]:"pipe",detached:!1}),i=()=>{try{n.kill("SIGINT")}catch{}console.log(`
1036
1036
 
1037
1037
  Cancelled.`),process.exit(130)},o=process.listeners("SIGINT");process.removeAllListeners("SIGINT"),process.on("SIGINT",i),n.on("close",s=>{process.removeListener("SIGINT",i),o.forEach(a=>process.on("SIGINT",a)),r(s===0)}),n.on("error",()=>{process.removeListener("SIGINT",i),o.forEach(s=>process.on("SIGINT",s)),r(!1)})})}async upgradeServer(e=!0){e&&console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiiware/aii",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "AI-powered CLI assistant for terminal productivity",
5
5
  "author": "AiiWare <support@aiiware.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",