specli 0.0.29 → 0.0.31

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/cli/main.js CHANGED
@@ -45,6 +45,7 @@ export async function main(argv, options = {}) {
45
45
  .option("--api-key <key>", "API key value")
46
46
  .option("--json", "Machine-readable output")
47
47
  .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`);
48
49
  // If user asks for help and we have no embedded spec and no --spec, show minimal help.
49
50
  const spec = getArgValue(argv, "--spec");
50
51
  const wantsHelp = hasAnyArg(argv, ["-h", "--help"]);
@@ -177,6 +178,10 @@ export async function main(argv, options = {}) {
177
178
  process.stdout.write(`- ${program.name()} ${op.resource} ${op.action}${args}\n`);
178
179
  }
179
180
  }
181
+ process.stdout.write("\nTip: explore required flags with --help at each level:\n" +
182
+ `- ${program.name()} --help\n` +
183
+ `- ${program.name()} <resource> --help\n` +
184
+ `- ${program.name()} <resource> <action> --help\n`);
180
185
  });
181
186
  addGeneratedCommands(program, {
182
187
  servers: ctx.servers,
@@ -189,5 +194,59 @@ export async function main(argv, options = {}) {
189
194
  auth: options.auth,
190
195
  },
191
196
  });
197
+ if (argv.length <= 2) {
198
+ program.outputHelp();
199
+ return;
200
+ }
201
+ const args = argv.slice(2);
202
+ const flagWithValue = new Set([
203
+ "--spec",
204
+ "--server",
205
+ "--server-var",
206
+ "--auth",
207
+ "--bearer-token",
208
+ "--oauth-token",
209
+ "--username",
210
+ "--password",
211
+ "--api-key",
212
+ ]);
213
+ const boolFlags = new Set(["--json"]);
214
+ const passthroughFlags = new Set(["-h", "--help", "-v", "--version"]);
215
+ let hasSubcommand = false;
216
+ let onlyKnownGlobals = true;
217
+ for (let i = 0; i < args.length; i++) {
218
+ const a = args[i];
219
+ if (!a)
220
+ continue;
221
+ if (passthroughFlags.has(a))
222
+ break;
223
+ if (boolFlags.has(a))
224
+ continue;
225
+ if (flagWithValue.has(a)) {
226
+ i++;
227
+ continue;
228
+ }
229
+ if (a.startsWith("--") && a.includes("=")) {
230
+ const key = a.slice(0, a.indexOf("="));
231
+ if (!flagWithValue.has(key) &&
232
+ !boolFlags.has(key) &&
233
+ !passthroughFlags.has(key)) {
234
+ onlyKnownGlobals = false;
235
+ }
236
+ continue;
237
+ }
238
+ if (a.startsWith("--") || a.startsWith("-")) {
239
+ onlyKnownGlobals = false;
240
+ continue;
241
+ }
242
+ hasSubcommand = true;
243
+ break;
244
+ }
245
+ if (!hasSubcommand &&
246
+ onlyKnownGlobals &&
247
+ !hasAnyArg(argv, ["-h", "--help", "-v", "--version"])) {
248
+ program.outputHelp();
249
+ return;
250
+ }
192
251
  await program.parseAsync(argv);
193
252
  }
@@ -264,7 +264,8 @@ export async function buildRequest(input) {
264
264
  function buildCurl(req, body) {
265
265
  const parts = ["curl", "-sS", "-X", req.method];
266
266
  for (const [k, v] of req.headers.entries()) {
267
- parts.push("-H", shellQuote(`${k}: ${v}`));
267
+ const value = k.toLowerCase() === "authorization" ? maskAuthHeader(v) : v;
268
+ parts.push("-H", shellQuote(`${k}: ${value}`));
268
269
  }
269
270
  if (typeof body === "string") {
270
271
  parts.push("--data", shellQuote(body));
@@ -272,6 +273,25 @@ function buildCurl(req, body) {
272
273
  parts.push(shellQuote(req.url));
273
274
  return parts.join(" ");
274
275
  }
276
+ function maskAuthHeader(value) {
277
+ // Mask token in authorization header, preserving scheme (e.g., "Bearer")
278
+ // "Bearer abc123xyz" -> "Bearer abc...xyz"
279
+ const parts = value.split(" ");
280
+ if (parts.length === 2) {
281
+ const [scheme, token] = parts;
282
+ return `${scheme} ${maskToken(token)}`;
283
+ }
284
+ // No scheme, just mask the whole value
285
+ return maskToken(value);
286
+ }
287
+ function maskToken(token) {
288
+ if (token.length <= 6) {
289
+ return "***";
290
+ }
291
+ const prefix = token.slice(0, 3);
292
+ const suffix = token.slice(-3);
293
+ return `${prefix}...${suffix}`;
294
+ }
275
295
  function shellQuote(value) {
276
296
  return `'${value.replace(/'/g, `'\\''`)}'`;
277
297
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specli",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "Run any OpenAPI spec as a CLI. Built for Agents.",
5
5
  "repository": {
6
6
  "type": "git",