polymath-society 0.2.19 → 0.2.21

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.
Files changed (40) hide show
  1. package/dist/cli.js +24620 -22073
  2. package/dist/engine/chat-loops.js +8 -1
  3. package/dist/engine/exp-allfacets.js +8 -1
  4. package/dist/engine/exp-person.js +8 -1
  5. package/dist/engine/exp-pipeline.js +8 -1
  6. package/dist/engine/ingest-export.js +7 -6
  7. package/dist/engine/peak-demos.js +8 -1
  8. package/dist/engine/person-dimension-summary.js +8 -1
  9. package/dist/engine/person-facet-lines.js +8 -1
  10. package/dist/engine/person-headline.js +8 -1
  11. package/dist/engine/person-report.js +8 -1
  12. package/dist/engine/person-self-image.js +8 -1
  13. package/dist/engine/public-report.js +15 -7
  14. package/dist/engine/run-analysis.js +8 -1
  15. package/dist/engine/run-tagger.js +8 -1
  16. package/dist/index.js +19600 -17706
  17. package/dist/pipeline/FOCUS-EXAMPLES.md +127 -0
  18. package/dist/pipeline/FOCUS-RUBRIC.md +418 -0
  19. package/dist/pipeline/coding-agglomerate.js +947 -79
  20. package/dist/pipeline/coding-aggregate.js +443 -23
  21. package/dist/pipeline/coding-build.js +569 -97
  22. package/dist/pipeline/coding-coaching.js +651 -101
  23. package/dist/pipeline/coding-day-digest.js +417 -36
  24. package/dist/pipeline/coding-delegation.js +564 -68
  25. package/dist/pipeline/coding-expertise.js +477 -59
  26. package/dist/pipeline/coding-flow.js +424 -15
  27. package/dist/pipeline/coding-focus.js +507 -51
  28. package/dist/pipeline/coding-frontier-detail.js +465 -47
  29. package/dist/pipeline/coding-frontier.js +7 -6
  30. package/dist/pipeline/coding-gap-dist.js +424 -15
  31. package/dist/pipeline/coding-gap.js +679 -128
  32. package/dist/pipeline/coding-grade.js +469 -42
  33. package/dist/pipeline/coding-growth.js +17041 -0
  34. package/dist/pipeline/coding-nutshell.js +168 -151
  35. package/dist/pipeline/coding-projects.js +7 -6
  36. package/dist/pipeline/coding-walkthrough.js +461 -37
  37. package/dist/pipeline/coding-workbrief.js +16387 -0
  38. package/dist/web/app.js +2095 -1396
  39. package/dist/web/styles.css +1 -1
  40. package/package.json +1 -1
@@ -134,13 +134,13 @@ var require_secure_json_parse = __commonJS({
134
134
  });
135
135
 
136
136
  // ../../scripts/coding-walkthrough.mts
137
- import { promises as fs6 } from "fs";
138
- import path11 from "path";
137
+ import { promises as fs7 } from "fs";
138
+ import path12 from "path";
139
139
 
140
140
  // ../../lib/agents/coding/walkthrough.ts
141
- import { promises as fs5 } from "fs";
142
- import os2 from "os";
143
- import path9 from "path";
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
- if (inv.model && !/^claude/i.test(inv.model)) args.push("--model", inv.model);
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: path12, errorMaps, issueData } = params;
2180
- const fullPath = [...path12, ...issueData.path || []];
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, path12, key) {
2303
+ constructor(parent, value, path13, key) {
2297
2304
  this._cachedPath = [];
2298
2305
  this.parent = parent;
2299
2306
  this.data = value;
2300
- this._path = path12;
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: path12 }) => `${baseURL}${path12}`,
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: path12 }) => `${baseURL}${path12}`,
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: path12 }) => `${baseURL}${path12}`,
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: path12 }) => `${baseURL}${path12}`,
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: path12 }) => `${baseURL}${path12}`,
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: path12 }) => `${baseURL}${path12}`,
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: path12 }) => `${baseURL}${path12}`,
15147
+ url: ({ path: path13 }) => `${baseURL}${path13}`,
15141
15148
  headers: getHeaders,
