@solidactions/cli 3.13.0 → 3.14.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/README.md CHANGED
@@ -35,7 +35,8 @@ solidactions run start my-project hello -e production -i '{"name":"Ada"}' --wait
35
35
 
36
36
  The generated `hello` workflow requires no third-party credentials. A successful
37
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.
38
+ command with `solidactions run view <run-id>` (accepts the numeric run id or
39
+ the run UUID) or open the run in the app.
39
40
 
40
41
  For non-interactive automation, explicitly read the key from stdin instead of
41
42
  placing it in argv:
@@ -151,6 +152,59 @@ For each field (`host`, `apiKey`, `workspaceId`), the CLI resolves independently
151
152
 
152
153
  You can mix: e.g., set only `SOLIDACTIONS_WORKSPACE_ID` in the environment while letting `host` and `apiKey` come from a file.
153
154
 
155
+ ### Workspace safety
156
+
157
+ Resolution order layers 2 and 3 mean the active workspace can come from *where you are
158
+ standing*: a `./.solidactions/config.json` in the current folder or any ancestor. That's
159
+ convenient in a single project, but running a command from the wrong directory can silently
160
+ target a different workspace than the one you last used.
161
+
162
+ The CLI remembers the workspace it last **wrote** to in `~/.solidactions/state.json` (a
163
+ cosmetic/advisory file — deleting it just means the next command has nothing to compare
164
+ against). Read-only commands never update it — a read must never consume the change that
165
+ gates a write, so the warning below keeps firing until you actually write. When a
166
+ CWD-inferred workspace differs from that last-written-to one, the CLI warns:
167
+
168
+ ```
169
+ warn: workspace changed to <name> — organization <org> (<workspaceId>) — inferred from <path>; last used was <last-used-name-or-id>. Pin it with -w <workspaceId>.
170
+ ```
171
+
172
+ For commands that **write** to the server, it also asks for confirmation before proceeding:
173
+
174
+ ```
175
+ This command WRITES to <name> — organization <org> (<workspaceId>). Proceed?
176
+ ```
177
+
178
+ Consent to a workspace is exactly two things: stating it explicitly with
179
+ `-w <id-or-slug-or-name>` or `SOLIDACTIONS_WORKSPACE_ID` (either of which skips the prompt
180
+ entirely), or answering the prompt. A command's **own** `--yes` is not workspace consent — it
181
+ acknowledges that command's own destructive act (`database push` requires `-y`, `database
182
+ pull --yes` means "overwrite the local file") and says nothing about which workspace you meant. A
183
+ non-interactive shell is refused rather than guessed:
184
+
185
+ ```
186
+ re-run with -w <workspaceId> to confirm the target workspace
187
+ ```
188
+
189
+ **Breaking change for existing non-interactive automation.** A script, cron job, or CI step
190
+ that writes from a directory whose `.solidactions/config.json` supplies the workspace, without
191
+ passing `-w` or setting `SOLIDACTIONS_WORKSPACE_ID`, now **exits 1** as soon as
192
+ `~/.solidactions/state.json` records a different workspace as the last one written to. On a
193
+ persistent runner that is not only the first run: any run after the box has written to some
194
+ other workspace — a second project's job, a manual command in another folder — will refuse,
195
+ because the guard compares against whatever was written last, not against a per-directory
196
+ memory. Passing `-w <id>` (or exporting `SOLIDACTIONS_WORKSPACE_ID`) restores the previous
197
+ behaviour and is the recommended fix for every non-interactive caller; it is also what the
198
+ refusal message tells you to do. Deleting `state.json` silences one run, not the next.
199
+
200
+ Read-only commands are never prompted — at most they print the `warn:` line above. Every
201
+ mutating command prints its resolved workspace, organization-qualified, as its first output
202
+ line:
203
+
204
+ ```
205
+ Workspace: <name> — organization <org> (<workspaceId>)
206
+ ```
207
+
154
208
  ### `solidactions login` flags
155
209
 
156
210
  - With no positional argument, `login` securely prompts for the API key using
@@ -288,7 +342,7 @@ its project or schedule.
288
342
  |---------|-----------|-------------|
289
343
  | `run start <project> <workflow>` | `-e`, `-i`, `--wait` | Trigger a workflow run |
290
344
  | `run list [project]` | `--json`, `--detailed`, `--status`, `--since`, `--workflow`, `--limit`, `--offset` | List and filter runs |
291
- | `run view <run-id>` | `--json`, `--timeline`, `--steps`, `--logs` | Inspect a run, incl. the deployed revision (`Revision (latest session): ...`, or `deployed_revision` under `--json`) |
345
+ | `run view <run-id>` | `--json`, `--timeline`, `--steps`, `--logs` | Inspect a run (accepts the numeric run id or the run UUID), incl. the deployed revision (`Revision (latest session): ...`, or `deployed_revision` under `--json`) |
292
346
 
293
347
  ### env
294
348
 
@@ -392,6 +446,8 @@ You do **not** need `--overwrite` to keep an edited file whose doc was deleted o
392
446
  | `workspace list` | List all workspaces |
393
447
  | `workspace set <id>` | Set active workspace (by ID, slug, or name) |
394
448
 
449
+ **A name that's ambiguous is refused, not guessed.** If the name is shared across two organizations, or is also the name of an organization that owns other workspaces, `workspace set` refuses (exit 1) and lists the candidates — re-run with the workspace's slug or ID instead. Slugs are unique only within an organization, so when the candidates don't have distinct slugs of their own — including when the ambiguous input *was* a slug shared by two organizations — the refusal asks for the ID specifically, which is the only handle that can separate them.
450
+
395
451
  ### ai
396
452
 
397
453
  | Command | Key Flags | Description |
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "cli_name": "solidactions",
4
- "cli_version": "3.13.0",
4
+ "cli_version": "3.14.0",
5
5
  "global_options": [
6
6
  {
7
7
  "flags": "-V, --version",
@@ -19,7 +19,7 @@
19
19
  "flags": "-w, --workspace-override <id-or-slug-or-name>",
20
20
  "long": "--workspace-override",
21
21
  "short": "-w",
22
- "description": "Override active workspace for this command (short form: -w)",
22
+ "description": "Override active workspace for this command (short form: -w; also skips the CWD-inference prompt)",
23
23
  "required": false,
24
24
  "value_required": true,
25
25
  "value_optional": false,
@@ -1978,7 +1978,7 @@
1978
1978
  "name": "run-id",
1979
1979
  "required": true,
1980
1980
  "variadic": false,
1981
- "description": "Run ID"
1981
+ "description": "Run ID (numeric id or run UUID)"
1982
1982
  }
1983
1983
  ],
1984
1984
  "options": [
@@ -11,6 +11,7 @@ exports.isConfirmationMatch = isConfirmationMatch;
11
11
  exports.confirmDeploymentWithRetry = confirmDeploymentWithRetry;
12
12
  exports.formatDeploymentConfirmation = formatDeploymentConfirmation;
13
13
  exports.safeCollectSourceMetadata = safeCollectSourceMetadata;
14
+ exports.formatSyncYamlWarnings = formatSyncYamlWarnings;
14
15
  exports.pushYamlDeclarations = pushYamlDeclarations;
15
16
  exports.shouldPrintWorkspaceMismatch = shouldPrintWorkspaceMismatch;
16
17
  exports.isPlanLimitReachedError = isPlanLimitReachedError;
@@ -212,6 +213,36 @@ function safeCollectSourceMetadata(sourceDir, options, collector = source_proven
212
213
  return null;
213
214
  }
214
215
  }
216
+ /**
217
+ * Turns the raw `warnings` array from the sync-yaml response into
218
+ * human-readable lines. Pure, defensive: any non-array input (undefined,
219
+ * null, an object, a string) yields `[]`, and an unrecognized/future
220
+ * `reason` still produces a readable line instead of crashing or printing
221
+ * "undefined" (app#1150).
222
+ */
223
+ function formatSyncYamlWarnings(warnings) {
224
+ if (!Array.isArray(warnings)) {
225
+ return [];
226
+ }
227
+ return warnings.map((warning) => {
228
+ const envName = warning?.env_name ?? 'unknown';
229
+ // The server always sends `key`/`name` alongside its reason; if one is
230
+ // ever missing, fall through to the generic line rather than naming the
231
+ // unresolved resource "undefined".
232
+ const target = warning?.key ?? warning?.name;
233
+ if (typeof target === 'string' && target !== '') {
234
+ switch (warning?.reason) {
235
+ case 'global_variable_not_found_in_workspace':
236
+ return `${envName} → no workspace variable with key "${target}"`;
237
+ case 'oauth_connection_not_found_in_workspace':
238
+ return `${envName} → no OAuth connection named "${target}"`;
239
+ case 'workspace_database_not_found_in_workspace':
240
+ return `${envName} → no workspace database named "${target}"`;
241
+ }
242
+ }
243
+ return `${envName} → unresolved (${warning?.reason ?? 'unknown reason'})`;
244
+ });
245
+ }
215
246
  /**
216
247
  * Push YAML env declarations to the project.
217
248
  * This registers all YAML-declared vars and their mappings.
@@ -234,10 +265,29 @@ async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
234
265
  yaml_default_database_name: v.databaseName,
235
266
  source: 'yaml',
236
267
  }));
237
- await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations }, {
268
+ const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations }, {
238
269
  headers: (0, api_1.getApiHeaders)(config, 'application/json'),
239
270
  });
240
- console.log(chalk_1.default.gray(`Synced ${declarations.length} YAML env declarations`));
271
+ // Non-fatal: a warning means a declared resource doesn't exist in the
272
+ // workspace yet, not that the sync failed (app#1150).
273
+ const body = response?.data;
274
+ const rawWarnings = (body !== null && typeof body === 'object') ? body.warnings : undefined;
275
+ const warnings = formatSyncYamlWarnings(rawWarnings);
276
+ const unresolvedSuffix = warnings.length > 0 ? ` (${warnings.length} unresolved)` : '';
277
+ console.log(chalk_1.default.gray(`Synced ${declarations.length} YAML env declarations${unresolvedSuffix}`));
278
+ // A `warnings` key that isn't an array means the response shape changed
279
+ // under us. Say so rather than silently reporting plain success, which is
280
+ // the exact bug app#1150 fixed. An ABSENT key is not a surprise — an older
281
+ // server simply doesn't send one — so it stays quiet.
282
+ if (rawWarnings !== undefined && !Array.isArray(rawWarnings)) {
283
+ console.log(chalk_1.default.gray(' Server returned warnings in an unrecognized shape; unresolved declarations may not be listed.'));
284
+ }
285
+ for (const warning of warnings) {
286
+ console.log(chalk_1.default.yellow(` ⚠ ${warning}`));
287
+ }
288
+ if (warnings.length > 0) {
289
+ console.log(chalk_1.default.yellow(" These variables won't get a value from this declaration until the named resource exists (a value set in the dashboard still applies)."));
290
+ }
241
291
  }
242
292
  /**
243
293
  * Returns true only when a 404 on the environment-specific project lookup
@@ -223,29 +223,87 @@ function loginHostLines(resolved) {
223
223
  * already-fetched list, persist the final config, and print success output.
224
224
  * Device login passes its already-written, preflighted destination.
225
225
  */
226
- async function completeLogin(config, workspaces, options, scope = null, preflight = null) {
226
+ async function completeLogin(config, workspaces, options, scope = null, preflight = null, dependencies = {}) {
227
227
  // Device-flow tokens carry a scope (mode + workspace_ids) that later
228
228
  // gates `workspace set`; absent for user-scoped Sanctum PATs.
229
229
  if (scope) {
230
230
  config.scopeMode = scope.mode;
231
231
  config.scopedWorkspaceIds = scope.workspace_ids;
232
232
  }
233
+ // A --workspace the resolver refuses (not-found, ambiguous, or org-only)
234
+ // never reaches writeConfigFile below on an API-key login, so it must exit
235
+ // before the destination/confirm/backup block runs — otherwise the block
236
+ // backs up and claims to overwrite a config that was never touched
237
+ // (app#1197 finding 1). Device login (preflight set) keeps its own
238
+ // --workspace-refusal handling below, which persists the credential first.
239
+ if (!preflight && options.workspace) {
240
+ const preflightMatch = (0, workspace_lookup_1.classifyWorkspaceInput)(options.workspace, workspaces);
241
+ if (preflightMatch.kind !== 'match') {
242
+ console.error(chalk_1.default.red((0, workspace_lookup_1.describeWorkspaceMatchFailure)(preflightMatch)));
243
+ process.exit(1);
244
+ return;
245
+ }
246
+ }
247
+ // Decide the destination and confirm any destructive overwrite BEFORE
248
+ // workspace resolution (including the interactive picker), so the y/N
249
+ // lands before the user has done the picker work, not after (app#1197).
250
+ // Device login has already persisted its base credential via a preflight.
251
+ let target;
252
+ let targetPath;
253
+ let sameCredentialExisting = null;
254
+ if (!preflight) {
255
+ target = await (0, config_write_target_1.decideWriteTarget)({ local: options.local, global: options.global }, undefined, LOGIN_REFUSAL_MESSAGE);
256
+ targetPath = (0, config_write_target_1.pathForTarget)(target);
257
+ // The final config (which gains workspace/workspaceId) isn't known
258
+ // until the workspace is chosen below, so we can't byte-compare
259
+ // against it here. Compare credentials instead — the guard exists to
260
+ // protect a *different* account's config from being clobbered.
261
+ const existingRaw = fs_1.default.existsSync(targetPath) ? fs_1.default.readFileSync(targetPath, 'utf-8') : null;
262
+ let isDestructive = false;
263
+ if (existingRaw !== null) {
264
+ try {
265
+ const existing = JSON.parse(existingRaw);
266
+ isDestructive = existing.host !== config.host || existing.apiKey !== config.apiKey;
267
+ if (!isDestructive) {
268
+ sameCredentialExisting = existing;
269
+ }
270
+ }
271
+ catch {
272
+ isDestructive = true;
273
+ }
274
+ }
275
+ if (isDestructive) {
276
+ const backupPath = backupPathFor(targetPath);
277
+ const proceed = await (0, config_write_target_1.confirmOverwrite)(targetPath, backupPath, { question: dependencies.overwriteQuestion });
278
+ if (!proceed) {
279
+ console.log(chalk_1.default.yellow('Aborted. No changes were made.'));
280
+ process.exit(0);
281
+ }
282
+ fs_1.default.copyFileSync(targetPath, backupPath);
283
+ console.log(chalk_1.default.gray(`Backup saved to ${backupPath}`));
284
+ }
285
+ }
233
286
  // Resolve the workspace. Device login has already persisted its base
234
287
  // credential; API-key login still resolves before its first write.
235
288
  if (options.workspace) {
236
- const match = (0, workspace_lookup_1.matchWorkspace)(options.workspace, workspaces);
237
- if (!match) {
238
- if (preflight?.credentialPersisted) {
239
- (0, config_1.writeConfigFile)(preflight.targetPath, config);
240
- console.error(chalk_1.default.yellow(`Workspace "${options.workspace}" was not found. Authentication was saved to ${preflight.targetPath}.`));
241
- console.error(chalk_1.default.yellow('Run `solidactions workspace list`, then `solidactions workspace set <name>` to finish setup.'));
242
- }
243
- else {
244
- console.error(chalk_1.default.red(`Workspace "${options.workspace}" not found. Run \`solidactions workspace list\` to list available workspaces.`));
245
- }
289
+ const result = (0, workspace_lookup_1.classifyWorkspaceInput)(options.workspace, workspaces);
290
+ if (result.kind !== 'match') {
291
+ // Device login only. The pre-write guard above exits every
292
+ // `!preflight` refusal, and the sole preflight caller
293
+ // (`device-login`) runs `persistPreflightedLoginCredential` —
294
+ // which sets `credentialPersisted` unconditionally — before
295
+ // calling in, so the credential is always already on disk here.
296
+ // Hence no `credentialPersisted` test and no non-preflight
297
+ // fallback: that branch was unreachable and only duplicated the
298
+ // guard's copy.
299
+ (0, config_1.writeConfigFile)(preflight.targetPath, config);
300
+ console.error(chalk_1.default.yellow((0, workspace_lookup_1.describeWorkspaceMatchFailure)(result)));
301
+ console.error(chalk_1.default.yellow(`Authentication was saved to ${preflight.targetPath}.`));
302
+ console.error(chalk_1.default.yellow('Run `solidactions workspace list`, then `solidactions workspace set <name>` to finish setup.'));
246
303
  process.exit(1);
247
304
  return;
248
305
  }
