mdedit-cli 0.2.0 → 0.2.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.
package/openclaw.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "schema_version": "1.0",
3
3
  "name": "mdedit",
4
4
  "display_name": "MDEdit.ai",
5
- "description": "Manage articles, folders, workspaces, and API keys on mdedit.ai from any AI agent. Supports full CRUD, markdown content piping, and JSON output for programmatic use.",
5
+ "description": "Manage articles, reviews, suggestions, folders, workspaces, and API keys on mdedit.ai from any AI agent. Supports server-authoritative review workflows, markdown editing, and JSON output.",
6
6
  "homepage_url": "https://mdedit.ai",
7
7
  "docs_url": "https://docs.mdedit.ai/cli",
8
8
  "auth": {
@@ -95,6 +95,23 @@
95
95
  },
96
96
  "example": "cat updated.md | mdedit article update abc123 --file -"
97
97
  },
98
+ {
99
+ "name": "article_edit",
100
+ "description": "Apply anchored one-shot edits through a live collaboration session or conditional REST fallback.",
101
+ "command": "mdedit article edit <articleId> --format json",
102
+ "flags": {
103
+ "--replace <text>": "Unique text to replace (requires --with)",
104
+ "--with <text>": "Replacement text (requires --replace)",
105
+ "--ops-file <path>": "JSON array of replace, insert, or delete operations",
106
+ "--workspace <id>": "Workspace ID"
107
+ },
108
+ "exit_codes": {
109
+ "2": "ANCHOR_NOT_FOUND",
110
+ "3": "AMBIGUOUS_ANCHOR",
111
+ "4": "EDIT_CONFLICT; re-read before continuing"
112
+ },
113
+ "example": "mdedit article edit abc123 --replace 'old text' --with 'new text' --format json"
114
+ },
98
115
  {
99
116
  "name": "article_delete",
100
117
  "description": "Delete an article (non-reversible)",
@@ -104,6 +121,61 @@
104
121
  },
105
122
  "example": "mdedit article delete abc123 --yes"
106
123
  },
124
+ {
125
+ "name": "review_list",
126
+ "description": "List review comments, highlights, and suggestions from the live article session or REST fallback.",
127
+ "command": "mdedit review list <articleId> --format json",
128
+ "flags": {
129
+ "--status <status>": "Filter by review status",
130
+ "--target <file.md>": "Markdown target (default: content.md)",
131
+ "--workspace <id>": "Workspace ID"
132
+ },
133
+ "example": "mdedit review list abc123 --status open --format json"
134
+ },
135
+ {
136
+ "name": "review_add",
137
+ "description": "Add a server-authored review comment anchored to quoted text.",
138
+ "command": "mdedit review add <articleId> --quote <text> --body <text> --format json",
139
+ "flags": {
140
+ "--occurrence <n>": "One-based occurrence when the quote repeats",
141
+ "--before <text>": "Context immediately before the quote",
142
+ "--after <text>": "Context immediately after the quote",
143
+ "--target <file.md>": "Markdown target"
144
+ },
145
+ "example": "mdedit review add abc123 --quote 'claim' --body 'Needs a source.' --format json"
146
+ },
147
+ {
148
+ "name": "review_reply",
149
+ "description": "Reply to a review thread.",
150
+ "command": "mdedit review reply <articleId> --thread <reviewId> --body <text> --format json",
151
+ "example": "mdedit review reply abc123 --thread c_123 --body 'Fixed.' --format json"
152
+ },
153
+ {
154
+ "name": "review_decide",
155
+ "description": "Resolve, reopen, accept, or reject a review thread. Accept requires articles:write.",
156
+ "command": "mdedit review <resolve|reopen|accept|reject> <articleId> --thread <reviewId> --format json",
157
+ "example": "mdedit review resolve abc123 --thread c_123 --format json"
158
+ },
159
+ {
160
+ "name": "review_delete",
161
+ "description": "Delete a review item or one reply owned by the authenticated reviewer.",
162
+ "command": "mdedit review delete <articleId> --thread <reviewId> --format json",
163
+ "flags": {
164
+ "--reply <replyId>": "Delete only this reply"
165
+ },
166
+ "example": "mdedit review delete abc123 --thread c_123 --reply r_456 --format json"
167
+ },
168
+ {
169
+ "name": "suggest",
170
+ "description": "Create a safe replacement suggestion without directly changing article text.",
171
+ "command": "mdedit suggest <articleId> --quote <text> --replace <text> --format json",
172
+ "flags": {
173
+ "--note <text>": "Optional explanation",
174
+ "--occurrence <n>": "One-based occurrence when the quote repeats",
175
+ "--target <file.md>": "Markdown target"
176
+ },
177
+ "example": "mdedit suggest abc123 --quote 'teh' --replace 'the' --note 'Typo' --format json"
178
+ },
107
179
  {
108
180
  "name": "article_export",
109
181
  "description": "Export an article as a ZIP archive",
@@ -263,6 +335,15 @@
263
335
  "CONTENT=$(mdedit article get <articleId> --content-only)",
264
336
  "echo \"$MODIFIED_CONTENT\" | mdedit article update <articleId> --file -"
265
337
  ],
