Skip to content

Commit cf73f3b

Browse files
KryptosAIclaude
andauthored
fix: watch now correctly diffs against previous run and shows "no changes" (#77)
findLatestArtifact accepts an excludePath param so watch can skip the artifact it just wrote. When runs are identical, shows "✓ No changes since last run" instead of silently falling through. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f26c65 commit cf73f3b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/commands/watch.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ async function runWatchOneShot(
2323
const outPath = await writeRunArtifact(artifact, outDir);
2424

2525
// Find the PREVIOUS run for this target (excluding the one just written)
26-
const latestPath = await findLatestArtifact(outDir, target.targetId);
27-
if (latestPath && latestPath !== outPath) {
28-
const previousRaw = await readArtifact(latestPath);
26+
const previousPath = await findLatestArtifact(outDir, target.targetId, outPath);
27+
if (previousPath) {
28+
const previousRaw = await readArtifact(previousPath);
2929
if (previousRaw.artifactType === "run") {
30-
const previous = previousRaw;
31-
const diffResult = diff(previous, artifact);
30+
const diffResult = diff(previousRaw, artifact);
3231

33-
process.stdout.write(formatOutput(diffResult, options.format as "terminal" | "json") + "\n");
32+
if (diffResult.summary.regressions === 0 && diffResult.summary.recoveries === 0 && diffResult.summary.added === 0 && diffResult.summary.removed === 0) {
33+
process.stdout.write(formatOutput(artifact, options.format as "terminal" | "json") + "\n");
34+
process.stdout.write(`${c(ANSI.green, "✓ No changes")} since last run\n`);
35+
} else {
36+
process.stdout.write(formatOutput(diffResult, options.format as "terminal" | "json") + "\n");
37+
}
3438
process.stdout.write(`${c(ANSI.dim, `Artifact: ${outPath}`)}\n`);
3539

3640
if (options.failOnRegression && diffResult.summary.regressions > 0) {

src/storage.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ export async function writeRunArtifact(
2828
return filePath;
2929
}
3030

31-
export async function findLatestArtifact(outDir: string, targetId: string): Promise<string | null> {
31+
export async function findLatestArtifact(outDir: string, targetId: string, excludePath?: string): Promise<string | null> {
3232
const slug = slugify(targetId);
3333
const suffix = `--${slug}.json`;
3434
try {
3535
const entries = await readdir(outDir);
3636
const matching = entries
3737
.filter(f => f.endsWith(suffix))
3838
.sort()
39-
.reverse();
39+
.reverse()
40+
.map(f => path.join(outDir, f))
41+
.filter(f => f !== excludePath);
4042
if (matching.length === 0) return null;
41-
return path.join(outDir, matching[0]!);
43+
return matching[0]!;
4244
} catch {
4345
return null;
4446
}

0 commit comments

Comments
 (0)