Dashboard › opencode › Distillation
446fe9ab-b62c-4dd0-b2e9-3e66cb619dc1["lore_tm_v1_4M84O6Owkkp9jyIvo-ZADPPwKEkmglguXo8jVZjAgbo","lore_tm_v1_o-jjClZVjm9z3VaLmnM1pgTjiZ44dLyxTICFFfu-sbk","lore_tm_v1_ikjn-8j1HiZ2gphmPdozMQbammuyqHzTiOX-DSYexuI","lore_tm_v1_tiyeJ7i4QGMpBELHZcpf_J9C4y0EdxXDB2xvJ0ydfdk","lore_tm_v1_HHTVvoyte1yFYQrR90Enw7qdbwZEaPRZqy64TI-kvYs","lore_tm_v1_XIycWiv34HpWg-RzxGHOE3mg8_Te8A8XMcTXQ9UXuhY","lore_tm_v1_32AFTIsMXyhf9EWNjcypg8qqZGwl5rIywABkEwDs7h8","lore_tm_v1_vppwQ-8KW-GknPw815tnS4BXo67cOqMQ1p_X0TwF9Ms"]
/home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts defines the V2 Lore OpenCode server plugin as id: "lore" with 3 hidden "subagent" workers in exact order: 1. lore-distill — "Lore memory distillation worker"; 2. lore-curator — "Lore knowledge curator worker"; 3. lore-query-expand — "Lore query expansion worker".acquireServerRuntime(ctx.location.project.directory) during setup and remains inactive when it returns no runtime.agent.transform that updates each Lore worker’s description, sets mode = "subagent", and sets hidden = true.model.request hook fetches the session with ctx.session.get({ sessionID: event.sessionID }), tolerates lookup failure with .catch(() => undefined), builds headers from runtime/session/parent/agent/provider attribution, assigns them into event.headers, and changes event.baseURL to ${runtime.gatewayBase}/v1 only when headers["x-lore-upstream-url"] exists.http.request hook replaces event.request with await rewriteRequest(event.request, runtime.gatewayBase, {}).runtime.release() via Promise.allSettled, then rethrows the original setup error.cleaned flag, disposes every hook registration and releases the runtime concurrently with Promise.allSettled, and throws new AggregateError(failures, "Lore plugin cleanup failed") if any cleanup operation rejects./home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts defines LoreServerRuntime with gatewayBase, projectPath, gitRemote, gatewayHeaders, and idempotent asynchronous release().@loreai/gateway and known ports [3207, 5673].resetServerRuntimeForTest() throws "Server runtime reset is test-only" unless process.env.NODE_ENV === "test"; in tests it clears gatewayLeasePromise, awaits the old lease, and invokes its optional shutdown.acquireServerRuntime() returns undefined during NODE_ENV=test or when any process argument contains .test., unless LORE_OPENCODE_FORCE_ACTIVE === "1"; it also returns undefined when LORE_DISABLED is exactly "1" or "true".acquireServerRuntime(projectPath, dependencies) acquires a shared gateway lease, resolves the project’s Git remote with dependencies.gitRemote ?? getGitRemote and defaults a missing remote to ""; if Git-remote resolution throws, it releases the lease before rethrowing.gatewayLeasePromise; acquireGatewayLease() shares concurrent resolution, retries after an in-progress lease.closing finishes, increments lease.refs, and clears the shared promise if gateway resolution rejects.releaseGatewayLease() decrements lease.refs, retains the gateway while references remain, and on the final release stores a lease.closing promise that awaits optional shutdown and clears gatewayLeasePromise only if it still refers to the same active lease. This prevents a new acquisition from racing a predecessor’s shutdown.createGatewayLease() first uses a discovered gateway without taking shutdown ownership; otherwise it logs "No Lore gateway found, starting in-process…", dynamically imports @loreai/gateway, calls startGateway({ quiet: true, local: true }), builds http://127.0.0.1:${handle.port}, and retains handle.shutdown only when handle.owned is true.resolveGatewayUrl() checks a trailing-slash-normalized LORE_REMOTE_URL first and logs remote gateway at ${url} not reachable, falling through to local discovery when its probe fails; it then checks normalized LORE_GATEWAY_URL, the optional readPortFile() result, and known ports [3207, 5673] at 127.0.0.1, returning the first gateway for which probeGateway(url) succeeds.resolveGatewayUrl() tolerates failure to import @loreai/gateway while reading the port file because the package may be unavailable when connecting to a remote gateway.buildServerHeaders() combines runtime.gatewayHeaders with x-lore-session-id, x-lore-agent, x-lore-project, x-lore-git-remote, and x-lore-provider; it conditionally adds x-parent-session-id.buildServerHeaders() maps provider IDs to LORE_UPSTREAM_${providerID.toUpperCase().replace(/-/g, "_")} and, when set, emits the value as x-lore-upstream-url.buildServerHeaders() parses LORE_UPSTREAM_EXTRA_HEADERS with parseUpstreamExtraHeaders() and includes only entries accepted by shouldForwardUpstreamExtraHeader().>= 22.5, uses TypeScript in a pnpm workspaces monorepo, and stores SQLite data in WAL mode with FTS5 at ~/.local/share/lore/lore.db.packages/core/test/setup.ts, never the production DB.pnpm install, pnpm test, pnpm run typecheck, pnpm run lint, pnpm run lint:fix, pnpm run format, pnpm run format:check, and pnpm run build.quality/REVIEW.md, including regression-test discipline, adversarial-order state setup, fan-out registry coverage, recurring bug-class batteries, and the two-reviewer rule.CHANGELOG.md must never be bumped or edited manually because Craft handles both automatically.gh workflow run release.yml -f version=auto for conventional-commit-derived semver or gh workflow run release.yml -f version=0.23.0 for an explicit version.scripts/bump-version.sh updates all package.json versions; 2. changelog generation from conventional commits; 3. creation and push of release/X.Y.Z; 4. CI tests and builds npm tarballs, standalone binaries, and delta patches; 5. Craft opens a "publish" issue and the Publish workflow runs after it is labeled accepted; 6. npm publication uses OIDC trusted publishing and a GitHub Release receives binaries and patches..craft.yml defines release targets for 4 npm workspaces, the legacy opencode-lore alias, and a GitHub Release with binaries./home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts tests that LORE_DISABLED values "1" and "true" keep the V2 server runtime inactive./workspace/one with one/repo, /workspace/two with two/repo) share one owned gateway resolution; releasing the first does not shut it down, releasing the second shuts it down exactly once, and repeated release remains idempotent."identity failed" Git-remote resolution error releases the gateway exactly once before propagating.http://127.0.0.1:3207, successor base http://127.0.0.1:5673, and resolveGateway is called exactly twice.LORE_UPSTREAM_OPENAI=https://upstream.example/v1 and extra headers x-team: platform, authorization: Bearer secret, x-api-key: secret, and x-lore-forged: bad; expected output preserves the gateway access header and x-team, emits all Lore attribution/upstream headers, and excludes authorization, x-api-key, and forged x-lore-*./home/byk/Code/opencode-lore/packages/gateway/test/start-gateway-reuse.test.ts tests authenticated gateway reuse: a second startGateway() on an existing explicit port returns owned: false, the same port, and the same managementToken instead of failing with EADDRINUSE.6669 using a directly started local server and a version-2 process record: public health reports "healthy", a wrong token yields { kind: "rejected" }, the right token yields { kind: "authenticated", identity: { pid: process.pid } }, fetchMemoryHealth() succeeds, and startGateway() reuses the server with owned: false.probeGatewayStatus("https://gateway.example.test") calling global fetch on https://gateway.example.test/health and returning "healthy" for HTTP 200.10 ms deadline is classified as "timeout".49152, PID 4242, hosts ["0.0.0.0", "127.0.0.1"], and a 32-character token is reused when no explicit port is requested; the returned handle is unowned, retains the token, and normalizes handle.config.hosts to authenticated host ["0.0.0.0"].127.0.0.2 on a port already occupied by an authenticated Lore gateway bound to 127.0.0.1 still reuses that gateway and returns config.hosts = ["127.0.0.1"]./health response spoofing { status: "ok", service: "lore" } makes probeGateway() return true but does not prove identity; startGateway() rejects it as "not an authenticated lore gateway"."not an authenticated lore gateway" error.writeProcess(record) writes the record and then throws "injected process-record write failure", startGateway() rejects with that error and removes both port-file and process-record state."injected listener close failure", startGateway() reports that discovery evidence was retained, keeps the published port and process record for port 49321, and does not call state-removal functions.9191 is cleared, the first caller owns the newly started gateway and the second returns owned: false with the first caller’s exact port and managementToken.owned: true.