@solidactions/cli 1.30.0 → 1.31.1

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 (44) hide show
  1. package/README.md +86 -12
  2. package/dist/commands/crew-env-delete.js +1 -1
  3. package/dist/commands/crew-env-list.js +9 -7
  4. package/dist/commands/crew-env-push.js +1 -1
  5. package/dist/commands/crew-env-set.js +1 -1
  6. package/dist/commands/docs-upload.js +1 -1
  7. package/dist/commands/env-delete.js +1 -1
  8. package/dist/commands/env-list.js +1 -1
  9. package/dist/commands/env-map.js +1 -1
  10. package/dist/commands/env-pull.js +2 -2
  11. package/dist/commands/env-push.js +2 -2
  12. package/dist/commands/env-set.js +7 -3
  13. package/dist/commands/login.js +50 -1
  14. package/dist/commands/oauth-actions-list.js +1 -1
  15. package/dist/commands/oauth-actions-platforms.js +1 -1
  16. package/dist/commands/oauth-actions-search.js +1 -1
  17. package/dist/commands/oauth-actions-show.js +1 -1
  18. package/dist/commands/project-create.js +1 -1
  19. package/dist/commands/project-list.js +1 -1
  20. package/dist/commands/project-logs.js +1 -1
  21. package/dist/commands/pull.js +1 -1
  22. package/dist/commands/run-list.js +1 -1
  23. package/dist/commands/run-start.js +1 -1
  24. package/dist/commands/run-view.js +1 -1
  25. package/dist/commands/schedule-delete.js +1 -1
  26. package/dist/commands/schedule-list.js +1 -1
  27. package/dist/commands/schedule-set.js +10 -13
  28. package/dist/commands/skill-dev.js +15 -0
  29. package/dist/commands/skill-exec.js +179 -7
  30. package/dist/commands/skill-pull.js +2 -14
  31. package/dist/commands/skill-push.js +2 -2
  32. package/dist/commands/skill-run.js +45 -22
  33. package/dist/commands/webhook-list.js +1 -1
  34. package/dist/commands/webhook-secret.js +1 -1
  35. package/dist/index.js +29 -12
  36. package/dist/utils/api.js +2 -2
  37. package/dist/utils/crew.js +48 -0
  38. package/dist/utils/github.js +7 -1
  39. package/dist/utils/mcp.js +26 -18
  40. package/dist/utils/skill-bundle.js +123 -0
  41. package/dist/utils/skill-cache-fs.js +133 -0
  42. package/dist/utils/skill-cache.js +84 -0
  43. package/dist/utils/skills.js +4 -2
  44. package/package.json +8 -5
@@ -3,26 +3,77 @@ 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.validateExecInvocation = validateExecInvocation;
6
7
  exports.skillExecWithConfig = skillExecWithConfig;
7
8
  exports.skillExec = skillExec;
8
9
  /**
9
- * solidactions skill exec <name> [--role <r>] [--environment <env>] -- <command...>
10
+ * solidactions skill exec <name> --target sandbox|host [...] -- <command...>
10
11
  *
11
- * Runs a command against the DEPLOYED skill in its real sandbox runtime via
12
- * the crews MCP exec_skill action — the post-push smoke step. Counterpart to
13
- * `skill run` (local). DELIBERATE DIVERGENCE from `skill run`: default
14
- * environment here is `production` (matches the server default — this is the
15
- * "verify deployed" step); `skill run` defaults to `dev` (a local dev loop).
12
+ * ALWAYS executes the server-stored skill (the artifact) — never local edits;
13
+ * that's `skill dev <dir>`. --target picks WHERE the stored skill executes:
14
+ * sandbox — the server-managed sandbox via crews MCP exec_skill (v1.30 behavior)
15
+ * host — this machine, from a transparent revision-checked cache under
16
+ * ~/.solidactions/cache/skills/ (no visible pull step)
17
+ * --target is REQUIRED (no default): a half-remembered command errors instead
18
+ * of guessing where to execute. Both targets default --environment production —
19
+ * moving execution between sandbox and host never silently changes the env.
16
20
  */
21
+ const fs_1 = __importDefault(require("fs"));
22
+ const axios_1 = __importDefault(require("axios"));
17
23
  const chalk_1 = __importDefault(require("chalk"));
24
+ const path_1 = __importDefault(require("path"));
18
25
  const api_1 = require("../utils/api");
19
26
  const mcp_1 = require("../utils/mcp");
20
27
  const skill_run_1 = require("./skill-run");
