@mx-space/cli 0.6.1 → 0.6.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 +14 -0
- package/ROADMAP.md +2 -1
- package/dist/bin/mxs.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{mxs-Bs_7ZKs9.mjs → mxs-Dj82UF06.mjs} +159 -4
- package/package.json +2 -1
- package/skills/commands-preview.md +58 -0
- package/skills/overview.md +1 -0
package/README.md
CHANGED
|
@@ -485,6 +485,20 @@ Example profile config:
|
|
|
485
485
|
| `6` | Server 5xx failure |
|
|
486
486
|
| `7` | Resource not found |
|
|
487
487
|
|
|
488
|
+
## Preview
|
|
489
|
+
|
|
490
|
+
`mxs preview <file>` renders a LiteXML fragment or `<mxpost>` / `<mxnote>` envelope to HTML and opens it in your default browser. Use it to sanity-check what the article will look like before publishing.
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
mxs preview ./post.xml # open in browser
|
|
494
|
+
mxs preview - < note.xml # read stdin
|
|
495
|
+
mxs preview ./post.xml --theme dark # dark theme
|
|
496
|
+
mxs preview ./post.xml --save out.html # write HTML to file
|
|
497
|
+
mxs preview ./post.xml --print # emit HTML to stdout
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
The variant (`article` / `note`) is auto-detected from the envelope root. Override with `--variant` for raw LiteXML fragments. The command does not contact `mx-core` — it's a pure local render via `@haklex/rich-litexml-cli`.
|
|
501
|
+
|
|
488
502
|
## Skill bundle
|
|
489
503
|
|
|
490
504
|
`mxs skill` exposes the bundled AI-agent documentation directly from the CLI binary. Chapters are shipped inside the published `@mx-space/cli` package; liteXML chapters are pulled live from `@haklex/rich-litexml` at runtime (requires `@haklex/rich-litexml@>=0.16.0`).
|
package/ROADMAP.md
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
- Internal rewrite onto Effect-TS (`@effect/cli` + `@effect/platform`). User-facing CLI surface is unchanged — see [`README.md`](./README.md#v030-behavior-changes) for the small list of behavioral adjustments and [`docs/architecture.md`](./docs/architecture.md) for the new internal architecture.
|
|
10
10
|
|
|
11
|
-
## Shipped in v0.
|
|
11
|
+
## Shipped in v0.6
|
|
12
12
|
|
|
13
13
|
- `mxs skill` — bundled AI-agent documentation. List, get, all, search across chapters shipped inside the CLI (`packages/cli/skills/*.md`); liteXML chapters loaded live from the installed `@haklex/rich-litexml` package. Default output is raw markdown for direct context injection.
|
|
14
|
+
- `mxs preview <file>` — local HTML preview of a LiteXML fragment or `<mxpost>` / `<mxnote>` envelope. Wraps `@haklex/rich-litexml-cli` so the output matches the editor renderer.
|
|
14
15
|
|
|
15
16
|
## Next — Comment moderation
|
|
16
17
|
|
package/dist/bin/mxs.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as defaultMessageFor, c as tagToCode, i as codeForTag, l as toErrorEnvelope, n as defaultGlobalFlags, o as exitCodeForError, r as parseGlobalFlags, s as exitCodeForTag, t as run } from "./mxs-
|
|
1
|
+
import { a as defaultMessageFor, c as tagToCode, i as codeForTag, l as toErrorEnvelope, n as defaultGlobalFlags, o as exitCodeForError, r as parseGlobalFlags, s as exitCodeForTag, t as run } from "./mxs-Dj82UF06.mjs";
|
|
2
2
|
export { codeForTag, defaultGlobalFlags, defaultMessageFor, exitCodeForError, exitCodeForTag, parseGlobalFlags, run, tagToCode, toErrorEnvelope };
|
|
@@ -27683,14 +27683,14 @@ const decideWriteGate = (resolved, method) => {
|
|
|
27683
27683
|
};
|
|
27684
27684
|
//#endregion
|
|
27685
27685
|
//#region src/domain/version.ts
|
|
27686
|
-
const requireFrom$
|
|
27686
|
+
const requireFrom$4 = createRequire(import.meta.url);
|
|
27687
27687
|
const resolveCliVersion$2 = () => {
|
|
27688
27688
|
for (const candidate of [
|
|
27689
27689
|
"../package.json",
|
|
27690
27690
|
"../../package.json",
|
|
27691
27691
|
"../../../package.json"
|
|
27692
27692
|
]) try {
|
|
27693
|
-
const pkg = requireFrom$
|
|
27693
|
+
const pkg = requireFrom$4(candidate);
|
|
27694
27694
|
if (pkg.name === "@mx-space/cli" && typeof pkg.version === "string") return pkg.version;
|
|
27695
27695
|
} catch {}
|
|
27696
27696
|
return "0.0.0-unknown";
|
|
@@ -31747,6 +31747,150 @@ const postCmd = make$13("post").pipe(withDescription(help$3.description), withSu
|
|
|
31747
31747
|
unpublish
|
|
31748
31748
|
]));
|
|
31749
31749
|
//#endregion
|
|
31750
|
+
//#region src/cli/preview/index.ts
|
|
31751
|
+
registerCommandHelp({
|
|
31752
|
+
name: "preview",
|
|
31753
|
+
description: "render a LiteXML fragment or <mxpost>/<mxnote> envelope to HTML and open it in a browser",
|
|
31754
|
+
isLeaf: true,
|
|
31755
|
+
leafOptions: [
|
|
31756
|
+
{
|
|
31757
|
+
flag: "--theme <light|dark>",
|
|
31758
|
+
description: "HTML theme; default: light"
|
|
31759
|
+
},
|
|
31760
|
+
{
|
|
31761
|
+
flag: "--variant <article|note|comment>",
|
|
31762
|
+
description: "HTML variant; auto-detected from envelope root, default: article"
|
|
31763
|
+
},
|
|
31764
|
+
{
|
|
31765
|
+
flag: "--save <path>",
|
|
31766
|
+
description: "write HTML to <path> instead of opening a browser"
|
|
31767
|
+
},
|
|
31768
|
+
{
|
|
31769
|
+
flag: "--print",
|
|
31770
|
+
description: "emit HTML to stdout instead of opening a browser"
|
|
31771
|
+
}
|
|
31772
|
+
]
|
|
31773
|
+
});
|
|
31774
|
+
const fileArg = text$3({ name: "file" }).pipe(optional$4);
|
|
31775
|
+
const themeOpt = choice("theme", ["light", "dark"]).pipe(optional$2);
|
|
31776
|
+
const variantOpt = choice("variant", [
|
|
31777
|
+
"article",
|
|
31778
|
+
"note",
|
|
31779
|
+
"comment"
|
|
31780
|
+
]).pipe(optional$2);
|
|
31781
|
+
const saveOpt = text$1("save").pipe(optional$2);
|
|
31782
|
+
const printOpt = boolean("print").pipe(optional$2);
|
|
31783
|
+
const requireFrom$3 = createRequire(import.meta.url);
|
|
31784
|
+
const resolveLitexmlBin = () => {
|
|
31785
|
+
try {
|
|
31786
|
+
return requireFrom$3.resolve("@haklex/rich-litexml-cli/dist/cli.mjs");
|
|
31787
|
+
} catch {}
|
|
31788
|
+
const here = import.meta.url;
|
|
31789
|
+
const filePath = here.startsWith("file://") ? here.slice(7) : here;
|
|
31790
|
+
let dir = filePath.slice(0, Math.max(0, filePath.lastIndexOf("/")));
|
|
31791
|
+
for (let i = 0; i < 8; i++) {
|
|
31792
|
+
const candidate = `${dir}/node_modules/@haklex/rich-litexml-cli/dist/cli.mjs`;
|
|
31793
|
+
try {
|
|
31794
|
+
requireFrom$3(`${candidate}`);
|
|
31795
|
+
return candidate;
|
|
31796
|
+
} catch {}
|
|
31797
|
+
const next = dir.slice(0, Math.max(0, dir.lastIndexOf("/")));
|
|
31798
|
+
if (next === dir) break;
|
|
31799
|
+
dir = next;
|
|
31800
|
+
}
|
|
31801
|
+
throw new Generic({
|
|
31802
|
+
message: "cannot resolve @haklex/rich-litexml-cli binary",
|
|
31803
|
+
hint: "reinstall mxs or run `pnpm install` so the dependency is present"
|
|
31804
|
+
});
|
|
31805
|
+
};
|
|
31806
|
+
const detectVariant = (body) => {
|
|
31807
|
+
const trimmed = body.trimStart();
|
|
31808
|
+
if (trimmed.startsWith("<mxpost")) return {
|
|
31809
|
+
contentXml: parseEnvelope(trimmed, "post").contentXml,
|
|
31810
|
+
variant: "article"
|
|
31811
|
+
};
|
|
31812
|
+
if (trimmed.startsWith("<mxnote")) return {
|
|
31813
|
+
contentXml: parseEnvelope(trimmed, "note").contentXml,
|
|
31814
|
+
variant: "note"
|
|
31815
|
+
};
|
|
31816
|
+
return {
|
|
31817
|
+
contentXml: body,
|
|
31818
|
+
variant: "article"
|
|
31819
|
+
};
|
|
31820
|
+
};
|
|
31821
|
+
const spawnLitexml = (bin, input, args, capture) => tryPromise({
|
|
31822
|
+
try: () => new Promise((resolve, reject) => {
|
|
31823
|
+
const child = spawn(process.execPath, [
|
|
31824
|
+
bin,
|
|
31825
|
+
"-",
|
|
31826
|
+
...args
|
|
31827
|
+
], { stdio: capture ? [
|
|
31828
|
+
"pipe",
|
|
31829
|
+
"pipe",
|
|
31830
|
+
"inherit"
|
|
31831
|
+
] : [
|
|
31832
|
+
"pipe",
|
|
31833
|
+
"inherit",
|
|
31834
|
+
"inherit"
|
|
31835
|
+
] });
|
|
31836
|
+
const out = [];
|
|
31837
|
+
if (capture && child.stdout) child.stdout.on("data", (chunk) => out.push(chunk));
|
|
31838
|
+
child.on("error", reject);
|
|
31839
|
+
child.on("exit", (code) => {
|
|
31840
|
+
if (code === 0) resolve(capture ? Buffer.concat(out).toString("utf8") : "");
|
|
31841
|
+
else reject(/* @__PURE__ */ new Error(`litexml exited with code ${code}`));
|
|
31842
|
+
});
|
|
31843
|
+
if (!child.stdin) {
|
|
31844
|
+
reject(/* @__PURE__ */ new Error("failed to open litexml stdin"));
|
|
31845
|
+
return;
|
|
31846
|
+
}
|
|
31847
|
+
child.stdin.write(input);
|
|
31848
|
+
child.stdin.end();
|
|
31849
|
+
}),
|
|
31850
|
+
catch: (err) => new Generic({
|
|
31851
|
+
message: err instanceof Error ? err.message : String(err),
|
|
31852
|
+
cause: err
|
|
31853
|
+
})
|
|
31854
|
+
});
|
|
31855
|
+
const previewCmd = make$13("preview", {
|
|
31856
|
+
file: fileArg,
|
|
31857
|
+
theme: themeOpt,
|
|
31858
|
+
variant: variantOpt,
|
|
31859
|
+
save: saveOpt,
|
|
31860
|
+
print: printOpt
|
|
31861
|
+
}, ({ file, theme, variant, save, print }) => gen(function* () {
|
|
31862
|
+
const editor = yield* Editor;
|
|
31863
|
+
const renderer = yield* Renderer;
|
|
31864
|
+
const filePath = getOrUndefined(file);
|
|
31865
|
+
const raw = yield* editor.readFileOrStdin(filePath);
|
|
31866
|
+
let body;
|
|
31867
|
+
let detectedVariant = "article";
|
|
31868
|
+
try {
|
|
31869
|
+
const det = detectVariant(raw);
|
|
31870
|
+
body = det.contentXml;
|
|
31871
|
+
detectedVariant = det.variant;
|
|
31872
|
+
} catch (err) {
|
|
31873
|
+
return yield* fail$2(err instanceof ValidationXml ? err : new ValidationXml({ message: err instanceof Error ? err.message : String(err) }));
|
|
31874
|
+
}
|
|
31875
|
+
const resolvedVariant = getOrElse(variant, () => detectedVariant);
|
|
31876
|
+
const resolvedTheme = getOrUndefined(theme);
|
|
31877
|
+
const savePath = getOrUndefined(save);
|
|
31878
|
+
const printMode = getOrElse(print, () => false);
|
|
31879
|
+
const args = [
|
|
31880
|
+
"--format",
|
|
31881
|
+
"html",
|
|
31882
|
+
"--variant",
|
|
31883
|
+
resolvedVariant
|
|
31884
|
+
];
|
|
31885
|
+
if (resolvedTheme) args.push("--theme", resolvedTheme);
|
|
31886
|
+
if (savePath) args.push("-o", savePath);
|
|
31887
|
+
else if (!printMode) args.push("--open");
|
|
31888
|
+
const html = yield* spawnLitexml(resolveLitexmlBin(), body, args, printMode);
|
|
31889
|
+
if (printMode) process.stdout.write(html.endsWith("\n") ? html : `${html}\n`);
|
|
31890
|
+
else if (savePath) yield* renderer.emitInfo(`wrote HTML preview to ${savePath}`);
|
|
31891
|
+
else yield* renderer.emitInfo(`opened HTML preview (variant=${resolvedVariant})`);
|
|
31892
|
+
}));
|
|
31893
|
+
//#endregion
|
|
31750
31894
|
//#region src/cli/profile/view.ts
|
|
31751
31895
|
const profileListView = {
|
|
31752
31896
|
kind: "profile-list",
|
|
@@ -34500,6 +34644,7 @@ const GROUP_NAMES = [
|
|
|
34500
34644
|
"comment",
|
|
34501
34645
|
"config",
|
|
34502
34646
|
"skill",
|
|
34647
|
+
"preview",
|
|
34503
34648
|
"update"
|
|
34504
34649
|
];
|
|
34505
34650
|
const isGroupName = (s) => GROUP_NAMES.includes(s);
|
|
@@ -34703,7 +34848,11 @@ const PREFLIGHT_EXEMPT_COMMANDS = [{
|
|
|
34703
34848
|
* Top-level command names that are exempt from the profile.none_active guard.
|
|
34704
34849
|
* Used for commands that should work without a configured server (e.g. `mxs update`).
|
|
34705
34850
|
*/
|
|
34706
|
-
const PREFLIGHT_EXEMPT_TOPLEVEL = new Set([
|
|
34851
|
+
const PREFLIGHT_EXEMPT_TOPLEVEL = new Set([
|
|
34852
|
+
"update",
|
|
34853
|
+
"skill",
|
|
34854
|
+
"preview"
|
|
34855
|
+
]);
|
|
34707
34856
|
/** Returns true if the command is exempt from the profile.none_active guard. */
|
|
34708
34857
|
function isPreflightExempt(input) {
|
|
34709
34858
|
return PREFLIGHT_EXEMPT_PARENTS.has(input.parentName) || input.commandName === "profile" || PREFLIGHT_EXEMPT_TOPLEVEL.has(input.commandName) || PREFLIGHT_EXEMPT_COMMANDS.some((c) => c.parent === input.parentName && c.name === input.commandName);
|
|
@@ -34730,6 +34879,7 @@ const TOPLEVEL_COMMANDS = new Set([
|
|
|
34730
34879
|
"topic",
|
|
34731
34880
|
"config",
|
|
34732
34881
|
"skill",
|
|
34882
|
+
"preview",
|
|
34733
34883
|
"update"
|
|
34734
34884
|
]);
|
|
34735
34885
|
/**
|
|
@@ -35105,6 +35255,7 @@ const rootCmd = make$13("mxs", {}, () => flatMap$1(Renderer, (r) => r.emitInfo("
|
|
|
35105
35255
|
commentCmd,
|
|
35106
35256
|
configCmd,
|
|
35107
35257
|
skillCmd,
|
|
35258
|
+
previewCmd,
|
|
35108
35259
|
updateCmd
|
|
35109
35260
|
]));
|
|
35110
35261
|
const preflight = (flags) => gen(function* () {
|
|
@@ -35150,7 +35301,11 @@ const preflight = (flags) => gen(function* () {
|
|
|
35150
35301
|
parentName: invoked.parentName
|
|
35151
35302
|
}));
|
|
35152
35303
|
});
|
|
35153
|
-
const LEAF_COMMANDS = new Set([
|
|
35304
|
+
const LEAF_COMMANDS = new Set([
|
|
35305
|
+
"update",
|
|
35306
|
+
"skill",
|
|
35307
|
+
"preview"
|
|
35308
|
+
]);
|
|
35154
35309
|
const detectHelpTarget = (rest) => {
|
|
35155
35310
|
const args = rest.slice(2);
|
|
35156
35311
|
if (args.length === 0) return { kind: "root" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Command line interface for mx-space (mx-core) — auth, content, configuration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mx-space",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@effect/platform-node": "0.106.0",
|
|
55
55
|
"@haklex/rich-headless": "0.13.0",
|
|
56
56
|
"@haklex/rich-litexml": "0.15.2",
|
|
57
|
+
"@haklex/rich-litexml-cli": "0.15.3",
|
|
57
58
|
"@lexical/headless": "^0.44.0",
|
|
58
59
|
"better-auth": "^1.6.9",
|
|
59
60
|
"effect": "3.21.2",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
slug: commands-preview
|
|
3
|
+
title: Preview command
|
|
4
|
+
description: render LiteXML / envelope to HTML and open it in a browser
|
|
5
|
+
order: 39
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Preview command
|
|
9
|
+
|
|
10
|
+
`mxs preview` renders a LiteXML fragment or `<mxpost>` / `<mxnote>` envelope to HTML and (by default) opens it in the system browser. It is a thin wrapper around the `@haklex/rich-litexml-cli` `litexml --format html` pipeline, so the output matches what the editor would render once published.
|
|
11
|
+
|
|
12
|
+
| Command | Behavior |
|
|
13
|
+
| ---------------------------------------- | --------------------------------------------------------------------------- |
|
|
14
|
+
| `mxs preview <file>` | Render the file and open the preview in a browser. |
|
|
15
|
+
| `mxs preview -` | Read LiteXML or envelope from stdin and open the preview. |
|
|
16
|
+
| `mxs preview <file> --print` | Emit HTML to stdout instead of opening a browser. |
|
|
17
|
+
| `mxs preview <file> --save <out.html>` | Write HTML to `<out.html>` instead of opening a browser. |
|
|
18
|
+
|
|
19
|
+
## Flags
|
|
20
|
+
|
|
21
|
+
| Flag | Meaning |
|
|
22
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
|
23
|
+
| `--theme <light\|dark>` | HTML theme. Default `light`. |
|
|
24
|
+
| `--variant <article\|note\|comment>` | HTML variant. Auto-detected from the envelope root (`<mxpost>` → `article`, `<mxnote>` → `note`). |
|
|
25
|
+
| `--save <path>` | Write HTML to a file instead of opening the browser. Mutually exclusive with `--print`. |
|
|
26
|
+
| `--print` | Emit HTML to stdout. Mutually exclusive with `--save`. |
|
|
27
|
+
|
|
28
|
+
## Behavior notes
|
|
29
|
+
|
|
30
|
+
- Input format is auto-detected. If the input starts with `<mxpost>` or `<mxnote>`, the envelope is parsed and only the `<content>` body is rendered (envelope `<meta>` such as title, category, tags is **not** reflected in the HTML preview — this command is for visualising the article body, not the listing card).
|
|
31
|
+
- For raw LiteXML fragments (no envelope wrapper), the entire input is treated as the article body.
|
|
32
|
+
- Variant detection only fires when an envelope is supplied. Override with `--variant` when previewing a raw fragment that should render as a note or comment.
|
|
33
|
+
- The command does not contact the `mx-core` server and does not require an active profile.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Open envelope file in browser
|
|
39
|
+
mxs preview ./post.xml
|
|
40
|
+
|
|
41
|
+
# Pipe from another tool
|
|
42
|
+
some-generator | mxs preview -
|
|
43
|
+
|
|
44
|
+
# Dark theme, save to file
|
|
45
|
+
mxs preview ./note.xml --theme dark --save ./preview.html
|
|
46
|
+
|
|
47
|
+
# Emit HTML to stdout (e.g. for CI)
|
|
48
|
+
mxs preview ./post.xml --print > preview.html
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Failure modes
|
|
52
|
+
|
|
53
|
+
| Symptom | Likely cause |
|
|
54
|
+
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `cannot resolve @haklex/rich-litexml-cli binary` | Installed dep is broken; reinstall `@mx-space/cli` or run `pnpm install`. |
|
|
56
|
+
| `Cannot resolve @haklex/rich-compose asset "style.css"` | Outdated `@haklex/rich-compose` (< 0.15.2). Upgrade or reinstall. |
|
|
57
|
+
| `expected root <mxpost>` / `expected root <mxnote>` | Input begins with the wrong envelope root, or the envelope is malformed. Check the root tag. |
|
|
58
|
+
| Browser does not open | `--open` shells out to the system `open`/`xdg-open`/`start`. Use `--save` or `--print` instead. |
|
package/skills/overview.md
CHANGED
|
@@ -26,6 +26,7 @@ The audience is **AI agents**. Pass `--output llm` for raw markdown suitable for
|
|
|
26
26
|
| Server-side options | `commands-config` |
|
|
27
27
|
| Authentication | `commands-auth` |
|
|
28
28
|
| Local profile management | `commands-profile` |
|
|
29
|
+
| Browser preview of LiteXML / envelopes | `commands-preview` |
|
|
29
30
|
| Profiles, env vars, target selection | `auth-config` |
|
|
30
31
|
| Output modes (`--json`, `--output llm`, …) | `output-modes` |
|
|
31
32
|
| Mutation safety, verification, exit codes | `safety` |
|