mdrules 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/dist/cli.js +17 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -205,6 +205,15 @@ function setIgnored(root2, rel, kind, ignored) {
205
205
  if (ignored) lines.push(entry);
206
206
  fs3.writeFileSync(path3.join(root2, IGNORE_FILE), lines.length ? lines.join("\n") + "\n" : "");
207
207
  }
208
+ function watchSkips(root2) {
209
+ const gitIgnore = loadIgnore(root2, ".gitignore");
210
+ return (rel, isDir) => {
211
+ if (!rel || rel.startsWith("..")) return false;
212
+ if (rel.split("/").some((s) => ALWAYS_SKIP.has(s))) return true;
213
+ if (isDir !== false && gitIgnore.ignores(rel + "/")) return true;
214
+ return isDir !== true && gitIgnore.ignores(rel);
215
+ };
216
+ }
208
217
  function scanTree(root2) {
209
218
  const gitIgnore = loadIgnore(root2, ".gitignore");
210
219
  const mdIgnore = loadIgnore(root2, IGNORE_FILE);
@@ -615,13 +624,18 @@ async function startServer({ root: root2, port, open: openBrowser }) {
615
624
  const data = JSON.stringify(msg);
616
625
  for (const client of wss.clients) client.send(data);
617
626
  };
627
+ const skips = watchSkips(root2);
618
628
  watch(root2, {
619
629
  ignoreInitial: true,
620
- ignored: (p2) => {
630
+ // Unreadable folders (e.g. caches owned by another user) are skipped instead of failing.
631
+ ignorePermissionErrors: true,
632
+ ignored: (p2, stats) => {
621
633
  const rel = toPosix(path6.relative(root2, p2));
622
- return /(^|\/)(node_modules|\.git|dist|build|\.next|\.turbo|coverage)(\/|$)/.test(rel) || rel.startsWith(".mdrules/") && !rel.startsWith(".mdrules/i18n") && rel !== ".mdrules/state.json" && rel !== ".mdrules/config.json";
634
+ if (rel === ".mdrules") return false;
635
+ if (rel.startsWith(".mdrules/")) return !rel.startsWith(".mdrules/i18n") && rel !== ".mdrules/state.json" && rel !== ".mdrules/config.json";
636
+ return skips(rel, stats ? stats.isDirectory() : void 0);
623
637
  }
624
- }).on("all", (event, file) => {
638
+ }).on("error", (err) => console.warn(pc.yellow(` file watcher: ${err.message}`))).on("all", (event, file) => {
625
639
  const abs = path6.resolve(file);
626
640
  if (!abs.endsWith(".md") && !abs.endsWith(".json") && !abs.endsWith(".mdrulesignore") && event !== "addDir" && event !== "unlinkDir") return;
627
641
  let rel = toPosix(path6.relative(root2, abs));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdrules",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Visual editor for CLAUDE.md, AGENTS.md and /docs — humans edit comfortably, the AI keeps reading plain Markdown.",
5
5
  "keywords": [
6
6
  "markdown",