@clickminded/coauthor-cli 0.0.26 → 0.0.28

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
@@ -236,7 +236,23 @@ async function runProjectCommand(action, input, client) {
236
236
  const data = await client.request({ path: `projects/${encodeURIComponent(projectId)}` });
237
237
  return { ok: true, data };
238
238
  }
239
- throw new Error('Usage: coauthor project <create|list|show>');
239
+ if (action === 'rename') {
240
+ const projectId = requireProjectId(input);
241
+ const title = getString(input.values, 'title') ?? input.positionals.slice(1).join(' ');
242
+ if (!title.trim())
243
+ throw new Error('Usage: coauthor project rename <project-id> --title "..."');
244
+ const data = await client.request({ method: 'POST', path: `projects/${encodeURIComponent(projectId)}/rename`, body: { title } });
245
+ return { ok: true, message: `Renamed to "${title.trim()}".`, data };
246
+ }
247
+ if (action === 'delete') {
248
+ const projectId = requireProjectId(input);
249
+ if (!getBoolean(input.values, 'yes')) {
250
+ throw new Error('Deleting a project removes its brief, outline, research, draft, images, and social posts permanently. Re-run with --yes to confirm.');
251
+ }
252
+ const data = await client.request({ method: 'DELETE', path: `projects/${encodeURIComponent(projectId)}` });
253
+ return { ok: true, message: `Deleted project ${projectId}.`, data };
254
+ }
255
+ throw new Error('Usage: coauthor project <create|list|show|rename|delete>');
240
256
  }
