@cortexkit/opencode-magic-context 0.41.0 → 0.41.2
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/schema/magic-context.d.ts +15 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-xj1r88a7.js → conflict-warning-hook-rf17b6et.js} +3 -3
- package/dist/{derive-budgets-3xfyphvk.js → derive-budgets-9q2d3r93.js} +2 -2
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +16 -17
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +21 -0
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -6
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-failure.d.ts +10 -2
- package/dist/features/magic-context/memory/embedding-failure.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +19 -2
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts +10 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts +3 -0
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts +4 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts +2 -0
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts +3 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-web-entry.d.ts +2 -0
- package/dist/features/magic-context/memory/transformers-web-entry.d.ts.map +1 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +28 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -0
- package/dist/features/magic-context/message-index.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 +15 -2
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +18 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +19 -2
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts +3 -2
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +2 -2
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-ops.d.ts +2 -0
- package/dist/features/magic-context/storage-ops.d.ts.map +1 -1
- package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +13 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +2 -2
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/hooks/magic-context/boundary-execution.d.ts +3 -0
- package/dist/hooks/magic-context/boundary-execution.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +4 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +3 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/live-session-state.d.ts +3 -1
- package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +9 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +13 -37
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +12 -5
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts +3 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +28 -2
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-b4gv9f7g.js → index-4x691bz5.js} +87 -2
- package/dist/{index-knna83k0.js → index-9j3tx8hy.js} +1 -1
- package/dist/{index-jmwq2wxr.js → index-b9j85d29.js} +1 -1
- package/dist/{index-2bykz3bx.js → index-cvda5jb3.js} +7 -2
- package/dist/{index-bf799gbq.js → index-d1mxrd3p.js} +0 -1
- package/dist/{index-dmgbar7r.js → index-eq9wr75c.js} +2 -2
- package/dist/{index-w8rkbhn6.js → index-j8r0ejb3.js} +1232 -261
- package/dist/{index-26ds03jd.js → index-vnz6jvdc.js} +1 -1
- package/dist/{index-x9dmzyp5.js → index-y1yr57fw.js} +81 -17
- package/dist/{index-88za3sz8.js → index-zwjhba2r.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1771 -1109
- package/dist/{model-resolution-jgrkt0z2.js → model-resolution-6w6wzw18.js} +1 -1
- package/dist/plugin/dream-timer.d.ts +4 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/embedding-routing.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-1w4xj6jt.js → recomp-orchestrator-m37p3fq6.js} +6 -6
- package/dist/{safe-notification-target-p0c0csxw.js → safe-notification-target-2a8py95v.js} +2 -2
- package/dist/{send-session-notification-kn34g7mx.js → send-session-notification-bw7eex6w.js} +3 -3
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/model-resolution.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +3 -1
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/summarize-child-stderr.d.ts +2 -0
- package/dist/shared/summarize-child-stderr.d.ts.map +1 -0
- package/dist/shared/test-temp-dir.d.ts +40 -0
- package/dist/shared/test-temp-dir.d.ts.map +1 -0
- package/dist/shared/window-geometry.d.ts +2 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/{storage-meta-session-snbzd26z.js → storage-meta-session-dse3qv6s.js} +5 -3
- package/dist/{task-config-ty08ptc2.js → task-config-gv6s04fp.js} +2 -2
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +2 -0
- package/dist/tools/ctx-memory/types.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/transformers-node-wasm.js +25676 -0
- package/dist/transformers-web.js +24570 -0
- package/dist/transformers.node-b1wa0hgx.js +28808 -0
- package/package.json +8 -3
- package/src/config/index.test.ts +50 -4
- package/src/config/latch-permanence-guard.test.ts +5 -0
- package/src/config/schema/magic-context.test.ts +20 -0
- package/src/config/schema/magic-context.ts +8 -0
- package/src/shared/conflict-detector.test.ts +6 -19
- package/src/shared/conflict-fixer.test.ts +5 -8
- package/src/shared/index.ts +1 -0
- package/src/shared/logger.test.ts +135 -40
- package/src/shared/logger.ts +115 -2
- package/src/shared/model-resolution.test.ts +21 -19
- package/src/shared/model-resolution.ts +0 -1
- package/src/shared/rpc-utils.test.ts +246 -5
- package/src/shared/rpc-utils.ts +340 -49
- package/src/shared/summarize-child-stderr.test.ts +55 -0
- package/src/shared/summarize-child-stderr.ts +33 -0
- package/src/shared/test-temp-dir.test.ts +57 -0
- package/src/shared/test-temp-dir.ts +165 -0
- package/src/shared/window-geometry.ts +9 -0
- /package/dist/{index-rpgg35ms.js → index-8sseka65.js} +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { mkdtempSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
const STALE_TEMP_DIR_AGE_MS = 60 * 60 * 1000;
|
|
6
|
+
|
|
7
|
+
// Keep this list narrow: startup cleanup must never turn into a shared /tmp purge.
|
|
8
|
+
export const TEST_TEMP_DIR_PREFIXES = [
|
|
9
|
+
"mc-plugin-test-xdg-pid-",
|
|
10
|
+
"mc-pi-test-xdg-",
|
|
11
|
+
"mc-conflict-",
|
|
12
|
+
"mc-conflict-fixer-",
|
|
13
|
+
"mc-config-secret-",
|
|
14
|
+
"pi-reasoning-replay-",
|
|
15
|
+
"pi-session-api-test-",
|
|
16
|
+
"pi-symlink-test-",
|
|
17
|
+
"pi-running-vs-stale-",
|
|
18
|
+
"pi-dist-metadata-",
|
|
19
|
+
"pi-traversal-",
|
|
20
|
+
"pi-source-mode-",
|
|
21
|
+
"pi-source-missing-",
|
|
22
|
+
"pi-nonprefixed-",
|
|
23
|
+
"pi-default-cond-",
|
|
24
|
+
"pi-array-exports-",
|
|
25
|
+
"pi-extensionless-",
|
|
26
|
+
"pi-tsx-source-",
|
|
27
|
+
"pi-guidance-",
|
|
28
|
+
"pi-system-v2-",
|
|
29
|
+
"pi-no-guidance-",
|
|
30
|
+
"pi-guidance-dedup-",
|
|
31
|
+
"pi-noreduce-",
|
|
32
|
+
"pi-language-baseline-",
|
|
33
|
+
"pi-language-unset-",
|
|
34
|
+
"pi-language-set-",
|
|
35
|
+
"pi-a1-guidance-",
|
|
36
|
+
"pi-prompt-epoch-",
|
|
37
|
+
"pi-embedding-bootstrap-",
|
|
38
|
+
"pi-embedding-home-",
|
|
39
|
+
"magic-context-pi-latch-test-",
|
|
40
|
+
"magic-context-pi-index-test-",
|
|
41
|
+
"mc-test-temp-dir-helper-",
|
|
42
|
+
] as const;
|
|
43
|
+
|
|
44
|
+
export type TestTempDirPrefix = (typeof TEST_TEMP_DIR_PREFIXES)[number];
|
|
45
|
+
|
|
46
|
+
type AfterAll = (callback: () => void) => void;
|
|
47
|
+
type SweepOptions = {
|
|
48
|
+
tempDir?: string;
|
|
49
|
+
nowMs?: number;
|
|
50
|
+
staleAgeMs?: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const registeredTempDirs = new Set<string>();
|
|
54
|
+
let lifecycleCleanupInstalled = false;
|
|
55
|
+
|
|
56
|
+
function hasRecognizedPrefix(name: string): boolean {
|
|
57
|
+
return TEST_TEMP_DIR_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isRegisteredTempDir(directory: string): boolean {
|
|
61
|
+
const resolvedDirectory = resolve(directory);
|
|
62
|
+
return (
|
|
63
|
+
registeredTempDirs.has(resolvedDirectory) &&
|
|
64
|
+
dirname(resolvedDirectory) === resolve(tmpdir()) &&
|
|
65
|
+
hasRecognizedPrefix(basename(resolvedDirectory))
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates a test-owned root under the system temp directory. The returned cleanup
|
|
71
|
+
* only removes roots made by this module, so an accidental path cannot delete an
|
|
72
|
+
* unrelated temp directory.
|
|
73
|
+
*/
|
|
74
|
+
export function createTestTempDir(
|
|
75
|
+
prefix: TestTempDirPrefix,
|
|
76
|
+
nameSuffix = "",
|
|
77
|
+
): { dir: string; cleanup: () => void } {
|
|
78
|
+
const dir = resolve(mkdtempSync(join(tmpdir(), `${prefix}${nameSuffix}`)));
|
|
79
|
+
registeredTempDirs.add(dir);
|
|
80
|
+
return { dir, cleanup: () => cleanupTestTempDir(dir) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Removes one registered test root and forgets it even when best-effort removal fails. */
|
|
84
|
+
export function cleanupTestTempDir(directory: string): void {
|
|
85
|
+
const resolvedDirectory = resolve(directory);
|
|
86
|
+
if (!isRegisteredTempDir(resolvedDirectory)) return;
|
|
87
|
+
|
|
88
|
+
registeredTempDirs.delete(resolvedDirectory);
|
|
89
|
+
try {
|
|
90
|
+
rmSync(resolvedDirectory, {
|
|
91
|
+
recursive: true,
|
|
92
|
+
force: true,
|
|
93
|
+
maxRetries: 10,
|
|
94
|
+
retryDelay: 100,
|
|
95
|
+
});
|
|
96
|
+
} catch {
|
|
97
|
+
// A process can still hold a file open on Windows. The next startup sweep retries it.
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Removes every root registered by this process. Safe to call more than once. */
|
|
102
|
+
export function cleanupRegisteredTestTempDirs(): void {
|
|
103
|
+
for (const directory of [...registeredTempDirs]) cleanupTestTempDir(directory);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Runs a callback with a fresh root and removes that root even when the callback throws.
|
|
108
|
+
* This keeps small fixture builders from forgetting a failure-path cleanup.
|
|
109
|
+
*/
|
|
110
|
+
export function withTestTempDir<T>(
|
|
111
|
+
prefix: TestTempDirPrefix,
|
|
112
|
+
callback: (directory: string) => T,
|
|
113
|
+
): T {
|
|
114
|
+
const { dir, cleanup } = createTestTempDir(prefix);
|
|
115
|
+
try {
|
|
116
|
+
return callback(dir);
|
|
117
|
+
} finally {
|
|
118
|
+
cleanup();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Installs both Bun's normal suite cleanup and an exit fallback for aborted runs.
|
|
124
|
+
* The callback is passed in so this utility remains usable from the test preload
|
|
125
|
+
* without making production code import bun:test.
|
|
126
|
+
*/
|
|
127
|
+
export function installTestTempDirCleanup(afterAll: AfterAll): void {
|
|
128
|
+
if (lifecycleCleanupInstalled) return;
|
|
129
|
+
lifecycleCleanupInstalled = true;
|
|
130
|
+
afterAll(cleanupRegisteredTestTempDirs);
|
|
131
|
+
process.once("exit", cleanupRegisteredTestTempDirs);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Removes only old, recognized test roots from one temp directory. The scan does
|
|
136
|
+
* one directory read, ignores non-directories, and leaves fresh roots and every
|
|
137
|
+
* unrecognized name alone so concurrently running tools stay isolated.
|
|
138
|
+
*/
|
|
139
|
+
export function sweepStaleTestTempDirs({
|
|
140
|
+
tempDir = tmpdir(),
|
|
141
|
+
nowMs = Date.now(),
|
|
142
|
+
staleAgeMs = STALE_TEMP_DIR_AGE_MS,
|
|
143
|
+
}: SweepOptions = {}): string[] {
|
|
144
|
+
let entries: Array<{ isDirectory(): boolean; name: string }>;
|
|
145
|
+
try {
|
|
146
|
+
entries = readdirSync(tempDir, { withFileTypes: true });
|
|
147
|
+
} catch {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const removed: string[] = [];
|
|
152
|
+
for (const entry of entries) {
|
|
153
|
+
if (!entry.isDirectory() || !hasRecognizedPrefix(entry.name)) continue;
|
|
154
|
+
|
|
155
|
+
const directory = join(tempDir, entry.name);
|
|
156
|
+
try {
|
|
157
|
+
if (nowMs - statSync(directory).mtimeMs <= staleAgeMs) continue;
|
|
158
|
+
rmSync(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
|
159
|
+
removed.push(directory);
|
|
160
|
+
} catch {
|
|
161
|
+
// Temp cleanup is best-effort; a later test run retries busy directories.
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return removed;
|
|
165
|
+
}
|
|
@@ -326,6 +326,15 @@ export function readWindowOverlayFile(
|
|
|
326
326
|
|
|
327
327
|
/** Set the user-tier overlay path. Undefined restores the Fusiform data-dir default. */
|
|
328
328
|
export function setWindowOverlayPath(path: string | undefined): void {
|
|
329
|
+
// Runtime hooks may resolve unchanged config more than once. Preserve the
|
|
330
|
+
// process snapshot unless the configured path actually changes, so an
|
|
331
|
+
// external same-path rewrite cannot alter geometry between turns.
|
|
332
|
+
if (configuredOverlayPath === path) return;
|
|
333
|
+
reloadWindowOverlay(path);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Start a new overlay snapshot at an explicit plugin/extension reload boundary. */
|
|
337
|
+
export function reloadWindowOverlay(path: string | undefined): void {
|
|
329
338
|
configuredOverlayPath = path;
|
|
330
339
|
loadedOverlayPath = undefined;
|
|
331
340
|
loadedOverlay = undefined;
|
|
File without changes
|