@nouter/platform-cli 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +14 -0
  2. package/dist/index.js +274 -41
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -11,6 +11,20 @@ Repository: <https://github.com/Nouter-ai/platform>
11
11
 
12
12
  ## Install
13
13
 
14
+ If the repository keeps the `apply` documents (agents and environments as
15
+ files), add the CLI as a devDependency and commit the lockfile: everyone and the
16
+ CI run the same version.
17
+
18
+ ```bash
19
+ npm i -D @nouter/platform-cli
20
+ npx nouter-platform apply -f ./resources --dry-run
21
+ ```
22
+
23
+ With pnpm, `pnpm add -D @nouter/platform-cli` and
24
+ `pnpm exec nouter-platform apply -f ./resources --dry-run` do the same.
25
+
26
+ The global install is for a one-off use outside a repo:
27
+
14
28
  ```bash
15
29
  npm i -g @nouter/platform-cli
16
30
  ```
package/dist/index.js CHANGED
@@ -7384,7 +7384,8 @@ import {
7384
7384
  writeSync
7385
7385
  } from "node:fs";
7386
7386
  import { homedir, hostname } from "node:os";
7387
- import { join as join2 } from "node:path";
7387
+ import { dirname, join as join2 } from "node:path";
7388
+ import { fileURLToPath } from "node:url";
7388
7389
  import {
7389
7390
  NouterPlatform
7390
7391
  } from "@nouter/platform";
@@ -8248,6 +8249,167 @@ function formatApplyResults(results) {
8248
8249
  return lines;
8249
8250
  }
8250
8251
 
