@topolo/cli 0.12.31 → 0.12.33

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 +17 -0
  2. package/dist/index.js +33 -10
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -25,6 +25,23 @@ npx @topolo/cli whoami
25
25
 
26
26
  ## Configure
27
27
 
28
+ ### Use it from your terminal
29
+
30
+ Every command starts with `topolo`. Running `topolo` prints help and returns to
31
+ your shell; it does not open an interactive prompt. Copy a complete command:
32
+
33
+ ```bash
34
+ topolo auth login # sign in with your browser
35
+ topolo whoami # see who you are signed in as
36
+ topolo apps --no-json # list your apps as a readable table
37
+ topolo auth --help # see sign-in commands
38
+ topolo help apps # see app commands and options
39
+ ```
40
+
41
+ In help output, `[brackets]` mean an argument is optional and `<angle brackets>`
42
+ mark a value to replace. Do not type the brackets. For example, `help [command]`
43
+ means you can run `topolo help` or `topolo help apps`.
44
+
28
45
  Credentials come from (in priority order):
29
46
 
30
47
  1. Environment-specific credential variables
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command } from "commander";
4
+ import { Command, Help } from "commander";
5
5
 
6
6
  // src/commands/auth.ts
7
7
  import { spawn } from "child_process";
@@ -9,7 +9,7 @@ import { platform as platform2 } from "os";
9
9
  import { createInterface } from "readline/promises";
10
10
  import { stdin as input } from "process";
11
11
 
12
- // node_modules/.pnpm/@topolo+sdk@0.23.16/node_modules/@topolo/sdk/dist/index.js
12
+ // node_modules/.pnpm/@topolo+sdk@0.23.17/node_modules/@topolo/sdk/dist/index.js
13
13
  function record(value) {
14
14
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
15
15
  }
@@ -3610,7 +3610,7 @@ async function pollUntilApproved(params) {
3610
3610
  throw new Error("Device code expired. Run `topolo auth login` again.");
3611
3611
  }
3612
3612
 
3613
- // node_modules/.pnpm/@topolo+sdk@0.23.16/node_modules/@topolo/sdk/dist/node/credential-store.js
3613
+ // node_modules/.pnpm/@topolo+sdk@0.23.17/node_modules/@topolo/sdk/dist/node/credential-store.js
3614
3614
  import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2, chmod as chmod2, rm as rm2, stat } from "fs/promises";
3615
3615
  import { existsSync as existsSync2 } from "fs";
3616
3616
  import { homedir as homedir2, platform } from "os";
