gobot-tools 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -43
- package/dist/index.js +61 -54
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
CLI marketplace for the **Autonomee** community. Browse, install, and configure integrations for your AI Telegram bot — all from the command line.
|
|
4
4
|
|
|
5
|
-
Each tool is an interactive setup guide designed for [Claude Code](https://claude.ai/claude-code). Install a tool, open its prompt, and Claude walks you through the rest.
|
|
5
|
+
Each tool is an interactive setup guide designed for [Claude Code](https://claude.ai/claude-code). Install a tool, open its prompt, and Claude walks you through the rest — API keys, code changes, testing, and deployment.
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
@@ -14,61 +14,193 @@ bun add -g gobot-tools
|
|
|
14
14
|
npx gobot-tools list
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
### First-Time Setup
|
|
18
|
-
|
|
19
17
|
```bash
|
|
20
|
-
# Point
|
|
21
|
-
gobot-tools
|
|
18
|
+
gobot-tools init # Point at your bot project
|
|
19
|
+
gobot-tools list # Browse all tools
|
|
20
|
+
gobot-tools info oura-ring # Details before you install
|
|
21
|
+
gobot-tools install oura-ring # Download the setup guide
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
After installing, open the tool's `prompt.md` in Claude Code and follow the guided setup.
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
gobot-tools list
|
|
26
|
+
---
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
gobot-tools info oura-ring
|
|
28
|
+
## Integrations
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
gobot-tools install oura-ring
|
|
31
|
-
```
|
|
30
|
+
### [Microsoft 365](packages/ms365) — `gobot-tools install ms365`
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
Connect your bot to Outlook Calendar, Email, and Microsoft To Do via the Microsoft Graph API. Ask your bot "What's on my schedule today?" or "Do I have any unread emails?" and get real answers from your actual account.
|
|
33
|
+
|
|
34
|
+
- Calendar reads/writes with natural language dates
|
|
35
|
+
- Unread email summaries
|
|
36
|
+
- Microsoft To Do task management
|
|
37
|
+
- Auto-inclusion in daily morning briefings
|
|
38
|
+
- **Setup time:** ~10 minutes
|
|
39
|
+
- **Requires:** `MS365_CLIENT_ID`, `MS365_TENANT_ID`, `MS365_REFRESH_TOKEN`
|
|
40
|
+
|
|
41
|
+
### [Google Calendar & Sheets](packages/google-api) — `gobot-tools install google-api`
|
|
42
|
+
|
|
43
|
+
Connect your bot to Google Calendar and Google Sheets using lightweight Python CLI scripts and a TypeScript client. Bypasses flaky MCP servers with direct API calls that actually work.
|
|
44
|
+
|
|
45
|
+
- Calendar: list, create, delete, search events
|
|
46
|
+
- Sheets: read, write, append, create spreadsheets
|
|
47
|
+
- Drive: search spreadsheets by name
|
|
48
|
+
- Shared OAuth credentials — one auth flow covers everything
|
|
49
|
+
- **Setup time:** ~15 minutes
|
|
50
|
+
- **Requires:** `GOOGLE_SHEETS_CLIENT_ID`, `GOOGLE_SHEETS_CLIENT_SECRET`, `GOOGLE_SHEETS_REFRESH_TOKEN`
|
|
51
|
+
|
|
52
|
+
### [Tempest Weather Station](packages/tempest-weather) — `gobot-tools install tempest-weather`
|
|
53
|
+
|
|
54
|
+
Connect your bot to a WeatherFlow Tempest personal weather station. Get live conditions from your own backyard instead of generic internet forecasts. Uses direct API calls to bypass Claude's web search for speed and accuracy.
|
|
55
|
+
|
|
56
|
+
- Live conditions: temperature, humidity, wind, pressure, rain, UV, lightning
|
|
57
|
+
- 5-day forecast
|
|
58
|
+
- Natural language triggers — "Is it cold outside?", "What's the weather?"
|
|
59
|
+
- Intentional Claude bypass for accurate local readings
|
|
60
|
+
- **Setup time:** ~5 minutes
|
|
61
|
+
- **Requires:** `TEMPEST_TOKEN`, `TEMPEST_STATION_ID`
|
|
62
|
+
|
|
63
|
+
### [Fireflies.ai Meeting Transcripts](packages/fireflies) — `gobot-tools install fireflies`
|
|
64
|
+
|
|
65
|
+
Connect your bot to Fireflies.ai so meeting transcripts are automatically stored in memory. Summaries become searchable facts, action items become trackable goals, and you get a Telegram notification when it's done.
|
|
66
|
+
|
|
67
|
+
- Automatic meeting summary storage
|
|
68
|
+
- Action items saved as trackable goals
|
|
69
|
+
- Webhook-based — no polling, no manual steps
|
|
70
|
+
- Searchable via semantic memory — "What did we discuss in the Q1 meeting?"
|
|
71
|
+
- **Setup time:** ~10 minutes
|
|
72
|
+
- **Requires:** `FIREFLIES_API_KEY`, `FIREFLIES_WEBHOOK_SECRET`
|
|
73
|
+
|
|
74
|
+
### [FlightAware Flight Tracking](packages/flightaware) — `gobot-tools install flightaware`
|
|
75
|
+
|
|
76
|
+
Real-time flight tracking via FlightAware AeroAPI. Look up any flight, set up active tracking with proactive Telegram notifications for gate changes, delays, and arrivals, and pull travel data into morning briefings.
|
|
77
|
+
|
|
78
|
+
- One-time flight lookups by flight number
|
|
79
|
+
- Active tracking with push notifications for status changes
|
|
80
|
+
- Morning briefing integration for upcoming travel
|
|
81
|
+
- Cost guardrails to stay within API limits
|
|
82
|
+
- **Setup time:** ~10 minutes
|
|
83
|
+
- **Requires:** `FLIGHTAWARE_API_KEY`
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Health
|
|
88
|
+
|
|
89
|
+
### [Oura Ring + Health Agent](packages/oura-ring) — `gobot-tools install oura-ring`
|
|
90
|
+
|
|
91
|
+
Connect your bot to an Oura Ring and add a Health Agent to the board. Biometric data flows into morning briefings and smart check-ins, and a dedicated wellness advisor handles everything from sleep analysis to medication lookups.
|
|
92
|
+
|
|
93
|
+
- Sleep, readiness, activity, and stress scores in briefings
|
|
94
|
+
- Health Agent on the board — biometrics, medication info, symptom lookup
|
|
95
|
+
- Health-aware smart check-ins — tone adapts to how you slept
|
|
96
|
+
- Drug interactions, side effects, lab results interpretation
|
|
97
|
+
- **Setup time:** ~5 minutes
|
|
98
|
+
- **Requires:** `OURA_ACCESS_TOKEN`
|
|
34
99
|
|
|
35
|
-
|
|
100
|
+
### [Apple Watch + Health Agent](packages/apple-health) — `gobot-tools install apple-health`
|
|
36
101
|
|
|
37
|
-
|
|
102
|
+
Connect your iPhone and Apple Watch to your bot using the free Health Auto Export app. No Apple API token required — data is pushed directly from your phone. Works standalone or alongside Oura Ring.
|
|
38
103
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
104
|
+
- Sleep stages (Deep, REM, Core), efficiency, bedtime/wake time
|
|
105
|
+
- HRV, resting heart rate, SpO₂, wrist temperature, VO₂ Max
|
|
106
|
+
- Steps, active calories, exercise minutes, stand hours
|
|
107
|
+
- Computed readiness score (proxy for Oura's readiness, no subscription needed)
|
|
108
|
+
- If you don't wear your watch to bed, the Health Agent automatically uses Oura (or any other source) for sleep data
|
|
109
|
+
- **Setup time:** ~5 minutes
|
|
110
|
+
- **Requires:** `APPLE_HEALTH_WEBHOOK_SECRET`
|
|
46
111
|
|
|
47
|
-
### Health
|
|
112
|
+
### [Garmin Connect + Health Agent](packages/garmin) — `gobot-tools install garmin`
|
|
48
113
|
|
|
49
|
-
|
|
50
|
-
|------|-------------|
|
|
51
|
-
| **oura-ring** | Oura Ring biometrics + Health Agent for sleep, readiness, medications, symptoms |
|
|
114
|
+
Connect your Garmin device to your bot for workout data, training insights, sleep tracking, and daily health metrics. Uses the community `garminconnect` library — no developer registration required.
|
|
52
115
|
|
|
53
|
-
|
|
116
|
+
- Body Battery, training readiness, VO₂ max, and training status
|
|
117
|
+
- All activity types: running, cycling, swimming, strength, hiking, and more
|
|
118
|
+
- Sleep stages, steps, resting heart rate, and stress data
|
|
119
|
+
- Works alongside Oura and Apple Watch — all three sources complement each other; the Health Agent pulls from whichever has data for any given metric
|
|
120
|
+
- **Setup time:** ~10 minutes
|
|
121
|
+
- **Requires:** `GARMIN_EMAIL`, `GARMIN_PASSWORD` (for initial setup only — tokens cached after first login)
|
|
54
122
|
|
|
55
|
-
|
|
56
|
-
|------|-------------|
|
|
57
|
-
| **teams** | Microsoft Teams as a second messaging platform with cross-platform sync |
|
|
58
|
-
| **voice-interface** | Telegram voice notes + web push-to-talk with per-agent voice mapping |
|
|
123
|
+
---
|
|
59
124
|
|
|
60
|
-
|
|
125
|
+
## Messaging
|
|
61
126
|
|
|
62
|
-
|
|
63
|
-
|------|-------------|
|
|
64
|
-
| **security-audit** | 5-phase application security audit prompt — works on any codebase |
|
|
65
|
-
| **vps-hardening** | 9-phase VPS hardening prompt — SSH, Fail2Ban, UFW, Cloudflare, auto-updates |
|
|
127
|
+
### [Microsoft Teams](packages/teams) — `gobot-tools install teams`
|
|
66
128
|
|
|
67
|
-
|
|
129
|
+
Add Teams as a second messaging platform with synchronized conversations. Messages from Telegram and Teams share the same history — Claude sees full context regardless of where you sent from.
|
|
68
130
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
131
|
+
- Synchronized cross-platform conversations
|
|
132
|
+
- Human-in-the-loop via Adaptive Cards
|
|
133
|
+
- Same hybrid routing (VPS + local Mac)
|
|
134
|
+
- No botbuilder SDK — direct Bot Framework REST API
|
|
135
|
+
- **Setup time:** ~30 minutes
|
|
136
|
+
- **Requires:** `TEAMS_APP_ID`, `TEAMS_APP_PASSWORD`, `TEAMS_ALLOWED_USER_ID`, `TEAMS_TENANT_ID`
|
|
137
|
+
- **Depends on:** `ms365`
|
|
138
|
+
|
|
139
|
+
### [Voice Interface — Telegram + Web](packages/voice-interface) — `gobot-tools install voice-interface`
|
|
140
|
+
|
|
141
|
+
Add two voice interfaces: Telegram voice notes (send a voice message, get a voice reply) and a web-based push-to-talk interface with distinct voices for each board agent.
|
|
142
|
+
|
|
143
|
+
- Telegram: Gemini transcription → Anthropic processing → Speaktor TTS
|
|
144
|
+
- Web: Browser STT (free, on-device) → Claude Code CLI → OpenAI TTS (per-agent voice)
|
|
145
|
+
- 8 distinct agent voices with personality instructions
|
|
146
|
+
- Estimated cost: ~$3/month (Telegram) or ~$0.05/month (web only)
|
|
147
|
+
- **Setup time:** ~15 minutes
|
|
148
|
+
- **Requires:** `GEMINI_API_KEY`, `SPEAKTOR_API_KEY`, `OPENAI_API_KEY`, `VOICE_WEB_TOKEN`
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Security
|
|
153
|
+
|
|
154
|
+
### [Security Sentinel](packages/security-sentinel) — `gobot-tools install security-sentinel`
|
|
155
|
+
|
|
156
|
+
Autonomous security scanning agent for your VPS and web infrastructure. Runs 80+ checks across authentication, TLS, headers, VPS hardening, API credentials, and dependencies. Generates compliance reports for SOC2, HIPAA, and PCI-DSS with optional AI-powered analysis via Ollama or Claude API.
|
|
157
|
+
|
|
158
|
+
- 4 scan modes: quick, standard, deep, compliance-only
|
|
159
|
+
- Scheduled scans with Telegram notifications
|
|
160
|
+
- AI analysis with local Ollama models or Claude API
|
|
161
|
+
- Full source code included — customize checks for your stack
|
|
162
|
+
- **Setup time:** ~20 minutes
|
|
163
|
+
- **Requires:** `VPS_URL`, `VPS_SSH_HOST`, `DOMAIN`, `TELEGRAM_BOT_TOKEN`, and more (see `gobot-tools info security-sentinel`)
|
|
164
|
+
|
|
165
|
+
### [Application Security Audit](packages/security-audit) — `gobot-tools install security-audit`
|
|
166
|
+
|
|
167
|
+
A 5-phase audit prompt that reviews your application code for vulnerabilities. Paste it into Claude Code from your project root — it maps your attack surface, identifies issues ranked by severity, and helps you fix them one commit at a time.
|
|
168
|
+
|
|
169
|
+
- Injection: command injection, prompt injection, path traversal, SSRF
|
|
170
|
+
- Auth gaps: unauthenticated endpoints, missing webhook verification
|
|
171
|
+
- Secret leaks: API keys in URLs/logs, hardcoded credentials, secrets in git history
|
|
172
|
+
- Config: permissive CORS, missing rate limiting, verbose error messages
|
|
173
|
+
- **Setup time:** ~5 minutes (audit itself takes longer depending on codebase size)
|
|
174
|
+
- **Works on any codebase** — no env vars required
|
|
175
|
+
|
|
176
|
+
### [VPS Hardening](packages/vps-hardening) — `gobot-tools install vps-hardening`
|
|
177
|
+
|
|
178
|
+
A 9-phase hardening prompt for your Linux VPS. Paste it into Claude Code while SSH'd into your server — it audits your current state, locks down SSH, sets up firewall rules, and verifies nothing broke.
|
|
179
|
+
|
|
180
|
+
- SSH hardening: disable root, key-only auth, AllowUsers, idle timeout
|
|
181
|
+
- Fail2Ban with 24-hour progressive bans for repeat offenders
|
|
182
|
+
- UFW firewall with Docker-aware iptables rules
|
|
183
|
+
- Cloudflare origin protection — locks ports 80/443 to Cloudflare IP ranges
|
|
184
|
+
- Automatic security updates
|
|
185
|
+
- **Setup time:** ~30 minutes
|
|
186
|
+
- **Works on any Linux VPS** — no env vars required
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Infrastructure
|
|
191
|
+
|
|
192
|
+
### [Supabase to Convex Migration](packages/supabase-to-convex) — `gobot-tools install supabase-to-convex`
|
|
193
|
+
|
|
194
|
+
Migrate your bot's database from Supabase to Convex with zero downtime. Uses a backend adapter pattern so you can run both databases in parallel and roll back instantly at every phase.
|
|
195
|
+
|
|
196
|
+
- Schema translation: SQL → TypeScript, pgvector → Convex vector search
|
|
197
|
+
- Drop-in client adapter with identical function signatures
|
|
198
|
+
- Data migration script that preserves existing embeddings
|
|
199
|
+
- Dual-write verification phase before cutover
|
|
200
|
+
- **Setup time:** ~1 day active work + 2 days monitoring
|
|
201
|
+
- **Requires:** `CONVEX_URL`, `DB_BACKEND`
|
|
202
|
+
|
|
203
|
+
---
|
|
72
204
|
|
|
73
205
|
## Commands
|
|
74
206
|
|
|
@@ -79,6 +211,7 @@ gobot-tools search <query> Search by name, category, or keyword
|
|
|
79
211
|
gobot-tools info <tool> Show details, env vars, dependencies
|
|
80
212
|
gobot-tools install <tool> Download tool into your project
|
|
81
213
|
gobot-tools uninstall <tool> Remove an installed tool
|
|
214
|
+
gobot-tools update [tool] Update a tool, or all installed tools
|
|
82
215
|
```
|
|
83
216
|
|
|
84
217
|
## How It Works
|
|
@@ -89,15 +222,22 @@ gobot-tools uninstall <tool> Remove an installed tool
|
|
|
89
222
|
|
|
90
223
|
Tools are standalone — install only what you need. Some tools list dependencies (e.g., `teams` depends on `ms365`), and the CLI will tell you if you need to install something first.
|
|
91
224
|
|
|
225
|
+
When a tool receives a bug fix or new feature, update it with:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
gobot-tools update security-sentinel # update one tool
|
|
229
|
+
gobot-tools update # update all installed tools
|
|
230
|
+
```
|
|
231
|
+
|
|
92
232
|
## Using Without the CLI
|
|
93
233
|
|
|
94
234
|
Every tool's `prompt.md` works on its own. If you don't want to use the CLI:
|
|
95
235
|
|
|
96
236
|
1. Browse the [`packages/`](packages/) directory
|
|
97
|
-
2. Open any `prompt.md` file
|
|
237
|
+
2. Open any tool's `prompt.md` file
|
|
98
238
|
3. Copy it into a Claude Code session
|
|
99
|
-
4. Follow the
|
|
239
|
+
4. Follow the interactive setup
|
|
100
240
|
|
|
101
241
|
## About
|
|
102
242
|
|
|
103
|
-
Built by [tk-47](https://github.com/tk-47) for the Autonomee community. These tools power [Claudebot](https://github.com/tk-47/go-telegram-bot) — an always-on AI Telegram agent with persistent memory, proactive check-ins, morning briefings, and a board of specialist agents.
|
|
243
|
+
Built by [tk-47](https://github.com/tk-47) for the Autonomee community. These tools power [Claudebot](https://github.com/tk-47/go-telegram-bot) — an always-on AI Telegram agent originally built by GodaGo with persistent memory, proactive check-ins, morning briefings, and a board of specialist agents.
|
package/dist/index.js
CHANGED
|
@@ -1,73 +1,80 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
3
|
-
`)}displayWidth($){return
|
|
4
|
-
`+" ".repeat(T+
|
|
5
|
-
${
|
|
6
|
-
`)}}function
|
|
2
|
+
import{createRequire as A$}from"node:module";var E$=Object.create;var{getPrototypeOf:f$,defineProperty:g,getOwnPropertyNames:N$}=Object;var D$=Object.prototype.hasOwnProperty;var F$=($,T,z)=>{z=$!=null?E$(f$($)):{};let R=T||!$||!$.__esModule?g(z,"default",{value:$,enumerable:!0}):z;for(let J of N$($))if(!D$.call(R,J))g(R,J,{get:()=>$[J],enumerable:!0});return R};var K=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var L=A$(import.meta.url);var W=K((w$)=>{class N extends Error{constructor($,T,z){super(z);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=T,this.exitCode=$,this.nestedError=void 0}}class c extends N{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}w$.CommanderError=N;w$.InvalidArgumentError=c});var y=K((O$)=>{var{InvalidArgumentError:C$}=W();class m{constructor($,T){switch(this.description=T||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,T){if(T===this.defaultValue||!Array.isArray(T))return[$];return T.concat($)}default($,T){return this.defaultValue=$,this.defaultValueDescription=T,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(T,z)=>{if(!this.argChoices.includes(T))throw new C$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(T,z);return T},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function x$($){let T=$.name()+($.variadic===!0?"...":"");return $.required?"<"+T+">":"["+T+"]"}O$.Argument=m;O$.humanReadableArgName=x$});var D=K((u$)=>{var{humanReadableArgName:l$}=y();class d{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let T=$.commands.filter((R)=>!R._hidden),z=$._getHelpCommand();if(z&&!z._hidden)T.push(z);if(this.sortSubcommands)T.sort((R,J)=>{return R.name().localeCompare(J.name())});return T}compareOptions($,T){let z=(R)=>{return R.short?R.short.replace(/^-/,""):R.long.replace(/^--/,"")};return z($).localeCompare(z(T))}visibleOptions($){let T=$.options.filter((R)=>!R.hidden),z=$._getHelpOption();if(z&&!z.hidden){let R=z.short&&$._findOption(z.short),J=z.long&&$._findOption(z.long);if(!R&&!J)T.push(z);else if(z.long&&!J)T.push($.createOption(z.long,z.description));else if(z.short&&!R)T.push($.createOption(z.short,z.description))}if(this.sortOptions)T.sort(this.compareOptions);return T}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let T=[];for(let z=$.parent;z;z=z.parent){let R=z.options.filter((J)=>!J.hidden);T.push(...R)}if(this.sortOptions)T.sort(this.compareOptions);return T}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((T)=>{T.description=T.description||$._argsDescription[T.name()]||""});if($.registeredArguments.find((T)=>T.description))return $.registeredArguments;return[]}subcommandTerm($){let T=$.registeredArguments.map((z)=>l$(z)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(T?" "+T:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,T){return T.visibleCommands($).reduce((z,R)=>{return Math.max(z,this.displayWidth(T.styleSubcommandTerm(T.subcommandTerm(R))))},0)}longestOptionTermLength($,T){return T.visibleOptions($).reduce((z,R)=>{return Math.max(z,this.displayWidth(T.styleOptionTerm(T.optionTerm(R))))},0)}longestGlobalOptionTermLength($,T){return T.visibleGlobalOptions($).reduce((z,R)=>{return Math.max(z,this.displayWidth(T.styleOptionTerm(T.optionTerm(R))))},0)}longestArgumentTermLength($,T){return T.visibleArguments($).reduce((z,R)=>{return Math.max(z,this.displayWidth(T.styleArgumentTerm(T.argumentTerm(R))))},0)}commandUsage($){let T=$._name;if($._aliases[0])T=T+"|"+$._aliases[0];let z="";for(let R=$.parent;R;R=R.parent)z=R.name()+" "+z;return z+T+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let T=[];if($.argChoices)T.push(`choices: ${$.argChoices.map((z)=>JSON.stringify(z)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")T.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)T.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)T.push(`env: ${$.envVar}`);if(T.length>0)return`${$.description} (${T.join(", ")})`;return $.description}argumentDescription($){let T=[];if($.argChoices)T.push(`choices: ${$.argChoices.map((z)=>JSON.stringify(z)).join(", ")}`);if($.defaultValue!==void 0)T.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(T.length>0){let z=`(${T.join(", ")})`;if($.description)return`${$.description} ${z}`;return z}return $.description}formatHelp($,T){let z=T.padWidth($,T),R=T.helpWidth??80;function J(U,G){return T.formatItem(U,z,G,T)}let Q=[`${T.styleTitle("Usage:")} ${T.styleUsage(T.commandUsage($))}`,""],Z=T.commandDescription($);if(Z.length>0)Q=Q.concat([T.boxWrap(T.styleCommandDescription(Z),R),""]);let X=T.visibleArguments($).map((U)=>{return J(T.styleArgumentTerm(T.argumentTerm(U)),T.styleArgumentDescription(T.argumentDescription(U)))});if(X.length>0)Q=Q.concat([T.styleTitle("Arguments:"),...X,""]);let Y=T.visibleOptions($).map((U)=>{return J(T.styleOptionTerm(T.optionTerm(U)),T.styleOptionDescription(T.optionDescription(U)))});if(Y.length>0)Q=Q.concat([T.styleTitle("Options:"),...Y,""]);if(T.showGlobalOptions){let U=T.visibleGlobalOptions($).map((G)=>{return J(T.styleOptionTerm(T.optionTerm(G)),T.styleOptionDescription(T.optionDescription(G)))});if(U.length>0)Q=Q.concat([T.styleTitle("Global Options:"),...U,""])}let q=T.visibleCommands($).map((U)=>{return J(T.styleSubcommandTerm(T.subcommandTerm(U)),T.styleSubcommandDescription(T.subcommandDescription(U)))});if(q.length>0)Q=Q.concat([T.styleTitle("Commands:"),...q,""]);return Q.join(`
|
|
3
|
+
`)}displayWidth($){return s($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((T)=>{if(T==="[options]")return this.styleOptionText(T);if(T==="[command]")return this.styleSubcommandText(T);if(T[0]==="["||T[0]==="<")return this.styleArgumentText(T);return this.styleCommandText(T)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((T)=>{if(T==="[options]")return this.styleOptionText(T);if(T[0]==="["||T[0]==="<")return this.styleArgumentText(T);return this.styleSubcommandText(T)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,T){return Math.max(T.longestOptionTermLength($,T),T.longestGlobalOptionTermLength($,T),T.longestSubcommandTermLength($,T),T.longestArgumentTermLength($,T))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,T,z,R){let Q=" ".repeat(2);if(!z)return Q+$;let Z=$.padEnd(T+$.length-R.displayWidth($)),X=2,q=(this.helpWidth??80)-T-X-2,U;if(q<this.minWidthToWrap||R.preformatted(z))U=z;else U=R.boxWrap(z,q).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(T+X));return Q+Z+" ".repeat(X)+U.replace(/\n/g,`
|
|
5
|
+
${Q}`)}boxWrap($,T){if(T<this.minWidthToWrap)return $;let z=$.split(/\r\n|\n/),R=/[\s]*[^\s]+/g,J=[];return z.forEach((Q)=>{let Z=Q.match(R);if(Z===null){J.push("");return}let X=[Z.shift()],Y=this.displayWidth(X[0]);Z.forEach((q)=>{let U=this.displayWidth(q);if(Y+U<=T){X.push(q),Y+=U;return}J.push(X.join(""));let G=q.trimStart();X=[G],Y=this.displayWidth(G)}),J.push(X.join(""))}),J.join(`
|
|
6
|
+
`)}}function s($){let T=/\x1b\[\d*(;\d*)*m/g;return $.replace(T,"")}u$.Help=d;u$.stripColor=s});var F=K((s$)=>{var{InvalidArgumentError:m$}=W();class o{constructor($,T){this.flags=$,this.description=T||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let z=d$($);if(this.short=z.shortFlag,this.long=z.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default($,T){return this.defaultValue=$,this.defaultValueDescription=T,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let T=$;if(typeof $==="string")T={[$]:!0};return this.implied=Object.assign(this.implied||{},T),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,T){if(T===this.defaultValue||!Array.isArray(T))return[$];return T.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(T,z)=>{if(!this.argChoices.includes(T))throw new m$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(T,z);return T},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return i(this.name().replace(/^no-/,""));return i(this.name())}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class t{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((T)=>{if(T.negate)this.negativeOptions.set(T.attributeName(),T);else this.positiveOptions.set(T.attributeName(),T)}),this.negativeOptions.forEach((T,z)=>{if(this.positiveOptions.has(z))this.dualOptions.add(z)})}valueFromOption($,T){let z=T.attributeName();if(!this.dualOptions.has(z))return!0;let R=this.negativeOptions.get(z).presetArg,J=R!==void 0?R:!1;return T.negate===(J===$)}}function i($){return $.split("-").reduce((T,z)=>{return T+z[0].toUpperCase()+z.slice(1)})}function d$($){let T,z,R=/^-[^-]$/,J=/^--[^-]/,Q=$.split(/[ |,]+/).concat("guard");if(R.test(Q[0]))T=Q.shift();if(J.test(Q[0]))z=Q.shift();if(!T&&R.test(Q[0]))T=Q.shift();if(!T&&J.test(Q[0]))T=z,z=Q.shift();if(Q[0].startsWith("-")){let Z=Q[0],X=`option creation failed due to '${Z}' in option flags '${$}'`;if(/^-[^-][^-]/.test(Z))throw Error(`${X}
|
|
7
7
|
- a short flag is a single dash and a single character
|
|
8
8
|
- either use a single dash and a single character (for a short flag)
|
|
9
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(
|
|
10
|
-
- too many short flags`);if(J.test(
|
|
11
|
-
- too many long flags`);throw Error(`${
|
|
12
|
-
- unrecognised flag format`)}if(T===void 0&&
|
|
13
|
-
(Did you mean one of ${
|
|
14
|
-
(Did you mean ${
|
|
15
|
-
- specify the name in Command constructor or using .name()`);if(T=T||{},T.isDefault)this._defaultCommandName=$._name;if(T.noHelp||T.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,T){return new
|
|
16
|
-
Expecting one of '${
|
|
17
|
-
- already used by option '${T.flags}'`)}this.options.push($)}_registerCommand($){let T=(
|
|
18
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,T,
|
|
19
|
-
- if '${
|
|
9
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(R.test(Z))throw Error(`${X}
|
|
10
|
+
- too many short flags`);if(J.test(Z))throw Error(`${X}
|
|
11
|
+
- too many long flags`);throw Error(`${X}
|
|
12
|
+
- unrecognised flag format`)}if(T===void 0&&z===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:T,longFlag:z}}s$.Option=o;s$.DualOptions=t});var n=K((p$)=>{function t$($,T){if(Math.abs($.length-T.length)>3)return Math.max($.length,T.length);let z=[];for(let R=0;R<=$.length;R++)z[R]=[R];for(let R=0;R<=T.length;R++)z[0][R]=R;for(let R=1;R<=T.length;R++)for(let J=1;J<=$.length;J++){let Q=1;if($[J-1]===T[R-1])Q=0;else Q=1;if(z[J][R]=Math.min(z[J-1][R]+1,z[J][R-1]+1,z[J-1][R-1]+Q),J>1&&R>1&&$[J-1]===T[R-2]&&$[J-2]===T[R-1])z[J][R]=Math.min(z[J][R],z[J-2][R-2]+1)}return z[$.length][T.length]}function n$($,T){if(!T||T.length===0)return"";T=Array.from(new Set(T));let z=$.startsWith("--");if(z)$=$.slice(2),T=T.map((Z)=>Z.slice(2));let R=[],J=3,Q=0.4;if(T.forEach((Z)=>{if(Z.length<=1)return;let X=t$($,Z),Y=Math.max($.length,Z.length);if((Y-X)/Y>Q){if(X<J)J=X,R=[Z];else if(X===J)R.push(Z)}}),R.sort((Z,X)=>Z.localeCompare(X)),z)R=R.map((Z)=>`--${Z}`);if(R.length>1)return`
|
|
13
|
+
(Did you mean one of ${R.join(", ")}?)`;if(R.length===1)return`
|
|
14
|
+
(Did you mean ${R[0]}?)`;return""}p$.suggestSimilar=n$});var e=K((J0)=>{var a$=L("node:events").EventEmitter,A=L("node:child_process"),_=L("node:path"),V=L("node:fs"),B=L("node:process"),{Argument:e$,humanReadableArgName:$0}=y(),{CommanderError:w}=W(),{Help:T0,stripColor:z0}=D(),{Option:p,DualOptions:R0}=F(),{suggestSimilar:r}=n();class b extends a${constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(T)=>B.stdout.write(T),writeErr:(T)=>B.stderr.write(T),outputError:(T,z)=>z(T),getOutHelpWidth:()=>B.stdout.isTTY?B.stdout.columns:void 0,getErrHelpWidth:()=>B.stderr.isTTY?B.stderr.columns:void 0,getOutHasColors:()=>k()??(B.stdout.isTTY&&B.stdout.hasColors?.()),getErrHasColors:()=>k()??(B.stderr.isTTY&&B.stderr.hasColors?.()),stripColor:(T)=>z0(T)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let T=this;T;T=T.parent)$.push(T);return $}command($,T,z){let R=T,J=z;if(typeof R==="object"&&R!==null)J=R,R=null;J=J||{};let[,Q,Z]=$.match(/([^ ]+) *(.*)/),X=this.createCommand(Q);if(R)X.description(R),X._executableHandler=!0;if(J.isDefault)this._defaultCommandName=X._name;if(X._hidden=!!(J.noHelp||J.hidden),X._executableFile=J.executableFile||null,Z)X.arguments(Z);if(this._registerCommand(X),X.parent=this,X.copyInheritedSettings(this),R)return this;return X}createCommand($){return new b($)}createHelp(){return Object.assign(new T0,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,T){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
15
|
+
- specify the name in Command constructor or using .name()`);if(T=T||{},T.isDefault)this._defaultCommandName=$._name;if(T.noHelp||T.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,T){return new e$($,T)}argument($,T,z,R){let J=this.createArgument($,T);if(typeof z==="function")J.default(R).argParser(z);else J.default(z);return this.addArgument(J),this}arguments($){return $.trim().split(/ +/).forEach((T)=>{this.argument(T)}),this}addArgument($){let T=this.registeredArguments.slice(-1)[0];if(T&&T.variadic)throw Error(`only the last argument can be variadic '${T.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,T){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,z,R]=$.match(/([^ ]+) *(.*)/),J=T??"display help for command",Q=this.createCommand(z);if(Q.helpOption(!1),R)Q.arguments(R);if(J)Q.description(J);return this._addImplicitHelpCommand=!0,this._helpCommand=Q,this}addHelpCommand($,T){if(typeof $!=="object")return this.helpCommand($,T),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,T){let z=["preSubcommand","preAction","postAction"];if(!z.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
16
|
+
Expecting one of '${z.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(T);else this._lifeCycleHooks[$]=[T];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(T)=>{if(T.code!=="commander.executeSubCommandAsync")throw T};return this}_exit($,T,z){if(this._exitCallback)this._exitCallback(new w($,T,z));B.exit($)}action($){let T=(z)=>{let R=this.registeredArguments.length,J=z.slice(0,R);if(this._storeOptionsAsProperties)J[R]=this;else J[R]=this.opts();return J.push(this),$.apply(this,J)};return this._actionHandler=T,this}createOption($,T){return new p($,T)}_callParseArg($,T,z,R){try{return $.parseArg(T,z)}catch(J){if(J.code==="commander.invalidArgument"){let Q=`${R} ${J.message}`;this.error(Q,{exitCode:J.exitCode,code:J.code})}throw J}}_registerOption($){let T=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(T){let z=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${z}'
|
|
17
|
+
- already used by option '${T.flags}'`)}this.options.push($)}_registerCommand($){let T=(R)=>{return[R.name()].concat(R.aliases())},z=T($).find((R)=>this._findCommand(R));if(z){let R=T(this._findCommand(z)).join("|"),J=T($).join("|");throw Error(`cannot add command '${J}' as already have command '${R}'`)}this.commands.push($)}addOption($){this._registerOption($);let T=$.name(),z=$.attributeName();if($.negate){let J=$.long.replace(/^--no-/,"--");if(!this._findOption(J))this.setOptionValueWithSource(z,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(z,$.defaultValue,"default");let R=(J,Q,Z)=>{if(J==null&&$.presetArg!==void 0)J=$.presetArg;let X=this.getOptionValue(z);if(J!==null&&$.parseArg)J=this._callParseArg($,J,X,Q);else if(J!==null&&$.variadic)J=$._concatValue(J,X);if(J==null)if($.negate)J=!1;else if($.isBoolean()||$.optional)J=!0;else J="";this.setOptionValueWithSource(z,J,Z)};if(this.on("option:"+T,(J)=>{let Q=`error: option '${$.flags}' argument '${J}' is invalid.`;R(J,Q,"cli")}),$.envVar)this.on("optionEnv:"+T,(J)=>{let Q=`error: option '${$.flags}' value '${J}' from env '${$.envVar}' is invalid.`;R(J,Q,"env")});return this}_optionEx($,T,z,R,J){if(typeof T==="object"&&T instanceof p)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Q=this.createOption(T,z);if(Q.makeOptionMandatory(!!$.mandatory),typeof R==="function")Q.default(J).argParser(R);else if(R instanceof RegExp){let Z=R;R=(X,Y)=>{let q=Z.exec(X);return q?q[0]:Y},Q.default(J).argParser(R)}else Q.default(R);return this.addOption(Q)}option($,T,z,R){return this._optionEx({},$,T,z,R)}requiredOption($,T,z,R){return this._optionEx({mandatory:!0},$,T,z,R)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,T){return this.setOptionValueWithSource($,T,void 0)}setOptionValueWithSource($,T,z){if(this._storeOptionsAsProperties)this[$]=T;else this._optionValues[$]=T;return this._optionValueSources[$]=z,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let T;return this._getCommandAndAncestors().forEach((z)=>{if(z.getOptionValueSource($)!==void 0)T=z.getOptionValueSource($)}),T}_prepareUserArgs($,T){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(T=T||{},$===void 0&&T.from===void 0){if(B.versions?.electron)T.from="electron";let R=B.execArgv??[];if(R.includes("-e")||R.includes("--eval")||R.includes("-p")||R.includes("--print"))T.from="eval"}if($===void 0)$=B.argv;this.rawArgs=$.slice();let z;switch(T.from){case void 0:case"node":this._scriptPath=$[1],z=$.slice(2);break;case"electron":if(B.defaultApp)this._scriptPath=$[1],z=$.slice(2);else z=$.slice(1);break;case"user":z=$.slice(0);break;case"eval":z=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${T.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",z}parse($,T){this._prepareForParse();let z=this._prepareUserArgs($,T);return this._parseCommand([],z),this}async parseAsync($,T){this._prepareForParse();let z=this._prepareUserArgs($,T);return await this._parseCommand([],z),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
18
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,T,z){if(V.existsSync($))return;let R=T?`searched for local subcommand relative to directory '${T}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",J=`'${$}' does not exist
|
|
19
|
+
- if '${z}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
20
20
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
21
|
-
- ${
|
|
21
|
+
- ${R}`;throw Error(J)}_executeSubCommand($,T){T=T.slice();let z=!1,R=[".js",".ts",".tsx",".mjs",".cjs"];function J(q,U){let G=_.resolve(q,U);if(V.existsSync(G))return G;if(R.includes(_.extname(U)))return;let u=R.find((V$)=>V.existsSync(`${G}${V$}`));if(u)return`${G}${u}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Q=$._executableFile||`${this._name}-${$._name}`,Z=this._executableDir||"";if(this._scriptPath){let q;try{q=V.realpathSync(this._scriptPath)}catch{q=this._scriptPath}Z=_.resolve(_.dirname(q),Z)}if(Z){let q=J(Z,Q);if(!q&&!$._executableFile&&this._scriptPath){let U=_.basename(this._scriptPath,_.extname(this._scriptPath));if(U!==this._name)q=J(Z,`${U}-${$._name}`)}Q=q||Q}z=R.includes(_.extname(Q));let X;if(B.platform!=="win32")if(z)T.unshift(Q),T=a(B.execArgv).concat(T),X=A.spawn(B.argv[0],T,{stdio:"inherit"});else X=A.spawn(Q,T,{stdio:"inherit"});else this._checkForMissingExecutable(Q,Z,$._name),T.unshift(Q),T=a(B.execArgv).concat(T),X=A.spawn(B.execPath,T,{stdio:"inherit"});if(!X.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((U)=>{B.on(U,()=>{if(X.killed===!1&&X.exitCode===null)X.kill(U)})});let Y=this._exitCallback;X.on("close",(q)=>{if(q=q??1,!Y)B.exit(q);else Y(new w(q,"commander.executeSubCommandAsync","(close)"))}),X.on("error",(q)=>{if(q.code==="ENOENT")this._checkForMissingExecutable(Q,Z,$._name);else if(q.code==="EACCES")throw Error(`'${Q}' not executable`);if(!Y)B.exit(1);else{let U=new w(1,"commander.executeSubCommandAsync","(error)");U.nestedError=q,Y(U)}}),this.runningCommand=X}_dispatchSubcommand($,T,z){let R=this._findCommand($);if(!R)this.help({error:!0});R._prepareForParse();let J;return J=this._chainOrCallSubCommandHook(J,R,"preSubcommand"),J=this._chainOrCall(J,()=>{if(R._executableHandler)this._executeSubCommand(R,T.concat(z));else return R._parseCommand(T,z)}),J}_dispatchHelpCommand($){if(!$)this.help();let T=this._findCommand($);if(T&&!T._executableHandler)T.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,T)=>{if($.required&&this.args[T]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(z,R,J)=>{let Q=R;if(R!==null&&z.parseArg){let Z=`error: command-argument value '${R}' is invalid for argument '${z.name()}'.`;Q=this._callParseArg(z,R,J,Z)}return Q};this._checkNumberOfArguments();let T=[];this.registeredArguments.forEach((z,R)=>{let J=z.defaultValue;if(z.variadic){if(R<this.args.length){if(J=this.args.slice(R),z.parseArg)J=J.reduce((Q,Z)=>{return $(z,Z,Q)},z.defaultValue)}else if(J===void 0)J=[]}else if(R<this.args.length){if(J=this.args[R],z.parseArg)J=$(z,J,z.defaultValue)}T[R]=J}),this.processedArgs=T}_chainOrCall($,T){if($&&$.then&&typeof $.then==="function")return $.then(()=>T());return T()}_chainOrCallHooks($,T){let z=$,R=[];if(this._getCommandAndAncestors().reverse().filter((J)=>J._lifeCycleHooks[T]!==void 0).forEach((J)=>{J._lifeCycleHooks[T].forEach((Q)=>{R.push({hookedCommand:J,callback:Q})})}),T==="postAction")R.reverse();return R.forEach((J)=>{z=this._chainOrCall(z,()=>{return J.callback(J.hookedCommand,this)})}),z}_chainOrCallSubCommandHook($,T,z){let R=$;if(this._lifeCycleHooks[z]!==void 0)this._lifeCycleHooks[z].forEach((J)=>{R=this._chainOrCall(R,()=>{return J(this,T)})});return R}_parseCommand($,T){let z=this.parseOptions(T);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(z.operands),T=z.unknown,this.args=$.concat(T),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),T);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(T),this._dispatchSubcommand(this._defaultCommandName,$,T);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(z.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let R=()=>{if(z.unknown.length>0)this.unknownOption(z.unknown[0])},J=`command:${this.name()}`;if(this._actionHandler){R(),this._processArguments();let Q;if(Q=this._chainOrCallHooks(Q,"preAction"),Q=this._chainOrCall(Q,()=>this._actionHandler(this.processedArgs)),this.parent)Q=this._chainOrCall(Q,()=>{this.parent.emit(J,$,T)});return Q=this._chainOrCallHooks(Q,"postAction"),Q}if(this.parent&&this.parent.listenerCount(J))R(),this._processArguments(),this.parent.emit(J,$,T);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,T);if(this.listenerCount("command:*"))this.emit("command:*",$,T);else if(this.commands.length)this.unknownCommand();else R(),this._processArguments()}else if(this.commands.length)R(),this.help({error:!0});else R(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((T)=>T._name===$||T._aliases.includes($))}_findOption($){return this.options.find((T)=>T.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((T)=>{if(T.mandatory&&$.getOptionValue(T.attributeName())===void 0)$.missingMandatoryOptionValue(T)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((z)=>{let R=z.attributeName();if(this.getOptionValue(R)===void 0)return!1;return this.getOptionValueSource(R)!=="default"});$.filter((z)=>z.conflictsWith.length>0).forEach((z)=>{let R=$.find((J)=>z.conflictsWith.includes(J.attributeName()));if(R)this._conflictingOption(z,R)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let T=[],z=[],R=T,J=$.slice();function Q(X){return X.length>1&&X[0]==="-"}let Z=null;while(J.length){let X=J.shift();if(X==="--"){if(R===z)R.push(X);R.push(...J);break}if(Z&&!Q(X)){this.emit(`option:${Z.name()}`,X);continue}if(Z=null,Q(X)){let Y=this._findOption(X);if(Y){if(Y.required){let q=J.shift();if(q===void 0)this.optionMissingArgument(Y);this.emit(`option:${Y.name()}`,q)}else if(Y.optional){let q=null;if(J.length>0&&!Q(J[0]))q=J.shift();this.emit(`option:${Y.name()}`,q)}else this.emit(`option:${Y.name()}`);Z=Y.variadic?Y:null;continue}}if(X.length>2&&X[0]==="-"&&X[1]!=="-"){let Y=this._findOption(`-${X[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,X.slice(2));else this.emit(`option:${Y.name()}`),J.unshift(`-${X.slice(2)}`);continue}}if(/^--[^=]+=/.test(X)){let Y=X.indexOf("="),q=this._findOption(X.slice(0,Y));if(q&&(q.required||q.optional)){this.emit(`option:${q.name()}`,X.slice(Y+1));continue}}if(Q(X))R=z;if((this._enablePositionalOptions||this._passThroughOptions)&&T.length===0&&z.length===0){if(this._findCommand(X)){if(T.push(X),J.length>0)z.push(...J);break}else if(this._getHelpCommand()&&X===this._getHelpCommand().name()){if(T.push(X),J.length>0)T.push(...J);break}else if(this._defaultCommandName){if(z.push(X),J.length>0)z.push(...J);break}}if(this._passThroughOptions){if(R.push(X),J.length>0)R.push(...J);break}R.push(X)}return{operands:T,unknown:z}}opts(){if(this._storeOptionsAsProperties){let $={},T=this.options.length;for(let z=0;z<T;z++){let R=this.options[z].attributeName();$[R]=R===this._versionOptionName?this._version:this[R]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,T)=>Object.assign($,T.opts()),{})}error($,T){if(this._outputConfiguration.outputError(`${$}
|
|
22
22
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
23
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
24
|
-
`),this.outputHelp({error:!0});let
|
|
25
|
-
`),this._exit(0,"commander.version",$)}),this}description($,T){if($===void 0&&T===void 0)return this._description;if(this._description=$,T)this._argsDescription=T;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let T=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)T=this.commands[this.commands.length-1];if($===T._name)throw Error("Command alias can't be the same as its name");let
|
|
26
|
-
Expecting one of '${
|
|
27
|
-
`)}),this}_outputHelpIfRequested($){let T=this._getHelpOption();if(T&&$.find((
|
|
28
|
-
`)}function
|
|
24
|
+
`),this.outputHelp({error:!0});let z=T||{},R=z.exitCode||1,J=z.code||"commander.error";this._exit(R,J,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in B.env){let T=$.attributeName();if(this.getOptionValue(T)===void 0||["default","config","env"].includes(this.getOptionValueSource(T)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,B.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new R0(this.options),T=(z)=>{return this.getOptionValue(z)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(z))};this.options.filter((z)=>z.implied!==void 0&&T(z.attributeName())&&$.valueFromOption(this.getOptionValue(z.attributeName()),z)).forEach((z)=>{Object.keys(z.implied).filter((R)=>!T(R)).forEach((R)=>{this.setOptionValueWithSource(R,z.implied[R],"implied")})})}missingArgument($){let T=`error: missing required argument '${$}'`;this.error(T,{code:"commander.missingArgument"})}optionMissingArgument($){let T=`error: option '${$.flags}' argument missing`;this.error(T,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let T=`error: required option '${$.flags}' not specified`;this.error(T,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,T){let z=(Q)=>{let Z=Q.attributeName(),X=this.getOptionValue(Z),Y=this.options.find((U)=>U.negate&&Z===U.attributeName()),q=this.options.find((U)=>!U.negate&&Z===U.attributeName());if(Y&&(Y.presetArg===void 0&&X===!1||Y.presetArg!==void 0&&X===Y.presetArg))return Y;return q||Q},R=(Q)=>{let Z=z(Q),X=Z.attributeName();if(this.getOptionValueSource(X)==="env")return`environment variable '${Z.envVar}'`;return`option '${Z.flags}'`},J=`error: ${R($)} cannot be used with ${R(T)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let T="";if($.startsWith("--")&&this._showSuggestionAfterError){let R=[],J=this;do{let Q=J.createHelp().visibleOptions(J).filter((Z)=>Z.long).map((Z)=>Z.long);R=R.concat(Q),J=J.parent}while(J&&!J._enablePositionalOptions);T=r($,R)}let z=`error: unknown option '${$}'${T}`;this.error(z,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let T=this.registeredArguments.length,z=T===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${T} argument${z} but got ${$.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],T="";if(this._showSuggestionAfterError){let R=[];this.createHelp().visibleCommands(this).forEach((J)=>{if(R.push(J.name()),J.alias())R.push(J.alias())}),T=r($,R)}let z=`error: unknown command '${$}'${T}`;this.error(z,{code:"commander.unknownCommand"})}version($,T,z){if($===void 0)return this._version;this._version=$,T=T||"-V, --version",z=z||"output the version number";let R=this.createOption(T,z);return this._versionOptionName=R.attributeName(),this._registerOption(R),this.on("option:"+R.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
25
|
+
`),this._exit(0,"commander.version",$)}),this}description($,T){if($===void 0&&T===void 0)return this._description;if(this._description=$,T)this._argsDescription=T;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let T=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)T=this.commands[this.commands.length-1];if($===T._name)throw Error("Command alias can't be the same as its name");let z=this.parent?._findCommand($);if(z){let R=[z.name()].concat(z.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${R}'`)}return T._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((T)=>this.alias(T)),this}usage($){if($===void 0){if(this._usage)return this._usage;let T=this.registeredArguments.map((z)=>{return $0(z)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?T:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=_.basename($,_.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let T=this.createHelp(),z=this._getOutputContext($);T.prepareContext({error:z.error,helpWidth:z.helpWidth,outputHasColors:z.hasColors});let R=T.formatHelp(this,T);if(z.hasColors)return R;return this._outputConfiguration.stripColor(R)}_getOutputContext($){$=$||{};let T=!!$.error,z,R,J;if(T)z=(Z)=>this._outputConfiguration.writeErr(Z),R=this._outputConfiguration.getErrHasColors(),J=this._outputConfiguration.getErrHelpWidth();else z=(Z)=>this._outputConfiguration.writeOut(Z),R=this._outputConfiguration.getOutHasColors(),J=this._outputConfiguration.getOutHelpWidth();return{error:T,write:(Z)=>{if(!R)Z=this._outputConfiguration.stripColor(Z);return z(Z)},hasColors:R,helpWidth:J}}outputHelp($){let T;if(typeof $==="function")T=$,$=void 0;let z=this._getOutputContext($),R={error:z.error,write:z.write,command:this};this._getCommandAndAncestors().reverse().forEach((Q)=>Q.emit("beforeAllHelp",R)),this.emit("beforeHelp",R);let J=this.helpInformation({error:z.error});if(T){if(J=T(J),typeof J!=="string"&&!Buffer.isBuffer(J))throw Error("outputHelp callback must return a string or a Buffer")}if(z.write(J),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",R),this._getCommandAndAncestors().forEach((Q)=>Q.emit("afterAllHelp",R))}helpOption($,T){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",T=T??"display help for command",this._helpOption=this.createOption($,T),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let T=Number(B.exitCode??0);if(T===0&&$&&typeof $!=="function"&&$.error)T=1;this._exit(T,"commander.help","(outputHelp)")}addHelpText($,T){let z=["beforeAll","before","after","afterAll"];if(!z.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${z.join("', '")}'`);let R=`${$}Help`;return this.on(R,(J)=>{let Q;if(typeof T==="function")Q=T({error:J.error,command:J.command});else Q=T;if(Q)J.write(`${Q}
|
|
27
|
+
`)}),this}_outputHelpIfRequested($){let T=this._getHelpOption();if(T&&$.find((R)=>T.is(R)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function a($){return $.map((T)=>{if(!T.startsWith("--inspect"))return T;let z,R="127.0.0.1",J="9229",Q;if((Q=T.match(/^(--inspect(-brk)?)$/))!==null)z=Q[1];else if((Q=T.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(z=Q[1],/^\d+$/.test(Q[3]))J=Q[3];else R=Q[3];else if((Q=T.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)z=Q[1],R=Q[3],J=Q[4];if(z&&J!=="0")return`${z}=${R}:${parseInt(J)+1}`;return T})}function k(){if(B.env.NO_COLOR||B.env.FORCE_COLOR==="0"||B.env.FORCE_COLOR==="false")return!1;if(B.env.FORCE_COLOR||B.env.CLICOLOR_FORCE!==void 0)return!0;return}J0.Command=b;J0.useColor=k});var R$=K((Y0)=>{var{Argument:$$}=y(),{Command:C}=e(),{CommanderError:Z0,InvalidArgumentError:T$}=W(),{Help:q0}=D(),{Option:z$}=F();Y0.program=new C;Y0.createCommand=($)=>new C($);Y0.createOption=($,T)=>new z$($,T);Y0.createArgument=($,T)=>new $$($,T);Y0.Command=C;Y0.Option=z$;Y0.Argument=$$;Y0.Help=q0;Y0.CommanderError=Z0;Y0.InvalidArgumentError=T$;Y0.InvalidOptionArgumentError=T$});var J$=F$(R$(),1),{program:i0,createCommand:o0,createArgument:t0,createOption:n0,CommanderError:p0,InvalidArgumentError:r0,InvalidOptionArgumentError:a0,Command:Q$,Argument:e0,Option:$T,Help:TT}=J$.default;import{createInterface as E0}from"readline";import{existsSync as f0}from"fs";import{resolve as N0}from"path";import{existsSync as Z$,mkdirSync as W0,readFileSync as S0,writeFileSync as y0}from"fs";import{homedir as V0}from"os";import{join as q$}from"path";var E=q$(V0(),".gobot-tools"),x=q$(E,"config.json");function X$(){return{projectDir:"",installedTools:[],installedVersions:{}}}function I(){if(!Z$(x))return X$();try{let $=JSON.parse(S0(x,"utf-8"));return{installedVersions:{},...$}}catch{return X$()}}function S($){if(!Z$(E))W0(E,{recursive:!0});y0(x,JSON.stringify($,null,2)+`
|
|
28
|
+
`)}function P(){return I().projectDir!==""}function O(){return E}function v($){let T=E0({input:process.stdin,output:process.stdout});return new Promise((z)=>{T.question($,(R)=>{T.close(),z(R.trim())})})}async function Y$(){console.log(`
|
|
29
29
|
gobot-tools init
|
|
30
30
|
`),console.log(` This sets up gobot-tools for your project.
|
|
31
|
-
`);let $=
|
|
32
|
-
`);return}}let T=await
|
|
33
|
-
Directory not found: ${
|
|
34
|
-
`);return}$.projectDir=
|
|
35
|
-
Project directory set to: ${
|
|
31
|
+
`);let $=I();if($.projectDir){if(console.log(` Current project directory: ${$.projectDir}`),(await v(" Change it? (y/N) ")).toLowerCase()!=="y"){console.log(` Keeping existing configuration.
|
|
32
|
+
`);return}}let T=await v(" Where is your bot project? (absolute path) "),z=N0(T);if(!f0(z))if(console.log(`
|
|
33
|
+
Directory not found: ${z}`),(await v(" Create it? (y/N) ")).toLowerCase()==="y"){let{mkdirSync:J}=L("fs");J(z,{recursive:!0}),console.log(` Created ${z}`)}else{console.log(` Aborted.
|
|
34
|
+
`);return}$.projectDir=z,S($),console.log(`
|
|
35
|
+
Project directory set to: ${z}`),console.log(" Config saved to: ~/.gobot-tools/config.json"),console.log(`
|
|
36
36
|
Next: run "gobot-tools list" to see available tools.
|
|
37
|
-
`)}import{existsSync as
|
|
37
|
+
`)}import{existsSync as h,readFileSync as U$}from"fs";import{join as B$}from"path";var __dirname="/Users/studio/Projects/gobot-tools/cli/src/lib",D0="https://raw.githubusercontent.com/tk-47/gobot-tools/main/registry.json",F0=900000;function G$(){return B$(O(),"registry-cache.json")}async function A0(){let $=await fetch(D0);if(!$.ok)throw Error(`Failed to fetch registry: ${$.status}`);return(await $.json()).tools}function w0(){let $=G$();if(!h($))return null;try{return JSON.parse(U$($,"utf-8"))}catch{return null}}function k0($){let{mkdirSync:T,writeFileSync:z}=L("fs"),R=O();if(!h(R))T(R,{recursive:!0});let J={fetchedAt:Date.now(),tools:$};z(G$(),JSON.stringify(J,null,2))}async function M(){let $=w0();if($&&Date.now()-$.fetchedAt<F0)return $.tools;try{let T=await A0();return k0(T),T}catch{if($)return $.tools;let T=B$(__dirname,"../../../registry.json");if(h(T))return JSON.parse(U$(T,"utf-8")).tools;throw Error("Could not load tool registry. Check your internet connection.")}}function j$($,T){let z=T.toLowerCase();return $.filter((R)=>R.name.includes(z)||R.displayName.toLowerCase().includes(z)||R.description.toLowerCase().includes(z)||R.category.includes(z)||R.tags.some((J)=>J.includes(z)))}import{existsSync as _$,mkdirSync as M$,writeFileSync as b0}from"fs";import{dirname as C0,join as l}from"path";var x0="https://raw.githubusercontent.com/tk-47/gobot-tools/main/packages";async function f($){let T=I();if(!T.projectDir)throw Error('No project directory configured. Run "gobot-tools init" first.');let z=l(T.projectDir,".gobot-tools",$.name);if(!_$(z))M$(z,{recursive:!0});for(let R of $.files){let J=`${x0}/${$.name}/${R}`,Q=await fetch(J);if(!Q.ok)throw Error(`Failed to download ${R}: ${Q.status}`);let Z=await Q.text(),X=l(z,R);M$(C0(X),{recursive:!0}),b0(X,Z)}if(!T.installedTools.includes($.name))T.installedTools.push($.name);T.installedVersions[$.name]=$.version,S(T)}function H$($){let T=I();if(!T.projectDir)throw Error('No project directory configured. Run "gobot-tools init" first.');let z=l(T.projectDir,".gobot-tools",$);if(_$(z)){let{rmSync:R}=L("fs");R(z,{recursive:!0})}T.installedTools=T.installedTools.filter((R)=>R!==$),delete T.installedVersions[$],S(T)}function j($){return I().installedTools.includes($)}function L$($){return I().installedVersions[$]}async function I$(){let $=await M();console.log(`
|
|
38
38
|
gobot-tools marketplace (${$.length} tools)
|
|
39
|
-
`);let T=new Map;for(let
|
|
40
|
-
`)}function
|
|
39
|
+
`);let T=new Map;for(let z of $){let R=z.category;if(!T.has(R))T.set(R,[]);T.get(R).push(z)}for(let[z,R]of T){let J=z.charAt(0).toUpperCase()+z.slice(1);console.log(` ${J}`),console.log(` ${"─".repeat(50)}`);for(let Q of R){let Z=j(Q.name)?" [installed]":"",X=Q.name.padEnd(22);console.log(` ${X} ${Q.displayName}${Z}`),console.log(` ${"".padEnd(22)} ${O0(Q.description.slice(0,70))}`)}console.log()}console.log(` Run "gobot-tools info <tool>" for details, or "gobot-tools install <tool>" to install.
|
|
40
|
+
`)}function O0($){return`\x1B[2m${$}\x1B[0m`}async function K$($){let T=await M(),z=j$(T,$);if(z.length===0){console.log(`
|
|
41
41
|
No tools found matching "${$}".
|
|
42
42
|
`);return}console.log(`
|
|
43
|
-
${
|
|
44
|
-
`);for(let
|
|
43
|
+
${z.length} result(s) for "${$}":
|
|
44
|
+
`);for(let R of z){let J=j(R.name)?" [installed]":"";console.log(` ${R.name} — ${R.displayName}${J}`),console.log(` ${R.description}`),console.log(` Category: ${R.category} Tags: ${R.tags.join(", ")}`),console.log()}}async function P$($){let z=(await M()).find((J)=>J.name===$);if(!z){console.log(`
|
|
45
45
|
Tool "${$}" not found.`),console.log(` Run "gobot-tools list" to see available tools.
|
|
46
|
-
`);return}let
|
|
47
|
-
${
|
|
48
|
-
`),console.log(` Version: ${
|
|
49
|
-
Environment variables needed:`);for(let J of
|
|
50
|
-
Files:`);for(let J of
|
|
51
|
-
After install: ${
|
|
52
|
-
`),!
|
|
53
|
-
`)}async function
|
|
46
|
+
`);return}let R=j(z.name);if(console.log(`
|
|
47
|
+
${z.displayName} (${z.name})`),console.log(` ${"─".repeat(50)}`),console.log(` ${z.description}
|
|
48
|
+
`),console.log(` Version: ${z.version}`),console.log(` Author: ${z.author}`),console.log(` Category: ${z.category}`),console.log(` Tags: ${z.tags.join(", ")}`),console.log(` Status: ${R?"Installed":"Not installed"}`),z.dependencies.length>0)console.log(` Dependencies: ${z.dependencies.join(", ")}`);if(z.envVars.length>0){console.log(`
|
|
49
|
+
Environment variables needed:`);for(let J of z.envVars)console.log(` - ${J}`)}console.log(`
|
|
50
|
+
Files:`);for(let J of z.files)console.log(` - ${J}`);if(console.log(`
|
|
51
|
+
After install: ${z.postInstall}
|
|
52
|
+
`),!R)console.log(` Run "gobot-tools install ${z.name}" to install.
|
|
53
|
+
`)}async function W$($){if(!P()){console.log(`
|
|
54
54
|
Not initialized. Run "gobot-tools init" first to set your project directory.
|
|
55
|
-
`);return}let
|
|
55
|
+
`);return}let z=(await M()).find((R)=>R.name===$);if(!z){console.log(`
|
|
56
56
|
Tool "${$}" not found.`),console.log(` Run "gobot-tools list" to see available tools.
|
|
57
|
-
`);return}if(
|
|
58
|
-
"${
|
|
59
|
-
`);return}for(let
|
|
60
|
-
Dependency "${
|
|
61
|
-
`),console.log(` gobot-tools install ${
|
|
57
|
+
`);return}if(j(z.name)){console.log(`
|
|
58
|
+
"${z.displayName}" is already installed.
|
|
59
|
+
`);return}for(let R of z.dependencies)if(!j(R)){console.log(`
|
|
60
|
+
Dependency "${R}" is not installed. Install it first:
|
|
61
|
+
`),console.log(` gobot-tools install ${R}
|
|
62
62
|
`);return}console.log(`
|
|
63
|
-
Installing ${
|
|
64
|
-
`),
|
|
65
|
-
`)}catch(
|
|
66
|
-
Install failed: ${
|
|
67
|
-
`)}}async function
|
|
63
|
+
Installing ${z.displayName}...`);try{if(await f(z),console.log(` Installed to: <project>/.gobot-tools/${z.name}/
|
|
64
|
+
`),z.envVars.length>0){console.log(" Add these to your .env:");for(let R of z.envVars)console.log(` ${R}=your-value-here`);console.log()}console.log(` Next step: ${z.postInstall}
|
|
65
|
+
`)}catch(R){console.log(`
|
|
66
|
+
Install failed: ${R.message}
|
|
67
|
+
`)}}async function S$($){if(!P()){console.log(`
|
|
68
68
|
Not initialized. Run "gobot-tools init" first.
|
|
69
|
-
`);return}if(!
|
|
69
|
+
`);return}if(!j($)){console.log(`
|
|
70
70
|
"${$}" is not installed.
|
|
71
|
-
`);return}
|
|
71
|
+
`);return}H$($),console.log(`
|
|
72
72
|
Uninstalled "${$}".
|
|
73
|
-
`)}
|
|
73
|
+
`)}async function y$($){if(!P()){console.log(`
|
|
74
|
+
Not initialized. Run "gobot-tools init" first to set your project directory.
|
|
75
|
+
`);return}let T=await M(),z=$?T.filter((Q)=>Q.name===$):T.filter((Q)=>j(Q.name));if($&&z.length===0){console.log(`
|
|
76
|
+
Tool "${$}" not found.`),console.log(` Run "gobot-tools list" to see available tools.
|
|
77
|
+
`);return}if(z.length===0){console.log(`
|
|
78
|
+
No tools installed yet. Run "gobot-tools install <tool>" first.
|
|
79
|
+
`);return}let R=0,J=0;for(let Q of z){let Z=L$(Q.name);if(Z===Q.version){console.log(` ${Q.displayName}: already up to date (${Q.version})`),J++;continue}let X=Z??"unknown";console.log(`
|
|
80
|
+
Updating ${Q.displayName}: ${X} → ${Q.version}...`);try{await f(Q),console.log(" Updated."),R++}catch(Y){console.log(` Update failed: ${Y.message}`)}}if(console.log(),R>0)console.log(` ${R} tool(s) updated.`);if(J>0&&R===0)console.log(" All tools are up to date.");console.log()}var H=new Q$;H.name("gobot-tools").description("CLI marketplace for Autonomee community bot tools").version("1.1.1");H.command("init").description("Set up gobot-tools for your project").action(Y$);H.command("list").description("Browse all available tools").action(I$);H.command("search <query>").description("Search tools by name, category, or keyword").action(K$);H.command("info <tool>").description("Show details about a specific tool").action(P$);H.command("install <tool>").description("Install a tool into your project").action(W$);H.command("uninstall <tool>").description("Remove an installed tool").action(S$);H.command("update [tool]").description("Update an installed tool, or all installed tools if no name given").action(y$);H.parse();
|
package/package.json
CHANGED