noskills 4.1.44 → 4.1.47
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 +74 -22
- package/chunks/{approve-NPG6X7O6.js → approve-D5AONTPF.js} +1 -1
- package/chunks/{ask-F4XM2EEC.js → ask-SWMI6GK2.js} +1 -1
- package/chunks/{block-LSEXCK45.js → block-MW7CCPRS.js} +1 -1
- package/chunks/{cancel-BK6GCIIY.js → cancel-3JUX5SPS.js} +1 -1
- package/chunks/{chunk-3SLKOP72.js → chunk-6FTHIS2Z.js} +1 -1
- package/chunks/chunk-FEHZCASN.js +3 -0
- package/chunks/chunk-FJCXMC2D.js +1 -0
- package/chunks/chunk-IZ4J7VRF.js +1 -0
- package/chunks/{chunk-ZMVD5IU4.js → chunk-OV7ZXBXC.js} +28 -27
- package/chunks/chunk-QMZBEPES.js +16 -0
- package/chunks/{chunk-LWCWPXCS.js → chunk-QYMX2GR3.js} +86 -83
- package/chunks/chunk-RBLZTQ64.js +3 -0
- package/chunks/{chunk-ERX4HONR.js → chunk-TIGKFDKY.js} +1 -1
- package/chunks/{chunk-7QFOEK3I.js → chunk-XRKWQJMC.js} +1 -1
- package/chunks/{chunk-ALZM4JXG.js → chunk-XYJXQHQN.js} +1 -1
- package/chunks/{claude-code-K3SX5D5F.js → claude-code-FZXKRWA5.js} +1 -1
- package/chunks/{concern-3K3QUYG4.js → concern-XME2LKJJ.js} +1 -1
- package/chunks/{done-OMGLEA32.js → done-5FR2OAXK.js} +1 -1
- package/chunks/{free-BO5UA5V2.js → free-KPB37MR3.js} +1 -1
- package/chunks/{init-M4MSHCVJ.js → init-HIQXEJDS.js} +1 -1
- package/chunks/invoke-hook-NXZYKSHD.js +11 -0
- package/chunks/{kiro-T5X4D4SC.js → kiro-AC5LYTVB.js} +1 -1
- package/chunks/{list-3RK7TPGG.js → list-B5YTFNLR.js} +1 -1
- package/chunks/manager-OOJQ6WXI.js +6 -0
- package/chunks/mod-RW5J2N5Q.js +1 -0
- package/chunks/next-SP7JFPGS.js +8 -0
- package/chunks/{ollama-CNKKUTPX.js → ollama-TM4MMP7N.js} +1 -1
- package/chunks/{opencode-MJO3K6T4.js → opencode-YGNBYWQL.js} +1 -1
- package/chunks/{purge-MDSEQLDQ.js → purge-OAHH3MCY.js} +1 -1
- package/chunks/{reopen-EKSLLO54.js → reopen-H6WXM2OQ.js} +1 -1
- package/chunks/{reset-WRTVX7TT.js → reset-O4WA2VGI.js} +1 -1
- package/chunks/rule-IHME5I6Q.js +6 -0
- package/chunks/run-7OEMPUFO.js +3 -0
- package/chunks/session-NSWI2Q3S.js +1 -0
- package/chunks/spec-2FKI55EV.js +1 -0
- package/chunks/{status-63TFVF7Y.js → status-MOMQ2FRD.js} +1 -1
- package/chunks/{sync-VS4HROEX.js → sync-YI7WLQP2.js} +1 -1
- package/chunks/{watch-4HJMGNF4.js → watch-GMTD4676.js} +1 -1
- package/chunks/{wontfix-BOT7HHH2.js → wontfix-2AKBA54I.js} +1 -1
- package/noskills.js +1 -1
- package/package.json +1 -1
- package/chunks/chunk-73EEM3FY.js +0 -1
- package/chunks/chunk-7GUYMD3Z.js +0 -16
- package/chunks/chunk-BBKSV2RO.js +0 -3
- package/chunks/chunk-SNHYXBHM.js +0 -3
- package/chunks/chunk-TMC5H2A5.js +0 -1
- package/chunks/invoke-hook-HB2TBCHD.js +0 -10
- package/chunks/mod-KTV64DHD.js +0 -1
- package/chunks/next-4DJGEJBW.js +0 -8
- package/chunks/rule-QP5BSH27.js +0 -2
- package/chunks/run-3VWWQDN2.js +0 -3
- package/chunks/spec-HQZVVCBY.js +0 -1
package/README.md
CHANGED
|
@@ -128,6 +128,32 @@ builders get a structured workflow that keeps the agent focused. Teams get a
|
|
|
128
128
|
shared source of truth that every tool and every teammate inherits
|
|
129
129
|
automatically.
|
|
130
130
|
|
|
131
|
+
## How noskills differs
|
|
132
|
+
|
|
133
|
+
| | Sequential Thinking | gstack | Skills / Rules | Ralph Loops | noskills |
|
|
134
|
+
| ------------------------- | ----------------------------------------- | ------------------------------------------------ | --------------------------------- | ---------------------------------------- | ------------------------------------------ |
|
|
135
|
+
| What it does | Structures agent's internal thinking | Role-based slash commands (CEO, Eng, QA) | Loads rules into context | Resets session, keeps state in files | Manages workflow via state machine |
|
|
136
|
+
| Metaphor | "Think out loud" | "Virtual team" | "Law book" | "Clean desk every turn" | "Scrum Master" |
|
|
137
|
+
| User role | None — agent self-talks | Chooses which role to invoke | Writes rules, hopes agent follows | Manages context manually | Active decision-maker at every gate |
|
|
138
|
+
| Enforcement | None | None — behavioral | None — behavioral | Context reset only | Mechanical (hooks block actions) |
|
|
139
|
+
| State tracking | Thought history (in-memory) | Learnings (cross-session) | None | File-based (manual) | Full state machine, per-spec |
|
|
140
|
+
| File control | None | None | None | None | Phase-based edit control |
|
|
141
|
+
| Sub-agents | None | None (single agent, multiple roles) | None | None | Executor / verifier / test-writer pipeline |
|
|
142
|
+
| Discovery | None | /office-hours (similar concept) | None | None | 6 structured questions + concerns |
|
|
143
|
+
| Works alongside noskills? | Yes — ST for thinking, noskills for doing | Yes — gstack for roles, noskills for enforcement | Replaced by noskills | Automated by noskills sub-agent pipeline | — |
|
|
144
|
+
|
|
145
|
+
**The core difference:** other tools tell the agent what to do and hope it
|
|
146
|
+
listens. noskills mechanically restricts what the agent _can_ do. When the agent
|
|
147
|
+
is in DISCOVERY, it literally cannot edit files — not because a rule says
|
|
148
|
+
"don't" but because a hook blocks the operation. That is the difference between
|
|
149
|
+
behavioral guidance and mechanical enforcement.
|
|
150
|
+
|
|
151
|
+
noskills is not a replacement for any of these tools. Sequential Thinking helps
|
|
152
|
+
agents reason better. gstack assigns useful roles. Both can run alongside
|
|
153
|
+
noskills. The distinction is that noskills owns the workflow — who does what,
|
|
154
|
+
when, and whether the result was verified — while the others own the thinking or
|
|
155
|
+
the persona.
|
|
156
|
+
|
|
131
157
|
## The Mental Model
|
|
132
158
|
|
|
133
159
|
```
|
|
@@ -160,6 +186,31 @@ emerge. If you want to discover those limits together, jump on board.
|
|
|
160
186
|
The name mirrors the SQL -> NoSQL shift: skills define everything upfront,
|
|
161
187
|
noskills determines what's needed at runtime.
|
|
162
188
|
|
|
189
|
+
### The Scrum analogy
|
|
190
|
+
|
|
191
|
+
If you know Agile, you already know noskills:
|
|
192
|
+
|
|
193
|
+
| Agile / Scrum | noskills |
|
|
194
|
+
| ------------------ | --------------------------------------------- |
|
|
195
|
+
| User Story | Spec |
|
|
196
|
+
| Increment | Spec's deliverable |
|
|
197
|
+
| Refinement meeting | Discovery (6 questions + concerns) |
|
|
198
|
+
| Sprint Planning | Spec draft → approval (tasks defined) |
|
|
199
|
+
| Sprint | Execution (runs until spec is done) |
|
|
200
|
+
| Dev team | Sub-agents (executor, verifier, test-writer) |
|
|
201
|
+
| Scrum Master | noskills (state machine, hooks, backpressure) |
|
|
202
|
+
| Definition of Done | Acceptance criteria |
|
|
203
|
+
| Sprint Review | AC status report + verifier validation |
|
|
204
|
+
| Retrospective | Debt tracking + concern reminders |
|
|
205
|
+
| Product Owner | You (every decision is yours) |
|
|
206
|
+
|
|
207
|
+
One key difference: in Scrum, a sprint is time-boxed. In noskills, execution
|
|
208
|
+
runs until the spec is complete — it is a single-story sprint. This is why
|
|
209
|
+
mid-execution checkpoints make no sense: a Scrum Master does not stop a sprint
|
|
210
|
+
halfway through the only story. If the story is too big, you split it _before_
|
|
211
|
+
the sprint starts — not during. That is exactly what noskills does at
|
|
212
|
+
DISCOVERY_REVIEW with the split proposal.
|
|
213
|
+
|
|
163
214
|
## Philosophy — A Scrum Master for Agents
|
|
164
215
|
|
|
165
216
|
I used to teach Agile. In those trainings, I'd go all the way back to the Toyota
|
|
@@ -837,28 +888,29 @@ eser nos <command>
|
|
|
837
888
|
|
|
838
889
|
### Commands
|
|
839
890
|
|
|
840
|
-
| Command
|
|
841
|
-
|
|
|
842
|
-
| `init`
|
|
843
|
-
| `status [-o format]`
|
|
844
|
-
| `spec new "
|
|
845
|
-
| `spec list [-o format]`
|
|
846
|
-
| `spec
|
|
847
|
-
| `next
|
|
848
|
-
| `
|
|
849
|
-
| `
|
|
850
|
-
| `
|
|
851
|
-
| `
|
|
852
|
-
| `
|
|
853
|
-
| `
|
|
854
|
-
| `
|
|
855
|
-
| `
|
|
856
|
-
| `
|
|
857
|
-
| `
|
|
858
|
-
| `
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
891
|
+
| Command | Description |
|
|
892
|
+
| ------------------------------------- | ------------------------------------------------------------------ |
|
|
893
|
+
| `init` | Scaffold `.eser/`, detect project traits, install hooks |
|
|
894
|
+
| `status [-o format]` | Show current phase, spec name, progress, debt |
|
|
895
|
+
| `spec new <name> "description"` | Start a new spec, enter DISCOVERY |
|
|
896
|
+
| `spec list [-o format]` | List all specs with phase info |
|
|
897
|
+
| `spec <name> next [-o format]` | Get instruction for current phase |
|
|
898
|
+
| `spec <name> next --answer="..."` | Submit answer and advance state |
|
|
899
|
+
| `spec <name> approve` | Approve spec draft -> SPEC_APPROVED |
|
|
900
|
+
| `spec <name> done` | Complete execution -> DONE |
|
|
901
|
+
| `spec <name> block "reason"` | Mark execution as blocked |
|
|
902
|
+
| `spec <name> reset` | Reset current spec to IDLE |
|
|
903
|
+
| `spec <name> revisit "reason"` | Return to DISCOVERY from EXECUTING |
|
|
904
|
+
| `spec <name> split --into x --into y` | Split spec into sub-specs |
|
|
905
|
+
| `run [--spec=name] [--unattended]` | Autonomous execution loop (Ralph loop) |
|
|
906
|
+
| `watch [-o format]` | Live dashboard monitoring agent progress |
|
|
907
|
+
| `concern add/remove/list` | Manage active concerns |
|
|
908
|
+
| `rule add/list/promote` | Manage permanent rules |
|
|
909
|
+
| `sync` | Regenerate tool-specific instruction files + hooks |
|
|
910
|
+
| `purge [--force]` | Remove all noskills content (specs, rules, concerns, hooks, state) |
|
|
911
|
+
|
|
912
|
+
All spec commands use the `spec <name> <command>` positional format. The spec
|
|
913
|
+
name always comes before the subcommand. Use `spec list` to see available specs.
|
|
862
914
|
|
|
863
915
|
### Output Formats
|
|
864
916
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k}from"./chunk-
|
|
1
|
+
import{a as k}from"./chunk-RBLZTQ64.js";import"./chunk-VPXOI7CR.js";import{a as x,d as F}from"./chunk-6FTHIS2Z.js";import{c as p}from"./chunk-YK6UG66R.js";import{g as P,j as A}from"./chunk-FJCXMC2D.js";import{d as y,f as C,h as R,i as w,j as u,l as D,p as E}from"./chunk-QYMX2GR3.js";import{c as i,d as l,f as a,g as d,k as m,o as S,q as v,r as g}from"./chunk-Y6AFIAJP.js";import{a as h,b as n}from"./chunk-2N4GTHXQ.js";import{b as c}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";var M=async _=>{let s=S({renderer:g.ansi(),sink:v.stdout()}),r=c.process.cwd(),o=R(_);if(!o.ok)return s.writeln(a(o.error)),await s.close(),n({exitCode:1});let t;try{t=await C(r,o.spec)}catch(e){let f=e instanceof Error?e.message:String(e);return s.writeln(a(f)),await s.close(),n({exitCode:1})}let $=await D(r);if(t.spec!==null){let e=`${r}/${y.specDir(t.spec)}`;try{await c.fs.stat(e)}catch{return s.writeln(a(`Active spec '${t.spec}' directory not found.`)),s.writeln(l("Run `noskills reset` to return to IDLE.")),await s.close(),n({exitCode:1})}}if(t.phase==="SPEC_DRAFT"){if(t.classification===null&&t.spec!==null){let b=(await E(r)).filter(I=>$?.concerns.includes(I.id)??!1);try{await k(r,t,b)}catch{}}let e=A(t);await w(r,e),e.spec!==null&&await u(r,e.spec,e),e.spec!==null&&(await x(r,e.spec,"approved"),await F(r,e.spec,"approved")),s.writeln(d("\u2714")," Spec approved. Phase: ",m("SPEC_APPROVED")),s.writeln("When ready, run ",i(`${p('next --answer="start"')}`)," to begin execution.")}else if(t.phase==="DISCOVERY_REVIEW"){let e=P(t);await w(r,e),e.spec!==null&&await u(r,e.spec,e),s.writeln(d("\u2714")," Discovery answers approved. Phase: ",m("SPEC_DRAFT")),s.writeln("Review the spec and run ",i(p("approve"))," again to approve.")}else t.phase==="DISCOVERY"&&t.discovery.completed?(s.writeln(l("Discovery complete. Spec draft already generated.")),s.writeln("Review the spec and run ",i(p("approve"))," again when in SPEC_DRAFT phase.")):s.writeln(a(`Cannot approve in phase: ${t.phase}`));return await s.close(),h(void 0)};export{M as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Ee,b as Ie}from"./chunk-AGPCY6XP.js";import{a as te,b as C,c as M,d as G,f as L,g as Ae,h as be,j as ke,k as re,l as Pe,o as ne,p as Re,q as oe,r as _e}from"./chunk-Y6AFIAJP.js";import{a as Fe}from"./chunk-5MN3MWQN.js";import"./chunk-OLM5RTFK.js";import{a as Le,b as D}from"./chunk-2N4GTHXQ.js";import{d as ie}from"./chunk-BBKSV2RO.js";import{b as T}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import{d as ee}from"./chunk-OTRBRRIO.js";var Ne=e=>({rawMessage:e.rawMessage??e.message,args:e.args??[],datetime:e.datetime??new Date,properties:e.properties??{},context:e.context??{},...e});var d=e=>typeof e=="string"?e.split(".").filter(Boolean):e,V=(e,t=".")=>e.join(t),w=e=>e.join("\0");var Oe=(e,t)=>e.length<t.length?!1:t.every((r,n)=>e[n]===r);var De=(e,t)=>{let r=[];for(let n of t.values()){let i=d(n.category);Oe(e,i)&&r.push(n)}return r.sort((n,i)=>{let o=d(n.category).length;return d(i.category).length-o}),r};var j=(e,t)=>{let r=typeof t=="string"?[t]:t;return[...e,...r]};var K={};ee(K,{configure:()=>Tt,configureSync:()=>Ct,getEffectiveConfig:()=>ue,getFilterNames:()=>Rt,getLoggerCategories:()=>_t,getRegistryState:()=>St,getSinkNames:()=>Pt,isConfigured:()=>ht,registerFilter:()=>At,registerLogger:()=>kt,registerLoggerCacheClear:()=>le,registerSink:()=>wt,reset:()=>ze,resetSync:()=>Ke,unregisterFilter:()=>bt,unregisterSink:()=>Lt});var g={Trace:1,Debug:5,Info:9,Notice:10,Warning:13,Error:17,Critical:21,Alert:22,Emergency:23},Me={[g.Trace]:"Trace",[g.Debug]:"Debug",[g.Info]:"Info",[g.Notice]:"Notice",[g.Warning]:"Warning",[g.Error]:"Error",[g.Critical]:"Critical",[g.Alert]:"Alert",[g.Emergency]:"Emergency"};var $,z,pt=()=>{if($===void 0)try{let e=globalThis.AsyncLocalStorage??globalThis.require?.("async_hooks")?.AsyncLocalStorage;e&&($=new e)}catch{}return $},mt=()=>{if(z===void 0)try{let e=globalThis.AsyncLocalStorage??globalThis.require?.("async_hooks")?.AsyncLocalStorage;e&&(z=new e)}catch{}return z},Ge,Ve,R=e=>{Ge=e},se=e=>{Ve=e},ge=()=>{$=void 0,z=void 0},dt=()=>Ge??pt(),yt=()=>Ve??mt();var je=()=>{let e=dt();return e?e.getStore()??{}:{}};var xt=()=>{let e=yt();return e?e.getStore()??[]:[]},$e=e=>{let t=xt();return t.length===0?e:j(t,e)};var ce=null,le=e=>{ce=e},u=null,y=new Map,St=()=>u,ht=()=>u!==null,Tt=async e=>{(e.reset||u===null)&&await ze(),u={sinks:new Map(Object.entries(e.sinks)),filters:new Map(Object.entries(e.filters??{})),loggers:new Map,contextLocalStorage:e.contextLocalStorage};for(let t of e.loggers){let r=d(t.category),n=w(r);u.loggers.set(n,{...t,category:r})}e.contextLocalStorage&&R(e.contextLocalStorage),y.clear()},Ct=e=>{(e.reset||u===null)&&Ke(),u={sinks:new Map(Object.entries(e.sinks)),filters:new Map(Object.entries(e.filters??{})),loggers:new Map,contextLocalStorage:e.contextLocalStorage};for(let t of e.loggers){let r=d(t.category),n=w(r);u.loggers.set(n,{...t,category:r})}e.contextLocalStorage&&R(e.contextLocalStorage),y.clear()},ze=async()=>{if(u)for(let e of u.sinks.values()){let t=e;typeof t.dispose=="function"?await t.dispose():typeof t[Symbol.asyncDispose]=="function"&&await t[Symbol.asyncDispose]()}u=null,y.clear(),ce?.(),R(void 0),se(void 0),ge()},Ke=()=>{if(u)for(let e of u.sinks.values()){let t=e;typeof t.disposeSync=="function"?t.disposeSync():typeof t[Symbol.dispose]=="function"&&t[Symbol.dispose]()}u=null,y.clear(),ce?.(),R(void 0),se(void 0),ge()},ue=e=>{let t=w(e),r=y.get(t);if(r)return r;let n={sinks:[],filters:[],lowestLevel:g.Info};if(!u)return n;let i=De(e,u.loggers),o=new Set,a=new Set,l=!1;for(let s of i){if(s.sinks&&s.sinks.length>0){s.parentSinks==="override"&&o.clear();for(let c of s.sinks)o.add(c)}if(s.filters)for(let c of s.filters)a.add(c);!l&&s.lowestLevel!==void 0&&(n.lowestLevel=s.lowestLevel,l=!0)}for(let s of o){let c=u.sinks.get(s);c&&n.sinks.push(c)}for(let s of a){let c=u.filters.get(s);c&&n.filters.push(c)}return y.set(t,n),n},wt=(e,t)=>{if(!u)throw new Error("Logging not configured. Call configure() first.");u.sinks.set(e,t),y.clear()},Lt=e=>{u&&(u.sinks.delete(e),y.clear())},At=(e,t)=>{if(!u)throw new Error("Logging not configured. Call configure() first.");u.filters.set(e,t),y.clear()},bt=e=>{u&&(u.filters.delete(e),y.clear())},kt=e=>{if(!u)throw new Error("Logging not configured. Call configure() first.");let t=d(e.category),r=w(t);u.loggers.set(r,{...e,category:t}),y.clear()},Pt=()=>u?Array.from(u.sinks.keys()):[],Rt=()=>u?Array.from(u.filters.keys()):[],_t=()=>u?Array.from(u.loggers.values()).map(e=>d(e.category)):[];var W={};ee(W,{DEFAULT_LEVEL:()=>Ft,Logger:()=>_,clearLoggerCache:()=>We,current:()=>It,getLogger:()=>Et});var Ft=g.Info,_=class e{category;parent;#e;#t=null;constructor(t,r=null,n={}){this.category=d(t),this.parent=r,this.#e=n}#r(){return this.#t===null&&(this.#t=ue(this.category)),this.#t}getChild(t){let r=j(this.category,d(t));return new e(r,this,this.#e)}with(t){return new e(this.category,this.parent,{...this.#e,...t})}get loggerName(){return V(this.category)}asString(t,r=!1){return typeof t=="string"?r?`"${t}"`:t:t===null||typeof t=="number"||typeof t=="bigint"||typeof t=="boolean"||typeof t>"u"||typeof t=="symbol"?String(t):t instanceof Error?t.stack:t!==null&&typeof t=="object"?Array.isArray(t)?JSON.stringify(t):`{${Object.entries(t).map(([n,i])=>`"${n}":${this.asString(i,!0)}`).join(",")}}`:"undefined"}async log(t,r,...n){let i=this.#r();if(t<i.lowestLevel)return r instanceof Function?void 0:r;let o,a;r instanceof Function?(o=r(),a=this.asString(o)):a=this.asString(r);let l=je(),s=Ne({message:a,rawMessage:a,args:n,datetime:new Date,severity:t,category:this.category,properties:this.#e,context:l});for(let c of i.filters)if(!c(s))return r instanceof Function?o:r;return i.sinks.length>0&&await Promise.all(i.sinks.map(c=>c(s))),r instanceof Function?o:r}debug(t,...r){return this.log(g.Debug,t,...r)}info(t,...r){return this.log(g.Info,t,...r)}warn(t,...r){return this.log(g.Warning,t,...r)}error(t,...r){return this.log(g.Error,t,...r)}critical(t,...r){return this.log(g.Critical,t,...r)}emergency(t,...r){return this.log(g.Emergency,t,...r)}alert(t,...r){return this.log(g.Alert,t,...r)}notice(t,...r){return this.log(g.Notice,t,...r)}trace(t,...r){return this.log(g.Trace,t,...r)}},fe=new Map,Et=e=>{let t=$e(d(e)),r=w(t),n=fe.get(r);return n||(n=new _(t),fe.set(r,n)),n},We=()=>{fe.clear()};le(We);var It=new _(["default"]);var B={};ee(B,{fingersCrossedSink:()=>Kt,getBufferedSink:()=>zt,getOutputSink:()=>jt,getRecordCollectorSink:()=>Ue,getTestSink:()=>Wt,withFilter:()=>$t});var Nt={[g.Trace]:"TRCE",[g.Debug]:"DBUG",[g.Info]:"INFO",[g.Notice]:"NOTC",[g.Warning]:"WARN",[g.Error]:"ERRO",[g.Critical]:"CRIT",[g.Alert]:"ALRT",[g.Emergency]:"EMRG"};var Ot=(e,t)=>{if(t==="none")return"";if(typeof t=="function")return t(e);let r=e.toISOString(),n=r.slice(0,10),i=r.slice(11,19),o=r.slice(19);switch(t){case"rfc3339":return r;case"date-time-timezone":case void 0:return`${n} ${i}${o}`;case"date-time":return`${n} ${i}`;case"time-timezone":return`${i}${o}`;case"time":return i;case"date":return n}},Dt=e=>{try{return JSON.stringify(e)}catch{return String(e)}},Mt=(e,t)=>{let r={...t,...e},n=Object.entries(r);return n.length===0?"":" "+n.map(([i,o])=>{let a=typeof o=="string"?o:Dt(o);return`${i}=${a}`}).join(" ")};var Gt=(e,t)=>{switch(e){case g.Trace:return G(ke(t));case g.Debug:return Pe(t);case g.Info:return Ae(t);case g.Notice:return re(t);case g.Warning:return be(t);case g.Error:return L(t);case g.Critical:return M(L(t));case g.Alert:return M(L(t));case g.Emergency:return M(L(t));default:return C(t)}},Be=e=>{let t=Ot(e.datetime,"date-time-timezone"),r=Nt[e.severity]??"????",n=e.category.length>0?V(e.category):"",i=Mt(e.properties,e.context),o=[];return t&&o.push(G(t),C(" ")),o.push(Gt(e.severity,r),C(" ")),n&&o.push(re(`[${n}]`),C(" ")),e.severity>=g.Error?o.push(L(e.message)):o.push(C(e.message)),i.trim()&&o.push(C(" "),G(i.trim())),o};var jt=(e,t)=>{let r=t?.formatter??Be;return n=>{let i=r(n);e.writeln(...i)}},$t=(e,t)=>r=>{if(t(r))return e(r)},zt=(e,t={})=>{let{maxSize:r=100,flushIntervalMs:n=5e3}=t,i=[],o=null,a=async()=>{if(i.length===0)return;let c=i;i=[],o&&(clearTimeout(o),o=null),await Promise.all(c.map(p=>e(p)))},l=()=>{o===null&&(o=setTimeout(()=>{o=null,a().catch(()=>{})},n))},s=async c=>{i.push(c),i.length>=r?await a():l()};return s.flush=a,s},Kt=(e,t={})=>{let{triggerLevel:r=17,maxBufferSize:n=1e3}=t,i=[],o=!1,a=async()=>{let c=i;i=[],o=!0,await Promise.all(c.map(p=>e(p)))},l=()=>{i=[],o=!1},s=async c=>{if(o){await e(c);return}if(c.severity>=r){i.push(c),await a();return}i.push(c),i.length>n&&i.shift()};return s.flush=a,s.clear=l,s},Ue=()=>{let e=[];return{sink:r=>{e.push(r)},records:e}},Wt=Ue;var Ye=typeof globalThis=="object"?globalThis:global;var v="1.9.0";var Xe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Ut(e){var t=new Set([e]),r=new Set,n=e.match(Xe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(s){return s===e};function o(l){return r.add(l),!1}function a(l){return t.add(l),!0}return function(s){if(t.has(s))return!0;if(r.has(s))return!1;var c=s.match(Xe);if(!c)return o(s);var p={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return p.prerelease!=null||i.major!==p.major?o(s):i.major===0?i.minor===p.minor&&i.patch<=p.patch?a(s):o(s):i.minor<=p.minor?a(s):o(s)}}var qe=Ut(v);var Yt=v.split(".")[0],F=Symbol.for("opentelemetry.js.api."+Yt),E=Ye;function A(e,t,r,n){var i;n===void 0&&(n=!1);var o=E[F]=(i=E[F])!==null&&i!==void 0?i:{version:v};if(!n&&o[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return r.error(a.stack||a.message),!1}if(o.version!==v){var a=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+e+" does not match previously registered API v"+v);return r.error(a.stack||a.message),!1}return o[e]=t,r.debug("@opentelemetry/api: Registered a global for "+e+" v"+v+"."),!0}function S(e){var t,r,n=(t=E[F])===null||t===void 0?void 0:t.version;if(!(!n||!qe(n)))return(r=E[F])===null||r===void 0?void 0:r[e]}function b(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+v+".");var r=E[F];r&&delete r[e]}var Xt=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},qt=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},He=function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("verbose",this._namespace,t)},e}();function I(e,t,r){var n=S("diag");if(n)return r.unshift(t),n[e].apply(n,qt([],Xt(r),!1))}var m;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(m||(m={}));function Je(e,t){e<m.NONE?e=m.NONE:e>m.ALL&&(e=m.ALL),t=t||{};function r(n,i){var o=t[n];return typeof o=="function"&&e>=i?o.bind(t):function(){}}return{error:r("error",m.ERROR),warn:r("warn",m.WARN),info:r("info",m.INFO),debug:r("debug",m.DEBUG),verbose:r("verbose",m.VERBOSE)}}var Ht=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},Jt=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},Qt="diag",k=function(){function e(){function t(i){return function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var l=S("diag");if(l)return l[i].apply(l,Jt([],Ht(o),!1))}}var r=this,n=function(i,o){var a,l,s;if(o===void 0&&(o={logLevel:m.INFO}),i===r){var c=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((a=c.stack)!==null&&a!==void 0?a:c.message),!1}typeof o=="number"&&(o={logLevel:o});var p=S("diag"),f=Je((l=o.logLevel)!==null&&l!==void 0?l:m.INFO,i);if(p&&!o.suppressOverrideMessage){var x=(s=new Error().stack)!==null&&s!==void 0?s:"<failed to generate stacktrace>";p.warn("Current logger will be overwritten from "+x),f.warn("Current logger will overwrite one already registered from "+x)}return A("diag",f,r,!0)};r.setLogger=n,r.disable=function(){b(Qt,r)},r.createComponentLogger=function(i){return new He(i)},r.verbose=t("verbose"),r.debug=t("debug"),r.info=t("info"),r.warn=t("warn"),r.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}();function Qe(e){return Symbol.for(e)}var Zt=function(){function e(t){var r=this;r._currentContext=t?new Map(t):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var o=new e(r._currentContext);return o._currentContext.set(n,i),o},r.deleteValue=function(n){var i=new e(r._currentContext);return i._currentContext.delete(n),i}}return e}(),Ze=new Zt;var er=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},tr=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},et=function(){function e(){}return e.prototype.active=function(){return Ze},e.prototype.with=function(t,r,n){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return r.call.apply(r,tr([n],er(i),!1))},e.prototype.bind=function(t,r){return r},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}();var rr=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},nr=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},pe="context",or=new et,U=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return A(pe,t,k.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,r,n){for(var i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return(i=this._getContextManager()).with.apply(i,nr([t,r,n],rr(o),!1))},e.prototype.bind=function(t,r){return this._getContextManager().bind(t,r)},e.prototype._getContextManager=function(){return S(pe)||or},e.prototype.disable=function(){this._getContextManager().disable(),b(pe,k.instance())},e}();var Y;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(Y||(Y={}));var me="0000000000000000",de="00000000000000000000000000000000",tt={traceId:de,spanId:me,traceFlags:Y.NONE};var h=function(){function e(t){t===void 0&&(t=tt),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,r){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,r){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,r){},e}();var ye=Qe("OpenTelemetry Context Key SPAN");function X(e){return e.getValue(ye)||void 0}function rt(){return X(U.getInstance().active())}function N(e,t){return e.setValue(ye,t)}function nt(e){return e.deleteValue(ye)}function ot(e,t){return N(e,new h(t))}function q(e){var t;return(t=X(e))===null||t===void 0?void 0:t.spanContext()}var ir=/^([0-9a-f]{32})$/i,ar=/^[0-9a-f]{16}$/i;function sr(e){return ir.test(e)&&e!==de}function gr(e){return ar.test(e)&&e!==me}function H(e){return sr(e.traceId)&&gr(e.spanId)}function it(e){return new h(e)}var xe=U.getInstance(),J=function(){function e(){}return e.prototype.startSpan=function(t,r,n){n===void 0&&(n=xe.active());var i=!!r?.root;if(i)return new h;var o=n&&q(n);return cr(o)&&H(o)?new h(o):new h},e.prototype.startActiveSpan=function(t,r,n,i){var o,a,l;if(!(arguments.length<2)){arguments.length===2?l=r:arguments.length===3?(o=r,l=n):(o=r,a=n,l=i);var s=a??xe.active(),c=this.startSpan(t,o,s),p=N(s,c);return xe.with(p,l,void 0,c)}},e}();function cr(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var lr=new J,at=function(){function e(t,r,n,i){this._provider=t,this.name=r,this.version=n,this.options=i}return e.prototype.startSpan=function(t,r,n){return this._getTracer().startSpan(t,r,n)},e.prototype.startActiveSpan=function(t,r,n,i){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):lr},e}();var st=function(){function e(){}return e.prototype.getTracer=function(t,r,n){return new J},e}();var ur=new st,ve=function(){function e(){}return e.prototype.getTracer=function(t,r,n){var i;return(i=this.getDelegateTracer(t,r,n))!==null&&i!==void 0?i:new at(this,t,r,n)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:ur},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(t,r,n)},e}();var Se="trace",gt=function(){function e(){this._proxyTracerProvider=new ve,this.wrapSpanContext=it,this.isSpanContextValid=H,this.deleteSpan=nt,this.getSpan=X,this.getActiveSpan=rt,this.getSpanContext=q,this.setSpan=N,this.setSpanContext=ot}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var r=A(Se,this._proxyTracerProvider,k.instance());return r&&this._proxyTracerProvider.setDelegate(t),r},e.prototype.getTracerProvider=function(){return S(Se)||this._proxyTracerProvider},e.prototype.getTracer=function(t,r){return this.getTracerProvider().getTracer(t,r)},e.prototype.disable=function(){b(Se,k.instance()),this._proxyTracerProvider=new ve},e}();var he=gt.getInstance();var Yn=he.getTracer("@eser/logging");var Te=(e,t,r)=>{let n=e.streamText(t,r);return{name:`ai-text/${e.provider}/${e.modelId}`,readable:new ReadableStream({async start(i){try{for await(let o of n)o.kind==="content_delta"&&i.enqueue(te(o.textDelta));i.close()}catch(o){i.error(o)}}})}};var dr={cc:"claude-code",ol:"ollama",oc:"opencode",oai:"openai",ant:"anthropic",gem:"gemini",vtx:"vertexai"},yr={"claude-code":"Claude Code",ollama:"Ollama",opencode:"OpenCode",kiro:"Kiro",anthropic:"Anthropic API",openai:"OpenAI API",gemini:"Gemini API",vertexai:"Vertex AI"},xr=e=>dr[e]??e,vr=async e=>{if(e){let t=T.process.stderr.getWriter(),r=ne({renderer:_e.ansi(),sink:oe.writable(new WritableStream({async write(n){await t.write(new TextEncoder().encode(String(n.data)))},close(){t.releaseLock()}}))});await K.configure({sinks:{stderr:B.getOutputSink(r)},loggers:[{category:["ai"],lowestLevel:g.Debug,sinks:["stderr"]}]})}return W.getLogger(["ai","ask"])},Sr=async e=>{await e.info("Auto-detecting AI provider...");try{if(await ie`which claude`.noThrow().code()===0)return await e.info("Claude Code detected."),"claude-code"}catch{}try{if((await fetch("http://localhost:11434/api/version",{signal:AbortSignal.timeout(1e3)})).ok)return await e.info("Ollama detected at localhost:11434."),"ollama"}catch{}try{if(await ie`which opencode`.noThrow().code()===0)return await e.info("OpenCode detected."),"opencode"}catch{}if(T.capabilities.env){if(T.env.has("ANTHROPIC_API_KEY"))return await e.info("Anthropic API key detected."),"anthropic";if(T.env.has("OPENAI_API_KEY"))return await e.info("OpenAI API key detected."),"openai"}throw new Error("No AI provider detected. Install claude, ollama, or set ANTHROPIC_API_KEY / OPENAI_API_KEY.")},hr=async e=>{switch(e){case"claude-code":return(await import("./claude-code-K3SX5D5F.js")).claudeCodeFactory;case"ollama":return(await import("./ollama-CNKKUTPX.js")).ollamaFactory;case"opencode":return(await import("./opencode-MJO3K6T4.js")).openCodeFactory;case"kiro":return(await import("./kiro-T5X4D4SC.js")).kiroFactory;case"anthropic":return(await import("./anthropic-UTLWCK66.js")).anthropicFactory;case"openai":return(await import("./openai-QGEN33SU.js")).openaiFactory;case"gemini":return(await import("./gemini-YR5KT32S.js")).geminiFactory;case"vertexai":return(await import("./vertexai-RUXZ24C2.js")).vertexaiFactory;default:throw new Error(`Unknown provider: ${e}`)}},lo=async e=>{let t=e??[],r=null,n=null,i=null,o=!1,a=!1,l=[],s=0;for(;s<t.length;){let f=t[s];if(f==="-p"||f==="--provider"){r=t[s+1]??null,s+=2;continue}if(f==="-m"||f==="--model"){n=t[s+1]??null,s+=2;continue}if(f==="--max-tokens"){let x=t[s+1];x!==void 0&&(i=Number(x)),s+=2;continue}if(f==="--json"){o=!0,s+=1;continue}if(f==="-v"||f==="--verbose"){a=!0,s+=1;continue}f.startsWith("-")||l.push(f),s+=1}let c=l.join(" ");if(c.length===0)return D({message:'Usage: ai ask "your prompt" [-p provider] [-m model] [--verbose]',exitCode:1});let p=await vr(a);try{let f=r!==null?xr(r):await Sr(p),x=yr[f]??f,Ce=n??Lr(f);await p.info(`Using ${x} (${Ce})`);let lt=await hr(f),Q=new Ie({factories:[lt]});await Q.addModel("default",{provider:f,model:Ce});let Z=Q.getDefault();if(Z===null)return D({message:"Failed to initialize model",exitCode:1});let we=[Fe("user",c)];if(await p.info(`Sending prompt (${c.length} chars)...`),o){let O=await Z.generateText({messages:we,maxTokens:i??void 0});await p.info(`Response received (${Ee(O).length} chars)`);let P=ne({sink:oe.stdout()});P.writeln(JSON.stringify(O,null,2)),await P.close()}else{let O=Te(Z,{messages:we,maxTokens:i??void 0});await Re().from(O).to(wr()).run();let P=T.process.stdout.getWriter();await P.write(new TextEncoder().encode(`
|
|
1
|
+
import{a as Ee,b as Ie}from"./chunk-AGPCY6XP.js";import{a as te,b as C,c as M,d as G,f as L,g as Ae,h as be,j as ke,k as re,l as Pe,o as ne,p as Re,q as oe,r as _e}from"./chunk-Y6AFIAJP.js";import{a as Fe}from"./chunk-5MN3MWQN.js";import"./chunk-OLM5RTFK.js";import{a as Le,b as D}from"./chunk-2N4GTHXQ.js";import{d as ie}from"./chunk-FEHZCASN.js";import{b as T}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import{d as ee}from"./chunk-OTRBRRIO.js";var Ne=e=>({rawMessage:e.rawMessage??e.message,args:e.args??[],datetime:e.datetime??new Date,properties:e.properties??{},context:e.context??{},...e});var d=e=>typeof e=="string"?e.split(".").filter(Boolean):e,V=(e,t=".")=>e.join(t),w=e=>e.join("\0");var Oe=(e,t)=>e.length<t.length?!1:t.every((r,n)=>e[n]===r);var De=(e,t)=>{let r=[];for(let n of t.values()){let i=d(n.category);Oe(e,i)&&r.push(n)}return r.sort((n,i)=>{let o=d(n.category).length;return d(i.category).length-o}),r};var j=(e,t)=>{let r=typeof t=="string"?[t]:t;return[...e,...r]};var K={};ee(K,{configure:()=>Tt,configureSync:()=>Ct,getEffectiveConfig:()=>ue,getFilterNames:()=>Rt,getLoggerCategories:()=>_t,getRegistryState:()=>St,getSinkNames:()=>Pt,isConfigured:()=>ht,registerFilter:()=>At,registerLogger:()=>kt,registerLoggerCacheClear:()=>le,registerSink:()=>wt,reset:()=>ze,resetSync:()=>Ke,unregisterFilter:()=>bt,unregisterSink:()=>Lt});var g={Trace:1,Debug:5,Info:9,Notice:10,Warning:13,Error:17,Critical:21,Alert:22,Emergency:23},Me={[g.Trace]:"Trace",[g.Debug]:"Debug",[g.Info]:"Info",[g.Notice]:"Notice",[g.Warning]:"Warning",[g.Error]:"Error",[g.Critical]:"Critical",[g.Alert]:"Alert",[g.Emergency]:"Emergency"};var $,z,pt=()=>{if($===void 0)try{let e=globalThis.AsyncLocalStorage??globalThis.require?.("async_hooks")?.AsyncLocalStorage;e&&($=new e)}catch{}return $},mt=()=>{if(z===void 0)try{let e=globalThis.AsyncLocalStorage??globalThis.require?.("async_hooks")?.AsyncLocalStorage;e&&(z=new e)}catch{}return z},Ge,Ve,R=e=>{Ge=e},se=e=>{Ve=e},ge=()=>{$=void 0,z=void 0},dt=()=>Ge??pt(),yt=()=>Ve??mt();var je=()=>{let e=dt();return e?e.getStore()??{}:{}};var xt=()=>{let e=yt();return e?e.getStore()??[]:[]},$e=e=>{let t=xt();return t.length===0?e:j(t,e)};var ce=null,le=e=>{ce=e},u=null,y=new Map,St=()=>u,ht=()=>u!==null,Tt=async e=>{(e.reset||u===null)&&await ze(),u={sinks:new Map(Object.entries(e.sinks)),filters:new Map(Object.entries(e.filters??{})),loggers:new Map,contextLocalStorage:e.contextLocalStorage};for(let t of e.loggers){let r=d(t.category),n=w(r);u.loggers.set(n,{...t,category:r})}e.contextLocalStorage&&R(e.contextLocalStorage),y.clear()},Ct=e=>{(e.reset||u===null)&&Ke(),u={sinks:new Map(Object.entries(e.sinks)),filters:new Map(Object.entries(e.filters??{})),loggers:new Map,contextLocalStorage:e.contextLocalStorage};for(let t of e.loggers){let r=d(t.category),n=w(r);u.loggers.set(n,{...t,category:r})}e.contextLocalStorage&&R(e.contextLocalStorage),y.clear()},ze=async()=>{if(u)for(let e of u.sinks.values()){let t=e;typeof t.dispose=="function"?await t.dispose():typeof t[Symbol.asyncDispose]=="function"&&await t[Symbol.asyncDispose]()}u=null,y.clear(),ce?.(),R(void 0),se(void 0),ge()},Ke=()=>{if(u)for(let e of u.sinks.values()){let t=e;typeof t.disposeSync=="function"?t.disposeSync():typeof t[Symbol.dispose]=="function"&&t[Symbol.dispose]()}u=null,y.clear(),ce?.(),R(void 0),se(void 0),ge()},ue=e=>{let t=w(e),r=y.get(t);if(r)return r;let n={sinks:[],filters:[],lowestLevel:g.Info};if(!u)return n;let i=De(e,u.loggers),o=new Set,a=new Set,l=!1;for(let s of i){if(s.sinks&&s.sinks.length>0){s.parentSinks==="override"&&o.clear();for(let c of s.sinks)o.add(c)}if(s.filters)for(let c of s.filters)a.add(c);!l&&s.lowestLevel!==void 0&&(n.lowestLevel=s.lowestLevel,l=!0)}for(let s of o){let c=u.sinks.get(s);c&&n.sinks.push(c)}for(let s of a){let c=u.filters.get(s);c&&n.filters.push(c)}return y.set(t,n),n},wt=(e,t)=>{if(!u)throw new Error("Logging not configured. Call configure() first.");u.sinks.set(e,t),y.clear()},Lt=e=>{u&&(u.sinks.delete(e),y.clear())},At=(e,t)=>{if(!u)throw new Error("Logging not configured. Call configure() first.");u.filters.set(e,t),y.clear()},bt=e=>{u&&(u.filters.delete(e),y.clear())},kt=e=>{if(!u)throw new Error("Logging not configured. Call configure() first.");let t=d(e.category),r=w(t);u.loggers.set(r,{...e,category:t}),y.clear()},Pt=()=>u?Array.from(u.sinks.keys()):[],Rt=()=>u?Array.from(u.filters.keys()):[],_t=()=>u?Array.from(u.loggers.values()).map(e=>d(e.category)):[];var W={};ee(W,{DEFAULT_LEVEL:()=>Ft,Logger:()=>_,clearLoggerCache:()=>We,current:()=>It,getLogger:()=>Et});var Ft=g.Info,_=class e{category;parent;#e;#t=null;constructor(t,r=null,n={}){this.category=d(t),this.parent=r,this.#e=n}#r(){return this.#t===null&&(this.#t=ue(this.category)),this.#t}getChild(t){let r=j(this.category,d(t));return new e(r,this,this.#e)}with(t){return new e(this.category,this.parent,{...this.#e,...t})}get loggerName(){return V(this.category)}asString(t,r=!1){return typeof t=="string"?r?`"${t}"`:t:t===null||typeof t=="number"||typeof t=="bigint"||typeof t=="boolean"||typeof t>"u"||typeof t=="symbol"?String(t):t instanceof Error?t.stack:t!==null&&typeof t=="object"?Array.isArray(t)?JSON.stringify(t):`{${Object.entries(t).map(([n,i])=>`"${n}":${this.asString(i,!0)}`).join(",")}}`:"undefined"}async log(t,r,...n){let i=this.#r();if(t<i.lowestLevel)return r instanceof Function?void 0:r;let o,a;r instanceof Function?(o=r(),a=this.asString(o)):a=this.asString(r);let l=je(),s=Ne({message:a,rawMessage:a,args:n,datetime:new Date,severity:t,category:this.category,properties:this.#e,context:l});for(let c of i.filters)if(!c(s))return r instanceof Function?o:r;return i.sinks.length>0&&await Promise.all(i.sinks.map(c=>c(s))),r instanceof Function?o:r}debug(t,...r){return this.log(g.Debug,t,...r)}info(t,...r){return this.log(g.Info,t,...r)}warn(t,...r){return this.log(g.Warning,t,...r)}error(t,...r){return this.log(g.Error,t,...r)}critical(t,...r){return this.log(g.Critical,t,...r)}emergency(t,...r){return this.log(g.Emergency,t,...r)}alert(t,...r){return this.log(g.Alert,t,...r)}notice(t,...r){return this.log(g.Notice,t,...r)}trace(t,...r){return this.log(g.Trace,t,...r)}},fe=new Map,Et=e=>{let t=$e(d(e)),r=w(t),n=fe.get(r);return n||(n=new _(t),fe.set(r,n)),n},We=()=>{fe.clear()};le(We);var It=new _(["default"]);var B={};ee(B,{fingersCrossedSink:()=>Kt,getBufferedSink:()=>zt,getOutputSink:()=>jt,getRecordCollectorSink:()=>Ue,getTestSink:()=>Wt,withFilter:()=>$t});var Nt={[g.Trace]:"TRCE",[g.Debug]:"DBUG",[g.Info]:"INFO",[g.Notice]:"NOTC",[g.Warning]:"WARN",[g.Error]:"ERRO",[g.Critical]:"CRIT",[g.Alert]:"ALRT",[g.Emergency]:"EMRG"};var Ot=(e,t)=>{if(t==="none")return"";if(typeof t=="function")return t(e);let r=e.toISOString(),n=r.slice(0,10),i=r.slice(11,19),o=r.slice(19);switch(t){case"rfc3339":return r;case"date-time-timezone":case void 0:return`${n} ${i}${o}`;case"date-time":return`${n} ${i}`;case"time-timezone":return`${i}${o}`;case"time":return i;case"date":return n}},Dt=e=>{try{return JSON.stringify(e)}catch{return String(e)}},Mt=(e,t)=>{let r={...t,...e},n=Object.entries(r);return n.length===0?"":" "+n.map(([i,o])=>{let a=typeof o=="string"?o:Dt(o);return`${i}=${a}`}).join(" ")};var Gt=(e,t)=>{switch(e){case g.Trace:return G(ke(t));case g.Debug:return Pe(t);case g.Info:return Ae(t);case g.Notice:return re(t);case g.Warning:return be(t);case g.Error:return L(t);case g.Critical:return M(L(t));case g.Alert:return M(L(t));case g.Emergency:return M(L(t));default:return C(t)}},Be=e=>{let t=Ot(e.datetime,"date-time-timezone"),r=Nt[e.severity]??"????",n=e.category.length>0?V(e.category):"",i=Mt(e.properties,e.context),o=[];return t&&o.push(G(t),C(" ")),o.push(Gt(e.severity,r),C(" ")),n&&o.push(re(`[${n}]`),C(" ")),e.severity>=g.Error?o.push(L(e.message)):o.push(C(e.message)),i.trim()&&o.push(C(" "),G(i.trim())),o};var jt=(e,t)=>{let r=t?.formatter??Be;return n=>{let i=r(n);e.writeln(...i)}},$t=(e,t)=>r=>{if(t(r))return e(r)},zt=(e,t={})=>{let{maxSize:r=100,flushIntervalMs:n=5e3}=t,i=[],o=null,a=async()=>{if(i.length===0)return;let c=i;i=[],o&&(clearTimeout(o),o=null),await Promise.all(c.map(p=>e(p)))},l=()=>{o===null&&(o=setTimeout(()=>{o=null,a().catch(()=>{})},n))},s=async c=>{i.push(c),i.length>=r?await a():l()};return s.flush=a,s},Kt=(e,t={})=>{let{triggerLevel:r=17,maxBufferSize:n=1e3}=t,i=[],o=!1,a=async()=>{let c=i;i=[],o=!0,await Promise.all(c.map(p=>e(p)))},l=()=>{i=[],o=!1},s=async c=>{if(o){await e(c);return}if(c.severity>=r){i.push(c),await a();return}i.push(c),i.length>n&&i.shift()};return s.flush=a,s.clear=l,s},Ue=()=>{let e=[];return{sink:r=>{e.push(r)},records:e}},Wt=Ue;var Ye=typeof globalThis=="object"?globalThis:global;var v="1.9.0";var Xe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Ut(e){var t=new Set([e]),r=new Set,n=e.match(Xe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(s){return s===e};function o(l){return r.add(l),!1}function a(l){return t.add(l),!0}return function(s){if(t.has(s))return!0;if(r.has(s))return!1;var c=s.match(Xe);if(!c)return o(s);var p={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return p.prerelease!=null||i.major!==p.major?o(s):i.major===0?i.minor===p.minor&&i.patch<=p.patch?a(s):o(s):i.minor<=p.minor?a(s):o(s)}}var qe=Ut(v);var Yt=v.split(".")[0],F=Symbol.for("opentelemetry.js.api."+Yt),E=Ye;function A(e,t,r,n){var i;n===void 0&&(n=!1);var o=E[F]=(i=E[F])!==null&&i!==void 0?i:{version:v};if(!n&&o[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return r.error(a.stack||a.message),!1}if(o.version!==v){var a=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+e+" does not match previously registered API v"+v);return r.error(a.stack||a.message),!1}return o[e]=t,r.debug("@opentelemetry/api: Registered a global for "+e+" v"+v+"."),!0}function S(e){var t,r,n=(t=E[F])===null||t===void 0?void 0:t.version;if(!(!n||!qe(n)))return(r=E[F])===null||r===void 0?void 0:r[e]}function b(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+v+".");var r=E[F];r&&delete r[e]}var Xt=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},qt=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},He=function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("verbose",this._namespace,t)},e}();function I(e,t,r){var n=S("diag");if(n)return r.unshift(t),n[e].apply(n,qt([],Xt(r),!1))}var m;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(m||(m={}));function Je(e,t){e<m.NONE?e=m.NONE:e>m.ALL&&(e=m.ALL),t=t||{};function r(n,i){var o=t[n];return typeof o=="function"&&e>=i?o.bind(t):function(){}}return{error:r("error",m.ERROR),warn:r("warn",m.WARN),info:r("info",m.INFO),debug:r("debug",m.DEBUG),verbose:r("verbose",m.VERBOSE)}}var Ht=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},Jt=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},Qt="diag",k=function(){function e(){function t(i){return function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var l=S("diag");if(l)return l[i].apply(l,Jt([],Ht(o),!1))}}var r=this,n=function(i,o){var a,l,s;if(o===void 0&&(o={logLevel:m.INFO}),i===r){var c=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((a=c.stack)!==null&&a!==void 0?a:c.message),!1}typeof o=="number"&&(o={logLevel:o});var p=S("diag"),f=Je((l=o.logLevel)!==null&&l!==void 0?l:m.INFO,i);if(p&&!o.suppressOverrideMessage){var x=(s=new Error().stack)!==null&&s!==void 0?s:"<failed to generate stacktrace>";p.warn("Current logger will be overwritten from "+x),f.warn("Current logger will overwrite one already registered from "+x)}return A("diag",f,r,!0)};r.setLogger=n,r.disable=function(){b(Qt,r)},r.createComponentLogger=function(i){return new He(i)},r.verbose=t("verbose"),r.debug=t("debug"),r.info=t("info"),r.warn=t("warn"),r.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}();function Qe(e){return Symbol.for(e)}var Zt=function(){function e(t){var r=this;r._currentContext=t?new Map(t):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var o=new e(r._currentContext);return o._currentContext.set(n,i),o},r.deleteValue=function(n){var i=new e(r._currentContext);return i._currentContext.delete(n),i}}return e}(),Ze=new Zt;var er=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},tr=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},et=function(){function e(){}return e.prototype.active=function(){return Ze},e.prototype.with=function(t,r,n){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return r.call.apply(r,tr([n],er(i),!1))},e.prototype.bind=function(t,r){return r},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}();var rr=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},nr=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},pe="context",or=new et,U=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return A(pe,t,k.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,r,n){for(var i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return(i=this._getContextManager()).with.apply(i,nr([t,r,n],rr(o),!1))},e.prototype.bind=function(t,r){return this._getContextManager().bind(t,r)},e.prototype._getContextManager=function(){return S(pe)||or},e.prototype.disable=function(){this._getContextManager().disable(),b(pe,k.instance())},e}();var Y;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(Y||(Y={}));var me="0000000000000000",de="00000000000000000000000000000000",tt={traceId:de,spanId:me,traceFlags:Y.NONE};var h=function(){function e(t){t===void 0&&(t=tt),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,r){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,r){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,r){},e}();var ye=Qe("OpenTelemetry Context Key SPAN");function X(e){return e.getValue(ye)||void 0}function rt(){return X(U.getInstance().active())}function N(e,t){return e.setValue(ye,t)}function nt(e){return e.deleteValue(ye)}function ot(e,t){return N(e,new h(t))}function q(e){var t;return(t=X(e))===null||t===void 0?void 0:t.spanContext()}var ir=/^([0-9a-f]{32})$/i,ar=/^[0-9a-f]{16}$/i;function sr(e){return ir.test(e)&&e!==de}function gr(e){return ar.test(e)&&e!==me}function H(e){return sr(e.traceId)&&gr(e.spanId)}function it(e){return new h(e)}var xe=U.getInstance(),J=function(){function e(){}return e.prototype.startSpan=function(t,r,n){n===void 0&&(n=xe.active());var i=!!r?.root;if(i)return new h;var o=n&&q(n);return cr(o)&&H(o)?new h(o):new h},e.prototype.startActiveSpan=function(t,r,n,i){var o,a,l;if(!(arguments.length<2)){arguments.length===2?l=r:arguments.length===3?(o=r,l=n):(o=r,a=n,l=i);var s=a??xe.active(),c=this.startSpan(t,o,s),p=N(s,c);return xe.with(p,l,void 0,c)}},e}();function cr(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var lr=new J,at=function(){function e(t,r,n,i){this._provider=t,this.name=r,this.version=n,this.options=i}return e.prototype.startSpan=function(t,r,n){return this._getTracer().startSpan(t,r,n)},e.prototype.startActiveSpan=function(t,r,n,i){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):lr},e}();var st=function(){function e(){}return e.prototype.getTracer=function(t,r,n){return new J},e}();var ur=new st,ve=function(){function e(){}return e.prototype.getTracer=function(t,r,n){var i;return(i=this.getDelegateTracer(t,r,n))!==null&&i!==void 0?i:new at(this,t,r,n)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:ur},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(t,r,n)},e}();var Se="trace",gt=function(){function e(){this._proxyTracerProvider=new ve,this.wrapSpanContext=it,this.isSpanContextValid=H,this.deleteSpan=nt,this.getSpan=X,this.getActiveSpan=rt,this.getSpanContext=q,this.setSpan=N,this.setSpanContext=ot}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var r=A(Se,this._proxyTracerProvider,k.instance());return r&&this._proxyTracerProvider.setDelegate(t),r},e.prototype.getTracerProvider=function(){return S(Se)||this._proxyTracerProvider},e.prototype.getTracer=function(t,r){return this.getTracerProvider().getTracer(t,r)},e.prototype.disable=function(){b(Se,k.instance()),this._proxyTracerProvider=new ve},e}();var he=gt.getInstance();var Yn=he.getTracer("@eser/logging");var Te=(e,t,r)=>{let n=e.streamText(t,r);return{name:`ai-text/${e.provider}/${e.modelId}`,readable:new ReadableStream({async start(i){try{for await(let o of n)o.kind==="content_delta"&&i.enqueue(te(o.textDelta));i.close()}catch(o){i.error(o)}}})}};var dr={cc:"claude-code",ol:"ollama",oc:"opencode",oai:"openai",ant:"anthropic",gem:"gemini",vtx:"vertexai"},yr={"claude-code":"Claude Code",ollama:"Ollama",opencode:"OpenCode",kiro:"Kiro",anthropic:"Anthropic API",openai:"OpenAI API",gemini:"Gemini API",vertexai:"Vertex AI"},xr=e=>dr[e]??e,vr=async e=>{if(e){let t=T.process.stderr.getWriter(),r=ne({renderer:_e.ansi(),sink:oe.writable(new WritableStream({async write(n){await t.write(new TextEncoder().encode(String(n.data)))},close(){t.releaseLock()}}))});await K.configure({sinks:{stderr:B.getOutputSink(r)},loggers:[{category:["ai"],lowestLevel:g.Debug,sinks:["stderr"]}]})}return W.getLogger(["ai","ask"])},Sr=async e=>{await e.info("Auto-detecting AI provider...");try{if(await ie`which claude`.noThrow().code()===0)return await e.info("Claude Code detected."),"claude-code"}catch{}try{if((await fetch("http://localhost:11434/api/version",{signal:AbortSignal.timeout(1e3)})).ok)return await e.info("Ollama detected at localhost:11434."),"ollama"}catch{}try{if(await ie`which opencode`.noThrow().code()===0)return await e.info("OpenCode detected."),"opencode"}catch{}if(T.capabilities.env){if(T.env.has("ANTHROPIC_API_KEY"))return await e.info("Anthropic API key detected."),"anthropic";if(T.env.has("OPENAI_API_KEY"))return await e.info("OpenAI API key detected."),"openai"}throw new Error("No AI provider detected. Install claude, ollama, or set ANTHROPIC_API_KEY / OPENAI_API_KEY.")},hr=async e=>{switch(e){case"claude-code":return(await import("./claude-code-FZXKRWA5.js")).claudeCodeFactory;case"ollama":return(await import("./ollama-TM4MMP7N.js")).ollamaFactory;case"opencode":return(await import("./opencode-YGNBYWQL.js")).openCodeFactory;case"kiro":return(await import("./kiro-AC5LYTVB.js")).kiroFactory;case"anthropic":return(await import("./anthropic-UTLWCK66.js")).anthropicFactory;case"openai":return(await import("./openai-QGEN33SU.js")).openaiFactory;case"gemini":return(await import("./gemini-YR5KT32S.js")).geminiFactory;case"vertexai":return(await import("./vertexai-RUXZ24C2.js")).vertexaiFactory;default:throw new Error(`Unknown provider: ${e}`)}},lo=async e=>{let t=e??[],r=null,n=null,i=null,o=!1,a=!1,l=[],s=0;for(;s<t.length;){let f=t[s];if(f==="-p"||f==="--provider"){r=t[s+1]??null,s+=2;continue}if(f==="-m"||f==="--model"){n=t[s+1]??null,s+=2;continue}if(f==="--max-tokens"){let x=t[s+1];x!==void 0&&(i=Number(x)),s+=2;continue}if(f==="--json"){o=!0,s+=1;continue}if(f==="-v"||f==="--verbose"){a=!0,s+=1;continue}f.startsWith("-")||l.push(f),s+=1}let c=l.join(" ");if(c.length===0)return D({message:'Usage: ai ask "your prompt" [-p provider] [-m model] [--verbose]',exitCode:1});let p=await vr(a);try{let f=r!==null?xr(r):await Sr(p),x=yr[f]??f,Ce=n??Lr(f);await p.info(`Using ${x} (${Ce})`);let lt=await hr(f),Q=new Ie({factories:[lt]});await Q.addModel("default",{provider:f,model:Ce});let Z=Q.getDefault();if(Z===null)return D({message:"Failed to initialize model",exitCode:1});let we=[Fe("user",c)];if(await p.info(`Sending prompt (${c.length} chars)...`),o){let O=await Z.generateText({messages:we,maxTokens:i??void 0});await p.info(`Response received (${Ee(O).length} chars)`);let P=ne({sink:oe.stdout()});P.writeln(JSON.stringify(O,null,2)),await P.close()}else{let O=Te(Z,{messages:we,maxTokens:i??void 0});await Re().from(O).to(wr()).run();let P=T.process.stdout.getWriter();await P.write(new TextEncoder().encode(`
|
|
2
2
|
`)),P.releaseLock()}return await Q.close(),Le(void 0)}catch(f){let x=f instanceof Error?f.message:String(f);return await p.error(x),a&&f instanceof Error&&f.cause!==void 0&&await p.debug(`Cause: ${String(f.cause)}`),D({message:x,exitCode:1})}},Tr=12,Cr=e=>new Promise(t=>setTimeout(t,e)),wr=(e=Tr)=>{let t=new TextEncoder;return{name:"typewriter",writable:new WritableStream({async write(r){let n=String(r.data),i=T.process.stdout.getWriter();for(let o of n)await i.write(t.encode(o)),await Cr(e);i.releaseLock()}})}},Lr=e=>{switch(e){case"claude-code":return"claude-sonnet-4-20250514";case"ollama":return"llama3";case"opencode":return"default";case"kiro":return"default";case"anthropic":return"claude-sonnet-4-20250514";case"openai":return"gpt-4o";case"gemini":return"gemini-2.0-flash";case"vertexai":return"gemini-2.0-flash";default:return"default"}};export{lo as main};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v}from"./chunk-YK6UG66R.js";import{
|
|
1
|
+
import{c as v}from"./chunk-YK6UG66R.js";import{l as A}from"./chunk-FJCXMC2D.js";import{d as k,f as S,h as y,i as x,j as C}from"./chunk-QYMX2GR3.js";import{c as d,d as l,f as i,h as f,o as w,q as h,r as g}from"./chunk-Y6AFIAJP.js";import{a as u,b as r}from"./chunk-2N4GTHXQ.js";import{b as c}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";var q=async p=>{let e=w({renderer:g.ansi(),sink:h.stdout()}),n=c.process.cwd(),o=y(p);if(!o.ok)return e.writeln(i(o.error)),await e.close(),r({exitCode:1});let m=(p??[]).filter(t=>!t.startsWith("--spec=")).join(" ")||"No reason given",s;try{s=await S(n,o.spec)}catch(t){let E=t instanceof Error?t.message:String(t);return e.writeln(i(E)),await e.close(),r({exitCode:1})}if(s.spec!==null){let t=`${n}/${k.specDir(s.spec)}`;try{await c.fs.stat(t)}catch{return e.writeln(i(`Active spec '${s.spec}' directory not found.`)),e.writeln(l("Run `noskills reset` to return to IDLE.")),await e.close(),r({exitCode:1})}}if(s.phase!=="EXECUTING")return e.writeln(i(`Cannot block in phase: ${s.phase}`)),await e.close(),r({exitCode:1});let a=A(s,m);return await x(n,a),a.spec!==null&&await C(n,a.spec,a),e.writeln(f("\u26A0")," Spec blocked: ",l(m)),e.writeln("Resolve with: ",d(`${v('next --answer="resolution"')}`)),await e.close(),u(void 0)};export{q as main};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,d as k}from"./chunk-
|
|
1
|
+
import{a as C,d as k}from"./chunk-6FTHIS2Z.js";import{n as y}from"./chunk-FJCXMC2D.js";import{d as w,f as h,h as S,i as g,j as E}from"./chunk-QYMX2GR3.js";import{d as l,f as n,g as m,o as u,q as d,r as f}from"./chunk-Y6AFIAJP.js";import{a as o,b as i}from"./chunk-2N4GTHXQ.js";import{b as p}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";var F=async D=>{let e=u({renderer:f.ansi(),sink:d.stdout()}),r=p.process.cwd(),c=S(D);if(!c.ok)return e.writeln(n(c.error)),await e.close(),i({exitCode:1});let s;try{s=await h(r,c.spec)}catch(a){let I=a instanceof Error?a.message:String(a);return e.writeln(n(I)),await e.close(),i({exitCode:1})}if(s.phase==="IDLE"||s.phase==="FREE"||s.phase==="UNINITIALIZED"||s.phase==="COMPLETED")return e.writeln(n(`Cannot cancel in phase: ${s.phase}`)),await e.close(),i({exitCode:1});if(s.spec!==null){let a=`${r}/${w.specDir(s.spec)}`;try{await p.fs.stat(a)}catch{return e.writeln(n(`Active spec '${s.spec}' directory not found.`)),e.writeln(l("Run `noskills reset` to return to IDLE.")),await e.close(),i({exitCode:1})}}let t=y(s,"cancelled");return await g(r,t),t.spec!==null&&await E(r,t.spec,t),t.spec!==null&&(await C(r,t.spec,"cancelled"),await k(r,t.spec,"cancelled")),e.writeln(m("\u2714")," Spec cancelled."),await e.close(),o(void 0)};export{F as main};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as o}from"./chunk-
|
|
1
|
+
import{d as o}from"./chunk-QYMX2GR3.js";import{b as e}from"./chunk-MNEZ5QGX.js";var d=async(r,i,n)=>{let s=`${r}/${o.specFile(i)}`;try{let t=await e.fs.readTextFile(s);t=t.replace(/^## Status: .+$/m,`## Status: ${n}`),await e.fs.writeTextFile(s,t)}catch{}},u=async(r,i,n)=>{let s=`${r}/${o.specFile(i)}`;try{let t=await e.fs.readTextFile(s),a=new RegExp(`^(- )\\[ \\]( ${n}:.*)$`,"m");t=t.replace(a,"$1[x]$2"),await e.fs.writeTextFile(s,t)}catch{}},w=async(r,i,n,s)=>{let t=`${r}/${o.specDir(i)}/progress.json`;try{let a=await e.fs.readTextFile(t),c=JSON.parse(a);for(let p of c.tasks)p.id===n&&(p.status=s);c.updatedAt=new Date().toISOString(),await e.fs.writeTextFile(t,JSON.stringify(c,null,2)+`
|
|
2
2
|
`)}catch{}},f=async(r,i,n)=>{let s=`${r}/${o.specDir(i)}/progress.json`;try{let t=await e.fs.readTextFile(s),a=JSON.parse(t);a.status=n,a.updatedAt=new Date().toISOString(),await e.fs.writeTextFile(s,JSON.stringify(a,null,2)+`
|
|
3
3
|
`)}catch{}};export{d as a,u as b,w as c,f as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{c as m}from"./chunk-MNEZ5QGX.js";import{m as v}from"./chunk-4BH6CF3J.js";var p=class extends Error{constructor(e,n,s,i){super(e);this.command=n;this.code=s;this.stderr=i;this.name="CommandError"}};var l=new TextDecoder,h=class r{#t;#r;#e;constructor(t,e=[],n={}){this.#t=t,this.#r=e,this.#e={throwOnError:!0,stdout:"piped",stderr:"piped",...n}}cwd(t){return new r(this.#t,this.#r,{...this.#e,cwd:t})}env(t,e){let n=this.#e.env??{},s;return typeof t=="string"&&e!==void 0?s={...n,[t]:e}:t!==null&&typeof t=="object"?s={...n,...t}:s=n,new r(this.#t,this.#r,{...this.#e,env:s})}stdin(t){return new r(this.#t,this.#r,{...this.#e,stdin:t})}stdout(t){return new r(this.#t,this.#r,{...this.#e,stdout:t})}stderr(t){return new r(this.#t,this.#r,{...this.#e,stderr:t})}timeout(t){return new r(this.#t,this.#r,{...this.#e,timeout:t})}noThrow(){return new r(this.#t,this.#r,{...this.#e,throwOnError:!1})}quiet(){return new r(this.#t,this.#r,{...this.#e,stdout:"null",stderr:"null"})}printCommand(){let t=[this.#t,...this.#r].join(" ");return console.log(`$ ${t}`),this}async spawn(){let{runtime:t}=m,e=await t.exec.spawn(this.#t,this.#r,{cwd:this.#e.cwd,env:this.#e.env,stdin:this.#e.stdin,stdout:this.#e.stdout,stderr:this.#e.stderr});if(!e.success&&this.#e.throwOnError===!0){let n=l.decode(e.stderr);throw new p(`Command failed with exit code ${e.code}: ${this.#t}`,this.#t,e.code,n)}return e}async text(t="stdout"){let e=await this.spawn();switch(t){case"stdout":return l.decode(e.stdout).trim();case"stderr":return l.decode(e.stderr).trim();case"combined":return(l.decode(e.stdout)+l.decode(e.stderr)).trim()}}async json(){let t=await this.text();return JSON.parse(t)}async lines(){let t=await this.text();return t===""?[]:t.split(`
|
|
2
|
+
`)}async bytes(){return(await this.spawn()).stdout}async code(){return(await this.noThrow().spawn()).code}pipe(t){return new f([this,t])}child(){let{runtime:t}=m;return t.exec.spawnChild(this.#t,this.#r,{cwd:this.#e.cwd,env:this.#e.env,stdin:this.#e.stdin??"piped",stdout:this.#e.stdout??"piped",stderr:this.#e.stderr??"piped"})}},f=class r{#t;constructor(t){this.#t=t}pipe(t){return new r([...this.#t,t])}async text(){let t="";for(let e of this.#t){let n=await e.spawn();t=l.decode(n.stdout)}return t.trim()}async lines(){let t=await this.text();return t===""?[]:t.split(`
|
|
3
|
+
`)}};var y=(r,t)=>{let e=[];for(let s=0;s<r.length;s++){let i=r[s];if(i!==void 0&&e.push(i),s<t.length){let d=t[s];Array.isArray(d)?e.push(d.map(c=>S(String(c))).join(" ")):d!=null&&e.push(S(String(d)))}}let n=e.join("").trim();return O(n)},S=r=>/[\s"'\\$`]/.test(r)?`'${r.replace(/'/g,"'\\''")}'`:r,O=r=>{let t=[],e="",n=!1,s=!1,i=!1;for(let c=0;c<r.length;c++){let a=r[c];if(i){e+=a,i=!1;continue}if(a==="\\"){i=!0;continue}if(a==="'"&&!s){n=!n;continue}if(a==='"'&&!n){s=!s;continue}if(a===" "&&!n&&!s){e.length>0&&(t.push(e),e="");continue}e+=a}e.length>0&&t.push(e);let d=t[0];return d===void 0?["",[]]:[d,t.slice(1)]};var E=(r,...t)=>{let[e,n]=y(r,t);return new h(e,n)};var B=/\x04/g,A=/^Script (started|done),? ?(output file is )?[^\n]*\n?/gm,M=r=>r.replace(B,"").replace(A,""),k=(r,t)=>{let e=v();return e==="darwin"?{cmd:"script",args:["-q","/dev/null",r,...t],usesScript:!0}:e==="linux"?{cmd:"script",args:["-qc",t.length>0?`${r} ${t.map(s=>`'${s.replace(/'/g,"'\\''")}'`).join(" ")}`:r,"/dev/null"],usesScript:!0}:{cmd:r,args:t,usesScript:!1}},I=async r=>{let{runtime:t}=m,e=r.args!==void 0?[...r.args]:[],n=k(r.command,e),s={...r.env,TERM:"xterm-256color",COLUMNS:String(r.cols??80),LINES:String(r.rows??24)},i=t.exec.spawnChild(n.cmd,[...n.args],{cwd:r.cwd,env:s,stdin:"piped",stdout:"piped",stderr:"piped"}),d=new TextDecoder,c=new TextEncoder,a=[],C=!1,b=o=>{let u=n.usesScript?M(o):o;if(u.length!==0)for(let g of a)g(u)},x=async o=>{let u=o.getReader();try{for(;;){let{done:g,value:T}=await u.read();if(g)break;b(d.decode(T))}}catch{}finally{u.releaseLock()}},R=()=>{C||(C=!0,i.stdout&&x(i.stdout),i.stderr&&x(i.stderr))},P=null;return i.stdin&&(P=i.stdin.getWriter()),{onData(o){a.push(o),R()},write(o){P?.write(c.encode(o)).catch(()=>{})},resize(o,u){},kill(o){try{i.kill(o==="SIGKILL"?"SIGKILL":"SIGTERM")}catch{}},get pid(){return i.pid},get exitCode(){return i.status.then(o=>o.code)}}};var w=class{#t=new Map;get size(){return this.#t.size}add(t,e){let n={id:t,process:e,active:!0};return this.#t.set(t,n),e.exitCode.then(()=>{n.active=!1}).catch(()=>{n.active=!1}),n}get(t){return this.#t.get(t)}remove(t){let e=this.#t.get(t);return e===void 0?!1:(e.active&&e.process.kill(),this.#t.delete(t),!0)}list(){return[...this.#t.values()]}async killAll(t="SIGTERM"){for(let s of this.#t.values())s.active&&s.process.kill(t);let e=3e3,n=Date.now();for(let s of this.#t.values())if(s.active){let i=e-(Date.now()-n);i>0&&await Promise.race([s.process.exitCode,new Promise(d=>setTimeout(d,i))])}}forceKillAll(){for(let t of this.#t.values())t.active&&(t.process.kill("SIGKILL"),t.active=!1);this.#t.clear()}};export{p as a,h as b,y as c,E as d,I as e,w as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a}from"./chunk-QYMX2GR3.js";var i={UNINITIALIZED:["IDLE"],IDLE:["DISCOVERY","COMPLETED","FREE"],FREE:["IDLE"],DISCOVERY:["DISCOVERY_REVIEW","COMPLETED"],DISCOVERY_REVIEW:["DISCOVERY_REVIEW","SPEC_DRAFT","COMPLETED"],SPEC_DRAFT:["SPEC_DRAFT","SPEC_APPROVED","COMPLETED"],SPEC_APPROVED:["EXECUTING","COMPLETED"],EXECUTING:["COMPLETED","BLOCKED"],BLOCKED:["EXECUTING","COMPLETED"],COMPLETED:["IDLE","DISCOVERY"]},l=(e,s)=>i[e].includes(s),t=(e,s)=>{if(!l(e,s))throw new Error(`Invalid phase transition: ${e} \u2192 ${s}. Allowed: ${i[e].join(", ")}`)},h=(e,s)=>(t(e.phase,s),{...e,phase:s}),E=(e,s,n,o)=>(t(e.phase,"DISCOVERY"),{...e,phase:"DISCOVERY",spec:s,specDescription:o??null,branch:n,discovery:{answers:[],completed:!1,currentQuestion:0,audience:"human",approved:!1},specState:{path:null,status:"none"},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},decisions:[]}),u=e=>(t(e.phase,"FREE"),{...e,phase:"FREE"}),d=e=>(t(e.phase,"IDLE"),{...e,phase:"IDLE"}),m=(e,s,n)=>{if(e.phase!=="DISCOVERY"&&e.phase!=="DISCOVERY_REVIEW")throw new Error(`Cannot add discovery answer in phase: ${e.phase}`);let r=[...e.discovery.answers.filter(c=>c.questionId!==s),{questionId:s,answer:n}];return{...e,discovery:{...e.discovery,answers:r}}},S=e=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot complete discovery in phase: ${e.phase}`);return{...e,phase:"DISCOVERY_REVIEW",discovery:{...e.discovery,completed:!0},specState:{path:a.specFile(e.spec),status:"draft"}}},C=e=>(t(e.phase,"SPEC_DRAFT"),{...e,phase:"SPEC_DRAFT"}),D=e=>{if(e.phase!=="DISCOVERY_REVIEW")throw new Error(`Cannot approve discovery answers in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,approved:!0}}},F=e=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot advance discovery question in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,currentQuestion:e.discovery.currentQuestion+1}}},I=e=>(t(e.phase,"SPEC_APPROVED"),{...e,phase:"SPEC_APPROVED",specState:{...e.specState,status:"approved"}}),v=e=>(t(e.phase,"EXECUTING"),{...e,phase:"EXECUTING",discovery:{...e.discovery,completed:!0,approved:!1},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]}});var R=(e,s)=>(t(e.phase,"BLOCKED"),{...e,phase:"BLOCKED",execution:{...e.execution,lastProgress:`BLOCKED: ${s}`}}),O=(e,s)=>({...e,decisions:[...e.decisions,s]}),P=(e,s,n)=>(t(e.phase,"COMPLETED"),{...e,phase:"COMPLETED",completionReason:s,completedAt:new Date().toISOString(),completionNote:n??null}),w=e=>{if(e.phase!=="COMPLETED")throw new Error(`Cannot reopen in phase: ${e.phase}`);return{...e,phase:"DISCOVERY",reopenedFrom:e.completionReason,completionReason:null,completedAt:null,completionNote:null,discovery:{...e.discovery,completed:!1,currentQuestion:0},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},classification:null}},x=(e,s)=>{if(e.phase!=="EXECUTING"&&e.phase!=="BLOCKED")throw new Error(`Cannot revisit in phase: ${e.phase}. Only EXECUTING or BLOCKED can revisit.`);let n={from:e.phase,reason:s,completedTasks:[...e.execution.completedTasks],timestamp:new Date().toISOString()};return{...e,phase:"DISCOVERY",discovery:{...e.discovery,completed:!1,currentQuestion:0,approved:!1},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},classification:null,revisitHistory:[...e.revisitHistory??[],n]}},f=e=>({...e,phase:"IDLE",spec:null,branch:null,discovery:{answers:[],completed:!1,currentQuestion:0,audience:"human",approved:!1},specState:{path:null,status:"none"},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},decisions:[],classification:null,completionReason:null,completedAt:null,completionNote:null,reopenedFrom:null});export{h as a,E as b,u as c,d,m as e,S as f,C as g,D as h,F as i,I as j,v as k,R as l,O as m,P as n,w as o,x as p,f as q};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as u,c as Ae,d,e as $,f as S,g as b,h as O,i as Oe,k as R,l as _,n as U,o as he,q as ee,r as te}from"./chunk-Y6AFIAJP.js";import{b as C}from"./chunk-MNEZ5QGX.js";import{d as N}from"./chunk-OTRBRRIO.js";var h=Symbol("tui.cancel"),Ke=e=>e===h,Ee={ctrlC:"exit",escape:"cancel"},Fe=()=>{try{return C.process.stdin}catch{return new ReadableStream}},He=e=>{let t=e?.interaction??(e?.target==="non-interactive"?"non-interactive":"interactive"),r=e?.audience??"human",s=t==="non-interactive"?"non-interactive":"interactive",n=t==="interactive";return{output:e?.output??he({renderer:n?te.ansi():te.plain(),sink:n?ee.stdout():ee.stderr()}),input:e?.input??Fe(),target:s,interaction:t,audience:r,signals:{...Ee,...e?.signals},stderr:e?.stderr??he({renderer:te.plain(),sink:ee.stderr()})}};var Pe={};N(Pe,{disableMouse:()=>We,enableMouse:()=>qe,isSGRMouseSequence:()=>ye,parseMouseEvent:()=>fe});var qe=()=>"\x1B[?1000h\x1B[?1002h\x1B[?1006h",We=()=>"\x1B[?1006l\x1B[?1002l\x1B[?1000l",je=/^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/,fe=e=>{let t=e.match(je);if(t===null)return null;let r=parseInt(t[1],10),s=parseInt(t[2],10)-1,n=parseInt(t[3],10)-1,i=t[4]==="m",o=r&3,a=(r&4)!==0,c=(r&16)!==0,p=(r&32)!==0;return(r&64)!==0?{type:"wheel",button:0,x:s,y:n,shift:a,ctrl:c,direction:r&1?"down":"up"}:p?{type:"mousemove",button:o,x:s,y:n,shift:a,ctrl:c}:{type:i?"mouseup":"mousedown",button:o,x:s,y:n,shift:a,ctrl:c}},ye=e=>e.length>=4&&e[0]===27&&e[1]===91&&e[2]===60;var E=async e=>{let t=!1;if(C.capabilities.stdin&&C.process.isTerminal("stdin"))try{C.process.setStdinRaw(!0),t=!0}catch{}try{return await e()}finally{if(t)try{C.process.setStdinRaw(!1)}catch{}}},P=e=>{e.write(u("\x1B[?25l"))},k=e=>{e.write(u("\x1B[?25h"))},f=(e,t)=>{t>0&&e.write(u(`\x1B[${t}A\x1B[J`))};var Le=e=>{let t=new Uint8Array(e);if(e.length===1&&e[0]===3)return{name:"c",ctrl:!0,meta:!1,shift:!1,raw:t};if(e.length===1&&e[0]===27)return{name:"escape",ctrl:!1,meta:!1,shift:!1,raw:t};if(e.length===1&&(e[0]===13||e[0]===10))return{name:"return",ctrl:!1,meta:!1,shift:!1,raw:t};if(e.length===1&&e[0]===9)return{name:"tab",ctrl:!1,meta:!1,shift:!1,raw:t};if(e.length===1&&e[0]===127)return{name:"backspace",ctrl:!1,meta:!1,shift:!1,raw:t};if(e.length>=3&&e[0]===27&&e[1]===91)switch(e[2]){case 65:return{name:"up",ctrl:!1,meta:!1,shift:!1,raw:t};case 66:return{name:"down",ctrl:!1,meta:!1,shift:!1,raw:t};case 67:return{name:"right",ctrl:!1,meta:!1,shift:!1,raw:t};case 68:return{name:"left",ctrl:!1,meta:!1,shift:!1,raw:t};case 72:return{name:"home",ctrl:!1,meta:!1,shift:!1,raw:t};case 70:return{name:"end",ctrl:!1,meta:!1,shift:!1,raw:t}}if(e.length===1&&e[0]>=1&&e[0]<=26)return{name:String.fromCharCode(e[0]+96),ctrl:!0,meta:!1,shift:!1,raw:t};if(e.length===1&&e[0]===32)return{name:"space",char:" ",ctrl:!1,meta:!1,shift:!1,raw:t};if(e.length===1&&e[0]>=33&&e[0]<=126){let r=String.fromCharCode(e[0]);return{name:r,char:r,ctrl:!1,meta:!1,shift:!1,raw:t}}if(e.length>0&&e[0]>=192){let r=new TextDecoder().decode(e);return{name:r,char:r,ctrl:!1,meta:!1,shift:!1,raw:t}}return{name:"unknown",ctrl:!1,meta:!1,shift:!1,raw:t}};async function*L(e,t){let r=e.getReader();try{for(;!t?.aborted;){let{done:s,value:n}=await r.read();if(s||n===void 0)break;yield Le(n)}}finally{r.releaseLock()}}async function*ze(e,t){let r=e.getReader(),s=new TextDecoder;try{for(;!t?.aborted;){let{done:n,value:i}=await r.read();if(n||i===void 0)break;if(ye(i)){let o=s.decode(i),a=fe(o);if(a!==null){yield{kind:"mouse",event:a};continue}}yield{kind:"key",event:Le(i)}}}finally{r.releaseLock()}}var v=(e,t)=>{if(e==="exit"){k(t.output);try{C.process.setStdinRaw(!1)}catch{}C.process.exit(130)}return e==="cancel"?"cancel":"continue"};var g="\u2502",Be="\u250C",w="\u2514";var re="\u25CF",se="\u25CB",Me="\u25FC",Ie="\u25FB",I="\u25C6",T="\u25C7",A="\u25A0",Ne="\u25CF";var D="\u25B2";var _e="\u25C7";var ne=(e,t,r,s)=>{if(s==="done"){let o=r?"Yes":"No";return e.output.writeln(b(T),u(` ${t}`),d(` \xB7 ${o}`)),1}if(s==="cancel")return e.output.writeln(S(A),u(` ${t}`)),1;let n=r?$(b(re),u(" Yes")):$(d(se),d(" Yes")),i=r?$(d(se),d(" No")):$(b(re),u(" No"));return e.output.writeln(R(I),u(` ${t}`)),e.output.writeln(d(g),u(" "),n,d(" / "),i),e.output.writeln(d(w)),3},Xe=async(e,t)=>{let r=t.initialValue??!0,s=0;P(e.output);try{return await E(async()=>{s=ne(e,t.message,r,"active"),await e.output.flush();let n=()=>{f(e.output,s),ne(e,t.message,r,"cancel")};for await(let i of L(e.input)){if(i.name==="c"&&i.ctrl){if(v(e.signals.ctrlC,e)==="cancel")return n(),await e.output.flush(),h;continue}if(i.name==="escape"){if(v(e.signals.escape,e)==="cancel")return n(),await e.output.flush(),h;continue}if(i.name==="return")return f(e.output,s),ne(e,t.message,r,"done"),await e.output.flush(),r;let o=!1;(i.name==="left"||i.name==="right")&&(r=!r,o=!0),(i.name==="y"||i.name==="Y")&&(r=!0,o=!0),(i.name==="n"||i.name==="N")&&(r=!1,o=!0),o&&(f(e.output,s),s=ne(e,t.message,r,"active"),await e.output.flush())}return h})}finally{k(e.output),await e.output.flush()}};var F=(e,t,r,s,n,i)=>{if(i==="done")return e.output.writeln(b(T),u(` ${t}`),d(` \xB7 ${r}`)),1;if(i==="cancel")return e.output.writeln(S(A),u(` ${t}`)),1;let o=r.length>0?u(r):s!==void 0?d(s):u(""),a=n!==void 0?O(D):R(I);e.output.writeln(a,u(` ${t}`)),e.output.writeln(d(g),u(" "),o);let c=2;return n!==void 0?(e.output.writeln(d(w),u(" "),O(n)),c=3):(e.output.writeln(d(w)),c=3),c},Ye=async(e,t)=>{let r=t.initialValue??"",s=r.length,n,i=0;P(e.output);try{return await E(async()=>{i=F(e,t.message,r,t.placeholder,n,"active"),await e.output.flush();let o=()=>{f(e.output,i),F(e,t.message,r,t.placeholder,void 0,"cancel")};for await(let a of L(e.input)){if(a.name==="c"&&a.ctrl){if(v(e.signals.ctrlC,e)==="cancel")return o(),await e.output.flush(),h;continue}if(a.name==="escape"){if(v(e.signals.escape,e)==="cancel")return o(),await e.output.flush(),h;continue}if(a.name==="return"){if(t.validate!==void 0){let c=t.validate(r);if(c!==void 0){n=c,f(e.output,i),i=F(e,t.message,r,t.placeholder,n,"active"),await e.output.flush();continue}}return f(e.output,i),F(e,t.message,r,t.placeholder,void 0,"done"),await e.output.flush(),r}if(n=void 0,a.name==="backspace")s>0&&(r=r.slice(0,s-1)+r.slice(s),s--);else if(a.name==="left")s>0&&s--;else if(a.name==="right")s<r.length&&s++;else if(a.name==="home")s=0;else if(a.name==="end")s=r.length;else if(a.char!==void 0)r=r.slice(0,s)+a.char+r.slice(s),s++;else continue;f(e.output,i),i=F(e,t.message,r,t.placeholder,n,"active"),await e.output.flush()}return h})}finally{k(e.output),await e.output.flush()}};var H=(e,t,r,s,n,i,o)=>{if(o==="done"){let p=[...n].sort((l,m)=>l-m).map(l=>r[l]?.label??"").join(", ");return e.output.writeln(b(T),u(` ${t}`),d(` \xB7 ${p}`)),1}if(o==="cancel")return e.output.writeln(S(A),u(` ${t}`)),1;let a=i!==void 0?O(D):R(I);e.output.writeln(a,u(` ${t}`));for(let p=0;p<r.length;p++){let l=r[p],m=p===s,y=n.has(p),G=l.disabled===!0,ce=y?b(Me):d(Ie),pe=G?d(` ${l.label}`):m?u(` ${l.label}`):d(` ${l.label}`),de=l.hint!==void 0?d(` (${l.hint})`):u("");e.output.writeln(d(g),u(" "),ce,pe,de)}let c=r.length+2;return i!==void 0?e.output.writeln(d(w),u(" "),O(i)):e.output.writeln(d(w)),c},ge=(e,t,r)=>{let s=e.length,n=t;for(let i=0;i<s;i++)if(n=(n+r+s)%s,e[n]?.disabled!==!0)return n;return t},Je=async(e,t)=>{let r=0,s=new Set;if(t.initialValues!==void 0)for(let o of t.initialValues){let a=t.options.findIndex(c=>c.value===o);a>=0&&s.add(a)}t.options[r]?.disabled===!0&&(r=ge(t.options,r,1));let n=0,i;P(e.output);try{return await E(async()=>{n=H(e,t.message,t.options,r,s,i,"active"),await e.output.flush();let o=()=>{f(e.output,n),H(e,t.message,t.options,r,s,void 0,"cancel")};for await(let a of L(e.input)){if(a.name==="c"&&a.ctrl){if(v(e.signals.ctrlC,e)==="cancel")return o(),await e.output.flush(),h;continue}if(a.name==="escape"){if(v(e.signals.escape,e)==="cancel")return o(),await e.output.flush(),h;continue}if(a.name==="return"){if(t.required!==!1&&s.size===0){i="Please select at least one option.",f(e.output,n),n=H(e,t.message,t.options,r,s,i,"active"),await e.output.flush();continue}return f(e.output,n),H(e,t.message,t.options,r,s,void 0,"done"),await e.output.flush(),[...s].sort((p,l)=>p-l).map(p=>t.options[p].value)}i=void 0;let c=!1;if((a.name==="up"||a.name==="k")&&(r=ge(t.options,r,-1),c=!0),(a.name==="down"||a.name==="j")&&(r=ge(t.options,r,1),c=!0),a.name==="space"&&t.options[r]?.disabled!==!0&&(s.has(r)?s.delete(r):s.add(r),c=!0),a.name==="a"){let p=t.options.every((l,m)=>l.disabled===!0||s.has(m));for(let l=0;l<t.options.length;l++)t.options[l]?.disabled!==!0&&(p?s.delete(l):s.add(l));c=!0}c&&(f(e.output,n),n=H(e,t.message,t.options,r,s,i,"active"),await e.output.flush())}return h})}finally{k(e.output),await e.output.flush()}};var Ze=(e,t)=>{e.output.writeln(_(Be),u(" "),Ae(t)),e.output.writeln(_(g))},Qe=(e,t)=>{e.output.writeln(_(g)),e.output.writeln(_(w),u(" "),u(t))},et=e=>{e.output.writeln(u(""))},tt=(e,t)=>{e.output.writeln(u(" "),d(t))},rt=e=>{e.output.writeln(_(g))},st={info:(e,t)=>{e.output.writeln(U("info",t))},success:(e,t)=>{e.output.writeln(U("success",t))},warn:(e,t)=>{e.output.writeln(U("warning",t))},error:(e,t)=>{e.output.writeln(U("error",t))},step:(e,t)=>{e.output.writeln(d(_e),u(" "),d(t))},message:(e,t,r)=>{e.output.writeln(d(r??g),u(" "),u(t))}};var nt=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],it=80,ot=(e,t,r)=>{let s=r?.frames??nt,n=r?.interval??it,i=t,o=0,a,c=()=>{e.output.write(u(`\r${" ".repeat(i.length+4)}\r`))},p=()=>{a!==void 0&&(clearInterval(a),a=void 0,c())};return{start:l=>{l!==void 0&&(i=l),a=setInterval(()=>{let m=s[o%s.length];e.output.write(u("\r"),R(m??""),u(` ${i}`)),o++},n)},stop:l=>{p(),l!==void 0&&(i=l)},update:l=>{i=l},succeed:l=>{p(),e.output.writeln(b(T),u(` ${l??i}`))},fail:l=>{p(),e.output.writeln(S(A),u(` ${l??i}`))},warn:l=>{p(),e.output.writeln(O(D),u(` ${l??i}`))},info:l=>{p(),e.output.writeln(Oe(Ne),u(` ${l??i}`))}}};var De={};N(De,{clearScreenSeq:()=>pt,enterAlternateScreen:()=>at,exitAlternateScreen:()=>lt,getTerminalSize:()=>dt,hideCursorSeq:()=>ut,showCursorSeq:()=>ct});var at=()=>"\x1B[?1049h",lt=()=>"\x1B[?1049l",ut=()=>"\x1B[?25l",ct=()=>"\x1B[?25h",pt=()=>"\x1B[2J\x1B[H",dt=()=>{try{let{columns:e,rows:t}=Deno.consoleSize();return{cols:e,rows:t}}catch{return{cols:80,rows:24}}};var le={};N(le,{bgBlue:()=>yt,bgGreen:()=>ft,bold:()=>mt,cyan:()=>we,dim:()=>ie,green:()=>oe,inverse:()=>Ce,moveTo:()=>x,red:()=>xe,reset:()=>ae,stripAnsi:()=>ve,truncate:()=>W,visibleLength:()=>q,white:()=>ht,yellow:()=>be});var x=(e,t)=>`\x1B[${e};${t}H`,mt=e=>`\x1B[1m${e}\x1B[22m`,ie=e=>`\x1B[2m${e}\x1B[22m`,oe=e=>`\x1B[32m${e}\x1B[39m`,be=e=>`\x1B[33m${e}\x1B[39m`,xe=e=>`\x1B[31m${e}\x1B[39m`,we=e=>`\x1B[36m${e}\x1B[39m`,ht=e=>`\x1B[37m${e}\x1B[39m`,ft=e=>`\x1B[42m${e}\x1B[49m`,yt=e=>`\x1B[44m${e}\x1B[49m`,Ce=e=>`\x1B[7m${e}\x1B[27m`,ae=()=>"\x1B[0m",gt=/\x1b\[[0-9;]*[a-zA-Z]/g,ve=e=>e.replace(gt,""),q=e=>ve(e).length,W=(e,t)=>{if(ve(e).length<=t)return e;let s=0,n=0,i=e;for(;n<i.length&&s<t-1;){if(i[n]==="\x1B"){let o=i.indexOf("m",n);if(o!==-1){n=o+1;continue}}s++,n++}return i.slice(0,n)+"\u2026"+ae()};var Ge={};N(Ge,{calculateLayout:()=>bt});var bt=(e,t,r)=>{let s=r.leftWidth<=1?Math.floor(e*r.leftWidth):Math.min(Math.floor(r.leftWidth),e),n=e-s,i=t-1,o=r.rightTopHeight<=1?Math.floor(i*r.rightTopHeight):Math.min(Math.floor(r.rightTopHeight),i),a=i-o;return{left:{id:"left",x:1,y:1,width:s,height:i},rightTop:{id:"rightTop",x:s+1,y:1,width:n,height:o},rightBottom:{id:"rightBottom",x:s+1,y:o+1,width:n,height:a},statusBar:{id:"statusBar",x:1,y:t,width:e,height:1}}};var $e={};N($e,{nextSelectableIndex:()=>wt,renderList:()=>Ct});var xt=(e,t)=>{switch(t){case"green":return oe(e);case"yellow":return be(e);case"red":return xe(e);case"cyan":return we(e);case"dim":return ie(e);default:return e}},wt=(e,t,r)=>{let s=r==="up"?-1:1,n=t+s;for(;n>=0&&n<e.length;){if(e[n].selectable!==!1)return n;n+=s}return t},Ct=(e,t,r)=>{let s=[],n=r.width-2,i=r.height-2,o=0;t>=i&&(o=t-i+1);for(let a=0;a<i;a++){let c=o+a,p=r.y+1+a;if(c>=e.length){s.push(x(p,r.x+1)+" ".repeat(n));continue}let l=e[c],m=l.selectable!==!1,y=c===t&&m,G=l.active?oe("\u25CF"):y?"\u25B8":" ",ce=l.badge!==void 0?" "+xt(`[${l.badge}]`,l.badgeColor??"dim"):"",pe=l.dimmed?ie(l.label):l.label,de=` ${G} ${pe}${ce}`,me=W(de,n),ke=Math.max(0,n-q(me));y?s.push(x(p,r.x+1)+Ce(me+" ".repeat(ke))):s.push(x(p,r.x+1)+me+" ".repeat(ke))}return s.join("")};var z=()=>({char:" ",fg:-1,bg:-1,fgRGB:null,bgRGB:null,bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1}),ue=(e,t)=>{let r=[];for(let s=0;s<e;s++){let n=[];for(let i=0;i<t;i++)n.push(z());r.push(n)}return r},j=e=>{let t=[];for(let r=0;r<e;r++)t.push(z());return t},X=class{#e;#t;#r;#i=null;#o=0;#n;#s=new Set;constructor(t,r){this.#e=t,this.#t=r,this.#r=ue(t,r),this.#n=t-1}get rows(){return this.#e}get cols(){return this.#t}getCell(t,r){return t<0||t>=this.#e||r<0||r>=this.#t?z():this.#r[t][r]}setCell(t,r,s,n){t<0||t>=this.#e||r<0||r>=this.#t||(this.#r[t][r]={char:n,fg:s.fg,bg:s.bg,fgRGB:s.fgRGB,bgRGB:s.bgRGB,bold:s.bold,dim:s.dim,italic:s.italic,underline:s.underline,inverse:s.inverse},this.#s.add(t))}scrollUp(t=1){for(let r=0;r<t;r++)this.#r.splice(this.#o,1),this.#r.splice(this.#n,0,j(this.#t));for(let r=this.#o;r<=this.#n;r++)this.#s.add(r)}scrollDown(t=1){for(let r=0;r<t;r++)this.#r.splice(this.#n,1),this.#r.splice(this.#o,0,j(this.#t));for(let r=this.#o;r<=this.#n;r++)this.#s.add(r)}setScrollRegion(t,r){this.#o=Math.max(0,t),this.#n=Math.min(this.#e-1,r)}insertLines(t,r){for(let s=0;s<t;s++)this.#r.splice(this.#n,1),this.#r.splice(r,0,j(this.#t));for(let s=r;s<=this.#n;s++)this.#s.add(s)}deleteLines(t,r){for(let s=0;s<t;s++)this.#r.splice(r,1),this.#r.splice(this.#n,0,j(this.#t));for(let s=r;s<=this.#n;s++)this.#s.add(s)}clearLine(t,r){if(t<0||t>=this.#e)return;let s=this.#r[t];if(r===2)for(let n=0;n<this.#t;n++)s[n]=z();this.#s.add(t)}clearLineRange(t,r,s){if(t<0||t>=this.#e)return;let n=this.#r[t];for(let i=r;i<=Math.min(s,this.#t-1);i++)n[i]=z();this.#s.add(t)}clearDisplay(t,r,s){if(t===0){this.clearLineRange(r,s,this.#t-1);for(let n=r+1;n<this.#e;n++)this.clearLine(n,2)}else if(t===1){for(let n=0;n<r;n++)this.clearLine(n,2);this.clearLineRange(r,0,s)}else{this.#r=ue(this.#e,this.#t);for(let n=0;n<this.#e;n++)this.#s.add(n)}}enterAlternateScreen(){this.#i=this.#r,this.#r=ue(this.#e,this.#t);for(let t=0;t<this.#e;t++)this.#s.add(t)}exitAlternateScreen(){if(this.#i!==null){this.#r=this.#i,this.#i=null;for(let t=0;t<this.#e;t++)this.#s.add(t)}}resize(t,r){let s=ue(t,r),n=Math.min(t,this.#e),i=Math.min(r,this.#t);for(let o=0;o<n;o++)for(let a=0;a<i;a++)s[o][a]=this.#r[o][a];this.#e=t,this.#t=r,this.#r=s,this.#n=t-1;for(let o=0;o<t;o++)this.#s.add(o)}getLine(t){return t<0||t>=this.#e?j(this.#t):this.#r[t]}getGrid(){return this.#r}getDirtyLines(){return this.#s}clearDirty(){this.#s.clear()}markAllDirty(){for(let t=0;t<this.#e;t++)this.#s.add(t)}};var Y=class{row=0;col=0;visible=!0;#e=0;#t=0;moveTo(t,r){this.row=t,this.col=r}moveUp(t=1){this.row=Math.max(0,this.row-t)}moveDown(t=1){this.row+=t}moveForward(t=1){this.col+=t}moveBack(t=1){this.col=Math.max(0,this.col-t)}moveToColumn(t){this.col=t}save(){this.#e=this.row,this.#t=this.col}restore(){this.row=this.#e,this.col=this.#t}clamp(t,r){this.row=Math.max(0,Math.min(this.row,t-1)),this.col=Math.max(0,Math.min(this.col,r-1))}};var J=()=>({fg:-1,bg:-1,fgRGB:null,bgRGB:null,bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1}),Te=(e,t)=>{let r={...t},s=0;for(;s<e.length;){let n=e[s];switch(n){case 0:Object.assign(r,J());break;case 1:r.bold=!0;break;case 2:r.dim=!0;break;case 3:r.italic=!0;break;case 4:r.underline=!0;break;case 7:r.inverse=!0;break;case 22:r.bold=!1,r.dim=!1;break;case 23:r.italic=!1;break;case 24:r.underline=!1;break;case 27:r.inverse=!1;break;case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:r.fg=n-30;break;case 39:r.fg=-1;break;case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:r.bg=n-40;break;case 49:r.bg=-1;break;case 90:case 91:case 92:case 93:case 94:case 95:case 96:case 97:r.fg=n-90+8;break;case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:r.bg=n-100+8;break;case 38:s+1<e.length&&e[s+1]===5&&s+2<e.length?(r.fg=e[s+2],r.fgRGB=null,s+=2):s+1<e.length&&e[s+1]===2&&s+4<e.length&&(r.fgRGB={r:e[s+2],g:e[s+3],b:e[s+4]},r.fg=-1,s+=4);break;case 48:s+1<e.length&&e[s+1]===5&&s+2<e.length?(r.bg=e[s+2],r.bgRGB=null,s+=2):s+1<e.length&&e[s+1]===2&&s+4<e.length&&(r.bgRGB={r:e[s+2],g:e[s+3],b:e[s+4]},r.bg=-1,s+=4);break}s++}return r};var Z=class{#e="GROUND";#t="";#r="";#i="";feed(t){let r=[],s=()=>{this.#i.length>0&&(r.push({type:"text",text:this.#i}),this.#i="")};for(let n=0;n<t.length;n++){let i=t[n],o=i.charCodeAt(0);switch(this.#e){case"GROUND":i==="\x1B"?(s(),this.#e="ESC"):o<32&&o!==27?(s(),r.push({type:"control",code:o})):this.#i+=i;break;case"ESC":i==="["?(this.#e="CSI_PARAM",this.#t=""):i==="]"?(this.#e="OSC",this.#r=""):(r.push({type:"esc",command:i}),this.#e="GROUND");break;case"CSI_PARAM":if(o>=48&&o<=63||i===";"||i==="?")this.#t+=i;else if(o>=64&&o<=126){let a=this.#t.replace(/^\?/,""),c=this.#t.startsWith("?"),p=a.length>0?a.split(";").map(m=>{let y=parseInt(m,10);return isNaN(y)?0:y}):[],l=(c?"?":"")+i;r.push({type:"csi",command:l,params:p}),this.#e="GROUND"}else this.#t+=i;break;case"OSC":if(i==="\x07"||i==="\\"&&this.#r.endsWith("\x1B")){let a=i==="\\"?this.#r.slice(0,-1):this.#r,c=a.indexOf(";"),p=c>=0?parseInt(a.slice(0,c),10):0,l=c>=0?a.slice(c+1):a;r.push({type:"osc",command:isNaN(p)?0:p,data:l}),this.#e="GROUND"}else this.#r+=i;break}}return s(),r}};var Q=class{screen;cursor;#e;#t;constructor(t,r){this.screen=new X(t,r),this.cursor=new Y,this.#e=new Z,this.#t=J()}write(t){let r=this.#e.feed(t);for(let s of r)switch(s.type){case"text":this.#r(s.text);break;case"csi":this.#o(s.command,s.params);break;case"esc":this.#n(s.command);break;case"control":this.#i(s.code);break;case"osc":break}}resize(t,r){this.screen.resize(t,r),this.cursor.clamp(t,r)}getScreen(){return this.screen}getCursor(){return this.cursor}#r(t){for(let r of t)this.cursor.col>=this.screen.cols&&(this.cursor.col=0,this.cursor.row++,this.cursor.row>=this.screen.rows&&(this.screen.scrollUp(),this.cursor.row=this.screen.rows-1)),this.screen.setCell(this.cursor.row,this.cursor.col,this.#t,r),this.cursor.col++}#i(t){switch(t){case 13:this.cursor.col=0;break;case 10:this.cursor.row++,this.cursor.row>=this.screen.rows&&(this.screen.scrollUp(),this.cursor.row=this.screen.rows-1);break;case 9:this.cursor.col=Math.min(this.screen.cols-1,(Math.floor(this.cursor.col/8)+1)*8);break;case 8:this.cursor.moveBack();break;case 7:break}}#o(t,r){let s=r[0]??0,n=r[1]??0,i=s||1;switch(t){case"A":this.cursor.moveUp(i);break;case"B":this.cursor.moveDown(i);break;case"C":this.cursor.moveForward(i);break;case"D":this.cursor.moveBack(i);break;case"H":case"f":this.cursor.moveTo((s||1)-1,(n||1)-1);break;case"G":this.cursor.moveToColumn((s||1)-1);break;case"d":this.cursor.moveTo((s||1)-1,this.cursor.col);break;case"J":this.screen.clearDisplay(s,this.cursor.row,this.cursor.col);break;case"K":s===0?this.screen.clearLineRange(this.cursor.row,this.cursor.col,this.screen.cols-1):s===1?this.screen.clearLineRange(this.cursor.row,0,this.cursor.col):this.screen.clearLine(this.cursor.row,2);break;case"m":this.#t=Te(r.length>0?r:[0],this.#t);break;case"S":this.screen.scrollUp(i);break;case"T":this.screen.scrollDown(i);break;case"L":this.screen.insertLines(i,this.cursor.row);break;case"M":this.screen.deleteLines(i,this.cursor.row);break;case"s":this.cursor.save();break;case"u":this.cursor.restore();break;case"r":this.screen.setScrollRegion((s||1)-1,(n||this.screen.rows)-1);break;case"?h":s===25&&(this.cursor.visible=!0),s===1049&&this.screen.enterAlternateScreen();break;case"?l":s===25&&(this.cursor.visible=!1),s===1049&&this.screen.exitAlternateScreen();break}this.cursor.clamp(this.screen.rows,this.screen.cols)}#n(t){switch(t){case"7":this.cursor.save();break;case"8":this.cursor.restore();break;case"M":this.cursor.row===0?this.screen.scrollDown():this.cursor.moveUp();break;case"c":this.screen.clearDisplay(2,0,0),this.cursor.moveTo(0,0),this.#t=J();break}}};var kt=e=>{let t=[];return e.bold&&t.push(1),e.dim&&t.push(2),e.italic&&t.push(3),e.underline&&t.push(4),e.fgRGB!==null?t.push(38,2,e.fgRGB.r,e.fgRGB.g,e.fgRGB.b):e.fg>=0&&e.fg<8?t.push(30+e.fg):e.fg>=8&&e.fg<16?t.push(90+(e.fg-8)):e.fg>=16&&t.push(38,5,e.fg),t.length===0?"":`\x1B[${t.join(";")}m`},At=e=>e.fg===-1&&e.fgRGB===null&&!e.bold&&!e.dim&&!e.italic&&!e.underline,Se=(e,t,r)=>{let s=[],n=e.getDirtyLines(),i=r.fullRedraw===!0||n.size>=r.height,o=Math.min(r.height,e.rows),a=Math.min(r.width,e.cols);for(let c=0;c<o;c++){if(!i&&!n.has(c))continue;s.push(`\x1B[${r.offsetRow+c};${r.offsetCol}H`);let p=e.getLine(c),l=!1,m=0;for(;m<a;m++){let y=m<p.length?p[m]:void 0;if(y===void 0||At(y))l&&(s.push("\x1B[0m"),l=!1),s.push(y?.char??" ");else{let G=kt(y);s.push(G),l=!0,s.push(y.char)}}l&&s.push("\x1B[0m")}return e.clearDirty(),s.join("")};var Re=class{#e;#t=!1;constructor(t,r){this.#e=new Q(t,r)}write(t){this.#e.write(t),this.#t=!0}render(t,r=!1){let s={offsetRow:t.y+1,offsetCol:t.x+1,width:t.width-2,height:t.height-2,fullRedraw:r};return this.#t=!1,Se(this.#e.getScreen(),this.#e.getCursor(),s)}resize(t,r){this.#e.resize(t,r),this.#t=!0}get dirty(){return this.#t}clearDirty(){this.#t=!1}get terminal(){return this.#e}};var Ve={};N(Ve,{drawBox:()=>Ue,fillBox:()=>Pt});var Et={single:{tl:"\u250C",tr:"\u2510",bl:"\u2514",br:"\u2518",h:"\u2500",v:"\u2502"},double:{tl:"\u2554",tr:"\u2557",bl:"\u255A",br:"\u255D",h:"\u2550",v:"\u2551"},rounded:{tl:"\u256D",tr:"\u256E",bl:"\u2570",br:"\u256F",h:"\u2500",v:"\u2502"}},Ue=e=>{let t=e.borderStyle??"single",r=Et[t],s=e.width-2,n=[],i=r.tl;if(e.title!==void 0){let o=` ${e.title} `;i+=o+r.h.repeat(Math.max(0,s-o.length))}else i+=r.h.repeat(s);if(i+=r.tr,n.push(x(e.y,e.x)+i),e.skipInterior===!0)for(let o=1;o<e.height-1;o++)n.push(x(e.y+o,e.x)+r.v+x(e.y+o,e.x+e.width-1)+r.v);else for(let o=1;o<e.height-1;o++)n.push(x(e.y+o,e.x)+r.v+ae()+" ".repeat(s)+r.v);return n.push(x(e.y+e.height-1,e.x)+r.bl+r.h.repeat(s)+r.br),n.join("")},Pt=(e,t)=>{let r=Ue(e),s=e.width-2,n=e.height-2,i=[];for(let o=0;o<n;o++){let a=o<t.length?t[o]:"",c=W(a??"",s),p=Math.max(0,s-q(c));i.push(x(e.y+1+o,e.x+1)+c+" ".repeat(p))}return r+i.join("")};export{Ke as a,He as b,Pe as c,E as d,ze as e,Xe as f,Ye as g,Je as h,Ze as i,Qe as j,et as k,tt as l,rt as m,st as n,ot as o,De as p,le as q,Ve as r,Ge as s,$e as t,Re as u};
|