mdedit-cli 0.4.2 → 0.4.3

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
@@ -54,13 +54,13 @@ mdedit info
54
54
  mdedit health
55
55
  ```
56
56
 
57
- ## One-shot article edits
57
+ ## One-shot document edits
58
58
 
59
- Apply a unique text replacement through the same article session used by live collaborators:
59
+ Apply a unique text replacement through the same document session used by live collaborators:
60
60
 
61
61
  ```bash
62
- mdedit article edit <articleId> --replace "old text" --with "new text"
63
- mdedit article edit <articleId> --ops-file ops.json --format json
62
+ mdedit document edit <documentId> --replace "old text" --with "new text"
63
+ mdedit document edit <documentId> --ops-file ops.json --format json
64
64
  ```
65
65
 
66
66
  An ops file is a non-empty JSON array of `replace`, `insert`, or `delete` operations with
@@ -75,18 +75,18 @@ Use a key with `publishing:write` to create a public `mded.it` link. New links a
75
75
  Use `--snapshot` for a frozen artifact that changes only when you publish again.
76
76
 
77
77
  ```bash
78
- mdedit article publish <articleId>
79
- mdedit article publish <articleId> --snapshot
80
- mdedit article publish <articleId> --slug my-document
81
- mdedit article publish-status <articleId> --format json
82
- mdedit article unpublish <articleId> --yes
78
+ mdedit document publish <documentId>
79
+ mdedit document publish <documentId> --snapshot
80
+ mdedit document publish <documentId> --slug my-document
81
+ mdedit document publish-status <documentId> --format json
82
+ mdedit document unpublish <documentId> --yes
83
83
  ```
84
84
 
85
85
  Create a document from Markdown and publish a Live link in one command, without a
86
86
  confirmation flag:
87
87
 
88
88
  ```bash
89
- mdedit article create \
89
+ mdedit document create \
90
90
  --file document.md \
91
91
  --publish
92
92
  ```
@@ -101,42 +101,44 @@ mode. Use `--live` or `--snapshot` to switch deliberately; the URL does not chan
101
101
  Links created before Live mode remain Snapshots until explicitly switched:
102
102
 
103
103
  ```bash
104
- mdedit article publish <articleId> --live
104
+ mdedit document publish <documentId> --live
105
105
  ```
106
106
 
107
- If article creation succeeds but publishing fails, the article is kept private and
108
- the command reports its article ID.
107
+ If document creation succeeds but publishing fails, the document is kept private and
108
+ the command reports its API `articleId`.
109
109
 
110
110
  ## Review commands
111
111
 
112
112
  Review agents can comment and suggest with `articles:read,reviews:write`; accepting a
113
- suggestion also requires `articles:write` because it changes article text.
113
+ suggestion also requires `articles:write` because it changes document text.
114
114
 
115
115
  ```bash
116
- mdedit review list <articleId> --status open --format json
117
- mdedit review add <articleId> --quote "claim" --body "Needs a source."
118
- mdedit review reply <articleId> --thread <reviewId> --body "Fixed."
119
- mdedit review resolve <articleId> --thread <reviewId>
120
- mdedit suggest <articleId> --quote "teh" --replace "the" --note "Typo"
116
+ mdedit review list <documentId> --status open --format json
117
+ mdedit review add <documentId> --quote "claim" --body "Needs a source."
118
+ mdedit review reply <documentId> --thread <reviewId> --body "Fixed."
119
+ mdedit review resolve <documentId> --thread <reviewId>
120
+ mdedit suggest <documentId> --quote "teh" --replace "the" --note "Typo"
121
121
  ```
122
122
 
123
123
  One-shot review commands use the REST review resources directly, so listing or commenting
124
124
  does not open a metered collaboration WebSocket. Mutations always use the
125
125
  server-authoritative `review-commands` API.
126
126
 
127
- ## Watch an article
127
+ ## Watch a document
128
128
 
129
- Keep an article session open and stream newline-delimited JSON for agent loops:
129
+ Keep a document session open and stream newline-delimited JSON for agent loops:
130
130
 
131
131
  ```bash
