@mintplex-labs/anything-llm-cli 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +286 -0
  2. package/dist/index.js +37 -0
  3. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,286 @@
1
+ # AnythingLLM CLI
2
+
3
+ A fast, lightweight command-line interface for chatting with your [AnythingLLM](https://anythingllm.com) instance directly from the terminal. Pipe in context, stream responses, and manage conversations — all without leaving your shell.
4
+
5
+ ```
6
+ ╔════════════════════════════════════════════════════════════════╗
7
+ ║ ║
8
+ ║ █████ ███ ██ ██ ██ ████████ ██ ██ ██ ███ ██ ██████ ║
9
+ ║ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ║
10
+ ║ ███████ ██ ██ ██ ████ ██ █████ ██ ██ ██ ██ ██ ███ ║
11
+ ║ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ║
12
+ ║ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ███ ██████ ║
13
+ ║ ║
14
+ ║ ██ ██ ██ ██ ║
15
+ ║ ██ ██ ███ ███ ║
16
+ ║ ██ ██ ██ █ ██ ║
17
+ ║ ██ ██ ██ ██ ║
18
+ ║ ███████ ███████ ██ ██ ║
19
+ ║ ║
20
+ ║ ✦ Chat with your AnythingLLM instance from the terminal ✦ ║
21
+ ║ ║
22
+ ╚════════════════════════════════════════════════════════════════╝
23
+ ```
24
+
25
+ ## Install
26
+
27
+ ### Install script (macOS/Linux)
28
+
29
+ ```bash
30
+ curl -fsSL https://raw.githubusercontent.com/Mintplex-Labs/anything-llm-cli/main/install.sh | sh
31
+ ```
32
+
33
+ This detects your platform, downloads the latest binary, and installs it to `/usr/local/bin`. Run it again to update.
34
+
35
+ To uninstall:
36
+
37
+ ```bash
38
+ sudo rm /usr/local/bin/any
39
+ ```
40
+
41
+ ### Via npm
42
+
43
+ ```bash
44
+ npm install -g anything-llm-cli
45
+ ```
46
+
47
+ This installs the `any` command globally.
48
+
49
+ ### Standalone binary
50
+
51
+ Download a prebuilt binary for your platform from the [Releases](https://github.com/mintplex-labs/anything-llm-cli/releases) page and place it somewhere on your `PATH`.
52
+
53
+ | Platform | Binary |
54
+ | ------------- | -------------------- |
55
+ | macOS ARM | `any-darwin-arm64` |
56
+ | macOS Intel | `any-darwin-x64` |
57
+ | Linux x64 | `any-linux-x64` |
58
+ | Linux ARM | `any-linux-arm64` |
59
+ | Windows x64 | `any-windows-x64.exe`|
60
+
61
+ ### From source
62
+
63
+ Requires [Bun](https://bun.sh).
64
+
65
+ ```bash
66
+ git clone https://github.com/mintplex-labs/anything-llm-cli.git
67
+ cd anything-llm-cli
68
+ bun run setup
69
+ ```
70
+
71
+ This installs dependencies and creates a `.env.local` file from `.env.example`. Open `.env.local` and fill in your values (see [Environment Variables](#environment-variables) below).
72
+
73
+ Then run with:
74
+
75
+ ```bash
76
+ bun run start prompt "Hello!"
77
+ ```
78
+
79
+ Or compile a native binary:
80
+
81
+ ```bash
82
+ bun run build
83
+ ./dist/any prompt "Hello!"
84
+ ```
85
+
86
+ ## Setup
87
+
88
+ The only required setup is your API key. You can generate one from your AnythingLLM instance under **Settings > Developer API**.
89
+
90
+ If running from source, fill in your `.env.local` file — Bun loads it automatically.
91
+
92
+ For the npm package or standalone binary, set environment variables directly:
93
+
94
+ ```bash
95
+ export ANYTHING_LLM_API_KEY="your-api-key"
96
+ export ANYTHING_LLM_BASE_URL="https://my-instance.example.com" # optional, default: http://localhost:3001
97
+ export ANYTHING_LLM_DEFAULT_WORKSPACE_SLUG="my-workspace" # optional, avoids needing -w
98
+ ```
99
+
100
+ If no workspace is specified via `-w` or the environment variable, the CLI will automatically create and use a default workspace.
101
+
102
+ > **Tip:** Add these to your `.bashrc`, `.zshrc`, or `.env` file for persistence.
103
+
104
+ ## Usage
105
+
106
+ ```
107
+ any prompt <message> [options]
108
+ ```
109
+
110
+ Running `any` with no arguments displays the help screen.
111
+
112
+ ### Commands
113
+
114
+ | Command | Alias | Description |
115
+ | --- | --- | --- |
116
+ | `prompt <message...>` | `p` | Send a prompt to the LLM |
117
+
118
+ ### Options (for `prompt`)
119
+
120
+ | Flag | Description |
121
+ | --- | --- |
122
+ | `-w, --workspace <slug>` | Workspace slug. Falls back to `ANYTHING_LLM_DEFAULT_WORKSPACE_SLUG` env var, or auto-creates a default workspace |
123
+ | `-a, --attach <path...>` | Attach image files to the prompt (png, jpg, jpeg, gif, webp) |
124
+ | `-t, --thread [slug]` | Use a specific thread for the conversation |
125
+ | `--nt, --new-thread` | Start a new thread for this conversation |
126
+ | `-S, --no-stream` | Disable streaming (wait for full response) |
127
+
128
+ #### Supported attachment types
129
+
130
+ `png`, `jpg`, `jpeg`, `gif`, `webp`
131
+
132
+ ### Examples
133
+
134
+ **Simple prompt:**
135
+
136
+ ```bash
137
+ any prompt "What is AnythingLLM?"
138
+ ```
139
+
140
+ **Multi-word prompts without quotes:**
141
+
142
+ ```bash
143
+ any prompt What is AnythingLLM
144
+ ```
145
+
146
+ **Using the short alias:**
147
+
148
+ ```bash
149
+ any p "What is AnythingLLM?"
150
+ ```
151
+
152
+ **Pipe in context from another command:**
153
+
154
+ ```bash
155
+ cat error.log | any prompt "Explain these errors"
156
+ ```
157
+
158
+ ```bash
159
+ git diff | any prompt "Write a commit message for these changes"
160
+ ```
161
+
162
+ ```bash
163
+ curl -s https://api.example.com/data | any prompt "Summarize this JSON"
164
+ ```
165
+
166
+ **Use a specific thread for ongoing conversations:**
167
+
168
+ ```bash
169
+ any prompt "Let's continue our discussion" -t thread-slug
170
+ ```
171
+
172
+ **Start a new thread:**
173
+
174
+ ```bash
175
+ any prompt "Start a fresh conversation about testing" --new-thread
176
+ ```
177
+
178
+ **Disable streaming (useful for scripting):**
179
+
180
+ ```bash
181
+ RESULT=$(any prompt "Give me a one-word answer: yes or no?" -S)
182
+ echo "The LLM said: $RESULT"
183
+ ```
184
+
185
+ **Save the response to a file:**
186
+
187
+ ```bash
188
+ any prompt "Write a summary of AnythingLLM" > summary.md
189
+ ```
190
+
191
+ > When piped to a file, ANSI formatting is automatically stripped and agent tool call assembly is cleaned up for readable plaintext output.
192
+
193
+ **Attach images:**
194
+
195
+ ```bash
196
+ any prompt "What's in this image?" -a ./photo.png
197
+ ```
198
+
199
+ ```bash
200
+ any prompt "Compare these images" -a image1.png image2.jpg
201
+ ```
202
+
203
+ **Agent workspaces:**
204
+
205
+ Agent workspaces that use tools (web browsing, scraping, etc.) are fully supported. In the terminal, tool call assembly updates in place and agent thoughts are dimmed for readability. When piped to a file, output is clean plaintext.
206
+
207
+ ## TypeScript SDK
208
+
209
+ The project also includes a fully-typed TypeScript SDK (`AnythingLLM` class) that you can use programmatically:
210
+
211
+ ```typescript
212
+ import { AnythingLLM } from "./src/sdk";
213
+
214
+ const client = new AnythingLLM({
215
+ apiKey: "your-api-key",
216
+ baseUrl: "http://localhost:3001",
217
+ });
218
+
219
+ // Send a chat message
220
+ const result = await client.workspaces.chat({
221
+ slug: "my-workspace",
222
+ message: "Hello!",
223
+ });
224
+
225
+ if (result.ok) {
226
+ console.log(result.data.textResponse);
227
+ }
228
+
229
+ // Stream a response
230
+ const stream = client.workspaces.streamChat({
231
+ slug: "my-workspace",
232
+ message: "Tell me a story",
233
+ mode: "chat",
234
+ });
235
+
236
+ for await (const chunk of stream) {
237
+ if (chunk.type === "textResponseChunk") {
238
+ process.stdout.write(chunk.textResponse);
239
+ }
240
+ }
241
+ ```
242
+
243
+ ### SDK Methods
244
+
245
+ | Method | Description |
246
+ | --- | --- |
247
+ | `workspaces.list()` | List all workspaces |
248
+ | `workspaces.get({ slug })` | Get a workspace by slug |
249
+ | `workspaces.create({ name, ... })` | Create a new workspace |
250
+ | `workspaces.chat({ slug, message })` | Send a message and get a complete response |
251
+ | `workspaces.streamChat({ slug, message })` | Stream a response as SSE chunks |
252
+ | `threads.create({ workspaceSlug, title })` | Create a new thread in a workspace |
253
+ | `threads.chat({ workspaceSlug, threadSlug, message })` | Chat within a thread |
254
+ | `threads.streamChat({ workspaceSlug, threadSlug, message })` | Stream a response within a thread |
255
+ | `threads.getMessages({ workspaceSlug, threadSlug? })` | Get chat history |
256
+
257
+ ## Development
258
+
259
+ ```bash
260
+ # Install dependencies
261
+ bun install
262
+
263
+ # Run in development
264
+ bun run start
265
+
266
+ # Lint and format
267
+ bun run lint
268
+
269
+ # Build for current platform
270
+ bun run build
271
+
272
+ # Build for all platforms
273
+ bun run build:all
274
+ ```
275
+
276
+ ## Environment Variables
277
+
278
+ | Variable | Required | Default | Description |
279
+ | --- | --- | --- | --- |
280
+ | `ANYTHING_LLM_API_KEY` | Yes | — | Your AnythingLLM API key |
281
+ | `ANYTHING_LLM_BASE_URL` | No | `http://localhost:3001` | Base URL of your AnythingLLM instance |
282
+ | `ANYTHING_LLM_DEFAULT_WORKSPACE_SLUG` | No | — | Default workspace slug (avoids needing `-w` flag) |
283
+
284
+ ## License
285
+
286
+ [MIT](LICENSE)
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as W4}from"node:module";var R4=Object.create;var{getPrototypeOf:j4,defineProperty:i,getOwnPropertyNames:L4}=Object;var K4=Object.prototype.hasOwnProperty;var I4=(q,z,J)=>{J=q!=null?R4(j4(q)):{};let Q=z||!q||!q.__esModule?i(J,"default",{value:q,enumerable:!0}):J;for(let X of L4(q))if(!K4.call(Q,X))i(Q,X,{get:()=>q[X],enumerable:!0});return Q};var D=(q,z)=>()=>(z||q((z={exports:{}}).exports,z),z.exports);var y=W4(import.meta.url);var A=D((E4)=>{class f extends Error{constructor(q,z,J){super(J);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=z,this.exitCode=q,this.nestedError=void 0}}class s extends f{constructor(q){super(1,"commander.invalidArgument",q);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}E4.CommanderError=f;E4.InvalidArgumentError=s});var k=D((N4)=>{var{InvalidArgumentError:P4}=A();class n{constructor(q,z){switch(this.description=z||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,q[0]){case"<":this.required=!0,this._name=q.slice(1,-1);break;case"[":this.required=!1,this._name=q.slice(1,-1);break;default:this.required=!0,this._name=q;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(q,z){if(z===this.defaultValue||!Array.isArray(z))return[q];return z.push(q),z}default(q,z){return this.defaultValue=q,this.defaultValueDescription=z,this}argParser(q){return this.parseArg=q,this}choices(q){return this.argChoices=q.slice(),this.parseArg=(z,J)=>{if(!this.argChoices.includes(z))throw new P4(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(z,J);return z},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function D4(q){let z=q.name()+(q.variadic===!0?"...":"");return q.required?"<"+z+">":"["+z+"]"}N4.Argument=n;N4.humanReadableArgName=D4});var v=D((w4)=>{var{humanReadableArgName:A4}=k();class r{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(q){this.helpWidth=this.helpWidth??q.helpWidth??80}visibleCommands(q){let z=q.commands.filter((Q)=>!Q._hidden),J=q._getHelpCommand();if(J&&!J._hidden)z.push(J);if(this.sortSubcommands)z.sort((Q,X)=>{return Q.name().localeCompare(X.name())});return z}compareOptions(q,z){let J=(Q)=>{return Q.short?Q.short.replace(/^-/,""):Q.long.replace(/^--/,"")};return J(q).localeCompare(J(z))}visibleOptions(q){let z=q.options.filter((Q)=>!Q.hidden),J=q._getHelpOption();if(J&&!J.hidden){let Q=J.short&&q._findOption(J.short),X=J.long&&q._findOption(J.long);if(!Q&&!X)z.push(J);else if(J.long&&!X)z.push(q.createOption(J.long,J.description));else if(J.short&&!Q)z.push(q.createOption(J.short,J.description))}if(this.sortOptions)z.sort(this.compareOptions);return z}visibleGlobalOptions(q){if(!this.showGlobalOptions)return[];let z=[];for(let J=q.parent;J;J=J.parent){let Q=J.options.filter((X)=>!X.hidden);z.push(...Q)}if(this.sortOptions)z.sort(this.compareOptions);return z}visibleArguments(q){if(q._argsDescription)q.registeredArguments.forEach((z)=>{z.description=z.description||q._argsDescription[z.name()]||""});if(q.registeredArguments.find((z)=>z.description))return q.registeredArguments;return[]}subcommandTerm(q){let z=q.registeredArguments.map((J)=>A4(J)).join(" ");return q._name+(q._aliases[0]?"|"+q._aliases[0]:"")+(q.options.length?" [options]":"")+(z?" "+z:"")}optionTerm(q){return q.flags}argumentTerm(q){return q.name()}longestSubcommandTermLength(q,z){return z.visibleCommands(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleSubcommandTerm(z.subcommandTerm(Q))))},0)}longestOptionTermLength(q,z){return z.visibleOptions(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleOptionTerm(z.optionTerm(Q))))},0)}longestGlobalOptionTermLength(q,z){return z.visibleGlobalOptions(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleOptionTerm(z.optionTerm(Q))))},0)}longestArgumentTermLength(q,z){return z.visibleArguments(q).reduce((J,Q)=>{return Math.max(J,this.displayWidth(z.styleArgumentTerm(z.argumentTerm(Q))))},0)}commandUsage(q){let z=q._name;if(q._aliases[0])z=z+"|"+q._aliases[0];let J="";for(let Q=q.parent;Q;Q=Q.parent)J=Q.name()+" "+J;return J+z+" "+q.usage()}commandDescription(q){return q.description()}subcommandDescription(q){return q.summary()||q.description()}optionDescription(q){let z=[];if(q.argChoices)z.push(`choices: ${q.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(q.defaultValue!==void 0){if(q.required||q.optional||q.isBoolean()&&typeof q.defaultValue==="boolean")z.push(`default: ${q.defaultValueDescription||JSON.stringify(q.defaultValue)}`)}if(q.presetArg!==void 0&&q.optional)z.push(`preset: ${JSON.stringify(q.presetArg)}`);if(q.envVar!==void 0)z.push(`env: ${q.envVar}`);if(z.length>0){let J=`(${z.join(", ")})`;if(q.description)return`${q.description} ${J}`;return J}return q.description}argumentDescription(q){let z=[];if(q.argChoices)z.push(`choices: ${q.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(q.defaultValue!==void 0)z.push(`default: ${q.defaultValueDescription||JSON.stringify(q.defaultValue)}`);if(z.length>0){let J=`(${z.join(", ")})`;if(q.description)return`${q.description} ${J}`;return J}return q.description}formatItemList(q,z,J){if(z.length===0)return[];return[J.styleTitle(q),...z,""]}groupItems(q,z,J){let Q=new Map;return q.forEach((X)=>{let Z=J(X);if(!Q.has(Z))Q.set(Z,[])}),z.forEach((X)=>{let Z=J(X);if(!Q.has(Z))Q.set(Z,[]);Q.get(Z).push(X)}),Q}formatHelp(q,z){let J=z.padWidth(q,z),Q=z.helpWidth??80;function X(B,H){return z.formatItem(B,J,H,z)}let Z=[`${z.styleTitle("Usage:")} ${z.styleUsage(z.commandUsage(q))}`,""],$=z.commandDescription(q);if($.length>0)Z=Z.concat([z.boxWrap(z.styleCommandDescription($),Q),""]);let _=z.visibleArguments(q).map((B)=>{return X(z.styleArgumentTerm(z.argumentTerm(B)),z.styleArgumentDescription(z.argumentDescription(B)))});if(Z=Z.concat(this.formatItemList("Arguments:",_,z)),this.groupItems(q.options,z.visibleOptions(q),(B)=>B.helpGroupHeading??"Options:").forEach((B,H)=>{let E=B.map((j)=>{return X(z.styleOptionTerm(z.optionTerm(j)),z.styleOptionDescription(z.optionDescription(j)))});Z=Z.concat(this.formatItemList(H,E,z))}),z.showGlobalOptions){let B=z.visibleGlobalOptions(q).map((H)=>{return X(z.styleOptionTerm(z.optionTerm(H)),z.styleOptionDescription(z.optionDescription(H)))});Z=Z.concat(this.formatItemList("Global Options:",B,z))}return this.groupItems(q.commands,z.visibleCommands(q),(B)=>B.helpGroup()||"Commands:").forEach((B,H)=>{let E=B.map((j)=>{return X(z.styleSubcommandTerm(z.subcommandTerm(j)),z.styleSubcommandDescription(z.subcommandDescription(j)))});Z=Z.concat(this.formatItemList(H,E,z))}),Z.join(`
3
+ `)}displayWidth(q){return t(q).length}styleTitle(q){return q}styleUsage(q){return q.split(" ").map((z)=>{if(z==="[options]")return this.styleOptionText(z);if(z==="[command]")return this.styleSubcommandText(z);if(z[0]==="["||z[0]==="<")return this.styleArgumentText(z);return this.styleCommandText(z)}).join(" ")}styleCommandDescription(q){return this.styleDescriptionText(q)}styleOptionDescription(q){return this.styleDescriptionText(q)}styleSubcommandDescription(q){return this.styleDescriptionText(q)}styleArgumentDescription(q){return this.styleDescriptionText(q)}styleDescriptionText(q){return q}styleOptionTerm(q){return this.styleOptionText(q)}styleSubcommandTerm(q){return q.split(" ").map((z)=>{if(z==="[options]")return this.styleOptionText(z);if(z[0]==="["||z[0]==="<")return this.styleArgumentText(z);return this.styleSubcommandText(z)}).join(" ")}styleArgumentTerm(q){return this.styleArgumentText(q)}styleOptionText(q){return q}styleArgumentText(q){return q}styleSubcommandText(q){return q}styleCommandText(q){return q}padWidth(q,z){return Math.max(z.longestOptionTermLength(q,z),z.longestGlobalOptionTermLength(q,z),z.longestSubcommandTermLength(q,z),z.longestArgumentTermLength(q,z))}preformatted(q){return/\n[^\S\r\n]/.test(q)}formatItem(q,z,J,Q){let Z=" ".repeat(2);if(!J)return Z+q;let $=q.padEnd(z+q.length-Q.displayWidth(q)),_=2,Y=(this.helpWidth??80)-z-_-2,B;if(Y<this.minWidthToWrap||Q.preformatted(J))B=J;else B=Q.boxWrap(J,Y).replace(/\n/g,`
4
+ `+" ".repeat(z+_));return Z+$+" ".repeat(_)+B.replace(/\n/g,`
5
+ ${Z}`)}boxWrap(q,z){if(z<this.minWidthToWrap)return q;let J=q.split(/\r\n|\n/),Q=/[\s]*[^\s]+/g,X=[];return J.forEach((Z)=>{let $=Z.match(Q);if($===null){X.push("");return}let _=[$.shift()],G=this.displayWidth(_[0]);$.forEach((Y)=>{let B=this.displayWidth(Y);if(G+B<=z){_.push(Y),G+=B;return}X.push(_.join(""));let H=Y.trimStart();_=[H],G=this.displayWidth(H)}),X.push(_.join(""))}),X.join(`
6
+ `)}}function t(q){let z=/\x1b\[\d*(;\d*)*m/g;return q.replace(z,"")}w4.Help=r;w4.stripColor=t});var h=D((b4)=>{var{InvalidArgumentError:x4}=A();class o{constructor(q,z){this.flags=q,this.description=z||"",this.required=q.includes("<"),this.optional=q.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(q),this.mandatory=!1;let J=O4(q);if(this.short=J.shortFlag,this.long=J.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,this.helpGroupHeading=void 0}default(q,z){return this.defaultValue=q,this.defaultValueDescription=z,this}preset(q){return this.presetArg=q,this}conflicts(q){return this.conflictsWith=this.conflictsWith.concat(q),this}implies(q){let z=q;if(typeof q==="string")z={[q]:!0};return this.implied=Object.assign(this.implied||{},z),this}env(q){return this.envVar=q,this}argParser(q){return this.parseArg=q,this}makeOptionMandatory(q=!0){return this.mandatory=!!q,this}hideHelp(q=!0){return this.hidden=!!q,this}_collectValue(q,z){if(z===this.defaultValue||!Array.isArray(z))return[q];return z.push(q),z}choices(q){return this.argChoices=q.slice(),this.parseArg=(z,J)=>{if(!this.argChoices.includes(z))throw new x4(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(z,J);return z},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return a(this.name().replace(/^no-/,""));return a(this.name())}helpGroup(q){return this.helpGroupHeading=q,this}is(q){return this.short===q||this.long===q}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class e{constructor(q){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,q.forEach((z)=>{if(z.negate)this.negativeOptions.set(z.attributeName(),z);else this.positiveOptions.set(z.attributeName(),z)}),this.negativeOptions.forEach((z,J)=>{if(this.positiveOptions.has(J))this.dualOptions.add(J)})}valueFromOption(q,z){let J=z.attributeName();if(!this.dualOptions.has(J))return!0;let Q=this.negativeOptions.get(J).presetArg,X=Q!==void 0?Q:!1;return z.negate===(X===q)}}function a(q){return q.split("-").reduce((z,J)=>{return z+J[0].toUpperCase()+J.slice(1)})}function O4(q){let z,J,Q=/^-[^-]$/,X=/^--[^-]/,Z=q.split(/[ |,]+/).concat("guard");if(Q.test(Z[0]))z=Z.shift();if(X.test(Z[0]))J=Z.shift();if(!z&&Q.test(Z[0]))z=Z.shift();if(!z&&X.test(Z[0]))z=J,J=Z.shift();if(Z[0].startsWith("-")){let $=Z[0],_=`option creation failed due to '${$}' in option flags '${q}'`;if(/^-[^-][^-]/.test($))throw Error(`${_}
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(Q.test($))throw Error(`${_}
10
+ - too many short flags`);if(X.test($))throw Error(`${_}
11
+ - too many long flags`);throw Error(`${_}
12
+ - unrecognised flag format`)}if(z===void 0&&J===void 0)throw Error(`option creation failed due to no flags found in '${q}'.`);return{shortFlag:z,longFlag:J}}b4.Option=o;b4.DualOptions=e});var q4=D((g4)=>{function h4(q,z){if(Math.abs(q.length-z.length)>3)return Math.max(q.length,z.length);let J=[];for(let Q=0;Q<=q.length;Q++)J[Q]=[Q];for(let Q=0;Q<=z.length;Q++)J[0][Q]=Q;for(let Q=1;Q<=z.length;Q++)for(let X=1;X<=q.length;X++){let Z=1;if(q[X-1]===z[Q-1])Z=0;else Z=1;if(J[X][Q]=Math.min(J[X-1][Q]+1,J[X][Q-1]+1,J[X-1][Q-1]+Z),X>1&&Q>1&&q[X-1]===z[Q-2]&&q[X-2]===z[Q-1])J[X][Q]=Math.min(J[X][Q],J[X-2][Q-2]+1)}return J[q.length][z.length]}function u4(q,z){if(!z||z.length===0)return"";z=Array.from(new Set(z));let J=q.startsWith("--");if(J)q=q.slice(2),z=z.map(($)=>$.slice(2));let Q=[],X=3,Z=0.4;if(z.forEach(($)=>{if($.length<=1)return;let _=h4(q,$),G=Math.max(q.length,$.length);if((G-_)/G>Z){if(_<X)X=_,Q=[$];else if(_===X)Q.push($)}}),Q.sort(($,_)=>$.localeCompare(_)),J)Q=Q.map(($)=>`--${$}`);if(Q.length>1)return`
13
+ (Did you mean one of ${Q.join(", ")}?)`;if(Q.length===1)return`
14
+ (Did you mean ${Q[0]}?)`;return""}g4.suggestSimilar=u4});var X4=D((n4)=>{var d4=y("node:events").EventEmitter,u=y("node:child_process"),P=y("node:path"),x=y("node:fs"),T=y("node:process"),{Argument:l4,humanReadableArgName:m4}=k(),{CommanderError:g}=A(),{Help:p4,stripColor:i4}=v(),{Option:z4,DualOptions:s4}=h(),{suggestSimilar:J4}=q4();class d extends d4{constructor(q){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=q||"",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:(z)=>T.stdout.write(z),writeErr:(z)=>T.stderr.write(z),outputError:(z,J)=>J(z),getOutHelpWidth:()=>T.stdout.isTTY?T.stdout.columns:void 0,getErrHelpWidth:()=>T.stderr.isTTY?T.stderr.columns:void 0,getOutHasColors:()=>c()??(T.stdout.isTTY&&T.stdout.hasColors?.()),getErrHasColors:()=>c()??(T.stderr.isTTY&&T.stderr.hasColors?.()),stripColor:(z)=>i4(z)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(q){return this._outputConfiguration=q._outputConfiguration,this._helpOption=q._helpOption,this._helpCommand=q._helpCommand,this._helpConfiguration=q._helpConfiguration,this._exitCallback=q._exitCallback,this._storeOptionsAsProperties=q._storeOptionsAsProperties,this._combineFlagAndOptionalValue=q._combineFlagAndOptionalValue,this._allowExcessArguments=q._allowExcessArguments,this._enablePositionalOptions=q._enablePositionalOptions,this._showHelpAfterError=q._showHelpAfterError,this._showSuggestionAfterError=q._showSuggestionAfterError,this}_getCommandAndAncestors(){let q=[];for(let z=this;z;z=z.parent)q.push(z);return q}command(q,z,J){let Q=z,X=J;if(typeof Q==="object"&&Q!==null)X=Q,Q=null;X=X||{};let[,Z,$]=q.match(/([^ ]+) *(.*)/),_=this.createCommand(Z);if(Q)_.description(Q),_._executableHandler=!0;if(X.isDefault)this._defaultCommandName=_._name;if(_._hidden=!!(X.noHelp||X.hidden),_._executableFile=X.executableFile||null,$)_.arguments($);if(this._registerCommand(_),_.parent=this,_.copyInheritedSettings(this),Q)return this;return _}createCommand(q){return new d(q)}createHelp(){return Object.assign(new p4,this.configureHelp())}configureHelp(q){if(q===void 0)return this._helpConfiguration;return this._helpConfiguration=q,this}configureOutput(q){if(q===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...q},this}showHelpAfterError(q=!0){if(typeof q!=="string")q=!!q;return this._showHelpAfterError=q,this}showSuggestionAfterError(q=!0){return this._showSuggestionAfterError=!!q,this}addCommand(q,z){if(!q._name)throw Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);if(z=z||{},z.isDefault)this._defaultCommandName=q._name;if(z.noHelp||z.hidden)q._hidden=!0;return this._registerCommand(q),q.parent=this,q._checkForBrokenPassThrough(),this}createArgument(q,z){return new l4(q,z)}argument(q,z,J,Q){let X=this.createArgument(q,z);if(typeof J==="function")X.default(Q).argParser(J);else X.default(J);return this.addArgument(X),this}arguments(q){return q.trim().split(/ +/).forEach((z)=>{this.argument(z)}),this}addArgument(q){let z=this.registeredArguments.slice(-1)[0];if(z?.variadic)throw Error(`only the last argument can be variadic '${z.name()}'`);if(q.required&&q.defaultValue!==void 0&&q.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${q.name()}'`);return this.registeredArguments.push(q),this}helpCommand(q,z){if(typeof q==="boolean"){if(this._addImplicitHelpCommand=q,q&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let J=q??"help [command]",[,Q,X]=J.match(/([^ ]+) *(.*)/),Z=z??"display help for command",$=this.createCommand(Q);if($.helpOption(!1),X)$.arguments(X);if(Z)$.description(Z);if(this._addImplicitHelpCommand=!0,this._helpCommand=$,q||z)this._initCommandGroup($);return this}addHelpCommand(q,z){if(typeof q!=="object")return this.helpCommand(q,z),this;return this._addImplicitHelpCommand=!0,this._helpCommand=q,this._initCommandGroup(q),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(q,z){let J=["preSubcommand","preAction","postAction"];if(!J.includes(q))throw Error(`Unexpected value for event passed to hook : '${q}'.
16
+ Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[q])this._lifeCycleHooks[q].push(z);else this._lifeCycleHooks[q]=[z];return this}exitOverride(q){if(q)this._exitCallback=q;else this._exitCallback=(z)=>{if(z.code!=="commander.executeSubCommandAsync")throw z};return this}_exit(q,z,J){if(this._exitCallback)this._exitCallback(new g(q,z,J));T.exit(q)}action(q){let z=(J)=>{let Q=this.registeredArguments.length,X=J.slice(0,Q);if(this._storeOptionsAsProperties)X[Q]=this;else X[Q]=this.opts();return X.push(this),q.apply(this,X)};return this._actionHandler=z,this}createOption(q,z){return new z4(q,z)}_callParseArg(q,z,J,Q){try{return q.parseArg(z,J)}catch(X){if(X.code==="commander.invalidArgument"){let Z=`${Q} ${X.message}`;this.error(Z,{exitCode:X.exitCode,code:X.code})}throw X}}_registerOption(q){let z=q.short&&this._findOption(q.short)||q.long&&this._findOption(q.long);if(z){let J=q.long&&this._findOption(q.long)?q.long:q.short;throw Error(`Cannot add option '${q.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${J}'
17
+ - already used by option '${z.flags}'`)}this._initOptionGroup(q),this.options.push(q)}_registerCommand(q){let z=(Q)=>{return[Q.name()].concat(Q.aliases())},J=z(q).find((Q)=>this._findCommand(Q));if(J){let Q=z(this._findCommand(J)).join("|"),X=z(q).join("|");throw Error(`cannot add command '${X}' as already have command '${Q}'`)}this._initCommandGroup(q),this.commands.push(q)}addOption(q){this._registerOption(q);let z=q.name(),J=q.attributeName();if(q.negate){let X=q.long.replace(/^--no-/,"--");if(!this._findOption(X))this.setOptionValueWithSource(J,q.defaultValue===void 0?!0:q.defaultValue,"default")}else if(q.defaultValue!==void 0)this.setOptionValueWithSource(J,q.defaultValue,"default");let Q=(X,Z,$)=>{if(X==null&&q.presetArg!==void 0)X=q.presetArg;let _=this.getOptionValue(J);if(X!==null&&q.parseArg)X=this._callParseArg(q,X,_,Z);else if(X!==null&&q.variadic)X=q._collectValue(X,_);if(X==null)if(q.negate)X=!1;else if(q.isBoolean()||q.optional)X=!0;else X="";this.setOptionValueWithSource(J,X,$)};if(this.on("option:"+z,(X)=>{let Z=`error: option '${q.flags}' argument '${X}' is invalid.`;Q(X,Z,"cli")}),q.envVar)this.on("optionEnv:"+z,(X)=>{let Z=`error: option '${q.flags}' value '${X}' from env '${q.envVar}' is invalid.`;Q(X,Z,"env")});return this}_optionEx(q,z,J,Q,X){if(typeof z==="object"&&z instanceof z4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Z=this.createOption(z,J);if(Z.makeOptionMandatory(!!q.mandatory),typeof Q==="function")Z.default(X).argParser(Q);else if(Q instanceof RegExp){let $=Q;Q=(_,G)=>{let Y=$.exec(_);return Y?Y[0]:G},Z.default(X).argParser(Q)}else Z.default(Q);return this.addOption(Z)}option(q,z,J,Q){return this._optionEx({},q,z,J,Q)}requiredOption(q,z,J,Q){return this._optionEx({mandatory:!0},q,z,J,Q)}combineFlagAndOptionalValue(q=!0){return this._combineFlagAndOptionalValue=!!q,this}allowUnknownOption(q=!0){return this._allowUnknownOption=!!q,this}allowExcessArguments(q=!0){return this._allowExcessArguments=!!q,this}enablePositionalOptions(q=!0){return this._enablePositionalOptions=!!q,this}passThroughOptions(q=!0){return this._passThroughOptions=!!q,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(q=!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=!!q,this}getOptionValue(q){if(this._storeOptionsAsProperties)return this[q];return this._optionValues[q]}setOptionValue(q,z){return this.setOptionValueWithSource(q,z,void 0)}setOptionValueWithSource(q,z,J){if(this._storeOptionsAsProperties)this[q]=z;else this._optionValues[q]=z;return this._optionValueSources[q]=J,this}getOptionValueSource(q){return this._optionValueSources[q]}getOptionValueSourceWithGlobals(q){let z;return this._getCommandAndAncestors().forEach((J)=>{if(J.getOptionValueSource(q)!==void 0)z=J.getOptionValueSource(q)}),z}_prepareUserArgs(q,z){if(q!==void 0&&!Array.isArray(q))throw Error("first parameter to parse must be array or undefined");if(z=z||{},q===void 0&&z.from===void 0){if(T.versions?.electron)z.from="electron";let Q=T.execArgv??[];if(Q.includes("-e")||Q.includes("--eval")||Q.includes("-p")||Q.includes("--print"))z.from="eval"}if(q===void 0)q=T.argv;this.rawArgs=q.slice();let J;switch(z.from){case void 0:case"node":this._scriptPath=q[1],J=q.slice(2);break;case"electron":if(T.defaultApp)this._scriptPath=q[1],J=q.slice(2);else J=q.slice(1);break;case"user":J=q.slice(0);break;case"eval":J=q.slice(1);break;default:throw Error(`unexpected parse option { from: '${z.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",J}parse(q,z){this._prepareForParse();let J=this._prepareUserArgs(q,z);return this._parseCommand([],J),this}async parseAsync(q,z){this._prepareForParse();let J=this._prepareUserArgs(q,z);return await this._parseCommand([],J),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(q,z,J){if(x.existsSync(q))return;let Q=z?`searched for local subcommand relative to directory '${z}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",X=`'${q}' does not exist
19
+ - if '${J}' 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
+ - ${Q}`;throw Error(X)}_executeSubCommand(q,z){z=z.slice();let J=!1,Q=[".js",".ts",".tsx",".mjs",".cjs"];function X(Y,B){let H=P.resolve(Y,B);if(x.existsSync(H))return H;if(Q.includes(P.extname(B)))return;let E=Q.find((j)=>x.existsSync(`${H}${j}`));if(E)return`${H}${E}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Z=q._executableFile||`${this._name}-${q._name}`,$=this._executableDir||"";if(this._scriptPath){let Y;try{Y=x.realpathSync(this._scriptPath)}catch{Y=this._scriptPath}$=P.resolve(P.dirname(Y),$)}if($){let Y=X($,Z);if(!Y&&!q._executableFile&&this._scriptPath){let B=P.basename(this._scriptPath,P.extname(this._scriptPath));if(B!==this._name)Y=X($,`${B}-${q._name}`)}Z=Y||Z}J=Q.includes(P.extname(Z));let _;if(T.platform!=="win32")if(J)z.unshift(Z),z=Q4(T.execArgv).concat(z),_=u.spawn(T.argv[0],z,{stdio:"inherit"});else _=u.spawn(Z,z,{stdio:"inherit"});else this._checkForMissingExecutable(Z,$,q._name),z.unshift(Z),z=Q4(T.execArgv).concat(z),_=u.spawn(T.execPath,z,{stdio:"inherit"});if(!_.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((B)=>{T.on(B,()=>{if(_.killed===!1&&_.exitCode===null)_.kill(B)})});let G=this._exitCallback;_.on("close",(Y)=>{if(Y=Y??1,!G)T.exit(Y);else G(new g(Y,"commander.executeSubCommandAsync","(close)"))}),_.on("error",(Y)=>{if(Y.code==="ENOENT")this._checkForMissingExecutable(Z,$,q._name);else if(Y.code==="EACCES")throw Error(`'${Z}' not executable`);if(!G)T.exit(1);else{let B=new g(1,"commander.executeSubCommandAsync","(error)");B.nestedError=Y,G(B)}}),this.runningCommand=_}_dispatchSubcommand(q,z,J){let Q=this._findCommand(q);if(!Q)this.help({error:!0});Q._prepareForParse();let X;return X=this._chainOrCallSubCommandHook(X,Q,"preSubcommand"),X=this._chainOrCall(X,()=>{if(Q._executableHandler)this._executeSubCommand(Q,z.concat(J));else return Q._parseCommand(z,J)}),X}_dispatchHelpCommand(q){if(!q)this.help();let z=this._findCommand(q);if(z&&!z._executableHandler)z.help();return this._dispatchSubcommand(q,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((q,z)=>{if(q.required&&this.args[z]==null)this.missingArgument(q.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 q=(J,Q,X)=>{let Z=Q;if(Q!==null&&J.parseArg){let $=`error: command-argument value '${Q}' is invalid for argument '${J.name()}'.`;Z=this._callParseArg(J,Q,X,$)}return Z};this._checkNumberOfArguments();let z=[];this.registeredArguments.forEach((J,Q)=>{let X=J.defaultValue;if(J.variadic){if(Q<this.args.length){if(X=this.args.slice(Q),J.parseArg)X=X.reduce((Z,$)=>{return q(J,$,Z)},J.defaultValue)}else if(X===void 0)X=[]}else if(Q<this.args.length){if(X=this.args[Q],J.parseArg)X=q(J,X,J.defaultValue)}z[Q]=X}),this.processedArgs=z}_chainOrCall(q,z){if(q?.then&&typeof q.then==="function")return q.then(()=>z());return z()}_chainOrCallHooks(q,z){let J=q,Q=[];if(this._getCommandAndAncestors().reverse().filter((X)=>X._lifeCycleHooks[z]!==void 0).forEach((X)=>{X._lifeCycleHooks[z].forEach((Z)=>{Q.push({hookedCommand:X,callback:Z})})}),z==="postAction")Q.reverse();return Q.forEach((X)=>{J=this._chainOrCall(J,()=>{return X.callback(X.hookedCommand,this)})}),J}_chainOrCallSubCommandHook(q,z,J){let Q=q;if(this._lifeCycleHooks[J]!==void 0)this._lifeCycleHooks[J].forEach((X)=>{Q=this._chainOrCall(Q,()=>{return X(this,z)})});return Q}_parseCommand(q,z){let J=this.parseOptions(z);if(this._parseOptionsEnv(),this._parseOptionsImplied(),q=q.concat(J.operands),z=J.unknown,this.args=q.concat(z),q&&this._findCommand(q[0]))return this._dispatchSubcommand(q[0],q.slice(1),z);if(this._getHelpCommand()&&q[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(q[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(z),this._dispatchSubcommand(this._defaultCommandName,q,z);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(J.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Q=()=>{if(J.unknown.length>0)this.unknownOption(J.unknown[0])},X=`command:${this.name()}`;if(this._actionHandler){Q(),this._processArguments();let Z;if(Z=this._chainOrCallHooks(Z,"preAction"),Z=this._chainOrCall(Z,()=>this._actionHandler(this.processedArgs)),this.parent)Z=this._chainOrCall(Z,()=>{this.parent.emit(X,q,z)});return Z=this._chainOrCallHooks(Z,"postAction"),Z}if(this.parent?.listenerCount(X))Q(),this._processArguments(),this.parent.emit(X,q,z);else if(q.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",q,z);if(this.listenerCount("command:*"))this.emit("command:*",q,z);else if(this.commands.length)this.unknownCommand();else Q(),this._processArguments()}else if(this.commands.length)Q(),this.help({error:!0});else Q(),this._processArguments()}_findCommand(q){if(!q)return;return this.commands.find((z)=>z._name===q||z._aliases.includes(q))}_findOption(q){return this.options.find((z)=>z.is(q))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((q)=>{q.options.forEach((z)=>{if(z.mandatory&&q.getOptionValue(z.attributeName())===void 0)q.missingMandatoryOptionValue(z)})})}_checkForConflictingLocalOptions(){let q=this.options.filter((J)=>{let Q=J.attributeName();if(this.getOptionValue(Q)===void 0)return!1;return this.getOptionValueSource(Q)!=="default"});q.filter((J)=>J.conflictsWith.length>0).forEach((J)=>{let Q=q.find((X)=>J.conflictsWith.includes(X.attributeName()));if(Q)this._conflictingOption(J,Q)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((q)=>{q._checkForConflictingLocalOptions()})}parseOptions(q){let z=[],J=[],Q=z;function X(Y){return Y.length>1&&Y[0]==="-"}let Z=(Y)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(Y))return!1;return!this._getCommandAndAncestors().some((B)=>B.options.map((H)=>H.short).some((H)=>/^-\d$/.test(H)))},$=null,_=null,G=0;while(G<q.length||_){let Y=_??q[G++];if(_=null,Y==="--"){if(Q===J)Q.push(Y);Q.push(...q.slice(G));break}if($&&(!X(Y)||Z(Y))){this.emit(`option:${$.name()}`,Y);continue}if($=null,X(Y)){let B=this._findOption(Y);if(B){if(B.required){let H=q[G++];if(H===void 0)this.optionMissingArgument(B);this.emit(`option:${B.name()}`,H)}else if(B.optional){let H=null;if(G<q.length&&(!X(q[G])||Z(q[G])))H=q[G++];this.emit(`option:${B.name()}`,H)}else this.emit(`option:${B.name()}`);$=B.variadic?B:null;continue}}if(Y.length>2&&Y[0]==="-"&&Y[1]!=="-"){let B=this._findOption(`-${Y[1]}`);if(B){if(B.required||B.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${B.name()}`,Y.slice(2));else this.emit(`option:${B.name()}`),_=`-${Y.slice(2)}`;continue}}if(/^--[^=]+=/.test(Y)){let B=Y.indexOf("="),H=this._findOption(Y.slice(0,B));if(H&&(H.required||H.optional)){this.emit(`option:${H.name()}`,Y.slice(B+1));continue}}if(Q===z&&X(Y)&&!(this.commands.length===0&&Z(Y)))Q=J;if((this._enablePositionalOptions||this._passThroughOptions)&&z.length===0&&J.length===0){if(this._findCommand(Y)){z.push(Y),J.push(...q.slice(G));break}else if(this._getHelpCommand()&&Y===this._getHelpCommand().name()){z.push(Y,...q.slice(G));break}else if(this._defaultCommandName){J.push(Y,...q.slice(G));break}}if(this._passThroughOptions){Q.push(Y,...q.slice(G));break}Q.push(Y)}return{operands:z,unknown:J}}opts(){if(this._storeOptionsAsProperties){let q={},z=this.options.length;for(let J=0;J<z;J++){let Q=this.options[J].attributeName();q[Q]=Q===this._versionOptionName?this._version:this[Q]}return q}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((q,z)=>Object.assign(q,z.opts()),{})}error(q,z){if(this._outputConfiguration.outputError(`${q}
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 J=z||{},Q=J.exitCode||1,X=J.code||"commander.error";this._exit(Q,X,q)}_parseOptionsEnv(){this.options.forEach((q)=>{if(q.envVar&&q.envVar in T.env){let z=q.attributeName();if(this.getOptionValue(z)===void 0||["default","config","env"].includes(this.getOptionValueSource(z)))if(q.required||q.optional)this.emit(`optionEnv:${q.name()}`,T.env[q.envVar]);else this.emit(`optionEnv:${q.name()}`)}})}_parseOptionsImplied(){let q=new s4(this.options),z=(J)=>{return this.getOptionValue(J)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(J))};this.options.filter((J)=>J.implied!==void 0&&z(J.attributeName())&&q.valueFromOption(this.getOptionValue(J.attributeName()),J)).forEach((J)=>{Object.keys(J.implied).filter((Q)=>!z(Q)).forEach((Q)=>{this.setOptionValueWithSource(Q,J.implied[Q],"implied")})})}missingArgument(q){let z=`error: missing required argument '${q}'`;this.error(z,{code:"commander.missingArgument"})}optionMissingArgument(q){let z=`error: option '${q.flags}' argument missing`;this.error(z,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(q){let z=`error: required option '${q.flags}' not specified`;this.error(z,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(q,z){let J=(Z)=>{let $=Z.attributeName(),_=this.getOptionValue($),G=this.options.find((B)=>B.negate&&$===B.attributeName()),Y=this.options.find((B)=>!B.negate&&$===B.attributeName());if(G&&(G.presetArg===void 0&&_===!1||G.presetArg!==void 0&&_===G.presetArg))return G;return Y||Z},Q=(Z)=>{let $=J(Z),_=$.attributeName();if(this.getOptionValueSource(_)==="env")return`environment variable '${$.envVar}'`;return`option '${$.flags}'`},X=`error: ${Q(q)} cannot be used with ${Q(z)}`;this.error(X,{code:"commander.conflictingOption"})}unknownOption(q){if(this._allowUnknownOption)return;let z="";if(q.startsWith("--")&&this._showSuggestionAfterError){let Q=[],X=this;do{let Z=X.createHelp().visibleOptions(X).filter(($)=>$.long).map(($)=>$.long);Q=Q.concat(Z),X=X.parent}while(X&&!X._enablePositionalOptions);z=J4(q,Q)}let J=`error: unknown option '${q}'${z}`;this.error(J,{code:"commander.unknownOption"})}_excessArguments(q){if(this._allowExcessArguments)return;let z=this.registeredArguments.length,J=z===1?"":"s",X=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${z} argument${J} but got ${q.length}.`;this.error(X,{code:"commander.excessArguments"})}unknownCommand(){let q=this.args[0],z="";if(this._showSuggestionAfterError){let Q=[];this.createHelp().visibleCommands(this).forEach((X)=>{if(Q.push(X.name()),X.alias())Q.push(X.alias())}),z=J4(q,Q)}let J=`error: unknown command '${q}'${z}`;this.error(J,{code:"commander.unknownCommand"})}version(q,z,J){if(q===void 0)return this._version;this._version=q,z=z||"-V, --version",J=J||"output the version number";let Q=this.createOption(z,J);return this._versionOptionName=Q.attributeName(),this._registerOption(Q),this.on("option:"+Q.name(),()=>{this._outputConfiguration.writeOut(`${q}
25
+ `),this._exit(0,"commander.version",q)}),this}description(q,z){if(q===void 0&&z===void 0)return this._description;if(this._description=q,z)this._argsDescription=z;return this}summary(q){if(q===void 0)return this._summary;return this._summary=q,this}alias(q){if(q===void 0)return this._aliases[0];let z=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)z=this.commands[this.commands.length-1];if(q===z._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand(q);if(J){let Q=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${q}' to command '${this.name()}' as already have command '${Q}'`)}return z._aliases.push(q),this}aliases(q){if(q===void 0)return this._aliases;return q.forEach((z)=>this.alias(z)),this}usage(q){if(q===void 0){if(this._usage)return this._usage;let z=this.registeredArguments.map((J)=>{return m4(J)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?z:[]).join(" ")}return this._usage=q,this}name(q){if(q===void 0)return this._name;return this._name=q,this}helpGroup(q){if(q===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=q,this}commandsGroup(q){if(q===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=q,this}optionsGroup(q){if(q===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=q,this}_initOptionGroup(q){if(this._defaultOptionGroup&&!q.helpGroupHeading)q.helpGroup(this._defaultOptionGroup)}_initCommandGroup(q){if(this._defaultCommandGroup&&!q.helpGroup())q.helpGroup(this._defaultCommandGroup)}nameFromFilename(q){return this._name=P.basename(q,P.extname(q)),this}executableDir(q){if(q===void 0)return this._executableDir;return this._executableDir=q,this}helpInformation(q){let z=this.createHelp(),J=this._getOutputContext(q);z.prepareContext({error:J.error,helpWidth:J.helpWidth,outputHasColors:J.hasColors});let Q=z.formatHelp(this,z);if(J.hasColors)return Q;return this._outputConfiguration.stripColor(Q)}_getOutputContext(q){q=q||{};let z=!!q.error,J,Q,X;if(z)J=($)=>this._outputConfiguration.writeErr($),Q=this._outputConfiguration.getErrHasColors(),X=this._outputConfiguration.getErrHelpWidth();else J=($)=>this._outputConfiguration.writeOut($),Q=this._outputConfiguration.getOutHasColors(),X=this._outputConfiguration.getOutHelpWidth();return{error:z,write:($)=>{if(!Q)$=this._outputConfiguration.stripColor($);return J($)},hasColors:Q,helpWidth:X}}outputHelp(q){let z;if(typeof q==="function")z=q,q=void 0;let J=this._getOutputContext(q),Q={error:J.error,write:J.write,command:this};this._getCommandAndAncestors().reverse().forEach((Z)=>Z.emit("beforeAllHelp",Q)),this.emit("beforeHelp",Q);let X=this.helpInformation({error:J.error});if(z){if(X=z(X),typeof X!=="string"&&!Buffer.isBuffer(X))throw Error("outputHelp callback must return a string or a Buffer")}if(J.write(X),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",Q),this._getCommandAndAncestors().forEach((Z)=>Z.emit("afterAllHelp",Q))}helpOption(q,z){if(typeof q==="boolean"){if(q){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(q??"-h, --help",z??"display help for command"),q||z)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(q){return this._helpOption=q,this._initOptionGroup(q),this}help(q){this.outputHelp(q);let z=Number(T.exitCode??0);if(z===0&&q&&typeof q!=="function"&&q.error)z=1;this._exit(z,"commander.help","(outputHelp)")}addHelpText(q,z){let J=["beforeAll","before","after","afterAll"];if(!J.includes(q))throw Error(`Unexpected value for position to addHelpText.
26
+ Expecting one of '${J.join("', '")}'`);let Q=`${q}Help`;return this.on(Q,(X)=>{let Z;if(typeof z==="function")Z=z({error:X.error,command:X.command});else Z=z;if(Z)X.write(`${Z}
27
+ `)}),this}_outputHelpIfRequested(q){let z=this._getHelpOption();if(z&&q.find((Q)=>z.is(Q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Q4(q){return q.map((z)=>{if(!z.startsWith("--inspect"))return z;let J,Q="127.0.0.1",X="9229",Z;if((Z=z.match(/^(--inspect(-brk)?)$/))!==null)J=Z[1];else if((Z=z.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=Z[1],/^\d+$/.test(Z[3]))X=Z[3];else Q=Z[3];else if((Z=z.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=Z[1],Q=Z[3],X=Z[4];if(J&&X!=="0")return`${J}=${Q}:${parseInt(X)+1}`;return z})}function c(){if(T.env.NO_COLOR||T.env.FORCE_COLOR==="0"||T.env.FORCE_COLOR==="false")return!1;if(T.env.FORCE_COLOR||T.env.CLICOLOR_FORCE!==void 0)return!0;return}n4.Command=d;n4.useColor=c});var Y4=D((e4)=>{var{Argument:Z4}=k(),{Command:l}=X4(),{CommanderError:a4,InvalidArgumentError:$4}=A(),{Help:o4}=v(),{Option:_4}=h();e4.program=new l;e4.createCommand=(q)=>new l(q);e4.createOption=(q,z)=>new _4(q,z);e4.createArgument=(q,z)=>new Z4(q,z);e4.Command=l;e4.Option=_4;e4.Argument=Z4;e4.Help=o4;e4.CommanderError=a4;e4.InvalidArgumentError=$4;e4.InvalidOptionArgumentError=$4});var B4=I4(Y4(),1),{program:w,createCommand:F6,createArgument:y6,createOption:A6,CommanderError:w6,InvalidArgumentError:C6,InvalidOptionArgumentError:k6,Command:x6,Argument:O6,Option:b6,Help:f6}=B4.default;var O={name:"@mintplex-labs/anything-llm-cli",version:"0.0.3",description:"A CLI tool to interact with AnythingLLM from the terminal",type:"module",bin:{any:"dist/index.js"},files:["dist/index.js","README.md"],keywords:["anythingllm","llm","cli","ai"],license:"MIT",scripts:{setup:"cp .env.example .env.local && bun install",start:"bun run src/index.ts",build:"bun build --compile --minify --outfile=dist/any src/index.ts","build:npm":"bun build --minify --target=node --banner '#!/usr/bin/env node' --outfile=dist/index.js src/index.ts",prepublishOnly:"bun run build:npm",lint:"bunx biome check --write .","build:linux-x64":"bun build --compile --minify --target=bun-linux-x64 --outfile=dist/any-linux-x64 src/index.ts","build:linux-arm64":"bun build --compile --minify --target=bun-linux-arm64 --outfile=dist/any-linux-arm64 src/index.ts","build:windows-x64":"bun build --compile --minify --target=bun-windows-x64 --outfile=dist/any-windows-x64.exe src/index.ts","build:darwin-x64":"bun build --compile --minify --target=bun-darwin-x64 --outfile=dist/any-darwin-x64 src/index.ts","build:darwin-arm64":"bun build --compile --minify --target=bun-darwin-arm64 --outfile=dist/any-darwin-arm64 src/index.ts","build:all":"bun run build:linux-x64 && bun run build:linux-arm64 && bun run build:windows-x64 && bun run build:darwin-x64 && bun run build:darwin-arm64"},devDependencies:{"@biomejs/biome":"2.3.15","@types/bun":"latest",lefthook:"^2.1.1"},peerDependencies:{typescript:"^5"},dependencies:{commander:"^14.0.3"}};import{readFileSync as M6}from"node:fs";import{basename as T6,extname as U6,resolve as R6}from"node:path";class b{apiKey=process.env.ANYTHINGLLM_API_KEY||"";baseUrl=new URL("http://localhost:3001");static fileToAttachment(q){let z={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"},J=R6(q),Q=U6(J).toLowerCase(),X=z[Q];if(!X)console.error(`Unsupported file type: ${Q}
28
+ Supported: ${Object.keys(z).join(", ")}`),process.exit(1);let $=M6(J).toString("base64");return{name:T6(J),mime:X,contentString:`data:${X};base64,${$}`}}streamResponse(q,z){let J=this;return{[Symbol.asyncIterator](){return async function*(){let Q=new URL(q,J.baseUrl),X=await fetch(Q.href,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${J.apiKey}`},body:JSON.stringify(z)});if(!X.ok||!X.body)throw Error(`Stream request failed with status ${X.status}`);let Z=new TextDecoder,$="";for await(let _ of X.body){$+=Z.decode(_,{stream:!0});let G=$.split(`
29
+
30
+ `);$=G.pop()||"";for(let Y of G){let B=Y.trim();if(!B.startsWith("data:"))continue;yield JSON.parse(B.slice(5).trim())}}}()}}}async callApi(q,z={}){try{let J=new URL(q,this.baseUrl),Q=await fetch(J.href,{method:z.method||"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:z.body?JSON.stringify(z.body):void 0});if(!Q.ok){let Z=await Q.text();throw Error(`API request failed with status ${Q.status}: ${Z}`)}return{ok:!0,data:await Q.json()}}catch(J){return{ok:!1,error:J instanceof Error?J.message:String(J)}}}admin={};documents={};systemSettings={};embeds={};workspaces={create:async(q)=>{return this.callApi("api/v1/workspace/new",{method:"POST",body:{...q,openAiTemp:q.temperature,openAiHistory:q.historyMessageCount,openAiPrompt:q.systemPrompt,chatMode:q.mode}})},list:async()=>{return this.callApi("api/v1/workspaces")},get:async(q)=>{return this.callApi(`api/v1/workspace/${q.slug}`)},chat:async(q)=>{return this.callApi(`api/v1/workspace/${q.slug}/chat`,{method:"POST",body:{message:q.message,mode:q.mode??"chat",attachments:q.attachments}})},streamChat:(q)=>{return this.streamResponse(`api/v1/workspace/${q.slug}/stream-chat`,{message:q.message,mode:q.mode??"chat",attachments:q.attachments})}};threads={create:async(q)=>{return this.callApi(`api/v1/workspace/${q.workspaceSlug}/thread/new`,{method:"POST",body:{...q,name:q.title}})},chat:async(q)=>{return this.callApi(`api/v1/workspace/${q.workspaceSlug}/thread/${q.threadSlug}/chat`,{method:"POST",body:{message:q.message,mode:q.mode??"chat",attachments:q.attachments}})},streamChat:(q)=>{return this.streamResponse(`api/v1/workspace/${q.workspaceSlug}/thread/${q.threadSlug}/stream-chat`,{message:q.message,mode:q.mode??"chat",attachments:q.attachments})},getMessages:async(q)=>{let z=q.threadSlug?`api/v1/workspace/${q.workspaceSlug}/thread/${q.threadSlug}/chats`:`api/v1/workspace/${q.workspaceSlug}/chats`;return this.callApi(z)}};constructor({apiKey:q,baseUrl:z}){this.apiKey=q||this.apiKey,this.baseUrl=z?new URL(z):this.baseUrl}}function G4(){return new Promise((q)=>{let z="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",(J)=>{z+=J}),process.stdin.on("end",()=>q(z))})}var H4="anythingllm-cli-default-workspace";async function M4(q,z){let J=q.join(" "),Q=process.env.ANYTHING_LLM_API_KEY;if(!Q)console.error("ANYTHING_LLM_API_KEY environment variable is not set"),process.exit(1);let X="";if(process.stdin.isTTY===!1)X=await G4();let Z=X?`${X} ${J}`:J,$=z.attach?z.attach.map(b.fileToAttachment):void 0,_=new b({apiKey:Q,baseUrl:process.env.ANYTHING_LLM_BASE_URL}),G=z.workspace||H4;if(G===H4){let U=await _.workspaces.get({slug:G});if(!U.ok)console.error(`Failed to get workspace "${G}": ${U.error}`),process.exit(1);if(U.data.workspace.length===0){let W=await _.workspaces.create({name:"AnythingLLM CLI Default Workspace",systemPrompt:"You are a helpful assistant responding to prompts from the AnythingLLM CLI tool. You will sometimes receive context passed in from the stdinput."});if(!W.ok)console.error(`Failed to create workspace: ${W.error}`),process.exit(1)}}let Y=z.thread;if(z.newThread){let U=await _.threads.create({workspaceSlug:G,title:`AnythingLLM CLI Thread - ${new Date().toLocaleString()}`});if(!U.ok)console.error(`Failed to create thread: ${U.error}`),process.exit(1);Y=U.data.thread.slug}if(!z.stream){let U=Y?await _.threads.chat({threadSlug:Y,message:Z,workspaceSlug:G,attachments:$}):await _.workspaces.chat({slug:G,message:Z,attachments:$});if(!U.ok)console.error(`LLM request failed: ${U.error}`),process.exit(1);process.stdout.write(`${U.data.textResponse}
31
+ `);return}let B=Y?_.threads.streamChat({workspaceSlug:G,threadSlug:Y,mode:"chat",message:Z,attachments:$}):_.workspaces.streamChat({slug:G,mode:"chat",message:Z,attachments:$}),H=process.stdout.isTTY===!0,E=H?"\x1B[2m":"",j=H?"\x1B[0m":"",S=!1,N="",C=!1,L=()=>{if(!S)return;if(!H&&N)process.stdout.write(`${N}
32
+ `);else process.stdout.write(`
33
+ `);S=!1,N=""},F=(U)=>{if(L(),!C)process.stdout.write(`
34
+ `),C=!0;process.stdout.write(U)};for await(let U of B)if(U.type==="textResponseChunk")F(U.textResponse);else if(U.type==="agentThought")L(),process.stdout.write(`${E}${U.thought}${j}
35
+ `);else if(U.type==="textResponse"&&U.textResponse){let W=U.textResponse;if(W.type==="toolCallInvocation"){if(H)process.stdout.write(`\r\x1B[K${E}${W.content}${j}`);N=W.content,S=!0}else if(W.type==="textResponseChunk")F(W.content)}process.stdout.write(`
36
+ `)}var j6=process.env.ANYTHING_LLM_DEFAULT_WORKSPACE_SLUG;function T4(q){q.command("prompt").alias("p").description("Send a prompt").argument("<message...>","The prompt message to send").option("-w, --workspace <slug>","Workspace slug to use. Defaults to ANYTHING_LLM_DEFAULT_WORKSPACE_SLUG environment variable.",j6).option("-t, --thread [slug]","Thread slug to use. If not provided the default thread for the workspace will be used.").option("-S, --no-stream","Disable streaming responses").option("--nt, --new-thread","Start a new thread for this conversation.").option("-a, --attach <path...>","Attach image files to the prompt (png, jpg, jpeg, gif, webp)").action(M4)}async function L6(){let q=process.env.ANYTHING_LLM_BASE_URL||"http://localhost:3001";try{return(await fetch(`${q}/api/ping`,{method:"GET",signal:AbortSignal.timeout(2000)})).ok}catch{return!1}}async function U4(){let q=await L6(),z=(M,R,I,K)=>`\x1B[1;38;2;${M};${R};${I}m${K}\x1B[0m`,J=(M)=>`\x1B[38;5;243m${M}\x1B[0m`,Q=(M)=>`\x1B[1;38;5;214m${M}\x1B[0m`,X=q?(M)=>z(90,200,170,M):(M)=>z(200,60,60,M),Z=(M,R,I)=>Math.round(M+(R-M)*I),$=q?(M,R,I)=>{let K=M/(R-1);return z(Z(70,123,K),Z(255,207,K),Z(200,224,K),I)}:(M,R,I)=>{let K=M/(R-1);return z(Z(180,220,K),Z(40,70,K),Z(40,60,K),I)},_=[" █████ ███ ██ ██ ██ ████████ ██ ██ ██ ███ ██ ██████","██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██","███████ ██ ██ ██ ████ ██ █████ ██ ██ ██ ██ ██ ███","██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██","██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ███ ██████"],G=["██ ██ ██ ██","██ ██ ███ ███","██ ██ ██ █ ██","██ ██ ██ ██","███████ ███████ ██ ██"],Y="✦ Chat with your AnythingLLM instance from the terminal ✦",B=`v${O.version}`,H=Math.max(..._.map((M)=>M.length))+2,E=(M,R)=>M+" ".repeat(Math.max(0,R-M.length)),j=(M,R)=>`${X("║")} ${M}${" ".repeat(Math.max(0,H-R))} ${X("║")}`,S=()=>j("",0),N=X(`╔${"═".repeat(H+2)}╗`),C=X(`╚${"═".repeat(H+2)}╝`),L=["",N,S()],F=_.length+G.length;for(let M=0;M<_.length;M++){let R=_[M];L.push(j($(M,F,E(R,H)),H))}L.push(S());let U=G[0].length,W=Math.floor((H-U)/2);for(let M=0;M<G.length;M++){let R=_.length+M,I=G[M],K=" ".repeat(W);if(M===0){let V=W+I.length+2+B.length;L.push(j(`${K}${$(R,F,I)} ${J(B)}`,V))}else L.push(j(K+$(R,F,I),W+I.length))}L.push(S());let m=Math.floor((H-57)/2);if(L.push(j(" ".repeat(m)+J("✦ Chat with your AnythingLLM instance from the terminal ✦"),m+57)),!q){L.push(S());let M=["Could not connect to your AnythingLLM instance.","Ensure it is running and these env vars are set:"];for(let V of M){let p=Math.max(0,Math.floor((H-V.length)/2));L.push(j(" ".repeat(p)+Q(V),p+V.length))}L.push(S());let R=["ANYTHING_LLM_API_KEY - API key for your instance","ANYTHING_LLM_BASE_URL - Instance URL"],I=Math.max(...R.map((V)=>V.length)),K=Math.max(0,Math.floor((H-I)/2));for(let V of R)L.push(j(" ".repeat(K)+Q(V),K+V.length))}return L.push(S(),C,""),L.join(`
37
+ `)}w.name("any").description("A simple CLI tool to interact with AnythingLLM").version(O.version).addHelpText("before",await U4());T4(w);w.parse();
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@mintplex-labs/anything-llm-cli",
3
+ "version": "0.0.3",
4
+ "description": "A CLI tool to interact with AnythingLLM from the terminal",
5
+ "type": "module",
6
+ "bin": {
7
+ "any": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist/index.js",
11
+ "README.md"
12
+ ],
13
+ "keywords": [
14
+ "anythingllm",
15
+ "llm",
16
+ "cli",
17
+ "ai"
18
+ ],
19
+ "license": "MIT",
20
+ "scripts": {
21
+ "setup": "cp .env.example .env.local && bun install",
22
+ "start": "bun run src/index.ts",
23
+ "build": "bun build --compile --minify --outfile=dist/any src/index.ts",
24
+ "build:npm": "bun build --minify --target=node --banner '#!/usr/bin/env node' --outfile=dist/index.js src/index.ts",
25
+ "prepublishOnly": "bun run build:npm",
26
+ "lint": "bunx biome check --write .",
27
+ "build:linux-x64": "bun build --compile --minify --target=bun-linux-x64 --outfile=dist/any-linux-x64 src/index.ts",
28
+ "build:linux-arm64": "bun build --compile --minify --target=bun-linux-arm64 --outfile=dist/any-linux-arm64 src/index.ts",
29
+ "build:windows-x64": "bun build --compile --minify --target=bun-windows-x64 --outfile=dist/any-windows-x64.exe src/index.ts",
30
+ "build:darwin-x64": "bun build --compile --minify --target=bun-darwin-x64 --outfile=dist/any-darwin-x64 src/index.ts",
31
+ "build:darwin-arm64": "bun build --compile --minify --target=bun-darwin-arm64 --outfile=dist/any-darwin-arm64 src/index.ts",
32
+ "build:all": "bun run build:linux-x64 && bun run build:linux-arm64 && bun run build:windows-x64 && bun run build:darwin-x64 && bun run build:darwin-arm64"
33
+ },
34
+ "devDependencies": {
35
+ "@biomejs/biome": "2.3.15",
36
+ "@types/bun": "latest",
37
+ "lefthook": "^2.1.1"
38
+ },
39
+ "peerDependencies": {
40
+ "typescript": "^5"
41
+ },
42
+ "dependencies": {
43
+ "commander": "^14.0.3"
44
+ }
45
+ }