quantex-cli 0.20.0 → 0.21.1

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 (44) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/dist/agents-CXJLxw8j.mjs +1 -0
  4. package/dist/capabilities-BTOJ0kaS.mjs +5 -0
  5. package/dist/capabilities-Cl3gp573.mjs +1 -0
  6. package/dist/cli.mjs +1 -1
  7. package/dist/color-DSVKeNpv.mjs +6 -0
  8. package/dist/commands-CcjvWI3b.mjs +1 -0
  9. package/dist/{commands-B_Hju0lq.mjs → commands-DoiBUV3g.mjs} +1 -1
  10. package/dist/{config-CFYt99os.mjs → config-DttlCFVr.mjs} +1 -1
  11. package/dist/detect-Bqm_mjTq.mjs +1 -0
  12. package/dist/doctor-D2a_99Z8.mjs +3 -0
  13. package/dist/{ensure-DpX11qbo.mjs → ensure-CHdbUTxg.mjs} +1 -1
  14. package/dist/ensure-CS7zwh7w.mjs +1 -0
  15. package/dist/index.d.mts +55 -3
  16. package/dist/index.mjs +2 -2
  17. package/dist/{info-BUsquCrf.mjs → info-BsR4unMZ.mjs} +1 -1
  18. package/dist/inspect-6f2xR5k8.mjs +1 -0
  19. package/dist/{inspect-CihiIfvE.mjs → inspect-Dv2vJ28l.mjs} +1 -1
  20. package/dist/{install-YLaojYug.mjs → install-DfENrV-i.mjs} +1 -1
  21. package/dist/{list-D79BiyLS.mjs → list-Dy7KyZI_.mjs} +1 -1
  22. package/dist/{resolve-BhJphfVN.mjs → resolve-CL20XmE2.mjs} +1 -1
  23. package/dist/resolve-Cj4FpG-J.mjs +1 -0
  24. package/dist/schema-Pi2h96nT.mjs +1 -0
  25. package/dist/schema-Pm-_bDkf.mjs +3 -0
  26. package/dist/{uninstall-C0IfMGxA.mjs → uninstall-tPD85IT2.mjs} +1 -1
  27. package/dist/update-DxXBIcgR.mjs +1 -0
  28. package/dist/{update-DNz98nPV.mjs → update-Dybu18B9.mjs} +1 -1
  29. package/dist/{upgrade-C60CHTun.mjs → upgrade-wuryVVTl.mjs} +1 -1
  30. package/dist/{user-output-DoYIFFWA.mjs → user-output-lYZ8Muqt.mjs} +1 -1
  31. package/package.json +1 -1
  32. package/dist/agents-Egq0RCta.mjs +0 -1
  33. package/dist/capabilities-DVYVq0Kb.mjs +0 -1
  34. package/dist/capabilities-LjMH_zbA.mjs +0 -5
  35. package/dist/color-DEbCq7kh.mjs +0 -6
  36. package/dist/commands-CBYZqBF0.mjs +0 -1
  37. package/dist/detect-DWabXMgY.mjs +0 -1
  38. package/dist/doctor-Dp9VEmRS.mjs +0 -3
  39. package/dist/ensure-B-zpnaT-.mjs +0 -1
  40. package/dist/inspect-DO3c51A6.mjs +0 -1
  41. package/dist/resolve-D3cko00u.mjs +0 -1
  42. package/dist/schema-1VaAQRYe.mjs +0 -1
  43. package/dist/schema-C7v-CajU.mjs +0 -3
  44. package/dist/update-DgZD1TXs.mjs +0 -1
package/README.md CHANGED
@@ -23,6 +23,7 @@ Quantex is a `human-friendly + agent-friendly` lifecycle CLI for AI coding assis
23
23
  - Manage multiple AI coding assistant CLIs from one lifecycle command: install, ensure, inspect, update, uninstall, and run.
24
24
  - Designed for scripts and coding agents: stable `--json`, `--output ndjson`, `--non-interactive`, and `--dry-run` contracts for machine-readable automation.
25
25
  - Tracks real install sources: `update --all` groups updates by recorded source instead of guessing from PATH alone.
26
+ - Supports managed agent installs through available Bun, npm, Homebrew, Cargo, Deno, pip, uv, and winget providers.
26
27
  - Supports Quantex self-upgrade across Bun, npm, and standalone binary installs.
27
28
 
28
29
  ## Agent Quick Start
@@ -178,11 +179,13 @@ Note: `qtx upgrade` follows the registry actually used by the current Bun/npm se
178
179
  | Codex CLI | `qtx codex` | OpenAI's official AI coding assistant CLI |
179
180
  | Crush | `qtx crush` | Charmbracelet's terminal AI coding agent CLI |
180
181
  | Cursor CLI | `qtx cursor` | Cursor AI coding assistant CLI |
182
+ | Deep Code CLI | `qtx deepcode` | Deep Code's terminal coding agent CLI |
181
183
  | DeepSeek TUI | `qtx deepseek` | DeepSeek's terminal-native coding agent |
182
184
  | Devin for Terminal | `qtx devin` | Cognition's local coding agent CLI |
183
185
  | Droid | `qtx droid` | Factory AI software engineering agent CLI |
184
186
  | ForgeCode | `qtx forgecode` | Antinomy's AI coding assistant CLI |
185
187
  | Gemini CLI | `qtx gemini` | Google's open-source AI coding assistant CLI |
188
+ | Genie | `qtx genie` | Deno-distributed terminal LLM agent |
186
189
  | GitHub Copilot CLI | `qtx copilot` | GitHub Copilot command-line tool |
187
190
  | Goose | `qtx goose` | Block's open-source extensible AI agent CLI |
188
191
  | JCode | `qtx jcode` | High-performance coding agent harness for multi-session workflows |
@@ -193,6 +196,7 @@ Note: `qtx upgrade` follows the registry actually used by the current Bun/npm se
193
196
  | Mistral Vibe | `qtx vibe` | Mistral's open-source CLI coding assistant |
194
197
  | OpenHands CLI | `qtx openhands` | OpenHands' open-source software development agent CLI |
195
198
  | OpenCode | `qtx opencode` | Open-source AI coding CLI |
199
+ | oh-my-pi (OMP) | `qtx omp` | oh-my-pi coding agent CLI |
196
200
  | Pi | `qtx pi` | Minimal and extensible terminal coding agent |
197
201
  | Qoder CLI | `qtx qoder` | Qoder's official AI coding assistant CLI |
198
202
  | Qwen Code | `qtx qwen` | Qwen's AI coding assistant CLI |
package/README.zh-CN.md CHANGED
@@ -23,6 +23,7 @@ Quantex 是一个 `human-friendly + agent-friendly` 的 AI 编程助手 CLI life
23
23
  - 一个生命周期命令管理多个 AI 编程助手 CLI:安装、确保可用、查询状态、更新、卸载、启动。
24
24
  - 适合脚本和 agent 调用:支持 `--json`、`--output ndjson`、`--non-interactive`、`--dry-run` 等适合机器读取的稳定契约。
25
25
  - 记住真实安装来源:`update --all` 会优先按已记录来源分组更新,避免混合安装环境下误用更新方式。
26
+ - 支持通过可用的 Bun、npm、Homebrew、Cargo、Deno、pip、uv、winget provider 管理 agent 安装。
26
27
  - 支持 Quantex 自升级:Bun、npm、独立二进制安装来源都有对应升级路径。
27
28
 
28
29
  ## Agent 快速接入
@@ -178,11 +179,13 @@ qtx upgrade --channel beta
178
179
  | Codex CLI | `qtx codex` | OpenAI 官方 AI 编程助手 CLI |
179
180
  | Crush | `qtx crush` | Charmbracelet 终端 AI 编程 Agent CLI |
180
181
  | Cursor CLI | `qtx cursor` | Cursor AI 编程助手命令行工具 |
182
+ | Deep Code CLI | `qtx deepcode` | Deep Code 终端编程 Agent CLI |
181
183
  | DeepSeek TUI | `qtx deepseek` | DeepSeek 终端原生编程 Agent |
182
184
  | Devin for Terminal | `qtx devin` | Cognition 本地编程 Agent CLI |
183
185
  | Droid | `qtx droid` | Factory AI 软件工程 Agent CLI |
184
186
  | ForgeCode | `qtx forgecode` | Antinomy AI 编程助手 CLI |
185
187
  | Gemini CLI | `qtx gemini` | Google 开源 AI 编程助手 CLI |
188
+ | Genie | `qtx genie` | 通过 Deno 分发的终端 LLM agent |
186
189
  | GitHub Copilot CLI | `qtx copilot` | GitHub Copilot 命令行工具 |
187
190
  | Goose | `qtx goose` | Block 开源可扩展 AI Agent CLI |
188
191
  | JCode | `qtx jcode` | 面向多 session 工作流的高性能编程 Agent harness |
@@ -193,6 +196,7 @@ qtx upgrade --channel beta
193
196
  | Mistral Vibe | `qtx vibe` | Mistral 开源终端编程助手 |
194
197
  | OpenHands CLI | `qtx openhands` | OpenHands 开源软件开发 Agent CLI |
195
198
  | OpenCode | `qtx opencode` | 开源 AI 编程 CLI |
199
+ | oh-my-pi (OMP) | `qtx omp` | oh-my-pi coding agent CLI |
196
200
  | Pi | `qtx pi` | 极简可扩展的终端编程 Agent |
197
201
  | Qoder CLI | `qtx qoder` | Qoder 官方 AI 编程助手 CLI |
198
202
  | Qwen Code | `qtx qwen` | Qwen AI 编程助手 CLI |