132
- mdedit article watch <articleId>
133
- mdedit article watch <articleId> --workspace <workspaceId> --agent claude-code
134
- mdedit article watch <articleId> --poll-interval 5000
132
+ mdedit document watch <documentId>
133
+ mdedit document watch <documentId> --workspace <workspaceId> --agent claude-code
134
+ mdedit document watch <documentId> --poll-interval 5000
135
135
  ```
136
136
 
137
137
  Each stdout line is one complete JSON event. The stream starts with `session.ready`,
138
- then reports article changes, review history events, and review snapshots. `Ctrl+C`
139
- closes the live session cleanly. Non-collaborative articles use REST polling.
138
+ then reports document changes, review history events, and review snapshots. `Ctrl+C`
139
+ closes the live session cleanly. Non-collaborative documents use REST polling.
140
+
141
+ `mdedit article` remains available as a deprecated compatibility alias. New scripts should use `mdedit document`.
140
142
 
141
143
  ## Agent / AI tool integration
142
144
 
package/dist/index.js CHANGED
@@ -1752,7 +1752,7 @@ var ArticleCreateContentError = class extends Error {
1752
1752
  constructor(args) {
1753
1753
  const contentError = args.contentError instanceof Error ? args.contentError.message : String(args.contentError);
1754
1754
  const compensationError = args.compensationError instanceof Error ? args.compensationError.message : args.compensationError === void 0 ? void 0 : String(args.compensationError);
1755
- super(args.compensated ? `Initial article content could not be saved; the created article ${args.articleId} was rolled back.` : `Initial article content could not be saved and article ${args.articleId} could not be rolled back.`);
1755
+ super(args.compensated ? `Initial document content could not be saved; the created document ${args.articleId} was rolled back.` : `Initial document content could not be saved and document ${args.articleId} could not be rolled back.`);
1756
1756
  this.name = "ArticleCreateContentError";
1757
1757
  this.articleId = args.articleId;
1758
1758
  this.compensated = args.compensated;
@@ -1959,14 +1959,20 @@ async function readEditOperations(filePath) {
1959
1959
  }
1960
1960
  return parsed;
1961
1961
  }
1962
- function createArticleCommands() {
1963
- const article = new Command("article").description("Manage articles").action(() => article.help());
1964
- article.command("list").description("List all articles").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-f, --folder <folderId>", "Filter by folder ID").option("-l, --limit <number>", "Limit number of results (client-side)", "50").option("-o, --offset <number>", "Offset for pagination (client-side)", "0").option("--full", "Show full article objects (all fields)").action(async (options) => {
1962
+ function createDocumentCommand(commandName, deprecated) {
1963
+ const commandPath = `mdedit ${commandName}`;
1964
+ const article = new Command(commandName).description(deprecated ? "Deprecated alias for document commands" : "Manage documents").action(() => article.help());
1965
+ if (deprecated) {
1966
+ article.hook("preAction", () => {
1967
+ output.warning("`mdedit article` is deprecated. Use `mdedit document` instead.");
1968
+ });
1969
+ }
1970
+ article.command("list").description("List all documents").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-f, --folder <folderId>", "Filter by folder ID").option("-l, --limit <number>", "Limit number of results (client-side)", "50").option("-o, --offset <number>", "Offset for pagination (client-side)", "0").option("--full", "Show full document objects (all fields)").action(async (options) => {
1965
1971
  requireApiKey();
1966
1972
  const client = getApiClient();
1967
1973
  const workspaceId = requireWorkspaceId(options.workspace);
1968
1974
  const articles = options.folder ? await client.article.listByFolder(workspaceId, options.folder) : await client.article.list(workspaceId);
1969
- output.header("Articles");
1975
+ output.header("Documents");
1970
1976
  const offset = Number(options.offset) || 0;
1971
1977
  const limit = Number(options.limit) || articles.length;
1972
1978
  const slice = articles.slice(offset, offset + limit);
@@ -1976,7 +1982,7 @@ function createArticleCommands() {
1976
1982
  }
1977
1983
  output.output(slice.map(presentArticleListRow));
1978
1984
  });
1979
- article.command("get <articleId>").description("Get article details").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-o, --output <file>", "Save article content (markdown) to this file path; use - for stdout").option("--content-only", "Print only the article markdown content to stdout (useful for piping / AI agents)").option("--include-content", "Include the article markdown content in the output object").option("--full", "Show full article object (all fields, including nested metadata)").action(async (articleId, options) => {
1985
+ article.command("get <documentId>").description("Get document details").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-o, --output <file>", "Save document content (markdown) to this file path; use - for stdout").option("--content-only", "Print only the document markdown content to stdout (useful for piping / AI agents)").option("--include-content", "Include the document markdown content in the output object").option("--full", "Show full document object (all fields, including nested metadata)").action(async (articleId, options) => {
1980
1986
  requireApiKey();
1981
1987
  const client = getApiClient();
1982
1988
  const workspaceId = requireWorkspaceId(options.workspace);
@@ -1991,20 +1997,20 @@ function createArticleCommands() {
1991
1997
  process.stdout.write(content);
1992
1998
  } else {
1993
1999
  await writeFile(options.output, content, "utf-8");
1994
- output.success(`Article content saved to ${options.output}`);
2000
+ output.success(`Document content saved to ${options.output}`);
1995
2001
  }
1996
2002
  return;
1997
2003
  }
1998
- output.header(`Article: ${articleId}`);
2004
+ output.header(`Document: ${articleId}`);
1999
2005
  const wantsFull = Boolean(options.full) || Boolean(options.includeContent);
2000
2006
  if (output.isJson() || wantsFull) {
2001
2007
  output.output(result);
2002
2008
  return;
2003
2009
  }
2004
2010
  output.output(presentArticleDetails(result));
2005
- output.info("Hint: use `mdedit article get <articleId> --content-only` to print markdown, or `--include-content` to include it in the output.");
2011
+ output.info(`Hint: use \`${commandPath} get <documentId> --content-only\` to print markdown, or \`--include-content\` to include it in the output.`);
2006
2012
  });
