quantex-cli 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +26 -2
  2. package/dist/{agents-BPMc1vIb.mjs → agents-bx8y3kRS.mjs} +1 -1
  3. package/dist/capabilities-C4rAD7sw.mjs +1 -0
  4. package/dist/{capabilities-CUyQejux.mjs → capabilities-KKT-gyc8.mjs} +1 -1
  5. package/dist/cli.mjs +1 -1
  6. package/dist/color-BbKp9aSG.mjs +4 -0
  7. package/dist/{commands-B4PWQRb1.mjs → commands-CJquInVH.mjs} +1 -1
  8. package/dist/commands-v1Sz-UYE.mjs +1 -0
  9. package/dist/{config-AtPtndss.mjs → config-D2XKUMhE.mjs} +1 -1
  10. package/dist/detect-FhBDsvJC.mjs +1 -0
  11. package/dist/doctor-D59eSvXO.mjs +3 -0
  12. package/dist/ensure-B4-KmDVN.mjs +1 -0
  13. package/dist/{ensure-CICTMwyQ.mjs → ensure-BceOwwrn.mjs} +1 -1
  14. package/dist/index.d.mts +11 -0
  15. package/dist/index.mjs +2 -2
  16. package/dist/{info-S-XkpGfH.mjs → info-DuDumnqd.mjs} +1 -1
  17. package/dist/inspect-C8CfhNED.mjs +1 -0
  18. package/dist/{inspect-CrAtG1sO.mjs → inspect-DIZiG8De.mjs} +1 -1
  19. package/dist/{install-C4UFbLXt.mjs → install-CdmFxCHJ.mjs} +1 -1
  20. package/dist/{list-BFP0FCnu.mjs → list-B-Uy3llF.mjs} +1 -1
  21. package/dist/messages-DMxGs5hh.mjs +1 -0
  22. package/dist/resolve-B_IU5vbb.mjs +1 -0
  23. package/dist/resolve-CpAvaM7V.mjs +1 -0
  24. package/dist/schema-Ckf19SIa.mjs +3 -0
  25. package/dist/schema-CvjJUAJb.mjs +1 -0
  26. package/dist/{uninstall-BDoLpgpH.mjs → uninstall-PDslmq45.mjs} +1 -1
  27. package/dist/update-BG44eiCz.mjs +1 -0
  28. package/dist/update-DHOTks91.mjs +1 -0
  29. package/dist/{upgrade-DetftUCc.mjs → upgrade-D9rsTwGk.mjs} +1 -1
  30. package/dist/{user-output-DYsOPwi1.mjs → user-output-DFxUPA-p.mjs} +1 -1
  31. package/package.json +9 -3
  32. package/dist/capabilities-BO5CNv4G.mjs +0 -1
  33. package/dist/color-CbC8zjc1.mjs +0 -4
  34. package/dist/commands-BzfE2L4B.mjs +0 -1
  35. package/dist/detect-q8eznhj9.mjs +0 -1
  36. package/dist/doctor-CEdPHLNc.mjs +0 -3
  37. package/dist/ensure-rkgpIWy6.mjs +0 -1
  38. package/dist/inspect-D3xXVuL2.mjs +0 -1
  39. package/dist/resolve-BaEyqkW-.mjs +0 -1
  40. package/dist/resolve-BueWa31L.mjs +0 -1
  41. package/dist/schema-C7gYIpnh.mjs +0 -1
  42. package/dist/schema-CrujLfID.mjs +0 -3
  43. package/dist/update-BufYok78.mjs +0 -1
  44. package/dist/update-CtO35mwD.mjs +0 -1
package/README.md CHANGED
@@ -15,8 +15,29 @@
15
15
 
16
16
  ## 设计文档
17
17
 
