mdedit-cli 0.1.2 → 0.2.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/openclaw.json ADDED
@@ -0,0 +1,279 @@
1
+ {
2
+ "schema_version": "1.0",
3
+ "name": "mdedit",
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.",
6
+ "homepage_url": "https://mdedit.ai",
7
+ "docs_url": "https://docs.mdedit.ai/cli",
8
+ "auth": {
9
+ "type": "env",
10
+ "env_var": "MDEDIT_API_KEY",
11
+ "instructions": "Set MDEDIT_API_KEY to your mdedit.ai API key. Get one at https://docs.mdedit.ai/api-keys"
12
+ },
13
+ "setup": {
14
+ "command": "npm install -g mdedit-cli",
15
+ "verify": "mdedit --version",
16
+ "configure": "mdedit config login --api-key $MDEDIT_API_KEY"
17
+ },
18
+ "global_flags": {
19
+ "--format <plain|table|json>": "Output format. Use json for agents (human messages go to stderr).",
20
+ "--api-key <key>": "Override API key for this invocation (or set MDEDIT_API_KEY).",
21
+ "--workspace <id>": "Override default workspace for this invocation (or set MDEDIT_WORKSPACE_ID).",
22
+ "--api-url <url>": "Override API base URL (default: https://apiv2.mdedit.ai).",
23
+ "--local": "Use local API at http://localhost:8080.",
24
+ "--debug": "Print debug info and stack traces."
25
+ },
26
+ "tools": [
27
+ {
28
+ "name": "config_show",
29
+ "description": "Show current CLI configuration (effective values including env overrides).",
30
+ "command": "mdedit config show --format json",
31
+ "example": "mdedit config show --format json"
32
+ },
33
+ {
34
+ "name": "config_use_workspace",
35
+ "description": "Set the default workspace for workspace-scoped commands.",
36
+ "command": "mdedit config use-workspace <workspaceId>",
37
+ "example": "mdedit config use-workspace ws-123"
38
+ },
39
+ {
40
+ "name": "article_list",
41
+ "description": "List all articles in a workspace, optionally filtered by folder",
42
+ "command": "mdedit article list --format json",
43
+ "flags": {
44
+ "--workspace <id>": "Workspace ID",
45
+ "--folder <id>": "Filter by folder ID",
46
+ "--limit <n>": "Limit results (client-side)",
47
+ "--offset <n>": "Offset for pagination"
48
+ },
49
+ "example": "mdedit article list --format json --limit 20"
50
+ },
51
+ {
52
+ "name": "article_get_metadata",
53
+ "description": "Get article metadata (markdown content is omitted unless requested).",
54
+ "command": "mdedit article get <articleId> --format json",
55
+ "flags": {
56
+ "--include-content": "Include markdown content in the output object",
57
+ "--full": "Show full raw article object",
58
+ "--workspace <id>": "Workspace ID"
59
+ },
60
+ "example": "mdedit article get abc123 --format json"
61
+ },
62
+ {
63
+ "name": "article_get_markdown",
64
+ "description": "Print only the article markdown to stdout (useful for piping / agents).",
65
+ "command": "mdedit article get <articleId> --content-only",
66
+ "flags": {
67
+ "--workspace <id>": "Workspace ID"
68
+ },
69
+ "example": "mdedit article get abc123 --content-only"
70
+ },
71
+ {
72
+ "name": "article_create",
73
+ "description": "Create a new article, optionally with initial markdown content from file or inline string",
74
+ "command": "mdedit article create --title <title> --format json",
75
+ "flags": {
76
+ "--title <title>": "Article title (required)",
77
+ "--folder <id>": "Place in a folder",
78
+ "--file <path>": "Read initial content from file (use - for stdin)",
79
+ "--content <text>": "Inline content string",
80
+ "--workspace <id>": "Workspace ID"
81
+ },
82
+ "example": "echo '# Hello' | mdedit article create --title 'My Post' --file - --format json"
83
+ },
84
+ {
85
+ "name": "article_update",
86
+ "description": "Update an article's title, metadata, or markdown content",
87
+ "command": "mdedit article update <articleId> --format json",
88
+ "flags": {
89
+ "--title <title>": "New title",
90
+ "--file <path>": "Replace content from file (use - for stdin)",
91
+ "--content <text>": "Replace content with inline string",
92
+ "--archive": "Archive the article",
93
+ "--pin": "Pin the article",
94
+ "--workspace <id>": "Workspace ID"
95
+ },
96
+ "example": "cat updated.md | mdedit article update abc123 --file -"
97
+ },
98
+ {
99
+ "name": "article_delete",
100
+ "description": "Delete an article (non-reversible)",
101
+ "command": "mdedit article delete <articleId> --yes",
102
+ "flags": {
103
+ "--yes": "Skip confirmation prompt (required for non-interactive agents)"
104
+ },
105
+ "example": "mdedit article delete abc123 --yes"
106
+ },
107
+ {
108
+ "name": "article_export",
109
+ "description": "Export an article as a ZIP archive",
110
+ "command": "mdedit article export <articleId>",
111
+ "flags": {
112
+ "--output <path>": "Output file path (default: article.zip)"
113
+ },
114
+ "example": "mdedit article export abc123 --output my-article.zip"
115
+ },
116
+ {
117
+ "name": "folder_list",
118
+ "description": "List folders in a workspace",
119
+ "command": "mdedit folder list --format json",
120
+ "flags": {
121
+ "--workspace <id>": "Workspace ID",
122
+ "--include-deleted": "Include deleted/tombstoned folders"
123
+ },
124
+ "example": "mdedit folder list --format json"
125
+ },
126
+ {
127
+ "name": "folder_get",
128
+ "description": "Get details of a folder.",
129
+ "command": "mdedit folder get <folderId> --format json",
130
+ "flags": {
131
+ "--workspace <id>": "Workspace ID",
132
+ "--full": "Show full raw folder object"
133
+ },
134
+ "example": "mdedit folder get fld-123 --format json"
135
+ },
136
+ {
137
+ "name": "folder_create",
138
+ "description": "Create a new folder",
139
+ "command": "mdedit folder create --name <name> --format json",
140
+ "flags": {
141
+ "--name <name>": "Folder name (required)",
142
+ "--parent <id>": "Parent folder ID for nesting",
143
+ "--workspace <id>": "Workspace ID"
144
+ },
145
+ "example": "mdedit folder create --name 'Blog Posts' --format json"
146
+ },
147
+ {
148
+ "name": "folder_update",
149
+ "description": "Update a folder (e.g., rename).",
150
+ "command": "mdedit folder update <folderId> --name <name> --format json",
151
+ "flags": {
152
+ "--name <name>": "New name",
153
+ "--workspace <id>": "Workspace ID"
154
+ },
155
+ "example": "mdedit folder update fld-123 --name 'Archive' --format json"
156
+ },
157
+ {
158
+ "name": "folder_delete",
159
+ "description": "Delete a folder",
160
+ "command": "mdedit folder delete <folderId> --yes",
161
+ "flags": {
162
+ "--yes": "Skip confirmation"
163
+ },
164
+ "example": "mdedit folder delete fld123 --yes"
165
+ },
166
+ {
167
+ "name": "workspace_list",
168
+ "description": "List all workspaces accessible with the current API key",
169
+ "command": "mdedit workspace list --format json",
170
+ "example": "mdedit workspace list --format json"
171
+ },
172
+ {
173
+ "name": "workspace_get",
174
+ "description": "Get details of a specific workspace",
175
+ "command": "mdedit workspace get <workspaceId> --format json",
176
+ "example": "mdedit workspace get ws123 --format json"
177
+ },
178
+ {
179
+ "name": "workspace_create",
180
+ "description": "Create a new workspace.",
181
+ "command": "mdedit workspace create --name <name> --type <user|team> --format json",
182
+ "flags": {
183
+ "--name <name>": "Workspace name (required)",
184
+ "--type <user|team>": "Workspace type"
185
+ },
186
+ "example": "mdedit workspace create --name 'My Workspace' --type user --format json"
187
+ },
188
+ {
189
+ "name": "workspace_update",
190
+ "description": "Update a workspace (e.g., rename).",
191
+ "command": "mdedit workspace update <workspaceId> --name <name> --format json",
192
+ "flags": {
193
+ "--name <name>": "New name"
194
+ },
195
+ "example": "mdedit workspace update ws-123 --name 'New Name' --format json"
196
+ },
197
+ {
198
+ "name": "workspace_delete",
199
+ "description": "Delete a workspace.",
200
+ "command": "mdedit workspace delete <workspaceId> --yes",
201
+ "flags": {
202
+ "--yes": "Skip confirmation"
203
+ },
204
+ "example": "mdedit workspace delete ws-123 --yes"
205
+ },
206
+ {
207
+ "name": "apikey_list",
208
+ "description": "List API keys associated with the authenticated account",
209
+ "command": "mdedit apikey list --format json",
210
+ "example": "mdedit apikey list --format json"
211
+ },
212
+ {
213
+ "name": "apikey_create",
214
+ "description": "Create a new API key",
215
+ "command": "mdedit apikey create --name <name> --format json",
216
+ "flags": {
217
+ "--name <name>": "Key name (required)",
218
+ "--description <desc>": "Key description",
219
+ "--expires <days>": "Expiration in days"
220
+ },
221
+ "example": "mdedit apikey create --name 'CI/CD Key' --expires 90 --format json"
222
+ },
223
+ {
224
+ "name": "apikey_revoke",
225
+ "description": "Revoke an API key by its ID",
226
+ "command": "mdedit apikey revoke <keyId> --yes",
227
+ "flags": {
228
+ "--yes": "Skip confirmation"
229
+ },
230
+ "example": "mdedit apikey revoke key123 --yes"
231
+ },
232
+ {
233
+ "name": "health",
234
+ "description": "Check the mdedit API health status",
235
+ "command": "mdedit health --format json",
236
+ "example": "mdedit health --format json"
237
+ },
238
+ {
239
+ "name": "info",
240
+ "description": "Display CLI version, API URL, workspace, and authentication status",
241
+ "command": "mdedit info --format json",
242
+ "example": "mdedit info"
243
+ },
244
+ {
245
+ "name": "skill_show",
246
+ "description": "Print the full mdedit agent skill/documentation to stdout",
247
+ "command": "mdedit skill show",
248
+ "example": "mdedit skill show"
249
+ },
250
+ {
251
+ "name": "skill_install",
252
+ "description": "Install the mdedit skill into agent configuration files (Claude Code, Cursor, GitHub Copilot/Codex).",
253
+ "command": "mdedit skill install",
254
+ "flags": {
255
+ "--target <claude|cursor|codex|all>": "Which agent tool to install for (default: all)",
256
+ "--global": "Install to home-directory targets instead of the current project"
257
+ },
258
+ "example": "mdedit skill install --target codex"
259
+ }
260
+ ],
261
+ "workflows": {
262
+ "read_and_update_article": [
263
+ "CONTENT=$(mdedit article get <articleId> --content-only)",
264
+ "echo \"$MODIFIED_CONTENT\" | mdedit article update <articleId> --file -"
265
+ ],
266
+ "create_article_in_folder": [
267
+ "mdedit folder list --format json",
268
+ "mdedit article create --title 'New Post' --folder <folderId> --file content.md --format json"
269
+ ],
270
+ "bulk_export": [
271
+ "mdedit article list --format json > articles.json"
272
+ ],
273
+ "setup_fresh_environment": [
274
+ "mdedit config login --api-key $MDEDIT_API_KEY",
275
+ "mdedit workspace list --format json",
276
+ "mdedit config use-workspace <workspaceId>"
277
+ ]
278
+ }
279
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdedit-cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command-line interface for mdedit.ai.",
@@ -14,6 +14,8 @@
14
14
  "files": [
15
15
  "bin",
16
16
  "dist",
17
+ "skill.md",
18
+ "openclaw.json",
17
19
  "README.md",
18
20
  "LICENSE"
19
21
  ],
@@ -25,7 +27,7 @@
25
27
  "prepack": "yarn build"
26
28
  },
