@solidactions/cli 3.7.0 → 3.9.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
@@ -212,7 +212,8 @@ env:
212
212
 
213
213
  - A global key, an `oauth:` name, and a `database:` name are **mutually exclusive**: bind each variable to exactly one. The platform enforces that server-side (HTTP 422), but do not rely on seeing that error: through CLI v3.6.0 the YAML parser keeps only the first form it recognizes — `oauth:` beats `database:` — so a declaration carrying both deploys silently as the wrong binding instead of failing.
214
214
  - `project deploy` (including `--config-only`) syncs the *complete* `env:` list to the server on every run. Any previously YAML-sourced mapping whose name no longer appears in the list is deleted — removing or emptying `env:` prunes those mappings on the next deploy. Only mappings that were never YAML-declared survive: overriding a YAML-declared variable with `env set`/`env map` doesn't change its provenance, so removing its declaration still deletes the mapping.
215
- - For a `database:` entry, the workflow receives a `DatabaseVar` at `ctx.vars.<NAME>` at runtime, typically wrapped with the SDK's `createDatabaseClient()`. See the SDK reference's [Workspace Databases](https://github.com/SolidActions/solidactions-ts-sdk/blob/main/docs/sdk-reference.md#workspace-databases) section for details.
215
+ - Create the workspace database first with `solidactions database create <name>` or in the web UI. Workspace-database bindings require `@solidactions/sdk >=0.8.0`.
216
+ - For a `database:` entry, the workflow receives a typed `DatabaseVar` at `ctx.vars.<NAME>` at runtime, typically wrapped with the SDK's `createDatabaseClient()`. The private transport payload uses `read_only`; SDK 0.8.0+ normalizes it to the public `DatabaseVar.readOnly` property. Use the typed SDK object rather than parsing the transport payload. See the SDK reference's [Workspace Databases](https://github.com/SolidActions/solidactions-ts-sdk/blob/main/docs/sdk-reference.md#workspace-databases) section for details.
216
217
 
217
218
  ## Commands
218
219
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "cli_name": "solidactions",
4
- "cli_version": "3.7.0",
4
+ "cli_version": "3.9.0",
5
5
  "global_options": [
6
6
  {
7
7
  "flags": "-V, --version",
@@ -2745,6 +2745,51 @@
2745
2745
  }
2746
2746
  ]
2747
2747
  },
2748
+ {
2749
+ "path": [
2750
+ "crew",
2751
+ "env",
2752
+ "map-database"
2753
+ ],
2754
+ "name": "map-database",
2755
+ "aliases": [],
2756
+ "description": "Map a workspace database into crew sandboxes",
2757
+ "hidden": false,
2758
+ "arguments": [
2759
+ {
2760
+ "name": "crew",
2761
+ "required": true,
2762
+ "variadic": false,
2763
+ "description": "Crew name or id"
2764
+ },
2765
+ {
2766
+ "name": "key",
2767
+ "required": true,
2768
+ "variadic": false,
2769
+ "description": "Variable key"
2770
+ },
2771
+ {
2772
+ "name": "database",
2773
+ "required": true,
2774
+ "variadic": false,
2775
+ "description": "Workspace database name or id"
2776
+ }
2777
+ ],
2778
+ "options": [
2779
+ {
2780
+ "flags": "-h, --help",
2781
+ "long": "--help",
2782
+ "short": "-h",
2783
+ "description": "display help for command",
2784
+ "required": false,
2785
+ "value_required": false,
2786
+ "value_optional": false,
2787
+ "variadic": false,
2788
+ "negated": false,
2789
+ "hidden": false
2790
+ }
2791
+ ]
2792
+ },
2748
2793
  {
2749
2794
  "path": [
2750
2795
  "crew",
@@ -33,7 +33,14 @@ async function crewEnvList(crewArg, options = {}) {
33
33
  });
34
34
  const variables = response.data?.data ?? [];
35
35
  if (options.json) {
36
- console.log(JSON.stringify(variables, null, 2));
36
+ const safeVariables = variables.map((variable) => {
37
+ if (variable.source_type !== 'workspace_database') {
38
+ return variable;
39
+ }
40
+ const { production_value: _productionValue, staging_value: _stagingValue, dev_value: _devValue, token: _token, ...metadata } = variable;
41
+ return metadata;
42
+ });
43
+ console.log(JSON.stringify(safeVariables, null, 2));
37
44
  return;
38
45
  }
39
46
  console.log(chalk_1.default.blue(`Variables for crew "${crew.name}":`));
@@ -50,11 +57,14 @@ async function crewEnvList(crewArg, options = {}) {
50
57
  console.log(chalk_1.default.gray('-'.repeat(100)));
51
58
  for (const variable of variables) {
52
59
  const key = variable.env_name || '?';
53
- const type = variable.is_secret ? chalk_1.default.yellow('secret') : chalk_1.default.gray('plain');
60
+ const isDatabase = variable.source_type === 'workspace_database';
61
+ const type = isDatabase
62
+ ? chalk_1.default.blue(`database:${variable.workspace_database_name ?? 'not-configured'}`)
63
+ : variable.is_secret ? chalk_1.default.yellow('secret') : chalk_1.default.gray('plain');
54
64
  console.log(key.substring(0, 22).padEnd(24) +
55
- formatValue(variable.production_value, variable.is_secret).padEnd(20) +
56
- formatValue(variable.staging_value, variable.is_secret).padEnd(20) +
57
- formatValue(variable.dev_value, variable.is_secret).padEnd(20) +
65
+ (isDatabase ? chalk_1.default.gray('-') : formatValue(variable.production_value, variable.is_secret)).padEnd(20) +
66
+ (isDatabase ? chalk_1.default.gray('-') : formatValue(variable.staging_value, variable.is_secret)).padEnd(20) +
67
+ (isDatabase ? chalk_1.default.gray('-') : formatValue(variable.dev_value, variable.is_secret)).padEnd(20) +
58
68
  type);
59
69
  }
60
70
  console.log('');
@@ -0,0 +1,58 @@
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.CREW_DATABASE_SCOPE_WARNING = void 0;
7
+ exports.matchWorkspaceDatabase = matchWorkspaceDatabase;
8
+ exports.crewEnvMapDatabase = crewEnvMapDatabase;
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const api_1 = require("../utils/api");
12
+ const crew_1 = require("../utils/crew");
13
+ const database_data_plane_1 = require("../utils/database-data-plane");
14
+ const env_1 = require("../utils/env");
15
+ exports.CREW_DATABASE_SCOPE_WARNING = 'Applies to production, staging, and dev crew sandboxes';
16
+ function matchWorkspaceDatabase(input, databases) {
17
+ return databases.find((database) => (database.deleted_at === null
18
+ && database.status === 'ready'
19
+ && (database.id === input || database.name.toLowerCase() === input.toLowerCase()))) ?? null;
20
+ }
21
+ async function crewEnvMapDatabase(crewArg, key, databaseArg) {
22
+ if (!(0, env_1.isValidEnvName)(key)) {
23
+ console.error(chalk_1.default.red((0, env_1.envNameError)(key)));
24
+ process.exit(1);
25
+ }
26
+ if ((0, env_1.isReservedEnvName)(key)) {
27
+ console.error(chalk_1.default.red((0, env_1.reservedEnvNameError)(key)));
28
+ process.exit(1);
29
+ }
30
+ const config = await (0, api_1.requireConfigWithWorkspace)();
31
+ const crew = await (0, crew_1.resolveCrewId)(config, crewArg);
32
+ try {
33
+ const result = await (0, database_data_plane_1.requestDatabaseOperation)(config, { operation: 'list' });
34
+ const database = matchWorkspaceDatabase(databaseArg, result.databases ?? []);
35
+ if (!database) {
36
+ console.error(chalk_1.default.red(`Ready database "${databaseArg}" not found in this workspace.`));
37
+ process.exit(1);
38
+ }
39
+ await axios_1.default.put(`${config.host}/api/v1/crews/${crew.id}/variables/${key}`, {
40
+ source_type: 'workspace_database',
41
+ workspace_database_id: database.id,
42
+ }, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
43
+ console.log(chalk_1.default.green(`Database "${database.name}" mapped to "${key}" for crew "${crew.name}".`));
44
+ console.log(chalk_1.default.yellow(exports.CREW_DATABASE_SCOPE_WARNING));
45
+ }
46
+ catch (error) {
47
+ if (error.response?.status === 422) {
48
+ console.error(chalk_1.default.red((0, api_1.formatValidationError)(error.response.data)));
49
+ }
50
+ else if (typeof error.message === 'string') {
51
+ console.error(chalk_1.default.red(error.message));
52
+ }
53
+ else {
54
+ console.error(chalk_1.default.red('Failed to map the workspace database.'));
55
+ }
56
+ process.exit(1);
57
+ }
58
+ }
@@ -125,6 +125,7 @@ function clientDependencies(dependencies) {
125
125
  }
126
126
  function stableDatabaseRecord(database) {
127
127
  if (!database
128
+ || (database.id !== undefined && typeof database.id !== 'string')
128
129
  || typeof database.name !== 'string'
129
130
  || typeof database.status !== 'string'
130
131
  || typeof database.size_bytes !== 'number'
@@ -133,6 +134,7 @@ function stableDatabaseRecord(database) {
133
134
  throw new database_data_plane_1.DatabaseOperationError('upstream_unavailable', 'The database response was invalid.');
134
135
  }
135
136
  return {
137
+ ...(database.id === undefined ? {} : { id: database.id }),
136
138
  name: database.name,
137
139
  status: database.status,
138
140
  deleted_at: database.deleted_at,
@@ -16,13 +16,46 @@ const login_1 = require("./login");
16
16
  const CLI_OAUTH_CLIENT_ID = '9f1b6e2a-9c1e-4b6e-8f0a-6c9f2b1e7d4c';
17
17
  // CLI capability scopes requested at device-code issuance — the server
18
18
  // rejects any scope not pre-registered via Passport::tokensCan().
19
- const CLI_SCOPES = 'env deploy runs docs databases';
19
+ //
20
+ // `env:reveal` is REQUESTED here but not necessarily GRANTED: the consent
21
+ // screen renders it as a default-off checkbox, and the server strips it from
22
+ // the issued token unless the user ticks it. Requesting it is what makes the
23
+ // opt-in reachable at all — a scope absent from this string can never be
24
+ // added at consent time, because the device code's scope set is frozen when
25
+ // the code is created (#1252).
26
+ const CLI_SCOPES_WITH_REVEAL = 'env env:reveal deploy runs docs databases';
27
+ // Pre-#1252 scope list, kept as the fallback for servers that haven't
28
+ // registered `env:reveal` yet (older production, a lagging staging, a
29
+ // self-hosted install). Passport rejects the entire device-code request with
30
+ // `invalid_scope` if ANY requested scope is unregistered, so requesting
31
+ // `env:reveal` unconditionally would hard-break device login everywhere
32
+ // until every server picks up the companion change.
33
+ const CLI_SCOPES_LEGACY = 'env deploy runs docs databases';
34
+ /**
35
+ * Request a device code with the full (env:reveal-including) scope list. If
36
+ * the server doesn't yet recognize `env:reveal` it rejects the whole request
37
+ * with 400 `invalid_scope` — retry once with the legacy scope list so login
38
+ * still succeeds. Any other rejection (e.g. a bad client_id) still fails
39
+ * loudly; only this specific, detectable condition is swallowed.
40
+ */
20
41
  async function requestDeviceCode(host) {
21
- const response = await axios_1.default.post(`${host}/oauth/device/code`, {
22
- client_id: CLI_OAUTH_CLIENT_ID,
23
- scope: CLI_SCOPES,
24
- });
25
- return response.data;
42
+ try {
43
+ const response = await axios_1.default.post(`${host}/oauth/device/code`, {
44
+ client_id: CLI_OAUTH_CLIENT_ID,
45
+ scope: CLI_SCOPES_WITH_REVEAL,
46
+ });
47
+ return response.data;
48
+ }
49
+ catch (e) {
50
+ if (e?.response?.status === 400 && e.response.data?.error === 'invalid_scope') {
51
+ const response = await axios_1.default.post(`${host}/oauth/device/code`, {
52
+ client_id: CLI_OAUTH_CLIENT_ID,
53
+ scope: CLI_SCOPES_LEGACY,
54
+ });
55
+ return response.data;
56
+ }
57
+ throw e;
58
+ }
26
59
  }
27
60
  function sleep(ms) {
28
61
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -56,7 +56,7 @@ async function envList(projectName, options = {}) {
56
56
  const key = mapping.env_name || '?';
57
57
  // Value display (resolved_value includes global/oauth resolution)
58
58
  const rawValue = mapping.resolved_value ?? mapping.value;
59
- const value = mapping.is_secret ? '••••••' : rawValue ? rawValue.toString() : '-';
59
+ let value = mapping.is_secret ? '••••••' : rawValue ? rawValue.toString() : '-';
60
60
  // Type & source (mirrors UI getMappingType)
61
61
  let type;
62
62
  let source;
@@ -64,6 +64,19 @@ async function envList(projectName, options = {}) {
64
64
  type = 'oauth';
65
65
  source = mapping.oauth_connection_name || 'OAuth';
66
66
  }
67
+ else if (mapping.source_type === 'workspace_database') {
68
+ value = '-';
69
+ type = 'database';
70
+ if (mapping.workspace_database_broken) {
71
+ const databaseName = mapping.yaml_default_workspace_database_name || 'Database';
72
+ source = `${databaseName} (missing)`;
73
+ }
74
+ else {
75
+ source = mapping.workspace_database_name
76
+ || mapping.yaml_default_workspace_database_name
77
+ || 'Database';
78
+ }
79
+ }
67
80
  else if (mapping.global_variable_key) {
68
81
  type = 'global';
69
82
  source = mapping.global_variable_key;
@@ -72,6 +85,13 @@ async function envList(projectName, options = {}) {
72
85
  type = 'project var';
73
86
  source = 'local';
74
87
  }
88
+ else if (typeof mapping.yaml_default_workspace_database_name === 'string'
89
+ && mapping.yaml_default_workspace_database_name.length > 0
90
+ && mapping.yaml_default_not_found === true) {
91
+ value = '-';
92
+ type = 'database';
93
+ source = `${mapping.yaml_default_workspace_database_name} (not configured)`;
94
+ }
75
95
  else {
76
96
  type = '-';
77
97
  source = '-';
@@ -213,6 +213,17 @@ async function envPull(projectName, options = {}) {
213
213
  console.log(chalk_1.default.gray(`Try deploying with: solidactions project deploy ${projectName} -e ${environment} --create`));
214
214
  }
215
215
  }
216
+ else if (error.response.status === 403) {
217
+ // Only the reveal step is named as the culprit — a 403 here can
218
+ // also be a workspace-scope or project-policy denial, and
219
+ // blaming env:reveal for those sends the user to the wrong fix.
220
+ const detail = typeof error.response.data?.message === 'string' ? error.response.data.message : undefined;
221
+ const needsReveal = error.response.data?.required_ability === 'env:reveal';
222
+ const lead = needsReveal
223
+ ? "Reading variable values requires the 'env:reveal' ability."
224
+ : 'Permission denied.';
225
+ console.error(chalk_1.default.red(detail ? `${lead}\n\n${detail}` : lead));
226
+ }
216
227
  else {
217
228
  console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
218
229
  }
@@ -81,9 +81,13 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
81
81
  `in project "${projectName}" (${environment}).`));
82
82
  return;
83
83
  }
84
- // Check if variable already has a value
84
+ // Check if variable already has a value. Deliberately do NOT pass
85
+ // reveal=true: this only reads `existing.has_value` (returned
86
+ // unconditionally by the mappings projection), never the
87
+ // plaintext value, so requesting reveal would force every write
88
+ // to also carry the env:reveal ability it doesn't need (#1252).
85
89
  if (!options.yes) {
86
- const mappingsResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings?reveal=true`, { headers: (0, api_1.getApiHeaders)(config) });
90
+ const mappingsResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, { headers: (0, api_1.getApiHeaders)(config) });
87
91
  const mappings = mappingsResponse.data || [];
88
92
  const existing = mappings.find((m) => m.env_name === key);
89
93
  if (existing && existing.has_value) {
@@ -251,7 +251,7 @@ async function completeLogin(config, workspaces, options, scope = null, prefligh
251
251
  }
252
252
  else if (workspaces.length === 1) {
253
253
  const selected = workspaces[0];
254
- console.log(chalk_1.default.gray(`Auto-selected workspace: ${selected.name}`));
254
+ console.log(chalk_1.default.gray(`Auto-selected workspace: ${(0, workspace_lookup_1.formatWorkspaceWithOrg)(selected)}`));
255
255
  config.workspace = selected.slug ?? selected.name;
256
256
  config.workspaceId = selected.id;
257
257
  }
@@ -68,7 +68,11 @@ function assembleEnv(opts) {
68
68
  const warnings = [];
69
69
  const env = {};
70
70
  for (const [key, value] of Object.entries(opts.resolved)) {
71
- if (isReservedEnvName(key)) {
71
+ // The resolve endpoint owns this database credential manifest. Local
72
+ // execution must pass it through with the mapped JSON values so the
73
+ // SDK can recognize database variables. All other platform-reserved
74
+ // names remain ignored and are re-added by the CLI where applicable.
75
+ if (key !== 'SOLIDACTIONS__DB_KEYS' && isReservedEnvName(key)) {
72
76
  warnings.push(`crew variable '${key}' is reserved (set by the platform at runtime) — ignored`);
73
77
  continue;
74
78
  }
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.workspacesList = workspacesList;
7
7
  exports.workspaceSet = workspaceSet;
8
- const axios_1 = __importDefault(require("axios"));
9
8
  const chalk_1 = __importDefault(require("chalk"));
10
9
  const api_1 = require("../utils/api");
11
10
  const config_1 = require("../utils/config");
@@ -13,46 +12,34 @@ const config_write_target_1 = require("../utils/config-write-target");
13
12
  const workspace_lookup_1 = require("../utils/workspace-lookup");
14
13
  async function workspacesList() {
15
14
  const config = (0, api_1.requireConfig)();
15
+ // Grouping keys are tenant ids (app#1214), so the org header and the
16
+ // same-name disambiguation both come from per-row tenant data, never
17
+ // from the key.
18
+ let workspaces;
16
19
  try {
17
- const response = await axios_1.default.get(`${config.host}/api/v1/workspaces`, {
18
- headers: {
19
- 'Authorization': `Bearer ${config.apiKey}`,
20
- 'Accept': 'application/json',
21
- },
22
- });
23
- // API returns { workspaces: { "Org Name": [{ id, name, role, tenant_name, ... }] } }
24
- const grouped = response.data.workspaces || response.data.data || response.data;
25
- let hasWorkspaces = false;
26
- console.log(chalk_1.default.blue(`\nYour workspaces:\n`));
27
- if (typeof grouped === 'object' && !Array.isArray(grouped)) {
28
- for (const orgName of Object.keys(grouped)) {
29
- console.log(` ${chalk_1.default.white(orgName)}`);
30
- for (const ws of grouped[orgName]) {
31
- hasWorkspaces = true;
32
- const current = config.workspaceId === ws.id ? chalk_1.default.green(' ← current') : '';
33
- console.log(` ${chalk_1.default.white(ws.name)} ${chalk_1.default.gray(`(${ws.role})`)}${current}`);
34
- console.log(chalk_1.default.gray(` ID: ${ws.id}`));
35
- }
36
- }
37
- }
38
- else if (Array.isArray(grouped)) {
39
- for (const ws of grouped) {
40
- hasWorkspaces = true;
41
- const current = config.workspaceId === ws.id ? chalk_1.default.green(' ← current') : '';
42
- console.log(` ${chalk_1.default.white(ws.name)} ${chalk_1.default.gray(`(${ws.org_name || ''}, ${ws.role})`)}${current}`);
43
- console.log(chalk_1.default.gray(` ID: ${ws.id}`));
44
- }
45
- }
46
- if (!hasWorkspaces) {
47
- console.log(chalk_1.default.yellow('No workspaces found.'));
48
- return;
49
- }
50
- console.log('');
20
+ ({ workspaces } = await (0, workspace_lookup_1.fetchWorkspaces)(config));
51
21
  }
52
22
  catch (error) {
53
23
  console.error(chalk_1.default.red('Failed to list workspaces:'), error.response?.data?.message || error.message);
54
24
  process.exit(1);
55
25
  }
26
+ console.log(chalk_1.default.blue(`\nYour workspaces:\n`));
27
+ if (workspaces.length === 0) {
28
+ console.log(chalk_1.default.yellow('No workspaces found.'));
29
+ return;
30
+ }
31
+ for (const group of (0, workspace_lookup_1.groupWorkspacesByOrg)(workspaces)) {
32
+ if (group.header) {
33
+ console.log(` ${chalk_1.default.white(group.header)}`);
34
+ }
35
+ for (const ws of group.workspaces) {
36
+ const current = config.workspaceId === ws.id ? chalk_1.default.green(' ← current') : '';
37
+ const slug = ws.slug ? ` ${chalk_1.default.gray(ws.slug)}` : '';
38
+ console.log(` ${chalk_1.default.white(ws.name)} ${chalk_1.default.gray(`(${ws.role})`)}${slug}${current}`);
39
+ console.log(chalk_1.default.gray(` ID: ${ws.id}`));
40
+ }
41
+ }
42
+ console.log('');
56
43
  }
57
44
  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
45
  function looksLikeUuid(input) {
@@ -84,6 +71,6 @@ async function workspaceSet(input, options = {}) {
84
71
  if (target === 'local') {
85
72
  await (0, config_write_target_1.ensureGitignoreCovers)(process.cwd(), !!options.gitignore);
86
73
  }
87
- console.log(chalk_1.default.green(`Workspace set to: ${workspace.name} (${workspace.id})`));
74
+ console.log(chalk_1.default.green(`Workspace set to: ${(0, workspace_lookup_1.formatWorkspaceWithOrg)(workspace)} (${workspace.id})`));
88
75
  console.log(chalk_1.default.gray(`Saved to ${targetPath}`));
89
76
  }
package/dist/index.js CHANGED
@@ -89,6 +89,7 @@ const crew_env_set_1 = require("./commands/crew-env-set");
89
89
  const crew_env_list_1 = require("./commands/crew-env-list");
90
90
  const crew_env_delete_1 = require("./commands/crew-env-delete");
91
91
  const crew_env_push_1 = require("./commands/crew-env-push");
92
+ const crew_env_map_database_1 = require("./commands/crew-env-map-database");
92
93
  const state_1 = require("./commands/state");
93
94
  const workflow_view_1 = require("./commands/workflow-view");
94
95
  const database_1 = require("./commands/database");
@@ -578,6 +579,15 @@ crewEnv
578
579
  .action((crewArg, options) => {
579
580
  (0, crew_env_list_1.crewEnvList)(crewArg, options);
580
581
  });
582
+ crewEnv
583
+ .command('map-database')
584
+ .description('Map a workspace database into crew sandboxes')
585
+ .argument('<crew>', 'Crew name or id')
586
+ .argument('<key>', 'Variable key')
587
+ .argument('<database>', 'Workspace database name or id')
588
+ .action((crewArg, key, databaseArg) => {
589
+ (0, crew_env_map_database_1.crewEnvMapDatabase)(crewArg, key, databaseArg);
590
+ });
581
591
  crewEnv
582
592
  .command('delete')
583
593
  .description('Delete a crew variable')
package/dist/utils/api.js CHANGED
@@ -156,6 +156,21 @@ function augmentTokenMissingAbilityMessage(error) {
156
156
  response.data.message = `${message}\n\n${hint}`;
157
157
  }
158
158
  }
159
+ const isEnvRevealAbility = requiredAbility === 'env:reveal';
160
+ if (response?.status === 403
161
+ && response.data?.code === 'token_missing_ability'
162
+ && isEnvRevealAbility) {
163
+ const hint = "The 'env:reveal' ability grants plaintext disclosure of secret values. "
164
+ + 'Re-run `solidactions login --device` and tick "Reveal secret values" on the consent screen, '
165
+ + 'or create an API key with the \'env:reveal\' ability checked at Settings → API keys '
166
+ + 'and `solidactions login` with that key.';
167
+ const message = typeof response.data.message === 'string' && response.data.message.length > 0
168
+ ? response.data.message
169
+ : "This session does not have the 'env:reveal' ability.";
170
+ if (!message.includes('Settings → API keys')) {
171
+ response.data.message = `${message}\n\n${hint}`;
172
+ }
173
+ }
159
174
  return error;
160
175
  }
161
176
  axios_1.default.interceptors.response.use((response) => response, (error) => Promise.reject(augmentTokenMissingAbilityMessage(augmentWorkspaceForbiddenMessage(augmentNotFoundMessage(augmentSandboxEgressMessage(error))))));
@@ -301,7 +316,7 @@ async function ensureWorkspaceSelected(config, dependencies = {}) {
301
316
  let selected;
302
317
  if (workspaces.length === 1) {
303
318
  selected = workspaces[0];
304
- console.log(chalk_1.default.gray(`Auto-selected workspace: ${selected.name}`));
319
+ console.log(chalk_1.default.gray(`Auto-selected workspace: ${(0, workspace_lookup_1.formatWorkspaceWithOrg)(selected)}`));
305
320
  }
306
321
  else {
307
322
  if (!process.stdin.isTTY) {
@@ -311,7 +326,6 @@ async function ensureWorkspaceSelected(config, dependencies = {}) {
311
326
  }
312
327
  const chosen = await (0, workspace_lookup_1.selectWorkspaceInteractively)(workspaces, {
313
328
  ...dependencies,
314
- label: (ws) => `${ws.name} ${chalk_1.default.gray(`(${ws.org_name}, ${ws.role})`)}`,
315
329
  });
316
330
  if (!chosen) {
317
331
  process.exit(1);
@@ -324,7 +338,6 @@ async function ensureWorkspaceSelected(config, dependencies = {}) {
324
338
  const targetPath = resolved?.activePath ?? (0, config_1.getGlobalConfigPath)();
325
339
  (0, config_1.writeConfigFile)(targetPath, config);
326
340
  }
327
- console.log(chalk_1.default.green(`Workspace set: ${selected.name}`));
328
341
  return config;
329
342
  }
330
343
  async function requireConfigWithWorkspace() {
@@ -17,7 +17,7 @@ exports.EXAMPLES_REF = void 0;
17
17
  * with the package it publishes. solidactions-examples does NOT version in
18
18
  * lockstep with the SDK — its newest tag (v0.7.0) predates the current template
19
19
  * by a wide margin: it declares `@solidactions/sdk` ^0.6.0 (this CLI declares
20
- * ^0.7.3) and lacks skills/solidactions-crew-skills.md entirely. Pinning to that
20
+ * ^0.8.0) and lacks skills/solidactions-crew-skills.md entirely. Pinning to that
21
21
  * tag would regress every new scaffold, so the same derived-version scheme cannot
22
22
  * apply here. A commit SHA is immutable and gives the property that actually
23
23
  * matters — the scaffold no longer moves under us.
@@ -28,10 +28,10 @@ exports.EXAMPLES_REF = void 0;
28
28
  * users. If solidactions-examples ever starts publishing tags in step with the
29
29
  * SDK, replace this with a derivation the way sdk-version.ts does.
30
30
  *
31
- * Currently: solidactions-examples PR #29 head @ 8a47ced4 "docs: add database
32
- * CLI guidance". Pinning this immutable PR-head commit is a temporary build-time necessity
33
- * while the coordinated wave is pending merge; no delivery override
34
- * was granted. Before any CLI release, repin EXAMPLES_REF to the
35
- * merged mainline SHA and verify that exact ref during the release ritual.
31
+ * Currently: the merged solidactions-examples mainline as of CLI v3.8.0
32
+ * (includes ex#31 "refresh workspace database guidance"). Repinned at release
33
+ * per the standing #1146 contract: on every CLI release, repin EXAMPLES_REF to
34
+ * the examples repo's merged mainline SHA and verify the exact ref during the
35
+ * release ritual.
36
36
  */
37
- exports.EXAMPLES_REF = 'c232c416a86f5873c4b209f83132290322495e15';
37
+ exports.EXAMPLES_REF = '5eaaaab417ef510401618b814a1eedf238752057';
@@ -4,7 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.matchWorkspace = matchWorkspace;
7
+ exports.groupWorkspacesByOrg = groupWorkspacesByOrg;
7
8
  exports.fetchWorkspaces = fetchWorkspaces;
9
+ exports.formatWorkspaceWithOrg = formatWorkspaceWithOrg;
8
10
  exports.selectWorkspaceInteractively = selectWorkspaceInteractively;
9
11
  exports.resolveWorkspaceInput = resolveWorkspaceInput;
10
12
  const axios_1 = __importDefault(require("axios"));
@@ -19,6 +21,41 @@ const readline_1 = __importDefault(require("readline"));
19
21
  function matchWorkspace(input, workspaces) {
20
22
  return workspaces.find((w) => w.id === input || w.slug === input || w.name === input);
21
23
  }
24
+ /**
25
+ * Pure: group workspaces by tenant for display, preserving payload order.
26
+ *
27
+ * Two different orgs may share a display name (a consultant's employer and
28
+ * their client both called "Acme"), so groups are keyed by tenant id and only
29
+ * the colliding names get a qualifier — the one thing that tells the two apart.
30
+ */
31
+ function groupWorkspacesByOrg(workspaces) {
32
+ const groups = new Map();
33
+ for (const ws of workspaces) {
34
+ const name = ws.org_name || ws.tenant_name || undefined;
35
+ const key = ws.tenant_id || name || '';
36
+ let group = groups.get(key);
37
+ if (!group) {
38
+ group = { name, qualifier: ws.tenant_slug || ws.tenant_id, workspaces: [] };
39
+ groups.set(key, group);
40
+ }
41
+ group.workspaces.push(ws);
42
+ }
43
+ const nameCounts = new Map();
44
+ for (const group of groups.values()) {
45
+ if (group.name) {
46
+ nameCounts.set(group.name, (nameCounts.get(group.name) ?? 0) + 1);
47
+ }
48
+ }
49
+ return [...groups.values()].map((group) => {
50
+ const ambiguous = !!group.name && (nameCounts.get(group.name) ?? 0) > 1;
51
+ return {
52
+ header: group.name && ambiguous && group.qualifier
53
+ ? `${group.name} (${group.qualifier})`
54
+ : group.name,
55
+ workspaces: group.workspaces,
56
+ };
57
+ });
58
+ }
22
59
  /**
23
60
  * Network: fetch the full list of workspaces the current API key can see.
24
61
  * Normalizes the API's grouped/array response shapes.
@@ -33,8 +70,10 @@ async function fetchWorkspaces(config) {
33
70
  const grouped = response.data.workspaces || response.data.teams || response.data.data || response.data;
34
71
  const out = [];
35
72
  if (typeof grouped === 'object' && !Array.isArray(grouped)) {
36
- for (const orgWorkspaces of Object.values(grouped)) {
37
- out.push(...orgWorkspaces);
73
+ for (const [orgName, orgWorkspaces] of Object.entries(grouped)) {
74
+ for (const ws of orgWorkspaces) {
75
+ out.push({ ...ws, org_name: ws.tenant_name || orgName });
76
+ }
38
77
  }
39
78
  }
40
79
  else if (Array.isArray(grouped)) {
@@ -43,19 +82,37 @@ async function fetchWorkspaces(config) {
43
82
  const scope = response.data.scope ?? null;
44
83
  return { workspaces: out, scope };
45
84
  }
85
+ /** Workspace name, qualified with its org name when known (e.g. `"Foo — organization Bar"`). */
86
+ function formatWorkspaceWithOrg(ws) {
87
+ return ws.org_name ? `${ws.name} — organization ${ws.org_name}` : ws.name;
88
+ }
46
89
  async function selectWorkspaceInteractively(workspaces, dependencies = {}) {
47
90
  if (workspaces.length === 0) {
48
91
  console.log(chalk_1.default.yellow('No workspaces found. Create one at your SolidActions dashboard, then run `solidactions workspace set <name>`.'));
49
92
  return undefined;
50
93
  }
51
94
  if (workspaces.length === 1) {
52
- console.log(chalk_1.default.gray(`Auto-selected workspace: ${workspaces[0].name}`));
95
+ console.log(chalk_1.default.gray(`Auto-selected workspace: ${formatWorkspaceWithOrg(workspaces[0])}`));
53
96
  return workspaces[0];
54
97
  }
55
- const label = dependencies.label ?? ((ws) => ws.name);
98
+ const label = dependencies.label ?? ((ws) => (ws.role ? `${ws.name} (${ws.role})` : ws.name));
99
+ // Header + grouping preamble are only useful once there's more than one
100
+ // org to disambiguate; a single-org account would otherwise get a
101
+ // redundant sole header and a pointless "grouped by organization" line.
102
+ const orgNames = new Set(workspaces.map((ws) => ws.org_name).filter((name) => !!name));
103
+ const grouped = orgNames.size > 1;
56
104
  console.log(chalk_1.default.blue('\nSelect your default workspace (change anytime with `solidactions workspace set`):\n'));
105
+ if (grouped) {
106
+ console.log(chalk_1.default.gray('Workspaces are grouped by organization.\n'));
107
+ }
108
+ let lastOrg;
57
109
  workspaces.forEach((ws, i) => {
58
- console.log(` ${chalk_1.default.white(`${i + 1}.`)} ${label(ws)}`);
110
+ if (grouped && ws.org_name !== lastOrg) {
111
+ console.log(` ${chalk_1.default.bold(ws.org_name ?? '')}`);
112
+ lastOrg = ws.org_name;
113
+ }
114
+ const indent = grouped ? ' ' : ' ';
115
+ console.log(`${indent}${chalk_1.default.white(`${i + 1}.`)} ${label(ws)}`);
59
116
  });
60
117
  console.log('');
61
118
  const rl = dependencies.question
@@ -88,7 +145,9 @@ async function selectWorkspaceInteractively(workspaces, dependencies = {}) {
88
145
  }
89
146
  const index = parseInt(answer, 10) - 1;
90
147
  if (!isNaN(index) && index >= 0 && index < workspaces.length) {
91
- return workspaces[index];
148
+ const selected = workspaces[index];
149
+ console.log(chalk_1.default.green(`Selected: ${formatWorkspaceWithOrg(selected)}`));
150
+ return selected;
92
151
  }
93
152
  console.error(chalk_1.default.red('Invalid selection. Enter one of the numbers shown.'));
94
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -54,7 +54,7 @@
54
54
  "tar": "^7.5.22"
55
55
  },
56
56
  "devDependencies": {
57
- "@solidactions/sdk": "^0.7.3",
57
+ "@solidactions/sdk": "^0.8.0",
58
58
  "@types/archiver": "^8.0.0",
59
59
  "@types/fs-extra": "^11.0.0",
60
60
  "@types/js-yaml": "^4.0.9",