polymath-society 0.2.5 → 0.2.7
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/dist/cli.js +2420 -1573
- package/dist/engine/ingest-export.js +14 -8
- package/dist/engine/public-report.js +14 -8
- package/dist/index.js +1475 -60
- package/dist/pipeline/coding-agglomerate.js +289 -35
- package/dist/pipeline/coding-aggregate.js +15 -9
- package/dist/pipeline/coding-build.js +14 -8
- package/dist/pipeline/coding-coaching.js +273 -21
- package/dist/pipeline/coding-day-digest.js +17 -10
- package/dist/pipeline/coding-delegation.js +62 -17
- package/dist/pipeline/coding-expertise.js +166 -61
- package/dist/pipeline/coding-flow.js +14 -8
- package/dist/pipeline/coding-frontier-detail.js +143 -27
- package/dist/pipeline/coding-frontier.js +14 -8
- package/dist/pipeline/coding-gap-dist.js +14 -8
- package/dist/pipeline/coding-gap.js +140 -39
- package/dist/pipeline/coding-grade.js +44 -14
- package/dist/pipeline/coding-nutshell.js +39 -11
- package/dist/pipeline/coding-projects.js +41 -10
- package/dist/pipeline/coding-walkthrough.js +15 -9
- package/dist/web/app.js +493 -117
- package/dist/web/styles.css +1 -1
- package/package.json +1 -1
|
@@ -134,12 +134,13 @@ var require_secure_json_parse = __commonJS({
|
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
// ../../scripts/coding-agglomerate.mts
|
|
137
|
-
import
|
|
137
|
+
import { promises as fs8 } from "fs";
|
|
138
|
+
import path12 from "path";
|
|
138
139
|
|
|
139
140
|
// ../../lib/agents/coding/agglomerate.ts
|
|
140
|
-
import { promises as
|
|
141
|
+
import { promises as fs7 } from "fs";
|
|
141
142
|
import os2 from "os";
|
|
142
|
-
import
|
|
143
|
+
import path10 from "path";
|
|
143
144
|
|
|
144
145
|
// ../../lib/agents/shared/agent.ts
|
|
145
146
|
import { readFileSync } from "fs";
|
|
@@ -2154,8 +2155,8 @@ function getErrorMap() {
|
|
|
2154
2155
|
|
|
2155
2156
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
2156
2157
|
var makeIssue = (params) => {
|
|
2157
|
-
const { data, path:
|
|
2158
|
-
const fullPath = [...
|
|
2158
|
+
const { data, path: path13, errorMaps, issueData } = params;
|
|
2159
|
+
const fullPath = [...path13, ...issueData.path || []];
|
|
2159
2160
|
const fullIssue = {
|
|
2160
2161
|
...issueData,
|
|
2161
2162
|
path: fullPath
|
|
@@ -2271,11 +2272,11 @@ var errorUtil;
|
|
|
2271
2272
|
|
|
2272
2273
|
// ../../node_modules/zod/v3/types.js
|
|
2273
2274
|
var ParseInputLazyPath = class {
|
|
2274
|
-
constructor(parent, value,
|
|
2275
|
+
constructor(parent, value, path13, key) {
|
|
2275
2276
|
this._cachedPath = [];
|
|
2276
2277
|
this.parent = parent;
|
|
2277
2278
|
this.data = value;
|
|
2278
|
-
this._path =
|
|
2279
|
+
this._path = path13;
|
|
2279
2280
|
this._key = key;
|
|
2280
2281
|
}
|
|
2281
2282
|
get path() {
|
|
@@ -15062,39 +15063,39 @@ function createOpenAI(options = {}) {
|
|
|
15062
15063
|
});
|
|
15063
15064
|
const createChatModel = (modelId, settings = {}) => new OpenAIChatLanguageModel(modelId, settings, {
|
|
15064
15065
|
provider: `${providerName}.chat`,
|
|
15065
|
-
url: ({ path:
|
|
15066
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15066
15067
|
headers: getHeaders,
|
|
15067
15068
|
compatibility,
|
|
15068
15069
|
fetch: options.fetch
|
|
15069
15070
|
});
|
|
15070
15071
|
const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
|
|
15071
15072
|
provider: `${providerName}.completion`,
|
|
15072
|
-
url: ({ path:
|
|
15073
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15073
15074
|
headers: getHeaders,
|
|
15074
15075
|
compatibility,
|
|
15075
15076
|
fetch: options.fetch
|
|
15076
15077
|
});
|
|
15077
15078
|
const createEmbeddingModel = (modelId, settings = {}) => new OpenAIEmbeddingModel(modelId, settings, {
|
|
15078
15079
|
provider: `${providerName}.embedding`,
|
|
15079
|
-
url: ({ path:
|
|
15080
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15080
15081
|
headers: getHeaders,
|
|
15081
15082
|
fetch: options.fetch
|
|
15082
15083
|
});
|
|
15083
15084
|
const createImageModel = (modelId, settings = {}) => new OpenAIImageModel(modelId, settings, {
|
|
15084
15085
|
provider: `${providerName}.image`,
|
|
15085
|
-
url: ({ path:
|
|
15086
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15086
15087
|
headers: getHeaders,
|
|
15087
15088
|
fetch: options.fetch
|
|
15088
15089
|
});
|
|
15089
15090
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
15090
15091
|
provider: `${providerName}.transcription`,
|
|
15091
|
-
url: ({ path:
|
|
15092
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15092
15093
|
headers: getHeaders,
|
|
15093
15094
|
fetch: options.fetch
|
|
15094
15095
|
});
|
|
15095
15096
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
15096
15097
|
provider: `${providerName}.speech`,
|
|
15097
|
-
url: ({ path:
|
|
15098
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15098
15099
|
headers: getHeaders,
|
|
15099
15100
|
fetch: options.fetch
|
|
15100
15101
|
});
|
|
@@ -15115,7 +15116,7 @@ function createOpenAI(options = {}) {
|
|
|
15115
15116
|
const createResponsesModel = (modelId) => {
|
|
15116
15117
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
15117
15118
|
provider: `${providerName}.responses`,
|
|
15118
|
-
url: ({ path:
|
|
15119
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15119
15120
|
headers: getHeaders,
|
|
15120
15121
|
fetch: options.fetch
|
|
15121
15122
|
});
|
|
@@ -15754,6 +15755,240 @@ var CODING_CRITERIA = [
|
|
|
15754
15755
|
var GRADED_CRITERIA = CODING_CRITERIA.filter((c) => c.graded);
|
|
15755
15756
|
var RUBRIC_FINGERPRINT = rubricFingerprint(GRADED_CRITERIA);
|
|
15756
15757
|
|
|
15758
|
+
// ../../lib/agents/coding/docsDir.ts
|
|
15759
|
+
import { promises as fs5 } from "fs";
|
|
15760
|
+
import path9 from "path";
|
|
15761
|
+
|
|
15762
|
+
// ../../lib/agents/coding/materialize.ts
|
|
15763
|
+
import { promises as fs4 } from "fs";
|
|
15764
|
+
|
|
15765
|
+
// ../coding-core/dist/injected.js
|
|
15766
|
+
function isHarnessEntry(e) {
|
|
15767
|
+
return e.isMeta === true || e.isCompactSummary === true;
|
|
15768
|
+
}
|
|
15769
|
+
|
|
15770
|
+
// ../../lib/agents/coding/materialize.ts
|
|
15771
|
+
var SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
15772
|
+
var INJECT_GIST = 120;
|
|
15773
|
+
var INJECTED = [
|
|
15774
|
+
{ re: /<task-notification>[\s\S]*?<\/task-notification>/g, label: "bg task", gistRe: /<summary>([\s\S]*?)<\/summary>/ },
|
|
15775
|
+
{ re: /<local-command-stdout>[\s\S]*?<\/local-command-stdout>/g, label: "cmd output" },
|
|
15776
|
+
{ re: /<local-command-caveat>[\s\S]*?<\/local-command-caveat>/g, label: null },
|
|
15777
|
+
{ re: /<ide_opened_file>[\s\S]*?<\/ide_opened_file>/g, label: null }
|
|
15778
|
+
];
|
|
15779
|
+
function collapseInjected(input) {
|
|
15780
|
+
const markers = [];
|
|
15781
|
+
let text2 = input;
|
|
15782
|
+
for (const { re: re2, label, gistRe } of INJECTED) {
|
|
15783
|
+
text2 = text2.replace(re2, (block) => {
|
|
15784
|
+
if (label) {
|
|
15785
|
+
const gist = (gistRe ? block.match(gistRe)?.[1] ?? "" : block.replace(/<[^>]*>/g, " ")).replace(/\s+/g, " ").trim().slice(0, INJECT_GIST);
|
|
15786
|
+
markers.push(gist ? `[${label}: ${gist}]` : `[${label}]`);
|
|
15787
|
+
}
|
|
15788
|
+
return "";
|
|
15789
|
+
});
|
|
15790
|
+
}
|
|
15791
|
+
return { text: text2.replace(SYSTEM_REMINDER_RE, "").trim(), markers };
|
|
15792
|
+
}
|
|
15793
|
+
function extractText(content) {
|
|
15794
|
+
if (typeof content === "string") return content;
|
|
15795
|
+
if (Array.isArray(content)) {
|
|
15796
|
+
const parts = [];
|
|
15797
|
+
for (const item of content) {
|
|
15798
|
+
if (item && typeof item === "object" && item.type === "text") parts.push(item.text || "");
|
|
15799
|
+
}
|
|
15800
|
+
return parts.join("\n");
|
|
15801
|
+
}
|
|
15802
|
+
return "";
|
|
15803
|
+
}
|
|
15804
|
+
function isToolResultOnly(content) {
|
|
15805
|
+
return Array.isArray(content) && content.length > 0 && content.every((c) => c && typeof c === "object" && c.type === "tool_result");
|
|
15806
|
+
}
|
|
15807
|
+
var AI_GIST = 160;
|
|
15808
|
+
async function materializeSession(file2) {
|
|
15809
|
+
let raw;
|
|
15810
|
+
try {
|
|
15811
|
+
raw = await fs4.readFile(file2, "utf-8");
|
|
15812
|
+
} catch {
|
|
15813
|
+
return null;
|
|
15814
|
+
}
|
|
15815
|
+
const lines = [];
|
|
15816
|
+
let humanTurns = 0, humanChars = 0;
|
|
15817
|
+
const pendingQueued = [];
|
|
15818
|
+
let lastMode = "";
|
|
15819
|
+
const pushMarkers = (markers) => {
|
|
15820
|
+
for (const mk of markers) if (mk !== lines[lines.length - 1]) lines.push(mk);
|
|
15821
|
+
};
|
|
15822
|
+
let aiLastProse = "";
|
|
15823
|
+
const aiTools = /* @__PURE__ */ new Map();
|
|
15824
|
+
const flushAI = () => {
|
|
15825
|
+
if (!aiLastProse && aiTools.size === 0) return;
|
|
15826
|
+
const tools = [...aiTools.entries()].map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
|
|
15827
|
+
const gist = aiLastProse ? aiLastProse.length > AI_GIST ? aiLastProse.slice(0, AI_GIST) + "\u2026" : aiLastProse : "";
|
|
15828
|
+
const bits = [];
|
|
15829
|
+
if (gist) bits.push(gist);
|
|
15830
|
+
if (tools) bits.push(`ran ${tools}`);
|
|
15831
|
+
lines.push(`[AI: ${bits.join(" \xB7 ")}]`);
|
|
15832
|
+
aiLastProse = "";
|
|
15833
|
+
aiTools.clear();
|
|
15834
|
+
};
|
|
15835
|
+
for (const lineRaw of raw.split("\n")) {
|
|
15836
|
+
const line = lineRaw.trim();
|
|
15837
|
+
if (!line) continue;
|
|
15838
|
+
let e;
|
|
15839
|
+
try {
|
|
15840
|
+
e = JSON.parse(line);
|
|
15841
|
+
} catch {
|
|
15842
|
+
continue;
|
|
15843
|
+
}
|
|
15844
|
+
const type = e.type;
|
|
15845
|
+
if (type === "ai-title") continue;
|
|
15846
|
+
if (type === "mode") {
|
|
15847
|
+
flushAI();
|
|
15848
|
+
const m = e.mode;
|
|
15849
|
+
if (m && String(m) !== lastMode) {
|
|
15850
|
+
lastMode = String(m);
|
|
15851
|
+
lines.push(`[mode \u2192 ${m}]`);
|
|
15852
|
+
}
|
|
15853
|
+
continue;
|
|
15854
|
+
}
|
|
15855
|
+
if (type === "queue-operation") {
|
|
15856
|
+
if (e.operation === "enqueue" && typeof e.content === "string") {
|
|
15857
|
+
const { text: t, markers } = collapseInjected(e.content);
|
|
15858
|
+
if (t || markers.length) flushAI();
|
|
15859
|
+
pushMarkers(markers);
|
|
15860
|
+
if (t) {
|
|
15861
|
+
pendingQueued.push(t);
|
|
15862
|
+
lines.push(`>> (queued while AI working) ${t}`);
|
|
15863
|
+
}
|
|
15864
|
+
}
|
|
15865
|
+
continue;
|
|
15866
|
+
}
|
|
15867
|
+
if (type === "user") {
|
|
15868
|
+
if (isHarnessEntry(e)) continue;
|
|
15869
|
+
const content = e.message?.content;
|
|
15870
|
+
if (isToolResultOnly(content)) continue;
|
|
15871
|
+
const { text: t, markers } = collapseInjected(extractText(content));
|
|
15872
|
+
if (!t && !markers.length) continue;
|
|
15873
|
+
flushAI();
|
|
15874
|
+
pushMarkers(markers);
|
|
15875
|
+
if (!t) continue;
|
|
15876
|
+
humanTurns++;
|
|
15877
|
+
humanChars += t.length;
|
|
15878
|
+
const qi = pendingQueued.indexOf(t);
|
|
15879
|
+
if (qi >= 0) {
|
|
15880
|
+
pendingQueued.splice(qi, 1);
|
|
15881
|
+
continue;
|
|
15882
|
+
}
|
|
15883
|
+
lines.push(`>> ${t}`);
|
|
15884
|
+
continue;
|
|
15885
|
+
}
|
|
15886
|
+
if (type === "assistant") {
|
|
15887
|
+
const msg = e.message ?? {};
|
|
15888
|
+
let prose = "";
|
|
15889
|
+
if (Array.isArray(msg.content)) {
|
|
15890
|
+
for (const item of msg.content) {
|
|
15891
|
+
const it = item;
|
|
15892
|
+
if (it.type === "text" && it.text) prose += it.text;
|
|
15893
|
+
else if (it.type === "tool_use" && it.name) aiTools.set(it.name, (aiTools.get(it.name) ?? 0) + 1);
|
|
15894
|
+
}
|
|
15895
|
+
} else prose = extractText(msg.content);
|
|
15896
|
+
prose = prose.replace(/\s+/g, " ").trim();
|
|
15897
|
+
if (prose) aiLastProse = prose;
|
|
15898
|
+
continue;
|
|
15899
|
+
}
|
|
15900
|
+
}
|
|
15901
|
+
flushAI();
|
|
15902
|
+
return { text: lines.join("\n"), humanTurns, humanChars };
|
|
15903
|
+
}
|
|
15904
|
+
|
|
15905
|
+
// ../../lib/agents/coding/docsDir.ts
|
|
15906
|
+
async function writeScoreboard(codingDir, docs) {
|
|
15907
|
+
const gradesDir = path9.join(codingDir, "grades");
|
|
15908
|
+
let files = [];
|
|
15909
|
+
try {
|
|
15910
|
+
files = (await fs5.readdir(gradesDir)).filter((f) => f.endsWith(".json")).sort();
|
|
15911
|
+
} catch {
|
|
15912
|
+
return;
|
|
15913
|
+
}
|
|
15914
|
+
const byCriterion = /* @__PURE__ */ new Map();
|
|
15915
|
+
for (const f of files) {
|
|
15916
|
+
let g;
|
|
15917
|
+
try {
|
|
15918
|
+
g = JSON.parse(await fs5.readFile(path9.join(gradesDir, f), "utf8"));
|
|
15919
|
+
} catch {
|
|
15920
|
+
continue;
|
|
15921
|
+
}
|
|
15922
|
+
for (const c of g.criteria ?? []) {
|
|
15923
|
+
const s = c.score ?? c.bestEstimate;
|
|
15924
|
+
if (s == null) continue;
|
|
15925
|
+
const line = `L${s}${c.score == null ? "~" : ""} \xB7 ${(g.date ?? "").slice(0, 10)} \xB7 ${(g.title ?? g.sessionId ?? "").replace(/\n.*/s, "").slice(0, 60)} \xB7 ${g.sessionId} \u2014 ${(c.instance ?? "").slice(0, 110)}`;
|
|
15926
|
+
(byCriterion.get(c.key) ?? byCriterion.set(c.key, []).get(c.key)).push({ s, line });
|
|
15927
|
+
}
|
|
15928
|
+
}
|
|
15929
|
+
if (!byCriterion.size) return;
|
|
15930
|
+
const blocks = [...byCriterion.entries()].sort(([a], [b]) => a < b ? -1 : 1).map(
|
|
15931
|
+
([key, rows]) => `## ${key}
|
|
15932
|
+
${rows.sort((a, b) => b.s - a.s).map((r) => r.line).join("\n")}`
|
|
15933
|
+
);
|
|
15934
|
+
await fs5.writeFile(
|
|
15935
|
+
path9.join(docs, "_scoreboard.md"),
|
|
15936
|
+
`# Scoreboard \u2014 every graded session per criterion, best first.
|
|
15937
|
+
# Lx~ = estimate. Format: level \xB7 date \xB7 title \xB7 sessionId \u2014 graded instance.
|
|
15938
|
+
|
|
15939
|
+
${blocks.join("\n\n")}
|
|
15940
|
+
`
|
|
15941
|
+
);
|
|
15942
|
+
}
|
|
15943
|
+
async function ensureCodingDocs(codingDir, sessions) {
|
|
15944
|
+
const docs = path9.join(codingDir, "docs");
|
|
15945
|
+
await fs5.mkdir(docs, { recursive: true });
|
|
15946
|
+
const user = sessions.filter((s) => s.sessionId && !s.duplicateOf && (!("klass" in s) || s.klass === "interactive"));
|
|
15947
|
+
let written = 0;
|
|
15948
|
+
for (const s of user) {
|
|
15949
|
+
const out = path9.join(docs, `${s.sessionId}.txt`);
|
|
15950
|
+
try {
|
|
15951
|
+
await fs5.access(out);
|
|
15952
|
+
continue;
|
|
15953
|
+
} catch {
|
|
15954
|
+
}
|
|
15955
|
+
const mat = await materializeSession(s.file).catch(() => null);
|
|
15956
|
+
if (!mat?.text) continue;
|
|
15957
|
+
await fs5.writeFile(out, mat.text);
|
|
15958
|
+
written++;
|
|
15959
|
+
}
|
|
15960
|
+
const rows = user.sort((a, b) => (a.start ?? "") < (b.start ?? "") ? -1 : 1).map((s) => `${(s.start ?? "").slice(0, 10)} \xB7 ${(s.title ?? "").replace(/\n.*/s, "").slice(0, 80)} \xB7 ${s.sessionId}`);
|
|
15961
|
+
await fs5.writeFile(path9.join(docs, "_map.md"), rows.join("\n") + "\n");
|
|
15962
|
+
await writeScoreboard(codingDir, docs);
|
|
15963
|
+
if (written) console.log(`[docs] materialized ${written} new transcript(s) \u2192 ${docs}`);
|
|
15964
|
+
return docs;
|
|
15965
|
+
}
|
|
15966
|
+
function sourceLookupNote() {
|
|
15967
|
+
return `
|
|
15968
|
+
|
|
15969
|
+
SOURCE LOOKUP \u2014 you have Read/Grep/Glob over the working directory, which holds EVERYTHING known about this person's coding work. MAPS FIRST, grep second (the engine rule): docs/_scoreboard.md ranks every graded session per criterion, best first \u2014 one glance shows where the spikes/flair are, so start there when hunting peaks or checking whether a high mark is consistent or a one-off; day-digest.json is the day-by-day story of what they did in order \u2014 read the relevant days to get the arc before searching; docs/_map.md lists every session (date \xB7 title \xB7 sessionId). Then drill down: walkthroughs/<sessionId>.json is that session's phase-by-phase account (cheap, already distilled), grades/<sessionId>.json its graded findings with quotes, and docs/<sessionId>.txt the FULL transcript (">> " = the person, "[AI]" = the model) \u2014 the ground truth, read it when the distilled layers can't settle it. Other artifacts (flow.json, delegation/, expertise/, aggregate.json) are there too if a claim depends on them. The digest you were given is the spine \u2014 use lookups when a CLAIM-MOVING question cannot be settled from it (a moment you are about to headline, a promotion/depth call, an ambiguous engagement, whether detail was vision or boilerplate). VERIFY every verbatim quote you cite by finding it in the transcript first; if you cannot find it, do not use it. Look up what changes the output \u2014 do not re-read the whole corpus.`;
|
|
15970
|
+
}
|
|
15971
|
+
|
|
15972
|
+
// ../../lib/agents/coding/promptCache.ts
|
|
15973
|
+
import { createHash as createHash2 } from "crypto";
|
|
15974
|
+
import { promises as fs6 } from "fs";
|
|
15975
|
+
function promptSha(parts) {
|
|
15976
|
+
const h = createHash2("sha256");
|
|
15977
|
+
for (const p of parts) {
|
|
15978
|
+
h.update(p ?? "");
|
|
15979
|
+
h.update("\0");
|
|
15980
|
+
}
|
|
15981
|
+
return h.digest("hex").slice(0, 16);
|
|
15982
|
+
}
|
|
15983
|
+
async function reusableOutput(outPath, sha, valid, key = "promptSha") {
|
|
15984
|
+
try {
|
|
15985
|
+
const o = JSON.parse(await fs6.readFile(outPath, "utf8"));
|
|
15986
|
+
if (o[key] === sha && valid(o)) return o;
|
|
15987
|
+
} catch {
|
|
15988
|
+
}
|
|
15989
|
+
return null;
|
|
15990
|
+
}
|
|
15991
|
+
|
|
15757
15992
|
// ../../lib/agents/coding/agglomerate.ts
|
|
15758
15993
|
var LABEL = new Map(GRADED_CRITERIA.map((c) => [c.key, c.label]));
|
|
15759
15994
|
function renderTakes(grades) {
|
|
@@ -15815,41 +16050,52 @@ function validate(raw, n, costUsd) {
|
|
|
15815
16050
|
async function agglomerate(opts) {
|
|
15816
16051
|
let files = [];
|
|
15817
16052
|
try {
|
|
15818
|
-
files = (await
|
|
16053
|
+
files = (await fs7.readdir(opts.gradesDir)).filter((f) => f.endsWith(".json")).sort();
|
|
15819
16054
|
} catch {
|
|
15820
16055
|
return null;
|
|
15821
16056
|
}
|
|
15822
16057
|
const grades = [];
|
|
15823
16058
|
for (const f of files) {
|
|
15824
16059
|
try {
|
|
15825
|
-
grades.push(JSON.parse(await
|
|
16060
|
+
grades.push(JSON.parse(await fs7.readFile(path10.join(opts.gradesDir, f), "utf8")));
|
|
15826
16061
|
} catch {
|
|
15827
16062
|
}
|
|
15828
16063
|
}
|
|
15829
16064
|
if (grades.length === 0) return null;
|
|
15830
|
-
const
|
|
16065
|
+
const prompt = buildPrompt(grades);
|
|
16066
|
+
const system = opts.sourceDir ? SYSTEM + sourceLookupNote() : SYSTEM;
|
|
16067
|
+
const sha = promptSha([system, prompt, opts.model ?? "sonnet"]);
|
|
16068
|
+
if (!opts.refresh) {
|
|
16069
|
+
const prev = await reusableOutput(opts.outFile, sha, (o) => !!o.overall);
|
|
16070
|
+
if (prev) {
|
|
16071
|
+
console.log(`[agglomerate] inputs unchanged \u2014 reusing output from ${prev.generatedAt} (--refresh to regenerate)`);
|
|
16072
|
+
return prev;
|
|
16073
|
+
}
|
|
16074
|
+
}
|
|
16075
|
+
const sandbox = opts.sourceDir ?? await fs7.mkdtemp(path10.join(os2.tmpdir(), "ps-coding-agg-"));
|
|
15831
16076
|
try {
|
|
15832
16077
|
const run2 = await invokeAgent({
|
|
15833
|
-
prompt
|
|
15834
|
-
systemPrompt:
|
|
16078
|
+
prompt,
|
|
16079
|
+
systemPrompt: system,
|
|
15835
16080
|
addDir: sandbox,
|
|
15836
|
-
allowedTools: ["Read"],
|
|
15837
|
-
maxTurns: 6,
|
|
16081
|
+
allowedTools: opts.sourceDir ? ["Read", "Grep", "Glob"] : ["Read"],
|
|
16082
|
+
maxTurns: opts.sourceDir ? 10 : 6,
|
|
15838
16083
|
timeoutMs: 3e5,
|
|
15839
16084
|
model: opts.model ?? "sonnet"
|
|
15840
16085
|
});
|
|
15841
16086
|
const agg = validate(run2.json, grades.length, run2.costUsd);
|
|
15842
16087
|
if (!agg) return null;
|
|
15843
|
-
|
|
16088
|
+
agg.promptSha = sha;
|
|
16089
|
+
await fs7.writeFile(opts.outFile, JSON.stringify(agg, null, 2));
|
|
15844
16090
|
return agg;
|
|
15845
16091
|
} finally {
|
|
15846
|
-
await
|
|
16092
|
+
if (!opts.sourceDir) await fs7.rm(sandbox, { recursive: true, force: true }).catch(() => {
|
|
15847
16093
|
});
|
|
15848
16094
|
}
|
|
15849
16095
|
}
|
|
15850
16096
|
|
|
15851
16097
|
// ../../lib/agents/coding/profile.ts
|
|
15852
|
-
import
|
|
16098
|
+
import path11 from "path";
|
|
15853
16099
|
|
|
15854
16100
|
// ../../lib/agents/coding/walkthrough.ts
|
|
15855
16101
|
var IDLE_CAP_MS = 12 * 6e4;
|
|
@@ -15860,7 +16106,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
|
|
|
15860
16106
|
|
|
15861
16107
|
// ../../lib/calibration/index.ts
|
|
15862
16108
|
var DEFAULT_CALIBRATION = {
|
|
15863
|
-
version: "2026-07-
|
|
16109
|
+
version: "2026-07-14.2",
|
|
15864
16110
|
// = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
|
|
15865
16111
|
// src/grade/criteria.ts). A unit test fails loud when the rubric changes
|
|
15866
16112
|
// without this being updated (and re-pushed to the server).
|
|
@@ -15949,7 +16195,7 @@ var DEFAULT_CALIBRATION = {
|
|
|
15949
16195
|
}
|
|
15950
16196
|
],
|
|
15951
16197
|
codingTiers: {
|
|
15952
|
-
push: { median: 300, sigma:
|
|
16198
|
+
push: { median: 300, sigma: 0.91, tag: "estimated \u2014 log-normal fit", source: "Anthropic 2026 Claude Code study (400k sessions): median engaged user ~8 prompts/day at ~35 words \u2014 ~300 directed words/day; tail: a 1-in-1,000 user AVERAGES ~5k directed words/day (near-daily heavy dictation, clearly below the ~10k single-day record). AVERAGE over substantial days, cumulative not spiky." },
|
|
15953
16199
|
focus: { median: 0.08, sigma: 0.559, tag: "estimated \u2014 proxy-anchored", source: "median: Anthropic 20h/week engaged-user figure implies ~1h/day of true rapid exchange against an 8h working day; ceiling anchored to the ~4h/day deep-work limit (45% share = 1-in-1,000). AVERAGE share, cumulative not spiky." },
|
|
15954
16200
|
orchestration: { tag: "estimated \u2014 behavior bands", source: "no published concurrency distribution exists; ceiling anchored to the Claude Code lead's documented 10-15 parallel sessions" }
|
|
15955
16201
|
},
|
|
@@ -15982,12 +16228,18 @@ var DEFAULT_CALIBRATION = {
|
|
|
15982
16228
|
line: "the Claude Code lead runs 10\u201315 sessions at once; his #1 tip is 3\u20135 git worktrees in parallel"
|
|
15983
16229
|
},
|
|
15984
16230
|
throughput: {
|
|
15985
|
-
//
|
|
15986
|
-
//
|
|
15987
|
-
//
|
|
15988
|
-
//
|
|
15989
|
-
|
|
15990
|
-
|
|
16231
|
+
// Two DIFFERENT kinds of line (2026-07-14.2): topAvg is a PERCENTILE
|
|
16232
|
+
// claim — what a 1-in-1,000 user AVERAGES over substantial days (5k/day:
|
|
16233
|
+
// near-daily heavy dictation; a measured top dictating power user
|
|
16234
|
+
// averages ~3.9k). topPeak is NOT a percentile — it is the CEILING
|
|
16235
|
+
// reference, the wildest single days on record (~10k: a 14-16h
|
|
16236
|
+
// launch-day marathon), rendered as "wildest single days", never
|
|
16237
|
+
// "top X% peak". An avg-percentile and a peak-percentile can't both be
|
|
16238
|
+
// shown at a same-ish value (avg≈peak reads broken — user call), and a
|
|
16239
|
+
// peak PERCENTILE line is unknowable anyway; the record framing is
|
|
16240
|
+
// honest and keeps the visual gap.
|
|
16241
|
+
topAvgWordsPerDay: 5e3,
|
|
16242
|
+
topPeakWordsPerDay: 1e4,
|
|
15991
16243
|
benchLabel: "top 0.1%",
|
|
15992
16244
|
// No published "words typed/day" for heavy users — the real story is OUTPUT.
|
|
15993
16245
|
loopsHeadline: ">1,000,000 lines of Rust at 99.8% tests passing",
|
|
@@ -16004,8 +16256,8 @@ var BEST = DEFAULT_CALIBRATION.codingBenchmarks;
|
|
|
16004
16256
|
|
|
16005
16257
|
// ../../lib/agents/coding/profile.ts
|
|
16006
16258
|
var ROOT = process.cwd();
|
|
16007
|
-
var CODING_DIR = process.env.POLYMATH_DATA_DIR ?
|
|
16008
|
-
var GRADES =
|
|
16259
|
+
var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path11.join(process.env.POLYMATH_DATA_DIR, "coding") : path11.join(ROOT, ".data", "coding");
|
|
16260
|
+
var GRADES = path11.join(CODING_DIR, "grades");
|
|
16009
16261
|
|
|
16010
16262
|
// ../../scripts/coding-agglomerate.mts
|
|
16011
16263
|
var argv = process.argv.slice(2);
|
|
@@ -16013,7 +16265,9 @@ var model = argv.indexOf("--model") >= 0 ? argv[argv.indexOf("--model") + 1] : "
|
|
|
16013
16265
|
var CODING = CODING_DIR;
|
|
16014
16266
|
async function main() {
|
|
16015
16267
|
console.log(`[agglomerate] synthesizing across graded sessions on ${model}\u2026`);
|
|
16016
|
-
const
|
|
16268
|
+
const sessions = await fs8.readFile(path12.join(CODING, "sessions.json"), "utf8").then(JSON.parse).catch(() => []);
|
|
16269
|
+
await ensureCodingDocs(CODING, sessions);
|
|
16270
|
+
const agg = await agglomerate({ model, gradesDir: path12.join(CODING, "grades"), outFile: path12.join(CODING, "agglomerate.json"), refresh: process.argv.includes("--refresh"), sourceDir: CODING });
|
|
16017
16271
|
if (!agg) {
|
|
16018
16272
|
console.log("[agglomerate] no grades found \u2014 run coding-grade.mts first");
|
|
16019
16273
|
return;
|
|
@@ -431,7 +431,7 @@ var IDLE_CAP_MS = 12 * 6e4;
|
|
|
431
431
|
|
|
432
432
|
// ../../lib/calibration/index.ts
|
|
433
433
|
var DEFAULT_CALIBRATION = {
|
|
434
|
-
version: "2026-07-
|
|
434
|
+
version: "2026-07-14.2",
|
|
435
435
|
// = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
|
|
436
436
|
// src/grade/criteria.ts). A unit test fails loud when the rubric changes
|
|
437
437
|
// without this being updated (and re-pushed to the server).
|
|
@@ -520,7 +520,7 @@ var DEFAULT_CALIBRATION = {
|
|
|
520
520
|
}
|
|
521
521
|
],
|
|
522
522
|
codingTiers: {
|
|
523
|
-
push: { median: 300, sigma:
|
|
523
|
+
push: { median: 300, sigma: 0.91, tag: "estimated \u2014 log-normal fit", source: "Anthropic 2026 Claude Code study (400k sessions): median engaged user ~8 prompts/day at ~35 words \u2014 ~300 directed words/day; tail: a 1-in-1,000 user AVERAGES ~5k directed words/day (near-daily heavy dictation, clearly below the ~10k single-day record). AVERAGE over substantial days, cumulative not spiky." },
|
|
524
524
|
focus: { median: 0.08, sigma: 0.559, tag: "estimated \u2014 proxy-anchored", source: "median: Anthropic 20h/week engaged-user figure implies ~1h/day of true rapid exchange against an 8h working day; ceiling anchored to the ~4h/day deep-work limit (45% share = 1-in-1,000). AVERAGE share, cumulative not spiky." },
|
|
525
525
|
orchestration: { tag: "estimated \u2014 behavior bands", source: "no published concurrency distribution exists; ceiling anchored to the Claude Code lead's documented 10-15 parallel sessions" }
|
|
526
526
|
},
|
|
@@ -553,12 +553,18 @@ var DEFAULT_CALIBRATION = {
|
|
|
553
553
|
line: "the Claude Code lead runs 10\u201315 sessions at once; his #1 tip is 3\u20135 git worktrees in parallel"
|
|
554
554
|
},
|
|
555
555
|
throughput: {
|
|
556
|
-
//
|
|
557
|
-
//
|
|
558
|
-
//
|
|
559
|
-
//
|
|
560
|
-
|
|
561
|
-
|
|
556
|
+
// Two DIFFERENT kinds of line (2026-07-14.2): topAvg is a PERCENTILE
|
|
557
|
+
// claim — what a 1-in-1,000 user AVERAGES over substantial days (5k/day:
|
|
558
|
+
// near-daily heavy dictation; a measured top dictating power user
|
|
559
|
+
// averages ~3.9k). topPeak is NOT a percentile — it is the CEILING
|
|
560
|
+
// reference, the wildest single days on record (~10k: a 14-16h
|
|
561
|
+
// launch-day marathon), rendered as "wildest single days", never
|
|
562
|
+
// "top X% peak". An avg-percentile and a peak-percentile can't both be
|
|
563
|
+
// shown at a same-ish value (avg≈peak reads broken — user call), and a
|
|
564
|
+
// peak PERCENTILE line is unknowable anyway; the record framing is
|
|
565
|
+
// honest and keeps the visual gap.
|
|
566
|
+
topAvgWordsPerDay: 5e3,
|
|
567
|
+
topPeakWordsPerDay: 1e4,
|
|
562
568
|
benchLabel: "top 0.1%",
|
|
563
569
|
// No published "words typed/day" for heavy users — the real story is OUTPUT.
|
|
564
570
|
loopsHeadline: ">1,000,000 lines of Rust at 99.8% tests passing",
|
|
@@ -722,7 +728,7 @@ async function main() {
|
|
|
722
728
|
const flow = await flowStats();
|
|
723
729
|
const throughput = await throughputAvg(4);
|
|
724
730
|
const prev = await readJson("aggregate.json", {});
|
|
725
|
-
const out = { generatedAt: (/* @__PURE__ */ new Date()).toISOString(), ability, flow, throughput, ...prev.bigPicture ? { bigPicture: prev.bigPicture } : {} };
|
|
731
|
+
const out = { generatedAt: (/* @__PURE__ */ new Date()).toISOString(), ability, flow, throughput, ...prev.bigPicture ? { bigPicture: prev.bigPicture, ...prev.bigPictureSha ? { bigPictureSha: prev.bigPictureSha } : {} } : {} };
|
|
726
732
|
await fs2.writeFile(path2.join(CODING, "aggregate.json"), JSON.stringify(out, null, 2));
|
|
727
733
|
console.log("aggregate.json written" + (prev.bigPicture ? " (bigPicture preserved)" : " (no bigPicture present \u2014 run coding-nutshell.mts)"));
|
|
728
734
|
console.log(` Throughput AVG (start\u2192finish span \u2265${throughput.spanHourMin}h): ${throughput.score}/11 (${throughput.label}) \xB7 ${throughput.avgWordsPerDay} words/day over ${throughput.substantialDays}/${throughput.totalCodingDays} days \xB7 [peak ceiling was ${throughput.ceiling}]`);
|
|
@@ -1294,7 +1294,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
|
|
|
1294
1294
|
|
|
1295
1295
|
// ../../lib/calibration/index.ts
|
|
1296
1296
|
var DEFAULT_CALIBRATION = {
|
|
1297
|
-
version: "2026-07-
|
|
1297
|
+
version: "2026-07-14.2",
|
|
1298
1298
|
// = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
|
|
1299
1299
|
// src/grade/criteria.ts). A unit test fails loud when the rubric changes
|
|
1300
1300
|
// without this being updated (and re-pushed to the server).
|
|
@@ -1383,7 +1383,7 @@ var DEFAULT_CALIBRATION = {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
],
|
|
1385
1385
|
codingTiers: {
|
|
1386
|
-
push: { median: 300, sigma:
|
|
1386
|
+
push: { median: 300, sigma: 0.91, tag: "estimated \u2014 log-normal fit", source: "Anthropic 2026 Claude Code study (400k sessions): median engaged user ~8 prompts/day at ~35 words \u2014 ~300 directed words/day; tail: a 1-in-1,000 user AVERAGES ~5k directed words/day (near-daily heavy dictation, clearly below the ~10k single-day record). AVERAGE over substantial days, cumulative not spiky." },
|
|
1387
1387
|
focus: { median: 0.08, sigma: 0.559, tag: "estimated \u2014 proxy-anchored", source: "median: Anthropic 20h/week engaged-user figure implies ~1h/day of true rapid exchange against an 8h working day; ceiling anchored to the ~4h/day deep-work limit (45% share = 1-in-1,000). AVERAGE share, cumulative not spiky." },
|
|
1388
1388
|
orchestration: { tag: "estimated \u2014 behavior bands", source: "no published concurrency distribution exists; ceiling anchored to the Claude Code lead's documented 10-15 parallel sessions" }
|
|
1389
1389
|
},
|
|
@@ -1416,12 +1416,18 @@ var DEFAULT_CALIBRATION = {
|
|
|
1416
1416
|
line: "the Claude Code lead runs 10\u201315 sessions at once; his #1 tip is 3\u20135 git worktrees in parallel"
|
|
1417
1417
|
},
|
|
1418
1418
|
throughput: {
|
|
1419
|
-
//
|
|
1420
|
-
//
|
|
1421
|
-
//
|
|
1422
|
-
//
|
|
1423
|
-
|
|
1424
|
-
|
|
1419
|
+
// Two DIFFERENT kinds of line (2026-07-14.2): topAvg is a PERCENTILE
|
|
1420
|
+
// claim — what a 1-in-1,000 user AVERAGES over substantial days (5k/day:
|
|
1421
|
+
// near-daily heavy dictation; a measured top dictating power user
|
|
1422
|
+
// averages ~3.9k). topPeak is NOT a percentile — it is the CEILING
|
|
1423
|
+
// reference, the wildest single days on record (~10k: a 14-16h
|
|
1424
|
+
// launch-day marathon), rendered as "wildest single days", never
|
|
1425
|
+
// "top X% peak". An avg-percentile and a peak-percentile can't both be
|
|
1426
|
+
// shown at a same-ish value (avg≈peak reads broken — user call), and a
|
|
1427
|
+
// peak PERCENTILE line is unknowable anyway; the record framing is
|
|
1428
|
+
// honest and keeps the visual gap.
|
|
1429
|
+
topAvgWordsPerDay: 5e3,
|
|
1430
|
+
topPeakWordsPerDay: 1e4,
|
|
1425
1431
|
benchLabel: "top 0.1%",
|
|
1426
1432
|
// No published "words typed/day" for heavy users — the real story is OUTPUT.
|
|
1427
1433
|
loopsHeadline: ">1,000,000 lines of Rust at 99.8% tests passing",
|