@locus-forge/locus-map 0.2.0 → 0.2.2-dev.20261206.g5e970d2

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 (202) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/README.md +21 -6
  3. package/dist/assets/{abnfDiagram-VCTEODGH-BnTGKKaL.js → abnfDiagram-VCTEODGH-JiCO6vo-.js} +1 -1
  4. package/dist/assets/{ar-SA-G6X2FPQ2-LY3czoz9.js → ar-SA-G6X2FPQ2-BdzEBmp3.js} +1 -1
  5. package/dist/assets/{architectureDiagram-5GKGNRK7-BG9h9KRx.js → architectureDiagram-5GKGNRK7-D7T_vJwe.js} +1 -1
  6. package/dist/assets/{az-AZ-76LH7QW2-Brv6kuM6.js → az-AZ-76LH7QW2-BQ_SoVB7.js} +1 -1
  7. package/dist/assets/{bg-BG-XCXSNQG7-tsQwwvMW.js → bg-BG-XCXSNQG7-DlH1olUf.js} +1 -1
  8. package/dist/assets/{blockDiagram-I7D4REHJ-V9bUuR63.js → blockDiagram-I7D4REHJ-DPz0LEjY.js} +1 -1
  9. package/dist/assets/{bn-BD-2XOGV67Q-0Cou5nNv.js → bn-BD-2XOGV67Q-CFIZU06C.js} +1 -1
  10. package/dist/assets/{c4Diagram-7LVT6UL2-BmCtzbrY.js → c4Diagram-7LVT6UL2-B6uCi0Ol.js} +1 -1
  11. package/dist/assets/{ca-ES-6MX7JW3Y-pZF7WJUL.js → ca-ES-6MX7JW3Y-Bpe3kOti.js} +1 -1
  12. package/dist/assets/channel-DB3atv5o.js +1 -0
  13. package/dist/assets/{chunk-2Q5K7J3B-D2iTDmHh.js → chunk-2Q5K7J3B-DTWRWhpx.js} +1 -1
  14. package/dist/assets/{chunk-5VM5RSS4-CTxdXZIx.js → chunk-5VM5RSS4-Dfr1HUAN.js} +1 -1
  15. package/dist/assets/{chunk-F27PBJKO-Hic1X1pm.js → chunk-F27PBJKO-D_IVoCIK.js} +1 -1
  16. package/dist/assets/{chunk-IMKFNOWR-DhLW1JVb.js → chunk-IMKFNOWR-Boa_chn8.js} +1 -1
  17. package/dist/assets/{chunk-JWPE2WC7-_g5twKlC.js → chunk-JWPE2WC7-RaK8jzc2.js} +1 -1
  18. package/dist/assets/{chunk-POPQ4Y6H-DMV4qmkd.js → chunk-POPQ4Y6H-D7xOpv6O.js} +1 -1
  19. package/dist/assets/{chunk-SVP7TREG-BWg83oEL.js → chunk-SVP7TREG-XvJsx1jt.js} +1 -1
  20. package/dist/assets/{chunk-TICWLB2K-CPmkpa7J.js → chunk-TICWLB2K-DZCVWmZG.js} +1 -1
  21. package/dist/assets/{chunk-XXDRQBXY-KnXvIZ_8.js → chunk-XXDRQBXY-Djk-REAy.js} +1 -1
  22. package/dist/assets/classDiagram-ZZMXUADV-CzvsXoj_.js +1 -0
  23. package/dist/assets/classDiagram-v2-VYDZK3BY-HxwJpdPt.js +1 -0
  24. package/dist/assets/{cose-bilkent-JH36ORCC-BChK_CGh.js → cose-bilkent-JH36ORCC-D6XaIbtG.js} +1 -1
  25. package/dist/assets/{cs-CZ-2BRQDIVT-CtAC2Qjy.js → cs-CZ-2BRQDIVT-BdzgSHdJ.js} +1 -1
  26. package/dist/assets/{cynefin-OW5HDTMX-CdsltaMX.js → cynefin-OW5HDTMX-BMTkMDG1.js} +1 -1
  27. package/dist/assets/{cynefinDiagram-5FMLGOSQ-bXvXX3Fx.js → cynefinDiagram-5FMLGOSQ-C2s5i9h9.js} +1 -1
  28. package/dist/assets/{d3-scale-sM87TD1Z.js → d3-scale-BMIMKl27.js} +1 -1
  29. package/dist/assets/{da-DK-5WZEPLOC-DyWwaclV.js → da-DK-5WZEPLOC-Bj-GFWHU.js} +1 -1
  30. package/dist/assets/{dagre-GXQ25YYZ-CTmiZZVO.js → dagre-GXQ25YYZ-CMT8wlz0.js} +1 -1
  31. package/dist/assets/{de-DE-XR44H4JA-BDXUBHki.js → de-DE-XR44H4JA-JmpondAB.js} +1 -1
  32. package/dist/assets/{diagram-S7CK7UJ4-Bm8Fy0R_.js → diagram-S7CK7UJ4-DU1blS3M.js} +1 -1
  33. package/dist/assets/{diagram-UQ7AKVKN-BU_AmM_A.js → diagram-UQ7AKVKN-0lWi4KDV.js} +1 -1
  34. package/dist/assets/{diagram-VSXAHHWV-B78LUoXq.js → diagram-VSXAHHWV-CrseWrhn.js} +1 -1
  35. package/dist/assets/{diagram-VX7I27RA-DNvWjMlf.js → diagram-VX7I27RA-C5BMS8Ql.js} +1 -1
  36. package/dist/assets/{diagram-Z3DM3KII-DmFVt1fa.js → diagram-Z3DM3KII-Cc3vq6b8.js} +1 -1
  37. package/dist/assets/{ebnfDiagram-PWID7BFC-CpDna0Jp.js → ebnfDiagram-PWID7BFC-ZF78imma.js} +1 -1
  38. package/dist/assets/{el-GR-BZB4AONW-CNhF7oN2.js → el-GR-BZB4AONW-BFslUpdm.js} +1 -1
  39. package/dist/assets/{engines-a8mi_N6S.js → engines-BtEtIBXt.js} +1 -1
  40. package/dist/assets/{erDiagram-RLTQ6QDP-BGD-9OAS.js → erDiagram-RLTQ6QDP-CjPjDn2i.js} +1 -1
  41. package/dist/assets/{es-ES-U4NZUMDT-DXMrJcKL.js → es-ES-U4NZUMDT-B0ezBTxQ.js} +1 -1
  42. package/dist/assets/{eu-ES-A7QVB2H4-BTkMEwMi.js → eu-ES-A7QVB2H4-DP_gx2kf.js} +1 -1
  43. package/dist/assets/{fa-IR-HGAKTJCU-CgkknSS7.js → fa-IR-HGAKTJCU-BuT1ELty.js} +1 -1
  44. package/dist/assets/{fi-FI-Z5N7JZ37-B1K83nId.js → fi-FI-Z5N7JZ37-BAu_Cj7n.js} +1 -1
  45. package/dist/assets/{flowDiagram-HODETNUW-CjU1yR1F.js → flowDiagram-HODETNUW-yqPGWNdd.js} +1 -1
  46. package/dist/assets/{fr-FR-RHASNOE6-CBFZBGMr.js → fr-FR-RHASNOE6-OF1CpgtN.js} +1 -1
  47. package/dist/assets/{ganttDiagram-EL5Y4UJY-bvb8BjSh.js → ganttDiagram-EL5Y4UJY-zUY5je2K.js} +1 -1
  48. package/dist/assets/{gitGraphDiagram-WWUBYQGX-DZXQ_x8t.js → gitGraphDiagram-WWUBYQGX-oWrs7wy0.js} +1 -1
  49. package/dist/assets/{gl-ES-HMX3MZ6V-CON98Mma.js → gl-ES-HMX3MZ6V-CkJ47l98.js} +1 -1
  50. package/dist/assets/{he-IL-6SHJWFNN-CBoFaEdB.js → he-IL-6SHJWFNN-D7CecRlh.js} +1 -1
  51. package/dist/assets/{hi-IN-IWLTKZ5I-BJuoh3dl.js → hi-IN-IWLTKZ5I-CGlW2X-h.js} +1 -1
  52. package/dist/assets/{hu-HU-A5ZG7DT2-CQruu8XR.js → hu-HU-A5ZG7DT2-Dq_n_tbp.js} +1 -1
  53. package/dist/assets/{id-ID-SAP4L64H-VhaoENjR.js → id-ID-SAP4L64H-CotwO_06.js} +1 -1
  54. package/dist/assets/index-CdVc9Lmz.js +624 -0
  55. package/dist/assets/{index-CDNl17QJ.css → index-Cv-tTxNC.css} +1 -1
  56. package/dist/assets/{index-CboxqaL5.js → index-VaWCb9bx.js} +5 -5
  57. package/dist/assets/{infoDiagram-27XIBGKW-CM9Hap0f.js → infoDiagram-27XIBGKW-CYzIkNFW.js} +1 -1
  58. package/dist/assets/{ishikawaDiagram-5VMMS53U-i8pQztJI.js → ishikawaDiagram-5VMMS53U-DkgUsuk5.js} +1 -1
  59. package/dist/assets/{it-IT-JPQ66NNP-Dj9BkXfh.js → it-IT-JPQ66NNP-h97o81us.js} +1 -1
  60. package/dist/assets/{ja-JP-DBVTYXUO-CB2BlfIS.js → ja-JP-DBVTYXUO-M6EVfh0o.js} +1 -1
  61. package/dist/assets/{journeyDiagram-3NMN7TZE-PxcdqONT.js → journeyDiagram-3NMN7TZE-CuKkNrJy.js} +1 -1
  62. package/dist/assets/{kaa-6HZHGXH3-CLnR_zY5.js → kaa-6HZHGXH3-DUy85zzz.js} +1 -1
  63. package/dist/assets/{kab-KAB-ZGHBKWFO-8TJr4nPf.js → kab-KAB-ZGHBKWFO-ChL-fKtk.js} +1 -1
  64. package/dist/assets/{kanban-definition-UXKFOSKX-B2p5NBhO.js → kanban-definition-UXKFOSKX-DkOxt3kf.js} +1 -1
  65. package/dist/assets/{kk-KZ-P5N5QNE5-5uZYjZ2e.js → kk-KZ-P5N5QNE5-DY6ucSGD.js} +1 -1
  66. package/dist/assets/{km-KH-HSX4SM5Z-D54aOpMd.js → km-KH-HSX4SM5Z-BAaS4014.js} +1 -1
  67. package/dist/assets/{ko-KR-MTYHY66A-Bnm0G6eo.js → ko-KR-MTYHY66A-D-r3mJ1R.js} +1 -1
  68. package/dist/assets/{ku-TR-6OUDTVRD-CtGCn_eB.js → ku-TR-6OUDTVRD-Dk1GCoOP.js} +1 -1
  69. package/dist/assets/{layout-BBV3_Svw.js → layout-DtNEGI4_.js} +1 -1
  70. package/dist/assets/{lt-LT-XHIRWOB4-Bl8G0yv6.js → lt-LT-XHIRWOB4-3Z2Ui1VZ.js} +1 -1
  71. package/dist/assets/{lv-LV-5QDEKY6T-Cax93Eua.js → lv-LV-5QDEKY6T-Bg59rOkR.js} +1 -1
  72. package/dist/assets/{mindmap-definition-YA3MSWOX-CsOezwmE.js → mindmap-definition-YA3MSWOX-Dcs8eV7p.js} +1 -1
  73. package/dist/assets/{mr-IN-CRQNXWMA-Br7GVyJH.js → mr-IN-CRQNXWMA-DepTOG29.js} +1 -1
  74. package/dist/assets/{my-MM-5M5IBNSE-xC6lzTDV.js → my-MM-5M5IBNSE-4KqL4Tav.js} +1 -1
  75. package/dist/assets/{nb-NO-T6EIAALU-B0i5THqA.js → nb-NO-T6EIAALU-5YWO_l3W.js} +1 -1
  76. package/dist/assets/{nl-NL-IS3SIHDZ-CqYhUjP3.js → nl-NL-IS3SIHDZ-QlAndkM2.js} +1 -1
  77. package/dist/assets/{nn-NO-6E72VCQL-rpjr_9Z5.js → nn-NO-6E72VCQL-BscwhEDW.js} +1 -1
  78. package/dist/assets/{oc-FR-POXYY2M6-BlhQ99Ty.js → oc-FR-POXYY2M6-k7bYbSQj.js} +1 -1
  79. package/dist/assets/{pa-IN-N4M65BXN-N2XbQgZ_.js → pa-IN-N4M65BXN-jxBFwrWj.js} +1 -1
  80. package/dist/assets/{pegDiagram-XKGWAZYB-C2iSJgYQ.js → pegDiagram-XKGWAZYB-zM-VZA3r.js} +1 -1
  81. package/dist/assets/{pica-DvYcrBvx.js → pica-CsWQ4DPU.js} +1 -1
  82. package/dist/assets/{pieDiagram-E7YTZNPT-CUjgOGBw.js → pieDiagram-E7YTZNPT-C60FE0D8.js} +1 -1
  83. package/dist/assets/{pl-PL-T2D74RX3-CnMxn1dA.js → pl-PL-T2D74RX3-be8atU_l.js} +1 -1
  84. package/dist/assets/{pt-BR-5N22H2LF-Di-jnHb3.js → pt-BR-5N22H2LF-CSE0O2fj.js} +1 -1
  85. package/dist/assets/{pt-PT-UZXXM6DQ-BaAKq8Sh.js → pt-PT-UZXXM6DQ-5rnYJhy1.js} +1 -1
  86. package/dist/assets/{quadrantDiagram-AXDQQJYC-DwwqgJXZ.js → quadrantDiagram-AXDQQJYC-DyH84hx6.js} +1 -1
  87. package/dist/assets/{railroadDiagram-O6MQD6OU-DyRgYGPF.js → railroadDiagram-O6MQD6OU-DCrJgP9s.js} +1 -1
  88. package/dist/assets/{requirementDiagram-BXWQKSXE-C3ixXeHJ.js → requirementDiagram-BXWQKSXE-C78-QlFo.js} +1 -1
  89. package/dist/assets/{ro-RO-JPDTUUEW-BWrclVyo.js → ro-RO-JPDTUUEW-Gh6EgC27.js} +1 -1
  90. package/dist/assets/{ru-RU-B4JR7IUQ-_z0DINaG.js → ru-RU-B4JR7IUQ-BUWESZhq.js} +1 -1
  91. package/dist/assets/{sankeyDiagram-P5KCCOFB-mKpKYI_w.js → sankeyDiagram-P5KCCOFB-D_MOkKEs.js} +1 -1
  92. package/dist/assets/{sequenceDiagram-WJ2MYXX4-ZkNd0Wnj.js → sequenceDiagram-WJ2MYXX4-BeQbHZRB.js} +1 -1
  93. package/dist/assets/{si-LK-N5RQ5JYF-CdKOb383.js → si-LK-N5RQ5JYF-C9pnvQMf.js} +1 -1
  94. package/dist/assets/{sizeCapture-INFHLROL-hQLGO-0z.js → sizeCapture-INFHLROL-DUn-Mus_.js} +1 -1
  95. package/dist/assets/{sk-SK-C5VTKIMK-MHJC6ZIe.js → sk-SK-C5VTKIMK-FnkPBibb.js} +1 -1
  96. package/dist/assets/{sl-SI-NN7IZMDC-BF9YWbZx.js → sl-SI-NN7IZMDC-Cwrqj_B9.js} +1 -1
  97. package/dist/assets/{stateDiagram-D77RDMKH-CRWj3j-B.js → stateDiagram-D77RDMKH-C3EF3jQ3.js} +1 -1
  98. package/dist/assets/stateDiagram-v2-MP3YSRHH-CVQHmIvK.js +1 -0
  99. package/dist/assets/{subset-shared.chunk-DtxXjVIA.js → subset-shared.chunk-8ifLcT_D.js} +1 -1
  100. package/dist/assets/{subset-worker.chunk-DONNSbUF.js → subset-worker.chunk-DrNTybDR.js} +1 -1
  101. package/dist/assets/{sv-SE-XGPEYMSR-DkaTkfUY.js → sv-SE-XGPEYMSR-Btz80pGx.js} +1 -1
  102. package/dist/assets/{swimlanes-42K2YHIH-CFf6j7jO.js → swimlanes-42K2YHIH-B2_kGhPA.js} +1 -1
  103. package/dist/assets/swimlanesDiagram-VR7AAH4N-C1rOmrkT.js +8 -0
  104. package/dist/assets/{ta-IN-2NMHFXQM-BfxqXEDI.js → ta-IN-2NMHFXQM-B0bWtgu1.js} +1 -1
  105. package/dist/assets/{th-TH-HPSO5L25-DT3vLA39.js → th-TH-HPSO5L25-DgC0yFw3.js} +1 -1
  106. package/dist/assets/{timeline-definition-24CTP7MA-BGP2Dq8M.js → timeline-definition-24CTP7MA-Bu0W3Mcy.js} +1 -1
  107. package/dist/assets/{tr-TR-DEFEU3FU-CdfsG7py.js → tr-TR-DEFEU3FU-C9Mmy6ri.js} +1 -1
  108. package/dist/assets/{uk-UA-QMV73CPH-CZrQuC1S.js → uk-UA-QMV73CPH-rxEnqB_i.js} +1 -1
  109. package/dist/assets/{vennDiagram-4TSXK5OY-CaxGPIab.js → vennDiagram-4TSXK5OY-63JTeOph.js} +1 -1
  110. package/dist/assets/{vi-VN-M7AON7JQ-DQJk1_KV.js → vi-VN-M7AON7JQ-DOVa-vAT.js} +1 -1
  111. package/dist/assets/{wardleyDiagram-VM6X3IG4-DQxQ-zXH.js → wardleyDiagram-VM6X3IG4-Bct0TRuC.js} +1 -1
  112. package/dist/assets/{xychartDiagram-S5SC5T6Z-DoxdZQ6R.js → xychartDiagram-S5SC5T6Z-C21zgvSM.js} +1 -1
  113. package/dist/assets/{zh-CN-LNUGB5OW-DRVBfkOy.js → zh-CN-LNUGB5OW-MyifsmQ8.js} +1 -1
  114. package/dist/assets/{zh-HK-E62DVLB3-BJHrltss.js → zh-HK-E62DVLB3-Cp55UViv.js} +1 -1
  115. package/dist/assets/{zh-TW-RAJ6MFWO-DpMZ5m2x.js → zh-TW-RAJ6MFWO-DMy6SZap.js} +1 -1
  116. package/dist/index.html +2 -2
  117. package/docs/BUNDLE-FORMAT.md +18 -5
  118. package/docs/DIAGRAM-SOURCE.md +59 -12
  119. package/docs/LOCAL-DOCUMENT.md +17 -14
  120. package/docs/MODEL-CONTRACT.md +7 -4
  121. package/docs/PLANTUML-SOURCE.md +3 -2
  122. package/docs/VIEWER-LAUNCH.md +13 -3
  123. package/docs/VIEWER.md +93 -26
  124. package/docs/capabilities.json +21 -3
  125. package/package.json +2 -1
  126. package/scripts/build-map.mjs +1 -1
  127. package/scripts/lib/map-viewer-server.mjs +48 -24
  128. package/scripts/lib/original-materials.mjs +1 -1
  129. package/scripts/lib/original-report-server.mjs +7 -3
  130. package/scripts/lib/project-catalog.mjs +14 -2
  131. package/scripts/lib/project-map-inputs.mjs +1 -1
  132. package/scripts/lib/sketch-publication.mjs +1 -1
  133. package/scripts/lib/task-map-build.mjs +1 -1
  134. package/scripts/lib/view-args.mjs +183 -0
  135. package/scripts/lib/workflow/reader-surface.mjs +29 -11
  136. package/scripts/locus-map.mjs +14 -20
  137. package/scripts/open-map.mjs +84 -49
  138. package/skills/README.md +2 -1
  139. package/skills/locus-map/SKILL.md +27 -25
  140. package/skills/locus-map/assets/artifact-handoff.md +2 -1
  141. package/skills/locus-map/references/build-environment.md +11 -7
  142. package/skills/locus-map/references/checks.md +16 -4
  143. package/skills/locus-map/references/component-checkpoint.md +35 -0
  144. package/skills/locus-map/references/draw-skill.md +2 -1
  145. package/skills/locus-map/references/selection.md +36 -13
  146. package/skills/locus-map/references/task-maps.md +5 -0
  147. package/skills/locus-map/references/visual-composition.md +69 -0
  148. package/skills/locus-map-draft/SKILL.md +95 -0
  149. package/skills/locus-map-draft/assets/chosen-direction.md +47 -0
  150. package/skills/locus-map-draft/references/divergence-and-formats.md +127 -0
  151. package/skills/locus-map-primitives/SKILL.md +6 -2
  152. package/skills/locus-map-primitives/references/card-presentation.md +57 -3
  153. package/skills/locus-map-primitives/references/reading-files.md +1 -1
  154. package/src/adapter/areas.js +1 -0
  155. package/src/adapter/semanticAdmission.js +118 -5
  156. package/src/authoring/buildDiagram.mjs +99 -19
  157. package/src/authoring/canvas-source-worker.mjs +96 -0
  158. package/src/authoring/canvasSource.mjs +41 -0
  159. package/src/authoring/diagramChecks.js +143 -1
  160. package/src/authoring/diagramSource.js +31 -5
  161. package/src/authoring/printPlantumlSource.js +13 -2
  162. package/src/authoring/readDetailsFiles.mjs +100 -19
  163. package/src/bundle/chain.js +129 -32
  164. package/src/bundle/chainBrowser.js +26 -2
  165. package/src/bundle/localDocument.mjs +87 -22
  166. package/src/bundle/localDocumentClient.js +5 -1
  167. package/src/bundle/projectClient.js +59 -18
  168. package/src/chain/validation.js +7 -1
  169. package/src/contract/readingMaterials.js +18 -2
  170. package/src/contract/readingTable.js +66 -0
  171. package/src/viewer/ControlIcon.jsx +1 -0
  172. package/src/viewer/DiagramViewer.jsx +70 -30
  173. package/src/viewer/EmbeddedExcalidrawEditor.jsx +305 -0
  174. package/src/viewer/HighlightOverlay.jsx +53 -25
  175. package/src/viewer/Inspector.jsx +109 -39
  176. package/src/viewer/ProjectRail.jsx +11 -5
  177. package/src/viewer/ProjectViewChainViewer.jsx +222 -70
  178. package/src/viewer/ReadingTable.jsx +151 -0
  179. package/src/viewer/SketchCanvas.jsx +15 -75
  180. package/src/viewer/ViewChainViewer.jsx +543 -52
  181. package/src/viewer/camera.js +50 -18
  182. package/src/viewer/chainEditorSession.js +160 -35
  183. package/src/viewer/chainInstallation.js +3 -3
  184. package/src/viewer/details/CanvasPreview.jsx +303 -0
  185. package/src/viewer/details/InspectorReadingSettings.jsx +50 -13
  186. package/src/viewer/details/ReadingFiles.jsx +32 -4
  187. package/src/viewer/details/details.css +65 -26
  188. package/src/viewer/diagramControls.css +1 -1
  189. package/src/viewer/fileError.js +53 -0
  190. package/src/viewer/geometry.js +12 -0
  191. package/src/viewer/inspectorPosition.js +54 -31
  192. package/src/viewer/readingTable.css +47 -0
  193. package/src/viewer/sketchSettling.js +71 -0
  194. package/src/viewer/useInspectorPosition.js +116 -35
  195. package/src/viewer/viewChain.css +40 -4
  196. package/src/viewer/viewer.css +23 -12
  197. package/dist/assets/channel-Dx9OTBrx.js +0 -1
  198. package/dist/assets/classDiagram-ZZMXUADV-Da4s894j.js +0 -1
  199. package/dist/assets/classDiagram-v2-VYDZK3BY--H9NrCfO.js +0 -1
  200. package/dist/assets/index-DBGHN_5E.js +0 -624
  201. package/dist/assets/stateDiagram-v2-MP3YSRHH-B2DcVJGG.js +0 -1
  202. package/dist/assets/swimlanesDiagram-VR7AAH4N-DO_W2uN2.js +0 -8
