etymd 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,8 @@ import { applyFiles } from './chunk-EF6BPBG6.js';
3
3
  import { planWorkflow } from './chunk-WENIJMVV.js';
4
4
  import './chunk-D2RI3CCT.js';
5
5
  import { theme, renderFacts, print, renderPlan, section, glyph } from './chunk-5BVKFJWM.js';
6
- import { scanProject } from './chunk-CIRNG736.js';
7
- import { VERSION } from './chunk-72Y2V7VF.js';
6
+ import { scanProject } from './chunk-UN7IAYM6.js';
7
+ import { VERSION } from './chunk-AQM4GYGN.js';
8
8
  import { writeCachedFacts, deriveProfile, writeBaseline, CACHE_DIR } from './chunk-C7LBUFNU.js';
9
9
  import { PACK_VERSION } from './chunk-6DUDIVIC.js';
10
10
  import { git, readText } from './chunk-IV3FYVTS.js';
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ export { scanProject } from './chunk-UN7IAYM6.js';
3
+ import './chunk-AQM4GYGN.js';
4
+ import './chunk-6DUDIVIC.js';
5
+ import './chunk-IV3FYVTS.js';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { print, renderFacts, theme } from './chunk-5BVKFJWM.js';
3
- import { scanProject } from './chunk-CIRNG736.js';
4
- import './chunk-72Y2V7VF.js';
3
+ import { scanProject } from './chunk-UN7IAYM6.js';
4
+ import './chunk-AQM4GYGN.js';
5
5
  import { writeCachedFacts } from './chunk-C7LBUFNU.js';
6
6
  import './chunk-6DUDIVIC.js';
7
7
  import './chunk-IV3FYVTS.js';
@@ -58,6 +58,17 @@ async function walk(dir, out, depth = 0) {
58
58
  else out.push(abs);
59
59
  }
60
60
  }
61
+ var BINARY_SNIFF_BYTES = 8192;
62
+ async function readScreenable(p) {
63
+ let buf;
64
+ try {
65
+ buf = await promises.readFile(p);
66
+ } catch {
67
+ return null;
68
+ }
69
+ if (buf.subarray(0, BINARY_SNIFF_BYTES).includes(0)) return "binary";
70
+ return buf.toString("utf8");
71
+ }
61
72
  async function run(opts) {
62
73
  const patternPath = opts.patterns ?? process.env.ETYMD_SCREEN_PATTERNS ?? process.env.PUBLIC_REPO_PATTERNS ?? path.join(process.env.HOME ?? "", ".config", "etymd", "screen-patterns");
63
74
  const rawPatterns = await readText(patternPath);
@@ -83,6 +94,7 @@ async function run(opts) {
83
94
  const active = self ? patterns.filter((re) => !isSelfName(re, self)) : patterns;
84
95
  const hits = [];
85
96
  let scanned = 0;
97
+ let skippedBinary = 0;
86
98
  if (opts.scope === "message") {
87
99
  const file = opts.target;
88
100
  if (!file) throw new Error("--message needs the message file path (the commit-msg hook's $1)");
@@ -97,8 +109,12 @@ async function run(opts) {
97
109
  const files = [];
98
110
  await walk(dir, files);
99
111
  for (const f of files) {
100
- const raw = await readText(f);
112
+ const raw = await readScreenable(f);
101
113
  if (raw === null) continue;
114
+ if (raw === "binary") {
115
+ skippedBinary++;
116
+ continue;
117
+ }
102
118
  scanned++;
103
119
  hits.push(...screenText(raw, path.relative(dir, f), active, allow));
104
120
  }
@@ -109,14 +125,22 @@ async function run(opts) {
109
125
  if (rel === ALLOW_FILE || rel === LEGACY_ALLOW_FILE) continue;
110
126
  const abs = path.join(opts.cwd, rel);
111
127
  if (!await pathExists(abs)) continue;
112
- const raw = await readText(abs);
128
+ const raw = await readScreenable(abs);
113
129
  if (raw === null) continue;
130
+ if (raw === "binary") {
131
+ skippedBinary++;
132
+ continue;
133
+ }
114
134
  scanned++;
115
135
  hits.push(...screenText(raw, rel, active, allow));
116
136
  }
117
137
  }
118
138
  if (!hits.length) return;
119
- section(`Content screen ${theme.dim(`\xB7 ${opts.scope} \xB7 ${scanned} file(s)`)}`);
139
+ section(
140
+ `Content screen ${theme.dim(
141
+ `\xB7 ${opts.scope} \xB7 ${scanned} file(s)${skippedBinary ? ` \xB7 ${skippedBinary} binary skipped` : ""}`
142
+ )}`
143
+ );
120
144
  for (const h of hits) {
121
145
  print(` ${theme.warn(h.file)}${theme.dim(`:${h.line}`)} ${theme.dim(`(${h.reason})`)}`);
122
146
  print(` ${h.text}`);
@@ -131,4 +155,4 @@ async function run(opts) {
131
155
  if (!opts.advisory) process.exitCode = 1;
132
156
  }
133
157
 
134
- export { isSelfName, run, screenText };
158
+ export { isSelfName, readScreenable, run, screenText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "etymd",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Keep your agent instructions true — verify AGENTS.md, CLAUDE.md, rules & skills against the actual repo, with drift caught over time and a regression ledger.",
5
5
  "keywords": [
6
6
  "cli",
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- export { scanProject } from './chunk-CIRNG736.js';
3
- import './chunk-72Y2V7VF.js';
4
- import './chunk-6DUDIVIC.js';
5
- import './chunk-IV3FYVTS.js';