@solidactions/cli 1.25.0 → 1.27.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.
@@ -3,9 +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.SKILLS_TIP_LINES = void 0;
6
+ exports.PLAN_LIMIT_NON_INTERACTIVE_HINT = exports.SKILLS_TIP_LINES = void 0;
7
7
  exports.cacheBusterEntry = cacheBusterEntry;
8
8
  exports.shouldPrintWorkspaceMismatch = shouldPrintWorkspaceMismatch;
9
+ exports.isPlanLimitReachedError = isPlanLimitReachedError;
10
+ exports.handlePlanLimitReached = handlePlanLimitReached;
9
11
  exports.deploy = deploy;
10
12
  exports.shouldPrintWebhookSecretNotice = shouldPrintWebhookSecretNotice;
11
13
  const fs_1 = __importDefault(require("fs"));
@@ -16,6 +18,7 @@ const axios_1 = __importDefault(require("axios"));
16
18
  const form_data_1 = __importDefault(require("form-data"));
17
19
  const chalk_1 = __importDefault(require("chalk"));
18
20
  const js_yaml_1 = __importDefault(require("js-yaml"));
21
+ const prompts_1 = __importDefault(require("prompts"));
19
22
  const env_1 = require("../utils/env");
20
23
  const api_1 = require("../utils/api");
21
24
  const deploy_ignore_1 = require("../utils/deploy-ignore");
@@ -149,6 +152,84 @@ async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
149
152
  function shouldPrintWorkspaceMismatch(environment, willCreate) {
150
153
  return environment !== 'production' && !willCreate;
151
154
  }
