kimi-plugin-cc 2.0.8 → 2.2.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.
Files changed (88) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +27 -0
  4. package/README.md +5 -5
  5. package/agents/kimi-ask.md +5 -1
  6. package/agents/kimi-challenge.md +4 -2
  7. package/agents/kimi-pursue.md +3 -1
  8. package/agents/kimi-rescue.md +5 -1
  9. package/agents/kimi-review.md +4 -2
  10. package/agents/kimi-swarm-write.md +3 -1
  11. package/agents/kimi-swarm.md +3 -1
  12. package/commands/ask.md +5 -3
  13. package/commands/challenge.md +5 -3
  14. package/commands/pursue.md +5 -1
  15. package/commands/rescue.md +5 -3
  16. package/commands/review.md +5 -3
  17. package/commands/swarm.md +5 -1
  18. package/dist/cli-client.js +42 -10
  19. package/dist/commands/ask.js +14 -7
  20. package/dist/commands/cli-helpers.js +66 -4
  21. package/dist/commands/pursue.js +7 -3
  22. package/dist/commands/rescue.js +16 -10
  23. package/dist/commands/result.js +5 -1
  24. package/dist/commands/review-gate.js +21 -14
  25. package/dist/commands/review.js +9 -5
  26. package/dist/commands/status.js +2 -2
  27. package/dist/commands/swarm.js +10 -4
  28. package/dist/help.js +1 -1
  29. package/dist/hook-escape.js +71 -0
  30. package/dist/hooks/approval-policy.js +17 -27
  31. package/dist/hooks/config-safety.js +15 -7
  32. package/dist/job-store.js +52 -7
  33. package/dist/kimi-engine.js +2 -0
  34. package/dist/kimi-errors.js +1 -1
  35. package/dist/kimi-timeouts.js +6 -10
  36. package/dist/kimi-version-probe.js +2 -2
  37. package/dist/parsing.js +59 -53
  38. package/dist/session-recovery.js +203 -0
  39. package/dist/vendor/smol-toml/date.js +50 -21
  40. package/dist/vendor/smol-toml/error.js +6 -2
  41. package/dist/vendor/smol-toml/extract.js +259 -66
  42. package/dist/vendor/smol-toml/parse.js +64 -48
  43. package/dist/vendor/smol-toml/primitive.js +107 -135
  44. package/dist/vendor/smol-toml/struct.js +106 -134
  45. package/dist/vendor/smol-toml/util.js +22 -78
  46. package/dist/version.js +1 -1
  47. package/docs/models.md +10 -0
  48. package/docs/registry-releases.md +24 -1
  49. package/docs/safety.md +59 -2
  50. package/package.json +1 -1
  51. package/plugins/kimi-codex/.codex-plugin/plugin.json +1 -1
  52. package/plugins/kimi-codex/dist/cli-client.js +42 -10
  53. package/plugins/kimi-codex/dist/commands/ask.js +14 -7
  54. package/plugins/kimi-codex/dist/commands/cli-helpers.js +66 -4
  55. package/plugins/kimi-codex/dist/commands/pursue.js +7 -3
  56. package/plugins/kimi-codex/dist/commands/rescue.js +16 -10
  57. package/plugins/kimi-codex/dist/commands/result.js +5 -1
  58. package/plugins/kimi-codex/dist/commands/review-gate.js +21 -14
  59. package/plugins/kimi-codex/dist/commands/review.js +9 -5
  60. package/plugins/kimi-codex/dist/commands/status.js +2 -2
  61. package/plugins/kimi-codex/dist/commands/swarm.js +10 -4
  62. package/plugins/kimi-codex/dist/help.js +1 -1
  63. package/plugins/kimi-codex/dist/hook-escape.js +71 -0
  64. package/plugins/kimi-codex/dist/hooks/approval-policy.js +17 -27
  65. package/plugins/kimi-codex/dist/hooks/config-safety.js +15 -7
  66. package/plugins/kimi-codex/dist/job-store.js +52 -7
  67. package/plugins/kimi-codex/dist/kimi-engine.js +2 -0
  68. package/plugins/kimi-codex/dist/kimi-errors.js +1 -1
  69. package/plugins/kimi-codex/dist/kimi-timeouts.js +6 -10
  70. package/plugins/kimi-codex/dist/kimi-version-probe.js +2 -2
  71. package/plugins/kimi-codex/dist/parsing.js +59 -53
  72. package/plugins/kimi-codex/dist/session-recovery.js +203 -0
  73. package/plugins/kimi-codex/dist/vendor/smol-toml/date.js +50 -21
  74. package/plugins/kimi-codex/dist/vendor/smol-toml/error.js +6 -2
  75. package/plugins/kimi-codex/dist/vendor/smol-toml/extract.js +259 -66
  76. package/plugins/kimi-codex/dist/vendor/smol-toml/parse.js +64 -48
  77. package/plugins/kimi-codex/dist/vendor/smol-toml/primitive.js +107 -135
  78. package/plugins/kimi-codex/dist/vendor/smol-toml/struct.js +106 -134
  79. package/plugins/kimi-codex/dist/vendor/smol-toml/util.js +22 -78
  80. package/plugins/kimi-codex/dist/version.js +1 -1
  81. package/plugins/kimi-codex/skills/kimi-ask/SKILL.md +4 -2
  82. package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +4 -2
  83. package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +3 -1
  84. package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +4 -2
  85. package/plugins/kimi-codex/skills/kimi-review/SKILL.md +4 -2
  86. package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +2 -0
  87. package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +3 -1
  88. package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +3 -1