2007
- article.command("create").description("Create a new article").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-i, --id <articleId>", "Article ID (defaults to a UUID)").option("-t, --title <title>", "Article title").option("-f, --folder <folderId>", "Folder ID").option("-c, --collaborative", "Enable collaborative editing").option("--file <path>", "Read initial article content from a file (use - for stdin)").option("--content <text>", "Set initial article content as an inline string").option("--publish", "Publish the created article to a live public mded.it link").option("--snapshot", "Publish a frozen snapshot instead of a live link (requires --publish)").option("--live", "Explicitly publish a live-updating link (requires --publish)").option("--slug <slug>", "Custom public-link slug (requires --publish)").option("--seo-title <title>", "SEO/social title for the public page (requires --publish)").option("--seo-description <description>", "SEO/social description for the public page (requires --publish)").addOption(new Option("-y, --yes").hideHelp()).action(async (options) => {
2013
+ article.command("create").description("Create a new document").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-i, --id <documentId>", "Document ID (defaults to a UUID)").option("-t, --title <title>", "Document title").option("-f, --folder <folderId>", "Folder ID").option("-c, --collaborative", "Enable collaborative editing").option("--file <path>", "Read initial document content from a file (use - for stdin)").option("--content <text>", "Set initial document content as an inline string").option("--publish", "Publish the created document to a live public mded.it link").option("--snapshot", "Publish a frozen snapshot instead of a live link (requires --publish)").option("--live", "Explicitly publish a live-updating link (requires --publish)").option("--slug <slug>", "Custom public-link slug (requires --publish)").option("--seo-title <title>", "SEO/social title for the public page (requires --publish)").option("--seo-description <description>", "SEO/social description for the public page (requires --publish)").addOption(new Option("-y, --yes").hideHelp()).action(async (options) => {
2008
2014
  requireAuthentication();
2009
2015
  const credentialProvider = getAgentCredentialProvider();
2010
2016
  const client = getApiClient();
@@ -2028,7 +2034,7 @@ function createArticleCommands() {
2028
2034
  {
2029
2035
  type: "input",
2030
2036
  name: "title",
2031
- message: "Article title:",
2037
+ message: "Document title:",
2032
2038
  validate: (input) => input.length > 0 || "Title is required"
2033
2039
  }
2034
2040
  ]);
@@ -2103,8 +2109,8 @@ function createArticleCommands() {
2103
2109
  });
2104
2110
  }
2105
2111
  }
