gobot-tools 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/index.js +73 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GodaGo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# gobot-tools
|
|
2
|
+
|
|
3
|
+
CLI marketplace for the **Autonomee** community. Browse, install, and configure integrations for your AI Telegram bot — all from the command line.
|
|
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.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Install globally
|
|
11
|
+
bun add -g gobot-tools
|
|
12
|
+
|
|
13
|
+
# Or run without installing
|
|
14
|
+
npx gobot-tools list
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### First-Time Setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Point gobot-tools at your bot project
|
|
21
|
+
gobot-tools init
|
|
22
|
+
|
|
23
|
+
# Browse available tools
|
|
24
|
+
gobot-tools list
|
|
25
|
+
|
|
26
|
+
# Get details on a specific tool
|
|
27
|
+
gobot-tools info oura-ring
|
|
28
|
+
|
|
29
|
+
# Install a tool into your project
|
|
30
|
+
gobot-tools install oura-ring
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
After installing, open the tool's `prompt.md` in Claude Code and follow the guided setup.
|
|
34
|
+
|
|
35
|
+
## Available Tools
|
|
36
|
+
|
|
37
|
+
### Integrations
|
|
38
|
+
|
|
39
|
+
| Tool | Description |
|
|
40
|
+
|------|-------------|
|
|
41
|
+
| **ms365** | Outlook Calendar, Email, and To Do via Microsoft Graph API |
|
|
42
|
+
| **google-api** | Google Calendar and Sheets via Python CLI + TypeScript client |
|
|
43
|
+
| **tempest-weather** | WeatherFlow Tempest personal weather station — live data + forecasts |
|
|
44
|
+
| **fireflies** | Fireflies.ai meeting transcripts — auto-stores summaries and action items |
|
|
45
|
+
| **flightaware** | FlightAware AeroAPI — flight tracking with proactive Telegram notifications |
|
|
46
|
+
|
|
47
|
+
### Health
|
|
48
|
+
|
|
49
|
+
| Tool | Description |
|
|
50
|
+
|------|-------------|
|
|
51
|
+
| **oura-ring** | Oura Ring biometrics + Health Agent for sleep, readiness, medications, symptoms |
|
|
52
|
+
|
|
53
|
+
### Messaging
|
|
54
|
+
|
|
55
|
+
| Tool | Description |
|
|
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 |
|
|
59
|
+
|
|
60
|
+
### Security
|
|
61
|
+
|
|
62
|
+
| Tool | Description |
|
|
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 |
|
|
66
|
+
|
|
67
|
+
### Infrastructure
|
|
68
|
+
|
|
69
|
+
| Tool | Description |
|
|
70
|
+
|------|-------------|
|
|
71
|
+
| **supabase-to-convex** | Zero-downtime database migration with instant rollback at every phase |
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
gobot-tools init Set your bot project directory
|
|
77
|
+
gobot-tools list Browse all available tools
|
|
78
|
+
gobot-tools search <query> Search by name, category, or keyword
|
|
79
|
+
gobot-tools info <tool> Show details, env vars, dependencies
|
|
80
|
+
gobot-tools install <tool> Download tool into your project
|
|
81
|
+
gobot-tools uninstall <tool> Remove an installed tool
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## How It Works
|
|
85
|
+
|
|
86
|
+
1. **`gobot-tools init`** — tell the CLI where your bot project lives
|
|
87
|
+
2. **`gobot-tools install <tool>`** — downloads the setup guide and any scripts into `<project>/.gobot-tools/<tool>/`
|
|
88
|
+
3. **Open `prompt.md` in Claude Code** — Claude walks you through API keys, code changes, testing, and deployment
|
|
89
|
+
|
|
90
|
+
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
|
+
|
|
92
|
+
## Using Without the CLI
|
|
93
|
+
|
|
94
|
+
Every tool's `prompt.md` works on its own. If you don't want to use the CLI:
|
|
95
|
+
|
|
96
|
+
1. Browse the [`packages/`](packages/) directory
|
|
97
|
+
2. Open any `prompt.md` file
|
|
98
|
+
3. Copy it into a Claude Code session
|
|
99
|
+
4. Follow the instructions
|
|
100
|
+
|
|
101
|
+
## About
|
|
102
|
+
|
|
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.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as D$}from"node:module";var W$=Object.create;var{getPrototypeOf:f$,defineProperty:g,getOwnPropertyNames:y$}=Object;var E$=Object.prototype.hasOwnProperty;var N$=($,T,R)=>{R=$!=null?W$(f$($)):{};let z=T||!$||!$.__esModule?g(R,"default",{value:$,enumerable:!0}):R;for(let J of y$($))if(!E$.call(z,J))g(z,J,{get:()=>$[J],enumerable:!0});return z};var H=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var U=D$(import.meta.url);var K=H((V$)=>{class N extends Error{constructor($,T,R){super(R);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=T,this.exitCode=$,this.nestedError=void 0}}class l extends N{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}V$.CommanderError=N;V$.InvalidArgumentError=l});var W=H((C$)=>{var{InvalidArgumentError:w$}=K();class c{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,R)=>{if(!this.argChoices.includes(T))throw new w$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(T,R);return T},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function k$($){let T=$.name()+($.variadic===!0?"...":"");return $.required?"<"+T+">":"["+T+"]"}C$.Argument=c;C$.humanReadableArgName=k$});var D=H((v$)=>{var{humanReadableArgName:O$}=W();class m{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((z)=>!z._hidden),R=$._getHelpCommand();if(R&&!R._hidden)T.push(R);if(this.sortSubcommands)T.sort((z,J)=>{return z.name().localeCompare(J.name())});return T}compareOptions($,T){let R=(z)=>{return z.short?z.short.replace(/^-/,""):z.long.replace(/^--/,"")};return R($).localeCompare(R(T))}visibleOptions($){let T=$.options.filter((z)=>!z.hidden),R=$._getHelpOption();if(R&&!R.hidden){let z=R.short&&$._findOption(R.short),J=R.long&&$._findOption(R.long);if(!z&&!J)T.push(R);else if(R.long&&!J)T.push($.createOption(R.long,R.description));else if(R.short&&!z)T.push($.createOption(R.short,R.description))}if(this.sortOptions)T.sort(this.compareOptions);return T}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let T=[];for(let R=$.parent;R;R=R.parent){let z=R.options.filter((J)=>!J.hidden);T.push(...z)}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((R)=>O$(R)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(T?" "+T:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,T){return T.visibleCommands($).reduce((R,z)=>{return Math.max(R,this.displayWidth(T.styleSubcommandTerm(T.subcommandTerm(z))))},0)}longestOptionTermLength($,T){return T.visibleOptions($).reduce((R,z)=>{return Math.max(R,this.displayWidth(T.styleOptionTerm(T.optionTerm(z))))},0)}longestGlobalOptionTermLength($,T){return T.visibleGlobalOptions($).reduce((R,z)=>{return Math.max(R,this.displayWidth(T.styleOptionTerm(T.optionTerm(z))))},0)}longestArgumentTermLength($,T){return T.visibleArguments($).reduce((R,z)=>{return Math.max(R,this.displayWidth(T.styleArgumentTerm(T.argumentTerm(z))))},0)}commandUsage($){let T=$._name;if($._aliases[0])T=T+"|"+$._aliases[0];let R="";for(let z=$.parent;z;z=z.parent)R=z.name()+" "+R;return R+T+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let T=[];if($.argChoices)T.push(`choices: ${$.argChoices.map((R)=>JSON.stringify(R)).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((R)=>JSON.stringify(R)).join(", ")}`);if($.defaultValue!==void 0)T.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(T.length>0){let R=`(${T.join(", ")})`;if($.description)return`${$.description} ${R}`;return R}return $.description}formatHelp($,T){let R=T.padWidth($,T),z=T.helpWidth??80;function J(Y,j){return T.formatItem(Y,R,j,T)}let G=[`${T.styleTitle("Usage:")} ${T.styleUsage(T.commandUsage($))}`,""],X=T.commandDescription($);if(X.length>0)G=G.concat([T.boxWrap(T.styleCommandDescription(X),z),""]);let Q=T.visibleArguments($).map((Y)=>{return J(T.styleArgumentTerm(T.argumentTerm(Y)),T.styleArgumentDescription(T.argumentDescription(Y)))});if(Q.length>0)G=G.concat([T.styleTitle("Arguments:"),...Q,""]);let q=T.visibleOptions($).map((Y)=>{return J(T.styleOptionTerm(T.optionTerm(Y)),T.styleOptionDescription(T.optionDescription(Y)))});if(q.length>0)G=G.concat([T.styleTitle("Options:"),...q,""]);if(T.showGlobalOptions){let Y=T.visibleGlobalOptions($).map((j)=>{return J(T.styleOptionTerm(T.optionTerm(j)),T.styleOptionDescription(T.optionDescription(j)))});if(Y.length>0)G=G.concat([T.styleTitle("Global Options:"),...Y,""])}let Z=T.visibleCommands($).map((Y)=>{return J(T.styleSubcommandTerm(T.subcommandTerm(Y)),T.styleSubcommandDescription(T.subcommandDescription(Y)))});if(Z.length>0)G=G.concat([T.styleTitle("Commands:"),...Z,""]);return G.join(`
|
|
3
|
+
`)}displayWidth($){return d($).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,R,z){let G=" ".repeat(2);if(!R)return G+$;let X=$.padEnd(T+$.length-z.displayWidth($)),Q=2,Z=(this.helpWidth??80)-T-Q-2,Y;if(Z<this.minWidthToWrap||z.preformatted(R))Y=R;else Y=z.boxWrap(R,Z).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(T+Q));return G+X+" ".repeat(Q)+Y.replace(/\n/g,`
|
|
5
|
+
${G}`)}boxWrap($,T){if(T<this.minWidthToWrap)return $;let R=$.split(/\r\n|\n/),z=/[\s]*[^\s]+/g,J=[];return R.forEach((G)=>{let X=G.match(z);if(X===null){J.push("");return}let Q=[X.shift()],q=this.displayWidth(Q[0]);X.forEach((Z)=>{let Y=this.displayWidth(Z);if(q+Y<=T){Q.push(Z),q+=Y;return}J.push(Q.join(""));let j=Z.trimStart();Q=[j],q=this.displayWidth(j)}),J.push(Q.join(""))}),J.join(`
|
|
6
|
+
`)}}function d($){let T=/\x1b\[\d*(;\d*)*m/g;return $.replace(T,"")}v$.Help=m;v$.stripColor=d});var V=H((c$)=>{var{InvalidArgumentError:g$}=K();class s{constructor($,T){this.flags=$,this.description=T||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let R=l$($);if(this.short=R.shortFlag,this.long=R.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,R)=>{if(!this.argChoices.includes(T))throw new g$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(T,R);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 o{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,R)=>{if(this.positiveOptions.has(R))this.dualOptions.add(R)})}valueFromOption($,T){let R=T.attributeName();if(!this.dualOptions.has(R))return!0;let z=this.negativeOptions.get(R).presetArg,J=z!==void 0?z:!1;return T.negate===(J===$)}}function i($){return $.split("-").reduce((T,R)=>{return T+R[0].toUpperCase()+R.slice(1)})}function l$($){let T,R,z=/^-[^-]$/,J=/^--[^-]/,G=$.split(/[ |,]+/).concat("guard");if(z.test(G[0]))T=G.shift();if(J.test(G[0]))R=G.shift();if(!T&&z.test(G[0]))T=G.shift();if(!T&&J.test(G[0]))T=R,R=G.shift();if(G[0].startsWith("-")){let X=G[0],Q=`option creation failed due to '${X}' in option flags '${$}'`;if(/^-[^-][^-]/.test(X))throw Error(`${Q}
|
|
7
|
+
- a short flag is a single dash and a single character
|
|
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(z.test(X))throw Error(`${Q}
|
|
10
|
+
- too many short flags`);if(J.test(X))throw Error(`${Q}
|
|
11
|
+
- too many long flags`);throw Error(`${Q}
|
|
12
|
+
- unrecognised flag format`)}if(T===void 0&&R===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:T,longFlag:R}}c$.Option=s;c$.DualOptions=o});var t=H((o$)=>{function i$($,T){if(Math.abs($.length-T.length)>3)return Math.max($.length,T.length);let R=[];for(let z=0;z<=$.length;z++)R[z]=[z];for(let z=0;z<=T.length;z++)R[0][z]=z;for(let z=1;z<=T.length;z++)for(let J=1;J<=$.length;J++){let G=1;if($[J-1]===T[z-1])G=0;else G=1;if(R[J][z]=Math.min(R[J-1][z]+1,R[J][z-1]+1,R[J-1][z-1]+G),J>1&&z>1&&$[J-1]===T[z-2]&&$[J-2]===T[z-1])R[J][z]=Math.min(R[J][z],R[J-2][z-2]+1)}return R[$.length][T.length]}function s$($,T){if(!T||T.length===0)return"";T=Array.from(new Set(T));let R=$.startsWith("--");if(R)$=$.slice(2),T=T.map((X)=>X.slice(2));let z=[],J=3,G=0.4;if(T.forEach((X)=>{if(X.length<=1)return;let Q=i$($,X),q=Math.max($.length,X.length);if((q-Q)/q>G){if(Q<J)J=Q,z=[X];else if(Q===J)z.push(X)}}),z.sort((X,Q)=>X.localeCompare(Q)),R)z=z.map((X)=>`--${X}`);if(z.length>1)return`
|
|
13
|
+
(Did you mean one of ${z.join(", ")}?)`;if(z.length===1)return`
|
|
14
|
+
(Did you mean ${z[0]}?)`;return""}o$.suggestSimilar=s$});var a=H((TT)=>{var p$=U("node:events").EventEmitter,F=U("node:child_process"),B=U("node:path"),f=U("node:fs"),_=U("node:process"),{Argument:n$,humanReadableArgName:r$}=W(),{CommanderError:A}=K(),{Help:a$,stripColor:e$}=D(),{Option:p,DualOptions:$T}=V(),{suggestSimilar:n}=t();class k extends p${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)=>_.stdout.write(T),writeErr:(T)=>_.stderr.write(T),outputError:(T,R)=>R(T),getOutHelpWidth:()=>_.stdout.isTTY?_.stdout.columns:void 0,getErrHelpWidth:()=>_.stderr.isTTY?_.stderr.columns:void 0,getOutHasColors:()=>w()??(_.stdout.isTTY&&_.stdout.hasColors?.()),getErrHasColors:()=>w()??(_.stderr.isTTY&&_.stderr.hasColors?.()),stripColor:(T)=>e$(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,R){let z=T,J=R;if(typeof z==="object"&&z!==null)J=z,z=null;J=J||{};let[,G,X]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(G);if(z)Q.description(z),Q._executableHandler=!0;if(J.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(J.noHelp||J.hidden),Q._executableFile=J.executableFile||null,X)Q.arguments(X);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),z)return this;return Q}createCommand($){return new k($)}createHelp(){return Object.assign(new a$,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 n$($,T)}argument($,T,R,z){let J=this.createArgument($,T);if(typeof R==="function")J.default(z).argParser(R);else J.default(R);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[,R,z]=$.match(/([^ ]+) *(.*)/),J=T??"display help for command",G=this.createCommand(R);if(G.helpOption(!1),z)G.arguments(z);if(J)G.description(J);return this._addImplicitHelpCommand=!0,this._helpCommand=G,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 R=["preSubcommand","preAction","postAction"];if(!R.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
16
|
+
Expecting one of '${R.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,R){if(this._exitCallback)this._exitCallback(new A($,T,R));_.exit($)}action($){let T=(R)=>{let z=this.registeredArguments.length,J=R.slice(0,z);if(this._storeOptionsAsProperties)J[z]=this;else J[z]=this.opts();return J.push(this),$.apply(this,J)};return this._actionHandler=T,this}createOption($,T){return new p($,T)}_callParseArg($,T,R,z){try{return $.parseArg(T,R)}catch(J){if(J.code==="commander.invalidArgument"){let G=`${z} ${J.message}`;this.error(G,{exitCode:J.exitCode,code:J.code})}throw J}}_registerOption($){let T=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(T){let R=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${R}'
|
|
17
|
+
- already used by option '${T.flags}'`)}this.options.push($)}_registerCommand($){let T=(z)=>{return[z.name()].concat(z.aliases())},R=T($).find((z)=>this._findCommand(z));if(R){let z=T(this._findCommand(R)).join("|"),J=T($).join("|");throw Error(`cannot add command '${J}' as already have command '${z}'`)}this.commands.push($)}addOption($){this._registerOption($);let T=$.name(),R=$.attributeName();if($.negate){let J=$.long.replace(/^--no-/,"--");if(!this._findOption(J))this.setOptionValueWithSource(R,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(R,$.defaultValue,"default");let z=(J,G,X)=>{if(J==null&&$.presetArg!==void 0)J=$.presetArg;let Q=this.getOptionValue(R);if(J!==null&&$.parseArg)J=this._callParseArg($,J,Q,G);else if(J!==null&&$.variadic)J=$._concatValue(J,Q);if(J==null)if($.negate)J=!1;else if($.isBoolean()||$.optional)J=!0;else J="";this.setOptionValueWithSource(R,J,X)};if(this.on("option:"+T,(J)=>{let G=`error: option '${$.flags}' argument '${J}' is invalid.`;z(J,G,"cli")}),$.envVar)this.on("optionEnv:"+T,(J)=>{let G=`error: option '${$.flags}' value '${J}' from env '${$.envVar}' is invalid.`;z(J,G,"env")});return this}_optionEx($,T,R,z,J){if(typeof T==="object"&&T instanceof p)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let G=this.createOption(T,R);if(G.makeOptionMandatory(!!$.mandatory),typeof z==="function")G.default(J).argParser(z);else if(z instanceof RegExp){let X=z;z=(Q,q)=>{let Z=X.exec(Q);return Z?Z[0]:q},G.default(J).argParser(z)}else G.default(z);return this.addOption(G)}option($,T,R,z){return this._optionEx({},$,T,R,z)}requiredOption($,T,R,z){return this._optionEx({mandatory:!0},$,T,R,z)}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,R){if(this._storeOptionsAsProperties)this[$]=T;else this._optionValues[$]=T;return this._optionValueSources[$]=R,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let T;return this._getCommandAndAncestors().forEach((R)=>{if(R.getOptionValueSource($)!==void 0)T=R.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(_.versions?.electron)T.from="electron";let z=_.execArgv??[];if(z.includes("-e")||z.includes("--eval")||z.includes("-p")||z.includes("--print"))T.from="eval"}if($===void 0)$=_.argv;this.rawArgs=$.slice();let R;switch(T.from){case void 0:case"node":this._scriptPath=$[1],R=$.slice(2);break;case"electron":if(_.defaultApp)this._scriptPath=$[1],R=$.slice(2);else R=$.slice(1);break;case"user":R=$.slice(0);break;case"eval":R=$.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",R}parse($,T){this._prepareForParse();let R=this._prepareUserArgs($,T);return this._parseCommand([],R),this}async parseAsync($,T){this._prepareForParse();let R=this._prepareUserArgs($,T);return await this._parseCommand([],R),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,R){if(f.existsSync($))return;let z=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 '${R}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
20
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
21
|
+
- ${z}`;throw Error(J)}_executeSubCommand($,T){T=T.slice();let R=!1,z=[".js",".ts",".tsx",".mjs",".cjs"];function J(Z,Y){let j=B.resolve(Z,Y);if(f.existsSync(j))return j;if(z.includes(B.extname(Y)))return;let u=z.find((P$)=>f.existsSync(`${j}${P$}`));if(u)return`${j}${u}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=$._executableFile||`${this._name}-${$._name}`,X=this._executableDir||"";if(this._scriptPath){let Z;try{Z=f.realpathSync(this._scriptPath)}catch{Z=this._scriptPath}X=B.resolve(B.dirname(Z),X)}if(X){let Z=J(X,G);if(!Z&&!$._executableFile&&this._scriptPath){let Y=B.basename(this._scriptPath,B.extname(this._scriptPath));if(Y!==this._name)Z=J(X,`${Y}-${$._name}`)}G=Z||G}R=z.includes(B.extname(G));let Q;if(_.platform!=="win32")if(R)T.unshift(G),T=r(_.execArgv).concat(T),Q=F.spawn(_.argv[0],T,{stdio:"inherit"});else Q=F.spawn(G,T,{stdio:"inherit"});else this._checkForMissingExecutable(G,X,$._name),T.unshift(G),T=r(_.execArgv).concat(T),Q=F.spawn(_.execPath,T,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((Y)=>{_.on(Y,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(Y)})});let q=this._exitCallback;Q.on("close",(Z)=>{if(Z=Z??1,!q)_.exit(Z);else q(new A(Z,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(Z)=>{if(Z.code==="ENOENT")this._checkForMissingExecutable(G,X,$._name);else if(Z.code==="EACCES")throw Error(`'${G}' not executable`);if(!q)_.exit(1);else{let Y=new A(1,"commander.executeSubCommandAsync","(error)");Y.nestedError=Z,q(Y)}}),this.runningCommand=Q}_dispatchSubcommand($,T,R){let z=this._findCommand($);if(!z)this.help({error:!0});z._prepareForParse();let J;return J=this._chainOrCallSubCommandHook(J,z,"preSubcommand"),J=this._chainOrCall(J,()=>{if(z._executableHandler)this._executeSubCommand(z,T.concat(R));else return z._parseCommand(T,R)}),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 $=(R,z,J)=>{let G=z;if(z!==null&&R.parseArg){let X=`error: command-argument value '${z}' is invalid for argument '${R.name()}'.`;G=this._callParseArg(R,z,J,X)}return G};this._checkNumberOfArguments();let T=[];this.registeredArguments.forEach((R,z)=>{let J=R.defaultValue;if(R.variadic){if(z<this.args.length){if(J=this.args.slice(z),R.parseArg)J=J.reduce((G,X)=>{return $(R,X,G)},R.defaultValue)}else if(J===void 0)J=[]}else if(z<this.args.length){if(J=this.args[z],R.parseArg)J=$(R,J,R.defaultValue)}T[z]=J}),this.processedArgs=T}_chainOrCall($,T){if($&&$.then&&typeof $.then==="function")return $.then(()=>T());return T()}_chainOrCallHooks($,T){let R=$,z=[];if(this._getCommandAndAncestors().reverse().filter((J)=>J._lifeCycleHooks[T]!==void 0).forEach((J)=>{J._lifeCycleHooks[T].forEach((G)=>{z.push({hookedCommand:J,callback:G})})}),T==="postAction")z.reverse();return z.forEach((J)=>{R=this._chainOrCall(R,()=>{return J.callback(J.hookedCommand,this)})}),R}_chainOrCallSubCommandHook($,T,R){let z=$;if(this._lifeCycleHooks[R]!==void 0)this._lifeCycleHooks[R].forEach((J)=>{z=this._chainOrCall(z,()=>{return J(this,T)})});return z}_parseCommand($,T){let R=this.parseOptions(T);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(R.operands),T=R.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(R.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=()=>{if(R.unknown.length>0)this.unknownOption(R.unknown[0])},J=`command:${this.name()}`;if(this._actionHandler){z(),this._processArguments();let G;if(G=this._chainOrCallHooks(G,"preAction"),G=this._chainOrCall(G,()=>this._actionHandler(this.processedArgs)),this.parent)G=this._chainOrCall(G,()=>{this.parent.emit(J,$,T)});return G=this._chainOrCallHooks(G,"postAction"),G}if(this.parent&&this.parent.listenerCount(J))z(),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 z(),this._processArguments()}else if(this.commands.length)z(),this.help({error:!0});else z(),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((R)=>{let z=R.attributeName();if(this.getOptionValue(z)===void 0)return!1;return this.getOptionValueSource(z)!=="default"});$.filter((R)=>R.conflictsWith.length>0).forEach((R)=>{let z=$.find((J)=>R.conflictsWith.includes(J.attributeName()));if(z)this._conflictingOption(R,z)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let T=[],R=[],z=T,J=$.slice();function G(Q){return Q.length>1&&Q[0]==="-"}let X=null;while(J.length){let Q=J.shift();if(Q==="--"){if(z===R)z.push(Q);z.push(...J);break}if(X&&!G(Q)){this.emit(`option:${X.name()}`,Q);continue}if(X=null,G(Q)){let q=this._findOption(Q);if(q){if(q.required){let Z=J.shift();if(Z===void 0)this.optionMissingArgument(q);this.emit(`option:${q.name()}`,Z)}else if(q.optional){let Z=null;if(J.length>0&&!G(J[0]))Z=J.shift();this.emit(`option:${q.name()}`,Z)}else this.emit(`option:${q.name()}`);X=q.variadic?q:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let q=this._findOption(`-${Q[1]}`);if(q){if(q.required||q.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${q.name()}`,Q.slice(2));else this.emit(`option:${q.name()}`),J.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let q=Q.indexOf("="),Z=this._findOption(Q.slice(0,q));if(Z&&(Z.required||Z.optional)){this.emit(`option:${Z.name()}`,Q.slice(q+1));continue}}if(G(Q))z=R;if((this._enablePositionalOptions||this._passThroughOptions)&&T.length===0&&R.length===0){if(this._findCommand(Q)){if(T.push(Q),J.length>0)R.push(...J);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(T.push(Q),J.length>0)T.push(...J);break}else if(this._defaultCommandName){if(R.push(Q),J.length>0)R.push(...J);break}}if(this._passThroughOptions){if(z.push(Q),J.length>0)z.push(...J);break}z.push(Q)}return{operands:T,unknown:R}}opts(){if(this._storeOptionsAsProperties){let $={},T=this.options.length;for(let R=0;R<T;R++){let z=this.options[R].attributeName();$[z]=z===this._versionOptionName?this._version:this[z]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,T)=>Object.assign($,T.opts()),{})}error($,T){if(this._outputConfiguration.outputError(`${$}
|
|
22
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
|
+
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
24
|
+
`),this.outputHelp({error:!0});let R=T||{},z=R.exitCode||1,J=R.code||"commander.error";this._exit(z,J,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in _.env){let T=$.attributeName();if(this.getOptionValue(T)===void 0||["default","config","env"].includes(this.getOptionValueSource(T)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,_.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new $T(this.options),T=(R)=>{return this.getOptionValue(R)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(R))};this.options.filter((R)=>R.implied!==void 0&&T(R.attributeName())&&$.valueFromOption(this.getOptionValue(R.attributeName()),R)).forEach((R)=>{Object.keys(R.implied).filter((z)=>!T(z)).forEach((z)=>{this.setOptionValueWithSource(z,R.implied[z],"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 R=(G)=>{let X=G.attributeName(),Q=this.getOptionValue(X),q=this.options.find((Y)=>Y.negate&&X===Y.attributeName()),Z=this.options.find((Y)=>!Y.negate&&X===Y.attributeName());if(q&&(q.presetArg===void 0&&Q===!1||q.presetArg!==void 0&&Q===q.presetArg))return q;return Z||G},z=(G)=>{let X=R(G),Q=X.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},J=`error: ${z($)} cannot be used with ${z(T)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let T="";if($.startsWith("--")&&this._showSuggestionAfterError){let z=[],J=this;do{let G=J.createHelp().visibleOptions(J).filter((X)=>X.long).map((X)=>X.long);z=z.concat(G),J=J.parent}while(J&&!J._enablePositionalOptions);T=n($,z)}let R=`error: unknown option '${$}'${T}`;this.error(R,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let T=this.registeredArguments.length,R=T===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${T} argument${R} but got ${$.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],T="";if(this._showSuggestionAfterError){let z=[];this.createHelp().visibleCommands(this).forEach((J)=>{if(z.push(J.name()),J.alias())z.push(J.alias())}),T=n($,z)}let R=`error: unknown command '${$}'${T}`;this.error(R,{code:"commander.unknownCommand"})}version($,T,R){if($===void 0)return this._version;this._version=$,T=T||"-V, --version",R=R||"output the version number";let z=this.createOption(T,R);return this._versionOptionName=z.attributeName(),this._registerOption(z),this.on("option:"+z.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 R=this.parent?._findCommand($);if(R){let z=[R.name()].concat(R.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${z}'`)}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((R)=>{return r$(R)});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=B.basename($,B.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let T=this.createHelp(),R=this._getOutputContext($);T.prepareContext({error:R.error,helpWidth:R.helpWidth,outputHasColors:R.hasColors});let z=T.formatHelp(this,T);if(R.hasColors)return z;return this._outputConfiguration.stripColor(z)}_getOutputContext($){$=$||{};let T=!!$.error,R,z,J;if(T)R=(X)=>this._outputConfiguration.writeErr(X),z=this._outputConfiguration.getErrHasColors(),J=this._outputConfiguration.getErrHelpWidth();else R=(X)=>this._outputConfiguration.writeOut(X),z=this._outputConfiguration.getOutHasColors(),J=this._outputConfiguration.getOutHelpWidth();return{error:T,write:(X)=>{if(!z)X=this._outputConfiguration.stripColor(X);return R(X)},hasColors:z,helpWidth:J}}outputHelp($){let T;if(typeof $==="function")T=$,$=void 0;let R=this._getOutputContext($),z={error:R.error,write:R.write,command:this};this._getCommandAndAncestors().reverse().forEach((G)=>G.emit("beforeAllHelp",z)),this.emit("beforeHelp",z);let J=this.helpInformation({error:R.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(R.write(J),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",z),this._getCommandAndAncestors().forEach((G)=>G.emit("afterAllHelp",z))}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(_.exitCode??0);if(T===0&&$&&typeof $!=="function"&&$.error)T=1;this._exit(T,"commander.help","(outputHelp)")}addHelpText($,T){let R=["beforeAll","before","after","afterAll"];if(!R.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${R.join("', '")}'`);let z=`${$}Help`;return this.on(z,(J)=>{let G;if(typeof T==="function")G=T({error:J.error,command:J.command});else G=T;if(G)J.write(`${G}
|
|
27
|
+
`)}),this}_outputHelpIfRequested($){let T=this._getHelpOption();if(T&&$.find((z)=>T.is(z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function r($){return $.map((T)=>{if(!T.startsWith("--inspect"))return T;let R,z="127.0.0.1",J="9229",G;if((G=T.match(/^(--inspect(-brk)?)$/))!==null)R=G[1];else if((G=T.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(R=G[1],/^\d+$/.test(G[3]))J=G[3];else z=G[3];else if((G=T.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)R=G[1],z=G[3],J=G[4];if(R&&J!=="0")return`${R}=${z}:${parseInt(J)+1}`;return T})}function w(){if(_.env.NO_COLOR||_.env.FORCE_COLOR==="0"||_.env.FORCE_COLOR==="false")return!1;if(_.env.FORCE_COLOR||_.env.CLICOLOR_FORCE!==void 0)return!0;return}TT.Command=k;TT.useColor=w});var R$=H((QT)=>{var{Argument:e}=W(),{Command:C}=a(),{CommanderError:JT,InvalidArgumentError:$$}=K(),{Help:GT}=D(),{Option:T$}=V();QT.program=new C;QT.createCommand=($)=>new C($);QT.createOption=($,T)=>new T$($,T);QT.createArgument=($,T)=>new e($,T);QT.Command=C;QT.Option=T$;QT.Argument=e;QT.Help=GT;QT.CommanderError=JT;QT.InvalidArgumentError=$$;QT.InvalidOptionArgumentError=$$});var z$=N$(R$(),1),{program:mT,createCommand:dT,createArgument:iT,createOption:sT,CommanderError:oT,InvalidArgumentError:tT,InvalidOptionArgumentError:pT,Command:J$,Argument:nT,Option:rT,Help:aT}=z$.default;import{createInterface as WT}from"readline";import{existsSync as fT}from"fs";import{resolve as yT}from"path";import{existsSync as Q$,mkdirSync as HT,readFileSync as ST,writeFileSync as KT}from"fs";import{homedir as PT}from"os";import{join as X$}from"path";var y=X$(PT(),".gobot-tools"),b=X$(y,"config.json");function G$(){return{projectDir:"",installedTools:[]}}function S(){if(!Q$(b))return G$();try{return JSON.parse(ST(b,"utf-8"))}catch{return G$()}}function P($){if(!Q$(y))HT(y,{recursive:!0});KT(b,JSON.stringify($,null,2)+`
|
|
28
|
+
`)}function E(){return S().projectDir!==""}function x(){return y}function O($){let T=WT({input:process.stdin,output:process.stdout});return new Promise((R)=>{T.question($,(z)=>{T.close(),R(z.trim())})})}async function Z$(){console.log(`
|
|
29
|
+
gobot-tools init
|
|
30
|
+
`),console.log(` This sets up gobot-tools for your project.
|
|
31
|
+
`);let $=S();if($.projectDir){if(console.log(` Current project directory: ${$.projectDir}`),(await O(" Change it? (y/N) ")).toLowerCase()!=="y"){console.log(` Keeping existing configuration.
|
|
32
|
+
`);return}}let T=await O(" Where is your bot project? (absolute path) "),R=yT(T);if(!fT(R))if(console.log(`
|
|
33
|
+
Directory not found: ${R}`),(await O(" Create it? (y/N) ")).toLowerCase()==="y"){let{mkdirSync:J}=U("fs");J(R,{recursive:!0}),console.log(` Created ${R}`)}else{console.log(` Aborted.
|
|
34
|
+
`);return}$.projectDir=R,P($),console.log(`
|
|
35
|
+
Project directory set to: ${R}`),console.log(" Config saved to: ~/.gobot-tools/config.json"),console.log(`
|
|
36
|
+
Next: run "gobot-tools list" to see available tools.
|
|
37
|
+
`)}import{existsSync as v,readFileSync as q$}from"fs";import{join as Y$}from"path";var __dirname="/Users/studio/Projects/gobot-tools/cli/src/lib",ET="https://raw.githubusercontent.com/tk-47/gobot-tools/main/registry.json",NT=900000;function _$(){return Y$(x(),"registry-cache.json")}async function DT(){let $=await fetch(ET);if(!$.ok)throw Error(`Failed to fetch registry: ${$.status}`);return(await $.json()).tools}function VT(){let $=_$();if(!v($))return null;try{return JSON.parse(q$($,"utf-8"))}catch{return null}}function FT($){let{mkdirSync:T,writeFileSync:R}=U("fs"),z=x();if(!v(z))T(z,{recursive:!0});let J={fetchedAt:Date.now(),tools:$};R(_$(),JSON.stringify(J,null,2))}async function M(){let $=VT();if($&&Date.now()-$.fetchedAt<NT)return $.tools;try{let T=await DT();return FT(T),T}catch{if($)return $.tools;let T=Y$(__dirname,"../../../registry.json");if(v(T))return JSON.parse(q$(T,"utf-8")).tools;throw Error("Could not load tool registry. Check your internet connection.")}}function j$($,T){let R=T.toLowerCase();return $.filter((z)=>z.name.includes(R)||z.displayName.toLowerCase().includes(R)||z.description.toLowerCase().includes(R)||z.category.includes(R)||z.tags.some((J)=>J.includes(R)))}import{existsSync as I$,mkdirSync as AT,writeFileSync as wT}from"fs";import{join as h}from"path";var kT="https://raw.githubusercontent.com/tk-47/gobot-tools/main/packages";async function B$($){let T=S();if(!T.projectDir)throw Error('No project directory configured. Run "gobot-tools init" first.');let R=h(T.projectDir,".gobot-tools",$.name);if(!I$(R))AT(R,{recursive:!0});for(let z of $.files){let J=`${kT}/${$.name}/${z}`,G=await fetch(J);if(!G.ok)throw Error(`Failed to download ${z}: ${G.status}`);let X=await G.text(),Q=h(R,z);wT(Q,X)}if(!T.installedTools.includes($.name))T.installedTools.push($.name),P(T)}function U$($){let T=S();if(!T.projectDir)throw Error('No project directory configured. Run "gobot-tools init" first.');let R=h(T.projectDir,".gobot-tools",$);if(I$(R)){let{rmSync:z}=U("fs");z(R,{recursive:!0})}T.installedTools=T.installedTools.filter((z)=>z!==$),P(T)}function I($){return S().installedTools.includes($)}async function M$(){let $=await M();console.log(`
|
|
38
|
+
gobot-tools marketplace (${$.length} tools)
|
|
39
|
+
`);let T=new Map;for(let R of $){let z=R.category;if(!T.has(z))T.set(z,[]);T.get(z).push(R)}for(let[R,z]of T){let J=R.charAt(0).toUpperCase()+R.slice(1);console.log(` ${J}`),console.log(` ${"─".repeat(50)}`);for(let G of z){let X=I(G.name)?" [installed]":"",Q=G.name.padEnd(22);console.log(` ${Q} ${G.displayName}${X}`),console.log(` ${"".padEnd(22)} ${CT(G.description.slice(0,70))}`)}console.log()}console.log(` Run "gobot-tools info <tool>" for details, or "gobot-tools install <tool>" to install.
|
|
40
|
+
`)}function CT($){return`\x1B[2m${$}\x1B[0m`}async function L$($){let T=await M(),R=j$(T,$);if(R.length===0){console.log(`
|
|
41
|
+
No tools found matching "${$}".
|
|
42
|
+
`);return}console.log(`
|
|
43
|
+
${R.length} result(s) for "${$}":
|
|
44
|
+
`);for(let z of R){let J=I(z.name)?" [installed]":"";console.log(` ${z.name} — ${z.displayName}${J}`),console.log(` ${z.description}`),console.log(` Category: ${z.category} Tags: ${z.tags.join(", ")}`),console.log()}}async function H$($){let R=(await M()).find((J)=>J.name===$);if(!R){console.log(`
|
|
45
|
+
Tool "${$}" not found.`),console.log(` Run "gobot-tools list" to see available tools.
|
|
46
|
+
`);return}let z=I(R.name);if(console.log(`
|
|
47
|
+
${R.displayName} (${R.name})`),console.log(` ${"─".repeat(50)}`),console.log(` ${R.description}
|
|
48
|
+
`),console.log(` Version: ${R.version}`),console.log(` Author: ${R.author}`),console.log(` Category: ${R.category}`),console.log(` Tags: ${R.tags.join(", ")}`),console.log(` Status: ${z?"Installed":"Not installed"}`),R.dependencies.length>0)console.log(` Dependencies: ${R.dependencies.join(", ")}`);if(R.envVars.length>0){console.log(`
|
|
49
|
+
Environment variables needed:`);for(let J of R.envVars)console.log(` - ${J}`)}console.log(`
|
|
50
|
+
Files:`);for(let J of R.files)console.log(` - ${J}`);if(console.log(`
|
|
51
|
+
After install: ${R.postInstall}
|
|
52
|
+
`),!z)console.log(` Run "gobot-tools install ${R.name}" to install.
|
|
53
|
+
`)}async function S$($){if(!E()){console.log(`
|
|
54
|
+
Not initialized. Run "gobot-tools init" first to set your project directory.
|
|
55
|
+
`);return}let R=(await M()).find((z)=>z.name===$);if(!R){console.log(`
|
|
56
|
+
Tool "${$}" not found.`),console.log(` Run "gobot-tools list" to see available tools.
|
|
57
|
+
`);return}if(I(R.name)){console.log(`
|
|
58
|
+
"${R.displayName}" is already installed.
|
|
59
|
+
`);return}for(let z of R.dependencies)if(!I(z)){console.log(`
|
|
60
|
+
Dependency "${z}" is not installed. Install it first:
|
|
61
|
+
`),console.log(` gobot-tools install ${z}
|
|
62
|
+
`);return}console.log(`
|
|
63
|
+
Installing ${R.displayName}...`);try{if(await B$(R),console.log(` Installed to: <project>/.gobot-tools/${R.name}/
|
|
64
|
+
`),R.envVars.length>0){console.log(" Add these to your .env:");for(let z of R.envVars)console.log(` ${z}=your-value-here`);console.log()}console.log(` Next step: ${R.postInstall}
|
|
65
|
+
`)}catch(z){console.log(`
|
|
66
|
+
Install failed: ${z.message}
|
|
67
|
+
`)}}async function K$($){if(!E()){console.log(`
|
|
68
|
+
Not initialized. Run "gobot-tools init" first.
|
|
69
|
+
`);return}if(!I($)){console.log(`
|
|
70
|
+
"${$}" is not installed.
|
|
71
|
+
`);return}U$($),console.log(`
|
|
72
|
+
Uninstalled "${$}".
|
|
73
|
+
`)}var L=new J$;L.name("gobot-tools").description("CLI marketplace for Autonomee community bot tools").version("1.0.0");L.command("init").description("Set up gobot-tools for your project").action(Z$);L.command("list").description("Browse all available tools").action(M$);L.command("search <query>").description("Search tools by name, category, or keyword").action(L$);L.command("info <tool>").description("Show details about a specific tool").action(H$);L.command("install <tool>").description("Install a tool into your project").action(S$);L.command("uninstall <tool>").description("Remove an installed tool").action(K$);L.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gobot-tools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI marketplace for Autonomee community bot tools — browse, install, and configure integrations for your AI Telegram bot",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"gobot-tools": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/index.js",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "bun run cli/src/index.ts",
|
|
16
|
+
"registry": "bun run scripts/generate-registry.ts",
|
|
17
|
+
"build": "cd cli && bun build src/index.ts --outfile ../dist/index.js --target node --minify",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"autonomee",
|
|
22
|
+
"telegram-bot",
|
|
23
|
+
"claude",
|
|
24
|
+
"ai-agent",
|
|
25
|
+
"tools",
|
|
26
|
+
"marketplace",
|
|
27
|
+
"integrations"
|
|
28
|
+
],
|
|
29
|
+
"author": "tk-47",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/tk-47/gobot-tools.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/tk-47/gobot-tools#readme"
|
|
36
|
+
}
|