@astroanywhere/cli 0.1.0 → 0.2.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/LICENSE CHANGED
@@ -1,21 +1,76 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Astro Anywhere
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: Xi Fu, Zhuoran Yang
11
+
12
+ Licensed Work: @astroanywhere/cli
13
+
14
+ Additional Use Grant: None
15
+
16
+ Change Date: 2030-02-25
17
+
18
+ Change License: Apache License, Version 2.0
19
+
20
+ -----------------------------------------------------------------------------
21
+
22
+ Terms
23
+
24
+ The Licensor hereby grants you the right to copy, modify, create derivative
25
+ works, redistribute, and make non-production use of the Licensed Work. The
26
+ Licensor may make an Additional Use Grant, above, permitting limited
27
+ production use.
28
+
29
+ Effective on the Change Date, or the fourth anniversary of the first publicly
30
+ available distribution of a specific version of the Licensed Work under this
31
+ License, whichever comes first, the Licensor hereby grants you rights under
32
+ the terms of the Change License, and the rights granted in the paragraph above
33
+ terminate.
34
+
35
+ If your use of the Licensed Work does not comply with the requirements
36
+ currently in effect as described in this License, you must purchase a
37
+ commercial license from the Licensor, its affiliated entities, or authorized
38
+ resellers, or you must refrain from using the Licensed Work.
39
+
40
+ All copies of the original and modified Licensed Work, and derivative works of
41
+ the Licensed Work, are subject to this License. This License applies
42
+ separately for each version of the Licensed Work and the Change Date may vary
43
+ for each version of the Licensed Work.
44
+
45
+ You must conspicuously display this License on each copy of the Licensed Work,
46
+ and you must retain the copyright notice for the Licensed Work in this License.
47
+
48
+ -----------------------------------------------------------------------------
49
+
50
+ Covenants of Licensor
51
+
52
+ In consideration of the right to use the Licensed Work granted to you by the
53
+ Licensor under this License, you covenant not to institute litigation against
54
+ the Licensor or any other licensee of the Licensed Work for patent
55
+ infringement claims arising from the Licensed Work. This covenant shall not
56
+ apply to claims that the Licensed Work infringes a patent that you own or
57
+ control, or to claims of patent infringement by combinations of the Licensed
58
+ Work with other software or hardware.
59
+
60
+ -----------------------------------------------------------------------------
61
+
62
+ Notice
63
+
64
+ This License does not grant you any right in any trademark or logo of Licensor
65
+ or its affiliates (provided that you may use a trademark or logo of Licensor
66
+ as expressly required by this License).
67
+
68
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN
69
+ "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
70
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
71
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
72
+ TITLE.
73
+
74
+ MariaDB hereby grants you permission to use this License's text to license
75
+ your works, and to refer to it using the trademark "Business Source License",
76
+ as long as you comply with the Covenants of Licensor above.
package/README.md CHANGED
@@ -1,6 +1,26 @@
1
- # @astroanywhere/cli
2
-
3
- CLI for managing [Astro](https://github.com/astro-anywhere) projects, plans, tasks, and environments.
1
+ <h1 align="center">@astroanywhere/cli</h1>
2
+ <p align="center">
3
+ <strong>Command-line interface for the Astro platform.</strong>
4
+ <br />
5
+ <br />
6
+ <a href="https://www.npmjs.com/package/@astroanywhere/cli"><img src="https://img.shields.io/npm/v/@astroanywhere/cli?style=flat-square&color=0a0a1a&labelColor=0a0a1a&logo=npm&logoColor=white" alt="npm version"></a>
7
+ <a href="https://www.npmjs.com/package/@astroanywhere/cli"><img src="https://img.shields.io/npm/dm/@astroanywhere/cli?style=flat-square&color=0a0a1a&labelColor=0a0a1a&logo=npm&logoColor=white" alt="npm downloads"></a>
8
+ <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-0a0a1a?style=flat-square&labelColor=0a0a1a&logo=node.js&logoColor=white" alt="node version"></a>
9
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-BSL--1.1-0a0a1a?style=flat-square&labelColor=0a0a1a" alt="license"></a>
10
+ <br />
11
+ <br />
12
+ <a href="https://astroanywhere.com/landing/">Website</a>
13
+ &nbsp;&middot;&nbsp;
14
+ <a href="https://astroanywhere.com">Dashboard</a>
15
+ &nbsp;&middot;&nbsp;
16
+ <a href="#install">Get Started</a>
17
+ <br />
18
+ <br />
19
+ </p>
20
+
21
+ ---
22
+
23
+ Manage [Astro](https://astroanywhere.com/landing/) projects, plans, tasks, and environments from the terminal.
4
24
 
5
25
  ## Install
6
26
 
@@ -20,13 +40,13 @@ astro-cli login
20
40
  # List projects
21
41
  astro-cli project list
22
42
 
23
- # View plan
43
+ # View plan as a tree
24
44
  astro-cli plan tree --project-id <id>
25
45
 
26
46
  # Dispatch a task
27
47
  astro-cli task dispatch <nodeId> --project-id <id>
28
48
 
29
- # Watch task output
49
+ # Watch task output in real time
30
50
  astro-cli task watch <executionId>
31
51
  ```
32
52
 
@@ -34,25 +54,46 @@ astro-cli task watch <executionId>
34
54
 
35
55
  | Command | Description |
36
56
  |---------|-------------|
37
- | `project list\|show\|create\|delete` | Manage projects |
38
- | `plan tree\|create-node\|update-node` | Manage plan graphs |
39
- | `task list\|show\|dispatch\|cancel\|steer\|watch` | Manage tasks |
40
- | `env list\|show\|revoke` | Manage environments and machines |
57
+ | `project list\|show\|create\|update\|delete\|stats` | Manage projects |
58
+ | `plan tree\|list\|show\|create-node\|update-node\|delete-node\|stats\|export` | Manage plan graphs |
59
+ | `task list\|show\|dispatch\|cancel\|steer\|watch\|update-status` | Manage tasks |
60
+ | `env list\|show\|remove\|set-default\|status\|providers\|clusters` | Manage environments and machines |
41
61
  | `search <query>` | Search across projects, tasks, executions |
42
- | `activity` | View activity feed |
43
- | `trace` | View execution traces |
44
- | `config` | Manage CLI configuration |
62
+ | `activity list\|watch` | View activity feed |
63
+ | `trace show\|observations\|summary\|stats` | View execution traces |
64
+ | `config show\|set\|get` | Manage CLI configuration |
45
65
  | `login\|logout\|whoami` | Authentication |
66
+ | `completion` | Generate shell completions (bash, zsh, fish) |
67
+
68
+ All commands support `--json` for machine-readable output.
46
69
 
47
70
  ## Configuration
48
71
 
49
- Config is stored at `~/.astro/config.json`.
72
+ Config is stored at `~/.astro/config.json` (permissions 0600).
50
73
 
51
74
  | Setting | Env var | Description |
52
75
  |---------|---------|-------------|
53
76
  | `serverUrl` | `ASTRO_SERVER_URL` | Astro server URL |
54
77
  | `authToken` | — | Access token (set via `login`) |
78
+ | `defaultMachineId` | — | Default machine for dispatch |
79
+
80
+ Resolution order: CLI flag `--server-url` > env var > config file > default.
81
+
82
+ ## Programmatic Usage
83
+
84
+ ```typescript
85
+ import { AstroClient } from '@astroanywhere/cli/client'
86
+
87
+ const client = new AstroClient({ serverUrl: 'http://localhost:3001' })
88
+ const projects = await client.listProjects()
89
+ ```
55
90
 
56
91
  ## License
57
92
 
58
- MIT
93
+ [BSL-1.1](./LICENSE) — converts to Apache 2.0 on 2030-02-25.
94
+
95
+ ---
96
+
97
+ <p align="center">
98
+ <a href="https://astroanywhere.com/landing/">astroanywhere.com</a>
99
+ </p>
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  // src/config.ts
2
4
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
3
5
  import { join } from "path";
@@ -19,18 +21,18 @@ function saveConfig(updates) {
19
21
  mkdirSync(CONFIG_DIR, { recursive: true });
20
22
  const current = loadConfig();
21
23
  const merged = { ...current, ...updates };
22
- writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2) + "\n");
24
+ writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2) + "\n", { mode: 384 });
23
25
  }
24
26
  function clearAuth() {
25
27
  const current = loadConfig();
26
28
  delete current.authToken;
27
29
  delete current.refreshToken;
28
30
  mkdirSync(CONFIG_DIR, { recursive: true });
29
- writeFileSync(CONFIG_FILE, JSON.stringify(current, null, 2) + "\n");
31
+ writeFileSync(CONFIG_FILE, JSON.stringify(current, null, 2) + "\n", { mode: 384 });
30
32
  }
31
33
  function resetConfig() {
32
34
  mkdirSync(CONFIG_DIR, { recursive: true });
33
- writeFileSync(CONFIG_FILE, JSON.stringify({ serverUrl: DEFAULT_SERVER_URL }, null, 2) + "\n");
35
+ writeFileSync(CONFIG_FILE, JSON.stringify({ serverUrl: DEFAULT_SERVER_URL }, null, 2) + "\n", { mode: 384 });
34
36
  }
35
37
  function getServerUrl(cliOverride) {
36
38
  if (cliOverride) return cliOverride;
@@ -69,7 +71,8 @@ var AstroClient = class {
69
71
  });
70
72
  this.headers["Authorization"] = `Bearer ${data.accessToken}`;
71
73
  return true;
72
- } catch {
74
+ } catch (err) {
75
+ console.error(`Token refresh failed: ${err instanceof Error ? err.message : String(err)}`);
73
76
  return false;
74
77
  }
75
78
  }
package/dist/client.js CHANGED
@@ -1,8 +1,9 @@
1
+ #!/usr/bin/env node
1
2
  import {
2
3
  AstroClient,
3
4
  getClient,
4
5
  streamDispatchToStdout
5
- } from "./chunk-PYFBZGQG.js";
6
+ } from "./chunk-7H7WD7QX.js";
6
7
  export {
7
8
  AstroClient,
8
9
  getClient,
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import {
2
3
  clearAuth,
3
4
  getClient,
@@ -6,7 +7,7 @@ import {
6
7
  resetConfig,
7
8
  saveConfig,
8
9
  streamDispatchToStdout
9
- } from "./chunk-PYFBZGQG.js";
10
+ } from "./chunk-7H7WD7QX.js";
10
11
 
11
12
  // src/index.ts
12
13
  import { Command } from "commander";
@@ -1727,6 +1728,19 @@ function registerConfigCommands(program2) {
1727
1728
  process.exitCode = 1;
1728
1729
  return;
1729
1730
  }
1731
+ if (resolved === "serverUrl") {
1732
+ try {
1733
+ new URL(value);
1734
+ } catch {
1735
+ if (json) {
1736
+ print({ error: `Invalid URL: "${value}"` }, { json: true });
1737
+ } else {
1738
+ console.error(chalk9.red(`Invalid URL: "${value}"`));
1739
+ }
1740
+ process.exitCode = 1;
1741
+ return;
1742
+ }
1743
+ }
1730
1744
  saveConfig({ [resolved]: value });
1731
1745
  if (json) {
1732
1746
  print({ ok: true, key: resolved, value }, { json: true });
@@ -2062,7 +2076,7 @@ function registerCompletionCommands(program2) {
2062
2076
 
2063
2077
  // src/index.ts
2064
2078
  var program = new Command();
2065
- program.name("astro-cli").description("CLI for managing Astro projects, plans, tasks, and environments").version("0.1.0").option("--json", "Machine-readable JSON output").option("--quiet", "Suppress spinners and decorative output").option("--server-url <url>", "Override server URL");
2079
+ program.name("astro-cli").description("CLI for managing Astro projects, plans, tasks, and environments").version("0.2.0").option("--json", "Machine-readable JSON output").option("--quiet", "Suppress spinners and decorative output").option("--server-url <url>", "Override server URL");
2066
2080
  registerProjectCommands(program);
2067
2081
  registerPlanCommands(program);
2068
2082
  registerTaskCommands(program);
@@ -2073,4 +2087,8 @@ registerEnvCommands(program);
2073
2087
  registerConfigCommands(program);
2074
2088
  registerAuthCommands(program);
2075
2089
  registerCompletionCommands(program);
2090
+ program.command("tui").description("Launch interactive terminal UI").action(async () => {
2091
+ const { launchTui } = await import("./tui.js");
2092
+ await launchTui(program.opts().serverUrl);
2093
+ });
2076
2094
  program.parse();