@fullstackhouse/cerber 1.6.1 → 1.6.2-pr.91.45d4d8c

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 (65) hide show
  1. package/dist/cli/index.js +1 -0
  2. package/dist/core/artifact.js +3 -2
  3. package/dist/core/state.js +18 -7
  4. package/dist/server/daemon.js +11 -13
  5. package/dist/server/index.js +61 -33
  6. package/package.json +1 -1
  7. package/web/dist/assets/{abnfDiagram-WEYOIA3C-BTgaW5Ha.js → abnfDiagram-WEYOIA3C-DDWiBgJ_.js} +1 -1
  8. package/web/dist/assets/{arc-CIs3AUpT.js → arc-CXTmovRq.js} +1 -1
  9. package/web/dist/assets/{architectureDiagram-ZHVYKT53-BxOr0InY.js → architectureDiagram-ZHVYKT53-DPwB58EC.js} +1 -1
  10. package/web/dist/assets/{blockDiagram-RJAE7QA3-Jz3vlC0A.js → blockDiagram-RJAE7QA3-BbdcPjtf.js} +1 -1
  11. package/web/dist/assets/{c4Diagram-XDPPPE54-CWxNefHm.js → c4Diagram-XDPPPE54-DHzjA55M.js} +1 -1
  12. package/web/dist/assets/channel-Bc1egjP3.js +1 -0
  13. package/web/dist/assets/{chunk-2E7WHVMD-rH7H23MR.js → chunk-2E7WHVMD-X1BSLNbz.js} +1 -1
  14. package/web/dist/assets/{chunk-2Q5K7J3B-CpVRQRjE.js → chunk-2Q5K7J3B-4uva6Krv.js} +1 -1
  15. package/web/dist/assets/{chunk-4EMNKR2T-CaV39mOM.js → chunk-4EMNKR2T-DFnlUBTZ.js} +1 -1
  16. package/web/dist/assets/{chunk-55XCU76K-BohfUFNm.js → chunk-55XCU76K-Cu8cVLZy.js} +1 -1
  17. package/web/dist/assets/{chunk-5VM5RSS4-DvbGi5bp.js → chunk-5VM5RSS4-B9WXEPBE.js} +1 -1
  18. package/web/dist/assets/{chunk-JWPE2WC7-D6RgvVPu.js → chunk-JWPE2WC7-CCsYBl0M.js} +1 -1
  19. package/web/dist/assets/{chunk-VQ5W62QI-ClY7U6Vf.js → chunk-VQ5W62QI-DBHQMI3P.js} +1 -1
  20. package/web/dist/assets/{chunk-XXDRQBXY-eY9jOqr_.js → chunk-XXDRQBXY-DFB2lFGh.js} +1 -1
  21. package/web/dist/assets/{chunk-ZCHMQSOR-CgMio2CB.js → chunk-ZCHMQSOR-dvczqjG8.js} +2 -2
  22. package/web/dist/assets/{classDiagram-v2-4MYWR3UA-LlSJxp_t.js → classDiagram-v2-4MYWR3UA-Ck2KUiuM.js} +1 -1
  23. package/web/dist/assets/{cose-bilkent-JH36ORCC-Bnh1tLw9.js → cose-bilkent-JH36ORCC-DcMTug3a.js} +1 -1
  24. package/web/dist/assets/{cynefin-EF2NZ3EQ-kGniXg3w.js → cynefin-EF2NZ3EQ-BG2opkNs.js} +1 -1
  25. package/web/dist/assets/{cynefinDiagram-WF24UDRP--Uo3wdoa.js → cynefinDiagram-WF24UDRP-BTIMNySy.js} +1 -1
  26. package/web/dist/assets/{dagre-NK4GIZVX-C6Wh-8uX.js → dagre-NK4GIZVX-1qi-5iCE.js} +1 -1
  27. package/web/dist/assets/{diagram-CBK3MWTC-5hd0s-_G.js → diagram-CBK3MWTC-CSH989hb.js} +1 -1
  28. package/web/dist/assets/{diagram-I5XIIV2D-Dk1mkLAG.js → diagram-I5XIIV2D-Z_1T8l7R.js} +1 -1
  29. package/web/dist/assets/{diagram-ODIL2UCW-CBt3ss4a.js → diagram-ODIL2UCW-B8jB07f-.js} +1 -1
  30. package/web/dist/assets/{diagram-PFBEJUXE-hYmeDTI1.js → diagram-PFBEJUXE-B9qraPmL.js} +1 -1
  31. package/web/dist/assets/{diagram-RJA3I4VV-BzbVAjB8.js → diagram-RJA3I4VV-CFhy381H.js} +1 -1
  32. package/web/dist/assets/{diagram-TYUNFSNR-DtRFKw4v.js → diagram-TYUNFSNR-DYEBj8MB.js} +1 -1
  33. package/web/dist/assets/{ebnfDiagram-V4P3TTPT-B9DWiiEP.js → ebnfDiagram-V4P3TTPT-DGtaeIoV.js} +1 -1
  34. package/web/dist/assets/{elk-QONTBCTQ-BdbHmsQg.js → elk-QONTBCTQ-Cpcx9jQq.js} +1 -1
  35. package/web/dist/assets/{erDiagram-KYQIGQAA-hMT7oMcs.js → erDiagram-KYQIGQAA-BFMhv1lb.js} +1 -1
  36. package/web/dist/assets/{flowDiagram-IUGLLWBU-QHTEaXd4.js → flowDiagram-IUGLLWBU-ZvrIwHpb.js} +1 -1
  37. package/web/dist/assets/{ganttDiagram-R7GPNTJY-CQrMEpag.js → ganttDiagram-R7GPNTJY-CMElMuNb.js} +1 -1
  38. package/web/dist/assets/{gitGraphDiagram-PDYL7XHY-DTSXZY8U.js → gitGraphDiagram-PDYL7XHY-C2YKWJEE.js} +1 -1
  39. package/web/dist/assets/{index-DKlYleui.js → index-CcSO4iOX.js} +3 -3
  40. package/web/dist/assets/{infoDiagram-MVDRKAX5-xNT6AIyK.js → infoDiagram-MVDRKAX5-Cekh0IW0.js} +1 -1
  41. package/web/dist/assets/{ishikawaDiagram-HPEHV2GE-MOjUFqQG.js → ishikawaDiagram-HPEHV2GE-BoxRJEa6.js} +1 -1
  42. package/web/dist/assets/{journeyDiagram-BOSHW7O7-C6ix2UEr.js → journeyDiagram-BOSHW7O7-kDJSSn-6.js} +1 -1
  43. package/web/dist/assets/{kanban-definition-FNSA4HC5-m2Nnm0cp.js → kanban-definition-FNSA4HC5-CBQ3lPM5.js} +1 -1
  44. package/web/dist/assets/{linear-B0rSbcNk.js → linear-DSIqP0TT.js} +1 -1
  45. package/web/dist/assets/{mermaid.core-CzVteVfI.js → mermaid.core-wbwCbWuQ.js} +4 -4
  46. package/web/dist/assets/{mindmap-definition-6OY57UG3-BJXUx9NU.js → mindmap-definition-6OY57UG3-C2PqDFz9.js} +1 -1
  47. package/web/dist/assets/{pegDiagram-ECIUJNBX-BulMADbl.js → pegDiagram-ECIUJNBX-S9r7bybM.js} +1 -1
  48. package/web/dist/assets/{pieDiagram-GNMPY74T-D4YgVxMx.js → pieDiagram-GNMPY74T-C1DFot1v.js} +1 -1
  49. package/web/dist/assets/{quadrantDiagram-D57K4MC3-CEV3_qk3.js → quadrantDiagram-D57K4MC3-QaUZgGzi.js} +1 -1
  50. package/web/dist/assets/{railroadDiagram-Y72NRBL7-CH4PrK1m.js → railroadDiagram-Y72NRBL7-BTsaNbut.js} +1 -1
  51. package/web/dist/assets/{requirementDiagram-EQYSW5RA-DvMpht2E.js → requirementDiagram-EQYSW5RA-Bul4YAfK.js} +1 -1
  52. package/web/dist/assets/{sankeyDiagram-SY24JHO5-XVD77nVZ.js → sankeyDiagram-SY24JHO5-J8X2PWDq.js} +1 -1
  53. package/web/dist/assets/{sequenceDiagram-BLEHNHQU-DkIENxL4.js → sequenceDiagram-BLEHNHQU-CTX4Y6no.js} +1 -1
  54. package/web/dist/assets/{sizeCapture-INFHLROL-_kq1C291.js → sizeCapture-INFHLROL-CXfB7h8n.js} +1 -1
  55. package/web/dist/assets/{stateDiagram-v2-A6IESKWZ-DsZFBHWW.js → stateDiagram-v2-A6IESKWZ-Kr5pKDbm.js} +1 -1
  56. package/web/dist/assets/{swimlanes-B3ENRKFQ-CFh405XI.js → swimlanes-B3ENRKFQ-DDWGDYUC.js} +1 -1
  57. package/web/dist/assets/swimlanesDiagram-AYQRV4AK-BkmYK-f1.js +8 -0
  58. package/web/dist/assets/{timeline-definition-JXYKGLGB-DXG5erfr.js → timeline-definition-JXYKGLGB-BAKElQ5f.js} +1 -1
  59. package/web/dist/assets/{usecaseDiagram-WPOLBNNX-CVHIvGVO.js → usecaseDiagram-WPOLBNNX-Dlw_OwnV.js} +1 -1
  60. package/web/dist/assets/{vennDiagram-Q3Y3IDCW-CaxyQ2k9.js → vennDiagram-Q3Y3IDCW-bTukfT0U.js} +1 -1
  61. package/web/dist/assets/{wardleyDiagram-IVAIDKWA-Bf5fGTPN.js → wardleyDiagram-IVAIDKWA-DeM6AGmO.js} +1 -1
  62. package/web/dist/assets/{xychartDiagram-4URNHDU4-D1bQbTqS.js → xychartDiagram-4URNHDU4-CVYyvgbH.js} +1 -1
  63. package/web/dist/index.html +1 -1
  64. package/web/dist/assets/channel-BmW_aDh3.js +0 -1
  65. package/web/dist/assets/swimlanesDiagram-AYQRV4AK-BLXLX888.js +0 -8
