Dashboard › opencode › Distillation
6899001f-7cc0-4f23-a01e-6db0ded29c18["lore_tm_v1_-ArbB7ZQWzkblBNgI295g0kpmdBUiOHM_kQeAnINLFw","lore_tm_v1_DdWHoKnLKGHofgpsoNK13YtLa2yKC1Wd4krI-c9yD9I","lore_tm_v1_6RgeG4zFaFRSceX3OVS1ocn3625NjDMy5Fc5JbHVTQw","lore_tm_v1_Jirn11SSzxV8F5lc478y8v3mXJk6pvJ-QoIT9DeQRkE","lore_tm_v1_WuLgaYCDp2FliwQnJW-0imRJnyjw6Msbg6Y-UQjvNLs"]
packages/opencode/script/build.ts defines an esbuild build script: removes and recreates dist, bundles src/server.ts to dist/server.js, and uses format: "esm", platform: "node", target: "esnext", sourcemap: true, and logLevel: "info".packages/opencode/script/build.ts marks @opencode/plugin, @loreai/core, and @loreai/gateway as external dependencies.packages/opencode/test/internal.test.ts tests parseUpstreamExtraHeaders() with empty values, CRLF, and an invalid line; "x-empty:\r\nx-team: platform\r\ninvalid" must parse to [["x-empty", ""], ["x-team", "platform"]].packages/opencode/test/internal.test.ts tests that gatewayAccessHeadersForRemote() injects x-lore-gateway-token only when the requested remote matches LORE_REMOTE_URL, including normalization of a trailing /; it must not inject the token for http://127.0.0.1:3207.packages/opencode/test/internal.test.ts establishes that provider credentials such as ANTHROPIC_API_KEY must not be confused with Lore gateway access credentials.packages/opencode/test/internal.test.ts establishes that shouldForwardUpstreamExtraHeader() must reject managed credential headers x-api-key, X-Goog-Api-Key, Authorization, and X-Lore-Gateway-Token, while forwarding a non-credential extra such as CF-Access-Client-Id.packages/opencode/test/internal.test.ts: surfaceGatewayUnavailable() must NEVER let a missing, synchronously throwing, or promise-rejecting toast turn a degraded session into a crash.surfaceGatewayUnavailable() is intended as the user-visible failure signal when the in-process gateway cannot start; because embedded/TUI mode silences log.error on stderr to avoid corrupting rendering, it raises a TUI-safe toast for the failure reported in Danielβs Windows report.packages/opencode/test/internal.test.ts tests the exact gateway failure message Lore failed to start β memory features are unavailable. and requires one showToast() call with { body: { title: "Lore", message: MSG, variant: "error" } }.packages/opencode/test/internal.test.ts requires surfaceGatewayUnavailable() to still call log.error for the file and Sentry sink, swallow a synchronous showToast() exception, attach handling for a rejected toast promise so there is no unhandled rejection, and tolerate both a client lacking tui.showToast and an undefined client.packages/opencode/test/package.test.ts creates a temporary lore-opencode-package- directory, runs pnpm run build, packs with pnpm pack --out <temporary>/loreai-opencode.tgz, extracts it using tar -xzf, and recursively removes the temporary directory afterward.packages/opencode/test/package.test.ts requires the packed package.json export ./server to equal { types: "./src/server.ts", bun: "./dist/server.js", default: "./dist/server.js" }.packages/opencode/test/package.test.ts verifies the package ships compiled package/dist/server.js; the output must not contain interface LoreServerRuntime, import type , or @opencode/plugin.packages/opencode/test/server-runtime.test.ts tests acquireServerRuntime(), buildServerHeaders(), and resetServerRuntimeForTest(); each test resets runtime state and restores process.env.acquireServerRuntime("/project", ...) must remain inactive and return undefined when LORE_DISABLED is either "1" or "true".LORE_OPENCODE_FORCE_ACTIVE="1", server runtime acquisition for /workspace/one and /workspace/two must share one owned gateway at http://127.0.0.1:3207, preserve distinct project paths and git remotes one/repo and two/repo, and invoke resolveGateway() exactly once.shutdown; releasing the second must call it exactly once; a repeated second release must remain idempotent and not call shutdown again.gitRemote() throws Error("identity failed"), acquireServerRuntime() must reject with identity failed and release the acquired gateway by calling shutdown() once.resolveGateway() call is blocked until the first shutdown resolves, after which the new runtime may use http://127.0.0.1:5673.buildServerHeaders() must combine gateway access and attribution headers: x-lore-access, x-lore-session-id, x-parent-session-id, x-lore-agent, x-lore-project, x-lore-git-remote, x-lore-provider, x-lore-upstream-url, and permitted extras such as x-team.buildServerHeaders() test, runtime attribution uses project path /workspace/project, git remote github.com/example/project, session ses_1, parent ses_parent, agent build, provider openai, and upstream URL https://upstream.example/v1.buildServerHeaders() must not forward authorization, x-api-key, or forged x-lore-* extras such as x-lore-forged.packages/opencode/test/server.test.ts tests the V2 server plugin exported by packages/opencode/src/server.ts, while mocking acquireServerRuntime, buildServerHeaders, and rewriteRequest.plugin.id === "lore" and a setup function without changing the legacy packages/opencode/src/index.ts API; legacy exports must remain exactly LorePlugin and default, with default === LorePlugin.lore-distill, description Lore memory distillation worker; 2. lore-curator, description Lore knowledge curator worker; 3. lore-query-expand, description Lore query expansion worker. Each has mode: "subagent" and hidden: true.model.request and http.request hooks and call acquireServerRuntime("/workspace/project").model.request event with session ses_1, agent build, provider openai, provider authorization, and base URL https://api.openai.com/v1, the plugin must look up the session, pass parent ses_parent into buildServerHeaders(), preserve the provider authorization header, add x-lore-session-id: ses_1, and rewrite the base URL to http://127.0.0.1:3207/v1.http.request event, the plugin must call rewriteRequest(original, "http://127.0.0.1:3207", {}) and replace https://api.openai.com/v1/chat/completions with http://127.0.0.1:3207/v1/chat/completions.Error("registration failed"), plugin setup must reject with that error, attempt to dispose the one prior registration even if disposal throws Error("dispose failed"), and release the runtime exactly once.Error("unavailable"), model routing must continue without a parentID header while still supplying x-lore-session-id: ses_1./workspace/a releases only its runtime and leaves /workspace/b active; subsequent /workspace/b routing must use runtime project path /workspace/b, after which its own cleanup releases its runtime.