8252
+ // src/commands.ts
8253
+ var COMMANDS = [
8254
+ {
8255
+ path: "login",
8256
+ summary: "Store an API key (from stdin) or log in through the browser",
8257
+ values: [],
8258
+ booleans: ["--api-key", "--browser"],
8259
+ positionals: []
8260
+ },
8261
+ {
8262
+ path: "logout",
8263
+ summary: "Remove the stored API key from this machine",
8264
+ values: [],
8265
+ booleans: [],
8266
+ positionals: []
8267
+ },
8268
+ {
8269
+ path: "whoami",
8270
+ summary: "Show the organization, the role and the scopes",
8271
+ values: [],
8272
+ booleans: [],
8273
+ positionals: []
8274
+ },
8275
+ {
8276
+ path: "auth status",
8277
+ summary: "Show which credential the CLI would use, without printing it",
8278
+ values: [],
8279
+ booleans: [],
8280
+ positionals: []
8281
+ },
8282
+ {
8283
+ path: "version",
8284
+ summary: "Show the CLI version and the version of the SDK it ships",
8285
+ values: [],
8286
+ booleans: [],
8287
+ positionals: []
8288
+ },
8289
+ {
8290
+ path: "agents list",
8291
+ summary: "List every agent",
8292
+ values: [],
8293
+ booleans: ["--json"],
8294
+ positionals: []
8295
+ },
8296
+ {
8297
+ path: "agents get",
8298
+ summary: "Show one agent by id",
8299
+ values: [],
8300
+ booleans: [],
8301
+ positionals: ["<agent-id>"]
8302
+ },
8303
+ {
8304
+ path: "environments list",
8305
+ summary: "List every environment",
8306
+ values: [],
8307
+ booleans: ["--json"],
8308
+ positionals: []
8309
+ },
8310
+ {
8311
+ path: "environments get",
8312
+ summary: "Show one environment by id",
8313
+ values: [],
8314
+ booleans: [],
8315
+ positionals: ["<environment-id>"]
8316
+ },
8317
+ {
8318
+ path: "service-accounts list",
8319
+ summary: "List the service accounts",
8320
+ values: [],
8321
+ booleans: ["--include-archived", "--json"],
8322
+ positionals: []
8323
+ },
8324
+ {
8325
+ path: "service-accounts create",
8326
+ summary: "Create a service account",
8327
+ values: ["--name", "--organization-role"],
8328
+ booleans: ["--json"],
8329
+ positionals: []
8330
+ },
8331
+ {
8332
+ path: "service-accounts archive",
8333
+ summary: "Archive a service account by id",
8334
+ values: [],
8335
+ booleans: [],
8336
+ positionals: ["<service-account-id>"]
8337
+ },
8338
+ {
8339
+ path: "federation issuers list",
8340
+ summary: "List the federation issuers",
8341
+ values: [],
8342
+ booleans: ["--include-archived", "--json"],
8343
+ positionals: []
8344
+ },
8345
+ {
8346
+ path: "federation issuers create",
8347
+ summary: "Create a federation issuer",
8348
+ values: ["--name", "--provider", "--issuer-url", "--jwks-url", "--check-jti", "--max-token-lifetime"],
8349
+ booleans: ["--json"],
8350
+ positionals: []
8351
+ },
8352
+ {
8353
+ path: "federation issuers archive",
8354
+ summary: "Archive a federation issuer by id",
8355
+ values: [],
8356
+ booleans: [],
8357
+ positionals: ["<issuer-id>"]
8358
+ },
8359
+ {
8360
+ path: "federation rules list",
8361
+ summary: "List the federation rules, optionally by issuer",
8362
+ values: ["--issuer"],
8363
+ booleans: ["--include-archived", "--json"],
8364
+ positionals: []
8365
+ },
8366
+ {
8367
+ path: "federation rules create",
8368
+ summary: "Create a federation rule",
8369
+ values: [
8370
+ "--name",
8371
+ "--issuer",
8372
+ "--service-account",
8373
+ "--subject-prefix",
8374
+ "--audience",
8375
+ "--claim",
8376
+ "--workspace",
8377
+ "--scopes",
8378
+ "--token-lifetime"
8379
+ ],
8380
+ booleans: ["--all-workspaces", "--json"],
8381
+ positionals: []
8382
+ },
8383
+ {
8384
+ path: "federation rules archive",
8385
+ summary: "Archive a federation rule by id",
8386
+ values: [],
8387
+ booleans: [],
8388
+ positionals: ["<rule-id>"]
8389
+ },
8390
+ {
8391
+ path: "federation token",
8392
+ summary: "Exchange the federated identity for a platform access token",
8393
+ values: [],
8394
+ booleans: ["--json"],
8395
+ positionals: []
8396
+ },
8397
+ {
8398
+ path: "apply",
8399
+ summary: "Apply agents and environments from files",
8400
+ values: ["--file"],
8401
+ booleans: ["--dry-run", "--rotate-secrets"],
8402
+ positionals: [],
8403
+ shortValues: ["-f"]
8404
+ }
8405
+ ];
8406
+ var BY_PATH = new Map(COMMANDS.map((command) => [command.path, command]));
8407
+ function specFor(path) {
8408
+ const spec = BY_PATH.get(path);
8409
+ if (spec === void 0) throw new Error(`Unknown command path: ${path}`);
8410
+ return spec;
8411
+ }
8412
+
8251
8413
  // src/identity-token.ts
8252
8414
  import { readFileSync as readFileSync2 } from "node:fs";
