dev-diagnosis-cli 0.1.2 → 0.1.4
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/CHANGELOG.md +23 -0
- package/README.md +3 -2
- package/lib/context.mjs +32 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.4 — unreleased
|
|
4
|
+
|
|
5
|
+
- Fix: a large file now carries a suggestion — its exact path from the
|
|
6
|
+
repo root — so `context --fix` writes it into `.aiignore` and a
|
|
7
|
+
re-scan comes back clean. Large files used to carry no suggestion, so
|
|
8
|
+
on any repo with one oversized file the fix wrote everything else and
|
|
9
|
+
the next scan still failed on the same file, including this project's
|
|
10
|
+
own demo fixture (its 1.7 MB `data/export.json`). The documented
|
|
11
|
+
"`--fix` followed by a re-scan comes back clean" promise now holds
|
|
12
|
+
for every kind of noise. (54 tests.)
|
|
13
|
+
- Docs: the 0.1.3 entry below is now dated — it went live on npm on
|
|
14
|
+
2026-11-11 but the entry still said "unreleased".
|
|
15
|
+
|
|
16
|
+
## 0.1.3 — 2026-11-11
|
|
17
|
+
|
|
18
|
+
- Fix: nested build-output directories are reported by their full path
|
|
19
|
+
from the repo root (`packages/foo/dist/`) instead of a bare `dist/` —
|
|
20
|
+
the bare entry only matches top-level output, so `--fix` on a repo
|
|
21
|
+
whose build output lives in a subdirectory wrote an `.aiignore`
|
|
22
|
+
entry the next scan ignored, and the scan kept failing after the
|
|
23
|
+
fix. Files under one build directory are also rolled up into a
|
|
24
|
+
single row instead of one row per file. (53 tests.)
|
|
25
|
+
|
|
3
26
|
## 0.1.2 — 2026-11-11
|
|
4
27
|
|
|
5
28
|
- New: `context --fix` (and `all --fix`) writes the `.aiignore`
|
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ Worth a look before sharing:
|
|
|
58
58
|
.env.example — environment template (usually safe to share)
|
|
59
59
|
Fix: add these to .aiignore (or the agent's ignore list):
|
|
60
60
|
*.log
|
|
61
|
+
data/export.json
|
|
61
62
|
dist/
|
|
62
63
|
package-lock.json
|
|
63
64
|
FAIL some context noise found (score 75/100)
|
|
@@ -92,7 +93,7 @@ The demo repo is intentionally noisy, so `all` exits 1: the context and flakes c
|
|
|
92
93
|
|
|
93
94
|
### `context` — what an AI agent should not read
|
|
94
95
|
|
|
95
|
-
Walks the repo (skipping `.git`, `node_modules` and other hidden directories) and classifies every file: build output, large files over 1 MB, lockfiles, logs, binary payloads, secret-like files and environment templates. It prints a 0–100 score, the bytes lost per category, the noisy files, the files worth a look before sharing, and the `.aiignore` entries that would fix it. Files the repo's `.aiignore` already lists are excluded from the scan entirely — they are what the agent will not be handed, so they are not noise any more. `context --fix` writes the suggestions into `.aiignore` for you; `--json` includes the fix outcome in the output.
|
|
96
|
+
Walks the repo (skipping `.git`, `node_modules` and other hidden directories) and classifies every file: build output, large files over 1 MB, lockfiles, logs, binary payloads, secret-like files and environment templates. It prints a 0–100 score, the bytes lost per category, the noisy files, the files worth a look before sharing, and the `.aiignore` entries that would fix it. Build-output directories are reported by their full path from the repo root (`packages/foo/dist/`, not a bare `dist/`) and rolled up into one row per directory, so the entry `--fix` writes matches nested build output too. A large file is fixed by its exact path from the repo root — no glob can single one file out — so `--fix` followed by a re-scan comes back clean even when the noise is a single oversized file. Files the repo's `.aiignore` already lists are excluded from the scan entirely — they are what the agent will not be handed, so they are not noise any more. `context --fix` writes the suggestions into `.aiignore` for you; `--json` includes the fix outcome in the output.
|
|
96
97
|
|
|
97
98
|
The score is the *noise-only* part of ai-context-doctor's score: 100 minus the category-weighted share of noise bytes (build 40, large 25, lockfile 20, log 15). The full ai-context-doctor score also weighs context volume, one file dominating, file sprawl and binary payloads, so its composite number reads lower on the same repo. The file classification itself is the same.
|
|
98
99
|
|
|
@@ -111,7 +112,7 @@ Reads JUnit XML across CI runs — each subdirectory of `<junit-dir>` is one run
|
|
|
111
112
|
## Development
|
|
112
113
|
|
|
113
114
|
```sh
|
|
114
|
-
npm test # node:test, no extra dependencies —
|
|
115
|
+
npm test # node:test, no extra dependencies — 54 tests
|
|
115
116
|
npm run example # run the CLI against the demo fixture
|
|
116
117
|
```
|
|
117
118
|
|
package/lib/context.mjs
CHANGED
|
@@ -96,9 +96,15 @@ export function classifyPath(relativePath, size = 0) {
|
|
|
96
96
|
const parts = normalized.split('/');
|
|
97
97
|
const basename = parts[parts.length - 1];
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
// A noise directory is reported by its full path from the repo root
|
|
100
|
+
// (packages/foo/dist/), not just its name: two build directories in
|
|
101
|
+
// different parts of the tree would otherwise print the same label,
|
|
102
|
+
// and the .aiignore entry --fix writes has to match the whole path —
|
|
103
|
+
// a bare dist/ only ignores top-level build output.
|
|
104
|
+
for (let i = 0; i < parts.length - 1; i += 1) {
|
|
105
|
+
if (NOISE_DIRS.has(parts[i])) {
|
|
106
|
+
const dir = `${parts.slice(0, i + 1).join('/')}/`;
|
|
107
|
+
return { noise: { label: dir, reason: NOISE_DIRS.get(parts[i]) }, suggestion: dir };
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
110
|
if (LOCKFILES.has(basename)) {
|
|
@@ -108,7 +114,13 @@ export function classifyPath(relativePath, size = 0) {
|
|
|
108
114
|
return { noise: { label: normalized, reason: 'local log file' }, suggestion: '*.log' };
|
|
109
115
|
}
|
|
110
116
|
if (size > LARGE_FILE_THRESHOLD_BYTES) {
|
|
111
|
-
|
|
117
|
+
// A large file has no pattern that fixes it — a glob would be wrong —
|
|
118
|
+
// so the fix is its exact path from the repo root. Without that, a
|
|
119
|
+
// repo with one oversized file could never come back clean: --fix
|
|
120
|
+
// would write everything else and the next scan would still fail on
|
|
121
|
+
// the same file, which is exactly what the --fix round-trip promises
|
|
122
|
+
// not to do.
|
|
123
|
+
return { noise: { label: normalized, reason: 'large file' }, suggestion: normalized };
|
|
112
124
|
}
|
|
113
125
|
if (isTemplateFile(basename)) {
|
|
114
126
|
return { review: { label: normalized, reason: 'environment template (usually safe to share)' }, suggestion: null };
|
|
@@ -239,12 +251,27 @@ export function scanDirectory(root, options = {}) {
|
|
|
239
251
|
walk(absolute, absolute, files, state);
|
|
240
252
|
|
|
241
253
|
const noise = [];
|
|
254
|
+
// One row per build-output directory, not one row per file inside it:
|
|
255
|
+
// a dist/ with hundreds of files would otherwise flood the noise list
|
|
256
|
+
// (and the score uses the summed bytes either way).
|
|
257
|
+
const dirNoise = new Map();
|
|
242
258
|
const review = [];
|
|
243
259
|
const suggestions = new Set();
|
|
244
260
|
for (const file of files) {
|
|
245
261
|
const result = classifyPath(file.relativePath, file.size);
|
|
246
262
|
if (result.noise) {
|
|
247
|
-
|
|
263
|
+
const item = { ...result.noise, bytes: file.size, path: file.relativePath.split(path.sep).join('/') };
|
|
264
|
+
if (item.label.endsWith('/')) {
|
|
265
|
+
const existing = dirNoise.get(item.label);
|
|
266
|
+
if (existing) existing.bytes += file.size;
|
|
267
|
+
else {
|
|
268
|
+
const aggregated = { label: item.label, reason: item.reason, bytes: file.size, path: item.label };
|
|
269
|
+
dirNoise.set(item.label, aggregated);
|
|
270
|
+
noise.push(aggregated);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
noise.push(item);
|
|
274
|
+
}
|
|
248
275
|
if (result.suggestion) suggestions.add(result.suggestion);
|
|
249
276
|
} else if (result.review) {
|
|
250
277
|
review.push({ ...result.review, bytes: file.size, path: file.relativePath.split(path.sep).join('/') });
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"WJDdidi-1","bin":{"dev-diagnosis":"bin/dev-diagnosis.js"},"bugs":{"url":"https://github.com/WJDdidi-1/dev-doctor/issues"},"description":"One offline CLI that diagnoses a repo the way four small tools do: context noise for AI agents, missing CLI commands, build-cache value, and flaky tests.","engines":{"node":">=18"},"files":["bin/","lib/","examples/","README.md","LICENSE","CHANGELOG.md"],"homepage":"https://github.com/WJDdidi-1/dev-doctor#readme","keywords":["cli","diagnostics","ai-coding","context","build-cache","flaky-tests","path","developer-tools","offline"],"license":"Apache-2.0","name":"dev-diagnosis-cli","repository":{"type":"git","url":"git+https://github.com/WJDdidi-1/dev-doctor.git"},"scripts":{"example":"node examples/demo.mjs","test":"node --test"},"type":"module","version":"0.1.
|
|
1
|
+
{"author":"WJDdidi-1","bin":{"dev-diagnosis":"bin/dev-diagnosis.js"},"bugs":{"url":"https://github.com/WJDdidi-1/dev-doctor/issues"},"description":"One offline CLI that diagnoses a repo the way four small tools do: context noise for AI agents, missing CLI commands, build-cache value, and flaky tests.","engines":{"node":">=18"},"files":["bin/","lib/","examples/","README.md","LICENSE","CHANGELOG.md"],"homepage":"https://github.com/WJDdidi-1/dev-doctor#readme","keywords":["cli","diagnostics","ai-coding","context","build-cache","flaky-tests","path","developer-tools","offline"],"license":"Apache-2.0","name":"dev-diagnosis-cli","repository":{"type":"git","url":"git+https://github.com/WJDdidi-1/dev-doctor.git"},"scripts":{"example":"node examples/demo.mjs","test":"node --test"},"type":"module","version":"0.1.4"}
|