@effortlessmotion/pdf-to-md 0.1.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 (189) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/bin/cli.js +9 -0
  4. package/dist/cjs/analyze.d.cts +35 -0
  5. package/dist/cjs/analyze.d.ts +35 -0
  6. package/dist/cjs/analyze.js +620 -0
  7. package/dist/cjs/analyze.js.map +1 -0
  8. package/dist/cjs/audit.d.cts +38 -0
  9. package/dist/cjs/audit.d.ts +38 -0
  10. package/dist/cjs/audit.js +252 -0
  11. package/dist/cjs/audit.js.map +1 -0
  12. package/dist/cjs/cli/audit.d.cts +3 -0
  13. package/dist/cjs/cli/audit.d.ts +3 -0
  14. package/dist/cjs/cli/audit.js +269 -0
  15. package/dist/cjs/cli/audit.js.map +1 -0
  16. package/dist/cjs/cli/extract.d.cts +3 -0
  17. package/dist/cjs/cli/extract.d.ts +3 -0
  18. package/dist/cjs/cli/extract.js +704 -0
  19. package/dist/cjs/cli/extract.js.map +1 -0
  20. package/dist/cjs/cli/index.d.cts +5 -0
  21. package/dist/cjs/cli/index.d.ts +5 -0
  22. package/dist/cjs/cli/index.js +58 -0
  23. package/dist/cjs/cli/index.js.map +1 -0
  24. package/dist/cjs/cli/render.d.cts +3 -0
  25. package/dist/cjs/cli/render.d.ts +3 -0
  26. package/dist/cjs/cli/render.js +361 -0
  27. package/dist/cjs/cli/render.js.map +1 -0
  28. package/dist/cjs/cli/types.d.cts +10 -0
  29. package/dist/cjs/cli/types.d.ts +10 -0
  30. package/dist/cjs/cli/types.js +7 -0
  31. package/dist/cjs/cli/types.js.map +1 -0
  32. package/dist/cjs/cli.d.cts +2 -0
  33. package/dist/cjs/cli.d.ts +2 -0
  34. package/dist/cjs/cli.js +345 -0
  35. package/dist/cjs/cli.js.map +1 -0
  36. package/dist/cjs/collect.d.cts +6 -0
  37. package/dist/cjs/collect.d.ts +6 -0
  38. package/dist/cjs/collect.js +370 -0
  39. package/dist/cjs/collect.js.map +1 -0
  40. package/dist/cjs/dict.d.cts +8 -0
  41. package/dist/cjs/dict.d.ts +8 -0
  42. package/dist/cjs/dict.js +55 -0
  43. package/dist/cjs/dict.js.map +1 -0
  44. package/dist/cjs/emit.d.cts +27 -0
  45. package/dist/cjs/emit.d.ts +27 -0
  46. package/dist/cjs/emit.js +187 -0
  47. package/dist/cjs/emit.js.map +1 -0
  48. package/dist/cjs/engines/tesseract.d.cts +30 -0
  49. package/dist/cjs/engines/tesseract.d.ts +30 -0
  50. package/dist/cjs/engines/tesseract.js +650 -0
  51. package/dist/cjs/engines/tesseract.js.map +1 -0
  52. package/dist/cjs/errors.d.cts +21 -0
  53. package/dist/cjs/errors.d.ts +21 -0
  54. package/dist/cjs/errors.js +124 -0
  55. package/dist/cjs/errors.js.map +1 -0
  56. package/dist/cjs/extract.d.cts +88 -0
  57. package/dist/cjs/extract.d.ts +88 -0
  58. package/dist/cjs/extract.js +436 -0
  59. package/dist/cjs/extract.js.map +1 -0
  60. package/dist/cjs/geometry.d.cts +63 -0
  61. package/dist/cjs/geometry.d.ts +63 -0
  62. package/dist/cjs/geometry.js +521 -0
  63. package/dist/cjs/geometry.js.map +1 -0
  64. package/dist/cjs/index.d.cts +15 -0
  65. package/dist/cjs/index.d.ts +15 -0
  66. package/dist/cjs/index.js +56 -0
  67. package/dist/cjs/index.js.map +1 -0
  68. package/dist/cjs/lines.d.cts +3 -0
  69. package/dist/cjs/lines.d.ts +3 -0
  70. package/dist/cjs/lines.js +181 -0
  71. package/dist/cjs/lines.js.map +1 -0
  72. package/dist/cjs/markdown.d.cts +2 -0
  73. package/dist/cjs/markdown.d.ts +2 -0
  74. package/dist/cjs/markdown.js +222 -0
  75. package/dist/cjs/markdown.js.map +1 -0
  76. package/dist/cjs/package.json +1 -0
  77. package/dist/cjs/page-marker.d.cts +16 -0
  78. package/dist/cjs/page-marker.d.ts +16 -0
  79. package/dist/cjs/page-marker.js +85 -0
  80. package/dist/cjs/page-marker.js.map +1 -0
  81. package/dist/cjs/pdf-open.d.cts +12 -0
  82. package/dist/cjs/pdf-open.d.ts +12 -0
  83. package/dist/cjs/pdf-open.js +257 -0
  84. package/dist/cjs/pdf-open.js.map +1 -0
  85. package/dist/cjs/raster.d.cts +26 -0
  86. package/dist/cjs/raster.d.ts +26 -0
  87. package/dist/cjs/raster.js +262 -0
  88. package/dist/cjs/raster.js.map +1 -0
  89. package/dist/cjs/render-analysis.d.cts +25 -0
  90. package/dist/cjs/render-analysis.d.ts +25 -0
  91. package/dist/cjs/render-analysis.js +319 -0
  92. package/dist/cjs/render-analysis.js.map +1 -0
  93. package/dist/cjs/report.d.cts +12 -0
  94. package/dist/cjs/report.d.ts +12 -0
  95. package/dist/cjs/report.js +392 -0
  96. package/dist/cjs/report.js.map +1 -0
  97. package/dist/cjs/resolve.d.cts +1 -0
  98. package/dist/cjs/resolve.d.ts +1 -0
  99. package/dist/cjs/resolve.js +18 -0
  100. package/dist/cjs/resolve.js.map +1 -0
  101. package/dist/cjs/types.d.cts +171 -0
  102. package/dist/cjs/types.d.ts +171 -0
  103. package/dist/cjs/types.js +9 -0
  104. package/dist/cjs/types.js.map +1 -0
  105. package/dist/cjs/validate.d.cts +14 -0
  106. package/dist/cjs/validate.d.ts +14 -0
  107. package/dist/cjs/validate.js +96 -0
  108. package/dist/cjs/validate.js.map +1 -0
  109. package/dist/esm/analyze.d.ts +35 -0
  110. package/dist/esm/analyze.js +270 -0
  111. package/dist/esm/analyze.js.map +1 -0
  112. package/dist/esm/audit.d.ts +38 -0
  113. package/dist/esm/audit.js +113 -0
  114. package/dist/esm/audit.js.map +1 -0
  115. package/dist/esm/cli/audit.d.ts +3 -0
  116. package/dist/esm/cli/audit.js +20 -0
  117. package/dist/esm/cli/audit.js.map +1 -0
  118. package/dist/esm/cli/extract.d.ts +3 -0
  119. package/dist/esm/cli/extract.js +313 -0
  120. package/dist/esm/cli/extract.js.map +1 -0
  121. package/dist/esm/cli/index.d.ts +5 -0
  122. package/dist/esm/cli/index.js +7 -0
  123. package/dist/esm/cli/index.js.map +1 -0
  124. package/dist/esm/cli/render.d.ts +3 -0
  125. package/dist/esm/cli/render.js +77 -0
  126. package/dist/esm/cli/render.js.map +1 -0
  127. package/dist/esm/cli/types.d.ts +10 -0
  128. package/dist/esm/cli/types.js +3 -0
  129. package/dist/esm/cli/types.js.map +1 -0
  130. package/dist/esm/cli.d.ts +2 -0
  131. package/dist/esm/cli.js +90 -0
  132. package/dist/esm/cli.js.map +1 -0
  133. package/dist/esm/collect.d.ts +6 -0
  134. package/dist/esm/collect.js +80 -0
  135. package/dist/esm/collect.js.map +1 -0
  136. package/dist/esm/dict.d.ts +8 -0
  137. package/dist/esm/dict.js +28 -0
  138. package/dist/esm/dict.js.map +1 -0
  139. package/dist/esm/emit.d.ts +27 -0
  140. package/dist/esm/emit.js +131 -0
  141. package/dist/esm/emit.js.map +1 -0
  142. package/dist/esm/engines/tesseract.d.ts +30 -0
  143. package/dist/esm/engines/tesseract.js +190 -0
  144. package/dist/esm/engines/tesseract.js.map +1 -0
  145. package/dist/esm/errors.d.ts +21 -0
  146. package/dist/esm/errors.js +9 -0
  147. package/dist/esm/errors.js.map +1 -0
  148. package/dist/esm/extract.d.ts +88 -0
  149. package/dist/esm/extract.js +147 -0
  150. package/dist/esm/extract.js.map +1 -0
  151. package/dist/esm/geometry.d.ts +63 -0
  152. package/dist/esm/geometry.js +279 -0
  153. package/dist/esm/geometry.js.map +1 -0
  154. package/dist/esm/index.d.ts +15 -0
  155. package/dist/esm/index.js +10 -0
  156. package/dist/esm/index.js.map +1 -0
  157. package/dist/esm/lines.d.ts +3 -0
  158. package/dist/esm/lines.js +67 -0
  159. package/dist/esm/lines.js.map +1 -0
  160. package/dist/esm/markdown.d.ts +2 -0
  161. package/dist/esm/markdown.js +153 -0
  162. package/dist/esm/markdown.js.map +1 -0
  163. package/dist/esm/package.json +1 -0
  164. package/dist/esm/page-marker.d.ts +16 -0
  165. package/dist/esm/page-marker.js +40 -0
  166. package/dist/esm/page-marker.js.map +1 -0
  167. package/dist/esm/pdf-open.d.ts +12 -0
  168. package/dist/esm/pdf-open.js +61 -0
  169. package/dist/esm/pdf-open.js.map +1 -0
  170. package/dist/esm/raster.d.ts +26 -0
  171. package/dist/esm/raster.js +60 -0
  172. package/dist/esm/raster.js.map +1 -0
  173. package/dist/esm/render-analysis.d.ts +25 -0
  174. package/dist/esm/render-analysis.js +115 -0
  175. package/dist/esm/render-analysis.js.map +1 -0
  176. package/dist/esm/report.d.ts +12 -0
  177. package/dist/esm/report.js +182 -0
  178. package/dist/esm/report.js.map +1 -0
  179. package/dist/esm/resolve.d.ts +1 -0
  180. package/dist/esm/resolve.js +7 -0
  181. package/dist/esm/resolve.js.map +1 -0
  182. package/dist/esm/types.d.ts +171 -0
  183. package/dist/esm/types.js +6 -0
  184. package/dist/esm/types.js.map +1 -0
  185. package/dist/esm/validate.d.ts +14 -0
  186. package/dist/esm/validate.js +56 -0
  187. package/dist/esm/validate.js.map +1 -0
  188. package/package.json +67 -0
  189. package/skills/pdf-to-md/SKILL.md +102 -0