@@ -0,0 +1,183 @@
1
+ import { realpath, stat } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ async function statKind(filePath) {
5
+ try {
6
+ const info = await stat(filePath);
7
+ if (info.isFile()) return 'file';
8
+ if (info.isDirectory()) return 'dir';
9
+ return null;
10
+ } catch (error) {
11
+ if (['ENOENT', 'ENOTDIR'].includes(error.code)) return null;
12
+ throw error;
13
+ }
14
+ }
15
+
16
+ async function canonicalPath(filePath) {
17
+ let current = path.resolve(filePath);
18
+ const suffix = [];
19
+ while (true) {
20
+ try {
21
+ const resolved = await realpath(current);
22
+ return suffix.length ? path.join(resolved, ...suffix.reverse()) : resolved;
23
+ } catch (error) {
24
+ if (!['ENOENT', 'ENOTDIR'].includes(error.code)) throw error;
25
+ const parent = path.dirname(current);
26
+ if (parent === current) return path.resolve(filePath);
27
+ suffix.push(path.basename(current));
28
+ current = parent;
29
+ }
30
+ }
31
+ }
32
+
33
+ function isBareTopicName(value) {
34
+ return typeof value === 'string' && value.length > 0
35
+ && !value.includes('/') && !value.includes('\\') && !value.includes('\0')
36
+ && value !== '.' && value !== '..' && path.basename(value) === value;
37
+ }
38
+
39
+ function enclosingLibraryRoot(targetPath) {
40
+ let directory = path.dirname(targetPath);
41
+ while (true) {
42
+ const parent = path.dirname(directory);
43
+ if (path.basename(directory) === '.locus-map' && parent !== directory) return parent;
44
+ if (parent === directory) return undefined;
45
+ directory = parent;
46
+ }
47
+ }
48
+
49
+ function isInsideDirectory(candidate, directory) {
50
+ const relative = path.relative(directory, candidate);
51
+ return Boolean(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
52
+ }
53
+
54
+ async function inferSourceRoot(mode, targetPath, cwd) {
55
+ const [realTarget, realCwd] = await Promise.all([canonicalPath(targetPath), canonicalPath(cwd)]);
56
+ if (mode === 'library') return realTarget;
57
+ const fromLibrary = enclosingLibraryRoot(realTarget);
58
+ if (fromLibrary) return fromLibrary;
59
+ if (isInsideDirectory(realTarget, realCwd)) return realCwd;
60
+ return undefined;
61
+ }
62
+
63
+ async function resolveTopicTarget(target, cwd, { projectFlag }) {
64
+ const direct = path.resolve(cwd, target);
65
+ const directKind = await statKind(direct);
66
+ if (directKind === 'file') {
67
+ const isCatalog = projectFlag || path.basename(direct) === 'project.json';
68
+ return { mode: isCatalog ? 'project' : 'document', targetPath: direct };
69
+ }
70
+ if (directKind === 'dir') {
71
+ const catalog = path.join(direct, 'project.json');
72
+ if (await statKind(catalog) === 'file') return { mode: 'project', targetPath: catalog };
73
+ const name = path.basename(direct);
74
+ if (!projectFlag && name === '.locus-map') return { mode: 'library', targetPath: path.dirname(direct) };
75
+ if (name !== '.locus-map') {
76
+ const namesake = path.join(direct, `${name}.locus-map.json`);
77
+ if (await statKind(namesake) === 'file') return { mode: 'document', targetPath: namesake };
78
+ }
79
+ if (!isBareTopicName(target) || name === '.locus-map') {
80
+ throw new Error(name === '.locus-map'
81
+ ? `Cannot find "project.json" in "${target}".`
82
+ : `Cannot find "project.json" or "${name}.locus-map.json" in "${target}".`);
83
+ }
84
+ }
85
+ if (isBareTopicName(target)) {
86
+ const candidates = [
87
+ { mode: 'project', targetPath: path.resolve(cwd, '.locus-map', target, 'project.json') },
88
+ { mode: 'document', targetPath: path.resolve(cwd, '.locus-map', target, `${target}.locus-map.json`) },
89
+ { mode: 'document', targetPath: path.resolve(cwd, '.locus-map', `${target}.locus-map.json`) },
90
+ ...(target === 'project'
91
+ ? [{ mode: 'project', targetPath: path.resolve(cwd, '.locus-map', 'project.json') }]
92
+ : []),
93
+ ];
94
+ for (const candidate of candidates) {
95
+ if (await statKind(candidate.targetPath) === 'file') return candidate;
96
+ }
97
+ throw new Error(
98
+ `Cannot find ${projectFlag ? 'project or diagram' : 'diagram or project'} "${target}". `
99
+ + `Checked "${target}", ".locus-map/${target}/project.json", ".locus-map/${target}/${target}.locus-map.json", and ".locus-map/${target}.locus-map.json".`,
100
+ );
101
+ }
102
+ return { mode: projectFlag ? 'project' : 'document', targetPath: direct };
103
+ }
104
+
105
+ /**
106
+ * Parse `locus-map view` CLI arguments, resolve topic/project shorthands relative
107
+ * to `cwd`, and return the canonical `open-map.mjs` argument list.
108
+ */
109
+ export async function resolveViewArgs(args, { cwd = process.cwd(), usage }) {
110
+ const resolvedCwd = path.resolve(cwd);
111
+ const seen = new Set();
112
+ let local = false;
113
+ let hasProject = false;
114
+ let positional;
115
+ let sourceRoot;
116
+ let noSourceRoot = false;
117
+ let readOnly = false;
118
+ let port;
119
+ let previousDocument;
120
+
121
+ for (let index = 0; index < args.length; index++) {
122
+ const token = args[index];
123
+ if (token === '--document') throw new Error('Pass the document as the first argument to view.');
124
+ if (!token.startsWith('-')) {
125
+ if (positional !== undefined) throw new Error(usage);
126
+ positional = token;
127
+ continue;
128
+ }
129
+ if (seen.has(token)) throw new Error(usage);
130
+ seen.add(token);
131
+ if (token === '--local') { local = true; continue; }
132
+ if (token === '--read-only') { readOnly = true; continue; }
133
+ if (token === '--no-source-root') { noSourceRoot = true; continue; }
134
+ if (token === '--project') { hasProject = true; continue; }
135
+ const value = args[++index];
136
+ if (!value || value.startsWith('-')) throw new Error(usage);
137
+ if (token === '--source-root') sourceRoot = path.resolve(resolvedCwd, value);
138
+ else if (token === '--previous-document') previousDocument = path.resolve(resolvedCwd, value);
139
+ else if (token === '--port') {
140
+ if (!/^[0-9]+$/.test(value)) throw new Error(usage);
141
+ const parsed = Number(value);
142
+ if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) throw new Error(usage);
143
+ port = value;
144
+ } else throw new Error(usage);
145
+ }
146
+
147
+ if (sourceRoot !== undefined && noSourceRoot) throw new Error(usage);
148
+ if (hasProject && local) throw new Error(usage);
149
+
150
+ let mode;
151
+ let targetPath;
152
+ if (hasProject) {
153
+ if (positional === undefined) {
154
+ const rootCatalog = path.resolve(resolvedCwd, '.locus-map', 'project.json');
155
+ if (await statKind(rootCatalog) !== 'file') {
156
+ throw new Error('Cannot find root project catalog ".locus-map/project.json". Pass a catalog file, topic name, or use "locus-map view --local".');
157
+ }
158
+ mode = 'project';
159
+ targetPath = rootCatalog;
160
+ } else {
161
+ ({ mode, targetPath } = await resolveTopicTarget(positional, resolvedCwd, { projectFlag: true }));
162
+ }
163
+ } else if (positional !== undefined) {
164
+ ({ mode, targetPath } = await resolveTopicTarget(positional, resolvedCwd, { projectFlag: false }));
165
+ } else {
166
+ const isolated = local || sourceRoot !== undefined || noSourceRoot;
167
+ mode = isolated ? 'library' : 'user-projects';
168
+ targetPath = resolvedCwd;
169
+ }
170
+
171
+ if (previousDocument !== undefined && mode !== 'document') throw new Error(usage);
172
+
173
+ const effectiveSourceRoot = mode === 'user-projects'
174
+ ? undefined
175
+ : sourceRoot ?? (noSourceRoot ? undefined : await inferSourceRoot(mode, targetPath, resolvedCwd));
176
+
177
+ const openArgs = [`--${mode}`, targetPath];
178
+ if (previousDocument !== undefined) openArgs.push('--previous-document', previousDocument);
179
+ if (effectiveSourceRoot !== undefined) openArgs.push('--source-root', effectiveSourceRoot);
180
+ if (readOnly) openArgs.push('--read-only');
181
+ if (port !== undefined) openArgs.push('--port', port);
182
+ return { mode, targetPath, sourceRoot: effectiveSourceRoot, openArgs };
183
+ }
@@ -7,15 +7,16 @@ import { startMapViewer } from '../map-viewer-server.mjs';
7
7
  const self = fileURLToPath(import.meta.url);
