@clickminded/coauthor-cli 0.0.78 → 0.0.80

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/commands.js CHANGED
@@ -916,6 +916,21 @@ async function runDraftReviseCommand(projectId, input, context) {
916
916
  data: started,
917
917
  };
918
918
  }
919
+ if (getResponseString(revision, 'state') === 'failed') {
920
+ // A failed revision is an error, never a result to review (dogfood, Nov 2026: a "safe limit" failure
921
+ // came back as ok: true with apply/discard next_commands).
922
+ const code = getResponseString(revision, 'error_code') ?? 'revision_failed';
923
+ const reply = getResponseString(revision, 'assistant_message');
924
+ const tooBig = /budget_exhausted$/.test(code);
925
+ return {
926
+ ok: false,
927
+ status: 'failed',
928
+ code,
929
+ exitCode: 1,
930
+ message: `Revision ${revisionId} failed (${code}); the draft was not changed.${reply ? `\nCoAuthor replied: ${reply}` : ''}${tooBig ? '\nSplit the instruction: send one or two fixes per `draft revise`, or edit exact text directly (references/editing-drafts.md).' : ''}`,
931
+ data: revision,
932
+ };
933
+ }
919
934
  if (getResponseValue(revision, 'awaiting_review') !== true) {
920
935
  // No changes usually means CoAuthor asked a question or explained why it
921
936
  // did not edit. Show its reply so the caller can answer or rephrase.
package/dist/output.d.ts CHANGED
@@ -5,6 +5,8 @@ export type CommandResult = {
5
5
  message?: string;
6
6
  data?: JsonValue;
7
7
  exitCode?: number;
8
+ /** Machine-readable failure code for --json (otherwise derived from status). */
9
+ code?: string;
8
10
  settings_url?: string;
9
11
  resume_command?: string;
10
12
  /** The Idempotency-Key sent with the command's live request; look it up with `coauthor operation status <key>`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickminded/coauthor-cli",
3
- "version": "0.0.78",
3
+ "version": "0.0.80",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "coauthor": "dist/index.js",
@@ -12,6 +12,7 @@ coauthor draft revise <id> --instruction "Cut the intro to two sentences and lea
12
12
 
13
13
  - The result's `data.groups` lists each proposed change with `before_markdown` and `after_markdown`. Review every group against the brief: is it accurate, in voice, and limited to what was asked?
14
14
  - Apply all groups: `coauthor draft revision apply <id> <revision-id> --json`. Keep only some with `--accept <group id>,<group id>`, or all but some with `--reject <group id>`, copying the ids (`review_…`) from `data.groups[].id`. Groups not named in `--accept` are dropped. Drop the whole revision with `coauthor draft revision discard <id> <revision-id> --json`.
15
+ - A failed revision exits 1 with `ok: false`, `status: "failed"` and a `code`; the draft is unchanged. `call_budget_exhausted`, `token_budget_exhausted`, `cost_budget_exhausted` and `time_budget_exhausted` mean the request was too big for one pass: send one or two fixes per `draft revise`, or make exact text fixes (a URL, a checklist's `[ ]` markers) with a direct edit (section 2).
15
16
  - `status: "no_changes"` usually means CoAuthor asked a question instead of guessing. Read `data.assistant_message`, then run `draft revise` again with a clearer instruction.
16
17
  - Name the place precisely ("the paragraph after the 'Write the first line' heading") and give numbers for cuts ("under 60 words"). Vague targets get a clarifying question back, and a vague "tighten" changes little.
17
18
  - One revision can be open on a draft at a time, and an open one blocks the user's saves in the browser. Always apply or discard it. `revision_pending` means one is already open. A revision you leave waiting for review is discarded automatically after 30 minutes (`expires_at` in `draft revision show`), so review it promptly; after that, start a new one.
@@ -8,6 +8,7 @@ Every failure prints JSON on stderr with `ok: false`, `error` (a readable messag
8
8
  | --- | --- | --- |
9
9
  | `needs_clarification` | The brief is too thin to outline well. | Answer `data.clarification_questions` from your context (ask the user only what you can't know), update the contract, run again. |
10
10
  | `timed_out` | The wait window ended; the work is still running on CoAuthor's side. | Run the resume command in `data.next_commands`, usually `coauthor workflow resume <id> --target draft --wait --json`. |
11
+ | `contract_field_too_long` | A brief field or list item is over its limit (`data.fields` lists each one: list items 600 characters, `additional_editorial_guidance` 10,000, other text fields 600 or 2,000, and 20–40 items per list). Nothing was saved. | Shorten the named fields, or split a long item into several items, and save again. |
11
12
  | `still_running` | Same, for a draft revision. | `coauthor draft revision show <id> <revision-id> --json`. |
12
13
  | `research_structuring` | Research finished and is being organized for drafting. Normal. | Keep waiting or resume toward draft. Don't rewind. |
13
14
  | `research_running_stale` | Research progress has not changed for 30+ minutes. | Check `coauthor research status <id> --json` a few minutes apart and look at `coauthor research structured <id> --json`. Rewinding (`coauthor workflow rewind <id> --target research --json`) discards the research done so far and costs credits to redo, so ask the user first. |
@@ -312,6 +312,7 @@ coauthor draft revise <id> --instruction "Cut the intro to two sentences and lea
312
312
 
313
313
  - The result's `data.groups` lists each proposed change with `before_markdown` and `after_markdown`. Review every group against the brief: is it accurate, in voice, and limited to what was asked?
314
314
  - Apply all groups: `coauthor draft revision apply <id> <revision-id> --json`. Keep only some with `--accept <group id>,<group id>`, or all but some with `--reject <group id>`, copying the ids (`review_…`) from `data.groups[].id`. Groups not named in `--accept` are dropped. Drop the whole revision with `coauthor draft revision discard <id> <revision-id> --json`.
315
+ - A failed revision exits 1 with `ok: false`, `status: "failed"` and a `code`; the draft is unchanged. `call_budget_exhausted`, `token_budget_exhausted`, `cost_budget_exhausted` and `time_budget_exhausted` mean the request was too big for one pass: send one or two fixes per `draft revise`, or make exact text fixes (a URL, a checklist's `[ ]` markers) with a direct edit (section 2).
315
316
  - `status: "no_changes"` usually means CoAuthor asked a question instead of guessing. Read `data.assistant_message`, then run `draft revise` again with a clearer instruction.
316
317
  - Name the place precisely ("the paragraph after the 'Write the first line' heading") and give numbers for cuts ("under 60 words"). Vague targets get a clarifying question back, and a vague "tighten" changes little.
317
318
  - One revision can be open on a draft at a time, and an open one blocks the user's saves in the browser. Always apply or discard it. `revision_pending` means one is already open. A revision you leave waiting for review is discarded automatically after 30 minutes (`expires_at` in `draft revision show`), so review it promptly; after that, start a new one.
@@ -724,6 +725,7 @@ Every failure prints JSON on stderr with `ok: false`, `error` (a readable messag
724
725
  | --- | --- | --- |
725
726
  | `needs_clarification` | The brief is too thin to outline well. | Answer `data.clarification_questions` from your context (ask the user only what you can't know), update the contract, run again. |
726
727
  | `timed_out` | The wait window ended; the work is still running on CoAuthor's side. | Run the resume command in `data.next_commands`, usually `coauthor workflow resume <id> --target draft --wait --json`. |
728
+ | `contract_field_too_long` | A brief field or list item is over its limit (`data.fields` lists each one: list items 600 characters, `additional_editorial_guidance` 10,000, other text fields 600 or 2,000, and 20–40 items per list). Nothing was saved. | Shorten the named fields, or split a long item into several items, and save again. |
727
729
  | `still_running` | Same, for a draft revision. | `coauthor draft revision show <id> <revision-id> --json`. |
728
730
  | `research_structuring` | Research finished and is being organized for drafting. Normal. | Keep waiting or resume toward draft. Don't rewind. |
729
731
  | `research_running_stale` | Research progress has not changed for 30+ minutes. | Check `coauthor research status <id> --json` a few minutes apart and look at `coauthor research structured <id> --json`. Rewinding (`coauthor workflow rewind <id> --target research --json`) discards the research done so far and costs credits to redo, so ask the user first. |