@eeshaai/code 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/LICENSE.md +115 -0
  2. package/README.md +322 -3
  3. package/dist/THIRD-PARTY-NOTICES.md +23 -0
  4. package/dist/claude-agent-sdk/LICENSE.md +1 -0
  5. package/dist/claude-agent-sdk/sdk.mjs +156 -0
  6. package/dist/cli.js +23 -0
  7. package/dist/pluginWorker.js +1610 -0
  8. package/dist/resources/styles/custom/instructions/design.md +284 -0
  9. package/dist/resources/styles/custom/instructions/requirements.md +161 -0
  10. package/dist/resources/styles/custom/instructions/tasks-implement.md +90 -0
  11. package/dist/resources/styles/custom/instructions/tasks.md +159 -0
  12. package/dist/resources/styles/custom/process.md +49 -0
  13. package/dist/resources/styles/custom/prompts/first.md +29 -0
  14. package/dist/resources/styles/custom/prompts/implement.md +27 -0
  15. package/dist/resources/styles/custom/prompts/rewrite-note.md +40 -0
  16. package/dist/resources/styles/custom/prompts/rewrite.md +32 -0
  17. package/dist/resources/styles/custom/style.yml +46 -0
  18. package/dist/resources/styles/grammar.md +731 -0
  19. package/dist/server.js +839 -0
  20. package/dist/web/chunks/abnfDiagram-VCTEODGH-6KC3BO47.js +2 -0
  21. package/dist/web/chunks/architecture-7GRP2DOG-JLXNDD4H.js +2 -0
  22. package/dist/web/chunks/architectureDiagram-5GKGNRK7-QKPCVOD2.js +37 -0
  23. package/dist/web/chunks/blockDiagram-I7D4REHJ-4XZWNXLB.js +130 -0
  24. package/dist/web/chunks/c4Diagram-7LVT6UL2-4HJHKNE3.js +39 -0
  25. package/dist/web/chunks/chunk-2DLEMZHM.js +33 -0
  26. package/dist/web/chunks/chunk-2RFQIKC6.js +232 -0
  27. package/dist/web/chunks/chunk-37NHO5VO.js +2 -0
  28. package/dist/web/chunks/chunk-46RPN6IE.js +3 -0
  29. package/dist/web/chunks/chunk-4IPDIKAU.js +2 -0
  30. package/dist/web/chunks/chunk-4KP3BIPB.js +2 -0
  31. package/dist/web/chunks/chunk-4S2DRQJ6.js +340 -0
  32. package/dist/web/chunks/chunk-4TORDSRR.js +2 -0
  33. package/dist/web/chunks/chunk-5KNOHX5X.js +15 -0
  34. package/dist/web/chunks/chunk-6FQEBIA3.js +133 -0
  35. package/dist/web/chunks/chunk-6KSWTVXD.js +3 -0
  36. package/dist/web/chunks/chunk-6TGTE6CF.js +2 -0
  37. package/dist/web/chunks/chunk-6URXM4C4.js +2 -0
  38. package/dist/web/chunks/chunk-6VRLULJH.js +2 -0
  39. package/dist/web/chunks/chunk-7XAOOQR4.js +2 -0
  40. package/dist/web/chunks/chunk-BUZPUGIT.js +2 -0
  41. package/dist/web/chunks/chunk-DIRT34TZ.js +2 -0
  42. package/dist/web/chunks/chunk-FGASMJTA.js +4 -0
  43. package/dist/web/chunks/chunk-FNIFXWXL.js +2 -0
  44. package/dist/web/chunks/chunk-FPLIRG3U.js +73 -0
  45. package/dist/web/chunks/chunk-GQPX4EIC.js +11 -0
  46. package/dist/web/chunks/chunk-HAKJ3AUV.js +2 -0
  47. package/dist/web/chunks/chunk-HBEUVMXY.js +2 -0
  48. package/dist/web/chunks/chunk-HNYXDXPN.js +63 -0
  49. package/dist/web/chunks/chunk-HX7W7GSO.js +2 -0
  50. package/dist/web/chunks/chunk-II6WN3ZG.js +2 -0
  51. package/dist/web/chunks/chunk-JOSXY3EP.js +169 -0
  52. package/dist/web/chunks/chunk-L34PKG4P.js +2 -0
  53. package/dist/web/chunks/chunk-LDXBIOBF.js +2 -0
  54. package/dist/web/chunks/chunk-LHNPPNB7.js +3 -0
  55. package/dist/web/chunks/chunk-LQ6CTWX6.js +2 -0
  56. package/dist/web/chunks/chunk-LSVIQRSY.js +2 -0
  57. package/dist/web/chunks/chunk-M3SWKTLZ.js +2 -0
  58. package/dist/web/chunks/chunk-MBZYSJFT.js +2 -0
  59. package/dist/web/chunks/chunk-MZEMPN3C.js +2 -0
  60. package/dist/web/chunks/chunk-OODDZ447.js +2 -0
  61. package/dist/web/chunks/chunk-OXLTOJNY.js +3 -0
  62. package/dist/web/chunks/chunk-PR453BYT.js +2 -0
  63. package/dist/web/chunks/chunk-QNEZP2TE.js +179 -0
  64. package/dist/web/chunks/chunk-R7TFKRNM.js +2 -0
  65. package/dist/web/chunks/chunk-T4HEWXAQ.js +2 -0
  66. package/dist/web/chunks/chunk-TPXX77KB.js +2 -0
  67. package/dist/web/chunks/chunk-TPYBIPJG.js +2 -0
  68. package/dist/web/chunks/chunk-TXNHMPKM.js +89 -0
  69. package/dist/web/chunks/chunk-VAKN3BTM.js +2 -0
  70. package/dist/web/chunks/chunk-VY4GEFSG.js +2 -0
  71. package/dist/web/chunks/chunk-XBYCKXUJ.js +207 -0
  72. package/dist/web/chunks/chunk-YM7LHP34.js +16 -0
  73. package/dist/web/chunks/classDiagram-ZZMXUADV-4J5HHZD6.js +2 -0
  74. package/dist/web/chunks/classDiagram-v2-VYDZK3BY-X6WY2DAS.js +2 -0
  75. package/dist/web/chunks/cose-bilkent-JH36ORCC-ZPRW5JRW.js +2 -0
  76. package/dist/web/chunks/cynefin-OW5HDTMX-SVVTQRRB.js +2 -0
  77. package/dist/web/chunks/cynefinDiagram-5FMLGOSQ-O7GURHJG.js +63 -0
  78. package/dist/web/chunks/dagre-GXQ25YYZ-WK67O4N6.js +5 -0
  79. package/dist/web/chunks/diagram-S7CK7UJ4-2CEO2EN2.js +31 -0
  80. package/dist/web/chunks/diagram-UQ7AKVKN-2Z4VHGF3.js +42 -0
  81. package/dist/web/chunks/diagram-VSXAHHWV-AN4BOWYB.js +4 -0
  82. package/dist/web/chunks/diagram-VX7I27RA-VEZ2GXCM.js +25 -0
  83. package/dist/web/chunks/diagram-Z3DM3KII-TGGNDSLW.js +25 -0
  84. package/dist/web/chunks/ebnfDiagram-PWID7BFC-7RM57IJV.js +2 -0
  85. package/dist/web/chunks/erDiagram-RLTQ6QDP-LCATC3YT.js +100 -0
  86. package/dist/web/chunks/eventmodeling-NTZA5JFV-2SR57JAH.js +2 -0
  87. package/dist/web/chunks/flowDiagram-HODETNUW-HU6Y2EYQ.js +2 -0
  88. package/dist/web/chunks/ganttDiagram-EL5Y4UJY-5VPBBF2V.js +293 -0
  89. package/dist/web/chunks/gitGraph-4MIJSDKK-25JPIQP7.js +2 -0
  90. package/dist/web/chunks/gitGraphDiagram-WWUBYQGX-HZMAGPIJ.js +107 -0
  91. package/dist/web/chunks/info-A6RAGUB7-72MROTVX.js +2 -0
  92. package/dist/web/chunks/infoDiagram-27XIBGKW-BQYTPGNG.js +3 -0
  93. package/dist/web/chunks/ishikawaDiagram-5VMMS53U-A54WWBPX.js +71 -0
  94. package/dist/web/chunks/journeyDiagram-3NMN7TZE-XRCTMTR7.js +140 -0
  95. package/dist/web/chunks/kanban-definition-UXKFOSKX-UW2PQXZF.js +90 -0
  96. package/dist/web/chunks/katex-B7HWCVTN.js +258 -0
  97. package/dist/web/chunks/mermaid.core-VL5SQK5M.js +19 -0
  98. package/dist/web/chunks/mindmap-definition-YA3MSWOX-2H2Z6CVN.js +97 -0
  99. package/dist/web/chunks/packet-AYTQ26CC-NEGDW4B6.js +2 -0
  100. package/dist/web/chunks/pegDiagram-XKGWAZYB-KC4BYUN7.js +2 -0
  101. package/dist/web/chunks/pie-WAS4IAKB-OT3EMGHT.js +2 -0
  102. package/dist/web/chunks/pieDiagram-E7YTZNPT-54T6XSU5.js +40 -0
  103. package/dist/web/chunks/quadrantDiagram-AXDQQJYC-3G3RXSTE.js +8 -0
  104. package/dist/web/chunks/radar-RG4KPBEZ-DCHU5FOQ.js +2 -0
  105. package/dist/web/chunks/railroad-74A4TZTK-RZX6D7H6.js +2 -0
  106. package/dist/web/chunks/railroad-abnf-HS5TGJTU-STTFN7R4.js +2 -0
  107. package/dist/web/chunks/railroad-ebnf-LZEXJU2U-RBXU3IBK.js +2 -0
  108. package/dist/web/chunks/railroad-peg-WCYAUIDC-OD5BXOH6.js +2 -0
  109. package/dist/web/chunks/railroadDiagram-O6MQD6OU-3LHKFF5N.js +2 -0
  110. package/dist/web/chunks/requirementDiagram-BXWQKSXE-M4LF54YT.js +85 -0
  111. package/dist/web/chunks/sankeyDiagram-P5KCCOFB-USCKKKNT.js +41 -0
  112. package/dist/web/chunks/sequenceDiagram-WJ2MYXX4-QZ2O4KWV.js +163 -0
  113. package/dist/web/chunks/sizeCapture-INFHLROL-DZI5JWEV.js +2 -0
  114. package/dist/web/chunks/stateDiagram-D77RDMKH-EQJNTBF3.js +2 -0
  115. package/dist/web/chunks/stateDiagram-v2-MP3YSRHH-WSCDKLG6.js +2 -0
  116. package/dist/web/chunks/swimlanes-42K2YHIH-H7SZ2HG6.js +2 -0
  117. package/dist/web/chunks/swimlanesDiagram-VR7AAH4N-DFYTBPVS.js +9 -0
  118. package/dist/web/chunks/timeline-definition-24CTP7MA-4Q2ARIQ6.js +121 -0
  119. package/dist/web/chunks/treeView-Q6P3EWNA-ADCP6RPT.js +2 -0
  120. package/dist/web/chunks/treemap-WGGIJYW6-NEV7DUDY.js +2 -0
  121. package/dist/web/chunks/vennDiagram-4TSXK5OY-WMJVK74C.js +35 -0
  122. package/dist/web/chunks/wardley-WFR3VGLG-4QZOFDI5.js +2 -0
  123. package/dist/web/chunks/wardleyDiagram-VM6X3IG4-CLB324RQ.js +79 -0
  124. package/dist/web/chunks/xychartDiagram-S5SC5T6Z-G5C2R7C2.js +8 -0
  125. package/dist/web/index.html +24 -0
  126. package/dist/web/page.css +2 -0
  127. package/dist/web/page.js +210 -0
  128. package/package.json +62 -6