8
8
  const fail = (code, message) => Object.assign(new Error(message), { code });
9
9
 
10
- async function publishSurface(recordPath, record) {
11
- const temporary = recordPath + '.' + randomUUID() + '.tmp';
10
+ async function publishSurface(recordPath, record, temporary = recordPath + '.' + randomUUID() + '.tmp') {
12
11
  const file = await open(temporary, 'wx', 0o600);
12
+ let closed = false;
13
13
  try {
14
14
  await file.writeFile(JSON.stringify(record) + '\n');
15
+ closed = true;
15
16
  await file.close();
16
17
  await rename(temporary, recordPath);
17
18
  } finally {
18
- await file.close();
19
+ if (!closed) await file.close().catch(() => {});
19
20
  await rm(temporary, { force: true });
20
21
  }
21
22
  }
@@ -36,8 +37,9 @@ export async function startReaderSurface(config) {
36
37
  throw fail('READER_ALREADY_STARTED', 'This reader call already owns a surface attempt.');
37
38
  throw error;
38
39
  });
40
+ const runningTempPath = config.recordPath + '.' + randomUUID() + '.tmp';
39
41
  return new Promise((resolveReady, reject) => {
40
- const child = fork(self, ['--worker', JSON.stringify(config)], {
42
+ const child = fork(self, ['--worker', JSON.stringify({ ...config, runningTempPath })], {
41
43
  stdio: ['ignore', 'ignore', 'ignore', 'ipc'],
42
44
  execArgv: [],
43
45
  });
@@ -51,6 +53,7 @@ export async function startReaderSurface(config) {
51
53
  ? Promise.resolve() : new Promise(resolve => child.once('close', resolve));
52
54
  child.kill('SIGKILL');
53
55
  await stopped;
56
+ await rm(runningTempPath, { force: true }).catch(() => {});
54
57
  let failure = error;
55
58
  try {
56
59
  await publishSurface(
@@ -94,11 +97,12 @@ async function worker(config) {
94
97
  const began = Date.now();
95
98
  let viewer,
96
99
  closing = false,
100
+ ready = false,
97
101
  watcher,
98
102
  deadline,
99
103
  hardStop;
100
104
  let writing = Promise.resolve();
101
- const write = (value) => {
105
+ const write = (value, temporary) => {
102
106
  const next = writing.then(() => publishSurface(config.recordPath, {
103
107
  schemaVersion: 1,
104
108
  runId: config.runId,
@@ -107,7 +111,7 @@ async function worker(config) {
107
111
  startedAt: new Date(began).toISOString(),
108
112
  expiresAt: new Date(began + config.timeoutMs + 5000).toISOString(),
109
113
  ...value,
110
- }));
114
+ }, temporary));
111
115
  writing = next.catch(() => {});
112
116
  return next;
113
117
  };
@@ -118,11 +122,13 @@ async function worker(config) {
118
122
  clearTimeout(deadline);
119
123
  try {
120
124
  await viewer?.close({ force: true });
121
- await write({ state: 'closed', reason, url: viewer?.url ?? null });
125
+ if (ready) await write({ state: 'closed', reason, url: viewer?.url ?? null });
126
+ else await writing;
122
127
  clearTimeout(hardStop);
123
128
  process.exitCode = 0;
124
129
  } catch (error) {
125
- await write({ state: 'failed', reason: error.message }).catch(() => {});
130
+ if (ready) await write({ state: 'failed', reason: error.message }).catch(() => {});
131
+ clearTimeout(hardStop);
126
132
  process.exitCode = 1;
127
133
  }
128
134
  };
@@ -136,9 +142,10 @@ async function worker(config) {
136
142
  await viewer.close({ force: true });
137
143
  return;
138
144
  }
139
- await write({ state: 'running', url: viewer.url });
145
+ await write({ state: 'running', url: viewer.url }, config.runningTempPath);
140
146
  if (closing) return;
141
147
  process.send?.({ kind: 'ready', url: viewer.url, pid: process.pid });
148
+ ready = true;
142
149
  let inspecting = false;
143
150
  watcher = setInterval(async () => {
144
151
  if (inspecting || closing) return;
@@ -175,8 +182,19 @@ async function worker(config) {
175
182
  }
176
183
  }, 250);
177
184
  } catch (error) {
178
- process.send?.({ kind: 'error', message: error.message });
179
- await stop('startup_failed');
185
+ // Before readiness, the parent owns failure publication and immediately SIGKILLs the worker.
186
+ closing = true;
187
+ clearInterval(watcher);
188
+ clearTimeout(deadline);
189
+ clearTimeout(hardStop);
190
+ await viewer?.close({ force: true }).catch(() => {});
191
+ await writing;
192
+ if (process.connected) {
193
+ try {
194
+ process.send?.({ kind: 'error', message: error.message });
195
+ } catch {}
196
+ }
197
+ process.exitCode = 1;
180
198
  }
181
199
  }
182
200
  if (process.argv[1] && resolve(process.argv[1]) === self && process.argv[2] === '--worker')
@@ -11,16 +11,21 @@ const usage = `Usage:
11
11
  locus-map build [build-map options]
12
12
  locus-map tasks export [--root DIR] [--dir .tasks] [--include-archived]
13
13
  locus-map view --help
14
- locus-map view [--local] [--read-only] [--port N]
15
- locus-map view FILE [--source-root DIR] [--read-only] [--port N] [--previous-document FILE]
16
- locus-map view --project FILE [--source-root DIR] [--read-only] [--port N]`;
14
+ locus-map view [--local] [--source-root DIR | --no-source-root] [--read-only] [--port N]
15
+ locus-map view TARGET [--source-root DIR | --no-source-root] [--read-only] [--port N] [--previous-document FILE]
16
+ locus-map view --project [TARGET] [--source-root DIR | --no-source-root] [--read-only] [--port N]`;
17
17
 
18
18
  const viewHelp = `${usage.slice(usage.indexOf(' locus-map view [--local]'))}
19
19
 
20
20
  Start one local viewer and open the URL it prints. Keep its process running.
21
21
  Register named folders in ~/.locusmap/projects.toml. Existing projects.json registries also work.
22
22
  Without a registry, view opens Personal and any library in the launch directory.
23
- --local skips the home registry. Explicit file, project and source-root launches also skip it.
23
+ --local skips the home registry. Explicit target, --project and --source-root launches also skip it.
24
+ TARGET may be a file, directory or topic name under .locus-map/ (.locus-map/<name>/project.json,
25
+ .locus-map/<name>/<name>.locus-map.json or .locus-map/<name>.locus-map.json). --project without a
26
+ target opens the root .locus-map/project.json. Isolated launches default --source-root to the
27
+ enclosing project directory when the target lives under .locus-map/ or the launch directory; pass
28
+ --no-source-root to disable original-file links.
24
29
  Workspace launches default to 127.0.0.1:8181 or the configured port. --port N overrides both.
25
30
  Use --port 0 for a free port, the default for explicit and isolated launches. --read-only disables file saves.
26
31
  Launch and configuration guide: ${join(root, 'docs', 'VIEWER-LAUNCH.md')}`;
@@ -31,6 +36,7 @@ async function doctor(json) {
31
36
  productRoot: root,
32
37
  docsRoot: join(root, 'docs'),
33
38
  mapSkillPath: join(root, 'skills/locus-map/SKILL.md'),
39
+ draftSkillPath: join(root, 'skills/locus-map-draft/SKILL.md'),
34
40
  primitivesSkillPath: join(root, 'skills/locus-map-primitives/SKILL.md'),
35
41
  researchSkillPath: join(root, 'skills/locus-map-research/SKILL.md'),
36
42
  drawSkillPath: null,
@@ -56,7 +62,7 @@ async function doctor(json) {
56
62
  } catch (error) { result.reasons.push(error.message); }
57
63
 
58
64
  try {
59
- await Promise.all([join(result.docsRoot, 'DIAGRAM-SOURCE.md'), result.mapSkillPath, result.primitivesSkillPath, result.researchSkillPath]
65
+ await Promise.all([join(result.docsRoot, 'DIAGRAM-SOURCE.md'), result.mapSkillPath, result.draftSkillPath, result.primitivesSkillPath, result.researchSkillPath]
60
66
  .map(async path => {
61
67
  if (!(await stat(path)).isFile()) throw new Error(`Expected a file at ${path}.`);
62
68
  }));
@@ -126,22 +132,10 @@ async function main([command, ...args]) {
126
132
  return 0;
127
133
  }
128
134
  if (command === 'build') return run('build-map.mjs', args);
129
- if (command === 'view' && args[0] === '--project' && args[1] && !args[1].startsWith('--')) {
130
- return run('open-map.mjs', ['--project', resolve(args[1]), ...args.slice(2)]);
131
- }
132
- if (command === 'view' && args[0] && !args[0].startsWith('--')) {
133
- const [file, ...options] = args;
134
- for (let index = 0; index < options.length; index++) {
135
- if (options[index] === '--document') throw new Error('Pass the document as the first argument to view.');
136
- if (options[index] === '--previous-document' && options[index + 1] && !options[index + 1].startsWith('--')) {
137
- options[++index] = resolve(options[index]);
138
- }
139
- }
140
- return run('open-map.mjs', ['--document', resolve(file), ...options]);
141
- }
142
135
  if (command === 'view') {
143
- const isolated = args.includes('--local') || args.includes('--source-root');
144
- return run('open-map.mjs', [isolated ? '--library' : '--user-projects', process.cwd(), ...args]);
136
+ const { resolveViewArgs } = await import('./lib/view-args.mjs');
137
+ const { openArgs } = await resolveViewArgs(args, { cwd: process.cwd(), usage });
138
+ return run('open-map.mjs', openArgs);
145
139
  }
146
140
  throw new Error(usage);
147
141
  }
@@ -1,59 +1,94 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
2
3
  import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
3
5
  import { readWorkspaceRegistry } from './lib/project-registry.mjs';
4
6
  import { startMapViewer } from './lib/map-viewer-server.mjs';
5
7
 
6
- const args = process.argv.slice(2);
7
- let filePath;
8
- let projectPath;
9
- let libraryRoot;
10
- let registryRoot;
11
- let previousDocumentPath;
12
- let sourceRoot;
13
- let readOnly = false;
14
- let port;
15
- const usage = `Usage:
8
+ export const DEFAULT_SHUTDOWN_GRACE_MS = 1500;
9
+
10
+ export async function runOpenMap(args = process.argv.slice(2), { distDir, shutdownGraceMs = DEFAULT_SHUTDOWN_GRACE_MS } = {}) {
11
+ let filePath;
12
+ let projectPath;
13
+ let libraryRoot;
14
+ let registryRoot;
15
+ let previousDocumentPath;
16
+ let sourceRoot;
17
+ let readOnly = false;
18
+ let port;
19
+ const usage = `Usage:
16
20
  node scripts/open-map.mjs --document /full/path/map.locus-map.json [--previous-document /full/path/previous.locus-map.json] [--source-root DIR] [--read-only] [--port 4181]
17
21
  node scripts/open-map.mjs --project /full/path/project.json [--source-root DIR] [--read-only] [--port 4181]
18
22
  node scripts/open-map.mjs --library /full/path/project [--source-root DIR] [--read-only] [--port 4181]`;
19
- const seen = new Set();
20
- for (let index = 0; index < args.length; index++) {
21
- const option = args[index];
22
- if (seen.has(option)) throw new Error(usage);
23
- seen.add(option);
24
- if (option === '--local' && libraryRoot) continue;
25
- if (option === '--read-only') { readOnly = true; continue; }
26
- const value = args[++index];
27
- if (!value || value.startsWith('--')) throw new Error(usage);
28
- if (option === '--document') filePath = value;
29
- else if (option === '--project') projectPath = value;
30
- else if (option === '--user-projects') registryRoot = value;
31
- else if (option === '--library') libraryRoot = value;
32
- else if (option === '--previous-document') previousDocumentPath = value;
33
- else if (option === '--source-root') sourceRoot = path.resolve(value);
34
- else if (option === '--port' && /^[0-9]+$/.test(value)) port = Number(value);
35
- else throw new Error(usage);
36
- }
37
- if ([filePath, projectPath, libraryRoot, registryRoot].filter(Boolean).length !== 1 || (!filePath && previousDocumentPath)
38
- || [filePath, projectPath, libraryRoot, registryRoot, previousDocumentPath].some(value => value !== undefined && !path.isAbsolute(value))
39
- || (port !== undefined && (!Number.isInteger(port) || port < 0 || port > 65535))) {
40
- throw new Error(usage);
23
+ const seen = new Set();
24
+ for (let index = 0; index < args.length; index++) {
25
+ const option = args[index];
26
+ if (seen.has(option)) throw new Error(usage);
27
+ seen.add(option);
28
+ if (option === '--local' && libraryRoot) continue;
29
+ if (option === '--read-only') { readOnly = true; continue; }
30
+ const value = args[++index];
31
+ if (!value || value.startsWith('--')) throw new Error(usage);
32
+ if (option === '--document') filePath = value;
33
+ else if (option === '--project') projectPath = value;
34
+ else if (option === '--user-projects') registryRoot = value;
35
+ else if (option === '--library') libraryRoot = value;
36
+ else if (option === '--previous-document') previousDocumentPath = value;
37
+ else if (option === '--source-root') sourceRoot = path.resolve(value);
38
+ else if (option === '--port' && /^[0-9]+$/.test(value)) port = Number(value);
39
+ else throw new Error(usage);
40
+ }
41
+ if ([filePath, projectPath, libraryRoot, registryRoot].filter(Boolean).length !== 1 || (!filePath && previousDocumentPath)
42
+ || [filePath, projectPath, libraryRoot, registryRoot, previousDocumentPath].some(value => value !== undefined && !path.isAbsolute(value))
43
+ || (port !== undefined && (!Number.isInteger(port) || port < 0 || port > 65535))) {
44
+ throw new Error(usage);
45
+ }
46
+ let viewer;
47
+ try {
48
+ const registry = registryRoot && await readWorkspaceRegistry(registryRoot);
49
+ port ??= registry ? registry.port ?? 8181 : 0;
50
+ viewer = await startMapViewer({ filePath, projectPath, libraryRoot, registry, previousDocumentPath, sourceRoot, readOnly, port, ...(distDir ? { distDir } : {}) });
51
+ if (registry?.file) console.error(`Using project registry ${registry.file}`);
52
+ } catch (error) {
53
+ console.error(error.code === 'EADDRINUSE' ? `Port ${port} is in use. Reuse your running viewer or choose another --port.` : error.message);
54
+ process.exit(1);
55
+ }
56
+ process.stdout.write(`${viewer.url}\n`);
57
+ const rawClose = viewer.close.bind(viewer);
58
+ const detachSignals = () => {
59
+ process.off('SIGINT', onSignal);
60
+ process.off('SIGTERM', onSignal);
61
+ };
62
+ let closePromise;
63
+ const close = options => {
64
+ const promise = rawClose(options);
65
+ if (!closePromise) closePromise = promise.finally(detachSignals);
66
+ return closePromise;
67
+ };
68
+ let closing = false;
69
+ async function onSignal() {
70
+ if (closing) {
71
+ close({ force: true }).catch(() => {});
72
+ return;
73
+ }
74
+ closing = true;
75
+ const forceTimer = setTimeout(() => {
76
+ close({ force: true }).catch(() => {});
77
+ }, shutdownGraceMs);
78
+ forceTimer.unref();
79
+ try { await close(); process.exitCode = 0; }
80
+ catch (error) { process.stderr.write(`${error.message}\n`); process.exitCode = 1; }
81
+ finally { clearTimeout(forceTimer); }
82
+ }
83
+ process.on('SIGINT', onSignal);
84
+ process.on('SIGTERM', onSignal);
85
+ return { ...viewer, close };
41
86
  }
42
- let viewer;
43
- try {
44
- const registry = registryRoot && await readWorkspaceRegistry(registryRoot);
45
- port ??= registry ? registry.port ?? 8181 : 0;
46
- viewer = await startMapViewer({ filePath, projectPath, libraryRoot, registry, previousDocumentPath, sourceRoot, readOnly, port });
47
- if (registry?.file) console.error(`Using project registry ${registry.file}`);
48
- } catch (error) {
49
- console.error(error.code === 'EADDRINUSE' ? `Port ${port} is in use. Reuse your running viewer or choose another --port.` : error.message);
50
- process.exit(1);
87
+
88
+ function isMainModule() {
89
+ if (!process.argv[1]) return false;
90
+ try { return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url)); }
91
+ catch { return false; }
51
92
  }
52
- process.stdout.write(`${viewer.url}\n`);
53
- let closing = false;
54
- for (const signal of ['SIGINT', 'SIGTERM']) process.on(signal, async () => {
55
- if (closing) return;
56
- closing = true;
57
- try { await viewer.close(); process.exitCode = 0; }
58
- catch (error) { process.stderr.write(`${error.message}\n`); process.exitCode = 1; }
59
- });
93
+
94
+ if (isMainModule()) await runOpenMap();
package/skills/README.md CHANGED
@@ -4,7 +4,8 @@ Start with the result the user wants. A request to revise a map uses the same en
4
4
 
5
5
  | User request | Start here | What it delivers |
6
6
  | --- | --- | --- |
7
- | “Show how checkout works.” “Fix the unreadable return arrow on this map.” | [locus-map](locus-map/SKILL.md) | The coordinator finds the source, chooses a supported view, builds or revises the editable map and checks what the reader can see. It owns diagram feedback and project drawing preferences. |
7
+ | “Show how checkout works.” “Visualize this ML experiment with charts and notes.” “Fix the unreadable return arrow on this map.” | [locus-map](locus-map/SKILL.md) | The main coordinator chooses a fitting visual structure (Draw visual board/chart, connected semantic map, or architecture view), builds or revises it in Locus Map, and owns feedback and project drawing preferences. |
8
+ | “I'm not sure how to lay out this experiment — show me 3 visual drafts first.” | [locus-map-draft](locus-map-draft/SKILL.md) | Formalizes an open-ended request, builds 1–4 quick draft options (`.mjs`, `.puml`, or `.map.json`) for early component feedback in Locus Map, and hands the chosen visual reference off to authoring or research. |
8
9
  | “How do I link this card to a second map?” “Which file owns a foldable tree?” | [locus-map-primitives](locus-map-primitives/SKILL.md) | A reference for canvas operations, files, links and runnable examples. An author can consult it during a map revision. |
9
10
  | “Verify who owns each component before drawing it.” | [locus-map-research](locus-map-research/SKILL.md) | A source-backed, independently reviewed research packet for the author. Use it for verified claims, component, sequence or decision families and the supported ArchiMate subset. The coordinator still owns delivery. |
10
11
 
@@ -1,19 +1,20 @@
1
1
  ---
2
2
  name: locus-map
3
- description: "Creates or revises a connected editable diagram from project sources, records diagram feedback and reuses the project’s drawing preferences."
3
+ description: "Creates or revises Draw visual boards, connected semantic maps, or researched architecture views in Locus Map, records feedback and reuses preferences."
4
4
  ---
5
5
 
6
6
  # locus-map
7
7
 
8
- Answer the reader's question with one diagram. Draw owns its language and geometry.
9
- Canvas operations: `skills/locus-map-primitives/SKILL.md`. In Pi use only assigned methods.
10
- Use installed `MAP_BIN` or `<checkout>/scripts/locus-map.mjs`. Resolve Map paths from `productRoot` in `"$MAP_BIN" doctor --json`.
11
- Prebuilt npm viewer: [setup](references/build-environment.md), `docs/VIEWER-LAUNCH.md`.
8
+ Answer the reader's question with the fitting visual structure in Locus Map. Draw owns genres and geometry.
9
+ Draft options: `skills/locus-map-draft/SKILL.md`. Primitives: `skills/locus-map-primitives/SKILL.md`. Pi: assigned methods only.
10
+ Use `locus-map` (`MAP_BIN`), `npx @locus-forge/locus-map`, or `scripts/locus-map.mjs`. Resolve paths via `productRoot` in `"$MAP_BIN" doctor --json`.
11
+ Viewer setup: [setup](references/build-environment.md), `docs/VIEWER-LAUNCH.md`.
12
12
 
13
13
  ## Create or revise
14
14
 
15
- Outside Pi duties, read the project's optional `.locus-map/preferences.md`. To revise a map, open its sibling
16
- `<name>.feedback.md` and follow [Revise a diagram from feedback](references/revise.md).
15
+ Outside Pi, pick structure first via [visual composition](references/visual-composition.md):
16
+ draft 1–4 options (`locus-map-draft`), build a Draw `.excalidraw` board, or follow sections 1–6 for `.locus-map.json`.
17
+ Read `.locus-map/preferences.md`; to revise, use `<name>.feedback.md` and [Revise a diagram from feedback](references/revise.md).
17
18
  In Pi, Build reads preferences only if assigned. The current request takes precedence.
18
19
 
19
20
  ## 1. Frame one diagram
@@ -30,7 +31,7 @@ hand-offs, decisions, stores. A request that names nothing specific needs no lis
30
31
  requested diagram type. Dropping an item, merging requested steps or replacing the subject is a narrowing: return it
31
32
  to the user with the options. A brief that delegates the diagram passes this frame unchanged.
32
33
 
33
- For a standalone source draft, trace the caller and its handoffs using [one connected diagram](references/connected-diagram.md). Read its destination rules before adding ↘.
34
+ For a standalone source draft, trace caller/handoffs via [one connected diagram](references/connected-diagram.md) and its ↘ destination rules.
34
35
  Use the [diagram folder and source checkout](references/folder.md).
35
36
 
36
37
  ## 2. Choose the family and route from the registry
@@ -48,15 +49,16 @@ An unsupported notation needs an explicit limit, a bounded alternative and agree
48
49
  - **Source draft (default when sufficient):** `source` admits only `semantic`, including `.puml` C4 Component
49
50
  vocabulary and reading areas. Read sources/callers; keep each planned node/relation, `path:line` evidence and
50
51
  unresolved claims in `facts.md`. Imports, citations and rendering do not establish truth. Continue with sections 3–6.
51
- - **Research route:** verified claims, component/sequence/decision families, the ArchiMate application subset,
52
- or the full author/reviewer/reader flow, subject to registry and profile admission.
53
- Use `skills/locus-map-research/SKILL.md` and the [research authoring order](references/authoring-order.md):
54
- question → mechanism → independent source review → build/open → reader understanding. For an authorized Pi run,
55
- read [the Pi handoff](references/pi-handoff.md); for reuse after a stopped run, follow `docs/PI-WORKFLOW.md`.
52
+ - **Research route:** verified claims, component/sequence/decision, ArchiMate subset,
53
+ or author/reviewer/reader flow, per registry admission.
54
+ Use `skills/locus-map-research/SKILL.md` and [research authoring order](references/authoring-order.md):
55
+ question → mechanism → source review → build/open → reader trial. Authorized Pi runs:
56
+ [Pi handoff](references/pi-handoff.md); stopped-run reuse: `docs/PI-WORKFLOW.md`.
56
57
 
57
- The route sets evidence requirements, not the subject: it can depict research or Pi without executing it.
58
- An instruction not to run Pi limits the method only.
59
- Do not combine research flags with `--source` or silently promote a source draft to a verified result.
58
+ Route sets evidence rules, not subject: it can depict research/Pi without running it.
59
+ Not running Pi limits method only.
60
+ Never mix research flags with `--source` or promote a draft to verified.
61
+ Outside Pi duties, check [component checkpoint](references/component-checkpoint.md) before authoring when its triggers apply.
60
62
 
61
63
  ## 3. Author the selected source view through Draw
62
64
 
@@ -67,7 +69,7 @@ Keep the selected family, route and `Must show` on the agreed surface; Draw refi
67
69
  Budgets cannot remove required content. A semantic conflict returns to selection and its source owner.
68
70
 
69
71
  For a source draft choose direction before placement using the main reading path guidance in `docs/DIAGRAM-SOURCE.md`.
70
- Keep the authored `.puml` with its preview stub, or retain the schema-v1 input and generator for JSON-only features such as a foldable tree.
72
+ Keep the `.puml` and preview stub, or keep schema-v1 input and generator for JSON-only features (such as a foldable tree).
71
73
  Before building, reconcile each shown responsibility, relation, guard and boundary with the actual sources.
72
74
  A semantic correction returns to the source/facts and, on the research route, its required review. A geometry-only
73
75
  repair stays in the authoring/build loop. Moving a card in the viewer cannot establish a new semantic claim.
@@ -80,21 +82,21 @@ repair stays in the authoring/build loop. Moving a card in the viewer cannot est
80
82
 
81
83
  See [build environment](references/build-environment.md) for browser/outputs/preflight. Run preflight before building; include it in build briefs.
82
84
 
83
- Inspect the build's PNG and check report. Compare the starting action, real handoffs and final outcome with the verbatim request and `Must show`.
84
- Keep inputs near their consumers. Use `--multi-screen` when the flow needs more space at reading zoom. Whole-map Fit gives orientation.
85
- Repair the authored source and build into the next directory. Follow [checks and repairs](references/checks.md) and [deliverable updates](references/folder.md#updates).
85
+ Inspect the build's PNG and check report against the request, real handoffs and `Must show`.
86
+ Keep inputs near consumers; use `--multi-screen` if reading zoom needs space. Whole-map Fit gives orientation.
87
+ Repair source into the next build directory via [checks and repairs](references/checks.md) and [deliverable updates](references/folder.md#updates).
86
88
 
87
89
  ## 5. Open, edit and reopen
88
90
 
89
91
  Checkout: `npm run build` once; npm: use the included viewer:
90
92
 
91
93
  ```sh
92
- "$MAP_BIN" view /ABSOLUTE/DIR/<diagram>.locus-map.json
94
+ "$MAP_BIN" view <diagram>
93
95
  ```
94
96
 
95
- Reopen by absolute path. Never save the printed address (`#write=` grants Save).
96
- Open the printed address in the selected browser. `docs/LOCAL-DOCUMENT.md` owns Open, Save and regeneration.
97
- On a copy outside the folder root, check that it opens, a complete card moves, Save succeeds and reopening keeps it.
97
+ Reopen by topic or relative path (`--source-root` is automatic). Never save `#write=`.
98
+ Open the printed URL in browser; `docs/LOCAL-DOCUMENT.md` owns Open, Save and regeneration.
99
+ On a copy outside folder root, check open, whole-card move, Save and reopen.
98
100
  Presentation edits may be retained; changes to labels, identity or relation direction are refused by design.
99
101
  A build proves no viewer opening, saved change or reader understanding; record those separately.
100
102
 
@@ -113,4 +115,4 @@ Return the folder (`.puml`, document, `README.md` with the verified reopen comma
113
115
  inspected PNG and check report; show the PNG itself where the reply can display images. State the source revision, claims
114
116
  state, remaining warnings, checks actually performed and any `Must show` item not shown, with who decided it.
115
117
  A source build is `claims: "unverified"` even when it renders and saves correctly. Human acceptance remains separate.
116
- For a neutral source reproduction, read the [library examples](assets/examples/README.md); research-family examples stay with the research skill.
118
+ Neutral examples: [library examples](assets/examples/README.md); research examples stay with research.
@@ -11,6 +11,7 @@ audience:
11
11
  outputLanguage:
12
12
  Must show: each item the request names -> where the reader sees it; or omitted, and who decided
13
13
  View choice: type/profile and composition, and why; each rejected real alternative and what it hides
14
+ Component checkpoint: approved (<specimen>) | skipped — <reason> | n/a (Pi)
14
15
  Orientation: TB | LR; prefer TB for directed graphs with no required orientation; reason
15
16
  Main path and roles: ordered IDs; entry, steps, result, helpers, records (also in facts.md);
16
17
  or none — <reason> when the view has no ordered stages and no single flow
@@ -26,7 +27,7 @@ Unknowns kept visible:
26
27
  Claims: unverified | accepted research evidence: <link>
27
28
  Open/edit/save/reopen: actual result, or not checked
28
29
  Reader understanding: first answers and separate assessment, or untested
29
- - Reopen: `locus-map view DIAGRAM_FILE` from the target project. For a development checkout, record the working directory and the exact `node scripts/open-map.mjs --document ABSOLUTE_FILE` invocation.
30
+ - Reopen: `locus-map view DIAGRAM_NAME` (or `npx @locus-forge/locus-map view DIAGRAM_NAME`) from the target project root when delivered under `.locus-map/`; for custom destinations outside `.locus-map/`, record the working directory and delivered file path (`locus-map view DELIVERED_FILE`). For an unpublished Map checkout, record `node <checkout>/scripts/locus-map.mjs view ...` with the same target.
30
31
  Next action:
31
32
  ```
32
33