15142
15149
  fetch: options.fetch
15143
15150
  });
@@ -15659,7 +15666,7 @@ function invokeAgent(inv, opts = {}) {
15659
15666
  }
15660
15667
 
15661
15668
  // ../coding-core/dist/messages.js
15662
- import { promises as fs4 } from "fs";
15669
+ import { promises as fs5 } from "fs";
15663
15670
 
15664
15671
  // ../coding-core/dist/injected.js
15665
15672
  var SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
@@ -15694,6 +15701,365 @@ function isHarnessEntry(e) {
15694
15701
  return e.isMeta === true || e.isCompactSummary === true;
15695
15702
  }
15696
15703
 
15704
+ // ../coding-core/dist/codex.js
15705
+ var SYSTEM_REMINDER_RE2 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
15706
+ var CODEX_INJECTED_TEXT_RE = /^\s*(<(environment_context|user_instructions|ENVIRONMENT_CONTEXT|turn_aborted)\b|#\s*AGENTS\.md instructions\b)/;
15707
+ function isCodexInjectedUserText(text2) {
15708
+ return CODEX_INJECTED_TEXT_RE.test(text2);
15709
+ }
15710
+ function codexContentText(content) {
15711
+ if (typeof content === "string")
15712
+ return content;
15713
+ if (!Array.isArray(content))
15714
+ return "";
15715
+ const parts = [];
15716
+ for (const item of content) {
15717
+ if (typeof item === "string") {
15718
+ parts.push(item);
15719
+ continue;
15720
+ }
15721
+ if (item && typeof item === "object") {
15722
+ const it = item;
15723
+ if (it.type === "input_text" || it.type === "output_text" || it.type === "text")
15724
+ parts.push(it.text || "");
15725
+ }
15726
+ }
15727
+ return parts.join("\n");
15728
+ }
15729
+ function sniffCodexRaw(raw) {
15730
+ let checked = 0;
15731
+ for (const lineRaw of raw.split("\n")) {
15732
+ const line = lineRaw.trim();
15733
+ if (!line)
15734
+ continue;
15735
+ if (checked++ >= 5)
15736
+ break;
15737
+ try {
15738
+ const e = JSON.parse(line);
15739
+ if (e.type === "session_meta" || e.type === "response_item" || e.type === "turn_context")
15740
+ return true;
15741
+ if (e.type === "user" || e.type === "assistant" || e.type === "summary" || e.type === "queue-operation")
15742
+ return false;
15743
+ } catch {
15744
+ }
15745
+ }
15746
+ return false;
15747
+ }
15748
+ var EXIT_CODE_RE = /(?:Process exited with code|Exit code:)\s+(\d+)/;
15749
+ function extractCodexEvents(raw) {
15750
+ const out = [];
15751
+ for (const lineRaw of raw.split("\n")) {
15752
+ const line = lineRaw.trim();
15753
+ if (!line)
15754
+ continue;
15755
+ let e;
15756
+ try {
15757
+ e = JSON.parse(line);
15758
+ } catch {
15759
+ continue;
15760
+ }
15761
+ if (e.type !== "response_item")
15762
+ continue;
15763
+ const p = e.payload ?? {};
15764
+ const t = typeof e.timestamp === "string" ? Date.parse(e.timestamp) : NaN;
15765
+ const ptype = p.type;
15766
+ if (ptype === "message") {
15767
+ const role = p.role;
15768
+ const text2 = codexContentText(p.content).replace(SYSTEM_REMINDER_RE2, "").trim();
15769
+ if (!text2)
15770
+ continue;
15771
+ if (role === "user") {
15772
+ if (isCodexInjectedUserText(text2))
15773
+ continue;
15774
+ out.push({ kind: "user", t, text: text2 });
15775
+ } else if (role === "assistant") {
15776
+ out.push({ kind: "assistant", t, text: text2 });
15777
+ }
15778
+ continue;
15779
+ }
15780
+ if (ptype === "function_call" || ptype === "custom_tool_call" || ptype === "local_shell_call") {
15781
+ const name17 = typeof p.name === "string" && p.name ? p.name : ptype === "local_shell_call" ? "shell" : String(ptype);
15782
+ const input = typeof p.arguments === "string" ? p.arguments : typeof p.input === "string" ? p.input : "";
15783
+ out.push({ kind: "tool", t, name: name17, input });
15784
+ continue;
15785
+ }
15786
+ if (ptype === "function_call_output" || ptype === "custom_tool_call_output") {
15787
+ const output = typeof p.output === "string" ? p.output : "";
15788
+ const m = EXIT_CODE_RE.exec(output.slice(0, 200));
15789
+ out.push({ kind: "tool_output", t, output, isError: !!m && m[1] !== "0" });
15790
+ }
15791
+ }
15792
+ return out;
15793
+ }
15794
+
15795
+ // ../coding-core/dist/cursor.js
15796
+ import { promises as fs4 } from "fs";
15797
+ var NODE_SQLITE = "node:sqlite";
15798
+ async function openCursorSqlite(dbPath) {
15799
+ try {
15800
+ await fs4.access(dbPath);
15801
+ } catch {
15802
+ return null;
15803
+ }
15804
+ let mod;
15805
+ try {
15806
+ mod = await import(NODE_SQLITE);
15807
+ } catch {
15808
+ return null;
15809
+ }
15810
+ const DatabaseSync = mod?.DatabaseSync;
15811
+ if (!DatabaseSync)
15812
+ return null;
15813
+ let db;
15814
+ try {
15815
+ db = new DatabaseSync(dbPath, { readOnly: true });
15816
+ } catch {
15817
+ try {
15818
+ db = new DatabaseSync(dbPath);
15819
+ } catch {
15820
+ return null;
15821
+ }
15822
+ }
15823
+ const asText = (v) => v == null ? null : typeof v === "string" ? v : Buffer.from(v).toString("utf-8");
15824
+ return {
15825
+ prefix(prefix) {
15826
+ try {
15827
+ const rows = db.prepare("SELECT key, value FROM cursorDiskKV WHERE key LIKE ? ESCAPE '\\'").all(likePrefix(prefix));
15828
+ return rows.map((r) => ({ key: r.key, value: asText(r.value) ?? "" }));
15829
+ } catch {
15830
+ return [];
15831
+ }
15832
+ },
15833
+ get(key) {
15834
+ try {
15835
+ const row = db.prepare("SELECT value FROM cursorDiskKV WHERE key = ?").get(key);
15836
+ return row ? asText(row.value) : null;
15837
+ } catch {
15838
+ return null;
15839
+ }
15840
+ },
15841
+ close() {
15842
+ try {
15843
+ db.close();
15844
+ } catch {
15845
+ }
15846
+ }
15847
+ };
15848
+ }
15849
+ function likePrefix(prefix) {
15850
+ return prefix.replace(/[\\%_]/g, (c) => "\\" + c) + "%";
15851
+ }
15852
+ var CURSOR_USER_QUERY_RE = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/;
15853
+ function cleanUserText(raw) {
15854
+ let t = raw.replace(SYSTEM_REMINDER_RE, "");
15855
+ const m = t.match(CURSOR_USER_QUERY_RE);
15856
+ if (m)
15857
+ t = m[1];
15858
+ return t.trim();
15859
+ }
15860
+ var msFrom = (v) => {
15861
+ if (typeof v === "number" && Number.isFinite(v))
15862
+ return v;
15863
+ if (typeof v === "string") {
15864
+ const n = Date.parse(v);
15865
+ return Number.isFinite(n) ? n : null;
15866
+ }
15867
+ return null;
15868
+ };
15869
+ function readCursorComposer(db, composerId) {
15870
+ const cdRaw = db.get(`composerData:${composerId}`);
15871
+ if (!cdRaw)
15872
+ return null;
15873
+ let cd;
15874
+ try {
15875
+ cd = JSON.parse(cdRaw);
15876
+ } catch {
15877
+ return null;
15878
+ }
15879
+ const headers = Array.isArray(cd.fullConversationHeadersOnly) ? cd.fullConversationHeadersOnly : [];
15880
+ if (headers.length === 0)
15881
+ return null;
15882
+ const bubbles = /* @__PURE__ */ new Map();
15883
+ for (const row of db.prefix(`bubbleId:${composerId}:`)) {
15884
+ const bid = row.key.slice(`bubbleId:${composerId}:`.length);
15885
+ try {
15886
+ bubbles.set(bid, JSON.parse(row.value));
15887
+ } catch {
15888
+ }
15889
+ }
15890
+ const turns = [];
15891
+ let clock = msFrom(cd.createdAt) ?? 0;
15892
+ for (const h of headers) {
15893
+ const b = bubbles.get(h.bubbleId);
15894
+ if (!b)
15895
+ continue;
15896
+ const type = h.type === 1 ? 1 : 2;
15897
+ const tool2 = type === 2 && b.toolFormerData && typeof b.toolFormerData.name === "string" ? b.toolFormerData.name : null;
15898
+ const rawText = typeof b.text === "string" ? b.text : "";
15899
+ const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
15900
+ if (!text2 && !tool2)
15901
+ continue;
15902
+ const t = msFrom(b.createdAt);
15903
+ clock = Math.max(clock, t ?? clock + 1);
15904
+ const model = b.modelInfo && typeof b.modelInfo.modelName === "string" ? b.modelInfo.modelName : null;
15905
+ turns.push({ t: clock, type, text: text2, tool: tool2, model });
15906
+ }
15907
+ if (turns.length === 0)
15908
+ return null;
15909
+ const gitRepo = Array.isArray(cd.trackedGitRepos) && cd.trackedGitRepos[0] && typeof cd.trackedGitRepos[0].repoPath === "string" ? cd.trackedGitRepos[0].repoPath : null;
15910
+ return {
15911
+ composerId,
15912
+ createdAt: msFrom(cd.createdAt),
15913
+ updatedAt: msFrom(cd.lastUpdatedAt),
15914
+ name: typeof cd.name === "string" && cd.name.trim() ? cd.name.trim() : null,
15915
+ gitRepo,
15916
+ turns
15917
+ };
15918
+ }
15919
+ function sniffCursorRaw(raw) {
15920
+ for (const lineRaw of raw.split("\n")) {
15921
+ const line = lineRaw.trim();
15922
+ if (!line)
15923
+ continue;
15924
+ try {
15925
+ const e = JSON.parse(line);
15926
+ return (e.role === "user" || e.role === "assistant") && typeof e.message === "object" && e.message !== null && "content" in e.message && !("type" in e);
15927
+ } catch {
15928
+ return false;
15929
+ }
15930
+ }
15931
+ return false;
15932
+ }
15933
+ function jsonlText(content) {
15934
+ const parts = [];
15935
+ const tools = [];
15936
+ if (Array.isArray(content)) {
15937
+ for (const item of content) {
15938
+ if (!item || typeof item !== "object")
15939
+ continue;
15940
+ const it = item;
15941
+ if (it.type === "text" && it.text)
15942
+ parts.push(it.text);
15943
+ else if (it.type === "tool_use" && it.name)
15944
+ tools.push(it.name);
15945
+ }
15946
+ } else if (typeof content === "string")
15947
+ parts.push(content);
15948
+ return { text: parts.join("\n"), tools };
15949
+ }
15950
+ function parseCursorJsonl(raw, base) {
15951
+ const turns = [];
15952
+ let clock = base;
15953
+ for (const lineRaw of raw.split("\n")) {
15954
+ const line = lineRaw.trim();
15955
+ if (!line)
15956
+ continue;
15957
+ let e;
15958
+ try {
15959
+ e = JSON.parse(line);
15960
+ } catch {
15961
+ continue;
15962
+ }
15963
+ if (e.role !== "user" && e.role !== "assistant")
15964
+ continue;
15965
+ const { text: rawText, tools } = jsonlText(e.message?.content);
15966
+ const type = e.role === "user" ? 1 : 2;
15967
+ const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
15968
+ if (type === 2 && tools.length) {
15969
+ for (const tool2 of tools) {
15970
+ clock += 1;
15971
+ turns.push({ t: clock, type: 2, text: "", tool: tool2, model: null });
15972
+ }
15973
+ }
15974
+ if (!text2)
15975
+ continue;
15976
+ clock += 1;
15977
+ turns.push({ t: clock, type, text: text2, tool: null, model: null });
15978
+ }
15979
+ if (turns.length === 0)
15980
+ return null;
15981
+ return { composerId: "", createdAt: base, updatedAt: clock, name: null, gitRepo: null, turns };
15982
+ }
15983
+ function cursorMessages(c) {
15984
+ const out = [];
15985
+ let aiStart = 0;
15986
+ let aiParts = [];
15987
+ const flushAI = () => {
15988
+ if (!aiParts.length)
15989
+ return;
15990
+ out.push({ t: aiStart, role: "ai", text: aiParts.join("\n") });
15991
+ aiParts = [];
15992
+ };
15993
+ for (const turn of c.turns) {
15994
+ if (turn.type === 1) {
15995
+ flushAI();
15996
+ out.push({ t: turn.t, role: "user", text: turn.text });
15997
+ } else {
15998
+ if (aiParts.length === 0)
15999
+ aiStart = turn.t;
16000
+ if (turn.text)
16001
+ aiParts.push(turn.text);
16002
+ }
16003
+ }
16004
+ flushAI();
16005
+ return out;
16006
+ }
16007
+ function composerIdFromFile(file2) {
16008
+ const m = file2.match(/agent-transcripts\/([^/]+)\/[^/]+\.jsonl$/);
16009
+ return m ? m[1] : null;
16010
+ }
16011
+ async function loadCursorComposer(file2, raw, dbPath) {
16012
+ const cid = composerIdFromFile(file2);
16013
+ if (cid && dbPath) {
16014
+ const db = await openCursorSqlite(dbPath);
16015
+ if (db) {
16016
+ try {
16017
+ const c = readCursorComposer(db, cid);
16018
+ if (c)
16019
+ return c;
16020
+ } finally {
16021
+ db.close();
16022
+ }
16023
+ }
16024
+ }
16025
+ return parseCursorJsonl(raw, 0);
16026
+ }
16027
+
16028
+ // ../coding-core/dist/raw.js
16029
+ import path9 from "path";
16030
+ import os2 from "os";
16031
+ var SOURCE_ROOT_ENV_VARS = [
16032
+ "CLAUDE_PROJECTS_DIR",
16033
+ "CODEX_SESSIONS_DIR",
16034
+ "CURSOR_WORKSPACE_DIR",
16035
+ "CURSOR_PROJECTS_DIR",
16036
+ // Cursor's globalStorage dir (holds state.vscdb — the composer bubbles that
16037
+ // carry a Cursor session's real per-turn timestamps + content). Same
16038
+ // isolation contract: overriding any root disables every unset source.
16039
+ "CURSOR_GLOBAL_DIR"
16040
+ ];
16041
+ var anyRootOverridden = () => SOURCE_ROOT_ENV_VARS.some((v) => !!process.env[v]);
16042
+ function resolveSourceRoot(envVar, ...defaultSegments) {
16043
+ const explicit = process.env[envVar];
16044
+ if (explicit)
16045
+ return explicit;
16046
+ if (anyRootOverridden())
16047
+ return null;
16048
+ return path9.join(os2.homedir(), ...defaultSegments);
16049
+ }
16050
+ var cursorGlobalRoot = () => resolveSourceRoot("CURSOR_GLOBAL_DIR", "Library", "Application Support", "Cursor", "User", "globalStorage");
16051
+ function cursorGlobalDbPath() {
16052
+ const root = cursorGlobalRoot();
16053
+ return root === null ? null : path9.join(root, "state.vscdb");
16054
+ }
16055
+ var MACHINE_CURSOR_FILE_RE = /^(.*[/\\]machines[/\\][^/\\]+[/\\]\.cursor)[/\\]projects[/\\]/;
16056
+ function cursorDbPathForFile(file2) {
16057
+ const m = file2.match(MACHINE_CURSOR_FILE_RE);
16058
+ if (m)
16059
+ return path9.join(m[1], "globalStorage", "state.vscdb");
16060
+ return cursorGlobalDbPath();
16061
+ }
16062
+
15697
16063
  // ../coding-core/dist/messages.js
15698
16064
  function extractText(content) {
15699
16065
  if (typeof content === "string")
@@ -15705,13 +16071,62 @@ function extractText(content) {
15705
16071
  function isToolResultOnly(content) {
15706
16072
  return Array.isArray(content) && content.length > 0 && content.every((c) => c && typeof c === "object" && c.type === "tool_result");
15707
16073
  }
16074
+ function extractMessagesCodex(raw) {
16075
+ const out = [];
16076
+ let aiProse = [];
16077
+ let aiTools = {};
16078
+ let aiStart = 0;
16079
+ const flushAI = () => {
16080
+ if (!aiProse.length && Object.keys(aiTools).length === 0)
16081
+ return;
16082
+ const toolStr = Object.entries(aiTools).map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
16083
+ let prose = aiProse.join(" ").replace(/\s+/g, " ").trim();
16084
+ if (prose.length > 2200)
16085
+ prose = prose.slice(0, 2200) + "\u2026";
16086
+ let text2 = prose;
16087
+ if (toolStr)
16088
+ text2 = (text2 ? text2 + " " : "") + `[ran ${toolStr}]`;
16089
+ if (text2)
16090
+ out.push({ t: aiStart, role: "ai", text: text2 });
16091
+ aiProse = [];
16092
+ aiTools = {};
16093
+ };
16094
+ for (const ev of extractCodexEvents(raw)) {
16095
+ if (!Number.isFinite(ev.t))
16096
+ continue;
16097
+ if (ev.kind === "user") {
16098
+ const text2 = humanTypedText(ev.text);
16099
+ if (text2) {
16100
+ flushAI();
16101
+ out.push({ t: ev.t, role: "user", text: text2 });
16102
+ }
16103
+ } else if (ev.kind === "assistant") {
16104
+ if (!aiProse.length && Object.keys(aiTools).length === 0)
16105
+ aiStart = ev.t;
16106
+ if (ev.text)
16107
+ aiProse.push(ev.text);
16108
+ } else if (ev.kind === "tool") {
16109
+ if (!aiProse.length && Object.keys(aiTools).length === 0)
16110
+ aiStart = ev.t;
16111
+ aiTools[ev.name] = (aiTools[ev.name] ?? 0) + 1;
16112
+ }
16113
+ }
16114
+ flushAI();
16115
+ return out.sort((a, b) => a.t - b.t);
16116
+ }
15708
16117
  async function extractMessages(file2) {
15709
16118
  let raw;
15710
16119
  try {
15711
- raw = await fs4.readFile(file2, "utf-8");
16120
+ raw = await fs5.readFile(file2, "utf-8");
15712
16121
  } catch {
15713
16122
  return [];
15714
16123
  }
16124
+ if (sniffCodexRaw(raw))
16125
+ return extractMessagesCodex(raw);
16126
+ if (sniffCursorRaw(raw)) {
16127
+ const c = await loadCursorComposer(file2, raw, cursorDbPathForFile(file2));
16128
+ return c ? cursorMessages(c) : [];
16129
+ }
15715
16130
  const out = [];
15716
16131
  const userTexts = /* @__PURE__ */ new Set();
15717
16132
  const seenUuids = /* @__PURE__ */ new Set();
@@ -15863,7 +16278,7 @@ async function buildWalkthrough(rec, opts) {
15863
16278
  const times = msgs.map((m) => m.t);
15864
16279
  const sessionEnd = Math.max(...times);
15865
16280
  const { text: text2, turnT, userTurns } = buildTranscript(msgs, tz);
15866
- const sandbox = await fs5.mkdtemp(path9.join(os2.tmpdir(), "ps-coding-walk-"));
16281
+ const sandbox = await fs6.mkdtemp(path10.join(os3.tmpdir(), "ps-coding-walk-"));
15867
16282
  try {
15868
16283
  const run2 = await invokeAgent({
15869
16284
  prompt: buildPrompt(rec, text2),
@@ -15886,16 +16301,16 @@ async function buildWalkthrough(rec, opts) {
15886
16301
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
15887
16302
  meta: { costUsd: run2.costUsd }
15888
16303
  };
15889
- await fs5.mkdir(opts.outDir, { recursive: true });
15890
- await fs5.writeFile(path9.join(opts.outDir, `${rec.sessionId}.json`), JSON.stringify(wt, null, 2));
16304
+ await fs6.mkdir(opts.outDir, { recursive: true });
16305
+ await fs6.writeFile(path10.join(opts.outDir, `${rec.sessionId}.json`), JSON.stringify(wt, null, 2));
15891
16306
  return wt;
15892
16307
  } finally {
15893
- await fs5.rm(sandbox, { recursive: true, force: true }).catch(() => {
16308
+ await fs6.rm(sandbox, { recursive: true, force: true }).catch(() => {
15894
16309
  });
15895
16310
  }
15896
16311
  }
15897
16312
  async function readWalkthrough(outDir, sessionId) {
15898
- return fs5.readFile(path9.join(outDir, `${sessionId}.json`), "utf8").then(JSON.parse).catch(() => null);
16313
+ return fs6.readFile(path10.join(outDir, `${sessionId}.json`), "utf8").then(JSON.parse).catch(() => null);
15899
16314
  }
15900
16315
 
15901
16316
  // ../coding-core/dist/gate.js
@@ -15952,7 +16367,7 @@ function capGradable(gradable) {
15952
16367
  }
15953
16368
 
15954
16369
  // ../../lib/agents/coding/profile.ts
15955
- import path10 from "path";
16370
+ import path11 from "path";
15956
16371
 
15957
16372
  // ../../lib/calibration/fingerprint.ts
15958
16373
  import { createHash } from "node:crypto";
@@ -16103,7 +16518,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
16103
16518
 
16104
16519
  // ../../lib/calibration/index.ts
16105
16520
  var DEFAULT_CALIBRATION = {
16106
- version: "2026-07-16.2",
16521
+ version: "2026-07-21.1",
16107
16522
  // = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
16108
16523
  // src/grade/criteria.ts). A unit test fails loud when the rubric changes
16109
16524
  // without this being updated (and re-pushed to the server).
@@ -16199,13 +16614,14 @@ var DEFAULT_CALIBRATION = {
16199
16614
  },
16200
16615
  codingBenchmarks: {
16201
16616
  flow: {
16202
- // typical knowledge worker ≈ 35% of an 8h day focused; ~4h/day is the
16203
- // recognized deep-work ceiling (Newport) 50% most sit far below it.
16617
+ // typical knowledge worker ≈ 35% of an 8h day focused; the ~4h/day
16618
+ // deep-work ceiling (Newport) sits nearer ~40% of a real (9-10h) top
16619
+ // performer's day — 50% overstated it (owner call 2026-07-21).
16204
16620
  typicalPctOfDay: 0.35,
16205
- topPctOfDay: 0.5,
16621
+ topPctOfDay: 0.4,
16206
16622
  tag: "measured",
16207
- source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling)",
16208
- line: "the best spend ~half the workday in true deep flow; ~4h/day is the human ceiling"
16623
+ source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling against a 9-10h day)",
16624
+ line: "the best spend ~40% of the workday in true deep flow; ~4h/day is the human ceiling"
16209
16625
  },
16210
16626
  longestRun: {
16211
16627
  typicalHours: 0.67,
@@ -16254,8 +16670,8 @@ var BEST = DEFAULT_CALIBRATION.codingBenchmarks;
16254
16670
 
16255
16671
  // ../../lib/agents/coding/profile.ts
16256
16672
  var ROOT = process.cwd();
16257
- var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path10.join(process.env.POLYMATH_DATA_DIR, "coding") : path10.join(ROOT, ".data", "coding");
16258
- var GRADES = path10.join(CODING_DIR, "grades");
16673
+ var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path11.join(process.env.POLYMATH_DATA_DIR, "coding") : path11.join(ROOT, ".data", "coding");
16674
+ var GRADES = path11.join(CODING_DIR, "grades");
16259
16675
 
16260
16676
  // ../../scripts/coding-walkthrough.mts
16261
16677
  var argv = process.argv.slice(2);
@@ -16267,7 +16683,7 @@ var MODEL = flag("model", "sonnet");
16267
16683
  var CONC = Number(flag("conc", "8"));
16268
16684
  var REGEN = argv.includes("--regen");
16269
16685
  var CODING = CODING_DIR;
16270
- var DIR = path11.join(CODING, "walkthroughs");
16686
+ var DIR = path12.join(CODING, "walkthroughs");
16271
16687
  function limiter(max) {
16272
16688
  let a = 0;
16273
16689
  const q = [];
@@ -16283,12 +16699,12 @@ function limiter(max) {
16283
16699
  };
16284
16700
  }
16285
16701
  async function main() {
16286
- const sessions = JSON.parse(await fs6.readFile(path11.join(CODING, "sessions.json"), "utf8"));
16702
+ const sessions = JSON.parse(await fs7.readFile(path12.join(CODING, "sessions.json"), "utf8"));
16287
16703
  const live = sessions.filter((s) => s.klass === "interactive" && !s.duplicateOf);
16288
16704
  const cutoff = aiWindowCutoff(live);
16289
16705
  const eligible = live.filter((s) => !isTrivial(s) && (!cutoff || (s.start ?? "") >= cutoff));
16290
16706
  const todo = capGradable(eligible);
16291
- await fs6.mkdir(DIR, { recursive: true });
16707
+ await fs7.mkdir(DIR, { recursive: true });
16292
16708
  const pending = [];
16293
16709
  for (const s of todo) {
16294
16710
  if (!REGEN && await readWalkthrough(DIR, s.sessionId)) continue;
@@ -16298,10 +16714,12 @@ async function main() {
16298
16714
  if (todo.length < eligible.length) console.log(`[walkthrough] cap: the ${todo.length} richest of ${eligible.length} eligible sessions (POLYMATH_MAX_GRADED; 0 = uncapped)`);
16299
16715
  const lim = limiter(CONC);
16300
16716
  startRun("walkthrough", pending.length);
16717
+ let doneN = 0;
16301
16718
  await Promise.all(pending.map((s) => lim(async () => {
16302
16719
  try {
16303
16720
  const w = await buildWalkthrough(s, { model: MODEL, outDir: DIR });
16304
16721
  tick(!!w);
16722
+ if (w) doneN++;
16305
16723
  console.log(` \u2022 ${s.title.slice(0, 46)} \u2192 ${w ? w.phases.length + " phases" : "skip"}`);
16306
16724
  } catch (e) {
16307
16725
  tick(false);
@@ -16309,7 +16727,13 @@ async function main() {
16309
16727
  }
16310
16728
  })));
16311
16729
  endRun();
16312
- console.log(`[walkthrough] done \u2192 ${path11.relative(process.cwd(), DIR)}/`);
16730
+ if (pending.length > 0 && doneN === 0) {
16731
+ console.error(`
16732
+ [walkthrough] FATAL: 0 of ${pending.length} attempted sessions produced a walkthrough \u2014 every attempt failed.`);
16733
+ console.error(`[walkthrough] Likely cause: unreadable or unsupported transcript files (a log format the reader cannot parse). Fix ingestion, then re-run this stage.`);
16734
+ process.exit(1);
16735
+ }
16736
+ console.log(`[walkthrough] done \u2192 ${path12.relative(process.cwd(), DIR)}/`);
16313
16737
  }
16314
16738
  main().catch((e) => {
16315
16739
  console.error(e);