@cortexkit/opencode-magic-context 0.43.1 → 0.43.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.
Files changed (51) hide show
  1. package/dist/{conflict-warning-hook-956fkedc.js → conflict-warning-hook-hyk9y29x.js} +3 -3
  2. package/dist/features/magic-context/dreamer/classify.d.ts +12 -0
  3. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  4. package/dist/features/magic-context/store-generation-rebase.d.ts +62 -1
  5. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  6. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  7. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +6 -0
  8. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  9. package/dist/hooks/magic-context/compartment-runner-validation.d.ts +7 -0
  10. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  11. package/dist/hooks/magic-context/ctx-reduce-availability.d.ts +60 -8
  12. package/dist/hooks/magic-context/ctx-reduce-availability.d.ts.map +1 -1
  13. package/dist/hooks/magic-context/hook.d.ts +3 -1
  14. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  15. package/dist/hooks/magic-context/system-prompt-hash.d.ts +9 -0
  16. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  19. package/dist/{index-kpmmr8s0.js → index-6j8th2hd.js} +1 -1
  20. package/dist/{index-v8qr6tt2.js → index-bmzt6xgy.js} +2 -2
  21. package/dist/{index-7wpwr2e2.js → index-g6hpfkqa.js} +250 -36
  22. package/dist/{index-yc81txp4.js → index-jgnag7sa.js} +1 -1
  23. package/dist/{index-1gtwrdc4.js → index-pa67brzn.js} +2 -2
  24. package/dist/{index-j7cnyvq1.js → index-tdrv6nd0.js} +1 -1
  25. package/dist/index.js +238 -28
  26. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  27. package/dist/{read-session-chunk-z7fv0qjv.js → read-session-chunk-53a7qbrh.js} +2 -2
  28. package/dist/{recomp-orchestrator-r00aa5t3.js → recomp-orchestrator-adsgqgse.js} +4 -4
  29. package/dist/{send-session-notification-3warjyjp.js → send-session-notification-e28r4xx2.js} +2 -2
  30. package/dist/shared/opencode-db-path.d.ts.map +1 -1
  31. package/dist/shared/test-fake-executable.d.ts +38 -0
  32. package/dist/shared/test-fake-executable.d.ts.map +1 -0
  33. package/dist/shared/user-facing-codes.d.ts +10 -0
  34. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  35. package/dist/v2/hooks/context.d.ts.map +1 -1
  36. package/dist/v2/hooks/refusal.d.ts +9 -1
  37. package/dist/v2/hooks/refusal.d.ts.map +1 -1
  38. package/dist/v2/hooks/restore-rows.d.ts +29 -0
  39. package/dist/v2/hooks/restore-rows.d.ts.map +1 -0
  40. package/dist/v2/hooks/update-check.d.ts +8 -0
  41. package/dist/v2/hooks/update-check.d.ts.map +1 -1
  42. package/dist/v2/server.js +470 -61
  43. package/dist/v2/store-reader.d.ts +8 -0
  44. package/dist/v2/store-reader.d.ts.map +1 -1
  45. package/dist/{wrapup-orchestrator-y0bs7t5a.js → wrapup-orchestrator-8xzbpvm8.js} +5 -5
  46. package/package.json +1 -1
  47. package/src/shared/opencode-db-path.test.ts +18 -0
  48. package/src/shared/opencode-db-path.ts +5 -2
  49. package/src/shared/test-fake-executable.test.ts +54 -0
  50. package/src/shared/test-fake-executable.ts +110 -0
  51. package/src/shared/user-facing-codes.ts +11 -0
