@solidactions/cli 1.28.0 → 1.30.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
@@ -145,11 +145,15 @@ Manage agent skills on the crews SOP surface. `push` is an idempotent upsert (cr
145
145
 
146
146
  | Command | Key Flags | Description |
147
147
  |---------|-----------|-------------|
148
- | `skill push <dir>` | `--role <name>`, `--dry-run`, `--json` | Push a skill folder, or a whole plugin dir — recursive: pushes every `skills/*/SKILL.md`, converts `commands/*.md` → skills, and ingests each skill's `references/`. `--role` scopes to a role instead of the shared library |
148
+ | `skill push <dir>` | `--role <name>`, `--dry-run`, `--json`, `--force` | Push a skill folder, or a whole plugin dir — recursive: pushes every `skills/*/SKILL.md`, converts `commands/*.md` → skills, and ingests each skill's `references/`. `--role` scopes to a role instead of the shared library. Drift-guarded against the local `.solidactions-skill.json` sidecar revision; `--force` skips the guard |
149
149
  | `skill list` | `--json`, `--limit <n>` | List skills in the library |
150
150
  | `skill view <name>` | `--json` | Show one skill |
151
- | `skill pull <name> [dest]` | `--json` | Fetch a skill to a local folder for editing (inverse of push) |
151
+ | `skill pull <name> [dest]` | `--json` | Fetch a skill to a local folder for editing (inverse of push); writes a `.solidactions-skill.json` provenance sidecar used by `push`'s drift guard |
152
152
  | `skill delete <name>` | `--json` | Delete a skill (Admin only) |
153
+ | `skill run <dir> -- <command...>` | `--crew <nameOrId>`, `--environment <env>` (default `dev`), `--env-file <path>` | Run a skill script LOCALLY with crew variables fetched from the platform (dev loop). Secret values need a token with `env:reveal`; see `skill exec` for the remote/deployed counterpart |
154
+ | `skill exec <name> -- <command...>` | `--role <name>`, `--in-crew <crew>`, `--environment <env>` (default `production`) | Run a command against the DEPLOYED skill in its real sandbox runtime (post-push smoke); see `skill run` for the local dev-loop counterpart |
155
+
156
+ For `skill run` / `skill exec`, pass the command as separate words after `--` (e.g. `-- python script.py --flag`); to run a single preformed shell string, wrap it explicitly with `sh -c '...'`.
153
157
 
154
158
  ### role
155
159
 
@@ -157,6 +161,35 @@ Manage agent skills on the crews SOP surface. `push` is an idempotent upsert (cr
157
161
  |---------|-----------|-------------|
158
162
  | `role push <dir>` | `--dry-run`, `--json` | Push a role definition (create or update) |
159
163
 
164
+ ### docs
165
+
166
+ Manage docs in SA-Docs (the app's built-in documentation vault). `push` is drift-guarded for files previously pulled: a tracked file whose server revision has moved since the pull fails with `re-pull to merge, or pass --force to overwrite` rather than silently clobbering it; untracked files always go through the existing bulk-create path.
167
+
168
+ | Command | Key Flags | Description |
169
+ |---------|-----------|-------------|
170
+ | `docs pull <folder> [dest]` | `-y`, `--overwrite`, `--json` | Download a Docs folder tree (markdown + media) to `dest` (defaults to `./<last-segment>/`); writes a `.solidactions-docs.json` revision manifest (including a `body_sha256` content hash per file) used by `push`'s drift guard. Falls back to fetching a single doc if `folder` is a doc path, not a folder |
171
+ | `docs push <dir>` | `--on-conflict`, `--type`, `--folder`, `--dry-run`, `--force`, `--json` | Recursively upload a local markdown tree. Manifest-tracked files (from a prior `pull`) are written with a `base_revision` guard and reported separately as written/drifted/unchanged; files whose content hash still matches the last pull are skipped as unchanged (no write, no revision bump). Tracked media files whose bytes changed are replaced the same way, under the same guard; a tracked media file missing locally is left alone — `push` never deletes. An untracked binary in the tree is warned about, never uploaded (use `docs upload`). `--force` skips the drift guard (unchanged files are still skipped). `--dry-run` previews without writing. Untracked files are created under the manifest's `folder_path` when `<dir>` came from a `docs pull` (pass `--folder` to override); an untracked file whose title already exists in the target folder is skipped per `--on-conflict` (default `skip`, reported as `duplicate_title`) |
172
+ | `docs upload <files...>` | `--folder`, `--title`, `--replace <doc-id-or-path>` | Upload one or more media files to SA-Docs (requires a token with the "docs" ability); `--title` only valid for a single file. `--replace` swaps the bytes behind an existing media doc instead of creating a new one — see below |
173
+
174
+ `docs upload <file> --replace <doc-id-or-path>` swaps the bytes behind an existing media doc, keeping its id, title, and folder, so embeds and references keep resolving — the old image stays in the doc's version history. Single file only; cannot be combined with `--title` or `--folder`. A purely numeric argument is a doc id; anything else is a docs path (`marketing/hero.png`), resolved against the doc's **title** — which `docs pull` may have sanitized, so for path-based work on a pulled folder prefer `docs push` instead:
175
+
176
+ ```bash
177
+ solidactions docs upload logo-v2.png --replace 482
178
+ solidactions docs upload logo-v2.png --replace marketing/logo.png
179
+ ```
180
+
181
+ **`docs pull` propagates deletions, within limits.** A file is removed locally only when its doc was deleted on the server *and* the file's bytes still match what the last pull gave it (the manifest's `body_sha256`) — anything you've edited locally is kept, with a warning that it's now untracked (re-create a markdown doc with `docs push`, a media doc with `docs upload`). Deletions only propagate when the destination's existing manifest `folder_path` matches the folder you're pulling (so pulling a different folder into a directory holding an old manifest deletes nothing), and never on the single-doc pull path; when propagation is skipped for either reason, `pull` says so. Nothing outside the destination directory is removed: every candidate path is resolved physically (so a symlinked subdirectory cannot lead the delete outside), and a file the same pull just wrote is never deleted, even if a case-only rename makes it look orphaned on a case-insensitive filesystem.
182
+
183
+ **`docs pull --overwrite` is destructive.** If a manifest-tracked file still exists on the server *and* your local copy no longer matches the `body_sha256` recorded at the last pull (i.e. you've edited it and haven't pushed yet), a plain `docs pull` — even with `-y`/`--yes` — refuses with exit 1, naming every modified file, rather than silently discarding your edits. Nothing is written before that refusal. `-y`/`--yes` only bypasses the generic "destination is not empty" prompt; it does not cover locally-modified tracked files. Pass `--overwrite` to discard those local changes and re-pull server content anyway (it also implies `--yes`).
184
+
185
+ You do **not** need `--overwrite` to keep an edited file whose doc was deleted on the server — that case is handled by deletion propagation above, on the default path, and the file is kept with a warning.
186
+
187
+ **Getting a doc id.** `docs upload --replace` accepts a docs path (`marketing/hero.png`), so you rarely need an id. If you want one, `docs pull` records it per file in the destination's `.solidactions-docs.json` sidecar, and `import_outputs` returns the ids it created. Note that `--replace` does not update a pulled directory's manifest. If you replace a tracked image out-of-band and leave the local file untouched, the next `docs push` reports it as **unchanged** and does nothing — the content hash matches, so `push` never asks the server. (Edit the local file too, and the drift guard fires as expected.) Re-pull to resync the manifest.
188
+
189
+ **`docs push` and deleted docs.** If a tracked file's doc was deleted on the server, `push` names it per file (`doc <id> no longer exists (deleted remotely) — re-pull to untrack it, then push to re-create`) and carries on with the other files. Note the deleted doc still holds its title until it leaves the trash, so re-creating it needs the trashed copy restored or purged first — `push` says so if you hit it. `push` exits 1 on drift (a tracked doc moved on since your pull) and on any per-file server error; a deleted doc alone is not an error.
190
+
191
+ **`docs pull` refuses to replace another folder's manifest.** If the destination already tracks a different folder, pulling into it would leave the previously tracked files untracked — and untracked files are not protected from being overwritten by a later pull. `pull` refuses (exit 1, before any network request) and names both folders. Pull into a different directory, or pass `--overwrite` to replace the manifest anyway. This also covers the single-doc pull path, whose one-entry manifest would otherwise clobber a folder's.
192
+
160
193
  ### workspace
161
194
 
162
195
  | Command | Description |
@@ -0,0 +1,50 @@
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.crewEnvDelete = crewEnvDelete;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const prompts_1 = __importDefault(require("prompts"));
10
+ const api_1 = require("../utils/api");
11
+ const crew_1 = require("../utils/crew");
12
+ async function crewEnvDelete(crewArg, key, options = {}) {
13
+ const config = await (0, api_1.requireConfigWithWorkspace)();
14
+ const crew = await (0, crew_1.resolveCrewId)(config, crewArg);
15
+ if (!options.yes) {
16
+ const response = await (0, prompts_1.default)({
17
+ type: 'confirm',
18
+ name: 'confirm',
19
+ message: `Delete variable "${key}" from crew "${crew.name}"?`,
20
+ initial: false,
21
+ });
22
+ if (!response.confirm) {
23
+ console.log(chalk_1.default.gray('Cancelled.'));
24
+ return;
25
+ }
26
+ }
27
+ try {
28
+ const response = await axios_1.default.delete(`${config.host}/api/v1/crews/${crew.id}/variables/${key}`, {
29
+ headers: (0, api_1.getApiHeaders)(config),
30
+ });
31
+ console.log(chalk_1.default.green(response.data?.message || `Variable "${key}" deleted from crew "${crew.name}".`));
32
+ }
33
+ catch (error) {
34
+ if (error.response) {
35
+ if (error.response.status === 401) {
36
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
37
+ }
38
+ else if (error.response.status === 404) {
39
+ console.error(chalk_1.default.red(error.response.data?.message || `Variable "${key}" not found for crew "${crew.name}".`));
40
+ }
41
+ else {
42
+ console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
43
+ }
44
+ }
45
+ else {
46
+ console.error(chalk_1.default.red('Connection failed:'), error.message);
47
+ }
48
+ process.exit(1);
49
+ }
50
+ }
@@ -0,0 +1,78 @@
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.crewEnvList = crewEnvList;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const api_1 = require("../utils/api");
10
+ const crew_1 = require("../utils/crew");
11
+ /**
12
+ * Format a value for display. Secrets are ALWAYS masked with a fixed
13
+ * placeholder — regardless of what the server sent — so a server-side
14
+ * masking bug can never leak a raw secret into stdout.
15
+ */
16
+ function formatValue(value, isSecret) {
17
+ if (isSecret) {
18
+ return chalk_1.default.yellow('••••••');
19
+ }
20
+ if (value === null || value === undefined) {
21
+ return chalk_1.default.gray('-');
22
+ }
23
+ return value.substring(0, 18);
24
+ }
25
+ async function crewEnvList(crewArg, options = {}) {
26
+ const config = await (0, api_1.requireConfigWithWorkspace)();
27
+ const crew = await (0, crew_1.resolveCrewId)(config, crewArg);
28
+ try {
29
+ const response = await axios_1.default.get(`${config.host}/api/v1/crews/${crew.id}/variables`, {
30
+ headers: (0, api_1.getApiHeaders)(config),
31
+ });
32
+ const variables = response.data?.data ?? [];
33
+ if (options.json) {
34
+ console.log(JSON.stringify(variables, null, 2));
35
+ return;
36
+ }
37
+ console.log(chalk_1.default.blue(`Variables for crew "${crew.name}":`));
38
+ if (variables.length === 0) {
39
+ console.log(chalk_1.default.gray('No variables found.'));
40
+ return;
41
+ }
42
+ console.log('');
43
+ console.log(chalk_1.default.gray('KEY'.padEnd(24) +
44
+ chalk_1.default.green('PRODUCTION').padEnd(20) +
45
+ chalk_1.default.yellow('STAGING').padEnd(20) +
46
+ chalk_1.default.blue('DEV').padEnd(20) +
47
+ 'TYPE'));
48
+ console.log(chalk_1.default.gray('-'.repeat(100)));
49
+ for (const variable of variables) {
50
+ const key = variable.env_name || '?';
51
+ const type = variable.is_secret ? chalk_1.default.yellow('secret') : chalk_1.default.gray('plain');
52
+ console.log(key.substring(0, 22).padEnd(24) +
53
+ formatValue(variable.production_value, variable.is_secret).padEnd(20) +
54
+ formatValue(variable.staging_value, variable.is_secret).padEnd(20) +
55
+ formatValue(variable.dev_value, variable.is_secret).padEnd(20) +
56
+ type);
57
+ }
58
+ console.log('');
59
+ console.log(chalk_1.default.gray(`${variables.length} variable(s)`));
60
+ }
61
+ catch (error) {
62
+ if (error.response) {
63
+ if (error.response.status === 401) {
64
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
65
+ }
66
+ else if (error.response.status === 404) {
67
+ console.error(chalk_1.default.red(error.response.data?.message || `Crew "${crewArg}" not found.`));
68
+ }
69
+ else {
70
+ console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
71
+ }
72
+ }
73
+ else {
74
+ console.error(chalk_1.default.red('Connection failed:'), error.message);
75
+ }
76
+ process.exit(1);
77
+ }
78
+ }
@@ -0,0 +1,162 @@
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.diffPushEntry = diffPushEntry;
7
+ exports.crewEnvPush = crewEnvPush;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const axios_1 = __importDefault(require("axios"));
11
+ const chalk_1 = __importDefault(require("chalk"));
12
+ const prompts_1 = __importDefault(require("prompts"));
13
+ const api_1 = require("../utils/api");
14
+ const crew_1 = require("../utils/crew");
15
+ const env_1 = require("../utils/env");
16
+ const crew_env_set_1 = require("./crew-env-set");
17
+ /**
18
+ * Pure: decide create/update/skip for one key. `skip` only fires for a
19
+ * plain (non-secret, no secret-status change) variable whose server-side
20
+ * value(s) already match what we're about to push — secrets are always
21
+ * masked server-side so we can never prove a secret push is a no-op.
22
+ */
23
+ function diffPushEntry(key, value, environment, isSecret, existing) {
24
+ const body = (0, crew_env_set_1.buildVariableBody)(environment, value, isSecret);
25
+ if (!existing) {
26
+ return { key, action: 'create', body };
27
+ }
28
+ if (existing.is_secret !== isSecret || isSecret) {
29
+ return { key, action: 'update', body };
30
+ }
31
+ const productionUnchanged = !(environment === 'production' || environment === 'all')
32
+ || existing.production_value === value;
33
+ const stagingUnchanged = !(environment === 'staging' || environment === 'all')
34
+ || (existing.staging_value === value && existing.staging_source === 'value');
35
+ const devUnchanged = !(environment === 'dev' || environment === 'all')
36
+ || (existing.dev_value === value && existing.dev_source === 'value');
37
+ const unchanged = productionUnchanged && stagingUnchanged && devUnchanged;
38
+ return { key, action: unchanged ? 'skip' : 'update', body };
39
+ }
40
+ async function crewEnvPush(crewArg, filePath = '.env', options = {}) {
41
+ const environment = options.env || 'all';
42
+ if (!(0, crew_1.isValidCrewEnv)(environment)) {
43
+ console.error(chalk_1.default.red((0, crew_1.crewEnvError)(environment)));
44
+ process.exit(1);
45
+ }
46
+ const resolvedPath = path_1.default.resolve(filePath);
47
+ if (!fs_1.default.existsSync(resolvedPath)) {
48
+ console.error(chalk_1.default.red(`${filePath} not found.`));
49
+ process.exit(1);
50
+ }
51
+ const envValues = (0, env_1.parseEnvFile)(resolvedPath);
52
+ if (envValues.size === 0) {
53
+ console.log(chalk_1.default.yellow(`${filePath} is empty — nothing to push.`));
54
+ process.exit(0);
55
+ }
56
+ const reservedKeys = Array.from(envValues.keys()).filter(env_1.isReservedEnvName);
57
+ if (reservedKeys.length > 0) {
58
+ console.error(chalk_1.default.red(`Refusing to push — reserved ${env_1.RESERVED_ENV_PREFIX} names found: ${reservedKeys.join(', ')}`));
59
+ process.exit(1);
60
+ }
61
+ const config = await (0, api_1.requireConfigWithWorkspace)();
62
+ const crew = await (0, crew_1.resolveCrewId)(config, crewArg);
63
+ // Secrets are the default for crew variables — --no-secret opts out,
64
+ // and applies uniformly to every key in this push.
65
+ const isSecret = options.secret !== false;
66
+ let serverVariables;
67
+ try {
68
+ const response = await axios_1.default.get(`${config.host}/api/v1/crews/${crew.id}/variables`, {
69
+ headers: (0, api_1.getApiHeaders)(config),
70
+ });
71
+ serverVariables = response.data?.data ?? [];
72
+ }
73
+ catch (error) {
74
+ if (error.response?.status === 401) {
75
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
76
+ }
77
+ else if (error.response?.status === 404) {
78
+ console.error(chalk_1.default.red(error.response.data?.message || `Crew "${crewArg}" not found.`));
79
+ }
80
+ else {
81
+ console.error(chalk_1.default.red('Failed to read existing variables:'), error.response?.data?.message || error.message);
82
+ }
83
+ process.exit(1);
84
+ }
85
+ const serverState = new Map();
86
+ for (const variable of serverVariables) {
87
+ serverState.set(variable.env_name, variable);
88
+ }
89
+ const entries = Array.from(envValues.entries()).map(([key, value]) => diffPushEntry(key, value, environment, isSecret, serverState.get(key)));
90
+ const toCreate = entries.filter((e) => e.action === 'create');
91
+ const toUpdate = entries.filter((e) => e.action === 'update');
92
+ const toSkip = entries.filter((e) => e.action === 'skip');
93
+ const toPush = entries.filter((e) => e.action !== 'skip');
94
+ // Diff table — values are NEVER printed, only a fixed mask placeholder.
95
+ console.log('');
96
+ console.log(chalk_1.default.bold(' KEY'.padEnd(36) + 'ACTION'.padEnd(10) + 'VALUE'.padEnd(12) + 'NOTES'));
97
+ console.log(chalk_1.default.gray(' ' + '─'.repeat(66)));
98
+ for (const entry of entries) {
99
+ const keyCol = (' ' + entry.key).padEnd(36);
100
+ let actionCol;
101
+ let notesCol;
102
+ switch (entry.action) {
103
+ case 'create':
104
+ actionCol = chalk_1.default.green('create'.padEnd(10));
105
+ notesCol = chalk_1.default.gray('(new)');
106
+ break;
107
+ case 'update':
108
+ actionCol = chalk_1.default.yellow('update'.padEnd(10));
109
+ notesCol = chalk_1.default.gray('(changed)');
110
+ break;
111
+ case 'skip':
112
+ actionCol = chalk_1.default.gray('skip'.padEnd(10));
113
+ notesCol = chalk_1.default.gray('(unchanged)');
114
+ break;
115
+ }
116
+ console.log(keyCol + actionCol + chalk_1.default.yellow('••••••').padEnd(12) + notesCol);
117
+ }
118
+ // Printed unconditionally (not just inside the prompt message) so the
119
+ // counts are visible with --yes and in captured/injected-prompt output.
120
+ const summary = [];
121
+ if (toCreate.length > 0)
122
+ summary.push(`${toCreate.length} create`);
123
+ if (toUpdate.length > 0)
124
+ summary.push(`${toUpdate.length} update`);
125
+ if (toSkip.length > 0)
126
+ summary.push(`${toSkip.length} skip`);
127
+ console.log('');
128
+ console.log(chalk_1.default.gray(summary.join(', ')));
129
+ console.log('');
130
+ if (toPush.length === 0) {
131
+ console.log(chalk_1.default.yellow('Nothing to push — all variables are already up to date.'));
132
+ process.exit(0);
133
+ }
134
+ if (!options.yes) {
135
+ const response = await (0, prompts_1.default)({
136
+ type: 'confirm',
137
+ name: 'confirm',
138
+ message: `Push ${toPush.length} variable(s) to crew "${crew.name}" (${environment})? (${summary.join(', ')})`,
139
+ initial: true,
140
+ });
141
+ if (!response.confirm) {
142
+ console.log(chalk_1.default.gray('Cancelled.'));
143
+ return;
144
+ }
145
+ }
146
+ for (const entry of toPush) {
147
+ try {
148
+ await axios_1.default.put(`${config.host}/api/v1/crews/${crew.id}/variables/${entry.key}`, entry.body, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
149
+ }
150
+ catch (error) {
151
+ if (error.response?.status === 422) {
152
+ console.error(chalk_1.default.red(`Failed to push "${entry.key}":`), (0, api_1.formatValidationError)(error.response.data));
153
+ }
154
+ else {
155
+ console.error(chalk_1.default.red(`Failed to push "${entry.key}":`), error.response?.data?.message || error.message);
156
+ }
157
+ process.exit(1);
158
+ }
159
+ }
160
+ console.log(chalk_1.default.green(`\n✓ Pushed ${toPush.length} variable(s) to crew "${crew.name}"`));
161
+ console.log(chalk_1.default.gray(` ${toCreate.length} created, ${toUpdate.length} updated` + (toSkip.length > 0 ? `, ${toSkip.length} skipped` : '')));
162
+ }
@@ -0,0 +1,78 @@
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.buildVariableBody = buildVariableBody;
7
+ exports.crewEnvSet = crewEnvSet;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const api_1 = require("../utils/api");
11
+ const crew_1 = require("../utils/crew");
12
+ const env_1 = require("../utils/env");
13
+ /**
14
+ * Maps a --env selection + value into the PUT body's column shape
15
+ * (mirrors GlobalVariableController's columns). `all` (the default) writes
16
+ * the same value to all three environments; staging/dev sources are always
17
+ * 'value' since the CLI never sets inheritance.
18
+ */
19
+ function buildVariableBody(environment, value, isSecret) {
20
+ const body = { is_secret: isSecret };
21
+ if (environment === 'production' || environment === 'all') {
22
+ body.production_value = value;
23
+ }
24
+ if (environment === 'staging' || environment === 'all') {
25
+ body.staging_value = value;
26
+ body.staging_source = 'value';
27
+ }
28
+ if (environment === 'dev' || environment === 'all') {
29
+ body.dev_value = value;
30
+ body.dev_source = 'value';
31
+ }
32
+ return body;
33
+ }
34
+ async function crewEnvSet(crewArg, key, value, options = {}) {
35
+ if (!(0, env_1.isValidEnvName)(key)) {
36
+ console.error(chalk_1.default.red((0, env_1.envNameError)(key)));
37
+ process.exit(1);
38
+ }
39
+ if ((0, env_1.isReservedEnvName)(key)) {
40
+ console.error(chalk_1.default.red((0, env_1.reservedEnvNameError)(key)));
41
+ process.exit(1);
42
+ }
43
+ const environment = options.env || 'all';
44
+ if (!(0, crew_1.isValidCrewEnv)(environment)) {
45
+ console.error(chalk_1.default.red((0, crew_1.crewEnvError)(environment)));
46
+ process.exit(1);
47
+ }
48
+ const config = await (0, api_1.requireConfigWithWorkspace)();
49
+ const crew = await (0, crew_1.resolveCrewId)(config, crewArg);
50
+ // Secrets are the default for crew variables (deliberately unlike
51
+ // project `env set`'s regex heuristic) — --no-secret opts out.
52
+ const isSecret = options.secret !== false;
53
+ const body = buildVariableBody(environment, value, isSecret);
54
+ try {
55
+ await axios_1.default.put(`${config.host}/api/v1/crews/${crew.id}/variables/${key}`, body, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
56
+ console.log(chalk_1.default.green(`Variable "${key}" set for crew "${crew.name}" (${environment}).`));
57
+ }
58
+ catch (error) {
59
+ if (error.response) {
60
+ if (error.response.status === 401) {
61
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
62
+ }
63
+ else if (error.response.status === 404) {
64
+ console.error(chalk_1.default.red(error.response.data?.message || `Crew "${crewArg}" not found.`));
65
+ }
66
+ else if (error.response.status === 422) {
67
+ console.error(chalk_1.default.red((0, api_1.formatValidationError)(error.response.data)));
68
+ }
69
+ else {
70
+ console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
71
+ }
72
+ }
73
+ else {
74
+ console.error(chalk_1.default.red('Connection failed:'), error.message);
75
+ }
76
+ process.exit(1);
77
+ }
78
+ }
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.buildSaApiClient = buildSaApiClient;
39
40
  exports.resolveProjectSlug = resolveProjectSlug;
40
41
  exports.runDev = runDev;
41
42
  exports.dev = dev;
@@ -47,6 +48,37 @@ const chalk_1 = __importDefault(require("chalk"));
47
48
  const js_yaml_1 = __importDefault(require("js-yaml"));
48
49
  const crypto_1 = require("crypto");
49
50
  const module_1 = require("module");
51
+ /**
52
+ * Build the production `SaApiClient`: fetches `variable-mappings` with
53
+ * `reveal=true` so secret values are populated on `ctx.vars`. When the token
54
+ * lacks the `env:reveal` ability, the API responds 403
55
+ * `{ code: 'token_missing_ability' }` — retry once without `reveal` and mark
56
+ * `revealDenied` so the caller can tell the user secrets were withheld.
57
+ */
58
+ function buildSaApiClient(config, projectSlug) {
59
+ const client = {
60
+ projectSlug,
61
+ revealDenied: false,
62
+ async fetchVarsAndConnections(_env) {
63
+ const axios = (await Promise.resolve().then(() => __importStar(require('axios')))).default;
64
+ const { getApiHeaders } = await Promise.resolve().then(() => __importStar(require('../utils/api')));
65
+ const base = `${config.host}/api/v1/projects/${projectSlug}/variable-mappings?resolve_oauth=true`;
66
+ try {
67
+ const response = await axios.get(`${base}&reveal=true`, { headers: getApiHeaders(config) });
68
+ return response.data || [];
69
+ }
70
+ catch (e) {
71
+ if (e?.response?.status === 403 && e.response.data?.code === 'token_missing_ability') {
72
+ client.revealDenied = true;
73
+ const response = await axios.get(base, { headers: getApiHeaders(config) });
74
+ return response.data || [];
75
+ }
76
+ throw e;
77
+ }
78
+ },
79
+ };
80
+ return client;
81
+ }
50
82
  /**
51
83
  * Resolve the SA project slug for a workflow entry file and a target env.
52
84
  *
@@ -242,19 +274,11 @@ async function runDev(opts) {
242
274
  // Production path: build from CLI config.
243
275
  // Lazy-import to keep tests fast (no config resolution needed).
244
276
  const { requireConfigWithWorkspace } = await Promise.resolve().then(() => __importStar(require('../utils/api')));
245
- const { getApiHeaders } = await Promise.resolve().then(() => __importStar(require('../utils/api')));
246
- const axios = (await Promise.resolve().then(() => __importStar(require('axios')))).default;
247
277
  const config = await requireConfigWithWorkspace();
248
278
  // Real project resolution: read the project name from the workflow
249
279
  // file's solidactions.yaml and apply the deploy env→slug rule.
250
280
  const projectSlug = resolveProjectSlug(opts.entry, opts.env);
251
- apiClient = {
252
- projectSlug,
253
- async fetchVarsAndConnections(_env) {
254
- const response = await axios.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings?resolve_oauth=true`, { headers: getApiHeaders(config) });
255
- return response.data || [];
256
- },
257
- };
281
+ apiClient = buildSaApiClient(config, projectSlug);
258
282
  }
259
283
  }
260
284
  // 2. Fetch vars from platform (only when an env + client are present).
@@ -319,7 +343,12 @@ async function runDev(opts) {
319
343
  summary += ` (${droppedCount} declared ${droppedCount === 1 ? 'var' : 'vars'} had no value in this env and ${droppedCount === 1 ? 'was' : 'were'} skipped)`;
320
344
  }
321
345
  if (droppedSecretCount > 0) {
322
- summary += ` (${droppedSecretCount} secret ${droppedSecretCount === 1 ? 'var is' : 'vars are'} not available to local dev — set a test value in your dev environment with \`solidactions env set\`, or pass values via \`-i\`.)`;
346
+ if (apiClient.revealDenied) {
347
+ summary += ` — ${droppedSecretCount} secret ${droppedSecretCount === 1 ? 'var' : 'vars'} unavailable: your API key lacks the 'env:reveal' ability. Mint a key with env:reveal, or set a test value with \`solidactions env set\`.`;
348
+ }
349
+ else {
350
+ summary += ` (${droppedSecretCount} secret ${droppedSecretCount === 1 ? 'var is' : 'vars are'} not available to local dev — set a test value in your dev environment with \`solidactions env set\`, or pass values via \`-i\`.)`;
351
+ }
323
352
  }
324
353
  out(summary);
325
354
  }