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.
Files changed (38) hide show
  1. package/dist/cli.js +23943 -21630
  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 +19647 -17969
  17. package/dist/pipeline/coding-agglomerate.js +826 -82
  18. package/dist/pipeline/coding-aggregate.js +307 -23
  19. package/dist/pipeline/coding-build.js +453 -95
  20. package/dist/pipeline/coding-coaching.js +479 -88
  21. package/dist/pipeline/coding-day-digest.js +308 -36
  22. package/dist/pipeline/coding-delegation.js +376 -52
  23. package/dist/pipeline/coding-expertise.js +356 -62
  24. package/dist/pipeline/coding-flow.js +288 -15
  25. package/dist/pipeline/coding-focus.js +371 -51
  26. package/dist/pipeline/coding-frontier-detail.js +344 -50
  27. package/dist/pipeline/coding-frontier.js +7 -6
  28. package/dist/pipeline/coding-gap-dist.js +288 -15
  29. package/dist/pipeline/coding-gap.js +507 -115
  30. package/dist/pipeline/coding-grade.js +342 -45
  31. package/dist/pipeline/coding-growth.js +17041 -0
  32. package/dist/pipeline/coding-nutshell.js +15 -7
  33. package/dist/pipeline/coding-projects.js +7 -6
  34. package/dist/pipeline/coding-walkthrough.js +317 -37
  35. package/dist/pipeline/coding-workbrief.js +16387 -0
  36. package/dist/web/app.js +2095 -1395
  37. package/dist/web/styles.css +1 -1
  38. package/package.json +1 -1
@@ -134,7 +134,7 @@ var require_secure_json_parse = __commonJS({
134
134
  });
135
135
 
136
136
  // ../../scripts/coding-frontier-detail.mts
137
- import { promises as fs7 } from "fs";
137
+ import { promises as fs8 } from "fs";
138
138
 
139
139
  // ../../lib/agents/shared/agent.ts
140
140
  import { readFileSync } from "fs";
@@ -502,6 +502,13 @@ ${report}`);
502
502
  }
503
503
 
504
504
  // ../../lib/agents/shared/codexAdapter.ts
505
+ var CODEX_DEFAULT_MODEL = "gpt-5.5";
506
+ var CODEX_MINI_MODEL = "gpt-5.4-mini";
507
+ function mapCodexTier(model, env = process.env) {
508
+ if (model && !/^(claude|haiku|sonnet|opus)/i.test(model)) return model;
509
+ if (model && /^haiku/i.test(model)) return env.POLYMATH_CODEX_MODEL_MINI || CODEX_MINI_MODEL;
510
+ return env.POLYMATH_CODEX_MODEL || CODEX_DEFAULT_MODEL;
511
+ }
505
512
  function composePrompt(inv, roots) {
506
513
  return [
507
514
  inv.systemPrompt ? `<system>
@@ -542,7 +549,7 @@ var codexAdapter = {
542
549
  "read-only",
543
550
  "--json"
544
551
  ];
545
- if (inv.model && !/^claude/i.test(inv.model)) args.push("--model", inv.model);
552
+ args.push("--model", mapCodexTier(inv.model));
546
553
  args.push(composePrompt(inv, roots));
547
554
  const started = Date.now();
548
555
  const toolCalls = [];