package/dist/cli.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var Wn=Object.create;var le=Object.defineProperty;var Jn=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,Yn=Object.prototype.hasOwnProperty;var a=(n,e)=>le(n,"name",{value:e,configurable:!0});var Zn=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Kn(e))!Yn.call(n,o)&&o!==t&&le(n,o,{get:()=>e[o],enumerable:!(r=Jn(e,o))||r.enumerable});return n};var p=(n,e,t)=>(t=n!=null?Wn(qn(n)):{},Zn(e||!n||!n.__esModule?le(t,"default",{value:n,enumerable:!0}):t,n));var Y=require("child_process"),v=p(require("fs")),Un=p(require("http")),Z=p(require("path"));var ee=require("child_process");var Ge=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(Ge.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)||(Xn.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)}},Xn=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 He={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."}},Qn=6e4,et=10*6e4,Q=class extends Error{static{a(this,"CliError")}};function ne(n){return j(k.machine(),He[n].name)}a(ne,"findCli");function te(n){return He[n].install}a(te,"installHint");function pe(n){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(n)}a(pe,"needsShell");function Ue(n){return pe(n)?`"${n}"`:n}a(Ue,"startable");function Ve(n){return n.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).slice(0,6).join(`
3
+ `)}a(Ve,"shortText");function Be(n,e){let t=ne(n);return t?new Promise((r,o)=>{(0,ee.execFile)(Ue(t),e,{env:{...k.machine(),GH_PROMPT_DISABLED:"1",AZURE_CORE_NO_COLOR:"true",AZURE_CORE_ONLY_SHOW_ERRORS:"true"},windowsHide:!0,timeout:Qn,maxBuffer:4*1024*1024,shell:pe(t)},(s,i,c)=>{if(s)return o(new Q(Ve(String(c||i||""))||s.message));r(String(i))})}):Promise.reject(new Q(te(n)))}a(Be,"runCli");async function ge(n){try{if(n==="ado")return(await Be("ado",["account","show","--query","user.name","-o","tsv"])).trim()||void 0;let e=await Be("github",["auth","status","--hostname","github.com"]);return/account\s+(\S+)/i.exec(e)?.[1]??(e.trim()?"GitHub":void 0)}catch{return}}a(ge,"signedInAs");function ze(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)(Ue(t),r,{env:{...k.machine(),AZURE_CORE_NO_COLOR:"true"},windowsHide:!0,shell:pe(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(),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 R=".eesha",rt="tasks.yml",me="settings.json",qe="workflows";var br=`**/${R}/${rt}`,ot=[`**/${R}/${qe}/**/*.yml`,`**/${R}/${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(),R)}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 x(n,e){return n!==void 0&&Object.prototype.hasOwnProperty.call(n,e)}a(x,"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(x(t.items,r))return this.explainPath(r,t.items[r],H(e).slice(1));if(x(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&&x(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(!x(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(x(t.items,r))return this.walk(t.items,r,H(e).slice(1));if(x(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&&x(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(!x(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"||!x(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,R),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 [object Object] 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",xe={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 specs icon on the left strip and the /sdd pages."},dt=["docDiff","hideCopilotPremiumRequests","handover"];function ft(){return Object.fromEntries(Object.keys(xe).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,R)}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?Re(c.variables,r):void 0,u?.variables!==void 0&&o?Re(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=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=gt(n.features,e)),r}a(pn,"parseDeclared");function gt(n,e){let t=T(n,"features",e),r=Object.keys(xe),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 Re(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(Re,"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(vn,"doctorReport");function An(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(An,"doctorLine");var Rn=7420,D={default:16,min:11,max:24};function xn(n){return typeof n=="number"&&Number.isInteger(n)&&n>=D.min&&n<=D.max}a(xn,"isFontSize");var At=["dark","light","system"];function ae(n=m("settings.json")){return Oe(A(n))}a(ae,"readServerSettings");function Oe(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&&(At.includes(r.theme)?s=r.theme:e.push('eesha.theme must be "dark", "light" or "system" - using dark.'));let i=D.default;r.fontSize!==void 0&&(xn(r.fontSize)?i=r.fontSize:e.push(`eesha.fontSize must be a whole number from ${D.min} to ${D.max} - using ${D.default}.`));let c=Rt(r.runtimes,e);return{port:o,theme:s,fontSize:i,runtimes:c,problems:e}}a(Oe,"serverSettingsFrom");function Rt(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(Rt,"runtimeToolsFrom");function K(){return m("settings.json")}a(K,"settingsFile");function xt(){try{return En.readFileSync(K(),"utf8")}catch{return""}}a(xt,"fileText");function Et(n){return se(void 0,{profileDir:O(),...n!==void 0?{readFile:a(async e=>e===K()?n:void 0,"readFile")}:{}})}a(Et,"load");async function $t(n){let e;try{e=J(n,K())}catch(r){return r.message}let t=Oe(e??{});if(t.problems.length)return t.problems.map(r=>r.replace(/ - using .*$/,".")).join(" ");try{await Et(n)}catch(r){return r.message}}a($t,"checkSettingsText");async function $n(n){let e;try{e=J(xt(),K())??{}}catch(r){return{problem:`${r.message} Fix settings.json first.`}}let t=n(e);return t?{problem:t}:Ot(JSON.stringify(e,void 0,2)+`
6
+ `)}a($n,"editSettingsJson");async function Ot(n){if(typeof n!="string")return{problem:"Send the file's text."};let e=await $t(n);return e?{problem:e}:(M(K(),n),{ok:!0})}a(Ot,"saveSettingsText");var Ct=["off","read","write"],Ce=["ado","github"],Te=["workitems","queries","repos","pulls","builds","releases","wiki","testplans"],Pe=["repos","files","pulls","issues","actions","releases","discussions","projects"],Tt=new Set(["ado.queries","ado.repos","ado.wiki","ado.testplans","github.repos","github.files","github.discussions","github.projects"]);function Pt(n,e,t){return t!=="write"||!Tt.has(`${n}.${e}`)}a(Pt,"accessAllowed");var jt=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/,_t=/^[^/\\:*?"<>|#%&+]{1,64}$/,It=/^[A-Za-z0-9-]{1,39}(\/[A-Za-z0-9._-]{1,100})?$/;function Dt(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"?Te:Pe,s={};for(let c of o){let u=r[c]??"off";if(!Ct.includes(u))return{problem:`${c} must be off, read or write.`};if(!Pt(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"||!jt.test(f)||typeof d!="string"||!_t.test(d.trim()))return{problem:"Each ADO entry is an organization and a project, like contoso and Web."};c.some(l=>F(l.org,f)&&F(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"||!It.test(c.trim()))return{problem:"Each GitHub entry is an owner, like octocat, or a repo, like octocat/hello."};i.some(u=>F(u,c.trim()))||i.push(c.trim())}return{config:{reach:i,sources:s}}}a(Dt,"checkConnector");function Ft(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 Ce){let s=t[o];if(s===void 0)continue;let i=Dt(o,s);"config"in i&&(r[o]=i.config)}return r}a(Ft,"connectorsFrom");function On(n=m("settings.json")){return Ft(A(n))}a(On,"readConnectors");function je(n,e){return $n(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(je,"saveConnector");function F(n,e){return n.localeCompare(e,void 0,{sensitivity:"accent"})===0}a(F,"sameText");var _n=p(require("http")),In=p(require("readline"));var _e=p(require("crypto")),Cn=p(require("fs"));var ce="x-eesha-key";function P(n=m("key")){try{let t=Cn.readFileSync(n,"utf8").trim();if(/^[0-9a-f]{48}$/.test(t))return t}catch{}let e=_e.randomBytes(24).toString("hex");return M(n,e+`
7
+ `),e}a(P,"ensureKey");var Tn=p(require("fs"));function Pn(){return m("server.json")}a(Pn,"serverFilePath");function U(){let n=A(Pn());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 Ie(n){let e=U();(n===void 0||e?.pid===n)&&Tn.rmSync(Pn(),{force:!0})}a(Ie,"removeServerFile");var De=p(require("path"));function Nt(){return A(De.join(__dirname,"..","package.json"))??A(De.join(__dirname,"..","..","package.json"))}a(Nt,"packageJson");function ue(){let n=Nt();return typeof n?.version=="string"?n.version:"unknown"}a(ue,"packageVersion");var Lt="eesha-connectors",Mt=30*6e4,Gt=3e4;function jn(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=_n.request({host:"127.0.0.1",port:r.port,method:"POST",path:n,headers:{[ce]: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(jn,"post");function Dn(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:Lt,version:ue()}});case"ping":return t(i,{});case"tools/list":try{let d=await jn("/control/connectors/tools",{chat:n},Gt);return t(i,{tools:d.tools})}catch(d){return r(i,-32603,d.message)}case"tools/call":try{let d=await jn("/control/connectors/call",{chat:n,name:u?.name,arguments:u?.arguments??{}},Mt);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=In.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(Dn,"runMcpBridge");var Nn=require("child_process"),N=p(require("fs")),S=p(require("path"));var Bt=64*1024*1024,Ht=2*6e4,As=10*6e4,Rs=2*1024*1024;var Fe=class extends Error{static{a(this,"GitError")}};function Ln(n,e,t={}){return new Promise((r,o)=>{(0,Nn.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:Bt,timeout:t.timeout??Ht,encoding:t.raw?"buffer":"utf8"},(s,i,c)=>{if(s){let u=String(c||i||"").trim();o(new Fe(u||s.message));return}r(i)})})}a(Ln,"git");async function Fn(n){try{return S.resolve((await Ln(n,["rev-parse","--show-toplevel"],{})).trim())}catch{return}}a(Fn,"topOf");function Ut(n){let e=S.resolve(n);return process.platform==="win32"?e.toLowerCase():e}a(Ut,"sameKey");async function Mn(n){let e=[],t=new Set,r=a(o=>{let s=Ut(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 Fn(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 Fn(u);f&&r(f)}}return e}a(Mn,"findRepos");async function Gn(n){try{return(await Ln(n.root,["config","--get-regexp","^remote\\..*\\.url$"],{})).split(/\r?\n/).map(t=>t.trim().split(/\s+/)[1]).filter(t=>!!t)}catch{return[]}}a(Gn,"repoRemoteUrls");function V(n){try{return decodeURIComponent(n)}catch{return n}}a(V,"decode");function Vt(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(Vt,"parseRemote");async function Bn(n){let e=[],t=[];for(let r of await Mn(n))for(let o of await Gn(r)){let s=Vt(o);if(s?.kind==="ado"&&!e.some(i=>F(i.org,s.org)&&F(i.project,s.project))&&e.push({org:s.org,project:s.project}),s?.kind==="github"){let i=`${s.owner}/${s.repo}`;t.some(c=>F(c,i))||t.push(i)}}return{ado:e,github:t}}a(Bn,"remotesOf");var Hn=`Eesha Code - a session with AI coding agents in a browser tab.
9
+
10
+ eesha start [--no-open] Start the server in the background and open the page.
11
+ eesha stop Stop the server. A turn still running is stopped.
12
+ eesha status Say whether the server runs, and print its link.
13
+ eesha open Open the page in the browser.
14
+ eesha run Run the server in this terminal. Ctrl+C stops it.
15
+ eesha doctor Say which runtimes' programs are on this machine.
16
+ eesha connect ado Sign in to Azure DevOps through az, and connect it.
17
+ eesha connect github Sign in to GitHub through gh, and connect it.
18
+ eesha --version Print the version.
19
+
20
+ Files: ${O()}
21
+ Settings: ${m("settings.json")} - "eesha": { "port": 7420, "theme": "dark", "fontSize": 16 }`;function de(){return m("logs","server-output.txt")}a(de,"outputFile");function q(n,e){return`http://127.0.0.1:${n}/?key=${e}`}a(q,"link");function Vn(n,e,t,r){return new Promise((o,s)=>{let i=Un.request({host:"127.0.0.1",port:n,method:t,path:r,headers:{[ce]: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(Vn,"control");async function fe(n){let e=U();if(e)try{return await Vn(e.port,n,"GET","/control/status")}catch{Ne(e.pid)||Ie(e.pid);return}}a(fe,"running");function Ne(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}a(Ne,"alive");function zn(n){return new Promise(e=>setTimeout(e,n))}a(zn,"wait");function Le(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(Le,"openInBrowser");function Me(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(Me,"printRunning");async function zt(n){let e=P(),t=await fe(e);if(t)return console.log("Already running."),Me(t,e),n&&Le(q(t.port,e)),0;let r=ae();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(An((await $e()).checks))),v.mkdirSync(Z.dirname(de()),{recursive:!0});let o=v.openSync(de(),"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 zn(200),i!==void 0){console.error(`Eesha Code did not start (exit ${i}).`);let f=v.existsSync(de())?v.readFileSync(de(),"utf8").trim():"";return f&&console.error(f),console.error(`More in ${m("logs")}.`),1}let u=await fe(e);if(u)return Me(u,e),n&&Le(q(u.port,e)),0}return console.error(`Eesha Code started but does not answer. See ${m("logs")}.`),1}a(zt,"start");async function Wt(){let n=P(),e=U();if(!e)return console.log("Not running."),0;try{await Vn(e.port,n,"POST","/control/stop")}catch{}for(let t=0;t<50&&Ne(e.pid);t++)await zn(200);if(Ne(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 Ie(e.pid),console.log("Stopped."),0}a(Wt,"stop");async function Jt(){let n=P(),e=await fe(n);return e?(Me(e,n),0):(console.log("Not running. Start it with: eesha start"),1)}a(Jt,"status");async function Kt(){let n=P(),e=await fe(n);return e?(Le(q(e.port,n)),0):(console.log("Not running. Start it with: eesha start"),1)}a(Kt,"openPage");function qt(){let n=P(),e=ae();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 Yt(n){if(!Ce.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 ge(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 ze(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(On()[e])return console.log("Connected already. Change what is in reach and allowed on the Connectors page."),0;let r=await Bn([process.cwd()]),o=e==="ado"?await je("ado",{reach:r.ado,sources:Object.fromEntries(Te.map(i=>[i,"read"]))}):await je("github",{reach:r.github,sources:Object.fromEntries(Pe.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(Yt,"connect");async function Zt(){let[n,...e]=process.argv.slice(2);switch(n){case"start":return zt(!e.includes("--no-open"));case"stop":return Wt();case"status":return Jt();case"open":return Kt();case"run":return qt();case"doctor":{let t=await $e();return console.log(vn(t)),t.checks.some(r=>r.found)?0:1}case"connect":return Yt(e[0]);case"mcp":{let t=e.indexOf("--chat"),r=t>=0?e[t+1]:void 0;return r?Dn(r):(console.error("Eesha Code mcp --chat <id> is started by a runtime for the connector tools."),2)}case"--version":case"-v":case"version":return console.log(ue()),0;case void 0:case"help":case"--help":case"-h":return console.log(Hn),0;default:return console.error(`Unknown command: ${n}
22
+ `),console.error(Hn),2}}a(Zt,"main");Zt().then(n=>process.exit(n),n=>{console.error(n.message),process.exit(1)});
23
+ //# sourceMappingURL=cli.js.map