241
257
  async function runWorkspaceCommand(action, input, client) {
242
258
  if (action !== 'show')
@@ -665,6 +681,11 @@ async function runResourceCommand(resource, action, input, client) {
665
681
  const data = await client.request({ method: 'POST', path: `${basePath}/${action}`, body });
666
682
  return { ok: true, data };
667
683
  }
684
+ if (resource === 'images' && action === 'generate' && getBoolean(input.values, 'all')) {
685
+ if (!projectId)
686
+ throw new Error('Usage: coauthor image generate <project-id> --all [--wait]');
687
+ return generateAllImages(client, projectId, getBoolean(input.values, 'wait'));
688
+ }
668
689
  if (resource === 'images' && action === 'metadata') {
669
690
  if (!projectId)
670
691
  throw new Error('Missing project id for image metadata');
@@ -1519,6 +1540,7 @@ async function downloadRepurposed(projectId, format, outOption, client) {
1519
1540
  }
1520
1541
  const formats = format === 'all' ? REPURPOSE_FORMATS : format === 'article' ? [] : [format];
1521
1542
  const manifest = {};
1543
+ const missingLink = [];
1522
1544
  for (const entry of formats) {
1523
1545
  const shown = await client.request({ path: `projects/${encodeURIComponent(projectId)}/repurpose/${encodeURIComponent(entry)}` });
1524
1546
  const artifact = getResponseValue(shown, 'artifact');
@@ -1527,14 +1549,17 @@ async function downloadRepurposed(projectId, format, outOption, client) {
1527
1549
  skipped.push(entry);
1528
1550
  continue;
1529
1551
  }
1530
- await write(`${entry}.md`, renderRepurposeMarkdown(entry, copy));
1552
+ const markdown = renderRepurposeMarkdown(entry, copy);
1553
+ if (markdown.includes('{{POST_URL}}'))
1554
+ missingLink.push(entry);
1555
+ await write(`${entry}.md`, markdown);
1531
1556
  await write(`${entry}.json`, JSON.stringify(artifact, null, 2));
1532
1557
  manifest[entry] = {
1533
1558
  stale: Boolean(getResponseValue(artifact, 'stale_at')),
1534
1559
  updated_at: getResponseValue(artifact, 'updated_at') ?? null,
1535
1560
  };
1536
1561
  }
1537
- await write('manifest.json', JSON.stringify({ project_id: projectId, downloaded_at: new Date().toISOString(), formats: manifest, skipped }, null, 2));
1562
+ await write('manifest.json', JSON.stringify({ project_id: projectId, downloaded_at: new Date().toISOString(), formats: manifest, skipped, missing_article_link: missingLink }, null, 2));
1538
1563
  const staleNote = Object.entries(manifest).filter(([, value]) => value.stale).map(([key]) => key);
1539
1564
  return {
1540
1565
  ok: true,
@@ -1542,6 +1567,9 @@ async function downloadRepurposed(projectId, format, outOption, client) {
1542
1567
  `Wrote ${written.length} files to ${outDir}`,
1543
1568
  skipped.length > 0 ? `Not generated yet: ${skipped.join(', ')} (coauthor repurpose generate ${projectId} --format <format>; slideshow and video are made in the web app).` : '',
1544
1569
  staleNote.length > 0 ? `Stale (the draft changed since they were made): ${staleNote.join(', ')}. Regenerate them before posting.` : '',
1570
+ missingLink.length > 0
1571
+ ? `No article link yet: ${missingLink.join(', ')} still contain {{POST_URL}}. Set it with coauthor repurpose save ${projectId} --format <format> --data '{"destination_url":"https://..."}' and download again, or replace it when posting.`
1572
+ : '',
1545
1573
  ].filter(Boolean).join('\n'),
1546
1574
  data: { out_dir: outDir, files: written, skipped },
1547
1575
  };
@@ -1574,6 +1602,67 @@ function renderRepurposeMarkdown(format, copy) {
1574
1602
  }
1575
1603
  return lines.join('\n');
1576
1604
  }
1605
+ function imageStatusRows(data) {
1606
+ const placeholders = getResponseValue(data, 'placeholders');
1607
+ if (!Array.isArray(placeholders))
1608
+ return [];
1609
+ return placeholders.flatMap((placeholder) => {
1610
+ if (!placeholder || typeof placeholder !== 'object' || Array.isArray(placeholder))
1611
+ return [];
1612
+ const id = placeholder.id;
1613
+ const latest = placeholder.latest_image;
1614
+ const status = latest && typeof latest === 'object' && !Array.isArray(latest) && typeof latest.status === 'string' ? latest.status : null;
1615
+ return typeof id === 'string' ? [{ id, status }] : [];
1616
+ });
1617
+ }
1618
+ // Generates every planned image that isn't already done or generating, then
1619
+ // optionally waits (under the 10-minute agent shell limit) until none are
1620
+ // still generating.
1621
+ async function generateAllImages(client, projectId, wait) {
1622
+ const statusPath = `projects/${encodeURIComponent(projectId)}/images/status`;
1623
+ const before = imageStatusRows(await client.request({ path: statusPath }));
1624
+ const toGenerate = before.filter((row) => row.status !== 'done' && row.status !== 'generating');
1625
+ const started = [];
1626
+ const failedToStart = [];
1627
+ for (const row of toGenerate) {
1628
+ try {
1629
+ await client.request({ method: 'POST', path: `projects/${encodeURIComponent(projectId)}/images/generate`, body: { placeholderId: row.id } });
1630
+ started.push(row.id);
1631
+ }
1632
+ catch (error) {
1633
+ failedToStart.push({ id: row.id, error: error instanceof Error ? error.message : String(error) });
1634
+ }
1635
+ }
1636
+ let rows = before;
1637
+ if (wait && (started.length > 0 || before.some((row) => row.status === 'generating'))) {
1638
+ const deadline = Date.now() + waitTimeoutMs(9 * 60_000);
1639
+ const pollMs = Math.max(waitPollMs(), 0);
1640
+ do {
1641
+ await sleep(Math.min(pollMs, 15_000));
1642
+ rows = imageStatusRows(await client.request({ path: statusPath }));
1643
+ } while (rows.some((row) => row.status === 'generating') && Date.now() < deadline);
1644
+ }
1645
+ const count = (status) => rows.filter((row) => row.status === status).length;
1646
+ const generating = wait ? count('generating') : started.length + count('generating');
1647
+ const summary = {
1648
+ placeholders: before.length,
1649
+ started: started.length,
1650
+ already_done: before.filter((row) => row.status === 'done').length,
1651
+ done: wait ? count('done') : null,
1652
+ failed: wait ? count('failed') : null,
1653
+ generating,
1654
+ failed_to_start: failedToStart,
1655
+ };
1656
+ return {
1657
+ ok: failedToStart.length === 0 && (!wait || count('failed') === 0),
1658
+ status: wait && generating > 0 ? 'still_running' : undefined,
1659
+ exitCode: wait && generating > 0 ? 2 : undefined,
1660
+ message: wait
1661
+ ? `Images: ${count('done')} done, ${count('failed')} failed, ${generating} still generating.${generating > 0 ? ` Check again with: coauthor image status ${projectId} --json` : ''}`
1662
+ : `Started ${started.length} image${started.length === 1 ? '' : 's'}. Check progress with: coauthor image status ${projectId} --json`,
1663
+ data: summary,
1664
+ };
1665
+ }
1577
1666
  function enrichResearchStatus(data) {
1578
1667
  if (!data || typeof data !== 'object' || Array.isArray(data))
1579
1668
  return data;
@@ -1749,7 +1838,7 @@ export function helpResult(command = []) {
1749
1838
  '',
1750
1839
  'Commands:',
1751
1840
  ' auth login|status|logout (logout supports --local-only)',
1752
- ' project create|list|show',
1841
+ ' project create|list|show|rename|delete',
1753
1842
  ' workspace show',
1754
1843
  ' chat [show|list]',
1755
1844
  ' contract show|save|approve',
@@ -1834,7 +1923,7 @@ function commandHelp(command) {
1834
1923
  DRAFT_SAVE_SHAPE,
1835
1924
  ].join('\n'),
1836
1925
  project: [
1837
- 'Usage: coauthor project <create|list|show> [<project-id>] [--json]',
1926
+ 'Usage: coauthor project <create|list|show|rename|delete> [<project-id>] [--title "..."] [--yes] [--json]',
1838
1927
  '',
1839
1928
  'create: --title, --topic, --audience, --contract <json|@file>. list: --limit. show: one project.',
1840
1929
  ].join('\n'),
@@ -1916,6 +2005,7 @@ function commandHelp(command) {
1916
2005
  ].join('\n'),
1917
2006
  image: [
1918
2007
  'Usage: coauthor image <list|status|show|generate|edit|metadata> <project-id> [...] [--json]',
2008
+ ' coauthor image generate <project-id> --all [--wait] [--json] (every planned image; --wait until they finish)',
1919
2009
  '',
1920
2010
  'list: planned placeholders (use each id). generate/edit: --placeholder-id <id> [--edit-prompt "..."]. status: generation progress.',
1921
2011
  'metadata <project-id> <placeholder id>: --alt-text, --description, --file-slug.',
package/dist/parser.js CHANGED
@@ -69,6 +69,7 @@ const OPTIONS = {
69
69
  feedback: { type: 'string' },
70
70
  profile: { type: 'string' },
71
71
  out: { type: 'string' },
72
+ all: { type: 'boolean', default: false },
72
73
  kind: { type: 'string' },
73
74
  apply: { type: 'boolean', default: false },
74
75
  accept: { type: 'string' },
@@ -141,7 +142,7 @@ function commandLength(positionals) {
141
142
  if (first === 'auth')
142
143
  return second && ['login', 'status', 'logout'].includes(second) ? 2 : 1;
143
144
  if (first === 'project')
144
- return second && ['create', 'list', 'show'].includes(second) ? 2 : 1;
145
+ return second && ['create', 'list', 'show', 'rename', 'delete'].includes(second) ? 2 : 1;
145
146
  if (first === 'workspace')
146
147
  return second === 'show' ? 2 : 1;
147
148
  if (first === 'chat')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickminded/coauthor-cli",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "coauthor": "dist/index.js",
@@ -37,7 +37,7 @@ Typical timing: brief and outline under a minute; research and draft 3–10 minu
37
37
  4. **Research-plan checkpoint.** `coauthor research-plan generate <id> --json` (tasks in `data.research_tasks`). Check every section has a task, every claim that needs proof points at the right sources (including URLs the user gave you), and deep research is used only where it matters. Fix it with `coauthor research-plan revise <id> --feedback "Add a task for the checklist section. Use https://… as a required source for the limits section." --json` and check `data.diff`, then `coauthor research-plan approve <id> --json` and log it.
38
38
  5. **Research and draft.** `COAUTHOR_CLI_WAIT_TIMEOUT_MS=540000 coauthor workflow run <id> --target draft --wait --json`. It is done when the message says the draft completed (`data.draft_status.project_state` is `draft_generated`); ignore the stale `data.workflow.status`. On `timed_out`: `coauthor workflow resume <id> --target draft --wait --json`.
39
39
  6. **Quality pass.** `coauthor draft get <id> --format markdown --json` and read `data.markdown` in full. Check it against the brief's must-include, must-avoid, and non-negotiables. Look for: notes about the research process ("the retrieved sources do not…"), invented "checked <date>" lines, numbered lists that restart at 1, garbled `*`, `_`, or code spans, literal `[ ]` in checklists, the same caveat repeated across sections, claims without a source or cited to a page that doesn't support them, contradictions, and a messy Sources list (generic titles like "Google", duplicate entries). Fix them in step 8.
40
- 7. **Images.** `coauthor image list <id> --json`, then for each placeholder `coauthor image generate <id> --placeholder-id <placeholder id> --json` (the `id` UUID, not `placeholder_id`), then poll `coauthor image status <id> --json` until none are generating. CoAuthor decides how many images a draft gets, sometimes only the featured image; the CLI can't add more, so tell the user if they expected several. Open each image and check it does not state numbers or claims the article does not make, then rewrite its alt text to match what is actually visible (the stored alt text describes the plan, not the result). See `references/images-and-social.md`.
40
+ 7. **Images.** `coauthor image generate <id> --all --wait --json` generates every planned image and waits for them (one image: `coauthor image generate <id> --placeholder-id <placeholder id> --json`, using the `id` UUID from `image list`). CoAuthor decides how many images a draft gets, sometimes only the featured image; the CLI can't add more, so tell the user if they expected several. Open each image and check it does not state numbers or claims the article does not make, then rewrite its alt text to match what is actually visible (the stored alt text describes the plan, not the result). See `references/images-and-social.md`.
41
41
  8. **Edits.** For prose changes: `coauthor draft revise <id> --instruction "..." --wait --json` (be specific: name the section and give a number, such as "cut the intro to under 60 words"), review each group's `before_markdown` and `after_markdown`, then `coauthor draft revision apply <id> <revision-id> --json` (optionally `--accept` or `--reject` with ids copied from `data.groups[].id`) or `coauthor draft revision discard <id> <revision-id> --json`. For exact text you already have, edit the document JSON and `draft save`. See `references/editing-drafts.md`.
42
42
  9. **Deliver.** Give the user the final markdown (or `--format html`), the decision log (`coauthor log show <id> --json`: what you approved, what you asked CoAuthor to change, what you assumed), and the credits used (`coauthor credits <id> --json`). The user also sees the log in the project's workspace in the web app. With their yes: share link or WordPress export (`references/publishing-and-export.md`). For social posts and an email newsletter, `coauthor repurpose generate <id> --format all --json`, review `data.copy`, and `coauthor repurpose download <id> --out <dir>` (`references/repurposing.md`).
43
43
 
@@ -60,6 +60,10 @@ Typical timing: brief and outline under a minute; research and draft 3–10 minu
60
60
 
61
61
  Everything else, including auth problems: `references/troubleshooting.md`. Credits, plans, and models: `references/credits-and-plans.md`.
62
62
 
63
+ ## Housekeeping
64
+
65
+ `coauthor project rename <id> --title "..."` renames a project. `coauthor project delete <id> --yes` deletes it permanently, so only do it when the user asks, or for a test project you created yourself.
66
+
63
67
  ## Not in the CLI yet
64
68
 
65
69
  Creating or editing writer profiles, PDFs over about 3.3 MB, adding more images than CoAuthor planned, slideshows, and video. Point the user to the CoAuthor web app at https://tools.clickminded.com/coauthor for these instead of improvising.
@@ -5,8 +5,8 @@
5
5
  Draft generation plans image placeholders, including a featured image (`is_featured: true`) when one fits. It does not generate them. CoAuthor decides how many images a piece gets, sometimes only the featured image, and the CLI cannot add more placeholders. If the user expected several images, tell them more can be added in the web app editor.
6
6
 
7
7
  1. `coauthor image list <id> --json` returns `data.placeholders`. Each has an `id` (UUID), a `purpose`, an `image_type`, and the planned brief.
8
- 2. Generate each one: `coauthor image generate <id> --placeholder-id <id UUID> --json`. Use the `id` UUID; the descriptive `placeholder_id` string is not accepted. Optional: `--grounding-mode <mode>`, `--image-generation-model <id>`.
9
- 3. Generation is asynchronous. Poll `coauthor image status <id> --json` every 15–30 seconds until no placeholder's latest image is `generating`. Each takes about 20 seconds.
8
+ 2. Generate them all and wait: `coauthor image generate <id> --all --wait --json`. It skips images that are already done, and reports `done`, `failed`, and `still_running` (check again with `coauthor image status <id> --json`). Each image takes about 20 seconds.
9
+ 3. To generate one: `coauthor image generate <id> --placeholder-id <id UUID> --json` (the `id` UUID; the descriptive `placeholder_id` string is not accepted; optional `--grounding-mode <mode>`, `--image-generation-model <id>`), then poll `coauthor image status <id> --json`.
10
10
  4. Check every finished image (the URLs are in `image status` and in `draft get --format markdown`):
11
11
  - Charts and tables must match the article's numbers, and must not state figures the article deliberately leaves open.
12
12
  - Screens of real products (for example a Google or Meta interface) must not be presented as genuine.
@@ -39,7 +39,7 @@ Typical timing: brief and outline under a minute; research and draft 3–10 minu
39
39
  4. **Research-plan checkpoint.** `coauthor research-plan generate <id> --json` (tasks in `data.research_tasks`). Check every section has a task, every claim that needs proof points at the right sources (including URLs the user gave you), and deep research is used only where it matters. Fix it with `coauthor research-plan revise <id> --feedback "Add a task for the checklist section. Use https://… as a required source for the limits section." --json` and check `data.diff`, then `coauthor research-plan approve <id> --json` and log it.
40
40
  5. **Research and draft.** `COAUTHOR_CLI_WAIT_TIMEOUT_MS=540000 coauthor workflow run <id> --target draft --wait --json`. It is done when the message says the draft completed (`data.draft_status.project_state` is `draft_generated`); ignore the stale `data.workflow.status`. On `timed_out`: `coauthor workflow resume <id> --target draft --wait --json`.
41
41
  6. **Quality pass.** `coauthor draft get <id> --format markdown --json` and read `data.markdown` in full. Check it against the brief's must-include, must-avoid, and non-negotiables. Look for: notes about the research process ("the retrieved sources do not…"), invented "checked <date>" lines, numbered lists that restart at 1, garbled `*`, `_`, or code spans, literal `[ ]` in checklists, the same caveat repeated across sections, claims without a source or cited to a page that doesn't support them, contradictions, and a messy Sources list (generic titles like "Google", duplicate entries). Fix them in step 8.
42
- 7. **Images.** `coauthor image list <id> --json`, then for each placeholder `coauthor image generate <id> --placeholder-id <placeholder id> --json` (the `id` UUID, not `placeholder_id`), then poll `coauthor image status <id> --json` until none are generating. CoAuthor decides how many images a draft gets, sometimes only the featured image; the CLI can't add more, so tell the user if they expected several. Open each image and check it does not state numbers or claims the article does not make, then rewrite its alt text to match what is actually visible (the stored alt text describes the plan, not the result). See `references/images-and-social.md`.
42
+ 7. **Images.** `coauthor image generate <id> --all --wait --json` generates every planned image and waits for them (one image: `coauthor image generate <id> --placeholder-id <placeholder id> --json`, using the `id` UUID from `image list`). CoAuthor decides how many images a draft gets, sometimes only the featured image; the CLI can't add more, so tell the user if they expected several. Open each image and check it does not state numbers or claims the article does not make, then rewrite its alt text to match what is actually visible (the stored alt text describes the plan, not the result). See `references/images-and-social.md`.
43
43
  8. **Edits.** For prose changes: `coauthor draft revise <id> --instruction "..." --wait --json` (be specific: name the section and give a number, such as "cut the intro to under 60 words"), review each group's `before_markdown` and `after_markdown`, then `coauthor draft revision apply <id> <revision-id> --json` (optionally `--accept` or `--reject` with ids copied from `data.groups[].id`) or `coauthor draft revision discard <id> <revision-id> --json`. For exact text you already have, edit the document JSON and `draft save`. See `references/editing-drafts.md`.
44
44
  9. **Deliver.** Give the user the final markdown (or `--format html`), the decision log (`coauthor log show <id> --json`: what you approved, what you asked CoAuthor to change, what you assumed), and the credits used (`coauthor credits <id> --json`). The user also sees the log in the project's workspace in the web app. With their yes: share link or WordPress export (`references/publishing-and-export.md`). For social posts and an email newsletter, `coauthor repurpose generate <id> --format all --json`, review `data.copy`, and `coauthor repurpose download <id> --out <dir>` (`references/repurposing.md`).
45
45
 
@@ -62,6 +62,10 @@ Typical timing: brief and outline under a minute; research and draft 3–10 minu
62
62
 
63
63
  Everything else, including auth problems: `references/troubleshooting.md`. Credits, plans, and models: `references/credits-and-plans.md`.
64
64
 
65
+ ## Housekeeping
66
+
67
+ `coauthor project rename <id> --title "..."` renames a project. `coauthor project delete <id> --yes` deletes it permanently, so only do it when the user asks, or for a test project you created yourself.
68
+
65
69
  ## Not in the CLI yet
66
70
 
67
71
  Creating or editing writer profiles, PDFs over about 3.3 MB, adding more images than CoAuthor planned, slideshows, and video. Point the user to the CoAuthor web app at https://tools.clickminded.com/coauthor for these instead of improvising.
@@ -330,8 +334,8 @@ CoAuthor's stages form a chain: brief → outline → research plan → research
330
334
  Draft generation plans image placeholders, including a featured image (`is_featured: true`) when one fits. It does not generate them. CoAuthor decides how many images a piece gets, sometimes only the featured image, and the CLI cannot add more placeholders. If the user expected several images, tell them more can be added in the web app editor.
331
335
 
332
336
  1. `coauthor image list <id> --json` returns `data.placeholders`. Each has an `id` (UUID), a `purpose`, an `image_type`, and the planned brief.
333
- 2. Generate each one: `coauthor image generate <id> --placeholder-id <id UUID> --json`. Use the `id` UUID; the descriptive `placeholder_id` string is not accepted. Optional: `--grounding-mode <mode>`, `--image-generation-model <id>`.
334
- 3. Generation is asynchronous. Poll `coauthor image status <id> --json` every 15–30 seconds until no placeholder's latest image is `generating`. Each takes about 20 seconds.
337
+ 2. Generate them all and wait: `coauthor image generate <id> --all --wait --json`. It skips images that are already done, and reports `done`, `failed`, and `still_running` (check again with `coauthor image status <id> --json`). Each image takes about 20 seconds.
338
+ 3. To generate one: `coauthor image generate <id> --placeholder-id <id UUID> --json` (the `id` UUID; the descriptive `placeholder_id` string is not accepted; optional `--grounding-mode <mode>`, `--image-generation-model <id>`), then poll `coauthor image status <id> --json`.
335
339
  4. Check every finished image (the URLs are in `image status` and in `draft get --format markdown`):
336
340
  - Charts and tables must match the article's numbers, and must not state figures the article deliberately leaves open.
337
341
  - Screens of real products (for example a Google or Meta interface) must not be presented as genuine.