dev-diagnosis-cli 0.1.0 → 0.1.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.
- package/CHANGELOG.md +12 -0
- package/README.md +13 -8
- package/bin/dev-diagnosis.js +8 -2
- package/examples/demo-repo/build.mjs +4 -2
- package/lib/context.mjs +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1 — 2026-11-11
|
|
4
|
+
|
|
5
|
+
- Docs: README now has npm version, CI, license and Node badges, and the
|
|
6
|
+
example output is regenerated verbatim — its paths match the repo layout.
|
|
7
|
+
- Fix: the demo build and the cache test fixture now simulate 400 ms of
|
|
8
|
+
work (was 150 ms), so the cache check's verdict stays decisive even on
|
|
9
|
+
loaded CI machines — 0.1.1's first CI run failed one job (macOS, Node 22)
|
|
10
|
+
because a 41 ms saving fell under the 50 ms "cache pays" threshold.
|
|
11
|
+
- Fix: `all` on a repo with no build cache no longer ends in FAIL — a
|
|
12
|
+
build command with no cache directory to measure is listed as skipped,
|
|
13
|
+
with the `--cache-dir` hint, instead of a failed cache check. (41 tests.)
|
|
14
|
+
|
|
3
15
|
## 0.1.0 — 2026-11-10
|
|
4
16
|
|
|
5
17
|
- First release: one CLI combining the four diagnostic checks.
|
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# dev-diagnosis
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/dev-diagnosis-cli)
|
|
4
|
+
[](https://github.com/WJDdidi-1/dev-doctor/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/WJDdidi-1/dev-doctor/blob/main/LICENSE)
|
|
6
|
+
[](https://www.npmjs.com/package/dev-diagnosis-cli)
|
|
7
|
+
|
|
3
8
|
One command that diagnoses your repo, your commands, your cache and your tests. It runs four checks that used to be four separate tools — whether an AI coding agent would read files it should not (`context`), why a CLI command is missing (`path`), whether a build cache actually pays (`cache`), and which tests are flaky (`flakes`) — and prints one report with a verdict per check. It is offline, has no runtime dependencies (Node.js standard library only), and works on Linux, macOS and Windows.
|
|
4
9
|
|
|
5
10
|
## Install and run
|
|
@@ -25,7 +30,7 @@ dev-diagnosis flakes <junit-dir> # flaky tests from JUnit XML
|
|
|
25
30
|
dev-diagnosis all [path] --command <name> --flakes <dir> -- <build-command...>
|
|
26
31
|
```
|
|
27
32
|
|
|
28
|
-
`all` always runs `context` on `[path]` (default: the current directory) and runs `path`, `flakes` and `cache` when their input is given. Checks without their input are listed as skipped, with the command that would run them, instead of silently pretending they ran. `--json` gives machine-readable output for `context`, `path`, `flakes` and `all`.
|
|
33
|
+
`all` always runs `context` on `[path]` (default: the current directory) and runs `path`, `flakes` and `cache` when their input is given. Checks without their input are listed as skipped, with the command that would run them, instead of silently pretending they ran. A build command on a repo with no cache directory to measure is also listed as skipped rather than failing: nothing to measure is not a problem. `--json` gives machine-readable output for `context`, `path`, `flakes` and `all`.
|
|
29
34
|
|
|
30
35
|
Exit codes: `0` every check that ran passed; `1` a check found something to fix or could not run; `2` usage error.
|
|
31
36
|
|
|
@@ -35,10 +40,10 @@ The repo ships a small demo project in `examples/demo-repo` (a build output, a l
|
|
|
35
40
|
|
|
36
41
|
```
|
|
37
42
|
$ dev-diagnosis all examples/demo-repo --command node --flakes examples/runs -- node build.mjs
|
|
38
|
-
dev-diagnosis — /home/hatch/workspace/dev-
|
|
43
|
+
dev-diagnosis — /home/hatch/workspace/dev-doctor-build/dev-doctor/examples/demo-repo
|
|
39
44
|
|
|
40
45
|
== context ==
|
|
41
|
-
Repo: /home/hatch/workspace/dev-
|
|
46
|
+
Repo: /home/hatch/workspace/dev-doctor-build/dev-doctor/examples/demo-repo
|
|
42
47
|
Files: 9 Size: 1.68 MB Score: 75/100 — Some context noise found
|
|
43
48
|
build output: 98 B (0%) — lost 0 of 40
|
|
44
49
|
large files: 1.68 MB (99.9%) — lost 25 of 25
|
|
@@ -72,11 +77,11 @@ com.example.CheckoutTest::appliesCoupon 1/2 2 new passed-o
|
|
|
72
77
|
FAIL 1 flaky, 1 always-failing across 2 runs
|
|
73
78
|
|
|
74
79
|
== cache ==
|
|
75
|
-
Cache dir: /home/hatch/workspace/dev-
|
|
80
|
+
Cache dir: /home/hatch/workspace/dev-doctor-build/dev-doctor/examples/demo-repo/.cache
|
|
76
81
|
Command: node build.mjs
|
|
77
|
-
Cold:
|
|
78
|
-
Verdict: cache pays — warm run is
|
|
79
|
-
PASS cache pays: cold
|
|
82
|
+
Cold: 491 ms Warm: 90 ms Saved: 401 ms (82%)
|
|
83
|
+
Verdict: cache pays — warm run is 401 ms (82%) faster than cold
|
|
84
|
+
PASS cache pays: cold 491 ms, warm 90 ms (warm run is 401 ms (82%) faster than cold)
|
|
80
85
|
|
|
81
86
|
Overall: FAIL — see the checks above
|
|
82
87
|
```
|
|
@@ -106,7 +111,7 @@ Reads JUnit XML across CI runs — each subdirectory of `<junit-dir>` is one run
|
|
|
106
111
|
## Development
|
|
107
112
|
|
|
108
113
|
```sh
|
|
109
|
-
npm test # node:test, no extra dependencies —
|
|
114
|
+
npm test # node:test, no extra dependencies — 41 tests
|
|
110
115
|
npm run example # run the CLI against the demo fixture
|
|
111
116
|
```
|
|
112
117
|
|
package/bin/dev-diagnosis.js
CHANGED
|
@@ -333,8 +333,14 @@ function main(argv) {
|
|
|
333
333
|
cacheCheck = runCache({ buildCommand: args.buildCommand, cacheDir: args.cacheDir, cwd: root });
|
|
334
334
|
checks.cache = cacheCheck;
|
|
335
335
|
} catch (error) {
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
if (String(error.message).includes('no cache directory found')) {
|
|
337
|
+
// Nothing to measure is not a failure: report it as skipped so
|
|
338
|
+
// `all` on a repo without a build cache does not end in FAIL.
|
|
339
|
+
skipped.push('cache — no cache directory found in this project; pass --cache-dir <dir> to measure one');
|
|
340
|
+
} else {
|
|
341
|
+
checks.cache = { result: null, passed: false, verdict: `could not run: ${error.message}`, error: error.message };
|
|
342
|
+
cacheCheck = checks.cache;
|
|
343
|
+
}
|
|
338
344
|
}
|
|
339
345
|
} else {
|
|
340
346
|
skipped.push('cache — add -- <build-command>, for example: dev-diagnosis all -- node build.mjs');
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Demo build: slow on a cold cache, fast on a warm one.
|
|
2
2
|
// If .cache/out.txt exists the work is already done; otherwise this
|
|
3
|
-
// script simulates
|
|
3
|
+
// script simulates 400 ms of real work and writes the cache file.
|
|
4
|
+
// 400 ms (not 150) so the cold-vs-warm gap dwarfs Node startup time
|
|
5
|
+
// and stays decisive on loaded CI machines.
|
|
4
6
|
import fs from 'node:fs';
|
|
5
7
|
import path from 'node:path';
|
|
6
8
|
|
|
@@ -9,7 +11,7 @@ const out = path.join(cacheDir, 'out.txt');
|
|
|
9
11
|
if (fs.existsSync(out)) {
|
|
10
12
|
console.log('cache hit');
|
|
11
13
|
} else {
|
|
12
|
-
const until = Date.now() +
|
|
14
|
+
const until = Date.now() + 400;
|
|
13
15
|
while (Date.now() < until) { /* simulate work the cache would skip */ }
|
|
14
16
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
15
17
|
fs.writeFileSync(out, 'built\n');
|
package/lib/context.mjs
CHANGED
|
@@ -137,7 +137,9 @@ function walk(root, dir, out, state) {
|
|
|
137
137
|
entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
138
138
|
for (const entry of entries) {
|
|
139
139
|
const full = path.join(dir, entry.name);
|
|
140
|
-
|
|
140
|
+
// Always report forward slashes, so output (and tests) are identical
|
|
141
|
+
// on Windows, macOS and Linux.
|
|
142
|
+
const rel = path.relative(root, full).split(path.sep).join('/');
|
|
141
143
|
if (entry.isDirectory()) {
|
|
142
144
|
if (IGNORED_DIRS.has(entry.name)) continue;
|
|
143
145
|
walk(root, full, out, state);
|
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.1"}
|