sim 2.2.9-preview.208.1 → 2.2.9-preview.210.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.
package/dist/index.js CHANGED
@@ -17328,6 +17328,13 @@ var V2_OPERATIONS = {
17328
17328
  }
17329
17329
  };
17330
17330
 
17331
+ // src/runtime/called-operations.ts
17332
+ var CALLED_OPERATIONS = new WeakMap;
17333
+ function callsOperations(command, operations) {
17334
+ CALLED_OPERATIONS.set(command, operations);
17335
+ return command;
17336
+ }
17337
+
17331
17338
  // src/commands/auth.ts
17332
17339
  var MAX_INTERACTIVE_WORKSPACES = 1000;
17333
17340
  function openBrowser(url) {
@@ -17848,7 +17855,7 @@ function presentVerification(verification) {
17848
17855
  }
17849
17856
  }
17850
17857
  function whoamiCommand() {
17851
- return new Command("whoami").description("Show the resolved profile, where each setting came from, and whether it works").option("--no-verify", "Skip the API check and only print the resolved settings").action(async (options, command) => {
17858
+ const whoami = new Command("whoami").description("Show the resolved profile, where each setting came from, and whether it works").option("--no-verify", "Skip the API check and only print the resolved settings").action(async (options, command) => {
17852
17859
  const { client, profile } = clientFrom(command);
17853
17860
  const { sources } = profile;
17854
17861
  const authentication = presentAuthentication(sources.credential);
@@ -17897,6 +17904,7 @@ function whoamiCommand() {
17897
17904
  if (exitCode !== 0)
17898
17905
  setSoftExitCode(exitCode);
17899
17906
  });
17907
+ return callsOperations(whoami, ["getMeta", "getWorkspace"]);
17900
17908
  }
17901
17909
  var PROFILE_COLUMNS = [
17902
17910
  { header: "", value: (row) => row.active ? styles3().green("*") : " " },
@@ -21295,7 +21303,7 @@ var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
21295
21303
  function looksLikeAnId(token) {
21296
21304
  return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
21297
21305
  }
21298
- function addArgumentExamples(command) {
21306
+ function addParseErrorGuidance(command) {
21299
21307
  const outputError = command.configureOutput().outputError;
21300
21308
  if (!outputError)
21301
21309
  throw new Error("Commander output formatter is not configured");
@@ -21309,12 +21317,16 @@ function addArgumentExamples(command) {
21309
21317
  `);
21310
21318
  return;
21311
21319
  }
21312
- if (command.registeredArguments.length === 0)
21313
- return;
21314
21320
  const token = UNKNOWN_OPTION_TOKEN.exec(message)?.[1];
21315
- if (!token || !looksLikeAnId(token))
21321
+ if (!token)
21316
21322
  return;
21317
- write(`Example: ${commandPath(command)} -- ${token}
21323
+ if (looksLikeAnId(token) && command.registeredArguments.length > 0) {
21324
+ write(`Example: ${commandPath(command)} -- ${token}
21325
+ `);
21326
+ return;
21327
+ }
21328
+ const flags = command.options.filter((option) => !option.hidden).map((option) => option.flags);
21329
+ write(`Options for ${commandPath(command)}: ${flags.join(", ")}
21318
21330
  `);
21319
21331
  }
21320
21332
  });
@@ -21441,7 +21453,7 @@ function configureOperation(command, operation, spec) {
21441
21453
  return command;
21442
21454
  }
21443
21455
  function buildLeaf(operation, spec, leafName) {
21444
- return addArgumentExamples(configureOperation(new Command(leafName), operation, spec));
21456
+ return addParseErrorGuidance(configureOperation(new Command(leafName), operation, spec));
21445
21457
  }
21446
21458
  function addRenamedCommand(groups, operation, spec, from, to) {
21447
21459
  const segments = from.split(" ");
@@ -21747,7 +21759,7 @@ function ignoreBrokenPipe(stream) {
21747
21759
  };
21748
21760
  }
21749
21761
  function attachChat(program) {
21750
- program.command("chat").description("Ask Sim and print the reply").argument("<message>", "What to ask Sim").allowExcessArguments(false).option("-c, --conversation <id>", "Continue the conversation with this ID").addHelpText("after", `
21762
+ const chat = program.command("chat").description("Ask Sim and print the reply").argument("<message>", "What to ask Sim").allowExcessArguments(false).option("-c, --conversation <id>", "Continue the conversation with this ID").addHelpText("after", `
21751
21763
  Each turn prints the reply on stdout and the conversation ID on stderr; pass
21752
21764
  that ID back with -c to continue the same conversation. With --output json or
21753
21765
  yaml the reply is not streamed — the finished result is printed as one
@@ -21813,6 +21825,7 @@ Examples:
21813
21825
  restorePipeHandling?.();
21814
21826
  }
21815
21827
  });
21828
+ callsOperations(chat, ["chat"]);
21816
21829
  }
21817
21830
 
21818
21831
  // src/commands/protocol/files-get.ts
@@ -22029,7 +22042,8 @@ function attachFileGet(files) {
22029
22042
  files.command("get").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, command) => downloadToOutput(command, V2_OPERATIONS.downloadFile, { fileId }, options));
22030
22043
  }