2106
- output.success("Article created successfully");
2107
- if (contentText !== null) output.success("Article content uploaded");
2112
+ output.success("Document created successfully");
2113
+ if (contentText !== null) output.success("Document content uploaded");
2108
2114
  if (!options.publish) {
2109
2115
  output.output(created);
2110
2116
  return;
@@ -2115,7 +2121,7 @@ function createArticleCommands() {
2115
2121
  articleId,
2116
2122
  publishRequest(options, "live")
2117
2123
  );
2118
- output.success("Article published publicly");
2124
+ output.success("Document published publicly");
2119
2125
  output.output({
2120
2126
  ...created ?? { articleId, workspaceId },
2121
2127
  publication
@@ -2123,11 +2129,11 @@ function createArticleCommands() {
2123
2129
  } catch (error) {
2124
2130
  const message = error instanceof Error ? error.message : String(error);
2125
2131
  throw new Error(
2126
- `Article ${articleId} was created and kept, but publishing failed: ${message}`
2132
+ `Document ${articleId} was created and kept, but publishing failed: ${message}`
2127
2133
  );
2128
2134
  }
2129
2135
  });
2130
- article.command("update <articleId>").description("Update an article").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-t, --title <title>", "New title").option("--archive", "Archive the article").option("--pin", "Pin the article").option("--file <path>", "Update article content from a file (use - for stdin)").option("--content <text>", "Update article content as an inline string").action(async (articleId, options) => {
2136
+ article.command("update <documentId>").description("Update a document").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-t, --title <title>", "New title").option("--archive", "Archive the document").option("--pin", "Pin the document").option("--file <path>", "Update document content from a file (use - for stdin)").option("--content <text>", "Update document content as an inline string").action(async (articleId, options) => {
2131
2137
  requireApiKey();
2132
2138
  const client = getApiClient();
2133
2139
  const workspaceId = requireWorkspaceId(options.workspace);
@@ -2143,7 +2149,7 @@ function createArticleCommands() {
2143
2149
  else if (options.file) contentText = await readContentFromFile(options.file);
2144
2150
  if (contentText === null && Object.keys(body).length > 0) {
2145
2151
  const result = await client.article.update(workspaceId, { articleId, ...body });
2146
- output.success("Article updated successfully");
2152
+ output.success("Document updated successfully");
2147
2153
  output.output(result);
2148
2154
  }
2149
2155
  if (contentText !== null) {
@@ -2157,14 +2163,14 @@ function createArticleCommands() {
2157
2163
  isArchived: body.isArchived,
2158
2164
  isPinned: body.isPinned
2159
2165
  });
2160
- output.success("Article content updated");
2166
+ output.success("Document content updated");
2161
2167
  output.output(result);
2162
2168
  }
2163
2169
  if (Object.keys(body).length === 0 && contentText === null) {
2164
2170
  output.warning("No changes provided. Use --title, --archive, --pin, --file, or --content.");
2165
2171
  }
2166
2172
  });
2167
- article.command("publish <articleId>").description("Publish or update an article at a public mded.it link").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("--slug <slug>", "Custom public-link slug").option("--seo-title <title>", "SEO/social title for the public page").option("--seo-description <description>", "SEO/social description for the public page").option("--snapshot", "Create or switch to a frozen snapshot").option("--live", "Create or switch to a live-updating public link").addOption(new Option("-y, --yes").hideHelp()).action(async (articleId, options) => {
2173
+ article.command("publish <documentId>").description("Publish or update a document at a public mded.it link").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("--slug <slug>", "Custom public-link slug").option("--seo-title <title>", "SEO/social title for the public page").option("--seo-description <description>", "SEO/social description for the public page").option("--snapshot", "Create or switch to a frozen snapshot").option("--live", "Create or switch to a live-updating public link").addOption(new Option("-y, --yes").hideHelp()).action(async (articleId, options) => {
2168
2174
  requireApiKey();
2169
2175
  const client = getApiClient();
2170
2176
  const workspaceId = requireWorkspaceId(options.workspace);
@@ -2173,16 +2179,16 @@ function createArticleCommands() {
2173
2179
  articleId,
2174
2180
  agentPublishRequest(options)
2175
2181
  );
2176
- output.success("Article published publicly");
2182
+ output.success("Document published publicly");
2177
2183
  output.output(result);
2178
2184
  });
2179
- article.command("publish-status <articleId>").description("Show public publishing status for an article").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").action(async (articleId, options) => {
2185
+ article.command("publish-status <documentId>").description("Show public publishing status for a document").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").action(async (articleId, options) => {
2180
2186
  requireApiKey();
2181
2187
  const client = getApiClient();
2182
2188
  const workspaceId = requireWorkspaceId(options.workspace);
2183
2189
  output.output(await client.publish.status(workspaceId, articleId));
2184
2190
  });
