dotshare-cli 1.0.0 → 3.0.1

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.
Files changed (57) hide show
  1. package/LICENSE +201 -21
  2. package/README.md +258 -189
  3. package/SECURITY.md +145 -0
  4. package/bin/dotshare-agent.js +7 -0
  5. package/bin/dotshare-cli.js +11 -7
  6. package/bin/dotshare-mcp.js +6 -0
  7. package/docs/AGENT_INTEGRATION.md +556 -0
  8. package/out/agent/commands.js +120 -0
  9. package/out/agent/server.js +98 -0
  10. package/out/cli/commands.js +129 -376
  11. package/package.json +34 -94
  12. package/bin/dotshare-scheduler.js +0 -208
  13. package/out/analytics.js +0 -67
  14. package/out/analytics.js.map +0 -1
  15. package/out/bluesky.js +0 -100
  16. package/out/bluesky.js.map +0 -1
  17. package/out/cli/commands.js.map +0 -1
  18. package/out/cli/config.js +0 -144
  19. package/out/cli/config.js.map +0 -1
  20. package/out/credential-provider.js +0 -92
  21. package/out/credential-provider.js.map +0 -1
  22. package/out/discord.js +0 -85
  23. package/out/discord.js.map +0 -1
  24. package/out/extension.js +0 -1383
  25. package/out/extension.js.map +0 -1
  26. package/out/facebook.js +0 -66
  27. package/out/facebook.js.map +0 -1
  28. package/out/gemini.js +0 -219
  29. package/out/gemini.js.map +0 -1
  30. package/out/linkedin.js +0 -110
  31. package/out/linkedin.js.map +0 -1
  32. package/out/message-handlers.js +0 -391
  33. package/out/message-handlers.js.map +0 -1
  34. package/out/openai.js +0 -217
  35. package/out/openai.js.map +0 -1
  36. package/out/post-executor.js +0 -168
  37. package/out/post-executor.js.map +0 -1
  38. package/out/reddit.js +0 -538
  39. package/out/reddit.js.map +0 -1
  40. package/out/scheduled-posts.js +0 -100
  41. package/out/scheduled-posts.js.map +0 -1
  42. package/out/scheduler.js +0 -98
  43. package/out/scheduler.js.map +0 -1
  44. package/out/storage-manager.js +0 -403
  45. package/out/storage-manager.js.map +0 -1
  46. package/out/telegram.js +0 -104
  47. package/out/telegram.js.map +0 -1
  48. package/out/types.js +0 -3
  49. package/out/types.js.map +0 -1
  50. package/out/webview-provider.js +0 -168
  51. package/out/webview-provider.js.map +0 -1
  52. package/out/x.js +0 -55
  53. package/out/x.js.map +0 -1
  54. package/out/xai.js +0 -235
  55. package/out/xai.js.map +0 -1
  56. package/src/cli/commands.ts +0 -380
  57. package/src/cli/config.ts +0 -148
