@captainsafia/stitch 1.0.0-preview.c77f34b → 1.0.0-preview.f2fe33d
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/dist/api.d.ts +88 -0
- package/dist/api.js +793 -438
- package/dist/cli.js +1357 -784
- package/dist/mcp.js +22839 -22449
- package/package.json +2 -1
package/dist/api.js
CHANGED
|
@@ -1,94 +1,80 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
9
13
|
|
|
10
14
|
// src/core/errors.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
class NotInitializedError extends StitchError {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
15
|
+
var StitchError, RepoNotFoundError, NotInitializedError, NoCurrentStitchError, StitchNotFoundError, GitError, ValidationError, FinishForceRequiredError, InvalidSupersededByError;
|
|
16
|
+
var init_errors = __esm(() => {
|
|
17
|
+
StitchError = class StitchError extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "StitchError";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
RepoNotFoundError = class RepoNotFoundError extends StitchError {
|
|
24
|
+
constructor(path) {
|
|
25
|
+
super(path ? `Not a git repository: ${path}` : "Not a git repository (or any parent up to mount point)");
|
|
26
|
+
this.name = "RepoNotFoundError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
NotInitializedError = class NotInitializedError extends StitchError {
|
|
30
|
+
constructor() {
|
|
31
|
+
super("Stitch is not initialized in this repository. Run 'stitch init' first.");
|
|
32
|
+
this.name = "NotInitializedError";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
NoCurrentStitchError = class NoCurrentStitchError extends StitchError {
|
|
36
|
+
constructor() {
|
|
37
|
+
super("No current stitch. Start a new stitch with 'stitch start <title>' or switch to an existing one with 'stitch switch <id>'.");
|
|
38
|
+
this.name = "NoCurrentStitchError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
StitchNotFoundError = class StitchNotFoundError extends StitchError {
|
|
42
|
+
constructor(id) {
|
|
43
|
+
super(`Stitch not found: ${id}`);
|
|
44
|
+
this.name = "StitchNotFoundError";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
GitError = class GitError extends StitchError {
|
|
48
|
+
command;
|
|
49
|
+
exitCode;
|
|
50
|
+
constructor(message, command, exitCode) {
|
|
51
|
+
super(`Git error: ${message}`);
|
|
52
|
+
this.command = command;
|
|
53
|
+
this.exitCode = exitCode;
|
|
54
|
+
this.name = "GitError";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
ValidationError = class ValidationError extends StitchError {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(`Validation error: ${message}`);
|
|
60
|
+
this.name = "ValidationError";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
FinishForceRequiredError = class FinishForceRequiredError extends StitchError {
|
|
64
|
+
constructor(message) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = "FinishForceRequiredError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
InvalidSupersededByError = class InvalidSupersededByError extends StitchError {
|
|
70
|
+
constructor() {
|
|
71
|
+
super("--by requires --status=superseded");
|
|
72
|
+
this.name = "InvalidSupersededByError";
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
63
76
|
|
|
64
77
|
// node_modules/smol-toml/dist/error.js
|
|
65
|
-
/*!
|
|
66
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
67
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
68
|
-
*
|
|
69
|
-
* Redistribution and use in source and binary forms, with or without
|
|
70
|
-
* modification, are permitted provided that the following conditions are met:
|
|
71
|
-
*
|
|
72
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
73
|
-
* list of conditions and the following disclaimer.
|
|
74
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
75
|
-
* this list of conditions and the following disclaimer in the
|
|
76
|
-
* documentation and/or other materials provided with the distribution.
|
|
77
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
78
|
-
* may be used to endorse or promote products derived from this software without
|
|
79
|
-
* specific prior written permission.
|
|
80
|
-
*
|
|
81
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
82
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
83
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
84
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
85
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
86
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
87
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
88
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
89
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
90
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
91
|
-
*/
|
|
92
78
|
function getLineColFromPtr(string, ptr) {
|
|
93
79
|
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
94
80
|
return [lines.length, lines.pop().length + 1];
|
|
@@ -114,51 +100,53 @@ function makeCodeBlock(string, line, column) {
|
|
|
114
100
|
}
|
|
115
101
|
return codeblock;
|
|
116
102
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
103
|
+
var TomlError;
|
|
104
|
+
var init_error = __esm(() => {
|
|
105
|
+
/*!
|
|
106
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
107
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
108
|
+
*
|
|
109
|
+
* Redistribution and use in source and binary forms, with or without
|
|
110
|
+
* modification, are permitted provided that the following conditions are met:
|
|
111
|
+
*
|
|
112
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
113
|
+
* list of conditions and the following disclaimer.
|
|
114
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
115
|
+
* this list of conditions and the following disclaimer in the
|
|
116
|
+
* documentation and/or other materials provided with the distribution.
|
|
117
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
118
|
+
* may be used to endorse or promote products derived from this software without
|
|
119
|
+
* specific prior written permission.
|
|
120
|
+
*
|
|
121
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
122
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
123
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
124
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
125
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
126
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
127
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
128
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
129
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
130
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
131
|
+
*/
|
|
132
|
+
TomlError = class TomlError extends Error {
|
|
133
|
+
line;
|
|
134
|
+
column;
|
|
135
|
+
codeblock;
|
|
136
|
+
constructor(message, options) {
|
|
137
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
138
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
139
|
+
super(`Invalid TOML document: ${message}
|
|
126
140
|
|
|
127
141
|
${codeblock}`, options);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
142
|
+
this.line = line;
|
|
143
|
+
this.column = column;
|
|
144
|
+
this.codeblock = codeblock;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
});
|
|
133
148
|
|
|
134
149
|
// node_modules/smol-toml/dist/util.js
|
|
135
|
-
/*!
|
|
136
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
137
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
138
|
-
*
|
|
139
|
-
* Redistribution and use in source and binary forms, with or without
|
|
140
|
-
* modification, are permitted provided that the following conditions are met:
|
|
141
|
-
*
|
|
142
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
143
|
-
* list of conditions and the following disclaimer.
|
|
144
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
145
|
-
* this list of conditions and the following disclaimer in the
|
|
146
|
-
* documentation and/or other materials provided with the distribution.
|
|
147
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
148
|
-
* may be used to endorse or promote products derived from this software without
|
|
149
|
-
* specific prior written permission.
|
|
150
|
-
*
|
|
151
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
152
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
153
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
154
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
155
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
156
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
157
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
158
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
159
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
160
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
161
|
-
*/
|
|
162
150
|
function isEscaped(str, ptr) {
|
|
163
151
|
let i = 0;
|
|
164
152
|
while (str[ptr - ++i] === "\\")
|
|
@@ -238,170 +226,160 @@ function getStringEnd(str, seek) {
|
|
|
238
226
|
}
|
|
239
227
|
return seek;
|
|
240
228
|
}
|
|
229
|
+
var init_util = __esm(() => {
|
|
230
|
+
init_error();
|
|
231
|
+
/*!
|
|
232
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
233
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
234
|
+
*
|
|
235
|
+
* Redistribution and use in source and binary forms, with or without
|
|
236
|
+
* modification, are permitted provided that the following conditions are met:
|
|
237
|
+
*
|
|
238
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
239
|
+
* list of conditions and the following disclaimer.
|
|
240
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
241
|
+
* this list of conditions and the following disclaimer in the
|
|
242
|
+
* documentation and/or other materials provided with the distribution.
|
|
243
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
244
|
+
* may be used to endorse or promote products derived from this software without
|
|
245
|
+
* specific prior written permission.
|
|
246
|
+
*
|
|
247
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
248
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
249
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
250
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
251
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
252
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
253
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
254
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
255
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
256
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
257
|
+
*/
|
|
258
|
+
});
|
|
241
259
|
|
|
242
260
|
// node_modules/smol-toml/dist/date.js
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
261
|
+
var DATE_TIME_RE, TomlDate;
|
|
262
|
+
var init_date = __esm(() => {
|
|
263
|
+
/*!
|
|
264
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
265
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
266
|
+
*
|
|
267
|
+
* Redistribution and use in source and binary forms, with or without
|
|
268
|
+
* modification, are permitted provided that the following conditions are met:
|
|
269
|
+
*
|
|
270
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
271
|
+
* list of conditions and the following disclaimer.
|
|
272
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
273
|
+
* this list of conditions and the following disclaimer in the
|
|
274
|
+
* documentation and/or other materials provided with the distribution.
|
|
275
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
276
|
+
* may be used to endorse or promote products derived from this software without
|
|
277
|
+
* specific prior written permission.
|
|
278
|
+
*
|
|
279
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
280
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
281
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
282
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
283
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
284
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
285
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
286
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
287
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
288
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
289
|
+
*/
|
|
290
|
+
DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
291
|
+
TomlDate = class TomlDate extends Date {
|
|
292
|
+
#hasDate = false;
|
|
293
|
+
#hasTime = false;
|
|
294
|
+
#offset = null;
|
|
295
|
+
constructor(date) {
|
|
296
|
+
let hasDate = true;
|
|
297
|
+
let hasTime = true;
|
|
298
|
+
let offset = "Z";
|
|
299
|
+
if (typeof date === "string") {
|
|
300
|
+
let match = date.match(DATE_TIME_RE);
|
|
301
|
+
if (match) {
|
|
302
|
+
if (!match[1]) {
|
|
303
|
+
hasDate = false;
|
|
304
|
+
date = `0000-01-01T${date}`;
|
|
305
|
+
}
|
|
306
|
+
hasTime = !!match[2];
|
|
307
|
+
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
308
|
+
if (match[2] && +match[2] > 23) {
|
|
309
|
+
date = "";
|
|
310
|
+
} else {
|
|
311
|
+
offset = match[3] || null;
|
|
312
|
+
date = date.toUpperCase();
|
|
313
|
+
if (!offset && hasTime)
|
|
314
|
+
date += "Z";
|
|
315
|
+
}
|
|
291
316
|
} else {
|
|
292
|
-
|
|
293
|
-
date = date.toUpperCase();
|
|
294
|
-
if (!offset && hasTime)
|
|
295
|
-
date += "Z";
|
|
317
|
+
date = "";
|
|
296
318
|
}
|
|
297
|
-
}
|
|
298
|
-
|
|
319
|
+
}
|
|
320
|
+
super(date);
|
|
321
|
+
if (!isNaN(this.getTime())) {
|
|
322
|
+
this.#hasDate = hasDate;
|
|
323
|
+
this.#hasTime = hasTime;
|
|
324
|
+
this.#offset = offset;
|
|
299
325
|
}
|
|
300
326
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this.#
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
let date = new TomlDate(jsDate);
|
|
356
|
-
date.#hasDate = false;
|
|
357
|
-
date.#offset = null;
|
|
358
|
-
return date;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
327
|
+
isDateTime() {
|
|
328
|
+
return this.#hasDate && this.#hasTime;
|
|
329
|
+
}
|
|
330
|
+
isLocal() {
|
|
331
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
332
|
+
}
|
|
333
|
+
isDate() {
|
|
334
|
+
return this.#hasDate && !this.#hasTime;
|
|
335
|
+
}
|
|
336
|
+
isTime() {
|
|
337
|
+
return this.#hasTime && !this.#hasDate;
|
|
338
|
+
}
|
|
339
|
+
isValid() {
|
|
340
|
+
return this.#hasDate || this.#hasTime;
|
|
341
|
+
}
|
|
342
|
+
toISOString() {
|
|
343
|
+
let iso = super.toISOString();
|
|
344
|
+
if (this.isDate())
|
|
345
|
+
return iso.slice(0, 10);
|
|
346
|
+
if (this.isTime())
|
|
347
|
+
return iso.slice(11, 23);
|
|
348
|
+
if (this.#offset === null)
|
|
349
|
+
return iso.slice(0, -1);
|
|
350
|
+
if (this.#offset === "Z")
|
|
351
|
+
return iso;
|
|
352
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
353
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
354
|
+
let offsetDate = new Date(this.getTime() - offset * 60000);
|
|
355
|
+
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
356
|
+
}
|
|
357
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
358
|
+
let date = new TomlDate(jsDate);
|
|
359
|
+
date.#offset = offset;
|
|
360
|
+
return date;
|
|
361
|
+
}
|
|
362
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
363
|
+
let date = new TomlDate(jsDate);
|
|
364
|
+
date.#offset = null;
|
|
365
|
+
return date;
|
|
366
|
+
}
|
|
367
|
+
static wrapAsLocalDate(jsDate) {
|
|
368
|
+
let date = new TomlDate(jsDate);
|
|
369
|
+
date.#hasTime = false;
|
|
370
|
+
date.#offset = null;
|
|
371
|
+
return date;
|
|
372
|
+
}
|
|
373
|
+
static wrapAsLocalTime(jsDate) {
|
|
374
|
+
let date = new TomlDate(jsDate);
|
|
375
|
+
date.#hasDate = false;
|
|
376
|
+
date.#offset = null;
|
|
377
|
+
return date;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
});
|
|
361
381
|
|
|
362
382
|
// node_modules/smol-toml/dist/primitive.js
|
|
363
|
-
/*!
|
|
364
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
365
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
366
|
-
*
|
|
367
|
-
* Redistribution and use in source and binary forms, with or without
|
|
368
|
-
* modification, are permitted provided that the following conditions are met:
|
|
369
|
-
*
|
|
370
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
371
|
-
* list of conditions and the following disclaimer.
|
|
372
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
373
|
-
* this list of conditions and the following disclaimer in the
|
|
374
|
-
* documentation and/or other materials provided with the distribution.
|
|
375
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
376
|
-
* may be used to endorse or promote products derived from this software without
|
|
377
|
-
* specific prior written permission.
|
|
378
|
-
*
|
|
379
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
380
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
381
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
382
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
383
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
384
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
385
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
386
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
387
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
388
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
389
|
-
*/
|
|
390
|
-
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
391
|
-
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
392
|
-
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
393
|
-
var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
|
|
394
|
-
var ESC_MAP = {
|
|
395
|
-
b: "\b",
|
|
396
|
-
t: "\t",
|
|
397
|
-
n: `
|
|
398
|
-
`,
|
|
399
|
-
f: "\f",
|
|
400
|
-
r: "\r",
|
|
401
|
-
e: "\x1B",
|
|
402
|
-
'"': '"',
|
|
403
|
-
"\\": "\\"
|
|
404
|
-
};
|
|
405
383
|
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
406
384
|
let isLiteral = str[ptr] === "'";
|
|
407
385
|
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
@@ -530,35 +508,56 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
530
508
|
}
|
|
531
509
|
return date;
|
|
532
510
|
}
|
|
511
|
+
var INT_REGEX, FLOAT_REGEX, LEADING_ZERO, ESCAPE_REGEX, ESC_MAP;
|
|
512
|
+
var init_primitive = __esm(() => {
|
|
513
|
+
init_util();
|
|
514
|
+
init_date();
|
|
515
|
+
init_error();
|
|
516
|
+
/*!
|
|
517
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
518
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
519
|
+
*
|
|
520
|
+
* Redistribution and use in source and binary forms, with or without
|
|
521
|
+
* modification, are permitted provided that the following conditions are met:
|
|
522
|
+
*
|
|
523
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
524
|
+
* list of conditions and the following disclaimer.
|
|
525
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
526
|
+
* this list of conditions and the following disclaimer in the
|
|
527
|
+
* documentation and/or other materials provided with the distribution.
|
|
528
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
529
|
+
* may be used to endorse or promote products derived from this software without
|
|
530
|
+
* specific prior written permission.
|
|
531
|
+
*
|
|
532
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
533
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
534
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
535
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
536
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
537
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
538
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
539
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
540
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
541
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
542
|
+
*/
|
|
543
|
+
INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
544
|
+
FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
545
|
+
LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
546
|
+
ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
|
|
547
|
+
ESC_MAP = {
|
|
548
|
+
b: "\b",
|
|
549
|
+
t: "\t",
|
|
550
|
+
n: `
|
|
551
|
+
`,
|
|
552
|
+
f: "\f",
|
|
553
|
+
r: "\r",
|
|
554
|
+
e: "\x1B",
|
|
555
|
+
'"': '"',
|
|
556
|
+
"\\": "\\"
|
|
557
|
+
};
|
|
558
|
+
});
|
|
533
559
|
|
|
534
560
|
// node_modules/smol-toml/dist/extract.js
|
|
535
|
-
/*!
|
|
536
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
537
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
538
|
-
*
|
|
539
|
-
* Redistribution and use in source and binary forms, with or without
|
|
540
|
-
* modification, are permitted provided that the following conditions are met:
|
|
541
|
-
*
|
|
542
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
543
|
-
* list of conditions and the following disclaimer.
|
|
544
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
545
|
-
* this list of conditions and the following disclaimer in the
|
|
546
|
-
* documentation and/or other materials provided with the distribution.
|
|
547
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
548
|
-
* may be used to endorse or promote products derived from this software without
|
|
549
|
-
* specific prior written permission.
|
|
550
|
-
*
|
|
551
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
552
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
553
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
554
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
555
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
556
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
557
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
558
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
559
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
560
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
561
|
-
*/
|
|
562
561
|
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
563
562
|
let value = str.slice(startPtr, endPtr);
|
|
564
563
|
let commentIdx = value.indexOf("#");
|
|
@@ -625,36 +624,41 @@ function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
|
625
624
|
endPtr
|
|
626
625
|
];
|
|
627
626
|
}
|
|
627
|
+
var init_extract = __esm(() => {
|
|
628
|
+
init_primitive();
|
|
629
|
+
init_struct();
|
|
630
|
+
init_util();
|
|
631
|
+
init_error();
|
|
632
|
+
/*!
|
|
633
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
634
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
635
|
+
*
|
|
636
|
+
* Redistribution and use in source and binary forms, with or without
|
|
637
|
+
* modification, are permitted provided that the following conditions are met:
|
|
638
|
+
*
|
|
639
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
640
|
+
* list of conditions and the following disclaimer.
|
|
641
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
642
|
+
* this list of conditions and the following disclaimer in the
|
|
643
|
+
* documentation and/or other materials provided with the distribution.
|
|
644
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
645
|
+
* may be used to endorse or promote products derived from this software without
|
|
646
|
+
* specific prior written permission.
|
|
647
|
+
*
|
|
648
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
649
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
650
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
651
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
652
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
653
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
654
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
655
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
656
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
657
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
658
|
+
*/
|
|
659
|
+
});
|
|
628
660
|
|
|
629
661
|
// node_modules/smol-toml/dist/struct.js
|
|
630
|
-
/*!
|
|
631
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
632
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
633
|
-
*
|
|
634
|
-
* Redistribution and use in source and binary forms, with or without
|
|
635
|
-
* modification, are permitted provided that the following conditions are met:
|
|
636
|
-
*
|
|
637
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
638
|
-
* list of conditions and the following disclaimer.
|
|
639
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
640
|
-
* this list of conditions and the following disclaimer in the
|
|
641
|
-
* documentation and/or other materials provided with the distribution.
|
|
642
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
643
|
-
* may be used to endorse or promote products derived from this software without
|
|
644
|
-
* specific prior written permission.
|
|
645
|
-
*
|
|
646
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
647
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
648
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
649
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
650
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
651
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
652
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
653
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
654
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
655
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
656
|
-
*/
|
|
657
|
-
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
658
662
|
function parseKey(str, ptr, end = "=") {
|
|
659
663
|
let dot = ptr - 1;
|
|
660
664
|
let parsed = [];
|
|
@@ -802,35 +806,43 @@ function parseArray(str, ptr, depth, integersAsBigInt) {
|
|
|
802
806
|
}
|
|
803
807
|
return [res, ptr];
|
|
804
808
|
}
|
|
809
|
+
var KEY_PART_RE;
|
|
810
|
+
var init_struct = __esm(() => {
|
|
811
|
+
init_primitive();
|
|
812
|
+
init_extract();
|
|
813
|
+
init_util();
|
|
814
|
+
init_error();
|
|
815
|
+
/*!
|
|
816
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
817
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
818
|
+
*
|
|
819
|
+
* Redistribution and use in source and binary forms, with or without
|
|
820
|
+
* modification, are permitted provided that the following conditions are met:
|
|
821
|
+
*
|
|
822
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
823
|
+
* list of conditions and the following disclaimer.
|
|
824
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
825
|
+
* this list of conditions and the following disclaimer in the
|
|
826
|
+
* documentation and/or other materials provided with the distribution.
|
|
827
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
828
|
+
* may be used to endorse or promote products derived from this software without
|
|
829
|
+
* specific prior written permission.
|
|
830
|
+
*
|
|
831
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
832
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
833
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
834
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
835
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
836
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
837
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
838
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
839
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
840
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
841
|
+
*/
|
|
842
|
+
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
843
|
+
});
|
|
805
844
|
|
|
806
845
|
// node_modules/smol-toml/dist/parse.js
|
|
807
|
-
/*!
|
|
808
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
809
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
810
|
-
*
|
|
811
|
-
* Redistribution and use in source and binary forms, with or without
|
|
812
|
-
* modification, are permitted provided that the following conditions are met:
|
|
813
|
-
*
|
|
814
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
815
|
-
* list of conditions and the following disclaimer.
|
|
816
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
817
|
-
* this list of conditions and the following disclaimer in the
|
|
818
|
-
* documentation and/or other materials provided with the distribution.
|
|
819
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
820
|
-
* may be used to endorse or promote products derived from this software without
|
|
821
|
-
* specific prior written permission.
|
|
822
|
-
*
|
|
823
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
824
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
825
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
826
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
827
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
828
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
829
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
830
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
831
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
832
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
833
|
-
*/
|
|
834
846
|
function peekTable(key, table, meta, type) {
|
|
835
847
|
let t = table;
|
|
836
848
|
let m = meta;
|
|
@@ -943,36 +955,41 @@ function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
|
943
955
|
}
|
|
944
956
|
return res;
|
|
945
957
|
}
|
|
958
|
+
var init_parse = __esm(() => {
|
|
959
|
+
init_struct();
|
|
960
|
+
init_extract();
|
|
961
|
+
init_util();
|
|
962
|
+
init_error();
|
|
963
|
+
/*!
|
|
964
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
965
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
966
|
+
*
|
|
967
|
+
* Redistribution and use in source and binary forms, with or without
|
|
968
|
+
* modification, are permitted provided that the following conditions are met:
|
|
969
|
+
*
|
|
970
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
971
|
+
* list of conditions and the following disclaimer.
|
|
972
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
973
|
+
* this list of conditions and the following disclaimer in the
|
|
974
|
+
* documentation and/or other materials provided with the distribution.
|
|
975
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
976
|
+
* may be used to endorse or promote products derived from this software without
|
|
977
|
+
* specific prior written permission.
|
|
978
|
+
*
|
|
979
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
980
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
981
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
982
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
983
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
984
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
985
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
986
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
987
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
988
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
989
|
+
*/
|
|
990
|
+
});
|
|
946
991
|
|
|
947
992
|
// node_modules/smol-toml/dist/stringify.js
|
|
948
|
-
/*!
|
|
949
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
950
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
951
|
-
*
|
|
952
|
-
* Redistribution and use in source and binary forms, with or without
|
|
953
|
-
* modification, are permitted provided that the following conditions are met:
|
|
954
|
-
*
|
|
955
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
956
|
-
* list of conditions and the following disclaimer.
|
|
957
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
958
|
-
* this list of conditions and the following disclaimer in the
|
|
959
|
-
* documentation and/or other materials provided with the distribution.
|
|
960
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
961
|
-
* may be used to endorse or promote products derived from this software without
|
|
962
|
-
* specific prior written permission.
|
|
963
|
-
*
|
|
964
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
965
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
966
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
967
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
968
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
969
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
970
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
971
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
972
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
973
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
974
|
-
*/
|
|
975
|
-
var BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
976
993
|
function extendedTypeOf(obj) {
|
|
977
994
|
let type = typeof obj;
|
|
978
995
|
if (type === "object") {
|
|
@@ -1117,38 +1134,80 @@ function stringify(obj, { maxDepth = 1000, numbersAsFloat = false } = {}) {
|
|
|
1117
1134
|
`;
|
|
1118
1135
|
return str;
|
|
1119
1136
|
}
|
|
1137
|
+
var BARE_KEY;
|
|
1138
|
+
var init_stringify = __esm(() => {
|
|
1139
|
+
/*!
|
|
1140
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
1141
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1142
|
+
*
|
|
1143
|
+
* Redistribution and use in source and binary forms, with or without
|
|
1144
|
+
* modification, are permitted provided that the following conditions are met:
|
|
1145
|
+
*
|
|
1146
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
1147
|
+
* list of conditions and the following disclaimer.
|
|
1148
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
1149
|
+
* this list of conditions and the following disclaimer in the
|
|
1150
|
+
* documentation and/or other materials provided with the distribution.
|
|
1151
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
1152
|
+
* may be used to endorse or promote products derived from this software without
|
|
1153
|
+
* specific prior written permission.
|
|
1154
|
+
*
|
|
1155
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
1156
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
1157
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
1158
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
1159
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
1160
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
1161
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
1162
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
1163
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
1164
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1165
|
+
*/
|
|
1166
|
+
BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
1167
|
+
});
|
|
1120
1168
|
|
|
1121
1169
|
// node_modules/smol-toml/dist/index.js
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1170
|
+
var init_dist = __esm(() => {
|
|
1171
|
+
init_parse();
|
|
1172
|
+
init_stringify();
|
|
1173
|
+
init_date();
|
|
1174
|
+
init_error();
|
|
1175
|
+
/*!
|
|
1176
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
1177
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1178
|
+
*
|
|
1179
|
+
* Redistribution and use in source and binary forms, with or without
|
|
1180
|
+
* modification, are permitted provided that the following conditions are met:
|
|
1181
|
+
*
|
|
1182
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
1183
|
+
* list of conditions and the following disclaimer.
|
|
1184
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
1185
|
+
* this list of conditions and the following disclaimer in the
|
|
1186
|
+
* documentation and/or other materials provided with the distribution.
|
|
1187
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
1188
|
+
* may be used to endorse or promote products derived from this software without
|
|
1189
|
+
* specific prior written permission.
|
|
1190
|
+
*
|
|
1191
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
1192
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
1193
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
1194
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
1195
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
1196
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
1197
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
1198
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
1199
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
1200
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1201
|
+
*/
|
|
1202
|
+
});
|
|
1149
1203
|
|
|
1150
1204
|
// src/core/frontmatter.ts
|
|
1151
|
-
var
|
|
1205
|
+
var exports_frontmatter = {};
|
|
1206
|
+
__export(exports_frontmatter, {
|
|
1207
|
+
updateTimestamp: () => updateTimestamp,
|
|
1208
|
+
serializeStitchFile: () => serializeStitchFile,
|
|
1209
|
+
parseStitchFile: () => parseStitchFile
|
|
1210
|
+
});
|
|
1152
1211
|
function parseStitchFile(content) {
|
|
1153
1212
|
const lines = content.split(`
|
|
1154
1213
|
`);
|
|
@@ -1313,6 +1372,21 @@ function updateTimestamp(frontmatter) {
|
|
|
1313
1372
|
updated_at: new Date().toISOString()
|
|
1314
1373
|
};
|
|
1315
1374
|
}
|
|
1375
|
+
var FRONTMATTER_DELIMITER = "+++";
|
|
1376
|
+
var init_frontmatter = __esm(() => {
|
|
1377
|
+
init_dist();
|
|
1378
|
+
init_errors();
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
// src/api.ts
|
|
1382
|
+
import { spawn } from "child_process";
|
|
1383
|
+
|
|
1384
|
+
// src/core/store.ts
|
|
1385
|
+
init_errors();
|
|
1386
|
+
init_frontmatter();
|
|
1387
|
+
import { readdir, readFile as readFile2, writeFile as writeFile2, mkdir } from "fs/promises";
|
|
1388
|
+
import { join as join2 } from "path";
|
|
1389
|
+
import { existsSync as existsSync2 } from "fs";
|
|
1316
1390
|
|
|
1317
1391
|
// src/core/ids.ts
|
|
1318
1392
|
function generateStitchId() {
|
|
@@ -1351,28 +1425,126 @@ var DEFAULT_STITCH_BODY = `## Intent
|
|
|
1351
1425
|
[Additional context or information]
|
|
1352
1426
|
`;
|
|
1353
1427
|
|
|
1428
|
+
// src/core/indexing.ts
|
|
1429
|
+
import { readFile, writeFile } from "fs/promises";
|
|
1430
|
+
import { existsSync } from "fs";
|
|
1431
|
+
import { join } from "path";
|
|
1432
|
+
init_errors();
|
|
1433
|
+
var INDEX_FILE = "index.json";
|
|
1434
|
+
var INDEX_VERSION = 1;
|
|
1435
|
+
function getIndexFilePath(repoRoot) {
|
|
1436
|
+
if (!isInitialized(repoRoot)) {
|
|
1437
|
+
throw new NotInitializedError;
|
|
1438
|
+
}
|
|
1439
|
+
return join(getStitchDir(repoRoot), INDEX_FILE);
|
|
1440
|
+
}
|
|
1441
|
+
function createEmptyIndex() {
|
|
1442
|
+
return {
|
|
1443
|
+
version: INDEX_VERSION,
|
|
1444
|
+
children: {},
|
|
1445
|
+
updated_at: new Date().toISOString()
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
async function loadIndex(repoRoot) {
|
|
1449
|
+
const indexPath = getIndexFilePath(repoRoot);
|
|
1450
|
+
if (!existsSync(indexPath)) {
|
|
1451
|
+
return null;
|
|
1452
|
+
}
|
|
1453
|
+
try {
|
|
1454
|
+
const content = await readFile(indexPath, "utf-8");
|
|
1455
|
+
const parsed = JSON.parse(content);
|
|
1456
|
+
if (parsed.version !== INDEX_VERSION) {
|
|
1457
|
+
return null;
|
|
1458
|
+
}
|
|
1459
|
+
return parsed;
|
|
1460
|
+
} catch {
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
async function saveIndex(repoRoot, index) {
|
|
1465
|
+
const indexPath = getIndexFilePath(repoRoot);
|
|
1466
|
+
const content = JSON.stringify(index, null, 2);
|
|
1467
|
+
await writeFile(indexPath, content, "utf-8");
|
|
1468
|
+
}
|
|
1469
|
+
async function rebuildIndex(repoRoot) {
|
|
1470
|
+
const stitches = await listStitches(repoRoot);
|
|
1471
|
+
const index = createEmptyIndex();
|
|
1472
|
+
for (const doc of stitches) {
|
|
1473
|
+
const parentId = doc.frontmatter.relations?.parent;
|
|
1474
|
+
if (parentId) {
|
|
1475
|
+
if (!index.children[parentId]) {
|
|
1476
|
+
index.children[parentId] = [];
|
|
1477
|
+
}
|
|
1478
|
+
index.children[parentId].push(doc.frontmatter.id);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
await saveIndex(repoRoot, index);
|
|
1482
|
+
return index;
|
|
1483
|
+
}
|
|
1484
|
+
async function getIndex(repoRoot) {
|
|
1485
|
+
let index = await loadIndex(repoRoot);
|
|
1486
|
+
if (!index) {
|
|
1487
|
+
index = await rebuildIndex(repoRoot);
|
|
1488
|
+
}
|
|
1489
|
+
return index;
|
|
1490
|
+
}
|
|
1491
|
+
async function getChildren(repoRoot, id) {
|
|
1492
|
+
const index = await getIndex(repoRoot);
|
|
1493
|
+
return index.children[id] ?? [];
|
|
1494
|
+
}
|
|
1495
|
+
async function getDescendants(repoRoot, id) {
|
|
1496
|
+
const index = await getIndex(repoRoot);
|
|
1497
|
+
const descendants = [];
|
|
1498
|
+
const queue = [id];
|
|
1499
|
+
const visited = new Set;
|
|
1500
|
+
while (queue.length > 0) {
|
|
1501
|
+
const currentId = queue.shift();
|
|
1502
|
+
if (visited.has(currentId)) {
|
|
1503
|
+
continue;
|
|
1504
|
+
}
|
|
1505
|
+
visited.add(currentId);
|
|
1506
|
+
const children = index.children[currentId] ?? [];
|
|
1507
|
+
for (const childId of children) {
|
|
1508
|
+
descendants.push(childId);
|
|
1509
|
+
queue.push(childId);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
return descendants;
|
|
1513
|
+
}
|
|
1514
|
+
async function addChildToIndex(repoRoot, parentId, childId) {
|
|
1515
|
+
const index = await getIndex(repoRoot);
|
|
1516
|
+
if (!index.children[parentId]) {
|
|
1517
|
+
index.children[parentId] = [];
|
|
1518
|
+
}
|
|
1519
|
+
if (!index.children[parentId].includes(childId)) {
|
|
1520
|
+
index.children[parentId].push(childId);
|
|
1521
|
+
index.updated_at = new Date().toISOString();
|
|
1522
|
+
await saveIndex(repoRoot, index);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1354
1526
|
// src/core/store.ts
|
|
1355
1527
|
var STITCH_DIR = ".stitch";
|
|
1356
1528
|
var STITCHES_SUBDIR = "stitches";
|
|
1357
1529
|
var CURRENT_FILE = "current";
|
|
1358
1530
|
function getStitchDir(repoRoot) {
|
|
1359
|
-
return
|
|
1531
|
+
return join2(repoRoot, STITCH_DIR);
|
|
1360
1532
|
}
|
|
1361
1533
|
function getStitchesDir(repoRoot) {
|
|
1362
|
-
return
|
|
1534
|
+
return join2(repoRoot, STITCH_DIR, STITCHES_SUBDIR);
|
|
1363
1535
|
}
|
|
1364
1536
|
function getCurrentFilePath(repoRoot) {
|
|
1365
|
-
return
|
|
1537
|
+
return join2(repoRoot, STITCH_DIR, CURRENT_FILE);
|
|
1366
1538
|
}
|
|
1367
1539
|
function isInitialized(repoRoot) {
|
|
1368
|
-
return
|
|
1540
|
+
return existsSync2(getStitchDir(repoRoot));
|
|
1369
1541
|
}
|
|
1370
1542
|
async function initializeStitch(repoRoot) {
|
|
1371
1543
|
const stitchesDir = getStitchesDir(repoRoot);
|
|
1372
1544
|
const currentPath = getCurrentFilePath(repoRoot);
|
|
1373
1545
|
await mkdir(stitchesDir, { recursive: true });
|
|
1374
|
-
if (!
|
|
1375
|
-
await
|
|
1546
|
+
if (!existsSync2(currentPath)) {
|
|
1547
|
+
await writeFile2(currentPath, "", "utf-8");
|
|
1376
1548
|
}
|
|
1377
1549
|
}
|
|
1378
1550
|
async function getCurrentStitchId(repoRoot) {
|
|
@@ -1380,7 +1552,7 @@ async function getCurrentStitchId(repoRoot) {
|
|
|
1380
1552
|
throw new NotInitializedError;
|
|
1381
1553
|
}
|
|
1382
1554
|
const currentPath = getCurrentFilePath(repoRoot);
|
|
1383
|
-
const content = await
|
|
1555
|
+
const content = await readFile2(currentPath, "utf-8");
|
|
1384
1556
|
const trimmed = content.trim();
|
|
1385
1557
|
return trimmed || null;
|
|
1386
1558
|
}
|
|
@@ -1389,10 +1561,10 @@ async function setCurrentStitchId(repoRoot, id) {
|
|
|
1389
1561
|
throw new NotInitializedError;
|
|
1390
1562
|
}
|
|
1391
1563
|
const currentPath = getCurrentFilePath(repoRoot);
|
|
1392
|
-
await
|
|
1564
|
+
await writeFile2(currentPath, id ?? "", "utf-8");
|
|
1393
1565
|
}
|
|
1394
1566
|
function getStitchFilePath(repoRoot, id) {
|
|
1395
|
-
return
|
|
1567
|
+
return join2(getStitchesDir(repoRoot), `${id}.md`);
|
|
1396
1568
|
}
|
|
1397
1569
|
async function createStitch(repoRoot, title, parentId) {
|
|
1398
1570
|
if (!isInitialized(repoRoot)) {
|
|
@@ -1414,7 +1586,10 @@ async function createStitch(repoRoot, title, parentId) {
|
|
|
1414
1586
|
}
|
|
1415
1587
|
const filePath = getStitchFilePath(repoRoot, id);
|
|
1416
1588
|
const content = serializeStitchFile(frontmatter, DEFAULT_STITCH_BODY);
|
|
1417
|
-
await
|
|
1589
|
+
await writeFile2(filePath, content, "utf-8");
|
|
1590
|
+
if (parentId) {
|
|
1591
|
+
await addChildToIndex(repoRoot, parentId, id);
|
|
1592
|
+
}
|
|
1418
1593
|
return {
|
|
1419
1594
|
frontmatter,
|
|
1420
1595
|
body: DEFAULT_STITCH_BODY,
|
|
@@ -1426,10 +1601,10 @@ async function loadStitch(repoRoot, id) {
|
|
|
1426
1601
|
throw new NotInitializedError;
|
|
1427
1602
|
}
|
|
1428
1603
|
const filePath = getStitchFilePath(repoRoot, id);
|
|
1429
|
-
if (!
|
|
1604
|
+
if (!existsSync2(filePath)) {
|
|
1430
1605
|
throw new StitchNotFoundError(id);
|
|
1431
1606
|
}
|
|
1432
|
-
const content = await
|
|
1607
|
+
const content = await readFile2(filePath, "utf-8");
|
|
1433
1608
|
const { frontmatter, body } = parseStitchFile(content);
|
|
1434
1609
|
return { frontmatter, body, filePath };
|
|
1435
1610
|
}
|
|
@@ -1439,7 +1614,7 @@ async function saveStitch(repoRoot, doc) {
|
|
|
1439
1614
|
}
|
|
1440
1615
|
const updatedFrontmatter = updateTimestamp(doc.frontmatter);
|
|
1441
1616
|
const content = serializeStitchFile(updatedFrontmatter, doc.body);
|
|
1442
|
-
await
|
|
1617
|
+
await writeFile2(doc.filePath, content, "utf-8");
|
|
1443
1618
|
return {
|
|
1444
1619
|
...doc,
|
|
1445
1620
|
frontmatter: updatedFrontmatter
|
|
@@ -1450,16 +1625,16 @@ async function listStitches(repoRoot, filter) {
|
|
|
1450
1625
|
throw new NotInitializedError;
|
|
1451
1626
|
}
|
|
1452
1627
|
const stitchesDir = getStitchesDir(repoRoot);
|
|
1453
|
-
if (!
|
|
1628
|
+
if (!existsSync2(stitchesDir)) {
|
|
1454
1629
|
return [];
|
|
1455
1630
|
}
|
|
1456
1631
|
const files = await readdir(stitchesDir);
|
|
1457
1632
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
1458
1633
|
const docs = [];
|
|
1459
1634
|
for (const file of mdFiles) {
|
|
1460
|
-
const filePath =
|
|
1635
|
+
const filePath = join2(stitchesDir, file);
|
|
1461
1636
|
try {
|
|
1462
|
-
const content = await
|
|
1637
|
+
const content = await readFile2(filePath, "utf-8");
|
|
1463
1638
|
const { frontmatter, body } = parseStitchFile(content);
|
|
1464
1639
|
if (filter?.status && frontmatter.status !== filter.status) {
|
|
1465
1640
|
continue;
|
|
@@ -1500,6 +1675,7 @@ async function requireCurrentStitchId(repoRoot) {
|
|
|
1500
1675
|
}
|
|
1501
1676
|
|
|
1502
1677
|
// src/core/git.ts
|
|
1678
|
+
init_errors();
|
|
1503
1679
|
var {$ } = globalThis.Bun;
|
|
1504
1680
|
async function getRepoRoot(cwd) {
|
|
1505
1681
|
try {
|
|
@@ -1587,6 +1763,7 @@ async function getCommitsInRange(range, repoRoot) {
|
|
|
1587
1763
|
}
|
|
1588
1764
|
|
|
1589
1765
|
// src/core/link.ts
|
|
1766
|
+
init_errors();
|
|
1590
1767
|
async function addCommitLink(repoRoot, doc, sha) {
|
|
1591
1768
|
const exists = await commitExists(sha, repoRoot);
|
|
1592
1769
|
if (!exists) {
|
|
@@ -1706,6 +1883,156 @@ function getEditor() {
|
|
|
1706
1883
|
}
|
|
1707
1884
|
|
|
1708
1885
|
// src/api.ts
|
|
1886
|
+
init_errors();
|
|
1887
|
+
|
|
1888
|
+
// src/core/finish.ts
|
|
1889
|
+
import { readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
1890
|
+
init_frontmatter();
|
|
1891
|
+
init_errors();
|
|
1892
|
+
function hasLinkedCommits(doc) {
|
|
1893
|
+
const links = doc.frontmatter.git?.links;
|
|
1894
|
+
return links !== undefined && links.length > 0;
|
|
1895
|
+
}
|
|
1896
|
+
async function shouldAutoAbandon(doc, descendants) {
|
|
1897
|
+
if (!hasLinkedCommits(doc)) {
|
|
1898
|
+
return { autoAbandon: true, reason: "No linked commits" };
|
|
1899
|
+
}
|
|
1900
|
+
const openDescendants = descendants.filter((d) => d.frontmatter.status === "open");
|
|
1901
|
+
if (openDescendants.length > 0) {
|
|
1902
|
+
return { autoAbandon: true, reason: `Has ${openDescendants.length} open children` };
|
|
1903
|
+
}
|
|
1904
|
+
return { autoAbandon: false };
|
|
1905
|
+
}
|
|
1906
|
+
async function prepareFinish(repoRoot, id, options = {}) {
|
|
1907
|
+
if (!isInitialized(repoRoot)) {
|
|
1908
|
+
throw new NotInitializedError;
|
|
1909
|
+
}
|
|
1910
|
+
const { status = "closed", supersededBy, force = false } = options;
|
|
1911
|
+
const warnings = [];
|
|
1912
|
+
if (supersededBy && status !== "superseded") {
|
|
1913
|
+
throw new InvalidSupersededByError;
|
|
1914
|
+
}
|
|
1915
|
+
if (supersededBy) {
|
|
1916
|
+
try {
|
|
1917
|
+
await loadStitch(repoRoot, supersededBy);
|
|
1918
|
+
} catch (error) {
|
|
1919
|
+
if (error instanceof StitchNotFoundError) {
|
|
1920
|
+
throw new StitchError(`Superseding stitch '${supersededBy}' not found`);
|
|
1921
|
+
}
|
|
1922
|
+
throw error;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
const target = await loadStitch(repoRoot, id);
|
|
1926
|
+
const descendantIds = await getDescendants(repoRoot, id);
|
|
1927
|
+
const descendants = [];
|
|
1928
|
+
for (const descId of descendantIds) {
|
|
1929
|
+
try {
|
|
1930
|
+
const doc = await loadStitch(repoRoot, descId);
|
|
1931
|
+
descendants.push(doc);
|
|
1932
|
+
} catch {
|
|
1933
|
+
warnings.push(`Warning: Could not load descendant '${descId}'`);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
let finalStatus = status;
|
|
1937
|
+
let autoDetected = false;
|
|
1938
|
+
let forceRequired;
|
|
1939
|
+
const autoAbandonCheck = await shouldAutoAbandon(target, descendants);
|
|
1940
|
+
if (autoAbandonCheck.autoAbandon) {
|
|
1941
|
+
if (status !== "abandoned") {
|
|
1942
|
+
if (force) {
|
|
1943
|
+
warnings.push(`Warning: ${autoAbandonCheck.reason}. Forcing status to '${status}' as requested.`);
|
|
1944
|
+
} else {
|
|
1945
|
+
finalStatus = "abandoned";
|
|
1946
|
+
autoDetected = true;
|
|
1947
|
+
forceRequired = `Cannot set status to '${status}' when ${autoAbandonCheck.reason?.toLowerCase()}. Use --force to override, or --status=abandoned.`;
|
|
1948
|
+
warnings.push(`Warning: ${autoAbandonCheck.reason}. Marking as abandoned. Use --status=superseded if this work was replaced.`);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
const affected = [target];
|
|
1953
|
+
for (const desc of descendants) {
|
|
1954
|
+
if (desc.frontmatter.status !== finalStatus) {
|
|
1955
|
+
affected.push(desc);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
const requiresConfirmation = affected.length >= 2;
|
|
1959
|
+
return {
|
|
1960
|
+
target,
|
|
1961
|
+
affected,
|
|
1962
|
+
finalStatus,
|
|
1963
|
+
autoDetected,
|
|
1964
|
+
warnings,
|
|
1965
|
+
requiresConfirmation,
|
|
1966
|
+
forceRequired: force ? undefined : forceRequired
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
async function executeFinish(preview, options = {}) {
|
|
1970
|
+
const { supersededBy } = options;
|
|
1971
|
+
if (preview.forceRequired) {
|
|
1972
|
+
throw new FinishForceRequiredError(preview.forceRequired);
|
|
1973
|
+
}
|
|
1974
|
+
const updates = [];
|
|
1975
|
+
const finished = [];
|
|
1976
|
+
for (const doc of preview.affected) {
|
|
1977
|
+
const originalContent = await readFile3(doc.filePath, "utf-8");
|
|
1978
|
+
let updatedFrontmatter = {
|
|
1979
|
+
...doc.frontmatter,
|
|
1980
|
+
status: preview.finalStatus
|
|
1981
|
+
};
|
|
1982
|
+
if (supersededBy && doc.frontmatter.id === preview.target.frontmatter.id) {
|
|
1983
|
+
const existingDependsOn = updatedFrontmatter.relations?.depends_on ?? [];
|
|
1984
|
+
if (!existingDependsOn.includes(supersededBy)) {
|
|
1985
|
+
updatedFrontmatter = {
|
|
1986
|
+
...updatedFrontmatter,
|
|
1987
|
+
relations: {
|
|
1988
|
+
...updatedFrontmatter.relations,
|
|
1989
|
+
depends_on: [...existingDependsOn, supersededBy]
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
updatedFrontmatter = updateTimestamp(updatedFrontmatter);
|
|
1995
|
+
const updatedDoc = {
|
|
1996
|
+
...doc,
|
|
1997
|
+
frontmatter: updatedFrontmatter
|
|
1998
|
+
};
|
|
1999
|
+
const { serializeStitchFile: serializeStitchFile2 } = await Promise.resolve().then(() => (init_frontmatter(), exports_frontmatter));
|
|
2000
|
+
const newContent = serializeStitchFile2(updatedFrontmatter, doc.body);
|
|
2001
|
+
updates.push({ doc: updatedDoc, originalContent, newContent });
|
|
2002
|
+
finished.push({
|
|
2003
|
+
id: doc.frontmatter.id,
|
|
2004
|
+
title: doc.frontmatter.title,
|
|
2005
|
+
previousStatus: doc.frontmatter.status,
|
|
2006
|
+
newStatus: preview.finalStatus
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
const writtenPaths = [];
|
|
2010
|
+
try {
|
|
2011
|
+
for (const update of updates) {
|
|
2012
|
+
await writeFile3(update.doc.filePath, update.newContent, "utf-8");
|
|
2013
|
+
writtenPaths.push(update.doc.filePath);
|
|
2014
|
+
}
|
|
2015
|
+
} catch (error) {
|
|
2016
|
+
for (let i = 0;i < writtenPaths.length; i++) {
|
|
2017
|
+
try {
|
|
2018
|
+
const path = writtenPaths[i];
|
|
2019
|
+
const update = updates[i];
|
|
2020
|
+
await writeFile3(path, update.originalContent, "utf-8");
|
|
2021
|
+
} catch {}
|
|
2022
|
+
}
|
|
2023
|
+
throw error;
|
|
2024
|
+
}
|
|
2025
|
+
return {
|
|
2026
|
+
finished,
|
|
2027
|
+
warnings: preview.warnings,
|
|
2028
|
+
autoDetectedStatus: preview.autoDetected,
|
|
2029
|
+
finalStatus: preview.finalStatus
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
// src/api.ts
|
|
2034
|
+
init_errors();
|
|
2035
|
+
|
|
1709
2036
|
class StitchClient {
|
|
1710
2037
|
repoRoot = null;
|
|
1711
2038
|
repoRootOverride;
|
|
@@ -1818,6 +2145,32 @@ class StitchClient {
|
|
|
1818
2145
|
const root = await this.getRepoRoot();
|
|
1819
2146
|
return stitchBlame(root, path);
|
|
1820
2147
|
}
|
|
2148
|
+
async getChildren(id) {
|
|
2149
|
+
const root = await this.getRepoRoot();
|
|
2150
|
+
return getChildren(root, id);
|
|
2151
|
+
}
|
|
2152
|
+
async getDescendants(id) {
|
|
2153
|
+
const root = await this.getRepoRoot();
|
|
2154
|
+
return getDescendants(root, id);
|
|
2155
|
+
}
|
|
2156
|
+
async prepareFinish(id, options) {
|
|
2157
|
+
const root = await this.getRepoRoot();
|
|
2158
|
+
const stitchId = id ?? await requireCurrentStitchId(root);
|
|
2159
|
+
return prepareFinish(root, stitchId, options);
|
|
2160
|
+
}
|
|
2161
|
+
async executeFinish(preview, options) {
|
|
2162
|
+
const root = await this.getRepoRoot();
|
|
2163
|
+
const result = await executeFinish(preview, options);
|
|
2164
|
+
const currentId = await getCurrentStitchId(root);
|
|
2165
|
+
if (currentId && result.finished.some((f) => f.id === currentId)) {
|
|
2166
|
+
await setCurrentStitchId(root, null);
|
|
2167
|
+
}
|
|
2168
|
+
return result;
|
|
2169
|
+
}
|
|
2170
|
+
async finish(id, options) {
|
|
2171
|
+
const preview = await this.prepareFinish(id, options);
|
|
2172
|
+
return this.executeFinish(preview, options);
|
|
2173
|
+
}
|
|
1821
2174
|
[Symbol.dispose]() {
|
|
1822
2175
|
this.close();
|
|
1823
2176
|
}
|
|
@@ -1833,5 +2186,7 @@ export {
|
|
|
1833
2186
|
RepoNotFoundError,
|
|
1834
2187
|
NotInitializedError,
|
|
1835
2188
|
NoCurrentStitchError,
|
|
1836
|
-
|
|
2189
|
+
InvalidSupersededByError,
|
|
2190
|
+
GitError,
|
|
2191
|
+
FinishForceRequiredError
|
|
1837
2192
|
};
|