18
- - [Human + Agent 双模 CLI 设计](./HUMAN_AGENT_DUAL_MODE_CLI.md)
19
- - [Human + Agent 双模 CLI Implementation Checklist / Issue Backlog](./HUMAN_AGENT_DUAL_MODE_CLI_IMPLEMENTATION_BACKLOG.md)
18
+ - [Human + Agent 双模 CLI 设计](./docs/archive/legacy-root-notes/HUMAN_AGENT_DUAL_MODE_CLI.md)
19
+ - [Human + Agent 双模 CLI Implementation Checklist / Issue Backlog](./docs/archive/legacy-root-notes/HUMAN_AGENT_DUAL_MODE_CLI_IMPLEMENTATION_BACKLOG.md)
20
+
21
+ ## Project Memory
22
+
23
+ 仓库现在开始采用一套面向 `human + agent` 协作、并为未来 agent 自主迭代预留的 repo-native 文档结构:
24
+
25
+ - [docs/README.md](./docs/README.md)
26
+ - [docs/adr/](./docs/adr/)
27
+ - [docs/runbooks/](./docs/runbooks/)
28
+ - [docs/sessions/](./docs/sessions/)
29
+ - [docs/github-collaboration.md](./docs/github-collaboration.md)
30
+ - [autonomy/README.md](./autonomy/README.md)
31
+ - [openspec/README.md](./openspec/README.md)
32
+
33
+ 迁移期遗留文档的归档位置和映射关系见 [docs/project-memory-migration.md](./docs/project-memory-migration.md)。
34
+
35
+ ## Releases
36
+
37
+ Quantex 的 canonical changelog 在 GitHub Releases:
38
+
39
+ - [GitHub Releases](https://github.com/Drswith/quantex-cli/releases)
40
+ - [docs/releases.md](./docs/releases.md)
20
41
 
21
42
  ## Agent Skill
22
43
 
@@ -28,6 +49,7 @@
28
49
  - [skills/quantex-cli/references/output-contracts.md](./skills/quantex-cli/references/output-contracts.md)
29
50
  - [skills/quantex-cli/references/troubleshooting.md](./skills/quantex-cli/references/troubleshooting.md)
30
51
  - [skills/quantex-cli/scripts/smoke-check.sh](./skills/quantex-cli/scripts/smoke-check.sh)
52
+ - [docs/skill-installation-and-distribution.md](./docs/skill-installation-and-distribution.md)
31
53
 
32
54
  这份 skill 会引导 agent 以 Quantex 的 lifecycle CLI 方式工作,优先使用 `inspect` / `ensure` / `resolve` / `exec` / `capabilities` / `commands` / `schema`,并遵循结构化输出、非交互和自动化契约。
33
55
 
@@ -39,6 +61,8 @@ skills/quantex-cli/scripts/smoke-check.sh
39
61
 
40
62
  它会对 `capabilities`、`commands`、`schema`、`inspect` 以及可选的 `resolve` 做一轮轻量结构化 smoke check。
41
63
 
64
+ 当前这份 skill 仍然是 repo-native artifact:支持随仓库共享、按仓库 revision 使用,或复制整个 `skills/quantex-cli/` 目录到兼容的技能目录;还没有单独的 marketplace / package 发布流。细节见 [docs/skill-installation-and-distribution.md](./docs/skill-installation-and-distribution.md)。
65
+
42
66
  ## 支持的 Agent
43
67
 
44
68
  | Agent | 命令 | 别名 | 描述 |
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,t as s}from"./detect-q8eznhj9.mjs";import{C as c,D as ee,E as te,F as l,H as u,N as ne,O as d,R as f,S as p,_ as re,b as ie,g as ae,h as oe,k as m,m as se,v as ce,x as h,y as g}from"./color-CbC8zjc1.mjs";import _ from"node:process";const v={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`},npm:{canInstall:!0,canLookupLatestVersion:!0,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 y(e){return v[e]}function b(e){return y(e).lifecycle===`managed`}function x(e){return y(e).lifecycle}function S(e){return y(e).canUpdate}function le(e){return y(e).canUninstall}function C(e){return y(e).canLookupLatestVersion}function w(e,t){return e?t===`cask`?` (${e} cask)`:t===`id`?` (${e} id)`:` (${e})`:``}function T(e,t){return t.packageName||e.packages?.npm||void 0}function E(e){return e?S(e.installType):!1}function D(e,t){return E(t)||!!e.selfUpdate}function ue(e){return!!e&&C(e.installType)}function de(e){return e.length>0&&e.every(e=>C(e.type))}function fe(e){return b(e.type)?`${x(e.type)}/${e.type}${w(e.packageName,e.packageTargetKind)}`:e.type===`script`?`unmanaged/script`:`unmanaged/binary`}function pe(e){return e?b(e.installType)?`managed via ${e.installType}${w(e.packageName,e.packageTargetKind)}`:e.installType===`script`?`script installer`:`binary installer`:`detected in PATH`}function me(e,t){let n=P({agent:e,installedState:t,methods:[]});return n===`managed`?`managed update`:n===`self-update`?`command update`:`manual update`}function he(e,t){if(t.type===`bun`){let n=T(e,t);return n?`bun add -g ${n}`:``}if(t.type===`npm`){let n=T(e,t);return n?`npm i -g ${n}`:``}return t.type===`brew`?t.packageName?t.packageTargetKind===`cask`?`brew install --cask ${t.packageName}`:`brew install ${t.packageName}`:``:t.type===`winget`?t.packageName?`winget install --id ${t.packageName} -e`:``:t.command??``}function ge(e,t,n){if(t)return ue(t)&&(t.packageName||e.packages?.npm)||void 0;if(!(!e.packages?.npm||!de(n)))return e.packages.npm}function O(e){if(e.installedState&&b(e.installedState.installType))return e.installedState.installType;for(let t of e.methods)if(b(t.type)&&S(t.type))return t.type}const k={strategy:`managed`,canHandle:e=>!!O(e),getManagedInstallerType:e=>O(e)},A={strategy:`self-update`,canHandle:e=>!E(e.installedState)&&!!e.agent.selfUpdate},j={strategy:`manual-hint`,canHandle:()=>!0},M=[k,A,j];function N(e){return M.find(t=>t.canHandle(e))??j}function P(e){return N(e).strategy}function F(e){return D(e.agent,e.installedState)}async function I(e){let t=s(),n=typeof e==`function`?e(t):e;try{return _.platform===`win32`?await c(p([`powershell.exe`,`-Command`,n]))===0:await c(p([`sh`,`-c`,n]))===0}catch{return!1}}function L(e){return e===`cask`?[`--cask`]:[]}async function R(e,t,n){try{return await c(p([`brew`,e,...L(n),t]))===0}catch{return!1}}async function _e(e,t){return R(`install`,e,t)}async function z(e,t){return R(`upgrade`,e,t)}async function ve(e){for(let t of e)if(!await z(t.packageName,t.packageTargetKind))return!1;return!0}async function ye(e,t){return R(`uninstall`,e,t)}async function B(e,t){try{return await c(p([`winget`,e,`--id`,t,`-e`]))===0}catch{return!1}}async function be(e){return B(`install`,e)}async function V(e){return B(`upgrade`,e)}async function xe(e){for(let t of e)if(!await V(t.packageName))return!1;return!0}async function Se(e){return B(`uninstall`,e)}const Ce={brew:{type:`brew`,isAvailable:async()=>o(),install:async(e,t)=>_e(e,t),uninstall:async(e,t)=>ye(e,t),update:async(e,t)=>z(e,t),updateMany:async e=>ve(e)},bun:{type:`bun`,isAvailable:async()=>n(),install:async e=>ce(e),uninstall:async e=>g(e),update:async(e,t,n)=>ie(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>h(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},npm:{type:`npm`,isAvailable:async()=>e(),install:async e=>se(e),uninstall:async e=>oe(e),update:async(e,t,n)=>ae(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>re(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},winget:{type:`winget`,isAvailable:async()=>a(),install:async e=>be(e),uninstall:async e=>Se(e),update:async e=>V(e),updateMany:async e=>xe(e.map(e=>({packageName:e.packageName})))}};function H(e){return Ce[e]}const U={resource:`agent lifecycle`,scope:[`agent-lifecycle`]};async function we(){return(await u()).defaultPackageManager}async function W(){return{npmBunUpdateStrategy:(await u()).npmBunUpdateStrategy}}async function G(e){let t=s(),n=e.platforms[t];if(!n)return[];let r=await we();return r?[...n.filter(e=>e.type===r),...n.filter(e=>e.type!==r)]:[...n]}async function K(e,t,n,r,i){let a=H(e);return await a.isAvailable()?r===`install`?a.install(t,n):r===`update`?a.update(t,n,{npmBunUpdateStrategy:i}):a.uninstall(t,n):!1}async function q(e,t,n,r){if(b(t.type)){let i=T(e,t);return i?K(t.type,i,t.packageTargetKind,n,r):!1}return n===`update`&&!S(t.type)||!t.command?!1:I(t.command)}async function J(e,t,n){return b(e.installType)?e.packageName?K(e.installType,e.packageName,e.packageTargetKind,t,n):!1:t!==`install`||!e.command?!1:I(e.command)}async function Te(e){if(!e.selfUpdate)return!1;let t=[e.selfUpdate.command,...e.selfUpdate.fallbackCommands??[]];for(let e of t)if(await I(e.join(` `)))return!0;return!1}async function Y(e,t){let n={agentName:e.name,installType:t.type,packageName:T(e,t),packageTargetKind:t.packageTargetKind,command:`command`in t?t.command:void 0};return await l(n),n}async function Ee(e){return f(U,async()=>{let t=await G(e);for(let n of t)if(await q(e,n,`install`))return{success:!0,installedState:await Y(e,n)};return{success:!1}})}async function X(e,t){return f(U,async()=>{let{npmBunUpdateStrategy:n}=await W(),r=await G(e);if(t&&await J(t,`update`,n))return await l(t),{success:!0,installedState:t};if(!t){for(let t of r)if(await q(e,t,`update`,n))return{success:!0,installedState:await Y(e,t)}}if(await Te(e))return{success:!0};if(t){for(let t of r)if(await q(e,t,`update`,n))return{success:!0,installedState:await Y(e,t)}}return{success:!1}})}async function De(e,t){return f(U,async()=>{let n=[...new Map(t.filter(e=>e.packageName).map(e=>[`${e.packageTargetKind??`package`}:${e.packageName}`,e])).values()],r=H(e);return await r.isAvailable()?r.updateMany(n,await W()):!1})}async function Oe(e){return f(U,async()=>{let t=await m(e.name);if(!t)return!1;let n=await J(t,`uninstall`);return n&&await ne(e.name),n})}async function Z(e){let[t,n,r]=await Promise.all([G(e),m(e.name),i(e.binaryName)]),[a,o,s]=await Promise.all([r?ee(e.binaryName,e.versionProbe):Promise.resolve(void 0),r?te(e.binaryName):Promise.resolve(void 0),ke(e,n,t)]);return{agent:e,methods:t,installedState:n,inPath:r,installedVersion:a,latestVersion:s,binaryPath:o,sourceLabel:pe(n),updateLabel:me(e,n),lifecycle:n?x(n.installType):`unmanaged`}}async function Q(e){return Promise.all(e.map(Z))}async function ke(e,t,n){let r=ge(e,t,n);if(r)return d(r)}function $(e){return t(e)}async function Ae(e){let t=$(e);if(t)return{agent:t,inspection:await Z(t)}}async function je(){return Q(r())}export{x as C,S,b as T,he as _,Q as a,C as b,Oe as c,H as d,M as f,D as g,N as h,Z as i,X as l,P as m,$ as n,G as o,F as p,Ae as r,Ee as s,je as t,De as u,fe as v,y as w,le as x,T as y};
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,t as s}from"./detect-FhBDsvJC.mjs";import{C as c,D as ee,E as l,F as u,N as te,O as ne,R as d,S as f,U as p,_ as re,b as ie,g as ae,h as oe,k as m,m as se,v as ce,x as h,y as g}from"./color-BbKp9aSG.mjs";import _ from"node:process";const v={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`},npm:{canInstall:!0,canLookupLatestVersion:!0,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 y(e){return v[e]}function b(e){return y(e).lifecycle===`managed`}function x(e){return y(e).lifecycle}function S(e){return y(e).canUpdate}function le(e){return y(e).canUninstall}function C(e){return y(e).canLookupLatestVersion}function w(e,t){return e?t===`cask`?` (${e} cask)`:t===`id`?` (${e} id)`:` (${e})`:``}function T(e,t){return t.packageName||e.packages?.npm||void 0}function E(e){return e?S(e.installType):!1}function D(e,t){return E(t)||!!e.selfUpdate}function ue(e){return!!e&&C(e.installType)}function de(e){return e.length>0&&e.every(e=>C(e.type))}function fe(e){return b(e.type)?`${x(e.type)}/${e.type}${w(e.packageName,e.packageTargetKind)}`:e.type===`script`?`unmanaged/script`:`unmanaged/binary`}function pe(e){return e?b(e.installType)?`managed via ${e.installType}${w(e.packageName,e.packageTargetKind)}`:e.installType===`script`?`script installer`:`binary installer`:`detected in PATH`}function me(e,t){let n=P({agent:e,installedState:t,methods:[]});return n===`managed`?`managed update`:n===`self-update`?`command update`:`manual update`}function he(e,t){if(t.type===`bun`){let n=T(e,t);return n?`bun add -g ${n}`:``}if(t.type===`npm`){let n=T(e,t);return n?`npm i -g ${n}`:``}return t.type===`brew`?t.packageName?t.packageTargetKind===`cask`?`brew install --cask ${t.packageName}`:`brew install ${t.packageName}`:``:t.type===`winget`?t.packageName?`winget install --id ${t.packageName} -e`:``:t.command??``}function ge(e,t,n){if(t)return ue(t)&&(t.packageName||e.packages?.npm)||void 0;if(!(!e.packages?.npm||!de(n)))return e.packages.npm}function O(e){if(e.installedState&&b(e.installedState.installType))return e.installedState.installType;for(let t of e.methods)if(b(t.type)&&S(t.type))return t.type}const k={strategy:`managed`,canHandle:e=>!!O(e),getManagedInstallerType:e=>O(e)},A={strategy:`self-update`,canHandle:e=>!E(e.installedState)&&!!e.agent.selfUpdate},j={strategy:`manual-hint`,canHandle:()=>!0},M=[k,A,j];function N(e){return M.find(t=>t.canHandle(e))??j}function P(e){return N(e).strategy}function F(e){return D(e.agent,e.installedState)}async function I(e){let t=s(),n=typeof e==`function`?e(t):e;try{return _.platform===`win32`?await c(f([`powershell.exe`,`-Command`,n]))===0:await c(f([`sh`,`-c`,n]))===0}catch{return!1}}function L(e){return e===`cask`?[`--cask`]:[]}async function R(e,t,n){try{return await c(f([`brew`,e,...L(n),t]))===0}catch{return!1}}async function _e(e,t){return R(`install`,e,t)}async function z(e,t){return R(`upgrade`,e,t)}async function ve(e){for(let t of e)if(!await z(t.packageName,t.packageTargetKind))return!1;return!0}async function ye(e,t){return R(`uninstall`,e,t)}async function B(e,t){try{return await c(f([`winget`,e,`--id`,t,`-e`]))===0}catch{return!1}}async function be(e){return B(`install`,e)}async function V(e){return B(`upgrade`,e)}async function xe(e){for(let t of e)if(!await V(t.packageName))return!1;return!0}async function Se(e){return B(`uninstall`,e)}const Ce={brew:{type:`brew`,isAvailable:async()=>o(),install:async(e,t)=>_e(e,t),uninstall:async(e,t)=>ye(e,t),update:async(e,t)=>z(e,t),updateMany:async e=>ve(e)},bun:{type:`bun`,isAvailable:async()=>n(),install:async e=>ce(e),uninstall:async e=>g(e),update:async(e,t,n)=>ie(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>h(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},npm:{type:`npm`,isAvailable:async()=>e(),install:async e=>se(e),uninstall:async e=>oe(e),update:async(e,t,n)=>ae(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>re(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},winget:{type:`winget`,isAvailable:async()=>a(),install:async e=>be(e),uninstall:async e=>Se(e),update:async e=>V(e),updateMany:async e=>xe(e.map(e=>({packageName:e.packageName})))}};function H(e){return Ce[e]}const U={resource:`agent lifecycle`,scope:[`agent-lifecycle`]};async function we(){return(await p()).defaultPackageManager}async function W(){return{npmBunUpdateStrategy:(await p()).npmBunUpdateStrategy}}async function G(e){let t=s(),n=e.platforms[t];if(!n)return[];let r=await we();return r?[...n.filter(e=>e.type===r),...n.filter(e=>e.type!==r)]:[...n]}async function K(e,t,n,r,i){let a=H(e);return await a.isAvailable()?r===`install`?a.install(t,n):r===`update`?a.update(t,n,{npmBunUpdateStrategy:i}):a.uninstall(t,n):!1}async function q(e,t,n,r){if(b(t.type)){let i=T(e,t);return i?K(t.type,i,t.packageTargetKind,n,r):!1}return n===`update`&&!S(t.type)||!t.command?!1:I(t.command)}async function J(e,t,n){return b(e.installType)?e.packageName?K(e.installType,e.packageName,e.packageTargetKind,t,n):!1:t!==`install`||!e.command?!1:I(e.command)}async function Te(e){if(!e.selfUpdate)return!1;let t=[e.selfUpdate.command,...e.selfUpdate.fallbackCommands??[]];for(let e of t)if(await I(e.join(` `)))return!0;return!1}async function Y(e,t){let n={agentName:e.name,installType:t.type,packageName:T(e,t),packageTargetKind:t.packageTargetKind,command:`command`in t?t.command:void 0};return await u(n),n}async function Ee(e){return d(U,async()=>{let t=await G(e);for(let n of t)if(await q(e,n,`install`))return{success:!0,installedState:await Y(e,n)};return{success:!1}})}async function X(e,t){return d(U,async()=>{let{npmBunUpdateStrategy:n}=await W(),r=await G(e);if(t&&await J(t,`update`,n))return await u(t),{success:!0,installedState:t};if(!t){for(let t of r)if(await q(e,t,`update`,n))return{success:!0,installedState:await Y(e,t)}}if(await Te(e))return{success:!0};if(t){for(let t of r)if(await q(e,t,`update`,n))return{success:!0,installedState:await Y(e,t)}}return{success:!1}})}async function De(e,t){return d(U,async()=>{let n=[...new Map(t.filter(e=>e.packageName).map(e=>[`${e.packageTargetKind??`package`}:${e.packageName}`,e])).values()],r=H(e);return await r.isAvailable()?r.updateMany(n,await W()):!1})}async function Oe(e){return d(U,async()=>{let t=await m(e.name);if(!t)return!1;let n=await J(t,`uninstall`);return n&&await te(e.name),n})}async function Z(e){let[t,n,r]=await Promise.all([G(e),m(e.name),i(e.binaryName)]),[a,o,s]=await Promise.all([r?ee(e.binaryName,e.versionProbe):Promise.resolve(void 0),r?l(e.binaryName):Promise.resolve(void 0),ke(e,n,t)]);return{agent:e,methods:t,installedState:n,inPath:r,installedVersion:a,latestVersion:s,binaryPath:o,sourceLabel:pe(n),updateLabel:me(e,n),lifecycle:n?x(n.installType):`unmanaged`}}async function Q(e){return Promise.all(e.map(Z))}async function ke(e,t,n){let r=ge(e,t,n);if(r)return ne(r)}function $(e){return t(e)}async function Ae(e){let t=$(e);if(t)return{agent:t,inspection:await Z(t)}}async function je(){return Q(r())}export{x as C,S,b as T,he as _,Q as a,C as b,Oe as c,H as d,M as f,D as g,N as h,Z as i,X as l,P as m,$ as n,G as o,F as p,Ae as r,Ee as s,je as t,De as u,fe as v,y as w,le as x,T as y};
@@ -0,0 +1 @@
1
+ import{t as e}from"./capabilities-KKT-gyc8.mjs";export{e as capabilitiesCommand};
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,l as n,o as r,r as i,t as a}from"./detect-q8eznhj9.mjs";import{a as o,r as s,t as c,u as l}from"./color-CbC8zjc1.mjs";import u from"node:process";async function d(){let[c,d,m,h,g]=await Promise.all([t(),e(),i(),r(),l()]);return o(s({action:`capabilities`,data:{agents:n().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:g.canAutoUpdate,timeout:!0},installers:{brew:{available:m,reason:m?void 0:f(`brew`)},bun:{available:c,reason:c?void 0:f(`bun`)},npm:{available:d,reason:d?void 0:f(`npm`)},winget:{available:h,reason:h?void 0:f(`winget`)}},outputModes:[`human`,`json`,`ndjson`],platform:{arch:u.arch,os:a()}},target:{kind:`system`,name:`capabilities`}}),p)}function f(e){return e===`winget`&&u.platform!==`win32`||e===`brew`&&u.platform===`win32`?`not-on-platform`:`not-found`}function p(e){e.data&&(console.log(c.bold(`
1
+ import{a as e,i as t,l as n,o as r,r as i,t as a}from"./detect-FhBDsvJC.mjs";import{a as o,r as s,t as c,u as l}from"./color-BbKp9aSG.mjs";import u from"node:process";async function d(){let[c,d,m,h,g]=await Promise.all([t(),e(),i(),r(),l()]);return o(s({action:`capabilities`,data:{agents:n().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:g.canAutoUpdate,timeout:!0},installers:{brew:{available:m,reason:m?void 0:f(`brew`)},bun:{available:c,reason:c?void 0:f(`bun`)},npm:{available:d,reason:d?void 0:f(`npm`)},winget:{available:h,reason:h?void 0:f(`winget`)}},outputModes:[`human`,`json`,`ndjson`],platform:{arch:u.arch,os:a()}},target:{kind:`system`,name:`capabilities`}}),p)}function f(e){return e===`winget`&&u.platform!==`win32`||e===`brew`&&u.platform===`win32`?`not-on-platform`:`not-found`}function p(e){e.data&&(console.log(c.bold(`
2
2
  Quantex Capabilities
3
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(c.bold(`
4
4
  Installers:`)),console.log(` bun: ${m(e.data.installers.bun)}`),console.log(` npm: ${m(e.data.installers.npm)}`),console.log(` brew: ${m(e.data.installers.brew)}`),console.log(` winget: ${m(e.data.installers.winget)}`),console.log(c.bold(`
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- import{r as e,s as t}from"./agents-BPMc1vIb.mjs";import{c as n}from"./detect-q8eznhj9.mjs";import{C as r,G as i,J as a,K as o,L as s,S as c,Y as l,a as u,i as d,l as f,n as p,q as m,t as h,z as g}from"./color-CbC8zjc1.mjs";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./user-output-DYsOPwi1.mjs";import{n as C,t as w}from"./errors-DCtNasuC.mjs";import T from"node:process";import{mkdir as E,readFile as D,rm as O,writeFile as k}from"node:fs/promises";import{join as A}from"node:path";import{program as j}from"commander";import M from"prompts";function N(){return A(g(),`idempotency`)}function P(e){return A(N(),`${L(e)}.json`)}async function F(e){try{let t=JSON.parse(await D(P(e),`utf8`));if(Date.parse(t.expiresAt)<=Date.now()){await O(P(e),{force:!0});return}return t}catch{return}}async function I(e,t){await E(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 k(P(e),`${JSON.stringify(i,null,2)}\n`,`utf8`)}function L(e){return e.replace(/[^\w.-]/g,`_`)}async function R(e){let t=await B(e.action,e.target);if(t)return t;let n=o().timeoutMs;if(n===void 0)return H(e,()=>e.run().then(t=>V(e.action,e.target,t)));let r;try{let t=new Promise(t=>{r=setTimeout(()=>{i(),d({action:e.action,data:{reason:`timeout`,timeoutMs:n},target:e.target,type:`cancelled`},{force:!0}),t(u(p({action:e.action,error:{code:`TIMEOUT`,details:{timeoutMs:n},message:`Command timed out after ${n}ms.`},target:e.target}),z,{force:!0}))},n)});return await H(e,()=>Promise.race([e.run().then(t=>V(e.action,e.target,t)),t]))}finally{r&&clearTimeout(r)}}function z(e){e.error&&console.error(h.red(e.error.message))}async function B(e,t){let n=o();if(!n.idempotencyKey)return;let r=await F(n.idempotencyKey);if(!r)return;if(r.action!==e)return u(p({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}),z,{force:!0});let i={...r.result,meta:{...r.result.meta,mode:n.outputMode,runId:n.runId,timestamp:new Date().toISOString()}};return u(i,z,{force:!0}),i}async function V(e,t,n){let r=o();return r.idempotencyKey&&await I(r.idempotencyKey,{action:e,result:n,target:t}),n}async function H(e,t){let n;try{let r=new Promise(t=>{let r=n=>{i(),d({action:e.action,data:{reason:`signal`,signal:n},target:e.target,type:`cancelled`},{force:!0}),t(u(p({action:e.action,error:{code:`CANCELLED`,details:{signal:n},message:`Command cancelled by ${n}.`},target:e.target}),z,{force:!0}))},a=()=>r(`SIGINT`),o=()=>r(`SIGTERM`);T.once(`SIGINT`,a),T.once(`SIGTERM`,o),n=()=>{T.off(`SIGINT`,a),T.off(`SIGTERM`,o)}});return await Promise.race([t(),r])}finally{n?.()}}async function U(t,n,r={}){let i=await e(t);if(!i)return x(h.red(`Unknown agent: ${t}`)),w(`AGENT_NOT_FOUND`);let{agent:a,inspection:s}=i,l=r.nonInteractive?!1:o().interactive,u=r.assumeYes??S(),d=r.dryRun??y(),f=r.install??`prompt`;if(!s.inPath){if(f===`never`)return x(h.red(`${a.displayName} is not installed.`)),w(`AGENT_NOT_INSTALLED`);if(f===`if-missing`||f===`always`){if(d?b(h.cyan(`Dry run: would install ${a.displayName}.`)):v(h.cyan(`Installing ${a.displayName}...`)),!(await W(a,d)).success)return x(h.red(`Failed to install ${a.displayName}.`)),1}else if(l){if(!(u||d?{install:!0}:await M({type:`confirm`,name:`install`,message:`${a.displayName} is not installed. Would you like to install it?`,initial:!0})).install)return _(h.yellow(`Installation cancelled.`)),1;if(d?b(h.cyan(`Dry run: would install ${a.displayName}.`)):v(h.cyan(`Installing ${a.displayName}...`)),!(await W(a,d)).success)return x(h.red(`Failed to install ${a.displayName}.`)),1}else return x(h.red(`${a.displayName} is not installed and interactive installation is disabled.`)),w(`INTERACTION_REQUIRED`)}if(d)return b(h.cyan(`Dry run: would run ${[a.binaryName,...n].join(` `)}`)),0;try{return await G(c([a.binaryName,...n]),a.displayName)}catch(e){return x(h.red(`Failed to launch ${a.displayName}: ${e instanceof Error?e.message:String(e)}`)),1}}async function W(e,n=y()){if(n)return{success:!0};try{return await t(e)}catch(t){return s(t)?(x(h.red(t.message)),{success:!1}):(x(h.red(`Failed to install ${e.displayName}: ${t instanceof Error?t.message:String(t)}`)),{success:!1})}}async function G(e,t){let{timeoutMs:n}=o(),a,s;try{let o=new Promise(e=>{let n=n=>{i(),x(h.red(`${t} was cancelled by ${n}.`)),e(w(`CANCELLED`))},r=()=>n(`SIGINT`),o=()=>n(`SIGTERM`);T.once(`SIGINT`,r),T.once(`SIGTERM`,o),a=()=>{T.off(`SIGINT`,r),T.off(`SIGTERM`,o)}}),c=n===void 0?void 0:new Promise(e=>{s=setTimeout(()=>{i(),x(h.red(`${t} timed out after ${n}ms.`)),e(w(`TIMEOUT`))},n)});return await Promise.race([r(e),o,...c?[c]:[]])}finally{s&&clearTimeout(s),a?.()}}j.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(f()),j.hook(`preAction`,(e,t)=>{try{l(a(t.optsWithGlobals()))}catch(e){console.log(h.red(e instanceof Error?e.message:String(e))),T.exit(2)}}),j.hook(`postAction`,()=>{m()}),j.command(`schema`).argument(`[command]`,`Optional command name`).description(`查看结构化输出 schema`).action(async e=>{let{schemaCommand:t}=await import(`./schema-C7gYIpnh.mjs`);T.exitCode=await X({action:`schema`,run:()=>t(e),target:{kind:`system`,name:`schema`}})}),j.command(`commands`).description(`查看命令目录与稳定能力`).action(async()=>{let{commandsCommand:e}=await import(`./commands-BzfE2L4B.mjs`);T.exitCode=await X({action:`commands`,run:()=>e(),target:{kind:`system`,name:`commands`}})}),j.command(`capabilities`).description(`查看当前环境与 surface 能力`).action(async()=>{let{capabilitiesCommand:e}=await import(`./capabilities-BO5CNv4G.mjs`);T.exitCode=await X({action:`capabilities`,run:()=>e(),target:{kind:`system`,name:`capabilities`}})}),j.command(`inspect <agent>`).description(`查看 agent 结构化状态`).action(async e=>{let{inspectCommand:t}=await import(`./inspect-D3xXVuL2.mjs`);T.exitCode=await X({action:`inspect`,run:()=>t(e),target:{kind:`agent`,name:e}})}),j.command(`resolve <agent>`).description(`解析 agent 可执行入口`).action(async e=>{let{resolveCommand:t}=await import(`./resolve-BueWa31L.mjs`);T.exitCode=await X({action:`resolve`,run:()=>t(e),target:{kind:`agent`,name:e}})}),j.command(`install <agent>`).alias(`i`).description(`安装指定 agent`).action(async e=>{let{installCommand:t}=await import(`./install-C4UFbLXt.mjs`);T.exitCode=await X({action:`install`,run:()=>t(e),target:{kind:`agent`,name:e}})}),j.command(`ensure <agent>`).description(`确保指定 agent 已安装`).action(async e=>{let{ensureCommand:t}=await import(`./ensure-rkgpIWy6.mjs`);T.exitCode=await X({action:`ensure`,run:()=>t(e),target:{kind:`agent`,name:e}})}),j.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(h.red(`Unknown install policy: ${i}`)),T.exitCode=2;return}let a=J(r);T.exitCode=await U(e,a.length>0?a:t,{install:i,nonInteractive:r.optsWithGlobals().nonInteractive})}),j.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-BufYok78.mjs`);T.exitCode=await X({action:`update`,run:()=>n(e,t.all??!1),target:{kind:`agent`,name:e}})}),j.command(`uninstall <agent>`).alias(`rm`).description(`卸载指定 agent`).action(async e=>{let{uninstallCommand:t}=await import(`./uninstall-BDoLpgpH.mjs`);T.exitCode=await X({action:`uninstall`,run:()=>t(e),target:{kind:`agent`,name:e}})}),j.command(`list`).alias(`ls`).description(`列出所有支持的 agent`).action(async()=>{let{listCommand:e}=await import(`./list-BFP0FCnu.mjs`);T.exitCode=await X({action:`list`,run:()=>e(),target:{kind:`system`,name:`agents`}})}),j.command(`info <agent>`).description(`查看 agent 详细信息`).action(async e=>{let{infoCommand:t}=await import(`./info-S-XkpGfH.mjs`);T.exitCode=await X({action:`info`,run:()=>t(e),target:{kind:`agent`,name:e}})}),j.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-AtPtndss.mjs`);T.exitCode=await X({action:`config`,run:()=>r(e,t,n),target:{kind:`config`,name:t}})}),j.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-DetftUCc.mjs`);T.exitCode=await X({action:`upgrade`,run:()=>t({channel:e.channel===`beta`?`beta`:void 0,check:e.check??!1}),target:{kind:`self`,name:`quantex`}})}),j.command(`doctor`).description(`检查环境`).action(async()=>{let{doctorCommand:e}=await import(`./doctor-CEdPHLNc.mjs`);T.exitCode=await X({action:`doctor`,run:()=>e(),target:{kind:`system`,name:`doctor`}})});const K=new Set([...j.commands.map(e=>e.name()),...j.commands.flatMap(e=>e.aliases()),`help`,`--help`,`--version`,`-v`]),q=Y(T.argv.slice(2),K);if(q?.error&&(console.log(h.red(q.error)),T.exit(2)),q&&n(q.agentName)){try{l(a({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(h.red(e instanceof Error?e.message:String(e))),T.exit(2)}try{let e=await U(q.agentName,q.agentArgs,{assumeYes:q.yes,dryRun:q.dryRun,nonInteractive:q.nonInteractive});T.exit(e)}finally{m()}}j.parse();function J(e){let t=e.processedArgs.at(-1);return Array.isArray(t)?t:e.args.slice(1)}function Y(e,t){let n=T.stdin.isTTY===!1||T.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 X(e){return C(await R(e))}export{};
2
+ import{_ as e,r as t,s as n,v as r}from"./agents-bx8y3kRS.mjs";import{c as i}from"./detect-FhBDsvJC.mjs";import{B as a,C as o,J as s,K as c,L as l,S as u,X as d,Y as f,a as p,i as m,l as h,n as g,q as _,r as v,t as y}from"./color-BbKp9aSG.mjs";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./user-output-DFxUPA-p.mjs";import{n as E,t as D}from"./errors-DCtNasuC.mjs";import O from"node:process";import{mkdir as ee,readFile as k,rm as A,writeFile as j}from"node:fs/promises";import{join as M}from"node:path";import{program as N}from"commander";import P from"prompts";function F(){return M(a(),`idempotency`)}function I(e){return M(F(),`${z(e)}.json`)}async function L(e){try{let t=JSON.parse(await k(I(e),`utf8`));if(Date.parse(t.expiresAt)<=Date.now()){await A(I(e),{force:!0});return}return t}catch{return}}async function R(e,t){await ee(F(),{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 j(I(e),`${JSON.stringify(i,null,2)}\n`,`utf8`)}function z(e){return e.replace(/[^\w.-]/g,`_`)}async function B(e){let t=await H(e.action,e.target);if(t)return t;let n=_().timeoutMs;if(n===void 0)return W(e,()=>e.run().then(t=>U(e.action,e.target,t)));let r;try{let t=new Promise(t=>{r=setTimeout(()=>{c(),m({action:e.action,data:{reason:`timeout`,timeoutMs:n},target:e.target,type:`cancelled`},{force:!0}),t(p(g({action:e.action,error:{code:`TIMEOUT`,details:{timeoutMs:n},message:`Command timed out after ${n}ms.`},target:e.target}),V,{force:!0}))},n)});return await W(e,()=>Promise.race([e.run().then(t=>U(e.action,e.target,t)),t]))}finally{r&&clearTimeout(r)}}function V(e){e.error&&console.error(y.red(e.error.message))}async function H(e,t){let n=_();if(!n.idempotencyKey)return;let r=await L(n.idempotencyKey);if(!r)return;if(r.action!==e)return p(g({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}),V,{force:!0});let i={...r.result,meta:{...r.result.meta,mode:n.outputMode,runId:n.runId,timestamp:new Date().toISOString()}};return p(i,V,{force:!0}),i}async function U(e,t,n){let r=_();return r.idempotencyKey&&await R(r.idempotencyKey,{action:e,result:n,target:t}),n}async function W(e,t){let n;try{let r=new Promise(t=>{let r=n=>{c(),m({action:e.action,data:{reason:`signal`,signal:n},target:e.target,type:`cancelled`},{force:!0}),t(p(g({action:e.action,error:{code:`CANCELLED`,details:{signal:n},message:`Command cancelled by ${n}.`},target:e.target}),V,{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 G(e,n,r={}){let i=await t(e);if(!i)return q({agent:{name:e},errorCode:`AGENT_NOT_FOUND`,errorMessage:`Unknown agent: ${e}`,execution:{args:n,installPolicy:r.install??`prompt`,installed:!1,interactive:!1,launched:!1}}),D(`AGENT_NOT_FOUND`);let{agent:a,inspection:o}=i,s=r.nonInteractive?!1:_().interactive,c=r.assumeYes??T(),l=r.dryRun??S(),d=r.install??`prompt`;if(!o.inPath){if(d===`never`)return q({agent:{binaryName:a.binaryName,displayName:a.displayName,name:a.name},errorCode:`AGENT_NOT_INSTALLED`,errorMessage:`${a.displayName} is not installed.`,execution:{args:n,installGuidance:K(a,o.methods,n),installPolicy:d,installed:!1,interactive:s,launched:!1}}),D(`AGENT_NOT_INSTALLED`);if(d===`if-missing`||d===`always`){if(l?C(y.cyan(`Dry run: would install ${a.displayName}.`)):x(y.cyan(`Installing ${a.displayName}...`)),!(await Y(a,l)).success)return w(y.red(`Failed to install ${a.displayName}.`)),1}else if(s){if(!(c||l?{install:!0}:await P({type:`confirm`,name:`install`,message:`${a.displayName} is not installed. Would you like to install it?`,initial:!0})).install)return b(y.yellow(`Installation cancelled.`)),1;if(l?C(y.cyan(`Dry run: would install ${a.displayName}.`)):x(y.cyan(`Installing ${a.displayName}...`)),!(await Y(a,l)).success)return w(y.red(`Failed to install ${a.displayName}.`)),1}else return q({agent:{binaryName:a.binaryName,displayName:a.displayName,name:a.name},errorCode:`INTERACTION_REQUIRED`,errorMessage:`${a.displayName} is not installed and interactive installation is disabled.`,execution:{args:n,installGuidance:K(a,o.methods,n),installPolicy:d,installed:!1,interactive:s,launched:!1}}),D(`INTERACTION_REQUIRED`)}if(l)return J({agent:{binaryName:a.binaryName,displayName:a.displayName,name:a.name},execution:{args:n,installPolicy:d,installed:!0,interactive:s,launched:!1},message:`Dry run: would run ${[a.binaryName,...n].join(` `)}`}),0;try{return await X(u([a.binaryName,...n]),a.displayName)}catch(e){return w(y.red(`Failed to launch ${a.displayName}: ${e instanceof Error?e.message:String(e)}`)),1}}function K(t,n,i){return{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:n.map(n=>({command:e(t,n),label:r(n),type:n.type})).filter(e=>e.command),suggestedAction:`rerun-with-install-policy`,suggestedEnsureCommand:`quantex ensure ${t.name}`,suggestedExecCommand:[`quantex`,`exec`,t.name,`--install`,`if-missing`,`--`,...i].join(` `)}}function q(e){if(_().outputMode===`human`){w(y.red(e.errorMessage));let t=e.execution.installGuidance;t&&(C(y.dim(`Try: ${t.suggestedEnsureCommand}`)),C(y.dim(`Or: ${t.suggestedExecCommand}`)));return}p(g({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 J(e){if(_().outputMode===`human`){C(y.cyan(e.message));return}p(v({action:`exec`,data:{agent:e.agent,execution:e.execution},target:{kind:`agent`,name:e.agent.name}}),()=>{})}async function Y(e,t=S()){if(t)return{success:!0};try{return await n(e)}catch(t){return l(t)?(w(y.red(t.message)),{success:!1}):(w(y.red(`Failed to install ${e.displayName}: ${t instanceof Error?t.message:String(t)}`)),{success:!1})}}async function X(e,t){let{timeoutMs:n}=_(),r,i;try{let a=new Promise(e=>{let n=n=>{c(),w(y.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)}}),s=n===void 0?void 0:new Promise(e=>{i=setTimeout(()=>{c(),w(y.red(`${t} timed out after ${n}ms.`)),e(D(`TIMEOUT`))},n)});return await Promise.race([o(e),a,...s?[s]:[]])}finally{i&&clearTimeout(i),r?.()}}N.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(h()),N.hook(`preAction`,(e,t)=>{try{d(f(t.optsWithGlobals()))}catch(e){console.log(y.red(e instanceof Error?e.message:String(e))),O.exit(2)}}),N.hook(`postAction`,()=>{s()}),N.command(`schema`).argument(`[command]`,`Optional command name`).description(`查看结构化输出 schema`).action(async e=>{let{schemaCommand:t}=await import(`./schema-CvjJUAJb.mjs`);O.exitCode=await $({action:`schema`,run:()=>t(e),target:{kind:`system`,name:`schema`}})}),N.command(`commands`).description(`查看命令目录与稳定能力`).action(async()=>{let{commandsCommand:e}=await import(`./commands-v1Sz-UYE.mjs`);O.exitCode=await $({action:`commands`,run:()=>e(),target:{kind:`system`,name:`commands`}})}),N.command(`capabilities`).description(`查看当前环境与 surface 能力`).action(async()=>{let{capabilitiesCommand:e}=await import(`./capabilities-C4rAD7sw.mjs`);O.exitCode=await $({action:`capabilities`,run:()=>e(),target:{kind:`system`,name:`capabilities`}})}),N.command(`inspect <agent>`).description(`查看 agent 结构化状态`).action(async e=>{let{inspectCommand:t}=await import(`./inspect-C8CfhNED.mjs`);O.exitCode=await $({action:`inspect`,run:()=>t(e),target:{kind:`agent`,name:e}})}),N.command(`resolve <agent>`).description(`解析 agent 可执行入口`).action(async e=>{let{resolveCommand:t}=await import(`./resolve-B_IU5vbb.mjs`);O.exitCode=await $({action:`resolve`,run:()=>t(e),target:{kind:`agent`,name:e}})}),N.command(`install <agent>`).alias(`i`).description(`安装指定 agent`).action(async e=>{let{installCommand:t}=await import(`./install-CdmFxCHJ.mjs`);O.exitCode=await $({action:`install`,run:()=>t(e),target:{kind:`agent`,name:e}})}),N.command(`ensure <agent>`).description(`确保指定 agent 已安装`).action(async e=>{let{ensureCommand:t}=await import(`./ensure-B4-KmDVN.mjs`);O.exitCode=await $({action:`ensure`,run:()=>t(e),target:{kind:`agent`,name:e}})}),N.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(y.red(`Unknown install policy: ${i}`)),O.exitCode=2;return}let a=te(r);O.exitCode=await G(e,a.length>0?a:t,{install:i,nonInteractive:r.optsWithGlobals().nonInteractive})}),N.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-BG44eiCz.mjs`);O.exitCode=await $({action:`update`,run:()=>n(e,t.all??!1),target:{kind:`agent`,name:e}})}),N.command(`uninstall <agent>`).alias(`rm`).description(`卸载指定 agent`).action(async e=>{let{uninstallCommand:t}=await import(`./uninstall-PDslmq45.mjs`);O.exitCode=await $({action:`uninstall`,run:()=>t(e),target:{kind:`agent`,name:e}})}),N.command(`list`).alias(`ls`).description(`列出所有支持的 agent`).action(async()=>{let{listCommand:e}=await import(`./list-B-Uy3llF.mjs`);O.exitCode=await $({action:`list`,run:()=>e(),target:{kind:`system`,name:`agents`}})}),N.command(`info <agent>`).description(`查看 agent 详细信息`).action(async e=>{let{infoCommand:t}=await import(`./info-DuDumnqd.mjs`);O.exitCode=await $({action:`info`,run:()=>t(e),target:{kind:`agent`,name:e}})}),N.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-D2XKUMhE.mjs`);O.exitCode=await $({action:`config`,run:()=>r(e,t,n),target:{kind:`config`,name:t}})}),N.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-D9rsTwGk.mjs`);O.exitCode=await $({action:`upgrade`,run:()=>t({channel:e.channel===`beta`?`beta`:void 0,check:e.check??!1}),target:{kind:`self`,name:`quantex`}})}),N.command(`doctor`).description(`检查环境`).action(async()=>{let{doctorCommand:e}=await import(`./doctor-D59eSvXO.mjs`);O.exitCode=await $({action:`doctor`,run:()=>e(),target:{kind:`system`,name:`doctor`}})});const Z=new Set([...N.commands.map(e=>e.name()),...N.commands.flatMap(e=>e.aliases()),`help`,`--help`,`--version`,`-v`]),Q=ne(O.argv.slice(2),Z);if(Q?.error&&(console.log(y.red(Q.error)),O.exit(2)),Q&&i(Q.agentName)){try{d(f({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(y.red(e instanceof Error?e.message:String(e))),O.exit(2)}try{let e=await G(Q.agentName,Q.agentArgs,{assumeYes:Q.yes,dryRun:Q.dryRun,nonInteractive:Q.nonInteractive});O.exit(e)}finally{s()}}N.parse();function te(e){let t=e.processedArgs.at(-1);return Array.isArray(t)?t:e.args.slice(1)}function ne(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 E(await B(e))}export{};
@@ -0,0 +1,4 @@
1
+ import{createHash as e,randomUUID as t}from"node:crypto";import n from"node:process";import{chmod as r,mkdir as i,mkdtemp as a,readFile as o,rename as s,rm as c,stat as l,writeFile as u}from"node:fs/promises";import{basename as d,dirname as f,join as p}from"node:path";import{fileURLToPath as m,pathToFileURL as h}from"node:url";import{homedir as g}from"node:os";import{loadConfig as ee}from"c12";import{Buffer as te}from"node:buffer";import{createColors as ne,isColorSupported as re}from"picocolors";function ie(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 _,v=new Set;function y(){return _??=ue(),_}function ae(e){v=new Set,_={...e,cacheMode:e.cacheMode??`default`,cancelled:e.cancelled??!1}}function oe(){_=void 0,v=new Set}function b(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:ie(e.timeout),c=de(e.color),l=fe(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 se(){_&&(_.cancelled=!0)}function ce(){se();for(let e of v)e();v.clear()}function x(e){return v.add(e),()=>{v.delete(e)}}function le(e){let t=y();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 ue(){return b()}function de(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 fe(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 pe={defaultPackageManager:`bun`,networkRetries:2,networkTimeoutMs:1e4,npmBunUpdateStrategy:`latest-major`,selfUpdateChannel:`stable`,versionCacheTtlHours:6};function S(){return p(n.env.HOME||n.env.USERPROFILE||g(),`.quantex`)}function C(){return p(S(),`config.json`)}async function w(){let{config:e}=await ee({name:`quantex`,defaults:pe,configFile:C(),jiti:{import:async(e,t)=>{if(e.endsWith(`.json`))return JSON.parse(await o(e,`utf8`));let n=await(e.startsWith(`file:`)?import(e):import(h(e).href));return t?.default?n.default??n:n}}}),t=e;return{...t,defaultPackageManager:t.defaultPackageManager===`npm`?`npm`:`bun`,networkRetries:T(t.networkRetries,2),networkTimeoutMs:T(t.networkTimeoutMs,1e4),npmBunUpdateStrategy:t.npmBunUpdateStrategy===`respect-semver`?`respect-semver`:`latest-major`,selfUpdateChannel:t.selfUpdateChannel===`beta`?`beta`:`stable`,versionCacheTtlHours:T(t.versionCacheTtlHours,6)}}function me(e){return e===`latest-major`||e===`respect-semver`}async function he(e){await i(S(),{recursive:!0}),await Bun.write(C(),`${JSON.stringify(e,null,2)}\n`)}function T(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}const E=`quantex-cli`,D=`https://github.com/Drswith/quantex-cli`,ge=`0.2.0`;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 k(e){return e instanceof O}function _e(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 p(S(),`locks`,...r,i)}async function A(e){let t=_e(e.scope);await i(f(t),{recursive:!0});try{await i(t,{recursive:!1})}catch(n){throw typeof n==`object`&&n&&`code`in n&&n.code===`EEXIST`?new O(e.resource,t):n}return async()=>{await c(t,{force:!0,recursive:!0})}}async function ve(e,t){let n=await A(e);try{return await t()}finally{await n()}}const ye={installedAgents:{},self:{}};function j(){return p(S(),`state.json`)}async function M(){return F()}async function be(e){let t=await A({resource:`state`,scope:[`state`]});try{await I(e)}finally{await t()}}async function xe(e){return(await M()).installedAgents[e]}async function Se(e){await L(t=>{t.installedAgents[e.agentName]=e})}async function Ce(e){await L(t=>{delete t.installedAgents[e]})}async function N(){return(await M()).self}async function P(e){await L(t=>{t.self.installSource=e})}async function F(){try{let e=await Bun.file(j()).json();return{installedAgents:e.installedAgents??{},self:e.self??{}}}catch{return{...ye}}}async function I(e){await i(S(),{recursive:!0}),await Bun.write(j(),`${JSON.stringify(e,null,2)}\n`)}async function L(e){let t=await A({resource:`state`,scope:[`state`]});try{let t=await F();await e(t),await I(t)}finally{await t()}}async function R(e,t){let n=await we(e,t,`json`);if(n)try{return JSON.parse(n)}catch{return}}async function we(e,t,n=`text`){let r=await w(),i=r.versionCacheTtlHours*60*60*1e3,a=y().cacheMode,o=a===`no-cache`?{entries:{}}:await Ee(),s=o.entries[t],c=Date.now();if(a===`default`&&s&&s.expiresAt>c)return V(s,i),s.body;let l=await Te(e,{headers:a!==`no-cache`&&s?.etag?{"If-None-Match":s.etag}:void 0,retries:r.networkRetries,timeoutMs:r.networkTimeoutMs});if(!l)return s&&V(s,i),s?.body;if(l.status===304&&s)return o.entries[t]={...s,expiresAt:c+i,fetchedAt:c},a!==`no-cache`&&await z(o),De(c,c+i),s.body;if(!l.ok)return s&&V(s,i),s?.body;let u=await l.text();if(n===`json`)try{JSON.parse(u)}catch{return s&&V(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 z(o)),De(c,c+i),u}async function Te(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 Ee(){try{return JSON.parse(await o(B(),`utf8`))}catch{return{entries:{}}}}async function z(e){await i(p(S(),`cache`),{recursive:!0}),await u(B(),`${JSON.stringify(e,null,2)}\n`,`utf8`)}function B(){return p(S(),`cache`,`versions.json`)}function V(e,t){let n=e.fetchedAt??Math.max(0,e.expiresAt-t);le({fetchedAt:new Date(n).toISOString(),source:`cache`,staleAfter:new Date(e.expiresAt).toISOString()})}function De(e,t){le({fetchedAt:new Date(e).toISOString(),source:`network`,staleAfter:new Date(t).toISOString()})}const Oe=/v?(\d+\.\d+\.\d+(?:-[a-z0-9.]+)?)/i;function ke(e,t){if(t)return t(e);let n=e.trim().split(`
2
+ `)[0],r=n.match(Oe);return r?r[1]:n||void 0}async function Ae(e,t){let n=t?.command??[e,`--version`];try{let e=Bun.spawn(n,{stdout:`pipe`,stderr:`pipe`});return await e.exited,e.exitCode===0?ke(await new Response(e.stdout).text(),t?.parser):void 0}catch{return}}async function je(e,t=`latest`){try{return(await R(`https://registry.npmjs.org/${e}/${t}`,`npm:${e}:${t}`))?.version}catch{return}}async function Me(e){try{let t=n.platform===`win32`?`where`:`which`,r=Bun.spawn([t,e],{stdout:`pipe`,stderr:`pipe`});return await r.exited,r.exitCode===0?(await new Response(r.stdout).text()).trim().split(`
3
+ `)[0]:void 0}catch{return}}async function Ne(){try{return await A({resource:`self upgrade`,scope:[`self-upgrade`]})}catch(e){if(k(e))return;throw e}}async function Pe(e,t,i,o){let l;try{l=await fetch(e)}catch(t){return U(`network`,`Failed to download ${e}.`,t)}if(!l.ok)return U(`network`,`Failed to download ${e}: HTTP ${l.status}.`);let m=await a(p(f(t),`.quantex-upgrade-`)),h=p(m,d(t)),g=`${t}.bak`;try{let a=te.from(await l.arrayBuffer()),d=await Fe(t),f=Ve(a);if(f!==W(i))return U(`checksum`,`Checksum mismatch for ${e}. Expected ${W(i)}, got ${f}.`);if(await u(h,a),n.platform===`win32`)return Ie(h,t,g,m,o);await r(h,d),await c(g,{force:!0}),await s(t,g),await s(h,t);let p=await Be(t,o);return p.success?(await c(g,{force:!0}),{success:!0}):(await ze(g,t),p)}catch(e){return U(Re(e),`Failed to replace the current Quantex binary.`,e)}finally{n.platform!==`win32`&&await c(m,{recursive:!0,force:!0})}}async function Fe(e){try{return(await l(e)).mode&511}catch{return 493}}function Ie(e,t,r,i,a){try{let o=Le(e,t,r,i,n.pid,a);return Bun.spawn([`powershell.exe`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-WindowStyle`,`Hidden`,`-Command`,o],{stdio:[`ignore`,`ignore`,`ignore`],windowsHide:!0}).unref?.(),{success:!0}}catch(e){return U(`locked`,`Failed to schedule Windows binary replacement.`,e)}}function Le(e,t,n,r,i,a){let o=H(e),s=H(t),c=H(n),l=H(r),u=H(a??``);return[`$pidToWait = ${i}`,`$tempPath = '${o}'`,`$targetPath = '${s}'`,`$backupPath = '${c}'`,`$tempDir = '${l}'`,`$expectedVersion = '${u}'`,`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`,` }`,`}`,`Remove-Item -LiteralPath $backupPath -Force -ErrorAction SilentlyContinue`,`Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`].join(`; `)}function H(e){return e.replaceAll(`'`,`''`)}function U(e,t,n){return{error:{detail:n,kind:e,message:t},success:!1}}function Re(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 ze(e,t){await c(t,{force:!0}),await s(e,t)}async function Be(e,t){if(!t)return{success:!0};try{let n=Bun.spawn([e,`--version`],{stdio:[`ignore`,`pipe`,`ignore`]}),r=n.stdout?await new Response(n.stdout).text():``,i=await n.exited;return i===0?r.includes(t)?{success:!0}:U(`verify`,`The upgraded Quantex binary reported an unexpected version during verification.`):U(`verify`,`The upgraded Quantex binary exited with code ${i} during verification.`)}catch(e){return U(`verify`,`Failed to execute the upgraded Quantex binary for verification.`,e)}}function Ve(t){return e(`sha256`).update(t).digest(`hex`)}function W(e){return e.trim().toLowerCase()}function He(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function G(e=n.execPath){if(d(He(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 Ue(e=n.execPath){let t=G(e);if(t)return`${D}/releases/latest/download/${t}`}function We(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 Ge(e){let t=await R(await Ke(e),`self:manifest:${e}`);if(!t)throw Error(`Failed to download release manifest.`);return t}async function Ke(e){if(e===`stable`)return`${D}/releases/latest/download/manifest.json`;let t=(await qe(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 qe(e){let t=Ye();if(!t)throw Error(`Failed to resolve the GitHub repository slug for Quantex releases.`);let n=await R(`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 Je(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 Ye(){return D.match(/github\.com\/([^/]+\/[^/]+)$/)?.[1]}const Xe={source:`binary`,canHandle:e=>e.installSource===`binary`,getRecoveryHint:(e,t)=>{let n=t?.error?.detail&&typeof t.error.detail==`object`&&`downloadUrl`in t.error.detail?String(t.error.detail.downloadUrl):Ue(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){if(!G(e.executablePath))return{error:{kind:`unsupported`,message:`No release artifact is available for the current platform and architecture.`},installSource:e.installSource,success:!1};let t;try{t=await Ge(e.updateChannel)}catch(t){return{error:{detail:t,kind:`network`,message:`Failed to resolve the ${e.updateChannel} release manifest.`},installSource:e.installSource,success:!1}}let n=Je(t,e.executablePath);if(!n)return{error:{detail:{channel:e.updateChannel},kind:`unsupported`,message:`No binary asset is available for the current platform on the ${e.updateChannel} channel.`},installSource:e.installSource,success:!1};let r=await Pe(n.downloadUrl,e.executablePath,n.checksum,t.version);return{...!r.success&&r.error?{...r,error:{...r.error,detail:{...typeof r.error.detail==`object`&&r.error.detail?r.error.detail:{},downloadUrl:n.downloadUrl}}}:r,installSource:e.installSource,newVersion:r.success?t.version:void 0}}};function K(e,t={}){if(y().outputMode===`human`){let n=Bun.spawn(e,{...t,stdio:[`inherit`,`inherit`,`inherit`]});return{cleanup:x(()=>n.kill?.(`SIGTERM`)),outputDrained:Promise.resolve(),proc:n}}let n=Bun.spawn(e,{...t,stdio:[`ignore`,`pipe`,`pipe`]});return{cleanup:x(()=>n.kill?.(`SIGTERM`)),outputDrained:Promise.all([Ze(n.stdout),Ze(n.stderr)]).then(()=>{}),proc:n}}async function q(e){try{return await e.proc.exited,await e.outputDrained,e.proc.exitCode??1}finally{e.cleanup()}}async function Ze(e){if(!e)return;let t=await new Response(e).text();t&&n.stderr.write(t)}async function Qe(e){try{return await J([`bun`,`add`,`-g`,e],[e])}catch{return!1}}async function $e(e,t=`latest-major`,n=`latest`){try{let r=n===`latest`?e:`${e}@${n}`;return await J([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],r],[e])}catch{return!1}}async function et(e,t=`latest-major`){if(e.length===0)return!0;try{return await J([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],...e],e)}catch{return!1}}async function tt(e){try{return await q(K([`bun`,`remove`,`-g`,e]))===0}catch{return!1}}async function J(e,t){return await q(K(e))===0?nt(t):!1}async function nt(e){let t=[...new Set(e)];if(t.length===0)return!0;let n=await rt();if(!n)return!0;let r=it(n),i=t.filter(e=>r.has(e));return i.length===0?!0:await q(K([`bun`,`pm`,`-g`,`trust`,...i]))===0}async function rt(){try{let e=Bun.spawn([`bun`,`pm`,`-g`,`untrusted`],{stdio:at()}),t=await new Response(e.stdout).text();return await e.exited,e.exitCode===0?t:void 0}catch{return}}function it(e){let t=new Set;for(let n of e.split(`
4
+ `)){let e=n.match(/^\.\/node_modules\/(.+?) @/);e?.[1]&&t.add(e[1])}return t}function at(){return[`ignore`,`pipe`,`ignore`]}const ot={source:`bun`,canHandle:e=>e.installSource===`bun`,getRecoveryHint:e=>`bun add -g ${E}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await $e(E,`latest-major`,e.updateChannel===`beta`?`beta`:`latest`);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${E} through Bun.`},installSource:e.installSource,newVersion:t?e.latestVersion:void 0,success:t}}};async function st(e){try{return await q(K([`npm`,`i`,`-g`,e]))===0}catch{return!1}}async function ct(e,t=`latest-major`,n=`latest`){try{return await q(K(t===`latest-major`?[`npm`,`install`,`-g`,`${e}@${n}`]:[`npm`,`update`,`-g`,e]))===0}catch{return!1}}async function lt(e,t=`latest-major`){if(e.length===0)return!0;try{return await q(K(t===`latest-major`?[`npm`,`install`,`-g`,...e.map(e=>`${e}@latest`)]:[`npm`,`update`,`-g`,...e]))===0}catch{return!1}}async function ut(e){try{return await q(K([`npm`,`uninstall`,`-g`,e]))===0}catch{return!1}}const dt={source:`npm`,canHandle:e=>e.installSource===`npm`,getRecoveryHint:e=>`npm install -g ${E}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await ct(E,`latest-major`,e.updateChannel===`beta`?`beta`:`latest`);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${E} through npm.`},installSource:e.installSource,newVersion:t?e.latestVersion:void 0,success:t}}},ft={source:`source`,canHandle:e=>e.installSource===`source`||e.installSource===`unknown`,getRecoveryHint:()=>void 0,async upgrade(e){return{error:{kind:`unsupported`,message:`Install source "${e.installSource}" does not support auto-update.`},installSource:e.installSource,success:!1}}},pt=[ot,dt,Xe,ft];function Y(e){return pt.find(t=>t.canHandle(e))??ft}function mt(e,t,n=`stable`){return Y({canAutoUpdate:e===`binary`||e===`bun`||e===`npm`,currentVersion:``,executablePath:t,installSource:e,packageRoot:``,updateChannel:n})}function ht(e,t,n=`stable`,r){return r?.error?.kind===`locked`?`another qtx upgrade is already running; wait for it to finish and retry`:mt(e,t,n).getRecoveryHint({canAutoUpdate:e===`binary`||e===`bun`||e===`npm`,currentVersion:``,executablePath:t,installSource:e,packageRoot:``,updateChannel:n},r)}function gt(e,t){return t?.error?.kind===`locked`?`another qtx upgrade is already running; wait for it to finish and retry`:Y(e).getRecoveryHint(e,t)}const X=E,_t=`/node_modules/${X}`;async function vt(e){let t=await xt(),r=n.execPath,i=t.foundPackageJson?Q(t.packageRoot):Q(``,r),a=await bt((await N()).installSource,i),o=await w(),s=We(e?.updateChannel,o.selfUpdateChannel),c=await Ct(a,r,s);return{canAutoUpdate:Z(a),currentVersion:t.version||`0.2.0`,executablePath:r,installSource:a,latestVersion:c,packageRoot:t.packageRoot,recommendedUpgradeCommand:Z(a)?`quantex upgrade`:void 0,updateChannel:s}}async function yt(e){let t=e??await vt(),n=await Ne();if(!n)return{error:{kind:`locked`,message:`Another qtx upgrade is already running.`},installSource:t.installSource,success:!1};try{return await Y(t).upgrade(t)}finally{await n()}}function Z(e){return e===`binary`||e===`bun`||e===`npm`}async function bt(e,t){return t!==`unknown`&&e!==t?(await P(t),t):e??t}function Q(e,t=n.execPath){let r=Tt(e);return r.includes(`/.bun/install/global/`)?`bun`:r.includes(_t)?`npm`:r?`source`:Et(t)?`binary`:`unknown`}async function xt(e=import.meta.url){let t=Dt(e),n=f(t);for(;;){let e=p(n,`package.json`),t=await wt(e);if(t?.name===X)return{foundPackageJson:!0,packageJsonPath:e,packageRoot:n,version:t.version??`0.2.0`};let r=f(n);if(r===n)break;n=r}return{foundPackageJson:!1,packageJsonPath:p(f(t),`package.json`),packageRoot:f(t),version:ge}}function $(){return ge}function St(e,t=n.execPath){return ht(e,t)}async function Ct(e,t,n){if(e===`binary`)try{let e=await Ge(n);return Je(e,t)?e.version:void 0}catch{return}return je(X,n===`beta`?`beta`:`latest`)}async function wt(e){try{return JSON.parse(await o(e,`utf8`))}catch{return}}function Tt(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function Et(e){let t=d(Tt(e));return t!==`bun`&&t!==`bun.exe`}function Dt(e){try{return m(e)}catch{return n.execPath}}function Ot(e){return Mt({...e,error:null,ok:!0})}function kt(e){return Mt({...e,ok:!1})}function At(e,t,n={}){let r=y();return r.cancelled&&!n.force||(r.outputMode===`json`?console.log(JSON.stringify(e,null,2)):r.outputMode===`ndjson`?Pt({action:e.action,data:e,target:e.target,type:`result`}):t(e)),e}function jt(e,t={}){let n=y();if(!(n.cancelled&&!t.force)&&n.outputMode===`ndjson`)return Pt(e)}function Mt(e){let t=y();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:$()},ok:e.ok,target:e.target,warnings:e.warnings??[]}}function Nt(e){let t=y();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:$()},target:e.target,type:e.type}}function Pt(e){let t=Nt(e);return console.log(JSON.stringify(t)),t}function Ft(){let e=y().colorMode??`auto`;return ne(e===`always`?!0:e===`never`?!1:re)}const It=new Proxy({},{get(e,t){let n=Ft(),r=n[t];return typeof r==`function`?r.bind(n):r}});export{N as A,S as B,q as C,Ae as D,Me as E,Se as F,pe as G,me as H,P as I,oe as J,ce as K,k as L,M,Ce as N,je as O,be as P,ve as R,K as S,Ue as T,w as U,C as V,he as W,ae as X,b as Y,lt as _,At as a,$e as b,St as c,yt as d,ht as f,ct as g,ut as h,jt as i,j,xe as k,$ as l,st as m,kt as n,Z as o,gt as p,y as q,Ot as r,Q as s,It as t,vt as u,Qe as v,G as w,et as x,tt as y,E as z};
@@ -1,3 +1,3 @@
1
- import{a as e,r as t,t as n}from"./color-CbC8zjc1.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 an agent`},{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-BbKp9aSG.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 an agent`},{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};
@@ -0,0 +1 @@
1
+ import{t as e}from"./commands-CJquInVH.mjs";export{e as commandsCommand};
@@ -1,3 +1,3 @@
1
- import{H as e,U as t,V as n,W as r,a as i,n as a,r as o,t as s}from"./color-CbC8zjc1.mjs";async function c(s,c,u){if(!s)return i(o({action:`config`,data:{action:`list`,config:await e()},target:{kind:`config`}}),l);switch(s){case`get`:{if(!c)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify a key`},target:{kind:`config`}}),l);let t=(await e())[c];return i(o({action:`config`,data:{action:`get`,key:c,value:typeof t==`number`||typeof t==`string`?t:void 0},target:{kind:`config`,name:c}}),l)}case`set`:{if(!c||u===void 0)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify both key and value`},target:{kind:`config`}}),l);if(c===`defaultPackageManager`&&u!==`bun`&&u!==`npm`)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`defaultPackageManager must be bun or npm`},target:{kind:`config`,name:c}}),l);if(c===`npmBunUpdateStrategy`&&!n(u))return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`npmBunUpdateStrategy must be latest-major or respect-semver`},target:{kind:`config`,name:c}}),l);if(c===`selfUpdateChannel`&&u!==`stable`&&u!==`beta`)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`selfUpdateChannel must be stable or beta`},target:{kind:`config`,name:c}}),l);if([`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(c)){let e=Number.parseInt(u,10);if(!Number.isInteger(e)||e<=0)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`${c} must be a positive integer`},target:{kind:`config`,name:c}}),l);u=`${e}`}let r={};try{r=await e()}catch{}return r[c]=[`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(c)?Number.parseInt(u,10):u,await t(r),i(o({action:`config`,data:{action:`set`,key:c,value:r[c]},target:{kind:`config`,name:c}}),l)}case`reset`:return await t(r),i(o({action:`config`,data:{action:`reset`,config:r},target:{kind:`config`}}),l);default:return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,details:{action:s},message:`Unknown action: ${s}`},target:{kind:`config`},warnings:[{code:`AVAILABLE_ACTIONS`,message:`Available actions: get, set, reset`}]}),l)}}function l(e){if(e.error){console.log(s.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(s.bold(`
1
+ import{G as e,H as t,U as n,W as r,a as i,n as a,r as o,t as s}from"./color-BbKp9aSG.mjs";async function c(s,c,u){if(!s)return i(o({action:`config`,data:{action:`list`,config:await n()},target:{kind:`config`}}),l);switch(s){case`get`:{if(!c)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify a key`},target:{kind:`config`}}),l);let e=(await n())[c];return i(o({action:`config`,data:{action:`get`,key:c,value:typeof e==`number`||typeof e==`string`?e:void 0},target:{kind:`config`,name:c}}),l)}case`set`:{if(!c||u===void 0)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`Please specify both key and value`},target:{kind:`config`}}),l);if(c===`defaultPackageManager`&&u!==`bun`&&u!==`npm`)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`defaultPackageManager must be bun or npm`},target:{kind:`config`,name:c}}),l);if(c===`npmBunUpdateStrategy`&&!t(u))return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`npmBunUpdateStrategy must be latest-major or respect-semver`},target:{kind:`config`,name:c}}),l);if(c===`selfUpdateChannel`&&u!==`stable`&&u!==`beta`)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`selfUpdateChannel must be stable or beta`},target:{kind:`config`,name:c}}),l);if([`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(c)){let e=Number.parseInt(u,10);if(!Number.isInteger(e)||e<=0)return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,message:`${c} must be a positive integer`},target:{kind:`config`,name:c}}),l);u=`${e}`}let e={};try{e=await n()}catch{}return e[c]=[`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(c)?Number.parseInt(u,10):u,await r(e),i(o({action:`config`,data:{action:`set`,key:c,value:e[c]},target:{kind:`config`,name:c}}),l)}case`reset`:return await r(e),i(o({action:`config`,data:{action:`reset`,config:e},target:{kind:`config`}}),l);default:return i(a({action:`config`,error:{code:`INVALID_ARGUMENT`,details:{action:s},message:`Unknown action: ${s}`},target:{kind:`config`},warnings:[{code:`AVAILABLE_ACTIONS`,message:`Available actions: get, set, reset`}]}),l)}}function l(e){if(e.error){console.log(s.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(s.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?s.gray(`(not set)`):String(e.data.value));break;case`set`:console.log(s.green(`Set ${e.data.key} = ${e.data.value}`));break;case`reset`:console.log(s.green(`Configuration reset to defaults.`));break}}export{c as configCommand};
@@ -0,0 +1 @@
1
+ import e from"node:process";function t(e){return{packageName:e,type:`bun`}}function n(e){return{packageName:e,type:`npm`}}function r(e,t){return{packageName:e,packageTargetKind:t,type:`brew`}}function i(e){return{packageName:e,packageTargetKind:`id`,type:`winget`}}function a(e){return{command:e,type:`script`}}const o={name:`claude`,displayName:`Claude Code`,description:`Anthropic 官方 AI 编程助手 CLI`,homepage:`https://code.claude.com/docs`,packages:{npm:`@anthropic-ai/claude-code`},binaryName:`claude`,selfUpdate:{command:[`claude`,`update`],fallbackCommands:[[`claude`,`upgrade`]]},platforms:{windows:[t(),n(),a(`irm https://claude.ai/install.ps1 | iex`),i(`Anthropic.ClaudeCode`)],macos:[t(),n(),a(`curl -fsSL https://claude.ai/install.sh | bash`),r(`claude-code`,`cask`)],linux:[t(),n(),a(`curl -fsSL https://claude.ai/install.sh | bash`),r(`claude-code`,`cask`)]}},s={name:`codex`,displayName:`Codex CLI`,description:`OpenAI 官方 AI 编程助手 CLI`,homepage:`https://developers.openai.com/codex/cli`,packages:{npm:`@openai/codex`},binaryName:`codex`,selfUpdate:{command:[`codex`,`--upgrade`]},platforms:{windows:[t(),n()],macos:[t(),n(),r(`codex`)],linux:[t(),n(),r(`codex`)]}},c={name:`copilot`,displayName:`GitHub Copilot CLI`,description:`GitHub Copilot 命令行工具`,homepage:`https://github.com/features/copilot/cli`,packages:{npm:`@github/copilot`},binaryName:`copilot`,platforms:{windows:[i(`GitHub.Copilot`)],macos:[t(),n(),a(`curl -fsSL https://gh.io/copilot-install | bash`),r(`copilot-cli`)],linux:[t(),n(),a(`curl -fsSL https://gh.io/copilot-install | bash`),r(`copilot-cli`)]}},l={name:`cursor`,lookupAliases:[`agent`],displayName:`Cursor CLI`,description:`Cursor AI 编程助手命令行工具`,homepage:`https://cursor.com/docs/cli`,binaryName:`agent`,selfUpdate:{command:[`agent`,`update`]},versionProbe:{command:[`agent`,`--version`]},platforms:{windows:[a(`irm 'https://cursor.com/install?win32=true' | iex`)],macos:[a(`curl https://cursor.com/install -fsS | bash`)],linux:[a(`curl https://cursor.com/install -fsS | bash`)]}},u={name:`droid`,displayName:`Droid`,description:`Factory AI 软件工程 Agent CLI`,homepage:`https://docs.factory.ai/cli/getting-started/overview`,packages:{npm:`droid`},binaryName:`droid`,selfUpdate:{command:[`droid`,`update`]},platforms:{windows:[t(),n(),a(`irm https://app.factory.ai/cli/windows | iex`)],macos:[t(),n(),a(`curl -fsSL https://app.factory.ai/cli | sh`),r(`droid`,`cask`)],linux:[t(),n(),a(`curl -fsSL https://app.factory.ai/cli | sh`),r(`droid`,`cask`)]}},d={name:`gemini`,displayName:`Gemini CLI`,description:`Google 开源 AI 编程助手 CLI`,homepage:`https://google-gemini.github.io/gemini-cli/docs/`,packages:{npm:`@google/gemini-cli`},binaryName:`gemini`,platforms:{windows:[t(),n()],macos:[t(),n(),r(`gemini-cli`)],linux:[t(),n(),r(`gemini-cli`)]}},f={name:`opencode`,displayName:`OpenCode`,description:`开源 AI 编程 CLI`,homepage:`https://opencode.ai`,packages:{npm:`opencode-ai`},binaryName:`opencode`,selfUpdate:{command:[`opencode`,`upgrade`]},platforms:{windows:[t(),n()],macos:[t(),n(),a(`curl -fsSL https://opencode.ai/install | bash`),r(`anomalyco/tap/opencode`)],linux:[t(),n(),a(`curl -fsSL https://opencode.ai/install | bash`),r(`anomalyco/tap/opencode`)]}},p={name:`pi`,displayName:`Pi`,description:`极简可扩展的终端编程 Agent`,homepage:`https://pi.dev`,packages:{npm:`@mariozechner/pi-coding-agent`},binaryName:`pi`,selfUpdate:{command:[`pi`,`update`]},platforms:{windows:[t(),n()],macos:[t(),n()],linux:[t(),n()]}},m=[o,s,c,l,u,d,f,p];function h(){return m}function g(e){return m.find(t=>t.name===e||(t.lookupAliases?.includes(e)??!1))}function _(e){return g(e)}function v(){switch(e.platform){case`win32`:return`windows`;case`darwin`:return`macos`;default:return`linux`}}async function y(e){try{let t=Bun.spawn([e,`--version`],{stdout:`pipe`,stderr:`pipe`});return await t.exited,t.exitCode===0}catch{return!1}}async function b(){return y(`bun`)}async function x(){return y(`npm`)}async function S(){return y(`brew`)}async function C(){return y(`winget`)}async function w(t){try{let n=e.platform===`win32`?`where`:`which`,r=Bun.spawn([n,t],{stdout:`pipe`,stderr:`pipe`});return await r.exited,r.exitCode===0}catch{return!1}}export{o as _,x as a,_ as c,f as d,d as f,s as g,c as h,b as i,h as l,l as m,w as n,C as o,u as p,S as r,g as s,v as t,p as u};
@@ -0,0 +1,3 @@
1
+ import{n as e,t}from"./messages-DMxGs5hh.mjs";import{t as n}from"./agents-bx8y3kRS.mjs";import{a as r,i,o as a,r as o}from"./detect-FhBDsvJC.mjs";import{a as s,p as c,r as l,t as u,u as d,z as f}from"./color-BbKp9aSG.mjs";async function p(){let u=await i(),f=await r(),p=await o(),g=await a(),_=await d(),v=_.latestVersion&&_.latestVersion!==_.currentVersion,y=await n(),b=y.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})),x=[],S=`docs/runbooks/quantex-troubleshooting.md`,C=`docs/runbooks/release-and-self-upgrade-debugging.md`;if(!u&&!f&&!p&&!g&&x.push({blocking:!0,category:`installers`,code:`NO_MANAGED_INSTALLER`,docsRef:S,message:`No managed installer found. Install bun, npm, brew, or winget before relying on managed lifecycle operations.`,severity:`warning`,subject:{kind:`system`},suggestedAction:`restore-managed-installer`,suggestedCommands:[]}),(_.installSource===`bun`&&!u||_.installSource===`npm`&&!f)&&x.push({blocking:!0,category:`self`,code:`SELF_INSTALLER_MISSING`,docsRef:C,message:`Quantex CLI is tracked as a ${_.installSource} install, but ${_.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:h(_.installSource,_.updateChannel)}),_.canAutoUpdate||x.push({blocking:!1,category:`self`,code:`SELF_AUTO_UPDATE_UNAVAILABLE`,docsRef:C,message:`Quantex CLI cannot auto-update from install source "${_.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:[]}),v&&_.recommendedUpgradeCommand){let e=c(_);x.push({blocking:!1,category:`self`,code:`SELF_UPDATE_AVAILABLE`,docsRef:C,message:e?`Quantex CLI ${_.currentVersion} is behind ${_.latestVersion}. Run ${_.recommendedUpgradeCommand} or follow: ${e}`:`Quantex CLI ${_.currentVersion} is behind ${_.latestVersion}. Run ${_.recommendedUpgradeCommand}.`,severity:`warning`,subject:{kind:`self`,name:`quantex`},suggestedAction:`run-self-upgrade`,suggestedCommands:[_.recommendedUpgradeCommand]})}for(let n of y.filter(e=>e.inPath)){if(n.installedState||x.push({blocking:!1,category:`agent`,code:`AGENT_UNTRACKED_IN_PATH`,docsRef:S,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);x.push({blocking:!1,category:`agent`,code:`AGENT_MANUAL_UPDATE_REQUIRED`,docsRef:S,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 s(l({action:`doctor`,data:{agents:b,issues:x,installers:{brew:p,bun:u,npm:f,winget:g},self:{canAutoUpdate:_.canAutoUpdate,currentVersion:_.currentVersion,installSource:_.installSource,latestVersion:_.latestVersion,outdated:!!v,recoveryHint:v?c(_):void 0}},target:{kind:`system`,name:`doctor`}}),m)}function m(e){if(e.data){if(console.log(u.bold(`
2
+ Quantex CLI Environment Check
3
+ `)),console.log(u.bold(`Managed Installers:`)),console.log(` Bun: ${e.data.installers.bun?u.green(`available`):u.red(`not found`)}`),console.log(` npm: ${e.data.installers.npm?u.green(`available`):u.red(`not found`)}`),console.log(` brew: ${e.data.installers.brew?u.green(`available`):u.red(`not found`)}`),console.log(` winget:${e.data.installers.winget?u.green(`available`):u.red(`not found`)}`),console.log(`\n${u.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?u.green(`supported`):u.yellow(`unsupported`)}`),e.data.self.latestVersion&&console.log(` Latest: ${e.data.self.latestVersion}${e.data.self.outdated?u.yellow(` (update available)`):``}`),e.data.self.recoveryHint&&console.log(` Recovery: ${e.data.self.recoveryHint}`),console.log(`\n${u.bold(`Installed Agents:`)}`),e.data.agents.length===0)console.log(u.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?u.yellow(` (update available: ${t.latestVersion})`):``}`);if(console.log(`\n${u.bold(`Issues:`)}`),e.data.issues.length===0)console.log(u.green(` No issues found.`));else for(let t of e.data.issues)console.log(u.yellow(` - ${t.message}`)),t.suggestedCommands.length>0&&console.log(u.dim(` Next: ${t.suggestedCommands.join(` | `)}`));console.log()}}function h(e,t){let n=t===`beta`?`beta`:`latest`;return e===`bun`?[`bun add -g ${f}@${n}`]:e===`npm`?[`npm install -g ${f}@${n}`]:[]}export{p as doctorCommand};
@@ -0,0 +1 @@
1
+ import{t as e}from"./ensure-BceOwwrn.mjs";export{e as ensureCommand};
@@ -1 +1 @@
1
- import{r as e,s as t}from"./agents-BPMc1vIb.mjs";import{L as n,a as r,i,n as a,r as o,t as s}from"./color-CbC8zjc1.mjs";import{t as c}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as l,i as u,n as d,r as f}from"./user-output-DYsOPwi1.mjs";async function p(s){let l=await e(s);if(!l)return r(a({action:`ensure`,error:{code:`AGENT_NOT_FOUND`,details:{input:s},message:`Unknown agent: ${s}`},target:{kind:`agent`,name:s}}),m);let{agent:u,inspection:f}=l;if(f.inPath)return r(o({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!0},target:{kind:`agent`,name:u.name},warnings:[{code:`ALREADY_INSTALLED`,message:`${u.displayName} is already installed.`}]}),m);if(d())return r(o({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},target:{kind:`agent`,name:u.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would install ${u.displayName}.`}]}),m);i({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name}},target:{kind:`agent`,name:u.name},type:`started`});let p;try{p=await t(u)}catch(e){if(n(e))return r(a({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},...c(e,{kind:`agent`,name:u.name})}),m);throw e}return p.success?r(o({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!0,installState:p.installedState?{installType:p.installedState.installType,packageName:p.installedState.packageName}:void 0,installed:!0},target:{kind:`agent`,name:u.name}}),m):r(a({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},error:{code:`INSTALL_FAILED`,message:`Failed to install ${u.displayName}.`},target:{kind:`agent`,name:u.name}}),m)}function m(e){if(e.error){f(s.red(e.error.message));return}if(e.data){if(e.warnings.length>0){for(let t of e.warnings)l(s.yellow(t.message));return}if(e.data.changed){u(s.cyan(`Installing ${e.data.agent.displayName}...`)),u(s.green(`${e.data.agent.displayName} is now installed.`));return}u(s.green(`${e.data.agent.displayName} is already installed.`))}}export{p as t};
1
+ import{r as e,s as t}from"./agents-bx8y3kRS.mjs";import{L as n,a as r,i,n as a,r as o,t as s}from"./color-BbKp9aSG.mjs";import{t as c}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as l,i as u,n as d,r as f}from"./user-output-DFxUPA-p.mjs";async function p(s){let l=await e(s);if(!l)return r(a({action:`ensure`,error:{code:`AGENT_NOT_FOUND`,details:{input:s},message:`Unknown agent: ${s}`},target:{kind:`agent`,name:s}}),m);let{agent:u,inspection:f}=l;if(f.inPath)return r(o({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!0},target:{kind:`agent`,name:u.name},warnings:[{code:`ALREADY_INSTALLED`,message:`${u.displayName} is already installed.`}]}),m);if(d())return r(o({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},target:{kind:`agent`,name:u.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would install ${u.displayName}.`}]}),m);i({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name}},target:{kind:`agent`,name:u.name},type:`started`});let p;try{p=await t(u)}catch(e){if(n(e))return r(a({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},...c(e,{kind:`agent`,name:u.name})}),m);throw e}return p.success?r(o({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!0,installState:p.installedState?{installType:p.installedState.installType,packageName:p.installedState.packageName}:void 0,installed:!0},target:{kind:`agent`,name:u.name}}),m):r(a({action:`ensure`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},error:{code:`INSTALL_FAILED`,message:`Failed to install ${u.displayName}.`},target:{kind:`agent`,name:u.name}}),m)}function m(e){if(e.error){f(s.red(e.error.message));return}if(e.data){if(e.warnings.length>0){for(let t of e.warnings)l(s.yellow(t.message));return}if(e.data.changed){u(s.cyan(`Installing ${e.data.agent.displayName}...`)),u(s.green(`${e.data.agent.displayName} is now installed.`));return}u(s.green(`${e.data.agent.displayName} is already installed.`))}}export{p as t};
package/dist/index.d.mts CHANGED
@@ -361,6 +361,17 @@ interface ResolveCommandData {
361
361
  };