package/dist/cli/index.js CHANGED
@@ -272,6 +272,7 @@ program
272
272
  await updateArtifactByKey(artifactKey(id), (a) => ({
273
273
  ...a,
274
274
  status: "sent",
275
+ pr: { ...a.pr, updatedAt: new Date().toISOString() },
275
276
  sent: { at: new Date().toISOString(), event, url, auto: false },
276
277
  calibration: computeCalibration(a, event),
277
278
  }));
@@ -160,8 +160,7 @@ export const PrInfoSchema = z.object({
160
160
  changedFiles: z.number().int().default(0),
161
161
  /**
162
162
  * When the PR itself last changed on GitHub — not when cerber last wrote this
163
- * file. On a row nobody has drafted, `updatedAt` is only when the poll found
164
- * it, so this is what the queue shows and sorts by there. Optional: artifacts
163
+ * file. This is what the queue shows and sorts by, on every row. Optional: artifacts
165
164
  * written before it existed load without it, and the poll fills it in.
166
165
  */
167
166
  updatedAt: z.string().optional(),
@@ -382,6 +381,8 @@ export const PendingChatSchema = z.object({
382
381
  progress: z.array(z.string()).default([]),
383
382
  /** What the user added while it worked — each one went into the live run. */
384
383
  steers: z.array(z.string()).default([]),
384
+ /** What it could no longer take: sent as the next turn once this one lands. */
385
+ queued: z.array(z.string()).optional(),
385
386
  /** Why the turn failed. Null while it is still running. */
386
387
  error: z.string().nullable().default(null),
387
388
  });
@@ -161,14 +161,25 @@ export async function deleteArtifact(id) {
161
161
  }
162
162
  }
163
163
  /** Load by key, apply a mutation, bump updatedAt, save. Returns the new artifact. */
164
- export async function updateArtifactByKey(key, mutate) {
165
- const artifact = await loadArtifactByKey(key);
166
- if (!artifact)
167
- return null;
168
- const updated = { ...mutate(artifact), updatedAt: new Date().toISOString() };
169
- await saveArtifact(updated);
170
- return updated;
164
+ export function updateArtifactByKey(key, mutate) {
165
+ // One at a time per review: a message queued while the answer is being written
166
+ // would otherwise be lost, or put the finished turn back as still running.
167
+ const run = (updates.get(key) ?? Promise.resolve()).then(async () => {
168
+ const artifact = await loadArtifactByKey(key);
169
+ if (!artifact)
170
+ return null;
171
+ const updated = { ...mutate(artifact), updatedAt: new Date().toISOString() };
172
+ await saveArtifact(updated);
173
+ return updated;
174
+ });
175
+ const settled = run.catch(() => { }).finally(() => {
176
+ if (updates.get(key) === settled)
177
+ updates.delete(key);
178
+ });
179
+ updates.set(key, settled);
180
+ return run;
171
181
  }
182
+ const updates = new Map();
172
183
  /**
173
184
  * Clear AI work left in flight by a process that died mid-run — a review marked
174
185
  * "running", a chat turn still waiting for its answer, or a check for findings
@@ -464,23 +464,20 @@ export function startDaemon(opts) {
464
464
  // already in hand — or the queue keeps calling a ready PR a draft until
465
465
  // something happens to re-review it.
466
466
  //
467
- // The PR's last activity is refreshed only on a row nobody has drafted,
468
- // the one place the queue reads it (`activityAt`). Every write bumps the
469
- // artifact's own `updatedAt`, and on a drafted row that is the review's
470
- // date: refreshing there would re-date every draft by the poll each time
471
- // its PR saw a comment, which is the meaningless date this field exists
472
- // to replace — and would race an open review's refresh besides.
473
- const activity = existing.status === "awaiting" && existing.pr.updatedAt !== ref.updatedAt;
474
- if (existing.pr.isDraft !== ref.isDraft || activity) {
467
+ if (existing.pr.isDraft !== ref.isDraft) {
475
468
  await updateArtifactByKey(artifactKey(existing.id), (a) => ({
476
469
  ...a,
477
- pr: {
478
- ...a.pr,
479
- isDraft: ref.isDraft,
480
- updatedAt: a.status === "awaiting" ? ref.updatedAt : a.pr.updatedAt,
481
- },
470
+ pr: { ...a.pr, isDraft: ref.isDraft },
482
471
  }));
483
472
  }
473
+ // The PR's last activity is what dates the row in the queue
474
+ // (`activityAt`). Saved directly: `updatedAt` is the artifact's version
475
+ // and a running row's "started 3m ago", and neither moved because
476
+ // somebody commented on the PR.
477
+ const current = await loadArtifact(existing.id);
478
+ if (current && current.pr.updatedAt !== ref.updatedAt) {
479
+ await saveArtifact({ ...current, pr: { ...current.pr, updatedAt: ref.updatedAt } });
480
+ }
484
481
  continue;
485
482
  }
486
483
  await saveArtifact(stubArtifact(ref, isOwnPr(ref, await who())));
@@ -969,6 +966,7 @@ export function startDaemon(opts) {
969
966
  await updateArtifactByKey(artifactKey(artifact.id), (a) => ({
970
967
  ...a,
971
968
  status: "sent",
969
+ pr: { ...a.pr, updatedAt: new Date().toISOString() },
972
970
  sent: { at: new Date().toISOString(), event: "APPROVE", url, auto: true },
973
971
  calibration: computeCalibration(a, "APPROVE"),
974
972
  }));
@@ -776,33 +776,16 @@ export async function buildApp(opts) {
776
776
  allowUserComments: z.boolean().optional(),
777
777
  });
778
778
  const turnInFlight = (a) => a.pendingChat != null && a.pendingChat.error == null;
779
- app.post("/api/reviews/:key/chat", async (c) => {
780
- const key = c.req.param("key");
781
- const artifact = await loadArtifactByKey(key);
782
- if (!artifact)
783
- return c.json({ error: "not found" }, 404);
784
- // A sent review is a record of what was posted — arguing with it now would
785
- // rewrite history that GitHub already has.
786
- if (artifact.sent)
787
- return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
788
- if (isReviewRunning(artifact.id) || turnInFlight(artifact)) {
789
- return c.json({ error: busy(artifact, "a run for this PR is already in flight") }, 409);
790
- }
791
- let request;
792
- try {
793
- request = ChatRequestSchema.parse(await c.req.json());
794
- }
795
- catch (err) {
796
- return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
797
- }
779
+ /** Record the question and answer it detached. Resolves once it is recorded. */
780
+ const startTurn = async (key, artifact, message, refs, allowUserComments) => {
798
781
  // Record the question before responding, so the cockpit's next poll — and a
799
782
  // reload mid-turn — finds a turn being answered rather than a message that
800
783
  // went nowhere.
801
784
  const pending = await updateArtifactByKey(key, (a) => ({
802
785
  ...a,
803
786
  pendingChat: {
804
- message: request.message,
805
- refs: request.refs ?? [],
787
+ message,
788
+ refs: refs ?? [],
806
789
  startedAt: new Date().toISOString(),
807
790
  progress: [],
808
791
  steers: [],
@@ -816,9 +799,9 @@ export async function buildApp(opts) {
816
799
  // Holding the request open is fine on localhost and fails behind a reverse
817
800
  // proxy's read timeout, which tells the user it broke while the turn
818
801
  // quietly succeeds — a worse failure than an honest error.
819
- void runChatTurn(artifact, request.message, {
820
- refs: request.refs,
821
- allowUserComments: request.allowUserComments,
802
+ void runChatTurn(artifact, message, {
803
+ refs,
804
+ allowUserComments,
822
805
  onProgress: (m) => {
823
806
  console.log(`[chat ${artifact.id}] ${m}`);
824
807
  progress.push(m);
@@ -835,12 +818,20 @@ export async function buildApp(opts) {
835
818
  // the review's own were. Marked in the same write that clears the
836
819
  // turn, so the cockpit's poll has no gap in which nothing is pending.
837
820
  const added = result.artifact.comments.some((cm) => !artifact.comments.some((before) => before.id === cm.id));
821
+ let queued = [];
838
822
  const landed = await updateArtifactByKey(key, (current) => {
823
+ queued = current.pendingChat?.queued ?? [];
839
824
  const merged = { ...mergeConcurrentEdits(artifact, result.artifact, current), pendingChat: null };
840
825
  return added ? startRaisedCheck(merged, new Date().toISOString()) : merged;
841
826
  });
842
- if (added && landed)
843
- void checkInBackground(landed);
827
+ const check = added && landed ? checkInBackground(landed) : null;
828
+ if (queued.length === 0)
829
+ return;
830
+ // The check holds the review's slot, so the next turn waits its go.
831
+ await check;
832
+ const next = await loadArtifactByKey(key);
833
+ if (next && !next.sent)
834
+ await startTurn(key, next, queued.join("\n\n"));
844
835
  })
845
836
  .catch(async (err) => {
846
837
  const message = err instanceof Error ? err.message : String(err);
@@ -854,18 +845,42 @@ export async function buildApp(opts) {
854
845
  pendingChat: a.pendingChat ? { ...a.pendingChat, error: message } : null,
855
846
  })).catch(() => { });
856
847
  });
848
+ return pending;
849
+ };
850
+ app.post("/api/reviews/:key/chat", async (c) => {
851
+ const key = c.req.param("key");
852
+ const artifact = await loadArtifactByKey(key);
853
+ if (!artifact)
854
+ return c.json({ error: "not found" }, 404);
855
+ // A sent review is a record of what was posted — arguing with it now would
856
+ // rewrite history that GitHub already has.
857
+ if (artifact.sent)
858
+ return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
859
+ if (isReviewRunning(artifact.id) || turnInFlight(artifact)) {
860
+ return c.json({ error: busy(artifact, "a run for this PR is already in flight") }, 409);
861
+ }
862
+ let request;
863
+ try {
864
+ request = ChatRequestSchema.parse(await c.req.json());
865
+ }
866
+ catch (err) {
867
+ return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
868
+ }
869
+ const pending = await startTurn(key, artifact, request.message, request.refs, request.allowUserComments);
857
870
  return c.json(pending, 202);
858
871
  });
859
872
  // Add to the turn being answered rather than waiting minutes to say "not that,
860
- // this". The message goes into the live run; when the turn has already
861
- // answered (or is only retrying its JSON) there is nothing to add it to, and
862
- // the cockpit is told so instead of being shown a message that went nowhere.
873
+ // this". A message is never turned away for its timing: one the live run can't
874
+ // take (still cloning, retrying its JSON, already answered) waits on the
875
+ // artifact for the next turn, and with no turn left it is the next turn.
863
876
  const SteerRequestSchema = z.object({ message: z.string().min(1) });
864
877
  app.post("/api/reviews/:key/chat/steer", async (c) => {
865
878
  const key = c.req.param("key");
866
879
  const artifact = await loadArtifactByKey(key);
867
880
  if (!artifact)
868
881
  return c.json({ error: "not found" }, 404);
882
+ if (artifact.sent)
883
+ return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
869
884
  let request;
870
885
  try {
871
886
  request = SteerRequestSchema.parse(await c.req.json());
@@ -873,11 +888,21 @@ export async function buildApp(opts) {
873
888
  catch (err) {
874
889
  return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
875
890
  }
876
- if (!turnInFlight(artifact) || !steerChatTurn(artifact.id, request.message)) {
877
- return c.json({ error: "that turn is no longer taking messages — send this as the next one" }, 409);
891
+ if (turnInFlight(artifact) && steerChatTurn(artifact.id, request.message)) {
892
+ const updated = await updateArtifactByKey(key, (a) => a.pendingChat ? { ...a, pendingChat: { ...a.pendingChat, steers: [...a.pendingChat.steers, request.message] } } : a);
893
+ return c.json(updated);
878
894
  }
879
- const updated = await updateArtifactByKey(key, (a) => a.pendingChat ? { ...a, pendingChat: { ...a.pendingChat, steers: [...a.pendingChat.steers, request.message] } } : a);
880
- return c.json(updated);
895
+ const updated = await updateArtifactByKey(key, (a) => a.pendingChat
896
+ ? { ...a, pendingChat: { ...a.pendingChat, queued: [...(a.pendingChat.queued ?? []), request.message] } }
897
+ : a);
898
+ if (updated?.pendingChat)
899
+ return c.json(updated);
900
+ if (!updated)
901
+ return c.json({ error: "not found" }, 404);
902
+ if (isReviewRunning(updated.id)) {
903
+ return c.json({ error: busy(updated, "a run for this PR is already in flight") }, 409);
904
+ }
905
+ return c.json(await startTurn(key, updated, request.message));
881
906
  });
882
907
  // Clear a turn that failed. Only that: a turn still being answered would come
883
908
  // back on the next write and the cockpit would have lied about dropping it.
@@ -970,6 +995,8 @@ export async function buildApp(opts) {
970
995
  await updateArtifactByKey(c.req.param("key"), (a) => ({
971
996
  ...a,
972
997
  status: "sent",
998
+ // A send is activity on the PR, and a sent PR usually leaves the poll's search.
999
+ pr: { ...a.pr, updatedAt: new Date().toISOString() },
973
1000
  sent: { at: new Date().toISOString(), event: payload.event, url, auto: false },
974
1001
  calibration: computeCalibration(a, payload.event),
975
1002
  }));
@@ -1228,6 +1255,7 @@ export async function buildApp(opts) {
1228
1255
  const settles = !sent && !a.sent;
1229
1256
  return {
1230
1257
  ...recordReplies(a, replies),
1258
+ pr: { ...a.pr, updatedAt: at },
1231
1259
  status: sent ? "sent" : a.sent ? a.status : "skipped",
1232
1260
  settledAt: settles ? at : a.settledAt,
1233
1261
  // Cerber's account of why a row is filed away cannot stand next to your
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstackhouse/cerber",
3
- "version": "1.6.1",
3
+ "version": "1.6.2-pr.91.45d4d8c",
4
4
  "description": "AI code-review cockpit: Claude reviews your PRs into local artifacts; nothing reaches GitHub until you say so.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-rH7H23MR.js";import{p as f}from"./chunk-JWPE2WC7-D6RgvVPu.js";import{_ as n,l as o}from"./mermaid.core-CzVteVfI.js";import{M as c,b as d}from"./cynefin-EF2NZ3EQ-kGniXg3w.js";import"./index-DKlYleui.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(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 i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-X1BSLNbz.js";import{p as f}from"./chunk-JWPE2WC7-CCsYBl0M.js";import{_ as n,l as o}from"./mermaid.core-wbwCbWuQ.js";import{M as c,b as d}from"./cynefin-EF2NZ3EQ-BG2opkNs.js";import"./index-CcSO4iOX.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(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 i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
@@ -1 +1 @@
1
- import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-CzVteVfI.js";function cn(l){return l.innerRadius}function gn(l){return l.outerRadius}function yn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,A,C,a){var I=E-l,i=q-h,n=C-v,d=a-A,u=d*I-n*i;if(!(u*u<g))return u=(n*(h-A)-d*(l-v))/u,[l+u*I,h+u*i]}function W(l,h,E,q,v,A,C){var a=l-E,I=h-q,i=(C?A:-A)/L(a*a+I*I),n=i*I,d=-i*a,u=l+n,s=h+d,f=E+n,c=q+d,F=(u+f)/2,t=(s+c)/2,m=f-u,y=c-s,R=m*m+y*y,T=v-A,P=u*c-f*s,O=(y<0?-1:1)*L(on(0,T*T*R-P*P)),S=(P*y-m*O)/R,z=(-P*m-y*O)/R,w=(P*y+m*O)/R,p=(-P*m+y*O)/R,x=S-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(S=w,z=p),{cx:S,cy:z,x01:-n,y01:-d,x11:S*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=gn,E=B(0),q=null,v=yn,A=dn,C=mn,a=null,I=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=I()),s<u&&(d=s,s=u,u=d),!(s>g))a.moveTo(0,0);else if(F>tn-g)a.moveTo(s*H(f),s*j(f)),a.arc(0,0,s,f,c,!t),u>g&&(a.moveTo(u*H(c),u*j(c)),a.arc(0,0,u,c,f,t));else{var m=f,y=c,R=f,T=c,P=F,O=F,S=C.apply(this,arguments)/2,z=S>g&&(q?+q.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(z>g){var G=sn(z/u*j(S)),M=sn(z/s*j(S));(P-=G*2)>g?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(O-=M*2)>g?(M*=t?1:-1,m+=M,y-=M):(O=0,m=y=(f+c)/2)}var J=s*H(m),K=s*j(m),N=u*H(T),Q=u*j(T);if(w>g){var U=s*H(y),V=s*j(y),X=u*H(R),Y=u*j(R),D;if(F<an)if(D=pn(J,K,X,Y,U,V,N,Q)){var Z=J-D[0],$=K-D[1],b=U-D[0],k=V-D[1],nn=1/j(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(D[0]*D[0]+D[1]*D[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}O>g?x>g?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,y,!t)):a.moveTo(J,K),!(u>g)||!(P>g)?a.lineTo(N,Q):p>g?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,j(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:B(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:B(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-wbwCbWuQ.js";function cn(l){return l.innerRadius}function gn(l){return l.outerRadius}function yn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,A,C,a){var I=E-l,i=q-h,n=C-v,d=a-A,u=d*I-n*i;if(!(u*u<g))return u=(n*(h-A)-d*(l-v))/u,[l+u*I,h+u*i]}function W(l,h,E,q,v,A,C){var a=l-E,I=h-q,i=(C?A:-A)/L(a*a+I*I),n=i*I,d=-i*a,u=l+n,s=h+d,f=E+n,c=q+d,F=(u+f)/2,t=(s+c)/2,m=f-u,y=c-s,R=m*m+y*y,T=v-A,P=u*c-f*s,O=(y<0?-1:1)*L(on(0,T*T*R-P*P)),S=(P*y-m*O)/R,z=(-P*m-y*O)/R,w=(P*y+m*O)/R,p=(-P*m+y*O)/R,x=S-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(S=w,z=p),{cx:S,cy:z,x01:-n,y01:-d,x11:S*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=gn,E=B(0),q=null,v=yn,A=dn,C=mn,a=null,I=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=I()),s<u&&(d=s,s=u,u=d),!(s>g))a.moveTo(0,0);else if(F>tn-g)a.moveTo(s*H(f),s*j(f)),a.arc(0,0,s,f,c,!t),u>g&&(a.moveTo(u*H(c),u*j(c)),a.arc(0,0,u,c,f,t));else{var m=f,y=c,R=f,T=c,P=F,O=F,S=C.apply(this,arguments)/2,z=S>g&&(q?+q.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(z>g){var G=sn(z/u*j(S)),M=sn(z/s*j(S));(P-=G*2)>g?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(O-=M*2)>g?(M*=t?1:-1,m+=M,y-=M):(O=0,m=y=(f+c)/2)}var J=s*H(m),K=s*j(m),N=u*H(T),Q=u*j(T);if(w>g){var U=s*H(y),V=s*j(y),X=u*H(R),Y=u*j(R),D;if(F<an)if(D=pn(J,K,X,Y,U,V,N,Q)){var Z=J-D[0],$=K-D[1],b=U-D[0],k=V-D[1],nn=1/j(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(D[0]*D[0]+D[1]*D[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}O>g?x>g?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,y,!t)):a.moveTo(J,K),!(u>g)||!(P>g)?a.lineTo(N,Q):p>g?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,j(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:B(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:B(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};