@nimtech/nimpress 2.6.1 → 2.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/dist/cli.es.js CHANGED
@@ -1,30 +1,30 @@
1
- import { d as z, c as Pe, r as Me, s as Bt, p as Gt, a as tt, b as ue, e as Ht, f as Ut, g as De, h as st, i as Zt, j as nt, k as Vt, l as Kt, m as Yt, C as ge, n as Qt, o as ot, q as Ge, w as pe, t as rt, u as Xt, v as qt, x as es, y as ts, z as ss, A as ns, B as we } from "./plugin-NiTYQgLI.js";
2
- import { join as d, dirname as N, relative as D, sep as I, extname as me, resolve as j, basename as F } from "node:path";
3
- import { readdirSync as se, existsSync as $, writeFileSync as W, mkdirSync as J, rmSync as ne, readFileSync as C, statSync as it, watch as He } from "node:fs";
4
- import fe from "gray-matter";
5
- import { readFile as Se, readdir as os, writeFile as Q, mkdir as _e, copyFile as at } from "node:fs/promises";
6
- import { s as rs, r as $e } from "./typeMembers-CNvE92EX.js";
1
+ import { d as J, c as Ae, r as Me, s as Bt, p as Gt, a as tt, b as pe, e as Ht, f as Ut, g as De, h as st, i as Zt, j as nt, k as Vt, l as Kt, m as Yt, C as ge, n as Qt, o as ot, q as Ge, w as me, t as rt, u as Xt, v as qt, x as es, y as ts, z as ss, A as ns, B as we, D as os } from "./plugin-FqF3mcpj.js";
2
+ import { join as d, dirname as N, relative as F, sep as L, extname as fe, resolve as x, basename as D } from "node:path";
3
+ import { readdirSync as re, existsSync as b, writeFileSync as W, mkdirSync as B, rmSync as q, readFileSync as C, statSync as it, watch as He } from "node:fs";
4
+ import le from "gray-matter";
5
+ import { readFile as Se, readdir as rs, writeFile as X, mkdir as _e, copyFile as at } from "node:fs/promises";
6
+ import { s as is, r as $e } from "./typeMembers-CNvE92EX.js";
7
7
  import { createServer as ct, build as lt } from "vite";
8
8
  import { createHash as ut } from "node:crypto";
9
9
  import { createInterface as pt } from "node:readline/promises";
10
10
  import { fileURLToPath as mt } from "node:url";
11
- import { homedir as K, platform as is } from "node:os";
12
- import { spawnSync as X, spawn as Ie } from "node:child_process";
13
- import { createInterface as as } from "node:readline";
14
- import { parse as cs } from "yaml";
11
+ import { homedir as K, platform as as } from "node:os";
12
+ import { spawnSync as ee, spawn as Ie } from "node:child_process";
13
+ import { createInterface as cs } from "node:readline";
14
+ import { parse as ls } from "yaml";
15
15
  function _(e, t) {
16
16
  return e.find((n) => n.startsWith(`--${t}=`))?.slice(t.length + 3);
17
17
  }
