@kaynooo/cli-code 0.14.0 → 0.14.2

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/README.md CHANGED
@@ -25,7 +25,7 @@ hotspots --since '3 months ago' --limit 10
25
25
  - `--around <regex> -C <n>` prints the `n` (3) lines on each side of each matching line, spans that touch merged, at most 20 spans (`--limit`, `--full`, the count of the rest after them).
26
26
  - Piped into with no file and no mode, it reads the `path:line` opening each line of the input (`errs`, `rg -n`, `grep -n`, a linter's `path:line:col`, tsc's `path(line,col)`) and prints the `-C` (3) lines around each, spans that touch merged and files in the order first named; a path outside the repository or not readable is skipped, and nothing readable exits 1.
27
27
  - `--json` prints the spans as `[{path, from, to, lines}]`, `--refs` as `[{path, line, text}]` and `--outline` as `[{path, line, depth, text}]`, the lines never cut; a failure prints as `{"error"}` on stderr.
28
- - `--def`, `--refs` and `--around` look through the paths given, the files git keeps here by default (`git ls-files` with the untracked files `.gitignore` lets through), and outside a repository a walk leaving dot folders and `node_modules`, `dist`, `build`, `vendor`, `target`, `coverage` out; binary files and files over 2 MB are skipped.
28
+ - `--def`, `--refs` and `--around` look through the paths given, the files git keeps here by default (`git ls-files` with the untracked files `.gitignore` lets through), and outside a repository a walk leaving dot folders and `node_modules`, `dist`, `build`, `vendor`, `target`, `coverage` and the names in the `ignore` array of `~/.config/kaynooo-cli/config.json` out; binary files and files over 2 MB are skipped.
29
29
  - The symbols are found by pattern, not by a type checker: a name declared twice in a file shows twice, and a symbol re-exported under another name is not followed.
30
30
  - A path must lie inside the repository (a symlink out of it counts as outside), absolute or relative. Exits 1 when nothing is found, a file cannot be read or a span starts past the end, 2 on a usage error or a path outside the repository.
31
31
 
@@ -41,3 +41,5 @@ hotspots --since '3 months ago' --limit 10
41
41
  - Churn is the commits touching the file since `--since` (any date git reads, `6 months ago` by default), counted from one `git log`. The score uses `recent`, the commits weighted by age (half as much every `--half-life`, `90d` by default, `0` to count them alike), and leaves out the commits touching more than `--bulk` files (25), the format and rename sweeps. Complexity is the decision points of the file (`if`, loops, `case`, `catch`, `&&`, `||`, `??`, ternaries, `and`/`or`) plus one, counted with comments and strings blanked; it is computed in-house (js, ts, vue, svelte, astro, kay, php, py, go, rs, rb, java, kt, swift, cs, c, cpp, scala, dart, lua and shell files are ranked) so the bin needs no dependency and reads any language the same way.
42
42
  - `--limit <n>` (`-n`) sets how many files are listed (20, the count of the rest after them), `--full` lists all, `--json` is never cut unless `--limit` is given. `--all` keeps test files and generated files (`dist/`, `*.d.ts`, `*.min.js`, snapshots, files whose first lines say generated), `--json` prints `[{rank, path, score, churn, recent, complexity, worst, lines}]`. The most complex declaration is found from the indentation alone (a class is opened into its methods), so it reads any language the same way.
43
43
  - Exits 1 when no file has commits in the window, 2 on a usage error or outside a git repository.
44
+
45
+ `~/.config/kaynooo-cli/hotspots.json` (`$XDG_CONFIG_HOME/kaynooo-cli/` when set) changes the defaults of `hotspots`: `since` (a date as git reads it, `6 months ago`), `bulk` (25) and `limit` (20, the files listed).
package/dist/cli.js CHANGED
@@ -9,6 +9,7 @@ import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
11
  import process7 from "process";
12
+
12
13
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
13
14
  var ct = /[aeiou]y$/;
14
15
  var N = new Map;
@@ -45,6 +46,7 @@ function ko(t, e, r = "...") {
45
46
  }
46
47
  var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
47
48
  var z = new Map;
49
+
48
50
  // ../kit/src/mode.ts
49
51
  import process2 from "process";
50
52
  var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
@@ -92,7 +94,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
92
94
  return false;
93
95
  return r?.isTTY === true;
94
96
  }