338
+ "anchored_article_edit": [
339
+ "mdedit article edit <articleId> --replace 'old text' --with 'new text' --format json",
340
+ "On exit 4, re-read the article before continuing"
341
+ ],
342
+ "review_article": [
343
+ "mdedit review list <articleId> --status open --format json",
344
+ "mdedit review add <articleId> --quote 'claim' --body 'Needs a source.' --format json",
345
+ "mdedit suggest <articleId> --quote 'teh' --replace 'the' --note 'Typo' --format json"
346
+ ],
266
347
  "create_article_in_folder": [
267
348
  "mdedit folder list --format json",
268
349
  "mdedit article create --title 'New Post' --folder <folderId> --file content.md --format json"
package/package.json CHANGED
@@ -1,9 +1,21 @@
1
1
  {
2
2
  "name": "mdedit-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command-line interface for mdedit.ai.",
7
+ "keywords": [
8
+ "mdedit",
9
+ "markdown",
10
+ "cli",
11
+ "markdown-editor",
12
+ "documentation",
13
+ "technical-writing",
14
+ "automation",
15
+ "ai",
16
+ "agent",
17
+ "terminal"
18
+ ],
7
19
  "license": "Apache-2.0",
8
20
  "engines": {
9
21
  "node": ">=20"
@@ -27,19 +39,22 @@
27
39
  "prepack": "yarn build"
28
40
  },
29
41
  "dependencies": {
30
- "@mdedit/sdk": "^0.2.0",
42
+ "@mdedit/agent-client": "0.1.0",
43
+ "@mdedit/sdk": "0.2.1",
31
44
  "chalk": "^5.6.2",
32
45
  "commander": "^14.0.3",
33
46
  "inquirer": "^8.2.7",
34
47
  "uuid": "^10.0.0"
35
48
  },
36
49
  "devDependencies": {
50
+ "@hocuspocus/server": "^4.2.0",
37
51
  "@types/inquirer": "^8.2.12",
38
52
  "@types/node": "^20.10.5",
39
53
  "@types/uuid": "^10.0.0",
40
54
  "tsup": "^8.0.2",
41
55
  "tsx": "^4.7.0",
42
56
  "typescript": "^5.3.3",
43
- "vitest": "^1.6.1"
57
+ "vitest": "^1.6.1",
58
+ "yjs": "^13.6.0"
44
59
  }
45
60
  }
package/skill.md CHANGED
@@ -26,7 +26,9 @@ export MDEDIT_WORKSPACE_ID=<YOUR_WORKSPACE_ID> # optional default workspace
26
26
  - **Use `-y` / `--yes`** on destructive commands to skip confirmation prompts.
27
27
  - **Pipe article content** via stdin using `--file -` or read it back with `--content-only` (stdout).
28
28
  - In `json` mode, **human-facing messages go to stderr** (stdout stays machine-parseable).
29
- - **Exit codes**: `0` = success, `1` = error. Errors are written to stderr.
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.
30
32
 
31
33
  ## Global flags
32
34
 
@@ -101,6 +103,14 @@ cat updated.md | mdedit article update <articleId> --file -
101
103
  mdedit article update <articleId> --archive
102
104
  mdedit article update <articleId> --pin
103
105
 
106
+ # One-shot live edit
107
+ mdedit article edit <articleId> --replace "old text" --with "new text"
108
+ mdedit article edit <articleId> --ops-file ops.json --format json
109
+
110
+ # Stream newline-delimited document and review events until interrupted
111
+ mdedit article watch <articleId>
112
+ mdedit article watch <articleId> --agent claude-code --poll-interval 5000
113
+
104
114
  # Delete
105
115
  mdedit article delete <articleId> --yes
106
116
 
@@ -108,11 +118,39 @@ mdedit article delete <articleId> --yes
108
118
  mdedit article export <articleId> --output article.zip
109
119
  ```
110
120
 
121
+ ## Reviewing and editing documents
122
+
123
+ Reviewer keys should use least-privilege scopes:
124
+
125
+ ```bash
126
+ mdedit apikey create --name "Review agent" --scopes articles:read,reviews:write
127
+ ```
128
+
129
+ All review mutations are server-authored and retry-safe. Suggestions do not change article
130
+ text until accepted; `review accept` therefore requires `articles:write` in addition to the
131
+ reviewer scopes.
132
+
133
+ ```bash
134
+ mdedit review list <articleId> --status open --format json
135
+ mdedit review add <articleId> --quote "some text" --body "This needs a citation."
136
+ mdedit review reply <articleId> --thread <reviewId> --body "Fixed."
137
+ mdedit review resolve <articleId> --thread <reviewId>
138
+ mdedit review reopen <articleId> --thread <reviewId>
139
+ mdedit review accept <articleId> --thread <suggestionId>
140
+ mdedit review reject <articleId> --thread <suggestionId>
141
+ mdedit review delete <articleId> --thread <reviewId>
142
+ mdedit review delete <articleId> --thread <reviewId> --reply <replyId>
143
+ mdedit suggest <articleId> --quote "teh" --replace "the" --note "Typo"
144
+ ```
145
+
146
+ When quoted text repeats, add `--occurrence <n>`, `--before <text>`, or `--after <text>`.
147
+ Use `--target <file.md>` for package targets other than `content.md`.
148
+
111
149
  ### api-key
112
150
 
113
151
  ```bash
114
152
  mdedit apikey list
115
- mdedit apikey create --name "CI/CD Key" --description "Used in pipeline"
153
+ mdedit apikey create --name "CI/CD Key" --description "Used in pipeline" --scopes articles:read,articles:write
116
154
  mdedit apikey create --name "30-day key" --expires 30
117
155
  mdedit apikey revoke <keyId> --yes
118
156
  ```
@@ -138,6 +176,55 @@ mdedit skill install --global # install globally (home directory
138
176
 
139
177
  ## Common agent workflows
140
178
 
179
+ ### Workflow: edit article text directly
180
+
181
+ Use `article edit` for anchored changes so collaborative documents join the live room and
182
+ non-collaborative documents use a conditional REST commit. A simple replacement must match
183
+ exactly once:
184
+
185
+ ```bash
186
+ mdedit article edit <articleId> \
187
+ --replace "The old sentence." \
188
+ --with "The revised sentence." \
189
+ --format json
190
+ ```
191
+
192
+ For context, occurrences, headings, ranges, or multiple sequential edits, pass a non-empty
193
+ JSON array to `--ops-file`:
194
+
195
+ ```json
196
+ [
197
+ {
198
+ "type": "replace",
199
+ "anchor": { "quote": "teh", "occurrence": 2 },
200
+ "text": "the"
201
+ },
202
+ {
203
+ "type": "insert",
204
+ "anchor": { "afterHeading": "## Setup" },
205
+ "text": "\nNew setup note.\n"
206
+ }
207
+ ]
208
+ ```
209
+
210
+ Quote anchors also accept `context: { before, after }`. Other anchors are
211
+ `beforeHeading`, `inSection`, and `range: { from, to }`. On exit `2` or `3`, revise the
212
+ anchor and retry. On exit `4`, the edit may have landed; re-read the article before making
213
+ another change.
214
+
215
+ ### Workflow: react to document and review changes
216
+
217
+ `article watch` writes exactly one JSON object per stdout line. It begins with
218
+ `session.ready`, then emits `article.updated`, `review.event`, and `review.updated`.
219
+ Use the stream as the input to a long-running agent loop and stop it with `SIGINT` or
220
+ `SIGTERM`; the CLI closes the article session before exiting.
221
+
222
+ ```bash
223
+ mdedit article watch <articleId> | while IFS= read -r event; do
224
+ printf '%s\n' "$event" | jq -c '{type, articleId, event}'
225
+ done
226
+ ```
227
+
141
228
  ### Workflow: read an article and update its content
142
229
 
143
230
  ```bash
@@ -197,7 +284,14 @@ In `json` mode all human-readable messages go to **stderr** so stdout stays mach
197
284
 
198
285
  ## Error handling
199
286
 
200
- Errors write a descriptive message to **stderr** and exit with code `1`.
287
+ General errors write a descriptive message to **stderr** and exit with code `1`.
288
+ Typed `article edit` failures use these stable codes:
289
+
290
+ | Exit | Error code | Meaning |
291
+ |------|------------|---------|
292
+ | 2 | `ANCHOR_NOT_FOUND` | No anchor match; nothing was applied |
293
+ | 3 | `AMBIGUOUS_ANCHOR` | Multiple matches; add occurrence or context |
294
+ | 4 | `EDIT_CONFLICT` | Concurrent edits overlapped or a conditional commit raced |
201
295
 
202
296
  Common errors and fixes:
203
297