json-rescue 0.0.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/PROPOSAL.md ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # json-rescue
2
+
3
+ **Don’t just parse. Rescue it.**
4
+
5
+
6
+ ## 1. Overview
7
+
8
+ ### 1.1 Project Introduction
9
+
10
+ `json-rescue` is a TypeScript library built to **extract**, **repair**, and **parse** JSON from messy real-world text — including (but not limited to) LLM outputs. It is designed to be **deterministic**, **transparent** (repair reports), and **dependency-free**.
11
+
12
+ | Item | Value |
13
+ |------|-------|
14
+ | Package Name | `json-rescue` |
15
+ | Target Version | 0.1.0 (Initial public release) |
16
+ | License | MIT |
17
+ | Dependencies | Zero Dependency |
18
+ | Primary Goal | Recover strict JSON from mixed / malformed text safely |
19
+
20
+ ### 1.2 Current Features (Planned for Initial Releases)
21
+
22
+ - ✅ Extract JSON from Markdown code blocks (```json … ```)
23
+ - ✅ Extract JSON from plain text using balanced braces / brackets
24
+ - ✅ Auto-repair (trailing commas, comments, smart quotes; more planned)
25
+ - ✅ TypeScript generics support
26
+ - ✅ Multiple JSON extraction (`mode: 'all'`)
27
+ - ✅ Repair report (issues list with codes + metadata)
28
+ - ⏳ Streaming / incremental extraction (planned)
29
+ - ⏳ Field extraction without full parsing (planned)
30
+ - ⏳ Schema validation (explicitly out-of-scope for early versions; optional later)
31
+
32
+ ### 1.3 Proposal Background
33
+
34
+ This proposal is driven by a consistent pattern across systems:
35
+
36
+ - JSON appears inside **mixed text** (logs, HTML, Markdown, CLI output, vendor payloads, LLM responses).
37
+ - It often contains **non-JSON defects** (comments, trailing commas, single quotes).
38
+ - Teams want a **single reliable tool** that can salvage JSON while keeping changes **auditable**.
39
+
40
+ ---
41
+
42
+ ## 2. User Feedback Summary
43
+
44
+ ### 2.1 Current Usage Environment
45
+
46
+ Teams commonly rely on combinations of:
47
+
48
+ - `JSON.parse` + regex extraction
49
+ - permissive parsers (JSON5 / HJSON / custom)
50
+ - fragile “fixers” that mutate input without explaining changes
51
+
52
+ Typical environments where this breaks:
53
+
54
+ - LLM systems returning JSON inside prose or markdown
55
+ - ingestion pipelines pulling embedded JSON from logs or documents
56
+ - web scraping pipelines extracting JSON-LD or app state from HTML
57
+
58
+ ### 2.2 Feature Requests (Priority Order)
59
+
60
+ | Priority | Feature | Importance | Status |
61
+ |----------|---------|------------|--------|
62
+ | 1 | Deterministic extraction from mixed text | ⭐⭐⭐ Highest | ✅ Planned (v0.1.0) |
63
+ | 2 | Repair report with issue codes | ⭐⭐⭐ Highest | ✅ Planned (v0.1.0) |
64
+ | 3 | Safe auto-repair for common defects | ⭐⭐ High | ✅ Planned (v0.1.0 → v0.2.0) |
65
+ | 4 | Multiple JSON extraction (`all`) | ⭐⭐ High | ✅ Planned (v0.1.0/v0.2.0) |
66
+ | 5 | Candidate scoring (`best`) | ⭐⭐ Medium | ✅ Planned (v0.2.0) |
67
+ | 6 | Streaming/incremental parsing | ⭐ Medium | ⏳ Planned (v0.4.0) |
68
+ | 7 | Field extraction API | ⭐ Low | ⏳ Planned (v0.4.0) |
69
+
70
+ ### 2.3 Expected Benefits
71
+
72
+ 1. **Reliability**: Stop failing on minor JSON defects and mixed-text wrappers.
73
+ 2. **Maintainability**: Replace ad-hoc regex parsing and “repair spaghetti.”
74
+ 3. **Observability**: Every repair is logged in an `issues[]` report for debugging.
75
+ 4. **Safety**: Avoid overly-permissive parsing with deterministic guardrails.
76
+ 5. **Portability**: Zero dependency, works in Node and browser runtimes.
77
+
78
+ ---
79
+
80
+ ## 3. Implementation Status
81
+
82
+ `json-rescue` is designed to ship fast in a staged roadmap, prioritizing the stable core first.
83
+
84
+ ### 3.1 Version Roadmap (Planned)
85
+
86
+ ```text
87
+ v0.1.0 (Core) → v0.2.0 → v0.3.0 → v0.4.0 → v1.0.0
88
+ │ │ │ │ │
89
+ ▼ ▼ ▼ ▼ ▼
90
+ Extract + Repair Multi + Streaming Stable
91
+ Report Expansion Scoring + Fields Contract
92
+ ```
93
+
94
+ ## 3.2 Planned Features by Version
95
+
96
+ | Version | Feature | Status |
97
+ |--------:|---------|:------|
98
+ | v0.1.0 | Markdown fence extraction | ✅ Planned |
99
+ | v0.1.0 | Balanced brace extraction (string-aware) | ✅ Planned |
100
+ | v0.1.0 | Repairs: trailing commas, JSONC comments, smart quotes | ✅ Planned |
101
+ | v0.1.0 | Repair report (`issues[]`) | ✅ Planned |
102
+ | v0.2.0 | Repairs: single quotes, unquoted keys, Python literals | ⏳ Planned |
103
+ | v0.2.0 | Candidate scoring (mode: `'best'`) | ⏳ Planned |
104
+ | v0.3.0 | `rescueJsonAll()` convenience | ⏳ Planned |
105
+ | v0.4.0 | Streaming / incremental candidate tracking | ⏳ Planned |
106
+ | v0.4.0 | Field extraction (optional, streaming-friendly) | ⏳ Planned |
107
+ | v1.0.0 | Behavior contract + stable issue codes | ⏳ Planned |
108
+
109
+ # License
110
+ `json-rescue` is released under the **MIT License**.
111
+
112
+ # Author
113
+
114
+ This project is developed by **[Azeem Mirza](https://azeemmirza.co)** with ❤️.
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "json-rescue",
3
+ "version": "0.0.1",
4
+ "description": "Rescue valid JSON from messy text by extracting candidates, applying safe repairs, and returning a parsed result with a transparent repair report.",
5
+ "keywords": [
6
+ "json",
7
+ "parsing",
8
+ "repair",
9
+ "typescript"
10
+ ],
11
+ "homepage": "https://github.com/azeemmirza/json-rescue#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/azeemmirza/json-rescue/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/azeemmirza/json-rescue.git"
18
+ },
19
+ "license": "MIT",
20
+ "author": {
21
+ "name": "Azeem Mirza",
22
+ "url": "https://azeemmirza.co"
23
+ },
24
+ "type": "commonjs",
25
+ "main": "index.ts",
26
+ "scripts": {
27
+ "build": "tsc",
28
+ "test": "jest",
29
+ "test:watch": "jest --watch",
30
+ "prepublishOnly": "npm run build",
31
+ "publish:public": "npm publish --access public"
32
+ },
33
+ "devDependencies": {
34
+ "@types/jest": "^30.0.0",
35
+ "jest": "^30.2.0",
36
+ "ts-jest": "^29.4.6",
37
+ "typescript": "^5.9.3"
38
+ }
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ console.log('json-rescue...');
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["dom", "esnext"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+ "sourceMap": true
16
+ },
17
+ "include": ["src/**/*"],
18
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
19
+ }