@sma1lboy/rove 0.9.108 → 0.9.147
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/README.md +0 -1
- package/dist/cli/chunk-003tvywc.js +3 -0
- package/dist/cli/chunk-0m9j3yap.js +7 -0
- package/dist/cli/chunk-0r8333z3.js +3 -0
- package/dist/cli/chunk-0sm2k04y.js +3 -0
- package/dist/cli/chunk-0vmrteyg.js +3 -0
- package/dist/cli/chunk-0vy8351p.js +18 -0
- package/dist/cli/chunk-13s8rnk5.js +3 -0
- package/dist/cli/chunk-1kktfmtg.js +4 -0
- package/dist/cli/chunk-1rkb0j1j.js +3 -0
- package/dist/cli/chunk-1tx1s5v6.js +2 -0
- package/dist/cli/chunk-20pt9yqh.js +4 -0
- package/dist/cli/chunk-2brn8e1y.js +3 -0
- package/dist/cli/chunk-2fypr41w.js +3 -0
- package/dist/cli/chunk-2jxdzw4r.js +3 -0
- package/dist/cli/chunk-2pqqvse3.js +2 -0
- package/dist/cli/chunk-3bfm4hrs.js +3 -0
- package/dist/cli/chunk-3ry6prwn.js +3 -0
- package/dist/cli/chunk-3ztek08w.js +4 -0
- package/dist/cli/chunk-49s2zc0h.js +8 -0
- package/dist/cli/chunk-4wwx51m5.js +3 -0
- package/dist/cli/chunk-5bn91n19.js +3 -0
- package/dist/cli/chunk-5c3d1y0r.js +2 -0
- package/dist/cli/chunk-5hhvrvgm.js +8 -0
- package/dist/cli/chunk-6dn6h640.js +3 -0
- package/dist/cli/chunk-6frfschk.js +2 -0
- package/dist/cli/chunk-6rkc7efm.js +5 -0
- package/dist/cli/chunk-6xppe9bj.js +3 -0
- package/dist/cli/chunk-6zwg6me2.js +4 -0
- package/dist/cli/chunk-764bsyb0.js +1 -0
- package/dist/cli/chunk-79gqh5p2.js +5 -0
- package/dist/cli/chunk-7nhdvr5v.js +4 -0
- package/dist/cli/chunk-7q67dz4c.js +3 -0
- package/dist/cli/chunk-7ydwn358.js +3 -0
- package/dist/cli/chunk-86j25g7y.js +7 -0
- package/dist/cli/chunk-88qjhytd.js +12 -0
- package/dist/cli/chunk-8arm7k43.js +69 -0
- package/dist/cli/chunk-8ddjfc2v.js +4 -0
- package/dist/cli/chunk-8r1shxz0.js +16 -0
- package/dist/cli/chunk-99devyxr.js +2 -0
- package/dist/cli/chunk-9c1e5z6a.js +3 -0
- package/dist/cli/chunk-9n458sdy.js +2 -0
- package/dist/cli/chunk-aq912vvw.js +3 -0
- package/dist/cli/chunk-arf294te.js +2 -0
- package/dist/cli/chunk-awsawfrm.js +2 -0
- package/dist/cli/chunk-aynx3d2a.js +2 -0
- package/dist/cli/chunk-b99tf0jr.js +3 -0
- package/dist/cli/chunk-bdbgmjt7.js +3 -0
- package/dist/cli/chunk-c6mthex1.js +5 -0
- package/dist/cli/chunk-cb0pgyq1.js +8 -0
- package/dist/cli/chunk-cb2fpajx.js +3 -0
- package/dist/cli/chunk-cehhk94g.js +2 -0
- package/dist/cli/chunk-d4bqay6d.js +9 -0
- package/dist/cli/chunk-dcb59tsn.js +2 -0
- package/dist/cli/chunk-df7qe9y7.js +4 -0
- package/dist/cli/chunk-dkxhmj9k.js +25 -0
- package/dist/cli/chunk-dnb2bmtb.js +3 -0
- package/dist/cli/chunk-dqndd97s.js +7 -0
- package/dist/cli/chunk-dvcb6mk4.js +3 -0
- package/dist/cli/chunk-dw853n4w.js +3 -0
- package/dist/cli/chunk-dwsgeq06.js +15 -0
- package/dist/cli/chunk-e1g9mvww.js +11 -0
- package/dist/cli/chunk-e3ye4kmk.js +2 -0
- package/dist/cli/chunk-ef11h2am.js +3 -0
- package/dist/cli/chunk-ef39ym8f.js +3 -0
- package/dist/cli/chunk-ewdhz3dv.js +2 -0
- package/dist/cli/chunk-f6zsej8e.js +3 -0
- package/dist/cli/chunk-fe34e0w7.js +28 -0
- package/dist/cli/chunk-g1ybdgad.js +25 -0
- package/dist/cli/chunk-gbasmvsc.js +4 -0
- package/dist/cli/chunk-gjf604bb.js +3 -0
- package/dist/cli/chunk-gm3vj0fv.js +5 -0
- package/dist/cli/chunk-grh6dvfv.js +5 -0
- package/dist/cli/chunk-gwcneg6c.js +2 -0
- package/dist/cli/chunk-h5j8b87f.js +2 -0
- package/dist/cli/chunk-h79zfebh.js +7 -0
- package/dist/cli/chunk-h82kzdsn.js +3 -0
- package/dist/cli/chunk-hape5vwj.js +3 -0
- package/dist/cli/chunk-hg5x2wr0.js +3 -0
- package/dist/cli/chunk-hgq2gtxx.js +4 -0
- package/dist/cli/chunk-j4xfsn9g.js +5 -0
- package/dist/cli/chunk-j9g1m4dy.js +2 -0
- package/dist/cli/chunk-jdbfawrm.js +3 -0
- package/dist/cli/chunk-jsss3ze7.js +11 -0
- package/dist/cli/chunk-jvssy49v.js +2 -0
- package/dist/cli/chunk-jvxh93nz.js +3 -0
- package/dist/cli/chunk-jyv82gf0.js +258 -0
- package/dist/cli/chunk-k3ksts6g.js +3 -0
- package/dist/cli/chunk-kdrrw9tm.js +2 -0
- package/dist/cli/chunk-kg11c1py.js +3 -0
- package/dist/cli/chunk-kwe61yx7.js +3 -0
- package/dist/cli/chunk-mb5m7ex7.js +2 -0
- package/dist/cli/chunk-mfqjdpd8.js +2 -0
- package/dist/cli/chunk-mjvq39gf.js +4 -0
- package/dist/cli/chunk-mrwee8sj.js +3 -0
- package/dist/cli/chunk-my20q579.js +3 -0
- package/dist/cli/chunk-myfjt6dw.js +7 -0
- package/dist/cli/chunk-nceh1q3d.js +12 -0
- package/dist/cli/chunk-ncsgawg7.js +2 -0
- package/dist/cli/chunk-nm6adny4.js +4 -0
- package/dist/cli/chunk-np07kccr.js +4 -0
- package/dist/cli/chunk-p56s3ekm.js +3 -0
- package/dist/cli/chunk-p5spmf7e.js +2 -0
- package/dist/cli/chunk-p7kztgsd.js +4 -0
- package/dist/cli/chunk-pdh5w4ht.js +3 -0
- package/dist/cli/chunk-pdj8kqa1.js +74 -0
- package/dist/cli/chunk-psx9tk3x.js +4 -0
- package/dist/cli/chunk-pw6yfj10.js +3 -0
- package/dist/cli/chunk-q6579rbz.js +3 -0
- package/dist/cli/chunk-q7dr9eh6.js +3 -0
- package/dist/cli/chunk-q9x6d0k6.js +3 -0
- package/dist/cli/chunk-qkehg2c1.js +3 -0
- package/dist/cli/chunk-qtke4x42.js +3 -0
- package/dist/cli/chunk-rgcv1wcs.js +4 -0
- package/dist/cli/chunk-rxvbm4vt.js +7 -0
- package/dist/cli/chunk-ryhrw647.js +3 -0
- package/dist/cli/chunk-s76r56rj.js +3 -0
- package/dist/cli/chunk-sdyzxayr.js +3 -0
- package/dist/cli/chunk-svpn3av1.js +3 -0
- package/dist/cli/chunk-v5893dx3.js +2 -0
- package/dist/cli/chunk-vapjtyv9.js +7 -0
- package/dist/cli/chunk-vkch2spv.js +33 -0
- package/dist/cli/chunk-vpzvcxc1.js +3 -0
- package/dist/cli/chunk-vws0j65e.js +4 -0
- package/dist/cli/chunk-vyb5a2rh.js +4 -0
- package/dist/cli/chunk-w298ayjc.js +3 -0
- package/dist/cli/chunk-w48zjgxv.js +9 -0
- package/dist/cli/chunk-w5xy83ze.js +2 -0
- package/dist/cli/chunk-wpgmq5z6.js +106 -0
- package/dist/cli/chunk-wqfp8d9w.js +3 -0
- package/dist/cli/chunk-x760j10f.js +3 -0
- package/dist/cli/chunk-xbc3gcry.js +2 -0
- package/dist/cli/chunk-xy8be792.js +3 -0
- package/dist/cli/chunk-yhcz2d2r.js +34 -0
- package/dist/cli/chunk-yk2ha5yj.js +3 -0
- package/dist/cli/chunk-ykvk2546.js +3 -0
- package/dist/cli/chunk-ympakh8w.js +6 -0
- package/dist/cli/chunk-zb56ck5f.js +3 -0
- package/dist/cli/chunk-zwzkve1e.js +2 -0
- package/dist/cli/chunk-zy6vgjdp.js +19 -0
- package/dist/cli/index.js +15 -845
- package/dist/cli/kobe-run.js +1 -853
- package/dist/cli/kobe.js +6 -6
- package/dist/cli/pty-host-node.mjs +190 -52
- package/dist/cli/rove-run.js +1 -853
- package/dist/cli/rove.js +6 -6
- package/dist/skills/rove/SKILL.md +29 -10
- package/dist/skills/rove/references/api-flags.md +35 -13
- package/dist/web-ui/assets/{ChatTerminal-BshL3M8G.js → harness-CYGJ4uoR.js} +19 -20
- package/dist/web-ui/assets/index-BTJ-X_4s.js +10 -0
- package/dist/web-ui/assets/index-Cs2vPLNB.css +1 -0
- package/dist/web-ui/index.html +2 -9
- package/dist/web-ui/pty-server.mjs +4 -5
- package/package.json +2 -2
- package/dist/web-ui/assets/AppShell-BGRIs5hW.js +0 -5
- package/dist/web-ui/assets/AppShell-HiyATJse.css +0 -1
- package/dist/web-ui/assets/Board-Bt3cwp25.js +0 -1
- package/dist/web-ui/assets/BoardPeek-BKR-tpS2.js +0 -2
- package/dist/web-ui/assets/ChatTranscript-B67_nnd6.js +0 -1
- package/dist/web-ui/assets/ConfirmDialog-kyA624OF.js +0 -1
- package/dist/web-ui/assets/IssueIntakePanel-BMP8Vc3E.js +0 -1
- package/dist/web-ui/assets/IssuePeek-C7afOYax.js +0 -1
- package/dist/web-ui/assets/IssuesPage-DwRaBB-m.js +0 -1
- package/dist/web-ui/assets/SettingsPage-CC1sDI8j.js +0 -2
- package/dist/web-ui/assets/SlideOver-B4sEOPyN.css +0 -1
- package/dist/web-ui/assets/SlideOver-Dq0ifiEm.js +0 -173
- package/dist/web-ui/assets/ViewToggle-mNsDLJp8.js +0 -1
- package/dist/web-ui/assets/WorkspaceTabs-DLzL-Tad.css +0 -1
- package/dist/web-ui/assets/WorkspaceTabs-ifAIZ5Fj.js +0 -3
- package/dist/web-ui/assets/active-task-gVYiAkLv.js +0 -1
- package/dist/web-ui/assets/arrow-left-CavMh90a.js +0 -1
- package/dist/web-ui/assets/board-DoArj55z.js +0 -1
- package/dist/web-ui/assets/chips-CS9PLtWy.js +0 -1
- package/dist/web-ui/assets/createLucideIcon-CuIQtyYV.js +0 -1
- package/dist/web-ui/assets/external-link-Du2dMe8S.js +0 -1
- package/dist/web-ui/assets/external-store-BCBJewGi.js +0 -1
- package/dist/web-ui/assets/harness-ClZMF1wx.js +0 -1
- package/dist/web-ui/assets/index-B4xJZEqf.js +0 -10
- package/dist/web-ui/assets/index-BnjD9Q-3.css +0 -1
- package/dist/web-ui/assets/issues-DwrKXp9c.js +0 -4
- package/dist/web-ui/assets/issues-ISAZBras.js +0 -1
- package/dist/web-ui/assets/lazy-issue-panels-DvXQJhKy.js +0 -6
- package/dist/web-ui/assets/rotate-cw-BXdpzm3v.js +0 -1
- package/dist/web-ui/assets/routes-DEEkL5gG.js +0 -1
- package/dist/web-ui/assets/store-BLM6nh6E.js +0 -2
- package/dist/web-ui/assets/tabs-CMZJhcSB.js +0 -1
- package/dist/web-ui/assets/task._taskId-BCIhg4IQ.js +0 -1
- package/dist/web-ui/assets/terminal-DOp1a9g6.js +0 -1
- package/dist/web-ui/assets/text-match-DW3sD-Rt.js +0 -1
- package/dist/web-ui/assets/time-kviT26Tm.js +0 -1
- package/dist/web-ui/assets/toast-C4yXq6hM.js +0 -1
- package/dist/web-ui/assets/web-transport-Beqz2mQ8.js +0 -1
- package/dist/web-ui/assets/worktrees-BGvJOG2b.js +0 -1
- /package/dist/web-ui/assets/{ChatTerminal-BrP-ENHg.css → harness-BrP-ENHg.css} +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{PLUGIN_EVENT_NAMES}from"./chunk-kwe61yx7.js";import{COMPAT_STATE_DIR_BASENAME,ROVE_STATE_DIR_BASENAME,readRoveHomeDirEnv}from"./chunk-3bfm4hrs.js";import{existsSync,readFileSync}from"fs";import{basename,join}from"path";/*!
|
|
3
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions are met:
|
|
8
|
+
*
|
|
9
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
* list of conditions and the following disclaimer.
|
|
11
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
* this list of conditions and the following disclaimer in the
|
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
|
14
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
15
|
+
* may be used to endorse or promote products derived from this software without
|
|
16
|
+
* specific prior written permission.
|
|
17
|
+
*
|
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*/var DATE_TIME_RE=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class TomlDate extends Date{#hasDate=!1;#hasTime=!1;#offset=null;constructor(date){let hasDate=!0,hasTime=!0,offset="Z";if(typeof date==="string"){let match=date.match(DATE_TIME_RE);if(match){if(!match[1])hasDate=!1,date=`0000-01-01T${date}`;if(hasTime=!!match[2],hasTime&&date[10]===" "&&(date=date.replace(" ","T")),match[2]&&+match[2]>23)date="";else if(offset=match[3]||null,date=date.toUpperCase(),!offset&&hasTime)date+="Z"}else date=""}super(date);if(!isNaN(this.getTime()))this.#hasDate=hasDate,this.#hasTime=hasTime,this.#offset=offset}isDateTime(){return this.#hasDate&&this.#hasTime}isLocal(){return!this.#hasDate||!this.#hasTime||!this.#offset}isDate(){return this.#hasDate&&!this.#hasTime}isTime(){return this.#hasTime&&!this.#hasDate}isValid(){return this.#hasDate||this.#hasTime}toISOString(){let iso=super.toISOString();if(this.isDate())return iso.slice(0,10);if(this.isTime())return iso.slice(11,23);if(this.#offset===null)return iso.slice(0,-1);if(this.#offset==="Z")return iso;let offset=+this.#offset.slice(1,3)*60+ +this.#offset.slice(4,6);return offset=this.#offset[0]==="-"?offset:-offset,new Date(this.getTime()-offset*60000).toISOString().slice(0,-1)+this.#offset}static wrapAsOffsetDateTime(jsDate,offset="Z"){let date=new TomlDate(jsDate);return date.#offset=offset,date}static wrapAsLocalDateTime(jsDate){let date=new TomlDate(jsDate);return date.#offset=null,date}static wrapAsLocalDate(jsDate){let date=new TomlDate(jsDate);return date.#hasTime=!1,date.#offset=null,date}static wrapAsLocalTime(jsDate){let date=new TomlDate(jsDate);return date.#hasDate=!1,date.#offset=null,date}}/*!
|
|
29
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
30
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
+
*
|
|
32
|
+
* Redistribution and use in source and binary forms, with or without
|
|
33
|
+
* modification, are permitted provided that the following conditions are met:
|
|
34
|
+
*
|
|
35
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
36
|
+
* list of conditions and the following disclaimer.
|
|
37
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
38
|
+
* this list of conditions and the following disclaimer in the
|
|
39
|
+
* documentation and/or other materials provided with the distribution.
|
|
40
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
41
|
+
* may be used to endorse or promote products derived from this software without
|
|
42
|
+
* specific prior written permission.
|
|
43
|
+
*
|
|
44
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
45
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
46
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
47
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
48
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
49
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
50
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
51
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
52
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
53
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
54
|
+
*/function getLineColFromPtr(string,ptr){let lines=string.slice(0,ptr).split(/\r\n|\n|\r/g);return[lines.length,lines.pop().length+1]}function makeCodeBlock(string,line,column){let lines=string.split(/\r\n|\n|\r/g),codeblock="",numberLen=(Math.log10(line+1)|0)+1;for(let i=line-1;i<=line+1;i++){let l=lines[i-1];if(!l)continue;if(codeblock+=i.toString().padEnd(numberLen," "),codeblock+=": ",codeblock+=l,codeblock+=`
|
|
55
|
+
`,i===line)codeblock+=" ".repeat(numberLen+column+2),codeblock+=`^
|
|
56
|
+
`}return codeblock}class TomlError extends Error{line;column;codeblock;constructor(message,options){let[line,column]=getLineColFromPtr(options.toml,options.ptr),codeblock=makeCodeBlock(options.toml,line,column);super(`Invalid TOML document: ${message}
|
|
57
|
+
|
|
58
|
+
${codeblock}`,options);this.line=line,this.column=column,this.codeblock=codeblock}}/*!
|
|
59
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*
|
|
62
|
+
* Redistribution and use in source and binary forms, with or without
|
|
63
|
+
* modification, are permitted provided that the following conditions are met:
|
|
64
|
+
*
|
|
65
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
66
|
+
* list of conditions and the following disclaimer.
|
|
67
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
68
|
+
* this list of conditions and the following disclaimer in the
|
|
69
|
+
* documentation and/or other materials provided with the distribution.
|
|
70
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
71
|
+
* may be used to endorse or promote products derived from this software without
|
|
72
|
+
* specific prior written permission.
|
|
73
|
+
*
|
|
74
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
75
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
76
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
77
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
78
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
79
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
80
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
81
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
82
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
83
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
84
|
+
*/var INT_REGEX=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,FLOAT_REGEX=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,LEADING_ZERO=/^[+-]?0[0-9_]/;function parseString(str,ptr){let c=str[ptr++],first=c,isLiteral=c==="'",isMultiline=c===str[ptr]&&c===str[ptr+1];if(isMultiline){if(str[ptr+=2]===`
|
|
85
|
+
`)ptr++;else if(str[ptr]==="\r"&&str[ptr+1]===`
|
|
86
|
+
`)ptr+=2}let parsed="",sliceStart=ptr,state=0;for(let i=ptr;i<str.length;i++)if(c=str[i],isMultiline&&(c===`
|
|
87
|
+
`||c==="\r"&&str[i+1]===`
|
|
88
|
+
`))state=state&&3;else if(c<" "&&c!=="\t"||c==="\x7F")throw new TomlError("control characters are not allowed in strings",{toml:str,ptr:i});else if((!state||state===3)&&c===first&&(!isMultiline||str[i+1]===first&&str[i+2]===first)){if(isMultiline){if(str[i+3]===first)i++;if(str[i+3]===first)i++}return[state?parsed:parsed+str.slice(sliceStart,i),i+(isMultiline?3:1)]}else if(!state){if(!isLiteral&&c==="\\")parsed+=str.slice(sliceStart,sliceStart=i),state=1}else if(state===1)if(c==="x"||c==="u"||c==="U"){let value=0,len=c==="x"?2:c==="u"?4:8;for(let j=0;j<len;j++,i++){let hex=str.charCodeAt(i+1),digit=hex>=48&&hex<=57?hex-48:hex>=65&&hex<=70?hex-65+10:hex>=97&&hex<=102?hex-97+10:-1;if(digit<0)throw new TomlError("invalid non-hex character in unicode escape",{toml:str,ptr:i+1});value=value<<4|digit}if(value<0||value>1114111||value>=55296&&value<=57343)throw new TomlError("invalid unicode escape",{toml:str,ptr:i});parsed+=String.fromCodePoint(value),sliceStart=i+1,state=0}else if(c===" "||c==="\t")state=2;else{if(c==="b")parsed+="\b";else if(c==="t")parsed+="\t";else if(c==="n")parsed+=`
|
|
89
|
+
`;else if(c==="f")parsed+="\f";else if(c==="r")parsed+="\r";else if(c==="e")parsed+="\x1B";else if(c==='"')parsed+='"';else if(c==="\\")parsed+="\\";else throw new TomlError("unrecognized escape sequence",{toml:str,ptr:i});sliceStart=i+1,state=0}else if(c!==" "&&c!=="\t"){if(state===2)throw new TomlError("invalid escape: only line-ending whitespace may be escaped",{toml:str,ptr:sliceStart});state=!isLiteral&&c==="\\"?1:0,sliceStart=i}throw new TomlError("unfinished string",{toml:str,ptr})}function parseValue(value,toml,ptr,integersAsBigInt){if(value==="true")return!0;if(value==="false")return!1;if(value==="-inf")return-1/0;if(value==="inf"||value==="+inf")return 1/0;if(value==="nan"||value==="+nan"||value==="-nan")return NaN;if(value==="-0")return integersAsBigInt?0n:0;let isInt=INT_REGEX.test(value);if(isInt||FLOAT_REGEX.test(value)){if(LEADING_ZERO.test(value))throw new TomlError("leading zeroes are not allowed",{toml,ptr});value=value.replace(/_/g,"");let numeric=+value;if(isNaN(numeric))throw new TomlError("invalid number",{toml,ptr});if(isInt){if((isInt=!Number.isSafeInteger(numeric))&&!integersAsBigInt)throw new TomlError("integer value cannot be represented losslessly",{toml,ptr});if(isInt||integersAsBigInt===!0)numeric=BigInt(value)}return numeric}let date=new TomlDate(value);if(!date.isValid())throw new TomlError("invalid value",{toml,ptr});return date}/*!
|
|
90
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
91
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
92
|
+
*
|
|
93
|
+
* Redistribution and use in source and binary forms, with or without
|
|
94
|
+
* modification, are permitted provided that the following conditions are met:
|
|
95
|
+
*
|
|
96
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
97
|
+
* list of conditions and the following disclaimer.
|
|
98
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
99
|
+
* this list of conditions and the following disclaimer in the
|
|
100
|
+
* documentation and/or other materials provided with the distribution.
|
|
101
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
102
|
+
* may be used to endorse or promote products derived from this software without
|
|
103
|
+
* specific prior written permission.
|
|
104
|
+
*
|
|
105
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
106
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
107
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
108
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
109
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
110
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
111
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
112
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
113
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
114
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
115
|
+
*/function indexOfNewline(str,start=0,end=str.length){let idx=str.indexOf(`
|
|
116
|
+
`,start);if(str[idx-1]==="\r")idx--;return idx<=end?idx:-1}function skipComment(str,ptr){for(let i=ptr;i<str.length;i++){let c=str[i];if(c===`
|
|
117
|
+
`)return i;if(c==="\r"&&str[i+1]===`
|
|
118
|
+
`)return i+1;if(c<" "&&c!=="\t"||c==="\x7F")throw new TomlError("control characters are not allowed in comments",{toml:str,ptr})}return str.length}function skipVoid(str,ptr,banNewLines,banComments){let c;while(!0){while((c=str[ptr])===" "||c==="\t"||!banNewLines&&(c===`
|
|
119
|
+
`||c==="\r"&&str[ptr+1]===`
|
|
120
|
+
`))ptr++;if(banComments||c!=="#")break;ptr=skipComment(str,ptr)}return ptr}function skipUntil(str,ptr,sep,end,banNewLines=!1){if(!end)return ptr=indexOfNewline(str,ptr),ptr<0?str.length:ptr;for(let i=ptr;i<str.length;i++){let c=str[i];if(c==="#"){if(i=indexOfNewline(str,i),i<0)break}else if(c===sep)return i+1;else if(c===end||banNewLines&&(c===`
|
|
121
|
+
`||c==="\r"&&str[i+1]===`
|
|
122
|
+
`))return i}throw new TomlError("cannot find end of structure",{toml:str,ptr})}/*!
|
|
123
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
124
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
125
|
+
*
|
|
126
|
+
* Redistribution and use in source and binary forms, with or without
|
|
127
|
+
* modification, are permitted provided that the following conditions are met:
|
|
128
|
+
*
|
|
129
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
130
|
+
* list of conditions and the following disclaimer.
|
|
131
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
132
|
+
* this list of conditions and the following disclaimer in the
|
|
133
|
+
* documentation and/or other materials provided with the distribution.
|
|
134
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
135
|
+
* may be used to endorse or promote products derived from this software without
|
|
136
|
+
* specific prior written permission.
|
|
137
|
+
*
|
|
138
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
139
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
140
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
141
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
142
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
143
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
144
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
145
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
146
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
147
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
148
|
+
*/function sliceAndTrimEndOf(str,startPtr,endPtr){let value=str.slice(startPtr,endPtr),commentIdx=value.indexOf("#");if(commentIdx>-1)skipComment(str,commentIdx),value=value.slice(0,commentIdx);return[value.trimEnd(),commentIdx]}function extractValue(str,ptr,end,depth,integersAsBigInt){if(depth===0)throw new TomlError("document contains excessively nested structures. aborting.",{toml:str,ptr});let c=str[ptr];if(c==="["||c==="{"){let[value,endPtr2]=c==="["?parseArray(str,ptr,depth,integersAsBigInt):parseInlineTable(str,ptr,depth,integersAsBigInt);if(end){if(endPtr2=skipVoid(str,endPtr2),str[endPtr2]===",")endPtr2++;else if(str[endPtr2]!==end)throw new TomlError("expected comma or end of structure",{toml:str,ptr:endPtr2})}return[value,endPtr2]}if(c==='"'||c==="'"){let[parsed,endPtr2]=parseString(str,ptr);if(end){if(endPtr2=skipVoid(str,endPtr2),str[endPtr2]&&str[endPtr2]!==","&&str[endPtr2]!==end&&str[endPtr2]!==`
|
|
149
|
+
`&&str[endPtr2]!=="\r")throw new TomlError("unexpected character encountered",{toml:str,ptr:endPtr2});if(str[endPtr2]===",")endPtr2++}return[parsed,endPtr2]}let endPtr=skipUntil(str,ptr,",",end),slice=sliceAndTrimEndOf(str,ptr,endPtr-(str[endPtr-1]===","?1:0));if(!slice[0])throw new TomlError("incomplete key-value declaration: no value specified",{toml:str,ptr});if(end&&slice[1]>-1){if(endPtr=skipVoid(str,ptr+slice[1]),str[endPtr]===",")endPtr++}return[parseValue(slice[0],str,ptr,integersAsBigInt),endPtr]}/*!
|
|
150
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
151
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
152
|
+
*
|
|
153
|
+
* Redistribution and use in source and binary forms, with or without
|
|
154
|
+
* modification, are permitted provided that the following conditions are met:
|
|
155
|
+
*
|
|
156
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
157
|
+
* list of conditions and the following disclaimer.
|
|
158
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
159
|
+
* this list of conditions and the following disclaimer in the
|
|
160
|
+
* documentation and/or other materials provided with the distribution.
|
|
161
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
162
|
+
* may be used to endorse or promote products derived from this software without
|
|
163
|
+
* specific prior written permission.
|
|
164
|
+
*
|
|
165
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
166
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
167
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
168
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
169
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
170
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
171
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
172
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
173
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
174
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
175
|
+
*/var KEY_PART_RE=/^[a-zA-Z0-9-_]+[ \t]*$/;function parseKey(str,ptr,end="="){let dot=ptr-1,parsed=[],endPtr=str.indexOf(end,ptr);if(endPtr<0)throw new TomlError("incomplete key-value: cannot find end of key",{toml:str,ptr});do{let c=str[ptr=++dot];if(c!==" "&&c!=="\t")if(c==='"'||c==="'"){if(c===str[ptr+1]&&c===str[ptr+2])throw new TomlError("multiline strings are not allowed in keys",{toml:str,ptr});let[part,eos]=parseString(str,ptr);dot=str.indexOf(".",eos);let strEnd=str.slice(eos,dot<0||dot>endPtr?endPtr:dot),newLine=indexOfNewline(strEnd);if(newLine>-1)throw new TomlError("newlines are not allowed in keys",{toml:str,ptr:ptr+dot+newLine});if(strEnd.trimStart())throw new TomlError("found extra tokens after the string part",{toml:str,ptr:eos});if(endPtr<eos){if(endPtr=str.indexOf(end,eos),endPtr<0)throw new TomlError("incomplete key-value: cannot find end of key",{toml:str,ptr})}parsed.push(part)}else{dot=str.indexOf(".",ptr);let part=str.slice(ptr,dot<0||dot>endPtr?endPtr:dot);if(!KEY_PART_RE.test(part))throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys",{toml:str,ptr});parsed.push(part.trimEnd())}}while(dot+1&&dot<endPtr);return[parsed,skipVoid(str,endPtr+1,!0,!0)]}function parseInlineTable(str,ptr,depth,integersAsBigInt){let res={},seen=new Set,c;ptr++;while((c=str[ptr++])!=="}"&&c)if(c===",")throw new TomlError("expected value, found comma",{toml:str,ptr:ptr-1});else if(c==="#")ptr=skipComment(str,ptr);else if(c!==" "&&c!=="\t"&&c!==`
|
|
176
|
+
`&&c!=="\r"){let k,t=res,hasOwn=!1,[key,keyEndPtr]=parseKey(str,ptr-1);for(let i=0;i<key.length;i++){if(i)t=hasOwn?t[k]:t[k]={};if(k=key[i],(hasOwn=Object.hasOwn(t,k))&&(typeof t[k]!=="object"||seen.has(t[k])))throw new TomlError("trying to redefine an already defined value",{toml:str,ptr});if(!hasOwn&&k==="__proto__")Object.defineProperty(t,k,{enumerable:!0,configurable:!0,writable:!0})}if(hasOwn)throw new TomlError("trying to redefine an already defined value",{toml:str,ptr});let[value,valueEndPtr]=extractValue(str,keyEndPtr,"}",depth-1,integersAsBigInt);seen.add(value),t[k]=value,ptr=valueEndPtr}if(!c)throw new TomlError("unfinished table encountered",{toml:str,ptr});return[res,ptr]}function parseArray(str,ptr,depth,integersAsBigInt){let res=[],c;ptr++;while((c=str[ptr++])!=="]"&&c)if(c===",")throw new TomlError("expected value, found comma",{toml:str,ptr:ptr-1});else if(c==="#")ptr=skipComment(str,ptr);else if(c!==" "&&c!=="\t"&&c!==`
|
|
177
|
+
`&&c!=="\r"){let e=extractValue(str,ptr-1,"]",depth-1,integersAsBigInt);res.push(e[0]),ptr=e[1]}if(!c)throw new TomlError("unfinished array encountered",{toml:str,ptr});return[res,ptr]}/*!
|
|
178
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
179
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
180
|
+
*
|
|
181
|
+
* Redistribution and use in source and binary forms, with or without
|
|
182
|
+
* modification, are permitted provided that the following conditions are met:
|
|
183
|
+
*
|
|
184
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
185
|
+
* list of conditions and the following disclaimer.
|
|
186
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
187
|
+
* this list of conditions and the following disclaimer in the
|
|
188
|
+
* documentation and/or other materials provided with the distribution.
|
|
189
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
190
|
+
* may be used to endorse or promote products derived from this software without
|
|
191
|
+
* specific prior written permission.
|
|
192
|
+
*
|
|
193
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
194
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
195
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
196
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
197
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
198
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
199
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
200
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
201
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
202
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
203
|
+
*/function peekTable(key,table,meta,type){let t=table,m=meta,k,hasOwn=!1,state;for(let i=0;i<key.length;i++){if(i){if(t=hasOwn?t[k]:t[k]={},m=(state=m[k]).c,type===0&&(state.t===1||state.t===2))return null;if(state.t===2){let l=t.length-1;t=t[l],m=m[l].c}}if(k=key[i],(hasOwn=Object.hasOwn(t,k))&&m[k]?.t===0&&m[k]?.d)return null;if(!hasOwn){if(k==="__proto__")Object.defineProperty(t,k,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(m,k,{enumerable:!0,configurable:!0,writable:!0});m[k]={t:i<key.length-1&&type===2?3:type,d:!1,i:0,c:{}}}}if(state=m[k],state.t!==type&&!(type===1&&state.t===3))return null;if(type===2){if(!state.d)state.d=!0,t[k]=[];t[k].push(t={}),state.c[state.i++]=state={t:1,d:!1,i:0,c:{}}}if(state.d)return null;if(state.d=!0,type===1)t=hasOwn?t[k]:t[k]={};else if(type===0&&hasOwn)return null;return[k,t,state.c]}function parse(toml,{maxDepth=1000,integersAsBigInt}={}){let res={},meta={},tbl=res,m=meta;for(let ptr=skipVoid(toml,0);ptr<toml.length;){if(toml[ptr]==="["){let isTableArray=toml[++ptr]==="[",k=parseKey(toml,ptr+=+isTableArray,"]");if(isTableArray){if(toml[k[1]-1]!=="]")throw new TomlError("expected end of table declaration",{toml,ptr:k[1]-1});k[1]++}let p=peekTable(k[0],res,meta,isTableArray?2:1);if(!p)throw new TomlError("trying to redefine an already defined table or value",{toml,ptr});m=p[2],tbl=p[1],ptr=k[1]}else{let k=parseKey(toml,ptr),p=peekTable(k[0],tbl,m,0);if(!p)throw new TomlError("trying to redefine an already defined table or value",{toml,ptr});let v=extractValue(toml,k[1],void 0,maxDepth,integersAsBigInt);p[1][p[0]]=v[0],ptr=v[1]}if(ptr=skipVoid(toml,ptr,!0),toml[ptr]&&toml[ptr]!==`
|
|
204
|
+
`&&toml[ptr]!=="\r")throw new TomlError("each key-value declaration must be followed by an end-of-line",{toml,ptr});ptr=skipVoid(toml,ptr)}return res}/*!
|
|
205
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
206
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
207
|
+
*
|
|
208
|
+
* Redistribution and use in source and binary forms, with or without
|
|
209
|
+
* modification, are permitted provided that the following conditions are met:
|
|
210
|
+
*
|
|
211
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
212
|
+
* list of conditions and the following disclaimer.
|
|
213
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
214
|
+
* this list of conditions and the following disclaimer in the
|
|
215
|
+
* documentation and/or other materials provided with the distribution.
|
|
216
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
217
|
+
* may be used to endorse or promote products derived from this software without
|
|
218
|
+
* specific prior written permission.
|
|
219
|
+
*
|
|
220
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
221
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
222
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
223
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
224
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
225
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
226
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
227
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
228
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
229
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
230
|
+
*//*!
|
|
231
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
232
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
233
|
+
*
|
|
234
|
+
* Redistribution and use in source and binary forms, with or without
|
|
235
|
+
* modification, are permitted provided that the following conditions are met:
|
|
236
|
+
*
|
|
237
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
238
|
+
* list of conditions and the following disclaimer.
|
|
239
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
240
|
+
* this list of conditions and the following disclaimer in the
|
|
241
|
+
* documentation and/or other materials provided with the distribution.
|
|
242
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
243
|
+
* may be used to endorse or promote products derived from this software without
|
|
244
|
+
* specific prior written permission.
|
|
245
|
+
*
|
|
246
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
247
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
248
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
249
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
250
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
251
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
252
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
253
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
254
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
255
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
256
|
+
*/var PLUGIN_PLATFORMS=["macos","linux","windows"];class ManifestError extends Error{}function fail(message){throw new ManifestError(`rove-plugin.toml: ${message}`)}function asString(value,field){if(typeof value!=="string"||value.length===0)fail(`\`${field}\` must be a non-empty string`);return value}function asSettingDefault(value,field){if(value===void 0||value===!1)return;if(value===!0)return"1";if(typeof value==="number"&&Number.isFinite(value))return String(value);return asString(value,field)}var TIMEOUT_MIN_MS=100,TIMEOUT_MAX_MS=600000;function asTimeoutMs(value,field){if(value===void 0)return;if(typeof value!=="number"||!Number.isInteger(value)||value<TIMEOUT_MIN_MS||value>TIMEOUT_MAX_MS)fail(`\`${field}\` must be a whole number of milliseconds between ${TIMEOUT_MIN_MS} and ${TIMEOUT_MAX_MS}`);return value}function asCommand(value,field){if(!Array.isArray(value)||value.length===0||!value.every((v)=>typeof v==="string"&&v.length>0))fail(`\`${field}\` must be a non-empty array of strings (argv form)`);return value}function asPlatforms(value,field){if(value===void 0)return;if(!Array.isArray(value)||!value.every((v)=>PLUGIN_PLATFORMS.includes(v)))fail(`\`${field}\` must be an array drawn from ${PLUGIN_PLATFORMS.join(", ")}`);return value}function asTableArray(value,field){if(value===void 0)return[];if(!Array.isArray(value)||!value.every((v)=>typeof v==="object"&&v!==null&&!Array.isArray(v)))fail(`\`[[${field}]]\` must be an array of tables`);return value}function asStringArray(value,field){if(value===void 0)return;if(!Array.isArray(value)||!value.every((v)=>typeof v==="string"&&v.length>0))fail(`\`${field}\` must be a non-empty array of strings`);return value}var SETTING_KEY_RE=/^[A-Za-z_][A-Za-z0-9_]*$/,RESERVED_SETTING_KEYS=["PATH","HOME","SHELL","IFS","LD_PRELOAD","LD_LIBRARY_PATH","LD_AUDIT","DYLD_INSERT_LIBRARIES","DYLD_LIBRARY_PATH","DYLD_FRAMEWORK_PATH","NODE_OPTIONS","BUN_INSPECT","PYTHONPATH","PYTHONSTARTUP","PERL5OPT","PERL5LIB","RUBYOPT","BASH_ENV","ENV","GIT_SSH_COMMAND","GIT_SSH","GIT_EXTERNAL_DIFF","GIT_PAGER","PAGER","EDITOR","VISUAL"];function settingKeyRejection(key){if(!SETTING_KEY_RE.test(key))return`\`${key}\` is not a valid env var name (${SETTING_KEY_RE.source})`;if(RESERVED_SETTING_KEYS.includes(key))return`\`${key}\` is reserved; it steers how the plugin's own process runs`;return null}var PLUGIN_MANIFEST_FILENAME="rove-plugin.toml",LEGACY_PLUGIN_MANIFEST_FILENAME="kobe-plugin.toml",PLUGIN_MANIFEST_FILENAMES=[PLUGIN_MANIFEST_FILENAME,LEGACY_PLUGIN_MANIFEST_FILENAME],RESERVED_ENGINE_IDS=["claude","codex","copilot","kimi","gemini","opencode","cursor","grok","droid","amp"];function pluginManifestPath(root){for(let filename of PLUGIN_MANIFEST_FILENAMES){let path=join(root,filename);if(existsSync(path))return path}return null}function readPluginManifest(root){let path=pluginManifestPath(root);if(!path)throw new ManifestError(`no ${PLUGIN_MANIFEST_FILENAMES.join(" or ")} found at ${root}`);return parsePluginManifest(readFileSync(path,"utf8"),basename(path))}var PLUGIN_ID_RE=/^[A-Za-z0-9][A-Za-z0-9._:-]*$/,LOCAL_ID_RE=/^[A-Za-z0-9][A-Za-z0-9_:-]*$/;function qualifiedActionId(pluginId,actionId){return`${pluginId}.${actionId}`}function currentPluginPlatform(platform=process.platform){if(platform==="darwin")return"macos";if(platform==="linux")return"linux";if(platform==="win32")return"windows";return}function supportsPlatform(item,manifest,platform){let declared=item.platforms??manifest.platforms;if(!declared)return!0;return platform!==void 0&&declared.includes(platform)}function parsePluginManifest(text,filename=PLUGIN_MANIFEST_FILENAME){try{return parseCanonicalPluginManifest(text)}catch(err){if(filename!==PLUGIN_MANIFEST_FILENAME&&err instanceof ManifestError)throw new ManifestError(err.message.replace(/^rove-plugin\.toml:/,`${filename}:`));throw err}}function parseCanonicalPluginManifest(text){let raw;try{raw=parse(text)}catch(err){fail(`invalid TOML \u2014 ${err instanceof Error?err.message:String(err)}`)}let warnings=[],id=asString(raw.id,"id");if(!PLUGIN_ID_RE.test(id))fail(`plugin id \`${id}\` may use ASCII letters, digits, dot, colon, underscore, hyphen`);let name=asString(raw.name,"name"),version=asString(raw.version,"version"),rawMinVersion=raw.min_rove_version??raw.min_kobe_version,minKobeVersion=asString(rawMinVersion,"min_rove_version"),description=raw.description===void 0?void 0:asString(raw.description,"description"),platforms=asPlatforms(raw.platforms,"platforms");if(!platforms)warnings.push("no top-level `platforms` declared; assuming the plugin runs everywhere");if(raw.min_rove_version!==void 0&&raw.min_kobe_version!==void 0&&raw.min_rove_version!==raw.min_kobe_version)warnings.push("both `min_rove_version` and legacy `min_kobe_version` are set; using `min_rove_version`");let build=asTableArray(raw.build,"build").map((t,i)=>({command:asCommand(t.command,`build[${i}].command`),platforms:asPlatforms(t.platforms,`build[${i}].platforms`)})),startup=asTableArray(raw.startup,"startup").map((t,i)=>({command:asCommand(t.command,`startup[${i}].command`),platforms:asPlatforms(t.platforms,`startup[${i}].platforms`),timeoutMs:asTimeoutMs(t.timeout_ms,`startup[${i}].timeout_ms`)})),shutdown=asTableArray(raw.shutdown,"shutdown").map((t,i)=>({command:asCommand(t.command,`shutdown[${i}].command`),platforms:asPlatforms(t.platforms,`shutdown[${i}].platforms`),timeoutMs:asTimeoutMs(t.timeout_ms,`shutdown[${i}].timeout_ms`)})),actions=asTableArray(raw.actions,"actions").map((t,i)=>{let actionId=asString(t.id,`actions[${i}].id`);if(t.timeout_ms!==void 0)warnings.push(`actions[${i}] declares \`timeout_ms\`; actions are user-invoked and are never killed on a deadline`);if(!LOCAL_ID_RE.test(actionId))fail(`action id \`${actionId}\` may not contain dots`);return{id:actionId,title:asString(t.title,`actions[${i}].title`),command:asCommand(t.command,`actions[${i}].command`),platforms:asPlatforms(t.platforms,`actions[${i}].platforms`)}}),seen=new Set;for(let a of actions){if(seen.has(a.id))fail(`duplicate action id \`${a.id}\``);seen.add(a.id)}let panes=asTableArray(raw.panes,"panes").map((t,i)=>{let paneId=asString(t.id,`panes[${i}].id`);if(!LOCAL_ID_RE.test(paneId))fail(`pane id \`${paneId}\` may not contain dots`);if(t.timeout_ms!==void 0)warnings.push(`panes[${i}] declares \`timeout_ms\`; a pane is a terminal the user closes, not a bounded hook`);if(t.placement!==void 0&&t.placement!=="tab"&&t.placement!=="split")warnings.push(`pane \`${paneId}\` placement \`${String(t.placement)}\` is not supported yet; opening as a split`);return{id:paneId,title:asString(t.title,`panes[${i}].title`),placement:t.placement==="tab"?"tab":"split",command:asCommand(t.command,`panes[${i}].command`),platforms:asPlatforms(t.platforms,`panes[${i}].platforms`)}}),paneSeen=new Set;for(let p of panes){if(paneSeen.has(p.id))fail(`duplicate pane id \`${p.id}\``);paneSeen.add(p.id)}let events=asTableArray(raw.events,"events").flatMap((t,i)=>{let on=asString(t.on,`events[${i}].on`),hook={on,command:asCommand(t.command,`events[${i}].command`),platforms:asPlatforms(t.platforms,`events[${i}].platforms`),timeoutMs:asTimeoutMs(t.timeout_ms,`events[${i}].timeout_ms`)};if(!PLUGIN_EVENT_NAMES.includes(on))warnings.push(`unknown event \`${on}\`; this hook will never fire on this Rove version`);return[hook]}),settings=asTableArray(raw.settings,"settings").map((t,i)=>{let type=asString(t.type,`settings[${i}].type`);if(type!=="string"&&type!=="number"&&type!=="boolean"&&type!=="enum"&&type!=="secret")fail(`settings[${i}].type must be string | number | boolean | enum | secret`);let options=t.options===void 0?void 0:Array.isArray(t.options)&&t.options.every((o)=>typeof o==="string"&&o.length>0)?t.options:fail(`settings[${i}].options must be an array of strings`);if(type==="enum"&&(!options||options.length===0))fail(`settings[${i}] enum needs \`options\``);let settingDefault=asSettingDefault(t.default,`settings[${i}].default`),key=asString(t.key,`settings[${i}].key`),rejection=settingKeyRejection(key);if(rejection)fail(`settings[${i}].key ${rejection}`);return{key,label:asString(t.label,`settings[${i}].label`),type,...options?{options}:{},...settingDefault===void 0?{}:{default:settingDefault}}}),fileHandlers=asTableArray(raw.file_handlers,"file_handlers").map((t,i)=>{let pattern=asString(t.pattern,`file_handlers[${i}].pattern`);try{new RegExp(pattern)}catch{fail(`file_handlers[${i}].pattern is not a valid regex`)}let action=asString(t.action,`file_handlers[${i}].action`);if(!actions.some((a)=>a.id===action))fail(`file_handlers[${i}] names unknown action \`${action}\``);return{pattern,action}}),engines=asTableArray(raw.engines,"engines").map((t,i)=>{let engineId=asString(t.id,`engines[${i}].id`);if(!LOCAL_ID_RE.test(engineId))fail(`engine id \`${engineId}\` may not contain dots`);if(RESERVED_ENGINE_IDS.includes(engineId))fail(`engine id \`${engineId}\` shadows a built-in or shipped engine`);let rules=asTableArray(t.rules,`engines[${i}].rules`).map((r,j)=>{let state=asString(r.state,`engines[${i}].rules[${j}].state`);if(state!=="working"&&state!=="blocked"&&state!=="idle")fail(`engines[${i}].rules[${j}].state must be working | blocked | idle`);let lineRegex=asStringArray(r.line_regex,`engines[${i}].rules[${j}].line_regex`);for(let re of lineRegex??[])try{new RegExp(re)}catch{fail(`engines[${i}].rules[${j}].line_regex \`${re}\` is not a valid regex`)}let all=asStringArray(r.all,`engines[${i}].rules[${j}].all`),any=asStringArray(r.any,`engines[${i}].rules[${j}].any`);if(!all&&!any&&!lineRegex)fail(`engines[${i}].rules[${j}] needs at least one of all/any/line_regex`);return{state,...typeof r.bottom_lines==="number"?{bottomLines:r.bottom_lines}:{},...all?{all}:{},...any?{any}:{},...lineRegex?{lineRegex}:{}}}),identityRaw=t.identity,identity;if(identityRaw!==void 0){if(typeof identityRaw!=="object"||identityRaw===null||Array.isArray(identityRaw))fail(`engines[${i}].identity must be a table`);let idt=identityRaw,shortName=((key)=>idt[key]===void 0?void 0:asString(idt[key],`engines[${i}].identity.${key}`))("short_name");identity={...shortName!==void 0?{shortName}:{}}}let firstMessageDelivery;if(t.first_message_delivery!==void 0){let raw2=asString(t.first_message_delivery,`engines[${i}].first_message_delivery`);if(raw2!=="argv"&&raw2!=="paste")fail(`engines[${i}].first_message_delivery must be argv | paste`);firstMessageDelivery=raw2}return{id:engineId,name:asString(t.name,`engines[${i}].name`),command:asCommand(t.command,`engines[${i}].command`),...t.process_names===void 0?{}:{processNames:asCommand(t.process_names,`engines[${i}].process_names`)},rules,...identity?{identity}:{},...firstMessageDelivery?{firstMessageDelivery}:{}}}),engineSeen=new Set;for(let e of engines){if(engineSeen.has(e.id))fail(`duplicate engine id \`${e.id}\``);engineSeen.add(e.id)}return{manifest:{id,name,version,minKobeVersion,description,platforms,build,startup,shutdown,actions,events,panes,settings,fileHandlers,engines},warnings}}import{existsSync as existsSync2}from"fs";import{homedir}from"os";import{join as join2}from"path";function stateRoot(homeDir){let home=homeDir??readRoveHomeDirEnv()??homedir(),canonical=join2(home,ROVE_STATE_DIR_BASENAME);if(existsSync2(join2(canonical,"plugins.json")))return canonical;let legacy=join2(home,COMPAT_STATE_DIR_BASENAME);return existsSync2(join2(legacy,"plugins.json"))?legacy:canonical}function pluginRegistryPath(homeDir){return join2(stateRoot(homeDir),"plugins.json")}function pluginsRootDir(homeDir){return join2(stateRoot(homeDir),"plugins")}function legacyPluginsRootDir(homeDir){let home=homeDir??readRoveHomeDirEnv()??homedir();return join2(home,COMPAT_STATE_DIR_BASENAME,"plugins")}function pluginDataDir(id,homeDir){return join2(pluginsRootDir(homeDir),id)}function pluginCheckoutDir(id,homeDir){return join2(pluginDataDir(id,homeDir),"checkout")}function pluginConfigDir(id,homeDir){return join2(pluginDataDir(id,homeDir),"config")}function pluginStateDir(id,homeDir){return join2(pluginDataDir(id,homeDir),"state")}function pluginLogPath(id,homeDir){return join2(pluginDataDir(id,homeDir),"log.jsonl")}function pluginsOutdatedCachePath(homeDir){return join2(stateRoot(homeDir),"plugins-outdated.json")}import{mkdirSync,readFileSync as readFileSync2,writeFileSync}from"fs";import{dirname,join as join3,relative}from"path";var EMPTY={plugins:[]};function loadPluginRegistry(homeDir){let text;try{text=readFileSync2(pluginRegistryPath(homeDir),"utf8")}catch{return EMPTY}try{let raw=JSON.parse(text);if(!Array.isArray(raw.plugins))return EMPTY;return{plugins:raw.plugins.filter(isEntry).map((entry)=>withCanonicalRoot(entry,homeDir))}}catch{return EMPTY}}function withCanonicalRoot(entry,homeDir){if(entry.source.kind!=="github")return entry;let legacy=legacyPluginsRootDir(homeDir),canonical=pluginsRootDir(homeDir);if(legacy===canonical)return entry;let inside=relative(legacy,entry.root);if(inside===""||inside.startsWith("..")||inside.startsWith("/"))return entry;return{...entry,root:join3(canonical,inside)}}function isEntry(v){if(typeof v!=="object"||v===null)return!1;let e=v,source=e.source;return typeof e.id==="string"&&typeof e.root==="string"&&typeof e.enabled==="boolean"&&typeof e.version==="string"&&typeof e.installedAt==="number"&&typeof source==="object"&&source!==null&&(source.kind==="link"||source.kind==="github"&&typeof source.spec==="string")}function savePluginRegistry(registry,homeDir){let path=pluginRegistryPath(homeDir);mkdirSync(dirname(path),{recursive:!0}),writeFileSync(path,`${JSON.stringify(registry,null,2)}
|
|
257
|
+
`,{mode:384})}function upsertPluginEntry(registry,entry){return{plugins:[...registry.plugins.filter((p)=>p.id!==entry.id),entry]}}function removePluginEntry(registry,id){return{plugins:registry.plugins.filter((p)=>p.id!==id)}}
|
|
258
|
+
export{PLUGIN_MANIFEST_FILENAMES,pluginManifestPath,readPluginManifest,qualifiedActionId,currentPluginPlatform,supportsPlatform,parsePluginManifest,pluginRegistryPath,pluginsRootDir,pluginDataDir,pluginCheckoutDir,pluginConfigDir,pluginStateDir,pluginLogPath,pluginsOutdatedCachePath,loadPluginRegistry,savePluginRegistry,upsertPluginEntry,removePluginEntry};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{getPersistedBool,loadStateFile,patchStateFile,readSavedRepos,updateStateFile}from"./chunk-gjf604bb.js";import{projectRejection}from"./chunk-9c1e5z6a.js";import{kvStatePath}from"./chunk-6dn6h640.js";import{spawnSync}from"child_process";import{realpathSync}from"fs";function isRemoteRepoKey(key){return key.startsWith("ssh://")}function isRemoteProjectsEnabled(){return getPersistedBool("experimental.remoteProjects",!1)}function remoteRepoKey(host,user,port,basePath){let authority=port?`${user}@${host}:${port}`:`${user}@${host}`,base=(basePath??"").trim().replace(/\/+$/,"");if(!base)return`ssh://${authority}`;return`ssh://${authority}${base.startsWith("/")?base:`/${base}`}`}function readRemoteRepos(state){let raw=state.remoteRepos;if(!raw||typeof raw!=="object"||Array.isArray(raw))return{};return raw}function getRemoteRepoConfig(key){return readRemoteRepos(loadStateFile())[key]??null}function getRemoteRepos(){return readRemoteRepos(loadStateFile())}function addRemoteRepo(config){let key=remoteRepoKey(config.host,config.user,config.port,config.basePath),added=!1;return updateStateFile((state)=>{let repos={...readRemoteRepos(state)},legacyKey=remoteRepoKey(config.host,config.user,config.port);if(key!==legacyKey&&repos[legacyKey]?.basePath===config.basePath)key=legacyKey;repos[key]=config,state.remoteRepos=repos;let saved=readSavedRepos(state);if(added=!saved.includes(key),added)state.savedRepos=[...saved,key];return}),{key,added}}function resolveRepoRoot(absPath){if(isRemoteRepoKey(absPath))return absPath;let r=spawnSync("git",["rev-parse","--show-toplevel"],{cwd:absPath,encoding:"utf8",shell:!1});if(r.status!==0)return absPath;let top=(r.stdout??"").trim();if(!top)return absPath;try{if(realpathSync(absPath)===realpathSync(top))return absPath}catch{}return top}function isGitRepo(absPath){if(isRemoteRepoKey(absPath))return!1;let r=spawnSync("git",["rev-parse","--is-inside-work-tree"],{cwd:absPath,encoding:"utf8",shell:!1});return r.status===0&&(r.stdout??"").trim()==="true"}function resolveMainRepoRoot(absPath){if(isRemoteRepoKey(absPath))return absPath;let r=spawnSync("git",["worktree","list","--porcelain"],{cwd:absPath,encoding:"utf8",shell:!1});if(r.status!==0)return resolveRepoRoot(absPath);return(r.stdout??"").split(/\r?\n/).find((line)=>line.startsWith("worktree "))?.slice(9).trim()||resolveRepoRoot(absPath)}function statePath(){return kvStatePath()}function getSavedRepos(){return readSavedRepos(loadStateFile())}function getPersistedString(key){let value=loadStateFile()[key];return typeof value==="string"?value:void 0}function setPersistedString(key,value){patchStateFile({[key]:value})}function getCustomEngineIds(){let raw=loadStateFile().customEngineIds;if(!Array.isArray(raw))return[];return raw.filter((s)=>typeof s==="string"&&s.trim().length>0)}function getDisabledEngineIds(){let raw=loadStateFile().disabledEngineIds;if(!Array.isArray(raw))return[];return raw.filter((s)=>typeof s==="string"&&s.trim().length>0)}function addSavedRepo(absPath,opts={}){let normalized=resolveMainRepoRoot(absPath),rejected=opts.skipGate?null:projectRejection(normalized,isGitRepo,opts.intent??"explicit");if(rejected)return{added:!1,path:normalized,total:getSavedRepos().length,rejected};let result={added:!1,path:normalized,total:0};return updateStateFile((state)=>{let cur=readSavedRepos(state);if(cur.includes(normalized))return result={added:!1,path:normalized,total:cur.length},!1;state.savedRepos=[...cur,normalized],result={added:!0,path:normalized,total:cur.length+1};return}),result}function backfillSavedReposFromProjects(mainRepos){let added=[];for(let repo of mainRepos)if(addSavedRepo(repo,{intent:"explicit"}).added)added.push(repo);return added}function normalizeSavedRepos(){let cur=getSavedRepos(),seen=new Set,next=[],changed=!1;for(let p of cur){let top=resolveMainRepoRoot(p);if(top!==p)changed=!0;if(seen.has(top)){changed=!0;continue}seen.add(top),next.push(top)}if(!changed)return;patchStateFile({savedRepos:next})}function readRepoConfigs(state){let raw=state.repoConfigs;if(!raw||typeof raw!=="object"||Array.isArray(raw))return{};return raw}function coerceOverride(entry){if(!entry||typeof entry!=="object")return{};let e=entry;return{initScript:typeof e.initScript==="string"&&e.initScript.length>0?e.initScript:void 0,initPrompt:typeof e.initPrompt==="string"&&e.initPrompt.length>0?e.initPrompt:void 0}}function getRepoInitOverride(repoRoot){return coerceOverride(readRepoConfigs(loadStateFile())[resolveRepoRoot(repoRoot)])}function setRepoInitOverride(repoRoot,patch){let normalized=resolveRepoRoot(repoRoot),next={};return updateStateFile((state)=>{let configs={...readRepoConfigs(state)},cur=coerceOverride(configs[normalized]),nextScript=patch.initScript===void 0?cur.initScript:patch.initScript||void 0,nextPrompt=patch.initPrompt===void 0?cur.initPrompt:patch.initPrompt||void 0;if(next={...nextScript?{initScript:nextScript}:{},...nextPrompt?{initPrompt:nextPrompt}:{}},!next.initScript&&!next.initPrompt){let{[normalized]:_dropped,...rest}=configs;state.repoConfigs=rest}else configs[normalized]=next,state.repoConfigs=configs;return}),next}function removeSavedRepo(absPath){let result={removed:!1,path:absPath,total:0};return updateStateFile((state)=>{let cur=readSavedRepos(state);if(!cur.includes(absPath))return result={removed:!1,path:absPath,total:cur.length},!1;if(state.savedRepos=cur.filter((p)=>p!==absPath),isRemoteRepoKey(absPath)){let remotes=readRemoteRepos(state);if(absPath in remotes){let next={...remotes};delete next[absPath],state.remoteRepos=next}}result={removed:!0,path:absPath,total:cur.length-1};return}),result}
|
|
3
|
+
export{isRemoteRepoKey,isRemoteProjectsEnabled,remoteRepoKey,getRemoteRepoConfig,getRemoteRepos,addRemoteRepo,resolveRepoRoot,isGitRepo,resolveMainRepoRoot,statePath,getSavedRepos,getPersistedString,setPersistedString,getCustomEngineIds,getDisabledEngineIds,addSavedRepo,backfillSavedReposFromProjects,normalizeSavedRepos,getRepoInitOverride,setRepoInitOverride,removeSavedRepo};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{basename}from"path";function globToRegExp(glob){let re="";for(let i=0;i<glob.length;i++){let c=glob[i];if(c==="*")if(glob[i+1]==="*")if((i===0||glob[i-1]==="/")&&glob[i+2]==="/")re+="(?:.*/)?",i+=2;else re+=".*",i++;else re+="[^/]*";else if(c==="?")re+="[^/]";else if(c&&"\\^$.|+()[]{}".includes(c))re+=`\\${c}`;else re+=c}return new RegExp(`^${re}$`)}function matchPathGlob(glob,p){let re;try{re=globToRegExp(glob)}catch{return!1}return re.test(p)||re.test(basename(p))}
|
|
3
|
+
export{matchPathGlob};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var PLUGIN_EVENT_NAMES=["task.created","task.deleted","task.changed","task.landed","task.pr-changed","worktree.created","issue.changed","note.filed","message.delivered","attention.handled","automation.dispatched","automation.skipped","automation.failed","quota.exhausted","quota.resumed","session.exited","plugin.enabled","plugin.disabled","agent.turn-complete","agent.permission-needed","agent.rate-limited","agent.error","agent.running","agent.idle","session.start","session.end","turn.prompt","turn.complete","turn.failed","turn.interrupted","tool.pre","tool.post","tool.failed","attention.permission","attention.question","context.pre-compact","context.post-compact","subagent.start","subagent.stop","file.will-open","file.opened","file.closed","task.opened","project.opened","tab.opened","tab.closed"],DAEMON_CHANNELS=["task.snapshot","issue.snapshot","active-task","update","engine-state","attention.inbox","ui-prefs","keybindings","task.jobs","worktree.changes","transcript.activity","session.deliver","tab.open","tab.close","engine.lifecycle","notice.event","usage.snapshot","usage.context","ui.prompt"];
|
|
3
|
+
export{PLUGIN_EVENT_NAMES,DAEMON_CHANNELS};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{StaleInstallError,autospawnDaemonEnv,connectIfRunning,connectOrStartDaemon,detachOptions,ensureDaemonReachable,isStaleInstallError,probeDaemonSocket,resolveKobeSpawn,spawnDetachedDaemon,testDaemonResponds,tryAcquireSpawnLock}from"./chunk-5bn91n19.js";import"./chunk-pdh5w4ht.js";import"./chunk-4wwx51m5.js";import"./chunk-79gqh5p2.js";import"./chunk-3ztek08w.js";import"./chunk-kwe61yx7.js";import"./chunk-grh6dvfv.js";import"./chunk-pw6yfj10.js";import"./chunk-x760j10f.js";import"./chunk-3bfm4hrs.js";import"./chunk-wqfp8d9w.js";export{tryAcquireSpawnLock,testDaemonResponds,spawnDetachedDaemon,resolveKobeSpawn,probeDaemonSocket,isStaleInstallError,ensureDaemonReachable,detachOptions,connectOrStartDaemon,connectIfRunning,autospawnDaemonEnv,StaleInstallError};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{addRemoteRepo,addSavedRepo,backfillSavedReposFromProjects,getCustomEngineIds,getDisabledEngineIds,getPersistedString,getRemoteRepoConfig,getRemoteRepos,getRepoInitOverride,getSavedRepos,isGitRepo,isRemoteProjectsEnabled,isRemoteRepoKey,normalizeSavedRepos,remoteRepoKey,removeSavedRepo,resolveMainRepoRoot,resolveRepoRoot,setPersistedString,setRepoInitOverride,statePath}from"./chunk-k3ksts6g.js";import"./chunk-gjf604bb.js";import"./chunk-9c1e5z6a.js";import"./chunk-6dn6h640.js";import"./chunk-cb2fpajx.js";import"./chunk-3bfm4hrs.js";import"./chunk-wqfp8d9w.js";export{statePath,setRepoInitOverride,setPersistedString,resolveRepoRoot,resolveMainRepoRoot,removeSavedRepo,remoteRepoKey,normalizeSavedRepos,isRemoteRepoKey,isRemoteProjectsEnabled,isGitRepo,getSavedRepos,getRepoInitOverride,getRemoteRepos,getRemoteRepoConfig,getPersistedString,getDisabledEngineIds,getCustomEngineIds,backfillSavedReposFromProjects,addSavedRepo,addRemoteRepo};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{readOnlyGitProcessEnv}from"./chunk-6xppe9bj.js";import{spawnSync}from"child_process";var ENCODER=new TextEncoder,DECODER=new TextDecoder;function isOctalDigit(ch){return ch>="0"&&ch<="7"}function readQuoted(field,start){let bytes=[],lit="",flush=()=>{if(lit.length>0){for(let b of ENCODER.encode(lit))bytes.push(b);lit=""}},i=start+1;while(i<field.length){let ch=field[i];if(ch==='"'){i++;break}if(ch==="\\"){let n=field[i+1];if(n===void 0){lit+="\\",i++;continue}switch(n){case"a":flush(),bytes.push(7),i+=2;break;case"b":flush(),bytes.push(8),i+=2;break;case"t":flush(),bytes.push(9),i+=2;break;case"n":flush(),bytes.push(10),i+=2;break;case"v":flush(),bytes.push(11),i+=2;break;case"f":flush(),bytes.push(12),i+=2;break;case"r":flush(),bytes.push(13),i+=2;break;case'"':lit+='"',i+=2;break;case"\\":lit+="\\",i+=2;break;default:if(isOctalDigit(n)){let oct="",j=i+1;while(j<field.length&&oct.length<3&&isOctalDigit(field[j]))oct+=field[j],j++;flush(),bytes.push(Number.parseInt(oct,8)&255),i=j}else lit+=n,i+=2;break}}else lit+=ch,i++}return flush(),{value:DECODER.decode(new Uint8Array(bytes)),end:i}}function unquoteGitPath(field){if(field.length===0||field[0]!=='"')return field;return readQuoted(field,0).value}function splitRenameField(field,sep){if(field[0]==='"'){let left=readQuoted(field,0);if(field.startsWith(sep,left.end))return{orig:left.value,neu:unquoteGitPath(field.slice(left.end+sep.length))};return null}let idx=field.indexOf(sep);if(idx<0)return null;return{orig:field.slice(0,idx),neu:unquoteGitPath(field.slice(idx+sep.length))}}function parsePorcelainRows(raw){let rows=[];for(let rawLine of raw.split(`
|
|
3
|
+
`)){let line=rawLine.replace(/\r$/,"");if(line.length<4)continue;if(line.startsWith("##"))continue;let x=line[0],y=line[1];if(line[2]!==" ")continue;let rest=line.slice(3);if(x==="R"||x==="C"||y==="R"||y==="C"){let split=splitRenameField(rest," -> ");if(split){rows.push({x,y,path:split.neu,origPath:split.orig});continue}}rows.push({x,y,path:unquoteGitPath(rest)})}return rows}function parseCount(token){if(token==="-")return null;let n=Number.parseInt(token,10);return Number.isNaN(n)?null:n}function parseNumstatRows(raw){let rows=[],fields=raw.split("\x00");if(fields.length>0&&fields[fields.length-1]==="")fields.pop();let i=0;while(i<fields.length){let header=fields[i],tab1=header.indexOf("\t");if(tab1<0){i++;continue}let tab2=header.indexOf("\t",tab1+1);if(tab2<0){i++;continue}let added=parseCount(header.slice(0,tab1)),deleted=parseCount(header.slice(tab1+1,tab2)),pathField=header.slice(tab2+1);if(pathField.length>0)rows.push({path:unquoteGitPath(pathField),added,deleted}),i++;else{if(i+2>=fields.length)break;rows.push({path:unquoteGitPath(fields[i+2]),origPath:unquoteGitPath(fields[i+1]),added,deleted}),i+=3}}return rows}var ZERO={added:0,deleted:0};function sameWorktreeChanges(a,b){if(a===null||b===null)return a===b;return a.added===b.added&&a.deleted===b.deleted&&a.behind===b.behind&&a.ahead===b.ahead}function pickPushedChanges(pushed,worktreePath){if(!pushed)return null;if(pushed.has(worktreePath))return pushed.get(worktreePath)??"unknown";return ZERO}function readWorktreeChanges(worktreePath){if(!worktreePath)return null;try{let out=spawnSync("git",["status","--porcelain=v1"],{cwd:worktreePath,encoding:"utf8",stdio:["ignore","pipe","pipe"],env:readOnlyGitProcessEnv()});if(out.status!==0||out.stdout===void 0||out.stdout===null)return null;return parsePorcelain(out.stdout)}catch{return null}}function parsePorcelain(text){let added=0,deleted=0;for(let{x,y}of parsePorcelainRows(text))if(x==="D"||y==="D")deleted+=1;else added+=1;return{added,deleted}}
|
|
4
|
+
export{unquoteGitPath,parsePorcelainRows,parseNumstatRows,sameWorktreeChanges,pickPushedChanges,readWorktreeChanges,parsePorcelain};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{loadPluginRegistry,pluginConfigDir,pluginDataDir,pluginLogPath,pluginRegistryPath,pluginStateDir,pluginsRootDir}from"./chunk-jyv82gf0.js";import{OWNER_ONLY_DIR_MODE,OWNER_ONLY_FILE_MODE}from"./chunk-4wwx51m5.js";import{chmodSync}from"fs";function tighten(path,mode){try{chmodSync(path,mode)}catch{}}function tightenPluginPermissions(id,homeDir){tighten(pluginDataDir(id,homeDir),OWNER_ONLY_DIR_MODE),tighten(pluginConfigDir(id,homeDir),OWNER_ONLY_DIR_MODE),tighten(pluginStateDir(id,homeDir),OWNER_ONLY_DIR_MODE),tighten(`${pluginConfigDir(id,homeDir)}/.env`,OWNER_ONLY_FILE_MODE),tighten(pluginLogPath(id,homeDir),OWNER_ONLY_FILE_MODE)}function tightenInstalledPluginPermissions(homeDir){tighten(pluginsRootDir(homeDir),OWNER_ONLY_DIR_MODE),tighten(pluginRegistryPath(homeDir),OWNER_ONLY_FILE_MODE);for(let entry of loadPluginRegistry(homeDir).plugins)tightenPluginPermissions(entry.id,homeDir)}var MONTH_NAMES=new Map([["JAN",1],["FEB",2],["MAR",3],["APR",4],["MAY",5],["JUN",6],["JUL",7],["AUG",8],["SEP",9],["OCT",10],["NOV",11],["DEC",12]]),DAY_NAMES=new Map([["SUN",0],["MON",1],["TUE",2],["WED",3],["THU",4],["FRI",5],["SAT",6]]);function fieldNumber(raw,names,field){let token=raw.toUpperCase(),named=names?.get(token);if(named!==void 0)return named;if(!/^\d+$/.test(token))throw Error(`invalid cron ${field}: ${raw}`);return Number(token)}function parseField(args){let out=new Set;for(let part of args.value.split(",")){if(part.length===0)throw Error(`invalid cron ${args.field}: ${args.value}`);let[spec,stepRaw,...extra]=part.split("/");if(extra.length>0||spec===void 0)throw Error(`invalid cron ${args.field}: ${part}`);let step=1;if(stepRaw!==void 0){if(!/^\d+$/.test(stepRaw))throw Error(`invalid cron ${args.field} step: ${part}`);if(step=Number(stepRaw),step<1)throw Error(`invalid cron ${args.field} step: ${part}`)}let lo,hi;if(spec==="*")lo=args.min,hi=args.max;else if(spec.includes("-")){let[loRaw,hiRaw,...rest]=spec.split("-");if(rest.length>0||loRaw===void 0||hiRaw===void 0)throw Error(`invalid cron ${args.field} range: ${part}`);lo=fieldNumber(loRaw,args.names,args.field),hi=fieldNumber(hiRaw,args.names,args.field)}else lo=fieldNumber(spec,args.names,args.field),hi=stepRaw===void 0?lo:args.max;if(lo<args.min||hi>args.max||lo>hi)throw Error(`cron ${args.field} out of range: ${part}`);for(let v=lo;v<=hi;v+=step)out.add(args.normalize?args.normalize(v):v)}return out}function parseCron(expression){if(expression.length>256)throw Error("cron expression is too long");let fields=expression.trim().split(/\s+/).filter(Boolean);if(fields.length!==5)throw Error(`cron expression needs 5 fields (minute hour day month weekday), got ${fields.length}`);let[minute,hour,dayOfMonth,month,dayOfWeek]=fields;return{minutes:parseField({value:minute,min:0,max:59,field:"minute"}),hours:parseField({value:hour,min:0,max:23,field:"hour"}),daysOfMonth:parseField({value:dayOfMonth,min:1,max:31,field:"day-of-month"}),months:parseField({value:month,min:1,max:12,field:"month",names:MONTH_NAMES}),daysOfWeek:parseField({value:dayOfWeek,min:0,max:7,field:"weekday",names:DAY_NAMES,normalize:(v)=>v%7}),dayOfMonthRestricted:dayOfMonth!=="*",dayOfWeekRestricted:dayOfWeek!=="*"}}function isValidCron(expression){try{return parseCron(expression),!0}catch{return!1}}function instantOf(d,hour,minute){return new Date(d.year,d.month-1,d.day,hour,minute,0,0).getTime()}function localDayOf(ms){let d=new Date(ms);return{year:d.getFullYear(),month:d.getMonth()+1,day:d.getDate()}}function shiftDay(d,delta){return localDayOf(new Date(d.year,d.month-1,d.day+delta,12,0,0,0).getTime())}function dayMatches(rule,d){if(!rule.months.has(d.month))return!1;let domMatch=rule.daysOfMonth.has(d.day),dowMatch=rule.daysOfWeek.has(new Date(d.year,d.month-1,d.day).getDay());if(rule.dayOfMonthRestricted&&rule.dayOfWeekRestricted)return domMatch||dowMatch;if(rule.dayOfMonthRestricted)return domMatch;if(rule.dayOfWeekRestricted)return dowMatch;return!0}function floorToMinute(ms){return ms-ms%60000}function sorted(values,direction){return[...values].sort((a,b)=>(a-b)*direction)}function nextCronAfter(expression,afterMs){let rule=parseCron(expression),hours=sorted(rule.hours,1),minutes=sorted(rule.minutes,1),from=new Date(floorToMinute(afterMs)+60000),day=localDayOf(from.getTime()),fromHour=from.getHours(),fromMinute=from.getMinutes();for(let i=0;i<3294;i++){if(dayMatches(rule,day))for(let hour of hours){if(hour<fromHour)continue;for(let minute of minutes){if(hour===fromHour&&minute<fromMinute)continue;let at=instantOf(day,hour,minute);if(at>afterMs)return at}}day=shiftDay(day,1),fromHour=0,fromMinute=0}throw Error(`cron expression never matches: ${expression}`)}function latestCronAtOrBefore(expression,nowMs,notBeforeMs){if(nowMs<notBeforeMs)return null;let rule=parseCron(expression),hours=sorted(rule.hours,-1),minutes=sorted(rule.minutes,-1),from=new Date(floorToMinute(nowMs)),day=localDayOf(from.getTime()),fromHour=from.getHours(),fromMinute=from.getMinutes();for(let i=0;i<3294;i++){if(instantOf(day,23,59)<notBeforeMs)return null;if(dayMatches(rule,day))for(let hour of hours){if(hour>fromHour)continue;for(let minute of minutes){if(hour===fromHour&&minute>fromMinute)continue;let at=instantOf(day,hour,minute);if(at>nowMs)continue;return at>=notBeforeMs?at:null}}day=shiftDay(day,-1),fromHour=23,fromMinute=59}return null}function countCronBetween(expression,fromMs,beforeMs,cap=500){if(!(fromMs<beforeMs))return 0;let count=0,cursor=fromMs-1;while(count<cap){let at;try{at=nextCronAfter(expression,cursor)}catch{return count}if(at>=beforeMs)return count;count+=1,cursor=at}return count}
|
|
3
|
+
export{tightenPluginPermissions,tightenInstalledPluginPermissions,isValidCron,nextCronAfter,latestCronAtOrBefore,countCronBetween};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{submitFeedback}from"./chunk-vkch2spv.js";import"./chunk-dnb2bmtb.js";import"./chunk-6dn6h640.js";import{activeCliName}from"./chunk-ef11h2am.js";import"./chunk-8ddjfc2v.js";import"./chunk-cb2fpajx.js";import"./chunk-3bfm4hrs.js";import"./chunk-wqfp8d9w.js";import{readFileSync}from"fs";var CLI_NAME=activeCliName(),FEEDBACK_USAGE=[`Usage: ${CLI_NAME} feedback --title <text> (--body <text> | --body-file <path>) [--category <slug>]`,"","Create a GitHub Discussion in the Rove repository using the GitHub CLI.","","Requires:"," gh auth login","","Options:"," --title <text> Discussion title"," --body <text> Discussion body"," --body-file <path> Read the Discussion body from a file; use - for stdin"," --category <slug> Discussion category slug (default: feedback)"," -h, --help Print this help",""].join(`
|
|
3
|
+
`);function usageError(message){process.stderr.write(`${CLI_NAME} feedback: ${message}
|
|
4
|
+
|
|
5
|
+
${FEEDBACK_USAGE}
|
|
6
|
+
`),process.exit(2)}function readBodyFile(path){if(path==="-")return readFileSync(0,"utf8");return readFileSync(path,"utf8")}function parseFeedbackArgs(args){let parsed={help:!1};for(let i=0;i<args.length;i++){let arg=args[i];if(arg==="--help"||arg==="-h"||arg==="help")return{...parsed,help:!0};if(arg==="--title"){if(parsed.title=args[++i],parsed.title===void 0)usageError("--title requires a value");continue}if(arg==="--body"){if(parsed.body=args[++i],parsed.body===void 0)usageError("--body requires a value");continue}if(arg==="--body-file"){if(parsed.bodyFile=args[++i],parsed.bodyFile===void 0)usageError("--body-file requires a value");continue}if(arg==="--category"){if(parsed.category=args[++i],parsed.category===void 0)usageError("--category requires a value");continue}usageError(`unexpected argument "${arg}"`)}return parsed}async function runFeedbackSubcommand(args){let parsed=parseFeedbackArgs(args);if(parsed.help){process.stdout.write(`${FEEDBACK_USAGE}
|
|
7
|
+
`);return}if(!parsed.title)usageError("--title is required");if(parsed.body&&parsed.bodyFile)usageError("pass either --body or --body-file, not both");let body=parsed.bodyFile?readBodyFile(parsed.bodyFile):parsed.body;if(!body)usageError("--body or --body-file is required");let result=submitFeedback({title:parsed.title,body,categorySlug:parsed.category});console.log(`created Discussion #${result.number}: ${result.url}`)}export{runFeedbackSubcommand,parseFeedbackArgs};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{RemoteExecHost,getKeychainPassword,isKeychainSupported,remoteKeychainRef,setKeychainPassword}from"./chunk-1kktfmtg.js";import"./chunk-2fypr41w.js";import{addRemoteRepo,isRemoteProjectsEnabled}from"./chunk-k3ksts6g.js";import"./chunk-gjf604bb.js";import{errorMessage}from"./chunk-2brn8e1y.js";import"./chunk-9c1e5z6a.js";import{remoteControlSocketPath}from"./chunk-6dn6h640.js";import{activeCliName}from"./chunk-ef11h2am.js";import"./chunk-8ddjfc2v.js";import"./chunk-cb2fpajx.js";import"./chunk-3bfm4hrs.js";import"./chunk-wqfp8d9w.js";import{createInterface}from"readline";var CLI_NAME=activeCliName(),USAGE=`Usage: ${CLI_NAME} add --remote --host <host> --user <user> --path <basePath>
|
|
3
|
+
[--port N] [--key [path] | --password]
|
|
4
|
+
|
|
5
|
+
Register an experimental SSH-backed project. Worktrees are created on <host>
|
|
6
|
+
under <basePath>; Hosted PTY engine launch over SSH is not implemented yet.
|
|
7
|
+
Choose ONE auth: --key [path] (ssh-agent when path omitted) or --password
|
|
8
|
+
(macOS only; prompted and stored in Keychain, never in state.json).
|
|
9
|
+
`;function parseRemoteFlags(args){let f={};for(let i=0;i<args.length;i++){let a=args[i];switch(a){case"--host":f.host=args[++i];break;case"--user":f.user=args[++i];break;case"--path":f.path=args[++i];break;case"--port":{let n=Number(args[++i]);if(!Number.isInteger(n)||n<=0)fail(`invalid --port "${args[i]}"`);f.port=n;break}case"--key":{let next=args[i+1];if(next&&!next.startsWith("-"))f.key={present:!0,path:next},i++;else f.key={present:!0};break}case"--password":f.password=!0;break;case"--help":case"-h":process.stdout.write(USAGE),process.exit(0);break;default:fail(`unknown flag "${a}"`)}}return f}function fail(msg){process.stderr.write(`${CLI_NAME} add --remote: ${msg}
|
|
10
|
+
|
|
11
|
+
${USAGE}`),process.exit(2)}async function promptHidden(prompt){let rl=createInterface({input:process.stdin,output:process.stdout,terminal:!0}),out=process.stdout,muted=!1,original=out._writeToOutput?.bind(out);return out._writeToOutput=(s)=>{if(!muted||!original)process.stdout.write(s)},process.stdout.write(prompt),muted=!0,new Promise((res)=>{rl.question("",(answer)=>{if(muted=!1,original)out._writeToOutput=original;process.stdout.write(`
|
|
12
|
+
`),rl.close(),res(answer)})})}async function runAddRemote(args){if(!isRemoteProjectsEnabled())fail("remote projects are experimental and disabled \u2014 enable Settings \u2192 Dev \u2192 Experimental \u2192 Remote projects first");let f=parseRemoteFlags(args);if(!f.host)fail("--host is required");if(!f.user)fail("--user is required");if(!f.path)fail("--path (remote base path) is required");if(f.key&&f.password)fail("choose ONE of --key or --password, not both");if(!f.key&&!f.password)fail("an auth method is required: --key [path] or --password");let auth;if(f.password){if(!isKeychainSupported())fail("--password needs the macOS keychain (unsupported on this platform)");let ref=remoteKeychainRef(f.host,f.user,f.port),pw=await promptHidden(`Password for ${f.user}@${f.host}: `);if(pw.length===0)fail("empty password");if(!setKeychainPassword(ref,pw))fail("failed to store the password in the keychain");auth={kind:"password",keychainRef:ref}}else auth={kind:"key",keyPath:f.key?.path};let{key,added}=addRemoteRepo({host:f.host,user:f.user,port:f.port,basePath:f.path,auth});console.log(added?`added remote project ${key} (base ${f.path})`:`updated remote project ${key} (base ${f.path})`),await probe(f,auth)}async function probe(f,auth){if(auth.kind==="password"&&!isKeychainSupported())return;let runtimeAuth=auth.kind==="key"?{kind:"key",keyPath:auth.keyPath}:{kind:"password",getPassword:()=>getKeychainPassword(auth.keychainRef)},spec={host:f.host,user:f.user,port:f.port,auth:runtimeAuth,controlPath:remoteControlSocketPath(f.host,f.user,f.port)};process.stdout.write("checking connection\u2026 ");try{if((await new RemoteExecHost(spec).run(["test","-d",f.path])).exitCode===0)console.log("ok");else console.log(`reachable, but base path "${f.path}" is not a directory (you can create it later)`)}catch(err){console.log(`could not connect (${errorMessage(err)})`),console.log("the project is saved; fix the host/credentials and it will connect on first use.")}}export{runAddRemote,parseRemoteFlags};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{TaskIndexStore}from"./chunk-6zwg6me2.js";import"./chunk-qkehg2c1.js";import"./chunk-qtke4x42.js";import"./chunk-xy8be792.js";import"./chunk-h82kzdsn.js";import"./chunk-8ddjfc2v.js";import"./chunk-cb2fpajx.js";import"./chunk-grh6dvfv.js";import"./chunk-pw6yfj10.js";import"./chunk-x760j10f.js";import"./chunk-3bfm4hrs.js";import"./chunk-wqfp8d9w.js";export{TaskIndexStore};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{pluginsOutdatedCachePath}from"./chunk-jyv82gf0.js";import{readFileSync,writeFileSync}from"fs";var OUTDATED_CACHE_TTL_MS=86400000;function writeOutdatedCache(outdatedIds,homeDir){let cache={checkedAt:Date.now(),outdated:outdatedIds};try{writeFileSync(pluginsOutdatedCachePath(homeDir),`${JSON.stringify(cache,null,2)}
|
|
3
|
+
`)}catch{}}function readOutdatedCache(homeDir){try{let cache=JSON.parse(readFileSync(pluginsOutdatedCachePath(homeDir),"utf8"));if(typeof cache.checkedAt!=="number"||!Array.isArray(cache.outdated))return[];if(Date.now()-cache.checkedAt>OUTDATED_CACHE_TTL_MS)return[];return cache.outdated.filter((id)=>typeof id==="string")}catch{return[]}}
|
|
4
|
+
export{writeOutdatedCache,readOutdatedCache};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{interactiveEngineCommand,listPresetIds}from"./chunk-q7dr9eh6.js";import{engineEntry}from"./chunk-yhcz2d2r.js";import{installedEngineIds}from"./chunk-df7qe9y7.js";import{spawnSync}from"child_process";import{statSync}from"fs";import path from"path";function whichOnPath(bin){let bunWhich=globalThis.Bun?.which;if(bunWhich)return bunWhich(bin);let out=spawnSync(process.platform==="win32"?"where":"which",[bin],{encoding:"utf8"});if(out.status!==0)return null;return out.stdout.split(`
|
|
3
|
+
`).map((l)=>l.trim()).find(Boolean)??null}var defaultDeps={which:whichOnPath,command:(vendor)=>interactiveEngineCommand(vendor)};function probeLaunchBinary(argv,which){let bin=argv[0]?.trim();if(!bin)return{found:!1,error:"no launch command"};if(bin.includes(path.sep)||bin.startsWith(".")){try{if(statSync(bin).isFile())return{found:!0,path:bin}}catch{}return{found:!1,error:`not found at ${bin}`}}let found=which(bin);return found?{found:!0,path:found}:{found:!1,error:"not found on PATH"}}async function detectEngineStatus(vendor,over={}){let deps={...defaultDeps,...over},detector=engineEntry(vendor).detectAccount;if(!detector)return{vendor,binary:probeLaunchBinary(deps.command(vendor),deps.which),account:null};let status=await detector(deps.accountDeps),binary=status.binary.found?status.binary:probeLaunchBinary(deps.command(vendor),deps.which);return{vendor,binary,account:status.account,accountError:status.accountError}}function detectEngineStatuses(vendors,over={}){return Promise.all(vendors.map((v)=>detectEngineStatus(v,over)))}function describeAccount(account){if(account===null)return"login not detectable";switch(account.kind){case"oauth":return"email"in account?`logged in (${account.email}${account.organization?`, ${account.organization}`:""})`:"logged in";case"chatgpt":return`logged in (${account.email}${account.plan?`, ${account.plan}`:""})`;case"apikey":return"API key";case"token":return`token (${account.source})`;default:return"no account"}}function engineUsable(status){return status.binary.found&&status.account?.kind!=="none"}async function probeableEngineIds(){return[...new Set([...listPresetIds(),...await installedEngineIds()])]}function summarizeEngines(statuses){let usable=[],signedOut=[];for(let status of statuses)if(engineUsable(status))usable.push(status.vendor);else if(status.binary.found)signedOut.push(status.vendor);return{usable,signedOut}}
|
|
4
|
+
export{detectEngineStatuses,describeAccount,probeableEngineIds,summarizeEngines};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{buildEngineSessionLaunch,trustEngineWorktree}from"./chunk-8arm7k43.js";import{engineForkArgv,engineResumeArgv,withPinnedSessionId}from"./chunk-q7dr9eh6.js";import{t}from"./chunk-q9x6d0k6.js";import{engineEntry,engineStatusPrefixes,isEnginePlaceholderTitle,stripEngineStatusPrefix}from"./chunk-yhcz2d2r.js";import*as fs from"fs";import*as os from"os";function pathLeaf(p){return p.slice(p.lastIndexOf("/")+1)}function expandHome(p){if(p==="~")return os.homedir();if(p.startsWith("~/"))return os.homedir()+p.slice(1);return p}function stripTrailingSlash(p){return p.length>1&&p.endsWith("/")?p.slice(0,-1):p}function splitPathForDirSuggest(value){if(!value)return{base:"",filter:""};let expanded=expandHome(value==="~"?"~/":value);if(expanded.endsWith("/"))return{base:expanded,filter:""};let lastSlash=expanded.lastIndexOf("/");if(lastSlash===-1)return{base:"",filter:expanded};return{base:expanded.slice(0,lastSlash+1),filter:expanded.slice(lastSlash+1)}}function listSubdirs(base){if(!base)return[];try{let entries=fs.readdirSync(base,{withFileTypes:!0}),out=[];for(let e of entries)if(e.isDirectory())out.push(e.name);return out.sort((a,b)=>a.localeCompare(b))}catch{return[]}}function filterSubdirs(all,filter){let f=filter.toLowerCase(),visible=f.startsWith(".")?all:all.filter((n)=>!n.startsWith("."));if(!f)return visible;return visible.filter((n)=>n.toLowerCase().startsWith(f))}function joinDrill(typedValue,baseExpanded,name){let out=`${baseExpanded+name}/`;if(typedValue.startsWith("~")){let home=os.homedir();if(out===`${home}/`)return"~/";if(out.startsWith(`${home}/`))return`~${out.slice(home.length)}`}return out}function joinPicked(typedValue,baseExpanded,name){let out=baseExpanded+name;if(typedValue.startsWith("~")){let home=os.homedir();if(out===home)return"~";if(out.startsWith(`${home}/`))return`~${out.slice(home.length)}`}return out}function depth(node){return node.kind==="leaf"?0:1+Math.max(...node.children.map(depth))}function siblingCount(root,id,orientation){let find=(node)=>{if(node.kind==="leaf")return null;if(node.orientation===orientation&&node.children.some((c)=>c.kind==="leaf"&&c.id===id))return node.children.length;for(let child of node.children){let n=find(child);if(n!==null)return n}return null};return find(root)??1}function splitFits(state,orientation,activeSize){let extent=orientation==="row"?activeSize.cols:activeSize.rows,min=orientation==="row"?20:6,n=siblingCount(state.root,state.activeLeafId,orientation);return Math.floor(extent*n/(n+1))-1>=min}function initialSplit(content){return{root:{kind:"leaf",id:"leaf-1",content},activeLeafId:"leaf-1",nextOrdinal:2}}function leaves(node){return node.kind==="leaf"?[node]:node.children.flatMap(leaves)}function splitActive(state,orientation,content,activeSize){if(activeSize&&!splitFits(state,orientation,activeSize))return state;let leaf={kind:"leaf",id:`leaf-${state.nextOrdinal}`,content},insert=(node)=>{if(node.kind==="leaf"){if(node.id!==state.activeLeafId)return node;return{kind:"group",orientation,children:[node,leaf]}}if(node.orientation===orientation){let i=node.children.findIndex((c)=>c.kind==="leaf"&&c.id===state.activeLeafId);if(i>=0){let children=[...node.children.slice(0,i+1),leaf,...node.children.slice(i+1)];return{...node,children}}}return{...node,children:node.children.map(insert)}},root=insert(state.root);if(!activeSize&&depth(root)>4)return state;return{root,activeLeafId:leaf.id,nextOrdinal:state.nextOrdinal+1}}function removeLeaf(state,id){let all=leaves(state.root);if(all.length<=1)return null;let prune=(node)=>{if(node.kind==="leaf")return node.id===id?null:node;let children=node.children.map(prune).filter((c)=>c!==null);if(children.length===0)return null;if(children.length===1)return children[0];return{...node,children}},root=prune(state.root);if(root===null)return null;if(leaves(root).length===all.length)return state;let order=all.map((l)=>l.id),removedIdx=order.indexOf(id),fallback=order[removedIdx>0?removedIdx-1:removedIdx+1],activeLeafId=state.activeLeafId===id?fallback:state.activeLeafId;return{...state,root,activeLeafId}}function renameLeaf(state,id,title){let trimmed=title.trim(),next=trimmed.length>0?trimmed:null,walk=(node)=>node.kind==="leaf"?node.id===id?{...node,title:next}:node:{...node,children:node.children.map(walk)};if(!leaves(state.root).some((l)=>l.id===id))return state;return{...state,root:walk(state.root)}}function cycleLeaf(state,delta){let order=leaves(state.root).map((l)=>l.id);if(order.length<=1)return state;let i=order.indexOf(state.activeLeafId),next=order[(i+delta+order.length)%order.length];return{...state,activeLeafId:next}}function hasEngineLeaf(tree){return!tree||leaves(tree.root).some((l)=>l.id==="leaf-1")}function isTabSplit(tree){return tree?leaves(tree.root).length>1:!1}function collapseSplit(next){let ls=leaves(next.root);return ls.length===1&&ls[0]?.id==="leaf-1"?null:next}function splitLeafPtyKey(tabKey,leafId){return leafId==="leaf-1"?tabKey:`${tabKey}::${leafId}`}var SHELL_LEAF_NAME="shell";function splitLeafNames(leafList,tabCommand,engineTitle,liveTitles){let basename=(argv)=>{let head=(argv??tabCommand)[0]??"",name=pathLeaf(head);return name.length>0?name:"?"},seen=new Map,out=new Map;for(let leaf of leafList){if(leaf.title){out.set(leaf.id,leaf.title);continue}let name=leaf.content===null?engineTitle||liveTitles?.get(leaf.id)||basename(leaf.content):liveTitles?.get(leaf.id)||SHELL_LEAF_NAME,n=(seen.get(name)??0)+1;seen.set(name,n),out.set(leaf.id,n===1?name:`${name} ${n}`)}return out}function meaningfulAutoTitle(autoTitle){let trimmed=(autoTitle??"").trim();if(trimmed.length<3)return null;if(/^[\d\s\p{P}\p{S}]+$/u.test(trimmed))return null;return trimmed}function stableRecordedTitle(raw,vendor){let recorded=raw?.trim();if(!recorded)return null;let cleaned=stripEngineStatusPrefix(recorded,vendor);if(cleaned===recorded&&isEngineDecoration(recorded,vendor))return null;if(isEnginePlaceholderTitle(cleaned,vendor))return null;return cleaned||null}function isEngineDecoration(text,vendor){let glyphs=new Set(engineStatusPrefixes(vendor));return[...text].every((ch)=>ch.trim().length===0||glyphs.has(ch))}function tabTitleStable(tab,taskVendor,liveVendor,liveTitle){if(liveVendor===null&&tab.kind==="engine")return tabTitle({...tab,kind:"command",lastTitle:null},taskVendor);let vendor=liveVendor??tab.liveVendor??(tab.kind==="engine"?tab.vendor??taskVendor:void 0)??void 0,source=liveTitle?.trim()||tab.lastTitle,named=vendor?stableRecordedTitle(source,vendor):source??null;if(!vendor||engineEntry(vendor).terminalTitle?.ownsStatus!==!0)return tabTitle({...tab,lastTitle:named},taskVendor);return tabTitle({...tab,kind:"engine",vendor,lastTitle:named},taskVendor)}function titleVendor(tab,taskVendor){return tab.liveVendor??(tab.kind==="engine"?tab.vendor:void 0)??taskVendor}function tabTitle(tab,taskVendor,liveName){if(tab.title)return tab.title;let ls=tab.splitTree?leaves(tab.splitTree.root):[];if(ls.length>1)return t("terminal.tab.groupTitle",{n:tab.ordinal});let sole=ls.length===1?ls[0]:void 0;if(sole&&sole.id!=="leaf-1")return sole.title??`${liveName??SHELL_LEAF_NAME} ${tab.ordinal}`;let vendor=titleVendor(tab,taskVendor);if(liveName&&!isEnginePlaceholderTitle(liveName,vendor))return`${liveName} ${tab.ordinal}`;if(tab.lastTitle&&!isEnginePlaceholderTitle(tab.lastTitle,vendor))return`${tab.lastTitle} ${tab.ordinal}`;let auto=meaningfulAutoTitle(tab.autoTitle);if(auto)return auto;return`${tab.kind==="engine"?engineEntry(tab.vendor??taskVendor).defaultCommand[0]??SHELL_LEAF_NAME:SHELL_LEAF_NAME} ${tab.ordinal}`}function visibleNativeStatus(tab,taskVendor,vendor,liveName){if(!vendor||!liveName)return!1;if(engineEntry(vendor).terminalTitle?.ownsStatus!==!0)return!1;return tabTitle(tab,taskVendor,liveName)===`${liveName} ${tab.ordinal}`}function initialTabs(){return{tabs:[{kind:"engine",id:"tab-1",title:null,ordinal:1}],activeId:"tab-1",nextOrdinal:2}}function reopenHintFor(closed){if(closed?.kind==="command")return{kind:"command"};if(closed?.kind==="engine"&&closed.vendor)return{kind:"engine",vendor:closed.vendor};return{kind:"engine"}}function reopenTabs(state,shell){let ordinal=state.nextOrdinal,id=`tab-${ordinal}`,next=state.nextOrdinal+1;if(state.reopenAs?.kind==="command")return{tabs:[{kind:"command",id,title:null,ordinal,command:[shell]}],activeId:id,nextOrdinal:next};let vendor=state.reopenAs?.kind==="engine"?state.reopenAs.vendor:void 0;return{tabs:[{kind:"engine",id,title:null,ordinal,...vendor?{vendor}:{}}],activeId:id,nextOrdinal:next}}function initialShellTabs(shell){return{tabs:[{kind:"command",id:"tab-1",title:null,ordinal:1,command:[shell]}],activeId:"tab-1",nextOrdinal:2}}function rehydrateTabs(persisted,shell,opts={}){let tabs=persisted.tabs.map((t2)=>t2.kind==="command"?{...t2,command:shell,purpose:void 0}:t2);if(tabs.length===0)return opts.allowEmpty?persisted:initialTabs();let activeId=tabs.some((t2)=>t2.id===persisted.activeId)?persisted.activeId:tabs[0].id,maxOrdinal=tabs.reduce((max,t2)=>Math.max(max,t2.ordinal),0);return{tabs,activeId,nextOrdinal:Math.max(persisted.nextOrdinal,maxOrdinal+1)}}function recycleTabs(state,prev){let ordinal=state.nextOrdinal,id=`tab-${ordinal}`,pinned=prev.kind==="engine"?prev:void 0;return{tabs:[{kind:"engine",id,ordinal,title:prev.title,autoTitle:prev.autoTitle,...pinned?.vendor?{vendor:pinned.vendor}:{},...pinned?.engineCommand?{engineCommand:pinned.engineCommand}:{}}],activeId:id,nextOrdinal:ordinal+1}}function engineTabArgv(tab,base,live,fallbackVendor){if(tab.forkFrom&&!tab.spawned&&!live){let forked=tab.vendor?engineForkArgv(base,tab.vendor,tab.forkFrom,tab.sessionId??null):null;if(forked)return forked}if(!tab.sessionId)return base;let vendor=tab.vendor??fallbackVendor;if(tab.spawned&&!live)return engineResumeArgv(base,vendor,tab.sessionId)??base;return withPinnedSessionId(base,vendor,()=>tab.sessionId).argv}function engineTabSpawnFor(state,tab,base,opts){let{live,shell,prompt}=opts,firstEngine=state.tabs.find((t2)=>t2.kind==="engine"),fresh=!tab.spawned&&!live,tabPrompt=fresh?tab.initialPrompt?.trim():void 0,wantsPrompt=!!prompt&&tab.id===firstEngine?.id&&fresh,isFreshFirstEngine=tab.id===firstEngine?.id&&fresh,promptIntent=tabPrompt?{kind:"explicit",prompt:tabPrompt}:wantsPrompt?{kind:"new-task",prompt}:isFreshFirstEngine?{kind:"repo-init"}:{kind:"none"},ref=tab.ptyTask;trustEngineWorktree(tab.vendor??opts.task.vendor,ref?.worktree??opts.worktreePath);let launch=buildEngineSessionLaunch({task:ref?{...opts.task,id:ref.id,kind:"task"}:opts.task,worktreePath:ref?.worktree??opts.worktreePath,shell,argv:engineTabArgv(tab,base,live,opts.task.vendor),promptIntent,protocolGates:opts.protocolGates,tabId:ref?"tab-1":tab.id});return{command:launch.command,...launch.firstMessage?{firstMessage:launch.firstMessage,engineBin:base[0]}:{}}}function tabExitAction(tab,deadOnAttach,resumeTried){if(tab.kind==="engine"&&deadOnAttach&&!!tab.sessionId&&tab.spawned&&!resumeTried)return"resume";return"close"}var SHELL_SAFE_ARG=/^[A-Za-z0-9@%+=:,./_-]+$/;function shellCommandLine(argv){return argv.map((a)=>SHELL_SAFE_ARG.test(a)?a:`'${a.replaceAll("'","'\\''")}'`).join(" ")}function shellIdentityInput(taskId,tabId){let task=shellCommandLine([taskId]),tab=shellCommandLine([tabId]);return` export ROVE_TASK_ID=${task} KOBE_TASK_ID=${task} ROVE_TAB_ID=${tab} KOBE_TAB_ID=${tab} && clear\r`}function insertAfterActive(state,tab){let i=state.tabs.findIndex((t2)=>t2.id===state.activeId);return{tabs:[...state.tabs.slice(0,i+1),tab,...state.tabs.slice(i+1)],activeId:tab.id,nextOrdinal:state.nextOrdinal+1}}function addTab(state,vendor){let ordinal=state.nextOrdinal;return insertAfterActive(state,{kind:"engine",id:`tab-${ordinal}`,title:null,ordinal,vendor})}function openCommandTab(state,command,label){let ordinal=state.nextOrdinal;return insertAfterActive(state,{kind:"command",id:`tab-${ordinal}`,title:label,ordinal,command})}function findEditorTab(state){return state.tabs.find((tab)=>tab.kind==="command"&&tab.purpose==="editor")}function openEditorTab(state,command,label){let existing=findEditorTab(state);if(!existing){let ordinal=state.nextOrdinal;return insertAfterActive(state,{kind:"command",id:`tab-${ordinal}`,title:label,ordinal,command,purpose:"editor"})}let tabs=state.tabs.map((tab)=>tab.id===existing.id?{...existing,title:label,command,splitTree:null}:tab);return{...state,tabs,activeId:existing.id}}function findContentTab(state){return state.tabs.find((tab)=>tab.kind==="content")}function openContentTab(state,relPath,label,base){let existing=findContentTab(state);if(!existing){let ordinal=state.nextOrdinal;return insertAfterActive(state,{kind:"content",id:`tab-${ordinal}`,title:label,ordinal,relPath,base})}let tabs=state.tabs.map((tab)=>tab.id===existing.id?{...existing,title:label,relPath,base}:tab);return{...state,tabs,activeId:existing.id}}function closeTab(state,id,opts={}){if(state.tabs.length<=1&&!opts.allowEmpty)return{state,closedId:null};let i=state.tabs.findIndex((t2)=>t2.id===id);if(i<0)return{state,closedId:null};let tabs=state.tabs.filter((t2)=>t2.id!==id);if(state.activeId!==id)return{state:{...state,tabs},closedId:id};if(tabs.length===0)return{state:{...state,tabs,activeId:id,reopenAs:reopenHintFor(state.tabs[i])},closedId:id};let next=tabs[Math.max(0,i-1)];return{state:{...state,tabs,activeId:(next??tabs[0]).id},closedId:id}}function closeActiveTab(state){return closeTab(state,state.activeId)}function renameActiveTab(state,title){let trimmed=title.trim(),tabs=state.tabs.map((t2)=>t2.id===state.activeId?{...t2,title:trimmed.length>0?trimmed:null}:t2);return{...state,tabs}}function setTabSessionId(state,id,sessionId){let tabs=state.tabs.map((t2)=>t2.id===id&&t2.kind==="engine"?{...t2,sessionId}:t2);return{...state,tabs}}function setTabForkFrom(state,id,sourceSessionId){let tabs=state.tabs.map((t2)=>t2.id===id&&t2.kind==="engine"?{...t2,forkFrom:sourceSessionId}:t2);return{...state,tabs}}function setTabEngineCommand(state,id,command){let tabs=state.tabs.map((t2)=>t2.id===id&&t2.kind==="engine"?{...t2,engineCommand:command}:t2);return{...state,tabs}}function setTabInitialPrompt(state,id,prompt){let tabs=state.tabs.map((t2)=>t2.id===id&&t2.kind==="engine"?{...t2,initialPrompt:prompt}:t2);return{...state,tabs}}function setTabLastTitle(state,id,lastTitle){if(lastTitle.length===0)return state;let current=state.tabs.find((t2)=>t2.id===id);if(!current||current.lastTitle===lastTitle)return state;let tabs=state.tabs.map((t2)=>t2.id===id?{...t2,lastTitle}:t2);return{...state,tabs}}function setTabLiveVendor(state,id,liveVendor){let current=state.tabs.find((t2)=>t2.id===id);if(!current||(current.liveVendor??null)===liveVendor)return state;let tabs=state.tabs.map((t2)=>t2.id===id?{...t2,liveVendor}:t2);return{...state,tabs}}function setTabAutoTitle(state,id,autoTitle){let tabs=state.tabs.map((t2)=>t2.id===id?{...t2,autoTitle}:t2);return{...state,tabs}}function setTabSpawned(state,id,spawned){let tabs=state.tabs.map((t2)=>t2.id===id&&t2.kind==="engine"&&!t2.spawned!==!spawned?{...t2,spawned}:t2);return{...state,tabs}}function cycleTab(state,delta){let n=state.tabs.length;if(n<=1)return state;let i=state.tabs.findIndex((t2)=>t2.id===state.activeId),next=state.tabs[(i+delta+n)%n];return{...state,activeId:next.id}}function moveTab(state,id,delta){let i=state.tabs.findIndex((t2)=>t2.id===id),j=i+delta;if(i<0||j<0||j>=state.tabs.length)return state;let tabs=[...state.tabs],a=tabs[i];return tabs[i]=tabs[j],tabs[j]=a,{...state,tabs}}function selectTab(state,id){if(state.activeId===id||!state.tabs.some((t2)=>t2.id===id))return state;return{...state,activeId:id}}function setTabSplit(state,id,tree){if(!state.tabs.some((t2)=>t2.id===id))return state;let tabs=state.tabs.map((t2)=>t2.id===id?{...t2,splitTree:tree}:t2);return{...state,tabs}}function tabPtyKey(taskId,tabId){return`${taskId}::${tabId}`}function tabPtyKeyFor(taskId,tab){if(tab.kind==="engine"&&tab.ptyTask)return tabPtyKey(tab.ptyTask.id,"tab-1");return tabPtyKey(taskId,tab.id)}function tabCwdFor(tab,taskWorktree){if(tab.kind==="engine"&&tab.ptyTask)return tab.ptyTask.worktree;return taskWorktree}function terminalTabsKey(taskId){return`terminalTabs.${taskId}`}function forgetTaskTabsSnapshot(kv,taskId){let key=terminalTabsKey(taskId);if(kv.store[key]===void 0)return;kv.set(key,void 0)}function sweepOrphanTabsSnapshots(kv,liveTaskIds){let live=new Set(liveTaskIds),swept=0;for(let key of Object.keys(kv.store)){if(!key.startsWith("terminalTabs."))continue;let taskId=key.slice(13);if(live.has(taskId))continue;kv.set(key,void 0),swept++}return swept}
|
|
3
|
+
export{pathLeaf,expandHome,stripTrailingSlash,splitPathForDirSuggest,listSubdirs,filterSubdirs,joinDrill,joinPicked,initialSplit,leaves,splitActive,removeLeaf,renameLeaf,cycleLeaf,hasEngineLeaf,isTabSplit,collapseSplit,splitLeafPtyKey,splitLeafNames,tabTitleStable,tabTitle,visibleNativeStatus,initialTabs,reopenTabs,initialShellTabs,rehydrateTabs,recycleTabs,engineTabArgv,engineTabSpawnFor,tabExitAction,shellIdentityInput,addTab,openCommandTab,findEditorTab,openEditorTab,openContentTab,closeTab,closeActiveTab,renameActiveTab,setTabSessionId,setTabForkFrom,setTabEngineCommand,setTabInitialPrompt,setTabLastTitle,setTabLiveVendor,setTabAutoTitle,setTabSpawned,cycleTab,moveTab,selectTab,setTabSplit,tabPtyKey,tabPtyKeyFor,tabCwdFor,terminalTabsKey,forgetTaskTabsSnapshot,sweepOrphanTabsSnapshots};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{releaseBodyLines,runShellUpdater}from"./chunk-dwsgeq06.js";import{$jsx,$jsxs,bootPaneHost,pageCloseBindings,require_react_production,useBindings,useRenderer,useT,useTheme}from"./chunk-fe34e0w7.js";import"./chunk-764bsyb0.js";import"./chunk-mjvq39gf.js";import"./chunk-6xppe9bj.js";import{BREAKING_VERSIONS,CURRENT_VERSION,UPDATE_COMMAND,breakingVersionsCrossed,fetchReleaseNotes,fetchReleaseSummaries}from"./chunk-dnb2bmtb.js";import"./chunk-jdbfawrm.js";import"./chunk-q9x6d0k6.js";import"./chunk-w298ayjc.js";import"./chunk-sdyzxayr.js";import"./chunk-0sm2k04y.js";import"./chunk-5bn91n19.js";import"./chunk-pdh5w4ht.js";import"./chunk-4wwx51m5.js";import"./chunk-79gqh5p2.js";import"./chunk-3ztek08w.js";import"./chunk-kwe61yx7.js";import"./chunk-gjf604bb.js";import"./chunk-xy8be792.js";import"./chunk-2brn8e1y.js";import"./chunk-6dn6h640.js";import"./chunk-cb2fpajx.js";import"./chunk-grh6dvfv.js";import"./chunk-pw6yfj10.js";import"./chunk-x760j10f.js";import"./chunk-3bfm4hrs.js";import{__toESM}from"./chunk-wqfp8d9w.js";import{TextAttributes}from"@opentui/core";var import_react2=__toESM(require_react_production(),1);var RELEASE_LIMIT=20;function VersionsPage(props){let{theme}=useTheme(),t=useT(),renderer=useRenderer(),[releases,setReleases]=import_react2.useState(null),[cursor,setCursor]=import_react2.useState(0),[notes,setNotes]=import_react2.useState({}),[status,setStatus]=import_react2.useState(null),selected=releases?.[cursor],crossings=selected?breakingVersionsCrossed(CURRENT_VERSION,selected.version):[];import_react2.useEffect(()=>{fetchReleaseSummaries(RELEASE_LIMIT).then((fetched)=>setReleases(fetched))},[]);let selectedVersion=selected?.version;import_react2.useEffect(()=>{if(selectedVersion===void 0||notes[selectedVersion]!==void 0)return;setNotes((cache)=>({...cache,[selectedVersion]:"loading"})),fetchReleaseNotes(selectedVersion).then((fetched)=>{setNotes((cache)=>({...cache,[selectedVersion]:fetched??"missing"}))})},[selectedVersion,notes]);function move(delta){let count=releases?.length??0;if(count===0)return;setCursor((index)=>(index+delta+count)%count)}async function installSelected(){if(!selected)return;setStatus(t("update.statusRunningUpdater")),await new Promise((resolve)=>setTimeout(resolve,30)),await runShellUpdater({renderer,t,targetLabel:selected.version,command:`${UPDATE_COMMAND} -s -- ${selected.version}`})}useBindings(()=>({bindings:[{key:"up",cmd:()=>move(-1)},{key:"down",cmd:()=>move(1)},{key:"k",cmd:()=>move(-1)},{key:"j",cmd:()=>move(1)},{key:"return",cmd:()=>void installSelected()},{key:"u",cmd:()=>void installSelected()},...pageCloseBindings(props.onClose)]}));let selectedNotes=selectedVersion===void 0?void 0:notes[selectedVersion];return $jsxs("box",{flexDirection:"column",flexGrow:1,paddingTop:1,paddingLeft:2,paddingRight:2,children:[$jsxs("box",{flexDirection:"row",justifyContent:"space-between",flexShrink:0,children:[$jsx("text",{fg:theme.text,attributes:TextAttributes.BOLD,wrapMode:"none",children:t("update.versions.pageTitle")}),$jsx("text",{fg:theme.textMuted,wrapMode:"none",onMouseUp:props.onClose,children:"q / esc"})]}),$jsxs("box",{flexDirection:"row",flexGrow:1,paddingTop:1,gap:2,children:[$jsxs("box",{flexDirection:"column",width:26,flexShrink:0,children:[releases===null?$jsx("text",{fg:theme.textMuted,children:t("update.versions.loading")}):null,releases!==null&&releases.length===0?$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t("update.versions.unavailable")}):null,(releases??[]).map((release,index)=>{let active=index===cursor,tags=[release.version===CURRENT_VERSION?t("update.versions.tagCurrent"):"",index===0?t("update.versions.tagLatest"):"",BREAKING_VERSIONS.includes(release.version)?t("update.versions.tagBreaking"):""].filter(Boolean).join(" ");return $jsxs("box",{flexDirection:"row",gap:1,paddingLeft:1,backgroundColor:active?theme.primary:void 0,onMouseUp:()=>setCursor(index),children:[$jsxs("text",{fg:active?theme.selectedListItemText:theme.text,attributes:release.version===CURRENT_VERSION?TextAttributes.BOLD:void 0,wrapMode:"none",children:["v",release.version]}),tags?$jsx("text",{fg:active?theme.selectedListItemText:theme.textMuted,wrapMode:"none",children:tags}):null]},release.version)})]}),$jsxs("box",{flexDirection:"column",flexGrow:1,flexShrink:1,children:[$jsx("scrollbox",{flexGrow:1,flexShrink:1,stickyScroll:!1,verticalScrollbarOptions:{trackOptions:{backgroundColor:theme.background,foregroundColor:theme.borderActive}},children:$jsxs("box",{flexDirection:"column",paddingRight:1,paddingBottom:1,gap:0,children:[selectedNotes==="loading"?$jsx("text",{fg:theme.textMuted,children:t("update.loadingNotes")}):null,selectedNotes==="missing"?$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:t("update.notesUnavailable")}):null,selectedNotes!==void 0&&selectedNotes!=="loading"&&selectedNotes!=="missing"?releaseBodyLines(selectedNotes.body).map((line,i)=>$jsx("text",{fg:theme.textMuted,wrapMode:"word",children:line},`${i}:${line}`)):null]})}),crossings.length>0?$jsx("text",{fg:theme.warning,wrapMode:"word",children:t("update.versions.breakingWarning",{versions:crossings.join(", ")})}):null]})]}),status?$jsx("text",{fg:theme.info,wrapMode:"word",children:status}):null,$jsx("box",{flexShrink:0,paddingTop:1,children:$jsx("text",{fg:theme.textMuted,attributes:TextAttributes.DIM,wrapMode:"none",children:t("update.versions.footerHint")})})]})}var INLINE_ROWS=24;async function startVersionsHost(){await bootPaneHost({inlineRows:INLINE_ROWS,setup:()=>({root:()=>$jsx(VersionsPage,{onClose:()=>process.exit(0)})})})}export{startVersionsHost};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{readOnlyGitProcessEnv}from"./chunk-6xppe9bj.js";import{quoteShellArg}from"./chunk-2fypr41w.js";import{getPersistedString}from"./chunk-k3ksts6g.js";var EDITOR_KINDS=["auto","vim","nvim","nano","emacs","custom"],AUTO_EDITOR_CANDIDATES=["nvim","vim","emacs","nano"],EDITOR_KIND_KEY="editor.kind",EDITOR_CUSTOM_KEY="editor.customCommand",DEFAULT_EDITOR_KIND="auto";function normalizeEditorKind(value){return EDITOR_KINDS.includes(value)?value:"auto"}var FILE_PLACEHOLDER="{file}";function firstToken(cmd){return cmd.trim().split(/\s+/)[0]??""}function buildEditorCommand(kind,customCommand,absPath,envEditor){let file=quoteShellArg(absPath);if(kind==="vim")return{bin:"vim",command:`vim ${file}`};if(kind==="nvim")return{bin:"nvim",command:`nvim ${file}`};if(kind==="nano")return{bin:"nano",command:`nano ${file}`};if(kind==="emacs")return{bin:"emacs",command:`emacs ${file}`};let tmpl=(customCommand.trim()||(envEditor??"").trim()).trim();if(!tmpl)return null;let bin=firstToken(tmpl);if(!bin)return null;let command=tmpl.includes(FILE_PLACEHOLDER)?tmpl.split(FILE_PLACEHOLDER).join(file):`${tmpl} ${file}`;return{bin,command}}function buildNvimDiffCommand(bin,absPath,relPath){let file=quoteShellArg(absPath);return["f=$(mktemp 2>/dev/null)",`if [ -n "$f" ] && git show ${quoteShellArg(`HEAD:./${relPath}`)} > "$f" 2>/dev/null; then`,` ${bin} -d "$f" ${file} -c 'setlocal nomodifiable' -c 'wincmd l'; r=$?`,"else",` ${bin} ${file}; r=$?`,"fi",'rm -f "$f" 2>/dev/null; exit $r'].join(`
|
|
3
|
+
`)}function relativeToWorktree(worktree,absPath){let prefix=worktree.endsWith("/")?worktree:`${worktree}/`;return absPath.startsWith(prefix)?absPath.slice(prefix.length):null}async function resolveEditorCommand(absPath){let kind=normalizeEditorKind(getPersistedString(EDITOR_KIND_KEY)),custom=getPersistedString(EDITOR_CUSTOM_KEY)??"",env=(process.env.VISUAL??process.env.EDITOR??"").trim();if(kind!=="auto")return buildEditorCommand(kind,custom,absPath,env);if(env)return buildEditorCommand("custom","",absPath,env);let file=quoteShellArg(absPath);for(let bin of AUTO_EDITOR_CANDIDATES)if(await binaryAvailable(bin))return{bin,command:`${bin} ${file}`};return null}async function binaryAvailable(bin){try{return await Bun.spawn(["sh","-c",`command -v ${quoteShellArg(bin)} >/dev/null 2>&1`],{stdin:"ignore",stdout:"ignore",stderr:"ignore"}).exited===0}catch{return!1}}async function fileHasDiff(worktree,relPath){try{return await Bun.spawn(["git","diff","--quiet","HEAD","--",relPath],{cwd:worktree,stdin:"ignore",stdout:"ignore",stderr:"ignore",env:readOnlyGitProcessEnv()}).exited===1}catch{return!1}}async function resolveEditorLaunch(worktree,absPath){let resolved=await resolveEditorCommand(absPath);if(!resolved)return null;if(!await binaryAvailable(resolved.bin))return null;return{command:await maybeDiffCommand(resolved,worktree,absPath),label:editorWindowLabel(absPath)}}async function maybeDiffCommand(resolved,worktree,absPath){let{bin,command}=resolved;if(bin!=="nvim"&&bin!=="vim")return command;if(command!==`${bin} ${quoteShellArg(absPath)}`)return command;let rel=relativeToWorktree(worktree,absPath);if(!rel)return command;if(!await fileHasDiff(worktree,rel))return command;return buildNvimDiffCommand(bin,absPath,rel)}function editorWindowLabel(absPath){let base=absPath.slice(absPath.lastIndexOf("/")+1).trim();return base.length>0?base:"edit"}
|
|
4
|
+
export{EDITOR_KINDS,EDITOR_KIND_KEY,EDITOR_CUSTOM_KEY,DEFAULT_EDITOR_KIND,normalizeEditorKind,resolveEditorCommand,binaryAvailable,resolveEditorLaunch};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{readPidFile}from"./chunk-4wwx51m5.js";import{KobeDaemonClient}from"./chunk-79gqh5p2.js";import{unlink}from"fs/promises";function isProcessAlive(pid){try{return process.kill(pid,0),!0}catch(err){return err.code==="EPERM"}}async function stopDaemonProcess(socketPath,pidPath){let oldPid=await readPidFile(pidPath),targetPid=oldPid!==null&&oldPid!==process.pid?oldPid:null,wasAlive=targetPid!==null&&isProcessAlive(targetPid),method=wasAlive?"graceful":"absent",client=new KobeDaemonClient(socketPath),stopRequest=client.request("daemon.stop").catch(()=>{return}),stopTimeout=new Promise((resolve)=>setTimeout(resolve,2000));if(await Promise.race([stopRequest,stopTimeout]),client.close(),wasAlive&&targetPid!==null){let deadline=Date.now()+5000,escalated=!1;while(Date.now()<deadline){try{process.kill(targetPid,0)}catch{break}if(!escalated&&Date.now()-(deadline-5000)>2000){try{process.kill(targetPid,"SIGTERM")}catch{}method="sigterm",escalated=!0}await new Promise((resolve)=>setTimeout(resolve,50))}try{process.kill(targetPid,0),process.kill(targetPid,"SIGKILL"),method="sigkill",await new Promise((resolve)=>setTimeout(resolve,100))}catch{}}let survivor=await readPidFile(pidPath);if(survivor!==null&&survivor!==process.pid&&isProcessAlive(survivor))return{pid:oldPid,method};return await unlink(socketPath).catch(()=>{}),await unlink(pidPath).catch(()=>{}),{pid:oldPid,method}}
|
|
3
|
+
export{isProcessAlive,stopDaemonProcess};
|