362
362
  resolution: {
363
363
  binaryPath: string;
364
+ installGuidance?: {
365
+ docsRef: string;
366
+ installMethods: Array<{
367
+ command: string;
368
+ label: string;
369
+ type: string;
370
+ }>;
371
+ suggestedAction: 'ensure-agent-installed';
372
+ suggestedEnsureCommand: string;
373
+ };
374
+ installed: boolean;
364
375
  installSource: string;
365
376
  installedVersion?: string;
366
377
  lifecycle: 'managed' | 'unmanaged';
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,i as t,n,o as r,s as i,t as a}from"./update-CtO35mwD.mjs";import{C as ee,S as te,T as ne,a as re,b as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,w as x,x as S}from"./agents-BPMc1vIb.mjs";import{_ as C,a as w,c as T,d as E,f as D,g as O,h as k,i as A,l as j,m as M,n as N,p as P,s as F,t as I,u as L}from"./detect-q8eznhj9.mjs";import{A as R,B as z,C as B,D as V,E as H,F as U,H as W,I as G,J as K,K as q,M as J,N as Y,O as ie,P as ae,S as oe,T as se,U as ce,Y as le,a as ue,c as de,d as fe,f as pe,j as me,k as he,l as ge,n as _e,o as ve,p as ye,q as be,r as xe,s as Se,u as Ce,w as we,z as Te}from"./color-CbC8zjc1.mjs";import{t as Ee}from"./capabilities-CUyQejux.mjs";import{t as De}from"./commands-B4PWQRb1.mjs";import{t as Oe}from"./ensure-CICTMwyQ.mjs";import{t as ke}from"./inspect-CrAtG1sO.mjs";import{t as Ae}from"./resolve-BaEyqkW-.mjs";import{n as X,t as je}from"./schema-CrujLfID.mjs";import{n as Me,t as Ne}from"./errors-DCtNasuC.mjs";function Pe(e){return`${e.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>`${e.checksum} ${e.name}`).join(`
2
- `)}\n`}function Fe(e){let t=new Map;for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e)continue;let[r,i]=e.split(/\s+/,2),a=i?.replace(/^\*/,``);r&&a&&t.set(a,r)}return t}function Z(e){let t=e.match(/^quantex-(darwin|linux|windows)-(arm64|x64)(?:\.exe)?$/);if(t)return{arch:t[2]===`arm64`?`arm64`:`x64`,platform:t[1]===`windows`?`win32`:t[1]===`darwin`?`darwin`:`linux`}}function Q(e){return e?e.startsWith(`git+`)?e.slice(4).replace(/\.git$/,``):e.startsWith(`git@github.com:`)?e.replace(`git@github.com:`,`https://github.com/`).replace(/\.git$/,``):e.replace(/\.git$/,``):`https://github.com/Drswith/quantex-cli`}function $(e){return e.includes(`beta`)?`beta`:`stable`}function Ie(e){let t=Q(e.repositoryUrl),n=$(e.version),r=e.files.map(n=>{let r=Z(n.name);if(!r)return;let i=e.checksums.get(n.name);if(!i)throw Error(`Missing checksum entry for ${n.name}.`);return{arch:r.arch,checksum:i,downloadUrl:`${t}/releases/download/v${e.version}/${n.name}`,name:n.name,platform:r.platform,size:n.size}}).filter(e=>e!==void 0).sort((e,t)=>e.name.localeCompare(t.name));if(r.length===0)throw Error(`No release binaries were found when creating manifest.json.`);return{assets:r,channel:n,version:e.version}}function Le(e,t){if(e.assets.length===0)throw Error(`manifest.json must contain at least one binary asset.`);for(let n of e.assets){let e=t.get(n.name);if(!e)throw Error(`manifest.json references ${n.name}, but it is missing from SHA256SUMS.txt.`);if(n.checksum!==e)throw Error(`manifest.json checksum mismatch for ${n.name}.`);if(!Z(n.name))throw Error(`manifest.json contains an invalid binary asset name: ${n.name}.`)}}async function Re(e,t){try{let n=await B(oe([e,...t]));return{success:n===0,exitCode:n}}catch{return{success:!1,exitCode:1}}}export{l as agentUpdateProviders,ve as canAutoUpdateSelf,o as canLookupLatestVersionForInstallType,g as canResolveAgentUpdate,S as canUninstallInstallType,te as canUpdateInstallType,Ee as capabilitiesCommand,C as claude,O as codex,De as commandsCommand,k as copilot,_e as createErrorResult,Ie as createReleaseManifest,xe as createSuccessResult,t as createUpdatePlan,M as cursor,Se as detectSelfInstallSource,P as droid,ue as emitCommandResult,Oe as ensureCommand,Re as execCommand,Pe as formatChecksums,D as gemini,F as getAgentByLookupName,T as getAgentByNameOrAlias,r as getAgentUpdateFailureHint,p as getAgentUpdateStrategy,j as getAllAgents,H as getBinaryPath,we as getBinaryReleaseAssetName,se as getBinaryReleaseDownloadUrl,q as getCliContext,Te as getConfigDir,z as getConfigFilePath,Ne as getExitCodeForError,Me as getExitCodeForResult,ee as getInstallLifecycle,he as getInstalledAgentState,V as getInstalledVersion,x as getInstallerCapabilities,ie as getLatestVersion,c as getManagedInstaller,i as getManualAgentUpdateMessage,de as getManualSelfUpgradeCommand,h as getOrderedInstallMethods,I as getPlatform,je as getSchemaCatalog,R as getSelfState,pe as getSelfUpgradeRecoveryHint,ye as getSelfUpgradeRecoveryHintForInspection,ge as getSelfVersion,a as getSingleAgentUpdateStatus,me as getStateFilePath,d as inspectAgent,re as inspectAllAgents,ke as inspectCommand,y as inspectRegisteredAgents,Ce as inspectSelf,v as installAgent,N as isBinaryInPath,A as isBunAvailable,e as isInspectionUpdateAvailable,ne as isManagedInstallType,w as isNpmAvailable,W as loadConfig,J as loadState,Q as normalizeRepositoryUrl,E as opencode,Z as parseBinaryTarget,Fe as parseChecksums,L as pi,n as planAgentUpdates,Y as removeInstalledAgentState,be as resetCliContext,m as resolveAgent,_ as resolveAgentInspection,u as resolveAgentUpdateProvider,K as resolveCliContext,Ae as resolveCommand,$ as resolveReleaseChannel,ce as saveConfig,ae as saveState,X as schemaCommand,le as setCliContext,U as setInstalledAgentState,G as setSelfInstallSource,s as uninstallAgent,f as updateAgent,b as updateAgentsByType,fe as upgradeSelf,Le as validateReleaseManifest};
1
+ import{n as e,t}from"./messages-DMxGs5hh.mjs";import{C as n,S as r,T as i,a,b as ee,c as te,d as ne,f as re,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,w as _,x as v}from"./agents-bx8y3kRS.mjs";import{_ as y,a as b,c as x,d as S,f as C,g as w,h as T,i as E,l as D,m as O,n as k,p as A,s as j,t as M,u as N}from"./detect-FhBDsvJC.mjs";import{A as P,B as F,C as I,D as L,E as R,F as z,I as B,J as V,M as H,N as U,O as W,P as G,S as K,T as q,U as J,V as Y,W as ie,X as ae,Y as oe,a as se,c as ce,d as le,f as ue,j as de,k as fe,l as pe,n as me,o as he,p as ge,q as _e,r as ve,s as ye,u as be,w as xe}from"./color-BbKp9aSG.mjs";import{t as Se}from"./capabilities-KKT-gyc8.mjs";import{t as Ce}from"./commands-CJquInVH.mjs";import{t as we}from"./ensure-BceOwwrn.mjs";import{t as Te}from"./inspect-DIZiG8De.mjs";import{t as Ee}from"./resolve-CpAvaM7V.mjs";import{n as De,t as Oe}from"./schema-Ckf19SIa.mjs";import{n as ke,t as Ae}from"./errors-DCtNasuC.mjs";import{a as X,i as je,n as Me,t as Ne}from"./update-DHOTks91.mjs";function Pe(e){return`${e.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>`${e.checksum} ${e.name}`).join(`
2
+ `)}\n`}function Fe(e){let t=new Map;for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e)continue;let[r,i]=e.split(/\s+/,2),a=i?.replace(/^\*/,``);r&&a&&t.set(a,r)}return t}function Z(e){let t=e.match(/^quantex-(darwin|linux|windows)-(arm64|x64)(?:\.exe)?$/);if(t)return{arch:t[2]===`arm64`?`arm64`:`x64`,platform:t[1]===`windows`?`win32`:t[1]===`darwin`?`darwin`:`linux`}}function Q(e){return e?e.startsWith(`git+`)?e.slice(4).replace(/\.git$/,``):e.startsWith(`git@github.com:`)?e.replace(`git@github.com:`,`https://github.com/`).replace(/\.git$/,``):e.replace(/\.git$/,``):`https://github.com/Drswith/quantex-cli`}function $(e){return e.includes(`beta`)?`beta`:`stable`}function Ie(e){let t=Q(e.repositoryUrl),n=$(e.version),r=e.files.map(n=>{let r=Z(n.name);if(!r)return;let i=e.checksums.get(n.name);if(!i)throw Error(`Missing checksum entry for ${n.name}.`);return{arch:r.arch,checksum:i,downloadUrl:`${t}/releases/download/v${e.version}/${n.name}`,name:n.name,platform:r.platform,size:n.size}}).filter(e=>e!==void 0).sort((e,t)=>e.name.localeCompare(t.name));if(r.length===0)throw Error(`No release binaries were found when creating manifest.json.`);return{assets:r,channel:n,version:e.version}}function Le(e,t){if(e.assets.length===0)throw Error(`manifest.json must contain at least one binary asset.`);for(let n of e.assets){let e=t.get(n.name);if(!e)throw Error(`manifest.json references ${n.name}, but it is missing from SHA256SUMS.txt.`);if(n.checksum!==e)throw Error(`manifest.json checksum mismatch for ${n.name}.`);if(!Z(n.name))throw Error(`manifest.json contains an invalid binary asset name: ${n.name}.`)}}async function Re(e,t){try{let n=await I(K([e,...t]));return{success:n===0,exitCode:n}}catch{return{success:!1,exitCode:1}}}export{re as agentUpdateProviders,he as canAutoUpdateSelf,ee as canLookupLatestVersionForInstallType,f as canResolveAgentUpdate,v as canUninstallInstallType,r as canUpdateInstallType,Se as capabilitiesCommand,y as claude,w as codex,Ce as commandsCommand,T as copilot,me as createErrorResult,Ie as createReleaseManifest,ve as createSuccessResult,je as createUpdatePlan,O as cursor,ye as detectSelfInstallSource,A as droid,se as emitCommandResult,we as ensureCommand,Re as execCommand,Pe as formatChecksums,C as gemini,j as getAgentByLookupName,x as getAgentByNameOrAlias,t as getAgentUpdateFailureHint,l as getAgentUpdateStrategy,D as getAllAgents,R as getBinaryPath,xe as getBinaryReleaseAssetName,q as getBinaryReleaseDownloadUrl,_e as getCliContext,F as getConfigDir,Y as getConfigFilePath,Ae as getExitCodeForError,ke as getExitCodeForResult,n as getInstallLifecycle,fe as getInstalledAgentState,L as getInstalledVersion,_ as getInstallerCapabilities,W as getLatestVersion,ne as getManagedInstaller,e as getManualAgentUpdateMessage,ce as getManualSelfUpgradeCommand,d as getOrderedInstallMethods,M as getPlatform,Oe as getSchemaCatalog,P as getSelfState,ue as getSelfUpgradeRecoveryHint,ge as getSelfUpgradeRecoveryHintForInspection,pe as getSelfVersion,Ne as getSingleAgentUpdateStatus,de as getStateFilePath,s as inspectAgent,a as inspectAllAgents,Te as inspectCommand,h as inspectRegisteredAgents,be as inspectSelf,m as installAgent,k as isBinaryInPath,E as isBunAvailable,X as isInspectionUpdateAvailable,i as isManagedInstallType,b as isNpmAvailable,J as loadConfig,H as loadState,Q as normalizeRepositoryUrl,S as opencode,Z as parseBinaryTarget,Fe as parseChecksums,N as pi,Me as planAgentUpdates,U as removeInstalledAgentState,V as resetCliContext,u as resolveAgent,p as resolveAgentInspection,o as resolveAgentUpdateProvider,oe as resolveCliContext,Ee as resolveCommand,$ as resolveReleaseChannel,ie as saveConfig,G as saveState,De as schemaCommand,ae as setCliContext,z as setInstalledAgentState,B as setSelfInstallSource,te as uninstallAgent,c as updateAgent,g as updateAgentsByType,le as upgradeSelf,Le as validateReleaseManifest};
@@ -1,2 +1,2 @@
1
- import{_ as e,r as t,v as n}from"./agents-BPMc1vIb.mjs";import{a as r,n as i,r as a,t as o}from"./color-CbC8zjc1.mjs";async function s(o){let s=await t(o);if(!s)return r(i({action:`info`,error:{code:`AGENT_NOT_FOUND`,details:{input:o},message:`Unknown agent: ${o}`},target:{kind:`agent`,name:o}}),c);let{agent:l,inspection:u}=s,d=l.selfUpdate?[l.selfUpdate.command,...l.selfUpdate.fallbackCommands??[]].map(e=>e.join(` `)):[];return r(a({action:`info`,data:{agent:{aliases:l.lookupAliases??[],binaryName:l.binaryName,description:l.description,displayName:l.displayName,installMethods:u.methods.map(t=>({command:e(l,t),label:n(t),type:t.type})),name:l.name,packageName:l.packages?.npm,selfUpdateCommands:d},inspection:{binaryPath:u.binaryPath,installed:u.inPath,installedVersion:u.installedVersion,latestVersion:u.latestVersion,lifecycle:u.lifecycle,sourceLabel:u.inPath?u.sourceLabel:void 0}},target:{kind:`agent`,name:l.name}}),c)}function c(e){if(e.error){console.log(o.red(e.error.message));return}if(e.data){console.log(o.bold(`\n${e.data.agent.displayName}\n`)),console.log(` Name: ${e.data.agent.name}`),console.log(` Aliases: ${e.data.agent.aliases.join(`, `)||`-`}`),console.log(` Description: ${e.data.agent.description}`),console.log(` Package: ${e.data.agent.packageName??`-`}`),console.log(` Binary: ${e.data.agent.binaryName}`),console.log(` Update: ${e.data.agent.selfUpdateCommands.join(` || `)||`-`}`),console.log(` Installed: ${e.data.inspection.installed?o.green(`Yes`):o.red(`No`)}`),e.data.inspection.sourceLabel&&console.log(` Source: ${e.data.inspection.sourceLabel}`),e.data.inspection.installed&&console.log(` Lifecycle: ${e.data.inspection.lifecycle}`),e.data.inspection.installedVersion&&console.log(` Version: ${e.data.inspection.installedVersion}`),e.data.inspection.latestVersion&&console.log(` Latest: ${e.data.inspection.latestVersion}`),e.data.inspection.binaryPath&&console.log(` Path: ${e.data.inspection.binaryPath}`),console.log(o.bold(`
1
+ import{_ as e,r as t,v as n}from"./agents-bx8y3kRS.mjs";import{a as r,n as i,r as a,t as o}from"./color-BbKp9aSG.mjs";async function s(o){let s=await t(o);if(!s)return r(i({action:`info`,error:{code:`AGENT_NOT_FOUND`,details:{input:o},message:`Unknown agent: ${o}`},target:{kind:`agent`,name:o}}),c);let{agent:l,inspection:u}=s,d=l.selfUpdate?[l.selfUpdate.command,...l.selfUpdate.fallbackCommands??[]].map(e=>e.join(` `)):[];return r(a({action:`info`,data:{agent:{aliases:l.lookupAliases??[],binaryName:l.binaryName,description:l.description,displayName:l.displayName,installMethods:u.methods.map(t=>({command:e(l,t),label:n(t),type:t.type})),name:l.name,packageName:l.packages?.npm,selfUpdateCommands:d},inspection:{binaryPath:u.binaryPath,installed:u.inPath,installedVersion:u.installedVersion,latestVersion:u.latestVersion,lifecycle:u.lifecycle,sourceLabel:u.inPath?u.sourceLabel:void 0}},target:{kind:`agent`,name:l.name}}),c)}function c(e){if(e.error){console.log(o.red(e.error.message));return}if(e.data){console.log(o.bold(`\n${e.data.agent.displayName}\n`)),console.log(` Name: ${e.data.agent.name}`),console.log(` Aliases: ${e.data.agent.aliases.join(`, `)||`-`}`),console.log(` Description: ${e.data.agent.description}`),console.log(` Package: ${e.data.agent.packageName??`-`}`),console.log(` Binary: ${e.data.agent.binaryName}`),console.log(` Update: ${e.data.agent.selfUpdateCommands.join(` || `)||`-`}`),console.log(` Installed: ${e.data.inspection.installed?o.green(`Yes`):o.red(`No`)}`),e.data.inspection.sourceLabel&&console.log(` Source: ${e.data.inspection.sourceLabel}`),e.data.inspection.installed&&console.log(` Lifecycle: ${e.data.inspection.lifecycle}`),e.data.inspection.installedVersion&&console.log(` Version: ${e.data.inspection.installedVersion}`),e.data.inspection.latestVersion&&console.log(` Latest: ${e.data.inspection.latestVersion}`),e.data.inspection.binaryPath&&console.log(` Path: ${e.data.inspection.binaryPath}`),console.log(o.bold(`
2
2
  Install Methods:`));for(let t of e.data.agent.installMethods)console.log(` ${o.green(`+`)} [${t.label}] ${t.command}`);console.log()}}export{s as infoCommand};
@@ -0,0 +1 @@
1
+ import{t as e}from"./inspect-DIZiG8De.mjs";export{e as inspectCommand};
@@ -1,3 +1,3 @@
1
- import{_ as e,r as t,v as n}from"./agents-BPMc1vIb.mjs";import{a as r,n as i,r as a,t as o}from"./color-CbC8zjc1.mjs";async function s(o){let s=await t(o);if(!s)return r(i({action:`inspect`,error:{code:`AGENT_NOT_FOUND`,details:{input:o},message:`Unknown agent: ${o}`},target:{kind:`agent`,name:o}}),c);let{agent:l,inspection:u}=s,d=l.selfUpdate?[l.selfUpdate.command,...l.selfUpdate.fallbackCommands??[]].map(e=>e.join(` `)):[];return r(a({action:`inspect`,data:{agent:{aliases:l.lookupAliases??[],binaryName:l.binaryName,description:l.description,displayName:l.displayName,installMethods:u.methods.map(t=>({command:e(l,t),label:n(t),type:t.type})),name:l.name,packageName:l.packages?.npm,selfUpdateCommands:d},capabilities:{canAutoInstall:u.methods.length>0,canAutoUninstall:u.inPath&&u.lifecycle===`managed`,canRun:u.inPath,canSelfUpdate:d.length>0},inspection:{binaryPath:u.binaryPath,installed:u.inPath,installedVersion:u.installedVersion,latestVersion:u.latestVersion,lifecycle:u.lifecycle,sourceLabel:u.inPath?u.sourceLabel:void 0,updateLabel:u.updateLabel}},target:{kind:`agent`,name:l.name}}),c)}function c(e){if(e.error){console.log(o.red(e.error.message));return}if(e.data){console.log(o.bold(`\n${e.data.agent.displayName}\n`)),console.log(` Name: ${e.data.agent.name}`),console.log(` Aliases: ${e.data.agent.aliases.join(`, `)||`-`}`),console.log(` Description: ${e.data.agent.description}`),console.log(` Package: ${e.data.agent.packageName??`-`}`),console.log(` Binary: ${e.data.agent.binaryName}`),console.log(` Installed: ${e.data.inspection.installed?o.green(`Yes`):o.red(`No`)}`),console.log(` Update Mode: ${e.data.inspection.updateLabel}`),console.log(` Self Update: ${e.data.agent.selfUpdateCommands.join(` || `)||`-`}`),e.data.inspection.sourceLabel&&console.log(` Source: ${e.data.inspection.sourceLabel}`),e.data.inspection.installedVersion&&console.log(` Version: ${e.data.inspection.installedVersion}`),e.data.inspection.latestVersion&&console.log(` Latest: ${e.data.inspection.latestVersion}`),e.data.inspection.binaryPath&&console.log(` Path: ${e.data.inspection.binaryPath}`),console.log(o.bold(`
1
+ import{_ as e,r as t,v as n}from"./agents-bx8y3kRS.mjs";import{a as r,n as i,r as a,t as o}from"./color-BbKp9aSG.mjs";async function s(o){let s=await t(o);if(!s)return r(i({action:`inspect`,error:{code:`AGENT_NOT_FOUND`,details:{input:o},message:`Unknown agent: ${o}`},target:{kind:`agent`,name:o}}),c);let{agent:l,inspection:u}=s,d=l.selfUpdate?[l.selfUpdate.command,...l.selfUpdate.fallbackCommands??[]].map(e=>e.join(` `)):[];return r(a({action:`inspect`,data:{agent:{aliases:l.lookupAliases??[],binaryName:l.binaryName,description:l.description,displayName:l.displayName,installMethods:u.methods.map(t=>({command:e(l,t),label:n(t),type:t.type})),name:l.name,packageName:l.packages?.npm,selfUpdateCommands:d},capabilities:{canAutoInstall:u.methods.length>0,canAutoUninstall:u.inPath&&u.lifecycle===`managed`,canRun:u.inPath,canSelfUpdate:d.length>0},inspection:{binaryPath:u.binaryPath,installed:u.inPath,installedVersion:u.installedVersion,latestVersion:u.latestVersion,lifecycle:u.lifecycle,sourceLabel:u.inPath?u.sourceLabel:void 0,updateLabel:u.updateLabel}},target:{kind:`agent`,name:l.name}}),c)}function c(e){if(e.error){console.log(o.red(e.error.message));return}if(e.data){console.log(o.bold(`\n${e.data.agent.displayName}\n`)),console.log(` Name: ${e.data.agent.name}`),console.log(` Aliases: ${e.data.agent.aliases.join(`, `)||`-`}`),console.log(` Description: ${e.data.agent.description}`),console.log(` Package: ${e.data.agent.packageName??`-`}`),console.log(` Binary: ${e.data.agent.binaryName}`),console.log(` Installed: ${e.data.inspection.installed?o.green(`Yes`):o.red(`No`)}`),console.log(` Update Mode: ${e.data.inspection.updateLabel}`),console.log(` Self Update: ${e.data.agent.selfUpdateCommands.join(` || `)||`-`}`),e.data.inspection.sourceLabel&&console.log(` Source: ${e.data.inspection.sourceLabel}`),e.data.inspection.installedVersion&&console.log(` Version: ${e.data.inspection.installedVersion}`),e.data.inspection.latestVersion&&console.log(` Latest: ${e.data.inspection.latestVersion}`),e.data.inspection.binaryPath&&console.log(` Path: ${e.data.inspection.binaryPath}`),console.log(o.bold(`
2
2
  Capabilities:`)),console.log(` auto-install: ${e.data.capabilities.canAutoInstall?`yes`:`no`}`),console.log(` self-update: ${e.data.capabilities.canSelfUpdate?`yes`:`no`}`),console.log(` auto-uninstall: ${e.data.capabilities.canAutoUninstall?`yes`:`no`}`),console.log(` runnable: ${e.data.capabilities.canRun?`yes`:`no`}`),console.log(o.bold(`
3
3
  Install Methods:`));for(let t of e.data.agent.installMethods)console.log(` ${o.green(`+`)} [${t.label}] ${t.command}`);console.log()}}export{s as t};
@@ -1 +1 @@
1
- import{r as e,s as t}from"./agents-BPMc1vIb.mjs";import{L as n,a as r,i,n as a,r as o,t as s}from"./color-CbC8zjc1.mjs";import{t as c}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as l,i as u,n as d,r as f}from"./user-output-DYsOPwi1.mjs";async function p(s){let l=await e(s);if(!l)return r(a({action:`install`,error:{code:`AGENT_NOT_FOUND`,details:{input:s},message:`Unknown agent: ${s}`},target:{kind:`agent`,name:s}}),m);let{agent:u,inspection:f}=l;if(f.inPath)return r(o({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!0},target:{kind:`agent`,name:u.name},warnings:[{code:`ALREADY_INSTALLED`,message:`${u.displayName} is already installed.`}]}),m);if(d())return r(o({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},target:{kind:`agent`,name:u.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would install ${u.displayName}.`}]}),m);i({action:`install`,data:{agent:{displayName:u.displayName,name:u.name}},target:{kind:`agent`,name:u.name},type:`started`});let p;try{p=await t(u)}catch(e){if(n(e))return r(a({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},...c(e,{kind:`agent`,name:u.name})}),m);throw e}return p.success?r(o({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!0,installState:p.installedState?{installType:p.installedState.installType,packageName:p.installedState.packageName}:void 0,installed:!0},target:{kind:`agent`,name:u.name}}),m):r(a({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},error:{code:`INSTALL_FAILED`,message:`Failed to install ${u.displayName}.`},target:{kind:`agent`,name:u.name}}),m)}function m(e){if(e.error){f(s.red(e.error.message));return}if(e.data){if(e.warnings.length>0){for(let t of e.warnings)l(s.yellow(t.message));return}u(s.cyan(`Installing ${e.data.agent.displayName}...`)),u(s.green(`${e.data.agent.displayName} installed successfully!`))}}export{p as installCommand};
1
+ import{r as e,s as t}from"./agents-bx8y3kRS.mjs";import{L as n,a as r,i,n as a,r as o,t as s}from"./color-BbKp9aSG.mjs";import{t as c}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as l,i as u,n as d,r as f}from"./user-output-DFxUPA-p.mjs";async function p(s){let l=await e(s);if(!l)return r(a({action:`install`,error:{code:`AGENT_NOT_FOUND`,details:{input:s},message:`Unknown agent: ${s}`},target:{kind:`agent`,name:s}}),m);let{agent:u,inspection:f}=l;if(f.inPath)return r(o({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!0},target:{kind:`agent`,name:u.name},warnings:[{code:`ALREADY_INSTALLED`,message:`${u.displayName} is already installed.`}]}),m);if(d())return r(o({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},target:{kind:`agent`,name:u.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would install ${u.displayName}.`}]}),m);i({action:`install`,data:{agent:{displayName:u.displayName,name:u.name}},target:{kind:`agent`,name:u.name},type:`started`});let p;try{p=await t(u)}catch(e){if(n(e))return r(a({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},...c(e,{kind:`agent`,name:u.name})}),m);throw e}return p.success?r(o({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!0,installState:p.installedState?{installType:p.installedState.installType,packageName:p.installedState.packageName}:void 0,installed:!0},target:{kind:`agent`,name:u.name}}),m):r(a({action:`install`,data:{agent:{displayName:u.displayName,name:u.name},changed:!1,installed:!1},error:{code:`INSTALL_FAILED`,message:`Failed to install ${u.displayName}.`},target:{kind:`agent`,name:u.name}}),m)}function m(e){if(e.error){f(s.red(e.error.message));return}if(e.data){if(e.warnings.length>0){for(let t of e.warnings)l(s.yellow(t.message));return}u(s.cyan(`Installing ${e.data.agent.displayName}...`)),u(s.green(`${e.data.agent.displayName} installed successfully!`))}}export{p as installCommand};
@@ -1,3 +1,3 @@
1
- import{t as e}from"./agents-BPMc1vIb.mjs";import{a as t,r as n,t as r}from"./color-CbC8zjc1.mjs";async function i(){return t(n({action:`list`,data:{agents:(await e()).map(e=>({binaryName:e.agent.binaryName,displayName:e.agent.displayName,installed:e.inPath,installedVersion:e.installedVersion,latestVersion:e.latestVersion,lifecycle:e.lifecycle,name:e.agent.name,sourceLabel:e.sourceLabel,updateLabel:e.updateLabel}))},target:{kind:`system`,name:`agents`}}),a)}function a(e){console.log(r.bold(`
1
+ import{t as e}from"./agents-bx8y3kRS.mjs";import{a as t,r as n,t as r}from"./color-BbKp9aSG.mjs";async function i(){return t(n({action:`list`,data:{agents:(await e()).map(e=>({binaryName:e.agent.binaryName,displayName:e.agent.displayName,installed:e.inPath,installedVersion:e.installedVersion,latestVersion:e.latestVersion,lifecycle:e.lifecycle,name:e.agent.name,sourceLabel:e.sourceLabel,updateLabel:e.updateLabel}))},target:{kind:`system`,name:`agents`}}),a)}function a(e){console.log(r.bold(`
2
2
  AI Agents:
3
3
  `));for(let t of e.data?.agents??[]){let e=t.displayName.padEnd(18),n=t.installed?r.green(`installed`):r.gray(`not installed`),i=t.installed?r.dim(t.installedVersion??`unknown version`):``,a=t.installed?r.cyan(t.updateLabel):``,o=t.installed?r.dim(t.sourceLabel):``;console.log(` ${e} ${n} ${i}${a?` ${a}`:``}${o?` ${o}`:``}`)}console.log()}export{i as listCommand};
@@ -0,0 +1 @@
1
+ function e(e){return`${e.displayName} uses a manually managed install source. Please check for updates manually.`}function t(e,t){if(t===`self-update`&&e.selfUpdate)return`Try running ${e.selfUpdate.command.join(` `)} directly.`;if(t===`manual-hint`)return`Check ${e.homepage} for the recommended update path.`}export{e as n,t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./resolve-CpAvaM7V.mjs";export{e as resolveCommand};
@@ -0,0 +1 @@
1
+ import{_ as e,r as t,v as n}from"./agents-bx8y3kRS.mjs";import{a as r,n as i,r as a,t as o}from"./color-BbKp9aSG.mjs";async function s(o){let s=await t(o);if(!s)return r(i({action:`resolve`,error:{code:`AGENT_NOT_FOUND`,details:{input:o},message:`Unknown agent: ${o}`},target:{kind:`agent`,name:o}}),c);let{agent:l,inspection:u}=s;if(!u.inPath||!u.binaryPath){let t=u.methods.map(t=>({command:e(l,t),label:n(t),type:t.type})).filter(e=>e.command);return r(i({action:`resolve`,data:{agent:{binaryName:l.binaryName,displayName:l.displayName,name:l.name},resolution:{binaryPath:``,installGuidance:{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t,suggestedAction:`ensure-agent-installed`,suggestedEnsureCommand:`quantex ensure ${l.name}`},installed:!1,installSource:`not-installed`,lifecycle:`unmanaged`,sourceLabel:`not installed`,suggestedLaunchCommand:[]}},error:{code:`AGENT_NOT_INSTALLED`,details:{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t,suggestedAction:`ensure-agent-installed`,suggestedEnsureCommand:`quantex ensure ${l.name}`},message:`${l.displayName} is not installed.`},target:{kind:`agent`,name:l.name}}),c)}return r(a({action:`resolve`,data:{agent:{binaryName:l.binaryName,displayName:l.displayName,name:l.name},resolution:{binaryPath:u.binaryPath,installed:!0,installSource:u.installedState?.installType??`detected-in-path`,installedVersion:u.installedVersion,lifecycle:u.lifecycle,sourceLabel:u.sourceLabel,suggestedLaunchCommand:[u.binaryPath]}},target:{kind:`agent`,name:l.name}}),c)}function c(e){if(e.error){console.log(o.red(e.error.message));let t=e.data?.resolution.installGuidance;if(t){console.log(o.dim(`Try: ${t.suggestedEnsureCommand}`));for(let e of t.installMethods)console.log(o.dim(`Install: [${e.label}] ${e.command}`))}return}e.data&&(console.log(o.bold(`\n${e.data.agent.displayName}\n`)),console.log(` Name: ${e.data.agent.name}`),console.log(` Binary: ${e.data.agent.binaryName}`),console.log(` Path: ${e.data.resolution.binaryPath}`),console.log(` Source: ${e.data.resolution.sourceLabel}`),console.log(` Lifecycle: ${e.data.resolution.lifecycle}`),console.log(` Install Type: ${e.data.resolution.installSource}`),e.data.resolution.installedVersion&&console.log(` Version: ${e.data.resolution.installedVersion}`),console.log(` Launch: ${e.data.resolution.suggestedLaunchCommand.join(` `)}`),console.log())}export{s as t};
@@ -0,0 +1,3 @@
1
+ import{a as e,n as t,r as n,t as r}from"./color-BbKp9aSG.mjs";const i={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},error:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},exitCode:{type:`integer`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},ok:{type:`boolean`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},warnings:{items:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},type:`array`}},required:[`action`,`error`,`meta`,`ok`,`warnings`],type:`object`},a={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},type:{type:`string`}},required:[`action`,`meta`,`type`],type:`object`},o=[{dataSchema:{additionalProperties:!1,properties:{agents:{items:{type:`string`},type:`array`},features:{additionalProperties:!1,properties:{assumeYes:{type:`boolean`},cacheBypass:{type:`boolean`},cacheRefresh:{type:`boolean`},channels:{items:{type:`string`},type:`array`},colorModes:{items:{type:`string`},type:`array`},dryRun:{type:`boolean`},execInstallPolicies:{items:{type:`string`},type:`array`},freshnessMetadata:{type:`boolean`},idempotencyKey:{type:`boolean`},logLevels:{items:{type:`string`},type:`array`},quietLogs:{type:`boolean`},selfUpgrade:{type:`boolean`},timeout:{type:`boolean`}},required:[`assumeYes`,`cacheBypass`,`cacheRefresh`,`channels`,`colorModes`,`dryRun`,`execInstallPolicies`,`freshnessMetadata`,`idempotencyKey`,`logLevels`,`quietLogs`,`selfUpgrade`,`timeout`],type:`object`},installers:{type:`object`},outputModes:{items:{type:`string`},type:`array`},platform:{additionalProperties:!1,properties:{arch:{type:`string`},os:{type:`string`}},required:[`arch`,`os`],type:`object`}},required:[`agents`,`features`,`installers`,`outputModes`,`platform`],type:`object`},description:`Environment and surface capabilities`,envelopeSchema:i,name:`capabilities`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{flags:{items:{type:`string`},type:`array`},name:{type:`string`},outputSchemaRef:{type:`string`},stability:{type:`string`},summary:{type:`string`}},required:[`flags`,`name`,`outputSchemaRef`,`stability`,`summary`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Stable command catalog`,envelopeSchema:i,name:`commands`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agents:{items:{additionalProperties:!1,properties:{displayName:{type:`string`},installedVersion:{type:`string`},latestVersion:{type:`string`},lifecycle:{type:`string`},outdated:{type:`boolean`},sourceLabel:{type:`string`}},required:[`displayName`,`lifecycle`,`outdated`,`sourceLabel`],type:`object`},type:`array`},installers:{additionalProperties:!1,properties:{brew:{type:`boolean`},bun:{type:`boolean`},npm:{type:`boolean`},winget:{type:`boolean`}},required:[`brew`,`bun`,`npm`,`winget`],type:`object`},issues:{items:{additionalProperties:!1,properties:{blocking:{type:`boolean`},category:{type:`string`},code:{type:`string`},docsRef:{type:`string`},message:{type:`string`},severity:{type:`string`},subject:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},suggestedAction:{type:`string`},suggestedCommands:{items:{type:`string`},type:`array`}},required:[`blocking`,`category`,`code`,`message`,`severity`,`subject`,`suggestedAction`,`suggestedCommands`],type:`object`},type:`array`},self:{additionalProperties:!1,properties:{canAutoUpdate:{type:`boolean`},currentVersion:{type:`string`},installSource:{type:`string`},latestVersion:{type:`string`},outdated:{type:`boolean`},recoveryHint:{type:`string`}},required:[`canAutoUpdate`,`currentVersion`,`installSource`,`outdated`],type:`object`}},required:[`agents`,`installers`,`issues`,`self`],type:`object`},description:`Diagnostic state and remediation guidance for the current environment`,envelopeSchema:i,name:`doctor`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agent:{additionalProperties:!1,properties:{binaryName:{type:`string`},displayName:{type:`string`},name:{type:`string`}},required:[`name`],type:`object`},execution:{additionalProperties:!1,properties:{args:{items:{type:`string`},type:`array`},installGuidance:{additionalProperties:!1,properties:{docsRef:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},suggestedAction:{type:`string`},suggestedEnsureCommand:{type:`string`},suggestedExecCommand:{type:`string`}},required:[`docsRef`,`installMethods`,`suggestedAction`,`suggestedEnsureCommand`,`suggestedExecCommand`],type:`object`},installPolicy:{type:`string`},installed:{type:`boolean`},interactive:{type:`boolean`},launched:{type:`boolean`}},required:[`args`,`installPolicy`,`installed`,`interactive`,`launched`],type:`object`}},required:[`agent`,`execution`],type:`object`},description:`Preflight contract for managed agent execution`,envelopeSchema:i,name:`exec`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},installState:{type:`object`},installed:{type:`boolean`}},required:[`agent`,`changed`,`installed`],type:`object`},description:`Ensure result for an agent`,envelopeSchema:i,name:`ensure`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},capabilities:{type:`object`},inspection:{type:`object`}},required:[`agent`,`capabilities`,`inspection`],type:`object`},description:`Structured inspection result for an agent`,envelopeSchema:i,name:`inspect`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},resolution:{additionalProperties:!1,properties:{binaryPath:{type:`string`},installGuidance:{additionalProperties:!1,properties:{docsRef:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},suggestedAction:{type:`string`},suggestedEnsureCommand:{type:`string`}},required:[`docsRef`,`installMethods`,`suggestedAction`,`suggestedEnsureCommand`],type:`object`},installed:{type:`boolean`},installSource:{type:`string`},installedVersion:{type:`string`},lifecycle:{type:`string`},sourceLabel:{type:`string`},suggestedLaunchCommand:{items:{type:`string`},type:`array`}},required:[`binaryPath`,`installed`,`installSource`,`lifecycle`,`sourceLabel`,`suggestedLaunchCommand`],type:`object`}},required:[`agent`,`resolution`],type:`object`},description:`Resolved executable entrypoint for an agent`,envelopeSchema:i,name:`resolve`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{dataSchema:{type:`object`},description:{type:`string`},envelopeSchema:{type:`object`},name:{type:`string`},ndjsonEventSchema:{type:`object`}},required:[`dataSchema`,`description`,`envelopeSchema`,`name`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Structured schema catalog`,envelopeSchema:i,name:`schema`,ndjsonEventSchema:a}];async function s(r){let i=r?o.filter(e=>e.name===r):o;return r&&i.length===0?e(t({action:`schema`,error:{code:`INVALID_ARGUMENT`,details:{command:r},message:`Unknown schema target: ${r}`},target:{kind:`system`,name:`schema`}}),c):e(n({action:`schema`,data:{commands:i},target:{kind:`system`,name:`schema`}}),c)}function c(e){if(e.error){console.log(r.red(e.error.message));return}if(e.data){console.log(r.bold(`
2
+ Quantex Schemas
3
+ `));for(let t of e.data.commands)console.log(` ${r.cyan(t.name)}`),console.log(` ${t.description}`);console.log()}}function l(){return o}export{s as n,l as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./schema-Ckf19SIa.mjs";export{e as schemaCommand};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./agents-BPMc1vIb.mjs";import{L as n,a as r,k as i,n as a,r as o,t as s}from"./color-CbC8zjc1.mjs";import{t as c}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as l,i as u,n as d,r as f}from"./user-output-DYsOPwi1.mjs";async function p(s){let l=t(s);if(!l)return r(a({action:`uninstall`,error:{code:`AGENT_NOT_FOUND`,details:{input:s},message:`Unknown agent: ${s}`},target:{kind:`agent`,name:s}}),m);if(d())return await i(l.name)?r(o({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},target:{kind:`agent`,name:l.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would uninstall ${l.displayName}.`}]}),m):r(a({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},error:{code:`UNINSTALL_FAILED`,message:`Failed to uninstall ${l.displayName}.`},target:{kind:`agent`,name:l.name}}),m);let u;try{u=await e(l)}catch(e){if(n(e))return r(a({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},...c(e,{kind:`agent`,name:l.name})}),m);throw e}return r(u?o({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!0},target:{kind:`agent`,name:l.name}}):a({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},error:{code:`UNINSTALL_FAILED`,message:`Failed to uninstall ${l.displayName}.`},target:{kind:`agent`,name:l.name}}),m)}function m(e){if(e.error){f(s.red(e.error.message));return}if(e.data){if(e.warnings&&e.warnings.length>0){for(let t of e.warnings)l(s.yellow(t.message));return}u(s.cyan(`Uninstalling ${e.data.agent.displayName}...`)),u(s.green(`${e.data.agent.displayName} uninstalled successfully!`))}}export{p as uninstallCommand};
1
+ import{c as e,n as t}from"./agents-bx8y3kRS.mjs";import{L as n,a as r,k as i,n as a,r as o,t as s}from"./color-BbKp9aSG.mjs";import{t as c}from"./lifecycle-errors-D7JpbOsK.mjs";import{a as l,i as u,n as d,r as f}from"./user-output-DFxUPA-p.mjs";async function p(s){let l=t(s);if(!l)return r(a({action:`uninstall`,error:{code:`AGENT_NOT_FOUND`,details:{input:s},message:`Unknown agent: ${s}`},target:{kind:`agent`,name:s}}),m);if(d())return await i(l.name)?r(o({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},target:{kind:`agent`,name:l.name},warnings:[{code:`DRY_RUN`,message:`Dry run: would uninstall ${l.displayName}.`}]}),m):r(a({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},error:{code:`UNINSTALL_FAILED`,message:`Failed to uninstall ${l.displayName}.`},target:{kind:`agent`,name:l.name}}),m);let u;try{u=await e(l)}catch(e){if(n(e))return r(a({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},...c(e,{kind:`agent`,name:l.name})}),m);throw e}return r(u?o({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!0},target:{kind:`agent`,name:l.name}}):a({action:`uninstall`,data:{agent:{displayName:l.displayName,name:l.name},changed:!1},error:{code:`UNINSTALL_FAILED`,message:`Failed to uninstall ${l.displayName}.`},target:{kind:`agent`,name:l.name}}),m)}function m(e){if(e.error){f(s.red(e.error.message));return}if(e.data){if(e.warnings&&e.warnings.length>0){for(let t of e.warnings)l(s.yellow(t.message));return}u(s.cyan(`Uninstalling ${e.data.agent.displayName}...`)),u(s.green(`${e.data.agent.displayName} uninstalled successfully!`))}}export{p as uninstallCommand};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./messages-DMxGs5hh.mjs";import{S as n,g as r,l as i,m as a,n as o,u as s}from"./agents-bx8y3kRS.mjs";import{L as c,a as l,i as u,n as d,r as f,t as p}from"./color-BbKp9aSG.mjs";import{a as m,i as h,n as g,r as _}from"./user-output-DFxUPA-p.mjs";import{n as v,r as y}from"./update-DHOTks91.mjs";async function b(e,t){if(t)return x();if(!e)return l(d({action:`update`,error:{code:`INVALID_ARGUMENT`,message:`Please specify an agent name or use --all flag`},target:{kind:`agent`}}),O);let n=o(e);return n?S(n):l(d({action:`update`,error:{code:`AGENT_NOT_FOUND`,details:{input:e},message:`Unknown agent: ${e}`},target:{kind:`agent`,name:e}}),O)}async function x(){u({action:`update`,data:{scope:`all`},target:{kind:`agent`},type:`started`});let e=await C(await v());return e.hasFailures?l(d({action:`update`,data:{results:e.results,scope:`all`},error:{code:`UPDATE_FAILED`,message:`One or more agents failed to update.`},target:{kind:`agent`}}),O):l(f({action:`update`,data:{results:e.results,scope:`all`},target:{kind:`agent`}}),O)}async function S(e){u({action:`update`,data:{agent:e.name,scope:`single`},target:{kind:`agent`,name:e.name},type:`started`});let{inspection:t,plan:n}=await y(e);if(!t.inPath)return l(d({action:`update`,error:{code:`AGENT_NOT_INSTALLED`,message:`${e.displayName} is not installed.`},target:{kind:`agent`,name:e.name}}),O);let r=await C(n),i=D(r.results);return i?l(d({action:`update`,data:{results:r.results,scope:`single`},error:{code:`RESOURCE_LOCKED`,details:i.resource?{resource:i.resource}:void 0,message:i.message??`Another quantex process is already updating ${e.displayName}.`},target:{kind:`agent`,name:e.name}}),O):r.hasFailures?l(d({action:`update`,data:{results:r.results,scope:`single`},error:{code:`UPDATE_FAILED`,message:`Failed to update ${e.displayName}.`},target:{kind:`agent`,name:e.name}}),O):l(f({action:`update`,data:{results:r.results,scope:`single`},target:{kind:`agent`,name:e.name}}),O)}async function C(t){let n=[];for(let e of t.upToDate)w(n,{displayName:e.agent.displayName,installedVersion:e.installedVersion,latestVersion:e.latestVersion,name:e.agent.name,status:`up-to-date`});for(let r of t.skippedManualCheck)w(n,{displayName:r.agent.displayName,message:e(r.agent),name:r.agent.name,status:`manual-required`});for(let e of t.grouped){let t=await T(e.type,e.packages,e.updates);for(let e of t)w(n,e)}for(let e of t.manual)w(n,await E(e.agent,e.state,e.inspection.methods,e.inspection));return{hasFailures:n.some(e=>e.status===`failed`||e.status===`locked`),results:n}}function w(e,t){e.push(t),u({action:`update`,data:t,target:{kind:`agent`,name:t.name},type:`progress`})}async function T(e,t,n){if(n.length===0)return[];if(g())return n.map(({agent:t,inspection:n,strategy:r})=>({displayName:t.displayName,installedVersion:n.installedVersion,latestVersion:n.latestVersion,message:`Dry run: would update ${t.displayName}.`,name:t.name,status:`planned`,strategy:r===`managed`?`managed/${e}`:r}));try{return await s(e,t)?n.map(({agent:t,inspection:n,strategy:r})=>({displayName:t.displayName,installedVersion:n.installedVersion,latestVersion:n.latestVersion,name:t.name,status:`updated`,strategy:r===`managed`?`managed/${e}`:r})):await Promise.all(n.map(({agent:e,inspection:t,state:n})=>E(e,n,t.methods,t)))}catch(t){if(!c(t))throw t;return n.map(({agent:n,inspection:r,strategy:i})=>({displayName:n.displayName,installedVersion:r.installedVersion,latestVersion:r.latestVersion,message:t.message,name:n.name,resource:t.resource,status:`locked`,strategy:i===`managed`?`managed/${e}`:i}))}}async function E(o,s,l,u){let d=l??u?.methods??[],f=a({agent:o,installedState:s,methods:d}),p=u?.installedVersion,m=u?.latestVersion;if(f===`manual-hint`&&!r(o,s)&&!d.some(e=>n(e.type)))return{displayName:o.displayName,installedVersion:p,latestVersion:m,message:e(o),name:o.name,status:`manual-required`,strategy:f};if(g())return{displayName:o.displayName,installedVersion:p,latestVersion:m,message:`Dry run: would update ${o.displayName}.`,name:o.name,status:`planned`,strategy:f};let h;try{h=await i(o,s)}catch(e){if(c(e))return{displayName:o.displayName,installedVersion:p,latestVersion:m,message:e.message,name:o.name,resource:e.resource,status:`locked`,strategy:f};throw e}return h.success?{displayName:o.displayName,installedVersion:p,latestVersion:m,name:o.name,status:`updated`,strategy:f}:{displayName:o.displayName,hint:t(o,f),installedVersion:p,latestVersion:m,name:o.name,status:`failed`,strategy:f}}function D(e){if(e.length===1)return e[0]?.status===`locked`?e[0]:void 0}function O(e){if(!e.data){e.error&&_(p.red(e.error.message));return}for(let t of e.data.results)switch(t.status){case`up-to-date`:h(p.green(`${t.displayName} is up to date (${t.installedVersion??`unknown`})`));break;case`manual-required`:m(p.yellow(`${t.displayName}: manual action required.`)),t.message&&m(p.cyan(`Next step: ${t.message}`));break;case`planned`:m(p.cyan(`Would update ${t.displayName}${t.strategy?` via ${t.strategy}`:``}${k(t.installedVersion,t.latestVersion)}`));break;case`updated`:h(p.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${k(t.installedVersion,t.latestVersion)}`)),h(p.green(`${t.displayName} updated successfully!`));break;case`failed`:h(p.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${k(t.installedVersion,t.latestVersion)}`)),_(p.red(`Failed to update ${t.displayName}.`)),t.hint&&m(p.cyan(`Next step: ${t.hint}`));break;case`locked`:m(p.yellow(t.message??`Another quantex process is already updating ${t.displayName}.`));break}e.data.results.length>1&&A(e.data.results),!e.data.results.length&&e.error&&_(p.red(e.error.message))}function k(e,t){return e?` (${e} -> ${t??`latest`})`:``}function A(e){let t={failed:0,locked:0,manualRequired:0,planned:0,upToDate:0,updated:0};for(let n of e)switch(n.status){case`up-to-date`:t.upToDate+=1;break;case`manual-required`:t.manualRequired+=1;break;case`planned`:t.planned+=1;break;case`updated`:t.updated+=1;break;case`failed`:t.failed+=1;break;case`locked`:t.locked+=1;break}let n=[t.updated?`updated ${t.updated}`:void 0,t.upToDate?`up to date ${t.upToDate}`:void 0,t.manualRequired?`manual ${t.manualRequired}`:void 0,t.failed?`failed ${t.failed}`:void 0,t.locked?`locked ${t.locked}`:void 0,t.planned?`planned ${t.planned}`:void 0].filter(Boolean);n.length>0&&h(p.bold(`Summary: ${n.join(`, `)}`))}export{b as updateCommand};
@@ -0,0 +1 @@
1
+ import{g as e,h as t,i as n,t as r,y as i}from"./agents-bx8y3kRS.mjs";function a(e){let n={bun:[],npm:[],brew:[],winget:[]},r=[],i=[],a=[];for(let c of e){if(!c.inPath)continue;if(s(c)){i.push(c);continue}if(!o(c)){a.push(c);continue}let e=t({agent:c.agent,installedState:c.installedState,methods:c.methods}),l=e.strategy===`managed`?e.getManagedInstallerType?.({agent:c.agent,installedState:c.installedState,methods:c.methods}):void 0;if(l){let e={inspection:c,installerType:l,strategy:`grouped`};n[l].push(e);continue}r.push({inspection:c,strategy:e.strategy===`self-update`?`self-update`:`manual`})}return{entries:[...n.bun,...n.npm,...n.brew,...n.winget,...r],grouped:n,manual:r,skippedManualCheck:i,upToDate:a}}function o(e){return e.installedVersion&&e.latestVersion?e.installedVersion!==e.latestVersion:!0}function s(t){return!t.latestVersion&&!e(t.agent,t.installedState)}const c=[`bun`,`npm`,`brew`,`winget`];async function l(e){let t=await n(e);return{agent:e,inspection:t,updateAvailable:o(t)}}async function u(){return f(await r())}async function d(e){let t=await n(e);return{inspection:t,plan:f([t])}}function f(e){let t=a(e),n=c.map(e=>p(e,t.grouped[e])).filter(e=>e!==void 0);return{entries:t.entries.map(e=>m(e.inspection)),grouped:n,manual:t.manual.map(e=>m(e.inspection)),skippedManualCheck:t.skippedManualCheck,upToDate:t.upToDate}}function p(e,t){if(t.length===0)return;let n=t.map(e=>m(e.inspection));return{type:e,packages:n.flatMap(e=>e.package?.packageName?[e.package]:[]),updates:n}}function m(e){let n=t({agent:e.agent,installedState:e.installedState,methods:e.methods}),r=n.getManagedInstallerType?.({agent:e.agent,installedState:e.installedState,methods:e.methods});return{agent:e.agent,inspection:e,installerType:r,package:r?h(e.agent,e.installedState,e.methods,r):void 0,state:e.installedState,strategy:n.strategy}}function h(e,t,n,r){if(t?.packageName&&t.installType===r)return{packageName:t.packageName,packageTargetKind:t.packageTargetKind};let a=n.find(e=>e.type===r);if(!a)return;let o=i(e,a);if(o)return{packageName:o,packageTargetKind:a.packageTargetKind}}export{o as a,a as i,u as n,d as r,l as t};
@@ -1 +1 @@
1
- import{a as e,d as t,n,p as r,r as i,t as a,u as o}from"./color-CbC8zjc1.mjs";import{a as s,i as c,n as l,r as u}from"./user-output-DYsOPwi1.mjs";async function d(a={}){let s=await o({updateChannel:a.channel}),c=l();if(s.latestVersion&&s.latestVersion===s.currentVersion)return e(i({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,status:`up-to-date`},target:{kind:`self`,name:`quantex`}}),f);if(a.check||c)return s.latestVersion?e(i({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,status:`update-available`},exitCode:a.check?1:void 0,target:{kind:`self`,name:`quantex`},warnings:c?[{code:`DRY_RUN`,message:`Dry run: would upgrade Quantex CLI.`}]:[]}),f):e(n({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,status:`check-unavailable`},error:{code:`NETWORK_ERROR`,message:`Unable to determine the latest Quantex CLI version.`},target:{kind:`self`,name:`quantex`}}),f);if(!s.canAutoUpdate){let t=r(s);return e(n({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,recoveryHint:t,status:`manual-required`},error:{code:`MANUAL_ACTION_REQUIRED`,message:`Quantex CLI cannot auto-update from the current install source: ${s.installSource}.`},target:{kind:`self`,name:`quantex`}}),f)}let u=await t(s);if(u.success)return e(i({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,status:`updated`},target:{kind:`self`,name:`quantex`}}),f);let d=r(s,u);return e(n({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,recoveryHint:d,status:`manual-required`},error:{code:`UPGRADE_FAILED`,details:u.error?.kind?{kind:u.error.kind}:void 0,message:u.error?.message??`Failed to upgrade Quantex CLI.`},target:{kind:`self`,name:`quantex`},warnings:d?[{code:`MANUAL_RECOVERY`,message:`Manual recovery: ${d}`}]:[]}),f)}function f(e){if(!e.data){e.error&&u(a.red(e.error.message));return}if(e.data.status===`up-to-date`){c(a.green(`Quantex CLI is already up to date (${e.data.currentVersion}).`));return}if(e.data.status===`update-available`){let t=e.warnings.some(e=>e.message.includes(`Dry run`))?`Dry run: `:``;s(a.yellow(`${t}Update available for Quantex CLI: ${e.data.currentVersion} -> ${e.data.latestVersion} (${e.data.channel}).`));return}if(e.data.status===`check-unavailable`){e.error&&s(a.yellow(e.error.message));return}if(e.data.status===`manual-required`&&e.error?.code===`MANUAL_ACTION_REQUIRED`){s(a.yellow(e.error.message)),e.data.recoveryHint&&s(a.cyan(`Manual upgrade: ${e.data.recoveryHint}`));return}let t=e.data.latestVersion?` (${e.data.currentVersion} -> ${e.data.latestVersion})`:` (${e.data.currentVersion})`;if(c(a.cyan(`Upgrading Quantex CLI...${t}`)),!e.error){c(a.green(`Quantex CLI upgraded successfully.`));return}u(a.red(`Failed to upgrade Quantex CLI.`)),s(a.yellow(`Reason: ${e.error.message}`));for(let t of e.warnings)s(a.cyan(t.message))}export{d as upgradeCommand};
1
+ import{a as e,d as t,n,p as r,r as i,t as a,u as o}from"./color-BbKp9aSG.mjs";import{a as s,i as c,n as l,r as u}from"./user-output-DFxUPA-p.mjs";async function d(a={}){let s=await o({updateChannel:a.channel}),c=l();if(s.latestVersion&&s.latestVersion===s.currentVersion)return e(i({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,status:`up-to-date`},target:{kind:`self`,name:`quantex`}}),f);if(a.check||c)return s.latestVersion?e(i({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,status:`update-available`},exitCode:a.check?1:void 0,target:{kind:`self`,name:`quantex`},warnings:c?[{code:`DRY_RUN`,message:`Dry run: would upgrade Quantex CLI.`}]:[]}),f):e(n({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,status:`check-unavailable`},error:{code:`NETWORK_ERROR`,message:`Unable to determine the latest Quantex CLI version.`},target:{kind:`self`,name:`quantex`}}),f);if(!s.canAutoUpdate){let t=r(s);return e(n({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,recoveryHint:t,status:`manual-required`},error:{code:`MANUAL_ACTION_REQUIRED`,message:`Quantex CLI cannot auto-update from the current install source: ${s.installSource}.`},target:{kind:`self`,name:`quantex`}}),f)}let u=await t(s);if(u.success)return e(i({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,status:`updated`},target:{kind:`self`,name:`quantex`}}),f);let d=r(s,u);return e(n({action:`upgrade`,data:{canAutoUpdate:s.canAutoUpdate,channel:s.updateChannel,currentVersion:s.currentVersion,installSource:s.installSource,latestVersion:s.latestVersion,recoveryHint:d,status:`manual-required`},error:{code:`UPGRADE_FAILED`,details:u.error?.kind?{kind:u.error.kind}:void 0,message:u.error?.message??`Failed to upgrade Quantex CLI.`},target:{kind:`self`,name:`quantex`},warnings:d?[{code:`MANUAL_RECOVERY`,message:`Manual recovery: ${d}`}]:[]}),f)}function f(e){if(!e.data){e.error&&u(a.red(e.error.message));return}if(e.data.status===`up-to-date`){c(a.green(`Quantex CLI is already up to date (${e.data.currentVersion}).`));return}if(e.data.status===`update-available`){let t=e.warnings.some(e=>e.message.includes(`Dry run`))?`Dry run: `:``;s(a.yellow(`${t}Update available for Quantex CLI: ${e.data.currentVersion} -> ${e.data.latestVersion} (${e.data.channel}).`));return}if(e.data.status===`check-unavailable`){e.error&&s(a.yellow(e.error.message));return}if(e.data.status===`manual-required`&&e.error?.code===`MANUAL_ACTION_REQUIRED`){s(a.yellow(e.error.message)),e.data.recoveryHint&&s(a.cyan(`Next step: ${e.data.recoveryHint}`));return}let t=e.data.latestVersion?` (${e.data.currentVersion} -> ${e.data.latestVersion})`:` (${e.data.currentVersion})`;if(c(a.cyan(`Upgrading Quantex CLI...${t}`)),!e.error){c(a.green(`Quantex CLI upgraded successfully.`));return}u(a.red(`Failed to upgrade Quantex CLI.`)),s(a.yellow(`Reason: ${e.error.message}`));for(let t of e.warnings)s(a.cyan(t.message.replace(/^Manual recovery:/,`Next step:`)))}export{d as upgradeCommand};
@@ -1 +1 @@
1
- import{K as e}from"./color-CbC8zjc1.mjs";import t from"node:process";const n={debug:4,error:1,info:3,silent:0,warn:2};function r(e){o(`info`)&&t.stdout.write(`${e}\n`)}function i(e){o(`warn`)&&t.stdout.write(`${e}\n`)}function a(e){o(`error`)&&t.stdout.write(`${e}\n`)}function o(t){let r=e();return r.outputMode===`human`?r.quiet&&t===`info`?!1:n[r.logLevel??`info`]>=n[t]:!0}function s(){return!!e().assumeYes}function c(){return!!e().dryRun}function l(e){t.stdout.write(`${e}\n`)}export{i as a,r as i,c as n,l as o,a as r,s as t};
1
+ import{q as e}from"./color-BbKp9aSG.mjs";import t from"node:process";const n={debug:4,error:1,info:3,silent:0,warn:2};function r(e){o(`info`)&&t.stdout.write(`${e}\n`)}function i(e){o(`warn`)&&t.stdout.write(`${e}\n`)}function a(e){o(`error`)&&t.stdout.write(`${e}\n`)}function o(t){let r=e();return r.outputMode===`human`?r.quiet&&t===`info`?!1:n[r.logLevel??`info`]>=n[t]:!0}function s(){return!!e().assumeYes}function c(){return!!e().dryRun}function l(e){t.stdout.write(`${e}\n`)}export{i as a,r as i,c as n,l as o,a as r,s as t};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quantex-cli",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "packageManager": "bun@1.3.11",
6
6
  "description": "统一的 AI Agent CLI 管理工具,支持安装、更新、卸载、查询、快捷启动主流 AI 编程助手",
