@cortexkit/opencode-magic-context 0.43.0 → 0.43.1

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 (68) hide show
  1. package/dist/{announcement-8mgn61fw.js → announcement-1a8bvswd.js} +2 -1
  2. package/dist/{conflict-warning-hook-t2vb0wnx.js → conflict-warning-hook-956fkedc.js} +6 -4
  3. package/dist/{derive-budgets-0sg5vp61.js → derive-budgets-b8ybssh9.js} +3 -2
  4. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +7 -4
  5. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  6. package/dist/features/magic-context/dreamer/map-memories.d.ts +3 -1
  7. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  8. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +3 -1
  9. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  10. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  11. package/dist/features/magic-context/dreamer/verify.d.ts +4 -1
  12. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  13. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  14. package/dist/hooks/auto-update-checker/checker.d.ts +1 -0
  15. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/compartment-trigger.d.ts +2 -1
  17. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/lkg-slot.d.ts +1 -0
  20. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/rust-mode-transform.d.ts +2 -0
  22. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/send-session-notification.d.ts +1 -0
  24. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  26. package/dist/{index-8w1skpnm.js → index-0ccmyzbj.js} +6 -6
  27. package/dist/{index-w2ety11c.js → index-1gtwrdc4.js} +3 -3
  28. package/dist/{index-ntbmt6rq.js → index-4b30nf6z.js} +1 -1
  29. package/dist/{index-99sfbrrf.js → index-6w9p73jz.js} +1 -1
  30. package/dist/{index-4ftb5hcq.js → index-6z9g64js.js} +7 -1
  31. package/dist/{index-d0dh7v0f.js → index-7wpwr2e2.js} +115 -86
  32. package/dist/{index-9skq8m9y.js → index-9r1cbh9e.js} +1 -1
  33. package/dist/{safe-notification-target-fepvcbsj.js → index-febg06dy.js} +6 -7
  34. package/dist/{index-ygwdyntq.js → index-j7cnyvq1.js} +6 -4
  35. package/dist/{index-rpz2me0v.js → index-kpmmr8s0.js} +2 -2
  36. package/dist/{index-ykg9sdzz.js → index-v8qr6tt2.js} +1 -1
  37. package/dist/{index-qp20p2py.js → index-wgzyeyf5.js} +1 -1
  38. package/dist/{index-rvwvdq59.js → index-yc81txp4.js} +38 -4
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +577 -226
  41. package/dist/{message-time-backfill-gzjer78y.js → message-time-backfill-0ccvyk9n.js} +3 -2
  42. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  43. package/dist/{read-session-chunk-ec3jkvhg.js → read-session-chunk-z7fv0qjv.js} +4 -3
  44. package/dist/{recomp-orchestrator-6akjp11f.js → recomp-orchestrator-r00aa5t3.js} +9 -7
  45. package/dist/safe-notification-target-vrkjrbgb.js +10 -0
  46. package/dist/{send-session-notification-f6gwkesy.js → send-session-notification-3warjyjp.js} +7 -3
  47. package/dist/shared/data-path.d.ts.map +1 -1
  48. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  49. package/dist/shared/test-temp-dir.d.ts +1 -1
  50. package/dist/shared/test-temp-dir.d.ts.map +1 -1
  51. package/dist/{task-config-ex4nt0q0.js → task-config-mgf5nsh3.js} +1 -1
  52. package/dist/v2/hidden-completion.d.ts.map +1 -1
  53. package/dist/v2/hooks/hidden-child.d.ts +6 -0
  54. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  55. package/dist/v2/hooks/payload.d.ts.map +1 -1
  56. package/dist/v2/hooks/types.d.ts +1 -0
  57. package/dist/v2/hooks/types.d.ts.map +1 -1
  58. package/dist/v2/host-service.d.ts +1 -1
  59. package/dist/v2/host-service.d.ts.map +1 -1
  60. package/dist/v2/server.js +701 -305
  61. package/dist/wrapup-orchestrator-y0bs7t5a.js +18 -0
  62. package/package.json +2 -1
  63. package/src/features/magic-context/dreamer/task-registry.ts +1 -1
  64. package/src/shared/data-path.ts +6 -6
  65. package/src/shared/model-suggestion-retry.test.ts +43 -0
  66. package/src/shared/model-suggestion-retry.ts +17 -0
  67. package/src/shared/test-temp-dir.ts +3 -0
  68. package/dist/wrapup-orchestrator-5akc87gr.js +0 -16
@@ -0,0 +1,18 @@
1
+ import {
2
+ runManagedWrapup2
3
+ } from "./index-1gtwrdc4.js";
4
+ import"./index-7wpwr2e2.js";
5
+ import"./index-sd3egckz.js";
6
+ import"./index-0ccmyzbj.js";
7
+ import"./index-yc81txp4.js";
8
+ import"./index-j7cnyvq1.js";
9
+ import"./index-y5145x8k.js";
10
+ import"./index-v8qr6tt2.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.0",
3
+ "version": "0.43.1",
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 file read and write tools to update project documentation",
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.
@@ -1,7 +1,8 @@
1
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
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
- testBackstopStorageDir = path.join(
266
- mkdtempSync(path.join(os.tmpdir(), "mc-test-db-backstop-")),
267
- "cortexkit",
268
- "magic-context",
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) {
@@ -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];
@@ -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
- };