@lexbuild/cli 1.0.0 → 1.0.2
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/LICENSE +21 -0
- package/README.md +114 -0
- package/package.json +14 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chris Thomas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @lexbuild/cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@lexbuild/cli)
|
|
4
|
+
[](https://github.com/chris-c-thomas/lexbuild/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/chris-c-thomas/lexbuild/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
This package is part of the [LexBuild](https://github.com/chris-c-thomas/lexbuild) monorepo, a tool that converts U.S. legislative XML into structured Markdown optimized for AI, RAG pipelines, and semantic search. See the monorepo for full documentation, architecture details, and contribution guidelines.
|
|
8
|
+
|
|
9
|
+
It provides the CLI entry point for downloading and converting legal and civic texts. Currently supports the [United States Code](https://uscode.house.gov/) via [`@lexbuild/usc`](https://www.npmjs.com/package/@lexbuild/usc), with additional sources (CFR, state statutes) planned.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @lexbuild/cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or run directly with npx:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @lexbuild/cli download --all
|
|
21
|
+
npx @lexbuild/cli convert --all
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Download and convert all 54 titles
|
|
28
|
+
lexbuild download --all && lexbuild convert --all
|
|
29
|
+
|
|
30
|
+
# Start small — download and convert Title 1
|
|
31
|
+
lexbuild download --titles 1 && lexbuild convert --titles 1
|
|
32
|
+
|
|
33
|
+
# Download and convert a range
|
|
34
|
+
lexbuild download --titles 1-5 && lexbuild convert --titles 1-5
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
### `lexbuild download`
|
|
40
|
+
|
|
41
|
+
Fetch U.S. Code XML files from the OLRC.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
lexbuild download --titles 1 # Single title
|
|
45
|
+
lexbuild download --titles 1-5,8,11 # Range + specific titles
|
|
46
|
+
lexbuild download --all # All 54 titles (single bulk zip)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
| Option | Default | Description |
|
|
50
|
+
|--------|---------|-------------|
|
|
51
|
+
| `--titles <spec>` | — | Title(s) to download: `1`, `1-5`, `1-5,8,11` |
|
|
52
|
+
| `--all` | — | Download all 54 titles |
|
|
53
|
+
| `-o, --output <dir>` | `./downloads/usc/xml` | Output directory |
|
|
54
|
+
| `--release-point <id>` | current | OLRC release point |
|
|
55
|
+
|
|
56
|
+
### `lexbuild convert`
|
|
57
|
+
|
|
58
|
+
Convert downloaded XML to Markdown.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
lexbuild convert --titles 1 # By title number
|
|
62
|
+
lexbuild convert --all # All downloaded titles
|
|
63
|
+
lexbuild convert ./downloads/usc/xml/usc01.xml # Direct file path
|
|
64
|
+
lexbuild convert --titles 1 -g chapter # Chapter-level output
|
|
65
|
+
lexbuild convert --titles 1 --link-style canonical # OLRC website links
|
|
66
|
+
lexbuild convert --titles 42 --dry-run # Preview without writing
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Option | Default | Description |
|
|
70
|
+
|--------|---------|-------------|
|
|
71
|
+
| `--titles <spec>` | — | Title(s) to convert |
|
|
72
|
+
| `--all` | — | Convert all titles in input directory |
|
|
73
|
+
| `-i, --input-dir <dir>` | `./downloads/usc/xml` | Input directory for XML files |
|
|
74
|
+
| `-o, --output <dir>` | `./output` | Output directory |
|
|
75
|
+
| `-g, --granularity <level>` | `section` | `section` or `chapter` |
|
|
76
|
+
| `--link-style <style>` | `plaintext` | `plaintext`, `canonical`, or `relative` |
|
|
77
|
+
| `--no-include-source-credits` | — | Exclude source credits |
|
|
78
|
+
| `--no-include-notes` | — | Exclude all notes |
|
|
79
|
+
| `--include-editorial-notes` | — | Include editorial notes only |
|
|
80
|
+
| `--include-statutory-notes` | — | Include statutory notes only |
|
|
81
|
+
| `--include-amendments` | — | Include amendment notes only |
|
|
82
|
+
| `--dry-run` | — | Parse and report without writing files |
|
|
83
|
+
| `-v, --verbose` | — | Verbose logging |
|
|
84
|
+
|
|
85
|
+
## Output
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
output/usc/
|
|
89
|
+
title-01/
|
|
90
|
+
README.md
|
|
91
|
+
_meta.json
|
|
92
|
+
chapter-01/
|
|
93
|
+
_meta.json
|
|
94
|
+
section-1.md
|
|
95
|
+
section-2.md
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Each section file includes YAML frontmatter (identifier, title, chapter, section, status, source credit) followed by the statutory text with bold inline numbering.
|
|
99
|
+
|
|
100
|
+
## Performance
|
|
101
|
+
|
|
102
|
+
The full U.S. Code — all 54 titles, 60,000+ sections, ~85 million estimated tokens — converts in about 20-30 seconds on modern machines. SAX streaming keeps memory bounded for even the largest titles (100MB+ XML).
|
|
103
|
+
|
|
104
|
+
## Documentation
|
|
105
|
+
|
|
106
|
+
- [Monorepo README](https://github.com/chris-c-thomas/lexbuild#readme)
|
|
107
|
+
- [Architecture](https://github.com/chris-c-thomas/lexbuild/blob/main/docs/architecture.md)
|
|
108
|
+
- [Output Format](https://github.com/chris-c-thomas/lexbuild/blob/main/docs/output-format.md)
|
|
109
|
+
- [XML Element Reference](https://github.com/chris-c-thomas/lexbuild/blob/main/docs/xml-element-reference.md)
|
|
110
|
+
- [Extending](https://github.com/chris-c-thomas/lexbuild/blob/main/docs/extending.md)
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
[MIT](https://github.com/chris-c-thomas/lexbuild/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexbuild/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Compiler for legal and civic texts. Converts disparate statutory data into structured formats optimized for AI, RAG, and semantic search.",
|
|
5
5
|
"author": "Chris Thomas",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/chris-c-thomas/lexbuild#readme",
|
|
7
|
+
"homepage": "https://github.com/chris-c-thomas/lexbuild/tree/main/packages/cli#readme",
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/chris-c-thomas/lexbuild/issues"
|
|
10
10
|
},
|
|
@@ -47,24 +47,15 @@
|
|
|
47
47
|
"files": [
|
|
48
48
|
"dist"
|
|
49
49
|
],
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "tsup",
|
|
52
|
-
"dev": "tsup --watch",
|
|
53
|
-
"typecheck": "tsc --noEmit",
|
|
54
|
-
"test": "vitest run",
|
|
55
|
-
"test:watch": "vitest",
|
|
56
|
-
"lint": "eslint src",
|
|
57
|
-
"lint:fix": "eslint src --fix"
|
|
58
|
-
},
|
|
59
50
|
"dependencies": {
|
|
60
|
-
"@lexbuild/core": "workspace:*",
|
|
61
|
-
"@lexbuild/usc": "workspace:*",
|
|
62
51
|
"chalk": "^5.6.2",
|
|
63
52
|
"cli-table3": "^0.6.5",
|
|
64
53
|
"commander": "^13.1.0",
|
|
65
54
|
"ora": "^8.2.0",
|
|
66
55
|
"pino": "^9.6.0",
|
|
67
|
-
"pino-pretty": "^13.0.0"
|
|
56
|
+
"pino-pretty": "^13.0.0",
|
|
57
|
+
"@lexbuild/core": "1.0.2",
|
|
58
|
+
"@lexbuild/usc": "1.0.2"
|
|
68
59
|
},
|
|
69
60
|
"devDependencies": {
|
|
70
61
|
"@types/node": "^25.3.2",
|
|
@@ -77,5 +68,14 @@
|
|
|
77
68
|
},
|
|
78
69
|
"publishConfig": {
|
|
79
70
|
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "tsup",
|
|
74
|
+
"dev": "tsup --watch",
|
|
75
|
+
"typecheck": "tsc --noEmit",
|
|
76
|
+
"test": "vitest run",
|
|
77
|
+
"test:watch": "vitest",
|
|
78
|
+
"lint": "eslint src",
|
|
79
|
+
"lint:fix": "eslint src --fix"
|
|
80
80
|
}
|
|
81
81
|
}
|