spexcode 0.6.8 → 0.7.0-next.1
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/node_modules/@spexcode/session-application/package.json +5 -5
- package/node_modules/@spexcode/session-events/package.json +2 -2
- package/node_modules/@spexcode/session-protocol/package.json +1 -1
- package/node_modules/@spexcode/session-runtime/package.json +2 -2
- package/node_modules/@spexcode/session-selflaunch/dist/locality.d.ts +12 -1
- package/node_modules/@spexcode/session-selflaunch/dist/locality.js +62 -10
- package/node_modules/@spexcode/session-selflaunch/package.json +3 -3
- package/node_modules/@spexcode/session-topology/package.json +2 -2
- package/node_modules/@spexcode/spec-cli/bin/spex.mjs +127 -10
- package/node_modules/@spexcode/spec-cli/dist/cli.js +19 -0
- package/node_modules/@spexcode/spec-cli/dist/file-write.js +14 -2
- package/node_modules/@spexcode/spec-cli/dist/guide.js +9 -11
- package/node_modules/@spexcode/spec-cli/dist/harness.d.ts +11 -5
- package/node_modules/@spexcode/spec-cli/dist/harness.js +185 -28
- package/node_modules/@spexcode/spec-cli/dist/host.js +5 -1
- package/node_modules/@spexcode/spec-cli/dist/index.js +21 -65
- package/node_modules/@spexcode/spec-cli/dist/machine-peer.d.ts +2 -1
- package/node_modules/@spexcode/spec-cli/dist/machine-peer.js +45 -14
- package/node_modules/@spexcode/spec-cli/dist/opencode.js +10 -2
- package/node_modules/@spexcode/spec-cli/dist/pi-harness.js +18 -5
- package/node_modules/@spexcode/spec-cli/dist/pi-headless.d.ts +2 -0
- package/node_modules/@spexcode/spec-cli/dist/pi-headless.js +27 -0
- package/node_modules/@spexcode/spec-cli/dist/session-transcript.d.ts +57 -0
- package/node_modules/@spexcode/spec-cli/dist/session-transcript.js +137 -0
- package/node_modules/@spexcode/spec-cli/dist/sessions.d.ts +4 -0
- package/node_modules/@spexcode/spec-cli/dist/sessions.js +104 -36
- package/node_modules/@spexcode/spec-cli/dist/shim-runtime.js +14 -0
- package/node_modules/@spexcode/spec-cli/dist/supervise.js +1 -1
- package/node_modules/@spexcode/spec-cli/package.json +8 -6
- package/node_modules/@spexcode/spec-core/dist/layout.d.ts +0 -1
- package/node_modules/@spexcode/spec-core/package.json +1 -1
- package/node_modules/@spexcode/spec-core/templates/spexcode.json +36 -13
- package/node_modules/@spexcode/spec-eval/package.json +2 -2
- package/node_modules/@spexcode/spec-forge/package.json +2 -2
- package/node_modules/@spexcode/transcript/dist/frames.d.ts +46 -0
- package/node_modules/@spexcode/transcript/dist/frames.js +87 -0
- package/node_modules/@spexcode/transcript/dist/index.d.ts +5 -0
- package/node_modules/@spexcode/transcript/dist/index.js +5 -0
- package/node_modules/@spexcode/transcript/dist/live.d.ts +16 -0
- package/node_modules/@spexcode/transcript/dist/live.js +65 -0
- package/node_modules/@spexcode/transcript/dist/parsers.d.ts +50 -0
- package/node_modules/@spexcode/transcript/dist/parsers.js +395 -0
- package/node_modules/@spexcode/transcript/dist/readers.d.ts +16 -0
- package/node_modules/@spexcode/transcript/dist/readers.js +375 -0
- package/node_modules/@spexcode/{spec-cli/dist/transcript-reader.d.ts → transcript/dist/turns.d.ts} +11 -5
- package/node_modules/@spexcode/transcript/dist/turns.js +11 -0
- package/node_modules/@spexcode/transcript/package.json +30 -0
- package/node_modules/smol-toml/LICENSE +24 -0
- package/node_modules/smol-toml/README.md +418 -0
- package/node_modules/smol-toml/dist/date.d.ts +41 -0
- package/node_modules/smol-toml/dist/date.js +127 -0
- package/node_modules/smol-toml/dist/error.d.ts +38 -0
- package/node_modules/smol-toml/dist/error.js +63 -0
- package/node_modules/smol-toml/dist/extract.js +69 -0
- package/node_modules/smol-toml/dist/index.cjs +734 -0
- package/node_modules/smol-toml/dist/index.d.ts +43 -0
- package/node_modules/smol-toml/dist/index.js +33 -0
- package/node_modules/smol-toml/dist/parse.d.ts +36 -0
- package/node_modules/smol-toml/dist/parse.js +149 -0
- package/node_modules/smol-toml/dist/primitive.js +238 -0
- package/node_modules/smol-toml/dist/stringify.d.ts +31 -0
- package/node_modules/smol-toml/dist/stringify.js +181 -0
- package/node_modules/smol-toml/dist/struct.js +179 -0
- package/node_modules/smol-toml/dist/util.d.ts +38 -0
- package/node_modules/smol-toml/dist/util.js +89 -0
- package/node_modules/smol-toml/package.json +68 -0
- package/package.json +3 -3
- package/node_modules/@spexcode/spec-cli/dist/execution-trace.d.ts +0 -27
- package/node_modules/@spexcode/spec-cli/dist/execution-trace.js +0 -475
- package/node_modules/@spexcode/spec-cli/dist/session-execution.d.ts +0 -10
- package/node_modules/@spexcode/spec-cli/dist/session-execution.js +0 -70
- package/node_modules/@spexcode/spec-cli/dist/transcript-reader.js +0 -251
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
* list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
* may be used to endorse or promote products derived from this software without
|
|
15
|
+
* specific prior written permission.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
let BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
29
|
+
function extendedTypeOf(obj) {
|
|
30
|
+
let type = typeof obj;
|
|
31
|
+
if (type === 'object') {
|
|
32
|
+
if (Array.isArray(obj))
|
|
33
|
+
return 'array';
|
|
34
|
+
if (typeof obj?.getUTCDate === 'function' && obj instanceof Date)
|
|
35
|
+
return 'date';
|
|
36
|
+
if (globalThis.Temporal &&
|
|
37
|
+
// check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
|
|
38
|
+
typeof obj?.since === 'function' &&
|
|
39
|
+
(obj instanceof Temporal.Instant ||
|
|
40
|
+
obj instanceof Temporal.PlainDate ||
|
|
41
|
+
obj instanceof Temporal.PlainDateTime ||
|
|
42
|
+
obj instanceof Temporal.PlainTime ||
|
|
43
|
+
obj instanceof Temporal.ZonedDateTime)) {
|
|
44
|
+
return 'temporal';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return type;
|
|
48
|
+
}
|
|
49
|
+
function isArrayOfTables(obj) {
|
|
50
|
+
for (let i = 0; i < obj.length; i++) {
|
|
51
|
+
if (extendedTypeOf(obj[i]) !== 'object')
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return obj.length != 0;
|
|
55
|
+
}
|
|
56
|
+
function formatString(s) {
|
|
57
|
+
return JSON.stringify(s).replace(/\x7f/g, '\\u007f');
|
|
58
|
+
}
|
|
59
|
+
function stringifyTemporal(temporal) {
|
|
60
|
+
return temporal.toString({
|
|
61
|
+
calendarName: 'never',
|
|
62
|
+
timeZoneName: 'never',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
66
|
+
if (depth === 0) {
|
|
67
|
+
throw new Error('Could not stringify the object: maximum object depth exceeded');
|
|
68
|
+
}
|
|
69
|
+
switch (type) {
|
|
70
|
+
// @ts-expect-error -- intentional fallthrough case
|
|
71
|
+
case 'number':
|
|
72
|
+
if (isNaN(val))
|
|
73
|
+
return 'nan';
|
|
74
|
+
if (val === Infinity)
|
|
75
|
+
return 'inf';
|
|
76
|
+
if (val === -Infinity)
|
|
77
|
+
return '-inf';
|
|
78
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
|
|
79
|
+
return val.toFixed(1);
|
|
80
|
+
case 'bigint':
|
|
81
|
+
case 'boolean':
|
|
82
|
+
return val.toString();
|
|
83
|
+
case 'string':
|
|
84
|
+
return formatString(val);
|
|
85
|
+
case 'date':
|
|
86
|
+
if (isNaN(val.getTime()))
|
|
87
|
+
throw new TypeError('cannot serialize invalid date');
|
|
88
|
+
return val.toISOString();
|
|
89
|
+
case 'object':
|
|
90
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
91
|
+
case 'array':
|
|
92
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
93
|
+
case 'temporal':
|
|
94
|
+
return stringifyTemporal(val);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
98
|
+
let keys = Object.keys(obj);
|
|
99
|
+
if (keys.length === 0)
|
|
100
|
+
return '{}';
|
|
101
|
+
let res = '{ ';
|
|
102
|
+
for (let i = 0; i < keys.length; i++) {
|
|
103
|
+
let k = keys[i];
|
|
104
|
+
if (i)
|
|
105
|
+
res += ', ';
|
|
106
|
+
res += BARE_KEY.test(k) ? k : formatString(k);
|
|
107
|
+
res += ' = ';
|
|
108
|
+
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
109
|
+
}
|
|
110
|
+
return res + ' }';
|
|
111
|
+
}
|
|
112
|
+
function stringifyArray(array, depth, numberAsFloat) {
|
|
113
|
+
if (array.length === 0)
|
|
114
|
+
return '[]';
|
|
115
|
+
let res = '[ ';
|
|
116
|
+
for (let i = 0; i < array.length; i++) {
|
|
117
|
+
if (i)
|
|
118
|
+
res += ', ';
|
|
119
|
+
if (array[i] === null || array[i] === void 0) {
|
|
120
|
+
throw new TypeError('arrays cannot contain null or undefined values');
|
|
121
|
+
}
|
|
122
|
+
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
|
|
123
|
+
}
|
|
124
|
+
return res + ' ]';
|
|
125
|
+
}
|
|
126
|
+
function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
127
|
+
if (depth === 0) {
|
|
128
|
+
throw new Error('Could not stringify the object: maximum object depth exceeded');
|
|
129
|
+
}
|
|
130
|
+
let res = '';
|
|
131
|
+
for (let i = 0; i < array.length; i++) {
|
|
132
|
+
res += `${res && '\n'}[[${key}]]\n`;
|
|
133
|
+
res += stringifyTable(0, array[i], key, depth, numberAsFloat);
|
|
134
|
+
}
|
|
135
|
+
return res;
|
|
136
|
+
}
|
|
137
|
+
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
138
|
+
if (depth === 0) {
|
|
139
|
+
throw new Error('Could not stringify the object: maximum object depth exceeded');
|
|
140
|
+
}
|
|
141
|
+
let preamble = '';
|
|
142
|
+
let tables = '';
|
|
143
|
+
let keys = Object.keys(obj);
|
|
144
|
+
for (let i = 0; i < keys.length; i++) {
|
|
145
|
+
let k = keys[i];
|
|
146
|
+
if (obj[k] !== null && obj[k] !== void 0) {
|
|
147
|
+
let type = extendedTypeOf(obj[k]);
|
|
148
|
+
if (type === 'symbol' || type === 'function') {
|
|
149
|
+
throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
150
|
+
}
|
|
151
|
+
let key = BARE_KEY.test(k) ? k : formatString(k);
|
|
152
|
+
if (type === 'array' && isArrayOfTables(obj[k])) {
|
|
153
|
+
tables += (tables && '\n') + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
154
|
+
}
|
|
155
|
+
else if (type === 'object') {
|
|
156
|
+
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
157
|
+
tables += (tables && '\n') + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
preamble += key;
|
|
161
|
+
preamble += ' = ';
|
|
162
|
+
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
163
|
+
preamble += '\n';
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (tableKey && (preamble || !tables)) // Create table only if necessary
|
|
168
|
+
preamble = preamble ? `[${tableKey}]\n${preamble}` : `[${tableKey}]`;
|
|
169
|
+
return preamble && tables
|
|
170
|
+
? `${preamble}\n${tables}`
|
|
171
|
+
: preamble || tables;
|
|
172
|
+
}
|
|
173
|
+
export function stringify(obj, { maxDepth = 1000, numbersAsFloat = false } = {}) {
|
|
174
|
+
if (extendedTypeOf(obj) !== 'object') {
|
|
175
|
+
throw new TypeError('stringify can only be called with an object');
|
|
176
|
+
}
|
|
177
|
+
let str = stringifyTable(0, obj, '', maxDepth, numbersAsFloat);
|
|
178
|
+
if (str[str.length - 1] !== '\n')
|
|
179
|
+
return str + '\n';
|
|
180
|
+
return str;
|
|
181
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
* list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
* may be used to endorse or promote products derived from this software without
|
|
15
|
+
* specific prior written permission.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
import { parseString } from './primitive.js';
|
|
29
|
+
import { extractValue } from './extract.js';
|
|
30
|
+
import { indexOfNewline, skipVoid } from './util.js';
|
|
31
|
+
import { TomlError } from './error.js';
|
|
32
|
+
let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
33
|
+
/** @internal */
|
|
34
|
+
export function parseKey(ctx, end = '=') {
|
|
35
|
+
let start = ctx.p;
|
|
36
|
+
let dot = start - 1;
|
|
37
|
+
let parsed = [];
|
|
38
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
39
|
+
if (endPtr < 0) {
|
|
40
|
+
throw new TomlError('incomplete key-value: cannot find end of key', {
|
|
41
|
+
toml: ctx.s,
|
|
42
|
+
ptr: start,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
do {
|
|
46
|
+
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
47
|
+
// If it's whitespace, ignore
|
|
48
|
+
if (c !== 0x20 && c !== 0x9 /* \t */) {
|
|
49
|
+
// If it's a string
|
|
50
|
+
if (c === 0x22 /* " */ || c === 0x27 /* ' */) {
|
|
51
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
|
|
52
|
+
throw new TomlError('multiline strings are not allowed in keys', {
|
|
53
|
+
toml: ctx.s,
|
|
54
|
+
ptr: ctx.p,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
let part = parseString(ctx);
|
|
58
|
+
dot = ctx.s.indexOf('.', ctx.p);
|
|
59
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
60
|
+
let newLine = indexOfNewline(strEnd);
|
|
61
|
+
if (newLine > -1) {
|
|
62
|
+
throw new TomlError('newlines are not allowed in keys', {
|
|
63
|
+
toml: ctx.s,
|
|
64
|
+
ptr: newLine,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (strEnd.trimStart()) {
|
|
68
|
+
throw new TomlError('found extra tokens after the string part', {
|
|
69
|
+
toml: ctx.s,
|
|
70
|
+
ptr: ctx.p,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (endPtr < ctx.p) {
|
|
74
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
75
|
+
if (endPtr < 0) {
|
|
76
|
+
throw new TomlError('incomplete key-value: cannot find end of key', {
|
|
77
|
+
toml: ctx.s,
|
|
78
|
+
ptr: start,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
parsed.push(part);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// Normal raw key part consumption and validation
|
|
86
|
+
dot = ctx.s.indexOf('.', ctx.p);
|
|
87
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
88
|
+
if (!KEY_PART_RE.test(part)) {
|
|
89
|
+
throw new TomlError('only letter, numbers, dashes and underscores are allowed in keys', {
|
|
90
|
+
toml: ctx.s,
|
|
91
|
+
ptr: ctx.p,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
parsed.push(part.trimEnd());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Until there's no more dot
|
|
98
|
+
} while (dot + 1 && dot < endPtr);
|
|
99
|
+
ctx.p = endPtr + 1;
|
|
100
|
+
skipVoid(ctx, true, true);
|
|
101
|
+
return parsed;
|
|
102
|
+
}
|
|
103
|
+
/** @internal */
|
|
104
|
+
export function parseInlineTable(ctx, integersAsBigInt) {
|
|
105
|
+
let res = {};
|
|
106
|
+
let seen = new Set();
|
|
107
|
+
let c;
|
|
108
|
+
ctx.p++;
|
|
109
|
+
while (ctx.p < ctx.s.length) {
|
|
110
|
+
skipVoid(ctx);
|
|
111
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 0x7d /* } */) {
|
|
112
|
+
ctx.p++;
|
|
113
|
+
return res;
|
|
114
|
+
}
|
|
115
|
+
let k;
|
|
116
|
+
let t = res;
|
|
117
|
+
let hasOwn = false;
|
|
118
|
+
let p = ctx.p;
|
|
119
|
+
let key = parseKey(ctx);
|
|
120
|
+
for (let i = 0; i < key.length; i++) {
|
|
121
|
+
if (i)
|
|
122
|
+
t = hasOwn ? t[k] : (t[k] = {});
|
|
123
|
+
k = key[i];
|
|
124
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== 'object' || seen.has(t[k]))) {
|
|
125
|
+
throw new TomlError('trying to redefine an already defined value', {
|
|
126
|
+
toml: ctx.s,
|
|
127
|
+
ptr: p,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (!hasOwn && k === '__proto__') {
|
|
131
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (hasOwn) {
|
|
135
|
+
throw new TomlError('trying to redefine an already defined value', {
|
|
136
|
+
toml: ctx.s,
|
|
137
|
+
ptr: ctx.p,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
let value = extractValue(ctx, 0x7d /* } */, integersAsBigInt);
|
|
141
|
+
seen.add(t[k] = value);
|
|
142
|
+
skipVoid(ctx);
|
|
143
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 0x7d /* } */) {
|
|
144
|
+
return res;
|
|
145
|
+
}
|
|
146
|
+
if (c !== 0x2c /* , */) {
|
|
147
|
+
throw new TomlError('expected comma or end of structure', { toml: ctx.s, ptr: ctx.p - 1 });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
throw new TomlError('unfinished table encountered', {
|
|
151
|
+
toml: ctx.s,
|
|
152
|
+
ptr: ctx.p,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/** @internal */
|
|
156
|
+
export function parseArray(ctx, integersAsBigInt) {
|
|
157
|
+
let res = [];
|
|
158
|
+
let c;
|
|
159
|
+
ctx.p++;
|
|
160
|
+
while (ctx.p < ctx.s.length) {
|
|
161
|
+
skipVoid(ctx);
|
|
162
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 0x5d /* ] */) {
|
|
163
|
+
ctx.p++;
|
|
164
|
+
return res;
|
|
165
|
+
}
|
|
166
|
+
res.push(extractValue(ctx, 0x5d /* ] */, integersAsBigInt));
|
|
167
|
+
skipVoid(ctx);
|
|
168
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 0x5d /* ] */) {
|
|
169
|
+
return res;
|
|
170
|
+
}
|
|
171
|
+
if (c !== 0x2c /* , */) {
|
|
172
|
+
throw new TomlError('expected comma or end of structure', { toml: ctx.s, ptr: ctx.p - 1 });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
throw new TomlError('unfinished array encountered', {
|
|
176
|
+
toml: ctx.s,
|
|
177
|
+
ptr: ctx.p,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
* list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
* may be used to endorse or promote products derived from this software without
|
|
15
|
+
* specific prior written permission.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
import type { TomlDate } from './date.js';
|
|
29
|
+
export type IntegersAsBigInt = undefined | boolean | 'asNeeded';
|
|
30
|
+
export type TomlPrimitive = string | number | bigint | boolean | TomlDate;
|
|
31
|
+
export type TomlTable = {
|
|
32
|
+
[key: string]: TomlValue;
|
|
33
|
+
};
|
|
34
|
+
export type TomlValue = TomlPrimitive | TomlValue[] | TomlTable;
|
|
35
|
+
export type TomlTableWithoutBigInt = {
|
|
36
|
+
[key: string]: TomlValueWithoutBigInt;
|
|
37
|
+
};
|
|
38
|
+
export type TomlValueWithoutBigInt = Exclude<TomlPrimitive, bigint> | TomlValueWithoutBigInt[] | TomlTableWithoutBigInt;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
* list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
* may be used to endorse or promote products derived from this software without
|
|
15
|
+
* specific prior written permission.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
import { TomlError } from './error.js';
|
|
29
|
+
/** @internal */
|
|
30
|
+
export function indexOfNewline(str, start = 0) {
|
|
31
|
+
let idx = str.indexOf('\n', start);
|
|
32
|
+
if (str.charCodeAt(idx - 1) === 0xd /* \r */)
|
|
33
|
+
idx--;
|
|
34
|
+
return idx;
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
export function skipComment(ctx) {
|
|
38
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
39
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
40
|
+
if (c === 0xa /* \n */)
|
|
41
|
+
break;
|
|
42
|
+
if (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */) {
|
|
43
|
+
ctx.p++;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) {
|
|
47
|
+
throw new TomlError('control characters are not allowed in comments', {
|
|
48
|
+
toml: ctx.s,
|
|
49
|
+
ptr: ctx.p,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** @internal */
|
|
55
|
+
export function skipVoid(ctx, banNewLines, banComments) {
|
|
56
|
+
let c;
|
|
57
|
+
while (1) {
|
|
58
|
+
while ((c = ctx.s.charCodeAt(ctx.p)) === 0x20 ||
|
|
59
|
+
c === 0x9 /* \t */ ||
|
|
60
|
+
(!banNewLines &&
|
|
61
|
+
(c === 0xa /* \n */ || (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */))))
|
|
62
|
+
ctx.p++;
|
|
63
|
+
if (banComments || c !== 0x23 /* # */)
|
|
64
|
+
break;
|
|
65
|
+
skipComment(ctx);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** @internal */
|
|
69
|
+
export function skipUntil(ctx, sep, end) {
|
|
70
|
+
let ptr = ctx.p;
|
|
71
|
+
if (!end) {
|
|
72
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
73
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
77
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
78
|
+
if (c === 0x23 /* # */) {
|
|
79
|
+
skipComment(ctx);
|
|
80
|
+
}
|
|
81
|
+
else if (c === end || c === sep) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw new TomlError('cannot find end of structure', {
|
|
86
|
+
toml: ctx.s,
|
|
87
|
+
ptr,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "smol-toml",
|
|
3
|
+
"version": "1.8.0",
|
|
4
|
+
"description": "A small, fast, and correct TOML parser/serializer",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"parser",
|
|
7
|
+
"serializer",
|
|
8
|
+
"toml"
|
|
9
|
+
],
|
|
10
|
+
"bugs": "https://github.com/squirrelchat/smol-toml/issues",
|
|
11
|
+
"license": "BSD-3-Clause",
|
|
12
|
+
"author": "Cynthia Rey <cynthia@cynthia.dev>",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "github:squirrelchat/smol-toml"
|
|
16
|
+
},
|
|
17
|
+
"funding": "https://github.com/sponsors/cyyynthia",
|
|
18
|
+
"files": [
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"provenance": true
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@mitata/counters": "^0.0.8",
|
|
38
|
+
"@tsconfig/node-lts": "^24.0.0",
|
|
39
|
+
"@tsconfig/node-ts": "^23.6.4",
|
|
40
|
+
"@tsconfig/strictest": "^2.0.8",
|
|
41
|
+
"@types/node": "^26.2.0",
|
|
42
|
+
"mitata": "^1.0.34",
|
|
43
|
+
"pin-github-action": "^3.5.1",
|
|
44
|
+
"rolldown": "^1.2.3",
|
|
45
|
+
"typescript": "^7.0.2",
|
|
46
|
+
"vite": "^7.3.6",
|
|
47
|
+
"vitest": "^4.1.10"
|
|
48
|
+
},
|
|
49
|
+
"devEngines": {
|
|
50
|
+
"packageManager": {
|
|
51
|
+
"name": "pnpm",
|
|
52
|
+
"version": "11.21.0",
|
|
53
|
+
"onFail": "error"
|
|
54
|
+
},
|
|
55
|
+
"runtime": {
|
|
56
|
+
"name": "node",
|
|
57
|
+
"version": "^26",
|
|
58
|
+
"onFail": "warn"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">= 18"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"test": "vitest",
|
|
66
|
+
"update-gha": "pin-github-action .github/workflows"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spexcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-next.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SpexCode — a spec-driven, self-developing dev tool. The `spex` CLI + spec server reads the .spec tree and its git history, and serves the dashboard.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"node": ">=22"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "
|
|
24
|
+
"build": "node scripts/build-workspaces.mjs",
|
|
25
25
|
"typecheck": "tsc --noEmit -p spec-cli/tsconfig.json",
|
|
26
26
|
"migrate:sessions": "npm run build && node scripts/migrate-session-json.mjs",
|
|
27
27
|
"test:session-cutover": "node --test scripts/session-live-cutover.test.mjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"prepack": "node scripts/sync-init-plugins.mjs --check && node scripts/prepack.mjs"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@spexcode/spec-cli": "0.
|
|
47
|
+
"@spexcode/spec-cli": "0.7.0-next.1"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type ExecutionTurn = Readonly<{
|
|
2
|
-
token: string;
|
|
3
|
-
acceptedAt: string;
|
|
4
|
-
}>;
|
|
5
|
-
export type ExecutionStepKind = 'command' | 'read' | 'write' | 'search' | 'tool';
|
|
6
|
-
export type ExecutionStep = Readonly<{
|
|
7
|
-
id: string;
|
|
8
|
-
kind: ExecutionStepKind;
|
|
9
|
-
label: string;
|
|
10
|
-
detail?: string;
|
|
11
|
-
state: 'running' | 'done';
|
|
12
|
-
}>;
|
|
13
|
-
export type ExecutionTrace = Readonly<{
|
|
14
|
-
revision: string;
|
|
15
|
-
turnId: string | null;
|
|
16
|
-
workingNote: string | null;
|
|
17
|
-
steps: readonly ExecutionStep[];
|
|
18
|
-
}>;
|
|
19
|
-
type ExportLoader = (threadId: string) => string;
|
|
20
|
-
export declare function codexRolloutPath(threadId: string, root?: string): string | null;
|
|
21
|
-
export declare function readCodexExecutionTrace(threadId: string, turn: ExecutionTurn | null, root?: string): ExecutionTrace;
|
|
22
|
-
export declare function claudeTranscriptPath(threadId: string, root?: string): string | null;
|
|
23
|
-
export declare function readProjectJsonlExecutionTrace(threadId: string, turn: ExecutionTurn | null, root?: string): ExecutionTrace;
|
|
24
|
-
export declare function readSessionJsonlExecutionTrace(threadId: string, turn: ExecutionTurn | null, root?: string): ExecutionTrace;
|
|
25
|
-
export declare function readLocalStoreExecutionTrace(threadId: string, turn: ExecutionTurn | null, root?: string, load?: ExportLoader): ExecutionTrace;
|
|
26
|
-
export declare const noExecutionTrace: (_threadId: string, _turn: ExecutionTurn | null) => ExecutionTrace | null;
|
|
27
|
-
export {};
|