neurastream 0.2.49 → 0.2.51
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/README.md +8 -5
- package/package.json +1 -1
- package/src/adapters/omp/doctor.ts +5 -1
- package/src/adapters/omp/index.ts +30 -12
- package/src/adapters/omp/sessions.ts +11 -8
- package/src/cli/dispatch.ts +1 -1
- package/src/cli/guard.ts +8 -1
- package/src/cli/metrics.ts +125 -1
- package/src/core/adapter.ts +6 -0
- package/src/core/config.ts +37 -2
- package/src/core/guards.ts +253 -48
- package/src/core/metrics.ts +2 -2
- package/src/core/owner-ui.ts +239 -8
- package/src/core/queue/lib.ts +21 -3
- package/src/core/queue-check.ts +8 -1
- package/src/core/queue-finished.ts +4 -3
- package/src/core/results.ts +408 -0
- package/templates/config.yml +5 -1
- package/templates/plan-review-brief.md +3 -5
package/src/core/owner-ui.ts
CHANGED
|
@@ -20,7 +20,8 @@ import { dismissIncident, isFindingKind, openIncidents } from "./incidents.ts";
|
|
|
20
20
|
import { byText, knowledgeManifest, readKnowledgeTopicFile, urlField, urlValue, type KnowledgeEntry } from "./knowledge.ts";
|
|
21
21
|
import { log } from "./guards.ts";
|
|
22
22
|
import { readMetricEvents } from "./metrics.ts";
|
|
23
|
-
import { activePlans, chatUnlock, dependencyOrderProblems, expandHome, stateDirPath, unlockPath, type Plan } from "./queue/lib.ts";
|
|
23
|
+
import { activePlans, chatUnlock, dependencyOrderProblems, expandHome, gitTop, stateDirPath, unlockPath, type Plan } from "./queue/lib.ts";
|
|
24
|
+
import { featuresReport, gatherTags, loadPlans, releasesReport, type FeaturesReport, type ReleaseRow, type ReleaseSideStats, type ReleasesReport } from "./results.ts";
|
|
24
25
|
import type { Tailscale } from "./tailscale.ts";
|
|
25
26
|
|
|
26
27
|
const ANSWER_MAX = 2000;
|
|
@@ -31,7 +32,7 @@ const MESSAGE_IMAGE_MAX_BYTES = 10 * 1024 * 1024;
|
|
|
31
32
|
export const OWNER_MESSAGE_KEEP_SEC = 43200;
|
|
32
33
|
const REFRESH_SEC = 20;
|
|
33
34
|
/** The page's tabs, in pill order; anything else in `?tab=` renders Now. */
|
|
34
|
-
const TABS: [string, string][] = [["now", "Now"], ["queue", "Queue"], ["agents", "Agents"], ["spend", "Spend"], ["knowledge", "Base"]];
|
|
35
|
+
const TABS: [string, string][] = [["now", "Now"], ["queue", "Queue"], ["agents", "Agents"], ["spend", "Spend"], ["knowledge", "Base"], ["results", "Results"]];
|
|
35
36
|
const TAB_IDS = TABS.map(([id]) => id);
|
|
36
37
|
// Tailscale hands out addresses from 100.64.0.0/10 (CGNAT) and its own ULA /48 for IPv6.
|
|
37
38
|
const TAILNET6 = /^fd7a:115c:a1e0:/i;
|
|
@@ -747,6 +748,8 @@ export interface PageData {
|
|
|
747
748
|
knowledge: KnowledgeEntry[] | null;
|
|
748
749
|
/** The 24 h tile numbers; null when the run source is unreadable. */
|
|
749
750
|
stats: NowStats | null;
|
|
751
|
+
/** The Results tab's ledger and release windows; null when unreadable, absent in hand-built PageData. */
|
|
752
|
+
results?: ResultsData | null;
|
|
750
753
|
/** The owner's messages newer than the keep window, newest first; null when unreadable. */
|
|
751
754
|
messages: MessageRow[] | null;
|
|
752
755
|
/** Minutes left in the guard unlock; null = locked. */
|
|
@@ -783,6 +786,7 @@ export function buildPageData(cfg: Config, source: RunSource): PageData {
|
|
|
783
786
|
machine: safe(() => machineRow(cfg)),
|
|
784
787
|
knowledge: safe(() => knowledgeManifest(cfg)),
|
|
785
788
|
stats: safe(() => nowStats(cfg, source, nowSec())),
|
|
789
|
+
results: safe(() => resultsData(cfg, source)),
|
|
786
790
|
messages: safe(() => recentOwnerMessages(nowSec())),
|
|
787
791
|
lockMinutesLeft: lockMinutesLeft(cfg),
|
|
788
792
|
};
|
|
@@ -822,8 +826,8 @@ export function edgeScrollStep(y: number, viewportH: number): number {
|
|
|
822
826
|
const SCRIPT = `(function(){
|
|
823
827
|
var dropSlot=${dropSlot.toString()};
|
|
824
828
|
var edgeScrollStep=${edgeScrollStep.toString()};
|
|
825
|
-
// Keep
|
|
826
|
-
if(location.search){var
|
|
829
|
+
// Keep the tab in the address bar (receipts are one-time DOM, not a reloadable URL); the Results tab keeps y/x so the 20 s refresh renders the same selection.
|
|
830
|
+
if(location.search){var q=new URLSearchParams(location.search);var keep=new URLSearchParams();if(q.get("tab"))keep.set("tab",q.get("tab"));if(q.get("tab")==="results"){if(q.get("y"))keep.set("y",q.get("y"));if(q.get("x"))keep.set("x",q.get("x"));}var ks=keep.toString();history.replaceState(null,"",location.pathname+(ks?"?"+ks:""));}
|
|
827
831
|
function store(d,v){var k="nsui:"+d.id;if(v===undefined)return sessionStorage.getItem(k);sessionStorage.setItem(k,v?"1":"0");}
|
|
828
832
|
function bindDetails(root){var ds=root.querySelectorAll("details[id]");for(var i=0;i<ds.length;i++){(function(d){var s=store(d);if(s!==null)d.open=s==="1";d.addEventListener("toggle",function(){store(d,d.open);});})(ds[i]);}}
|
|
829
833
|
var dragging=false;
|
|
@@ -946,6 +950,222 @@ function knowledgeHtml(entries: KnowledgeEntry[], repo: string, topic: string):
|
|
|
946
950
|
return `${crumb}<h1>${esc(hit.title)}</h1><div class="card"><iframe class="knowframe" title="${esc(hit.title)}" src="/knowledge/${urlValue(repo)}/${urlValue(topic)}"></iframe></div>`;
|
|
947
951
|
}
|
|
948
952
|
|
|
953
|
+
// ---- Results tab (plan 20261025_2148 P4): $ per finished feature, releases before vs after ----
|
|
954
|
+
|
|
955
|
+
export interface ResultsData {
|
|
956
|
+
/** The ledger over the last `metrics.report_days` days — only the empty state reads it. */
|
|
957
|
+
features: FeaturesReport;
|
|
958
|
+
/** Per release, the N-day before/after windows: the chart's series and the table's rows. */
|
|
959
|
+
releases: ReleasesReport;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
let resultsCache: { at: number; data: ResultsData } | null = null;
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* The tab's data from the P2/P3 functions, computed once per build (the chart and the table read
|
|
966
|
+
* the same object, like the Spend tile and its table). Cached for a minute: a release's before
|
|
967
|
+
* window reaches back past the features window, so one build can parse months of sessions while
|
|
968
|
+
* the page refetches every ${REFRESH_SEC} s.
|
|
969
|
+
*/
|
|
970
|
+
function resultsData(cfg: Config, source: RunSource): ResultsData {
|
|
971
|
+
const now = nowSec();
|
|
972
|
+
if (resultsCache && now - resultsCache.at < 60) return resultsCache.data;
|
|
973
|
+
const days = 7;
|
|
974
|
+
const selfRepo = gitTop(import.meta.dir)?.repo ?? null;
|
|
975
|
+
const tags = gatherTags(selfRepo);
|
|
976
|
+
const events = readMetricEvents(cfg);
|
|
977
|
+
const oldest = Math.min(now, ...tags.map(t => t.ts), ...events.filter(e => e.type === "ci").map(e => Number(e.ts)));
|
|
978
|
+
const runs = source.listRuns(oldest - days * 86400);
|
|
979
|
+
const plans = loadPlans(cfg);
|
|
980
|
+
const data: ResultsData = {
|
|
981
|
+
features: featuresReport(runs, plans, selfRepo, now - cfg.metrics.report_days * 86400, now),
|
|
982
|
+
releases: releasesReport(runs, plans, selfRepo, days, now, tags, events),
|
|
983
|
+
};
|
|
984
|
+
resultsCache = { at: now, data };
|
|
985
|
+
return data;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/** One y axis choice: where the number sits on a release side and which way is better. */
|
|
989
|
+
interface YMetric {
|
|
990
|
+
key: string;
|
|
991
|
+
label: string;
|
|
992
|
+
axis: string;
|
|
993
|
+
/** null = no known direction (product numbers): the table's arrow carries no color. */
|
|
994
|
+
better: "lower" | "higher" | null;
|
|
995
|
+
fmt(v: number): string;
|
|
996
|
+
get(side: ReleaseSideStats): number | null;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
const LEDGER_METRICS: YMetric[] = [
|
|
1000
|
+
{ key: "usd", label: "$/feat", axis: "$ per feature", better: "lower", fmt: v => `$${v.toFixed(2)}`, get: s => s.perFeature },
|
|
1001
|
+
{ key: "perday", label: "/day", axis: "features per day", better: "higher", fmt: v => v.toFixed(2), get: s => s.featuresPerDay },
|
|
1002
|
+
{ key: "calls", label: "calls", axis: "main calls per feature", better: "lower", fmt: v => v.toFixed(1), get: s => s.callsPerFeature },
|
|
1003
|
+
{ key: "tok", label: "tok", axis: "tokens per call", better: "lower", fmt: v => v.toFixed(0), get: s => s.tokensPerCall },
|
|
1004
|
+
{ key: "fix", label: "fix", axis: "fix plans per feature", better: "lower", fmt: v => v.toFixed(2), get: s => s.fixPlansPerFeature },
|
|
1005
|
+
];
|
|
1006
|
+
|
|
1007
|
+
/** One metric per recorded product number, keyed `p:<name>` (repo-qualified when names clash). */
|
|
1008
|
+
function productMetrics(releases: ReleasesReport): YMetric[] {
|
|
1009
|
+
const pairs = new Map<string, { repo: string; name: string }>();
|
|
1010
|
+
for (const row of releases.rows) for (const p of [...row.before.products, ...row.after.products]) pairs.set(`${p.repo}|${p.name}`, p);
|
|
1011
|
+
const clashes: Record<string, number> = {};
|
|
1012
|
+
for (const { name } of pairs.values()) clashes[name] = (clashes[name] ?? 0) + 1;
|
|
1013
|
+
return [...pairs.values()]
|
|
1014
|
+
.sort((a, b) => (a.name + a.repo).localeCompare(b.name + b.repo))
|
|
1015
|
+
.map(({ repo, name }) => {
|
|
1016
|
+
const clash = (clashes[name] ?? 0) > 1;
|
|
1017
|
+
return {
|
|
1018
|
+
key: clash ? `p:${basename(repo)}:${name}` : `p:${name}`,
|
|
1019
|
+
label: clash ? `${basename(repo)}/${name}` : name,
|
|
1020
|
+
axis: `${name} (product number)`,
|
|
1021
|
+
better: null,
|
|
1022
|
+
fmt: (v: number) => String(Math.round(v * 100) / 100),
|
|
1023
|
+
get: (s: ReleaseSideStats): number | null => s.products.find(p => p.repo === repo && p.name === name)?.value ?? null,
|
|
1024
|
+
};
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
const RESULT_KINDS = ["product", "neurastream"] as const;
|
|
1029
|
+
const KIND_COLOR: Record<(typeof RESULT_KINDS)[number], string> = { product: "var(--acc)", neurastream: "var(--teal)" };
|
|
1030
|
+
const CHART_W = 390;
|
|
1031
|
+
const CHART_H = 200;
|
|
1032
|
+
const CHART_L = 48;
|
|
1033
|
+
const CHART_R = 8;
|
|
1034
|
+
const CHART_T = 10;
|
|
1035
|
+
const CHART_B = 20;
|
|
1036
|
+
|
|
1037
|
+
interface ChartPoint {
|
|
1038
|
+
px: number;
|
|
1039
|
+
py: number;
|
|
1040
|
+
label: string;
|
|
1041
|
+
value: number;
|
|
1042
|
+
}
|
|
1043
|
+
interface ChartSeries {
|
|
1044
|
+
label: string;
|
|
1045
|
+
color: string;
|
|
1046
|
+
points: ChartPoint[];
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/** The tab's controls: plain links, so the page's existing fetch/pushState swap handles them with no new script. */
|
|
1050
|
+
function resultsControls(all: YMetric[], y: YMetric, x: "time" | "feature"): string {
|
|
1051
|
+
const yLinks = all
|
|
1052
|
+
.map(m => `<a href="/?tab=results&y=${m.key}&x=${x}"${m.key === y.key ? ` class="on"` : ""}>${esc(m.label)}</a>`)
|
|
1053
|
+
.join("");
|
|
1054
|
+
const xLinks = (["time", "feature"] as const)
|
|
1055
|
+
.map(v => `<a href="/?tab=results&y=${y.key}&x=${v}"${v === x ? ` class="on"` : ""}>${v === "time" ? "time" : "feature"}</a>`)
|
|
1056
|
+
.join("");
|
|
1057
|
+
return `<div class="rlinks"><span>y</span>${yLinks}</div><div class="rlinks"><span>x</span>${xLinks}</div>`;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Hand-written inline SVG under the page's CSP: one polyline per series (product vs neurastream
|
|
1062
|
+
* for a ledger metric, one per product number), points carrying <title> tooltips, releases as
|
|
1063
|
+
* dashed verticals on the time axis, theme colors via the page's CSS variables.
|
|
1064
|
+
*/
|
|
1065
|
+
function resultsChart(releases: ReleasesReport, y: YMetric, x: "time" | "feature"): string {
|
|
1066
|
+
const rows = releases.rows;
|
|
1067
|
+
const mid = CHART_L + (CHART_W - CHART_L - CHART_R) / 2;
|
|
1068
|
+
const t0 = rows[0]!.ts;
|
|
1069
|
+
const t1 = rows[rows.length - 1]!.ts;
|
|
1070
|
+
const pxOf = (i: number, ts: number): number =>
|
|
1071
|
+
x === "feature" ? (rows.length < 2 ? mid : CHART_L + (i / (rows.length - 1)) * (CHART_W - CHART_L - CHART_R))
|
|
1072
|
+
: t1 === t0 ? mid : CHART_L + ((ts - t0) / (t1 - t0)) * (CHART_W - CHART_L - CHART_R);
|
|
1073
|
+
const tip = (row: ReleaseRow, v: number): string => `${row.name} · ${y.fmt(v)} · ${strftime(row.ts, "%m-%d %H:%M")}`;
|
|
1074
|
+
const point = (row: ReleaseRow, i: number, v: number): ChartPoint => ({ px: pxOf(i, row.ts), py: 0, label: tip(row, v), value: v });
|
|
1075
|
+
const series: ChartSeries[] = LEDGER_METRICS.includes(y)
|
|
1076
|
+
? RESULT_KINDS.map(kind => ({
|
|
1077
|
+
label: kind,
|
|
1078
|
+
color: KIND_COLOR[kind],
|
|
1079
|
+
points: rows.flatMap((row, i) => {
|
|
1080
|
+
if (row.kind !== kind) return [];
|
|
1081
|
+
const v = y.get(row.after);
|
|
1082
|
+
return v === null ? [] : [point(row, i, v)];
|
|
1083
|
+
}),
|
|
1084
|
+
}))
|
|
1085
|
+
: [
|
|
1086
|
+
{
|
|
1087
|
+
label: y.label,
|
|
1088
|
+
color: "var(--warn)",
|
|
1089
|
+
points: rows.flatMap((row, i) => {
|
|
1090
|
+
const v = y.get(row.after);
|
|
1091
|
+
return v === null ? [] : [point(row, i, v)];
|
|
1092
|
+
}),
|
|
1093
|
+
},
|
|
1094
|
+
];
|
|
1095
|
+
const yMax = Math.max(...series.flatMap(s => s.points.map(p => p.value)), 1e-9);
|
|
1096
|
+
const pyOf = (v: number): number => CHART_T + (1 - v / yMax) * (CHART_H - CHART_T - CHART_B);
|
|
1097
|
+
const parts: string[] = [];
|
|
1098
|
+
for (const v of [0, yMax / 2, yMax]) {
|
|
1099
|
+
parts.push(`<line x1="${CHART_L}" x2="${CHART_W - CHART_R}" y1="${pyOf(v).toFixed(1)}" y2="${pyOf(v).toFixed(1)}" stroke="var(--bd)"/>`);
|
|
1100
|
+
parts.push(`<text x="${CHART_L - 5}" y="${(pyOf(v) + 3).toFixed(1)}" text-anchor="end" font-size="10" fill="var(--mut)">${esc(y.fmt(v))}</text>`);
|
|
1101
|
+
}
|
|
1102
|
+
if (x === "time") {
|
|
1103
|
+
for (const row of rows) {
|
|
1104
|
+
const px = pxOf(0, row.ts).toFixed(1);
|
|
1105
|
+
parts.push(
|
|
1106
|
+
`<line x1="${px}" x2="${px}" y1="${CHART_T}" y2="${CHART_H - CHART_B}" stroke="var(--bd)" stroke-dasharray="3 3"><title>${esc(`${row.name} · ${strftime(row.ts, "%m-%d %H:%M")}`)}</title></line>`,
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
parts.push(`<text x="${CHART_L}" y="${CHART_H - 6}" font-size="10" fill="var(--mut)">${esc(strftime(t0, "%m-%d"))}</text>`);
|
|
1110
|
+
parts.push(`<text x="${CHART_W - CHART_R}" y="${CHART_H - 6}" text-anchor="end" font-size="10" fill="var(--mut)">${esc(strftime(t1, "%m-%d"))}</text>`);
|
|
1111
|
+
}
|
|
1112
|
+
for (const s of series) {
|
|
1113
|
+
if (s.points.length > 1) {
|
|
1114
|
+
const pts = s.points.map(p => `${p.px.toFixed(1)},${pyOf(p.value).toFixed(1)}`).join(" ");
|
|
1115
|
+
parts.push(`<polyline points="${pts}" fill="none" stroke="${s.color}" stroke-width="2"/>`);
|
|
1116
|
+
}
|
|
1117
|
+
for (const p of s.points) {
|
|
1118
|
+
parts.push(`<circle cx="${p.px.toFixed(1)}" cy="${pyOf(p.value).toFixed(1)}" r="3" fill="${s.color}"><title>${esc(p.label)}</title></circle>`);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
const legend = series.map(s => `<span style="color:${s.color}">— ${esc(s.label)}</span>`).join("");
|
|
1122
|
+
return `<p class="rlegend">${legend}</p><svg class="rchart" role="img" aria-label="${esc(`${y.axis} by ${x === "time" ? "day" : "release"}`)}" viewBox="0 0 ${CHART_W} ${CHART_H}">${parts.join("")}</svg>`;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/** One row per release, the `metrics releases` table: before→after cells with ▲/▼, green when the change is for the better. */
|
|
1126
|
+
function resultsTable(releases: ReleasesReport, all: YMetric[]): string {
|
|
1127
|
+
const cell = (row: ReleaseRow, m: YMetric): string => {
|
|
1128
|
+
const before = m.get(row.before);
|
|
1129
|
+
const after = m.get(row.after);
|
|
1130
|
+
if (before === null || after === null) return `<td class="mutcell">–</td>`;
|
|
1131
|
+
const arrow = after > before ? "▲" : after < before ? "▼" : "·";
|
|
1132
|
+
const cls = m.better !== null && after !== before ? ((m.better === "lower") === (after < before) ? ` class="good"` : ` class="badv"`) : "";
|
|
1133
|
+
return `<td>${esc(m.fmt(before))}→${esc(m.fmt(after))}<span${cls}>${arrow}</span></td>`;
|
|
1134
|
+
};
|
|
1135
|
+
const head = `<tr><th>release</th>${all.map(m => `<th>${esc(m.label)}</th>`).join("")}</tr>`;
|
|
1136
|
+
const body = releases.rows
|
|
1137
|
+
.map(row =>
|
|
1138
|
+
`<tr><td>${esc(row.name)} <span class="note">${strftime(row.ts, "%m-%d")}</span>${row.measuring ? ` <span class="chip c-ready">measuring</span>` : ""}</td>${all.map(m => cell(row, m)).join("")}</tr>`,
|
|
1139
|
+
)
|
|
1140
|
+
.join("");
|
|
1141
|
+
return `<div class="tscroll"><table><thead>${head}</thead><tbody>${body}</tbody></table></div>`;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
const RESULTS_CAVEAT = "Fixes inside the same plan are not split out; plans that do not cite an earlier stem are not linked. Product numbers carry no better/worse color.";
|
|
1145
|
+
|
|
1146
|
+
function resultsTabHtml(d: ResultsData | null | undefined, params: URLSearchParams): string {
|
|
1147
|
+
if (!d) return `<h1>Results</h1>${na("Results")}`;
|
|
1148
|
+
if (!d.releases.rows.length) {
|
|
1149
|
+
const empty = d.features.rows.length ? "No releases recorded yet" : "No finished features yet";
|
|
1150
|
+
return `<h1>Results</h1><div class="card"><p class="empty">${empty}</p></div><p class="sub">${RESULTS_CAVEAT}</p>`;
|
|
1151
|
+
}
|
|
1152
|
+
const x = params.get("x") === "feature" ? "feature" : "time";
|
|
1153
|
+
const all = [...LEDGER_METRICS, ...productMetrics(d.releases)];
|
|
1154
|
+
// An unknown y falls back to $/feature.
|
|
1155
|
+
const y = all.find(m => m.key === params.get("y")) ?? all[0]!;
|
|
1156
|
+
return `<h1>Results</h1>
|
|
1157
|
+
<p class="sub">What features cost and whether releases made it better or worse.</p>
|
|
1158
|
+
<div class="card">
|
|
1159
|
+
${resultsControls(all, y, x)}
|
|
1160
|
+
${resultsChart(d.releases, y, x)}
|
|
1161
|
+
</div>
|
|
1162
|
+
<h2>Releases <small>${d.releases.days} days before → after</small></h2>
|
|
1163
|
+
<div class="card">
|
|
1164
|
+
${resultsTable(d.releases, all)}
|
|
1165
|
+
</div>
|
|
1166
|
+
<p class="sub">${RESULTS_CAVEAT}</p>`;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
949
1169
|
/** The whole page as one HTML string. Exported for scripts/ui-preview.ts (no server). */
|
|
950
1170
|
export function renderPage(cfg: Config, data: PageData, params: URLSearchParams, nonce: string): string {
|
|
951
1171
|
const req = params.get("tab") ?? "";
|
|
@@ -1005,7 +1225,8 @@ ${machine}
|
|
|
1005
1225
|
</div>`
|
|
1006
1226
|
: tab === "knowledge"
|
|
1007
1227
|
? `${data.knowledge === null ? na("Base") : knowledgeHtml(data.knowledge, params.get("repo") ?? "", params.get("topic") ?? "")}`
|
|
1008
|
-
:
|
|
1228
|
+
: tab === "spend"
|
|
1229
|
+
? `<h1>Spend</h1>
|
|
1009
1230
|
<p class="sub">List price over the last 24 hours.</p>
|
|
1010
1231
|
<div class="card">
|
|
1011
1232
|
${spendTileHtml(data)}
|
|
@@ -1013,7 +1234,8 @@ ${spendTileHtml(data)}
|
|
|
1013
1234
|
<h2>By model</h2>
|
|
1014
1235
|
<div class="card">
|
|
1015
1236
|
${modelSpendTable(data.stats)}
|
|
1016
|
-
</div
|
|
1237
|
+
</div>`
|
|
1238
|
+
: resultsTabHtml(data.results, params);
|
|
1017
1239
|
return `<!doctype html>
|
|
1018
1240
|
<html lang="en">
|
|
1019
1241
|
<head>
|
|
@@ -1030,8 +1252,8 @@ html{scroll-padding-top:64px}
|
|
|
1030
1252
|
body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.4 system-ui,-apple-system,sans-serif}
|
|
1031
1253
|
.top{position:sticky;top:0;display:flex;align-items:center;gap:8px;padding:10px 12px;background:var(--bg);z-index:2}
|
|
1032
1254
|
.logo{font-weight:800;color:var(--acc)}
|
|
1033
|
-
.pills{display:flex;background:var(--card);border:1px solid var(--bd);border-radius:999px;padding:3px;flex:1}
|
|
1034
|
-
.pills a{flex:
|
|
1255
|
+
.pills{display:flex;background:var(--card);border:1px solid var(--bd);border-radius:999px;padding:3px;flex:1;gap:3px;overflow-x:auto}
|
|
1256
|
+
.pills a{flex:none;text-align:center;padding:5px 10px;border-radius:999px;color:var(--mut);text-decoration:none;font-size:13px;white-space:nowrap}
|
|
1035
1257
|
.pills a.on{background:var(--bg);color:var(--fg);font-weight:600;box-shadow:0 0 0 1px var(--bd)}
|
|
1036
1258
|
.lock{border:1px solid var(--bd);background:var(--card);border-radius:999px;padding:6px 10px;font-size:13px;color:var(--fg);position:relative;flex:none}
|
|
1037
1259
|
.lock summary{list-style:none;white-space:nowrap}
|
|
@@ -1110,6 +1332,15 @@ table{border-collapse:collapse;width:100%;font-size:13px}
|
|
|
1110
1332
|
th,td{text-align:left;padding:6px 8px;border-bottom:1px solid var(--bd);font-variant-numeric:tabular-nums}
|
|
1111
1333
|
th{color:var(--mut);font-weight:600}
|
|
1112
1334
|
tr:last-child td{border-bottom:none}
|
|
1335
|
+
.tscroll{overflow-x:auto}
|
|
1336
|
+
td.mutcell{color:var(--mut)}
|
|
1337
|
+
span.good{color:var(--ok);font-weight:600}
|
|
1338
|
+
span.badv{color:var(--red);font-weight:600}
|
|
1339
|
+
.rlinks{display:flex;gap:6px;align-items:center;flex-wrap:wrap;padding:10px 14px 0;font-size:12px;color:var(--mut)}
|
|
1340
|
+
.rlinks a{border:1px solid var(--bd);border-radius:999px;padding:3px 10px;color:var(--mut);text-decoration:none;background:var(--card)}
|
|
1341
|
+
.rlinks a.on{color:var(--fg);background:var(--bg);font-weight:600;box-shadow:0 0 0 1px var(--bd)}
|
|
1342
|
+
.rlegend{margin:0;padding:10px 14px 0;font-size:12px;color:var(--mut);display:flex;gap:12px}
|
|
1343
|
+
.rchart{width:100%;height:auto;display:block;padding:4px 2px 8px}
|
|
1113
1344
|
.merges,.incidents{margin:0;padding:8px 14px 8px 32px}
|
|
1114
1345
|
.merges li,.incidents li{margin:6px 0}
|
|
1115
1346
|
.mrow{display:flex;justify-content:space-between;gap:12px;padding:6px 0;border-bottom:1px solid var(--bd)}
|
package/src/core/queue/lib.ts
CHANGED
|
@@ -572,11 +572,13 @@ function subagentsOpWrites(code: string): boolean {
|
|
|
572
572
|
return false;
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
export function writeTargets(toolName: string, input: Record<string, unknown>, cwd: string): string[] {
|
|
575
|
+
export function writeTargets(toolName: string, input: Record<string, unknown>, cwd: string, relative?: string[]): string[] {
|
|
576
576
|
const out = new Set<string>();
|
|
577
577
|
const add = (raw: string, from: string) => {
|
|
578
|
-
const
|
|
578
|
+
const typed = String(raw).trim().replace(/^["']|["']$/g, "");
|
|
579
|
+
const s = expandHome(typed);
|
|
579
580
|
if (!s || s.includes("://") || s.startsWith("$") || s === "/dev/null" || s.startsWith("/dev/")) return;
|
|
581
|
+
if (relative && !typed.startsWith("/")) relative.push(typed);
|
|
580
582
|
out.add(path.resolve(from, s));
|
|
581
583
|
};
|
|
582
584
|
if (toolName === "write") {
|
|
@@ -785,6 +787,21 @@ export function allowedAgents(file = subagentsPath()): Set<string> {
|
|
|
785
787
|
return new Set([...body.matchAll(/^\s*[-*]\s+`([a-z0-9-]+)`/gm)].map(m => m[1] ?? ""));
|
|
786
788
|
}
|
|
787
789
|
|
|
790
|
+
// P4d (plan 20261028_1600): a review spawn runs under a review.agents entry that Main may spawn
|
|
791
|
+
// (## Allowed of the subagents file). When Allowed names agents and none of them is a review.agents
|
|
792
|
+
// entry, every review spawn is refused: a problem. When Allowed is empty (a fresh install), no subagent
|
|
793
|
+
// can spawn at all yet, so there is no review spawn to refuse. An entry not allowed is a warning.
|
|
794
|
+
export function reviewAgentsProblem(cfg: Config, allowed: Set<string>): { problem: string | null; warnings: string[] } {
|
|
795
|
+
const agents = cfg.review.agents;
|
|
796
|
+
const warnings = agents
|
|
797
|
+
.filter(a => !allowed.has(a))
|
|
798
|
+
.map(a => `review.agents lists "${a}", which is not in "## Allowed" of ${cfg.paths.subagents}; it cannot run a review spawn`);
|
|
799
|
+
const problem = allowed.size === 0 || agents.some(a => allowed.has(a))
|
|
800
|
+
? null
|
|
801
|
+
: `no review.agents entry is in "## Allowed" of ${cfg.paths.subagents}: set review.agents to an allowed agent in config.yml`;
|
|
802
|
+
return { problem, warnings };
|
|
803
|
+
}
|
|
804
|
+
|
|
788
805
|
export const CANCELLED_REL = "docs/plans/CANCELLED.md";
|
|
789
806
|
export function globalCancelledPath(): string {
|
|
790
807
|
return process.env.QUEUE_CANCELLED ?? `${agentDir()}/CANCELLED.md`;
|
|
@@ -1015,7 +1032,8 @@ export function queueSummary(index = INDEX, reviewSince = ""): string {
|
|
|
1015
1032
|
if (at === undefined || plans[at - 1]!.status !== "open") continue;
|
|
1016
1033
|
waits.push(`waits on #${at}`);
|
|
1017
1034
|
}
|
|
1018
|
-
const
|
|
1035
|
+
const done = p.phases.total ? `${p.phases.done}/${p.phases.total} done` : "";
|
|
1036
|
+
const flags = [status, done, hold, ...waits, p.priorityId ?? ""].filter(Boolean).join(", ");
|
|
1019
1037
|
const goal = items(sections(p.text).get("goal") ?? "")[0]?.slice(0, 100) ?? "";
|
|
1020
1038
|
lines.push(` ${i + 1}. ${p.file} [${flags}] ${goal}`);
|
|
1021
1039
|
});
|
package/src/core/queue-check.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from "./config.ts";
|
|
2
2
|
import { applyQueueEnv } from "./queue/env.ts";
|
|
3
|
-
import { activePlans, queueProblems, queueSummary } from "./queue/lib.ts";
|
|
3
|
+
import { activePlans, allowedAgents, queueProblems, queueSummary, reviewAgentsProblem } from "./queue/lib.ts";
|
|
4
4
|
import { mrSweep } from "./mr-sweep.ts";
|
|
5
5
|
|
|
6
6
|
// One index (20261024_1400_one_index): the main index lists plan files directly, so there are no
|
|
@@ -15,6 +15,13 @@ export function queueCheck(args: string[], cfg: Config): number {
|
|
|
15
15
|
console.log(queueSummary(undefined, cfg.review.since));
|
|
16
16
|
// main-start prints the sweep itself and passes this so the child bin does not print it twice.
|
|
17
17
|
let fail = queueProblems(undefined, undefined, cfg.review.since).length > 0;
|
|
18
|
+
// P4d (plan 20261028_1600): a review spawn needs a review.agents entry that Main may spawn.
|
|
19
|
+
const review = reviewAgentsProblem(cfg, allowedAgents(cfg.paths.subagents));
|
|
20
|
+
if (review.problem) {
|
|
21
|
+
console.log(`review gate: ${review.problem}`);
|
|
22
|
+
fail = true;
|
|
23
|
+
}
|
|
24
|
+
for (const w of review.warnings) console.log(`warning: ${w}`);
|
|
18
25
|
if (!args.includes("--no-mr-sweep")) {
|
|
19
26
|
try {
|
|
20
27
|
const sweep = mrSweep();
|
|
@@ -8,7 +8,8 @@ import { finishedEntry, finishedKey, finishedPath, parsePlan, planRepo, prependF
|
|
|
8
8
|
|
|
9
9
|
const USAGE = "usage: queue-finished --backfill | --dedupe | queue-finished <word>";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** Shared with src/core/results.ts: every *.md under dir, recursively. */
|
|
12
|
+
export function walkMd(dir: string, out: string[]): void {
|
|
12
13
|
let names: string[];
|
|
13
14
|
try {
|
|
14
15
|
names = readdirSync(dir);
|
|
@@ -28,8 +29,8 @@ function walkMd(dir: string, out: string[]): void {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
/** Repos named by work_roots, plus one level of children so a root that holds many checkouts still counts. */
|
|
32
|
-
function repoRoots(roots: string[]): string[] {
|
|
32
|
+
/** Repos named by work_roots, plus one level of children so a root that holds many checkouts still counts. Shared with src/core/results.ts. */
|
|
33
|
+
export function repoRoots(roots: string[]): string[] {
|
|
33
34
|
const out: string[] = [];
|
|
34
35
|
for (const root of roots) {
|
|
35
36
|
if (!existsSync(root)) continue;
|