@clickminded/coauthor-cli 0.0.9 → 0.0.10

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/README.md CHANGED
@@ -189,6 +189,7 @@ Agents should:
189
189
  - Use `--json` on every command they need to parse.
190
190
  - Use `--wait` when starting long-running research or draft jobs and the user expects completion.
191
191
  - Treat `status: "requires_key"` as a recoverable pause, not a failed workflow. Tell the user to add keys in AI settings, then resume with `coauthor workflow resume <project-id> --wait --json`.
192
+ - Treat `status: "research_structuring"` or `data.diagnostic.code: "research_structuring"` as a normal transition after raw research completes. Wait for `project_state: "research_structured"` before generating a draft; do not rewind for this state.
192
193
  - Use `coauthor credits <project-id> --json` to inspect credit allowance, pending holds, and remaining credits.
193
194
  - Avoid retrying publish/export after uncertain network failures.
194
195
  - Use `coauthor operation status <operation-key>` after uncertainty.
package/dist/commands.js CHANGED
@@ -792,6 +792,20 @@ function enrichResearchStatus(data) {
792
792
  const projectState = getResponseString(data, 'project_state');
793
793
  if (runStatus !== 'running' || projectState === 'research_running')
794
794
  return data;
795
+ if (projectState === 'research_complete') {
796
+ return {
797
+ ...data,
798
+ diagnostic: {
799
+ code: 'research_structuring',
800
+ message: 'Raw research is complete and the worker is structuring the results. Keep waiting until project_state is "research_structured"; do not rewind for this transition.',
801
+ next_commands: [
802
+ 'coauthor research status <project-id> --json',
803
+ 'coauthor draft status <project-id> --json',
804
+ 'coauthor workflow resume <project-id> --target draft --wait --json',
805
+ ],
806
+ },
807
+ };
808
+ }
795
809
  return {
796
810
  ...data,
797
811
  diagnostic: {
package/dist/index.js CHANGED
@@ -41,26 +41,44 @@ function formatCliError(error, baseUrl, argv = []) {
41
41
  if (requiresKey)
42
42
  return { error: new Error(requiresKey.message), result: requiresKey, exitCode: 2 };
43
43
  const message = extractErrorMessage(error.responseBody) ?? error.message;
44
- const researchBlock = formatResearchRunningDraftBlock(message, argv);
44
+ const researchBlock = formatResearchDraftBlock(message, argv);
45
45
  if (researchBlock)
46
46
  return { error: new Error(researchBlock.message), result: researchBlock, exitCode: 2 };
47
47
  return { error: new Error(message), exitCode: 1 };
48
48
  }
49
49
  return { error: error instanceof Error ? error : new Error(String(error)), exitCode: 1 };
50
50
  }
51
- function formatResearchRunningDraftBlock(message, argv) {
52
- if (!/Cannot generate draft in state "research_running"/i.test(message))
51
+ function formatResearchDraftBlock(message, argv) {
52
+ const stateMatch = /Cannot generate draft in state "(research_running|research_complete)"/i.exec(message);
53
+ if (!stateMatch)
53
54
  return null;
55
+ const state = stateMatch[1]?.toLowerCase();
54
56
  const projectId = resolveProjectIdFromArgv(argv);
57
+ const statusCommand = projectId ? `coauthor research status ${projectId} --json` : 'coauthor research status <project-id> --json';
58
+ const resumeCommand = projectId
59
+ ? `coauthor workflow resume ${projectId} --target draft --wait --json`
60
+ : 'coauthor workflow resume <project-id> --target draft --wait --json';
61
+ if (state === 'research_complete') {
62
+ return {
63
+ ok: false,
64
+ status: 'research_structuring',
65
+ message: `${message}\nResearch is complete and the results are being structured. Wait for project_state "research_structured" before generating a draft.`,
66
+ next_commands: [
67
+ statusCommand,
68
+ resumeCommand,
69
+ ],
70
+ exitCode: 2,
71
+ };
72
+ }
55
73
  const recoveryCommands = projectId
56
74
  ? [
57
- `coauthor research status ${projectId} --json`,
58
- `coauthor workflow resume ${projectId} --target draft --wait --json`,
75
+ statusCommand,
76
+ resumeCommand,
59
77
  `coauthor workflow rewind ${projectId} --target research --json`,
60
78
  ]
61
79
  : [
62
- 'coauthor research status <project-id> --json',
63
- 'coauthor workflow resume <project-id> --target draft --wait --json',
80
+ statusCommand,
81
+ resumeCommand,
64
82
  'coauthor workflow rewind <project-id> --target research --json',
65
83
  ];
66
84
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickminded/coauthor-cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "coauthor": "dist/index.js",
@@ -16,6 +16,7 @@ This skill guides agent use of the CoAuthor CLI.
16
16
  - Let the default bounded briefing review run before outline/draft generation. Use `--briefing-mode strict` when the user explicitly wants a stronger brief gate, and answer or relay `data.clarification_questions` if the CLI returns `status: "needs_clarification"`.
17
17
  - Treat `status: "requires_key"` or `paused_requires_key` as a saved, recoverable pause. Do not retry in a loop; tell the user to add the required provider key in AI settings, then resume with `coauthor workflow resume <project-id> --wait --json`.
18
18
  - Treat `status: "blocked_by_research"` as an actionable blocked state. Use the returned `recovery_commands` instead of retrying blindly.
19
+ - Treat `status: "research_structuring"` or `data.diagnostic.code: "research_structuring"` as a normal transition after raw research completes. Keep waiting or resume toward draft; do not rewind or generate a draft until project state reaches `research_structured`.
19
20
  - If `coauthor research status <project-id> --json` returns `data.diagnostic.code: "research_run_state_mismatch"`, report the mismatch and use the returned recovery commands.
20
21
  - Use `coauthor credits <project-id> --json` to check credit allowance, pending credits, and remaining credits.
21
22
  - After a timeout, interruption, network error, or unclear result, check operation status before retrying.
@@ -16,6 +16,7 @@ This skill guides agent use of the CoAuthor CLI.
16
16
  - Let the default bounded briefing review run before outline/draft generation. Use `--briefing-mode strict` when the user explicitly wants a stronger brief gate, and answer or relay `data.clarification_questions` if the CLI returns `status: "needs_clarification"`.
17
17
  - Treat `status: "requires_key"` or `paused_requires_key` as a saved, recoverable pause. Do not retry in a loop; tell the user to add the required provider key in AI settings, then resume with `coauthor workflow resume <project-id> --wait --json`.
18
18
  - Treat `status: "blocked_by_research"` as an actionable blocked state. Use the returned `recovery_commands` instead of retrying blindly.
19
+ - Treat `status: "research_structuring"` or `data.diagnostic.code: "research_structuring"` as a normal transition after raw research completes. Keep waiting or resume toward draft; do not rewind or generate a draft until project state reaches `research_structured`.
19
20
  - If `coauthor research status <project-id> --json` returns `data.diagnostic.code: "research_run_state_mismatch"`, report the mismatch and use the returned recovery commands.
20
21
  - Use `coauthor credits <project-id> --json` to check credit allowance, pending credits, and remaining credits.
21
22
  - After a timeout, interruption, network error, or unclear result, check operation status before retrying.
@@ -16,6 +16,7 @@ This skill guides agent use of the CoAuthor CLI.
16
16
  - Let the default bounded briefing review run before outline/draft generation. Use `--briefing-mode strict` when the user explicitly wants a stronger brief gate, and answer or relay `data.clarification_questions` if the CLI returns `status: "needs_clarification"`.
17
17
  - Treat `status: "requires_key"` or `paused_requires_key` as a saved, recoverable pause. Do not retry in a loop; tell the user to add the required provider key in AI settings, then resume with `coauthor workflow resume <project-id> --wait --json`.
18
18
  - Treat `status: "blocked_by_research"` as an actionable blocked state. Use the returned `recovery_commands` instead of retrying blindly.
19
+ - Treat `status: "research_structuring"` or `data.diagnostic.code: "research_structuring"` as a normal transition after raw research completes. Keep waiting or resume toward draft; do not rewind or generate a draft until project state reaches `research_structured`.
19
20
  - If `coauthor research status <project-id> --json` returns `data.diagnostic.code: "research_run_state_mismatch"`, report the mismatch and use the returned recovery commands.
20
21
  - Use `coauthor credits <project-id> --json` to check credit allowance, pending credits, and remaining credits.
21
22
  - After a timeout, interruption, network error, or unclear result, check operation status before retrying.
@@ -13,6 +13,7 @@ alwaysApply: true
13
13
  - Let the default bounded briefing review run before outline/draft generation. Use `--briefing-mode strict` for a stronger brief gate, and answer or relay `data.clarification_questions` if the CLI returns `status: "needs_clarification"`.
14
14
  - Treat `status: "requires_key"` or `paused_requires_key` as a saved, recoverable pause. Do not retry in a loop; tell the user to add the required provider key in AI settings, then resume with `coauthor workflow resume <project-id> --wait --json`.
15
15
  - Treat `status: "blocked_by_research"` as an actionable blocked state. Use the returned `recovery_commands` instead of retrying blindly.
16
+ - Treat `status: "research_structuring"` or `data.diagnostic.code: "research_structuring"` as a normal transition after raw research completes. Keep waiting or resume toward draft; do not rewind or generate a draft until project state reaches `research_structured`.
16
17
  - If `coauthor research status <project-id> --json` returns `data.diagnostic.code: "research_run_state_mismatch"`, report the mismatch and use the returned recovery commands.
17
18
  - Use `coauthor credits <project-id> --json` to check credit allowance, pending credits, and remaining credits.
18
19
  - After timeout, interruption, network error, or ambiguous output, check operation status before retrying or reporting success.