95
- function f2(r, e = []) {
97
+ function f(r, e = []) {
96
98
  let l = "", n = "";
97
99
  for (let t = 0, i = e.length;t < i; t++)
98
100
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
@@ -102,7 +104,7 @@ function f2(r, e = []) {
102
104
  if (Array.isArray(a)) {
103
105
  let s = g.get(i);
104
106
  if (s === undefined)
105
- s = f2(r, [...e, a]), g.set(i, s);
107
+ s = f(r, [...e, a]), g.set(i, s);
106
108
  return s;
107
109
  }
108
110
  if (typeof a === "function")
@@ -111,20 +113,20 @@ function f2(r, e = []) {
111
113
  if (u === undefined) {
112
114
  if (g.size >= 64)
113
115
  g.clear();
114
- u = f2(r, [...e, a(...s)]), g.set(y, u);
116
+ u = f(r, [...e, a(...s)]), g.set(y, u);
115
117
  }
116
118
  return u;
117
119
  };
118
120
  throw Error(`Unknown style: ${String(i)}`);
119
121
  } });
120
122
  }
121
- function Fe2(r = {}) {
122
- return f2(r);
123
+ function Fe(r = {}) {
124
+ return f(r);
123
125
  }
124
- var o2 = Fe2();
126
+ var o = Fe();
125
127
 
126
128
  // ../kit/src/theme.ts
127
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
129
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
128
130
  import { homedir as homedir2 } from "os";
129
131
  import { join as join3, resolve as resolve2 } from "path";
130
132
  import process5 from "process";
@@ -145,6 +147,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
145
147
  }
146
148
 
147
149
  // ../kit/src/user-config.ts
150
+ import { existsSync as existsSync2, readFileSync } from "fs";
148
151
  import { homedir } from "os";
149
152
  import { join as join2 } from "path";
150
153
  import process4 from "process";
@@ -155,6 +158,28 @@ function configBase(where = {}) {
155
158
  function userConfigPath(bin, where = {}) {
156
159
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
157
160
  }
161
+ function userConfigReadPath(bin, legacy = [], where = {}) {
162
+ const current = userConfigPath(bin, where);
163
+ if (existsSync2(current))
164
+ return current;
165
+ const base = configBase(where);
166
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
167
+ }
168
+ function readUserConfig(bin, where = {}, legacy = []) {
169
+ const path = userConfigReadPath(bin, legacy, where);
170
+ if (!existsSync2(path))
171
+ return {};
172
+ try {
173
+ const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
174
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
175
+ } catch {
176
+ return {};
177
+ }
178
+ }
179
+ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
180
+ const value = readUserConfig(bin, where, legacy)[key];
181
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
182
+ }
158
183
 
159
184
  // ../kit/src/theme.ts
160
185
  var ENDS = new Map;
@@ -221,7 +246,7 @@ function readThemeFile(path, warn) {
221
246
  warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
222
247
  return;
223
248
  }
224
- const parsed = JSON.parse(readFileSync(path, "utf8"));
249
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
225
250
  if (isRecord(parsed))
226
251
  return parsed;
227
252
  warn(`${path} is not a JSON object, theme ignored`);
@@ -287,7 +312,7 @@ function applyFile(theme, file, where, warn) {
287
312
  }
288
313
  }
289
314
  function endsWalk(home) {
290
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
315
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
291
316
  }
292
317
  var warned = new Set;
