@solidactions/cli 1.31.0 → 1.33.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 (38) hide show
  1. package/README.md +74 -9
  2. package/dist/commands/crew-env-delete.js +1 -1
  3. package/dist/commands/crew-env-list.js +1 -1
  4. package/dist/commands/crew-env-push.js +1 -1
  5. package/dist/commands/crew-env-set.js +1 -1
  6. package/dist/commands/device-login.js +114 -0
  7. package/dist/commands/docs-upload.js +1 -1
  8. package/dist/commands/env-delete.js +1 -1
  9. package/dist/commands/env-list.js +1 -1
  10. package/dist/commands/env-map.js +1 -1
  11. package/dist/commands/env-pull.js +2 -2
  12. package/dist/commands/env-push.js +2 -2
  13. package/dist/commands/env-set.js +7 -3
  14. package/dist/commands/login.js +96 -31
  15. package/dist/commands/oauth-actions-list.js +1 -1
  16. package/dist/commands/oauth-actions-platforms.js +1 -1
  17. package/dist/commands/oauth-actions-search.js +1 -1
  18. package/dist/commands/oauth-actions-show.js +1 -1
  19. package/dist/commands/project-create.js +1 -1
  20. package/dist/commands/project-list.js +1 -1
  21. package/dist/commands/project-logs.js +1 -1
  22. package/dist/commands/pull.js +1 -1
  23. package/dist/commands/run-list.js +1 -1
  24. package/dist/commands/run-start.js +1 -1
  25. package/dist/commands/run-view.js +1 -1
  26. package/dist/commands/schedule-delete.js +1 -1
  27. package/dist/commands/schedule-list.js +1 -1
  28. package/dist/commands/schedule-set.js +10 -13
  29. package/dist/commands/webhook-list.js +1 -1
  30. package/dist/commands/webhook-secret.js +1 -1
  31. package/dist/commands/workspaces.js +16 -0
  32. package/dist/index.js +56 -5
  33. package/dist/utils/api.js +25 -3
  34. package/dist/utils/config.js +5 -0
  35. package/dist/utils/github.js +7 -1
  36. package/dist/utils/skills.js +3 -2
  37. package/dist/utils/workspace-lookup.js +16 -3
  38. package/package.json +8 -5
package/README.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Deploy and manage workflow automation with SolidActions.
4
4
 