@@ -2170,8 +2177,8 @@ function getErrorMap() {
2170
2177
 
2171
2178
  // ../../node_modules/zod/v3/helpers/parseUtil.js
2172
2179
  var makeIssue = (params) => {
2173
- const { data, path: path11, errorMaps, issueData } = params;
2174
- const fullPath = [...path11, ...issueData.path || []];
2180
+ const { data, path: path12, errorMaps, issueData } = params;
2181
+ const fullPath = [...path12, ...issueData.path || []];
2175
2182
  const fullIssue = {
2176
2183
  ...issueData,
2177
2184
  path: fullPath
@@ -2287,11 +2294,11 @@ var errorUtil;
2287
2294
 
2288
2295
  // ../../node_modules/zod/v3/types.js
2289
2296
  var ParseInputLazyPath = class {
2290
- constructor(parent, value, path11, key) {
2297
+ constructor(parent, value, path12, key) {
2291
2298
  this._cachedPath = [];
2292
2299
  this.parent = parent;
2293
2300
  this.data = value;
2294
- this._path = path11;
2301
+ this._path = path12;
2295
2302
  this._key = key;
2296
2303
  }
2297
2304
  get path() {
@@ -15078,39 +15085,39 @@ function createOpenAI(options = {}) {
15078
15085
  });
15079
15086
  const createChatModel = (modelId, settings = {}) => new OpenAIChatLanguageModel(modelId, settings, {
15080
15087
  provider: `${providerName}.chat`,
15081
- url: ({ path: path11 }) => `${baseURL}${path11}`,
15088
+ url: ({ path: path12 }) => `${baseURL}${path12}`,
15082
15089
  headers: getHeaders,
15083
15090
  compatibility,
15084
15091
  fetch: options.fetch
15085
15092
  });
15086
15093
  const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
15087
15094
  provider: `${providerName}.completion`,
15088
- url: ({ path: path11 }) => `${baseURL}${path11}`,
15095
+ url: ({ path: path12 }) => `${baseURL}${path12}`,
15089
15096
  headers: getHeaders,
15090
15097
  compatibility,
15091
15098
  fetch: options.fetch
15092
15099
  });
15093
15100
  const createEmbeddingModel = (modelId, settings = {}) => new OpenAIEmbeddingModel(modelId, settings, {
15094
15101
  provider: `${providerName}.embedding`,
15095
- url: ({ path: path11 }) => `${baseURL}${path11}`,
15102
+ url: ({ path: path12 }) => `${baseURL}${path12}`,
15096
15103
  headers: getHeaders,
15097
15104
  fetch: options.fetch
15098
15105
  });
15099
15106
  const createImageModel = (modelId, settings = {}) => new OpenAIImageModel(modelId, settings, {
15100
15107
  provider: `${providerName}.image`,
15101
- url: ({ path: path11 }) => `${baseURL}${path11}`,
15108
+ url: ({ path: path12 }) => `${baseURL}${path12}`,
15102
15109
  headers: getHeaders,
15103
15110
  fetch: options.fetch
15104
15111
  });
15105
15112
  const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
15106
15113
  provider: `${providerName}.transcription`,
15107
- url: ({ path: path11 }) => `${baseURL}${path11}`,
15114
+ url: ({ path: path12 }) => `${baseURL}${path12}`,
15108
15115
  headers: getHeaders,
15109
15116
  fetch: options.fetch
15110
15117
  });
15111
15118
  const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
15112
15119
  provider: `${providerName}.speech`,
15113
- url: ({ path: path11 }) => `${baseURL}${path11}`,
15120
+ url: ({ path: path12 }) => `${baseURL}${path12}`,
15114
15121
  headers: getHeaders,
15115
15122
  fetch: options.fetch
15116
15123
  });
