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,9 +134,9 @@ var require_secure_json_parse = __commonJS({
|
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
// ../../scripts/coding-expertise.mts
|
|
137
|
-
import { promises as
|
|
138
|
-
import
|
|
139
|
-
import
|
|
137
|
+
import { promises as fs8 } from "fs";
|
|
138
|
+
import os3 from "os";
|
|
139
|
+
import path12 from "path";
|
|
140
140
|
|
|
141
141
|
// ../../lib/agents/shared/agent.ts
|
|
142
142
|
import { readFileSync } from "fs";
|
|
@@ -504,6 +504,13 @@ ${report}`);
|
|
|
504
504
|
}
|
|
505
505
|
|
|
506
506
|
// ../../lib/agents/shared/codexAdapter.ts
|
|
507
|
+
var CODEX_DEFAULT_MODEL = "gpt-5.5";
|
|
508
|
+
var CODEX_MINI_MODEL = "gpt-5.4-mini";
|
|
509
|
+
function mapCodexTier(model, env = process.env) {
|
|
510
|
+
if (model && !/^(claude|haiku|sonnet|opus)/i.test(model)) return model;
|
|
511
|
+
if (model && /^haiku/i.test(model)) return env.POLYMATH_CODEX_MODEL_MINI || CODEX_MINI_MODEL;
|
|
512
|
+
return env.POLYMATH_CODEX_MODEL || CODEX_DEFAULT_MODEL;
|
|
513
|
+
}
|
|
507
514
|
function composePrompt(inv, roots) {
|
|
508
515
|
return [
|
|
509
516
|
inv.systemPrompt ? `<system>
|
|
@@ -544,7 +551,7 @@ var codexAdapter = {
|
|
|
544
551
|
"read-only",
|
|
545
552
|
"--json"
|
|
546
553
|
];
|
|
547
|
-
|
|
554
|
+
args.push("--model", mapCodexTier(inv.model));
|
|
548
555
|
args.push(composePrompt(inv, roots));
|
|
549
556
|
const started = Date.now();
|
|
550
557
|
const toolCalls = [];
|
|
@@ -2172,8 +2179,8 @@ function getErrorMap() {
|
|
|
2172
2179
|
|
|
2173
2180
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
2174
2181
|
var makeIssue = (params) => {
|
|
2175
|
-
const { data, path:
|
|
2176
|
-
const fullPath = [...
|
|
2182
|
+
const { data, path: path13, errorMaps, issueData } = params;
|
|
2183
|
+
const fullPath = [...path13, ...issueData.path || []];
|
|
2177
2184
|
const fullIssue = {
|
|
2178
2185
|
...issueData,
|
|
2179
2186
|
path: fullPath
|
|
@@ -2289,11 +2296,11 @@ var errorUtil;
|
|
|
2289
2296
|
|
|
2290
2297
|
// ../../node_modules/zod/v3/types.js
|
|
2291
2298
|
var ParseInputLazyPath = class {
|
|
2292
|
-
constructor(parent, value,
|
|
2299
|
+
constructor(parent, value, path13, key) {
|
|
2293
2300
|
this._cachedPath = [];
|
|
2294
2301
|
this.parent = parent;
|
|
2295
2302
|
this.data = value;
|
|
2296
|
-
this._path =
|
|
2303
|
+
this._path = path13;
|
|
2297
2304
|
this._key = key;
|
|
2298
2305
|
}
|
|
2299
2306
|
get path() {
|
|
@@ -15080,39 +15087,39 @@ function createOpenAI(options = {}) {
|
|
|
15080
15087
|
});
|
|
15081
15088
|
const createChatModel = (modelId, settings = {}) => new OpenAIChatLanguageModel(modelId, settings, {
|
|
15082
15089
|
provider: `${providerName}.chat`,
|
|
15083
|
-
url: ({ path:
|
|
15090
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15084
15091
|
headers: getHeaders,
|
|
15085
15092
|
compatibility,
|
|
15086
15093
|
fetch: options.fetch
|
|
15087
15094
|
});
|
|
15088
15095
|
const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
|
|
15089
15096
|
provider: `${providerName}.completion`,
|
|
15090
|
-
url: ({ path:
|
|
15097
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15091
15098
|
headers: getHeaders,
|
|
15092
15099
|
compatibility,
|
|
15093
15100
|
fetch: options.fetch
|
|
15094
15101
|
});
|
|
15095
15102
|
const createEmbeddingModel = (modelId, settings = {}) => new OpenAIEmbeddingModel(modelId, settings, {
|
|
15096
15103
|
provider: `${providerName}.embedding`,
|
|
15097
|
-
url: ({ path:
|
|
15104
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15098
15105
|
headers: getHeaders,
|
|
15099
15106
|
fetch: options.fetch
|
|
15100
15107
|
});
|
|
15101
15108
|
const createImageModel = (modelId, settings = {}) => new OpenAIImageModel(modelId, settings, {
|
|
15102
15109
|
provider: `${providerName}.image`,
|
|
15103
|
-
url: ({ path:
|
|
15110
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15104
15111
|
headers: getHeaders,
|
|
15105
15112
|
fetch: options.fetch
|
|
15106
15113
|
});
|
|
15107
15114
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
15108
15115
|
provider: `${providerName}.transcription`,
|
|
15109
|
-
url: ({ path:
|
|
15116
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15110
15117
|
headers: getHeaders,
|
|
15111
15118
|
fetch: options.fetch
|
|
15112
15119
|
});
|
|
15113
15120
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
15114
15121
|
provider: `${providerName}.speech`,
|
|
15115
|
-
url: ({ path:
|
|
15122
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15116
15123
|
headers: getHeaders,
|
|
15117
15124
|
fetch: options.fetch
|
|
15118
15125
|
});
|
|
@@ -15133,7 +15140,7 @@ function createOpenAI(options = {}) {
|
|
|
15133
15140
|
const createResponsesModel = (modelId) => {
|
|
15134
15141
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
15135
15142
|
provider: `${providerName}.responses`,
|
|
15136
|
-
url: ({ path:
|
|
15143
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15137
15144
|
headers: getHeaders,
|
|
15138
15145
|
fetch: options.fetch
|
|
15139
15146
|
});
|
|
@@ -15647,19 +15654,20 @@ function chunkText(text2, max) {
|
|
|
15647
15654
|
}
|
|
15648
15655
|
|
|
15649
15656
|
// ../../lib/agents/coding/docsDir.ts
|
|
15650
|
-
import { promises as
|
|
15651
|
-
import
|
|
15657
|
+
import { promises as fs6 } from "fs";
|
|
15658
|
+
import path10 from "path";
|
|
15652
15659
|
|
|
15653
15660
|
// ../../lib/agents/coding/materialize.ts
|
|
15654
|
-
import { promises as
|
|
15661
|
+
import { promises as fs5 } from "fs";
|
|
15655
15662
|
|
|
15656
15663
|
// ../coding-core/dist/injected.js
|
|
15664
|
+
var SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
15657
15665
|
function isHarnessEntry(e) {
|
|
15658
15666
|
return e.isMeta === true || e.isCompactSummary === true;
|
|
15659
15667
|
}
|
|
15660
15668
|
|
|
15661
15669
|
// ../coding-core/dist/codex.js
|
|
15662
|
-
var
|
|
15670
|
+
var SYSTEM_REMINDER_RE2 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
15663
15671
|
var CODEX_INJECTED_TEXT_RE = /^\s*(<(environment_context|user_instructions|ENVIRONMENT_CONTEXT|turn_aborted)\b|#\s*AGENTS\.md instructions\b)/;
|
|
15664
15672
|
function isCodexInjectedUserText(text2) {
|
|
15665
15673
|
return CODEX_INJECTED_TEXT_RE.test(text2);
|
|
@@ -15722,7 +15730,7 @@ function extractCodexEvents(raw) {
|
|
|
15722
15730
|
const ptype = p.type;
|
|
15723
15731
|
if (ptype === "message") {
|
|
15724
15732
|
const role = p.role;
|
|
15725
|
-
const text2 = codexContentText(p.content).replace(
|
|
15733
|
+
const text2 = codexContentText(p.content).replace(SYSTEM_REMINDER_RE2, "").trim();
|
|
15726
15734
|
if (!text2)
|
|
15727
15735
|
continue;
|
|
15728
15736
|
if (role === "user") {
|
|
@@ -15749,8 +15757,288 @@ function extractCodexEvents(raw) {
|
|
|
15749
15757
|
return out;
|
|
15750
15758
|
}
|
|
15751
15759
|
|
|
15760
|
+
// ../coding-core/dist/cursor.js
|
|
15761
|
+
import { promises as fs4 } from "fs";
|
|
15762
|
+
var NODE_SQLITE = "node:sqlite";
|
|
15763
|
+
async function openCursorSqlite(dbPath) {
|
|
15764
|
+
try {
|
|
15765
|
+
await fs4.access(dbPath);
|
|
15766
|
+
} catch {
|
|
15767
|
+
return null;
|
|
15768
|
+
}
|
|
15769
|
+
let mod;
|
|
15770
|
+
try {
|
|
15771
|
+
mod = await import(NODE_SQLITE);
|
|
15772
|
+
} catch {
|
|
15773
|
+
return null;
|
|
15774
|
+
}
|
|
15775
|
+
const DatabaseSync = mod?.DatabaseSync;
|
|
15776
|
+
if (!DatabaseSync)
|
|
15777
|
+
return null;
|
|
15778
|
+
let db;
|
|
15779
|
+
try {
|
|
15780
|
+
db = new DatabaseSync(dbPath, { readOnly: true });
|
|
15781
|
+
} catch {
|
|
15782
|
+
try {
|
|
15783
|
+
db = new DatabaseSync(dbPath);
|
|
15784
|
+
} catch {
|
|
15785
|
+
return null;
|
|
15786
|
+
}
|
|
15787
|
+
}
|
|
15788
|
+
const asText = (v) => v == null ? null : typeof v === "string" ? v : Buffer.from(v).toString("utf-8");
|
|
15789
|
+
return {
|
|
15790
|
+
prefix(prefix) {
|
|
15791
|
+
try {
|
|
15792
|
+
const rows = db.prepare("SELECT key, value FROM cursorDiskKV WHERE key LIKE ? ESCAPE '\\'").all(likePrefix(prefix));
|
|
15793
|
+
return rows.map((r) => ({ key: r.key, value: asText(r.value) ?? "" }));
|
|
15794
|
+
} catch {
|
|
15795
|
+
return [];
|
|
15796
|
+
}
|
|
15797
|
+
},
|
|
15798
|
+
get(key) {
|
|
15799
|
+
try {
|
|
15800
|
+
const row = db.prepare("SELECT value FROM cursorDiskKV WHERE key = ?").get(key);
|
|
15801
|
+
return row ? asText(row.value) : null;
|
|
15802
|
+
} catch {
|
|
15803
|
+
return null;
|
|
15804
|
+
}
|
|
15805
|
+
},
|
|
15806
|
+
close() {
|
|
15807
|
+
try {
|
|
15808
|
+
db.close();
|
|
15809
|
+
} catch {
|
|
15810
|
+
}
|
|
15811
|
+
}
|
|
15812
|
+
};
|
|
15813
|
+
}
|
|
15814
|
+
function likePrefix(prefix) {
|
|
15815
|
+
return prefix.replace(/[\\%_]/g, (c) => "\\" + c) + "%";
|
|
15816
|
+
}
|
|
15817
|
+
var CURSOR_USER_QUERY_RE = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/;
|
|
15818
|
+
function cleanUserText(raw) {
|
|
15819
|
+
let t = raw.replace(SYSTEM_REMINDER_RE, "");
|
|
15820
|
+
const m = t.match(CURSOR_USER_QUERY_RE);
|
|
15821
|
+
if (m)
|
|
15822
|
+
t = m[1];
|
|
15823
|
+
return t.trim();
|
|
15824
|
+
}
|
|
15825
|
+
var msFrom = (v) => {
|
|
15826
|
+
if (typeof v === "number" && Number.isFinite(v))
|
|
15827
|
+
return v;
|
|
15828
|
+
if (typeof v === "string") {
|
|
15829
|
+
const n = Date.parse(v);
|
|
15830
|
+
return Number.isFinite(n) ? n : null;
|
|
15831
|
+
}
|
|
15832
|
+
return null;
|
|
15833
|
+
};
|
|
15834
|
+
function readCursorComposer(db, composerId) {
|
|
15835
|
+
const cdRaw = db.get(`composerData:${composerId}`);
|
|
15836
|
+
if (!cdRaw)
|
|
15837
|
+
return null;
|
|
15838
|
+
let cd;
|
|
15839
|
+
try {
|
|
15840
|
+
cd = JSON.parse(cdRaw);
|
|
15841
|
+
} catch {
|
|
15842
|
+
return null;
|
|
15843
|
+
}
|
|
15844
|
+
const headers = Array.isArray(cd.fullConversationHeadersOnly) ? cd.fullConversationHeadersOnly : [];
|
|
15845
|
+
if (headers.length === 0)
|
|
15846
|
+
return null;
|
|
15847
|
+
const bubbles = /* @__PURE__ */ new Map();
|
|
15848
|
+
for (const row of db.prefix(`bubbleId:${composerId}:`)) {
|
|
15849
|
+
const bid = row.key.slice(`bubbleId:${composerId}:`.length);
|
|
15850
|
+
try {
|
|
15851
|
+
bubbles.set(bid, JSON.parse(row.value));
|
|
15852
|
+
} catch {
|
|
15853
|
+
}
|
|
15854
|
+
}
|
|
15855
|
+
const turns = [];
|
|
15856
|
+
let clock = msFrom(cd.createdAt) ?? 0;
|
|
15857
|
+
for (const h of headers) {
|
|
15858
|
+
const b = bubbles.get(h.bubbleId);
|
|
15859
|
+
if (!b)
|
|
15860
|
+
continue;
|
|
15861
|
+
const type = h.type === 1 ? 1 : 2;
|
|
15862
|
+
const tool2 = type === 2 && b.toolFormerData && typeof b.toolFormerData.name === "string" ? b.toolFormerData.name : null;
|
|
15863
|
+
const rawText = typeof b.text === "string" ? b.text : "";
|
|
15864
|
+
const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
|
|
15865
|
+
if (!text2 && !tool2)
|
|
15866
|
+
continue;
|
|
15867
|
+
const t = msFrom(b.createdAt);
|
|
15868
|
+
clock = Math.max(clock, t ?? clock + 1);
|
|
15869
|
+
const model = b.modelInfo && typeof b.modelInfo.modelName === "string" ? b.modelInfo.modelName : null;
|
|
15870
|
+
turns.push({ t: clock, type, text: text2, tool: tool2, model });
|
|
15871
|
+
}
|
|
15872
|
+
if (turns.length === 0)
|
|
15873
|
+
return null;
|
|
15874
|
+
const gitRepo = Array.isArray(cd.trackedGitRepos) && cd.trackedGitRepos[0] && typeof cd.trackedGitRepos[0].repoPath === "string" ? cd.trackedGitRepos[0].repoPath : null;
|
|
15875
|
+
return {
|
|
15876
|
+
composerId,
|
|
15877
|
+
createdAt: msFrom(cd.createdAt),
|
|
15878
|
+
updatedAt: msFrom(cd.lastUpdatedAt),
|
|
15879
|
+
name: typeof cd.name === "string" && cd.name.trim() ? cd.name.trim() : null,
|
|
15880
|
+
gitRepo,
|
|
15881
|
+
turns
|
|
15882
|
+
};
|
|
15883
|
+
}
|
|
15884
|
+
function sniffCursorRaw(raw) {
|
|
15885
|
+
for (const lineRaw of raw.split("\n")) {
|
|
15886
|
+
const line = lineRaw.trim();
|
|
15887
|
+
if (!line)
|
|
15888
|
+
continue;
|
|
15889
|
+
try {
|
|
15890
|
+
const e = JSON.parse(line);
|
|
15891
|
+
return (e.role === "user" || e.role === "assistant") && typeof e.message === "object" && e.message !== null && "content" in e.message && !("type" in e);
|
|
15892
|
+
} catch {
|
|
15893
|
+
return false;
|
|
15894
|
+
}
|
|
15895
|
+
}
|
|
15896
|
+
return false;
|
|
15897
|
+
}
|
|
15898
|
+
function jsonlText(content) {
|
|
15899
|
+
const parts = [];
|
|
15900
|
+
const tools = [];
|
|
15901
|
+
if (Array.isArray(content)) {
|
|
15902
|
+
for (const item of content) {
|
|
15903
|
+
if (!item || typeof item !== "object")
|
|
15904
|
+
continue;
|
|
15905
|
+
const it = item;
|
|
15906
|
+
if (it.type === "text" && it.text)
|
|
15907
|
+
parts.push(it.text);
|
|
15908
|
+
else if (it.type === "tool_use" && it.name)
|
|
15909
|
+
tools.push(it.name);
|
|
15910
|
+
}
|
|
15911
|
+
} else if (typeof content === "string")
|
|
15912
|
+
parts.push(content);
|
|
15913
|
+
return { text: parts.join("\n"), tools };
|
|
15914
|
+
}
|
|
15915
|
+
function parseCursorJsonl(raw, base) {
|
|
15916
|
+
const turns = [];
|
|
15917
|
+
let clock = base;
|
|
15918
|
+
for (const lineRaw of raw.split("\n")) {
|
|
15919
|
+
const line = lineRaw.trim();
|
|
15920
|
+
if (!line)
|
|
15921
|
+
continue;
|
|
15922
|
+
let e;
|
|
15923
|
+
try {
|
|
15924
|
+
e = JSON.parse(line);
|
|
15925
|
+
} catch {
|
|
15926
|
+
continue;
|
|
15927
|
+
}
|
|
15928
|
+
if (e.role !== "user" && e.role !== "assistant")
|
|
15929
|
+
continue;
|
|
15930
|
+
const { text: rawText, tools } = jsonlText(e.message?.content);
|
|
15931
|
+
const type = e.role === "user" ? 1 : 2;
|
|
15932
|
+
const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
|
|
15933
|
+
if (type === 2 && tools.length) {
|
|
15934
|
+
for (const tool2 of tools) {
|
|
15935
|
+
clock += 1;
|
|
15936
|
+
turns.push({ t: clock, type: 2, text: "", tool: tool2, model: null });
|
|
15937
|
+
}
|
|
15938
|
+
}
|
|
15939
|
+
if (!text2)
|
|
15940
|
+
continue;
|
|
15941
|
+
clock += 1;
|
|
15942
|
+
turns.push({ t: clock, type, text: text2, tool: null, model: null });
|
|
15943
|
+
}
|
|
15944
|
+
if (turns.length === 0)
|
|
15945
|
+
return null;
|
|
15946
|
+
return { composerId: "", createdAt: base, updatedAt: clock, name: null, gitRepo: null, turns };
|
|
15947
|
+
}
|
|
15948
|
+
var AI_GIST = 500;
|
|
15949
|
+
function renderCursorTranscript(c) {
|
|
15950
|
+
const lines = [];
|
|
15951
|
+
let humanTurns = 0, humanChars = 0;
|
|
15952
|
+
let aiProse = "";
|
|
15953
|
+
const aiTools = /* @__PURE__ */ new Map();
|
|
15954
|
+
const flushAI = () => {
|
|
15955
|
+
if (!aiProse && aiTools.size === 0)
|
|
15956
|
+
return;
|
|
15957
|
+
const tools = [...aiTools.entries()].map(([n, k]) => k > 1 ? `${n}\xD7${k}` : n).join(", ");
|
|
15958
|
+
const gist = aiProse ? aiProse.length > AI_GIST ? aiProse.slice(0, AI_GIST) + "\u2026" : aiProse : "";
|
|
15959
|
+
const bits = [];
|
|
15960
|
+
if (gist)
|
|
15961
|
+
bits.push(gist);
|
|
15962
|
+
if (tools)
|
|
15963
|
+
bits.push(`ran ${tools}`);
|
|
15964
|
+
lines.push(`[AI: ${bits.join(" \xB7 ")}]`);
|
|
15965
|
+
aiProse = "";
|
|
15966
|
+
aiTools.clear();
|
|
15967
|
+
};
|
|
15968
|
+
for (const turn of c.turns) {
|
|
15969
|
+
if (turn.type === 1) {
|
|
15970
|
+
flushAI();
|
|
15971
|
+
humanTurns++;
|
|
15972
|
+
humanChars += turn.text.length;
|
|
15973
|
+
lines.push(`>> ${turn.text}`);
|
|
15974
|
+
} else {
|
|
15975
|
+
if (turn.tool)
|
|
15976
|
+
aiTools.set(turn.tool, (aiTools.get(turn.tool) ?? 0) + 1);
|
|
15977
|
+
if (turn.text)
|
|
15978
|
+
aiProse = turn.text.replace(/\s+/g, " ").trim();
|
|
15979
|
+
}
|
|
15980
|
+
}
|
|
15981
|
+
flushAI();
|
|
15982
|
+
return { text: lines.join("\n"), humanTurns, humanChars };
|
|
15983
|
+
}
|
|
15984
|
+
function composerIdFromFile(file2) {
|
|
15985
|
+
const m = file2.match(/agent-transcripts\/([^/]+)\/[^/]+\.jsonl$/);
|
|
15986
|
+
return m ? m[1] : null;
|
|
15987
|
+
}
|
|
15988
|
+
async function loadCursorComposer(file2, raw, dbPath) {
|
|
15989
|
+
const cid = composerIdFromFile(file2);
|
|
15990
|
+
if (cid && dbPath) {
|
|
15991
|
+
const db = await openCursorSqlite(dbPath);
|
|
15992
|
+
if (db) {
|
|
15993
|
+
try {
|
|
15994
|
+
const c = readCursorComposer(db, cid);
|
|
15995
|
+
if (c)
|
|
15996
|
+
return c;
|
|
15997
|
+
} finally {
|
|
15998
|
+
db.close();
|
|
15999
|
+
}
|
|
16000
|
+
}
|
|
16001
|
+
}
|
|
16002
|
+
return parseCursorJsonl(raw, 0);
|
|
16003
|
+
}
|
|
16004
|
+
|
|
16005
|
+
// ../coding-core/dist/raw.js
|
|
16006
|
+
import path9 from "path";
|
|
16007
|
+
import os2 from "os";
|
|
16008
|
+
var SOURCE_ROOT_ENV_VARS = [
|
|
16009
|
+
"CLAUDE_PROJECTS_DIR",
|
|
16010
|
+
"CODEX_SESSIONS_DIR",
|
|
16011
|
+
"CURSOR_WORKSPACE_DIR",
|
|
16012
|
+
"CURSOR_PROJECTS_DIR",
|
|
16013
|
+
// Cursor's globalStorage dir (holds state.vscdb — the composer bubbles that
|
|
16014
|
+
// carry a Cursor session's real per-turn timestamps + content). Same
|
|
16015
|
+
// isolation contract: overriding any root disables every unset source.
|
|
16016
|
+
"CURSOR_GLOBAL_DIR"
|
|
16017
|
+
];
|
|
16018
|
+
var anyRootOverridden = () => SOURCE_ROOT_ENV_VARS.some((v) => !!process.env[v]);
|
|
16019
|
+
function resolveSourceRoot(envVar, ...defaultSegments) {
|
|
16020
|
+
const explicit = process.env[envVar];
|
|
16021
|
+
if (explicit)
|
|
16022
|
+
return explicit;
|
|
16023
|
+
if (anyRootOverridden())
|
|
16024
|
+
return null;
|
|
16025
|
+
return path9.join(os2.homedir(), ...defaultSegments);
|
|
16026
|
+
}
|
|
16027
|
+
var cursorGlobalRoot = () => resolveSourceRoot("CURSOR_GLOBAL_DIR", "Library", "Application Support", "Cursor", "User", "globalStorage");
|
|
16028
|
+
function cursorGlobalDbPath() {
|
|
16029
|
+
const root = cursorGlobalRoot();
|
|
16030
|
+
return root === null ? null : path9.join(root, "state.vscdb");
|
|
16031
|
+
}
|
|
16032
|
+
var MACHINE_CURSOR_FILE_RE = /^(.*[/\\]machines[/\\][^/\\]+[/\\]\.cursor)[/\\]projects[/\\]/;
|
|
16033
|
+
function cursorDbPathForFile(file2) {
|
|
16034
|
+
const m = file2.match(MACHINE_CURSOR_FILE_RE);
|
|
16035
|
+
if (m)
|
|
16036
|
+
return path9.join(m[1], "globalStorage", "state.vscdb");
|
|
16037
|
+
return cursorGlobalDbPath();
|
|
16038
|
+
}
|
|
16039
|
+
|
|
15752
16040
|
// ../../lib/agents/coding/materialize.ts
|
|
15753
|
-
var
|
|
16041
|
+
var SYSTEM_REMINDER_RE3 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
15754
16042
|
var INJECT_GIST = 120;
|
|
15755
16043
|
var INJECTED = [
|
|
15756
16044
|
{ re: /<task-notification>[\s\S]*?<\/task-notification>/g, label: "bg task", gistRe: /<summary>([\s\S]*?)<\/summary>/ },
|
|
@@ -15770,7 +16058,7 @@ function collapseInjected(input) {
|
|
|
15770
16058
|
return "";
|
|
15771
16059
|
});
|
|
15772
16060
|
}
|
|
15773
|
-
return { text: text2.replace(
|
|
16061
|
+
return { text: text2.replace(SYSTEM_REMINDER_RE3, "").trim(), markers };
|
|
15774
16062
|
}
|
|
15775
16063
|
function extractText(content) {
|
|
15776
16064
|
if (typeof content === "string") return content;
|
|
@@ -15786,7 +16074,7 @@ function extractText(content) {
|
|
|
15786
16074
|
function isToolResultOnly(content) {
|
|
15787
16075
|
return Array.isArray(content) && content.length > 0 && content.every((c) => c && typeof c === "object" && c.type === "tool_result");
|
|
15788
16076
|
}
|
|
15789
|
-
var
|
|
16077
|
+
var AI_GIST2 = 160;
|
|
15790
16078
|
function materializeCodex(raw) {
|
|
15791
16079
|
const lines = [];
|
|
15792
16080
|
let humanTurns = 0, humanChars = 0;
|
|
@@ -15795,7 +16083,7 @@ function materializeCodex(raw) {
|
|
|
15795
16083
|
const flushAI = () => {
|
|
15796
16084
|
if (!aiLastProse && aiTools.size === 0) return;
|
|
15797
16085
|
const tools = [...aiTools.entries()].map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
|
|
15798
|
-
const gist = aiLastProse ? aiLastProse.length >
|
|
16086
|
+
const gist = aiLastProse ? aiLastProse.length > AI_GIST2 ? aiLastProse.slice(0, AI_GIST2) + "\u2026" : aiLastProse : "";
|
|
15799
16087
|
const bits = [];
|
|
15800
16088
|
if (gist) bits.push(gist);
|
|
15801
16089
|
if (tools) bits.push(`ran ${tools}`);
|
|
@@ -15819,14 +16107,19 @@ function materializeCodex(raw) {
|
|
|
15819
16107
|
flushAI();
|
|
15820
16108
|
return { text: lines.join("\n"), humanTurns, humanChars };
|
|
15821
16109
|
}
|
|
16110
|
+
async function materializeCursor(file2, raw) {
|
|
16111
|
+
const composer = await loadCursorComposer(file2, raw, cursorDbPathForFile(file2));
|
|
16112
|
+
return composer ? renderCursorTranscript(composer) : { text: "", humanTurns: 0, humanChars: 0 };
|
|
16113
|
+
}
|
|
15822
16114
|
async function materializeSession(file2) {
|
|
15823
16115
|
let raw;
|
|
15824
16116
|
try {
|
|
15825
|
-
raw = await
|
|
16117
|
+
raw = await fs5.readFile(file2, "utf-8");
|
|
15826
16118
|
} catch {
|
|
15827
16119
|
return null;
|
|
15828
16120
|
}
|
|
15829
16121
|
if (sniffCodexRaw(raw)) return materializeCodex(raw);
|
|
16122
|
+
if (sniffCursorRaw(raw)) return materializeCursor(file2, raw);
|
|
15830
16123
|
const lines = [];
|
|
15831
16124
|
let humanTurns = 0, humanChars = 0;
|
|
15832
16125
|
const pendingQueued = [];
|
|
@@ -15839,7 +16132,7 @@ async function materializeSession(file2) {
|
|
|
15839
16132
|
const flushAI = () => {
|
|
15840
16133
|
if (!aiLastProse && aiTools.size === 0) return;
|
|
15841
16134
|
const tools = [...aiTools.entries()].map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
|
|
15842
|
-
const gist = aiLastProse ? aiLastProse.length >
|
|
16135
|
+
const gist = aiLastProse ? aiLastProse.length > AI_GIST2 ? aiLastProse.slice(0, AI_GIST2) + "\u2026" : aiLastProse : "";
|
|
15843
16136
|
const bits = [];
|
|
15844
16137
|
if (gist) bits.push(gist);
|
|
15845
16138
|
if (tools) bits.push(`ran ${tools}`);
|
|
@@ -15919,10 +16212,10 @@ async function materializeSession(file2) {
|
|
|
15919
16212
|
|
|
15920
16213
|
// ../../lib/agents/coding/docsDir.ts
|
|
15921
16214
|
async function writeScoreboard(codingDir, docs) {
|
|
15922
|
-
const gradesDir =
|
|
16215
|
+
const gradesDir = path10.join(codingDir, "grades");
|
|
15923
16216
|
let files = [];
|
|
15924
16217
|
try {
|
|
15925
|
-
files = (await
|
|
16218
|
+
files = (await fs6.readdir(gradesDir)).filter((f) => f.endsWith(".json")).sort();
|
|
15926
16219
|
} catch {
|
|
15927
16220
|
return;
|
|
15928
16221
|
}
|
|
@@ -15930,7 +16223,7 @@ async function writeScoreboard(codingDir, docs) {
|
|
|
15930
16223
|
for (const f of files) {
|
|
15931
16224
|
let g;
|
|
15932
16225
|
try {
|
|
15933
|
-
g = JSON.parse(await
|
|
16226
|
+
g = JSON.parse(await fs6.readFile(path10.join(gradesDir, f), "utf8"));
|
|
15934
16227
|
} catch {
|
|
15935
16228
|
continue;
|
|
15936
16229
|
}
|
|
@@ -15946,8 +16239,8 @@ async function writeScoreboard(codingDir, docs) {
|
|
|
15946
16239
|
([key, rows]) => `## ${key}
|
|
15947
16240
|
${rows.sort((a, b) => b.s - a.s).map((r) => r.line).join("\n")}`
|
|
15948
16241
|
);
|
|
15949
|
-
await
|
|
15950
|
-
|
|
16242
|
+
await fs6.writeFile(
|
|
16243
|
+
path10.join(docs, "_scoreboard.md"),
|
|
15951
16244
|
`# Scoreboard \u2014 every graded session per criterion, best first.
|
|
15952
16245
|
# Lx~ = estimate. Format: level \xB7 date \xB7 title \xB7 sessionId \u2014 graded instance.
|
|
15953
16246
|
|
|
@@ -15956,24 +16249,24 @@ ${blocks.join("\n\n")}
|
|
|
15956
16249
|
);
|
|
15957
16250
|
}
|
|
15958
16251
|
async function ensureCodingDocs(codingDir, sessions) {
|
|
15959
|
-
const docs =
|
|
15960
|
-
await
|
|
16252
|
+
const docs = path10.join(codingDir, "docs");
|
|
16253
|
+
await fs6.mkdir(docs, { recursive: true });
|
|
15961
16254
|
const user = sessions.filter((s) => s.sessionId && !s.duplicateOf && (!("klass" in s) || s.klass === "interactive"));
|
|
15962
16255
|
let written = 0;
|
|
15963
16256
|
for (const s of user) {
|
|
15964
|
-
const out =
|
|
16257
|
+
const out = path10.join(docs, `${s.sessionId}.txt`);
|
|
15965
16258
|
try {
|
|
15966
|
-
await
|
|
16259
|
+
await fs6.access(out);
|
|
15967
16260
|
continue;
|
|
15968
16261
|
} catch {
|
|
15969
16262
|
}
|
|
15970
16263
|
const mat = await materializeSession(s.file).catch(() => null);
|
|
15971
16264
|
if (!mat?.text) continue;
|
|
15972
|
-
await
|
|
16265
|
+
await fs6.writeFile(out, mat.text);
|
|
15973
16266
|
written++;
|
|
15974
16267
|
}
|
|
15975
16268
|
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}`);
|
|
15976
|
-
await
|
|
16269
|
+
await fs6.writeFile(path10.join(docs, "_map.md"), rows.join("\n") + "\n");
|
|
15977
16270
|
await writeScoreboard(codingDir, docs);
|
|
15978
16271
|
if (written) console.log(`[docs] materialized ${written} new transcript(s) \u2192 ${docs}`);
|
|
15979
16272
|
return docs;
|
|
@@ -16001,7 +16294,7 @@ function applyExpertiseFloor(domains, min = MIN_EXPERTISE_SESSIONS) {
|
|
|
16001
16294
|
|
|
16002
16295
|
// ../../lib/agents/coding/promptCache.ts
|
|
16003
16296
|
import { createHash } from "crypto";
|
|
16004
|
-
import { promises as
|
|
16297
|
+
import { promises as fs7 } from "fs";
|
|
16005
16298
|
function promptSha(parts) {
|
|
16006
16299
|
const h = createHash("sha256");
|
|
16007
16300
|
for (const p of parts) {
|
|
@@ -16012,7 +16305,7 @@ function promptSha(parts) {
|
|
|
16012
16305
|
}
|
|
16013
16306
|
async function reusableOutput(outPath, sha, valid, key = "promptSha") {
|
|
16014
16307
|
try {
|
|
16015
|
-
const o = JSON.parse(await
|
|
16308
|
+
const o = JSON.parse(await fs7.readFile(outPath, "utf8"));
|
|
16016
16309
|
if (o[key] === sha && valid(o)) return o;
|
|
16017
16310
|
} catch {
|
|
16018
16311
|
}
|
|
@@ -16020,7 +16313,7 @@ async function reusableOutput(outPath, sha, valid, key = "promptSha") {
|
|
|
16020
16313
|
}
|
|
16021
16314
|
|
|
16022
16315
|
// ../../lib/agents/coding/profile.ts
|
|
16023
|
-
import
|
|
16316
|
+
import path11 from "path";
|
|
16024
16317
|
|
|
16025
16318
|
// ../../lib/calibration/fingerprint.ts
|
|
16026
16319
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -16174,7 +16467,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
|
|
|
16174
16467
|
|
|
16175
16468
|
// ../../lib/calibration/index.ts
|
|
16176
16469
|
var DEFAULT_CALIBRATION = {
|
|
16177
|
-
version: "2026-07-
|
|
16470
|
+
version: "2026-07-21.1",
|
|
16178
16471
|
// = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
|
|
16179
16472
|
// src/grade/criteria.ts). A unit test fails loud when the rubric changes
|
|
16180
16473
|
// without this being updated (and re-pushed to the server).
|
|
@@ -16270,13 +16563,14 @@ var DEFAULT_CALIBRATION = {
|
|
|
16270
16563
|
},
|
|
16271
16564
|
codingBenchmarks: {
|
|
16272
16565
|
flow: {
|
|
16273
|
-
// typical knowledge worker ≈ 35% of an 8h day focused; ~4h/day
|
|
16274
|
-
//
|
|
16566
|
+
// typical knowledge worker ≈ 35% of an 8h day focused; the ~4h/day
|
|
16567
|
+
// deep-work ceiling (Newport) sits nearer ~40% of a real (9-10h) top
|
|
16568
|
+
// performer's day — 50% overstated it (owner call 2026-07-21).
|
|
16275
16569
|
typicalPctOfDay: 0.35,
|
|
16276
|
-
topPctOfDay: 0.
|
|
16570
|
+
topPctOfDay: 0.4,
|
|
16277
16571
|
tag: "measured",
|
|
16278
|
-
source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling)",
|
|
16279
|
-
line: "the best spend ~
|
|
16572
|
+
source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling against a 9-10h day)",
|
|
16573
|
+
line: "the best spend ~40% of the workday in true deep flow; ~4h/day is the human ceiling"
|
|
16280
16574
|
},
|
|
16281
16575
|
longestRun: {
|
|
16282
16576
|
typicalHours: 0.67,
|
|
@@ -16325,12 +16619,12 @@ var BEST = DEFAULT_CALIBRATION.codingBenchmarks;
|
|
|
16325
16619
|
|
|
16326
16620
|
// ../../lib/agents/coding/profile.ts
|
|
16327
16621
|
var ROOT = process.cwd();
|
|
16328
|
-
var CODING_DIR = process.env.POLYMATH_DATA_DIR ?
|
|
16329
|
-
var GRADES =
|
|
16622
|
+
var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path11.join(process.env.POLYMATH_DATA_DIR, "coding") : path11.join(ROOT, ".data", "coding");
|
|
16623
|
+
var GRADES = path11.join(CODING_DIR, "grades");
|
|
16330
16624
|
|
|
16331
16625
|
// ../../scripts/coding-expertise.mts
|
|
16332
16626
|
var CODING = CODING_DIR;
|
|
16333
|
-
var OUTDIR =
|
|
16627
|
+
var OUTDIR = path12.join(CODING, "expertise");
|
|
16334
16628
|
var CHUNK = 46e3;
|
|
16335
16629
|
var concFlag = process.argv.indexOf("--conc");
|
|
16336
16630
|
var CONC = concFlag >= 0 ? Math.max(1, Number(process.argv[concFlag + 1]) || 5) : 5;
|
|
@@ -16372,17 +16666,17 @@ async function pool(items, n, fn) {
|
|
|
16372
16666
|
}
|
|
16373
16667
|
async function main() {
|
|
16374
16668
|
const aggOnly = process.argv.includes("--agg");
|
|
16375
|
-
await
|
|
16376
|
-
const sessions = JSON.parse(await
|
|
16669
|
+
await fs8.mkdir(OUTDIR, { recursive: true });
|
|
16670
|
+
const sessions = JSON.parse(await fs8.readFile(path12.join(CODING, "sessions.json"), "utf8"));
|
|
16377
16671
|
const byId = new Map(sessions.map((s) => [s.sessionId, s]));
|
|
16378
|
-
const gradeFiles = (await
|
|
16672
|
+
const gradeFiles = (await fs8.readdir(path12.join(CODING, "grades"))).filter((f) => f.endsWith(".json")).sort();
|
|
16379
16673
|
const ids = gradeFiles.map((f) => f.replace(".json", ""));
|
|
16380
16674
|
if (!aggOnly) {
|
|
16381
16675
|
let done = 0;
|
|
16382
16676
|
await pool(ids, CONC, async (id) => {
|
|
16383
|
-
const out =
|
|
16677
|
+
const out = path12.join(OUTDIR, id + ".json");
|
|
16384
16678
|
try {
|
|
16385
|
-
await
|
|
16679
|
+
await fs8.access(out);
|
|
16386
16680
|
done++;
|
|
16387
16681
|
return;
|
|
16388
16682
|
} catch {
|
|
@@ -16391,7 +16685,7 @@ async function main() {
|
|
|
16391
16685
|
if (!rec) return;
|
|
16392
16686
|
const mat = await materializeSession(rec.file);
|
|
16393
16687
|
if (!mat) return;
|
|
16394
|
-
const sandbox = await
|
|
16688
|
+
const sandbox = await fs8.mkdtemp(path12.join(os3.tmpdir(), "exp-"));
|
|
16395
16689
|
try {
|
|
16396
16690
|
const chunks = chunkText(mat.text, CHUNK);
|
|
16397
16691
|
const realExpertise = [];
|
|
@@ -16407,21 +16701,21 @@ async function main() {
|
|
|
16407
16701
|
for (const d of j.domains || []) if (!domains.includes(d)) domains.push(d);
|
|
16408
16702
|
if (j.summary) summaries.push(j.summary);
|
|
16409
16703
|
}
|
|
16410
|
-
await
|
|
16704
|
+
await fs8.writeFile(out, JSON.stringify({ sessionId: id, date: rec.start?.slice(0, 10), title: rec.title, realExpertise, excluded, domains, summary: summaries.join(" ") }, null, 1));
|
|
16411
16705
|
done++;
|
|
16412
16706
|
console.log(`[${done}/${ids.length}] ${rec.title} \u2014 ${realExpertise.length} real`);
|
|
16413
16707
|
} catch (e) {
|
|
16414
16708
|
console.log(`ERR ${rec.title}: ${e.message.slice(0, 80)}`);
|
|
16415
16709
|
} finally {
|
|
16416
|
-
await
|
|
16710
|
+
await fs8.rm(sandbox, { recursive: true, force: true }).catch(() => {
|
|
16417
16711
|
});
|
|
16418
16712
|
}
|
|
16419
16713
|
});
|
|
16420
16714
|
}
|
|
16421
16715
|
const perSession = [];
|
|
16422
|
-
for (const f of (await
|
|
16716
|
+
for (const f of (await fs8.readdir(OUTDIR)).filter((f2) => f2.endsWith(".json")).sort()) {
|
|
16423
16717
|
try {
|
|
16424
|
-
perSession.push(JSON.parse(await
|
|
16718
|
+
perSession.push(JSON.parse(await fs8.readFile(path12.join(OUTDIR, f), "utf8")));
|
|
16425
16719
|
} catch {
|
|
16426
16720
|
}
|
|
16427
16721
|
}
|
|
@@ -16432,7 +16726,7 @@ async function main() {
|
|
|
16432
16726
|
const prompt2 = aggPrompt(items, stats, titles);
|
|
16433
16727
|
const sha = promptSha([AGG_SYSX, prompt2, "sonnet"]);
|
|
16434
16728
|
if (!process.argv.includes("--refresh")) {
|
|
16435
|
-
const prev = await reusableOutput(
|
|
16729
|
+
const prev = await reusableOutput(path12.join(CODING, "expertise.json"), sha, (o) => Array.isArray(o.domains));
|
|
16436
16730
|
if (prev) {
|
|
16437
16731
|
console.log(`[expertise] inputs unchanged \u2014 reusing aggregate from ${prev.generatedAt} (--refresh to regenerate)`);
|
|
16438
16732
|
return;
|
|
@@ -16461,7 +16755,7 @@ async function main() {
|
|
|
16461
16755
|
map.domains = kept;
|
|
16462
16756
|
}
|
|
16463
16757
|
if (!aggOk && !(map.domains || []).length) {
|
|
16464
|
-
const existing = await
|
|
16758
|
+
const existing = await fs8.readFile(path12.join(CODING, "expertise.json"), "utf8").then(JSON.parse).catch(() => null);
|
|
16465
16759
|
if (existing && (existing.domains || []).length) {
|
|
16466
16760
|
console.log("AGG FAILED (0 domains) \u2014 keeping existing", existing.domains.length, "domains");
|
|
16467
16761
|
return;
|
|
@@ -16469,7 +16763,7 @@ async function main() {
|
|
|
16469
16763
|
console.log("AGG failed and no good existing file \u2014 writing empty");
|
|
16470
16764
|
}
|
|
16471
16765
|
const result = { generatedAt: (/* @__PURE__ */ new Date()).toISOString(), ...aggOk ? { promptSha: sha } : {}, ...stats, ...map };
|
|
16472
|
-
await
|
|
16766
|
+
await fs8.writeFile(path12.join(CODING, "expertise.json"), JSON.stringify(result, null, 2));
|
|
16473
16767
|
console.log("\nWROTE .data/coding/expertise.json \u2014", (map.domains || []).length, "domains");
|
|
16474
16768
|
}
|
|
16475
16769
|
main().catch((e) => {
|