155
+ /**
156
+ * Printed (after the server's own message) when a free-plan tenant hits the
157
+ * dev/staging environment gate in a non-interactive context, or declines the
158
+ * interactive fallback prompt.
159
+ */
160
+ exports.PLAN_LIMIT_NON_INTERACTIVE_HINT = 'Hint: pass -e production, or upgrade your plan for dev/staging environments.';
161
+ /**
162
+ * True when `error` is the app's 422 response for a free-plan tenant hitting
163
+ * the multi-environment gate on project auto-create:
164
+ * `{ error: { code: 'plan_limit_reached', limit: 'multi_env', plan, max } }`.
165
+ */
166
+ function isPlanLimitReachedError(error) {
167
+ const data = error?.response?.data;
168
+ return error?.response?.status === 422
169
+ && data?.error?.code === 'plan_limit_reached'
170
+ && data?.error?.limit === 'multi_env';
171
+ }
172
+ /**
173
+ * POST /api/v1/projects to create a new environment-project record. Returns
174
+ * the resolved slug (server-echoed slug, falling back to the requested one).
175
+ * Throws the raw axios error on failure — callers decide how to handle it.
176
+ */
177
+ async function createEnvironmentProject(config, projectName, environment) {
178
+ const requestedSlug = (0, slug_1.buildProjectSlug)(projectName, environment);
179
+ const createResponse = await axios_1.default.post(`${config.host}/api/v1/projects`, {
180
+ name: projectName,
181
+ slug: requestedSlug,
182
+ environment: environment,
183
+ }, {
184
+ headers: (0, api_1.getApiHeaders)(config, 'application/json'),
185
+ });
186
+ const slug = createResponse.data.slug || requestedSlug;
187
+ if (process.env.SOLIDACTIONS_DEPLOY_DEBUG === '1') {
188
+ process.stderr.write(`[deploy-debug] requestedSlug=${requestedSlug} responseSlug=${createResponse.data.slug ?? '(missing)'} responseName=${createResponse.data.name ?? '(missing)'} resolvedSlug=${slug}\n`);
189
+ }
190
+ return slug;
191
+ }
192
+ /**
193
+ * Handles a 422 plan_limit_reached/multi_env error from the env-project
194
+ * auto-create call (billing v0.5: free-plan tenants only get production).
195
+ *
196
+ * Interactive TTYs are offered a y/N fallback to production; declining exits
197
+ * 1 with an upgrade hint. Non-interactive callers (CI, agents) never see a
198
+ * prompt — they get the same hint and exit 1 immediately, so the command
199
+ * never hangs waiting for input that will never arrive.
200
+ *
201
+ * On confirmed fallback, resolves (and creates if necessary) the production
202
+ * project and returns its slug. Every other path calls process.exit(1) and
203
+ * never returns.
204
+ */
205
+ async function handlePlanLimitReached(config, projectName, error, productionExists, productionSlug) {
206
+ const serverMessage = error.response?.data?.message || 'Your plan does not support additional environments.';
207
+ console.error(chalk_1.default.red(serverMessage));
208
+ if (!process.stdin.isTTY) {
209
+ console.error(chalk_1.default.yellow(exports.PLAN_LIMIT_NON_INTERACTIVE_HINT));
210
+ process.exit(1);
211
+ }
212
+ const response = await (0, prompts_1.default)({
213
+ type: 'confirm',
214
+ name: 'proceed',
215
+ message: 'Your plan has a single production environment — deploy to production instead?',
216
+ initial: false,
217
+ });
218
+ if (!response.proceed) {
219
+ console.error(chalk_1.default.yellow(exports.PLAN_LIMIT_NON_INTERACTIVE_HINT));
220
+ process.exit(1);
221
+ }
222
+ if (productionExists === true && productionSlug !== null) {
223
+ return productionSlug;
224
+ }
225
+ try {
226
+ return await createEnvironmentProject(config, projectName, 'production');
227
+ }
228
+ catch (prodError) {
229
+ console.error(chalk_1.default.red('Failed to create project:'), prodError.response?.data?.message || prodError.message);
230
+ process.exit(1);
231
+ }
232
+ }
152
233
  async function deploy(projectName, sourcePath, options = {}) {
153
234
  const config = await (0, api_1.requireConfigWithWorkspace)();
154
235
  let workspaceMismatchPrinted = false;
@@ -218,8 +299,10 @@ async function deploy(projectName, sourcePath, options = {}) {
218
299
  }
219
300
  // Apply default: if production already exists and the user didn't pass -e,
220
301
  // use 'dev' — this preserves existing behavior for mature projects.
221
- const environment = explicitEnv ?? 'dev';
222
- const envLabel = environment !== 'production' ? ` (${environment})` : '';
302
+ // `let`, not `const`: a free-plan 422 (plan_limit_reached/multi_env) on the
303
+ // env-project auto-create below can fall the deploy back to production.
304
+ let environment = explicitEnv ?? 'dev';
305
+ let envLabel = environment !== 'production' ? ` (${environment})` : '';
223
306
  console.log(chalk_1.default.blue(`Deploying to project "${projectName}"${envLabel}...`));
224
307
  console.log(chalk_1.default.gray(`Source: ${sourceDir}`));
225
308
  // Validate project structure before deploying
@@ -285,28 +368,23 @@ async function deploy(projectName, sourcePath, options = {}) {
285
368
  process.exit(1);
286
369
  }
287
370
  console.log(chalk_1.default.yellow(`Project "${projectName}"${envLabel} not found. Creating...`));
288
- const requestedSlug = (0, slug_1.buildProjectSlug)(projectName, environment);
289
371
  try {
290
- const createResponse = await axios_1.default.post(`${config.host}/api/v1/projects`, {
291
- name: projectName,
292
- slug: requestedSlug,
293
- environment: environment,
294
- }, {
295
- headers: (0, api_1.getApiHeaders)(config, 'application/json'),
296
- });
297
- // Fallback chain: prefer the server-echoed slug; if absent, use the slug we
298
- // *requested* in the POST body (server stored that value). Falling back to
299
- // `name` strips the env suffix and causes the polling GET to 404 with
300
- // "Project 'X' not found in your active workspace 'Y'.".
301
- projectSlug = createResponse.data.slug || requestedSlug;
302
- if (process.env.SOLIDACTIONS_DEPLOY_DEBUG === '1') {
303
- process.stderr.write(`[deploy-debug] requestedSlug=${requestedSlug} responseSlug=${createResponse.data.slug ?? '(missing)'} responseName=${createResponse.data.name ?? '(missing)'} resolvedSlug=${projectSlug}\n`);
304
- }
372
+ projectSlug = await createEnvironmentProject(config, projectName, environment);
305
373
  console.log(chalk_1.default.green(`Project "${projectName}"${envLabel} created.`));
306
374
  }
307
375
  catch (createError) {
308
- console.error(chalk_1.default.red('Failed to create project:'), createError.response?.data?.message || createError.message);
309
- process.exit(1);
376
+ if (isPlanLimitReachedError(createError)) {
377
+ // Free-plan tenant hit the multi_env gate. handlePlanLimitReached()
378
+ // exits(1) on every path except a confirmed fallback to production.
379
+ projectSlug = await handlePlanLimitReached(config, projectName, createError, productionExists, productionSlug);
380
+ environment = 'production';
381
+ envLabel = '';
382
+ console.log(chalk_1.default.blue(`Deploying to project "${projectName}" (production) instead.`));
383
+ }
384
+ else {
385
+ console.error(chalk_1.default.red('Failed to create project:'), createError.response?.data?.message || createError.message);
386
+ process.exit(1);
387
+ }
310
388
  }
311
389
  }
