@dawipong/opcflow 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/cli.mjs +57 -45
  2. package/package.json +1 -1
  3. package/web/dist/assets/{abnfDiagram-VRR7QNED-B5Ymr02_.js → abnfDiagram-VRR7QNED-DAx6EpGI.js} +1 -1
  4. package/web/dist/assets/{architectureDiagram-ZJ3FMSHR-DkSnVejp.js → architectureDiagram-ZJ3FMSHR-Dvr2nr59.js} +1 -1
  5. package/web/dist/assets/{chunk-EX3LRPZG-BH7du1zb.js → chunk-EX3LRPZG-M3QhKBUG.js} +1 -1
  6. package/web/dist/assets/{chunk-MOJQB5TN-BJQ2jnj0.js → chunk-MOJQB5TN-DXlFl9Jv.js} +1 -1
  7. package/web/dist/assets/{chunk-PUDLZKDR-C6SYgnAr.js → chunk-PUDLZKDR-BTWHaeTZ.js} +1 -1
  8. package/web/dist/assets/{chunk-V7JOEXUC-CPVDLAL6.js → chunk-V7JOEXUC-Cbgml1c1.js} +1 -1
  9. package/web/dist/assets/{classDiagram-OUVF2IWQ-Bq-vpAZV.js → classDiagram-OUVF2IWQ-Blusw6t4.js} +1 -1
  10. package/web/dist/assets/{classDiagram-v2-EOCWNBFH-Bq-vpAZV.js → classDiagram-v2-EOCWNBFH-Blusw6t4.js} +1 -1
  11. package/web/dist/assets/{cynefinDiagram-TSTJHNR4-C1e5y-Qt.js → cynefinDiagram-TSTJHNR4-DrrKaXmw.js} +1 -1
  12. package/web/dist/assets/{dagre-VKFMJZFB-C9vqkLKd.js → dagre-VKFMJZFB-BxDsa977.js} +1 -1
  13. package/web/dist/assets/{diagram-G47NLZAW-B0YXSheC.js → diagram-G47NLZAW-BxVnT5Li.js} +1 -1
  14. package/web/dist/assets/{diagram-NH7WQ7WH-B-0nt2Rj.js → diagram-NH7WQ7WH-BT56mGuK.js} +1 -1
  15. package/web/dist/assets/{diagram-OA4YK3LP-hTbE8qZc.js → diagram-OA4YK3LP-CezybdJA.js} +1 -1
  16. package/web/dist/assets/{diagram-WEI45ONY-z9AYL1YS.js → diagram-WEI45ONY-CO8JNWNf.js} +1 -1
  17. package/web/dist/assets/{ebnfDiagram-CCIWWBDH-BhlcOI7N.js → ebnfDiagram-CCIWWBDH-B-OkdWz4.js} +1 -1
  18. package/web/dist/assets/{erDiagram-Q63AITRT-Djt4xUn4.js → erDiagram-Q63AITRT-DQNn2L0y.js} +1 -1
  19. package/web/dist/assets/{flowDiagram-23GEKE2U-KXHFGTuX.js → flowDiagram-23GEKE2U-CPO1BGjg.js} +1 -1
  20. package/web/dist/assets/{index-D02utICb.js → index-HsPwY2CU.js} +5 -5
  21. package/web/dist/assets/{infoDiagram-FWYZ7A6U-DcyiJUfy.js → infoDiagram-FWYZ7A6U-DM429PMt.js} +1 -1
  22. package/web/dist/assets/{ishikawaDiagram-FXEZZL3T-C_XXRphh.js → ishikawaDiagram-FXEZZL3T-D-nr9wXb.js} +1 -1
  23. package/web/dist/assets/{kanban-definition-HUTT4EX6-BxPpLtNJ.js → kanban-definition-HUTT4EX6-Cq6fbJBF.js} +1 -1
  24. package/web/dist/assets/{mindmap-definition-LN4V7U3C-DMqPdkF8.js → mindmap-definition-LN4V7U3C-zZ5w-lPU.js} +1 -1
  25. package/web/dist/assets/{pegDiagram-2B236MQR-D3Uh6VmT.js → pegDiagram-2B236MQR-BL13lL1j.js} +1 -1
  26. package/web/dist/assets/{pieDiagram-ENE6RG2P-Cfk6tbDs.js → pieDiagram-ENE6RG2P-B1mmu34A.js} +1 -1
  27. package/web/dist/assets/{railroadDiagram-RFXS5EU6-DY-MNsQI.js → railroadDiagram-RFXS5EU6-BUbf08v3.js} +1 -1
  28. package/web/dist/assets/{requirementDiagram-TGXJPOKE-DkBeHVjA.js → requirementDiagram-TGXJPOKE-CgepHMpy.js} +1 -1
  29. package/web/dist/assets/{sequenceDiagram-DBY2YBRQ-C3xWt8pk.js → sequenceDiagram-DBY2YBRQ-CkIJuJ5O.js} +1 -1
  30. package/web/dist/assets/{stateDiagram-2N3HPSRC-awwgArtJ.js → stateDiagram-2N3HPSRC-wX6zU3Hv.js} +1 -1
  31. package/web/dist/assets/{stateDiagram-v2-6OUMAXLB-DCBMLj_H.js → stateDiagram-v2-6OUMAXLB-CAdDNary.js} +1 -1
  32. package/web/dist/assets/{swimlanes-5IMT3BWC-Diauu8OM.js → swimlanes-5IMT3BWC-YXgGP77C.js} +1 -1
  33. package/web/dist/assets/{swimlanesDiagram-G3AALYLV-CTpA1N8I.js → swimlanesDiagram-G3AALYLV--Ha4WrTi.js} +1 -1
  34. package/web/dist/assets/{timeline-definition-FHXFAJF6-CzLt2q6q.js → timeline-definition-FHXFAJF6-CtMf684d.js} +1 -1
  35. package/web/dist/assets/{vennDiagram-L72KCM5P-gYZsJaVB.js → vennDiagram-L72KCM5P-DbFoFgBM.js} +1 -1
  36. package/web/dist/assets/{wardleyDiagram-EHGQE667-N-mJLzn_.js → wardleyDiagram-EHGQE667-C3J4of-x.js} +1 -1
  37. package/web/dist/assets/{xychartDiagram-FW5EYKEG-CbPlSd84.js → xychartDiagram-FW5EYKEG-Fbzeb84K.js} +1 -1
  38. package/web/dist/index.html +1 -1
