Dashboard › opencode › Distillation
66f3bcca-b81a-4740-a473-79a95810e83b["lore_tm_v1_tPb6Qcb1SS0ugTYJGkqL-GFzhcnYFli4DcC9jJTOXMg","lore_tm_v1_H8g7iJKU3cyvtnEPoMNO8P3nNTkU0FvKtf5PQr0N5qA","lore_tm_v1_3hZ8ZdRCWaUPKi2ZNq1UQnBdwb5E8WfntVVX-lP0s6M","lore_tm_v1_8DHfKztQmOrHjqiHMTXTYw0R7T2RmPl__LRyBv8XvJU","lore_tm_v1_9XevYALzcVzOLQndazQN9rFe490HNqRrj9uE2sx_XxE","lore_tm_v1_zru0Ni7QoYQqTo29h19mbUTTY9Bbs90dWUnBtCUCHS0","lore_tm_v1_Zlf_6JG8l8uiFxbR548KF41pV6EJOF0ilz9Ru2HnOcA","lore_tm_v1_IhiHmq-XMVhAmy0w66kG4Ot4g4r5eAJMh7gRNRh18FQ","lore_tm_v1_5O_kzOfjQFD83yYzRKVNJCBAuHONNMF3piH8QF5mCkI","lore_tm_v1_Ce4zZFOJyXiChqUnBQh4WWkAZSu5f-UbxlOWTaV3mwI","lore_tm_v1_pCvOeQ4ns1UQVRinojfdAvjgl9ej2MAy1UmYSXcK8GA"]
mode: "subagent" and hidden: true so it never surfaces in the host project's agent/skill picker./home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts tests LorePlugin with a mock client and timestamped temp directory. Its config-hook cases verify: built-in compaction becomes { auto: false, prune: false }; hidden workers are registered as lore-distill ("Lore memory distillation worker"), lore-curator ("Lore knowledge curator worker"), and lore-query-expand ("Lore query expansion worker"), each with mode: "subagent" and hidden: true; existing agent config such as "my-agent" is preserved.applyLoreProviderConfig tests in /home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts verify every object-valued provider entry—including openai, anthropic, google, and mistral—gets options.baseURL = "http://127.0.0.1:3207/v1". This guards an Anthropic /messages versus /v1/messages 404 caused when OpenCode derives an Anthropic base URL from OPENAI_BASE_URL by stripping /v1; resolveSDK() bypasses OPENAI_BASE_URL/ANTHROPIC_BASE_URL, and other @ai-sdk providers lack a base-URL environment variable.applyLoreProviderConfig cases preserve existing nested options such as defaultHeaders: { "X-Custom": "value" }; force headerTimeout: false for openai and openai-codex, including overriding an inherited 30_000, while preserving Anthropic’s explicit headerTimeout: 10_000; no-op when gatewayBase is ""; create provider.openai.options with { baseURL: "http://127.0.0.1:3207/v1", headerTimeout: false } when cfg.provider is absent; and skip malformed non-object provider entries such as glitch: "not-an-object" without crashing./home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts verifies LorePlugin returns an empty tool map and exposes config, tool, and chat.headers only: event, experimental.chat.system.transform, experimental.chat.messages.transform, and experimental.session.compacting remain undefined.undefined is not an object (evaluating 'A.event'). Root cause: OpenCode’s legacy getLegacyPlugins/getServerPlugin iterates Object.values(mod), invokes every function export as a plugin, and rejects non-function exports with Plugin export is not a function; applyLoreProviderConfig had been invoked as a bogus plugin and returned undefined. Required shape: /home/byk/Code/opencode-lore/packages/opencode/src/index exports exactly LorePlugin and default, with default === LorePlugin, and reference deduplication yields exactly 1 unique function./home/byk/Code/opencode-lore/packages/opencode/test/routing.e2e.test.ts runs the real active LorePlugin path against a real in-process @loreai/gateway with a mocked upstream. It forces activation using LORE_OPENCODE_FORCE_ACTIVE=1, selects the gateway with LORE_GATEWAY_URL, clears LORE_REMOTE_URL and LORE_DISABLED, starts on 127.0.0.1 with ephemeral port 0, remoteGateway=false, and hostedMode=false, and restores environment, fetch, database, upstream interceptor, and pipeline state afterward.gatewayBase === "" never patched fetch; the routing regression test therefore requires active discovery to replace globalThis.fetch, while restoring the pristine function after the test so later tests do not route through a stopped gateway.config hook pins Anthropic baseURL to ${baseURL}/v1, preserves apiKey: "x", and sets compaction to { auto: false, prune: false }; 3. chat.headers emits x-lore-session-id: oc-sess-1, x-lore-agent: build, and x-lore-provider: anthropic; 4. a POST https://api.anthropic.com/v1/messages is rewritten through the gateway, reaches the mocked upstream, returns "hello from mock upstream", and increments upstreamCalls.anthropic-version: "2023-06-01", model claude-sonnet-4-20250514, max_tokens: 64, and Lore headers including x-lore-project: process.cwd(). The canned successful response has ID msg_oc_e2e_0, stop reason end_turn, and usage { input_tokens: 100, output_tokens: 10 }./home/byk/Code/opencode-lore/packages/opencode/test/session-state.test.ts covers per-project state when LorePlugin is initialized multiple times in one process. It guards the prior module-global currentProjectPath bug where sibling project initialization overwrote attribution. Tests verify a single project emits its directory; projects A and B retain distinct directories even after B initializes; sessions s1, s2, s3, sub-agent-1, and sub-agent-2 share their project directory; and meta-agent "title" requests still emit the project path.x-lore-git-remote and must have no sibling leak: neither its own nonexistent remote nor a remote from another project may appear./home/byk/Code/opencode-lore/packages/opencode/test/session-state.test.ts initializes separate non-repository temp directories for project-b and project-a, then verifies each project emits its own x-lore-project and leaves x-lore-git-remote undefined./home/byk/Code/opencode-lore/packages/opencode/test/subagent-detection.test.ts defines OpenCode sub-agent detection for #1300/#1302: chat.headers calls client.session.get({ path: { id } }), forwards a child session’s parentID as x-parent-session-id, retains the child’s own ID in x-lore-session-id, and emits no parent header for a primary session."sa-child-1" emits parent "sa-parent-1"; 2. "primary-1" emits no x-parent-session-id; 3. parent resolution for "cache-child"/"cache-parent" is cached so 3 turns produce exactly 1 session.get call; 4. a transient "server down" rejection is swallowed and not cached, so the first "retry-child" request proceeds without a parent header and the next turn retries successfully to emit "retry-parent"./home/byk/Code/opencode-lore/packages/opencode/test/tui-silence.test.ts verifies activation calls log.silenceStderr() before gateway work so neither the plugin nor its in-process gateway can write [lore] to OpenCode’s full-screen TUI. The test forces the active path with LORE_OPENCODE_FORCE_ACTIVE=1, prevents gateway probing/startup with LORE_DISABLED=1, checks log.isStderrSilenced() changes from false to true, then restores environment and calls log.silenceStderr(false)./home/byk/Code/opencode-lore/packages/opencode/test/gateway-smoke.test.ts has 4 in-process gateway smoke cases: 1. probeGateway("http://127.0.0.1:19876", 500) returns false; 2. startServer with port 0, remoteGateway=false, and hostedMode=false yields a healthy gateway within 2000 ms whose /health body has status: "ok"; 3. an explicit free port obtained via node:net, followed by a 50 ms release delay, is honored and healthy; 4. probeGateway(..., 2000) returns true for a node:http server implementing a compatible /health endpoint. Shutdown handles are awaited in afterAll.startServer rather than startGateway because embedding worker initialization can trigger Bun NAPI teardown crashes./home/byk/Code/opencode-v2-pilot/packages/plugin/test contains exactly 1 entry: host.test.ts./home/byk/Code/opencode-v2-pilot/packages/cli/src/commands/handlers/plugin/ contains 6 handlers: update.ts, remove.ts, list.ts, inventory.ts, check.ts, and add.ts./home/byk/Code/opencode-v2-pilot/packages/cli/src/commands/handlers/plugin/list.ts obtains the service endpoint, calls client.plugin.list({ location: { directory: process.cwd() } }), loads configured and locally discovered plugin targets, and excludes disabled/wildcard/internal targets beginning with -, equal to *, ending in .*, or beginning with opencode..localSource(target, path.dirname(config.path)) as local, uses Host.resolve({ directory }), and includes it only if a TUI entrypoint exists with version "local". Package targets must satisfy Npm.isInstallablePackage(target), resolve through npm.resolve(target), and expose a TUI entrypoint through Host.resolve(installed).tui.format(...) in /home/byk/Code/opencode-v2-pilot/packages/cli/src/commands/handlers/plugin/list.ts omits built-ins unless builtin=true; maps package, local, and builtin sources into ID, VERSION, and SOURCE; avoids duplicate TUI targets already represented by server plugins; deduplicates remaining targets; sorts by ID then target; abbreviates exact 40- or 64-character hexadecimal versions to 7 characters; aligns the first 2 columns; returns "" for no rows; and causes the handler to print No plugins found./home/byk/Code/opencode-v2-pilot/packages/cli/src/commands/handlers/plugin/check.ts runs inspect(Option.getOrUndefined(input.target)), prints format(result.items) or No package plugins found, and sets process.exitCode = 1 when any inspected item has an error.