@clickminded/coauthor-cli 0.0.67 → 0.0.68

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
@@ -82,6 +82,7 @@ coauthor post-details show <id> --json # SEO title, meta
82
82
  coauthor post-details set <id> --seo-title "..." --json # exports use these as defaults
83
83
  coauthor post-details set <id> --live-url https://example.com/post/ # where the post is live (--clear-live-url removes it)
84
84
  coauthor draft get <id> --format markdown --frontmatter --json # markdown with YAML frontmatter
85
+ coauthor draft get <id> --format markdown --widgets embed --json # interactives as live iframes, for a site you control
85
86
  coauthor export wordpress <id> --yes --json # creates a WordPress draft post (--slug to override)
86
87
  coauthor credits <id> --json
87
88
  coauthor integrations list --json # WordPress sites and X accounts
package/dist/commands.js CHANGED
@@ -631,11 +631,21 @@ async function runDraftCommand(action, input, context) {
631
631
  if (frontmatter && format?.trim().toLowerCase() !== 'markdown') {
632
632
  throw new Error('--frontmatter only applies to --format markdown.');
633
633
  }
634
+ const widgets = getString(input.values, 'widgets')?.trim().toLowerCase();
635
+ if (widgets !== undefined) {
636
+ if (!['image', 'embed'].includes(widgets))
637
+ throw new Error(`--widgets must be image or embed (got "${widgets}").`);
638
+ if (!['markdown', 'html'].includes(format?.trim().toLowerCase() ?? '')) {
639
+ throw new Error('--widgets only applies to --format markdown or html.');
640
+ }
641
+ }
634
642
  const query = new URLSearchParams();
635
643
  if (format)
636
644
  query.set('format', format);
637
645
  if (frontmatter)
638
646
  query.set('frontmatter', '1');
647
+ if (widgets)
648
+ query.set('widgets', widgets);
639
649
  const suffix = query.toString();
640
650
  const data = await client.request({ path: suffix ? `${basePath}/get?${suffix}` : `${basePath}/get` });
641
651
  return { ok: true, data };
@@ -1964,7 +1974,7 @@ function widgetStateLabel(widget) {
1964
1974
  function widgetSpec(widget) {
1965
1975
  return widget.spec && typeof widget.spec === 'object' && !Array.isArray(widget.spec) ? widget.spec : {};
1966
1976
  }
1967
- function describeWidget(widget) {
1977
+ function describeWidget(widget, options = {}) {
1968
1978
  const spec = widgetSpec(widget);
1969
1979
  const lines = [
1970
1980
  `${String(widget.id)} ${String(spec.title ?? '(untitled)')} [${widgetStateLabel(widget)}]`,
@@ -1975,6 +1985,9 @@ function describeWidget(widget) {
1975
1985
  ];
1976
1986
  if (typeof widget.embed_url === 'string')
1977
1987
  lines.push(` embed: ${widget.embed_url}`);
1988
+ if (options.embedCode && typeof widget.embed_code === 'string' && widget.embed_code) {
1989
+ lines.push(' embed code:', ...widget.embed_code.split('\n').map((line) => ` ${line}`));
1990
+ }
1978
1991
  if (widget.fact_check_warning)
1979
1992
  lines.push(` fact check: ${String(widget.fact_check_warning)}`);
1980
1993
  const error = widgetError(widget);
@@ -1989,7 +2002,7 @@ function widgetsListMessage(data) {
1989
2002
  }
1990
2003
  const model = getResponseValue(data, 'model');
1991
2004
  const placeholders = widgets.filter((widget) => widget.current_version == null && widget.build_state === 'idle').length;
1992
- const lines = widgets.map(describeWidget);
2005
+ const lines = widgets.map((widget) => describeWidget(widget, { embedCode: true }));
1993
2006
  if (model) {
1994
2007
  lines.push('', `Build model: ${String(model.label ?? model.id)}. One build spends up to ${String(model.cap)} credits (an edit up to ${String(model.edit_cap)}).`);
1995
2008
  }
@@ -2046,7 +2059,7 @@ function widgetsWaitResult(projectId, result, resumeCommand, doneWord) {
2046
2059
  }
2047
2060
  return {
2048
2061
  ok: true,
2049
- message: `${widgets.length} interactive${widgets.length === 1 ? '' : 's'} ${doneWord}.\n${widgets.map(describeWidget).join('\n')}`,
2062
+ message: `${widgets.length} interactive${widgets.length === 1 ? '' : 's'} ${doneWord}.\n${widgets.map((widget) => describeWidget(widget)).join('\n')}`,
2050
2063
  messageIncludesData: true,
2051
2064
  data,
2052
2065
  };
@@ -2088,7 +2101,7 @@ async function runWidgetsCommand(action, input, client) {
2088
2101
  const waited = await waitForWidgets(client, projectId, [id], [widget]);
2089
2102
  return widgetsWaitResult(projectId, waited, `coauthor widgets status ${projectId} ${id} --wait`, 'ready');
2090
2103
  }
2091
- return { ok: true, message: widget ? describeWidget(widget) : undefined, messageIncludesData: Boolean(widget), data };
2104
+ return { ok: true, message: widget ? describeWidget(widget, { embedCode: true }) : undefined, messageIncludesData: Boolean(widget), data };
2092
2105
  }
2093
2106
  if (action === 'build') {
2094
2107
  const id = needWidget('build');
@@ -3450,7 +3463,7 @@ export function helpResult(command = []) {
3450
3463
  ' research run|status|structured',
3451
3464
  ' draft generate|status|get|save|revise',
3452
3465
  ' draft revision show|apply|discard',
3453
- ' draft get supports --format json|markdown|html|text (--frontmatter adds post details to markdown)',
3466
+ ' draft get supports --format json|markdown|html|text (--frontmatter adds post details to markdown; --widgets embed exports interactives as live iframes)',
3454
3467
  ' post-details show|set',
3455
3468
  ' seo markets [--country <country>] [--language <language>]',
3456
3469
  ' search-brief show|set-keyword|set-mode',
@@ -3541,10 +3554,11 @@ function commandHelp(command) {
3541
3554
  '--widget-model (interactives beta) picks the model that builds interactives: claude-opus-5-5 (default) or claude-sonnet-5-5.',
3542
3555
  ].join('\n'),
3543
3556
  'draft get': [
3544
- 'Usage: coauthor draft get <project-id> [--format json|markdown|html|text] [--frontmatter] [--json]',
3557
+ 'Usage: coauthor draft get <project-id> [--format json|markdown|html|text] [--frontmatter] [--widgets image|embed] [--json]',
3545
3558
  '',
3546
3559
  'Retrieves a saved generated draft. Chat responses are available through coauthor chat show.',
3547
3560
  '--frontmatter (markdown only) prepends YAML frontmatter from the post details: title, seo_title, description, slug, excerpt, and the featured image. Posts without post details get no frontmatter.',
3561
+ '--widgets (markdown or html only) chooses how built interactives export. image (default) is the linked poster image, safe for email and newsletters. embed is the live sandboxed iframe plus one embed.js script, for a website you control (Astro, Hugo, Next, custom HTML). In markdown the iframe is a raw HTML block that is also valid MDX.',
3548
3562
  ].join('\n'),
3549
3563
  'draft save': [
3550
3564
  'Usage: coauthor draft save <project-id> --data @payload.json [--force] [--json]',
package/dist/parser.js CHANGED
@@ -60,6 +60,7 @@ const OPTIONS = {
60
60
  seo: { type: 'string' },
61
61
  'confirm-reset': { type: 'boolean', default: false },
62
62
  frontmatter: { type: 'boolean', default: false },
63
+ widgets: { type: 'string' },
63
64
  country: { type: 'string' },
64
65
  language: { type: 'string' },
65
66
  status: { type: 'string' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickminded/coauthor-cli",
3
- "version": "0.0.67",
3
+ "version": "0.0.68",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "coauthor": "dist/index.js",
@@ -27,7 +27,9 @@ coauthor models preferences set --widget-model claude-opus-5-5|claude-sonnet-5-5
27
27
  - `build-all` with no ids builds every placeholder; with ids, only those.
28
28
  - `use-image` is for a placeholder that took over a planned image (`replaces_image: true`). It turns the node in the draft back into an image placeholder (it updates the draft for you); then generate it with `coauthor image generate <project-id> --placeholder-id <placeholder-id>`. If `document_updated` is false, `document_status` says why: `already_removed` means a repeat (the swap was already done, nothing to fix); `not_updated` is a real failure and `document_note` has the manual fix. The call is safe to repeat.
29
29
  - `edit` takes a plain instruction of up to 500 characters and rebuilds the widget. `edit` and `delete` change every published copy, so both need `--yes`: confirm with the user first. `delete` removes the interactive everywhere, including posts already published, and cannot be undone. It also removes the node from the draft.
30
- - A built widget exports as its poster image linked to the live version in markdown and HTML (`draft get --format markdown`), and live in WordPress when the connection allows it.
30
+ - `status` and `list` print an `embed code:` block for each built widget (an iframe plus the one `embed.js` script, ready to paste into any page) and return it as `embed_code` in the JSON.
31
+ - By default a built widget exports as its poster image linked to the live version in markdown and HTML (`draft get --format markdown`). Add `--widgets embed` to get the live sandboxed iframe instead: `coauthor draft get <id> --format markdown --widgets embed --json` (or `--format html`). Use `embed` when publishing to a website the user controls (Astro, Hugo, Next.js, plain HTML). Keep the default image form for email, newsletters, and anywhere that strips iframes. `--widgets` only applies to `--format markdown` and `html`; `--format text` stays the caption plus the link. WordPress export chooses automatically and ignores the flag.
32
+ - The markdown embed form is a raw HTML block (`<figure class="coauthor-widget"><iframe ...></iframe></figure>`) and one `<script src="https://figurehost.com/embed.js" async></script>` at the end of the document. The attributes are valid in plain Markdown and in MDX (no inline `style`, braces in captions escaped). If the site renders its own layout and already loads `embed.js` once, delete the trailing script line to avoid loading it twice. The iframe keeps its `sandbox="allow-scripts"` and resizes itself once `embed.js` runs.
31
33
 
32
34
  ## Limitations to tell the user
33
35
 
@@ -5,6 +5,7 @@
5
5
  ```sh
6
6
  coauthor draft get <id> --format markdown --json # data.markdown, images as markdown image links
7
7
  coauthor draft get <id> --format html --json # data.html, images as <img> tags
8
+ coauthor draft get <id> --format markdown --widgets embed --json # website you control: interactives as live iframes (see interactive-widgets.md)
8
9
  coauthor draft get <id> --format text --json # data.text, plain text with image URLs
9
10
  coauthor draft get <id> --format json --json # data.content, the editor document (for edits)
10
11
  ```
@@ -425,7 +425,9 @@ coauthor models preferences set --widget-model claude-opus-5-5|claude-sonnet-5-5
425
425
  - `build-all` with no ids builds every placeholder; with ids, only those.
426
426
  - `use-image` is for a placeholder that took over a planned image (`replaces_image: true`). It turns the node in the draft back into an image placeholder (it updates the draft for you); then generate it with `coauthor image generate <project-id> --placeholder-id <placeholder-id>`. If `document_updated` is false, `document_status` says why: `already_removed` means a repeat (the swap was already done, nothing to fix); `not_updated` is a real failure and `document_note` has the manual fix. The call is safe to repeat.
427
427
  - `edit` takes a plain instruction of up to 500 characters and rebuilds the widget. `edit` and `delete` change every published copy, so both need `--yes`: confirm with the user first. `delete` removes the interactive everywhere, including posts already published, and cannot be undone. It also removes the node from the draft.
428
- - A built widget exports as its poster image linked to the live version in markdown and HTML (`draft get --format markdown`), and live in WordPress when the connection allows it.
428
+ - `status` and `list` print an `embed code:` block for each built widget (an iframe plus the one `embed.js` script, ready to paste into any page) and return it as `embed_code` in the JSON.
429
+ - By default a built widget exports as its poster image linked to the live version in markdown and HTML (`draft get --format markdown`). Add `--widgets embed` to get the live sandboxed iframe instead: `coauthor draft get <id> --format markdown --widgets embed --json` (or `--format html`). Use `embed` when publishing to a website the user controls (Astro, Hugo, Next.js, plain HTML). Keep the default image form for email, newsletters, and anywhere that strips iframes. `--widgets` only applies to `--format markdown` and `html`; `--format text` stays the caption plus the link. WordPress export chooses automatically and ignores the flag.
430
+ - The markdown embed form is a raw HTML block (`<figure class="coauthor-widget"><iframe ...></iframe></figure>`) and one `<script src="https://figurehost.com/embed.js" async></script>` at the end of the document. The attributes are valid in plain Markdown and in MDX (no inline `style`, braces in captions escaped). If the site renders its own layout and already loads `embed.js` once, delete the trailing script line to avoid loading it twice. The iframe keeps its `sandbox="allow-scripts"` and resizes itself once `embed.js` runs.
429
431
 
430
432
  ### Limitations to tell the user
431
433
 
@@ -446,6 +448,7 @@ Error codes: `references/troubleshooting.md`.
446
448
  ```sh
447
449
  coauthor draft get <id> --format markdown --json # data.markdown, images as markdown image links
448
450
  coauthor draft get <id> --format html --json # data.html, images as <img> tags
451
+ coauthor draft get <id> --format markdown --widgets embed --json # website you control: interactives as live iframes (see interactive-widgets.md)
449
452
  coauthor draft get <id> --format text --json # data.text, plain text with image URLs
450
453
  coauthor draft get <id> --format json --json # data.content, the editor document (for edits)
451
454
  ```