specli 0.0.31 → 0.0.32
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/dist/ai/tools.d.ts +1 -1
- package/dist/cli/main.js +71 -2
- package/package.json +1 -1
package/dist/ai/tools.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { type SpecliOptions } from "../client/index.js";
|
|
|
25
25
|
* tool already has the spec loaded and ready to use.
|
|
26
26
|
*/
|
|
27
27
|
export declare function specliTool(options: SpecliOptions): Promise<import("ai").Tool<{
|
|
28
|
-
command: "list" | "
|
|
28
|
+
command: "list" | "help" | "exec";
|
|
29
29
|
resource?: string | undefined;
|
|
30
30
|
action?: string | undefined;
|
|
31
31
|
args?: string[] | undefined;
|
package/dist/cli/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { Command } from "commander";
|
|
4
|
+
import { Command, Help } from "commander";
|
|
5
5
|
import { getArgValue, hasAnyArg } from "./runtime/argv.js";
|
|
6
6
|
import { collectRepeatable } from "./runtime/collect.js";
|
|
7
7
|
/**
|
|
@@ -28,6 +28,7 @@ import { deleteToken, getToken, setToken } from "./runtime/profile/secrets.js";
|
|
|
28
28
|
import { readProfiles, upsertProfile, writeProfiles, } from "./runtime/profile/store.js";
|
|
29
29
|
export async function main(argv, options = {}) {
|
|
30
30
|
const program = new Command();
|
|
31
|
+
const defaultHelp = new Help();
|
|
31
32
|
// Get version - use embedded version if available, otherwise read from package.json
|
|
32
33
|
const cliVersion = options.version ?? getPackageVersion();
|
|
33
34
|
program
|
|
@@ -45,7 +46,6 @@ export async function main(argv, options = {}) {
|
|
|
45
46
|
.option("--api-key <key>", "API key value")
|
|
46
47
|
.option("--json", "Machine-readable output")
|
|
47
48
|
.showHelpAfterError();
|
|
48
|
-
program.addHelpText("after", `\nAgent workflow:\n 1) ${options.cliName ?? "specli"} __schema --json --min\n 2) ${options.cliName ?? "specli"} <resource> --help\n 3) ${options.cliName ?? "specli"} <resource> <action> --help\n`);
|
|
49
49
|
// If user asks for help and we have no embedded spec and no --spec, show minimal help.
|
|
50
50
|
const spec = getArgValue(argv, "--spec");
|
|
51
51
|
const wantsHelp = hasAnyArg(argv, ["-h", "--help"]);
|
|
@@ -194,6 +194,75 @@ export async function main(argv, options = {}) {
|
|
|
194
194
|
auth: options.auth,
|
|
195
195
|
},
|
|
196
196
|
});
|
|
197
|
+
program.configureHelp({
|
|
198
|
+
formatHelp: (cmd, _helper) => {
|
|
199
|
+
// Only customize the top-level help. Subcommands should keep
|
|
200
|
+
// their own default or explicitly configured help.
|
|
201
|
+
if (cmd !== program)
|
|
202
|
+
return defaultHelp.formatHelp(cmd, defaultHelp);
|
|
203
|
+
const lines = [];
|
|
204
|
+
const name = program.name();
|
|
205
|
+
const embedded = Boolean(options.embeddedSpecText);
|
|
206
|
+
lines.push(`Usage: ${name} [options] [command]`);
|
|
207
|
+
lines.push("");
|
|
208
|
+
lines.push(program.description());
|
|
209
|
+
lines.push("");
|
|
210
|
+
// OpenAPI-derived commands first (resources)
|
|
211
|
+
if (ctx.commands.resources.length > 0) {
|
|
212
|
+
lines.push("OpenAPI Commands:");
|
|
213
|
+
const resources = [...ctx.commands.resources]
|
|
214
|
+
.map((r) => r.resource)
|
|
215
|
+
.sort((a, b) => a.localeCompare(b));
|
|
216
|
+
for (const r of resources) {
|
|
217
|
+
lines.push(` ${r}`);
|
|
218
|
+
}
|
|
219
|
+
lines.push("");
|
|
220
|
+
}
|
|
221
|
+
// Non-OpenAPI commands (built-ins)
|
|
222
|
+
lines.push("Global Commands:");
|
|
223
|
+
const globalCommands = ["login", "logout", "whoami", "__schema", "help"];
|
|
224
|
+
const maxCmdLen = Math.max(...globalCommands.map((c) => c.length));
|
|
225
|
+
for (const cmdName of globalCommands) {
|
|
226
|
+
const c = program.commands.find((c) => c.name() === cmdName);
|
|
227
|
+
if (!c)
|
|
228
|
+
continue;
|
|
229
|
+
const term = cmdName === "login"
|
|
230
|
+
? "login [token]"
|
|
231
|
+
: cmdName === "help"
|
|
232
|
+
? "help [command]"
|
|
233
|
+
: cmdName;
|
|
234
|
+
const desc = c.description();
|
|
235
|
+
const pad = " ".repeat(Math.max(1, maxCmdLen - cmdName.length + 2));
|
|
236
|
+
lines.push(` ${term}${pad}${desc}`);
|
|
237
|
+
}
|
|
238
|
+
lines.push("");
|
|
239
|
+
// Global options last
|
|
240
|
+
lines.push("Global Options:");
|
|
241
|
+
const optionRows = [];
|
|
242
|
+
for (const opt of program.options) {
|
|
243
|
+
// In compiled binaries the spec is embedded; --spec is meaningless.
|
|
244
|
+
if (embedded && opt.long === "--spec")
|
|
245
|
+
continue;
|
|
246
|
+
optionRows.push({ flags: opt.flags, desc: opt.description });
|
|
247
|
+
}
|
|
248
|
+
optionRows.push({
|
|
249
|
+
flags: "-h, --help",
|
|
250
|
+
desc: "display help for command",
|
|
251
|
+
});
|
|
252
|
+
const maxOptLen = Math.max(...optionRows.map((o) => o.flags.length));
|
|
253
|
+
for (const row of optionRows) {
|
|
254
|
+
const pad = " ".repeat(Math.max(1, maxOptLen - row.flags.length + 2));
|
|
255
|
+
lines.push(` ${row.flags}${pad}${row.desc}`);
|
|
256
|
+
}
|
|
257
|
+
lines.push("");
|
|
258
|
+
lines.push("Agent workflow:");
|
|
259
|
+
lines.push(` 1) ${name} __schema --json --min`);
|
|
260
|
+
lines.push(` 2) ${name} <resource> --help`);
|
|
261
|
+
lines.push(` 3) ${name} <resource> <action> --help`);
|
|
262
|
+
lines.push("");
|
|
263
|
+
return lines.join("\n");
|
|
264
|
+
},
|
|
265
|
+
});
|
|
197
266
|
if (argv.length <= 2) {
|
|
198
267
|
program.outputHelp();
|
|
199
268
|
return;
|