sim 2.2.20 → 2.2.21-preview.260.1

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.
@@ -41,6 +41,20 @@ export interface FlagSpec {
41
41
  * current spelling rather than silently picking one.
42
42
  */
43
43
  renamedFrom?: readonly string[];
44
+ /**
45
+ * Other names this flag answers to because callers reach for them: the request field's own
46
+ * name behind a shortened flag (`--row-ids` for `--row`), or the noun a sibling command uses
47
+ * (`--ids`, `--paths` for `--file-ids`). Only for a spelling that can mean nothing but this
48
+ * field on this command. Hidden like a {@link renamedFrom} spelling, but silent.
49
+ */
50
+ hiddenAliases?: readonly string[];
51
+ /**
52
+ * The list holds workspace file ids or `files/…` paths, so an inline value written as a JSON
53
+ * array (`["wf_a","wf_b"]`) or joined with commas (`wf_a,wf_b`) is read as its entries.
54
+ * Unambiguous because an id is `[A-Za-z0-9_-]` and a path starts with `files/`: neither starts
55
+ * with `[`, and a comma splits only a value with no `/`, so a path keeps a comma in its name.
56
+ */
57
+ fileReferences?: true;
44
58
  /**
45
59
  * Accept one or more space-separated values, or `@path` / `@-` with one
46
60
  * value per line.
package/dist/embed.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type EmbedContext, type EmbeddedCliIdentity } from './embed-context';
2
+ import type { V2OperationName } from './generated/v2-api';
2
3
  import { SimClient } from './http/client';
3
4
  /**
4
5
  * In-process execution of one CLI invocation, for a server that already knows
@@ -14,7 +15,7 @@ import { SimClient } from './http/client';
14
15
  */
15
16
  export type { EmbeddedCliIdentity, EmbeddedFileSnapshot } from './embed-context';
16
17
  export { STILL_RUNNING_EXIT_CODE } from './exit-codes';
17
- export type { ExportWorkflowResponse, ListFilesResponse, ListWorkflowsResponse, ReadFileTextResponse, } from './generated/v2-api';
18
+ export type { ExportWorkflowResponse, ListFilesResponse, ListWorkflowsResponse, ReadFileTextResponse, V2OperationName, } from './generated/v2-api';
18
19
  export { SimApiError, SimClient } from './http/client';
19
20
  export interface EmbeddedCliResult {
20
21
  exitCode: number;
@@ -39,3 +40,18 @@ export declare function runEmbeddedCli(argv: string[], identity: EmbeddedCliIden
39
40
  openFile?: EmbedContext['openFile'];
40
41
  writeFile?: EmbedContext['writeFile'];
41
42
  }): Promise<EmbeddedCliResult>;
43
+ interface EmbeddedCliCommand {
44
+ /** The command's canonical path (`['workflows', 'deploy']`), aliases resolved. */
45
+ path: string[];
46
+ /** Every v2 operation it may call: a command reaches only those it declares (`connect`). */
47
+ operations: readonly V2OperationName[];
48
+ }
49
+ /**
50
+ * The command `argv` runs under {@link runEmbeddedCli}, resolved by the same command
51
+ * tree and parser and stopped before any action runs.
52
+ *
53
+ * Null when the parse ends without dispatching (help, a usage error), which calls
54
+ * nothing. Undefined when the parse could not be followed to an answer, so a caller
55
+ * deciding whether to stop for consent can fail closed.
56
+ */
57
+ export declare function resolveEmbeddedCliCommand(argv: string[]): EmbeddedCliCommand | null | undefined;
@@ -12035,7 +12035,7 @@ export declare const V2_OPERATIONS: {
12035
12035
  readonly fileIds: {
12036
12036
  readonly kind: 'array';
12037
12037
  readonly required: true;
12038
- readonly describe: 'File identifiers to delete.';
12038
+ readonly describe: 'Files to delete, each by identifier or by the VFS path of a live file: `files/<folder>/<name>`. Pass the id when two files in a folder have names that display alike. At most 100 entries may be paths.';
12039
12039
  };
12040
12040
  };
12041
12041
  };