2185
- article.command("unpublish <articleId>").description("Disable an article public link").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-y, --yes", "Skip confirmation").action(async (articleId, options) => {
2191
+ article.command("unpublish <documentId>").description("Disable a document public link").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-y, --yes", "Skip confirmation").action(async (articleId, options) => {
2186
2192
  requireApiKey();
2187
2193
  const client = getApiClient();
2188
2194
  const workspaceId = requireWorkspaceId(options.workspace);
@@ -2191,7 +2197,7 @@ function createArticleCommands() {
2191
2197
  {
2192
2198
  type: "confirm",
2193
2199
  name: "confirm",
2194
- message: `Unpublish article ${articleId}? Its public link will stop working.`,
2200
+ message: `Unpublish document ${articleId}? Its public link will stop working.`,
2195
2201
  default: false
2196
2202
  }
2197
2203
  ]);
@@ -2201,10 +2207,10 @@ function createArticleCommands() {
2201
2207
  }
2202
2208
  }
2203
2209
  const result = await client.publish.unpublish(workspaceId, articleId);
2204
- output.success("Article unpublished");
2210
+ output.success("Document unpublished");
2205
2211
  output.output(result);
2206
2212
  });
2207
- article.command("watch <articleId>").description("Stream article and review changes as newline-delimited JSON").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("--agent <name>", "Agent presence name", "mdedit-cli").option("--poll-interval <milliseconds>", "REST fallback polling interval", "2000").action(async (articleId, options) => {
2213
+ article.command("watch <documentId>").description("Stream document and review changes as newline-delimited JSON").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("--agent <name>", "Agent presence name", "mdedit-cli").option("--poll-interval <milliseconds>", "REST fallback polling interval", "2000").action(async (articleId, options) => {
2208
2214
  requireAuthentication();
2209
2215
  const credentialProvider = getAgentCredentialProvider();
2210
2216
  const workspaceId = requireWorkspaceId(options.workspace);
@@ -2238,7 +2244,7 @@ function createArticleCommands() {
2238
2244
  await session?.close();
2239
2245
  }
2240
2246
  });
2241
- article.command("edit <articleId>").description("Apply an anchored one-shot edit through an agent article session").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("--replace <text>", "Replace the unique matching text").option("--with <text>", "Replacement text (used with --replace)").option("--ops-file <path>", "Read a JSON array of edit operations from a file").action(async (articleId, options) => {
2247
+ article.command("edit <documentId>").description("Apply an anchored one-shot edit through an agent document session").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("--replace <text>", "Replace the unique matching text").option("--with <text>", "Replacement text (used with --replace)").option("--ops-file <path>", "Read a JSON array of edit operations from a file").action(async (articleId, options) => {
2242
2248
  requireAuthentication();
2243
2249
  const credentialProvider = getAgentCredentialProvider();
2244
2250
  const workspaceId = requireWorkspaceId(options.workspace);
@@ -2274,14 +2280,14 @@ function createArticleCommands() {
2274
2280
  }
2275
2281
  }
2276
2282
  }
2277
- if (!session || !result) throw new Error("Article edit did not return a result.");
2283
+ if (!session || !result) throw new Error("Document edit did not return a result.");
2278
2284
  output.output({ articleId, mode: session.mode, ...result });
2279
2285
  if (result.conflicts.length > 0) {
2280
- output.warning("The edit was applied with overlapping remote changes; re-read the article before continuing.");
2286
+ output.warning("The edit was applied with overlapping remote changes; re-read the document before continuing.");
2281
2287
  process.exitCode = CLI_EXIT_CODES.EDIT_CONFLICT;
2282
2288
  }
2283
2289
  });
2284
- article.command("delete <articleId>").description("Delete an article").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-y, --yes", "Skip confirmation").action(async (articleId, options) => {
2290
+ article.command("delete <documentId>").description("Delete a document").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-y, --yes", "Skip confirmation").action(async (articleId, options) => {
2285
2291
  requireApiKey();
2286
2292
  const client = getApiClient();
2287
2293
  const workspaceId = requireWorkspaceId(options.workspace);
@@ -2290,7 +2296,7 @@ function createArticleCommands() {
2290
2296
  {
2291
2297
  type: "confirm",
2292
2298
  name: "confirm",
2293
- message: `Are you sure you want to delete article ${articleId}?`,
2299
+ message: `Are you sure you want to delete document ${articleId}?`,
2294
2300
  default: false
2295
2301
  }
2296
2302
  ]);
@@ -2300,19 +2306,29 @@ function createArticleCommands() {
2300
2306
  }
2301
2307
  }
