@eeshaai/code 1.0.5 → 1.0.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.
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";var Kn=Object.create;var pe=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var Yn=Object.getOwnPropertyNames;var Zn=Object.getPrototypeOf,Xn=Object.prototype.hasOwnProperty;var a=(n,e)=>pe(n,"name",{value:e,configurable:!0});var Qn=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Yn(e))!Xn.call(n,o)&&o!==t&&pe(n,o,{get:()=>e[o],enumerable:!(r=qn(e,o))||r.enumerable});return n};var p=(n,e,t)=>(t=n!=null?Kn(Zn(n)):{},Qn(e||!n||!n.__esModule?pe(t,"default",{value:n,enumerable:!0}):t,n));var Y=require("child_process"),v=p(require("fs")),zn=p(require("http")),Z=p(require("path"));var ee=require("child_process");var Be=p(require("fs")),X=p(require("path"));function j(n,e){let t=(L(n,"PATH")??"").split(X.delimiter).filter(Boolean),r=process.platform==="win32"?(L(n,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean):[""];for(let o of t)for(let s of r){let i=X.join(o,e+s);try{if(Be.statSync(i).isFile())return i}catch{}}}a(j,"commandOnPath");function L(n,e){if(n[e]!==void 0)return n[e];let t=e.toUpperCase(),r=Object.keys(n).find(o=>o.toUpperCase()===t);return r===void 0?void 0:n[r]}a(L,"envValue");var k=class{constructor(e){this.access=e;this.env=e.env??process.env,this.deniedUpper=new Set(e.denied.map(t=>t.toUpperCase()))}access;static{a(this,"EnvService")}env;deniedUpper;isDenied(e){return this.deniedUpper.has(e.toUpperCase())}static machine(){let e={};for(let[t,r]of Object.entries(process.env))r!==void 0&&(e[t]=r);return e}spawnEnv(){let{allowed:e,allowedEnv:t,taskEnv:r}=this.access,o={};for(let[s,i]of Object.entries(this.env))i===void 0||this.isDenied(s)||(et.has(s.toUpperCase())||e.includes(s)||t?.includes(s))&&(o[s]=i);for(let[s,i]of Object.entries(r??{}))this.isDenied(s)||(o[s]=i);return o}spawnEnvMasked(e){let t=this.spawnEnv();for(let r of this.grantValues())e?.(r);return t}allowedValues(){let e={};for(let t of this.grantedNames()){let r=this.valueOf(t);r!==void 0&&(e[t]=r)}return e}grantValues(){return[...new Set([...this.access.allowed,...this.access.allowedEnv??[]].filter(t=>!this.isDenied(t)))].map(t=>this.valueOf(t)).filter(t=>t!==void 0)}resolve(e){if(this.isDenied(e))throw new Error(`'${e}' is denied by 'env.denied' in settings.json.`);if(!this.granted(e))throw new Error(`Nothing allows '${e}' to be read. Add it to 'env.allowed' in settings.json, declare it in the workflow's 'env:' block, or list it in the task's allowedEnv arg.`);let t=this.valueOf(e);if(t===void 0)throw new Error(`'${e}' is allowed, but the environment variable '${e}' is not set.`);return t}granted(e){return this.fromTask(e)||this.access.allowed.includes(e)||this.access.allowedEnv?.includes(e)||!1}grantedNames(){let{allowed:e,taskEnv:t,allowedEnv:r}=this.access,o=new Set([...Object.keys(t??{}),...e,...r??[]]);for(let s of o)this.isDenied(s)&&o.delete(s);return o}valueOf(e){return this.fromTask(e)?this.access.taskEnv[e]:Object.prototype.hasOwnProperty.call(this.env,e)?this.env[e]:void 0}fromTask(e){return!!this.access.taskEnv&&Object.prototype.hasOwnProperty.call(this.access.taskEnv,e)}},et=new Set(["PATH","PATHEXT","SYSTEMROOT","WINDIR","COMSPEC","SYSTEMDRIVE","TEMP","TMP","TMPDIR","APPDATA","LOCALAPPDATA","HOME","USERPROFILE","HOMEDRIVE","HOMEPATH","USERNAME","LANG","LC_ALL","SHELL","COPILOT_CLI_PATH","CLAUDE_CLI_PATH"]);var Ue={ado:{name:"az",install:"Install the Azure CLI: https://aka.ms/installazurecli - then sign in here."},github:{name:"gh",install:"Install the GitHub CLI: https://cli.github.com - then sign in here."}},nt=6e4,tt=10*6e4,Q=class extends Error{static{a(this,"CliError")}};function ne(n){return j(k.machine(),Ue[n].name)}a(ne,"findCli");function te(n){return Ue[n].install}a(te,"installHint");function ge(n){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(n)}a(ge,"needsShell");function Ve(n){return ge(n)?`"${n}"`:n}a(Ve,"startable");function ze(n){return n.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).slice(0,6).join(`
3
3
  `)}a(ze,"shortText");function He(n,e){let t=ne(n);return t?new Promise((r,o)=>{(0,ee.execFile)(Ve(t),e,{env:{...k.machine(),GH_PROMPT_DISABLED:"1",AZURE_CORE_NO_COLOR:"true",AZURE_CORE_ONLY_SHOW_ERRORS:"true"},windowsHide:!0,timeout:nt,maxBuffer:4*1024*1024,shell:ge(t)},(s,i,c)=>{if(s)return o(new Q(ze(String(c||i||""))||s.message));r(String(i))})}):Promise.reject(new Q(te(n)))}a(He,"runCli");async function me(n){try{if(n==="ado")return(await He("ado",["account","show","--query","user.name","-o","tsv"])).trim()||void 0;let e=await He("github",["auth","status","--hostname","github.com"]);return/account\s+(\S+)/i.exec(e)?.[1]??(e.trim()?"GitHub":void 0)}catch{return}}a(me,"signedInAs");function We(n,e){let t=ne(n);if(!t)return{done:Promise.resolve({problem:te(n)}),stop:a(()=>{},"stop")};let r=n==="ado"?["login","--allow-no-subscriptions","--only-show-errors","-o","none"]:["auth","login","--web","--hostname","github.com","--git-protocol","https"],o=(0,ee.spawn)(Ve(t),r,{env:{...k.machine(),AZURE_CORE_NO_COLOR:"true"},windowsHide:!0,shell:ge(t),stdio:["pipe","pipe","pipe"]}),s=!1,i="",c=a(d=>{let l=d.toString("utf8");i=(i+l).slice(-4e3);for(let h of l.split(/\r?\n/).map(w=>w.trim()).filter(Boolean)){let w=/one-time code:\s*([A-Z0-9]{4}-[A-Z0-9]{4})/i.exec(h)?.[1],z=/(https:\/\/\S+)/.exec(h)?.[1];e({line:h,...w?{code:w}:{},...z?{url:z}:{}}),/press enter/i.test(h)&&o.stdin.writable&&o.stdin.write(`
