@dosu/cli 0.28.0 → 0.28.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 (2) hide show
  1. package/bin/dosu.js +35 -18
  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.28.0", INSTALL_CHANNEL = "npm";
4580
+ var VERSION = "0.28.1", INSTALL_CHANNEL = "npm";
4581
4581
 
4582
4582
  // src/debug/logger.ts
4583
4583
  import {
@@ -15664,17 +15664,32 @@ function requireConfig10() {
15664
15664
  function isNotFound(err) {
15665
15665
  return isTRPCClientError(err) && err.data?.code === "NOT_FOUND";
15666
15666
  }
15667
- async function resolveChange(client, id) {
15667
+ function isInvalidId(err) {
15668
+ return isTRPCClientError(err) && err.data?.code === "UNPROCESSABLE_CONTENT";
15669
+ }
15670
+ var DRAFT_MESSAGE_ID_PREFIX = "draft_message:";
15671
+ function isDraftId(id) {
15672
+ return id.startsWith(DRAFT_MESSAGE_ID_PREFIX);
15673
+ }
15674
+ function bareMessageId(id) {
15675
+ return id.slice(DRAFT_MESSAGE_ID_PREFIX.length);
15676
+ }
15677
+ function truncateId(id) {
15678
+ return (isDraftId(id) ? bareMessageId(id) : id).slice(0, 8);
15679
+ }
15680
+ async function requireChange(client, id) {
15668
15681
  try {
15669
15682
  return await client.review.getChange.query({ id });
15670
15683
  } catch (err) {
15671
- if (isNotFound(err))
15672
- return null;
15684
+ if (isNotFound(err) || isInvalidId(err)) {
15685
+ console.error(import_picocolors20.default.red(`No review item found for '${id}'. Run 'dosu review list' to see pending items.`));
15686
+ process.exit(1);
15687
+ }
15673
15688
  throw err;
15674
15689
  }
15675
15690
  }
15676
15691
  async function requireDraft(client, id) {
15677
- const draft = await client.messages.getMessage.query(id);
15692
+ const draft = await client.messages.getMessage.query(bareMessageId(id));
15678
15693
  if (!draft) {
15679
15694
  console.error(import_picocolors20.default.red(`No review item found for '${id}'. Run 'dosu review list' to see pending items.`));
15680
15695
  process.exit(1);
@@ -15781,8 +15796,7 @@ function reviewCommand() {
15781
15796
  cmd.command("diff").description("Show a pending review item (doc-change diff or draft reply body)").argument("<id>", "Review item ID (from `dosu review list`)").option("--json", "Output as JSON").action(async (id, opts) => {
15782
15797
  const cfg = requireConfig10();
15783
15798
  const client = createTypedClient(cfg);
15784
- const change = await resolveChange(client, id);
15785
- if (!change) {
15799
+ if (isDraftId(id)) {
15786
15800
  const draft = await requireDraft(client, id);
15787
15801
  if (opts.json) {
15788
15802
  printResult({ id, kind: "draft_message", title: draft.title, body: draft.body }, opts);
@@ -15794,6 +15808,7 @@ function reviewCommand() {
15794
15808
  console.log(draft.body ?? "");
15795
15809
  return;
15796
15810
  }
15811
+ const change = await requireChange(client, id);
15797
15812
  if (opts.json) {
15798
15813
  printResult(change, opts);
15799
15814
  return;
@@ -15824,14 +15839,16 @@ function reviewCommand() {
15824
15839
  console.error(import_picocolors20.default.red("Nothing to edit. Pass --title and/or --body/--body-file."));
15825
15840
  process.exit(1);
15826
15841
  }
15827
- const change = await resolveChange(client, id);
15828
- if (!change) {
15842
+ if (isDraftId(id)) {
15829
15843
  if (opts.title !== undefined) {
15830
15844
  console.error(import_picocolors20.default.red("Draft replies support --body only (no --title)."));
15831
15845
  process.exit(1);
15832
15846
  }
15833
15847
  await requireDraft(client, id);
15834
- await client.messages.saveDraft.mutate({ messageId: id, body });
15848
+ await client.messages.saveDraft.mutate({
15849
+ messageId: bareMessageId(id),
15850
+ body
15851
+ });
15835
15852
  } else {
15836
15853
  try {
15837
15854
  await client.page.updateReview.mutate({
@@ -15851,7 +15868,7 @@ function reviewCommand() {
15851
15868
  printResult({ success: true, id }, opts);
15852
15869
  return;
15853
15870
  }
15854
- console.log(import_picocolors20.default.green(`Review edited: ${id.slice(0, 8)}`));
15871
+ console.log(import_picocolors20.default.green(`Review edited: ${truncateId(id)}`));
15855
15872
  });
15856
15873
  cmd.command("context").description("Get review context for a thread").argument("<thread-id>", "Thread ID").option("--json", "Output as JSON").action(async (threadId, opts) => {
15857
15874
  const cfg = requireConfig10();
@@ -15882,7 +15899,7 @@ function reviewCommand() {
15882
15899
  cmd.command(name).description(`${verb} a review item (doc change or draft reply; shows a preview, 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) => {
15883
15900
  const cfg = requireConfig10();
15884
15901
  const client = createTypedClient(cfg);
15885
- const change = await resolveChange(client, id);
15902
+ const change = isDraftId(id) ? null : await requireChange(client, id);
15886
15903
  const draft = change ? null : await requireDraft(client, id);
15887
15904
  const noun = change ? "change" : "draft reply";
15888
15905
  if (!opts.json) {
@@ -15920,26 +15937,26 @@ function reviewCommand() {
15920
15937
  if (change) {
15921
15938
  await client.page.updatePublicationStatus.mutate({ page_version_id: id, action });
15922
15939
  } else if (action === "accept") {
15923
- await client.messages.publishMessage.mutate({ postId: id });
15940
+ await client.messages.publishMessage.mutate({ postId: bareMessageId(id) });
15924
15941
  } else {
15925
- await client.messages.deleteMessage.mutate(id);
15942
+ await client.messages.deleteMessage.mutate(bareMessageId(id));
15926
15943
  }
15927
15944
  if (opts.json) {
15928
15945
  printResult({ success: true, id, action }, opts);
15929
15946
  return;
15930
15947
  }
15931
- console.log(import_picocolors20.default.green(`Review ${name}: ${id.slice(0, 8)}`));
15948
+ console.log(import_picocolors20.default.green(`Review ${name}: ${truncateId(id)}`));
15932
15949
  });
15933
15950
  }
15934
15951
  cmd.command("revert").description("Revert a doc change to pending review (not supported for draft replies)").argument("<id>", "Review item ID (from `dosu review list`)").option("--json", "Output as JSON").action(async (id, opts) => {
15935
15952
  const cfg = requireConfig10();
15936
15953
  const client = createTypedClient(cfg);
15937
- const change = await resolveChange(client, id);
15938
- if (!change) {
15954
+ if (isDraftId(id)) {
15939
15955
  await requireDraft(client, id);
15940
15956
  console.error(import_picocolors20.default.red("Revert is not supported for draft replies. A rejected draft is regenerated on the next agent run."));
15941
15957
  process.exit(1);
15942
15958
  }
15959
+ await requireChange(client, id);
15943
15960
  await client.page.updatePublicationStatus.mutate({
15944
15961
  page_version_id: id,
15945
15962
  action: "revert_to_pending"
@@ -15948,7 +15965,7 @@ function reviewCommand() {
15948
15965
  printResult({ success: true, id, action: "revert_to_pending" }, opts);
15949
15966
  return;
15950
15967
  }
15951
- console.log(import_picocolors20.default.green(`Review revert: ${id.slice(0, 8)}`));
15968
+ console.log(import_picocolors20.default.green(`Review revert: ${truncateId(id)}`));
15952
15969
  });
15953
15970
  return cmd;
15954
15971
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosu/cli",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "type": "module",
5
5
  "description": "Dosu CLI - Manage MCP servers for AI tools",
6
6
  "license": "MIT",