28
+ const crew_1 = require("../utils/crew");
29
+ const skill_cache_1 = require("../utils/skill-cache");
30
+ const skill_cache_fs_1 = require("../utils/skill-cache-fs");
31
+ const skill_bundle_1 = require("../utils/skill-bundle");
32
+ /** Pure invocation checks (option matrix + name shape). Returns error text or null. */
33
+ function validateExecInvocation(name, options) {
34
+ if (options.target !== 'sandbox' && options.target !== 'host') {
35
+ return "--target is required: 'sandbox' (run in the server sandbox) or 'host' (run on this machine from the stored skill)";
36
+ }
37
+ if (name.startsWith('./') || name.startsWith('../') || path_1.default.isAbsolute(name)) {
38
+ return `'${name}' looks like a directory — skill exec executes the server-stored skill by name. To run a working copy: skill dev ${name}`;
39
+ }
40
+ if (options.target === 'sandbox' && options.crew) {
41
+ return '--crew only applies to --target host (sandbox variable composition is server-side)';
42
+ }
43
+ if (options.target === 'sandbox' && options.envFile) {
44
+ return '--env-file only applies to --target host (the sandbox env is composed server-side)';
45
+ }
46
+ if (options.role && options.crew) {
47
+ return '--crew conflicts with --role: a role-scoped skill takes its variables from the crew the role lives in';
48
+ }
49
+ if (options.inCrew && !options.role) {
50
+ return '--in-crew requires --role';
51
+ }
52
+ return null;
53
+ }
21
54
  async function skillExecWithConfig(name, commandParts, options, config) {
55
+ const invalid = validateExecInvocation(name, options);
56
+ if (invalid) {
57
+ process.stderr.write(chalk_1.default.red(`error: ${invalid}\n`));
58
+ process.exit(1);
59
+ }
60
+ if (fs_1.default.existsSync(name) && fs_1.default.statSync(name).isDirectory()) {
61
+ process.stderr.write(chalk_1.default.red(`error: '${name}' looks like a directory — skill exec executes the server-stored skill by name. To run a working copy: skill dev ${name}\n`));
62
+ process.exit(1);
63
+ }
22
64
  if (commandParts.length === 0) {
23
- process.stderr.write(chalk_1.default.red('error: no command given — usage: skill exec <name> -- <command...>\n'));
65
+ process.stderr.write(chalk_1.default.red('error: no command given — usage: skill exec <name> --target sandbox|host -- <command...>\n'));
24
66
  process.exit(1);
25
67
  }
68
+ const environment = options.environment ?? 'production';
69
+ if (options.target === 'sandbox') {
70
+ await execInSandbox(name, commandParts, options, environment, config);
71
+ }
72
+ else {
73
+ await execOnHost(name, commandParts, options, environment, config);
74
+ }
75
+ }
76
+ async function execInSandbox(name, commandParts, options, environment, config) {
26
77
  const command = commandParts.map(skill_run_1.shellQuoteArg).join(' ');
27
78
  const isRole = Boolean(options.role);
28
79
  const tool = isRole ? 'roles' : 'skills';
@@ -33,6 +84,7 @@ async function skillExecWithConfig(name, commandParts, options, config) {
33
84
  args.environment = options.environment;
34
85
  if (isRole && options.inCrew)
35
86
  args.in_crew = options.inCrew;
87
+ process.stderr.write(chalk_1.default.blue(`▶ stored skill ${name} → sandbox (${environment})\n`));
36
88
  let result;
37
89
  try {
38
90
  result = await (0, mcp_1.callCrewsTool)(config, tool, args);
@@ -55,6 +107,126 @@ async function skillExecWithConfig(name, commandParts, options, config) {
55
107
  process.stderr.write(chalk_1.default.blue(`remote exec: status=${data.status ?? 'unknown'} exit_code=${data.exit_code ?? 'unknown'}\n`));
56
108
  process.exit(data.exit_code ?? 1);
57
109
  }
110
+ async function execOnHost(name, commandParts, options, environment, config) {
111
+ const isRole = Boolean(options.role);
112
+ const tool = isRole ? 'roles' : 'skills';
113
+ const locator = isRole
114
+ ? { role: options.role, name, ...(options.inCrew ? { in_crew: options.inCrew } : {}) }
115
+ : { identifier: name };
116
+ // 1. Fetch the bundle.
117
+ let result;
118
+ try {
119
+ result = await (0, mcp_1.callCrewsTool)(config, tool, isRole
120
+ ? { action: 'read_skill', ...locator }
121
+ : { action: 'read', ...locator });
122
+ }
123
+ catch (e) {
124
+ process.stderr.write(chalk_1.default.red(`error: ${e.message}\n`));
125
+ process.exit(1);
126
+ }
127
+ if (!result.ok) {
128
+ const code = result.data?.code ?? 'unknown_error';
129
+ const message = result.data?.message ?? 'MCP returned an error with no message';
130
+ process.stderr.write(chalk_1.default.red(`error: ${code}: ${message}\n`));
131
+ process.exit(1);
132
+ }
133
+ const bundle = (0, skill_bundle_1.normalizeBundle)(result.data);
134
+ for (const unsafe of bundle.skippedUnsafe) {
135
+ process.stderr.write(chalk_1.default.yellow(`warn: skipping unsafe reference key: ${unsafe}\n`));
136
+ }
137
+ // 2. Resolve crew identity (vars + cache scope).
138
+ let crewId = null;
139
+ let scope = { kind: 'shared' };
140
+ if (isRole) {
141
+ const crewPath = await (0, crew_1.resolveRoleCrewPath)(config, options.role, options.inCrew);
142
+ crewId = await (0, crew_1.crewIdForPath)(config, crewPath);
143
+ scope = { kind: 'role', crewPath, role: options.role };
144
+ }
145
+ else if (options.crew) {
146
+ crewId = (await (0, crew_1.resolveCrewId)(config, options.crew)).id;
147
+ }
148
+ else {
149
+ process.stderr.write(chalk_1.default.gray('no --crew given — running without crew variables (shared-skill parity)\n'));
150
+ }
151
+ // 3. Plan + refresh the cache under the lock.
152
+ const cacheDir = (0, skill_cache_1.cacheDirFor)(config, scope, name);
153
+ const origin = (0, skill_cache_1.cacheOrigin)(config);
154
+ const desired = { 'SKILL.md': { kind: 'text', sha256: (0, skill_cache_fs_1.sha256Hex)(bundle.skillMd) } };
155
+ for (const [p, content] of Object.entries(bundle.textFiles)) {
156
+ desired[p] = { kind: 'text', sha256: (0, skill_cache_fs_1.sha256Hex)(content) };
157
+ }
158
+ for (const [p, ref] of Object.entries(bundle.binaryFiles)) {
159
+ desired[p] = { kind: 'binary', blobSha: ref.blobSha };
160
+ }
161
+ await (0, skill_cache_fs_1.withCacheLock)(cacheDir, async () => {
162
+ const manifest = (0, skill_cache_fs_1.readManifest)(cacheDir);
163
+ const onDisk = (0, skill_cache_fs_1.onDiskHashes)(cacheDir, [...new Set([...Object.keys(desired), ...Object.keys(manifest?.files ?? {})])]);
164
+ const plan = (0, skill_cache_1.planCacheRefresh)({ manifest, origin, identity: bundle.identity, desired, onDisk });
165
+ if (plan.action === 'refresh') {
166
+ const contents = {};
167
+ const newFiles = {};
168
+ for (const p of Object.keys(desired)) {
169
+ const spec = desired[p];
170
+ if (spec.kind === 'text') {
171
+ const content = p === 'SKILL.md' ? bundle.skillMd : bundle.textFiles[p];
172
+ if (plan.writes.includes(p))
173
+ contents[p] = content;
174
+ newFiles[p] = { sha256: spec.sha256 };
175
+ }
176
+ else {
177
+ if (plan.writes.includes(p)) {
178
+ const ref = bundle.binaryFiles[p];
179
+ const bytes = await (0, skill_bundle_1.fetchBinaryReference)(config, tool, locator, p, { size: ref.size, blobSha: ref.blobSha });
180
+ contents[p] = bytes;
181
+ newFiles[p] = { sha256: (0, skill_cache_fs_1.sha256Hex)(bytes), blob_sha: spec.blobSha };
182
+ }
183
+ else {
184
+ // Invariant: the planner only omits a binary from writes when the
185
+ // manifest entry exists and matches (upstreamSame && diskSame), so
186
+ // this carry-over cannot be undefined.
187
+ newFiles[p] = manifest?.files[p];
188
+ }
189
+ }
190
+ }
191
+ (0, skill_cache_fs_1.applyCachePlan)(cacheDir, plan, contents, {
192
+ schema_version: 1,
193
+ origin,
194
+ doc_id: bundle.identity.docId,
195
+ published: bundle.identity.published,
196
+ execution_revision_id: bundle.identity.executionRevisionId,
197
+ files: newFiles,
198
+ });
199
+ }
200
+ });
201
+ // 4. Resolve crew variables.
202
+ let resolved = {};
203
+ let skippedSecrets = [];
204
+ if (crewId !== null) {
205
+ try {
206
+ const response = await axios_1.default.get(`${config.host}/api/v1/crews/${crewId}/variables/resolve?environment=${encodeURIComponent(environment)}`, { headers: (0, api_1.getApiHeaders)(config) });
207
+ resolved = response.data?.variables ?? {};
208
+ skippedSecrets = response.data?.skipped_secrets ?? [];
209
+ }
210
+ catch (e) {
211
+ process.stderr.write(chalk_1.default.red(`error: failed to resolve crew variables: ${e?.response?.data?.message ?? e.message}\n`));
212
+ process.exit(1);
213
+ }
214
+ }
215
+ // 5. Run.
216
+ if (!bundle.identity.published) {
217
+ process.stderr.write(chalk_1.default.yellow('running unpublished draft revision\n'));
218
+ }
219
+ (0, skill_run_1.execLocally)({
220
+ dir: cacheDir,
221
+ commandParts,
222
+ environment,
223
+ resolved,
224
+ skippedSecrets,
225
+ envFile: options.envFile,
226
+ config,
227
+ banner: `▶ stored skill ${name} @ rev ${bundle.identity.executionRevisionId ?? '?'} → local cache (${environment})`,
228
+ });
229
+ }
58
230
  async function skillExec(name, commandParts, options) {
59
231
  const config = await (0, api_1.requireConfigWithWorkspace)();
60
232
  await skillExecWithConfig(name, commandParts, options, config);
@@ -20,9 +20,9 @@ exports.skillPull = skillPull;
20
20
  const fs_1 = __importDefault(require("fs"));
21
21
  const path_1 = __importDefault(require("path"));
22
22
  const chalk_1 = __importDefault(require("chalk"));
23
- const js_yaml_1 = __importDefault(require("js-yaml"));
24
23
  const api_1 = require("../utils/api");
25
24
  const mcp_1 = require("../utils/mcp");
25
+ const skill_bundle_1 = require("../utils/skill-bundle");
26
26
  /** Filename of the provenance sidecar written alongside a pulled skill. */
27
27
  exports.SKILL_SIDECAR = '.solidactions-skill.json';
28
28
  /**
@@ -69,19 +69,7 @@ async function skillPullWithConfig(name, dest, options, config) {
69
69
  // The server stores a `type` field but it is stripped on push (parseSkillFile
70
70
  // does `const { type: _type, ...properties } = rest`). We mirror that here
71
71
  // so that pull → push is idempotent.
72
- const { type: _type, name: propName, description: propDescription, ...extraProps } = data.properties;
73
- // Reconstruct the full frontmatter: name + description (from properties)
74
- // followed by all remaining extra props (minus type).
75
- const frontmatterObj = {
76
- name: propName,
77
- description: propDescription,
78
- ...extraProps,
79
- };
80
- // yaml.dump produces "key: value\n" lines; we wrap in ---\n...\n---\n
81
- const yamlBlock = js_yaml_1.default.dump(frontmatterObj, { lineWidth: -1 });
82
- const body = data.body ?? '';
83
- // Ensure the body starts on its own line after the closing ---
84
- const skillMdContent = `---\n${yamlBlock}---\n${body.startsWith('\n') ? body : '\n' + body}`;
72
+ const skillMdContent = (0, skill_bundle_1.reconstructSkillMd)(data.properties, data.body);
85
73
  // Create the output directory (and parents) if needed
86
74
  fs_1.default.mkdirSync(absOut, { recursive: true });
87
75
  // Write SKILL.md
@@ -102,7 +102,7 @@ function parseSkillFile(content) {
102
102
  * SKILL.md cites them, so bundled reference docs land complete (#247).
103
103
  *
104
104
  * Also excludes `skill pull`'s provenance sidecar (SKILL_SIDECAR) and
105
- * `skill run`'s local runtime-state dir (.sa-state/) — neither is skill
105
+ * `skill dev`'s local runtime-state dir (.sa-state/) — neither is skill
106
106
  * content, and uploading them would leak local revision bookkeeping / state
107
107
  * into the remote library and agent sandboxes.
108
108
  */
@@ -113,7 +113,7 @@ function readReferences(dir) {
113
113
  const abs = path_1.default.join(current, entry.name);
114
114
  if (entry.isDirectory()) {
115
115
  if (entry.name === '.sa-state')
116
- continue; // skill run's local runtime-state dir
116
+ continue; // skill dev's local runtime-state dir
117
117
  walk(abs);
118
118
  continue;
119
119
  }
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.shellQuoteArg = shellQuoteArg;
7
7
  exports.parseEnvFile = parseEnvFile;
8
8
  exports.assembleEnv = assembleEnv;
9
+ exports.execLocally = execLocally;
9
10
  exports.skillRunWithConfig = skillRunWithConfig;
10
11
  exports.skillRun = skillRun;
11
12
  /**
12
- * solidactions skill run <dir> [--crew <c>] [--environment <env>] [--env-file <f>] -- <command...>
13
+ * solidactions skill dev <dir> [--crew <c>] [--environment <env>] [--env-file <f>] -- <command...>
13
14
  *
14
15
  * Local analogue of the crews MCP exec_skill: runs <command> with cwd=<dir>
15
16
  * (matching the sandbox's cwd=/work/skills/<slug>), with crew variables
@@ -106,14 +107,47 @@ function readStorageScope(dir) {
106
107
  const scope = fm?.storage?.scope ?? fm?.['storage.scope'] ?? null;
107
108
  return scope === 'crew' || scope === 'workspace' ? scope : null;
108
109
  }
110
+ /**
111
+ * Shared local runner: env assembly + provenance banner + spawn. Used by both
112
+ * `skill dev` (working copy) and `skill exec --target host` (cached artifact).
113
+ */
114
+ function execLocally(args) {
115
+ const fileVars = args.envFile ? parseEnvFile(fs_1.default.readFileSync(path_1.default.resolve(args.envFile), 'utf8')) : {};
116
+ const storageScope = readStorageScope(args.dir);
117
+ const { env, warnings } = assembleEnv({
118
+ resolved: args.resolved, fileVars, storageScope, dir: args.dir, config: args.config,
119
+ });
120
+ for (const w of warnings)
121
+ process.stderr.write(chalk_1.default.yellow(`warn: ${w}\n`));
122
+ if (env.SOLIDACTIONS_STATE_DIR)
123
+ fs_1.default.mkdirSync(env.SOLIDACTIONS_STATE_DIR, { recursive: true });
124
+ if (env.SOLIDACTIONS_SHARED_DIR)
125
+ fs_1.default.mkdirSync(env.SOLIDACTIONS_SHARED_DIR, { recursive: true });
126
+ process.stderr.write(chalk_1.default.blue(`${args.banner}\n`));
127
+ if (args.skippedSecrets.length > 0) {
128
+ process.stderr.write(chalk_1.default.yellow(`${args.skippedSecrets.length} secret ${args.skippedSecrets.length === 1 ? 'var' : 'vars'} unavailable (${args.skippedSecrets.join(', ')}): ` +
129
+ `your API key lacks the 'env:reveal' ability. Mint a key with env:reveal, set a dev value with \`solidactions crew env set\`, or use --env-file.\n`));
130
+ }
131
+ const result = (0, child_process_1.spawnSync)(args.commandParts.map(shellQuoteArg).join(' '), {
132
+ shell: true,
133
+ cwd: args.dir,
134
+ stdio: 'inherit',
135
+ env: { ...process.env, ...env },
136
+ });
137
+ process.exit(result.status ?? 1);
138
+ }
109
139
  async function skillRunWithConfig(dir, commandParts, options, config) {
110
140
  const absDir = path_1.default.resolve(dir);
141
+ if (!fs_1.default.existsSync(absDir) || !fs_1.default.statSync(absDir).isDirectory()) {
142
+ process.stderr.write(chalk_1.default.red(`error: '${dir}' is not a directory — skill dev runs a local working folder. To execute the stored skill locally: skill exec ${dir} --target host\n`));
143
+ process.exit(1);
144
+ }
111
145
  if (!fs_1.default.existsSync(path_1.default.join(absDir, 'SKILL.md'))) {
112
146
  process.stderr.write(chalk_1.default.red(`error: ${dir} does not contain a SKILL.md\n`));
113
147
  process.exit(1);
114
148
  }
115
149
  if (commandParts.length === 0) {
116
- process.stderr.write(chalk_1.default.red('error: no command given — usage: skill run <dir> -- <command...>\n'));
150
+ process.stderr.write(chalk_1.default.red('error: no command given — usage: skill dev <dir> -- <command...>\n'));
117
151
  process.exit(1);
118
152
  }
119
153
  const environment = options.environment ?? 'dev';
@@ -135,28 +169,17 @@ async function skillRunWithConfig(dir, commandParts, options, config) {
135
169
  else {
136
170
  process.stderr.write(chalk_1.default.gray('no --crew given — running without crew variables (shared-skill parity)\n'));
137
171
  }
138
- const fileVars = options.envFile ? parseEnvFile(fs_1.default.readFileSync(path_1.default.resolve(options.envFile), 'utf8')) : {};
139
- const storageScope = readStorageScope(absDir);
140
- const { env, warnings } = assembleEnv({ resolved, fileVars, storageScope, dir: absDir, config });
141
- for (const w of warnings)
142
- process.stderr.write(chalk_1.default.yellow(`warn: ${w}\n`));
143
- if (env.SOLIDACTIONS_STATE_DIR)
144
- fs_1.default.mkdirSync(env.SOLIDACTIONS_STATE_DIR, { recursive: true });
145
- if (env.SOLIDACTIONS_SHARED_DIR)
146
- fs_1.default.mkdirSync(env.SOLIDACTIONS_SHARED_DIR, { recursive: true });
147
172
  const plainCount = Object.keys(resolved).length;
148
- process.stderr.write(chalk_1.default.blue(`running locally in ${dir} — env '${environment}', ${plainCount} crew vars loaded\n`));
149
- if (skippedSecrets.length > 0) {
150
- process.stderr.write(chalk_1.default.yellow(`${skippedSecrets.length} secret ${skippedSecrets.length === 1 ? 'var' : 'vars'} unavailable (${skippedSecrets.join(', ')}): ` +
151
- `your API key lacks the 'env:reveal' ability. Mint a key with env:reveal, set a dev value with \`solidactions crew env set\`, or use --env-file.\n`));
152
- }
153
- const result = (0, child_process_1.spawnSync)(commandParts.map(shellQuoteArg).join(' '), {
154
- shell: true,
155
- cwd: absDir,
156
- stdio: 'inherit',
157
- env: { ...process.env, ...env },
173
+ execLocally({
174
+ dir: absDir,
175
+ commandParts,
176
+ environment,
177
+ resolved,
178
+ skippedSecrets,
179
+ envFile: options.envFile,
180
+ config,
181
+ banner: `▶ working copy ${dir} → local (${environment}) — ${plainCount} crew vars`,
158
182
  });
159
- process.exit(result.status ?? 1);
160
183
  }
161
184
  async function skillRun(dir, commandParts, options) {
162
185
  const config = await (0, api_1.requireConfigWithWorkspace)();
@@ -50,7 +50,7 @@ async function webhookList(projectName, options = {}) {
50
50
  catch (error) {
51
51
  if (error.response) {
52
52
  if (error.response.status === 401) {
53
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
53
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
54
54
  }
55
55
  else if (error.response.status === 404) {
56
56
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
@@ -57,7 +57,7 @@ async function webhookSecret(projectName, options = {}) {
57
57
  catch (error) {
58
58
  if (error.response) {
59
59
  if (error.response.status === 401) {
60
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login <api-key>" to re-configure.'));
60
+ console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
61
61
  }
62
62
  else if (error.response.status === 404) {
63
63
  console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
package/dist/index.js CHANGED
@@ -41,7 +41,7 @@ const skill_pull_1 = require("./commands/skill-pull");
41
41
  const skill_list_1 = require("./commands/skill-list");
42
42
  const skill_view_1 = require("./commands/skill-view");
43
43
  const skill_delete_1 = require("./commands/skill-delete");
44
- const skill_run_1 = require("./commands/skill-run");
44
+ const skill_dev_1 = require("./commands/skill-dev");
45
45
  const skill_exec_1 = require("./commands/skill-exec");
46
46
  const role_push_1 = require("./commands/role-push");
47
47
  const docs_push_1 = require("./commands/docs-push");
@@ -108,8 +108,9 @@ program.hook('preAction', (thisCommand, actionCommand) => {
108
108
  // =============================================================================
109
109
  program
110
110
  .command('login')
111
- .description('Authenticate the CLI with your API key')
112
- .argument('<api-key>', 'Your SolidActions API key')
111
+ .description('Authenticate the CLI (prompts securely for your API key)')
112
+ .argument('[api-key]', 'Legacy positional API key (prefer the masked prompt or --stdin)')
113
+ .option('--stdin', 'Read the API key from stdin (for non-interactive automation)')
113
114
  .option('--dev', 'Use local development server (http://localhost:8000)')
114
115
  .option('--host <url>', 'Custom API host URL')
115
116
  .option('--workspace <name-or-id>', 'Set workspace by name, slug, or ID (skips interactive prompt). Non-interactive logins without this flag leave the workspace unset.')
@@ -117,7 +118,8 @@ program
117
118
  .option('--global', 'Save config to ~/.solidactions/config.json (default if prompted)')
118
119
  .option('--gitignore', 'With --local, add .solidactions/ to .gitignore without prompting')
119
120
  .action(async (apiKey, options) => {
120
- await (0, login_1.login)(apiKey, options);
121
+ const resolvedApiKey = await (0, login_1.resolveLoginApiKey)(apiKey, { stdin: options.stdin });
122
+ await (0, login_1.login)(resolvedApiKey, options);
121
123
  });
122
124
  program
123
125
  .command('init')
@@ -557,24 +559,39 @@ skill
557
559
  await (0, skill_delete_1.skillDelete)(name, options);
558
560
  });
559
561
  skill
560
- .command('run')
561
- .description('Run a skill script LOCALLY with crew variables fetched from the platform (dev loop; default env dev; secrets need env:reveal; see `skill exec` for the remote/deployed counterpart, default env production)')
562
+ .command('dev')
563
+ .description('Run YOUR WORKING COPY of a skill locally with crew variables fetched from the platform (dev loop; default env dev; secrets need env:reveal). To execute the server-stored skill instead: skill exec <name> --target sandbox|host')
562
564
  .argument('<dir>', 'Local skill directory (must contain SKILL.md)')
563
565
  .argument('<command...>', 'Command to run (after --), e.g. -- node scripts/q.js')
564
566
  .option('--crew <nameOrId>', 'Crew whose variables to fetch (omit for shared skills)')
565
567
  .option('--environment <env>', 'Variable environment: production|staging|dev', 'dev')
566
568
  .option('--env-file <path>', 'Local KEY=VALUE overrides (reserved names ignored)')
567
569
  .action(async (dir, commandParts, options) => {
568
- await (0, skill_run_1.skillRun)(dir, commandParts, options);
570
+ await (0, skill_dev_1.skillDev)(dir, commandParts, options);
571
+ });
572
+ skill
573
+ .command('run', { hidden: true })
574
+ .description('[deprecated] alias of `skill dev` — removed in v2.0.0')
575
+ .argument('<dir>', 'Local skill directory (must contain SKILL.md)')
576
+ .argument('<command...>', 'Command to run (after --)')
577
+ .option('--crew <nameOrId>', 'Crew whose variables to fetch (omit for shared skills)')
578
+ .option('--environment <env>', 'Variable environment: production|staging|dev', 'dev')
579
+ .option('--env-file <path>', 'Local KEY=VALUE overrides (reserved names ignored)')
580
+ .action(async (dir, commandParts, options) => {
581
+ process.stderr.write(chalk_1.default.yellow("warn: 'skill run' is deprecated — use 'skill dev' (alias removed in v2.0.0)\n"));
582
+ await (0, skill_dev_1.skillDev)(dir, commandParts, options);
569
583
  });
570
584
  skill
571
585
  .command('exec')
572
- .description('Run a command against the DEPLOYED skill in its real sandbox runtime (post-push smoke; default env production; see `skill run` for the local dev-loop counterpart, default env dev)')
573
- .argument('<name>', 'Skill name or identifier')
574
- .argument('<command...>', 'Command to run remotely (after --), e.g. -- node scripts/q.js')
575
- .option('--role <name>', 'Role-scoped skill (uses roles.exec_skill)')
586
+ .description('Execute the SERVER-STORED skill (never local edits — see `skill dev`). --target picks where: sandbox (server) or host (this machine, transparent cache). Default env production for both targets; secrets on host need env:reveal')
587
+ .argument('<name>', 'Skill name or identifier (names only — directories are rejected)')
588
+ .argument('<command...>', 'Command to run (after --), e.g. -- node scripts/q.js')
589
+ .requiredOption('--target <target>', "Where to execute: 'sandbox' or 'host'")
590
+ .option('--role <name>', 'Role-scoped skill (crew inferred from the role)')
576
591
  .option('--in-crew <crew>', 'Disambiguate when the role name exists in multiple crews')
577
- .option('--environment <env>', 'Sandbox environment: production|staging|dev (default production)')
592
+ .option('--crew <nameOrId>', 'host+shared only: crew whose variables to fetch')
593
+ .option('--environment <env>', 'Variable environment: production|staging|dev (default production)')
594
+ .option('--env-file <path>', 'host only: local KEY=VALUE overrides (reserved names ignored)')
578
595
  .action(async (name, commandParts, options) => {
579
596
  await (0, skill_exec_1.skillExec)(name, commandParts, options);
580
597
  });
package/dist/utils/api.js CHANGED
@@ -108,7 +108,7 @@ function formatValidationError(data) {
108
108
  function requireResolvedConfig() {
109
109
  const resolved = (0, config_1.resolveConfig)();
110
110
  if (!resolved || !resolved.config.apiKey) {
111
- console.error(chalk_1.default.red('Not initialized. Run `solidactions login <api-key>` first.'));
111
+ console.error(chalk_1.default.red('Not initialized. Run `solidactions login --global` first.'));
112
112
  process.exit(1);
113
113
  }
114
114
  return resolved;
@@ -123,7 +123,7 @@ function requireConfig() {
123
123
  */
124
124
  function authFailureMessage(config, sources) {
125
125
  const keySource = sources?.apiKey ?? 'config';
126
- return `Authentication failed against ${config.host} (key from ${keySource}). Run \`solidactions login <api-key>\` to re-configure.`;
126
+ return `Authentication failed against ${config.host} (key from ${keySource}). Run \`solidactions login --global\` to re-configure.`;
127
127
  }
128
128
  async function ensureWorkspaceSelected(config) {
129
129
  if (config.workspaceId) {
@@ -10,9 +10,12 @@ exports.isNumericCrewArg = isNumericCrewArg;
10
10
  exports.matchCrewByName = matchCrewByName;
11
11
  exports.fetchCrews = fetchCrews;
12
12
  exports.resolveCrewId = resolveCrewId;
13
+ exports.resolveRoleCrewPath = resolveRoleCrewPath;
14
+ exports.crewIdForPath = crewIdForPath;
13
15
  const axios_1 = __importDefault(require("axios"));
14
16
  const chalk_1 = __importDefault(require("chalk"));
15
17
  const api_1 = require("./api");
18
+ const mcp_1 = require("./mcp");
16
19
  exports.CREW_ENV_VALUES = ['production', 'staging', 'dev', 'all'];
17
20
  function isValidCrewEnv(value) {
18
21
  return exports.CREW_ENV_VALUES.includes(value);
@@ -70,3 +73,48 @@ async function resolveCrewId(config, input) {
70
73
  }
71
74
  return result.crew;
72
75
  }
76
+ /**
77
+ * Resolve the containment crew path for a role-scoped skill. --in-crew names it
78
+ * directly; otherwise roles.list is consulted (each entry carries in_crew).
79
+ * roles.read_skill does NOT return the crew, so this lookup is load-bearing for
80
+ * both variable resolution and cache scoping.
81
+ */
82
+ async function resolveRoleCrewPath(config, role, inCrew) {
83
+ if (inCrew)
84
+ return inCrew;
85
+ const result = await (0, mcp_1.callCrewsTool)(config, 'roles', { action: 'list' });
86
+ if (!result.ok) {
87
+ console.error(chalk_1.default.red(`Failed to list roles: ${result.data?.message ?? 'unknown error'}`));
88
+ process.exit(1);
89
+ }
90
+ const roles = result.data?.roles ?? [];
91
+ const matches = roles.filter((r) => r.identifier === role);
92
+ if (matches.length === 0) {
93
+ console.error(chalk_1.default.red(`Role "${role}" not found.`));
94
+ process.exit(1);
95
+ }
96
+ if (matches.length > 1) {
97
+ console.error(chalk_1.default.red(`Role "${role}" exists in multiple crews — pass --in-crew <crew>:`));
98
+ for (const m of matches)
99
+ console.error(chalk_1.default.gray(` --in-crew ${m.in_crew ?? '(legacy flat role)'}`));
100
+ process.exit(1);
101
+ }
102
+ if (!matches[0].in_crew) {
103
+ console.error(chalk_1.default.red(`Role "${role}" is a legacy flat role with no crew — crew variables cannot be resolved.`));
104
+ process.exit(1);
105
+ }
106
+ return matches[0].in_crew;
107
+ }
108
+ /** Map a containment crew path (e.g. "acme/marketing") to the crew doc id used by /variables/resolve. */
109
+ async function crewIdForPath(config, crewPath) {
110
+ const crews = await fetchCrews(config);
111
+ const byPath = crews.filter((c) => c.path === crewPath);
112
+ if (byPath.length === 1)
113
+ return byPath[0].id;
114
+ const lastSegment = crewPath.split('/').pop() ?? crewPath;
115
+ const byName = crews.filter((c) => c.name.toLowerCase() === lastSegment.toLowerCase());
116
+ if (byName.length === 1)
117
+ return byName[0].id;
118
+ console.error(chalk_1.default.red(`Could not resolve crew "${crewPath}" to a crew id (matched ${byPath.length} by path, ${byName.length} by name).`));
119
+ process.exit(1);
120
+ }
@@ -3,12 +3,18 @@ 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.rawContentUrl = rawContentUrl;
6
7
  exports.fetchRawFile = fetchRawFile;
7
8
  exports.listRepoContents = listRepoContents;
8
9
  const axios_1 = __importDefault(require("axios"));
10
+ const DEFAULT_RAW_CONTENT_BASE_URL = 'https://raw.githubusercontent.com';
11
+ function rawContentUrl(owner, repo, path, branch = 'main') {
12
+ const baseUrl = (process.env.SOLIDACTIONS_RAW_CONTENT_BASE_URL ?? DEFAULT_RAW_CONTENT_BASE_URL).replace(/\/$/, '');
13
+ return `${baseUrl}/${owner}/${repo}/${branch}/${path}`;
14
+ }
9
15
  async function fetchRawFile(owner, repo, path, branch = 'main') {
10
16
  try {
11
- const url = `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${path}`;
17
+ const url = rawContentUrl(owner, repo, path, branch);
12
18
  const response = await axios_1.default.get(url, { responseType: 'text' });
13
19
  return response.data;
14
20
  }