5
+ Public setup guides: [www.solidactions.com/docs](https://www.solidactions.com/docs)
6
+
7
+ ## Prerequisites
8
+
9
+ - Node.js 24 for generated workflow projects (`@solidactions/sdk` requires Node 24)
10
+ - A SolidActions account, workspace, and API key
11
+
5
12
  ## Installation
6
13
 
7
14
  ```bash
@@ -10,15 +17,66 @@ npm install -g @solidactions/cli
10
17
 
11
18
  ## Quick Start
12
19
 
20
+ Create an API key in the SolidActions app under **Settings → API Keys**, then run:
21
+
13
22
  ```bash
14
- solidactions login <api-key> # Authenticate (prompts for workspace)
15
- solidactions init my-project # Scaffold a new project (files + AI skills)
23
+ # The API key is requested in a masked prompt and is not placed in shell history.
24
+ solidactions login --global
25
+
26
+ # Choose one agent target. init creates the project and installs local skills.
27
+ solidactions init my-project --claude
28
+ # Or: solidactions init my-project --agents
29
+
16
30
  cd my-project
17
- solidactions project deploy my-project -e production # Deploy it
18
- solidactions run start my-project <workflow> # Trigger a workflow
19
- solidactions run view <run-id> # Inspect a run
31
+ npm install
32
+ solidactions project deploy my-project -e production
33
+ solidactions run start my-project hello -e production -i '{"name":"Ada"}' --wait
20
34
  ```
21
35
 
36
+ The generated `hello` workflow requires no third-party credentials. A successful
37
+ run completes with a greeting of `Hello, Ada!`; use the run ID printed by the
38
+ command with `solidactions run view <run-id>` or open the run in the app.
39
+
40
+ For non-interactive automation, explicitly read the key from stdin instead of
41
+ placing it in argv:
42
+
43
+ ```bash
44
+ printenv SOLIDACTIONS_API_KEY | solidactions login --stdin --global
45
+ ```
46
+
47
+ Automation that does not need to write a config file can set
48
+ `SOLIDACTIONS_API_KEY` and `SOLIDACTIONS_WORKSPACE_ID` directly.
49
+
50
+ ### Verify the generated AI tooling
51
+
52
+ `solidactions init` installs all five current SolidActions skills plus the SDK
53
+ reference:
54
+
55
+ - `solidactions-getting-started`
56
+ - `solidactions-workflow-coding`
57
+ - `solidactions-deploy-and-config`
58
+ - `solidactions-oauth-actions`
59
+ - `solidactions-crew-skills`
60
+
61
+ For `--claude`, skills are written to `.claude/skills/`; for `--agents`, they
62
+ are written to `.agents/skills/`. Each skill is a flat `solidactions-*.md` file.
63
+ Both targets receive `.solidactions/sdk-reference.md` and a pointer block in
64
+ `CLAUDE.md` or `AGENTS.md`.
65
+
66
+ ```bash
67
+ # Use the directory matching the target selected above.
68
+ find .claude/skills -maxdepth 1 -name 'solidactions-*.md' -print
69
+ test -f .solidactions/sdk-reference.md
70
+ ```
71
+
72
+ Restart the coding-agent session after installation so it reloads project
73
+ instructions. Then ask: “Which SolidActions skills are installed, and which
74
+ one should you use to deploy this workflow?” The answer should identify the
75
+ installed skills and select `solidactions-deploy-and-config` for deployment.
76
+
77
+ For an existing project, install or refresh the same tooling with
78
+ `solidactions ai init --claude` or `solidactions ai init --agents`.
79
+
22
80
  ## Configuration
23
81
 
24
82
  The CLI stores `host`, `apiKey`, and `workspaceId` in a JSON config file. Two locations are supported:
@@ -38,6 +96,9 @@ You can mix: e.g., set only `SOLIDACTIONS_WORKSPACE_ID` in the environment while
38
96
 
39
97
  ### `solidactions login` flags
40
98
 
99
+ - With no positional argument, `login` securely prompts for the API key using
100
+ masked input. This is the recommended interactive flow.
101
+ - `--stdin` — read the API key from stdin for explicitly non-interactive use.
41
102
  - `--local` — write config to `./.solidactions/config.json` in the current folder.
42
103
  - `--global` — write config to `~/.solidactions/config.json` (today's default).
43
104
  - `--gitignore` — with `--local`, auto-add `.solidactions/` to `.gitignore` without prompting.
@@ -60,7 +121,7 @@ Set `SOLIDACTIONS_DEBUG=1` on any command to print the resolved configuration an
60
121
 
61
122
  If you run multiple AI coding agents in different project folders simultaneously, either:
62
123
 
63
- - Run `solidactions login <key> --local` in each folder so each has its own config, or
124
+ - Run `solidactions login --local` interactively in each folder so each has its own config, or
64
125
  - Set `SOLIDACTIONS_API_KEY` / `SOLIDACTIONS_WORKSPACE_ID` in the environment each agent uses (no files to share or stomp).
65
126
 
66
127
  ### Deploy bundle exclusions (`solidactions.yaml`)
@@ -89,7 +150,7 @@ Use `solidactions <command> --help` for full flag details on any command.
89
150
 
90
151
  | Command | Description |
91
152
  |---------|-------------|
92
- | `login <api-key>` | Authenticate CLI with API key |
153
+ | `login` | Authenticate via a masked API-key prompt (`--stdin` for automation) |
93
154
  | `logout` | Remove saved credentials |
94
155
  | `whoami` | Show current configuration |
95
156
  | `init [directory]` | Scaffold a new project (files + AI skills) |
@@ -129,10 +190,14 @@ Use `solidactions <command> --help` for full flag details on any command.
129
190
 
130
191
  | Command | Key Flags | Description |
131
192
  |---------|-----------|-------------|
132
- | `schedule set <project> <cron>` | `--workflow`, `-i`, `-y` | Set cron schedule (warns if exists) |
193
+ | `schedule set <project> <cron>` | `--workflow`, `-i`, `-z`, `-y` | Set cron schedule and optional IANA timezone (warns if exists) |
133
194
  | `schedule list <project>` | | List schedules |
134
195
  | `schedule delete <project> <id>` | `-y` | Delete a schedule |
135
196
 
197
+ ```bash
198
+ solidactions schedule set my-project '0 9 * * 1-5' --workflow daily-summary --timezone America/Chicago
199
+ ```
200
+
136
201
  ### webhook
137
202
 
138
203
  | Command | Key Flags | Description |
@@ -213,7 +278,7 @@ You do **not** need `--overwrite` to keep an edited file whose doc was deleted o
213
278
  | `ai init` | `--claude`, `--agents` | Install AI skills and SDK reference into an **existing** project (use `init` for new projects) |
214
279
  | `ai examples [names...]` | `--all`, `--overwrite` | Install example workflows |
215
280
 
216
- `ai init` installs three auto-activating SolidActions skills and a
281
+ `ai init` installs five auto-activating SolidActions skills and a
217
282
  full SDK reference into your project:
218
283
 
219
284
  - Skills go to `.claude/skills/` (for `--claude` / Claude Code) or
@@ -33,7 +33,7 @@ async function crewEnvDelete(crewArg, key, options = {}) {
33
33
  catch (error) {
34
34
  if (error.response) {
35
35
  if (error.response.status === 401) {
36
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
36
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
37
37
  }
38
38
  else if (error.response.status === 404) {
39
39
  console.error(chalk_1.default.red(error.response.data?.message || `Variable "${key}" not found for crew "${crew.name}".`));
@@ -63,7 +63,7 @@ async function crewEnvList(crewArg, options = {}) {
63
63
  catch (error) {
64
64
  if (error.response) {
65
65
  if (error.response.status === 401) {
66
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
66
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
67
67
  }
68
68
  else if (error.response.status === 404) {
69
69
  console.error(chalk_1.default.red(error.response.data?.message || `Crew "${crewArg}" not found.`));
@@ -72,7 +72,7 @@ async function crewEnvPush(crewArg, filePath = '.env', options = {}) {
72
72
  }
73
73
  catch (error) {
74
74
  if (error.response?.status === 401) {
75
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
75
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
76
76
  }
77
77
  else if (error.response?.status === 404) {
78
78
  console.error(chalk_1.default.red(error.response.data?.message || `Crew "${crewArg}" not found.`));
@@ -58,7 +58,7 @@ async function crewEnvSet(crewArg, key, value, options = {}) {
58
58
  catch (error) {
59
59
  if (error.response) {
60
60
  if (error.response.status === 401) {
61
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
61
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
62
62
  }
63
63
  else if (error.response.status === 404) {
64
64
  console.error(chalk_1.default.red(error.response.data?.message || `Crew "${crewArg}" not found.`));
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.requestDeviceCode = requestDeviceCode;
7
+ exports.pollForToken = pollForToken;
8
+ exports.deviceLogin = deviceLogin;
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const workspace_lookup_1 = require("../utils/workspace-lookup");
12
+ const login_1 = require("./login");
13
+ // Public device-flow client id — not a secret; matches the server-seeded
14
+ // oauth_clients row (config('services.cli.oauth_client_id') on the app side).
15
+ const CLI_OAUTH_CLIENT_ID = '9f1b6e2a-9c1e-4b6e-8f0a-6c9f2b1e7d4c';
16
+ // CLI capability scopes requested at device-code issuance — the server
17
+ // rejects any scope not pre-registered via Passport::tokensCan().
18
+ const CLI_SCOPES = 'env deploy runs docs';
19
+ async function requestDeviceCode(host) {
20
+ const response = await axios_1.default.post(`${host}/oauth/device/code`, {
21
+ client_id: CLI_OAUTH_CLIENT_ID,
22
+ scope: CLI_SCOPES,
23
+ });
24
+ return response.data;
25
+ }
26
+ function sleep(ms) {
27
+ return new Promise((resolve) => setTimeout(resolve, ms));
28
+ }
29
+ /**
30
+ * Poll POST /oauth/token per RFC 8628 §3.5: repeat at `intervalSeconds`,
31
+ * honoring `authorization_pending` (keep polling) and `slow_down` (add
32
+ * `slowDownIncrementSeconds` to the interval and keep polling). Rejects on
33
+ * any other OAuth error, including a server-sent `expired_token`.
34
+ * `slowDownIncrementSeconds` defaults to the RFC-recommended 5s and is only
35
+ * overridden by tests, to keep them fast.
36
+ *
37
+ * `expiresInSeconds` bounds the loop client-side to the device code's own
38
+ * lifetime, so a server that never emits `expired_token` (and just keeps
39
+ * returning `authorization_pending`) can't cause an infinite poll.
40
+ */
41
+ async function pollForToken(host, clientId, deviceCode, intervalSeconds, expiresInSeconds, slowDownIncrementSeconds = 5) {
42
+ let interval = intervalSeconds;
43
+ let elapsed = 0;
44
+ while (true) {
45
+ if (elapsed + interval > expiresInSeconds) {
46
+ throw new Error('device code expired — run `solidactions login --device` again');
47
+ }
48
+ await sleep(interval * 1000);
49
+ elapsed += interval;
50
+ try {
51
+ const response = await axios_1.default.post(`${host}/oauth/token`, {
52
+ grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
53
+ device_code: deviceCode,
54
+ client_id: clientId,
55
+ });
56
+ return response.data;
57
+ }
58
+ catch (error) {
59
+ const oauthError = error?.response?.data?.error;
60
+ if (oauthError === 'authorization_pending') {
61
+ continue;
62
+ }
63
+ if (oauthError === 'slow_down') {
64
+ interval += slowDownIncrementSeconds;
65
+ continue;
66
+ }
67
+ if (oauthError === 'expired_token') {
68
+ throw new Error('device code expired — run `solidactions login --device` again');
69
+ }
70
+ throw new Error(oauthError || error.message);
71
+ }
72
+ }
73
+ }
74
+ async function deviceLogin(options) {
75
+ const resolved = (0, login_1.resolveLoginHost)(options);
76
+ const host = resolved.host;
77
+ console.log(chalk_1.default.blue('Requesting device authorization...'));
78
+ const code = await requestDeviceCode(host);
79
+ const verifyUrl = code.verification_uri_complete || code.verification_uri;
80
+ console.log('');
81
+ console.log(chalk_1.default.green('To finish signing in, visit:'));
82
+ console.log(' ' + chalk_1.default.blue.underline(verifyUrl));
83
+ console.log(chalk_1.default.gray(' Enter code: ') + chalk_1.default.bold(code.user_code));
84
+ console.log('');
85
+ console.log(chalk_1.default.gray('Waiting for approval in your browser...'));
86
+ let token;
87
+ try {
88
+ token = await pollForToken(host, CLI_OAUTH_CLIENT_ID, code.device_code, code.interval || 5, code.expires_in);
89
+ }
90
+ catch (error) {
91
+ console.error(chalk_1.default.red('Device login failed:'), error.message);
92
+ process.exit(1);
93
+ return;
94
+ }
95
+ const config = { host, apiKey: token.access_token };
96
+ // Same tail as login(): fetch workspaces, then resolve + write + report
97
+ // exactly as login() does via the shared completeLogin() helper.
98
+ let workspaces;
99
+ let scope;
100
+ try {
101
+ ({ workspaces, scope } = await (0, workspace_lookup_1.fetchWorkspaces)(config));
102
+ }
103
+ catch (e) {
104
+ if (e.response?.status === 401) {
105
+ console.error(chalk_1.default.red(`Invalid API key for ${host}.`));
106
+ }
107
+ else {
108
+ console.error(chalk_1.default.red(`Could not reach ${host}: ${e.message}`));
109
+ }
110
+ process.exit(1);
111
+ return;
112
+ }
113
+ await (0, login_1.completeLogin)(config, workspaces, options, scope);
114
+ }
@@ -159,7 +159,7 @@ async function docsUpload(files, options = {}) {
159
159
  console.error(chalk_1.default.red(`✗ ${displayName} — ${data?.message || 'File exceeds the maximum upload size (20MB).'}`));
160
160
  }
161
161
  else if (status === 401) {
162
- console.error(chalk_1.default.red(`✗ ${displayName} — Authentication failed. Run "solidactions login <api-key>" to re-configure.`));
162
+ console.error(chalk_1.default.red(`✗ ${displayName} — Authentication failed. Run "solidactions login --global" to re-configure.`));
163
163
  }
164
164
  else if (status === 404 && data?.code === 'media_not_found') {
165
165
  console.error(chalk_1.default.red(`✗ ${displayName} — doc ${replaceDocId} is not a media doc`));
@@ -92,7 +92,7 @@ async function envDelete(keyOrProject, keyIfProject, options = {}) {
92
92
  catch (error) {
93
93
  if (error.response) {
94
94
  if (error.response.status === 401) {
95
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
95
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
96
96
  }
97
97
  else if (error.response.status === 404) {
98
98
  if (isProjectMode) {
@@ -187,7 +187,7 @@ async function envList(projectName, options = {}) {
187
187
  catch (error) {
188
188
  if (error.response) {
189
189
  if (error.response.status === 401) {
190
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
190
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
191
191
  }
192
192
  else if (error.response.status === 404) {
193
193
  if (projectName) {
@@ -63,7 +63,7 @@ async function envMap(projectName, projectKey, globalKey, options = {}) {
63
63
  catch (error) {
64
64
  if (error.response) {
65
65
  if (error.response.status === 401) {
66
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
66
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
67
67
  }
68
68
  else if (error.response.status === 404) {
69
69
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
@@ -205,12 +205,12 @@ async function envPull(projectName, options = {}) {
205
205
  catch (error) {
206
206
  if (error.response) {
207
207
  if (error.response.status === 401) {
208
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
208
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
209
209
  }
210
210
  else if (error.response.status === 404) {
211
211
  console.error(chalk_1.default.red(`Project "${projectSlug}" not found.`));
212
212
  if (environment !== 'production') {
213
- console.log(chalk_1.default.gray(`Try deploying with: solidactions project deploy ${projectName} --env ${environment} --create`));
213
+ console.log(chalk_1.default.gray(`Try deploying with: solidactions project deploy ${projectName} -e ${environment} --create`));
214
214
  }
215
215
  }
216
216
  else {
@@ -96,12 +96,12 @@ async function envPush(projectName, sourcePath, options = {}) {
96
96
  }
97
97
  catch (error) {
98
98
  if (error.response?.status === 401) {
99
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
99
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
100
100
  process.exit(1);
101
101
  }
102
102
  else if (error.response?.status === 404) {
103
103
  console.error(chalk_1.default.red(`Project "${projectSlug}" not found.`));
104
- console.log(chalk_1.default.gray(`Deploy first with: solidactions project deploy ${projectName} --env ${environment}` + (environment !== 'production' ? ' --create' : '')));
104
+ console.log(chalk_1.default.gray(`Deploy first with: solidactions project deploy ${projectName} -e ${environment}` + (environment !== 'production' ? ' --create' : '')));
105
105
  process.exit(1);
106
106
  }
107
107
  throw error;
@@ -106,7 +106,7 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
106
106
  catch (error) {
107
107
  if (error.response) {
108
108
  if (error.response.status === 401) {
109
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
109
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
110
110
  }
111
111
  else if (error.response.status === 404) {
112
112
  const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
@@ -138,7 +138,11 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
138
138
  process.exit(1);
139
139
  }
140
140
  console.log(chalk_1.default.yellow(exports.GLOBAL_ENV_SCOPE_NOTE));
141
- const isSecret = options.secret || false;
141
+ // Keep global and project writes consistent: names that commonly carry
142
+ // credentials are secrets unless the caller explicitly uses a plain
143
+ // name. `--secret` remains available for sensitive values whose names
144
+ // do not match this convention.
145
+ const isSecret = options.secret || /secret|key|token|password|credential/i.test(key);
142
146
  // Build the request body with per-environment values
143
147
  const body = {
144
148
  key,
@@ -224,7 +228,7 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
224
228
  catch (error) {
225
229
  if (error.response) {
226
230
  if (error.response.status === 401) {
227
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
231
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
228
232
  }
229
233
  else if (error.response.status === 422) {
230
234
  console.error(chalk_1.default.red((0, api_1.formatValidationError)(error.response.data)));
@@ -3,21 +3,71 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.API_KEY_PROMPT = void 0;
7
+ exports.resolveLoginApiKey = resolveLoginApiKey;
6
8
  exports.getConfig = getConfig;
7
9
  exports.saveConfig = saveConfig;
8
10
  exports.clearConfig = clearConfig;
9
11
  exports.resolveLoginHost = resolveLoginHost;
10
12
  exports.backupPathFor = backupPathFor;
11
13
  exports.loginHostLines = loginHostLines;
14
+ exports.completeLogin = completeLogin;
12
15
  exports.login = login;
13
16
  exports.logout = logout;
14
17
  exports.whoami = whoami;
15
18
  const fs_1 = __importDefault(require("fs"));
16
19
  const readline_1 = __importDefault(require("readline"));
17
20
  const chalk_1 = __importDefault(require("chalk"));
21
+ const prompts_1 = __importDefault(require("prompts"));
18
22
  const config_1 = require("../utils/config");
19
23
  const config_write_target_1 = require("../utils/config-write-target");
20
24
  const workspace_lookup_1 = require("../utils/workspace-lookup");
25
+ exports.API_KEY_PROMPT = {
26
+ type: 'password',
27
+ name: 'apiKey',
28
+ message: 'SolidActions API key',
29
+ };
30
+ async function readAll(input) {
31
+ let value = '';
32
+ for await (const chunk of input) {
33
+ value += chunk.toString();
34
+ }
35
+ return value;
36
+ }
37
+ /**
38
+ * Resolve a login secret without requiring it in argv. The positional key is
39
+ * retained for backwards compatibility, while new interactive documentation
40
+ * uses the masked prompt and automation can opt into stdin explicitly.
41
+ */
42
+ async function resolveLoginApiKey(apiKey, options = {}, dependencies = {}) {
43
+ if (apiKey && options.stdin) {
44
+ throw new Error('Pass the API key either as the legacy positional argument or via --stdin, not both.');
45
+ }
46
+ let resolved = apiKey;
47
+ if (options.stdin) {
48
+ resolved = await readAll(dependencies.input ?? process.stdin);
49
+ }
50
+ else if (!resolved) {
51
+ const isTTY = dependencies.isTTY ?? process.stdin.isTTY === true;
52
+ if (!isTTY) {
53
+ throw new Error('API key is required in non-interactive mode. Pipe it with --stdin, ' +
54
+ 'or set SOLIDACTIONS_API_KEY without running login.');
55
+ }
56
+ const prompt = dependencies.prompt ?? (async () => {
57
+ const response = await (0, prompts_1.default)(exports.API_KEY_PROMPT);
58
+ return response.apiKey;
59
+ });
60
+ resolved = await prompt();
61
+ if (resolved === undefined) {
62
+ throw new Error('Login cancelled.');
63
+ }
64
+ }
65
+ const trimmed = resolved?.trim();
66
+ if (!trimmed) {
67
+ throw new Error('API key is required.');
68
+ }
69
+ return trimmed;
70
+ }
21
71
  function getConfig() {
22
72
  const resolved = (0, config_1.resolveConfig)();
23
73
  return resolved ? resolved.config : null;
@@ -90,36 +140,17 @@ async function selectWorkspaceInteractively(workspaces) {
90
140
  }
91
141
  return workspaces[index];
92
142
  }
93
- async function login(apiKey, options) {
94
- const resolved = resolveLoginHost(options);
95
- const host = resolved.host;
96
- if (!apiKey || apiKey.trim().length === 0) {
97
- console.error(chalk_1.default.red('Error: API key is required.'));
98
- console.log(chalk_1.default.gray('Generate an API key at: ') + chalk_1.default.blue(`${host}/settings/api-keys`));
99
- process.exit(1);
100
- }
101
- console.log(chalk_1.default.blue(`Initializing SolidActions CLI...`));
102
- for (const line of loginHostLines(resolved)) {
103
- console.log(resolved.isDefault ? chalk_1.default.yellow(line) : chalk_1.default.gray(line));
104
- }
105
- const config = {
106
- host,
107
- apiKey: apiKey.trim(),
108
- };
109
- // 1. Validate the key BEFORE any disk write.
110
- let workspaces;
111
- try {
112
- workspaces = await (0, workspace_lookup_1.fetchWorkspaces)(config);
113
- }
114
- catch (e) {
115
- if (e.response?.status === 401) {
116
- console.error(chalk_1.default.red(`Invalid API key for ${host}.`));
117
- }
118
- else {
119
- console.error(chalk_1.default.red(`Could not reach ${host}: ${e.message}`));
120
- }
121
- process.exit(1);
122
- return;
143
+ /**
144
+ * Shared tail of `login`, reused verbatim by `deviceLogin`: resolve the
145
+ * workspace against an already-fetched list, determine the write target,
146
+ * back up + write the config file once, and print the success output.
147
+ */
148
+ async function completeLogin(config, workspaces, options, scope = null) {
149
+ // Device-flow tokens carry a scope (mode + workspace_ids) that later
150
+ // gates `workspace set`; absent for user-scoped Sanctum PATs.
151
+ if (scope) {
152
+ config.scopeMode = scope.mode;
153
+ config.scopedWorkspaceIds = scope.workspace_ids;
123
154
  }
124
155
  // 2. Resolve the workspace (still before writing).
125
156
  if (options.workspace) {
@@ -173,6 +204,40 @@ async function login(apiKey, options) {
173
204
  console.log(chalk_1.default.gray(' solidactions run start <proj> <wf> Run a workflow'));
174
205
  console.log(chalk_1.default.gray(' solidactions run list List recent runs'));
175
206
  }
207
+ async function login(apiKey, options) {
208
+ const resolved = resolveLoginHost(options);
209
+ const host = resolved.host;
210
+ if (!apiKey || apiKey.trim().length === 0) {
211
+ console.error(chalk_1.default.red('Error: API key is required.'));
212
+ console.log(chalk_1.default.gray('Generate an API key at: ') + chalk_1.default.blue(`${host}/settings/api-keys`));
213
+ process.exit(1);
214
+ }
215
+ console.log(chalk_1.default.blue(`Initializing SolidActions CLI...`));
216
+ for (const line of loginHostLines(resolved)) {
217
+ console.log(resolved.isDefault ? chalk_1.default.yellow(line) : chalk_1.default.gray(line));
218
+ }
219
+ const config = {
220
+ host,
221
+ apiKey: apiKey.trim(),
222
+ };
223
+ // 1. Validate the key BEFORE any disk write.
224
+ let workspaces;
225
+ let scope;
226
+ try {
227
+ ({ workspaces, scope } = await (0, workspace_lookup_1.fetchWorkspaces)(config));
228
+ }
229
+ catch (e) {
230
+ if (e.response?.status === 401) {
231
+ console.error(chalk_1.default.red(`Invalid API key for ${host}.`));
232
+ }
233
+ else {
234
+ console.error(chalk_1.default.red(`Could not reach ${host}: ${e.message}`));
235
+ }
236
+ process.exit(1);
237
+ return;
238
+ }
239
+ await completeLogin(config, workspaces, options, scope);
240
+ }
176
241
  function logout(options = {}) {
177
242
  if (options.local && options.global) {
178
243
  console.error(chalk_1.default.red('Error: --local and --global are mutually exclusive.'));
@@ -207,7 +272,7 @@ function whoami() {
207
272
  const resolved = (0, config_1.resolveConfig)();
208
273
  if (!resolved || !resolved.config.apiKey) {
209
274
  console.log(chalk_1.default.yellow('Not initialized.'));
210
- console.log(chalk_1.default.gray('Run "solidactions login <api-key>" to configure.'));
275
+ console.log(chalk_1.default.gray('Run "solidactions login --global" to configure.'));
211
276
  process.exit(1);
212
277
  }
213
278
  const { config, sources } = resolved;
@@ -38,7 +38,7 @@ async function oauthActionsList(platform, options) {
38
38
  console.error(chalk_1.default.red(`Unknown platform "${platform}". Run \`solidactions oauth-actions platforms\` to see available platforms.`));
