@clickminded/coauthor-cli 0.0.24 → 0.0.26

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
@@ -45,7 +45,9 @@ Updating the CLI updates installed skills automatically, unless you edited them;
45
45
  A typical piece:
46
46
 
47
47
  ```sh
48
- coauthor project create --title "Post title" --contract @brief.json --json
48
+ coauthor profile list --json # pick the writer profile (voice, context, image style)
49
+ coauthor project create --title "Post title" --contract @brief.json --profile <profile id> --json
50
+ coauthor source add <id> notes.pdf --json # optional reference documents, before research
49
51
  coauthor workflow run <id> --target contract --briefing-mode strict --json # CoAuthor questions the brief
50
52
  coauthor outline generate <id> --json # review, then:
51
53
  coauthor outline approve <id> --json
@@ -69,10 +71,12 @@ Images, social, and export:
69
71
  coauthor image list <id> --json
70
72
  coauthor image generate <id> --placeholder-id <placeholder id> --json
71
73
  coauthor image status <id> --json
72
- coauthor thread generate <id> --json
74
+ coauthor repurpose generate <id> --format all --json # X thread and post, LinkedIn, Facebook, email newsletter
75
+ coauthor repurpose download <id> --out ./social # copy-ready files plus the article
73
76
  coauthor share <id> --json # public read-only link
74
77
  coauthor export wordpress <id> --yes --slug <slug> --json # creates a WordPress draft post
75
78
  coauthor credits <id> --json
79
+ coauthor integrations list --json # WordPress sites and X accounts
76
80
  ```
77
81
 
78
82
  Run `coauthor --help` or `coauthor <command> --help` for every command and option. `--json` gives machine-readable output, `--wait` waits for long-running work, and JSON options such as `--data` and `--contract` accept `@file.json` (or `@-` for stdin).
package/dist/commands.js CHANGED
@@ -4,7 +4,7 @@ import { createHash } from 'node:crypto';
4
4
  import { existsSync } from 'node:fs';
5
5
  import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
6
6
  import { homedir } from 'node:os';
7
- import { dirname, join, resolve } from 'node:path';
7
+ import { basename, dirname, join, resolve } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { AgentHttpError, normalizeBaseUrl } from './client.js';
10
10
  import { clearConfig, loadConfig, saveConfig } from './config.js';
