@aiderdesk/aiderdesk 0.76.0 → 0.78.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 (106) hide show
  1. package/out/cli.js +124 -17
  2. package/out/renderer/assets/{AgentSettings-Dc8h1zSI.js → AgentSettings-mSGpRs0A.js} +1228 -4469
  3. package/out/renderer/assets/{InfoIcon-BuABw5oZ.js → InfoIcon-Dllba1sv.js} +1 -1
  4. package/out/renderer/assets/{Onboarding-lX23sGcW.js → Onboarding-D_AT4vxY.js} +4 -4
  5. package/out/renderer/assets/{ProviderHeader-s7JSikLR.js → ProviderHeader-DAchpkUt.js} +8 -20
  6. package/out/renderer/assets/{SettingsPage-CcsH6kmE.js → SettingsPage-DPaPSR-0.js} +5649 -299
  7. package/out/renderer/assets/{UsageDashboard-oAQNYvYh.js → UsageDashboard-CfP-txzz.js} +3 -3
  8. package/out/renderer/assets/abnfDiagram-N423BO3Z-tqPb0OUs.js +118 -0
  9. package/out/renderer/assets/{arc-BiaIwS79.js → arc-lUzj6CoE.js} +1 -1
  10. package/out/renderer/assets/{architectureDiagram-3BPJPVTR-d7fu6X13.js → architectureDiagram-T3A2C74G-CuNUo8J6.js} +242 -133
  11. package/out/renderer/assets/{blockDiagram-GPEHLZMM-CWD8GVpw.js → blockDiagram-VBNYF7ZC-CIiOkZ_D.js} +76 -77
  12. package/out/renderer/assets/{c4Diagram-AAUBKEIU-b5nYOm14.js → c4Diagram-5PPSVZJV-DcgBNVnI.js} +2 -2
  13. package/out/renderer/assets/{channel-B99g0IUF.js → channel-PMBABQAa.js} +1 -1
  14. package/out/renderer/assets/{chunk-ND2GUHAM-BkVCmcvx.js → chunk-2GRJ4B5K-CJI-utiZ.js} +4 -4
  15. package/out/renderer/assets/{chunk-QZHKN3VN-DwLbWeqf.js → chunk-2Q5K7J3B-D8LOcAuY.js} +1 -1
  16. package/out/renderer/assets/{chunk-AQP2D5EJ-m8ArTZfD.js → chunk-5RXB4S5H-dp0xqMbI.js} +67 -32
  17. package/out/renderer/assets/{chunk-FMBD7UC4-yWO_9Kky.js → chunk-5VM5RSS4-D731WvT8.js} +1 -1
  18. package/out/renderer/assets/chunk-6Q2QTUOP-BjzdFhNB.js +860 -0
  19. package/out/renderer/assets/{chunk-727SXJPM-CVxcBF7D.js → chunk-GF5L2VYU-Ct3zh1DW.js} +18 -8
  20. package/out/renderer/assets/{chunk-4BX2VUAB-4Soxfj2i.js → chunk-JWPE2WC7-OPg0X7jU.js} +1 -1
  21. package/out/renderer/assets/{chunk-2J33WTMH-DmrXuNY-.js → chunk-KBJHAD2P-qbM4OnIO.js} +1 -1
  22. package/out/renderer/assets/{dagre-BM42HDAG-D_Val_ih.js → chunk-RYQCIY6F-DQI4Jds6.js} +85 -316
  23. package/out/renderer/assets/{chunk-55IACEB6-BtS727h4.js → chunk-XXDRQBXY-D_LC4QkV.js} +1 -1
  24. package/out/renderer/assets/{classDiagram-4FO5ZUOK-B3t9RWJZ.js → classDiagram-JCYQIIEL-D4e_9tkA.js} +6 -6
  25. package/out/renderer/assets/{classDiagram-v2-Q7XG4LA2-B3t9RWJZ.js → classDiagram-v2-OCEON4UE-D4e_9tkA.js} +6 -6
  26. package/out/renderer/assets/{cose-bilkent-S5V4N54A-W70GNPEp.js → cose-bilkent-JH36ORCC-tRlBuEjd.js} +2 -2
  27. package/out/renderer/assets/{wardley-L42UT6IY-Dnx4ZTc4.js → cynefin-VYW2F7L2-BiEI2vQb.js} +1527 -120
  28. package/out/renderer/assets/cynefinDiagram-MW4NZA55-DBSV1HcE.js +453 -0
  29. package/out/renderer/assets/{cytoscape.esm-BNSvh83I.js → cytoscape.esm-Bx_1tVW-.js} +160 -67
  30. package/out/renderer/assets/dagre-VZM6K2ZE-DRrMrSSw.js +522 -0
  31. package/out/renderer/assets/diagram-7IWD3JNH-CreTV9nH.js +488 -0
  32. package/out/renderer/assets/{diagram-KO2AKTUF-CGi0HZww.js → diagram-B4RE2ZJO-3tlgxoIb.js} +3 -3
  33. package/out/renderer/assets/{diagram-LMA3HP47-bdoVxL2p.js → diagram-LBJQPF4R-BFO2qTLJ.js} +3 -3
  34. package/out/renderer/assets/{diagram-OG6HWLK6-2K829auL.js → diagram-Q27KOJAE-BDgXUH9Q.js} +30 -24
  35. package/out/renderer/assets/{diagram-2AECGRRQ-Z7UeOtJN.js → diagram-UB23O5K3-Qw-ipaCG.js} +18 -8
  36. package/out/renderer/assets/ebnfDiagram-BXEA7PRR-izS1zYs0.js +138 -0
  37. package/out/renderer/assets/{erDiagram-TEJ5UH35-D4sO1GH8.js → erDiagram-JOGREHBK-ld9lNh2F.js} +88 -77
  38. package/out/renderer/assets/{flowDiagram-I6XJVG4X-DQNz4Jg_.js → flowDiagram-UKHOOZJN-g11KS_zg.js} +112 -96
  39. package/out/renderer/assets/{ganttDiagram-6RSMTGT7-B3dUFX1p.js → ganttDiagram-PKOTCBZU-CMsbJWqv.js} +31 -19
  40. package/out/renderer/assets/{gitGraphDiagram-PVQCEYII-B95Lrq_7.js → gitGraphDiagram-DS77QQ5N-CKiYKjBJ.js} +4 -4
  41. package/out/renderer/assets/{graph-7kCtdoo_.js → graph--1WSNErU.js} +10 -10
  42. package/out/renderer/assets/{index-58fbbmhI.js → index-BJGP-Ed0.js} +1 -1
  43. package/out/renderer/assets/{index-Bihcg0ql.js → index-BSQTFZZV.js} +1 -1
  44. package/out/renderer/assets/{index-GRVDmgjb.js → index-BSRjTKaQ.js} +1 -1
  45. package/out/renderer/assets/{index-CNgsMipO.js → index-BahRAP01.js} +7200 -3741
  46. package/out/renderer/assets/{index-BoogYopJ.js → index-BbYkC4ZX.js} +1 -1
  47. package/out/renderer/assets/{index-BHaWBJe9.js → index-BktqS5iT.js} +1 -1
  48. package/out/renderer/assets/{index-BnFS7uhp.js → index-DJfxm3SJ.js} +3 -3
  49. package/out/renderer/assets/{index-DcD881Q1.css → index-DVEVSdXO.css} +21 -0
  50. package/out/renderer/assets/{index-B2TL7Kll.js → index-DqZ8FyZG.js} +1 -1
  51. package/out/renderer/assets/{index-CRfveI6m.js → index-r15oFU5X.js} +1 -1
  52. package/out/renderer/assets/{index-pvhejocY.js → index-xC4jIIdf.js} +1 -1
  53. package/out/renderer/assets/{infoDiagram-5YYISTIA-C0OH2to7.js → infoDiagram-6WML65LV-CZoJK8b2.js} +3 -3
  54. package/out/renderer/assets/{ishikawaDiagram-YF4QCWOH-DsgR-cKp.js → ishikawaDiagram-WSZJBQD7-BrUuSNZ-.js} +1 -1
  55. package/out/renderer/assets/{journeyDiagram-JHISSGLW-Bg6okgzG.js → journeyDiagram-NVQOT4AX-w91U6vB5.js} +4 -4
  56. package/out/renderer/assets/{jsx-dev-runtime-DLJNe6VM.js → jsx-dev-runtime-Bu2_G2cv.js} +1 -1
  57. package/out/renderer/assets/{kanban-definition-UN3LZRKU-1UvLCrWk.js → kanban-definition-27J2QSJJ-DVuGbAnS.js} +2 -2
  58. package/out/renderer/assets/{katex-Co8xHYNH.js → katex-oVG3DVWa.js} +4039 -4063
  59. package/out/renderer/assets/{layout-9w0fH2nL.js → layout-BA4uCGdL.js} +36 -320
  60. package/out/renderer/assets/{linear-WTE7GZY2.js → linear-CWQmShZV.js} +1 -1
  61. package/out/renderer/assets/map-DSwlVIuN.js +299 -0
  62. package/out/renderer/assets/{mindmap-definition-RKZ34NQL-BlxjYw-a.js → mindmap-definition-FAOFIHXS-CbswsknG.js} +3 -3
  63. package/out/renderer/assets/pegDiagram-VL7TDLO6-CCqeWB6l.js +126 -0
  64. package/out/renderer/assets/{pieDiagram-4H26LBE5-C4jZuzAH.js → pieDiagram-7S7Q4E2Y-Chd5qh8F.js} +89 -19
  65. package/out/renderer/assets/pierre-dark-BL-l9r39.js +4 -0
  66. package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-BBjGuJQU.js +4 -0
  67. package/out/renderer/assets/pierre-dark-soft-B6TBhICr.js +4 -0
  68. package/out/renderer/assets/pierre-dark-tritanopia-f-j_EX9A.js +4 -0
  69. package/out/renderer/assets/pierre-dark-vibrant-yElMGqZN.js +4 -0
  70. package/out/renderer/assets/pierre-light-BUzWTcjO.js +4 -0
  71. package/out/renderer/assets/pierre-light-protanopia-deuteranopia-DlvVSCaI.js +4 -0
  72. package/out/renderer/assets/pierre-light-soft-CCMU-Zh0.js +4 -0
  73. package/out/renderer/assets/pierre-light-tritanopia-v4xacE1C.js +4 -0
  74. package/out/renderer/assets/pierre-light-vibrant-BRUbQnMc.js +4 -0
  75. package/out/renderer/assets/{quadrantDiagram-W4KKPZXB-BLG4PrcM.js → quadrantDiagram-CIZ2JOQS-CzmUVvXi.js} +8 -9
  76. package/out/renderer/assets/railroadDiagram-AXF67PYL-CXY83yzR.js +92 -0
  77. package/out/renderer/assets/{requirementDiagram-4Y6WPE33-CTTFFDvR.js → requirementDiagram-LRYGKXZP-DToxgkKr.js} +3 -3
  78. package/out/renderer/assets/{sankeyDiagram-5OEKKPKP-CjDlOfXf.js → sankeyDiagram-W5VNT64P-CRs67mfK.js} +1 -1
  79. package/out/renderer/assets/{sequenceDiagram-3UESZ5HK-6PJo_0SQ.js → sequenceDiagram-SI44F4Z6-CzmgqSt2.js} +11 -11
  80. package/out/renderer/assets/sizeCapture-X5ZJPWSS-mheyKWG9.js +62 -0
  81. package/out/renderer/assets/{stateDiagram-AJRCARHV-Cnhm9mmx.js → stateDiagram-OKZ733FA-DGyuxXU_.js} +8 -6
  82. package/out/renderer/assets/{stateDiagram-v2-BHNVJYJU-BxKTEg-3.js → stateDiagram-v2-UEYNNEHI-TldVLbtJ.js} +5 -4
  83. package/out/renderer/assets/swimlanes-SLNWSIFB-B3lFy2HE.js +8557 -0
  84. package/out/renderer/assets/swimlanesDiagram-ULZ7WXOC-BxN-HDA3.js +20 -0
  85. package/out/renderer/assets/{time-YGhgEMYh.js → time-DcFzC-ob.js} +1 -1
  86. package/out/renderer/assets/{timeline-definition-PNZ67QCA-ooi5Tti4.js → timeline-definition-Z64GVDOM-DQ7vCcJR.js} +2 -2
  87. package/out/renderer/assets/{vennDiagram-CIIHVFJN-B_kwCHhU.js → vennDiagram-T6HMQDX7-MrgLWWY3.js} +32 -3
  88. package/out/renderer/assets/{wardleyDiagram-YWT4CUSO-cqZcXF7R.js → wardleyDiagram-T6FBY63Y-BCA6xyJ2.js} +3 -3
  89. package/out/renderer/assets/{worker-BdXuKH1Q.js → worker-CdcPcIJG.js} +322 -102
  90. package/out/renderer/assets/{xychartDiagram-2RQKCTM6-BBUpFNY4.js → xychartDiagram-ELKLHX3M-BZmPte5b.js} +125 -57
  91. package/out/renderer/index.html +2 -2
  92. package/out/renderer/sw.js +4 -0
  93. package/out/resources/connector/connector.py +3 -1
  94. package/out/resources/prompts/init-project.hbs +16 -42
  95. package/out/resources/prompts/system-prompt.hbs +25 -60
  96. package/out/resources/prompts/workflow.hbs +17 -52
  97. package/out/resources/skills/extension-creator/SKILL.md +1 -0
  98. package/out/resources/skills/extension-creator/references/event-types.md +13 -1
  99. package/out/resources/skills/extension-creator/references/extension-interface.md +3 -0
  100. package/out/runner.js +5735 -3379
  101. package/package.json +5 -4
  102. package/out/renderer/assets/diagram-5GNKFQAL-DY9Yifty.js +0 -169
  103. package/out/renderer/assets/pierre-dark-C-Drv5KU.js +0 -4
  104. package/out/renderer/assets/pierre-dark-soft-Cd74uQaL.js +0 -4
  105. package/out/renderer/assets/pierre-light-CfQnmt6J.js +0 -4
  106. package/out/renderer/assets/pierre-light-soft-DMVdU74b.js +0 -4
