pi-quiver 6.16.0 → 6.16.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/CHANGELOG.md +4 -0
- package/dist/bin/pi-quiver.js +4 -2
- package/extensions/doc_to_md.ts +10 -9
- package/lib/doc-to-md-core.ts +2 -3
- package/lib/doc-to-md-handle.ts +12 -5
- package/lib/doc-to-md-options.ts +8 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
Format follows sibling pi packages (e.g. [`pi-condense`](https://github.com/jjuraszek/pi-condense/blob/main/CHANGELOG.md)):
|
|
4
4
|
one entry per `vX.Y.Z` tag, newest first, terse bullets, dated.
|
|
5
5
|
|
|
6
|
+
## v6.16.1 - 2026-11-09
|
|
7
|
+
|
|
8
|
+
- doc_to_md result and option enums share one declaration in `lib/`, so members cannot drift between TypeScript types and tool schemas. (#38)
|
|
9
|
+
|
|
6
10
|
Published to npm as `pi-quiver` (`pi install npm:pi-quiver`). Pushing a
|
|
7
11
|
`vX.Y.Z` tag triggers `.github/workflows/release.yml`, which publishes to npm
|
|
8
12
|
via OIDC trusted publishing. The release helper at
|
package/dist/bin/pi-quiver.js
CHANGED
|
@@ -1034,6 +1034,8 @@ function formatInfoHandle(i, max) {
|
|
|
1034
1034
|
|
|
1035
1035
|
// lib/doc-to-md-options.ts
|
|
1036
1036
|
import { extname as extname2 } from "node:path";
|
|
1037
|
+
var IMAGE_FORMATS = ["png", "jpg"];
|
|
1038
|
+
var OCR_MODES = ["textless", "all"];
|
|
1037
1039
|
var UsageError = class extends Error {
|
|
1038
1040
|
};
|
|
1039
1041
|
var MIN_PYMUPDF4LLM = "1.27.0";
|
|
@@ -1048,7 +1050,7 @@ var DOC_TO_MD_OPTIONS = [
|
|
|
1048
1050
|
{ key: "overwrite", flag: "--overwrite", type: "bool", default: false, settable: false, help: "Replace an existing completed <stem>.md bundle" },
|
|
1049
1051
|
{ key: "pageImages", flag: "--page-images", type: "bool", default: false, settable: false, help: "Also render every selected page to pages/<stem>-pNNN.<imageFormat> at imageDpi (PDF, PPTX, .doc, DOCX via LibreOffice); off by default" },
|
|
1050
1052
|
{ key: "words", toolHelp: "Write word positions to <stem>.words.json, or ocr/<stem>-pNNN.words.json for ocrMode all. Never triggers OCR. PDF and image inputs only.", flag: "--words", type: "bool", default: false, settable: false, help: 'Write word positions: <stem>.words.json beside the Markdown lists every text-layer word of each selected page with its bbox (PDF points, top-left origin, display orientation; image inputs in source pixels) and the words inline OCR recognized, tagged source "text" or "ocr"; under --ocr-mode all the OCR words go to ocr/<stem>-pNNN.words.json beside each sidecar. Never triggers OCR. PDF and image inputs only.' },
|
|
1051
|
-
{ key: "ocrMode", toolHelp: "textless (default): OCR empty text layers inline. all: OCR selected pages to ocr/ sidecars without changing Markdown; requires ocr and explicit pages (PDF, PPTX, DOC).", flag: "--ocr-mode", type: "enum", default: "textless", settable: false, enumValues:
|
|
1053
|
+
{ key: "ocrMode", toolHelp: "textless (default): OCR empty text layers inline. all: OCR selected pages to ocr/ sidecars without changing Markdown; requires ocr and explicit pages (PDF, PPTX, DOC).", flag: "--ocr-mode", type: "enum", default: "textless", settable: false, enumValues: OCR_MODES, help: "OCR policy: textless (default) OCRs only pages with an empty text layer, inline; all OCRs every selected page and writes the recognized text to ocr/<stem>-pNNN.md sidecars, leaving the Markdown untouched. all requires --ocr and an explicit --pages selection (PDF, PPTX, DOC)." },
|
|
1052
1054
|
{ key: "primaryTimeoutMs", flag: "--primary-timeout", type: "int", default: 6e4, settable: true, env: "PI_DOC_TO_MD_CONVERT_TIMEOUT_MS", help: "pymupdf4llm tier and DOCX child (docx mode); also the unpdf tier" },
|
|
1053
1055
|
{ key: "fallbackTimeoutMs", flag: "--fallback-timeout", type: "int", default: 3e4, settable: true, help: "PyMuPDF get_text tier (including DOCX LibreOffice fallback); also PDF and DOCX info and Excel rendered views" },
|
|
1054
1056
|
{ key: "sofficeTimeoutMs", flag: "--soffice-timeout", type: "int", default: 12e4, settable: true, env: "PI_DOC_TO_MD_SOFFICE_TIMEOUT_MS", help: "DOCX/PPTX -> PDF via LibreOffice; also Excel rendered views" },
|
|
@@ -1056,7 +1058,7 @@ var DOC_TO_MD_OPTIONS = [
|
|
|
1056
1058
|
{ key: "warmTimeoutMs", flag: "--warm-timeout", type: "int", default: 12e4, settable: true, env: "PI_DOC_TO_MD_WARM_TIMEOUT_MS", help: "Absolute backend discovery/bootstrap deadline (first call per process)" },
|
|
1057
1059
|
{ key: "pymupdfVersion", flag: "--pymupdf-version", type: "version", default: "1.27.2.3", settable: true, env: "PI_DOC_TO_MD_PYMUPDF_VERSION", help: "pymupdf4llm pin (>= 1.27.0)" },
|
|
1058
1060
|
{ key: "imageDpi", flag: "--image-dpi", type: "int", default: 150, settable: true, help: "Render DPI for page images and Excel rendered views" },
|
|
1059
|
-
{ key: "imageFormat", flag: "--image-format", type: "enum", default: "png", settable: true, enumValues:
|
|
1061
|
+
{ key: "imageFormat", flag: "--image-format", type: "enum", default: "png", settable: true, enumValues: IMAGE_FORMATS, help: "Rendered image format (embedded images keep their native extension)" },
|
|
1060
1062
|
{ key: "maxOutputBytes", flag: "--max-output-bytes", type: "int", default: 2e7, settable: true, help: "Child stdout cap in bytes" },
|
|
1061
1063
|
{ key: "outlineMaxEntries", flag: "--outline-max-entries", type: "int", default: 40, settable: true, help: "Heading outline / TOC / sheet inventory cap in the handle" },
|
|
1062
1064
|
{ key: "ocr", flag: "--ocr", type: "bool", default: false, settable: true, help: "Run OCR on pages without a text layer and on image inputs when Tesseract language data is installed; off by default (--no-ocr turns a settings-level true off)" },
|
package/extensions/doc_to_md.ts
CHANGED
|
@@ -14,23 +14,24 @@ import {
|
|
|
14
14
|
coerceDocToMdSettings, convertDocument, inspectDocument, resolveOptions,
|
|
15
15
|
} from "../lib/doc-to-md-core.ts";
|
|
16
16
|
import { resolve } from "node:path";
|
|
17
|
-
import { publicHandle } from "../lib/doc-to-md-handle.ts";
|
|
17
|
+
import { BACKEND_KINDS, ENGINES, OCR_STATUSES, SHEET_KINDS, TIERS, publicHandle } from "../lib/doc-to-md-handle.ts";
|
|
18
|
+
import { INPUT_TYPES, OCR_MODES } from "../lib/doc-to-md-options.ts";
|
|
18
19
|
|
|
19
20
|
const nullable = <T extends TSchema>(schema: T) => Type.Union([schema, Type.Null()]);
|
|
20
|
-
const strings = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));
|
|
21
|
+
const strings = <T extends string>(values: readonly T[]) => Type.Union(values.map((value) => Type.Literal(value)));
|
|
21
22
|
const pages = Type.Array(Type.Integer());
|
|
22
23
|
const pageStrings = Type.Record(Type.String(), Type.String());
|
|
23
|
-
const inputType = strings(
|
|
24
|
+
const inputType = strings(INPUT_TYPES);
|
|
24
25
|
const tocEntry = { level: Type.Integer(), title: Type.String(), page: nullable(Type.Integer()) };
|
|
25
26
|
const ocrSchema = Type.Object({
|
|
26
|
-
status: strings(
|
|
27
|
+
status: strings(OCR_STATUSES), lang: Type.String(),
|
|
27
28
|
textless: pages, pages, noText: pages, ocrFailed: pages, budgetStopped: pages, ceilingStopped: pages,
|
|
28
29
|
ocrMaxPages: Type.Integer(), reason: nullable(Type.String()), tesseract: nullable(Type.Boolean()),
|
|
29
|
-
mode: strings(
|
|
30
|
+
mode: strings(OCR_MODES), sidecars: pageStrings, wordSidecars: pageStrings, ocrErrors: pageStrings,
|
|
30
31
|
killed: nullable(Type.Integer()), notAttempted: pages, childError: nullable(Type.String()),
|
|
31
32
|
});
|
|
32
33
|
const sheetSchema = Type.Object({
|
|
33
|
-
index: Type.Integer(), name: Type.String(), kind: strings(
|
|
34
|
+
index: Type.Integer(), name: Type.String(), kind: strings(SHEET_KINDS), hidden: Type.Boolean(),
|
|
34
35
|
rows: nullable(Type.Integer()), cols: nullable(Type.Integer()), hiddenRows: Type.Integer(), hiddenCols: Type.Integer(),
|
|
35
36
|
charts: Type.Integer(), images: Type.Integer(), rendered: Type.Boolean(), csv: nullable(Type.String()),
|
|
36
37
|
});
|
|
@@ -38,8 +39,8 @@ const outputSchema = Type.Union([
|
|
|
38
39
|
Type.Object({
|
|
39
40
|
savedTo: Type.String(), imagesDir: nullable(Type.String()), sheetsDir: nullable(Type.String()), pagesDir: nullable(Type.String()),
|
|
40
41
|
type: inputType,
|
|
41
|
-
engine: strings(
|
|
42
|
-
tier: strings(
|
|
42
|
+
engine: strings(ENGINES),
|
|
43
|
+
tier: strings(TIERS),
|
|
43
44
|
pageCount: nullable(Type.Integer()), pages: nullable(pages), explicitBreaks: nullable(Type.Integer()),
|
|
44
45
|
imageCount: Type.Integer(), pageImageCount: Type.Integer(), pageImagesReason: nullable(Type.String()), bytes: Type.Integer(), lines: Type.Integer(),
|
|
45
46
|
degraded: nullable(Type.String()), fallbackReason: nullable(Type.String()), failedPages: pages, emptyPages: pages,
|
|
@@ -53,7 +54,7 @@ const outputSchema = Type.Union([
|
|
|
53
54
|
wordsPath: nullable(Type.String()), wordsReason: nullable(Type.String()), wordsErrors: pageStrings,
|
|
54
55
|
}),
|
|
55
56
|
Type.Object({
|
|
56
|
-
type: inputType, backend: strings(
|
|
57
|
+
type: inputType, backend: strings(BACKEND_KINDS), pageCount: nullable(Type.Integer()),
|
|
57
58
|
metadata: Type.Record(Type.String(), Type.String()), toc: Type.Array(Type.Object(tocEntry)), tocTotal: Type.Integer(),
|
|
58
59
|
sheets: nullable(Type.Array(sheetSchema)), sheetsTotal: Type.Integer(),
|
|
59
60
|
}),
|
package/lib/doc-to-md-core.ts
CHANGED
|
@@ -13,12 +13,12 @@ import { homedir, tmpdir } from "node:os";
|
|
|
13
13
|
import { basename, dirname, extname, isAbsolute, join, resolve } from "node:path";
|
|
14
14
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
15
|
import { type StagedPage, type Bundle, abortBundle, commitBundle, openBundle, publishAttachments, publishSidecars, publishWords, writePageStats, publishPageImages, publishSheetCsvs, publishSheetImages, publishStaged, rewriteLinks, tempBundleRoot, validateImageLinks } from "./doc-to-md-bundle.ts";
|
|
16
|
-
import { type NativeImage, type Engine, type HandleData, type InfoData, type OcrInfo, type PageStat, type Tier, formatHandle, formatInfoHandle, scanOutline, type SheetInfo, type TocEntry } from "./doc-to-md-handle.ts";
|
|
16
|
+
import { type BackendKind, type NativeImage, type Engine, type HandleData, type InfoData, type OcrInfo, type PageStat, type Tier, formatHandle, formatInfoHandle, scanOutline, type SheetInfo, type TocEntry } from "./doc-to-md-handle.ts";
|
|
17
17
|
import { type DocToMdOptions, type InputType, IMAGE_EXTS, TUNABLE_DEFAULTS, UsageError, classifyInput, sanitizeStem } from "./doc-to-md-options.ts";
|
|
18
18
|
|
|
19
19
|
export * from "./doc-to-md-options.ts";
|
|
20
20
|
export { compactRanges, formatHandle, formatInfoHandle, formatSize, scanOutline } from "./doc-to-md-handle.ts";
|
|
21
|
-
export type { Engine, HandleData, InfoData, OutlineEntry, SheetInfo, Tier, TocEntry } from "./doc-to-md-handle.ts";
|
|
21
|
+
export type { BackendKind, Engine, HandleData, InfoData, OutlineEntry, SheetInfo, Tier, TocEntry } from "./doc-to-md-handle.ts";
|
|
22
22
|
|
|
23
23
|
// --- Types ---
|
|
24
24
|
|
|
@@ -227,7 +227,6 @@ export function probeArgs(): string[] {
|
|
|
227
227
|
}
|
|
228
228
|
export const PYTHON_CANDIDATES = ["python3", "python"] as const;
|
|
229
229
|
|
|
230
|
-
export type BackendKind = "uv" | "python" | "venv" | "none";
|
|
231
230
|
export type Backend =
|
|
232
231
|
| { kind: "uv"; pdf: true; xlsx: true; docx: true; email: true }
|
|
233
232
|
| { kind: "python"; exe: string; pdf: boolean; xlsx: boolean; docx: boolean; email: boolean }
|
package/lib/doc-to-md-handle.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import type { InputType, OcrMode } from "./doc-to-md-options.ts";
|
|
2
2
|
import type { DocToMdDetails } from "./doc-to-md-core.ts";
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
export type
|
|
6
|
-
export
|
|
4
|
+
export const TIERS = ["primary", "fallback", "unpdf", "excel", "docx", "html", "image", "email"] as const;
|
|
5
|
+
export type Tier = (typeof TIERS)[number];
|
|
6
|
+
export const ENGINES = ["pymupdf4llm", "pymupdf-text", "unpdf", "openpyxl", "xlrd", "mammoth", "python-docx", "markdownify", "turndown", "copy", "extract-msg", "email"] as const;
|
|
7
|
+
export type Engine = (typeof ENGINES)[number];
|
|
8
|
+
export const BACKEND_KINDS = ["uv", "python", "venv", "none"] as const;
|
|
9
|
+
export type BackendKind = (typeof BACKEND_KINDS)[number];
|
|
10
|
+
export const SHEET_KINDS = ["worksheet", "chartsheet"] as const;
|
|
11
|
+
export type SheetKind = (typeof SHEET_KINDS)[number];
|
|
12
|
+
export const OCR_STATUSES = ["off", "unavailable", "skipped", "ran"] as const;
|
|
13
|
+
export type OcrStatus = (typeof OCR_STATUSES)[number];
|
|
7
14
|
|
|
8
15
|
export interface OutlineEntry { line: number; level: number; title: string; page: number | null; }
|
|
9
16
|
export interface TocEntry { level: number; title: string; page: number | null; }
|
|
10
17
|
export interface SheetInfo {
|
|
11
18
|
index: number;
|
|
12
19
|
name: string;
|
|
13
|
-
kind:
|
|
20
|
+
kind: SheetKind;
|
|
14
21
|
hidden: boolean;
|
|
15
22
|
rows: number | null; cols: number | null;
|
|
16
23
|
hiddenRows: number; hiddenCols: number;
|
|
@@ -22,7 +29,7 @@ export interface SheetInfo {
|
|
|
22
29
|
export type PageStat = { page: number; chars: number; images: number; imageCoverage: number } | { page: number; error: string };
|
|
23
30
|
|
|
24
31
|
export interface OcrInfo {
|
|
25
|
-
status:
|
|
32
|
+
status: OcrStatus;
|
|
26
33
|
lang: string;
|
|
27
34
|
textless: number[];
|
|
28
35
|
pages: number[];
|
package/lib/doc-to-md-options.ts
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { extname } from "node:path";
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
export type
|
|
9
|
-
export
|
|
7
|
+
export const INPUT_TYPES = ["pdf", "docx", "doc", "pptx", "xlsx", "xlsm", "xls", "html", "image", "email"] as const;
|
|
8
|
+
export type InputType = (typeof INPUT_TYPES)[number];
|
|
9
|
+
export const IMAGE_FORMATS = ["png", "jpg"] as const;
|
|
10
|
+
export type ImageFormat = (typeof IMAGE_FORMATS)[number];
|
|
11
|
+
export const OCR_MODES = ["textless", "all"] as const;
|
|
12
|
+
export type OcrMode = (typeof OCR_MODES)[number];
|
|
10
13
|
|
|
11
14
|
export interface Tunables {
|
|
12
15
|
primaryTimeoutMs: number;
|
|
@@ -78,7 +81,7 @@ export const DOC_TO_MD_OPTIONS: readonly OptionDescriptor[] = [
|
|
|
78
81
|
{ key: "overwrite", flag: "--overwrite", type: "bool", default: false, settable: false, help: "Replace an existing completed <stem>.md bundle" },
|
|
79
82
|
{ key: "pageImages", flag: "--page-images", type: "bool", default: false, settable: false, help: "Also render every selected page to pages/<stem>-pNNN.<imageFormat> at imageDpi (PDF, PPTX, .doc, DOCX via LibreOffice); off by default" },
|
|
80
83
|
{ key: "words", toolHelp: "Write word positions to <stem>.words.json, or ocr/<stem>-pNNN.words.json for ocrMode all. Never triggers OCR. PDF and image inputs only.", flag: "--words", type: "bool", default: false, settable: false, help: "Write word positions: <stem>.words.json beside the Markdown lists every text-layer word of each selected page with its bbox (PDF points, top-left origin, display orientation; image inputs in source pixels) and the words inline OCR recognized, tagged source \"text\" or \"ocr\"; under --ocr-mode all the OCR words go to ocr/<stem>-pNNN.words.json beside each sidecar. Never triggers OCR. PDF and image inputs only." },
|
|
81
|
-
{ key: "ocrMode", toolHelp: "textless (default): OCR empty text layers inline. all: OCR selected pages to ocr/ sidecars without changing Markdown; requires ocr and explicit pages (PDF, PPTX, DOC).", flag: "--ocr-mode", type: "enum", default: "textless", settable: false, enumValues:
|
|
84
|
+
{ key: "ocrMode", toolHelp: "textless (default): OCR empty text layers inline. all: OCR selected pages to ocr/ sidecars without changing Markdown; requires ocr and explicit pages (PDF, PPTX, DOC).", flag: "--ocr-mode", type: "enum", default: "textless", settable: false, enumValues: OCR_MODES, help: "OCR policy: textless (default) OCRs only pages with an empty text layer, inline; all OCRs every selected page and writes the recognized text to ocr/<stem>-pNNN.md sidecars, leaving the Markdown untouched. all requires --ocr and an explicit --pages selection (PDF, PPTX, DOC)." },
|
|
82
85
|
{ key: "primaryTimeoutMs", flag: "--primary-timeout", type: "int", default: 60000, settable: true, env: "PI_DOC_TO_MD_CONVERT_TIMEOUT_MS", help: "pymupdf4llm tier and DOCX child (docx mode); also the unpdf tier" },
|
|
83
86
|
{ key: "fallbackTimeoutMs", flag: "--fallback-timeout", type: "int", default: 30000, settable: true, help: "PyMuPDF get_text tier (including DOCX LibreOffice fallback); also PDF and DOCX info and Excel rendered views" },
|
|
84
87
|
{ key: "sofficeTimeoutMs", flag: "--soffice-timeout", type: "int", default: 120000, settable: true, env: "PI_DOC_TO_MD_SOFFICE_TIMEOUT_MS", help: "DOCX/PPTX -> PDF via LibreOffice; also Excel rendered views" },
|
|
@@ -86,7 +89,7 @@ export const DOC_TO_MD_OPTIONS: readonly OptionDescriptor[] = [
|
|
|
86
89
|
{ key: "warmTimeoutMs", flag: "--warm-timeout", type: "int", default: 120000, settable: true, env: "PI_DOC_TO_MD_WARM_TIMEOUT_MS", help: "Absolute backend discovery/bootstrap deadline (first call per process)" },
|
|
87
90
|
{ key: "pymupdfVersion", flag: "--pymupdf-version", type: "version", default: "1.27.2.3", settable: true, env: "PI_DOC_TO_MD_PYMUPDF_VERSION", help: "pymupdf4llm pin (>= 1.27.0)" },
|
|
88
91
|
{ key: "imageDpi", flag: "--image-dpi", type: "int", default: 150, settable: true, help: "Render DPI for page images and Excel rendered views" },
|
|
89
|
-
{ key: "imageFormat", flag: "--image-format", type: "enum", default: "png", settable: true, enumValues:
|
|
92
|
+
{ key: "imageFormat", flag: "--image-format", type: "enum", default: "png", settable: true, enumValues: IMAGE_FORMATS, help: "Rendered image format (embedded images keep their native extension)" },
|
|
90
93
|
{ key: "maxOutputBytes", flag: "--max-output-bytes", type: "int", default: 20000000, settable: true, help: "Child stdout cap in bytes" },
|
|
91
94
|
{ key: "outlineMaxEntries", flag: "--outline-max-entries", type: "int", default: 40, settable: true, help: "Heading outline / TOC / sheet inventory cap in the handle" },
|
|
92
95
|
{ key: "ocr", flag: "--ocr", type: "bool", default: false, settable: true, help: "Run OCR on pages without a text layer and on image inputs when Tesseract language data is installed; off by default (--no-ocr turns a settings-level true off)" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-quiver",
|
|
3
|
-
"version": "6.16.
|
|
3
|
+
"version": "6.16.1",
|
|
4
4
|
"description": "Personal pack of Pi coding-agent extensions: context-safe fetch, doc_to_md PDF/DOCX/PPTX-to-Markdown conversion, session naming, a themed ASCII startup header, Opus 4.8 fast mode, and a provider-stall watchdog.",
|
|
5
5
|
"author": "Jacek Juraszek",
|
|
6
6
|
"license": "MIT",
|