@cortexkit/opencode-magic-context 0.43.0 → 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.
- package/dist/{announcement-8mgn61fw.js → announcement-1a8bvswd.js} +2 -1
- package/dist/{conflict-warning-hook-t2vb0wnx.js → conflict-warning-hook-hyk9y29x.js} +6 -4
- package/dist/{derive-budgets-0sg5vp61.js → derive-budgets-b8ybssh9.js} +3 -2
- package/dist/features/magic-context/dreamer/classify.d.ts +12 -0
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +7 -4
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +3 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts +3 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +4 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts +62 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
- package/dist/hooks/auto-update-checker/checker.d.ts +1 -0
- package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +6 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +7 -0
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts +60 -8
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +3 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +2 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts +1 -0
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +9 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-8w1skpnm.js → index-0ccmyzbj.js} +6 -6
- package/dist/{index-ntbmt6rq.js → index-4b30nf6z.js} +1 -1
- package/dist/{index-rpz2me0v.js → index-6j8th2hd.js} +2 -2
- package/dist/{index-99sfbrrf.js → index-6w9p73jz.js} +1 -1
- package/dist/{index-4ftb5hcq.js → index-6z9g64js.js} +7 -1
- package/dist/{index-9skq8m9y.js → index-9r1cbh9e.js} +1 -1
- package/dist/{index-ykg9sdzz.js → index-bmzt6xgy.js} +3 -3
- package/dist/{safe-notification-target-fepvcbsj.js → index-febg06dy.js} +6 -7
- package/dist/{index-d0dh7v0f.js → index-g6hpfkqa.js} +361 -118
- package/dist/{index-rvwvdq59.js → index-jgnag7sa.js} +38 -4
- package/dist/{index-w2ety11c.js → index-pa67brzn.js} +3 -3
- package/dist/{index-ygwdyntq.js → index-tdrv6nd0.js} +6 -4
- package/dist/{index-qp20p2py.js → index-wgzyeyf5.js} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +801 -240
- package/dist/{message-time-backfill-gzjer78y.js → message-time-backfill-0ccvyk9n.js} +3 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{read-session-chunk-ec3jkvhg.js → read-session-chunk-53a7qbrh.js} +4 -3
- package/dist/{recomp-orchestrator-6akjp11f.js → recomp-orchestrator-adsgqgse.js} +9 -7
- package/dist/safe-notification-target-vrkjrbgb.js +10 -0
- package/dist/{send-session-notification-f6gwkesy.js → send-session-notification-e28r4xx2.js} +7 -3
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/opencode-db-path.d.ts.map +1 -1
- package/dist/shared/test-fake-executable.d.ts +38 -0
- package/dist/shared/test-fake-executable.d.ts.map +1 -0
- package/dist/shared/test-temp-dir.d.ts +1 -1
- package/dist/shared/test-temp-dir.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +10 -0
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/{task-config-ex4nt0q0.js → task-config-mgf5nsh3.js} +1 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +6 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/refusal.d.ts +9 -1
- package/dist/v2/hooks/refusal.d.ts.map +1 -1
- package/dist/v2/hooks/restore-rows.d.ts +29 -0
- package/dist/v2/hooks/restore-rows.d.ts.map +1 -0
- package/dist/v2/hooks/types.d.ts +1 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/hooks/update-check.d.ts +8 -0
- package/dist/v2/hooks/update-check.d.ts.map +1 -1
- package/dist/v2/host-service.d.ts +1 -1
- package/dist/v2/host-service.d.ts.map +1 -1
- package/dist/v2/server.js +1171 -366
- package/dist/v2/store-reader.d.ts +8 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/wrapup-orchestrator-8xzbpvm8.js +18 -0
- package/package.json +2 -1
- package/src/features/magic-context/dreamer/task-registry.ts +1 -1
- package/src/shared/data-path.ts +6 -6
- package/src/shared/model-suggestion-retry.test.ts +43 -0
- package/src/shared/model-suggestion-retry.ts +17 -0
- package/src/shared/opencode-db-path.test.ts +18 -0
- package/src/shared/opencode-db-path.ts +5 -2
- package/src/shared/test-fake-executable.test.ts +54 -0
- package/src/shared/test-fake-executable.ts +110 -0
- package/src/shared/test-temp-dir.ts +3 -0
- package/src/shared/user-facing-codes.ts +11 -0
- package/dist/wrapup-orchestrator-5akc87gr.js +0 -16
|
@@ -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,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AE,SAAS,MAAM,EAAE,GAAG,MAAM;IAevE,OAAO,CAAC,kBAAkB;IAe1B,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS;IAMvE,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS;IAM9E,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE;IAO3D,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOvD,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAOzC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS;IAWrE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS;IAW3D,8EAA8E;IAC9E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IASrC;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IAItC,OAAO,CAAC,GAAG;CAcd"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runManagedWrapup2
|
|
3
|
+
} from "./index-pa67brzn.js";
|
|
4
|
+
import"./index-g6hpfkqa.js";
|
|
5
|
+
import"./index-sd3egckz.js";
|
|
6
|
+
import"./index-0ccmyzbj.js";
|
|
7
|
+
import"./index-jgnag7sa.js";
|
|
8
|
+
import"./index-tdrv6nd0.js";
|
|
9
|
+
import"./index-y5145x8k.js";
|
|
10
|
+
import"./index-bmzt6xgy.js";
|
|
11
|
+
import"./index-9r1cbh9e.js";
|
|
12
|
+
import"./index-jdxxq8cz.js";
|
|
13
|
+
import"./index-febg06dy.js";
|
|
14
|
+
import"./index-wgzyeyf5.js";
|
|
15
|
+
import"./index-6z9g64js.js";
|
|
16
|
+
export {
|
|
17
|
+
runManagedWrapup2 as runManagedWrapup
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-magic-context",
|
|
3
|
-
"version": "0.43.
|
|
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",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@opencode/plugin": "2.0.15",
|
|
77
|
+
"@opencode/ai": "2.0.15",
|
|
77
78
|
"@opencode/cli": "2.0.15",
|
|
78
79
|
"@opencode/client": "2.0.15",
|
|
79
80
|
"effect": "4.0.0-rc.112",
|
|
@@ -89,7 +89,7 @@ export const DREAM_TASK_CAPABILITIES: Record<DreamTaskName, DreamTaskCapability>
|
|
|
89
89
|
"maintain-docs": {
|
|
90
90
|
requiresTools: true,
|
|
91
91
|
transport: "tool-loop",
|
|
92
|
-
toolLoopPurpose: "needs
|
|
92
|
+
toolLoopPurpose: "needs read-only file tools to investigate documentation corrections",
|
|
93
93
|
},
|
|
94
94
|
// The evaluator is a no-tool compiler plus a no-tool confirmation prompt; the
|
|
95
95
|
// generated check runs in the local capability sandbox, never as model tools.
|
package/src/shared/data-path.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync, mkdirSync,
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { getHarness, type HarnessId } from "./harness";
|
|
5
|
+
import { createTestTempDir } from "./test-temp-dir";
|
|
5
6
|
|
|
6
7
|
export function getDataDir(): string {
|
|
7
8
|
return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
|
|
@@ -262,11 +263,10 @@ let testBackstopWarned = false;
|
|
|
262
263
|
*/
|
|
263
264
|
function getTestBackstopStorageDir(): string {
|
|
264
265
|
if (!testBackstopStorageDir) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
);
|
|
266
|
+
// Registered so the test preload's exit cleanup removes it; the preload's
|
|
267
|
+
// stale sweep also recognizes the prefix.
|
|
268
|
+
const { dir } = createTestTempDir("mc-test-db-backstop-");
|
|
269
|
+
testBackstopStorageDir = path.join(dir, "cortexkit", "magic-context");
|
|
270
270
|
}
|
|
271
271
|
if (!testBackstopWarned) {
|
|
272
272
|
testBackstopWarned = true;
|
|
@@ -393,6 +393,49 @@ describe("promptSyncWithModelSuggestionRetry", () => {
|
|
|
393
393
|
});
|
|
394
394
|
|
|
395
395
|
describe("promptSyncWithValidatedOutputRetry", () => {
|
|
396
|
+
test("surfaces a host-recorded assistant refusal even when the row has no text", async () => {
|
|
397
|
+
const client = createClient(mock(async () => ({})));
|
|
398
|
+
const refusal =
|
|
399
|
+
"UnknownError: custody accounts exhausted: provider=synthetic accounts=main:cooldown";
|
|
400
|
+
|
|
401
|
+
await expect(
|
|
402
|
+
promptSyncWithValidatedOutputRetry(client, createArgs(), {
|
|
403
|
+
fetchOutput: async () => [
|
|
404
|
+
{
|
|
405
|
+
info: {
|
|
406
|
+
role: "assistant",
|
|
407
|
+
time: { created: 1 },
|
|
408
|
+
finish: "stop",
|
|
409
|
+
tokens: { output: 0 },
|
|
410
|
+
},
|
|
411
|
+
parts: [],
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
info: { role: "assistant", time: { created: 2 }, error: refusal },
|
|
415
|
+
parts: [],
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
validateOutput: () => {
|
|
419
|
+
throw new Error("empty_completion");
|
|
420
|
+
},
|
|
421
|
+
}),
|
|
422
|
+
).rejects.toMatchObject({
|
|
423
|
+
message: `Host recorded assistant error: ${refusal}`,
|
|
424
|
+
transient: true,
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test("keeps a real empty completion without an assistant error on the normal validation path", async () => {
|
|
429
|
+
const client = createClient(mock(async () => ({})));
|
|
430
|
+
await expect(
|
|
431
|
+
promptSyncWithValidatedOutputRetry(client, createArgs(), {
|
|
432
|
+
fetchOutput: async () => [{ info: { role: "assistant" }, parts: [] }],
|
|
433
|
+
validateOutput: () => {
|
|
434
|
+
throw new Error("empty_completion");
|
|
435
|
+
},
|
|
436
|
+
}),
|
|
437
|
+
).rejects.toThrow("empty_completion");
|
|
438
|
+
});
|
|
396
439
|
test("valid first model returns without trying fallbacks", async () => {
|
|
397
440
|
const prompt = mock(async () => ({}));
|
|
398
441
|
const messages = mock(async () => "primary-output");
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { createOpencodeClient } from "@opencode-ai/sdk";
|
|
2
2
|
|
|
3
3
|
import { detectOverflow } from "../features/magic-context/overflow-detection";
|
|
4
|
+
import {
|
|
5
|
+
extractLatestAssistantFailure,
|
|
6
|
+
extractLatestAssistantText,
|
|
7
|
+
} from "./assistant-message-extractor";
|
|
4
8
|
import { log } from "./logger";
|
|
5
9
|
import type { ModelInput } from "./model-resolution";
|
|
6
10
|
import { sanitizeDiagnosticText } from "./redaction";
|
|
@@ -599,6 +603,19 @@ async function attemptAndValidate<TOutput, TValidated>(
|
|
|
599
603
|
}
|
|
600
604
|
|
|
601
605
|
try {
|
|
606
|
+
if (!extractLatestAssistantText(output)) {
|
|
607
|
+
const assistantFailure = extractLatestAssistantFailure(output);
|
|
608
|
+
if (assistantFailure) {
|
|
609
|
+
const error = new Error(
|
|
610
|
+
`Host recorded assistant error: ${String(assistantFailure.error)}`,
|
|
611
|
+
);
|
|
612
|
+
Object.assign(error, {
|
|
613
|
+
name: "DreamerProviderOutputFailureError",
|
|
614
|
+
transient: true,
|
|
615
|
+
});
|
|
616
|
+
throw error;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
602
619
|
const validated = await options.validateOutput(output, attempt);
|
|
603
620
|
return { output, validated, attempt };
|
|
604
621
|
} catch (error) {
|
|
@@ -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
|
-
|
|
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
|
+
}
|
|
@@ -39,6 +39,9 @@ export const TEST_TEMP_DIR_PREFIXES = [
|
|
|
39
39
|
"magic-context-pi-latch-test-",
|
|
40
40
|
"magic-context-pi-index-test-",
|
|
41
41
|
"mc-test-temp-dir-helper-",
|
|
42
|
+
"mc-v2-surface-",
|
|
43
|
+
// Created by the NODE_ENV=test storage backstop in data-path.ts.
|
|
44
|
+
"mc-test-db-backstop-",
|
|
42
45
|
] as const;
|
|
43
46
|
|
|
44
47
|
export type TestTempDirPrefix = (typeof TEST_TEMP_DIR_PREFIXES)[number];
|
|
@@ -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.",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runManagedWrapup2
|
|
3
|
-
} from "./index-w2ety11c.js";
|
|
4
|
-
import"./index-d0dh7v0f.js";
|
|
5
|
-
import"./index-sd3egckz.js";
|
|
6
|
-
import"./index-8w1skpnm.js";
|
|
7
|
-
import"./index-rvwvdq59.js";
|
|
8
|
-
import"./index-ygwdyntq.js";
|
|
9
|
-
import"./index-y5145x8k.js";
|
|
10
|
-
import"./index-ykg9sdzz.js";
|
|
11
|
-
import"./index-9skq8m9y.js";
|
|
12
|
-
import"./index-jdxxq8cz.js";
|
|
13
|
-
import"./index-qp20p2py.js";
|
|
14
|
-
export {
|
|
15
|
-
runManagedWrapup2 as runManagedWrapup
|
|
16
|
-
};
|