@intentic/fileq 1.317.0 → 1.319.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.
- package/NOTICE +208 -0
- package/README.md +39 -12
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +19 -7
- package/dist/app.js.map +1 -1
- package/dist/commands/check.command.d.ts +3 -0
- package/dist/commands/check.command.d.ts.map +1 -0
- package/dist/commands/check.command.js +80 -0
- package/dist/commands/check.command.js.map +1 -0
- package/dist/commands/derive.command.js +1 -1
- package/dist/commands/derive.command.js.map +1 -1
- package/dist/commands/read.command.d.ts.map +1 -1
- package/dist/commands/read.command.js +26 -45
- package/dist/commands/read.command.js.map +1 -1
- package/dist/commands/render.command.d.ts +3 -0
- package/dist/commands/render.command.d.ts.map +1 -0
- package/dist/commands/render.command.js +67 -0
- package/dist/commands/render.command.js.map +1 -0
- package/dist/lib/check/check.d.ts +15 -0
- package/dist/lib/check/check.d.ts.map +1 -0
- package/dist/lib/check/check.js +35 -0
- package/dist/lib/check/check.js.map +1 -0
- package/dist/lib/check/docx.d.ts +3 -0
- package/dist/lib/check/docx.d.ts.map +1 -0
- package/dist/lib/check/docx.js +329 -0
- package/dist/lib/check/docx.js.map +1 -0
- package/dist/lib/check/finding.d.ts +20 -0
- package/dist/lib/check/finding.d.ts.map +1 -0
- package/dist/lib/check/finding.js +27 -0
- package/dist/lib/check/finding.js.map +1 -0
- package/dist/lib/check/package.d.ts +25 -0
- package/dist/lib/check/package.d.ts.map +1 -0
- package/dist/lib/check/package.js +139 -0
- package/dist/lib/check/package.js.map +1 -0
- package/dist/lib/check/pdf.d.ts +3 -0
- package/dist/lib/check/pdf.d.ts.map +1 -0
- package/dist/lib/check/pdf.js +160 -0
- package/dist/lib/check/pdf.js.map +1 -0
- package/dist/lib/check/pptx.d.ts +3 -0
- package/dist/lib/check/pptx.d.ts.map +1 -0
- package/dist/lib/check/pptx.js +497 -0
- package/dist/lib/check/pptx.js.map +1 -0
- package/dist/lib/check/text-fit.d.ts +18 -0
- package/dist/lib/check/text-fit.d.ts.map +1 -0
- package/dist/lib/check/text-fit.js +69 -0
- package/dist/lib/check/text-fit.js.map +1 -0
- package/dist/lib/check/xlsx.d.ts +3 -0
- package/dist/lib/check/xlsx.d.ts.map +1 -0
- package/dist/lib/check/xlsx.js +131 -0
- package/dist/lib/check/xlsx.js.map +1 -0
- package/dist/lib/check/xml-tree.d.ts +15 -0
- package/dist/lib/check/xml-tree.d.ts.map +1 -0
- package/dist/lib/check/xml-tree.js +131 -0
- package/dist/lib/check/xml-tree.js.map +1 -0
- package/dist/lib/content-cache.d.ts +12 -0
- package/dist/lib/content-cache.d.ts.map +1 -0
- package/dist/lib/content-cache.js +33 -0
- package/dist/lib/content-cache.js.map +1 -0
- package/dist/lib/derive.d.ts +10 -0
- package/dist/lib/derive.d.ts.map +1 -1
- package/dist/lib/derive.js +37 -4
- package/dist/lib/derive.js.map +1 -1
- package/dist/lib/derivers/image.d.ts.map +1 -1
- package/dist/lib/derivers/image.js.map +1 -1
- package/dist/lib/formats.d.ts +1 -0
- package/dist/lib/formats.d.ts.map +1 -1
- package/dist/lib/formats.js +1 -0
- package/dist/lib/formats.js.map +1 -1
- package/dist/lib/render/convert.d.ts +11 -0
- package/dist/lib/render/convert.d.ts.map +1 -0
- package/dist/lib/render/convert.js +107 -0
- package/dist/lib/render/convert.js.map +1 -0
- package/dist/lib/render/pages.d.ts +11 -0
- package/dist/lib/render/pages.d.ts.map +1 -0
- package/dist/lib/render/pages.js +43 -0
- package/dist/lib/render/pages.js.map +1 -0
- package/dist/lib/render/render.d.ts +29 -0
- package/dist/lib/render/render.d.ts.map +1 -0
- package/dist/lib/render/render.js +142 -0
- package/dist/lib/render/render.js.map +1 -0
- package/dist/lib/sidecar.d.ts +11 -2
- package/dist/lib/sidecar.d.ts.map +1 -1
- package/dist/lib/sidecar.js +28 -16
- package/dist/lib/sidecar.js.map +1 -1
- package/dist/skill-authoring.d.ts +2 -0
- package/dist/skill-authoring.d.ts.map +1 -0
- package/dist/skill-authoring.js +20 -0
- package/dist/skill-authoring.js.map +1 -0
- package/dist/skill.d.ts.map +1 -1
- package/dist/skill.js +32 -8
- package/dist/skill.js.map +1 -1
- package/dist/testing.d.ts +67 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +151 -0
- package/dist/testing.js.map +1 -1
- package/package.json +21 -8
- package/src/app.ts +19 -7
- package/src/cli.integration.test.ts +115 -30
- package/src/commands/check.command.ts +97 -0
- package/src/commands/derive.command.ts +1 -1
- package/src/commands/read.command.ts +30 -52
- package/src/commands/render.command.ts +80 -0
- package/src/lib/archives.ts +1 -1
- package/src/lib/check/check.test.ts +446 -0
- package/src/lib/check/check.ts +49 -0
- package/src/lib/check/docx.ts +434 -0
- package/src/lib/check/finding.ts +63 -0
- package/src/lib/check/package.ts +199 -0
- package/src/lib/check/pdf.ts +228 -0
- package/src/lib/check/pptx.ts +641 -0
- package/src/lib/check/text-fit.ts +105 -0
- package/src/lib/check/xlsx.ts +163 -0
- package/src/lib/check/xml-tree.ts +186 -0
- package/src/lib/content-cache.ts +58 -0
- package/src/lib/derive.integration.test.ts +198 -0
- package/src/lib/derive.ts +66 -7
- package/src/lib/derivers/archive.ts +1 -1
- package/src/lib/derivers/image.ts +2 -1
- package/src/lib/derivers/load-cost.test.ts +1 -1
- package/src/lib/derivers/pdf.ts +1 -1
- package/src/lib/derivers/xlsx.ts +1 -1
- package/src/lib/formats.ts +6 -0
- package/src/lib/render/convert.ts +133 -0
- package/src/lib/render/pages.test.ts +38 -0
- package/src/lib/render/pages.ts +58 -0
- package/src/lib/render/render.ts +198 -0
- package/src/lib/sidecar.ts +42 -22
- package/src/render.integration.test.ts +217 -0
- package/src/skill-authoring.ts +27 -0
- package/src/skill.ts +36 -8
- package/src/testing.ts +287 -0
- package/dist/commands/sweep.command.d.ts +0 -3
- package/dist/commands/sweep.command.d.ts.map +0 -1
- package/dist/commands/sweep.command.js +0 -41
- package/dist/commands/sweep.command.js.map +0 -1
- package/dist/lib/flags.d.ts +0 -2
- package/dist/lib/flags.d.ts.map +0 -1
- package/dist/lib/flags.js +0 -8
- package/dist/lib/flags.js.map +0 -1
- package/dist/lib/sweep.d.ts +0 -7
- package/dist/lib/sweep.d.ts.map +0 -1
- package/dist/lib/sweep.js +0 -56
- package/dist/lib/sweep.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -3
- package/dist/version.js.map +0 -1
- package/src/commands/sweep.command.ts +0 -48
- package/src/lib/sweep.ts +0 -72
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,26 +1,45 @@
|
|
|
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
|
|
3
|
+
A CLI that shows an agent the contents of binary workspace files (Office documents, PDFs, images, audio, archives) as budgeted markdown, cached by content, 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
|
-
|
|
8
|
+
maker["Agent<br/>fileq check · render"] --> fileq
|
|
9
|
+
daemon["Daemon<br/>derive"] --> 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,
|
|
15
|
-
token cost, derived or fresh), then the markdown clipped to `--budget` tokens, and names the
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
17
|
+
token cost, derived or fresh), then the markdown clipped to `--budget` tokens, and names the file that holds the whole
|
|
18
|
+
text.
|
|
19
|
+
- Renderings are cached by content: keyed by the source's sha256 and the deriver's version stamp, never its path, so
|
|
20
|
+
a repeat read of unchanged content is instant, whether it is the same file, a copy or a move of it, or a file
|
|
21
|
+
outside the workspace. The entries live under `.intentic/local/cache/derived/.by-hash/`, or with no workspace under
|
|
22
|
+
`by-hash/` in `$FILEQ_HOME`, else `$XDG_CACHE_HOME/fileq`, else `~/.cache/fileq`. A cache that cannot be written costs the speed-up,
|
|
23
|
+
never the read.
|
|
24
|
+
- A workspace file also gets a sidecar at `.intentic/local/cache/derived/<path>.md`, fresh while its sha256 and the
|
|
25
|
+
stamp both match. Text is neutralized at write time, because a sidecar or a cache entry is later read as a plain
|
|
26
|
+
file.
|
|
27
|
+
- The daemon renders one file when asked with `fileq derive --json <path>` (`_sandbox/sandbox/src/derived/`), and
|
|
28
|
+
imports `./formats` and `./sidecar` so both sides agree on what is derivable.
|
|
22
29
|
- In the sandbox image, `git diff` and `git show` on a document print its text through `fileq read --plain`, wired by
|
|
23
30
|
`fileq git-attributes`.
|
|
31
|
+
- `fileq check <file>` lints a docx, pptx, xlsx or pdf an agent produced and names each problem where a reader meets
|
|
32
|
+
it (`slide 3 · "Title 1"`, `'Q3 plan'!C4`, `page 7`, `paragraph 12 · "…"`). An error is a fact read off the
|
|
33
|
+
structure (a missing image, a cell showing `#REF!`, a link to a bookmark that is not there, a blank page, Office's
|
|
34
|
+
own "Click to add title" left as text) and makes it exit 1; a warning is a judgement call or an estimate (text
|
|
35
|
+
overflowing its box, from average glyph widths). Some rules are adapted from SurfSense's artifact verification
|
|
36
|
+
(Apache-2.0); [NOTICE](NOTICE) names them.
|
|
37
|
+
- `fileq render <file>` draws pages or slides to PNG under `.intentic/local/cache/rendered/<path>/` (or `--out`) and
|
|
38
|
+
prints their paths for an image reader. Office formats go through LibreOffice to PDF first, keeping hidden slides
|
|
39
|
+
so slide N is image N; `pdftoppm` or `mutool` draws the PDF. A render is keyed by the document's hash, so an
|
|
40
|
+
unchanged file answers from the last one. A missing tool exits 2 with what installs it.
|
|
41
|
+
- Its skill ([src/skill.ts](src/skill.ts)) tells an agent to check and look at every document it makes, with short
|
|
42
|
+
authoring rules adapted from SurfSense's document skills ([src/skill-authoring.ts](src/skill-authoring.ts)).
|
|
24
43
|
- Out of scope: plain text files (read them directly), web pages ([webq](../webq)), OCR and transcription.
|
|
25
44
|
|
|
26
45
|
## Usage
|
|
@@ -28,16 +47,24 @@ flowchart LR
|
|
|
28
47
|
```sh
|
|
29
48
|
fileq report.docx # capsule + markdown up to 4000 tokens, whole text saved
|
|
30
49
|
fileq read deck.pptx --budget 8000 # a bigger slice on stdout
|
|
50
|
+
fileq check deck.pptx # problems by slide and drawing; exit 1 on an error
|
|
51
|
+
fileq render deck.pptx --pages 1-3 # slide-1.png … slide-3.png, one path per line
|
|
31
52
|
```
|
|
32
53
|
|
|
54
|
+
2026-09-29: rendering shells out to LibreOffice and poppler instead of bundling a renderer. pdf.js draws only onto a
|
|
55
|
+
canvas fileq does not carry, and an office layout faithful enough to judge overflow is LibreOffice itself. No published sandbox
|
|
56
|
+
image carries them: they are the opt-in `office` pack (`_sandbox/sandbox/image-packs/office.Dockerfile`, ~335 MB), so
|
|
57
|
+
there `fileq render` names the missing tool and prints `environment propose office --pack`, which asks the owner for it.
|
|
58
|
+
|
|
33
59
|
## Key files
|
|
34
60
|
|
|
35
61
|
- [src/app.ts](src/app.ts) — the command routes and the `--help` text an agent reads.
|
|
36
|
-
- [src/lib/derive.ts](src/lib/derive.ts) — `ensureSidecar`: the pipeline `read
|
|
62
|
+
- [src/lib/derive.ts](src/lib/derive.ts) — `ensureSidecar` and `renderByContent`: the pipeline `read` and `derive` both run.
|
|
63
|
+
- [src/lib/content-cache.ts](src/lib/content-cache.ts) — renderings keyed by content hash and deriver stamp.
|
|
37
64
|
- [src/lib/formats.ts](src/lib/formats.ts) — `detectFormat`: magic bytes first, extension as fallback.
|
|
38
65
|
- [src/lib/sidecar.ts](src/lib/sidecar.ts) — sidecar paths, front matter and the freshness rule.
|
|
39
|
-
- [src/lib/
|
|
40
|
-
- [src/
|
|
66
|
+
- [src/lib/check/check.ts](src/lib/check/check.ts) — `fileq check`: which formats have a checker; each format's rules sit beside it.
|
|
67
|
+
- [src/lib/render/render.ts](src/lib/render/render.ts) — `fileq render`: conversion, rasterizing and the render cache.
|
|
41
68
|
|
|
42
69
|
## Commands
|
|
43
70
|
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAyCA,eAAO,MAAM,GAAG,6EAkBf,CAAC"}
|
package/dist/app.js
CHANGED
|
@@ -1,35 +1,47 @@
|
|
|
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";
|
|
6
|
-
import {
|
|
7
|
+
import { renderCommand } from "./commands/render.command.js";
|
|
7
8
|
const HELP = `fileq — binary workspace files as clean, budgeted markdown.
|
|
8
9
|
|
|
9
10
|
Reads the formats an agent cannot: docx, xlsx, pptx, pdf (text layer), images
|
|
10
|
-
(dimensions + EXIF), audio/video (duration + tags), html.
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
(dimensions + EXIF), audio/video (duration + tags), html. Renderings are cached
|
|
12
|
+
by content hash, so reading unchanged bytes again (the same file, a copy, a
|
|
13
|
+
download outside the workspace) is instant; each workspace file also gets a
|
|
14
|
+
markdown SIDECAR under .intentic/local/cache/derived/<path>.md.
|
|
13
15
|
|
|
14
16
|
fileq <file> print it as markdown (default: read), budgeted
|
|
15
17
|
fileq read <file> --budget 8000
|
|
16
18
|
fileq derive <file…> converge named files' sidecars (stale→derive, gone→remove)
|
|
17
|
-
fileq sweep converge the whole workspace, prune orphaned sidecars
|
|
18
19
|
fileq read --plain <f> the markdown alone, for a program; git's textconv driver
|
|
19
20
|
fileq git-attributes the gitattributes that route documents through it
|
|
20
21
|
|
|
22
|
+
After producing a document, check it and look at it:
|
|
23
|
+
|
|
24
|
+
fileq check <file> docx, pptx, xlsx, pdf: problems a reader would meet, each
|
|
25
|
+
with its slide, page, cell or paragraph; exit 1 on an error
|
|
26
|
+
fileq render <file> [--pages 1-3] [--out <dir>]
|
|
27
|
+
pages or slides as PNG files, one path per line, for an
|
|
28
|
+
image reader (office formats need LibreOffice; all need
|
|
29
|
+
pdftoppm or mutool)
|
|
30
|
+
|
|
21
31
|
git diff, git show and git log -p on a document print its text, not "Binary
|
|
22
32
|
files differ": the sandbox names every derivable extension diff=fileq.
|
|
23
33
|
|
|
24
34
|
Not fileq's business: plain text (read it directly), the open web (webq),
|
|
25
35
|
files needing OCR or transcription (later tiers say so in their sidecars).
|
|
26
36
|
|
|
27
|
-
Exit codes: 0 content, 1 nothing derivable, 2 broken
|
|
37
|
+
Exit codes: 0 content, 1 nothing derivable (check: an error found), 2 broken
|
|
38
|
+
invocation or install (render: a tool it needs is missing).`;
|
|
28
39
|
export const app = buildApplication(buildRouteMap({
|
|
29
40
|
routes: {
|
|
30
41
|
read: readCommand,
|
|
42
|
+
check: checkCommand,
|
|
43
|
+
render: renderCommand,
|
|
31
44
|
derive: deriveCommand,
|
|
32
|
-
sweep: sweepCommand,
|
|
33
45
|
gitAttributes: gitAttributesCommand,
|
|
34
46
|
},
|
|
35
47
|
defaultCommand: "read",
|
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,
|
|
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;AAG7D,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,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 @@
|
|
|
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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CAAC;QAC1H,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClE,MAAM,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"}
|
|
@@ -30,7 +30,7 @@ export const deriveCommand = buildCommand({
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
if (files.length === 0) {
|
|
33
|
-
this.process.stdout.write("fileq: derive takes file paths
|
|
33
|
+
this.process.stdout.write("fileq: derive takes file paths\n");
|
|
34
34
|
process.exitCode = 2;
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.command.js","sourceRoot":"","sources":["../../src/commands/derive.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAuB,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAM9C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAU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 @@
|
|
|
1
|
-
{"version":3,"file":"read.command.d.ts","sourceRoot":"","sources":["../../src/commands/read.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read.command.d.ts","sourceRoot":"","sources":["../../src/commands/read.command.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAWlE,eAAO,MAAM,WAAW,iDA2CtB,CAAC"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
-
import { basename, join, resolve } from "node:path";
|
|
4
|
-
import { toolOutDir } from "@intentic/agent-cli/env";
|
|
1
|
+
import { basename, resolve } from "node:path";
|
|
5
2
|
import { countParser } from "@intentic/agent-cli/flags";
|
|
6
3
|
import { capsule, clip } from "@intentic/agent-cli/output";
|
|
7
4
|
import { estimateTokens } from "@intentic/base/format";
|
|
8
5
|
import { buildCommand } from "@stricli/core";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { detectFormat } from "../lib/formats.js";
|
|
12
|
-
import { DERIVERS, ensureSidecar } from "../lib/derive.js";
|
|
6
|
+
import { deriverStamp } from "../lib/derivers/deriver.js";
|
|
7
|
+
import { DERIVERS, ensureSidecar, renderByContent } from "../lib/derive.js";
|
|
13
8
|
import { workspaceRoot } from "../lib/env.js";
|
|
14
9
|
export const readCommand = buildCommand({
|
|
15
10
|
docs: { brief: "One file as clean markdown: budgeted on stdout, whole in its sidecar" },
|
|
@@ -17,7 +12,7 @@ export const readCommand = buildCommand({
|
|
|
17
12
|
flags: {
|
|
18
13
|
budget: { kind: "parsed", parse: countParser, default: "4000", brief: "Max stdout tokens; 0 prints only the capsule" },
|
|
19
14
|
json: { kind: "boolean", default: false, brief: "Machine-readable result on stdout" },
|
|
20
|
-
plain: { kind: "boolean", default: false, brief: "The markdown alone, whole and unbudgeted
|
|
15
|
+
plain: { kind: "boolean", default: false, brief: "The markdown alone, whole and unbudgeted (git textconv)" },
|
|
21
16
|
},
|
|
22
17
|
positional: {
|
|
23
18
|
kind: "tuple",
|
|
@@ -27,8 +22,7 @@ export const readCommand = buildCommand({
|
|
|
27
22
|
async func(flags, file) {
|
|
28
23
|
const absPath = resolve(file);
|
|
29
24
|
const root = workspaceRoot();
|
|
30
|
-
const
|
|
31
|
-
const result = root === undefined ? await readOutsideWorkspace(absPath, save) : await readInWorkspace(root, absPath, save);
|
|
25
|
+
const result = root === undefined ? await readOutsideWorkspace(undefined, absPath) : await readInWorkspace(root, absPath);
|
|
32
26
|
if (result === undefined) {
|
|
33
27
|
process.exitCode = 1;
|
|
34
28
|
return;
|
|
@@ -42,18 +36,22 @@ export const readCommand = buildCommand({
|
|
|
42
36
|
return;
|
|
43
37
|
}
|
|
44
38
|
const fields = [result.title ?? basename(absPath), result.format, `${result.tokens} tokens`, result.source];
|
|
45
|
-
|
|
46
|
-
this.process.stdout.write(
|
|
39
|
+
const notes = result.savedPath === undefined ? [...result.notes, "nothing saved: the rendering cache could not be written"] : result.notes;
|
|
40
|
+
this.process.stdout.write(capsule("fileq", fields, notes));
|
|
41
|
+
if (result.savedPath !== undefined) {
|
|
42
|
+
this.process.stdout.write(`saved: ${result.savedPath}\n`);
|
|
43
|
+
}
|
|
47
44
|
if (flags.budget > 0 && result.body !== "") {
|
|
45
|
+
const whole = result.savedPath ?? `the output of \`fileq read --plain ${absPath}\``;
|
|
48
46
|
this.process.stdout.write("---\n");
|
|
49
|
-
this.process.stdout.write(withFinalNewline(clip(result.body, flags.budget,
|
|
47
|
+
this.process.stdout.write(withFinalNewline(clip(result.body, flags.budget, whole, "document")));
|
|
50
48
|
}
|
|
51
49
|
},
|
|
52
50
|
});
|
|
53
|
-
const readInWorkspace = async (root, absPath
|
|
51
|
+
const readInWorkspace = async (root, absPath) => {
|
|
54
52
|
const outcome = await ensureSidecar(root, absPath);
|
|
55
53
|
if (outcome.kind === "skipped" && outcome.reason === "outside-workspace") {
|
|
56
|
-
return readOutsideWorkspace(
|
|
54
|
+
return readOutsideWorkspace(root, absPath);
|
|
57
55
|
}
|
|
58
56
|
return fromOutcome(outcome);
|
|
59
57
|
};
|
|
@@ -88,38 +86,21 @@ const fromOutcome = (outcome) => {
|
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
88
|
};
|
|
91
|
-
const readOutsideWorkspace = async (
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
process.stdout.write(`fileq: cannot read ${absPath}:
|
|
89
|
+
const readOutsideWorkspace = async (root, absPath) => {
|
|
90
|
+
const outcome = await renderByContent(root, absPath);
|
|
91
|
+
if (outcome.kind === "failed") {
|
|
92
|
+
process.stdout.write(`fileq: cannot read ${absPath}: ${outcome.reason}\n`);
|
|
95
93
|
return undefined;
|
|
96
94
|
}
|
|
97
|
-
let doc;
|
|
98
|
-
try {
|
|
99
|
-
doc = neutralizeDoc(await DERIVERS[format].derive(absPath));
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
process.stdout.write(`fileq: cannot read ${absPath}: derive-failed (${format}): ${errorMessage(error).split("\n")[0]}\n`);
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
const outDir = toolOutDir("fileq");
|
|
106
|
-
const hash = createHash("sha256").update(absPath).digest("hex").slice(0, 8);
|
|
107
|
-
const savedPath = join(outDir, `${basename(absPath)
|
|
108
|
-
.toLowerCase()
|
|
109
|
-
.replaceAll(/[^a-z0-9.]+/g, "-")}-${hash}.md`);
|
|
110
|
-
if (save) {
|
|
111
|
-
await mkdir(outDir, { recursive: true });
|
|
112
|
-
await writeFile(savedPath, `${doc.markdown}\n`);
|
|
113
|
-
}
|
|
114
95
|
return {
|
|
115
|
-
format,
|
|
116
|
-
deriver: deriverStamp(DERIVERS[format]),
|
|
117
|
-
body: doc.markdown,
|
|
118
|
-
tokens: estimateTokens(doc.markdown),
|
|
119
|
-
savedPath,
|
|
120
|
-
source:
|
|
121
|
-
title: doc.title,
|
|
122
|
-
notes: doc.notes,
|
|
96
|
+
format: outcome.format,
|
|
97
|
+
deriver: deriverStamp(DERIVERS[outcome.format]),
|
|
98
|
+
body: outcome.doc.markdown,
|
|
99
|
+
tokens: estimateTokens(outcome.doc.markdown),
|
|
100
|
+
savedPath: outcome.cachedPath,
|
|
101
|
+
source: outcome.kind,
|
|
102
|
+
title: outcome.doc.title,
|
|
103
|
+
notes: outcome.doc.notes,
|
|
123
104
|
};
|
|
124
105
|
};
|
|
125
106
|
const withFinalNewline = (text) => (text.endsWith("\n") ? text : `${text}\n`);
|