@kairyou/agent-tools 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/README.zh-CN.md +3 -3
- package/dist/statusline/claude-statusline.mjs +866 -61
- package/dist/usage/core.mjs +1199 -377
- package/integrations/statusline/claude-statusline.mjs +6 -65
- package/integrations/usage/core.mjs +13 -1103
- package/integrations/usage/lib/cache.mjs +110 -0
- package/integrations/usage/lib/config.mjs +99 -0
- package/integrations/usage/lib/context.mjs +138 -0
- package/integrations/usage/lib/format.mjs +265 -0
- package/integrations/usage/lib/http.mjs +186 -0
- package/integrations/usage/lib/routes.mjs +265 -0
- package/integrations/usage/lib/urls.mjs +48 -0
- package/package.json +1 -1
|
@@ -5,6 +5,867 @@ import { execFileSync, spawn } from "node:child_process";
|
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import { basename, dirname, join } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
// node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
10
|
+
function createScanner(text, ignoreTrivia = false) {
|
|
11
|
+
const len = text.length;
|
|
12
|
+
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
13
|
+
function scanHexDigits(count, exact) {
|
|
14
|
+
let digits = 0;
|
|
15
|
+
let value2 = 0;
|
|
16
|
+
while (digits < count || !exact) {
|
|
17
|
+
let ch = text.charCodeAt(pos);
|
|
18
|
+
if (ch >= 48 && ch <= 57) {
|
|
19
|
+
value2 = value2 * 16 + ch - 48;
|
|
20
|
+
} else if (ch >= 65 && ch <= 70) {
|
|
21
|
+
value2 = value2 * 16 + ch - 65 + 10;
|
|
22
|
+
} else if (ch >= 97 && ch <= 102) {
|
|
23
|
+
value2 = value2 * 16 + ch - 97 + 10;
|
|
24
|
+
} else {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
pos++;
|
|
28
|
+
digits++;
|
|
29
|
+
}
|
|
30
|
+
if (digits < count) {
|
|
31
|
+
value2 = -1;
|
|
32
|
+
}
|
|
33
|
+
return value2;
|
|
34
|
+
}
|
|
35
|
+
function setPosition(newPosition) {
|
|
36
|
+
pos = newPosition;
|
|
37
|
+
value = "";
|
|
38
|
+
tokenOffset = 0;
|
|
39
|
+
token = 16;
|
|
40
|
+
scanError = 0;
|
|
41
|
+
}
|
|
42
|
+
function scanNumber() {
|
|
43
|
+
let start = pos;
|
|
44
|
+
if (text.charCodeAt(pos) === 48) {
|
|
45
|
+
pos++;
|
|
46
|
+
} else {
|
|
47
|
+
pos++;
|
|
48
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
49
|
+
pos++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (pos < text.length && text.charCodeAt(pos) === 46) {
|
|
53
|
+
pos++;
|
|
54
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
55
|
+
pos++;
|
|
56
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
57
|
+
pos++;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
scanError = 3;
|
|
61
|
+
return text.substring(start, pos);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let end = pos;
|
|
65
|
+
if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
66
|
+
pos++;
|
|
67
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
|
|
68
|
+
pos++;
|
|
69
|
+
}
|
|
70
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
71
|
+
pos++;
|
|
72
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
73
|
+
pos++;
|
|
74
|
+
}
|
|
75
|
+
end = pos;
|
|
76
|
+
} else {
|
|
77
|
+
scanError = 3;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return text.substring(start, end);
|
|
81
|
+
}
|
|
82
|
+
function scanString() {
|
|
83
|
+
let result = "", start = pos;
|
|
84
|
+
while (true) {
|
|
85
|
+
if (pos >= len) {
|
|
86
|
+
result += text.substring(start, pos);
|
|
87
|
+
scanError = 2;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
const ch = text.charCodeAt(pos);
|
|
91
|
+
if (ch === 34) {
|
|
92
|
+
result += text.substring(start, pos);
|
|
93
|
+
pos++;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
if (ch === 92) {
|
|
97
|
+
result += text.substring(start, pos);
|
|
98
|
+
pos++;
|
|
99
|
+
if (pos >= len) {
|
|
100
|
+
scanError = 2;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
const ch2 = text.charCodeAt(pos++);
|
|
104
|
+
switch (ch2) {
|
|
105
|
+
case 34:
|
|
106
|
+
result += '"';
|
|
107
|
+
break;
|
|
108
|
+
case 92:
|
|
109
|
+
result += "\\";
|
|
110
|
+
break;
|
|
111
|
+
case 47:
|
|
112
|
+
result += "/";
|
|
113
|
+
break;
|
|
114
|
+
case 98:
|
|
115
|
+
result += "\b";
|
|
116
|
+
break;
|
|
117
|
+
case 102:
|
|
118
|
+
result += "\f";
|
|
119
|
+
break;
|
|
120
|
+
case 110:
|
|
121
|
+
result += "\n";
|
|
122
|
+
break;
|
|
123
|
+
case 114:
|
|
124
|
+
result += "\r";
|
|
125
|
+
break;
|
|
126
|
+
case 116:
|
|
127
|
+
result += " ";
|
|
128
|
+
break;
|
|
129
|
+
case 117:
|
|
130
|
+
const ch3 = scanHexDigits(4, true);
|
|
131
|
+
if (ch3 >= 0) {
|
|
132
|
+
result += String.fromCharCode(ch3);
|
|
133
|
+
} else {
|
|
134
|
+
scanError = 4;
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
scanError = 5;
|
|
139
|
+
}
|
|
140
|
+
start = pos;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (ch >= 0 && ch <= 31) {
|
|
144
|
+
if (isLineBreak(ch)) {
|
|
145
|
+
result += text.substring(start, pos);
|
|
146
|
+
scanError = 2;
|
|
147
|
+
break;
|
|
148
|
+
} else {
|
|
149
|
+
scanError = 6;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
pos++;
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
function scanNext() {
|
|
157
|
+
value = "";
|
|
158
|
+
scanError = 0;
|
|
159
|
+
tokenOffset = pos;
|
|
160
|
+
lineStartOffset = lineNumber;
|
|
161
|
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
162
|
+
if (pos >= len) {
|
|
163
|
+
tokenOffset = len;
|
|
164
|
+
return token = 17;
|
|
165
|
+
}
|
|
166
|
+
let code = text.charCodeAt(pos);
|
|
167
|
+
if (isWhiteSpace(code)) {
|
|
168
|
+
do {
|
|
169
|
+
pos++;
|
|
170
|
+
value += String.fromCharCode(code);
|
|
171
|
+
code = text.charCodeAt(pos);
|
|
172
|
+
} while (isWhiteSpace(code));
|
|
173
|
+
return token = 15;
|
|
174
|
+
}
|
|
175
|
+
if (isLineBreak(code)) {
|
|
176
|
+
pos++;
|
|
177
|
+
value += String.fromCharCode(code);
|
|
178
|
+
if (code === 13 && text.charCodeAt(pos) === 10) {
|
|
179
|
+
pos++;
|
|
180
|
+
value += "\n";
|
|
181
|
+
}
|
|
182
|
+
lineNumber++;
|
|
183
|
+
tokenLineStartOffset = pos;
|
|
184
|
+
return token = 14;
|
|
185
|
+
}
|
|
186
|
+
switch (code) {
|
|
187
|
+
// tokens: []{}:,
|
|
188
|
+
case 123:
|
|
189
|
+
pos++;
|
|
190
|
+
return token = 1;
|
|
191
|
+
case 125:
|
|
192
|
+
pos++;
|
|
193
|
+
return token = 2;
|
|
194
|
+
case 91:
|
|
195
|
+
pos++;
|
|
196
|
+
return token = 3;
|
|
197
|
+
case 93:
|
|
198
|
+
pos++;
|
|
199
|
+
return token = 4;
|
|
200
|
+
case 58:
|
|
201
|
+
pos++;
|
|
202
|
+
return token = 6;
|
|
203
|
+
case 44:
|
|
204
|
+
pos++;
|
|
205
|
+
return token = 5;
|
|
206
|
+
// strings
|
|
207
|
+
case 34:
|
|
208
|
+
pos++;
|
|
209
|
+
value = scanString();
|
|
210
|
+
return token = 10;
|
|
211
|
+
// comments
|
|
212
|
+
case 47:
|
|
213
|
+
const start = pos - 1;
|
|
214
|
+
if (text.charCodeAt(pos + 1) === 47) {
|
|
215
|
+
pos += 2;
|
|
216
|
+
while (pos < len) {
|
|
217
|
+
if (isLineBreak(text.charCodeAt(pos))) {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
pos++;
|
|
221
|
+
}
|
|
222
|
+
value = text.substring(start, pos);
|
|
223
|
+
return token = 12;
|
|
224
|
+
}
|
|
225
|
+
if (text.charCodeAt(pos + 1) === 42) {
|
|
226
|
+
pos += 2;
|
|
227
|
+
const safeLength = len - 1;
|
|
228
|
+
let commentClosed = false;
|
|
229
|
+
while (pos < safeLength) {
|
|
230
|
+
const ch = text.charCodeAt(pos);
|
|
231
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
232
|
+
pos += 2;
|
|
233
|
+
commentClosed = true;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
pos++;
|
|
237
|
+
if (isLineBreak(ch)) {
|
|
238
|
+
if (ch === 13 && text.charCodeAt(pos) === 10) {
|
|
239
|
+
pos++;
|
|
240
|
+
}
|
|
241
|
+
lineNumber++;
|
|
242
|
+
tokenLineStartOffset = pos;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (!commentClosed) {
|
|
246
|
+
pos++;
|
|
247
|
+
scanError = 1;
|
|
248
|
+
}
|
|
249
|
+
value = text.substring(start, pos);
|
|
250
|
+
return token = 13;
|
|
251
|
+
}
|
|
252
|
+
value += String.fromCharCode(code);
|
|
253
|
+
pos++;
|
|
254
|
+
return token = 16;
|
|
255
|
+
// numbers
|
|
256
|
+
case 45:
|
|
257
|
+
value += String.fromCharCode(code);
|
|
258
|
+
pos++;
|
|
259
|
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
260
|
+
return token = 16;
|
|
261
|
+
}
|
|
262
|
+
// found a minus, followed by a number so
|
|
263
|
+
// we fall through to proceed with scanning
|
|
264
|
+
// numbers
|
|
265
|
+
case 48:
|
|
266
|
+
case 49:
|
|
267
|
+
case 50:
|
|
268
|
+
case 51:
|
|
269
|
+
case 52:
|
|
270
|
+
case 53:
|
|
271
|
+
case 54:
|
|
272
|
+
case 55:
|
|
273
|
+
case 56:
|
|
274
|
+
case 57:
|
|
275
|
+
value += scanNumber();
|
|
276
|
+
return token = 11;
|
|
277
|
+
// literals and unknown symbols
|
|
278
|
+
default:
|
|
279
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
280
|
+
pos++;
|
|
281
|
+
code = text.charCodeAt(pos);
|
|
282
|
+
}
|
|
283
|
+
if (tokenOffset !== pos) {
|
|
284
|
+
value = text.substring(tokenOffset, pos);
|
|
285
|
+
switch (value) {
|
|
286
|
+
case "true":
|
|
287
|
+
return token = 8;
|
|
288
|
+
case "false":
|
|
289
|
+
return token = 9;
|
|
290
|
+
case "null":
|
|
291
|
+
return token = 7;
|
|
292
|
+
}
|
|
293
|
+
return token = 16;
|
|
294
|
+
}
|
|
295
|
+
value += String.fromCharCode(code);
|
|
296
|
+
pos++;
|
|
297
|
+
return token = 16;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function isUnknownContentCharacter(code) {
|
|
301
|
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
switch (code) {
|
|
305
|
+
case 125:
|
|
306
|
+
case 93:
|
|
307
|
+
case 123:
|
|
308
|
+
case 91:
|
|
309
|
+
case 34:
|
|
310
|
+
case 58:
|
|
311
|
+
case 44:
|
|
312
|
+
case 47:
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
function scanNextNonTrivia() {
|
|
318
|
+
let result;
|
|
319
|
+
do {
|
|
320
|
+
result = scanNext();
|
|
321
|
+
} while (result >= 12 && result <= 15);
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
setPosition,
|
|
326
|
+
getPosition: () => pos,
|
|
327
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
328
|
+
getToken: () => token,
|
|
329
|
+
getTokenValue: () => value,
|
|
330
|
+
getTokenOffset: () => tokenOffset,
|
|
331
|
+
getTokenLength: () => pos - tokenOffset,
|
|
332
|
+
getTokenStartLine: () => lineStartOffset,
|
|
333
|
+
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
334
|
+
getTokenError: () => scanError
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function isWhiteSpace(ch) {
|
|
338
|
+
return ch === 32 || ch === 9;
|
|
339
|
+
}
|
|
340
|
+
function isLineBreak(ch) {
|
|
341
|
+
return ch === 10 || ch === 13;
|
|
342
|
+
}
|
|
343
|
+
function isDigit(ch) {
|
|
344
|
+
return ch >= 48 && ch <= 57;
|
|
345
|
+
}
|
|
346
|
+
var CharacterCodes;
|
|
347
|
+
(function(CharacterCodes2) {
|
|
348
|
+
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
|
|
349
|
+
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
|
|
350
|
+
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
|
|
351
|
+
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
|
|
352
|
+
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
|
|
353
|
+
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
|
|
354
|
+
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
|
|
355
|
+
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
|
|
356
|
+
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
|
|
357
|
+
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
|
|
358
|
+
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
|
|
359
|
+
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
|
|
360
|
+
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
|
|
361
|
+
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
|
|
362
|
+
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
|
|
363
|
+
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
|
|
364
|
+
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
|
|
365
|
+
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
|
|
366
|
+
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
|
|
367
|
+
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
|
|
368
|
+
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
|
|
369
|
+
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
|
|
370
|
+
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
|
|
371
|
+
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
|
|
372
|
+
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
|
|
373
|
+
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
|
|
374
|
+
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
|
|
375
|
+
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
|
|
376
|
+
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
|
|
377
|
+
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
|
|
378
|
+
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
|
|
379
|
+
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
|
|
380
|
+
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
|
|
381
|
+
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
|
|
382
|
+
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
|
|
383
|
+
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
|
|
384
|
+
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
|
|
385
|
+
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
|
|
386
|
+
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
|
|
387
|
+
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
|
|
388
|
+
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
|
|
389
|
+
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
|
|
390
|
+
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
|
|
391
|
+
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
|
|
392
|
+
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
|
|
393
|
+
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
|
|
394
|
+
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
|
|
395
|
+
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
|
|
396
|
+
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
|
|
397
|
+
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
|
|
398
|
+
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
|
|
399
|
+
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
|
|
400
|
+
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
|
|
401
|
+
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
|
|
402
|
+
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
|
|
403
|
+
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
|
|
404
|
+
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
|
|
405
|
+
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
|
|
406
|
+
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
|
|
407
|
+
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
|
|
408
|
+
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
|
|
409
|
+
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
|
|
410
|
+
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
|
|
411
|
+
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
|
|
412
|
+
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
|
|
413
|
+
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
|
|
414
|
+
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
|
|
415
|
+
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
|
|
416
|
+
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
|
|
417
|
+
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
|
|
418
|
+
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
|
|
419
|
+
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
|
|
420
|
+
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
|
|
421
|
+
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
|
|
422
|
+
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
|
|
423
|
+
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
|
|
424
|
+
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
|
|
425
|
+
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
|
|
426
|
+
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
427
|
+
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
428
|
+
})(CharacterCodes || (CharacterCodes = {}));
|
|
429
|
+
|
|
430
|
+
// node_modules/jsonc-parser/lib/esm/impl/string-intern.js
|
|
431
|
+
var cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
|
432
|
+
return " ".repeat(index);
|
|
433
|
+
});
|
|
434
|
+
var maxCachedValues = 200;
|
|
435
|
+
var cachedBreakLinesWithSpaces = {
|
|
436
|
+
" ": {
|
|
437
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
438
|
+
return "\n" + " ".repeat(index);
|
|
439
|
+
}),
|
|
440
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
441
|
+
return "\r" + " ".repeat(index);
|
|
442
|
+
}),
|
|
443
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
444
|
+
return "\r\n" + " ".repeat(index);
|
|
445
|
+
})
|
|
446
|
+
},
|
|
447
|
+
" ": {
|
|
448
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
449
|
+
return "\n" + " ".repeat(index);
|
|
450
|
+
}),
|
|
451
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
452
|
+
return "\r" + " ".repeat(index);
|
|
453
|
+
}),
|
|
454
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
455
|
+
return "\r\n" + " ".repeat(index);
|
|
456
|
+
})
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
// node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
461
|
+
var ParseOptions;
|
|
462
|
+
(function(ParseOptions2) {
|
|
463
|
+
ParseOptions2.DEFAULT = {
|
|
464
|
+
allowTrailingComma: false
|
|
465
|
+
};
|
|
466
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
467
|
+
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
468
|
+
let currentProperty = null;
|
|
469
|
+
let currentParent = [];
|
|
470
|
+
const previousParents = [];
|
|
471
|
+
function onValue(value) {
|
|
472
|
+
if (Array.isArray(currentParent)) {
|
|
473
|
+
currentParent.push(value);
|
|
474
|
+
} else if (currentProperty !== null) {
|
|
475
|
+
currentParent[currentProperty] = value;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const visitor = {
|
|
479
|
+
onObjectBegin: () => {
|
|
480
|
+
const object = {};
|
|
481
|
+
onValue(object);
|
|
482
|
+
previousParents.push(currentParent);
|
|
483
|
+
currentParent = object;
|
|
484
|
+
currentProperty = null;
|
|
485
|
+
},
|
|
486
|
+
onObjectProperty: (name) => {
|
|
487
|
+
currentProperty = name;
|
|
488
|
+
},
|
|
489
|
+
onObjectEnd: () => {
|
|
490
|
+
currentParent = previousParents.pop();
|
|
491
|
+
},
|
|
492
|
+
onArrayBegin: () => {
|
|
493
|
+
const array = [];
|
|
494
|
+
onValue(array);
|
|
495
|
+
previousParents.push(currentParent);
|
|
496
|
+
currentParent = array;
|
|
497
|
+
currentProperty = null;
|
|
498
|
+
},
|
|
499
|
+
onArrayEnd: () => {
|
|
500
|
+
currentParent = previousParents.pop();
|
|
501
|
+
},
|
|
502
|
+
onLiteralValue: onValue,
|
|
503
|
+
onError: (error, offset, length) => {
|
|
504
|
+
errors.push({ error, offset, length });
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
visit(text, visitor, options);
|
|
508
|
+
return currentParent[0];
|
|
509
|
+
}
|
|
510
|
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
511
|
+
const _scanner = createScanner(text, false);
|
|
512
|
+
const _jsonPath = [];
|
|
513
|
+
let suppressedCallbacks = 0;
|
|
514
|
+
function toNoArgVisit(visitFunction) {
|
|
515
|
+
return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
516
|
+
}
|
|
517
|
+
function toOneArgVisit(visitFunction) {
|
|
518
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
519
|
+
}
|
|
520
|
+
function toOneArgVisitWithPath(visitFunction) {
|
|
521
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
522
|
+
}
|
|
523
|
+
function toBeginVisit(visitFunction) {
|
|
524
|
+
return visitFunction ? () => {
|
|
525
|
+
if (suppressedCallbacks > 0) {
|
|
526
|
+
suppressedCallbacks++;
|
|
527
|
+
} else {
|
|
528
|
+
let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
|
|
529
|
+
if (cbReturn === false) {
|
|
530
|
+
suppressedCallbacks = 1;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
} : () => true;
|
|
534
|
+
}
|
|
535
|
+
function toEndVisit(visitFunction) {
|
|
536
|
+
return visitFunction ? () => {
|
|
537
|
+
if (suppressedCallbacks > 0) {
|
|
538
|
+
suppressedCallbacks--;
|
|
539
|
+
}
|
|
540
|
+
if (suppressedCallbacks === 0) {
|
|
541
|
+
visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
|
|
542
|
+
}
|
|
543
|
+
} : () => true;
|
|
544
|
+
}
|
|
545
|
+
const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
546
|
+
const disallowComments = options && options.disallowComments;
|
|
547
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
548
|
+
function scanNext() {
|
|
549
|
+
while (true) {
|
|
550
|
+
const token = _scanner.scan();
|
|
551
|
+
switch (_scanner.getTokenError()) {
|
|
552
|
+
case 4:
|
|
553
|
+
handleError(
|
|
554
|
+
14
|
|
555
|
+
/* ParseErrorCode.InvalidUnicode */
|
|
556
|
+
);
|
|
557
|
+
break;
|
|
558
|
+
case 5:
|
|
559
|
+
handleError(
|
|
560
|
+
15
|
|
561
|
+
/* ParseErrorCode.InvalidEscapeCharacter */
|
|
562
|
+
);
|
|
563
|
+
break;
|
|
564
|
+
case 3:
|
|
565
|
+
handleError(
|
|
566
|
+
13
|
|
567
|
+
/* ParseErrorCode.UnexpectedEndOfNumber */
|
|
568
|
+
);
|
|
569
|
+
break;
|
|
570
|
+
case 1:
|
|
571
|
+
if (!disallowComments) {
|
|
572
|
+
handleError(
|
|
573
|
+
11
|
|
574
|
+
/* ParseErrorCode.UnexpectedEndOfComment */
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
break;
|
|
578
|
+
case 2:
|
|
579
|
+
handleError(
|
|
580
|
+
12
|
|
581
|
+
/* ParseErrorCode.UnexpectedEndOfString */
|
|
582
|
+
);
|
|
583
|
+
break;
|
|
584
|
+
case 6:
|
|
585
|
+
handleError(
|
|
586
|
+
16
|
|
587
|
+
/* ParseErrorCode.InvalidCharacter */
|
|
588
|
+
);
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
switch (token) {
|
|
592
|
+
case 12:
|
|
593
|
+
case 13:
|
|
594
|
+
if (disallowComments) {
|
|
595
|
+
handleError(
|
|
596
|
+
10
|
|
597
|
+
/* ParseErrorCode.InvalidCommentToken */
|
|
598
|
+
);
|
|
599
|
+
} else {
|
|
600
|
+
onComment();
|
|
601
|
+
}
|
|
602
|
+
break;
|
|
603
|
+
case 16:
|
|
604
|
+
handleError(
|
|
605
|
+
1
|
|
606
|
+
/* ParseErrorCode.InvalidSymbol */
|
|
607
|
+
);
|
|
608
|
+
break;
|
|
609
|
+
case 15:
|
|
610
|
+
case 14:
|
|
611
|
+
break;
|
|
612
|
+
default:
|
|
613
|
+
return token;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
618
|
+
onError(error);
|
|
619
|
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
620
|
+
let token = _scanner.getToken();
|
|
621
|
+
while (token !== 17) {
|
|
622
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
623
|
+
scanNext();
|
|
624
|
+
break;
|
|
625
|
+
} else if (skipUntil.indexOf(token) !== -1) {
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
token = scanNext();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
function parseString(isValue) {
|
|
633
|
+
const value = _scanner.getTokenValue();
|
|
634
|
+
if (isValue) {
|
|
635
|
+
onLiteralValue(value);
|
|
636
|
+
} else {
|
|
637
|
+
onObjectProperty(value);
|
|
638
|
+
_jsonPath.push(value);
|
|
639
|
+
}
|
|
640
|
+
scanNext();
|
|
641
|
+
return true;
|
|
642
|
+
}
|
|
643
|
+
function parseLiteral() {
|
|
644
|
+
switch (_scanner.getToken()) {
|
|
645
|
+
case 11:
|
|
646
|
+
const tokenValue = _scanner.getTokenValue();
|
|
647
|
+
let value = Number(tokenValue);
|
|
648
|
+
if (isNaN(value)) {
|
|
649
|
+
handleError(
|
|
650
|
+
2
|
|
651
|
+
/* ParseErrorCode.InvalidNumberFormat */
|
|
652
|
+
);
|
|
653
|
+
value = 0;
|
|
654
|
+
}
|
|
655
|
+
onLiteralValue(value);
|
|
656
|
+
break;
|
|
657
|
+
case 7:
|
|
658
|
+
onLiteralValue(null);
|
|
659
|
+
break;
|
|
660
|
+
case 8:
|
|
661
|
+
onLiteralValue(true);
|
|
662
|
+
break;
|
|
663
|
+
case 9:
|
|
664
|
+
onLiteralValue(false);
|
|
665
|
+
break;
|
|
666
|
+
default:
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
scanNext();
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
672
|
+
function parseProperty() {
|
|
673
|
+
if (_scanner.getToken() !== 10) {
|
|
674
|
+
handleError(3, [], [
|
|
675
|
+
2,
|
|
676
|
+
5
|
|
677
|
+
/* SyntaxKind.CommaToken */
|
|
678
|
+
]);
|
|
679
|
+
return false;
|
|
680
|
+
}
|
|
681
|
+
parseString(false);
|
|
682
|
+
if (_scanner.getToken() === 6) {
|
|
683
|
+
onSeparator(":");
|
|
684
|
+
scanNext();
|
|
685
|
+
if (!parseValue()) {
|
|
686
|
+
handleError(4, [], [
|
|
687
|
+
2,
|
|
688
|
+
5
|
|
689
|
+
/* SyntaxKind.CommaToken */
|
|
690
|
+
]);
|
|
691
|
+
}
|
|
692
|
+
} else {
|
|
693
|
+
handleError(5, [], [
|
|
694
|
+
2,
|
|
695
|
+
5
|
|
696
|
+
/* SyntaxKind.CommaToken */
|
|
697
|
+
]);
|
|
698
|
+
}
|
|
699
|
+
_jsonPath.pop();
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
702
|
+
function parseObject() {
|
|
703
|
+
onObjectBegin();
|
|
704
|
+
scanNext();
|
|
705
|
+
let needsComma = false;
|
|
706
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
707
|
+
if (_scanner.getToken() === 5) {
|
|
708
|
+
if (!needsComma) {
|
|
709
|
+
handleError(4, [], []);
|
|
710
|
+
}
|
|
711
|
+
onSeparator(",");
|
|
712
|
+
scanNext();
|
|
713
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
} else if (needsComma) {
|
|
717
|
+
handleError(6, [], []);
|
|
718
|
+
}
|
|
719
|
+
if (!parseProperty()) {
|
|
720
|
+
handleError(4, [], [
|
|
721
|
+
2,
|
|
722
|
+
5
|
|
723
|
+
/* SyntaxKind.CommaToken */
|
|
724
|
+
]);
|
|
725
|
+
}
|
|
726
|
+
needsComma = true;
|
|
727
|
+
}
|
|
728
|
+
onObjectEnd();
|
|
729
|
+
if (_scanner.getToken() !== 2) {
|
|
730
|
+
handleError(7, [
|
|
731
|
+
2
|
|
732
|
+
/* SyntaxKind.CloseBraceToken */
|
|
733
|
+
], []);
|
|
734
|
+
} else {
|
|
735
|
+
scanNext();
|
|
736
|
+
}
|
|
737
|
+
return true;
|
|
738
|
+
}
|
|
739
|
+
function parseArray() {
|
|
740
|
+
onArrayBegin();
|
|
741
|
+
scanNext();
|
|
742
|
+
let isFirstElement = true;
|
|
743
|
+
let needsComma = false;
|
|
744
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
745
|
+
if (_scanner.getToken() === 5) {
|
|
746
|
+
if (!needsComma) {
|
|
747
|
+
handleError(4, [], []);
|
|
748
|
+
}
|
|
749
|
+
onSeparator(",");
|
|
750
|
+
scanNext();
|
|
751
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
} else if (needsComma) {
|
|
755
|
+
handleError(6, [], []);
|
|
756
|
+
}
|
|
757
|
+
if (isFirstElement) {
|
|
758
|
+
_jsonPath.push(0);
|
|
759
|
+
isFirstElement = false;
|
|
760
|
+
} else {
|
|
761
|
+
_jsonPath[_jsonPath.length - 1]++;
|
|
762
|
+
}
|
|
763
|
+
if (!parseValue()) {
|
|
764
|
+
handleError(4, [], [
|
|
765
|
+
4,
|
|
766
|
+
5
|
|
767
|
+
/* SyntaxKind.CommaToken */
|
|
768
|
+
]);
|
|
769
|
+
}
|
|
770
|
+
needsComma = true;
|
|
771
|
+
}
|
|
772
|
+
onArrayEnd();
|
|
773
|
+
if (!isFirstElement) {
|
|
774
|
+
_jsonPath.pop();
|
|
775
|
+
}
|
|
776
|
+
if (_scanner.getToken() !== 4) {
|
|
777
|
+
handleError(8, [
|
|
778
|
+
4
|
|
779
|
+
/* SyntaxKind.CloseBracketToken */
|
|
780
|
+
], []);
|
|
781
|
+
} else {
|
|
782
|
+
scanNext();
|
|
783
|
+
}
|
|
784
|
+
return true;
|
|
785
|
+
}
|
|
786
|
+
function parseValue() {
|
|
787
|
+
switch (_scanner.getToken()) {
|
|
788
|
+
case 3:
|
|
789
|
+
return parseArray();
|
|
790
|
+
case 1:
|
|
791
|
+
return parseObject();
|
|
792
|
+
case 10:
|
|
793
|
+
return parseString(true);
|
|
794
|
+
default:
|
|
795
|
+
return parseLiteral();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
scanNext();
|
|
799
|
+
if (_scanner.getToken() === 17) {
|
|
800
|
+
if (options.allowEmptyContent) {
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
handleError(4, [], []);
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
if (!parseValue()) {
|
|
807
|
+
handleError(4, [], []);
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
if (_scanner.getToken() !== 17) {
|
|
811
|
+
handleError(9, [], []);
|
|
812
|
+
}
|
|
813
|
+
return true;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// node_modules/jsonc-parser/lib/esm/main.js
|
|
817
|
+
var ScanError;
|
|
818
|
+
(function(ScanError2) {
|
|
819
|
+
ScanError2[ScanError2["None"] = 0] = "None";
|
|
820
|
+
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
821
|
+
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
822
|
+
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
823
|
+
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
824
|
+
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
825
|
+
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
826
|
+
})(ScanError || (ScanError = {}));
|
|
827
|
+
var SyntaxKind;
|
|
828
|
+
(function(SyntaxKind2) {
|
|
829
|
+
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
830
|
+
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
831
|
+
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
832
|
+
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
833
|
+
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
|
|
834
|
+
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
|
|
835
|
+
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
|
|
836
|
+
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
|
|
837
|
+
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
|
|
838
|
+
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
|
|
839
|
+
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
|
|
840
|
+
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
841
|
+
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
842
|
+
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
843
|
+
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
|
|
844
|
+
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
845
|
+
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
846
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
847
|
+
var parse2 = parse;
|
|
848
|
+
var ParseErrorCode;
|
|
849
|
+
(function(ParseErrorCode2) {
|
|
850
|
+
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
851
|
+
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
852
|
+
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
853
|
+
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
|
|
854
|
+
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
|
|
855
|
+
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
|
|
856
|
+
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
857
|
+
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
858
|
+
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
859
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
860
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
861
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
862
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
863
|
+
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
864
|
+
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
865
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
866
|
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
867
|
+
|
|
868
|
+
// integrations/statusline/claude-statusline.mjs
|
|
8
869
|
var SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
9
870
|
var AGENT_TOOLS_HOME = process.env.AGENT_TOOLS_HOME || join(SCRIPT_DIR, "..", "..");
|
|
10
871
|
var DEFAULT_CONFIG_FILE = join(AGENT_TOOLS_HOME, "config.jsonc");
|
|
@@ -46,71 +907,15 @@ async function readStdin() {
|
|
|
46
907
|
function readJsonFile(file) {
|
|
47
908
|
try {
|
|
48
909
|
if (!fs.existsSync(file)) return {};
|
|
49
|
-
const raw =
|
|
50
|
-
|
|
910
|
+
const raw = fs.readFileSync(file, "utf8").replace(/^\uFEFF/, "");
|
|
911
|
+
if (!raw.trim()) return {};
|
|
912
|
+
const errors = [];
|
|
913
|
+
const parsed = parse2(raw, errors, { allowTrailingComma: true });
|
|
914
|
+
return errors.length === 0 && parsed && typeof parsed === "object" ? parsed : {};
|
|
51
915
|
} catch {
|
|
52
916
|
return {};
|
|
53
917
|
}
|
|
54
918
|
}
|
|
55
|
-
function stripJsonComments(input) {
|
|
56
|
-
let out = "";
|
|
57
|
-
let inString = false;
|
|
58
|
-
let escaped = false;
|
|
59
|
-
for (let i = 0; i < input.length; i++) {
|
|
60
|
-
const ch = input[i];
|
|
61
|
-
const next = input[i + 1];
|
|
62
|
-
if (inString) {
|
|
63
|
-
out += ch;
|
|
64
|
-
escaped = ch === "\\" ? !escaped : false;
|
|
65
|
-
if (ch === '"' && !escaped) inString = false;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (ch === '"') {
|
|
69
|
-
inString = true;
|
|
70
|
-
out += ch;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (ch === "/" && next === "/") {
|
|
74
|
-
while (i < input.length && input[i] !== "\n") i++;
|
|
75
|
-
out += "\n";
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (ch === "/" && next === "*") {
|
|
79
|
-
i += 2;
|
|
80
|
-
while (i < input.length && !(input[i] === "*" && input[i + 1] === "/")) i++;
|
|
81
|
-
i++;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
out += ch;
|
|
85
|
-
}
|
|
86
|
-
return out;
|
|
87
|
-
}
|
|
88
|
-
function stripTrailingCommas(input) {
|
|
89
|
-
let out = "";
|
|
90
|
-
let inString = false;
|
|
91
|
-
let escaped = false;
|
|
92
|
-
for (let i = 0; i < input.length; i++) {
|
|
93
|
-
const ch = input[i];
|
|
94
|
-
if (inString) {
|
|
95
|
-
out += ch;
|
|
96
|
-
escaped = ch === "\\" ? !escaped : false;
|
|
97
|
-
if (ch === '"' && !escaped) inString = false;
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
if (ch === '"') {
|
|
101
|
-
inString = true;
|
|
102
|
-
out += ch;
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
if (ch === ",") {
|
|
106
|
-
let j = i + 1;
|
|
107
|
-
while (j < input.length && /\s/.test(input[j])) j++;
|
|
108
|
-
if (input[j] === "}" || input[j] === "]") continue;
|
|
109
|
-
}
|
|
110
|
-
out += ch;
|
|
111
|
-
}
|
|
112
|
-
return out;
|
|
113
|
-
}
|
|
114
919
|
function parseArgs(argv) {
|
|
115
920
|
const opts = {};
|
|
116
921
|
for (let i = 0; i < argv.length; i++) {
|