4
- `)}},"read");o.stdout.on("data",c),o.stderr.on("data",c);let u=setTimeout(()=>o.kill(),tt);return{done:new Promise(d=>{o.on("error",l=>d({problem:l.message})),o.on("close",async l=>{if(clearTimeout(u),s)return d({problem:"Sign-in stopped."});if(l!==0)return d({problem:ze(i)||`Sign-in ended with code ${l}.`});d({ok:!0,account:await me(n)})})}),stop:a(()=>{s=!0,o.kill()},"stop")}}a(We,"startSignIn");var $=p(require("fs")),Je=p(require("os")),W=p(require("path"));var rt=".eesha";function O(){return W.join(Je.homedir(),rt)}a(O,"eeshaHome");function m(...n){return W.join(O(),...n)}a(m,"eeshaPath");function M(n,e){$.mkdirSync(W.dirname(n),{recursive:!0});let t=`${n}.${process.pid}.tmp`;$.writeFileSync(t,e,"utf8"),$.renameSync(t,n)}a(M,"writeAtomic");function A(n){try{return JSON.parse($.readFileSync(n,"utf8"))}catch{return}}a(A,"readJson");var On=p(require("fs"));var G=["ghcp","claude"];var mn=p(require("fs/promises"));var oe=p(require("path"));var b="providers",ot=["provider","uses",b],B=a(n=>typeof n=="object"&&n!==null&&!Array.isArray(n),"isMapping");function Ke(n,e){if(!B(n))throw new Error(`${e} has a '${b}:' that is not a mapping. Write one entry per runtime id, e.g. providers: { ghcp: { reasoningEffort: high }, kiro-cli: { model: claude-sonnet-4.5 } }.`);for(let[t,r]of Object.entries(n)){if(!B(r))throw new Error(`${e} has '${b}.${t}' that is not a mapping of args.`);for(let o of ot)if(o in r)throw new Error(`${e} sets '${o}' inside '${b}.${t}'. A block only applies once '${t}' is already the runtime, so it cannot choose one. Write '${o}' outside '${b}:'.`)}return n}a(Ke,"checkProviderBlocks");function qe(n,e){let t={...n,...e},r=n?.[b],o=e?.[b];if(B(r)&&B(o)){let s={...r};for(let[i,c]of Object.entries(o))s[i]=B(s[i])&&B(c)?{...s[i],...c}:c;t[b]=s}return t}a(qe,"mergeAiArgs");var x=".eesha",st="tasks.yml",he="settings.json",Ye="workflows";var Ar=`**/${x}/${st}`,it=[`**/${x}/${Ye}/**/*.yml`,`**/${x}/${Ye}/**/*.yaml`];function at(n){return n.length===1?n[0]:`{${n.join(",")}}`}a(at,"braced");var xr=at(it);var Ze=p(require("os")),we=p(require("path"));var Xe;function Qe(n){Xe=n}a(Qe,"useProfileDirectory");function en(){return Xe??we.join(Ze.homedir(),x)}a(en,"profileDirectory");var cn=p(require("os")),un=p(require("path"));var rn=String.raw`[\w.]+(?:\[(?:\d+|"[^"]*")\](?:\.\w+)*)*`,ye=new RegExp(String.raw`\$\{\{\s*(${rn})\s*\}\}`,"g"),nn=new RegExp(String.raw`^\$\{\{\s*(${rn})\s*\}\}$`);function H(n){return[...n.matchAll(/\[(\d+|"[^"]*")\]|[^.[\]]+/g)].map(e=>e[1]===void 0?e[0]:e[1].startsWith('"')?e[1].slice(1,-1):e[1])}a(H,"pathOf");var ct=5,on="run",sn="context",_=`${on}.${sn}`,be=["dateToday","dateNow","dateUtcNow","timestamp","runId","platform"];function tn(n){return be.includes(n)}a(tn,"isStampName");var an=["workspaceFolder","workspaceConfig","cwd","home","params","vars","env","run","spec",...be],I=class extends Error{static{a(this,"TemplateResolutionError")}};function E(n){return typeof n=="string"?[...n.matchAll(ye)].map(e=>e[1]):Array.isArray(n)?n.flatMap(E):n!==null&&typeof n=="object"?Object.values(n).flatMap(E):[]}a(E,"expressionsIn");function R(n,e){return n!==void 0&&Object.prototype.hasOwnProperty.call(n,e)}a(R,"owns");var C=class{static{a(this,"TemplateResolver")}resolve(e,t){return e.replace(ye,(r,o)=>this.stringify(this.demand(o,t,e)))}resolveValue(e,t){if(typeof e=="string"){let r=nn.exec(e.trim());return r?this.demand(r[1],t,e):this.resolve(e,t)}return Array.isArray(e)?e.map(r=>this.resolveValue(r,t)):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,this.resolveValue(o,t)])):e}resolveKnown(e,t){return this.tryResolveValue(e,t)}resolveVars(e,t){let r={workspaceFolder:t.workspaceFolder,workspaceConfig:t.workspaceConfig,home:t.home,cwd:t.cwd,params:t.params,stamps:t.stamps,variables:t.variables};return this.settle(e,o=>({...r,vars:o}))}resolveEnv(e,t){let r={workspaceFolder:t.workspaceFolder,workspaceConfig:t.workspaceConfig,home:t.home,cwd:t.cwd,params:t.params,stamps:t.stamps,variables:t.variables,vars:t.vars,run:t.run},o=this.settle(e,s=>({...r,env:{...t.env,...s}}));return Object.fromEntries(Object.entries(o).map(([s,i])=>[s,this.stringify(i)]))}resolveVariables(e,t){let r={workspaceFolder:t.workspaceFolder,workspaceConfig:t.workspaceConfig,home:t.home,cwd:t.cwd,env:t.env},o=this.settle(e,s=>({...r,variables:s}));for(let[s,i]of Object.entries(o)){if(!E(i).length)continue;let[c]=E(e[s]);throw new I(`Cannot resolve '\${{ ${c} }}' in '${s}' - '${s}' still has no value after every pass, so it reads a variable that reads it back.`)}return o}settle(e,t){let r={...e};for(let s=0;s<ct;s++){let i={},c=!1,u=t(r);for(let f of Object.keys(r))i[f]=this.tryResolveValue(r[f],u),i[f]!==r[f]&&(c=!0);if(r=i,!c)break}let o=t(r);for(let s of Object.keys(r))this.resolveValue(r[s],o);return r}tryResolveValue(e,t){if(typeof e=="string"){let r=nn.exec(e.trim());if(r){let o=this.lookup(r[1],t);return o?o.value:e}return e.replace(ye,(o,s)=>{let i=this.lookup(s,t);return i?this.stringify(i.value):o})}return Array.isArray(e)?e.map(r=>this.tryResolveValue(r,t)):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,this.tryResolveValue(o,t)])):e}demand(e,t,r){let o=this.lookup(e,t);if(o)return o.value;throw new I(`Cannot resolve '\${{ ${e} }}' in '${r}' - ${this.explain(e,t)}`)}explain(e,t){let{namespace:r,name:o,path:s}=this.split(e),i=o??"";if(r==="vars"&&t.vars===void 0)return"vars are not available here. They are resolved first, so nothing they read can be a var.";if(r==="env"&&t.env===void 0)return"env is not available here. Env is resolved after vars, so a 'vars:' value cannot read it.";if(r===_&&t.run===void 0)return"run variables are produced by tasks as they finish, so they cannot be read from 'vars:'.";if(r==="params"&&t.params===void 0)return"params are not available here.";if(R(t.items,r))return this.explainPath(r,t.items[r],H(e).slice(1));if(R(t.variables,r))return this.explainPath(r,t.variables[r],H(e).slice(1));let c=r==="params"?t.params:r==="vars"?t.vars:r===_?t.run:void 0;return o&&s.length&&R(c,o)?this.explainPath(`${r}.${o}`,c[o],s):r==="params"?`the file declares no param named '${i}'. A param has to be declared in 'params:' before a run can be asked for it.`:tn(r)&&t.stamps===void 0?`'${r}' is stamped when a run starts, and this value is read before any run exists.`:r==="env"&&s.length?`env vars are flat text - there is no '${r}.${i}.${s[0]}'.`:r==="vars"||r==="env"||r===_?`no ${r===_?"run variable":r==="env"?"env var":"var"} named '${i}' is in scope.`:`'${r}' is not a thing. Available: ${this.available(t).join(", ")}.`}explainPath(e,t,r){for(let o of r){if(Array.isArray(t)){if(!/^\d+$/.test(o))return`'${e}' is a list of ${t.length}, so it is read by position - '[0]', not '.${o}'.`;if(Number(o)>=t.length)return`'${e}' is a list of ${t.length}, so [${o}] is out of range.`;t=t[Number(o)],e=`${e}[${o}]`;continue}if(t===null||typeof t!="object")return`'${e}' is ${t===null?"null":typeof t=="string"?"text":`a ${typeof t}`}, so there is no '${o}' under it.`;if(!R(t,o))return`'${e}' has no '${o}'. It has: ${Object.keys(t).join(", ")||"nothing"}.`;t=t[o],e=`${e}.${o}`}return`'${e}' did not resolve.`}available(e){return["workspaceFolder","workspaceConfig","cwd","home",...e.stamps?[...be]:[],...e.params?["params.NAME"]:[],...e.vars?["vars.NAME"]:[],...e.env?["env.NAME"]:[],...e.run?[`${_}.NAME`]:[],...Object.keys(e.items??{}),...Object.keys(e.variables??{})]}lookup(e,t){if(e==="workspaceFolder")return{value:t.workspaceFolder};if(e==="workspaceConfig")return{value:t.workspaceConfig};if(e==="home")return{value:t.home};if(e==="cwd")return{value:t.cwd};if(tn(e))return t.stamps?{value:t.stamps[e]}:void 0;let[r]=H(e);if(R(t.items,r))return this.walk(t.items,r,H(e).slice(1));if(R(t.variables,r))return this.walk(t.variables,r,H(e).slice(1));let{namespace:o,name:s,path:i}=this.split(e);if(s!==void 0){if(o==="env")return i.length===0&&R(t.env,s)?{value:t.env[s]}:void 0;if(o==="params")return this.walk(t.params,s,i);if(o==="vars")return this.walk(t.vars,s,i);if(o===_)return this.walk(t.run,s,i)}}split(e){let t=H(e),r=t[0]===on&&t[1]===sn,o=r?2:1;return{namespace:r?_:t[0],name:t[o],path:t.slice(o+1)}}walk(e,t,r){if(!R(e,t))return;let o=e[t];for(let s of r){if(Array.isArray(o)){if(!/^\d+$/.test(s)||Number(s)>=o.length)return;o=o[Number(s)];continue}if(o===null||typeof o!="object"||!R(o,s))return;o=o[s]}return{value:o}}stringify(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}};function ke(n){let e=n.workspaceFolder;if(e)return{workspaceFolder:e,workspaceConfig:un.join(e,x),cwd:e,home:n.home??cn.homedir(),env:dt(n.denied??[],n.processEnv),variables:n.variables}}a(ke,"configScope");function dn(n,e,t){let r=E(n);if(!r.length)return n;Ae(r,e,t.denied??[]);let o=ke({...t,variables:void 0});if(!o)throw new Error(`${e} uses \${{ }} but no workspace is open, so there is nothing for 'workspaceFolder' to mean. Open the folder this file belongs to, or write the value without an expression.`);try{return new C().resolveVariables(n,o)}catch(s){throw s instanceof I?new Error(`${e}: ${s.message}`):s}}a(dn,"resolveVariables");function Se(n,e,t,r=[]){let o=E(n);if(!o.length)return n;let s=a(u=>r.includes(ut(u)),"late"),i=o.filter(u=>!s(u));Ae(i,e,t.denied??[]);let c=ke(t);if(!c){if(!i.length)return n;throw new Error(`'${e}' uses \${{ }} but no workspace is open, so there is nothing for 'workspaceFolder' to mean. Open the folder this file belongs to, or write the value without an expression.`)}try{if(i.length===o.length)return new C().resolveValue(n,c);let u=new C().resolveKnown(n,c);for(let f of E(u))s(f)||new C().resolve(`\${{ ${f} }}`,c);return u}catch(u){throw u instanceof I?new Error(`'${e}': ${u.message}`):u}}a(Se,"resolveConfigValue");function ut(n){return n.split(".")[0]}a(ut,"namespaceOf");function ve(n,e,t){let r=E(n);if(!r.length)return n;Ae(r,e,t.denied??[]);let o=ke(t);return o?new C().resolveKnown(n,{...o,env:void 0}):n}a(ve,"resolveAnchorsOnly");function Ae(n,e,t){if(!t.length)return;let r=new Set(t.map(o=>o.toUpperCase()));for(let o of n){let s=o.split(".");if(!(s.length!==2||s[0]!=="env"||!r.has(s[1].toUpperCase())))throw new Error(`'${e}' reads \${{ env.${s[1]} }}, which 'env.denied' vetoes. Remove the name from env.denied, or the expression from this file.`)}}a(Ae,"refuseDenied");function dt(n,e){let t=e??k.machine(),r=new Set(n.map(s=>s.toUpperCase())),o={};for(let[s,i]of Object.entries(t))i!==void 0&&!r.has(s.toUpperCase())&&(o[s]=i);return o}a(dt,"readableEnv");var hn={"kiro-cli":{command:"kiro-cli",args:["acp"],extensions:["kiro-v2"]},"kiro-cli-v3":{command:"kiro-cli",args:["acp","--agent-engine","v3","--auth-method","cli"],extensions:["kiro-v3"]},"copilot-cli":{command:"copilot",args:["--acp","--stdio","--disallow-temp-dir"],extensions:["copilot-cli"]},"claude-cli":{command:"claude-agent-acp",extensions:["claude-cli"]},"gemini-cli":{command:"gemini",args:["--acp"]},"codex-cli":{command:"codex-acp"},"cursor-cli":{command:"cursor-agent",args:["acp"]},"opencode-cli":{command:"opencode",args:["acp"]}},ft="built-in",Ee={liveToolOutput:"Stream a running tool's output into its row in the log.",sessionCost:"Show what a session cost in money, not just in credits, in the usage card.",docDiff:`Offer "What changed" on a spec document - the last run's changes in red and green.`,steering:"Hand the project's steering files (.md files with an 'inclusion:' header) to AI chats.",hideCopilotPremiumRequests:"Record only Copilot's credits, not its premium requests, for what a call charged.",handover:"Offer a Handover button that moves a started chat to another runtime, through a saved file the new runtime reads.",toolResults:"Show what a finished tool call returned when its card in the chat is opened.",evals:"Offer the Evaluator page, which runs a built-in eval set on several runtimes and compares the results.",fakeRuntime:"Offer a fake runtime that calls no model and costs nothing. It writes sample drafts, asks one question and ticks tasks. For testing only.","Feature-SDD":"Show the SDD module in Eesha Code: the Spec explorer, the Specs item on a workspace's menu, and the /sdd pages."},lt=["docDiff","hideCopilotPremiumRequests","handover"];function pt(){return Object.fromEntries(Object.keys(Ee).map(n=>[n,lt.includes(n)]))}a(pt,"defaultFeatures");var gt=["node_modules",".git",".vscode",".idea","TestResults","bin","obj","dist","out","coverage","build","target","logs","tmp","temp"];function mt(n){return oe.join(n,x)}a(mt,"workspaceConfigOf");async function se(n,e={}){let t=e.readFile??kt,r=oe.join(e.profileDir??en(),he),o=n?oe.join(mt(n),he):void 0,[s,i]=await Promise.all([t(r),o?t(o):Promise.resolve(void 0)]),c=s!==void 0?J(s,r):void 0,u=i!==void 0&&o?J(i,o):void 0,f={workspaceFolder:n,home:e.home,processEnv:e.processEnv,denied:[...ln(c),...ln(u)]},d=[c?.variables!==void 0?Re(c.variables,r):void 0,u?.variables!==void 0&&o?Re(u.variables,o):void 0];return d.some(Boolean)&&(f.variables=dn(wn(d[0],d[1]).variables,`'variables' in ${[r,o].filter(Boolean).map(l=>`'${l}'`).join(" / ")}`,f)),wt(c!==void 0?gn(fn(c,r,f),r,"profile"):void 0,u!==void 0&&o?gn(fn(u,o,f),o,"workspace"):void 0)}a(se,"loadEngineSettings");function fn(n,e,t){let r=n.ai,o=!!r&&typeof r=="object"&&!Array.isArray(r),s=o?r.mcpServers:void 0,i=o?r.acpAgents:void 0;if(s===void 0&&i===void 0)return Se(n,e,t);let c={...r};delete c.mcpServers,delete c.acpAgents;let u=Se({...n,ai:c},e,t);return{...u,ai:{...u.ai,...s!==void 0?{mcpServers:ve(s,e,t)}:{},...i!==void 0?{acpAgents:ve(i,e,t)}:{}}}}a(fn,"resolved");function ln(n){let e=n?.env;if(!e||typeof e!="object"||Array.isArray(e))return[];let t=e.denied;return Array.isArray(t)?t.filter(r=>typeof r=="string"&&!r.includes("${{")):[]}a(ln,"deniedIn");var pn=["sdd","ai","env","variables","defaultFoldersToIgnoreScanning","debug","features","eesha"];function J(n,e){if(!n.trim())return;let t;try{t=JSON.parse(n)}catch(r){throw new Error(`'${e}' is not valid JSON: ${r instanceof Error?r.message:String(r)}. Plain JSON only - no comments.`)}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`'${e}' must be a JSON object of settings sections.`);return t}a(J,"readJson");function gn(n,e,t="profile"){for(let o of Object.keys(n))if(!pn.includes(o))throw new Error(`'${e}' has an unknown setting '${o}'. Valid sections: ${pn.join(", ")}.`);let r={source:e};if(n.sdd!==void 0&&(r.sdd=T(n.sdd,"sdd",e)),n.ai!==void 0){let o=T(n.ai,"ai",e),s={};for(let[i,c]of Object.entries(o)){if(i==="mcpServers"){r.mcpServers=T(c,"ai.mcpServers",e);continue}if(i==="acpAgents"){r.acpAgents=T(c,"ai.acpAgents",e);continue}if(i===b){let u=re(c,"ai.providers",e),f=u.find((d,l)=>u.indexOf(d)!==l);if(f)throw new Error(`'${e}' lists '${f}' twice in ai.providers.`);r.providers=u;continue}s[i]=T(c,`ai.${i}`,e),s[i][b]!==void 0&&Ke(s[i][b],`'${e}' ai.${i}`)}Object.keys(s).length&&(r.aiDefaults=s)}if(n.env!==void 0){let o=T(n.env,"env",e);for(let s of Object.keys(o))if(s!=="allowed"&&s!=="denied")throw new Error(`'${e}' has an unknown key 'env.${s}'. Valid: allowed, denied.`);o.allowed!==void 0&&(r.envAllowed=re(o.allowed,"env.allowed",e)),o.denied!==void 0&&(r.envDenied=re(o.denied,"env.denied",e))}if(n.variables!==void 0&&(r.variables=Re(n.variables,e)),n.defaultFoldersToIgnoreScanning!==void 0&&(r.ignore=re(n.defaultFoldersToIgnoreScanning,"defaultFoldersToIgnoreScanning",e)),n.debug!==void 0){if(t==="workspace")throw new Error(`'${e}' sets 'debug', which is a personal setting. Put it in your profile file, '~/.eesha/settings.json'.`);if(typeof n.debug!="boolean")throw new Error(`'${e}': 'debug' must be true or false.`);r.debug=n.debug}return n.features!==void 0&&(r.features=ht(n.features,e)),r}a(gn,"parseDeclared");function ht(n,e){let t=T(n,"features",e),r=Object.keys(Ee),o={};for(let[s,i]of Object.entries(t)){if(!r.includes(s))throw new Error(`'${e}' has an unknown feature flag 'features.${s}'. Valid flags: ${r.join(", ")}.`);if(typeof i!="boolean")throw new Error(`'${e}': 'features.${s}' must be true or false.`);o[s]=i}return o}a(ht,"featuresOf");function wt(n,e){let t=yt(n?.sdd,e?.sdd),r={},o={},s={};for(let l of[e,n])for(let[h,w]of Object.entries(l?.aiDefaults??{})){r[h]=qe(r[h],w);for(let z of Object.keys(w))(o[h]??={})[z]=l.source,(s[h]??={})[z]=l===n?"profile":"workspace"}let i={};for(let l of[e,n])for(let[h,w]of Object.entries(l?.mcpServers??{}))i[h]={server:w,source:l.source};let c={};for(let[l,h]of Object.entries(hn))c[l]={agent:h,source:ft};for(let l of[e,n])for(let[h,w]of Object.entries(l?.acpAgents??{}))c[h]={agent:w,source:l.source};let{variables:u,overrides:f}=wn(n?.variables,e?.variables,n?.source,e?.source),d=n?.providers??e?.providers;return d&&bt(d,[...new Set([...G,...Object.keys(c)])],r,(n?.providers?n:e).source),{sdd:t,ai:{defaults:r,defaultSources:o,defaultScopes:s,scopedDefaults:{workspace:e?.aiDefaults??{},profile:n?.aiDefaults??{}},...d?{providers:d}:{},mcpServers:i,acpAgents:c},env:{allowed:xe(n?.envAllowed,e?.envAllowed),denied:xe(n?.envDenied,e?.envDenied)},variables:u,variableOverrides:f,ignore:n?.ignore||e?.ignore?xe(n?.ignore,e?.ignore):[...gt],debug:n?.debug??!1,features:{...pt(),...e?.features,...n?.features}}}a(wt,"mergeEngineSettings");function Re(n,e){let t=T(n,"variables",e);for(let r of Object.keys(t))if(an.includes(r))throw new Error(`'${e}' declares a variable named '${r}', which \${{ ${r} }} already means. Pick another name.`);return t}a(Re,"variablesOf");function wn(n,e,t="profile",r="workspace"){let o=[],s=a(c=>!!c&&typeof c=="object"&&!Array.isArray(c),"isMapping"),i=a((c,u,f)=>{let d={...c};for(let[l,h]of Object.entries(u)){let w=f?`${f}.${l}`:l;if(s(d[l])&&s(h)){d[l]=i(d[l],h,w);continue}Object.prototype.hasOwnProperty.call(c,l)&&o.push(`variables.${w}: '${t}' overrides '${r}'.`),d[l]=h}return d},"merge");return{variables:i(e??{},n??{},""),overrides:o}}a(wn,"mergeVariables");function yt(n,e){return{...e,...n}}a(yt,"mergeSdd");function xe(n,e){return[...new Set([...n??[],...e??[]])]}a(xe,"union");function T(n,e,t){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`'${t}': '${e}' must be a mapping.`);return n}a(T,"mapping");function bt(n,e,t,r){let o=n.filter(i=>!e.includes(i));if(o.length)throw new Error(`'${r}' lists ${o.map(i=>`'${i}'`).join(", ")} in ai.providers, which this build cannot run. Known runtimes: ${e.join(", ")}. An ACP agent of your own goes under ai.acpAgents first.`);let s=t["ai@1"]?.provider?.trim()||"ghcp";if(!n.includes(s))throw new Error(`'${r}' lists ai.providers without '${s}', the runtime ai@1 starts on`+(t["ai@1"]?.provider?"":" when nothing names one")+`. Add it to the list, or set ai."ai@1".provider to one of: ${n.join(", ")}.`)}a(bt,"checkProviderList");function re(n,e,t){if(!Array.isArray(n)||n.some(r=>typeof r!="string"))throw new Error(`'${t}': '${e}' must be a list of names.`);return n}a(re,"names");async function kt(n){try{return await mn.readFile(n,"utf8")}catch(e){if(e.code==="ENOENT")return;throw new Error(`Could not read '${n}': ${e instanceof Error?e.message:String(e)}`)}}a(kt,"readFileOrUndefined");var kn=p(require("fs")),Sn=p(require("path"));var ie=p(require("fs")),y=p(require("path"));var St="CLAUDE_CLI_PATH";function yn(n){let e=L(n,St);if(e)return e;try{let r=y.dirname(y.dirname(require.resolve("./claude-agent-sdk/sdk.mjs"))),o=bn(r);if(o)return o}catch{}let t=j(n,"claude");return t?vt(t):void 0}a(yn,"cliBinary");function vt(n){let e=n;try{e=ie.realpathSync(n)}catch{return}if(!At(e))return e;let t=[y.join(y.dirname(n),"node_modules","@anthropic-ai")];e!==n&&t.push(y.dirname(y.dirname(e)));for(let r of t){let o=bn(r);if(o)return o}}a(vt,"globalCliBinary");function At(n){return[".cmd",".bat",".ps1",".js",".cjs",".mjs"].includes(y.extname(n).toLowerCase())}a(At,"isScript");function bn(n){let e="claude"+(process.platform==="win32"?".exe":""),t=process.platform==="linux"?[`linux-${process.arch}`,`linux-${process.arch}-musl`]:[`${process.platform}-${process.arch}`],r=[y.join(n,"claude-code","bin",e)];for(let o of t)for(let s of["claude-code","claude-agent-sdk"]){let i=`${s}-${o}`;r.push(y.join(n,i,e),y.join(n,s,"node_modules","@anthropic-ai",i,e))}for(let o of r)try{if(ie.statSync(o).isFile())return o}catch{}}a(bn,"platformBinaryIn");var $e={claude:"npm install -g @anthropic-ai/claude-code, or set CLAUDE_CLI_PATH to a copy you have",ghcp:"npm install -g @github/copilot, or set COPILOT_CLI_PATH to a copy you have","kiro-cli":"Kiro's own installer","kiro-cli-v3":"Kiro's own installer","copilot-cli":"npm install -g @github/copilot","claude-cli":"npm install -g @agentclientprotocol/claude-agent-acp","gemini-cli":"Google's Gemini CLI","codex-cli":"the Codex ACP adapter","cursor-cli":"Cursor's CLI","opencode-cli":"OpenCode"};function vn(n,e,t){return n.map(r=>{if(r==="claude")return{id:r,program:"claude",found:yn(t),install:$e.claude};if(r==="ghcp")return{id:r,program:"copilot",found:L(t,"COPILOT_CLI_PATH")||j(t,"copilot"),install:$e.ghcp};let o=e[r]?.agent;if(!o||typeof o.command!="string"||!o.command)return{id:r,program:"?",install:`${r} is not a runtime Eesha Code knows - check ai.providers and ai.acpAgents in settings.json`};let s=o.command;return{id:r,program:s,found:xt(s,t),install:$e[r]??`check ai.acpAgents.${r}.command in settings.json`}})}a(vn,"checkRuntimes");function xt(n,e){return Sn.isAbsolute(n)?kn.existsSync(n)?n:void 0:j(e,n)}a(xt,"programAt");async function Oe(){Qe(O());let n=k.machine();try{let e=await se(void 0),t=e.ai.providers!==void 0,r=e.ai.providers?[...e.ai.providers]:[...G,...Object.keys(e.ai.acpAgents).filter(o=>!G.includes(o))];return{checks:vn(r,e.ai.acpAgents,n),listed:t}}catch(e){return{checks:[],listed:!1,problem:`${m("settings.json")} could not be read: ${e.message}`}}}a(Oe,"checkThisMachine");function An(n){if(n.problem)return n.problem;let{checks:e,listed:t}=n,r=Math.max(...e.map(i=>i.id.length),7)+2,o=[t?"Runtimes the picker offers (ai.providers in settings.json), and whether their program is on this machine:":"Runtimes Eesha Code knows, and whether their program is on this machine. With no ai.providers list in settings.json, the picker offers the ones found:","",...e.map(i=>` ${i.id.padEnd(r)}${i.found?`found ${i.found}`:`not found ${i.program==="?"?i.install:`${i.program} - install: ${i.install}`}`}`),""],s=e.filter(i=>i.found);return o.push(`${s.length} of ${e.length} found. Sign-in is not checked: each runtime uses the sign-in its own program has.`),o.join(`
4
+ `)}},"read");o.stdout.on("data",c),o.stderr.on("data",c);let u=setTimeout(()=>o.kill(),tt);return{done:new Promise(d=>{o.on("error",l=>d({problem:l.message})),o.on("close",async l=>{if(clearTimeout(u),s)return d({problem:"Sign-in stopped."});if(l!==0)return d({problem:ze(i)||`Sign-in ended with code ${l}.`});d({ok:!0,account:await me(n)})})}),stop:a(()=>{s=!0,o.kill()},"stop")}}a(We,"startSignIn");var $=p(require("fs")),Je=p(require("os")),W=p(require("path"));var rt=".eesha";function O(){return W.join(Je.homedir(),rt)}a(O,"eeshaHome");function m(...n){return W.join(O(),...n)}a(m,"eeshaPath");function M(n,e){$.mkdirSync(W.dirname(n),{recursive:!0});let t=`${n}.${process.pid}.tmp`;$.writeFileSync(t,e,"utf8"),$.renameSync(t,n)}a(M,"writeAtomic");function A(n){try{return JSON.parse($.readFileSync(n,"utf8"))}catch{return}}a(A,"readJson");var On=p(require("fs"));var G=["ghcp","claude"];var mn=p(require("fs/promises"));var oe=p(require("path"));var b="providers",ot=["provider","uses",b],B=a(n=>typeof n=="object"&&n!==null&&!Array.isArray(n),"isMapping");function Ke(n,e){if(!B(n))throw new Error(`${e} has a '${b}:' that is not a mapping. Write one entry per runtime id, e.g. providers: { ghcp: { reasoningEffort: high }, kiro-cli: { model: claude-sonnet-4.5 } }.`);for(let[t,r]of Object.entries(n)){if(!B(r))throw new Error(`${e} has '${b}.${t}' that is not a mapping of args.`);for(let o of ot)if(o in r)throw new Error(`${e} sets '${o}' inside '${b}.${t}'. A block only applies once '${t}' is already the runtime, so it cannot choose one. Write '${o}' outside '${b}:'.`)}return n}a(Ke,"checkProviderBlocks");function qe(n,e){let t={...n,...e},r=n?.[b],o=e?.[b];if(B(r)&&B(o)){let s={...r};for(let[i,c]of Object.entries(o))s[i]=B(s[i])&&B(c)?{...s[i],...c}:c;t[b]=s}return t}a(qe,"mergeAiArgs");var x=".eesha",st="tasks.yml",he="settings.json",Ye="workflows";var Ar=`**/${x}/${st}`,it=[`**/${x}/${Ye}/**/*.yml`,`**/${x}/${Ye}/**/*.yaml`];function at(n){return n.length===1?n[0]:`{${n.join(",")}}`}a(at,"braced");var xr=at(it);var Ze=p(require("os")),we=p(require("path"));var Xe;function Qe(n){Xe=n}a(Qe,"useProfileDirectory");function en(){return Xe??we.join(Ze.homedir(),x)}a(en,"profileDirectory");var cn=p(require("os")),un=p(require("path"));var rn=String.raw`[\w.]+(?:\[(?:\d+|"[^"]*")\](?:\.\w+)*)*`,ye=new RegExp(String.raw`\$\{\{\s*(${rn})\s*\}\}`,"g"),nn=new RegExp(String.raw`^\$\{\{\s*(${rn})\s*\}\}$`);function H(n){return[...n.matchAll(/\[(\d+|"[^"]*")\]|[^.[\]]+/g)].map(e=>e[1]===void 0?e[0]:e[1].startsWith('"')?e[1].slice(1,-1):e[1])}a(H,"pathOf");var ct=5,on="run",sn="context",_=`${on}.${sn}`,be=["dateToday","dateNow","dateUtcNow","timestamp","runId","platform"];function tn(n){return be.includes(n)}a(tn,"isStampName");var an=["workspaceFolder","workspaceConfig","cwd","home","params","vars","env","run","spec",...be],I=class extends Error{static{a(this,"TemplateResolutionError")}};function E(n){return typeof n=="string"?[...n.matchAll(ye)].map(e=>e[1]):Array.isArray(n)?n.flatMap(E):n!==null&&typeof n=="object"?Object.values(n).flatMap(E):[]}a(E,"expressionsIn");function R(n,e){return n!==void 0&&Object.prototype.hasOwnProperty.call(n,e)}a(R,"owns");var C=class{static{a(this,"TemplateResolver")}resolve(e,t){return e.replace(ye,(r,o)=>this.stringify(this.demand(o,t,e)))}resolveValue(e,t){if(typeof e=="string"){let r=nn.exec(e.trim());return r?this.demand(r[1],t,e):this.resolve(e,t)}return Array.isArray(e)?e.map(r=>this.resolveValue(r,t)):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,this.resolveValue(o,t)])):e}resolveKnown(e,t){return this.tryResolveValue(e,t)}resolveVars(e,t){let r={workspaceFolder:t.workspaceFolder,workspaceConfig:t.workspaceConfig,home:t.home,cwd:t.cwd,params:t.params,stamps:t.stamps,variables:t.variables};return this.settle(e,o=>({...r,vars:o}))}resolveEnv(e,t){let r={workspaceFolder:t.workspaceFolder,workspaceConfig:t.workspaceConfig,home:t.home,cwd:t.cwd,params:t.params,stamps:t.stamps,variables:t.variables,vars:t.vars,run:t.run},o=this.settle(e,s=>({...r,env:{...t.env,...s}}));return Object.fromEntries(Object.entries(o).map(([s,i])=>[s,this.stringify(i)]))}resolveVariables(e,t){let r={workspaceFolder:t.workspaceFolder,workspaceConfig:t.workspaceConfig,home:t.home,cwd:t.cwd,env:t.env},o=this.settle(e,s=>({...r,variables:s}));for(let[s,i]of Object.entries(o)){if(!E(i).length)continue;let[c]=E(e[s]);throw new I(`Cannot resolve '\${{ ${c} }}' in '${s}' - '${s}' still has no value after every pass, so it reads a variable that reads it back.`)}return o}settle(e,t){let r={...e};for(let s=0;s<ct;s++){let i={},c=!1,u=t(r);for(let f of Object.keys(r))i[f]=this.tryResolveValue(r[f],u),i[f]!==r[f]&&(c=!0);if(r=i,!c)break}let o=t(r);for(let s of Object.keys(r))this.resolveValue(r[s],o);return r}tryResolveValue(e,t){if(typeof e=="string"){let r=nn.exec(e.trim());if(r){let o=this.lookup(r[1],t);return o?o.value:e}return e.replace(ye,(o,s)=>{let i=this.lookup(s,t);return i?this.stringify(i.value):o})}return Array.isArray(e)?e.map(r=>this.tryResolveValue(r,t)):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,this.tryResolveValue(o,t)])):e}demand(e,t,r){let o=this.lookup(e,t);if(o)return o.value;throw new I(`Cannot resolve '\${{ ${e} }}' in '${r}' - ${this.explain(e,t)}`)}explain(e,t){let{namespace:r,name:o,path:s}=this.split(e),i=o??"";if(r==="vars"&&t.vars===void 0)return"vars are not available here. They are resolved first, so nothing they read can be a var.";if(r==="env"&&t.env===void 0)return"env is not available here. Env is resolved after vars, so a 'vars:' value cannot read it.";if(r===_&&t.run===void 0)return"run variables are produced by tasks as they finish, so they cannot be read from 'vars:'.";if(r==="params"&&t.params===void 0)return"params are not available here.";if(R(t.items,r))return this.explainPath(r,t.items[r],H(e).slice(1));if(R(t.variables,r))return this.explainPath(r,t.variables[r],H(e).slice(1));let c=r==="params"?t.params:r==="vars"?t.vars:r===_?t.run:void 0;return o&&s.length&&R(c,o)?this.explainPath(`${r}.${o}`,c[o],s):r==="params"?`the file declares no param named '${i}'. A param has to be declared in 'params:' before a run can be asked for it.`:tn(r)&&t.stamps===void 0?`'${r}' is stamped when a run starts, and this value is read before any run exists.`:r==="env"&&s.length?`env vars are flat text - there is no '${r}.${i}.${s[0]}'.`:r==="vars"||r==="env"||r===_?`no ${r===_?"run variable":r==="env"?"env var":"var"} named '${i}' is in scope.`:`'${r}' is not a thing. Available: ${this.available(t).join(", ")}.`}explainPath(e,t,r){for(let o of r){if(Array.isArray(t)){if(!/^\d+$/.test(o))return`'${e}' is a list of ${t.length}, so it is read by position - '[0]', not '.${o}'.`;if(Number(o)>=t.length)return`'${e}' is a list of ${t.length}, so [${o}] is out of range.`;t=t[Number(o)],e=`${e}[${o}]`;continue}if(t===null||typeof t!="object")return`'${e}' is ${t===null?"null":typeof t=="string"?"text":`a ${typeof t}`}, so there is no '${o}' under it.`;if(!R(t,o))return`'${e}' has no '${o}'. It has: ${Object.keys(t).join(", ")||"nothing"}.`;t=t[o],e=`${e}.${o}`}return`'${e}' did not resolve.`}available(e){return["workspaceFolder","workspaceConfig","cwd","home",...e.stamps?[...be]:[],...e.params?["params.NAME"]:[],...e.vars?["vars.NAME"]:[],...e.env?["env.NAME"]:[],...e.run?[`${_}.NAME`]:[],...Object.keys(e.items??{}),...Object.keys(e.variables??{})]}lookup(e,t){if(e==="workspaceFolder")return{value:t.workspaceFolder};if(e==="workspaceConfig")return{value:t.workspaceConfig};if(e==="home")return{value:t.home};if(e==="cwd")return{value:t.cwd};if(tn(e))return t.stamps?{value:t.stamps[e]}:void 0;let[r]=H(e);if(R(t.items,r))return this.walk(t.items,r,H(e).slice(1));if(R(t.variables,r))return this.walk(t.variables,r,H(e).slice(1));let{namespace:o,name:s,path:i}=this.split(e);if(s!==void 0){if(o==="env")return i.length===0&&R(t.env,s)?{value:t.env[s]}:void 0;if(o==="params")return this.walk(t.params,s,i);if(o==="vars")return this.walk(t.vars,s,i);if(o===_)return this.walk(t.run,s,i)}}split(e){let t=H(e),r=t[0]===on&&t[1]===sn,o=r?2:1;return{namespace:r?_:t[0],name:t[o],path:t.slice(o+1)}}walk(e,t,r){if(!R(e,t))return;let o=e[t];for(let s of r){if(Array.isArray(o)){if(!/^\d+$/.test(s)||Number(s)>=o.length)return;o=o[Number(s)];continue}if(o===null||typeof o!="object"||!R(o,s))return;o=o[s]}return{value:o}}stringify(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}};function ke(n){let e=n.workspaceFolder;if(e)return{workspaceFolder:e,workspaceConfig:un.join(e,x),cwd:e,home:n.home??cn.homedir(),env:dt(n.denied??[],n.processEnv),variables:n.variables}}a(ke,"configScope");function dn(n,e,t){let r=E(n);if(!r.length)return n;Ae(r,e,t.denied??[]);let o=ke({...t,variables:void 0});if(!o)throw new Error(`${e} uses \${{ }} but no workspace is open, so there is nothing for 'workspaceFolder' to mean. Open the folder this file belongs to, or write the value without an expression.`);try{return new C().resolveVariables(n,o)}catch(s){throw s instanceof I?new Error(`${e}: ${s.message}`):s}}a(dn,"resolveVariables");function Se(n,e,t,r=[]){let o=E(n);if(!o.length)return n;let s=a(u=>r.includes(ut(u)),"late"),i=o.filter(u=>!s(u));Ae(i,e,t.denied??[]);let c=ke(t);if(!c){if(!i.length)return n;throw new Error(`'${e}' uses \${{ }} but no workspace is open, so there is nothing for 'workspaceFolder' to mean. Open the folder this file belongs to, or write the value without an expression.`)}try{if(i.length===o.length)return new C().resolveValue(n,c);let u=new C().resolveKnown(n,c);for(let f of E(u))s(f)||new C().resolve(`\${{ ${f} }}`,c);return u}catch(u){throw u instanceof I?new Error(`'${e}': ${u.message}`):u}}a(Se,"resolveConfigValue");function ut(n){return n.split(".")[0]}a(ut,"namespaceOf");function ve(n,e,t){let r=E(n);if(!r.length)return n;Ae(r,e,t.denied??[]);let o=ke(t);return o?new C().resolveKnown(n,{...o,env:void 0}):n}a(ve,"resolveAnchorsOnly");function Ae(n,e,t){if(!t.length)return;let r=new Set(t.map(o=>o.toUpperCase()));for(let o of n){let s=o.split(".");if(!(s.length!==2||s[0]!=="env"||!r.has(s[1].toUpperCase())))throw new Error(`'${e}' reads \${{ env.${s[1]} }}, which 'env.denied' vetoes. Remove the name from env.denied, or the expression from this file.`)}}a(Ae,"refuseDenied");function dt(n,e){let t=e??k.machine(),r=new Set(n.map(s=>s.toUpperCase())),o={};for(let[s,i]of Object.entries(t))i!==void 0&&!r.has(s.toUpperCase())&&(o[s]=i);return o}a(dt,"readableEnv");var hn={"kiro-cli":{command:"kiro-cli",args:["acp","--agent-engine","v3","--auth-method","cli"],extensions:["kiro-v3"]},"copilot-cli":{command:"copilot",args:["--acp","--stdio","--disallow-temp-dir"],extensions:["copilot-cli"]},"claude-cli":{command:"claude-agent-acp",extensions:["claude-cli"]},"gemini-cli":{command:"gemini",args:["--acp"]},"codex-cli":{command:"codex-acp"},"cursor-cli":{command:"cursor-agent",args:["acp"]},"opencode-cli":{command:"opencode",args:["acp"]}},ft="built-in",Ee={liveToolOutput:"Stream a running tool's output into its row in the log.",sessionCost:"Show what a session cost in money, not just in credits, in the usage card.",docDiff:`Offer "What changed" on a spec document - the last run's changes in red and green.`,steering:"Hand the project's steering files (.md files with an 'inclusion:' header) to AI chats.",hideCopilotPremiumRequests:"Record only Copilot's credits, not its premium requests, for what a call charged.",handover:"Offer a Handover button that moves a started chat to another runtime, through a saved file the new runtime reads.",toolResults:"Show what a finished tool call returned when its card in the chat is opened.",evals:"Offer the Evaluator page, which sends one message to up to six runtimes or models at once, each in its own copy of the folder, and shows their chats side by side with a report of time, cost and tool calls.",fakeRuntime:"Offer a fake runtime that calls no model and costs nothing. It writes sample drafts, asks one question and ticks tasks. For testing only.","Feature-SDD":"Show the SDD module in Eesha Code: the Spec explorer, the Specs item on a workspace's menu, and the /sdd pages."},lt=["docDiff","hideCopilotPremiumRequests","handover"];function pt(){return Object.fromEntries(Object.keys(Ee).map(n=>[n,lt.includes(n)]))}a(pt,"defaultFeatures");var gt=["node_modules",".git",".vscode",".idea","TestResults","bin","obj","dist","out","coverage","build","target","logs","tmp","temp"];function mt(n){return oe.join(n,x)}a(mt,"workspaceConfigOf");async function se(n,e={}){let t=e.readFile??kt,r=oe.join(e.profileDir??en(),he),o=n?oe.join(mt(n),he):void 0,[s,i]=await Promise.all([t(r),o?t(o):Promise.resolve(void 0)]),c=s!==void 0?J(s,r):void 0,u=i!==void 0&&o?J(i,o):void 0,f={workspaceFolder:n,home:e.home,processEnv:e.processEnv,denied:[...ln(c),...ln(u)]},d=[c?.variables!==void 0?Re(c.variables,r):void 0,u?.variables!==void 0&&o?Re(u.variables,o):void 0];return d.some(Boolean)&&(f.variables=dn(wn(d[0],d[1]).variables,`'variables' in ${[r,o].filter(Boolean).map(l=>`'${l}'`).join(" / ")}`,f)),wt(c!==void 0?gn(fn(c,r,f),r,"profile"):void 0,u!==void 0&&o?gn(fn(u,o,f),o,"workspace"):void 0)}a(se,"loadEngineSettings");function fn(n,e,t){let r=n.ai,o=!!r&&typeof r=="object"&&!Array.isArray(r),s=o?r.mcpServers:void 0,i=o?r.acpAgents:void 0;if(s===void 0&&i===void 0)return Se(n,e,t);let c={...r};delete c.mcpServers,delete c.acpAgents;let u=Se({...n,ai:c},e,t);return{...u,ai:{...u.ai,...s!==void 0?{mcpServers:ve(s,e,t)}:{},...i!==void 0?{acpAgents:ve(i,e,t)}:{}}}}a(fn,"resolved");function ln(n){let e=n?.env;if(!e||typeof e!="object"||Array.isArray(e))return[];let t=e.denied;return Array.isArray(t)?t.filter(r=>typeof r=="string"&&!r.includes("${{")):[]}a(ln,"deniedIn");var pn=["sdd","ai","env","variables","defaultFoldersToIgnoreScanning","debug","features","eesha"];function J(n,e){if(!n.trim())return;let t;try{t=JSON.parse(n)}catch(r){throw new Error(`'${e}' is not valid JSON: ${r instanceof Error?r.message:String(r)}. Plain JSON only - no comments.`)}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`'${e}' must be a JSON object of settings sections.`);return t}a(J,"readJson");function gn(n,e,t="profile"){for(let o of Object.keys(n))if(!pn.includes(o))throw new Error(`'${e}' has an unknown setting '${o}'. Valid sections: ${pn.join(", ")}.`);let r={source:e};if(n.sdd!==void 0&&(r.sdd=T(n.sdd,"sdd",e)),n.ai!==void 0){let o=T(n.ai,"ai",e),s={};for(let[i,c]of Object.entries(o)){if(i==="mcpServers"){r.mcpServers=T(c,"ai.mcpServers",e);continue}if(i==="acpAgents"){r.acpAgents=T(c,"ai.acpAgents",e);continue}if(i===b){let u=re(c,"ai.providers",e),f=u.find((d,l)=>u.indexOf(d)!==l);if(f)throw new Error(`'${e}' lists '${f}' twice in ai.providers.`);r.providers=u;continue}s[i]=T(c,`ai.${i}`,e),s[i][b]!==void 0&&Ke(s[i][b],`'${e}' ai.${i}`)}Object.keys(s).length&&(r.aiDefaults=s)}if(n.env!==void 0){let o=T(n.env,"env",e);for(let s of Object.keys(o))if(s!=="allowed"&&s!=="denied")throw new Error(`'${e}' has an unknown key 'env.${s}'. Valid: allowed, denied.`);o.allowed!==void 0&&(r.envAllowed=re(o.allowed,"env.allowed",e)),o.denied!==void 0&&(r.envDenied=re(o.denied,"env.denied",e))}if(n.variables!==void 0&&(r.variables=Re(n.variables,e)),n.defaultFoldersToIgnoreScanning!==void 0&&(r.ignore=re(n.defaultFoldersToIgnoreScanning,"defaultFoldersToIgnoreScanning",e)),n.debug!==void 0){if(t==="workspace")throw new Error(`'${e}' sets 'debug', which is a personal setting. Put it in your profile file, '~/.eesha/settings.json'.`);if(typeof n.debug!="boolean")throw new Error(`'${e}': 'debug' must be true or false.`);r.debug=n.debug}return n.features!==void 0&&(r.features=ht(n.features,e)),r}a(gn,"parseDeclared");function ht(n,e){let t=T(n,"features",e),r=Object.keys(Ee),o={};for(let[s,i]of Object.entries(t)){if(!r.includes(s))throw new Error(`'${e}' has an unknown feature flag 'features.${s}'. Valid flags: ${r.join(", ")}.`);if(typeof i!="boolean")throw new Error(`'${e}': 'features.${s}' must be true or false.`);o[s]=i}return o}a(ht,"featuresOf");function wt(n,e){let t=yt(n?.sdd,e?.sdd),r={},o={},s={};for(let l of[e,n])for(let[h,w]of Object.entries(l?.aiDefaults??{})){r[h]=qe(r[h],w);for(let z of Object.keys(w))(o[h]??={})[z]=l.source,(s[h]??={})[z]=l===n?"profile":"workspace"}let i={};for(let l of[e,n])for(let[h,w]of Object.entries(l?.mcpServers??{}))i[h]={server:w,source:l.source};let c={};for(let[l,h]of Object.entries(hn))c[l]={agent:h,source:ft};for(let l of[e,n])for(let[h,w]of Object.entries(l?.acpAgents??{}))c[h]={agent:w,source:l.source};let{variables:u,overrides:f}=wn(n?.variables,e?.variables,n?.source,e?.source),d=n?.providers??e?.providers;return d&&bt(d,[...new Set([...G,...Object.keys(c)])],r,(n?.providers?n:e).source),{sdd:t,ai:{defaults:r,defaultSources:o,defaultScopes:s,scopedDefaults:{workspace:e?.aiDefaults??{},profile:n?.aiDefaults??{}},...d?{providers:d}:{},mcpServers:i,acpAgents:c},env:{allowed:xe(n?.envAllowed,e?.envAllowed),denied:xe(n?.envDenied,e?.envDenied)},variables:u,variableOverrides:f,ignore:n?.ignore||e?.ignore?xe(n?.ignore,e?.ignore):[...gt],debug:n?.debug??!1,features:{...pt(),...e?.features,...n?.features}}}a(wt,"mergeEngineSettings");function Re(n,e){let t=T(n,"variables",e);for(let r of Object.keys(t))if(an.includes(r))throw new Error(`'${e}' declares a variable named '${r}', which \${{ ${r} }} already means. Pick another name.`);return t}a(Re,"variablesOf");function wn(n,e,t="profile",r="workspace"){let o=[],s=a(c=>!!c&&typeof c=="object"&&!Array.isArray(c),"isMapping"),i=a((c,u,f)=>{let d={...c};for(let[l,h]of Object.entries(u)){let w=f?`${f}.${l}`:l;if(s(d[l])&&s(h)){d[l]=i(d[l],h,w);continue}Object.prototype.hasOwnProperty.call(c,l)&&o.push(`variables.${w}: '${t}' overrides '${r}'.`),d[l]=h}return d},"merge");return{variables:i(e??{},n??{},""),overrides:o}}a(wn,"mergeVariables");function yt(n,e){return{...e,...n}}a(yt,"mergeSdd");function xe(n,e){return[...new Set([...n??[],...e??[]])]}a(xe,"union");function T(n,e,t){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`'${t}': '${e}' must be a mapping.`);return n}a(T,"mapping");function bt(n,e,t,r){let o=n.filter(i=>!e.includes(i));if(o.length)throw new Error(`'${r}' lists ${o.map(i=>`'${i}'`).join(", ")} in ai.providers, which this build cannot run. Known runtimes: ${e.join(", ")}. An ACP agent of your own goes under ai.acpAgents first.`);let s=t["ai@1"]?.provider?.trim()||"ghcp";if(!n.includes(s))throw new Error(`'${r}' lists ai.providers without '${s}', the runtime ai@1 starts on`+(t["ai@1"]?.provider?"":" when nothing names one")+`. Add it to the list, or set ai."ai@1".provider to one of: ${n.join(", ")}.`)}a(bt,"checkProviderList");function re(n,e,t){if(!Array.isArray(n)||n.some(r=>typeof r!="string"))throw new Error(`'${t}': '${e}' must be a list of names.`);return n}a(re,"names");async function kt(n){try{return await mn.readFile(n,"utf8")}catch(e){if(e.code==="ENOENT")return;throw new Error(`Could not read '${n}': ${e instanceof Error?e.message:String(e)}`)}}a(kt,"readFileOrUndefined");var kn=p(require("fs")),Sn=p(require("path"));var ie=p(require("fs")),y=p(require("path"));var St="CLAUDE_CLI_PATH";function yn(n){let e=L(n,St);if(e)return e;try{let r=y.dirname(y.dirname(require.resolve("./claude-agent-sdk/sdk.mjs"))),o=bn(r);if(o)return o}catch{}let t=j(n,"claude");return t?vt(t):void 0}a(yn,"cliBinary");function vt(n){let e=n;try{e=ie.realpathSync(n)}catch{return}if(!At(e))return e;let t=[y.join(y.dirname(n),"node_modules","@anthropic-ai")];e!==n&&t.push(y.dirname(y.dirname(e)));for(let r of t){let o=bn(r);if(o)return o}}a(vt,"globalCliBinary");function At(n){return[".cmd",".bat",".ps1",".js",".cjs",".mjs"].includes(y.extname(n).toLowerCase())}a(At,"isScript");function bn(n){let e="claude"+(process.platform==="win32"?".exe":""),t=process.platform==="linux"?[`linux-${process.arch}`,`linux-${process.arch}-musl`]:[`${process.platform}-${process.arch}`],r=[y.join(n,"claude-code","bin",e)];for(let o of t)for(let s of["claude-code","claude-agent-sdk"]){let i=`${s}-${o}`;r.push(y.join(n,i,e),y.join(n,s,"node_modules","@anthropic-ai",i,e))}for(let o of r)try{if(ie.statSync(o).isFile())return o}catch{}}a(bn,"platformBinaryIn");var $e={claude:"npm install -g @anthropic-ai/claude-code, or set CLAUDE_CLI_PATH to a copy you have",ghcp:"npm install -g @github/copilot, or set COPILOT_CLI_PATH to a copy you have","kiro-cli":"Kiro's own installer","copilot-cli":"npm install -g @github/copilot","claude-cli":"npm install -g @agentclientprotocol/claude-agent-acp","gemini-cli":"Google's Gemini CLI","codex-cli":"the Codex ACP adapter","cursor-cli":"Cursor's CLI","opencode-cli":"OpenCode"};function vn(n,e,t){return n.map(r=>{if(r==="claude")return{id:r,program:"claude",found:yn(t),install:$e.claude};if(r==="ghcp")return{id:r,program:"copilot",found:L(t,"COPILOT_CLI_PATH")||j(t,"copilot"),install:$e.ghcp};let o=e[r]?.agent;if(!o||typeof o.command!="string"||!o.command)return{id:r,program:"?",install:`${r} is not a runtime Eesha Code knows - check ai.providers and ai.acpAgents in settings.json`};let s=o.command;return{id:r,program:s,found:xt(s,t),install:$e[r]??`check ai.acpAgents.${r}.command in settings.json`}})}a(vn,"checkRuntimes");function xt(n,e){return Sn.isAbsolute(n)?kn.existsSync(n)?n:void 0:j(e,n)}a(xt,"programAt");async function Oe(){Qe(O());let n=k.machine();try{let e=await se(void 0),t=e.ai.providers!==void 0,r=e.ai.providers?[...e.ai.providers]:[...G,...Object.keys(e.ai.acpAgents).filter(o=>!G.includes(o))];return{checks:vn(r,e.ai.acpAgents,n),listed:t}}catch(e){return{checks:[],listed:!1,problem:`${m("settings.json")} could not be read: ${e.message}`}}}a(Oe,"checkThisMachine");function An(n){if(n.problem)return n.problem;let{checks:e,listed:t}=n,r=Math.max(...e.map(i=>i.id.length),7)+2,o=[t?"Runtimes the picker offers (ai.providers in settings.json), and whether their program is on this machine:":"Runtimes Eesha Code knows, and whether their program is on this machine. With no ai.providers list in settings.json, the picker offers the ones found:","",...e.map(i=>` ${i.id.padEnd(r)}${i.found?`found ${i.found}`:`not found ${i.program==="?"?i.install:`${i.program} - install: ${i.install}`}`}`),""],s=e.filter(i=>i.found);return o.push(`${s.length} of ${e.length} found. Sign-in is not checked: each runtime uses the sign-in its own program has.`),o.join(`
5
5
  `)}a(An,"doctorReport");function xn(n){let e=n.filter(r=>r.found).map(r=>r.id),t=n.filter(r=>!r.found).map(r=>r.id);return e.length?`Runtimes found: ${e.join(", ")}.${t.length?` Not found: ${t.join(", ")} - \`eesha doctor\` says how to install them.`:""}`:"No runtime's program was found on this machine. Run `eesha doctor` to see how to install one."}a(xn,"doctorLine");var ae=p(require("path"));var Rn=7420,F={default:16,min:11,max:24};function En(n){return typeof n=="number"&&Number.isInteger(n)&&n>=F.min&&n<=F.max}a(En,"isFontSize");var Rt=["dark","light","system"];function ce(n=m("settings.json")){return Ce(A(n))}a(ce,"readServerSettings");function Ce(n){let e=[],t=n&&typeof n=="object"?n.eesha:void 0;t!==void 0&&(typeof t!="object"||t===null)&&e.push("eesha must be an object - using the defaults.");let r=t&&typeof t=="object"?t:{},o=Rn;r.port!==void 0&&(typeof r.port=="number"&&Number.isInteger(r.port)&&r.port>=1024&&r.port<=65535?o=r.port:e.push(`eesha.port must be a whole number from 1024 to 65535 - using ${Rn}.`));let s="dark";r.theme!==void 0&&(Rt.includes(r.theme)?s=r.theme:e.push('eesha.theme must be "dark", "light" or "system" - using dark.'));let i=F.default;r.fontSize!==void 0&&(En(r.fontSize)?i=r.fontSize:e.push(`eesha.fontSize must be a whole number from ${F.min} to ${F.max} - using ${F.default}.`));let c=Et(r.workingFolders,e),u=Ot(r.runtimes,e);return{port:o,theme:s,fontSize:i,workingFolders:c,runtimes:u,problems:e}}a(Ce,"serverSettingsFrom");function $n(n){if(!Array.isArray(n)||n.some(t=>typeof t!="string"||!t.trim()))return"eesha.workingFolders must be a list of folder paths.";let e=n.find(t=>!ae.isAbsolute(t.trim()));if(e!==void 0)return`"${e}" in eesha.workingFolders is not a full folder path.`}a($n,"workingFoldersProblem");function Et(n,e){if(n===void 0)return[];let t=$n(n);if(t)return e.push(`${t.replace(/\.$/,"")} - no working folders are used.`),[];let r=[];for(let o of n){let s=ae.resolve(o.trim());r.some(i=>$t(i,s))||r.push(s)}return r}a(Et,"workingFoldersFrom");function $t(n,e){return process.platform==="win32"?n.toLowerCase()===e.toLowerCase():n===e}a($t,"sameFolder");function Ot(n,e){if(n===void 0)return{};if(!n||typeof n!="object"||Array.isArray(n))return e.push("eesha.runtimes must be an object of runtime ids - no tools are turned off."),{};let t={};for(let[r,o]of Object.entries(n)){if(!o||typeof o!="object"||Array.isArray(o)){e.push(`eesha.runtimes.${r} must be an object with toolsOff - left out.`);continue}let{toolsOff:s}=o;if(s===void 0){t[r]={toolsOff:[]};continue}if(!Array.isArray(s)||s.some(i=>typeof i!="string"||!i.trim())){e.push(`eesha.runtimes.${r}.toolsOff must be a list of tool names - left out.`),t[r]={toolsOff:[]};continue}t[r]={toolsOff:[...new Set(s.map(i=>i.trim()))]}}return t}a(Ot,"runtimeToolsFrom");function K(){return m("settings.json")}a(K,"settingsFile");function Ct(){try{return On.readFileSync(K(),"utf8")}catch{return""}}a(Ct,"fileText");function Tt(n){return se(void 0,{profileDir:O(),...n!==void 0?{readFile:a(async e=>e===K()?n:void 0,"readFile")}:{}})}a(Tt,"load");async function Pt(n){let e;try{e=J(n,K())}catch(r){return r.message}let t=Ce(e??{});if(t.problems.length)return t.problems.map(r=>r.replace(/ - using .*$/,".")).join(" ");try{await Tt(n)}catch(r){return r.message}}a(Pt,"checkSettingsText");async function Cn(n){let e;try{e=J(Ct(),K())??{}}catch(r){return{problem:`${r.message} Fix settings.json first.`}}let t=n(e);return t?{problem:t}:jt(JSON.stringify(e,void 0,2)+`
6
6
  `)}a(Cn,"editSettingsJson");async function jt(n){if(typeof n!="string")return{problem:"Send the file's text."};let e=await Pt(n);return e?{problem:e}:(M(K(),n),{ok:!0})}a(jt,"saveSettingsText");var _t=["off","read","write"],Te=["ado","github"],Pe=["workitems","queries","repos","pulls","builds","releases","wiki","testplans"],je=["repos","files","pulls","issues","actions","releases","discussions","projects"],It=new Set(["ado.queries","ado.repos","ado.wiki","ado.testplans","github.repos","github.files","github.discussions","github.projects"]);function Ft(n,e,t){return t!=="write"||!It.has(`${n}.${e}`)}a(Ft,"accessAllowed");var Dt=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/,Nt=/^[^/\\:*?"<>|#%&+]{1,64}$/,Lt=/^[A-Za-z0-9-]{1,39}(\/[A-Za-z0-9._-]{1,100})?$/;function Mt(n,e){if(!e||typeof e!="object")return{problem:"Send the connector's reach and sources."};let{reach:t,sources:r}=e;if(!Array.isArray(t))return{problem:"Send what is in reach as a list."};if(!r||typeof r!="object")return{problem:"Send each source's access: off, read or write."};let o=n==="ado"?Pe:je,s={};for(let c of o){let u=r[c]??"off";if(!_t.includes(u))return{problem:`${c} must be off, read or write.`};if(!Ft(n,c,u))return{problem:`${c} can only be off or read.`};s[c]=u}if(n==="ado"){let c=[];for(let u of t){let{org:f,project:d}=u??{};if(typeof f!="string"||!Dt.test(f)||typeof d!="string"||!Nt.test(d.trim()))return{problem:"Each ADO entry is an organization and a project, like contoso and Web."};c.some(l=>D(l.org,f)&&D(l.project,d.trim()))||c.push({org:f,project:d.trim()})}return{config:{reach:c,sources:s}}}let i=[];for(let c of t){if(typeof c!="string"||!Lt.test(c.trim()))return{problem:"Each GitHub entry is an owner, like octocat, or a repo, like octocat/hello."};i.some(u=>D(u,c.trim()))||i.push(c.trim())}return{config:{reach:i,sources:s}}}a(Mt,"checkConnector");function Gt(n){let e=n&&typeof n=="object"?n.eesha:void 0,t=e&&typeof e=="object"?e.connectors:void 0;if(!t||typeof t!="object")return{};let r={};for(let o of Te){let s=t[o];if(s===void 0)continue;let i=Mt(o,s);"config"in i&&(r[o]=i.config)}return r}a(Gt,"connectorsFrom");function Tn(n=m("settings.json")){return Gt(A(n))}a(Tn,"readConnectors");function _e(n,e){return Cn(t=>{let r=t.eesha&&typeof t.eesha=="object"&&!Array.isArray(t.eesha)?{...t.eesha}:{},o=r.connectors&&typeof r.connectors=="object"&&!Array.isArray(r.connectors)?{...r.connectors}:{};e?o[n]=e:delete o[n],Object.keys(o).length?r.connectors=o:delete r.connectors,Object.keys(r).length?t.eesha=r:delete t.eesha})}a(_e,"saveConnector");function D(n,e){return n.localeCompare(e,void 0,{sensitivity:"accent"})===0}a(D,"sameText");var Fn=p(require("http")),Dn=p(require("readline"));var Ie=p(require("crypto")),Pn=p(require("fs"));var ue="x-eesha-key";function P(n=m("key")){try{let t=Pn.readFileSync(n,"utf8").trim();if(/^[0-9a-f]{48}$/.test(t))return t}catch{}let e=Ie.randomBytes(24).toString("hex");return M(n,e+`
7
7
  `),e}a(P,"ensureKey");var jn=p(require("fs"));function _n(){return m("server.json")}a(_n,"serverFilePath");function U(){let n=A(_n());return n&&typeof n.pid=="number"&&typeof n.port=="number"?{pid:n.pid,port:n.port,startedAt:typeof n.startedAt=="number"?n.startedAt:0}:void 0}a(U,"readServerFile");function Fe(n){let e=U();(n===void 0||e?.pid===n)&&jn.rmSync(_n(),{force:!0})}a(Fe,"removeServerFile");var De=p(require("path"));function Bt(){return A(De.join(__dirname,"..","package.json"))??A(De.join(__dirname,"..","..","package.json"))}a(Bt,"packageJson");function de(){let n=Bt();return typeof n?.version=="string"?n.version:"unknown"}a(de,"packageVersion");var Ht="eesha-connectors",Ut=30*6e4,Vt=3e4;function In(n,e,t){let r=U();if(!r)return Promise.reject(new Error("The Eesha Code server is not running. Start it with `eesha start`."));let o=Buffer.from(JSON.stringify(e),"utf8");return new Promise((s,i)=>{let c=Fn.request({host:"127.0.0.1",port:r.port,method:"POST",path:n,headers:{[ue]:P(),"Content-Type":"application/json","Content-Length":o.length},timeout:t},u=>{let f=[];u.on("data",d=>f.push(d)),u.on("end",()=>{let d;try{d=JSON.parse(Buffer.concat(f).toString("utf8"))}catch{return i(new Error("The Eesha Code server's answer was not JSON."))}if(u.statusCode!==200)return i(new Error(d.problem??`The Eesha Code server answered ${u.statusCode}.`));s(d)})});c.on("timeout",()=>c.destroy(new Error("The Eesha Code server did not answer in time."))),c.on("error",i),c.end(o)})}a(In,"post");function Nn(n){let e=a(s=>{process.stdout.write(JSON.stringify(s)+`
@@ -20,7 +20,7 @@ specsDir: .kiro/specs
20
20
  # runtime and mode picked in the compose box. The model you pick for
21
21
  # Kiro still applies.
22
22
  ai:
23
- provider: kiro-cli-v3
23
+ provider: kiro-cli
24
24
  agentMode: spec
25
25
 
26
26
  # Kiro's documents have no "Open Questions" section to stop on.