8253
8415
  var IdentityTokenError = class extends Error {
@@ -8290,6 +8452,26 @@ function createIdentityTokenReader(source, read = (path) => readFileSync2(path,
8290
8452
  };
8291
8453
  }
8292
8454
 
8455
+ // src/non-api-host.ts
8456
+ function hostOf(url) {
8457
+ try {
8458
+ return new URL(url).host;
8459
+ } catch {
8460
+ return url;
8461
+ }
8462
+ }
8463
+ function notTheApiMessage(url, response) {
8464
+ const status = response.status;
8465
+ if (status >= 500) return null;
8466
+ const contentType = (response.headers.get("content-type") ?? "").trim();
8467
+ const mediaType = contentType.toLowerCase();
8468
+ const isRedirect = status >= 300 && status < 400;
8469
+ const isHtml = mediaType.startsWith("text/html");
8470
+ const followedToNonJson = response.redirected && !mediaType.includes("application/json");
8471
+ if (!isRedirect && !isHtml && !followedToNonJson) return null;
8472
+ return `this host is not the API: ${hostOf(url)} responded ${status} ${contentType || "(no content-type)"}`;
8473
+ }
8474
+
8293
8475
  // src/federation.ts
8294
8476
  var FederationError = class extends Error {
8295
8477
  constructor(message) {
@@ -8352,11 +8534,16 @@ async function exchange(baseUrl, settings, assertion, fetch, timeoutMs) {
8352
8534
  ...settings.serviceAccountId !== void 0 && { service_account_id: settings.serviceAccountId },
8353
8535
  ...settings.workspaceId !== void 0 && { workspace_id: settings.workspaceId }
8354
8536
  }),
8355
- signal: AbortSignal.timeout(timeoutMs)
8537
+ signal: AbortSignal.timeout(timeoutMs),
8538
+ // La aserción va en el cuerpo: si el host redirige (la consola detrás de un IdP), seguir el 3xx la llevaría a
8539
+ // otro origen. Se corta acá con el mismo mensaje que el cliente.
8540
+ redirect: "manual"
8356
8541
  });
8357
8542
  } catch {
8358
8543
  throw new FederationError("The federation exchange failed (network error).");
8359
8544
  }
8545
+ const notTheApi = notTheApiMessage(`${baseUrl}/v1/oauth/token`, response);
8546
+ if (notTheApi !== null) throw new FederationError(notTheApi);
8360
8547
  if (response.status === 401) {
8361
8548
  throw new FederationError("Authentication failed");
8362
8549
  }
@@ -8550,7 +8737,9 @@ async function readBody(request) {
8550
8737
  }
8551
8738
 
8552
8739
  // src/index.ts
8553
- var USER_AGENT = "NouterPlatform-CLI/0.1";
8740
+ function cliUserAgent() {
8741
+ return `nouter-platform-cli/${cliVersion()} node/${process.versions.node}`;
8742
+ }
8554
8743
  var REQUEST_TIMEOUT_MS = 3e4;
8555
8744
  var CONFIG_DIRECTORY = "nouter-platform";
8556
8745
  var CONFIG_FILE = "config.json";
@@ -8782,11 +8971,18 @@ async function resolveAuth(deps) {
8782
8971
  }
8783
8972
  return { baseUrl: storedBaseUrl, credential: stored.apiKey, transport: "api-key" };
8784
8973
  }
8974
+ var notTheApiMiddleware = async (request, next) => {
8975
+ const response = await next({ ...request, redirect: "manual" });
8976
+ const message = notTheApiMessage(request.url, response);
8977
+ if (message !== null) throw new CliError(message);
8978
+ return response;
8979
+ };
8785
8980
  function clientFor(auth, deps, options = {}) {
8786
8981
  const common = {
8787
8982
  baseURL: auth.baseUrl,
8788
8983
  fetch: deps.fetch,
8789
- userAgent: USER_AGENT,
8984
+ userAgent: cliUserAgent(),
8985
+ middleware: [notTheApiMiddleware],
8790
8986
  ...options.maxRetries !== void 0 && { maxRetries: options.maxRetries }
8791
8987
  };
8792
8988
  return auth.transport === "bearer" ? new NouterPlatform({ ...common, authToken: auth.credential }) : new NouterPlatform({ ...common, apiKey: auth.credential });
@@ -8802,6 +8998,7 @@ async function fetchMe(auth, deps) {
8802
8998
  signal: AbortSignal.timeout(deps.requestTimeoutMs)
8803
8999
  });
8804
9000
  } catch (error) {
9001
+ if (error instanceof CliError) throw error;
8805
9002
  throw new CliError(`Could not read the account: ${describeApiFailure(error)}`);
8806
9003
  }
8807
9004
  }
@@ -8865,14 +9062,15 @@ async function loginWithBrowser(deps) {
8865
9062
  }
