mdedit-cli 0.3.5 → 0.4.0

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/skill.md DELETED
@@ -1,333 +0,0 @@
1
- # mdedit CLI — Agent Skill
2
-
3
- > Use this skill to manage articles, folders, workspaces, and existing API keys on [mdedit.ai](https://mdedit.ai) directly from your terminal or from an AI agent.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install -g mdedit-cli
9
- ```
10
-
11
- ## Quick-start authentication
12
-
13
- ```bash
14
- # Set your API key (get one at https://mdedit.ai/docs/api-keys)
15
- mdedit config login --api-key <YOUR_KEY>
16
-
17
- # Or via environment variable (recommended for CI/agents)
18
- export MDEDIT_API_KEY=<YOUR_KEY>
19
- export MDEDIT_WORKSPACE_ID=<YOUR_WORKSPACE_ID> # optional default workspace
20
- ```
21
-
22
- ## Agent tips
23
-
24
- - **Always use `--format json`** when parsing output programmatically: `mdedit article list --format json`
25
- - **Suppress interactive prompts** by supplying all required flags (title, name, …) on the command line.
26
- - **Use `-y` / `--yes`** on destructive commands to skip confirmation prompts.
27
- - **Pipe article content** via stdin using `--file -` or read it back with `--content-only` (stdout).
28
- - In `json` mode, **human-facing messages go to stderr** (stdout stays machine-parseable).
29
- - **Exit codes**: `0` = success, `1` = general error, `2` = edit anchor missing,
30
- `3` = edit anchor ambiguous, `4` = edit conflict. Typed edit errors are JSON on stdout
31
- in `json` mode; other errors are written to stderr.
32
-
33
- ## Global flags
34
-
35
- | Flag | Description |
36
- |------|-------------|
37
- | `-F, --format <plain\|table\|json>` | Output format. Use `json` for agents. |
38
- | `--api-key <key>` | Override API key for this call |
39
- | `--workspace <workspaceId>` | Override default workspace for this call |
40
- | `--api-url <url>` | Override API base URL |
41
- | `--local` | Target local API at `http://localhost:8080` |
42
- | `--debug` | Print stack traces and request info on errors |
43
-
44
- ## Commands reference
45
-
46
- ### config
47
-
48
- ```bash
49
- mdedit config show # show current config (api key redacted)
50
- mdedit config login --api-key <key> # authenticate
51
- mdedit config logout # remove stored api key
52
- mdedit config use-workspace <workspaceId> # set default workspace
53
- mdedit config set <key> <value> # set any config key
54
- mdedit config clear --yes # wipe all config
55
- ```
56
-
57
- ### workspace
58
-
59
- ```bash
60
- mdedit workspace list
61
- mdedit workspace get <workspaceId>
62
- mdedit workspace create --name "My Workspace" --type user
63
- mdedit workspace update <workspaceId> --name "New Name"
64
- mdedit workspace delete <workspaceId> --yes
65
- ```
66
-
67
- ### folder
68
-
69
- ```bash
70
- mdedit folder list [-w <workspaceId>]
71
- mdedit folder list --include-deleted
72
- mdedit folder get <folderId>
73
- mdedit folder create --name "Drafts" [--parent <parentFolderId>]
74
- mdedit folder update <folderId> --name "Archive"
75
- mdedit folder delete <folderId> --yes
76
- ```
77
-
78
- ### article
79
-
80
- ```bash
81
- # List & filter
82
- mdedit article list
83
- mdedit article list --folder <folderId>
84
- mdedit article list --limit 10 --offset 0
85
-
86
- # Read
87
- mdedit article get <articleId>
88
- mdedit article get <articleId> --content-only # raw markdown to stdout
89
- mdedit article get <articleId> --include-content # include markdown in output object
90
- mdedit article get <articleId> --output article.md # save markdown to file
91
-
92
- # Create
93
- mdedit article create --title "My Article"
94
- mdedit article create --title "My Article" --folder <folderId> --file article.md
95
- mdedit article create --title "My Article" --content "# Hello world"
96
- echo "# Hello" | mdedit article create --title "My Article" --file -
97
- mdedit article create --file article.md --publish # new Live public link
98
- mdedit article create --file article.md --publish --snapshot
99
-
100
- # Update
101
- mdedit article update <articleId> --title "New Title"
102
- mdedit article update <articleId> --file updated.md
103
- mdedit article update <articleId> --content "# Updated"
104
- cat updated.md | mdedit article update <articleId> --file -
105
- mdedit article update <articleId> --archive
106
- mdedit article update <articleId> --pin
107
-
108
- # One-shot live edit
109
- mdedit article edit <articleId> --replace "old text" --with "new text"
110
- mdedit article edit <articleId> --ops-file ops.json --format json
111
-
112
- # Stream newline-delimited document and review events until interrupted
113
- mdedit article watch <articleId>
114
- mdedit article watch <articleId> --agent claude-code --poll-interval 5000
115
-
116
- # Publish a public link (requires publishing:write)
117
- mdedit article publish <articleId> # new links default Live
118
- mdedit article publish <articleId> --snapshot # frozen artifact
119
- mdedit article publish <articleId> --live # switch existing link to Live
120
- mdedit article publish <articleId> --slug my-document
121
- mdedit article publish-status <articleId> --format json
122
- mdedit article unpublish <articleId> --yes
123
-
124
- # Delete
125
- mdedit article delete <articleId> --yes
126
-
127
- # Export
128
- mdedit article export <articleId> --output article.zip
129
- ```
130
-
131
- ## Reviewing and editing documents
132
-
133
- Reviewer keys should use least-privilege scopes:
134
-
135
- Create reviewer keys in mdedit.ai Settings → Integrations → API Keys. A reviewer key should usually use `articles:read,reviews:write`.
136
-
137
- All review mutations are server-authored and retry-safe. Suggestions do not change article
138
- text until accepted; `review accept` therefore requires `articles:write` in addition to the
139
- reviewer scopes.
140
-
141
- ```bash
142
- mdedit review list <articleId> --status open --format json
143
- mdedit review add <articleId> --quote "some text" --body "This needs a citation."
144
- mdedit review reply <articleId> --thread <reviewId> --body "Fixed."
145
- mdedit review resolve <articleId> --thread <reviewId>
146
- mdedit review reopen <articleId> --thread <reviewId>
147
- mdedit review accept <articleId> --thread <suggestionId>
148
- mdedit review reject <articleId> --thread <suggestionId>
149
- mdedit review delete <articleId> --thread <reviewId>
150
- mdedit review delete <articleId> --thread <reviewId> --reply <replyId>
151
- mdedit suggest <articleId> --quote "teh" --replace "the" --note "Typo"
152
- ```
153
-
154
- When quoted text repeats, add `--occurrence <n>`, `--before <text>`, or `--after <text>`.
155
- Use `--target <file.md>` for package targets other than `content.md`.
156
-
157
- ### api-key
158
-
159
- Create new API keys in mdedit.ai Settings → Integrations → API Keys. The CLI can list and revoke existing keys.
160
-
161
- ```bash
162
- mdedit apikey list
163
- mdedit apikey revoke <keyId> --yes
164
- ```
165
-
166
- ### utility
167
-
168
- ```bash
169
- mdedit health # check API health
170
- mdedit info # CLI version, API URL, workspace, auth status
171
- ```
172
-
173
- ### skill
174
-
175
- ```bash
176
- mdedit skill show # print this skill to stdout
177
- mdedit skill install # install skill into all detected agent tools
178
- mdedit skill install --target claude # Claude Code: ~/.claude/CLAUDE.md
179
- mdedit skill install --target cursor # Cursor: .cursor/rules/mdedit.mdc
180
- mdedit skill install --target codex # GitHub Copilot: .github/copilot-instructions.md
181
- mdedit skill install --target all # all of the above
182
- mdedit skill install --global # install globally (home directory targets)
183
- ```
184
-
185
- ## Common agent workflows
186
-
187
- ### Workflow: edit article text directly
188
-
189
- Use `article edit` for anchored changes so collaborative documents join the live room and
190
- non-collaborative documents use a conditional REST commit. A simple replacement must match
191
- exactly once:
192
-
193
- ```bash
194
- mdedit article edit <articleId> \
195
- --replace "The old sentence." \
196
- --with "The revised sentence." \
197
- --format json
198
- ```
199
-
200
- For context, occurrences, headings, ranges, or multiple sequential edits, pass a non-empty
201
- JSON array to `--ops-file`:
202
-
203
- ```json
204
- [
205
- {
206
- "type": "replace",
207
- "anchor": { "quote": "teh", "occurrence": 2 },
208
- "text": "the"
209
- },
210
- {
211
- "type": "insert",
212
- "anchor": { "afterHeading": "## Setup" },
213
- "text": "\nNew setup note.\n"
214
- }
215
- ]
216
- ```
217
-
218
- Quote anchors also accept `context: { before, after }`. Other anchors are
219
- `beforeHeading`, `inSection`, and `range: { from, to }`. On exit `2` or `3`, revise the
220
- anchor and retry. On exit `4`, the edit may have landed; re-read the article before making
221
- another change.
222
-
223
- ### Workflow: react to document and review changes
224
-
225
- `article watch` writes exactly one JSON object per stdout line. It begins with
226
- `session.ready`, then emits `article.updated`, `review.event`, and `review.updated`.
227
- Use the stream as the input to a long-running agent loop and stop it with `SIGINT` or
228
- `SIGTERM`; the CLI closes the article session before exiting.
229
-
230
- ```bash
231
- mdedit article watch <articleId> | while IFS= read -r event; do
232
- printf '%s\n' "$event" | jq -c '{type, articleId, event}'
233
- done
234
- ```
235
-
236
- ### Workflow: read an article and update its content
237
-
238
- ```bash
239
- # Fetch current content
240
- CONTENT=$(mdedit article get <articleId> --content-only)
241
-
242
- # Modify $CONTENT with your agent logic, then push it back
243
- echo "$MODIFIED_CONTENT" | mdedit article update <articleId> --file -
244
- ```
245
-
246
- ### Workflow: publish and monitor a public link
247
-
248
- CLI publication is non-interactive. A new link defaults to **Live**, so later durable
249
- edits update the same URL automatically. Use `--snapshot` for a frozen artifact.
250
- Existing links keep their stored mode when neither mode flag is passed; use `--live`
251
- or `--snapshot` to switch deliberately without changing the URL.
252
-
253
- ```bash
254
- mdedit article create --file document.md --publish --format json
255
- mdedit article publish-status <articleId> --format json
256
- ```
257
-
258
- Read `shortUrl`, `mode`, the `source*` revision/version fields, and `syncStatus` from
259
- JSON output. If `syncStatus` is `failed`, the URL still serves the last good content;
260
- report `lastSuccessfulSyncAt` and `syncError` rather than claiming it is current.
261
- Links created before Live mode are legacy Snapshots until explicitly switched:
262
-
263
- ```bash
264
- mdedit article publish <articleId> --live --format json
265
- ```
266
-
267
- ### Workflow: create a new article in a folder
268
-
269
- ```bash
270
- # Find the target folder
271
- mdedit folder list --format json | jq '.[] | select(.name=="Docs") | .id'
272
-
273
- # Create article in that folder
274
- mdedit article create --title "API Reference" --folder <folderId> --file api-ref.md
275
- ```
276
-
277
- ### Workflow: bulk export all articles as JSON
278
-
279
- ```bash
280
- mdedit article list --format json > articles.json
281
- ```
282
-
283
- ### Workflow: set up a fresh environment
284
-
285
- ```bash
286
- export MDEDIT_API_KEY=<key>
287
- mdedit config login --api-key "$MDEDIT_API_KEY"
288
- # list workspaces and set the default
289
- mdedit workspace list --format json
290
- mdedit config use-workspace <workspaceId>
291
- ```
292
-
293
- ## Environment variables
294
-
295
- | Variable | Description |
296
- |----------|-------------|
297
- | `MDEDIT_API_KEY` | API key (overrides stored config) |
298
- | `MDEDIT_API_URL` | API base URL (default: `https://apiv2.mdedit.ai`) |
299
- | `MDEDIT_WORKSPACE_ID` | Default workspace ID |
300
- | `MDEDIT_CONFIG_DIR` | Override config directory (default: `~/.mdedit-cli`) |
301
- | `MDEDIT_DEBUG` | Set to `1` to enable debug output |
302
-
303
- ## Output format guide
304
-
305
- | Format | Best for |
306
- |--------|----------|
307
- | `table` | Humans scanning many rows (default) |
308
- | `plain` | Human reading (object details) |
309
- | `json` | Agents, scripts, piping to `jq` |
310
-
311
- Use `--format json` globally: `mdedit <command> --format json`.
312
- In `json` mode all human-readable messages go to **stderr** so stdout stays machine-parseable.
313
-
314
- ## Error handling
315
-
316
- General errors write a descriptive message to **stderr** and exit with code `1`.
317
- Typed `article edit` failures use these stable codes:
318
-
319
- | Exit | Error code | Meaning |
320
- |------|------------|---------|
321
- | 2 | `ANCHOR_NOT_FOUND` | No anchor match; nothing was applied |
322
- | 3 | `AMBIGUOUS_ANCHOR` | Multiple matches; add occurrence or context |
323
- | 4 | `EDIT_CONFLICT` | Concurrent edits overlapped or a conditional commit raced |
324
-
325
- Common errors and fixes:
326
-
327
- | HTTP | Meaning | Fix |
328
- |------|---------|-----|
329
- | 401 | Unauthenticated | Run `mdedit config login --api-key <key>` |
330
- | 403 | Forbidden | Check API key workspace permissions |
331
- | 404 | Not found | Verify IDs and `--api-url` |
332
-
333
- Add `--debug` to print full stack traces.