excaliagent 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +106 -2
- package/bin/excaliagent.js +2 -0
- package/dist/server/args.js +52 -0
- package/dist/server/cli.js +100 -0
- package/dist/server/desktop/desktop.js +150 -0
- package/dist/server/desktop/exec.js +27 -0
- package/dist/server/desktop/process-table.js +167 -0
- package/dist/server/http.js +240 -0
- package/dist/server/hub.js +101 -0
- package/dist/server/panes/herdr-client.js +220 -0
- package/dist/server/panes/herdr-clients.js +37 -0
- package/dist/server/panes/herdr.js +248 -0
- package/dist/server/panes/none.js +10 -0
- package/dist/server/panes/types.js +1 -0
- package/dist/server/scene-store.js +61 -0
- package/dist/server/sources/claude.js +292 -0
- package/dist/server/sources/git.js +65 -0
- package/dist/server/sources/log.js +10 -0
- package/dist/server/sources/registry.js +79 -0
- package/dist/server/sources/transcript.js +204 -0
- package/dist/server/sources/types.js +1 -0
- package/dist/shared/types.js +9 -0
- package/dist/web/assets/Assistant-Bold-gm-uSS1B.woff2 +0 -0
- package/dist/web/assets/Assistant-Medium-DrcxCXg3.woff2 +0 -0
- package/dist/web/assets/Assistant-Regular-DVxZuzxb.woff2 +0 -0
- package/dist/web/assets/Assistant-SemiBold-SCI4bEL9.woff2 +0 -0
- package/dist/web/assets/abnfDiagram-VCTEODGH-tmjYj3VY.js +1 -0
- package/dist/web/assets/ar-SA-G6X2FPQ2-8ZGGBDRT.js +10 -0
- package/dist/web/assets/arc-Y1ARJVZ4.js +1 -0
- package/dist/web/assets/architecture-7GRP2DOG-CsvDkWt3.js +1 -0
- package/dist/web/assets/architectureDiagram-5GKGNRK7-Bq-1CDhU.js +36 -0
- package/dist/web/assets/array-BifhSqXX.js +1 -0
- package/dist/web/assets/az-AZ-76LH7QW2-DbdS_q-w.js +1 -0
- package/dist/web/assets/bg-BG-XCXSNQG7-CANqXhG1.js +5 -0
- package/dist/web/assets/blockDiagram-I7D4REHJ-DtYn-xOl.js +129 -0
- package/dist/web/assets/bn-BD-2XOGV67Q-DJdq0B1R.js +5 -0
- package/dist/web/assets/c4Diagram-7LVT6UL2-DW6Pzj1e.js +38 -0
- package/dist/web/assets/ca-ES-6MX7JW3Y-B7pUqerV.js +8 -0
- package/dist/web/assets/channel-gFr9jEgP.js +1 -0
- package/dist/web/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dist/web/assets/chunk-4HAMMTFA-_AKNu1--.js +62 -0
- package/dist/web/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/dist/web/assets/chunk-75Z2AOVW-BoMl8Mqw.js +2 -0
- package/dist/web/assets/chunk-DU6HZSFF-DYHa8ENH.js +127 -0
- package/dist/web/assets/chunk-EIO257PC--adgQBo2.js +22 -0
- package/dist/web/assets/chunk-F27PBJKO-CvQi01qZ.js +1 -0
- package/dist/web/assets/chunk-FOHPRMQF-DD4dKubD.js +161 -0
- package/dist/web/assets/chunk-GMAD6QVW-ojaxPuMG.js +72 -0
- package/dist/web/assets/chunk-GVQU2GXP-DYAeD1IL.js +1 -0
- package/dist/web/assets/chunk-IMKFNOWR-oVPWqbpV.js +231 -0
- package/dist/web/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dist/web/assets/chunk-L3NEJ4N5-BelAXiIN.js +1 -0
- package/dist/web/assets/chunk-OSK3NFVY-CATtjN8l.js +10 -0
- package/dist/web/assets/chunk-P2QGCYS3-CbKPCENJ.js +1 -0
- package/dist/web/assets/chunk-POPQ4Y6H-BfOCSezn.js +1 -0
- package/dist/web/assets/chunk-PWAF6VOD-C7O-JWJt.js +1 -0
- package/dist/web/assets/chunk-SHT3W25Y-BfEpPCTX.js +168 -0
- package/dist/web/assets/chunk-SVP7TREG-CaeKcCSu.js +88 -0
- package/dist/web/assets/chunk-TICWLB2K-Bx6AcLB_.js +206 -0
- package/dist/web/assets/chunk-XXDRQBXY-CnbRkih_.js +1 -0
- package/dist/web/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dist/web/assets/classDiagram-ZZMXUADV-9J2CNLBI.js +1 -0
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-9J2CNLBI.js +1 -0
- package/dist/web/assets/cose-bilkent-JH36ORCC-lWVj4msc.js +1 -0
- package/dist/web/assets/cs-CZ-2BRQDIVT-DF8hZ2mh.js +11 -0
- package/dist/web/assets/cynefin-OW5HDTMX-Dol6Weuo.js +1 -0
- package/dist/web/assets/cynefinDiagram-5FMLGOSQ-CbOJ2lks.js +62 -0
- package/dist/web/assets/cytoscape.esm-BegBNzOV.js +321 -0
- package/dist/web/assets/da-DK-5WZEPLOC-CgPdNz6E.js +5 -0
- package/dist/web/assets/dagre-D7JM2Yhv.js +1 -0
- package/dist/web/assets/dagre-GXQ25YYZ-CcuaBID7.js +4 -0
- package/dist/web/assets/de-DE-XR44H4JA-DaVeYWRc.js +8 -0
- package/dist/web/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/dist/web/assets/diagram-S7CK7UJ4-BR2gIsNx.js +30 -0
- package/dist/web/assets/diagram-UQ7AKVKN-DwSZsV-Z.js +41 -0
- package/dist/web/assets/diagram-VSXAHHWV-BcJpQHbj.js +3 -0
- package/dist/web/assets/diagram-VX7I27RA-CvjRTkwu.js +24 -0
- package/dist/web/assets/diagram-Z3DM3KII-vg0-r_P4.js +24 -0
- package/dist/web/assets/directory-open-01563666-D4xXyWb_.js +1 -0
- package/dist/web/assets/directory-open-4ed118d0-1i309Asm.js +1 -0
- package/dist/web/assets/dist-CumnGVmJ.js +1 -0
- package/dist/web/assets/dist-D-3cz42D.js +62 -0
- package/dist/web/assets/ebnfDiagram-PWID7BFC-DZCaMmMd.js +1 -0
- package/dist/web/assets/el-GR-BZB4AONW-nYncjO-L.js +10 -0
- package/dist/web/assets/en-B4ZKOASM-DqIz0rJz.js +1 -0
- package/dist/web/assets/erDiagram-RLTQ6QDP-DgyrjoaZ.js +99 -0
- package/dist/web/assets/es-ES-U4NZUMDT-e3WeRDLl.js +9 -0
- package/dist/web/assets/eu-ES-A7QVB2H4-CwXv1t13.js +11 -0
- package/dist/web/assets/eventmodeling-NTZA5JFV-DCTWpAwP.js +1 -0
- package/dist/web/assets/fa-IR-HGAKTJCU-D-9plwKu.js +8 -0
- package/dist/web/assets/fi-FI-Z5N7JZ37-BTK1rs8G.js +6 -0
- package/dist/web/assets/file-open-002ab408-BHUWm0Sh.js +1 -0
- package/dist/web/assets/file-open-7c801643-DZtJT5zp.js +1 -0
- package/dist/web/assets/file-save-3189631c-CO9S4HFW.js +1 -0
- package/dist/web/assets/file-save-745eba88-Bwdfz6OZ.js +1 -0
- package/dist/web/assets/flowDiagram-HODETNUW--2QUGuZ7.js +1 -0
- package/dist/web/assets/fr-FR-RHASNOE6-CAuUMPtN.js +9 -0
- package/dist/web/assets/ganttDiagram-EL5Y4UJY-bFfu4BMj.js +292 -0
- package/dist/web/assets/gitGraph-4MIJSDKK-DIl4-oqK.js +1 -0
- package/dist/web/assets/gitGraphDiagram-WWUBYQGX-ho3FT8XP.js +106 -0
- package/dist/web/assets/gl-ES-HMX3MZ6V-DlKPdjtk.js +10 -0
- package/dist/web/assets/graphlib-DS17s2tU.js +1 -0
- package/dist/web/assets/he-IL-6SHJWFNN-CLyP0zBo.js +10 -0
- package/dist/web/assets/hi-IN-IWLTKZ5I-kvhBHNzH.js +4 -0
- package/dist/web/assets/hu-HU-A5ZG7DT2-Dtd-o-RJ.js +7 -0
- package/dist/web/assets/id-ID-SAP4L64H-VZ3IV-8B.js +10 -0
- package/dist/web/assets/image-GAAHSSAO-DWvjHHd3.js +1 -0
- package/dist/web/assets/image-blob-reduce.esm-Fj7y_Tzy.js +2 -0
- package/dist/web/assets/index-B2hGCC2V.js +212 -0
- package/dist/web/assets/index-DtRVLazd.css +1 -0
- package/dist/web/assets/info-A6RAGUB7-DN8pwhKt.js +1 -0
- package/dist/web/assets/infoDiagram-27XIBGKW-i2JHBJKe.js +2 -0
- package/dist/web/assets/init-C-OQMol4.js +1 -0
- package/dist/web/assets/ishikawaDiagram-5VMMS53U-DLLdu9-W.js +70 -0
- package/dist/web/assets/it-IT-JPQ66NNP-6SULWnRA.js +11 -0
- package/dist/web/assets/ja-JP-DBVTYXUO-BbgutQYO.js +8 -0
- package/dist/web/assets/journeyDiagram-3NMN7TZE-DsysKJxX.js +139 -0
- package/dist/web/assets/kaa-6HZHGXH3-Bc6yhZWQ.js +1 -0
- package/dist/web/assets/kab-KAB-ZGHBKWFO-BaICxis-.js +8 -0
- package/dist/web/assets/kanban-definition-UXKFOSKX-w3k_6RhT.js +89 -0
- package/dist/web/assets/katex-DJhrJSbw.js +257 -0
- package/dist/web/assets/kk-KZ-P5N5QNE5-BVsfmPoG.js +1 -0
- package/dist/web/assets/km-KH-HSX4SM5Z-BS1M1bUx.js +11 -0
- package/dist/web/assets/ko-KR-MTYHY66A-C0x16zQm.js +9 -0
- package/dist/web/assets/ku-TR-6OUDTVRD-BWI9z5E8.js +9 -0
- package/dist/web/assets/line-BRXlgUrO.js +1 -0
- package/dist/web/assets/linear-C9iwaMOi.js +1 -0
- package/dist/web/assets/lt-LT-XHIRWOB4-CTDq1zFR.js +3 -0
- package/dist/web/assets/lv-LV-5QDEKY6T-h8b-E15B.js +7 -0
- package/dist/web/assets/mermaid-parser.core-Da_XEVmR.js +7 -0
- package/dist/web/assets/mindmap-definition-YA3MSWOX-DUBdgu2g.js +96 -0
- package/dist/web/assets/mr-IN-CRQNXWMA-dTdkz007.js +13 -0
- package/dist/web/assets/my-MM-5M5IBNSE-CmYwTRil.js +1 -0
- package/dist/web/assets/nb-NO-T6EIAALU-DLLYcK-s.js +10 -0
- package/dist/web/assets/nl-NL-IS3SIHDZ-mtv15Mmm.js +8 -0
- package/dist/web/assets/nn-NO-6E72VCQL-CJDTT3kB.js +8 -0
- package/dist/web/assets/oc-FR-POXYY2M6-DdHJTqH4.js +8 -0
- package/dist/web/assets/ordinal-BDEzSJ7C.js +1 -0
- package/dist/web/assets/pa-IN-N4M65BXN-DxzzhbLu.js +4 -0
- package/dist/web/assets/packet-AYTQ26CC-CzX42SOE.js +1 -0
- package/dist/web/assets/path-fybaL0A-.js +1 -0
- package/dist/web/assets/pegDiagram-XKGWAZYB-1R2Hd3Th.js +1 -0
- package/dist/web/assets/percentages-BXMCSKIN-Br7824d3.js +1 -0
- package/dist/web/assets/pica-CXv_OHDX.js +2 -0
- package/dist/web/assets/pie-WAS4IAKB-DEI2uslz.js +1 -0
- package/dist/web/assets/pieDiagram-E7YTZNPT-DOQnFSrs.js +39 -0
- package/dist/web/assets/pl-PL-T2D74RX3-Dpyab0lI.js +9 -0
- package/dist/web/assets/pt-BR-5N22H2LF-DOGrUA6Y.js +9 -0
- package/dist/web/assets/pt-PT-UZXXM6DQ-DAoNiiOg.js +9 -0
- package/dist/web/assets/quadrantDiagram-AXDQQJYC-CQE1OxRJ.js +7 -0
- package/dist/web/assets/radar-RG4KPBEZ-B-er2ORT.js +1 -0
- package/dist/web/assets/railroad-74A4TZTK-D1Veuu81.js +1 -0
- package/dist/web/assets/railroad-abnf-HS5TGJTU-DTxLo5az.js +1 -0
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-BmP2IZGe.js +1 -0
- package/dist/web/assets/railroad-peg-WCYAUIDC-Do60gMTC.js +1 -0
- package/dist/web/assets/railroadDiagram-O6MQD6OU-5I8Qk1dI.js +1 -0
- package/dist/web/assets/requirementDiagram-BXWQKSXE-CIIM8YmC.js +84 -0
- package/dist/web/assets/ro-RO-JPDTUUEW-DR9yu2MV.js +11 -0
- package/dist/web/assets/rolldown-runtime-COiEfhsA.js +1 -0
- package/dist/web/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/web/assets/roundRect-D01gJrlt.js +1 -0
- package/dist/web/assets/ru-RU-B4JR7IUQ-B9uIhZUd.js +9 -0
- package/dist/web/assets/sankeyDiagram-P5KCCOFB-BdGmiiCQ.js +40 -0
- package/dist/web/assets/sequenceDiagram-WJ2MYXX4-BeCmgCpG.js +162 -0
- package/dist/web/assets/si-LK-N5RQ5JYF-C7DYCsOB.js +1 -0
- package/dist/web/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
- package/dist/web/assets/sk-SK-C5VTKIMK-BbBBLLCs.js +6 -0
- package/dist/web/assets/sl-SI-NN7IZMDC-BIaW2Iuj.js +6 -0
- package/dist/web/assets/src-BWF7jMDv.js +1 -0
- package/dist/web/assets/stateDiagram-D77RDMKH-CmENpSfH.js +1 -0
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-BWgn52cG.js +1 -0
- package/dist/web/assets/subset-shared.chunk-d2GNuFHV.js +1 -0
- package/dist/web/assets/subset-worker.chunk-Bi16Jh4x.js +1 -0
- package/dist/web/assets/sv-SE-XGPEYMSR-D5A1U3nk.js +10 -0
- package/dist/web/assets/swimlanes-42K2YHIH-_ymwQg8o.js +1 -0
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-fzrjtpfS.js +8 -0
- package/dist/web/assets/ta-IN-2NMHFXQM-BDzXUwiE.js +9 -0
- package/dist/web/assets/th-TH-HPSO5L25-DdVnWuWW.js +2 -0
- package/dist/web/assets/timeline-definition-24CTP7MA-CRcZde4k.js +120 -0
- package/dist/web/assets/tr-TR-DEFEU3FU-BQwfGN3o.js +7 -0
- package/dist/web/assets/treeView-Q6P3EWNA-BHZZuSXr.js +1 -0
- package/dist/web/assets/treemap-WGGIJYW6-DAzotEQZ.js +1 -0
- package/dist/web/assets/uk-UA-QMV73CPH-CFYnWqHD.js +6 -0
- package/dist/web/assets/vennDiagram-4TSXK5OY-BsNz9Qnn.js +34 -0
- package/dist/web/assets/vi-VN-M7AON7JQ-DO3BySmm.js +5 -0
- package/dist/web/assets/wardley-WFR3VGLG-Cc2r8Vp8.js +1 -0
- package/dist/web/assets/wardleyDiagram-VM6X3IG4-47UvJO4N.js +78 -0
- package/dist/web/assets/xychartDiagram-S5SC5T6Z-CVl63zr-.js +7 -0
- package/dist/web/assets/zh-CN-LNUGB5OW-DKJ2CF-O.js +10 -0
- package/dist/web/assets/zh-HK-E62DVLB3-DHW8OH5j.js +1 -0
- package/dist/web/assets/zh-TW-RAJ6MFWO-B9cMDifZ.js +9 -0
- package/dist/web/fonts/Assistant/Assistant-Bold.woff2 +0 -0
- package/dist/web/fonts/Assistant/Assistant-Medium.woff2 +0 -0
- package/dist/web/fonts/Assistant/Assistant-Regular.woff2 +0 -0
- package/dist/web/fonts/Assistant/Assistant-SemiBold.woff2 +0 -0
- package/dist/web/fonts/Cascadia/CascadiaCode-Regular.woff2 +0 -0
- package/dist/web/fonts/ComicShanns/ComicShanns-Regular-279a7b317d12eb88de06167bd672b4b4.woff2 +0 -0
- package/dist/web/fonts/ComicShanns/ComicShanns-Regular-6e066e8de2ac57ea9283adb9c24d7f0c.woff2 +0 -0
- package/dist/web/fonts/ComicShanns/ComicShanns-Regular-dc6a8806fa96795d7b3be5026f989a17.woff2 +0 -0
- package/dist/web/fonts/ComicShanns/ComicShanns-Regular-fcb0fc02dcbee4c9846b3e2508668039.woff2 +0 -0
- package/dist/web/fonts/Excalifont/Excalifont-Regular-349fac6ca4700ffec595a7150a0d1e1d.woff2 +0 -0
- package/dist/web/fonts/Excalifont/Excalifont-Regular-3f2c5db56cc93c5a6873b1361d730c16.woff2 +0 -0
- package/dist/web/fonts/Excalifont/Excalifont-Regular-41b173a47b57366892116a575a43e2b6.woff2 +0 -0
- package/dist/web/fonts/Excalifont/Excalifont-Regular-623ccf21b21ef6b3a0d87738f77eb071.woff2 +0 -0
- package/dist/web/fonts/Excalifont/Excalifont-Regular-a88b72a24fb54c9f94e3b5fdaa7481c9.woff2 +0 -0
- package/dist/web/fonts/Excalifont/Excalifont-Regular-b9dcf9d2e50a1eaf42fc664b50a3fd0d.woff2 +0 -0
- package/dist/web/fonts/Excalifont/Excalifont-Regular-be310b9bcd4f1a43f571c46df7809174.woff2 +0 -0
- package/dist/web/fonts/Liberation/LiberationSans-Regular.woff2 +0 -0
- package/dist/web/fonts/Lilita/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYE98RXi4EwSsbg.woff2 +0 -0
- package/dist/web/fonts/Lilita/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYEF8RXi4EwQ.woff2 +0 -0
- package/dist/web/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTA3j6zbXWjgevT5.woff2 +0 -0
- package/dist/web/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTQ3j6zbXWjgeg.woff2 +0 -0
- package/dist/web/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTk3j6zbXWjgevT5.woff2 +0 -0
- package/dist/web/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTo3j6zbXWjgevT5.woff2 +0 -0
- package/dist/web/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTs3j6zbXWjgevT5.woff2 +0 -0
- package/dist/web/fonts/Virgil/Virgil-Regular.woff2 +0 -0
- package/dist/web/index.html +15 -0
- package/package.json +68 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Martin Popovski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,107 @@
|
|
|
1
|
-
#
|
|
1
|
+
# excaliagent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A spatial scratchboard for your Claude Code sessions, on an Excalidraw canvas.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Every session is a card. You drag cards wherever they make sense to you (parked,
|
|
8
|
+
blocked on a colleague, come back to, done) and draw anything around them. The
|
|
9
|
+
app keeps each card's **color and label** in sync with the session and never
|
|
10
|
+
moves, resizes, or edits anything else.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Fix flaky checkout test ← title (handwritten, larger)
|
|
14
|
+
demo-app · fix/flaky ← repo · branch
|
|
15
|
+
needs user: input needed · 2m ← status · what it waits for · last activity
|
|
16
|
+
cache warm 41m ← prompt-cache warmth
|
|
17
|
+
herdr: demo-app › oauth ← herdr workspace › tab
|
|
18
|
+
PR #12 ← last PR link
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Color | Meaning |
|
|
22
|
+
|---|---|
|
|
23
|
+
| red | needs you (input, permission, trust, blocked) |
|
|
24
|
+
| yellow | busy |
|
|
25
|
+
| green | idle, prompt cache still warm: review it before it goes cold |
|
|
26
|
+
| grey | idle, cache cold |
|
|
27
|
+
| dashed, pale | dormant (not running) |
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
## Run
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx excaliagent
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
It starts a server on `127.0.0.1` and opens the board in your browser.
|
|
38
|
+
|
|
39
|
+
- **Live sessions** appear in the *inbox* by themselves. A new board comes with
|
|
40
|
+
lanes next to it (To Do, In Progress, Review, Blocked, Parked, Done, and two
|
|
41
|
+
blank ones to name yourself); they are plain shapes you can rename, move or
|
|
42
|
+
delete. On an older board, add them from the main menu: *Add starter lanes*.
|
|
43
|
+
- **Dormant sessions** are added from the **Sessions** panel (top right).
|
|
44
|
+
- **Double-click a card** to jump to it: a live session focuses its
|
|
45
|
+
[herdr](https://herdr.dev) pane and raises the terminal window (Hyprland,
|
|
46
|
+
Sway). A dormant session is resumed with `claude --resume` in a new herdr
|
|
47
|
+
tab, in the workspace for that repo. Without herdr, the resume command is
|
|
48
|
+
copied instead.
|
|
49
|
+
- **Right-click a card** for an excaliagent section on top of the Excalidraw
|
|
50
|
+
menu: focus or resume, copy the resume command (with or without `cd`), open
|
|
51
|
+
the PR.
|
|
52
|
+
- A **PR link** (GitHub, Bitbucket, GitLab) shows on the card; the card's link
|
|
53
|
+
icon opens it.
|
|
54
|
+
- The board is saved to `$XDG_STATE_HOME/excaliagent/scene.json`
|
|
55
|
+
(default `~/.local/state/excaliagent/`).
|
|
56
|
+
|
|
57
|
+
Options: `--port`, `--no-open`, `--state-dir`, `--claude-dir`, `--no-herdr`, `--no-raise`.
|
|
58
|
+
See `npx excaliagent --help`.
|
|
59
|
+
|
|
60
|
+
## Privacy and security
|
|
61
|
+
|
|
62
|
+
- Reads `~/.claude/sessions/*.json` and the transcript files under
|
|
63
|
+
`~/.claude/projects/` (only metadata lines: title, branch, timestamps, token
|
|
64
|
+
usage, PR links; never message content). Installs no hooks, writes nothing
|
|
65
|
+
outside its state directory.
|
|
66
|
+
- Listens on loopback only. A random token is put into the URL it opens and
|
|
67
|
+
exchanged for an HttpOnly cookie; every request needs it. Requests with a
|
|
68
|
+
foreign `Host` (DNS rebinding) or cross-origin writes are refused.
|
|
69
|
+
- Its only actions: focus a herdr pane, raise the terminal window, and start
|
|
70
|
+
`claude --resume <id>` in a new herdr pane. It never types into a running
|
|
71
|
+
session.
|
|
72
|
+
- The only outside request: Chinese, Japanese or Korean text on the board loads
|
|
73
|
+
Excalidraw's CJK font from esm.sh (it is not bundled, to keep the package
|
|
74
|
+
small). Everything else, including all other fonts, is served locally.
|
|
75
|
+
|
|
76
|
+
## Platforms
|
|
77
|
+
|
|
78
|
+
Linux and macOS. Raising the terminal window after a jump works on Hyprland,
|
|
79
|
+
Sway and macOS. Windows is not supported yet
|
|
80
|
+
([#1](https://github.com/martinkozle/excaliagent/issues/1), contributions welcome).
|
|
81
|
+
|
|
82
|
+
## herdr (optional)
|
|
83
|
+
|
|
84
|
+
If [herdr](https://herdr.dev) is running, cards are linked to panes by matching
|
|
85
|
+
the session's process id to the pane's foreground process. No herdr
|
|
86
|
+
integration or plugin is needed. Tested with herdr 0.9.0 and its protocol 22.
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
The repo ships a Nix flake with Node 24 and Chromium for the browser tests:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
direnv allow # or: nix develop
|
|
94
|
+
npm install
|
|
95
|
+
npm test # unit tests (vitest)
|
|
96
|
+
npm run test:e2e # browser tests (playwright) against a mock Claude home
|
|
97
|
+
npm run demo # the board with a seeded, synthetic set of sessions
|
|
98
|
+
npm run dev # server + Vite hot reload against your real ~/.claude
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Tests never read your real `~/.claude` or talk to your running herdr:
|
|
102
|
+
`test/mock-claude.ts` seeds a throwaway Claude home with dummy processes, and the
|
|
103
|
+
herdr tests start an isolated `herdr server` with its own temp home and socket.
|
|
104
|
+
A privacy test fails if any fixture contains this machine's home path or user
|
|
105
|
+
name.
|
|
106
|
+
|
|
107
|
+
Docs: [product](docs/product.md), [design](docs/design.md), [roadmap](docs/roadmap.md). Agents start at [AGENTS.md](AGENTS.md).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
export const USAGE = `Usage: excaliagent [options]
|
|
3
|
+
|
|
4
|
+
A spatial Excalidraw board for your Claude Code sessions.
|
|
5
|
+
|
|
6
|
+
Options:
|
|
7
|
+
--port <n> Port on 127.0.0.1 (default: random free port)
|
|
8
|
+
--no-open Do not open the browser, just print the URL
|
|
9
|
+
--state-dir <dir> Where scene.json lives (default: $XDG_STATE_HOME/excaliagent)
|
|
10
|
+
--claude-dir <dir> Claude Code home (default: ~/.claude)
|
|
11
|
+
--no-herdr Do not link sessions to herdr panes
|
|
12
|
+
--no-raise Focus the herdr pane but do not raise its terminal window
|
|
13
|
+
(raising supports Hyprland, Sway and macOS)
|
|
14
|
+
--dev Serve the frontend through Vite with hot reload
|
|
15
|
+
-h, --help Show this help
|
|
16
|
+
-v, --version Show the version
|
|
17
|
+
`;
|
|
18
|
+
export function parseCliArgs(argv) {
|
|
19
|
+
const { values } = parseArgs({
|
|
20
|
+
args: argv,
|
|
21
|
+
strict: true,
|
|
22
|
+
allowNegative: true,
|
|
23
|
+
options: {
|
|
24
|
+
port: { type: "string" },
|
|
25
|
+
open: { type: "boolean", default: true },
|
|
26
|
+
dev: { type: "boolean", default: false },
|
|
27
|
+
herdr: { type: "boolean", default: true },
|
|
28
|
+
raise: { type: "boolean", default: true },
|
|
29
|
+
"state-dir": { type: "string" },
|
|
30
|
+
"claude-dir": { type: "string" },
|
|
31
|
+
help: { type: "boolean", short: "h", default: false },
|
|
32
|
+
version: { type: "boolean", short: "v", default: false },
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
let port = 0;
|
|
36
|
+
if (values.port !== undefined) {
|
|
37
|
+
port = Number(values.port);
|
|
38
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
39
|
+
throw new Error(`invalid --port: ${values.port}`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
port,
|
|
43
|
+
open: values.open,
|
|
44
|
+
dev: values.dev,
|
|
45
|
+
herdr: values.herdr,
|
|
46
|
+
raise: values.raise,
|
|
47
|
+
stateDir: values["state-dir"],
|
|
48
|
+
claudeDir: values["claude-dir"],
|
|
49
|
+
help: values.help,
|
|
50
|
+
version: values.version,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { parseCliArgs, USAGE } from "./args.js";
|
|
7
|
+
import { createHub } from "./hub.js";
|
|
8
|
+
import { createAppServer } from "./http.js";
|
|
9
|
+
import { createDesktop } from "./desktop/desktop.js";
|
|
10
|
+
import { createHerdrLink, createNoPaneLink } from "./panes/herdr.js";
|
|
11
|
+
import { createSceneStore, defaultStateDir } from "./scene-store.js";
|
|
12
|
+
import { createClaudeSource } from "./sources/claude.js";
|
|
13
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
// src/server or dist/server → package root
|
|
15
|
+
const root = join(here, "..", "..");
|
|
16
|
+
function openBrowser(url) {
|
|
17
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
18
|
+
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
19
|
+
try {
|
|
20
|
+
const child = spawn(cmd, args, { detached: true, stdio: "ignore" });
|
|
21
|
+
child.on("error", () => { });
|
|
22
|
+
child.unref();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// printing the URL is enough
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function main(args) {
|
|
29
|
+
const token = randomBytes(24).toString("base64url");
|
|
30
|
+
const source = createClaudeSource({ claudeDir: args.claudeDir });
|
|
31
|
+
const desktop = args.herdr && args.raise ? createDesktop({ env: process.env }) : undefined;
|
|
32
|
+
const panes = args.herdr ? createHerdrLink({ desktop }) : createNoPaneLink();
|
|
33
|
+
const hub = createHub({ source, panes });
|
|
34
|
+
await hub.start();
|
|
35
|
+
const scenes = createSceneStore(args.stateDir ?? defaultStateDir());
|
|
36
|
+
let middleware;
|
|
37
|
+
let closeVite = async () => { };
|
|
38
|
+
const server = createAppServer({
|
|
39
|
+
hub,
|
|
40
|
+
scenes,
|
|
41
|
+
token,
|
|
42
|
+
webRoot: join(root, "dist", "web"),
|
|
43
|
+
get middleware() {
|
|
44
|
+
return middleware;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if (args.dev) {
|
|
48
|
+
const { createServer } = await import("vite");
|
|
49
|
+
const vite = await createServer({
|
|
50
|
+
configFile: join(root, "vite.config.ts"),
|
|
51
|
+
server: { middlewareMode: true, hmr: { server: server.server } },
|
|
52
|
+
appType: "spa",
|
|
53
|
+
});
|
|
54
|
+
middleware = vite.middlewares;
|
|
55
|
+
closeVite = () => vite.close();
|
|
56
|
+
}
|
|
57
|
+
await server.listen(args.port);
|
|
58
|
+
const url = `http://127.0.0.1:${server.port}/?token=${token}`;
|
|
59
|
+
console.log(`excaliagent ${args.dev ? "(dev) " : ""}listening on http://127.0.0.1:${server.port}`);
|
|
60
|
+
console.log(`scene: ${scenes.path}`);
|
|
61
|
+
console.log(`herdr: ${panes.available() ? "connected" : args.herdr ? "not running (will retry)" : "disabled"}`);
|
|
62
|
+
if (args.herdr)
|
|
63
|
+
console.log(`raise window on focus: ${!desktop ? "off (--no-raise)" : desktop.kind === "none" ? "unsupported here" : desktop.kind}`);
|
|
64
|
+
console.log(`open: ${url}`);
|
|
65
|
+
if (args.open)
|
|
66
|
+
openBrowser(url);
|
|
67
|
+
let stopping = false;
|
|
68
|
+
const stop = async () => {
|
|
69
|
+
if (stopping)
|
|
70
|
+
process.exit(1);
|
|
71
|
+
stopping = true;
|
|
72
|
+
hub.stop();
|
|
73
|
+
panes.close();
|
|
74
|
+
await closeVite();
|
|
75
|
+
await server.close();
|
|
76
|
+
process.exit(0);
|
|
77
|
+
};
|
|
78
|
+
process.on("SIGINT", stop);
|
|
79
|
+
process.on("SIGTERM", stop);
|
|
80
|
+
}
|
|
81
|
+
let args;
|
|
82
|
+
try {
|
|
83
|
+
args = parseCliArgs(process.argv.slice(2));
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error(`excaliagent: ${err.message}\n\n${USAGE}`);
|
|
87
|
+
process.exit(2);
|
|
88
|
+
}
|
|
89
|
+
if (args.help) {
|
|
90
|
+
console.log(USAGE);
|
|
91
|
+
}
|
|
92
|
+
else if (args.version) {
|
|
93
|
+
console.log(JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
main(args).catch((err) => {
|
|
97
|
+
console.error("excaliagent:", err);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raise the desktop window that hosts a process (e.g. the terminal running a
|
|
3
|
+
* herdr client), so focusing a pane also brings its terminal to the front.
|
|
4
|
+
*
|
|
5
|
+
* Walks each candidate pid's ancestors through a ProcessTable and acts on the
|
|
6
|
+
* first ancestor that is a window / app:
|
|
7
|
+
* - Linux + Hyprland: `hyprctl clients -j` → `hyprctl dispatch focuswindow address:<addr>`
|
|
8
|
+
* - Linux + Sway: `swaymsg -t get_tree` → `swaymsg [pid=N] focus`
|
|
9
|
+
* - macOS: first ancestor whose executable lives in an `.app` bundle →
|
|
10
|
+
* `open -a <bundle>` (activates the app; no Accessibility permission).
|
|
11
|
+
* Unverified on real hardware.
|
|
12
|
+
* - anything else: no-op.
|
|
13
|
+
* Never throws; raise() resolves false when nothing was raised.
|
|
14
|
+
*/
|
|
15
|
+
import { defaultExec, defaultLog, describeExecFailure, logOnce } from "./exec.js";
|
|
16
|
+
import { createProcessTable } from "./process-table.js";
|
|
17
|
+
export { defaultExec };
|
|
18
|
+
/** pid, then its parents up to (excluding) init/launchd. */
|
|
19
|
+
async function ancestry(table, pid) {
|
|
20
|
+
const chain = [];
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
let cur = pid;
|
|
23
|
+
while (cur !== undefined && cur > 1 && !seen.has(cur) && chain.length < 64) {
|
|
24
|
+
seen.add(cur);
|
|
25
|
+
chain.push(cur);
|
|
26
|
+
cur = await table.parent(cur);
|
|
27
|
+
}
|
|
28
|
+
return chain;
|
|
29
|
+
}
|
|
30
|
+
function windowManager(listWindows, focus) {
|
|
31
|
+
return {
|
|
32
|
+
async prepare() {
|
|
33
|
+
const windows = await listWindows();
|
|
34
|
+
return async (pid) => windows.get(pid);
|
|
35
|
+
},
|
|
36
|
+
focus,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function hyprland(exec, timeout) {
|
|
40
|
+
return windowManager(async () => {
|
|
41
|
+
const { stdout } = await exec("hyprctl", ["clients", "-j"], { timeout });
|
|
42
|
+
const out = new Map();
|
|
43
|
+
for (const c of JSON.parse(stdout)) {
|
|
44
|
+
if (typeof c.pid === "number" && typeof c.address === "string" && !out.has(c.pid))
|
|
45
|
+
out.set(c.pid, c.address);
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}, async (address) => {
|
|
49
|
+
await exec("hyprctl", ["dispatch", "focuswindow", `address:${address}`], { timeout });
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function sway(exec, timeout) {
|
|
53
|
+
return windowManager(async () => {
|
|
54
|
+
const { stdout } = await exec("swaymsg", ["-t", "get_tree"], { timeout });
|
|
55
|
+
const out = new Map();
|
|
56
|
+
const walk = (n) => {
|
|
57
|
+
if (typeof n.pid === "number")
|
|
58
|
+
out.set(n.pid, String(n.pid));
|
|
59
|
+
for (const c of [...(n.nodes ?? []), ...(n.floating_nodes ?? [])])
|
|
60
|
+
walk(c);
|
|
61
|
+
};
|
|
62
|
+
walk(JSON.parse(stdout));
|
|
63
|
+
return out;
|
|
64
|
+
}, async (pid) => {
|
|
65
|
+
await exec("swaymsg", [`[pid=${pid}]`, "focus"], { timeout });
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Outermost `.app` bundle containing an executable path, e.g. /Applications/kitty.app. */
|
|
69
|
+
export function appBundleOf(exe) {
|
|
70
|
+
const m = /^(\/.*?\.app)\//.exec(exe);
|
|
71
|
+
return m?.[1];
|
|
72
|
+
}
|
|
73
|
+
function macos(exec, timeout, table, log) {
|
|
74
|
+
const once = logOnce(log);
|
|
75
|
+
return {
|
|
76
|
+
async prepare() {
|
|
77
|
+
return async (pid) => {
|
|
78
|
+
const exe = await table.exe(pid);
|
|
79
|
+
return exe ? appBundleOf(exe) : undefined;
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
async focus(bundle) {
|
|
83
|
+
const args = ["-a", bundle];
|
|
84
|
+
try {
|
|
85
|
+
await exec("open", args, { timeout });
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
once(`open:${bundle}`, `raise: ${describeExecFailure("open", args, e)}`);
|
|
89
|
+
throw e;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
async notFound(chains) {
|
|
93
|
+
const shown = await Promise.all(chains.map(async (chain) => (await Promise.all(chain.map(async (p) => `${p} ${(await table.exe(p)) ?? "?"}`))).join(" <- ")));
|
|
94
|
+
once("no-app", `raise: no .app bundle among the ancestors of herdr client(s): ${shown.join("; ")}`);
|
|
95
|
+
},
|
|
96
|
+
noPids() {
|
|
97
|
+
once("no-pids", "raise: no herdr client process found (is herdr running in a terminal on this Mac?)");
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function createDesktop(opts = {}) {
|
|
102
|
+
const { platform = process.platform, env = process.env, exec = defaultExec, timeoutMs = 2000 } = opts;
|
|
103
|
+
const table = opts.table ?? createProcessTable({ platform, procRoot: opts.procRoot, exec, timeoutMs, log: opts.log });
|
|
104
|
+
const log = opts.log ?? defaultLog;
|
|
105
|
+
const kind = platform === "darwin"
|
|
106
|
+
? "macos"
|
|
107
|
+
: platform === "linux" && env.HYPRLAND_INSTANCE_SIGNATURE
|
|
108
|
+
? "hyprland"
|
|
109
|
+
: platform === "linux" && env.SWAYSOCK
|
|
110
|
+
? "sway"
|
|
111
|
+
: "none";
|
|
112
|
+
const raiser = kind === "macos"
|
|
113
|
+
? macos(exec, timeoutMs, table, log)
|
|
114
|
+
: kind === "hyprland"
|
|
115
|
+
? hyprland(exec, timeoutMs)
|
|
116
|
+
: kind === "sway"
|
|
117
|
+
? sway(exec, timeoutMs)
|
|
118
|
+
: undefined;
|
|
119
|
+
return {
|
|
120
|
+
kind,
|
|
121
|
+
async raise(pids) {
|
|
122
|
+
if (!raiser)
|
|
123
|
+
return false;
|
|
124
|
+
if (pids.length === 0) {
|
|
125
|
+
raiser.noPids?.();
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const targetOf = await raiser.prepare();
|
|
130
|
+
const chains = [];
|
|
131
|
+
for (const pid of pids) {
|
|
132
|
+
const chain = await ancestry(table, pid);
|
|
133
|
+
chains.push(chain);
|
|
134
|
+
for (const p of chain) {
|
|
135
|
+
const target = await targetOf(p);
|
|
136
|
+
if (target !== undefined) {
|
|
137
|
+
await raiser.focus(target);
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
await raiser.notFound?.(chains);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// no compositor, timeout, bad output: just don't raise
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
export const defaultExec = (file, args, opts) => new Promise((resolve, reject) => {
|
|
3
|
+
execFile(file, args, { timeout: opts.timeout, maxBuffer: 16 << 20, encoding: "utf8" }, (err, stdout, stderr) => {
|
|
4
|
+
if (err)
|
|
5
|
+
reject(Object.assign(err, { stderr }));
|
|
6
|
+
else
|
|
7
|
+
resolve({ stdout });
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
/** "`cmd args` failed: <stderr, else message>" for logs. */
|
|
11
|
+
export function describeExecFailure(file, args, err) {
|
|
12
|
+
const e = err;
|
|
13
|
+
const stderr = typeof e?.stderr === "string" ? e.stderr.trim() : "";
|
|
14
|
+
const detail = stderr || (typeof e?.message === "string" ? e.message : String(err));
|
|
15
|
+
return `\`${[file, ...args].join(" ")}\` failed: ${detail}`;
|
|
16
|
+
}
|
|
17
|
+
export const defaultLog = (m) => console.warn(`excaliagent: ${m}`);
|
|
18
|
+
/** Wraps a logger so each key is reported at most once. */
|
|
19
|
+
export function logOnce(log) {
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
return (key, message) => {
|
|
22
|
+
if (seen.has(key))
|
|
23
|
+
return;
|
|
24
|
+
seen.add(key);
|
|
25
|
+
log(message);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal process information, portable across Linux and macOS.
|
|
3
|
+
*
|
|
4
|
+
* - linux: /proc (stat, comm, cmdline, environ, exe). No subprocesses.
|
|
5
|
+
* - darwin: `ps -axww -o pid=,ppid=,comm=` (comm is the full executable path
|
|
6
|
+
* on macOS), `ps -ww -o command= -p N` for argv and `ps -E -ww -o command= -p N`
|
|
7
|
+
* for the environment (own-user processes only; -E = "display the environment"). argv/env are split on
|
|
8
|
+
* whitespace, so arguments or values containing spaces are approximate.
|
|
9
|
+
* Unverified on real hardware; CI runs the parsers against fixtures.
|
|
10
|
+
* - anything else: an empty table.
|
|
11
|
+
* Every method fails soft (empty / undefined).
|
|
12
|
+
*/
|
|
13
|
+
import { readdir, readFile, readlink } from "node:fs/promises";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { defaultExec, defaultLog, describeExecFailure, logOnce } from "./exec.js";
|
|
16
|
+
const read = (p) => readFile(p, "utf8").catch(() => undefined);
|
|
17
|
+
function parseStat(stat) {
|
|
18
|
+
const open = stat.indexOf("(");
|
|
19
|
+
const close = stat.lastIndexOf(")");
|
|
20
|
+
if (open < 0 || close < open)
|
|
21
|
+
return undefined;
|
|
22
|
+
const ppid = Number(stat.slice(close + 1).trim().split(/\s+/)[1]);
|
|
23
|
+
return Number.isInteger(ppid) ? { comm: stat.slice(open + 1, close), ppid } : undefined;
|
|
24
|
+
}
|
|
25
|
+
function linuxTable(procRoot) {
|
|
26
|
+
const stat = async (pid) => {
|
|
27
|
+
const s = await read(join(procRoot, String(pid), "stat"));
|
|
28
|
+
return s === undefined ? undefined : parseStat(s);
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
async list() {
|
|
32
|
+
let entries;
|
|
33
|
+
try {
|
|
34
|
+
entries = await readdir(procRoot);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
const out = await Promise.all(entries
|
|
40
|
+
.filter((e) => /^\d+$/.test(e))
|
|
41
|
+
.map(async (e) => {
|
|
42
|
+
const s = await stat(Number(e));
|
|
43
|
+
return s ? { pid: Number(e), ppid: s.ppid, comm: s.comm } : undefined;
|
|
44
|
+
}));
|
|
45
|
+
return out.filter((p) => p !== undefined);
|
|
46
|
+
},
|
|
47
|
+
async parent(pid) {
|
|
48
|
+
const ppid = (await stat(pid))?.ppid;
|
|
49
|
+
return ppid !== undefined && ppid > 0 ? ppid : undefined;
|
|
50
|
+
},
|
|
51
|
+
async argv(pid) {
|
|
52
|
+
return (await read(join(procRoot, String(pid), "cmdline")))?.split("\0").filter(Boolean);
|
|
53
|
+
},
|
|
54
|
+
async env(pid) {
|
|
55
|
+
const environ = await read(join(procRoot, String(pid), "environ"));
|
|
56
|
+
if (environ === undefined)
|
|
57
|
+
return undefined;
|
|
58
|
+
const env = {};
|
|
59
|
+
for (const kv of environ.split("\0")) {
|
|
60
|
+
const i = kv.indexOf("=");
|
|
61
|
+
if (i > 0)
|
|
62
|
+
env[kv.slice(0, i)] = kv.slice(i + 1);
|
|
63
|
+
}
|
|
64
|
+
return env;
|
|
65
|
+
},
|
|
66
|
+
async exe(pid) {
|
|
67
|
+
return readlink(join(procRoot, String(pid), "exe")).catch(() => undefined);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Lines of `ps -o pid=,ppid=,comm=`; comm runs to end of line (may contain spaces). */
|
|
72
|
+
export function parsePsList(out) {
|
|
73
|
+
const list = [];
|
|
74
|
+
for (const line of out.split("\n")) {
|
|
75
|
+
const m = /^\s*(\d+)\s+(\d+)\s(.*)$/.exec(line);
|
|
76
|
+
if (m)
|
|
77
|
+
list.push({ pid: Number(m[1]), ppid: Number(m[2]), comm: m[3].trim() });
|
|
78
|
+
}
|
|
79
|
+
return list;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Environment from `ps -E -ww -o command=`: the command line followed by
|
|
83
|
+
* KEY=VALUE pairs. The known argv prefix is skipped; a token that is not
|
|
84
|
+
* KEY=VALUE continues the previous value (values with spaces).
|
|
85
|
+
*/
|
|
86
|
+
export function parsePsEnv(out, argv = []) {
|
|
87
|
+
let rest = out.trim();
|
|
88
|
+
const cmd = argv.join(" ");
|
|
89
|
+
if (cmd && rest.startsWith(cmd))
|
|
90
|
+
rest = rest.slice(cmd.length);
|
|
91
|
+
else if (argv.length > 0)
|
|
92
|
+
return {};
|
|
93
|
+
const env = {};
|
|
94
|
+
let last;
|
|
95
|
+
for (const tok of rest.split(/\s+/).filter(Boolean)) {
|
|
96
|
+
const m = /^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.exec(tok);
|
|
97
|
+
if (m) {
|
|
98
|
+
last = m[1];
|
|
99
|
+
env[last] = m[2];
|
|
100
|
+
}
|
|
101
|
+
else if (last !== undefined) {
|
|
102
|
+
env[last] += " " + tok;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return env;
|
|
106
|
+
}
|
|
107
|
+
function darwinTable(exec, timeout, cacheMs, log) {
|
|
108
|
+
const once = logOnce(log);
|
|
109
|
+
const ps = async (args, key) => {
|
|
110
|
+
try {
|
|
111
|
+
return (await exec("ps", args, { timeout })).stdout;
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
once(key, `process table: ${describeExecFailure("ps", args, e)}`);
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
let cached;
|
|
119
|
+
const list = () => {
|
|
120
|
+
if (!cached || Date.now() - cached.at > cacheMs) {
|
|
121
|
+
const listing = ps(["-axww", "-o", "pid=,ppid=,comm="], "list").then((out) => (out === undefined ? [] : parsePsList(out)));
|
|
122
|
+
cached = { at: Date.now(), list: listing };
|
|
123
|
+
}
|
|
124
|
+
return cached.list;
|
|
125
|
+
};
|
|
126
|
+
// A process that exited meanwhile also makes ps fail: not worth a log line each.
|
|
127
|
+
const argv = async (pid) => {
|
|
128
|
+
const out = await ps(["-ww", "-o", "command=", "-p", String(pid)], "argv");
|
|
129
|
+
const parts = out?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
130
|
+
return parts.length > 0 ? parts : undefined;
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
list,
|
|
134
|
+
async parent(pid) {
|
|
135
|
+
const ppid = (await list()).find((p) => p.pid === pid)?.ppid;
|
|
136
|
+
return ppid !== undefined && ppid > 0 ? ppid : undefined;
|
|
137
|
+
},
|
|
138
|
+
argv,
|
|
139
|
+
async env(pid) {
|
|
140
|
+
const args = await argv(pid);
|
|
141
|
+
if (!args)
|
|
142
|
+
return undefined;
|
|
143
|
+
const out = await ps(["-E", "-ww", "-o", "command=", "-p", String(pid)], "env");
|
|
144
|
+
return out === undefined ? undefined : parsePsEnv(out, args);
|
|
145
|
+
},
|
|
146
|
+
async exe(pid) {
|
|
147
|
+
const comm = (await list()).find((p) => p.pid === pid)?.comm;
|
|
148
|
+
return comm?.startsWith("/") ? comm : undefined;
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const emptyTable = {
|
|
153
|
+
list: async () => [],
|
|
154
|
+
parent: async () => undefined,
|
|
155
|
+
argv: async () => undefined,
|
|
156
|
+
env: async () => undefined,
|
|
157
|
+
exe: async () => undefined,
|
|
158
|
+
};
|
|
159
|
+
export function createProcessTable(opts = {}) {
|
|
160
|
+
const { platform = process.platform, procRoot = "/proc", exec = defaultExec, timeoutMs = 2000, cacheMs = 1000 } = opts;
|
|
161
|
+
const log = opts.log ?? defaultLog;
|
|
162
|
+
if (platform === "linux")
|
|
163
|
+
return linuxTable(procRoot);
|
|
164
|
+
if (platform === "darwin")
|
|
165
|
+
return darwinTable(exec, timeoutMs, cacheMs, log);
|
|
166
|
+
return emptyTable;
|
|
167
|
+
}
|