@@ -15131,7 +15138,7 @@ function createOpenAI(options = {}) {
15131
15138
  const createResponsesModel = (modelId) => {
15132
15139
  return new OpenAIResponsesLanguageModel(modelId, {
15133
15140
  provider: `${providerName}.responses`,
15134
- url: ({ path: path11 }) => `${baseURL}${path11}`,
15141
+ url: ({ path: path12 }) => `${baseURL}${path12}`,
15135
15142
  headers: getHeaders,
15136
15143
  fetch: options.fetch
15137
15144
  });
@@ -15628,19 +15635,20 @@ function invokeAgent(inv, opts = {}) {
15628
15635
  }
15629
15636
 
15630
15637
  // ../../lib/agents/coding/docsDir.ts
15631
- import { promises as fs5 } from "fs";
15632
- import path9 from "path";
15638
+ import { promises as fs6 } from "fs";
15639
+ import path10 from "path";
15633
15640
 
15634
15641
  // ../../lib/agents/coding/materialize.ts
15635
- import { promises as fs4 } from "fs";
15642
+ import { promises as fs5 } from "fs";
15636
15643
 
15637
15644
  // ../coding-core/dist/injected.js
15645
+ var SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
15638
15646
  function isHarnessEntry(e) {
15639
15647
  return e.isMeta === true || e.isCompactSummary === true;
15640
15648
  }
15641
15649
 
15642
15650
  // ../coding-core/dist/codex.js
15643
- var SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
15651
+ var SYSTEM_REMINDER_RE2 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
15644
15652
  var CODEX_INJECTED_TEXT_RE = /^\s*(<(environment_context|user_instructions|ENVIRONMENT_CONTEXT|turn_aborted)\b|#\s*AGENTS\.md instructions\b)/;
15645
15653
  function isCodexInjectedUserText(text2) {
15646
15654
  return CODEX_INJECTED_TEXT_RE.test(text2);
@@ -15703,7 +15711,7 @@ function extractCodexEvents(raw) {
15703
15711
  const ptype = p.type;
15704
15712
  if (ptype === "message") {
15705
15713
  const role = p.role;
15706
- const text2 = codexContentText(p.content).replace(SYSTEM_REMINDER_RE, "").trim();
15714
+ const text2 = codexContentText(p.content).replace(SYSTEM_REMINDER_RE2, "").trim();
15707
15715
  if (!text2)
15708
15716
  continue;
15709
15717
  if (role === "user") {
@@ -15730,8 +15738,288 @@ function extractCodexEvents(raw) {
15730
15738
  return out;
15731
15739
  }
15732
15740
 
15741
+ // ../coding-core/dist/cursor.js
15742
+ import { promises as fs4 } from "fs";
15743
+ var NODE_SQLITE = "node:sqlite";
15744
+ async function openCursorSqlite(dbPath) {
15745
+ try {
15746
+ await fs4.access(dbPath);
15747
+ } catch {
15748
+ return null;
15749
+ }
15750
+ let mod;
15751
+ try {
15752
+ mod = await import(NODE_SQLITE);
15753
+ } catch {
15754
+ return null;
15755
+ }
15756
+ const DatabaseSync = mod?.DatabaseSync;
15757
+ if (!DatabaseSync)
15758
+ return null;
15759
+ let db;
15760
+ try {
15761
+ db = new DatabaseSync(dbPath, { readOnly: true });
15762
+ } catch {
15763
+ try {
15764
+ db = new DatabaseSync(dbPath);
15765
+ } catch {
15766
+ return null;
15767
+ }
15768
+ }
15769
+ const asText = (v) => v == null ? null : typeof v === "string" ? v : Buffer.from(v).toString("utf-8");
15770
+ return {
15771
+ prefix(prefix) {
15772
+ try {
15773
+ const rows = db.prepare("SELECT key, value FROM cursorDiskKV WHERE key LIKE ? ESCAPE '\\'").all(likePrefix(prefix));
15774
+ return rows.map((r) => ({ key: r.key, value: asText(r.value) ?? "" }));
15775
+ } catch {
15776
+ return [];
15777
+ }
15778
+ },
15779
+ get(key) {
15780
+ try {
15781
+ const row = db.prepare("SELECT value FROM cursorDiskKV WHERE key = ?").get(key);
15782
+ return row ? asText(row.value) : null;
15783
+ } catch {
15784
+ return null;
15785
+ }
15786
+ },
15787
+ close() {
15788
+ try {
15789
+ db.close();
15790
+ } catch {
15791
+ }
15792
+ }
15793
+ };
15794
+ }
15795
+ function likePrefix(prefix) {
15796
+ return prefix.replace(/[\\%_]/g, (c) => "\\" + c) + "%";
15797
+ }
15798
+ var CURSOR_USER_QUERY_RE = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/;
15799
+ function cleanUserText(raw) {
15800
+ let t = raw.replace(SYSTEM_REMINDER_RE, "");
15801
+ const m = t.match(CURSOR_USER_QUERY_RE);
15802
+ if (m)
15803
+ t = m[1];
15804
+ return t.trim();
15805
+ }
15806
+ var msFrom = (v) => {
15807
+ if (typeof v === "number" && Number.isFinite(v))
15808
+ return v;
15809
+ if (typeof v === "string") {
15810
+ const n = Date.parse(v);
15811
+ return Number.isFinite(n) ? n : null;
15812
+ }
15813
+ return null;
15814
+ };
15815
+ function readCursorComposer(db, composerId) {
15816
+ const cdRaw = db.get(`composerData:${composerId}`);
15817
+ if (!cdRaw)
15818
+ return null;
15819
+ let cd;
15820
+ try {
15821
+ cd = JSON.parse(cdRaw);
15822
+ } catch {
15823
+ return null;
15824
+ }
15825
+ const headers = Array.isArray(cd.fullConversationHeadersOnly) ? cd.fullConversationHeadersOnly : [];
15826
+ if (headers.length === 0)
15827
+ return null;
15828
+ const bubbles = /* @__PURE__ */ new Map();
15829
+ for (const row of db.prefix(`bubbleId:${composerId}:`)) {
15830
+ const bid = row.key.slice(`bubbleId:${composerId}:`.length);
15831
+ try {
15832
+ bubbles.set(bid, JSON.parse(row.value));
15833
+ } catch {
15834
+ }
15835
+ }
15836
+ const turns = [];
15837
+ let clock = msFrom(cd.createdAt) ?? 0;
15838
+ for (const h of headers) {
15839
+ const b = bubbles.get(h.bubbleId);
15840
+ if (!b)
15841
+ continue;
15842
+ const type = h.type === 1 ? 1 : 2;
15843
+ const tool2 = type === 2 && b.toolFormerData && typeof b.toolFormerData.name === "string" ? b.toolFormerData.name : null;
15844
+ const rawText = typeof b.text === "string" ? b.text : "";
15845
+ const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
15846
+ if (!text2 && !tool2)
15847
+ continue;
15848
+ const t = msFrom(b.createdAt);
15849
+ clock = Math.max(clock, t ?? clock + 1);
15850
+ const model = b.modelInfo && typeof b.modelInfo.modelName === "string" ? b.modelInfo.modelName : null;
15851
+ turns.push({ t: clock, type, text: text2, tool: tool2, model });
15852
+ }
15853
+ if (turns.length === 0)
15854
+ return null;
15855
+ const gitRepo = Array.isArray(cd.trackedGitRepos) && cd.trackedGitRepos[0] && typeof cd.trackedGitRepos[0].repoPath === "string" ? cd.trackedGitRepos[0].repoPath : null;
15856
+ return {
15857
+ composerId,
15858
+ createdAt: msFrom(cd.createdAt),
15859
+ updatedAt: msFrom(cd.lastUpdatedAt),
15860
+ name: typeof cd.name === "string" && cd.name.trim() ? cd.name.trim() : null,
15861
+ gitRepo,
15862
+ turns
15863
+ };
15864
+ }
15865
+ function sniffCursorRaw(raw) {
15866
+ for (const lineRaw of raw.split("\n")) {
15867
+ const line = lineRaw.trim();
15868
+ if (!line)
15869
+ continue;
15870
+ try {
15871
+ const e = JSON.parse(line);
15872
+ return (e.role === "user" || e.role === "assistant") && typeof e.message === "object" && e.message !== null && "content" in e.message && !("type" in e);
15873
+ } catch {
15874
+ return false;
15875
+ }
15876
+ }
15877
+ return false;
15878
+ }
15879
+ function jsonlText(content) {
15880
+ const parts = [];
15881
+ const tools = [];
15882
+ if (Array.isArray(content)) {
15883
+ for (const item of content) {
15884
+ if (!item || typeof item !== "object")
15885
+ continue;
15886
+ const it = item;
15887
+ if (it.type === "text" && it.text)
15888
+ parts.push(it.text);
15889
+ else if (it.type === "tool_use" && it.name)
15890
+ tools.push(it.name);
15891
+ }
15892
+ } else if (typeof content === "string")
15893
+ parts.push(content);
15894
+ return { text: parts.join("\n"), tools };
15895
+ }
15896
+ function parseCursorJsonl(raw, base) {
15897
+ const turns = [];
15898
+ let clock = base;
15899
+ for (const lineRaw of raw.split("\n")) {
15900
+ const line = lineRaw.trim();
15901
+ if (!line)
15902
+ continue;
15903
+ let e;
15904
+ try {
15905
+ e = JSON.parse(line);
15906
+ } catch {
15907
+ continue;
15908
+ }
15909
+ if (e.role !== "user" && e.role !== "assistant")
15910
+ continue;
15911
+ const { text: rawText, tools } = jsonlText(e.message?.content);
15912
+ const type = e.role === "user" ? 1 : 2;
15913
+ const text2 = type === 1 ? cleanUserText(rawText) : rawText.replace(SYSTEM_REMINDER_RE, "").trim();
15914
+ if (type === 2 && tools.length) {
15915
+ for (const tool2 of tools) {
15916
+ clock += 1;
15917
+ turns.push({ t: clock, type: 2, text: "", tool: tool2, model: null });
15918
+ }
15919
+ }
15920
+ if (!text2)
15921
+ continue;
15922
+ clock += 1;
15923
+ turns.push({ t: clock, type, text: text2, tool: null, model: null });
15924
+ }
15925
+ if (turns.length === 0)
15926
+ return null;
15927
+ return { composerId: "", createdAt: base, updatedAt: clock, name: null, gitRepo: null, turns };
15928
+ }
15929
+ var AI_GIST = 500;
15930
+ function renderCursorTranscript(c) {
15931
+ const lines = [];
15932
+ let humanTurns = 0, humanChars = 0;
15933
+ let aiProse = "";
15934
+ const aiTools = /* @__PURE__ */ new Map();
15935
+ const flushAI = () => {
15936
+ if (!aiProse && aiTools.size === 0)
15937
+ return;
15938
+ const tools = [...aiTools.entries()].map(([n, k]) => k > 1 ? `${n}\xD7${k}` : n).join(", ");
15939
+ const gist = aiProse ? aiProse.length > AI_GIST ? aiProse.slice(0, AI_GIST) + "\u2026" : aiProse : "";
15940
+ const bits = [];
15941
+ if (gist)
15942
+ bits.push(gist);
15943
+ if (tools)
15944
+ bits.push(`ran ${tools}`);
15945
+ lines.push(`[AI: ${bits.join(" \xB7 ")}]`);
15946
+ aiProse = "";
15947
+ aiTools.clear();
15948
+ };
15949
+ for (const turn of c.turns) {
15950
+ if (turn.type === 1) {
15951
+ flushAI();
15952
+ humanTurns++;
15953
+ humanChars += turn.text.length;
15954
+ lines.push(`>> ${turn.text}`);
15955
+ } else {
15956
+ if (turn.tool)
15957
+ aiTools.set(turn.tool, (aiTools.get(turn.tool) ?? 0) + 1);
15958
+ if (turn.text)
15959
+ aiProse = turn.text.replace(/\s+/g, " ").trim();
15960
+ }
15961
+ }
15962
+ flushAI();
15963
+ return { text: lines.join("\n"), humanTurns, humanChars };
15964
+ }
15965
+ function composerIdFromFile(file2) {
15966
+ const m = file2.match(/agent-transcripts\/([^/]+)\/[^/]+\.jsonl$/);
15967
+ return m ? m[1] : null;
15968
+ }
15969
+ async function loadCursorComposer(file2, raw, dbPath) {
15970
+ const cid = composerIdFromFile(file2);
15971
+ if (cid && dbPath) {
15972
+ const db = await openCursorSqlite(dbPath);
15973
+ if (db) {
15974
+ try {
15975
+ const c = readCursorComposer(db, cid);
15976
+ if (c)
15977
+ return c;
15978
+ } finally {
15979
+ db.close();
15980
+ }
15981
+ }
15982
+ }
15983
+ return parseCursorJsonl(raw, 0);
15984
+ }
15985
+
15986
+ // ../coding-core/dist/raw.js
15987
+ import path9 from "path";
15988
+ import os2 from "os";
15989
+ var SOURCE_ROOT_ENV_VARS = [
15990
+ "CLAUDE_PROJECTS_DIR",
15991
+ "CODEX_SESSIONS_DIR",
15992
+ "CURSOR_WORKSPACE_DIR",
15993
+ "CURSOR_PROJECTS_DIR",
15994
+ // Cursor's globalStorage dir (holds state.vscdb — the composer bubbles that
15995
+ // carry a Cursor session's real per-turn timestamps + content). Same
15996
+ // isolation contract: overriding any root disables every unset source.
15997
+ "CURSOR_GLOBAL_DIR"
15998
+ ];
15999
+ var anyRootOverridden = () => SOURCE_ROOT_ENV_VARS.some((v) => !!process.env[v]);
16000
+ function resolveSourceRoot(envVar, ...defaultSegments) {
16001
+ const explicit = process.env[envVar];
16002
+ if (explicit)
16003
+ return explicit;
16004
+ if (anyRootOverridden())
16005
+ return null;
16006
+ return path9.join(os2.homedir(), ...defaultSegments);
16007
+ }
16008
+ var cursorGlobalRoot = () => resolveSourceRoot("CURSOR_GLOBAL_DIR", "Library", "Application Support", "Cursor", "User", "globalStorage");
16009
+ function cursorGlobalDbPath() {
16010
+ const root = cursorGlobalRoot();
16011
+ return root === null ? null : path9.join(root, "state.vscdb");
16012
+ }
16013
+ var MACHINE_CURSOR_FILE_RE = /^(.*[/\\]machines[/\\][^/\\]+[/\\]\.cursor)[/\\]projects[/\\]/;
16014
+ function cursorDbPathForFile(file2) {
16015
+ const m = file2.match(MACHINE_CURSOR_FILE_RE);
16016
+ if (m)
16017
+ return path9.join(m[1], "globalStorage", "state.vscdb");
16018
+ return cursorGlobalDbPath();
16019
+ }
16020
+
15733
16021
  // ../../lib/agents/coding/materialize.ts
15734
- var SYSTEM_REMINDER_RE2 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
16022
+ var SYSTEM_REMINDER_RE3 = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
15735
16023
  var INJECT_GIST = 120;
15736
16024
  var INJECTED = [
15737
16025
  { re: /<task-notification>[\s\S]*?<\/task-notification>/g, label: "bg task", gistRe: /<summary>([\s\S]*?)<\/summary>/ },
@@ -15751,7 +16039,7 @@ function collapseInjected(input) {
15751
16039
  return "";
15752
16040
  });
15753
16041
  }
15754
- return { text: text2.replace(SYSTEM_REMINDER_RE2, "").trim(), markers };
16042
+ return { text: text2.replace(SYSTEM_REMINDER_RE3, "").trim(), markers };
15755
16043
  }
15756
16044
  function extractText(content) {
15757
16045
  if (typeof content === "string") return content;
@@ -15767,7 +16055,7 @@ function extractText(content) {
15767
16055
  function isToolResultOnly(content) {
15768
16056
  return Array.isArray(content) && content.length > 0 && content.every((c) => c && typeof c === "object" && c.type === "tool_result");
15769
16057
  }
15770
- var AI_GIST = 160;
16058
+ var AI_GIST2 = 160;
15771
16059
  function materializeCodex(raw) {
15772
16060
  const lines = [];
15773
16061
  let humanTurns = 0, humanChars = 0;
@@ -15776,7 +16064,7 @@ function materializeCodex(raw) {
15776
16064
  const flushAI = () => {
15777
16065
  if (!aiLastProse && aiTools.size === 0) return;
15778
16066
  const tools = [...aiTools.entries()].map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
15779
- const gist = aiLastProse ? aiLastProse.length > AI_GIST ? aiLastProse.slice(0, AI_GIST) + "\u2026" : aiLastProse : "";
16067
+ const gist = aiLastProse ? aiLastProse.length > AI_GIST2 ? aiLastProse.slice(0, AI_GIST2) + "\u2026" : aiLastProse : "";
15780
16068
  const bits = [];
15781
16069
  if (gist) bits.push(gist);
15782
16070
  if (tools) bits.push(`ran ${tools}`);
@@ -15800,14 +16088,19 @@ function materializeCodex(raw) {
15800
16088
  flushAI();
15801
16089
  return { text: lines.join("\n"), humanTurns, humanChars };
15802
16090
  }
16091
+ async function materializeCursor(file2, raw) {
16092
+ const composer = await loadCursorComposer(file2, raw, cursorDbPathForFile(file2));
16093
+ return composer ? renderCursorTranscript(composer) : { text: "", humanTurns: 0, humanChars: 0 };
16094
+ }
15803
16095
  async function materializeSession(file2) {
15804
16096
  let raw;
15805
16097
  try {
15806
- raw = await fs4.readFile(file2, "utf-8");
16098
+ raw = await fs5.readFile(file2, "utf-8");
15807
16099
  } catch {
15808
16100
  return null;
15809
16101
  }
15810
16102
  if (sniffCodexRaw(raw)) return materializeCodex(raw);
16103
+ if (sniffCursorRaw(raw)) return materializeCursor(file2, raw);
15811
16104
  const lines = [];
15812
16105
  let humanTurns = 0, humanChars = 0;
15813
16106
  const pendingQueued = [];
@@ -15820,7 +16113,7 @@ async function materializeSession(file2) {
15820
16113
  const flushAI = () => {
15821
16114
  if (!aiLastProse && aiTools.size === 0) return;
15822
16115
  const tools = [...aiTools.entries()].map(([n, c]) => c > 1 ? `${n}\xD7${c}` : n).join(", ");
15823
- const gist = aiLastProse ? aiLastProse.length > AI_GIST ? aiLastProse.slice(0, AI_GIST) + "\u2026" : aiLastProse : "";
16116
+ const gist = aiLastProse ? aiLastProse.length > AI_GIST2 ? aiLastProse.slice(0, AI_GIST2) + "\u2026" : aiLastProse : "";
15824
16117
  const bits = [];
15825
16118
  if (gist) bits.push(gist);
15826
16119
  if (tools) bits.push(`ran ${tools}`);
@@ -15900,10 +16193,10 @@ async function materializeSession(file2) {
15900
16193
 
15901
16194
  // ../../lib/agents/coding/docsDir.ts
15902
16195
  async function writeScoreboard(codingDir, docs) {
15903
- const gradesDir = path9.join(codingDir, "grades");
16196
+ const gradesDir = path10.join(codingDir, "grades");
15904
16197
  let files = [];
15905
16198
  try {
15906
- files = (await fs5.readdir(gradesDir)).filter((f) => f.endsWith(".json")).sort();
16199
+ files = (await fs6.readdir(gradesDir)).filter((f) => f.endsWith(".json")).sort();
15907
16200
  } catch {
15908
16201
  return;
15909
16202
  }
@@ -15911,7 +16204,7 @@ async function writeScoreboard(codingDir, docs) {
15911
16204
  for (const f of files) {
15912
16205
  let g;
15913
16206
  try {
15914
- g = JSON.parse(await fs5.readFile(path9.join(gradesDir, f), "utf8"));
16207
+ g = JSON.parse(await fs6.readFile(path10.join(gradesDir, f), "utf8"));
15915
16208
  } catch {
15916
16209
  continue;
15917
16210
  }
@@ -15927,8 +16220,8 @@ async function writeScoreboard(codingDir, docs) {
15927
16220
  ([key, rows]) => `## ${key}
15928
16221
  ${rows.sort((a, b) => b.s - a.s).map((r) => r.line).join("\n")}`
15929
16222
  );
15930
- await fs5.writeFile(
15931
- path9.join(docs, "_scoreboard.md"),
16223
+ await fs6.writeFile(
16224
+ path10.join(docs, "_scoreboard.md"),
15932
16225
  `# Scoreboard \u2014 every graded session per criterion, best first.
15933
16226
  # Lx~ = estimate. Format: level \xB7 date \xB7 title \xB7 sessionId \u2014 graded instance.
15934
16227
 
@@ -15937,24 +16230,24 @@ ${blocks.join("\n\n")}
15937
16230
  );
15938
16231
  }
15939
16232
  async function ensureCodingDocs(codingDir, sessions) {
15940
- const docs = path9.join(codingDir, "docs");
15941
- await fs5.mkdir(docs, { recursive: true });
16233
+ const docs = path10.join(codingDir, "docs");
16234
+ await fs6.mkdir(docs, { recursive: true });
15942
16235
  const user = sessions.filter((s) => s.sessionId && !s.duplicateOf && (!("klass" in s) || s.klass === "interactive"));
15943
16236
  let written = 0;
15944
16237
  for (const s of user) {
15945
- const out = path9.join(docs, `${s.sessionId}.txt`);
16238
+ const out = path10.join(docs, `${s.sessionId}.txt`);
15946
16239
  try {
15947
- await fs5.access(out);
16240
+ await fs6.access(out);
15948
16241
  continue;
15949
16242
  } catch {
15950
16243
  }
15951
16244
  const mat = await materializeSession(s.file).catch(() => null);
15952
16245
  if (!mat?.text) continue;
15953
- await fs5.writeFile(out, mat.text);
16246
+ await fs6.writeFile(out, mat.text);
15954
16247
  written++;
15955
16248
  }
15956
16249
  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}`);
15957
- await fs5.writeFile(path9.join(docs, "_map.md"), rows.join("\n") + "\n");
16250
+ await fs6.writeFile(path10.join(docs, "_map.md"), rows.join("\n") + "\n");
15958
16251
  await writeScoreboard(codingDir, docs);
15959
16252
  if (written) console.log(`[docs] materialized ${written} new transcript(s) \u2192 ${docs}`);
15960
16253
  return docs;
@@ -15967,7 +16260,7 @@ SOURCE LOOKUP \u2014 you have Read/Grep/Glob over the working directory, which h
15967
16260
 
15968
16261
  // ../../lib/agents/coding/promptCache.ts
15969
16262
  import { createHash } from "crypto";
15970
- import { promises as fs6 } from "fs";
16263
+ import { promises as fs7 } from "fs";
15971
16264
  function promptSha(parts) {
15972
16265
  const h = createHash("sha256");
15973
16266
  for (const p of parts) {
@@ -15978,7 +16271,7 @@ function promptSha(parts) {
15978
16271
  }
15979
16272
  async function reusableOutput(outPath, sha, valid, key = "promptSha") {
15980
16273
  try {
15981
- const o = JSON.parse(await fs6.readFile(outPath, "utf8"));
16274
+ const o = JSON.parse(await fs7.readFile(outPath, "utf8"));
15982
16275
  if (o[key] === sha && valid(o)) return o;
15983
16276
  } catch {
15984
16277
  }
@@ -15986,7 +16279,7 @@ async function reusableOutput(outPath, sha, valid, key = "promptSha") {
15986
16279
  }
15987
16280
 
15988
16281
  // ../../lib/agents/coding/profile.ts
15989
- import path10 from "path";
16282
+ import path11 from "path";
15990
16283
 
15991
16284
  // ../../lib/calibration/fingerprint.ts
15992
16285
  import { createHash as createHash2 } from "node:crypto";
@@ -16140,7 +16433,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
16140
16433
 
16141
16434
  // ../../lib/calibration/index.ts
16142
16435
  var DEFAULT_CALIBRATION = {
16143
- version: "2026-07-16.2",
16436
+ version: "2026-07-21.1",
16144
16437
  // = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
16145
16438
  // src/grade/criteria.ts). A unit test fails loud when the rubric changes
16146
16439
  // without this being updated (and re-pushed to the server).
@@ -16236,13 +16529,14 @@ var DEFAULT_CALIBRATION = {
16236
16529
  },
16237
16530
  codingBenchmarks: {
16238
16531
  flow: {
16239
- // typical knowledge worker ≈ 35% of an 8h day focused; ~4h/day is the
16240
- // recognized deep-work ceiling (Newport) 50% most sit far below it.
16532
+ // typical knowledge worker ≈ 35% of an 8h day focused; the ~4h/day
16533
+ // deep-work ceiling (Newport) sits nearer ~40% of a real (9-10h) top
16534
+ // performer's day — 50% overstated it (owner call 2026-07-21).
16241
16535
  typicalPctOfDay: 0.35,
16242
- topPctOfDay: 0.5,
16536
+ topPctOfDay: 0.4,
16243
16537
  tag: "measured",
16244
- source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling)",
16245
- line: "the best spend ~half the workday in true deep flow; ~4h/day is the human ceiling"
16538
+ source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling against a 9-10h day)",
16539
+ line: "the best spend ~40% of the workday in true deep flow; ~4h/day is the human ceiling"
16246
16540
  },
16247
16541
  longestRun: {
16248
16542
  typicalHours: 0.67,
@@ -16291,8 +16585,8 @@ var BEST = DEFAULT_CALIBRATION.codingBenchmarks;
16291
16585
 
16292
16586
  // ../../lib/agents/coding/profile.ts
16293
16587
  var ROOT = process.cwd();
16294
- var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path10.join(process.env.POLYMATH_DATA_DIR, "coding") : path10.join(ROOT, ".data", "coding");
16295
- var GRADES = path10.join(CODING_DIR, "grades");
16588
+ var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path11.join(process.env.POLYMATH_DATA_DIR, "coding") : path11.join(ROOT, ".data", "coding");
16589
+ var GRADES = path11.join(CODING_DIR, "grades");
16296
16590
 
16297
16591
  // ../../scripts/coding-frontier-detail.mts
16298
16592
  var CODING = CODING_DIR;
@@ -16309,7 +16603,7 @@ var isUuid = (s) => /^[0-9a-f]{8}-?[0-9a-f]/.test(s);
16309
16603
  async function parseSkillCalls(file2) {
16310
16604
  let raw;
16311
16605
  try {
16312
- raw = await fs7.readFile(file2, "utf8");
16606
+ raw = await fs8.readFile(file2, "utf8");
16313
16607
  } catch {
16314
16608
  return [];
16315
16609
  }
@@ -16332,7 +16626,7 @@ async function parseSkillCalls(file2) {
16332
16626
  return out;
16333
16627
  }
16334
16628
  async function main() {
16335
- const all = JSON.parse(await fs7.readFile(`${CODING}/sessions.json`, "utf8"));
16629
+ const all = JSON.parse(await fs8.readFile(`${CODING}/sessions.json`, "utf8"));
16336
16630
  const sessions = all.filter((s) => s.klass === "interactive");
16337
16631
  const dateOf = (s) => (s.start || "").slice(0, 10);
16338
16632
  const byActive = (a, b) => (b.activeMin ?? 0) - (a.activeMin ?? 0);
@@ -16420,14 +16714,14 @@ Put anything with verdict "tried-failed" into BOTH its list (with the verdict) A
16420
16714
  console.log("ERR", e.message.slice(0, 160));
16421
16715
  }
16422
16716
  if (!ok) {
16423
- const existing = await fs7.readFile(`${CODING}/frontier-detail.json`, "utf8").then(JSON.parse).catch(() => null);
16717
+ const existing = await fs8.readFile(`${CODING}/frontier-detail.json`, "utf8").then(JSON.parse).catch(() => null);
16424
16718
  if (existing && (existing.skills || []).length) {
16425
16719
  console.error(`REFUSING to write ${CODING}/frontier-detail.json \u2014 the LLM pass failed and the existing file has ${existing.skills.length} assessed skill(s)`);
16426
16720
  process.exit(1);
16427
16721
  }
16428
16722
  }
16429
16723
  const out = { generatedAt: (/* @__PURE__ */ new Date()).toISOString(), ...ok ? { promptSha: sha } : {}, skillsUsed, mcpServers, ...detail };
16430
- await fs7.writeFile(`${CODING}/frontier-detail.json`, JSON.stringify(out, null, 2));
16724
+ await fs8.writeFile(`${CODING}/frontier-detail.json`, JSON.stringify(out, null, 2));
16431
16725
  if (!ok) {
16432
16726
  console.error(`frontier-detail LLM pass failed \u2014 wrote deterministic portion only (skillsUsed/mcpServers), exiting non-zero`);
16433
16727
  process.exit(1);
@@ -203,7 +203,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
203
203
 
204
204
  // ../../lib/calibration/index.ts
205
205
  var DEFAULT_CALIBRATION = {
206
- version: "2026-07-16.2",
206
+ version: "2026-07-21.1",
207
207
  // = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
208
208
  // src/grade/criteria.ts). A unit test fails loud when the rubric changes
209
209
  // without this being updated (and re-pushed to the server).
@@ -299,13 +299,14 @@ var DEFAULT_CALIBRATION = {
299
299
  },
300
300
  codingBenchmarks: {
301
301
  flow: {
302
- // typical knowledge worker ≈ 35% of an 8h day focused; ~4h/day is the
303
- // recognized deep-work ceiling (Newport) 50% most sit far below it.
302
+ // typical knowledge worker ≈ 35% of an 8h day focused; the ~4h/day
303
+ // deep-work ceiling (Newport) sits nearer ~40% of a real (9-10h) top
304
+ // performer's day — 50% overstated it (owner call 2026-07-21).
304
305
  typicalPctOfDay: 0.35,
305
- topPctOfDay: 0.5,
306
+ topPctOfDay: 0.4,
306
307
  tag: "measured",
307
- source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling)",
308
- line: "the best spend ~half the workday in true deep flow; ~4h/day is the human ceiling"
308
+ source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling against a 9-10h day)",
309
+ line: "the best spend ~40% of the workday in true deep flow; ~4h/day is the human ceiling"
309
310
  },
310
311
  longestRun: {
311
312
  typicalHours: 0.67,