312
390
  else {
@@ -264,7 +264,11 @@ async function runDev(opts) {
264
264
  platformVars = await apiClient.fetchVarsAndConnections(opts.env);
265
265
  }
266
266
  catch (e) {
267
- err(`failed to fetch platform vars: ${e?.message ?? e}`);
267
+ let msg = `failed to fetch platform vars: ${e?.message ?? e}`;
268
+ if (e?.response?.status === 404 && opts.env !== 'production') {
269
+ msg += `\nThe '${opts.env}' environment project doesn't exist — staging/dev environments require a paid plan. On the free plan, use --env production.`;
270
+ }
271
+ err(msg);
268
272
  }
269
273
  }
270
274
  // 3. Build ctx.vars from platform vars. A declared mapping is only readable
@@ -56,6 +56,7 @@ async function rolePushWithConfig(dir, options, config) {
56
56
  let body;
57
57
  try {
58
58
  ({ name, description, properties, body } = (0, skill_push_1.parseSkillFile)(skillMdContent));
59
+ (0, skill_push_1.assertNoReservedFrontmatterKeys)(properties);
59
60
  }
60
61
  catch (e) {
61
62
  process.stderr.write(chalk_1.default.red(`error: ${e.message}\n`));
@@ -99,14 +100,15 @@ async function rolePushWithConfig(dir, options, config) {
99
100
  }
100
101
  // Upsert: try create first; on name_collision switch to edit.
101
102
  // Roles carry NO references — do not send references key.
103
+ // Frontmatter extras are spread FIRST so the fixed protocol keys always win.
102
104
  let result;
103
105
  try {
104
106
  result = await (0, mcp_1.callCrewsTool)(config, 'roles', {
107
+ ...properties,
105
108
  action: 'create',
106
109
  name,
107
110
  description,
108
111
  body,
109
- properties,
110
112
  });
111
113
  }
112
114
  catch (e) {
@@ -114,15 +116,15 @@ async function rolePushWithConfig(dir, options, config) {
114
116
  process.exit(1);
115
117
  }
116
118
  // On name collision, switch to the edit path.
117
- // Roles edit uses 'name' (NOT 'identifier'), and properties → properties_patch.
119
+ // Roles edit uses 'name' (NOT 'identifier').
118
120
  if (!result.ok && result.data?.code === 'name_collision') {
119
121
  try {
120
122
  result = await (0, mcp_1.callCrewsTool)(config, 'roles', {
123
+ ...properties,
121
124
  action: 'edit',
122
125
  name,
123
126
  description,
124
127
  body,
125
- properties_patch: properties,
126
128
  });
127
129
  }
128
130
  catch (e) {
@@ -13,6 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.RESERVED_PARAM_KEYS = void 0;
17
+ exports.assertNoReservedFrontmatterKeys = assertNoReservedFrontmatterKeys;
16
18
  exports.parseSkillFile = parseSkillFile;
17
19
  exports.readReferences = readReferences;
18
20
  exports.readSkillDir = readSkillDir;
@@ -26,6 +28,22 @@ const chalk_1 = __importDefault(require("chalk"));
26
28
  const js_yaml_1 = __importDefault(require("js-yaml"));
27
29
  const api_1 = require("../utils/api");
28
30
  const mcp_1 = require("../utils/mcp");
31
+ /**
32
+ * Protocol param names reserved by the skills/roles MCP tool actions. Frontmatter
33
+ * keys that collide with these would silently corrupt the request once spread
34
+ * top-level into the call arguments.
35
+ */
36
+ exports.RESERVED_PARAM_KEYS = ['action', 'identifier', 'role', 'name', 'description', 'body', 'references', 'base_version_id'];
37
+ /**
38
+ * Throws if any frontmatter-derived property key collides with a reserved
39
+ * protocol param name.
40
+ */
41
+ function assertNoReservedFrontmatterKeys(properties) {
42
+ const offending = Object.keys(properties).filter((key) => exports.RESERVED_PARAM_KEYS.includes(key));
43
+ if (offending.length > 0) {
44
+ throw new Error(`SKILL.md frontmatter contains reserved key(s) that would collide with protocol params: ${offending.join(', ')}`);
45
+ }
46
+ }
29
47
  /**
30
48
  * Parse a SKILL.md file that begins with a YAML frontmatter block.
31
49
  *
@@ -177,6 +195,7 @@ function parseCommandFile(filename, content) {
177
195
  */
178
196
  async function pushParsedSkill(payload, options, config) {
179
197
  const { name, description, properties, body, references } = payload;
198
+ assertNoReservedFrontmatterKeys(properties);
180
199
  const isRole = !!options.role;
181
200
  const tool = isRole ? 'roles' : 'skills';
182
201
  // --dry-run: pre-flight a read to detect existence; make NO create/edit calls.
@@ -207,9 +226,10 @@ async function pushParsedSkill(payload, options, config) {
207
226
  // Read succeeded → skill exists → would update
208
227
  return { status: 'would-update', name, data: {} };
209
228
  }
229
+ // Spread frontmatter extras FIRST so the fixed protocol keys always win.
210
230
  const createArgs = isRole
211
- ? { action: 'create_skill', role: options.role, name, description, body, properties, references }
212
- : { action: 'create', name, description, body, properties, references };
231
+ ? { ...properties, action: 'create_skill', role: options.role, name, description, body, references }
232
+ : { ...properties, action: 'create', name, description, body, references };
213
233
  let result;
214
234
  try {
215
235
  result = await (0, mcp_1.callCrewsTool)(config, tool, createArgs);
@@ -217,11 +237,11 @@ async function pushParsedSkill(payload, options, config) {
217
237
  catch (e) {
218
238
  throw new Error(`${e.message}`);
219
239
  }
220
- // On name collision, switch to the edit path. properties → properties_patch.
240
+ // On name collision, switch to the edit path.
221
241
  if (!result.ok && result.data?.code === 'name_collision') {
222
242
  const editArgs = isRole
223
- ? { action: 'edit_skill', role: options.role, name, description, body, properties_patch: properties, references }
224
- : { action: 'edit', identifier: name, description, body, properties_patch: properties, references };
243
+ ? { ...properties, action: 'edit_skill', role: options.role, name, description, body, references }
244
+ : { ...properties, action: 'edit', identifier: name, description, body, references };
225
245
  try {
226
246
  result = await (0, mcp_1.callCrewsTool)(config, tool, editArgs);
227
247
  }
package/dist/index.js CHANGED
@@ -139,7 +139,7 @@ program
139
139
  .description('Run a workflow locally using an in-memory mock server (no deploy needed)')
140
140
  .argument('<file>', 'Workflow file to run (e.g., src/simple-steps.ts)')
141
141
  .option('-i, --input <json>', 'JSON input for the workflow', '{}')
142
- .option('-e, --env <env>', 'Pull platform variables for this environment (e.g. dev, staging, production)')
142
+ .option('-e, --env <env>', 'Pull platform variables for this environment (e.g. production, staging, dev)')
143
143
  .action((file, options) => {
144
144
  // Unified in-process invoke path. With --env: fetch declared vars, build
145
145
  // ctx.vars, invoke locally. Without --env: NO platform fetch, ctx.vars is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "1.25.0",
3
+ "version": "1.27.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {