@solidactions/cli 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.program = void 0;
40
41
  const chalk_1 = __importDefault(require("chalk"));
41
42
  const commander_1 = require("commander");
42
43
  const deploy_1 = require("./commands/deploy");
@@ -90,7 +91,7 @@ const crew_env_push_1 = require("./commands/crew-env-push");
90
91
  const config_1 = require("./utils/config");
91
92
  // eslint-disable-next-line @typescript-eslint/no-var-requires
92
93
  const pkg = require('../package.json');
93
- const program = new commander_1.Command();
94
+ exports.program = new commander_1.Command();
94
95
  if (process.env.SOLIDACTIONS_DEBUG === '1') {
95
96
  // eslint-disable-next-line @typescript-eslint/no-var-requires
96
97
  const { resolveConfig } = require('./utils/config');
@@ -113,7 +114,7 @@ if (process.env.SOLIDACTIONS_DEBUG === '1') {
113
114
  process.stderr.write('[SOLIDACTIONS_DEBUG] no config resolvable\n');
114
115
  }
115
116
  }
116
- program
117
+ exports.program
117
118
  .name('solidactions')
118
119
  .description('SolidActions CLI - Deploy and manage workflow automation')
119
120
  .version(pkg.version);
@@ -123,8 +124,8 @@ program
123
124
  // a parent option of the same name, so `login --workspace <x>` was being
124
125
  // swallowed by this global flag instead of reaching login()'s own option.
125
126
  // The short form `-w` is unaffected and remains the primary way to use this.