293
318
  function warnOnce(message) {
@@ -343,7 +368,7 @@ function takesControlCodes(stream, env = process6.env) {
343
368
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
344
369
  }
345
370
  function paint(stream, env = process6.env) {
346
- return Fe2({ stream: { isTTY: takesControlCodes(stream, env) }, env });
371
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
347
372
  }
348
373
  function marked(mark, text, stream, detail, env = process6.env) {
349
374
  const colors = paint(stream, env);
@@ -871,7 +896,7 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
871
896
  var RESET_STYLE = `${ESC}[0m`;
872
897
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
873
898
  // ../kit/src/cli.ts
874
- import { readFileSync as readFileSync2, realpathSync } from "fs";
899
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
875
900
  import { dirname as dirname3, join as join5 } from "path";
876
901
  import process12 from "process";
877
902
 
@@ -1172,7 +1197,7 @@ async function printCandidates(found) {
1172
1197
  function packageVersion(entry = Bun.main) {
1173
1198
  for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1174
1199
  try {
1175
- const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1200
+ const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
1176
1201
  if (typeof version === "string")
1177
1202
  return version;
1178
1203
  } catch {}
@@ -1229,6 +1254,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
1229
1254
  }
1230
1255
  // ../kit/src/folders.ts
1231
1256
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1257
+ function ignoredFolders(extra = [], where = {}) {
1258
+ const configured = readUserConfig("config", where).ignore;
1259
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1260
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1261
+ }
1232
1262
  // ../kit/src/limit.ts
1233
1263
  function limitOptions(fallback) {
1234
1264
  return {
@@ -1299,11 +1329,11 @@ async function churnSince(cwd, since, { bulk, halfLifeMs, now = Date.now() }) {
1299
1329
  }
1300
1330
 
1301
1331
  // src/files.ts
1302
- import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "fs";
1332
+ import { existsSync as existsSync4, readdirSync, statSync as statSync2 } from "fs";
1303
1333
  import { join as join6, relative } from "path";
1304
1334
  var MAX_BYTES = 2000000;
1305
1335
  var SNIFF_BYTES = 8000;
1306
- function walk(dir, found) {
1336
+ function walk(dir, found, ignored) {
1307
1337
  let entries;
1308
1338
  try {
1309
1339
  entries = readdirSync(dir, { withFileTypes: true });
@@ -1311,10 +1341,10 @@ function walk(dir, found) {
1311
1341
  return found;
1312
1342
  }
1313
1343
  for (const entry of entries) {
1314
- if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
1344
+ if (entry.name.startsWith(".") || ignored.has(entry.name))
1315
1345
  continue;
1316
1346
  if (entry.isDirectory())
1317
- walk(join6(dir, entry.name), found);
1347
+ walk(join6(dir, entry.name), found, ignored);
1318
1348
  else if (entry.isFile())
1319
1349
  found.push(join6(dir, entry.name));
1320
1350
  }
@@ -1323,9 +1353,10 @@ function walk(dir, found) {
1323
1353
  async function listFiles(paths, cwd) {
1324
1354
  const listed = await runCommand(["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", ...paths], { cwd });
1325
1355
  if (listed.code === 0)
1326
- return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync3(join6(cwd, path))).sort();
1356
+ return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync4(join6(cwd, path))).sort();
1327
1357
  const roots = paths.length === 0 ? [cwd] : paths.map((path) => join6(cwd, path));
1328
- return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [])).map((path) => relative(cwd, path)).sort();
1358
+ const ignored = ignoredFolders();
1359
+ return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [], ignored)).map((path) => relative(cwd, path)).sort();
1329
1360
  }
1330
1361
  async function readText(path) {
1331
1362
  const file = Bun.file(path);
@@ -1388,11 +1419,12 @@ ${blanked(template)}`) : text.replace(MARKUP_BLOCK, blanked);
1388
1419
  }
1389
1420
 
1390
1421
  // src/hotspots.ts
1391
- var DEFAULT_SINCE = "6 months ago";
1392
- var DEFAULT_BULK = 25;
1422
+ var SETTINGS = readUserConfig("hotspots");
1423
+ var DEFAULT_SINCE = typeof SETTINGS.since === "string" && SETTINGS.since !== "" ? SETTINGS.since : "6 months ago";
1424
+ var DEFAULT_BULK = configuredNumber("hotspots", "bulk", 25);
1393
1425
  var DAY_MS2 = 86400000;
1394
1426
  var DEFAULT_HALF_LIFE = "90d";
1395
- var DEFAULT_COUNT = 20;
1427
+ var DEFAULT_COUNT = configuredNumber("hotspots", "limit", 20);
1396
1428
  var USAGE = `hotspots [options] [dir]: ranks the source files under dir (here by default) by complexity times churn, the ones both hard to read and often edited first, honouring .gitignore
1397
1429
 
1398
1430
  Complexity is the count of decision points in the file (branches, loops, cases, catches, boolean operators, ternaries) plus one, churn the commits touching it since --since (${DEFAULT_SINCE}), score their product. A commit counts for less the older it is (half as much every --half-life, 0 for all alike) and a commit touching more than --bulk files, a format or rename sweep, is left out. Each file also shows its most complex declaration, found by indentation. Test files and generated or built files are left out unless --all.
@@ -9,6 +9,7 @@ import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
11
  import process7 from "process";
12
+
12
13
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
13
14
  var ct = /[aeiou]y$/;
14
15
  var N = new Map;
@@ -45,6 +46,7 @@ function ko(t, e, r = "...") {
45
46
  }
46
47
  var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
47
48
  var z = new Map;
49
+
48
50
  // ../kit/src/mode.ts
49
51
  import process2 from "process";
50
52
  var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
@@ -92,7 +94,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
92
94
  return false;
93
95
  return r?.isTTY === true;
94
96
  }
95
- function f2(r, e = []) {
97
+ function f(r, e = []) {
96
98
  let l = "", n = "";
97
99
  for (let t = 0, i = e.length;t < i; t++)
98
100
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
@@ -102,7 +104,7 @@ function f2(r, e = []) {
102
104
  if (Array.isArray(a)) {
103
105
  let s = g.get(i);
104
106
  if (s === undefined)
105
- s = f2(r, [...e, a]), g.set(i, s);
107
+ s = f(r, [...e, a]), g.set(i, s);
106
108
  return s;
107
109
  }
108
110
  if (typeof a === "function")
@@ -111,20 +113,20 @@ function f2(r, e = []) {
111
113
  if (u === undefined) {
112
114
  if (g.size >= 64)
113
115
  g.clear();
114
- u = f2(r, [...e, a(...s)]), g.set(y, u);
116
+ u = f(r, [...e, a(...s)]), g.set(y, u);
115
117
  }
116
118
  return u;
117
119
  };
118
120
  throw Error(`Unknown style: ${String(i)}`);
119
121
  } });
120
122
  }
121
- function Fe2(r = {}) {
122
- return f2(r);
123
+ function Fe(r = {}) {
124
+ return f(r);
123
125
  }
124
- var o2 = Fe2();
126
+ var o = Fe();
125
127
 
126
128
  // ../kit/src/theme.ts
127
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
129
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
128
130
  import { homedir as homedir2 } from "os";
129
131
  import { join as join3, resolve as resolve2 } from "path";
130
132
  import process5 from "process";
@@ -145,6 +147,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
145
147
  }
146
148
 
147
149
  // ../kit/src/user-config.ts
150
+ import { existsSync as existsSync2, readFileSync } from "fs";
148
151
  import { homedir } from "os";
149
152
  import { join as join2 } from "path";
150
153
  import process4 from "process";
@@ -155,6 +158,28 @@ function configBase(where = {}) {
155
158
  function userConfigPath(bin, where = {}) {
156
159
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
157
160
  }
161
+ function userConfigReadPath(bin, legacy = [], where = {}) {
162
+ const current = userConfigPath(bin, where);
163
+ if (existsSync2(current))
164
+ return current;
165
+ const base = configBase(where);
166
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
167
+ }
168
+ function readUserConfig(bin, where = {}, legacy = []) {
169
+ const path = userConfigReadPath(bin, legacy, where);
170
+ if (!existsSync2(path))
171
+ return {};
172
+ try {
173
+ const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
174
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
175
+ } catch {
176
+ return {};
177
+ }
178
+ }
179
+ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
180
+ const value = readUserConfig(bin, where, legacy)[key];
181
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
182
+ }
158
183
 
159
184
  // ../kit/src/theme.ts
160
185
  var ENDS = new Map;
@@ -221,7 +246,7 @@ function readThemeFile(path, warn) {
221
246
  warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
222
247
  return;
223
248
  }
224
- const parsed = JSON.parse(readFileSync(path, "utf8"));
249
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
225
250
  if (isRecord(parsed))
226
251
  return parsed;
227
252
  warn(`${path} is not a JSON object, theme ignored`);
@@ -287,7 +312,7 @@ function applyFile(theme, file, where, warn) {
287
312
  }
288
313
  }
289
314
  function endsWalk(home) {
290
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
315
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
291
316
  }
292
317
  var warned = new Set;
293
318
  function warnOnce(message) {
@@ -343,7 +368,7 @@ function takesControlCodes(stream, env = process6.env) {
343
368
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
344
369
  }
345
370
  function paint(stream, env = process6.env) {
346
- return Fe2({ stream: { isTTY: takesControlCodes(stream, env) }, env });
371
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
347
372
  }
348
373
  function marked(mark, text, stream, detail, env = process6.env) {
349
374
  const colors = paint(stream, env);
@@ -871,7 +896,7 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
871
896
  var RESET_STYLE = `${ESC}[0m`;
872
897
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
873
898
  // ../kit/src/cli.ts
874
- import { readFileSync as readFileSync2, realpathSync } from "fs";
899
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
875
900
  import { dirname as dirname3, join as join5 } from "path";
876
901
  import process12 from "process";
877
902
 
@@ -1172,7 +1197,7 @@ async function printCandidates(found) {
1172
1197
  function packageVersion(entry = Bun.main) {
1173
1198
  for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1174
1199
  try {
1175
- const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1200
+ const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
1176
1201
  if (typeof version === "string")
1177
1202
  return version;
1178
1203
  } catch {}
@@ -1229,6 +1254,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
1229
1254
  }
1230
1255
  // ../kit/src/folders.ts
1231
1256
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1257
+ function ignoredFolders(extra = [], where = {}) {
1258
+ const configured = readUserConfig("config", where).ignore;
1259
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1260
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1261
+ }
1232
1262
  // ../kit/src/limit.ts
1233
1263
  function limitOptions(fallback) {
1234
1264
  return {
@@ -1299,11 +1329,11 @@ async function churnSince(cwd, since, { bulk, halfLifeMs, now = Date.now() }) {
1299
1329
  }
1300
1330
 
1301
1331
  // src/files.ts
1302
- import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "fs";
1332
+ import { existsSync as existsSync4, readdirSync, statSync as statSync2 } from "fs";
1303
1333
  import { join as join6, relative } from "path";
1304
1334
  var MAX_BYTES = 2000000;
1305
1335
  var SNIFF_BYTES = 8000;
1306
- function walk(dir, found) {
1336
+ function walk(dir, found, ignored) {
1307
1337
  let entries;
1308
1338
  try {
1309
1339
  entries = readdirSync(dir, { withFileTypes: true });
@@ -1311,10 +1341,10 @@ function walk(dir, found) {
1311
1341
  return found;
1312
1342
  }
1313
1343
  for (const entry of entries) {
1314
- if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
1344
+ if (entry.name.startsWith(".") || ignored.has(entry.name))
1315
1345
  continue;
1316
1346
  if (entry.isDirectory())
1317
- walk(join6(dir, entry.name), found);
1347
+ walk(join6(dir, entry.name), found, ignored);
1318
1348
  else if (entry.isFile())
1319
1349
  found.push(join6(dir, entry.name));
1320
1350
  }
@@ -1323,9 +1353,10 @@ function walk(dir, found) {
1323
1353
  async function listFiles(paths, cwd) {
1324
1354
  const listed = await runCommand(["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", ...paths], { cwd });
1325
1355
  if (listed.code === 0)
1326
- return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync3(join6(cwd, path))).sort();
1356
+ return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync4(join6(cwd, path))).sort();
1327
1357
  const roots = paths.length === 0 ? [cwd] : paths.map((path) => join6(cwd, path));
1328
- return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [])).map((path) => relative(cwd, path)).sort();
1358
+ const ignored = ignoredFolders();
1359
+ return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [], ignored)).map((path) => relative(cwd, path)).sort();
1329
1360
  }
1330
1361
  async function readText(path) {
1331
1362
  const file = Bun.file(path);
@@ -1388,11 +1419,12 @@ ${blanked(template)}`) : text.replace(MARKUP_BLOCK, blanked);
1388
1419
  }
1389
1420
 
1390
1421
  // src/hotspots.ts
1391
- var DEFAULT_SINCE = "6 months ago";
1392
- var DEFAULT_BULK = 25;
1422
+ var SETTINGS = readUserConfig("hotspots");
1423
+ var DEFAULT_SINCE = typeof SETTINGS.since === "string" && SETTINGS.since !== "" ? SETTINGS.since : "6 months ago";
1424
+ var DEFAULT_BULK = configuredNumber("hotspots", "bulk", 25);
1393
1425
  var DAY_MS2 = 86400000;
1394
1426
  var DEFAULT_HALF_LIFE = "90d";
1395
- var DEFAULT_COUNT = 20;
1427
+ var DEFAULT_COUNT = configuredNumber("hotspots", "limit", 20);
1396
1428
  var USAGE = `hotspots [options] [dir]: ranks the source files under dir (here by default) by complexity times churn, the ones both hard to read and often edited first, honouring .gitignore
1397
1429
 
1398
1430
  Complexity is the count of decision points in the file (branches, loops, cases, catches, boolean operators, ternaries) plus one, churn the commits touching it since --since (${DEFAULT_SINCE}), score their product. A commit counts for less the older it is (half as much every --half-life, 0 for all alike) and a commit touching more than --bulk files, a format or rename sweep, is left out. Each file also shows its most complex declaration, found by indentation. Test files and generated or built files are left out unless --all.
package/dist/peek-cli.js CHANGED
@@ -9,6 +9,7 @@ import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
11
  import process7 from "process";
12
+
12
13
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
13
14
  var ct = /[aeiou]y$/;
14
15
  var N = new Map;
@@ -45,6 +46,7 @@ function ko(t, e, r = "...") {
45
46
  }
46
47
  var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
47
48
  var z = new Map;
49
+
48
50
  // ../kit/src/mode.ts
49
51
  import process2 from "process";
50
52
  var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
@@ -92,7 +94,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
92
94
  return false;
93
95
  return r?.isTTY === true;
94
96
  }
95
- function f2(r, e = []) {
97
+ function f(r, e = []) {
96
98
  let l = "", n = "";
97
99
  for (let t = 0, i = e.length;t < i; t++)
98
100
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
@@ -102,7 +104,7 @@ function f2(r, e = []) {
102
104
  if (Array.isArray(a)) {
103
105
  let s = g.get(i);
104
106
  if (s === undefined)
105
- s = f2(r, [...e, a]), g.set(i, s);
107
+ s = f(r, [...e, a]), g.set(i, s);
106
108
  return s;
107
109
  }
108
110
  if (typeof a === "function")
@@ -111,20 +113,20 @@ function f2(r, e = []) {
111
113
  if (u === undefined) {
112
114
  if (g.size >= 64)
113
115
  g.clear();
114
- u = f2(r, [...e, a(...s)]), g.set(y, u);
116
+ u = f(r, [...e, a(...s)]), g.set(y, u);
115
117
  }
116
118
  return u;
117
119
  };
118
120
  throw Error(`Unknown style: ${String(i)}`);
119
121
  } });
120
122
  }
121
- function Fe2(r = {}) {
122
- return f2(r);
123
+ function Fe(r = {}) {
124
+ return f(r);
123
125
  }
124
- var o2 = Fe2();
126
+ var o = Fe();
125
127
 
126
128
  // ../kit/src/theme.ts
127
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
129
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
128
130
  import { homedir as homedir2 } from "os";
129
131
  import { join as join3, resolve as resolve2 } from "path";
130
132
  import process5 from "process";
@@ -145,6 +147,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
145
147
  }
146
148
 
147
149
  // ../kit/src/user-config.ts
150
+ import { existsSync as existsSync2, readFileSync } from "fs";
148
151
  import { homedir } from "os";
149
152
  import { join as join2 } from "path";
150
153
  import process4 from "process";
@@ -155,6 +158,28 @@ function configBase(where = {}) {
155
158
  function userConfigPath(bin, where = {}) {
156
159
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
157
160
  }
161
+ function userConfigReadPath(bin, legacy = [], where = {}) {
162
+ const current = userConfigPath(bin, where);
163
+ if (existsSync2(current))
164
+ return current;
165
+ const base = configBase(where);
166
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
167
+ }
168
+ function readUserConfig(bin, where = {}, legacy = []) {
169
+ const path = userConfigReadPath(bin, legacy, where);
170
+ if (!existsSync2(path))
171
+ return {};
172
+ try {
173
+ const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
174
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
175
+ } catch {
176
+ return {};
177
+ }
178
+ }
179
+ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
180
+ const value = readUserConfig(bin, where, legacy)[key];
181
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
182
+ }
158
183
 
159
184
  // ../kit/src/theme.ts
160
185
  var ENDS = new Map;
@@ -221,7 +246,7 @@ function readThemeFile(path, warn) {
221
246
  warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
222
247
  return;
223
248
  }
224
- const parsed = JSON.parse(readFileSync(path, "utf8"));
249
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
225
250
  if (isRecord(parsed))
226
251
  return parsed;
227
252
  warn(`${path} is not a JSON object, theme ignored`);
@@ -287,7 +312,7 @@ function applyFile(theme, file, where, warn) {
287
312
  }
288
313
  }
289
314
  function endsWalk(home) {
290
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
315
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
291
316
  }
292
317
  var warned = new Set;
293
318
  function warnOnce(message) {
@@ -343,7 +368,7 @@ function takesControlCodes(stream, env = process6.env) {
343
368
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
344
369
  }
345
370
  function paint(stream, env = process6.env) {
346
- return Fe2({ stream: { isTTY: takesControlCodes(stream, env) }, env });
371
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
347
372
  }
348
373
  function marked(mark, text, stream, detail, env = process6.env) {
349
374
  const colors = paint(stream, env);
@@ -871,7 +896,7 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
871
896
  var RESET_STYLE = `${ESC}[0m`;
872
897
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
873
898
  // ../kit/src/cli.ts
874
- import { readFileSync as readFileSync2, realpathSync } from "fs";
899
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
875
900
  import { dirname as dirname3, join as join5 } from "path";
876
901
  import process12 from "process";
877
902
 
@@ -1172,7 +1197,7 @@ async function printCandidates(found) {
1172
1197
  function packageVersion(entry = Bun.main) {
1173
1198
  for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1174
1199
  try {
1175
- const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1200
+ const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
1176
1201
  if (typeof version === "string")
1177
1202
  return version;
1178
1203
  } catch {}
@@ -1229,6 +1254,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
1229
1254
  }
1230
1255
  // ../kit/src/folders.ts
1231
1256
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1257
+ function ignoredFolders(extra = [], where = {}) {
1258
+ const configured = readUserConfig("config", where).ignore;
1259
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1260
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1261
+ }
1232
1262
  // ../kit/src/limit.ts
1233
1263
  function limitOptions(fallback) {
1234
1264
  return {
@@ -1262,11 +1292,11 @@ import { isAbsolute as isAbsolute2, join as join7, relative as relative2, resolv
1262
1292
  import process14 from "process";
1263
1293
 
1264
1294
  // src/files.ts
1265
- import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "fs";
1295
+ import { existsSync as existsSync4, readdirSync, statSync as statSync2 } from "fs";
1266
1296
  import { join as join6, relative } from "path";
1267
1297
  var MAX_BYTES = 2000000;
1268
1298
  var SNIFF_BYTES = 8000;
1269
- function walk(dir, found) {
1299
+ function walk(dir, found, ignored) {
1270
1300
  let entries;
1271
1301
  try {
1272
1302
  entries = readdirSync(dir, { withFileTypes: true });
@@ -1274,10 +1304,10 @@ function walk(dir, found) {
1274
1304
  return found;
1275
1305
  }
1276
1306
  for (const entry of entries) {
1277
- if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
1307
+ if (entry.name.startsWith(".") || ignored.has(entry.name))
1278
1308
  continue;
1279
1309
  if (entry.isDirectory())
1280
- walk(join6(dir, entry.name), found);
1310
+ walk(join6(dir, entry.name), found, ignored);
1281
1311
  else if (entry.isFile())
1282
1312
  found.push(join6(dir, entry.name));
1283
1313
  }
@@ -1286,9 +1316,10 @@ function walk(dir, found) {
1286
1316
  async function listFiles(paths, cwd) {
1287
1317
  const listed = await runCommand(["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", ...paths], { cwd });
1288
1318
  if (listed.code === 0)
1289
- return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync3(join6(cwd, path))).sort();
1319
+ return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync4(join6(cwd, path))).sort();
1290
1320
  const roots = paths.length === 0 ? [cwd] : paths.map((path) => join6(cwd, path));
1291
- return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [])).map((path) => relative(cwd, path)).sort();
1321
+ const ignored = ignoredFolders();
1322
+ return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [], ignored)).map((path) => relative(cwd, path)).sort();
1292
1323
  }
1293
1324
  async function readText(path) {
1294
1325
  const file = Bun.file(path);
@@ -9,6 +9,7 @@ import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
11
  import process7 from "process";
12
+
12
13
  // ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
13
14
  var ct = /[aeiou]y$/;
14
15
  var N = new Map;
@@ -45,6 +46,7 @@ function ko(t, e, r = "...") {
45
46
  }
46
47
  var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
47
48
  var z = new Map;
49
+
48
50
  // ../kit/src/mode.ts
49
51
  import process2 from "process";
50
52
  var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
@@ -92,7 +94,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
92
94
  return false;
93
95
  return r?.isTTY === true;
94
96
  }
95
- function f2(r, e = []) {
97
+ function f(r, e = []) {
96
98
  let l = "", n = "";
97
99
  for (let t = 0, i = e.length;t < i; t++)
98
100
  l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
@@ -102,7 +104,7 @@ function f2(r, e = []) {
102
104
  if (Array.isArray(a)) {
103
105
  let s = g.get(i);
104
106
  if (s === undefined)
105
- s = f2(r, [...e, a]), g.set(i, s);
107
+ s = f(r, [...e, a]), g.set(i, s);
106
108
  return s;
107
109
  }
108
110
  if (typeof a === "function")
@@ -111,20 +113,20 @@ function f2(r, e = []) {
111
113
  if (u === undefined) {
112
114
  if (g.size >= 64)
113
115
  g.clear();
114
- u = f2(r, [...e, a(...s)]), g.set(y, u);
116
+ u = f(r, [...e, a(...s)]), g.set(y, u);
115
117
  }
116
118
  return u;
117
119
  };
118
120
  throw Error(`Unknown style: ${String(i)}`);
119
121
  } });
120
122
  }
121
- function Fe2(r = {}) {
122
- return f2(r);
123
+ function Fe(r = {}) {
124
+ return f(r);
123
125
  }
124
- var o2 = Fe2();
126
+ var o = Fe();
125
127
 
126
128
  // ../kit/src/theme.ts
127
- import { existsSync as existsSync2, readFileSync, statSync } from "fs";
129
+ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
128
130
  import { homedir as homedir2 } from "os";
129
131
  import { join as join3, resolve as resolve2 } from "path";
130
132
  import process5 from "process";
@@ -145,6 +147,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
145
147
  }
146
148
 
147
149
  // ../kit/src/user-config.ts
150
+ import { existsSync as existsSync2, readFileSync } from "fs";
148
151
  import { homedir } from "os";
149
152
  import { join as join2 } from "path";
150
153
  import process4 from "process";
@@ -155,6 +158,28 @@ function configBase(where = {}) {
155
158
  function userConfigPath(bin, where = {}) {
156
159
  return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
157
160
  }
161
+ function userConfigReadPath(bin, legacy = [], where = {}) {
162
+ const current = userConfigPath(bin, where);
163
+ if (existsSync2(current))
164
+ return current;
165
+ const base = configBase(where);
166
+ return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
167
+ }
168
+ function readUserConfig(bin, where = {}, legacy = []) {
169
+ const path = userConfigReadPath(bin, legacy, where);
170
+ if (!existsSync2(path))
171
+ return {};
172
+ try {
173
+ const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
174
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
175
+ } catch {
176
+ return {};
177
+ }
178
+ }
179
+ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
180
+ const value = readUserConfig(bin, where, legacy)[key];
181
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
182
+ }
158
183
 
159
184
  // ../kit/src/theme.ts
160
185
  var ENDS = new Map;
@@ -221,7 +246,7 @@ function readThemeFile(path, warn) {
221
246
  warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
222
247
  return;
223
248
  }
224
- const parsed = JSON.parse(readFileSync(path, "utf8"));
249
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
225
250
  if (isRecord(parsed))
226
251
  return parsed;
227
252
  warn(`${path} is not a JSON object, theme ignored`);
@@ -287,7 +312,7 @@ function applyFile(theme, file, where, warn) {
287
312
  }
288
313
  }
289
314
  function endsWalk(home) {
290
- return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
315
+ return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
291
316
  }
292
317
  var warned = new Set;
293
318
  function warnOnce(message) {
@@ -343,7 +368,7 @@ function takesControlCodes(stream, env = process6.env) {
343
368
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
344
369
  }
345
370
  function paint(stream, env = process6.env) {
346
- return Fe2({ stream: { isTTY: takesControlCodes(stream, env) }, env });
371
+ return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
347
372
  }
348
373
  function marked(mark, text, stream, detail, env = process6.env) {
349
374
  const colors = paint(stream, env);
@@ -871,7 +896,7 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
871
896
  var RESET_STYLE = `${ESC}[0m`;
872
897
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
873
898
  // ../kit/src/cli.ts
874
- import { readFileSync as readFileSync2, realpathSync } from "fs";
899
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
875
900
  import { dirname as dirname3, join as join5 } from "path";
876
901
  import process12 from "process";
877
902
 
@@ -1172,7 +1197,7 @@ async function printCandidates(found) {
1172
1197
  function packageVersion(entry = Bun.main) {
1173
1198
  for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1174
1199
  try {
1175
- const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
1200
+ const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
1176
1201
  if (typeof version === "string")
1177
1202
  return version;
1178
1203
  } catch {}
@@ -1229,6 +1254,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
1229
1254
  }
1230
1255
  // ../kit/src/folders.ts
1231
1256
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1257
+ function ignoredFolders(extra = [], where = {}) {
1258
+ const configured = readUserConfig("config", where).ignore;
1259
+ const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1260
+ return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1261
+ }
1232
1262
  // ../kit/src/limit.ts
1233
1263
  function limitOptions(fallback) {
1234
1264
  return {
@@ -1261,11 +1291,11 @@ import { join as join7 } from "path";
1261
1291
  import process14 from "process";
1262
1292
 
1263
1293
  // src/files.ts
1264
- import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "fs";
1294
+ import { existsSync as existsSync4, readdirSync, statSync as statSync2 } from "fs";
1265
1295
  import { join as join6, relative } from "path";
1266
1296
  var MAX_BYTES = 2000000;
1267
1297
  var SNIFF_BYTES = 8000;
1268
- function walk(dir, found) {
1298
+ function walk(dir, found, ignored) {
1269
1299
  let entries;
1270
1300
  try {
1271
1301
  entries = readdirSync(dir, { withFileTypes: true });
@@ -1273,10 +1303,10 @@ function walk(dir, found) {
1273
1303
  return found;
1274
1304
  }
1275
1305
  for (const entry of entries) {
1276
- if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
1306
+ if (entry.name.startsWith(".") || ignored.has(entry.name))
1277
1307
  continue;
1278
1308
  if (entry.isDirectory())
1279
- walk(join6(dir, entry.name), found);
1309
+ walk(join6(dir, entry.name), found, ignored);
1280
1310
  else if (entry.isFile())
1281
1311
  found.push(join6(dir, entry.name));
1282
1312
  }
@@ -1285,9 +1315,10 @@ function walk(dir, found) {
1285
1315
  async function listFiles(paths, cwd) {
1286
1316
  const listed = await runCommand(["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", ...paths], { cwd });
1287
1317
  if (listed.code === 0)
1288
- return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync3(join6(cwd, path))).sort();
1318
+ return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync4(join6(cwd, path))).sort();
1289
1319
  const roots = paths.length === 0 ? [cwd] : paths.map((path) => join6(cwd, path));
1290
- return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [])).map((path) => relative(cwd, path)).sort();
1320
+ const ignored = ignoredFolders();
1321
+ return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [], ignored)).map((path) => relative(cwd, path)).sort();
1291
1322
  }
1292
1323
  async function readText(path) {
1293
1324
  const file = Bun.file(path);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-code",
3
3
  "type": "module",
4
- "version": "0.14.0",
4
+ "version": "0.14.2",
5
5
  "description": "peek, todo-scan and hotspots: source read by spans, symbols and outlines in one call, the TODO and issue-reference comments of a repository with stale ones flagged, and the files ranked by complexity times git churn.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -46,6 +46,6 @@
46
46
  "@kaynooo/utils": "3.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@kaynooo/cli-kit": "0.35.0"
49
+ "@kaynooo/cli-kit": "0.37.0"
50
50
  }
51
51
  }