@solidactions/cli 3.20.1 → 3.22.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 +12 -6
  2. package/dist/command-manifest.json +18 -7
  3. package/dist/commands/connection-list.js +2 -2
  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-push.js +5 -2
  7. package/dist/commands/crew-env-set.js +2 -2
  8. package/dist/commands/database-push.js +1 -1
  9. package/dist/commands/deploy.js +41 -12
  10. package/dist/commands/dev.js +4 -4
  11. package/dist/commands/doc-pull.js +531 -73
  12. package/dist/commands/doc-push.js +291 -28
  13. package/dist/commands/doc-upload.js +5 -2
  14. package/dist/commands/env-delete.js +12 -5
  15. package/dist/commands/env-list.js +19 -14
  16. package/dist/commands/env-map.js +7 -5
  17. package/dist/commands/env-pull.js +5 -6
  18. package/dist/commands/env-push.js +10 -6
  19. package/dist/commands/env-reset.js +12 -8
  20. package/dist/commands/env-set.js +15 -11
  21. package/dist/commands/init.js +4 -1
  22. package/dist/commands/login.js +15 -18
  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 +27 -22
  33. package/dist/commands/run-start.js +22 -18
  34. package/dist/commands/run-view.js +10 -22
  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/state.js +3 -3
  40. package/dist/commands/webhook-list.js +12 -4
  41. package/dist/commands/webhook-secret.js +12 -4
  42. package/dist/commands/workflow-view.js +3 -3
  43. package/dist/commands/workspaces.js +58 -3
  44. package/dist/index.js +13 -7
  45. package/dist/utils/api.js +69 -4
  46. package/dist/utils/config.js +96 -3
  47. package/dist/utils/crew.js +6 -1
  48. package/dist/utils/mcp.js +7 -3
  49. package/dist/utils/project-ref.js +91 -0
  50. package/dist/utils/run-status.js +61 -0
  51. package/dist/utils/secure-write.js +40 -5
  52. package/dist/utils/workspace-lookup.js +30 -3
  53. package/package.json +2 -2
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.secretTempPath = secretTempPath;
6
7
  exports.writeSecretFileSync = writeSecretFileSync;
7
8
  exports.writeViaTempFileSync = writeViaTempFileSync;
8
9
  const crypto_1 = __importDefault(require("crypto"));
@@ -37,6 +38,29 @@ function resolveCreationPath(filePath) {
37
38
  error.code = 'ELOOP';
38
39
  throw error;
39
40
  }
41
+ /** Sibling temp path for `target`: `<basename>.<pid>.<hex>.tmp`, so a leaked `.env` temp still matches `.env*` ignores (cli#129). */
42
+ function secretTempPath(target) {
43
+ return path_1.default.join(path_1.default.dirname(target), `${path_1.default.basename(target)}.${process.pid}.${crypto_1.default.randomBytes(4).toString('hex')}.tmp`);
44
+ }
45
+ /**
46
+ * In-place write for a target rename(2) cannot replace (a file-level bind mount is a mount
47
+ * point: `docker run -v ./.env:/app/.env`). The mode is forced to 0600 BEFORE the old
48
+ * content is truncated or any new byte is written. Deliberately not atomic — see the
49
+ * cli-trust spec §6 "Deliberate consequences".
50
+ */
51
+ function writeInPlaceOwnerOnlySync(target, contents) {
52
+ // O_NOFOLLOW: never write a secret through a symlink (PM ruling 5). Rename replaces a link;
53
+ // an in-place open would follow it. Undefined on Windows, where this path never runs.
54
+ const fd = fs_1.default.openSync(target, fs_1.default.constants.O_RDWR | (fs_1.default.constants.O_NOFOLLOW ?? 0));
55
+ try {
56
+ fs_1.default.fchmodSync(fd, 0o600);
57
+ fs_1.default.ftruncateSync(fd, 0);
58
+ fs_1.default.writeFileSync(fd, contents);
59
+ }
60
+ finally {
61
+ fs_1.default.closeSync(fd);
62
+ }
63
+ }
40
64
  /**
41
65
  * Write a secret-bearing file so the result is owner-only, whether or not the
42
66
  * destination already exists.
@@ -50,6 +74,8 @@ function resolveCreationPath(filePath) {
50
74
  *
51
75
  * The mode is masked by the process umask, which can only subtract bits, so
52
76
  * the result is always <= 0600: never group- or world-readable.
77
+ *
78
+ * On `EBUSY` it falls back to an owner-only in-place write (not atomic).
53
79
  */
54
80
  function writeSecretFileSync(filePath, contents) {
55
81
  let stats;
@@ -71,7 +97,7 @@ function writeSecretFileSync(filePath, contents) {
71
97
  return;
72
98
  }
73
99
  const target = stats ? fs_1.default.realpathSync(filePath) : resolveCreationPath(filePath);
74
- const tempPath = path_1.default.join(path_1.default.dirname(target), `.${path_1.default.basename(target)}.${process.pid}.${crypto_1.default.randomBytes(4).toString('hex')}.tmp`);
100
+ const tempPath = secretTempPath(target);
75
101
  writeViaTempFileSync(target, tempPath, contents);
76
102
  }