@@ -0,0 +1,38 @@
1
+ /** auditWords()'s result — the severity-1 no-silent-loss check. */
2
+ export interface AuditResult {
3
+ /** JSON lines successfully parsed from the word dump */
4
+ parsed: number;
5
+ /** lines in the dump that were not parseable JSON, skipped rather than
6
+ * failing the whole audit (same policy `--words-json` itself uses) */
7
+ nonJsonSkipped: number;
8
+ /** distinct page numbers present in the dump */
9
+ pages: number;
10
+ /** total recognized words across all pages in the dump */
11
+ words: number;
12
+ /** words present in the dump but not found verbatim on their page, BEFORE
13
+ * hyphen-join/split repair is applied; always `>= missing` */
14
+ strictDeficits: number;
15
+ /** words genuinely absent from the markdown after repair-checking; `0` is
16
+ * the only passing value (`pdf-to-md audit` exits 1 otherwise) */
17
+ missing: number;
18
+ /** per-page detail for every page with at least one missing word (capped
19
+ * sample of the missing tokens per page) */
20
+ perPage: {
21
+ page: number;
22
+ missing: string[];
23
+ }[];
24
+ /** the one-line `parsed=… pages=… words=… strict_deficits=… MISSING=…`
25
+ * summary, also the last entry of `lines` */
26
+ summaryLine: string;
27
+ /** every line `pdf-to-md audit` prints, in order: one per page with
28
+ * missing words, then `summaryLine` */
29
+ lines: string[];
30
+ }
31
+ /**
32
+ * Audit a --debug-words dump against a markdown file: every recognized word
33
+ * must land somewhere in its page's markdown. `result.missing === 0` is the pass/fail signal.
34
+ *
35
+ * @param wordsPath path to a --debug-words JSON-lines dump (`{page, text, ...}` per line)
36
+ * @param mdPath path to the markdown file to check the dump against
37
+ */
38
+ export declare function auditWords(wordsPath: string, mdPath: string): AuditResult;
@@ -0,0 +1,38 @@
1
+ /** auditWords()'s result — the severity-1 no-silent-loss check. */
2
+ export interface AuditResult {
3
+ /** JSON lines successfully parsed from the word dump */
4
+ parsed: number;
5
+ /** lines in the dump that were not parseable JSON, skipped rather than
6
+ * failing the whole audit (same policy `--words-json` itself uses) */
7
+ nonJsonSkipped: number;
8
+ /** distinct page numbers present in the dump */
9
+ pages: number;
10
+ /** total recognized words across all pages in the dump */
11
+ words: number;
12
+ /** words present in the dump but not found verbatim on their page, BEFORE
13
+ * hyphen-join/split repair is applied; always `>= missing` */
14
+ strictDeficits: number;
15
+ /** words genuinely absent from the markdown after repair-checking; `0` is
16
+ * the only passing value (`pdf-to-md audit` exits 1 otherwise) */
17
+ missing: number;
18
+ /** per-page detail for every page with at least one missing word (capped
19
+ * sample of the missing tokens per page) */
20
+ perPage: {
21
+ page: number;
22
+ missing: string[];
23
+ }[];
24
+ /** the one-line `parsed=… pages=… words=… strict_deficits=… MISSING=…`
25
+ * summary, also the last entry of `lines` */
26
+ summaryLine: string;
27
+ /** every line `pdf-to-md audit` prints, in order: one per page with
28
+ * missing words, then `summaryLine` */
29
+ lines: string[];
30
+ }
31
+ /**
32
+ * Audit a --debug-words dump against a markdown file: every recognized word
33
+ * must land somewhere in its page's markdown. `result.missing === 0` is the pass/fail signal.
34
+ *
35
+ * @param wordsPath path to a --debug-words JSON-lines dump (`{page, text, ...}` per line)
36
+ * @param mdPath path to the markdown file to check the dump against
37
+ */
38
+ export declare function auditWords(wordsPath: string, mdPath: string): AuditResult;
@@ -0,0 +1,252 @@
1
+ // audit.ts — the severity-1 audit instrument (README's "Design contract"),
2
+ // shipped as part of the product, not just a path into the source tree.
3
+ //
4
+ // Every recognized word (a --debug-words dump, or an Analysis page's
5
+ // `words`) must appear in its page's markdown — normalized, compared as a per-page multiset, with substring repair for hyphen joins.
6
+ //
7
+ // NOTE: no producer guarantees JSON key order in a --debug-words dump —
8
+ // parse, never grep.
9
+ "use strict";
10
+ Object.defineProperty(exports, "__esModule", {
11
+ value: true
12
+ });
13
+ Object.defineProperty(exports, "auditWords", {
14
+ enumerable: true,
15
+ get: function() {
16
+ return auditWords;
17
+ }
18
+ });
19
+ var _nodefs = require("node:fs");
20
+ var _pagemarkerts = require("./page-marker.js");
21
+ function _array_like_to_array(arr, len) {
22
+ if (len == null || len > arr.length) len = arr.length;
23
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
24
+ return arr2;
25
+ }
26
+ function _array_with_holes(arr) {
27
+ if (Array.isArray(arr)) return arr;
28
+ }
29
+ function _array_without_holes(arr) {
30
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
31
+ }
32
+ function _iterable_to_array(iter) {
33
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
34
+ return Array.from(iter);
35
+ }
36
+ }
37
+ function _iterable_to_array_limit(arr, i) {
38
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
39
+ if (_i == null) return;
40
+ var _arr = [];
41
+ var _n = true;
42
+ var _d = false;
43
+ var _s, _e;
44
+ try {
45
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
46
+ _arr.push(_s.value);
47
+ if (i && _arr.length === i) break;
48
+ }
49
+ } catch (err) {
50
+ _d = true;
51
+ _e = err;
52
+ } finally{
53
+ try {
54
+ if (!_n && _i["return"] != null) _i["return"]();
55
+ } finally{
56
+ if (_d) throw _e;
57
+ }
58
+ }
59
+ return _arr;
60
+ }
61
+ function _non_iterable_rest() {
62
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
63
+ }
64
+ function _non_iterable_spread() {
65
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
66
+ }
67
+ function _sliced_to_array(arr, i) {
68
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
69
+ }
70
+ function _to_consumable_array(arr) {
71
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
72
+ }
73
+ function _unsupported_iterable_to_array(o, minLen) {
74
+ if (!o) return;
75
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
76
+ var n = Object.prototype.toString.call(o).slice(8, -1);
77
+ if (n === "Object" && o.constructor) n = o.constructor.name;
78
+ if (n === "Map" || n === "Set") return Array.from(n);
79
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
80
+ }
81
+ function norm(s) {
82
+ return s.normalize('NFKD').replace(RegExp("[\\u0300-\\u036F\\u0483-\\u0489\\u0591-\\u05BD\\u05BF\\u05C1-\\u05C2\\u05C4-\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065F\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7-\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u07FD\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0859-\\u085B\\u0897-\\u089F\\u08CA-\\u08E1\\u08E3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1062-\\u1064\\u1067-\\u106D\\u1071-\\u1074\\u1082-\\u108D\\u108F\\u109A-\\u109D\\u135D-\\u135F\\u1712-\\u1715\\u1732-\\u1734\\u1752-\\u1753\\u1772-\\u1773\\u17B4-\\u17D3\\u17DD\\u180B-\\u180D\\u180F\\u1885-\\u1886\\u18A9\\u1920-\\u192B\\u1930-\\u193B\\u1A17-\\u1A1B\\u1A55-\\u1A5E\\u1A60-\\u1A7C\\u1A7F\\u1AB0-\\u1ADD\\u1AE0-\\u1AEB\\u1B00-\\u1B04\\u1B34-\\u1B44\\u1B6B-\\u1B73\\u1B80-\\u1B82\\u1BA1-\\u1BAD\\u1BE6-\\u1BF3\\u1C24-\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE8\\u1CED\\u1CF4\\u1CF7-\\u1CF9\\u1DC0-\\u1DFF\\u20D0-\\u20F0\\u2CEF-\\u2CF1\\u2D7F\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099-\\u309A\\uA66F-\\uA672\\uA674-\\uA67D\\uA69E-\\uA69F\\uA6F0-\\uA6F1\\uA802\\uA806\\uA80B\\uA823-\\uA827\\uA82C\\uA880-\\uA881\\uA8B4-\\uA8C5\\uA8E0-\\uA8F1\\uA8FF\\uA926-\\uA92D\\uA947-\\uA953\\uA980-\\uA983\\uA9B3-\\uA9C0\\uA9E5\\uAA29-\\uAA36\\uAA43\\uAA4C-\\uAA4D\\uAA7B-\\uAA7D\\uAAB0\\uAAB2-\\uAAB4\\uAAB7-\\uAAB8\\uAABE-\\uAABF\\uAAC1\\uAAEB-\\uAAEF\\uAAF5-\\uAAF6\\uABE3-\\uABEA\\uABEC-\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE2F\\u{101FD}\\u{102E0}\\u{10376}-\\u{1037A}\\u{10A01}-\\u{10A03}\\u{10A05}-\\u{10A06}\\u{10A0C}-\\u{10A0F}\\u{10A38}-\\u{10A3A}\\u{10A3F}\\u{10AE5}-\\u{10AE6}\\u{10D24}-\\u{10D27}\\u{10D69}-\\u{10D6D}\\u{10EAB}-\\u{10EAC}\\u{10EFA}-\\u{10EFF}\\u{10F46}-\\u{10F50}\\u{10F82}-\\u{10F85}\\u{11000}-\\u{11002}\\u{11038}-\\u{11046}\\u{11070}\\u{11073}-\\u{11074}\\u{1107F}-\\u{11082}\\u{110B0}-\\u{110BA}\\u{110C2}\\u{11100}-\\u{11102}\\u{11127}-\\u{11134}\\u{11145}-\\u{11146}\\u{11173}\\u{11180}-\\u{11182}\\u{111B3}-\\u{111C0}\\u{111C9}-\\u{111CC}\\u{111CE}-\\u{111CF}\\u{1122C}-\\u{11237}\\u{1123E}\\u{11241}\\u{112DF}-\\u{112EA}\\u{11300}-\\u{11303}\\u{1133B}-\\u{1133C}\\u{1133E}-\\u{11344}\\u{11347}-\\u{11348}\\u{1134B}-\\u{1134D}\\u{11357}\\u{11362}-\\u{11363}\\u{11366}-\\u{1136C}\\u{11370}-\\u{11374}\\u{113B8}-\\u{113C0}\\u{113C2}\\u{113C5}\\u{113C7}-\\u{113CA}\\u{113CC}-\\u{113D0}\\u{113D2}\\u{113E1}-\\u{113E2}\\u{11435}-\\u{11446}\\u{1145E}\\u{114B0}-\\u{114C3}\\u{115AF}-\\u{115B5}\\u{115B8}-\\u{115C0}\\u{115DC}-\\u{115DD}\\u{11630}-\\u{11640}\\u{116AB}-\\u{116B7}\\u{1171D}-\\u{1172B}\\u{1182C}-\\u{1183A}\\u{11930}-\\u{11935}\\u{11937}-\\u{11938}\\u{1193B}-\\u{1193E}\\u{11940}\\u{11942}-\\u{11943}\\u{119D1}-\\u{119D7}\\u{119DA}-\\u{119E0}\\u{119E4}\\u{11A01}-\\u{11A0A}\\u{11A33}-\\u{11A39}\\u{11A3B}-\\u{11A3E}\\u{11A47}\\u{11A51}-\\u{11A5B}\\u{11A8A}-\\u{11A99}\\u{11B60}-\\u{11B67}\\u{11C2F}-\\u{11C36}\\u{11C38}-\\u{11C3F}\\u{11C92}-\\u{11CA7}\\u{11CA9}-\\u{11CB6}\\u{11D31}-\\u{11D36}\\u{11D3A}\\u{11D3C}-\\u{11D3D}\\u{11D3F}-\\u{11D45}\\u{11D47}\\u{11D8A}-\\u{11D8E}\\u{11D90}-\\u{11D91}\\u{11D93}-\\u{11D97}\\u{11EF3}-\\u{11EF6}\\u{11F00}-\\u{11F01}\\u{11F03}\\u{11F34}-\\u{11F3A}\\u{11F3E}-\\u{11F42}\\u{11F5A}\\u{13440}\\u{13447}-\\u{13455}\\u{1611E}-\\u{1612F}\\u{16AF0}-\\u{16AF4}\\u{16B30}-\\u{16B36}\\u{16F4F}\\u{16F51}-\\u{16F87}\\u{16F8F}-\\u{16F92}\\u{16FE4}\\u{16FF0}-\\u{16FF1}\\u{1BC9D}-\\u{1BC9E}\\u{1CF00}-\\u{1CF2D}\\u{1CF30}-\\u{1CF46}\\u{1D165}-\\u{1D169}\\u{1D16D}-\\u{1D172}\\u{1D17B}-\\u{1D182}\\u{1D185}-\\u{1D18B}\\u{1D1AA}-\\u{1D1AD}\\u{1D242}-\\u{1D244}\\u{1DA00}-\\u{1DA36}\\u{1DA3B}-\\u{1DA6C}\\u{1DA75}\\u{1DA84}\\u{1DA9B}-\\u{1DA9F}\\u{1DAA1}-\\u{1DAAF}\\u{1E000}-\\u{1E006}\\u{1E008}-\\u{1E018}\\u{1E01B}-\\u{1E021}\\u{1E023}-\\u{1E024}\\u{1E026}-\\u{1E02A}\\u{1E08F}\\u{1E130}-\\u{1E136}\\u{1E2AE}\\u{1E2EC}-\\u{1E2EF}\\u{1E4EC}-\\u{1E4EF}\\u{1E5EE}-\\u{1E5EF}\\u{1E6E3}\\u{1E6E6}\\u{1E6EE}-\\u{1E6EF}\\u{1E6F5}\\u{1E8D0}-\\u{1E8D6}\\u{1E944}-\\u{1E94A}\\u{E0100}-\\u{E01EF}]", "gu"), '').toLowerCase().replace(/[^a-z0-9]/g, '');
83
+ }
84
+ function counter(items) {
85
+ var _m_get;
86
+ var m = new Map();
87
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
88
+ try {
89
+ for(var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
90
+ var item = _step.value;
91
+ m.set(item, ((_m_get = m.get(item)) !== null && _m_get !== void 0 ? _m_get : 0) + 1);
92
+ }
93
+ } catch (err) {
94
+ _didIteratorError = true;
95
+ _iteratorError = err;
96
+ } finally{
97
+ try {
98
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
99
+ _iterator.return();
100
+ }
101
+ } finally{
102
+ if (_didIteratorError) {
103
+ throw _iteratorError;
104
+ }
105
+ }
106
+ }
107
+ return m;
108
+ }
109
+ function auditWords(wordsPath, mdPath) {
110
+ var rec = new Map();
111
+ var parsed = 0;
112
+ var skipped = 0;
113
+ var wordsRaw = (0, _nodefs.readFileSync)(wordsPath, 'utf8');
114
+ // A trailing "\n" at EOF must not yield a spurious final empty line; a
115
+ // genuine blank line mid-file does count, as skipped.
116
+ var rawLines = wordsRaw.split('\n');
117
+ if (rawLines.length > 0 && rawLines[rawLines.length - 1] === '') rawLines.pop();
118
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
119
+ try {
120
+ for(var _iterator = rawLines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
121
+ var line = _step.value;
122
+ line = line.trim();
123
+ if (!line.startsWith('{')) {
124
+ skipped++;
125
+ continue;
126
+ }
127
+ var o = void 0;
128
+ try {
129
+ o = JSON.parse(line);
130
+ } catch (unused) {
131
+ skipped++;
132
+ continue;
133
+ }
134
+ parsed++;
135
+ var t = norm(o.text);
136
+ if (t) {
137
+ var arr = rec.get(o.page);
138
+ if (arr) arr.push(t);
139
+ else rec.set(o.page, [
140
+ t
141
+ ]);
142
+ }
143
+ }
144
+ } catch (err) {
145
+ _didIteratorError = true;
146
+ _iteratorError = err;
147
+ } finally{
148
+ try {
149
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
150
+ _iterator.return();
151
+ }
152
+ } finally{
153
+ if (_didIteratorError) {
154
+ throw _iteratorError;
155
+ }
156
+ }
157
+ }
158
+ var md = (0, _nodefs.readFileSync)(mdPath, 'utf8');
159
+ var out = (0, _pagemarkerts.bodyByPage)(md);
160
+ var lines = [];
161
+ var total = 0;
162
+ var strict = 0;
163
+ var perPage = [];
164
+ var pages = _to_consumable_array(rec.keys()).sort(function(a, b) {
165
+ return a - b;
166
+ });
167
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
168
+ try {
169
+ for(var _iterator1 = pages[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
170
+ var page = _step1.value;
171
+ var _ref, _rec_get;
172
+ var _out_get;
173
+ var toks = ((_ref = (_out_get = out.get(page)) === null || _out_get === void 0 ? void 0 : _out_get.match(/\S+/g)) !== null && _ref !== void 0 ? _ref : []).map(norm).filter(function(t) {
174
+ return t.length > 0;
175
+ });
176
+ var ms = counter(toks);
177
+ var joined = toks.join('');
178
+ var missing = [];
179
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
180
+ try {
181
+ for(var _iterator2 = counter((_rec_get = rec.get(page)) !== null && _rec_get !== void 0 ? _rec_get : [])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
182
+ var _step_value = _sliced_to_array(_step2.value, 2), tok = _step_value[0], n = _step_value[1];
183
+ var _ms_get;
184
+ var d = n - ((_ms_get = ms.get(tok)) !== null && _ms_get !== void 0 ? _ms_get : 0);
185
+ if (d <= 0) continue;
186
+ strict += d;
187
+ if (joined.includes(tok)) continue; // hyphen-join / split repair
188
+ for(var i = 0; i < d; i++)missing.push(tok);
189
+ }
190
+ } catch (err) {
191
+ _didIteratorError2 = true;
192
+ _iteratorError2 = err;
193
+ } finally{
194
+ try {
195
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
196
+ _iterator2.return();
197
+ }
198
+ } finally{
199
+ if (_didIteratorError2) {
200
+ throw _iteratorError2;
201
+ }
202
+ }
203
+ }
204
+ if (missing.length > 0) {
205
+ total += missing.length;
206
+ perPage.push({
207
+ page: page,
208
+ missing: missing
209
+ });
210
+ lines.push("p".concat(page, ": MISSING ").concat(missing.length, ": ").concat(pyRepr(missing.slice(0, 12))));
211
+ }
212
+ }
213
+ } catch (err) {
214
+ _didIteratorError1 = true;
215
+ _iteratorError1 = err;
216
+ } finally{
217
+ try {
218
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
219
+ _iterator1.return();
220
+ }
221
+ } finally{
222
+ if (_didIteratorError1) {
223
+ throw _iteratorError1;
224
+ }
225
+ }
226
+ }
227
+ var words = pages.reduce(function(sum, p) {
228
+ var _ref;
229
+ var _rec_get;
230
+ return sum + ((_ref = (_rec_get = rec.get(p)) === null || _rec_get === void 0 ? void 0 : _rec_get.length) !== null && _ref !== void 0 ? _ref : 0);
231
+ }, 0);
232
+ var summaryLine = "parsed=".concat(parsed, " non-json-skipped=").concat(skipped, " pages=").concat(rec.size, " words=").concat(words, " strict_deficits=").concat(strict, " MISSING=").concat(total);
233
+ lines.push(summaryLine);
234
+ return {
235
+ parsed: parsed,
236
+ nonJsonSkipped: skipped,
237
+ pages: rec.size,
238
+ words: words,
239
+ strictDeficits: strict,
240
+ missing: total,
241
+ perPage: perPage,
242
+ summaryLine: summaryLine,
243
+ lines: lines
244
+ };
245
+ }
246
+ // Renders a string list as ['a', 'b'] (single-quoted) to match frozen baseline comparisons byte-for-byte.
247
+ function pyRepr(items) {
248
+ return "[".concat(items.map(function(s) {
249
+ return "'".concat(s.replace(/\\/g, '\\\\').replace(/'/g, "\\'"), "'");
250
+ }).join(', '), "]");
251
+ }
252
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Projects/pdf-to-md/src/audit.ts"],"sourcesContent":["// audit.ts — the severity-1 audit instrument (README's \"Design contract\"),\n// shipped as part of the product, not just a path into the source tree.\n//\n// Every recognized word (a --debug-words dump, or an Analysis page's\n// `words`) must appear in its page's markdown — normalized, compared as a per-page multiset, with substring repair for hyphen joins.\n//\n// NOTE: no producer guarantees JSON key order in a --debug-words dump —\n// parse, never grep.\nimport { readFileSync } from 'node:fs';\nimport { bodyByPage } from './page-marker.ts';\n\nfunction norm(s: string): string {\n return s\n .normalize('NFKD')\n .replace(/\\p{M}/gu, '')\n .toLowerCase()\n .replace(/[^a-z0-9]/g, '');\n}\n\nfunction counter(items: Iterable<string>): Map<string, number> {\n const m = new Map<string, number>();\n for (const item of items) m.set(item, (m.get(item) ?? 0) + 1);\n return m;\n}\n\n/** auditWords()'s result — the severity-1 no-silent-loss check. */\nexport interface AuditResult {\n /** JSON lines successfully parsed from the word dump */\n parsed: number;\n /** lines in the dump that were not parseable JSON, skipped rather than\n * failing the whole audit (same policy `--words-json` itself uses) */\n nonJsonSkipped: number;\n /** distinct page numbers present in the dump */\n pages: number;\n /** total recognized words across all pages in the dump */\n words: number;\n /** words present in the dump but not found verbatim on their page, BEFORE\n * hyphen-join/split repair is applied; always `>= missing` */\n strictDeficits: number;\n /** words genuinely absent from the markdown after repair-checking; `0` is\n * the only passing value (`pdf-to-md audit` exits 1 otherwise) */\n missing: number;\n /** per-page detail for every page with at least one missing word (capped\n * sample of the missing tokens per page) */\n perPage: { page: number; missing: string[] }[];\n /** the one-line `parsed=… pages=… words=… strict_deficits=… MISSING=…`\n * summary, also the last entry of `lines` */\n summaryLine: string;\n /** every line `pdf-to-md audit` prints, in order: one per page with\n * missing words, then `summaryLine` */\n lines: string[];\n}\n\n/**\n * Audit a --debug-words dump against a markdown file: every recognized word\n * must land somewhere in its page's markdown. `result.missing === 0` is the pass/fail signal.\n *\n * @param wordsPath path to a --debug-words JSON-lines dump (`{page, text, ...}` per line)\n * @param mdPath path to the markdown file to check the dump against\n */\nexport function auditWords(wordsPath: string, mdPath: string): AuditResult {\n const rec = new Map<number, string[]>();\n let parsed = 0;\n let skipped = 0;\n\n const wordsRaw = readFileSync(wordsPath, 'utf8');\n // A trailing \"\\n\" at EOF must not yield a spurious final empty line; a\n // genuine blank line mid-file does count, as skipped.\n const rawLines = wordsRaw.split('\\n');\n if (rawLines.length > 0 && rawLines[rawLines.length - 1] === '') rawLines.pop();\n for (let line of rawLines) {\n line = line.trim();\n if (!line.startsWith('{')) {\n skipped++;\n continue;\n }\n let o: { page: number; text: string };\n try {\n o = JSON.parse(line);\n } catch {\n skipped++;\n continue;\n }\n parsed++;\n const t = norm(o.text);\n if (t) {\n const arr = rec.get(o.page);\n if (arr) arr.push(t);\n else rec.set(o.page, [t]);\n }\n }\n\n const md = readFileSync(mdPath, 'utf8');\n const out = bodyByPage(md);\n\n const lines: string[] = [];\n let total = 0;\n let strict = 0;\n const perPage: { page: number; missing: string[] }[] = [];\n const pages = [...rec.keys()].sort((a, b) => a - b);\n\n for (const page of pages) {\n const toks = (out.get(page)?.match(/\\S+/g) ?? []).map(norm).filter((t) => t.length > 0);\n const ms = counter(toks);\n const joined = toks.join('');\n const missing: string[] = [];\n for (const [tok, n] of counter(rec.get(page) ?? [])) {\n const d = n - (ms.get(tok) ?? 0);\n if (d <= 0) continue;\n strict += d;\n if (joined.includes(tok)) continue; // hyphen-join / split repair\n for (let i = 0; i < d; i++) missing.push(tok);\n }\n if (missing.length > 0) {\n total += missing.length;\n perPage.push({ page, missing });\n lines.push(`p${page}: MISSING ${missing.length}: ${pyRepr(missing.slice(0, 12))}`);\n }\n }\n\n const words = pages.reduce((sum, p) => sum + (rec.get(p)?.length ?? 0), 0);\n const summaryLine = `parsed=${parsed} non-json-skipped=${skipped} pages=${rec.size} words=${words} strict_deficits=${strict} MISSING=${total}`;\n lines.push(summaryLine);\n\n return {\n parsed,\n nonJsonSkipped: skipped,\n pages: rec.size,\n words,\n strictDeficits: strict,\n missing: total,\n perPage,\n summaryLine,\n lines,\n };\n}\n\n// Renders a string list as ['a', 'b'] (single-quoted) to match frozen baseline comparisons byte-for-byte.\nfunction pyRepr(items: string[]): string {\n return `[${items.map((s) => `'${s.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`).join(', ')}]`;\n}\n"],"names":["auditWords","norm","s","normalize","replace","toLowerCase","counter","items","m","Map","item","set","get","wordsPath","mdPath","rec","parsed","skipped","wordsRaw","readFileSync","rawLines","split","length","pop","line","trim","startsWith","o","JSON","parse","t","text","arr","page","push","md","out","bodyByPage","lines","total","strict","perPage","pages","keys","sort","a","b","toks","match","map","filter","ms","joined","join","missing","tok","n","d","includes","i","pyRepr","slice","words","reduce","sum","p","summaryLine","size","nonJsonSkipped","strictDeficits"],"mappings":"AAAA,2EAA2E;AAC3E,wEAAwE;AACxE,EAAE;AACF,qEAAqE;AACrE,qIAAqI;AACrI,EAAE;AACF,wEAAwE;AACxE,qBAAqB;;;;;+BAqDLA;;;eAAAA;;;sBApDa;4BACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3B,SAASC,KAAKC,CAAS;IACrB,OAAOA,EACJC,SAAS,CAAC,QACVC,OAAO,CAAC,27JAAW,IACnBC,WAAW,GACXD,OAAO,CAAC,cAAc;AAC3B;AAEA,SAASE,QAAQC,KAAuB;QAECC;IADvC,IAAMA,IAAI,IAAIC;QACT,kCAAA,2BAAA;;QAAL,QAAK,YAAcF,0BAAd,SAAA,6BAAA,QAAA,yBAAA;YAAA,IAAMG,OAAN;YAAqBF,EAAEG,GAAG,CAACD,MAAM,EAACF,SAAAA,EAAEI,GAAG,CAACF,mBAANF,oBAAAA,SAAe,KAAK;;;QAAtD;QAAA;;;iBAAA,6BAAA;gBAA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K;QAAA;;;iBAAA,8BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAmBL,IAAMC,QAAQpB,MAAMqB,MAAM,CAAC,SAACC,KAAKC;;YAAalD;eAAPiD,gBAAOjD,WAAAA,IAAIH,GAAG,CAACqD,gBAARlD,+BAAAA,SAAYO,MAAM,uCAAI;OAAI;IACxE,IAAM4C,cAAc,AAAC,UAAoCjD,OAA3BD,QAAO,sBAAqCD,OAAjBE,SAAQ,WAA2B6C,OAAlB/C,IAAIoD,IAAI,EAAC,WAAkC3B,OAAzBsB,OAAM,qBAAqCvB,OAAlBC,QAAO,aAAiB,OAAND;IACvID,MAAMJ,IAAI,CAACgC;IAEX,OAAO;QACLlD,QAAAA;QACAoD,gBAAgBnD;QAChByB,OAAO3B,IAAIoD,IAAI;QACfL,OAAAA;QACAO,gBAAgB7B;QAChBc,SAASf;QACTE,SAAAA;QACAyB,aAAAA;QACA5B,OAAAA;IACF;AACF;AAEA,0GAA0G;AAC1G,SAASsB,OAAOrD,KAAe;IAC7B,OAAO,AAAC,IAAqF,OAAlFA,MAAM0C,GAAG,CAAC,SAAC/C;eAAM,AAAC,IAAiD,OAA9CA,EAAEE,OAAO,CAAC,OAAO,QAAQA,OAAO,CAAC,MAAM,QAAO;OAAIiD,IAAI,CAAC,OAAM;AAC/F"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from './types.js';
2
+ declare const audit: Command;
3
+ export default audit;
@@ -0,0 +1,3 @@
1
+ import type { Command } from './types.js';
2
+ declare const audit: Command;
3
+ export default audit;
@@ -0,0 +1,269 @@
1
+ // audit command — the severity-1 audit instrument (README's "Design
2
+ // contract") as a first-class subcommand. Thin wrapper over src/audit.ts's auditWords (the library returns data, only the CLI prints and exits).
3
+ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function() {
10
+ return _default;
11
+ }
12
+ });
13
+ function _array_like_to_array(arr, len) {
14
+ if (len == null || len > arr.length) len = arr.length;
15
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
16
+ return arr2;
17
+ }
18
+ function _array_with_holes(arr) {
19
+ if (Array.isArray(arr)) return arr;
20
+ }
21
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
22
+ try {
23
+ var info = gen[key](arg);
24
+ var value = info.value;
25
+ } catch (error) {
26
+ reject(error);
27
+ return;
28
+ }
29
+ if (info.done) resolve(value);
30
+ else Promise.resolve(value).then(_next, _throw);
31
+ }
32
+ function _async_to_generator(fn) {
33
+ return function() {
34
+ var self = this, args = arguments;
35
+ return new Promise(function(resolve, reject) {
36
+ var gen = fn.apply(self, args);
37
+ function _next(value) {
38
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
39
+ }
40
+ function _throw(err) {
41
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
42
+ }
43
+ _next(undefined);
44
+ });
45
+ };
46
+ }
47
+ function _getRequireWildcardCache(nodeInterop) {
48
+ if (typeof WeakMap !== "function") return null;
49
+ var cacheBabelInterop = new WeakMap();
50
+ var cacheNodeInterop = new WeakMap();
51
+ return (_getRequireWildcardCache = function(nodeInterop) {
52
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
53
+ })(nodeInterop);
54
+ }
55
+ function _interop_require_wildcard(obj, nodeInterop) {
56
+ if (!nodeInterop && obj && obj.__esModule) return obj;
57
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
58
+ default: obj
59
+ };
60
+ var cache = _getRequireWildcardCache(nodeInterop);
61
+ if (cache && cache.has(obj)) return cache.get(obj);
62
+ var newObj = {
63
+ __proto__: null
64
+ };
65
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
66
+ for(var key in obj){
67
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
68
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
69
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
70
+ else newObj[key] = obj[key];
71
+ }
72
+ }
73
+ newObj.default = obj;
74
+ if (cache) cache.set(obj, newObj);
75
+ return newObj;
76
+ }
77
+ function _iterable_to_array_limit(arr, i) {
78
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
79
+ if (_i == null) return;
80
+ var _arr = [];
81
+ var _n = true;
82
+ var _d = false;
83
+ var _s, _e;
84
+ try {
85
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
86
+ _arr.push(_s.value);
87
+ if (i && _arr.length === i) break;
88
+ }
89
+ } catch (err) {
90
+ _d = true;
91
+ _e = err;
92
+ } finally{
93
+ try {
94
+ if (!_n && _i["return"] != null) _i["return"]();
95
+ } finally{
96
+ if (_d) throw _e;
97
+ }
98
+ }
99
+ return _arr;
100
+ }
101
+ function _non_iterable_rest() {
102
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
103
+ }
104
+ function _sliced_to_array(arr, i) {
105
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
106
+ }
107
+ function _ts_generator(thisArg, body) {
108
+ var f, y, t, _ = {
109
+ label: 0,
110
+ sent: function() {
111
+ if (t[0] & 1) throw t[1];
112
+ return t[1];
113
+ },
114
+ trys: [],
115
+ ops: []
116
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
117
+ return d(g, "next", {
118
+ value: verb(0)
119
+ }), d(g, "throw", {
120
+ value: verb(1)
121
+ }), d(g, "return", {
122
+ value: verb(2)
123
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
124
+ value: function() {
125
+ return this;
126
+ }
127
+ }), g;
128
+ function verb(n) {
129
+ return function(v) {
130
+ return step([
131
+ n,
132
+ v
133
+ ]);
134
+ };
135
+ }
136
+ function step(op) {
137
+ if (f) throw new TypeError("Generator is already executing.");
138
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
139
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
140
+ if (y = 0, t) op = [
141
+ op[0] & 2,
142
+ t.value
143
+ ];
144
+ switch(op[0]){
145
+ case 0:
146
+ case 1:
147
+ t = op;
148
+ break;
149
+ case 4:
150
+ _.label++;
151
+ return {
152
+ value: op[1],
153
+ done: false
154
+ };
155
+ case 5:
156
+ _.label++;
157
+ y = op[1];
158
+ op = [
159
+ 0
160
+ ];
161
+ continue;
162
+ case 7:
163
+ op = _.ops.pop();
164
+ _.trys.pop();
165
+ continue;
166
+ default:
167
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
168
+ _ = 0;
169
+ continue;
170
+ }
171
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
172
+ _.label = op[1];
173
+ break;
174
+ }
175
+ if (op[0] === 6 && _.label < t[1]) {
176
+ _.label = t[1];
177
+ t = op;
178
+ break;
179
+ }
180
+ if (t && _.label < t[2]) {
181
+ _.label = t[2];
182
+ _.ops.push(op);
183
+ break;
184
+ }
185
+ if (t[2]) _.ops.pop();
186
+ _.trys.pop();
187
+ continue;
188
+ }
189
+ op = body.call(thisArg, _);
190
+ } catch (e) {
191
+ op = [
192
+ 6,
193
+ e
194
+ ];
195
+ y = 0;
196
+ } finally{
197
+ f = t = 0;
198
+ }
199
+ if (op[0] & 5) throw op[1];
200
+ return {
201
+ value: op[0] ? op[1] : void 0,
202
+ done: true
203
+ };
204
+ }
205
+ }
206
+ function _unsupported_iterable_to_array(o, minLen) {
207
+ if (!o) return;
208
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
209
+ var n = Object.prototype.toString.call(o).slice(8, -1);
210
+ if (n === "Object" && o.constructor) n = o.constructor.name;
211
+ if (n === "Map" || n === "Set") return Array.from(n);
212
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
213
+ }
214
+ var USAGE = 'usage: pdf-to-md audit <words.jsonl> <file.md>';
215
+ var audit = function audit(ctx) {
216
+ return _async_to_generator(function() {
217
+ var _ctx_rest, wordsPath, mdPath, auditWords, result, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, line;
218
+ return _ts_generator(this, function(_state) {
219
+ switch(_state.label){
220
+ case 0:
221
+ if (ctx.rest.includes('-h') || ctx.rest.includes('--help')) {
222
+ console.log(USAGE);
223
+ return [
224
+ 2
225
+ ];
226
+ }
227
+ _ctx_rest = _sliced_to_array(ctx.rest, 2), wordsPath = _ctx_rest[0], mdPath = _ctx_rest[1];
228
+ if (!wordsPath || !mdPath) ctx.usageError(USAGE);
229
+ return [
230
+ 4,
231
+ Promise.resolve().then(function() {
232
+ return /*#__PURE__*/ _interop_require_wildcard(require("../audit.js"));
233
+ })
234
+ ];
235
+ case 1:
236
+ auditWords = _state.sent().auditWords;
237
+ result = auditWords(wordsPath, mdPath);
238
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
239
+ try {
240
+ for(_iterator = result.lines[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
241
+ line = _step.value;
242
+ console.log(line);
243
+ }
244
+ } catch (err) {
245
+ _didIteratorError = true;
246
+ _iteratorError = err;
247
+ } finally{
248
+ try {
249
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
250
+ _iterator.return();
251
+ }
252
+ } finally{
253
+ if (_didIteratorError) {
254
+ throw _iteratorError;
255
+ }
256
+ }
257
+ }
258
+ // MISSING>0 is the severity-1 fail signal: a recognized word this markdown
259
+ // lost. Exit 1 so the subcommand is usable as a CI gate; strict_deficits from hyphen-join repairs are reported but not failures.
260
+ if (result.missing > 0) process.exitCode = 1;
261
+ return [
262
+ 2
263
+ ];
264
+ }
265
+ });
266
+ })();
267
+ };
268
+ var _default = audit;
269
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Projects/pdf-to-md/src/cli/audit.ts"],"sourcesContent":["// audit command — the severity-1 audit instrument (README's \"Design\n// contract\") as a first-class subcommand. Thin wrapper over src/audit.ts's auditWords (the library returns data, only the CLI prints and exits).\nimport type { Command } from './types.ts';\n\nconst USAGE = 'usage: pdf-to-md audit <words.jsonl> <file.md>';\n\nconst audit: Command = async (ctx) => {\n if (ctx.rest.includes('-h') || ctx.rest.includes('--help')) {\n console.log(USAGE);\n return;\n }\n const [wordsPath, mdPath] = ctx.rest;\n if (!wordsPath || !mdPath) ctx.usageError(USAGE);\n\n // Imported here, not at module top, same lazy-load rule as every other\n // command — `pdf-to-md audit` should never pay for what the other commands need.\n const { auditWords } = await import('../audit.ts');\n const result = auditWords(wordsPath, mdPath);\n for (const line of result.lines) console.log(line);\n\n // MISSING>0 is the severity-1 fail signal: a recognized word this markdown\n // lost. Exit 1 so the subcommand is usable as a CI gate; strict_deficits from hyphen-join repairs are reported but not failures.\n if (result.missing > 0) process.exitCode = 1;\n};\n\nexport default audit;\n"],"names":["USAGE","audit","ctx","wordsPath","mdPath","auditWords","result","line","rest","includes","console","log","usageError","lines","missing","process","exitCode"],"mappings":"AAAA,oEAAoE;AACpE,iJAAiJ;;;;;+BAwBjJ;;;eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AArBA,IAAMA,QAAQ;AAEd,IAAMC,QAAiB,eAAOC;;YAKAA,WAArBC,WAAWC,QAKVC,YACFC,QACD,2BAAA,mBAAA,gBAAA,WAAA,OAAMC;;;;oBAXX,IAAIL,IAAIM,IAAI,CAACC,QAAQ,CAAC,SAASP,IAAIM,IAAI,CAACC,QAAQ,CAAC,WAAW;wBAC1DC,QAAQC,GAAG,CAACX;wBACZ;;;oBACF;oBAC4BE,6BAAAA,IAAIM,IAAI,MAA7BL,YAAqBD,cAAVE,SAAUF;oBAC5B,IAAI,CAACC,aAAa,CAACC,QAAQF,IAAIU,UAAU,CAACZ;oBAInB;;wBAAM;2EAAA,QAAO;;;;oBAA5BK,aAAe,cAAfA;oBACFC,SAASD,WAAWF,WAAWC;oBAChC,kCAAA,2BAAA;;wBAAL,IAAK,YAAcE,OAAOO,KAAK,uBAA1B,6BAAA,QAAA,yBAAA;4BAAMN,OAAN;4BAA4BG,QAAQC,GAAG,CAACJ;;;wBAAxC;wBAAA;;;iCAAA,6BAAA;gCAAA;;;gCAAA;sCAAA;;;;oBAEL,2EAA2E;oBAC3E,iIAAiI;oBACjI,IAAID,OAAOQ,OAAO,GAAG,GAAGC,QAAQC,QAAQ,GAAG;;;;;;IAC7C;;IAEA,WAAef"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from './types.js';
2
+ declare const extract: Command;
3
+ export default extract;
@@ -0,0 +1,3 @@
1
+ import type { Command } from './types.js';
2
+ declare const extract: Command;
3
+ export default extract;