@@ -112,6 +112,14 @@ export declare class V2StoreReader {
112
112
  messageIdOrdinals(sessionID: string, fromOrdinal: number, toOrdinal: number): Map<string, number>;
113
113
  messageOrdinalPage(sessionID: string, after: V2MessageOrdinalAnchor | null, limit: number): V2MessageOrdinalEntry[];
114
114
  range(sessionID: string, after: number, through: number): StoreRow[];
115
+ /**
116
+ * One stamp per row with `after < seq <= through`, keyed by seq, built without
117
+ * decoding any row: the row id, its update time and the byte length of its data.
118
+ * A row deleted, added, or rewritten in place to a different size or with a new
119
+ * update time changes its stamp; comparing stamps row by row, not an aggregate,
120
+ * means two such changes cannot cancel out.
121
+ */
122
+ spanRowStamps(sessionID: string, after: number, through: number): Map<number, string>;
115
123
  /** Conversational rows at or before `throughSeq`, newest first. */
116
124
  rawRowsThrough(sessionID: string, throughSeq: number, limit: number): StoreRow[];
117
125
  sequenceForId(sessionID: string, id: string | null | undefined): number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"store-reader.d.ts","sourceRoot":"","sources":["../../src/v2/store-reader.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,SAAW,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAGD,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,OAAO,GACP,OAAO,GACP,WAAW,GACX,YAAY,GACZ,MAAM,CAAC;AAEb,eAAO,MAAM,iBAAiB,yEAOa,CAAC;AAI5C,eAAO,MAAM,mBAAmB,QAkBP,CAAC;AAC1B,MAAM,WAAW,WAAW;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IACjD,KAAK,CA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AAE;IAItC,OAAO,CAAC,GAAG;CAcd"}
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  runManagedWrapup2
3
- } from "./index-1gtwrdc4.js";
4
- import"./index-7wpwr2e2.js";
3
+ } from "./index-pa67brzn.js";
4
+ import"./index-g6hpfkqa.js";
5
5
  import"./index-sd3egckz.js";
6
6
  import"./index-0ccmyzbj.js";
7
- import"./index-yc81txp4.js";
8
- import"./index-j7cnyvq1.js";
7
+ import"./index-jgnag7sa.js";
8
+ import"./index-tdrv6nd0.js";
9
9
  import"./index-y5145x8k.js";
10
- import"./index-v8qr6tt2.js";
10
+ import"./index-bmzt6xgy.js";
11
11
  import"./index-9r1cbh9e.js";
12
12
  import"./index-jdxxq8cz.js";
13
13
  import"./index-febg06dy.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.43.1",
3
+ "version": "0.43.2",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -197,6 +197,24 @@ describe("resolveOpenCodeDbPath", () => {
197
197
  });
198
198
  });
199
199
 
