@solidactions/cli 3.21.0 → 3.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +7 -3
  2. package/dist/command-manifest.json +1 -1
  3. package/dist/commands/connection-list.js +1 -1
  4. package/dist/commands/crew-env-delete.js +2 -2
  5. package/dist/commands/crew-env-list.js +2 -2
  6. package/dist/commands/crew-env-map-database.js +4 -1
  7. package/dist/commands/crew-env-push.js +5 -2
  8. package/dist/commands/crew-env-set.js +2 -2
  9. package/dist/commands/database-push.js +2 -1
  10. package/dist/commands/deploy.js +44 -28
  11. package/dist/commands/device-login.js +3 -2
  12. package/dist/commands/doc-pull.js +628 -90
  13. package/dist/commands/doc-push.js +54 -3
  14. package/dist/commands/doc-upload.js +5 -2
  15. package/dist/commands/env-delete.js +12 -5
  16. package/dist/commands/env-list.js +12 -7
  17. package/dist/commands/env-map.js +7 -5
  18. package/dist/commands/env-pull.js +5 -6
  19. package/dist/commands/env-push.js +10 -6
  20. package/dist/commands/env-reset.js +12 -8
  21. package/dist/commands/env-set.js +15 -11
  22. package/dist/commands/login.js +84 -20
  23. package/dist/commands/oauth-action-list.js +2 -2
  24. package/dist/commands/oauth-action-platforms.js +2 -2
  25. package/dist/commands/oauth-action-search.js +2 -2
  26. package/dist/commands/oauth-action-view.js +2 -2
  27. package/dist/commands/project-create.js +1 -1
  28. package/dist/commands/project-list.js +2 -2
  29. package/dist/commands/project-logs.js +7 -3
  30. package/dist/commands/project-view.js +26 -9
  31. package/dist/commands/pull.js +4 -2
  32. package/dist/commands/run-list.js +24 -3
  33. package/dist/commands/run-start.js +12 -9
  34. package/dist/commands/run-view.js +2 -2
  35. package/dist/commands/schedule-delete.js +5 -10
  36. package/dist/commands/schedule-list.js +5 -10
  37. package/dist/commands/schedule-set.js +39 -44
  38. package/dist/commands/schedule-state.js +12 -16
  39. package/dist/commands/skill-exec.js +4 -1
  40. package/dist/commands/skill-run.js +4 -1
  41. package/dist/commands/state.js +3 -3
  42. package/dist/commands/webhook-list.js +12 -4
  43. package/dist/commands/webhook-secret.js +12 -4
  44. package/dist/commands/workflow-view.js +20 -4
  45. package/dist/commands/workspaces.js +53 -2
  46. package/dist/index.js +2 -1
  47. package/dist/utils/api.js +18 -4
  48. package/dist/utils/config.js +5 -4
  49. package/dist/utils/crew.js +6 -1
  50. package/dist/utils/host-display.js +47 -0
  51. package/dist/utils/project-ref.js +91 -0
  52. package/dist/utils/workspace-lookup.js +11 -1
  53. package/package.json +2 -2
@@ -8,6 +8,10 @@
8
8
  *
9
9
  * Prints a report distinguishing fully-published docs from "properties pending"
