pi-evals 0.2.0 → 0.4.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 +15 -0
- package/README.md +23 -9
- package/dist/build.js +14 -4
- package/dist/cli.js +2 -2
- package/dist/coverage.js +8 -1
- package/dist/extract/run.js +1 -1
- package/dist/extract/session.js +43 -3
- package/dist/findings.js +54 -0
- package/dist/index.js +14 -7
- package/dist/meta.js +43 -1
- package/dist/model.js +35 -14
- package/dist/ops.js +53 -22
- package/dist/paths.js +3 -0
- package/dist/query.js +36 -13
- package/dist/ranges.js +14 -0
- package/dist/render.js +15 -5
- package/dist/report/concepts.js +23 -1
- package/dist/report/findings.js +12 -1
- package/dist/report/sections.js +7 -5
- package/dist/report/strip.js +42 -0
- package/dist/report/style.js +14 -1
- package/dist/report/timeline.js +5 -14
- package/dist/report/week.js +21 -13
- package/dist/report/work.js +59 -0
- package/dist/schema.js +16 -1
- package/dist/trends.js +58 -0
- package/dist/work/join.js +429 -0
- package/dist/work/model.js +145 -0
- package/dist/work/query.js +59 -0
- package/dist/work/sb.js +131 -0
- package/dist/work/track.js +323 -0
- package/docs/design.md +15 -0
- package/docs/schema.md +8 -2
- package/package.json +5 -2
- package/scripts/change-impact.mjs +18 -0
- package/scripts/package-errors.mjs +10 -0
- package/scripts/query-lib.mjs +36 -0
- package/scripts/skill-days.mjs +9 -0
- package/skills/analyzing-evals/SKILL.md +23 -0
- package/src/aggregate.ts +14 -2
- package/src/build.ts +13 -4
- package/src/cli.ts +2 -2
- package/src/coverage.ts +8 -1
- package/src/extract/run.ts +1 -1
- package/src/extract/session.ts +36 -2
- package/src/findings.ts +52 -0
- package/src/index.ts +14 -9
- package/src/meta.ts +45 -1
- package/src/model.ts +40 -15
- package/src/ops.ts +50 -22
- package/src/paths.ts +7 -0
- package/src/query.ts +32 -13
- package/src/ranges.ts +15 -0
- package/src/render.ts +15 -5
- package/src/report/concepts.ts +30 -1
- package/src/report/findings.ts +19 -1
- package/src/report/sections.ts +9 -9
- package/src/report/strip.ts +40 -0
- package/src/report/style.ts +14 -1
- package/src/report/timeline.ts +6 -22
- package/src/report/week.ts +21 -17
- package/src/report/work.ts +87 -0
- package/src/schema.ts +16 -1
- package/src/trends.ts +61 -0
- package/src/work/join.ts +476 -0
- package/src/work/model.ts +179 -0
- package/src/work/query.ts +53 -0
- package/src/work/sb.ts +158 -0
- package/src/work/track.ts +397 -0
package/docs/design.md
CHANGED
|
@@ -93,6 +93,21 @@ The renderer makes the following editorial choices from the model, without consu
|
|
|
93
93
|
- The workload chart covers the last seven complete UTC dates in the report period (or fewer if the filter starts later), not seven nonempty days. Each marker means at least one change that day. Session and tool totals in the other sections still cover the selected report period.
|
|
94
94
|
- Each detail uses the model’s actual window and session counts. Dates with records may exceed seven in a seven-day window that starts mid-day. The ruler shows the last extract only when it falls inside the after window, and its segments are not to scale.
|
|
95
95
|
|
|
96
|
+
### Date ranges and findings (0.3.0)
|
|
97
|
+
|
|
98
|
+
The 30-day page opens first; the other pages cover 14 days, 90 days or all indexed dates.
|
|
99
|
+
The last day is the UTC date of extraction, even when the extract is old, so a stale index does not become an apparently quiet month.
|
|
100
|
+
The chart now covers the selected period including the partial last day.
|
|
101
|
+
The report reads the index and checks file coverage once, then reuses the same change comparisons in each narrower period.
|
|
102
|
+
The set of currently offered skills is the reference list; “never loaded” means no loads in the selected dates and project, not that the skill has never been used.
|
|
103
|
+
Coverage counts files modified in the chosen dates and separately shows the cleanup gate across all dates and projects.
|
|
104
|
+
|
|
105
|
+
`findings` uses the timeline’s headline, trust line, selection and verdicts, without copying the text of a commit or manual note.
|
|
106
|
+
For error trends it compares the two seven-day periods immediately before the extraction date, excluding the partial day, only if both weeks fit inside the selection and the index extends to the first date.
|
|
107
|
+
It counts tool errors over calls per package and job endings marked `error` over all recorded endings; both weeks need at least 20 observations and a rise of at least five percentage points.
|
|
108
|
+
If several packages qualify, the largest rise wins, then the larger recent call count, then the package name.
|
|
109
|
+
No flag means no rise met that rule, not proof that nothing went wrong.
|
|
110
|
+
|
|
96
111
|
### Storage choices
|
|
97
112
|
|
|
98
113
|
JSON lines and JSON files, no database: the index is rebuilt from per-session summaries in about a second, and the reader needs no service (research §4: everything reduces to files plus one static page).
|
package/docs/schema.md
CHANGED
|
@@ -16,7 +16,7 @@ The envelope is shaped so a replay to an OTLP backend needs no renaming.
|
|
|
16
16
|
| `trace_id` | 32 hex | One trace per user prompt: everything from one prompt to the next. Stable across re-extraction. |
|
|
17
17
|
| `span_id` | 16 hex | Stable id derived from the session id and the entry or tool call id. |
|
|
18
18
|
| `source` | `"backfill"` \| `"live"` | Which reader wrote it. |
|
|
19
|
-
| `attrs` | object | Attributes. Strings must look like names (letters, digits, `_@./:+#=\|-`, at most 160 characters); anything else is stored as `redacted`. |
|
|
19
|
+
| `attrs` | object | Attributes. Strings must look like names (letters, digits, `_@./:+#=\|-`, at most 160 characters); anything else is stored as `redacted`. The one exception is `pi.item.title`: a todo subject, cut to one line of at most 80 characters. |
|
|
20
20
|
|
|
21
21
|
Every record carries `session.id` (the pi session id from the session header) and `pi.project` (a short project key: the repository name for `~/projects/<repo>/…` and for Herdr worktrees, else the first path segment).
|
|
22
22
|
|
|
@@ -34,6 +34,12 @@ Every record carries `session.id` (the pi session id from the session header) an
|
|
|
34
34
|
| `pi.compaction` | event | A compaction entry in the session. |
|
|
35
35
|
| `pi.tools.snapshot` | event | Live, once per session at the first prompt: `pi.tools`, a sorted list of `tool=owner@version`. |
|
|
36
36
|
| `pi.skills.available` | event | Live, once per session: `pi.skills`, the names of the skills pi offered. |
|
|
37
|
+
| `pi.workitem` | span | One per todo task (written to `index/workitems.jsonl` on every build). `ts` = the first switch to `in_progress` (else creation), `end_ts` = completed or deleted, `duration_ms` = time in progress. `pi.item.key` (todo `uid`, else `<origin session>#<id>` for an import, else `<session id>#<id>`, with `.2`, `.3` when a `clear` reuses an id and `@<entry8>` for a task only on an abandoned `/tree` branch), `pi.item.title`, `pi.item.owner`, `pi.item.level` (`top` \| `nested` for a subagent's own list), `pi.item.status`, `pi.item.created`, `pi.item.close_kind` (`review_done` \| `landed` \| `wrap` \| `evidence` \| `unproven` \| `deleted` \| `open`), `pi.item.thread` (`T<n>`), `pi.item.evidence_n`, `pi.item.blocked_by_n`, `pi.usage.cost_usd` (main cost in the window, each reply split evenly among the items in progress at that moment), `pi.item.child_cost_usd` (exact cost of the joined subagent sessions), `pi.item.children` (their names), `pi.item.lines_changed` (git, from the previous item's last evidence commit in the same repository), `pi.item.sessions` (when a uid or import carried it across sessions). A `nested` item's cost is part of its subagent session, which the parent item already counts in `pi.item.child_cost_usd`: summing across levels counts it twice. A task first seen already completed or deleted (carried in by a list switch or an import) gets no record in that session. |
|
|
38
|
+
| `pi.stall` | span | A main idle of two minutes or more inside an item's window. `pi.item.key`, `pi.stall.kind` by what woke the main (`human` \| `peer` \| `child` \| `timer` \| `ci` \| `device`), `pi.stall.on` (a subagent name, a peer session's first 13 characters, or from the sb ledger `W<n>`, `L<n>`, `T<n>`), `pi.stall.via` (`idle` \| `ask` for a question tool held open). `duration_ms` is the part inside the item's window. |
|
|
39
|
+
|
|
40
|
+
### Work items
|
|
41
|
+
|
|
42
|
+
Back-fill rebuilds each session's items from its `todo/v1` snapshots, diffed along the entry tree. When producers add them, it reads todo `uid`, `origin.session` and evidence `ref` (`child:<id>` joins a subagent), `subagent` `details.item`, `boss_pair` `item`, the sb thread fields `item` and `closed`, and the sb ledger (`~/.pi/agent/straw-boss/ledger/*.jsonl`); without them it joins by names: a subagent whose name is the task owner, a reviewer `<prefix>-review*`, the sb thread whose worker is the owner, and a car whose coordinator is the session (ticket ids in the title must match). Close kind takes the first that holds: the linked thread's `done` within five minutes of the close, a car landed in the window, a successful `boss_wrap` around the close, evidence rows, else `unproven`.
|
|
37
43
|
|
|
38
44
|
### Process detectors
|
|
39
45
|
|
|
@@ -54,7 +60,7 @@ Sessions that started before 2026-11-23T10:51:07Z (the anchorloop 3.0.0 pin) get
|
|
|
54
60
|
{ "session_id": "01a2…", "evaluation_name": "anchor_before_first_edit", "label": "fail", "at": "2026-12-01T09:00:00Z", "note": "optional" }
|
|
55
61
|
```
|
|
56
62
|
|
|
57
|
-
The report joins these with `index/session-evals.json` (the code labels per session) and shows how often they agree.
|
|
63
|
+
`label` is `pass`, `fail`, or `unclear` (the reader could not tell). The report joins these with `index/session-evals.json` (the code labels per session) and shows how often they agree; `unclear` labels are left out of the agreement rate and counted on their own (「看不出來 N」).
|
|
58
64
|
|
|
59
65
|
## Change timeline
|
|
60
66
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-evals",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"src",
|
|
28
28
|
"dist",
|
|
29
29
|
"docs",
|
|
30
|
+
"scripts",
|
|
31
|
+
"skills",
|
|
30
32
|
"README.md",
|
|
31
33
|
"CHANGELOG.md",
|
|
32
34
|
"LICENSE"
|
|
@@ -34,7 +36,8 @@
|
|
|
34
36
|
"pi": {
|
|
35
37
|
"extensions": [
|
|
36
38
|
"./src/index.ts"
|
|
37
|
-
]
|
|
39
|
+
],
|
|
40
|
+
"skills": ["./skills"]
|
|
38
41
|
},
|
|
39
42
|
"scripts": {
|
|
40
43
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { QueryError, report, run, safeName } from './query-lib.mjs';
|
|
2
|
+
|
|
3
|
+
const usage = 'node change-impact.mjs UTC_TIMESTAMP_OR_SHA [PACKAGE_OR_KIND]';
|
|
4
|
+
run(usage, args => {
|
|
5
|
+
if (args.length > 2) throw new QueryError(usage);
|
|
6
|
+
const [id, which] = args, m = report();
|
|
7
|
+
const hits = m.changes.filter(c => (c.at === id || c.sha === id) && (!which || c.package === which || c.kind === which));
|
|
8
|
+
if (hits.length !== 1) throw new QueryError(hits.length ? 'Multiple entries match; specify a package or change kind.' : 'No such change in the saved report.');
|
|
9
|
+
const { at, impact: i } = hits[0];
|
|
10
|
+
const header = `${at}; extract ${m.freshness.lastExtract ?? 'never'}; ${m.window.project ? safeName(m.window.project) : 'all projects'}`;
|
|
11
|
+
if (!i) return [header, 'No earlier records.'];
|
|
12
|
+
const rows = [header, `${i.window.days} days each side; sessions ${i.before.sessions} → ${i.after.sessions}`, `Too few sessions: ${i.smallSample}; incomplete window: ${i.incomplete}; other changes: ${i.confounded}. A difference does not prove cause.`];
|
|
13
|
+
for (const key of ['tool_error_rate', 'package_error_rate', 'ask_cancel_rate', 'cost_per_session', 'skill_loads_per_session', 'notices_per_session', 'anchor_before_first_edit', 'check_after_last_edit', 'todo_evidence']) {
|
|
14
|
+
const format = r => !r || r.value == null ? 'n/a (n=0)' : `${r.value.toFixed(4)} (n=${r.n})`;
|
|
15
|
+
rows.push(`${key}: ${format(i.before[key])} → ${format(i.after[key])}`);
|
|
16
|
+
}
|
|
17
|
+
return rows;
|
|
18
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { daily, packageCounts, QueryError, run } from './query-lib.mjs';
|
|
2
|
+
|
|
3
|
+
const usage = 'node package-errors.mjs PACKAGE [PROJECT]';
|
|
4
|
+
run(usage, args => {
|
|
5
|
+
if (args.length > 2) throw new QueryError(usage);
|
|
6
|
+
const [pkg, project] = args, { rows, index, header } = daily(project);
|
|
7
|
+
const counts = rows.map(({ day, agg }) => ({ day, count: packageCounts(index, agg).get(pkg) }));
|
|
8
|
+
if (!counts.some(x => x.count)) throw new QueryError('No calls for this package in the selected days and project.');
|
|
9
|
+
return [header, `${pkg}: tool errors/calls`, ...counts.map(({ day, count }) => `${day} ${count?.errors ?? 0}/${count?.calls ?? 0} ${count?.calls ? (100 * count.errors / count.calls).toFixed(1) + '%' : 'n/a'}`)];
|
|
10
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
// Node strips types in checkouts but forbids it under node_modules. npm ships dist there.
|
|
4
|
+
const installed = new URL(import.meta.url).pathname.split('/').includes('node_modules');
|
|
5
|
+
const load = name => import(installed ? `../dist/${name}.js` : `../src/${name}.ts`);
|
|
6
|
+
const [{ layout }, { loadIndex }, { recentDays, packageCounts }, { safeName }] = await Promise.all(
|
|
7
|
+
['paths', 'build', 'trends', 'schema'].map(load),
|
|
8
|
+
);
|
|
9
|
+
export { packageCounts, safeName };
|
|
10
|
+
|
|
11
|
+
export function run(usage, fn) {
|
|
12
|
+
try {
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
if (!args.length || args.some(x => !x || safeName(x) !== x)) throw new Error(usage);
|
|
15
|
+
const text = fn(args).join('\n') + '\n';
|
|
16
|
+
if (Buffer.byteLength(text) > 2000) throw new Error('Result exceeds the output limit.');
|
|
17
|
+
process.stdout.write(text);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
// Never echo unknown arguments, local paths or JSON parse excerpts.
|
|
20
|
+
console.error(error instanceof QueryError ? error.message : `Cannot read query. ${usage}`);
|
|
21
|
+
process.exitCode = 1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class QueryError extends Error {}
|
|
25
|
+
export function daily(project) {
|
|
26
|
+
const index = loadIndex(layout());
|
|
27
|
+
if (!index) throw new QueryError('No index. Run /evals extract first.');
|
|
28
|
+
return { rows: recentDays(index, project), index, header: `Extract ${index.lastExtract ?? 'never'}; complete UTC dates${project ? `; project ${project}` : '; all projects'}` };
|
|
29
|
+
}
|
|
30
|
+
export function report() {
|
|
31
|
+
const range = process.env.PI_EVALS_REPORT_RANGE ?? '30';
|
|
32
|
+
const files = new Map([['14', 'model-14d.json'], ['30', 'model.json'], ['90', 'model-90d.json'], ['all', 'model-all.json'], ['custom', 'model-custom.json']]);
|
|
33
|
+
if (!files.has(range)) throw new QueryError('Choose PI_EVALS_REPORT_RANGE=14, 30, 90, all or custom.');
|
|
34
|
+
try { return JSON.parse(readFileSync(join(layout().reports, files.get(range)), 'utf8')); }
|
|
35
|
+
catch { throw new QueryError('No readable report model. Run /evals report first.'); }
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { daily, QueryError, run } from './query-lib.mjs';
|
|
2
|
+
|
|
3
|
+
const usage = 'node skill-days.mjs SKILL [PROJECT]';
|
|
4
|
+
run(usage, args => {
|
|
5
|
+
if (args.length > 2) throw new QueryError(usage);
|
|
6
|
+
const [skill, project] = args, { rows, index, header } = daily(project);
|
|
7
|
+
if (!index.offeredSkills.includes(skill) && !Object.values(index.days).some(projects => Object.values(projects).some(a => Object.hasOwn(a.skillSessions, skill)))) throw new QueryError('Skill not found in index.');
|
|
8
|
+
return [header, `${skill}: sessions that loaded the skill, by session start date`, ...rows.map(({ day, agg }) => `${day} ${agg && Object.hasOwn(agg.skillSessions, skill) ? agg.skillSessions[skill] : 0}`)];
|
|
9
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: analyzing-evals
|
|
3
|
+
description: Use when the user asks how their agents, skills or packages are doing, what a setup change did, or how to read the pi-evals report.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Analyze agent activity
|
|
7
|
+
|
|
8
|
+
1. Call `evals_query` with `view: "findings"` first. Check the dates and last extraction; default is the latest 30 UTC dates in the index. Use `since` or `project` when the question specifies a narrower scope.
|
|
9
|
+
2. Follow **one** pointer that answers the question. For a weekly change in tool errors use `packages`; for a rule about editing use `process`; for what a piece of work cost, where it closed, where it stalled, or whether one way of working is cheaper, use `items`. Keep the same filters. Stop when the numbers answer the question.
|
|
10
|
+
3. If one detail is still missing, run one script below. Set `SCRIPTS` to the absolute path on the `Scripts:` line or in `details.scriptsDir`. For a default npm install, the fallback is `SCRIPTS="$HOME/.pi/agent/npm/node_modules/pi-evals/scripts"`. Check `test -f "$SCRIPTS/query-lib.mjs"` before running a query; if it fails, stop rather than guessing another path. Use exact identifiers returned by the view; none of these commands reads a transcript.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
node "$SCRIPTS/change-impact.mjs" UTC_TIMESTAMP_OR_SHA [PACKAGE_OR_KIND]
|
|
14
|
+
node "$SCRIPTS/skill-days.mjs" SKILL [PROJECT]
|
|
15
|
+
node "$SCRIPTS/package-errors.mjs" PACKAGE [PROJECT]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The first reads the saved `reports/model.json`: check its extract time and project before using the comparison. For a different saved page, prefix the command with `PI_EVALS_REPORT_RANGE=14`, `90`, `all` or `custom`. If the file is missing or out of date, say so; `/evals report` rebuilds the preset pages.
|
|
19
|
+
The other two read the last 14 complete UTC dates in the index. Skill sessions count on their start date; package errors count on the date of the call. Neither script treats zero calls as a 0% error rate.
|
|
20
|
+
|
|
21
|
+
Reading `items`: an item is one todo task from `in_progress` to done or deleted. Subagent cost is exact; main cost is an estimate, split evenly among items in progress at the same moment, so say which part you quote. Compare only like with like (the view already separates work handed to subagents from work the main did itself); when it says "too few items to tell", say that in those words rather than reading the medians. A stall says what woke the main (`human`, `peer`, `child`, `timer`, `ci`, `device`), not why it waited; `on` names the subagent, peer session or sb wait (`W12`, `L340`, `T5`) when known.
|
|
22
|
+
|
|
23
|
+
Lead with what rose, fell or held steady, and give the counts behind the rates. Say “too early to tell” when a side is short or too small; when other changes landed nearby, say “we cannot tell which change mattered.” Even a clear difference is not proof of cause. More sessions or skill loads measure activity, not better work.
|
package/src/aggregate.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Additive per-day aggregates. A session summary holds one per UTC day; the index sums them by day and project. */
|
|
2
2
|
import type { DetectorName, NoticeKind } from "./detectors.ts";
|
|
3
3
|
import type { Label } from "./schema.ts";
|
|
4
|
+
import type { SessionWork } from "./work/track.ts";
|
|
4
5
|
|
|
5
6
|
export interface ToolAgg {
|
|
6
7
|
calls: number;
|
|
@@ -146,8 +147,16 @@ export interface SessionSummary {
|
|
|
146
147
|
logicalId?: string;
|
|
147
148
|
/** Parent session id, when the brief's artifact path or a dispatch ledger names it. */
|
|
148
149
|
parentId?: string;
|
|
149
|
-
/** Logical ids of the subagents this session launched, with the role and model it asked for. */
|
|
150
|
-
spawned: { id: string; role: string; model: string }[];
|
|
150
|
+
/** Logical ids of the subagents this session launched, with the role and model it asked for, and its name. */
|
|
151
|
+
spawned: { id: string; role: string; model: string; name?: string }[];
|
|
152
|
+
/** The last model the session used. */
|
|
153
|
+
model?: string;
|
|
154
|
+
/** A subagent's own name, from its brief path. */
|
|
155
|
+
childName?: string;
|
|
156
|
+
/** Working directory, when it is name-shaped: where to look for evidence commits. Internal; never in a record. */
|
|
157
|
+
cwd?: string;
|
|
158
|
+
/** Work items and what the join needs about them (todo transitions, cost, idle gaps, launches). */
|
|
159
|
+
work?: SessionWork;
|
|
151
160
|
cost: number;
|
|
152
161
|
tokens: number;
|
|
153
162
|
toolCalls: number;
|
|
@@ -164,6 +173,9 @@ export interface SessionSummary {
|
|
|
164
173
|
* version split read, so a change at 16:00 splits a day's sessions at 16:00 rather than at midnight.
|
|
165
174
|
*/
|
|
166
175
|
export interface SessionRow {
|
|
176
|
+
/** Used for the date/project-scoped labels join. Older indices lack these two fields. */
|
|
177
|
+
id?: string;
|
|
178
|
+
linked?: boolean;
|
|
167
179
|
/** Start, ISO. */
|
|
168
180
|
s: string;
|
|
169
181
|
p: string;
|
package/src/build.ts
CHANGED
|
@@ -10,8 +10,9 @@ import { addLabel, bucketOf, bump, type DayAgg, emptyDay, mergeDay, rowOf, type
|
|
|
10
10
|
import { buildChanges, type Change, versionAt, writeChanges } from "./changes.ts";
|
|
11
11
|
import type { Checkpoint } from "./extract/run.ts";
|
|
12
12
|
import { dayOf, type Layout, type Settings } from "./paths.ts";
|
|
13
|
-
import { type EvalRecord, NAMES } from "./schema.ts";
|
|
13
|
+
import { type EvalRecord, NAMES, traceId } from "./schema.ts";
|
|
14
14
|
import { liveFiles, readRecords } from "./store.ts";
|
|
15
|
+
import { ANCHORLOOP, joinWork, Lines, sbDirOf, writeWork } from "./work/join.ts";
|
|
15
16
|
|
|
16
17
|
export interface DaysIndex {
|
|
17
18
|
v: 1;
|
|
@@ -28,7 +29,7 @@ export interface DaysIndex {
|
|
|
28
29
|
range: { start: string; end: string };
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export const ANCHORLOOP_PACKAGES =
|
|
32
|
+
export const ANCHORLOOP_PACKAGES = ANCHORLOOP;
|
|
32
33
|
|
|
33
34
|
function atomicWrite(file: string, text: string) {
|
|
34
35
|
mkdirSync(dirname(file), { recursive: true });
|
|
@@ -200,7 +201,8 @@ export function buildIndex(options: { layout: Layout; settings: Settings; checkp
|
|
|
200
201
|
}
|
|
201
202
|
if (Object.keys(labels).length) sessionEvals[s.sessionId] = labels;
|
|
202
203
|
add(s.project, days);
|
|
203
|
-
rows.push(rowOf(s.start, s.project, s.kind === "subagent", s.cost, days, s.evals))
|
|
204
|
+
rows.push({ ...rowOf(s.start, s.project, s.kind === "subagent", s.cost, days, s.evals), id: traceId(s.sessionId, "labels"),
|
|
205
|
+
linked: s.kind === "subagent" ? Boolean(s.parentId || (s.logicalId && links.has(s.logicalId))) : undefined });
|
|
204
206
|
}
|
|
205
207
|
let liveOnly = 0;
|
|
206
208
|
for (const [id, records] of bySession) {
|
|
@@ -208,7 +210,7 @@ export function buildIndex(options: { layout: Layout; settings: Settings; checkp
|
|
|
208
210
|
liveOnly += 1;
|
|
209
211
|
const summary = liveSummary(records);
|
|
210
212
|
add(summary.project, summary.days);
|
|
211
|
-
rows.push(rowOf(summary.start, summary.project, records.some((r) => r.name === NAMES.session && r.attrs["pi.session.kind"] === "subagent"), 0, summary.days));
|
|
213
|
+
rows.push({ ...rowOf(summary.start, summary.project, records.some((r) => r.name === NAMES.session && r.attrs["pi.session.kind"] === "subagent"), 0, summary.days), id: traceId(id, "labels"), linked: false });
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
const owners: DaysIndex["owners"] = {};
|
|
@@ -244,6 +246,13 @@ export function buildIndex(options: { layout: Layout; settings: Settings; checkp
|
|
|
244
246
|
atomicWrite(layout.days, JSON.stringify(index));
|
|
245
247
|
atomicWrite(layout.sessionRows, JSON.stringify(rows));
|
|
246
248
|
atomicWrite(layout.sessionEvals, JSON.stringify(sessionEvals));
|
|
249
|
+
const now = options.now?.() ?? new Date();
|
|
250
|
+
try {
|
|
251
|
+
const work = joinWork({ summaries, changes, sbDir: sbDirOf(options.agentDir), repos: options.settings.changeRepos, lines: new Lines(layout.lines, now), now });
|
|
252
|
+
writeWork(layout, work);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
errors.push(`work items: ${error instanceof Error ? error.message : String(error)}`);
|
|
255
|
+
}
|
|
247
256
|
return { index, changes, errors };
|
|
248
257
|
}
|
|
249
258
|
|
package/src/cli.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { query, type View, VIEWS } from "./query.ts";
|
|
|
5
5
|
|
|
6
6
|
const USAGE = `usage:
|
|
7
7
|
pi-evals extract [--root <dir>]... [--workers <n>] [--json]
|
|
8
|
-
pi-evals report [--out <dir>] [--since YYYY-MM-DD] [--project <key>] [--lang zh|en]
|
|
8
|
+
pi-evals report [--out <dir>] [--since YYYY-MM-DD | --days N] [--project <key>] [--lang zh|en]
|
|
9
9
|
pi-evals status
|
|
10
10
|
pi-evals query <${VIEWS.join("|")}> [--since YYYY-MM-DD] [--project <key>]
|
|
11
11
|
pi-evals mark <note>`;
|
|
@@ -49,7 +49,7 @@ async function main(argv: string[]): Promise<number> {
|
|
|
49
49
|
}
|
|
50
50
|
if (cmd === "report") {
|
|
51
51
|
const lang = flag(args, "--lang") === "en" ? "en" : "zh";
|
|
52
|
-
const out = runReport({ outDir: flag(args, "--out"), filter: { since: flag(args, "--since"), project: flag(args, "--project") }, lang });
|
|
52
|
+
const out = runReport({ outDir: flag(args, "--out"), filter: { since: flag(args, "--since"), days: args.includes("--days") ? Number(flag(args, "--days")) : undefined, project: flag(args, "--project") }, lang });
|
|
53
53
|
if (!out) {
|
|
54
54
|
console.error("nothing extracted yet: run pi-evals extract");
|
|
55
55
|
return 1;
|
package/src/coverage.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Checkpoint } from "./extract/run.ts";
|
|
|
3
3
|
import { listSessionFiles } from "./extract/run.ts";
|
|
4
4
|
|
|
5
5
|
export interface Coverage {
|
|
6
|
+
/** Files whose modification date falls in the selected report dates (all projects). */
|
|
7
|
+
inRange?: { files: number; indexed: number };
|
|
6
8
|
cutDays: number;
|
|
7
9
|
cutoff: string;
|
|
8
10
|
old: { files: number; bytes: number };
|
|
@@ -13,7 +15,7 @@ export interface Coverage {
|
|
|
13
15
|
retainedGone: number;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
export function coverage(roots: string[], checkpoint: Checkpoint, cutDays: number, now = Date.now()): Coverage {
|
|
18
|
+
export function coverage(roots: string[], checkpoint: Checkpoint, cutDays: number, now = Date.now(), activity?: Map<string, { files: number; indexed: number }>): Coverage {
|
|
17
19
|
const cutoff = now - cutDays * 86_400_000;
|
|
18
20
|
const files = listSessionFiles(roots);
|
|
19
21
|
const result: Coverage = {
|
|
@@ -32,6 +34,11 @@ export function coverage(roots: string[], checkpoint: Checkpoint, cutDays: numbe
|
|
|
32
34
|
const known = checkpoint.files[f.path];
|
|
33
35
|
const fresh = !!known && known.size === f.size && known.mtimeMs === f.mtimeMs;
|
|
34
36
|
if (fresh) result.all.indexedFiles += 1;
|
|
37
|
+
if (activity) {
|
|
38
|
+
const day = new Date(f.mtimeMs).toISOString().slice(0, 10), row = activity.get(day) ?? { files: 0, indexed: 0 };
|
|
39
|
+
row.files++; if (fresh) row.indexed++;
|
|
40
|
+
activity.set(day, row);
|
|
41
|
+
}
|
|
35
42
|
if (f.mtimeMs >= cutoff) continue;
|
|
36
43
|
result.old.files += 1;
|
|
37
44
|
result.old.bytes += f.size;
|
package/src/extract/run.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface FileEntry {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** Bump when extraction changes what it derives; a checkpoint from another version re-reads every file. */
|
|
21
|
-
export const EXTRACTOR_VERSION =
|
|
21
|
+
export const EXTRACTOR_VERSION = 4;
|
|
22
22
|
|
|
23
23
|
export interface Checkpoint {
|
|
24
24
|
v: 1;
|
package/src/extract/session.ts
CHANGED
|
@@ -10,10 +10,15 @@ import { dayOf } from "../paths.ts";
|
|
|
10
10
|
import { projectKey } from "../project.ts";
|
|
11
11
|
import { type Attrs, type EvalRecord, NAMES, record, safeName, type SkillTrigger, spanId, traceId } from "../schema.ts";
|
|
12
12
|
import { skillFromPath, skillsFromBlocks, skillsFromCatalog, skillsFromCommand } from "../skills.ts";
|
|
13
|
+
import { WorkTracker } from "../work/track.ts";
|
|
13
14
|
|
|
14
15
|
const UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
15
16
|
const CHILD_FILE = new RegExp(`_(${UUID})-[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{4}\\.jsonl$`);
|
|
16
17
|
const BRIEF_PARENT = new RegExp(`/artifacts/(${UUID})/context/`);
|
|
18
|
+
/** The subagent name in a brief path `…/context/<name>-<YYYY-MM-DDTHH-MM-SS>.md`. */
|
|
19
|
+
const BRIEF_NAME = new RegExp(`/artifacts/${UUID}/context/([A-Za-z0-9_.-]+?)-\\d{4}-\\d{2}-\\d{2}T[0-9-]+\\.md`);
|
|
20
|
+
/** Question tools: the main waits on a person while one runs. */
|
|
21
|
+
const HUMAN_WAIT = new Set(["ask_user_question", "ask_user", "secret_drop"]);
|
|
17
22
|
const ASK_TOOLS = new Set(["ask_user_question", "ask_user"]);
|
|
18
23
|
|
|
19
24
|
interface PendingCall {
|
|
@@ -63,6 +68,9 @@ export class SessionReader {
|
|
|
63
68
|
private notices: SessionSummary["notices"] = {};
|
|
64
69
|
private firstUser = true;
|
|
65
70
|
private model?: string;
|
|
71
|
+
private childName?: string;
|
|
72
|
+
private cwd?: string;
|
|
73
|
+
private work = new WorkTracker();
|
|
66
74
|
readonly logicalId?: string;
|
|
67
75
|
private readonly home: string;
|
|
68
76
|
private readonly emit: (r: EvalRecord) => void;
|
|
@@ -101,6 +109,7 @@ export class SessionReader {
|
|
|
101
109
|
if (type === "session") return this.header(entry);
|
|
102
110
|
if (!this.start && ts) this.start = ts;
|
|
103
111
|
const kind = this.tracker.feed(entry);
|
|
112
|
+
this.work.entry(entry, ts);
|
|
104
113
|
if (type === "model_change") {
|
|
105
114
|
this.model = safeName(`${str(entry.provider) ?? "?"}/${str(entry.modelId) ?? "?"}`);
|
|
106
115
|
} else if (type === "compaction") {
|
|
@@ -122,6 +131,8 @@ export class SessionReader {
|
|
|
122
131
|
this.sessionId = safeName(str(entry.id) ?? "");
|
|
123
132
|
this.start = str(entry.timestamp) ?? this.start;
|
|
124
133
|
this.project = safeName(projectKey(str(entry.cwd), this.home));
|
|
134
|
+
const cwd = str(entry.cwd);
|
|
135
|
+
if (cwd && safeName(cwd) === cwd) this.cwd = cwd;
|
|
125
136
|
}
|
|
126
137
|
|
|
127
138
|
private system(message: Obj) {
|
|
@@ -134,8 +145,11 @@ export class SessionReader {
|
|
|
134
145
|
const text = textOf(message.content);
|
|
135
146
|
if (this.firstUser) {
|
|
136
147
|
this.firstUser = false;
|
|
137
|
-
const
|
|
148
|
+
const head = text.slice(0, 2000);
|
|
149
|
+
const parent = head.match(BRIEF_PARENT)?.[1];
|
|
138
150
|
if (parent && this.logicalId) this.parentId = parent;
|
|
151
|
+
const name = head.match(BRIEF_NAME)?.[1];
|
|
152
|
+
if (name && this.logicalId) this.childName = safeName(name);
|
|
139
153
|
}
|
|
140
154
|
const anchor = str(entry.id) ?? ts;
|
|
141
155
|
this.closeTrace();
|
|
@@ -188,6 +202,7 @@ export class SessionReader {
|
|
|
188
202
|
day.usage.calls += 1;
|
|
189
203
|
bump(day.models, model);
|
|
190
204
|
this.cost += u.cost;
|
|
205
|
+
this.work.assistant(ts, u.cost, message.stopReason);
|
|
191
206
|
this.tokens += num(usage.totalTokens) || u.input + u.output + u.cacheRead + u.cacheWrite;
|
|
192
207
|
if (this.traceUsage) {
|
|
193
208
|
this.traceUsage.input += u.input;
|
|
@@ -257,8 +272,20 @@ export class SessionReader {
|
|
|
257
272
|
attrs["gen_ai.request.model"] = model;
|
|
258
273
|
attrs["pi.subagent.logical_id"] = child;
|
|
259
274
|
bump(day.subagents, `${role}|${model}`);
|
|
260
|
-
if (child)
|
|
275
|
+
if (child) {
|
|
276
|
+
const name = str(details.name) ? safeName(details.name) : undefined;
|
|
277
|
+
const item = str(details.item) ? safeName(details.item) : undefined;
|
|
278
|
+
this.spawned.push({ id: child, role, model, name });
|
|
279
|
+
this.work.launch({ id: child, name, role, model, item, at: ts });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (!isError && call && HUMAN_WAIT.has(name)) this.work.wait(call.ts, ts, "human");
|
|
283
|
+
if (!isError && name === "subagent_resume" && str(details.name)) this.work.child(ts, String(details.name), "resume");
|
|
284
|
+
if (!isError && name === "boss_pair" && str(details.thread)) {
|
|
285
|
+
const opt = (v: unknown) => (str(v) ? safeName(v) : undefined);
|
|
286
|
+
this.work.pair({ thread: safeName(details.thread), worker: opt(details.worker), reviewer: opt(details.reviewer), item: opt(details.item), at: ts });
|
|
261
287
|
}
|
|
288
|
+
if (!isError && name === "boss_wrap") this.work.wrap(ts, details.wrapped === true);
|
|
262
289
|
if (call?.monitor && !isError) {
|
|
263
290
|
const monitorId = textOf(message.content).concat(" ", str(details.summary) ?? "").match(/Monitor #(\d+)/)?.[1];
|
|
264
291
|
day.monitors.started += 1;
|
|
@@ -300,6 +327,8 @@ export class SessionReader {
|
|
|
300
327
|
const type = entry.customType;
|
|
301
328
|
if (type === "pi-herdr-agents:declared-skills") {
|
|
302
329
|
for (const skill of skillsFromBlocks(textOf(entry.content))) this.skillLoad(skill, "declared", ts);
|
|
330
|
+
} else if (type === "subagent_result" && str(obj(entry.details).name)) {
|
|
331
|
+
this.work.child(ts, String(obj(entry.details).name), "result");
|
|
303
332
|
} else if (kind) {
|
|
304
333
|
bump(this.notices as Record<string, number>, kind);
|
|
305
334
|
bump(this.day(ts).notices, kind);
|
|
@@ -417,6 +446,9 @@ export class SessionReader {
|
|
|
417
446
|
kind: this.logicalId ? "subagent" : "interactive",
|
|
418
447
|
logicalId: this.logicalId,
|
|
419
448
|
parentId: this.parentId,
|
|
449
|
+
model: this.model,
|
|
450
|
+
childName: this.childName,
|
|
451
|
+
cwd: this.cwd,
|
|
420
452
|
spawned: this.spawned,
|
|
421
453
|
cost: this.cost,
|
|
422
454
|
tokens: this.tokens,
|
|
@@ -425,6 +457,8 @@ export class SessionReader {
|
|
|
425
457
|
notices: this.notices,
|
|
426
458
|
days: this.days,
|
|
427
459
|
};
|
|
460
|
+
const work = this.work.finish(this.sessionId, !!this.logicalId);
|
|
461
|
+
if (work) summary.work = work;
|
|
428
462
|
return { summary, catalog: this.catalog };
|
|
429
463
|
}
|
|
430
464
|
}
|
package/src/findings.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import type { ReportModel } from "./model.ts";
|
|
3
|
+
import { overview, readings, value, verdict } from "./report/findings.ts";
|
|
4
|
+
import { words } from "./report/format.ts";
|
|
5
|
+
import { safeName } from "./schema.ts";
|
|
6
|
+
import { trendPair } from "./trends.ts";
|
|
7
|
+
import { itemsFinding } from "./work/query.ts";
|
|
8
|
+
|
|
9
|
+
export const scriptsDir = fileURLToPath(new URL("../scripts", import.meta.url));
|
|
10
|
+
|
|
11
|
+
/** Shorten only identifiers, never a verdict or its drill-down pointer. */
|
|
12
|
+
function name(s: string) {
|
|
13
|
+
const chars = Array.from(safeName(s));
|
|
14
|
+
if (Buffer.byteLength(chars.join("")) <= 72) return chars.join("");
|
|
15
|
+
while (Buffer.byteLength(chars.join("")) > 69) chars.pop();
|
|
16
|
+
return chars.join("") + "…";
|
|
17
|
+
}
|
|
18
|
+
export function findings(m: ReportModel) {
|
|
19
|
+
const { headline, trust, highlighted } = overview(m, "en"), L = words("en");
|
|
20
|
+
const lines = [
|
|
21
|
+
`${m.window.since ?? "?"}..${m.window.until ?? "?"} UTC${m.window.project ? ` · ${name(m.window.project)}` : ""} · ${m.freshness.stale ? "STALE: " : ""}last extract ${m.freshness.lastExtract ?? "never"} → coverage`,
|
|
22
|
+
`Scripts: ${scriptsDir}`, `${headline} → changes`, `${trust} → changes`,
|
|
23
|
+
];
|
|
24
|
+
const extras: { line: number; prefix: string; metric: string }[] = [];
|
|
25
|
+
for (const c of highlighted) {
|
|
26
|
+
const id = c.package ? `${name(c.package)} ${name(c.to ?? "unknown")}` : c.kind;
|
|
27
|
+
const rs = readings(c, m, "en"), r = rs.find(row => row.before?.value != null && row.after?.value != null);
|
|
28
|
+
const metric = r ? `${r.label} ${value(r, "before")} → ${value(r, "after")}; ` : "";
|
|
29
|
+
const prefix = `${c.at} ${id}: `;
|
|
30
|
+
extras.push({ line: lines.length, prefix, metric });
|
|
31
|
+
lines.push(`${prefix}${verdict(c, rs, L)} → changes`);
|
|
32
|
+
}
|
|
33
|
+
const unseen = m.skills.neverLoaded.length;
|
|
34
|
+
lines.push(`${unseen}/${m.skills.offered} offered skills never loaded in range → skills`);
|
|
35
|
+
const cov = m.coverage;
|
|
36
|
+
const gate = !cov ? "not measured" : !cov.old.files ? "no old files" : cov.notIndexed.files || cov.notIndexed.bytes
|
|
37
|
+
? `blocked: ${cov.notIndexed.files}/${cov.old.files} old files not indexed` : `all ${cov.old.files} old files indexed`;
|
|
38
|
+
lines.push(`Cleanup (all projects/dates): ${gate} → coverage`);
|
|
39
|
+
const work = itemsFinding(m.work);
|
|
40
|
+
if (work) lines.push(work);
|
|
41
|
+
const w = m.weekly;
|
|
42
|
+
if (!w) lines.push("Need two weeks in range for error trends → packages / monitors");
|
|
43
|
+
else {
|
|
44
|
+
const p = w.packages[0];
|
|
45
|
+
lines.push(`${w.start}..${w.end} UTC, earlier week vs later: ${p ? `${p.name === "unknown" ? "tools with no known package" : name(p.name)} errors/calls ${trendPair(p)}` : "no package rise flagged"} → packages`);
|
|
46
|
+
lines.push(`Same weeks: ${w.monitors ? `failed/finished jobs ${trendPair(w.monitors)}` : "no job error rise flagged"} → monitors`);
|
|
47
|
+
}
|
|
48
|
+
for (const { line, prefix, metric } of extras) {
|
|
49
|
+
if (Buffer.byteLength(lines.join("\n") + metric) <= 1499) lines[line] = prefix + metric + lines[line].slice(prefix.length);
|
|
50
|
+
}
|
|
51
|
+
return lines.join("\n");
|
|
52
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { existsSync } from "node:fs";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
8
8
|
import { Type } from "typebox";
|
|
9
|
+
import { scriptsDir } from "./findings.ts";
|
|
9
10
|
import { observe } from "./observer.ts";
|
|
10
11
|
import { context, mark, reportPath, runReport, statusText } from "./ops.ts";
|
|
11
12
|
import { query, type View, VIEWS } from "./query.ts";
|
|
@@ -22,12 +23,13 @@ export function cliPath(): { cmd: string; args: string[] } | undefined {
|
|
|
22
23
|
return found ? { cmd: process.execPath, args: [found] } : undefined;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const SUBCOMMANDS = ["status", "extract", "report", "mark"];
|
|
26
|
+
const SUBCOMMANDS = ["status", "findings", "extract", "report", "mark"];
|
|
26
27
|
|
|
27
|
-
function parseFlags(args: string[])
|
|
28
|
-
const out: { since?: string; project?: string; rest: string[] } = { rest: [] };
|
|
28
|
+
function parseFlags(args: string[]) {
|
|
29
|
+
const out: { since?: string; days?: number; project?: string; rest: string[] } = { rest: [] };
|
|
29
30
|
for (let i = 0; i < args.length; i++) {
|
|
30
31
|
if (args[i] === "--since") out.since = args[++i];
|
|
32
|
+
else if (args[i] === "--days") out.days = Number(args[++i]);
|
|
31
33
|
else if (args[i] === "--project") out.project = args[++i];
|
|
32
34
|
else out.rest.push(args[i]);
|
|
33
35
|
}
|
|
@@ -94,7 +96,7 @@ export function createEvals(options: { env?: Env; spawnExtract?: typeof spawn; n
|
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
pi.registerCommand("evals", {
|
|
97
|
-
description: "Usage and process records: /evals [status|extract|report|mark <note>]",
|
|
99
|
+
description: "Usage and process records: /evals [status|findings|extract|report|mark <note>]",
|
|
98
100
|
getArgumentCompletions: (prefix: string) => {
|
|
99
101
|
const items = SUBCOMMANDS.filter((s) => s.startsWith(prefix)).map((s) => ({ value: s, label: s }));
|
|
100
102
|
return items.length ? items : null;
|
|
@@ -104,6 +106,9 @@ export function createEvals(options: { env?: Env; spawnExtract?: typeof spawn; n
|
|
|
104
106
|
const sub = words[0] ?? "status";
|
|
105
107
|
if (sub === "status") {
|
|
106
108
|
ctx.ui.notify(statusText(env), "info");
|
|
109
|
+
} else if (sub === "findings") {
|
|
110
|
+
const flags = parseFlags(words.slice(1));
|
|
111
|
+
ctx.ui.notify(query("findings", { env, ...flags }), "info");
|
|
107
112
|
} else if (sub === "extract") {
|
|
108
113
|
if (running) {
|
|
109
114
|
ctx.ui.notify("pi-evals: an extract is already running.", "warning");
|
|
@@ -120,7 +125,7 @@ export function createEvals(options: { env?: Env; spawnExtract?: typeof spawn; n
|
|
|
120
125
|
});
|
|
121
126
|
} else if (sub === "report") {
|
|
122
127
|
const flags = parseFlags(words.slice(1));
|
|
123
|
-
const out = runReport({ env, filter:
|
|
128
|
+
const out = runReport({ env, filter: flags });
|
|
124
129
|
ctx.ui.notify(out ? `pi-evals report: ${out.html}\nmodel: ${out.json}` : "pi-evals: nothing extracted yet; run /evals extract first.", out ? "info" : "warning");
|
|
125
130
|
} else if (sub === "mark") {
|
|
126
131
|
const text = words.slice(1).join(" ").trim();
|
|
@@ -139,11 +144,11 @@ export function createEvals(options: { env?: Env; spawnExtract?: typeof spawn; n
|
|
|
139
144
|
pi.registerTool({
|
|
140
145
|
name: "evals_query",
|
|
141
146
|
label: "Evals Query",
|
|
142
|
-
description: "
|
|
143
|
-
promptSnippet: "
|
|
147
|
+
description: "Start with findings for agent activity and changes; use one detail view for counts, cost or coverage.",
|
|
148
|
+
promptSnippet: "Analyze agent activity: query findings first, then one detail view",
|
|
144
149
|
parameters: Type.Object({
|
|
145
150
|
view: Type.Unsafe<View>({ type: "string", enum: [...VIEWS], description: "Which summary" }),
|
|
146
|
-
since: Type.Optional(Type.String({ description: "YYYY-MM-DD; default
|
|
151
|
+
since: Type.Optional(Type.String({ description: "YYYY-MM-DD; default last 30 UTC dates through extraction" })),
|
|
147
152
|
project: Type.Optional(Type.String({ description: "Project key, e.g. a repo name" })),
|
|
148
153
|
}),
|
|
149
154
|
async execute(_id, params) {
|
|
@@ -151,7 +156,7 @@ export function createEvals(options: { env?: Env; spawnExtract?: typeof spawn; n
|
|
|
151
156
|
if (!VIEWS.includes(view)) throw new Error(`Unknown view "${view}". Views: ${VIEWS.join(", ")}.`);
|
|
152
157
|
if (params.since && !/^\d{4}-\d{2}-\d{2}$/.test(params.since)) throw new Error("since must be YYYY-MM-DD.");
|
|
153
158
|
const text = query(view, { since: params.since, project: params.project, env });
|
|
154
|
-
return { content: [{ type: "text", text }], details: { view, report: reportPath(env) } };
|
|
159
|
+
return { content: [{ type: "text", text }], details: { view, scriptsDir, report: reportPath(env) } };
|
|
155
160
|
},
|
|
156
161
|
});
|
|
157
162
|
};
|