@cortexkit/opencode-magic-context 0.42.4 → 0.42.5
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/features/magic-context/dreamer/curate-category-rotation.d.ts +26 -0
- package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +7 -5
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts +1 -0
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +3 -0
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +6 -0
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +5 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +11 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/{index-faay035c.js → index-3wbd8sdq.js} +29 -11
- package/dist/{index-bkg2fdj1.js → index-4wwr6cz0.js} +3 -0
- package/dist/index.js +189 -27
- package/dist/{recomp-orchestrator-c4sa354a.js → recomp-orchestrator-k20sfpm2.js} +1 -1
- package/dist/{task-config-ys0arma5.js → task-config-cv8k9y8r.js} +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/v2/server.js +530 -2471
- package/package.json +1 -1
- package/src/features/magic-context/dreamer/task-registry.ts +10 -0
package/dist/index.js
CHANGED
|
@@ -547,7 +547,7 @@ import {
|
|
|
547
547
|
setRecompTerminal2,
|
|
548
548
|
runManagedRecomp2,
|
|
549
549
|
runManagedUpgrade2
|
|
550
|
-
} from "./index-
|
|
550
|
+
} from "./index-3wbd8sdq.js";
|
|
551
551
|
import {
|
|
552
552
|
stripJsonComments,
|
|
553
553
|
isPrototypePollutionKey,
|
|
@@ -626,7 +626,7 @@ import {
|
|
|
626
626
|
compareTaskOrder,
|
|
627
627
|
buildDreamTaskRuntimeConfigs2,
|
|
628
628
|
userMemoryCollectionEnabled2
|
|
629
|
-
} from "./index-
|
|
629
|
+
} from "./index-4wwr6cz0.js";
|
|
630
630
|
import {
|
|
631
631
|
logSlowWriteTransaction,
|
|
632
632
|
getOrCreateSessionMeta2,
|
|
@@ -10781,9 +10781,11 @@ function buildCuratePrompt(args) {
|
|
|
10781
10781
|
|
|
10782
10782
|
**Project:** ${args.projectPath}
|
|
10783
10783
|
|
|
10784
|
+
This run covers the whole of the \`${args.category}\` category (the other categories run in later windows).
|
|
10785
|
+
|
|
10784
10786
|
The memories below are assumed ACCURATE (a separate verify task keeps them true). Your job is pool QUALITY: remove duplicates, tighten wording, and consolidate redundant entries that waste the ~6000-token injection budget. Explain each action in one line first. Do NOT mint new facts (that is the historian's job).
|
|
10785
10787
|
|
|
10786
|
-
Work ALL THREE phases below in order (A → B → C) over
|
|
10788
|
+
Work ALL THREE phases below in order (A → B → C) over this category. Do NOT stop after consolidating — a run that only merges and never improves or archives is incomplete.
|
|
10787
10789
|
|
|
10788
10790
|
### Phase A — Consolidate duplicates
|
|
10789
10791
|
Group by category, then merge near-identical / superset-subset / same-fact-different-angle clusters into one canonical memory with \`ctx_memory(action="merge", ids=[...], content="...", category="...")\`. Preserve every unique detail; terse present tense; paths/keys verbatim. Every id in a merge MUST share the same category — the system rejects cross-category merges. If two similar memories sit in different categories they are NOT duplicates; do not archive either as a consolidation. One fact per memory.
|
|
@@ -11003,6 +11005,7 @@ function buildDreamTaskPrompt(task, args) {
|
|
|
11003
11005
|
case "curate":
|
|
11004
11006
|
return buildCuratePrompt({
|
|
11005
11007
|
projectPath: args.projectPath,
|
|
11008
|
+
category: args.curate?.category ?? "PROJECT_RULES",
|
|
11006
11009
|
memories: args.curate?.memories ?? []
|
|
11007
11010
|
});
|
|
11008
11011
|
case "maintain-docs":
|
|
@@ -13567,6 +13570,7 @@ function toRow(r) {
|
|
|
13567
13570
|
lastStatus: r.last_status ?? null,
|
|
13568
13571
|
lastError: r.last_error,
|
|
13569
13572
|
retryCount: r.retry_count ?? 0,
|
|
13573
|
+
taskStateJson: r.last_checked_commit ?? null,
|
|
13570
13574
|
lastCheckedCommit: r.last_checked_commit ?? null,
|
|
13571
13575
|
lastBroadRunAt: r.last_broad_run_at ?? null,
|
|
13572
13576
|
retrospectiveWatermarkMs: r.retrospective_watermark_ms ?? null
|
|
@@ -13610,7 +13614,12 @@ function writeTaskScheduleState(db, row) {
|
|
|
13610
13614
|
retry_count = excluded.retry_count,
|
|
13611
13615
|
last_checked_commit = COALESCE(excluded.last_checked_commit, task_schedule_state.last_checked_commit),
|
|
13612
13616
|
${broadCycleUpdate},
|
|
13613
|
-
retrospective_watermark_ms = COALESCE(excluded.retrospective_watermark_ms, task_schedule_state.retrospective_watermark_ms)`).run(row.projectPath, row.task, row.lastRunAt, row.nextDueAt, row.schedule, row.lastStatus, row.lastError, row.retryCount, row.lastCheckedCommit ?? null, row.lastBroadRunAt ?? null, row.retrospectiveWatermarkMs ?? null);
|
|
13617
|
+
retrospective_watermark_ms = COALESCE(excluded.retrospective_watermark_ms, task_schedule_state.retrospective_watermark_ms)`).run(row.projectPath, row.task, row.lastRunAt, row.nextDueAt, row.schedule, row.lastStatus, row.lastError, row.retryCount, row.taskStateJson ?? row.lastCheckedCommit ?? null, row.lastBroadRunAt ?? null, row.retrospectiveWatermarkMs ?? null);
|
|
13618
|
+
}
|
|
13619
|
+
function writeTaskStateJson(db, projectPath, task, taskStateJson) {
|
|
13620
|
+
db.prepare(`INSERT INTO task_schedule_state (project_path, task, last_checked_commit)
|
|
13621
|
+
VALUES (?, ?, ?)
|
|
13622
|
+
ON CONFLICT(project_path, task) DO UPDATE SET last_checked_commit = excluded.last_checked_commit`).run(projectPath, task, taskStateJson);
|
|
13614
13623
|
}
|
|
13615
13624
|
function isRetrospectiveWindowProcessed(db, projectPath, windowKey) {
|
|
13616
13625
|
const row = db.prepare("SELECT 1 AS one FROM retrospective_processed_windows WHERE project_path = ? AND window_key = ?").get(projectPath, windowKey);
|
|
@@ -15046,6 +15055,104 @@ function recordInvocation(args, startedAt, params) {
|
|
|
15046
15055
|
});
|
|
15047
15056
|
}
|
|
15048
15057
|
|
|
15058
|
+
// src/features/magic-context/dreamer/curate-category-rotation.ts
|
|
15059
|
+
var CURATE_MEMORY_CATEGORIES = [
|
|
15060
|
+
"PROJECT_RULES",
|
|
15061
|
+
"ARCHITECTURE",
|
|
15062
|
+
"CONSTRAINTS",
|
|
15063
|
+
"CONFIG_VALUES",
|
|
15064
|
+
"NAMING"
|
|
15065
|
+
];
|
|
15066
|
+
var LEGACY_CURATE_CATEGORY_BUCKETS = {
|
|
15067
|
+
ARCHITECTURE_DECISIONS: "ARCHITECTURE",
|
|
15068
|
+
CONFIG_DEFAULTS: "CONFIG_VALUES",
|
|
15069
|
+
ENVIRONMENT: "CONFIG_VALUES",
|
|
15070
|
+
KNOWN_ISSUES: "CONSTRAINTS",
|
|
15071
|
+
USER_DIRECTIVES: "PROJECT_RULES",
|
|
15072
|
+
USER_PREFERENCES: "PROJECT_RULES",
|
|
15073
|
+
WORKFLOW_RULES: "PROJECT_RULES"
|
|
15074
|
+
};
|
|
15075
|
+
function curateCategoryForMemoryCategory(category) {
|
|
15076
|
+
return isCurateMemoryCategory(category) ? category : LEGACY_CURATE_CATEGORY_BUCKETS[category] ?? null;
|
|
15077
|
+
}
|
|
15078
|
+
function isCurateMemoryCategory(value) {
|
|
15079
|
+
return CURATE_MEMORY_CATEGORIES.includes(value);
|
|
15080
|
+
}
|
|
15081
|
+
function parseTaskState(raw) {
|
|
15082
|
+
if (!raw)
|
|
15083
|
+
return {};
|
|
15084
|
+
try {
|
|
15085
|
+
const parsed = JSON.parse(raw);
|
|
15086
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
15087
|
+
} catch {
|
|
15088
|
+
return {};
|
|
15089
|
+
}
|
|
15090
|
+
}
|
|
15091
|
+
function normalizedCursor(value) {
|
|
15092
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value % CURATE_MEMORY_CATEGORIES.length : 0;
|
|
15093
|
+
}
|
|
15094
|
+
function readState(db, projectIdentity) {
|
|
15095
|
+
return parseTaskState(getTaskScheduleState(db, projectIdentity, "curate")?.taskStateJson);
|
|
15096
|
+
}
|
|
15097
|
+
function categoryStartIndex(state, populated) {
|
|
15098
|
+
const active = state.curate?.activeCategory;
|
|
15099
|
+
if (isCurateMemoryCategory(active)) {
|
|
15100
|
+
const activeIndex = CURATE_MEMORY_CATEGORIES.indexOf(active);
|
|
15101
|
+
return populated.has(active) ? activeIndex : (activeIndex + 1) % CURATE_MEMORY_CATEGORIES.length;
|
|
15102
|
+
}
|
|
15103
|
+
return normalizedCursor(state.curate?.cursor);
|
|
15104
|
+
}
|
|
15105
|
+
function peekCurateCategoryScope(db, projectIdentity, memories) {
|
|
15106
|
+
const populated = new Set(memories.map((memory) => curateCategoryForMemoryCategory(memory.category)).filter((category) => category !== null));
|
|
15107
|
+
const start = categoryStartIndex(readState(db, projectIdentity), populated);
|
|
15108
|
+
for (let offset = 0;offset < CURATE_MEMORY_CATEGORIES.length; offset += 1) {
|
|
15109
|
+
const category = CURATE_MEMORY_CATEGORIES[(start + offset) % CURATE_MEMORY_CATEGORIES.length];
|
|
15110
|
+
const scoped = memories.filter((memory) => curateCategoryForMemoryCategory(memory.category) === category);
|
|
15111
|
+
if (scoped.length > 0)
|
|
15112
|
+
return { category, memories: scoped };
|
|
15113
|
+
}
|
|
15114
|
+
return null;
|
|
15115
|
+
}
|
|
15116
|
+
function beginCurateCategoryRun(db, projectIdentity, memories) {
|
|
15117
|
+
const scope = peekCurateCategoryScope(db, projectIdentity, memories);
|
|
15118
|
+
if (!scope)
|
|
15119
|
+
return null;
|
|
15120
|
+
const state = readState(db, projectIdentity);
|
|
15121
|
+
writeTaskStateJson(db, projectIdentity, "curate", JSON.stringify({
|
|
15122
|
+
...state,
|
|
15123
|
+
curate: {
|
|
15124
|
+
cursor: normalizedCursor(state.curate?.cursor),
|
|
15125
|
+
activeCategory: scope.category
|
|
15126
|
+
}
|
|
15127
|
+
}));
|
|
15128
|
+
return scope;
|
|
15129
|
+
}
|
|
15130
|
+
function curateTaskStateAfterSuccess(db, projectIdentity, category) {
|
|
15131
|
+
const state = readState(db, projectIdentity);
|
|
15132
|
+
return JSON.stringify({
|
|
15133
|
+
...state,
|
|
15134
|
+
curate: {
|
|
15135
|
+
cursor: (CURATE_MEMORY_CATEGORIES.indexOf(category) + 1) % CURATE_MEMORY_CATEGORIES.length
|
|
15136
|
+
}
|
|
15137
|
+
});
|
|
15138
|
+
}
|
|
15139
|
+
function getActiveCurateCategory(db, projectIdentity) {
|
|
15140
|
+
const active = readState(db, projectIdentity).curate?.activeCategory;
|
|
15141
|
+
return isCurateMemoryCategory(active) ? active : null;
|
|
15142
|
+
}
|
|
15143
|
+
function getCurateCategoryScopeRefusal(args) {
|
|
15144
|
+
if (args.requestedCategory && args.requestedCategory !== args.scope) {
|
|
15145
|
+
return `Error: Curate scope is ${args.scope}; ${args.action} cannot target category ${args.requestedCategory}.`;
|
|
15146
|
+
}
|
|
15147
|
+
for (const id of args.ids ?? []) {
|
|
15148
|
+
const category = args.categoryForId(id);
|
|
15149
|
+
if (category && category !== args.scope) {
|
|
15150
|
+
return `Error: Curate scope is ${args.scope}; memory ID ${id} is outside the scoped category.`;
|
|
15151
|
+
}
|
|
15152
|
+
}
|
|
15153
|
+
return null;
|
|
15154
|
+
}
|
|
15155
|
+
|
|
15049
15156
|
// src/features/magic-context/dreamer/memory-claim-safety.ts
|
|
15050
15157
|
var POLICY_SENTENCE_START = /(?:^|[.!?]\s+|\n\s*)(?:[-*]\s+|\d+[.)]\s+)?(?:you\s+|we\s+)?(?:must(?:\s+not)?|never|always|do\s+not|don't|shall\s+not)\b/i;
|
|
15051
15158
|
var ACTOR_POLICY = /\b(?:you|we|agents?|masons?|workers?|operators?|users?|maintainers?)\s+(?:must(?:\s+not)?|should(?:\s+not)?|need\s+to|shall(?:\s+not)?|cannot|can't|may\s+not)\b/i;
|
|
@@ -18338,12 +18445,13 @@ function countActiveMemories(db, projectPath) {
|
|
|
18338
18445
|
}
|
|
18339
18446
|
function countLiveMemories(db, projectPath, options = {}) {
|
|
18340
18447
|
const unclassified = options.unclassifiedOnly && hasMemoryClassifiedAtColumn(db);
|
|
18341
|
-
const
|
|
18342
|
-
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
|
|
18346
|
-
|
|
18448
|
+
const sql = `SELECT COUNT(*) AS cnt
|
|
18449
|
+
FROM memories
|
|
18450
|
+
WHERE project_path = ?
|
|
18451
|
+
AND status IN ('active','permanent')
|
|
18452
|
+
AND (expires_at IS NULL OR expires_at > ?)
|
|
18453
|
+
${unclassified ? "AND classified_at IS NULL" : ""}`;
|
|
18454
|
+
const row = options.category ? db.prepare(`${sql} AND category = ?`).get(projectPath, Date.now(), options.category) : db.prepare(sql).get(projectPath, Date.now());
|
|
18347
18455
|
return row?.cnt ?? 0;
|
|
18348
18456
|
}
|
|
18349
18457
|
function countUnmappedActiveMemories(db, projectPath) {
|
|
@@ -18454,8 +18562,13 @@ function getDreamTaskBacklog(db, projectPath, task, options = {}) {
|
|
|
18454
18562
|
return { pending, total };
|
|
18455
18563
|
}
|
|
18456
18564
|
case "curate": {
|
|
18457
|
-
const
|
|
18458
|
-
|
|
18565
|
+
const categories = db.prepare(`SELECT category FROM memories
|
|
18566
|
+
WHERE project_path = ?
|
|
18567
|
+
AND status IN ('active','permanent')
|
|
18568
|
+
AND (expires_at IS NULL OR expires_at > ?)`).all(projectPath, Date.now());
|
|
18569
|
+
const scope = peekCurateCategoryScope(db, projectPath, categories);
|
|
18570
|
+
const total = scope?.memories.length ?? 0;
|
|
18571
|
+
return scope ? { pending: total, total, category: scope.category } : { pending: 0, total: 0 };
|
|
18459
18572
|
}
|
|
18460
18573
|
case "compress-cues": {
|
|
18461
18574
|
const total = countLiveMemories(db, projectPath);
|
|
@@ -19307,6 +19420,7 @@ function createDreamTaskExecutor(deps) {
|
|
|
19307
19420
|
processed: Math.max(0, processed),
|
|
19308
19421
|
total: backlogAtStart.pending,
|
|
19309
19422
|
startedAt,
|
|
19423
|
+
...backlogAtStart.category ? { category: backlogAtStart.category } : {},
|
|
19310
19424
|
...refused === undefined ? {} : { refused: Math.max(0, refused) }
|
|
19311
19425
|
});
|
|
19312
19426
|
};
|
|
@@ -19359,7 +19473,8 @@ function createDreamTaskExecutor(deps) {
|
|
|
19359
19473
|
totalAtStart: backlogAtStart.total,
|
|
19360
19474
|
pendingAtEnd: end.pending,
|
|
19361
19475
|
totalAtEnd: end.total,
|
|
19362
|
-
processed
|
|
19476
|
+
processed,
|
|
19477
|
+
...backlogAtStart.category ? { category: backlogAtStart.category } : {}
|
|
19363
19478
|
};
|
|
19364
19479
|
return value;
|
|
19365
19480
|
})()
|
|
@@ -19965,6 +20080,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19965
20080
|
let expiredArchived = 0;
|
|
19966
20081
|
try {
|
|
19967
20082
|
let curateMemories;
|
|
20083
|
+
let curateCategory;
|
|
19968
20084
|
if (task === "curate") {
|
|
19969
20085
|
expiredArchived = await archiveExpiredMemories({
|
|
19970
20086
|
db,
|
|
@@ -19976,10 +20092,12 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19976
20092
|
});
|
|
19977
20093
|
if (leaseLost)
|
|
19978
20094
|
throw new Error("Dream lease lost during expired-memory archive");
|
|
19979
|
-
|
|
19980
|
-
|
|
19981
|
-
|
|
19982
|
-
|
|
20095
|
+
const scope = beginCurateCategoryRun(db, projectIdentity, loadActiveMemoryPromptMemories(db, projectIdentity));
|
|
20096
|
+
curateMemories = scope?.memories ?? [];
|
|
20097
|
+
curateCategory = scope?.category;
|
|
20098
|
+
log(`[dreamer] curate pool: category=${curateCategory ?? "none"} in_scope=${curateMemories.length} expired_archived=${expiredArchived}`);
|
|
20099
|
+
if (curateMemories.length === 0) {
|
|
20100
|
+
const progress = expiredArchived > 0 ? formatExpiredArchiveProgress(expiredArchived) : "curate: no populated project-memory category";
|
|
19983
20101
|
helpers.recordRun("completed", null, {
|
|
19984
20102
|
memoryChanges: helpers.computeMemoryDelta(memoryBefore),
|
|
19985
20103
|
progress
|
|
@@ -19991,7 +20109,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19991
20109
|
projectPath: projectIdentity,
|
|
19992
20110
|
lastDreamAt: lastRunAt ? String(lastRunAt) : null,
|
|
19993
20111
|
existingDocs,
|
|
19994
|
-
curate: curateMemories ? { memories: curateMemories } : undefined
|
|
20112
|
+
curate: curateMemories && curateCategory ? { category: curateCategory, memories: curateMemories } : undefined
|
|
19995
20113
|
});
|
|
19996
20114
|
const createResponse = await createChildSessionWithFence({
|
|
19997
20115
|
client: requireDreamClient(deps.client),
|
|
@@ -20083,16 +20201,34 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
20083
20201
|
}
|
|
20084
20202
|
}
|
|
20085
20203
|
const curateOutput = task === "curate" ? run.validated : undefined;
|
|
20204
|
+
const curateScopeProgress = task === "curate" && curateCategory && curateMemories ? `curate: ${curateCategory} (${curateMemories.length})` : null;
|
|
20086
20205
|
const progress = [
|
|
20206
|
+
curateScopeProgress,
|
|
20087
20207
|
expiredArchived > 0 ? formatExpiredArchiveProgress(expiredArchived) : null,
|
|
20088
20208
|
curateOutput && curateOutput.memoryOperations.completedActions.length > 0 ? formatCurateMemoryOperations(curateOutput.memoryOperations.completedActions) : null,
|
|
20089
20209
|
curateRefused > 0 ? `curate: refused ${curateRefused} unsafe mutation(s)` : null
|
|
20090
20210
|
].filter((value) => Boolean(value)).join("; ");
|
|
20211
|
+
const curateCount = task === "curate" && curateCategory ? loadActiveMemoryPromptMemories(db, projectIdentity).filter((memory) => curateCategoryForMemoryCategory(memory.category) === curateCategory).length : undefined;
|
|
20212
|
+
const curateBacklog = curateCount !== undefined && curateCategory ? {
|
|
20213
|
+
pending: curateCount,
|
|
20214
|
+
total: curateCount,
|
|
20215
|
+
category: curateCategory
|
|
20216
|
+
} : undefined;
|
|
20091
20217
|
helpers.recordRun("completed", null, {
|
|
20092
20218
|
memoryChanges: helpers.computeMemoryDelta(memoryBefore),
|
|
20093
|
-
progress: progress || null
|
|
20219
|
+
progress: progress || null,
|
|
20220
|
+
backlogAfter: curateBacklog
|
|
20094
20221
|
});
|
|
20095
|
-
return {
|
|
20222
|
+
return {
|
|
20223
|
+
status: "completed",
|
|
20224
|
+
...progress ? { detail: progress } : {},
|
|
20225
|
+
...curateBacklog ? { backlog: curateBacklog } : {},
|
|
20226
|
+
...curateCategory ? {
|
|
20227
|
+
schedulePatch: {
|
|
20228
|
+
taskStateJson: curateTaskStateAfterSuccess(db, projectIdentity, curateCategory)
|
|
20229
|
+
}
|
|
20230
|
+
} : {}
|
|
20231
|
+
};
|
|
20096
20232
|
} finally {
|
|
20097
20233
|
heartbeat.stop();
|
|
20098
20234
|
if (childSessionId)
|
|
@@ -20167,6 +20303,7 @@ function advanceAfterRun(db, projectIdentity, due, finishedAt, status, error, sc
|
|
|
20167
20303
|
lastStatus: status,
|
|
20168
20304
|
lastError: error,
|
|
20169
20305
|
retryCount: 0,
|
|
20306
|
+
taskStateJson: schedulePatch?.taskStateJson,
|
|
20170
20307
|
retrospectiveWatermarkMs: schedulePatch?.retrospectiveWatermarkMs
|
|
20171
20308
|
});
|
|
20172
20309
|
}
|
|
@@ -20259,7 +20396,7 @@ async function runDomainGroup(deps, group, cb) {
|
|
|
20259
20396
|
const finishedAt = Date.now();
|
|
20260
20397
|
if (outcome.status === "completed") {
|
|
20261
20398
|
advanceAfterRun(db, projectIdentity, due, finishedAt, "completed", null, outcome.schedulePatch);
|
|
20262
|
-
cb?.onRan?.(due.config.task, outcome.detail);
|
|
20399
|
+
cb?.onRan?.(due.config.task, outcome.detail, outcome.backlog);
|
|
20263
20400
|
} else if (outcome.transient) {
|
|
20264
20401
|
recordTransientFailure(db, projectIdentity, due, finishedAt, outcome.error ?? null);
|
|
20265
20402
|
cb?.onFailed?.(due.config.task, outcome.failureDetail ?? outcome.error);
|
|
@@ -20326,6 +20463,7 @@ async function runManualDream(deps) {
|
|
|
20326
20463
|
return result;
|
|
20327
20464
|
}
|
|
20328
20465
|
const groups = new Map;
|
|
20466
|
+
const runLocalBacklogs = {};
|
|
20329
20467
|
for (const d of gated) {
|
|
20330
20468
|
const kind = leaseKindFor(d.config.task);
|
|
20331
20469
|
const arr = groups.get(kind) ?? [];
|
|
@@ -20335,10 +20473,12 @@ async function runManualDream(deps) {
|
|
|
20335
20473
|
await Promise.all([...groups.values()].map((group) => runDomainGroup({ ...deps, executor: deps.executor }, group, {
|
|
20336
20474
|
forceGate,
|
|
20337
20475
|
leaseWaitMs: MANUAL_RUN_LEASE_WAIT_MS,
|
|
20338
|
-
onRan: (t, detail) => {
|
|
20476
|
+
onRan: (t, detail, backlog) => {
|
|
20339
20477
|
result.ran.push(t);
|
|
20340
20478
|
if (detail)
|
|
20341
20479
|
result.details?.push(detail);
|
|
20480
|
+
if (backlog)
|
|
20481
|
+
runLocalBacklogs[t] = backlog;
|
|
20342
20482
|
},
|
|
20343
20483
|
onFailed: (task, error) => {
|
|
20344
20484
|
result.failed.push(task);
|
|
@@ -20347,7 +20487,10 @@ async function runManualDream(deps) {
|
|
|
20347
20487
|
},
|
|
20348
20488
|
onBusy: (t) => result.deferredBusy.push(t)
|
|
20349
20489
|
})));
|
|
20350
|
-
result.backlogAfter =
|
|
20490
|
+
result.backlogAfter = {
|
|
20491
|
+
...getDreamTaskBacklogs(deps.db, deps.projectIdentity, selectedTaskNames),
|
|
20492
|
+
...runLocalBacklogs
|
|
20493
|
+
};
|
|
20351
20494
|
return result;
|
|
20352
20495
|
}
|
|
20353
20496
|
async function runDueTasksForProject(deps) {
|
|
@@ -29517,7 +29660,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
29517
29660
|
const buildManagedCtx = async (db) => {
|
|
29518
29661
|
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await import("./derive-budgets-v1fkhjjr.js");
|
|
29519
29662
|
const { resolveHistorianModel } = await import("./model-resolution-dxatzjde.js");
|
|
29520
|
-
const { userMemoryCollectionEnabled } = await import("./task-config-
|
|
29663
|
+
const { userMemoryCollectionEnabled } = await import("./task-config-cv8k9y8r.js");
|
|
29521
29664
|
const DEFAULT_HISTORIAN_TIMEOUT_MS = 600000;
|
|
29522
29665
|
const historianModel = resolveHistorianModel(config, "opencode");
|
|
29523
29666
|
return {
|
|
@@ -29548,7 +29691,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
29548
29691
|
const db = getDb();
|
|
29549
29692
|
if (!db)
|
|
29550
29693
|
return { ok: false, error: "db unavailable" };
|
|
29551
|
-
const { runManagedRecomp } = await import("./recomp-orchestrator-
|
|
29694
|
+
const { runManagedRecomp } = await import("./recomp-orchestrator-k20sfpm2.js");
|
|
29552
29695
|
const { sendIgnoredMessage } = await import("./send-session-notification-xnypkxpx.js");
|
|
29553
29696
|
log(`[rpc] recomp requested for session ${sessionId}`);
|
|
29554
29697
|
const ctx = await buildManagedCtx(db);
|
|
@@ -29567,7 +29710,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
29567
29710
|
const db = getDb();
|
|
29568
29711
|
if (!db)
|
|
29569
29712
|
return { ok: false, error: "db unavailable" };
|
|
29570
|
-
const { runManagedUpgrade } = await import("./recomp-orchestrator-
|
|
29713
|
+
const { runManagedUpgrade } = await import("./recomp-orchestrator-k20sfpm2.js");
|
|
29571
29714
|
const { sendIgnoredMessage } = await import("./send-session-notification-xnypkxpx.js");
|
|
29572
29715
|
log(`[rpc] session-upgrade requested for session ${sessionId}`);
|
|
29573
29716
|
const ctx = await buildManagedCtx(db);
|
|
@@ -41535,6 +41678,24 @@ function createCtxMemoryTool(deps) {
|
|
|
41535
41678
|
return "Error: Could not resolve project identity for memory action.";
|
|
41536
41679
|
}
|
|
41537
41680
|
await deps.ensureProjectRegistered?.(toolContext.directory, deps.db);
|
|
41681
|
+
const activeCurateCategory = toolContext.agent === DREAMER_AGENT ? getActiveCurateCategory(deps.db, projectPath) : null;
|
|
41682
|
+
if (activeCurateCategory) {
|
|
41683
|
+
const scopeRefusal = getCurateCategoryScopeRefusal({
|
|
41684
|
+
scope: activeCurateCategory,
|
|
41685
|
+
action: args.action,
|
|
41686
|
+
requestedCategory: args.category,
|
|
41687
|
+
ids: [
|
|
41688
|
+
...args.ids ?? [],
|
|
41689
|
+
...Number.isInteger(args.superseded_by) ? [args.superseded_by] : []
|
|
41690
|
+
],
|
|
41691
|
+
categoryForId: (id) => {
|
|
41692
|
+
const category = getMemoryById(deps.db, id)?.category;
|
|
41693
|
+
return category ? curateCategoryForMemoryCategory(category) : null;
|
|
41694
|
+
}
|
|
41695
|
+
});
|
|
41696
|
+
if (scopeRefusal)
|
|
41697
|
+
return scopeRefusal;
|
|
41698
|
+
}
|
|
41538
41699
|
const curatePreflight = toolContext.agent === DREAMER_AGENT ? preflightCurateMutation({
|
|
41539
41700
|
db: deps.db,
|
|
41540
41701
|
params: args,
|
|
@@ -41669,7 +41830,8 @@ function createCtxMemoryTool(deps) {
|
|
|
41669
41830
|
if (args.action === "list") {
|
|
41670
41831
|
const limit = normalizeLimit2(args.limit);
|
|
41671
41832
|
const category = normalizeCategory(args.category);
|
|
41672
|
-
const
|
|
41833
|
+
const allMemories = getMemoriesByProject(deps.db, projectPath);
|
|
41834
|
+
const memories = (activeCurateCategory ? allMemories.filter((memory) => curateCategoryForMemoryCategory(memory.category) === activeCurateCategory) : filterByCategory(allMemories, category)).slice(0, limit);
|
|
41673
41835
|
return formatMemoryList(memories);
|
|
41674
41836
|
}
|
|
41675
41837
|
if (args.action === "get") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AA4DhE,OAAO,EAKH,KAAK,iBAAiB,EACzB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAikCrE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
|