@dosu/cli 0.23.1 → 0.25.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 (2) hide show
  1. package/bin/dosu.js +96 -11
  2. package/package.json +1 -1
package/bin/dosu.js CHANGED
@@ -4577,7 +4577,7 @@ var init_dist4 = __esm(() => {
4577
4577
  function getVersionString() {
4578
4578
  return `v${VERSION}`;
4579
4579
  }
4580
- var VERSION = "0.23.1", INSTALL_CHANNEL = "npm";
4580
+ var VERSION = "0.25.0", INSTALL_CHANNEL = "npm";
4581
4581
 
4582
4582
  // src/debug/logger.ts
4583
4583
  import {
@@ -15253,6 +15253,8 @@ ${import_picocolors17.default.dim(`Current: ${cfg.org_id}`)}`);
15253
15253
  }
15254
15254
 
15255
15255
  // src/commands/review.ts
15256
+ init_dist8();
15257
+ init_dist();
15256
15258
  init_commander();
15257
15259
  init_trpc();
15258
15260
  var import_picocolors18 = __toESM(require_picocolors(), 1);
@@ -15273,6 +15275,35 @@ function humanizeSource(origin, version) {
15273
15275
  return origin;
15274
15276
  }
15275
15277
  }
15278
+ function colorizeDiff(diff) {
15279
+ return diff.split(`
15280
+ `).map((line) => {
15281
+ if (line.startsWith("+"))
15282
+ return import_picocolors18.default.green(line);
15283
+ if (line.startsWith("-"))
15284
+ return import_picocolors18.default.red(line);
15285
+ if (line.startsWith("@@"))
15286
+ return import_picocolors18.default.cyan(line);
15287
+ return import_picocolors18.default.dim(line);
15288
+ }).join(`
15289
+ `);
15290
+ }
15291
+ function printChangePreview(change) {
15292
+ printInfo([
15293
+ ["Title", change.title],
15294
+ ["Source", change.source],
15295
+ [
15296
+ "Version",
15297
+ change.isNewDoc ? `${change.version} (new)` : `${change.publishedVersion ?? "?"} → ${change.version}`
15298
+ ]
15299
+ ]);
15300
+ if (!change.hasChanges) {
15301
+ console.log(import_picocolors18.default.dim("No content changes."));
15302
+ return;
15303
+ }
15304
+ console.log();
15305
+ console.log(colorizeDiff(change.diff));
15306
+ }
15276
15307
  async function getKnowledgeStoreId2(client, spaceId) {
15277
15308
  const store = await client.knowledgeStore.getBySpaceId.query({ space_id: spaceId });
15278
15309
  if (!store) {
@@ -15309,6 +15340,29 @@ function reviewCommand() {
15309
15340
  formatDate(i2.createdAt)
15310
15341
  ]), { rawData: items });
15311
15342
  });
15343
+ cmd.command("diff").description("Show the server-rendered diff for a pending document version").argument("<page-version-id>", "Page version ID (from `dosu review list`)").option("--json", "Output as JSON").action(async (id, opts) => {
15344
+ const cfg = requireConfig9();
15345
+ const client = createTypedClient(cfg);
15346
+ let change;
15347
+ try {
15348
+ change = await client.review.getChange.query({ id });
15349
+ } catch (err) {
15350
+ if (isTRPCClientError(err) && err.data?.code === "NOT_FOUND") {
15351
+ console.error(import_picocolors18.default.red(`No review item found for '${id}'. Run 'dosu review list' to see pending items.`));
15352
+ process.exit(1);
15353
+ }
15354
+ throw err;
15355
+ }
15356
+ if (opts.json) {
15357
+ printResult(change, opts);
15358
+ return;
15359
+ }
15360
+ const versions = change.publishedVersion != null ? `v${change.publishedVersion} → v${change.version}` : `v${change.version}`;
15361
+ console.log(import_picocolors18.default.bold(change.title));
15362
+ console.log(import_picocolors18.default.dim(`${change.source} · ${versions}`));
15363
+ console.log("");
15364
+ console.log(change.diff);
15365
+ });
15312
15366
  cmd.command("context").description("Get review context for a thread").argument("<thread-id>", "Thread ID").option("--json", "Output as JSON").action(async (threadId, opts) => {
15313
15367
  const cfg = requireConfig9();
15314
15368
  const client = createTypedClient(cfg);
@@ -15330,19 +15384,37 @@ function reviewCommand() {
15330
15384
  ["Sync PR", ctx.syncPrUrl ?? undefined]
15331
15385
  ]);
15332
15386
  });
15333
- const actions = [
15334
- { name: "approve", action: "accept", description: "Approve a document version" },
15335
- { name: "reject", action: "decline", description: "Reject a document version" },
15336
- {
15337
- name: "revert",
15338
- action: "revert_to_pending",
15339
- description: "Revert to pending review"
15340
- }
15387
+ const gated = [
15388
+ { name: "approve", action: "accept", verb: "Approve" },
15389
+ { name: "reject", action: "decline", verb: "Reject" }
15341
15390
  ];
15342
- for (const { name, action, description } of actions) {
15343
- cmd.command(name).description(description).argument("<id>", "Review item ID (from `dosu review list`)").option("--json", "Output as JSON").action(async (id, opts) => {
15391
+ for (const { name, action, verb } of gated) {
15392
+ cmd.command(name).description(`${verb} a document version (shows the diff, requires --confirm)`).argument("<id>", "Review item ID (from `dosu review list`)").option("--confirm", "Apply without the interactive prompt").option("--json", "Output as JSON").action(async (id, opts) => {
15344
15393
  const cfg = requireConfig9();
15345
15394
  const client = createTypedClient(cfg);
15395
+ const change = await client.review.getChange.query({ id });
15396
+ if (!opts.json)
15397
+ printChangePreview(change);
15398
+ let proceed = opts.confirm === true;
15399
+ if (!proceed && !opts.json && process.stdin?.isTTY) {
15400
+ const answer = await confirm({
15401
+ message: `${verb} this change?`,
15402
+ initialValue: false
15403
+ });
15404
+ if (isCancel(answer)) {
15405
+ console.log(import_picocolors18.default.dim("Cancelled."));
15406
+ return;
15407
+ }
15408
+ proceed = answer === true;
15409
+ }
15410
+ if (!proceed) {
15411
+ if (opts.json) {
15412
+ printResult({ ...change, applied: false, confirmRequired: true }, opts);
15413
+ } else {
15414
+ console.log(import_picocolors18.default.dim("Aborted. Re-run with --confirm to apply."));
15415
+ }
15416
+ return;
15417
+ }
15346
15418
  await client.page.updatePublicationStatus.mutate({
15347
15419
  page_version_id: id,
15348
15420
  action
@@ -15354,6 +15426,19 @@ function reviewCommand() {
15354
15426
  console.log(import_picocolors18.default.green(`Review ${name}: ${id.slice(0, 8)}`));
15355
15427
  });
15356
15428
  }
15429
+ cmd.command("revert").description("Revert to pending review").argument("<id>", "Review item ID (from `dosu review list`)").option("--json", "Output as JSON").action(async (id, opts) => {
15430
+ const cfg = requireConfig9();
15431
+ const client = createTypedClient(cfg);
15432
+ await client.page.updatePublicationStatus.mutate({
15433
+ page_version_id: id,
15434
+ action: "revert_to_pending"
15435
+ });
15436
+ if (opts.json) {
15437
+ printResult({ success: true, id, action: "revert_to_pending" }, opts);
15438
+ return;
15439
+ }
15440
+ console.log(import_picocolors18.default.green(`Review revert: ${id.slice(0, 8)}`));
15441
+ });
15357
15442
  return cmd;
15358
15443
  }
15359
15444
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosu/cli",
3
- "version": "0.23.1",
3
+ "version": "0.25.0",
4
4
  "type": "module",
5
5
  "description": "Dosu CLI - Manage MCP servers for AI tools",
6
6
  "license": "MIT",