@cortexkit/opencode-magic-context 0.44.2 → 0.44.4
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/{conflict-warning-hook-1msyvb51.js → conflict-warning-hook-hmpzxep6.js} +3 -3
- package/dist/{derive-budgets-gd2270s0.js → derive-budgets-ncwn1jk9.js} +4 -2
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/lease.d.ts +1 -1
- package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +1 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +8 -4
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +1 -1
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-storage.d.ts +5 -5
- package/dist/features/magic-context/session-project-storage.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +6 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-embedding-measurements.d.ts.map +1 -1
- package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts +12 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/derive-budgets.d.ts +4 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
- package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +7 -0
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +5 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +1 -4
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts +4 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +4 -2
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +2 -2
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/storage-busy-refusal.d.ts +6 -0
- package/dist/hooks/magic-context/storage-busy-refusal.d.ts.map +1 -1
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
- 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-r9vkp4n9.js → index-33q7s9y2.js} +1 -1
- package/dist/{index-egkfvhms.js → index-4an2p8qa.js} +80 -14
- package/dist/{index-18tjha8g.js → index-638hf49n.js} +1 -1
- package/dist/{index-gtzcmv90.js → index-mrc0twf3.js} +12 -6
- package/dist/{index-stb5fg12.js → index-msqr3x6m.js} +32 -2
- package/dist/{index-y5145x8k.js → index-n96ag4rk.js} +15 -1
- package/dist/{index-esxfcz5z.js → index-qm36k34q.js} +56 -13
- package/dist/{index-ttdn47aq.js → index-sqp1hz9v.js} +311 -82
- package/dist/{index-40s1xz22.js → index-wprsye9w.js} +1 -1
- package/dist/{index-3x9caerx.js → index-zx7pmr39.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +530 -250
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{read-session-chunk-wmvgnd24.js → read-session-chunk-339hg90t.js} +3 -3
- package/dist/{recomp-orchestrator-rk40ff15.js → recomp-orchestrator-0ers6smx.js} +7 -7
- package/dist/{send-session-notification-6xsrcxnp.js → send-session-notification-04hvd54c.js} +2 -2
- package/dist/shared/rpc-utils.d.ts +7 -0
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/run-token-log.d.ts +13 -0
- package/dist/shared/run-token-log.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +7 -0
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +2 -0
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/shared/user-answer.d.ts +4 -0
- package/dist/shared/user-answer.d.ts.map +1 -0
- package/dist/{transform-postprocess-phase-t7xgdhdf.js → transform-postprocess-phase-ttdkrm6r.js} +7 -7
- package/dist/v2/hidden-completion.d.ts +7 -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-terminal-error.d.ts +8 -0
- package/dist/v2/hooks/hidden-terminal-error.d.ts.map +1 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +1 -1
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/server.js +916 -221
- package/dist/v2/store-reader.d.ts +2 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/{wrapup-orchestrator-h8tr10c6.js → wrapup-orchestrator-x0jvvrqn.js} +8 -8
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/shared/data-path.test.ts +1 -1
- package/src/shared/models-dev-cache.test.ts +30 -1
- package/src/shared/rpc-utils.test.ts +27 -2
- package/src/shared/rpc-utils.ts +44 -15
- package/src/shared/run-token-log.test.ts +65 -0
- package/src/shared/run-token-log.ts +39 -0
- package/src/shared/sqlite-acquisition-routing.test.ts +19 -11
- package/src/shared/sqlite-pass-scope.test.ts +115 -144
- package/src/shared/sqlite.ts +123 -20
- package/src/shared/storage-busy.test.ts +34 -57
- package/src/shared/tag-transcript.ts +4 -1
- package/src/shared/transcript.ts +3 -0
- package/src/shared/user-answer.test.ts +40 -0
- package/src/shared/user-answer.ts +17 -0
- package/src/shared/write-transaction-attribution.test.ts +13 -11
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { expect, it } from "bun:test";
|
|
2
|
+
import cases from "../../../../tests/fixtures/user-answer-metadata.json";
|
|
3
|
+
import { hasUserAnswerMetadata, toolPartHasUserAnswer } from "./user-answer";
|
|
4
|
+
|
|
5
|
+
it("TS/Rust parity recognizes structural host answer metadata", () => {
|
|
6
|
+
for (const test of cases) {
|
|
7
|
+
expect(hasUserAnswerMetadata(test.metadata)).toBe(test.protected);
|
|
8
|
+
expect(toolPartHasUserAnswer({ state: { metadata: test.metadata } })).toBe(test.protected);
|
|
9
|
+
expect(toolPartHasUserAnswer({ details: test.metadata })).toBe(test.protected);
|
|
10
|
+
}
|
|
11
|
+
expect(toolPartHasUserAnswer({ tool: "question", state: { output: "no marker" } })).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("OpenCode CK sidecars preserve answer provenance without changing block identities", async () => {
|
|
15
|
+
const { encodeOpenCodeMessagesToCk } = await import("../hooks/magic-context/module-wire");
|
|
16
|
+
const message = {
|
|
17
|
+
info: { id: "m", role: "assistant" },
|
|
18
|
+
parts: [
|
|
19
|
+
{
|
|
20
|
+
type: "tool",
|
|
21
|
+
tool: "renamed-question",
|
|
22
|
+
callID: "q",
|
|
23
|
+
state: {
|
|
24
|
+
status: "completed",
|
|
25
|
+
input: {},
|
|
26
|
+
output: "answer",
|
|
27
|
+
metadata: { answers: [["yes"]] },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
const answered = encodeOpenCodeMessagesToCk([message]);
|
|
33
|
+
const plain = structuredClone(message);
|
|
34
|
+
Reflect.deleteProperty(plain.parts[0].state, "metadata");
|
|
35
|
+
const ordinary = encodeOpenCodeMessagesToCk([plain]);
|
|
36
|
+
expect(answered[0].ck.content).toEqual(ordinary[0].ck.content);
|
|
37
|
+
expect(answered[0].ck.provider_extras).toEqual({
|
|
38
|
+
opencode: { user_answer_block_indices: [1] },
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isRecord } from "./record-type-guard";
|
|
2
|
+
|
|
3
|
+
/** Host-owned answer metadata, independent of the tool's registered name. */
|
|
4
|
+
export function hasUserAnswerMetadata(value: unknown): boolean {
|
|
5
|
+
if (!isRecord(value)) return false;
|
|
6
|
+
if (value.userAnswer === true) return true;
|
|
7
|
+
if (Array.isArray(value.answers)) return true;
|
|
8
|
+
if (typeof value.answer === "string") return true;
|
|
9
|
+
if (Array.isArray(value.selectedOptions) || typeof value.customInput === "string") return true;
|
|
10
|
+
return Array.isArray(value.results) && value.results.some(hasUserAnswerMetadata);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function toolPartHasUserAnswer(part: unknown): boolean {
|
|
14
|
+
if (!isRecord(part)) return false;
|
|
15
|
+
const state = isRecord(part.state) ? part.state : undefined;
|
|
16
|
+
return hasUserAnswerMetadata(state?.metadata) || hasUserAnswerMetadata(part.details);
|
|
17
|
+
}
|
|
@@ -6,7 +6,7 @@ import { join, resolve } from "node:path";
|
|
|
6
6
|
const repoRoot = resolve(import.meta.dir, "../../../../");
|
|
7
7
|
const beginImmediate = /\b(?:[A-Za-z_$][\w$]*\.)?exec\("BEGIN IMMEDIATE"\)/g;
|
|
8
8
|
|
|
9
|
-
const fencedSources: Array<{ path: string; sites: string[] }> = [
|
|
9
|
+
const fencedSources: Array<{ path: string; sites: string[]; reporterCalls?: string[] }> = [
|
|
10
10
|
{
|
|
11
11
|
path: "packages/plugin/src/features/magic-context/smart-notes/storage.ts",
|
|
12
12
|
sites: ["smart_note_commit"],
|
|
@@ -52,8 +52,8 @@ const fencedSources: Array<{ path: string; sites: string[] }> = [
|
|
|
52
52
|
// The chokepoint cannot import the logging chain (Node executes it
|
|
53
53
|
// directly), so it reports through the injected reporter instead.
|
|
54
54
|
path: "packages/plugin/src/shared/sqlite.ts",
|
|
55
|
-
sites: ["privileged_writer"],
|
|
56
|
-
|
|
55
|
+
sites: ["async_acquisition_dynamic_site", "privileged_writer"],
|
|
56
|
+
reporterCalls: ["console.warn(", "reportSlowPrivilegedWrite?.("],
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
path: "packages/plugin/src/features/magic-context/git-commits/sweep-coordinator.ts",
|
|
@@ -75,10 +75,6 @@ const fencedSources: Array<{ path: string; sites: string[] }> = [
|
|
|
75
75
|
path: "packages/plugin/src/hooks/magic-context/compartment-runner-recomp.ts",
|
|
76
76
|
sites: ["historian-publish:recomp"],
|
|
77
77
|
},
|
|
78
|
-
{
|
|
79
|
-
path: "packages/plugin/src/hooks/magic-context/compartment-runner-incremental.ts",
|
|
80
|
-
sites: ["historian-publish"],
|
|
81
|
-
},
|
|
82
78
|
{
|
|
83
79
|
path: "packages/plugin/src/features/magic-context/dreamer/lease.ts",
|
|
84
80
|
sites: ["lease_dynamic_site"],
|
|
@@ -98,6 +94,10 @@ const fencedSources: Array<{ path: string; sites: string[] }> = [
|
|
|
98
94
|
];
|
|
99
95
|
|
|
100
96
|
const nonBeginCoveredSites: Array<{ path: string; site: string }> = [
|
|
97
|
+
{
|
|
98
|
+
path: "packages/plugin/src/hooks/magic-context/compartment-runner-incremental.ts",
|
|
99
|
+
site: "historian-publish",
|
|
100
|
+
},
|
|
101
101
|
{
|
|
102
102
|
path: "packages/plugin/src/features/magic-context/message-index.ts",
|
|
103
103
|
site: "message_index_clear",
|
|
@@ -159,7 +159,7 @@ function sourceFor(relativePath: string): string {
|
|
|
159
159
|
function assertCoveredBeginImmediate(
|
|
160
160
|
source: string,
|
|
161
161
|
sites: string[],
|
|
162
|
-
|
|
162
|
+
reporterCalls: string[] = [],
|
|
163
163
|
): void {
|
|
164
164
|
const matches = [...source.matchAll(beginImmediate)];
|
|
165
165
|
expect(matches).toHaveLength(sites.length);
|
|
@@ -167,8 +167,10 @@ function assertCoveredBeginImmediate(
|
|
|
167
167
|
const match = matches[index];
|
|
168
168
|
const nextBegin = matches[index + 1]?.index ?? source.length;
|
|
169
169
|
const transactionRegion = source.slice(match.index, nextBegin);
|
|
170
|
-
expect(transactionRegion).toContain(
|
|
171
|
-
if (sites[index] === "
|
|
170
|
+
expect(transactionRegion).toContain(reporterCalls[index] ?? "logSlowWriteTransaction(");
|
|
171
|
+
if (sites[index] === "async_acquisition_dynamic_site") {
|
|
172
|
+
expect(transactionRegion).toContain("site=${site}");
|
|
173
|
+
} else if (sites[index] === "lease_dynamic_site") {
|
|
172
174
|
expect(transactionRegion).toContain("logSlowWriteTransaction(site");
|
|
173
175
|
} else {
|
|
174
176
|
expect(transactionRegion).toContain(`"${sites[index]}"`);
|
|
@@ -219,7 +221,7 @@ describe("write transaction attribution fences", () => {
|
|
|
219
221
|
assertCoveredBeginImmediate(
|
|
220
222
|
sourceFor(fencedSource.path),
|
|
221
223
|
fencedSource.sites,
|
|
222
|
-
|
|
224
|
+
fencedSource.reporterCalls,
|
|
223
225
|
);
|
|
224
226
|
}
|
|
225
227
|
for (const coveredSite of nonBeginCoveredSites) {
|