@bpmnkit/cli 0.0.16 → 0.0.18

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/output.js CHANGED
@@ -259,4 +259,29 @@ export function printRawResponse(raw, noColor) {
259
259
  process.stdout.write(`${raw.body}\n`);
260
260
  }
261
261
  }
262
+ /** Print HTTP error details (request + response) to stderr. */
263
+ export function printHttpErrorDetails(raw, noColor) {
264
+ const colors = shouldUseColor(noColor);
265
+ process.stderr.write(`\n${dim("→", colors)} ${bold(`${raw.method} ${raw.url}`, colors)}\n`);
266
+ for (const [k, v] of Object.entries(raw.requestHeaders)) {
267
+ process.stderr.write(` ${dim(k, colors)}: ${v}\n`);
268
+ }
269
+ if (raw.requestBody) {
270
+ process.stderr.write(`\n${dim(raw.requestBody, colors)}\n`);
271
+ }
272
+ process.stderr.write(`\n${red(`HTTP ${raw.status}`, colors)}\n`);
273
+ for (const [k, v] of Object.entries(raw.headers)) {
274
+ process.stderr.write(` ${dim(k, colors)}: ${v}\n`);
275
+ }
276
+ if (raw.body) {
277
+ process.stderr.write("\n");
278
+ try {
279
+ const parsed = JSON.parse(raw.body);
280
+ process.stderr.write(`${JSON.stringify(parsed, null, 2)}\n`);
281
+ }
282
+ catch {
283
+ process.stderr.write(`${raw.body}\n`);
284
+ }
285
+ }
286
+ }
262
287
  //# sourceMappingURL=output.js.map
package/dist/run.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { appendAuditEntry, createAdminClientFromProfile, createClientFromProfile, getActiveName, getProfile, } from "@bpmnkit/profiles";
2
2
  import { parseArgs } from "./args.js";
3
- import { commandGroups } from "./commands/index.js";
3
+ import { apiGroups, commandGroups, pinnedGroups, pluginGroup, profileGroup, } from "./commands/index.js";
4
4
  import { getRuntimeCompletions } from "./completion.js";
5
5
  import { printCommandHelp, printGlobalHelp, printGroupHelp, printVersion } from "./help.js";
6
- import { createNullWriter, createOutputWriter, printRawResponse } from "./output.js";
6
+ import { createNullWriter, createOutputWriter, printHttpErrorDetails, printRawResponse, } from "./output.js";
7
7
  import { loadPlugins } from "./plugin-loader.js";
8
8
  import { runProfileManager } from "./profile-tui.js";
9
9
  import { runSettingsManager } from "./settings-tui.js";
@@ -51,7 +51,7 @@ export async function run(argv) {
51
51
  // Load plugin-contributed groups and merge with built-in groups.
52
52
  // Failures are isolated inside loadPlugins — a broken plugin cannot crash the CLI.
53
53
  const pluginGroups = await loadPlugins();
54
- const allGroups = [...commandGroups, ...pluginGroups];
54
+ const allGroups = [...commandGroups, profileGroup, pluginGroup, ...pluginGroups];
55
55
  // ── Completion protocol ───────────────────────────────────────────────────
56
56
  // casen --complete <cursorWordIndex> -- <words...>
57
57
  const completeIdx = argv.indexOf("--complete");
@@ -82,7 +82,13 @@ export async function run(argv) {
82
82
  }
83
83
  else {
84
84
  const { name: pName, info: pInfo } = buildProfileInfo(profileName);
85
- await runMainTui(allGroups, () => Promise.resolve(createClientFromProfile(profileName)), () => Promise.resolve(createAdminClientFromProfile(profileName)), { profile: pName, profileInfo: pInfo });
85
+ await runMainTui(
86
+ // Order: pinned → plugins (tagged) → api groups
87
+ [
88
+ ...pinnedGroups,
89
+ ...pluginGroups.map((g) => ({ ...g, _plugin: true })),
90
+ ...apiGroups,
91
+ ], () => Promise.resolve(createClientFromProfile(profileName)), () => Promise.resolve(createAdminClientFromProfile(profileName)), { profile: pName, profileInfo: pInfo });
86
92
  }
87
93
  return;
88
94
  }
@@ -96,6 +102,21 @@ export async function run(argv) {
96
102
  process.exitCode = 1;
97
103
  return;
98
104
  }
105
+ // ── worker: treat positional[1] as the job type argument ─────────────────
106
+ if (group.name === "worker" && positional.length >= 2 && !wantHelp) {
107
+ const output = createOutputWriter(outputFormat, noColor);
108
+ const ctx = {
109
+ positional: positional.slice(1),
110
+ flags,
111
+ output,
112
+ getClient,
113
+ getAdminClient,
114
+ };
115
+ const cmd = group.commands[0];
116
+ if (cmd)
117
+ await cmd.run(ctx);
118
+ return;
119
+ }
99
120
  // ── ask: join remaining positionals as the query ─────────────────────────
100
121
  if (group.name === "ask" && positional.length >= 2 && !wantHelp) {
101
122
  const queryWords = positional.slice(1);
@@ -219,6 +240,9 @@ export async function run(argv) {
219
240
  if (isRaw && capture) {
220
241
  printRawResponse(capture, noColor);
221
242
  }
243
+ else if (capture) {
244
+ printHttpErrorDetails(capture, noColor);
245
+ }
222
246
  const msg = err instanceof Error ? err.message : String(err);
223
247
  appendAuditEntry(effectiveProfile, {
224
248
  group: group.name,