brewdoc 0.0.0-stage → 0.3.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 +128 -2
- package/bin/brewdoc.cjs +85 -0
- package/package.json +42 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Maksim Kochetkov
|
|
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
CHANGED
|
@@ -1,3 +1,129 @@
|
|
|
1
|
-
#
|
|
1
|
+
# brewdoc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://pypi.org/project/brewdoc/)
|
|
4
|
+
[](https://github.com/kochetkov-ma/brewdoc/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/kochetkov-ma/brewdoc/releases/latest)
|
|
6
|
+
[](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/LICENSE)
|
|
7
|
+
|
|
8
|
+
Fast, deterministic document-to-Markdown conversion for agent systems. Easy to install. No model weights, OCR or external services.
|
|
9
|
+
|
|
10
|
+
Local conversion runs offline after installation, with no runtime component downloads.
|
|
11
|
+
Supported documents become one Markdown file and a JSON receipt describing omissions.
|
|
12
|
+
See [supported formats and limits](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/FORMATS.md).
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
These examples select 0.3.2. Use a channel listed as available in [that release](https://github.com/kochetkov-ma/brewdoc/releases/tag/v0.3.2). Choose one method:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
python -m pip install "brewdoc==0.3.2"
|
|
20
|
+
uv tool install --python 3.12 "brewdoc==0.3.2"
|
|
21
|
+
pipx install --python 3.12 "brewdoc==0.3.2"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use a virtual environment for pip. Python 3.12+ is required; HTML/URL need CPython 3.12-3.14.
|
|
25
|
+
[INSTALL.md](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/INSTALL.md) covers prerequisites, Windows, uvx, PATH, update and removal.
|
|
26
|
+
[Latest release](https://github.com/kochetkov-ma/brewdoc/releases/latest) lists actual assets and channel availability.
|
|
27
|
+
|
|
28
|
+
### Standalone downloads
|
|
29
|
+
|
|
30
|
+
Use downloads listed as available in the release. Python and dependencies are bundled. Verify [SHA256SUMS](https://github.com/kochetkov-ma/brewdoc/releases/download/v0.3.2/SHA256SUMS) and keep the entire extracted directory.
|
|
31
|
+
|
|
32
|
+
[](https://github.com/kochetkov-ma/brewdoc/releases/download/v0.3.2/brewdoc-0.3.2-linux-x64.tar.gz)
|
|
33
|
+
[](https://github.com/kochetkov-ma/brewdoc/releases/download/v0.3.2/brewdoc-0.3.2-windows-x64.zip)
|
|
34
|
+
[](https://github.com/kochetkov-ma/brewdoc/releases/download/v0.3.2/brewdoc-0.3.2-macos-arm64.tar.gz)
|
|
35
|
+
|
|
36
|
+
| Native target | Verification environment | JavaScript |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| Linux x64/glibc | Ubuntu 22.04, glibc 2.35 | Bundled |
|
|
39
|
+
| Windows x64 | Windows Server 2025 | Refused before requests |
|
|
40
|
+
| macOS ARM64 | macOS 15, Apple Silicon | Bundled |
|
|
41
|
+
|
|
42
|
+
Older OSes, Linux musl/ARM64 and macOS Intel are outside this binary set.
|
|
43
|
+
Windows is unsigned; macOS has an ad hoc signature without Developer ID/notarization.
|
|
44
|
+
Linux archives have checksums, without a detached publisher signature. [Download and launch](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/INSTALL.md#standalone).
|
|
45
|
+
|
|
46
|
+
### npm
|
|
47
|
+
|
|
48
|
+
[](https://www.npmjs.com/package/brewdoc)
|
|
49
|
+
|
|
50
|
+
npm targets Linux x64/glibc and macOS ARM64. Windows uses the GitHub native download or Python package.
|
|
51
|
+
Use npm/npx only when listed as available in [the release](https://github.com/kochetkov-ma/brewdoc/releases/tag/v0.3.2).
|
|
52
|
+
[INSTALL.md](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/INSTALL.md#npm-and-npx) contains exact-version installation, update and removal instructions.
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
brewdoc file.pdf --out file.md
|
|
58
|
+
brewdoc book.epub --out book.md
|
|
59
|
+
brewdoc file.xlsx --sheet Calc --sheet Inputs --out book.md
|
|
60
|
+
brewdoc file.xlsm --artifact formula/sheet/000002=formulas.json
|
|
61
|
+
brewdoc file.xlsm --artifact vba/project/000001=vbaProject.bin
|
|
62
|
+
brewdoc --self-check
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`--sheet` and `--artifact` are repeatable and workbook-only. Sheet names are exact and case-sensitive;
|
|
66
|
+
caller order retains full-workbook ordinals. Artifact keys come from the Markdown artifact table.
|
|
67
|
+
Requests and output collisions are validated before writes. Paths resolve against the caller's directory;
|
|
68
|
+
`--out` creates parents. Refusal preserves existing output. Self-check is offline and has its own output.
|
|
69
|
+
|
|
70
|
+
## Markdown and receipts
|
|
71
|
+
|
|
72
|
+
Successful output uses `brewdoc.markdown/2`: quoted source title, Metadata, Artifacts,
|
|
73
|
+
Known omissions, Contents, then anchored units. PDF uses `page/000001`, workbooks `sheet/000001`,
|
|
74
|
+
PPTX `slide/000001`, and DOCX/EPUB/HTML `chapter/000001`. Empty declared units remain navigable.
|
|
75
|
+
Metadata holds source/selection/content hashes, conversion tallies and artifact capabilities;
|
|
76
|
+
it excludes paths, timestamps, permissions and host data. EPUB retains declared publication metadata.
|
|
77
|
+
|
|
78
|
+
Conversion prints one JSON receipt line first. With `--out`, Markdown goes to the file;
|
|
79
|
+
without it, Markdown follows on stdout. Local receipts use `brewdoc.receipt/1`; URL receipts use `brewdoc.receipt/2`.
|
|
80
|
+
|
|
81
|
+
| Receipt fields | Meaning |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `file_ok`, `reason` | Conversion success or named refusal |
|
|
84
|
+
| `receipt_schema` | Local brewdoc.receipt/1 or URL brewdoc.receipt/2 |
|
|
85
|
+
| `route`, `source`, `unit_kind`, `units` | Reader, local filename/redacted URL, content kind/count |
|
|
86
|
+
| `tables`, `text_regions`, `columns_split` | Conversion tallies |
|
|
87
|
+
| `dropped`, `broken_ligature_words` | Counted normalization; malformed font words are folded, not guessed |
|
|
88
|
+
| `not_carried` | Structural omissions; read before concluding a fact is absent |
|
|
89
|
+
| `out` | Markdown path, or null for stdout |
|
|
90
|
+
| `markdown_schema`, `unit_keys`, `artifacts` | Success-only schema, ordered source keys and available/requested artifacts |
|
|
91
|
+
| `selected_sheets` | Caller-ordered names, only when selected |
|
|
92
|
+
| `acquisition` | URL provenance, frozen snapshot and capture status |
|
|
93
|
+
|
|
94
|
+
Exit 0 means conversion, 1 refusal and 2 invalid usage. Success does not prove content fidelity or complete JavaScript.
|
|
95
|
+
PDF/DOCX/PPTX/workbooks emit ASCII; HTML/EPUB emit UTF-8 without BOM, with LF newlines. JSON keeps ASCII escaping.
|
|
96
|
+
The same local file or frozen snapshot produces identical bytes; live pages can change.
|
|
97
|
+
|
|
98
|
+
## Python API
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
import brewdoc
|
|
102
|
+
|
|
103
|
+
code, receipt, markdown = brewdoc.run("book.epub", out="book.md")
|
|
104
|
+
markdown, tally = brewdoc.render_html("page.html")
|
|
105
|
+
refs = brewdoc.list_book_artifacts("book.xlsm", sheets=("Calc",))
|
|
106
|
+
payload = brewdoc.read_book_artifact("book.xlsm", refs[0].key, sheets=("Calc",))
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`run` accepts `sheets` and an `artifact_outputs` key-to-path mapping. Renderers include
|
|
110
|
+
`render_pdf`, `render_doc`, `render_presentation`, `render_epub`, `render_html` and `render_book`.
|
|
111
|
+
`read_formulas` provides typed formulas; `self_check` verifies installed routes. Local APIs never acquire URLs.
|
|
112
|
+
|
|
113
|
+
## Explicit URL acquisition
|
|
114
|
+
|
|
115
|
+
`--url` deliberately acquires a public HTTP(S) page before local conversion.
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
brewdoc --url https://example.com/article --out article.md
|
|
119
|
+
brewdoc --url https://example.com/article --render-js --timeout 30 --out article.md
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`--timeout` is one positive finite waiting budget, default 30 seconds; cleanup/conversion can add time.
|
|
123
|
+
Public destinations, DNS, redirects, TLS, requests and bytes are validated. Ordinary requests use GET;
|
|
124
|
+
JS admits only the narrow credential-free HN Algolia XHR POST exception. Local HTML never fetches or runs scripts.
|
|
125
|
+
Optional JS needs installed/bundled prerequisites, refuses unsupported runtimes before HTTP and downloads no engine.
|
|
126
|
+
Timing-only expiry can preserve valid partial content; hard failures refuse output. [Full URL/JS limits](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/FORMATS.md#url-acquisition).
|
|
127
|
+
|
|
128
|
+
[Format contracts](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/FORMATS.md) | [Corpus](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/benchmarks/CATALOG.md) | [Measurements](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/benchmarks/METHODOLOGY.md) | [Results](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/benchmarks/results/README.md)
|
|
129
|
+
[Releasing](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/RELEASING.md) | [Agent entry point](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/llms.txt) | [MIT license](https://github.com/kochetkov-ma/brewdoc/blob/v0.3.2/LICENSE)
|
package/bin/brewdoc.cjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawn } = require('node:child_process');
|
|
5
|
+
const { existsSync } = require('node:fs');
|
|
6
|
+
const { dirname, join } = require('node:path');
|
|
7
|
+
|
|
8
|
+
/** Select only admitted targets and supported libc versions. */
|
|
9
|
+
function selectTarget(targets, platform, arch, glibc) {
|
|
10
|
+
if (platform === 'win32') return undefined;
|
|
11
|
+
return Object.values(targets).find(target => {
|
|
12
|
+
if (target.os !== platform || target.cpu !== arch) return false;
|
|
13
|
+
if (target.libc !== 'glibc') return true;
|
|
14
|
+
const observed = typeof glibc === 'string' && glibc.match(/^([0-9]+)\.([0-9]+)(?:\.[0-9]+)*$/);
|
|
15
|
+
const minimum = target.minimumLibc.split('.').map(Number);
|
|
16
|
+
return Boolean(observed) && (Number(observed[1]) > minimum[0]
|
|
17
|
+
|| (Number(observed[1]) === minimum[0] && Number(observed[2]) >= minimum[1]));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Run the installed native CLI without changing its streams. */
|
|
22
|
+
function launch() {
|
|
23
|
+
const metadata = require('../package.json');
|
|
24
|
+
const glibc = process.platform === 'linux' ? process.report.getReport().header.glibcVersionRuntime : null;
|
|
25
|
+
const target = selectTarget(metadata.brewdocTargets, process.platform, process.arch, glibc);
|
|
26
|
+
const fallback = 'Use Python: python -m pip install brewdoc (or uv tool install brewdoc / pipx install brewdoc).';
|
|
27
|
+
function refuse(reason) {
|
|
28
|
+
process.stderr.write(`brewdoc: ${reason}. ${fallback}\n`);
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
}
|
|
31
|
+
if (!target) {
|
|
32
|
+
refuse(process.platform === 'win32'
|
|
33
|
+
? 'npm is unsupported on Windows; download the standalone Windows archive from https://github.com/kochetkov-ma/brewdoc/releases'
|
|
34
|
+
: `unsupported native target ${process.platform}/${process.arch} or operating-system/libc version`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let executable;
|
|
38
|
+
try {
|
|
39
|
+
const packagePath = require.resolve(`${target.package}/package.json`);
|
|
40
|
+
const installed = require(packagePath);
|
|
41
|
+
if (installed.version !== metadata.version) {
|
|
42
|
+
refuse(`native package version ${installed.version} differs from ${metadata.version}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
executable = join(dirname(packagePath), target.executable);
|
|
46
|
+
if (!existsSync(executable)) {
|
|
47
|
+
refuse(`native executable is missing from ${target.package}`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
refuse(`native package ${target.package} is unavailable; reinstall with optional dependencies`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const signals = process.platform === 'win32' ? ['SIGINT', 'SIGTERM', 'SIGBREAK'] : ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
55
|
+
const child = spawn(executable, process.argv.slice(2), {
|
|
56
|
+
stdio: 'inherit', shell: false, detached: process.platform !== 'win32',
|
|
57
|
+
});
|
|
58
|
+
const handlers = new Map();
|
|
59
|
+
for (const signal of signals) {
|
|
60
|
+
const handler = () => {
|
|
61
|
+
try {
|
|
62
|
+
if (process.platform === 'win32') child.kill(signal === 'SIGBREAK' ? 'SIGTERM' : signal);
|
|
63
|
+
else process.kill(-child.pid, signal);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.code !== 'ESRCH') refuse(`cannot forward ${signal}: ${error.code}`);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
handlers.set(signal, handler);
|
|
69
|
+
process.on(signal, handler);
|
|
70
|
+
}
|
|
71
|
+
let failed = false;
|
|
72
|
+
child.once('error', error => {
|
|
73
|
+
failed = true;
|
|
74
|
+
refuse(`cannot launch native executable: ${error.code}`);
|
|
75
|
+
});
|
|
76
|
+
child.once('close', (code, signal) => {
|
|
77
|
+
for (const [name, handler] of handlers) process.removeListener(name, handler);
|
|
78
|
+
if (failed) return;
|
|
79
|
+
if (signal && process.platform !== 'win32') process.kill(process.pid, signal);
|
|
80
|
+
else process.exitCode = code === null ? 1 : code;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = { selectTarget };
|
|
85
|
+
if (require.main === module) launch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
+
"bin": {
|
|
3
|
+
"brewdoc": "bin/brewdoc.cjs"
|
|
4
|
+
},
|
|
5
|
+
"brewdocTargets": {
|
|
6
|
+
"linux-x64": {
|
|
7
|
+
"cpu": "x64",
|
|
8
|
+
"executable": "binary/brewdoc",
|
|
9
|
+
"libc": "glibc",
|
|
10
|
+
"minimumLibc": "2.35",
|
|
11
|
+
"os": "linux",
|
|
12
|
+
"package": "brewdoc-linux-x64-glibc"
|
|
13
|
+
},
|
|
14
|
+
"macos-arm64": {
|
|
15
|
+
"cpu": "arm64",
|
|
16
|
+
"executable": "binary/brewdoc",
|
|
17
|
+
"os": "darwin",
|
|
18
|
+
"package": "brewdoc-darwin-arm64"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"description": "Fast, deterministic document-to-Markdown conversion for agent systems. Easy to install. No model weights, OCR or external services.",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=24.21.0 <25"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/"
|
|
27
|
+
],
|
|
28
|
+
"homepage": "https://github.com/kochetkov-ma/brewdoc#readme",
|
|
29
|
+
"license": "MIT",
|
|
2
30
|
"name": "brewdoc",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
31
|
+
"optionalDependencies": {
|
|
32
|
+
"brewdoc-darwin-arm64": "0.3.2",
|
|
33
|
+
"brewdoc-linux-x64-glibc": "0.3.2"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/kochetkov-ma/brewdoc.git"
|
|
42
|
+
},
|
|
43
|
+
"version": "0.3.2"
|
|
44
|
+
}
|