@magic-markdown/cli 0.3.6 → 0.3.7
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 +8 -6
- package/dist/index.js +75 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,19 +22,21 @@ The package is a single self-contained bundle with no runtime dependencies. It r
|
|
|
22
22
|
## Quick start for agents
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs version --json
|
|
26
|
+
|
|
25
27
|
# Join a shared document and announce presence
|
|
26
|
-
mdocs join <share-url> --doc <docId> --name "Claude Code" --json
|
|
28
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs join <share-url> --doc <docId> --name "Claude Code" --json
|
|
27
29
|
|
|
28
30
|
# Orient without dumping the whole document
|
|
29
|
-
mdocs remote context --summary --json
|
|
31
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs remote context --summary --json
|
|
30
32
|
|
|
31
33
|
# Page document text separately from review state
|
|
32
|
-
mdocs remote context --start-line 1 --end-line 120 --no-review --json
|
|
33
|
-
mdocs remote review --json
|
|
34
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs remote context --start-line 1 --end-line 120 --no-review --json
|
|
35
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs remote review --json
|
|
34
36
|
|
|
35
37
|
# Leave a comment or propose an edit (ranges are 1-based, inclusive)
|
|
36
|
-
mdocs remote comment --range 12:14 --body "Tighten this paragraph." --json
|
|
37
|
-
mdocs remote suggest --range 12:14 --with-file replacement.md --message "Clearer phrasing" --json
|
|
38
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs remote comment --range 12:14 --body "Tighten this paragraph." --json
|
|
39
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs remote suggest --range 12:14 --with-file replacement.md --message "Clearer phrasing" --json
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
Run `mdocs agent guide` for the full agent workflow, `mdocs help <command>` for any command, or `mdocs agent commands --json` for the machine-readable command contract.
|
package/dist/index.js
CHANGED
|
@@ -10990,7 +10990,7 @@ var RemoteDocumentIO = class {
|
|
|
10990
10990
|
};
|
|
10991
10991
|
|
|
10992
10992
|
// src/agent.ts
|
|
10993
|
-
var CLI_VERSION = "0.3.
|
|
10993
|
+
var CLI_VERSION = "0.3.7";
|
|
10994
10994
|
var CLI_PACKAGE_NAME = "@magic-markdown/cli";
|
|
10995
10995
|
var AGENT_COMMANDS = [
|
|
10996
10996
|
{
|
|
@@ -11009,6 +11009,14 @@ var AGENT_COMMANDS = [
|
|
|
11009
11009
|
mutates: false,
|
|
11010
11010
|
examples: ["mdocs agent commands --json"]
|
|
11011
11011
|
},
|
|
11012
|
+
{
|
|
11013
|
+
name: "agent-guide",
|
|
11014
|
+
summary: "Alias for mdocs agent guide.",
|
|
11015
|
+
usage: "mdocs agent-guide [--json]",
|
|
11016
|
+
output: "text",
|
|
11017
|
+
mutates: false,
|
|
11018
|
+
examples: ["mdocs agent-guide", "mdocs agent-guide --json"]
|
|
11019
|
+
},
|
|
11012
11020
|
{
|
|
11013
11021
|
name: "init",
|
|
11014
11022
|
summary: "Create .mdocs metadata and index Markdown documents.",
|
|
@@ -11249,6 +11257,21 @@ var AGENT_COMMANDS = [
|
|
|
11249
11257
|
"mdocs checkpoint restore checkpoint_abc123 --json"
|
|
11250
11258
|
]
|
|
11251
11259
|
},
|
|
11260
|
+
{
|
|
11261
|
+
name: "bridge setup",
|
|
11262
|
+
summary: "Initialize, validate, request approval for, and start an agent filesystem bridge.",
|
|
11263
|
+
usage: "mdocs bridge setup --workspace <id> --root <path> --root-id <id> --url <base-url> --actor-name <agent-name> --request-token",
|
|
11264
|
+
output: "long-running",
|
|
11265
|
+
mutates: true,
|
|
11266
|
+
examples: [
|
|
11267
|
+
"mdocs bridge setup --workspace workspace_abc --root . --root-id agentfs-hermes --url https://magic.example.com --actor-name Hermes --request-token"
|
|
11268
|
+
],
|
|
11269
|
+
notes: [
|
|
11270
|
+
"Runs init and doctor before starting the bridge.",
|
|
11271
|
+
"--request-token opens a human approval URL and avoids pasting bridge secrets into an agent session.",
|
|
11272
|
+
"--token (or MDOCS_BRIDGE_TOKEN) still works when a scoped bridge token is already available."
|
|
11273
|
+
]
|
|
11274
|
+
},
|
|
11252
11275
|
{
|
|
11253
11276
|
name: "bridge",
|
|
11254
11277
|
summary: "Sync a local Markdown root with a Magic workspace over WebSocket (long-running).",
|
|
@@ -11300,14 +11323,10 @@ Magic Markdown keeps Markdown files clean and stores collaboration metadata in .
|
|
|
11300
11323
|
|
|
11301
11324
|
## Install / Bootstrap
|
|
11302
11325
|
|
|
11303
|
-
The only official package is \`@magic-markdown/cli\` (bins \`mdocs\` and \`magic-markdown\`). A different, unrelated package is published as \`@mdocs/cli\` \u2014 do not install it.
|
|
11326
|
+
The only official package is \`@magic-markdown/cli\` (bins \`mdocs\` and \`magic-markdown\`). A different, unrelated package is published as \`@mdocs/cli\` \u2014 do not install it. Agent sessions should bootstrap through the latest official package so they do not reuse a stale global \`mdocs\`:
|
|
11304
11327
|
|
|
11305
11328
|
\`\`\`bash
|
|
11306
|
-
|
|
11307
|
-
if ! command -v mdocs >/dev/null 2>&1 || ! mdocs version --json 2>/dev/null | grep -qF '"name": "@magic-markdown/cli"'; then
|
|
11308
|
-
MDOCS="npx --yes --package=@magic-markdown/cli@latest mdocs"
|
|
11309
|
-
fi
|
|
11310
|
-
$MDOCS version --json
|
|
11329
|
+
npx --yes --package=@magic-markdown/cli@latest mdocs version --json
|
|
11311
11330
|
\`\`\`
|
|
11312
11331
|
|
|
11313
11332
|
Run \`mdocs help <command>\` (or \`mdocs <command> --help\`) for usage, examples, and notes on any command, or \`mdocs agent commands --json\` for the full machine-readable contract.
|
|
@@ -13367,6 +13386,33 @@ function optionalFolderTarget(value) {
|
|
|
13367
13386
|
// src/bridge.ts
|
|
13368
13387
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
13369
13388
|
import { basename as basename2, resolve as resolve4 } from "node:path";
|
|
13389
|
+
function bridgeSetupIdentity(input) {
|
|
13390
|
+
const actorName = input.actorName?.trim() || "Agent";
|
|
13391
|
+
return {
|
|
13392
|
+
actorId: input.actorId?.trim() || `agent:${agentSlug(actorName)}`,
|
|
13393
|
+
actorName,
|
|
13394
|
+
sourceName: input.sourceName?.trim() || agentFilesystemDisplayName(actorName)
|
|
13395
|
+
};
|
|
13396
|
+
}
|
|
13397
|
+
async function runBridgeSetup(options) {
|
|
13398
|
+
const root = resolve4(options.root);
|
|
13399
|
+
const identity = bridgeSetupIdentity(options);
|
|
13400
|
+
const io = new NodeWorkspaceIO(root);
|
|
13401
|
+
const manifest = await indexWorkspace(io);
|
|
13402
|
+
process.stdout.write(`mdocs bridge setup indexed ${manifest.docs.length} Markdown document${manifest.docs.length === 1 ? "" : "s"} in ${root}
|
|
13403
|
+
`);
|
|
13404
|
+
const doctor = await runDoctor(io, root);
|
|
13405
|
+
process.stdout.write(`mdocs doctor ${doctor.ok ? "ok" : "has warnings"}: ${doctor.checks.map((check) => check.details).join(" ")}
|
|
13406
|
+
`);
|
|
13407
|
+
await runBridge({
|
|
13408
|
+
...options,
|
|
13409
|
+
root,
|
|
13410
|
+
actorId: identity.actorId,
|
|
13411
|
+
actorName: identity.actorName,
|
|
13412
|
+
sourceName: identity.sourceName,
|
|
13413
|
+
requestToken: options.requestToken || !options.token
|
|
13414
|
+
});
|
|
13415
|
+
}
|
|
13370
13416
|
async function runBridge(options) {
|
|
13371
13417
|
const root = resolve4(options.root);
|
|
13372
13418
|
const localManifestSource = await readLocalSource(root);
|
|
@@ -13776,6 +13822,15 @@ function agentNameFromActorId(actorId, rootName) {
|
|
|
13776
13822
|
if (nameFromId) return nameFromId;
|
|
13777
13823
|
return "Agent";
|
|
13778
13824
|
}
|
|
13825
|
+
function agentFilesystemDisplayName(agentName) {
|
|
13826
|
+
const trimmed = agentName.trim();
|
|
13827
|
+
if (!trimmed) return "Agent Filesystem";
|
|
13828
|
+
return /\bagent$/i.test(trimmed) ? `${trimmed} Filesystem` : `${trimmed} Agent Filesystem`;
|
|
13829
|
+
}
|
|
13830
|
+
function agentSlug(agentName) {
|
|
13831
|
+
const slug = agentName.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
13832
|
+
return slug || "agent";
|
|
13833
|
+
}
|
|
13779
13834
|
function mergePermissions(permissions, permission) {
|
|
13780
13835
|
return [...permissions.filter((candidate) => candidate.actorId !== permission.actorId), permission];
|
|
13781
13836
|
}
|
|
@@ -13974,8 +14029,12 @@ async function main() {
|
|
|
13974
14029
|
await runAgentCommand(io, cwd, subcommand, parsed);
|
|
13975
14030
|
return;
|
|
13976
14031
|
}
|
|
14032
|
+
case "agent-guide": {
|
|
14033
|
+
print(parsed.flags.json ? getAgentGuidePayload() : getAgentSkillMarkdown(), parsed.flags);
|
|
14034
|
+
return;
|
|
14035
|
+
}
|
|
13977
14036
|
case "bridge": {
|
|
13978
|
-
|
|
14037
|
+
const options = {
|
|
13979
14038
|
root: resolve5(String(parsed.flags.root ?? cwd)),
|
|
13980
14039
|
workspaceId: String(parsed.flags.workspace ?? "workspace_demo"),
|
|
13981
14040
|
rootId: typeof parsed.flags["root-id"] === "string" ? parsed.flags["root-id"] : void 0,
|
|
@@ -13984,14 +14043,16 @@ async function main() {
|
|
|
13984
14043
|
canonicalPrefix: typeof parsed.flags["canonical-prefix"] === "string" ? parsed.flags["canonical-prefix"] : void 0,
|
|
13985
14044
|
replicaPrefix: typeof parsed.flags["replica-prefix"] === "string" ? parsed.flags["replica-prefix"] : void 0,
|
|
13986
14045
|
claimToken: typeof parsed.flags.claim === "string" ? parsed.flags.claim : void 0,
|
|
13987
|
-
actorId:
|
|
14046
|
+
actorId: typeof parsed.flags.actor === "string" ? parsed.flags.actor : void 0,
|
|
13988
14047
|
actorName: typeof parsed.flags["actor-name"] === "string" ? parsed.flags["actor-name"] : void 0,
|
|
13989
14048
|
baseUrl: bridgeBaseUrl(parsed.flags),
|
|
13990
14049
|
intervalMs: Number(parsed.flags.interval ?? 1e3),
|
|
13991
14050
|
token: typeof parsed.flags.token === "string" ? parsed.flags.token : process.env.MDOCS_BRIDGE_TOKEN || void 0,
|
|
13992
14051
|
requestToken: Boolean(parsed.flags["request-token"] || parsed.flags.pair),
|
|
13993
14052
|
pairingTimeoutMs: typeof parsed.flags["pairing-timeout-ms"] === "string" ? Number(parsed.flags["pairing-timeout-ms"]) : void 0
|
|
13994
|
-
}
|
|
14053
|
+
};
|
|
14054
|
+
if (subcommand === "setup") await runBridgeSetup(options);
|
|
14055
|
+
else await runBridge({ ...options, actorId: options.actorId ?? "actor_local" });
|
|
13995
14056
|
return;
|
|
13996
14057
|
}
|
|
13997
14058
|
case "doctor": {
|
|
@@ -14147,6 +14208,7 @@ function help() {
|
|
|
14147
14208
|
|
|
14148
14209
|
Commands:
|
|
14149
14210
|
agent guide Print agent SKILL.md workflow guidance
|
|
14211
|
+
agent-guide Alias for agent guide
|
|
14150
14212
|
agent commands --json Print machine-readable command metadata
|
|
14151
14213
|
init [path] Initialize .mdocs and index Markdown files
|
|
14152
14214
|
map --json Print workspace map
|
|
@@ -14179,6 +14241,9 @@ Commands:
|
|
|
14179
14241
|
remote events|history|restore Poll events, list commits, restore snapshots
|
|
14180
14242
|
remote library|create-folder|update-folder|move-root|invite-folder
|
|
14181
14243
|
Organize the joined project library
|
|
14244
|
+
bridge setup --workspace <id> --root . --url <base-url> --request-token
|
|
14245
|
+
Initialize, validate, request approval,
|
|
14246
|
+
and start an agent filesystem bridge
|
|
14182
14247
|
bridge --workspace <id> --root . --url <base-url> --request-token
|
|
14183
14248
|
Request human approval, then sync an
|
|
14184
14249
|
approved local root with the workspace
|
package/package.json
CHANGED