@intentic/fileq 1.317.0 → 1.318.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 (111) hide show
  1. package/NOTICE +208 -0
  2. package/README.md +24 -3
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +15 -1
  5. package/dist/app.js.map +1 -1
  6. package/dist/commands/check.command.d.ts +3 -0
  7. package/dist/commands/check.command.d.ts.map +1 -0
  8. package/dist/commands/check.command.js +80 -0
  9. package/dist/commands/check.command.js.map +1 -0
  10. package/dist/commands/render.command.d.ts +3 -0
  11. package/dist/commands/render.command.d.ts.map +1 -0
  12. package/dist/commands/render.command.js +67 -0
  13. package/dist/commands/render.command.js.map +1 -0
  14. package/dist/lib/check/check.d.ts +15 -0
  15. package/dist/lib/check/check.d.ts.map +1 -0
  16. package/dist/lib/check/check.js +35 -0
  17. package/dist/lib/check/check.js.map +1 -0
  18. package/dist/lib/check/docx.d.ts +3 -0
  19. package/dist/lib/check/docx.d.ts.map +1 -0
  20. package/dist/lib/check/docx.js +329 -0
  21. package/dist/lib/check/docx.js.map +1 -0
  22. package/dist/lib/check/finding.d.ts +20 -0
  23. package/dist/lib/check/finding.d.ts.map +1 -0
  24. package/dist/lib/check/finding.js +27 -0
  25. package/dist/lib/check/finding.js.map +1 -0
  26. package/dist/lib/check/package.d.ts +25 -0
  27. package/dist/lib/check/package.d.ts.map +1 -0
  28. package/dist/lib/check/package.js +139 -0
  29. package/dist/lib/check/package.js.map +1 -0
  30. package/dist/lib/check/pdf.d.ts +3 -0
  31. package/dist/lib/check/pdf.d.ts.map +1 -0
  32. package/dist/lib/check/pdf.js +160 -0
  33. package/dist/lib/check/pdf.js.map +1 -0
  34. package/dist/lib/check/pptx.d.ts +3 -0
  35. package/dist/lib/check/pptx.d.ts.map +1 -0
  36. package/dist/lib/check/pptx.js +497 -0
  37. package/dist/lib/check/pptx.js.map +1 -0
  38. package/dist/lib/check/text-fit.d.ts +18 -0
  39. package/dist/lib/check/text-fit.d.ts.map +1 -0
  40. package/dist/lib/check/text-fit.js +69 -0
  41. package/dist/lib/check/text-fit.js.map +1 -0
  42. package/dist/lib/check/xlsx.d.ts +3 -0
  43. package/dist/lib/check/xlsx.d.ts.map +1 -0
  44. package/dist/lib/check/xlsx.js +131 -0
  45. package/dist/lib/check/xlsx.js.map +1 -0
  46. package/dist/lib/check/xml-tree.d.ts +15 -0
  47. package/dist/lib/check/xml-tree.d.ts.map +1 -0
  48. package/dist/lib/check/xml-tree.js +131 -0
  49. package/dist/lib/check/xml-tree.js.map +1 -0
  50. package/dist/lib/derivers/image.d.ts.map +1 -1
  51. package/dist/lib/derivers/image.js.map +1 -1
  52. package/dist/lib/formats.d.ts +1 -0
  53. package/dist/lib/formats.d.ts.map +1 -1
  54. package/dist/lib/formats.js +1 -0
  55. package/dist/lib/formats.js.map +1 -1
  56. package/dist/lib/render/convert.d.ts +11 -0
  57. package/dist/lib/render/convert.d.ts.map +1 -0
  58. package/dist/lib/render/convert.js +107 -0
  59. package/dist/lib/render/convert.js.map +1 -0
  60. package/dist/lib/render/pages.d.ts +11 -0
  61. package/dist/lib/render/pages.d.ts.map +1 -0
  62. package/dist/lib/render/pages.js +43 -0
  63. package/dist/lib/render/pages.js.map +1 -0
  64. package/dist/lib/render/render.d.ts +29 -0
  65. package/dist/lib/render/render.d.ts.map +1 -0
  66. package/dist/lib/render/render.js +142 -0
  67. package/dist/lib/render/render.js.map +1 -0
  68. package/dist/skill-authoring.d.ts +2 -0
  69. package/dist/skill-authoring.d.ts.map +1 -0
  70. package/dist/skill-authoring.js +20 -0
  71. package/dist/skill-authoring.js.map +1 -0
  72. package/dist/skill.d.ts.map +1 -1
  73. package/dist/skill.js +24 -1
  74. package/dist/skill.js.map +1 -1
  75. package/dist/testing.d.ts +67 -0
  76. package/dist/testing.d.ts.map +1 -1
  77. package/dist/testing.js +151 -0
  78. package/dist/testing.js.map +1 -1
  79. package/package.json +20 -7
  80. package/src/app.ts +15 -1
  81. package/src/cli.integration.test.ts +63 -1
  82. package/src/commands/check.command.ts +97 -0
  83. package/src/commands/render.command.ts +80 -0
  84. package/src/lib/check/check.test.ts +446 -0
  85. package/src/lib/check/check.ts +49 -0
  86. package/src/lib/check/docx.ts +434 -0
  87. package/src/lib/check/finding.ts +63 -0
  88. package/src/lib/check/package.ts +199 -0
  89. package/src/lib/check/pdf.ts +228 -0
  90. package/src/lib/check/pptx.ts +641 -0
  91. package/src/lib/check/text-fit.ts +105 -0
  92. package/src/lib/check/xlsx.ts +163 -0
  93. package/src/lib/check/xml-tree.ts +186 -0
  94. package/src/lib/derivers/image.ts +2 -1
  95. package/src/lib/formats.ts +6 -0
  96. package/src/lib/render/convert.ts +133 -0
  97. package/src/lib/render/pages.test.ts +38 -0
  98. package/src/lib/render/pages.ts +58 -0
  99. package/src/lib/render/render.ts +198 -0
  100. package/src/render.integration.test.ts +217 -0
  101. package/src/skill-authoring.ts +27 -0
  102. package/src/skill.ts +28 -1
  103. package/src/testing.ts +287 -0
  104. package/dist/lib/flags.d.ts +0 -2
  105. package/dist/lib/flags.d.ts.map +0 -1
  106. package/dist/lib/flags.js +0 -8
  107. package/dist/lib/flags.js.map +0 -1
  108. package/dist/version.d.ts +0 -2
  109. package/dist/version.d.ts.map +0 -1
  110. package/dist/version.js +0 -3
  111. package/dist/version.js.map +0 -1