126
- program.option('-w, --workspace-override <id-or-slug-or-name>', 'Override active workspace for this command (short form: -w)');
127
- program.hook('preAction', (thisCommand, actionCommand) => {
127
+ exports.program.option('-w, --workspace-override <id-or-slug-or-name>', 'Override active workspace for this command (short form: -w)');
128
+ exports.program.hook('preAction', (thisCommand, actionCommand) => {
128
129
  const opts = thisCommand.opts();
129
130
  const wsOverride = opts.workspaceOverride;
130
131
  if (wsOverride) {
@@ -142,7 +143,7 @@ program.hook('preAction', (thisCommand, actionCommand) => {
142
143
  // =============================================================================
143
144
  // Top-level commands
144
145
  // =============================================================================
145
- program
146
+ exports.program
146
147
  .command('login')
147
148
  .description('Authenticate the CLI (prompts securely for your API key, or via --device for browser-based login)')
148
149
  .argument('[api-key]', 'Legacy positional API key (prefer the masked prompt, --stdin, or --device)')
@@ -168,7 +169,7 @@ Environment:
168
169
  const resolvedApiKey = await (0, login_1.resolveLoginApiKey)(apiKey, { stdin: options.stdin });
169
170
  await (0, login_1.login)(resolvedApiKey, options);
170
171
  });
171
- program
172
+ exports.program
172
173
  .command('init')
173
174
  .description('Scaffold a new SolidActions project (files + AI skills)')
174
175
  .argument('[directory]', 'Directory to create (omit to scaffold in the current empty directory)')
@@ -178,7 +179,7 @@ program
178
179
  .action(async (directory, options) => {
179
180
  await (0, init_1.init)(directory, options);
180
181
  });
181
- program
182
+ exports.program
182
183
  .command('logout')
183
184
  .description('Remove saved credentials')
184
185
  .option('--local', 'Remove only the nearest local ./.solidactions/config.json')
@@ -186,13 +187,13 @@ program
186
187
  .action((options) => {
187
188
  (0, login_1.logout)(options);
188
189
  });
189
- program
190
+ exports.program
190
191
  .command('whoami')
191
192
  .description('Show current configuration')
192
193
  .action(() => {
193
194
  (0, login_1.whoami)();
194
195
  });
195
- program
196
+ exports.program
196
197
  .command('dev')
197
198
  .description('Run a workflow locally using an in-memory mock server (no deploy needed)')
198
199
  .argument('<file>', 'Workflow file to run (e.g., src/simple-steps.ts)')
@@ -207,7 +208,7 @@ program
207
208
  // =============================================================================
208
209
  // project <subcommand>
209
210
  // =============================================================================
210
- const project = program.command('project').description('Manage projects');
211
+ const project = exports.program.command('project').description('Manage projects');
211
212
  project
212
213
  .command('view')
213
214
  .description('View project status and the client-reported deployed revision')
@@ -275,7 +276,7 @@ project
275
276
  // =============================================================================
276
277
  // run <subcommand>
277
278
  // =============================================================================
278
- const runCmd = program.command('run').description('Manage workflow runs');
279
+ const runCmd = exports.program.command('run').description('Manage workflow runs');
279
280
  runCmd
280
281
  .command('start')
281
282
  .description('Trigger a workflow run')
@@ -319,7 +320,7 @@ runCmd
319
320
  // =============================================================================
320
321
  // env <subcommand>
321
322
  // =============================================================================
322
- const env = program.command('env').description('Manage variables');
323
+ const env = exports.program.command('env').description('Manage variables');
323
324
  env
324
325
  .command('set')
325
326
  .description('Set a variable (create or update, global or project)')
@@ -404,7 +405,7 @@ env
404
405
  // =============================================================================
405
406
  // crew env <subcommand>
406
407
  // =============================================================================
407
- const crew = program.command('crew').description('Manage crews');
408
+ const crew = exports.program.command('crew').description('Manage crews');
408
409
  const crewEnv = crew.command('env').description('Manage crew variables');
409
410
  crewEnv
410
411
  .command('set')
@@ -448,7 +449,7 @@ crewEnv
448
449
  // =============================================================================
449
450
  // schedule <subcommand>
450
451
  // =============================================================================
451
- const schedule = program.command('schedule').description('Manage cron schedules');
452
+ const schedule = exports.program.command('schedule').description('Manage cron schedules');
452
453
  schedule
453
454
  .command('set')
454
455
  .description('Set a cron schedule for a workflow')
@@ -480,7 +481,7 @@ schedule
480
481
  // =============================================================================
481
482
  // webhook <subcommand>
482
483
  // =============================================================================
483
- const webhook = program.command('webhook').description('Manage webhooks');
484
+ const webhook = exports.program.command('webhook').description('Manage webhooks');
484
485
  webhook
485
486
  .command('list')
486
487
  .description('List webhook URLs for a project')
@@ -504,7 +505,7 @@ webhook
504
505
  // =============================================================================
505
506
  // workspace <subcommand>
506
507
  // =============================================================================
507
- const workspace = program.command('workspace').description('Manage workspaces');
508
+ const workspace = exports.program.command('workspace').description('Manage workspaces');
508
509
  workspace
509
510
  .command('list')
510
511
  .description('List your workspaces across all organizations')
@@ -529,7 +530,7 @@ Where the pin is saved (--local / --global):
529
530
  // =============================================================================
530
531
  // oauth-action <subcommand>
531
532
  // =============================================================================
532
- const oauthActionCmd = program.command('oauth-action').description('Discover OAuth-backed API operations callable via the SA proxy');
533
+ const oauthActionCmd = exports.program.command('oauth-action').description('Discover OAuth-backed API operations callable via the SA proxy');
533
534
  oauthActionCmd
534
535
  .command('search <platform> [query]')
535
536
  .description('Search available actions for a connected platform')
@@ -566,7 +567,7 @@ oauthActionCmd
566
567
  // =============================================================================
567
568
  // connection <subcommand>
568
569
  // =============================================================================
569
- const connection = program.command('connection').description('Manage OAuth connections');
570
+ const connection = exports.program.command('connection').description('Manage OAuth connections');
570
571
  connection
571
572
  .command('list')
572
573
  .description('List OAuth connections in the active workspace')
@@ -576,7 +577,7 @@ connection
576
577
  // =============================================================================
577
578
  // ai <subcommand>
578
579
  // =============================================================================
579
- const ai = program.command('ai').description('AI helper tools');
580
+ const ai = exports.program.command('ai').description('AI helper tools');
580
581
  ai
581
582
  .command('init')
582
583
  .description('Install SolidActions AI skills and SDK reference for AI-assisted development')
@@ -593,7 +594,7 @@ ai
593
594
  // =============================================================================
594
595
  // skill <subcommand> (SOP surface — flat top-level noun per cli#34)
595
596
  // =============================================================================
596
- const skill = program.command('skill').description('Manage agent skills (crews SOP surface)');
597
+ const skill = exports.program.command('skill').description('Manage agent skills (crews SOP surface)');
597
598
  skill
598
599
  .command('push')
599
600
  .description('Push a local skill folder into the library (create, or update if it already exists)')
@@ -685,7 +686,7 @@ skill
685
686
  // =============================================================================
686
687
  // role <subcommand> (SOP surface — flat peer of skill, per cli#34)
687
688
  // =============================================================================
688
- const role = program.command('role').description('Manage roles (crews SOP surface)');
689
+ const role = exports.program.command('role').description('Manage roles (crews SOP surface)');
689
690
  role
690
691
  .command('push <dir>')
691
692
  .description('Push a role definition (create or update)')
@@ -697,7 +698,7 @@ role
697
698
  // =============================================================================
698
699
  // doc <subcommand> (SA-Docs surface)
699
700
  // =============================================================================
700
- const doc = program.command('doc').description('Manage docs in SA-Docs');
701
+ const doc = exports.program.command('doc').description('Manage docs in SA-Docs');
701
702
  doc
702
703
  .command('push')
703
704
  .description('Recursively upload a local markdown tree into SA-Docs')
@@ -731,7 +732,12 @@ doc
731
732
  .action(async (files, options) => {
732
733
  await (0, doc_upload_1.docUpload)(files, { folder: options.folder, title: options.title, replace: options.replace });
733
734
  });
734
- program.parseAsync().catch((err) => {
735
- console.error(chalk_1.default.red(err.message ?? String(err)));
736
- process.exit(1);
737
- });
735
+ // Only parse argv when this file IS the process entry point (the `solidactions`
736
+ // bin). The #1004 command-manifest generator requires this module to walk the
737
+ // assembled command tree; that must not consume the caller's argv or exit.
738
+ if (require.main === module) {
739
+ exports.program.parseAsync().catch((err) => {
740
+ console.error(chalk_1.default.red(err.message ?? String(err)));
741
+ process.exit(1);
742
+ });
743
+ }
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COMMAND_MANIFEST_FILE = exports.COMMAND_MANIFEST_SCHEMA_VERSION = void 0;
4
+ exports.buildCommandManifest = buildCommandManifest;
5
+ /**
6
+ * Machine-readable description of the CLI's command surface, generated from the
7
+ * commander definitions at build time (#1004 PR 0). Consumers — chiefly the
8
+ * content repo's prose validator — pin a released manifest and fail CI when
9
+ * documentation names a command or flag that does not exist here.
10
+ *
11
+ * Follows the `schema_version` precedent set by src/utils/skill-cache.ts.
12
+ */
13
+ exports.COMMAND_MANIFEST_SCHEMA_VERSION = 1;
14
+ exports.COMMAND_MANIFEST_FILE = 'command-manifest.json';
15
+ /**
16
+ * True when `value` survives JSON.stringify without becoming undefined —
17
+ * functions, symbols and undefined do not, and must never reach the manifest.
18
+ */
19
+ function isJsonSafe(value) {
20
+ try {
21
+ return JSON.stringify(value) !== undefined;
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ }
27
+ function applyDefault(target, defaultValue, defaultValueDescription) {
28
+ if (defaultValue === undefined) {
29
+ if (defaultValueDescription !== undefined) {
30
+ target.default_description = defaultValueDescription;
31
+ }
32
+ return;
33
+ }
34
+ if (isJsonSafe(defaultValue)) {
35
+ target.default = defaultValue;
36
+ if (defaultValueDescription !== undefined) {
37
+ target.default_description = defaultValueDescription;
38
+ }
39
+ return;
40
+ }
41
+ target.default_description = defaultValueDescription ?? String(defaultValue);
42
+ }
43
+ function describeOption(option) {
44
+ const entry = {
45
+ flags: option.flags,
46
+ long: option.long ?? null,
47
+ short: option.short ?? null,
48
+ description: option.description,
49
+ required: option.mandatory === true,
50
+ value_required: option.required === true,
51
+ value_optional: option.optional === true,
52
+ variadic: option.variadic === true,
53
+ negated: option.negate === true,
54
+ hidden: option.hidden === true,
55
+ };
56
+ // commander's Command.addOption() (lib/command.js ~:548) defaults a negated
57
+ // option's positive attribute to `true` when no explicit defaultValue was
58
+ // given (and no positive counterpart option is registered) — e.g.
59
+ // `--no-cache` implicitly defaults `cache` to `true`. That implicit default
60
+ // lives in the Command's option-processing, not on Option.defaultValue, so
61
+ // it's otherwise invisible here.
62
+ const defaultValue = option.negate === true && option.defaultValue === undefined ? true : option.defaultValue;
63
+ applyDefault(entry, defaultValue, option.defaultValueDescription);
64
+ if (option.argChoices) {
65
+ entry.choices = [...option.argChoices];
66
+ }
67
+ return entry;
68
+ }
69
+ function describeArgument(argument) {
70
+ const entry = {
71
+ name: argument.name(),
72
+ required: argument.required === true,
73
+ variadic: argument.variadic === true,
74
+ description: argument.description,
75
+ };
76
+ applyDefault(entry, argument.defaultValue, argument.defaultValueDescription);
77
+ if (argument.argChoices) {
78
+ entry.choices = [...argument.argChoices];
79
+ }
80
+ return entry;
81
+ }
82
+ /**
83
+ * commander exposes no public getter for a command hidden via
84
+ * `.command(name, { hidden: true })` — the flag lives on the private `_hidden`
85
+ * field, which its own help renderer reads. Read it the same way.
86
+ */
87
+ function isHiddenCommand(command) {
88
+ return command._hidden === true;
89
+ }
90
+ /**
91
+ * commander auto-adds a `-h, --help` option to every command, but it is
92
+ * synthesized at help-render time (see lib/help.js `visibleOptions`) rather
93
+ * than being a real `Option` living in `command.options` — so the plain
94
+ * `command.options.map(describeOption)` walk below silently drops it from
95
+ * the manifest. Downstream doc validators need it (real prose documents
96
+ * `--help`), so read the same private fields commander's own help renderer
97
+ * reads (`_hasHelpOption`, `_helpFlags`, `_helpShortFlag`, `_helpLongFlag`,
98
+ * `_helpDescription` — there is no public getter for any of them) and
99
+ * synthesize an equivalent manifest entry by hand.
100
+ *
101
+ * commander also suppresses a help flag form when a real option on the
102
+ * command already owns that exact flag (`Help.visibleOptions` in
103
+ * lib/help.js, via `Command._findOption`/`Option.is`) — e.g.
104
+ * `.option('-h, --human')` steals `-h` from the synthesized help option, so
105
+ * only `--help` is shown. Mirror that per-form check here.
106
+ */
107
+ function describeHelpOption(command) {
108
+ const cmd = command;
109
+ if (cmd._hasHelpOption !== true) {
110
+ return null;
111
+ }
112
+ const ownsFlag = (flag) => flag !== undefined && command.options.some((option) => option.short === flag || option.long === flag);
113
+ const showShort = cmd._helpShortFlag !== undefined && !ownsFlag(cmd._helpShortFlag);
114
+ const showLong = !ownsFlag(cmd._helpLongFlag);
115
+ if (!showShort && !showLong) {
116
+ return null;
117
+ }
118
+ const short = showShort ? (cmd._helpShortFlag ?? null) : null;
119
+ const long = showLong ? (cmd._helpLongFlag ?? null) : null;
120
+ const flags = showShort && showLong
121
+ ? (cmd._helpFlags ?? [short, long].filter((flag) => flag !== null).join(', '))
122
+ : (long ?? short);
123
+ return {
124
+ flags,
125
+ long,
126
+ short,
127
+ description: cmd._helpDescription ?? '',
128
+ required: false,
129
+ value_required: false,
130
+ value_optional: false,
131
+ variadic: false,
132
+ negated: false,
133
+ hidden: false,
134
+ };
135
+ }
136
+ /**
137
+ * commander adds an implicit `help [command]` (sub)command to any command
138
+ * that has children, no action handler of its own, and no explicit `help`
139
+ * command already registered (`_hasImplicitHelpCommand()` in command.js) —
140
+ * but, like the `-h, --help` option above, it is synthesized at help-render
141
+ * time (see `Help.visibleCommands` in lib/help.js) rather than living in
142
+ * `command.commands`, so the recursive walk in `describeCommand` never sees
143
+ * it. It is real and typable at every level it applies — both
144
+ * `solidactions help project` and `solidactions project help view` work —
145
+ * so downstream doc validators need an entry for it too. Reconstruct it the
146
+ * same way commander's own help renderer does (there is no public API for
147
+ * any of `_hasImplicitHelpCommand`, `_helpCommandnameAndArgs`,
148
+ * `_helpCommandDescription`): build a throwaway `Command` from those private
149
+ * fields, then run it through the normal `describeCommand` walk so its shape
150
+ * (path, aliases, options via `describeHelpOption`, etc.) matches every
151
+ * other command for free.
152
+ */
153
+ function describeImplicitHelpCommand(command, path) {
154
+ const cmd = command;
155
+ if (typeof cmd._hasImplicitHelpCommand !== 'function' || !cmd._hasImplicitHelpCommand()) {
156
+ return [];
157
+ }
158
+ const nameAndArgs = cmd._helpCommandnameAndArgs ?? 'help [command]';
159
+ const match = nameAndArgs.match(/([^ ]+) *(.*)/);
160
+ const helpName = match?.[1] ?? 'help';
161
+ const helpArgs = match?.[2] ?? '';
162
+ // Same construction as commander's Help.visibleCommands: a fresh command
163
+ // with its own help option turned off (commander never lists "-h, --help"
164
+ // twice for the same invocation) and, when the nameAndArgs spec carries
165
+ // one (e.g. "[command]"), the optional target-command argument.
166
+ const helpCommand = command.createCommand(helpName).helpOption(false);
167
+ helpCommand.description(cmd._helpCommandDescription ?? '');
168
+ if (helpArgs) {
169
+ helpCommand.arguments(helpArgs);
170
+ }
171
+ return describeCommand(helpCommand, path);
172
+ }
173
+ function describeCommand(command, parentPath) {
174
+ const path = [...parentPath, command.name()];
175
+ const options = command.options.map(describeOption);
176
+ const helpOption = describeHelpOption(command);
177
+ if (helpOption) {
178
+ options.push(helpOption);
179
+ }
180
+ const entry = {
181
+ path,
182
+ name: command.name(),
183
+ aliases: [...command.aliases()],
184
+ description: command.description(),
185
+ hidden: isHiddenCommand(command),
186
+ arguments: command.registeredArguments.map(describeArgument),
187
+ options,
188
+ };
189
+ return [
190
+ entry,
191
+ ...command.commands.flatMap((child) => describeCommand(child, path)),
192
+ ...describeImplicitHelpCommand(command, path),
193
+ ];
194
+ }
195
+ /**
196
+ * Walk an assembled commander program into its manifest. Declaration order is
197
+ * preserved throughout: it is already deterministic and mirrors help ordering.
198
+ */
199
+ function buildCommandManifest(program, cliVersion) {
200
+ // The root program's `-h, --help` is the same commander-synthesized
201
+ // option as describeHelpOption handles per-command (see that function's
202
+ // comment) — commander keeps it outside `program.options` too, so the
203
+ // plain `program.options.map(describeOption)` walk below would otherwise
204
+ // silently drop it from global_options even though `solidactions --help`
205
+ // works (README.md documents it).
206
+ const globalOptions = program.options.map(describeOption);
207
+ const rootHelpOption = describeHelpOption(program);
208
+ if (rootHelpOption) {
209
+ globalOptions.push(rootHelpOption);
210
+ }
211
+ return {
212
+ schema_version: exports.COMMAND_MANIFEST_SCHEMA_VERSION,
213
+ cli_name: program.name(),
214
+ cli_version: cliVersion,
215
+ global_options: globalOptions,
216
+ commands: [
217
+ ...program.commands.flatMap((command) => describeCommand(command, [])),
218
+ ...describeImplicitHelpCommand(program, []),
219
+ ],
220
+ };
221
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "deploy"
33
33
  ],
34
34
  "scripts": {
35
- "build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs && cp src/utils/archiver-loader.cjs dist/utils/archiver-loader.cjs",
35
+ "build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs && cp src/utils/archiver-loader.cjs dist/utils/archiver-loader.cjs && node scripts/generate-command-manifest.mjs",
36
36
  "check:release": "npm run build && npm run test && npm run smoke:init",
37
37
  "prepublishOnly": "npm run build",
38
38
  "smoke:init": "node scripts/smoke-init.mjs",