polymath-society 0.2.8 → 0.2.10
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 +420 -239
- package/dist/engine/chat-loops.js +17290 -0
- package/dist/index.js +312 -193
- package/dist/pipeline/coding-day-digest.js +40 -2
- package/dist/pipeline/coding-delegation.js +27 -2
- package/dist/pipeline/coding-grade.js +29 -2
- package/dist/pipeline/coding-walkthrough.js +30 -2
- package/dist/web/app.js +363 -436
- package/dist/web/styles.css +1 -1
- package/package.json +1 -1
|
@@ -15820,6 +15820,43 @@ Output a SINGLE fenced \`\`\`json block:
|
|
|
15820
15820
|
}
|
|
15821
15821
|
}
|
|
15822
15822
|
|
|
15823
|
+
// ../coding-core/dist/gate.js
|
|
15824
|
+
var GATE = {
|
|
15825
|
+
minHumanChars: 800,
|
|
15826
|
+
// the user must have actually said something substantial
|
|
15827
|
+
minHumanTurns: 3,
|
|
15828
|
+
// …over enough back-and-forth to reveal how they work
|
|
15829
|
+
trivialHumanChars: 300,
|
|
15830
|
+
// below this = a one-liner, definitely trivial
|
|
15831
|
+
trivialHumanTurns: 2
|
|
15832
|
+
};
|
|
15833
|
+
function isGradable(s) {
|
|
15834
|
+
return s.humanChars >= GATE.minHumanChars && s.humanTurns >= GATE.minHumanTurns;
|
|
15835
|
+
}
|
|
15836
|
+
var AI_WINDOW = {
|
|
15837
|
+
days: 90,
|
|
15838
|
+
// ~3 months
|
|
15839
|
+
minSessions: 40
|
|
15840
|
+
// extend the window back until this many gradable sessions
|
|
15841
|
+
};
|
|
15842
|
+
function aiWindowCutoff(sessions, opts = {}) {
|
|
15843
|
+
const envDays = Number(process.env.POLYMATH_AI_WINDOW_DAYS);
|
|
15844
|
+
const days = opts.windowDays ?? (Number.isFinite(envDays) && envDays >= 0 ? envDays : AI_WINDOW.days);
|
|
15845
|
+
const floor = opts.minSessions ?? AI_WINDOW.minSessions;
|
|
15846
|
+
if (days === 0)
|
|
15847
|
+
return "";
|
|
15848
|
+
const starts = sessions.map((s) => s.start ?? "").filter(Boolean).sort();
|
|
15849
|
+
const latest = starts[starts.length - 1];
|
|
15850
|
+
if (!latest)
|
|
15851
|
+
return "";
|
|
15852
|
+
const windowCutoff = new Date(new Date(latest).getTime() - days * 864e5).toISOString();
|
|
15853
|
+
const gradableStarts = sessions.filter(isGradable).map((s) => s.start ?? "").filter(Boolean).sort().reverse();
|
|
15854
|
+
if (gradableStarts.length <= floor)
|
|
15855
|
+
return "";
|
|
15856
|
+
const floorStart = gradableStarts[floor - 1];
|
|
15857
|
+
return floorStart < windowCutoff ? floorStart : windowCutoff;
|
|
15858
|
+
}
|
|
15859
|
+
|
|
15823
15860
|
// ../../lib/agents/coding/profile.ts
|
|
15824
15861
|
import path10 from "path";
|
|
15825
15862
|
|
|
@@ -16150,8 +16187,9 @@ async function main() {
|
|
|
16150
16187
|
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: "" })) })
|
|
16151
16188
|
};
|
|
16152
16189
|
await fs6.writeFile(OUT, JSON.stringify(out, null, 2));
|
|
16153
|
-
const
|
|
16154
|
-
|
|
16190
|
+
const cutoffDay = aiWindowCutoff(sessions).slice(0, 10);
|
|
16191
|
+
const todo = dayConvs.filter((dc) => (REDO || !done.get(dc.date)?.overall) && (!cutoffDay || dc.date >= cutoffDay));
|
|
16192
|
+
console.log(`[day-digest] digesting ${todo.length} days${cutoffDay ? ` since ${cutoffDay} (AI window)` : ""} on ${model}, conc ${CONC} (newest first)\u2026`);
|
|
16155
16193
|
startRun("day-digest", todo.length);
|
|
16156
16194
|
let writeChain = Promise.resolve();
|
|
16157
16195
|
const save = () => writeChain = writeChain.then(() => fs6.writeFile(OUT, JSON.stringify(out, null, 2)));
|
|
@@ -16220,6 +16220,29 @@ function partition(sessions) {
|
|
|
16220
16220
|
(isGradable(s) ? gradable : isTrivial(s) ? trivial : thin).push(s);
|
|
16221
16221
|
return { gradable, thin, trivial };
|
|
16222
16222
|
}
|
|
16223
|
+
var AI_WINDOW = {
|
|
16224
|
+
days: 90,
|
|
16225
|
+
// ~3 months
|
|
16226
|
+
minSessions: 40
|
|
16227
|
+
// extend the window back until this many gradable sessions
|
|
16228
|
+
};
|
|
16229
|
+
function aiWindowCutoff(sessions, opts = {}) {
|
|
16230
|
+
const envDays = Number(process.env.POLYMATH_AI_WINDOW_DAYS);
|
|
16231
|
+
const days = opts.windowDays ?? (Number.isFinite(envDays) && envDays >= 0 ? envDays : AI_WINDOW.days);
|
|
16232
|
+
const floor = opts.minSessions ?? AI_WINDOW.minSessions;
|
|
16233
|
+
if (days === 0)
|
|
16234
|
+
return "";
|
|
16235
|
+
const starts = sessions.map((s) => s.start ?? "").filter(Boolean).sort();
|
|
16236
|
+
const latest = starts[starts.length - 1];
|
|
16237
|
+
if (!latest)
|
|
16238
|
+
return "";
|
|
16239
|
+
const windowCutoff = new Date(new Date(latest).getTime() - days * 864e5).toISOString();
|
|
16240
|
+
const gradableStarts = sessions.filter(isGradable).map((s) => s.start ?? "").filter(Boolean).sort().reverse();
|
|
16241
|
+
if (gradableStarts.length <= floor)
|
|
16242
|
+
return "";
|
|
16243
|
+
const floorStart = gradableStarts[floor - 1];
|
|
16244
|
+
return floorStart < windowCutoff ? floorStart : windowCutoff;
|
|
16245
|
+
}
|
|
16223
16246
|
|
|
16224
16247
|
// ../../lib/agents/coding/promptCache.ts
|
|
16225
16248
|
import { createHash } from "crypto";
|
|
@@ -16580,14 +16603,16 @@ var LOGS = path12.join(OUT, "logs");
|
|
|
16580
16603
|
async function main() {
|
|
16581
16604
|
const sessions = JSON.parse(await fs9.readFile(path12.join(CODING, "sessions.json"), "utf8"));
|
|
16582
16605
|
const live = sessions.filter((s) => s.klass === "interactive" && !s.duplicateOf);
|
|
16583
|
-
const { gradable } = partition(live);
|
|
16606
|
+
const { gradable: allGradable } = partition(live);
|
|
16607
|
+
const cutoff = aiWindowCutoff(live);
|
|
16608
|
+
const gradable = cutoff ? allGradable.filter((s) => (s.start ?? "") >= cutoff) : allGradable;
|
|
16584
16609
|
let picked = gradable;
|
|
16585
16610
|
if (IDS.length) {
|
|
16586
16611
|
const set = new Set(IDS);
|
|
16587
16612
|
picked = live.filter((s) => set.has(s.sessionId));
|
|
16588
16613
|
} else if (N > 0) picked = gradable.slice().sort((a, b) => b.humanChars * Math.log1p(b.humanTurns) - a.humanChars * Math.log1p(a.humanTurns)).slice(0, N);
|
|
16589
16614
|
await fs9.mkdir(LOGS, { recursive: true });
|
|
16590
|
-
console.log(`[delegation] ${live.length} live \xB7 ${
|
|
16615
|
+
console.log(`[delegation] ${live.length} live \xB7 ${allGradable.length} gradable${cutoff ? ` \xB7 ${gradable.length} since ${cutoff.slice(0, 10)} (AI window)` : ""} \xB7 running detect on ${picked.length} (LLM only on stuck-loop candidates)\u2026`);
|
|
16591
16616
|
const lim = makeLimiter(CONC);
|
|
16592
16617
|
let reused = 0;
|
|
16593
16618
|
startRun("coding-delegation", picked.length);
|
|
@@ -16139,6 +16139,29 @@ function partition(sessions) {
|
|
|
16139
16139
|
(isGradable(s) ? gradable : isTrivial(s) ? trivial : thin).push(s);
|
|
16140
16140
|
return { gradable, thin, trivial };
|
|
16141
16141
|
}
|
|
16142
|
+
var AI_WINDOW = {
|
|
16143
|
+
days: 90,
|
|
16144
|
+
// ~3 months
|
|
16145
|
+
minSessions: 40
|
|
16146
|
+
// extend the window back until this many gradable sessions
|
|
16147
|
+
};
|
|
16148
|
+
function aiWindowCutoff(sessions, opts = {}) {
|
|
16149
|
+
const envDays = Number(process.env.POLYMATH_AI_WINDOW_DAYS);
|
|
16150
|
+
const days = opts.windowDays ?? (Number.isFinite(envDays) && envDays >= 0 ? envDays : AI_WINDOW.days);
|
|
16151
|
+
const floor = opts.minSessions ?? AI_WINDOW.minSessions;
|
|
16152
|
+
if (days === 0)
|
|
16153
|
+
return "";
|
|
16154
|
+
const starts = sessions.map((s) => s.start ?? "").filter(Boolean).sort();
|
|
16155
|
+
const latest = starts[starts.length - 1];
|
|
16156
|
+
if (!latest)
|
|
16157
|
+
return "";
|
|
16158
|
+
const windowCutoff = new Date(new Date(latest).getTime() - days * 864e5).toISOString();
|
|
16159
|
+
const gradableStarts = sessions.filter(isGradable).map((s) => s.start ?? "").filter(Boolean).sort().reverse();
|
|
16160
|
+
if (gradableStarts.length <= floor)
|
|
16161
|
+
return "";
|
|
16162
|
+
const floorStart = gradableStarts[floor - 1];
|
|
16163
|
+
return floorStart < windowCutoff ? floorStart : windowCutoff;
|
|
16164
|
+
}
|
|
16142
16165
|
|
|
16143
16166
|
// ../../lib/agents/coding/profile.ts
|
|
16144
16167
|
import path10 from "path";
|
|
@@ -16335,9 +16358,13 @@ var GRADES2 = path11.join(CODING, "grades");
|
|
|
16335
16358
|
var LOGS = path11.join(GRADES2, "logs");
|
|
16336
16359
|
async function main() {
|
|
16337
16360
|
const sessions = JSON.parse(await fs6.readFile(path11.join(CODING, "sessions.json"), "utf8"));
|
|
16338
|
-
const
|
|
16361
|
+
const live = sessions.filter((s) => s.klass === "interactive" && !s.duplicateOf);
|
|
16362
|
+
const { gradable: allGradable, thin, trivial } = partition(live);
|
|
16363
|
+
const cutoff = aiWindowCutoff(live);
|
|
16364
|
+
const gradable = cutoff ? allGradable.filter((s) => (s.start ?? "") >= cutoff) : allGradable;
|
|
16339
16365
|
const ranked = gradable.slice().sort((a, b) => b.humanChars * Math.log1p(b.humanTurns) - a.humanChars * Math.log1p(a.humanTurns));
|
|
16340
|
-
console.log(`[coding-grade] ${sessions.length} sessions \u2192 ${
|
|
16366
|
+
console.log(`[coding-grade] ${sessions.length} sessions \u2192 ${allGradable.length} gradable \xB7 ${thin.length} thin \xB7 ${trivial.length} trivial (skipped)`);
|
|
16367
|
+
if (cutoff) console.log(`[coding-grade] AI window: grading sessions since ${cutoff.slice(0, 10)} \u2014 ${gradable.length} of ${allGradable.length} gradable (POLYMATH_AI_WINDOW_DAYS=0 for full history)`);
|
|
16341
16368
|
await fs6.mkdir(LOGS, { recursive: true });
|
|
16342
16369
|
const limit = ALL ? ranked.length : N;
|
|
16343
16370
|
const picked = [];
|
|
@@ -15887,9 +15887,35 @@ var GATE = {
|
|
|
15887
15887
|
// below this = a one-liner, definitely trivial
|
|
15888
15888
|
trivialHumanTurns: 2
|
|
15889
15889
|
};
|
|
15890
|
+
function isGradable(s) {
|
|
15891
|
+
return s.humanChars >= GATE.minHumanChars && s.humanTurns >= GATE.minHumanTurns;
|
|
15892
|
+
}
|
|
15890
15893
|
function isTrivial(s) {
|
|
15891
15894
|
return s.humanTurns < GATE.trivialHumanTurns || s.humanChars < GATE.trivialHumanChars;
|
|
15892
15895
|
}
|
|
15896
|
+
var AI_WINDOW = {
|
|
15897
|
+
days: 90,
|
|
15898
|
+
// ~3 months
|
|
15899
|
+
minSessions: 40
|
|
15900
|
+
// extend the window back until this many gradable sessions
|
|
15901
|
+
};
|
|
15902
|
+
function aiWindowCutoff(sessions, opts = {}) {
|
|
15903
|
+
const envDays = Number(process.env.POLYMATH_AI_WINDOW_DAYS);
|
|
15904
|
+
const days = opts.windowDays ?? (Number.isFinite(envDays) && envDays >= 0 ? envDays : AI_WINDOW.days);
|
|
15905
|
+
const floor = opts.minSessions ?? AI_WINDOW.minSessions;
|
|
15906
|
+
if (days === 0)
|
|
15907
|
+
return "";
|
|
15908
|
+
const starts = sessions.map((s) => s.start ?? "").filter(Boolean).sort();
|
|
15909
|
+
const latest = starts[starts.length - 1];
|
|
15910
|
+
if (!latest)
|
|
15911
|
+
return "";
|
|
15912
|
+
const windowCutoff = new Date(new Date(latest).getTime() - days * 864e5).toISOString();
|
|
15913
|
+
const gradableStarts = sessions.filter(isGradable).map((s) => s.start ?? "").filter(Boolean).sort().reverse();
|
|
15914
|
+
if (gradableStarts.length <= floor)
|
|
15915
|
+
return "";
|
|
15916
|
+
const floorStart = gradableStarts[floor - 1];
|
|
15917
|
+
return floorStart < windowCutoff ? floorStart : windowCutoff;
|
|
15918
|
+
}
|
|
15893
15919
|
|
|
15894
15920
|
// ../../lib/agents/coding/profile.ts
|
|
15895
15921
|
import path10 from "path";
|
|
@@ -16223,14 +16249,16 @@ function limiter(max) {
|
|
|
16223
16249
|
}
|
|
16224
16250
|
async function main() {
|
|
16225
16251
|
const sessions = JSON.parse(await fs6.readFile(path11.join(CODING, "sessions.json"), "utf8"));
|
|
16226
|
-
const
|
|
16252
|
+
const live = sessions.filter((s) => s.klass === "interactive" && !s.duplicateOf);
|
|
16253
|
+
const cutoff = aiWindowCutoff(live);
|
|
16254
|
+
const todo = live.filter((s) => !isTrivial(s) && (!cutoff || (s.start ?? "") >= cutoff)).sort((a, b) => b.humanChars - a.humanChars);
|
|
16227
16255
|
await fs6.mkdir(DIR, { recursive: true });
|
|
16228
16256
|
const pending = [];
|
|
16229
16257
|
for (const s of todo) {
|
|
16230
16258
|
if (!REGEN && await readWalkthrough(DIR, s.sessionId)) continue;
|
|
16231
16259
|
pending.push(s);
|
|
16232
16260
|
}
|
|
16233
|
-
console.log(`[walkthrough] ${todo.length} substantial sessions \xB7 ${pending.length} to build on ${MODEL}, conc ${CONC}`);
|
|
16261
|
+
console.log(`[walkthrough] ${todo.length} substantial sessions${cutoff ? ` since ${cutoff.slice(0, 10)} (AI window)` : ""} \xB7 ${pending.length} to build on ${MODEL}, conc ${CONC}`);
|
|
16234
16262
|
const lim = limiter(CONC);
|
|
16235
16263
|
startRun("walkthrough", pending.length);
|
|
16236
16264
|
await Promise.all(pending.map((s) => lim(async () => {
|