Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions skill/scripts/context-signals.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ function latestCritique(cwd) {
if (!latest) return null;
const get = (key) => latest.meta[key] ?? null;
const num = (v) => {
if (v == null) return null;
const n = Number(v);
return Number.isFinite(n) ? n : null;
};
return {
slug: get('slug'),
score: num(get('score')),
p0: num(get('p0')),
p1: num(get('p1')),
score: num(get('total_score') ?? get('score')),
p0: num(get('p0_count') ?? get('p0')),
p1: num(get('p1_count') ?? get('p1')),
timestamp: get('timestamp'),
file: path.relative(cwd, latest.path),
};
Expand Down
18 changes: 18 additions & 0 deletions tests/context-signals.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ describe('gatherSignals', () => {
assert.equal(s.critique.latest.slug, 'home');
});

it('reads the documented critique snapshot metadata keys', async () => {
write('.impeccable/critique/2026-05-02T10-00-00Z__pricing.md',
'---\nslug: pricing\ntotal_score: 24\np0_count: 2\np1_count: 5\ntimestamp: 2026-05-02T10-00-00Z\n---\nbody\n');
const s = await gatherSignals(scratch);
assert.equal(s.critique.latest.score, 24);
assert.equal(s.critique.latest.p0, 2);
assert.equal(s.critique.latest.p1, 5);
});

it('reports missing critique metrics as null', async () => {
write('.impeccable/critique/2026-05-02T10-00-00Z__pricing.md',
'---\nslug: pricing\ntimestamp: 2026-05-02T10-00-00Z\n---\nbody\n');
const s = await gatherSignals(scratch);
assert.equal(s.critique.latest.score, null);
assert.equal(s.critique.latest.p0, null);
assert.equal(s.critique.latest.p1, null);
});

it('reads the newest critique snapshot across target slugs', async () => {
write('.impeccable/critique/2026-05-01T10-00-00Z__home.md',
'---\nslug: home\nscore: 6\np0: 1\np1: 3\ntimestamp: 2026-05-01T10-00-00Z\n---\nbody\n');
Expand Down