27
29
  "dependencies": {
28
- "@mdedit/sdk": "^0.1.1",
30
+ "@mdedit/sdk": "^0.2.0",
29
31
  "chalk": "^5.6.2",
30
32
  "commander": "^14.0.3",
31
33
  "inquirer": "^8.2.7",
package/skill.md ADDED
@@ -0,0 +1,210 @@
1
+ # mdedit CLI — Agent Skill
2
+
3
+ > Use this skill to manage articles, folders, workspaces, and 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://docs.mdedit.ai/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` = error. Errors are written to stderr.
30
+
31
+ ## Global flags
32
+
33
+ | Flag | Description |
34
+ |------|-------------|
35
+ | `-F, --format <plain\|table\|json>` | Output format. Use `json` for agents. |
36
+ | `--api-key <key>` | Override API key for this call |
37
+ | `--workspace <workspaceId>` | Override default workspace for this call |
38
+ | `--api-url <url>` | Override API base URL |
39
+ | `--local` | Target local API at `http://localhost:8080` |
40
+ | `--debug` | Print stack traces and request info on errors |
41
+
42
+ ## Commands reference
43
+
44
+ ### config
45
+
46
+ ```bash
47
+ mdedit config show # show current config (api key redacted)
48
+ mdedit config login --api-key <key> # authenticate
49
+ mdedit config logout # remove stored api key
50
+ mdedit config use-workspace <workspaceId> # set default workspace
51
+ mdedit config set <key> <value> # set any config key
52
+ mdedit config clear --yes # wipe all config
53
+ ```
54
+
55
+ ### workspace
56
+
57
+ ```bash
58
+ mdedit workspace list
59
+ mdedit workspace get <workspaceId>
60
+ mdedit workspace create --name "My Workspace" --type user
61
+ mdedit workspace update <workspaceId> --name "New Name"
62
+ mdedit workspace delete <workspaceId> --yes
63
+ ```
64
+
65
+ ### folder
66
+
67
+ ```bash
68
+ mdedit folder list [-w <workspaceId>]
69
+ mdedit folder list --include-deleted
70
+ mdedit folder get <folderId>
71
+ mdedit folder create --name "Drafts" [--parent <parentFolderId>]
72
+ mdedit folder update <folderId> --name "Archive"
73
+ mdedit folder delete <folderId> --yes
74
+ ```
75
+
76
+ ### article
77
+
78
+ ```bash
79
+ # List & filter
80
+ mdedit article list
81
+ mdedit article list --folder <folderId>
82
+ mdedit article list --limit 10 --offset 0
83
+
84
+ # Read
85
+ mdedit article get <articleId>
86
+ mdedit article get <articleId> --content-only # raw markdown to stdout
87
+ mdedit article get <articleId> --include-content # include markdown in output object
88
+ mdedit article get <articleId> --output article.md # save markdown to file
89
+
90
+ # Create
91
+ mdedit article create --title "My Article"
92
+ mdedit article create --title "My Article" --folder <folderId> --file article.md
93
+ mdedit article create --title "My Article" --content "# Hello world"
94
+ echo "# Hello" | mdedit article create --title "My Article" --file -
95
+
96
+ # Update
97
+ mdedit article update <articleId> --title "New Title"
98
+ mdedit article update <articleId> --file updated.md
99
+ mdedit article update <articleId> --content "# Updated"
100
+ cat updated.md | mdedit article update <articleId> --file -
101
+ mdedit article update <articleId> --archive
102
+ mdedit article update <articleId> --pin
103
+
104
+ # Delete
105
+ mdedit article delete <articleId> --yes
106
+
107
+ # Export
108
+ mdedit article export <articleId> --output article.zip
109
+ ```
110
+
111
+ ### api-key
112
+
113
+ ```bash
114
+ mdedit apikey list
115
+ mdedit apikey create --name "CI/CD Key" --description "Used in pipeline"
116
+ mdedit apikey create --name "30-day key" --expires 30
117
+ mdedit apikey revoke <keyId> --yes
118
+ ```
119
+
120
+ ### utility
121
+
122
+ ```bash
123
+ mdedit health # check API health
124
+ mdedit info # CLI version, API URL, workspace, auth status
125
+ ```
126
+
127
+ ### skill
128
+
129
+ ```bash
130
+ mdedit skill show # print this skill to stdout
131
+ mdedit skill install # install skill into all detected agent tools
132
+ mdedit skill install --target claude # Claude Code: ~/.claude/CLAUDE.md
133
+ mdedit skill install --target cursor # Cursor: .cursor/rules/mdedit.mdc
134
+ mdedit skill install --target codex # GitHub Copilot: .github/copilot-instructions.md
135
+ mdedit skill install --target all # all of the above
136
+ mdedit skill install --global # install globally (home directory targets)
137
+ ```
138
+
139
+ ## Common agent workflows
140
+
141
+ ### Workflow: read an article and update its content
142
+
143
+ ```bash
144
+ # Fetch current content
145
+ CONTENT=$(mdedit article get <articleId> --content-only)
146
+
147
+ # Modify $CONTENT with your agent logic, then push it back
148
+ echo "$MODIFIED_CONTENT" | mdedit article update <articleId> --file -
149
+ ```
150
+
151
+ ### Workflow: create a new article in a folder
152
+
153
+ ```bash
154
+ # Find the target folder
155
+ mdedit folder list --format json | jq '.[] | select(.name=="Docs") | .id'
156
+
157
+ # Create article in that folder
158
+ mdedit article create --title "API Reference" --folder <folderId> --file api-ref.md
159
+ ```
160
+
161
+ ### Workflow: bulk export all articles as JSON
162
+
163
+ ```bash
164
+ mdedit article list --format json > articles.json
165
+ ```
166
+
167
+ ### Workflow: set up a fresh environment
168
+
169
+ ```bash
170
+ export MDEDIT_API_KEY=<key>
171
+ mdedit config login --api-key "$MDEDIT_API_KEY"
172
+ # list workspaces and set the default
173
+ mdedit workspace list --format json
174
+ mdedit config use-workspace <workspaceId>
175
+ ```
176
+
177
+ ## Environment variables
178
+
179
+ | Variable | Description |
180
+ |----------|-------------|
181
+ | `MDEDIT_API_KEY` | API key (overrides stored config) |
182
+ | `MDEDIT_API_URL` | API base URL (default: `https://apiv2.mdedit.ai`) |
183
+ | `MDEDIT_WORKSPACE_ID` | Default workspace ID |
184
+ | `MDEDIT_CONFIG_DIR` | Override config directory (default: `~/.mdedit-cli`) |
185
+ | `MDEDIT_DEBUG` | Set to `1` to enable debug output |
186
+
187
+ ## Output format guide
188
+
189
+ | Format | Best for |
190
+ |--------|----------|
191
+ | `table` | Humans scanning many rows (default) |
192
+ | `plain` | Human reading (object details) |
193
+ | `json` | Agents, scripts, piping to `jq` |
194
+
195
+ Use `--format json` globally: `mdedit <command> --format json`.
196
+ In `json` mode all human-readable messages go to **stderr** so stdout stays machine-parseable.
197
+
198
+ ## Error handling
199
+
200
+ Errors write a descriptive message to **stderr** and exit with code `1`.
201
+
202
+ Common errors and fixes:
203
+
204
+ | HTTP | Meaning | Fix |
205
+ |------|---------|-----|
206
+ | 401 | Unauthenticated | Run `mdedit config login --api-key <key>` |
207
+ | 403 | Forbidden | Check API key workspace permissions |
208
+ | 404 | Not found | Verify IDs and `--api-url` |
209
+
210
+ Add `--debug` to print full stack traces.