@cortexkit/opencode-magic-context 0.36.1 → 0.37.0
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/config/index.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +2 -1
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +10 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-mt0ttc4x.js → conflict-warning-hook-an4fxhwf.js} +3 -3
- package/dist/{derive-budgets-88mxk2w1.js → derive-budgets-0f8xpyw2.js} +3 -2
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +3 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +6 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/runner.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/wake-plane.d.ts +21 -0
- package/dist/features/magic-context/smart-notes/wake-plane.d.ts.map +1 -0
- package/dist/features/magic-context/storage-db.d.ts +13 -2
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +22 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-primers.d.ts +11 -0
- package/dist/features/magic-context/storage-primers.d.ts.map +1 -1
- package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +7 -0
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
- package/dist/features/magic-context/window-report-ledger.d.ts +70 -0
- package/dist/features/magic-context/window-report-ledger.d.ts.map +1 -0
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +4 -0
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +2 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +20 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +8 -0
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts +6 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +17 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +25 -0
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +11 -3
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +10 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-1skzp4dc.js → index-0ze9p983.js} +572 -92
- package/dist/{index-nsx2n9eg.js → index-4cz5nfxf.js} +3 -3
- package/dist/{index-f1tnb3vm.js → index-8pqfcghm.js} +21 -9
- package/dist/{index-zp6x6s6a.js → index-cae89eas.js} +25 -6
- package/dist/index-cgyfn1s2.js +53 -0
- package/dist/{index-3zqcdwqr.js → index-crke4z5j.js} +7 -4
- package/dist/{index-tsgs7td8.js → index-pck9vadr.js} +1 -1
- package/dist/index-q0t189ay.js +741 -0
- package/dist/{index-3tnkymva.js → index-sw8gnq34.js} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1172 -287
- package/dist/plugin/hooks/create-session-hooks.d.ts +3 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-a0g9b52q.js → recomp-orchestrator-c3ff16k7.js} +7 -6
- package/dist/{safe-notification-target-c11fdda2.js → safe-notification-target-b693f9x3.js} +2 -2
- package/dist/{send-session-notification-bgtf4853.js → send-session-notification-dxske5zm.js} +3 -3
- package/dist/shared/conflict-detector.d.ts +63 -0
- package/dist/shared/conflict-detector.d.ts.map +1 -1
- package/dist/shared/harness-provider-map.d.ts +8 -0
- package/dist/shared/harness-provider-map.d.ts.map +1 -1
- package/dist/shared/logger.d.ts +8 -0
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts +5 -0
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/prompt-surface.d.ts +2 -0
- package/dist/shared/prompt-surface.d.ts.map +1 -1
- package/dist/shared/rpc-client.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +14 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +19 -9
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/window-geometry.d.ts +89 -0
- package/dist/shared/window-geometry.d.ts.map +1 -0
- package/dist/{storage-meta-session-df9tstzr.js → storage-meta-session-mk4gsnke.js} +4 -3
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config/index.ts +2 -0
- package/src/config/latch-permanence-guard.test.ts +218 -0
- package/src/config/project-security.ts +10 -1
- package/src/config/schema/magic-context.ts +10 -0
- package/src/shared/__fixtures__/window-overlay.v1.json +337 -0
- package/src/shared/conflict-detector.test.ts +176 -1
- package/src/shared/conflict-detector.ts +126 -3
- package/src/shared/harness-provider-map.test.ts +20 -0
- package/src/shared/harness-provider-map.ts +19 -0
- package/src/shared/logger.test.ts +119 -0
- package/src/shared/logger.ts +33 -15
- package/src/shared/models-dev-cache.test.ts +17 -0
- package/src/shared/models-dev-cache.ts +58 -6
- package/src/shared/prompt-surface-runtime.ts +5 -3
- package/src/shared/prompt-surface.test.ts +38 -0
- package/src/shared/prompt-surface.ts +15 -2
- package/src/shared/rpc-client.ts +4 -2
- package/src/shared/rpc-types.ts +14 -0
- package/src/shared/rpc-utils.test.ts +137 -13
- package/src/shared/rpc-utils.ts +144 -31
- package/src/shared/window-geometry.test.ts +309 -0
- package/src/shared/window-geometry.ts +629 -0
- package/src/tui/data/context-db.ts +5 -0
- package/src/tui/index.tsx +22 -0
- package/src/tui-compiled/data/context-db.ts +5 -0
- package/src/tui-compiled/index.tsx +319 -255
- package/dist/index-wgvxkqpx.js +0 -342
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isMidTurn
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-sw8gnq34.js";
|
|
4
4
|
import {
|
|
5
5
|
sessionLog
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-8pqfcghm.js";
|
|
7
7
|
import {
|
|
8
8
|
__require
|
|
9
9
|
} from "./index-wckvcay0.js";
|
|
@@ -171,7 +171,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
171
171
|
queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
|
|
172
172
|
return "queued";
|
|
173
173
|
}
|
|
174
|
-
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-
|
|
174
|
+
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-b693f9x3.js");
|
|
175
175
|
if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
|
|
176
176
|
sessionLog(sessionId, "notification skipped (session not titled yet)");
|
|
177
177
|
return "skipped";
|
|
@@ -10,16 +10,19 @@ var buffer = [];
|
|
|
10
10
|
var flushTimer = null;
|
|
11
11
|
var FLUSH_INTERVAL_MS = 500;
|
|
12
12
|
var BUFFER_SIZE_LIMIT = 50;
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return;
|
|
13
|
+
var swallowedWriteCount = 0;
|
|
14
|
+
var lastErrorMessage = null;
|
|
15
|
+
var lastErrorTime = null;
|
|
16
|
+
function recordSwallowedWrite(error) {
|
|
18
17
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
swallowedWriteCount++;
|
|
19
|
+
lastErrorMessage = error instanceof Error ? error.message : String(error);
|
|
20
|
+
lastErrorTime = new Date().toISOString();
|
|
21
21
|
} catch {}
|
|
22
22
|
}
|
|
23
|
+
function ensureDir(filePath) {
|
|
24
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
25
|
+
}
|
|
23
26
|
function flush() {
|
|
24
27
|
if (flushTimer) {
|
|
25
28
|
clearTimeout(flushTimer);
|
|
@@ -33,7 +36,9 @@ function flush() {
|
|
|
33
36
|
const logFile = getMagicContextLogPath();
|
|
34
37
|
ensureDir(logFile);
|
|
35
38
|
fs.appendFileSync(logFile, data);
|
|
36
|
-
} catch {
|
|
39
|
+
} catch (error) {
|
|
40
|
+
recordSwallowedWrite(error);
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
function scheduleFlush() {
|
|
39
44
|
if (flushTimer)
|
|
@@ -62,8 +67,15 @@ ${data.stack}` : ""}` : ` ${JSON.stringify(data)}`;
|
|
|
62
67
|
function sessionLog(sessionId, message, data) {
|
|
63
68
|
log(`[magic-context][${sessionId}] ${message}`, data);
|
|
64
69
|
}
|
|
70
|
+
function getLoggerDiagnostics() {
|
|
71
|
+
return {
|
|
72
|
+
swallowedWriteCount,
|
|
73
|
+
lastErrorMessage,
|
|
74
|
+
lastErrorTime
|
|
75
|
+
};
|
|
76
|
+
}
|
|
65
77
|
if (!isTestEnv) {
|
|
66
78
|
process.on("exit", flush);
|
|
67
79
|
}
|
|
68
80
|
|
|
69
|
-
export { log, sessionLog };
|
|
81
|
+
export { log, sessionLog, getLoggerDiagnostics };
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./index-8mtsfhyg.js";
|
|
4
4
|
import {
|
|
5
5
|
waitForSafeNotificationTarget
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-pck9vadr.js";
|
|
7
7
|
import {
|
|
8
8
|
log
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-8pqfcghm.js";
|
|
10
10
|
import {
|
|
11
11
|
__require
|
|
12
12
|
} from "./index-wckvcay0.js";
|
|
@@ -59,14 +59,17 @@ function detectConflicts(directory, options) {
|
|
|
59
59
|
omoAnthropicRecovery: false
|
|
60
60
|
};
|
|
61
61
|
const reasons = [];
|
|
62
|
-
|
|
62
|
+
let compactionResult = options?.resolvedCompaction ?? checkCompaction(directory);
|
|
63
|
+
if (process.env.OPENCODE_DISABLE_AUTOCOMPACT) {
|
|
64
|
+
compactionResult = { auto: false, prune: false };
|
|
65
|
+
}
|
|
63
66
|
if (compactionEnabled && compactionResult.auto) {
|
|
64
67
|
conflicts.compactionAuto = true;
|
|
65
|
-
reasons.push("OpenCode auto-compaction is enabled (compaction.auto=true)");
|
|
68
|
+
reasons.push(options?.resolvedCompaction ? "OpenCode auto-compaction is enabled (compaction.auto=true) (resolved config)" : "OpenCode auto-compaction is enabled (compaction.auto=true)");
|
|
66
69
|
}
|
|
67
70
|
if (compactionEnabled && compactionResult.prune) {
|
|
68
71
|
conflicts.compactionPrune = true;
|
|
69
|
-
reasons.push("OpenCode prune is enabled (compaction.prune=true)");
|
|
72
|
+
reasons.push(options?.resolvedCompaction ? "OpenCode prune is enabled (compaction.prune=true) (resolved config)" : "OpenCode prune is enabled (compaction.prune=true)");
|
|
70
73
|
}
|
|
71
74
|
const dcpFound = checkDcpPlugin(directory);
|
|
72
75
|
if (dcpFound) {
|
|
@@ -93,6 +96,22 @@ function detectConflicts(directory, options) {
|
|
|
93
96
|
nativeCompaction: { auto: compactionResult.auto, prune: compactionResult.prune }
|
|
94
97
|
};
|
|
95
98
|
}
|
|
99
|
+
async function resolveCompactionForBoot(client, timeoutMs = 2000) {
|
|
100
|
+
try {
|
|
101
|
+
const result = await Promise.race([
|
|
102
|
+
client.config.get(),
|
|
103
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("config.get() timed out")), timeoutMs))
|
|
104
|
+
]);
|
|
105
|
+
const compaction = result?.data?.compaction;
|
|
106
|
+
if (typeof compaction?.auto !== "boolean" || typeof compaction?.prune !== "boolean") {
|
|
107
|
+
log(`[magic-context] conflict-detector: resolved config carried no explicit compaction block (${JSON.stringify(compaction) ?? "absent"}); falling back to file-based detection`);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return { auto: compaction.auto, prune: compaction.prune };
|
|
111
|
+
} catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
96
115
|
function checkCompaction(directory) {
|
|
97
116
|
if (process.env.OPENCODE_DISABLE_AUTOCOMPACT) {
|
|
98
117
|
return { auto: false, prune: false };
|
|
@@ -586,4 +605,4 @@ async function sendStartupAnnouncement(client, directory, version, features, foo
|
|
|
586
605
|
markSeen(version);
|
|
587
606
|
}
|
|
588
607
|
|
|
589
|
-
export { detectConflicts, sendConflictWarning, cleanupConflictWarnings, sendSchemaFenceWarning, sendStartupAnnouncement };
|
|
608
|
+
export { detectConflicts, resolveCompactionForBoot, sendConflictWarning, cleanupConflictWarnings, sendSchemaFenceWarning, sendStartupAnnouncement };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/shared/harness-provider-map.ts
|
|
2
|
+
var CANONICAL_TO_PI_PROVIDER = {
|
|
3
|
+
openai: "openai-codex",
|
|
4
|
+
google: "google-antigravity"
|
|
5
|
+
};
|
|
6
|
+
var PI_TO_CANONICAL_PROVIDER = {
|
|
7
|
+
"openai-codex": "openai",
|
|
8
|
+
"google-antigravity": "google"
|
|
9
|
+
};
|
|
10
|
+
var CANONICAL_TO_OMP_PROVIDER = {
|
|
11
|
+
openai: "openai-codex",
|
|
12
|
+
google: "google-antigravity"
|
|
13
|
+
};
|
|
14
|
+
var OMP_TO_CANONICAL_PROVIDER = {
|
|
15
|
+
"openai-codex": "openai",
|
|
16
|
+
"google-antigravity": "google"
|
|
17
|
+
};
|
|
18
|
+
function remapProviderPrefix(ref, map) {
|
|
19
|
+
if (typeof ref !== "string")
|
|
20
|
+
return ref;
|
|
21
|
+
const slash = ref.indexOf("/");
|
|
22
|
+
if (slash <= 0)
|
|
23
|
+
return ref;
|
|
24
|
+
const provider = ref.slice(0, slash);
|
|
25
|
+
if (!Object.hasOwn(map, provider))
|
|
26
|
+
return ref;
|
|
27
|
+
return `${map[provider]}${ref.slice(slash)}`;
|
|
28
|
+
}
|
|
29
|
+
function piModelRefToCanonical(ref) {
|
|
30
|
+
return remapProviderPrefix(ref, PI_TO_CANONICAL_PROVIDER);
|
|
31
|
+
}
|
|
32
|
+
function resolveModelRefForPi(ref) {
|
|
33
|
+
return remapProviderPrefix(piModelRefToCanonical(ref), CANONICAL_TO_PI_PROVIDER);
|
|
34
|
+
}
|
|
35
|
+
function modelRefLookupOrder(ref) {
|
|
36
|
+
const canonical = piModelRefToCanonical(ompModelRefToCanonical(ref));
|
|
37
|
+
return [
|
|
38
|
+
...new Set([
|
|
39
|
+
canonical,
|
|
40
|
+
ref,
|
|
41
|
+
resolveModelRefForPi(canonical),
|
|
42
|
+
resolveModelRefForOmp(canonical)
|
|
43
|
+
])
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
function ompModelRefToCanonical(ref) {
|
|
47
|
+
return remapProviderPrefix(ref, OMP_TO_CANONICAL_PROVIDER);
|
|
48
|
+
}
|
|
49
|
+
function resolveModelRefForOmp(ref) {
|
|
50
|
+
return remapProviderPrefix(ompModelRefToCanonical(ref), CANONICAL_TO_OMP_PROVIDER);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { piModelRefToCanonical, modelRefLookupOrder };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
piModelRefToCanonical
|
|
3
|
+
} from "./index-cgyfn1s2.js";
|
|
1
4
|
import {
|
|
2
5
|
closeQuietly,
|
|
3
6
|
getRawSessionMessageCountFromDb,
|
|
4
7
|
openCodeDbExists,
|
|
5
8
|
withReadOnlySessionDb
|
|
6
|
-
} from "./index-
|
|
9
|
+
} from "./index-sw8gnq34.js";
|
|
7
10
|
import {
|
|
8
11
|
log
|
|
9
|
-
} from "./index-
|
|
12
|
+
} from "./index-8pqfcghm.js";
|
|
10
13
|
import {
|
|
11
14
|
getHarness
|
|
12
15
|
} from "./index-mmrhhk9a.js";
|
|
@@ -2822,7 +2825,7 @@ function persistCachedM0(db, sessionId, payload) {
|
|
|
2822
2825
|
cached_m0_system_hash = ?,
|
|
2823
2826
|
cached_m0_model_key = ?,
|
|
2824
2827
|
cached_m0_project_identity = ?
|
|
2825
|
-
WHERE session_id = ?`).run(Buffer.from(payload.m0Bytes), payload.muralDataUrl ?? null, payload.muralHash ?? null, payload.projectMemoryEpoch, payload.workspaceFingerprint ?? null, payload.projectUserProfileVersion, payload.maxCompartmentSeq, payload.maxMemoryId, payload.maxMutationId, payload.maxMemoryMutationId ?? null, payload.m1Bytes ? Buffer.from(payload.m1Bytes) : null, payload.projectDocsHash, payload.materializedAt, payload.sessionFactsVersion, payload.upgradeState, payload.systemHash ?? "", payload.modelKey
|
|
2828
|
+
WHERE session_id = ?`).run(Buffer.from(payload.m0Bytes), payload.muralDataUrl ?? null, payload.muralHash ?? null, payload.projectMemoryEpoch, payload.workspaceFingerprint ?? null, payload.projectUserProfileVersion, payload.maxCompartmentSeq, payload.maxMemoryId, payload.maxMutationId, payload.maxMemoryMutationId ?? null, payload.m1Bytes ? Buffer.from(payload.m1Bytes) : null, payload.projectDocsHash, payload.materializedAt, payload.sessionFactsVersion, payload.upgradeState, payload.systemHash ?? "", payload.modelKey ? piModelRefToCanonical(payload.modelKey) : "", payload.projectIdentity ?? null, sessionId);
|
|
2826
2829
|
}
|
|
2827
2830
|
function clearCachedM0M1(db, sessionId) {
|
|
2828
2831
|
ensureSessionMetaRow(db, sessionId);
|
|
@@ -2944,7 +2947,7 @@ function updateSessionMeta(db, sessionId, updates) {
|
|
|
2944
2947
|
values.push(value ? 1 : 0);
|
|
2945
2948
|
} else if (typeof value === "string" || typeof value === "number") {
|
|
2946
2949
|
setClauses.push(`${column} = ?`);
|
|
2947
|
-
values.push(value);
|
|
2950
|
+
values.push(key === "lastObservedModelKey" && typeof value === "string" ? piModelRefToCanonical(value) : value);
|
|
2948
2951
|
}
|
|
2949
2952
|
}
|
|
2950
2953
|
if (setClauses.length === 0) {
|