polymath-society 0.2.20 → 0.2.22
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 +23943 -21630
- package/dist/engine/chat-loops.js +8 -1
- package/dist/engine/exp-allfacets.js +8 -1
- package/dist/engine/exp-person.js +8 -1
- package/dist/engine/exp-pipeline.js +8 -1
- package/dist/engine/ingest-export.js +7 -6
- package/dist/engine/peak-demos.js +8 -1
- package/dist/engine/person-dimension-summary.js +8 -1
- package/dist/engine/person-facet-lines.js +8 -1
- package/dist/engine/person-headline.js +8 -1
- package/dist/engine/person-report.js +8 -1
- package/dist/engine/person-self-image.js +8 -1
- package/dist/engine/public-report.js +15 -7
- package/dist/engine/run-analysis.js +8 -1
- package/dist/engine/run-tagger.js +8 -1
- package/dist/index.js +19647 -17969
- package/dist/pipeline/coding-agglomerate.js +826 -82
- package/dist/pipeline/coding-aggregate.js +307 -23
- package/dist/pipeline/coding-build.js +453 -95
- package/dist/pipeline/coding-coaching.js +479 -88
- package/dist/pipeline/coding-day-digest.js +308 -36
- package/dist/pipeline/coding-delegation.js +376 -52
- package/dist/pipeline/coding-expertise.js +356 -62
- package/dist/pipeline/coding-flow.js +288 -15
- package/dist/pipeline/coding-focus.js +371 -51
- package/dist/pipeline/coding-frontier-detail.js +344 -50
- package/dist/pipeline/coding-frontier.js +7 -6
- package/dist/pipeline/coding-gap-dist.js +288 -15
- package/dist/pipeline/coding-gap.js +507 -115
- package/dist/pipeline/coding-grade.js +342 -45
- package/dist/pipeline/coding-growth.js +17041 -0
- package/dist/pipeline/coding-nutshell.js +15 -7
- package/dist/pipeline/coding-projects.js +7 -6
- package/dist/pipeline/coding-walkthrough.js +317 -37
- package/dist/pipeline/coding-workbrief.js +16387 -0
- package/dist/web/app.js +2095 -1395
- package/dist/web/styles.css +1 -1
- package/package.json +1 -1
|
@@ -134,13 +134,13 @@ var require_secure_json_parse = __commonJS({
|
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
// ../../scripts/coding-grade.mts
|
|
137
|
-
import { promises as
|
|
138
|
-
import
|
|
137
|
+
import { promises as fs7 } from "fs";
|
|
138
|
+
import path12 from "path";
|
|
139
139
|
|
|
140
140
|
// ../../lib/agents/coding/grade.ts
|
|
141
|
-
import { promises as
|
|
142
|
-
import
|
|
143
|
-
import
|
|
141
|
+
import { promises as fs6 } from "fs";
|
|
142
|
+
import os3 from "os";
|
|
143
|
+
import path10 from "path";
|
|
144
144
|
|
|
145
145
|
// ../../lib/agents/shared/agent.ts
|
|
146
146
|
import { readFileSync } from "fs";
|
|
@@ -508,6 +508,13 @@ ${report}`);
|
|
|
508
508
|
}
|
|
509
509
|
|
|
510
510
|
// ../../lib/agents/shared/codexAdapter.ts
|
|
511
|
+
var CODEX_DEFAULT_MODEL = "gpt-5.5";
|
|
512
|
+
var CODEX_MINI_MODEL = "gpt-5.4-mini";
|
|
513
|
+
function mapCodexTier(model, env = process.env) {
|
|
514
|
+
if (model && !/^(claude|haiku|sonnet|opus)/i.test(model)) return model;
|
|
515
|
+
if (model && /^haiku/i.test(model)) return env.POLYMATH_CODEX_MODEL_MINI || CODEX_MINI_MODEL;
|
|
516
|
+
return env.POLYMATH_CODEX_MODEL || CODEX_DEFAULT_MODEL;
|
|
517
|
+
}
|
|
511
518
|
function composePrompt(inv, roots) {
|
|
512
519
|
return [
|
|
513
520
|
inv.systemPrompt ? `<system>
|
|
@@ -548,7 +555,7 @@ var codexAdapter = {
|
|
|
548
555
|
"read-only",
|
|
549
556
|
"--json"
|
|
550
557
|
];
|
|
551
|
-
|
|
558
|
+
args.push("--model", mapCodexTier(inv.model));
|
|
552
559
|
args.push(composePrompt(inv, roots));
|
|
553
560
|
const started = Date.now();
|
|
554
561
|
const toolCalls = [];
|
|
@@ -2176,8 +2183,8 @@ function getErrorMap() {
|
|
|
2176
2183
|
|
|
2177
2184
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
2178
2185
|
var makeIssue = (params) => {
|
|
2179
|
-
const { data, path:
|
|
2180
|
-
const fullPath = [...
|
|
2186
|
+
const { data, path: path13, errorMaps, issueData } = params;
|
|
2187
|
+
const fullPath = [...path13, ...issueData.path || []];
|
|
2181
2188
|
const fullIssue = {
|
|
2182
2189
|
...issueData,
|
|
2183
2190
|
path: fullPath
|
|
@@ -2293,11 +2300,11 @@ var errorUtil;
|
|
|
2293
2300
|
|
|
2294
2301
|
// ../../node_modules/zod/v3/types.js
|
|
2295
2302
|
var ParseInputLazyPath = class {
|
|
2296
|
-
constructor(parent, value,
|
|
2303
|
+
constructor(parent, value, path13, key) {
|
|
2297
2304
|
this._cachedPath = [];
|
|
2298
2305
|
this.parent = parent;
|
|
2299
2306
|
this.data = value;
|
|
2300
|
-
this._path =
|
|
2307
|
+
this._path = path13;
|
|
2301
2308
|
this._key = key;
|
|
2302
2309
|
}
|
|
2303
2310
|
get path() {
|
|
@@ -15084,39 +15091,39 @@ function createOpenAI(options = {}) {
|
|
|
15084
15091
|
});
|
|
15085
15092
|
const createChatModel = (modelId, settings = {}) => new OpenAIChatLanguageModel(modelId, settings, {
|
|
15086
15093
|
provider: `${providerName}.chat`,
|
|
15087
|
-
url: ({ path:
|
|
15094
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15088
15095
|
headers: getHeaders,
|
|
15089
15096
|
compatibility,
|
|
15090
15097
|
fetch: options.fetch
|
|
15091
15098
|
});
|
|
15092
15099
|
const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
|
|
15093
15100
|
provider: `${providerName}.completion`,
|
|
15094
|
-
url: ({ path:
|
|
15101
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15095
15102
|
headers: getHeaders,
|
|
15096
15103
|
compatibility,
|
|
15097
15104
|
fetch: options.fetch
|
|
15098
15105
|
});
|
|
15099
15106
|
const createEmbeddingModel = (modelId, settings = {}) => new OpenAIEmbeddingModel(modelId, settings, {
|
|
15100
15107
|
provider: `${providerName}.embedding`,
|
|
15101
|
-
url: ({ path:
|
|
15108
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15102
15109
|
headers: getHeaders,
|
|
15103
15110
|
fetch: options.fetch
|
|
15104
15111
|
});
|
|
15105
15112
|
const createImageModel = (modelId, settings = {}) => new OpenAIImageModel(modelId, settings, {
|
|
15106
15113
|
provider: `${providerName}.image`,
|
|
15107
|
-
url: ({ path:
|
|
15114
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15108
15115
|
headers: getHeaders,
|
|
15109
15116
|
fetch: options.fetch
|
|
15110
15117
|
});
|
|
15111
15118
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
15112
15119
|
provider: `${providerName}.transcription`,
|
|
15113
|
-
url: ({ path:
|
|
15120
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15114
15121
|
headers: getHeaders,
|
|
15115
15122
|
fetch: options.fetch
|
|
15116
15123
|
});
|
|
15117
15124
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
15118
15125
|
provider: `${providerName}.speech`,
|
|
15119
|
-
url: ({ path:
|
|
15126
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15120
15127
|
headers: getHeaders,
|
|
15121
15128
|
fetch: options.fetch
|
|
15122
15129
|
});
|
|
@@ -15137,7 +15144,7 @@ function createOpenAI(options = {}) {
|
|
|
15137
15144
|
const createResponsesModel = (modelId) => {
|
|
15138
15145
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
15139
15146
|
provider: `${providerName}.responses`,
|
|
15140
|
-
url: ({ path:
|
|
15147
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15141
15148
|
headers: getHeaders,
|
|
15142
15149
|
fetch: options.fetch
|
|
15143
15150
|
});
|
|
@@ -15856,15 +15863,16 @@ var GRADED_CRITERIA = CODING_CRITERIA.filter((c) => c.graded);
|
|
|
15856
15863
|
var RUBRIC_FINGERPRINT = rubricFingerprint(GRADED_CRITERIA);
|
|
15857
15864
|
|
|
15858
15865
|
// ../../lib/agents/coding/materialize.ts
|
|
15859
|
-
import { promises as
|
|
15866
|
+
import { promises as fs5 } from "fs";
|
|
15860
15867
|
|
|
15861
15868
|
// ../coding-core/dist/injected.js
|
|
15869
|
+
var SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
15862
15870
|
function isHarnessEntry(e) {
|
|
15863
15871
|
return e.isMeta === true || e.isCompactSummary === true;
|
|
15864
15872
|
}
|
|
15865
15873
|
|
|
15866
15874
|
// ../coding-core/dist/codex.js
|
|
15867
|
-
var
|
|
15875
|
+
var SYSTEM_REMINDER_RE2 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
15868
15876
|
var CODEX_INJECTED_TEXT_RE = /^\s*(<(environment_context|user_instructions|ENVIRONMENT_CONTEXT|turn_aborted)\b|#\s*AGENTS\.md instructions\b)/;
|
|
15869
15877
|
function isCodexInjectedUserText(text2) {
|
|
15870
15878
|
return CODEX_INJECTED_TEXT_RE.test(text2);
|
|
@@ -15927,7 +15935,7 @@ function extractCodexEvents(raw) {
|
|
|
15927
15935
|
const ptype = p.type;
|
|
15928
15936
|
if (ptype === "message") {
|
|
15929
15937
|
const role = p.role;
|
|
15930
|
-
const text2 = codexContentText(p.content).replace(
|
|
15938
|
+
const text2 = codexContentText(p.content).replace(SYSTEM_REMINDER_RE2, "").trim();
|
|
15931
15939
|
if (!text2)
|
|
15932
15940
|
continue;
|
|
15933
15941
|
if (role === "user") {
|
|
@@ -15954,8 +15962,288 @@ function extractCodexEvents(raw) {
|
|
|
15954
15962
|
return out;
|
|
15955
15963
|
}
|
|
15956
15964
|
|
|
15965
|
+
// ../coding-core/dist/cursor.js
|
|
15966
|
+
import { promises as fs4 } from "fs";
|
|
15967
|
+
var NODE_SQLITE = "node:sqlite";
|
|
15968
|
+
async function openCursorSqlite(dbPath) {
|
|
15969
|
+
try {
|
|
15970
|
+
await fs4.access(dbPath);
|
|
15971
|
+
} catch {
|
|
15972
|
+
return null;
|
|
15973
|
+
}
|
|
15974
|
+
let mod;
|
|
15975
|
+
try {
|
|
15976
|
+
mod = await import(NODE_SQLITE);
|
|
15977
|
+
} catch {
|
|
15978
|
+
return null;
|
|
15979
|
+
}
|
|
15980
|
+
const DatabaseSync = mod?.DatabaseSync;
|
|
15981
|
+
if (!DatabaseSync)
|
|
15982
|
+
return null;
|
|
15983
|
+
let db;
|
|
15984
|
+
try {
|
|
15985
|
+
db = new DatabaseSync(dbPath, { readOnly: true });
|
|
15986
|
+
} catch {
|
|
15987
|
+
try {
|
|
15988
|
+
db = new DatabaseSync(dbPath);
|
|
15989
|
+
} catch {
|
|
15990
|
+
return null;
|
|
15991
|
+
}
|
|
15992
|
+
}
|
|
15993
|
+
const asText = (v) => v == null ? null : typeof v === "string" ? v : Buffer.from(v).toString("utf-8");
|
|
15994
|
+
return {
|
|
15995
|
+
prefix(prefix) {
|
|
15996
|
+
try {
|
|
15997
|
+
const rows = db.prepare("SELECT key, value FROM cursorDiskKV WHERE key LIKE ? ESCAPE '\\'").all(likePrefix(prefix));
|
|
15998
|
+
return rows.map((r) => ({ key: r.key, value: asText(r.value) ?? "" }));
|
|
15999
|
+
} catch {
|
|
16000
|
+
return [];
|
|
16001
|
+
}
|
|
16002
|
+
},
|
|
16003
|
+
get(key) {
|
|
16004
|
+
try {
|
|
16005
|
+
const row = db.prepare("SELECT value FROM cursorDiskKV WHERE key = ?").get(key);
|
|
16006
|
+
return row ? asText(row.value) : null;
|
|
16007
|
+
} catch {
|
|
16008
|
+
return null;
|
|
16009
|
+
}
|
|
16010
|
+
},
|
|
16011
|
+
close() {
|
|
16012
|
+
try {
|
|
16013
|
+
db.close();
|
|
16014
|
+
} catch {
|
|
16015
|
+
}
|
|
16016
|
+
}
|
|
16017
|
+
};
|
|
16018
|
+
}
|
|
16019
|
+
function likePrefix(prefix) {
|
|
16020
|
+
return prefix.replace(/[\\%_]/g, (c) => "\\" + c) + "%";
|
|
16021
|
+
}
|
|
16022
|
+
var CURSOR_USER_QUERY_RE = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/;
|
|
16023
|
+
function cleanUserText(raw) {
|
|
16024
|
+
let t = raw.replace(SYSTEM_REMINDER_RE, "");
|
|
16025
|
+
const m = t.match(CURSOR_USER_QUERY_RE);
|
|
16026
|
+
if (m)
|
|
16027
|
+
t = m[1];
|
|
16028
|
+
return t.trim();
|
|
16029
|
+
}
|
|
16030
|
+
var msFrom = (v) => {
|
|
16031
|
+
if (typeof v === "number" && Number.isFinite(v))
|
|
16032
|
+
return v;
|
|
16033
|
+
if (typeof v === "string") {
|
|
16034
|
+
const n = Date.parse(v);
|
|
16035
|
+
return Number.isFinite(n) ? n : null;
|
|
16036
|
+
}
|
|
16037
|
+
return null;
|
|
16038
|
+
};
|
|
16039
|
+
function readCursorComposer(db, composerId) {
|
|
16040
|
+
const cdRaw = db.get(`composerData:${composerId}`);
|
|
16041
|
+
if (!cdRaw)
|
|
16042
|
+
return null;
|
|
16043
|
+
let cd;
|
|
16044
|
+
try {
|
|
16045
|
+
cd = JSON.parse(cdRaw);
|
|
16046
|
+
} catch {
|
|
16047
|
+
return null;
|
|
16048
|
+
}
|
|
16049
|
+
const headers = Array.isArray(cd.fullConversationHeadersOnly) ? cd.fullConversationHeadersOnly : [];
|
|
16050
|
+
if (headers.length === 0)
|
|
16051
|
+
return null;
|
|
16052
|
+
const bubbles = /* @__PURE__ */ new Map();
|
|
16053
|
+
for (const row of db.prefix(`bubbleId:${composerId}:`)) {
|
|
16054
|
+
const bid = row.key.slice(`bubbleId:${composerId}:`.length);
|
|
16055
|
+
try {
|
|
16056
|
+
bubbles.set(bid, JSON.parse(row.value));
|
|
16057
|
+
} catch {
|
|
16058
|
+
}
|
|
16059
|
+
}
|
|
16060
|
+
const turns = [];
|
|
16061
|
+
let clock = msFrom(cd.createdAt) ?? 0;
|
|
16062
|
+
for (const h of headers) {
|
|
16063
|
+
const b = bubbles.get(h.bubbleId);
|
|
16064
|
+
if (!b)
|
|
16065
|
+
continue;
|
|
16066
|
+
const type = h.type === 1 ? 1 : 2;
|
|
16067
|
+
const tool2 = type === 2 && b.toolFormerData && typeof b.toolFormerData.name === "string" ? b.toolFormerData.name : null;
|
|
16068
|
+
const rawText = typeof b.text === "string" ? b.text : "";
|
|
16069
|
+
const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
|
|
16070
|
+
if (!text2 && !tool2)
|
|
16071
|
+
continue;
|
|
16072
|
+
const t = msFrom(b.createdAt);
|
|
16073
|
+
clock = Math.max(clock, t ?? clock + 1);
|
|
16074
|
+
const model = b.modelInfo && typeof b.modelInfo.modelName === "string" ? b.modelInfo.modelName : null;
|
|
16075
|
+
turns.push({ t: clock, type, text: text2, tool: tool2, model });
|
|
16076
|
+
}
|
|
16077
|
+
if (turns.length === 0)
|
|
16078
|
+
return null;
|
|
16079
|
+
const gitRepo = Array.isArray(cd.trackedGitRepos) && cd.trackedGitRepos[0] && typeof cd.trackedGitRepos[0].repoPath === "string" ? cd.trackedGitRepos[0].repoPath : null;
|
|
16080
|
+
return {
|
|
16081
|
+
composerId,
|
|
16082
|
+
createdAt: msFrom(cd.createdAt),
|
|
16083
|
+
updatedAt: msFrom(cd.lastUpdatedAt),
|
|
16084
|
+
name: typeof cd.name === "string" && cd.name.trim() ? cd.name.trim() : null,
|
|
16085
|
+
gitRepo,
|
|
16086
|
+
turns
|
|
16087
|
+
};
|
|
16088
|
+
}
|
|
16089
|
+
function sniffCursorRaw(raw) {
|
|
16090
|
+
for (const lineRaw of raw.split("\n")) {
|
|
16091
|
+
const line = lineRaw.trim();
|
|
16092
|
+
if (!line)
|
|
16093
|
+
continue;
|
|
16094
|
+
try {
|
|
16095
|
+
const e = JSON.parse(line);
|
|
16096
|
+
return (e.role === "user" || e.role === "assistant") && typeof e.message === "object" && e.message !== null && "content" in e.message && !("type" in e);
|
|
16097
|
+
} catch {
|
|
16098
|
+
return false;
|
|
16099
|
+
}
|
|
16100
|
+
}
|
|
16101
|
+
return false;
|
|
16102
|
+
}
|
|
16103
|
+
function jsonlText(content) {
|
|
16104
|
+
const parts = [];
|
|
16105
|
+
const tools = [];
|
|
16106
|
+
if (Array.isArray(content)) {
|
|
16107
|
+
for (const item of content) {
|
|
16108
|
+
if (!item || typeof item !== "object")
|
|
16109
|
+
continue;
|
|
16110
|
+
const it = item;
|
|
16111
|
+
if (it.type === "text" && it.text)
|
|
16112
|
+
parts.push(it.text);
|
|
16113
|
+
else if (it.type === "tool_use" && it.name)
|
|
16114
|
+
tools.push(it.name);
|
|
16115
|
+
}
|
|
16116
|
+
} else if (typeof content === "string")
|
|
16117
|
+
parts.push(content);
|
|
16118
|
+
return { text: parts.join("\n"), tools };
|
|
16119
|
+
}
|
|
16120
|
+
function parseCursorJsonl(raw, base) {
|
|
16121
|
+
const turns = [];
|
|
16122
|
+
let clock = base;
|
|
16123
|
+
for (const lineRaw of raw.split("\n")) {
|
|
16124
|
+
const line = lineRaw.trim();
|
|
16125
|
+
if (!line)
|
|
16126
|
+
continue;
|
|
16127
|
+
let e;
|
|
16128
|
+
try {
|
|
16129
|
+
e = JSON.parse(line);
|
|
16130
|
+
} catch {
|
|
16131
|
+
continue;
|
|
16132
|
+
}
|
|
16133
|
+
if (e.role !== "user" && e.role !== "assistant")
|
|
16134
|
+
continue;
|
|
16135
|
+
const { text: rawText, tools } = jsonlText(e.message?.content);
|
|
16136
|
+
const type = e.role === "user" ? 1 : 2;
|
|
16137
|
+
const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
|
|
16138
|
+
if (type === 2 && tools.length) {
|
|
16139
|
+
for (const tool2 of tools) {
|
|
16140
|
+
clock += 1;
|
|
16141
|
+
turns.push({ t: clock, type: 2, text: "", tool: tool2, model: null });
|
|
16142
|
+
}
|
|
16143
|
+
}
|
|
16144
|
+
if (!text2)
|
|
16145
|
+
continue;
|
|
16146
|
+
clock += 1;
|
|
16147
|
+
turns.push({ t: clock, type, text: text2, tool: null, model: null });
|
|
16148
|
+
}
|
|
16149
|
+
if (turns.length === 0)
|
|
16150
|
+
return null;
|
|
16151
|
+
return { composerId: "", createdAt: base, updatedAt: clock, name: null, gitRepo: null, turns };
|
|
16152
|
+
}
|
|
16153
|
+
var AI_GIST = 500;
|
|
16154
|
+
function renderCursorTranscript(c) {
|
|
16155
|
+
const lines = [];
|
|
16156
|
+
let humanTurns = 0, humanChars = 0;
|
|
16157
|
+
let aiProse = "";
|
|
16158
|
+
const aiTools = /* @__PURE__ */ new Map();
|
|
16159
|
+
const flushAI = () => {
|
|
16160
|
+
if (!aiProse && aiTools.size === 0)
|
|
16161
|
+
return;
|
|
16162
|
+
const tools = [...aiTools.entries()].map(([n, k]) => k > 1 ? `${n}\xD7${k}` : n).join(", ");
|
|
16163
|
+
const gist = aiProse ? aiProse.length > AI_GIST ? aiProse.slice(0, AI_GIST) + "\u2026" : aiProse : "";
|
|
16164
|
+
const bits = [];
|
|
16165
|
+
if (gist)
|
|
16166
|
+
bits.push(gist);
|
|
16167
|
+
if (tools)
|
|
16168
|
+
bits.push(`ran ${tools}`);
|
|
16169
|
+
lines.push(`[AI: ${bits.join(" \xB7 ")}]`);
|
|
16170
|
+
aiProse = "";
|
|
16171
|
+
aiTools.clear();
|
|
16172
|
+
};
|
|
16173
|
+
for (const turn of c.turns) {
|
|
16174
|
+
if (turn.type === 1) {
|
|
16175
|
+
flushAI();
|
|
16176
|
+
humanTurns++;
|
|
16177
|
+
humanChars += turn.text.length;
|
|
16178
|
+
lines.push(`>> ${turn.text}`);
|
|
16179
|
+
} else {
|
|
16180
|
+
if (turn.tool)
|
|
16181
|
+
aiTools.set(turn.tool, (aiTools.get(turn.tool) ?? 0) + 1);
|
|
16182
|
+
if (turn.text)
|
|
16183
|
+
aiProse = turn.text.replace(/\s+/g, " ").trim();
|
|
16184
|
+
}
|
|
16185
|
+
}
|
|
16186
|
+
flushAI();
|
|
16187
|
+
return { text: lines.join("\n"), humanTurns, humanChars };
|
|
16188
|
+
}
|
|
16189
|
+
function composerIdFromFile(file2) {
|
|
16190
|
+
const m = file2.match(/agent-transcripts\/([^/]+)\/[^/]+\.jsonl$/);
|
|
16191
|
+
return m ? m[1] : null;
|
|
16192
|
+
}
|
|
16193
|
+
async function loadCursorComposer(file2, raw, dbPath) {
|
|
16194
|
+
const cid = composerIdFromFile(file2);
|
|
16195
|
+
if (cid && dbPath) {
|
|
16196
|
+
const db = await openCursorSqlite(dbPath);
|
|
16197
|
+
if (db) {
|
|
16198
|
+
try {
|
|
16199
|
+
const c = readCursorComposer(db, cid);
|
|
16200
|
+
if (c)
|
|
16201
|
+
return c;
|
|
16202
|
+
} finally {
|
|
16203
|
+
db.close();
|
|
16204
|
+
}
|
|
16205
|
+
}
|
|
16206
|
+
}
|
|
16207
|
+
return parseCursorJsonl(raw, 0);
|
|
16208
|
+
}
|
|
16209
|
+
|
|
16210
|
+
// ../coding-core/dist/raw.js
|
|
16211
|
+
import path9 from "path";
|
|
16212
|
+
import os2 from "os";
|
|
16213
|
+
var SOURCE_ROOT_ENV_VARS = [
|
|
16214
|
+
"CLAUDE_PROJECTS_DIR",
|
|
16215
|
+
"CODEX_SESSIONS_DIR",
|
|
16216
|
+
"CURSOR_WORKSPACE_DIR",
|
|
16217
|
+
"CURSOR_PROJECTS_DIR",
|
|
16218
|
+
// Cursor's globalStorage dir (holds state.vscdb — the composer bubbles that
|
|
16219
|
+
// carry a Cursor session's real per-turn timestamps + content). Same
|
|
16220
|
+
// isolation contract: overriding any root disables every unset source.
|
|
16221
|
+
"CURSOR_GLOBAL_DIR"
|
|
16222
|
+
];
|
|
16223
|
+
var anyRootOverridden = () => SOURCE_ROOT_ENV_VARS.some((v) => !!process.env[v]);
|
|
16224
|
+
function resolveSourceRoot(envVar, ...defaultSegments) {
|
|
16225
|
+
const explicit = process.env[envVar];
|
|
16226
|
+
if (explicit)
|
|
16227
|
+
return explicit;
|
|
16228
|
+
if (anyRootOverridden())
|
|
16229
|
+
return null;
|
|
16230
|
+
return path9.join(os2.homedir(), ...defaultSegments);
|
|
16231
|
+
}
|
|
16232
|
+
var cursorGlobalRoot = () => resolveSourceRoot("CURSOR_GLOBAL_DIR", "Library", "Application Support", "Cursor", "User", "globalStorage");
|
|
16233
|
+
function cursorGlobalDbPath() {
|
|
16234
|
+
const root = cursorGlobalRoot();
|
|
16235
|
+
return root === null ? null : path9.join(root, "state.vscdb");
|
|
16236
|
+
}
|
|
16237
|
+
var MACHINE_CURSOR_FILE_RE = /^(.*[/\\]machines[/\\][^/\\]+[/\\]\.cursor)[/\\]projects[/\\]/;
|
|
16238
|
+
function cursorDbPathForFile(file2) {
|
|
16239
|
+
const m = file2.match(MACHINE_CURSOR_FILE_RE);
|
|
16240
|
+
if (m)
|
|
16241
|
+
return path9.join(m[1], "globalStorage", "state.vscdb");
|
|
16242
|
+
return cursorGlobalDbPath();
|
|
16243
|
+
}
|
|
16244
|
+
|
|
15957
16245
|
// ../../lib/agents/coding/materialize.ts
|
|
15958
|
-
var
|
|
16246
|
+
var SYSTEM_REMINDER_RE3 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
15959
16247
|
var INJECT_GIST = 120;
|
|
15960
16248
|
var INJECTED = [
|
|
15961
16249
|
{ re: /<task-notification>[\s\S]*?<\/task-notification>/g, label: "bg task", gistRe: /<summary>([\s\S]*?)<\/summary>/ },
|
|
@@ -15975,7 +16263,7 @@ function collapseInjected(input) {
|
|
|
15975
16263
|
return "";
|
|
15976
16264
|
});
|
|
15977
16265
|
}
|
|
15978
|
-
return { text: text2.replace(
|
|
16266
|
+
return { text: text2.replace(SYSTEM_REMINDER_RE3, "").trim(), markers };
|
|
15979
16267
|
}
|
|
15980
16268
|
function extractText(content) {
|
|
15981
16269
|
if (typeof content === "string") return content;
|
|
@@ -15991,7 +16279,7 @@ function extractText(content) {
|
|
|
15991
16279
|
function isToolResultOnly(content) {
|
|
15992
16280
|
return Array.isArray(content) && content.length > 0 && content.every((c) => c && typeof c === "object" && c.type === "tool_result");
|
|
15993
16281
|
}
|
|
15994
|
-
var
|
|
16282
|
+
var AI_GIST2 = 160;
|
|
15995
16283
|
function materializeCodex(raw) {
|
|
15996
16284
|
const lines = [];
|
|
15997
16285
|
let humanTurns = 0, humanChars = 0;
|
|
@@ -16000,7 +16288,7 @@ function materializeCodex(raw) {
|
|
|
16000
16288
|
const flushAI = () => {
|
|
16001
16289
|
if (!aiLastProse && aiTools.size === 0) return;
|
|
16002
16290
|
const tools = [...aiTools.entries()].map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
|
|
16003
|
-
const gist = aiLastProse ? aiLastProse.length >
|
|
16291
|
+
const gist = aiLastProse ? aiLastProse.length > AI_GIST2 ? aiLastProse.slice(0, AI_GIST2) + "\u2026" : aiLastProse : "";
|
|
16004
16292
|
const bits = [];
|
|
16005
16293
|
if (gist) bits.push(gist);
|
|
16006
16294
|
if (tools) bits.push(`ran ${tools}`);
|
|
@@ -16024,14 +16312,19 @@ function materializeCodex(raw) {
|
|
|
16024
16312
|
flushAI();
|
|
16025
16313
|
return { text: lines.join("\n"), humanTurns, humanChars };
|
|
16026
16314
|
}
|
|
16315
|
+
async function materializeCursor(file2, raw) {
|
|
16316
|
+
const composer = await loadCursorComposer(file2, raw, cursorDbPathForFile(file2));
|
|
16317
|
+
return composer ? renderCursorTranscript(composer) : { text: "", humanTurns: 0, humanChars: 0 };
|
|
16318
|
+
}
|
|
16027
16319
|
async function materializeSession(file2) {
|
|
16028
16320
|
let raw;
|
|
16029
16321
|
try {
|
|
16030
|
-
raw = await
|
|
16322
|
+
raw = await fs5.readFile(file2, "utf-8");
|
|
16031
16323
|
} catch {
|
|
16032
16324
|
return null;
|
|
16033
16325
|
}
|
|
16034
16326
|
if (sniffCodexRaw(raw)) return materializeCodex(raw);
|
|
16327
|
+
if (sniffCursorRaw(raw)) return materializeCursor(file2, raw);
|
|
16035
16328
|
const lines = [];
|
|
16036
16329
|
let humanTurns = 0, humanChars = 0;
|
|
16037
16330
|
const pendingQueued = [];
|
|
@@ -16044,7 +16337,7 @@ async function materializeSession(file2) {
|
|
|
16044
16337
|
const flushAI = () => {
|
|
16045
16338
|
if (!aiLastProse && aiTools.size === 0) return;
|
|
16046
16339
|
const tools = [...aiTools.entries()].map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
|
|
16047
|
-
const gist = aiLastProse ? aiLastProse.length >
|
|
16340
|
+
const gist = aiLastProse ? aiLastProse.length > AI_GIST2 ? aiLastProse.slice(0, AI_GIST2) + "\u2026" : aiLastProse : "";
|
|
16048
16341
|
const bits = [];
|
|
16049
16342
|
if (gist) bits.push(gist);
|
|
16050
16343
|
if (tools) bits.push(`ran ${tools}`);
|
|
@@ -16209,8 +16502,11 @@ function validate(raw) {
|
|
|
16209
16502
|
}
|
|
16210
16503
|
async function gradeSession(rec, opts = { outDir: "" }) {
|
|
16211
16504
|
const mat = await materializeSession(rec.file);
|
|
16505
|
+
if (rec.humanChars >= 200 && (!mat || mat.humanChars === 0)) {
|
|
16506
|
+
throw new Error(`[grade] ${rec.source} session ${rec.sessionId} has ${rec.humanChars} human chars on disk but materialized EMPTY \u2014 the materializer is missing a branch for this source (see the Codex/Cursor lesson in CLAUDE.md). Refusing to silently skip.`);
|
|
16507
|
+
}
|
|
16212
16508
|
if (!mat || mat.humanChars < 200) return null;
|
|
16213
|
-
const sandbox = await
|
|
16509
|
+
const sandbox = await fs6.mkdtemp(path10.join(os3.tmpdir(), "ps-coding-"));
|
|
16214
16510
|
try {
|
|
16215
16511
|
const chunks = chunkText(mat.text, CHUNK);
|
|
16216
16512
|
const perChunk = [];
|
|
@@ -16226,7 +16522,7 @@ async function gradeSession(rec, opts = { outDir: "" }) {
|
|
|
16226
16522
|
maxTurns: 6,
|
|
16227
16523
|
timeoutMs: 3e5,
|
|
16228
16524
|
model: opts.model ?? "sonnet",
|
|
16229
|
-
logPath: opts.logDir ?
|
|
16525
|
+
logPath: opts.logDir ? path10.join(opts.logDir, `${rec.sessionId}${chunks.length > 1 ? `.part${ci + 1}` : ""}.log`) : void 0
|
|
16230
16526
|
});
|
|
16231
16527
|
const c = validate(run2.json);
|
|
16232
16528
|
if (c.length) perChunk.push(c);
|
|
@@ -16253,11 +16549,11 @@ async function gradeSession(rec, opts = { outDir: "" }) {
|
|
|
16253
16549
|
criteria,
|
|
16254
16550
|
meta: { costUsd, durationMs, calls: chunks.length, ...small ? { scoreMap: HAIKU_SCORE_MAP_ID } : {} }
|
|
16255
16551
|
};
|
|
16256
|
-
await
|
|
16257
|
-
await
|
|
16552
|
+
await fs6.mkdir(opts.outDir, { recursive: true });
|
|
16553
|
+
await fs6.writeFile(path10.join(opts.outDir, `${rec.sessionId}.json`), JSON.stringify(grade, null, 2));
|
|
16258
16554
|
return grade;
|
|
16259
16555
|
} finally {
|
|
16260
|
-
await
|
|
16556
|
+
await fs6.rm(sandbox, { recursive: true, force: true }).catch(() => {
|
|
16261
16557
|
});
|
|
16262
16558
|
}
|
|
16263
16559
|
}
|
|
@@ -16322,7 +16618,7 @@ function capGradable(gradable) {
|
|
|
16322
16618
|
}
|
|
16323
16619
|
|
|
16324
16620
|
// ../../lib/agents/coding/profile.ts
|
|
16325
|
-
import
|
|
16621
|
+
import path11 from "path";
|
|
16326
16622
|
|
|
16327
16623
|
// ../../lib/agents/coding/walkthrough.ts
|
|
16328
16624
|
var IDLE_CAP_MS = 12 * 6e4;
|
|
@@ -16333,7 +16629,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
|
|
|
16333
16629
|
|
|
16334
16630
|
// ../../lib/calibration/index.ts
|
|
16335
16631
|
var DEFAULT_CALIBRATION = {
|
|
16336
|
-
version: "2026-07-
|
|
16632
|
+
version: "2026-07-21.1",
|
|
16337
16633
|
// = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
|
|
16338
16634
|
// src/grade/criteria.ts). A unit test fails loud when the rubric changes
|
|
16339
16635
|
// without this being updated (and re-pushed to the server).
|
|
@@ -16429,13 +16725,14 @@ var DEFAULT_CALIBRATION = {
|
|
|
16429
16725
|
},
|
|
16430
16726
|
codingBenchmarks: {
|
|
16431
16727
|
flow: {
|
|
16432
|
-
// typical knowledge worker ≈ 35% of an 8h day focused; ~4h/day
|
|
16433
|
-
//
|
|
16728
|
+
// typical knowledge worker ≈ 35% of an 8h day focused; the ~4h/day
|
|
16729
|
+
// deep-work ceiling (Newport) sits nearer ~40% of a real (9-10h) top
|
|
16730
|
+
// performer's day — 50% overstated it (owner call 2026-07-21).
|
|
16434
16731
|
typicalPctOfDay: 0.35,
|
|
16435
|
-
topPctOfDay: 0.
|
|
16732
|
+
topPctOfDay: 0.4,
|
|
16436
16733
|
tag: "measured",
|
|
16437
|
-
source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling)",
|
|
16438
|
-
line: "the best spend ~
|
|
16734
|
+
source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling against a 9-10h day)",
|
|
16735
|
+
line: "the best spend ~40% of the workday in true deep flow; ~4h/day is the human ceiling"
|
|
16439
16736
|
},
|
|
16440
16737
|
longestRun: {
|
|
16441
16738
|
typicalHours: 0.67,
|
|
@@ -16484,8 +16781,8 @@ var BEST = DEFAULT_CALIBRATION.codingBenchmarks;
|
|
|
16484
16781
|
|
|
16485
16782
|
// ../../lib/agents/coding/profile.ts
|
|
16486
16783
|
var ROOT = process.cwd();
|
|
16487
|
-
var CODING_DIR = process.env.POLYMATH_DATA_DIR ?
|
|
16488
|
-
var GRADES =
|
|
16784
|
+
var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path11.join(process.env.POLYMATH_DATA_DIR, "coding") : path11.join(ROOT, ".data", "coding");
|
|
16785
|
+
var GRADES = path11.join(CODING_DIR, "grades");
|
|
16489
16786
|
|
|
16490
16787
|
// ../../scripts/coding-grade.mts
|
|
16491
16788
|
var argv = process.argv.slice(2);
|
|
@@ -16513,10 +16810,10 @@ function makeLimiter(max) {
|
|
|
16513
16810
|
};
|
|
16514
16811
|
}
|
|
16515
16812
|
var CODING = CODING_DIR;
|
|
16516
|
-
var GRADES2 =
|
|
16517
|
-
var LOGS =
|
|
16813
|
+
var GRADES2 = path12.join(CODING, "grades");
|
|
16814
|
+
var LOGS = path12.join(GRADES2, "logs");
|
|
16518
16815
|
async function main() {
|
|
16519
|
-
const sessions = JSON.parse(await
|
|
16816
|
+
const sessions = JSON.parse(await fs7.readFile(path12.join(CODING, "sessions.json"), "utf8"));
|
|
16520
16817
|
const live = sessions.filter((s) => s.klass === "interactive" && !s.duplicateOf);
|
|
16521
16818
|
const { gradable: allGradable, thin, trivial } = partition(live);
|
|
16522
16819
|
const cutoff = aiWindowCutoff(live);
|
|
@@ -16525,13 +16822,13 @@ async function main() {
|
|
|
16525
16822
|
console.log(`[coding-grade] ${sessions.length} sessions \u2192 ${allGradable.length} gradable \xB7 ${thin.length} thin \xB7 ${trivial.length} trivial (skipped)`);
|
|
16526
16823
|
if (cutoff) console.log(`[coding-grade] AI window: grading sessions since ${cutoff.slice(0, 10)} \u2014 ${gradable.length} of ${allGradable.length} gradable (POLYMATH_AI_WINDOW_DAYS=0 for full history)`);
|
|
16527
16824
|
if (ranked.length < gradable.length) console.log(`[coding-grade] cap: grading the ${ranked.length} richest of ${gradable.length} gradable sessions (POLYMATH_MAX_GRADED=${maxGraded()}; 0 = uncapped) \u2014 the rest still feed every deterministic number`);
|
|
16528
|
-
await
|
|
16825
|
+
await fs7.mkdir(LOGS, { recursive: true });
|
|
16529
16826
|
const limit = ALL ? ranked.length : N;
|
|
16530
16827
|
const picked = [];
|
|
16531
16828
|
for (const s of ranked) {
|
|
16532
16829
|
if (picked.length >= limit) break;
|
|
16533
16830
|
if (!REGRADE) {
|
|
16534
|
-
const done = await
|
|
16831
|
+
const done = await fs7.readFile(path12.join(GRADES2, `${s.sessionId}.json`), "utf8").catch(() => null);
|
|
16535
16832
|
if (done) continue;
|
|
16536
16833
|
}
|
|
16537
16834
|
picked.push(s);
|