pi-evals 0.6.1 → 0.7.0
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 +6 -0
- package/README.md +16 -0
- package/dist/analysis.js +314 -0
- package/dist/detectors.js +3 -1
- package/dist/index.js +43 -3
- package/dist/plan-graph.js +5 -1
- package/dist/shape.js +149 -0
- package/package.json +1 -1
- package/scripts/by-version.mjs +9 -0
- package/scripts/disagree.mjs +9 -0
- package/scripts/freshness.mjs +7 -0
- package/scripts/label-import.mjs +9 -0
- package/scripts/query-lib.mjs +41 -11
- package/scripts/sample.mjs +9 -0
- package/scripts/session-shape.mjs +8 -0
- package/skills/analyzing-evals/SKILL.md +8 -5
- package/src/analysis.ts +275 -0
- package/src/detectors.ts +3 -1
- package/src/index.ts +44 -3
- package/src/plan-graph.ts +6 -1
- package/src/shape.ts +123 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
- The analysis scripts from labelling and error analysis ship in `scripts/`: `freshness` (is the index current; exits 1 when summaries come from mixed extractor versions), `disagree <rule>` (where the code and your labels disagree, session by session, and which way), `by-version <detector>` (pass rate per package version), `sample <n>` (a stratified, seeded sample of unlabelled sessions to label), `label-import <answers>` (a submitted label form into `labels.jsonl`), and `session-shape <id>` (the ordered events the detectors see, without message text). Output over 2,000 bytes goes to a file under `runs/` in the state dir.
|
|
6
|
+
- `/evals run` lists the scripts with what each is for; `/evals run <script> [args]` runs one and shows its output, with script names completed.
|
|
7
|
+
- The analyzing-evals skill names these scripts at the steps that use them: freshness first, disagree and session-shape when a number looks wrong, sample and label-import for hand labels.
|
|
8
|
+
|
|
3
9
|
## 0.6.1
|
|
4
10
|
|
|
5
11
|
- An extract stopped part-way after an extractor upgrade no longer passes off old results as current. Each session file's summary now records the extractor version that wrote it, and any other version is read again. Before, the first 0.6.0 extract was killed by a timeout and saved the new version mark while most summaries were still old, so the next run skipped them: check agreement read 11/20 instead of 23/24 until a full rebuild. Every session is read once more (extractor version 6).
|
package/README.md
CHANGED
|
@@ -51,10 +51,26 @@ The observer loads in every session, subagents included.
|
|
|
51
51
|
| `/evals label <rule> pass\|fail\|unclear [note]` | The same in one line; `<rule>` is a check name (`anchor_before_first_edit`, `check_after_last_edit`, `todo_evidence`, `close_guard_quiet`, `plan_names_graph`) or `other`. |
|
|
52
52
|
| `/evals label <your words>` | Anything else, e.g. `/evals label 剛剛沒先跑測試就說完成`: the agent turns your words into labels with `evals_label` and says in one line what it recorded. The verdict is yours and your words are kept as the note. |
|
|
53
53
|
| `/evals label undo` | Withdraws the current session's last label given in the moment. |
|
|
54
|
+
| `/evals run` | Lists the shipped analysis scripts, each with what it is for. |
|
|
55
|
+
| `/evals run <script> [args]` | Runs one and shows its output; output over 2,000 bytes goes to a file under `runs/` in the state dir and the reply names it. |
|
|
54
56
|
|
|
55
57
|
A label records the session, the time, and the key of the todo item in progress, if any (its `uid`, else `<session>#<id>`, as work items are keyed).
|
|
56
58
|
It reaches the report and `evals_query` at their next read, without an extract.
|
|
57
59
|
|
|
60
|
+
### Analysis scripts
|
|
61
|
+
|
|
62
|
+
Shipped in `scripts/`; run them with `/evals run`, or with `node <package>/scripts/<name>.mjs` (agents do, through the analyzing-evals skill). They read the index, checkpoint, labels and change timeline, never a transcript into their output; `session-shape` reads one session file to classify its events and prints no message text.
|
|
63
|
+
|
|
64
|
+
| Script | What it answers |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `freshness` | Is the index current: last extract, summaries per extractor version, a run stopped part-way. Exits 1 when versions are mixed. |
|
|
67
|
+
| `disagree <rule> [--range DAYS]` | Each labelled session where the code and your verdict in effect disagree, with the code's reason and where the label came from, and which way they lean. |
|
|
68
|
+
| `by-version <detector> [--pkg PACKAGE]` | Pass rate and n per package version at session start (anchorloop by default; pi-straw-boss for `plan_names_graph`). |
|
|
69
|
+
| `sample <n> [--since ISO] [--seed N]` | A seeded sample of judged sessions you have not labelled, spread over project, kind, model and size, written to `labels/sample-<date>.json` (ids and metadata only). |
|
|
70
|
+
| `label-import <answer-file> [--sample FILE]` | Your submitted label form (`- <n>_<rule>: pass`, `- <n>_type: …`, `- <n>_note: …`) as after-the-fact labels in `labels.jsonl`. |
|
|
71
|
+
| `session-shape <session id>` | The events the detectors see, in order: tools, edit paths, check runs by exit code, todo statuses and evidence, close-guard reminders, the sb role; then each detector's verdict. |
|
|
72
|
+
| `change-impact`, `skill-days`, `package-errors` | A change's numbers before and after; a skill's sessions per day; a package's errors per day. |
|
|
73
|
+
|
|
58
74
|
### `/ask-ai`: get an answer before the agent acts
|
|
59
75
|
|
|
60
76
|
| Command | What it does |
|
package/dist/analysis.js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The analysis scripts' logic (scripts/*.mjs are thin wrappers): freshness, disagree, by-version, sample and
|
|
3
|
+
* label-import. Each reads the index, checkpoint, labels or change timeline and returns lines; none prints message
|
|
4
|
+
* text or a label's note.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { loadRows } from "./build.js";
|
|
9
|
+
import { readChanges, versionAt } from "./changes.js";
|
|
10
|
+
import { DETECTORS, ERA_START } from "./detectors.js";
|
|
11
|
+
import { EXTRACTOR_VERSION, loadCheckpoint } from "./extract/run.js";
|
|
12
|
+
import { appendLabel, cleanNote, FAILURE_TYPES, readLabels, RULES } from "./labels.js";
|
|
13
|
+
import { DETECTOR_META } from "./meta.js";
|
|
14
|
+
import { safeName } from "./schema.js";
|
|
15
|
+
import { ANCHORLOOP } from "./work/join.js";
|
|
16
|
+
export class AnalysisError extends Error {
|
|
17
|
+
}
|
|
18
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
19
|
+
const pct = (num, den) => (den ? `${((100 * num) / den).toFixed(1)}%` : "n/a");
|
|
20
|
+
function checkpointOf(lay) {
|
|
21
|
+
if (!existsSync(lay.checkpoint))
|
|
22
|
+
throw new AnalysisError("No checkpoint. Run /evals extract first.");
|
|
23
|
+
return loadCheckpoint(lay.checkpoint);
|
|
24
|
+
}
|
|
25
|
+
function lastExtractOf(lay, cp) {
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(readFileSync(lay.status, "utf8")).lastExtract ?? cp.lastExtract;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return cp.lastExtract;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Last extract, summaries per extractor version, and signs of a run stopped part-way; status 1 when versions are mixed. */
|
|
34
|
+
export function freshness(lay, now = Date.now()) {
|
|
35
|
+
const cp = checkpointOf(lay);
|
|
36
|
+
const last = lastExtractOf(lay, cp);
|
|
37
|
+
const by = new Map();
|
|
38
|
+
for (const f of Object.values(cp.files)) {
|
|
39
|
+
const key = f.extractor === undefined ? "unstamped (0.6.0 or older)" : String(f.extractor);
|
|
40
|
+
by.set(key, (by.get(key) ?? 0) + 1);
|
|
41
|
+
}
|
|
42
|
+
const lines = [`last extract ${last ?? "never"}${last ? ` (${((now - Date.parse(last)) / 3_600_000).toFixed(1)} h ago)` : ""}`, `this pi-evals writes extractor ${EXTRACTOR_VERSION}`];
|
|
43
|
+
for (const [version, n] of [...by].sort())
|
|
44
|
+
lines.push(`extractor ${version}: ${plural(n, "summary", "summaries")}`);
|
|
45
|
+
const saved = statSync(lay.checkpoint).mtimeMs;
|
|
46
|
+
if (last && saved > Date.parse(last) + 120_000)
|
|
47
|
+
lines.push("The checkpoint was saved after the last finished extract: a run stopped part-way.");
|
|
48
|
+
if (existsSync(lay.days) && last) {
|
|
49
|
+
const built = JSON.parse(readFileSync(lay.days, "utf8")).built;
|
|
50
|
+
if (built && built < last)
|
|
51
|
+
lines.push(`The index (built ${built}) is older than the last extract: run /evals extract to rebuild it.`);
|
|
52
|
+
}
|
|
53
|
+
const mixed = [...by.keys()].some((v) => v !== String(EXTRACTOR_VERSION));
|
|
54
|
+
if (mixed)
|
|
55
|
+
lines.push(`STALE: some summaries are from another extractor version. Run /evals extract to finish; do not read the numbers until this passes.`);
|
|
56
|
+
else
|
|
57
|
+
lines.push("Fresh: every summary is from the current extractor.");
|
|
58
|
+
return { lines, status: mixed ? 1 : 0 };
|
|
59
|
+
}
|
|
60
|
+
const sourceOf = (r) => (r.source === "live" ? "live" : r.source === "live-prompt" ? "prompt" : "after");
|
|
61
|
+
/** Code verdicts and explanations by session id, with each session's start. */
|
|
62
|
+
function verdicts(cp, rule) {
|
|
63
|
+
const out = new Map();
|
|
64
|
+
for (const f of Object.values(cp.files)) {
|
|
65
|
+
const r = f.summary.evals[rule];
|
|
66
|
+
if (r)
|
|
67
|
+
out.set(f.summary.sessionId, { label: r.label, why: r.explanation, start: f.summary.start });
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/** Per labelled session, the user's verdict in effect against the code's, and which way the disagreements lean. */
|
|
72
|
+
export function disagree(lay, rule, rangeDays) {
|
|
73
|
+
if (!DETECTORS.includes(rule))
|
|
74
|
+
throw new AnalysisError(`Unknown rule. Rules: ${DETECTORS.join(", ")}.`);
|
|
75
|
+
const cp = checkpointOf(lay);
|
|
76
|
+
const code = verdicts(cp, rule);
|
|
77
|
+
const last = Date.parse(lastExtractOf(lay, cp) ?? new Date().toISOString());
|
|
78
|
+
const rows = readLabels(lay.labels).filter((r) => r.annotator !== "agent" && r.evaluation_name === rule && !r.undo);
|
|
79
|
+
let agree = 0, unclear = 0, noCode = 0, under = 0, over = 0;
|
|
80
|
+
const listed = [];
|
|
81
|
+
for (const r of rows) {
|
|
82
|
+
const c = code.get(r.session_id);
|
|
83
|
+
if (rangeDays !== undefined && (!c || Date.parse(c.start) < last - rangeDays * 86_400_000))
|
|
84
|
+
continue;
|
|
85
|
+
if (r.label === "unclear") {
|
|
86
|
+
unclear += 1;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (!c || c.label === "na") {
|
|
90
|
+
noCode += 1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (c.label === r.label) {
|
|
94
|
+
agree += 1;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (c.label === "fail")
|
|
98
|
+
under += 1;
|
|
99
|
+
else
|
|
100
|
+
over += 1;
|
|
101
|
+
listed.push(`${safeName(r.session_id)} human ${r.label}, code ${c.label} (${safeName(c.why)}), ${sourceOf(r)}`);
|
|
102
|
+
}
|
|
103
|
+
const lean = !listed.length ? "No disagreements." : under === over ? "The disagreements split evenly." : under > over
|
|
104
|
+
? "Most disagreements are code fail / human pass: the detector undercounts; its rate is too low."
|
|
105
|
+
: "Most disagreements are code pass / human fail: the detector overcounts; its rate is too high.";
|
|
106
|
+
return {
|
|
107
|
+
lines: [
|
|
108
|
+
`${rule}${rangeDays !== undefined ? ` (sessions of the last ${rangeDays} days)` : ""}: ${agree + listed.length} labelled, ${agree} agree, ${listed.length} disagree; unclear ${unclear}; no code verdict ${noCode}`,
|
|
109
|
+
...listed,
|
|
110
|
+
`code fail / human pass: ${under} (detector undercounts)`,
|
|
111
|
+
`code pass / human fail: ${over} (detector overcounts)`,
|
|
112
|
+
lean,
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const numeric = (v) => (/^\d+(\.\d+)*$/.test(v) ? v.split(".").map(Number) : undefined);
|
|
117
|
+
function byVersionOrder(a, b) {
|
|
118
|
+
const x = numeric(a), y = numeric(b);
|
|
119
|
+
if (!x || !y)
|
|
120
|
+
return x ? -1 : y ? 1 : a.localeCompare(b);
|
|
121
|
+
for (let i = 0; i < Math.max(x.length, y.length); i++)
|
|
122
|
+
if ((x[i] ?? 0) !== (y[i] ?? 0))
|
|
123
|
+
return (x[i] ?? 0) - (y[i] ?? 0);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
/** A detector's pass rate per version of a package at each session's start. */
|
|
127
|
+
export function byVersion(lay, detector, pkg) {
|
|
128
|
+
if (!DETECTORS.includes(detector))
|
|
129
|
+
throw new AnalysisError(`Unknown detector. Detectors: ${DETECTORS.join(", ")}.`);
|
|
130
|
+
const names = pkg ? [pkg] : DETECTOR_META[detector]?.introducedIn ? [DETECTOR_META[detector].introducedIn.package] : ANCHORLOOP;
|
|
131
|
+
const changes = readChanges(lay.changes);
|
|
132
|
+
const cells = new Map();
|
|
133
|
+
for (const r of loadRows(lay)) {
|
|
134
|
+
const v = r.ev[detector];
|
|
135
|
+
if (v === undefined)
|
|
136
|
+
continue;
|
|
137
|
+
const version = versionAt(changes, names, r.s) ?? "unknown";
|
|
138
|
+
const cell = cells.get(version) ?? { pass: 0, n: 0 };
|
|
139
|
+
cell.pass += v;
|
|
140
|
+
cell.n += 1;
|
|
141
|
+
cells.set(version, cell);
|
|
142
|
+
}
|
|
143
|
+
if (!cells.size)
|
|
144
|
+
return { lines: [`${detector} by ${names[0]} version: no judged sessions in the index.`] };
|
|
145
|
+
return {
|
|
146
|
+
lines: [
|
|
147
|
+
`${detector} by ${names[0]} version at session start (pass / judged):`,
|
|
148
|
+
...[...cells].sort(([a], [b]) => byVersionOrder(a, b)).map(([v, c]) => `${v}: ${c.pass}/${c.n} ${pct(c.pass, c.n)}`),
|
|
149
|
+
"Versions differ in time as well as code: other changes landed in the same days.",
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** Small seeded generator (mulberry32). */
|
|
154
|
+
function random(seed) {
|
|
155
|
+
let a = seed >>> 0;
|
|
156
|
+
return () => {
|
|
157
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
158
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
159
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
160
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const sizeOf = (calls) => (calls < 20 ? "small" : calls < 100 ? "medium" : "large");
|
|
164
|
+
/** A stratified sample of judged sessions the user has not labelled yet, written to `<state>/labels/sample-<date>.json`. */
|
|
165
|
+
export function sample(lay, n, options = {}) {
|
|
166
|
+
if (!Number.isSafeInteger(n) || n < 1 || n > 500)
|
|
167
|
+
throw new AnalysisError("n must be 1 to 500.");
|
|
168
|
+
const since = options.since ?? ERA_START;
|
|
169
|
+
if (!Number.isFinite(Date.parse(since)))
|
|
170
|
+
throw new AnalysisError("--since must be an ISO time.");
|
|
171
|
+
const now = options.now ?? new Date();
|
|
172
|
+
const seed = options.seed ?? Number(now.toISOString().slice(0, 10).replaceAll("-", ""));
|
|
173
|
+
const labelled = new Set(readLabels(lay.labels).filter((r) => r.annotator !== "agent").map((r) => r.session_id));
|
|
174
|
+
const strata = new Map();
|
|
175
|
+
const seen = new Set();
|
|
176
|
+
let judged = 0;
|
|
177
|
+
for (const f of Object.values(checkpointOf(lay).files)) {
|
|
178
|
+
const s = f.summary;
|
|
179
|
+
if (!s.sessionId || seen.has(s.sessionId) || labelled.has(s.sessionId) || s.start < since)
|
|
180
|
+
continue;
|
|
181
|
+
seen.add(s.sessionId);
|
|
182
|
+
if (!Object.values(s.evals).some((r) => r && r.label !== "na"))
|
|
183
|
+
continue;
|
|
184
|
+
judged += 1;
|
|
185
|
+
const row = { session_id: s.sessionId, project: s.project, kind: s.kind, model: safeName(s.model ?? "unknown"), start: s.start, tool_calls: s.toolCalls, size: sizeOf(s.toolCalls) };
|
|
186
|
+
const key = `${row.project}|${row.kind}|${row.model}|${row.size}`;
|
|
187
|
+
strata.set(key, [...(strata.get(key) ?? []), row]);
|
|
188
|
+
}
|
|
189
|
+
const next = random(seed);
|
|
190
|
+
const shuffle = (list) => {
|
|
191
|
+
for (let i = list.length - 1; i > 0; i--) {
|
|
192
|
+
const j = Math.floor(next() * (i + 1));
|
|
193
|
+
[list[i], list[j]] = [list[j], list[i]];
|
|
194
|
+
}
|
|
195
|
+
return list;
|
|
196
|
+
};
|
|
197
|
+
const groups = shuffle([...strata.keys()].sort()).map((k) => shuffle([...strata.get(k)].sort((a, b) => a.session_id.localeCompare(b.session_id))));
|
|
198
|
+
const chosen = [];
|
|
199
|
+
while (chosen.length < n && groups.some((g) => g.length)) {
|
|
200
|
+
for (const g of groups)
|
|
201
|
+
if (g.length && chosen.length < n)
|
|
202
|
+
chosen.push({ n: chosen.length + 1, ...g.pop() });
|
|
203
|
+
}
|
|
204
|
+
const dir = join(lay.state, "labels");
|
|
205
|
+
mkdirSync(dir, { recursive: true });
|
|
206
|
+
const file = join(dir, `sample-${now.toISOString().slice(0, 10)}.json`);
|
|
207
|
+
writeFileSync(file, `${JSON.stringify(chosen, null, 1)}\n`);
|
|
208
|
+
const tally = (key) => [...new Set(chosen.map((c) => c[key]))].map((v) => `${v} ${chosen.filter((c) => c[key] === v).length}`).join(", ");
|
|
209
|
+
return {
|
|
210
|
+
lines: [
|
|
211
|
+
`${chosen.length} of ${judged} judged, unlabelled sessions since ${since} (${strata.size} strata by project, kind, model, size; seed ${seed}; labelled sessions left out)`,
|
|
212
|
+
`kind: ${tally("kind")}`,
|
|
213
|
+
`size: ${tally("size")}`,
|
|
214
|
+
`projects: ${new Set(chosen.map((c) => c.project)).size}`,
|
|
215
|
+
`sample: ${file}`,
|
|
216
|
+
],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/** The newest `sample-*.json` under `<state>/labels`. */
|
|
220
|
+
function latestSample(lay) {
|
|
221
|
+
const dir = join(lay.state, "labels");
|
|
222
|
+
const files = existsSync(dir) ? readdirSync(dir).filter((f) => /^sample-.*\.json$/.test(f)).sort() : [];
|
|
223
|
+
if (!files.length)
|
|
224
|
+
throw new AnalysisError("No sample under <state>/labels; run the sample script or pass --sample.");
|
|
225
|
+
return join(dir, files.at(-1));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Form answers (`- <n>_<rule>: pass|fail|unclear`, `- <n>_type: <failure type>`, `- <n>_note: ...`) become after-the-fact
|
|
229
|
+
* human rows, appended to labels.jsonl; a later import of the same session and rule replaces the earlier in effect.
|
|
230
|
+
*/
|
|
231
|
+
export function labelImport(lay, answerFile, sampleFile, at = new Date().toISOString()) {
|
|
232
|
+
let answer;
|
|
233
|
+
let entries;
|
|
234
|
+
try {
|
|
235
|
+
answer = readFileSync(answerFile, "utf8");
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
throw new AnalysisError("Cannot read the answer file.");
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
entries = JSON.parse(readFileSync(sampleFile ?? latestSample(lay), "utf8"));
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
throw error instanceof AnalysisError ? error : new AnalysisError("Cannot read the sample file.");
|
|
245
|
+
}
|
|
246
|
+
const sessionOf = (n) => entries.find((e) => e.n === n)?.session_id ?? (entries.some((e) => e.n !== undefined) ? undefined : entries[n - 1]?.session_id);
|
|
247
|
+
const fields = new Map();
|
|
248
|
+
let current;
|
|
249
|
+
for (const line of answer.split("\n")) {
|
|
250
|
+
const m = /^- ([A-Za-z0-9_]+): ?(.*)$/.exec(line);
|
|
251
|
+
if (m)
|
|
252
|
+
fields.set((current = m[1]), m[2]);
|
|
253
|
+
else if (/^Other comments:/.test(line))
|
|
254
|
+
current = undefined;
|
|
255
|
+
else if (current !== undefined && line !== "")
|
|
256
|
+
fields.set(current, `${fields.get(current)}\n${line}`);
|
|
257
|
+
}
|
|
258
|
+
const rules = RULES.filter((r) => r !== "other");
|
|
259
|
+
const rows = [];
|
|
260
|
+
const problems = [];
|
|
261
|
+
const noted = new Set();
|
|
262
|
+
for (const [name, raw] of fields) {
|
|
263
|
+
const m = /^(\d+)_([a-z_]+)$/.exec(name);
|
|
264
|
+
if (!m || !rules.includes(m[2]))
|
|
265
|
+
continue;
|
|
266
|
+
const n = Number(m[1]);
|
|
267
|
+
const session = sessionOf(n);
|
|
268
|
+
if (!session) {
|
|
269
|
+
problems.push(`${name}: no session #${n} in the sample`);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const label = raw.trim();
|
|
273
|
+
if (!label)
|
|
274
|
+
continue;
|
|
275
|
+
if (label !== "pass" && label !== "fail" && label !== "unclear") {
|
|
276
|
+
problems.push(`${name}: unknown verdict`);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const row = { session_id: session, evaluation_name: m[2], label, at, annotator: "human", source: "batch" };
|
|
280
|
+
const type = fields.get(`${n}_type`)?.trim();
|
|
281
|
+
if (type && label === "fail") {
|
|
282
|
+
if (FAILURE_TYPES.includes(type))
|
|
283
|
+
row.type = type;
|
|
284
|
+
else
|
|
285
|
+
problems.push(`${n}_type: unknown failure type`);
|
|
286
|
+
}
|
|
287
|
+
const note = cleanNote(fields.get(`${n}_note`));
|
|
288
|
+
if (note && !noted.has(n)) {
|
|
289
|
+
row.note = note;
|
|
290
|
+
noted.add(n);
|
|
291
|
+
}
|
|
292
|
+
rows.push(row);
|
|
293
|
+
}
|
|
294
|
+
for (const row of rows)
|
|
295
|
+
appendLabel(lay.labels, row);
|
|
296
|
+
const per = new Map();
|
|
297
|
+
for (const r of rows)
|
|
298
|
+
per.set(r.evaluation_name, (per.get(r.evaluation_name) ?? 0) + 1);
|
|
299
|
+
return {
|
|
300
|
+
lines: [
|
|
301
|
+
`wrote ${plural(rows.length, "label", "labels")} (after the fact, human) to labels.jsonl${per.size ? `: ${[...per].map(([k, v]) => `${k} ${v}`).join(", ")}` : ""}`,
|
|
302
|
+
...problems.map((p) => `warning: ${p}`),
|
|
303
|
+
"A later import of the same session and rule replaces this one; labels.jsonl keeps both.",
|
|
304
|
+
],
|
|
305
|
+
status: rows.length ? 0 : 1,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/** The session file holding a session id, from the checkpoint. */
|
|
309
|
+
export function sessionFile(lay, id) {
|
|
310
|
+
for (const [path, f] of Object.entries(checkpointOf(lay).files))
|
|
311
|
+
if (f.summary.sessionId === id)
|
|
312
|
+
return path;
|
|
313
|
+
throw new AnalysisError("No such session in the index.");
|
|
314
|
+
}
|
package/dist/detectors.js
CHANGED
|
@@ -42,7 +42,7 @@ function commandsOf(text, bare) {
|
|
|
42
42
|
}
|
|
43
43
|
const LABEL = String.raw `(?:reality anchor|anchor|checks?|gates?|verify|verification|done when|驗證|檢查|驗收)`;
|
|
44
44
|
const LABELLED = new RegExp(String.raw `^[ \t>*_#-]*${LABEL}[*_]*\s*[::][*_]*\s*(.+)$`, "gim");
|
|
45
|
-
function anchorLine(text) {
|
|
45
|
+
export function anchorLine(text) {
|
|
46
46
|
return [...text.matchAll(LABELLED)].at(-1)?.[1];
|
|
47
47
|
}
|
|
48
48
|
/** Tools and scripts whose run checks a change: tests, builds, linters, type checkers, and named check scripts. */
|
|
@@ -64,6 +64,8 @@ const DOTNET_SCRIPT = String.raw `\S*dotnet[\w-]*\.py\s+(?:build|test)\b`;
|
|
|
64
64
|
const RUN_START = new RegExp(String.raw `^(?:(?:\S*/)?(?:${RUNNER.source})|${INTERPRETER}?(?:${CHECK_SCRIPT}|${DOTNET_SCRIPT}|\S*\btests?/\S+))`, "i");
|
|
65
65
|
// A mention in prose, as in a brief: a runner or a check script anywhere in a line.
|
|
66
66
|
const MENTION = new RegExp(String.raw `(?:^|[\s\x60("'>/])(?:${RUNNER.source}|${CHECK_SCRIPT})`, "im");
|
|
67
|
+
/** Whether a brief names a check: a labelled check line, or a runner or check script anywhere in it. */
|
|
68
|
+
export const namesCheck = (text) => anchorLine(text) !== undefined || MENTION.test(text);
|
|
67
69
|
// Shell lead-ins stripped from each command segment before matching.
|
|
68
70
|
const LEAD = /^(?:[({!]\s*|(?:time|exec|command|nice|sudo\s+-n|timeout\s+\d+[smh]?|set\s+-\S+(?:\s+\S+)?)\s+|[A-Za-z_][A-Za-z0-9_]*=(?:'[^']*'|"[^"]*"|\S*)\s+)+/;
|
|
69
71
|
/** Whether a shell command runs a check: one of its `&&`, `||`, `;`, `|` or line segments starts with a check runner. */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pi-evals: the live observer, the `/evals` command (status, extract, report, mark, label), `/ask-ai`, and the `evals_query` and `evals_label` tools.
|
|
2
|
+
* pi-evals: the live observer, the `/evals` command (status, extract, report, mark, label, run), `/ask-ai`, and the `evals_query` and `evals_label` tools.
|
|
3
3
|
*/
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -20,7 +20,30 @@ export function cliPath() {
|
|
|
20
20
|
const found = candidates.find((p) => existsSync(p));
|
|
21
21
|
return found ? { cmd: process.execPath, args: [found] } : undefined;
|
|
22
22
|
}
|
|
23
|
-
const SUBCOMMANDS = ["status", "findings", "extract", "report", "mark", "label"];
|
|
23
|
+
const SUBCOMMANDS = ["status", "findings", "extract", "report", "mark", "label", "run"];
|
|
24
|
+
/** The shipped analysis scripts (`scripts/<name>.mjs`) `/evals run` offers, with what each is for. */
|
|
25
|
+
export const SCRIPTS = {
|
|
26
|
+
freshness: "索引是不是最新的:最後擷取時間、各擷取器版本的摘要數;版本混雜時數字不能看",
|
|
27
|
+
disagree: "某條規則上程式判定和你的標記哪裡不一致,逐段列出,看偏哪一邊(用法:disagree <規則> [--range 天數])",
|
|
28
|
+
"by-version": "某項檢查在各套件版本下的通過率(用法:by-version <檢查> [--pkg 套件])",
|
|
29
|
+
sample: "分層抽樣還沒標過的工作段,給你手動標記(只有 id 與屬性)(用法:sample <數量> [--since 時間] [--seed 數字])",
|
|
30
|
+
"label-import": "把填好的標記表單答案寫進 labels.jsonl(用法:label-import <答案檔> [--sample 樣本檔])",
|
|
31
|
+
"session-shape": "一段工作的結構軌跡:檢查看到的事件順序,不含訊息內容(用法:session-shape <session id>)",
|
|
32
|
+
"change-impact": "某次調整前後的數字(用法:change-impact <時間或 sha> [套件或種類])",
|
|
33
|
+
"skill-days": "某個 skill 每天被載入的工作段數(用法:skill-days <skill> [專案])",
|
|
34
|
+
"package-errors": "某個套件每天的工具出錯數(用法:package-errors <套件> [專案])",
|
|
35
|
+
};
|
|
36
|
+
/** Runs one shipped script with the session's environment; resolves with its exit code and output. */
|
|
37
|
+
function runScript(name, args, env) {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
const child = spawn(process.execPath, [fileURLToPath(new URL(`../scripts/${name}.mjs`, import.meta.url)), ...args], { env: { ...process.env, ...env }, stdio: ["ignore", "pipe", "pipe"] });
|
|
40
|
+
let out = "";
|
|
41
|
+
child.stdout?.on("data", (c) => void (out += c.toString()));
|
|
42
|
+
child.stderr?.on("data", (c) => void (out += c.toString()));
|
|
43
|
+
child.on("error", (error) => resolve({ code: -1, out: error.message }));
|
|
44
|
+
child.on("close", (code) => resolve({ code, out: out.trim() }));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
24
47
|
function parseFlags(args) {
|
|
25
48
|
const out = { rest: [] };
|
|
26
49
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -102,8 +125,12 @@ export function createEvals(options = {}) {
|
|
|
102
125
|
});
|
|
103
126
|
};
|
|
104
127
|
pi.registerCommand("evals", {
|
|
105
|
-
description: "Usage and process records: /evals [status|findings|extract|report|mark <note>|label]",
|
|
128
|
+
description: "Usage and process records: /evals [status|findings|extract|report|mark <note>|label|run <script>]",
|
|
106
129
|
getArgumentCompletions: (prefix) => {
|
|
130
|
+
if (prefix.startsWith("run ")) {
|
|
131
|
+
const names = Object.keys(SCRIPTS).filter((n) => n.startsWith(prefix.slice(4)));
|
|
132
|
+
return names.length ? names.map((n) => ({ value: `run ${n}`, label: n, description: SCRIPTS[n] })) : null;
|
|
133
|
+
}
|
|
107
134
|
const items = SUBCOMMANDS.filter((s) => s.startsWith(prefix)).map((s) => ({ value: s, label: s }));
|
|
108
135
|
return items.length ? items : null;
|
|
109
136
|
},
|
|
@@ -149,6 +176,19 @@ export function createEvals(options = {}) {
|
|
|
149
176
|
else if (sub === "label") {
|
|
150
177
|
await labels.command(words.slice(1), ctx);
|
|
151
178
|
}
|
|
179
|
+
else if (sub === "run") {
|
|
180
|
+
const name = words[1];
|
|
181
|
+
if (!name) {
|
|
182
|
+
ctx.ui.notify(`pi-evals scripts (/evals run <script> [args]):\n${Object.entries(SCRIPTS).map(([n, what]) => `${n} ${what}`).join("\n")}`, "info");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (!Object.hasOwn(SCRIPTS, name)) {
|
|
186
|
+
ctx.ui.notify(`Unknown script "${name}". /evals run lists them.`, "warning");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const { code, out } = await runScript(name, words.slice(2), env);
|
|
190
|
+
ctx.ui.notify(out || `${name}: no output (exit ${code})`, code === 0 ? "info" : "warning");
|
|
191
|
+
}
|
|
152
192
|
else {
|
|
153
193
|
ctx.ui.notify(`Unknown subcommand "${sub}". Use: ${SUBCOMMANDS.join(", ")}.`, "warning");
|
|
154
194
|
}
|
package/dist/plan-graph.js
CHANGED
|
@@ -31,6 +31,10 @@ function text(content) {
|
|
|
31
31
|
return content;
|
|
32
32
|
return Array.isArray(content) ? content.map((p) => (obj(p).type === "text" ? String(obj(p).text ?? "") : "")).join("\n") : "";
|
|
33
33
|
}
|
|
34
|
+
/** A main's kind from the sb role prompt section, if it is a main's prompt. */
|
|
35
|
+
export function sbKindOf(section) {
|
|
36
|
+
return STANDING_PROMPT.test(section) ? "standing" : MAIN_PROMPT.exec(section)?.[1];
|
|
37
|
+
}
|
|
34
38
|
export class PlanGraphTracker {
|
|
35
39
|
kind;
|
|
36
40
|
wasMain = false;
|
|
@@ -65,7 +69,7 @@ export class PlanGraphTracker {
|
|
|
65
69
|
const section = obj(message.sections)["straw-boss"];
|
|
66
70
|
if (typeof section !== "string")
|
|
67
71
|
return;
|
|
68
|
-
this.setKind(
|
|
72
|
+
this.setKind(sbKindOf(section));
|
|
69
73
|
}
|
|
70
74
|
else if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
71
75
|
for (const raw of message.content) {
|
package/dist/shape.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session's structural trace, the events the detectors read, in file order, for error analysis (`session-shape`).
|
|
3
|
+
* It names tools, edit paths (safe names only), check runs by exit code, todo statuses and evidence results, close-guard
|
|
4
|
+
* notice kinds and the sb role; message text, commands and arguments are read only to classify and never printed.
|
|
5
|
+
*/
|
|
6
|
+
import { createReadStream } from "node:fs";
|
|
7
|
+
import { createInterface } from "node:readline";
|
|
8
|
+
import { anchorLine, ERA_START, isCheckRun, namesCheck, noticeKind, ProcessTracker } from "./detectors.js";
|
|
9
|
+
import { graphOfTodo, sbKindOf } from "./plan-graph.js";
|
|
10
|
+
import { safeName } from "./schema.js";
|
|
11
|
+
const obj = (v) => (v && typeof v === "object" ? v : {});
|
|
12
|
+
const str = (v) => (typeof v === "string" ? v : undefined);
|
|
13
|
+
const text = (content) => (typeof content === "string" ? content : Array.isArray(content) ? content.map((p) => (obj(p).type === "text" ? String(obj(p).text ?? "") : "")).join("\n") : "");
|
|
14
|
+
function counts(list) {
|
|
15
|
+
const by = new Map();
|
|
16
|
+
for (const k of list)
|
|
17
|
+
by.set(k, (by.get(k) ?? 0) + 1);
|
|
18
|
+
return [...by].map(([k, n]) => `${n} ${k}`).join(", ");
|
|
19
|
+
}
|
|
20
|
+
/** Lines of the trace, then one line per detector result. */
|
|
21
|
+
export async function sessionShape(file) {
|
|
22
|
+
const out = [];
|
|
23
|
+
const tracker = new ProcessTracker();
|
|
24
|
+
const calls = new Map();
|
|
25
|
+
let start = "";
|
|
26
|
+
let seq = 0;
|
|
27
|
+
let firstUser = true;
|
|
28
|
+
let lastTodo = "";
|
|
29
|
+
const at = (ts) => {
|
|
30
|
+
const t = Date.parse(str(ts) ?? "");
|
|
31
|
+
if (!start || !Number.isFinite(t))
|
|
32
|
+
return "";
|
|
33
|
+
const s = Math.max(0, Math.round((t - Date.parse(start)) / 1000));
|
|
34
|
+
return ` +${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
|
35
|
+
};
|
|
36
|
+
const push = (entry, what) => out.push(`#${seq}${at(entry.timestamp)} ${what}`);
|
|
37
|
+
const lines = createInterface({ input: createReadStream(file, "utf8"), crlfDelay: Number.POSITIVE_INFINITY });
|
|
38
|
+
for await (const line of lines) {
|
|
39
|
+
if (!line || line.charCodeAt(0) !== 123)
|
|
40
|
+
continue;
|
|
41
|
+
let entry;
|
|
42
|
+
try {
|
|
43
|
+
entry = JSON.parse(line);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
seq += 1;
|
|
49
|
+
tracker.feed(entry);
|
|
50
|
+
const type = entry.type;
|
|
51
|
+
if (type === "session") {
|
|
52
|
+
start = str(entry.timestamp) ?? "";
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!start && str(entry.timestamp))
|
|
56
|
+
start = str(entry.timestamp);
|
|
57
|
+
if (type === "compaction")
|
|
58
|
+
push(entry, "compaction");
|
|
59
|
+
else if (type === "custom") {
|
|
60
|
+
const data = obj(entry.data);
|
|
61
|
+
if (entry.customType === "todo/v1" && Array.isArray(data.tasks)) {
|
|
62
|
+
const tasks = data.tasks.map(obj);
|
|
63
|
+
const ev = tasks.flatMap((t) => (Array.isArray(t.evidence) ? t.evidence.map((e) => `evidence ${obj(e).result === "pass" ? "pass" : "fail"}`) : []));
|
|
64
|
+
const graph = tasks.some((t) => graphOfTodo(t)) ? "; graph named" : "";
|
|
65
|
+
const now = `todo list: ${counts(tasks.map((t) => safeName(t.status)))}${ev.length ? `; ${counts(ev)}` : ""}${graph}`;
|
|
66
|
+
if (now !== lastTodo)
|
|
67
|
+
push(entry, now);
|
|
68
|
+
lastTodo = now;
|
|
69
|
+
}
|
|
70
|
+
else if (entry.customType === "straw-boss" && typeof data.duty === "string")
|
|
71
|
+
push(entry, `sb kind ${safeName(data.duty)} (kind entry)`);
|
|
72
|
+
}
|
|
73
|
+
else if (type === "custom_message") {
|
|
74
|
+
const details = obj(entry.details);
|
|
75
|
+
if (entry.customType === "anchorloop-close-guard")
|
|
76
|
+
push(entry, `close-guard ${noticeKind(entry.content)}`);
|
|
77
|
+
else if (entry.customType === "pi-loop-monitor") {
|
|
78
|
+
const o = obj(details.monitorOutcome);
|
|
79
|
+
if (details.deliveryGroup === "monitor-terminal")
|
|
80
|
+
push(entry, `monitor ${safeName(str(o.monitorId) ?? "?")} ended ${typeof o.exitCode === "number" ? `exit=${o.exitCode}` : safeName(o.status)}`);
|
|
81
|
+
}
|
|
82
|
+
else if (entry.customType === "straw-boss" && details.briefed) {
|
|
83
|
+
const b = obj(details.briefed);
|
|
84
|
+
push(entry, `sb role ${safeName(b.name ?? b.role)} ${b.duty ? safeName(b.duty) : ""}`.trim());
|
|
85
|
+
}
|
|
86
|
+
else if (entry.customType === "subagent_result")
|
|
87
|
+
push(entry, "subagent result");
|
|
88
|
+
}
|
|
89
|
+
else if (type === "message") {
|
|
90
|
+
const message = obj(entry.message);
|
|
91
|
+
if (message.role === "system") {
|
|
92
|
+
const section = obj(message.sections)["straw-boss"];
|
|
93
|
+
if (typeof section === "string")
|
|
94
|
+
push(entry, `sb kind ${sbKindOf(section) ?? "none (not a main)"} (role prompt)`);
|
|
95
|
+
}
|
|
96
|
+
else if (message.role === "user") {
|
|
97
|
+
const words = text(message.content);
|
|
98
|
+
push(entry, firstUser ? `user brief${namesCheck(words) ? " (names a check)" : ""}` : "user");
|
|
99
|
+
firstUser = false;
|
|
100
|
+
}
|
|
101
|
+
else if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
102
|
+
for (const raw of message.content) {
|
|
103
|
+
const part = obj(raw);
|
|
104
|
+
if (part.type === "text" && typeof part.text === "string" && anchorLine(part.text) !== undefined)
|
|
105
|
+
push(entry, "anchor stated");
|
|
106
|
+
if (part.type !== "toolCall" || typeof part.id !== "string")
|
|
107
|
+
continue;
|
|
108
|
+
const args = obj(part.arguments);
|
|
109
|
+
const name = safeName(part.name);
|
|
110
|
+
const command = str(args.command);
|
|
111
|
+
const items = [args, ...(Array.isArray(args.tasks) ? args.tasks.map(obj) : [])];
|
|
112
|
+
const evidence = items.flatMap((i) => (Array.isArray(i.evidence) ? i.evidence.map((e) => (obj(e).result === "pass" ? "pass" : "fail")) : []));
|
|
113
|
+
calls.set(part.id, {
|
|
114
|
+
name,
|
|
115
|
+
path: str(args.path),
|
|
116
|
+
check: command !== undefined && isCheckRun(command),
|
|
117
|
+
evidence: evidence.length ? counts(evidence.map((e) => `evidence ${e}`)) : undefined,
|
|
118
|
+
action: str(args.action) ? safeName(args.action) : undefined,
|
|
119
|
+
role: name === "subagent" ? safeName(str(args.agent) ?? "default") : undefined,
|
|
120
|
+
});
|
|
121
|
+
if (name === "todo" && items.some((i) => (typeof i.anchor === "string" && i.anchor.trim()) || obj(i.metadata).anchor))
|
|
122
|
+
push(entry, "todo anchor set");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (message.role === "toolResult" && typeof message.toolCallId === "string") {
|
|
126
|
+
const call = calls.get(message.toolCallId);
|
|
127
|
+
if (!call)
|
|
128
|
+
continue;
|
|
129
|
+
calls.delete(message.toolCallId);
|
|
130
|
+
const code = obj(message.structuredContent).exit_code;
|
|
131
|
+
const ok = typeof code === "number" ? code === 0 : message.isError !== true;
|
|
132
|
+
const status = typeof code === "number" ? `exit=${code}` : ok ? "ok" : "error";
|
|
133
|
+
if (call.name === "edit" || call.name === "write")
|
|
134
|
+
push(entry, `${call.name} ${call.path ? safeName(call.path) : "?"} ${ok ? "ok" : "error"}`);
|
|
135
|
+
else if (call.name === "bash" || call.name === "MonitorCreate")
|
|
136
|
+
push(entry, `${call.name === "bash" ? "bash" : "monitor start"}${call.check ? " check" : ""} ${status}`);
|
|
137
|
+
else if (call.name === "todo")
|
|
138
|
+
push(entry, `todo ${call.action ?? "?"} ${ok ? "ok" : "error"}${call.evidence ? `; ${call.evidence}` : ""}`);
|
|
139
|
+
else if (call.name === "subagent")
|
|
140
|
+
push(entry, `subagent ${call.role} ${ok ? "launched" : "error"}`);
|
|
141
|
+
else
|
|
142
|
+
push(entry, `${call.name} ${ok ? "ok" : "error"}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const r of tracker.results(start >= ERA_START))
|
|
147
|
+
out.push(`${r.name}: ${r.label} (${r.explanation})`);
|
|
148
|
+
return out;
|
|
149
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-evals",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Usage and process records for pi: how skills, packages, ask-user, monitors and subagents are used, back-filled from past sessions, with a static report and an evals_query tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { analysis, flags, layout, QueryError, run } from './query-lib.mjs';
|
|
2
|
+
|
|
3
|
+
// A detector's pass rate per package version at session start.
|
|
4
|
+
const usage = 'node by-version.mjs DETECTOR [--pkg PACKAGE]';
|
|
5
|
+
run(usage, args => {
|
|
6
|
+
const f = flags(args, ['--pkg']);
|
|
7
|
+
if (f.rest.length !== 1) throw new QueryError(usage);
|
|
8
|
+
return analysis.byVersion(layout(), f.rest[0], f.pkg);
|
|
9
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { analysis, flags, layout, QueryError, run } from './query-lib.mjs';
|
|
2
|
+
|
|
3
|
+
// Where the code and the user's labels disagree on one rule, session by session.
|
|
4
|
+
const usage = 'node disagree.mjs RULE [--range DAYS]';
|
|
5
|
+
run(usage, args => {
|
|
6
|
+
const f = flags(args, ['--range']);
|
|
7
|
+
if (f.rest.length !== 1 || (f.range !== undefined && !/^\d+$/.test(f.range))) throw new QueryError(usage);
|
|
8
|
+
return analysis.disagree(layout(), f.rest[0], f.range === undefined ? undefined : Number(f.range));
|
|
9
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { analysis, layout, run } from './query-lib.mjs';
|
|
2
|
+
|
|
3
|
+
// Is the index current? Exit 1 when summaries come from more than one extractor version.
|
|
4
|
+
const usage = 'node freshness.mjs';
|
|
5
|
+
const check = args => { if (args.length) throw new Error(usage); return analysis.freshness(layout()); };
|
|
6
|
+
check.noArgs = true;
|
|
7
|
+
run(usage, check);
|