package/NOTICE ADDED
@@ -0,0 +1,208 @@
1
+ NOTICE
2
+ ======
3
+
4
+ fileq is part of the Intentic repository and is MIT-licensed (package.json).
5
+ It includes material adapted from SurfSense, which is covered below.
6
+
7
+
8
+ SurfSense
9
+ ---------
10
+
11
+ Copyright (c) SurfSense
12
+ https://github.com/MODSetter/SurfSense (read at a51f9a367ccafe873d7d85a4f3878e5a6de4e662)
13
+
14
+ The adapted material comes from the parts of SurfSense licensed under the
15
+ Apache License, Version 2.0; its full text follows. SurfSense ships no NOTICE
16
+ file of its own. Each adapted file says in its header what it took and what it
17
+ changed:
18
+
19
+ src/skill-authoring.ts authoring rules, from
20
+ docker/sandbox/skills/{pptx,docx,xlsx,pdf}/SKILL.md
21
+ src/lib/check/pptx.ts geometry, crop and missing-media rules, from
22
+ surfsense_backend/app/artifacts/verification/formats/pptx.py
23
+ src/lib/check/docx.ts the literal-bullet rule, from .../formats/docx.py
24
+ src/lib/check/xlsx.ts error-value and missing-cached-value rules, from
25
+ .../formats/xlsx.py
26
+ src/lib/check/pdf.ts blank-page and unembedded-font rules, from
27
+ .../formats/pdf.py
28
+
29
+ The code in those files is written for fileq, in TypeScript; what it carries
30
+ over is the rules, their thresholds and the wording of the authoring guidance.
31
+
32
+
33
+ Apache License
34
+ Version 2.0, January 2004
35
+ http://www.apache.org/licenses/
36
+
37
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
38
+
39
+ 1. Definitions.
40
+
41
+ "License" shall mean the terms and conditions for use, reproduction,
42
+ and distribution as defined by Sections 1 through 9 of this document.
43
+
44
+ "Licensor" shall mean the copyright owner or entity authorized by
45
+ the copyright owner that is granting the License.
46
+
47
+ "Legal Entity" shall mean the union of the acting entity and all
48
+ other entities that control, are controlled by, or are under common
49
+ control with that entity. For the purposes of this definition,
50
+ "control" means (i) the power, direct or indirect, to cause the
51
+ direction or management of such entity, whether by contract or
52
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
53
+ outstanding shares, or (iii) beneficial ownership of such entity.
54
+
55
+ "You" (or "Your") shall mean an individual or Legal Entity
56
+ exercising permissions granted by this License.
57
+
58
+ "Source" form shall mean the preferred form for making modifications,
59
+ including but not limited to software source code, documentation
60
+ source, and configuration files.
61
+
62
+ "Object" form shall mean any form resulting from mechanical
63
+ transformation or translation of a Source form, including but
64
+ not limited to compiled object code, generated documentation,
65
+ and conversions to other media types.
66
+
67
+ "Work" shall mean the work of authorship, whether in Source or
68
+ Object form, made available under the License, as indicated by a
69
+ copyright notice that is included in or attached to the work
70
+ (an example is provided in the Appendix below).
71
+
72
+ "Derivative Works" shall mean any work, whether in Source or Object
73
+ form, that is based on (or derived from) the Work and for which the
74
+ editorial revisions, annotations, elaborations, or other modifications
75
+ represent, as a whole, an original work of authorship. For the purposes
76
+ of this License, Derivative Works shall not include works that remain
77
+ separable from, or merely link (or bind by name) to the interfaces of,
78
+ the Work and Derivative Works thereof.
79
+
80
+ "Contribution" shall mean any work of authorship, including
81
+ the original version of the Work and any modifications or additions
82
+ to that Work or Derivative Works thereof, that is intentionally
83
+ submitted to Licensor for inclusion in the Work by the copyright owner
84
+ or by an individual or Legal Entity authorized to submit on behalf of
85
+ the copyright owner. For the purposes of this definition, "submitted"
86
+ means any form of electronic, verbal, or written communication sent
87
+ to the Licensor or its representatives, including but not limited to
88
+ communication on electronic mailing lists, source code control systems,
89
+ and issue tracking systems that are managed by, or on behalf of, the
90
+ Licensor for the purpose of discussing and improving the Work, but
91
+ excluding communication that is conspicuously marked or otherwise
92
+ designated in writing by the copyright owner as "Not a Contribution."
93
+
94
+ "Contributor" shall mean Licensor and any individual or Legal Entity
95
+ on behalf of whom a Contribution has been received by Licensor and
96
+ subsequently incorporated within the Work.
97
+
98
+ 2. Grant of Copyright License. Subject to the terms and conditions of
99
+ this License, each Contributor hereby grants to You a perpetual,
100
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
101
+ copyright license to reproduce, prepare Derivative Works of,
102
+ publicly display, publicly perform, sublicense, and distribute the
103
+ Work and such Derivative Works in Source or Object form.
104
+
105
+ 3. Grant of Patent License. Subject to the terms and conditions of
106
+ this License, each Contributor hereby grants to You a perpetual,
107
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
108
+ (except as stated in this section) patent license to make, have made,
109
+ use, offer to sell, sell, import, and otherwise transfer the Work,
110
+ where such license applies only to those patent claims licensable
111
+ by such Contributor that are necessarily infringed by their
112
+ Contribution(s) alone or by combination of their Contribution(s)
113
+ with the Work to which such Contribution(s) was submitted. If You
114
+ institute patent litigation against any entity (including a
115
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
116
+ or a Contribution incorporated within the Work constitutes direct
117
+ or contributory patent infringement, then any patent licenses
118
+ granted to You under this License for that Work shall terminate
119
+ as of the date such litigation is filed.
120
+
121
+ 4. Redistribution. You may reproduce and distribute copies of the
122
+ Work or Derivative Works thereof in any medium, with or without
123
+ modifications, and in Source or Object form, provided that You
124
+ meet the following conditions:
125
+
126
+ (a) You must give any other recipients of the Work or
127
+ Derivative Works a copy of this License; and
128
+
129
+ (b) You must cause any modified files to carry prominent notices
130
+ stating that You changed the files; and
131
+
132
+ (c) You must retain, in the Source form of any Derivative Works
133
+ that You distribute, all copyright, patent, trademark, and
134
+ attribution notices from the Source form of the Work,
135
+ excluding those notices that do not pertain to any part of
136
+ the Derivative Works; and
137
+
138
+ (d) If the Work includes a "NOTICE" text file as part of its
139
+ distribution, then any Derivative Works that You distribute must
140
+ include a readable copy of the attribution notices contained
141
+ within such NOTICE file, excluding those notices that do not
142
+ pertain to any part of the Derivative Works, in at least one
143
+ of the following places: within a NOTICE text file distributed
144
+ as part of the Derivative Works; within the Source form or
145
+ documentation, if provided along with the Derivative Works; or,
146
+ within a display generated by the Derivative Works, if and
147
+ wherever such third-party notices normally appear. The contents
148
+ of the NOTICE file are for informational purposes only and
149
+ do not modify the License. You may add Your own attribution
150
+ notices within Derivative Works that You distribute, alongside
151
+ or as an addendum to the NOTICE text from the Work, provided
152
+ that such additional attribution notices cannot be construed
153
+ as modifying the License.
154
+
155
+ You may add Your own copyright statement to Your modifications and
156
+ may provide additional or different license terms and conditions
157
+ for use, reproduction, or distribution of Your modifications, or
158
+ for any such Derivative Works as a whole, provided Your use,
159
+ reproduction, and distribution of the Work otherwise complies with
160
+ the conditions stated in this License.
161
+
162
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
163
+ any Contribution intentionally submitted for inclusion in the Work
164
+ by You to the Licensor shall be under the terms and conditions of
165
+ this License, without any additional terms or conditions.
166
+ Notwithstanding the above, nothing herein shall supersede or modify
167
+ the terms of any separate license agreement you may have executed
168
+ with Licensor regarding such Contributions.
169
+
170
+ 6. Trademarks. This License does not grant permission to use the trade
171
+ names, trademarks, service marks, or product names of the Licensor,
172
+ except as required for reasonable and customary use in describing the
173
+ origin of the Work and reproducing the content of the NOTICE file.
174
+
175
+ 7. Disclaimer of Warranty. Unless required by applicable law or
176
+ agreed to in writing, Licensor provides the Work (and each
177
+ Contributor provides its Contributions) on an "AS IS" BASIS,
178
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
179
+ implied, including, without limitation, any warranties or conditions
180
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
181
+ PARTICULAR PURPOSE. You are solely responsible for determining the
182
+ appropriateness of using or redistributing the Work and assume any
183
+ risks associated with Your exercise of permissions under this License.
184
+
185
+ 8. Limitation of Liability. In no event and under no legal theory,
186
+ whether in tort (including negligence), contract, or otherwise,
187
+ unless required by applicable law (such as deliberate and grossly
188
+ negligent acts) or agreed to in writing, shall any Contributor be
189
+ liable to You for damages, including any direct, indirect, special,
190
+ incidental, or consequential damages of any character arising as a
191
+ result of this License or out of the use or inability to use the
192
+ Work (including but not limited to damages for loss of goodwill,
193
+ work stoppage, computer failure or malfunction, or any and all
194
+ other commercial damages or losses), even if such Contributor
195
+ has been advised of the possibility of such damages.
196
+
197
+ 9. Accepting Warranty or Additional Liability. While redistributing
198
+ the Work or Derivative Works thereof, You may choose to offer,
199
+ and charge a fee for, acceptance of support, warranty, indemnity,
200
+ or other liability obligations and/or rights consistent with this
201
+ License. However, in accepting such obligations, You may act only
202
+ on Your own behalf and on Your sole responsibility, not on behalf
203
+ of any other Contributor, and only if You agree to indemnify,
204
+ defend, and hold each Contributor harmless for any liability
205
+ incurred by, or claims asserted against, such Contributor by reason
206
+ of your accepting any such warranty or additional liability.
207
+
208
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # fileq
2
2
 
3
- A CLI that shows an agent the contents of binary workspace files (Office documents, PDFs, images, audio, archives) as budgeted markdown, cached as sidecars.
3
+ A CLI that shows an agent the contents of binary workspace files (Office documents, PDFs, images, audio, archives) as budgeted markdown, cached as sidecars, and checks and draws the documents an agent makes.
4
4
 
5
5
  ```mermaid
6
6
  flowchart LR
7
7
  agent["Agent<br/>fileq read"] --> fileq(["fileq"])
8
+ maker["Agent<br/>fileq check · render"] --> fileq
8
9
  daemon["Daemon<br/>derive · sweep"] --> fileq
9
10
  git["git diff · show<br/>textconv"] --> fileq
10
11
  fileq --> derivers["Derivers<br/>docx · pdf · xlsx · image …"]
11
12
  fileq --> sidecars["Sidecars<br/>.intentic/local/cache/derived"]
13
+ fileq --> tools["LibreOffice · pdftoppm<br/>.intentic/local/cache/rendered"]
12
14
  ```
13
15
 
14
16
  - An agent cannot `cat` a docx or the text layer of a PDF. `fileq <file>` prints a capsule line (title, format,
@@ -21,6 +23,18 @@ flowchart LR
21
23
  (`_sandbox/sandbox/src/derived/`), and imports `./formats` and `./sidecar` so both sides agree on what is derivable.
22
24
  - In the sandbox image, `git diff` and `git show` on a document print its text through `fileq read --plain`, wired by
23
25
  `fileq git-attributes`.
26
+ - `fileq check <file>` lints a docx, pptx, xlsx or pdf an agent produced and names each problem where a reader meets
27
+ it (`slide 3 · "Title 1"`, `'Q3 plan'!C4`, `page 7`, `paragraph 12 · "…"`). An error is a fact read off the
28
+ structure (a missing image, a cell showing `#REF!`, a link to a bookmark that is not there, a blank page, Office's
29
+ own "Click to add title" left as text) and makes it exit 1; a warning is a judgement call or an estimate (text
30
+ overflowing its box, from average glyph widths). Some rules are adapted from SurfSense's artifact verification
31
+ (Apache-2.0); [NOTICE](NOTICE) names them.
32
+ - `fileq render <file>` draws pages or slides to PNG under `.intentic/local/cache/rendered/<path>/` (or `--out`) and
33
+ prints their paths for an image reader. Office formats go through LibreOffice to PDF first, keeping hidden slides
34
+ so slide N is image N; `pdftoppm` or `mutool` draws the PDF. A render is keyed by the document's hash, so an
35
+ unchanged file answers from the last one. A missing tool exits 2 with what installs it.
36
+ - Its skill ([src/skill.ts](src/skill.ts)) tells an agent to check and look at every document it makes, with short
37
+ authoring rules adapted from SurfSense's document skills ([src/skill-authoring.ts](src/skill-authoring.ts)).
24
38
  - Out of scope: plain text files (read them directly), web pages ([webq](../webq)), OCR and transcription.
25
39
 
26
40
  ## Usage
@@ -28,16 +42,23 @@ flowchart LR
28
42
  ```sh
29
43
  fileq report.docx # capsule + markdown up to 4000 tokens, whole text saved
30
44
  fileq read deck.pptx --budget 8000 # a bigger slice on stdout
45
+ fileq check deck.pptx # problems by slide and drawing; exit 1 on an error
46
+ fileq render deck.pptx --pages 1-3 # slide-1.png … slide-3.png, one path per line
31
47
  ```
32
48
 
49
+ 2026-09-29: rendering shells out to LibreOffice and poppler instead of bundling a renderer. pdf.js draws only onto a
50
+ canvas fileq does not carry, and an office layout faithful enough to judge overflow is LibreOffice itself. No published sandbox
51
+ image carries them: they are the opt-in `office` pack (`_sandbox/sandbox/image-packs/office.Dockerfile`, ~335 MB), so
52
+ there `fileq render` names the missing tool and prints `environment propose office --pack`, which asks the owner for it.
53
+
33
54
  ## Key files
34
55
 
35
56
  - [src/app.ts](src/app.ts) — the command routes and the `--help` text an agent reads.
36
57
  - [src/lib/derive.ts](src/lib/derive.ts) — `ensureSidecar`: the pipeline `read`, `derive` and `sweep` all run.
37
58
  - [src/lib/formats.ts](src/lib/formats.ts) — `detectFormat`: magic bytes first, extension as fallback.
38
59
  - [src/lib/sidecar.ts](src/lib/sidecar.ts) — sidecar paths, front matter and the freshness rule.
39
- - [src/lib/derivers/deriver.ts](src/lib/derivers/deriver.ts) — the contract every format handler meets.
40
- - [src/derivers.integration.test.ts](src/derivers.integration.test.ts) — each format's output, by fixture.
60
+ - [src/lib/check/check.ts](src/lib/check/check.ts) — `fileq check`: which formats have a checker; each format's rules sit beside it.
61
+ - [src/lib/render/render.ts](src/lib/render/render.ts) — `fileq render`: conversion, rasterizing and the render cache.
41
62
 
42
63
  ## Commands
43
64
 
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,GAAG,6EAiBf,CAAC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,GAAG,6EAmBf,CAAC"}
package/dist/app.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { packageVersion } from "@intentic/agent-cli/version";
2
2
  import { buildApplication, buildRouteMap } from "@stricli/core";
3
+ import { checkCommand } from "./commands/check.command.js";
3
4
  import { deriveCommand } from "./commands/derive.command.js";
4
5
  import { gitAttributesCommand } from "./commands/git-attributes.command.js";
5
6
  import { readCommand } from "./commands/read.command.js";
7
+ import { renderCommand } from "./commands/render.command.js";
6
8
  import { sweepCommand } from "./commands/sweep.command.js";
7
9
  const HELP = `fileq — binary workspace files as clean, budgeted markdown.
8
10
 
@@ -18,16 +20,28 @@ fresh by content hash — reading a file twice derives once.
18
20
  fileq read --plain <f> the markdown alone, for a program; git's textconv driver
19
21
  fileq git-attributes the gitattributes that route documents through it
20
22
 
23
+ After producing a document, check it and look at it:
24
+
25
+ fileq check <file> docx, pptx, xlsx, pdf: problems a reader would meet, each
26
+ with its slide, page, cell or paragraph; exit 1 on an error
27
+ fileq render <file> [--pages 1-3] [--out <dir>]
28
+ pages or slides as PNG files, one path per line, for an
29
+ image reader (office formats need LibreOffice; all need
30
+ pdftoppm or mutool)
31
+
21
32
  git diff, git show and git log -p on a document print its text, not "Binary
22
33
  files differ": the sandbox names every derivable extension diff=fileq.
23
34
 
24
35
  Not fileq's business: plain text (read it directly), the open web (webq),
25
36
  files needing OCR or transcription (later tiers say so in their sidecars).
26
37
 
27
- Exit codes: 0 content, 1 nothing derivable, 2 broken invocation or install.`;
38
+ Exit codes: 0 content, 1 nothing derivable (check: an error found), 2 broken
39
+ invocation or install (render: a tool it needs is missing).`;
28
40
  export const app = buildApplication(buildRouteMap({
29
41
  routes: {
30
42
  read: readCommand,
43
+ check: checkCommand,
44
+ render: renderCommand,
31
45
  derive: deriveCommand,
32
46
  sweep: sweepCommand,
33
47
  gitAttributes: gitAttributesCommand,
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;4EAoB+D,CAAC;AAE7E,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAgB,CAC/B,aAAa,CAAC;IACV,MAAM,EAAE;QACJ,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,YAAY;QACnB,aAAa,EAAE,oBAAoB;KACtC;IACD,cAAc,EAAE,MAAM;IACtB,IAAI,EAAE,EAAE,KAAK,EAAE,2EAA2E,EAAE,eAAe,EAAE,IAAI,EAAE;CACtH,CAAC,EACF;IACI,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,EAAE,cAAc,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE;IAChE,OAAO,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE;IAC/C,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;CAC7B,CACJ,CAAC"}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DA8B+C,CAAC;AAE7D,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAgB,CAC/B,aAAa,CAAC;IACV,MAAM,EAAE;QACJ,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,YAAY;QACnB,aAAa,EAAE,oBAAoB;KACtC;IACD,cAAc,EAAE,MAAM;IACtB,IAAI,EAAE,EAAE,KAAK,EAAE,2EAA2E,EAAE,eAAe,EAAE,IAAI,EAAE;CACtH,CAAC,EACF;IACI,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,EAAE,cAAc,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE;IAChE,OAAO,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE;IAC/C,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;CAC7B,CACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type CommandContext } from "@stricli/core";
2
+ export declare const checkCommand: import("@stricli/core").Command<CommandContext>;
3
+ //# sourceMappingURL=check.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.command.d.ts","sourceRoot":"","sources":["../../src/commands/check.command.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AA+ClE,eAAO,MAAM,YAAY,iDA6CvB,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { basename, resolve } from "node:path";
2
+ import { capsule } from "@intentic/agent-cli/output";
3
+ import { neutralizeOutsideText } from "@intentic/base/outside-text";
4
+ import { buildCommand } from "@stricli/core";
5
+ const SHOWN_PER_RULE = 12;
6
+ const line = (finding) => {
7
+ const where = finding.where === "" ? "" : `${finding.where}: `;
8
+ return neutralizeOutsideText(`${finding.severity === "error" ? "error " : "warning"} ${where}${finding.message}`);
9
+ };
10
+ const listing = (findings) => {
11
+ const shown = new Map();
12
+ const lines = [];
13
+ const hidden = new Map();
14
+ for (const finding of [...findings.filter((item) => item.severity === "error"), ...findings.filter((item) => item.severity === "warning")]) {
15
+ const count = shown.get(finding.rule) ?? 0;
16
+ if (count < SHOWN_PER_RULE) {
17
+ lines.push(line(finding));
18
+ shown.set(finding.rule, count + 1);
19
+ }
20
+ else {
21
+ hidden.set(finding.rule, (hidden.get(finding.rule) ?? 0) + 1);
22
+ }
23
+ }
24
+ for (const [rule, count] of hidden) {
25
+ lines.push(`… and ${count} more ${rule} (--json lists every one)`);
26
+ }
27
+ return lines;
28
+ };
29
+ const counted = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
30
+ const tally = (report) => {
31
+ const errors = report.findings.filter((finding) => finding.severity === "error").length;
32
+ const warnings = report.findings.length - errors;
33
+ if (report.findings.length === 0) {
34
+ return "no problems found";
35
+ }
36
+ return [errors > 0 ? counted(errors, "error") : "", warnings > 0 ? counted(warnings, "warning") : ""].filter((part) => part !== "").join(", ");
37
+ };
38
+ export const checkCommand = buildCommand({
39
+ docs: { brief: "Lint a docx, pptx, xlsx or pdf for problems a reader would meet; exit 1 on any error" },
40
+ parameters: {
41
+ flags: {
42
+ json: { kind: "boolean", default: false, brief: "Every finding as JSON on stdout" },
43
+ },
44
+ positional: {
45
+ kind: "tuple",
46
+ parameters: [{ parse: String, brief: "The document to check (relative paths resolve against the cwd)", placeholder: "file" }],
47
+ },
48
+ },
49
+ async func(flags, file) {
50
+ const absPath = resolve(file);
51
+ const { CHECKABLE, checkFile } = await import("../lib/check/check.js");
52
+ const outcome = await checkFile(absPath);
53
+ if (outcome.kind !== "checked") {
54
+ const reason = outcome.kind === "unreadable"
55
+ ? outcome.reason
56
+ : `fileq check reads ${CHECKABLE.join(", ")}; this is ${outcome.format ?? "none of them"} (fileq read shows what it holds)`;
57
+ this.process.stdout.write(`fileq: cannot check ${absPath}: ${reason}\n`);
58
+ process.exitCode = 2;
59
+ return;
60
+ }
61
+ const { report } = outcome;
62
+ const errors = report.findings.filter((finding) => finding.severity === "error").length;
63
+ process.exitCode = errors > 0 ? 1 : 0;
64
+ if (flags.json) {
65
+ const findings = report.findings.map((finding) => ({ ...finding, where: neutralizeOutsideText(finding.where), message: neutralizeOutsideText(finding.message) }));
66
+ this.process.stdout.write(`${JSON.stringify({ file: absPath, format: report.format, extent: report.extent, errors, warnings: findings.length - errors, findings, notes: report.notes })}\n`);
67
+ return;
68
+ }
69
+ const fields = [basename(absPath), report.format, ...(report.extent === undefined ? [] : [report.extent]), tally(report)];
70
+ this.process.stdout.write(capsule("fileq", fields, report.notes));
71
+ const lines = listing(report.findings);
72
+ if (lines.length > 0) {
73
+ this.process.stdout.write(`${lines.join("\n")}\n`);
74
+ }
75
+ if (errors === 0) {
76
+ this.process.stdout.write(`structure only: look at the ${report.format === "pptx" ? "slides" : "pages"} with \`fileq render ${file}\`\n`);
77
+ }
78
+ },
79
+ });
80
+ //# sourceMappingURL=check.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.command.js","sourceRoot":"","sources":["../../src/commands/check.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,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KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,wBAAwB,IAAI,MAAM,CAAC,CAAC;QAC9I,CAAC;IACL,CAAC;CACJ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type CommandContext } from "@stricli/core";
2
+ export declare const renderCommand: import("@stricli/core").Command<CommandContext>;
3
+ //# sourceMappingURL=render.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.command.d.ts","sourceRoot":"","sources":["../../src/commands/render.command.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAqClE,eAAO,MAAM,aAAa,iDAqCxB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { basename, resolve } from "node:path";
2
+ import { countParser } from "@intentic/agent-cli/flags";
3
+ import { capsule } from "@intentic/agent-cli/output";
4
+ import { errorMessage } from "@intentic/base/errors";
5
+ import { buildCommand } from "@stricli/core";
6
+ import { workspaceRoot } from "../lib/env.js";
7
+ import { ConvertFailed, ToolMissing } from "../lib/render/convert.js";
8
+ import { BadPages, describePages, parsePages } from "../lib/render/pages.js";
9
+ import { DEFAULT_SIZE, NotRenderable, renderDocument } from "../lib/render/render.js";
10
+ const failure = (cause) => {
11
+ if (cause instanceof ToolMissing || cause instanceof BadPages) {
12
+ return { code: 2, message: cause.message };
13
+ }
14
+ if (cause instanceof NotRenderable || cause instanceof ConvertFailed) {
15
+ return { code: 1, message: cause.message };
16
+ }
17
+ return undefined;
18
+ };
19
+ const summary = (file, result) => {
20
+ const drawn = result.images.map((image) => image.page);
21
+ const fields = [
22
+ basename(file),
23
+ result.format,
24
+ `${result.total} ${result.unit}${result.total === 1 ? "" : "s"}`,
25
+ drawn.length === 0 ? "nothing drawn" : `drew ${result.unit}${drawn.length === 1 ? "" : "s"} ${describePages(drawn)}`,
26
+ result.reused ? "unchanged since the last render" : "rendered",
27
+ ];
28
+ return capsule("fileq", fields, result.notes);
29
+ };
30
+ export const renderCommand = buildCommand({
31
+ docs: { brief: "Draw a document's pages or slides as PNG files and print their paths, to look at with an image reader" },
32
+ parameters: {
33
+ flags: {
34
+ pages: { kind: "parsed", parse: String, optional: true, brief: "Which pages or slides: 3, 1-3, 2,5,7-9, 7- (default: the first 20)" },
35
+ out: { kind: "parsed", parse: String, optional: true, brief: "Folder for the PNGs (default: .intentic/local/cache/rendered/<path>/ in the workspace)" },
36
+ size: { kind: "parsed", parse: countParser, default: String(DEFAULT_SIZE), brief: "Longest side of each image, in pixels" },
37
+ json: { kind: "boolean", default: false, brief: "Machine-readable result on stdout" },
38
+ },
39
+ positional: {
40
+ kind: "tuple",
41
+ parameters: [{ parse: String, brief: "The document to draw (relative paths resolve against the cwd)", placeholder: "file" }],
42
+ },
43
+ },
44
+ async func(flags, file) {
45
+ const absPath = resolve(file);
46
+ let result;
47
+ try {
48
+ const pages = flags.pages === undefined ? undefined : parsePages(flags.pages);
49
+ const size = Math.max(64, Math.round(flags.size));
50
+ result = await renderDocument({ absPath, pages, outDir: flags.out === undefined ? undefined : resolve(flags.out), size }, workspaceRoot());
51
+ }
52
+ catch (cause) {
53
+ const known = failure(cause);
54
+ this.process.stdout.write(`fileq: cannot render ${absPath}: ${known?.message ?? errorMessage(cause)}\n`);
55
+ process.exitCode = known?.code ?? 2;
56
+ return;
57
+ }
58
+ process.exitCode = result.images.length > 0 ? 0 : 1;
59
+ if (flags.json) {
60
+ this.process.stdout.write(`${JSON.stringify({ file: absPath, format: result.format, unit: result.unit, total: result.total, images: result.images, reused: result.reused, notes: result.notes })}\n`);
61
+ return;
62
+ }
63
+ this.process.stdout.write(summary(absPath, result));
64
+ this.process.stdout.write(result.images.map((image) => `${image.path}\n`).join(""));
65
+ },
66
+ });
67
+ //# sourceMappingURL=render.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.command.js","sourceRoot":"","sources":["../../src/commands/render.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAuB,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAqB,MAAM,yBAAyB,CAAC;AAWzG,MAAM,OAAO,GAAG,CAAC,KAAc,EAAiD,EAAE;IAC9E,IAAI,KAAK,YAAY,WAAW,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC5D,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/C,CAAC;IACD,IAAI,KAAK,YAAY,aAAa,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;QACnE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/C,CA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AK,EAAE,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzG,OAAO,CAAC,QAAQ,GAAG,KAAK,EAAE,IAAI,IAAI,CAAC,CAAC;YACpC,OAAO;QACX,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACrB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAC7K,CAAC;YACF,OAAO;QACX,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;CACJ,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type Format } from "../formats.js";
2
+ import type { CheckReport } from "./finding.js";
3
+ export declare const CHECKABLE: readonly Format[];
4
+ export type CheckOutcome = {
5
+ readonly kind: "checked";
6
+ readonly report: CheckReport;
7
+ } | {
8
+ readonly kind: "unsupported";
9
+ readonly format: Format | undefined;
10
+ } | {
11
+ readonly kind: "unreadable";
12
+ readonly reason: string;
13
+ };
14
+ export declare const checkFile: (absPath: string) => Promise<CheckOutcome>;
15
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/lib/check/check.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAgBhD,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAAyB,CAAC;AAKjE,MAAM,MAAM,YAAY,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrE;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAG/D,eAAO,MAAM,SAAS,YAAmB,MAAM,KAAG,OAAO,CAAC,YAAY,CAiBrE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { errorMessage, isMissing } from "@intentic/base/errors";
3
+ import { claimedFormat } from "../formats.js";
4
+ import { checkDocx } from "./docx.js";
5
+ import { checkPdf } from "./pdf.js";
6
+ import { checkPptx } from "./pptx.js";
7
+ import { checkXlsx } from "./xlsx.js";
8
+ const CHECKERS = new Map([
9
+ ["docx", checkDocx],
10
+ ["pptx", checkPptx],
11
+ ["xlsx", checkXlsx],
12
+ ["pdf", checkPdf],
13
+ ]);
14
+ export const CHECKABLE = [...CHECKERS.keys()];
15
+ const MAX_CHECK_BYTES = 200 * 1024 * 1024;
16
+ export const checkFile = async (absPath) => {
17
+ let size;
18
+ try {
19
+ size = (await stat(absPath)).size;
20
+ }
21
+ catch (cause) {
22
+ return { kind: "unreadable", reason: isMissing(cause) ? "no such file" : errorMessage(cause) };
23
+ }
24
+ if (size > MAX_CHECK_BYTES) {
25
+ return { kind: "unreadable", reason: `${Math.round(size / 1024 / 1024)} MB is over the ${MAX_CHECK_BYTES / 1024 / 1024} MB a check reads` };
26
+ }
27
+ const format = await claimedFormat(absPath);
28
+ const checker = format === undefined ? undefined : CHECKERS.get(format);
29
+ if (checker === undefined) {
30
+ return { kind: "unsupported", format };
31
+ }
32
+ const report = await checker(new Uint8Array(await readFile(absPath)));
33
+ return { kind: "checked", report };
34
+ };
35
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/lib/check/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAe,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAMtC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAkB;IACtC,CAAC,MAAM,EAAE,SAAS,CAAC;IACnB,CAAC,MAAM,EAAE,SAAS,CAAC;IACnB,CAAC,MAAM,EAAE,SAAS,CAAC;IACnB,CAAC,KAAK,EAAE,QAAQ,CAAC;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAsB,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;AAGjE,MAAM,eAAe,GAAG,GAA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) => CheckReport;
3
+ //# sourceMappingURL=docx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docx.d.ts","sourceRoot":"","sources":["../../../src/lib/check/docx.ts"],"names":[],"mappings":"AAQA,OAAO,EAAyD,KAAK,WAAW,EAAgB,MAAM,cAAc,CAAC;AAgXrH,eAAO,MAAM,SAAS,UAAW,UAAU,KAAG,WAyD7C,CAAC"}