@cortexkit/opencode-magic-context 0.35.1 → 0.36.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/README.md +9 -5
- package/dist/agents/permissions.d.ts +17 -0
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/{announcement-gms2nhya.js → announcement-6c1g4es4.js} +2 -2
- 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-p2pmhvn7.js → conflict-warning-hook-dw9fs934.js} +4 -4
- package/dist/{derive-budgets-9crp0cvd.js → derive-budgets-88mxk2w1.js} +3 -3
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts +2 -0
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/condition-compiler.d.ts +37 -0
- package/dist/features/magic-context/smart-notes/condition-compiler.d.ts.map +1 -0
- package/dist/features/magic-context/smart-notes/runner.d.ts +1 -0
- package/dist/features/magic-context/smart-notes/runner.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/storage.d.ts +3 -3
- package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-notes.d.ts +13 -0
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -1
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +3 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +15 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +6 -0
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +9 -0
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-fallback-context-limit.d.ts +10 -0
- package/dist/hooks/magic-context/raw-fallback-context-limit.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +7 -2
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/{index-8aaadh98.js → index-37rt2bka.js} +2 -2
- package/dist/{index-fkyamz2w.js → index-3nfgbsp4.js} +99 -56
- package/dist/{index-w0nygb4p.js → index-3tnkymva.js} +2 -2
- package/dist/{index-k1esqfwk.js → index-f1tnb3vm.js} +1 -1
- package/dist/{index-kvrcg31b.js → index-mmrhhk9a.js} +8 -1
- package/dist/{index-h5zjfesc.js → index-nsx2n9eg.js} +3 -3
- package/dist/{index-dmr999a2.js → index-qf20mv7e.js} +1 -1
- package/dist/{index-73xz0247.js → index-tsgs7td8.js} +1 -1
- package/dist/{index-ry8rh8cv.js → index-wgvxkqpx.js} +5 -4
- package/dist/{index-dpdnjawy.js → index-z8v31d85.js} +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +781 -116
- package/dist/plugin/dream-timer.d.ts +1 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- 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/messages-transform.d.ts +5 -5
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-29f4rqax.js → recomp-orchestrator-7wbbvf87.js} +7 -7
- package/dist/{safe-notification-target-q9jk5n44.js → safe-notification-target-c11fdda2.js} +3 -3
- package/dist/{send-session-notification-sr5g06hz.js → send-session-notification-bgtf4853.js} +4 -4
- package/dist/shared/data-path.d.ts +27 -0
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/harness-provider-map.d.ts +23 -20
- package/dist/shared/harness-provider-map.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +15 -2
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/{storage-meta-session-ev8b55a9.js → storage-meta-session-kh5egr11.js} +4 -4
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/agents/permissions.ts +87 -0
- package/src/config/compaction-accessor-guard.test.ts +9 -4
- package/src/config/schema/magic-context.test.ts +2 -0
- package/src/config/schema/magic-context.ts +15 -0
- package/src/shared/data-path.test.ts +65 -9
- package/src/shared/data-path.ts +66 -1
- package/src/shared/harness-provider-map.test.ts +42 -1
- package/src/shared/harness-provider-map.ts +48 -26
- package/src/shared/prompt-surface-runtime.ts +13 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dream-timer.d.ts","sourceRoot":"","sources":["../../src/plugin/dream-timer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AASvF,OAAO,EAEH,KAAK,wBAAwB,EAChC,MAAM,8DAA8D,CAAC;AAOtE,OAAO,KAAK,EACR,aAAa,EACb,iBAAiB,EACpB,MAAM,iDAAiD,CAAC;AA4BzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAS7C;;;;;GAKG;AACH,UAAU,mBAAmB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,aA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AAI,EAAE,mBAAmB,GAC1B,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,CAoEnC"}
|
|
@@ -32,6 +32,9 @@ export declare function buildMagicContextHookConfig(pluginConfig: MagicContextPl
|
|
|
32
32
|
language?: string;
|
|
33
33
|
historian?: import("../../config/schema/magic-context").HistorianConfig;
|
|
34
34
|
dreamer?: import("../../config/schema/magic-context").DreamerConfig;
|
|
35
|
+
smart_notes: {
|
|
36
|
+
retina_handoff: boolean;
|
|
37
|
+
};
|
|
35
38
|
cache_ttl: string | {
|
|
36
39
|
default: string;
|
|
37
40
|
[modelKey: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,wBAAwB;;;;;;;;;mBACxD,CAAC;aAA2B,CAAC;aAQnD,CAPC;eAA8B,CAAA
|
|
1
|
+
{"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,KAAK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@@ -17,9 +17,9 @@ type MagicContextTransformHooks = {
|
|
|
17
17
|
*
|
|
18
18
|
* Error handling is tiered:
|
|
19
19
|
*
|
|
20
|
-
* - **FailClosedBlockingError / EmergencyFailClosedError
|
|
21
|
-
* aborts. Rethrown so the TUI surfaces the message and the turn does not
|
|
22
|
-
* silently fall through to native compaction.
|
|
20
|
+
* - **FailClosedBlockingError / EmergencyFailClosedError / RawFallbackContextLimitError**:
|
|
21
|
+
* Intentional loud aborts. Rethrown so the TUI surfaces the message and the turn does not
|
|
22
|
+
* silently fall through to native compaction or a provider-rejected raw prompt.
|
|
23
23
|
*
|
|
24
24
|
* - **SQLITE_BUSY**: Transient, expected from concurrent plugin processes
|
|
25
25
|
* (second OpenCode instance, long dreamer/historian child session, slow
|
|
@@ -39,8 +39,8 @@ type MagicContextTransformHooks = {
|
|
|
39
39
|
* 3. Return with messages unmodified for this pass.
|
|
40
40
|
*
|
|
41
41
|
* Ordinary transform failures are not rethrown because OpenCode's Effect pipeline
|
|
42
|
-
* turns thrown errors into user-visible prompt failures. FailClosedBlockingError
|
|
43
|
-
* and
|
|
42
|
+
* turns thrown errors into user-visible prompt failures. FailClosedBlockingError,
|
|
43
|
+
* EmergencyFailClosedError, and RawFallbackContextLimitError are intentional exceptions.
|
|
44
44
|
* We accept degraded behavior (no injection / no drops this turn) rather than
|
|
45
45
|
* blocking the user for ordinary bugs — but deterministic inoperability must
|
|
46
46
|
* block loudly when fail_closed_blocking is on.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-transform.d.ts","sourceRoot":"","sources":["../../src/plugin/messages-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,oBAAoB,EAI5B,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"messages-transform.d.ts","sourceRoot":"","sources":["../../src/plugin/messages-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,oBAAoB,EAI5B,MAAM,6CAA6C,CAAC;AAqBrD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14
14
|
import"./index-td9depx5.js";
|
|
15
|
-
import"./index-
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
15
|
+
import"./index-nsx2n9eg.js";
|
|
16
|
+
import"./index-z8v31d85.js";
|
|
17
|
+
import"./index-3tnkymva.js";
|
|
18
18
|
import"./index-0c9dmw9m.js";
|
|
19
19
|
import"./index-d62ypazr.js";
|
|
20
|
-
import"./index-
|
|
21
|
-
import"./index-
|
|
20
|
+
import"./index-f1tnb3vm.js";
|
|
21
|
+
import"./index-mmrhhk9a.js";
|
|
22
22
|
import"./index-wckvcay0.js";
|
|
23
23
|
export {
|
|
24
24
|
setRecompTerminal,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isDefaultSessionTitle,
|
|
3
3
|
waitForSafeNotificationTarget
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
4
|
+
} from "./index-tsgs7td8.js";
|
|
5
|
+
import"./index-f1tnb3vm.js";
|
|
6
|
+
import"./index-mmrhhk9a.js";
|
|
7
7
|
import"./index-wckvcay0.js";
|
|
8
8
|
export {
|
|
9
9
|
waitForSafeNotificationTarget,
|
package/dist/{send-session-notification-sr5g06hz.js → send-session-notification-bgtf4853.js}
RENAMED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
flushIgnoredMessages,
|
|
6
6
|
sendIgnoredMessage,
|
|
7
7
|
sendUserPrompt
|
|
8
|
-
} from "./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
8
|
+
} from "./index-nsx2n9eg.js";
|
|
9
|
+
import"./index-3tnkymva.js";
|
|
10
|
+
import"./index-f1tnb3vm.js";
|
|
11
|
+
import"./index-mmrhhk9a.js";
|
|
12
12
|
import"./index-wckvcay0.js";
|
|
13
13
|
export {
|
|
14
14
|
sendUserPrompt,
|
|
@@ -115,6 +115,33 @@ export declare function getOpenCodeStorageDir(): string;
|
|
|
115
115
|
* - Future cross-harness session migration
|
|
116
116
|
*
|
|
117
117
|
* Layout: <XDG_DATA_HOME>/cortexkit/magic-context/
|
|
118
|
+
*
|
|
119
|
+
* TEST-ISOLATION GUARD. `openDatabase()` has been guarded in
|
|
120
|
+
* `resolveDatabasePath()` since the 2026-06-01 (v26) and 2026-06-19 (v41)
|
|
121
|
+
* incidents, in which unisolated tests migrated the user's REAL shared DB.
|
|
122
|
+
* Every OTHER caller bypassed that guard — notably the CLI doctors, which
|
|
123
|
+
* build `join(getMagicContextStorageDir(), "context.db")` themselves and run
|
|
124
|
+
* `PRAGMA integrity_check` against it. A test that deletes XDG_DATA_HOME to
|
|
125
|
+
* exercise path fallbacks cannot restore isolation by setting
|
|
126
|
+
* `process.env.HOME`: bun caches `os.homedir()` at startup, so `getDataDir()`
|
|
127
|
+
* still resolves to the real home. MAGIC_CONTEXT_TEST_DATA_DIR — set by
|
|
128
|
+
* `packages/plugin/test-preload.ts`, and restored by any test that touches it
|
|
129
|
+
* — is honored here, so the preload's "cannot be defeated" guarantee holds for
|
|
130
|
+
* every caller, not just `openDatabase()`. It is never set in production.
|
|
131
|
+
*
|
|
132
|
+
* CWD-INDEPENDENT BACKSTOP. The preload only runs when `bun test`'s CWD has a
|
|
133
|
+
* bunfig wiring `[test] preload`. A run from a dir WITHOUT that wiring (a
|
|
134
|
+
* package missing its bunfig, or a brand-new one) executes every *.test.ts with
|
|
135
|
+
* NO preload, and this resolver would hand back the REAL shared path — which is
|
|
136
|
+
* how the live DB reached v41. Bun sets NODE_ENV=test for EVERY `bun test`
|
|
137
|
+
* regardless of CWD, and production never sets it, so that window redirects to
|
|
138
|
+
* a memoized throwaway dir instead. It lives here rather than in
|
|
139
|
+
* `resolveDatabasePath()` so direct callers (the CLI doctors' own
|
|
140
|
+
* `PRAGMA integrity_check`, announcements, the models.dev cache) are covered
|
|
141
|
+
* too — they never go through the DB resolver.
|
|
142
|
+
*
|
|
143
|
+
* XDG_DATA_HOME still wins over both: a test that manages its own data home is
|
|
144
|
+
* already controlled, and production has no test dir set at all.
|
|
118
145
|
*/
|
|
119
146
|
export declare function getMagicContextStorageDir(): string;
|
|
120
147
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-path.d.ts","sourceRoot":"","sources":["../../src/shared/data-path.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAOhF;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAErF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAkBxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED
|
|
1
|
+
{"version":3,"file":"data-path.d.ts","sourceRoot":"","sources":["../../src/shared/data-path.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAOhF;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAErF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAkBxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAWlD;AA+BD;;;;;;GAMG;AACH,wBAAgB,uCAAuC,IAAI,MAAM,CAEhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
|
|
@@ -2,33 +2,32 @@
|
|
|
2
2
|
* Provider-id translation between the canonical (OpenCode) form stored in the
|
|
3
3
|
* shared magic-context config and Pi's harness-native provider ids.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Provider IDs are a harness boundary, not a database identity. Shared config
|
|
6
|
+
* always stores the canonical OpenCode form. Each non-OpenCode harness owns an
|
|
7
|
+
* explicit pair of edge transforms:
|
|
8
8
|
*
|
|
9
|
-
* canonical (OpenCode) Pi
|
|
10
|
-
* --------------------
|
|
9
|
+
* canonical (OpenCode) Pi / OMP selector
|
|
10
|
+
* -------------------- -----------------
|
|
11
11
|
* openai/<model> openai-codex/<model>
|
|
12
12
|
* google/<model> google-antigravity/<model>
|
|
13
13
|
* anthropic/<model> anthropic/<model> (same; every other provider too)
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* should win. Pi therefore starts with the preferred auth-plugin form at the
|
|
19
|
-
* spawn boundary and subagent-runner may retry once with the untranslated
|
|
20
|
-
* canonical form when that form reports missing credentials. The runner caches
|
|
21
|
-
* the winning form per provider prefix in memory only; setup writes still use
|
|
22
|
-
* the reverse mapping below so configs remain canonical.
|
|
15
|
+
* Pi and OMP currently expose the same two subscription-provider aliases, but
|
|
16
|
+
* their exported functions remain distinct deliberately. A future OMP catalog
|
|
17
|
+
* rename must not silently change plain-Pi behavior (or vice versa).
|
|
23
18
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
19
|
+
* The mapping is intentionally not a one-to-one provider identity. Both
|
|
20
|
+
* harnesses also expose plain `openai` and `google` providers for direct API
|
|
21
|
+
* keys, while the canonical prefix does not record whether a subscription or
|
|
22
|
+
* API-key backend should win. The runtime starts with the preferred
|
|
23
|
+
* subscription form and subagent-runner may retry once with the untranslated
|
|
24
|
+
* canonical form when that form reports missing credentials.
|
|
30
25
|
*
|
|
31
|
-
*
|
|
26
|
+
* Only the provider prefix before the first slash is translated. Model IDs,
|
|
27
|
+
* including nested IDs containing more slashes, are preserved byte-for-byte.
|
|
28
|
+
* Scoped or otherwise unknown provider prefixes are identities.
|
|
29
|
+
*
|
|
30
|
+
* OpenCode needs no translation because canonical is its native form.
|
|
32
31
|
*/
|
|
33
32
|
/** Pi-native `provider/model` -> canonical (OpenCode). Identity when unmapped.
|
|
34
33
|
* Used by the Pi setup wizard so configs it writes stay OpenCode-readable. */
|
|
@@ -37,4 +36,8 @@ export declare function piModelRefToCanonical(ref: string): string;
|
|
|
37
36
|
* Pi. Idempotent: normalizes any Pi-form prefix back to canonical first, so it
|
|
38
37
|
* is safe on a config that already holds Pi-form ids (hand-edited or pre-fix). */
|
|
39
38
|
export declare function resolveModelRefForPi(ref: string): string;
|
|
39
|
+
/** OMP-native selector -> canonical shared-config model reference. */
|
|
40
|
+
export declare function ompModelRefToCanonical(ref: string): string;
|
|
41
|
+
/** Canonical shared-config model reference -> OMP-native selector. */
|
|
42
|
+
export declare function resolveModelRefForOmp(ref: string): string;
|
|
40
43
|
//# sourceMappingURL=harness-provider-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness-provider-map.d.ts","sourceRoot":"","sources":["../../src/shared/harness-provider-map.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"harness-provider-map.d.ts","sourceRoot":"","sources":["../../src/shared/harness-provider-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAoCH;+EAC+E;AAC/E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;mFAEmF;AACnF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { type ConfigHarness } from "../config/migrate-config-location";
|
|
2
2
|
import { type PromptSurfaceConfig, type PromptSurfacePreset } from "./prompt-surface";
|
|
3
|
+
/**
|
|
4
|
+
* The single source of truth for the ctx_* tools exposed by the prompt surface.
|
|
5
|
+
* Consumers derive their registries and light-description catalogs from this list
|
|
6
|
+
* so adding a tool cannot silently skip one prompt-surface integration point.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ACTIVE_TOOL_IDS: readonly ["ctx_reduce", "ctx_expand", "ctx_note", "ctx_memory", "ctx_search"];
|
|
9
|
+
/** @deprecated Use ACTIVE_TOOL_IDS. Kept as an alias for existing consumers. */
|
|
3
10
|
export declare const PROMPT_SURFACE_TOOL_IDS: readonly ["ctx_reduce", "ctx_expand", "ctx_note", "ctx_memory", "ctx_search"];
|
|
4
|
-
export type PromptSurfaceToolId = (typeof
|
|
5
|
-
export declare const LIGHT_TOOL_DESCRIPTIONS:
|
|
11
|
+
export type PromptSurfaceToolId = (typeof ACTIVE_TOOL_IDS)[number];
|
|
12
|
+
export declare const LIGHT_TOOL_DESCRIPTIONS: {
|
|
13
|
+
readonly ctx_reduce: "For ctx_reduce users, mark spent §N§ outputs discardable; release is QUEUED, not immediate, so content stays visible until space is needed. Newest tags stay protected until they age out. Released content becomes a placeholder; recover it only by rerunning the source or recovery tool, so mark only genuinely finished material. Mark analyzed, redundant, persisted, or merely confirmatory outputs; keep user messages, unresolved errors, unextracted evidence, and exact wording. NEVER blanket-mark a large range: review every tag first.";
|
|
14
|
+
readonly ctx_expand: "For ctx_expand users, recover compacted conversation by passing a session-history heading's inclusive start/end ordinals. Results are raw [N] U:/A: transcript capped near 15K tokens; oversized ranges return the head and a continuation. Use verbose=true to list each message ordinal, part previews, and tool-output sizes; use message=N for one complete stored message and its tool exchanges. NEVER expand ranges after the last compartment because that live tail is already visible.";
|
|
15
|
+
readonly ctx_note: "For ctx_note users, write saves, read lists, update changes, and dismiss retires future session notes; surface_condition creates a smart note. For smart notes, NEVER use a condition tied to this conversation or an unobservable future action because the background checker can inspect only external GitHub, disk, git, or web signals.";
|
|
16
|
+
readonly ctx_memory: "For ctx_memory users, write one standalone durable fact with category and content; update one ID, archive one or more IDs, merge two or more IDs, or get one to twenty numeric IDs. get reads memories in every status; list remains dreamer-only, so primary agents must NEVER assume bulk-list access.";
|
|
17
|
+
readonly ctx_search: "For ctx_search users, retrieve only hidden recall: memories not already in <project-memory>, compacted messages outside the live tail, commits, and notes. Omit sources for broad search; select memory, message, git_commit, or note to target a source, or pass memory IDs to bypass text search. Message hits continue through ctx_expand.";
|
|
18
|
+
};
|
|
6
19
|
/**
|
|
7
20
|
* Preserve the existing full-preset hash exactly while giving other presets a
|
|
8
21
|
* distinct semantic cache identity, including during any future asset fallback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-surface-runtime.d.ts","sourceRoot":"","sources":["../../src/shared/prompt-surface-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,KAAK,aAAa,EAGrB,MAAM,mCAAmC,CAAC;AAS3C,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAE3B,MAAM,kBAAkB,CAAC;AAK1B,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"prompt-surface-runtime.d.ts","sourceRoot":"","sources":["../../src/shared/prompt-surface-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,KAAK,aAAa,EAGrB,MAAM,mCAAmC,CAAC;AAS3C,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAE3B,MAAM,kBAAkB,CAAC;AAK1B;;;;GAIG;AACH,eAAO,MAAM,eAAe,+EAMlB,CAAC;AAEX,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,+EAAkB,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,eAAO,MAAM,uBAAuB;;;;;;CAM8B,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,yBAAyB,CACrC,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,mBAA4B,GACrC,MAAM,CAIR;AAID,MAAM,WAAW,8BAA8B;IAC3C,sCAAsC;IACtC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,qFAAqF;IACrF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,kCAAkC;IAC/C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC;CACvE;AAED,MAAM,WAAW,oBAAoB;IACjC,mBAAmB,EAAE,CACjB,MAAM,EAAE,mBAAmB,GAAG,SAAS,KACtC,kCAAkC,CAAC;IACxC,eAAe,EAAE,CACb,MAAM,EAAE,mBAAmB,GAAG,SAAS,EACvC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAC3B,8BAA8B,CAAC;CACvC;AAED,MAAM,WAAW,iCAAiC;IAC9C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAwBD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACtC,OAAO,EAAE,iCAAiC,GAC3C,oBAAoB,CAkGtB;AAQD,uFAAuF;AACvF,wBAAgB,qCAAqC,CAAC,OAAO,EAAE,oBAAoB,GAAG;IAClF,OAAO,EAAE,CACL,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,GAAG,SAAS,EACvC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAC3B,8BAA8B,CAAC;IACpC,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC,CAkBA"}
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
markSessionCleanupPending,
|
|
6
6
|
retryPendingSessionCleanups,
|
|
7
7
|
updateSessionMeta
|
|
8
|
-
} from "./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
8
|
+
} from "./index-z8v31d85.js";
|
|
9
|
+
import"./index-3tnkymva.js";
|
|
10
|
+
import"./index-f1tnb3vm.js";
|
|
11
|
+
import"./index-mmrhhk9a.js";
|
|
12
12
|
import"./index-wckvcay0.js";
|
|
13
13
|
export {
|
|
14
14
|
updateSessionMeta,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-note/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-note/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAmBhE,OAAO,KAAK,EAAuB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAK7F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC/D,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACvC;AAmbD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAIxF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-magic-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"README.md"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "bun run build:tui && rm -f dist/index.js dist/*-*.js && bun build src/index.ts --outdir dist --target node --format esm --splitting --external @opencode-ai/plugin --external @huggingface/transformers --external onnxruntime-web --external bun:sqlite --external node:sqlite && tsc --emitDeclarationOnly",
|
|
38
|
+
"build": "tsc -p ../retina-local-fs/tsconfig.build.json && bun run build:tui && rm -f dist/index.js dist/*-*.js && bun build src/index.ts --outdir dist --target node --format esm --splitting --external @opencode-ai/plugin --external @huggingface/transformers --external onnxruntime-web --external bun:sqlite --external node:sqlite && tsc --emitDeclarationOnly",
|
|
39
39
|
"build:tui": "bun scripts/build-tui.ts",
|
|
40
40
|
"check:tui-compiled": "bun run build:tui && git diff --exit-code -- src/tui-compiled && test -z \"$(git status --porcelain -- src/tui-compiled)\"",
|
|
41
|
-
"typecheck": "tsc --noEmit && tsc -p tsconfig.scripts.json",
|
|
41
|
+
"typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit && tsc -p tsconfig.scripts.json",
|
|
42
42
|
"test": "bun test",
|
|
43
43
|
"lint": "biome check .",
|
|
44
44
|
"lint:fix": "biome check --write .",
|
|
@@ -109,6 +109,93 @@ export function buildAllowOnlyPermission(
|
|
|
109
109
|
return permission;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
type PermissionAction = "ask" | "allow" | "deny";
|
|
113
|
+
|
|
114
|
+
function isPermissionAction(value: unknown): value is PermissionAction {
|
|
115
|
+
return value === "ask" || value === "allow" || value === "deny";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function isPermissionMap(value: unknown): value is Record<string, unknown> {
|
|
119
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Add final `permission.task` denies for Magic Context's internal workers.
|
|
124
|
+
*
|
|
125
|
+
* OpenCode accepts either a whole-permission action or a pattern map for
|
|
126
|
+
* `permission.task`; its evaluator uses the last matching rule. Normalize the
|
|
127
|
+
* whole-permission form, retain every unrelated user rule, then append our
|
|
128
|
+
* exact agent-id denies after both the user's task patterns and any `*` rule.
|
|
129
|
+
*/
|
|
130
|
+
export function denyTaskRoutingToAgents(
|
|
131
|
+
permission: unknown,
|
|
132
|
+
internalAgentIds: readonly string[],
|
|
133
|
+
): Record<string, unknown> {
|
|
134
|
+
const configured = isPermissionAction(permission)
|
|
135
|
+
? { "*": permission }
|
|
136
|
+
: isPermissionMap(permission)
|
|
137
|
+
? permission
|
|
138
|
+
: {};
|
|
139
|
+
const { task, ...otherPermissions } = configured;
|
|
140
|
+
const configuredTask = isPermissionAction(task)
|
|
141
|
+
? { "*": task }
|
|
142
|
+
: isPermissionMap(task)
|
|
143
|
+
? task
|
|
144
|
+
: {};
|
|
145
|
+
const internalAgentIdSet = new Set(internalAgentIds);
|
|
146
|
+
const retainedTask = Object.fromEntries(
|
|
147
|
+
Object.entries(configuredTask).filter(([agentId]) => !internalAgentIdSet.has(agentId)),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
...otherPermissions,
|
|
152
|
+
task: {
|
|
153
|
+
...retainedTask,
|
|
154
|
+
...Object.fromEntries(internalAgentIds.map((agentId) => [agentId, "deny"])),
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const BUILTIN_TASK_CALLER_IDS = ["build", "plan"] as const;
|
|
160
|
+
|
|
161
|
+
function isTaskRoutingCaller(agentId: string, config: Record<string, unknown>): boolean {
|
|
162
|
+
const mode = config.mode;
|
|
163
|
+
// OpenCode compatibility:
|
|
164
|
+
// Only strictly-primary callers receive explicit Task routing rules.
|
|
165
|
+
// Agents that may execute as Task children are intentionally left untouched,
|
|
166
|
+
// because explicit task permissions can alter OpenCode's default anti-nesting
|
|
167
|
+
// behavior in the currently supported permission model.
|
|
168
|
+
if (mode === "primary") return true;
|
|
169
|
+
if (mode === "subagent" || mode === "all") return false;
|
|
170
|
+
return agentId === "build" || agentId === "plan";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Apply Task routing denies only to agents that can act as Task callers.
|
|
175
|
+
*
|
|
176
|
+
* A top-level permission rule is merged into every OpenCode agent. Adding one
|
|
177
|
+
* there would suppress the Task tool's default deny for ordinary subagents, so
|
|
178
|
+
* seed only the built-in interactive callers and configured primary agents.
|
|
179
|
+
*/
|
|
180
|
+
export function denyTaskRoutingToCallerAgents(
|
|
181
|
+
agentConfigs: Record<string, Record<string, unknown>>,
|
|
182
|
+
internalAgentIds: readonly string[],
|
|
183
|
+
): Record<string, Record<string, unknown>> {
|
|
184
|
+
const result = { ...agentConfigs };
|
|
185
|
+
const candidateIds = new Set([...BUILTIN_TASK_CALLER_IDS, ...Object.keys(agentConfigs)]);
|
|
186
|
+
|
|
187
|
+
for (const agentId of candidateIds) {
|
|
188
|
+
const agentConfig = agentConfigs[agentId] ?? {};
|
|
189
|
+
if (!isTaskRoutingCaller(agentId, agentConfig)) continue;
|
|
190
|
+
result[agentId] = {
|
|
191
|
+
...agentConfig,
|
|
192
|
+
permission: denyTaskRoutingToAgents(agentConfig.permission, internalAgentIds),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
|
|
112
199
|
/**
|
|
113
200
|
* Tools the historian + historian-editor + compressor agents need.
|
|
114
201
|
*
|
|
@@ -27,6 +27,11 @@ const ALLOWED_READERS = new Set<string>([
|
|
|
27
27
|
// The strip operates on a raw Record<string, unknown> by key name, not on
|
|
28
28
|
// a parsed MagicContextConfig.
|
|
29
29
|
"packages/plugin/src/config/project-security.ts",
|
|
30
|
+
// OMP's own setting key appears only as an external CLI string literal;
|
|
31
|
+
// these files never read Magic Context's parsed compaction config.
|
|
32
|
+
"packages/cli/src/lib/omp-helpers.ts",
|
|
33
|
+
"packages/cli/src/commands/setup-omp.ts",
|
|
34
|
+
"packages/cli/src/commands/doctor-omp.ts",
|
|
30
35
|
]);
|
|
31
36
|
|
|
32
37
|
function sourceFiles(directory: string): string[] {
|
|
@@ -42,10 +47,10 @@ function sourceFiles(directory: string): string[] {
|
|
|
42
47
|
return result;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
//
|
|
46
|
-
// `compaction?.enabled
|
|
47
|
-
//
|
|
48
|
-
//
|
|
50
|
+
// Conservatively matches the textual token `compaction.enabled` or
|
|
51
|
+
// `compaction?.enabled`, including string literals. False positives are
|
|
52
|
+
// allow-listed only after confirming they do not read Magic Context's parsed
|
|
53
|
+
// config path.
|
|
49
54
|
// It does NOT match the DB column `compaction_mode_record`, the accessor name
|
|
50
55
|
// `isCompactionEnabled`, or the schema's own `.object({ enabled: ... })`.
|
|
51
56
|
const COMPACTION_ENABLED_READ = /\bcompaction\??\s*\.\s*enabled\b(?!_)/;
|
|
@@ -18,6 +18,7 @@ describe("MagicContextConfigSchema", () => {
|
|
|
18
18
|
fail_closed_blocking: true,
|
|
19
19
|
transform_mode: "ts",
|
|
20
20
|
storage: { enforce_private_permissions: true },
|
|
21
|
+
smart_notes: { retina_handoff: false },
|
|
21
22
|
cache_ttl: "5m",
|
|
22
23
|
prompt_surface: { default: "full" },
|
|
23
24
|
execute_threshold_percentage: 65,
|
|
@@ -108,6 +109,7 @@ describe("MagicContextConfigSchema", () => {
|
|
|
108
109
|
overlay: false,
|
|
109
110
|
},
|
|
110
111
|
smart_drops: false,
|
|
112
|
+
smart_notes: { retina_handoff: false },
|
|
111
113
|
shadow_embedding: {
|
|
112
114
|
enabled: false,
|
|
113
115
|
},
|
|
@@ -470,6 +470,10 @@ export interface MagicContextConfig {
|
|
|
470
470
|
language?: string;
|
|
471
471
|
historian?: HistorianConfig;
|
|
472
472
|
dreamer?: DreamerConfig;
|
|
473
|
+
smart_notes: {
|
|
474
|
+
/** Flip ownership of authoring-compiled conditions from dreamer to retina. */
|
|
475
|
+
retina_handoff: boolean;
|
|
476
|
+
};
|
|
473
477
|
cache_ttl: string | { default: string; [modelKey: string]: string };
|
|
474
478
|
/** Preset routing for guidance and provider-visible prompt surfaces. */
|
|
475
479
|
prompt_surface: PromptSurfaceConfig;
|
|
@@ -688,6 +692,17 @@ export const MagicContextConfigSchema = z
|
|
|
688
692
|
dreamer: DreamerConfigSchema.optional().describe(
|
|
689
693
|
"Dreamer agent + scheduling configuration (model, fallback_models, disable, schedule, tasks, etc.)",
|
|
690
694
|
),
|
|
695
|
+
smart_notes: z
|
|
696
|
+
.object({
|
|
697
|
+
retina_handoff: z
|
|
698
|
+
.boolean()
|
|
699
|
+
.default(false)
|
|
700
|
+
.describe(
|
|
701
|
+
"When true, dreamer skips smart notes whose surface conditions compiled to retina provider configs at authoring time. Default false keeps both paths active until the retina consumer is deployed.",
|
|
702
|
+
),
|
|
703
|
+
})
|
|
704
|
+
.default({ retina_handoff: false })
|
|
705
|
+
.describe("Smart-note ownership transition controls."),
|
|
691
706
|
cache_ttl: z
|
|
692
707
|
.union([z.string(), z.object({ default: z.string() }).catchall(z.string())])
|
|
693
708
|
.default("5m")
|
|
@@ -20,6 +20,8 @@ const savedEnv = {
|
|
|
20
20
|
XDG_DATA_HOME: process.env.XDG_DATA_HOME,
|
|
21
21
|
LOCALAPPDATA: process.env.LOCALAPPDATA,
|
|
22
22
|
MAGIC_CONTEXT_LOG_PATH: process.env.MAGIC_CONTEXT_LOG_PATH,
|
|
23
|
+
MAGIC_CONTEXT_TEST_DATA_DIR: process.env.MAGIC_CONTEXT_TEST_DATA_DIR,
|
|
24
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
describe("data-path", () => {
|
|
@@ -36,14 +38,14 @@ describe("data-path", () => {
|
|
|
36
38
|
});
|
|
37
39
|
|
|
38
40
|
afterEach(() => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
process.env
|
|
46
|
-
|
|
41
|
+
// Restore-or-delete every var this suite touches. Several tests lift a
|
|
42
|
+
// guard (NODE_ENV, MAGIC_CONTEXT_TEST_DATA_DIR) to assert production
|
|
43
|
+
// shape, so a restore that skips the unset case would leak state into
|
|
44
|
+
// the next test and make results order-dependent.
|
|
45
|
+
for (const [key, value] of Object.entries(savedEnv)) {
|
|
46
|
+
if (value !== undefined) process.env[key] = value;
|
|
47
|
+
else delete process.env[key];
|
|
48
|
+
}
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
test("getCacheDir falls back to <homedir>/.cache when XDG_CACHE_HOME is unset (all platforms)", () => {
|
|
@@ -89,8 +91,62 @@ describe("data-path", () => {
|
|
|
89
91
|
// Cross-harness shared path: both OpenCode and Pi plugins read/write here,
|
|
90
92
|
// unlike the legacy opencode/storage/plugin/magic-context location which
|
|
91
93
|
// was OpenCode-specific. See ARCHITECTURE_DECISIONS memory for rationale.
|
|
94
|
+
// Production shape, so both test-isolation guards (the preload's data
|
|
95
|
+
// dir and the NODE_ENV backstop bun sets for every `bun test`) are
|
|
96
|
+
// lifted for the duration of this assertion.
|
|
97
|
+
const savedTestDir = process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
|
|
98
|
+
const savedNodeEnv = process.env.NODE_ENV;
|
|
99
|
+
delete process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
|
|
100
|
+
delete process.env.NODE_ENV;
|
|
101
|
+
try {
|
|
102
|
+
expect(getMagicContextStorageDir()).toBe(
|
|
103
|
+
path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context"),
|
|
104
|
+
);
|
|
105
|
+
} finally {
|
|
106
|
+
if (savedTestDir !== undefined) process.env.MAGIC_CONTEXT_TEST_DATA_DIR = savedTestDir;
|
|
107
|
+
if (savedNodeEnv !== undefined) process.env.NODE_ENV = savedNodeEnv;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("getMagicContextStorageDir backstops to a temp dir under NODE_ENV=test with no guard set", () => {
|
|
112
|
+
// CWD-independent backstop: a `bun test` from a dir whose bunfig has no
|
|
113
|
+
// `[test] preload` runs every suite with neither guard env var set. The
|
|
114
|
+
// DB resolver used to own this branch, so direct callers of this helper
|
|
115
|
+
// (the CLI doctors' own PRAGMA integrity_check) still reached the real
|
|
116
|
+
// shared DB. Memoized, so repeated calls must agree — openDatabase()
|
|
117
|
+
// caches by path.
|
|
118
|
+
const savedTestDir = process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
|
|
119
|
+
delete process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
|
|
120
|
+
process.env.NODE_ENV = "test";
|
|
121
|
+
try {
|
|
122
|
+
const resolved = getMagicContextStorageDir();
|
|
123
|
+
expect(resolved).not.toContain(path.join(os.homedir(), ".local", "share"));
|
|
124
|
+
expect(resolved.endsWith(path.join("cortexkit", "magic-context"))).toBe(true);
|
|
125
|
+
expect(getMagicContextStorageDir()).toBe(resolved);
|
|
126
|
+
} finally {
|
|
127
|
+
if (savedTestDir !== undefined) process.env.MAGIC_CONTEXT_TEST_DATA_DIR = savedTestDir;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("getMagicContextStorageDir honors MAGIC_CONTEXT_TEST_DATA_DIR when XDG_DATA_HOME is unset", () => {
|
|
132
|
+
// The hole this closes: a test that deletes XDG_DATA_HOME to exercise
|
|
133
|
+
// path fallbacks used to resolve to the user's REAL shared storage,
|
|
134
|
+
// because bun caches os.homedir() and a mutated process.env.HOME cannot
|
|
135
|
+
// move getDataDir(). Callers that build their own context.db path (the
|
|
136
|
+
// CLI doctors) then ran integrity checks against production data.
|
|
137
|
+
process.env.MAGIC_CONTEXT_TEST_DATA_DIR = "/tmp/mc-test-isolation";
|
|
92
138
|
expect(getMagicContextStorageDir()).toBe(
|
|
93
|
-
path.join(
|
|
139
|
+
path.join("/tmp/mc-test-isolation", "cortexkit", "magic-context"),
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("getMagicContextStorageDir prefers XDG_DATA_HOME over MAGIC_CONTEXT_TEST_DATA_DIR", () => {
|
|
144
|
+
// A test managing its own per-test data home is already controlled, and
|
|
145
|
+
// several suites depend on that dir being honored.
|
|
146
|
+
process.env.MAGIC_CONTEXT_TEST_DATA_DIR = "/tmp/mc-test-isolation";
|
|
147
|
+
process.env.XDG_DATA_HOME = "/tmp/custom-data";
|
|
148
|
+
expect(getMagicContextStorageDir()).toBe(
|
|
149
|
+
path.join("/tmp/custom-data", "cortexkit", "magic-context"),
|
|
94
150
|
);
|
|
95
151
|
});
|
|
96
152
|
|