quantex-cli 0.0.1 → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -0
- package/dist/agents-Cag2AZCY.mjs +1 -0
- package/dist/capabilities-B3ffggvz.mjs +5 -0
- package/dist/capabilities-BFVH18wr.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/color-D1aRiz7E.mjs +4 -0
- package/dist/commands-CJiphyF_.mjs +1 -0
- package/dist/commands-CwZpvRp0.mjs +3 -0
- package/dist/config-C8GizwSD.mjs +3 -0
- package/dist/detect-q8eznhj9.mjs +1 -0
- package/dist/doctor-DREyUzZI.mjs +3 -0
- package/dist/ensure-COQzNBEp.mjs +1 -0
- package/dist/ensure-Cbp7NtYL.mjs +1 -0
- package/dist/errors-DCtNasuC.mjs +1 -0
- package/dist/index.d.mts +263 -1
- package/dist/index.mjs +2 -2
- package/dist/info-BvoP2C5o.mjs +2 -0
- package/dist/inspect-CJnn0eG8.mjs +3 -0
- package/dist/inspect-OJ9-qvwG.mjs +1 -0
- package/dist/install-Blmx9uTg.mjs +1 -0
- package/dist/lifecycle-errors-D7JpbOsK.mjs +1 -0
- package/dist/list-B3NtC54o.mjs +3 -0
- package/dist/postinstall.mjs +1 -1
- package/dist/resolve-BCqc_ZL8.mjs +1 -0
- package/dist/resolve-HGAozfCy.mjs +1 -0
- package/dist/schema-C4Mbbl2a.mjs +3 -0
- package/dist/schema-DOED00XQ.mjs +1 -0
- package/dist/uninstall-BfIR-9p_.mjs +1 -0
- package/dist/{update-C6oNB0Kw.mjs → update-d-egOW3q.mjs} +1 -1
- package/dist/update-uEAHEquL.mjs +1 -0
- package/dist/upgrade-CJr1xtWf.mjs +1 -0
- package/dist/user-output-Dj9auSeW.mjs +1 -0
- package/package.json +1 -1
- package/dist/agents-BALRvoqc.mjs +0 -1
- package/dist/config-B1BACpEg.mjs +0 -3
- package/dist/config-DWeRAIFV.mjs +0 -1
- package/dist/doctor-C3MeTdcd.mjs +0 -3
- package/dist/info-m8Pm4m7N.mjs +0 -2
- package/dist/install-LlwsPjcI.mjs +0 -1
- package/dist/list-C3iiju9D.mjs +0 -3
- package/dist/self-Bj9L_tIu.mjs +0 -1
- package/dist/uninstall-BYGbg7Kt.mjs +0 -1
- package/dist/update-DTqFneka.mjs +0 -1
- package/dist/upgrade-CTQyBekz.mjs +0 -1
- package/dist/version-CrMPGstC.mjs +0 -4
package/README.md
CHANGED
|
@@ -11,6 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
|
+
> 项目定位:Quantex 是 `human-friendly + agent-friendly` 的 `agent lifecycle CLI`。主线聚焦 agent 的安装、检查、确保可用、更新、卸载、能力发现与稳定执行契约,不把自身扩张为 workflow orchestration platform。
|
|
15
|
+
|
|
16
|
+
## 设计文档
|
|
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)
|
|
20
|
+
|
|
14
21
|
## 支持的 Agent
|
|
15
22
|
|
|
16
23
|
| Agent | 命令 | 别名 | 描述 |
|
|
@@ -57,6 +64,18 @@ quantex install claude
|
|
|
57
64
|
qtx i claude
|
|
58
65
|
```
|
|
59
66
|
|
|
67
|
+
### 确保 Agent 已安装
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
quantex ensure claude
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`ensure` 是面向自动化和 agent 调用的幂等入口:
|
|
74
|
+
|
|
75
|
+
- 已安装则直接成功
|
|
76
|
+
- 未安装时才执行安装
|
|
77
|
+
- 配合 `--json` 时会返回 `changed` 字段,便于上层判断是否发生变更
|
|
78
|
+
|
|
60
79
|
### 更新 Agent
|
|
61
80
|
|
|
62
81
|
```bash
|
|
@@ -145,6 +164,34 @@ quantex info claude
|
|
|
145
164
|
- 当前版本和可检测到的最新版本
|
|
146
165
|
- agent 自带的自更新命令
|
|
147
166
|
|
|
167
|
+
### 查看 Agent 结构化状态
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
quantex inspect claude
|
|
171
|
+
quantex inspect claude --json
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`inspect` 更偏 agent-friendly,会集中返回:
|
|
175
|
+
|
|
176
|
+
- 安装状态、版本、路径、来源
|
|
177
|
+
- 当前 update mode
|
|
178
|
+
- 当前平台可用安装方式
|
|
179
|
+
- `auto-install` / `self-update` / `runnable` 等能力摘要
|
|
180
|
+
|
|
181
|
+
### 解析 Agent 可执行入口
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
quantex resolve claude
|
|
185
|
+
quantex resolve claude --json
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`resolve` 更偏 runtime-friendly,会直接返回:
|
|
189
|
+
|
|
190
|
+
- 当前可执行 binary 的绝对路径
|
|
191
|
+
- 已安装版本
|
|
192
|
+
- 安装来源
|
|
193
|
+
- 建议启动命令
|
|
194
|
+
|
|
148
195
|
### 快捷启动 Agent
|
|
149
196
|
|
|
150
197
|
```bash
|
|
@@ -155,6 +202,53 @@ quantex agent --help
|
|
|
155
202
|
|
|
156
203
|
如果 agent 未安装,Quantex 会提示是否先安装再启动。
|
|
157
204
|
|
|
205
|
+
### 以显式策略启动 Agent
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
quantex exec claude --install if-missing -- --dangerously-skip-permissions
|
|
209
|
+
quantex exec codex --install never -- --help
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`exec` 是比快捷启动更适合自动化的入口:
|
|
213
|
+
|
|
214
|
+
- `--install never`:未安装时直接失败
|
|
215
|
+
- `--install if-missing`:缺失时自动安装再启动
|
|
216
|
+
- `--install always`:显式要求先满足安装前置,再启动
|
|
217
|
+
|
|
218
|
+
`--` 之后的参数会原样透传给下游 agent,避免与 Quantex 自己的参数冲突。
|
|
219
|
+
|
|
220
|
+
### Agent-friendly 全局参数
|
|
221
|
+
|
|
222
|
+
Quantex 现在默认保留 human-first CLI,同时补齐了一组统一的 agent-friendly 全局参数:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
quantex inspect claude --json --refresh
|
|
226
|
+
quantex install claude --json --dry-run
|
|
227
|
+
quantex exec claude --install if-missing --yes -- --help
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
当前主线支持:
|
|
231
|
+
|
|
232
|
+
- `--json` / `--output <human|json|ndjson>`
|
|
233
|
+
- `--non-interactive`
|
|
234
|
+
- `--yes`
|
|
235
|
+
- `--quiet`
|
|
236
|
+
- `--color <auto|always|never>`
|
|
237
|
+
- `--log-level <silent|error|warn|info|debug>`
|
|
238
|
+
- `--dry-run`
|
|
239
|
+
- `--refresh` / `--no-cache`
|
|
240
|
+
- `--run-id`
|
|
241
|
+
- `--idempotency-key`
|
|
242
|
+
- `--timeout`
|
|
243
|
+
|
|
244
|
+
对于版本与 release 元数据查询,结构化结果的 `meta` 现在会附带:
|
|
245
|
+
|
|
246
|
+
- `fetchedAt`
|
|
247
|
+
- `staleAfter`
|
|
248
|
+
- `source`
|
|
249
|
+
|
|
250
|
+
这让上层 agent 可以判断结果是否来自缓存、何时应主动强刷。
|
|
251
|
+
|
|
158
252
|
### 配置管理
|
|
159
253
|
|
|
160
254
|
```bash
|
|
@@ -180,6 +274,36 @@ quantex doctor
|
|
|
180
274
|
- 已安装 agent 的版本状态
|
|
181
275
|
- 当前环境是否缺少任何可用于托管安装/更新的安装器
|
|
182
276
|
|
|
277
|
+
### 查看能力探测结果
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
quantex capabilities
|
|
281
|
+
quantex capabilities --json
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`capabilities` 和 `doctor` 的边界不同:
|
|
285
|
+
|
|
286
|
+
- `capabilities`:回答“当前环境能做什么”
|
|
287
|
+
- `doctor`:回答“当前哪里有问题,以及怎么修”
|
|
288
|
+
|
|
289
|
+
### 查看命令目录
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
quantex commands
|
|
293
|
+
quantex commands --json
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
`commands` 会返回当前支持的稳定命令、摘要以及常用 flag,适合作为上层 agent 做 command discovery 的入口。
|
|
297
|
+
|
|
298
|
+
### 查看输出 Schema
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
quantex schema
|
|
302
|
+
quantex schema inspect --json
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
`schema` 用来导出稳定命令的结构化输出定义,适合作为 agent 或 SDK 的类型参考。
|
|
306
|
+
|
|
183
307
|
## 配置
|
|
184
308
|
|
|
185
309
|
配置文件位于 `~/.quantex/config.json`,当前支持:
|
|
@@ -0,0 +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-D1aRiz7E.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};
|
|
@@ -0,0 +1,5 @@
|
|
|
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-D1aRiz7E.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
|
+
Quantex Capabilities
|
|
3
|
+
`)),console.log(` Platform: ${e.data.platform.os}/${e.data.platform.arch}`),console.log(` Output Modes: ${e.data.outputModes.join(`, `)}`),console.log(` Agents: ${e.data.agents.join(`, `)}`),console.log(c.bold(`
|
|
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(`
|
|
5
|
+
Features:`)),console.log(` assume-yes: ${e.data.features.assumeYes?`yes`:`no`}`),console.log(` cache-refresh: ${e.data.features.cacheRefresh?`yes`:`no`}`),console.log(` color-modes: ${e.data.features.colorModes.join(`, `)}`),console.log(` no-cache: ${e.data.features.cacheBypass?`yes`:`no`}`),console.log(` dry-run: ${e.data.features.dryRun?`yes`:`no`}`),console.log(` freshness-metadata: ${e.data.features.freshnessMetadata?`yes`:`no`}`),console.log(` self-upgrade: ${e.data.features.selfUpgrade?`yes`:`no`}`),console.log(` idempotency-key: ${e.data.features.idempotencyKey?`yes`:`no`}`),console.log(` log-levels: ${e.data.features.logLevels.join(`, `)}`),console.log(` quiet-logs: ${e.data.features.quietLogs?`yes`:`no`}`),console.log(` timeout: ${e.data.features.timeout?`yes`:`no`}`),console.log(` channels: ${e.data.features.channels.join(`, `)}`),console.log(` exec-install-policy: ${e.data.features.execInstallPolicies.join(`, `)}`),console.log())}function m(e){return e.available?c.green(`available`):c.red(e.reason??`not-found`)}export{d as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./capabilities-B3ffggvz.mjs";export{e as capabilitiesCommand};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import{r as e,s as t,y as n}from"./agents-BALRvoqc.mjs";import{i as r}from"./self-Bj9L_tIu.mjs";import i from"node:process";import{program as a}from"commander";import o from"picocolors";import s from"prompts";async function c(n,r){let i=await e(n);if(!i)return console.log(o.red(`Unknown agent: ${n}`)),1;let{agent:a,inspection:c}=i;if(!c.inPath){if(!(await s({type:`confirm`,name:`install`,message:`${a.displayName} is not installed. Would you like to install it?`,initial:!0})).install)return console.log(o.yellow(`Installation cancelled.`)),1;if(console.log(o.cyan(`Installing ${a.displayName}...`)),!(await t(a)).success)return console.log(o.red(`Failed to install ${a.displayName}.`)),1}try{let e=Bun.spawn([a.binaryName,...r],{stdio:[`inherit`,`inherit`,`inherit`]});return await e.exited,e.exitCode??1}catch(e){return console.log(o.red(`Failed to launch ${a.displayName}: ${e instanceof Error?e.message:String(e)}`)),1}}a.name(`quantex`).description(`统一的 AI Agent CLI 管理工具`).version(r()),a.command(`install <agent>`).alias(`i`).description(`安装指定 agent`).action(async e=>{let{installCommand:t}=await import(`./install-LlwsPjcI.mjs`);await t(e)}),a.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-DTqFneka.mjs`);await n(e,t.all??!1)}),a.command(`uninstall <agent>`).alias(`rm`).description(`卸载指定 agent`).action(async e=>{let{uninstallCommand:t}=await import(`./uninstall-BYGbg7Kt.mjs`);await t(e)}),a.command(`list`).alias(`ls`).description(`列出所有支持的 agent`).action(async()=>{let{listCommand:e}=await import(`./list-C3iiju9D.mjs`);await e()}),a.command(`info <agent>`).description(`查看 agent 详细信息`).action(async e=>{let{infoCommand:t}=await import(`./info-m8Pm4m7N.mjs`);await t(e)}),a.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-B1BACpEg.mjs`);await r(e,t,n)}),a.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-CTQyBekz.mjs`);i.exitCode=await t({channel:e.channel===`beta`?`beta`:void 0,check:e.check??!1})}),a.command(`doctor`).description(`检查环境`).action(async()=>{let{doctorCommand:e}=await import(`./doctor-C3MeTdcd.mjs`);await e()});const l=i.argv[2],u=new Set([...a.commands.map(e=>e.name()),...a.commands.flatMap(e=>e.aliases()),`help`,`--help`,`--version`,`-v`]);if(l&&!l.startsWith(`-`)&&!u.has(l)&&n(l)){let e=await c(l,i.argv.slice(3));i.exit(e)}a.parse();export{};
|
|
2
|
+
import{r as e,s as t}from"./agents-Cag2AZCY.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-D1aRiz7E.mjs";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./user-output-Dj9auSeW.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-DOED00XQ.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-CJiphyF_.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-BFVH18wr.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-OJ9-qvwG.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-HGAozfCy.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-Blmx9uTg.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-Cbp7NtYL.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-uEAHEquL.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-BfIR-9p_.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-B3NtC54o.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-BvoP2C5o.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-C8GizwSD.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-CJr1xtWf.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-DREyUzZI.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{};
|
|
@@ -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.1.0-beta.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.0-beta.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.0-beta.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./commands-CwZpvRp0.mjs";export{e as commandsCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e,r as t,t as n}from"./color-D1aRiz7E.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
|
+
Quantex Commands
|
|
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,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-D1aRiz7E.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(`
|
|
2
|
+
Current Configuration:
|
|
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`,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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"./agents-Cag2AZCY.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-D1aRiz7E.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,s as t}from"./agents-Cag2AZCY.mjs";import{L as n,a as r,i,n as a,r as o,t as s}from"./color-D1aRiz7E.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-Dj9auSeW.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./ensure-COQzNBEp.mjs";export{e as ensureCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){switch(e){case`INVALID_ARGUMENT`:return 2;case`AGENT_NOT_FOUND`:return 3;case`AGENT_NOT_INSTALLED`:return 4;case`NETWORK_ERROR`:return 6;case`INTERACTION_REQUIRED`:return 7;case`MANUAL_ACTION_REQUIRED`:return 8;case`RESOURCE_LOCKED`:return 9;case`TIMEOUT`:return 10;case`CANCELLED`:return 11;default:return 1}}function t(t){return t.exitCode===void 0?t.ok?0:t.error?e(t.error.code):1:t.exitCode}export{t as n,e as t};
|
package/dist/index.d.mts
CHANGED
|
@@ -148,6 +148,249 @@ declare function resolveAgentUpdateProvider(context: AgentUpdateContext): AgentU
|
|
|
148
148
|
declare function getAgentUpdateStrategy(context: AgentUpdateContext): AgentUpdateProvider['strategy'];
|
|
149
149
|
declare function canResolveAgentUpdate(context: AgentUpdateContext): boolean;
|
|
150
150
|
//#endregion
|
|
151
|
+
//#region src/cli-context.d.ts
|
|
152
|
+
type OutputMode = 'human' | 'json' | 'ndjson';
|
|
153
|
+
type CacheMode = 'default' | 'no-cache' | 'refresh';
|
|
154
|
+
type FreshnessSource = 'cache' | 'network';
|
|
155
|
+
type ColorMode = 'always' | 'auto' | 'never';
|
|
156
|
+
type LogLevel = 'debug' | 'error' | 'info' | 'silent' | 'warn';
|
|
157
|
+
interface CliFreshness {
|
|
158
|
+
fetchedAt: string;
|
|
159
|
+
source: FreshnessSource;
|
|
160
|
+
staleAfter: string;
|
|
161
|
+
}
|
|
162
|
+
interface CliContext {
|
|
163
|
+
assumeYes?: boolean;
|
|
164
|
+
cacheMode?: CacheMode;
|
|
165
|
+
cancelled?: boolean;
|
|
166
|
+
colorMode?: ColorMode;
|
|
167
|
+
dryRun?: boolean;
|
|
168
|
+
freshness?: CliFreshness;
|
|
169
|
+
idempotencyKey?: string;
|
|
170
|
+
interactive: boolean;
|
|
171
|
+
logLevel?: LogLevel;
|
|
172
|
+
outputMode: OutputMode;
|
|
173
|
+
quiet?: boolean;
|
|
174
|
+
runId: string;
|
|
175
|
+
timeoutMs?: number;
|
|
176
|
+
}
|
|
177
|
+
interface CliContextOptions {
|
|
178
|
+
idempotencyKey?: string;
|
|
179
|
+
json?: boolean;
|
|
180
|
+
noCache?: boolean;
|
|
181
|
+
nonInteractive?: boolean;
|
|
182
|
+
output?: string;
|
|
183
|
+
color?: string;
|
|
184
|
+
dryRun?: boolean;
|
|
185
|
+
logLevel?: string;
|
|
186
|
+
quiet?: boolean;
|
|
187
|
+
refresh?: boolean;
|
|
188
|
+
runId?: string;
|
|
189
|
+
timeout?: string;
|
|
190
|
+
yes?: boolean;
|
|
191
|
+
}
|
|
192
|
+
declare function getCliContext(): CliContext;
|
|
193
|
+
declare function setCliContext(context: CliContext): void;
|
|
194
|
+
declare function resetCliContext(): void;
|
|
195
|
+
declare function resolveCliContext(options?: CliContextOptions): CliContext;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/errors.d.ts
|
|
198
|
+
declare const cliErrorCodes: readonly ["AGENT_NOT_FOUND", "AGENT_NOT_INSTALLED", "CANCELLED", "INSTALL_FAILED", "INTERACTION_REQUIRED", "INVALID_ARGUMENT", "MANUAL_ACTION_REQUIRED", "NETWORK_ERROR", "RESOURCE_LOCKED", "TIMEOUT", "UNINSTALL_FAILED", "UPDATE_FAILED", "UPGRADE_FAILED"];
|
|
199
|
+
type CliErrorCode = typeof cliErrorCodes[number];
|
|
200
|
+
declare function getExitCodeForError(code: CliErrorCode): number;
|
|
201
|
+
declare function getExitCodeForResult(result: Pick<CommandResult, 'ok' | 'error' | 'exitCode'>): number;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/output/types.d.ts
|
|
204
|
+
interface CommandTarget {
|
|
205
|
+
kind: 'agent' | 'config' | 'self' | 'system';
|
|
206
|
+
name?: string;
|
|
207
|
+
}
|
|
208
|
+
interface CommandWarning {
|
|
209
|
+
code: string;
|
|
210
|
+
details?: Record<string, unknown>;
|
|
211
|
+
message: string;
|
|
212
|
+
}
|
|
213
|
+
interface CommandError {
|
|
214
|
+
code: CliErrorCode;
|
|
215
|
+
details?: Record<string, unknown>;
|
|
216
|
+
message: string;
|
|
217
|
+
}
|
|
218
|
+
interface CommandMeta {
|
|
219
|
+
fetchedAt?: string;
|
|
220
|
+
mode: OutputMode;
|
|
221
|
+
runId: string;
|
|
222
|
+
schemaVersion: string;
|
|
223
|
+
source?: FreshnessSource;
|
|
224
|
+
staleAfter?: string;
|
|
225
|
+
timestamp: string;
|
|
226
|
+
version: string;
|
|
227
|
+
}
|
|
228
|
+
interface CommandResult<T = unknown> {
|
|
229
|
+
action: string;
|
|
230
|
+
data?: T;
|
|
231
|
+
error: CommandError | null;
|
|
232
|
+
exitCode?: number;
|
|
233
|
+
meta: CommandMeta;
|
|
234
|
+
ok: boolean;
|
|
235
|
+
target?: CommandTarget;
|
|
236
|
+
warnings: CommandWarning[];
|
|
237
|
+
}
|
|
238
|
+
type HumanRenderer<T> = (result: CommandResult<T>) => void;
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/commands/capabilities.d.ts
|
|
241
|
+
interface CapabilitiesData {
|
|
242
|
+
agents: string[];
|
|
243
|
+
features: {
|
|
244
|
+
assumeYes: boolean;
|
|
245
|
+
cacheBypass: boolean;
|
|
246
|
+
cacheRefresh: boolean;
|
|
247
|
+
channels: string[];
|
|
248
|
+
colorModes: string[];
|
|
249
|
+
dryRun: boolean;
|
|
250
|
+
execInstallPolicies: string[];
|
|
251
|
+
idempotencyKey: boolean;
|
|
252
|
+
freshnessMetadata: boolean;
|
|
253
|
+
logLevels: string[];
|
|
254
|
+
quietLogs: boolean;
|
|
255
|
+
selfUpgrade: boolean;
|
|
256
|
+
timeout: boolean;
|
|
257
|
+
};
|
|
258
|
+
installers: {
|
|
259
|
+
brew: {
|
|
260
|
+
available: boolean;
|
|
261
|
+
reason?: string;
|
|
262
|
+
};
|
|
263
|
+
bun: {
|
|
264
|
+
available: boolean;
|
|
265
|
+
reason?: string;
|
|
266
|
+
};
|
|
267
|
+
npm: {
|
|
268
|
+
available: boolean;
|
|
269
|
+
reason?: string;
|
|
270
|
+
};
|
|
271
|
+
winget: {
|
|
272
|
+
available: boolean;
|
|
273
|
+
reason?: string;
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
outputModes: string[];
|
|
277
|
+
platform: {
|
|
278
|
+
arch: string;
|
|
279
|
+
os: string;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
declare function capabilitiesCommand(): Promise<CommandResult<CapabilitiesData>>;
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/commands/commands.d.ts
|
|
285
|
+
interface CommandDescriptor {
|
|
286
|
+
flags: string[];
|
|
287
|
+
name: string;
|
|
288
|
+
outputSchemaRef: string;
|
|
289
|
+
stability: 'stable';
|
|
290
|
+
summary: string;
|
|
291
|
+
}
|
|
292
|
+
interface CommandsCommandData {
|
|
293
|
+
commands: CommandDescriptor[];
|
|
294
|
+
}
|
|
295
|
+
declare function commandsCommand(): Promise<CommandResult<CommandsCommandData>>;
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/commands/ensure.d.ts
|
|
298
|
+
interface EnsureCommandData {
|
|
299
|
+
agent: {
|
|
300
|
+
displayName: string;
|
|
301
|
+
name: string;
|
|
302
|
+
};
|
|
303
|
+
changed: boolean;
|
|
304
|
+
installState?: {
|
|
305
|
+
installType: string;
|
|
306
|
+
packageName?: string;
|
|
307
|
+
};
|
|
308
|
+
installed: boolean;
|
|
309
|
+
}
|
|
310
|
+
declare function ensureCommand(agentName: string): Promise<CommandResult<EnsureCommandData>>;
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/commands/exec.d.ts
|
|
313
|
+
type ExecInstallPolicy = 'always' | 'if-missing' | 'never';
|
|
314
|
+
interface ExecCommandOptions {
|
|
315
|
+
assumeYes?: boolean;
|
|
316
|
+
dryRun?: boolean;
|
|
317
|
+
install?: ExecInstallPolicy;
|
|
318
|
+
nonInteractive?: boolean;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/commands/inspect.d.ts
|
|
322
|
+
interface InspectCommandData {
|
|
323
|
+
agent: {
|
|
324
|
+
aliases: string[];
|
|
325
|
+
binaryName: string;
|
|
326
|
+
description: string;
|
|
327
|
+
displayName: string;
|
|
328
|
+
installMethods: Array<{
|
|
329
|
+
command: string;
|
|
330
|
+
label: string;
|
|
331
|
+
type: string;
|
|
332
|
+
}>;
|
|
333
|
+
name: string;
|
|
334
|
+
packageName?: string;
|
|
335
|
+
selfUpdateCommands: string[];
|
|
336
|
+
};
|
|
337
|
+
capabilities: {
|
|
338
|
+
canAutoInstall: boolean;
|
|
339
|
+
canAutoUninstall: boolean;
|
|
340
|
+
canRun: boolean;
|
|
341
|
+
canSelfUpdate: boolean;
|
|
342
|
+
};
|
|
343
|
+
inspection: {
|
|
344
|
+
binaryPath?: string;
|
|
345
|
+
installed: boolean;
|
|
346
|
+
installedVersion?: string;
|
|
347
|
+
latestVersion?: string;
|
|
348
|
+
lifecycle: 'managed' | 'unmanaged';
|
|
349
|
+
sourceLabel?: string;
|
|
350
|
+
updateLabel: string;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
declare function inspectCommand(agentName: string): Promise<CommandResult<InspectCommandData>>;
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/commands/resolve.d.ts
|
|
356
|
+
interface ResolveCommandData {
|
|
357
|
+
agent: {
|
|
358
|
+
binaryName: string;
|
|
359
|
+
displayName: string;
|
|
360
|
+
name: string;
|
|
361
|
+
};
|
|
362
|
+
resolution: {
|
|
363
|
+
binaryPath: string;
|
|
364
|
+
installSource: string;
|
|
365
|
+
installedVersion?: string;
|
|
366
|
+
lifecycle: 'managed' | 'unmanaged';
|
|
367
|
+
sourceLabel: string;
|
|
368
|
+
suggestedLaunchCommand: string[];
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
declare function resolveCommand(agentName: string): Promise<CommandResult<ResolveCommandData>>;
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/commands/schema.d.ts
|
|
374
|
+
interface JsonSchema {
|
|
375
|
+
additionalProperties?: boolean;
|
|
376
|
+
items?: JsonSchema;
|
|
377
|
+
properties?: Record<string, JsonSchema>;
|
|
378
|
+
required?: string[];
|
|
379
|
+
type: 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
|
|
380
|
+
}
|
|
381
|
+
interface SchemaDocument {
|
|
382
|
+
dataSchema: JsonSchema;
|
|
383
|
+
description: string;
|
|
384
|
+
envelopeSchema: JsonSchema;
|
|
385
|
+
name: string;
|
|
386
|
+
ndjsonEventSchema?: JsonSchema;
|
|
387
|
+
}
|
|
388
|
+
interface SchemaCommandData {
|
|
389
|
+
commands: SchemaDocument[];
|
|
390
|
+
}
|
|
391
|
+
declare function schemaCommand(commandName?: string): Promise<CommandResult<SchemaCommandData>>;
|
|
392
|
+
declare function getSchemaCatalog(): SchemaDocument[];
|
|
393
|
+
//#endregion
|
|
151
394
|
//#region src/config/index.d.ts
|
|
152
395
|
type NpmBunUpdateStrategy = 'latest-major' | 'respect-semver';
|
|
153
396
|
interface QuantexConfig {
|
|
@@ -180,6 +423,25 @@ interface AgentInspection {
|
|
|
180
423
|
declare function inspectAgent(agent: AgentDefinition): Promise<AgentInspection>;
|
|
181
424
|
declare function inspectAllAgents(agents: AgentDefinition[]): Promise<AgentInspection[]>;
|
|
182
425
|
//#endregion
|
|
426
|
+
//#region src/output/index.d.ts
|
|
427
|
+
interface CreateResultOptions<T> {
|
|
428
|
+
action: string;
|
|
429
|
+
data?: T;
|
|
430
|
+
error?: CommandError | null;
|
|
431
|
+
exitCode?: number;
|
|
432
|
+
ok: boolean;
|
|
433
|
+
target?: CommandTarget;
|
|
434
|
+
warnings?: CommandWarning[];
|
|
435
|
+
}
|
|
436
|
+
declare function createSuccessResult<T>(options: Omit<CreateResultOptions<T>, 'error' | 'ok'>): CommandResult<T>;
|
|
437
|
+
declare function createErrorResult<T>(options: Omit<CreateResultOptions<T>, 'ok'> & {
|
|
438
|
+
error: CommandError;
|
|
439
|
+
}): CommandResult<T>;
|
|
440
|
+
interface EmitBehaviorOptions {
|
|
441
|
+
force?: boolean;
|
|
442
|
+
}
|
|
443
|
+
declare function emitCommandResult<T>(result: CommandResult<T>, renderHuman: HumanRenderer<T>, behavior?: EmitBehaviorOptions): CommandResult<T>;
|
|
444
|
+
//#endregion
|
|
183
445
|
//#region src/package-manager/installers.d.ts
|
|
184
446
|
interface ManagedPackageSpec {
|
|
185
447
|
packageName: string;
|
|
@@ -349,4 +611,4 @@ declare function getInstalledVersion(binaryName: string, versionProbe?: AgentVer
|
|
|
349
611
|
declare function getLatestVersion(packageName: string, distTag?: string): Promise<string | undefined>;
|
|
350
612
|
declare function getBinaryPath(binaryName: string): Promise<string | undefined>;
|
|
351
613
|
//#endregion
|
|
352
|
-
export { type AgentDefinition, type AgentInspection, type AgentOperationResult, type AgentPackageMetadata, type AgentSelfUpdate, type AgentUpdateContext, type AgentUpdateProvider, type AgentUpdateStrategy, type AgentVersionProbe, type BinaryInstallMethod, type InstallMethod, type InstallType, type InstalledAgentState, type ManagedInstallMethod, type ManagedInstallType, type ManagedInstaller, type ManagedPackageSpec, type ManagedUpdateBucket, type PackageTargetKind, type PendingAgentUpdate, type PlannedAgentUpdates, type Platform, type QuantexConfig, type QuantexState, type ReleaseArtifactTarget, type ReleaseChannel, type ReleaseManifest, type ReleaseManifestAsset, type ResolvedAgentInspection, type ScriptInstallMethod, type SelfInspection, type SelfInstallSource, type SelfState, type SelfUpdateResult, type SingleAgentUpdateStatus, type UpdatePlan, type UpdatePlanEntry, agentUpdateProviders, canAutoUpdateSelf, canLookupLatestVersionForInstallType, canResolveAgentUpdate, canUninstallInstallType, canUpdateInstallType, claude, codex, copilot, createReleaseManifest, createUpdatePlan, cursor, detectSelfInstallSource, droid, execCommand, formatChecksums, gemini, getAgentByLookupName, getAgentByNameOrAlias, getAgentUpdateFailureHint, getAgentUpdateStrategy, getAllAgents, getBinaryPath, getBinaryReleaseAssetName, getBinaryReleaseDownloadUrl, getConfigDir, getConfigFilePath, getInstallLifecycle, getInstalledAgentState, getInstalledVersion, getInstallerCapabilities, getLatestVersion, getManagedInstaller, getManualAgentUpdateMessage, getManualSelfUpgradeCommand, getOrderedInstallMethods, getPlatform, getSelfState, getSelfUpgradeRecoveryHint, getSelfUpgradeRecoveryHintForInspection, getSelfVersion, getSingleAgentUpdateStatus, getStateFilePath, inspectAgent, inspectAllAgents, inspectRegisteredAgents, inspectSelf, installAgent, isBinaryInPath, isBunAvailable, isInspectionUpdateAvailable, isManagedInstallType, isNpmAvailable, loadConfig, loadState, normalizeRepositoryUrl, opencode, parseBinaryTarget, parseChecksums, pi, planAgentUpdates, removeInstalledAgentState, resolveAgent, resolveAgentInspection, resolveAgentUpdateProvider, resolveReleaseChannel, saveConfig, saveState, setInstalledAgentState, setSelfInstallSource, uninstallAgent, updateAgent, updateAgentsByType, upgradeSelf, validateReleaseManifest };
|
|
614
|
+
export { type AgentDefinition, type AgentInspection, type AgentOperationResult, type AgentPackageMetadata, type AgentSelfUpdate, type AgentUpdateContext, type AgentUpdateProvider, type AgentUpdateStrategy, type AgentVersionProbe, type BinaryInstallMethod, type CliContext, type CliContextOptions, type CliErrorCode, type CommandError, type CommandMeta, type CommandResult, type CommandTarget, type CommandWarning, type ExecCommandOptions, type ExecInstallPolicy, type HumanRenderer, type InstallMethod, type InstallType, type InstalledAgentState, type ManagedInstallMethod, type ManagedInstallType, type ManagedInstaller, type ManagedPackageSpec, type ManagedUpdateBucket, type OutputMode, type PackageTargetKind, type PendingAgentUpdate, type PlannedAgentUpdates, type Platform, type QuantexConfig, type QuantexState, type ReleaseArtifactTarget, type ReleaseChannel, type ReleaseManifest, type ReleaseManifestAsset, type ResolvedAgentInspection, type ScriptInstallMethod, type SelfInspection, type SelfInstallSource, type SelfState, type SelfUpdateResult, type SingleAgentUpdateStatus, type UpdatePlan, type UpdatePlanEntry, agentUpdateProviders, canAutoUpdateSelf, canLookupLatestVersionForInstallType, canResolveAgentUpdate, canUninstallInstallType, canUpdateInstallType, capabilitiesCommand, claude, codex, commandsCommand, copilot, createErrorResult, createReleaseManifest, createSuccessResult, createUpdatePlan, cursor, detectSelfInstallSource, droid, emitCommandResult, ensureCommand, execCommand, formatChecksums, gemini, getAgentByLookupName, getAgentByNameOrAlias, getAgentUpdateFailureHint, getAgentUpdateStrategy, getAllAgents, getBinaryPath, getBinaryReleaseAssetName, getBinaryReleaseDownloadUrl, getCliContext, getConfigDir, getConfigFilePath, getExitCodeForError, getExitCodeForResult, getInstallLifecycle, getInstalledAgentState, getInstalledVersion, getInstallerCapabilities, getLatestVersion, getManagedInstaller, getManualAgentUpdateMessage, getManualSelfUpgradeCommand, getOrderedInstallMethods, getPlatform, getSchemaCatalog, getSelfState, getSelfUpgradeRecoveryHint, getSelfUpgradeRecoveryHintForInspection, getSelfVersion, getSingleAgentUpdateStatus, getStateFilePath, inspectAgent, inspectAllAgents, inspectCommand, inspectRegisteredAgents, inspectSelf, installAgent, isBinaryInPath, isBunAvailable, isInspectionUpdateAvailable, isManagedInstallType, isNpmAvailable, loadConfig, loadState, normalizeRepositoryUrl, opencode, parseBinaryTarget, parseChecksums, pi, planAgentUpdates, removeInstalledAgentState, resetCliContext, resolveAgent, resolveAgentInspection, resolveAgentUpdateProvider, resolveCliContext, resolveCommand, resolveReleaseChannel, saveConfig, saveState, schemaCommand, setCliContext, setInstalledAgentState, setSelfInstallSource, uninstallAgent, updateAgent, updateAgentsByType, upgradeSelf, validateReleaseManifest };
|
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-
|
|
2
|
-
`)}\n`}function
|
|
1
|
+
import{a as e,i as t,n,o as r,s as i,t as a}from"./update-d-egOW3q.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-Cag2AZCY.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-D1aRiz7E.mjs";import{t as Ee}from"./capabilities-B3ffggvz.mjs";import{t as De}from"./commands-CwZpvRp0.mjs";import{t as Oe}from"./ensure-COQzNBEp.mjs";import{t as ke}from"./inspect-CJnn0eG8.mjs";import{t as Ae}from"./resolve-BCqc_ZL8.mjs";import{n as X,t as je}from"./schema-C4Mbbl2a.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,r as t,v as n}from"./agents-Cag2AZCY.mjs";import{a as r,n as i,r as a,t as o}from"./color-D1aRiz7E.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
|
+
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,3 @@
|
|
|
1
|
+
import{_ as e,r as t,v as n}from"./agents-Cag2AZCY.mjs";import{a as r,n as i,r as a,t as o}from"./color-D1aRiz7E.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
|
+
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
|
+
Install Methods:`));for(let t of e.data.agent.installMethods)console.log(` ${o.green(`+`)} [${t.label}] ${t.command}`);console.log()}}export{s as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./inspect-CJnn0eG8.mjs";export{e as inspectCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,s as t}from"./agents-Cag2AZCY.mjs";import{L as n,a as r,i,n as a,r as o,t as s}from"./color-D1aRiz7E.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-Dj9auSeW.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t){return{error:{code:`RESOURCE_LOCKED`,details:{lockPath:e.lockPath,resource:e.resource},message:e.message},target:t}}export{e as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"./agents-Cag2AZCY.mjs";import{a as t,r as n,t as r}from"./color-D1aRiz7E.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
|
+
AI Agents:
|
|
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};
|
package/dist/postinstall.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdir as
|
|
1
|
+
import e from"node:process";import{mkdir as t,readFile as n,writeFile as r}from"node:fs/promises";import{dirname as i,join as a}from"node:path";import{homedir as o}from"node:os";function s(t=e.env){if(!f(t))return;let n=t.npm_config_user_agent?.toLowerCase()??``;if(n.startsWith(`bun/`))return`bun`;if(n.startsWith(`npm/`))return`npm`}async function c(t=e.env){let n=s(t);return n?(await l(n,t),!0):!1}async function l(n,a=e.env){let o=u(a),s=await m(o);s.installedAgents??={},s.self??={},s.self.installSource=n,await t(i(o),{recursive:!0}),await r(o,`${JSON.stringify(s,null,2)}\n`,`utf8`)}function u(t=e.env){return a(d(t),`state.json`)}function d(t=e.env){return a(p(t),`.quantex`)}function f(e){return e.npm_config_global===`true`||e.npm_config_location===`global`}function p(e){return e.HOME||e.USERPROFILE||o()}async function m(e){try{return JSON.parse(await n(e,`utf8`))}catch{return{}}}h();async function h(){try{await c(e.env)}catch{}}export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./agents-Cag2AZCY.mjs";import{a as t,n,r,t as i}from"./color-D1aRiz7E.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./resolve-BCqc_ZL8.mjs";export{e as resolveCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e,n as t,r as n,t as r}from"./color-D1aRiz7E.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./schema-C4Mbbl2a.mjs";export{e as schemaCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,n as t}from"./agents-Cag2AZCY.mjs";import{L as n,a as r,k as i,n as a,r as o,t as s}from"./color-D1aRiz7E.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-Dj9auSeW.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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e,h as t,i as n,t as r,y as i}from"./agents-Cag2AZCY.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,r as n,s as r}from"./update-d-egOW3q.mjs";import{S as i,g as a,l as o,m as s,n as c,u as l}from"./agents-Cag2AZCY.mjs";import{L as u,a as d,i as f,n as p,r as m,t as h}from"./color-D1aRiz7E.mjs";import{a as g,i as _,n as v,r as y}from"./user-output-Dj9auSeW.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,d as t,n,p as r,r as i,t as a,u as o}from"./color-D1aRiz7E.mjs";import{a as s,i as c,n as l,r as u}from"./user-output-Dj9auSeW.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{K as e}from"./color-D1aRiz7E.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
package/dist/agents-BALRvoqc.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./config-DWeRAIFV.mjs";import{_ as t,a as n,c as r,d as i,f as a,l as o,n as ee,o as te,p as s,r as ne,s as re,t as ie,u as ae,y as c}from"./version-CrMPGstC.mjs";import l from"node:process";const oe={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 u(e){return oe[e]}function d(e){return u(e).lifecycle===`managed`}function f(e){return u(e).lifecycle}function p(e){return u(e).canUpdate}function se(e){return u(e).canUninstall}function m(e){return u(e).canLookupLatestVersion}function ce(e,t){return e?t===`cask`?` (${e} cask)`:t===`id`?` (${e} id)`:` (${e})`:``}function h(e,t){return t.packageName||e.packages?.npm||void 0}function le(e){return e?p(e.installType):!1}function ue(e,t){return le(t)||!!e.selfUpdate}function de(e){return!!e&&m(e.installType)}function fe(e){return e.length>0&&e.every(e=>m(e.type))}function pe(e){return d(e.type)?`${f(e.type)}/${e.type}${ce(e.packageName,e.packageTargetKind)}`:e.type===`script`?`unmanaged/script`:`unmanaged/binary`}function me(e){return e?d(e.installType)?`managed via ${e.installType}${ce(e.packageName,e.packageTargetKind)}`:e.installType===`script`?`script installer`:`binary installer`:`detected in PATH`}function he(e,t){let n=b({agent:e,installedState:t,methods:[]});return n===`managed`?`managed update`:n===`self-update`?`command update`:`manual update`}function ge(e,t){if(t.type===`bun`){let n=h(e,t);return n?`bun add -g ${n}`:``}if(t.type===`npm`){let n=h(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 _e(e,t,n){if(t)return de(t)&&(t.packageName||e.packages?.npm)||void 0;if(!(!e.packages?.npm||!fe(n)))return e.packages.npm}function g(e){if(e.installedState&&d(e.installedState.installType))return e.installedState.installType;for(let t of e.methods)if(d(t.type)&&p(t.type))return t.type}const ve={strategy:`managed`,canHandle:e=>!!g(e),getManagedInstallerType:e=>g(e)},ye={strategy:`self-update`,canHandle:e=>!le(e.installedState)&&!!e.agent.selfUpdate},_={strategy:`manual-hint`,canHandle:()=>!0},v=[ve,ye,_];function y(e){return v.find(t=>t.canHandle(e))??_}function b(e){return y(e).strategy}function be(e){return ue(e.agent,e.installedState)}function x(e){return{packageName:e,type:`bun`}}function S(e){return{packageName:e,type:`npm`}}function C(e,t){return{packageName:e,packageTargetKind:t,type:`brew`}}function w(e){return{packageName:e,packageTargetKind:`id`,type:`winget`}}function T(e){return{command:e,type:`script`}}const E={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:[x(),S(),T(`irm https://claude.ai/install.ps1 | iex`),w(`Anthropic.ClaudeCode`)],macos:[x(),S(),T(`curl -fsSL https://claude.ai/install.sh | bash`),C(`claude-code`,`cask`)],linux:[x(),S(),T(`curl -fsSL https://claude.ai/install.sh | bash`),C(`claude-code`,`cask`)]}},D={name:`codex`,displayName:`Codex CLI`,description:`OpenAI 官方 AI 编程助手 CLI`,homepage:`https://developers.openai.com/codex`,packages:{npm:`@openai/codex`},binaryName:`codex`,platforms:{windows:[x(),S()],macos:[x(),S(),C(`codex`)],linux:[x(),S(),C(`codex`)]}},O={name:`copilot`,displayName:`GitHub Copilot CLI`,description:`GitHub Copilot 命令行工具`,homepage:`https://github.com/features/copilot/cli`,packages:{npm:`@github/copilot`},binaryName:`copilot`,platforms:{windows:[w(`GitHub.Copilot`)],macos:[x(),S(),T(`curl -fsSL https://gh.io/copilot-install | bash`),C(`copilot-cli`)],linux:[x(),S(),T(`curl -fsSL https://gh.io/copilot-install | bash`),C(`copilot-cli`)]}},k={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:[T(`irm 'https://cursor.com/install?win32=true' | iex`)],macos:[T(`curl https://cursor.com/install -fsS | bash`)],linux:[T(`curl https://cursor.com/install -fsS | bash`)]}},A={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:[x(),S(),T(`irm https://app.factory.ai/cli/windows | iex`)],macos:[x(),S(),T(`curl -fsSL https://app.factory.ai/cli | sh`),C(`droid`,`cask`)],linux:[x(),S(),T(`curl -fsSL https://app.factory.ai/cli | sh`),C(`droid`,`cask`)]}},j={name:`gemini`,displayName:`Gemini CLI`,description:`Google 开源 AI 编程助手 CLI`,homepage:`https://geminicli.com`,packages:{npm:`@google/gemini-cli`},binaryName:`gemini`,platforms:{windows:[x(),S()],macos:[x(),S(),C(`gemini-cli`)],linux:[x(),S(),C(`gemini-cli`)]}},M={name:`opencode`,displayName:`OpenCode`,description:`开源 AI 编程 CLI`,homepage:`https://opencode.ai`,packages:{npm:`opencode-ai`},binaryName:`opencode`,platforms:{windows:[x(),S()],macos:[x(),S(),T(`curl -fsSL https://opencode.ai/install | bash`),C(`anomalyco/tap/opencode`)],linux:[x(),S(),T(`curl -fsSL https://opencode.ai/install | bash`),C(`anomalyco/tap/opencode`)]}},N={name:`pi`,displayName:`Pi`,description:`极简可扩展的终端编程 Agent`,homepage:`https://pi.dev`,packages:{npm:`@mariozechner/pi-coding-agent`},binaryName:`pi`,platforms:{windows:[x(),S()],macos:[x(),S()],linux:[x(),S()]}},xe=[E,D,O,k,A,j,M,N];function P(){return xe}function F(e){return xe.find(t=>t.name===e||(t.lookupAliases?.includes(e)??!1))}function I(e){return F(e)}function L(){switch(l.platform){case`win32`:return`windows`;case`darwin`:return`macos`;default:return`linux`}}async function R(e){try{let t=Bun.spawn([e,`--version`],{stdout:`pipe`,stderr:`pipe`});return await t.exited,t.exitCode===0}catch{return!1}}async function z(){return R(`bun`)}async function B(){return R(`npm`)}async function V(){return R(`brew`)}async function H(){return R(`winget`)}async function U(e){try{let t=l.platform===`win32`?`where`:`which`,n=Bun.spawn([t,e],{stdout:`pipe`,stderr:`pipe`});return await n.exited,n.exitCode===0}catch{return!1}}async function W(e){let t=L(),n=typeof e==`function`?e(t):e;try{let e;return e=l.platform===`win32`?Bun.spawn([`powershell.exe`,`-Command`,n],{stdio:[`inherit`,`inherit`,`inherit`]}):Bun.spawn([`sh`,`-c`,n],{stdio:[`inherit`,`inherit`,`inherit`]}),await e.exited,e.exitCode===0}catch{return!1}}function Se(e){return e===`cask`?[`--cask`]:[]}async function G(e,t,n){try{let r=Bun.spawn([`brew`,e,...Se(n),t],{stdio:[`inherit`,`inherit`,`inherit`]});return await r.exited,r.exitCode===0}catch{return!1}}async function Ce(e,t){return G(`install`,e,t)}async function K(e,t){return G(`upgrade`,e,t)}async function we(e){for(let t of e)if(!await K(t.packageName,t.packageTargetKind))return!1;return!0}async function Te(e,t){return G(`uninstall`,e,t)}async function q(e,t){try{let n=Bun.spawn([`winget`,e,`--id`,t,`-e`],{stdio:[`inherit`,`inherit`,`inherit`]});return await n.exited,n.exitCode===0}catch{return!1}}async function Ee(e){return q(`install`,e)}async function De(e){return q(`upgrade`,e)}async function Oe(e){for(let t of e)if(!await De(t.packageName))return!1;return!0}async function ke(e){return q(`uninstall`,e)}const Ae={brew:{type:`brew`,isAvailable:async()=>V(),install:async(e,t)=>Ce(e,t),uninstall:async(e,t)=>Te(e,t),update:async(e,t)=>K(e,t),updateMany:async e=>we(e)},bun:{type:`bun`,isAvailable:async()=>z(),install:async e=>o(e),uninstall:async e=>ae(e),update:async(e,t,n)=>i(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>a(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},npm:{type:`npm`,isAvailable:async()=>B(),install:async e=>n(e),uninstall:async e=>te(e),update:async(e,t,n)=>re(e,n?.npmBunUpdateStrategy),updateMany:async(e,t)=>r(e.map(e=>e.packageName),t?.npmBunUpdateStrategy)},winget:{type:`winget`,isAvailable:async()=>H(),install:async e=>Ee(e),uninstall:async e=>ke(e),update:async e=>De(e),updateMany:async e=>Oe(e.map(e=>({packageName:e.packageName})))}};function J(e){return Ae[e]}async function je(){return(await e()).defaultPackageManager}async function Me(){return{npmBunUpdateStrategy:(await e()).npmBunUpdateStrategy}}async function Y(e){let t=L(),n=e.platforms[t];if(!n)return[];let r=await je();return r?[...n.filter(e=>e.type===r),...n.filter(e=>e.type!==r)]:[...n]}async function Ne(e,t,n,r,i){let a=J(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 X(e,t,n,r){if(d(t.type)){let i=h(e,t);return i?Ne(t.type,i,t.packageTargetKind,n,r):!1}return n===`update`&&!p(t.type)||!t.command?!1:W(t.command)}async function Pe(e,t,n){return d(e.installType)?e.packageName?Ne(e.installType,e.packageName,e.packageTargetKind,t,n):!1:t!==`install`||!e.command?!1:W(e.command)}async function Fe(e){if(!e.selfUpdate)return!1;let t=[e.selfUpdate.command,...e.selfUpdate.fallbackCommands??[]];for(let e of t)if(await W(e.join(` `)))return!0;return!1}async function Z(e,t){let n={agentName:e.name,installType:t.type,packageName:h(e,t),packageTargetKind:t.packageTargetKind,command:`command`in t?t.command:void 0};return await c(n),n}async function Ie(e){let t=await Y(e);for(let n of t)if(await X(e,n,`install`))return{success:!0,installedState:await Z(e,n)};return{success:!1}}async function Le(e,t){let{npmBunUpdateStrategy:n}=await Me(),r=await Y(e);if(t&&await Pe(t,`update`,n))return await c(t),{success:!0,installedState:t};if(!t){for(let t of r)if(await X(e,t,`update`,n))return{success:!0,installedState:await Z(e,t)}}if(await Fe(e))return{success:!0};if(t){for(let t of r)if(await X(e,t,`update`,n))return{success:!0,installedState:await Z(e,t)}}return{success:!1}}async function Re(e,t){let n=[...new Map(t.filter(e=>e.packageName).map(e=>[`${e.packageTargetKind??`package`}:${e.packageName}`,e])).values()],r=J(e);return await r.isAvailable()?r.updateMany(n,await Me()):!1}async function ze(e){let n=await s(e.name);if(!n)return!1;let r=await Pe(n,`uninstall`);return r&&await t(e.name),r}async function Q(e){let[t,n,r]=await Promise.all([Y(e),s(e.name),U(e.binaryName)]),[i,a,o]=await Promise.all([r?ee(e.binaryName,e.versionProbe):Promise.resolve(void 0),r?ie(e.binaryName):Promise.resolve(void 0),Ve(e,n,t)]);return{agent:e,methods:t,installedState:n,inPath:r,installedVersion:i,latestVersion:o,binaryPath:a,sourceLabel:me(n),updateLabel:he(e,n),lifecycle:n?f(n.installType):`unmanaged`}}async function Be(e){return Promise.all(e.map(Q))}async function Ve(e,t,n){let r=_e(e,t,n);if(r)return ne(r)}function $(e){return I(e)}async function He(e){let t=$(e);if(t)return{agent:t,inspection:await Q(t)}}async function Ue(){return Be(P())}export{be as A,f as B,j as C,D,O as E,pe as F,d as H,h as I,m as L,y as M,ue as N,E as O,ge as P,se as R,M as S,k as T,u as V,H as _,Be as a,P as b,ze as c,J as d,L as f,B as g,z as h,Q as i,b as j,v as k,Le as l,V as m,$ as n,Y as o,U as p,He as r,Ie as s,Ue as t,Re as u,F as v,A as w,N as x,I as y,p as z};
|
package/dist/config-B1BACpEg.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,o as n,r}from"./config-DWeRAIFV.mjs";import i from"picocolors";async function a(a,o,s){if(!a){let e=await t();console.log(i.bold(`
|
|
2
|
-
Current Configuration:
|
|
3
|
-
`)),console.log(JSON.stringify(e,null,2)),console.log();return}switch(a){case`get`:{if(!o){console.log(i.red(`Please specify a key`));return}let e=(await t())[o];console.log(e===void 0?i.gray(`(not set)`):String(e));break}case`set`:{if(!o||s===void 0){console.log(i.red(`Please specify both key and value`));return}if(o===`defaultPackageManager`&&s!==`bun`&&s!==`npm`){console.log(i.red(`defaultPackageManager must be bun or npm`));return}if(o===`npmBunUpdateStrategy`&&!r(s)){console.log(i.red(`npmBunUpdateStrategy must be latest-major or respect-semver`));return}if(o===`selfUpdateChannel`&&s!==`stable`&&s!==`beta`){console.log(i.red(`selfUpdateChannel must be stable or beta`));return}if([`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(o)){let e=Number.parseInt(s,10);if(!Number.isInteger(e)||e<=0){console.log(i.red(`${o} must be a positive integer`));return}s=`${e}`}let n={};try{n=await t()}catch{}n[o]=[`networkRetries`,`networkTimeoutMs`,`versionCacheTtlHours`].includes(o)?Number.parseInt(s,10):s,await e(n),console.log(i.green(`Set ${o} = ${s}`));break}case`reset`:await e(n),console.log(i.green(`Configuration reset to defaults.`));break;default:console.log(i.red(`Unknown action: ${a}`)),console.log(`Available actions: get, set, reset`)}}export{a as configCommand};
|
package/dist/config-DWeRAIFV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{mkdir as e,readFile as t}from"node:fs/promises";import{homedir as n}from"node:os";import{join as r}from"node:path";import i from"node:process";import{pathToFileURL as a}from"node:url";import{loadConfig as o}from"c12";const s={defaultPackageManager:`bun`,networkRetries:2,networkTimeoutMs:1e4,npmBunUpdateStrategy:`latest-major`,selfUpdateChannel:`stable`,versionCacheTtlHours:6};function c(){return r(i.env.HOME||i.env.USERPROFILE||n(),`.quantex`)}function l(){return r(c(),`config.json`)}async function u(){let{config:e}=await o({name:`quantex`,defaults:s,configFile:l(),jiti:{import:async(e,n)=>{if(e.endsWith(`.json`))return JSON.parse(await t(e,`utf8`));let r=await(e.startsWith(`file:`)?import(e):import(a(e).href));return n?.default?r.default??r:r}}}),n=e;return{...n,defaultPackageManager:n.defaultPackageManager===`npm`?`npm`:`bun`,networkRetries:p(n.networkRetries,2),networkTimeoutMs:p(n.networkTimeoutMs,1e4),npmBunUpdateStrategy:n.npmBunUpdateStrategy===`respect-semver`?`respect-semver`:`latest-major`,selfUpdateChannel:n.selfUpdateChannel===`beta`?`beta`:`stable`,versionCacheTtlHours:p(n.versionCacheTtlHours,6)}}function d(e){return e===`latest-major`||e===`respect-semver`}async function f(t){await e(c(),{recursive:!0}),await Bun.write(l(),`${JSON.stringify(t,null,2)}\n`)}function p(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}export{f as a,u as i,l as n,s as o,d as r,c as t};
|
package/dist/doctor-C3MeTdcd.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{_ as e,g as t,h as n,m as r,t as i}from"./agents-BALRvoqc.mjs";import{a,c as o}from"./self-Bj9L_tIu.mjs";import s from"picocolors";async function c(){console.log(s.bold(`
|
|
2
|
-
Quantex CLI Environment Check
|
|
3
|
-
`)),console.log(s.bold(`Managed Installers:`));let c=await n();console.log(` Bun: ${c?s.green(`available`):s.red(`not found`)}`);let l=await t();console.log(` npm: ${l?s.green(`available`):s.red(`not found`)}`);let u=await r();console.log(` brew: ${u?s.green(`available`):s.red(`not found`)}`);let d=await e();console.log(` winget:${d?s.green(`available`):s.red(`not found`)}`);let f=await a(),p=f.latestVersion&&f.latestVersion!==f.currentVersion;if(console.log(`\n${s.bold(`Quantex CLI:`)}`),console.log(` Version: ${f.currentVersion}`),console.log(` Source: ${f.installSource}`),console.log(` Auto-update: ${f.canAutoUpdate?s.green(`supported`):s.yellow(`unsupported`)}`),f.latestVersion&&console.log(` Latest: ${f.latestVersion}${p?s.yellow(` (update available)`):``}`),p){let e=o(f);e&&console.log(` Recovery: ${e}`)}console.log(`\n${s.bold(`Installed Agents:`)}`);let m=await i(),h=!1;for(let e of m)if(e.inPath){h=!0;let t=e.installedVersion&&e.latestVersion&&e.installedVersion!==e.latestVersion;console.log(` ${e.agent.displayName}: ${e.installedVersion??`unknown`} [${e.lifecycle}; ${e.sourceLabel}]${t?s.yellow(` (update available: ${e.latestVersion})`):``}`)}h||console.log(s.dim(` No agents installed`)),console.log(`\n${s.bold(`Issues:`)}`);let g=[];if(!c&&!l&&!u&&!d&&g.push(`No managed installer found. Install bun, npm, brew, or winget.`),g.length===0)console.log(s.green(` No issues found.`));else for(let e of g)console.log(s.yellow(` - ${e}`));console.log()}export{c as doctorCommand};
|
package/dist/info-m8Pm4m7N.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{F as e,P as t,r as n}from"./agents-BALRvoqc.mjs";import r from"picocolors";async function i(i){let a=await n(i);if(!a){console.log(r.red(`Unknown agent: ${i}`));return}let{agent:o,inspection:s}=a;console.log(r.bold(`\n${o.displayName}\n`)),console.log(` Name: ${o.name}`),console.log(` Aliases: ${o.lookupAliases?.join(`, `)??`-`}`),console.log(` Description: ${o.description}`),console.log(` Package: ${o.packages?.npm??`-`}`),console.log(` Binary: ${o.binaryName}`);let c=o.selfUpdate?[o.selfUpdate.command,...o.selfUpdate.fallbackCommands??[]].map(e=>e.join(` `)).join(` || `):`-`;console.log(` Update: ${c}`),console.log(` Installed: ${s.inPath?r.green(`Yes`):r.red(`No`)}`),s.inPath&&console.log(` Source: ${s.sourceLabel}`),s.installedState&&console.log(` Lifecycle: ${s.lifecycle}`),s.installedVersion&&console.log(` Version: ${s.installedVersion}`),s.latestVersion&&console.log(` Latest: ${s.latestVersion}`),s.binaryPath&&console.log(` Path: ${s.binaryPath}`),console.log(r.bold(`
|
|
2
|
-
Install Methods:`));for(let n of s.methods)console.log(` ${r.green(`+`)} [${e(n)}] ${t(o,n)}`);console.log()}export{i as infoCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,s as t}from"./agents-BALRvoqc.mjs";import n from"picocolors";async function r(r){let i=await e(r);if(!i){console.log(n.red(`Unknown agent: ${r}`));return}let{agent:a,inspection:o}=i;if(o.inPath){console.log(n.yellow(`${a.displayName} is already installed.`));return}console.log(n.cyan(`Installing ${a.displayName}...`)),(await t(a)).success?console.log(n.green(`${a.displayName} installed successfully!`)):console.log(n.red(`Failed to install ${a.displayName}.`))}export{r as installCommand};
|
package/dist/list-C3iiju9D.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./agents-BALRvoqc.mjs";import t from"picocolors";async function n(){let n=await e();console.log(t.bold(`
|
|
2
|
-
AI Agents:
|
|
3
|
-
`));for(let e of n){let n=e.agent.displayName.padEnd(18),r=e.inPath?t.green(`installed`):t.gray(`not installed`),i=e.inPath?t.dim(e.installedVersion??`unknown version`):``,a=e.inPath?t.cyan(e.updateLabel):``,o=e.inPath?t.dim(e.sourceLabel):``;console.log(` ${n} ${r} ${i}${a?` ${a}`:``}${o?` ${o}`:``}`)}console.log()}export{n as listCommand};
|
package/dist/self-Bj9L_tIu.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./config-DWeRAIFV.mjs";import{b as n,d as r,i,m as a,r as o,s}from"./version-CrMPGstC.mjs";import{chmod as c,mkdir as l,mkdtemp as u,readFile as d,rename as f,rm as p,stat as m,writeFile as h}from"node:fs/promises";import{basename as g,dirname as _,join as v}from"node:path";import y from"node:process";import{fileURLToPath as b}from"node:url";import{Buffer as x}from"node:buffer";import{createHash as S}from"node:crypto";const C=`quantex-cli`,w=`https://github.com/Drswith/quantex-cli`,T=`0.0.1`;function E(){return v(t(),`locks`,`self-upgrade.lock`)}async function D(){let e=E();await l(_(e),{recursive:!0});try{await l(e,{recursive:!1})}catch(e){if(typeof e==`object`&&e&&`code`in e&&e.code===`EEXIST`)return;throw e}return async()=>{await p(e,{force:!0,recursive:!0})}}async function ee(e,t,n,r){let i;try{i=await fetch(e)}catch(t){return A(`network`,`Failed to download ${e}.`,t)}if(!i.ok)return A(`network`,`Failed to download ${e}: HTTP ${i.status}.`);let a=await u(v(_(t),`.quantex-upgrade-`)),o=v(a,g(t)),s=`${t}.bak`;try{let l=x.from(await i.arrayBuffer()),u=await te(t),d=ie(l);if(d!==N(n))return A(`checksum`,`Checksum mismatch for ${e}. Expected ${N(n)}, got ${d}.`);if(await h(o,l),y.platform===`win32`)return ne(o,t,s,a,r);await c(o,u),await p(s,{force:!0}),await f(t,s),await f(o,t);let m=await re(t,r);return m.success?(await p(s,{force:!0}),{success:!0}):(await M(s,t),m)}catch(e){return A(j(e),`Failed to replace the current Quantex binary.`,e)}finally{y.platform!==`win32`&&await p(a,{recursive:!0,force:!0})}}async function te(e){try{return(await m(e)).mode&511}catch{return 493}}function ne(e,t,n,r,i){try{let a=O(e,t,n,r,y.pid,i);return Bun.spawn([`powershell.exe`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-WindowStyle`,`Hidden`,`-Command`,a],{stdio:[`ignore`,`ignore`,`ignore`],windowsHide:!0}).unref?.(),{success:!0}}catch(e){return A(`locked`,`Failed to schedule Windows binary replacement.`,e)}}function O(e,t,n,r,i,a){let o=k(e),s=k(t),c=k(n),l=k(r),u=k(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 k(e){return e.replaceAll(`'`,`''`)}function A(e,t,n){return{error:{detail:n,kind:e,message:t},success:!1}}function j(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 M(e,t){await p(t,{force:!0}),await f(e,t)}async function re(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}:A(`verify`,`The upgraded Quantex binary reported an unexpected version during verification.`):A(`verify`,`The upgraded Quantex binary exited with code ${i} during verification.`)}catch(e){return A(`verify`,`Failed to execute the upgraded Quantex binary for verification.`,e)}}function ie(e){return S(`sha256`).update(e).digest(`hex`)}function N(e){return e.trim().toLowerCase()}function P(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function F(e=y.execPath){if(g(P(e)).endsWith(`.exe`))return`quantex-windows-x64.exe`;if(y.platform===`darwin`)return y.arch===`arm64`?`quantex-darwin-arm64`:`quantex-darwin-x64`;if(y.platform===`linux`)return y.arch===`arm64`?`quantex-linux-arm64`:`quantex-linux-x64`}function I(e=y.execPath){let t=F(e);if(t)return`${w}/releases/latest/download/${t}`}function L(e,t,n=y.env){return e||(n.QUANTEX_UPDATE_CHANNEL===`beta`?`beta`:n.QUANTEX_UPDATE_CHANNEL===`stable`?`stable`:t===`beta`?`beta`:`stable`)}async function R(e){let t=await i(await z(e),`self:manifest:${e}`);if(!t)throw Error(`Failed to download release manifest.`);return t}async function z(e){if(e===`stable`)return`${w}/releases/latest/download/manifest.json`;let t=(await B(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 B(e){let t=H();if(!t)throw Error(`Failed to resolve the GitHub repository slug for Quantex releases.`);let n=await i(`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 V(e,t=y.execPath){let n=y.platform,r=y.arch===`arm64`?`arm64`:`x64`,i=F(t);return e.assets.find(e=>e.platform===n&&e.arch===r&&(!i||e.name===i))}function H(){return w.match(/github\.com\/([^/]+\/[^/]+)$/)?.[1]}const U={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):I(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(!F(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 R(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=V(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 ee(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}}},W={source:`bun`,canHandle:e=>e.installSource===`bun`,getRecoveryHint:e=>`bun add -g ${C}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await r(C,`latest-major`,e.updateChannel===`beta`?`beta`:`latest`);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${C} through Bun.`},installSource:e.installSource,newVersion:t?e.latestVersion:void 0,success:t}}},G={source:`npm`,canHandle:e=>e.installSource===`npm`,getRecoveryHint:e=>`npm install -g ${C}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e){let t=await s(C,`latest-major`,e.updateChannel===`beta`?`beta`:`latest`);return{error:t?void 0:{kind:`unknown`,message:`Failed to update ${C} through npm.`},installSource:e.installSource,newVersion:t?e.latestVersion:void 0,success:t}}},K={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}}},q=[W,G,U,K];function ae(e){return q.find(t=>t.canHandle(e))??K}function J(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 ${C}@${n===`beta`?`beta`:`latest`}`;if(e===`npm`)return`npm install -g ${C}@${n===`beta`?`beta`:`latest`}`;if(e===`binary`){let e=I(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 oe(e,t){return J(e.installSource,e.executablePath,e.updateChannel,t)}const Y=C,se=`/node_modules/${Y}`;async function X(t){let n=await ue(),r=y.execPath,i=n.foundPackageJson?Q(n.packageRoot):Q(``,r),o=await le((await a()).installSource,i),s=await e(),c=L(t?.updateChannel,s.selfUpdateChannel),l=await pe(o,r,c);return{canAutoUpdate:Z(o),currentVersion:n.version||`0.0.1`,executablePath:r,installSource:o,latestVersion:l,packageRoot:n.packageRoot,recommendedUpgradeCommand:Z(o)?`quantex upgrade`:void 0,updateChannel:c}}async function ce(e){let t=e??await X(),n=await D();if(!n)return{error:{kind:`locked`,message:`Another qtx upgrade is already running.`},installSource:t.installSource,success:!1};try{return await ae(t).upgrade(t)}finally{await n()}}function Z(e){return e===`binary`||e===`bun`||e===`npm`}async function le(e,t){return t!==`unknown`&&e!==t?(await n(t),t):e??t}function Q(e,t=y.execPath){let n=$(e);return n.includes(`/.bun/install/global/`)?`bun`:n.includes(se)?`npm`:n?`source`:he(t)?`binary`:`unknown`}async function ue(e=import.meta.url){let t=ge(e),n=_(t);for(;;){let e=v(n,`package.json`),t=await me(e);if(t?.name===Y)return{foundPackageJson:!0,packageJsonPath:e,packageRoot:n,version:t.version??`0.0.1`};let r=_(n);if(r===n)break;n=r}return{foundPackageJson:!1,packageJsonPath:v(_(t),`package.json`),packageRoot:_(t),version:T}}function de(){return T}function fe(e,t=y.execPath){return J(e,t)}async function pe(e,t,n){if(e===`binary`)try{let e=await R(n);return V(e,t)?e.version:void 0}catch{return}return o(Y,n===`beta`?`beta`:`latest`)}async function me(e){try{return JSON.parse(await d(e,`utf8`))}catch{return}}function $(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function he(e){let t=g($(e));return t!==`bun`&&t!==`bun.exe`}function ge(e){try{return b(e)}catch{return y.execPath}}export{X as a,oe as c,de as i,F as l,Q as n,ce as o,fe as r,J as s,Z as t,I as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,n as t}from"./agents-BALRvoqc.mjs";import n from"picocolors";async function r(r){let i=t(r);if(!i){console.log(n.red(`Unknown agent: ${r}`));return}console.log(n.cyan(`Uninstalling ${i.displayName}...`)),await e(i)?console.log(n.green(`${i.displayName} uninstalled successfully!`)):console.log(n.red(`Failed to uninstall ${i.displayName}.`))}export{r as uninstallCommand};
|
package/dist/update-DTqFneka.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,r as n,s as r,t as i}from"./update-C6oNB0Kw.mjs";import{N as a,j as o,l as s,n as c,u as l,z as u}from"./agents-BALRvoqc.mjs";import d from"picocolors";async function f(e,t){if(t){await p();return}if(!e){console.log(d.red(`Please specify an agent name or use --all flag`));return}let n=c(e);if(!n){console.log(d.red(`Unknown agent: ${e}`));return}await g(n)}async function p(){await m(await e())}async function m(e){for(let t of e.upToDate)console.log(d.green(`${t.agent.displayName} is up to date (${t.installedVersion??`unknown`})`));for(let t of e.skippedManualCheck)console.log(d.yellow(r(t.agent)));for(let t of e.entries)console.log(d.cyan(`Updating ${t.agent.displayName} via ${y(t)}...${v(t.inspection.installedVersion,t.inspection.latestVersion)}`));for(let t of e.grouped)await h(t.type,t.packages,t.updates);for(let t of e.manual)await _(t.agent,t.state,t.inspection.methods,!1)}async function h(e,t,n){if(n.length!==0){if(await l(e,t)){for(let{agent:e}of n)console.log(d.green(`${e.displayName} updated successfully!`));return}for(let{agent:e,state:t}of n)await _(e,t,void 0,!1)}}async function g(e){let{inspection:t,plan:i}=await n(e);if(!t.inPath){console.log(d.red(`${e.displayName} is not installed.`));return}if(i.upToDate.length>0){console.log(d.green(`${e.displayName} is up to date (${t.installedVersion??`unknown`})`));return}if(i.skippedManualCheck.length>0){console.log(d.yellow(r(e)));return}await m(i)}async function _(e,n,c,l=!0){if(l){let{inspection:t}=await i(e);console.log(d.cyan(`Updating ${e.displayName}...${v(t.installedVersion,t.latestVersion)}`)),c=t.methods}let f=o({agent:e,installedState:n,methods:c??[]});if(f===`manual-hint`&&!a(e,n)&&!c?.some(e=>u(e.type))){console.log(d.yellow(r(e)));return}if((await s(e,n)).success)console.log(d.green(`${e.displayName} updated successfully!`));else{console.log(d.red(`Failed to update ${e.displayName}.`));let n=t(e,f);n&&console.log(d.yellow(n))}}function v(e,t){return e?` (${e} -> ${t??`latest`})`:``}function y(e){return e.strategy===`managed`?`managed/${e.installerType??e.state?.installType??`unknown`}`:e.strategy===`self-update`?`self-update`:`manual-hint`}export{f as updateCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,c as t,o as n}from"./self-Bj9L_tIu.mjs";import r from"picocolors";async function i(i={}){let a=await e({updateChannel:i.channel});if(a.latestVersion&&a.latestVersion===a.currentVersion)return console.log(r.green(`Quantex CLI is already up to date (${a.currentVersion}).`)),0;if(i.check)return a.latestVersion?(console.log(r.yellow(`Update available for Quantex CLI: ${a.currentVersion} -> ${a.latestVersion} (${a.updateChannel}).`)),1):(console.log(r.yellow(`Unable to determine the latest Quantex CLI version.`)),2);if(!a.canAutoUpdate){console.log(r.yellow(`Quantex CLI cannot auto-update from the current install source: ${a.installSource}.`));let e=t(a);return e&&console.log(r.cyan(`Manual upgrade: ${e}`)),2}let o=a.latestVersion?` (${a.currentVersion} -> ${a.latestVersion})`:` (${a.currentVersion})`;console.log(r.cyan(`Upgrading Quantex CLI...${o}`));let s=await n(a);if(s.success)return console.log(r.green(`Quantex CLI upgraded successfully.`)),0;{console.log(r.red(`Failed to upgrade Quantex CLI.`)),s.error?.message&&console.log(r.yellow(`Reason: ${s.error.message}`));let e=t(a,s);return e&&console.log(r.cyan(`Manual recovery: ${e}`)),2}}export{i as upgradeCommand};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./config-DWeRAIFV.mjs";import{mkdir as n,readFile as r,writeFile as i}from"node:fs/promises";import{join as a}from"node:path";import o from"node:process";const s={installedAgents:{},self:{}};function c(){return a(t(),`state.json`)}async function l(){try{let e=await Bun.file(c()).json();return{installedAgents:e.installedAgents??{},self:e.self??{}}}catch{return{...s}}}async function u(e){await n(t(),{recursive:!0}),await Bun.write(c(),`${JSON.stringify(e,null,2)}\n`)}async function d(e){return(await l()).installedAgents[e]}async function f(e){let t=await l();t.installedAgents[e.agentName]=e,await u(t)}async function p(e){let t=await l();delete t.installedAgents[e],await u(t)}async function m(){return(await l()).self}async function h(e){let t=await l();t.self.installSource=e,await u(t)}async function g(e){try{return await b([`bun`,`add`,`-g`,e],[e])}catch{return!1}}async function _(e,t=`latest-major`,n=`latest`){try{let r=n===`latest`?e:`${e}@${n}`;return await b([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],r],[e])}catch{return!1}}async function v(e,t=`latest-major`){if(e.length===0)return!0;try{return await b([`bun`,`update`,`-g`,...t===`latest-major`?[`--latest`]:[],...e],e)}catch{return!1}}async function y(e){try{let t=Bun.spawn([`bun`,`remove`,`-g`,e],{stdio:w()});return await t.exited,t.exitCode===0}catch{return!1}}async function b(e,t){let n=Bun.spawn(e,{stdio:w()});return await n.exited,n.exitCode===0?x(t):!1}async function x(e){let t=[...new Set(e)];if(t.length===0)return!0;let n=await S();if(!n)return!0;let r=C(n),i=t.filter(e=>r.has(e));if(i.length===0)return!0;let a=Bun.spawn([`bun`,`pm`,`-g`,`trust`,...i],{stdio:w()});return await a.exited,a.exitCode===0}async function S(){try{let e=Bun.spawn([`bun`,`pm`,`-g`,`untrusted`],{stdio:T()}),t=await new Response(e.stdout).text();return await e.exited,e.exitCode===0?t:void 0}catch{return}}function C(e){let t=new Set;for(let n of e.split(`
|
|
2
|
-
`)){let e=n.match(/^\.\/node_modules\/(.+?) @/);e?.[1]&&t.add(e[1])}return t}function w(){return[`inherit`,`inherit`,`inherit`]}function T(){return[`ignore`,`pipe`,`ignore`]}async function E(e){try{let t=Bun.spawn([`npm`,`i`,`-g`,e],{stdio:[`inherit`,`inherit`,`inherit`]});return await t.exited,t.exitCode===0}catch{return!1}}async function D(e,t=`latest-major`,n=`latest`){try{let r=Bun.spawn(t===`latest-major`?[`npm`,`install`,`-g`,`${e}@${n}`]:[`npm`,`update`,`-g`,e],{stdio:[`inherit`,`inherit`,`inherit`]});return await r.exited,r.exitCode===0}catch{return!1}}async function O(e,t=`latest-major`){if(e.length===0)return!0;try{let n=Bun.spawn(t===`latest-major`?[`npm`,`install`,`-g`,...e.map(e=>`${e}@latest`)]:[`npm`,`update`,`-g`,...e],{stdio:[`inherit`,`inherit`,`inherit`]});return await n.exited,n.exitCode===0}catch{return!1}}async function k(e){try{let t=Bun.spawn([`npm`,`uninstall`,`-g`,e],{stdio:[`inherit`,`inherit`,`inherit`]});return await t.exited,t.exitCode===0}catch{return!1}}async function A(e,t){let n=await j(e,t,`json`);if(n)try{return JSON.parse(n)}catch{return}}async function j(t,n,r=`text`){let i=await e(),a=await N(),o=a.entries[n],s=Date.now();if(o&&o.expiresAt>s)return o.body;let c=await M(t,{headers:o?.etag?{"If-None-Match":o.etag}:void 0,retries:i.networkRetries,timeoutMs:i.networkTimeoutMs});if(!c)return o?.body;if(c.status===304&&o)return a.entries[n]={...o,expiresAt:s+i.versionCacheTtlHours*60*60*1e3},await P(a),o.body;if(!c.ok)return o?.body;let l=await c.text();if(r===`json`)try{JSON.parse(l)}catch{return o?.body}return a.entries[n]={body:l,etag:c.headers.get(`etag`)??void 0,expiresAt:s+i.versionCacheTtlHours*60*60*1e3},await P(a),l}async function M(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 N(){try{return JSON.parse(await r(F(),`utf8`))}catch{return{entries:{}}}}async function P(e){await n(a(t(),`cache`),{recursive:!0}),await i(F(),`${JSON.stringify(e,null,2)}\n`,`utf8`)}function F(){return a(t(),`cache`,`versions.json`)}const I=/v?(\d+\.\d+\.\d+(?:-[a-z0-9.]+)?)/i;function L(e,t){if(t)return t(e);let n=e.trim().split(`
|
|
3
|
-
`)[0],r=n.match(I);return r?r[1]:n||void 0}async function R(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?L(await new Response(e.stdout).text(),t?.parser):void 0}catch{return}}async function z(e,t=`latest`){try{return(await A(`https://registry.npmjs.org/${e}/${t}`,`npm:${e}:${t}`))?.version}catch{return}}async function B(e){try{let t=o.platform===`win32`?`where`:`which`,n=Bun.spawn([t,e],{stdout:`pipe`,stderr:`pipe`});return await n.exited,n.exitCode===0?(await new Response(n.stdout).text()).trim().split(`
|
|
4
|
-
`)[0]:void 0}catch{return}}export{p as _,E as a,h as b,O as c,_ as d,v as f,l as g,c as h,A as i,g as l,m,R as n,k as o,d as p,z as r,D as s,B as t,y as u,u as v,f as y};
|