@@ -29,7 +29,7 @@ import { parseKey } from './struct.js';
29
29
  import { extractValue } from './extract.js';
30
30
  import { skipVoid } from './util.js';
31
31
  import { TomlError } from './error.js';
32
- function peekTable(key, table, meta, type) {
32
+ function peekTable(ctx, key, table, meta, type) {
33
33
  let t = table;
34
34
  let m = meta;
35
35
  let k;
@@ -37,7 +37,7 @@ function peekTable(key, table, meta, type) {
37
37
  let state;
38
38
  for (let i = 0; i < key.length; i++) {
39
39
  if (i) {
40
- t = hasOwn ? t[k] : (t[k] = {});
40
+ t = hasOwn ? t[k] : (t[k] = Object.create(null));
41
41
  m = (state = m[k]).c;
42
42
  if (type === 0 /* Type.DOTTED */ && (state.t === 1 /* Type.EXPLICIT */ || state.t === 2 /* Type.ARRAY */)) {
43
43
  return null;
@@ -53,17 +53,19 @@ function peekTable(key, table, meta, type) {
53
53
  return null;
54
54
  }
55
55
  if (!hasOwn) {
56
- if (k === '__proto__') {
56
+ let unsafe = k === '__proto__';
57
+ if (ctx.uk && (unsafe || k === 'constructor'))
58
+ return false;
59
+ if (unsafe) {
57
60
  Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
58
61
  Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
59
62
  }
60
63
  m[k] = {
61
64
  t: i < key.length - 1 && type === 2 /* Type.ARRAY */
62
- ? 3 /* Type.ARRAY_DOTTED */
63
- : type,
65
+ ? 3 /* Type.ARRAY_DOTTED */ : type,
64
66
  d: false,
65
67
  i: 0,
66
- c: {},
68
+ c: Object.create(null),
67
69
  };
68
70
  }
69
71
  }
@@ -77,8 +79,8 @@ function peekTable(key, table, meta, type) {
77
79
  state.d = true;
78
80
  t[k] = [];
79
81
  }
80
- t[k].push(t = {});
81
- state.c[state.i++] = (state = { t: 1 /* Type.EXPLICIT */, d: false, i: 0, c: {} });
82
+ t[k].push(t = Object.create(null));
83
+ state.c[state.i++] = (state = { t: 1 /* Type.EXPLICIT */, d: false, i: 0, c: Object.create(null) });
82
84
  }
83
85
  if (state.d) {
84
86
  // Redefining a table!
@@ -86,63 +88,77 @@ function peekTable(key, table, meta, type) {
86
88
  }
87
89
  state.d = true;
88
90
  if (type === 1 /* Type.EXPLICIT */) {
89
- t = hasOwn ? t[k] : (t[k] = {});
91
+ t = hasOwn ? t[k] : (t[k] = Object.create(null));
90
92
  }
91
93
  else if (type === 0 /* Type.DOTTED */ && hasOwn) {
92
94
  return null;
93
95
  }
94
96
  return [k, t, state.c];
95
97
  }
96
- export function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
97
- let res = {};
98
- let meta = {};
98
+ function validateTablePeek(ctx, peek, ptr) {
99
+ if (peek === null || ctx.uk === 2)
100
+ TomlError.x(peek === null
101
+ ? 'trying to redefine an already defined table or value'
102
+ : 'document contains an unsafe property', ctx, ptr);
103
+ }
104
+ export function parse(toml, options = {}) {
105
+ let ctx = {
106
+ s: toml,
107
+ p: 0,
108
+ d: options.maxDepth ?? 1000,
109
+ bi: options.integersAsBigInt ?? false,
110
+ ld: options.useLegacyDate ?? true,
111
+ uk: options.unsafeKeyBehaviour === 'throw' ? 2 : options.unsafeKeyBehaviour === 'drop' ? 1 : 0,
112
+ };
113
+ let res = Object.create(null);
114
+ let meta = Object.create(null);
115
+ let tmp;
116
+ let skipping = false;
99
117
  let tbl = res;
100
118
  let m = meta;
101
- for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
102
- if (toml[ptr] === '[') {
103
- let isTableArray = toml[++ptr] === '[';
104
- let k = parseKey(toml, ptr += +isTableArray, ']');
119
+ // BOM is allowed, skip.
120
+ // JS is UTF-16, so we have to check for the UTF-16 BOM instead of the UTF-8 BOM sequence!
121
+ if (toml.charCodeAt(0) === 0xfeff)
122
+ ctx.p++;
123
+ skipVoid(ctx);
124
+ while (ctx.p < toml.length) {
125
+ if (toml.charCodeAt(ctx.p) === 0x5b /* [ */) {
126
+ let isTableArray = toml.charCodeAt(++ctx.p) === 0x5b; /* [ */
127
+ tmp = ctx.p += +isTableArray;
128
+ skipping = false;
129
+ let k = parseKey(ctx, 0x5d /* ] */);
105
130
  if (isTableArray) {
106
- if (toml[k[1] - 1] !== ']') {
107
- throw new TomlError('expected end of table declaration', {
108
- toml: toml,
109
- ptr: k[1] - 1,
110
- });
131
+ if (toml.charCodeAt(ctx.p) !== 0x5d /* ] */) {
132
+ TomlError.x('expected end of table array declaration', ctx);
111
133
  }
112
- k[1]++;
134
+ ctx.p++;
113
135
  }
114
- let p = peekTable(k[0], res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */);
136
+ let p = peekTable(ctx, k, res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */);
115
137
  if (!p) {
116
- throw new TomlError('trying to redefine an already defined table or value', {
117
- toml: toml,
118
- ptr: ptr,
119
- });
138
+ validateTablePeek(ctx, p, tmp);
139
+ skipping = true;
140
+ }
141
+ else {
142
+ m = p[2];
143
+ tbl = p[1];
120
144
  }
121
- m = p[2];
122
- tbl = p[1];
123
- ptr = k[1];
124
145
  }
125
146
  else {
126
- let k = parseKey(toml, ptr);
127
- let p = peekTable(k[0], tbl, m, 0 /* Type.DOTTED */);
128
- if (!p) {
129
- throw new TomlError('trying to redefine an already defined table or value', {
130
- toml: toml,
131
- ptr: ptr,
132
- });
133
- }
134
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
135
- p[1][p[0]] = v[0];
136
- ptr = v[1];
147
+ tmp = ctx.p;
148
+ let k = parseKey(ctx);
149
+ let p = peekTable(ctx, k, tbl, m, 0 /* Type.DOTTED */);
150
+ if (!p && !skipping)
151
+ validateTablePeek(ctx, p, tmp);
152
+ skipVoid(ctx, true, true);
153
+ let v = extractValue(ctx, void 0);
154
+ if (p && !skipping)
155
+ p[1][p[0]] = v;
137
156
  }
138
- ptr = skipVoid(toml, ptr, true);
139
- if (toml[ptr] && toml[ptr] !== '\n' && toml[ptr] !== '\r') {
140
- throw new TomlError('each key-value declaration must be followed by an end-of-line', {
141
- toml: toml,
142
- ptr: ptr
143
- });
157
+ skipVoid(ctx, true);
158
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 0xa /* \n */ && (tmp !== 0xd /* \r */ || toml.charCodeAt(ctx.p + 1) !== 0xa /* \n */)) {
159
+ TomlError.x('each key-value declaration must be followed by an end-of-line', ctx);
144
160
  }
145
- ptr = skipVoid(toml, ptr);
161
+ skipVoid(ctx);
146
162
  }
147
163
  return res;
148
164
  }
@@ -25,155 +25,127 @@
25
25
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
26
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  */
28
- import { skipVoid } from './util.js';
29
- import { TomlDate } from './date.js';
30
28
  import { TomlError } from './error.js';
31
- let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
32
- let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
33
- let LEADING_ZERO = /^[+-]?0[0-9_]/;
34
- let ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
35
- let ESC_MAP = {
36
- b: '\b',
37
- t: '\t',
38
- n: '\n',
39
- f: '\f',
40
- r: '\r',
41
- e: '\x1b',
42
- '"': '"',
43
- '\\': '\\',
44
- };
45
- export function parseString(str, ptr = 0, endPtr = str.length) {
46
- let isLiteral = str[ptr] === '\'';
47
- let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
29
+ /** @internal */
30
+ export function parseString(ctx) {
31
+ let startPtr = ctx.p;
32
+ let c = ctx.s.charCodeAt(ctx.p++);
33
+ let first = c;
34
+ let isLiteral = c === 0x27; /* ' */
35
+ let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
48
36
  if (isMultiline) {
49
- endPtr -= 2;
50
- if (str[ptr += 2] === '\r')
51
- ptr++;
52
- if (str[ptr] === '\n')
53
- ptr++;
37
+ // Trim initial newline
38
+ if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 0xa /* \n */)
39
+ ctx.p++;
40
+ else if (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */)
41
+ ctx.p += 2;
54
42
  }
55
- let tmp = 0;
56
- let isEscape;
43
+ // For the record: it is not worth it to use a fast-path for literal strings using `indexOf`.
44
+ // Doing a char-by-char iteration ends up dispatching less instructions, for the same wall-clock runtime.
57
45
  let parsed = '';
58
- let sliceStart = ptr;
59
- while (ptr < endPtr - 1) {
60
- let c = str[ptr++];
61
- if (c === '\n' || (c === '\r' && str[ptr] === '\n')) {
62
- if (!isMultiline) {
63
- throw new TomlError('newlines are not allowed in strings', {
64
- toml: str,
65
- ptr: ptr - 1,
66
- });
46
+ let sliceStart = ctx.p;
47
+ // states:
48
+ // 0 - decoding
49
+ // 1 - decoding escape
50
+ // 2 - whitespace escape (no newline encountered yet, must fail on non-whitespace)
51
+ // 3 - whitespace escape (newline encountered, allowed to transition back to normal decode)
52
+ let state = 0;
53
+ for (; ctx.p < ctx.s.length; ctx.p++) {
54
+ c = ctx.s.charCodeAt(ctx.p);
55
+ // Deal with newlines first, since that simplifies control character checking and handling across all states
56
+ if (isMultiline && (c === 0xa /* \n */ || (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */))) {
57
+ state = state && 3;
58
+ }
59
+ // Control characters are banned in TOML, so we throw an error if we encounter them
60
+ else if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) {
61
+ TomlError.x('control characters are not allowed in strings', ctx);
62
+ }
63
+ // The string might terminate while we're parsing through a newline escape.
64
+ // It must have encountered a newline; otherwise, it'll simply fail in another branch.
65
+ else if ((!state || state === 3) && c === first && (!isMultiline || (ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first))) {
66
+ if (isMultiline) {
67
+ // If the string ends with 4-5 quotes, then the first 1-2 are part of the string
68
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
69
+ ctx.p++;
70
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
71
+ ctx.p++;
67
72
  }
73
+ // If we're in a newline escape still, then there's nothing to add.
74
+ if (!state) {
75
+ // Avoid a useless concat operation if the string can be used as-is.
76
+ let s = ctx.s.slice(sliceStart, ctx.p);
77
+ parsed = parsed ? parsed + s : s;
78
+ }
79
+ ctx.p += isMultiline ? 3 : 1;
80
+ return parsed;
68
81
  }
69
- else if ((c < '\x20' && c !== '\t') || c === '\x7f') {
70
- throw new TomlError('control characters are not allowed in strings', {
71
- toml: str,
72
- ptr: ptr - 1,
73
- });
82
+ // Baseline state; keep moving forward unless an escape sequence starts
83
+ else if (!state) {
84
+ if (!isLiteral && c === 0x5c /* \ */) {
85
+ parsed += ctx.s.slice(sliceStart, (sliceStart = ctx.p));
86
+ state = 1;
87
+ }
74
88
  }
75
- if (isEscape) {
76
- isEscape = false;
77
- if (c === 'x' || c === 'u' || c === 'U') {
78
- // Unicode escape
79
- let code = str.slice(ptr, (ptr += (c === 'x' ? 2 : c === 'u' ? 4 : 8)));
80
- if (!ESCAPE_REGEX.test(code)) {
81
- throw new TomlError('invalid unicode escape', {
82
- toml: str,
83
- ptr: tmp,
84
- });
89
+ else if (state === 1) {
90
+ if (c === 0x78 /* x */ || c === 0x75 /* u */ || c === 0x55 /* U */) { // Unicode escape
91
+ let errPtr = ctx.p++ - 1;
92
+ let value = 0;
93
+ let len = c === 0x78 /* x */ ? 2 : c === 0x75 /* u */ ? 4 : 8;
94
+ for (let j = 0; j < len; j++, ctx.p++) {
95
+ let hex = ctx.s.charCodeAt(ctx.p);
96
+ let digit =
97
+ /* 0-9 */ hex >= 0x30 && hex <= 0x39 ? hex - 0x30 :
98
+ /* A-F */ hex >= 0x41 && hex <= 0x46 ? hex - 0x41 + 10 :
99
+ /* a-f */ hex >= 0x61 && hex <= 0x66 ? hex - 0x61 + 10 : -1;
100
+ if (digit < 0)
101
+ TomlError.x('invalid non-hex character in unicode escape', ctx);
102
+ value = (value << 4) | digit;
85
103
  }
86
- try {
87
- parsed += String.fromCodePoint(parseInt(code, 16));
88
- }
89
- catch {
90
- throw new TomlError('invalid unicode escape', {
91
- toml: str,
92
- ptr: tmp,
93
- });
94
- }
95
- }
96
- else if (isMultiline && (c === '\n' || c === ' ' || c === '\t' || c === '\r')) {
97
- // Multiline escape
98
- ptr = skipVoid(str, ptr - 1, true);
99
- if (str[ptr] !== '\n' && str[ptr] !== '\r') {
100
- throw new TomlError('invalid escape: only line-ending whitespace may be escaped', {
101
- toml: str,
102
- ptr: tmp,
103
- });
104
+ // Because JS does bitwise on signed 32bit integers, all 0xfzzzzzzz values are actually seen as negative
105
+ if (value < 0 || value > 0x10ffff || (value >= 0xd800 && value <= 0xdfff)) {
106
+ TomlError.x('invalid unicode escape', ctx, errPtr);
104
107
  }
105
- ptr = skipVoid(str, ptr);
108
+ parsed += String.fromCodePoint(value);
109
+ sliceStart = ctx.p--;
110
+ state = 0;
106
111
  }
107
- else if (c in ESC_MAP) {
108
- // Classic escape
109
- parsed += ESC_MAP[c];
112
+ // Newline escape sequence. We only need to care about spaces and tabs; newlines are dealt with earlier
113
+ else if (isMultiline && (c === 0x20 || c === 0x9 /* \t */)) {
114
+ state = 2;
110
115
  }
116
+ // Basic escape sequence
111
117
  else {
112
- throw new TomlError('unrecognized escape sequence', {
113
- toml: str,
114
- ptr: tmp,
115
- });
118
+ if (c === 0x62 /* b */)
119
+ parsed += '\b';
120
+ else if (c === 0x74 /* t */)
121
+ parsed += '\t';
122
+ else if (c === 0x6e /* n */)
123
+ parsed += '\n';
124
+ else if (c === 0x66 /* f */)
125
+ parsed += '\f';
126
+ else if (c === 0x72 /* r */)
127
+ parsed += '\r';
128
+ else if (c === 0x65 /* e */)
129
+ parsed += '\x1b';
130
+ else if (c === 0x22 /* " */)
131
+ parsed += '"';
132
+ else if (c === 0x5c /* \ */)
133
+ parsed += '\\';
134
+ else
135
+ TomlError.x('unrecognised escape sequence', ctx);
136
+ sliceStart = ctx.p + 1;
137
+ state = 0;
116
138
  }
117
- sliceStart = ptr;
118
139
  }
119
- else if (!isLiteral && c === '\\') {
120
- tmp = ptr - 1;
121
- isEscape = true;
122
- parsed += str.slice(sliceStart, tmp);
140
+ // Newline escape continuation: keep moving forward until the first non-whitespace char
141
+ else if (c !== 0x20 && c !== 0x9 /* \t */) {
142
+ if (state === 2)
143
+ TomlError.x('invalid escape: only line-ending whitespace may be escaped', ctx, sliceStart);
144
+ // State cannot be zero, or we'd have branched earlier already.
145
+ // If it's a backslash, immediately transition to the escape state so it can be processed.
146
+ state = !isLiteral && c === 0x5c /* \ */ ? 1 : 0;
147
+ sliceStart = ctx.p;
123
148
  }
124
149
  }
125
- return parsed + str.slice(sliceStart, endPtr - 1);
126
- }
127
- export function parseValue(value, toml, ptr, integersAsBigInt) {
128
- // Constant values
129
- if (value === 'true')
130
- return true;
131
- if (value === 'false')
132
- return false;
133
- if (value === '-inf')
134
- return -Infinity;
135
- if (value === 'inf' || value === '+inf')
136
- return Infinity;
137
- if (value === 'nan' || value === '+nan' || value === '-nan')
138
- return NaN;
139
- // Avoid FP representation of -0
140
- if (value === '-0')
141
- return integersAsBigInt ? 0n : 0;
142
- // Numbers
143
- let isInt = INT_REGEX.test(value);
144
- if (isInt || FLOAT_REGEX.test(value)) {
145
- if (LEADING_ZERO.test(value)) {
146
- throw new TomlError('leading zeroes are not allowed', {
147
- toml: toml,
148
- ptr: ptr,
149
- });
150
- }
151
- value = value.replace(/_/g, '');
152
- let numeric = +value;
153
- if (isNaN(numeric)) {
154
- throw new TomlError('invalid number', {
155
- toml: toml,
156
- ptr: ptr,
157
- });
158
- }
159
- if (isInt) {
160
- if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
161
- throw new TomlError('integer value cannot be represented losslessly', {
162
- toml: toml,
163
- ptr: ptr,
164
- });
165
- }
166
- if (isInt || integersAsBigInt === true)
167
- numeric = BigInt(value);
168
- }
169
- return numeric;
170
- }
171
- const date = new TomlDate(value);
172
- if (!date.isValid()) {
173
- throw new TomlError('invalid value', {
174
- toml: toml,
175
- ptr: ptr,
176
- });
177
- }
178
- return date;
150
+ TomlError.x('unfinished string', ctx, startPtr);
179
151
  }