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.
- package/dist/cli.js +24620 -22073
- 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 +19600 -17706
- package/dist/pipeline/FOCUS-EXAMPLES.md +127 -0
- package/dist/pipeline/FOCUS-RUBRIC.md +418 -0
- package/dist/pipeline/coding-agglomerate.js +947 -79
- package/dist/pipeline/coding-aggregate.js +443 -23
- package/dist/pipeline/coding-build.js +569 -97
- package/dist/pipeline/coding-coaching.js +651 -101
- package/dist/pipeline/coding-day-digest.js +417 -36
- package/dist/pipeline/coding-delegation.js +564 -68
- package/dist/pipeline/coding-expertise.js +477 -59
- package/dist/pipeline/coding-flow.js +424 -15
- package/dist/pipeline/coding-focus.js +507 -51
- package/dist/pipeline/coding-frontier-detail.js +465 -47
- package/dist/pipeline/coding-frontier.js +7 -6
- package/dist/pipeline/coding-gap-dist.js +424 -15
- package/dist/pipeline/coding-gap.js +679 -128
- package/dist/pipeline/coding-grade.js +469 -42
- package/dist/pipeline/coding-growth.js +17041 -0
- package/dist/pipeline/coding-nutshell.js +168 -151
- package/dist/pipeline/coding-projects.js +7 -6
- package/dist/pipeline/coding-walkthrough.js +461 -37
- package/dist/pipeline/coding-workbrief.js +16387 -0
- package/dist/web/app.js +2095 -1396
- package/dist/web/styles.css +1 -1
- package/package.json +1 -1
|
@@ -134,13 +134,13 @@ var require_secure_json_parse = __commonJS({
|
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
// ../../scripts/coding-day-digest.mts
|
|
137
|
-
import { promises as
|
|
138
|
-
import
|
|
137
|
+
import { promises as fs7 } from "fs";
|
|
138
|
+
import path12 from "path";
|
|
139
139
|
|
|
140
140
|
// ../../lib/agents/coding/dayDigest.ts
|
|
141
|
-
import { promises as
|
|
142
|
-
import
|
|
143
|
-
import
|
|
141
|
+
import { promises as fs6 } from "fs";
|
|
142
|
+
import os3 from "os";
|
|
143
|
+
import path10 from "path";
|
|
144
144
|
|
|
145
145
|
// ../../lib/agents/shared/agent.ts
|
|
146
146
|
import { readFileSync } from "fs";
|
|
@@ -508,6 +508,13 @@ ${report}`);
|
|
|
508
508
|
}
|
|
509
509
|
|
|
510
510
|
// ../../lib/agents/shared/codexAdapter.ts
|
|
511
|
+
var CODEX_DEFAULT_MODEL = "gpt-5.5";
|
|
512
|
+
var CODEX_MINI_MODEL = "gpt-5.4-mini";
|
|
513
|
+
function mapCodexTier(model2, env = process.env) {
|
|
514
|
+
if (model2 && !/^(claude|haiku|sonnet|opus)/i.test(model2)) return model2;
|
|
515
|
+
if (model2 && /^haiku/i.test(model2)) return env.POLYMATH_CODEX_MODEL_MINI || CODEX_MINI_MODEL;
|
|
516
|
+
return env.POLYMATH_CODEX_MODEL || CODEX_DEFAULT_MODEL;
|
|
517
|
+
}
|
|
511
518
|
function composePrompt(inv, roots) {
|
|
512
519
|
return [
|
|
513
520
|
inv.systemPrompt ? `<system>
|
|
@@ -548,7 +555,7 @@ var codexAdapter = {
|
|
|
548
555
|
"read-only",
|
|
549
556
|
"--json"
|
|
550
557
|
];
|
|
551
|
-
|
|
558
|
+
args.push("--model", mapCodexTier(inv.model));
|
|
552
559
|
args.push(composePrompt(inv, roots));
|
|
553
560
|
const started = Date.now();
|
|
554
561
|
const toolCalls = [];
|
|
@@ -2176,8 +2183,8 @@ function getErrorMap() {
|
|
|
2176
2183
|
|
|
2177
2184
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
2178
2185
|
var makeIssue = (params) => {
|
|
2179
|
-
const { data, path:
|
|
2180
|
-
const fullPath = [...
|
|
2186
|
+
const { data, path: path13, errorMaps, issueData } = params;
|
|
2187
|
+
const fullPath = [...path13, ...issueData.path || []];
|
|
2181
2188
|
const fullIssue = {
|
|
2182
2189
|
...issueData,
|
|
2183
2190
|
path: fullPath
|
|
@@ -2293,11 +2300,11 @@ var errorUtil;
|
|
|
2293
2300
|
|
|
2294
2301
|
// ../../node_modules/zod/v3/types.js
|
|
2295
2302
|
var ParseInputLazyPath = class {
|
|
2296
|
-
constructor(parent, value,
|
|
2303
|
+
constructor(parent, value, path13, key) {
|
|
2297
2304
|
this._cachedPath = [];
|
|
2298
2305
|
this.parent = parent;
|
|
2299
2306
|
this.data = value;
|
|
2300
|
-
this._path =
|
|
2307
|
+
this._path = path13;
|
|
2301
2308
|
this._key = key;
|
|
2302
2309
|
}
|
|
2303
2310
|
get path() {
|
|
@@ -15084,39 +15091,39 @@ function createOpenAI(options = {}) {
|
|
|
15084
15091
|
});
|
|
15085
15092
|
const createChatModel = (modelId, settings = {}) => new OpenAIChatLanguageModel(modelId, settings, {
|
|
15086
15093
|
provider: `${providerName}.chat`,
|
|
15087
|
-
url: ({ path:
|
|
15094
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15088
15095
|
headers: getHeaders,
|
|
15089
15096
|
compatibility,
|
|
15090
15097
|
fetch: options.fetch
|
|
15091
15098
|
});
|
|
15092
15099
|
const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
|
|
15093
15100
|
provider: `${providerName}.completion`,
|
|
15094
|
-
url: ({ path:
|
|
15101
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15095
15102
|
headers: getHeaders,
|
|
15096
15103
|
compatibility,
|
|
15097
15104
|
fetch: options.fetch
|
|
15098
15105
|
});
|
|
15099
15106
|
const createEmbeddingModel = (modelId, settings = {}) => new OpenAIEmbeddingModel(modelId, settings, {
|
|
15100
15107
|
provider: `${providerName}.embedding`,
|
|
15101
|
-
url: ({ path:
|
|
15108
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15102
15109
|
headers: getHeaders,
|
|
15103
15110
|
fetch: options.fetch
|
|
15104
15111
|
});
|
|
15105
15112
|
const createImageModel = (modelId, settings = {}) => new OpenAIImageModel(modelId, settings, {
|
|
15106
15113
|
provider: `${providerName}.image`,
|
|
15107
|
-
url: ({ path:
|
|
15114
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15108
15115
|
headers: getHeaders,
|
|
15109
15116
|
fetch: options.fetch
|
|
15110
15117
|
});
|
|
15111
15118
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
15112
15119
|
provider: `${providerName}.transcription`,
|
|
15113
|
-
url: ({ path:
|
|
15120
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15114
15121
|
headers: getHeaders,
|
|
15115
15122
|
fetch: options.fetch
|
|
15116
15123
|
});
|
|
15117
15124
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
15118
15125
|
provider: `${providerName}.speech`,
|
|
15119
|
-
url: ({ path:
|
|
15126
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15120
15127
|
headers: getHeaders,
|
|
15121
15128
|
fetch: options.fetch
|
|
15122
15129
|
});
|
|
@@ -15137,7 +15144,7 @@ function createOpenAI(options = {}) {
|
|
|
15137
15144
|
const createResponsesModel = (modelId) => {
|
|
15138
15145
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
15139
15146
|
provider: `${providerName}.responses`,
|
|
15140
|
-
url: ({ path:
|
|
15147
|
+
url: ({ path: path13 }) => `${baseURL}${path13}`,
|
|
15141
15148
|
headers: getHeaders,
|
|
15142
15149
|
fetch: options.fetch
|
|
15143
15150
|
});
|
|
@@ -15659,7 +15666,7 @@ function invokeAgent(inv, opts = {}) {
|
|
|
15659
15666
|
}
|
|
15660
15667
|
|
|
15661
15668
|
// ../coding-core/dist/messages.js
|
|
15662
|
-
import { promises as
|
|
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,341 @@ 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 model2 = b.modelInfo && typeof b.modelInfo.modelName === "string" ? b.modelInfo.modelName : null;
|
|
15905
|
+
turns.push({ t: clock, type, text: text2, tool: tool2, model: model2 });
|
|
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 composerIdFromFile(file2) {
|
|
15984
|
+
const m = file2.match(/agent-transcripts\/([^/]+)\/[^/]+\.jsonl$/);
|
|
15985
|
+
return m ? m[1] : null;
|
|
15986
|
+
}
|
|
15987
|
+
async function loadCursorComposer(file2, raw, dbPath) {
|
|
15988
|
+
const cid = composerIdFromFile(file2);
|
|
15989
|
+
if (cid && dbPath) {
|
|
15990
|
+
const db = await openCursorSqlite(dbPath);
|
|
15991
|
+
if (db) {
|
|
15992
|
+
try {
|
|
15993
|
+
const c = readCursorComposer(db, cid);
|
|
15994
|
+
if (c)
|
|
15995
|
+
return c;
|
|
15996
|
+
} finally {
|
|
15997
|
+
db.close();
|
|
15998
|
+
}
|
|
15999
|
+
}
|
|
16000
|
+
}
|
|
16001
|
+
return parseCursorJsonl(raw, 0);
|
|
16002
|
+
}
|
|
16003
|
+
|
|
16004
|
+
// ../coding-core/dist/raw.js
|
|
16005
|
+
import path9 from "path";
|
|
16006
|
+
import os2 from "os";
|
|
16007
|
+
var SOURCE_ROOT_ENV_VARS = [
|
|
16008
|
+
"CLAUDE_PROJECTS_DIR",
|
|
16009
|
+
"CODEX_SESSIONS_DIR",
|
|
16010
|
+
"CURSOR_WORKSPACE_DIR",
|
|
16011
|
+
"CURSOR_PROJECTS_DIR",
|
|
16012
|
+
// Cursor's globalStorage dir (holds state.vscdb — the composer bubbles that
|
|
16013
|
+
// carry a Cursor session's real per-turn timestamps + content). Same
|
|
16014
|
+
// isolation contract: overriding any root disables every unset source.
|
|
16015
|
+
"CURSOR_GLOBAL_DIR"
|
|
16016
|
+
];
|
|
16017
|
+
var anyRootOverridden = () => SOURCE_ROOT_ENV_VARS.some((v) => !!process.env[v]);
|
|
16018
|
+
function resolveSourceRoot(envVar, ...defaultSegments) {
|
|
16019
|
+
const explicit = process.env[envVar];
|
|
16020
|
+
if (explicit)
|
|
16021
|
+
return explicit;
|
|
16022
|
+
if (anyRootOverridden())
|
|
16023
|
+
return null;
|
|
16024
|
+
return path9.join(os2.homedir(), ...defaultSegments);
|
|
16025
|
+
}
|
|
16026
|
+
var cursorGlobalRoot = () => resolveSourceRoot("CURSOR_GLOBAL_DIR", "Library", "Application Support", "Cursor", "User", "globalStorage");
|
|
16027
|
+
function cursorGlobalDbPath() {
|
|
16028
|
+
const root = cursorGlobalRoot();
|
|
16029
|
+
return root === null ? null : path9.join(root, "state.vscdb");
|
|
16030
|
+
}
|
|
16031
|
+
var MACHINE_CURSOR_FILE_RE = /^(.*[/\\]machines[/\\][^/\\]+[/\\]\.cursor)[/\\]projects[/\\]/;
|
|
16032
|
+
function cursorDbPathForFile(file2) {
|
|
16033
|
+
const m = file2.match(MACHINE_CURSOR_FILE_RE);
|
|
16034
|
+
if (m)
|
|
16035
|
+
return path9.join(m[1], "globalStorage", "state.vscdb");
|
|
16036
|
+
return cursorGlobalDbPath();
|
|
16037
|
+
}
|
|
16038
|
+
|
|
15697
16039
|
// ../coding-core/dist/messages.js
|
|
15698
16040
|
function extractText(content) {
|
|
15699
16041
|
if (typeof content === "string")
|
|
@@ -15705,13 +16047,51 @@ function extractText(content) {
|
|
|
15705
16047
|
function isToolResultOnly(content) {
|
|
15706
16048
|
return Array.isArray(content) && content.length > 0 && content.every((c) => c && typeof c === "object" && c.type === "tool_result");
|
|
15707
16049
|
}
|
|
16050
|
+
function extractUserMessagesCodex(raw) {
|
|
16051
|
+
const out = [];
|
|
16052
|
+
let lastTs = null;
|
|
16053
|
+
for (const ev of extractCodexEvents(raw)) {
|
|
16054
|
+
const t = ev.t;
|
|
16055
|
+
const gapMs = Number.isFinite(t) && lastTs != null ? t - lastTs : NaN;
|
|
16056
|
+
if (Number.isFinite(t))
|
|
16057
|
+
lastTs = t;
|
|
16058
|
+
if (ev.kind !== "user")
|
|
16059
|
+
continue;
|
|
16060
|
+
const text2 = humanTypedText(ev.text);
|
|
16061
|
+
if (text2 && Number.isFinite(t))
|
|
16062
|
+
out.push({ t, text: text2, gapMs });
|
|
16063
|
+
}
|
|
16064
|
+
return out.sort((a, b) => a.t - b.t);
|
|
16065
|
+
}
|
|
16066
|
+
function extractUserMessagesCursor(c) {
|
|
16067
|
+
const out = [];
|
|
16068
|
+
let lastTs = null;
|
|
16069
|
+
for (const turn of c.turns) {
|
|
16070
|
+
const t = turn.t;
|
|
16071
|
+
const gapMs = Number.isFinite(t) && lastTs != null ? t - lastTs : NaN;
|
|
16072
|
+
if (Number.isFinite(t))
|
|
16073
|
+
lastTs = t;
|
|
16074
|
+
if (turn.type !== 1)
|
|
16075
|
+
continue;
|
|
16076
|
+
const text2 = humanTypedText(turn.text);
|
|
16077
|
+
if (text2 && Number.isFinite(t))
|
|
16078
|
+
out.push({ t, text: text2, gapMs });
|
|
16079
|
+
}
|
|
16080
|
+
return out.sort((a, b) => a.t - b.t);
|
|
16081
|
+
}
|
|
15708
16082
|
async function extractUserMessages(file2) {
|
|
15709
16083
|
let raw;
|
|
15710
16084
|
try {
|
|
15711
|
-
raw = await
|
|
16085
|
+
raw = await fs5.readFile(file2, "utf-8");
|
|
15712
16086
|
} catch {
|
|
15713
16087
|
return [];
|
|
15714
16088
|
}
|
|
16089
|
+
if (sniffCodexRaw(raw))
|
|
16090
|
+
return extractUserMessagesCodex(raw);
|
|
16091
|
+
if (sniffCursorRaw(raw)) {
|
|
16092
|
+
const c = await loadCursorComposer(file2, raw, cursorDbPathForFile(file2));
|
|
16093
|
+
return c ? extractUserMessagesCursor(c) : [];
|
|
16094
|
+
}
|
|
15715
16095
|
const out = [];
|
|
15716
16096
|
const userTexts = /* @__PURE__ */ new Set();
|
|
15717
16097
|
const seenUuids = /* @__PURE__ */ new Set();
|
|
@@ -15815,7 +16195,7 @@ ${lines.join("\n")}`);
|
|
|
15815
16195
|
}
|
|
15816
16196
|
var SYSTEM = "You read all the messages a person sent on ONE day across several coding-agent conversations, and say \u2014 per conversation \u2014 what they actually DID that day, semantically and specifically. Their words only; ignore mechanical scaffolding. One tight line per conversation (e.g. 'built the full prototype of the apprenticeship app', 'tuned the intelligence rubric with examples from their own read on people', 'set up an EC2 box to run the analysis overnight'). No flattery, no filler.";
|
|
15817
16197
|
async function digestDay(dc, opts = {}) {
|
|
15818
|
-
const sandbox = await
|
|
16198
|
+
const sandbox = await fs6.mkdtemp(path10.join(os3.tmpdir(), "ps-coding-day-"));
|
|
15819
16199
|
try {
|
|
15820
16200
|
const prompt = `Date: ${dc.date}. Below are ALL the conversations this person sent messages in that day, each with their verbatim messages. For EACH conversation write one specific line on what they did/worked on that day. Then one "overall" line summarizing the whole day.
|
|
15821
16201
|
|
|
@@ -15836,7 +16216,7 @@ Output a SINGLE fenced \`\`\`json block:
|
|
|
15836
16216
|
conversations: dc.conversations.map((c) => ({ sessionId: c.sessionId, title: c.title, messageCount: c.messageCount, summary: summaries.get(c.sessionId.slice(0, 8)) ?? "" }))
|
|
15837
16217
|
};
|
|
15838
16218
|
} finally {
|
|
15839
|
-
await
|
|
16219
|
+
await fs6.rm(sandbox, { recursive: true, force: true }).catch(() => {
|
|
15840
16220
|
});
|
|
15841
16221
|
}
|
|
15842
16222
|
}
|
|
@@ -15879,7 +16259,7 @@ function aiWindowCutoff(sessions, opts = {}) {
|
|
|
15879
16259
|
}
|
|
15880
16260
|
|
|
15881
16261
|
// ../../lib/agents/coding/profile.ts
|
|
15882
|
-
import
|
|
16262
|
+
import path11 from "path";
|
|
15883
16263
|
|
|
15884
16264
|
// ../../lib/calibration/fingerprint.ts
|
|
15885
16265
|
import { createHash } from "node:crypto";
|
|
@@ -16033,7 +16413,7 @@ var TRANSCRIPT_LINE_RE = new RegExp(`^\\s*(${NOTE})((,| and) ${NOTE})*\\s*$|^\\s
|
|
|
16033
16413
|
|
|
16034
16414
|
// ../../lib/calibration/index.ts
|
|
16035
16415
|
var DEFAULT_CALIBRATION = {
|
|
16036
|
-
version: "2026-07-
|
|
16416
|
+
version: "2026-07-21.1",
|
|
16037
16417
|
// = RUBRIC_FINGERPRINT of the shipped npm rubric (packages/coding-analyzer/
|
|
16038
16418
|
// src/grade/criteria.ts). A unit test fails loud when the rubric changes
|
|
16039
16419
|
// without this being updated (and re-pushed to the server).
|
|
@@ -16129,13 +16509,14 @@ var DEFAULT_CALIBRATION = {
|
|
|
16129
16509
|
},
|
|
16130
16510
|
codingBenchmarks: {
|
|
16131
16511
|
flow: {
|
|
16132
|
-
// typical knowledge worker ≈ 35% of an 8h day focused; ~4h/day
|
|
16133
|
-
//
|
|
16512
|
+
// typical knowledge worker ≈ 35% of an 8h day focused; the ~4h/day
|
|
16513
|
+
// deep-work ceiling (Newport) sits nearer ~40% of a real (9-10h) top
|
|
16514
|
+
// performer's day — 50% overstated it (owner call 2026-07-21).
|
|
16134
16515
|
typicalPctOfDay: 0.35,
|
|
16135
|
-
topPctOfDay: 0.
|
|
16516
|
+
topPctOfDay: 0.4,
|
|
16136
16517
|
tag: "measured",
|
|
16137
|
-
source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling)",
|
|
16138
|
-
line: "the best spend ~
|
|
16518
|
+
source: "RescueTime 2019 (~2h48m focused/day) \xB7 Cal Newport, Deep Work (~4h/day deep-work ceiling against a 9-10h day)",
|
|
16519
|
+
line: "the best spend ~40% of the workday in true deep flow; ~4h/day is the human ceiling"
|
|
16139
16520
|
},
|
|
16140
16521
|
longestRun: {
|
|
16141
16522
|
typicalHours: 0.67,
|
|
@@ -16184,8 +16565,8 @@ var BEST = DEFAULT_CALIBRATION.codingBenchmarks;
|
|
|
16184
16565
|
|
|
16185
16566
|
// ../../lib/agents/coding/profile.ts
|
|
16186
16567
|
var ROOT = process.cwd();
|
|
16187
|
-
var CODING_DIR = process.env.POLYMATH_DATA_DIR ?
|
|
16188
|
-
var GRADES =
|
|
16568
|
+
var CODING_DIR = process.env.POLYMATH_DATA_DIR ? path11.join(process.env.POLYMATH_DATA_DIR, "coding") : path11.join(ROOT, ".data", "coding");
|
|
16569
|
+
var GRADES = path11.join(CODING_DIR, "grades");
|
|
16189
16570
|
|
|
16190
16571
|
// ../../scripts/coding-day-digest.mts
|
|
16191
16572
|
var argv = process.argv.slice(2);
|
|
@@ -16193,28 +16574,28 @@ var model = argv.indexOf("--model") >= 0 ? argv[argv.indexOf("--model") + 1] : "
|
|
|
16193
16574
|
var REDO = argv.includes("--redo");
|
|
16194
16575
|
var CONC = Number(argv.indexOf("--conc") >= 0 ? argv[argv.indexOf("--conc") + 1] : "8");
|
|
16195
16576
|
var CODING = CODING_DIR;
|
|
16196
|
-
var OUT =
|
|
16577
|
+
var OUT = path12.join(CODING, "day-digest.json");
|
|
16197
16578
|
var TZ = process.env.CODING_TZ || "America/Los_Angeles";
|
|
16198
16579
|
async function main() {
|
|
16199
|
-
const all = JSON.parse(await
|
|
16580
|
+
const all = JSON.parse(await fs7.readFile(path12.join(CODING, "sessions.json"), "utf8"));
|
|
16200
16581
|
const sessions = all.filter((s) => s.klass === "interactive");
|
|
16201
16582
|
console.log(`[day-digest] grouping ${sessions.length}/${all.length} interactive sessions' messages by day (tz ${TZ})\u2026`);
|
|
16202
16583
|
const dayConvs = await buildDayConversations(sessions, TZ);
|
|
16203
16584
|
console.log(`[day-digest] ${dayConvs.length} active days \xB7 ${dayConvs.reduce((a, d) => a + d.totalMessages, 0)} user messages total`);
|
|
16204
|
-
const prev = REDO ? { generatedAt: "", tz: TZ, days: [] } : await
|
|
16585
|
+
const prev = REDO ? { generatedAt: "", tz: TZ, days: [] } : await fs7.readFile(OUT, "utf8").then(JSON.parse).catch(() => ({ generatedAt: "", tz: TZ, days: [] }));
|
|
16205
16586
|
const done = new Map((prev.days ?? []).map((d) => [d.date, d]));
|
|
16206
16587
|
const out = {
|
|
16207
16588
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16208
16589
|
tz: TZ,
|
|
16209
16590
|
days: dayConvs.map((dc) => done.get(dc.date) ?? { date: dc.date, overall: "", conversationsTouched: dc.conversations.length, totalMessages: dc.totalMessages, conversations: dc.conversations.map((c) => ({ sessionId: c.sessionId, title: c.title, messageCount: c.messageCount, summary: "" })) })
|
|
16210
16591
|
};
|
|
16211
|
-
await
|
|
16592
|
+
await fs7.writeFile(OUT, JSON.stringify(out, null, 2));
|
|
16212
16593
|
const cutoffDay = aiWindowCutoff(sessions).slice(0, 10);
|
|
16213
16594
|
const todo = dayConvs.filter((dc) => (REDO || !done.get(dc.date)?.overall) && (!cutoffDay || dc.date >= cutoffDay));
|
|
16214
16595
|
console.log(`[day-digest] digesting ${todo.length} days${cutoffDay ? ` since ${cutoffDay} (AI window)` : ""} on ${model}, conc ${CONC} (newest first)\u2026`);
|
|
16215
16596
|
startRun("day-digest", todo.length);
|
|
16216
16597
|
let writeChain = Promise.resolve();
|
|
16217
|
-
const save = () => writeChain = writeChain.then(() =>
|
|
16598
|
+
const save = () => writeChain = writeChain.then(() => fs7.writeFile(OUT, JSON.stringify(out, null, 2)));
|
|
16218
16599
|
let cursor = 0;
|
|
16219
16600
|
const worker = async () => {
|
|
16220
16601
|
while (cursor < todo.length) {
|
|
@@ -16239,7 +16620,7 @@ async function main() {
|
|
|
16239
16620
|
await Promise.all(Array.from({ length: Math.min(CONC, todo.length) }, worker));
|
|
16240
16621
|
await writeChain;
|
|
16241
16622
|
endRun();
|
|
16242
|
-
console.log(`[day-digest] wrote \u2192 ${
|
|
16623
|
+
console.log(`[day-digest] wrote \u2192 ${path12.relative(process.cwd(), OUT)}`);
|
|
16243
16624
|
}
|
|
16244
16625
|
main().catch((e) => {
|
|
16245
16626
|
console.error(e);
|