package/dist/cli.mjs CHANGED
@@ -690,6 +690,7 @@ __export(kind_exports, {
690
690
  META_KINDS: () => META_KINDS,
691
691
  PM_KINDS: () => PM_KINDS,
692
692
  contractKinds: () => contractKinds,
693
+ expandPattern: () => expandPattern,
693
694
  getKindRegistry: () => getKindRegistry,
694
695
  inferKind: () => inferKind,
695
696
  kindSpec: () => kindSpec,
@@ -755,15 +756,15 @@ var init_kind = __esm({
755
756
  project: { level: "project", approval: "human", parents: [], drivesStale: true, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{prd}/project.md"] },
756
757
  roles: { level: "project", approval: "human", parents: ["project"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/roles.md"] },
757
758
  glossary: { level: "project", approval: "human", parents: ["project"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/glossary.md"] },
758
- flow: { level: "module", approval: "human", parents: ["project", "roles", "glossary"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/flows/"] },
759
- "module-prd": { level: "module", approval: "human", parents: ["flow"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/modules/"] },
760
- "page-prd": { level: "page", approval: "human", parents: ["module-prd"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/pages/"] },
761
- "db-doc": { level: "module", approval: "human", parents: ["module-prd"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{architecture}/database/"] },
762
- "api-doc": { level: "module", approval: "human", parents: ["module-prd", "db-doc"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{architecture}/api/"] },
763
- "design-system": { level: "endpoint", approval: "human", parents: ["baseline"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{design}/systems/"] },
764
- "design-prompt": { level: "page", approval: "none", parents: ["page-prd", "api-doc", "design-system"], drivesStale: false, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{design}/prompts/"] },
765
- prototype: { level: "page", approval: "thumbs", parents: ["design-prompt", "design-system"], drivesStale: true, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{design}/prototypes/"] },
766
- acceptance: { level: "page", approval: "human", parents: ["page-prd", "prototype"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{acceptance}/"] },
759
+ flow: { level: "module", approval: "human", parents: ["project", "roles", "glossary"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/flows/"], coords: "{module}", defaultEndpoint: "common" },
760
+ "module-prd": { level: "module", approval: "human", parents: ["flow"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/modules/"], coords: "{module}", defaultEndpoint: "common" },
761
+ "page-prd": { level: "page", approval: "human", parents: ["module-prd"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{prd}/pages/"], coords: "{endpoint}/{module}/{page}" },
762
+ "db-doc": { level: "module", approval: "human", parents: ["module-prd"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{architecture}/database/"], coords: "{module}", defaultEndpoint: "common" },
763
+ "api-doc": { level: "module", approval: "human", parents: ["module-prd", "db-doc"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{architecture}/api/"], coords: "{module}", defaultEndpoint: "service" },
764
+ "design-system": { level: "endpoint", approval: "human", parents: ["baseline"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{design}/systems/"], coords: "{endpoint}" },
765
+ "design-prompt": { level: "page", approval: "none", parents: ["page-prd", "api-doc", "design-system"], drivesStale: false, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{design}/prompts/"], coords: "{endpoint}/{module}/{page}" },
766
+ prototype: { level: "page", approval: "thumbs", parents: ["design-prompt", "design-system"], drivesStale: true, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{design}/prototypes/"], coords: "{endpoint}/{module}/{page}" },
767
+ acceptance: { level: "page", approval: "human", parents: ["page-prd", "prototype"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{acceptance}/"], coords: "{endpoint}/{module}/{page}" },
767
768
  code: { level: "module", approval: "machine", parents: ["baseline", "api-doc", "prototype"], drivesStale: false, hashMode: "directory", retrieval: "semantic" },
768
769
  doc: { level: "module", approval: "none", parents: [], drivesStale: false, hashMode: "text-normalize", retrieval: "summary" }
769
770
  };
@@ -2412,31 +2413,37 @@ import { existsSync as existsSync9, readdirSync as readdirSync4, statSync as sta
2412
2413
  import { join as join10 } from "node:path";
2413
2414
  function parseCoords(ctx, kind, relPath) {
2414
2415
  const none = { module: null, endpoint: null, page: null };
2415
- const base = (p) => p.split("/").pop().replace(/\.(md|html)$/i, "");
2416
- const seg = relPath.split("/");
2416
+ const spec = getKindRegistry(ctx.config)[kind];
2417
+ const grammar = spec?.coords;
2418
+ if (!grammar) return none;
2419
+ const prefix = spec.pathPatterns?.[0] ? expandPattern(spec.pathPatterns[0], ctx.config) : "";
2420
+ const tail = relPath.startsWith(prefix) ? relPath.slice(prefix.length) : relPath;
2421
+ const tailSegs = tail.split("/").filter(Boolean);
2422
+ const gSegs = grammar.split("/");
2423
+ const defEnd = spec.defaultEndpoint ?? null;
2417
2424
  const mod = (raw) => normalizeModule(raw, ctx.config);
2418
- switch (kind) {
2419
- case "flow":
2420
- case "module-prd":
2421
- return { module: mod(base(relPath)), endpoint: "common", page: null };
2422
- case "db-doc":
2423
- return { module: mod(base(relPath)), endpoint: "common", page: null };
2424
- case "api-doc":
2425
- return { module: mod(base(relPath)), endpoint: "service", page: null };
2426
- case "design-system":
2427
- return { module: null, endpoint: base(relPath), page: null };
2428
- case "page-prd":
2429
- case "design-prompt":
2430
- case "prototype":
2431
- case "acceptance": {
2432
- if (seg.length < 3) return none;
2433
- const endpoint = seg[seg.length - 3];
2434
- const module = mod(seg[seg.length - 2]);
2435
- return { module, endpoint, page: `${module}/${base(relPath)}` };
2436
- }
2437
- default:
2438
- return none;
2439
- }
2425
+ if (gSegs.length === 1) {
2426
+ if (tailSegs.length === 0) return null;
2427
+ const leaf = stripExt(tailSegs[tailSegs.length - 1]);
2428
+ if (gSegs[0] === "{module}") return { module: mod(leaf), endpoint: defEnd, page: null };
2429
+ if (gSegs[0] === "{endpoint}") return { module: null, endpoint: leaf, page: null };
2430
+ return none;
2431
+ }
2432
+ const hasPage = gSegs[gSegs.length - 1] === "{page}";
2433
+ const fixed = hasPage ? gSegs.length - 1 : gSegs.length;
2434
+ if (hasPage ? tailSegs.length < gSegs.length : tailSegs.length !== gSegs.length) return null;
2435
+ const cap = {};
2436
+ for (let i = 0; i < fixed; i++) cap[gSegs[i]] = stripExt(tailSegs[i]);
2437
+ if (cap["{endpoint}"] !== void 0 && !ctx.config.endpoints.includes(cap["{endpoint}"])) return null;
2438
+ const endpoint = cap["{endpoint}"] ?? defEnd;
2439
+ const module = cap["{module}"] !== void 0 ? mod(cap["{module}"]) : null;
2440
+ let page = null;
2441
+ if (hasPage) {
2442
+ const pageSegs = tailSegs.slice(fixed);
2443
+ const pageTail = pageSegs.map((s, i) => i === pageSegs.length - 1 ? stripExt(s) : s).join("/");
2444
+ page = module ? `${module}/${pageTail}` : pageTail;
2445
+ }
2446
+ return { module, endpoint, page };
2440
2447
  }
2441
2448
  function isMetaPath(ctx, relPath) {
2442
2449
  const registry = getKindRegistry(ctx.config);
@@ -2528,7 +2535,7 @@ function deriveEdges(ctx) {
2528
2535
  return created;
2529
2536
  }
2530
2537
  function scanArtifacts(ctx, actor = "system") {
2531
- const summary = { registered: 0, refreshed: 0, remapped: 0, edges: 0, skipped: [] };
2538
+ const summary = { registered: 0, refreshed: 0, remapped: 0, edges: 0, skipped: [], unresolved: [] };
2532
2539
  const files = [];
2533
2540
  for (const dir of Object.values(ctx.config.docs)) {
2534
2541
  const abs = join10(ctx.root, dir);
@@ -2552,7 +2559,7 @@ function scanArtifacts(ctx, actor = "system") {
2552
2559
  const before = row.content_hash;
2553
2560
  const after = refreshArtifact(ctx, { id: row.id }, actor);
2554
2561
  if (after.content_hash !== before) summary.refreshed++;
2555
- if (row.kind !== kind || row.module !== coords.module || row.endpoint !== coords.endpoint || row.page !== coords.page) {
2562
+ if (coords && (row.kind !== kind || row.module !== coords.module || row.endpoint !== coords.endpoint || row.page !== coords.page)) {
2556
2563
  const tx2 = ctx.db.transaction(() => {
2557
2564
  remap.run(kind, coords.module, coords.endpoint, coords.page, row.id);
2558
2565
  logEvent(ctx.db, {
@@ -2575,6 +2582,10 @@ function scanArtifacts(ctx, actor = "system") {
2575
2582
  }
2576
2583
  return;
2577
2584
  }
2585
+ if (!coords) {
2586
+ summary.unresolved.push(relPath);
2587
+ return;
2588
+ }
2578
2589
  const hash = hashPath(join10(ctx.root, relPath));
2579
2590
  if (hash === null) return;
2580
2591
  const tx = ctx.db.transaction(() => {
@@ -2607,6 +2618,7 @@ function scanArtifacts(ctx, actor = "system") {
2607
2618
  summary.edges = deriveEdges(ctx);
2608
2619
  return summary;
2609
2620
  }
2621
+ var stripExt;
2610
2622
  var init_scan_command = __esm({
2611
2623
  "core/commands/scan.command.ts"() {
2612
2624
  "use strict";
@@ -2614,6 +2626,7 @@ var init_scan_command = __esm({
2614
2626
  init_hash();
2615
2627
  init_kind();
2616
2628
  init_artifact_commands();
2629
+ stripExt = (s) => s.replace(/\.(md|html)$/i, "");
2617
2630
  }
2618
2631
  });
2619
2632
 
@@ -3435,6 +3448,7 @@ __export(core_exports, {
3435
3448
  distillFeedback: () => distillFeedback,
3436
3449
  ensureSchema: () => ensureSchema,
3437
3450
  everApproved: () => everApproved,
3451
+ expandPattern: () => expandPattern,
3438
3452
  exportEventLog: () => exportEventLog,
3439
3453
  feedbackArtifact: () => feedbackArtifact,
3440
3454
  findProjectRoot: () => findProjectRoot,
@@ -3682,7 +3696,7 @@ __export(app_exports, {
3682
3696
  import fastifyCors from "@fastify/cors";
3683
3697
  import fastifyStatic from "@fastify/static";
3684
3698
  import Fastify from "fastify";
3685
- import { existsSync as existsSync14, readFileSync as readFileSync8, readdirSync as readdirSync7, statSync as statSync6 } from "node:fs";
3699
+ import { existsSync as existsSync14, mkdirSync as mkdirSync8, readFileSync as readFileSync8, readdirSync as readdirSync7, statSync as statSync6 } from "node:fs";
3686
3700
  import { isAbsolute as isAbsolute2, join as join16, normalize, relative as relative2 } from "node:path";
3687
3701
  function getArtifact(ctx, id) {
3688
3702
  const row = ctx.db.prepare("SELECT * FROM artifacts WHERE id = ?").get(id);
@@ -3706,6 +3720,9 @@ async function createServer(ctx) {
3706
3720
  if (existsSync14(webDist)) {
3707
3721
  await app.register(fastifyStatic, { root: webDist });
3708
3722
  }
3723
+ const protoRoot = join16(ctx.root, ctx.config.docs.design, "prototypes");
3724
+ mkdirSync8(protoRoot, { recursive: true });
3725
+ await app.register(fastifyStatic, { root: protoRoot, prefix: "/proto/", decorateReply: false });
3709
3726
  app.get("/api/meta", async () => ({
3710
3727
  root: ctx.root,
3711
3728
  language: ctx.config.language,
@@ -3747,15 +3764,6 @@ async function createServer(ctx) {
3747
3764
  }
3748
3765
  return { artifact, content, isDirectory, missing, feedback, events };
3749
3766
  });
3750
- app.get("/api/artifact/:id/raw", async (req, reply) => {
3751
- const artifact = getArtifact(ctx, parseInt(req.params.id));
3752
- const abs = guardedAbsPath(ctx, artifact);
3753
- if (!existsSync14(abs) || statSync6(abs).isDirectory()) {
3754
- return reply.code(404).send("not found");
3755
- }
3756
- reply.header("content-type", artifact.path.endsWith(".html") ? "text/html; charset=utf-8" : "text/plain; charset=utf-8");
3757
- return reply.send(readFileSync8(abs));
3758
- });
3759
3767
  app.get("/api/artifact/:id/files", async (req) => {
3760
3768
  const artifact = getArtifact(ctx, parseInt(req.params.id));
3761
3769
  const base = guardedAbsPath(ctx, artifact);
@@ -4440,6 +4448,10 @@ async function runCommand(ctx, command, a) {
4440
4448
  case "scan": {
4441
4449
  const s = scanArtifacts(ctx, a.actor || "system");
4442
4450
  console.log(chalk.green(`\u2705 \u626B\u63CF\u5B8C\u6210:\u65B0\u767B\u8BB0 ${s.registered},\u5185\u5BB9\u5237\u65B0 ${s.refreshed},\u91CD\u6302\u5750\u6807 ${s.remapped},\u65B0\u589E\u8FB9 ${s.edges},\u6392\u9664\u5143\u4EA7\u7269 ${s.skipped.length}`));
4451
+ if (s.unresolved.length > 0) {
4452
+ console.log(chalk.yellow(`\u26A0 ${s.unresolved.length} \u4E2A\u6587\u4EF6\u547D\u4E2D kind \u4F46\u8DEF\u5F84\u4E0D\u7B26 coords \u6587\u6CD5,\u672A\u767B\u8BB0(\u975E\u89C4\u8303/\u5E9F\u5F03\u7AEF?):`));
4453
+ for (const p of s.unresolved) console.log(chalk.yellow(` - ${p}`));
4454
+ }
4443
4455
  break;
4444
4456
  }
4445
4457
  case "move": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawipong/opcflow",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Spec-anchored, drift-enforced execution layer for AI coding agents — artifact DAG, trust gates, multi-role pipeline; generates agents/MCP/hooks for Claude Code, Codex, OpenCode & Cursor.",
5
5
  "license": "MIT",
6
6
  "author": "Dawi",
@@ -1 +1 @@
1
- import{m as e}from"./src-W4W9ly-y.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import"./chunk-WYO6CB5R-BaRUDpDl.js";import"./index-D02utICb.js";import{m as n,t as r}from"./mermaid-parser.core-CAAH_OSq.js";import{n as i,r as a,t as o}from"./chunk-MOJQB5TN-BJQ2jnj0.js";import{t as s}from"./chunk-JWPE2WC7-DVXcaiue.js";var c=n().RailroadAbnf.parser.LangiumParser,l=t(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=t(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=t(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=t(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=t(e=>{switch(e.$type){case`AbnfStringLiteral`:return{type:`terminal`,value:e.value};case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=t(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=t(e=>{s(e,o),e.title&&o.setTitle(e.title),e.rules.map(e=>o.addRule(m(e)))},`populateDb`),g={parser:{parse:t(t=>{o.clear(),e.debug(`[ABNF Parser] Starting Langium parse`);let n=c.parse(t);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new r(n);let i=n.value;e.debug(`[ABNF Parser] Parsed rules:`,i.rules.length),h(i),e.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:o}},db:o,renderer:a,styles:i};export{g as diagram};
1
+ import{m as e}from"./src-W4W9ly-y.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import"./chunk-WYO6CB5R-BaRUDpDl.js";import"./index-HsPwY2CU.js";import{m as n,t as r}from"./mermaid-parser.core-CAAH_OSq.js";import{n as i,r as a,t as o}from"./chunk-MOJQB5TN-DXlFl9Jv.js";import{t as s}from"./chunk-JWPE2WC7-DVXcaiue.js";var c=n().RailroadAbnf.parser.LangiumParser,l=t(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=t(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=t(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=t(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=t(e=>{switch(e.$type){case`AbnfStringLiteral`:return{type:`terminal`,value:e.value};case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=t(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=t(e=>{s(e,o),e.title&&o.setTitle(e.title),e.rules.map(e=>o.addRule(m(e)))},`populateDb`),g={parser:{parse:t(t=>{o.clear(),e.debug(`[ABNF Parser] Starting Langium parse`);let n=c.parse(t);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new r(n);let i=n.value;e.debug(`[ABNF Parser] Parsed rules:`,i.rules.length),h(i),e.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:o}},db:o,renderer:a,styles:i};export{g as diagram};