@@ -29,10 +29,18 @@ export async function runCommand(input, context) {
29
29
  return runArtifactCommand('research-plan', action, input, context.client);
30
30
  if (scope === 'research')
31
31
  return runResearchCommand(action, input, context);
32
+ if (scope === 'repurpose')
33
+ return runRepurposeCommand(action, input, context.client);
32
34
  if (scope === 'brief')
33
35
  return runBriefCommand(action, input, context.client);
34
36
  if (scope === 'log')
35
37
  return runLogCommand(action, input, context.client);
38
+ if (scope === 'profile')
39
+ return runProfileCommand(action, input, context.client);
40
+ if (scope === 'integrations')
41
+ return { ok: true, data: await context.client.request({ path: 'integrations' }) };
42
+ if (scope === 'source')
43
+ return runSourceCommand(action, input, context.client);
36
44
  if (scope === 'draft')
37
45
  return runDraftCommand(action, input, context);
38
46
  if (scope === 'workflow')
@@ -207,6 +215,9 @@ function inactiveAgentTokenCode(error) {
207
215
  async function runProjectCommand(action, input, client) {
208
216
  if (action === 'create') {
209
217
  const body = withNamedOptions(parseJsonOption(input.values), input.values, ['title', 'topic', 'audience']);
218
+ const profile = getString(input.values, 'profile');
219
+ if (profile)
220
+ body.profile_id = profile;
210
221
  const rawContract = getString(input.values, 'contract');
211
222
  if (rawContract !== undefined) {
212
223
  if (!rawContract.trim())
@@ -1351,6 +1362,64 @@ function revisionMessage(artifact, data) {
1351
1362
  lines.push(`Review it with: coauthor ${artifact} show <project-id> --json, then approve with: coauthor ${artifact} approve <project-id> --json`);
1352
1363
  return lines.join('\n');
1353
1364
  }
1365
+ async function runProfileCommand(action, input, client) {
1366
+ if (!action || action === 'list')
1367
+ return { ok: true, data: await client.request({ path: 'profiles' }) };
1368
+ if (action === 'show') {
1369
+ const profileId = input.positionals[0];
1370
+ if (!profileId)
1371
+ throw new Error('Usage: coauthor profile show <profile-id>');
1372
+ return { ok: true, data: await client.request({ path: `profiles/${encodeURIComponent(profileId)}` }) };
1373
+ }
1374
+ throw new Error('Usage: coauthor profile <list|show>');
1375
+ }
1376
+ const SOURCE_TYPES = { pdf: 'application/pdf', txt: 'text/plain', md: 'text/markdown', markdown: 'text/markdown' };
1377
+ // Mirrors the server: base64 over the API caps PDFs at ~3.3 MB; text at 512 KB.
1378
+ const MAX_SOURCE_PDF_BYTES = 3_300_000;
1379
+ const MAX_SOURCE_TEXT_BYTES = 512 * 1024;
1380
+ async function runSourceCommand(action, input, client) {
1381
+ const projectId = requireProjectId(input);
1382
+ const path = `projects/${encodeURIComponent(projectId)}/sources`;
1383
+ if (!action || action === 'list')
1384
+ return { ok: true, data: await client.request({ path }) };
1385
+ if (action === 'add') {
1386
+ const filePath = input.positionals[1];
1387
+ if (!filePath)
1388
+ throw new Error('Usage: coauthor source add <project-id> <file.pdf|.txt|.md>');
1389
+ const fileName = basename(filePath);
1390
+ const extension = fileName.split('.').pop()?.toLowerCase() ?? '';
1391
+ const mimeType = SOURCE_TYPES[extension];
1392
+ if (!mimeType)
1393
+ throw new Error(`Unsupported file type ".${extension}". CoAuthor accepts PDF, .txt, and .md sources.`);
1394
+ const bytes = await readFile(filePath);
1395
+ const limit = mimeType === 'application/pdf' ? MAX_SOURCE_PDF_BYTES : MAX_SOURCE_TEXT_BYTES;
1396
+ if (bytes.byteLength > limit) {
1397
+ throw new Error(`${fileName} is ${Math.round(bytes.byteLength / 1024)} KB; the CLI accepts up to ${Math.round(limit / 1024)} KB for this type. Upload larger files in the web app.`);
1398
+ }
1399
+ const data = await client.request({
1400
+ method: 'POST',
1401
+ path,
1402
+ body: { file_name: fileName, mime_type: mimeType, content_base64: bytes.toString('base64') },
1403
+ });
1404
+ const invalidated = getResponseValue(data, 'research_invalidated') === true;
1405
+ return {
1406
+ ok: true,
1407
+ message: invalidated
1408
+ ? `Added ${fileName}. Existing research and the draft are now stale; run research again so they use it.`
1409
+ : `Added ${fileName}. It is used the next time research runs.`,
1410
+ data,
1411
+ };
1412
+ }
1413
+ if (action === 'remove') {
1414
+ const documentId = input.positionals[1];
1415
+ if (!documentId)
1416
+ throw new Error('Usage: coauthor source remove <project-id> <source-id> --yes');
1417
+ if (!getBoolean(input.values, 'yes'))
1418
+ throw new Error('Removing a source can mark existing research and the draft stale. Re-run with --yes to confirm.');
1419
+ return { ok: true, data: await client.request({ method: 'DELETE', path: `${path}/${encodeURIComponent(documentId)}` }) };
1420
+ }
1421
+ throw new Error('Usage: coauthor source <list|add|remove> <project-id>');
1422
+ }
1354
1423
  async function runBriefCommand(action, input, client) {
1355
1424
  const projectId = requireProjectId(input);
1356
1425
  const path = `projects/${encodeURIComponent(projectId)}/brief`;
@@ -1385,6 +1454,126 @@ async function runLogCommand(action, input, client) {
1385
1454
  }
1386
1455
  throw new Error('Usage: coauthor log <add|show> <projectId>');
1387
1456
  }
1457
+ const REPURPOSE_FORMATS = ['x-thread', 'x-post', 'linkedin', 'facebook', 'email', 'slideshow', 'video'];
1458
+ const REPURPOSE_GENERATABLE = ['x-thread', 'x-post', 'linkedin', 'facebook', 'email'];
1459
+ async function runRepurposeCommand(action, input, client) {
1460
+ const projectId = requireProjectId(input);
1461
+ const base = `projects/${encodeURIComponent(projectId)}/repurpose`;
1462
+ const format = getString(input.values, 'format');
1463
+ if (!action || action === 'list')
1464
+ return { ok: true, data: await client.request({ path: base }) };
1465
+ if (action === 'show') {
1466
+ if (!format)
1467
+ throw new Error(`Usage: coauthor repurpose show <project-id> --format <${REPURPOSE_FORMATS.join('|')}>`);
1468
+ return { ok: true, data: await client.request({ path: `${base}/${encodeURIComponent(format)}` }) };
1469
+ }
1470
+ if (action === 'generate') {
1471
+ if (!format)
1472
+ throw new Error(`Usage: coauthor repurpose generate <project-id> --format <${REPURPOSE_GENERATABLE.join('|')}|all> [--writing-model <id>]`);
1473
+ const formats = format === 'all' ? REPURPOSE_GENERATABLE : [format];
1474
+ const writingModel = getString(input.values, 'writing-model');
1475
+ const results = {};
1476
+ for (const entry of formats) {
1477
+ results[entry] = await client.request({
1478
+ method: 'POST',
1479
+ path: `${base}/${encodeURIComponent(entry)}/generate`,
1480
+ body: writingModel ? { writingModel } : {},
1481
+ });
1482
+ }
1483
+ return {
1484
+ ok: true,
1485
+ message: `Generated ${formats.join(', ')}. Review with: coauthor repurpose show ${projectId} --format <format> --json, or save files with: coauthor repurpose download ${projectId} --format ${format}`,
1486
+ data: format === 'all' ? results : results[format],
1487
+ };
1488
+ }
1489
+ if (action === 'save') {
1490
+ if (!format || readJsonOptionText(input.values) === undefined) {
1491
+ throw new Error('Usage: coauthor repurpose save <project-id> --format <format> --data @edits.json');
1492
+ }
1493
+ return {
1494
+ ok: true,
1495
+ data: await client.request({ method: 'POST', path: `${base}/${encodeURIComponent(format)}/save`, body: parseJsonOption(input.values) }),
1496
+ };
1497
+ }
1498
+ if (action === 'download')
1499
+ return downloadRepurposed(projectId, format ?? 'all', getString(input.values, 'out'), client);
1500
+ throw new Error('Usage: coauthor repurpose <list|show|generate|save|download> <project-id> --format <format>');
1501
+ }
1502
+ async function downloadRepurposed(projectId, format, outOption, client) {
1503
+ const outDir = resolve(outOption ?? `coauthor-${projectId.slice(0, 8)}`);
1504
+ await mkdir(outDir, { recursive: true });
1505
+ const written = [];
1506
+ const skipped = [];
1507
+ const write = async (name, contents) => {
1508
+ await writeFile(join(outDir, name), contents.endsWith('\n') ? contents : `${contents}\n`);
1509
+ written.push(name);
1510
+ };
1511
+ if (format === 'all' || format === 'article') {
1512
+ const [project, draft] = await Promise.all([
1513
+ client.request({ path: `projects/${encodeURIComponent(projectId)}` }),
1514
+ client.request({ path: `projects/${encodeURIComponent(projectId)}/draft/get?format=markdown` }),
1515
+ ]);
1516
+ const title = extractNestedString(project, ['project', 'title']);
1517
+ const markdown = getResponseString(draft, 'markdown') ?? '';
1518
+ await write('article.md', `${title ? `# ${title}\n\n` : ''}${markdown}`);
1519
+ }
1520
+ const formats = format === 'all' ? REPURPOSE_FORMATS : format === 'article' ? [] : [format];
1521
+ const manifest = {};
1522
+ for (const entry of formats) {
1523
+ const shown = await client.request({ path: `projects/${encodeURIComponent(projectId)}/repurpose/${encodeURIComponent(entry)}` });
1524
+ const artifact = getResponseValue(shown, 'artifact');
1525
+ const copy = getResponseValue(shown, 'copy');
1526
+ if (!artifact || !copy) {
1527
+ skipped.push(entry);
1528
+ continue;
1529
+ }
1530
+ await write(`${entry}.md`, renderRepurposeMarkdown(entry, copy));
1531
+ await write(`${entry}.json`, JSON.stringify(artifact, null, 2));
1532
+ manifest[entry] = {
1533
+ stale: Boolean(getResponseValue(artifact, 'stale_at')),
1534
+ updated_at: getResponseValue(artifact, 'updated_at') ?? null,
1535
+ };
1536
+ }
1537
+ await write('manifest.json', JSON.stringify({ project_id: projectId, downloaded_at: new Date().toISOString(), formats: manifest, skipped }, null, 2));
1538
+ const staleNote = Object.entries(manifest).filter(([, value]) => value.stale).map(([key]) => key);
1539
+ return {
1540
+ ok: true,
1541
+ message: [
1542
+ `Wrote ${written.length} files to ${outDir}`,
1543
+ skipped.length > 0 ? `Not generated yet: ${skipped.join(', ')} (coauthor repurpose generate ${projectId} --format <format>; slideshow and video are made in the web app).` : '',
1544
+ staleNote.length > 0 ? `Stale (the draft changed since they were made): ${staleNote.join(', ')}. Regenerate them before posting.` : '',
1545
+ ].filter(Boolean).join('\n'),
1546
+ data: { out_dir: outDir, files: written, skipped },
1547
+ };
1548
+ }
1549
+ function renderRepurposeMarkdown(format, copy) {
1550
+ const asRecord = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : {};
1551
+ const asList = (value) => Array.isArray(value) ? value : [];
1552
+ const text = (value) => typeof value === 'string' ? value : '';
1553
+ const data = asRecord(copy);
1554
+ const titles = { 'x-thread': 'X thread', 'x-post': 'X post', linkedin: 'LinkedIn post', facebook: 'Facebook post', email: 'Email newsletter' };
1555
+ const lines = [`# ${titles[format] ?? format}`, ''];
1556
+ if (format === 'x-thread') {
1557
+ const posts = asList(data.posts).map(text);
1558
+ posts.forEach((post, index) => lines.push(`**${index + 1}/${posts.length}**`, '', post, ''));
1559
+ return lines.join('\n');
1560
+ }
1561
+ for (const variation of asList(data.variations).map(asRecord)) {
1562
+ lines.push(`## ${text(variation.label) || 'Variation'}`, '');
1563
+ if (format === 'x-post') {
1564
+ for (const post of asList(variation.posts).map(asRecord)) {
1565
+ lines.push(text(post.role) === 'link_reply' ? '**Link reply**' : '**Post**', '', text(post.text), '');
1566
+ }
1567
+ }
1568
+ else {
1569
+ lines.push(text(variation.text), '');
1570
+ }
1571
+ const hooks = asList(variation.alternate_hooks).map(text).filter(Boolean);
1572
+ if (hooks.length > 0)
1573
+ lines.push('**Alternate hooks**', '', ...hooks.map((hook) => `- ${hook.replace(/\n+/g, ' ')}`), '');
1574
+ }
1575
+ return lines.join('\n');
1576
+ }
1388
1577
  function enrichResearchStatus(data) {
1389
1578
  if (!data || typeof data !== 'object' || Array.isArray(data))
1390
1579
  return data;
@@ -1566,7 +1755,11 @@ export function helpResult(command = []) {
1566
1755
  ' contract show|save|approve',
1567
1756
  ' outline show|generate|revise|save|approve',
1568
1757
  ' research-plan show|generate|revise|save|approve',
1758
+ ' repurpose list|generate|show|save|download',
1569
1759
  ' brief review|answer',
1760
+ ' profile list|show',
1761
+ ' source list|add|remove',
1762
+ ' integrations list',
1570
1763
  ' log add|show',
1571
1764
  ' research run|status|structured',
1572
1765
  ' draft generate|status|get|save|revise',
@@ -1598,7 +1791,7 @@ function commandHelp(command) {
1598
1791
  '--local-only removes the local credential without revoking the remote token. Use it only when explicitly abandoning remote revocation.',
1599
1792
  ].join('\n'),
1600
1793
  'project create': [
1601
- 'Usage: coauthor project create [--title <title>] [--topic <brief>] [--audience <audience>] [--contract <json>] [--json]',
1794
+ 'Usage: coauthor project create [--title <title>] [--topic <brief>] [--audience <audience>] [--contract <json>] [--profile <profile-id>] [--json]',
1602
1795
  '',
1603
1796
  'Creates a project. When --topic or --audience is provided, CoAuthor seeds the saved contract so workflow briefing review can use that context.',
1604
1797
  '--contract accepts a JSON editorial contract object. Top-level --topic and --audience fill missing contract topic/audience fields.',
@@ -1645,6 +1838,36 @@ function commandHelp(command) {
1645
1838
  '',
1646
1839
  'create: --title, --topic, --audience, --contract <json|@file>. list: --limit. show: one project.',
1647
1840
  ].join('\n'),
1841
+ profile: [
1842
+ 'Usage: coauthor profile list [--json]',
1843
+ ' coauthor profile show <profile-id> [--json]',
1844
+ '',
1845
+ 'Writer profiles hold the voice, writer and business context, and visual style. New projects use the default (most recently used) profile unless you pass --profile to project create. A project keeps its profile for good.',
1846
+ ].join('\n'),
1847
+ integrations: [
1848
+ 'Usage: coauthor integrations list [--json]',
1849
+ '',
1850
+ 'Connected WordPress sites (ids for export wordpress --connection-id) and X accounts. Connect new ones in the web app.',
1851
+ ].join('\n'),
1852
+ source: [
1853
+ 'Usage: coauthor source list <project-id> [--json]',
1854
+ ' coauthor source add <project-id> <file.pdf|.txt|.md> [--json]',
1855
+ ' coauthor source remove <project-id> <source-id> --yes [--json]',
1856
+ '',
1857
+ 'Reference documents CoAuthor researches from (up to 5 per project; PDF up to ~3.3 MB via the CLI, text up to 512 KB).',
1858
+ 'Add them before research runs. Adding or removing one after research marks the research and draft stale.',
1859
+ ].join('\n'),
1860
+ repurpose: [
1861
+ 'Usage: coauthor repurpose list <project-id> [--json]',
1862
+ ' coauthor repurpose generate <project-id> --format <x-thread|x-post|linkedin|facebook|email|all> [--writing-model <id>] [--json]',
1863
+ ' coauthor repurpose show <project-id> --format <format> [--json]',
1864
+ ' coauthor repurpose save <project-id> --format <format> --data @edits.json [--json]',
1865
+ ' coauthor repurpose download <project-id> [--format <format|article|all>] [--out <dir>]',
1866
+ '',
1867
+ 'Turns the finished draft into social posts and an email newsletter. generate takes about 20-90 seconds per format and replaces the previous version.',
1868
+ 'show returns data.copy (copy-ready text with the destination link filled in). download writes article.md, <format>.md, <format>.json, and manifest.json.',
1869
+ 'Slideshows and videos are generated in the web app; download includes them only as JSON once they exist. Publish an X thread with coauthor publish thread.',
1870
+ ].join('\n'),
1648
1871
  brief: [
1649
1872
  'Usage: coauthor brief review <project-id> [--json]',
1650
1873
  ' coauthor brief answer <project-id> --data @answers.json [--force] [--json]',
package/dist/parser.js CHANGED
@@ -67,6 +67,8 @@ const OPTIONS = {
67
67
  instruction: { type: 'string' },
68
68
  scope: { type: 'string' },
69
69
  feedback: { type: 'string' },
70
+ profile: { type: 'string' },
71
+ out: { type: 'string' },
70
72
  kind: { type: 'string' },
71
73
  apply: { type: 'boolean', default: false },
72
74
  accept: { type: 'string' },
@@ -148,6 +150,12 @@ function commandLength(positionals) {
148
150
  return second && ['review', 'answer'].includes(second) ? 2 : 1;
149
151
  if (first === 'log')
150
152
  return second && ['add', 'show'].includes(second) ? 2 : 1;
153
+ if (first === 'profile')
154
+ return second && ['list', 'show'].includes(second) ? 2 : 1;
155
+ if (first === 'integrations')
156
+ return second === 'list' ? 2 : 1;
157
+ if (first === 'source')
158
+ return second && ['list', 'add', 'remove'].includes(second) ? 2 : 1;
151
159
  if (first === 'skills')
152
160
  return second && ['list', 'install'].includes(second) ? 2 : 1;
153
161
  if (first === 'models')
@@ -156,6 +164,8 @@ function commandLength(positionals) {
156
164
  : 1;
157
165
  if (first === 'workflow')
158
166
  return second ? 2 : 1;
167
+ if (first === 'repurpose')
168
+ return second && ['list', 'show', 'generate', 'save', 'download'].includes(second) ? 2 : 1;
159
169
  if (first === 'draft' && second === 'revision')
160
170
  return positionals[2] && ['show', 'apply', 'discard'].includes(positionals[2]) ? 3 : 2;
161
171
  if (first === 'credits')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickminded/coauthor-cli",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "coauthor": "dist/index.js",
@@ -29,7 +29,9 @@ You drive it with the `coauthor` CLI. CoAuthor does the writing. **You are the u
29
29
  Typical timing: brief and outline under a minute; research and draft 3–10 minutes (deep research can take 20+); images about 20 seconds each; a revision 15–40 seconds. A typical article uses about 300 credits.
30
30
 
31
31
  1. **Brief.** Gather topic, audience, angle, core promise, length, must-include points, and sources from the conversation and your context (the repo, docs, the user's site). Ask the user only what you cannot infer, in one message of at most 2–3 questions. Write the contract to a file (schema, field guide, and examples: `references/brief-and-contract.md`), then:
32
- `coauthor project create --title "..." --contract @brief.json --json` → `data.project.id`
32
+ `coauthor project create --title "..." --contract @brief.json --profile <profile id> --json` → `data.project.id`
33
+ **Profile first.** A writer profile carries the voice, writer and business context, and image style, and a project keeps its profile for good. Run `coauthor profile list --json`. With one profile, omit `--profile`. With several, pick the one that fits the request (for example the company blog vs a personal newsletter) and ask the user if it isn't clear.
34
+ **Sources.** If the user gave you documents to work from (PDF, .txt, .md), add each before research: `coauthor source add <id> <file> --json` (up to 5; see `references/brief-and-contract.md`). Put source URLs in the brief instead.
33
35
  2. **Brief review.** `coauthor brief review <id> --json`. CoAuthor critiques the brief and returns `data.verdict`, `data.concerns`, and `data.questions`, each with `why`, the `field` it changes, and `answerable_by`. Answer the `agent` questions from your context; take `human` ones (opinions, private business facts, numbers, risk tolerance) to the user in one message, or, if they asked not to be interrupted, answer them as assumptions. Write `{"answers":[{"question","answer","source":"agent|user|assumption"}]}` to a file (add `"apply_suggested_patch": <data.suggested_patch>` if its suggestions are good) and run `coauthor brief answer <id> --data @answers.json --json`. Repeat once if the verdict was `needs_answers`, then approve: `coauthor contract approve <id> --json`. Log what you assumed: `coauthor log add <id> --kind assumption --message "..." --json`.
34
36
  3. **Outline checkpoint.** `coauthor outline generate <id> --json` (this does not approve it; sections are in `data.sections`). Review it as the user's editor: every section serves the core promise, must-includes are covered, the order builds, nothing is generic, repeated, or unsupported. Find problems; a bare approval is the exception. Send all your changes in one request: `coauthor outline revise <id> --feedback "Merge sections 3 and 4. Replace the conclusion with a one-week checklist." --json`. It saves the revision and returns `data.diff` (added, removed, renamed, changed, reordered); check the diff matches what you asked, and revise again (at most twice) if not. For exact wording you already have, `coauthor outline save <id> --data @outline.json --json` with the complete `{"sections":[...]}` instead. Then `coauthor outline approve <id> --json` and log it (`coauthor log add <id> --message "Approved the outline after …" --json`). If the user asked to see the outline, show it to them here and wait.
35
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.
@@ -37,7 +39,7 @@ Typical timing: brief and outline under a minute; research and draft 3–10 minu
37
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.
38
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`.
39
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`.
40
- 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, WordPress export, or X thread (`references/publishing-and-export.md`).
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`).
41
43
 
42
44
  ## When something stops
43
45
 
@@ -60,4 +62,4 @@ Everything else, including auth problems: `references/troubleshooting.md`. Credi
60
62
 
61
63
  ## Not in the CLI yet
62
64
 
63
- Choosing a writer profile (projects use the profile most recently selected in the web app), uploading source documents (put URLs in the brief instead), adding more images than CoAuthor planned, LinkedIn, Facebook, and email versions, slideshows, and video. Point the user to the CoAuthor web app at https://tools.clickminded.com/coauthor for these instead of improvising.
65
+ 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.
@@ -10,6 +10,12 @@ coauthor project create --title "Working title" --contract @brief.json --json
10
10
 
11
11
  All fields are optional and omitted ones get defaults, but always include at least `topic`, `target_audience`, `core_promise`, and either `angle` or `additional_editorial_guidance`. `--topic` and `--audience` flags fill those fields when the contract leaves them empty. Keep `--topic` plain prose; never put JSON in it.
12
12
 
13
+ ## Profiles and source documents
14
+
15
+ - `coauthor profile list --json` shows the user's writer profiles: `is_default` marks the one new projects get without `--profile`, plus a `summary` and the `visual_style`. `coauthor profile show <profile id> --json` shows the voice, writer context, and business context in full. Pass `--profile <id>` to `project create`; the profile can't be changed later, so pick deliberately. Profiles are created and edited in the web app (`manage_url`).
16
+ - `coauthor source add <id> <file>` uploads a reference document CoAuthor's research reads (PDF up to about 3.3 MB through the CLI, .txt or .md up to 512 KB, 5 per project). `coauthor source list <id> --json` shows them; `coauthor source remove <id> <source id> --yes` deletes one.
17
+ - Add sources before research runs. Adding or removing one after research marks the research and draft stale (the output says `research_invalidated`), so research has to run again.
18
+
13
19
  ## Writing a sharp brief
14
20
 
15
21
  - **Angle over topic.** "Google Business Profile descriptions" is a topic. "Most descriptions fail Google's rules in the first sentence; here is a 20-minute fix" is an angle. Push for the specific claim the piece will make.
@@ -25,4 +25,4 @@ Images cost credits each time they are generated or edited, so check the brief a
25
25
 
26
26
  ## Other formats
27
27
 
28
- LinkedIn, Facebook, and email newsletter versions, carousel slideshows, and short videos are generated in the CoAuthor web app (open the project and use Promote). The CLI cannot create them yet.
28
+ X posts, LinkedIn, Facebook, and email newsletter versions: see `references/repurposing.md`. Carousel slideshows and short videos are generated in the CoAuthor web app (open the project, then Promote).
@@ -22,7 +22,7 @@ Export creates a **draft post** in the user's WordPress site (it is not publishe
22
22
  1. The token needs publish permission. If an export fails with `insufficient_scope`, have the user run `coauthor auth login --with-publish` (in the background with `--no-browser`; they approve in the browser).
23
23
  2. With the user's yes:
24
24
  `coauthor export wordpress <id> --yes --slug <url-slug> --json`
25
- 3. If they have several WordPress sites connected, the error `wordpress_connection_required` lists them in `details.connections` (`id`, `label`, `site_base_url`). Ask which one, then add `--connection-id <id>`.
25
+ 3. `coauthor integrations list --json` shows the connected WordPress sites (`id`, `label`, `site_base_url`, `enabled`) and X accounts. With several sites, ask which one and add `--connection-id <id>` (the error `wordpress_connection_required` lists them too).
26
26
  4. `wordpress_not_connected` means no site is connected yet. The user connects one in CoAuthor's settings (Publishing).
27
27
  5. Give the user `wordpress_edit_url` from the response (also `wordpress_link`) so they can review and publish the post in WordPress.
28
28
 
@@ -0,0 +1,56 @@
1
+ # Repurposing: social posts and an email newsletter
2
+
3
+ Once the draft is final, CoAuthor turns it into distribution copy in the project's voice.
4
+
5
+ | Format | `--format` | What you get |
6
+ | --- | --- | --- |
7
+ | X thread | `x-thread` | A numbered thread linking back to the article |
8
+ | X post | `x-post` | Variations, each a main post plus a link reply, with alternate hooks |
9
+ | LinkedIn post | `linkedin` | Variations with alternate hooks |
10
+ | Facebook post | `facebook` | Variations with alternate hooks |
11
+ | Email newsletter | `email` | Variations with subject line, preheader, and body |
12
+
13
+ Slideshows (carousels) and short videos are generated in the CoAuthor web app (open the project, then Promote). `repurpose download` includes them as JSON once they exist.
14
+
15
+ ## Generate
16
+
17
+ ```sh
18
+ coauthor repurpose generate <id> --format linkedin --json # one format, about 20-90 seconds
19
+ coauthor repurpose generate <id> --format all --json # all five text formats, in turn
20
+ ```
21
+
22
+ - Generate only after the draft is final. Regenerating replaces the previous version of that format.
23
+ - The full set costs roughly 100-150 credits on top of the article.
24
+ - `coauthor repurpose list <id> --json` shows which formats exist and which are `stale` (the draft changed since they were made). Regenerate stale ones before anyone posts them.
25
+
26
+ ## Review
27
+
28
+ `coauthor repurpose show <id> --format <format> --json` returns:
29
+ - `data.copy`: copy-ready text, with the article link filled in exactly as the web app's Copy button produces it
30
+ - `data.artifact`: the stored version with ids, used for edits
31
+
32
+ Review every variation against the brief and the article: claims must match the article, the voice must match the profile, and there must be no invented numbers.
33
+
34
+ ## Edit
35
+
36
+ Save edits with the stored ids (`data.artifact.variations[].id`):
37
+
38
+ ```sh
39
+ coauthor repurpose save <id> --format linkedin --data '{"variation_id":"<id>","post_text":"..."}' --json
40
+ coauthor repurpose save <id> --format email --data '{"variation_id":"<id>","subject_line":"...","preheader":"...","body_text":"..."}' --json
41
+ coauthor repurpose save <id> --format x-post --data '{"variation_id":"<id>","posts":[<main>,<link_reply>]}' --json # exactly the 2 posts from the artifact, edited
42
+ coauthor repurpose save <id> --format x-thread --data '{"posts":[...]}' --json
43
+ ```
44
+
45
+ Add `"destination_url": "https://..."` to point the posts at the published article. Keep the `{{POST_URL}}` placeholder in stored text; it is replaced with the destination URL on copy.
46
+
47
+ ## Deliver
48
+
49
+ `coauthor repurpose download <id> --out <dir>` writes:
50
+ - `article.md` (with its title)
51
+ - `<format>.md` with copy-ready text and `<format>.json` for each format that exists
52
+ - `manifest.json` (stale flags)
53
+
54
+ Hand the user the folder, or paste from `data.copy`.
55
+
56
+ Only X can be posted directly. A thread posts with `coauthor publish thread <id> --yes` after the user's explicit OK. LinkedIn, Facebook, and email are copy-and-paste.
@@ -31,7 +31,9 @@ You drive it with the `coauthor` CLI. CoAuthor does the writing. **You are the u
31
31
  Typical timing: brief and outline under a minute; research and draft 3–10 minutes (deep research can take 20+); images about 20 seconds each; a revision 15–40 seconds. A typical article uses about 300 credits.
32
32
 
33
33
  1. **Brief.** Gather topic, audience, angle, core promise, length, must-include points, and sources from the conversation and your context (the repo, docs, the user's site). Ask the user only what you cannot infer, in one message of at most 2–3 questions. Write the contract to a file (schema, field guide, and examples: `references/brief-and-contract.md`), then:
34
- `coauthor project create --title "..." --contract @brief.json --json` → `data.project.id`
34
+ `coauthor project create --title "..." --contract @brief.json --profile <profile id> --json` → `data.project.id`
35
+ **Profile first.** A writer profile carries the voice, writer and business context, and image style, and a project keeps its profile for good. Run `coauthor profile list --json`. With one profile, omit `--profile`. With several, pick the one that fits the request (for example the company blog vs a personal newsletter) and ask the user if it isn't clear.
36
+ **Sources.** If the user gave you documents to work from (PDF, .txt, .md), add each before research: `coauthor source add <id> <file> --json` (up to 5; see `references/brief-and-contract.md`). Put source URLs in the brief instead.
35
37
  2. **Brief review.** `coauthor brief review <id> --json`. CoAuthor critiques the brief and returns `data.verdict`, `data.concerns`, and `data.questions`, each with `why`, the `field` it changes, and `answerable_by`. Answer the `agent` questions from your context; take `human` ones (opinions, private business facts, numbers, risk tolerance) to the user in one message, or, if they asked not to be interrupted, answer them as assumptions. Write `{"answers":[{"question","answer","source":"agent|user|assumption"}]}` to a file (add `"apply_suggested_patch": <data.suggested_patch>` if its suggestions are good) and run `coauthor brief answer <id> --data @answers.json --json`. Repeat once if the verdict was `needs_answers`, then approve: `coauthor contract approve <id> --json`. Log what you assumed: `coauthor log add <id> --kind assumption --message "..." --json`.
36
38
  3. **Outline checkpoint.** `coauthor outline generate <id> --json` (this does not approve it; sections are in `data.sections`). Review it as the user's editor: every section serves the core promise, must-includes are covered, the order builds, nothing is generic, repeated, or unsupported. Find problems; a bare approval is the exception. Send all your changes in one request: `coauthor outline revise <id> --feedback "Merge sections 3 and 4. Replace the conclusion with a one-week checklist." --json`. It saves the revision and returns `data.diff` (added, removed, renamed, changed, reordered); check the diff matches what you asked, and revise again (at most twice) if not. For exact wording you already have, `coauthor outline save <id> --data @outline.json --json` with the complete `{"sections":[...]}` instead. Then `coauthor outline approve <id> --json` and log it (`coauthor log add <id> --message "Approved the outline after …" --json`). If the user asked to see the outline, show it to them here and wait.
37
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.
@@ -39,7 +41,7 @@ Typical timing: brief and outline under a minute; research and draft 3–10 minu
39
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.
40
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`.
41
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`.
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, WordPress export, or X thread (`references/publishing-and-export.md`).
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`).
43
45
 
44
46
  ## When something stops
45
47
 
@@ -62,7 +64,7 @@ Everything else, including auth problems: `references/troubleshooting.md`. Credi
62
64
 
63
65
  ## Not in the CLI yet
64
66
 
65
- Choosing a writer profile (projects use the profile most recently selected in the web app), uploading source documents (put URLs in the brief instead), adding more images than CoAuthor planned, LinkedIn, Facebook, and email versions, slideshows, and video. Point the user to the CoAuthor web app at https://tools.clickminded.com/coauthor for these instead of improvising.
67
+ 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.
66
68
 
67
69
  # Reference sections
68
70
 
@@ -82,6 +84,12 @@ coauthor project create --title "Working title" --contract @brief.json --json
82
84
 
83
85
  All fields are optional and omitted ones get defaults, but always include at least `topic`, `target_audience`, `core_promise`, and either `angle` or `additional_editorial_guidance`. `--topic` and `--audience` flags fill those fields when the contract leaves them empty. Keep `--topic` plain prose; never put JSON in it.
84
86
 
87
+ ### Profiles and source documents
88
+
89
+ - `coauthor profile list --json` shows the user's writer profiles: `is_default` marks the one new projects get without `--profile`, plus a `summary` and the `visual_style`. `coauthor profile show <profile id> --json` shows the voice, writer context, and business context in full. Pass `--profile <id>` to `project create`; the profile can't be changed later, so pick deliberately. Profiles are created and edited in the web app (`manage_url`).
90
+ - `coauthor source add <id> <file>` uploads a reference document CoAuthor's research reads (PDF up to about 3.3 MB through the CLI, .txt or .md up to 512 KB, 5 per project). `coauthor source list <id> --json` shows them; `coauthor source remove <id> <source id> --yes` deletes one.
91
+ - Add sources before research runs. Adding or removing one after research marks the research and draft stale (the output says `research_invalidated`), so research has to run again.
92
+
85
93
  ### Writing a sharp brief
86
94
 
87
95
  - **Angle over topic.** "Google Business Profile descriptions" is a topic. "Most descriptions fail Google's rules in the first sentence; here is a 20-minute fix" is an angle. Push for the specific claim the piece will make.
@@ -342,7 +350,7 @@ Images cost credits each time they are generated or edited, so check the brief a
342
350
 
343
351
  ### Other formats
344
352
 
345
- LinkedIn, Facebook, and email newsletter versions, carousel slideshows, and short videos are generated in the CoAuthor web app (open the project and use Promote). The CLI cannot create them yet.
353
+ X posts, LinkedIn, Facebook, and email newsletter versions: see `references/repurposing.md`. Carousel slideshows and short videos are generated in the CoAuthor web app (open the project, then Promote).
346
354
 
347
355
  ## references/publishing-and-export.md
348
356
 
@@ -370,7 +378,7 @@ Export creates a **draft post** in the user's WordPress site (it is not publishe
370
378
  1. The token needs publish permission. If an export fails with `insufficient_scope`, have the user run `coauthor auth login --with-publish` (in the background with `--no-browser`; they approve in the browser).
371
379
  2. With the user's yes:
372
380
  `coauthor export wordpress <id> --yes --slug <url-slug> --json`
373
- 3. If they have several WordPress sites connected, the error `wordpress_connection_required` lists them in `details.connections` (`id`, `label`, `site_base_url`). Ask which one, then add `--connection-id <id>`.
381
+ 3. `coauthor integrations list --json` shows the connected WordPress sites (`id`, `label`, `site_base_url`, `enabled`) and X accounts. With several sites, ask which one and add `--connection-id <id>` (the error `wordpress_connection_required` lists them too).
374
382
  4. `wordpress_not_connected` means no site is connected yet. The user connects one in CoAuthor's settings (Publishing).
375
383
  5. Give the user `wordpress_edit_url` from the response (also `wordpress_link`) so they can review and publish the post in WordPress.
376
384
 
@@ -384,6 +392,65 @@ See `references/images-and-social.md`. Publishing a thread posts immediately and
384
392
 
385
393
  After a network error or an unclear result on an export or publish, do not run it again straight away. Check `coauthor operation list --json` for the operation and its status first, then decide.
386
394
 
395
+ ## references/repurposing.md
396
+
397
+ ## Repurposing: social posts and an email newsletter
398
+
399
+ Once the draft is final, CoAuthor turns it into distribution copy in the project's voice.
400
+
401
+ | Format | `--format` | What you get |
402
+ | --- | --- | --- |
403
+ | X thread | `x-thread` | A numbered thread linking back to the article |
404
+ | X post | `x-post` | Variations, each a main post plus a link reply, with alternate hooks |
405
+ | LinkedIn post | `linkedin` | Variations with alternate hooks |
406
+ | Facebook post | `facebook` | Variations with alternate hooks |
407
+ | Email newsletter | `email` | Variations with subject line, preheader, and body |
408
+
409
+ Slideshows (carousels) and short videos are generated in the CoAuthor web app (open the project, then Promote). `repurpose download` includes them as JSON once they exist.
410
+
411
+ ### Generate
412
+
413
+ ```sh
414
+ coauthor repurpose generate <id> --format linkedin --json # one format, about 20-90 seconds
415
+ coauthor repurpose generate <id> --format all --json # all five text formats, in turn
416
+ ```
417
+
418
+ - Generate only after the draft is final. Regenerating replaces the previous version of that format.
419
+ - The full set costs roughly 100-150 credits on top of the article.
420
+ - `coauthor repurpose list <id> --json` shows which formats exist and which are `stale` (the draft changed since they were made). Regenerate stale ones before anyone posts them.
421
+
422
+ ### Review
423
+
424
+ `coauthor repurpose show <id> --format <format> --json` returns:
425
+ - `data.copy`: copy-ready text, with the article link filled in exactly as the web app's Copy button produces it
426
+ - `data.artifact`: the stored version with ids, used for edits
427
+
428
+ Review every variation against the brief and the article: claims must match the article, the voice must match the profile, and there must be no invented numbers.
429
+
430
+ ### Edit
431
+
432
+ Save edits with the stored ids (`data.artifact.variations[].id`):
433
+
434
+ ```sh
435
+ coauthor repurpose save <id> --format linkedin --data '{"variation_id":"<id>","post_text":"..."}' --json
436
+ coauthor repurpose save <id> --format email --data '{"variation_id":"<id>","subject_line":"...","preheader":"...","body_text":"..."}' --json
437
+ coauthor repurpose save <id> --format x-post --data '{"variation_id":"<id>","posts":[<main>,<link_reply>]}' --json # exactly the 2 posts from the artifact, edited
438
+ coauthor repurpose save <id> --format x-thread --data '{"posts":[...]}' --json
439
+ ```
440
+
441
+ Add `"destination_url": "https://..."` to point the posts at the published article. Keep the `{{POST_URL}}` placeholder in stored text; it is replaced with the destination URL on copy.
442
+
443
+ ### Deliver
444
+
445
+ `coauthor repurpose download <id> --out <dir>` writes:
446
+ - `article.md` (with its title)
447
+ - `<format>.md` with copy-ready text and `<format>.json` for each format that exists
448
+ - `manifest.json` (stale flags)
449
+
450
+ Hand the user the folder, or paste from `data.copy`.
451
+
452
+ Only X can be posted directly. A thread posts with `coauthor publish thread <id> --yes` after the user's explicit OK. LinkedIn, Facebook, and email are copy-and-paste.
453
+
387
454
  ## references/troubleshooting.md
388
455
 
389
456
  ## Troubleshooting