8866
9063
  function login(argv, deps) {
8867
9064
  const rejectedValue = argv.some((argument) => argument.startsWith("--api-key="));
8868
- const unknown = argv.filter((argument) => argument !== "--api-key" && argument !== "--browser");
9065
+ const allowed = MANUAL_FLAGS.login;
9066
+ const unknown = argv.filter((argument) => !allowed.includes(argument));
8869
9067
  if (rejectedValue || unknown.length > 0) {
8870
9068
  throw new CliError(
8871
9069
  "The API key must come from stdin: use `nouter-platform login --api-key` with no value."
8872
9070
  );
8873
9071
  }
8874
- const withApiKey = argv.includes("--api-key");
8875
- const withBrowser = argv.includes("--browser");
9072
+ const withApiKey = argv.includes(allowed[0]);
9073
+ const withBrowser = argv.includes(allowed[1]);
8876
9074
  if (withApiKey && withBrowser) {
8877
9075
  throw new CliError("Choose one way to log in: `--api-key` (from stdin) or `--browser`.");
8878
9076
  }
@@ -8987,6 +9185,14 @@ async function getEnvironment(id, deps) {
8987
9185
  throw new CliError(`Could not read environment ${id}: ${describeApiFailure(error)}`);
8988
9186
  }
8989
9187
  }