39
39
  }
40
40
  else if (error.response?.status === 401) {
41
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>".'));
41
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global".'));
42
42
  }
43
43
  else if (error.response) {
44
44
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
@@ -28,7 +28,7 @@ async function oauthActionsPlatforms(options) {
28
28
  }
29
29
  catch (error) {
30
30
  if (error.response?.status === 401) {
31
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>".'));
31
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global".'));
32
32
  }
33
33
  else if (error.response) {
34
34
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
@@ -49,7 +49,7 @@ async function oauthActionsSearch(platform, query, options) {
49
49
  console.error(chalk_1.default.red(`Unknown platform "${platform}". Run \`solidactions oauth-actions platforms\` to see available platforms.`));
50
50
  }
51
51
  else if (error.response?.status === 401) {
52
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
52
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
53
53
  }
54
54
  else if (error.response) {
55
55
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
@@ -26,7 +26,7 @@ async function oauthActionsShow(platform, actionId, options) {
26
26
  console.error(chalk_1.default.red(`Action not found: ${platform}/${actionId}`));
27
27
  }
28
28
  else if (error.response?.status === 401) {
29
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>".'));
29
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global".'));
30
30
  }
31
31
  else if (error.response) {
32
32
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
@@ -45,7 +45,7 @@ async function projectCreateWithConfig(name, options, config) {
45
45
  catch (error) {
46
46
  if (error.response) {
47
47
  if (error.response.status === 401) {
48
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
48
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
49
49
  }
50
50
  else {
51
51
  console.error(chalk_1.default.red('Failed to create project:'), error.response.data?.message || error.message);
@@ -44,7 +44,7 @@ async function projectList(options = {}) {
44
44
  catch (error) {
45
45
  if (error.response) {
46
46
  if (error.response.status === 401) {
47
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
47
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
48
48
  }
49
49
  else {
50
50
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
@@ -45,7 +45,7 @@ async function logsBuild(projectName, environment) {
45
45
  catch (error) {
46
46
  if (error.response) {
47
47
  if (error.response.status === 401) {
48
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
48
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
49
49
  }
50
50
  else if (error.response.status === 404) {
51
51
  console.error(chalk_1.default.red(error.response.data?.message ?? `Project "${projectName}" not found.`));
@@ -70,7 +70,7 @@ async function pull(projectName, destPath, options = {}) {
70
70
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
71
71
  }
72
72
  else if (error.response.status === 401) {
73
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
73
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
74
74
  }
75
75
  else {
76
76
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`));
@@ -82,7 +82,7 @@ async function runs(projectName, options = {}) {
82
82
  console.error(chalk_1.default.yellow(`Pass -e <env> to disambiguate, e.g.: solidactions run list ${projectName} -e dev`));
83
83
  }
84
84
  else if (error.response.status === 401) {
85
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
85
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
86
86
  }
87
87
  else {
88
88
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
@@ -69,7 +69,7 @@ async function run(projectName, workflowName, options) {
69
69
  catch (error) {
70
70
  if (error.response) {
71
71
  if (error.response.status === 401) {
72
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
72
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
73
73
  }
74
74
  else if (error.response.status === 404) {
75
75
  const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
@@ -110,7 +110,7 @@ async function runView(runId, options) {
110
110
  catch (error) {
111
111
  if (error.response) {
112
112
  if (error.response.status === 401) {
113
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
113
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
114
114
  }
115
115
  else if (error.response.status === 404) {
116
116
  console.error(chalk_1.default.red('Run not found.'));
@@ -46,7 +46,7 @@ async function scheduleDelete(projectName, scheduleId, options = {}) {
46
46
  catch (error) {
47
47
  if (error.response) {
48
48
  if (error.response.status === 401) {
49
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
49
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
50
50
  }
51
51
  else if (error.response.status === 404) {
52
52
  console.error(chalk_1.default.red(`Project "${projectName}" or schedule ${scheduleId} not found.`));
@@ -43,7 +43,7 @@ async function scheduleList(projectName) {
43
43
  catch (error) {
44
44
  if (error.response) {
45
45
  if (error.response.status === 401) {
46
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
46
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
47
47
  }
48
48
  else if (error.response.status === 404) {
49
49
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EXISTING_SCHEDULE_CHOICES = void 0;
6
7
  exports.buildSchedulePayload = buildSchedulePayload;
7
8
  exports.timezoneMismatch = timezoneMismatch;
8
9
  exports.timezoneMismatchRemedy = timezoneMismatchRemedy;
@@ -35,6 +36,10 @@ function timezoneMismatch(requested, returned) {
35
36
  function timezoneMismatchRemedy(projectName) {
36
37
  return `Your server may not support schedule timezones yet; update the server, or run 'solidactions schedule list ${projectName}' to find the schedule ID and remove it with: solidactions schedule delete ${projectName} <schedule-id>`;
37
38
  }
39
+ exports.EXISTING_SCHEDULE_CHOICES = [
40
+ { title: 'Replace existing schedule', value: 'replace' },
41
+ { title: 'Cancel', value: 'cancel' },
42
+ ];
38
43
  async function scheduleSet(projectName, cron, options) {
39
44
  const config = await (0, api_1.requireConfigWithWorkspace)();
40
45
  // Parse input JSON if provided
@@ -68,23 +73,15 @@ async function scheduleSet(projectName, cron, options) {
68
73
  type: 'select',
69
74
  name: 'action',
70
75
  message: 'What would you like to do?',
71
- choices: [
72
- { title: 'Replace existing schedule', value: 'replace' },
73
- { title: 'Add another schedule', value: 'add' },
74
- { title: 'Cancel', value: 'cancel' },
75
- ],
76
+ choices: exports.EXISTING_SCHEDULE_CHOICES,
76
77
  });
77
78
  if (confirm.action === 'cancel' || confirm.action === undefined) {
78
79
  console.log(chalk_1.default.gray('Cancelled.'));
79
80
  return;
80
81
  }
81
- if (confirm.action === 'replace') {
82
- // Delete the existing schedule first
83
- await axios_1.default.delete(`${config.host}/api/v1/projects/${projectName}/schedules/${existing.id}`, {
84
- headers: (0, api_1.getApiHeaders)(config),
85
- });
86
- console.log(chalk_1.default.gray(`Removed old schedule (${existing.cron_expression}).`));
87
- }
82
+ // The API owns the one-schedule-per-workflow invariant and
83
+ // updates the existing row. Do not delete first: deletion
84
+ // loses YAML provenance and any persistent override state.
88
85
  }
89
86
  }
90
87
  catch {
@@ -122,7 +119,7 @@ async function scheduleSet(projectName, cron, options) {
122
119
  catch (error) {
123
120
  if (error.response) {
124
121
  if (error.response.status === 401) {
125
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
122
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
126
123
  }
127
124
  else if (error.response.status === 404) {
128
125
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
@@ -50,7 +50,7 @@ async function webhookList(projectName, options = {}) {
50
50
  catch (error) {
51
51
  if (error.response) {
52
52
  if (error.response.status === 401) {
53
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
53
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
54
54
  }
55
55
  else if (error.response.status === 404) {
56
56
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
@@ -57,7 +57,7 @@ async function webhookSecret(projectName, options = {}) {
57
57
  catch (error) {
58
58
  if (error.response) {
59
59
  if (error.response.status === 401) {
60
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
60
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
61
61
  }
62
62
  else if (error.response.status === 404) {
63
63
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
@@ -54,6 +54,10 @@ async function workspacesList() {
54
54
  process.exit(1);
55
55
  }
56
56
  }
57
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
58
+ function looksLikeUuid(input) {
59
+ return UUID_RE.test(input);
60
+ }
57
61
  async function workspaceSet(input, options = {}) {
58
62
  if (process.env.SOLIDACTIONS_WORKSPACE_ID) {
59
63
  console.error(chalk_1.default.red('SOLIDACTIONS_WORKSPACE_ID is set in the environment; the change would not take effect. ' +
@@ -61,6 +65,18 @@ async function workspaceSet(input, options = {}) {
61
65
  process.exit(1);
62
66
  }
63
67
  const config = (0, api_1.requireResolvedConfig)().config;
68
+ if ((config.scopeMode === 'single' || config.scopeMode === 'subset') && config.scopedWorkspaceIds) {
69
+ // Best-effort pre-check: the scope list holds raw ids, so only an id
70
+ // input can be checked locally; slug/name inputs fall through to the
71
+ // server's authoritative 403 workspace_forbidden (surfaced cleanly).
72
+ const isKnownOutOfScope = config.scopedWorkspaceIds.length > 0
73
+ && !config.scopedWorkspaceIds.includes(input);
74
+ if (isKnownOutOfScope && looksLikeUuid(input)) {
75
+ console.error(chalk_1.default.red(`This session is scoped to workspace(s) ${config.scopedWorkspaceIds.join(', ')}. `
76
+ + 'Re-run `solidactions login --device` to change scope.'));
77
+ process.exit(1);
78
+ }
79
+ }
64
80
  const workspace = await (0, workspace_lookup_1.resolveWorkspaceInput)(config, input);
65
81
  const target = await (0, config_write_target_1.decideWriteTarget)({ local: options.local, global: options.global });
66
82
  const targetPath = (0, config_write_target_1.pathForTarget)(target);
package/dist/index.js CHANGED
@@ -1,5 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
38
  };
@@ -108,16 +141,29 @@ program.hook('preAction', (thisCommand, actionCommand) => {
108
141
  // =============================================================================
109
142
  program
110
143
  .command('login')
111
- .description('Authenticate the CLI with your API key')
112
- .argument('<api-key>', 'Your SolidActions API key')
144
+ .description('Authenticate the CLI (prompts securely for your API key, or via --device for browser-based login)')
145
+ .argument('[api-key]', 'Legacy positional API key (prefer the masked prompt, --stdin, or --device)')
146
+ .option('--stdin', 'Read the API key from stdin (for non-interactive automation)')
147
+ .option('--device', 'Authenticate via browser using OAuth device authorization')
113
148
  .option('--dev', 'Use local development server (http://localhost:8000)')
114
149
  .option('--host <url>', 'Custom API host URL')
115
150
  .option('--workspace <name-or-id>', 'Set workspace by name, slug, or ID (skips interactive prompt). Non-interactive logins without this flag leave the workspace unset.')
116
151
  .option('--local', 'Save config to ./.solidactions/config.json in the current folder')
117
152
  .option('--global', 'Save config to ~/.solidactions/config.json (default if prompted)')
118
153
  .option('--gitignore', 'With --local, add .solidactions/ to .gitignore without prompting')
154
+ .addHelpText('after', `
155
+ Environment:
156
+ SOLIDACTIONS_API_KEY When set, this key takes precedence over any saved
157
+ credentials and is used directly — you do not need to run
158
+ \`login\` (or \`login --device\`) at all in that setup.`)
119
159
  .action(async (apiKey, options) => {
120
- await (0, login_1.login)(apiKey, options);
160
+ if (options.device) {
161
+ const { deviceLogin } = await Promise.resolve().then(() => __importStar(require('./commands/device-login')));
162
+ await deviceLogin(options);
163
+ return;
164
+ }
165
+ const resolvedApiKey = await (0, login_1.resolveLoginApiKey)(apiKey, { stdin: options.stdin });
166
+ await (0, login_1.login)(resolvedApiKey, options);
121
167
  });
122
168
  program
123
169
  .command('init')
@@ -441,9 +487,14 @@ workspace
441
487
  .command('set')
442
488
  .description('Set the active workspace and pin it')
443
489
  .argument('<id-or-slug-or-name>', 'Workspace ID, slug, or name')
444
- .option('--local', 'pin to ./.solidactions/config.json')
445
- .option('--global', 'pin to ~/.solidactions/config.json')
490
+ .option('--local', 'pin to ./.solidactions/config.json (this folder only)')
491
+ .option('--global', 'pin to ~/.solidactions/config.json (machine-wide)')
446
492
  .option('--gitignore', 'auto-add .solidactions/ to local .gitignore (skip prompt)')
493
+ .addHelpText('after', `
494
+ Where the pin is saved (--local / --global):
495
+ --local and --global choose the target file and are mutually exclusive.
496
+ If neither is passed, you are prompted when interactive (default: global);
497
+ in non-interactive/CI use, the command exits with an error asking you to pass one.`)
447
498
  .action(async (input, opts) => {
448
499
  await (0, workspaces_1.workspaceSet)(input, opts);
449
500
  });
package/dist/utils/api.js CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.augmentNotFoundMessage = augmentNotFoundMessage;
7
+ exports.augmentWorkspaceForbiddenMessage = augmentWorkspaceForbiddenMessage;
7
8
  exports.getApiHeaders = getApiHeaders;
8
9
  exports.describeProjectEnvironments = describeProjectEnvironments;
9
10
  exports.formatValidationError = formatValidationError;
@@ -37,7 +38,23 @@ function augmentNotFoundMessage(error) {
37
38
  }
38
39
  return error;
39
40
  }
40
- axios_1.default.interceptors.response.use((response) => response, (error) => Promise.reject(augmentNotFoundMessage(error)));
41
+ /**
42
+ * Inspect an axios error and, if it's a 403 with the app's `workspace_forbidden`
43
+ * error code (device-flow-scoped token targeting a workspace outside its
44
+ * scope), replace the raw server message with actionable guidance similar in
45
+ * spirit to `workspaceSet`'s local pre-check (wording isn't kept in sync
46
+ * verbatim) — so slug/name inputs (which can't be pre-checked locally) still
47
+ * surface a clear message instead of a raw axios/HTTP error.
48
+ */
49
+ function augmentWorkspaceForbiddenMessage(error) {
50
+ if (error?.response?.status === 403 && error.response.data?.code === 'workspace_forbidden') {
51
+ error.response.data.message =
52
+ 'This session is scoped to a limited set of workspaces. '
53
+ + 'Re-run `solidactions login --device` to change scope.';
54
+ }
55
+ return error;
56
+ }
57
+ axios_1.default.interceptors.response.use((response) => response, (error) => Promise.reject(augmentWorkspaceForbiddenMessage(augmentNotFoundMessage(error))));
41
58
  function getApiHeaders(config, contentType) {
42
59
  const headers = {
43
60
  'Authorization': `Bearer ${config.apiKey}`,
@@ -108,7 +125,7 @@ function formatValidationError(data) {
108
125
  function requireResolvedConfig() {
109
126
  const resolved = (0, config_1.resolveConfig)();
110
127
  if (!resolved || !resolved.config.apiKey) {
111
- console.error(chalk_1.default.red('Not initialized. Run `solidactions login <api-key>` first.'));
128
+ console.error(chalk_1.default.red('Not initialized. Run `solidactions login --global` first.'));
112
129
  process.exit(1);
113
130
  }
114
131
  return resolved;
@@ -123,7 +140,7 @@ function requireConfig() {
123
140
  */
124
141
  function authFailureMessage(config, sources) {
125
142
  const keySource = sources?.apiKey ?? 'config';
126
- return `Authentication failed against ${config.host} (key from ${keySource}). Run \`solidactions login <api-key>\` to re-configure.`;
143
+ return `Authentication failed against ${config.host} (key from ${keySource}). Run \`solidactions login --global\` to re-configure.`;
127
144
  }
128
145
  async function ensureWorkspaceSelected(config) {
129
146
  if (config.workspaceId) {
@@ -157,6 +174,11 @@ async function ensureWorkspaceSelected(config) {
157
174
  else {
158
175
  workspaces = Array.isArray(grouped) ? grouped : [];
159
176
  }
177
+ const scope = response.data.scope;
178
+ if (scope) {
179
+ config.scopeMode = scope.mode;
180
+ config.scopedWorkspaceIds = scope.workspace_ids;
181
+ }
160
182
  }
161
183
  catch (error) {
162
184
  if (error.response?.status === 401) {
@@ -168,6 +168,9 @@ function mergeConfigs(env, local, localPath, global, globalPath) {
168
168
  };
169
169
  const workspace = pickWorkspaceField('workspace');
170
170
  const workspaceId = pickWorkspaceField('workspaceId');
171
+ // Never env-settable — config-file layers only (local > global).
172
+ const scopeMode = pick('scopeMode');
173
+ const scopedWorkspaceIds = pick('scopedWorkspaceIds');
171
174
  if (!host.value && !apiKey.value) {
172
175
  return null;
173
176
  }
@@ -177,6 +180,8 @@ function mergeConfigs(env, local, localPath, global, globalPath) {
177
180
  apiKey: (apiKey.value ?? ''),
178
181
  workspace: workspace.value,
179
182
  workspaceId: workspaceId.value,
183
+ scopeMode: scopeMode.value,
184
+ scopedWorkspaceIds: scopedWorkspaceIds.value,
180
185
  },
181
186
  sources: {
182
187
  host: host.source,
@@ -3,12 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.rawContentUrl = rawContentUrl;
6
7
  exports.fetchRawFile = fetchRawFile;
7
8
  exports.listRepoContents = listRepoContents;
8
9
  const axios_1 = __importDefault(require("axios"));
10
+ const DEFAULT_RAW_CONTENT_BASE_URL = 'https://raw.githubusercontent.com';
11
+ function rawContentUrl(owner, repo, path, branch = 'main') {
12
+ const baseUrl = (process.env.SOLIDACTIONS_RAW_CONTENT_BASE_URL ?? DEFAULT_RAW_CONTENT_BASE_URL).replace(/\/$/, '');
13
+ return `${baseUrl}/${owner}/${repo}/${branch}/${path}`;
14
+ }
9
15
  async function fetchRawFile(owner, repo, path, branch = 'main') {
10
16
  try {
11
- const url = `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${path}`;
17
+ const url = rawContentUrl(owner, repo, path, branch);
12
18
  const response = await axios_1.default.get(url, { responseType: 'text' });
13
19
  return response.data;
14
20
  }
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SOLIDACTIONS_SKILL_NAMES = void 0;
6
7
  exports.skillTargetDir = skillTargetDir;
7
8
  exports.installSkills = installSkills;
8
9
  exports.fetchAiHelperContent = fetchAiHelperContent;
@@ -11,7 +12,7 @@ const fs_1 = __importDefault(require("fs"));
11
12
  const path_1 = __importDefault(require("path"));
12
13
  const fs_extra_1 = __importDefault(require("fs-extra"));
13
14
  const github_1 = require("./github");
14
- const SKILL_NAMES = [
15
+ exports.SOLIDACTIONS_SKILL_NAMES = [
15
16
  'solidactions-getting-started',
16
17
  'solidactions-workflow-coding',
17
18
  'solidactions-deploy-and-config',
@@ -44,7 +45,7 @@ function skillTargetDir(targetFile, cwd = process.cwd()) {
44
45
  async function installSkills(targetDir) {
45
46
  const written = [];
46
47
  fs_extra_1.default.ensureDirSync(targetDir);
47
- for (const skillName of SKILL_NAMES) {
48
+ for (const skillName of exports.SOLIDACTIONS_SKILL_NAMES) {
48
49
  const remotePath = `${SKILLS_PATH_PREFIX}/${skillName}.md`;
49
50
  const content = await (0, github_1.fetchRawFile)(EXAMPLES_OWNER, EXAMPLES_REPO, remotePath);
50
51
  const filePath = path_1.default.join(targetDir, `${skillName}.md`);
@@ -38,7 +38,8 @@ async function fetchWorkspaces(config) {
38
38
  else if (Array.isArray(grouped)) {
39
39
  out.push(...grouped);
40
40
  }
41
- return out;
41
+ const scope = response.data.scope ?? null;
42
+ return { workspaces: out, scope };
42
43
  }
43
44
  /**
44
45
  * High-level: fetch + match. Errors with a clear CLI message and exits
@@ -46,8 +47,9 @@ async function fetchWorkspaces(config) {
46
47
  */
47
48
  async function resolveWorkspaceInput(config, input) {
48
49
  let workspaces;
50
+ let scope = null;
49
51
  try {
50
- workspaces = await fetchWorkspaces(config);
52
+ ({ workspaces, scope } = await fetchWorkspaces(config));
51
53
  }
52
54
  catch (error) {
53
55
  console.error(chalk_1.default.red('Failed to list workspaces:'), error.response?.data?.message || error.message);
@@ -55,7 +57,18 @@ async function resolveWorkspaceInput(config, input) {
55
57
  }
56
58
  const match = matchWorkspace(input, workspaces);
57
59
  if (!match) {
58
- console.error(chalk_1.default.red(`Workspace "${input}" not found. Run \`solidactions workspace list\` to list available workspaces.`));
60
+ // A scoped (single/subset) session only ever lists the workspaces its
61
+ // OAuth grant covers, so a miss can mean either "doesn't exist" OR
62
+ // "exists but out of this session's scope" — disambiguate so the user
63
+ // knows re-auth with broader scope may be the fix, not a typo.
64
+ if (scope && (scope.mode === 'single' || scope.mode === 'subset')) {
65
+ console.error(chalk_1.default.red(`Workspace "${input}" not found in this session's authorized workspaces `
66
+ + `(scope: ${scope.mode}${scope.workspace_ids.length ? `, covering ${scope.workspace_ids.join(', ')}` : ''}). `
67
+ + 'If it exists but is out of scope, re-authenticate with broader scope: `solidactions login --device`.'));
68
+ }
69
+ else {
70
+ console.error(chalk_1.default.red(`Workspace "${input}" not found. Run \`solidactions workspace list\` to list available workspaces.`));
71
+ }
59
72
  process.exit(1);
60
73
  }
61
74
  return match;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -33,24 +33,27 @@
33
33
  ],
34
34
  "scripts": {
35
35
  "build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs",
36
+ "check:release": "npm run build && npm run test && npm run smoke:init",
36
37
  "prepublishOnly": "npm run build",
38
+ "smoke:init": "node scripts/smoke-init.mjs",
37
39
  "test": "vitest run",
38
40
  "test:watch": "vitest"
39
41
  },
40
42
  "dependencies": {
41
43
  "archiver": "^7.0.0",
42
- "axios": "^1.6.0",
44
+ "axios": "^1.18.1",
43
45
  "chalk": "^4.1.2",
44
46
  "commander": "^11.0.0",
45
47
  "dotenv": "^17.3.1",
46
- "form-data": "^4.0.0",
48
+ "form-data": "^4.0.6",
47
49
  "fs-extra": "^11.0.0",
48
50
  "ignore": "^7.0.5",
49
- "js-yaml": "^4.1.0",
51
+ "js-yaml": "^4.3.0",
50
52
  "prompts": "^2.4.2",
51
- "tar": "^7.5.12"
53
+ "tar": "^7.5.20"
52
54
  },
53
55
  "devDependencies": {
56
+ "@solidactions/sdk": "^0.7.3",
54
57
  "@types/archiver": "^6.0.0",
55
58
  "@types/fs-extra": "^11.0.0",
56
59
  "@types/js-yaml": "^4.0.9",