200
+ it("takes an absolute v2 OPENCODE_DB as is and resolves a relative one against the data dir", () => {
201
+ // OpenCode 2 resolves the database with `path.resolve(data, OPENCODE_DB)`;
202
+ // verified against the 2.0.15 binary's `opencode debug paths db`.
203
+ const { dataHome, openCodeDir } = useDataHome();
204
+ const absolute = join(dataHome, "elsewhere", "custom.db");
205
+ expect(resolveOpenCodeDbPath("v2", { dataHome, env: { OPENCODE_DB: absolute } })).toEqual({
206
+ path: absolute,
207
+ source: "OPENCODE_DB",
208
+ channel: null,
209
+ });
210
+ expect(
211
+ resolveOpenCodeDbPath("v2", { dataHome, env: { OPENCODE_DB: "nested/../rel.db" } }),
212
+ ).toEqual({ path: join(openCodeDir, "rel.db"), source: "OPENCODE_DB", channel: null });
213
+ expect(resolveOpenCodeDbPath("v2", { dataHome, env: { OPENCODE_DB: ":memory:" } })).toEqual(
214
+ { path: ":memory:", source: "OPENCODE_DB", channel: null },
215
+ );
216
+ });
217
+
200
218
  it("detects store generations and refuses a mismatched schema before reading", () => {
201
219
  const { openCodeDir } = useDataHome();
202
220
  const v1Path = join(openCodeDir, "v1.db");
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readdirSync, statSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
- import { isAbsolute, join } from "node:path";
3
+ import { isAbsolute, join, resolve } from "node:path";
4
4
 
5
5
  export type OpenCodeDbPathSource = "OPENCODE_DB" | "channel" | "default" | "discovered";
6
6
  export type OpenCodeHostGeneration = "v1" | "v2";
@@ -185,7 +185,10 @@ function resolveV2Fresh(
185
185
  const filename = sourceOpenCodeDatabaseFilename("v2", channel, env);
186
186
  const explicit = env.OPENCODE_DB !== undefined;
187
187
  return {
188
- path: filename === ":memory:" ? filename : join(dataDir, filename),
188
+ // OpenCode 2 uses `path.resolve(data, filename)`: an absolute
189
+ // OPENCODE_DB is taken as is and a relative one is resolved against
190
+ // the data directory. `join` would nest an absolute value under it.
191
+ path: filename === ":memory:" ? filename : resolve(dataDir, filename),
189
192
  source: explicit ? "OPENCODE_DB" : env.OPENCODE_CHANNEL ? "channel" : "default",
190
193
  channel: explicit ? null : channel,
191
194
  };
@@ -0,0 +1,54 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { readdirSync, readFileSync, statSync } from "node:fs";
3
+ import { basename, dirname } from "node:path";
4
+ import { testExecutableRoot, writeTestExecutable } from "./test-fake-executable";
5
+
6
+ // Fixed contents on purpose: a random body would create a new executable on
7
+ // every run, which is exactly what the helper exists to avoid.
8
+ const STUB = "#!/bin/sh\necho test-fake-executable-helper\n";
9
+
10
+ describe("writeTestExecutable", () => {
11
+ it("places the stub at a content-addressed path under the shared root", () => {
12
+ const path = writeTestExecutable("helper-stub", STUB);
13
+
14
+ expect(basename(path)).toBe("helper-stub");
15
+ expect(dirname(dirname(path))).toBe(testExecutableRoot());
16
+ expect(basename(dirname(path))).toMatch(/^[0-9a-f]{16}$/);
17
+ expect(readFileSync(path, "utf8")).toBe(STUB);
18
+ if (process.platform !== "win32") expect(statSync(path).mode & 0o111).not.toBe(0);
19
+ expect(readdirSync(dirname(path))).toEqual(["helper-stub"]);
20
+ });
21
+
22
+ it("reuses the existing file instead of rewriting it", () => {
23
+ const first = writeTestExecutable("helper-stub", STUB);
24
+ const before = statSync(first);
25
+ const second = writeTestExecutable("helper-stub", STUB);
26
+ const after = statSync(second);
27
+
28
+ expect(second).toBe(first);
29
+ expect(after.ino).toBe(before.ino);
30
+ expect(after.mtimeMs).toBe(before.mtimeMs);
31
+ });
32
+
33
+ it("gives different content or a different name a different directory", () => {
34
+ const base = writeTestExecutable("helper-stub", STUB);
35
+ const otherContent = writeTestExecutable("helper-stub", `${STUB}exit 0\n`);
36
+ const otherName = writeTestExecutable("helper-stub-2", STUB);
37
+
38
+ expect(new Set([dirname(base), dirname(otherContent), dirname(otherName)]).size).toBe(3);
39
+ });
40
+
41
+ it("keeps a directory-name prefix verbatim before the hash", () => {
42
+ const prefix = "mc %MC_TEST% & shim ";
43
+ const path = writeTestExecutable("helper-stub", STUB, { dirPrefix: prefix });
44
+ const dirName = basename(dirname(path));
45
+
46
+ expect(dirName.startsWith(prefix)).toBe(true);
47
+ expect(dirName.slice(prefix.length)).toMatch(/^[0-9a-f]{16}$/);
48
+ });
49
+
50
+ it("rejects names that would escape the stub directory", () => {
51
+ expect(() => writeTestExecutable("../escape", STUB)).toThrow();
52
+ expect(() => writeTestExecutable("stub", STUB, { dirPrefix: "a/b" })).toThrow();
53
+ });
54
+ });
@@ -0,0 +1,110 @@
1
+ import { createHash, randomBytes } from "node:crypto";
2
+ import {
3
+ chmodSync,
4
+ mkdirSync,
5
+ readFileSync,
6
+ renameSync,
7
+ rmSync,
8
+ statSync,
9
+ writeFileSync,
10
+ } from "node:fs";
11
+ import { tmpdir } from "node:os";
12
+ import { join } from "node:path";
13
+
14
+ /**
15
+ * Test-only helper for fake executables (shell stubs standing in for opencode,
16
+ * sqlite3, bun, ...).
17
+ *
18
+ * macOS runs a malware assessment the first time any new executable file is
19
+ * launched. Writing a fresh stub into a fresh temp directory for every test
20
+ * case therefore triggers one assessment per case per run. Instead, each
21
+ * distinct stub lives at a fixed, content-addressed path and is written only
22
+ * once; later tests and later runs reuse the same file.
23
+ *
24
+ * Callers must never delete these files in per-test cleanup, and must never
25
+ * modify one in place: a test that needs a stub to "change" between steps asks
26
+ * for a second stub with different content, which lands at a different path.
27
+ */
28
+
29
+ /** Directory name under the OS temp dir that holds every shared fake executable. */
30
+ export const TEST_EXECUTABLE_ROOT_NAME = "magic-context-test-bin";
31
+
32
+ export function testExecutableRoot(): string {
33
+ return join(tmpdir(), TEST_EXECUTABLE_ROOT_NAME);
34
+ }
35
+
36
+ export interface WriteTestExecutableOptions {
37
+ /**
38
+ * Kept verbatim in front of the hash in the directory name. Use it only when
39
+ * the test depends on the directory name itself, for example to exercise
40
+ * quoting of spaces or shell metacharacters in the executable's path.
41
+ */
42
+ dirPrefix?: string;
43
+ }
44
+
45
+ function assertSinglePathSegment(label: string, value: string, allowEmpty: boolean): void {
46
+ if ((!allowEmpty && value.length === 0) || value === "." || value === "..") {
47
+ throw new Error(`writeTestExecutable: invalid ${label} ${JSON.stringify(value)}`);
48
+ }
49
+ if (value.includes("/") || value.includes("\\") || value.includes("\0")) {
50
+ throw new Error(`writeTestExecutable: ${label} must be a single path segment`);
51
+ }
52
+ }
53
+
54
+ function hasExpectedContent(path: string, content: string): boolean {
55
+ try {
56
+ if (readFileSync(path, "utf8") !== content) return false;
57
+ // Windows has no executable bit, so content alone decides there.
58
+ return process.platform === "win32" || (statSync(path).mode & 0o111) !== 0;
59
+ } catch {
60
+ return false;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Returns the path of an executable named `name` whose bytes are `content`,
66
+ * creating it only when no identical file exists yet. The path is
67
+ * `<tmpdir>/magic-context-test-bin/<dirPrefix><first 16 hex of sha256(name, content)>/<name>`,
68
+ * so each directory holds exactly one executable and pointing PATH at it
69
+ * exposes nothing else.
70
+ *
71
+ * The file is written to a unique temporary name in the same directory and
72
+ * then renamed into place, so concurrent test processes never observe a
73
+ * half-written stub.
74
+ */
75
+ export function writeTestExecutable(
76
+ name: string,
77
+ content: string,
78
+ options: WriteTestExecutableOptions = {},
79
+ ): string {
80
+ const dirPrefix = options.dirPrefix ?? "";
81
+ assertSinglePathSegment("name", name, false);
82
+ assertSinglePathSegment("dirPrefix", dirPrefix, true);
83
+
84
+ // The NUL separator keeps ("ab", "c") and ("a", "bc") from sharing a hash.
85
+ const hash = createHash("sha256")
86
+ .update(name)
87
+ .update("\0")
88
+ .update(content)
89
+ .digest("hex")
90
+ .slice(0, 16);
91
+ const dir = join(testExecutableRoot(), `${dirPrefix}${hash}`);
92
+ const target = join(dir, name);
93
+ if (hasExpectedContent(target, content)) return target;
94
+
95
+ mkdirSync(dir, { recursive: true });
96
+ const staging = join(dir, `.${name}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
97
+ try {
98
+ writeFileSync(staging, content, { mode: 0o755 });
99
+ // The process umask can strip bits from the create mode; set them explicitly.
100
+ chmodSync(staging, 0o755);
101
+ renameSync(staging, target);
102
+ } catch (error) {
103
+ rmSync(staging, { force: true });
104
+ // Another process may have won the race with identical bytes (Windows
105
+ // refuses to rename over a file that is currently open).
106
+ if (hasExpectedContent(target, content)) return target;
107
+ throw error;
108
+ }
109
+ return target;
110
+ }
@@ -12,6 +12,12 @@ export const USER_FACING_FAILURES = {
12
12
  sentence: "Some finished background sessions could not be removed from this host.",
13
13
  action: "They are removed automatically the next time Magic Context runs inside a registered OpenCode service.",
14
14
  },
15
+ historian_saved_history_misaligned: {
16
+ code: "MC-H03",
17
+ sentence:
18
+ "History compression is paused because this session's saved summaries no longer line up with its messages.",
19
+ action: "Run /ctx-recomp to rebuild them.",
20
+ },
15
21
  recomp_unavailable: {
16
22
  code: "MC-R01",
17
23
  sentence: "History compression could not be rebuilt.",
@@ -183,6 +189,11 @@ export const USER_FACING_FAILURES = {
183
189
  sentence: "History compression is paused while the engine syncs.",
184
190
  action: "Retry in a moment.",
185
191
  },
192
+ history_compression_needs_message: {
193
+ code: "MC-C12",
194
+ sentence: "History compression has not seen this session since Magic Context reconnected.",
195
+ action: "Send a message in this session first, then run /ctx-wrapup again.",
196
+ },
186
197
  context_service_unavailable: {
187
198
  code: "MC-C10",
188
199
  sentence: "Magic Context is temporarily unavailable.",