@mx-space/cli 0.5.1 → 0.6.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/README.md +21 -1
- package/ROADMAP.md +4 -0
- package/dist/bin/mxs.mjs +1 -1
- package/dist/{esm-DO9hVR8S.mjs → esm-CK9m5JKX.mjs} +1 -1
- package/dist/esm-DRbkkY3r.mjs +2 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.mjs +1 -1
- package/dist/{mxs-CCu8LdBX.mjs → mxs-Bs_7ZKs9.mjs} +3671 -3107
- package/package.json +4 -3
- package/skills/auth-config.md +70 -0
- package/skills/authoring.md +175 -0
- package/skills/commands-auth.md +19 -0
- package/skills/commands-category.md +20 -0
- package/skills/commands-comment.md +47 -0
- package/skills/commands-config.md +30 -0
- package/skills/commands-note.md +53 -0
- package/skills/commands-page.md +32 -0
- package/skills/commands-post.md +51 -0
- package/skills/commands-profile.md +22 -0
- package/skills/commands-topic.md +18 -0
- package/skills/output-modes.md +45 -0
- package/skills/overview.md +41 -0
- package/skills/safety.md +114 -0
- package/skills/workflow.md +49 -0
- package/dist/esm-BKxzBG1f.mjs +0 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
slug: overview
|
|
3
|
+
title: Overview
|
|
4
|
+
description: Entry point and reference map for the bundled mxs skill
|
|
5
|
+
order: 0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# mxs CLI — AI agent skill bundle
|
|
9
|
+
|
|
10
|
+
`mxs` is the deterministic interface for managing an `mx-core` deployment from the command line — authentication, content (posts, notes, pages), moderation, configuration. This skill bundle is shipped inside the published `@mx-space/cli` package so any agent with the installed binary can read it via `mxs skill <slug>`.
|
|
11
|
+
|
|
12
|
+
The audience is **AI agents**. Pass `--output llm` for raw markdown suitable for direct context injection. Default output is `readable` (markdown rendered as ANSI for a terminal).
|
|
13
|
+
|
|
14
|
+
## Reference map
|
|
15
|
+
|
|
16
|
+
| Need | Chapter |
|
|
17
|
+
| --------------------------------------------- | -------------------------------- |
|
|
18
|
+
| How to drive any task end-to-end | `workflow` |
|
|
19
|
+
| Post / note / page content authoring | `authoring` |
|
|
20
|
+
| Exact command syntax for posts | `commands-post` |
|
|
21
|
+
| Notes | `commands-note` |
|
|
22
|
+
| Pages | `commands-page` |
|
|
23
|
+
| Comments / moderation | `commands-comment` |
|
|
24
|
+
| Categories | `commands-category` |
|
|
25
|
+
| Topics | `commands-topic` |
|
|
26
|
+
| Server-side options | `commands-config` |
|
|
27
|
+
| Authentication | `commands-auth` |
|
|
28
|
+
| Local profile management | `commands-profile` |
|
|
29
|
+
| Profiles, env vars, target selection | `auth-config` |
|
|
30
|
+
| Output modes (`--json`, `--output llm`, …) | `output-modes` |
|
|
31
|
+
| Mutation safety, verification, exit codes | `safety` |
|
|
32
|
+
| LiteXML syntax for `<mxpost>` / `<mxnote>` | `litexml`, `litexml-nodes`, `litexml-recipes`, `litexml-cli` |
|
|
33
|
+
|
|
34
|
+
`litexml*` chapters are shipped from `@haklex/rich-litexml`. If they are missing, upgrade haklex to a version that bundles its `.claude/skills/litexml-authoring/` directory.
|
|
35
|
+
|
|
36
|
+
## How to navigate
|
|
37
|
+
|
|
38
|
+
- `mxs skill` — list every chapter (slug + one-liner)
|
|
39
|
+
- `mxs skill get <slug>` — print the chapter body as raw markdown
|
|
40
|
+
- `mxs skill all` — concatenate every chapter (for one-shot context injection)
|
|
41
|
+
- `mxs skill search <keyword>` — substring search, returns matching chapters with snippets
|
package/skills/safety.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
slug: safety
|
|
3
|
+
title: Safety, troubleshooting, exit codes
|
|
4
|
+
description: mutation safety matrix, common failures, verification templates
|
|
5
|
+
order: 60
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Safety and troubleshooting
|
|
9
|
+
|
|
10
|
+
Use this reference for every mutation, deletion, publication change, or failed command.
|
|
11
|
+
|
|
12
|
+
## Mutation safety matrix
|
|
13
|
+
|
|
14
|
+
| Operation | Required guard | Required verification |
|
|
15
|
+
| ----------------------------------- | --------------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
16
|
+
| Create post/note/page | Confirm target and run `--dry-run` when practical. | `get <slugOrId>` and compare metadata plus body sample. |
|
|
17
|
+
| Update post/note/page | Prefer partial flags when body is unchanged. | Confirm changed fields and unchanged body when applicable. |
|
|
18
|
+
| Edit post/note/page | Avoid `$EDITOR` in non-interactive workflows unless explicitly requested. | Read back the full document. |
|
|
19
|
+
| Publish/unpublish | Confirm publication intent and target. | Read back `state` or `isPublished`. |
|
|
20
|
+
| Delete | Confirm destructive intent and target; prefer `--dry-run`; use `--force` only when non-interactive deletion is intentional. | Confirm `get` fails with not found or list no longer includes the resource. |
|
|
21
|
+
| Config set/edit | Confirm target because changes affect server behavior. | `config get <key>` or `config list`. |
|
|
22
|
+
| Category/topic changes | Confirm dependent content implications before deletion or slug changes. | `category get/list` or `topic get/list`. |
|
|
23
|
+
| Comment approve/reject | State change is soft and reversible; explicit-id form runs without confirmation. | `comment get <id> --json` and confirm `state`. |
|
|
24
|
+
| Comment delete | Soft-delete; `--force` required in non-TTY for both single id and `--all`. | `comment list --state <s>` or `comment get <id>` confirms removal. |
|
|
25
|
+
| Comment `--all` | Mass operation; always pass `--force` in non-TTY and prefer narrowing with `--state`. | `comment list --all --json` to confirm post-state. |
|
|
26
|
+
|
|
27
|
+
`--dry-run` validates local payload construction only; it does not contact the server and does not prove write authorization. If the actual mutation returns `auth.expired`, `auth.denied`, or `未登录`, stop and obtain a server-valid Better Auth token or API key instead of retrying with the same stored credential.
|
|
28
|
+
|
|
29
|
+
## Non-interactive rules
|
|
30
|
+
|
|
31
|
+
| Context | Rule |
|
|
32
|
+
| ----------------- | --------------------------------------------------------------------- |
|
|
33
|
+
| Agent mutation | Always pass `--json`. |
|
|
34
|
+
| Non-TTY delete | `--force` is required after target confirmation. |
|
|
35
|
+
| Stdin content | Use `--content=-`, `--content=stdin`, or `--file -`; fail if stdin is a TTY. |
|
|
36
|
+
| Editor workflow | Requires `EDITOR`; avoid unless user requested manual editor semantics. |
|
|
37
|
+
|
|
38
|
+
## Common failures
|
|
39
|
+
|
|
40
|
+
| Symptom or code | Likely cause | Resolution |
|
|
41
|
+
| ----------------------------------------------------- | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
42
|
+
| `config.missing.api_url` | No target configured. | Set `MXS_API_URL`, pass `--api-url`, or run `mxs auth login` interactively. |
|
|
43
|
+
| `cannot detect auth endpoint` | URL does not point to a live `mx-core` server with device auth. | Check origin and use `--verbose` for probes. |
|
|
44
|
+
| `fetch failed` | Server unavailable or incorrect target. | Start local server or select intended API origin. |
|
|
45
|
+
| `auth.expired` | Expired bearer token or API key supplied as bearer token. | Refresh login, pass valid `MXS_TOKEN`, or use `MXS_API_KEY` for API keys. |
|
|
46
|
+
| `auth.denied` | Insufficient permission. | Confirm credential owner and target. |
|
|
47
|
+
| `validation.failed` | Invalid flags, missing required fields, bad JSON, invalid coordinates, or empty lexical content. | Inspect JSON specs, envelope metadata, and content source. |
|
|
48
|
+
| `validation.xml` | Invalid LiteXML envelope. | Check root tag, `<meta>`, `<content>`, nested tags, and line detail. |
|
|
49
|
+
| `resource.not_found` | Wrong slug/id, deleted resource, or wrong target. | Re-run list/get on the confirmed target. |
|
|
50
|
+
| `profile.write_requires_explicit` | Active profile is flagged production; mutation refused without `--profile`. | Pass `--profile <name>` explicitly, or `mxs profile mark <name> --no-production`. |
|
|
51
|
+
| `skill.chapter_not_found` | Requested chapter slug is not in the registry. | `mxs skill` to list; for `litexml-*` upgrade `@haklex/rich-litexml` to ≥0.16.0. |
|
|
52
|
+
| `EDITOR is not set` | Interactive edit requested without editor. | Set `EDITOR` or use flags/file instead. |
|
|
53
|
+
| Large noisy JSON output | Raw document payload is too verbose. | Use `--output llm` for read-back and `--json` for mutations. |
|
|
54
|
+
| Link or embed URLs become empty during dry-run | LiteXML round-trip lost node attributes or the agent is using an older CLI build. | Stop before writing; update/fix the CLI and repeat dry-run before mutation. |
|
|
55
|
+
|
|
56
|
+
## Exit codes
|
|
57
|
+
|
|
58
|
+
| Code | Meaning |
|
|
59
|
+
| ---- | --------------------------------------------- |
|
|
60
|
+
| `0` | Success |
|
|
61
|
+
| `1` | Generic failure |
|
|
62
|
+
| `2` | Argument parsing failure |
|
|
63
|
+
| `3` | Authentication or authorization failure |
|
|
64
|
+
| `4` | Network failure |
|
|
65
|
+
| `5` | Validation or configuration failure |
|
|
66
|
+
| `6` | Server 5xx failure |
|
|
67
|
+
| `7` | Resource not found (incl. skill chapter) |
|
|
68
|
+
|
|
69
|
+
## Verification templates
|
|
70
|
+
|
|
71
|
+
### Post
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mxs post get <slugOrId> --output llm
|
|
75
|
+
mxs post get <slugOrId> --json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Verify `title`, `slug`, `state`, category, tags, summary, and representative body text.
|
|
79
|
+
|
|
80
|
+
### Note
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
mxs note get <slugOrId> --output llm
|
|
84
|
+
mxs note get <slugOrId> --json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Verify `title`, `slug` or `nid`, `state`, topic, note metadata, and representative body text.
|
|
88
|
+
|
|
89
|
+
### Page
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
mxs page get <slugOrId> --output llm
|
|
93
|
+
mxs page get <slugOrId> --json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Verify `title`, `slug`, `subtitle`, `order`, and representative body text.
|
|
97
|
+
|
|
98
|
+
### Config
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
mxs config get <key> --json
|
|
102
|
+
mxs config list --json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Verify only the intended option changed.
|
|
106
|
+
|
|
107
|
+
### Comment
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
mxs comment get <id> --json
|
|
111
|
+
mxs comment list --state <unread|read|junk> --json
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Verify `state` matches the intended transition (`0=unread`, `1=read`, `2=junk`) and, for delete, that the id no longer appears in `comment list`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
slug: workflow
|
|
3
|
+
title: Mandatory workflow and safety rules
|
|
4
|
+
description: How to drive any mxs task end-to-end without damaging server state
|
|
5
|
+
order: 10
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Workflow
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
┌──────────────────────┐
|
|
12
|
+
│ Identify operation │
|
|
13
|
+
└──────────┬───────────┘
|
|
14
|
+
▼
|
|
15
|
+
┌──────────────────────┐
|
|
16
|
+
│ Load relevant refs │ (mxs skill get commands-post, authoring, …)
|
|
17
|
+
└──────────┬───────────┘
|
|
18
|
+
▼
|
|
19
|
+
┌──────────────────────┐
|
|
20
|
+
│ Confirm target/auth │ (mxs auth whoami --json, mxs auth status --json)
|
|
21
|
+
└──────────┬───────────┘
|
|
22
|
+
▼
|
|
23
|
+
◆ Mutation? ◆
|
|
24
|
+
/ \
|
|
25
|
+
▼ ▼
|
|
26
|
+
┌──────────┐ ┌──────────────────────┐
|
|
27
|
+
│ Read cmd │ │ Dry run if supported │
|
|
28
|
+
└────┬─────┘ └──────────┬───────────┘
|
|
29
|
+
│ ▼
|
|
30
|
+
│ ┌──────────────────────┐
|
|
31
|
+
│ │ Execute mutation │ (--json)
|
|
32
|
+
│ └──────────┬───────────┘
|
|
33
|
+
│ ▼
|
|
34
|
+
└─────────>┌──────────────────────┐
|
|
35
|
+
│ Verify read-back │ (--output llm or --json)
|
|
36
|
+
└──────────────────────┘
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Required safety rules
|
|
40
|
+
|
|
41
|
+
- Always use machine-readable output: pass `--json` for mutations and reads unless the task explicitly asks for human output.
|
|
42
|
+
- Never print access tokens, refresh tokens, cookies, API keys, or raw credential files.
|
|
43
|
+
- Treat `MXS_API_URL`, `MXS_TOKEN`, `MXS_API_KEY`, `--api-url`, `--token`, and `--api-key` as execution context, not content.
|
|
44
|
+
- Do not publish to production unless the user explicitly requested publication or the configured target has been confirmed as the intended target.
|
|
45
|
+
- If testing the write path without publication, set `<state>draft</state>` or pass `--state draft`.
|
|
46
|
+
- After any create, edit, update, publish, or unpublish operation, read the resource back and verify observable fields.
|
|
47
|
+
- For destructive operations, prefer `--dry-run` first where supported, then require an explicit user request or confirmed intended target before using `delete --force`.
|
|
48
|
+
|
|
49
|
+
See `safety` for the full mutation matrix, common failures, and exit codes.
|
package/dist/esm-BKxzBG1f.mjs
DELETED