22031
22044
  function attachFileVersionDownload(versions) {
22032
- versions.command("download").argument("<fileId>", "File identifier.").argument("<version>", "Version number.").allowExcessArguments(false).description("Download the content of one version of a 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, version, options, command) => downloadToOutput(command, V2_OPERATIONS.downloadFileVersion, { fileId, version }, options));
22045
+ const download = versions.command("download").argument("<fileId>", "File identifier.").argument("<version>", "Version number.").allowExcessArguments(false).description("Download the content of one version of a 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, version, options, command) => downloadToOutput(command, V2_OPERATIONS.downloadFileVersion, { fileId, version }, options));
22046
+ callsOperations(download, ["downloadFileVersion"]);
22033
22047
  }
22034
22048
 
22035
22049
  // src/transfer/upload-session.ts
@@ -0,0 +1,11 @@
1
+ import type { Command } from 'commander';
2
+ import type { V2OperationName } from '../generated/v2-api';
3
+ /**
4
+ * Records the v2 operations a hand-written command calls.
5
+ *
6
+ * A generated command is one operation and the command inventory finds it by path. A
7
+ * hand-written one is opaque until it says what it calls, and the inventory needs that
8
+ * to describe it truthfully, such as whether every call is open to a Mothership caller.
9
+ */
10
+ export declare function callsOperations(command: Command, operations: readonly V2OperationName[]): Command;
11
+ export declare function calledOperations(command: Command): readonly V2OperationName[] | undefined;
package/dist/runtime.js CHANGED
@@ -17377,6 +17377,13 @@ var V2_OPERATIONS = {
17377
17377
  }
17378
17378
  };
17379
17379
 
17380
+ // src/runtime/called-operations.ts
17381
+ var CALLED_OPERATIONS = new WeakMap;
17382
+ function callsOperations(command, operations) {
17383
+ CALLED_OPERATIONS.set(command, operations);
17384
+ return command;
17385
+ }
17386
+
17380
17387
  // src/commands/auth.ts
17381
17388
  var MAX_INTERACTIVE_WORKSPACES = 1000;
17382
17389
  function openBrowser(url) {
@@ -17897,7 +17904,7 @@ function presentVerification(verification) {
17897
17904
  }
17898
17905
  }
17899
17906
  function whoamiCommand() {
17900
- return new Command("whoami").description("Show the resolved profile, where each setting came from, and whether it works").option("--no-verify", "Skip the API check and only print the resolved settings").action(async (options, command) => {
17907
+ const whoami = new Command("whoami").description("Show the resolved profile, where each setting came from, and whether it works").option("--no-verify", "Skip the API check and only print the resolved settings").action(async (options, command) => {
17901
17908
  const { client, profile } = clientFrom(command);
17902
17909
  const { sources } = profile;
17903
17910
  const authentication = presentAuthentication(sources.credential);
@@ -17946,6 +17953,7 @@ function whoamiCommand() {
17946
17953
  if (exitCode !== 0)
17947
17954
  setSoftExitCode(exitCode);
17948
17955
  });
17956
+ return callsOperations(whoami, ["getMeta", "getWorkspace"]);
17949
17957
  }
17950
17958
  var PROFILE_COLUMNS = [
17951
17959
  { header: "", value: (row) => row.active ? styles3().green("*") : " " },
@@ -21344,7 +21352,7 @@ var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
21344
21352
  function looksLikeAnId(token) {
21345
21353
  return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
21346
21354
  }
21347
- function addArgumentExamples(command) {
21355
+ function addParseErrorGuidance(command) {
21348
21356
  const outputError = command.configureOutput().outputError;
21349
21357
  if (!outputError)
21350
21358
  throw new Error("Commander output formatter is not configured");
@@ -21358,12 +21366,16 @@ function addArgumentExamples(command) {
21358
21366
  `);
21359
21367
  return;
21360
21368
  }
21361
- if (command.registeredArguments.length === 0)
21362
- return;
21363
21369
  const token = UNKNOWN_OPTION_TOKEN.exec(message)?.[1];
21364
- if (!token || !looksLikeAnId(token))
21370
+ if (!token)
21365
21371
  return;
21366
- write(`Example: ${commandPath(command)} -- ${token}
21372
+ if (looksLikeAnId(token) && command.registeredArguments.length > 0) {
21373
+ write(`Example: ${commandPath(command)} -- ${token}
21374
+ `);
21375
+ return;
21376
+ }
21377
+ const flags = command.options.filter((option) => !option.hidden).map((option) => option.flags);
21378
+ write(`Options for ${commandPath(command)}: ${flags.join(", ")}
21367
21379
  `);
21368
21380
  }
21369
21381
  });
@@ -21490,7 +21502,7 @@ function configureOperation(command, operation, spec) {
21490
21502
  return command;
21491
21503
  }
21492
21504
  function buildLeaf(operation, spec, leafName) {
21493
- return addArgumentExamples(configureOperation(new Command(leafName), operation, spec));
21505
+ return addParseErrorGuidance(configureOperation(new Command(leafName), operation, spec));
21494
21506
  }
21495
21507
  function addRenamedCommand(groups, operation, spec, from, to) {
21496
21508
  const segments = from.split(" ");
@@ -21796,7 +21808,7 @@ function ignoreBrokenPipe(stream) {
21796
21808
  };
21797
21809
  }
21798
21810
  function attachChat(program) {
21799
- program.command("chat").description("Ask Sim and print the reply").argument("<message>", "What to ask Sim").allowExcessArguments(false).option("-c, --conversation <id>", "Continue the conversation with this ID").addHelpText("after", `
21811
+ const chat = program.command("chat").description("Ask Sim and print the reply").argument("<message>", "What to ask Sim").allowExcessArguments(false).option("-c, --conversation <id>", "Continue the conversation with this ID").addHelpText("after", `
21800
21812
  Each turn prints the reply on stdout and the conversation ID on stderr; pass
21801
21813
  that ID back with -c to continue the same conversation. With --output json or
21802
21814
  yaml the reply is not streamed — the finished result is printed as one
@@ -21862,6 +21874,7 @@ Examples:
21862
21874
  restorePipeHandling?.();
21863
21875
  }
21864
21876
  });
21877
+ callsOperations(chat, ["chat"]);
21865
21878
  }
21866
21879
 
21867
21880
  // src/commands/protocol/files-get.ts
@@ -22078,7 +22091,8 @@ function attachFileGet(files) {
22078
22091
  files.command("get").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, command) => downloadToOutput(command, V2_OPERATIONS.downloadFile, { fileId }, options));
22079
22092
  }
22080
22093
  function attachFileVersionDownload(versions) {
22081
- versions.command("download").argument("<fileId>", "File identifier.").argument("<version>", "Version number.").allowExcessArguments(false).description("Download the content of one version of a 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, version, options, command) => downloadToOutput(command, V2_OPERATIONS.downloadFileVersion, { fileId, version }, options));
22094
+ const download = versions.command("download").argument("<fileId>", "File identifier.").argument("<version>", "Version number.").allowExcessArguments(false).description("Download the content of one version of a 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, version, options, command) => downloadToOutput(command, V2_OPERATIONS.downloadFileVersion, { fileId, version }, options));
22095
+ callsOperations(download, ["downloadFileVersion"]);
22082
22096
  }
22083
22097
 
22084
22098
  // src/transfer/upload-session.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.2.9-preview.208.1",
3
+ "version": "2.2.9-preview.210.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "imports": {