Dashboard › opencode › Distillation
c443c2b3-d58d-4698-97e8-ae87938fec47["lore_tm_v1_ly1wmb38T_FXVkaGnxEa_hH8BxZrFd5Fbx5ci_Tbi_4","lore_tm_v1_R58udF6w5R3jHzyW5Bar3ZStl3Tt_cQTZnEuQKeKUhQ"]
/home/byk/.local/share/opencode-v2-pilot/config/opencode, and Lore 0.40.0 cannot load unchanged under /home/byk/Code/opencode-v2-pilot because the V2 loader rejects Lore’s default export before setup runs./home/byk/.local/share/opencode-v2-pilot/config/opencode/opencode.json:1-3 contains only $schema and no plugins; package.json:4-8 and bun.lock:4-12 contain only effect and @types/bun; no node_modules/@loreai or node_modules/@opencode-ai/plugin tree exists. /home/byk/.local/share/opencode-v2-pilot/config/opencode/service-v2-pilot.json:2-4 has only hostname, port, and password keys and no plugin inventory or activation state; only key names, not values, were inspected./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/source-directory.ts:7-32 loads .ts/.js files, symlinks, and directories from plugin or plugins; the pilot has exactly two eligible files, defining followup at plugins/followup.ts:22-24 and local-pty at plugins/pty.ts:148-151, exported at plugins/pty.ts:493. /home/byk/Code/opencode-v2-pilot/.opencode/opencode.jsonc:1-20 declares no package plugins, and .opencode/plugins/smoke-theme.json is ignored because discovery accepts only .ts, .js, or directories. Lore’s .opencode/package.json:1-5 installs legacy @opencode-ai/plugin but does not activate Lore. This static state corroborates the prior runtime inventory containing only followup and local-pty./home/byk/Code/opencode-lore/packages/opencode/package.json:7-15 exports src/index.ts at package root; src/index.ts:1 imports legacy Hooks, Plugin, and PluginInput; LorePlugin is an async function at src/index.ts:242 and the default export at src/index.ts:505-511. Legacy @opencode-ai/plugin/dist/index.d.ts:10-18 defines Plugin as (input: PluginInput) => Promise<Hooks> with client, project, directory, and worktree; lines 108-156 expose config, returned tool, and chat.headers hooks.@opencode/plugin is version 1.18.15 per /home/byk/Code/opencode-v2-pilot/packages/plugin/package.json:3-18; a Promise plugin must be { id, setup } per packages/plugin/src/promise/plugin.ts:54-62. Setup receives domain APIs and location, not legacy client, project, directory, worktree, or a TUI client (plugin.ts:25-52). /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts:60-73 validates module.default as { id, effect } or { id, setup }; invalid definitions produce Plugin must export a default definition with an id and an effect or setup function. at lines 107-116. No legacy function-export compatibility loader was found, so Lore’s default function fails validation before setup.packages/core/src/config/plugin/source.ts:148-157), and local directories are probed only for root server or index entrypoints (packages/plugin/src/host.ts:17-43); /home/byk/Code/opencode-lore/packages/opencode contains only src/index.ts, so direct local-directory configuration also fails entrypoint discovery. Registry-installed packages avoid the second issue because package resolution honors exports.@opencode-ai/plugin >=1.1.0 and develops against that old SDK (packages/opencode/package.json:20-30), while V2 exposes @opencode/plugin. 2. Legacy Hooks, function-style Plugin, and PluginInput have no V2 equivalents. 3. ctx.project.id, ctx.worktree, ctx.directory, and ctx.client usages at Lore src/index.ts:198-200,307,314-335 must move to V2 ctx.location, whose project identity/path fields are defined at packages/schema/src/location.ts:14-22. 4. Lore’s client.session.get({ path: { id } }) and res.data usage at src/index.ts:198-216 differs from V2’s { sessionID } request and direct session return at packages/client/src/promise/generated/client.ts:612-622. 5. Legacy returned config, tool, and chat.headers hooks must become explicit V2 registrations such as ctx.session.hook(...) and ctx.tool.transform(...) (packages/plugin/src/promise/session.ts:76-102; tool.ts:25-35,65-69). 6. surfaceGatewayUnavailable uses client.tui.showToast at Lore src/internal.ts:174-194, but V2 server setup has no TUI API. 7. Tests under Lore/packages/opencode/test/ importing legacy PluginInput or Hooks must be converted or retained only as legacy-entrypoint tests.prune (src/index.ts:337-344); V2 defaults auto: true (packages/core/src/session/compaction.ts:375-383) and supports auto, keep, and buffer, not prune (packages/schema/src/config/compaction.ts:6-14). Since Promise setup has no compaction domain, preserving behavior requires static "compaction": { "auto": false }. 2. Lore adds three hidden agents through legacy cfg.agent (src/index.ts:349-366); V2’s canonical field is agents (packages/schema/src/config.ts:57-59), while AgentEditor can update/remove but not add (packages/plugin/src/promise/agent.ts:6-16), so hidden agents require static config unless V2 gains add support. 3. Legacy chat.headers is replaced by V2 model.request, exposing mutable baseURL and headers, and http.request, exposing the final mutable Request (packages/plugin/src/promise/session.ts:39-63,76-82); core runs them immediately before dispatch (packages/core/src/session/model-request.ts:220-269).x-parent-session-id from durable session state before hooks (packages/core/src/session/model-request.ts:207-215); recreating Lore’s lookup would add a failing API call and duplicate behavior. 5. Lore’s unsafe input.provider.id cast at src/index.ts:413-422 is unnecessary because V2’s Model.Ref supplies event.model.providerID (packages/schema/src/model.ts:14-18). 6. Lore’s TUI assumption and global stderr suppression at src/index.ts:251-258 would suppress V2 server diagnostics and must not be ported. 7. Lore installs a process-global fetch interceptor and discards cleanup at src/index.ts:466-485, despite cleanup being returned by packages/core/src/fetch-interceptor.ts:561-566; V2 unloads replaced scopes and runs Promise cleanups (packages/core/src/plugin.ts:127-159; packages/plugin/src/promise/adapter.ts:598-600), so retaining the patch would leak or incorrectly remove routing across reloads and concurrent locations.src/index.ts:89-108, although packages/gateway/src/cli/start.ts:108-116 exposes shutdown(); V2 needs either a shared reference-counted gateway lifecycle or an externally managed gateway. 9. Lore’s provider mutation at src/internal.ts:102-135 targets singular provider, nested options, and headerTimeout; V2 uses providers, settings, headers, and body (packages/schema/src/config/provider.ts:9-20,61-69). Native request hooks replace base-URL mutation, and the old OpenAI timeout workaround has no direct V2 mapping. 10. Lore currently consumes no events, and tests at packages/opencode/test/index.test.ts:262-271 assert no event or transform hooks; V2’s event API is an async subscription stream (packages/plugin/src/promise/event.ts:1-3; packages/protocol/src/groups/event.ts:38-65), but this is not a minimum-port blocker. 11. Lore returns an empty tool map (src/index.ts:372), verified at test/index.test.ts:252-260; the V2 port should remove it rather than register an empty transform./v1/messages (packages/ai/src/protocols/anthropic-messages.ts:35-38) and OpenAI Chat to /v1/chat/completions (packages/ai/src/protocols/openai-chat.ts:37-38), while Lore already recognizes these paths and preserves original upstream metadata (Lore/packages/core/src/fetch-interceptor.ts:44-64,182-225,383-394).<package>/server before <package> in /home/byk/Code/opencode-v2-pilot/packages/plugin/src/host.ts:17-43.Lore/packages/opencode/package.json—export ./server, add the V2 @opencode/plugin type dependency, retain the legacy root export. 2. Lore/packages/opencode/src/server.ts—default-export Plugin.define({ id: "lore", setup }). 3. Lore/packages/opencode/src/index.ts—retain the current legacy adapter and move out only shared gateway-discovery code if needed. 4. Lore/packages/opencode/src/internal.ts or a new focused runtime module—share gateway discovery, remote access-header handling, and owned-gateway lifecycle without a legacy client type. 5. Lore/packages/core/src/fetch-interceptor.ts—extract a pure web Request rewrite operation; V2 http.request must preserve the exact original URL and complete pathname in x-lore-upstream-url and x-lore-upstream-path, never gateway-derived values. 6. Lore/packages/opencode/test/—add V2 definition, hook, routing, multi-location, setup-failure, and cleanup tests while keeping legacy-entry regressions. 7. Pilot/opencode.json—only after acceptance, activate @loreai/opencode, set "compaction": { "auto": false }, and define all three hidden agents under canonical agents.ctx.location; register session.http.request; retain V2’s existing parent header; inject Lore attribution from hook session/agent/model fields; return cleanup that disposes registrations and releases the shared gateway; never call log.silenceStderr().pnpm --filter @loreai/opencode run typecheck. 2. Run focused adapter tests with pnpm exec vitest run packages/opencode/test. 3. Prove the legacy root exports exactly one function and new /server exports exactly one { id: "lore", setup } definition. 4. Adapt the routing E2E fixture to exercise V2 http.request with no external network./v1, and prefixed endpoints; assert exact original upstream URL/path, auth-header preservation, Lore-header filtering, request kind, session, agent, provider, project path, Git remote, and parent-session behavior. 6. Test two concurrent V2 locations, reload, failed setup, last-user cleanup, owned-versus-reused gateway shutdown, and absence of project-state leakage. 7. Run each adversarial routing/lifecycle regression exactly ten times. 8. Build exact artifacts with pnpm --filter @loreai/core run build, pnpm --filter @loreai/gateway run bundle, and pnpm run build.pnpm run typecheck, pnpm test, pnpm run lint, and pnpm run format:check. 10. Pack exact npm artifacts, install them in a disposable wrapper workspace, and use an auto-discovered V2 test plugin to re-export @loreai/opencode/server. 11. Start a disposable V2 server with separate config, data, state, cache, database, and an unused loopback port; do not use or alter the current pilot service. 12. Confirm inventory reports lore active, then send controlled primary, title, compaction, and generate requests through a mock upstream; verify cleanup, gateway health, logs, and zero external network traffic. 13. Only after every check passes, update the isolated pilot config and leave restart control to the user.