@isdk/json-repair 0.1.3 → 0.2.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.
Files changed (46) hide show
  1. package/README.cn.md +126 -7
  2. package/README.md +148 -7
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.cts +571 -4
  5. package/dist/index.d.ts +571 -4
  6. package/dist/index.js +1 -1
  7. package/docs/README.md +148 -7
  8. package/docs/_media/README.cn.md +126 -7
  9. package/docs/classes/RepairParser.md +69 -3
  10. package/docs/classes/SchemaWalker.md +9 -9
  11. package/docs/functions/compareScores.md +32 -0
  12. package/docs/functions/discardedText.md +42 -0
  13. package/docs/functions/expectsArrayRoot.md +23 -0
  14. package/docs/functions/findImplicitRecordRegion.md +32 -0
  15. package/docs/functions/jsonRepair.md +4 -3
  16. package/docs/functions/jsonRepairResult.md +50 -0
  17. package/docs/functions/locateJsonCandidates.md +33 -0
  18. package/docs/functions/looksLikeSchemaEcho.md +29 -0
  19. package/docs/functions/renderValidatorErrors.md +32 -0
  20. package/docs/functions/scoreCandidate.md +45 -0
  21. package/docs/functions/validateValue.md +38 -0
  22. package/docs/globals.md +19 -0
  23. package/docs/interfaces/CandidateScore.md +63 -0
  24. package/docs/interfaces/JsonCandidate.md +71 -0
  25. package/docs/interfaces/LocatedJson.md +48 -0
  26. package/docs/interfaces/RepairOptions.md +210 -5
  27. package/docs/interfaces/RepairResult.md +58 -0
  28. package/docs/interfaces/ValidationError.md +27 -0
  29. package/docs/type-aliases/CommentStyle.md +13 -0
  30. package/docs/type-aliases/EscapeMode.md +13 -0
  31. package/docs/type-aliases/JSONPath.md +1 -1
  32. package/docs/type-aliases/LiteralDialect.md +13 -0
  33. package/docs/type-aliases/RepairFlag.md +11 -0
  34. package/package.json +26 -4
  35. package/.prettierignore +0 -12
  36. package/.prettierrc +0 -8
  37. package/.versionrc +0 -36
  38. package/CHANGELOG.md +0 -34
  39. package/TODO +0 -0
  40. package/eslint.config.mjs +0 -65
  41. package/setupVitest.mjs +0 -15
  42. package/tsconfig.json +0 -20
  43. package/tsconfig.release.json +0 -21
  44. package/tsup.config.ts +0 -38
  45. package/typedoc.config.cjs +0 -9
  46. package/vite.config.mjs +0 -21
@@ -0,0 +1,48 @@
1
+ [**@isdk/json-repair**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/json-repair](../globals.md) / LocatedJson
6
+
7
+ # Interface: LocatedJson
8
+
9
+ Defined in: [types.ts:339](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L339)
10
+
11
+ A JSON region located inside a larger piece of text, given as offsets into that text so
12
+ the caller can line it up against what the model actually returned.
13
+
14
+ ## Extended by
15
+
16
+ - [`JsonCandidate`](JsonCandidate.md)
17
+
18
+ ## Properties
19
+
20
+ ### end
21
+
22
+ > **end**: `number`
23
+
24
+ Defined in: [types.ts:341](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L341)
25
+
26
+ ***
27
+
28
+ ### flags
29
+
30
+ > **flags**: [`RepairFlag`](../type-aliases/RepairFlag.md)[]
31
+
32
+ Defined in: [types.ts:343](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L343)
33
+
34
+ ***
35
+
36
+ ### start
37
+
38
+ > **start**: `number`
39
+
40
+ Defined in: [types.ts:340](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L340)
41
+
42
+ ***
43
+
44
+ ### text
45
+
46
+ > **text**: `string`
47
+
48
+ Defined in: [types.ts:342](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L342)
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Interface: RepairOptions
8
8
 
