polymath-society 0.2.4 → 0.2.6
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 +3132 -1694
- package/dist/engine/ingest-export.js +14 -8
- package/dist/engine/public-report.js +14 -8
- package/dist/index.js +1506 -57
- package/dist/pipeline/coding-agglomerate.js +439 -26
- package/dist/pipeline/coding-aggregate.js +313 -9
- package/dist/pipeline/coding-build.js +361 -8
- package/dist/pipeline/coding-coaching.js +274 -22
- package/dist/pipeline/coding-day-digest.js +351 -33
- package/dist/pipeline/coding-delegation.js +369 -22
- package/dist/pipeline/coding-expertise.js +456 -49
- package/dist/pipeline/coding-flow.js +308 -4
- package/dist/pipeline/coding-focus.js +16306 -0
- package/dist/pipeline/coding-frontier-detail.js +444 -26
- package/dist/pipeline/coding-frontier.js +356 -1
- package/dist/pipeline/coding-gap-dist.js +308 -4
- package/dist/pipeline/coding-gap.js +141 -40
- package/dist/pipeline/coding-grade.js +216 -26
- package/dist/pipeline/coding-nutshell.js +347 -17
- package/dist/pipeline/coding-projects.js +387 -7
- package/dist/pipeline/coding-walkthrough.js +324 -19
- package/dist/web/app.js +539 -113
- package/dist/web/styles.css +1 -1
- package/package.json +2 -2
|
@@ -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,51 +16050,229 @@ 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
|
|
|
16097
|
+
// ../../lib/agents/coding/profile.ts
|
|
16098
|
+
import path11 from "path";
|
|
16099
|
+
|
|
16100
|
+
// ../../lib/agents/coding/walkthrough.ts
|
|
16101
|
+
var IDLE_CAP_MS = 12 * 6e4;
|
|
16102
|
+
|
|
16103
|
+
// ../coding-core/dist/words.js
|
|
16104
|
+
var NOTE = "((ran|created|edited|read|wrote|searched) (a|an|\\d+) [a-z]+|updated todos)";
|
|
16105
|
+
var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s*thought for .{1,30}$`, "im");
|
|
16106
|
+
|
|
16107
|
+
// ../../lib/calibration/index.ts
|
|
16108
|
+
var DEFAULT_CALIBRATION = {
|
|
16109
|
+
version: "2026-07-14.2",
|
|
16110
|
+
// = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
|
|
16111
|
+
// src/grade/criteria.ts). A unit test fails loud when the rubric changes
|
|
16112
|
+
// without this being updated (and re-pushed to the server).
|
|
16113
|
+
rubricVersion: "f51b3a93a3",
|
|
16114
|
+
// Canonical scale = the one the product owner set for the public report
|
|
16115
|
+
// (11=0.01% … 8=2%), extended downward from the old report ladder. The old
|
|
16116
|
+
// CodeAnalysisView / npm-viewer maps (7→10%/15%, 6→25%/30%) were drift, not
|
|
16117
|
+
// intent.
|
|
16118
|
+
scoreBands: [
|
|
16119
|
+
{ score: 11, label: "Top 0.01%" },
|
|
16120
|
+
{ score: 10, label: "Top 0.1%" },
|
|
16121
|
+
{ score: 9, label: "Top 0.5%" },
|
|
16122
|
+
{ score: 8, label: "Top 2%" },
|
|
16123
|
+
{ score: 7, label: "Top 5%" },
|
|
16124
|
+
{ score: 6, label: "Top 15%" },
|
|
16125
|
+
{ score: 5, label: "Top 50%" },
|
|
16126
|
+
{ score: 4, label: "Top 65%" },
|
|
16127
|
+
{ score: 3, label: "Top 80%" },
|
|
16128
|
+
{ score: 2, label: "Top 90%" },
|
|
16129
|
+
{ score: 1, label: "Top 97%" }
|
|
16130
|
+
],
|
|
16131
|
+
minRankedScore: 6,
|
|
16132
|
+
benchmarkBands: [
|
|
16133
|
+
{
|
|
16134
|
+
level: "11",
|
|
16135
|
+
name: "Superhuman",
|
|
16136
|
+
rank: "Top 0.01%",
|
|
16137
|
+
oneIn: "1 in 10,000+",
|
|
16138
|
+
meaning: "Beyond the normal human ceiling for the trait \u2014 the genuine power-law outlier. Almost no one earns this; when the evidence shows it, it is scored, not rounded down.",
|
|
16139
|
+
foundIn: [
|
|
16140
|
+
"Fields Medal and Nobel-track researchers",
|
|
16141
|
+
"Founders of generational companies",
|
|
16142
|
+
"The handful of people a frontier field is named after"
|
|
16143
|
+
],
|
|
16144
|
+
maxTopPct: 0.01
|
|
16145
|
+
},
|
|
16146
|
+
{
|
|
16147
|
+
level: "10",
|
|
16148
|
+
name: "World-class",
|
|
16149
|
+
rank: "Top 0.1%",
|
|
16150
|
+
oneIn: "1 in 1,000",
|
|
16151
|
+
meaning: "Among the best alive at this trait \u2014 the level entire institutions are built to find.",
|
|
16152
|
+
foundIn: [
|
|
16153
|
+
"Researchers at frontier AI labs",
|
|
16154
|
+
"Faculty at top-5 research universities",
|
|
16155
|
+
"IMO / IOI medalists",
|
|
16156
|
+
"Founders backed by the top decile of venture firms"
|
|
16157
|
+
],
|
|
16158
|
+
maxTopPct: 0.1
|
|
16159
|
+
},
|
|
16160
|
+
{
|
|
16161
|
+
level: "9",
|
|
16162
|
+
name: "Exceptional",
|
|
16163
|
+
rank: "Top 1%",
|
|
16164
|
+
oneIn: "1 in 100",
|
|
16165
|
+
meaning: "Clearly exceptional \u2014 the strongest person on most strong teams.",
|
|
16166
|
+
foundIn: [
|
|
16167
|
+
"PhD students at top programs",
|
|
16168
|
+
"Early engineers at breakout startups",
|
|
16169
|
+
"YC-class founders",
|
|
16170
|
+
"National olympiad finalists"
|
|
16171
|
+
],
|
|
16172
|
+
maxTopPct: 1
|
|
16173
|
+
},
|
|
16174
|
+
{
|
|
16175
|
+
level: "8",
|
|
16176
|
+
name: "Strong",
|
|
16177
|
+
rank: "Top 10%",
|
|
16178
|
+
oneIn: "1 in 10",
|
|
16179
|
+
meaning: "Strong against the whole population \u2014 the best person in most rooms, not every room.",
|
|
16180
|
+
foundIn: [
|
|
16181
|
+
"Senior engineers at selective tech companies",
|
|
16182
|
+
"Graduates of demanding technical programs",
|
|
16183
|
+
"Operators who get promoted everywhere they go"
|
|
16184
|
+
],
|
|
16185
|
+
maxTopPct: 10
|
|
16186
|
+
},
|
|
16187
|
+
{
|
|
16188
|
+
level: "5",
|
|
16189
|
+
name: "Median",
|
|
16190
|
+
rank: "50th percentile",
|
|
16191
|
+
oneIn: "1 in 2",
|
|
16192
|
+
meaning: 'The middle of the general population. The reference class is all ~8 billion humans \u2014 so even "strong" above already means top 10% of everyone.',
|
|
16193
|
+
foundIn: ["The general population \u2014 most people, most places"],
|
|
16194
|
+
maxTopPct: 100
|
|
16195
|
+
}
|
|
16196
|
+
],
|
|
16197
|
+
codingTiers: {
|
|
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." },
|
|
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." },
|
|
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" }
|
|
16201
|
+
},
|
|
16202
|
+
codingBenchmarks: {
|
|
16203
|
+
flow: {
|
|
16204
|
+
// typical knowledge worker ≈ 35% of an 8h day focused; ~4h/day is the
|
|
16205
|
+
// recognized deep-work ceiling (Newport) ≈ 50% — most sit far below it.
|
|
16206
|
+
typicalPctOfDay: 0.35,
|
|
16207
|
+
topPctOfDay: 0.5,
|
|
16208
|
+
tag: "measured",
|
|
16209
|
+
source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling)",
|
|
16210
|
+
line: "the best spend ~half the workday in true deep flow; ~4h/day is the human ceiling"
|
|
16211
|
+
},
|
|
16212
|
+
longestRun: {
|
|
16213
|
+
typicalHours: 0.67,
|
|
16214
|
+
// ~40 min before the average worker is interrupted
|
|
16215
|
+
topHours: 4,
|
|
16216
|
+
tag: "measured",
|
|
16217
|
+
source: "RescueTime (avg max ~40 min focus before interruption) \xB7 deep-work single-block ceiling ~3\u20134h",
|
|
16218
|
+
line: "a top performer can hold a single ~3\u20134h uninterrupted block; the average worker breaks at ~40 min"
|
|
16219
|
+
},
|
|
16220
|
+
parallelism: {
|
|
16221
|
+
topMaxConcurrent: 12,
|
|
16222
|
+
// Boris Cherny ~10–15 interactive sessions
|
|
16223
|
+
topAvgConcurrent: 6,
|
|
16224
|
+
// time-weighted average while active (anecdotal, same source)
|
|
16225
|
+
worktreesTip: "3\u20135 git worktrees at once",
|
|
16226
|
+
tag: "anecdotal",
|
|
16227
|
+
source: "Boris Cherny (Claude Code lead, Anthropic): ~10\u201315 concurrent sessions, 'dozens of Claudes running at all times'; 3\u20135 worktrees = 'the single biggest productivity unlock'",
|
|
16228
|
+
line: "the Claude Code lead runs 10\u201315 sessions at once; his #1 tip is 3\u20135 git worktrees in parallel"
|
|
16229
|
+
},
|
|
16230
|
+
throughput: {
|
|
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,
|
|
16243
|
+
benchLabel: "top 0.1%",
|
|
16244
|
+
// No published "words typed/day" for heavy users — the real story is OUTPUT.
|
|
16245
|
+
loopsHeadline: ">1,000,000 lines of Rust at 99.8% tests passing",
|
|
16246
|
+
loopsDetail: "the Bun runtime was ported Zig\u2192Rust largely autonomously \u2014 hundreds of parallel subagents, two AI reviewers per file",
|
|
16247
|
+
tag: "measured",
|
|
16248
|
+
source: "The Register, May 2026 (Bun Zig\u2192Rust rewrite)",
|
|
16249
|
+
line: "autonomous fleets ported >1M lines of Rust at 99.8% tests passing; a while-loop agent delivered a $50k contract for $297 of compute"
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
};
|
|
16253
|
+
|
|
16254
|
+
// ../../lib/agents/coding/benchmarks.ts
|
|
16255
|
+
var BEST = DEFAULT_CALIBRATION.codingBenchmarks;
|
|
16256
|
+
|
|
16257
|
+
// ../../lib/agents/coding/profile.ts
|
|
16258
|
+
var ROOT = process.cwd();
|
|
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");
|
|
16261
|
+
|
|
15851
16262
|
// ../../scripts/coding-agglomerate.mts
|
|
15852
16263
|
var argv = process.argv.slice(2);
|
|
15853
16264
|
var model = argv.indexOf("--model") >= 0 ? argv[argv.indexOf("--model") + 1] : "sonnet";
|
|
15854
|
-
var CODING =
|
|
16265
|
+
var CODING = CODING_DIR;
|
|
15855
16266
|
async function main() {
|
|
15856
16267
|
console.log(`[agglomerate] synthesizing across graded sessions on ${model}\u2026`);
|
|
15857
|
-
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 });
|
|
15858
16271
|
if (!agg) {
|
|
15859
16272
|
console.log("[agglomerate] no grades found \u2014 run coding-grade.mts first");
|
|
15860
16273
|
return;
|
|
15861
16274
|
}
|
|
15862
|
-
console.log(`[agglomerate] ${agg.sessionsUsed} sessions \xB7 ${agg.criteria.length} criteria \xB7 ${agg.signatureMoves.length} signature moves
|
|
16275
|
+
console.log(`[agglomerate] ${agg.sessionsUsed} sessions \xB7 ${agg.criteria.length} criteria \xB7 ${agg.signatureMoves.length} signature moves`);
|
|
15863
16276
|
console.log(`
|
|
15864
16277
|
OVERALL:
|
|
15865
16278
|
${agg.overall}
|