77
103
  /**
@@ -80,15 +106,25 @@ function writeSecretFileSync(filePath, contents) {
80
106
  * Exported so tests can stage a collision at a known temp path; production
81
107
  * callers go through writeSecretFileSync, which randomizes that path.
82
108
  */
83
- function writeViaTempFileSync(target, tempPath, contents) {
109
+ function writeViaTempFileSync(target, tempPath, contents, rename = fs_1.default.renameSync) {
84
110
  let created = false;
85
111
  try {
86
112
  // 'wx' refuses to follow or clobber an existing (or planted) temp path.
87
113
  fs_1.default.writeFileSync(tempPath, contents, { flag: 'wx', mode: 0o600 });
88
114
  created = true;
89
- fs_1.default.renameSync(tempPath, target);
115
+ try {
116
+ rename(tempPath, target);
117
+ created = false; // the temp file IS the target now
118
+ return;
119
+ }
120
+ catch (error) {
121
+ if (error.code !== 'EBUSY') {
122
+ throw error;
123
+ }
124
+ }
125
+ writeInPlaceOwnerOnlySync(target, contents);
90
126
  }
91
- catch (error) {
127
+ finally {
92
128
  // Only our own temp file may be removed: a failed 'wx' means the path
93
129
  // holds someone else's file, which is not ours to delete.
94
130
  if (created) {
@@ -99,6 +135,5 @@ function writeViaTempFileSync(target, tempPath, contents) {
99
135
  // Nothing to clean up.
100
136
  }
101
137
  }
102
- throw error;
103
138
  }
104
139
  }
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.suggestWorkspaces = suggestWorkspaces;
6
7
  exports.classifyWorkspaceInput = classifyWorkspaceInput;
7
8
  exports.describeWorkspaceMatchFailure = describeWorkspaceMatchFailure;
8
9
  exports.groupWorkspacesByOrg = groupWorkspacesByOrg;
@@ -13,6 +14,23 @@ exports.resolveWorkspaceInput = resolveWorkspaceInput;
13
14
  const axios_1 = __importDefault(require("axios"));
14
15
  const chalk_1 = __importDefault(require("chalk"));
15
16
  const readline_1 = __importDefault(require("readline"));
17
+ /**
18
+ * Workspaces whose slug or name contains the input (or is contained in it), case-insensitively —
19
+ * offered after a miss, never selected (cli#112). Reverse containment only counts for
20
+ * slugs/names of 3+ characters, so a one-letter workspace isn't suggested for every miss.
21
+ */
22
+ function suggestWorkspaces(input, workspaces, limit = 5) {
23
+ const needle = input.trim().toLowerCase();
24
+ if (needle === '')
25
+ return [];
26
+ const similar = (value) => {
27
+ if (!value)
28
+ return false;
29
+ const hay = value.toLowerCase();
30
+ return hay.includes(needle) || (hay.length >= 3 && needle.includes(hay));
31
+ };
32
+ return workspaces.filter((w) => similar(w.slug) || similar(w.name)).slice(0, limit);
33
+ }
16
34
  /**
17
35
  * Pure: given a list of workspaces and an input string, classify the match.
18
36
  * Match order: id, slug, name — but unlike a bare first-match, NAME matches
@@ -47,7 +65,8 @@ function classifyWorkspaceInput(input, workspaces) {
47
65
  if (orgWorkspaces.length > 0) {
48
66
  return { kind: 'org-only', input, orgWorkspaces };
49
67
  }
50
- return { kind: 'not-found', input };
68
+ const suggestions = suggestWorkspaces(input, workspaces);
69
+ return suggestions.length > 0 ? { kind: 'not-found', input, suggestions } : { kind: 'not-found', input };
51
70
  }
52
71
  // Union name matches with same-named-org workspaces (not just when
53
72
  // there's exactly one name match): two workspaces can share the input's
@@ -120,8 +139,16 @@ function describeWorkspaceMatchFailure(result) {
120
139
  ];
121
140
  return lines.join('\n');
122
141
  }
123
- case 'not-found':
124
- return `Workspace "${result.input}" not found. Run \`solidactions workspace list\` to list available workspaces.`;
142
+ case 'not-found': {
143
+ const base = `Workspace "${result.input}" not found. Run \`solidactions workspace list\` to list available workspaces.`;
144
+ if (!result.suggestions?.length)
145
+ return base;
146
+ const names = result.suggestions.map((w) => {
147
+ const org = w.org_name || w.tenant_name;
148
+ return `${w.slug ?? w.name}${org ? ` (${org})` : ''}`;
149
+ });
150
+ return `${base}\nDid you mean: ${names.join(', ')}?`;
151
+ }
125
152
  case 'match':
126
153
  return '';
127
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.20.1",
3
+ "version": "3.22.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -62,6 +62,6 @@
62
62
  "@types/prompts": "^2.4.9",
63
63
  "@types/tar": "^6.1.13",
64
64
  "typescript": "^5.0.0",
65
- "vitest": "^4.1.5"
65
+ "vitest": "^4.1.11"
66
66
  }
67
67
  }