306
+ const match = result.workspace;
249
307
  config.workspace = match.slug ?? match.name;
250
308
  config.workspaceId = match.id;
251
309
  }
@@ -260,7 +318,8 @@ async function completeLogin(config, workspaces, options, scope = null, prefligh
260
318
  + 'run `solidactions workspace set <name>`.'));
261
319
  }
262
320
  else if (process.stdin.isTTY) {
263
- const selected = await (0, workspace_lookup_1.selectWorkspaceInteractively)(workspaces);
321
+ const selectWorkspace = dependencies.selectWorkspace ?? workspace_lookup_1.selectWorkspaceInteractively;
322
+ const selected = await selectWorkspace(workspaces);
264
323
  if (selected) {
265
324
  config.workspace = selected.slug ?? selected.name;
266
325
  config.workspaceId = selected.id;
@@ -270,43 +329,52 @@ async function completeLogin(config, workspaces, options, scope = null, prefligh
270
329
  console.log(chalk_1.default.yellow('Multiple workspaces are available, so no workspace was selected. '
271
330
  + 'Run `solidactions workspace list`, then `solidactions workspace set <name>`.'));
272
331
  }
332
+ // `writeConfigFile` writes the config wholesale, and the credentials-only
333
+ // compare above cannot see a workspace pin going missing — so a
334
+ // same-credential re-login that resolves no workspace of its own (picker
335
+ // cancelled, or non-interactive with several workspaces) used to delete an
336
+ // existing pin silently: no prompt and no .bak, because identical
337
+ // credentials are not "destructive". The pin is still valid for this exact
338
+ // account, so carry every workspace field forward instead. Deliberately
339
+ // gated on unchanged credentials: when they differ, the pin belongs to a
340
+ // different account and that path is already prompted and backed up.
341
+ if (!config.workspaceId && sameCredentialExisting?.workspaceId) {
342
+ config.workspace = sameCredentialExisting.workspace;
343
+ config.workspaceId = sameCredentialExisting.workspaceId;
344
+ config.workspaceOrg = sameCredentialExisting.workspaceOrg;
345
+ console.log(chalk_1.default.gray(`Keeping the workspace already pinned in this config: ${config.workspace ?? config.workspaceId}`));
346
+ }
273
347
  let savedTargetPath;
274
348
  if (preflight) {
275
349
  savedTargetPath = preflight.targetPath;
276
350
  (0, config_1.writeConfigFile)(preflight.targetPath, config);
277
351
  }
278
352
  else {
279
- const target = await (0, config_write_target_1.decideWriteTarget)({ local: options.local, global: options.global }, undefined, LOGIN_REFUSAL_MESSAGE);
280
- const targetPath = (0, config_write_target_1.pathForTarget)(target);
281
353
  savedTargetPath = targetPath;
282
- const existingRaw = fs_1.default.existsSync(targetPath) ? fs_1.default.readFileSync(targetPath, 'utf-8') : null;
283
- const wouldChange = existingRaw !== null && existingRaw.trim() !== JSON.stringify(config, null, 2).trim();
284
- if (wouldChange) {
285
- const backupPath = backupPathFor(targetPath);
286
- const proceed = await (0, config_write_target_1.confirmOverwrite)(targetPath, backupPath);
287
- if (!proceed) {
288
- console.log(chalk_1.default.yellow('Aborted. No changes were made.'));
289
- process.exit(0);
290
- }
291
- fs_1.default.copyFileSync(targetPath, backupPath);
292
- console.log(chalk_1.default.gray(`Backup saved to ${backupPath}`));
293
- }
294
354
  (0, config_1.writeConfigFile)(targetPath, config);
295
355
  if (target === 'local') {
296
356
  await (0, config_write_target_1.ensureGitignoreCovers)(process.cwd(), !!options.gitignore);
297
357
  }
298
358
  }
299
- console.log(chalk_1.default.green('Logged in successfully!'));
300
- console.log(chalk_1.default.gray(`Configuration saved to ${savedTargetPath}`));
301
- console.log('');
302
- console.log(chalk_1.default.blue('Next step — scaffold a new project (includes AI tooling):'));
303
- console.log(chalk_1.default.gray(' solidactions init <project-name> Creates ./<project-name>/ with scaffold + AI skills'));
304
- console.log(chalk_1.default.gray(' solidactions init Scaffolds in the current (empty) directory'));
305
- console.log('');
306
- console.log(chalk_1.default.blue('Quick start:'));
307
- console.log(chalk_1.default.gray(' solidactions project deploy <name> Deploy current directory'));
308
- console.log(chalk_1.default.gray(' solidactions run start <proj> <wf> Run a workflow'));
309
- console.log(chalk_1.default.gray(' solidactions run list List recent runs'));
359
+ if (config.workspaceId) {
360
+ console.log(chalk_1.default.green('Logged in successfully!'));
361
+ console.log(chalk_1.default.gray(`Configuration saved to ${savedTargetPath}`));
362
+ console.log('');
363
+ console.log(chalk_1.default.blue('Next step — scaffold a new project (includes AI tooling):'));
364
+ console.log(chalk_1.default.gray(' solidactions init <project-name> Creates ./<project-name>/ with scaffold + AI skills'));
365
+ console.log(chalk_1.default.gray(' solidactions init Scaffolds in the current (empty) directory'));
366
+ console.log('');
367
+ console.log(chalk_1.default.blue('Quick start:'));
368
+ console.log(chalk_1.default.gray(' solidactions project deploy <name> Deploy current directory'));
369
+ console.log(chalk_1.default.gray(' solidactions run start <proj> <wf> Run a workflow'));
370
+ console.log(chalk_1.default.gray(' solidactions run list List recent runs'));
371
+ }
372
+ else {
373
+ console.log(chalk_1.default.yellow(`Authentication saved to ${savedTargetPath}.`));
374
+ if (workspaces.length > 0) {
375
+ console.log(chalk_1.default.yellow('Run `solidactions workspace list`, then `solidactions workspace set <name>` to finish setup.'));
376
+ }
377
+ }
310
378
  }
311
379
  async function login(apiKey, options) {
312
380
  const resolved = resolveLoginHost(options);
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const api_1 = require("../utils/api");
10
10
  const table_1 = require("../utils/table");
11
+ const source_provenance_1 = require("../utils/source-provenance");
11
12
  function projectEnvironments(project) {
12
13
  const details = project.environment_details;
13
14
  if (Array.isArray(details) && details.length > 0) {
@@ -46,10 +47,11 @@ async function projectList(options = {}) {
46
47
  project.name || '?',
47
48
  project.status || '?',
48
49
  project.snapshot_name || '-',
50
+ (0, source_provenance_1.formatRevisionCell)(project.deployed_revision ?? null),
49
51
  environmentCells[index],
50
52
  ]);
51
- const lines = (0, table_1.renderTable)(['NAME', 'STATUS', 'SNAPSHOT', 'ENVIRONMENTS'], rows, {
52
- minWidths: [25, 15, 30],
53
+ const lines = (0, table_1.renderTable)(['NAME', 'STATUS', 'SNAPSHOT', 'REVISION', 'ENVIRONMENTS'], rows, {
54
+ minWidths: [25, 15, 30, 14],
53
55
  });
54
56
  console.log(chalk_1.default.gray(lines[0]));
55
57
  console.log(chalk_1.default.gray(lines[1]));
@@ -60,6 +62,7 @@ async function projectList(options = {}) {
60
62
  console.log(prefix + colorizeEnvironmentStates(environmentCell));
61
63
  }
62
64
  console.log('');
65
+ console.log(chalk_1.default.gray('REVISION shows the latest successful deployment: * dirty, ? dirty state unknown, ↓N behind default branch at deploy.'));
63
66
  console.log(chalk_1.default.gray(`${projects.length} project(s)`));
64
67
  }
65
68
  catch (error) {
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.projectViewJsonProjection = projectViewJsonProjection;
7
+ exports.quoteCommandArg = quoteCommandArg;
7
8
  exports.projectSlugForView = projectSlugForView;
8
9
  exports.formatDeploymentRevision = formatDeploymentRevision;
9
10
  exports.formatProjectView = formatProjectView;
@@ -55,6 +56,14 @@ function projectViewJsonProjection(project) {
55
56
  latest_successful_deployment: deployment === null ? null : deploymentJsonProjection(deployment),
56
57
  };
57
58
  }
59
+ /**
60
+ * Quote a copy-pasteable command argument so the printed remedy survives a
61
+ * shell. Slugs from the API are normally bare words needing nothing; anything
62
+ * with whitespace or shell metacharacters gets single-quoted.
63
+ */
64
+ function quoteCommandArg(arg) {
65
+ return /^[A-Za-z0-9._/-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, "'\\''")}'`;
66
+ }
58
67
  function projectSlugForView(project, environment) {
59
68
  if (environment === undefined) {
60
69
  return project;
@@ -141,9 +150,10 @@ function formatProjectView(project) {
141
150
  return lines;
142
151
  }
143
152
  async function projectViewWithConfig(project, options, config, writeLine = console.log) {
153
+ const environment = options.env ?? 'dev';
144
154
  let slug;
145
155
  try {
146
- slug = projectSlugForView(project, options.env ?? 'dev');
156
+ slug = projectSlugForView(project, environment);
147
157
  }
148
158
  catch (error) {
149
159
  console.error(chalk_1.default.red(error.message));
@@ -166,9 +176,30 @@ async function projectViewWithConfig(project, options, config, writeLine = conso
166
176
  console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
167
177
  }
168
178
  else if (error.response?.status === 404) {
169
- const message = (0, source_provenance_1.sanitizeDisplayText)(error.response.data?.message, 500)
170
- ?? `Project "${slug}" not found.`;
171
- console.error(chalk_1.default.red(message));
179
+ const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, project);
180
+ const envs = family?.environments ?? [];
181
+ // Only claim the environment is missing when the family genuinely lacks it.
182
+ // `GET /api/v1/projects` can report the requested environment (a standalone
183
+ // env row, or a row created before its deployment landed) while the detail
184
+ // endpoint 404s for that exact slug; asserting "has no dev environment"
185
+ // against a list that says dev exists is self-contradictory, so let the
186
+ // server's own message through instead.
187
+ if (envs.length > 0 && !envs.includes(environment)) {
188
+ const suggested = envs.includes('production') ? 'production' : envs[0];
189
+ // The remedy must name the environment's REAL slug: `project view` passes a
190
+ // production argument through un-slugified, so echoing back a name-typed
191
+ // argument ("My App") would print a command that 404s in its turn.
192
+ const suggestedSlug = (0, source_provenance_1.sanitizeDisplayText)(family?.slugs[suggested], 255);
193
+ console.error(chalk_1.default.red(`Project "${project}" has no ${environment} environment (exists in: ${envs.join(', ')}).`));
194
+ if (suggestedSlug) {
195
+ console.error(` solidactions project view ${quoteCommandArg(suggestedSlug)} -e ${suggested}`);
196
+ }
197
+ }
198
+ else {
199
+ const message = (0, source_provenance_1.sanitizeDisplayText)(error.response.data?.message, 500)
200
+ ?? `Project "${slug}" not found.`;
201
+ console.error(chalk_1.default.red(message));
202
+ }
172
203
  }
173
204
  else if (error.response) {
174
205
  console.error(chalk_1.default.red(`Failed to view project: ${error.response.status}`));
@@ -3,12 +3,11 @@ 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.formatDetailedRevision = void 0;
6
+ exports.formatRevisionCell = exports.formatDetailedRevision = void 0;
7
7
  exports.buildRunListParams = buildRunListParams;
8
8
  exports.runs = runs;
9
9
  exports.summaryStatusLabel = summaryStatusLabel;
10
10
  exports.detailedOutcomeTag = detailedOutcomeTag;
11
- exports.formatRevisionCell = formatRevisionCell;
12
11
  exports.displaySummaryTable = displaySummaryTable;
13
12
  exports.displayDetailedList = displayDetailedList;
14
13
  const axios_1 = __importDefault(require("axios"));
@@ -18,6 +17,7 @@ const table_1 = require("../utils/table");
18
17
  const source_provenance_1 = require("../utils/source-provenance");
19
18
  var source_provenance_2 = require("../utils/source-provenance");
20
19
  Object.defineProperty(exports, "formatDetailedRevision", { enumerable: true, get: function () { return source_provenance_2.formatDetailedRevision; } });
20
+ Object.defineProperty(exports, "formatRevisionCell", { enumerable: true, get: function () { return source_provenance_2.formatRevisionCell; } });
21
21
  /**
22
22
  * Build the params object for GET /api/v1/runs.
23
23
  * Extracted as a pure function so it can be unit-tested without mocking axios.
@@ -128,18 +128,6 @@ function detailedOutcomeTag(run) {
128
128
  return ' [DEGRADED]';
129
129
  return '';
130
130
  }
131
- function formatRevisionCell(revision) {
132
- const sha = (0, source_provenance_1.revisionSha)(revision);
133
- if (!sha)
134
- return '-';
135
- const dirty = revision?.dirty === true ? '*' : revision?.dirty === false ? '' : '?';
136
- const behind = typeof revision?.commits_behind === 'number'
137
- && Number.isSafeInteger(revision.commits_behind)
138
- && revision.commits_behind > 0
139
- ? ` ↓${revision.commits_behind}`
140
- : '';
141
- return (0, table_1.sanitizeCell)(`${sha}${dirty}${behind}`);
142
- }
143
131
  function displaySummaryTable(runsList, projectName) {
144
132
  const header = projectName ? `Recent runs for "${projectName}":` : 'Recent runs:';
145
133
  console.log(chalk_1.default.blue(header));
@@ -152,7 +140,7 @@ function displaySummaryTable(runsList, projectName) {
152
140
  String(run.id || '?'),
153
141
  (0, table_1.sanitizeCell)((0, table_1.truncateCell)(run.workflow_name || '?', 24)),
154
142
  status,
155
- formatRevisionCell(run.deployed_revision ?? null),
143
+ (0, source_provenance_1.formatRevisionCell)(run.deployed_revision ?? null),
156
144
  triggeredAt,
157
145
  (0, table_1.sanitizeCell)(run.triggered_by || '-'),
158
146
  ];
@@ -12,16 +12,20 @@ const axios_1 = __importDefault(require("axios"));
12
12
  const chalk_1 = __importDefault(require("chalk"));
13
13
  const api_1 = require("../utils/api");
14
14
  const source_provenance_1 = require("../utils/source-provenance");
15
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
15
16
  async function runView(runId, options) {
16
- if (!/^\d+$/.test(runId)) {
17
- console.error(chalk_1.default.red(`Invalid run id: "${runId}" (run ids are numeric — see \`solidactions run list\`).`));
17
+ if (!/^\d+$/.test(runId) && !UUID_PATTERN.test(runId)) {
18
+ console.error(chalk_1.default.red(`Invalid run id: "${runId}" (expected a numeric run id or a run UUID — see \`solidactions run list\`).`));
18
19
  process.exit(1);
19
20
  return;
20
21
  }
22
+ // The server stores `run_uuid` lowercase and compares it verbatim, so an
23
+ // uppercase UUID must be normalized here or it would silently 404.
24
+ const resolvedRunId = UUID_PATTERN.test(runId) ? runId.toLowerCase() : runId;
21
25
  const config = await (0, api_1.requireConfigWithWorkspace)();
22
26
  try {
23
27
  // Fetch run data (includes session timing)
24
- const runResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}`, {
28
+ const runResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${resolvedRunId}`, {
25
29
  headers: (0, api_1.getApiHeaders)(config),
26
30
  });
27
31
  const runData = runResponse.data;
@@ -41,7 +45,7 @@ async function runView(runId, options) {
41
45
  };
42
46
  // --logs: fetch and display raw logs
43
47
  if (options.logs) {
44
- const logsResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}/logs`, {
48
+ const logsResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${resolvedRunId}/logs`, {
45
49
  headers: (0, api_1.getApiHeaders)(config),
46
50
  });
47
51
  const logData = logsResponse.data.logs || '';
@@ -55,7 +59,7 @@ async function runView(runId, options) {
55
59
  return;
56
60
  }
57
61
  // Fetch steps data
58
- const stepsResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}/steps`, {
62
+ const stepsResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${resolvedRunId}/steps`, {
59
63
  headers: (0, api_1.getApiHeaders)(config),
60
64
  });
61
65
  const stepsData = stepsResponse.data;
@@ -82,7 +86,7 @@ async function runView(runId, options) {
82
86
  }
83
87
  // Full view
84
88
  // Fetch logs for the full view
85
- const logsResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}/logs`, {
89
+ const logsResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${resolvedRunId}/logs`, {
86
90
  headers: (0, api_1.getApiHeaders)(config),
87
91
  });
88
92
  if (options.json) {
@@ -67,7 +67,7 @@ async function workspaceSet(input, options = {}) {
67
67
  const workspace = await (0, workspace_lookup_1.resolveWorkspaceInput)(config, input);
68
68
  const target = await (0, config_write_target_1.decideWriteTarget)({ local: options.local, global: options.global });
69
69
  const targetPath = (0, config_write_target_1.pathForTarget)(target);
70
- (0, config_1.writeWorkspaceToFile)(targetPath, workspace.slug ?? workspace.name, workspace.id);
70
+ (0, config_1.writeWorkspaceToFile)(targetPath, workspace.slug ?? workspace.name, workspace.id, workspace.org_name);
71
71
  if (target === 'local') {
72
72
  await (0, config_write_target_1.ensureGitignoreCovers)(process.cwd(), !!options.gitignore);
73
73
  }
package/dist/index.js CHANGED
@@ -95,6 +95,7 @@ const workflow_view_1 = require("./commands/workflow-view");
95
95
  const database_1 = require("./commands/database");
96
96
  const database_push_1 = require("./commands/database-push");
97
97
  const config_1 = require("./utils/config");
98
+ const mutating_commands_1 = require("./utils/mutating-commands");
98
99
  // eslint-disable-next-line @typescript-eslint/no-var-requires
99
100
  const pkg = require('../package.json');
100
101
  exports.program = new commander_1.Command();
@@ -130,8 +131,16 @@ exports.program
130
131
  // a parent option of the same name, so `login --workspace <x>` was being
131
132
  // swallowed by this global flag instead of reaching login()'s own option.
132
133
  // The short form `-w` is unaffected and remains the primary way to use this.
133
- exports.program.option('-w, --workspace-override <id-or-slug-or-name>', 'Override active workspace for this command (short form: -w)');
134
+ exports.program.option('-w, --workspace-override <id-or-slug-or-name>', 'Override active workspace for this command (short form: -w; also skips the CWD-inference prompt)');
134
135
  exports.program.hook('preAction', (thisCommand, actionCommand) => {
136
+ // Record the full commander path (e.g. ['project', 'deploy']) unconditionally —
137
+ // it feeds the workspace guard in requireConfigWithWorkspace() and must never be
138
+ // skipped by an early return below (e.g. the `workspace set` -w warning).
139
+ const commandPath = [];
140
+ for (let cmd = actionCommand; cmd && cmd !== exports.program; cmd = cmd.parent) {
141
+ commandPath.unshift(cmd.name());
142
+ }
143
+ (0, mutating_commands_1.setActiveCommandPath)(commandPath);
135
144
  const opts = thisCommand.opts();
136
145
  const wsOverride = opts.workspaceOverride;
137
146
  if (wsOverride) {
@@ -485,7 +494,7 @@ runCmd
485
494
  runCmd
486
495
  .command('view')
487
496
  .description('View details, timeline, steps, or logs for a workflow run')
488
- .argument('<run-id>', 'Run ID')
497
+ .argument('<run-id>', 'Run ID (numeric id or run UUID)')
489
498
  .option('--timeline', 'Show only timeline data')
490
499
  .option('--steps', 'Show only step data')
491
500
  .option('--logs', 'Show raw logs')