@@ -4507,7 +4507,9 @@ async function refreshCredentialIfNeeded(environment = selectedEnvironment(), op
4507
4507
  if (process.env[`${prefix}_API_KEY`] || process.env[`${prefix}_ACCESS_TOKEN`] || environment === "production" && process.env.TOPOLO_API_KEY || environment === "production" && process.env.TOPOLO_ACCESS_TOKEN) {
4508
4508
  return resolveCredential(environment);
4509
4509
  }
4510
- const observed = profileForEnvironment(await readConfig(), environment).credential;
4510
+ const observedProfile = profileForEnvironment(await readConfig(), environment);
4511
+ const observed = observedProfile.credential;
4512
+ if (!observed || observed.kind !== "access_token" || !observed.refreshToken || !observedProfile.oauthClientId || !options.force && observed.expiresAt && observed.expiresAt - REFRESH_SKEW_SECONDS > Math.floor(Date.now() / 1e3)) return observed ?? null;
4511
4513
  return withConfigWriteLock(async () => {
4512
4514
  const config = await readConfig();
4513
4515
  const profile = profileForEnvironment(config, environment);
@@ -4561,6 +4563,10 @@ async function refreshCredentialIfNeeded(environment = selectedEnvironment(), op
4561
4563
  });
4562
4564
  }
4563
4565
  async function refreshContextCredentialIfNeeded(environment, key, options = {}) {
4566
+ const observedProfile = profileForEnvironment(await readConfig(), environment);
4567
+ const observedContext = observedProfile.contexts?.[key];
4568
+ const observed = observedContext?.credential;
4569
+ if (!observed || observed.kind !== "access_token" || !observed.refreshToken || !(observedContext.oauthClientId ?? observedProfile.oauthClientId) || !options.force && observed.expiresAt && observed.expiresAt - REFRESH_SKEW_SECONDS > Math.floor(Date.now() / 1e3)) return observed ?? null;
4564
4570
  return withConfigWriteLock(async () => {
4565
4571
  const config = await readConfig();
4566
4572
  const profile = profileForEnvironment(config, environment);
@@ -7688,8 +7694,8 @@ try {
7688
7694
  }
7689
7695
  var environmentWasStated = Boolean(inheritedEnvironment) || environmentArgSeen;
7690
7696
  program.name("topolo").description(
7691
- "Public Topolo CLI for customer identity, organization context, applications, resources, and actions."
7692
- ).version(CLI_VERSION).option("--env <environment>", "Topolo environment: production, staging, development, or local");
7697
+ "Use Topolo from your terminal: sign in, find your apps, and run actions.\n\nQuick start (copy a command, then press Enter):\n topolo auth login # Sign in with your browser\n topolo whoami # See who you are signed in as\n topolo apps --no-json # List your apps as a readable table\n topolo auth --help # See sign-in commands\n topolo help apps # See app commands and options"
7698
+ ).version(CLI_VERSION).option("--env <environment>", "Topolo environment: production, staging, development, or local").addHelpText("beforeAll", '\nEvery command starts with "topolo". Running "topolo" alone prints help; it does not open an interactive prompt.\n').addHelpText("afterAll", "\nHelp notation: [brackets] mean optional; <angle brackets> mark a value to replace. Do not type the brackets.");
7693
7699
  program.hook("preAction", async (thisCommand, actionCommand) => {
7694
7700
  const opts = thisCommand.opts();
7695
7701
  if (opts.env) process.env.TOPOLO_ENV = normalizeEnvironment(opts.env);
@@ -7727,11 +7733,28 @@ registerContextCommand(program);
7727
7733
  registerResourcesCommand(program);
7728
7734
  registerWorkspacesCommand(program);
7729
7735
  registerInstallationsCommand(program);
7730
- program.parseAsync(argv).catch((err) => {
7731
- process.stderr.write(`Unexpected error: ${err instanceof Error ? err.message : String(err)}
7736
+ var helpCommands = [program];
7737
+ for (const command of helpCommands) {
7738
+ command.configureHelp({
7739
+ subcommandTerm(subcommand) {
7740
+ const parents = [];
7741
+ for (let parent = subcommand.parent ?? command; parent; parent = parent.parent) {
7742
+ parents.unshift(parent.name());
7743
+ }
7744
+ return [...parents, new Help().subcommandTerm(subcommand)].join(" ");
7745
+ }
7746
+ });
7747
+ helpCommands.push(...command.commands);
7748
+ }
7749
+ if (argv.length === 2) {
7750
+ program.outputHelp();
7751
+ } else {
7752
+ program.parseAsync(argv).catch((err) => {
7753
+ process.stderr.write(`Unexpected error: ${err instanceof Error ? err.message : String(err)}
7732
7754
  `);
7733
- process.exit(1);
7734
- });
7755
+ process.exit(1);
7756
+ });
7757
+ }
7735
7758
  function consumeEnvironmentArg(argv2) {
7736
7759
  const next = argv2.slice(0, 2);
7737
7760
  for (let i = 2; i < argv2.length; i += 1) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@topolo/cli",
3
3
  "packageManager": "pnpm@10.17.1",
4
- "version": "0.12.31",
5
- "topoloPublishedVersion": "0.12.31",
4
+ "version": "0.12.33",
5
+ "topoloPublishedVersion": "0.12.33",
6
6
  "description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
7
7
  "license": "UNLICENSED",
8
8
  "author": "Topolo",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@modelcontextprotocol/sdk": "^1.0.0",
31
- "@topolo/mcp": "0.14.21",
32
- "@topolo/sdk": "0.23.16",
31
+ "@topolo/mcp": "0.14.22",
32
+ "@topolo/sdk": "0.23.17",
33
33
  "commander": "^12.1.0",
34
34
  "undici": "6.29.0"
35
35
  },