2302
2308
  await client.article.delete(workspaceId, articleId);
2303
- output.success("Article deleted successfully");
2309
+ output.success("Document deleted successfully");
2304
2310
  });
2305
- article.command("export <articleId>").description("Export article as ZIP").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option("-o, --output <path>", "Output file path", "./article.zip").action(async (articleId, options) => {
2311
+ article.command("export <documentId>").description("Export document as ZIP").option("-w, --workspace <workspaceId>", "Workspace ID (or set default via config)").option(
2312
+ "-o, --output <path>",
2313
+ "Output file path",
2314
+ commandName === "article" ? "./article.zip" : "./document.zip"
2315
+ ).action(async (articleId, options) => {
2306
2316
  requireApiKey();
2307
2317
  const client = getApiClient();
2308
2318
  const workspaceId = requireWorkspaceId(options.workspace);
2309
- output.info(`Exporting article ${articleId}...`);
2319
+ output.info(`Exporting document ${articleId}...`);
2310
2320
  const zipBlob = await client.article.exportZip(workspaceId, articleId);
2311
2321
  await writeBlobToFile(zipBlob, options.output);
2312
2322
  output.success(`Exported to ${options.output}`);
2313
2323
  });
2314
2324
  return article;
2315
2325
  }
2326
+ function createDocumentCommands() {
2327
+ return createDocumentCommand("document", false);
2328
+ }
2329
+ function createArticleCommands() {
2330
+ return createDocumentCommand("article", true);
2331
+ }
2316
2332
 
2317
2333
  // src/commands/workspace.ts
2318
2334
  init_output();
@@ -3016,8 +3032,8 @@ function presentReviewItem(item) {
3016
3032
  };
3017
3033
  }