9
- Defined in: [types.ts:4](https://github.com/isdk/json-repair.js/blob/bd999430e5a6ec831a040451c76463ff7791a09a/src/types.ts#L4)
9
+ Defined in: [types.ts:4](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L4)
10
10
 
11
11
  Options for the JSON repair process.
12
12
 
@@ -16,7 +16,7 @@ Options for the JSON repair process.
16
16
 
17
17
  > `optional` **additionalProperties?**: `"keep"` \| `"remove"`
18
18
 
19
- Defined in: [types.ts:70](https://github.com/isdk/json-repair.js/blob/bd999430e5a6ec831a040451c76463ff7791a09a/src/types.ts#L70)
19
+ Defined in: [types.ts:76](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L76)
20
20
 
21
21
  Defines how to handle properties not defined in the Schema.
22
22
 
@@ -33,7 +33,7 @@ which is respected on its own when validating incoming keys.
33
33
 
34
34
  > `optional` **coerceTypes?**: `boolean`
35
35
 
36
- Defined in: [types.ts:58](https://github.com/isdk/json-repair.js/blob/bd999430e5a6ec831a040451c76463ff7791a09a/src/types.ts#L58)
36
+ Defined in: [types.ts:64](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L64)
37
37
 
38
38
  Whether to coerce values to the type the Schema declares. Enabled by default.
39
39
 
@@ -50,13 +50,91 @@ parsed to, so a leading zero survives: `{ id: 01234 }` becomes `"01234"`.
50
50
  `null` and structures (`{}` / `[]`) are never stringified - `"null"` and
51
51
  `"[object Object]"` are not what a `type: 'string'` declaration asks for.
52
52
 
53
+ A coercion that keeps part of a value and gives up the text around it says so:
54
+ `coerced-text-dropped`. A unit given up that way (`Approx. USD`) is the option doing its
55
+ job; text long enough to read as a sentence is listed in [RepairResult.discarded](RepairResult.md#discarded)
56
+ too, because greedy capture can run a value into prose the model wrote after it
57
+ (`age: 30\n\nHope this helps!}` -> `30`) and the sentence would otherwise leave no trace.
58
+
59
+ ***
60
+
61
+ ### comments?
62
+
63
+ > `optional` **comments?**: `boolean` \| [`CommentStyle`](../type-aliases/CommentStyle.md)[]
64
+
65
+ Defined in: [types.ts:115](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L115)
66
+
67
+ Which comment styles are skipped, and only where a member is expected: between two
68
+ fields, after `{` or `[`, before a closing bracket, and after a completed value.
69
+
70
+ Strict JSON has no comments, so this is off by default - skipping one consumes
71
+ characters, and only the caller knows which style its models write. Open the style you
72
+ actually see.
73
+
74
+ - `'line'` - `//` to the end of the line (JSONC, and most JavaScript-trained models).
75
+ - `'block'` - `/* ... */`, and only when it is closed: an unterminated `/*` stays text.
76
+ - `'hash'` - `#` to the end of the line (Python-trained models).
77
+ - `true` - all three. `false` or `[]` - none, which is the default.
78
+
79
+ A style is never recognised inside a string or inside a bare token, so
80
+ `url: https://x.com/a`, `issue: #123` and `"#ff0000"` survive every setting. With the
81
+ default, a comment written between two fields ends up inside one of them; turning the
82
+ switch on is what prevents that. Emits `comment-skipped`.
83
+
84
+ ***
85
+
86
+ ### dangling?
87
+
88
+ > `optional` **dangling?**: `boolean`
89
+
90
+ Defined in: [types.ts:175](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L175)
91
+
92
+ Whether a key or separator the output was cut off at is dropped or kept.
93
+
94
+ `{"a": 1, "b`: `true` (default) gives `{ a: 1 }`. `false` gives `{ a: '1, "b' }` - the
95
+ fragment written into a field that was already correct, which is exactly what this option
96
+ exists to prevent. Dropping is the default, and the dropped text is listed in
97
+ [RepairResult.discarded](RepairResult.md#discarded) and flagged `dangling-dropped`, so nothing disappears
98
+ without a trace. Only the fragment is dropped: the container closes and a record written
99
+ after it is still read, so `{"a": 1, "b"} {"c": 2}` becomes `[{ a: 1 }, { c: 2 }]`. A
100
+ broken key with a value after it is syntax to repair, not a fragment, and is left alone.
101
+
102
+ ***
103
+
104
+ ### escapes?
105
+
106
+ > `optional` **escapes?**: [`EscapeMode`](../type-aliases/EscapeMode.md)
107
+
108
+ Defined in: [types.ts:162](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L162)
109
+
110
+ How much the parser trusts the backslashes a document writes.
111
+
112
+ The three settings read as one axis - how far the document's escapes are escapes:
113
+
114
+ - `'json5'` (default): JSON's own escapes decode, the JSON5-style `\xNN` decodes to the
115
+ character it names, and an escape of a character that needs none is unwrapped
116
+ (`"\$10"` -> `$10`, `"C:\Users"` -> `C:Users`) the way JSON5 reads one.
117
+ - `'json'`: only the escapes JSON defines decode. Anything else stays exactly as the
118
+ document wrote it, backslash included (`"C:\Users"` -> `C:\Users`), so markdown and
119
+ LaTeX punctuation keeps its backslashes and a path keeps its separators.
120
+ - `'raw'`: nothing decodes - a backslash is content. `"C:\temp"` is a path, not a tab,
121
+ and `"\frac{a}{b}"` is a LaTeX command, not a form feed. The setting is honest about
122
+ what it costs: it applies to escapes JSON defines too, so `"a\nb"` stays two characters
123
+ and a value can no longer carry a newline. Use it when the values are paths, regular
124
+ expressions or markup rather than prose.
125
+
126
+ A backslash is structural in every setting: it always keeps the character behind it inside
127
+ the string, so a value is never cut where the model escaped something. An incomplete hex
128
+ escape (`\xg`, `\uZZ`) decodes nothing in every setting and stays as written.
129
+ Whichever is chosen, an escape strict JSON would reject is reported as `invalid-escape`.
130
+
53
131
  ***
54
132
 
55
133
  ### keyMatching?
56
134
 
57
135
  > `optional` **keyMatching?**: `boolean` \| ((`key`, `properties`) => `string` \| `undefined`)
58
136
 
59
- Defined in: [types.ts:21](https://github.com/isdk/json-repair.js/blob/bd999430e5a6ec831a040451c76463ff7791a09a/src/types.ts#L21)
137
+ Defined in: [types.ts:21](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L21)
60
138
 
61
139
  Fuzzy matching of property keys against the Schema's declared `properties`.
62
140
 
@@ -75,11 +153,96 @@ When you reuse a `SchemaWalker`, pass this option to `SchemaWalker.create()`.
75
153
 
76
154
  ***
77
155
 
156
+ ### literals?
157
+
158
+ > `optional` **literals?**: `boolean` \| [`LiteralDialect`](../type-aliases/LiteralDialect.md)[]
159
+
160
+ Defined in: [types.ts:138](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L138)
161
+
162
+ Which bare tokens (tokens with no quotes around them) are read as a literal of another
163
+ language.
164
+
165
+ `ok: True` means `true`, not the word `True`: the token carries no quotes, so it is not a
166
+ string in any JSON dialect either - reading it as a literal is reading the model, while
167
+ turning it into `'True'` invents a value.
168
+
169
+ - `'python'` - `True` -> `true`, `False` -> `false`, `None` -> `null`.
170
+ - `'js'` - `undefined` -> `null`. `NaN` is left as the text it spells: no JSON number
171
+ can carry it, so the reported errors point at the field instead of the parser inventing
172
+ a value that cannot be serialised.
173
+ - `true` - both dialects, which is the default. `false` or `[]` - neither: the token
174
+ becomes the string it spells.
175
+
176
+ A model trained on JavaScript does not write `None` and a Python-trained one rarely writes
177
+ `undefined`, so the list is how you say which of them can occur. It never applies to a
178
+ quoted `"True"` (always a string), never to a key, and never to a path whose Schema names
179
+ a type - there [coerceTypes](#coercetypes) decides, and it already reads `True` as `true`.
180
+ Emits `non-json-literal`.
181
+
182
+ ***
183
+
184
+ ### locate?
185
+
186
+ > `optional` **locate?**: `boolean`
187
+
188
+ Defined in: [types.ts:201](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L201)
189
+
190
+ Whether to look for the JSON inside the input text first.
191
+
192
+ LLM output is text, not a document: the JSON often sits inside a Markdown fence and
193
+ between sentences. With `true` (the default) the input is scanned for
194
+ quote-aware, escape-aware, bracket-balanced JSON regions and the best one is repaired;
195
+ prose and fences around it are dropped and reported. With `false` the whole string is
196
+ parsed as if it were already a JSON document (the behaviour up to 0.1.x).
197
+
198
+ Input that already parses as JSON is never touched either way.
199
+
200
+ ***
201
+
202
+ ### onDiscard?
203
+
204
+ > `optional` **onDiscard?**: `"throw"` \| `"report"` \| `"ignore"`
205
+
206
+ Defined in: [types.ts:230](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L230)
207
+
208
+ What to do with text the repair dropped on the floor (prose, fences, losing fragments).
209
+
210
+ - `'report'` (default): drop it, but list it in `RepairResult.discarded`.
211
+ - `'throw'`: refuse the input - a caller that cannot afford to lose content should not
212
+ accept a repair that discards any.
213
+ - `'ignore'`: drop it silently.
214
+
215
+ ***
216
+
217
+ ### onMultiple?
218
+
219
+ > `optional` **onMultiple?**: `"best"` \| `"last"` \| `"first"` \| `"throw"`
220
+
221
+ Defined in: [types.ts:220](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L220)
222
+
223
+ How to choose when the input contains more than one JSON fragment.
224
+
225
+ - `'best'` (default): rank the fragments by how well they fit the Schema - fewer
226
+ validation errors, more `required` fields carrying real values, more declared fields,
227
+ fewer Schema keywords in the answer - and take the winner. A tie is decided by position,
228
+ last first, because a model usually drafts before it answers; the tie is then reported as
229
+ `ambiguous-candidates` rather than hidden. An extra key the Schema never named is not held
230
+ against a fragment ([CandidateScore.undeclaredKeys](CandidateScore.md#undeclaredkeys) reports it); only an answer built
231
+ out of the Schema itself is.
232
+ - `'last'` / `'first'`: take the position regardless of how well the fragment fits. The
233
+ Schema errors of the chosen fragment are still reported.
234
+ - `'throw'`: reject the input outright and list the candidates with their scores.
235
+
236
+ Without a Schema the ranking has no information to work with, so it collapses to the
237
+ position rule (the last fragment).
238
+
239
+ ***
240
+
78
241
  ### stringCaptureStrategy?
79
242
 
80
243
  > `optional` **stringCaptureStrategy?**: `"conservative"` \| `"aggressive"`
81
244
 
82
- Defined in: [types.ts:40](https://github.com/isdk/json-repair.js/blob/bd999430e5a6ec831a040451c76463ff7791a09a/src/types.ts#L40)
245
+ Defined in: [types.ts:40](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L40)
83
246
 
84
247
  Strategy for greedy string capture when the strict JSON path failed for a value.
85
248
 
@@ -94,3 +257,45 @@ when the document left it unquoted (`{ Capital: Berlin, Official language: Itali
94
257
  because it can only be recognised from the declaration.
95
258
  Neither strategy affects values that were parsed by the strict JSON path; the
96
259
  boundary rules described in the README apply to those unchanged.
260
+
261
+ ***
262
+
263
+ ### unescapedQuotes?
264
+
265
+ > `optional` **unescapedQuotes?**: `"keep"` \| `"declared"` \| `"lookahead"`
266
+
267
+ Defined in: [types.ts:95](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L95)
268
+
269
+ Where a quoted value ends when the model left one of its quotes unescaped -
270
+ `{"t": "The "Best" Paper", "y": 2020}`.
271
+
272
+ - `'keep'` (default) - what the document spells, delimiters included:
273
+ `t = '"The "Best" Paper"'`. Nothing is inferred, which is the rule the README section
274
+ "How Property Boundaries Are Detected" describes.
275
+ - `'declared'` - the first quote after which a member the Schema declares begins:
276
+ `t = 'The "Best" Paper'`. The Schema named that member, so the boundary is known rather
277
+ than guessed - and where the Schema names nothing at that level, nothing is inferred
278
+ either.
279
+ - `'lookahead'` - the same rule judged by the shape of the text alone, for documents with
280
+ no Schema. It reads more, and guesses more.
281
+
282
+ A document that `JSON.parse` accepts is never affected: the strict parse is tried first,
283
+ and only a quoted value it could not close comes here. Emits `unescaped-quote-inferred`.
284
+
285
+ ***
286
+
287
+ ### wrapArrays?
288
+
289
+ > `optional` **wrapArrays?**: `boolean`
290
+
291
+ Defined in: [types.ts:188](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L188)
292
+
293
+ Whether a record the Schema expects inside a list is read as one item: a single object
294
+ under a root `array` becomes `[object]`, and sibling records written side by side
295
+ (`{...} {...}`, or the same without braces) become the items of that list.
296
+
297
+ Enabled by default - the structure was declared by the Schema, so it is not a guess.
298
+ Set it to `false` to keep the value exactly as the document wrote it and let the
299
+ reported `errors` say what is missing. The cost: the record is no longer looked up
300
+ against `items`, so its own keys lose their Schema guide - coercion stops applying and
301
+ a value can run into the next key. That is why the default is `true`.
@@ -0,0 +1,58 @@
1
+ [**@isdk/json-repair**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/json-repair](../globals.md) / RepairResult
6
+
7
+ # Interface: RepairResult\<T\>
8
+
9
+ Defined in: [types.ts:365](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L365)
10
+
11
+ Everything a repair produced: the value, what was noticed about the input, what still
12
+ fails against the Schema, and what was discarded to get there.
13
+
14
+ ## Type Parameters
15
+
16
+ ### T
17
+
18
+ `T` = `any`
19
+
20
+ ## Properties
21
+
22
+ ### candidates
23
+
24
+ > **candidates**: [`JsonCandidate`](JsonCandidate.md)[]
25
+
26
+ Defined in: [types.ts:369](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L369)
27
+
28
+ ***
29
+
30
+ ### discarded
31
+
32
+ > **discarded**: `string`[]
33
+
34
+ Defined in: [types.ts:370](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L370)
35
+
36
+ ***
37
+
38
+ ### errors
39
+
40
+ > **errors**: [`ValidationError`](ValidationError.md)[]
41
+
42
+ Defined in: [types.ts:368](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L368)
43
+
44
+ ***
45
+
46
+ ### flags
47
+
48
+ > **flags**: [`RepairFlag`](../type-aliases/RepairFlag.md)[]
49
+
50
+ Defined in: [types.ts:367](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L367)
51
+
52
+ ***
53
+
54
+ ### value
55
+
56
+ > **value**: `T`
57
+
58
+ Defined in: [types.ts:366](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L366)
@@ -0,0 +1,27 @@
1
+ [**@isdk/json-repair**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/json-repair](../globals.md) / ValidationError
6
+
7
+ # Interface: ValidationError
8
+
9
+ Defined in: [types.ts:356](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L356)
10
+
11
+ A JSON Schema violation, located by path so it can be handed back to a model verbatim.
12
+
13
+ ## Properties
14
+
15
+ ### message
16
+
17
+ > **message**: `string`
18
+
19
+ Defined in: [types.ts:358](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L358)
20
+
21
+ ***
22
+
23
+ ### path
24
+
25
+ > **path**: [`JSONPath`](../type-aliases/JSONPath.md)
26
+
27
+ Defined in: [types.ts:357](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L357)
@@ -0,0 +1,13 @@
1
+ [**@isdk/json-repair**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/json-repair](../globals.md) / CommentStyle
6
+
7
+ # Type Alias: CommentStyle
8
+
9
+ > **CommentStyle** = `"line"` \| `"block"` \| `"hash"`
10
+
11
+ Defined in: [types.ts:257](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L257)
12
+
13
+ A comment style. See [RepairOptions.comments](../interfaces/RepairOptions.md#comments).
@@ -0,0 +1,13 @@
1
+ [**@isdk/json-repair**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/json-repair](../globals.md) / EscapeMode
6
+
7
+ # Type Alias: EscapeMode
8
+
9
+ > **EscapeMode** = `"json5"` \| `"json"` \| `"raw"`
10
+
11
+ Defined in: [types.ts:263](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L263)
12
+
13
+ How much a backslash is trusted as an escape. See [RepairOptions.escapes](../interfaces/RepairOptions.md#escapes).
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **JSONPath** = (`string` \| `number`)[]
10
10
 
11
- Defined in: [types.ts:77](https://github.com/isdk/json-repair.js/blob/bd999430e5a6ec831a040451c76463ff7791a09a/src/types.ts#L77)
11
+ Defined in: [types.ts:237](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L237)
12
12
 
13
13
  Represents the current path in a JSON structure.
14
14
  A list of strings (keys) and numbers (indices).
@@ -0,0 +1,13 @@
1
+ [**@isdk/json-repair**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/json-repair](../globals.md) / LiteralDialect
6
+
7
+ # Type Alias: LiteralDialect
8
+
9
+ > **LiteralDialect** = `"js"` \| `"python"`
10
+
11
+ Defined in: [types.ts:260](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L260)
12
+
13
+ A language whose bare-token literals a model may write. See [RepairOptions.literals](../interfaces/RepairOptions.md#literals).
@@ -0,0 +1,11 @@
1
+ [**@isdk/json-repair**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/json-repair](../globals.md) / RepairFlag
6
+
7
+ # Type Alias: RepairFlag
8
+
9
+ > **RepairFlag** = `"markdown-fence"` \| `"prose-prefix"` \| `"trailing-chatter"` \| `"implicit-structure"` \| `"truncated-candidate"` \| `"sibling-objects-merged"` \| `"extra-fragments-dropped"` \| `"duplicate-candidates"` \| `"ambiguous-candidates"` \| `"empty-required"` \| `"schema-echo-detected"` \| `"unescaped-quote-inferred"` \| `"comment-skipped"` \| `"comment-in-value"` \| `"non-json-literal"` \| `"invalid-escape"` \| `"dangling-dropped"` \| `"unparsed-tail"` \| `"coerced-text-dropped"` \| `"nesting-limited"`
10
+
11
+ Defined in: [types.ts:265](https://github.com/isdk/json-repair.js/blob/5dd9e8689f96f00064dc6c6f8343ca1fd8216d98/src/types.ts#L265)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isdk/json-repair",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "A powerful, schema-guided JSON repair library for fixing broken JSON generated by LLMs, featuring semantic coercion and fuzzy matching.",
5
5
  "keywords": [
6
6
  "json",
@@ -24,11 +24,22 @@
24
24
  },
25
25
  "bugs": "https://github.com/@isdk/json-repair.js/issues",
26
26
  "license": "MIT",
27
- "main": "dist/index.js",
28
- "types": "dist/index.d.ts",
29
27
  "type": "module",
28
+ "main": "./dist/index.cjs",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
30
31
  "exports": {
31
- ".": "./dist/index.js"
32
+ ".": {
33
+ "import": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ },
37
+ "require": {
38
+ "types": "./dist/index.d.cts",
39
+ "default": "./dist/index.cjs"
40
+ }
41
+ },
42
+ "./package.json": "./package.json"
32
43
  },
33
44
  "dependencies": {
34
45
  "@apidevtools/json-schema-ref-parser": "^15.1.3",
@@ -43,6 +54,7 @@
43
54
  "eslint-config-prettier": "^10.1.8",
44
55
  "eslint-plugin-tsdoc": "^0.5.0",
45
56
  "prettier": "^3.8.1",
57
+ "prettier-plugin-markdown-table-layout": "^0.2.1",
46
58
  "terser": "^5.46.0",
47
59
  "tsup": "^8.5.1",
48
60
  "tsx": "^4.21.0",
@@ -53,6 +65,16 @@
53
65
  "vite-tsconfig-paths": "^6.0.5",
54
66
  "vitest": "^4.0.18"
55
67
  },
68
+ "files": [
69
+ "dist",
70
+ "docs",
71
+ "README.cn.md",
72
+ "LICENSE-MIT"
73
+ ],
74
+ "engines": {
75
+ "node": ">=20.19"
76
+ },
77
+ "sideEffects": false,
56
78
  "scripts": {
57
79
  "build-fast": "tsup",
58
80
  "build": "pnpm run build-fast --dts-resolve --dts && pnpm run doc:md",
package/.prettierignore DELETED
@@ -1,12 +0,0 @@
1
- node_modules
2
- dist
3
- web
4
- docs
5
- .cache
6
-
7
- # 由 commit-and-tag-version 生成
8
- CHANGELOG.md
9
-
10
- # 本地编辑器配置 / 包管理器配置
11
- .vscode
12
- .npmrc
package/.prettierrc DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "singleQuote": true,
3
- "arrowParens": "always",
4
- "semi": false,
5
- "bracketSpacing": true,
6
- "trailingComma": "es5",
7
- "printWidth": 80
8
- }
package/.versionrc DELETED
@@ -1,36 +0,0 @@
1
- {
2
- "types": [
3
- {
4
- "type": "feat",
5
- "section": "Features"
6
- },
7
- {
8
- "type": "fix",
9
- "section": "Bug Fixes"
10
- },
11
- {
12
- "type": "chore",
13
- "hidden": true
14
- },
15
- {
16
- "type": "docs",
17
- "hidden": true
18
- },
19
- {
20
- "type": "style",
21
- "hidden": true
22
- },
23
- {
24
- "type": "refactor",
25
- "section": "Refactor"
26
- },
27
- {
28
- "type": "perf",
29
- "section": "Performance"
30
- },
31
- {
32
- "type": "test",
33
- "hidden": true
34
- }
35
- ]
36
- }
package/CHANGELOG.md DELETED
@@ -1,34 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
-
5
- ## [0.1.3](https://github.com///compare/v0.1.2...v0.1.3) (2026-11-30)
6
-
7
- ### Features
8
-
9
- * wire up keyMatching, additionalProperties and stringCaptureStrategy ([3aea142](https://github.com///commit/3aea14276d07fc71ad86f4d26d768f071b1ee21c))
10
-
11
- ### Bug Fixes
12
-
13
- * honour Schema-declared types that the parser used to ignore ([bd99943](https://github.com///commit/bd999430e5a6ec831a040451c76463ff7791a09a))
14
- * keep clean parses and recognize quoted keys containing whitespace ([fbe4973](https://github.com///commit/fbe49736f3862b38354f93edf3dee294dbc2ed1e))
15
- * never touch the prototype chain and dereference a copy of the Schema ([681d40f](https://github.com///commit/681d40f72400a92a50431dd5576db64ef7f1073c))
16
- * parse scientific notation and stop a number at the end of the literal ([49ac3f4](https://github.com///commit/49ac3f403ff4bd148e118dd8fa506af1f3eec264))
17
- * recognise Schema-declared multi-word keys in unquoted documents ([59c6d36](https://github.com///commit/59c6d36037a5cf1865954685d9201a03bb3231c6))
18
- * take the first numeric token when coercing a noisy number ([d3b5f1b](https://github.com///commit/d3b5f1be9194cc880aea62ac3cdbb40d14ed2d29))
19
- * use hasOwnProperty.call for the duplicate-key check ([e575794](https://github.com///commit/e575794cf3a652c9a872ea13f965453a797ddef5))
20
-
21
- ## [0.1.2](https://github.com/isdk/json-repair.js/compare/v0.1.1...v0.1.2) (2026-01-30)
22
-
23
-
24
- ### Features
25
-
26
- * support balanced delimiter tracking in greedy capture ([51ba9c9](https://github.com/isdk/json-repair.js/commit/51ba9c939ae687b9da4b8574f2af0af0f31a3c0e))
27
-
28
- ## 0.1.1 (2026-01-30)
29
-
30
-
31
- ### Features
32
-
33
- * initial implementation of schema-guided json-repair with fuzzy matching and semantic coercion ([0b5c61d](https://github.com/isdk/json-repair.js/commit/0b5c61d4f059ddcdc6b47498f3bb4cfbb905409d))
34
- * support JSON repair with missing or empty schema ([285873c](https://github.com/isdk/json-repair.js/commit/285873c5a6c2afa891c3cbea3296f13e2b11a4d0))
package/TODO DELETED
File without changes