18
- function M(e, t) {
18
+ function I(e, t) {
19
19
  return e.includes(`--${t}`);
20
20
  }
21
- function re(e, t) {
21
+ function ie(e, t) {
22
22
  return e.filter((n) => !n.startsWith("--"))[t];
23
23
  }
24
- function oe(e, t = []) {
24
+ function Y(e, t = []) {
25
25
  let s;
26
26
  try {
27
- s = se(e, { withFileTypes: !0 });
27
+ s = re(e, { withFileTypes: !0 });
28
28
  } catch {
29
29
  return t;
30
30
  }
@@ -32,7 +32,7 @@ function oe(e, t = []) {
32
32
  const o = d(e, n.name);
33
33
  if (n.isDirectory()) {
34
34
  if (n.name === "node_modules" || n.name.startsWith(".")) continue;
35
- oe(o, t);
35
+ Y(o, t);
36
36
  } else n.isFile() && t.push(o);
37
37
  }
38
38
  return t;
@@ -45,7 +45,7 @@ function Ne(e, t, s) {
45
45
  }
46
46
  console.log(s);
47
47
  }
48
- function ls() {
48
+ function us() {
49
49
  return `import { defineConfig } from '@nimtech/nimpress/plugin'
50
50
 
51
51
  /**
@@ -55,15 +55,15 @@ function ls() {
55
55
  */
56
56
  export default defineConfig({
57
57
  /** Site title shown in the header and the tab. */
58
- title: ${JSON.stringify(z.title)},
58
+ title: ${JSON.stringify(J.title)},
59
59
 
60
- /** Folder holding the markdown content. Default ${JSON.stringify(z.contentDir)}. */
60
+ /** Folder holding the markdown content. Default ${JSON.stringify(J.contentDir)}. */
61
61
  // contentDir: 'docs',
62
62
 
63
- /** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(z.assetsDir)}. */
63
+ /** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(J.assetsDir)}. */
64
64
  // assetsDir: 'assets',
65
65
 
66
- /** Url base the assets folder serves under. Default ${JSON.stringify(z.assetUrlBase)}. */
66
+ /** Url base the assets folder serves under. Default ${JSON.stringify(J.assetUrlBase)}. */
67
67
  // assetUrlBase: '/assets',
68
68
 
69
69
  /**
@@ -181,21 +181,21 @@ export default defineConfig({
181
181
  })
182
182
  `;
183
183
  }
184
- function us() {
184
+ function ps() {
185
185
  return JSON.stringify(
186
186
  {
187
187
  $schema: "./node_modules/@nimtech/nimpress/config.schema.json",
188
- title: z.title,
189
- contentDir: z.contentDir,
190
- assetsDir: z.assetsDir,
191
- assetUrlBase: z.assetUrlBase
188
+ title: J.title,
189
+ contentDir: J.contentDir,
190
+ assetsDir: J.assetsDir,
191
+ assetUrlBase: J.assetUrlBase
192
192
  },
193
193
  null,
194
194
  2
195
195
  ) + `
196
196
  `;
197
197
  }
198
- function ps(e) {
198
+ function ms(e) {
199
199
  return `# Nimpress project
200
200
 
201
201
  This site is built with @nimtech/nimpress. Content lives in \`${e}/\` as markdown with typed frontmatter.
@@ -237,11 +237,11 @@ The authoritative AI working rules ship inside the package at \`node_modules/@ni
237
237
  8. \`nimpress guard map\` and \`nimpress guard apply\` wire gated pages, marked with the \`gate:\` frontmatter field, to the auth provider artifacts.
238
238
  `;
239
239
  }
240
- function ms(e) {
241
- const t = d(e, "nimpress.config.ts"), s = d(e, "nimpress.config.json"), n = M(process.argv.slice(2), "json");
242
- !$(t) && !$(s) && (n ? (W(s, us()), console.log(`nimpress init: ${s} written, field descriptions come from the referenced config.schema.json`)) : (W(t, ls()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
243
- const o = d(e, z.contentDir);
244
- (!$(o) || se(o).length === 0) && (J(o, { recursive: !0 }), W(
240
+ function fs(e) {
241
+ const t = d(e, "nimpress.config.ts"), s = d(e, "nimpress.config.json"), n = I(process.argv.slice(2), "json");
242
+ !b(t) && !b(s) && (n ? (W(s, ps()), console.log(`nimpress init: ${s} written, field descriptions come from the referenced config.schema.json`)) : (W(t, us()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
243
+ const o = d(e, J.contentDir);
244
+ (!b(o) || re(o).length === 0) && (B(o, { recursive: !0 }), W(
245
245
  d(o, "index.md"),
246
246
  `---
247
247
  title: Home
@@ -250,126 +250,126 @@ title: Home
250
250
  Welcome to your Nimpress site.
251
251
  `
252
252
  ));
253
- const i = ps(z.contentDir);
253
+ const i = ms(J.contentDir);
254
254
  for (const c of ["CLAUDE.md", "AGENTS.md"]) {
255
255
  const u = d(e, c);
256
- $(u) || (W(u, i), console.log(`nimpress init: ${c} written, pointing at the packaged rules in node_modules/@nimtech/nimpress/.claude/rules/`));
256
+ b(u) || (W(u, i), console.log(`nimpress init: ${c} written, pointing at the packaged rules in node_modules/@nimtech/nimpress/.claude/rules/`));
257
257
  }
258
258
  }
259
- const fs = { vue: "vueStory", svelte: "svelteStory" }, ds = { vue: ".svelte", svelte: ".vue" };
260
- function ie(e) {
259
+ const ds = { vue: "vueStory", svelte: "svelteStory" }, hs = { vue: ".svelte", svelte: ".vue" };
260
+ function ae(e) {
261
261
  return `run nimpress modules update ${e}`;
262
262
  }
263
- async function hs(e) {
263
+ async function gs(e) {
264
264
  let t;
265
265
  try {
266
- t = await os(e, { withFileTypes: !0 });
266
+ t = await rs(e, { withFileTypes: !0 });
267
267
  } catch {
268
268
  return [];
269
269
  }
270
270
  return t.filter((s) => s.isFile() && /\.story\.tsx?$/.test(s.name)).map((s) => s.name);
271
271
  }
272
- function gs(e, t) {
272
+ function ws(e, t) {
273
273
  const s = t === "integer" ? "number" : t;
274
274
  return e.every((n) => typeof n === s);
275
275
  }
276
- function ws(e, t, s, n, o) {
276
+ function $s(e, t, s, n, o) {
277
277
  const r = [], i = n.properties ?? {}, c = o.properties ?? {};
278
278
  for (const m of Object.keys(c))
279
- m in i || r.push(`${e}: prop ${m} is missing from the schema, ${ie(t)}`);
279
+ m in i || r.push(`${e}: prop ${m} is missing from the schema, ${ae(t)}`);
280
280
  for (const m of Object.keys(i))
281
281
  m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${s}, remove it or restore the prop`);
282
282
  for (const [m, f] of Object.entries(i)) {
283
283
  const h = c[m];
284
284
  if (h && (f.type && h.type && f.type !== h.type && !f.enum && r.push(
285
- `${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${ie(t)}`
286
- ), f.enum && h.type && !gs(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
287
- const g = new Set(h.enum.map((v) => JSON.stringify(v))), w = f.enum.filter((v) => !g.has(JSON.stringify(v)));
285
+ `${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${ae(t)}`
286
+ ), f.enum && h.type && !ws(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
287
+ const g = new Set(h.enum.map((k) => JSON.stringify(k))), w = f.enum.filter((k) => !g.has(JSON.stringify(k)));
288
288
  w.length && r.push(
289
- `${e}: prop ${m} enum carries ${w.map((v) => JSON.stringify(v)).join(", ")} outside the source union`
289
+ `${e}: prop ${m} enum carries ${w.map((k) => JSON.stringify(k)).join(", ")} outside the source union`
290
290
  );
291
291
  }
292
292
  }
293
293
  const u = n.slots ?? {}, a = o.slots ?? {};
294
294
  for (const m of Object.keys(a))
295
- m in u || r.push(`${e}: slot ${m} is missing from the schema, ${ie(t)}`);
295
+ m in u || r.push(`${e}: slot ${m} is missing from the schema, ${ae(t)}`);
296
296
  for (const m of Object.keys(u))
297
297
  m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${s}`);
298
298
  const p = new Set(n.emits ?? []), l = new Set(o.emits ?? []);
299
299
  for (const m of l)
300
- p.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ie(t)}`);
300
+ p.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ae(t)}`);
301
301
  for (const m of p)
302
302
  l.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${s}`);
303
303
  return r;
304
304
  }
305
305
  async function ft(e, t, s) {
306
- const n = s ? [s] : Object.keys(t.modules.systems), o = [], r = await Pe(e, t.contentDir);
306
+ const n = s ? [s] : Object.keys(t.modules.systems), o = [], r = await Ae(e, t.contentDir);
307
307
  for (const i of n) {
308
308
  const c = t.modules.systems[i];
309
309
  if (!c) {
310
310
  o.push(`${i}: not a configured system`);
311
311
  continue;
312
312
  }
313
- const u = c.framework, a = fs[u === "vue" ? "svelte" : "vue"], p = ds[u];
313
+ const u = c.framework, a = ds[u === "vue" ? "svelte" : "vue"], p = hs[u];
314
314
  for (const l of r) {
315
315
  if (l.system !== i) continue;
316
- const m = N(l.pageFile), f = D(e, m).split(I).join("/"), h = await hs(m);
316
+ const m = N(l.pageFile), f = F(e, m).split(L).join("/"), h = await gs(m);
317
317
  h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${l.component}`);
318
318
  const g = /* @__PURE__ */ new Set();
319
- for (const x of h) {
320
- let R;
319
+ for (const O of h) {
320
+ let T;
321
321
  try {
322
- R = await Se(d(m, x), "utf-8");
322
+ T = await Se(d(m, O), "utf-8");
323
323
  } catch {
324
324
  continue;
325
325
  }
326
- (/\bharness\s*:/.test(R) || /\brender\s*:/.test(R)) && g.add(x), R.includes(a) && o.push(`${f}/${x}: uses ${a} inside the ${u} system ${i}`);
327
- for (const y of R.matchAll(/from\s+['"]([^'"]+)['"]/g))
328
- me(y[1]) === p && o.push(`${f}/${x}: imports ${y[1]} inside the ${u} system ${i}`);
326
+ (/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(O), T.includes(a) && o.push(`${f}/${O}: uses ${a} inside the ${u} system ${i}`);
327
+ for (const $ of T.matchAll(/from\s+['"]([^'"]+)['"]/g))
328
+ fe($[1]) === p && o.push(`${f}/${O}: imports ${$[1]} inside the ${u} system ${i}`);
329
329
  }
330
330
  const w = Me(e, t.modules, i, l.component, l.file);
331
- if (w && me(w.componentFile) === p && o.push(
332
- `${f}: component file ${D(e, w.componentFile)} mismatches the ${u} system ${i}`
333
- ), $(d(m, "schema.json")) && $(d(m, "schema.yml"))) {
331
+ if (w && fe(w.componentFile) === p && o.push(
332
+ `${f}: component file ${F(e, w.componentFile)} mismatches the ${u} system ${i}`
333
+ ), b(d(m, "schema.json")) && b(d(m, "schema.yml"))) {
334
334
  o.push(`${f}: both schema.json and schema.yml exist, keep one`);
335
335
  continue;
336
336
  }
337
- const v = Bt(m);
338
- if (!v) {
339
- o.push(`${f}: schema file missing, ${ie(l.component)}`);
337
+ const k = Bt(m);
338
+ if (!k) {
339
+ o.push(`${f}: schema file missing, ${ae(l.component)}`);
340
340
  continue;
341
341
  }
342
- let O;
342
+ let j;
343
343
  try {
344
- O = await Se(v.path, "utf-8");
344
+ j = await Se(k.path, "utf-8");
345
345
  } catch {
346
- o.push(`${f}: ${v.form} schema unreadable`);
346
+ o.push(`${f}: ${k.form} schema unreadable`);
347
347
  continue;
348
348
  }
349
349
  let E;
350
350
  try {
351
- E = Gt(O, v.form);
351
+ E = Gt(j, k.form);
352
352
  } catch {
353
- o.push(`${f}: schema is not valid ${v.form}, fix it by hand`);
353
+ o.push(`${f}: schema is not valid ${k.form}, fix it by hand`);
354
354
  continue;
355
355
  }
356
- const k = new Set(Object.keys(E.properties ?? {}));
357
- for (const x of await tt(m))
358
- if (!g.has(x.file))
359
- for (const R of Object.keys(x.props ?? {}))
360
- k.has(R) || o.push(`${f}/${x.file}: prop ${R} is absent from the schema, ${ie(l.component)}`);
361
- const T = w ? await Se(w.componentFile, "utf-8").catch(() => {
356
+ const v = new Set(Object.keys(E.properties ?? {}));
357
+ for (const O of await tt(m))
358
+ if (!g.has(O.file))
359
+ for (const T of Object.keys(O.props ?? {}))
360
+ v.has(T) || o.push(`${f}/${O.file}: prop ${T} is absent from the schema, ${ae(l.component)}`);
361
+ const R = w ? await Se(w.componentFile, "utf-8").catch(() => {
362
362
  }) : void 0;
363
363
  if (w) {
364
- const x = await ue(w.componentFile, u, l.component);
365
- if (x) {
366
- const R = rs(l.component, x.props, x.slots, x.emits);
364
+ const O = await pe(w.componentFile, u, l.component);
365
+ if (O) {
366
+ const T = is(l.component, O.props, O.slots, O.emits);
367
367
  o.push(
368
- ...ws(f, l.component, D(e, w.componentFile), E, R)
368
+ ...$s(f, l.component, F(e, w.componentFile), E, T)
369
369
  );
370
370
  }
371
371
  }
372
- Ht(Ut(l.component, E, { sourceFile: w?.componentFile, sourceText: T }));
372
+ Ht(Ut(l.component, E, { sourceFile: w?.componentFile, sourceText: R }));
373
373
  }
374
374
  }
375
375
  return De(e), o;
@@ -389,15 +389,15 @@ async function gt(e, t, s) {
389
389
  for (const n of s)
390
390
  await lt(await nt(e, t, n, "build")), console.log(`nimpress modules: built ${n}`);
391
391
  }
392
- async function $s(e, t) {
392
+ async function ys(e, t) {
393
393
  const s = await ct(await st({ cwd: e, command: "serve", resolved: t }));
394
394
  await s.listen(), await ht(e, t, Object.keys(t.modules.systems)), s.printUrls(), s.bindCLIShortcuts({ print: !0 });
395
395
  }
396
396
  async function wt(e, t) {
397
- const s = d(e, "index.html"), n = !$(s);
397
+ const s = d(e, "index.html"), n = !b(s);
398
398
  n && W(s, Zt(t));
399
399
  const o = () => {
400
- n && ne(s, { force: !0 });
400
+ n && q(s, { force: !0 });
401
401
  }, r = () => {
402
402
  o(), process.exit(130);
403
403
  };
@@ -409,8 +409,8 @@ async function wt(e, t) {
409
409
  }
410
410
  await gt(e, t, dt(t));
411
411
  }
412
- const ys = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], bs = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Ue = /^[a-z0-9][a-z0-9.-]*$/, vs = /^[A-Z][A-Za-z0-9]*$/;
413
- function ks(e) {
412
+ const bs = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], vs = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Ue = /^[a-z0-9][a-z0-9.-]*$/, ks = /^[A-Z][A-Za-z0-9]*$/;
413
+ function xs(e) {
414
414
  const t = e.resolve;
415
415
  if (!t || typeof t != "object") return [];
416
416
  const s = t.alias;
@@ -422,7 +422,7 @@ function ks(e) {
422
422
  ([n, o]) => typeof o == "string" ? [{ find: n, replacement: o }] : []
423
423
  );
424
424
  }
425
- function xs(e) {
425
+ function Ss(e) {
426
426
  const t = [], s = [
427
427
  /(?:^|\n)[ \t]*import[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
428
428
  /(?:^|\n)[ \t]*export[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
@@ -436,9 +436,9 @@ function xs(e) {
436
436
  return t;
437
437
  }
438
438
  function Ze(e) {
439
- return bs.some((t) => {
439
+ return vs.some((t) => {
440
440
  const s = e + t;
441
- if (!$(s)) return !1;
441
+ if (!b(s)) return !1;
442
442
  try {
443
443
  return it(s).isFile();
444
444
  } catch {
@@ -446,18 +446,18 @@ function Ze(e) {
446
446
  }
447
447
  });
448
448
  }
449
- function Ss(e, t) {
450
- const s = j(e, t.contentDir), n = ks(t.vite), o = [];
451
- for (const r of oe(s)) {
452
- if (!ys.some((u) => r.endsWith(u))) continue;
449
+ function js(e, t) {
450
+ const s = x(e, t.contentDir), n = xs(t.vite), o = [];
451
+ for (const r of Y(s)) {
452
+ if (!bs.some((u) => r.endsWith(u))) continue;
453
453
  let i;
454
454
  try {
455
455
  i = C(r, "utf-8");
456
456
  } catch {
457
457
  continue;
458
458
  }
459
- const c = D(s, r).split(I).join("/");
460
- for (const u of xs(i)) {
459
+ const c = F(s, r).split(L).join("/");
460
+ for (const u of Ss(i)) {
461
461
  if (u.includes("_shared/") || u.startsWith("_shared")) {
462
462
  o.push(
463
463
  `${c}: imports ${u}, shared fixture folders are forbidden, stories are self contained and shared setup lives in a group harness component`
@@ -466,27 +466,27 @@ function Ss(e, t) {
466
466
  }
467
467
  const a = u.split("?")[0];
468
468
  if (a.startsWith("./") || a.startsWith("../")) {
469
- const l = j(N(r), a);
469
+ const l = x(N(r), a);
470
470
  Ze(l) || o.push(`${c}: unresolved import ${u}, fix the path or create the file`);
471
471
  continue;
472
472
  }
473
473
  const p = n.find((l) => a === l.find || a.startsWith(l.find + "/"));
474
474
  if (p) {
475
- const l = j(e, p.replacement + a.slice(p.find.length));
475
+ const l = x(e, p.replacement + a.slice(p.find.length));
476
476
  Ze(l) || o.push(`${c}: unresolved import ${u} via alias ${p.find}`);
477
477
  }
478
478
  }
479
479
  }
480
480
  return o;
481
481
  }
482
- function js(e, t) {
483
- const s = j(e, t.contentDir), n = [];
484
- if (!$(s)) return [`${t.contentDir}: contentDir does not exist`];
482
+ function Cs(e, t) {
483
+ const s = x(e, t.contentDir), n = [];
484
+ if (!b(s)) return [`${t.contentDir}: contentDir does not exist`];
485
485
  const o = /* @__PURE__ */ new Map();
486
486
  let r, i;
487
487
  const c = /* @__PURE__ */ new Map();
488
- for (const a of oe(s)) {
489
- const p = D(s, a).split(I).join("/"), l = N(a), m = F(a);
488
+ for (const a of Y(s)) {
489
+ const p = F(s, a).split(L).join("/"), l = N(a), m = D(a);
490
490
  if (m.endsWith(".md")) {
491
491
  const f = c.get(l) ?? [];
492
492
  f.push(a), c.set(l, f);
@@ -494,42 +494,42 @@ function js(e, t) {
494
494
  Ue.test(h) || n.push(`${p}: markdown file names are lowercase kebab case, rename to ${h.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9.-]+/g, "-")}.md`);
495
495
  let g;
496
496
  try {
497
- g = fe(C(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
497
+ g = le(C(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
498
498
  } catch {
499
499
  continue;
500
500
  }
501
- if (g?.type === "glossary" && (i ? n.push(`${p}: second type glossary page in the site, ${D(s, i).split(I).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(fe(C(a, "utf-8")).content) || n.push(`${p}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${I}index.md`) && n.push(`${p}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? n.push(`${p}: second type 404 page in the site, ${D(s, r).split(I).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
501
+ if (g?.type === "glossary" && (i ? n.push(`${p}: second type glossary page in the site, ${F(s, i).split(L).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(le(C(a, "utf-8")).content) || n.push(`${p}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${L}index.md`) && n.push(`${p}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? n.push(`${p}: second type 404 page in the site, ${F(s, r).split(L).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
502
502
  const w = o.get(l);
503
- w ? n.push(`${p}: second type component page in one folder, ${D(s, w).split(I).join("/")} already owns it, one component per folder`) : o.set(l, a);
503
+ w ? n.push(`${p}: second type component page in one folder, ${F(s, w).split(L).join("/")} already owns it, one component per folder`) : o.set(l, a);
504
504
  }
505
505
  if (g?.type === "dbml") {
506
506
  const w = typeof g.spec == "string" ? g.spec : "";
507
- w ? $(j(l, w)) || n.push(`${p}: spec ${w} does not resolve, create the file or fix the path`) : n.push(`${p}: type dbml needs a spec field pointing at the .dbml file`);
507
+ w ? b(x(l, w)) || n.push(`${p}: spec ${w} does not resolve, create the file or fix the path`) : n.push(`${p}: type dbml needs a spec field pointing at the .dbml file`);
508
508
  }
509
509
  g?.type === "changelog" && typeof g.path == "string" && n.push(`${p}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
510
510
  }
511
- if (m.endsWith(".css") && !m.startsWith("_") && F(N(a)) === "styles" && N(N(a)) === s) {
511
+ if (m.endsWith(".css") && !m.startsWith("_") && D(N(a)) === "styles" && N(N(a)) === s) {
512
512
  const f = m.replace(/\.css$/, "");
513
513
  ge.includes(f) || n.push(`${p}: ${f} is not a component class root, name the file after one of ${ge.join(", ")}`);
514
514
  continue;
515
515
  }
516
516
  if (m.endsWith(".css") && !m.startsWith("_") && m.split(".").length > 2) {
517
517
  const f = m.split(".")[0], h = Qt(m, f);
518
- if (h && $(d(N(a), `${f}.md`))) {
518
+ if (h && b(d(N(a), `${f}.md`))) {
519
519
  ge.includes(h) || n.push(`${p}: ${h} is not a component class root, name the file after one of ${ge.join(", ")}`);
520
520
  continue;
521
521
  }
522
522
  }
523
523
  if (m.endsWith(".css") && !m.startsWith("_")) {
524
524
  const f = a.replace(/\.css$/, ".md");
525
- $(f) || n.push(`${p}: page css without a matching ${F(f)}, page styles are named after the page they scope`);
525
+ b(f) || n.push(`${p}: page css without a matching ${D(f)}, page styles are named after the page they scope`);
526
526
  }
527
527
  }
528
528
  for (const [a, p] of c) {
529
- const l = D(s, a).split(I).join("/") || ".", m = o.has(a);
529
+ const l = F(s, a).split(L).join("/") || ".", m = o.has(a);
530
530
  let f = [];
531
531
  try {
532
- f = se(a);
532
+ f = re(a);
533
533
  } catch {
534
534
  continue;
535
535
  }
@@ -537,21 +537,21 @@ function js(e, t) {
537
537
  for (const g of ["schema.json", "schema.yml"])
538
538
  f.includes(g) && !m && n.push(`${l}: ${g} without a type component page, it belongs beside the component index.md`);
539
539
  if (m && p.length > 1) {
540
- const g = p.filter((w) => w !== o.get(a)).map((w) => F(w));
540
+ const g = p.filter((w) => w !== o.get(a)).map((w) => D(w));
541
541
  n.push(`${l}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
542
542
  }
543
543
  }
544
544
  const u = (a) => {
545
545
  let p;
546
546
  try {
547
- p = se(a, { withFileTypes: !0 });
547
+ p = re(a, { withFileTypes: !0 });
548
548
  } catch {
549
549
  return;
550
550
  }
551
551
  for (const l of p)
552
552
  if (l.isDirectory() && !(l.name.startsWith(".") || l.name === "node_modules")) {
553
- if (!Ue.test(l.name) && !vs.test(l.name)) {
554
- const m = D(s, d(a, l.name)).split(I).join("/");
553
+ if (!Ue.test(l.name) && !ks.test(l.name)) {
554
+ const m = F(s, d(a, l.name)).split(L).join("/");
555
555
  n.push(`${m}/: folder names are lowercase kebab case, or PascalCase for component and group folders, rename it`);
556
556
  }
557
557
  u(d(a, l.name));
@@ -559,8 +559,8 @@ function js(e, t) {
559
559
  };
560
560
  return u(s), n;
561
561
  }
562
- async function Cs(e, t) {
563
- const s = ot(e, t, "lint"), n = () => ne(s, { recursive: !0, force: !0 }), o = () => {
562
+ async function Es(e, t) {
563
+ const s = ot(e, t, "lint"), n = () => q(s, { recursive: !0, force: !0 }), o = () => {
564
564
  n(), process.exit(130);
565
565
  };
566
566
  process.once("SIGINT", o), process.once("SIGTERM", o);
@@ -573,23 +573,23 @@ async function Cs(e, t) {
573
573
  process.off("SIGINT", o), process.off("SIGTERM", o), n();
574
574
  }
575
575
  }
576
- async function Es(e, t) {
576
+ async function Os(e, t) {
577
577
  const s = process.argv.slice(2), n = [
578
- ...js(e, t),
578
+ ...Cs(e, t),
579
579
  ...(Kt(e, t.pageTypes ?? {}), await Yt(e, t.contentDir)),
580
- ...Ss(e, t),
580
+ ...js(e, t),
581
581
  ...await ft(e, t)
582
582
  ];
583
583
  if (n.length) {
584
584
  Ne("nimpress lint", n, "");
585
585
  return;
586
586
  }
587
- if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), M(s, "no-build")) return;
587
+ if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), I(s, "no-build")) return;
588
588
  console.log("nimpress lint: building to verify the output compiles");
589
- const o = await Cs(e, t);
589
+ const o = await Es(e, t);
590
590
  Ne("nimpress lint", o, "nimpress lint: build ok, everything passes");
591
591
  }
592
- const Os = {
592
+ const Fs = {
593
593
  ".json": "application/json",
594
594
  ".xml": "application/rss+xml",
595
595
  ".html": "text/html",
@@ -602,25 +602,25 @@ const Os = {
602
602
  ".webp": "image/webp",
603
603
  ".pdf": "application/pdf"
604
604
  };
605
- function Fs(e, t, s) {
605
+ function Ds(e, t, s) {
606
606
  const n = s[0], o = d(e, _(s, "dist") ?? t.paths.out), r = `/${t.paths.guarded}/`, i = d(o, "access.json");
607
- if (!$(i))
607
+ if (!b(i))
608
608
  throw new Error(`[nimpress] guard: ${i} not found, run a build first`);
609
609
  const c = JSON.parse(C(i, "utf-8"));
610
610
  if (n === "map") {
611
- const u = Ge(o, t), a = d(o, "guard.map.json"), p = $(a) ? JSON.parse(C(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, l = $(u) ? oe(u) : [], m = p.prefix ?? r, f = l.map((w) => {
612
- const v = D(u, w).split("\\").join("/"), O = v.split("/")[0] ?? "", E = [
611
+ const u = Ge(o, t), a = d(o, "guard.map.json"), p = b(a) ? JSON.parse(C(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, l = b(u) ? Y(u) : [], m = p.prefix ?? r, f = l.map((w) => {
612
+ const k = F(u, w).split("\\").join("/"), j = k.split("/")[0] ?? "", E = [
613
613
  ...new Set(
614
- Object.values(p.routes ?? {}).filter((T) => T.bundle === O && T.gate).map((T) => T.gate)
614
+ Object.values(p.routes ?? {}).filter((R) => R.bundle === j && R.gate).map((R) => R.gate)
615
615
  )
616
- ], k = C(w);
616
+ ], v = C(w);
617
617
  return {
618
- path: `${m}${v}`,
619
- file: v,
620
- bundle: O,
621
- sha256: ut("sha256").update(k).digest("hex"),
618
+ path: `${m}${k}`,
619
+ file: k,
620
+ bundle: j,
621
+ sha256: ut("sha256").update(v).digest("hex"),
622
622
  size: it(w).size,
623
- mime: Os[me(w).toLowerCase()] ?? "application/octet-stream",
623
+ mime: Fs[fe(w).toLowerCase()] ?? "application/octet-stream",
624
624
  gates: E
625
625
  };
626
626
  }), h = _(s, "out"), g = h ? d(e, h) : a;
@@ -643,17 +643,17 @@ function Fs(e, t, s) {
643
643
  asset_id: p.asset_id,
644
644
  url: p.url
645
645
  })), W(i, JSON.stringify(c, null, 2) + `
646
- `), ne(Ge(o, t), { recursive: !0, force: !0 }), ne(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
646
+ `), q(Ge(o, t), { recursive: !0, force: !0 }), q(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
647
647
  return;
648
648
  }
649
649
  throw new Error("[nimpress] guard expects map or apply");
650
650
  }
651
651
  function $t(e) {
652
- const t = me(e);
652
+ const t = fe(e);
653
653
  return t === ".vue" ? "vue" : t === ".svelte" ? "svelte" : null;
654
654
  }
655
655
  async function Le(e, t, s, n, o) {
656
- const i = (await Pe(e, t.contentDir)).find((m) => m.system === s && m.component === n);
656
+ const i = (await Ae(e, t.contentDir)).find((m) => m.system === s && m.component === n);
657
657
  if (!i)
658
658
  return console.warn(`[nimpress] modules story: no type component page found for ${s}/${n}`), null;
659
659
  const c = Me(e, t.modules, s, n, i.file);
@@ -671,10 +671,10 @@ export default ${a}({
671
671
  name: "Default"
672
672
  })
673
673
  `, l = d(N(i.pageFile), "default.story.tsx");
674
- return $(l) ? (console.warn(`[nimpress] modules story: ${l} exists, not overwriting`), null) : (await Q(l, p), l);
674
+ return b(l) ? (console.warn(`[nimpress] modules story: ${l} exists, not overwriting`), null) : (await X(l, p), l);
675
675
  }
676
- async function Ds(e, t, s) {
677
- const n = await Pe(e, t.contentDir);
676
+ async function _s(e, t, s) {
677
+ const n = await Ae(e, t.contentDir);
678
678
  let o = 0;
679
679
  for (const r of n)
680
680
  if (!(r.system !== s || (await tt(N(r.pageFile))).length))
@@ -685,16 +685,16 @@ async function Ds(e, t, s) {
685
685
  }
686
686
  return o;
687
687
  }
688
- async function _s(e, t, s, n, o) {
688
+ async function Ns(e, t, s, n, o) {
689
689
  const r = t.modules.systems[s];
690
690
  if (!r) throw new Error(`[nimpress] modules create: unknown system ${s}`);
691
691
  const i = d(e, t.contentDir, "components", "Components", n), c = d(i, "index.md");
692
- if ($(c))
692
+ if (b(c))
693
693
  throw new Error(`[nimpress] modules create: ${c} exists`);
694
694
  const { mkdir: u } = await import("node:fs/promises");
695
695
  await u(i, { recursive: !0 });
696
696
  const a = r.package;
697
- await Q(
697
+ await X(
698
698
  c,
699
699
  `---
700
700
  title: ${n}
@@ -715,10 +715,10 @@ import { ${n} } from "${a ?? s}";
715
715
  const p = Me(e, t.modules, s, n);
716
716
  if (p) {
717
717
  const l = o ?? $t(p.componentFile) ?? r.framework;
718
- await pe(i, n, await ue(p.componentFile, l, n)), await Le(e, t, s, n, o);
718
+ await me(i, n, await pe(p.componentFile, l, n)), await Le(e, t, s, n, o);
719
719
  } else {
720
720
  const l = r.framework === "vue" ? "vueStory" : "svelteStory";
721
- await Q(
721
+ await X(
722
722
  d(i, "default.story.tsx"),
723
723
  `import { ${l} } from '@nimtech/nimpress/story'
724
724
 
@@ -744,7 +744,7 @@ function ye(e) {
744
744
  function be(e, t = []) {
745
745
  let s;
746
746
  try {
747
- s = se(e, { withFileTypes: !0 });
747
+ s = re(e, { withFileTypes: !0 });
748
748
  } catch {
749
749
  return t;
750
750
  }
@@ -781,8 +781,8 @@ function Te(e) {
781
781
  break;
782
782
  }
783
783
  const r = N(e), i = [], c = (f) => {
784
- const h = j(r, f);
785
- return /\.(vue|svelte)$/.test(f) ? { kind: "source", abs: h } : f.endsWith(".ts") ? $(h) ? { kind: "data", abs: h } : null : $(`${h}.ts`) ? { kind: "data", abs: `${h}.ts` } : $(`${h}.vue`) || $(`${h}.svelte`) || $(d(h, "index.ts")) ? { kind: "source", abs: h } : null;
784
+ const h = x(r, f);
785
+ return /\.(vue|svelte)$/.test(f) ? { kind: "source", abs: h } : f.endsWith(".ts") ? b(h) ? { kind: "data", abs: h } : null : b(`${h}.ts`) ? { kind: "data", abs: `${h}.ts` } : b(`${h}.vue`) || b(`${h}.svelte`) || b(d(h, "index.ts")) ? { kind: "source", abs: h } : null;
786
786
  };
787
787
  for (const f of n) {
788
788
  const h = f.match(/from\s+["'](\.\.?\/[^"']+)["']/)?.[1];
@@ -793,7 +793,7 @@ function Te(e) {
793
793
  const u = n.filter((f) => !f.includes("@storybook")).map(
794
794
  (f) => f.replace(/from\s+["'](\.\.?\/[^"']+)["']/g, (h, g) => {
795
795
  const w = c(g);
796
- return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${F(g).replace(/\.ts$/, "")}"`;
796
+ return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${D(g).replace(/\.ts$/, "")}"`;
797
797
  })
798
798
  ).join(`
799
799
  `);
@@ -808,8 +808,8 @@ function Te(e) {
808
808
  `, h) + 1);
809
809
  return;
810
810
  }
811
- const w = $e(a, g + 1), v = g + 1 + w.length + 1, O = a.slice(v).match(/^[^\n]*/)?.[0] ?? "";
812
- a = a.slice(0, h) + a.slice(v + O.length);
811
+ const w = $e(a, g + 1), k = g + 1 + w.length + 1, j = a.slice(k).match(/^[^\n]*/)?.[0] ?? "";
812
+ a = a.slice(0, h) + a.slice(k + j.length);
813
813
  };
814
814
  p(/^const meta\b[^\n]*/m), a = a.replace(/^export default meta;?\s*$/m, ""), a = a.replace(/^(?:export )?type \w+[^\n]*\n(?:[ \t]+[^\n]*\n?)*/gm, "");
815
815
  let l = 0;
@@ -828,7 +828,7 @@ function Te(e) {
828
828
  dataModules: i
829
829
  };
830
830
  }
831
- function Ns(e, t) {
831
+ function Ws(e, t) {
832
832
  const s = e.indexOf(":", t) + 1;
833
833
  let n = 0, o = null;
834
834
  for (let r = s; r < e.length; r++) {
@@ -858,7 +858,7 @@ function bt(e) {
858
858
  if (o === "default" || o === "meta") continue;
859
859
  const r = $e(e.text, s.lastIndex), i = r.search(/\brender\s*:/);
860
860
  if (i >= 0) {
861
- const a = Ns(r, i);
861
+ const a = Ws(r, i);
862
862
  if (a) {
863
863
  t.push({ name: o, renderFn: a });
864
864
  continue;
@@ -940,149 +940,149 @@ async function kt(e) {
940
940
  }
941
941
  function xt(e, t) {
942
942
  const s = /* @__PURE__ */ new Map(), n = d(e, "node_modules", t, "index.mjs");
943
- if (!$(n)) return s;
943
+ if (!b(n)) return s;
944
944
  const o = C(n, "utf-8");
945
945
  for (const r of o.matchAll(/export \{ default as ([A-Za-z]+) \}/g))
946
946
  s.set(r[1].toLowerCase(), r[1]);
947
947
  return s;
948
948
  }
949
- async function Ws(e, t, s, n) {
949
+ async function Ts(e, t, s, n) {
950
950
  const o = t.modules.systems[s];
951
951
  if (!o) throw new Error(`[nimpress] modules import: unknown system ${s}`);
952
952
  const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"), u = o.package, a = n.match ? new RegExp(n.match) : null;
953
953
  if (n.file) {
954
- const y = j(e, n.file);
955
- if (!$(y)) throw new Error(`[nimpress] modules import: ${y} not found`);
956
- if (me(y) !== i)
957
- throw new Error(`[nimpress] modules import: ${y} does not match system framework ${r}`);
958
- const b = n.name ?? F(y, i), U = o.source ? j(e, o.source) : e, A = d(c, "Components", b);
959
- await _e(A, { recursive: !0 });
960
- const P = D(U, y);
961
- await Q(d(A, "index.md"), Re(s, b, u, P)), await pe(A, b, await ue(y, r, b)), console.log(`nimpress modules: imported ${b} at ${D(e, A)}`);
954
+ const $ = x(e, n.file);
955
+ if (!b($)) throw new Error(`[nimpress] modules import: ${$} not found`);
956
+ if (fe($) !== i)
957
+ throw new Error(`[nimpress] modules import: ${$} does not match system framework ${r}`);
958
+ const y = n.name ?? D($, i), M = o.source ? x(e, o.source) : e, P = d(c, "Components", y);
959
+ await _e(P, { recursive: !0 });
960
+ const A = F(M, $);
961
+ await X(d(P, "index.md"), Pe(s, y, u, A)), await me(P, y, await pe($, r, y)), console.log(`nimpress modules: imported ${y} at ${F(e, P)}`);
962
962
  return;
963
963
  }
964
964
  if (n.fromStories) {
965
- await Ts(e, t, s, n);
965
+ await Ps(e, t, s, n);
966
966
  return;
967
967
  }
968
- const p = j(e, n.source ?? o.source ?? "");
969
- if (!$(p))
968
+ const p = x(e, n.source ?? o.source ?? "");
969
+ if (!b(p))
970
970
  throw new Error(`[nimpress] modules import: source ${p} not found`);
971
- const l = be(p), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = l.filter((y) => y.endsWith(".stories.ts")), g = n.stories ? [j(e, n.stories)] : [];
972
- for (const y of g)
973
- for (const b of be(y))
974
- b.endsWith(".stories.ts") && h.push(b);
971
+ const l = be(p), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = l.filter(($) => $.endsWith(".stories.ts")), g = n.stories ? [x(e, n.stories)] : [];
972
+ for (const $ of g)
973
+ for (const y of be($))
974
+ y.endsWith(".stories.ts") && h.push(y);
975
975
  const w = l.filter(
976
- (y) => y.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(F(y, i))
977
- ), v = new Set(w.map((y) => F(y, i))), O = u && !o.source ? xt(e, u) : null;
978
- for (const y of h) {
979
- const b = Te(y);
980
- if (b.title?.includes("/")) {
981
- const [B, L] = b.title.split("/");
982
- m.set(L, B.replace(/\s+/g, ""));
976
+ ($) => $.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(D($, i))
977
+ ), k = new Set(w.map(($) => D($, i))), j = u && !o.source ? xt(e, u) : null;
978
+ for (const $ of h) {
979
+ const y = Te($);
980
+ if (y.title?.includes("/")) {
981
+ const [G, z] = y.title.split("/");
982
+ m.set(z, G.replace(/\s+/g, ""));
983
983
  }
984
- const U = F(y, ".stories.ts");
985
- let P = $(d(N(y), `${U}${i}`)) ? U : b.metaComponent ?? U;
986
- if (!v.has(P)) {
987
- let B = "";
988
- for (const L of v)
989
- U.startsWith(L) && L.length > B.length && (B = L);
990
- B ? P = B : console.warn(`nimpress modules: ${F(y)} targets ${P} which has no component page`);
984
+ const M = D($, ".stories.ts");
985
+ let A = b(d(N($), `${M}${i}`)) ? M : y.metaComponent ?? M;
986
+ if (!k.has(A)) {
987
+ let G = "";
988
+ for (const z of k)
989
+ M.startsWith(z) && z.length > G.length && (G = z);
990
+ G ? A = G : console.warn(`nimpress modules: ${D($)} targets ${A} which has no component page`);
991
991
  }
992
- const S = O?.get(P.toLowerCase()) ?? P, Z = f.get(S) ?? [];
993
- Z.push(b), f.set(S, Z);
992
+ const S = j?.get(A.toLowerCase()) ?? A, Z = f.get(S) ?? [];
993
+ Z.push(y), f.set(S, Z);
994
994
  }
995
995
  const E = /* @__PURE__ */ new Map();
996
- let k = 0, T = 0;
997
- const x = w.filter((y) => !a || a.test(F(y, i))), R = n.select ? await kt(x.map((y) => F(y, i))) : null;
998
- for (const y of x) {
999
- const b = F(y, i);
1000
- if (R && !R.has(b)) continue;
1001
- if (E.has(b)) {
1002
- console.warn(`nimpress modules: skip duplicate ${b}, kept ${E.get(b)}`);
996
+ let v = 0, R = 0;
997
+ const O = w.filter(($) => !a || a.test(D($, i))), T = n.select ? await kt(O.map(($) => D($, i))) : null;
998
+ for (const $ of O) {
999
+ const y = D($, i);
1000
+ if (T && !T.has(y)) continue;
1001
+ if (E.has(y)) {
1002
+ console.warn(`nimpress modules: skip duplicate ${y}, kept ${E.get(y)}`);
1003
1003
  continue;
1004
1004
  }
1005
- E.set(b, D(p, y));
1006
- const U = m.get(b) ?? "Components", A = d(c, U, b);
1007
- await _e(A, { recursive: !0 });
1008
- const P = D(p, y), S = P === `${b}/${b}${i}` || P === `${b}${i}`, Z = (f.get(b) ?? []).map((G) => vt(G)).reduce(
1009
- (G, q) => q ? { ...G ?? {}, ...q } : G,
1005
+ E.set(y, F(p, $));
1006
+ const M = m.get(y) ?? "Components", P = d(c, M, y);
1007
+ await _e(P, { recursive: !0 });
1008
+ const A = F(p, $), S = A === `${y}/${y}${i}` || A === `${y}${i}`, Z = (f.get(y) ?? []).map((H) => vt(H)).reduce(
1009
+ (H, te) => te ? { ...H ?? {}, ...te } : H,
1010
1010
  void 0
1011
1011
  );
1012
- await Q(d(A, "index.md"), Re(s, b, u, S ? void 0 : P)), await pe(A, b, await ue(y, r, b)), Z && await rt(A, { properties: Z }), k++;
1013
- const B = f.get(b) ?? [], L = /* @__PURE__ */ new Set();
1014
- for (const G of B) {
1015
- const q = F(G.file, ".stories.ts"), ze = bt(G);
1016
- ze.length || console.warn(`nimpress modules: no stories mined from ${F(G.file)}`);
1017
- for (const Y of G.dataModules)
1018
- await at(Y, d(A, F(Y)));
1019
- for (const Y of ze) {
1020
- const Je = Y.name === b ? "Default" : q === b ? Y.name : `${q} ${Y.name}`;
1012
+ await X(d(P, "index.md"), Pe(s, y, u, S ? void 0 : A)), await me(P, y, await pe($, r, y)), Z && await rt(P, { properties: Z }), v++;
1013
+ const G = f.get(y) ?? [], z = /* @__PURE__ */ new Set();
1014
+ for (const H of G) {
1015
+ const te = D(H.file, ".stories.ts"), ze = bt(H);
1016
+ ze.length || console.warn(`nimpress modules: no stories mined from ${D(H.file)}`);
1017
+ for (const Q of H.dataModules)
1018
+ await at(Q, d(P, D(Q)));
1019
+ for (const Q of ze) {
1020
+ const Je = Q.name === y ? "Default" : te === y ? Q.name : `${te} ${Q.name}`;
1021
1021
  let he = We(Je);
1022
- L.has(he) && (he = We(`${q}-${Y.name}`));
1023
- const Be = d(A, `${he}.story.tsx`);
1024
- L.add(he), !$(Be) && (await Q(Be, St(r, Je, q, Y, G)), T++);
1022
+ z.has(he) && (he = We(`${te}-${Q.name}`));
1023
+ const Be = d(P, `${he}.story.tsx`);
1024
+ z.add(he), !b(Be) && (await X(Be, St(r, Je, te, Q, H)), R++);
1025
1025
  }
1026
1026
  }
1027
1027
  }
1028
- console.log(`nimpress modules: imported ${k} components with ${T} stories for ${s}`);
1028
+ console.log(`nimpress modules: imported ${v} components with ${R} stories for ${s}`);
1029
1029
  }
1030
- async function Ts(e, t, s, n) {
1031
- const o = t.modules.systems[s], r = o.framework, i = d(e, t.contentDir, "components"), c = j(e, n.stories ?? "");
1032
- if (!n.stories || !$(c))
1030
+ async function Ps(e, t, s, n) {
1031
+ const o = t.modules.systems[s], r = o.framework, i = d(e, t.contentDir, "components"), c = x(e, n.stories ?? "");
1032
+ if (!n.stories || !b(c))
1033
1033
  throw new Error("[nimpress] modules import --from-stories requires --stories=<csf dir>");
1034
- const u = o.source ? j(e, o.source) : e, a = n.match ? new RegExp(n.match) : null, p = /* @__PURE__ */ new Set();
1034
+ const u = o.source ? x(e, o.source) : e, a = n.match ? new RegExp(n.match) : null, p = /* @__PURE__ */ new Set();
1035
1035
  let l = 0, m = 0;
1036
1036
  const f = be(c).filter((g) => g.endsWith(".stories.ts")), h = n.select ? await kt(
1037
- f.map((g) => Te(g).metaComponent ?? F(g, ".stories.ts"))
1037
+ f.map((g) => Te(g).metaComponent ?? D(g, ".stories.ts"))
1038
1038
  ) : null;
1039
1039
  for (const g of f) {
1040
- const w = Te(g), v = F(g, ".stories.ts"), O = w.metaComponent ?? v;
1041
- if (h && !h.has(O)) continue;
1040
+ const w = Te(g), k = D(g, ".stories.ts"), j = w.metaComponent ?? k;
1041
+ if (h && !h.has(j)) continue;
1042
1042
  const E = w.text.match(
1043
- new RegExp(`import\\s+(?:\\{\\s*)?${O}(?:\\s*\\})?\\s+from\\s+["']([^"']+)["']`)
1043
+ new RegExp(`import\\s+(?:\\{\\s*)?${j}(?:\\s*\\})?\\s+from\\s+["']([^"']+)["']`)
1044
1044
  )?.[1];
1045
- let k = O, T = o.package, x;
1045
+ let v = j, R = o.package, O;
1046
1046
  if (E && !E.startsWith(".") && !E.startsWith("@/")) {
1047
1047
  const S = E.split("/")[0].startsWith("@") ? E.split("/").slice(0, 2).join("/") : E.split("/")[0];
1048
- T = S, k = xt(e, S).get(O.toLowerCase()) ?? O;
1048
+ R = S, v = xt(e, S).get(j.toLowerCase()) ?? j;
1049
1049
  } else if (E?.startsWith("@/components/")) {
1050
1050
  const S = E.slice(13);
1051
- S === k || S === `${k}/${k}.vue` || (x = S.endsWith(".vue") || S.endsWith(".svelte") ? S : `${S}/${k}.vue`);
1051
+ S === v || S === `${v}/${v}.vue` || (O = S.endsWith(".vue") || S.endsWith(".svelte") ? S : `${S}/${v}.vue`);
1052
1052
  } else if (E?.startsWith(".")) {
1053
- const S = j(N(g), E);
1054
- x = D(u, S);
1053
+ const S = x(N(g), E);
1054
+ O = F(u, S);
1055
1055
  }
1056
- if (a && !a.test(k)) continue;
1057
- if (p.has(k)) {
1058
- console.warn(`nimpress modules: skip duplicate ${k} from ${F(g)}`);
1056
+ if (a && !a.test(v)) continue;
1057
+ if (p.has(v)) {
1058
+ console.warn(`nimpress modules: skip duplicate ${v} from ${D(g)}`);
1059
1059
  continue;
1060
1060
  }
1061
- p.add(k);
1062
- const R = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", y = d(i, R, k);
1063
- await _e(y, { recursive: !0 }), await Q(d(y, "index.md"), Re(s, k, T, x));
1064
- const b = r === "vue" ? ".vue" : ".svelte", A = (x ? [j(u, x)] : [
1065
- d(u, k, `${k}${b}`),
1066
- d(u, `${k}${b}`)
1067
- ]).find((S) => $(S));
1068
- if (A)
1069
- await pe(y, k, await ue(A, r, k));
1070
- else if (T) {
1071
- const S = Xt(e, T, k);
1072
- S ? await pe(y, k, qt(C(S, "utf-8"), k)) : console.warn(`nimpress modules: no source or d.ts found for ${k}, the schema seed is skipped`);
1061
+ p.add(v);
1062
+ const T = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", $ = d(i, T, v);
1063
+ await _e($, { recursive: !0 }), await X(d($, "index.md"), Pe(s, v, R, O));
1064
+ const y = r === "vue" ? ".vue" : ".svelte", P = (O ? [x(u, O)] : [
1065
+ d(u, v, `${v}${y}`),
1066
+ d(u, `${v}${y}`)
1067
+ ]).find((S) => b(S));
1068
+ if (P)
1069
+ await me($, v, await pe(P, r, v));
1070
+ else if (R) {
1071
+ const S = Xt(e, R, v);
1072
+ S ? await me($, v, qt(C(S, "utf-8"), v)) : console.warn(`nimpress modules: no source or d.ts found for ${v}, the schema seed is skipped`);
1073
1073
  }
1074
- const P = vt(w);
1075
- P && await rt(y, { properties: P }), l++;
1074
+ const A = vt(w);
1075
+ A && await rt($, { properties: A }), l++;
1076
1076
  for (const S of w.dataModules)
1077
- await at(S, d(y, F(S)));
1077
+ await at(S, d($, D(S)));
1078
1078
  for (const S of bt(w)) {
1079
- const Z = S.name === k ? "Default" : S.name, B = We(Z), L = d(y, `${B}.story.tsx`);
1080
- $(L) || (await Q(L, St(r, Z, v, S, w)), m++);
1079
+ const Z = S.name === v ? "Default" : S.name, G = We(Z), z = d($, `${G}.story.tsx`);
1080
+ b(z) || (await X(z, St(r, Z, k, S, w)), m++);
1081
1081
  }
1082
1082
  }
1083
1083
  console.log(`nimpress modules: imported ${l} components with ${m} stories for ${s} from stories`);
1084
1084
  }
1085
- function Re(e, t, s, n) {
1085
+ function Pe(e, t, s, n) {
1086
1086
  const o = s ? `
1087
1087
  package: "${s}"` : "", r = n ? `
1088
1088
  file: ${JSON.stringify(n)}` : "";
@@ -1123,7 +1123,7 @@ export default ${r}({
1123
1123
  })
1124
1124
  `;
1125
1125
  }
1126
- function le(e, t) {
1126
+ function ue(e, t) {
1127
1127
  const s = _(t, "system");
1128
1128
  if (s === void 0) return;
1129
1129
  const n = Object.keys(e.modules.systems);
@@ -1132,7 +1132,7 @@ function le(e, t) {
1132
1132
  return s;
1133
1133
  }
1134
1134
  function je(e, t, s) {
1135
- const n = le(e, t);
1135
+ const n = ue(e, t);
1136
1136
  if (n) return n;
1137
1137
  const o = Object.keys(e.modules.systems);
1138
1138
  if (o.length === 1) return o[0];
@@ -1147,36 +1147,36 @@ async function Rs(e, t, s) {
1147
1147
  return;
1148
1148
  }
1149
1149
  if (n === "dev") {
1150
- const i = le(t, o), c = i ? [i] : r;
1150
+ const i = ue(t, o), c = i ? [i] : r;
1151
1151
  if (!c.length) throw new Error("[nimpress] modules dev: no systems configured");
1152
1152
  await ht(e, t, c), await new Promise(() => {
1153
1153
  });
1154
1154
  }
1155
1155
  if (n === "build") {
1156
- const i = le(t, o), c = i ? [i] : dt(t);
1156
+ const i = ue(t, o), c = i ? [i] : dt(t);
1157
1157
  if (!c.length) throw new Error("[nimpress] modules build: no systems configured");
1158
1158
  await gt(e, t, c);
1159
1159
  return;
1160
1160
  }
1161
1161
  if (n === "lint") {
1162
- const i = await ft(e, t, le(t, o));
1162
+ const i = await ft(e, t, ue(t, o));
1163
1163
  Ne("nimpress modules lint", i, "nimpress modules lint: systems, schemas, and stories ok");
1164
1164
  return;
1165
1165
  }
1166
1166
  if (n === "story") {
1167
- const i = je(t, o, "story"), c = re(o, 0), u = _(o, "framework");
1167
+ const i = je(t, o, "story"), c = ie(o, 0), u = _(o, "framework");
1168
1168
  if (c) {
1169
1169
  const p = await Le(e, t, i, c, u);
1170
1170
  p && console.log(`nimpress modules: story written to ${p}`);
1171
1171
  return;
1172
1172
  }
1173
- const a = await Ds(e, t, i);
1173
+ const a = await _s(e, t, i);
1174
1174
  console.log(`nimpress modules: ${a} auto stories written for ${i}`);
1175
1175
  return;
1176
1176
  }
1177
1177
  if (n === "import") {
1178
- const i = je(t, o, "import"), c = re(o, 0);
1179
- await Ws(e, t, i, {
1178
+ const i = je(t, o, "import"), c = ie(o, 0);
1179
+ await Ts(e, t, i, {
1180
1180
  file: c,
1181
1181
  name: _(o, "name"),
1182
1182
  source: _(o, "source"),
@@ -1188,33 +1188,33 @@ async function Rs(e, t, s) {
1188
1188
  return;
1189
1189
  }
1190
1190
  if (n === "update") {
1191
- const i = _(o, "component") ?? re(o, 0), c = await es(e, t, { ref: i, system: le(t, o) });
1191
+ const i = _(o, "component") ?? ie(o, 0), c = await es(e, t, { ref: i, system: ue(t, o) });
1192
1192
  console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`), De(e);
1193
1193
  return;
1194
1194
  }
1195
1195
  if (n === "create") {
1196
1196
  const i = _(o, "component");
1197
1197
  if (i) {
1198
- if (!M(o, "schema"))
1198
+ if (!I(o, "schema"))
1199
1199
  throw new Error("[nimpress] modules create --component expects --schema to upsert the schema");
1200
1200
  const l = await ts(e, t, i);
1201
1201
  console.log(`nimpress modules: schema upserted at ${l}`);
1202
1202
  return;
1203
1203
  }
1204
- const c = re(o, 0);
1204
+ const c = ie(o, 0);
1205
1205
  if (!c)
1206
1206
  throw new Error("[nimpress] modules create expects: nimpress modules create <Component> [--system=<name>], or --component=<ref> --schema");
1207
- const u = je(t, o, "create"), a = _(o, "framework"), p = await _s(e, t, u, c, a);
1208
- console.log(`nimpress modules: created ${c} at ${D(e, p)}`);
1207
+ const u = je(t, o, "create"), a = _(o, "framework"), p = await Ns(e, t, u, c, a);
1208
+ console.log(`nimpress modules: created ${c} at ${F(e, p)}`);
1209
1209
  return;
1210
1210
  }
1211
1211
  throw new Error("[nimpress] modules expects init, dev, build, lint, story, import, create or update");
1212
1212
  }
1213
1213
  function As(e, t) {
1214
1214
  const s = d(e, t.modules.dir);
1215
- J(s, { recursive: !0 });
1215
+ B(s, { recursive: !0 });
1216
1216
  const n = d(e, "nimpress.config.json");
1217
- if ($(n)) {
1217
+ if (b(n)) {
1218
1218
  const o = JSON.parse(C(n, "utf-8"));
1219
1219
  o.modules || (o.modules = { dir: t.modules.dir, route: t.modules.route, systems: {} }, W(n, JSON.stringify(o, null, 2) + `
1220
1220
  `), console.log(`nimpress modules: modules block added to ${n}`));
@@ -1229,7 +1229,7 @@ function jt(e) {
1229
1229
  ---`, 4);
1230
1230
  return t < 0 ? null : e.slice(4, t);
1231
1231
  }
1232
- function Ps(e) {
1232
+ function Ms(e) {
1233
1233
  for (const t of e.split(`
1234
1234
  `)) {
1235
1235
  if (!t.startsWith("export:")) continue;
@@ -1238,7 +1238,7 @@ function Ps(e) {
1238
1238
  }
1239
1239
  return null;
1240
1240
  }
1241
- function Ms(e, t) {
1241
+ function Is(e, t) {
1242
1242
  const s = jt(e);
1243
1243
  if (s === null) return e;
1244
1244
  const n = s.split(`
@@ -1247,7 +1247,7 @@ function Ms(e, t) {
1247
1247
  ${n.join(`
1248
1248
  `)}${e.slice(4 + s.length)}`;
1249
1249
  }
1250
- function Ae(e, t, s) {
1250
+ function Re(e, t, s) {
1251
1251
  const n = _(s, "target") ?? "", o = d(e, _(s, "out") ?? t.paths.export), r = d(e, t.contentDir);
1252
1252
  let i = "";
1253
1253
  try {
@@ -1256,20 +1256,20 @@ function Ae(e, t, s) {
1256
1256
  i = "";
1257
1257
  }
1258
1258
  let c = 0;
1259
- for (const u of oe(r)) {
1259
+ for (const u of Y(r)) {
1260
1260
  if (!u.endsWith(".md")) continue;
1261
1261
  const a = C(u, "utf-8"), p = jt(a);
1262
1262
  if (p === null) continue;
1263
- const l = Ps(p);
1263
+ const l = Ms(p);
1264
1264
  if (l === null || n && l !== n && l !== "true") continue;
1265
- const m = N(u), f = d(o, D(r, m));
1266
- J(f, { recursive: !0 });
1267
- for (const h of se(m, { withFileTypes: !0 })) {
1265
+ const m = N(u), f = d(o, F(r, m));
1266
+ B(f, { recursive: !0 });
1267
+ for (const h of re(m, { withFileTypes: !0 })) {
1268
1268
  if (!h.isFile()) continue;
1269
1269
  const g = C(d(m, h.name), "utf-8");
1270
1270
  W(
1271
1271
  d(f, h.name),
1272
- h.name.endsWith(".md") ? Ms(g, i) : g
1272
+ h.name.endsWith(".md") ? Is(g, i) : g
1273
1273
  );
1274
1274
  }
1275
1275
  c++;
@@ -1279,9 +1279,9 @@ function Ae(e, t, s) {
1279
1279
  const Ce = d(".claude", "skills", "nimpress", "SKILL.md");
1280
1280
  function Ct() {
1281
1281
  const e = N(mt(import.meta.url)), t = [
1282
- j(e, Ce),
1283
- j(e, "..", Ce),
1284
- j(e, "..", "..", Ce)
1282
+ x(e, Ce),
1283
+ x(e, "..", Ce),
1284
+ x(e, "..", "..", Ce)
1285
1285
  ];
1286
1286
  for (const s of t)
1287
1287
  try {
@@ -1292,41 +1292,41 @@ function Ct() {
1292
1292
  }
1293
1293
  function Et(e, t) {
1294
1294
  const s = t ? d(K(), ".claude") : d(e, ".claude"), n = d(s, "skills", "nimpress");
1295
- J(n, { recursive: !0 });
1295
+ B(n, { recursive: !0 });
1296
1296
  const o = d(n, "SKILL.md");
1297
1297
  return W(o, Ct()), console.log(`wrote ${o}`), o;
1298
1298
  }
1299
- function Is(e, t) {
1299
+ function Ls(e, t) {
1300
1300
  const s = t[0];
1301
1301
  if (s === "get") {
1302
1302
  process.stdout.write(Ct());
1303
1303
  return;
1304
1304
  }
1305
1305
  if (s === "put") {
1306
- Et(e, !M(t, "project"));
1306
+ Et(e, !I(t, "project"));
1307
1307
  return;
1308
1308
  }
1309
1309
  throw new Error("[nimpress] skill expects get or put");
1310
1310
  }
1311
- const Ls = "nimling/nimpress", zs = "nimpress@nimpress";
1311
+ const zs = "nimling/nimpress", Js = "nimpress@nimpress";
1312
1312
  function Ve(e, t) {
1313
1313
  console.log(`claude ${t.join(" ")}`);
1314
- const s = X("claude", t, { cwd: e, stdio: "inherit" });
1314
+ const s = ee("claude", t, { cwd: e, stdio: "inherit" });
1315
1315
  if (s.error) throw new Error(`[nimpress] plugin: could not run claude, install Claude Code first: ${s.error.message}`);
1316
1316
  if (s.status !== 0) throw new Error(`[nimpress] plugin: claude ${t.join(" ")} exited with ${s.status}`);
1317
1317
  }
1318
- function Js(e, t) {
1318
+ function Bs(e, t) {
1319
1319
  const s = t ? "user" : "project";
1320
- Ve(e, ["plugin", "marketplace", "add", Ls, "--scope", s]), Ve(e, ["plugin", "install", zs, "--scope", s]);
1320
+ Ve(e, ["plugin", "marketplace", "add", zs, "--scope", s]), Ve(e, ["plugin", "install", Js, "--scope", s]);
1321
1321
  }
1322
- function Bs(e, t) {
1322
+ function Gs(e, t) {
1323
1323
  if (t[0] === "put") {
1324
- Js(e, !M(t, "project"));
1324
+ Bs(e, !I(t, "project"));
1325
1325
  return;
1326
1326
  }
1327
1327
  throw new Error("[nimpress] plugin expects put");
1328
1328
  }
1329
- const ee = {
1329
+ const se = {
1330
1330
  name: "--system",
1331
1331
  value: !0,
1332
1332
  describe: "the configured component system to act on"
@@ -1371,15 +1371,15 @@ const ee = {
1371
1371
  flags: [],
1372
1372
  subs: [
1373
1373
  { name: "init", describe: "Create the modules folder and the config block", flags: [], subs: [] },
1374
- { name: "dev", describe: "Serve the harnesses and stay running", flags: [ee], subs: [] },
1375
- { name: "build", describe: "Build the harness bundles", flags: [ee], subs: [] },
1376
- { name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [ee], subs: [] },
1377
- { name: "story", describe: "Write auto stories for one component or for every component", flags: [ee, Ke], subs: [] },
1374
+ { name: "dev", describe: "Serve the harnesses and stay running", flags: [se], subs: [] },
1375
+ { name: "build", describe: "Build the harness bundles", flags: [se], subs: [] },
1376
+ { name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [se], subs: [] },
1377
+ { name: "story", describe: "Write auto stories for one component or for every component", flags: [se, Ke], subs: [] },
1378
1378
  {
1379
1379
  name: "import",
1380
1380
  describe: "Import components and storybook stories into component pages",
1381
1381
  flags: [
1382
- ee,
1382
+ se,
1383
1383
  { name: "--name", value: !0, describe: "the component name when a single file is imported" },
1384
1384
  { name: "--source", value: !0, describe: "the component source root, overriding the system source" },
1385
1385
  { name: "--stories", value: !0, describe: "an extra folder of storybook csf files" },
@@ -1393,7 +1393,7 @@ const ee = {
1393
1393
  name: "create",
1394
1394
  describe: "Create a component page, or upsert one schema",
1395
1395
  flags: [
1396
- ee,
1396
+ se,
1397
1397
  Ke,
1398
1398
  { name: "--component", value: !0, describe: "the component reference whose schema is upserted" },
1399
1399
  { name: "--schema", value: !1, describe: "required with --component, upserts the schema" }
@@ -1403,7 +1403,7 @@ const ee = {
1403
1403
  {
1404
1404
  name: "update",
1405
1405
  describe: "Upsert the component schemas from the component types",
1406
- flags: [ee, { name: "--component", value: !0, describe: "limit the upsert to one component reference" }],
1406
+ flags: [se, { name: "--component", value: !0, describe: "limit the upsert to one component reference" }],
1407
1407
  subs: []
1408
1408
  }
1409
1409
  ]
@@ -1528,7 +1528,7 @@ function ke(e) {
1528
1528
  function xe(e, t) {
1529
1529
  return t && e.value ? `${e.name}=` : e.name;
1530
1530
  }
1531
- function Gs() {
1531
+ function Hs() {
1532
1532
  const e = ["_nimpress() {", ' local cur="${COMP_WORDS[COMP_CWORD]}"'];
1533
1533
  e.push(` local words="${V.map((t) => t.name).join(" ")}"`), e.push(' if [ "$COMP_CWORD" -gt 1 ]; then'), e.push(' case "${COMP_WORDS[1]}" in');
1534
1534
  for (const t of V) {
@@ -1544,7 +1544,7 @@ function Ee(e, t, s) {
1544
1544
  for (const o of s) n.push(`${e} ${o}`);
1545
1545
  return n.push(`${e})`), n.push(`${e}_describe '${t}' entries`), n.push(`${e}return`), n;
1546
1546
  }
1547
- function Hs() {
1547
+ function Us() {
1548
1548
  const e = ["#compdef nimpress", "", "_nimpress() {", " local -a entries", " if (( CURRENT == 2 )); then"];
1549
1549
  e.push(
1550
1550
  ...Ee(
@@ -1574,7 +1574,7 @@ function Hs() {
1574
1574
  `) + `
1575
1575
  `;
1576
1576
  }
1577
- function Us() {
1577
+ function Zs() {
1578
1578
  const e = ["complete -c nimpress -f"];
1579
1579
  for (const t of V)
1580
1580
  e.push(
@@ -1593,7 +1593,7 @@ function Us() {
1593
1593
  `) + `
1594
1594
  `;
1595
1595
  }
1596
- function Zs() {
1596
+ function Vs() {
1597
1597
  const e = [
1598
1598
  "Register-ArgumentCompleter -Native -CommandName nimpress -ScriptBlock {",
1599
1599
  " param($wordToComplete, $commandAst, $cursorPosition)",
@@ -1613,10 +1613,10 @@ function Zs() {
1613
1613
  `;
1614
1614
  }
1615
1615
  function Ft(e) {
1616
- if (e === "bash") return Gs();
1617
- if (e === "zsh") return Hs();
1618
- if (e === "fish") return Us();
1619
- if (e === "powershell") return Zs();
1616
+ if (e === "bash") return Hs();
1617
+ if (e === "zsh") return Us();
1618
+ if (e === "fish") return Zs();
1619
+ if (e === "powershell") return Vs();
1620
1620
  throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${Ot.join(", ")}`);
1621
1621
  }
1622
1622
  function Ye(e) {
@@ -1641,13 +1641,13 @@ function Ye(e) {
1641
1641
  ].join(`
1642
1642
  `);
1643
1643
  }
1644
- function Vs() {
1645
- const e = F(process.env.SHELL ?? "");
1644
+ function Ks() {
1645
+ const e = D(process.env.SHELL ?? "");
1646
1646
  for (const t of ["zsh", "bash", "fish"])
1647
1647
  if (e.includes(t)) return t;
1648
1648
  return "";
1649
1649
  }
1650
- function Ks(e, t) {
1650
+ function Ys(e, t) {
1651
1651
  const s = "# >>> nimpress completion >>>", n = "# <<< nimpress completion <<<", o = `${s}
1652
1652
  ${t}
1653
1653
  ${n}`, r = e.indexOf(s), i = e.indexOf(n);
@@ -1658,27 +1658,27 @@ ${n}`, r = e.indexOf(s), i = e.indexOf(n);
1658
1658
  `) + o + `
1659
1659
  `;
1660
1660
  }
1661
- function Ys(e, t) {
1661
+ function Qs(e, t) {
1662
1662
  let s = "";
1663
1663
  try {
1664
1664
  s = C(e, "utf-8");
1665
1665
  } catch {
1666
1666
  s = "";
1667
1667
  }
1668
- W(e, Ks(s, t));
1668
+ W(e, Ys(s, t));
1669
1669
  }
1670
- function Qs(e) {
1671
- const t = e || Vs();
1670
+ function Xs(e) {
1671
+ const t = e || Ks();
1672
1672
  if (!t)
1673
1673
  throw new Error("[nimpress] completion: could not detect the shell from $SHELL, name it: nimpress completion <shell> --auto");
1674
1674
  const s = Ft(t), n = K();
1675
1675
  if (t === "fish") {
1676
1676
  const a = d(n, ".config", "fish", "completions");
1677
- J(a, { recursive: !0 });
1677
+ B(a, { recursive: !0 });
1678
1678
  const p = d(a, "nimpress.fish");
1679
1679
  W(p, s), console.log(`wrote ${p}`);
1680
1680
  const l = d(n, ".config", "fish", "functions");
1681
- J(l, { recursive: !0 });
1681
+ B(l, { recursive: !0 });
1682
1682
  const m = d(l, "nimpress.fish");
1683
1683
  W(m, Ye(t)), console.log(`wrote ${m}`), console.log("fish loads them on the next shell");
1684
1684
  return;
@@ -1686,25 +1686,25 @@ function Qs(e) {
1686
1686
  if (t !== "bash" && t !== "zsh")
1687
1687
  throw new Error(`[nimpress] completion: auto install covers bash, zsh, and fish, for ${t} run: nimpress completion ${t}`);
1688
1688
  const o = d(n, ".config", "nimpress", "completions");
1689
- J(o, { recursive: !0 });
1689
+ B(o, { recursive: !0 });
1690
1690
  const r = d(o, t === "zsh" ? "_nimpress" : "nimpress.bash");
1691
1691
  W(r, s), console.log(`wrote ${r}`);
1692
1692
  const i = d(n, t === "zsh" ? ".zshrc" : ".bashrc"), c = t === "zsh" ? `fpath=("${o}" $fpath)
1693
1693
  autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, u = `${Ye(t)}
1694
1694
  ${c}`;
1695
- Ys(i, u), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
1695
+ Qs(i, u), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
1696
1696
  }
1697
- function Xs(e, t) {
1698
- const s = re(t, 0) ?? "", n = M(t, "auto"), o = M(t, "skill");
1697
+ function qs(e, t) {
1698
+ const s = ie(t, 0) ?? "", n = I(t, "auto"), o = I(t, "skill");
1699
1699
  if (!n) {
1700
1700
  if (o) throw new Error("[nimpress] completion: --skill installs alongside --auto");
1701
1701
  if (!s) throw new Error(`[nimpress] completion: name a shell (${Ot.join(", ")}) or pass --auto`);
1702
1702
  process.stdout.write(Ft(s));
1703
1703
  return;
1704
1704
  }
1705
- Qs(s), o && Et(e, !0);
1705
+ Xs(s), o && Et(e, !0);
1706
1706
  }
1707
- const qs = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), en = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), tn = 2e4, de = /* @__PURE__ */ new Map();
1707
+ const en = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), tn = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), sn = 2e4, de = /* @__PURE__ */ new Map();
1708
1708
  function Dt(e, t) {
1709
1709
  const s = [...t, e.name];
1710
1710
  return e.subs.length ? e.subs.flatMap((n) => Dt(n, s)) : [
@@ -1713,21 +1713,21 @@ function Dt(e, t) {
1713
1713
  argv: s,
1714
1714
  describe: e.describe,
1715
1715
  flags: e.flags,
1716
- serves: en.has(s.join(" "))
1716
+ serves: tn.has(s.join(" "))
1717
1717
  }
1718
1718
  ];
1719
1719
  }
1720
- const _t = V.filter((e) => !qs.has(e.name)).flatMap((e) => Dt(e, []));
1721
- function sn() {
1720
+ const _t = V.filter((e) => !en.has(e.name)).flatMap((e) => Dt(e, []));
1721
+ function nn() {
1722
1722
  const e = N(mt(import.meta.url));
1723
- for (const t of [j(e, "..", "package.json"), j(e, "..", "..", "package.json")])
1723
+ for (const t of [x(e, "..", "package.json"), x(e, "..", "..", "package.json")])
1724
1724
  try {
1725
1725
  return JSON.parse(C(t, "utf-8")).version;
1726
1726
  } catch {
1727
1727
  }
1728
1728
  return "0.0.0";
1729
1729
  }
1730
- function nn(e) {
1730
+ function on(e) {
1731
1731
  const t = {};
1732
1732
  for (const s of e.flags)
1733
1733
  t[s.name.slice(2)] = { type: s.value ? "string" : "boolean", description: s.describe };
@@ -1741,12 +1741,12 @@ function nn(e) {
1741
1741
  additionalProperties: !1
1742
1742
  };
1743
1743
  }
1744
- function on() {
1744
+ function rn() {
1745
1745
  return [
1746
1746
  ..._t.map((e) => ({
1747
1747
  name: e.name,
1748
1748
  description: `nimpress ${e.argv.join(" ")}: ${e.describe}${e.serves ? ". Keeps running in the background and returns its pid with the first output" : ""}`,
1749
- inputSchema: nn(e)
1749
+ inputSchema: on(e)
1750
1750
  })),
1751
1751
  {
1752
1752
  name: "stop",
@@ -1760,98 +1760,98 @@ function on() {
1760
1760
  }
1761
1761
  ];
1762
1762
  }
1763
- function rn(e, t) {
1763
+ function an(e, t) {
1764
1764
  const s = [...e.argv, ...t.args ?? []];
1765
1765
  for (const [n, o] of Object.entries(t.flags ?? {}))
1766
1766
  o === !0 ? s.push(`--${n}`) : typeof o == "string" && s.push(`--${n}=${o}`);
1767
1767
  return s;
1768
1768
  }
1769
- function H(e, t = !1) {
1769
+ function U(e, t = !1) {
1770
1770
  return { content: [{ type: "text", text: e || "(no output)" }], ...t ? { isError: t } : {} };
1771
1771
  }
1772
1772
  function Nt(e, t, s) {
1773
- return Ie(process.execPath, [process.argv[1], ...rn(t, s)], {
1774
- cwd: j(e, s.cwd ?? "."),
1773
+ return Ie(process.execPath, [process.argv[1], ...an(t, s)], {
1774
+ cwd: x(e, s.cwd ?? "."),
1775
1775
  env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" },
1776
1776
  stdio: ["ignore", "pipe", "pipe"]
1777
1777
  });
1778
1778
  }
1779
- function an(e, t, s) {
1779
+ function cn(e, t, s) {
1780
1780
  const n = Nt(e, t, s);
1781
1781
  let o = "";
1782
1782
  return n.stdout?.on("data", (r) => o += r), n.stderr?.on("data", (r) => o += r), new Promise((r) => {
1783
- n.on("error", (i) => r(H(`${o}${i.message}`, !0))), n.on("close", (i) => r(H(o, i !== 0)));
1783
+ n.on("error", (i) => r(U(`${o}${i.message}`, !0))), n.on("close", (i) => r(U(o, i !== 0)));
1784
1784
  });
1785
1785
  }
1786
- function cn(e, t, s) {
1786
+ function ln(e, t, s) {
1787
1787
  const n = Nt(e, t, s);
1788
1788
  let o = "";
1789
1789
  return new Promise((r) => {
1790
1790
  const i = (a) => {
1791
1791
  clearTimeout(u), n.stdout?.removeAllListeners("data"), n.stderr?.removeAllListeners("data"), n.stdout?.resume(), n.stderr?.resume(), r(a);
1792
1792
  }, c = (a) => {
1793
- o += a, /https?:\/\/\S+/.test(o) && i(H(`pid ${n.pid}
1793
+ o += a, /https?:\/\/\S+/.test(o) && i(U(`pid ${n.pid}
1794
1794
  ${o}`));
1795
- }, u = setTimeout(() => i(H(`pid ${n.pid}
1796
- ${o}`)), tn);
1797
- n.stdout?.on("data", c), n.stderr?.on("data", c), n.on("error", (a) => i(H(`${o}${a.message}`, !0))), n.on("exit", (a) => {
1798
- de.delete(n.pid ?? -1), i(H(o, a !== 0));
1795
+ }, u = setTimeout(() => i(U(`pid ${n.pid}
1796
+ ${o}`)), sn);
1797
+ n.stdout?.on("data", c), n.stderr?.on("data", c), n.on("error", (a) => i(U(`${o}${a.message}`, !0))), n.on("exit", (a) => {
1798
+ de.delete(n.pid ?? -1), i(U(o, a !== 0));
1799
1799
  }), n.pid && de.set(n.pid, n);
1800
1800
  });
1801
1801
  }
1802
- function ln(e) {
1802
+ function un(e) {
1803
1803
  const t = de.get(e);
1804
- return t ? (t.kill("SIGTERM"), de.delete(e), H(`stopped ${e}`)) : H(`no server with pid ${e} was started by this session`, !0);
1804
+ return t ? (t.kill("SIGTERM"), de.delete(e), U(`stopped ${e}`)) : U(`no server with pid ${e} was started by this session`, !0);
1805
1805
  }
1806
- async function un(e, t) {
1806
+ async function pn(e, t) {
1807
1807
  const s = String(t.name ?? ""), n = t.arguments ?? {};
1808
- if (s === "stop") return ln(Number(n.pid));
1808
+ if (s === "stop") return un(Number(n.pid));
1809
1809
  const o = _t.find((r) => r.name === s);
1810
- return o ? $(j(e, n.cwd ?? ".")) ? o.serves ? cn(e, o, n) : an(e, o, n) : H(`no folder ${n.cwd} under ${e}`, !0) : H(`unknown tool ${s}`, !0);
1810
+ return o ? b(x(e, n.cwd ?? ".")) ? o.serves ? ln(e, o, n) : cn(e, o, n) : U(`no folder ${n.cwd} under ${e}`, !0) : U(`unknown tool ${s}`, !0);
1811
1811
  }
1812
- function te(e, t) {
1812
+ function ne(e, t) {
1813
1813
  process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: e, ...t }) + `
1814
1814
  `);
1815
1815
  }
1816
- async function pn(e, t) {
1816
+ async function mn(e, t) {
1817
1817
  if (t.id !== void 0) {
1818
1818
  if (t.method === "initialize") {
1819
- te(t.id, {
1819
+ ne(t.id, {
1820
1820
  result: {
1821
1821
  protocolVersion: t.params?.protocolVersion ?? "2025-06-18",
1822
1822
  capabilities: { tools: {} },
1823
- serverInfo: { name: "nimpress", version: sn() }
1823
+ serverInfo: { name: "nimpress", version: nn() }
1824
1824
  }
1825
1825
  });
1826
1826
  return;
1827
1827
  }
1828
1828
  if (t.method === "ping") {
1829
- te(t.id, { result: {} });
1829
+ ne(t.id, { result: {} });
1830
1830
  return;
1831
1831
  }
1832
1832
  if (t.method === "tools/list") {
1833
- te(t.id, { result: { tools: on() } });
1833
+ ne(t.id, { result: { tools: rn() } });
1834
1834
  return;
1835
1835
  }
1836
1836
  if (t.method === "tools/call") {
1837
- te(t.id, { result: await un(e, t.params ?? {}) });
1837
+ ne(t.id, { result: await pn(e, t.params ?? {}) });
1838
1838
  return;
1839
1839
  }
1840
- te(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
1840
+ ne(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
1841
1841
  }
1842
1842
  }
1843
- function mn(e) {
1844
- const t = as({ input: process.stdin }), s = /* @__PURE__ */ new Set();
1843
+ function fn(e) {
1844
+ const t = cs({ input: process.stdin }), s = /* @__PURE__ */ new Set();
1845
1845
  t.on("line", (n) => {
1846
1846
  if (!n.trim()) return;
1847
1847
  let o;
1848
1848
  try {
1849
1849
  o = JSON.parse(n);
1850
1850
  } catch {
1851
- te(null, { error: { code: -32700, message: "parse error" } });
1851
+ ne(null, { error: { code: -32700, message: "parse error" } });
1852
1852
  return;
1853
1853
  }
1854
- const r = pn(e, o).catch((i) => te(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => s.delete(r));
1854
+ const r = mn(e, o).catch((i) => ne(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => s.delete(r));
1855
1855
  s.add(r);
1856
1856
  }), t.on("close", async () => {
1857
1857
  await Promise.all(s);
@@ -1859,62 +1859,62 @@ function mn(e) {
1859
1859
  process.exit(0);
1860
1860
  });
1861
1861
  }
1862
- function fn(e, t, s) {
1862
+ function dn(e, t, s) {
1863
1863
  if (typeof s.path == "string") return s.path.startsWith("/") ? s.path : `/${s.path}`;
1864
- const n = D(e, t).split(I).join("/").replace(/\.md$/, "");
1864
+ const n = F(e, t).split(L).join("/").replace(/\.md$/, "");
1865
1865
  return n === "index" ? "/" : `/${n.replace(/\/index$/, "")}`;
1866
1866
  }
1867
1867
  function Qe(e) {
1868
1868
  return e ? (Array.isArray(e) ? e : String(e).split(",")).map((s) => String(s).trim()).filter(Boolean) : [];
1869
1869
  }
1870
- function dn(e) {
1870
+ function hn(e) {
1871
1871
  return e.split(`
1872
1872
  `).filter((t) => /^#{1,6}\s/.test(t)).map((t) => t.replace(/^#{1,6}\s+/, "").trim());
1873
1873
  }
1874
- function hn(e, t) {
1875
- const s = j(e, t.contentDir), o = oe(s).filter((a) => a.endsWith(".md")).map((a) => {
1876
- const { data: p, content: l } = fe(C(a, "utf-8"));
1874
+ function gn(e, t) {
1875
+ const s = x(e, t.contentDir), o = Y(s).filter((a) => a.endsWith(".md")).map((a) => {
1876
+ const { data: p, content: l } = le(C(a, "utf-8"));
1877
1877
  return { file: a, data: p, content: l };
1878
1878
  }).filter((a) => typeof a.data.title == "string" && a.data.visibility !== "hidden" && !a.data.link), r = o.map((a) => ({
1879
1879
  slug: a.file,
1880
1880
  title: String(a.data.title),
1881
- headings: dn(a.content),
1881
+ headings: hn(a.content),
1882
1882
  tags: Qe(a.data.tags),
1883
1883
  body: a.content
1884
1884
  })), i = ss(r), c = t.site?.url?.replace(/\/$/, "") ?? "", u = t.base.replace(/\/$/, "");
1885
1885
  return o.map((a) => {
1886
- const p = i.get(a.file) ?? { keywords: [], description: "" }, l = a.data.meta ?? {}, m = Array.isArray(l.keywords) ? l.keywords : typeof l.keywords == "string" ? [l.keywords] : void 0, f = typeof l.description == "string" ? l.description : typeof a.data.description == "string" ? a.data.description : void 0, h = l.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : p.keywords.length ? p.keywords : m ?? [] : m ?? Qe(a.data.tags), v = g ? h && f ? f : p.description || f || "" : f ?? "", O = fn(s, a.file, a.data);
1886
+ const p = i.get(a.file) ?? { keywords: [], description: "" }, l = a.data.meta ?? {}, m = Array.isArray(l.keywords) ? l.keywords : typeof l.keywords == "string" ? [l.keywords] : void 0, f = typeof l.description == "string" ? l.description : typeof a.data.description == "string" ? a.data.description : void 0, h = l.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : p.keywords.length ? p.keywords : m ?? [] : m ?? Qe(a.data.tags), k = g ? h && f ? f : p.description || f || "" : f ?? "", j = dn(s, a.file, a.data);
1887
1887
  return {
1888
- path: O,
1889
- file: D(e, a.file).split(I).join("/"),
1888
+ path: j,
1889
+ file: F(e, a.file).split(L).join("/"),
1890
1890
  title: String(a.data.title),
1891
1891
  keywords: w,
1892
- description: v,
1892
+ description: k,
1893
1893
  robots: ns(typeof l.robots == "string" ? l.robots : "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1", t.seo?.ai?.index, typeof l.ai == "boolean" ? l.ai : void 0),
1894
- canonical: typeof l.canonical == "string" ? l.canonical : c ? `${c}${u}${O === "/" ? "/" : O}` : "",
1894
+ canonical: typeof l.canonical == "string" ? l.canonical : c ? `${c}${u}${j === "/" ? "/" : j}` : "",
1895
1895
  generated: p,
1896
1896
  authored: { keywords: m, description: f, override: h, ai: typeof l.ai == "boolean" ? l.ai : void 0 }
1897
1897
  };
1898
1898
  });
1899
1899
  }
1900
- function gn(e, t) {
1900
+ function wn(e, t) {
1901
1901
  let s = 0;
1902
1902
  for (const n of t) {
1903
- const o = j(e, n.file), { data: r, content: i } = fe(C(o, "utf-8")), c = { ...r.meta ?? {} };
1903
+ const o = x(e, n.file), { data: r, content: i } = le(C(o, "utf-8")), c = { ...r.meta ?? {} };
1904
1904
  let u = !1;
1905
- c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords, u = !0), c.description === void 0 && n.generated.description && (c.description = n.generated.description, u = !0), u && (W(o, fe.stringify(i, { ...r, meta: c })), s += 1);
1905
+ c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords, u = !0), c.description === void 0 && n.generated.description && (c.description = n.generated.description, u = !0), u && (W(o, le.stringify(i, { ...r, meta: c })), s += 1);
1906
1906
  }
1907
1907
  return s;
1908
1908
  }
1909
- function wn(e, t, s) {
1910
- const n = hn(e, t), o = _(s, "out") ?? "seo.map.json";
1909
+ function $n(e, t, s) {
1910
+ const n = gn(e, t), o = _(s, "out") ?? "seo.map.json";
1911
1911
  for (const r of n) {
1912
1912
  const i = t.seo?.auto ? r.authored.override ? "authored" : "generated" : "authored";
1913
1913
  console.log(`${r.path.padEnd(40)} ${String(r.keywords.length).padStart(2)} keywords ${String(r.description.length).padStart(3)} chars ${r.robots.includes("noai") ? "noai" : "ai ok"} ${i}`);
1914
1914
  }
1915
- if (W(j(e, o), JSON.stringify(n, null, 2) + `
1915
+ if (W(x(e, o), JSON.stringify(n, null, 2) + `
1916
1916
  `), console.log(`nimpress seo: ${n.length} pages, map written to ${o}`), s.includes("--write")) {
1917
- const r = gn(e, n);
1917
+ const r = wn(e, n);
1918
1918
  console.log(`nimpress seo: generated fields written into ${r} pages`);
1919
1919
  }
1920
1920
  }
@@ -1924,13 +1924,13 @@ function Wt(e = K()) {
1924
1924
  function Tt(e = K()) {
1925
1925
  return d(e, ".tide", "nimpress", "sites");
1926
1926
  }
1927
- function Rt(e = K()) {
1927
+ function Pt(e = K()) {
1928
1928
  const t = Wt(e);
1929
- return $(t) ? { links: JSON.parse(C(t, "utf-8")).links ?? {} } : { links: {} };
1929
+ return b(t) ? { links: JSON.parse(C(t, "utf-8")).links ?? {} } : { links: {} };
1930
1930
  }
1931
- function At(e, t = K()) {
1931
+ function Rt(e, t = K()) {
1932
1932
  const s = Wt(t);
1933
- J(N(s), { recursive: !0 }), W(s, `${JSON.stringify(e, null, 2)}
1933
+ B(N(s), { recursive: !0 }), W(s, `${JSON.stringify(e, null, 2)}
1934
1934
  `);
1935
1935
  }
1936
1936
  function ve(e) {
@@ -1944,19 +1944,19 @@ function Oe(e) {
1944
1944
  const t = e.trim();
1945
1945
  return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${ve(t)}.git`;
1946
1946
  }
1947
- function Pt(e) {
1947
+ function At(e) {
1948
1948
  const t = d(e, ".github", "workflows");
1949
- return $(t) ? se(t).filter((s) => s.endsWith(".yml") || s.endsWith(".yaml")).sort().map((s) => d(t, s)) : [];
1949
+ return b(t) ? re(t).filter((s) => s.endsWith(".yml") || s.endsWith(".yaml")).sort().map((s) => d(t, s)) : [];
1950
1950
  }
1951
1951
  function Mt(e) {
1952
1952
  try {
1953
- const t = cs(C(e, "utf-8"));
1953
+ const t = ls(C(e, "utf-8"));
1954
1954
  return typeof t == "object" && t !== null ? t : null;
1955
1955
  } catch {
1956
1956
  return null;
1957
1957
  }
1958
1958
  }
1959
- function ae(e, t) {
1959
+ function ce(e, t) {
1960
1960
  return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (n, o) => {
1961
1961
  for (const r of t)
1962
1962
  if (r && r[o] !== void 0) return String(r[o]);
@@ -1970,15 +1970,15 @@ function It(e, t) {
1970
1970
  typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) && s.push({ step: o, scopes: [o.env, n.env, e.env] });
1971
1971
  return s;
1972
1972
  }
1973
- function $n(e) {
1973
+ function yn(e) {
1974
1974
  const t = /* @__PURE__ */ new Map();
1975
- for (const s of Pt(e)) {
1975
+ for (const s of At(e)) {
1976
1976
  const n = Mt(s);
1977
1977
  if (n)
1978
1978
  for (const { step: o, scopes: r } of It(n, "docs-notify")) {
1979
- const i = ae(o.with?.["docs-repo"], r);
1979
+ const i = ce(o.with?.["docs-repo"], r);
1980
1980
  if (!i) continue;
1981
- const c = ae(o.with?.["export-dir"], r) || ".nimpress";
1981
+ const c = ce(o.with?.["export-dir"], r) || ".nimpress";
1982
1982
  t.set(i, { repo: i, exportDir: c });
1983
1983
  }
1984
1984
  }
@@ -1987,87 +1987,99 @@ function $n(e) {
1987
1987
  function Xe(e) {
1988
1988
  return e.replace(/\$\{\{\s*github\.workspace\s*\}\}\/?/g, "").replace(/^\.\//, "");
1989
1989
  }
1990
- function yn(e, t) {
1990
+ function bn(e, t) {
1991
1991
  const s = {
1992
1992
  contentRoot: t,
1993
- mapping: $(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
1993
+ mapping: b(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
1994
1994
  defaults: {}
1995
1995
  };
1996
- for (const n of Pt(e)) {
1996
+ for (const n of At(e)) {
1997
1997
  const o = Mt(n);
1998
1998
  if (o)
1999
1999
  for (const { step: r, scopes: i } of It(o, "docs-sync")) {
2000
- const c = Xe(ae(r.with?.["docs-dir"], i)), u = (m) => {
2000
+ const c = Xe(ce(r.with?.["docs-dir"], i)), u = (m) => {
2001
2001
  const f = Xe(m);
2002
2002
  return (c && f.startsWith(`${c}/`) ? f.slice(c.length + 1) : f).replace(/\/+$/, "");
2003
- }, a = ae(r.with?.["content-root"], i);
2003
+ }, a = ce(r.with?.["content-root"], i);
2004
2004
  a && (s.contentRoot = u(a));
2005
- const p = ae(r.with?.mapping, i);
2005
+ const p = ce(r.with?.mapping, i);
2006
2006
  p && (s.mapping = u(p));
2007
- const l = ae(r.with?.defaults, i);
2007
+ const l = ce(r.with?.defaults, i);
2008
2008
  return l && (s.defaults = JSON.parse(l)), s;
2009
2009
  }
2010
2010
  }
2011
2011
  return s;
2012
2012
  }
2013
- function bn(e, t) {
2013
+ function vn(e, t) {
2014
2014
  const s = { ...e };
2015
2015
  return t.target && (s.target = t.target), t.targets?.length && (s.targets = t.targets), t.mode && (s.mode = t.mode), s;
2016
2016
  }
2017
- function vn(e) {
2017
+ function kn(e) {
2018
2018
  const t = e.mode || "mirror";
2019
2019
  return e.targets?.length ? e.targets.map((s) => ({ from: s.from ?? "", to: s.to, mode: s.mode || t })) : e.target ? [{ from: "", to: e.target, mode: t }] : [];
2020
2020
  }
2021
- function kn(e, t, s) {
2021
+ function xn(e, t, s) {
2022
2022
  let n = t.defaults;
2023
2023
  const o = t.mapping ? d(e, t.mapping) : "";
2024
- if (o && $(o)) {
2024
+ if (o && b(o)) {
2025
2025
  const i = JSON.parse(C(o, "utf-8")).sources?.[s];
2026
- i && (n = bn(n, i));
2026
+ i && (n = vn(n, i));
2027
2027
  }
2028
2028
  return n;
2029
2029
  }
2030
2030
  function qe(e) {
2031
2031
  const t = /* @__PURE__ */ new Map();
2032
- if (!$(e)) return t;
2033
- for (const s of oe(e))
2034
- t.set(D(e, s).split(I).join("/"), C(s));
2032
+ if (!b(e)) return t;
2033
+ for (const s of Y(e))
2034
+ t.set(F(e, s).split(L).join("/"), C(s));
2035
2035
  return t;
2036
2036
  }
2037
- function xn(e, t, s) {
2037
+ function Sn(e, t, s) {
2038
2038
  const n = { added: [], modified: [], deleted: [] }, o = qe(e), r = qe(t);
2039
2039
  for (const [i, c] of o) {
2040
2040
  const u = r.get(i);
2041
2041
  if (u && u.equals(c)) continue;
2042
2042
  const a = d(t, ...i.split("/"));
2043
- J(N(a), { recursive: !0 }), W(a, c), u ? n.modified.push(i) : n.added.push(i);
2043
+ B(N(a), { recursive: !0 }), W(a, c), u ? n.modified.push(i) : n.added.push(i);
2044
2044
  }
2045
2045
  if (s === "mirror")
2046
2046
  for (const i of r.keys())
2047
- o.has(i) || (ne(d(t, ...i.split("/")), { force: !0 }), n.deleted.push(i));
2047
+ o.has(i) || (q(d(t, ...i.split("/")), { force: !0 }), n.deleted.push(i));
2048
2048
  return n;
2049
2049
  }
2050
- function ce(e, t, s) {
2051
- const n = X("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...s } });
2050
+ function jn(e, t) {
2051
+ const s = /* @__PURE__ */ new Map();
2052
+ for (const o of Y(e)) {
2053
+ if (!o.endsWith(".md")) continue;
2054
+ const r = le(C(o, "utf-8")).data.path, i = os(e, o, typeof r == "string" ? r : void 0);
2055
+ s.set(i, [...s.get(i) ?? [], o]);
2056
+ }
2057
+ const n = [];
2058
+ for (const o of s.values())
2059
+ o.some((r) => t.has(r)) && n.push(...o.filter((r) => !t.has(r)));
2060
+ return n.sort();
2061
+ }
2062
+ function oe(e, t, s) {
2063
+ const n = ee("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...s } });
2052
2064
  return { ok: n.status === 0, out: `${n.stdout ?? ""}${n.stderr ?? ""}`.trim() };
2053
2065
  }
2054
2066
  function Lt(e) {
2055
- const t = ce(["rev-parse", "--show-toplevel"], e);
2067
+ const t = oe(["rev-parse", "--show-toplevel"], e);
2056
2068
  return t.ok ? t.out : e;
2057
2069
  }
2058
- function Sn(e) {
2059
- const t = ce(["remote", "get-url", "origin"], e);
2070
+ function Cn(e) {
2071
+ const t = oe(["remote", "get-url", "origin"], e);
2060
2072
  if (!t.ok) throw new Error(`[nimpress] view: ${e} has no origin remote, so its docs site mapping cannot be looked up`);
2061
2073
  return ve(t.out);
2062
2074
  }
2063
- function jn() {
2064
- return X("gh", ["--version"], { encoding: "utf-8" }).status === 0;
2075
+ function En() {
2076
+ return ee("gh", ["--version"], { encoding: "utf-8" }).status === 0;
2065
2077
  }
2066
2078
  function zt(e) {
2067
2079
  return e?.method === "ssh" && e.key ? { GIT_SSH_COMMAND: `ssh -i ${e.key} -o IdentitiesOnly=yes` } : {};
2068
2080
  }
2069
2081
  function Fe(e) {
2070
- return e.login?.method === "gh" ? X("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : ce(["ls-remote", "--exit-code", "-h", e.url], void 0, zt(e.login)).ok;
2082
+ return e.login?.method === "gh" ? ee("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : oe(["ls-remote", "--exit-code", "-h", e.url], void 0, zt(e.login)).ok;
2071
2083
  }
2072
2084
  async function Jt(e) {
2073
2085
  const t = pt({ input: process.stdin, output: process.stdout });
@@ -2077,22 +2089,22 @@ async function Jt(e) {
2077
2089
  t.close();
2078
2090
  }
2079
2091
  }
2080
- async function Cn(e) {
2092
+ async function On(e) {
2081
2093
  if (Fe(e)) return e;
2082
- if (console.log(`nimpress view: ${e.url} refused the connection`), jn()) {
2083
- if (console.log("nimpress view: logging in through gh"), X("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
2094
+ if (console.log(`nimpress view: ${e.url} refused the connection`), En()) {
2095
+ if (console.log("nimpress view: logging in through gh"), ee("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
2084
2096
  const o = { ...e, login: { method: "gh" } };
2085
2097
  if (Fe(o)) return o;
2086
2098
  throw new Error(`[nimpress] view: ${e.repo} is still unreachable after the gh login, ask for access to it`);
2087
2099
  }
2088
2100
  const t = await Jt("nimpress view: path to the ssh key with access to the repo: ");
2089
2101
  if (!t) throw new Error("[nimpress] view: no ssh key given and gh is not installed");
2090
- const s = { ...e, login: { method: "ssh", key: j(t.replace(/^~/, K())) } };
2102
+ const s = { ...e, login: { method: "ssh", key: x(t.replace(/^~/, K())) } };
2091
2103
  if (Fe(s)) return s;
2092
2104
  throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${s.login.key}, ask for access to it`);
2093
2105
  }
2094
- async function En(e, t, s = K()) {
2095
- const n = Lt(e), o = Rt(s), r = o.links[n] ?? [], i = $n(n), c = _(t, "docs-repo");
2106
+ async function Fn(e, t, s = K()) {
2107
+ const n = Lt(e), o = Pt(s), r = o.links[n] ?? [], i = yn(n), c = _(t, "docs-repo");
2096
2108
  let u;
2097
2109
  if (c) {
2098
2110
  const p = ve(c), l = i.find((m) => m.repo === p)?.exportDir ?? _(t, "export-dir") ?? ".nimpress";
@@ -2113,40 +2125,40 @@ async function En(e, t, s = K()) {
2113
2125
  u = [{ repo: ve(p), url: Oe(p), exportDir: _(t, "export-dir") ?? ".nimpress" }];
2114
2126
  }
2115
2127
  const a = [];
2116
- for (const p of u) a.push(await Cn(p));
2117
- return o.links[n] = a, At(o, s), a;
2128
+ for (const p of u) a.push(await On(p));
2129
+ return o.links[n] = a, Rt(o, s), a;
2118
2130
  }
2119
- function On(e, t = K()) {
2131
+ function Dn(e, t = K()) {
2120
2132
  return d(Tt(t), e.repo.replace("/", "__"));
2121
2133
  }
2122
- function Fn(e, t, s) {
2134
+ function _n(e, t, s) {
2123
2135
  const n = zt(e.login);
2124
- if (!$(d(t, ".git"))) {
2125
- J(N(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
2126
- const r = e.login?.method === "gh" ? X("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : X("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...n } });
2136
+ if (!b(d(t, ".git"))) {
2137
+ B(N(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
2138
+ const r = e.login?.method === "gh" ? ee("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : ee("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...n } });
2127
2139
  if (r.status !== 0) throw new Error(`[nimpress] view: clone of ${e.repo} failed
2128
2140
  ${r.stderr ?? ""}`);
2129
2141
  return;
2130
2142
  }
2131
2143
  if (s) return;
2132
- const o = ce(["fetch", "--depth", "1", "origin", "HEAD"], t, n);
2144
+ const o = oe(["fetch", "--depth", "1", "origin", "HEAD"], t, n);
2133
2145
  if (!o.ok) throw new Error(`[nimpress] view: fetch of ${e.repo} failed
2134
2146
  ${o.out}`);
2135
- ce(["reset", "--hard", "FETCH_HEAD"], t), ce(["clean", "-fd"], t);
2147
+ oe(["reset", "--hard", "FETCH_HEAD"], t), oe(["clean", "-fd"], t);
2136
2148
  }
2137
- function Dn(e) {
2138
- const t = ["pnpm-lock.yaml", "package.json"].map((s) => d(e, s)).find((s) => $(s));
2149
+ function Nn(e) {
2150
+ const t = ["pnpm-lock.yaml", "package.json"].map((s) => d(e, s)).find((s) => b(s));
2139
2151
  return t ? ut("sha256").update(C(t)).digest("hex") : "";
2140
2152
  }
2141
- function _n(e) {
2142
- const t = d(e, z.paths.cache, "view", "lockfile.sha256"), s = Dn(e);
2143
- if ($(d(e, "node_modules")) && $(t) && C(t, "utf-8").trim() === s) return;
2144
- if (console.log("nimpress view: installing the docs site dependencies"), X("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
2145
- J(N(t), { recursive: !0 }), W(t, `${s}
2153
+ function Wn(e) {
2154
+ const t = d(e, J.paths.cache, "view", "lockfile.sha256"), s = Nn(e);
2155
+ if (b(d(e, "node_modules")) && b(t) && C(t, "utf-8").trim() === s) return;
2156
+ if (console.log("nimpress view: installing the docs site dependencies"), ee("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
2157
+ B(N(t), { recursive: !0 }), W(t, `${s}
2146
2158
  `);
2147
2159
  }
2148
- function Nn(e) {
2149
- const t = is(), s = t === "darwin" ? ["open", e] : t === "win32" ? ["cmd", "/c", "start", "", e] : ["xdg-open", e], n = Ie(s[0], s.slice(1), { stdio: "ignore", detached: !0 });
2160
+ function Tn(e) {
2161
+ const t = as(), s = t === "darwin" ? ["open", e] : t === "win32" ? ["cmd", "/c", "start", "", e] : ["xdg-open", e], n = Ie(s[0], s.slice(1), { stdio: "ignore", detached: !0 });
2150
2162
  n.on("error", () => console.log(`nimpress view: open ${e} in a browser`)), n.unref();
2151
2163
  }
2152
2164
  function et(e, t) {
@@ -2155,10 +2167,10 @@ function et(e, t) {
2155
2167
  s && clearTimeout(s), s = setTimeout(e, t);
2156
2168
  };
2157
2169
  }
2158
- function Wn(e, t) {
2170
+ function Pn(e, t) {
2159
2171
  t.added.length + t.modified.length + t.deleted.length !== 0 && console.log(`nimpress view: ${e} ${t.added.length} added, ${t.modified.length} modified, ${t.deleted.length} deleted`);
2160
2172
  }
2161
- function Tn(e) {
2173
+ function Rn(e) {
2162
2174
  const t = Ie("pnpm", ["exec", "nimpress", "dev"], { cwd: e, stdio: ["ignore", "pipe", "inherit"] }), s = new Promise((n, o) => {
2163
2175
  let r = !1;
2164
2176
  t.stdout?.on("data", (i) => {
@@ -2172,39 +2184,49 @@ function Tn(e) {
2172
2184
  });
2173
2185
  return { child: t, origin: s };
2174
2186
  }
2175
- async function Rn(e, t) {
2176
- const s = M(t, "offline"), n = await En(e, t), o = Sn(e), r = Lt(e), i = await we(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], u = [];
2187
+ async function An(e, t) {
2188
+ const s = I(t, "offline"), n = await Fn(e, t), o = Cn(e), r = Lt(e), i = await we(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], u = [];
2177
2189
  for (const p of n) {
2178
- const l = j(r, p.exportDir);
2179
- if (i.configFile && Ae(e, i.resolved, [...c, `--out=${l}`]), !$(l))
2190
+ const l = x(r, p.exportDir);
2191
+ if (i.configFile && Re(e, i.resolved, [...c, `--out=${l}`]), !b(l))
2180
2192
  throw new Error(`[nimpress] view: no export folder at ${l}, write the pages there or mark pages with export: and add a config`);
2181
- const m = On(p);
2182
- Fn(p, m, s), _n(m);
2193
+ const m = Dn(p);
2194
+ _n(p, m, s), Wn(m);
2183
2195
  const f = await we(m);
2184
2196
  if (!f.configFile) throw new Error(`[nimpress] view: ${p.repo} carries no nimpress config, so it is not a docs site`);
2185
- const h = yn(m, f.resolved.contentDir), g = vn(kn(m, h, o));
2197
+ const h = bn(m, f.resolved.contentDir), g = kn(xn(m, h, o));
2186
2198
  if (!g.length)
2187
2199
  throw new Error(
2188
2200
  `[nimpress] view: ${p.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
2189
2201
  );
2190
- const w = j(m, h.contentRoot), v = () => {
2191
- for (const x of g)
2192
- Wn(x.to, xn(d(l, ...x.from.split("/").filter(Boolean)), d(w, ...x.to.split("/")), x.mode));
2202
+ const w = x(m, h.contentRoot), k = x(m, f.resolved.contentDir);
2203
+ let j = [];
2204
+ const E = () => {
2205
+ j.length && oe(["checkout", "--", ...j], m);
2206
+ const $ = /* @__PURE__ */ new Set();
2207
+ for (const y of g) {
2208
+ const M = d(l, ...y.from.split("/").filter(Boolean)), P = d(w, ...y.to.split("/"));
2209
+ Pn(y.to, Sn(M, P, y.mode));
2210
+ for (const A of Y(M)) $.add(d(P, F(M, A)));
2211
+ }
2212
+ j = jn(k, $);
2213
+ for (const y of j) q(y);
2214
+ j.length && console.log(`nimpress view: the local pages replace ${j.map((y) => F(m, y)).join(", ")}`);
2193
2215
  };
2194
- v();
2195
- const O = He(l, { recursive: !0 }, et(v, 150));
2196
- if (u.push(() => O.close()), i.configFile) {
2197
- const x = He(
2198
- j(e, i.resolved.contentDir),
2216
+ E();
2217
+ const v = He(l, { recursive: !0 }, et(E, 150));
2218
+ if (u.push(() => v.close()), i.configFile) {
2219
+ const $ = He(
2220
+ x(e, i.resolved.contentDir),
2199
2221
  { recursive: !0 },
2200
- et(() => Ae(e, i.resolved, [...c, `--out=${l}`]), 150)
2222
+ et(() => Re(e, i.resolved, [...c, `--out=${l}`]), 150)
2201
2223
  );
2202
- u.push(() => x.close());
2224
+ u.push(() => $.close());
2203
2225
  }
2204
- const { child: E, origin: k } = Tn(m);
2205
- u.push(() => E.kill());
2206
- const T = `${(await k).replace(/\/$/, "")}/${g[0].to}`;
2207
- console.log(`nimpress view: ${o} inside ${p.repo} at ${T}`), M(t, "no-browser") || Nn(T);
2226
+ const { child: R, origin: O } = Rn(m);
2227
+ u.push(() => R.kill());
2228
+ const T = `${(await O).replace(/\/$/, "")}/${g[0].to}`;
2229
+ console.log(`nimpress view: ${o} inside ${p.repo} at ${T}`), I(t, "no-browser") || Tn(T);
2208
2230
  }
2209
2231
  const a = () => {
2210
2232
  for (const p of u) p();
@@ -2212,66 +2234,66 @@ async function Rn(e, t) {
2212
2234
  };
2213
2235
  process.on("SIGINT", a), process.on("SIGTERM", a);
2214
2236
  }
2215
- async function An(e, t) {
2216
- const s = re(t, 0);
2237
+ async function Mn(e, t) {
2238
+ const s = ie(t, 0);
2217
2239
  if (s !== "clear") throw new Error(`[nimpress] cache: unknown subcommand ${s ?? ""}, use clear`);
2218
- const n = M(t, "links"), o = M(t, "sites"), r = M(t, "local"), i = !n && !o && !r;
2240
+ const n = I(t, "links"), o = I(t, "sites"), r = I(t, "local"), i = !n && !o && !r;
2219
2241
  if (n || i) {
2220
- const c = Rt(), u = Object.keys(c.links).length;
2221
- At({ links: {} }), console.log(`nimpress cache: cleared ${u} links`);
2242
+ const c = Pt(), u = Object.keys(c.links).length;
2243
+ Rt({ links: {} }), console.log(`nimpress cache: cleared ${u} links`);
2222
2244
  }
2223
2245
  if (o || i) {
2224
2246
  const c = Tt();
2225
- ne(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
2247
+ q(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
2226
2248
  }
2227
2249
  if (r) {
2228
2250
  const { resolved: c, configFile: u } = await we(e);
2229
2251
  if (!u) throw new Error(`[nimpress] cache: --local needs a nimpress config in ${e}`);
2230
2252
  const a = ot(e, c);
2231
- $(a) && ne(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
2253
+ b(a) && q(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
2232
2254
  }
2233
2255
  }
2234
- async function Xn(e) {
2256
+ async function eo(e) {
2235
2257
  const t = e[0] ?? "dev", s = e.slice(1), n = process.cwd();
2236
2258
  if (t === "init") {
2237
- ms(n);
2259
+ fs(n);
2238
2260
  return;
2239
2261
  }
2240
2262
  if (t === "skill") {
2241
- Is(n, s);
2263
+ Ls(n, s);
2242
2264
  return;
2243
2265
  }
2244
2266
  if (t === "plugin") {
2245
- Bs(n, s);
2267
+ Gs(n, s);
2246
2268
  return;
2247
2269
  }
2248
2270
  if (t === "mcp") {
2249
- mn(n);
2271
+ fn(n);
2250
2272
  return;
2251
2273
  }
2252
2274
  if (t === "completion") {
2253
- Xs(n, s);
2275
+ qs(n, s);
2254
2276
  return;
2255
2277
  }
2256
- if (t === "view" || t === "dev" && M(s, "view")) {
2257
- await Rn(n, s);
2278
+ if (t === "view" || t === "dev" && I(s, "view")) {
2279
+ await An(n, s);
2258
2280
  return;
2259
2281
  }
2260
2282
  if (t === "cache") {
2261
- await An(n, s);
2283
+ await Mn(n, s);
2262
2284
  return;
2263
2285
  }
2264
2286
  const { resolved: o } = await we(n);
2265
2287
  if (t === "seo") {
2266
- wn(n, o, s);
2288
+ $n(n, o, s);
2267
2289
  return;
2268
2290
  }
2269
2291
  if (t === "lint") {
2270
- await Es(n, o);
2292
+ await Os(n, o);
2271
2293
  return;
2272
2294
  }
2273
2295
  if (t === "dev") {
2274
- await $s(n, o);
2296
+ await ys(n, o);
2275
2297
  return;
2276
2298
  }
2277
2299
  if (t === "build") {
@@ -2279,7 +2301,7 @@ async function Xn(e) {
2279
2301
  return;
2280
2302
  }
2281
2303
  if (t === "guard") {
2282
- Fs(n, o, s);
2304
+ Ds(n, o, s);
2283
2305
  return;
2284
2306
  }
2285
2307
  if (t === "modules") {
@@ -2287,7 +2309,7 @@ async function Xn(e) {
2287
2309
  return;
2288
2310
  }
2289
2311
  if (t === "export") {
2290
- Ae(n, o, s);
2312
+ Re(n, o, s);
2291
2313
  return;
2292
2314
  }
2293
2315
  throw new Error(`[nimpress] unknown command: ${t}`);
@@ -2296,5 +2318,5 @@ export {
2296
2318
  st as buildViteConfig,
2297
2319
  Zt as indexHtml,
2298
2320
  we as loadNimpressConfig,
2299
- Xn as run
2321
+ eo as run
2300
2322
  };