frontmost 0.6.1 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontmost",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "See how AI apps answer your buyers' questions, from the terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/cli.js CHANGED
@@ -8,7 +8,7 @@ import { home, welcome } from "./home.js";
8
8
  import { request } from "./http.js";
9
9
  import { accessToken, openBrowser, signIn } from "./oauth.js";
10
10
  import { clean, json, render } from "./output.js";
11
- import { commands, GLOBALS, VERSION } from "./spec.js";
11
+ import { commands, GLOBALS, OPTIONAL_ARGS, VERSION } from "./spec.js";
12
12
  import { PLAIN, spinner, styleFor } from "./style.js";
13
13
 
14
14
  const SETUP_LIMIT_MS = 10 * 60_000;
@@ -302,7 +302,7 @@ async function execute(client, cmd, args, values, io) {
302
302
  // Arguments
303
303
  /** @type {Record<string, string>} */ const ids = {};
304
304
  for (const arg of cmd.args) {
305
- const value = rest.shift();
305
+ const value = rest.shift() ?? OPTIONAL_ARGS[arg];
306
306
  if (value === undefined) throw wrong(`Missing <${arg.replaceAll("_", "-")}>.`);
307
307
  ids[arg] = value;
308
308
  }
package/src/help.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Help text, made from the same command list that runs the commands.
2
2
  import { KEYS_URL } from "./config.js";
3
- import { commands, GLOBALS } from "./spec.js";
3
+ import { commands, GLOBALS, OPTIONAL_ARGS } from "./spec.js";
4
4
  import { PLAIN } from "./style.js";
5
5
 
6
6
  const DOCS_URL = "https://app.frontmost.ai/docs/api.md";
@@ -27,7 +27,7 @@ Options
27
27
  /** @param {import("./spec.js").Command} c */
28
28
  export function usage(c) {
29
29
  const ownProject = c.path === "/projects/{id}";
30
- const parts = [c.name, ...c.args.map((a) => `<${a.replaceAll("_", "-")}>`), ownProject ? "[project-id]" : "", c.positional?.label ?? ""];
30
+ const parts = [c.name, ...c.args.map((a) => (a in OPTIONAL_ARGS ? `[${a.replaceAll("_", "-")}]` : `<${a.replaceAll("_", "-")}>`)), ownProject ? "[project-id]" : "", c.positional?.label ?? ""];
31
31
  return parts.filter(Boolean).join(" ");
32
32
  }
33
33
 
package/src/spec.js CHANGED
@@ -16,7 +16,19 @@ export const VERSION = embedded?.version ?? read("package.json").version;
16
16
  */
17
17
 
18
18
  const VERBS = /** @type {Record<string, string>} */ ({ post: "add", patch: "update", delete: "remove" });
19
- const RENAMES = /** @type {Record<string, string>} */ ({ workspace: "whoami", "projects add": "projects create" });
19
+ const RENAMES = /** @type {Record<string, string>} */ ({
20
+ workspace: "whoami",
21
+ "projects add": "projects create",
22
+ "projects remove": "projects delete",
23
+ "share add": "scans share",
24
+ "rating add": "brief rate",
25
+ });
26
+
27
+ /** A GET of one scan's tab, /projects/{id}/scans/{scan_id}/<tab>, is "scans <tab>", as the API names it scans.<tab>. */
28
+ const scanTab = (/** @type {string} */ method, /** @type {string} */ path) => (method === "get" ? /\/scans\/\{scan_id\}\/([a-z]+)$/.exec(path)?.[1] : undefined);
29
+
30
+ /** A path argument that a command can leave out, and the value it then sends. */
31
+ export const OPTIONAL_ARGS = /** @type {Record<string, string>} */ ({ scan_id: "latest" });
20
32
 
21
33
  /** Body fields that a command also accepts without a flag name. */
22
34
  const POSITIONAL = /** @type {Record<string, { field: string, list?: string, label: string }>} */ ({
@@ -66,7 +78,8 @@ function command(method, path, op) {
66
78
  const noun = parts.findLast((p) => !p.startsWith("{")) ?? "";
67
79
  const verb = method === "get" ? (parts.at(-1)?.startsWith("{") ? "get" : "") : VERBS[method];
68
80
  const derived = verb ? `${noun} ${verb}` : noun;
69
- const name = RENAMES[derived] ?? derived;
81
+ const tab = scanTab(method, path);
82
+ const name = tab ? `scans ${tab}` : (RENAMES[derived] ?? derived);
70
83
  const inProject = path.startsWith("/projects/{id}");
71
84
  const params = /** @type {any[]} */ (op.parameters ?? []);
72
85
  const body = op.requestBody?.content["application/json"].schema;