@clickminded/coauthor-cli 0.0.27 → 0.0.29
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,34 @@ 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
|
-
|
|
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 === 'duplicate') {
|
|
248
|
+
const projectId = requireProjectId(input);
|
|
249
|
+
const title = getString(input.values, 'title');
|
|
250
|
+
const data = await client.request({
|
|
251
|
+
method: 'POST',
|
|
252
|
+
path: `projects/${encodeURIComponent(projectId)}/duplicate`,
|
|
253
|
+
body: title !== undefined && title.trim() ? { title } : {},
|
|
254
|
+
});
|
|
255
|
+
const newId = data.project?.id;
|
|
256
|
+
return { ok: true, message: newId ? `Duplicated project ${projectId} as ${newId}${data.project?.title ? ` ("${data.project.title}")` : ''}.` : `Duplicated project ${projectId}.`, data };
|
|
257
|
+
}
|
|
258
|
+
if (action === 'delete') {
|
|
259
|
+
const projectId = requireProjectId(input);
|
|
260
|
+
if (!getBoolean(input.values, 'yes')) {
|
|
261
|
+
throw new Error('Deleting a project removes its brief, outline, research, draft, images, and social posts permanently. Re-run with --yes to confirm.');
|
|
262
|
+
}
|
|
263
|
+
const data = await client.request({ method: 'DELETE', path: `projects/${encodeURIComponent(projectId)}` });
|
|
264
|
+
return { ok: true, message: `Deleted project ${projectId}.`, data };
|
|
265
|
+
}
|
|
266
|
+
throw new Error('Usage: coauthor project <create|list|show|rename|delete|duplicate>');
|
|
240
267
|
}
|
|
241
268
|
async function runWorkspaceCommand(action, input, client) {
|
|
242
269
|
if (action !== 'show')
|
|
@@ -665,6 +692,11 @@ async function runResourceCommand(resource, action, input, client) {
|
|
|
665
692
|
const data = await client.request({ method: 'POST', path: `${basePath}/${action}`, body });
|
|
666
693
|
return { ok: true, data };
|
|
667
694
|
}
|
|
695
|
+
if (resource === 'images' && action === 'generate' && getBoolean(input.values, 'all')) {
|
|
696
|
+
if (!projectId)
|
|
697
|
+
throw new Error('Usage: coauthor image generate <project-id> --all [--wait]');
|
|
698
|
+
return generateAllImages(client, projectId, getBoolean(input.values, 'wait'));
|
|
699
|
+
}
|
|
668
700
|
if (resource === 'images' && action === 'metadata') {
|
|
669
701
|
if (!projectId)
|
|
670
702
|
throw new Error('Missing project id for image metadata');
|
|
@@ -1581,6 +1613,67 @@ function renderRepurposeMarkdown(format, copy) {
|
|
|
1581
1613
|
}
|
|
1582
1614
|
return lines.join('\n');
|
|
1583
1615
|
}
|
|
1616
|
+
function imageStatusRows(data) {
|
|
1617
|
+
const placeholders = getResponseValue(data, 'placeholders');
|
|
1618
|
+
if (!Array.isArray(placeholders))
|
|
1619
|
+
return [];
|
|
1620
|
+
return placeholders.flatMap((placeholder) => {
|
|
1621
|
+
if (!placeholder || typeof placeholder !== 'object' || Array.isArray(placeholder))
|
|
1622
|
+
return [];
|
|
1623
|
+
const id = placeholder.id;
|
|
1624
|
+
const latest = placeholder.latest_image;
|
|
1625
|
+
const status = latest && typeof latest === 'object' && !Array.isArray(latest) && typeof latest.status === 'string' ? latest.status : null;
|
|
1626
|
+
return typeof id === 'string' ? [{ id, status }] : [];
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
// Generates every planned image that isn't already done or generating, then
|
|
1630
|
+
// optionally waits (under the 10-minute agent shell limit) until none are
|
|
1631
|
+
// still generating.
|
|
1632
|
+
async function generateAllImages(client, projectId, wait) {
|
|
1633
|
+
const statusPath = `projects/${encodeURIComponent(projectId)}/images/status`;
|
|
1634
|
+
const before = imageStatusRows(await client.request({ path: statusPath }));
|
|
1635
|
+
const toGenerate = before.filter((row) => row.status !== 'done' && row.status !== 'generating');
|
|
1636
|
+
const started = [];
|
|
1637
|
+
const failedToStart = [];
|
|
1638
|
+
for (const row of toGenerate) {
|
|
1639
|
+
try {
|
|
1640
|
+
await client.request({ method: 'POST', path: `projects/${encodeURIComponent(projectId)}/images/generate`, body: { placeholderId: row.id } });
|
|
1641
|
+
started.push(row.id);
|
|
1642
|
+
}
|
|
1643
|
+
catch (error) {
|
|
1644
|
+
failedToStart.push({ id: row.id, error: error instanceof Error ? error.message : String(error) });
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
let rows = before;
|
|
1648
|
+
if (wait && (started.length > 0 || before.some((row) => row.status === 'generating'))) {
|
|
1649
|
+
const deadline = Date.now() + waitTimeoutMs(9 * 60_000);
|
|
1650
|
+
const pollMs = Math.max(waitPollMs(), 0);
|
|
1651
|
+
do {
|
|
1652
|
+
await sleep(Math.min(pollMs, 15_000));
|
|
1653
|
+
rows = imageStatusRows(await client.request({ path: statusPath }));
|
|
1654
|
+
} while (rows.some((row) => row.status === 'generating') && Date.now() < deadline);
|
|
1655
|
+
}
|
|
1656
|
+
const count = (status) => rows.filter((row) => row.status === status).length;
|
|
1657
|
+
const generating = wait ? count('generating') : started.length + count('generating');
|
|
1658
|
+
const summary = {
|
|
1659
|
+
placeholders: before.length,
|
|
1660
|
+
started: started.length,
|
|
1661
|
+
already_done: before.filter((row) => row.status === 'done').length,
|
|
1662
|
+
done: wait ? count('done') : null,
|
|
1663
|
+
failed: wait ? count('failed') : null,
|
|
1664
|
+
generating,
|
|
1665
|
+
failed_to_start: failedToStart,
|
|
1666
|
+
};
|
|
1667
|
+
return {
|
|
1668
|
+
ok: failedToStart.length === 0 && (!wait || count('failed') === 0),
|
|
1669
|
+
status: wait && generating > 0 ? 'still_running' : undefined,
|
|
1670
|
+
exitCode: wait && generating > 0 ? 2 : undefined,
|
|
1671
|
+
message: wait
|
|
1672
|
+
? `Images: ${count('done')} done, ${count('failed')} failed, ${generating} still generating.${generating > 0 ? ` Check again with: coauthor image status ${projectId} --json` : ''}`
|
|
1673
|
+
: `Started ${started.length} image${started.length === 1 ? '' : 's'}. Check progress with: coauthor image status ${projectId} --json`,
|
|
1674
|
+
data: summary,
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1584
1677
|
function enrichResearchStatus(data) {
|
|
1585
1678
|
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
1586
1679
|
return data;
|
|
@@ -1756,7 +1849,7 @@ export function helpResult(command = []) {
|
|
|
1756
1849
|
'',
|
|
1757
1850
|
'Commands:',
|
|
1758
1851
|
' auth login|status|logout (logout supports --local-only)',
|
|
1759
|
-
' project create|list|show',
|
|
1852
|
+
' project create|list|show|rename|delete|duplicate',
|
|
1760
1853
|
' workspace show',
|
|
1761
1854
|
' chat [show|list]',
|
|
1762
1855
|
' contract show|save|approve',
|
|
@@ -1797,6 +1890,11 @@ function commandHelp(command) {
|
|
|
1797
1890
|
'Revokes the remote token before removing local credentials. If revocation cannot be confirmed, the token is kept locally so the command can be retried.',
|
|
1798
1891
|
'--local-only removes the local credential without revoking the remote token. Use it only when explicitly abandoning remote revocation.',
|
|
1799
1892
|
].join('\n'),
|
|
1893
|
+
'project duplicate': [
|
|
1894
|
+
'Usage: coauthor project duplicate <project-id> [--title "..."] [--json]',
|
|
1895
|
+
'',
|
|
1896
|
+
'Copies the brief, outline, research, chats, draft, images and repurposed posts into a new project that keeps the same profile. The default title is "<title> (Copy)". Prints the new project id.',
|
|
1897
|
+
].join('\n'),
|
|
1800
1898
|
'project create': [
|
|
1801
1899
|
'Usage: coauthor project create [--title <title>] [--topic <brief>] [--audience <audience>] [--contract <json>] [--profile <profile-id>] [--json]',
|
|
1802
1900
|
'',
|
|
@@ -1841,9 +1939,10 @@ function commandHelp(command) {
|
|
|
1841
1939
|
DRAFT_SAVE_SHAPE,
|
|
1842
1940
|
].join('\n'),
|
|
1843
1941
|
project: [
|
|
1844
|
-
'Usage: coauthor project <create|list|show> [<project-id>] [--json]',
|
|
1942
|
+
'Usage: coauthor project <create|list|show|rename|delete|duplicate> [<project-id>] [--title "..."] [--yes] [--json]',
|
|
1845
1943
|
'',
|
|
1846
1944
|
'create: --title, --topic, --audience, --contract <json|@file>. list: --limit. show: one project.',
|
|
1945
|
+
'duplicate <project-id> [--title "..."]: copies the brief, outline, research, chats, draft, images and repurposed posts into a new project that keeps the same profile (default title is "<title> (Copy)"). Prints the new project id.',
|
|
1847
1946
|
].join('\n'),
|
|
1848
1947
|
profile: [
|
|
1849
1948
|
'Usage: coauthor profile list [--json]',
|
|
@@ -1923,6 +2022,7 @@ function commandHelp(command) {
|
|
|
1923
2022
|
].join('\n'),
|
|
1924
2023
|
image: [
|
|
1925
2024
|
'Usage: coauthor image <list|status|show|generate|edit|metadata> <project-id> [...] [--json]',
|
|
2025
|
+
' coauthor image generate <project-id> --all [--wait] [--json] (every planned image; --wait until they finish)',
|
|
1926
2026
|
'',
|
|
1927
2027
|
'list: planned placeholders (use each id). generate/edit: --placeholder-id <id> [--edit-prompt "..."]. status: generation progress.',
|
|
1928
2028
|
'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', 'duplicate'].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
package/skills/coauthor/SKILL.md
CHANGED
|
@@ -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
|
|
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 duplicate <id> [--title "..."]` copies it with its brief, outline, research, draft, images, and posts (keeping its profile), for example to try a different angle without losing the original. `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
|
|
9
|
-
3.
|
|
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
|
|
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 duplicate <id> [--title "..."]` copies it with its brief, outline, research, draft, images, and posts (keeping its profile), for example to try a different angle without losing the original. `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
|
|
334
|
-
3.
|
|
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.
|