package/dist/index.js CHANGED
@@ -9758,7 +9758,11 @@ var V2_OPERATIONS = {
9758
9758
  summary: "Delete files",
9759
9759
  body: {
9760
9760
  workspaceId: { kind: "string", required: true, describe: "Workspace containing the files." },
9761
- fileIds: { kind: "array", required: true, describe: "File identifiers to delete." }
9761
+ fileIds: {
9762
+ kind: "array",
9763
+ required: true,
9764
+ describe: "Files to delete, each by identifier or by the VFS path of a live file: `files/<folder>/<name>`. Pass the id when two files in a folder have names that display alike. At most 100 entries may be paths."
9765
+ }
9762
9766
  }
9763
9767
  },
9764
9768
  bulkDeleteTables: {
@@ -19013,7 +19017,7 @@ var TARGET_FOLDER_PATH_FLAG = {
19013
19017
  describe: "Destination folder path; omit for root"
19014
19018
  };
19015
19019
  var LOG_LIST_FILTER_FLAGS = {
19016
- workflowIds: { name: "workflow", list: true },
19020
+ workflowIds: { name: "workflow", list: true, hiddenAliases: ["workflow-ids"] },
19017
19021
  folderPaths: FOLDER_PATHS_FLAG,
19018
19022
  triggers: { name: "trigger", list: true }
19019
19023
  };
@@ -19114,7 +19118,7 @@ var CLI_CONTRACT = {
19114
19118
  command: "tables rows batch-delete",
19115
19119
  describe: "Delete rows matching a filter, or an explicit list of ids",
19116
19120
  flags: {
19117
- rowIds: { name: "row", list: true },
19121
+ rowIds: { name: "row", list: true, hiddenAliases: ["row-ids"] },
19118
19122
  filter: { json: true, describe: TABLE_FILTER_HELP }
19119
19123
  },
19120
19124
  confirm: "This deletes every matching row and cannot be undone."
@@ -20218,7 +20222,12 @@ var CLI_CONTRACT = {
20218
20222
  command: "files batch-delete",
20219
20223
  describe: "Delete several files at once",
20220
20224
  flags: {
20221
- fileIds: { list: true, trailing: true }
20225
+ fileIds: {
20226
+ list: true,
20227
+ trailing: true,
20228
+ fileReferences: true,
20229
+ hiddenAliases: ["ids", "paths"]
20230
+ }
20222
20231
  },
20223
20232
  confirm: "This archives the listed files; restore them with `files restore`."
20224
20233
  },
@@ -21359,6 +21368,12 @@ var NUMERIC_KINDS = new Set(["number", "integer"]);
21359
21368
  function flagSpecFor(operation, field) {
21360
21369
  return CLI_CONTRACT[operation]?.flags?.[field] ?? {};
21361
21370
  }
21371
+ function otherSpellings(flag) {
21372
+ return [
21373
+ ...(flag.renamedFrom ?? []).map((name) => ({ name, renamed: true })),
21374
+ ...(flag.hiddenAliases ?? []).map((name) => ({ name, renamed: false }))
21375
+ ];
21376
+ }
21362
21377
  function trailingListField(commandSpec) {
21363
21378
  return Object.entries(commandSpec.flags ?? {}).find(([, flag]) => flag.trailing)?.[0];
21364
21379
  }
@@ -21475,6 +21490,24 @@ async function readArgumentSource(raw, flagName) {
21475
21490
  throw new SimApiError(`--${flagName} cannot read ${path}: ${error.message}${literalAtHint(error, path)}`, 0);
21476
21491
  }
21477
21492
  }
21493
+ function fileReferenceEntries(value, flagName) {
21494
+ const entries = value.startsWith("[") ? jsonStringArray(value) : value.includes(",") && !value.includes("/") ? value.split(",") : undefined;
21495
+ if (!entries)
21496
+ return [value];
21497
+ const trimmed = entries.map((entry) => entry.trim());
21498
+ if (trimmed.some((entry) => !entry)) {
21499
+ throw new SimApiError(`--${flagName} values cannot be empty: ${value}`, 0);
21500
+ }
21501
+ return trimmed;
21502
+ }
21503
+ function jsonStringArray(value) {
21504
+ try {
21505
+ const parsed = JSON.parse(value);
21506
+ return Array.isArray(parsed) && parsed.every((entry) => typeof entry === "string") ? parsed : undefined;
21507
+ } catch {
21508
+ return;
21509
+ }
21510
+ }
21478
21511
  function isManifestNoise(line) {
21479
21512
  const trimmed = line.trim();
21480
21513
  return trimmed === "" || trimmed.startsWith("#");
@@ -21543,7 +21576,8 @@ async function coerce(raw, field, flag, flagName) {
21543
21576
  if (raw === undefined)
21544
21577
  return;
21545
21578
  if (flag.list) {
21546
- const values = (await readListValues(raw, flagName, flag.manifest === true)).map((value) => flag.folderPath ? encodeFolderPath(value) : value);
21579
+ const listed = await readListValues(raw, flagName, flag.manifest === true);
21580
+ const values = (flag.fileReferences ? listed.flatMap((value) => fileReferenceEntries(value, flagName)) : listed).map((value) => flag.folderPath ? encodeFolderPath(value) : value);
21547
21581
  return field.kind === "string" ? values.join(",") : values;
21548
21582
  }
21549
21583
  if (flag.rowCap)
@@ -21797,7 +21831,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
21797
21831
  if (!flag.boolean || flag.negatable) {
21798
21832
  command.option(`--no-${name}`, `Send --${name} as false`);
21799
21833
  }
21800
- for (const previous of flag.renamedFrom ?? []) {
21834
+ for (const { name: previous } of otherSpellings(flag)) {
21801
21835
  command.addOption(new Option(`--${previous}`).hideHelp());
21802
21836
  if (!flag.boolean || flag.negatable)
21803
21837
  command.addOption(new Option(`--no-${previous}`).hideHelp());
@@ -21810,7 +21844,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
21810
21844
  const choices = flag.choices ?? descriptor.values;
21811
21845
  const literalNull = slot === "body" && !takesList && !wantsJson && !descriptor.nullable;
21812
21846
  const describe = `${documented}${takesList ? flag.manifest ? " (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)" : " (space-separated, or @path / @- with one value per line; @@value for a literal leading @)" : wantsJson ? " (JSON, or @path / @- to read a file or stdin)" : flag.textSource ? " (@path / @- reads a file or stdin verbatim, including trailing newlines; @@value for a literal leading @)" : ""}${descriptor.required ? flag.trailing ? " (required, or pass the values as arguments)" : " (required)" : ""}${literalNull ? literalNullHint(documented, name) : ""}`;
21813
- const renamedFrom = flag.renamedFrom ?? [];
21847
+ const hiddenNames = otherSpellings(flag).map(({ name }) => name);
21814
21848
  const option = new Option(`${short}--${name} ${placeholder}`, describe);
21815
21849
  if (flag.hidden)
21816
21850
  option.hideHelp();
@@ -21819,15 +21853,15 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
21819
21853
  if (descriptor.default !== undefined && field !== "limit") {
21820
21854
  option.default(undefined, String(descriptor.default));
21821
21855
  }
21822
- if (descriptor.required && renamedFrom.length === 0 && !flag.trailing) {
21856
+ if (descriptor.required && hiddenNames.length === 0 && !flag.trailing) {
21823
21857
  option.makeOptionMandatory();
21824
21858
  }
21825
21859
  command.addOption(option);
21826
- for (const previous of renamedFrom) {
21827
- const retired = new Option(`--${previous} ${placeholder}`).hideHelp();
21860
+ for (const previous of hiddenNames) {
21861
+ const hidden = new Option(`--${previous} ${placeholder}`).hideHelp();
21828
21862
  if (choices && !takesList)
21829
- retired.choices([...choices]);
21830
- command.addOption(retired);
21863
+ hidden.choices([...choices]);
21864
+ command.addOption(hidden);
21831
21865
  }
21832
21866
  }
21833
21867
  function addOperationOptions(command, operation, commandSpec, operationSpec) {
@@ -22063,19 +22097,18 @@ function assertSelectorIsUsable(operation, flags) {
22063
22097
  return;
22064
22098
  throw new SimApiError(given.length === 0 ? `--${first} or --${second} is required to choose the ${selector.noun}` : `--${first} and --${second} choose the ${selector.noun} two different ways; pass one, not both`, 0);
22065
22099
  }
22066
- function foldRenamedFlags(operation, commandSpec, flags) {
22100
+ function foldOtherSpellings(operation, commandSpec, flags) {
22067
22101
  for (const [field, flag] of Object.entries(commandSpec.flags ?? {})) {
22068
- if (!flag.renamedFrom?.length)
22069
- continue;
22070
22102
  const current = flagNameFor(operation, field);
22071
- for (const previous of flag.renamedFrom) {
22072
- const supplied = flags[camel(previous)];
22103
+ for (const { name, renamed } of otherSpellings(flag)) {
22104
+ const supplied = flags[camel(name)];
22073
22105
  if (supplied === undefined)
22074
22106
  continue;
22075
22107
  if (flags[camel(current)] !== undefined) {
22076
- throw new SimApiError(`--${previous} is the former name of --${current}; pass one, not both`, 0);
22108
+ throw new SimApiError(`--${name} is ${renamed ? "the former name" : "another spelling"} of --${current}; pass one, not both`, 0);
22077
22109
  }
22078
- warnRenamedFlag(previous, current);
22110
+ if (renamed)
22111
+ warnRenamedFlag(name, current);
22079
22112
  flags[camel(current)] = supplied;
22080
22113
  }
22081
22114
  }
@@ -22103,7 +22136,7 @@ async function executeOperation(operation, commandSpec, operationSpec, invocatio
22103
22136
  }
22104
22137
  requestFlags[camel(name)] = trailingValues;
22105
22138
  }
22106
- foldRenamedFlags(operation, commandSpec, requestFlags);
22139
+ foldOtherSpellings(operation, commandSpec, requestFlags);
22107
22140
  assertCapIsUsable(operation, requestFlags);
22108
22141
  assertSelectorIsUsable(operation, requestFlags);
22109
22142
  if (commandSpec.confirm && !requestFlags.yes && requestFlags.dryRun !== true) {
@@ -23057,7 +23090,7 @@ function isTerminalSafeContentType(contentType) {
23057
23090
  "image/svg+xml"
23058
23091
  ].includes(mediaType);
23059
23092
  }
23060
- async function downloadToOutput(connect, operation, pathParams, options, scope, requestInput = {}) {
23093
+ async function downloadToOutput(connect, operation, pathParams, options, scope, requestInput = {}, { metadataCommand } = {}) {
23061
23094
  const target = options.outputFile;
23062
23095
  const writesToStdout = target === undefined || target === "-";
23063
23096
  if (writesToStdout && options.force) {
@@ -23077,7 +23110,7 @@ async function downloadToOutput(connect, operation, pathParams, options, scope,
23077
23110
  const embedded = embedStore.getStore();
23078
23111
  if ((embedded || process.stdout.isTTY) && !isTerminalSafeContentType(contentType)) {
23079
23112
  await response.body.cancel();
23080
- throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23113
+ throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>${metadataCommand ? `, or run \`sim ${metadataCommand}\` for its metadata` : ""}.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23081
23114
  }
23082
23115
  await streamToStdout(response.body);
23083
23116
  return;
@@ -23107,7 +23140,7 @@ function attachProjectFileSnapshotExport(files) {
23107
23140
  }
23108
23141
  function attachFileGet(files) {
23109
23142
  const [command, connect] = apiCommand(files, "get", ["downloadFile"]);
23110
- command.argument("<fileId>", "File whose content to read").allowExcessArguments(false).description("Download a file’s content to stdout or a local file").option("-o, --output-file <path>", "Write content to a file instead of stdout").option("--force", "Overwrite --output-file if it already exists").action((fileId, options) => downloadToOutput(connect, "downloadFile", { fileId }, options, "workspace"));
23143
+ command.argument("<fileId>", "File whose content to read").allowExcessArguments(false).description("Download a file’s content to stdout or a local file").option("-o, --output-file <path>", "Write content to a file instead of stdout").option("--force", "Overwrite --output-file if it already exists").action((fileId, options) => downloadToOutput(connect, "downloadFile", { fileId }, options, "workspace", {}, { metadataCommand: `files describe ${fileId}` }));
23111
23144
  }
23112
23145
  function attachFileVersionDownload(versions) {
23113
23146
  const [command, connect] = apiCommand(versions, "download", ["downloadFileVersion"]);
@@ -23477,7 +23510,7 @@ function attachKnowledgeExport(knowledge) {
23477
23510
  const embedded = embedStore.getStore();
23478
23511
  if ((embedded || process.stdout.isTTY) && !isTerminalSafeContentType(contentType)) {
23479
23512
  await response.body.cancel();
23480
- throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23513
+ throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>, or run \`sim knowledge get ${knowledgeBaseId}\` for its metadata.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23481
23514
  }
23482
23515
  await streamToStdout(response.body);
23483
23516
  return;
@@ -34,6 +34,11 @@ export declare function isProfileWorkspacePath(commandSpec: CommandSpec, param:
34
34
  */
35
35
  export declare function cursorSlot(operationSpec: Pick<OperationSpec, 'query' | 'body'>): 'query' | 'body' | null;
36
36
  export declare function flagSpecFor(operation: V2OperationName, field: string): FlagSpec;
37
+ /** The undocumented spellings a flag also answers to: former names, then hidden aliases. */
38
+ export declare function otherSpellings(flag: FlagSpec): {
39
+ name: string;
40
+ renamed: boolean;
41
+ }[];
37
42
  /** The list field whose values may also follow the command as arguments, if any. */
38
43
  export declare function trailingListField(commandSpec: CommandSpec): string | undefined;
39
44
  /**
package/dist/runtime.js CHANGED
@@ -9807,7 +9807,11 @@ var V2_OPERATIONS = {
9807
9807
  summary: "Delete files",
9808
9808
  body: {
9809
9809
  workspaceId: { kind: "string", required: true, describe: "Workspace containing the files." },
9810
- fileIds: { kind: "array", required: true, describe: "File identifiers to delete." }
9810
+ fileIds: {
9811
+ kind: "array",
9812
+ required: true,
9813
+ describe: "Files to delete, each by identifier or by the VFS path of a live file: `files/<folder>/<name>`. Pass the id when two files in a folder have names that display alike. At most 100 entries may be paths."
9814
+ }
9811
9815
  }
9812
9816
  },
9813
9817
  bulkDeleteTables: {
@@ -19062,7 +19066,7 @@ var TARGET_FOLDER_PATH_FLAG = {
19062
19066
  describe: "Destination folder path; omit for root"
19063
19067
  };
19064
19068
  var LOG_LIST_FILTER_FLAGS = {
19065
- workflowIds: { name: "workflow", list: true },
19069
+ workflowIds: { name: "workflow", list: true, hiddenAliases: ["workflow-ids"] },
19066
19070
  folderPaths: FOLDER_PATHS_FLAG,
19067
19071
  triggers: { name: "trigger", list: true }
19068
19072
  };
@@ -19163,7 +19167,7 @@ var CLI_CONTRACT = {
19163
19167
  command: "tables rows batch-delete",
19164
19168
  describe: "Delete rows matching a filter, or an explicit list of ids",
19165
19169
  flags: {
19166
- rowIds: { name: "row", list: true },
19170
+ rowIds: { name: "row", list: true, hiddenAliases: ["row-ids"] },
19167
19171
  filter: { json: true, describe: TABLE_FILTER_HELP }
19168
19172
  },
19169
19173
  confirm: "This deletes every matching row and cannot be undone."
@@ -20267,7 +20271,12 @@ var CLI_CONTRACT = {
20267
20271
  command: "files batch-delete",
20268
20272
  describe: "Delete several files at once",
20269
20273
  flags: {
20270
- fileIds: { list: true, trailing: true }
20274
+ fileIds: {
20275
+ list: true,
20276
+ trailing: true,
20277
+ fileReferences: true,
20278
+ hiddenAliases: ["ids", "paths"]
20279
+ }
20271
20280
  },
20272
20281
  confirm: "This archives the listed files; restore them with `files restore`."
20273
20282
  },
@@ -21408,6 +21417,12 @@ var NUMERIC_KINDS = new Set(["number", "integer"]);
21408
21417
  function flagSpecFor(operation, field) {
21409
21418
  return CLI_CONTRACT[operation]?.flags?.[field] ?? {};
21410
21419
  }
21420
+ function otherSpellings(flag) {
21421
+ return [
21422
+ ...(flag.renamedFrom ?? []).map((name) => ({ name, renamed: true })),
21423
+ ...(flag.hiddenAliases ?? []).map((name) => ({ name, renamed: false }))
21424
+ ];
21425
+ }
21411
21426
  function trailingListField(commandSpec) {
21412
21427
  return Object.entries(commandSpec.flags ?? {}).find(([, flag]) => flag.trailing)?.[0];
21413
21428
  }
@@ -21524,6 +21539,24 @@ async function readArgumentSource(raw, flagName) {
21524
21539
  throw new SimApiError(`--${flagName} cannot read ${path}: ${error.message}${literalAtHint(error, path)}`, 0);
21525
21540
  }
21526
21541
  }
21542
+ function fileReferenceEntries(value, flagName) {
21543
+ const entries = value.startsWith("[") ? jsonStringArray(value) : value.includes(",") && !value.includes("/") ? value.split(",") : undefined;
21544
+ if (!entries)
21545
+ return [value];
21546
+ const trimmed = entries.map((entry) => entry.trim());
21547
+ if (trimmed.some((entry) => !entry)) {
21548
+ throw new SimApiError(`--${flagName} values cannot be empty: ${value}`, 0);
21549
+ }
21550
+ return trimmed;
21551
+ }
21552
+ function jsonStringArray(value) {
21553
+ try {
21554
+ const parsed = JSON.parse(value);
21555
+ return Array.isArray(parsed) && parsed.every((entry) => typeof entry === "string") ? parsed : undefined;
21556
+ } catch {
21557
+ return;
21558
+ }
21559
+ }
21527
21560
  function isManifestNoise(line) {
21528
21561
  const trimmed = line.trim();
21529
21562
  return trimmed === "" || trimmed.startsWith("#");
@@ -21592,7 +21625,8 @@ async function coerce(raw, field, flag, flagName) {
21592
21625
  if (raw === undefined)
21593
21626
  return;
21594
21627
  if (flag.list) {
21595
- const values = (await readListValues(raw, flagName, flag.manifest === true)).map((value) => flag.folderPath ? encodeFolderPath(value) : value);
21628
+ const listed = await readListValues(raw, flagName, flag.manifest === true);
21629
+ const values = (flag.fileReferences ? listed.flatMap((value) => fileReferenceEntries(value, flagName)) : listed).map((value) => flag.folderPath ? encodeFolderPath(value) : value);
21596
21630
  return field.kind === "string" ? values.join(",") : values;
21597
21631
  }
21598
21632
  if (flag.rowCap)
@@ -21846,7 +21880,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
21846
21880
  if (!flag.boolean || flag.negatable) {
21847
21881
  command.option(`--no-${name}`, `Send --${name} as false`);
21848
21882
  }
21849
- for (const previous of flag.renamedFrom ?? []) {
21883
+ for (const { name: previous } of otherSpellings(flag)) {
21850
21884
  command.addOption(new Option(`--${previous}`).hideHelp());
21851
21885
  if (!flag.boolean || flag.negatable)
21852
21886
  command.addOption(new Option(`--no-${previous}`).hideHelp());
@@ -21859,7 +21893,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
21859
21893
  const choices = flag.choices ?? descriptor.values;
21860
21894
  const literalNull = slot === "body" && !takesList && !wantsJson && !descriptor.nullable;
21861
21895
  const describe = `${documented}${takesList ? flag.manifest ? " (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)" : " (space-separated, or @path / @- with one value per line; @@value for a literal leading @)" : wantsJson ? " (JSON, or @path / @- to read a file or stdin)" : flag.textSource ? " (@path / @- reads a file or stdin verbatim, including trailing newlines; @@value for a literal leading @)" : ""}${descriptor.required ? flag.trailing ? " (required, or pass the values as arguments)" : " (required)" : ""}${literalNull ? literalNullHint(documented, name) : ""}`;
21862
- const renamedFrom = flag.renamedFrom ?? [];
21896
+ const hiddenNames = otherSpellings(flag).map(({ name }) => name);
21863
21897
  const option = new Option(`${short}--${name} ${placeholder}`, describe);
21864
21898
  if (flag.hidden)
21865
21899
  option.hideHelp();
@@ -21868,15 +21902,15 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
21868
21902
  if (descriptor.default !== undefined && field !== "limit") {
21869
21903
  option.default(undefined, String(descriptor.default));
21870
21904
  }
21871
- if (descriptor.required && renamedFrom.length === 0 && !flag.trailing) {
21905
+ if (descriptor.required && hiddenNames.length === 0 && !flag.trailing) {
21872
21906
  option.makeOptionMandatory();
21873
21907
  }
21874
21908
  command.addOption(option);
21875
- for (const previous of renamedFrom) {
21876
- const retired = new Option(`--${previous} ${placeholder}`).hideHelp();
21909
+ for (const previous of hiddenNames) {
21910
+ const hidden = new Option(`--${previous} ${placeholder}`).hideHelp();
21877
21911
  if (choices && !takesList)
21878
- retired.choices([...choices]);
21879
- command.addOption(retired);
21912
+ hidden.choices([...choices]);
21913
+ command.addOption(hidden);
21880
21914
  }
21881
21915
  }
21882
21916
  function addOperationOptions(command, operation, commandSpec, operationSpec) {
@@ -22112,19 +22146,18 @@ function assertSelectorIsUsable(operation, flags) {
22112
22146
  return;
22113
22147
  throw new SimApiError(given.length === 0 ? `--${first} or --${second} is required to choose the ${selector.noun}` : `--${first} and --${second} choose the ${selector.noun} two different ways; pass one, not both`, 0);
22114
22148
  }
22115
- function foldRenamedFlags(operation, commandSpec, flags) {
22149
+ function foldOtherSpellings(operation, commandSpec, flags) {
22116
22150
  for (const [field, flag] of Object.entries(commandSpec.flags ?? {})) {
22117
- if (!flag.renamedFrom?.length)
22118
- continue;
22119
22151
  const current = flagNameFor(operation, field);
22120
- for (const previous of flag.renamedFrom) {
22121
- const supplied = flags[camel(previous)];
22152
+ for (const { name, renamed } of otherSpellings(flag)) {
22153
+ const supplied = flags[camel(name)];
22122
22154
  if (supplied === undefined)
22123
22155
  continue;
22124
22156
  if (flags[camel(current)] !== undefined) {
22125
- throw new SimApiError(`--${previous} is the former name of --${current}; pass one, not both`, 0);
22157
+ throw new SimApiError(`--${name} is ${renamed ? "the former name" : "another spelling"} of --${current}; pass one, not both`, 0);
22126
22158
  }
22127
- warnRenamedFlag(previous, current);
22159
+ if (renamed)
22160
+ warnRenamedFlag(name, current);
22128
22161
  flags[camel(current)] = supplied;
22129
22162
  }
22130
22163
  }
@@ -22152,7 +22185,7 @@ async function executeOperation(operation, commandSpec, operationSpec, invocatio
22152
22185
  }
22153
22186
  requestFlags[camel(name)] = trailingValues;
22154
22187
  }
22155
- foldRenamedFlags(operation, commandSpec, requestFlags);
22188
+ foldOtherSpellings(operation, commandSpec, requestFlags);
22156
22189
  assertCapIsUsable(operation, requestFlags);
22157
22190
  assertSelectorIsUsable(operation, requestFlags);
22158
22191
  if (commandSpec.confirm && !requestFlags.yes && requestFlags.dryRun !== true) {
@@ -23106,7 +23139,7 @@ function isTerminalSafeContentType(contentType) {
23106
23139
  "image/svg+xml"
23107
23140
  ].includes(mediaType);
23108
23141
  }
23109
- async function downloadToOutput(connect, operation, pathParams, options, scope, requestInput = {}) {
23142
+ async function downloadToOutput(connect, operation, pathParams, options, scope, requestInput = {}, { metadataCommand } = {}) {
23110
23143
  const target = options.outputFile;
23111
23144
  const writesToStdout = target === undefined || target === "-";
23112
23145
  if (writesToStdout && options.force) {
@@ -23126,7 +23159,7 @@ async function downloadToOutput(connect, operation, pathParams, options, scope,
23126
23159
  const embedded = embedStore.getStore();
23127
23160
  if ((embedded || process.stdout.isTTY) && !isTerminalSafeContentType(contentType)) {
23128
23161
  await response.body.cancel();
23129
- throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23162
+ throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>${metadataCommand ? `, or run \`sim ${metadataCommand}\` for its metadata` : ""}.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23130
23163
  }
23131
23164
  await streamToStdout(response.body);
23132
23165
  return;
@@ -23156,7 +23189,7 @@ function attachProjectFileSnapshotExport(files) {
23156
23189
  }
23157
23190
  function attachFileGet(files) {
23158
23191
  const [command, connect] = apiCommand(files, "get", ["downloadFile"]);
23159
- command.argument("<fileId>", "File whose content to read").allowExcessArguments(false).description("Download a file’s content to stdout or a local file").option("-o, --output-file <path>", "Write content to a file instead of stdout").option("--force", "Overwrite --output-file if it already exists").action((fileId, options) => downloadToOutput(connect, "downloadFile", { fileId }, options, "workspace"));
23192
+ command.argument("<fileId>", "File whose content to read").allowExcessArguments(false).description("Download a file’s content to stdout or a local file").option("-o, --output-file <path>", "Write content to a file instead of stdout").option("--force", "Overwrite --output-file if it already exists").action((fileId, options) => downloadToOutput(connect, "downloadFile", { fileId }, options, "workspace", {}, { metadataCommand: `files describe ${fileId}` }));
23160
23193
  }
23161
23194
  function attachFileVersionDownload(versions) {
23162
23195
  const [command, connect] = apiCommand(versions, "download", ["downloadFileVersion"]);
@@ -23526,7 +23559,7 @@ function attachKnowledgeExport(knowledge) {
23526
23559
  const embedded = embedStore.getStore();
23527
23560
  if ((embedded || process.stdout.isTTY) && !isTerminalSafeContentType(contentType)) {
23528
23561
  await response.body.cancel();
23529
- throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23562
+ throw new SimApiError(embedded ? `Refusing to put ${contentType ?? "unknown content"} in a text result. Use --output-file <path>, or run \`sim knowledge get ${knowledgeBaseId}\` for its metadata.` : `Refusing to write ${contentType ?? "unknown content"} to an interactive terminal. Use --output-file <path> or pipe stdout.`, 0);
23530
23563
  }
23531
23564
  await streamToStdout(response.body);
23532
23565
  return;
@@ -26447,11 +26480,7 @@ async function runEmbeddedCli(argv, identity, options) {
26447
26480
  let exitCode = 0;
26448
26481
  try {
26449
26482
  identity.signal?.throwIfAborted();
26450
- const program = buildProgram({
26451
- hostCommands: false,
26452
- helpText: "The embedding application supplies authentication, endpoint and workspace scope."
26453
- });
26454
- configureEmbeddedOutput(program);
26483
+ const program = buildEmbeddedProgram({ writeOut: writeStdout, writeErr: writeStderr });
26455
26484
  await program.parseAsync(argv, { from: "user" });
26456
26485
  if (ctx.softExitCode !== undefined && ctx.softExitCode !== 0)
26457
26486
  exitCode = ctx.softExitCode;
@@ -26511,11 +26540,19 @@ function renderEmbeddedError(ctx, error) {
26511
26540
  ctx.stderr.diagnostic(`Error: ${sanitize(getErrorMessage(error))}`);
26512
26541
  return 1;
26513
26542
  }
26514
- function configureEmbeddedOutput(command) {
26515
- command.configureOutput({ writeOut: writeStdout, writeErr: writeStderr });
26543
+ function buildEmbeddedProgram(output) {
26544
+ const program = buildProgram({
26545
+ hostCommands: false,
26546
+ helpText: "The embedding application supplies authentication, endpoint and workspace scope."
26547
+ });
26548
+ configureEmbeddedOutput(program, output);
26549
+ return program;
26550
+ }
26551
+ function configureEmbeddedOutput(command, output) {
26552
+ command.configureOutput(output);
26516
26553
  command.exitOverride();
26517
26554
  for (const child of command.commands)
26518
- configureEmbeddedOutput(child);
26555
+ configureEmbeddedOutput(child, output);
26519
26556
  }
26520
26557
  // src/terminal.ts
26521
26558
  function explainFailure(error, program) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.2.20",
3
+ "version": "2.2.21-preview.260.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "imports": {