@@ -1,7 +1,7 @@
1
- import { bW as getDefaultExportFromCjs, _ as __name, an as selectSvgElement, aS as setupGraphViewbox, O as log, K as setAccTitle, J as getAccTitle, a5 as setDiagramTitle, a6 as getDiagramTitle, H as getAccDescription, C as setAccDescription, ac as clear, ak as cleanAndMerge, ai as getConfig, al as defaultConfig_default, L as getConfig2, bF as createText, bX as getIconSVG, W as sanitizeText, N as select, aa as getEdgeId, bY as registerIconPacks, bZ as unknownIcon } from "./index-CNgsMipO.js";
2
- import { p as populateCommonDb } from "./chunk-4BX2VUAB-4Soxfj2i.js";
3
- import { p as parse } from "./wardley-L42UT6IY-Dnx4ZTc4.js";
4
- import { c as cytoscape$1 } from "./cytoscape.esm-BNSvh83I.js";
1
+ import { p as populateCommonDb } from "./chunk-JWPE2WC7-OPg0X7jU.js";
2
+ import { b_ as getDefaultExportFromCjs, _ as __name, ah as selectSvgElement, aQ as setupGraphViewbox, O as log, K as setAccTitle, J as getAccTitle, a3 as setDiagramTitle, a4 as getDiagramTitle, H as getAccDescription, C as setAccDescription, a5 as clear, ae as cleanAndMerge, ac as getConfig, af as defaultConfig_default, L as getConfig2, bT as createText, aX as getIconSVG, W as sanitizeText, N as select, a6 as getEdgeId, aY as registerIconPacks, b$ as unknownIcon } from "./index-BahRAP01.js";
3
+ import { p as parse } from "./cynefin-VYW2F7L2-BiEI2vQb.js";
4
+ import { c as cytoscape$1 } from "./cytoscape.esm-Bx_1tVW-.js";
5
5
  var cytoscapeFcose$1 = { exports: {} };