7
7
  "author": "Drswith <drswith@outlook.com>",
@@ -33,12 +33,16 @@
33
33
  "prebuild": "bun run scripts/write-build-metadata.ts",
34
34
  "build": "tsdown",
35
35
  "build:bin": "bun run scripts/write-build-metadata.ts && bun run scripts/build-bin.ts",
36
+ "adr:new": "bun run scripts/new-adr.ts",
37
+ "memory:check": "bun run scripts/check-project-memory.ts",
36
38
  "lint:fix": "eslint --fix",
37
39
  "lint": "eslint",
38
40
  "prepublishOnly": "bun run build",
39
41
  "postinstall": "node scripts/postinstall.cjs",
40
- "release": "bumpp",
42
+ "release:ci": "semantic-release",
41
43
  "release:artifacts": "bun run scripts/write-release-checksums.ts && bun run scripts/generate-release-manifest.ts && bun run scripts/verify-release-artifacts.ts",
44
+ "release:smoke": "bun run scripts/verify-release-smoke.ts",
45
+ "task:new": "bun run scripts/new-task.ts",
42
46
  "dev": "bun run src/cli.ts",
43
47
  "test": "vitest run",
44
48
  "test:watch": "vitest",
@@ -53,12 +57,14 @@
53
57
  },
54
58
  "devDependencies": {
55
59
  "@antfu/eslint-config": "^6.6.1",
60
+ "@semantic-release/exec": "^7.1.0",
61
+ "@semantic-release/npm": "^13.1.5",
56
62
  "@types/bun": "^1.3.11",
57
63
  "@types/node": "^25.0.1",
58
64
  "@types/prompts": "^2.4.9",
59
- "bumpp": "^10.3.2",
60
65
  "eslint": "^9.39.2",
61
66
  "lint-staged": "^16.2.7",
67
+ "semantic-release": "^25.0.3",
62
68
  "simple-git-hooks": "^2.13.1",
63
69
  "tsdown": "^0.21.7",
64
70
  "typescript": "^5.9.3",
@@ -1 +0,0 @@
1
- import{t as e}from"./capabilities-CUyQejux.mjs";export{e as capabilitiesCommand};
@@ -1,4 +0,0 @@
1
- import{createHash as e,randomUUID as t}from"node:crypto";import n from"node:process";import{chmod as r,mkdir as i,mkdtemp as a,readFile as o,rename as s,rm as c,stat as l,writeFile as u}from"node:fs/promises";import{basename as d,dirname as f,join as p}from"node:path";import{fileURLToPath as m,pathToFileURL as h}from"node:url";import{homedir as g}from"node:os";import{loadConfig as ee}from"c12";import{Buffer as te}from"node:buffer";import{createColors as ne,isColorSupported as re}from"picocolors";function ie(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 _,v=new Set;function y(){return _??=ue(),_}function ae(e){v=new Set,_={...e,cacheMode:e.cacheMode??`default`,cancelled:e.cancelled??!1}}function oe(){_=void 0,v=new Set}function b(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:ie(e.timeout),c=de(e.color),l=fe(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 se(){_&&(_.cancelled=!0)}function ce(){se();for(let e of v)e();v.clear()}function x(e){return v.add(e),()=>{v.delete(e)}}function le(e){let t=y();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 ue(){return b()}function de(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 fe(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 pe={defaultPackageManager:`bun`,networkRetries:2,networkTimeoutMs:1e4,npmBunUpdateStrategy:`latest-major`,selfUpdateChannel:`stable`,versionCacheTtlHours:6};function S(){return p(n.env.HOME||n.env.USERPROFILE||g(),`.quantex`)}function C(){return p(S(),`config.json`)}async function w(){let{config:e}=await ee({name:`quantex`,defaults:pe,configFile:C(),jiti:{import:async(e,t)=>{if(e.endsWith(`.json`))return JSON.parse(await o(e,`utf8`));let n=await(e.startsWith(`file:`)?import(e):import(h(e).href));return t?.default?n.default??n:n}}}),t=e;return{...t,defaultPackageManager:t.defaultPackageManager===`npm`?`npm`:`bun`,networkRetries:T(t.networkRetries,2),networkTimeoutMs:T(t.networkTimeoutMs,1e4),npmBunUpdateStrategy:t.npmBunUpdateStrategy===`respect-semver`?`respect-semver`:`latest-major`,selfUpdateChannel:t.selfUpdateChannel===`beta`?`beta`:`stable`,versionCacheTtlHours:T(t.versionCacheTtlHours,6)}}function me(e){return e===`latest-major`||e===`respect-semver`}async function he(e){await i(S(),{recursive:!0}),await Bun.write(C(),`${JSON.stringify(e,null,2)}\n`)}function T(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}const E=`quantex-cli`,D=`https://github.com/Drswith/quantex-cli`,ge=`0.1.1`;var _e=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 O(e){return e instanceof _e}function ve(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 p(S(),`locks`,...r,i)}async function k(e){let t=ve(e.scope);await i(f(t),{recursive:!0});try{await i(t,{recursive:!1})}catch(n){throw typeof n==`object`&&n&&`code`in n&&n.code===`EEXIST`?new _e(e.resource,t):n}return async()=>{await c(t,{force:!0,recursive:!0})}}async function ye(e,t){let n=await k(e);try{return await t()}finally{await n()}}const be={installedAgents:{},self:{}};function A(){return p(S(),`state.json`)}async function j(){return P()}async function xe(e){let t=await k({resource:`state`,scope:[`state`]});try{await F(e)}finally{await t()}}async function Se(e){return(await j()).installedAgents[e]}async function Ce(e){await I(t=>{t.installedAgents[e.agentName]=e})}async function we(e){await I(t=>{delete t.installedAgents[e]})}async function M(){return(await j()).self}async function N(e){await I(t=>{t.self.installSource=e})}async function P(){try{let e=await Bun.file(A()).json();return{installedAgents:e.installedAgents??{},self:e.self??{}}}catch{return{...be}}}async function F(e){await i(S(),{recursive:!0}),await Bun.write(A(),`${JSON.stringify(e,null,2)}\n`)}async function I(e){let t=await k({resource:`state`,scope:[`state`]});try{let t=await P();await e(t),await F(t)}finally{await t()}}async function L(e,t){let n=await Te(e,t,`json`);if(n)try{return JSON.parse(n)}catch{return}}async function Te(e,t,n=`text`){let r=await w(),i=r.versionCacheTtlHours*60*60*1e3,a=y().cacheMode,o=a===`no-cache`?{entries:{}}:await De(),s=o.entries[t],c=Date.now();if(a===`default`&&s&&s.expiresAt>c)return B(s,i),s.body;let l=await Ee(e,{headers:a!==`no-cache`&&s?.etag?{"If-None-Match":s.etag}:void 0,retries:r.networkRetries,timeoutMs:r.networkTimeoutMs});if(!l)return s&&B(s,i),s?.body;if(l.status===304&&s)return o.entries[t]={...s,expiresAt:c+i,fetchedAt:c},a!==`no-cache`&&await R(o),Oe(c,c+i),s.body;if(!l.ok)return s&&B(s,i),s?.body;let u=await l.text();if(n===`json`)try{JSON.parse(u)}catch{return s&&B(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 R(o)),Oe(c,c+i),u}async function Ee(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 De(){try{return JSON.parse(await o(z(),`utf8`))}catch{return{entries:{}}}}async function R(e){await i(p(S(),`cache`),{recursive:!0}),await u(z(),`${JSON.stringify(e,null,2)}\n`,`utf8`)}function z(){return p(S(),`cache`,`versions.json`)}function B(e,t){let n=e.fetchedAt??Math.max(0,e.expiresAt-t);le({fetchedAt:new Date(n).toISOString(),source:`cache`,staleAfter:new Date(e.expiresAt).toISOString()})}function Oe(e,t){le({fetchedAt:new Date(e).toISOString(),source:`network`,staleAfter:new Date(t).toISOString()})}const ke=/v?(\d+\.\d+\.\d+(?:-[a-z0-9.]+)?)/i;function Ae(e,t){if(t)return t(e);let n=e.trim().split(`
2
- `)[0],r=n.match(ke);return r?r[1]:n||void 0}async function je(e,t){let n=t?.command??[e,`--version`];try{let e=Bun.spawn(n,{stdout:`pipe`,stderr:`pipe`});return await e.exited,e.exitCode===0?Ae(await new Response(e.stdout).text(),t?.parser):void 0}catch{return}}async function Me(e,t=`latest`){try{return(await L(`https://registry.npmjs.org/${e}/${t}`,`npm:${e}:${t}`))?.version}catch{return}}async function Ne(e){try{let t=n.platform===`win32`?`where`:`which`,r=Bun.spawn([t,e],{stdout:`pipe`,stderr:`pipe`});return await r.exited,r.exitCode===0?(await new Response(r.stdout).text()).trim().split(`
3
- `)[0]:void 0}catch{return}}async function Pe(){try{return await k({resource:`self upgrade`,scope:[`self-upgrade`]})}catch(e){if(O(e))return;throw e}}async function Fe(e,t,i,o){let l;try{l=await fetch(e)}catch(t){return H(`network`,`Failed to download ${e}.`,t)}if(!l.ok)return H(`network`,`Failed to download ${e}: HTTP ${l.status}.`);let m=await a(p(f(t),`.quantex-upgrade-`)),h=p(m,d(t)),g=`${t}.bak`;try{let a=te.from(await l.arrayBuffer()),d=await Ie(t),f=He(a);if(f!==U(i))return H(`checksum`,`Checksum mismatch for ${e}. Expected ${U(i)}, got ${f}.`);if(await u(h,a),n.platform===`win32`)return Le(h,t,g,m,o);await r(h,d),await c(g,{force:!0}),await s(t,g),await s(h,t);let p=await Ve(t,o);return p.success?(await c(g,{force:!0}),{success:!0}):(await Be(g,t),p)}catch(e){return H(ze(e),`Failed to replace the current Quantex binary.`,e)}finally{n.platform!==`win32`&&await c(m,{recursive:!0,force:!0})}}async function Ie(e){try{return(await l(e)).mode&511}catch{return 493}}function Le(e,t,r,i,a){try{let o=Re(e,t,r,i,n.pid,a);return Bun.spawn([`powershell.exe`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-WindowStyle`,`Hidden`,`-Command`,o],{stdio:[`ignore`,`ignore`,`ignore`],windowsHide:!0}).unref?.(),{success:!0}}catch(e){return H(`locked`,`Failed to schedule Windows binary replacement.`,e)}}function Re(e,t,n,r,i,a){let o=V(e),s=V(t),c=V(n),l=V(r),u=V(a??``);return[`$pidToWait = ${i}`,`$tempPath = '${o}'`,`$targetPath = '${s}'`,`$backupPath = '${c}'`,`$tempDir = '${l}'`,`$expectedVersion = '${u}'`,`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`,` }`,`}`,`Remove-Item -LiteralPath $backupPath -Force -ErrorAction SilentlyContinue`,`Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`].join(`; `)}function V(e){return e.replaceAll(`'`,`''`)}function H(e,t,n){return{error:{detail:n,kind:e,message:t},success:!1}}function ze(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 Be(e,t){await c(t,{force:!0}),await s(e,t)}async function Ve(e,t){if(!t)return{success:!0};try{let n=Bun.spawn([e,`--version`],{stdio:[`ignore`,`pipe`,`ignore`]}),r=n.stdout?await new Response(n.stdout).text():``,i=await n.exited;return i===0?r.includes(t)?{success:!0}:H(`verify`,`The upgraded Quantex binary reported an unexpected version during verification.`):H(`verify`,`The upgraded Quantex binary exited with code ${i} during verification.`)}catch(e){return H(`verify`,`Failed to execute the upgraded Quantex binary for verification.`,e)}}function He(t){return e(`sha256`).update(t).digest(`hex`)}function U(e){return e.trim().toLowerCase()}function Ue(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function W(e=n.execPath){if(d(Ue(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 G(e=n.execPath){let t=W(e);if(t)return`${D}/releases/latest/download/${t}`}function We(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 Ge(e){let t=await L(await Ke(e),`self:manifest:${e}`);if(!t)throw Error(`Failed to download release manifest.`);return t}async function Ke(e){if(e===`stable`)return`${D}/releases/latest/download/manifest.json`;let t=(await qe(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 qe(e){let t=Ye();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 Je(e,t=n.execPath){let r=n.platform,i=n.arch===`arm64`?`arm64`:`x64`,a=W(t);return e.assets.find(e=>e.platform===r&&e.arch===i&&(!a||e.name===a))}function Ye(){return D.match(/github\.com\/([^/]+\/[^/]+)$/)?.[1]}const Xe={source:`binary`,canHandle:e=>e.installSource===`binary`,getRecoveryHint:(e,t)=>{let n=t?.error?.detail&&typeof t.error.detail==`object`&&`downloadUrl`in t.error.detail?String(t.error.detail.downloadUrl):G(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){if(!W(e.executablePath))return{error:{kind:`unsupported`,message:`No release artifact is available for the current platform and architecture.`},installSource:e.installSource,success:!1};let t;try{t=await Ge(e.updateChannel)}catch(t){return{error:{detail:t,kind:`network`,message:`Failed to resolve the ${e.updateChannel} release manifest.`},installSource:e.installSource,success:!1}}let n=Je(t,e.executablePath);if(!n)return{error:{detail:{channel:e.updateChannel},kind:`unsupported`,message:`No binary asset is available for the current platform on the ${e.updateChannel} channel.`},installSource:e.installSource,success:!1};let r=await Fe(n.downloadUrl,e.executablePath,n.checksum,t.version);return{...!r.success&&r.error?{...r,error:{...r.error,detail:{...typeof r.error.detail==`object`&&r.error.detail?r.error.detail:{},downloadUrl:n.downloadUrl}}}:r,installSource:e.installSource,newVersion:r.success?t.version:void 0}}};function K(e,t={}){if(y().outputMode===`human`){let n=Bun.spawn(e,{...t,stdio:[`inherit`,`inherit`,`inherit`]});return{cleanup:x(()=>n.kill?.(`SIGTERM`)),outputDrained:Promise.resolve(),proc:n}}let n=Bun.spawn(e,{...t,stdio:[`ignore`,`pipe`,`pipe`]});return{cleanup:x(()=>n.kill?.(`SIGTERM`)),outputDrained:Promise.all([Ze(n.stdout),Ze(n.stderr)]).then(()=>{}),proc:n}}async function q(e){try{return await e.proc.exited,await e.outputDrained,e.proc.exitCode??1}finally{e.cleanup()}}async function Ze(e){if(!e)return;let t=await new Response(e).text();t&&n.stderr.write(t)}async function Qe(e){try{return await J([`bun`,`add`,`-g`,e],[e])}catch{return!1}}async function $e(e,t=`latest-major`,n=`latest`){try{let r=n===`latest`?e:`${e}@${n}`;return await J([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],r],[e])}catch{return!1}}async function et(e,t=`latest-major`){if(e.length===0)return!0;try{return await J([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],...e],e)}catch{return!1}}async function tt(e){try{return await q(K([`bun`,`remove`,`-g`,e]))===0}catch{return!1}}async function J(e,t){return await q(K(e))===0?nt(t):!1}async function nt(e){let t=[...new Set(e)];if(t.length===0)return!0;let n=await rt();if(!n)return!0;let r=it(n),i=t.filter(e=>r.has(e));return i.length===0?!0:await q(K([`bun`,`pm`,`-g`,`trust`,...i]))===0}async function rt(){try{let e=Bun.spawn([`bun`,`pm`,`-g`,`untrusted`],{stdio:at()}),t=await new Response(e.stdout).text();return await e.exited,e.exitCode===0?t:void 0}catch{return}}function it(e){let t=new Set;for(let n of e.split(`
4
- `)){let e=n.match(/^\.\/node_modules\/(.+?) @/);e?.[1]&&t.add(e[1])}return t}function at(){return[`ignore`,`pipe`,`ignore`]}const ot={source:`bun`,canHandle:e=>e.installSource===`bun`,getRecoveryHint:e=>`bun add -g ${E}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await $e(E,`latest-major`,e.updateChannel===`beta`?`beta`:`latest`);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${E} through Bun.`},installSource:e.installSource,newVersion:t?e.latestVersion:void 0,success:t}}};async function st(e){try{return await q(K([`npm`,`i`,`-g`,e]))===0}catch{return!1}}async function ct(e,t=`latest-major`,n=`latest`){try{return await q(K(t===`latest-major`?[`npm`,`install`,`-g`,`${e}@${n}`]:[`npm`,`update`,`-g`,e]))===0}catch{return!1}}async function lt(e,t=`latest-major`){if(e.length===0)return!0;try{return await q(K(t===`latest-major`?[`npm`,`install`,`-g`,...e.map(e=>`${e}@latest`)]:[`npm`,`update`,`-g`,...e]))===0}catch{return!1}}async function ut(e){try{return await q(K([`npm`,`uninstall`,`-g`,e]))===0}catch{return!1}}const dt={source:`npm`,canHandle:e=>e.installSource===`npm`,getRecoveryHint:e=>`npm install -g ${E}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await ct(E,`latest-major`,e.updateChannel===`beta`?`beta`:`latest`);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${E} through npm.`},installSource:e.installSource,newVersion:t?e.latestVersion:void 0,success:t}}},ft={source:`source`,canHandle:e=>e.installSource===`source`||e.installSource===`unknown`,getRecoveryHint:()=>void 0,async upgrade(e){return{error:{kind:`unsupported`,message:`Install source "${e.installSource}" does not support auto-update.`},installSource:e.installSource,success:!1}}},pt=[ot,dt,Xe,ft];function mt(e){return pt.find(t=>t.canHandle(e))??ft}function Y(e,t,n=`stable`,r){if(r?.error?.kind===`locked`)return`another qtx upgrade is already running; wait for it to finish and retry`;if(e===`bun`)return`bun add -g ${E}@${n===`beta`?`beta`:`latest`}`;if(e===`npm`)return`npm install -g ${E}@${n===`beta`?`beta`:`latest`}`;if(e===`binary`){let e=G(t);return e?r?.error?.kind===`permission`?`check write permission for the current binary path, or download and replace the binary from ${e}`:r?.error?.kind===`network`?`check network access and retry, or download and replace the binary from ${e}`:`download and replace the binary from ${e}`:void 0}}function ht(e,t){return Y(e.installSource,e.executablePath,e.updateChannel,t)}const X=E,gt=`/node_modules/${X}`;async function _t(e){let t=await bt(),r=n.execPath,i=t.foundPackageJson?Q(t.packageRoot):Q(``,r),a=await yt((await M()).installSource,i),o=await w(),s=We(e?.updateChannel,o.selfUpdateChannel),c=await St(a,r,s);return{canAutoUpdate:Z(a),currentVersion:t.version||`0.1.1`,executablePath:r,installSource:a,latestVersion:c,packageRoot:t.packageRoot,recommendedUpgradeCommand:Z(a)?`quantex upgrade`:void 0,updateChannel:s}}async function vt(e){let t=e??await _t(),n=await Pe();if(!n)return{error:{kind:`locked`,message:`Another qtx upgrade is already running.`},installSource:t.installSource,success:!1};try{return await mt(t).upgrade(t)}finally{await n()}}function Z(e){return e===`binary`||e===`bun`||e===`npm`}async function yt(e,t){return t!==`unknown`&&e!==t?(await N(t),t):e??t}function Q(e,t=n.execPath){let r=wt(e);return r.includes(`/.bun/install/global/`)?`bun`:r.includes(gt)?`npm`:r?`source`:Tt(t)?`binary`:`unknown`}async function bt(e=import.meta.url){let t=Et(e),n=f(t);for(;;){let e=p(n,`package.json`),t=await Ct(e);if(t?.name===X)return{foundPackageJson:!0,packageJsonPath:e,packageRoot:n,version:t.version??`0.1.1`};let r=f(n);if(r===n)break;n=r}return{foundPackageJson:!1,packageJsonPath:p(f(t),`package.json`),packageRoot:f(t),version:ge}}function $(){return ge}function xt(e,t=n.execPath){return Y(e,t)}async function St(e,t,n){if(e===`binary`)try{let e=await Ge(n);return Je(e,t)?e.version:void 0}catch{return}return Me(X,n===`beta`?`beta`:`latest`)}async function Ct(e){try{return JSON.parse(await o(e,`utf8`))}catch{return}}function wt(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function Tt(e){let t=d(wt(e));return t!==`bun`&&t!==`bun.exe`}function Et(e){try{return m(e)}catch{return n.execPath}}function Dt(e){return jt({...e,error:null,ok:!0})}function Ot(e){return jt({...e,ok:!1})}function kt(e,t,n={}){let r=y();return r.cancelled&&!n.force||(r.outputMode===`json`?console.log(JSON.stringify(e,null,2)):r.outputMode===`ndjson`?Nt({action:e.action,data:e,target:e.target,type:`result`}):t(e)),e}function At(e,t={}){let n=y();if(!(n.cancelled&&!t.force)&&n.outputMode===`ndjson`)return Nt(e)}function jt(e){let t=y();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:$()},ok:e.ok,target:e.target,warnings:e.warnings??[]}}function Mt(e){let t=y();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:$()},target:e.target,type:e.type}}function Nt(e){let t=Mt(e);return console.log(JSON.stringify(t)),t}function Pt(){let e=y().colorMode??`auto`;return ne(e===`always`?!0:e===`never`?!1:re)}const Ft=new Proxy({},{get(e,t){let n=Pt(),r=n[t];return typeof r==`function`?r.bind(n):r}});export{M as A,C as B,q as C,je as D,Ne as E,Ce as F,ce as G,w as H,N as I,b as J,y as K,O as L,j as M,we as N,Me as O,xe as P,ye as R,K as S,G as T,he as U,me as V,pe as W,ae as Y,lt as _,kt as a,$e as b,xt as c,vt as d,Y as f,ct as g,ut as h,At as i,A as j,Se as k,$ as l,st as m,Ot as n,Z as o,ht as p,oe as q,Dt as r,Q as s,Ft as t,_t as u,Qe as v,W as w,et as x,tt as y,S as z};
@@ -1 +0,0 @@
1
- import{t as e}from"./commands-B4PWQRb1.mjs";export{e as commandsCommand};
@@ -1 +0,0 @@
1
- import e from"node:process";function t(e){return{packageName:e,type:`bun`}}function n(e){return{packageName:e,type:`npm`}}function r(e,t){return{packageName:e,packageTargetKind:t,type:`brew`}}function i(e){return{packageName:e,packageTargetKind:`id`,type:`winget`}}function a(e){return{command:e,type:`script`}}const o={name:`claude`,displayName:`Claude Code`,description:`Anthropic 官方 AI 编程助手 CLI`,homepage:`https://code.claude.com/docs`,packages:{npm:`@anthropic-ai/claude-code`},binaryName:`claude`,selfUpdate:{command:[`claude`,`update`],fallbackCommands:[[`claude`,`upgrade`]]},platforms:{windows:[t(),n(),a(`irm https://claude.ai/install.ps1 | iex`),i(`Anthropic.ClaudeCode`)],macos:[t(),n(),a(`curl -fsSL https://claude.ai/install.sh | bash`),r(`claude-code`,`cask`)],linux:[t(),n(),a(`curl -fsSL https://claude.ai/install.sh | bash`),r(`claude-code`,`cask`)]}},s={name:`codex`,displayName:`Codex CLI`,description:`OpenAI 官方 AI 编程助手 CLI`,homepage:`https://developers.openai.com/codex`,packages:{npm:`@openai/codex`},binaryName:`codex`,platforms:{windows:[t(),n()],macos:[t(),n(),r(`codex`)],linux:[t(),n(),r(`codex`)]}},c={name:`copilot`,displayName:`GitHub Copilot CLI`,description:`GitHub Copilot 命令行工具`,homepage:`https://github.com/features/copilot/cli`,packages:{npm:`@github/copilot`},binaryName:`copilot`,platforms:{windows:[i(`GitHub.Copilot`)],macos:[t(),n(),a(`curl -fsSL https://gh.io/copilot-install | bash`),r(`copilot-cli`)],linux:[t(),n(),a(`curl -fsSL https://gh.io/copilot-install | bash`),r(`copilot-cli`)]}},l={name:`cursor`,lookupAliases:[`agent`],displayName:`Cursor CLI`,description:`Cursor AI 编程助手命令行工具`,homepage:`https://cursor.com/docs/cli`,binaryName:`agent`,selfUpdate:{command:[`agent`,`update`]},versionProbe:{command:[`agent`,`--version`]},platforms:{windows:[a(`irm 'https://cursor.com/install?win32=true' | iex`)],macos:[a(`curl https://cursor.com/install -fsS | bash`)],linux:[a(`curl https://cursor.com/install -fsS | bash`)]}},u={name:`droid`,displayName:`Droid`,description:`Factory AI 软件工程 Agent CLI`,homepage:`https://docs.factory.ai/cli/getting-started/overview`,packages:{npm:`droid`},binaryName:`droid`,platforms:{windows:[t(),n(),a(`irm https://app.factory.ai/cli/windows | iex`)],macos:[t(),n(),a(`curl -fsSL https://app.factory.ai/cli | sh`),r(`droid`,`cask`)],linux:[t(),n(),a(`curl -fsSL https://app.factory.ai/cli | sh`),r(`droid`,`cask`)]}},d={name:`gemini`,displayName:`Gemini CLI`,description:`Google 开源 AI 编程助手 CLI`,homepage:`https://geminicli.com`,packages:{npm:`@google/gemini-cli`},binaryName:`gemini`,platforms:{windows:[t(),n()],macos:[t(),n(),r(`gemini-cli`)],linux:[t(),n(),r(`gemini-cli`)]}},f={name:`opencode`,displayName:`OpenCode`,description:`开源 AI 编程 CLI`,homepage:`https://opencode.ai`,packages:{npm:`opencode-ai`},binaryName:`opencode`,platforms:{windows:[t(),n()],macos:[t(),n(),a(`curl -fsSL https://opencode.ai/install | bash`),r(`anomalyco/tap/opencode`)],linux:[t(),n(),a(`curl -fsSL https://opencode.ai/install | bash`),r(`anomalyco/tap/opencode`)]}},p={name:`pi`,displayName:`Pi`,description:`极简可扩展的终端编程 Agent`,homepage:`https://pi.dev`,packages:{npm:`@mariozechner/pi-coding-agent`},binaryName:`pi`,platforms:{windows:[t(),n()],macos:[t(),n()],linux:[t(),n()]}},m=[o,s,c,l,u,d,f,p];function h(){return m}function g(e){return m.find(t=>t.name===e||(t.lookupAliases?.includes(e)??!1))}function _(e){return g(e)}function v(){switch(e.platform){case`win32`:return`windows`;case`darwin`:return`macos`;default:return`linux`}}async function y(e){try{let t=Bun.spawn([e,`--version`],{stdout:`pipe`,stderr:`pipe`});return await t.exited,t.exitCode===0}catch{return!1}}async function b(){return y(`bun`)}async function x(){return y(`npm`)}async function S(){return y(`brew`)}async function C(){return y(`winget`)}async function w(t){try{let n=e.platform===`win32`?`where`:`which`,r=Bun.spawn([n,t],{stdout:`pipe`,stderr:`pipe`});return await r.exited,r.exitCode===0}catch{return!1}}export{o as _,x as a,_ as c,f as d,d as f,s as g,c as h,b as i,h as l,l as m,w as n,C as o,u as p,S as r,g as s,v as t,p as u};
@@ -1,3 +0,0 @@
1
- import{t as e}from"./agents-BPMc1vIb.mjs";import{a as t,i as n,o as r,r as i}from"./detect-q8eznhj9.mjs";import{a,p as o,r as s,t as c,u as l}from"./color-CbC8zjc1.mjs";async function u(){let c=await n(),u=await t(),f=await i(),p=await r(),m=await l(),h=m.latestVersion&&m.latestVersion!==m.currentVersion,g=(await e()).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})),_=[];return!c&&!u&&!f&&!p&&_.push({code:`NO_MANAGED_INSTALLER`,message:`No managed installer found. Install bun, npm, brew, or winget.`,severity:`warning`}),a(s({action:`doctor`,data:{agents:g,issues:_,installers:{brew:f,bun:c,npm:u,winget:p},self:{canAutoUpdate:m.canAutoUpdate,currentVersion:m.currentVersion,installSource:m.installSource,latestVersion:m.latestVersion,outdated:!!h,recoveryHint:h?o(m):void 0}},target:{kind:`system`,name:`doctor`}}),d)}function d(e){if(e.data){if(console.log(c.bold(`
2
- Quantex CLI Environment Check
3
- `)),console.log(c.bold(`Managed Installers:`)),console.log(` Bun: ${e.data.installers.bun?c.green(`available`):c.red(`not found`)}`),console.log(` npm: ${e.data.installers.npm?c.green(`available`):c.red(`not found`)}`),console.log(` brew: ${e.data.installers.brew?c.green(`available`):c.red(`not found`)}`),console.log(` winget:${e.data.installers.winget?c.green(`available`):c.red(`not found`)}`),console.log(`\n${c.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?c.green(`supported`):c.yellow(`unsupported`)}`),e.data.self.latestVersion&&console.log(` Latest: ${e.data.self.latestVersion}${e.data.self.outdated?c.yellow(` (update available)`):``}`),e.data.self.recoveryHint&&console.log(` Recovery: ${e.data.self.recoveryHint}`),console.log(`\n${c.bold(`Installed Agents:`)}`),e.data.agents.length===0)console.log(c.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?c.yellow(` (update available: ${t.latestVersion})`):``}`);if(console.log(`\n${c.bold(`Issues:`)}`),e.data.issues.length===0)console.log(c.green(` No issues found.`));else for(let t of e.data.issues)console.log(c.yellow(` - ${t.message}`));console.log()}}export{u as doctorCommand};
@@ -1 +0,0 @@
1
- import{t as e}from"./ensure-CICTMwyQ.mjs";export{e as ensureCommand};
@@ -1 +0,0 @@
1
- import{t as e}from"./inspect-CrAtG1sO.mjs";export{e as inspectCommand};
@@ -1 +0,0 @@
1
- import{r as e}from"./agents-BPMc1vIb.mjs";import{a as t,n,r,t as i}from"./color-CbC8zjc1.mjs";async function a(i){let a=await e(i);if(!a)return t(n({action:`resolve`,error:{code:`AGENT_NOT_FOUND`,details:{input:i},message:`Unknown agent: ${i}`},target:{kind:`agent`,name:i}}),o);let{agent:s,inspection:c}=a;return!c.inPath||!c.binaryPath?t(n({action:`resolve`,error:{code:`AGENT_NOT_INSTALLED`,message:`${s.displayName} is not installed.`},target:{kind:`agent`,name:s.name}}),o):t(r({action:`resolve`,data:{agent:{binaryName:s.binaryName,displayName:s.displayName,name:s.name},resolution:{binaryPath:c.binaryPath,installSource:c.installedState?.installType??`detected-in-path`,installedVersion:c.installedVersion,lifecycle:c.lifecycle,sourceLabel:c.sourceLabel,suggestedLaunchCommand:[c.binaryPath]}},target:{kind:`agent`,name:s.name}}),o)}function o(e){if(e.error){console.log(i.red(e.error.message));return}e.data&&(console.log(i.bold(`\n${e.data.agent.displayName}\n`)),console.log(` Name: ${e.data.agent.name}`),console.log(` Binary: ${e.data.agent.binaryName}`),console.log(` Path: ${e.data.resolution.binaryPath}`),console.log(` Source: ${e.data.resolution.sourceLabel}`),console.log(` Lifecycle: ${e.data.resolution.lifecycle}`),console.log(` Install Type: ${e.data.resolution.installSource}`),e.data.resolution.installedVersion&&console.log(` Version: ${e.data.resolution.installedVersion}`),console.log(` Launch: ${e.data.resolution.suggestedLaunchCommand.join(` `)}`),console.log())}export{a as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./resolve-BaEyqkW-.mjs";export{e as resolveCommand};
@@ -1 +0,0 @@
1
- import{n as e}from"./schema-CrujLfID.mjs";export{e as schemaCommand};
@@ -1,3 +0,0 @@
1
- import{a as e,n as t,r as n,t as r}from"./color-CbC8zjc1.mjs";const i={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},error:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},exitCode:{type:`integer`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},ok:{type:`boolean`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},warnings:{items:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},type:`array`}},required:[`action`,`error`,`meta`,`ok`,`warnings`],type:`object`},a={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},type:{type:`string`}},required:[`action`,`meta`,`type`],type:`object`},o=[{dataSchema:{additionalProperties:!1,properties:{agents:{items:{type:`string`},type:`array`},features:{additionalProperties:!1,properties:{assumeYes:{type:`boolean`},cacheBypass:{type:`boolean`},cacheRefresh:{type:`boolean`},channels:{items:{type:`string`},type:`array`},colorModes:{items:{type:`string`},type:`array`},dryRun:{type:`boolean`},execInstallPolicies:{items:{type:`string`},type:`array`},freshnessMetadata:{type:`boolean`},idempotencyKey:{type:`boolean`},logLevels:{items:{type:`string`},type:`array`},quietLogs:{type:`boolean`},selfUpgrade:{type:`boolean`},timeout:{type:`boolean`}},required:[`assumeYes`,`cacheBypass`,`cacheRefresh`,`channels`,`colorModes`,`dryRun`,`execInstallPolicies`,`freshnessMetadata`,`idempotencyKey`,`logLevels`,`quietLogs`,`selfUpgrade`,`timeout`],type:`object`},installers:{type:`object`},outputModes:{items:{type:`string`},type:`array`},platform:{additionalProperties:!1,properties:{arch:{type:`string`},os:{type:`string`}},required:[`arch`,`os`],type:`object`}},required:[`agents`,`features`,`installers`,`outputModes`,`platform`],type:`object`},description:`Environment and surface capabilities`,envelopeSchema:i,name:`capabilities`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{flags:{items:{type:`string`},type:`array`},name:{type:`string`},outputSchemaRef:{type:`string`},stability:{type:`string`},summary:{type:`string`}},required:[`flags`,`name`,`outputSchemaRef`,`stability`,`summary`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Stable command catalog`,envelopeSchema:i,name:`commands`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},installState:{type:`object`},installed:{type:`boolean`}},required:[`agent`,`changed`,`installed`],type:`object`},description:`Ensure result for an agent`,envelopeSchema:i,name:`ensure`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},capabilities:{type:`object`},inspection:{type:`object`}},required:[`agent`,`capabilities`,`inspection`],type:`object`},description:`Structured inspection result for an agent`,envelopeSchema:i,name:`inspect`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},resolution:{type:`object`}},required:[`agent`,`resolution`],type:`object`},description:`Resolved executable entrypoint for an agent`,envelopeSchema:i,name:`resolve`,ndjsonEventSchema:a},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{dataSchema:{type:`object`},description:{type:`string`},envelopeSchema:{type:`object`},name:{type:`string`},ndjsonEventSchema:{type:`object`}},required:[`dataSchema`,`description`,`envelopeSchema`,`name`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Structured schema catalog`,envelopeSchema:i,name:`schema`,ndjsonEventSchema:a}];async function s(r){let i=r?o.filter(e=>e.name===r):o;return r&&i.length===0?e(t({action:`schema`,error:{code:`INVALID_ARGUMENT`,details:{command:r},message:`Unknown schema target: ${r}`},target:{kind:`system`,name:`schema`}}),c):e(n({action:`schema`,data:{commands:i},target:{kind:`system`,name:`schema`}}),c)}function c(e){if(e.error){console.log(r.red(e.error.message));return}if(e.data){console.log(r.bold(`
2
- Quantex Schemas
3
- `));for(let t of e.data.commands)console.log(` ${r.cyan(t.name)}`),console.log(` ${t.description}`);console.log()}}function l(){return o}export{s as n,l as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n,s as r}from"./update-CtO35mwD.mjs";import{S as i,g as a,l as o,m as s,n as c,u as l}from"./agents-BPMc1vIb.mjs";import{L as u,a as d,i as f,n as p,r as m,t as h}from"./color-CbC8zjc1.mjs";import{a as g,i as _,n as v,r as y}from"./user-output-DYsOPwi1.mjs";async function b(e,t){if(t)return x();if(!e)return d(p({action:`update`,error:{code:`INVALID_ARGUMENT`,message:`Please specify an agent name or use --all flag`},target:{kind:`agent`}}),O);let n=c(e);return n?S(n):d(p({action:`update`,error:{code:`AGENT_NOT_FOUND`,details:{input:e},message:`Unknown agent: ${e}`},target:{kind:`agent`,name:e}}),O)}async function x(){f({action:`update`,data:{scope:`all`},target:{kind:`agent`},type:`started`});let t=await C(await e());return t.hasFailures?d(p({action:`update`,data:{results:t.results,scope:`all`},error:{code:`UPDATE_FAILED`,message:`One or more agents failed to update.`},target:{kind:`agent`}}),O):d(m({action:`update`,data:{results:t.results,scope:`all`},target:{kind:`agent`}}),O)}async function S(e){f({action:`update`,data:{agent:e.name,scope:`single`},target:{kind:`agent`,name:e.name},type:`started`});let{inspection:t,plan:r}=await n(e);if(!t.inPath)return d(p({action:`update`,error:{code:`AGENT_NOT_INSTALLED`,message:`${e.displayName} is not installed.`},target:{kind:`agent`,name:e.name}}),O);let i=await C(r),a=D(i.results);return a?d(p({action:`update`,data:{results:i.results,scope:`single`},error:{code:`RESOURCE_LOCKED`,details:a.resource?{resource:a.resource}:void 0,message:a.message??`Another quantex process is already updating ${e.displayName}.`},target:{kind:`agent`,name:e.name}}),O):i.hasFailures?d(p({action:`update`,data:{results:i.results,scope:`single`},error:{code:`UPDATE_FAILED`,message:`Failed to update ${e.displayName}.`},target:{kind:`agent`,name:e.name}}),O):d(m({action:`update`,data:{results:i.results,scope:`single`},target:{kind:`agent`,name:e.name}}),O)}async function C(e){let t=[];for(let n of e.upToDate)w(t,{displayName:n.agent.displayName,installedVersion:n.installedVersion,latestVersion:n.latestVersion,name:n.agent.name,status:`up-to-date`});for(let n of e.skippedManualCheck)w(t,{displayName:n.agent.displayName,message:r(n.agent),name:n.agent.name,status:`manual-required`});for(let n of e.grouped){let e=await T(n.type,n.packages,n.updates);for(let n of e)w(t,n)}for(let n of e.manual)w(t,await E(n.agent,n.state,n.inspection.methods,n.inspection));return{hasFailures:t.some(e=>e.status===`failed`||e.status===`locked`),results:t}}function w(e,t){e.push(t),f({action:`update`,data:t,target:{kind:`agent`,name:t.name},type:`progress`})}async function T(e,t,n){if(n.length===0)return[];if(v())return n.map(({agent:t,inspection:n,strategy:r})=>({displayName:t.displayName,installedVersion:n.installedVersion,latestVersion:n.latestVersion,message:`Dry run: would update ${t.displayName}.`,name:t.name,status:`planned`,strategy:r===`managed`?`managed/${e}`:r}));try{return await l(e,t)?n.map(({agent:t,inspection:n,strategy:r})=>({displayName:t.displayName,installedVersion:n.installedVersion,latestVersion:n.latestVersion,name:t.name,status:`updated`,strategy:r===`managed`?`managed/${e}`:r})):await Promise.all(n.map(({agent:e,inspection:t,state:n})=>E(e,n,t.methods,t)))}catch(t){if(!u(t))throw t;return n.map(({agent:n,inspection:r,strategy:i})=>({displayName:n.displayName,installedVersion:r.installedVersion,latestVersion:r.latestVersion,message:t.message,name:n.name,resource:t.resource,status:`locked`,strategy:i===`managed`?`managed/${e}`:i}))}}async function E(e,n,c,l){let d=c??l?.methods??[],f=s({agent:e,installedState:n,methods:d}),p=l?.installedVersion,m=l?.latestVersion;if(f===`manual-hint`&&!a(e,n)&&!d.some(e=>i(e.type)))return{displayName:e.displayName,installedVersion:p,latestVersion:m,message:r(e),name:e.name,status:`manual-required`,strategy:f};if(v())return{displayName:e.displayName,installedVersion:p,latestVersion:m,message:`Dry run: would update ${e.displayName}.`,name:e.name,status:`planned`,strategy:f};let h;try{h=await o(e,n)}catch(t){if(u(t))return{displayName:e.displayName,installedVersion:p,latestVersion:m,message:t.message,name:e.name,resource:t.resource,status:`locked`,strategy:f};throw t}return h.success?{displayName:e.displayName,installedVersion:p,latestVersion:m,name:e.name,status:`updated`,strategy:f}:{displayName:e.displayName,hint:t(e,f),installedVersion:p,latestVersion:m,name:e.name,status:`failed`,strategy:f}}function D(e){if(e.length===1)return e[0]?.status===`locked`?e[0]:void 0}function O(e){if(!e.data){e.error&&y(h.red(e.error.message));return}for(let t of e.data.results)switch(t.status){case`up-to-date`:_(h.green(`${t.displayName} is up to date (${t.installedVersion??`unknown`})`));break;case`manual-required`:t.message&&g(h.yellow(t.message));break;case`planned`:g(h.cyan(`Would update ${t.displayName}${t.strategy?` via ${t.strategy}`:``}${k(t.installedVersion,t.latestVersion)}`));break;case`updated`:_(h.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${k(t.installedVersion,t.latestVersion)}`)),_(h.green(`${t.displayName} updated successfully!`));break;case`failed`:_(h.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${k(t.installedVersion,t.latestVersion)}`)),y(h.red(`Failed to update ${t.displayName}.`)),t.hint&&g(h.yellow(t.hint));break;case`locked`:g(h.yellow(t.message??`Another quantex process is already updating ${t.displayName}.`));break}!e.data.results.length&&e.error&&y(h.red(e.error.message))}function k(e,t){return e?` (${e} -> ${t??`latest`})`:``}export{b as updateCommand};
@@ -1 +0,0 @@
1
- import{g as e,h as t,i as n,t as r,y as i}from"./agents-BPMc1vIb.mjs";function a(e){return`${e.displayName} uses a manually managed install source. Please check for updates manually.`}function o(e,t){if(t===`self-update`&&e.selfUpdate)return`Try running ${e.selfUpdate.command.join(` `)} directly.`;if(t===`manual-hint`)return`Check ${e.homepage} for the recommended update path.`}function s(e){let n={bun:[],npm:[],brew:[],winget:[]},r=[],i=[],a=[];for(let o of e){if(!o.inPath)continue;if(l(o)){i.push(o);continue}if(!c(o)){a.push(o);continue}let e=t({agent:o.agent,installedState:o.installedState,methods:o.methods}),s=e.strategy===`managed`?e.getManagedInstallerType?.({agent:o.agent,installedState:o.installedState,methods:o.methods}):void 0;if(s){let e={inspection:o,installerType:s,strategy:`grouped`};n[s].push(e);continue}r.push({inspection:o,strategy:e.strategy===`self-update`?`self-update`:`manual`})}return{entries:[...n.bun,...n.npm,...n.brew,...n.winget,...r],grouped:n,manual:r,skippedManualCheck:i,upToDate:a}}function c(e){return e.installedVersion&&e.latestVersion?e.installedVersion!==e.latestVersion:!0}function l(t){return!t.latestVersion&&!e(t.agent,t.installedState)}const u=[`bun`,`npm`,`brew`,`winget`];async function d(e){let t=await n(e);return{agent:e,inspection:t,updateAvailable:c(t)}}async function f(){return m(await r())}async function p(e){let t=await n(e);return{inspection:t,plan:m([t])}}function m(e){let t=s(e),n=u.map(e=>h(e,t.grouped[e])).filter(e=>e!==void 0);return{entries:t.entries.map(e=>g(e.inspection)),grouped:n,manual:t.manual.map(e=>g(e.inspection)),skippedManualCheck:t.skippedManualCheck,upToDate:t.upToDate}}function h(e,t){if(t.length===0)return;let n=t.map(e=>g(e.inspection));return{type:e,packages:n.flatMap(e=>e.package?.packageName?[e.package]:[]),updates:n}}function g(e){let n=t({agent:e.agent,installedState:e.installedState,methods:e.methods}),r=n.getManagedInstallerType?.({agent:e.agent,installedState:e.installedState,methods:e.methods});return{agent:e.agent,inspection:e,installerType:r,package:r?_(e.agent,e.installedState,e.methods,r):void 0,state:e.installedState,strategy:n.strategy}}function _(e,t,n,r){if(t?.packageName&&t.installType===r)return{packageName:t.packageName,packageTargetKind:t.packageTargetKind};let a=n.find(e=>e.type===r);if(!a)return;let o=i(e,a);if(o)return{packageName:o,packageTargetKind:a.packageTargetKind}}export{c as a,s as i,f as n,o,p as r,a as s,d as t};