@eeshaai/code 1.0.2 → 1.0.3
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/README.md +339 -337
- package/dist/cli.js +9 -9
- package/dist/server.js +259 -259
- package/dist/web/page.css +1 -1
- package/dist/web/page.js +124 -124
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`)}a(
|
|
4
|
-
`)}},"read");o.stdout.on("data",c),o.stderr.on("data",c);let u=setTimeout(()=>o.kill(),et);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:Ve(i)||`Sign-in ended with code ${l}.`});d({ok:!0,account:await ge(n)})})}),stop:a(()=>{s=!0,o.kill()},"stop")}}a(ze,"startSignIn");var $=p(require("fs")),We=p(require("os")),W=p(require("path"));var nt=".eesha";function O(){return W.join(We.homedir(),nt)}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 En=p(require("fs"));var G=["ghcp","claude"];var gn=p(require("fs/promises"));var oe=p(require("path"));var b="providers",tt=["provider","uses",b],B=a(n=>typeof n=="object"&&n!==null&&!Array.isArray(n),"isMapping");function Je(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 tt)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(Je,"checkProviderBlocks");function Ke(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(Ke,"mergeAiArgs");var x=".eesha",rt="tasks.yml",me="settings.json",qe="workflows";var br=`**/${x}/${rt}`,ot=[`**/${x}/${qe}/**/*.yml`,`**/${x}/${qe}/**/*.yaml`];function st(n){return n.length===1?n[0]:`{${n.join(",")}}`}a(st,"braced");var kr=st(ot);var Ye=p(require("os")),he=p(require("path"));var Ze;function Xe(n){Ze=n}a(Xe,"useProfileDirectory");function Qe(){return Ze??he.join(Ye.homedir(),x)}a(Qe,"profileDirectory");var an=p(require("os")),cn=p(require("path"));var tn=String.raw`[\w.]+(?:\[(?:\d+|"[^"]*")\](?:\.\w+)*)*`,we=new RegExp(String.raw`\$\{\{\s*(${tn})\s*\}\}`,"g"),en=new RegExp(String.raw`^\$\{\{\s*(${tn})\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 it=5,rn="run",on="context",_=`${rn}.${on}`,ye=["dateToday","dateNow","dateUtcNow","timestamp","runId","platform"];function nn(n){return ye.includes(n)}a(nn,"isStampName");var sn=["workspaceFolder","workspaceConfig","cwd","home","params","vars","env","run","spec",...ye],I=class extends Error{static{a(this,"TemplateResolutionError")}};function E(n){return typeof n=="string"?[...n.matchAll(we)].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(we,(r,o)=>this.stringify(this.demand(o,t,e)))}resolveValue(e,t){if(typeof e=="string"){let r=en.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<it;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=en.exec(e.trim());if(r){let o=this.lookup(r[1],t);return o?o.value:e}return e.replace(we,(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.`:nn(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?[...ye]:[],...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(nn(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]===rn&&t[1]===on,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 be(n){let e=n.workspaceFolder;if(e)return{workspaceFolder:e,workspaceConfig:cn.join(e,x),cwd:e,home:n.home??an.homedir(),env:ct(n.denied??[],n.processEnv),variables:n.variables}}a(be,"configScope");function un(n,e,t){let r=E(n);if(!r.length)return n;ve(r,e,t.denied??[]);let o=be({...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(un,"resolveVariables");function ke(n,e,t,r=[]){let o=E(n);if(!o.length)return n;let s=a(u=>r.includes(at(u)),"late"),i=o.filter(u=>!s(u));ve(i,e,t.denied??[]);let c=be(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(ke,"resolveConfigValue");function at(n){return n.split(".")[0]}a(at,"namespaceOf");function Se(n,e,t){let r=E(n);if(!r.length)return n;ve(r,e,t.denied??[]);let o=be(t);return o?new C().resolveKnown(n,{...o,env:void 0}):n}a(Se,"resolveAnchorsOnly");function ve(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(ve,"refuseDenied");function ct(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(ct,"readableEnv");var mn={"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"]}},ut="built-in",Re={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."},dt=["docDiff","hideCopilotPremiumRequests","handover"];function ft(){return Object.fromEntries(Object.keys(Re).map(n=>[n,dt.includes(n)]))}a(ft,"defaultFeatures");var lt=["node_modules",".git",".vscode",".idea","TestResults","bin","obj","dist","out","coverage","build","target","logs","tmp","temp"];function pt(n){return oe.join(n,x)}a(pt,"workspaceConfigOf");async function se(n,e={}){let t=e.readFile??yt,r=oe.join(e.profileDir??Qe(),me),o=n?oe.join(pt(n),me):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:[...fn(c),...fn(u)]},d=[c?.variables!==void 0?xe(c.variables,r):void 0,u?.variables!==void 0&&o?xe(u.variables,o):void 0];return d.some(Boolean)&&(f.variables=un(hn(d[0],d[1]).variables,`'variables' in ${[r,o].filter(Boolean).map(l=>`'${l}'`).join(" / ")}`,f)),mt(c!==void 0?pn(dn(c,r,f),r,"profile"):void 0,u!==void 0&&o?pn(dn(u,o,f),o,"workspace"):void 0)}a(se,"loadEngineSettings");function dn(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 ke(n,e,t);let c={...r};delete c.mcpServers,delete c.acpAgents;let u=ke({...n,ai:c},e,t);return{...u,ai:{...u.ai,...s!==void 0?{mcpServers:Se(s,e,t)}:{},...i!==void 0?{acpAgents:Se(i,e,t)}:{}}}}a(dn,"resolved");function fn(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(fn,"deniedIn");var ln=["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 pn(n,e,t="profile"){for(let o of Object.keys(n))if(!ln.includes(o))throw new Error(`'${e}' has an unknown setting '${o}'. Valid sections: ${ln.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&&Je(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=xe(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=gt(n.features,e)),r}a(pn,"parseDeclared");function gt(n,e){let t=T(n,"features",e),r=Object.keys(Re),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(gt,"featuresOf");function mt(n,e){let t=ht(n?.sdd,e?.sdd),r={},o={},s={};for(let l of[e,n])for(let[h,w]of Object.entries(l?.aiDefaults??{})){r[h]=Ke(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(mn))c[l]={agent:h,source:ut};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}=hn(n?.variables,e?.variables,n?.source,e?.source),d=n?.providers??e?.providers;return d&&wt(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:Ae(n?.envAllowed,e?.envAllowed),denied:Ae(n?.envDenied,e?.envDenied)},variables:u,variableOverrides:f,ignore:n?.ignore||e?.ignore?Ae(n?.ignore,e?.ignore):[...lt],debug:n?.debug??!1,features:{...ft(),...e?.features,...n?.features}}}a(mt,"mergeEngineSettings");function xe(n,e){let t=T(n,"variables",e);for(let r of Object.keys(t))if(sn.includes(r))throw new Error(`'${e}' declares a variable named '${r}', which \${{ ${r} }} already means. Pick another name.`);return t}a(xe,"variablesOf");function hn(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(hn,"mergeVariables");function ht(n,e){return{...e,...n}}a(ht,"mergeSdd");function Ae(n,e){return[...new Set([...n??[],...e??[]])]}a(Ae,"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 wt(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(wt,"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 yt(n){try{return await gn.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(yt,"readFileOrUndefined");var bn=p(require("fs")),kn=p(require("path"));var ie=p(require("fs")),y=p(require("path"));var bt="CLAUDE_CLI_PATH";function wn(n){let e=L(n,bt);if(e)return e;try{let r=y.dirname(y.dirname(require.resolve("./claude-agent-sdk/sdk.mjs"))),o=yn(r);if(o)return o}catch{}let t=j(n,"claude");return t?kt(t):void 0}a(wn,"cliBinary");function kt(n){let e=n;try{e=ie.realpathSync(n)}catch{return}if(!St(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=yn(r);if(o)return o}}a(kt,"globalCliBinary");function St(n){return[".cmd",".bat",".ps1",".js",".cjs",".mjs"].includes(y.extname(n).toLowerCase())}a(St,"isScript");function yn(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(yn,"platformBinaryIn");var Ee={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 Sn(n,e,t){return n.map(r=>{if(r==="claude")return{id:r,program:"claude",found:wn(t),install:Ee.claude};if(r==="ghcp")return{id:r,program:"copilot",found:L(t,"COPILOT_CLI_PATH")||j(t,"copilot"),install:Ee.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:vt(s,t),install:Ee[r]??`check ai.acpAgents.${r}.command in settings.json`}})}a(Sn,"checkRuntimes");function vt(n,e){return kn.isAbsolute(n)?bn.existsSync(n)?n:void 0:j(e,n)}a(vt,"programAt");async function $e(){Xe(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:Sn(r,e.ai.acpAgents,n),listed:t}}catch(e){return{checks:[],listed:!1,problem:`${m("settings.json")} could not be read: ${e.message}`}}}a($e,"checkThisMachine");function vn(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
|
-
`)}a(
|
|
6
|
-
`)}a(
|
|
7
|
-
`),e}a(P,"ensureKey");var
|
|
8
|
-
`)},"write"),t=a((s,i)=>e({jsonrpc:"2.0",id:s,result:i}),"answer"),r=a((s,i,c)=>e({jsonrpc:"2.0",id:s,error:{code:i,message:c}}),"fail"),o=a(async s=>{let{id:i,method:c,params:u}=s,f=i!=null;switch(c){case"initialize":return t(i,{protocolVersion:typeof u?.protocolVersion=="string"?u.protocolVersion:"2025-06-18",capabilities:{tools:{}},serverInfo:{name:
|
|
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
|
+
`)}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(`
|
|
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
|
+
`)}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
|
+
`),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)+`
|
|
8
|
+
`)},"write"),t=a((s,i)=>e({jsonrpc:"2.0",id:s,result:i}),"answer"),r=a((s,i,c)=>e({jsonrpc:"2.0",id:s,error:{code:i,message:c}}),"fail"),o=a(async s=>{let{id:i,method:c,params:u}=s,f=i!=null;switch(c){case"initialize":return t(i,{protocolVersion:typeof u?.protocolVersion=="string"?u.protocolVersion:"2025-06-18",capabilities:{tools:{}},serverInfo:{name:Ht,version:de()}});case"ping":return t(i,{});case"tools/list":try{let d=await In("/control/connectors/tools",{chat:n},Vt);return t(i,{tools:d.tools})}catch(d){return r(i,-32603,d.message)}case"tools/call":try{let d=await In("/control/connectors/call",{chat:n,name:u?.name,arguments:u?.arguments??{}},Ut);return t(i,{content:[{type:"text",text:d.text}],...d.isError?{isError:!0}:{}})}catch(d){return t(i,{content:[{type:"text",text:d.message}],isError:!0})}default:f&&r(i,-32601,`${c} is not something this server does.`)}},"handle");return new Promise(s=>{let i=Dn.createInterface({input:process.stdin});i.on("line",c=>{if(!c.trim())return;let u;try{u=JSON.parse(c)}catch{return r(null,-32700,"Not JSON.")}o(u)}),i.on("close",()=>s(0))})}a(Nn,"runMcpBridge");var Mn=require("child_process"),N=p(require("fs")),S=p(require("path"));var zt=64*1024*1024,Wt=2*6e4,$s=10*6e4,Os=2*1024*1024;var Ne=class extends Error{static{a(this,"GitError")}};function Gn(n,e,t={}){return new Promise((r,o)=>{(0,Mn.execFile)("git",e,{cwd:n,env:{...process.env,GIT_TERMINAL_PROMPT:"0",GIT_EDITOR:"true",GIT_SEQUENCE_EDITOR:"true",GIT_OPTIONAL_LOCKS:"0",GIT_PAGER:"cat"},windowsHide:!0,maxBuffer:zt,timeout:t.timeout??Wt,encoding:t.raw?"buffer":"utf8"},(s,i,c)=>{if(s){let u=String(c||i||"").trim();o(new Ne(u||s.message));return}r(i)})})}a(Gn,"git");async function Ln(n){try{return S.resolve((await Gn(n,["rev-parse","--show-toplevel"],{})).trim())}catch{return}}a(Ln,"topOf");function Jt(n){let e=S.resolve(n);return process.platform==="win32"?e.toLowerCase():e}a(Jt,"sameKey");async function Bn(n){let e=[],t=new Set,r=a(o=>{let s=Jt(o);t.has(s)||(t.add(s),e.push({root:o,name:S.basename(o)||o}))},"add");for(let o of n){let s=await Ln(o);if(s){r(s);continue}let i;try{i=await N.promises.readdir(o,{withFileTypes:!0})}catch{continue}let c=i.filter(u=>u.isDirectory()&&N.existsSync(S.join(o,u.name,".git"))).map(u=>S.join(o,u.name)).sort((u,f)=>u.localeCompare(f));for(let u of c){let f=await Ln(u);f&&r(f)}}return e}a(Bn,"findRepos");async function Hn(n){try{return(await Gn(n.root,["config","--get-regexp","^remote\\..*\\.url$"],{})).split(/\r?\n/).map(t=>t.trim().split(/\s+/)[1]).filter(t=>!!t)}catch{return[]}}a(Hn,"repoRemoteUrls");function V(n){try{return decodeURIComponent(n)}catch{return n}}a(V,"decode");function Kt(n){let e=n.trim(),t=/^https?:\/\/(?:[^@/]+@)?dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\//i.exec(e);if(t)return{kind:"ado",org:V(t[1]),project:V(t[2])};if(t=/^https?:\/\/(?:[^@/]+@)?([^./]+)\.visualstudio\.com\/(?:DefaultCollection\/)?([^/]+)\/_git\//i.exec(e),t)return{kind:"ado",org:V(t[1]),project:V(t[2])};if(t=/^(?:ssh:\/\/)?[^@]+@(?:ssh\.dev\.azure\.com|vs-ssh\.visualstudio\.com)[:/]v3\/([^/]+)\/([^/]+)\//i.exec(e),t)return{kind:"ado",org:V(t[1]),project:V(t[2])};if(t=/^(?:https?:\/\/(?:[^@/]+@)?github\.com\/|(?:ssh:\/\/)?git@github\.com[:/])([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(e),t)return{kind:"github",owner:t[1],repo:t[2]}}a(Kt,"parseRemote");async function Un(n){let e=[],t=[];for(let r of await Bn(n))for(let o of await Hn(r)){let s=Kt(o);if(s?.kind==="ado"&&!e.some(i=>D(i.org,s.org)&&D(i.project,s.project))&&e.push({org:s.org,project:s.project}),s?.kind==="github"){let i=`${s.owner}/${s.repo}`;t.some(c=>D(c,i))||t.push(i)}}return{ado:e,github:t}}a(Un,"remotesOf");var Vn=`Eesha Code - a session with AI coding agents in a browser tab.
|
|
9
9
|
|
|
10
10
|
eesha start [--no-open] Start the server in the background and open the page.
|
|
11
11
|
eesha stop Stop the server. A turn still running is stopped.
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
eesha --version Print the version.
|
|
19
19
|
|
|
20
20
|
Files: ${O()}
|
|
21
|
-
Settings: ${m("settings.json")} - "eesha": { "port": 7420, "theme": "dark", "fontSize": 16 }`;function
|
|
22
|
-
`),console.error(
|
|
21
|
+
Settings: ${m("settings.json")} - "eesha": { "port": 7420, "theme": "dark", "fontSize": 16 }`;function fe(){return m("logs","server-output.txt")}a(fe,"outputFile");function q(n,e){return`http://127.0.0.1:${n}/?key=${e}`}a(q,"link");function Wn(n,e,t,r){return new Promise((o,s)=>{let i=zn.request({host:"127.0.0.1",port:n,method:t,path:r,headers:{[ue]:e},timeout:3e3},c=>{let u=[];c.on("data",f=>u.push(f)),c.on("end",()=>{if(c.statusCode!==200)return s(new Error(`The server answered ${c.statusCode}.`));try{o(JSON.parse(Buffer.concat(u).toString("utf8")))}catch{s(new Error("The server's answer was not JSON."))}})});i.on("timeout",()=>i.destroy(new Error("The server did not answer."))),i.on("error",s),i.end()})}a(Wn,"control");async function le(n){let e=U();if(e)try{return await Wn(e.port,n,"GET","/control/status")}catch{Le(e.pid)||Fe(e.pid);return}}a(le,"running");function Le(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}a(Le,"alive");function Jn(n){return new Promise(e=>setTimeout(e,n))}a(Jn,"wait");function Me(n){let[e,t]=process.platform==="win32"?["cmd",["/c","start","",n]]:process.platform==="darwin"?["open",[n]]:["xdg-open",[n]];try{(0,Y.spawn)(e,t,{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{console.log("Could not open the browser - open the link above yourself.")}}a(Me,"openInBrowser");function Ge(n,e){console.log(`Eesha Code is running (pid ${n.pid}).`),console.log(` Open: ${q(n.port,e)}`),console.log(` Sessions: ${n.chats} open, ${n.working} working, ${n.tabs} browser tab(s).`),console.log(` Log: ${m("logs")}`),console.log(" Stop: eesha stop")}a(Ge,"printRunning");async function qt(n){let e=P(),t=await le(e);if(t)return console.log("Already running."),Ge(t,e),n&&Me(q(t.port,e)),0;let r=ce();for(let c of r.problems)console.log(`settings.json: ${c}`);v.existsSync(m("settings.json"))||(console.log(`No ${m("settings.json")} yet - the runtimes use their built-in defaults.`),console.log(xn((await Oe()).checks))),v.mkdirSync(Z.dirname(fe()),{recursive:!0});let o=v.openSync(fe(),"w"),s=(0,Y.spawn)(process.execPath,[Z.join(__dirname,"server.js")],{detached:!0,stdio:["ignore",o,o],windowsHide:!0,cwd:O()});v.closeSync(o);let i;s.on("exit",c=>{i=c}),s.unref();for(let c=0;c<100;c++){if(await Jn(200),i!==void 0){console.error(`Eesha Code did not start (exit ${i}).`);let f=v.existsSync(fe())?v.readFileSync(fe(),"utf8").trim():"";return f&&console.error(f),console.error(`More in ${m("logs")}.`),1}let u=await le(e);if(u)return Ge(u,e),n&&Me(q(u.port,e)),0}return console.error(`Eesha Code started but does not answer. See ${m("logs")}.`),1}a(qt,"start");async function Yt(){let n=P(),e=U();if(!e)return console.log("Not running."),0;try{await Wn(e.port,n,"POST","/control/stop")}catch{}for(let t=0;t<50&&Le(e.pid);t++)await Jn(200);if(Le(e.pid)){console.log("The server did not stop by itself - ending its process.");try{process.kill(e.pid)}catch(t){return console.error(`Could not end process ${e.pid}: ${t.message}`),1}}return Fe(e.pid),console.log("Stopped."),0}a(Yt,"stop");async function Zt(){let n=P(),e=await le(n);return e?(Ge(e,n),0):(console.log("Not running. Start it with: eesha start"),1)}a(Zt,"status");async function Xt(){let n=P(),e=await le(n);return e?(Me(q(e.port,n)),0):(console.log("Not running. Start it with: eesha start"),1)}a(Xt,"openPage");function Qt(){let n=P(),e=ce();return console.log(`Eesha Code on ${q(e.port,n)} - Ctrl+C stops it.`),(0,Y.spawnSync)(process.execPath,[Z.join(__dirname,"server.js"),"--foreground"],{stdio:"inherit"}).status??1}a(Qt,"runHere");async function er(n){if(!Te.includes(n))return console.error("Say which: eesha connect ado, or eesha connect github."),2;let e=n;if(!ne(e))return console.error(te(e)),1;let t=await me(e);if(t)console.log(`Already signed in as ${t}.`);else{console.log(e==="ado"?"Signing in with az login - a browser window opens.":"Signing in with gh auth login - a browser window opens.");let c=await We(e,u=>{u.code?console.log(`One-time code: ${u.code}${u.url?` - enter it at ${u.url}`:""}`):u.line&&console.log(` ${u.line}`)}).done;if("problem"in c)return console.error(c.problem),1;t=c.account,console.log(`Signed in${t?` as ${t}`:""}.`)}if(Tn()[e])return console.log("Connected already. Change what is in reach and allowed on the Connectors page."),0;let r=await Un([process.cwd()]),o=e==="ado"?await _e("ado",{reach:r.ado,sources:Object.fromEntries(Pe.map(i=>[i,"read"]))}):await _e("github",{reach:r.github,sources:Object.fromEntries(je.map(i=>[i,"read"]))});if("problem"in o)return console.error(o.problem),1;let s=e==="ado"?r.ado.map(i=>`${i.org}/${i.project}`):r.github;return console.log(`Connected, every source on Read. In reach: ${s.length?s.join(", "):"nothing yet - add it on the Connectors page"}.`),console.log("Sessions started from now on get the connector tools."),0}a(er,"connect");async function nr(){let[n,...e]=process.argv.slice(2);switch(n){case"start":return qt(!e.includes("--no-open"));case"stop":return Yt();case"status":return Zt();case"open":return Xt();case"run":return Qt();case"doctor":{let t=await Oe();return console.log(An(t)),t.checks.some(r=>r.found)?0:1}case"connect":return er(e[0]);case"mcp":{let t=e.indexOf("--chat"),r=t>=0?e[t+1]:void 0;return r?Nn(r):(console.error("eesha mcp --chat <id> is started by a runtime for the connector tools."),2)}case"--version":case"-v":case"version":return console.log(de()),0;case void 0:case"help":case"--help":case"-h":return console.log(Vn),0;default:return console.error(`Unknown command: ${n}
|
|
22
|
+
`),console.error(Vn),2}}a(nr,"main");nr().then(n=>process.exit(n),n=>{console.error(n.message),process.exit(1)});
|
|
23
23
|
//# sourceMappingURL=cli.js.map
|