@@ -0,0 +1 @@
1
+ import{a as e,c as t,d as n,i as r,l as i,m as a,n as o,o as s,p as ee,r as te,s as ne,t as c,u as re}from"./detect-Bqm_mjTq.mjs";import{B as ie,G as l,K as u,M as ae,O as d,P as f,R as oe,U as p,V as se,W as m,Y as h,_ as ce,b as le,d as ue,et as de,f as fe,g as pe,h as me,m as he,p as ge,v as _e,y as ve,z as ye}from"./color-DSVKeNpv.mjs";import be from"node:process";const xe={binary:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!1,canUpdate:!1,lifecycle:`unmanaged`},brew:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},bun:{canInstall:!0,canLookupLatestVersion:!0,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},cargo:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},deno:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},mise:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},npm:{canInstall:!0,canLookupLatestVersion:!0,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},pip:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},uv:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!0,canUpdate:!0,lifecycle:`managed`},script:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!1,canUpdate:!1,lifecycle:`unmanaged`},winget:{canInstall:!0,canLookupLatestVersion:!1,canUninstall:!0,canUpdate:!0,lifecycle:`managed`}};function g(e){return xe[e]}function _(e){return g(e).lifecycle===`managed`}function v(e){return g(e).lifecycle}function y(e){return g(e).canUpdate}function Se(e){return g(e).canUninstall}function b(e){return g(e).canLookupLatestVersion}function x(e,t){return e?t===`cask`?` (${e} cask)`:t===`id`?` (${e} id)`:` (${e})`:``}function S(e,t){if(t.packageName)return t.packageName;if(t.type===`cargo`)return e.packages?.cargo;if(t.type===`deno`)return e.packages?.deno;if(t.type===`mise`)return e.packages?.mise;if(t.type===`pip`)return e.packages?.pip;if(t.type===`uv`)return e.packages?.uv;if(t.type===`bun`||t.type===`npm`)return e.packages?.npm}function C(e){return e?y(e.installType):!1}function w(e,t){return C(t)||!!e.selfUpdate}function Ce(e){return!!e&&b(e.installType)}function we(e){return e.length>0&&e.every(e=>b(e.type))}function Te(e){return _(e.type)?`${v(e.type)}/${e.type}${x(e.packageName,e.packageTargetKind)}`:e.type===`script`?`unmanaged/script`:`unmanaged/binary`}function Ee(e){return e?_(e.installType)?`managed via ${e.installType}${x(e.packageName,e.packageTargetKind)}`:e.installType===`script`?`script installer`:`binary installer`:`detected in PATH`}function De(e,t){let n=Fe({agent:e,installedState:t,methods:[]});return n===`managed`?`managed update`:n===`self-update`?`command update`:`manual update`}function Oe(e,t){if(t.type===`bun`){let n=S(e,t);return n?`bun add -g ${n}`:``}if(t.type===`npm`){let n=S(e,t);return n?`npm i -g ${n}`:``}if(t.type===`brew`)return t.packageName?t.packageTargetKind===`cask`?`brew install --cask ${t.packageName}`:`brew install ${t.packageName}`:``;if(t.type===`cargo`){let n=S(e,t);return n?[`cargo`,`install`,n,...t.packageInstallArgs??[]].join(` `):``}if(t.type===`deno`){let n=S(e,t);return n?[`deno`,`install`,`--global`,...t.packageInstallArgs??[],n].join(` `):``}if(t.type===`mise`){let n=S(e,t);return n?`mise use --global ${n}`:``}if(t.type===`pip`){let n=S(e,t);return n?`pip install ${n}`:``}if(t.type===`uv`){let n=S(e,t);return n?[`uv`,`tool`,`install`,n,...t.packageInstallArgs??[]].join(` `):``}return t.type===`winget`?t.packageName?`winget install --id ${t.packageName} -e`:``:t.command??``}function ke(e,t,n){if(t)return Ce(t)&&(t.packageName||e.packages?.npm)||void 0;if(!(!e.packages?.npm||!we(n)))return e.packages.npm}function Ae(e,t){let n=je(t);if(n){let t=e.find(e=>e.type===n);if(t)return t}if(e.length!==1)return;let[r]=e;if(!(r.type!==`script`&&r.type!==`binary`))return r}function je(e){if(!e)return;let t=e.replaceAll(`\\`,`/`);if(t.includes(`/.bun/bin/`)||t.includes(`/.bun/install/global/`))return`bun`;if(t.includes(`/.local/share/mise/shims/`)||t.includes(`/.mise/shims/`))return`mise`;if(t.includes(`/node_modules/.bin/`)||t.includes(`/node_modules/`))return`npm`}function T(e){if(e.installedState)return _(e.installedState.installType)?e.installedState.installType:void 0;for(let t of e.methods)if(_(t.type)&&y(t.type))return t.type}const Me={strategy:`managed`,canHandle:e=>!!T(e),getManagedInstallerType:e=>T(e)},Ne={strategy:`self-update`,canHandle:e=>!C(e.installedState)&&!!e.agent.selfUpdate},E={strategy:`manual-hint`,canHandle:()=>!0},D=[Me,Ne,E];function Pe(e){return D.find(t=>t.canHandle(e))??E}function Fe(e){return Pe(e).strategy}function Ie(e){return w(e.agent,e.installedState)}async function O(e){let t=c(),n=typeof e==`function`?e(t):e;try{return be.platform===`win32`?await u(l([`powershell.exe`,`-Command`,n]))===0:await u(l([`sh`,`-c`,n]))===0}catch{return!1}}function Le(e){return e===`cask`?[`--cask`]:[]}async function k(e,t,n){try{return await u(l([`brew`,e,...Le(n),t]))===0}catch{return!1}}async function Re(e,t){return k(`install`,e,t)}async function A(e,t){return k(`upgrade`,e,t)}async function ze(e){for(let t of e)if(!await A(t.packageName,t.packageTargetKind))return!1;return!0}async function Be(e,t){return k(`uninstall`,e,t)}async function j(e,t,n=[]){try{return await u(l([`cargo`,e,t,...n]))===0}catch{return!1}}async function M(e,t){return j(`install`,e,t)}async function N(e,t){return M(e,[`--force`,...t??[]])}async function Ve(e){for(let t of e)if(!await N(t.packageName,t.packageInstallArgs))return!1;return!0}async function He(e){return j(`uninstall`,e)}async function P(e,t=[],n={}){let r=[`deno`,`install`,`--global`];n.force&&r.push(`--force`),r.push(...t,e);try{return await u(l(r))===0}catch{return!1}}async function Ue(e,t){return P(e,t)}async function F(e,t){return P(e,t,{force:!0})}async function We(e){for(let t of e)if(!await F(t.packageName,t.packageInstallArgs))return!1;return!0}async function Ge(e){try{return await u(l([`deno`,`uninstall`,`--global`,e]))===0}catch{return!1}}async function I(e,t=!1){try{return await u(l([`mise`,`use`,`--global`,...t?[`--force`]:[],e]))===0}catch{return!1}}async function Ke(e){return I(e)}async function L(e){return I(e,!0)}async function qe(e){for(let t of e)if(!await L(t.packageName))return!1;return!0}async function Je(e){try{return await u(l([`mise`,`unuse`,`--global`,e]))===0}catch{return!1}}async function Ye(e){try{let{exitCode:t,stdout:n}=await p(m([`mise`,`ls`,`--installed`,`--json`,e],{stdio:[`ignore`,`pipe`,`ignore`]}));return t===0?Xe(n,e):void 0}catch{return}}function Xe(e,t){try{let n=JSON.parse(e);if(!R(n))return;let r=Ze(n,t),i=r?n[r]:void 0;if(!Array.isArray(i))return;for(let e of i)if(R(e)&&typeof e.version==`string`&&e.version.length>0)return e.version;return}catch{return}}function Ze(e,t){if(Array.isArray(e[t]))return t;let n=t.split(`:`).pop()?.split(`/`).pop();if(n)return Object.keys(e).find(t=>t===n&&Array.isArray(e[t]))}function R(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let z=null;async function Qe(){if(z)return z;for(let e of[[`pip`],[`pip3`],[`python`,`-m`,`pip`],[`python3`,`-m`,`pip`]])try{let{exitCode:t}=await p(m([...e,`--version`]));if(t===0)return z=e,e}catch{}return z=[`pip`],z}async function B(e){try{return await u(l([...await Qe(),...e]))===0}catch{return!1}}async function $e(e){return B([`install`,e])}async function V(e){return B([`install`,`--upgrade`,e])}async function et(e){if(e.length===0)return!0;for(let t of e)if(!await V(t.packageName))return!1;return!0}async function tt(e){return B([`uninstall`,`-y`,e])}async function H(e,t,n=[]){try{return await u(l([`uv`,`tool`,e,t,...n]))===0}catch{return!1}}async function nt(e,t){return H(`install`,e,t)}async function U(e,t){return H(`upgrade`,e,t)}async function rt(e){for(let t of e)if(!await U(t.packageName,t.packageInstallArgs))return!1;return!0}async function it(e){try{return await u(l([`uv`,`tool`,`uninstall`,e]))===0}catch{return!1}}async function at(e){try{let{exitCode:t,stdout:n}=await p(m([`uv`,`tool`,`list`],{stdio:[`ignore`,`pipe`,`ignore`]}));return t===0?ot(n,e):void 0}catch{return}}function ot(e,t){let n=W(t);for(let t of e.split(/\r?\n/)){let e=t.trim(),r=/^(\S+)\s+v([^\s]+)/.exec(e);if(!r)continue;let[,i,a]=r;if(W(i)===n)return a}}function W(e){return e.toLowerCase().replaceAll(/[-_.]+/g,`-`)}async function G(e,t){try{return await u(l([`winget`,e,`--id`,t,`-e`]))===0}catch{return!1}}async function st(e){return G(`install`,e)}async function K(e){return G(`upgrade`,e)}async function ct(e){for(let t of e)if(!await K(t.packageName))return!1;return!0}async function lt(e){return G(`uninstall`,e)}const ut={brew:{type:`brew`,isAvailable:async()=>te(),install:async(e,t)=>Re(e,t),uninstall:async(e,t)=>Be(e,t),update:async(e,t)=>A(e,t),updateMany:async e=>ze(e)},bun:{type:`bun`,getInstalledVersion:async e=>pe(e),isAvailable:async()=>r(),install:async e=>ce(e),uninstall:async e=>_e(e),update:async(e,t,n)=>ve(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>le(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},cargo:{type:`cargo`,isAvailable:async()=>e(),install:async(e,t,n)=>M(e,n),uninstall:async e=>He(e),update:async(e,t,n)=>N(e,n?.packageInstallArgs),updateMany:async e=>Ve(e.map(e=>({packageInstallArgs:e.packageInstallArgs,packageName:e.packageName})))},deno:{type:`deno`,isAvailable:async()=>s(),install:async(e,t,n)=>Ue(e,n),uninstall:async(e,t,n)=>Ge(n?.binaryName??e),update:async(e,t,n)=>F(e,n?.packageInstallArgs),updateMany:async e=>We(e.map(e=>({binaryName:e.binaryName,packageInstallArgs:e.packageInstallArgs,packageName:e.packageName})))},mise:{type:`mise`,getInstalledVersion:async e=>Ye(e),isAvailable:async()=>ne(),install:async e=>Ke(e),uninstall:async e=>Je(e),update:async e=>L(e),updateMany:async e=>qe(e.map(e=>({packageName:e.packageName})))},npm:{type:`npm`,getInstalledVersion:async e=>ue(e),isAvailable:async()=>t(),install:async e=>fe(e),uninstall:async e=>ge(e),update:async(e,t,n)=>he(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>me(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},pip:{type:`pip`,isAvailable:async()=>i(),install:async e=>$e(e),uninstall:async e=>tt(e),update:async e=>V(e),updateMany:async e=>et(e.map(e=>({packageName:e.packageName})))},uv:{type:`uv`,getInstalledVersion:async e=>at(e),isAvailable:async()=>re(),install:async(e,t,n)=>nt(e,n),uninstall:async e=>it(e),update:async(e,t,n)=>U(e,n?.packageInstallArgs),updateMany:async e=>rt(e.map(e=>({packageInstallArgs:e.packageInstallArgs,packageName:e.packageName})))},winget:{type:`winget`,isAvailable:async()=>n(),install:async e=>st(e),uninstall:async e=>lt(e),update:async e=>K(e),updateMany:async e=>ct(e.map(e=>({packageName:e.packageName})))}};function q(e){return ut[e]}const J={resource:`agent lifecycle`,scope:[`agent-lifecycle`]};async function dt(){return(await de()).defaultPackageManager}async function Y(){return{npmBunUpdateStrategy:(await de()).npmBunUpdateStrategy}}async function X(e){let t=c(),n=e.platforms[t];if(!n)return[];let r=await dt();return r?[...n.filter(e=>e.type===r),...n.filter(e=>e.type!==r)]:[...n]}async function Z(e,t,n,r,i,a,o){let s=q(e);return await s.isAvailable()?a===`install`?s.install(t,i,r):a===`update`?s.update(t,i,{binaryName:n,npmBunUpdateStrategy:o,packageInstallArgs:r}):s.uninstall(t,i,{binaryName:n}):!1}async function ft(e,t,n,r){if(_(t.type)){let i=S(e,t);return i?Z(t.type,i,t.binaryName??e.binaryName,t.packageInstallArgs,t.packageTargetKind,n,r):!1}return n===`update`&&!y(t.type)||!t.command?!1:O(t.command)}async function pt(e,t,n){return _(e.installType)?e.packageName?Z(e.installType,e.packageName,e.binaryName,e.packageInstallArgs,e.packageTargetKind,t,n):!1:t!==`install`||!e.command?!1:O(e.command)}async function mt(e){if(!e.selfUpdate)return!1;let t=[e.selfUpdate.command,...e.selfUpdate.fallbackCommands??[]];for(let e of t)if(await O(e.join(` `)))return!0;return!1}async function Q(e,t){let n={agentName:e.name,installType:t.type,packageName:S(e,t),packageTargetKind:t.packageTargetKind,command:`command`in t?t.command:void 0},r=t.binaryName??(t.type===`deno`?e.binaryName:void 0);return r&&(n.binaryName=r),t.packageInstallArgs?.length&&(n.packageInstallArgs=t.packageInstallArgs),await f(n),n}async function ht(e,t){return h(J,async()=>Q(e,t))}async function gt(e){return h(J,async()=>{let t=await X(e);for(let n of t)if(await ft(e,n,`install`))return{success:!0,installedState:await Q(e,n)};return{success:!1}})}async function _t(e,t){return h(J,async()=>{let{npmBunUpdateStrategy:n}=await Y(),r=await X(e);if(t&&await pt(t,`update`,n))return await f(t),{success:!0,installedState:t};if(!t){for(let t of r)if(await ft(e,t,`update`,n))return{success:!0,installedState:await Q(e,t)}}return await mt(e)?{success:!0}:{success:!1}})}async function vt(e,t){return h(J,async()=>{let n=[...new Map(t.filter(e=>e.packageName).map(e=>[`${e.packageTargetKind??`package`}:${e.packageName}:${e.packageInstallArgs?.join(` `)??``}`,e])).values()];if(n.length===0)return!1;let r=q(e);return await r.isAvailable()?r.updateMany(n,await Y()):!1})}async function yt(e,t,n){let r=q(e);if(r.getInstalledVersion&&await r.isAvailable())return r.getInstalledVersion(t,n)}async function bt(e){return h(J,async()=>{let t=await d(e.name);if(!t)return!1;let n=await pt(t,`uninstall`);return n&&await ae(e.name),n})}async function $(e){let[t,n,r]=await Promise.all([X(e),d(e.name),o(e.binaryName)]),[i,a,s]=await Promise.all([r?St(e,n):Promise.resolve(void 0),r?oe(e.binaryName):Promise.resolve(void 0),Ct(e,n,t)]);return{agent:e,methods:t,installedState:n,inPath:r,installedVersion:i,latestVersion:s,binaryPath:a,resolvedBinaryPath:await se(a),sourceLabel:Ee(n),updateLabel:De(e,n),lifecycle:n?v(n.installType):`unmanaged`}}async function xt(e){return Promise.all(e.map($))}async function St(e,t){if(t&&_(t.installType)&&t.packageName){let e=await yt(t.installType,t.packageName,t.packageTargetKind);if(e)return e}return ye(e.binaryName,e.versionProbe)}async function Ct(e,t,n){let r=ke(e,t,n);if(r)return ie(r)}function wt(e){return ee(e)}async function Tt(e){let t=wt(e);if(t)return{agent:t,inspection:await $(t)}}async function Et(){return xt(a())}export{Se as C,_ as D,g as E,b as S,v as T,w as _,xt as a,Ae as b,ht as c,vt as d,q as f,Pe as g,Fe as h,$ as i,bt as l,Ie as m,wt as n,X as o,D as p,Tt as r,gt as s,Et as t,_t as u,Oe as v,y as w,S as x,Te as y};
@@ -0,0 +1,5 @@
1
+ import{a as e,c as t,d as n,i as r,l as i,m as a,o,r as s,s as c,t as l,u}from"./detect-Bqm_mjTq.mjs";import{a as d,r as f,s as p,t as m}from"./color-DSVKeNpv.mjs";import h from"node:process";async function g(){let[m,g,y,b,x,S,C,w,T,E]=await Promise.all([r(),t(),s(),e(),o(),c(),i(),u(),n(),p()]);return d(f({action:`capabilities`,data:{agents:a().map(e=>e.name),features:{assumeYes:!0,cacheBypass:!0,cacheRefresh:!0,channels:[`stable`,`beta`],colorModes:[`auto`,`always`,`never`],dryRun:!0,execInstallPolicies:[`never`,`if-missing`,`always`],freshnessMetadata:!0,idempotencyKey:!0,logLevels:[`silent`,`error`,`warn`,`info`,`debug`],quietLogs:!0,selfUpgrade:E.canAutoUpdate,timeout:!0},installers:{brew:{available:y,reason:y?void 0:_(`brew`)},bun:{available:m,reason:m?void 0:_(`bun`)},cargo:{available:b,reason:b?void 0:_(`cargo`)},deno:{available:x,reason:x?void 0:_(`deno`)},mise:{available:S,reason:S?void 0:_(`mise`)},npm:{available:g,reason:g?void 0:_(`npm`)},pip:{available:C,reason:C?void 0:_(`pip`)},uv:{available:w,reason:w?void 0:_(`uv`)},winget:{available:T,reason:T?void 0:_(`winget`)}},outputModes:[`human`,`json`,`ndjson`],platform:{arch:h.arch,os:l()}},target:{kind:`system`,name:`capabilities`}}),v)}function _(e){return e===`winget`&&h.platform!==`win32`||e===`brew`&&h.platform===`win32`?`not-on-platform`:`not-found`}function v(e){e.data&&(console.log(m.bold(`
2
+ Quantex Capabilities
3
+ `)),console.log(` Platform: ${e.data.platform.os}/${e.data.platform.arch}`),console.log(` Output Modes: ${e.data.outputModes.join(`, `)}`),console.log(` Agents: ${e.data.agents.join(`, `)}`),console.log(m.bold(`
4
+ Installers:`)),console.log(` bun: ${y(e.data.installers.bun)}`),console.log(` npm: ${y(e.data.installers.npm)}`),console.log(` brew: ${y(e.data.installers.brew)}`),console.log(` cargo: ${y(e.data.installers.cargo)}`),console.log(` deno: ${y(e.data.installers.deno)}`),console.log(` mise: ${y(e.data.installers.mise)}`),console.log(` pip: ${y(e.data.installers.pip)}`),console.log(` uv: ${y(e.data.installers.uv)}`),console.log(` winget: ${y(e.data.installers.winget)}`),console.log(m.bold(`
5
+ Features:`)),console.log(` --yes: ${e.data.features.assumeYes?`yes`:`no`}`),console.log(` cache-refresh: ${e.data.features.cacheRefresh?`yes`:`no`}`),console.log(` color-modes: ${e.data.features.colorModes.join(`, `)}`),console.log(` no-cache: ${e.data.features.cacheBypass?`yes`:`no`}`),console.log(` dry-run: ${e.data.features.dryRun?`yes`:`no`}`),console.log(` freshness-metadata: ${e.data.features.freshnessMetadata?`yes`:`no`}`),console.log(` self-upgrade: ${e.data.features.selfUpgrade?`yes`:`no`}`),console.log(` idempotency-key: ${e.data.features.idempotencyKey?`yes`:`no`}`),console.log(` log-levels: ${e.data.features.logLevels.join(`, `)}`),console.log(` quiet-logs: ${e.data.features.quietLogs?`yes`:`no`}`),console.log(` timeout: ${e.data.features.timeout?`yes`:`no`}`),console.log(` channels: ${e.data.features.channels.join(`, `)}`),console.log(` exec-install-policy: ${e.data.features.execInstallPolicies.join(`, `)}`),console.log())}function y(e){return e.available?m.green(`available`):m.red(e.reason??`not-found`)}export{g as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./capabilities-BTOJ0kaS.mjs";export{e as capabilitiesCommand};
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{r as e,s as t,v as n,y as r}from"./agents-Egq0RCta.mjs";import{f as i}from"./detect-DWabXMgY.mjs";import{G as a,H as o,I as s,J as c,K as l,T as u,X as d,a as f,at as p,ct as m,i as h,it as g,k as _,n as v,ot as y,r as ee,s as te,st as b,t as x}from"./color-DEbCq7kh.mjs";import{a as S,i as C,n as w,o as T,r as E,t as ne}from"./user-output-DoYIFFWA.mjs";import{n as re,t as D}from"./errors-DCtNasuC.mjs";import O from"node:process";import{mkdir as k,readFile as A,rm as ie,writeFile as ae}from"node:fs/promises";import{join as j}from"node:path";import{program as M}from"commander";import oe from"prompts";function N(){return j(d(),`idempotency`)}function P(e){return j(N(),`${L(e)}.json`)}async function F(e){try{let t=JSON.parse(await A(P(e),`utf8`));if(Date.parse(t.expiresAt)<=Date.now()){await ie(P(e),{force:!0});return}return t}catch{return}}async function I(e,t){await k(N(),{recursive:!0});let n=new Date().toISOString(),r=new Date(Date.now()+864e5).toISOString(),i={action:t.action,createdAt:n,expiresAt:r,result:t.result,target:t.target};await ae(P(e),`${JSON.stringify(i,null,2)}\n`,`utf8`)}function L(e){return e.replace(/[^\w.-]/g,`_`)}const R=new Set([`doctor`,`upgrade`]);async function z(e){if(!e.ok||R.has(e.action))return;let t=p();if(t.outputMode!==`human`||t.quiet)return;let n=await te();if(!n.latestVersion||!o(n.latestVersion,n.currentVersion))return;let r=await _(),i=Date.now();if(B(r.updateNoticeVersion,r.updateNoticeAt,n.latestVersion,i))return;let a=n.canAutoUpdate?"Run `quantex upgrade`.":"Run `quantex doctor` for source-specific update steps.";C(x.yellow(`Quantex CLI ${n.latestVersion} is available (current ${n.currentVersion}). ${a}`)),await s(n.latestVersion,new Date(i).toISOString())}function B(e,t,n,r){if(!e||!t||e!==n)return!1;let i=Date.parse(t);return Number.isNaN(i)?!1:r-i<864e5}async function V(e){let t=await W(e.action,e.target);if(t)return t;let n=p().timeoutMs;if(n===void 0)return K(e,()=>e.run().then(t=>H(e.action,e.target,t)));let r;try{let t=new Promise(t=>{r=setTimeout(()=>{g(),h({action:e.action,data:{reason:`timeout`,timeoutMs:n},target:e.target,type:`cancelled`},{force:!0}),t(f(v({action:e.action,error:{code:`TIMEOUT`,details:{timeoutMs:n},message:`Command timed out after ${n}ms.`},target:e.target}),U,{force:!0}))},n)});return await K(e,async()=>{let n=await Promise.race([e.run(),t]);return r!==void 0&&(clearTimeout(r),r=void 0),H(e.action,e.target,n)})}finally{r&&clearTimeout(r)}}async function H(e,t,n){let r=await G(e,t,n);try{await z({action:e,ok:r.ok})}catch{}return r}function U(e){e.error&&console.error(x.red(e.error.message))}async function W(e,t){let n=p();if(!n.idempotencyKey)return;let r=await F(n.idempotencyKey);if(!r)return;if(r.action!==e)return f(v({action:e,error:{code:`INVALID_ARGUMENT`,details:{existingAction:r.action,idempotencyKey:n.idempotencyKey},message:`Idempotency key ${n.idempotencyKey} was already used for ${r.action}.`},target:t}),U,{force:!0});let i={...r.result,meta:{...r.result.meta,mode:n.outputMode,runId:n.runId,timestamp:new Date().toISOString()}};return f(i,U,{force:!0}),i}async function G(e,t,n){let r=p();return r.idempotencyKey&&await I(r.idempotencyKey,{action:e,result:n,target:t}),n}async function K(e,t){let n;try{let r=new Promise(t=>{let r=n=>{g(),h({action:e.action,data:{reason:`signal`,signal:n},target:e.target,type:`cancelled`},{force:!0}),t(f(v({action:e.action,error:{code:`CANCELLED`,details:{signal:n},message:`Command cancelled by ${n}.`},target:e.target}),U,{force:!0}))},i=()=>r(`SIGINT`),a=()=>r(`SIGTERM`);O.once(`SIGINT`,i),O.once(`SIGTERM`,a),n=()=>{O.off(`SIGINT`,i),O.off(`SIGTERM`,a)}});return await Promise.race([t(),r])}finally{n?.()}}async function q(t,n,r={}){let i=await e(t);if(!i)return Y({agent:{name:t},errorCode:`AGENT_NOT_FOUND`,errorMessage:`Unknown agent: ${t}`,execution:{args:n,installPolicy:r.install??`prompt`,installed:!1,interactive:!1,launched:!1}}),D(`AGENT_NOT_FOUND`);let{agent:o,inspection:s}=i,c=r.nonInteractive?!1:p().interactive,l=r.assumeYes??ne(),u=r.dryRun??w(),d=r.install??`prompt`;if(!s.inPath){if(d===`never`)return Y({agent:{binaryName:o.binaryName,displayName:o.displayName,name:o.name},errorCode:`AGENT_NOT_INSTALLED`,errorMessage:`${o.displayName} is not installed.`,execution:{args:n,installGuidance:J(o,s.methods,n),installPolicy:d,installed:!1,interactive:c,launched:!1}}),D(`AGENT_NOT_INSTALLED`);if(d===`if-missing`||d===`always`){if(u?T(x.cyan(`Dry run: would install ${o.displayName}.`)):C(x.cyan(`Installing ${o.displayName}...`)),!(await X(o,u)).success)return E(x.red(`Failed to install ${o.displayName}.`)),1}else if(c){if(!(l||u?{install:!0}:await oe({type:`confirm`,name:`install`,message:`${o.displayName} is not installed. Would you like to install it?`,initial:!0})).install)return S(x.yellow(`Installation cancelled.`)),1;if(u?T(x.cyan(`Dry run: would install ${o.displayName}.`)):C(x.cyan(`Installing ${o.displayName}...`)),!(await X(o,u)).success)return E(x.red(`Failed to install ${o.displayName}.`)),1}else return Y({agent:{binaryName:o.binaryName,displayName:o.displayName,name:o.name},errorCode:`INTERACTION_REQUIRED`,errorMessage:`${o.displayName} is not installed and interactive installation is disabled.`,execution:{args:n,installGuidance:J(o,s.methods,n),installPolicy:d,installed:!1,interactive:c,launched:!1}}),D(`INTERACTION_REQUIRED`)}if(u)return se({agent:{binaryName:o.binaryName,displayName:o.displayName,name:o.name},execution:{args:n,installPolicy:d,installed:!0,interactive:c,launched:!1},message:`Dry run: would run ${[o.binaryName,...n].join(` `)}`}),0;try{return await ce(a([o.binaryName,...n]),o.displayName)}catch(e){return E(x.red(`Failed to launch ${o.displayName}: ${e instanceof Error?e.message:String(e)}`)),1}}function J(e,t,i){return{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t.map(t=>({command:n(e,t),label:r(t),type:t.type})).filter(e=>e.command),suggestedAction:`rerun-with-install-policy`,suggestedEnsureCommand:`quantex ensure ${e.name}`,suggestedExecCommand:[`quantex`,`exec`,e.name,`--install`,`if-missing`,`--`,...i].join(` `)}}function Y(e){if(p().outputMode===`human`){E(x.red(e.errorMessage));let t=e.execution.installGuidance;t&&(T(x.dim(`Try: ${t.suggestedEnsureCommand}`)),T(x.dim(`Or: ${t.suggestedExecCommand}`)));return}f(v({action:`exec`,data:{agent:e.agent,execution:e.execution},error:{code:e.errorCode,details:e.execution.installGuidance,message:e.errorMessage},target:{kind:`agent`,name:e.agent.name}}),()=>{})}function se(e){if(p().outputMode===`human`){T(x.cyan(e.message));return}f(ee({action:`exec`,data:{agent:e.agent,execution:e.execution},target:{kind:`agent`,name:e.agent.name}}),()=>{})}async function X(e,n=w()){if(n)return{success:!0};try{return await t(e)}catch(t){return c(t)?(E(x.red(t.message)),{success:!1}):(E(x.red(`Failed to install ${e.displayName}: ${t instanceof Error?t.message:String(t)}`)),{success:!1})}}async function ce(e,t){let{timeoutMs:n}=p(),r,i;try{let a=new Promise(e=>{let n=n=>{g(),E(x.red(`${t} was cancelled by ${n}.`)),e(D(`CANCELLED`))},i=()=>n(`SIGINT`),a=()=>n(`SIGTERM`);O.once(`SIGINT`,i),O.once(`SIGTERM`,a),r=()=>{O.off(`SIGINT`,i),O.off(`SIGTERM`,a)}}),o=n===void 0?void 0:new Promise(e=>{i=setTimeout(()=>{g(),E(x.red(`${t} timed out after ${n}ms.`)),e(D(`TIMEOUT`))},n)});return await Promise.race([l(e),a,...o?[o]:[]])}finally{i&&clearTimeout(i),r?.()}}M.name(`quantex`).description(`统一的 AI Agent CLI 管理工具`).option(`--json`,`Output structured JSON`).option(`--output <mode>`,`Output mode: human, json, or ndjson`).option(`--non-interactive`,`Disable interactive prompts and confirmations`).option(`--yes`,`Automatically accept safe default confirmations`).option(`--quiet`,`Suppress non-essential human logs`).option(`--color <mode>`,`Color mode: auto, always, or never`).option(`--log-level <level>`,`Log level: silent, error, warn, info, or debug`).option(`--dry-run`,`Show what would happen without making changes`).option(`--refresh`,`Refresh cached version metadata before returning results`).option(`--no-cache`,`Bypass the local version cache for this command`).option(`--run-id <id>`,`Attach a run id to structured output and logs`).option(`--idempotency-key <key>`,`Deduplicate repeated mutating requests by client-supplied key`).option(`--timeout <duration>`,`Abort a command after the given duration, e.g. 500ms, 30s, 5m`).version(u()),M.hook(`preAction`,(e,t)=>{try{m(b(t.optsWithGlobals()))}catch(e){console.log(x.red(e instanceof Error?e.message:String(e))),O.exit(2)}}),M.hook(`postAction`,()=>{y()}),M.command(`schema`).argument(`[command]`,`Optional command name`).description(`查看结构化输出 schema`).action(async e=>{let{schemaCommand:t}=await import(`./schema-1VaAQRYe.mjs`);O.exitCode=await $({action:`schema`,run:()=>t(e),target:{kind:`system`,name:`schema`}})}),M.command(`commands`).description(`查看命令目录与稳定能力`).action(async()=>{let{commandsCommand:e}=await import(`./commands-CBYZqBF0.mjs`);O.exitCode=await $({action:`commands`,run:()=>e(),target:{kind:`system`,name:`commands`}})}),M.command(`capabilities`).description(`查看当前环境与 surface 能力`).action(async()=>{let{capabilitiesCommand:e}=await import(`./capabilities-DVYVq0Kb.mjs`);O.exitCode=await $({action:`capabilities`,run:()=>e(),target:{kind:`system`,name:`capabilities`}})}),M.command(`inspect <agent>`).description(`查看 agent 结构化状态`).action(async e=>{let{inspectCommand:t}=await import(`./inspect-DO3c51A6.mjs`);O.exitCode=await $({action:`inspect`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`resolve <agent>`).description(`解析 agent 可执行入口`).action(async e=>{let{resolveCommand:t}=await import(`./resolve-D3cko00u.mjs`);O.exitCode=await $({action:`resolve`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`install <agents...>`).alias(`i`).description(`安装指定 agent`).action(async e=>{let{installCommand:t}=await import(`./install-YLaojYug.mjs`);O.exitCode=await $({action:`install`,run:()=>t(e),target:e.length===1?{kind:`agent`,name:e[0]}:{kind:`agent`}})}),M.command(`ensure <agent>`).description(`确保指定 agent 已安装`).action(async e=>{let{ensureCommand:t}=await import(`./ensure-B-zpnaT-.mjs`);O.exitCode=await $({action:`ensure`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`exec <agent>`).description(`以显式策略启动 agent`).allowUnknownOption().option(`--install <policy>`,`Install policy: never, if-missing, always`,`never`).argument(`[args...]`,`Arguments passed through to the agent`).action(async(e,t,n,r)=>{let i=n.install;if(i!==`never`&&i!==`if-missing`&&i!==`always`){console.log(x.red(`Unknown install policy: ${i}`)),O.exitCode=2;return}let a=ue(r);O.exitCode=await q(e,a.length>0?a:t,{install:i,nonInteractive:r.optsWithGlobals().nonInteractive})}),M.command(`update`).argument(`[agent]`,`Agent name or alias`).option(`--all`,`更新所有已安装的 agent`).alias(`u`).description(`更新指定 agent`).action(async(e,t)=>{let{updateCommand:n}=await import(`./update-DNz98nPV.mjs`);O.exitCode=await $({action:`update`,run:()=>n(e,t.all??!1),target:{kind:`agent`,name:e}})}),M.command(`uninstall <agent>`).alias(`rm`).description(`卸载指定 agent`).action(async e=>{let{uninstallCommand:t}=await import(`./uninstall-C0IfMGxA.mjs`);O.exitCode=await $({action:`uninstall`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`list`).alias(`ls`).description(`列出所有支持的 agent`).action(async()=>{let{listCommand:e}=await import(`./list-D79BiyLS.mjs`);O.exitCode=await $({action:`list`,run:()=>e(),target:{kind:`system`,name:`agents`}})}),M.command(`info <agent>`).description(`查看 agent 详细信息`).action(async e=>{let{infoCommand:t}=await import(`./info-BUsquCrf.mjs`);O.exitCode=await $({action:`info`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`config`).argument(`[action]`,`Action: get, set, reset`).argument(`[key]`,`Config key`).argument(`[value]`,`Config value`).description(`配置管理`).action(async(e,t,n)=>{let{configCommand:r}=await import(`./config-CFYt99os.mjs`);O.exitCode=await $({action:`config`,run:()=>r(e,t,n),target:{kind:`config`,name:t}})}),M.command(`upgrade`).description(`升级 Quantex CLI`).option(`--channel <channel>`,`Update channel: stable or beta`).option(`--check`,`Only check whether an update is available`).action(async e=>{let{upgradeCommand:t}=await import(`./upgrade-C60CHTun.mjs`);O.exitCode=await $({action:`upgrade`,run:()=>t({channel:e.channel===`beta`?`beta`:void 0,check:e.check??!1}),target:{kind:`self`,name:`quantex`}})}),M.command(`doctor`).description(`检查环境`).action(async()=>{let{doctorCommand:e}=await import(`./doctor-Dp9VEmRS.mjs`);O.exitCode=await $({action:`doctor`,run:()=>e(),target:{kind:`system`,name:`doctor`}})});const le=new Set([...M.commands.map(e=>e.name()),...M.commands.flatMap(e=>e.aliases()),`help`,`--help`,`--version`,`-v`]),Z=Q(O.argv.slice(2),le);if(Z?.error&&(console.log(x.red(Z.error)),O.exit(2)),Z&&i(Z.agentName)){try{m(b({color:Z.color,dryRun:Z.dryRun,idempotencyKey:Z.idempotencyKey,logLevel:Z.logLevel,noCache:Z.noCache,nonInteractive:Z.nonInteractive,quiet:Z.quiet,refresh:Z.refresh,runId:Z.runId,timeout:Z.timeout,yes:Z.yes}))}catch(e){console.log(x.red(e instanceof Error?e.message:String(e))),O.exit(2)}try{let e=await q(Z.agentName,Z.agentArgs,{assumeYes:Z.yes,dryRun:Z.dryRun,nonInteractive:Z.nonInteractive});O.exit(e)}finally{y()}}M.parse();function ue(e){let t=e.processedArgs.at(-1);return Array.isArray(t)?t:e.args.slice(1)}function Q(e,t){let n=O.stdin.isTTY===!1||O.stdout.isTTY===!1,r,i=!1,a=0,o,s=!1,c,l=!1,u=!1,d,f=!1,p=!1,m,h,g=!1;for(;a<e.length;){let _=e[a];if(_===`--json`){s=!0,a+=1;continue}if(_===`--output`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--output requires a value`};d=t,a+=2;continue}if(_===`--non-interactive`){u=!0,a+=1;continue}if(_===`--yes`){g=!0,a+=1;continue}if(_===`--quiet`){f=!0,a+=1;continue}if(_===`--color`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--color requires a value`};r=t,a+=2;continue}if(_===`--log-level`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--log-level requires a value`};c=t,a+=2;continue}if(_===`--dry-run`){i=!0,a+=1;continue}if(_===`--refresh`){p=!0,a+=1;continue}if(_===`--no-cache`){l=!0,a+=1;continue}if(_===`--idempotency-key`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--idempotency-key requires a value`};o=t,a+=2;continue}if(_===`--run-id`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--run-id requires a value`};m=t,a+=2;continue}if(_===`--timeout`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--timeout requires a value`};h=t,a+=2;continue}return _.startsWith(`-`)||t.has(_)?void 0:s||d===`json`||d===`ndjson`||n&&d!==`human`?{agentArgs:[],agentName:``,error:`Structured output is not supported for shortcut agent execution yet. Use a management command instead.`}:{agentArgs:e.slice(a+1),agentName:_,color:r,dryRun:i,idempotencyKey:o,logLevel:c,noCache:l,nonInteractive:u,quiet:f,refresh:p,runId:m,timeout:h,yes:g}}}async function $(e){return re(await V(e))}export{};
2
+ import{r as e,s as t,v as n,y as r}from"./agents-CXJLxw8j.mjs";import{p as i}from"./detect-Bqm_mjTq.mjs";import{G as a,H as o,I as s,J as c,K as l,T as u,X as d,a as f,at as p,ct as m,i as h,it as g,k as _,n as v,ot as y,r as ee,s as te,st as b,t as x}from"./color-DSVKeNpv.mjs";import{a as S,i as C,n as w,o as T,r as E,t as ne}from"./user-output-lYZ8Muqt.mjs";import{n as re,t as D}from"./errors-DCtNasuC.mjs";import O from"node:process";import{mkdir as k,readFile as A,rm as ie,writeFile as ae}from"node:fs/promises";import{join as j}from"node:path";import{program as M}from"commander";import oe from"prompts";function N(){return j(d(),`idempotency`)}function P(e){return j(N(),`${L(e)}.json`)}async function F(e){try{let t=JSON.parse(await A(P(e),`utf8`));if(Date.parse(t.expiresAt)<=Date.now()){await ie(P(e),{force:!0});return}return t}catch{return}}async function I(e,t){await k(N(),{recursive:!0});let n=new Date().toISOString(),r=new Date(Date.now()+864e5).toISOString(),i={action:t.action,createdAt:n,expiresAt:r,result:t.result,target:t.target};await ae(P(e),`${JSON.stringify(i,null,2)}\n`,`utf8`)}function L(e){return e.replace(/[^\w.-]/g,`_`)}const R=new Set([`doctor`,`upgrade`]);async function z(e){if(!e.ok||R.has(e.action))return;let t=p();if(t.outputMode!==`human`||t.quiet)return;let n=await te();if(!n.latestVersion||!o(n.latestVersion,n.currentVersion))return;let r=await _(),i=Date.now();if(B(r.updateNoticeVersion,r.updateNoticeAt,n.latestVersion,i))return;let a=n.canAutoUpdate?"Run `quantex upgrade`.":"Run `quantex doctor` for source-specific update steps.";C(x.yellow(`Quantex CLI ${n.latestVersion} is available (current ${n.currentVersion}). ${a}`)),await s(n.latestVersion,new Date(i).toISOString())}function B(e,t,n,r){if(!e||!t||e!==n)return!1;let i=Date.parse(t);return Number.isNaN(i)?!1:r-i<864e5}async function V(e){let t=await W(e.action,e.target);if(t)return t;let n=p().timeoutMs;if(n===void 0)return K(e,()=>e.run().then(t=>H(e.action,e.target,t)));let r;try{let t=new Promise(t=>{r=setTimeout(()=>{le(e,n).then(t)},n)});return await K(e,async()=>{let n=await Promise.race([se(e.run,()=>t),t]);return r!==void 0&&(clearTimeout(r),r=void 0),H(e.action,e.target,n)})}finally{r&&clearTimeout(r)}}async function H(e,t,n){let r=await G(e,t,n);try{await z({action:e,ok:r.ok})}catch{}return r}function U(e){e.error&&console.error(x.red(e.error.message))}async function W(e,t){let n=p();if(!n.idempotencyKey)return;let r=await F(n.idempotencyKey);if(!r)return;if(r.action!==e)return f(v({action:e,error:{code:`INVALID_ARGUMENT`,details:{existingAction:r.action,idempotencyKey:n.idempotencyKey},message:`Idempotency key ${n.idempotencyKey} was already used for ${r.action}.`},target:t}),U,{force:!0});let i={...r.result,meta:{...r.result.meta,mode:n.outputMode,runId:n.runId,timestamp:new Date().toISOString()}};return f(i,U,{force:!0}),i}async function G(e,t,n){let r=p();return r.idempotencyKey&&await I(r.idempotencyKey,{action:e,result:n,target:t}),n}async function K(e,t){let n,r;try{let i=new Promise(t=>{let i=r=>{n??=ue(e,r),n.then(t)},a=()=>i(`SIGINT`),o=()=>i(`SIGTERM`);O.once(`SIGINT`,a),O.once(`SIGTERM`,o),r=()=>{O.off(`SIGINT`,a),O.off(`SIGTERM`,o)}});return await Promise.race([ce(t,()=>n),i])}finally{r?.()}}async function se(e,t){try{let n=await e();return p().cancelled?t():n}catch(e){if(p().cancelled)return t();throw e}}async function ce(e,t){try{let n=await e(),r=t();return p().cancelled&&r?r:n}catch(e){let n=t();if(p().cancelled&&n)return n;throw e}}async function le(e,t){return await g(),h({action:e.action,data:{reason:`timeout`,timeoutMs:t},target:e.target,type:`cancelled`},{force:!0}),f(v({action:e.action,error:{code:`TIMEOUT`,details:{timeoutMs:t},message:`Command timed out after ${t}ms.`},target:e.target}),U,{force:!0})}async function ue(e,t){return await g(),h({action:e.action,data:{reason:`signal`,signal:t},target:e.target,type:`cancelled`},{force:!0}),f(v({action:e.action,error:{code:`CANCELLED`,details:{signal:t},message:`Command cancelled by ${t}.`},target:e.target}),U,{force:!0})}async function q(t,n,r={}){let i=await e(t);if(!i)return Y({agent:{name:t},errorCode:`AGENT_NOT_FOUND`,errorMessage:`Unknown agent: ${t}`,execution:{args:n,installPolicy:r.install??`prompt`,installed:!1,interactive:!1,launched:!1}}),D(`AGENT_NOT_FOUND`);let{agent:o,inspection:s}=i,c=r.nonInteractive?!1:p().interactive,l=r.assumeYes??ne(),u=r.dryRun??w(),d=r.install??`prompt`;if(!s.inPath){if(d===`never`)return Y({agent:{binaryName:o.binaryName,displayName:o.displayName,name:o.name},errorCode:`AGENT_NOT_INSTALLED`,errorMessage:`${o.displayName} is not installed.`,execution:{args:n,installGuidance:J(o,s.methods,n),installPolicy:d,installed:!1,interactive:c,launched:!1}}),D(`AGENT_NOT_INSTALLED`);if(d===`if-missing`||d===`always`){if(u?T(x.cyan(`Dry run: would install ${o.displayName}.`)):C(x.cyan(`Installing ${o.displayName}...`)),!(await X(o,u)).success)return E(x.red(`Failed to install ${o.displayName}.`)),1}else if(c){if(!(l||u?{install:!0}:await oe({type:`confirm`,name:`install`,message:`${o.displayName} is not installed. Would you like to install it?`,initial:!0})).install)return S(x.yellow(`Installation cancelled.`)),1;if(u?T(x.cyan(`Dry run: would install ${o.displayName}.`)):C(x.cyan(`Installing ${o.displayName}...`)),!(await X(o,u)).success)return E(x.red(`Failed to install ${o.displayName}.`)),1}else return Y({agent:{binaryName:o.binaryName,displayName:o.displayName,name:o.name},errorCode:`INTERACTION_REQUIRED`,errorMessage:`${o.displayName} is not installed and interactive installation is disabled.`,execution:{args:n,installGuidance:J(o,s.methods,n),installPolicy:d,installed:!1,interactive:c,launched:!1}}),D(`INTERACTION_REQUIRED`)}if(u)return de({agent:{binaryName:o.binaryName,displayName:o.displayName,name:o.name},execution:{args:n,installPolicy:d,installed:!0,interactive:c,launched:!1},message:`Dry run: would run ${[o.binaryName,...n].join(` `)}`}),0;try{return await Z(a([o.binaryName,...n]),o.displayName)}catch(e){return E(x.red(`Failed to launch ${o.displayName}: ${e instanceof Error?e.message:String(e)}`)),1}}function J(e,t,i){return{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t.map(t=>({command:n(e,t),label:r(t),type:t.type})).filter(e=>e.command),suggestedAction:`rerun-with-install-policy`,suggestedEnsureCommand:`quantex ensure ${e.name}`,suggestedExecCommand:[`quantex`,`exec`,e.name,`--install`,`if-missing`,`--`,...i].join(` `)}}function Y(e){if(p().outputMode===`human`){E(x.red(e.errorMessage));let t=e.execution.installGuidance;t&&(T(x.dim(`Try: ${t.suggestedEnsureCommand}`)),T(x.dim(`Or: ${t.suggestedExecCommand}`)));return}f(v({action:`exec`,data:{agent:e.agent,execution:e.execution},error:{code:e.errorCode,details:e.execution.installGuidance,message:e.errorMessage},target:{kind:`agent`,name:e.agent.name}}),()=>{})}function de(e){if(p().outputMode===`human`){T(x.cyan(e.message));return}f(ee({action:`exec`,data:{agent:e.agent,execution:e.execution},target:{kind:`agent`,name:e.agent.name}}),()=>{})}async function X(e,n=w()){if(n)return{success:!0};try{return await t(e)}catch(t){return c(t)?(E(x.red(t.message)),{success:!1}):(E(x.red(`Failed to install ${e.displayName}: ${t instanceof Error?t.message:String(t)}`)),{success:!1})}}async function Z(e,t){let{timeoutMs:n}=p(),r,i,a;try{let o=new Promise(e=>{let n=n=>{r??=(async()=>(await g(),E(x.red(`${t} was cancelled by ${n}.`)),D(`CANCELLED`)))(),r.then(e)},a=()=>n(`SIGINT`),o=()=>n(`SIGTERM`);O.once(`SIGINT`,a),O.once(`SIGTERM`,o),i=()=>{O.off(`SIGINT`,a),O.off(`SIGTERM`,o)}}),s=n===void 0?void 0:new Promise(e=>{a=setTimeout(()=>{r??=(async()=>(await g(),E(x.red(`${t} timed out after ${n}ms.`)),D(`TIMEOUT`)))(),r.then(e)},n)});return await Promise.race([fe(e,()=>r),o,...s?[s]:[]])}finally{a&&clearTimeout(a),i?.()}}async function fe(e,t){try{let n=await l(e),r=t();return p().cancelled&&r?r:n}catch(e){let n=t();if(p().cancelled&&n)return n;throw e}}M.name(`quantex`).description(`统一的 AI Agent CLI 管理工具`).option(`--json`,`Output structured JSON`).option(`--output <mode>`,`Output mode: human, json, or ndjson`).option(`--non-interactive`,`Disable interactive prompts and confirmations`).option(`--yes`,`Automatically accept safe default confirmations`).option(`--quiet`,`Suppress non-essential human logs`).option(`--color <mode>`,`Color mode: auto, always, or never`).option(`--log-level <level>`,`Log level: silent, error, warn, info, or debug`).option(`--dry-run`,`Show what would happen without making changes`).option(`--refresh`,`Refresh cached version metadata before returning results`).option(`--no-cache`,`Bypass the local version cache for this command`).option(`--run-id <id>`,`Attach a run id to structured output and logs`).option(`--idempotency-key <key>`,`Deduplicate repeated mutating requests by client-supplied key`).option(`--timeout <duration>`,`Abort a command after the given duration, e.g. 500ms, 30s, 5m`).version(u()),M.hook(`preAction`,(e,t)=>{try{m(b(t.optsWithGlobals()))}catch(e){console.log(x.red(e instanceof Error?e.message:String(e))),O.exit(2)}}),M.hook(`postAction`,()=>{y()}),M.command(`schema`).argument(`[command]`,`Optional command name`).description(`查看结构化输出 schema`).action(async e=>{let{schemaCommand:t}=await import(`./schema-Pi2h96nT.mjs`);O.exitCode=await $({action:`schema`,run:()=>t(e),target:{kind:`system`,name:`schema`}})}),M.command(`commands`).description(`查看命令目录与稳定能力`).action(async()=>{let{commandsCommand:e}=await import(`./commands-CcjvWI3b.mjs`);O.exitCode=await $({action:`commands`,run:()=>e(),target:{kind:`system`,name:`commands`}})}),M.command(`capabilities`).description(`查看当前环境与 surface 能力`).action(async()=>{let{capabilitiesCommand:e}=await import(`./capabilities-Cl3gp573.mjs`);O.exitCode=await $({action:`capabilities`,run:()=>e(),target:{kind:`system`,name:`capabilities`}})}),M.command(`inspect <agent>`).description(`查看 agent 结构化状态`).action(async e=>{let{inspectCommand:t}=await import(`./inspect-6f2xR5k8.mjs`);O.exitCode=await $({action:`inspect`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`resolve <agent>`).description(`解析 agent 可执行入口`).action(async e=>{let{resolveCommand:t}=await import(`./resolve-Cj4FpG-J.mjs`);O.exitCode=await $({action:`resolve`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`install <agents...>`).alias(`i`).description(`安装指定 agent`).action(async e=>{let{installCommand:t}=await import(`./install-DfENrV-i.mjs`);O.exitCode=await $({action:`install`,run:()=>t(e),target:e.length===1?{kind:`agent`,name:e[0]}:{kind:`agent`}})}),M.command(`ensure <agent>`).description(`确保指定 agent 已安装`).action(async e=>{let{ensureCommand:t}=await import(`./ensure-CS7zwh7w.mjs`);O.exitCode=await $({action:`ensure`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`exec <agent>`).description(`以显式策略启动 agent`).allowUnknownOption().option(`--install <policy>`,`Install policy: never, if-missing, always`,`never`).argument(`[args...]`,`Arguments passed through to the agent`).action(async(e,t,n,r)=>{let i=n.install;if(i!==`never`&&i!==`if-missing`&&i!==`always`){console.log(x.red(`Unknown install policy: ${i}`)),O.exitCode=2;return}let a=me(r);O.exitCode=await q(e,a.length>0?a:t,{install:i,nonInteractive:r.optsWithGlobals().nonInteractive})}),M.command(`update`).argument(`[agent]`,`Agent name or alias`).option(`--all`,`更新所有已安装的 agent`).alias(`u`).description(`更新指定 agent`).action(async(e,t)=>{let{updateCommand:n}=await import(`./update-Dybu18B9.mjs`);O.exitCode=await $({action:`update`,run:()=>n(e,t.all??!1),target:{kind:`agent`,name:e}})}),M.command(`uninstall <agent>`).alias(`rm`).description(`卸载指定 agent`).action(async e=>{let{uninstallCommand:t}=await import(`./uninstall-tPD85IT2.mjs`);O.exitCode=await $({action:`uninstall`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`list`).alias(`ls`).description(`列出所有支持的 agent`).action(async()=>{let{listCommand:e}=await import(`./list-Dy7KyZI_.mjs`);O.exitCode=await $({action:`list`,run:()=>e(),target:{kind:`system`,name:`agents`}})}),M.command(`info <agent>`).description(`查看 agent 详细信息`).action(async e=>{let{infoCommand:t}=await import(`./info-BsR4unMZ.mjs`);O.exitCode=await $({action:`info`,run:()=>t(e),target:{kind:`agent`,name:e}})}),M.command(`config`).argument(`[action]`,`Action: get, set, reset`).argument(`[key]`,`Config key`).argument(`[value]`,`Config value`).description(`配置管理`).action(async(e,t,n)=>{let{configCommand:r}=await import(`./config-DttlCFVr.mjs`);O.exitCode=await $({action:`config`,run:()=>r(e,t,n),target:{kind:`config`,name:t}})}),M.command(`upgrade`).description(`升级 Quantex CLI`).option(`--channel <channel>`,`Update channel: stable or beta`).option(`--check`,`Only check whether an update is available`).action(async e=>{let{upgradeCommand:t}=await import(`./upgrade-wuryVVTl.mjs`);O.exitCode=await $({action:`upgrade`,run:()=>t({channel:e.channel===`beta`?`beta`:void 0,check:e.check??!1}),target:{kind:`self`,name:`quantex`}})}),M.command(`doctor`).description(`检查环境`).action(async()=>{let{doctorCommand:e}=await import(`./doctor-D2a_99Z8.mjs`);O.exitCode=await $({action:`doctor`,run:()=>e(),target:{kind:`system`,name:`doctor`}})});const pe=new Set([...M.commands.map(e=>e.name()),...M.commands.flatMap(e=>e.aliases()),`help`,`--help`,`--version`,`-v`]),Q=he(O.argv.slice(2),pe);if(Q?.error&&(console.log(x.red(Q.error)),O.exit(2)),Q&&i(Q.agentName)){try{m(b({color:Q.color,dryRun:Q.dryRun,idempotencyKey:Q.idempotencyKey,logLevel:Q.logLevel,noCache:Q.noCache,nonInteractive:Q.nonInteractive,quiet:Q.quiet,refresh:Q.refresh,runId:Q.runId,timeout:Q.timeout,yes:Q.yes}))}catch(e){console.log(x.red(e instanceof Error?e.message:String(e))),O.exit(2)}try{let e=await q(Q.agentName,Q.agentArgs,{assumeYes:Q.yes,dryRun:Q.dryRun,nonInteractive:Q.nonInteractive});O.exit(e)}finally{y()}}M.parse();function me(e){let t=e.processedArgs.at(-1);return Array.isArray(t)?t:e.args.slice(1)}function he(e,t){let n=O.stdin.isTTY===!1||O.stdout.isTTY===!1,r,i=!1,a=0,o,s=!1,c,l=!1,u=!1,d,f=!1,p=!1,m,h,g=!1;for(;a<e.length;){let _=e[a];if(_===`--json`){s=!0,a+=1;continue}if(_===`--output`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--output requires a value`};d=t,a+=2;continue}if(_===`--non-interactive`){u=!0,a+=1;continue}if(_===`--yes`){g=!0,a+=1;continue}if(_===`--quiet`){f=!0,a+=1;continue}if(_===`--color`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--color requires a value`};r=t,a+=2;continue}if(_===`--log-level`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--log-level requires a value`};c=t,a+=2;continue}if(_===`--dry-run`){i=!0,a+=1;continue}if(_===`--refresh`){p=!0,a+=1;continue}if(_===`--no-cache`){l=!0,a+=1;continue}if(_===`--idempotency-key`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--idempotency-key requires a value`};o=t,a+=2;continue}if(_===`--run-id`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--run-id requires a value`};m=t,a+=2;continue}if(_===`--timeout`){let t=e[a+1];if(!t)return{agentArgs:[],agentName:``,error:`--timeout requires a value`};h=t,a+=2;continue}return _.startsWith(`-`)||t.has(_)?void 0:s||d===`json`||d===`ndjson`||n&&d!==`human`?{agentArgs:[],agentName:``,error:`Structured output is not supported for shortcut agent execution yet. Use a management command instead.`}:{agentArgs:e.slice(a+1),agentName:_,color:r,dryRun:i,idempotencyKey:o,logLevel:c,noCache:l,nonInteractive:u,quiet:f,refresh:p,runId:m,timeout:h,yes:g}}}async function $(e){return re(await V(e))}export{};
@@ -0,0 +1,6 @@
1
+ import{createHash as e,randomUUID as t}from"node:crypto";import n from"node:process";import{existsSync as r,mkdirSync as i,writeFileSync as a}from"node:fs";import{chmod as o,mkdir as s,mkdtemp as c,readFile as l,realpath as u,rename as d,rm as f,stat as p,writeFile as m}from"node:fs/promises";import{basename as h,dirname as g,join as _,win32 as v}from"node:path";import{homedir as ee}from"node:os";import{spawn as y}from"node:child_process";import{text as te}from"node:stream/consumers";import{fileURLToPath as ne}from"node:url";import{Buffer as re}from"node:buffer";import ie from"picocolors";function ae(e){let t=e.trim().match(/^(\d+)(ms|[smh])?$/);if(!t)return;let n=Number.parseInt(t[1],10),r=t[2]??`ms`;if(Number.isFinite(n))switch(r){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*60*1e3;case`h`:return n*60*60*1e3;default:return}}let b,x=new Set;function S(){return b??=pe(),b}function oe(e){x=new Set,b={...e,cacheMode:e.cacheMode??`default`,cancelled:e.cancelled??!1}}function se(){b=void 0,x=new Set}function ce(e={}){let r=n.stdin.isTTY!==!1,i=n.stdout.isTTY!==!1,a=!r||!i,o=e.json||e.output===`json`?`json`:e.output===`ndjson`?`ndjson`:e.output===`human`?`human`:a?`json`:`human`,s=e.timeout===void 0?void 0:ae(e.timeout),c=me(e.color),l=he(e.logLevel);if(e.timeout!==void 0&&s===void 0)throw Error(`Invalid timeout value: ${e.timeout}`);if(e.refresh&&e.noCache)throw Error(`Cannot combine --refresh with --no-cache.`);return{assumeYes:e.yes,cacheMode:e.noCache?`no-cache`:e.refresh?`refresh`:`default`,cancelled:!1,colorMode:c,dryRun:e.dryRun,idempotencyKey:e.idempotencyKey,interactive:!e.nonInteractive&&!a&&r&&i,logLevel:l,outputMode:o,quiet:e.quiet,runId:e.runId??n.env.QUANTEX_RUN_ID??t(),timeoutMs:s}}function le(){b&&(b.cancelled=!0)}async function ue(){le();let e=[...x];x.clear(),await Promise.allSettled(e.map(e=>Promise.resolve().then(e)))}function de(e){return x.add(e),()=>{x.delete(e)}}function fe(e){let t=S();if(!t.freshness){t.freshness=e;return}t.freshness={fetchedAt:t.freshness.fetchedAt<=e.fetchedAt?t.freshness.fetchedAt:e.fetchedAt,source:t.freshness.source===`network`&&e.source===`network`?`network`:`cache`,staleAfter:t.freshness.staleAfter<=e.staleAfter?t.freshness.staleAfter:e.staleAfter}}function pe(){return ce()}function me(e){if(e===void 0||e===`auto`)return`auto`;if(e===`always`)return`always`;if(e===`never`)return`never`;throw Error(`Invalid color mode: ${e}`)}function he(e){if(e===void 0||e===`info`)return`info`;if(e===`silent`||e===`error`||e===`warn`||e===`debug`)return e;throw Error(`Invalid log level: ${e}`)}const ge=`https://registry.npmjs.org`;function C(e){if(e)try{return new URL(e.trim()).toString().replace(/\/+$/,``)}catch{return}}function _e(e,t,n){return`${C(n)}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}const ve={defaultPackageManager:`bun`,networkRetries:2,networkTimeoutMs:1e4,npmBunUpdateStrategy:`latest-major`,selfUpdateChannel:`stable`,selfUpdateRegistry:void 0,versionCacheTtlHours:6};function w(){return _(n.env.HOME||n.env.USERPROFILE||ee(),`.quantex`)}function T(){return _(w(),`config.json`)}async function E(){let e={...ve,...await Se()};return{...e,defaultPackageManager:ye(e.defaultPackageManager)?e.defaultPackageManager:`bun`,networkRetries:D(e.networkRetries,2),networkTimeoutMs:D(e.networkTimeoutMs,1e4),npmBunUpdateStrategy:e.npmBunUpdateStrategy===`respect-semver`?`respect-semver`:`latest-major`,selfUpdateChannel:e.selfUpdateChannel===`beta`?`beta`:`stable`,selfUpdateRegistry:typeof e.selfUpdateRegistry==`string`?C(e.selfUpdateRegistry):void 0,versionCacheTtlHours:D(e.versionCacheTtlHours,6)}}function ye(e){return e===`bun`||e===`mise`||e===`npm`}function be(e){return e===`latest-major`||e===`respect-semver`}async function xe(e){await s(w(),{recursive:!0}),await m(T(),`${JSON.stringify(e,null,2)}\n`,`utf8`)}async function Se(){try{let e=await l(T(),`utf8`),t=JSON.parse(e);return Ce(t)?t:{}}catch{return{}}}function D(e,t){if(typeof e==`number`&&Number.isInteger(e)&&e>0)return e;if(typeof e==`string`){let t=Number.parseInt(e,10);if(Number.isInteger(t)&&t>0)return t}return t}function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var O=class extends Error{lockPath;resource;constructor(e,t){super(`Another quantex process is already using the ${e} lock.`),this.name=`ResourceLockError`,this.lockPath=t,this.resource=e}};function we(e){return e instanceof O}function Te(e){let t=e.map(e=>e.trim().replaceAll(/[^\w.-]+/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-|-$/g,``)).filter(Boolean),n=t.length>0?t:[`default`],r=n.slice(0,-1),i=`${n.at(-1)}.lock`;return _(w(),`locks`,...r,i)}async function k(e){let t=Te(e.scope);return await s(g(t),{recursive:!0}),await Ee(e.resource,t),async()=>{await f(t,{force:!0,recursive:!0})}}async function Ee(e,t){try{i(t,{recursive:!1}),De(t);return}catch(e){if(!Me(e))throw e}if(!await Oe(t))throw new O(e,t);try{i(t,{recursive:!1}),De(t)}catch(n){throw Me(n)?new O(e,t):n}}function De(e){a(_(e,`owner.json`),`${JSON.stringify({pid:n.pid,createdAt:new Date().toISOString()})}\n`,`utf8`)}async function Oe(e){let t;try{t=await ke(e)}catch{return!1}return t&&je(t.pid)?!1:(await f(e,{force:!0,recursive:!0}),!0)}async function ke(e){let t=Date.now()+100;for(;Date.now()<t;){let t=await Ae(e);if(t)return t;await new Promise(e=>setTimeout(e,2))}return await Ae(e)}async function Ae(e){try{let t=await l(_(e,`owner.json`),`utf8`),n=JSON.parse(t);return typeof n.pid==`number`&&Number.isInteger(n.pid)&&n.pid>0?{pid:n.pid}:void 0}catch(e){if(Ne(e))return;throw e}}function je(e){try{return n.kill(e,0),!0}catch(e){return(typeof e==`object`&&e&&`code`in e?e.code:void 0)===`EPERM`}}function Me(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`EEXIST`}function Ne(e){let t=typeof e==`object`&&e&&`code`in e?e.code:void 0;return t===`ENOENT`||t===`ENOTDIR`}async function Pe(e,t){let n=await k(e);try{return await t()}finally{await n()}}async function Fe(){try{return await k({resource:`self upgrade`,scope:[`self-upgrade`]})}catch(e){if(we(e))return;throw e}}const A=`quantex-cli`,j=`https://github.com/Drswith/quantex-cli`,Ie=`0.21.1`;function M(e,t={}){if(S().outputMode===`human`){let n=P(e,{...t,stdio:[`inherit`,`inherit`,`inherit`]});return{cleanup:de(()=>He(n)),outputDrained:Promise.resolve(),proc:n}}let n=P(e,{...t,stdio:[`ignore`,`pipe`,`pipe`]});return{cleanup:de(()=>He(n)),outputDrained:Promise.all([Le(n.stdout),Le(n.stderr)]).then(()=>void 0),proc:n}}async function N(e){let t=S();try{let n=await e.proc.exited;return await e.outputDrained,t.cancelled?1:n}finally{e.cleanup()}}function P(e,t={}){let n=Be();if(n)return Ve(e,t,n);let[r,...i]=e;if(!r)throw Error(`spawnCommand requires a non-empty command array.`);let a=y(r,i,{...t,shell:t.shell??ze(r)});return{get exitCode(){return a.exitCode},pid:a.pid,stderr:a.stderr,stdout:a.stdout,exited:Re(a),kill:a.kill.bind(a),unref:()=>a.unref()}}async function F(e){let[t,n,r]=await Promise.all([I(e.stdout),I(e.stderr),e.exited]);return{exitCode:r,stderr:n,stdout:t}}async function Le(e){if(!e)return;let t=await I(e);t&&n.stderr.write(t)}async function Re(e){return new Promise((t,n)=>{e.once(`error`,n),e.once(`close`,e=>{t(typeof e==`number`?e:1)})})}async function I(e){return e?typeof e==`string`?e:typeof e.getReader==`function`?new Response(e).text():te(e):``}function ze(e){return n.platform!==`win32`||e.includes(`/`)||e.includes(`\\`)?!1:!/\.[a-z0-9]+$/i.test(e)}function Be(){let e=globalThis.Bun?.spawn;return typeof e==`function`?e:void 0}function Ve(e,t,n){let r=n([...e],t);return{get exitCode(){return r.exitCode},pid:r.pid,stderr:r.stderr,stdout:r.stdout,exited:r.exited.then(()=>typeof r.exitCode==`number`?r.exitCode:1),kill:e=>r.kill?.(e)??!1,unref:()=>r.unref?.()}}async function He(e){n.platform===`win32`&&e.pid!==void 0&&await We(Ue(e.pid),2e3);try{e.kill?.(`SIGTERM`)}catch{}await We(e.exited.then(()=>void 0).catch(()=>void 0),2e3)}async function Ue(e){await new Promise(t=>{let n=y(`taskkill.exe`,[`/PID`,String(e),`/T`,`/F`],{stdio:[`ignore`,`ignore`,`ignore`],windowsHide:!0});n.once(`error`,()=>t()),n.once(`close`,()=>t())})}async function We(e,t){let n;try{await Promise.race([e,new Promise(e=>{n=setTimeout(e,t)})])}finally{n&&clearTimeout(n)}}async function L(e,t){let n=await Ge(e,t,`json`);if(n)try{return JSON.parse(n)}catch{return}}async function Ge(e,t,n=`text`){let r=await E(),i=r.versionCacheTtlHours*60*60*1e3,a=S().cacheMode,o=a===`no-cache`?{entries:{}}:await qe(),s=o.entries[t],c=Date.now();if(a===`default`&&s&&s.expiresAt>c)return R(s,i),s.body;let l=await Ke(e,{headers:a!==`no-cache`&&s?.etag?{"If-None-Match":s.etag}:void 0,retries:r.networkRetries,timeoutMs:r.networkTimeoutMs});if(!l)return s&&R(s,i),s?.body;if(l.status===304&&s)return o.entries[t]={...s,expiresAt:c+i,fetchedAt:c},a!==`no-cache`&&await Je(o),Xe(c,c+i),s.body;if(!l.ok)return s&&R(s,i),s?.body;let u=await l.text();if(n===`json`)try{JSON.parse(u)}catch{return s&&R(s,i),s?.body}let d={body:u,etag:l.headers.get(`etag`)??void 0,expiresAt:c+i,fetchedAt:c};return a!==`no-cache`&&(o.entries[t]=d,await Je(o)),Xe(c,c+i),u}async function Ke(e,t){for(let n=0;n<=t.retries;n++){let r=new AbortController,i=setTimeout(()=>r.abort(),t.timeoutMs);try{return await fetch(e,{headers:t.headers,signal:r.signal})}catch{if(n===t.retries)return}finally{clearTimeout(i)}}}async function qe(){try{return JSON.parse(await l(Ye(),`utf8`))}catch{return{entries:{}}}}async function Je(e){await s(_(w(),`cache`),{recursive:!0}),await m(Ye(),`${JSON.stringify(e,null,2)}\n`,`utf8`)}function Ye(){return _(w(),`cache`,`versions.json`)}function R(e,t){let n=e.fetchedAt??Math.max(0,e.expiresAt-t);fe({fetchedAt:new Date(n).toISOString(),source:`cache`,staleAfter:new Date(e.expiresAt).toISOString()})}function Xe(e,t){fe({fetchedAt:new Date(e).toISOString(),source:`network`,staleAfter:new Date(t).toISOString()})}const Ze=/v?(\d+\.\d+\.\d+(?:-[a-z0-9.]+)?)/i;function Qe(e,t){if(t)return t(e);let n=e.trim().split(`
2
+ `)[0],r=n.match(Ze);return r?r[1]:n||void 0}function $e(e,t){let n=nt(e),r=nt(t);if(!(!n||!r)){for(let e=0;e<3;e+=1){let t=n.core[e]-r.core[e];if(t!==0)return t>0?1:-1}return rt(n.prerelease,r.prerelease)}}function z(e,t){return $e(e,t)===1}async function B(e,t){let n=t?.command??[e,`--version`];try{let{exitCode:e,stdout:r}=await F(P(n));return e===0?Qe(r,t?.parser):void 0}catch{return}}async function V(e,t=`latest`,n={}){try{let r=C(n.registry)??`https://registry.npmjs.org`;return(await L(_e(e,t,r),`npm:${r}:${e}:${t}`))?.version}catch{return}}async function et(e){try{let{exitCode:t,stdout:r}=await F(P([n.platform===`win32`?`where`:`which`,e]));return t===0?r.trim().split(`
3
+ `)[0]:void 0}catch{return}}async function tt(e){if(e)try{return await u(e)}catch{return e}}function nt(e){let t=e.trim().match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9a-z.-]+))?$/i);if(t)return{core:[Number(t[1]),Number(t[2]),Number(t[3])],prerelease:t[4]?t[4].split(`.`):[]}}function rt(e,t){if(e.length===0&&t.length===0)return 0;if(e.length===0)return 1;if(t.length===0)return-1;let n=Math.max(e.length,t.length);for(let r=0;r<n;r+=1){let n=e[r],i=t[r];if(n===void 0)return-1;if(i===void 0)return 1;if(n===i)continue;let a=/^\d+$/.test(n),o=/^\d+$/.test(i);return a&&o?Number(n)>Number(i)?1:-1:a?-1:o||n>i?1:-1}return 0}const it={installedAgents:{},self:{}};function H(){return _(w(),`state.json`)}async function U(){return ft()}async function at(e){let t=await k({resource:`state`,scope:[`state`]});try{await gt(e)}finally{await t()}}async function ot(e){return(await U()).installedAgents[e]}async function st(e){await W(t=>{t.installedAgents[e.agentName]=e})}async function ct(e){await W(t=>{delete t.installedAgents[e]})}async function lt(){return(await U()).self}async function ut(e){await W(t=>{t.self.installSource=e})}async function dt(e,t){await W(n=>{n.self.updateNoticeVersion=e,n.self.updateNoticeAt=t})}async function ft(){try{let e=JSON.parse(await l(H(),`utf8`)),t=pt(e.self);return{installedAgents:e.installedAgents??{},self:t}}catch{return{...it}}}function pt(e){if(!ht(e))return{};let t={...e};return mt(e.installSource)?t.installSource=e.installSource:delete t.installSource,typeof e.updateNoticeAt==`string`?t.updateNoticeAt=e.updateNoticeAt:delete t.updateNoticeAt,typeof e.updateNoticeVersion==`string`?t.updateNoticeVersion=e.updateNoticeVersion:delete t.updateNoticeVersion,t}function mt(e){return e===`binary`||e===`bun`||e===`npm`||e===`source`||e===`unknown`}function ht(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function gt(e){await s(w(),{recursive:!0}),await m(H(),`${JSON.stringify(e,null,2)}\n`,`utf8`)}async function W(e){let t=await k({resource:`state`,scope:[`state`]});try{let t=await ft();await e(t),await gt(t)}finally{await t()}}function _t(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function G(e=n.execPath){if(h(_t(e)).endsWith(`.exe`))return`quantex-windows-x64.exe`;if(n.platform===`darwin`)return n.arch===`arm64`?`quantex-darwin-arm64`:`quantex-darwin-x64`;if(n.platform===`linux`)return n.arch===`arm64`?`quantex-linux-arm64`:`quantex-linux-x64`}function vt(e=n.execPath){let t=G(e);if(t)return`${j}/releases/latest/download/${t}`}function yt(e,t,r=n.env){return e||(r.QUANTEX_UPDATE_CHANNEL===`beta`?`beta`:r.QUANTEX_UPDATE_CHANNEL===`stable`?`stable`:t===`beta`?`beta`:`stable`)}async function bt(e){let t=await L(await xt(e),`self:manifest:${e}`);if(!t)throw Error(`Failed to download release manifest.`);return t}async function xt(e){if(e===`stable`)return`${j}/releases/latest/download/manifest.json`;let t=(await St(e)).assets.find(e=>e.name===`manifest.json`);if(!t?.browser_download_url)throw Error(`No manifest.json asset was found for the ${e} release channel.`);return t.browser_download_url}async function St(e){let t=wt();if(!t)throw Error(`Failed to resolve the GitHub repository slug for Quantex releases.`);let n=await L(`https://api.github.com/repos/${t}/releases?per_page=20`,`self:github-releases`);if(!n)throw Error(`Failed to query GitHub releases.`);let r=n.find(t=>e===`beta`?t.prerelease:!t.prerelease);if(!r)throw Error(`No GitHub release was found for the ${e} channel.`);return r}function Ct(e,t=n.execPath){let r=n.platform,i=n.arch===`arm64`?`arm64`:`x64`,a=G(t);return e.assets.find(e=>e.platform===r&&e.arch===i&&(!a||e.name===a))}function wt(){return j.match(/github\.com\/([^/]+\/[^/]+)$/)?.[1]}const Tt=A,Et=`/node_modules/${Tt}`;async function Dt(e){let t=await At(),r=n.execPath,i=t.foundPackageJson?K(t.packageRoot):K(``,r),a=await kt((await lt()).installSource,i),o=await E(),s=yt(e?.updateChannel,o.selfUpdateChannel);return{canAutoUpdate:Ot(a),currentVersion:t.version||`0.21.1`,executablePath:r,installSource:a,packageRoot:t.packageRoot,updateChannel:s}}function Ot(e){return e===`binary`||e===`bun`||e===`npm`}async function kt(e,t){return t!==`unknown`&&e!==t?(await ut(t),t):e??t}function K(e,t=n.execPath){let r=Mt(e);return r.includes(`/.bun/install/global/`)?`bun`:r.includes(Et)?`npm`:r?`source`:Nt(t)?`binary`:`unknown`}async function At(e=import.meta.url){let t=Pt(e),n=g(t);for(;;){let e=_(n,`package.json`),t=await jt(e);if(t?.name===Tt)return{foundPackageJson:!0,packageJsonPath:e,packageRoot:n,version:t.version??`0.21.1`};let r=g(n);if(r===n)break;n=r}return{foundPackageJson:!1,packageJsonPath:_(g(t),`package.json`),packageRoot:g(t),version:Ie}}function q(){return Ie}async function jt(e){try{return JSON.parse(await l(e,`utf8`))}catch{return}}function Mt(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function Nt(e){let t=h(Mt(e));return t!==`bun`&&t!==`bun.exe`}function Pt(e){try{return ne(e)}catch{return n.execPath}}async function Ft(e,t,r=n.env,i=n.cwd()){if(e!==`bun`&&e!==`npm`)return;let a=C(r.QTX_SELF_UPDATE_REGISTRY);return a?{isOverride:!0,registry:a,source:`quantex-env`}:t.selfUpdateRegistry?{isOverride:!0,registry:t.selfUpdateRegistry,source:`quantex-config`}:await It(e,r,i)||{isOverride:!1,registry:ge,source:`fallback`}}async function It(e,t,n){if(e===`bun`){let e=Lt(t,[`BUN_CONFIG_REGISTRY`,`NPM_CONFIG_REGISTRY`,`npm_config_registry`]);if(e)return{isOverride:!1,registry:e,source:`bun-env`};let r=await Rt(n,t);if(r)return{isOverride:!1,registry:r,source:`bunfig`}}let r=Lt(t,[`NPM_CONFIG_REGISTRY`,`npm_config_registry`]);if(r)return{isOverride:!1,registry:r,source:`npm-env`};let i=await Bt(n,t);if(i)return{isOverride:!1,registry:i,source:`npmrc`}}function Lt(e,t){for(let n of t){let t=C(e[n]);if(t)return t}}async function Rt(e,t){let n=Ut(t),i=t.XDG_CONFIG_HOME,a=Ht(e,`bunfig.toml`),o=[_(n,`.bunfig.toml`),i?_(i,`.bunfig.toml`):void 0];if(a){let e=await zt(a);if(e)return e}for(let e of o){if(!e||!r(e))continue;let t=await zt(e);if(t)return t}}async function zt(e){try{return Wt(await l(e,`utf8`))}catch{return}}async function Bt(e,t){let n=Ut(t),i=Ht(e,`.npmrc`),a=_(n,`.npmrc`);if(i){let e=await Vt(i);if(e)return e}if(r(a))return Vt(a)}async function Vt(e){try{let t=(await l(e,`utf8`)).split(`
4
+ `).map(e=>e.trim());for(let e=t.length-1;e>=0;--e){let n=t[e];if(!n||n.startsWith(`#`)||n.startsWith(`;`))continue;let r=n.match(/^registry\s*=\s*(.+)$/);if(!r?.[1])continue;let i=C(r[1]);if(i)return i}}catch{}}function Ht(e,t){let n=e;for(;;){let e=_(n,t);if(r(e))return e;let i=g(n);if(i===n)return;n=i}}function Ut(e){return e.HOME||e.USERPROFILE||ee()}function Wt(e){let t=Gt(e,[/(?:^|\n)\s*install\.registry\s*=\s*["']([^"'#\n]+)["']/,/(?:^|\n)\s*install\.registry\s*=\s*\{\s*url\s*=\s*["']([^"'#\n]+)["']/,/(?:^|\n)\s*install\s*=\s*\{[\s\S]*?\bregistry\s*=\s*["']([^"'#\n]+)["'][\s\S]*?\}/,/(?:^|\n)\s*install\s*=\s*\{[\s\S]*?\bregistry\s*=\s*\{\s*url\s*=\s*["']([^"'#\n]+)["'][\s\S]*?\}[\s\S]*?\}/]);if(t)return C(t);let n=e.match(/(?:^|\n)\s*\[install\]\s*\n([\s\S]*?)(?=\n\s*\[[^\]]+\]|\s*$)/)?.[1];if(n)return C(Gt(n,[/(?:^|\n)\s*registry\s*=\s*["']([^"'#\n]+)["']/,/(?:^|\n)\s*registry\s*=\s*\{\s*url\s*=\s*["']([^"'#\n]+)["']/]))}function Gt(e,t){for(let n of t){let t=e.match(n)?.[1];if(t)return t}}async function Kt(e){let t=await E();if(e.installSource===`binary`)try{let t=await bt(e.updateChannel),n=Ct(t,e.executablePath);return n?{binaryAsset:n,targetVersion:t.version}:{resolutionError:{detail:{channel:e.updateChannel},kind:`unsupported`,message:`No binary asset is available for the current platform on the ${e.updateChannel} channel.`}}}catch{return{resolutionError:{kind:`network`,message:`Failed to resolve the ${e.updateChannel} release manifest.`}}}let n=e.updateChannel===`beta`?`beta`:`latest`,r=await V(A,n,{registry:ge});if(e.installSource===`bun`||e.installSource===`npm`){let i=await Ft(e.installSource,t);return{managedRegistry:i?.registry,managedRegistryIsOverride:i?.isOverride??!1,packageTag:n,targetVersion:await V(A,n,{registry:i?.registry}),upstreamLatestVersion:r,verificationCommand:Qt(e.packageRoot)}}return{packageTag:n,targetVersion:r,upstreamLatestVersion:r}}async function J(e){let t=e?.facts??await Dt({updateChannel:e?.updateChannel}),n=e?.target??await Kt(t),r=n.targetVersion?z(n.targetVersion,t.currentVersion):!1;return{facts:t,status:Xt(t,n,r),target:n,updateAvailable:r}}function qt(e){return{canAutoUpdate:e.facts.canAutoUpdate,currentVersion:e.facts.currentVersion,executablePath:e.facts.executablePath,installSource:e.facts.installSource,latestVersion:e.target.targetVersion,managedRegistry:e.target.managedRegistry,managedRegistryIsOverride:e.target.managedRegistryIsOverride,packageRoot:e.facts.packageRoot,recommendedUpgradeCommand:e.facts.canAutoUpdate?`quantex upgrade`:void 0,upstreamLatestVersion:e.target.upstreamLatestVersion,updateChannel:e.facts.updateChannel}}async function Jt(e,t){if(!t.success||e.facts.installSource!==`bun`&&e.facts.installSource!==`npm`)return t;let n=await Zt(e);if(!n)return{error:{kind:`verify`,message:`Managed self-upgrade finished but Quantex could not verify the installed version afterwards.`},installSource:e.facts.installSource,success:!1};let r=t.newVersion??e.target.targetVersion;return r&&n!==r?{error:{detail:{expectedVersion:r,observedVersion:n},kind:`verify`,message:`Managed self-upgrade installed version ${n}, but expected ${r}.`},installSource:e.facts.installSource,success:!1}:!r&&n===e.facts.currentVersion&&e.target.targetVersion!==void 0?{error:{detail:{observedVersion:n},kind:`verify`,message:`Managed self-upgrade completed without changing the installed Quantex version.`},installSource:e.facts.installSource,success:!1}:{...t,newVersion:n}}function Yt(e){let t={canAutoUpdate:e.canAutoUpdate,currentVersion:e.currentVersion,executablePath:e.executablePath,installSource:e.installSource,packageRoot:e.packageRoot,updateChannel:e.updateChannel},n={managedRegistry:e.managedRegistry,managedRegistryIsOverride:e.managedRegistryIsOverride,packageTag:e.updateChannel===`beta`?`beta`:`latest`,targetVersion:e.latestVersion,upstreamLatestVersion:e.upstreamLatestVersion,verificationCommand:Qt(e.packageRoot)},r=e.latestVersion?z(e.latestVersion,e.currentVersion):!1;return{facts:t,status:Xt(t,n,r),target:n,updateAvailable:r}}function Xt(e,t,n){return e.canAutoUpdate?t.targetVersion&&!n?`up-to-date`:t.targetVersion?`update-available`:`check-unavailable`:`manual-required`}async function Zt(e){if(e.target.verificationCommand){let t=await B(e.facts.executablePath,{command:e.target.verificationCommand});if(t)return t}return B(e.facts.executablePath)}function Qt(e){if(e)return[n.execPath,_(e,`dist`,`cli.mjs`),`--version`]}async function $t(e,t,r,i,a=en(t)){let s;try{s=await fetch(e)}catch(t){return X(`network`,`Failed to download ${e}.`,t)}if(!s.ok)return X(`network`,`Failed to download ${e}: HTTP ${s.status}.`);let l=await c(_(g(t),`.quantex-upgrade-`)),u=_(l,h(t)),p=`${t}.bak`,v=!1;try{let c=re.from(await s.arrayBuffer()),h=await tn(t),g=sn(c);if(g!==cn(r))return X(`checksum`,`Checksum mismatch for ${e}. Expected ${cn(r)}, got ${g}.`);if(await m(u,c),n.platform===`win32`)return nn(u,t,p,l,i,a);await o(u,h),await f(p,{force:!0}),await d(t,p),v=!0,await d(u,t);let _=await on(t,i);return _.success?(v=!1,await f(p,{force:!0}),{success:!0}):(await Z(p,t),v=!1,_)}catch(e){if(v){try{await Z(p,t)}catch{}v=!1}return X(an(e),`Failed to replace the current Quantex binary.`,e)}finally{n.platform!==`win32`&&await f(l,{recursive:!0,force:!0})}}function en(e){if(n.platform!==`win32`)return;let t=v.basename(e).toLowerCase();if(t===`qtx.exe`)return v.join(v.dirname(e),`quantex.exe`);if(t===`quantex.exe`)return v.join(v.dirname(e),`qtx.exe`)}async function tn(e){try{return(await p(e)).mode&511}catch{return 493}}function nn(e,t,r,i,a,o){try{return P([`powershell.exe`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-WindowStyle`,`Hidden`,`-Command`,rn(e,t,r,i,n.pid,a,o)],{stdio:[`ignore`,`ignore`,`ignore`],windowsHide:!0}).unref(),{success:!0}}catch(e){return X(`locked`,`Failed to schedule Windows binary replacement.`,e)}}function rn(e,t,n,r,i,a,o){let s=Y(e),c=Y(t),l=Y(n),u=Y(r),d=Y(a??``),f=Y(o??``);return[`$ErrorActionPreference = 'Stop'`,`$pidToWait = ${i}`,`$tempPath = '${s}'`,`$targetPath = '${c}'`,`$backupPath = '${l}'`,`$tempDir = '${u}'`,`$expectedVersion = '${d}'`,`$peerPath = '${f}'`,`while (Get-Process -Id $pidToWait -ErrorAction SilentlyContinue) { Start-Sleep -Milliseconds 200 }`,`for ($attempt = 0; $attempt -lt 50; $attempt++) {`,` try {`,` if (Test-Path -LiteralPath $backupPath) { Remove-Item -LiteralPath $backupPath -Force -ErrorAction SilentlyContinue }`,` Move-Item -LiteralPath $targetPath -Destination $backupPath -Force -ErrorAction Stop`,` break`,` }`,` catch {`,` Start-Sleep -Milliseconds 200`,` }`,`}`,`Move-Item -LiteralPath $tempPath -Destination $targetPath -Force`,`if ($expectedVersion -ne '') {`,` $output = & $targetPath --version 2>$null`,` if ($LASTEXITCODE -ne 0 -or ($output -notmatch [regex]::Escape($expectedVersion))) {`,` Remove-Item -LiteralPath $targetPath -Force -ErrorAction SilentlyContinue`,` Move-Item -LiteralPath $backupPath -Destination $targetPath -Force`,` Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`,` exit 1`,` }`,`}`,`if ($peerPath -ne '') {`,` Copy-Item -LiteralPath $targetPath -Destination $peerPath -Force`,`}`,`Remove-Item -LiteralPath $backupPath -Force -ErrorAction SilentlyContinue`,`Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`].join(`; `)}function Y(e){return e.replaceAll(`'`,`''`)}function X(e,t,n){return{error:{detail:n,kind:e,message:t},success:!1}}function an(e){let t=typeof e==`object`&&e&&`code`in e?String(e.code):``;return t===`EACCES`||t===`EPERM`?`permission`:t===`EBUSY`?`locked`:`unknown`}async function Z(e,t){await f(t,{force:!0}),await d(e,t)}async function on(e,t){if(!t)return{success:!0};try{let{exitCode:n,stdout:r}=await F(P([e,`--version`],{stdio:[`ignore`,`pipe`,`ignore`]}));return n===0?r.includes(t)?{success:!0}:X(`verify`,`The upgraded Quantex binary reported an unexpected version during verification.`):X(`verify`,`The upgraded Quantex binary exited with code ${n} during verification.`)}catch(e){return X(`verify`,`Failed to execute the upgraded Quantex binary for verification.`,e)}}function sn(t){return e(`sha256`).update(t).digest(`hex`)}function cn(e){return e.trim().toLowerCase()}const ln={source:`binary`,canHandle:e=>un(e)===`binary`,getRecoveryHint:(e,t)=>{let n=t?.error?.detail&&typeof t.error.detail==`object`&&`downloadUrl`in t.error.detail?String(t.error.detail.downloadUrl):vt(e.executablePath);if(n)return t?.error?.kind===`locked`?`close other qtx processes and retry, or download and replace the binary from ${n}`:t?.error?.kind===`permission`?`check write permission for the current binary path, or download and replace the binary from ${n}`:t?.error?.kind===`network`?`check network access and retry, or download and replace the binary from ${n}`:`download and replace the binary from ${n}`},async upgrade(e){let t=e.target.binaryAsset;if(!t)return{error:e.target.resolutionError??{kind:`unsupported`,message:`No release artifact is available for the current platform and architecture.`},installSource:e.facts.installSource,success:!1};let n=await $t(t.downloadUrl,e.facts.executablePath,t.checksum,e.target.targetVersion??`latest`,en(e.facts.executablePath));return{...!n.success&&n.error?{...n,error:{...n.error,detail:{...typeof n.error.detail==`object`&&n.error.detail?n.error.detail:{},downloadUrl:t.downloadUrl}}}:n,installSource:e.facts.installSource,newVersion:n.success?e.target.targetVersion:void 0}}};function un(e){return`facts`in e?e.facts.installSource:e.installSource}async function dn(e,t,n){try{let r=t?`${e}@${t}`:e,i=C(n);return await Q([`bun`,`add`,`-g`,...i?[`--registry`,i]:[],r],[e])}catch{return!1}}async function fn(e,t=`latest-major`,n=`latest`,r){try{let i=n===`latest`?e:`${e}@${n}`,a=C(r);return await Q([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],...a?[`--registry`,a]:[],i],[e])}catch{return!1}}async function pn(e,t=`latest-major`){if(e.length===0)return!0;try{return await Q([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],...e],e)}catch{return!1}}async function mn(e){try{return await N(M([`bun`,`remove`,`-g`,e]))===0}catch{return!1}}async function hn(e){try{let{exitCode:t,stdout:n}=await F(P([`bun`,`pm`,`-g`,`ls`],{stdio:bn()}));return t===0?gn(n,e):void 0}catch{return}}function gn(e,t){let n=`${t}@`;for(let t of e.split(`
5
+ `)){let e=t.trim().split(/\s+/).at(-1);if(!e?.startsWith(n))continue;let r=e.slice(n.length);if(r)return r}}async function Q(e,t){return await N(M(e))===0?_n(t):!1}async function _n(e){let t=[...new Set(e)];if(t.length===0)return!0;let n=await vn();if(!n)return!0;let r=yn(n),i=t.filter(e=>r.has(e));return i.length===0?!0:await N(M([`bun`,`pm`,`-g`,`trust`,...i]))===0}async function vn(){try{let{exitCode:e,stdout:t}=await F(P([`bun`,`pm`,`-g`,`untrusted`],{stdio:bn()}));return e===0?t:void 0}catch{return}}function yn(e){let t=new Set;for(let n of e.split(`
6
+ `)){let e=n.replaceAll(`\\`,`/`).match(/^\.\/node_modules\/(.+?) @/);e?.[1]&&t.add(e[1])}return t}function bn(){return[`ignore`,`pipe`,`ignore`]}const xn={source:`bun`,canHandle:e=>Sn(e)===`bun`,getRecoveryHint:e=>`bun add -g ${A}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await dn(A,e.target.packageTag??(e.facts.updateChannel===`beta`?`beta`:`latest`),e.target.managedRegistry);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${A} through Bun.`},installSource:e.facts.installSource,newVersion:t?e.target.targetVersion:void 0,success:t}}};function Sn(e){return`facts`in e?e.facts.installSource:e.installSource}async function Cn(e,t,n){try{let r=t?`${e}@${t}`:e,i=C(n);return await N(M([`npm`,`install`,`-g`,r,...i?[`--registry`,i]:[]]))===0}catch{return!1}}async function wn(e,t=`latest-major`,n=`latest`,r){try{let i=C(r);return await N(M(t===`latest-major`?[`npm`,`install`,`-g`,`${e}@${n}`,...i?[`--registry`,i]:[]]:[`npm`,`update`,`-g`,e,...i?[`--registry`,i]:[]]))===0}catch{return!1}}async function Tn(e,t=`latest-major`){if(e.length===0)return!0;try{return await N(M(t===`latest-major`?[`npm`,`install`,`-g`,...e.map(e=>`${e}@latest`)]:[`npm`,`update`,`-g`,...e]))===0}catch{return!1}}async function En(e){try{return await N(M([`npm`,`uninstall`,`-g`,e]))===0}catch{return!1}}async function Dn(e){try{let{exitCode:t,stdout:n}=await F(P([`npm`,`list`,`-g`,`--depth=0`,`--json`],{stdio:[`ignore`,`pipe`,`ignore`]}));return t===0?On(n,e):void 0}catch{return}}function On(e,t){let n=JSON.parse(e).dependencies?.[t]?.version;return typeof n==`string`?n:void 0}const kn={source:`npm`,canHandle:e=>An(e)===`npm`,getRecoveryHint:e=>`npm install -g ${A}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await Cn(A,e.target.packageTag??(e.facts.updateChannel===`beta`?`beta`:`latest`),e.target.managedRegistry);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${A} through npm.`},installSource:e.facts.installSource,newVersion:t?e.target.targetVersion:void 0,success:t}}};function An(e){return`facts`in e?e.facts.installSource:e.installSource}const jn={source:`source`,canHandle:e=>{let t=`facts`in e?e.facts.installSource:e.installSource;return t===`source`||t===`unknown`},getRecoveryHint:()=>void 0,async upgrade(e){return{error:{kind:`unsupported`,message:`Install source "${e.facts.installSource}" does not support auto-update.`},installSource:e.facts.installSource,success:!1}}},Mn=[xn,kn,ln,jn];function $(e){return Mn.find(t=>t.canHandle(e))??jn}function Nn(e,t,n=`stable`){return $({canAutoUpdate:e===`binary`||e===`bun`||e===`npm`,currentVersion:``,executablePath:t,installSource:e,packageRoot:``,updateChannel:n})}function Pn(e,t,n=`stable`,r){return r?.error?.kind===`locked`?`another qtx upgrade is already running; wait for it to finish and retry`:Nn(e,t,n).getRecoveryHint({canAutoUpdate:e===`binary`||e===`bun`||e===`npm`,currentVersion:``,executablePath:t,installSource:e,packageRoot:``,updateChannel:n},r)}function Fn(e,t){return t?.error?.kind===`locked`?`another qtx upgrade is already running; wait for it to finish and retry`:$(e).getRecoveryHint(e,t)}async function In(e){return qt(await J({updateChannel:e?.updateChannel}))}async function Ln(e){let t=await zn(e),n=await Fe();if(!n)return{error:{kind:`locked`,message:`Another qtx upgrade is already running.`},installSource:t.facts.installSource,success:!1};try{return Jt(t,await $(t).upgrade(t))}finally{await n()}}function Rn(e,t=n.execPath){return Pn(e,t)}async function zn(e){return e?`facts`in e?e:e.installSource===`binary`?J({facts:{canAutoUpdate:e.canAutoUpdate,currentVersion:e.currentVersion,executablePath:e.executablePath,installSource:e.installSource,packageRoot:e.packageRoot,updateChannel:e.updateChannel}}):Yt(e):J()}function Bn(e){return Wn({...e,error:null,ok:!0})}function Vn(e){return Wn({...e,ok:!1})}function Hn(e,t,n={}){let r=S();return r.cancelled&&!n.force||(r.outputMode===`json`?console.log(JSON.stringify(e,null,2)):r.outputMode===`ndjson`?Kn({action:e.action,data:e,target:e.target,type:`result`}):t(e)),e}function Un(e,t={}){let n=S();if(!(n.cancelled&&!t.force)&&n.outputMode===`ndjson`)return Kn(e)}function Wn(e){let t=S();return{action:e.action,data:e.data,error:e.error??null,exitCode:e.exitCode,meta:{fetchedAt:t.freshness?.fetchedAt,mode:t.outputMode,runId:t.runId,schemaVersion:`1`,source:t.freshness?.source,staleAfter:t.freshness?.staleAfter,timestamp:new Date().toISOString(),version:q()},ok:e.ok,target:e.target,warnings:e.warnings??[]}}function Gn(e){let t=S();return{action:e.action,data:e.data,meta:{fetchedAt:t.freshness?.fetchedAt,mode:`ndjson`,runId:t.runId,schemaVersion:`1`,source:t.freshness?.source,staleAfter:t.freshness?.staleAfter,timestamp:new Date().toISOString(),version:q()},target:e.target,type:e.type}}function Kn(e){let t=Gn(e);return console.log(JSON.stringify(t)),t}const{createColors:qn,isColorSupported:Jn}=ie;function Yn(){let e=S().colorMode??`auto`;return qn(e===`always`?!0:e===`never`?!1:Jn)}const Xn=new Proxy({},{get(e,t){let n=Yn(),r=n[t];return typeof r==`function`?r.bind(n):r}});export{be as $,H as A,V as B,Ot as C,vt as D,G as E,ut as F,M as G,z as H,dt as I,we as J,N as K,$e as L,ct as M,at as N,ot as O,st as P,ye as Q,et as R,J as S,q as T,F as U,tt as V,P as W,w as X,Pe as Y,T as Z,dn as _,Hn as a,S as at,pn as b,Ln as c,oe as ct,Dn as d,E as et,Cn as f,hn as g,Tn as h,Un as i,ue as it,U as j,lt as k,Pn as l,wn as m,Vn as n,ve as nt,Rn as o,se as ot,En as p,A as q,Bn as r,C as rt,In as s,ce as st,Xn as t,xe as tt,Fn as u,mn as v,K as w,qt as x,fn as y,B as z};
@@ -0,0 +1 @@
1
+ import{t as e}from"./commands-DoiBUV3g.mjs";export{e as commandsCommand};
@@ -1,3 +1,3 @@
1
- import{a as e,r as t,t as n}from"./color-DEbCq7kh.mjs";const r=[{flags:[`--json`,`--output`,`--non-interactive`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`capabilities`,outputSchemaRef:`#/commands/capabilities`,stability:`stable`,summary:`Return environment and surface capabilities`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--timeout`],name:`commands`,outputSchemaRef:`#/commands/commands`,stability:`stable`,summary:`Return the stable command catalog`},{flags:[`get`,`set`,`reset`,`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--timeout`],name:`config`,outputSchemaRef:`#/commands/config`,stability:`stable`,summary:`Read and modify Quantex configuration`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`doctor`,outputSchemaRef:`#/commands/doctor`,stability:`stable`,summary:`Diagnose the current environment and installed tools`},{flags:[`--install`,`--non-interactive`,`--yes`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--output`],name:`exec`,outputSchemaRef:`#/commands/exec`,stability:`stable`,summary:`Run an agent with explicit install policy`},{flags:[`--json`,`--output`,`--yes`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--timeout`,`--idempotency-key`],name:`ensure`,outputSchemaRef:`#/commands/ensure`,stability:`stable`,summary:`Ensure an agent is installed`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`info`,outputSchemaRef:`#/commands/info`,stability:`stable`,summary:`Show human-friendly agent details`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`inspect`,outputSchemaRef:`#/commands/inspect`,stability:`stable`,summary:`Return structured agent state`},{flags:[`--json`,`--output`,`--yes`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--timeout`,`--idempotency-key`],name:`install`,outputSchemaRef:`#/commands/install`,stability:`stable`,summary:`Install one or more agents`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`list`,outputSchemaRef:`#/commands/list`,stability:`stable`,summary:`List supported agents`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`resolve`,outputSchemaRef:`#/commands/resolve`,stability:`stable`,summary:`Resolve an agent executable entrypoint`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--timeout`],name:`schema`,outputSchemaRef:`#/commands/schema`,stability:`stable`,summary:`Return structured output schemas`},{flags:[`--all`,`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--refresh`,`--no-cache`,`--timeout`,`--idempotency-key`],name:`update`,outputSchemaRef:`#/commands/update`,stability:`stable`,summary:`Update one or all agents`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--timeout`,`--idempotency-key`],name:`uninstall`,outputSchemaRef:`#/commands/uninstall`,stability:`stable`,summary:`Uninstall an agent`},{flags:[`--check`,`--channel`,`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--refresh`,`--no-cache`,`--timeout`,`--idempotency-key`],name:`upgrade`,outputSchemaRef:`#/commands/upgrade`,stability:`stable`,summary:`Upgrade Quantex CLI itself`}];async function i(){return e(t({action:`commands`,data:{commands:r},target:{kind:`system`,name:`commands`}}),a)}function a(e){if(e.data){console.log(n.bold(`
1
+ import{a as e,r as t,t as n}from"./color-DSVKeNpv.mjs";const r=[{flags:[`--json`,`--output`,`--non-interactive`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`capabilities`,outputSchemaRef:`#/commands/capabilities`,stability:`stable`,summary:`Return environment and surface capabilities`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--timeout`],name:`commands`,outputSchemaRef:`#/commands/commands`,stability:`stable`,summary:`Return the stable command catalog`},{flags:[`get`,`set`,`reset`,`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--timeout`],name:`config`,outputSchemaRef:`#/commands/config`,stability:`stable`,summary:`Read and modify Quantex configuration`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`doctor`,outputSchemaRef:`#/commands/doctor`,stability:`stable`,summary:`Diagnose the current environment and installed tools`},{flags:[`--install`,`--non-interactive`,`--yes`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--output`],name:`exec`,outputSchemaRef:`#/commands/exec`,stability:`stable`,summary:`Run an agent with explicit install policy`},{flags:[`--json`,`--output`,`--yes`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--timeout`,`--idempotency-key`],name:`ensure`,outputSchemaRef:`#/commands/ensure`,stability:`stable`,summary:`Ensure an agent is installed`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`info`,outputSchemaRef:`#/commands/info`,stability:`stable`,summary:`Show human-friendly agent details`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`inspect`,outputSchemaRef:`#/commands/inspect`,stability:`stable`,summary:`Return structured agent state`},{flags:[`--json`,`--output`,`--yes`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--timeout`,`--idempotency-key`],name:`install`,outputSchemaRef:`#/commands/install`,stability:`stable`,summary:`Install one or more agents`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`list`,outputSchemaRef:`#/commands/list`,stability:`stable`,summary:`List supported agents`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--refresh`,`--no-cache`,`--timeout`],name:`resolve`,outputSchemaRef:`#/commands/resolve`,stability:`stable`,summary:`Resolve an agent executable entrypoint`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--timeout`],name:`schema`,outputSchemaRef:`#/commands/schema`,stability:`stable`,summary:`Return structured output schemas`},{flags:[`--all`,`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--refresh`,`--no-cache`,`--timeout`,`--idempotency-key`],name:`update`,outputSchemaRef:`#/commands/update`,stability:`stable`,summary:`Update one or all agents`},{flags:[`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--timeout`,`--idempotency-key`],name:`uninstall`,outputSchemaRef:`#/commands/uninstall`,stability:`stable`,summary:`Uninstall an agent`},{flags:[`--check`,`--channel`,`--json`,`--output`,`--quiet`,`--color`,`--log-level`,`--dry-run`,`--refresh`,`--no-cache`,`--timeout`,`--idempotency-key`],name:`upgrade`,outputSchemaRef:`#/commands/upgrade`,stability:`stable`,summary:`Upgrade Quantex CLI itself`}];async function i(){return e(t({action:`commands`,data:{commands:r},target:{kind:`system`,name:`commands`}}),a)}function a(e){if(e.data){console.log(n.bold(`
2
2
  Quantex Commands
3
3
  `));for(let t of e.data.commands){let e=t.flags.length>0?n.dim(` [${t.flags.join(`, `)}]`):``;console.log(` ${n.cyan(t.name)}${e}`),console.log(` ${t.summary}`),console.log(` ${n.dim(t.outputSchemaRef)}`)}console.log()}}export{i as t};
@@ -1,3 +1,3 @@
1
- import{$ as e,Q as t,a as n,et as r,n as i,nt as a,r as o,rt as s,t as c,tt as l}from"./color-DEbCq7kh.mjs";async function u(c,u,f){if(!c)return n(o({action:`config`,data:{action:`list`,config:await r()},target:{kind:`config`}}),d);switch(c){case`get`:{if(!u)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify a key`},target:{kind:`config`}}),d);let e=(await r())[u];return n(o({action:`config`,data:{action:`get`,key:u,value:typeof e==`number`||typeof e==`string`?e:void 0},target:{kind:`config`,name:u}}),d)}case`set`:{if(!u||f===void 0)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify both key and value`},target:{kind:`config`}}),d);if(u===`defaultPackageManager`&&!t(f))return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`defaultPackageManager must be bun, npm, or mise`},target:{kind:`config`,name:u}}),d);if(u===`npmBunUpdateStrategy`&&!e(f))return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`npmBunUpdateStrategy must be latest-major or respect-semver`},target:{kind:`config`,name:u}}),d);if(u===`selfUpdateChannel`&&f!==`stable`&&f!==`beta`)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`selfUpdateChannel must be stable or beta`},target:{kind:`config`,name:u}}),d);if(u===`selfUpdateRegistry`&&!s(f))return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`selfUpdateRegistry must be a valid absolute URL`},target:{kind:`config`,name:u}}),d);if([`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(u)){let e=Number.parseInt(f,10);if(!Number.isInteger(e)||e<=0)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`${u} must be a positive integer`},target:{kind:`config`,name:u}}),d);f=`${e}`}let a={};try{a=await r()}catch{}return a[u]=[`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(u)?Number.parseInt(f,10):u===`selfUpdateRegistry`?s(f):f,await l(a),n(o({action:`config`,data:{action:`set`,key:u,value:a[u]},target:{kind:`config`,name:u}}),d)}case`reset`:return await l(a),n(o({action:`config`,data:{action:`reset`,config:a},target:{kind:`config`}}),d);default:return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,details:{action:c},message:`Unknown action: ${c}`},target:{kind:`config`},warnings:[{code:`AVAILABLE_ACTIONS`,message:`Available actions: get, set, reset`}]}),d)}}function d(e){if(e.error){console.log(c.red(e.error.message));for(let t of e.warnings)console.log(t.message);return}if(e.data)switch(e.data.action){case`list`:console.log(c.bold(`
1
+ import{$ as e,Q as t,a as n,et as r,n as i,nt as a,r as o,rt as s,t as c,tt as l}from"./color-DSVKeNpv.mjs";async function u(c,u,f){if(!c)return n(o({action:`config`,data:{action:`list`,config:await r()},target:{kind:`config`}}),d);switch(c){case`get`:{if(!u)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify a key`},target:{kind:`config`}}),d);let e=(await r())[u];return n(o({action:`config`,data:{action:`get`,key:u,value:typeof e==`number`||typeof e==`string`?e:void 0},target:{kind:`config`,name:u}}),d)}case`set`:{if(!u||f===void 0)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify both key and value`},target:{kind:`config`}}),d);if(u===`defaultPackageManager`&&!t(f))return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`defaultPackageManager must be bun, npm, or mise`},target:{kind:`config`,name:u}}),d);if(u===`npmBunUpdateStrategy`&&!e(f))return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`npmBunUpdateStrategy must be latest-major or respect-semver`},target:{kind:`config`,name:u}}),d);if(u===`selfUpdateChannel`&&f!==`stable`&&f!==`beta`)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`selfUpdateChannel must be stable or beta`},target:{kind:`config`,name:u}}),d);if(u===`selfUpdateRegistry`&&!s(f))return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`selfUpdateRegistry must be a valid absolute URL`},target:{kind:`config`,name:u}}),d);if([`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(u)){let e=Number.parseInt(f,10);if(!Number.isInteger(e)||e<=0)return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`${u} must be a positive integer`},target:{kind:`config`,name:u}}),d);f=`${e}`}let a={};try{a=await r()}catch{}return a[u]=[`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(u)?Number.parseInt(f,10):u===`selfUpdateRegistry`?s(f):f,await l(a),n(o({action:`config`,data:{action:`set`,key:u,value:a[u]},target:{kind:`config`,name:u}}),d)}case`reset`:return await l(a),n(o({action:`config`,data:{action:`reset`,config:a},target:{kind:`config`}}),d);default:return n(i({action:`config`,error:{code:`INVALID_ARGUMENT`,details:{action:c},message:`Unknown action: ${c}`},target:{kind:`config`},warnings:[{code:`AVAILABLE_ACTIONS`,message:`Available actions: get, set, reset`}]}),d)}}function d(e){if(e.error){console.log(c.red(e.error.message));for(let t of e.warnings)console.log(t.message);return}if(e.data)switch(e.data.action){case`list`:console.log(c.bold(`
2
2
  Current Configuration:
3
3
  `)),console.log(JSON.stringify(e.data.config,null,2)),console.log();break;case`get`:console.log(e.data.value===void 0?c.gray(`(not set)`):String(e.data.value));break;case`set`:console.log(c.green(`Set ${e.data.key} = ${e.data.value}`));break;case`reset`:console.log(c.green(`Configuration reset to defaults.`));break}}export{u as configCommand};
@@ -0,0 +1 @@
1
+ import{U as e,W as t}from"./color-DSVKeNpv.mjs";import{toJSONSchema as n,z as r}from"zod";import i from"node:process";const a=[{name:`amp`,displayName:`Amp`,homepage:`https://ampcode.com/`,packages:{npm:`@sourcegraph/amp`},binaryName:`amp`,selfUpdate:{command:[`amp`,`update`]},versionProbe:{command:[`amp`,`version`]},platforms:{windows:[{type:`bun`},{type:`npm`}],macos:[{type:`bun`},{type:`npm`}],linux:[{type:`bun`},{type:`npm`}]}},{name:`auggie`,displayName:`Auggie CLI`,homepage:`https://docs.augmentcode.com/cli/overview`,packages:{npm:`@augmentcode/auggie`},binaryName:`auggie`,selfUpdate:{command:[`auggie`,`upgrade`]},versionProbe:{command:[`auggie`,`--version`]},platforms:{macos:[{type:`bun`},{type:`npm`}],linux:[{type:`bun`},{type:`npm`}]}},{name:`autohand`,lookupAliases:[`autohand-cli`],displayName:`Autohand Code CLI`,homepage:`https://autohand.ai/cli/`,packages:{npm:`autohand-cli`},binaryName:`autohand`,versionProbe:{command:[`autohand`,`--version`]},platforms:{windows:[{command:`iwr -useb https://autohand.ai/install.ps1 | iex`,type:`script`}],macos:[{command:`curl -fsSL https://autohand.ai/install.sh | bash`,type:`script`}],linux:[{command:`curl -fsSL https://autohand.ai/install.sh | bash`,type:`script`}]}},{name:`claude`,displayName:`Claude Code`,homepage:`https://code.claude.com/docs`,packages:{npm:`@anthropic-ai/claude-code`},binaryName:`claude`,selfUpdate:{command:[`claude`,`update`],fallbackCommands:[[`claude`,`upgrade`]]},platforms:{windows:[{type:`bun`},{type:`npm`},{command:`irm https://claude.ai/install.ps1 | iex`,type:`script`},{packageName:`Anthropic.ClaudeCode`,packageTargetKind:`id`,type:`winget`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://claude.ai/install.sh | bash`,type:`script`},{packageName:`claude-code`,packageTargetKind:`cask`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://claude.ai/install.sh | bash`,type:`script`},{packageName:`claude-code`,packageTargetKind:`cask`,type:`brew`}]}},{name:`codebuddy`,lookupAliases:[`codebuddy-code`],displayName:`CodeBuddy Code`,homepage:`https://www.codebuddy.cn/docs/cli/installation`,packages:{npm:`@tencent-ai/codebuddy-code`},binaryName:`codebuddy`,selfUpdate:{command:[`codebuddy`,`update`]},versionProbe:{command:[`codebuddy`,`--version`]},platforms:{windows:[{type:`bun`},{type:`npm`},{command:`irm https://www.codebuddy.cn/cli/install.ps1 | iex`,type:`script`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://www.codebuddy.cn/cli/install.sh | bash`,type:`script`},{packageName:`Tencent-CodeBuddy/tap/codebuddy-code`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://www.codebuddy.cn/cli/install.sh | bash`,type:`script`},{packageName:`Tencent-CodeBuddy/tap/codebuddy-code`,type:`brew`}]}},{name:`codex`,displayName:`Codex CLI`,homepage:`https://developers.openai.com/codex/cli`,packages:{mise:`npm:@openai/codex`,npm:`@openai/codex`},binaryName:`codex`,selfUpdate:{command:[`codex`,`--upgrade`]},platforms:{windows:[{type:`bun`},{type:`npm`},{type:`mise`}],macos:[{type:`bun`},{type:`npm`},{type:`mise`},{packageName:`codex`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{type:`mise`},{packageName:`codex`,type:`brew`}]}},{name:`copilot`,displayName:`GitHub Copilot CLI`,homepage:`https://github.com/features/copilot/cli`,packages:{npm:`@github/copilot`},binaryName:`copilot`,platforms:{windows:[{packageName:`GitHub.Copilot`,packageTargetKind:`id`,type:`winget`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://gh.io/copilot-install | bash`,type:`script`},{packageName:`copilot-cli`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://gh.io/copilot-install | bash`,type:`script`},{packageName:`copilot-cli`,type:`brew`}]}},{name:`crush`,displayName:`Crush`,homepage:`https://github.com/charmbracelet/crush`,packages:{npm:`@charmland/crush`},binaryName:`crush`,selfUpdate:{command:[`crush`,`update`]},versionProbe:{command:[`crush`,`--version`]},platforms:{windows:[{type:`bun`},{type:`npm`},{packageName:`charmbracelet.crush`,packageTargetKind:`id`,type:`winget`}],macos:[{type:`bun`},{type:`npm`},{packageName:`charmbracelet/tap/crush`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{packageName:`charmbracelet/tap/crush`,type:`brew`}]}},{name:`cursor`,lookupAliases:[`agent`],displayName:`Cursor CLI`,homepage:`https://cursor.com/docs/cli`,binaryName:`agent`,selfUpdate:{command:[`agent`,`update`]},versionProbe:{command:[`agent`,`--version`]},platforms:{windows:[{command:`irm 'https://cursor.com/install?win32=true' | iex`,type:`script`}],macos:[{command:`curl https://cursor.com/install -fsS | bash`,type:`script`}],linux:[{command:`curl https://cursor.com/install -fsS | bash`,type:`script`}]}},{name:`deepcode`,displayName:`Deep Code CLI`,homepage:`https://github.com/lessweb/deepcode-cli`,packages:{npm:`@vegamo/deepcode-cli`},binaryName:`deepcode`,versionProbe:{command:[`deepcode`,`--version`]},platforms:{windows:[{type:`npm`}],macos:[{type:`npm`}],linux:[{type:`npm`}]}},{name:`deepseek`,lookupAliases:[`deepseek-tui`],displayName:`DeepSeek TUI`,homepage:`https://github.com/Hmbown/DeepSeek-TUI`,packages:{cargo:`deepseek-tui-cli`,npm:`deepseek-tui`},binaryName:`deepseek`,selfUpdate:{command:[`deepseek`,`update`]},versionProbe:{command:[`deepseek`,`--version`]},platforms:{windows:[{type:`npm`},{packageInstallArgs:[`--locked`],type:`cargo`}],macos:[{type:`npm`},{packageInstallArgs:[`--locked`],type:`cargo`}],linux:[{type:`npm`},{packageInstallArgs:[`--locked`],type:`cargo`}]}},{name:`devin`,displayName:`Devin for Terminal`,homepage:`https://cli.devin.ai/`,binaryName:`devin`,selfUpdate:{command:[`devin`,`update`]},versionProbe:{command:[`devin`,`version`]},platforms:{windows:[{command:`irm https://static.devin.ai/cli/setup.ps1 | iex`,type:`script`}],macos:[{command:`curl -fsSL https://cli.devin.ai/install.sh | bash`,type:`script`}],linux:[{command:`curl -fsSL https://cli.devin.ai/install.sh | bash`,type:`script`}]}},{name:`droid`,displayName:`Droid`,homepage:`https://docs.factory.ai/cli/getting-started/overview`,packages:{npm:`droid`},binaryName:`droid`,selfUpdate:{command:[`droid`,`update`]},platforms:{windows:[{type:`bun`},{type:`npm`},{command:`irm https://app.factory.ai/cli/windows | iex`,type:`script`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://app.factory.ai/cli | sh`,type:`script`},{packageName:`droid`,packageTargetKind:`cask`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://app.factory.ai/cli | sh`,type:`script`},{packageName:`droid`,packageTargetKind:`cask`,type:`brew`}]}},{name:`forgecode`,lookupAliases:[`forge`],displayName:`ForgeCode`,homepage:`https://forgecode.dev`,packages:{npm:`forgecode`},binaryName:`forge`,selfUpdate:{command:[`forge`,`update`]},versionProbe:{command:[`forge`,`--version`]},platforms:{windows:[{type:`bun`},{type:`npm`},{command:`irm https://forgecode.dev/cli | iex`,type:`script`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://forgecode.dev/cli | sh`,type:`script`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://forgecode.dev/cli | sh`,type:`script`}]}},{name:`gemini`,displayName:`Gemini CLI`,homepage:`https://google-gemini.github.io/gemini-cli/docs/`,packages:{npm:`@google/gemini-cli`},binaryName:`gemini`,platforms:{windows:[{type:`bun`},{type:`npm`}],macos:[{type:`bun`},{type:`npm`},{packageName:`gemini-cli`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{packageName:`gemini-cli`,type:`brew`}]}},{name:`genie`,displayName:`Genie`,homepage:`https://jsr.io/@nicorio/genie`,packages:{deno:`jsr:@nicorio/genie`},binaryName:`genie`,platforms:{windows:[{packageInstallArgs:[`-A`],type:`deno`}],macos:[{packageInstallArgs:[`-A`],type:`deno`}],linux:[{packageInstallArgs:[`-A`],type:`deno`}]}},{name:`goose`,displayName:`Goose`,homepage:`https://github.com/aaif-goose/goose`,binaryName:`goose`,selfUpdate:{command:[`goose`,`update`]},versionProbe:{command:[`goose`,`--version`]},platforms:{windows:[{command:`curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | bash`,type:`script`},{command:`Invoke-WebRequest -Uri "https://raw.githubusercontent.com/aaif-goose/goose/main/download_cli.ps1" -OutFile "download_cli.ps1"; ./download_cli.ps1`,type:`script`}],macos:[{command:`curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | bash`,type:`script`},{packageName:`block-goose-cli`,type:`brew`}],linux:[{command:`curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | bash`,type:`script`},{packageName:`block-goose-cli`,type:`brew`}]}},{name:`jcode`,displayName:`JCode`,homepage:`https://github.com/1jehuang/jcode`,binaryName:`jcode`,versionProbe:{command:[`jcode`,`--version`]},platforms:{windows:[{command:`irm https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.ps1 | iex`,type:`script`}],macos:[{packageName:`1jehuang/jcode/jcode`,type:`brew`},{command:`curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash`,type:`script`}],linux:[{command:`curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash`,type:`script`}]}},{name:`junie`,displayName:`Junie CLI`,homepage:`https://junie.jetbrains.com/docs/junie-cli.html`,packages:{npm:`@jetbrains/junie`},binaryName:`junie`,versionProbe:{command:[`junie`,`--version`]},platforms:{windows:[{type:`bun`},{type:`npm`},{command:`iex (irm 'https://junie.jetbrains.com/install.ps1')`,type:`script`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://junie.jetbrains.com/install.sh | bash`,type:`script`},{packageName:`jetbrains-junie/junie/junie`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://junie.jetbrains.com/install.sh | bash`,type:`script`},{packageName:`jetbrains-junie/junie/junie`,type:`brew`}]}},{name:`kilo`,displayName:`Kilo CLI`,homepage:`https://kilo.ai/docs/cli`,packages:{npm:`@kilocode/cli`},binaryName:`kilo`,selfUpdate:{command:[`kilo`,`upgrade`]},platforms:{windows:[{type:`bun`},{type:`npm`}],macos:[{type:`bun`},{type:`npm`}],linux:[{type:`bun`},{type:`npm`}]}},{name:`kimi`,lookupAliases:[`kimi-code`,`kimi-cli`],displayName:`Kimi Code`,homepage:`https://moonshotai.github.io/kimi-cli/`,binaryName:`kimi`,packages:{uv:`kimi-cli`},selfUpdate:{command:[`uv`,`tool`,`upgrade`,`kimi-cli`,`--no-cache`]},versionProbe:{command:[`kimi`,`--version`]},platforms:{windows:[{command:`irm https://code.kimi.com/install.ps1 | iex`,type:`script`}],macos:[{packageInstallArgs:[`--python`,`3.13`],type:`uv`},{command:`curl -LsSf https://code.kimi.com/install.sh | bash`,type:`script`}],linux:[{packageInstallArgs:[`--python`,`3.13`],type:`uv`},{command:`curl -LsSf https://code.kimi.com/install.sh | bash`,type:`script`}]}},{name:`kiro`,lookupAliases:[`kiro-cli`],displayName:`Kiro CLI`,homepage:`https://kiro.dev/cli/`,binaryName:`kiro-cli`,versionProbe:{command:[`kiro-cli`,`--version`]},platforms:{windows:[{command:`irm 'https://cli.kiro.dev/install.ps1' | iex`,type:`script`}],macos:[{command:`curl -fsSL https://cli.kiro.dev/install | bash`,type:`script`}],linux:[{command:`curl -fsSL https://cli.kiro.dev/install | bash`,type:`script`}]}},{name:`omp`,displayName:`oh-my-pi (OMP)`,homepage:`https://github.com/can1357/oh-my-pi`,packages:{npm:`@oh-my-pi/pi-coding-agent`},binaryName:`omp`,versionProbe:{command:[`omp`,`--version`]},platforms:{windows:[{type:`bun`},{command:`irm https://omp.sh/install.ps1 | iex`,type:`script`}],macos:[{type:`bun`},{command:`curl -fsSL https://omp.sh/install | sh`,type:`script`}],linux:[{type:`bun`},{command:`curl -fsSL https://omp.sh/install | sh`,type:`script`}]}},{name:`opencode`,displayName:`OpenCode`,homepage:`https://opencode.ai`,packages:{npm:`opencode-ai`},binaryName:`opencode`,selfUpdate:{command:[`opencode`,`upgrade`]},platforms:{windows:[{type:`bun`},{type:`npm`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://opencode.ai/install | bash`,type:`script`},{packageName:`anomalyco/tap/opencode`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://opencode.ai/install | bash`,type:`script`},{packageName:`anomalyco/tap/opencode`,type:`brew`}]}},{name:`openhands`,displayName:`OpenHands CLI`,homepage:`https://docs.openhands.dev/openhands/usage/cli/installation`,binaryName:`openhands`,packages:{uv:`openhands`},selfUpdate:{command:[`uv`,`tool`,`upgrade`,`openhands`,`--python`,`3.12`]},versionProbe:{command:[`openhands`,`--version`]},platforms:{macos:[{packageInstallArgs:[`--python`,`3.12`],type:`uv`},{command:`curl -fsSL https://install.openhands.dev/install.sh | sh`,type:`script`}],linux:[{packageInstallArgs:[`--python`,`3.12`],type:`uv`},{command:`curl -fsSL https://install.openhands.dev/install.sh | sh`,type:`script`}]}},{name:`pi`,displayName:`Pi`,homepage:`https://pi.dev`,packages:{npm:`@mariozechner/pi-coding-agent`},binaryName:`pi`,selfUpdate:{command:[`pi`,`update`]},platforms:{windows:[{type:`bun`},{type:`npm`}],macos:[{type:`bun`},{type:`npm`}],linux:[{type:`bun`},{type:`npm`}]}},{name:`qoder`,lookupAliases:[`qodercli`],displayName:`Qoder CLI`,homepage:`https://docs.qoder.com/cli/quick-start`,packages:{npm:`@qoder-ai/qodercli`},binaryName:`qodercli`,selfUpdate:{command:[`qodercli`,`update`]},platforms:{windows:[{type:`bun`},{type:`npm`}],macos:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://qoder.com/install | bash`,type:`script`},{packageName:`qoderai/qoder/qodercli`,packageTargetKind:`cask`,type:`brew`}],linux:[{type:`bun`},{type:`npm`},{command:`curl -fsSL https://qoder.com/install | bash`,type:`script`},{packageName:`qoderai/qoder/qodercli`,packageTargetKind:`cask`,type:`brew`}]}},{name:`qwen`,displayName:`Qwen Code`,homepage:`https://qwenlm.github.io/qwen-code-docs/`,packages:{npm:`@qwen-code/qwen-code`},binaryName:`qwen`,platforms:{windows:[{command:`curl -fsSL -o %TEMP%\\install-qwen.bat https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.bat && %TEMP%\\install-qwen.bat`,type:`script`},{type:`bun`},{type:`npm`}],macos:[{command:`curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.sh | bash`,type:`script`},{type:`bun`},{type:`npm`},{packageName:`qwen-code`,type:`brew`}],linux:[{command:`curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.sh | bash`,type:`script`},{type:`bun`},{type:`npm`},{packageName:`qwen-code`,type:`brew`}]}},{name:`reasonix`,lookupAliases:[`deepseek-reasonix`],displayName:`Reasonix`,homepage:`https://github.com/esengine/DeepSeek-Reasonix`,packages:{npm:`reasonix`},binaryName:`reasonix`,selfUpdate:{command:[`reasonix`,`update`]},versionProbe:{command:[`reasonix`,`--version`]},platforms:{windows:[{type:`npm`}],macos:[{type:`npm`}],linux:[{type:`npm`}]}},{name:`vibe`,lookupAliases:[`mistral-vibe`],displayName:`Mistral Vibe`,homepage:`https://docs.mistral.ai/mistral-vibe/terminal/install`,binaryName:`vibe`,packages:{pip:`mistral-vibe`,uv:`mistral-vibe`},versionProbe:{command:[`vibe`,`--version`]},platforms:{windows:[{packageName:`mistral-vibe`,type:`uv`},{packageName:`mistral-vibe`,type:`pip`}],macos:[{command:`curl -LsSf https://mistral.ai/vibe/install.sh | bash`,type:`script`},{packageName:`mistral-vibe`,type:`uv`},{packageName:`mistral-vibe`,type:`pip`}],linux:[{command:`curl -LsSf https://mistral.ai/vibe/install.sh | bash`,type:`script`},{packageName:`mistral-vibe`,type:`uv`},{packageName:`mistral-vibe`,type:`pip`}]}},{name:`vtcode`,displayName:`VTCode`,homepage:`https://github.com/vinhnx/vtcode`,packages:{cargo:`vtcode`},binaryName:`vtcode`,selfUpdate:{command:[`vtcode`,`update`]},versionProbe:{command:[`vtcode`,`--version`]},platforms:{windows:[{type:`cargo`},{command:`irm https://raw.githubusercontent.com/vinhnx/vtcode/main/scripts/install.ps1 | iex`,type:`script`}],macos:[{command:`curl -fsSL https://raw.githubusercontent.com/vinhnx/vtcode/main/scripts/install.sh | bash`,type:`script`},{type:`cargo`},{packageName:`vtcode`,type:`brew`}],linux:[{command:`curl -fsSL https://raw.githubusercontent.com/vinhnx/vtcode/main/scripts/install.sh | bash`,type:`script`},{type:`cargo`},{packageName:`vtcode`,type:`brew`}]}}],o=r.string().min(1),s=r.array(o).min(1);r.enum([`windows`,`macos`,`linux`]);const c=r.enum([`bun`,`npm`,`brew`,`cargo`,`deno`,`mise`,`pip`,`uv`,`winget`]),l=r.enum([`package`,`cask`,`id`]),u={binaryName:o.optional(),packageInstallArgs:r.array(o).min(1).optional(),packageName:o.optional(),packageTargetKind:l.optional()},d=r.object({...u,type:c}).strict(),f=r.object({...u,command:o,type:r.literal(`script`)}).strict(),p=r.object({...u,command:o,type:r.literal(`binary`)}).strict(),m=r.discriminatedUnion(`type`,[d,f,p]),h=r.object({cargo:o.optional(),deno:o.optional(),mise:o.optional(),npm:o.optional(),pip:o.optional(),uv:o.optional()}).strict().refine(e=>Object.values(e).some(Boolean),{message:`packages must include at least one package identifier`}),ee=r.object({command:s,fallbackCommands:r.array(s).min(1).optional(),versionAfter:r.enum([`same-process`,`respawn`]).optional()}).strict(),te=r.object({command:s.optional()}).strict().refine(e=>e.command!==void 0,{message:`versionProbe must include a serializable command`}),g=r.object({linux:r.array(m).min(1).optional(),macos:r.array(m).min(1).optional(),windows:r.array(m).min(1).optional()}).strict().refine(e=>Object.values(e).some(Boolean),{message:`platforms must include at least one supported platform`}),_=r.object({binaryName:o,displayName:o,homepage:r.url().startsWith(`https://`),lookupAliases:r.array(o).min(1).optional(),name:o.regex(/^[a-z0-9][a-z0-9-]*$/),packages:h.optional(),platforms:g,selfUpdate:ee.optional(),versionProbe:te.optional()}).strict(),v=r.array(_).min(1),y={...n(v),$id:`https://github.com/Drswith/quantex-cli/schemas/agent-catalog.schema.json`,title:`Quantex Supported Agent Catalog`},b={},x=v.parse(a).map(T),S=new Map(x.map(e=>[e.name,e]));function C(){return x}function w(e){let t=S.get(e);if(!t)throw Error(`Unknown catalog agent: ${e}`);return t}function T(e){let t=b[e.name],n=E(e.versionProbe,t);return{...e,versionProbe:n}}function E(e,t){if(!(!e&&!t?.versionProbeParser))return{...e,...t?.versionProbeParser?{parser:t.versionProbeParser}:{}}}w(`amp`),w(`auggie`);const D=w(`autohand`),O=w(`claude`),k=w(`codebuddy`),A=w(`codex`),j=w(`copilot`);w(`crush`);const M=w(`cursor`),N=w(`deepcode`),P=w(`deepseek`),F=w(`devin`),I=w(`droid`);w(`forgecode`);const L=w(`gemini`),R=w(`genie`);w(`goose`);const z=w(`jcode`),ne=w(`junie`),B=w(`kilo`);w(`kimi`),w(`kiro`);const V=w(`omp`),H=w(`opencode`),U=w(`openhands`),W=w(`pi`),G=w(`qoder`);w(`qwen`);const K=w(`reasonix`),q=w(`vibe`),J=w(`vtcode`),Y=C();function X(){return Y}function Z(e){return Y.find(t=>t.name===e||(t.lookupAliases?.includes(e)??!1))}function re(e){return Z(e)}function ie(){switch(i.platform){case`win32`:return`windows`;case`darwin`:return`macos`;default:return`linux`}}async function Q(n){try{let{exitCode:r}=await e(t([n,`--version`]));return r===0}catch{return!1}}async function ae(){return Q(`bun`)}async function oe(){return Q(`npm`)}async function $(){return Q(`brew`)}async function se(){return Q(`deno`)}async function ce(){return Q(`cargo`)}async function le(){return Q(`mise`)}async function ue(){return Q(`winget`)}async function de(){return await Q(`pip`)||await Q(`pip3`)?!0:pe()}async function fe(){return Q(`uv`)}async function pe(){try{let{exitCode:n}=await e(t([`python`,`-m`,`pip`,`--version`]));if(n===0)return!0}catch{}try{let{exitCode:n}=await e(t([`python3`,`-m`,`pip`,`--version`]));return n===0}catch{return!1}}async function me(n){try{let{exitCode:r}=await e(t([i.platform===`win32`?`where`:`which`,n]));return r===0}catch{return!1}}export{V as A,_ as B,F as C,z as D,R as E,K as F,v as H,q as I,J as L,U as M,W as N,ne as O,G as P,w as R,P as S,L as T,y as V,k as _,ce as a,M as b,oe as c,ue as d,Z as f,O as g,D as h,ae as i,H as j,B as k,de as l,X as m,me as n,se as o,re as p,$ as r,le as s,ie as t,fe as u,A as v,I as w,N as x,j as y,C as z};
@@ -0,0 +1,3 @@
1
+ import{n as e,t}from"./messages-qcLhD-Gc.mjs";import{t as n}from"./agents-CXJLxw8j.mjs";import{a as r,c as i,d as a,i as o,l as s,o as c,r as l,s as u,u as d}from"./detect-Bqm_mjTq.mjs";import{H as f,a as p,q as m,r as h,s as g,t as _,u as v}from"./color-DSVKeNpv.mjs";async function y(){let m=await o(),_=await i(),y=await l(),S=await r(),C=await c(),w=await u(),T=await s(),E=await d(),D=await a(),O=await g(),k=O.latestVersion?f(O.latestVersion,O.currentVersion):!1,A=await n(),j=A.filter(e=>e.inPath).map(e=>({displayName:e.agent.displayName,installedVersion:e.installedVersion,latestVersion:e.latestVersion,lifecycle:e.lifecycle,outdated:!!(e.installedVersion&&e.latestVersion&&e.installedVersion!==e.latestVersion),sourceLabel:e.sourceLabel})),M=[],N=`docs/runbooks/quantex-troubleshooting.md`,P=`docs/runbooks/release-and-self-upgrade-debugging.md`;if(!m&&!_&&!y&&!S&&!C&&!w&&!T&&!E&&!D&&M.push({blocking:!0,category:`installers`,code:`NO_MANAGED_INSTALLER`,docsRef:N,message:`No managed installer found. Install bun, npm, brew, cargo, deno, mise, pip, uv, or winget before relying on managed lifecycle operations.`,severity:`warning`,subject:{kind:`system`},suggestedAction:`restore-managed-installer`,suggestedCommands:[]}),(O.installSource===`bun`&&!m||O.installSource===`npm`&&!_)&&M.push({blocking:!0,category:`self`,code:`SELF_INSTALLER_MISSING`,docsRef:P,message:`Quantex CLI is tracked as a ${O.installSource} install, but ${O.installSource} is not available in PATH. Reinstall that package manager or reinstall Quantex from a supported source.`,severity:`warning`,subject:{kind:`self`,name:`quantex`},suggestedAction:`restore-self-installer`,suggestedCommands:x(O.installSource,O.updateChannel)}),O.canAutoUpdate||M.push({blocking:!1,category:`self`,code:`SELF_AUTO_UPDATE_UNAVAILABLE`,docsRef:P,message:`Quantex CLI cannot auto-update from install source "${O.installSource}". Reinstall via bun, npm, or the standalone binary if you want \`quantex upgrade\` support.`,severity:`warning`,subject:{kind:`self`,name:`quantex`},suggestedAction:`reinstall-self-with-auto-update-source`,suggestedCommands:[]}),k&&O.recommendedUpgradeCommand){let e=v(O);M.push({blocking:!1,category:`self`,code:`SELF_UPDATE_AVAILABLE`,docsRef:P,message:e?`Quantex CLI ${O.currentVersion} is behind ${O.latestVersion}. Run ${O.recommendedUpgradeCommand} or follow: ${e}`:`Quantex CLI ${O.currentVersion} is behind ${O.latestVersion}. Run ${O.recommendedUpgradeCommand}.`,severity:`warning`,subject:{kind:`self`,name:`quantex`},suggestedAction:`run-self-upgrade`,suggestedCommands:[O.recommendedUpgradeCommand]})}for(let n of A.filter(e=>e.inPath)){if(n.installedState||M.push({blocking:!1,category:`agent`,code:`AGENT_UNTRACKED_IN_PATH`,docsRef:N,message:`${n.agent.displayName} is available in PATH but not tracked as a managed Quantex install. Use \`quantex inspect ${n.agent.name} --json\` to confirm the source, then reinstall through Quantex if you want managed lifecycle operations.`,severity:`warning`,subject:{kind:`agent`,name:n.agent.name},suggestedAction:`inspect-agent-install-source`,suggestedCommands:[`quantex inspect ${n.agent.name} --json`,`quantex install ${n.agent.name}`]}),!(n.installedVersion&&n.latestVersion&&n.installedVersion!==n.latestVersion)||n.lifecycle===`managed`)continue;let r=t(n.agent,n.agent.selfUpdate?`self-update`:`manual-hint`)??e(n.agent);M.push({blocking:!1,category:`agent`,code:`AGENT_MANUAL_UPDATE_REQUIRED`,docsRef:N,message:`${n.agent.displayName} ${n.installedVersion} is behind ${n.latestVersion}, but the current source is ${n.sourceLabel}. ${r}`,severity:`warning`,subject:{kind:`agent`,name:n.agent.name},suggestedAction:n.agent.selfUpdate?`run-agent-self-update`:`follow-manual-agent-update`,suggestedCommands:n.agent.selfUpdate?[n.agent.selfUpdate.command.join(` `)]:[]})}return p(h({action:`doctor`,data:{agents:j,issues:M,installers:{brew:y,bun:m,cargo:S,deno:C,mise:w,npm:_,pip:T,uv:E,winget:D},self:{canAutoUpdate:O.canAutoUpdate,currentVersion:O.currentVersion,installSource:O.installSource,latestVersion:O.latestVersion,outdated:!!k,recoveryHint:k?v(O):void 0}},target:{kind:`system`,name:`doctor`}}),b)}function b(e){if(e.data){if(console.log(_.bold(`
2
+ Quantex CLI Environment Check
3
+ `)),console.log(_.bold(`Managed Installers:`)),console.log(` Bun: ${e.data.installers.bun?_.green(`available`):_.red(`not found`)}`),console.log(` npm: ${e.data.installers.npm?_.green(`available`):_.red(`not found`)}`),console.log(` brew: ${e.data.installers.brew?_.green(`available`):_.red(`not found`)}`),console.log(` cargo: ${e.data.installers.cargo?_.green(`available`):_.red(`not found`)}`),console.log(` deno: ${e.data.installers.deno?_.green(`available`):_.red(`not found`)}`),console.log(` mise: ${e.data.installers.mise?_.green(`available`):_.red(`not found`)}`),console.log(` pip: ${e.data.installers.pip?_.green(`available`):_.red(`not found`)}`),console.log(` uv: ${e.data.installers.uv?_.green(`available`):_.red(`not found`)}`),console.log(` winget:${e.data.installers.winget?_.green(`available`):_.red(`not found`)}`),console.log(`\n${_.bold(`Quantex CLI:`)}`),console.log(` Version: ${e.data.self.currentVersion}`),console.log(` Source: ${e.data.self.installSource}`),console.log(` Auto-update: ${e.data.self.canAutoUpdate?_.green(`supported`):_.yellow(`unsupported`)}`),e.data.self.latestVersion&&console.log(` Latest: ${e.data.self.latestVersion}${e.data.self.outdated?_.yellow(` (update available)`):``}`),e.data.self.recoveryHint&&console.log(` Recovery: ${e.data.self.recoveryHint}`),console.log(`\n${_.bold(`Installed Agents:`)}`),e.data.agents.length===0)console.log(_.dim(` No agents installed`));else for(let t of e.data.agents)console.log(` ${t.displayName}: ${t.installedVersion??`unknown`} [${t.lifecycle}; ${t.sourceLabel}]${t.outdated?_.yellow(` (update available: ${t.latestVersion})`):``}`);if(console.log(`\n${_.bold(`Issues:`)}`),e.data.issues.length===0)console.log(_.green(` No issues found.`));else for(let t of e.data.issues)console.log(_.yellow(` - ${t.message}`)),t.suggestedCommands.length>0&&console.log(_.dim(` Next: ${t.suggestedCommands.join(` | `)}`));console.log()}}function x(e,t){let n=t===`beta`?`beta`:`latest`;return e===`bun`?[`bun add -g ${m}@${n}`]:e===`npm`?[`npm install -g ${m}@${n}`]:[]}export{y as doctorCommand};
@@ -1 +1 @@
1
- import{b as e,c as t,r as n,s as r}from"./agents-Egq0RCta.mjs";import{J as i,a,i as o,n as s,r as c,t as l}from"./color-DEbCq7kh.mjs";import{t as u}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as d,i as f,n as p,r as m}from"./user-output-DoYIFFWA.mjs";async function h(l){let d=await n(l);if(!d)return a(s({action:`ensure`,error:{code:`AGENT_NOT_FOUND`,details:{input:l},message:`Unknown agent: ${l}`},target:{kind:`agent`,name:l}}),g);let{agent:f,inspection:m}=d;if(m.inPath){if(m.installedState)return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`ALREADY_INSTALLED`,message:`${f.displayName} is already installed.`}]}),g);let n=e(m.methods,m.resolvedBinaryPath??m.binaryPath);if(n){if(p())return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would record the existing ${f.displayName} install in Quantex state.`}]}),g);o({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name}},target:{kind:`agent`,name:f.name},type:`started`});try{let e=await t(f,n);return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!0,installState:{installType:e.installType,packageName:e.packageName},installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`TRACKED_EXISTING_INSTALL`,message:`${f.displayName} is already installed. Quantex is now tracking the existing install.`}]}),g)}catch(e){if(i(e))return a(s({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},...u(e,{kind:`agent`,name:f.name})}),g);throw e}}return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`UNTRACKED_EXISTING_INSTALL`,message:`${f.displayName} is already installed but not tracked by Quantex. Quantex could not safely determine the supported install source, so the existing install remains unmanaged.`}]}),g)}if(p())return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!1},target:{kind:`agent`,name:f.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would install ${f.displayName}.`}]}),g);o({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name}},target:{kind:`agent`,name:f.name},type:`started`});let h;try{h=await r(f)}catch(e){if(i(e))return a(s({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!1},...u(e,{kind:`agent`,name:f.name})}),g);throw e}return h.success?a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!0,installState:h.installedState?{installType:h.installedState.installType,packageName:h.installedState.packageName}:void 0,installed:!0},target:{kind:`agent`,name:f.name}}),g):a(s({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!1},error:{code:`INSTALL_FAILED`,message:`Failed to install ${f.displayName}.`},target:{kind:`agent`,name:f.name}}),g)}function g(e){if(e.error){m(l.red(e.error.message));return}if(e.data){if(e.warnings.length>0){for(let t of e.warnings){if(t.code===`TRACKED_EXISTING_INSTALL`){f(l.green(t.message));continue}if(t.code===`DRY_RUN`){d(l.cyan(t.message));continue}d(l.yellow(t.message))}return}if(e.data.changed){f(l.cyan(`Installing ${e.data.agent.displayName}...`)),f(l.green(`${e.data.agent.displayName} is now installed.`));return}f(l.green(`${e.data.agent.displayName} is already installed.`))}}export{h as t};
1
+ import{b as e,c as t,r as n,s as r}from"./agents-CXJLxw8j.mjs";import{J as i,a,i as o,n as s,r as c,t as l}from"./color-DSVKeNpv.mjs";import{t as u}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as d,i as f,n as p,r as m}from"./user-output-lYZ8Muqt.mjs";async function h(l){let d=await n(l);if(!d)return a(s({action:`ensure`,error:{code:`AGENT_NOT_FOUND`,details:{input:l},message:`Unknown agent: ${l}`},target:{kind:`agent`,name:l}}),g);let{agent:f,inspection:m}=d;if(m.inPath){if(m.installedState)return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`ALREADY_INSTALLED`,message:`${f.displayName} is already installed.`}]}),g);let n=e(m.methods,m.resolvedBinaryPath??m.binaryPath);if(n){if(p())return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would record the existing ${f.displayName} install in Quantex state.`}]}),g);o({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name}},target:{kind:`agent`,name:f.name},type:`started`});try{let e=await t(f,n);return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!0,installState:{installType:e.installType,packageName:e.packageName},installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`TRACKED_EXISTING_INSTALL`,message:`${f.displayName} is already installed. Quantex is now tracking the existing install.`}]}),g)}catch(e){if(i(e))return a(s({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},...u(e,{kind:`agent`,name:f.name})}),g);throw e}}return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!0},target:{kind:`agent`,name:f.name},warnings:[{code:`UNTRACKED_EXISTING_INSTALL`,message:`${f.displayName} is already installed but not tracked by Quantex. Quantex could not safely determine the supported install source, so the existing install remains unmanaged.`}]}),g)}if(p())return a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!1},target:{kind:`agent`,name:f.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would install ${f.displayName}.`}]}),g);o({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name}},target:{kind:`agent`,name:f.name},type:`started`});let h;try{h=await r(f)}catch(e){if(i(e))return a(s({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!1},...u(e,{kind:`agent`,name:f.name})}),g);throw e}return h.success?a(c({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!0,installState:h.installedState?{installType:h.installedState.installType,packageName:h.installedState.packageName}:void 0,installed:!0},target:{kind:`agent`,name:f.name}}),g):a(s({action:`ensure`,data:{agent:{displayName:f.displayName,name:f.name},changed:!1,installed:!1},error:{code:`INSTALL_FAILED`,message:`Failed to install ${f.displayName}.`},target:{kind:`agent`,name:f.name}}),g)}function g(e){if(e.error){m(l.red(e.error.message));return}if(e.data){if(e.warnings.length>0){for(let t of e.warnings){if(t.code===`TRACKED_EXISTING_INSTALL`){f(l.green(t.message));continue}if(t.code===`DRY_RUN`){d(l.cyan(t.message));continue}d(l.yellow(t.message))}return}if(e.data.changed){f(l.cyan(`Installing ${e.data.agent.displayName}...`)),f(l.green(`${e.data.agent.displayName} is now installed.`));return}f(l.green(`${e.data.agent.displayName} is already installed.`))}}export{h as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./ensure-CHdbUTxg.mjs";export{e as ensureCommand};