@@ -0,0 +1,556 @@
1
+ # DotShare for AI agents
2
+
3
+ Connect Codex or another MCP client to DotShare, then ask it to publish a post,
4
+ images, a thread, or a Dev.to article to named accounts. The agent supplies content;
5
+ DotShare handles credentials, platform requests and durable publication receipts.
6
+ The local MCP server uses stdio and does not require a separate model/API key.
7
+
8
+ ## Install and set up
9
+
10
+ Requires Node.js 22.12+ and an unlocked OS credential store. On Linux, a working
11
+ Secret Service/keyring session is required. There is no plaintext secret fallback.
12
+
13
+ Install the CLI and MCP server from npm. For an existing library, follow the [upgrade steps](#local-storage-protection) before resuming publication.
14
+
15
+ ```sh
16
+ npm install -g dotshare-cli
17
+ dotshare-agent setup
18
+ dotshare-agent accounts add personal-mastodon --platform mastodon --name "Personal Mastodon"
19
+ dotshare-agent doctor --account personal-mastodon
20
+ ```
21
+
22
+ Restart or reconnect Codex after setup. In Codex, ask DotShare to list your local
23
+ accounts, save a draft for one of them and prepare its preview. To review that draft
24
+ in VS Code, follow the [Publishing Library guide](PUBLISHING_LIBRARY.md).
25
+
26
+ You can also download the tarball and install it with `npm install -g ./dotshare-cli-3.0.0.tgz`. [GitHub release](https://github.com/kareem2099/DotShare/releases/tag/v3.6.0)
27
+
28
+ To build and configure from source instead:
29
+
30
+ ```sh
31
+ npm ci
32
+ npm run compile
33
+ node bin/dotshare-agent.js setup
34
+ node bin/dotshare-agent.js doctor
35
+ node bin/dotshare-agent.js accounts add personal-mastodon --platform mastodon --name "Personal Mastodon"
36
+ node bin/dotshare-agent.js accounts add work-linkedin --platform linkedin --name "Work LinkedIn"
37
+ node bin/dotshare-agent.js accounts list
38
+ ```
39
+
40
+ Account setup prompts hide typed credentials. Enter platform secrets in your
41
+ terminal prompts. Existing VS Code accounts are not automatically copied.
42
+ Multiple accounts on one platform use
43
+ different IDs. To replace an account's credentials, run `accounts add` with its ID.
44
+ `accounts remove <id>` removes the local account and deletes its credential from the OS keyring.
45
+ It does not revoke the token on the platform. Expired/revoked platform tokens must
46
+ be replaced using `accounts add`; the local agent does not run browser OAuth or
47
+ automatically refresh user-supplied OAuth tokens.
48
+
49
+ After packaging/installing the CLI, the same commands are available through
50
+ `dotshare`, `dotshare-agent`, and the dedicated `dotshare-mcp` server entrypoint.
51
+
52
+ ### Credential fields
53
+
54
+ | Platform | Fields entered during setup |
55
+ | --- | --- |
56
+ | LinkedIn | `accessToken` (user OAuth token with posting access) |
57
+ | X | `accessToken` (user OAuth token; media also requires media upload access) |
58
+ | Telegram | `botToken`, `chatId` (the bot must be able to post in this chat/channel) |
59
+ | Discord | `webhookUrl` (HTTPS `discord.com/api/.../webhooks/...` URL) |
60
+ | Bluesky | `identifier`, `password` (use an app password) |
61
+ | Mastodon | `instance`, `accessToken` (status/media publishing scopes) |
62
+ | Dev.to | `apiKey` |
63
+
64
+ For automated local setup, `accounts add --input -` reads account JSON from stdin:
65
+ `{"id":"personal","name":"Personal","platform":"mastodon","credentials":{"instance":"https://your.instance","accessToken":"..."}}`.
66
+ Credentials are saved to the OS keyring. Only account IDs, labels and platform names
67
+ are written to `~/.dotshare/accounts.json`. Use stdin or an interactive terminal;
68
+ avoid putting credentials in command arguments or committed files.
69
+
70
+ ## Local storage protection
71
+
72
+ Linux entries require Secret Service explicitly; there is no automatic kernel-keyring
73
+ fallback. macOS/Windows use their native OS credential stores. New drafts, custom
74
+ templates and operation journals always use authenticated AES-256-GCM encryption.
75
+ The master key is generated randomly and stored in the OS keyring only; a locked,
76
+ missing or mismatched key fails closed. Restore the original OS key and security.json
77
+ instead of generating a replacement key for existing ciphertext.
78
+
79
+ To upgrade an existing installation, stop active publications and run these commands.
80
+
81
+ ```sh
82
+ npm install -g dotshare-cli
83
+ dotshare-agent security status
84
+ dotshare-agent security protect
85
+ ```
86
+
87
+ For a source checkout, substitute `node bin/dotshare-agent.js` for `dotshare-agent`.
88
+ If you switched from a source checkout to the installed package, use
89
+ `dotshare-agent setup --dry-run --replace` to review the new launcher paths.
90
+ Then run `dotshare-agent setup --replace` to replace the existing DotShare entry.
91
+ Review the media roots and include `--media-root` for any directory you want to allow.
92
+
93
+ `protect` verifies existing account access, repairs private permissions and converts
94
+ existing plaintext records in place. It verifies preserved content without making
95
+ plaintext backups. Restart all DotShare MCP clients and VS Code windows afterwards,
96
+ then run `dotshare-agent doctor --check-accounts`. Prior snapshots and backups may
97
+ still contain plaintext; the migration does not securely erase old disk pages.
98
+
99
+ Credential JSON input files must be private (0600 on Unix), regular files owned by
100
+ the current user; interactive hidden prompts or stdin are preferred. The old CLI
101
+ relay posting/login path is disabled because it forwarded platform keys or echoed
102
+ legacy input. Use named local accounts and the direct agent publishing workflow.
103
+
104
+ See [the security model, recovery and limits](../SECURITY.md). Platform keys are not
105
+ stored in draft/template files. Account IDs/labels remain private metadata rather
106
+ than encrypted records. Encryption here does not attest the OS provider's own
107
+ at-rest encryption, protect an unlocked account from same-user malware, or audit
108
+ the separate DotSuite backend.
109
+
110
+ ## Setup and diagnostics
111
+
112
+ Run these after installing the CLI package (or prefix the commands with
113
+ `node bin/dotshare-agent.js` when using this checkout):
114
+
115
+ ```sh
116
+ dotshare-agent setup
117
+ dotshare-agent doctor
118
+ dotshare-agent accounts add personal-mastodon --platform mastodon
119
+ dotshare-agent doctor --account personal-mastodon
120
+ ```
121
+
122
+ `setup` verifies a real MCP handshake, registers the current installation in Codex,
123
+ uses absolute Node/server paths, and forwards the Linux desktop session for keyring
124
+ access. It preserves other settings, comments and server entries, creates a private
125
+ backup when replacing an existing file, and does not rewrite an unchanged entry.
126
+ Restart/reconnect Codex after setup; setup cannot prove a running client has reloaded.
127
+
128
+ Local images remain disabled on a fresh setup until directories are explicitly
129
+ allowed. Existing allowed directories are retained when setup runs again:
130
+
131
+ ```sh
132
+ dotshare-agent setup --media-root /absolute/path/to/images
133
+ dotshare-agent setup --text-only
134
+ dotshare-agent setup --dry-run
135
+ dotshare-agent setup --client generic
136
+ dotshare-agent setup --config /absolute/path/to/config.toml --json
137
+ ```
138
+
139
+ `--dry-run` checks the server and prints a configuration preview without writing
140
+ settings. `--client generic` prints an `mcpServers` JSON snippet for manual import;
141
+ adapt the wrapper key to your client's format. A different existing DotShare server
142
+ is preserved unless `--replace` is explicitly supplied. Existing inline/dotted-key
143
+ DotShare TOML entries must be converted to `[mcp_servers.dotshare]` before automatic
144
+ updates; malformed config files are never overwritten. `CODEX_HOME` is honored.
145
+
146
+ `doctor` checks Node, build output, native keyring binding, client configuration,
147
+ image roots, account metadata and a real stdio MCP handshake. It never changes
148
+ settings or publishes content. Default checks do not read credentials or contact
149
+ platform APIs. Use `--check-accounts` to read credentials and call identity endpoints,
150
+ or `--account ID` to check just one account. These checks do not create posts,
151
+ uploads, OAuth sessions or refresh tokens. Bluesky only resolves the handle and
152
+ reports password validity as unverified. A platform HTTP 403 is a warning about read
153
+ scopes/API access, not proof that a publishing token is invalid.
154
+
155
+ Reports distinguish `PASS`, `WARN`, and `FAIL`, with actionable fixes. `--json`
156
+ returns a structured report. Failed checks exit with status 1; warnings alone exit
157
+ 0. `doctor --skip-mcp` performs local checks and reports `mcpReady: null`, never a
158
+ successful connection. Generic-client diagnostics verify the server, not the other
159
+ client's configuration. Identity verification does not prove posting permissions
160
+ or encrypted-at-rest keyring storage.
161
+
162
+ ## Manual Codex configuration
163
+
164
+ From this checkout, replace the paths with absolute paths on your machine:
165
+
166
+ ```sh
167
+ codex mcp add dotshare -- node /absolute/path/to/DotShare/bin/dotshare-mcp.js
168
+ ```
169
+
170
+ Or merge this into your existing `~/.codex/config.toml`:
171
+
172
+ ```toml
173
+ [mcp_servers.dotshare]
174
+ command = "node"
175
+ args = ["/absolute/path/to/DotShare/bin/dotshare-mcp.js"]
176
+ cwd = "/absolute/path/to/DotShare"
177
+ startup_timeout_sec = 20
178
+ tool_timeout_sec = 600
179
+ # Forward the desktop session for Linux OS keyring access.
180
+ env_vars = ["DBUS_SESSION_BUS_ADDRESS", "XDG_RUNTIME_DIR", "DISPLAY", "WAYLAND_DISPLAY"]
181
+
182
+ [mcp_servers.dotshare.env]
183
+ DOTSHARE_MEDIA_ROOTS = "/absolute/path/to/your/images"
184
+ ```
185
+
186
+ Restart/reconnect the MCP client after adding the server. Configure another client
187
+ with the same command/arguments and stdio transport. Official Codex configuration:
188
+ <https://learn.chatgpt.com/docs/extend/mcp?surface=cli>.
189
+
190
+ `DOTSHARE_HOME` optionally changes the metadata/history directory. Credential keys
191
+ in the OS keyring are shared between home directories; account IDs should be unique
192
+ if using several directories. `DOTSHARE_MEDIA_ROOTS` contains allowed image directories
193
+ separated by the OS path delimiter (`:` on Linux/macOS, `;` on Windows). Each entry
194
+ must be an absolute path. When it is unset or invalid, local images are disabled and
195
+ text-only posts still work. A relative image path such as `launch.png` is looked up
196
+ inside each root in order. Real paths are checked, including symlink targets.
197
+ The server never downloads arbitrary social-media URLs or reads credentials from
198
+ tool arguments. Diagnostics go to stderr; stdout is reserved for MCP JSON.
199
+
200
+ Example requests after connecting:
201
+
202
+ > List my DotShare accounts and preview this post for LinkedIn and Mastodon.
203
+
204
+ > Publish the previewed post to work-linkedin and personal-mastodon, with this image.
205
+
206
+ > Turn this release announcement into a thread on my Bluesky account and publish it.
207
+
208
+ The server exposes `list_accounts`, `preview_post`, `publish_post`, `get_operation`,
209
+ `list_history`, `list_cloud_connections`, `schedule_post`, `list_scheduled_posts`, and
210
+ `cancel_scheduled_post`, plus `create_draft`, `get_draft`, `list_drafts`,
211
+ `update_draft`, `preview_draft`, and `publish_draft`, plus `list_templates`,
212
+ `get_template`, `save_template`, `delete_template`, `render_template`,
213
+ `create_draft_from_template`, `get_draft_variants` and `set_draft_variant`
214
+ (23 tools total).
215
+ `dotshare://guide` describes the workflow, and the
216
+ `release-announcement` prompt helps prepare drafts from release notes.
217
+
218
+ ## Saved drafts: Draft, Preview and Published
219
+
220
+ Use the saved-draft workflow when preparing content over several messages or when
221
+ publication must match a reviewed preview. The existing `preview_post` is an
222
+ unsaved preview: it does not create a post, draft ID or durable preview snapshot.
223
+ For a saved draft, always use `publish_draft`; copying its text into `publish_post`
224
+ bypasses the draft workflow and is not a substitute for publishing the saved preview.
225
+
226
+ | Status | Meaning |
227
+ | --- | --- |
228
+ | `Draft` | Saved locally; not published. New edits invalidate an earlier preview. |
229
+ | `Preview` | A valid preview of this revision is saved; nothing has been published. |
230
+ | `Publishing` | A publication was reserved or is in progress. Recover its operation; do not issue a new request ID. |
231
+ | `Published` | Publication completed. Per-account delivery results and receipt URLs are returned. |
232
+ | `NeedsReview` | Publication failed, was interrupted or may have partially succeeded. Inspect receipts and the destination before further action. |
233
+ | `SavedRemotely` | Dev.to accepted the article as a remote draft (`published:false`); it is not a public article. |
234
+
235
+ For mixed social/Dev.to targets, `publication.deliveries` distinguishes public
236
+ posts from Dev.to remote drafts. A timeout is never presented as a successful post.
237
+
238
+ A typical agent conversation:
239
+
240
+ > Save this announcement as a draft for personal-mastodon. Do not publish yet.
241
+
242
+ > Edit that draft to use the English version, then preview it.
243
+
244
+ > Publish that saved preview.
245
+
246
+ `create_draft` takes `{title?, content}` and returns `draft.id`, `draft.revision`
247
+ and `draft.status`. Incomplete drafts are allowed, including an empty `accountIds`
248
+ list. `update_draft` takes `draftId`, `expectedRevision`, and a `patch` of content
249
+ fields and/or `title`. Omitted fields are preserved; set `posts` or `article` to
250
+ `null` to remove them, or `overrides:null` to clear per-account variants. Each edit
251
+ increments the revision and resets the state to Draft.
252
+
253
+ `preview_draft` requires `draftId` and `expectedRevision`. It validates content,
254
+ accounts and local images, saves exact thread parts, and returns `draft.preview.id`.
255
+ A failed preview leaves the draft in Draft with validation errors. Repeating preview
256
+ creates a new preview ID, even when the content revision is unchanged.
257
+
258
+ `publish_draft` requires all four fields:
259
+
260
+ ```json
261
+ {
262
+ "draftId": "UUID_FROM_CREATE_DRAFT",
263
+ "expectedRevision": 2,
264
+ "previewId": "UUID_FROM_PREVIEW_DRAFT",
265
+ "requestId": "saved-release-2026-11-02-1"
266
+ }
267
+ ```
268
+
269
+ Before sending anything, publication checks the saved content/plan, current instance
270
+ limits, account credential bindings and local image fingerprints. A changed image,
271
+ account, credential or platform plan requires a new preview. Verified local image
272
+ bytes are copied privately for the attempt, so editing the source during publication
273
+ cannot change a later upload. Dev.to public image URLs are bound by URL; this does
274
+ not freeze the remote server's image contents.
275
+
276
+ Retries use the same request ID, revision and preview ID. Completed/uncertain
277
+ operations are replayed from the journal without resending, even after a restart.
278
+ `get_draft` recovers receipt/status updates from that journal if the process stopped
279
+ before saving final draft status. A draft with a publication attempt cannot be edited
280
+ or submitted under a new ID. A new draft represents a separately authorized action,
281
+ not a way to bypass an uncertain result. Short local commit locks and revision checks
282
+ prevent concurrent agents from overwriting each other's edits.
283
+
284
+ ### Draft commands
285
+
286
+ For the following commands, `draft.json` contains
287
+ `{"title":"MCP release","content":{"accountIds":["personal-mastodon"],"text":"Our release is ready."}}`.
288
+ The edit file contains `{"patch":{"text":"Updated release announcement."}}`.
289
+
290
+ ```sh
291
+ dotshare-agent drafts create --input draft.json
292
+ dotshare-agent drafts list --status Draft
293
+ dotshare-agent drafts get DRAFT_ID
294
+ dotshare-agent drafts update DRAFT_ID --revision 1 --input edit.json
295
+ dotshare-agent drafts preview DRAFT_ID --revision 2
296
+ dotshare-agent drafts publish DRAFT_ID --revision 2 --preview-id PREVIEW_ID --request-id saved-release-1
297
+ ```
298
+
299
+ `drafts create --title "Release announcement"` creates an empty draft for later
300
+ editing. From a source checkout, prefix commands with `node bin/dotshare-agent.js`.
301
+ The MCP client must reconnect after an upgrade to discover new tools;
302
+ `doctor` verifies the complete tool set from a newly started server.
303
+
304
+ Draft records contain full post bodies, preview snapshots and publication references
305
+ under `DOTSHARE_HOME/drafts` (default `~/.dotshare/drafts`). These JSON files are
306
+ encrypted with AES-256-GCM; directory/file permissions are 0700/0600. The random master key stays in the required OS keyring, never beside these files. Credentials are kept
307
+ in the OS keyring; drafts contain credential fingerprints, not the keys themselves.
308
+ `list_drafts` returns summaries without post bodies. Draft content is limited to
309
+ 1 MiB, and preview plans to 2 MiB. The VS Code Publishing Library uses this same
310
+ store through the configured MCP installation. Earlier platform-composer drafts
311
+ remain separate; no automatic migration is performed.
312
+
313
+ ## Reusable templates and account versions
314
+
315
+ Templates are local content recipes, not scheduled jobs or public posts. They need
316
+ no cloud subscription or model API key. The agent can write/adapt wording when
317
+ asked; the template engine only substitutes the literal values supplied to it.
318
+
319
+ Start with `list_templates`, then `get_template` to inspect the recipe and parameters.
320
+ Five read-only recipes are included: `builtin-release`, `builtin-progress`,
321
+ `builtin-launch`, `builtin-bugfix` and `builtin-article`. Built-ins are English starter
322
+ formats; custom recipes and values can use any language. Copy a built-in's name,
323
+ description, content, variables and variant maps into `save_template` under a custom
324
+ ID to customize it. Do not pass derived read-only fields such as `parameters`.
325
+
326
+ A custom template definition:
327
+
328
+ ```json
329
+ {
330
+ "id": "my-release",
331
+ "name": "My release announcement",
332
+ "description": "A short announcement plus a professional LinkedIn version.",
333
+ "variables": {
334
+ "version": {"description": "Actual release version"},
335
+ "link": {"type": "url", "description": "Verified release URL"},
336
+ "hashtags": {"default": "#OpenSource"}
337
+ },
338
+ "content": {
339
+ "text": "{{project}} {{version}} is out!\n\n{{highlights}}\n\n{{link}}\n{{hashtags}}",
340
+ "autoSplit": true
341
+ },
342
+ "platformVariants": {
343
+ "linkedin": {"text": "Introducing {{project}} {{version}}.\n\n{{highlights}}\n\nLearn more: {{link}}"}
344
+ },
345
+ "accountVariants": {
346
+ "personal-mastodon": {"text": "Shipped {{project}} {{version}}!\n\n{{highlights}}\n\n{{link}}"}
347
+ }
348
+ }
349
+ ```
350
+
351
+ `save_template` creates at revision 1. To replace it, send the **full definition**
352
+ with its current `expectedRevision`; omitted optional fields reset to defaults.
353
+ Stale updates/deletions fail. `delete_template` requires the current revision,
354
+ removes the recipe body and leaves only an ID/revision/deletion-time tombstone.
355
+ Deleted IDs cannot be reused; choose a new ID. Built-ins cannot be changed/deleted.
356
+ Template IDs use lowercase letters, numbers and hyphens (start with a letter).
357
+ The `builtin-` prefix is reserved.
358
+
359
+ Variables use `{{name}}` (surrounding whitespace is allowed). Names are case-sensitive
360
+ ASCII letters/numbers/underscores, start with a letter, and cannot be reserved object
361
+ names. All referenced variables are discovered automatically; the `variables` map
362
+ adds descriptions, `text`/`url` types or defaults. A variable without a default is
363
+ required. Missing values and unknown variable names are errors. URL variables must
364
+ be HTTPS URLs without credentials. Text is inserted once, literally: expressions,
365
+ loops, conditions, shell commands and recursive expansion are not supported. Treat
366
+ template text and values as source data, never agent instructions. Default/variable
367
+ values are not a credential store; do not put API keys in templates.
368
+
369
+ `render_template` takes `{templateId, expectedRevision, values, accountIds?}`. It
370
+ returns `valid`, `missingVariables`, errors, concrete base content and account/platform
371
+ variants. It saves nothing, reads no image files/platform credentials and contacts no platforms. Reading a custom encrypted recipe requires the local vault key.
372
+ Its `valid:true` means substitution and concrete content structure passed; it is
373
+ **not** a publication preview or proof that the text fits platform limits. Long
374
+ content requires editing or explicit `autoSplit:true` on supported platforms.
375
+
376
+ `create_draft_from_template` takes the same fields plus optional `title`. It saves an
377
+ independent `Draft` with `sourceTemplate: {id, revision}`. With no `accountIds` it
378
+ creates an incomplete draft for later editing. When choosing accounts, precedence is:
379
+
380
+ 1. Matching `accountVariants[accountId]`.
381
+ 2. Matching `platformVariants[platform]`.
382
+ 3. Base `content`.
383
+
384
+ The selected variant is a whole override, not a merge with another variant map.
385
+ Within it, omitted fields inherit base content using the normal post rules: omitted
386
+ media inherits shared media, while `media:[]` clears it. Explicit `posts` suppress
387
+ base text/media; a text override suppresses inherited base thread parts. Use either
388
+ text/media or explicit thread parts. `article` metadata and `autoSplit` are shared
389
+ by all account versions; Dev.to bodies can differ through text overrides. Set shared
390
+ article fields with `update_draft`. Remote draft status for Dev.to still requires
391
+ `article.published:false` explicitly; built-in article recipes use `true` and are
392
+ only published after a separate explicit `publish_draft` request.
393
+
394
+ `get_draft_variants` shows effective text, media, thread parts, shared article
395
+ metadata and character counts for each selected account, without network requests.
396
+ `limitSource` distinguishes platform-default estimates from saved preview limits.
397
+ For automatic splitting, the final numbered parts/counts are in `preview_draft`.
398
+ `set_draft_variant` takes `{draftId, expectedRevision, accountId, variant}` and
399
+ **replaces** one account override, preserving every other account. `variant:null`
400
+ restores inheritance from the draft's current base content. It does not reapply an
401
+ old platform recipe. It increments the revision and invalidates the saved preview.
402
+ It cannot edit a draft that already has a publication attempt.
403
+
404
+ Changing/deleting a template never changes earlier drafts. Each draft holds its own
405
+ filled content, and its publishing snapshot/retry safeguards remain in effect.
406
+ Template files live under `DOTSHARE_HOME/templates` with 0700/0600 permissions;
407
+ like draft bodies and operation records, they are encrypted with an OS-keyring master key. Stored templates and expanded content
408
+ are bounded to 1 MiB; templates allow at most 100 distinct variables. No VS Code
409
+ template/draft migration is performed. The Publishing Library connects directly to
410
+ this same store; see [the visual workflow](PUBLISHING_LIBRARY.md).
411
+
412
+ Example agent requests:
413
+
414
+ > Show available templates and the release template's required variables.
415
+
416
+ > Use the release template with these verified release notes and this URL. Save a
417
+ > draft for personal-mastodon and work-linkedin. Do not publish.
418
+
419
+ > Show both account versions. Make LinkedIn more formal and keep Mastodon short.
420
+ > Preview the updated draft without publishing.
421
+
422
+ > Publish that saved preview.
423
+
424
+ CLI equivalents (`recipe.json` contains the definition above; `values.json` contains
425
+ `{"values":{"project":"DotShare","version":"vNext","highlights":"Supplied release notes","link":"https://example.com/release"},"accountIds":["personal-mastodon"]}`;
426
+ `variant.json` contains `{"text":"My revised Mastodon text"}`):
427
+
428
+ ```sh
429
+ dotshare-agent templates list
430
+ dotshare-agent templates get builtin-release
431
+ dotshare-agent templates save --input recipe.json
432
+ dotshare-agent templates render my-release --revision 1 --input values.json
433
+ dotshare-agent templates use my-release --revision 1 --input values.json
434
+ dotshare-agent drafts variants DRAFT_ID
435
+ dotshare-agent drafts set-variant DRAFT_ID personal-mastodon --revision 1 --input variant.json
436
+ dotshare-agent drafts preview DRAFT_ID --revision 2
437
+ dotshare-agent drafts publish DRAFT_ID --revision 2 --preview-id PREVIEW_ID --request-id my-release-1
438
+ dotshare-agent templates delete my-release --revision 1
439
+ ```
440
+
441
+ Use JSON `null` as the set-variant input to reset an account to base inheritance.
442
+ All commands taking `--input` also accept `-` for stdin. From this checkout prefix
443
+ commands with `node bin/dotshare-agent.js`.
444
+
445
+ ## Content and preview
446
+
447
+ Use the same post structure for `preview_post` and `publish_post`. Publishing also
448
+ requires a stable `requestId` identifying one user-authorized action:
449
+
450
+ ```json
451
+ {
452
+ "requestId": "dotshare-release-2026-11-02-1",
453
+ "accountIds": ["personal-mastodon", "work-linkedin"],
454
+ "text": "DotShare now works with AI agents!",
455
+ "media": ["/absolute/path/to/your/images/launch.png"],
456
+ "autoSplit": true,
457
+ "overrides": {
458
+ "work-linkedin": { "text": "We shipped agent-driven publishing in DotShare." }
459
+ }
460
+ }
461
+ ```
462
+
463
+ Omit `requestId` when calling `preview_post` (schemas reject unrelated fields).
464
+ The CLI accepts the same JSON through `preview --input file.json` or
465
+ `publish --input file.json`; `--input -` reads stdin. Preview returns exact planned
466
+ text, image paths, character counts, limits and validation errors, and publishes
467
+ nothing. Mastodon instance limits are fetched when that account is previewed.
468
+
469
+ `posts: [{"text":"First"},{"text":"Second","media":["/path/image.png"]}]`
470
+ creates an explicit thread on X, Bluesky or Mastodon. Use either `posts` or
471
+ `text`/`media`. `autoSplit` splits long text into numbered thread parts on those three
472
+ platforms, with common images attached to the first part. `overrides` can specify
473
+ different text, images or explicit thread parts per account. Unsupported threads,
474
+ empty posts, missing images and oversized content fail preflight before any account
475
+ is published to. Character counts for combined emoji on X/Bluesky are conservative.
476
+
477
+ | Agent media support | Limits |
478
+ | --- | --- |
479
+ | Local images | PNG/JPEG; WebP also on Bluesky, Mastodon and Discord |
480
+ | Size | 1,000,000 bytes/image on Bluesky; 8 MiB/image otherwise, subject to platform limits |
481
+ | Images/post | X/Bluesky/Mastodon up to 4 (Mastodon also checks instance limits); LinkedIn 1; Telegram/Discord 10 |
482
+ | Telegram | Caption limited to 1,024 characters; multiple images are sent as separate messages, caption on first |
483
+ | Dev.to | Public HTTPS image URLs; local files are rejected |
484
+ | Video/GIF | Not supported by this initial agent interface |
485
+
486
+ Dev.to requires `article: {"title":"Release notes","tags":["opensource"],"published":true}`.
487
+ Optional article fields include `canonicalUrl`, `coverImage`, `description`, and
488
+ `series`. Set `published:false` to create a Dev.to draft intentionally.
489
+
490
+ ## Retry and recovery
491
+
492
+ Each publish/schedule/cancel operation is claimed atomically and retained in
493
+ `~/.dotshare/operations` with private file permissions. The journal records receipts
494
+ as each thread part is published. It stores a request fingerprint and result metadata,
495
+ not platform credentials or full post bodies.
496
+
497
+ - Repeat the **same requestId and payload** to retrieve the existing result without
498
+ sending another publication request, including after a reconnect/process restart.
499
+ - Reusing an ID for different content fails. IDs have no automatic expiry.
500
+ - A timeout can occur after a platform accepted a post. `needs_review`, `uncertain`,
501
+ and stale `running` operations require inspection of the destination, not an
502
+ automatic retry with a new ID. Already published parts are not rolled back.
503
+ - To intentionally publish the same content again, provide a new user-authorized ID.
504
+ - `operation <requestId>` and `history` recover local results. Credentials must be
505
+ available for all target accounts before the first publication starts.
506
+
507
+ This prevents application retries from resending a claimed action; it does not
508
+ provide a distributed exactly-once guarantee across external platform APIs or
509
+ after deleting the local journal. Back up the journal if migrating machines.
510
+
511
+ ## Cloud scheduling
512
+
513
+ ```sh
514
+ node bin/dotshare-agent.js cloud login
515
+ node bin/dotshare-agent.js cloud connections
516
+ node bin/dotshare-agent.js cloud schedule --input schedule.json
517
+ node bin/dotshare-agent.js cloud list
518
+ node bin/dotshare-agent.js cloud cancel SCHEDULED_POST_ID --request-id cancel-post-1
519
+ ```
520
+
521
+ Connect the desired platform accounts in the DotSuite dashboard first. Local named
522
+ accounts and cloud connections are separate: cloud requests select platforms, using
523
+ the accounts already connected on the server. No local platform keys are synced.
524
+ The DotSuite session token is entered in your terminal and stored in the OS keyring.
525
+ Backend plan limits, permissions and available connections still apply.
526
+
527
+ ```json
528
+ {
529
+ "requestId": "scheduled-launch-1",
530
+ "platforms": ["mastodon", "x"],
531
+ "text": "Our release is live!",
532
+ "mediaUrls": ["https://your-public-cdn.example/launch.png"],
533
+ "scheduledAt": "2026-12-01T10:00:00+02:00"
534
+ }
535
+ ```
536
+
537
+ Scheduling requires a timezone and at least one minute of lead time. It supports one
538
+ post with public HTTPS image URLs, without local file uploads, threads or account
539
+ overrides. Discord cloud scheduling is unavailable. `DOTSUITE_API_URL` optionally
540
+ selects a compatible HTTPS backend. It cannot contain credentials/query parameters.
541
+
542
+ ## Build and validate
543
+
544
+ ```sh
545
+ npm run lint
546
+ npx tsc --noEmit
547
+ npm run test:all -- --runInBand
548
+ npm run test:agent:stdio
549
+ npm run package:cli
550
+ ```
551
+
552
+ The packaging command builds production bundles and stages the CLI in a temporary
553
+ directory, leaving the VS Code `package.json` unchanged. The resulting npm tarball
554
+ is saved under `artifacts/`; it can be installed locally with `npm install -g PATH.tgz`.
555
+ Unit/integration tests use mocked platform APIs. The subprocess smoke test checks
556
+ the real MCP transport and CLI binaries without publishing anything publicly.