9188
+ var MANUAL_FLAGS = {
9189
+ login: ["--api-key", "--browser"],
9190
+ "agents list": ["--json"],
9191
+ "agents get": [],
9192
+ "environments list": ["--json"],
9193
+ "environments get": [],
9194
+ apply: ["--file", "-f", "--dry-run", "--rotate-secrets"]
9195
+ };
8990
9196
  function parseOptions(args, spec) {
8991
9197
  const values = /* @__PURE__ */ new Map();
8992
9198
  const booleans = /* @__PURE__ */ new Set();
@@ -9066,7 +9272,7 @@ function matchSummary(match) {
9066
9272
  async function serviceAccountsCommand(argv, deps) {
9067
9273
  const [subcommand, ...args] = argv;
9068
9274
  if (subcommand === "list") {
9069
- const options = parseOptions(args, { values: [], booleans: ["--include-archived", "--json"] });
9275
+ const options = parseOptions(args, specFor("service-accounts list"));
9070
9276
  if (options.positionals.length > 0) throw new CliError("Usage: nouter-platform service-accounts list [--include-archived] [--json]");
9071
9277
  const auth = await resolveAuth(deps);
9072
9278
  try {
@@ -9103,7 +9309,7 @@ async function serviceAccountsCommand(argv, deps) {
9103
9309
  }
9104
9310
  }
9105
9311
  if (subcommand === "create") {
9106
- const options = parseOptions(args, { values: ["--name", "--organization-role"], booleans: ["--json"] });
9312
+ const options = parseOptions(args, specFor("service-accounts create"));
9107
9313
  const name = requiredOption(options, "--name");
9108
9314
  const role = requiredOption(options, "--organization-role");
9109
9315
  if (role !== "developer" && role !== "admin") {
@@ -9125,7 +9331,7 @@ async function serviceAccountsCommand(argv, deps) {
9125
9331
  }
9126
9332
  }
9127
9333
  if (subcommand === "archive") {
9128
- const options = parseOptions(args, { values: [], booleans: [] });
9334
+ const options = parseOptions(args, specFor("service-accounts archive"));
9129
9335
  const id = options.positionals[0];
9130
9336
  if (id === void 0 || options.positionals.length > 1) {
9131
9337
  throw new CliError("Usage: nouter-platform service-accounts archive <service-account-id>");
@@ -9148,7 +9354,7 @@ async function serviceAccountsCommand(argv, deps) {
9148
9354
  async function federationIssuersCommand(argv, deps) {
9149
9355
  const [subcommand, ...args] = argv;
9150
9356
  if (subcommand === "list") {
9151
- const options = parseOptions(args, { values: [], booleans: ["--include-archived", "--json"] });
9357
+ const options = parseOptions(args, specFor("federation issuers list"));
9152
9358
  if (options.positionals.length > 0) throw new CliError("Usage: nouter-platform federation issuers list [--include-archived] [--json]");
9153
9359
  const auth = await resolveAuth(deps);
9154
9360
  try {
@@ -9186,10 +9392,7 @@ async function federationIssuersCommand(argv, deps) {
9186
9392
  }
9187
9393
  }
9188
9394
  if (subcommand === "create") {
9189
- const options = parseOptions(args, {
9190
- values: ["--name", "--provider", "--issuer-url", "--jwks-url", "--check-jti", "--max-token-lifetime"],
9191
- booleans: ["--json"]
9192
- });
9395
+ const options = parseOptions(args, specFor("federation issuers create"));
9193
9396
  const name = requiredOption(options, "--name");
9194
9397
  const provider = requiredOption(options, "--provider");
9195
9398
  if (provider !== "github" && provider !== "gcp" && provider !== "aws" && provider !== "custom") {
@@ -9219,7 +9422,7 @@ async function federationIssuersCommand(argv, deps) {
9219
9422
  }
9220
9423
  }
9221
9424
  if (subcommand === "archive") {
9222
- const options = parseOptions(args, { values: [], booleans: [] });
9425
+ const options = parseOptions(args, specFor("federation issuers archive"));
9223
9426
  const id = options.positionals[0];
9224
9427
  if (id === void 0 || options.positionals.length > 1) {
9225
9428
  throw new CliError("Usage: nouter-platform federation issuers archive <issuer-id>");
@@ -9242,10 +9445,7 @@ async function federationIssuersCommand(argv, deps) {
9242
9445
  async function federationRulesCommand(argv, deps) {
9243
9446
  const [subcommand, ...args] = argv;
9244
9447
  if (subcommand === "list") {
9245
- const options = parseOptions(args, {
9246
- values: ["--issuer"],
9247
- booleans: ["--include-archived", "--json"]
9248
- });
9448
+ const options = parseOptions(args, specFor("federation rules list"));
9249
9449
  if (options.positionals.length > 0) {
9250
9450
  throw new CliError("Usage: nouter-platform federation rules list [--issuer <issuer-id>] [--include-archived] [--json]");
9251
9451
  }
@@ -9288,20 +9488,7 @@ async function federationRulesCommand(argv, deps) {
9288
9488
  }
9289
9489
  }
9290
9490
  if (subcommand === "create") {
9291
- const options = parseOptions(args, {
9292
- values: [
9293
- "--name",
9294
- "--issuer",
9295
- "--service-account",
9296
- "--subject-prefix",
9297
- "--audience",
9298
- "--claim",
9299
- "--workspace",
9300
- "--scopes",
9301
- "--token-lifetime"
9302
- ],
9303
- booleans: ["--all-workspaces", "--json"]
9304
- });
9491
+ const options = parseOptions(args, specFor("federation rules create"));
9305
9492
  const name = requiredOption(options, "--name");
9306
9493
  const issuerId = requiredOption(options, "--issuer");
9307
9494
  const serviceAccountId = requiredOption(options, "--service-account");
@@ -9358,7 +9545,7 @@ async function federationRulesCommand(argv, deps) {
9358
9545
  }
9359
9546
  }
9360
9547
  if (subcommand === "archive") {
9361
- const options = parseOptions(args, { values: [], booleans: [] });
9548
+ const options = parseOptions(args, specFor("federation rules archive"));
9362
9549
  const id = options.positionals[0];
9363
9550
  if (id === void 0 || options.positionals.length > 1) {
9364
9551
  throw new CliError("Usage: nouter-platform federation rules archive <rule-id>");
@@ -9379,7 +9566,7 @@ async function federationRulesCommand(argv, deps) {
9379
9566
  return usageError("federation rules list|create|archive", deps);
9380
9567
  }
9381
9568
  async function federationTokenCommand(argv, deps) {
9382
- const options = parseOptions(argv, { values: [], booleans: ["--json"] });
9569
+ const options = parseOptions(argv, specFor("federation token"));
9383
9570
  if (options.positionals.length > 0) throw new CliError("Usage: nouter-platform federation token [--json]");
9384
9571
  const settings = federationSettingsOrNull();
9385
9572
  if (settings === null) {
@@ -9472,16 +9659,17 @@ async function applyCommand(argv, deps) {
9472
9659
  const inputs = [];
9473
9660
  let dryRun = false;
9474
9661
  let rotateSecrets = false;
9662
+ const [fileFlag, shortFileFlag, dryRunFlag, rotateSecretsFlag] = MANUAL_FLAGS.apply;
9475
9663
  for (let index = 0; index < argv.length; index += 1) {
9476
9664
  const argument = argv[index];
9477
- if (argument === "-f" || argument === "--file") {
9665
+ if (argument === shortFileFlag || argument === fileFlag) {
9478
9666
  const input = argv[index + 1];
9479
9667
  if (input === void 0 || input.startsWith("-")) return applyUsage(deps);
9480
9668
  inputs.push(input);
9481
9669
  index += 1;
9482
- } else if (argument === "--dry-run") {
9670
+ } else if (argument === dryRunFlag) {
9483
9671
  dryRun = true;
9484
- } else if (argument === "--rotate-secrets") {
9672
+ } else if (argument === rotateSecretsFlag) {
9485
9673
  rotateSecrets = true;
9486
9674
  } else {
9487
9675
  return applyUsage(deps);
@@ -9504,6 +9692,7 @@ async function applyCommand(argv, deps) {
9504
9692
  environments: await client.listEnvironments()
9505
9693
  };
9506
9694
  } catch (error) {
9695
+ if (error instanceof CliError) throw error;
9507
9696
  throw new CliError(`Could not read the current agents and environments: ${describeApiFailure(error)}`);
9508
9697
  }
9509
9698
  let plan;
@@ -9531,12 +9720,17 @@ function printHelp(deps) {
9531
9720
  " logout Remove the stored API key (local only; revoke it in the console)",
9532
9721
  " whoami Show the organization, role and scopes",
9533
9722
  " auth status: show which credential the CLI would use",
9723
+ " version Show the CLI version and the SDK version it ships",
9534
9724
  " agents list | get <agent-id>",
9535
9725
  " environments list | get <environment-id>",
9536
9726
  " service-accounts list | create | archive",
9537
9727
  " federation issuers list|create|archive | rules list|create|archive | token",
9538
9728
  " apply Apply agents and environments from files",
9539
9729
  "",
9730
+ "Options:",
9731
+ " -h, --help Show this help",
9732
+ " -v, --version Show the version",
9733
+ "",
9540
9734
  "Environment:",
9541
9735
  " NOUTER_PLATFORM_API_KEY API key; wins over the stored key and the federation",
9542
9736
  " NOUTER_PLATFORM_BASE_URL API base URL",
@@ -9549,6 +9743,35 @@ function printHelp(deps) {
9549
9743
  ].join("\n")
9550
9744
  );
9551
9745
  }
9746
+ function manifestAt(path) {
9747
+ try {
9748
+ return JSON.parse(readFileSync3(path, "utf8"));
9749
+ } catch {
9750
+ return null;
9751
+ }
9752
+ }
9753
+ function cliVersion() {
9754
+ return manifestAt(fileURLToPath(new URL("../package.json", import.meta.url)))?.version ?? "unknown";
9755
+ }
9756
+ function sdkVersion() {
9757
+ let directory;
9758
+ try {
9759
+ directory = dirname(fileURLToPath(import.meta.resolve("@nouter/platform")));
9760
+ } catch {
9761
+ return "unknown";
9762
+ }
9763
+ for (let depth = 0; depth < 8; depth += 1) {
9764
+ const manifest = manifestAt(join2(directory, "package.json"));
9765
+ if (manifest?.name === "@nouter/platform" && typeof manifest.version === "string") return manifest.version;
9766
+ const parent = dirname(directory);
9767
+ if (parent === directory) break;
9768
+ directory = parent;
9769
+ }
9770
+ return "unknown";
9771
+ }
9772
+ function versionLine() {
9773
+ return `nouter-platform-cli ${cliVersion()} (sdk ${sdkVersion()})`;
9774
+ }
9552
9775
  function usageError(command, deps) {
9553
9776
  deps.writeStderr(`Usage: nouter-platform ${command} ...`);
9554
9777
  return 1;
@@ -9559,6 +9782,10 @@ async function dispatch(argv, deps) {
9559
9782
  printHelp(deps);
9560
9783
  return 0;
9561
9784
  }
9785
+ if (command === "--version" || command === "-v") {
9786
+ deps.writeStdout(versionLine());
9787
+ return 0;
9788
+ }
9562
9789
  switch (command) {
9563
9790
  case "login":
9564
9791
  return await login(rest, deps);
@@ -9572,14 +9799,16 @@ async function dispatch(argv, deps) {
9572
9799
  }
9573
9800
  case "agents": {
9574
9801
  const [subcommand, ...args] = rest;
9575
- const json = args.includes("--json") || rest.includes("--json");
9802
+ const jsonFlag = MANUAL_FLAGS["agents list"][0];
9803
+ const json = subcommand === "list" && (args.includes(jsonFlag) || rest.includes(jsonFlag));
9576
9804
  if (subcommand === "list") return await listAgents(deps, json);
9577
9805
  if (subcommand === "get" && args[0]) return await getAgent(args[0], deps);
9578
9806
  return usageError("agents list|get <agent-id>", deps);
9579
9807
  }
9580
9808
  case "environments": {
9581
9809
  const [subcommand, ...args] = rest;
9582
- const json = args.includes("--json") || rest.includes("--json");
9810
+ const jsonFlag = MANUAL_FLAGS["environments list"][0];
9811
+ const json = subcommand === "list" && (args.includes(jsonFlag) || rest.includes(jsonFlag));
9583
9812
  if (subcommand === "list") return await listEnvironments(deps, json);
9584
9813
  if (subcommand === "get" && args[0]) return await getEnvironment(args[0], deps);
9585
9814
  return usageError("environments list|get <environment-id>", deps);
@@ -9588,6 +9817,10 @@ async function dispatch(argv, deps) {
9588
9817
  if (rest.length === 1 && rest[0] === "status") return authStatus(deps);
9589
9818
  return usageError("auth status", deps);
9590
9819
  }
9820
+ case "version":
9821
+ if (rest.length > 0) return usageError("version", deps);
9822
+ deps.writeStdout(versionLine());
9823
+ return 0;
9591
9824
  case "service-accounts":
9592
9825
  return await serviceAccountsCommand(rest, deps);
9593
9826
  case "federation": {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@nouter/platform-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "CLI for the Nouter platform",
5
5
  "type": "module",
6
6
  "bin": {
7
- "nouter-platform": "./dist/index.js"
7
+ "nouter-platform": "dist/index.js"
8
8
  },
9
9
  "files": [
10
10
  "dist",
@@ -13,7 +13,7 @@
13
13
  "NOTICE"
14
14
  ],
15
15
  "engines": {
16
- "node": ">=20"
16
+ "node": ">=20.6"
17
17
  },
18
18
  "scripts": {
19
19
  "prebuild": "pnpm --filter @nouter/platform build",
@@ -39,14 +39,14 @@
39
39
  "homepage": "https://github.com/Nouter-ai/platform",
40
40
  "repository": {
41
41
  "type": "git",
42
- "url": "https://github.com/Nouter-ai/platform",
42
+ "url": "git+https://github.com/Nouter-ai/platform.git",
43
43
  "directory": "packages/cli"
44
44
  },
45
45
  "bugs": {
46
46
  "url": "https://github.com/Nouter-ai/platform/issues"
47
47
  },
48
48
  "dependencies": {
49
- "@nouter/platform": "^0.2.0",
49
+ "@nouter/platform": "^0.3.0",
50
50
  "yaml": "2.9.1"
51
51
  },
52
52
  "devDependencies": {