Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project are documented here, following
[Keep a Changelog](https://keepachangelog.com/) and semantic versioning.

## [0.1.14] - 2026-09-16

### Fixed

- Include symlinked files that resolve to regular files in scan results instead of silently omitting them.

## [0.1.13] - 2026-09-16

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ctxtrim",
"version": "0.1.13",
"version": "0.1.14",
"description": "Trim what bloats your AI coding context. Scan a repo, find the high-cost/low-value files ballooning your Claude Code / Cursor / Codex context, and write ignore files to cut token cost. Zero dependencies.",
"type": "module",
"bin": {
Expand Down
9 changes: 6 additions & 3 deletions src/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ export function scanRepo(target, opts = {}) {
for (const e of entries) {
if (ALWAYS_SKIP.has(e.name)) continue;
const abs = join(dir, e.name);
if (e.isSymbolicLink()) continue;
if (e.isDirectory()) { walk(abs); continue; }
if (!e.isFile()) continue;
if (!e.isFile() && !e.isSymbolicLink()) continue;
let size = 0;
try { size = statSync(abs).size; } catch { continue; }
try {
const stat = statSync(abs);
if (!stat.isFile()) continue;
size = stat.size;
} catch { continue; }
const rel = relative(root, abs).split(sep).join("/");
const pathClassification = classifyPath(rel);
const info = pathClassification?.binary ? { tokens: 0, sample: "" } : fileInfo(abs, size);
Expand Down
12 changes: 11 additions & 1 deletion test/ctxtrim.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs, { existsSync, mkdtempSync, rmSync, truncateSync, writeFileSync } from "node:fs";
import fs, { existsSync, mkdtempSync, rmSync, symlinkSync, truncateSync, writeFileSync } from "node:fs";
import { spawnSync } from "node:child_process";
import { syncBuiltinESMExports } from "node:module";
import { tmpdir } from "node:os";
Expand Down Expand Up @@ -112,6 +112,16 @@ test("scan skips binary reads and retains content-dependent classification", (t)
assert.equal(result.files.find((file) => file.rel === "large.json").category, "data");
});

test("scan includes symlinked source files", (t) => {
const root = mkdtempSync(join(tmpdir(), "ctxtrim-symlink-"));
t.after(() => rmSync(root, { recursive: true, force: true }));
writeFileSync(join(root, "real.py"), "print(\"hello\")\n");
symlinkSync("real.py", join(root, "linked.py"));

const result = scanRepo(root);
assert.deepEqual(result.files.map((file) => file.rel).sort(), ["linked.py", "real.py"]);
});

test("scan finds trimmable bloat and keeps source", () => {
const s = scanRepo(repo);
assert.ok(s.totals.trimTokens > 0);
Expand Down
Loading