@kodax-ai/kodax 0.7.82 → 0.7.84

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 (63) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +20 -0
  3. package/README_CN.md +10 -0
  4. package/dist/chunks/{agent-4UTCCMD5.js → agent-VMXNVYRK.js} +1 -1
  5. package/dist/chunks/argument-completer-QCS6GUAE.js +2 -0
  6. package/dist/chunks/{chunk-WMYCNECP.js → chunk-4ZI2CPUQ.js} +142 -67
  7. package/dist/chunks/{chunk-7ZN2MLVM.js → chunk-726WJGGY.js} +1 -1
  8. package/dist/chunks/{chunk-S6JTWDN6.js → chunk-A7L7XTUH.js} +1 -1
  9. package/dist/chunks/{chunk-XTCDCU2Q.js → chunk-BBBS644N.js} +4 -4
  10. package/dist/chunks/{chunk-JDZFNWMZ.js → chunk-ET2BMEQQ.js} +2 -2
  11. package/dist/chunks/{chunk-ZOBNDWOA.js → chunk-F44YYR6Z.js} +1 -1
  12. package/dist/chunks/{chunk-GIVYTXQW.js → chunk-GRLC3N46.js} +155 -155
  13. package/dist/chunks/{chunk-VQBJMNFD.js → chunk-OHZFGQEH.js} +2 -2
  14. package/dist/chunks/{chunk-ZZUIO5KL.js → chunk-TDJS5SFS.js} +1 -1
  15. package/dist/chunks/{chunk-NINELPXH.js → chunk-WTYAZOWO.js} +1 -1
  16. package/dist/chunks/chunk-WXHHZZRJ.js +379 -0
  17. package/dist/chunks/{chunk-KH2HED37.js → chunk-ZVPTDYDI.js} +2 -2
  18. package/dist/chunks/{compaction-config-IDL5JQVI.js → compaction-config-QTMFP7AF.js} +1 -1
  19. package/dist/chunks/{construction-bootstrap-STYUR6XA.js → construction-bootstrap-EVQ6VWSX.js} +1 -1
  20. package/dist/chunks/{dist-RKBHBUHV.js → dist-XRH6CRLL.js} +1 -1
  21. package/dist/chunks/{host-RF2IX3N6.js → host-F4TPD6WY.js} +1 -1
  22. package/dist/chunks/{run-manager-WE2KPAKZ.js → run-manager-PYD46OGY.js} +1 -1
  23. package/dist/chunks/{utils-Z2RSAENX.js → utils-TOTTXU2I.js} +1 -1
  24. package/dist/index.d.ts +13 -13
  25. package/dist/index.js +5 -5
  26. package/dist/kodax_bootstrap.js +1 -1
  27. package/dist/kodax_cli.js +1716 -1292
  28. package/dist/kodax_resume.js +140 -65
  29. package/dist/runtime-worker.js +1567 -1143
  30. package/dist/sandbox-workspace-session.js +121 -46
  31. package/dist/sdk-a2a.d.ts +8 -8
  32. package/dist/sdk-a2a.js +5 -5
  33. package/dist/sdk-agent.d.ts +16 -9
  34. package/dist/sdk-agent.js +1 -1
  35. package/dist/sdk-coding.d.ts +13 -13
  36. package/dist/sdk-coding.js +1 -1
  37. package/dist/sdk-mcp.js +1 -1
  38. package/dist/sdk-repl.d.ts +11 -11
  39. package/dist/sdk-repl.js +1 -1
  40. package/dist/sdk-runtime.d.ts +55 -10
  41. package/dist/sdk-runtime.js +1 -1
  42. package/dist/sdk-sandbox.js +1 -1
  43. package/dist/sdk-session.d.ts +4 -4
  44. package/dist/sdk-session.js +1 -1
  45. package/dist/sdk-skills.js +1 -1
  46. package/dist/semantic-worker.js +120 -45
  47. package/dist/types-chunks/{bash-prefix-extractor.d-CJM7OY-L.d.ts → bash-prefix-extractor.d-CkdGL4rM.d.ts} +1 -1
  48. package/dist/types-chunks/{capsule.d-B7yoH4dM.d.ts → capsule.d-7wQ_kM1C.d.ts} +1 -1
  49. package/dist/types-chunks/{controller.d-CYNuR2n9.d.ts → controller.d-CesRxFL5.d.ts} +2 -0
  50. package/dist/types-chunks/{guardrail.d-fM3mn4Op.d.ts → guardrail.d-KaIeVree.d.ts} +2 -2
  51. package/dist/types-chunks/{history-retrieval.d-BDI-ZMvY.d.ts → history-retrieval.d-CbCls7r0.d.ts} +1 -1
  52. package/dist/types-chunks/{public-api.d-i10kvYFs.d.ts → public-api.d-DpRj8b7d.d.ts} +2 -2
  53. package/dist/types-chunks/{repl.d-Cs3eqGVT.d.ts → repl.d-DWeC3PLW.d.ts} +5 -5
  54. package/dist/types-chunks/{run-manager.d-CodHf6rw.d.ts → run-manager.d-BXBkLT0A.d.ts} +1 -1
  55. package/dist/types-chunks/{sdk-session-CRXu5xNs.d.ts → sdk-session-DEtS6u20.d.ts} +2 -2
  56. package/dist/types-chunks/{shell-command-sets.d-DfeSUjjM.d.ts → shell-command-sets.d-P2h4_KKL.d.ts} +1 -1
  57. package/dist/types-chunks/{types.d-DKs4tfSd.d.ts → types.d-0m3PS7Ng.d.ts} +2 -2
  58. package/dist/types-chunks/{types.d-DIXZFauU.d.ts → types.d-CUtMr2IG.d.ts} +1 -1
  59. package/dist/types-chunks/{utils.d-CgITiLyc.d.ts → utils.d-C-eSIZ9n.d.ts} +4 -4
  60. package/docs/SDK_EMBEDDER_GUIDE.md +52 -8
  61. package/package.json +2 -1
  62. package/dist/chunks/argument-completer-N7ORRJBS.js +0 -2
  63. package/dist/chunks/chunk-PGTU7JQX.js +0 -30
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{A as Be,C as cs,D as ds,E as us,F as Zn,I as Vo,K as fs,O as ms,Q as Yo,Y as Se,ba as ps,c as ts,d as rs,da as gs,ea as ws,f as ss,fa as hs,h as Yn,i as Jn,m as is,n as as,y as ls}from"./chunk-VQBJMNFD.js";import{a as ys}from"./chunk-7ZN2MLVM.js";import{Ba as Xn,Ga as po,Ha as Vn,ea as He,sb as Qr,ta as mo,tb as es,xb as os,ya as Xo,za as be,zb as ns}from"./chunk-ZOBNDWOA.js";import{Ta as Jr,Ua as Zr,Z as Gr}from"./chunk-ZZUIO5KL.js";import{i as Ko}from"./chunk-NINELPXH.js";import{A as Yr,D as ke,J as Fe,m as Go,n as qo,o as je,q as uo,r as zo,s as qr,t as zr,v as Xr,w as zn,x as Vr,y as fo}from"./chunk-KH2HED37.js";import{$b as qn,Gb as jr,Ib as Fr,Jb as Hr,Mb as Gn,Na as Ho,S as Ur,Tc as Kr,Vc as ne,ac as Bo,dc as Br}from"./chunk-GIVYTXQW.js";import{C as Sr,Pa as Hn,Qa as Oe,Ra as Ne,ka as co,ma as jn,ya as Fn}from"./chunk-TRNAWSXP.js";import{Ac as Or,Fa as xr,Ga as Ar,Ha as Bn,Od as Dr,id as Ue,jd as Nr,nd as Kn,xd as Fo}from"./chunk-WMYCNECP.js";import{$a as ve,J as Ir,K as Tr,L as Pr,X as Uo,Z as jo,_ as Lr,a as Do,aa as Mr,ab as De,d as K,fb as _r,g as ue,h as _,i as oe,j as $r,lb as Wr,s as Rr,t as Er,y as Cr}from"./chunk-EVXIJPZ6.js";import{a as i}from"./chunk-ONUPGMER.js";import*as _n from"fs";import*as Wo from"path";import*as Tn from"fs";import In from"path";import s from"chalk";var Jo=["plan","accept-edits","auto","auto-in-project"];function _a(e){return e==="auto"||e==="auto-in-project"}i(_a,"isAutoMode");function zf(e,o){return _a(e)&&o==="llm"}i(zf,"isAutoLlmMode");function Wa(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}i(Wa,"permissionModeDisplayName");var Oa='[deprecated] permissionMode "auto-in-project" is now an alias for "auto" (FEATURE_092, v0.7.33). The alias will be removed in v0.7.38 \u2014 please update ~/.kodax/config.json to use "auto".';function Xf(e=o=>{K({source:"repl:permission",level:"warn",message:o})}){let o=!1;return()=>{o||(o=!0,e(Oa))}}i(Xf,"createAutoInProjectDeprecationEmitter");function Zo(e){switch(e){case"plan":return new Set(["bash","write","edit","undo"]);case"accept-edits":return new Set(["bash"]);case"auto":case"auto-in-project":return new Set}}i(Zo,"computeConfirmTools");function ks(e){return e!==void 0&&Jo.includes(e)}i(ks,"isPermissionMode");function go(e,o){return ks(e)?e:o}i(go,"normalizePermissionMode");import{createHash as Na,randomUUID as Da}from"node:crypto";import Ke from"node:fs";import bs from"node:path";var ho=class extends Error{static{i(this,"ProviderSetupConfigConflictError")}constructor(o){super(`KodaX configuration changed while setup was open: ${o}. Re-run \`kodax setup\`.`),this.name="ProviderSetupConfigConflictError"}},Ge=class extends Error{static{i(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Es=/^[A-Za-z_][A-Za-z0-9_]*$/,Ua=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function qe(){return Object.entries(co).filter(([,e])=>e.capabilityProfile.transport!=="cli-bridge").map(([e,o])=>({name:e,apiKeyEnv:o.apiKeyEnv,defaultModel:o.model,models:[...new Set(o.models?[o.model,...o.models.map(n=>n.id)]:[o.model])]})).sort((e,o)=>e.name===jn?-1:o.name===jn?1:e.name.localeCompare(o.name))}i(qe,"getProviderSetupCatalog");function Cs(e={}){let o=e.configPath??_("config.json"),n=e.catalog??qe(),t=e.environment??process.env,r=Qn(o);if(!r.config)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:r.error??"config.json is not a JSON object."};let a=Ps(r.config);if(a)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:a};let l=xs(e.explicitProvider);if(l){let d=Rs(r.config,l,n);return d&&(!d.requiresCredential||As(t,d.apiKeyEnv))?Ss(o,r.revision,l):$s(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=xs(r.config.provider);if(c){let d=Rs(r.config,c,n);return d?!d.requiresCredential||As(t,d.apiKeyEnv)?Ss(o,r.revision,c):$s(o,r.revision,c,d.apiKeyEnv):{status:"invalid-config",configPath:o,configRevision:r.revision,reason:`provider "${c}" is not a valid built-in or custom provider.`}}return{status:"needs-provider",configPath:o,configRevision:r.revision}}i(Cs,"inspectProviderSetupReadiness");function Is(e){let o=e.configPath??_("config.json"),n=e.catalog??qe();try{return ss(o,()=>{let t=Qn(o);if(!t.config)throw new Ge(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new ho(o);ja(t.config,o);let r=Ha(e.choice,n,t.config),a={...t.config,provider:r.provider,model:r.model,...r.customProviders?{customProviders:r.customProviders}:{}};if(Qn(o).revision!==e.expectedRevision)throw new ho(o);return Ba(o,a),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof rs?new ho(o):t}}i(Is,"persistProviderSetupChoice");function Ts(e){let n=(e.platform??process.platform)==="win32"?`Required next step: use this provider's API key as the value of the user environment variable "${e.apiKeyEnv}" in Windows Environment Variables.`:`Required next step: use this provider's API key as the value of the environment variable "${e.apiKeyEnv}" in your shell profile.`;return[`config.json stores the environment-variable name only: "${e.apiKeyEnv}"; it never stores the API key.`,n,"KodaX cannot set this environment variable for you.","Close and restart this terminal so the environment is refreshed.","Then run `kodax` again.","Optional: run `kodax doctor` to verify local configuration without an LLM request."]}i(Ts,"providerSetupRestartInstructions");function Ss(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}i(Ss,"ready");function $s(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}i($s,"needsCredential");function xs(e){return typeof e=="string"&&e.trim()?e.trim():void 0}i(xs,"normalizedString");function As(e,o){return o!==void 0&&!!e[o]?.trim()}i(As,"hasEnvironmentValue");function Rs(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(co).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let a=Fa(e,o);return a?{apiKeyEnv:a.apiKeyEnv,requiresCredential:!0}:void 0}i(Rs,"resolveConfiguredProvider");function ja(e,o){let n=Ps(e);if(n)throw new Ge(o,n)}i(ja,"assertCustomProvidersPreservable");function Ps(e){let o=e.customProviders;if(o===void 0)return;if(!Array.isArray(o))return"Existing customProviders must be an array; repair it before running setup.";let n=new Set;for(let t of o){let r=et(t);if(!r)return"Existing customProviders contains an invalid entry; repair it before running setup.";let a=Ls(r.baseUrl);if(a)return`Existing customProviders entry "${r.name}" is unsafe: ${a}`;if(n.has(r.name))return`Existing customProviders contains duplicate name "${r.name}"; repair it before running setup.`;n.add(r.name)}}i(Ps,"existingCustomProvidersError");function Fa(e,o){let n=e.customProviders;if(Array.isArray(n))for(let t of n){let r=et(t);if(r?.name===o)return r}}i(Fa,"findValidCustomProvider");function et(e){if(!Ms(e))return;let{name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a}=e;if(typeof o!="string"||n!=="openai"&&n!=="anthropic"||typeof t!="string"||typeof r!="string"||typeof a!="string")return;let l={...e,name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a};try{return Fn(l),Es.test(l.apiKeyEnv)?l:void 0}catch{return}}i(et,"toValidCustomProvider");function Ha(e,o,n){if(e.kind==="builtin"){let d=o.find(u=>u.name===e.provider);if(!d||!d.models.includes(e.model))throw new Error("Choose a supported built-in provider and model.");return{provider:d.name,model:e.model,apiKeyEnv:d.apiKeyEnv}}let t=ot(e.provider);if(o.some(d=>d.name===t.name))throw new Error(`Custom provider name "${t.name}" conflicts with a built-in provider.`);let r=n.customProviders,a=Array.isArray(r)?r.flatMap(d=>{let u=et(d);return u?[u]:[]}):[],c=a.find(d=>d.name===t.name)?a.map(d=>d.name===t.name?t:d):[...a,t];return{provider:t.name,model:t.model,apiKeyEnv:t.apiKeyEnv,customProviders:c}}i(Ha,"normalizeProviderSetupChoice");function ot(e){let o={name:e.name.trim(),protocol:e.protocol,baseUrl:e.baseUrl.trim(),apiKeyEnv:e.apiKeyEnv.trim(),model:e.model.trim()},n=Ls(o.baseUrl);if(n)throw new Error(n);if(Fn(o),!Es.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}i(ot,"validateProviderSetupCustomMetadata");function Ls(e){let o;try{o=new URL(e)}catch{return"Custom provider Base URL must be a valid absolute URL."}if(o.protocol!=="https:"&&o.protocol!=="http:")return"Custom provider Base URL must use http or https.";if(o.username||o.password)return"Custom provider Base URL must not contain credentials.";let n=[...o.searchParams.keys()].find(t=>Ua.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}i(Ls,"customProviderEndpointError");function Qn(e){if(!Ke.existsSync(e))return{configPath:e,revision:wo(void 0),exists:!1,config:{}};let o;try{o=Ke.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:wo(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Ms(n)?{configPath:e,revision:wo(o),exists:!0,config:n}:{configPath:e,revision:wo(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:wo(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}i(Qn,"readConfig");function wo(e){return Na("sha256").update(e??"<missing>","utf8").digest("hex")}i(wo,"revisionFor");function Ms(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Ms,"isRecord");function Ba(e,o){let n=bs.dirname(e);Ke.mkdirSync(n,{recursive:!0});let t=bs.join(n,`.config.${process.pid}.${Da()}.tmp`);try{Ke.writeFileSync(t,`${JSON.stringify(o,null,2)}
2
+ import{A as Be,C as cs,D as ds,E as us,F as Zn,I as Vo,K as fs,O as ms,Q as Yo,Y as Se,ba as ps,c as ts,d as rs,da as gs,ea as ws,f as ss,fa as hs,h as Yn,i as Jn,m as is,n as as,y as ls}from"./chunk-OHZFGQEH.js";import{a as ys}from"./chunk-726WJGGY.js";import{Ba as Xn,Ga as po,Ha as Vn,ea as He,sb as Qr,ta as mo,tb as es,xb as os,ya as Xo,za as be,zb as ns}from"./chunk-F44YYR6Z.js";import{Ta as Jr,Ua as Zr,Z as Gr}from"./chunk-TDJS5SFS.js";import{i as Ko}from"./chunk-WTYAZOWO.js";import{A as Yr,D as ke,J as Fe,m as Go,n as qo,o as je,q as uo,r as zo,s as qr,t as zr,v as Xr,w as zn,x as Vr,y as fo}from"./chunk-ZVPTDYDI.js";import{$b as qn,Gb as jr,Ib as Fr,Jb as Hr,Mb as Gn,Na as Ho,S as Ur,Tc as Kr,Vc as ne,ac as Bo,dc as Br}from"./chunk-GRLC3N46.js";import{C as Sr,Pa as Hn,Qa as Oe,Ra as Ne,ka as co,ma as jn,ya as Fn}from"./chunk-TRNAWSXP.js";import{Bc as Or,Fa as xr,Ga as Ar,Ha as Bn,Pd as Dr,jd as Ue,kd as Nr,od as Kn,yd as Fo}from"./chunk-4ZI2CPUQ.js";import{$a as ve,J as Ir,K as Tr,L as Pr,X as Uo,Z as jo,_ as Lr,a as Do,aa as Mr,ab as De,d as K,fb as _r,g as ue,h as _,i as oe,j as $r,lb as Wr,s as Rr,t as Er,y as Cr}from"./chunk-EVXIJPZ6.js";import{a as i}from"./chunk-ONUPGMER.js";import*as _n from"fs";import*as Wo from"path";import*as Tn from"fs";import In from"path";import s from"chalk";var Jo=["plan","accept-edits","auto","auto-in-project"];function _a(e){return e==="auto"||e==="auto-in-project"}i(_a,"isAutoMode");function zf(e,o){return _a(e)&&o==="llm"}i(zf,"isAutoLlmMode");function Wa(e){switch(e){case"plan":return"Plan";case"accept-edits":return"Edits";case"auto":case"auto-in-project":return"Auto"}}i(Wa,"permissionModeDisplayName");var Oa='[deprecated] permissionMode "auto-in-project" is now an alias for "auto" (FEATURE_092, v0.7.33). The alias will be removed in v0.7.38 \u2014 please update ~/.kodax/config.json to use "auto".';function Xf(e=o=>{K({source:"repl:permission",level:"warn",message:o})}){let o=!1;return()=>{o||(o=!0,e(Oa))}}i(Xf,"createAutoInProjectDeprecationEmitter");function Zo(e){switch(e){case"plan":return new Set(["bash","write","edit","undo"]);case"accept-edits":return new Set(["bash"]);case"auto":case"auto-in-project":return new Set}}i(Zo,"computeConfirmTools");function ks(e){return e!==void 0&&Jo.includes(e)}i(ks,"isPermissionMode");function go(e,o){return ks(e)?e:o}i(go,"normalizePermissionMode");import{createHash as Na,randomUUID as Da}from"node:crypto";import Ke from"node:fs";import bs from"node:path";var ho=class extends Error{static{i(this,"ProviderSetupConfigConflictError")}constructor(o){super(`KodaX configuration changed while setup was open: ${o}. Re-run \`kodax setup\`.`),this.name="ProviderSetupConfigConflictError"}},Ge=class extends Error{static{i(this,"ProviderSetupInvalidConfigError")}constructor(o,n){super(`KodaX configuration cannot be safely updated: ${o}. ${n}`),this.name="ProviderSetupInvalidConfigError"}},Es=/^[A-Za-z_][A-Za-z0-9_]*$/,Ua=new Set(["accesskey","apikey","accesstoken","auth","authorization","bearertoken","clientsecret","credential","key","password","privatekey","refreshtoken","secret","sig","signature","token","xapikey"]);function qe(){return Object.entries(co).filter(([,e])=>e.capabilityProfile.transport!=="cli-bridge").map(([e,o])=>({name:e,apiKeyEnv:o.apiKeyEnv,defaultModel:o.model,models:[...new Set(o.models?[o.model,...o.models.map(n=>n.id)]:[o.model])]})).sort((e,o)=>e.name===jn?-1:o.name===jn?1:e.name.localeCompare(o.name))}i(qe,"getProviderSetupCatalog");function Cs(e={}){let o=e.configPath??_("config.json"),n=e.catalog??qe(),t=e.environment??process.env,r=Qn(o);if(!r.config)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:r.error??"config.json is not a JSON object."};let a=Ps(r.config);if(a)return{status:"invalid-config",configPath:o,configRevision:r.revision,reason:a};let l=xs(e.explicitProvider);if(l){let d=Rs(r.config,l,n);return d&&(!d.requiresCredential||As(t,d.apiKeyEnv))?Ss(o,r.revision,l):$s(o,r.revision,l,d?.apiKeyEnv)}if(!r.exists)return{status:"needs-provider",configPath:o,configRevision:r.revision};let c=xs(r.config.provider);if(c){let d=Rs(r.config,c,n);return d?!d.requiresCredential||As(t,d.apiKeyEnv)?Ss(o,r.revision,c):$s(o,r.revision,c,d.apiKeyEnv):{status:"invalid-config",configPath:o,configRevision:r.revision,reason:`provider "${c}" is not a valid built-in or custom provider.`}}return{status:"needs-provider",configPath:o,configRevision:r.revision}}i(Cs,"inspectProviderSetupReadiness");function Is(e){let o=e.configPath??_("config.json"),n=e.catalog??qe();try{return ss(o,()=>{let t=Qn(o);if(!t.config)throw new Ge(o,t.error??"config.json is invalid JSON.");if(t.revision!==e.expectedRevision)throw new ho(o);ja(t.config,o);let r=Ha(e.choice,n,t.config),a={...t.config,provider:r.provider,model:r.model,...r.customProviders?{customProviders:r.customProviders}:{}};if(Qn(o).revision!==e.expectedRevision)throw new ho(o);return Ba(o,a),{provider:r.provider,model:r.model,apiKeyEnv:r.apiKeyEnv,configPath:o}})}catch(t){throw t instanceof rs?new ho(o):t}}i(Is,"persistProviderSetupChoice");function Ts(e){let n=(e.platform??process.platform)==="win32"?`Required next step: use this provider's API key as the value of the user environment variable "${e.apiKeyEnv}" in Windows Environment Variables.`:`Required next step: use this provider's API key as the value of the environment variable "${e.apiKeyEnv}" in your shell profile.`;return[`config.json stores the environment-variable name only: "${e.apiKeyEnv}"; it never stores the API key.`,n,"KodaX cannot set this environment variable for you.","Close and restart this terminal so the environment is refreshed.","Then run `kodax` again.","Optional: run `kodax doctor` to verify local configuration without an LLM request."]}i(Ts,"providerSetupRestartInstructions");function Ss(e,o,n){return{status:"ready",configPath:e,configRevision:o,...n?{provider:n}:{}}}i(Ss,"ready");function $s(e,o,n,t){return{status:"needs-credential",configPath:e,configRevision:o,provider:n,...t?{apiKeyEnv:t}:{}}}i($s,"needsCredential");function xs(e){return typeof e=="string"&&e.trim()?e.trim():void 0}i(xs,"normalizedString");function As(e,o){return o!==void 0&&!!e[o]?.trim()}i(As,"hasEnvironmentValue");function Rs(e,o,n){let t=n.find(l=>l.name===o);if(t)return{apiKeyEnv:t.apiKeyEnv,requiresCredential:!0};if(Object.entries(co).find(([l])=>l===o)?.[1]?.capabilityProfile.transport==="cli-bridge")return{requiresCredential:!1};let a=Fa(e,o);return a?{apiKeyEnv:a.apiKeyEnv,requiresCredential:!0}:void 0}i(Rs,"resolveConfiguredProvider");function ja(e,o){let n=Ps(e);if(n)throw new Ge(o,n)}i(ja,"assertCustomProvidersPreservable");function Ps(e){let o=e.customProviders;if(o===void 0)return;if(!Array.isArray(o))return"Existing customProviders must be an array; repair it before running setup.";let n=new Set;for(let t of o){let r=et(t);if(!r)return"Existing customProviders contains an invalid entry; repair it before running setup.";let a=Ls(r.baseUrl);if(a)return`Existing customProviders entry "${r.name}" is unsafe: ${a}`;if(n.has(r.name))return`Existing customProviders contains duplicate name "${r.name}"; repair it before running setup.`;n.add(r.name)}}i(Ps,"existingCustomProvidersError");function Fa(e,o){let n=e.customProviders;if(Array.isArray(n))for(let t of n){let r=et(t);if(r?.name===o)return r}}i(Fa,"findValidCustomProvider");function et(e){if(!Ms(e))return;let{name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a}=e;if(typeof o!="string"||n!=="openai"&&n!=="anthropic"||typeof t!="string"||typeof r!="string"||typeof a!="string")return;let l={...e,name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a};try{return Fn(l),Es.test(l.apiKeyEnv)?l:void 0}catch{return}}i(et,"toValidCustomProvider");function Ha(e,o,n){if(e.kind==="builtin"){let d=o.find(u=>u.name===e.provider);if(!d||!d.models.includes(e.model))throw new Error("Choose a supported built-in provider and model.");return{provider:d.name,model:e.model,apiKeyEnv:d.apiKeyEnv}}let t=ot(e.provider);if(o.some(d=>d.name===t.name))throw new Error(`Custom provider name "${t.name}" conflicts with a built-in provider.`);let r=n.customProviders,a=Array.isArray(r)?r.flatMap(d=>{let u=et(d);return u?[u]:[]}):[],c=a.find(d=>d.name===t.name)?a.map(d=>d.name===t.name?t:d):[...a,t];return{provider:t.name,model:t.model,apiKeyEnv:t.apiKeyEnv,customProviders:c}}i(Ha,"normalizeProviderSetupChoice");function ot(e){let o={name:e.name.trim(),protocol:e.protocol,baseUrl:e.baseUrl.trim(),apiKeyEnv:e.apiKeyEnv.trim(),model:e.model.trim()},n=Ls(o.baseUrl);if(n)throw new Error(n);if(Fn(o),!Es.test(o.apiKeyEnv))throw new Error("Custom provider API key environment variable name is invalid.");return o}i(ot,"validateProviderSetupCustomMetadata");function Ls(e){let o;try{o=new URL(e)}catch{return"Custom provider Base URL must be a valid absolute URL."}if(o.protocol!=="https:"&&o.protocol!=="http:")return"Custom provider Base URL must use http or https.";if(o.username||o.password)return"Custom provider Base URL must not contain credentials.";let n=[...o.searchParams.keys()].find(t=>Ua.has(t.toLowerCase().replace(/[-_.]/g,"")));return n===void 0?void 0:`Custom provider Base URL must not contain credential query parameter "${n}".`}i(Ls,"customProviderEndpointError");function Qn(e){if(!Ke.existsSync(e))return{configPath:e,revision:wo(void 0),exists:!1,config:{}};let o;try{o=Ke.readFileSync(e,"utf8")}catch(n){return{configPath:e,revision:wo(void 0),exists:!0,error:n instanceof Error?n.message:"config.json cannot be read."}}try{let n=JSON.parse(o);return Ms(n)?{configPath:e,revision:wo(o),exists:!0,config:n}:{configPath:e,revision:wo(o),exists:!0,error:"config.json must contain a JSON object."}}catch(n){return{configPath:e,revision:wo(o),exists:!0,error:n instanceof Error?n.message:"config.json is invalid JSON."}}}i(Qn,"readConfig");function wo(e){return Na("sha256").update(e??"<missing>","utf8").digest("hex")}i(wo,"revisionFor");function Ms(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Ms,"isRecord");function Ba(e,o){let n=bs.dirname(e);Ke.mkdirSync(n,{recursive:!0});let t=bs.join(n,`.config.${process.pid}.${Da()}.tmp`);try{Ke.writeFileSync(t,`${JSON.stringify(o,null,2)}
3
3
  `,{encoding:"utf8",mode:384}),Ke.renameSync(t,e)}catch(r){throw Ke.rmSync(t,{force:!0}),r}}i(Ba,"writeConfigAtomically");import{existsSync as _s,mkdirSync as Ka,readFileSync as Ws,writeFileSync as Ga}from"node:fs";import ze from"node:path";var qa={core:{},mcp:{version:1,servers:{}},extensions:{version:1,paths:[]},a2a:{version:2,agents:{}}},za=["core","mcp","extensions","a2a"];function nt(e,o){return o==="core"?ze.join(e,"config.json"):ze.join(e,"integrations",`${o}.json`)}i(nt,"activePath");function Xa(e,o){return o==="core"?ze.join(e,"config.example.jsonc"):ze.join(e,"integrations",`${o}.example.jsonc`)}i(Xa,"templatePath");function Va(e){let o=e.replaceAll("\\","/");return za.flatMap(n=>[{domain:n,kind:"active",path:nt(e,n),content:`${JSON.stringify(qa[n],null,2)}
4
4
  `},{domain:n,kind:"template",path:Xa(e,n),content:ts(n).replaceAll("~/.kodax",o)}])}i(Va,"configFiles");function yo(e,o){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${o} must contain a JSON object.`);return e}i(yo,"requireRecord");function Ya(e,o){let n=yo(e,"A2A config"),t=Object.keys(n).find(a=>!["version","agents","server"].includes(a));if(t)throw new Error(`A2A config contains unknown field "${t}".`);if(n.version!==1&&n.version!==2)throw new Error("A2A config version must be 1 or 2.");let r=yo(n.agents,"A2A config agents");if(n.server!==void 0&&yo(n.server,"A2A config server"),o)o(e);else if(Object.keys(r).length>0||n.server!==void 0)throw new Error("A2A config contains active declarations that require the KodaX host validator.")}i(Ya,"validateA2ADocument");function Ja(e,o){let n=Ws(e.path,"utf8"),t;try{t=JSON.parse(n)}catch{throw new Error(`${e.domain} config is invalid JSON.`)}e.domain==="core"?yo(t,"Core config"):e.domain==="mcp"?Yn(t):e.domain==="extensions"?Jn(t):Ya(t,o)}i(Ja,"validateActiveFile");function Os(e,o){if(!_s(e.path))return{domain:e.domain,kind:e.kind,path:e.path,status:"missing"};if(e.kind==="template")return{domain:e.domain,kind:e.kind,path:e.path,status:"existing"};try{return Ja(e,o),{domain:e.domain,kind:e.kind,path:e.path,status:"existing"}}catch(n){return{domain:e.domain,kind:e.kind,path:e.path,status:"invalid",diagnostic:n instanceof Error?n.message:`${e.domain} config is invalid.`}}}i(Os,"existingFileResult");function Za(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}i(Za,"isAlreadyExists");function Qa(e,o){Ka(ze.dirname(e.path),{recursive:!0,mode:448});try{return Ga(e.path,e.content,{encoding:"utf8",flag:"wx",mode:384}),{domain:e.domain,kind:e.kind,path:e.path,status:"created"}}catch(n){if(Za(n))return Os(e,o);throw n}}i(Qa,"createIfMissing");function el(e){let o=nt(e,"core");if(_s(o))try{let n=yo(JSON.parse(Ws(o,"utf8")),"Core config"),t=is(e);t.mcp.action==="create"&&Yn({version:1,servers:n.mcpServers}),t.extensions.action==="create"&&Jn({version:1,paths:n.extensions})}catch(n){return`Legacy integration configuration is invalid: ${n instanceof Error?n.message:"Legacy integration config is invalid."}`}}i(el,"legacyIntegrationDiagnostic");function Ns(e={}){let o=ze.resolve(e.configHome??ue()),n=Va(o),t=n.map(a=>Os(a,e.validateA2A));if(t.some(a=>a.status==="invalid"))return{configHome:o,files:t};let r=el(o);if(r){let a=nt(o,"core");return t=t.map(l=>l.path===a?{...l,status:"invalid",diagnostic:r}:l),{configHome:o,files:t}}return as({configHome:o}),{configHome:o,files:n.map(a=>Qa(a,e.validateA2A))}}i(Ns,"initializeSetupConfiguration");import $e from"node:path";var Ds=[{id:"interrupt",name:"Interrupt",description:"Interrupt the current streaming response",defaultBindings:[{key:"c",ctrl:!0}],context:"global",priority:200,category:"global",configurable:!1},{id:"showHelp",name:"Toggle Help",description:"Show or hide shortcut help when the input is empty",defaultBindings:[{key:"?"}],context:"global",priority:150,category:"global",configurable:!0},{id:"toggleThinking",name:"Cycle Reasoning Effort",description:"Cycle reasoning effort for the active model: off, low \u2026 max, auto",defaultBindings:[{key:"t",ctrl:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"toggleTranscriptMode",name:"Toggle Transcript Mode",description:"Toggle transcript mode on or off",defaultBindings:[{key:"o",ctrl:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"openTranscriptSearch",name:"Search Transcript",description:"Open transcript search",defaultBindings:[{key:"f",ctrl:!0}],context:"global",priority:150,category:"navigation",configurable:!0},{id:"togglePermissionMode",name:"Cycle Permissions",description:"Cycle permission mode: plan, accept-edits, auto-in-project",defaultBindings:[{key:"tab",shift:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"toggleAgentMode",name:"Cycle Agent Mode",description:"Cycle agent mode: AMA, SA",defaultBindings:[{key:"m",meta:!0}],context:"global",priority:150,category:"mode",configurable:!0},{id:"submitInput",name:"Submit Input",description:"Submit the current input",defaultBindings:[{key:"enter"}],context:"input",priority:50,category:"global",configurable:!1},{id:"acceptCompletion",name:"Accept Completion",description:"Accept the current autocomplete suggestion",defaultBindings:[{key:"tab"}],context:"input",priority:60,category:"editing",configurable:!0},{id:"cancelInput",name:"Cancel Input",description:"Cancel or clear the current input",defaultBindings:[{key:"escape"}],context:"input",priority:70,category:"editing",configurable:!0},{id:"newline",name:"Insert Newline",description:"Insert a newline in the current input",defaultBindings:[{key:"enter",shift:!0},{key:"j",ctrl:!0}],context:"input",priority:40,category:"editing",configurable:!0},{id:"historyUp",name:"History Up",description:"Browse previous input history",defaultBindings:[{key:"up"}],context:"input",priority:30,category:"navigation",configurable:!0},{id:"historyDown",name:"History Down",description:"Browse next input history",defaultBindings:[{key:"down"}],context:"input",priority:30,category:"navigation",configurable:!0},{id:"moveLeft",name:"Move Left",description:"Move the cursor left",defaultBindings:[{key:"left"}],context:"input",priority:20,category:"navigation",configurable:!1},{id:"moveRight",name:"Move Right",description:"Move the cursor right",defaultBindings:[{key:"right"}],context:"input",priority:20,category:"navigation",configurable:!1},{id:"moveToStart",name:"Move To Start",description:"Move the cursor to the start of the line",defaultBindings:[{key:"a",ctrl:!0}],context:"input",priority:25,category:"navigation",configurable:!0},{id:"moveToEnd",name:"Move To End",description:"Move the cursor to the end of the line",defaultBindings:[{key:"e",ctrl:!0}],context:"input",priority:25,category:"navigation",configurable:!0},{id:"killLineRight",name:"Delete To End",description:"Delete from the cursor to the end of the current line",defaultBindings:[{key:"k",ctrl:!0}],context:"input",priority:25,category:"editing",configurable:!0},{id:"killLineLeft",name:"Delete To Start",description:"Delete from the start of the line to the cursor",defaultBindings:[{key:"u",ctrl:!0}],context:"input",priority:25,category:"editing",configurable:!0},{id:"deleteWordLeft",name:"Delete Word Left",description:"Delete the word before the cursor",defaultBindings:[{key:"w",ctrl:!0},{key:"backspace",meta:!0}],context:"input",priority:25,category:"editing",configurable:!0},{id:"moveLineUp",name:"Move Line Up",description:"Move to the previous visual line in multiline input",defaultBindings:[{key:"up",ctrl:!0}],context:"input",priority:20,category:"navigation",configurable:!0},{id:"moveLineDown",name:"Move Line Down",description:"Move to the next visual line in multiline input",defaultBindings:[{key:"down",ctrl:!0}],context:"input",priority:20,category:"navigation",configurable:!0},{id:"backspace",name:"Backspace",description:"Delete the previous character",defaultBindings:[{key:"backspace"}],context:"input",priority:10,category:"editing",configurable:!1},{id:"delete",name:"Delete",description:"Delete the next character",defaultBindings:[{key:"delete"}],context:"input",priority:10,category:"editing",configurable:!1}];function ol(e){let o=[];e.ctrl&&o.push("Ctrl"),e.meta&&o.push("Alt"),e.shift&&o.push("Shift");let n={tab:"Tab",escape:"Esc",enter:"Enter",backspace:"Backspace"};return o.push(n[e.key]??(e.key.length===1?e.key.toUpperCase():e.key)),o.join("+")}i(ol,"formatBinding");function tt(e){let n=Ds.find(t=>t.id===e)?.defaultBindings[0];return n?ol(n):"<unavailable>"}i(tt,"shortcut");function nl(){return Object.entries(co).filter(([,e])=>e.capabilityProfile.transport==="cli-bridge").map(([e])=>e).sort()}i(nl,"defaultCliBridges");function rt(e={}){let o=$e.resolve(e.configHome??ue()),n=e.catalog??qe(),t=e.cliBridges??nl(),r=n.map(a=>` ${a.name.padEnd(18)} ${a.apiKeyEnv} (default model: ${a.defaultModel})`);return["KodaX setup guide","","Configuration files (existing files are never overwritten by setup):",` Core: ${$e.join(o,"config.json")}`,` Annotated template: ${$e.join(o,"config.example.jsonc")}`,` MCP: ${$e.join(o,"integrations","mcp.json")}`,` Extensions: ${$e.join(o,"integrations","extensions.json")}`,` A2A: ${$e.join(o,"integrations","a2a.json")}`,` Integration templates: ${$e.join(o,"integrations","*.example.jsonc")}`," Existing active files are validated first. If one is invalid, setup reports"," it and stops without creating or overwriting any configuration file."," The annotated core template includes `sandbox.envPass` for exact command-target"," environment passthrough; setup never stores an environment-variable value.","","Built-in API providers and credential environment variables:",...r,...t.length>0?[` CLI bridges: ${t.join(", ")} (authenticate with the provider CLI; no KodaX API-key variable)`]:[],"","Set the variable named for your provider; keep the credential out of config.json:"," Custom providers: `apiKeyEnv` is the environment-variable name stored in config.json,"," never the API key value."," Put the provider's actual API key in the value of that exact environment variable."," KodaX does not set this environment variable for you."," Windows PowerShell (persistent user variable):",' [Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "<your-key>", "User")'," macOS/Linux shell profile:",' export OPENAI_API_KEY="<your-key>"'," Obtain the key from the provider console, then close and restart the terminal."," Run `kodax doctor` to verify local configuration without sending an LLM request.","","Setup commands:"," kodax setup Initialize missing files and choose a built-in or custom provider"," kodax setup --custom Configure only a custom OpenAI/Anthropic-compatible provider"," kodax setup --help Show this guide without changing files","","Sandbox containment (optional; permission decisions still work when it is unavailable):"," `kodax setup`, first-run setup, and `/setup` check sandbox readiness once."," Windows: setup can launch the one-time UAC provisioning flow; the terminal itself"," does not need to run as Administrator. Declining UAC is non-fatal."," macOS: ASRT uses Seatbelt/sandbox-exec; install ripgrep with `brew install ripgrep`."," Linux: ASRT uses bubblewrap; install bubblewrap, socat, and ripgrep with apt,"," dnf, or pacman. KodaX never invokes sudo or a package manager automatically."," Ordinary startup and tool calls do not repeat setup reminders or trigger UAC."," Inspect/activate explicitly: `kodax sandbox doctor` / `kodax sandbox setup`."," Model-issued commands filter credential-shaped variables by default. Add exact names"," such as GH_TOKEN to user-level `sandbox.envPass` only when command access is intended."," The default list is empty; NODE_OPTIONS and BASH_ENV remain blocked."," Restart KodaX (and any persistent daemon) after changing the list or host variables."," SDK: `@kodax-ai/kodax/sandbox` exposes doctor, activation, capability metadata,"," and policy-controlled command execution independent of Auto[LLM].","","CLI basics:"," kodax Enter the interactive REPL",' kodax -p "task" Run one task and exit'," kodax -r Search and resume a saved session"," kodax -c Continue the most recent non-empty session","","Inside the REPL:"," /model [provider[/model]] List or switch provider/model"," /mode [plan|accept-edits|auto] Switch permission mode"," /effort [off|auto|low|medium|high|xhigh|max] Set reasoning depth"," /agent-mode [ama|sa|toggle] Switch AMA/SA execution"," /setup --help Show this guide","","Default shortcuts:",` ${tt("toggleThinking")} Cycle reasoning effort`,` ${tt("togglePermissionMode")} Cycle permission mode`,` ${tt("toggleAgentMode")} Cycle AMA/SA`," Tab Accept completion"," Esc Cancel or clear input"].join(`
5
5
  `)}i(rt,"renderSetupGuide");import*as Us from"node:readline";import st from"chalk";async function js(e={}){let o=e.catalog??qe(),n=Cs({...e.configPath?{configPath:e.configPath}:{},catalog:o});if(n.status==="invalid-config")throw new Ge(n.configPath,n.reason);if(o.length===0)throw new Error("No built-in API providers are available for setup.");let t=e.interaction===void 0,r=e.interaction??il({input:e.input??process.stdin,output:e.output??process.stdout});try{let a=e.customOnly?"custom":await r.choose("Choose a provider. KodaX will save metadata only and will never ask for an API key.",[...o.map(u=>({value:`builtin:${u.name}`,label:`${u.name} \u2014 ${u.defaultModel} (set ${u.apiKeyEnv})`})),{value:"custom",label:"Custom OpenAI/Anthropic-compatible provider"},{value:"cancel",label:"Cancel"}]);if(!a||a==="cancel")return{status:"cancelled"};let l=a==="custom"?await rl(r):await tl(r,o,a.slice(8));if(!l)return{status:"cancelled"};let c=sl(l,o);return await r.confirm(`Save ${c}? config.json will store the environment-variable name only. You must set that variable to the provider's API key after setup. No credential value will be written.`)?{status:"configured",selection:Is({configPath:n.configPath,expectedRevision:n.configRevision,catalog:o,choice:l})}:{status:"cancelled"}}finally{t&&r.close?.()}}i(js,"runProviderSetupWizard");async function tl(e,o,n){let t=o.find(l=>l.name===n);if(!t)throw new Error(`Unknown setup provider: ${n}`);let r=[...new Set(t.models)],a=await e.choose(`Choose a model for ${t.name}.`,r.map(l=>({value:l,label:l===t.defaultModel?`${l} (default)`:l})));return a?{kind:"builtin",provider:t.name,model:a}:void 0}i(tl,"collectBuiltinChoice");async function rl(e){let o=await Qo(e,"Custom provider name (a unique local alias used by /model and config.json)");if(!o)return;let n=await e.choose("Protocol family (check the provider API documentation for OpenAI or Anthropic compatibility)",[{value:"openai",label:"OpenAI-compatible"},{value:"anthropic",label:"Anthropic-compatible"}]);if(n!=="openai"&&n!=="anthropic")return;let t=await Qo(e,"API Base URL from the provider documentation, for example https://example.com/v1");if(!t)return;let r=await Qo(e,["Environment-variable name only (for example MY_PROVIDER_API_KEY).","Do not paste an API key here.","config.json stores this name only.","After setup, set this environment variable's value to this provider's API key."].join(" "));if(!r)return;let a=await Qo(e,"Model identifier from the provider documentation, for example provider/model-name");if(a)return{kind:"custom",provider:ot({name:o,protocol:n,baseUrl:t,apiKeyEnv:r,model:a})}}i(rl,"collectCustomChoice");async function Qo(e,o){let t=(await e.text(o))?.trim();return t||void 0}i(Qo,"requiredText");function sl(e,o){if(e.kind==="custom"){let t=e.provider;return`provider=${t.name}, protocol=${t.protocol}, baseUrl=${t.baseUrl}, model=${t.model}, apiKeyEnv=${t.apiKeyEnv}`}let n=o.find(t=>t.name===e.provider);return`provider=${e.provider}, model=${e.model}, apiKeyEnv=${n?.apiKeyEnv??"<unknown>"}`}i(sl,"summarizeChoice");function il(e){let o=Us.createInterface({input:e.input,output:e.output}),n=!1;o.on("close",()=>{n=!0}),o.on("SIGINT",()=>o.close());let t=i(r=>new Promise((a,l)=>{let c=!1,d=i(f=>{c||(c=!0,o.removeListener("close",u),a(f))},"finish"),u=i(()=>d(void 0),"onClose");if(n){d(void 0);return}o.once("close",u);try{o.question(r,f=>d(f))}catch(f){o.removeListener("close",u),n?d(void 0):l(f)}}),"question");return{async choose(r,a){for(e.output.write(`
@@ -652,4 +652,4 @@ Available Skills:
652
652
  [Skill "${t}" is not user-invocable]`)),!1;console.log(s.cyan(`
653
653
  [Invoking skill: ${t}]`)),a.argumentHint&&console.log(s.dim(`Arguments: ${r||"(none)"}`)),console.log();let l=await n.loadFull(t),c={workingDirectory:process.cwd(),projectRoot:o.gitRoot??void 0,sessionId:o.sessionId,environment:{},executeDynamicContext:o.skillDynamicContext?.execute,disableDynamicContext:o.skillDynamicContext?.disable},d=await _r(l,r,c);return console.log(s.green(`Skill activated: ${t}`)),console.log(s.dim("The skill context has been prepared for the AI.")),console.log(),{invocation:{prompt:d.content,source:"skill",displayName:t,path:l.skillFilePath,disableModelInvocation:d.disableModelInvocation,userInvocable:l.userInvocable,allowedTools:l.allowedTools,context:l.context,agent:l.agent,argumentHint:l.argumentHint,model:l.model,hooks:l.hooks,skillInvocation:{name:t,path:l.skillFilePath,description:l.description,arguments:r||void 0,allowedTools:l.allowedTools,context:l.context,agent:l.agent,argumentHint:l.argumentHint,model:l.model,hookEvents:l.hooks?Object.entries(l.hooks).filter(([,u])=>Array.isArray(u)&&u.length>0).map(([u])=>u):void 0,expandedContent:d.content}}}}catch(a){return console.log(s.red(`
654
654
  [Error invoking skill: ${a instanceof Error?a.message:String(a)}]`)),!1}}i(lr,"executeSkillCommand");var Mn=class{static{i(this,"SkillCompleter")}gitRoot;constructor(o){this.gitRoot=o}canComplete(o,n){return this.parseTrigger(o.slice(0,n))!==void 0}async getCompletions(o,n){let t=this.parseTrigger(o.slice(0,n));if(!t)return[];let r=t.partial.toLowerCase();return(await this.getSkills()).filter(l=>{let c=l.name.toLowerCase();return c.includes(r)||this.fuzzyIncludes(r,c)}).map(l=>({text:`${t.invocationPrefix}${l.name}`,display:l.name,description:this.truncateDescription(l.description),type:"skill"})).sort((l,c)=>{let d=l.display.toLowerCase().startsWith(r),u=c.display.toLowerCase().startsWith(r);return d&&!u?-1:!d&&u?1:l.display.length-c.display.length})}setGitRoot(o){this.gitRoot!==o&&(this.gitRoot=o)}parseTrigger(o){let n=o.match(/(^|\s)\/skill:([^\s]*)$/);if(n)return{partial:n[2]??"",invocationPrefix:"/skill:"};let t=o.match(/(^|\s)\/([^\s]*)$/);if(t)return{partial:t[2]??"",invocationPrefix:"/"}}async getSkills(){try{let o=ve(this.gitRoot);return o.size===0&&await De(this.gitRoot),o.listUserInvocable()}catch{return[]}}fuzzyIncludes(o,n){let t=0;for(let r=0;r<n.length&&t<o.length;r+=1)n[r]===o[t]&&(t+=1);return t===o.length}truncateDescription(o,n=50){return o.length<=n?o:o.slice(0,n-3)+"..."}};import{exec as of}from"node:child_process";import*as to from"node:path";import{promisify as nf}from"node:util";var xa=nf(of);function tf(e){let o=e.slice(3);if(!o)return;let n=o.indexOf(" -> ");return(n===-1?o:o.slice(n+4)).replace(/^"(.*)"$/,"$1").trim()||void 0}i(tf,"pathFromPorcelainLine");async function Aa(e,o=10){try{let[{stdout:n},{stdout:t}]=await Promise.all([xa("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0}),xa("git status --porcelain=v1 -uall",{cwd:e,windowsHide:!0})]),r=n.trim(),a=[],l=new Set;for(let c of t.split(`
655
- `)){if(!c.trim())continue;let d=tf(c);if(!d)continue;let u=to.resolve(r,d),f=to.relative(e,u).split(to.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),a.push(f),a.length>=o))break}return a}catch{return[]}}i(Aa,"getRecentWorkingSetFiles");function ro(e){let o=e.lastIndexOf("/");if(o===-1)return-1;for(;o>0&&!/\s/.test(e[o-1]??"");)if(o=e.lastIndexOf("/",o-1),o===-1)return-1;return o}i(ro,"findCommandSlashIndex");var ur=class{static{i(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Aa){this.cwdSource=o,this.recentFilesProvider=n}canComplete(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");return!(r===-1||r>0&&!/\s/.test(t[r-1]??"")||t.slice(r+1).includes(" "))}async getCompletions(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");if(r===-1)return[];let a=t.slice(r+1),l=[],c=this.resolveCwd(),d=a.lastIndexOf("/"),u=d===-1?c:Wo.join(c,a.slice(0,d)),f=d===-1?a:a.slice(d+1);try{let b=(await this.readdir(u)).filter(S=>S.toLowerCase().startsWith(f.toLowerCase()));for(let S of b){let C=Wo.join(u,S),A=await this.isDirectory(C),v=d===-1?S:a.slice(0,d+1)+S;l.push({text:"@"+v+(A?"/":""),display:S+(A?"/":""),description:A?"directory":"file",type:"file"})}}catch{}if(d===-1){let m=await this.getRecentFiles(c),b=new Set(l.map(A=>A.text)),S=f.toLowerCase(),C=[];for(let A of m){if(f&&!Wo.basename(A).toLowerCase().startsWith(S))continue;let v="@"+A;b.has(v)||(b.add(v),C.push({text:v,display:A,description:"recent",type:"file"}))}l.unshift(...C)}return l}async getRecentFiles(o){let n=Date.now(),t=this.recentCache.get(o);if(t&&t.expiresAt>n)return t.files;let r=await this.recentFilesProvider(o);return this.recentCache.set(o,{files:r,expiresAt:Date.now()+this.cacheTimeout}),r}resolveCwd(){return typeof this.cwdSource=="function"?this.cwdSource():this.cwdSource??process.cwd()}async readdir(o){let n=Date.now(),t=this.cache.get(o);return t&&t.expiresAt>n?t.entries:(t&&this.cache.delete(o),new Promise(r=>{_n.readdir(o,(a,l)=>{a?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{_n.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},fr=class{static{i(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of _o().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=ne();for(let n of o?.listCommands()??[])n.metadata?.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]})}canComplete(o,n){let t=o.slice(0,n),r=ro(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let a=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(a,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(a,u)&&l.push({text:"/"+u,display:"/"+u,description:`Alias for /${c}: ${d.description}`,type:"command"})}return l}fuzzyMatch(o,n){if(!o)return!0;let t=o.toLowerCase(),r=n.toLowerCase(),a=0;for(let l=0;l<r.length&&a<t.length;l++)r[l]===t[a]&&a++;return a===t.length}};function Jy(e){let o=new ur(e),n=new Mn,t=new fr;return async r=>{let a=r.includes("@"),l=r.includes("/");if(!a&&!l)return[[],r];let c=[];if(l){let u=await rf(r,r.length);c.push(...u)}if(l&&n.canComplete(r,r.length)){let u=await n.getCompletions(r,r.length);c.push(...u)}if(l&&t.canComplete(r,r.length)){let u=await t.getCompletions(r,r.length);c.push(...u)}if(a&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>sf(r,u)),r]}}i(Jy,"createCompleter");async function rf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-N7ORRJBS.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}i(rf,"getArgumentCompletions");function sf(e,o){if(o.type!=="argument")return o.text;let n=ro(e);if(n!==-1&&!/\s/.test(e.slice(n)))return`${e} ${o.text}`;let r=e.match(/\S+$/)?.[0]??"";return`${r?e.slice(0,e.length-r.length):e}${o.text}`}i(sf,"formatReadlineCompletion");import{existsSync as Wn,readdirSync as Ia,readFileSync as Ta}from"node:fs";import{join as On}from"node:path";var af=[{name:"plan",description:"Read-only planning mode - blocks all modifications",type:"enum"},{name:"accept-edits",description:"File edits auto-approved, bash requires confirmation",type:"enum"},{name:"auto",description:"Use auto-mode classifier for tool permissions",type:"enum"}],so=[{name:"none",description:"Disable reasoning when the model supports it",type:"enum"},{name:"auto",description:"Clear the explicit effort override",type:"enum"},{name:"low",description:"Use low reasoning effort",type:"enum"},{name:"medium",description:"Use medium reasoning effort",type:"enum"},{name:"high",description:"Use high reasoning effort",type:"enum"},{name:"xhigh",description:"Use extra-high reasoning effort",type:"enum"},{name:"max",description:"Use maximum reasoning effort",type:"enum"}];function lf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(Oe(n))try{return Be(n).filter(a=>!t||a.toLowerCase().includes(t.toLowerCase())).map(a=>({name:`${n}/${a}`,description:a,type:"enum"}))}catch{}return[]}return Ne().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}i(lf,"getModelArgs");var mr=[{name:"workspace",description:"Inspect current workspace/runtime truth in more detail",type:"enum"},{name:"runtime",description:"Alias for workspace runtime inspection",type:"enum"},{name:"worktree",description:"Alias for workspace runtime inspection",type:"enum"}],pr=[{name:"all",description:"Delete ALL sessions",type:"enum"}],cf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],df=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],uf=[{name:"llm",description:"Use LLM classifier for auto mode",type:"enum"},{name:"rules",description:"Use rules-only auto mode",type:"enum"}],Ra=[{name:"ama",description:"Use AMA agent mode",type:"enum"},{name:"sa",description:"Use single-agent mode",type:"enum"},{name:"toggle",description:"Cycle to the next agent mode",type:"enum"}],Ea=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],ff=[{name:"list",description:"List project memory files",type:"enum"},{name:"pending",description:"List pending memory proposals",type:"enum"},{name:"show",description:"Preview a memory proposal",type:"enum"},{name:"approve",description:"Approve a memory proposal",type:"enum"},{name:"reject",description:"Reject a memory proposal",type:"enum"},{name:"curate",description:"Report memory governance findings",type:"enum"},{name:"rebuild",description:"Rebuild MEMORY.md index",type:"enum"},{name:"open",description:"Print the memory entrypoint path",type:"enum"},{name:"help",description:"Show memory help",type:"enum"}],mf=[{name:"list",description:"List learned capabilities",type:"enum"},{name:"show",description:"Inspect one exact learned capability",type:"enum"},{name:"review",description:"Start or restart bounded canary review",type:"enum"},{name:"trust",description:"Explicitly trust a reviewed revision",type:"enum"},{name:"reject",description:"Reject a learned capability",type:"enum"},{name:"disable",description:"Disable an active learned capability",type:"enum"},{name:"rollback",description:"Restore the previous good revision",type:"enum"},{name:"promote",description:"Promote an exact revision to the user Skill catalog",type:"enum"},{name:"help",description:"Show Learning Center help",type:"enum"}];function pf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?mf:n==="help"&&t<=2?[{name:"promote",description:"Show dedicated promotion help",type:"enum"}]:n!=="promote"?[]:t<=2?[{name:"--help",description:"Show dedicated promotion help",type:"enum"}]:t<=3?[{name:"--scope",description:"Choose the formal user Skill scope",type:"enum"}]:e[2]?.toLowerCase()==="--scope"&&t<=4?[{name:"user",description:"Promote to the formal user Skill catalog",type:"enum"}]:[]}i(pf,"getLearnArgs");var gf=[{name:"status",description:"Show current persistent goal",type:"enum"},{name:"pause",description:"Pause the active goal",type:"enum"},{name:"resume",description:"Resume a paused goal",type:"enum"},{name:"clear",description:"Clear the current goal",type:"enum"},{name:"help",description:"Show goal help",type:"enum"},{name:"--tokens",description:"Set an optional goal token budget",type:"enum"}],wf=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],hf=[{name:"--lean",description:"Add a minimal-diff/YAGNI review pass",type:"enum"},{name:"--workflow",description:"Review through a dynamic workflow",type:"enum"},{name:"base",description:"Review changes against the detected base branch",type:"enum"},{name:"sha",description:"Review a specific commit",type:"enum"},{name:"help",description:"Show review help",type:"enum"}],yf=[{name:"init",description:"Create AGENTS.md in the target project if absent",type:"enum"},{name:"lean",description:"Initialize or LLM-review AGENTS.md for Lean Mode guidance",type:"enum"},{name:"help",description:"Show agents help",type:"enum"}],vf=[{name:"status",description:"Inspect the current repo-intelligence runtime state",type:"enum"},{name:"mode",description:"Switch repo-intelligence runtime mode",type:"enum"},{name:"trace",description:"Toggle repo-intelligence trace output",type:"enum"}],kf=[{name:"auto",description:"Let KodaX pick the best repo-intelligence engine",type:"enum"},{name:"full",description:"Prefer the full repo-intelligence engine",type:"enum"},{name:"light",description:"Use the light repo-intelligence engine",type:"enum"},{name:"off",description:"Disable repo-intelligence injection",type:"enum"}],bf=[{name:"on",description:"Enable repo-intelligence trace output",type:"enum"},{name:"off",description:"Disable repo-intelligence trace output",type:"enum"},{name:"toggle",description:"Toggle repo-intelligence trace output",type:"enum"}],Sf=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],$f=[{name:"list",description:"List built-in and saved workflows",type:"enum"},{name:"create",description:"Generate and run a workflow from a request",type:"enum"},{name:"runs",description:"List active and recent workflow runs",type:"enum"},{name:"show",description:"Show latest run or a specific workflow run",type:"enum"},{name:"pause",description:"Pause future child launches for a run",type:"enum"},{name:"resume",description:"Resume a paused run",type:"enum"},{name:"stop",description:"Stop an active workflow run",type:"enum"},{name:"delete",description:"Delete one persisted workflow run or generated saved capsule",type:"enum"},{name:"prune",description:"Preview or delete old terminal workflow runs",type:"enum"},{name:"rerun",description:"Rerun a run id or saved workflow name",type:"enum"},{name:"save",description:"Save a generated run as a workflow capsule",type:"enum"},{name:"rename",description:"Rename a run display name or saved workflow capsule",type:"enum"},{name:"revise",description:"Generate a revised workflow capsule",type:"enum"},{name:"help",description:"Show workflow help",type:"enum"}],xf=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Af=new Set(["show","delete","rerun","save","rename","revise"]),Rf=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Ef=[{name:"--dry-run",description:"Preview cleanup without deleting runs",type:"enum"},{name:"--keep",description:"Keep the newest N terminal runs",type:"enum"},{name:"--older-than",description:"Delete terminal runs older than Nd or Nh",type:"enum"}],Cf=[{name:"--force",description:"Delete stale non-terminal run records",type:"enum"},{name:"--run",description:"Treat the target as a workflow run record",type:"enum"},{name:"--saved",description:"Treat the target as a generated saved workflow capsule",type:"enum"}],If=[".workflow.json",".ts",".mjs",".js"];function Tf(e,o){switch(e){case"pause":return o==="running";case"resume":return o==="paused";case"stop":return o==="running"||o==="paused";case"delete":return o!=="running"&&o!=="paused";default:return!0}}i(Tf,"workflowRunMatchesSubcommand");function Nn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}i(Nn,"isWorkflowRunEntryName");function Pf(e,o){let n=On(e,"workflow-metadata.json");if(Wn(n))try{let r=JSON.parse(Ta(n,"utf8"));if(typeof r=="object"&&r!==null){let a=r.displayName;if(typeof a=="string"&&Nn(a.trim()))return a.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&Nn(t.trim())?t.trim():void 0}i(Pf,"readWorkflowRunDisplayName");function Lf(){let e=Re(process.cwd()).key,o=_("workflow-runs",e);if(!Wn(o))return[];let n=[];for(let t of Ia(o)){if(!Nn(t))continue;let r=On(o,t,"run.json");if(Wn(r))try{let a=JSON.parse(Ta(r,"utf8")),l=typeof a.workflow=="string"?a.workflow:"?",c=typeof a.status=="string"?a.status:"?",d=typeof a.endedAt=="number"?a.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=Pf(On(o,t),a);u&&u!==t&&n.push({arg:{name:u,description:`${l} alias for ${t} - ${c}`,type:"string"},endedAt:d})}catch{}}return n.sort((t,r)=>r.endedAt-t.endedAt).map(t=>t.arg)}i(Lf,"getPersistedWorkflowRunIdArgs");function Dn(e){let o=Fe().list().filter(r=>Tf(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Af.has(e)?Lf():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}i(Dn,"getWorkflowRunIdArgs");function Mf(e){for(let o of If)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Nn(n)?n:void 0}}i(Mf,"savedWorkflowNameFromFile");function Oo(e={}){let o=[{path:_("workflows"),source:"personal"},{path:On(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(Wn(t.path))try{for(let r of Ia(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let a=Mf(r);a&&n.set(a,{name:a,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}i(Oo,"getSavedWorkflowNameArgs");function _f(){let e=new Map;for(let o of Dn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of Oo()){let n=e.get(o.name);if(n){e.set(o.name,{...n,description:`${n.description}; also ${o.description}`});continue}e.set(o.name,{...o,description:o.description,type:"string"})}return[...e.values()]}i(_f,"getWorkflowRerunArgs");function gr(e){let o=new Map;for(let n of Dn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of Oo({generatedOnly:e==="delete"})){let t=o.get(n.name);if(t){o.set(n.name,{...t,description:`${t.description}; also ${n.description}`});continue}o.set(n.name,{...n,description:n.description,type:"string"})}return[...o.values()]}i(gr,"getWorkflowRunOrSavedNameArgs");function Ca(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Oo({generatedOnly:!0}):o.has("--run")?Dn("delete"):gr("delete")}i(Ca,"getWorkflowDeleteTargetArgs");function Wf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...$f,...qo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Oo()];if(n==="rerun"&&t<=2)return _f();if(n==="rename"&&t<=2)return gr("rename");if(n==="delete"&&t<=2)return[...Cf,...Ca(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return Ca(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...gr("revise")];if(e[1]==="--replace"&&t<=3)return Oo()}return xf.has(n)&&t<=2?Dn(n):n==="runs"&&t<=2?Rf:n==="prune"&&t<=2?Ef:[]}i(Wf,"getWorkflowArgs");function Of(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?vf:t>2?[]:n==="mode"?kf:n==="trace"?bf:[]}i(Of,"getRepoIntelArgs");var Nf=new Map([["mode",af],["thinking",so],["think",so],["t",so],["reasoning",so],["reason",so],["effort",so],["status",mr],["info",mr],["ctx",mr],["mcp",cf],["fallback",df],["auto-engine",uf],["agent-mode",Ra],["am",Ra],["verifier-log",Ea],["stall-log",Ea],["memory",ff],["goal",gf],["paste",wf],["review",hf],["agents",yf],["delete",pr],["rm",pr],["del",pr]]),Df=new Set(["model","m","provider"]),Uf=new Set(["repo-intel"]),jf=new Set(["repointel","ri"]),Ff=new Set(["workflow"]),Hf=new Set(["learn"]);function wr(e,o,n=[]){let t=e.toLowerCase();return Df.has(t)?lf(o):Uf.has(t)?Of(n):jf.has(t)?n.length<=1?Sf:[]:Ff.has(t)?Wf(n):Hf.has(t)?pf(n):Nf.get(t)??[]}i(wr,"getCommandArguments");var hr=class{static{i(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return!1;let a=t.slice(r),l=a.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=a.slice(1).toLowerCase();return wr(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];let a=t.slice(r),l=a.indexOf(" "),c=(l===-1?a.slice(1):a.slice(1,l)).toLowerCase(),d=l===-1?"":a.slice(l+1),u=d?d.split(/\s+/):[""],f=u.length-1,m=(u[f]??"").toLowerCase(),b=wr(c,m,u);if(!b||b.length===0)return[];let S=new Set(u.slice(0,-1).map(A=>A.toLowerCase()));return b.filter(A=>!S.has(A.name.toLowerCase())).filter(A=>!m||A.name.includes("/")?!0:A.name.toLowerCase().includes(m)).map(A=>({text:A.name,display:A.name,description:A.description,type:"argument"})).sort((A,v)=>{if(!m)return 0;let x=A.display.toLowerCase().startsWith(m),M=v.display.toLowerCase().startsWith(m);return x&&!M?-1:!x&&M?1:A.display.length-v.display.length})}};function dv(){return new hr}i(dv,"createArgumentCompleter");export{pt as a,B as b,_p as c,si as d,Wp as e,Jo as f,_a as g,zf as h,Wa as i,Xf as j,Zo as k,ks as l,go as m,ho as n,Ge as o,qe as p,Cs as q,Is as r,Ts as s,Ns as t,Ds as u,rt as v,js as w,pl as x,hl as y,np as z,hp as A,yl as B,dt as C,yp as D,vp as E,Qs as F,Rp as G,ri as H,te as I,li as J,ci as K,Fp as L,_l as M,Xl as N,Hp as O,rn as P,wt as Q,Bp as R,vi as S,Kp as T,Gp as U,qp as V,hg as W,yg as X,vg as Y,Ci as Z,bt as _,Ii as $,Re as aa,Ag as ba,xo as ca,Et as da,Ie as ea,pd as fa,gd as ga,Xi as ha,Jg as ia,Zg as ja,Cd as ka,Xw as la,Vw as ma,Yw as na,gh as oa,wh as pa,hh as qa,yh as ra,vh as sa,aa as ta,Ah as ua,Rh as va,ca as wa,Eh as xa,qh as ya,da as za,_o as Aa,Oy as Ba,Ny as Ca,Mn as Da,hr as Ea,dv as Fa,ro as Ga,ur as Ha,fr as Ia,Jy as Ja};
655
+ `)){if(!c.trim())continue;let d=tf(c);if(!d)continue;let u=to.resolve(r,d),f=to.relative(e,u).split(to.sep).join("/");if(!(!f||f.startsWith("..")||l.has(f))&&(l.add(f),a.push(f),a.length>=o))break}return a}catch{return[]}}i(Aa,"getRecentWorkingSetFiles");function ro(e){let o=e.lastIndexOf("/");if(o===-1)return-1;for(;o>0&&!/\s/.test(e[o-1]??"");)if(o=e.lastIndexOf("/",o-1),o===-1)return-1;return o}i(ro,"findCommandSlashIndex");var ur=class{static{i(this,"FileCompleter")}cwdSource;cache=new Map;cacheTimeout=5e3;recentCache=new Map;recentFilesProvider;constructor(o,n=Aa){this.cwdSource=o,this.recentFilesProvider=n}canComplete(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");return!(r===-1||r>0&&!/\s/.test(t[r-1]??"")||t.slice(r+1).includes(" "))}async getCompletions(o,n){let t=o.slice(0,n),r=t.lastIndexOf("@");if(r===-1)return[];let a=t.slice(r+1),l=[],c=this.resolveCwd(),d=a.lastIndexOf("/"),u=d===-1?c:Wo.join(c,a.slice(0,d)),f=d===-1?a:a.slice(d+1);try{let b=(await this.readdir(u)).filter(S=>S.toLowerCase().startsWith(f.toLowerCase()));for(let S of b){let C=Wo.join(u,S),A=await this.isDirectory(C),v=d===-1?S:a.slice(0,d+1)+S;l.push({text:"@"+v+(A?"/":""),display:S+(A?"/":""),description:A?"directory":"file",type:"file"})}}catch{}if(d===-1){let m=await this.getRecentFiles(c),b=new Set(l.map(A=>A.text)),S=f.toLowerCase(),C=[];for(let A of m){if(f&&!Wo.basename(A).toLowerCase().startsWith(S))continue;let v="@"+A;b.has(v)||(b.add(v),C.push({text:v,display:A,description:"recent",type:"file"}))}l.unshift(...C)}return l}async getRecentFiles(o){let n=Date.now(),t=this.recentCache.get(o);if(t&&t.expiresAt>n)return t.files;let r=await this.recentFilesProvider(o);return this.recentCache.set(o,{files:r,expiresAt:Date.now()+this.cacheTimeout}),r}resolveCwd(){return typeof this.cwdSource=="function"?this.cwdSource():this.cwdSource??process.cwd()}async readdir(o){let n=Date.now(),t=this.cache.get(o);return t&&t.expiresAt>n?t.entries:(t&&this.cache.delete(o),new Promise(r=>{_n.readdir(o,(a,l)=>{a?r([]):(this.cache.set(o,{entries:l,expiresAt:Date.now()+this.cacheTimeout}),r(l))})}))}async isDirectory(o){return new Promise(n=>{_n.stat(o,(t,r)=>{n(!t&&r.isDirectory())})})}},fr=class{static{i(this,"CommandCompleter")}commands;constructor(){this.commands=new Map,this.loadCommands()}loadCommands(){for(let n of _o().getAll())n.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]});let o=ne();for(let n of o?.listCommands()??[])n.metadata?.userInvocable!==!1&&this.commands.set(n.name,{description:n.description,aliases:n.aliases??[]})}canComplete(o,n){let t=o.slice(0,n),r=ro(t);return r===-1?!1:!t.slice(r).includes(" ")}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];this.commands.clear(),this.loadCommands();let a=t.slice(r+1).toLowerCase(),l=[];for(let[c,d]of this.commands){this.fuzzyMatch(a,c)&&l.push({text:"/"+c,display:"/"+c,description:d.description,type:"command"});for(let u of d.aliases)u!==c&&this.fuzzyMatch(a,u)&&l.push({text:"/"+u,display:"/"+u,description:`Alias for /${c}: ${d.description}`,type:"command"})}return l}fuzzyMatch(o,n){if(!o)return!0;let t=o.toLowerCase(),r=n.toLowerCase(),a=0;for(let l=0;l<r.length&&a<t.length;l++)r[l]===t[a]&&a++;return a===t.length}};function Jy(e){let o=new ur(e),n=new Mn,t=new fr;return async r=>{let a=r.includes("@"),l=r.includes("/");if(!a&&!l)return[[],r];let c=[];if(l){let u=await rf(r,r.length);c.push(...u)}if(l&&n.canComplete(r,r.length)){let u=await n.getCompletions(r,r.length);c.push(...u)}if(l&&t.canComplete(r,r.length)){let u=await t.getCompletions(r,r.length);c.push(...u)}if(a&&o.canComplete(r,r.length)){let u=await o.getCompletions(r,r.length);c.push(...u)}return[c.map(u=>sf(r,u)),r]}}i(Jy,"createCompleter");async function rf(e,o){let{ArgumentCompleter:n}=await import("./argument-completer-QCS6GUAE.js"),t=new n;return t.canComplete(e,o)?t.getCompletions(e,o):[]}i(rf,"getArgumentCompletions");function sf(e,o){if(o.type!=="argument")return o.text;let n=ro(e);if(n!==-1&&!/\s/.test(e.slice(n)))return`${e} ${o.text}`;let r=e.match(/\S+$/)?.[0]??"";return`${r?e.slice(0,e.length-r.length):e}${o.text}`}i(sf,"formatReadlineCompletion");import{existsSync as Wn,readdirSync as Ia,readFileSync as Ta}from"node:fs";import{join as On}from"node:path";var af=[{name:"plan",description:"Read-only planning mode - blocks all modifications",type:"enum"},{name:"accept-edits",description:"File edits auto-approved, bash requires confirmation",type:"enum"},{name:"auto",description:"Use auto-mode classifier for tool permissions",type:"enum"}],so=[{name:"none",description:"Disable reasoning when the model supports it",type:"enum"},{name:"auto",description:"Clear the explicit effort override",type:"enum"},{name:"low",description:"Use low reasoning effort",type:"enum"},{name:"medium",description:"Use medium reasoning effort",type:"enum"},{name:"high",description:"Use high reasoning effort",type:"enum"},{name:"xhigh",description:"Use extra-high reasoning effort",type:"enum"},{name:"max",description:"Use maximum reasoning effort",type:"enum"}];function lf(e){if(e&&e.includes("/")){let o=e.indexOf("/"),n=e.slice(0,o),t=e.slice(o+1);if(Oe(n))try{return Be(n).filter(a=>!t||a.toLowerCase().includes(t.toLowerCase())).map(a=>({name:`${n}/${a}`,description:a,type:"enum"}))}catch{}return[]}return Ne().map(o=>({name:o,description:`Switch to ${o} provider`,type:"enum"}))}i(lf,"getModelArgs");var mr=[{name:"workspace",description:"Inspect current workspace/runtime truth in more detail",type:"enum"},{name:"runtime",description:"Alias for workspace runtime inspection",type:"enum"},{name:"worktree",description:"Alias for workspace runtime inspection",type:"enum"}],pr=[{name:"all",description:"Delete ALL sessions",type:"enum"}],cf=[{name:"status",description:"Show MCP server status",type:"enum"},{name:"refresh",description:"Refresh MCP server catalogs",type:"enum"}],df=[{name:"status",description:"Show child-task fallback order",type:"enum"},{name:"off",description:"Disable child-task fallback providers",type:"enum"}],uf=[{name:"llm",description:"Use LLM classifier for auto mode",type:"enum"},{name:"rules",description:"Use rules-only auto mode",type:"enum"}],Ra=[{name:"ama",description:"Use AMA agent mode",type:"enum"},{name:"sa",description:"Use single-agent mode",type:"enum"},{name:"toggle",description:"Cycle to the next agent mode",type:"enum"}],Ea=[{name:"on",description:"Enable logging",type:"enum"},{name:"off",description:"Disable logging",type:"enum"}],ff=[{name:"list",description:"List project memory files",type:"enum"},{name:"pending",description:"List pending memory proposals",type:"enum"},{name:"show",description:"Preview a memory proposal",type:"enum"},{name:"approve",description:"Approve a memory proposal",type:"enum"},{name:"reject",description:"Reject a memory proposal",type:"enum"},{name:"curate",description:"Report memory governance findings",type:"enum"},{name:"rebuild",description:"Rebuild MEMORY.md index",type:"enum"},{name:"open",description:"Print the memory entrypoint path",type:"enum"},{name:"help",description:"Show memory help",type:"enum"}],mf=[{name:"list",description:"List learned capabilities",type:"enum"},{name:"show",description:"Inspect one exact learned capability",type:"enum"},{name:"review",description:"Start or restart bounded canary review",type:"enum"},{name:"trust",description:"Explicitly trust a reviewed revision",type:"enum"},{name:"reject",description:"Reject a learned capability",type:"enum"},{name:"disable",description:"Disable an active learned capability",type:"enum"},{name:"rollback",description:"Restore the previous good revision",type:"enum"},{name:"promote",description:"Promote an exact revision to the user Skill catalog",type:"enum"},{name:"help",description:"Show Learning Center help",type:"enum"}];function pf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?mf:n==="help"&&t<=2?[{name:"promote",description:"Show dedicated promotion help",type:"enum"}]:n!=="promote"?[]:t<=2?[{name:"--help",description:"Show dedicated promotion help",type:"enum"}]:t<=3?[{name:"--scope",description:"Choose the formal user Skill scope",type:"enum"}]:e[2]?.toLowerCase()==="--scope"&&t<=4?[{name:"user",description:"Promote to the formal user Skill catalog",type:"enum"}]:[]}i(pf,"getLearnArgs");var gf=[{name:"status",description:"Show current persistent goal",type:"enum"},{name:"pause",description:"Pause the active goal",type:"enum"},{name:"resume",description:"Resume a paused goal",type:"enum"},{name:"clear",description:"Clear the current goal",type:"enum"},{name:"help",description:"Show goal help",type:"enum"},{name:"--tokens",description:"Set an optional goal token budget",type:"enum"}],wf=[{name:"show",description:"Show a captured paste by id",type:"enum"},{name:"list",description:"List captured pastes",type:"enum"}],hf=[{name:"--lean",description:"Add a minimal-diff/YAGNI review pass",type:"enum"},{name:"--workflow",description:"Review through a dynamic workflow",type:"enum"},{name:"base",description:"Review changes against the detected base branch",type:"enum"},{name:"sha",description:"Review a specific commit",type:"enum"},{name:"help",description:"Show review help",type:"enum"}],yf=[{name:"init",description:"Create AGENTS.md in the target project if absent",type:"enum"},{name:"lean",description:"Initialize or LLM-review AGENTS.md for Lean Mode guidance",type:"enum"},{name:"help",description:"Show agents help",type:"enum"}],vf=[{name:"status",description:"Inspect the current repo-intelligence runtime state",type:"enum"},{name:"mode",description:"Switch repo-intelligence runtime mode",type:"enum"},{name:"trace",description:"Toggle repo-intelligence trace output",type:"enum"}],kf=[{name:"auto",description:"Let KodaX pick the best repo-intelligence engine",type:"enum"},{name:"full",description:"Prefer the full repo-intelligence engine",type:"enum"},{name:"light",description:"Use the light repo-intelligence engine",type:"enum"},{name:"off",description:"Disable repo-intelligence injection",type:"enum"}],bf=[{name:"on",description:"Enable repo-intelligence trace output",type:"enum"},{name:"off",description:"Disable repo-intelligence trace output",type:"enum"},{name:"toggle",description:"Toggle repo-intelligence trace output",type:"enum"}],Sf=[{name:"status",description:"Deprecated alias for /repo-intel status",type:"enum"}],$f=[{name:"list",description:"List built-in and saved workflows",type:"enum"},{name:"create",description:"Generate and run a workflow from a request",type:"enum"},{name:"runs",description:"List active and recent workflow runs",type:"enum"},{name:"show",description:"Show latest run or a specific workflow run",type:"enum"},{name:"pause",description:"Pause future child launches for a run",type:"enum"},{name:"resume",description:"Resume a paused run",type:"enum"},{name:"stop",description:"Stop an active workflow run",type:"enum"},{name:"delete",description:"Delete one persisted workflow run or generated saved capsule",type:"enum"},{name:"prune",description:"Preview or delete old terminal workflow runs",type:"enum"},{name:"rerun",description:"Rerun a run id or saved workflow name",type:"enum"},{name:"save",description:"Save a generated run as a workflow capsule",type:"enum"},{name:"rename",description:"Rename a run display name or saved workflow capsule",type:"enum"},{name:"revise",description:"Generate a revised workflow capsule",type:"enum"},{name:"help",description:"Show workflow help",type:"enum"}],xf=new Set(["show","pause","resume","stop","delete","rerun","save","rename","revise"]),Af=new Set(["show","delete","rerun","save","rename","revise"]),Rf=[{name:"--all",description:"Show all persisted workflow runs",type:"enum"},{name:"--limit",description:"Show at most N persisted workflow runs",type:"enum"}],Ef=[{name:"--dry-run",description:"Preview cleanup without deleting runs",type:"enum"},{name:"--keep",description:"Keep the newest N terminal runs",type:"enum"},{name:"--older-than",description:"Delete terminal runs older than Nd or Nh",type:"enum"}],Cf=[{name:"--force",description:"Delete stale non-terminal run records",type:"enum"},{name:"--run",description:"Treat the target as a workflow run record",type:"enum"},{name:"--saved",description:"Treat the target as a generated saved workflow capsule",type:"enum"}],If=[".workflow.json",".ts",".mjs",".js"];function Tf(e,o){switch(e){case"pause":return o==="running";case"resume":return o==="paused";case"stop":return o==="running"||o==="paused";case"delete":return o!=="running"&&o!=="paused";default:return!0}}i(Tf,"workflowRunMatchesSubcommand");function Nn(e){return/^[a-zA-Z0-9._-]{1,120}$/.test(e)&&!e.startsWith(".")&&!e.includes("..")}i(Nn,"isWorkflowRunEntryName");function Pf(e,o){let n=On(e,"workflow-metadata.json");if(Wn(n))try{let r=JSON.parse(Ta(n,"utf8"));if(typeof r=="object"&&r!==null){let a=r.displayName;if(typeof a=="string"&&Nn(a.trim()))return a.trim()}}catch{}let t=o.displayName;return typeof t=="string"&&Nn(t.trim())?t.trim():void 0}i(Pf,"readWorkflowRunDisplayName");function Lf(){let e=Re(process.cwd()).key,o=_("workflow-runs",e);if(!Wn(o))return[];let n=[];for(let t of Ia(o)){if(!Nn(t))continue;let r=On(o,t,"run.json");if(Wn(r))try{let a=JSON.parse(Ta(r,"utf8")),l=typeof a.workflow=="string"?a.workflow:"?",c=typeof a.status=="string"?a.status:"?",d=typeof a.endedAt=="number"?a.endedAt:0;n.push({arg:{name:t,description:`${l} - ${c}`,type:"string"},endedAt:d});let u=Pf(On(o,t),a);u&&u!==t&&n.push({arg:{name:u,description:`${l} alias for ${t} - ${c}`,type:"string"},endedAt:d})}catch{}}return n.sort((t,r)=>r.endedAt-t.endedAt).map(t=>t.arg)}i(Lf,"getPersistedWorkflowRunIdArgs");function Dn(e){let o=Fe().list().filter(r=>Tf(e,r.status)).map(r=>({name:r.runId,description:`${r.workflow} - ${r.status}`,type:"string"})),n=Af.has(e)?Lf():[],t=new Set;return[...o,...n].filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}i(Dn,"getWorkflowRunIdArgs");function Mf(e){for(let o of If)if(e.endsWith(o)){let n=e.slice(0,-o.length);return Nn(n)?n:void 0}}i(Mf,"savedWorkflowNameFromFile");function Oo(e={}){let o=[{path:_("workflows"),source:"personal"},{path:On(process.cwd(),".kodax","workflows"),source:"project"}],n=new Map;for(let t of o)if(Wn(t.path))try{for(let r of Ia(t.path)){if(e.generatedOnly===!0&&!r.endsWith(".workflow.json"))continue;let a=Mf(r);a&&n.set(a,{name:a,description:`${t.source} saved workflow`,type:"enum"})}}catch{}return[...n.values()].sort((t,r)=>t.name.localeCompare(r.name))}i(Oo,"getSavedWorkflowNameArgs");function _f(){let e=new Map;for(let o of Dn("rerun"))e.set(o.name,{...o,description:`recent run: ${o.description}`,type:"string"});for(let o of Oo()){let n=e.get(o.name);if(n){e.set(o.name,{...n,description:`${n.description}; also ${o.description}`});continue}e.set(o.name,{...o,description:o.description,type:"string"})}return[...e.values()]}i(_f,"getWorkflowRerunArgs");function gr(e){let o=new Map;for(let n of Dn(e))o.set(n.name,{...n,description:`workflow run: ${n.description}`,type:"string"});for(let n of Oo({generatedOnly:e==="delete"})){let t=o.get(n.name);if(t){o.set(n.name,{...t,description:`${t.description}; also ${n.description}`});continue}o.set(n.name,{...n,description:n.description,type:"string"})}return[...o.values()]}i(gr,"getWorkflowRunOrSavedNameArgs");function Ca(e){let o=new Set(e.slice(1).filter(n=>n.startsWith("--")));return o.has("--saved")?Oo({generatedOnly:!0}):o.has("--run")?Dn("delete"):gr("delete")}i(Ca,"getWorkflowDeleteTargetArgs");function Wf(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;if(t<=1)return[...$f,...qo().map(r=>({name:r.name,description:r.description,type:"enum"})),...Oo()];if(n==="rerun"&&t<=2)return _f();if(n==="rename"&&t<=2)return gr("rename");if(n==="delete"&&t<=2)return[...Cf,...Ca(e)];if(n==="delete"&&t<=3&&e.slice(1).some(r=>r.startsWith("--")))return Ca(e);if(n==="revise"){if(t<=2)return[{name:"--replace",description:"Replace a saved workflow after confirmation",type:"enum"},...gr("revise")];if(e[1]==="--replace"&&t<=3)return Oo()}return xf.has(n)&&t<=2?Dn(n):n==="runs"&&t<=2?Rf:n==="prune"&&t<=2?Ef:[]}i(Wf,"getWorkflowArgs");function Of(e){let[o=""]=e,n=o.toLowerCase(),t=e.length===1&&e[0]===""?0:e.length;return t<=1?vf:t>2?[]:n==="mode"?kf:n==="trace"?bf:[]}i(Of,"getRepoIntelArgs");var Nf=new Map([["mode",af],["thinking",so],["think",so],["t",so],["reasoning",so],["reason",so],["effort",so],["status",mr],["info",mr],["ctx",mr],["mcp",cf],["fallback",df],["auto-engine",uf],["agent-mode",Ra],["am",Ra],["verifier-log",Ea],["stall-log",Ea],["memory",ff],["goal",gf],["paste",wf],["review",hf],["agents",yf],["delete",pr],["rm",pr],["del",pr]]),Df=new Set(["model","m","provider"]),Uf=new Set(["repo-intel"]),jf=new Set(["repointel","ri"]),Ff=new Set(["workflow"]),Hf=new Set(["learn"]);function wr(e,o,n=[]){let t=e.toLowerCase();return Df.has(t)?lf(o):Uf.has(t)?Of(n):jf.has(t)?n.length<=1?Sf:[]:Ff.has(t)?Wf(n):Hf.has(t)?pf(n):Nf.get(t)??[]}i(wr,"getCommandArguments");var hr=class{static{i(this,"ArgumentCompleter")}canComplete(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return!1;let a=t.slice(r),l=a.split(/\s+/);if(l.length>=2&&l[0]!=="")return!0;let c=a.slice(1).toLowerCase();return wr(c).length>0}async getCompletions(o,n){let t=o.slice(0,n),r=ro(t);if(r===-1)return[];let a=t.slice(r),l=a.indexOf(" "),c=(l===-1?a.slice(1):a.slice(1,l)).toLowerCase(),d=l===-1?"":a.slice(l+1),u=d?d.split(/\s+/):[""],f=u.length-1,m=(u[f]??"").toLowerCase(),b=wr(c,m,u);if(!b||b.length===0)return[];let S=new Set(u.slice(0,-1).map(A=>A.toLowerCase()));return b.filter(A=>!S.has(A.name.toLowerCase())).filter(A=>!m||A.name.includes("/")?!0:A.name.toLowerCase().includes(m)).map(A=>({text:A.name,display:A.name,description:A.description,type:"argument"})).sort((A,v)=>{if(!m)return 0;let x=A.display.toLowerCase().startsWith(m),M=v.display.toLowerCase().startsWith(m);return x&&!M?-1:!x&&M?1:A.display.length-v.display.length})}};function dv(){return new hr}i(dv,"createArgumentCompleter");export{pt as a,B as b,_p as c,si as d,Wp as e,Jo as f,_a as g,zf as h,Wa as i,Xf as j,Zo as k,ks as l,go as m,ho as n,Ge as o,qe as p,Cs as q,Is as r,Ts as s,Ns as t,Ds as u,rt as v,js as w,pl as x,hl as y,np as z,hp as A,yl as B,dt as C,yp as D,vp as E,Qs as F,Rp as G,ri as H,te as I,li as J,ci as K,Fp as L,_l as M,Xl as N,Hp as O,rn as P,wt as Q,Bp as R,vi as S,Kp as T,Gp as U,qp as V,hg as W,yg as X,vg as Y,Ci as Z,bt as _,Ii as $,Re as aa,Ag as ba,xo as ca,Et as da,Ie as ea,pd as fa,gd as ga,Xi as ha,Jg as ia,Zg as ja,Cd as ka,Xw as la,Vw as ma,Yw as na,gh as oa,wh as pa,hh as qa,yh as ra,vh as sa,aa as ta,Ah as ua,Rh as va,ca as wa,Eh as xa,qh as ya,da as za,_o as Aa,Oy as Ba,Ny as Ca,Mn as Da,hr as Ea,dv as Fa,ro as Ga,ur as Ha,fr as Ia,Jy as Ja};
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{$a as Wl,Aa as fl,Ba as ml,C as Wr,Ca as pl,D as Gr,Da as hl,E as Hu,Ea as sn,F as qs,Fa as gl,G as zu,Ga as bl,Ha as vl,Ia as Cl,J as qu,Ja as Al,K as Ku,Ka as Il,L as Xu,La as Ml,M as Un,Ma as Hr,N as Ks,Na as Ol,Oa as Pl,Pa as Nl,Qa as $l,Ra as Ll,Sa as zr,Ta as ci,U as tl,Ua as ui,V as nl,Va as Dl,Wa as jl,X as Xs,Xa as Fl,Y as Ys,Ya as li,Za as Ul,_ as Js,_a as Bl,a as qe,aa as Qs,ba as rl,ca as ol,cb as Gl,da as Zs,db as nt,ea as ei,f as hu,h as gu,i as bu,ia as Bn,j as vu,ka as sl,l as ms,la as il,m as ps,ma as ti,n as $n,oa as ni,qa as ri,ra as al,sa as cl,ua as oi,va as ul,wa as si,xa as ll,y as zs,ya as dl,za as Wn}from"./chunk-ZZUIO5KL.js";import{a as ii}from"./chunk-HTVLCHWH.js";import{A as ai,o as Sl,t as El,u as _l,v as xl,y as kl}from"./chunk-KH2HED37.js";import{$ as _s,Aa as As,Ab as Fu,Bb as Uu,Ca as Is,Da as Ms,Dd as Vu,Eb as Lr,Fd as Yu,Gb as Dr,Gd as Ju,Ha as Os,Hb as jr,Hd as Qu,I as Cu,Id as Zu,J as Au,Ka as Ps,Kb as Fr,L as Iu,Lb as Ur,Ld as el,M as ws,N as Mu,Nb as Ds,Nc as Us,Oa as Nr,Ob as it,Pa as $r,Pb as js,Qb as Fs,Rb as Bu,Sa as Ns,U as Mr,Va as $s,W as Ts,Wa as Ls,X as Ss,Xa as Du,Y as Or,Z as Ou,Zc as Wu,Zd as yl,_ as Es,_c as Gu,a as Ar,aa as Pu,b as pu,ba as Nt,cd as Br,da as Nu,dd as Fn,de as wl,e as yu,ee as Vr,f as hs,fe as Tl,g as wu,hd as Bs,he as Rl,i as Tu,id as Ws,j as Su,ja as xs,k as Ir,ka as ks,kd as Gs,l as Eu,la as $u,m as Ln,ma as Lu,n as _u,oa as Dn,ob as Ke,p as gs,q as rn,qa as Pr,qd as at,r as xu,rd as Vs,s as on,t as ku,v as bs,w as vs,wa as jn,xa as Rs,y as ys,yd as Hs,za as Cs,zb as ju}from"./chunk-GIVYTXQW.js";import{h as Ru}from"./chunk-KHEFUT6O.js";import{D as It,Pa as Le,R as Pc,T as Tr,ab as rs,bb as Sr,cb as os,db as ss,e as ns,fb as is,gb as Er,k as wr,na as Mt,ua as Ot}from"./chunk-TRNAWSXP.js";import{Ab as tn,Ac as nu,Ba as Uc,Bb as Qc,Bc as ru,Bd as fu,Dc as ou,Ec as su,Fc as iu,G as $c,Gc as au,Hc as fs,Hd as mu,J as Lc,Va as Bc,Wb as Cr,Ya as Wc,ca as as,db as ze,fb as Gc,g as _r,ib as qc,id as nn,jd as cu,m as Nn,nb as Kc,o as xr,oa as Zt,pa as Dc,qb as Xc,ra as jc,rb as Yc,tb as Jc,ua as Fc,ud as uu,va as cs,w as Nc,wb as us,xb as ls,yd as lu,zc as ds,zd as du}from"./chunk-WMYCNECP.js";import{a as ce,b as st,d as Pt,g as We,i as le,j as en,lb as Zc,pb as eu,qb as tu}from"./chunk-EVXIJPZ6.js";import{E as zc,b as kr,d as Rr,e as Vc,j as Hc}from"./chunk-E7C4DRD2.js";import{a as i,b as ts,d as ob}from"./chunk-ONUPGMER.js";var xp=ts((sD,_p)=>{"use strict";_p.exports=i(function(t){return t.map(function(n){return n===""?"''":n&&typeof n=="object"?n.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(n)&&!/'/.test(n)?"'"+n.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(n)?'"'+n.replace(/(["\\$`!])/g,"\\$1")+'"':String(n).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")},"quote")});var Op=ts((aD,Mp)=>{"use strict";var Ip="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",kp=new RegExp("^"+Ip+"$"),Rp="|&;()<> \\t",JE='"((\\\\"|[^"])*?)"',QE="'((\\\\'|[^'])*?)'",ZE=/^#$/,Cp="'",Ap='"',ga="$",Gt="",e_=4294967296;for(ba=0;ba<4;ba++)Gt+=(e_*Math.random()).toString(16);var ba,t_=new RegExp("^"+Gt);function n_(e,t){for(var n=t.lastIndex,r=[],o;o=t.exec(e);)r.push(o),t.lastIndex===o.index&&(t.lastIndex+=1);return t.lastIndex=n,r}i(n_,"matchAll");function r_(e,t,n){var r=typeof e=="function"?e(n):e[n];return typeof r>"u"&&n!=""?r="":typeof r>"u"&&(r="$"),typeof r=="object"?t+Gt+JSON.stringify(r)+Gt:t+r}i(r_,"getVar");function o_(e,t,n){n||(n={});var r=n.escape||"\\",o="(\\"+r+`['"`+Rp+`]|[^\\s'"`+Rp+"])+",s=new RegExp(["("+Ip+")","("+o+"|"+JE+"|"+QE+")+"].join("|"),"g"),a=n_(e,s);if(a.length===0)return[];t||(t={});var c=!1;return a.map(function(u){var l=u[0];if(!l||c)return;if(kp.test(l))return{op:l};var d=!1,f=!1,h="",p=!1,m;function b(){m+=1;var y,w,T=l.charAt(m);if(T==="{"){if(m+=1,l.charAt(m)==="}")throw new Error("Bad substitution: "+l.slice(m-2,m+1));if(y=l.indexOf("}",m),y<0)throw new Error("Bad substitution: "+l.slice(m));w=l.slice(m,y),m=y}else if(/[*@#?$!_-]/.test(T))w=T,m+=1;else{var S=l.slice(m);y=S.match(/[^\w\d_]/),y?(w=S.slice(0,y.index),m+=y.index-1):(w=S,m=l.length)}return r_(t,"",w)}for(i(b,"parseEnvVar"),m=0;m<l.length;m++){var g=l.charAt(m);if(p=p||!d&&(g==="*"||g==="?"),f)h+=g,f=!1;else if(d)g===d?d=!1:d==Cp?h+=g:g===r?(m+=1,g=l.charAt(m),g===Ap||g===r||g===ga?h+=g:h+=r+g):g===ga?h+=b():h+=g;else if(g===Ap||g===Cp)d=g;else{if(kp.test(g))return{op:l};if(ZE.test(g)){c=!0;var v={comment:e.slice(u.index+m+1)};return h.length?[h,v]:[v]}else g===r?f=!0:g===ga?h+=b():h+=g}}return p?{op:"glob",pattern:h}:h}).reduce(function(u,l){return typeof l>"u"?u:u.concat(l)},[])}i(o_,"parseInternal");Mp.exports=i(function(t,n,r){var o=o_(t,n,r);return typeof n!="function"?o:o.reduce(function(s,a){if(typeof a=="object")return s.concat(a);var c=a.split(RegExp("("+Gt+".*?"+Gt+")","g"));return c.length===1?s.concat(c[0]):s.concat(c.filter(Boolean).map(function(u){return t_.test(u)?JSON.parse(u.split(Gt)[1]):u}))},[])},"parse")});var Pp=ts(va=>{"use strict";va.quote=xp();va.parse=Op()});var Gn=class extends Error{static{i(this,"KodaXError")}code;constructor(t,n="KODAX_ERROR"){super(t),this.code=n,this.name="KodaXError"}};var di=class extends Gn{static{i(this,"KodaXToolError")}toolName;toolId;constructor(t,n,r){super(t,"TOOL_ERROR"),this.toolName=n,this.toolId=r,this.name="KodaXToolError"}};var fi=class extends Gn{static{i(this,"KodaXSessionError")}sessionId;constructor(t,n){super(t,"SESSION_ERROR"),this.sessionId=n,this.name="KodaXSessionError"}},mi=class extends Gn{static{i(this,"KodaXTerminalError")}suggestions;constructor(t,n=[]){super(t,"TERMINAL_ERROR"),this.name="KodaXTerminalError",this.suggestions=n}};function sb(){return new qr}i(sb,"createSessionControl");function pi(e,t){let n=new AbortController,r=!1,o=i(p=>{r||(r=!0,n.abort(p))},"markAborted");e.abortSignal&&(e.abortSignal.aborted?o(e.abortSignal.reason):e.abortSignal.addEventListener("abort",()=>o(e.abortSignal.reason),{once:!0}));let s=new qr;s.seed({provider:e.provider,model:e.modelOverride??e.model,reasoning:e.reasoningMode});let a=e.session?.id,c=a!=null,u=a??ib(),d=!c&&e.session?.autoResume!==!0&&e.session?.resume!==!0?Fl({...e.session??{},id:u}):e.session,f={...e,...e.agentMode!==void 0?{agentMode:$n(e.agentMode)}:{},...d!==void 0?{session:d}:{},abortSignal:n.signal,sessionControl:s},h=nt(f,t);return{id:u,get currentProvider(){return s.getProvider()},get currentModel(){return s.getModel()},get currentReasoning(){return s.getReasoning()},get aborted(){return r},get attached(){return s.isAttached()},setProvider:i(p=>s.setProvider(p),"setProvider"),setModel:i(p=>s.setModel(p),"setModel"),setReasoning:i(p=>s.setReasoning(p),"setReasoning"),abort:i(p=>o(p),"abort"),result:h}}i(pi,"startKodaX");function ib(){return`sess_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}i(ib,"generateSessionId");var qr=class{static{i(this,"SessionControlImpl")}mutators=null;providerValue;modelValue;reasoningValue;hasPendingProvider=!1;hasPendingModel=!1;hasPendingReasoning=!1;seed(t){this.providerValue=t.provider,this.modelValue=t.model,this.reasoningValue=t.reasoning}setProvider(t){this.providerValue=t,this.mutators?this.mutators.setProvider(t):this.hasPendingProvider=!0}setModel(t){this.modelValue=t,this.mutators?this.mutators.setModel(t):this.hasPendingModel=!0}setReasoning(t){this.reasoningValue=t,this.mutators?this.mutators.setReasoning(t):this.hasPendingReasoning=!0}getProvider(){return this.providerValue??""}getModel(){return this.modelValue}getReasoning(){return this.reasoningValue}isAttached(){return this.mutators!==null}_attach(t){this.mutators,this.mutators=t,this.hasPendingProvider&&this.providerValue!==void 0&&t.setProvider(this.providerValue),this.hasPendingModel&&t.setModel(this.modelValue),this.hasPendingReasoning&&t.setReasoning(this.reasoningValue),this.hasPendingProvider=!1,this.hasPendingModel=!1,this.hasPendingReasoning=!1}};function ab(e,t){return e.kind!=="revise_count"?{ok:!0}:e.count<=3?{ok:!0}:{ok:!1,severity:"warn",reason:`boundedRevise: revise_count for harness="${e.harness}" reached ${e.count}, exceeding soft threshold 3`}}i(ab,"observe");var hi={id:"boundedRevise",description:"Per-harness revise count must stay within the soft threshold; crossings emit a warn signal for dispatch-eval (hard cap enforced by the budget controller).",observe:ab};function cb(e,t){return typeof e.maxBudget!="number"?{ok:!0}:e.maxBudget<=t.systemCap.maxBudget?{ok:!0}:{ok:!1,severity:"clamp",reason:`budgetCeiling: manifest.maxBudget=${e.maxBudget} exceeds systemCap.maxBudget=${t.systemCap.maxBudget}`,patch:{clampMaxBudget:t.systemCap.maxBudget}}}i(cb,"admit");var gi={id:"budgetCeiling",description:"manifest.maxBudget must be \u2264 systemCap.maxBudget; over-cap declarations are clamped down to the cap.",admit:cb};function ub(e,t){return{ok:!0}}i(ub,"observe");var Vl={id:"harnessSelectionTiming",description:"FEATURE_193 V2 no-op shell \u2014 predicate always admits since V1 Scout retired. Kept registered for admission-framework / audit-array compat.",observe:ub};function lb(e,t){if(e.kind!=="mutation_recorded")return{ok:!0};let n=t.recorder;return typeof n.todoUpdateCount!="number"?{ok:!0}:n.todoUpdateCount>0?{ok:!0}:n.workerTrivialDeclaration===!0?{ok:!0}:{ok:!1,severity:"warn",reason:`planBeforeMutate: Worker mutated ${e.file} without a prior todo_update plan commit and without a trivial declaration`}}i(lb,"observe");var Hl={id:"planBeforeMutate",description:"Worker mutations should be preceded by a todo_update plan commit (or an explicit trivial declaration). Missing plan is a warn-only signal in v0.7.36.",observe:lb};function bi(e){switch(e){case"read":case"glob":case"grep":case"code_search":case"semantic_lookup":case"lsp_definition":case"lsp_hover":case"lsp_references":case"lsp_document_symbols":case"lsp_workspace_symbols":case"lsp_implementation":case"lsp_prepare_call_hierarchy":case"lsp_incoming_calls":case"lsp_outgoing_calls":case"repo_overview":case"changed_scope":case"changed_diff":case"changed_diff_bundle":case"module_context":case"symbol_context":case"process_context":case"impact_estimate":case"relationship_scan":case"cyclic_dependencies":case"ask_user_question":case"exit_plan_mode":return"read";case"write":case"edit":case"multi_edit":case"insert_after_anchor":case"undo":return"edit";case"bash":return"bash:mutating";case"web_search":case"web_fetch":case"mcp_search":case"mcp_describe":case"mcp_call":case"mcp_read_resource":case"mcp_get_prompt":return"bash:network";case"spawn_agent":case"send_message":case"followup_task":case"wait_agent":case"interrupt_agent":case"list_agents":case"agent_output":case"emit_verdict":case"scaffold_tool":case"validate_tool":case"stage_construction":case"test_tool":case"activate_tool":case"scaffold_agent":case"validate_agent":case"stage_agent_construction":case"test_agent":case"activate_agent":case"worktree_create":case"worktree_remove":return"subagent";default:return"subagent"}}i(bi,"resolveToolCapability");function db(e){if(typeof e=="object"&&e!==null&&"name"in e){let t=e.name;if(typeof t=="string"&&t.length>0)return t}}i(db,"getToolName");function fb(e,t){if(!e.tools||e.tools.length===0)return{ok:!0};let n=new Set(t.systemCap.allowedToolCapabilities),r=[];for(let a of e.tools){let c=db(a);if(!c)continue;let u=bi(c);n.has(u)||r.push({name:c,capability:u})}if(r.length===0)return{ok:!0};let o=r.map(a=>a.name);return{ok:!1,severity:"clamp",reason:`toolPermission: tools requiring disallowed capabilities \u2014 ${r.map(a=>`${a.name}=${a.capability}`).join(", ")}`,patch:{removeTools:o}}}i(fb,"admit");var vi={id:"toolPermission",description:"Every tool in manifest.tools must resolve to a capability tier that systemCap.allowedToolCapabilities permits; offending tools are clamped via removeTools.",admit:fb};var zl=[gi,vi,hi,Vl,Hl];function mb(){Uc();for(let e of zl)Lc(e)}i(mb,"registerCodingInvariants");var Kr=class{static{i(this,"KodaXClient")}options;sessionId;messages=[];contextTokenSnapshot;constructor(t){this.options=t,this.sessionId=t.session?.id??"",this.messages=t.session?.initialMessages?[...t.session.initialMessages]:[],this.contextTokenSnapshot=t.context?.contextTokenSnapshot}async send(t){let n=this.messages.length>0?this.messages:this.options.session?.initialMessages,r=await nt({...this.options,session:{...this.options.session,id:this.sessionId||void 0,initialMessages:n},context:{...this.options.context,contextTokenSnapshot:this.contextTokenSnapshot}},t);return this.sessionId=r.sessionId,this.messages=r.messages,this.contextTokenSnapshot=r.contextTokenSnapshot,r}getSessionId(){return this.sessionId}getMessages(){return[...this.messages]}clear(){this.messages=[],this.sessionId="",this.contextTokenSnapshot=void 0}};function ql(e){return/\bworkflows?\b|工作流(?!程)|ワークフロー|워크플로우/iu.test(e)}i(ql,"hasExplicitNaturalLanguageWorkflowIntent");function OI(e){return{action:e.source==="command"?"suggest":"none"}}i(OI,"decideWorkflowInvocation");function PI(e){return e.outcome==="started"||e.outcome==="cancelled"}i(PI,"workflowStartOutcomeConsumesTurn");var pb="KODAX_VERIFIER_PROVIDER",hb="KODAX_VERIFIER_MODEL";function gb(e){if(Ot(e))try{return Mt(e)}catch{return}}i(gb,"tryGetProvider");function Xr(e){let t=e.env??process.env,n=t[pb],r=t[hb];if(n&&r){let o=gb(n);if(o)return{provider:o,model:r,providerName:n,source:"explicit-env"}}return{provider:e.mainProvider,model:e.mainModel,providerName:e.mainProviderName,source:"inherit-main"}}i(Xr,"resolveVerifierProvider");function yi(e){let t=e.context?.agentProfile;if(!t)return;let n=t.verification,r=e.context?.taskVerification;if(!n&&!r)return;let o={...n,...r};return Array.isArray(r?.criteria)&&r.criteria.length===0&&Array.isArray(n?.criteria)&&n.criteria.length>0?{...o,criteria:n.criteria}:o}i(yi,"resolveEffectiveVerification");function bb(e){let t=e.provider??"anthropic";if(Ot(t))try{let n=Xr({mainProvider:Mt(t),mainProviderName:t,mainModel:e.modelOverride??e.model});return{provider:n.providerName,...n.model!==void 0?{model:n.model}:{}}}catch{return}}i(bb,"resolveVerifierAttribution");function wi(e,t){let n=e.events?.onEffectiveConfig;if(!n)return;let r=t.verifier??bb(e),o={agentMode:t.agentMode,agentProfile:e.context?.agentProfile,toolScope:t.toolScope,verification:yi(e),...r?{verifier:r}:{}};try{n(o)}catch{}}i(wi,"emitEffectiveTaskConfig");var Kl="kodax-review-findings",Xl="kodax-investigation-shards",Yl="kodax-lookup-shards",Jl="kodax-child-result";var Ql="kodax-budget-request";function $t(e,t=!1){return{globalWorkBudget:e?.totalBudget,budgetUsage:e?.spentBudget,budgetApprovalRequired:t}}i($t,"buildManagedStatusBudgetFields");function Vn(e,t=1){e.spentBudget=Math.max(0,e.spentBudget+t)}i(Vn,"incrementManagedBudgetUsage");function yb(e,t=200){e.totalBudget+=t}i(yb,"extendManagedWorkBudget");function Jr(e,t,n=!1){if(!e?.askUser)return!1;if(!n){let r=Math.ceil(t.totalBudget*.9);if(t.spentBudget<r)return!1}return t.lastApprovalBudgetTotal!==t.totalBudget}i(Jr,"canRequestAdditionalWorkBudget");async function Ti(e,t,n){let r=e?.askUser;if(!r||!Jr(e,t,n.force))return"skipped";let o=n.additionalUnits??200,s=Math.min(100,Math.round(t.spentBudget/Math.max(1,t.totalBudget)*100)),a=/[\u4e00-\u9fff]/.test(n.originalTask??n.summary),c=ze(await r({question:a?`\u5F53\u524D AMA \u8FD0\u884C\u5DF2\u4F7F\u7528 ${t.spentBudget}/${t.totalBudget} \u5DE5\u4F5C\u5355\u5143\uFF08${s}%\uFF09\uFF0C\u9700\u8981\u66F4\u591A\u5DE5\u4F5C\u91CF\u3002\u662F\u5426\u8FFD\u52A0 ${o} \u5355\u5143\uFF1F`:`This AMA run has used ${t.spentBudget}/${t.totalBudget} work units (${s}%) and needs more work. Add ${o} more work units?`,allowCustomInput:!1,options:[{label:a?`\u7EE7\u7EED (+${o})`:`Continue (+${o})`,value:"continue",description:a?`\u8FFD\u52A0 ${o} \u5DE5\u4F5C\u5355\u5143\uFF0C\u4ECE\u7B2C ${n.currentRound}/${n.maxRounds} \u8F6E\u7EE7\u7EED\u3002`:`Grant ${o} more work units and continue from round ${n.currentRound}/${n.maxRounds}.`},{label:a?"\u505C\u6B62":"Stop here",value:"stop",description:a?`\u4F7F\u7528\u5F53\u524D\u6700\u4F73\u7ED3\u679C\u3002\u6700\u65B0\u8FDB\u5C55\uFF1A${qs(n.summary,80)}`:`Finish now with the current best result. Latest note: ${qs(n.summary,80)}`}],default:"continue"})),u=t.totalBudget;return c==="continue"?(t.lastApprovalBudgetTotal=u,yb(t,o),"approved"):(t.lastApprovalBudgetTotal=u,"denied")}i(Ti,"maybeRequestAdditionalWorkBudget");import{mkdir as wb,readdir as Tb,readFile as ed,stat as Sb,unlink as Eb,writeFile as _b}from"node:fs/promises";import{execFile as xb}from"node:child_process";import{promisify as kb}from"node:util";import an from"node:path";import Zl from"node:path";function ct(e){return e.context?.taskSurface??"cli"}i(ct,"getManagedTaskSurface");function ut(e,t){if(e.context?.managedTaskWorkspaceDir?.trim())return Zl.resolve(e.context.managedTaskWorkspaceDir);let n=e.context?.executionCwd??e.context?.gitRoot??process.cwd();return Zl.resolve(n,".agent","managed-tasks")}i(ut,"getManagedTaskWorkspaceRoot");var Rb=kb(xb),td=3600*1e3,Qr="checkpoint.json";function Si(e){let t=e.session?.id?.trim();return t||void 0}i(Si,"getCheckpointSessionId");function Cb(e,t){return t?e.sessionId===t:!1}i(Cb,"checkpointBelongsToSession");async function Zr(e){let t=an.resolve(e?.trim()||process.cwd());try{let{stdout:n}=await Rb("git",["rev-parse","--short","HEAD"],{cwd:t,windowsHide:!0});return n.trim()||void 0}catch{return}}i(Zr,"getGitHeadCommit");async function Ei(e,t){await wb(e,{recursive:!0}),await _b(an.join(e,Qr),`${JSON.stringify(t,null,2)}
2
+ import{$a as Wl,Aa as fl,Ba as ml,C as Wr,Ca as pl,D as Gr,Da as hl,E as Hu,Ea as sn,F as qs,Fa as gl,G as zu,Ga as bl,Ha as vl,Ia as Cl,J as qu,Ja as Al,K as Ku,Ka as Il,L as Xu,La as Ml,M as Un,Ma as Hr,N as Ks,Na as Ol,Oa as Pl,Pa as Nl,Qa as $l,Ra as Ll,Sa as zr,Ta as ci,U as tl,Ua as ui,V as nl,Va as Dl,Wa as jl,X as Xs,Xa as Fl,Y as Ys,Ya as li,Za as Ul,_ as Js,_a as Bl,a as qe,aa as Qs,ba as rl,ca as ol,cb as Gl,da as Zs,db as nt,ea as ei,f as hu,h as gu,i as bu,ia as Bn,j as vu,ka as sl,l as ms,la as il,m as ps,ma as ti,n as $n,oa as ni,qa as ri,ra as al,sa as cl,ua as oi,va as ul,wa as si,xa as ll,y as zs,ya as dl,za as Wn}from"./chunk-TDJS5SFS.js";import{a as ii}from"./chunk-HTVLCHWH.js";import{A as ai,o as Sl,t as El,u as _l,v as xl,y as kl}from"./chunk-ZVPTDYDI.js";import{$ as _s,Aa as As,Ab as Fu,Bb as Uu,Ca as Is,Da as Ms,Dd as Vu,Eb as Lr,Fd as Yu,Gb as Dr,Gd as Ju,Ha as Os,Hb as jr,Hd as Qu,I as Cu,Id as Zu,J as Au,Ka as Ps,Kb as Fr,L as Iu,Lb as Ur,Ld as el,M as ws,N as Mu,Nb as Ds,Nc as Us,Oa as Nr,Ob as it,Pa as $r,Pb as js,Qb as Fs,Rb as Bu,Sa as Ns,U as Mr,Va as $s,W as Ts,Wa as Ls,X as Ss,Xa as Du,Y as Or,Z as Ou,Zc as Wu,Zd as yl,_ as Es,_c as Gu,a as Ar,aa as Pu,b as pu,ba as Nt,cd as Br,da as Nu,dd as Fn,de as wl,e as yu,ee as Vr,f as hs,fe as Tl,g as wu,hd as Bs,he as Rl,i as Tu,id as Ws,j as Su,ja as xs,k as Ir,ka as ks,kd as Gs,l as Eu,la as $u,m as Ln,ma as Lu,n as _u,oa as Dn,ob as Ke,p as gs,q as rn,qa as Pr,qd as at,r as xu,rd as Vs,s as on,t as ku,v as bs,w as vs,wa as jn,xa as Rs,y as ys,yd as Hs,za as Cs,zb as ju}from"./chunk-GRLC3N46.js";import{h as Ru}from"./chunk-KHEFUT6O.js";import{D as It,Pa as Le,R as Pc,T as Tr,ab as rs,bb as Sr,cb as os,db as ss,e as ns,fb as is,gb as Er,k as wr,na as Mt,ua as Ot}from"./chunk-TRNAWSXP.js";import{Ac as ds,Ad as du,Ba as Uc,Bb as tn,Bc as nu,Cb as Qc,Cc as ru,Cd as fu,Ec as ou,Fc as su,G as $c,Gc as iu,Hc as au,Ic as fs,Id as mu,J as Lc,Wa as Bc,Xb as Cr,Za as Wc,ca as as,eb as ze,g as _r,gb as Gc,jb as qc,jd as nn,kd as cu,m as Nn,o as xr,oa as Zt,ob as Kc,pa as Dc,ra as jc,rb as Xc,sb as Yc,ua as Fc,ub as Jc,va as cs,vd as uu,w as Nc,xb as us,yb as ls,zd as lu}from"./chunk-4ZI2CPUQ.js";import{a as ce,b as st,d as Pt,g as We,i as le,j as en,lb as Zc,pb as eu,qb as tu}from"./chunk-EVXIJPZ6.js";import{E as zc,b as kr,d as Rr,e as Vc,j as Hc}from"./chunk-E7C4DRD2.js";import{a as i,b as ts,d as ob}from"./chunk-ONUPGMER.js";var xp=ts((sD,_p)=>{"use strict";_p.exports=i(function(t){return t.map(function(n){return n===""?"''":n&&typeof n=="object"?n.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(n)&&!/'/.test(n)?"'"+n.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(n)?'"'+n.replace(/(["\\$`!])/g,"\\$1")+'"':String(n).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")},"quote")});var Op=ts((aD,Mp)=>{"use strict";var Ip="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",kp=new RegExp("^"+Ip+"$"),Rp="|&;()<> \\t",JE='"((\\\\"|[^"])*?)"',QE="'((\\\\'|[^'])*?)'",ZE=/^#$/,Cp="'",Ap='"',ga="$",Gt="",e_=4294967296;for(ba=0;ba<4;ba++)Gt+=(e_*Math.random()).toString(16);var ba,t_=new RegExp("^"+Gt);function n_(e,t){for(var n=t.lastIndex,r=[],o;o=t.exec(e);)r.push(o),t.lastIndex===o.index&&(t.lastIndex+=1);return t.lastIndex=n,r}i(n_,"matchAll");function r_(e,t,n){var r=typeof e=="function"?e(n):e[n];return typeof r>"u"&&n!=""?r="":typeof r>"u"&&(r="$"),typeof r=="object"?t+Gt+JSON.stringify(r)+Gt:t+r}i(r_,"getVar");function o_(e,t,n){n||(n={});var r=n.escape||"\\",o="(\\"+r+`['"`+Rp+`]|[^\\s'"`+Rp+"])+",s=new RegExp(["("+Ip+")","("+o+"|"+JE+"|"+QE+")+"].join("|"),"g"),a=n_(e,s);if(a.length===0)return[];t||(t={});var c=!1;return a.map(function(u){var l=u[0];if(!l||c)return;if(kp.test(l))return{op:l};var d=!1,f=!1,h="",p=!1,m;function b(){m+=1;var y,w,T=l.charAt(m);if(T==="{"){if(m+=1,l.charAt(m)==="}")throw new Error("Bad substitution: "+l.slice(m-2,m+1));if(y=l.indexOf("}",m),y<0)throw new Error("Bad substitution: "+l.slice(m));w=l.slice(m,y),m=y}else if(/[*@#?$!_-]/.test(T))w=T,m+=1;else{var S=l.slice(m);y=S.match(/[^\w\d_]/),y?(w=S.slice(0,y.index),m+=y.index-1):(w=S,m=l.length)}return r_(t,"",w)}for(i(b,"parseEnvVar"),m=0;m<l.length;m++){var g=l.charAt(m);if(p=p||!d&&(g==="*"||g==="?"),f)h+=g,f=!1;else if(d)g===d?d=!1:d==Cp?h+=g:g===r?(m+=1,g=l.charAt(m),g===Ap||g===r||g===ga?h+=g:h+=r+g):g===ga?h+=b():h+=g;else if(g===Ap||g===Cp)d=g;else{if(kp.test(g))return{op:l};if(ZE.test(g)){c=!0;var v={comment:e.slice(u.index+m+1)};return h.length?[h,v]:[v]}else g===r?f=!0:g===ga?h+=b():h+=g}}return p?{op:"glob",pattern:h}:h}).reduce(function(u,l){return typeof l>"u"?u:u.concat(l)},[])}i(o_,"parseInternal");Mp.exports=i(function(t,n,r){var o=o_(t,n,r);return typeof n!="function"?o:o.reduce(function(s,a){if(typeof a=="object")return s.concat(a);var c=a.split(RegExp("("+Gt+".*?"+Gt+")","g"));return c.length===1?s.concat(c[0]):s.concat(c.filter(Boolean).map(function(u){return t_.test(u)?JSON.parse(u.split(Gt)[1]):u}))},[])},"parse")});var Pp=ts(va=>{"use strict";va.quote=xp();va.parse=Op()});var Gn=class extends Error{static{i(this,"KodaXError")}code;constructor(t,n="KODAX_ERROR"){super(t),this.code=n,this.name="KodaXError"}};var di=class extends Gn{static{i(this,"KodaXToolError")}toolName;toolId;constructor(t,n,r){super(t,"TOOL_ERROR"),this.toolName=n,this.toolId=r,this.name="KodaXToolError"}};var fi=class extends Gn{static{i(this,"KodaXSessionError")}sessionId;constructor(t,n){super(t,"SESSION_ERROR"),this.sessionId=n,this.name="KodaXSessionError"}},mi=class extends Gn{static{i(this,"KodaXTerminalError")}suggestions;constructor(t,n=[]){super(t,"TERMINAL_ERROR"),this.name="KodaXTerminalError",this.suggestions=n}};function sb(){return new qr}i(sb,"createSessionControl");function pi(e,t){let n=new AbortController,r=!1,o=i(p=>{r||(r=!0,n.abort(p))},"markAborted");e.abortSignal&&(e.abortSignal.aborted?o(e.abortSignal.reason):e.abortSignal.addEventListener("abort",()=>o(e.abortSignal.reason),{once:!0}));let s=new qr;s.seed({provider:e.provider,model:e.modelOverride??e.model,reasoning:e.reasoningMode});let a=e.session?.id,c=a!=null,u=a??ib(),d=!c&&e.session?.autoResume!==!0&&e.session?.resume!==!0?Fl({...e.session??{},id:u}):e.session,f={...e,...e.agentMode!==void 0?{agentMode:$n(e.agentMode)}:{},...d!==void 0?{session:d}:{},abortSignal:n.signal,sessionControl:s},h=nt(f,t);return{id:u,get currentProvider(){return s.getProvider()},get currentModel(){return s.getModel()},get currentReasoning(){return s.getReasoning()},get aborted(){return r},get attached(){return s.isAttached()},setProvider:i(p=>s.setProvider(p),"setProvider"),setModel:i(p=>s.setModel(p),"setModel"),setReasoning:i(p=>s.setReasoning(p),"setReasoning"),abort:i(p=>o(p),"abort"),result:h}}i(pi,"startKodaX");function ib(){return`sess_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}i(ib,"generateSessionId");var qr=class{static{i(this,"SessionControlImpl")}mutators=null;providerValue;modelValue;reasoningValue;hasPendingProvider=!1;hasPendingModel=!1;hasPendingReasoning=!1;seed(t){this.providerValue=t.provider,this.modelValue=t.model,this.reasoningValue=t.reasoning}setProvider(t){this.providerValue=t,this.mutators?this.mutators.setProvider(t):this.hasPendingProvider=!0}setModel(t){this.modelValue=t,this.mutators?this.mutators.setModel(t):this.hasPendingModel=!0}setReasoning(t){this.reasoningValue=t,this.mutators?this.mutators.setReasoning(t):this.hasPendingReasoning=!0}getProvider(){return this.providerValue??""}getModel(){return this.modelValue}getReasoning(){return this.reasoningValue}isAttached(){return this.mutators!==null}_attach(t){this.mutators,this.mutators=t,this.hasPendingProvider&&this.providerValue!==void 0&&t.setProvider(this.providerValue),this.hasPendingModel&&t.setModel(this.modelValue),this.hasPendingReasoning&&t.setReasoning(this.reasoningValue),this.hasPendingProvider=!1,this.hasPendingModel=!1,this.hasPendingReasoning=!1}};function ab(e,t){return e.kind!=="revise_count"?{ok:!0}:e.count<=3?{ok:!0}:{ok:!1,severity:"warn",reason:`boundedRevise: revise_count for harness="${e.harness}" reached ${e.count}, exceeding soft threshold 3`}}i(ab,"observe");var hi={id:"boundedRevise",description:"Per-harness revise count must stay within the soft threshold; crossings emit a warn signal for dispatch-eval (hard cap enforced by the budget controller).",observe:ab};function cb(e,t){return typeof e.maxBudget!="number"?{ok:!0}:e.maxBudget<=t.systemCap.maxBudget?{ok:!0}:{ok:!1,severity:"clamp",reason:`budgetCeiling: manifest.maxBudget=${e.maxBudget} exceeds systemCap.maxBudget=${t.systemCap.maxBudget}`,patch:{clampMaxBudget:t.systemCap.maxBudget}}}i(cb,"admit");var gi={id:"budgetCeiling",description:"manifest.maxBudget must be \u2264 systemCap.maxBudget; over-cap declarations are clamped down to the cap.",admit:cb};function ub(e,t){return{ok:!0}}i(ub,"observe");var Vl={id:"harnessSelectionTiming",description:"FEATURE_193 V2 no-op shell \u2014 predicate always admits since V1 Scout retired. Kept registered for admission-framework / audit-array compat.",observe:ub};function lb(e,t){if(e.kind!=="mutation_recorded")return{ok:!0};let n=t.recorder;return typeof n.todoUpdateCount!="number"?{ok:!0}:n.todoUpdateCount>0?{ok:!0}:n.workerTrivialDeclaration===!0?{ok:!0}:{ok:!1,severity:"warn",reason:`planBeforeMutate: Worker mutated ${e.file} without a prior todo_update plan commit and without a trivial declaration`}}i(lb,"observe");var Hl={id:"planBeforeMutate",description:"Worker mutations should be preceded by a todo_update plan commit (or an explicit trivial declaration). Missing plan is a warn-only signal in v0.7.36.",observe:lb};function bi(e){switch(e){case"read":case"glob":case"grep":case"code_search":case"semantic_lookup":case"lsp_definition":case"lsp_hover":case"lsp_references":case"lsp_document_symbols":case"lsp_workspace_symbols":case"lsp_implementation":case"lsp_prepare_call_hierarchy":case"lsp_incoming_calls":case"lsp_outgoing_calls":case"repo_overview":case"changed_scope":case"changed_diff":case"changed_diff_bundle":case"module_context":case"symbol_context":case"process_context":case"impact_estimate":case"relationship_scan":case"cyclic_dependencies":case"ask_user_question":case"exit_plan_mode":return"read";case"write":case"edit":case"multi_edit":case"insert_after_anchor":case"undo":return"edit";case"bash":return"bash:mutating";case"web_search":case"web_fetch":case"mcp_search":case"mcp_describe":case"mcp_call":case"mcp_read_resource":case"mcp_get_prompt":return"bash:network";case"spawn_agent":case"send_message":case"followup_task":case"wait_agent":case"interrupt_agent":case"list_agents":case"agent_output":case"emit_verdict":case"scaffold_tool":case"validate_tool":case"stage_construction":case"test_tool":case"activate_tool":case"scaffold_agent":case"validate_agent":case"stage_agent_construction":case"test_agent":case"activate_agent":case"worktree_create":case"worktree_remove":return"subagent";default:return"subagent"}}i(bi,"resolveToolCapability");function db(e){if(typeof e=="object"&&e!==null&&"name"in e){let t=e.name;if(typeof t=="string"&&t.length>0)return t}}i(db,"getToolName");function fb(e,t){if(!e.tools||e.tools.length===0)return{ok:!0};let n=new Set(t.systemCap.allowedToolCapabilities),r=[];for(let a of e.tools){let c=db(a);if(!c)continue;let u=bi(c);n.has(u)||r.push({name:c,capability:u})}if(r.length===0)return{ok:!0};let o=r.map(a=>a.name);return{ok:!1,severity:"clamp",reason:`toolPermission: tools requiring disallowed capabilities \u2014 ${r.map(a=>`${a.name}=${a.capability}`).join(", ")}`,patch:{removeTools:o}}}i(fb,"admit");var vi={id:"toolPermission",description:"Every tool in manifest.tools must resolve to a capability tier that systemCap.allowedToolCapabilities permits; offending tools are clamped via removeTools.",admit:fb};var zl=[gi,vi,hi,Vl,Hl];function mb(){Uc();for(let e of zl)Lc(e)}i(mb,"registerCodingInvariants");var Kr=class{static{i(this,"KodaXClient")}options;sessionId;messages=[];contextTokenSnapshot;constructor(t){this.options=t,this.sessionId=t.session?.id??"",this.messages=t.session?.initialMessages?[...t.session.initialMessages]:[],this.contextTokenSnapshot=t.context?.contextTokenSnapshot}async send(t){let n=this.messages.length>0?this.messages:this.options.session?.initialMessages,r=await nt({...this.options,session:{...this.options.session,id:this.sessionId||void 0,initialMessages:n},context:{...this.options.context,contextTokenSnapshot:this.contextTokenSnapshot}},t);return this.sessionId=r.sessionId,this.messages=r.messages,this.contextTokenSnapshot=r.contextTokenSnapshot,r}getSessionId(){return this.sessionId}getMessages(){return[...this.messages]}clear(){this.messages=[],this.sessionId="",this.contextTokenSnapshot=void 0}};function ql(e){return/\bworkflows?\b|工作流(?!程)|ワークフロー|워크플로우/iu.test(e)}i(ql,"hasExplicitNaturalLanguageWorkflowIntent");function OI(e){return{action:e.source==="command"?"suggest":"none"}}i(OI,"decideWorkflowInvocation");function PI(e){return e.outcome==="started"||e.outcome==="cancelled"}i(PI,"workflowStartOutcomeConsumesTurn");var pb="KODAX_VERIFIER_PROVIDER",hb="KODAX_VERIFIER_MODEL";function gb(e){if(Ot(e))try{return Mt(e)}catch{return}}i(gb,"tryGetProvider");function Xr(e){let t=e.env??process.env,n=t[pb],r=t[hb];if(n&&r){let o=gb(n);if(o)return{provider:o,model:r,providerName:n,source:"explicit-env"}}return{provider:e.mainProvider,model:e.mainModel,providerName:e.mainProviderName,source:"inherit-main"}}i(Xr,"resolveVerifierProvider");function yi(e){let t=e.context?.agentProfile;if(!t)return;let n=t.verification,r=e.context?.taskVerification;if(!n&&!r)return;let o={...n,...r};return Array.isArray(r?.criteria)&&r.criteria.length===0&&Array.isArray(n?.criteria)&&n.criteria.length>0?{...o,criteria:n.criteria}:o}i(yi,"resolveEffectiveVerification");function bb(e){let t=e.provider??"anthropic";if(Ot(t))try{let n=Xr({mainProvider:Mt(t),mainProviderName:t,mainModel:e.modelOverride??e.model});return{provider:n.providerName,...n.model!==void 0?{model:n.model}:{}}}catch{return}}i(bb,"resolveVerifierAttribution");function wi(e,t){let n=e.events?.onEffectiveConfig;if(!n)return;let r=t.verifier??bb(e),o={agentMode:t.agentMode,agentProfile:e.context?.agentProfile,toolScope:t.toolScope,verification:yi(e),...r?{verifier:r}:{}};try{n(o)}catch{}}i(wi,"emitEffectiveTaskConfig");var Kl="kodax-review-findings",Xl="kodax-investigation-shards",Yl="kodax-lookup-shards",Jl="kodax-child-result";var Ql="kodax-budget-request";function $t(e,t=!1){return{globalWorkBudget:e?.totalBudget,budgetUsage:e?.spentBudget,budgetApprovalRequired:t}}i($t,"buildManagedStatusBudgetFields");function Vn(e,t=1){e.spentBudget=Math.max(0,e.spentBudget+t)}i(Vn,"incrementManagedBudgetUsage");function yb(e,t=200){e.totalBudget+=t}i(yb,"extendManagedWorkBudget");function Jr(e,t,n=!1){if(!e?.askUser)return!1;if(!n){let r=Math.ceil(t.totalBudget*.9);if(t.spentBudget<r)return!1}return t.lastApprovalBudgetTotal!==t.totalBudget}i(Jr,"canRequestAdditionalWorkBudget");async function Ti(e,t,n){let r=e?.askUser;if(!r||!Jr(e,t,n.force))return"skipped";let o=n.additionalUnits??200,s=Math.min(100,Math.round(t.spentBudget/Math.max(1,t.totalBudget)*100)),a=/[\u4e00-\u9fff]/.test(n.originalTask??n.summary),c=ze(await r({question:a?`\u5F53\u524D AMA \u8FD0\u884C\u5DF2\u4F7F\u7528 ${t.spentBudget}/${t.totalBudget} \u5DE5\u4F5C\u5355\u5143\uFF08${s}%\uFF09\uFF0C\u9700\u8981\u66F4\u591A\u5DE5\u4F5C\u91CF\u3002\u662F\u5426\u8FFD\u52A0 ${o} \u5355\u5143\uFF1F`:`This AMA run has used ${t.spentBudget}/${t.totalBudget} work units (${s}%) and needs more work. Add ${o} more work units?`,allowCustomInput:!1,options:[{label:a?`\u7EE7\u7EED (+${o})`:`Continue (+${o})`,value:"continue",description:a?`\u8FFD\u52A0 ${o} \u5DE5\u4F5C\u5355\u5143\uFF0C\u4ECE\u7B2C ${n.currentRound}/${n.maxRounds} \u8F6E\u7EE7\u7EED\u3002`:`Grant ${o} more work units and continue from round ${n.currentRound}/${n.maxRounds}.`},{label:a?"\u505C\u6B62":"Stop here",value:"stop",description:a?`\u4F7F\u7528\u5F53\u524D\u6700\u4F73\u7ED3\u679C\u3002\u6700\u65B0\u8FDB\u5C55\uFF1A${qs(n.summary,80)}`:`Finish now with the current best result. Latest note: ${qs(n.summary,80)}`}],default:"continue"})),u=t.totalBudget;return c==="continue"?(t.lastApprovalBudgetTotal=u,yb(t,o),"approved"):(t.lastApprovalBudgetTotal=u,"denied")}i(Ti,"maybeRequestAdditionalWorkBudget");import{mkdir as wb,readdir as Tb,readFile as ed,stat as Sb,unlink as Eb,writeFile as _b}from"node:fs/promises";import{execFile as xb}from"node:child_process";import{promisify as kb}from"node:util";import an from"node:path";import Zl from"node:path";function ct(e){return e.context?.taskSurface??"cli"}i(ct,"getManagedTaskSurface");function ut(e,t){if(e.context?.managedTaskWorkspaceDir?.trim())return Zl.resolve(e.context.managedTaskWorkspaceDir);let n=e.context?.executionCwd??e.context?.gitRoot??process.cwd();return Zl.resolve(n,".agent","managed-tasks")}i(ut,"getManagedTaskWorkspaceRoot");var Rb=kb(xb),td=3600*1e3,Qr="checkpoint.json";function Si(e){let t=e.session?.id?.trim();return t||void 0}i(Si,"getCheckpointSessionId");function Cb(e,t){return t?e.sessionId===t:!1}i(Cb,"checkpointBelongsToSession");async function Zr(e){let t=an.resolve(e?.trim()||process.cwd());try{let{stdout:n}=await Rb("git",["rev-parse","--short","HEAD"],{cwd:t,windowsHide:!0});return n.trim()||void 0}catch{return}}i(Zr,"getGitHeadCommit");async function Ei(e,t){await wb(e,{recursive:!0}),await _b(an.join(e,Qr),`${JSON.stringify(t,null,2)}
3
3
  `,"utf8")}i(Ei,"writeCheckpoint");async function Lt(e){try{await Eb(an.join(e,Qr))}catch{}}i(Lt,"deleteCheckpoint");async function _i(e){let t=e.context?.gitRoot,n=ct(e),r=ut(e,n),o;try{o=await Tb(r)}catch{return}let s=await Zr(t),a=Si(e),c=Date.now();for(let u of o){let l=an.join(r,u),d=an.join(l,Qr);try{let f=await Sb(d);if(!f.isFile())continue;let h=await ed(d,"utf8"),p=JSON.parse(h);if(!p||typeof p!="object")continue;let m=p;if(m.version!==1||typeof m.taskId!="string"||typeof m.createdAt!="string"||typeof m.gitCommit!="string"||typeof m.harnessProfile!="string"||m.sessionId!==void 0&&typeof m.sessionId!="string")continue;if(m.processId!==void 0||m.pid!==void 0){let k=m.processId??m.pid;if(typeof k!="number"||!Number.isFinite(k))continue}let b=m.processId??m.pid,g={version:1,taskId:m.taskId,...typeof m.sessionId=="string"&&m.sessionId.trim()?{sessionId:m.sessionId}:{},...typeof b=="number"&&Number.isFinite(b)?{processId:b}:{},createdAt:m.createdAt,gitCommit:m.gitCommit,objective:typeof m.objective=="string"?m.objective:"",harnessProfile:m.harnessProfile,currentRound:typeof m.currentRound=="number"?m.currentRound:1,completedWorkerIds:Array.isArray(m.completedWorkerIds)?m.completedWorkerIds.filter(k=>typeof k=="string"):[],scoutCompleted:m.scoutCompleted===!0},v=new Date(g.createdAt).getTime();if(Number.isNaN(v))continue;let y=c-f.mtimeMs;if(y>td||y<0){await Lt(l);continue}if(!Cb(g,a))continue;if(s&&g.gitCommit&&g.gitCommit!==s){await Lt(l);continue}let w=an.join(l,"managed-task.json"),T=await ed(w,"utf8"),S=JSON.parse(T);if(!S||typeof S!="object")continue;let C=S;if(!C.contract?.taskId||!C.evidence?.workspaceDir)continue;return{checkpoint:g,workspaceDir:l,managedTask:C}}catch{continue}}}i(_i,"findValidCheckpoint");import{mkdir as Ib,writeFile as Ae}from"node:fs/promises";import W from"node:path";function xi(e){let t=e?.runtime;return t?`${["# Runtime Execution Guide","","Use this guide to drive live verification against the runtime under test.","",t.cwd?`- Working directory: ${t.cwd}`:void 0,t.startupCommand?`- Startup command: ${t.startupCommand}`:void 0,t.readySignal?`- Ready signal: ${t.readySignal}`:void 0,t.baseUrl?`- Base URL: ${t.baseUrl}`:void 0,t.env&&Object.keys(t.env).length>0?`- Environment keys: ${Object.keys(t.env).join(", ")}`:void 0,"","Execution protocol:",t.startupCommand?"1. Start or confirm the runtime using the declared startup command before accepting the task.":"1. Confirm the target runtime is available before accepting the task.",t.readySignal||t.baseUrl?"2. Wait until the runtime is ready, using the ready signal or base URL when available.":"2. Confirm runtime readiness using the strongest observable signal you have.",t.uiFlows?.length?["3. Execute the declared UI flows:",...t.uiFlows.map((r,o)=>` ${o+1}. ${r}`)].join(`
4
4
  `):"3. Execute the critical user-facing flow when browser verification is required.",t.apiChecks?.length?["4. Run the declared API checks:",...t.apiChecks.map((r,o)=>` ${o+1}. ${r}`)].join(`
5
5
  `):void 0,t.dbChecks?.length?["5. Run the declared DB checks:",...t.dbChecks.map((r,o)=>` ${o+1}. ${r}`)].join(`