10
10
  * ones (docs whose frontmatter properties couldn't be validated yet).
11
+ *
12
+ * Docs the push creates from untracked files are recorded in the directory's
13
+ * manifest (cli#157), so pushing again updates them by id instead of skipping
14
+ * them — but only when they landed in the manifest's own folder tree.
11
15
  */
12
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -123,7 +127,7 @@ function fileToItem(absPath, rootDir) {
123
127
  const relDir = path_1.default.relative(rootDir, path_1.default.dirname(absPath));
124
128
  // Use POSIX separators; omit if file is in the root dir
125
129
  const relative_folder_path = relDir === '' ? undefined : relDir.split(path_1.default.sep).join('/');
126
- const item = { title, body, _filePath: absPath };
130
+ const item = { title, body, _filePath: absPath, _hash: (0, docs_manifest_1.sha256Hex)(body) };
127
131
  if (relative_folder_path !== undefined) {
128
132
  item.relative_folder_path = relative_folder_path;
129
133
  }
@@ -521,6 +525,15 @@ async function docPushWithConfig(dir, options, config) {
521
525
  const onConflict = options.onConflict ?? 'skip';
522
526
  const allResultRows = [];
523
527
  let mergedSummary = {};
528
+ // cli#157: record what this push creates, so the next push updates it instead of skipping it.
529
+ // Only when the docs landed in the manifest's own folder tree.
530
+ // PM ruling 5: a single-file push records only into a manifest its directory already has.
531
+ const recordable = !options.dryRun
532
+ && (manifest !== null || !singleFile)
533
+ && (manifest === null || options.folder === undefined || options.folder === manifest.folder_path);
534
+ const recordTarget = recordable
535
+ ? (manifest ?? { folder_path: options.folder ?? '', docs: {} })
536
+ : null;
524
537
  for (const chunk of chunks) {
525
538
  const callArgs = {
526
539
  action: 'bulk_create',
@@ -566,14 +579,52 @@ async function docPushWithConfig(dir, options, config) {
566
579
  const rows = data?.results ?? [];
567
580
  const summary = data?.summary ?? {};
568
581
  // Correlate rows back to source files using chunk index
582
+ const chunkResultRows = [];
569
583
  for (const row of rows) {
570
584
  const sourceFile = chunk[row.index]?._filePath ?? '(unknown)';
571
- allResultRows.push({
585
+ const resultRow = {
572
586
  ...row,
573
587
  file: path_1.default.relative(absDir, sourceFile),
574
- });
588
+ };
589
+ chunkResultRows.push(resultRow);
590
+ allResultRows.push(resultRow);
575
591
  }
576
592
  mergedSummary = mergeSummaries(mergedSummary, summary);
593
+ // Record and persist this chunk's successes before the next chunk is
594
+ // sent: a later chunk's failure exits first, and docs already created
595
+ // must still be updatable by id on the next push. The folder /
596
+ // dry-run / single-file guards and existing manifest entries are kept
597
+ // (recordTarget is null unless recording applies).
598
+ if (recordTarget !== null) {
599
+ let changed = false;
600
+ for (const row of chunkResultRows) {
601
+ if (!['created', 'renamed', 'overwritten'].includes(row.status) || row.id === undefined)
602
+ continue;
603
+ const snapshotHash = chunk[row.index]?._hash;
604
+ if (snapshotHash === undefined)
605
+ continue;
606
+ const relPath = row.file.split(path_1.default.sep).join('/');
607
+ if (row.status === 'renamed' && row.title) {
608
+ process.stderr.write(chalk_1.default.yellow(`${relPath}: created as "${row.title}" (the original title was taken); the next doc pull will name the local file after "${row.title}"\n`));
609
+ }
610
+ recordTarget.docs[relPath] = {
611
+ id: Number(row.id),
612
+ title: row.title ?? path_1.default.basename(relPath),
613
+ current_revision_id: row.current_revision_id ?? null,
614
+ media: false,
615
+ body_sha256: snapshotHash,
616
+ };
617
+ changed = true;
618
+ }
619
+ if (changed)
620
+ (0, docs_manifest_1.writeManifest)(absDir, recordTarget);
621
+ }
622
+ }
623
+ // PM ruling 8: never dereference a missing manifest. The "went elsewhere" note is only for an
624
+ // existing manifest with a different --folder; a single-file push with no manifest stays quiet.
625
+ if (!options.dryRun && manifest !== null && options.folder !== undefined && options.folder !== manifest.folder_path
626
+ && allResultRows.some((r) => ['created', 'renamed', 'overwritten'].includes(r.status))) {
627
+ process.stderr.write(chalk_1.default.yellow(`created docs were not recorded in ${docs_manifest_1.DOCS_MANIFEST}: they went to "${options.folder}", not "${manifest.folder_path}"\n`));
577
628
  }
578
629
  // Collect pending items (results that have property_validation)
579
630
  const pendingItems = allResultRows
@@ -78,7 +78,10 @@ async function resolveReplaceTarget(config, replace) {
78
78
  catch (error) {
79
79
  const status = error.response?.status;
80
80
  const code = error.response?.data?.code;
81
- if (status === 422 && code === 'folder_path_not_found') {
81
+ if (status === 401) {
82
+ console.error(chalk_1.default.red(`✗ ${(0, api_1.authFailedLine)(config.host)}`));
83
+ }
84
+ else if (status === 422 && code === 'folder_path_not_found') {
82
85
  console.error(chalk_1.default.red(`✗ no folder "${folderPath}" in this workspace`));
83
86
  }
84
87
  else if (status === 404) {
@@ -159,7 +162,7 @@ async function docUpload(files, options = {}) {
159
162
  console.error(chalk_1.default.red(`✗ ${displayName} — ${data?.message || 'File exceeds the maximum upload size (20MB).'}`));
160
163
  }
161
164
  else if (status === 401) {
162
- console.error(chalk_1.default.red(`✗ ${displayName} — Authentication failed. Run "solidactions login --global" to re-configure.`));
165
+ console.error(chalk_1.default.red(`✗ ${displayName} — ${(0, api_1.authFailedLine)(config.host)}`));
163
166
  }
164
167
  else if (status === 404 && data?.code === 'media_not_found') {
165
168
  console.error(chalk_1.default.red(`✗ ${displayName} — doc ${replaceDocId} is not a media doc`));
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const prompts_1 = __importDefault(require("prompts"));
10
10
  const api_1 = require("../utils/api");
11
+ const project_ref_1 = require("../utils/project-ref");
11
12
  async function envDelete(keyOrProject, keyIfProject, options = {}) {
12
13
  const config = await (0, api_1.requireConfigWithWorkspace)();
13
14
  // Determine mode: if keyIfProject is provided, it's project mapping delete
@@ -15,11 +16,11 @@ async function envDelete(keyOrProject, keyIfProject, options = {}) {
15
16
  const projectName = isProjectMode ? keyOrProject : undefined;
16
17
  const key = isProjectMode ? keyIfProject : keyOrProject;
17
18
  const environment = options.env ?? 'dev';
18
- const projectSlug = projectName && environment === 'production' ? projectName : `${projectName}-${environment}`;
19
19
  try {
20
20
  if (isProjectMode) {
21
21
  // Delete project variable
22
22
  console.log(chalk_1.default.blue(`Deleting variable "${key}" from project "${projectName}" (${environment})...`));
23
+ const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
23
24
  // First, get the variable to find its ID
24
25
  const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, {
25
26
  headers: (0, api_1.getApiHeaders)(config),
@@ -92,19 +93,25 @@ async function envDelete(keyOrProject, keyIfProject, options = {}) {
92
93
  catch (error) {
93
94
  if (error.response) {
94
95
  if (error.response.status === 401) {
95
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
96
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
96
97
  }
97
98
  else if (error.response.status === 404) {
98
99
  if (isProjectMode) {
99
- const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
100
- console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment${envsList ? ` (exists in: ${envsList})` : ''}.`));
100
+ const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
101
+ const envs = family?.environments ?? [];
102
+ if (envs.length > 0 && !envs.includes(environment)) {
103
+ console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}).`));
104
+ }
105
+ else {
106
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
107
+ }
101
108
  }
102
109
  else {
103
110
  console.error(chalk_1.default.red(`Variable "${key}" not found.`));
104
111
  }
105
112
  }
106
113
  else {
107
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
114
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
108
115
  }
109
116
  }
110
117
  else {
@@ -7,6 +7,7 @@ exports.envList = envList;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const api_1 = require("../utils/api");
10
+ const project_ref_1 = require("../utils/project-ref");
10
11
  const table_1 = require("../utils/table");
11
12
  /**
12
13
  * Format a value for display, with inherited badge if applicable.
@@ -33,9 +34,7 @@ async function envList(projectName, options = {}) {
33
34
  try {
34
35
  if (projectName) {
35
36
  // List project variable mappings
36
- const projectSlug = environment === 'production'
37
- ? projectName
38
- : `${projectName}-${environment}`;
37
+ const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
39
38
  const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, {
40
39
  headers: (0, api_1.getApiHeaders)(config),
41
40
  });
@@ -207,15 +206,21 @@ async function envList(projectName, options = {}) {
207
206
  catch (error) {
208
207
  if (error.response) {
209
208
  if (error.response.status === 401) {
210
- console.error(chalk_1.default.red(`Authentication failed against ${config.host}. Run "solidactions login --global" to re-configure.`));
209
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
211
210
  }
212
211
  else if (error.response.status === 404) {
213
212
  if (projectName) {
214
- const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
215
- console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment${envsList ? ` (exists in: ${envsList})` : ''}.`));
213
+ const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
214
+ const envs = family?.environments ?? [];
215
+ if (envs.length > 0 && !envs.includes(environment)) {
216
+ console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}).`));
217
+ }
218
+ else {
219
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
220
+ }
216
221
  }
217
222
  else {
218
- console.error(chalk_1.default.red('Resource not found.'));
223
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
219
224
  }
220
225
  }
221
226
  else {
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const prompts_1 = __importDefault(require("prompts"));
10
10
  const api_1 = require("../utils/api");
11
+ const project_ref_1 = require("../utils/project-ref");
11
12
  const env_1 = require("../utils/env");
12
13
  async function envMap(projectName, projectKey, globalKey, options = {}) {
13
14
  const config = await (0, api_1.requireConfigWithWorkspace)();
@@ -17,6 +18,7 @@ async function envMap(projectName, projectKey, globalKey, options = {}) {
17
18
  }
18
19
  console.log(chalk_1.default.blue(`Mapping global variable "${globalKey}" to project key "${projectKey}" in "${projectName}"...`));
19
20
  try {
21
+ const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName);
20
22
  // First, get the global variable ID by key
21
23
  const varsResponse = await axios_1.default.get(`${config.host}/api/v1/variables`, {
22
24
  headers: (0, api_1.getApiHeaders)(config),
@@ -30,7 +32,7 @@ async function envMap(projectName, projectKey, globalKey, options = {}) {
30
32
  }
31
33
  // Check if project key already has a mapping
32
34
  if (!options.yes) {
33
- const mappingsResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectName}/variable-mappings`, { headers: (0, api_1.getApiHeaders)(config) });
35
+ const mappingsResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, { headers: (0, api_1.getApiHeaders)(config) });
34
36
  const mappings = mappingsResponse.data || [];
35
37
  const existing = mappings.find((m) => m.env_name === projectKey);
36
38
  if (existing && (existing.has_value || existing.global_variable_id)) {
@@ -51,7 +53,7 @@ async function envMap(projectName, projectKey, globalKey, options = {}) {
51
53
  }
52
54
  }
53
55
  // Create the mapping
54
- await axios_1.default.post(`${config.host}/api/v1/projects/${projectName}/variable-mappings`, {
56
+ await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, {
55
57
  project_key: projectKey,
56
58
  global_variable_id: globalVar.id,
57
59
  }, {
@@ -63,16 +65,16 @@ async function envMap(projectName, projectKey, globalKey, options = {}) {
63
65
  catch (error) {
64
66
  if (error.response) {
65
67
  if (error.response.status === 401) {
66
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
68
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
67
69
  }
68
70
  else if (error.response.status === 404) {
69
71
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
70
72
  }
71
73
  else if (error.response.status === 422) {
72
- console.error(chalk_1.default.red('Validation error:'), error.response.data.message || error.response.data.errors);
74
+ console.error(chalk_1.default.red('Validation error:'), (0, api_1.formatValidationError)(error.response.data));
73
75
  }
74
76
  else {
75
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
77
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
76
78
  }
77
79
  }
78
80
  else {
@@ -11,6 +11,7 @@ const axios_1 = __importDefault(require("axios"));
11
11
  const chalk_1 = __importDefault(require("chalk"));
12
12
  const readline_1 = __importDefault(require("readline"));
13
13
  const api_1 = require("../utils/api");
14
+ const project_ref_1 = require("../utils/project-ref");
14
15
  const secure_write_1 = require("../utils/secure-write");
15
16
  /**
16
17
  * Prompt the user for confirmation (unless --yes flag is set).
@@ -75,15 +76,13 @@ function databaseDisplayName(variable) {
75
76
  async function envPull(projectName, options = {}) {
76
77
  const config = await (0, api_1.requireConfigWithWorkspace)();
77
78
  const environment = options.env || 'dev';
78
- // Build the project slug for lookup
79
- const projectSlug = environment === 'production'
80
- ? projectName
81
- : `${projectName}-${environment}`;
82
79
  // Determine output file
83
80
  const outputFile = options.output || (environment === 'production' ? '.env' : `.env.${environment}`);
84
81
  const outputPath = path_1.default.resolve(outputFile);
85
82
  console.log(chalk_1.default.blue(`Pulling variables from "${projectName}" (${environment})...`));
83
+ let projectSlug = '';
86
84
  try {
85
+ projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
87
86
  // First, check if there are any secrets
88
87
  const checkResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings?resolve_oauth=true`, {
89
88
  headers: (0, api_1.getApiHeaders)(config),
@@ -299,7 +298,7 @@ async function envPull(projectName, options = {}) {
299
298
  catch (error) {
300
299
  if (error.response) {
301
300
  if (error.response.status === 401) {
302
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
301
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
303
302
  }
304
303
  else if (error.response.status === 404) {
305
304
  console.error(chalk_1.default.red(`Project "${projectSlug}" not found.`));
@@ -319,7 +318,7 @@ async function envPull(projectName, options = {}) {
319
318
  console.error(chalk_1.default.red(detail ? `${lead}\n\n${detail}` : lead));
320
319
  }
321
320
  else {
322
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
321
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
323
322
  }
324
323
  }
325
324
  else if (!axios_1.default.isAxiosError(error) && error.code) {
@@ -10,6 +10,7 @@ const axios_1 = __importDefault(require("axios"));
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  const prompts_1 = __importDefault(require("prompts"));
12
12
  const api_1 = require("../utils/api");
13
+ const project_ref_1 = require("../utils/project-ref");
13
14
  const env_1 = require("../utils/env");
14
15
  async function envPush(projectName, sourcePath, options = {}) {
15
16
  const config = await (0, api_1.requireConfigWithWorkspace)();
@@ -81,14 +82,12 @@ async function envPush(projectName, sourcePath, options = {}) {
81
82
  `Rename them (e.g. "${reservedKeys[0].replace(/^SOLIDACTIONS_/, 'MY_')}") and retry. Nothing was pushed.`));
82
83
  process.exit(1);
83
84
  }
84
- // Build project slug
85
- const projectSlug = environment === 'production'
86
- ? projectName
87
- : `${projectName}-${environment}`;
88
85
  console.log(chalk_1.default.blue(`Pushing variables to "${projectName}" (${environment})...`));
89
86
  // Fetch current server state
90
87
  let serverMappings = [];
88
+ let projectSlug = '';
91
89
  try {
90
+ projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
92
91
  const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, {
93
92
  headers: (0, api_1.getApiHeaders)(config),
94
93
  });
@@ -96,7 +95,7 @@ async function envPush(projectName, sourcePath, options = {}) {
96
95
  }
97
96
  catch (error) {
98
97
  if (error.response?.status === 401) {
99
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
98
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
100
99
  process.exit(1);
101
100
  }
102
101
  else if (error.response?.status === 404) {
@@ -200,7 +199,12 @@ async function envPush(projectName, sourcePath, options = {}) {
200
199
  console.log(chalk_1.default.gray(` ${created} created, ${updated} updated` + (toSkip.length > 0 ? `, ${toSkip.length} skipped` : '')));
201
200
  }
202
201
  catch (error) {
203
- console.error(chalk_1.default.red('Failed to push variables:'), error.response?.data?.message || error.message);
202
+ if (error.response?.status === 401) {
203
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
204
+ }
205
+ else {
206
+ console.error(chalk_1.default.red('Failed to push variables:'), error.response?.data?.message || error.message);
207
+ }
204
208
  process.exit(1);
205
209
  }
206
210
  }
@@ -7,6 +7,7 @@ exports.envReset = envReset;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const api_1 = require("../utils/api");
10
+ const project_ref_1 = require("../utils/project-ref");
10
11
  function describeRestoredSource(mapping) {
11
12
  const sourceType = mapping.source_type || mapping.source || 'unknown';
12
13
  if (sourceType === 'oauth_connection') {
@@ -22,10 +23,8 @@ function describeRestoredSource(mapping) {
22
23
  async function envReset(projectName, key, options = {}) {
23
24
  const config = await (0, api_1.requireConfigWithWorkspace)();
24
25
  const environment = options.env || 'dev';
25
- const projectSlug = environment === 'production'
26
- ? projectName
27
- : `${projectName}-${environment}`;
28
26
  try {
27
+ const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
29
28
  const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, { headers: (0, api_1.getApiHeaders)(config) });
30
29
  const mappings = listResponse.data || [];
31
30
  const mapping = mappings.find((candidate) => candidate.env_name === key);
@@ -41,15 +40,20 @@ async function envReset(projectName, key, options = {}) {
41
40
  catch (error) {
42
41
  if (error.response) {
43
42
  if (error.response.status === 401) {
44
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
43
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
45
44
  }
46
45
  else if (error.response.status === 404) {
47
- const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
48
- console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment` +
49
- `${envsList ? ` (exists in: ${envsList})` : ''}.`));
46
+ const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
47
+ const envs = family?.environments ?? [];
48
+ if (envs.length > 0 && !envs.includes(environment)) {
49
+ console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}).`));
50
+ }
51
+ else {
52
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
53
+ }
50
54
  }
51
55
  else {
52
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
56
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
53
57
  }
54
58
  }
55
59
  else {
@@ -10,6 +10,7 @@ const axios_1 = __importDefault(require("axios"));
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  const prompts_1 = __importDefault(require("prompts"));
12
12
  const api_1 = require("../utils/api");
13
+ const project_ref_1 = require("../utils/project-ref");
13
14
  const env_1 = require("../utils/env");
14
15
  /** Returns true when stdin is not an interactive terminal (CI, pipes, scripts). */
15
16
  function isNonTty() {
@@ -63,13 +64,10 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
63
64
  process.exit(1);
64
65
  }
65
66
  const environment = options.env || 'dev';
66
- // Build project slug
67
- const projectSlug = environment === 'production'
68
- ? projectName
69
- : `${projectName}-${environment}`;
70
67
  // Auto-detect secrets
71
68
  const isSecret = options.secret || /secret|key|token|password|credential/i.test(key);
72
69
  try {
70
+ const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
73
71
  if (isOauthConnectionMode) {
74
72
  await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, {
75
73
  project_key: key,
@@ -126,18 +124,24 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
126
124
  catch (error) {
127
125
  if (error.response) {
128
126
  if (error.response.status === 401) {
129
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
127
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
130
128
  }
131
129
  else if (error.response.status === 404) {
132
- const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
133
- console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment${envsList ? ` (exists in: ${envsList})` : ''}.`
134
- + `\nRun 'solidactions project deploy ${projectName} -e ${environment} --create' first.`));
130
+ const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
131
+ const envs = family?.environments ?? [];
132
+ if (envs.length > 0 && !envs.includes(environment)) {
133
+ console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}).`
134
+ + `\nRun 'solidactions project deploy ${projectName} -e ${environment} --create' first.`));
135
+ }
136
+ else {
137
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
138
+ }
135
139
  }
136
140
  else if (error.response.status === 422) {
137
141
  console.error(chalk_1.default.red((0, api_1.formatValidationError)(error.response.data)));
138
142
  }
139
143
  else {
140
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
144
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
141
145
  }
142
146
  }
143
147
  else {
@@ -249,13 +253,13 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
249
253
  catch (error) {
250
254
  if (error.response) {
251
255
  if (error.response.status === 401) {
252
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
256
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
253
257
  }
254
258
  else if (error.response.status === 422) {
255
259
  console.error(chalk_1.default.red((0, api_1.formatValidationError)(error.response.data)));
256
260
  }
257
261
  else {
258
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
262
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
259
263
  }
260
264
  }
261
265
  else {
@@ -3,10 +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.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
6
+ exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.LoginHostInvalidError = exports.LoginHostConflictError = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
7
7
  exports.resolveLoginApiKey = resolveLoginApiKey;
8
8
  exports.clearConfig = clearConfig;
9
9
  exports.resolveLoginHost = resolveLoginHost;
10
+ exports.resolveLoginHostOrExit = resolveLoginHostOrExit;
10
11
  exports.backupPathFor = backupPathFor;
11
12
  exports.preflightDeviceLoginWrite = preflightDeviceLoginWrite;
12
13
  exports.persistPreflightedLoginCredential = persistPreflightedLoginCredential;
@@ -22,6 +23,7 @@ const prompts_1 = __importDefault(require("prompts"));
22
23
  const config_1 = require("../utils/config");
23
24
  const config_write_target_1 = require("../utils/config-write-target");
24
25
  const workspace_lookup_1 = require("../utils/workspace-lookup");
26
+ const host_display_1 = require("../utils/host-display");
25
27
  var workspace_lookup_2 = require("../utils/workspace-lookup");
26
28
  Object.defineProperty(exports, "selectWorkspaceInteractively", { enumerable: true, get: function () { return workspace_lookup_2.selectWorkspaceInteractively; } });
27
29
  exports.API_KEY_PROMPT = {
@@ -73,15 +75,76 @@ async function resolveLoginApiKey(apiKey, options = {}, dependencies = {}) {
73
75
  function clearConfig() {
74
76
  (0, config_1.removeConfigFile)((0, config_1.getGlobalConfigPath)());
75
77
  }
76
- function resolveLoginHost(options) {
77
- if (options.host) {
78
- return { host: options.host, isDefault: false };
78
+ class LoginHostConflictError extends Error {
79
+ flag;
80
+ envHost;
81
+ constructor(flag, envHost) {
82
+ super(`${flag} disagrees with SOLIDACTIONS_HOST=${(0, host_display_1.displayHost)(envHost)}; refusing to send the API key.`);
83
+ this.flag = flag;
84
+ this.envHost = envHost;
79
85
  }
80
- if (options.dev) {
81
- return { host: 'http://localhost:8000', isDefault: false };
86
+ }
87
+ exports.LoginHostConflictError = LoginHostConflictError;
88
+ class LoginHostInvalidError extends Error {
89
+ label;
90
+ raw;
91
+ constructor(label, raw) {
92
+ super(`${label}=${JSON.stringify(raw)} is not a usable host; refusing to send the API key.`);
93
+ this.label = label;
94
+ this.raw = raw;
82
95
  }
96
+ }
97
+ exports.LoginHostInvalidError = LoginHostInvalidError;
98
+ function resolveLoginHost(options, env = process.env) {
99
+ const strip = (h) => h.trim().replace(/\/+$/, '');
100
+ // Ruling 9: a non-empty value that strips to nothing is INVALID, never "absent".
101
+ const usable = (raw, label) => {
102
+ const value = strip(raw);
103
+ if (value === '')
104
+ throw new LoginHostInvalidError(label, raw);
105
+ return value;
106
+ };
107
+ const rawEnv = env.SOLIDACTIONS_HOST;
108
+ const envHost = rawEnv !== undefined && rawEnv.trim() !== '' ? usable(rawEnv, 'SOLIDACTIONS_HOST') : undefined;
109
+ const explicitHostFlag = (raw) => {
110
+ const host = usable(raw, '--host');
111
+ return { host, flag: `--host ${(0, host_display_1.displayHost)(host)}` };
112
+ };
113
+ const explicit = options.host !== undefined
114
+ ? explicitHostFlag(options.host)
115
+ : options.dev
116
+ ? { host: 'http://localhost:8000', flag: '--dev (http://localhost:8000)' }
117
+ : undefined;
118
+ if (explicit && envHost && (0, config_1.normalizeHost)(explicit.host) !== (0, config_1.normalizeHost)(envHost)) {
119
+ throw new LoginHostConflictError(explicit.flag, envHost);
120
+ }
121
+ if (explicit)
122
+ return { host: explicit.host, isDefault: false };
123
+ if (envHost)
124
+ return { host: envHost, isDefault: false };
83
125
  return { host: 'https://app.solidactions.com', isDefault: true };
84
126
  }
127
+ /**
128
+ * `resolveLoginHost` for the login commands: a refused host prints the
129
+ * refusal to stderr and exits 1 before any request or config write.
130
+ */
131
+ function resolveLoginHostOrExit(options) {
132
+ try {
133
+ return resolveLoginHost(options);
134
+ }
135
+ catch (error) {
136
+ if (error instanceof LoginHostConflictError) {
137
+ console.error(chalk_1.default.red(`error: ${error.message}`));
138
+ console.error(chalk_1.default.red('Unset SOLIDACTIONS_HOST or pass the same host to --host.'));
139
+ process.exit(1);
140
+ }
141
+ if (error instanceof LoginHostInvalidError) {
142
+ console.error(chalk_1.default.red(`error: ${error.message}`));
143
+ process.exit(1);
144
+ }
145
+ throw error;
146
+ }
147
+ }
85
148
  /**
86
149
  * Path for a timestamped backup of `targetPath`, e.g.
87
150
  * `config.json.bak-2026-07-05T12-30-00Z`. Pure — takes `now` so tests are
@@ -203,9 +266,9 @@ async function persistPreflightedLoginCredential(config, preflight, options) {
203
266
  }
204
267
  function loginHostLines(resolved) {
205
268
  if (resolved.isDefault) {
206
- return [`Logging into ${resolved.host} (SolidActions Cloud)`];
269
+ return [`Logging into ${(0, host_display_1.displayHost)(resolved.host)} (SolidActions Cloud)`];
207
270
  }
208
- return [`Host: ${resolved.host}`];
271
+ return [`Host: ${(0, host_display_1.displayHost)(resolved.host)}`];
209
272
  }
210
273
  /**
211
274
  * Shared tail of API-key and device login: resolve the workspace against an
@@ -361,11 +424,11 @@ async function completeLogin(config, workspaces, options, scope = null, prefligh
361
424
  }
362
425
  }
363
426
  async function login(apiKey, options) {
364
- const resolved = resolveLoginHost(options);
427
+ const resolved = resolveLoginHostOrExit(options);
365
428
  const host = resolved.host;
366
429
  if (!apiKey || apiKey.trim().length === 0) {
367
430
  console.error(chalk_1.default.red('Error: API key is required.'));
368
- console.log(chalk_1.default.gray('Generate an API key at: ') + chalk_1.default.blue(`${host}/settings/api-keys`));
431
+ console.log(chalk_1.default.gray('Generate an API key at: ') + chalk_1.default.blue(`${(0, host_display_1.displayHost)(host)}/settings/api-keys`));
369
432
  process.exit(1);
370
433
  }
371
434
  console.log(chalk_1.default.blue(`Initializing SolidActions CLI...`));
@@ -384,10 +447,10 @@ async function login(apiKey, options) {
384
447
  }
385
448
  catch (e) {
386
449
  if (e.response?.status === 401) {
387
- console.error(chalk_1.default.red(`Invalid API key for ${host}.`));
450
+ console.error(chalk_1.default.red(`Invalid API key for ${(0, host_display_1.displayHost)(host)}.`));
388
451
  }
389
452
  else {
390
- console.error(chalk_1.default.red(`Could not reach ${host}: ${e.message}`));
453
+ console.error(chalk_1.default.red(`Could not reach ${(0, host_display_1.displayHost)(host)}: ${e.message}`));
391
454
  }
392
455
  process.exit(1);
393
456
  return;
@@ -451,15 +514,16 @@ function whoami() {
451
514
  return chalk_1.default.gray('(unset)');
452
515
  return chalk_1.default.gray(`(from ${src})`);
453
516
  };
454
- const workspaceLabel = config.workspace
455
- ? `${config.workspace}${config.workspaceId ? ` (${config.workspaceId})` : ''}`
456
- : config.workspaceId
517
+ const workspaceName = config.workspace ?? config.workspaceId;
518
+ const workspaceLabel = !config.workspaceId && !config.workspace
519
+ ? ''
520
+ : !config.workspace
457
521
  ? `${config.workspaceId} (slug unknown — run 'workspace set <slug>' to populate)`
458
- : '';
459
- const isFileSource = (src) => src !== null && src !== 'env' && src !== 'cli';
460
- const workspaceInheritedFromOtherFile = isFileSource(sources.workspaceId) && sources.workspaceId !== sources.apiKey;
522
+ : config.workspaceOrg
523
+ ? `${workspaceName} — organization ${config.workspaceOrg}${config.workspaceId ? ` (${config.workspaceId})` : ''}`
524
+ : `${workspaceName}${config.workspaceId ? ` (${config.workspaceId})` : ''}`;
461
525
  console.log(chalk_1.default.blue('Current configuration:'));
462
- console.log(` Host: ${config.host.padEnd(50)} ${fmt(sources.host)}`);
526
+ console.log(` Host: ${(0, host_display_1.displayHost)(config.host).padEnd(50)} ${fmt(sources.host)}`);
463
527
  console.log(` API Key: ${maskedKey.padEnd(50)} ${fmt(sources.apiKey)}`);
464
- console.log(` Workspace: ${workspaceLabel.padEnd(50)} ${fmt(sources.workspaceId)}${workspaceInheritedFromOtherFile ? chalk_1.default.yellow(' (inherited from a different config file)') : ''}`);
528
+ console.log(` Workspace: ${workspaceLabel.padEnd(50)} ${fmt(sources.workspaceId)}`);
465
529
  }