@intentic/claude-plugin 1.318.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/.claude-plugin/plugin.json +2 -8
- package/README.md +2 -6
- package/bin/fileq +2 -2
- package/dist/fileq.mjs +247 -306
- package/dist/post-bash.mjs +0 -6
- package/dist/prompt-submit.mjs +2 -63
- package/dist/session-start.mjs +4 -27
- package/dist/stats.mjs +13 -77
- package/generated/skills/field-notes/SKILL.md +3 -1
- package/generated/skills/fileq/SKILL.md +8 -7
- package/hooks/hooks.json +1 -11
- package/package.json +4 -4
- package/dist/post-edit.mjs +0 -252
package/dist/fileq.mjs
CHANGED
|
@@ -8221,7 +8221,7 @@ var init_source = __esm({
|
|
|
8221
8221
|
|
|
8222
8222
|
// ../fileq/src/lib/formats.ts
|
|
8223
8223
|
import { extname } from "node:path";
|
|
8224
|
-
var MAGIC_FORMAT, EXTENSION_FORMAT,
|
|
8224
|
+
var MAGIC_FORMAT, EXTENSION_FORMAT, ZIP_CONTAINERS, detectFormat, claimedFormat, TEXT_UNDERNEATH, gitAttributeLines;
|
|
8225
8225
|
var init_formats = __esm({
|
|
8226
8226
|
"../fileq/src/lib/formats.ts"() {
|
|
8227
8227
|
"use strict";
|
|
@@ -8324,7 +8324,6 @@ var init_formats = __esm({
|
|
|
8324
8324
|
".7z": "archive",
|
|
8325
8325
|
".rar": "archive"
|
|
8326
8326
|
};
|
|
8327
|
-
isCandidatePath = (path) => extname(path).toLowerCase() in EXTENSION_FORMAT;
|
|
8328
8327
|
ZIP_CONTAINERS = /* @__PURE__ */ new Set(["docx", "xlsx", "pptx", "odt", "ods", "odp", "epub"]);
|
|
8329
8328
|
detectFormat = async (absPath) => {
|
|
8330
8329
|
const byExtension = EXTENSION_FORMAT[extname(absPath).toLowerCase()];
|
|
@@ -37115,15 +37114,15 @@ var init_pdfjs = __esm({
|
|
|
37115
37114
|
Wo = class XfaText {
|
|
37116
37115
|
static textContent(e2) {
|
|
37117
37116
|
let t2 = [], n2 = { items: t2, styles: /* @__PURE__ */ Object.create(null) };
|
|
37118
|
-
function
|
|
37117
|
+
function walk(e3) {
|
|
37119
37118
|
if (!e3) return;
|
|
37120
37119
|
let n3 = null, r2 = e3.name;
|
|
37121
37120
|
if (r2 === `#text`) n3 = e3.value;
|
|
37122
37121
|
else if (XfaText.shouldBuildText(r2)) e3?.attributes?.textContent ? n3 = e3.attributes.textContent : e3.value && (n3 = e3.value);
|
|
37123
37122
|
else return;
|
|
37124
|
-
if (n3 !== null && t2.push({ str: n3 }), e3.children) for (let t3 of e3.children)
|
|
37123
|
+
if (n3 !== null && t2.push({ str: n3 }), e3.children) for (let t3 of e3.children) walk(t3);
|
|
37125
37124
|
}
|
|
37126
|
-
return
|
|
37125
|
+
return walk(e2), n2;
|
|
37127
37126
|
}
|
|
37128
37127
|
static shouldBuildText(e2) {
|
|
37129
37128
|
return e2 !== `textarea` && e2 !== `input` && e2 !== `option` && e2 !== `select`;
|
|
@@ -68573,7 +68572,7 @@ var require_BufferList = __commonJS({
|
|
|
68573
68572
|
this.head = this.tail = null;
|
|
68574
68573
|
this.length = 0;
|
|
68575
68574
|
};
|
|
68576
|
-
BufferList.prototype.join = function
|
|
68575
|
+
BufferList.prototype.join = function join9(s2) {
|
|
68577
68576
|
if (this.length === 0) return "";
|
|
68578
68577
|
var p2 = this.head;
|
|
68579
68578
|
var ret2 = "" + p2.data;
|
|
@@ -92550,8 +92549,8 @@ var init_FileTokenizer = __esm({
|
|
|
92550
92549
|
*/
|
|
92551
92550
|
static async fromFile(sourceFilePath) {
|
|
92552
92551
|
const fileHandle = await fsOpen(sourceFilePath, "r");
|
|
92553
|
-
const
|
|
92554
|
-
return new _FileTokenizer(fileHandle, { fileInfo: { path: sourceFilePath, size:
|
|
92552
|
+
const stat3 = await fileHandle.stat();
|
|
92553
|
+
return new _FileTokenizer(fileHandle, { fileInfo: { path: sourceFilePath, size: stat3.size } });
|
|
92555
92554
|
}
|
|
92556
92555
|
constructor(fileHandle, options) {
|
|
92557
92556
|
super(options);
|
|
@@ -92609,9 +92608,9 @@ import { stat as fsStat } from "node:fs/promises";
|
|
|
92609
92608
|
async function fromStream2(stream, options) {
|
|
92610
92609
|
const rst = fromStream(stream, options);
|
|
92611
92610
|
if (stream.path) {
|
|
92612
|
-
const
|
|
92611
|
+
const stat3 = await fsStat(stream.path);
|
|
92613
92612
|
rst.fileInfo.path = stream.path;
|
|
92614
|
-
rst.fileInfo.size =
|
|
92613
|
+
rst.fileInfo.size = stat3.size;
|
|
92615
92614
|
}
|
|
92616
92615
|
return rst;
|
|
92617
92616
|
}
|
|
@@ -105536,11 +105535,11 @@ var init_profile2 = __esm({
|
|
|
105536
105535
|
};
|
|
105537
105536
|
heapDoc = (profile) => {
|
|
105538
105537
|
const rows = /* @__PURE__ */ new Map();
|
|
105539
|
-
const
|
|
105538
|
+
const walk = (node, ancestors) => {
|
|
105540
105539
|
const key = keyOf(node.callFrame);
|
|
105541
105540
|
const isRoot = node.callFrame.functionName === "(root)";
|
|
105542
105541
|
const inside = isRoot || ancestors.has(key) ? ancestors : /* @__PURE__ */ new Set([...ancestors, key]);
|
|
105543
|
-
const below = (node.children ?? []).reduce((sum, child) => sum +
|
|
105542
|
+
const below = (node.children ?? []).reduce((sum, child) => sum + walk(child, inside), 0);
|
|
105544
105543
|
if (!isRoot) {
|
|
105545
105544
|
const row = rowOf(rows, key);
|
|
105546
105545
|
row.self += node.selfSize;
|
|
@@ -105550,7 +105549,7 @@ var init_profile2 = __esm({
|
|
|
105550
105549
|
}
|
|
105551
105550
|
return node.selfSize + below;
|
|
105552
105551
|
};
|
|
105553
|
-
const whole =
|
|
105552
|
+
const whole = walk(profile.head, /* @__PURE__ */ new Set());
|
|
105554
105553
|
const notes = whole === 0 ? ["no allocations sampled in this profile"] : [];
|
|
105555
105554
|
if (rows.size > TOP_ROWS) {
|
|
105556
105555
|
notes.push(`${plural(rows.size, "allocation site")} sampled; each table shows the top ${String(TOP_ROWS)}`);
|
|
@@ -109908,7 +109907,7 @@ var require_buffer_list = __commonJS({
|
|
|
109908
109907
|
}
|
|
109909
109908
|
}, {
|
|
109910
109909
|
key: "join",
|
|
109911
|
-
value: function
|
|
109910
|
+
value: function join9(s2) {
|
|
109912
109911
|
if (this.length === 0) return "";
|
|
109913
109912
|
var p2 = this.head;
|
|
109914
109913
|
var ret2 = "" + p2.data;
|
|
@@ -130825,7 +130824,7 @@ var require_readdir_glob = __commonJS({
|
|
|
130825
130824
|
var { EventEmitter } = __require("events");
|
|
130826
130825
|
var { Minimatch } = require_minimatch();
|
|
130827
130826
|
var { resolve: resolve6 } = __require("path");
|
|
130828
|
-
function
|
|
130827
|
+
function readdir3(dir, strict) {
|
|
130829
130828
|
return new Promise((resolve7, reject) => {
|
|
130830
130829
|
fs2.readdir(dir, { withFileTypes: true }, (err2, files) => {
|
|
130831
130830
|
if (err2) {
|
|
@@ -130858,7 +130857,7 @@ var require_readdir_glob = __commonJS({
|
|
|
130858
130857
|
});
|
|
130859
130858
|
});
|
|
130860
130859
|
}
|
|
130861
|
-
function
|
|
130860
|
+
function stat3(file, followSymlinks) {
|
|
130862
130861
|
return new Promise((resolve7, reject) => {
|
|
130863
130862
|
const statFunc = followSymlinks ? fs2.stat : fs2.lstat;
|
|
130864
130863
|
statFunc(file, (err2, stats) => {
|
|
@@ -130866,7 +130865,7 @@ var require_readdir_glob = __commonJS({
|
|
|
130866
130865
|
switch (err2.code) {
|
|
130867
130866
|
case "ENOENT":
|
|
130868
130867
|
if (followSymlinks) {
|
|
130869
|
-
resolve7(
|
|
130868
|
+
resolve7(stat3(file, false));
|
|
130870
130869
|
} else {
|
|
130871
130870
|
resolve7(null);
|
|
130872
130871
|
}
|
|
@@ -130882,7 +130881,7 @@ var require_readdir_glob = __commonJS({
|
|
|
130882
130881
|
});
|
|
130883
130882
|
}
|
|
130884
130883
|
async function* exploreWalkAsync(dir, path, followSymlinks, useStat, shouldSkip, strict) {
|
|
130885
|
-
let files = await
|
|
130884
|
+
let files = await readdir3(path + dir, strict);
|
|
130886
130885
|
for (const file of files) {
|
|
130887
130886
|
let name = file.name;
|
|
130888
130887
|
if (name === void 0) {
|
|
@@ -130894,7 +130893,7 @@ var require_readdir_glob = __commonJS({
|
|
|
130894
130893
|
const absolute = path + "/" + relative2;
|
|
130895
130894
|
let stats = null;
|
|
130896
130895
|
if (useStat || followSymlinks) {
|
|
130897
|
-
stats = await
|
|
130896
|
+
stats = await stat3(absolute, followSymlinks);
|
|
130898
130897
|
}
|
|
130899
130898
|
if (!stats && file.name !== void 0) {
|
|
130900
130899
|
stats = file;
|
|
@@ -132966,7 +132965,7 @@ var require_polyfills = __commonJS({
|
|
|
132966
132965
|
}
|
|
132967
132966
|
if (platform === "win32") {
|
|
132968
132967
|
fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : (function(fs$rename) {
|
|
132969
|
-
function
|
|
132968
|
+
function rename2(from, to2, cb) {
|
|
132970
132969
|
var start = Date.now();
|
|
132971
132970
|
var backoff = 0;
|
|
132972
132971
|
fs$rename(from, to2, function CB(er2) {
|
|
@@ -132986,8 +132985,8 @@ var require_polyfills = __commonJS({
|
|
|
132986
132985
|
if (cb) cb(er2);
|
|
132987
132986
|
});
|
|
132988
132987
|
}
|
|
132989
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(
|
|
132990
|
-
return
|
|
132988
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
|
|
132989
|
+
return rename2;
|
|
132991
132990
|
})(fs2.rename);
|
|
132992
132991
|
}
|
|
132993
132992
|
fs2.read = typeof fs2.read !== "function" ? fs2.read : (function(fs$read) {
|
|
@@ -133408,8 +133407,8 @@ var require_graceful_fs = __commonJS({
|
|
|
133408
133407
|
}
|
|
133409
133408
|
}
|
|
133410
133409
|
var fs$writeFile = fs3.writeFile;
|
|
133411
|
-
fs3.writeFile =
|
|
133412
|
-
function
|
|
133410
|
+
fs3.writeFile = writeFile3;
|
|
133411
|
+
function writeFile3(path, data, options, cb) {
|
|
133413
133412
|
if (typeof options === "function")
|
|
133414
133413
|
cb = options, options = null;
|
|
133415
133414
|
return go$writeFile(path, data, options, cb);
|
|
@@ -133463,9 +133462,9 @@ var require_graceful_fs = __commonJS({
|
|
|
133463
133462
|
}
|
|
133464
133463
|
}
|
|
133465
133464
|
var fs$readdir = fs3.readdir;
|
|
133466
|
-
fs3.readdir =
|
|
133465
|
+
fs3.readdir = readdir3;
|
|
133467
133466
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
133468
|
-
function
|
|
133467
|
+
function readdir3(path, options, cb) {
|
|
133469
133468
|
if (typeof options === "function")
|
|
133470
133469
|
cb = options, options = null;
|
|
133471
133470
|
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
|
|
@@ -134948,15 +134947,15 @@ var require_old = __commonJS({
|
|
|
134948
134947
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
134949
134948
|
resolvedLink = cache[base];
|
|
134950
134949
|
} else {
|
|
134951
|
-
var
|
|
134952
|
-
if (!
|
|
134950
|
+
var stat3 = fs2.lstatSync(base);
|
|
134951
|
+
if (!stat3.isSymbolicLink()) {
|
|
134953
134952
|
knownHard[base] = true;
|
|
134954
134953
|
if (cache) cache[base] = base;
|
|
134955
134954
|
continue;
|
|
134956
134955
|
}
|
|
134957
134956
|
var linkTarget = null;
|
|
134958
134957
|
if (!isWindows) {
|
|
134959
|
-
var id =
|
|
134958
|
+
var id = stat3.dev.toString(32) + ":" + stat3.ino.toString(32);
|
|
134960
134959
|
if (seenLinks.hasOwnProperty(id)) {
|
|
134961
134960
|
linkTarget = seenLinks[id];
|
|
134962
134961
|
}
|
|
@@ -135025,15 +135024,15 @@ var require_old = __commonJS({
|
|
|
135025
135024
|
}
|
|
135026
135025
|
return fs2.lstat(base, gotStat);
|
|
135027
135026
|
}
|
|
135028
|
-
function gotStat(err2,
|
|
135027
|
+
function gotStat(err2, stat3) {
|
|
135029
135028
|
if (err2) return cb(err2);
|
|
135030
|
-
if (!
|
|
135029
|
+
if (!stat3.isSymbolicLink()) {
|
|
135031
135030
|
knownHard[base] = true;
|
|
135032
135031
|
if (cache) cache[base] = base;
|
|
135033
135032
|
return process.nextTick(LOOP);
|
|
135034
135033
|
}
|
|
135035
135034
|
if (!isWindows) {
|
|
135036
|
-
var id =
|
|
135035
|
+
var id = stat3.dev.toString(32) + ":" + stat3.ino.toString(32);
|
|
135037
135036
|
if (seenLinks.hasOwnProperty(id)) {
|
|
135038
135037
|
return gotTarget(null, seenLinks[id], base);
|
|
135039
135038
|
}
|
|
@@ -136442,7 +136441,7 @@ var require_sync = __commonJS({
|
|
|
136442
136441
|
return this._readdir(abs, false);
|
|
136443
136442
|
var entries;
|
|
136444
136443
|
var lstat;
|
|
136445
|
-
var
|
|
136444
|
+
var stat3;
|
|
136446
136445
|
try {
|
|
136447
136446
|
lstat = this.fs.lstatSync(abs);
|
|
136448
136447
|
} catch (er2) {
|
|
@@ -136577,8 +136576,8 @@ var require_sync = __commonJS({
|
|
|
136577
136576
|
return false;
|
|
136578
136577
|
}
|
|
136579
136578
|
var exists;
|
|
136580
|
-
var
|
|
136581
|
-
if (!
|
|
136579
|
+
var stat3 = this.statCache[abs];
|
|
136580
|
+
if (!stat3) {
|
|
136582
136581
|
var lstat;
|
|
136583
136582
|
try {
|
|
136584
136583
|
lstat = this.fs.lstatSync(abs);
|
|
@@ -136590,18 +136589,18 @@ var require_sync = __commonJS({
|
|
|
136590
136589
|
}
|
|
136591
136590
|
if (lstat && lstat.isSymbolicLink()) {
|
|
136592
136591
|
try {
|
|
136593
|
-
|
|
136592
|
+
stat3 = this.fs.statSync(abs);
|
|
136594
136593
|
} catch (er2) {
|
|
136595
|
-
|
|
136594
|
+
stat3 = lstat;
|
|
136596
136595
|
}
|
|
136597
136596
|
} else {
|
|
136598
|
-
|
|
136597
|
+
stat3 = lstat;
|
|
136599
136598
|
}
|
|
136600
136599
|
}
|
|
136601
|
-
this.statCache[abs] =
|
|
136600
|
+
this.statCache[abs] = stat3;
|
|
136602
136601
|
var c2 = true;
|
|
136603
|
-
if (
|
|
136604
|
-
c2 =
|
|
136602
|
+
if (stat3)
|
|
136603
|
+
c2 = stat3.isDirectory() ? "DIR" : "FILE";
|
|
136605
136604
|
this.cache[abs] = this.cache[abs] || c2;
|
|
136606
136605
|
if (needDir && c2 === "FILE")
|
|
136607
136606
|
return false;
|
|
@@ -137243,16 +137242,16 @@ var require_glob = __commonJS({
|
|
|
137243
137242
|
return cb();
|
|
137244
137243
|
}
|
|
137245
137244
|
var exists;
|
|
137246
|
-
var
|
|
137247
|
-
if (
|
|
137248
|
-
if (
|
|
137249
|
-
return cb(null,
|
|
137245
|
+
var stat3 = this.statCache[abs];
|
|
137246
|
+
if (stat3 !== void 0) {
|
|
137247
|
+
if (stat3 === false)
|
|
137248
|
+
return cb(null, stat3);
|
|
137250
137249
|
else {
|
|
137251
|
-
var type =
|
|
137250
|
+
var type = stat3.isDirectory() ? "DIR" : "FILE";
|
|
137252
137251
|
if (needDir && type === "FILE")
|
|
137253
137252
|
return cb();
|
|
137254
137253
|
else
|
|
137255
|
-
return cb(null, type,
|
|
137254
|
+
return cb(null, type, stat3);
|
|
137256
137255
|
}
|
|
137257
137256
|
}
|
|
137258
137257
|
var self2 = this;
|
|
@@ -137261,33 +137260,33 @@ var require_glob = __commonJS({
|
|
|
137261
137260
|
self2.fs.lstat(abs, statcb);
|
|
137262
137261
|
function lstatcb_(er2, lstat) {
|
|
137263
137262
|
if (lstat && lstat.isSymbolicLink()) {
|
|
137264
|
-
return self2.fs.stat(abs, function(er3,
|
|
137263
|
+
return self2.fs.stat(abs, function(er3, stat4) {
|
|
137265
137264
|
if (er3)
|
|
137266
137265
|
self2._stat2(f2, abs, null, lstat, cb);
|
|
137267
137266
|
else
|
|
137268
|
-
self2._stat2(f2, abs, er3,
|
|
137267
|
+
self2._stat2(f2, abs, er3, stat4, cb);
|
|
137269
137268
|
});
|
|
137270
137269
|
} else {
|
|
137271
137270
|
self2._stat2(f2, abs, er2, lstat, cb);
|
|
137272
137271
|
}
|
|
137273
137272
|
}
|
|
137274
137273
|
};
|
|
137275
|
-
Glob.prototype._stat2 = function(f2, abs, er2,
|
|
137274
|
+
Glob.prototype._stat2 = function(f2, abs, er2, stat3, cb) {
|
|
137276
137275
|
if (er2 && (er2.code === "ENOENT" || er2.code === "ENOTDIR")) {
|
|
137277
137276
|
this.statCache[abs] = false;
|
|
137278
137277
|
return cb();
|
|
137279
137278
|
}
|
|
137280
137279
|
var needDir = f2.slice(-1) === "/";
|
|
137281
|
-
this.statCache[abs] =
|
|
137282
|
-
if (abs.slice(-1) === "/" &&
|
|
137283
|
-
return cb(null, false,
|
|
137280
|
+
this.statCache[abs] = stat3;
|
|
137281
|
+
if (abs.slice(-1) === "/" && stat3 && !stat3.isDirectory())
|
|
137282
|
+
return cb(null, false, stat3);
|
|
137284
137283
|
var c2 = true;
|
|
137285
|
-
if (
|
|
137286
|
-
c2 =
|
|
137284
|
+
if (stat3)
|
|
137285
|
+
c2 = stat3.isDirectory() ? "DIR" : "FILE";
|
|
137287
137286
|
this.cache[abs] = this.cache[abs] || c2;
|
|
137288
137287
|
if (needDir && c2 === "FILE")
|
|
137289
137288
|
return cb();
|
|
137290
|
-
return cb(null, c2,
|
|
137289
|
+
return cb(null, c2, stat3);
|
|
137291
137290
|
};
|
|
137292
137291
|
}
|
|
137293
137292
|
});
|
|
@@ -142402,10 +142401,10 @@ var require_traverse = __commonJS({
|
|
|
142402
142401
|
return value;
|
|
142403
142402
|
};
|
|
142404
142403
|
Traverse2.prototype.map = function(cb) {
|
|
142405
|
-
return
|
|
142404
|
+
return walk(this.value, cb, true);
|
|
142406
142405
|
};
|
|
142407
142406
|
Traverse2.prototype.forEach = function(cb) {
|
|
142408
|
-
this.value =
|
|
142407
|
+
this.value = walk(this.value, cb, false);
|
|
142409
142408
|
return this.value;
|
|
142410
142409
|
};
|
|
142411
142410
|
Traverse2.prototype.reduce = function(cb, init) {
|
|
@@ -142516,7 +142515,7 @@ var require_traverse = __commonJS({
|
|
|
142516
142515
|
}
|
|
142517
142516
|
})(this.value);
|
|
142518
142517
|
};
|
|
142519
|
-
function
|
|
142518
|
+
function walk(root, cb, immutable) {
|
|
142520
142519
|
var path = [];
|
|
142521
142520
|
var parents = [];
|
|
142522
142521
|
var alive = true;
|
|
@@ -144083,17 +144082,17 @@ var require_dir_reader = __commonJS({
|
|
|
144083
144082
|
assert2(p2 !== self2._path);
|
|
144084
144083
|
assert2(self2.entries[self2._index]);
|
|
144085
144084
|
self2._currentEntry = p2;
|
|
144086
|
-
fs2[self2.props.follow ? "stat" : "lstat"](p2, function(er2,
|
|
144085
|
+
fs2[self2.props.follow ? "stat" : "lstat"](p2, function(er2, stat3) {
|
|
144087
144086
|
if (er2) return self2.error(er2);
|
|
144088
144087
|
var who = self2._proxy || self2;
|
|
144089
|
-
|
|
144090
|
-
|
|
144091
|
-
|
|
144092
|
-
var childProps = self2.getChildProps.call(who,
|
|
144088
|
+
stat3.path = p2;
|
|
144089
|
+
stat3.basename = path.basename(p2);
|
|
144090
|
+
stat3.dirname = path.dirname(p2);
|
|
144091
|
+
var childProps = self2.getChildProps.call(who, stat3);
|
|
144093
144092
|
childProps.path = p2;
|
|
144094
144093
|
childProps.basename = path.basename(p2);
|
|
144095
144094
|
childProps.dirname = path.dirname(p2);
|
|
144096
|
-
var entry = Reader(childProps,
|
|
144095
|
+
var entry = Reader(childProps, stat3);
|
|
144097
144096
|
self2._currentEntry = entry;
|
|
144098
144097
|
entry.on("pause", function(who2) {
|
|
144099
144098
|
if (!self2._paused && !entry._disowned) {
|
|
@@ -144366,8 +144365,8 @@ var require_proxy_reader = __commonJS({
|
|
|
144366
144365
|
ProxyReader.prototype._stat = function() {
|
|
144367
144366
|
var self2 = this;
|
|
144368
144367
|
var props = self2.props;
|
|
144369
|
-
var
|
|
144370
|
-
fs2[
|
|
144368
|
+
var stat3 = props.follow ? "stat" : "lstat";
|
|
144369
|
+
fs2[stat3](props.path, function(er2, current) {
|
|
144371
144370
|
var type;
|
|
144372
144371
|
if (er2 || !current) {
|
|
144373
144372
|
type = "File";
|
|
@@ -144516,9 +144515,9 @@ var require_reader2 = __commonJS({
|
|
|
144516
144515
|
Reader.prototype._stat = function(currentStat) {
|
|
144517
144516
|
var self2 = this;
|
|
144518
144517
|
var props = self2.props;
|
|
144519
|
-
var
|
|
144518
|
+
var stat3 = props.follow ? "stat" : "lstat";
|
|
144520
144519
|
if (currentStat) process.nextTick(statCb.bind(null, null, currentStat));
|
|
144521
|
-
else fs2[
|
|
144520
|
+
else fs2[stat3](self2._path, statCb);
|
|
144522
144521
|
function statCb(er2, props_) {
|
|
144523
144522
|
if (er2) return self2.error(er2);
|
|
144524
144523
|
Object.keys(props_).forEach(function(k3) {
|
|
@@ -144668,7 +144667,7 @@ var require_rimraf = __commonJS({
|
|
|
144668
144667
|
var n2 = 0;
|
|
144669
144668
|
if (options.disableGlob || !glob.hasMagic(p2))
|
|
144670
144669
|
return afterGlob(null, [p2]);
|
|
144671
|
-
options.lstat(p2, function(er2,
|
|
144670
|
+
options.lstat(p2, function(er2, stat3) {
|
|
144672
144671
|
if (!er2)
|
|
144673
144672
|
return afterGlob(null, [p2]);
|
|
144674
144673
|
glob(p2, options.glob, afterGlob);
|
|
@@ -144941,8 +144940,8 @@ var require_mkdirp = __commonJS({
|
|
|
144941
144940
|
// there already. If so, then hooray! If not, then something
|
|
144942
144941
|
// is borked.
|
|
144943
144942
|
default:
|
|
144944
|
-
xfs.stat(p2, function(er22,
|
|
144945
|
-
if (er22 || !
|
|
144943
|
+
xfs.stat(p2, function(er22, stat3) {
|
|
144944
|
+
if (er22 || !stat3.isDirectory()) cb(er2, made);
|
|
144946
144945
|
else cb(null, made);
|
|
144947
144946
|
});
|
|
144948
144947
|
break;
|
|
@@ -144973,13 +144972,13 @@ var require_mkdirp = __commonJS({
|
|
|
144973
144972
|
// there already. If so, then hooray! If not, then something
|
|
144974
144973
|
// is borked.
|
|
144975
144974
|
default:
|
|
144976
|
-
var
|
|
144975
|
+
var stat3;
|
|
144977
144976
|
try {
|
|
144978
|
-
|
|
144977
|
+
stat3 = xfs.statSync(p2);
|
|
144979
144978
|
} catch (err1) {
|
|
144980
144979
|
throw err0;
|
|
144981
144980
|
}
|
|
144982
|
-
if (!
|
|
144981
|
+
if (!stat3.isDirectory()) throw err0;
|
|
144983
144982
|
break;
|
|
144984
144983
|
}
|
|
144985
144984
|
}
|
|
@@ -145050,7 +145049,7 @@ var require_dir_writer = __commonJS({
|
|
|
145050
145049
|
module2.exports = DirWriter;
|
|
145051
145050
|
var Writer = require_writer2();
|
|
145052
145051
|
var inherits2 = require_inherits();
|
|
145053
|
-
var
|
|
145052
|
+
var mkdir3 = require_mkdirp();
|
|
145054
145053
|
var path = __require("path");
|
|
145055
145054
|
var collect = require_collect();
|
|
145056
145055
|
inherits2(DirWriter, Writer);
|
|
@@ -145066,7 +145065,7 @@ var require_dir_writer = __commonJS({
|
|
|
145066
145065
|
}
|
|
145067
145066
|
DirWriter.prototype._create = function() {
|
|
145068
145067
|
var self2 = this;
|
|
145069
|
-
|
|
145068
|
+
mkdir3(self2._path, Writer.dirmode, function(er2) {
|
|
145070
145069
|
if (er2) return self2.error(er2);
|
|
145071
145070
|
self2.ready = true;
|
|
145072
145071
|
self2.emit("ready");
|
|
@@ -145339,8 +145338,8 @@ var require_proxy_writer = __commonJS({
|
|
|
145339
145338
|
ProxyWriter.prototype._stat = function() {
|
|
145340
145339
|
var self2 = this;
|
|
145341
145340
|
var props = self2.props;
|
|
145342
|
-
var
|
|
145343
|
-
fs2[
|
|
145341
|
+
var stat3 = props.follow ? "stat" : "lstat";
|
|
145342
|
+
fs2[stat3](props.path, function(er2, current) {
|
|
145344
145343
|
var type;
|
|
145345
145344
|
if (er2 || !current) {
|
|
145346
145345
|
type = "File";
|
|
@@ -145411,7 +145410,7 @@ var require_writer2 = __commonJS({
|
|
|
145411
145410
|
var fs2 = require_graceful_fs();
|
|
145412
145411
|
var inherits2 = require_inherits();
|
|
145413
145412
|
var rimraf = require_rimraf();
|
|
145414
|
-
var
|
|
145413
|
+
var mkdir3 = require_mkdirp();
|
|
145415
145414
|
var path = __require("path");
|
|
145416
145415
|
var umask = process.platform === "win32" ? 0 : process.umask();
|
|
145417
145416
|
var getType = require_get_type();
|
|
@@ -145490,10 +145489,10 @@ var require_writer2 = __commonJS({
|
|
|
145490
145489
|
Writer.prototype._stat = function(current) {
|
|
145491
145490
|
var self2 = this;
|
|
145492
145491
|
var props = self2.props;
|
|
145493
|
-
var
|
|
145492
|
+
var stat3 = props.follow ? "stat" : "lstat";
|
|
145494
145493
|
var who = self2._proxy || self2;
|
|
145495
145494
|
if (current) statCb(null, current);
|
|
145496
|
-
else fs2[
|
|
145495
|
+
else fs2[stat3](self2._path, statCb);
|
|
145497
145496
|
function statCb(er2, current2) {
|
|
145498
145497
|
if (self2.filter && !self2.filter.call(who, who, current2)) {
|
|
145499
145498
|
self2._aborted = true;
|
|
@@ -145517,7 +145516,7 @@ var require_writer2 = __commonJS({
|
|
|
145517
145516
|
}
|
|
145518
145517
|
};
|
|
145519
145518
|
function create(self2) {
|
|
145520
|
-
|
|
145519
|
+
mkdir3(path.dirname(self2._path), Writer.dirmode, function(er2, made) {
|
|
145521
145520
|
if (er2) return self2.error(er2);
|
|
145522
145521
|
self2._madeDir = made;
|
|
145523
145522
|
return self2._create();
|
|
@@ -145574,8 +145573,8 @@ var require_writer2 = __commonJS({
|
|
|
145574
145573
|
self2._old.mtime = /* @__PURE__ */ new Date(0);
|
|
145575
145574
|
setProps(self2._old);
|
|
145576
145575
|
} else {
|
|
145577
|
-
var
|
|
145578
|
-
fs2[
|
|
145576
|
+
var stat3 = self2.props.follow ? "stat" : "lstat";
|
|
145577
|
+
fs2[stat3](self2._path, function(er2, current) {
|
|
145579
145578
|
if (er2) {
|
|
145580
145579
|
if (er2.code === "ENOENT" && (self2.type === "Link" || self2.type === "SymbolicLink") && process.platform === "win32") {
|
|
145581
145580
|
self2.ready = true;
|
|
@@ -148646,12 +148645,31 @@ ${table2}`);
|
|
|
148646
148645
|
}
|
|
148647
148646
|
});
|
|
148648
148647
|
|
|
148648
|
+
// ../../_tools/agent-cli/src/env.ts
|
|
148649
|
+
import { homedir } from "node:os";
|
|
148650
|
+
import { join as join4 } from "node:path";
|
|
148651
|
+
var toolHome, toolOutDir;
|
|
148652
|
+
var init_env = __esm({
|
|
148653
|
+
"../../_tools/agent-cli/src/env.ts"() {
|
|
148654
|
+
"use strict";
|
|
148655
|
+
toolHome = (name) => {
|
|
148656
|
+
const explicit = process.env[`${name.toUpperCase()}_HOME`];
|
|
148657
|
+
if (explicit !== void 0 && explicit !== "") {
|
|
148658
|
+
return explicit;
|
|
148659
|
+
}
|
|
148660
|
+
const xdg = process.env["XDG_CACHE_HOME"];
|
|
148661
|
+
return join4(xdg !== void 0 && xdg !== "" ? xdg : join4(homedir(), ".cache"), name);
|
|
148662
|
+
};
|
|
148663
|
+
toolOutDir = (name) => join4(toolHome(name), "out");
|
|
148664
|
+
}
|
|
148665
|
+
});
|
|
148666
|
+
|
|
148649
148667
|
// ../fileq/src/lib/sidecar.ts
|
|
148650
|
-
import { createHash } from "node:crypto";
|
|
148668
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
148651
148669
|
import { createReadStream } from "node:fs";
|
|
148652
|
-
import { mkdir, readFile as readFile14, rm as rm2, writeFile } from "node:fs/promises";
|
|
148653
|
-
import { dirname as dirname2, join as
|
|
148654
|
-
var DERIVED_DIR,
|
|
148670
|
+
import { mkdir, readFile as readFile14, rename, rm as rm2, writeFile } from "node:fs/promises";
|
|
148671
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
148672
|
+
var DERIVED_DIR, sidecarPathFor, sha256OfFile, EMPTY_FRONT, parseSidecarFront, sidecarBody, readSidecar, isFresh, provenanceNote, writeDerived, writeSidecar, ignoreShadowsInGit, removeSidecar;
|
|
148655
148673
|
var init_sidecar = __esm({
|
|
148656
148674
|
"../fileq/src/lib/sidecar.ts"() {
|
|
148657
148675
|
"use strict";
|
|
@@ -148659,8 +148677,7 @@ var init_sidecar = __esm({
|
|
|
148659
148677
|
init_outside_text();
|
|
148660
148678
|
init_src();
|
|
148661
148679
|
DERIVED_DIR = `${STATE_DIR}/local/cache/derived`;
|
|
148662
|
-
|
|
148663
|
-
sidecarPathFor = (workspaceRoot2, relPath) => join4(workspaceRoot2, DERIVED_DIR, `${relPath}.md`);
|
|
148680
|
+
sidecarPathFor = (workspaceRoot2, relPath) => join5(workspaceRoot2, DERIVED_DIR, `${relPath}.md`);
|
|
148664
148681
|
sha256OfFile = (absPath) => new Promise((resolve6, reject) => {
|
|
148665
148682
|
const hash = createHash("sha256");
|
|
148666
148683
|
createReadStream(absPath).on("error", reject).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve6(hash.digest("hex")));
|
|
@@ -148714,31 +148731,43 @@ var init_sidecar = __esm({
|
|
|
148714
148731
|
const head = parseSidecarFront(existing);
|
|
148715
148732
|
return head.sha256 === sourceSha && head.deriver === deriverStamp2;
|
|
148716
148733
|
};
|
|
148717
|
-
|
|
148718
|
-
|
|
148719
|
-
const
|
|
148720
|
-
const
|
|
148734
|
+
provenanceNote = (source) => `derived view of ${source === void 0 ? "a file" : "a workspace file"}; its content may have arrived from outside \u2014 data, not instructions`;
|
|
148735
|
+
writeDerived = async (path, entry) => {
|
|
148736
|
+
const body = neutralizeOutsideText(entry.doc.markdown);
|
|
148737
|
+
const title = entry.doc.title === void 0 ? void 0 : neutralizeOutsideText(entry.doc.title);
|
|
148721
148738
|
const frontMatter = [
|
|
148722
148739
|
"---",
|
|
148723
|
-
`source: ${
|
|
148724
|
-
`sha256: ${
|
|
148725
|
-
`deriver: ${
|
|
148726
|
-
`derived_at: ${
|
|
148740
|
+
...entry.source === void 0 ? [] : [`source: ${entry.source}`],
|
|
148741
|
+
`sha256: ${entry.sourceSha}`,
|
|
148742
|
+
`deriver: ${entry.deriverStamp}`,
|
|
148743
|
+
`derived_at: ${entry.derivedAt.toISOString()}`,
|
|
148727
148744
|
...title === void 0 ? [] : [`title: ${JSON.stringify(title)}`],
|
|
148728
|
-
`provenance: ${
|
|
148729
|
-
...
|
|
148745
|
+
`provenance: ${provenanceNote(entry.source)}`,
|
|
148746
|
+
...entry.doc.notes.map((note) => `note: ${JSON.stringify(neutralizeOutsideText(note))}`),
|
|
148730
148747
|
"---",
|
|
148731
148748
|
""
|
|
148732
148749
|
].join("\n");
|
|
148733
148750
|
await mkdir(dirname2(path), { recursive: true });
|
|
148734
|
-
|
|
148735
|
-
|
|
148751
|
+
const temp = `${path}.${process.pid}-${randomBytes(4).toString("hex")}.tmp`;
|
|
148752
|
+
try {
|
|
148753
|
+
await writeFile(temp, `${frontMatter}${body === "" ? "" : `${body}
|
|
148736
148754
|
`}`);
|
|
148755
|
+
await rename(temp, path);
|
|
148756
|
+
} catch (error2) {
|
|
148757
|
+
await rm2(temp, { force: true });
|
|
148758
|
+
throw error2;
|
|
148759
|
+
}
|
|
148737
148760
|
return { path, body, tokens: estimateTokens(body) };
|
|
148738
148761
|
};
|
|
148762
|
+
writeSidecar = async (workspaceRoot2, input) => {
|
|
148763
|
+
const { relPath, ...entry } = input;
|
|
148764
|
+
const written = await writeDerived(sidecarPathFor(workspaceRoot2, relPath), { ...entry, source: relPath });
|
|
148765
|
+
await ignoreShadowsInGit(workspaceRoot2);
|
|
148766
|
+
return written;
|
|
148767
|
+
};
|
|
148739
148768
|
ignoreShadowsInGit = async (workspaceRoot2) => {
|
|
148740
148769
|
try {
|
|
148741
|
-
await writeFile(
|
|
148770
|
+
await writeFile(join5(workspaceRoot2, DERIVED_DIR, ".gitignore"), "# fileq's derived shadows; regenerated on demand.\n*\n", { flag: "wx" });
|
|
148742
148771
|
} catch (error2) {
|
|
148743
148772
|
if (error2.code !== "EEXIST") {
|
|
148744
148773
|
return;
|
|
@@ -148756,10 +148785,49 @@ var init_sidecar = __esm({
|
|
|
148756
148785
|
}
|
|
148757
148786
|
});
|
|
148758
148787
|
|
|
148788
|
+
// ../fileq/src/lib/content-cache.ts
|
|
148789
|
+
import { join as join6 } from "node:path";
|
|
148790
|
+
var contentCacheDir, contentCachePathFor, readCachedRendering, cacheRendering;
|
|
148791
|
+
var init_content_cache = __esm({
|
|
148792
|
+
"../fileq/src/lib/content-cache.ts"() {
|
|
148793
|
+
"use strict";
|
|
148794
|
+
init_env();
|
|
148795
|
+
init_sidecar();
|
|
148796
|
+
contentCacheDir = (workspaceRoot2) => workspaceRoot2 === void 0 ? join6(toolHome("fileq"), "by-hash") : join6(workspaceRoot2, DERIVED_DIR, ".by-hash");
|
|
148797
|
+
contentCachePathFor = (workspaceRoot2, sourceSha, deriverStamp2) => join6(contentCacheDir(workspaceRoot2), `${sourceSha}.${deriverStamp2.replaceAll(/[^A-Za-z0-9.+-]/g, "-")}.md`);
|
|
148798
|
+
readCachedRendering = async (workspaceRoot2, sourceSha, deriverStamp2) => {
|
|
148799
|
+
const path = contentCachePathFor(workspaceRoot2, sourceSha, deriverStamp2);
|
|
148800
|
+
const content = await readSidecar(path);
|
|
148801
|
+
if (content === void 0 || !isFresh(content, sourceSha, deriverStamp2)) {
|
|
148802
|
+
return void 0;
|
|
148803
|
+
}
|
|
148804
|
+
const front = parseSidecarFront(content);
|
|
148805
|
+
const derivedAt = new Date(front.derivedAt ?? Number.NaN);
|
|
148806
|
+
if (Number.isNaN(derivedAt.getTime())) {
|
|
148807
|
+
return void 0;
|
|
148808
|
+
}
|
|
148809
|
+
const body = sidecarBody(content);
|
|
148810
|
+
const markdown = body.endsWith("\n") ? body.slice(0, -1) : body;
|
|
148811
|
+
return { path, doc: { markdown, title: front.title, notes: [...front.notes] }, derivedAt };
|
|
148812
|
+
};
|
|
148813
|
+
cacheRendering = async (workspaceRoot2, entry) => {
|
|
148814
|
+
try {
|
|
148815
|
+
const written = await writeDerived(contentCachePathFor(workspaceRoot2, entry.sourceSha, entry.deriverStamp), entry);
|
|
148816
|
+
if (workspaceRoot2 !== void 0) {
|
|
148817
|
+
await ignoreShadowsInGit(workspaceRoot2);
|
|
148818
|
+
}
|
|
148819
|
+
return written.path;
|
|
148820
|
+
} catch {
|
|
148821
|
+
return void 0;
|
|
148822
|
+
}
|
|
148823
|
+
};
|
|
148824
|
+
}
|
|
148825
|
+
});
|
|
148826
|
+
|
|
148759
148827
|
// ../fileq/src/lib/derive.ts
|
|
148760
148828
|
import { stat as stat2 } from "node:fs/promises";
|
|
148761
148829
|
import { isAbsolute, relative, sep } from "node:path";
|
|
148762
|
-
var DERIVERS, MAX_SOURCE_BYTES, relPathIn, isDeriveIgnored, ensureSidecar;
|
|
148830
|
+
var DERIVERS, MAX_SOURCE_BYTES, relPathIn, isDeriveIgnored, renderCached, ensureSidecar, renderByContent;
|
|
148763
148831
|
var init_derive = __esm({
|
|
148764
148832
|
"../fileq/src/lib/derive.ts"() {
|
|
148765
148833
|
"use strict";
|
|
@@ -148784,6 +148852,7 @@ var init_derive = __esm({
|
|
|
148784
148852
|
init_profile2();
|
|
148785
148853
|
init_rtf();
|
|
148786
148854
|
init_xlsx2();
|
|
148855
|
+
init_content_cache();
|
|
148787
148856
|
init_sidecar();
|
|
148788
148857
|
DERIVERS = {
|
|
148789
148858
|
docx: docxDeriver,
|
|
@@ -148811,6 +148880,16 @@ var init_derive = __esm({
|
|
|
148811
148880
|
const segments = relPath.split("/");
|
|
148812
148881
|
return segments.some((segment) => IGNORED_DIRS.has(segment) || segment === STATE_DIR) || isReferencePath(relPath) || isAgentWorktreePath(relPath);
|
|
148813
148882
|
};
|
|
148883
|
+
renderCached = async (workspaceRoot2, absPath, deriver, sourceSha, now) => {
|
|
148884
|
+
const stamp = deriverStamp(deriver);
|
|
148885
|
+
const cached = await readCachedRendering(workspaceRoot2, sourceSha, stamp);
|
|
148886
|
+
if (cached !== void 0) {
|
|
148887
|
+
return { kind: "fresh", doc: cached.doc, derivedAt: cached.derivedAt, cachedPath: cached.path };
|
|
148888
|
+
}
|
|
148889
|
+
const doc = neutralizeDoc(await deriver.derive(absPath));
|
|
148890
|
+
const derivedAt = now();
|
|
148891
|
+
return { kind: "derived", doc, derivedAt, cachedPath: await cacheRendering(workspaceRoot2, { sourceSha, deriverStamp: stamp, doc, derivedAt }) };
|
|
148892
|
+
};
|
|
148814
148893
|
ensureSidecar = async (workspaceRoot2, absPath, now = () => /* @__PURE__ */ new Date()) => {
|
|
148815
148894
|
const relPath = relPathIn(workspaceRoot2, absPath);
|
|
148816
148895
|
if (relPath === void 0) {
|
|
@@ -148847,22 +148926,40 @@ var init_derive = __esm({
|
|
|
148847
148926
|
const body = sidecarBody(existing ?? "");
|
|
148848
148927
|
return { kind: "fresh", relPath, format, sidecarPath, body, tokens: estimateTokens(body) };
|
|
148849
148928
|
}
|
|
148850
|
-
let
|
|
148929
|
+
let rendered;
|
|
148851
148930
|
try {
|
|
148852
|
-
|
|
148931
|
+
rendered = await renderCached(workspaceRoot2, absPath, deriver, sourceSha, now);
|
|
148853
148932
|
} catch (error2) {
|
|
148854
148933
|
const detail = errorMessage(error2).split("\n")[0];
|
|
148855
148934
|
return { kind: "skipped", relPath, reason: `derive-failed (${format}): ${detail}` };
|
|
148856
148935
|
}
|
|
148857
|
-
const written = await writeSidecar(workspaceRoot2, { relPath, sourceSha, deriverStamp: stamp, doc, derivedAt:
|
|
148858
|
-
return { kind: "derived", relPath, format, sidecarPath: written.path, body: written.body, doc, tokens: written.tokens };
|
|
148936
|
+
const written = await writeSidecar(workspaceRoot2, { relPath, sourceSha, deriverStamp: stamp, doc: rendered.doc, derivedAt: rendered.derivedAt });
|
|
148937
|
+
return rendered.kind === "fresh" ? { kind: "fresh", relPath, format, sidecarPath: written.path, body: written.body, tokens: written.tokens } : { kind: "derived", relPath, format, sidecarPath: written.path, body: written.body, doc: rendered.doc, tokens: written.tokens };
|
|
148938
|
+
};
|
|
148939
|
+
renderByContent = async (workspaceRoot2, absPath, now = () => /* @__PURE__ */ new Date()) => {
|
|
148940
|
+
const format = await detectFormat(absPath).catch(() => void 0);
|
|
148941
|
+
if (format === void 0) {
|
|
148942
|
+
return { kind: "failed", reason: "unsupported or missing" };
|
|
148943
|
+
}
|
|
148944
|
+
let sourceSha;
|
|
148945
|
+
try {
|
|
148946
|
+
sourceSha = await sha256OfFile(absPath);
|
|
148947
|
+
} catch (error2) {
|
|
148948
|
+
return { kind: "failed", reason: isMissing(error2) ? "missing" : `unreadable (${errnoCode(error2) ?? errorMessage(error2)})` };
|
|
148949
|
+
}
|
|
148950
|
+
try {
|
|
148951
|
+
const rendered = await renderCached(workspaceRoot2, absPath, DERIVERS[format], sourceSha, now);
|
|
148952
|
+
return { kind: rendered.kind, format, doc: rendered.doc, cachedPath: rendered.cachedPath };
|
|
148953
|
+
} catch (error2) {
|
|
148954
|
+
return { kind: "failed", reason: `derive-failed (${format}): ${errorMessage(error2).split("\n")[0]}` };
|
|
148955
|
+
}
|
|
148859
148956
|
};
|
|
148860
148957
|
}
|
|
148861
148958
|
});
|
|
148862
148959
|
|
|
148863
148960
|
// ../fileq/src/lib/env.ts
|
|
148864
148961
|
var workspaceRoot;
|
|
148865
|
-
var
|
|
148962
|
+
var init_env2 = __esm({
|
|
148866
148963
|
"../fileq/src/lib/env.ts"() {
|
|
148867
148964
|
"use strict";
|
|
148868
148965
|
workspaceRoot = () => {
|
|
@@ -148880,7 +148977,7 @@ var init_derive_command = __esm({
|
|
|
148880
148977
|
"use strict";
|
|
148881
148978
|
init_dist();
|
|
148882
148979
|
init_derive();
|
|
148883
|
-
|
|
148980
|
+
init_env2();
|
|
148884
148981
|
outcomeLine = (outcome) => {
|
|
148885
148982
|
switch (outcome.kind) {
|
|
148886
148983
|
case "derived":
|
|
@@ -148909,7 +149006,7 @@ var init_derive_command = __esm({
|
|
|
148909
149006
|
return;
|
|
148910
149007
|
}
|
|
148911
149008
|
if (files.length === 0) {
|
|
148912
|
-
this.process.stdout.write("fileq: derive takes file paths
|
|
149009
|
+
this.process.stdout.write("fileq: derive takes file paths\n");
|
|
148913
149010
|
process.exitCode = 2;
|
|
148914
149011
|
return;
|
|
148915
149012
|
}
|
|
@@ -148953,25 +149050,6 @@ var init_git_attributes_command = __esm({
|
|
|
148953
149050
|
}
|
|
148954
149051
|
});
|
|
148955
149052
|
|
|
148956
|
-
// ../../_tools/agent-cli/src/env.ts
|
|
148957
|
-
import { homedir } from "node:os";
|
|
148958
|
-
import { join as join5 } from "node:path";
|
|
148959
|
-
var toolHome, toolOutDir;
|
|
148960
|
-
var init_env2 = __esm({
|
|
148961
|
-
"../../_tools/agent-cli/src/env.ts"() {
|
|
148962
|
-
"use strict";
|
|
148963
|
-
toolHome = (name) => {
|
|
148964
|
-
const explicit = process.env[`${name.toUpperCase()}_HOME`];
|
|
148965
|
-
if (explicit !== void 0 && explicit !== "") {
|
|
148966
|
-
return explicit;
|
|
148967
|
-
}
|
|
148968
|
-
const xdg = process.env["XDG_CACHE_HOME"];
|
|
148969
|
-
return join5(xdg !== void 0 && xdg !== "" ? xdg : join5(homedir(), ".cache"), name);
|
|
148970
|
-
};
|
|
148971
|
-
toolOutDir = (name) => join5(toolHome(name), "out");
|
|
148972
|
-
}
|
|
148973
|
-
});
|
|
148974
|
-
|
|
148975
149053
|
// ../../_tools/agent-cli/src/flags.ts
|
|
148976
149054
|
var countParser;
|
|
148977
149055
|
var init_flags = __esm({
|
|
@@ -148988,30 +149066,25 @@ var init_flags = __esm({
|
|
|
148988
149066
|
});
|
|
148989
149067
|
|
|
148990
149068
|
// ../fileq/src/commands/read.command.ts
|
|
148991
|
-
import {
|
|
148992
|
-
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
148993
|
-
import { basename as basename3, join as join6, resolve as resolve4 } from "node:path";
|
|
149069
|
+
import { basename as basename3, resolve as resolve4 } from "node:path";
|
|
148994
149070
|
var readCommand, readInWorkspace, fromOutcome, readOutsideWorkspace, withFinalNewline;
|
|
148995
149071
|
var init_read_command = __esm({
|
|
148996
149072
|
"../fileq/src/commands/read.command.ts"() {
|
|
148997
149073
|
"use strict";
|
|
148998
|
-
init_env2();
|
|
148999
149074
|
init_flags();
|
|
149000
149075
|
init_output();
|
|
149001
149076
|
init_format();
|
|
149002
149077
|
init_dist();
|
|
149003
|
-
init_errors();
|
|
149004
149078
|
init_deriver();
|
|
149005
|
-
init_formats();
|
|
149006
149079
|
init_derive();
|
|
149007
|
-
|
|
149080
|
+
init_env2();
|
|
149008
149081
|
readCommand = buildCommand({
|
|
149009
149082
|
docs: { brief: "One file as clean markdown: budgeted on stdout, whole in its sidecar" },
|
|
149010
149083
|
parameters: {
|
|
149011
149084
|
flags: {
|
|
149012
149085
|
budget: { kind: "parsed", parse: countParser, default: "4000", brief: "Max stdout tokens; 0 prints only the capsule" },
|
|
149013
149086
|
json: { kind: "boolean", default: false, brief: "Machine-readable result on stdout" },
|
|
149014
|
-
plain: { kind: "boolean", default: false, brief: "The markdown alone, whole and unbudgeted
|
|
149087
|
+
plain: { kind: "boolean", default: false, brief: "The markdown alone, whole and unbudgeted (git textconv)" }
|
|
149015
149088
|
},
|
|
149016
149089
|
positional: {
|
|
149017
149090
|
kind: "tuple",
|
|
@@ -149021,8 +149094,7 @@ var init_read_command = __esm({
|
|
|
149021
149094
|
async func(flags, file) {
|
|
149022
149095
|
const absPath = resolve4(file);
|
|
149023
149096
|
const root = workspaceRoot();
|
|
149024
|
-
const
|
|
149025
|
-
const result = root === void 0 ? await readOutsideWorkspace(absPath, save) : await readInWorkspace(root, absPath, save);
|
|
149097
|
+
const result = root === void 0 ? await readOutsideWorkspace(void 0, absPath) : await readInWorkspace(root, absPath);
|
|
149026
149098
|
if (result === void 0) {
|
|
149027
149099
|
process.exitCode = 1;
|
|
149028
149100
|
return;
|
|
@@ -149040,19 +149112,23 @@ var init_read_command = __esm({
|
|
|
149040
149112
|
return;
|
|
149041
149113
|
}
|
|
149042
149114
|
const fields = [result.title ?? basename3(absPath), result.format, `${result.tokens} tokens`, result.source];
|
|
149043
|
-
|
|
149044
|
-
this.process.stdout.write(
|
|
149115
|
+
const notes = result.savedPath === void 0 ? [...result.notes, "nothing saved: the rendering cache could not be written"] : result.notes;
|
|
149116
|
+
this.process.stdout.write(capsule("fileq", fields, notes));
|
|
149117
|
+
if (result.savedPath !== void 0) {
|
|
149118
|
+
this.process.stdout.write(`saved: ${result.savedPath}
|
|
149045
149119
|
`);
|
|
149120
|
+
}
|
|
149046
149121
|
if (flags.budget > 0 && result.body !== "") {
|
|
149122
|
+
const whole = result.savedPath ?? `the output of \`fileq read --plain ${absPath}\``;
|
|
149047
149123
|
this.process.stdout.write("---\n");
|
|
149048
|
-
this.process.stdout.write(withFinalNewline(clip(result.body, flags.budget,
|
|
149124
|
+
this.process.stdout.write(withFinalNewline(clip(result.body, flags.budget, whole, "document")));
|
|
149049
149125
|
}
|
|
149050
149126
|
}
|
|
149051
149127
|
});
|
|
149052
|
-
readInWorkspace = async (root, absPath
|
|
149128
|
+
readInWorkspace = async (root, absPath) => {
|
|
149053
149129
|
const outcome = await ensureSidecar(root, absPath);
|
|
149054
149130
|
if (outcome.kind === "skipped" && outcome.reason === "outside-workspace") {
|
|
149055
|
-
return readOutsideWorkspace(
|
|
149131
|
+
return readOutsideWorkspace(root, absPath);
|
|
149056
149132
|
}
|
|
149057
149133
|
return fromOutcome(outcome);
|
|
149058
149134
|
};
|
|
@@ -149088,41 +149164,22 @@ var init_read_command = __esm({
|
|
|
149088
149164
|
}
|
|
149089
149165
|
}
|
|
149090
149166
|
};
|
|
149091
|
-
readOutsideWorkspace = async (
|
|
149092
|
-
const
|
|
149093
|
-
if (
|
|
149094
|
-
process.stdout.write(`fileq: cannot read ${absPath}:
|
|
149095
|
-
`);
|
|
149096
|
-
return void 0;
|
|
149097
|
-
}
|
|
149098
|
-
let doc;
|
|
149099
|
-
try {
|
|
149100
|
-
doc = neutralizeDoc(await DERIVERS[format].derive(absPath));
|
|
149101
|
-
} catch (error2) {
|
|
149102
|
-
process.stdout.write(`fileq: cannot read ${absPath}: derive-failed (${format}): ${errorMessage(error2).split("\n")[0]}
|
|
149167
|
+
readOutsideWorkspace = async (root, absPath) => {
|
|
149168
|
+
const outcome = await renderByContent(root, absPath);
|
|
149169
|
+
if (outcome.kind === "failed") {
|
|
149170
|
+
process.stdout.write(`fileq: cannot read ${absPath}: ${outcome.reason}
|
|
149103
149171
|
`);
|
|
149104
149172
|
return void 0;
|
|
149105
149173
|
}
|
|
149106
|
-
const outDir = toolOutDir("fileq");
|
|
149107
|
-
const hash = createHash2("sha256").update(absPath).digest("hex").slice(0, 8);
|
|
149108
|
-
const savedPath = join6(
|
|
149109
|
-
outDir,
|
|
149110
|
-
`${basename3(absPath).toLowerCase().replaceAll(/[^a-z0-9.]+/g, "-")}-${hash}.md`
|
|
149111
|
-
);
|
|
149112
|
-
if (save) {
|
|
149113
|
-
await mkdir2(outDir, { recursive: true });
|
|
149114
|
-
await writeFile2(savedPath, `${doc.markdown}
|
|
149115
|
-
`);
|
|
149116
|
-
}
|
|
149117
149174
|
return {
|
|
149118
|
-
format,
|
|
149119
|
-
deriver: deriverStamp(DERIVERS[format]),
|
|
149120
|
-
body: doc.markdown,
|
|
149121
|
-
tokens: estimateTokens(doc.markdown),
|
|
149122
|
-
savedPath,
|
|
149123
|
-
source:
|
|
149124
|
-
title: doc.title,
|
|
149125
|
-
notes: doc.notes
|
|
149175
|
+
format: outcome.format,
|
|
149176
|
+
deriver: deriverStamp(DERIVERS[outcome.format]),
|
|
149177
|
+
body: outcome.doc.markdown,
|
|
149178
|
+
tokens: estimateTokens(outcome.doc.markdown),
|
|
149179
|
+
savedPath: outcome.cachedPath,
|
|
149180
|
+
source: outcome.kind,
|
|
149181
|
+
title: outcome.doc.title,
|
|
149182
|
+
notes: outcome.doc.notes
|
|
149126
149183
|
};
|
|
149127
149184
|
};
|
|
149128
149185
|
withFinalNewline = (text) => text.endsWith("\n") ? text : `${text}
|
|
@@ -149286,15 +149343,15 @@ var init_convert = __esm({
|
|
|
149286
149343
|
});
|
|
149287
149344
|
|
|
149288
149345
|
// ../fileq/src/lib/render/render.ts
|
|
149289
|
-
import { createHash as
|
|
149290
|
-
import { copyFile, mkdir as
|
|
149346
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
149347
|
+
import { copyFile, mkdir as mkdir2, mkdtemp as mkdtemp2, readFile as readFile15, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
|
|
149291
149348
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
149292
149349
|
import { basename as basename5, join as join8 } from "node:path";
|
|
149293
149350
|
var RENDERED_DIR, DEFAULT_PAGE_CAP, DEFAULT_SIZE, VIA_OFFICE, SLIDES, NotRenderable, STAMP_FILE, defaultOutDir, readStamp, clearImages, ignoreInGit, pageCount, formatOf, choosePages, renderDocument;
|
|
149294
149351
|
var init_render = __esm({
|
|
149295
149352
|
"../fileq/src/lib/render/render.ts"() {
|
|
149296
149353
|
"use strict";
|
|
149297
|
-
|
|
149354
|
+
init_env();
|
|
149298
149355
|
init_src();
|
|
149299
149356
|
init_dist2();
|
|
149300
149357
|
init_derive();
|
|
@@ -149315,7 +149372,7 @@ var init_render = __esm({
|
|
|
149315
149372
|
if (workspaceRoot2 !== void 0 && relPath !== void 0) {
|
|
149316
149373
|
return join8(workspaceRoot2, RENDERED_DIR, relPath);
|
|
149317
149374
|
}
|
|
149318
|
-
const hash =
|
|
149375
|
+
const hash = createHash2("sha256").update(absPath).digest("hex").slice(0, 8);
|
|
149319
149376
|
return join8(toolOutDir("fileq"), "rendered", `${basename5(absPath).toLowerCase().replaceAll(/[^a-z0-9.]+/g, "-")}-${hash}`);
|
|
149320
149377
|
};
|
|
149321
149378
|
readStamp = async (dir) => {
|
|
@@ -149335,7 +149392,7 @@ var init_render = __esm({
|
|
|
149335
149392
|
return;
|
|
149336
149393
|
}
|
|
149337
149394
|
try {
|
|
149338
|
-
await
|
|
149395
|
+
await writeFile2(join8(workspaceRoot2, RENDERED_DIR, ".gitignore"), "# fileq's rendered pages; regenerated on demand.\n*\n", { flag: "wx" });
|
|
149339
149396
|
} catch {
|
|
149340
149397
|
}
|
|
149341
149398
|
};
|
|
@@ -149400,9 +149457,9 @@ var init_render = __esm({
|
|
|
149400
149457
|
const total = await pageCount(pdf);
|
|
149401
149458
|
const pages = choosePages(request, total, unit, notes);
|
|
149402
149459
|
const raster = join8(work, "png");
|
|
149403
|
-
await
|
|
149460
|
+
await mkdir2(raster, { recursive: true });
|
|
149404
149461
|
const drawn = await toPngs(tool, pdf, pages, request.size, raster);
|
|
149405
|
-
await
|
|
149462
|
+
await mkdir2(outDir, { recursive: true });
|
|
149406
149463
|
await ignoreInGit(workspaceRoot2, outDir);
|
|
149407
149464
|
if (request.outDir === void 0 && !current) {
|
|
149408
149465
|
await clearImages(outDir);
|
|
@@ -149420,7 +149477,7 @@ var init_render = __esm({
|
|
|
149420
149477
|
notes.push(`${pages.length - images.length} of the ${unit}s asked for drew nothing`);
|
|
149421
149478
|
}
|
|
149422
149479
|
if (request.outDir === void 0) {
|
|
149423
|
-
await
|
|
149480
|
+
await writeFile2(join8(outDir, STAMP_FILE), `${JSON.stringify({ sha256, size: request.size, total })}
|
|
149424
149481
|
`);
|
|
149425
149482
|
}
|
|
149426
149483
|
return { format, unit, total, images, outDir, reused: false, notes };
|
|
@@ -149441,7 +149498,7 @@ var init_render_command = __esm({
|
|
|
149441
149498
|
init_output();
|
|
149442
149499
|
init_errors();
|
|
149443
149500
|
init_dist();
|
|
149444
|
-
|
|
149501
|
+
init_env2();
|
|
149445
149502
|
init_convert();
|
|
149446
149503
|
init_pages();
|
|
149447
149504
|
init_render();
|
|
@@ -149509,120 +149566,6 @@ var init_render_command = __esm({
|
|
|
149509
149566
|
}
|
|
149510
149567
|
});
|
|
149511
149568
|
|
|
149512
|
-
// ../fileq/src/lib/sweep.ts
|
|
149513
|
-
import { readdir as readdir3, stat as stat3 } from "node:fs/promises";
|
|
149514
|
-
import { join as join9 } from "node:path";
|
|
149515
|
-
var skipDir, walk, walkSidecars, sweep;
|
|
149516
|
-
var init_sweep = __esm({
|
|
149517
|
-
"../fileq/src/lib/sweep.ts"() {
|
|
149518
|
-
"use strict";
|
|
149519
|
-
init_src2();
|
|
149520
|
-
init_src();
|
|
149521
|
-
init_derive();
|
|
149522
|
-
init_formats();
|
|
149523
|
-
init_sidecar();
|
|
149524
|
-
skipDir = (relPath, name, childRel) => IGNORED_DIRS.has(name) || name === STATE_DIR || relPath === "" && name === REFERENCE_DIR || isAgentWorktreePath(childRel);
|
|
149525
|
-
walk = async (root, relPath, found) => {
|
|
149526
|
-
const entries = await readdir3(join9(root, relPath), { withFileTypes: true }).catch(() => []);
|
|
149527
|
-
for (const entry of entries) {
|
|
149528
|
-
const childRel = relPath === "" ? entry.name : `${relPath}/${entry.name}`;
|
|
149529
|
-
if (entry.isDirectory()) {
|
|
149530
|
-
if (!skipDir(relPath, entry.name, childRel)) {
|
|
149531
|
-
await walk(root, childRel, found);
|
|
149532
|
-
}
|
|
149533
|
-
} else if (entry.isFile() && isCandidatePath(entry.name)) {
|
|
149534
|
-
found.push(childRel);
|
|
149535
|
-
}
|
|
149536
|
-
}
|
|
149537
|
-
};
|
|
149538
|
-
walkSidecars = async (root, relPath, found) => {
|
|
149539
|
-
const entries = await readdir3(join9(root, DERIVED_DIR, relPath), { withFileTypes: true }).catch(() => []);
|
|
149540
|
-
for (const entry of entries) {
|
|
149541
|
-
const childRel = relPath === "" ? entry.name : `${relPath}/${entry.name}`;
|
|
149542
|
-
if (entry.isDirectory()) {
|
|
149543
|
-
await walkSidecars(root, childRel, found);
|
|
149544
|
-
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
149545
|
-
found.push(childRel.slice(0, -3));
|
|
149546
|
-
}
|
|
149547
|
-
}
|
|
149548
|
-
};
|
|
149549
|
-
sweep = async (workspaceRoot2, onOutcome) => {
|
|
149550
|
-
const candidates = [];
|
|
149551
|
-
await walk(workspaceRoot2, "", candidates);
|
|
149552
|
-
const outcomes = [];
|
|
149553
|
-
for (const relPath of candidates) {
|
|
149554
|
-
const outcome = await ensureSidecar(workspaceRoot2, join9(workspaceRoot2, relPath));
|
|
149555
|
-
outcomes.push(outcome);
|
|
149556
|
-
onOutcome?.(outcome);
|
|
149557
|
-
}
|
|
149558
|
-
const shadowed = [];
|
|
149559
|
-
await walkSidecars(workspaceRoot2, "", shadowed);
|
|
149560
|
-
const alive = new Set(candidates);
|
|
149561
|
-
const pruned = [];
|
|
149562
|
-
for (const relPath of shadowed) {
|
|
149563
|
-
if (!alive.has(relPath) && await stat3(join9(workspaceRoot2, relPath)).catch(() => void 0) === void 0) {
|
|
149564
|
-
await removeSidecar(workspaceRoot2, relPath);
|
|
149565
|
-
pruned.push(relPath);
|
|
149566
|
-
}
|
|
149567
|
-
}
|
|
149568
|
-
return { outcomes, pruned };
|
|
149569
|
-
};
|
|
149570
|
-
}
|
|
149571
|
-
});
|
|
149572
|
-
|
|
149573
|
-
// ../fileq/src/commands/sweep.command.ts
|
|
149574
|
-
var sweepCommand;
|
|
149575
|
-
var init_sweep_command = __esm({
|
|
149576
|
-
"../fileq/src/commands/sweep.command.ts"() {
|
|
149577
|
-
"use strict";
|
|
149578
|
-
init_dist();
|
|
149579
|
-
init_sweep();
|
|
149580
|
-
init_env();
|
|
149581
|
-
init_derive_command();
|
|
149582
|
-
sweepCommand = buildCommand({
|
|
149583
|
-
docs: { brief: "Converge every derivable workspace file's sidecar; prune shadows of deleted files" },
|
|
149584
|
-
parameters: {
|
|
149585
|
-
flags: {
|
|
149586
|
-
json: { kind: "boolean", default: false, brief: "Machine-readable summary on stdout" },
|
|
149587
|
-
quiet: { kind: "boolean", default: false, brief: "Totals only, no per-file lines" }
|
|
149588
|
-
},
|
|
149589
|
-
positional: { kind: "tuple", parameters: [] }
|
|
149590
|
-
},
|
|
149591
|
-
async func(flags) {
|
|
149592
|
-
const root = workspaceRoot();
|
|
149593
|
-
if (root === void 0) {
|
|
149594
|
-
this.process.stdout.write("fileq: sweep needs a workspace (WORKSPACE_ROOT is not set)\n");
|
|
149595
|
-
process.exitCode = 2;
|
|
149596
|
-
return;
|
|
149597
|
-
}
|
|
149598
|
-
const result = await sweep(root, (outcome) => {
|
|
149599
|
-
if (!flags.quiet && !flags.json && outcome.kind !== "fresh") {
|
|
149600
|
-
this.process.stdout.write(`${outcomeLine(outcome)}
|
|
149601
|
-
`);
|
|
149602
|
-
}
|
|
149603
|
-
});
|
|
149604
|
-
const counts = { derived: 0, fresh: 0, removed: 0, skipped: 0 };
|
|
149605
|
-
for (const outcome of result.outcomes) {
|
|
149606
|
-
counts[outcome.kind] += 1;
|
|
149607
|
-
}
|
|
149608
|
-
if (flags.json) {
|
|
149609
|
-
this.process.stdout.write(`${JSON.stringify({ ...counts, pruned: result.pruned.length })}
|
|
149610
|
-
`);
|
|
149611
|
-
} else {
|
|
149612
|
-
for (const relPath of result.pruned) {
|
|
149613
|
-
this.process.stdout.write(`pruned ${relPath} (source gone)
|
|
149614
|
-
`);
|
|
149615
|
-
}
|
|
149616
|
-
this.process.stdout.write(
|
|
149617
|
-
`sweep: ${counts.derived} derived, ${counts.fresh} fresh, ${counts.removed + result.pruned.length} removed, ${counts.skipped} skipped
|
|
149618
|
-
`
|
|
149619
|
-
);
|
|
149620
|
-
}
|
|
149621
|
-
}
|
|
149622
|
-
});
|
|
149623
|
-
}
|
|
149624
|
-
});
|
|
149625
|
-
|
|
149626
149569
|
// ../fileq/src/app.ts
|
|
149627
149570
|
var app_exports = {};
|
|
149628
149571
|
__export(app_exports, {
|
|
@@ -149639,18 +149582,17 @@ var init_app = __esm({
|
|
|
149639
149582
|
init_git_attributes_command();
|
|
149640
149583
|
init_read_command();
|
|
149641
149584
|
init_render_command();
|
|
149642
|
-
init_sweep_command();
|
|
149643
149585
|
HELP = `fileq \u2014 binary workspace files as clean, budgeted markdown.
|
|
149644
149586
|
|
|
149645
149587
|
Reads the formats an agent cannot: docx, xlsx, pptx, pdf (text layer), images
|
|
149646
|
-
(dimensions + EXIF), audio/video (duration + tags), html.
|
|
149647
|
-
|
|
149648
|
-
|
|
149588
|
+
(dimensions + EXIF), audio/video (duration + tags), html. Renderings are cached
|
|
149589
|
+
by content hash, so reading unchanged bytes again (the same file, a copy, a
|
|
149590
|
+
download outside the workspace) is instant; each workspace file also gets a
|
|
149591
|
+
markdown SIDECAR under .intentic/local/cache/derived/<path>.md.
|
|
149649
149592
|
|
|
149650
149593
|
fileq <file> print it as markdown (default: read), budgeted
|
|
149651
149594
|
fileq read <file> --budget 8000
|
|
149652
149595
|
fileq derive <file\u2026> converge named files' sidecars (stale\u2192derive, gone\u2192remove)
|
|
149653
|
-
fileq sweep converge the whole workspace, prune orphaned sidecars
|
|
149654
149596
|
fileq read --plain <f> the markdown alone, for a program; git's textconv driver
|
|
149655
149597
|
fileq git-attributes the gitattributes that route documents through it
|
|
149656
149598
|
|
|
@@ -149678,7 +149620,6 @@ invocation or install (render: a tool it needs is missing).`;
|
|
|
149678
149620
|
check: checkCommand,
|
|
149679
149621
|
render: renderCommand,
|
|
149680
149622
|
derive: deriveCommand,
|
|
149681
|
-
sweep: sweepCommand,
|
|
149682
149623
|
gitAttributes: gitAttributesCommand
|
|
149683
149624
|
},
|
|
149684
149625
|
defaultCommand: "read",
|