@magic-markdown/cli 0.3.9 → 0.3.11

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10997,7 +10997,7 @@ var RemoteDocumentIO = class {
10997
10997
  };
10998
10998
 
10999
10999
  // src/agent.ts
11000
- var CLI_VERSION = "0.3.9";
11000
+ var CLI_VERSION = "0.3.11";
11001
11001
  var CLI_PACKAGE_NAME = "@magic-markdown/cli";
11002
11002
  var AGENT_COMMANDS = [
11003
11003
  {
@@ -11565,6 +11565,7 @@ function nextCommands(map) {
11565
11565
  }
11566
11566
 
11567
11567
  // src/fs-io.ts
11568
+ import { randomUUID } from "node:crypto";
11568
11569
  import { mkdir as mkdir2, readFile as readFile2, readdir as readdir2, realpath, rename, rm as rm2, stat as stat2, writeFile as writeFile2 } from "node:fs/promises";
11569
11570
  import { dirname as dirname4, join as join2, relative, resolve } from "node:path";
11570
11571
  var NodeWorkspaceIO = class {
@@ -11585,7 +11586,7 @@ var NodeWorkspaceIO = class {
11585
11586
  async writeTextAtomic(path, content) {
11586
11587
  const target = await this.resolveWritablePath(path, Buffer.byteLength(content, "utf8"));
11587
11588
  await mkdir2(dirname4(target), { recursive: true });
11588
- const temporary = `${target}.${process.pid}.${Date.now()}.tmp`;
11589
+ const temporary = `${target}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;
11589
11590
  await writeFile2(temporary, content, "utf8");
11590
11591
  await rename(temporary, target);
11591
11592
  }
@@ -11674,6 +11675,7 @@ async function walk(root, output, base, rules, ignoreFiles) {
11674
11675
  for (const entry of entries) {
11675
11676
  const absolute = join2(root, entry.name);
11676
11677
  const relativePath = relative(base, absolute).replaceAll("\\", "/");
11678
+ if (relativePath.endsWith(".tmp")) continue;
11677
11679
  if (isIgnoredWorkspacePath(relativePath, rules)) continue;
11678
11680
  if (ignoreMatcher(relativePath)) continue;
11679
11681
  if (entry.isDirectory()) {
@@ -11683,11 +11685,18 @@ async function walk(root, output, base, rules, ignoreFiles) {
11683
11685
  continue;
11684
11686
  }
11685
11687
  if (entry.isFile()) {
11686
- const stats = await stat2(absolute);
11688
+ const stats = await stat2(absolute).catch((error) => {
11689
+ if (isMissingPathError(error)) return void 0;
11690
+ throw error;
11691
+ });
11692
+ if (!stats) continue;
11687
11693
  if (isWorkspaceMarkdownPathAllowed(relativePath, rules, stats.size, ignoreMatcher)) output.push(normalizeWorkspacePath3(relativePath));
11688
11694
  }
11689
11695
  }
11690
11696
  }
11697
+ function isMissingPathError(error) {
11698
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
11699
+ }
11691
11700
  async function withDirectoryIgnoreFile(root, base, ignoreFiles) {
11692
11701
  try {
11693
11702
  const path = join2(relative(base, root).replaceAll("\\", "/"), ".gitignore").replace(/^\.\//, "");
@@ -12296,7 +12305,7 @@ function respond(payload) {
12296
12305
  }
12297
12306
 
12298
12307
  // src/remote-api.ts
12299
- import { randomUUID } from "node:crypto";
12308
+ import { randomUUID as randomUUID2 } from "node:crypto";
12300
12309
  async function postPresence(share, shareUrl, docId, agentId, agentName) {
12301
12310
  await fetchJson(agentUrl({ ...share, shareUrl }, docId, "presence"), {
12302
12311
  method: "POST",
@@ -12454,7 +12463,7 @@ async function postReview(record, docId, additions, actor) {
12454
12463
  {
12455
12464
  method: "POST",
12456
12465
  headers: { ...shareHeaders(record.shareUrl), "Content-Type": "application/json" },
12457
- body: JSON.stringify({ actor, changeId: randomUUID(), ...additions })
12466
+ body: JSON.stringify({ actor, changeId: randomUUID2(), ...additions })
12458
12467
  }
12459
12468
  );
12460
12469
  return response.document;
@@ -12479,7 +12488,7 @@ async function pushDocument(record, baseDocument, markdown, sidecar) {
12479
12488
  // Full identity so version-history commits show the agent's name.
12480
12489
  actor: { id: record.agentId, name: record.agentName, kind: "agent" },
12481
12490
  sourceId: record.agentId,
12482
- changeId: randomUUID(),
12491
+ changeId: randomUUID2(),
12483
12492
  payload,
12484
12493
  createdAt
12485
12494
  })
@@ -13391,7 +13400,7 @@ function optionalFolderTarget(value) {
13391
13400
  }
13392
13401
 
13393
13402
  // src/bridge.ts
13394
- import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
13403
+ import { createHash as createHash2, randomUUID as randomUUID3 } from "node:crypto";
13395
13404
  import { basename as basename2, resolve as resolve4 } from "node:path";
13396
13405
  function bridgeSetupIdentity(input) {
13397
13406
  const actorName = input.actorName?.trim() || "Agent";
@@ -13436,7 +13445,7 @@ async function runBridge(options) {
13436
13445
  replicaPrefix: options.replicaPrefix,
13437
13446
  lastAppliedHead: localManifestSource?.canonicalHead
13438
13447
  });
13439
- const sourceId = `bridge_${replicaId}_${randomUUID2().replaceAll("-", "").slice(0, 8)}`;
13448
+ const sourceId = `bridge_${replicaId}_${randomUUID3().replaceAll("-", "").slice(0, 8)}`;
13440
13449
  const io = new PathMappedWorkspaceIO(root, mapping);
13441
13450
  const signatures = /* @__PURE__ */ new Map();
13442
13451
  const pendingDocs = /* @__PURE__ */ new Set();
@@ -13657,7 +13666,7 @@ async function runBridge(options) {
13657
13666
  kind: actorKindForBridge(options.actorId)
13658
13667
  },
13659
13668
  sourceId,
13660
- changeId: randomUUID2(),
13669
+ changeId: randomUUID3(),
13661
13670
  payload,
13662
13671
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
13663
13672
  })
@@ -13776,7 +13785,7 @@ async function fetchScopedRoot(options, rootId) {
13776
13785
  async function registerRoot(options, root, rootId, mapping) {
13777
13786
  const now = (/* @__PURE__ */ new Date()).toISOString();
13778
13787
  const existingRoot = await fetchExistingRoot(options, rootId);
13779
- const canonicalHead = existingRoot?.canonical.head ?? mapping.lastAppliedHead ?? `head_${randomUUID2().replaceAll("-", "").slice(0, 16)}`;
13788
+ const canonicalHead = existingRoot?.canonical.head ?? mapping.lastAppliedHead ?? `head_${randomUUID3().replaceAll("-", "").slice(0, 16)}`;
13780
13789
  const rootName = options.sourceName ?? existingRoot?.name ?? (basename2(root) || rootId);
13781
13790
  const owner = ownerForBridge(options.actorId, rootName, options.actorName);
13782
13791
  const replica = { ...mapping, lastAppliedHead: canonicalHead, status: "synced", updatedAt: now };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magic-markdown/cli",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "Magic Markdown agent CLI (mdocs): read, review, comment on, suggest edits to, and sync clean Markdown workspaces.",
5
5
  "type": "module",
6
6
  "license": "MIT",