3018
3034
  function createReviewCommands() {
3019
- const review = new Command7("review").description("Review an article through server-authoritative agent commands").action(() => review.help());
3020
- addCommon(review.command("list <articleId>").description("List article review items").option("-s, --status <status>", "Filter by review status")).action(async (articleId, options) => {
3035
+ const review = new Command7("review").description("Review a document through server-authoritative agent commands").action(() => review.help());
3036
+ addCommon(review.command("list <documentId>").description("List document review items").option("-s, --status <status>", "Filter by review status")).action(async (articleId, options) => {
3021
3037
  const workspaceId = requireWorkspaceId(options.workspace);
3022
3038
  const { result } = await withReview(articleId, workspaceId, (reviewSession) => reviewSession.list({
3023
3039
  status: options.status,
@@ -3025,7 +3041,7 @@ function createReviewCommands() {
3025
3041
  }));
3026
3042
  output.output(output.isJson() ? result : result.map(presentReviewItem));
3027
3043
  });
3028
- addQuote(review.command("add <articleId>").description("Add a comment anchored to quoted text").requiredOption("-b, --body <text>", "Comment body")).action(async (articleId, options) => {
3044
+ addQuote(review.command("add <documentId>").description("Add a comment anchored to quoted text").requiredOption("-b, --body <text>", "Comment body")).action(async (articleId, options) => {
3029
3045
  const workspaceId = requireWorkspaceId(options.workspace);
3030
3046
  const { mode, result } = await withReview(articleId, workspaceId, (reviewSession) => reviewSession.addComment({
3031
3047
  anchor: quoteAnchor(options),
@@ -3034,7 +3050,7 @@ function createReviewCommands() {
3034
3050
  }));
3035
3051
  output.output({ articleId, mode, ...result });
3036
3052
  });
3037
- addCommon(review.command("reply <articleId>").description("Reply to a comment or suggestion thread").requiredOption("--thread <reviewId>", "Review thread ID").requiredOption("-b, --body <text>", "Reply body")).action(async (articleId, options) => {
3053
+ addCommon(review.command("reply <documentId>").description("Reply to a comment or suggestion thread").requiredOption("--thread <reviewId>", "Review thread ID").requiredOption("-b, --body <text>", "Reply body")).action(async (articleId, options) => {
3038
3054
  const workspaceId = requireWorkspaceId(options.workspace);
3039
3055
  const { mode, result } = await withReview(articleId, workspaceId, (reviewSession) => reviewSession.reply({
3040
3056
  threadId: options.thread,
@@ -3044,7 +3060,7 @@ function createReviewCommands() {
3044
3060
  output.output({ articleId, mode, ...result });
3045
3061
  });
3046
3062
  for (const verb of ["resolve", "reopen", "accept", "reject"]) {
3047
- addCommon(review.command(`${verb} <articleId>`).description(`${verb[0].toUpperCase()}${verb.slice(1)} a review thread`).requiredOption("--thread <reviewId>", "Review thread ID")).action(async (articleId, options) => {
3063
+ addCommon(review.command(`${verb} <documentId>`).description(`${verb[0].toUpperCase()}${verb.slice(1)} a review thread`).requiredOption("--thread <reviewId>", "Review thread ID")).action(async (articleId, options) => {
3048
3064
  const workspaceId = requireWorkspaceId(options.workspace);
3049
3065
  const { mode, result } = await withReview(articleId, workspaceId, (reviewSession) => reviewSession[verb]({
3050
3066
  threadId: options.thread,
@@ -3053,7 +3069,7 @@ function createReviewCommands() {
3053
3069
  output.output({ articleId, mode, ...result });
3054
3070
  });
3055
3071
  }
3056
- addCommon(review.command("delete <articleId>").description("Delete a review item or one of its replies").requiredOption("--thread <reviewId>", "Review thread ID").option("--reply <replyId>", "Reply ID; omit to delete the whole review item")).action(async (articleId, options) => {
3072
+ addCommon(review.command("delete <documentId>").description("Delete a review item or one of its replies").requiredOption("--thread <reviewId>", "Review thread ID").option("--reply <replyId>", "Reply ID; omit to delete the whole review item")).action(async (articleId, options) => {
3057
3073
  const workspaceId = requireWorkspaceId(options.workspace);
3058
3074
  const { mode, result } = await withReview(articleId, workspaceId, (reviewSession) => reviewSession.delete({
3059
3075
  threadId: options.thread,
@@ -3065,7 +3081,7 @@ function createReviewCommands() {
3065
3081
  return review;
3066
3082
  }
3067
3083
  function createSuggestCommand() {
3068
- return addQuote(new Command7("suggest").description("Suggest a replacement anchored to quoted text").argument("<articleId>", "Article ID").requiredOption("-r, --replace <text>", "Replacement text").option("-n, --note <text>", "Optional explanation for the suggestion")).action(async (articleId, options) => {
3084
+ return addQuote(new Command7("suggest").description("Suggest a replacement anchored to quoted text").argument("<documentId>", "Document ID").requiredOption("-r, --replace <text>", "Replacement text").option("-n, --note <text>", "Optional explanation for the suggestion")).action(async (articleId, options) => {
3069
3085
  const workspaceId = requireWorkspaceId(options.workspace);
3070
3086
  const { mode, result } = await withReview(articleId, workspaceId, (reviewSession) => reviewSession.suggest({
3071
3087
  anchor: quoteAnchor(options),
@@ -3146,6 +3162,7 @@ program.name("mdedit").description("MDEdit.ai CLI - Command-line interface for t
3146
3162
  if (opts.workspace) process.env.MDEDIT_WORKSPACE_ID = opts.workspace;
3147
3163
  if (opts.debug) process.env.MDEDIT_DEBUG = "1";
3148
3164
  });
3165
+ program.addCommand(createDocumentCommands());
3149
3166
  program.addCommand(createArticleCommands());
3150
3167
  program.addCommand(createWorkspaceCommands());
3151
3168
  program.addCommand(createFolderCommands());
@@ -3257,7 +3274,7 @@ async function main() {
3257
3274
  } else {
3258
3275
  output.error(`API request failed (${err.status}): ${err.message}`);
3259
3276
  if (details?.requiredScope === "articles:write") {
3260
- output.info("Hint: accepting a suggestion changes article text and requires an API key with articles:write.");
3277
+ output.info("Hint: accepting a suggestion changes document text and requires an API key with articles:write.");
3261
3278
  } else if (err.status === 403) {
3262
3279
  output.info("Hint: review keys need articles:read,reviews:write; accepting suggestions additionally needs articles:write.");
3263
3280
  }