6
6
  var coseBase$1 = { exports: {} };
7
7
  var layoutBase$1 = { exports: {} };
@@ -7671,6 +7671,10 @@ var isArchitectureJunction = /* @__PURE__ */ __name(function(x) {
7671
7671
  const temp = x;
7672
7672
  return temp.type === "junction";
7673
7673
  }, "isArchitectureJunction");
7674
+ var architectureGroupAlignmentKey = /* @__PURE__ */ __name((groupA, groupB) => {
7675
+ const [lowerGroupId, upperGroupId] = [groupA, groupB].sort();
7676
+ return `${JSON.stringify(lowerGroupId)}-${JSON.stringify(upperGroupId)}`;
7677
+ }, "architectureGroupAlignmentKey");
7674
7678
  var edgeData = /* @__PURE__ */ __name((edge) => {
7675
7679
  return edge.data();
7676
7680
  }, "edgeData");
@@ -7680,11 +7684,12 @@ var nodeData = /* @__PURE__ */ __name((node) => {
7680
7684
  var DEFAULT_ARCHITECTURE_CONFIG = defaultConfig_default.architecture;
7681
7685
  var ArchitectureDB = class {
7682
7686
  constructor() {
7683
- this.nodes = {};
7684
- this.groups = {};
7687
+ this.nodes = /* @__PURE__ */ new Map();
7688
+ this.groups = /* @__PURE__ */ new Map();
7685
7689
  this.edges = [];
7686
- this.registeredIds = {};
7687
- this.elements = {};
7690
+ this.layoutHints = [];
7691
+ this.registeredIds = /* @__PURE__ */ new Map();
7692
+ this.elements = /* @__PURE__ */ new Map();
7688
7693
  this.diagramId = "";
7689
7694
  this.setAccTitle = setAccTitle;
7690
7695
  this.getAccTitle = getAccTitle;
@@ -7704,12 +7709,13 @@ var ArchitectureDB = class {
7704
7709
  return this.diagramId;
7705
7710
  }
7706
7711
  clear() {
7707
- this.nodes = {};
7708
- this.groups = {};
7712
+ this.nodes = /* @__PURE__ */ new Map();
7713
+ this.groups = /* @__PURE__ */ new Map();
7709
7714
  this.edges = [];
7710
- this.registeredIds = {};
7715
+ this.layoutHints = [];
7716
+ this.registeredIds = /* @__PURE__ */ new Map();
7711
7717
  this.dataStructures = void 0;
7712
- this.elements = {};
7718
+ this.elements = /* @__PURE__ */ new Map();
7713
7719
  this.diagramId = "";
7714
7720
  clear();
7715
7721
  }
@@ -7720,26 +7726,26 @@ var ArchitectureDB = class {
7720
7726
  title,
7721
7727
  iconText
7722
7728
  }) {
7723
- if (this.registeredIds[id] !== void 0) {
7729
+ if (this.registeredIds.has(id)) {
7724
7730
  throw new Error(
7725
- `The service id [${id}] is already in use by another ${this.registeredIds[id]}`
7731
+ `The service id [${id}] is already in use by another ${this.registeredIds.get(id)}`
7726
7732
  );
7727
7733
  }
7728
7734
  if (parent !== void 0) {
7729
7735
  if (id === parent) {
7730
7736
  throw new Error(`The service [${id}] cannot be placed within itself`);
7731
7737
  }
7732
- if (this.registeredIds[parent] === void 0) {
7738
+ if (!this.registeredIds.has(parent)) {
7733
7739
  throw new Error(
7734
7740
  `The service [${id}]'s parent does not exist. Please make sure the parent is created before this service`
7735
7741
  );
7736
7742
  }
7737
- if (this.registeredIds[parent] === "node") {
7743
+ if (this.registeredIds.get(parent) === "node") {
7738
7744
  throw new Error(`The service [${id}]'s parent is not a group`);
7739
7745
  }
7740
7746
  }
7741
- this.registeredIds[id] = "node";
7742
- this.nodes[id] = {
7747
+ this.registeredIds.set(id, "node");
7748
+ this.nodes.set(id, {
7743
7749
  id,
7744
7750
  type: "service",
7745
7751
  icon,
@@ -7747,76 +7753,76 @@ var ArchitectureDB = class {
7747
7753
  title,
7748
7754
  edges: [],
7749
7755
  in: parent
7750
- };
7756
+ });
7751
7757
  }
7752
7758
  getServices() {
7753
- return Object.values(this.nodes).filter(isArchitectureService);
7759
+ return [...this.nodes.values()].filter(isArchitectureService);
7754
7760
  }
7755
7761
  addJunction({ id, in: parent }) {
7756
- if (this.registeredIds[id] !== void 0) {
7762
+ if (this.registeredIds.has(id)) {
7757
7763
  throw new Error(
7758
- `The junction id [${id}] is already in use by another ${this.registeredIds[id]}`
7764
+ `The junction id [${id}] is already in use by another ${this.registeredIds.get(id)}`
7759
7765
  );
7760
7766
  }
7761
7767
  if (parent !== void 0) {
7762
7768
  if (id === parent) {
7763
7769
  throw new Error(`The junction [${id}] cannot be placed within itself`);
7764
7770
  }
7765
- if (this.registeredIds[parent] === void 0) {
7771
+ if (!this.registeredIds.has(parent)) {
7766
7772
  throw new Error(
7767
7773
  `The junction [${id}]'s parent does not exist. Please make sure the parent is created before this junction`
7768
7774
  );
7769
7775
  }
7770
- if (this.registeredIds[parent] === "node") {
7776
+ if (this.registeredIds.get(parent) === "node") {
7771
7777
  throw new Error(`The junction [${id}]'s parent is not a group`);
7772
7778
  }
7773
7779
  }
7774
- this.registeredIds[id] = "node";
7775
- this.nodes[id] = {
7780
+ this.registeredIds.set(id, "node");
7781
+ this.nodes.set(id, {
7776
7782
  id,
7777
7783
  type: "junction",
7778
7784
  edges: [],
7779
7785
  in: parent
7780
- };
7786
+ });
7781
7787
  }
7782
7788
  getJunctions() {
7783
- return Object.values(this.nodes).filter(isArchitectureJunction);
7789
+ return [...this.nodes.values()].filter(isArchitectureJunction);
7784
7790
  }
7785
7791
  getNodes() {
7786
- return Object.values(this.nodes);
7792
+ return [...this.nodes.values()];
7787
7793
  }
7788
7794
  getNode(id) {
7789
- return this.nodes[id] ?? null;
7795
+ return this.nodes.get(id) ?? null;
7790
7796
  }
7791
7797
  addGroup({ id, icon, in: parent, title }) {
7792
- if (this.registeredIds?.[id] !== void 0) {
7798
+ if (this.registeredIds.has(id)) {
7793
7799
  throw new Error(
7794
- `The group id [${id}] is already in use by another ${this.registeredIds[id]}`
7800
+ `The group id [${id}] is already in use by another ${this.registeredIds.get(id)}`
7795
7801
  );
7796
7802
  }
7797
7803
  if (parent !== void 0) {
7798
7804
  if (id === parent) {
7799
7805
  throw new Error(`The group [${id}] cannot be placed within itself`);
7800
7806
  }
7801
- if (this.registeredIds?.[parent] === void 0) {
7807
+ if (!this.registeredIds.has(parent)) {
7802
7808
  throw new Error(
7803
7809
  `The group [${id}]'s parent does not exist. Please make sure the parent is created before this group`
7804
7810
  );
7805
7811
  }
7806
- if (this.registeredIds?.[parent] === "node") {
7812
+ if (this.registeredIds.get(parent) === "node") {
7807
7813
  throw new Error(`The group [${id}]'s parent is not a group`);
7808
7814
  }
7809
7815
  }
7810
- this.registeredIds[id] = "group";
7811
- this.groups[id] = {
7816
+ this.registeredIds.set(id, "group");
7817
+ this.groups.set(id, {
7812
7818
  id,
7813
7819
  icon,
7814
7820
  title,
7815
7821
  in: parent
7816
- };
7822
+ });
7817
7823
  }
7818
7824
  getGroups() {
7819
- return Object.values(this.groups);
7825
+ return [...this.groups.values()];
7820
7826
  }
7821
7827
  addEdge({
7822
7828
  lhsId,
@@ -7839,18 +7845,18 @@ var ArchitectureDB = class {
7839
7845
  `Invalid direction given for right hand side of edge ${lhsId}--${rhsId}. Expected (L,R,T,B) got ${String(rhsDir)}`
7840
7846
  );
7841
7847
  }
7842
- if (this.nodes[lhsId] === void 0 && this.groups[lhsId] === void 0) {
7848
+ if (!this.nodes.has(lhsId) && !this.groups.has(lhsId)) {
7843
7849
  throw new Error(
7844
7850
  `The left-hand id [${lhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
7845
7851
  );
7846
7852
  }
7847
- if (this.nodes[rhsId] === void 0 && this.groups[rhsId] === void 0) {
7853
+ if (!this.nodes.has(rhsId) && !this.groups.has(rhsId)) {
7848
7854
  throw new Error(
7849
7855
  `The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
7850
7856
  );
7851
7857
  }
7852
- const lhsGroupId = this.nodes[lhsId].in;
7853
- const rhsGroupId = this.nodes[rhsId].in;
7858
+ const lhsGroupId = this.nodes.get(lhsId).in;
7859
+ const rhsGroupId = this.nodes.get(rhsId).in;
7854
7860
  if (lhsGroup && lhsGroupId && rhsGroupId && lhsGroupId == rhsGroupId) {
7855
7861
  throw new Error(
7856
7862
  `The left-hand id [${lhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups.`
@@ -7873,14 +7879,39 @@ var ArchitectureDB = class {
7873
7879
  title
7874
7880
  };
7875
7881
  this.edges.push(edge);
7876
- if (this.nodes[lhsId] && this.nodes[rhsId]) {
7877
- this.nodes[lhsId].edges.push(this.edges[this.edges.length - 1]);
7878
- this.nodes[rhsId].edges.push(this.edges[this.edges.length - 1]);
7882
+ const lhsNode = this.nodes.get(lhsId);
7883
+ const rhsNode = this.nodes.get(rhsId);
7884
+ if (lhsNode && rhsNode) {
7885
+ lhsNode.edges.push(this.edges[this.edges.length - 1]);
7886
+ rhsNode.edges.push(this.edges[this.edges.length - 1]);
7879
7887
  }
7880
7888
  }
7881
7889
  getEdges() {
7882
7890
  return this.edges;
7883
7891
  }
7892
+ addLayoutHint(hint) {
7893
+ if (hint.members.length < 2) {
7894
+ throw new Error(
7895
+ `An align directive requires at least two members; got ${hint.members.length}`
7896
+ );
7897
+ }
7898
+ const seen = /* @__PURE__ */ new Set();
7899
+ hint.members.forEach((id) => {
7900
+ if (this.registeredIds.get(id) !== "node") {
7901
+ throw new Error(
7902
+ `align ${hint.direction} references [${id}], which is not a service or junction`
7903
+ );
7904
+ }
7905
+ if (seen.has(id)) {
7906
+ throw new Error(`align ${hint.direction} lists [${id}] more than once`);
7907
+ }
7908
+ seen.add(id);
7909
+ });
7910
+ this.layoutHints.push(hint);
7911
+ }
7912
+ getLayoutHints() {
7913
+ return this.layoutHints;
7914
+ }
7884
7915
  /**
7885
7916
  * Returns the current diagram's adjacency list, spatial map, & group alignments.
7886
7917
  * If they have not been created, run the algorithms to generate them.
@@ -7888,57 +7919,59 @@ var ArchitectureDB = class {
7888
7919
  */
7889
7920
  getDataStructures() {
7890
7921
  if (this.dataStructures === void 0) {
7891
- const groupAlignments = {};
7892
- const adjList = Object.entries(this.nodes).reduce((prevOuter, [id, service]) => {
7893
- prevOuter[id] = service.edges.reduce((prevInner, edge) => {
7922
+ const groupAlignments = /* @__PURE__ */ new Map();
7923
+ const adjList = /* @__PURE__ */ new Map();
7924
+ for (const [id, service] of this.nodes.entries()) {
7925
+ const directionMap = /* @__PURE__ */ new Map();
7926
+ for (const edge of service.edges) {
7894
7927
  const lhsGroupId = this.getNode(edge.lhsId)?.in;
7895
7928
  const rhsGroupId = this.getNode(edge.rhsId)?.in;
7896
7929
  if (lhsGroupId && rhsGroupId && lhsGroupId !== rhsGroupId) {
7897
7930
  const alignment = getArchitectureDirectionAlignment(edge.lhsDir, edge.rhsDir);
7898
7931
  if (alignment !== "bend") {
7899
- groupAlignments[lhsGroupId] ??= {};
7900
- groupAlignments[lhsGroupId][rhsGroupId] = alignment;
7901
- groupAlignments[rhsGroupId] ??= {};
7902
- groupAlignments[rhsGroupId][lhsGroupId] = alignment;
7932
+ groupAlignments.set(architectureGroupAlignmentKey(lhsGroupId, rhsGroupId), alignment);
7903
7933
  }
7904
7934
  }
7905
7935
  if (edge.lhsId === id) {
7906
7936
  const pair = getArchitectureDirectionPair(edge.lhsDir, edge.rhsDir);
7907
7937
  if (pair) {
7908
- prevInner[pair] = edge.rhsId;
7938
+ directionMap.set(pair, edge.rhsId);
7909
7939
  }
7910
7940
  } else {
7911
7941
  const pair = getArchitectureDirectionPair(edge.rhsDir, edge.lhsDir);
7912
7942
  if (pair) {
7913
- prevInner[pair] = edge.lhsId;
7943
+ directionMap.set(pair, edge.lhsId);
7914
7944
  }
7915
7945
  }
7916
- return prevInner;
7917
- }, {});
7918
- return prevOuter;
7919
- }, {});
7920
- const firstId = Object.keys(adjList)[0];
7921
- const visited = { [firstId]: 1 };
7922
- const notVisited = Object.keys(adjList).reduce(
7923
- (prev, id) => id === firstId ? prev : { ...prev, [id]: 1 },
7924
- {}
7925
- );
7946
+ }
7947
+ adjList.set(id, directionMap);
7948
+ }
7949
+ const visited = /* @__PURE__ */ new Set();
7950
+ const notVisited = new Set(adjList.keys());
7926
7951
  const BFS = /* @__PURE__ */ __name((startingId) => {
7927
- const spatialMap = { [startingId]: [0, 0] };
7952
+ const spatialMap = /* @__PURE__ */ new Map([[startingId, [0, 0]]]);
7928
7953
  const queue = [startingId];
7929
7954
  while (queue.length > 0) {
7930
7955
  const id = queue.shift();
7931
7956
  if (id) {
7932
- visited[id] = 1;
7933
- delete notVisited[id];
7934
- const adj = adjList[id];
7935
- const [posX, posY] = spatialMap[id];
7936
- Object.entries(adj).forEach(([dir, rhsId]) => {
7937
- if (!visited[rhsId]) {
7938
- spatialMap[rhsId] = shiftPositionByArchitectureDirectionPair(
7939
- [posX, posY],
7940
- dir
7941
- );
7957
+ visited.add(id);
7958
+ notVisited.delete(id);
7959
+ const adj = adjList.get(id);
7960
+ if (!adj) {
7961
+ throw new Error(
7962
+ `BFS error: adjacency list for id ${id} not found. Please report this as a bug.`
7963
+ );
7964
+ }
7965
+ const pos = spatialMap.get(id);
7966
+ if (!pos) {
7967
+ throw new Error(
7968
+ `BFS error: position for id ${id} not found in spatial map. Please report this as a bug.`
7969
+ );
7970
+ }
7971
+ const [posX, posY] = pos;
7972
+ adj.forEach((rhsId, dir) => {
7973
+ if (!visited.has(rhsId)) {
7974
+ spatialMap.set(rhsId, shiftPositionByArchitectureDirectionPair([posX, posY], dir));
7942
7975
  queue.push(rhsId);
7943
7976
  }
7944
7977
  });
@@ -7946,9 +7979,10 @@ var ArchitectureDB = class {
7946
7979
  }
7947
7980
  return spatialMap;
7948
7981
  }, "BFS");
7949
- const spatialMaps = [BFS(firstId)];
7950
- while (Object.keys(notVisited).length > 0) {
7951
- spatialMaps.push(BFS(Object.keys(notVisited)[0]));
7982
+ const spatialMaps = [];
7983
+ while (notVisited.size > 0) {
7984
+ const firstId = notVisited.values().next().value;
7985
+ spatialMaps.push(BFS(firstId));
7952
7986
  }
7953
7987
  this.dataStructures = {
7954
7988
  adjList,
@@ -7959,10 +7993,10 @@ var ArchitectureDB = class {
7959
7993
  return this.dataStructures;
7960
7994
  }
7961
7995
  setElementForId(id, element) {
7962
- this.elements[id] = element;
7996
+ this.elements.set(id, element);
7963
7997
  }
7964
7998
  getElementById(id) {
7965
- return this.elements[id];
7999
+ return this.elements.get(id);
7966
8000
  }
7967
8001
  getConfig() {
7968
8002
  return cleanAndMerge({
@@ -7980,6 +8014,9 @@ var populateDb = /* @__PURE__ */ __name((ast, db) => {
7980
8014
  ast.services.map((service) => db.addService({ ...service, type: "service" }));
7981
8015
  ast.junctions.map((service) => db.addJunction({ ...service, type: "junction" }));
7982
8016
  ast.edges.map((edge) => db.addEdge(edge));
8017
+ ast.alignments?.map(
8018
+ (alignment) => db.addLayoutHint({ direction: alignment.direction, members: [...alignment.members] })
8019
+ );
7983
8020
  }, "populateDb");
7984
8021
  var parser = {
7985
8022
  parser: {
@@ -8031,6 +8068,26 @@ var getStyles = /* @__PURE__ */ __name((options) => `
8031
8068
  }
8032
8069
  `, "getStyles");
8033
8070
  var architectureStyles_default = getStyles;
8071
+ function withSeededRandom(seed, fn) {
8072
+ if (seed === 0) {
8073
+ return fn();
8074
+ }
8075
+ const original = Math.random;
8076
+ let state = seed >>> 0;
8077
+ Math.random = function() {
8078
+ state = state + 1831565813 >>> 0;
8079
+ let t = state;
8080
+ t = Math.imul(t ^ t >>> 15, t | 1);
8081
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
8082
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
8083
+ };
8084
+ try {
8085
+ return fn();
8086
+ } finally {
8087
+ Math.random = original;
8088
+ }
8089
+ }
8090
+ __name(withSeededRandom, "withSeededRandom");
8034
8091
  var wrapIcon = /* @__PURE__ */ __name((icon) => {
8035
8092
  return `<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/>${icon}</g>`;
8036
8093
  }, "wrapIcon");
@@ -8392,62 +8449,68 @@ function addEdges(edges, cy) {
8392
8449
  });
8393
8450
  }
8394
8451
  __name(addEdges, "addEdges");
8395
- function getAlignments(db, spatialMaps, groupAlignments) {
8396
- const flattenAlignments = /* @__PURE__ */ __name((alignmentObj, alignmentDir) => {
8397
- return Object.entries(alignmentObj).reduce(
8398
- (prev, [dir, alignments2]) => {
8399
- let cnt = 0;
8400
- const arr = Object.entries(alignments2);
8401
- if (arr.length === 1) {
8402
- prev[dir] = arr[0][1];
8403
- return prev;
8404
- }
8405
- for (let i = 0; i < arr.length - 1; i++) {
8406
- for (let j = i + 1; j < arr.length; j++) {
8407
- const [aGroupId, aNodeIds] = arr[i];
8408
- const [bGroupId, bNodeIds] = arr[j];
8409
- const alignment = groupAlignments[aGroupId]?.[bGroupId];
8410
- if (alignment === alignmentDir) {
8411
- prev[dir] ??= [];
8412
- prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds];
8413
- } else if (aGroupId === "default" || bGroupId === "default") {
8414
- prev[dir] ??= [];
8415
- prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds];
8416
- } else {
8417
- const keyA = `${dir}-${cnt++}`;
8418
- prev[keyA] = aNodeIds;
8419
- const keyB = `${dir}-${cnt++}`;
8420
- prev[keyB] = bNodeIds;
8421
- }
8452
+ function getAlignments(db, spatialMaps, groupAlignments, layoutHints = []) {
8453
+ const flattenAlignments = /* @__PURE__ */ __name((alignmentMap, alignmentDir) => {
8454
+ const flattened = /* @__PURE__ */ new Map();
8455
+ for (const [numericDir, alignments2] of alignmentMap.entries()) {
8456
+ const dir = `${numericDir}`;
8457
+ let cnt = 0;
8458
+ const arr = [...alignments2.entries()];
8459
+ if (arr.length === 1) {
8460
+ flattened.set(dir, arr[0][1]);
8461
+ continue;
8462
+ }
8463
+ for (let i = 0; i < arr.length - 1; i++) {
8464
+ for (let j = i + 1; j < arr.length; j++) {
8465
+ const [aGroupId, aNodeIds] = arr[i];
8466
+ const [bGroupId, bNodeIds] = arr[j];
8467
+ const alignment = groupAlignments.get(architectureGroupAlignmentKey(aGroupId, bGroupId));
8468
+ if (alignment === alignmentDir) {
8469
+ flattened.set(dir, [...flattened.get(dir) ?? [], ...aNodeIds, ...bNodeIds]);
8470
+ } else if (aGroupId === "default" || bGroupId === "default") {
8471
+ flattened.set(dir, [...flattened.get(dir) ?? [], ...aNodeIds, ...bNodeIds]);
8472
+ } else {
8473
+ const keyA = `${dir}-${cnt++}`;
8474
+ flattened.set(keyA, aNodeIds);
8475
+ const keyB = `${dir}-${cnt++}`;
8476
+ flattened.set(keyB, bNodeIds);
8422
8477
  }
8423
8478
  }
8424
- return prev;
8425
- },
8426
- {}
8427
- );
8479
+ }
8480
+ }
8481
+ return flattened;
8428
8482
  }, "flattenAlignments");
8429
8483
  const alignments = spatialMaps.map((spatialMap) => {
8430
- const horizontalAlignments = {};
8431
- const verticalAlignments = {};
8432
- Object.entries(spatialMap).forEach(([id, [x, y]]) => {
8484
+ const horizontalAlignments = /* @__PURE__ */ new Map();
8485
+ const verticalAlignments = /* @__PURE__ */ new Map();
8486
+ spatialMap.forEach(([x, y], id) => {
8433
8487
  const nodeGroup = db.getNode(id)?.in ?? "default";
8434
- horizontalAlignments[y] ??= {};
8435
- horizontalAlignments[y][nodeGroup] ??= [];
8436
- horizontalAlignments[y][nodeGroup].push(id);
8437
- verticalAlignments[x] ??= {};
8438
- verticalAlignments[x][nodeGroup] ??= [];
8439
- verticalAlignments[x][nodeGroup].push(id);
8488
+ const horizontalAlignment = horizontalAlignments.get(y) ?? /* @__PURE__ */ new Map();
8489
+ if (!horizontalAlignments.has(y)) {
8490
+ horizontalAlignments.set(y, horizontalAlignment);
8491
+ }
8492
+ const verticalAlignment = verticalAlignments.get(x) ?? /* @__PURE__ */ new Map();
8493
+ if (!verticalAlignments.has(x)) {
8494
+ verticalAlignments.set(x, verticalAlignment);
8495
+ }
8496
+ for (const alignment of [horizontalAlignment, verticalAlignment]) {
8497
+ const nodeList = alignment.get(nodeGroup) ?? [];
8498
+ if (!alignment.has(nodeGroup)) {
8499
+ alignment.set(nodeGroup, nodeList);
8500
+ }
8501
+ nodeList.push(id);
8502
+ }
8440
8503
  });
8441
8504
  return {
8442
- horiz: Object.values(flattenAlignments(horizontalAlignments, "horizontal")).filter(
8505
+ horiz: [...flattenAlignments(horizontalAlignments, "horizontal").values()].filter(
8443
8506
  (arr) => arr.length > 1
8444
8507
  ),
8445
- vert: Object.values(flattenAlignments(verticalAlignments, "vertical")).filter(
8508
+ vert: [...flattenAlignments(verticalAlignments, "vertical").values()].filter(
8446
8509
  (arr) => arr.length > 1
8447
8510
  )
8448
8511
  };
8449
8512
  });
8450
- const [horizontal, vertical] = alignments.reduce(
8513
+ const [horizontalRaw, verticalRaw] = alignments.reduce(
8451
8514
  ([prevHoriz, prevVert], { horiz, vert }) => {
8452
8515
  return [
8453
8516
  [...prevHoriz, ...horiz],
@@ -8456,19 +8519,51 @@ function getAlignments(db, spatialMaps, groupAlignments) {
8456
8519
  },
8457
8520
  [[], []]
8458
8521
  );
8522
+ const declaredMembers = /* @__PURE__ */ new Set();
8523
+ layoutHints.forEach((hint) => hint.members.forEach((m) => declaredMembers.add(m)));
8524
+ const dropOverlapping = /* @__PURE__ */ __name((groups) => groups.filter((group) => !group.some((id) => declaredMembers.has(id))), "dropOverlapping");
8525
+ const horizontal = dropOverlapping(horizontalRaw);
8526
+ const vertical = dropOverlapping(verticalRaw);
8527
+ layoutHints.forEach((hint) => {
8528
+ if (hint.members.length < 2) {
8529
+ return;
8530
+ }
8531
+ if (hint.direction === "row") {
8532
+ horizontal.push([...hint.members]);
8533
+ } else {
8534
+ vertical.push([...hint.members]);
8535
+ }
8536
+ });
8459
8537
  return {
8460
8538
  horizontal,
8461
8539
  vertical
8462
8540
  };
8463
8541
  }
8464
8542
  __name(getAlignments, "getAlignments");
8465
- function getRelativeConstraints(spatialMaps, db) {
8543
+ function getRelativeConstraints(spatialMaps, db, layoutHints = []) {
8466
8544
  const relativeConstraints = [];
8545
+ const iconSize = db.getConfigField("iconSize");
8546
+ const idealMult = db.getConfigField("idealEdgeLengthMultiplier");
8547
+ const hintGap = idealMult * iconSize;
8548
+ const declaredPairs = /* @__PURE__ */ new Set();
8549
+ layoutHints.forEach((hint) => {
8550
+ for (let i = 0; i < hint.members.length - 1; i++) {
8551
+ const a = hint.members[i];
8552
+ const b = hint.members[i + 1];
8553
+ declaredPairs.add(`${a}|${b}`);
8554
+ declaredPairs.add(`${b}|${a}`);
8555
+ if (hint.direction === "row") {
8556
+ relativeConstraints.push({ left: a, right: b, gap: hintGap });
8557
+ } else {
8558
+ relativeConstraints.push({ top: a, bottom: b, gap: hintGap });
8559
+ }
8560
+ }
8561
+ });
8467
8562
  const posToStr = /* @__PURE__ */ __name((pos) => `${pos[0]},${pos[1]}`, "posToStr");
8468
8563
  const strToPos = /* @__PURE__ */ __name((pos) => pos.split(",").map((p) => parseInt(p)), "strToPos");
8469
8564
  spatialMaps.forEach((spatialMap) => {
8470
- const invSpatialMap = Object.fromEntries(
8471
- Object.entries(spatialMap).map(([id, pos]) => [posToStr(pos), id])
8565
+ const invSpatialMap = new Map(
8566
+ [...spatialMap.entries()].map(([key, value]) => [posToStr(value), key])
8472
8567
  );
8473
8568
  const queue = [posToStr([0, 0])];
8474
8569
  const visited = {};
@@ -8482,18 +8577,21 @@ function getRelativeConstraints(spatialMaps, db) {
8482
8577
  const curr = queue.shift();
8483
8578
  if (curr) {
8484
8579
  visited[curr] = 1;
8485
- const currId = invSpatialMap[curr];
8580
+ const currId = invSpatialMap.get(curr);
8486
8581
  if (currId) {
8487
8582
  const currPos = strToPos(curr);
8488
8583
  Object.entries(directions).forEach(([dir, shift]) => {
8489
8584
  const newPos = posToStr([currPos[0] + shift[0], currPos[1] + shift[1]]);
8490
- const newId = invSpatialMap[newPos];
8585
+ const newId = invSpatialMap.get(newPos);
8491
8586
  if (newId && !visited[newPos]) {
8492
8587
  queue.push(newPos);
8588
+ if (declaredPairs.has(`${currId}|${newId}`)) {
8589
+ return;
8590
+ }
8493
8591
  relativeConstraints.push({
8494
8592
  [ArchitectureDirectionName[dir]]: newId,
8495
8593
  [ArchitectureDirectionName[getOppositeArchitectureDirection(dir)]]: currId,
8496
- gap: 1.5 * db.getConfigField("iconSize")
8594
+ gap: idealMult * iconSize
8497
8595
  });
8498
8596
  }
8499
8597
  });
@@ -8589,12 +8687,14 @@ function layoutArchitecture(services, junctions, groups, edges, db, { spatialMap
8589
8687
  addServices(services, cy, db);
8590
8688
  addJunctions(junctions, cy, db);
8591
8689
  addEdges(edges, cy);
8592
- const alignmentConstraint = getAlignments(db, spatialMaps, groupAlignments);
8593
- const relativePlacementConstraint = getRelativeConstraints(spatialMaps, db);
8690
+ const layoutHints = db.getLayoutHints();
8691
+ const alignmentConstraint = getAlignments(db, spatialMaps, groupAlignments, layoutHints);
8692
+ const relativePlacementConstraint = getRelativeConstraints(spatialMaps, db, layoutHints);
8594
8693
  const iconSize = db.getConfigField("iconSize");
8595
8694
  const sameGroupIdealLength = db.getConfigField("idealEdgeLengthMultiplier") * iconSize;
8596
8695
  const crossGroupIdealLength = 0.5 * iconSize;
8597
8696
  const sameGroupElasticity = db.getConfigField("edgeElasticity");
8697
+ const seed = db.getConfigField("seed");
8598
8698
  const layout = cy.layout({
8599
8699
  name: "fcose",
8600
8700
  quality: "proof",
@@ -8673,9 +8773,18 @@ function layoutArchitecture(services, junctions, groups, edges, db, { spatialMap
8673
8773
  }
8674
8774
  }
8675
8775
  cy.endBatch();
8676
- layout.run();
8776
+ withSeededRandom(seed, () => layout.run());
8677
8777
  });
8678
- layout.run();
8778
+ try {
8779
+ withSeededRandom(seed, () => layout.run());
8780
+ } catch (err) {
8781
+ if (err instanceof RangeError && err.message.includes("Invalid array length")) {
8782
+ throw new Error(
8783
+ "Architecture layout failed: a declared `align row|column` directive likely contradicts the edge directions, or two declared alignments overlap on a shared node. Check that the order of members in each `align` chain is consistent with the edges between them, and that no node appears in two `align` directives along the same axis."
8784
+ );
8785
+ }
8786
+ throw err;
8787
+ }
8679
8788
  cy.ready((e) => {
8680
8789
  log.info("Ready", e);
8681
8790
  resolve(cy);