Dashboard › opencode › Distillation
75be14d6-1961-4fda-a393-81f1d4d3d77f["lore_tm_v1_ydoM5_xV1UbvduCmDpJA66oZzylfJd6QYua9x_Fz5mg","lore_tm_v1_5REfhhXJ6jpZa4PZY7SGznpe1XpanJ4vX8QHfFQbCSw","lore_tm_v1_DSKdtvw3OYi1zDM5Y-a_wWIBwECn59gUeOIxm7M7-es","lore_tm_v1_XJ94Lu7v-kYrHWrRa0P-T3n676f4SfBDWdJD29k2cfo","lore_tm_v1_bBXiAFCsDoIGhLMsxqdNLpnUvs6PSsIbhAEH1J0vNmg","lore_tm_v1_fiZwWv328_L2mksgLAsvAfmgUUDPt-Vf66QYVBF3hfI","lore_tm_v1_CQfUyRSwBeqZoN8vcVBw2fjmtVAGLrMJ77zKUEmNol4","lore_tm_v1_IZVXLY-QR8Gl9wVGzyKHmYNsDuV6QzN2NRZCpQH0E9Y","lore_tm_v1_m_fVwS2jFF1FyqkQDSAGlziMi6poMicPPkgDbdGBmTM","lore_tm_v1_z7m0KQUyyI5EtL2TxEDW6mLT95usrdFTkLcxquOm4vQ","lore_tm_v1_HSnuKJE_aRGNZo0cn869SvX0UP3cINK_A9FBbNEhl2E","lore_tm_v1_M-N2CKXE0Al1knwXUrA0q6V51-VdtqLOGMXCX5mM4gM","lore_tm_v1_VDATN0IUoZLoaWbQ0X4PhR3PHCUxpZeO_tOce0vwAMk","lore_tm_v1_TOMAXepDbrhEXsoN4nzNGKY7KQpstBTVQVtTXeTSGLk"]
/home/byk/Code/opencode-lore/packages/opencode/src/index.ts defines KNOWN_GATEWAY_PORTS = [3207, 5673]; resolveGatewayUrl() checks LORE_REMOTE_URL first, then LORE_GATEWAY_URL, then a dynamically imported @loreai/gateway port file, then known default ports, probing each candidate with probeGateway() and returning null when none is reachable.resolveGatewayUrl() strips one trailing slash from LORE_REMOTE_URL and LORE_GATEWAY_URL; an unreachable remote logs that it is falling through to local discovery rather than preventing local startup.startInProcess() dynamically imports startGateway from @loreai/gateway with /* webpackIgnore: true */, calls startGateway({ quiet: true, local: true }), returns http://127.0.0.1:${handle.port}, logs reuse when handle.owned is false, and records failures in lastGatewayStartError.processInitDone, processLoreActive, processLoreBase, and memoized loreInitPromise as process-wide state so concurrent LorePlugin calls do not race through gateway probe/start.lastSeenAt together in projectState, keyed by ctx.project.id, while currentProject is only a fallback for requests bypassing chat.headers.SESSION_STATE_TTL_MS = 24 * 60 * 60 * 1000; stale project entries are opportunistically reaped when registering a project. The code estimates each entry at approximately 200 bytes and 100 projects at 20 KB.thisProjectPath with discoverWorkspaceRoot(ctx.worktree || ctx.directory) and reuses the cached git remote only when the cached projectPath equals thisProjectPath; otherwise it calls getGitRemote(thisProjectPath) ?? "".sessionParent cache maps session.id to immutable { parentID, lastSeenAt }, uses the same 24-hour TTL as project state, and caches successful lookups including null for primary sessions.resolveParentSession() calls client.session.get({ path: { id: sessionID } }); a non-null parentID identifies an OpenCode Task child session and is forwarded as x-parent-session-id so the Lore gateway can size LTM injection for sub-agents under issue #1300.null and can be retried on the next turn instead of permanently classifying a real sub-agent as primary.chat.headers is cached and never blocks or throws on failure.isInertTestEnv() keeps the plugin inert when NODE_ENV === "test" or any process.argv entry includes .test., unless LORE_OPENCODE_FORCE_ACTIVE === "1"; forced-active tests retain test logging/database behavior while exercising discovery, interception, and routing through controlled LORE_GATEWAY_URL, mirroring LORE_PI_FORCE_ACTIVE.LORE_DISABLED values "1" and "true" as disabled and skips Lore initialization; otherwise it probes for an existing gateway before starting one in-process.log.silenceStderr() outside inert tests because OpenCode owns a full-screen TUI and any stdout/stderr byte corrupts rendering; the silence flag is process-global via globalThis, including the in-process gateway’s bundled copy of core, while logs still reach the file and Sentry sink visible through lore logs.log and is NEVER a raw stderr write, because OpenCode owns a full-screen TUI and any stray byte corrupts it.Lore failed to start — memory features are unavailable. and includes lastGatewayStartError when available; errors matching not found|not exported|cannot find module additionally recommend pnpm --filter @loreai/gateway run bundle or run build for a development checkout, while absent detail recommends ensuring @loreai/gateway is installed.surfaceGatewayUnavailable(ctx.client, msg) for non-test startup failures so a failed gateway is visible through a TUI-safe toast rather than becoming a silent no-op, including the referenced Daniel Windows report.config hook sets cfg.compaction = { auto: false, prune: false }, because the gateway handles compaction.config hook deep-preserves existing cfg.agent entries and adds three hidden worker agents in mode: "subagent": lore-distill with description Lore memory distillation worker; lore-curator with description Lore knowledge curator worker; and lore-query-expand with description Lore query expansion worker.mode: "subagent" is required for hidden: true to take effect; OpenCode otherwise defaults agents to mode: "all", exposing them in both the primary Tab picker and the @-mention/skill list.chat.headers hook injects gatewayAccessHeadersForRemote(gatewayBase), stable x-lore-session-id = input.sessionID, x-lore-agent = input.agent, optional x-parent-session-id, request-specific x-lore-project, request-specific x-lore-git-remote, and runtime provider identifier x-lore-provider.x-session-affinity, whose nanoid is regenerated per process.input.provider to Record<string, unknown> because OpenCode’s plugin SDK types omit .id although it exists at runtime.LORE_UPSTREAM_${providerID.toUpperCase().replace(/-/g, "_")} for providers such as vllm, ollama, and llamacpp; a present value becomes x-lore-upstream-url only when that header is not already set.LORE_UPSTREAM_EXTRA_HEADERS parser splits on CRLF or LF, trims lines, ignores empty or malformed lines, splits each valid line at its first colon, and forwards the literal name/value only when shouldForwardUpstreamExtraHeader(name) permits it; these headers support corporate proxies, LiteLLM, Cloudflare AI Gateway, authentication, and team routing.x-lore-project from currentProject.path and emits x-lore-git-remote only from the same stored currentProject object—never a remote left over from a different project’s plugin call.installFetchInterceptor() only once on first process initialization when Lore is active, logs routing through ${gatewayBase} and dashboard: ${gatewayBase}/ui, and supplies per-request gateway access plus paired project fallback headers through getHeaders().e.stack || e.message through log.error("init failed: ...") before rethrowing, preserving the root cause in file/Sentry logs even if OpenCode’s plugin loader catches and swallows the error./home/byk/Code/opencode-lore/packages/opencode/src/index.ts export contract allows only named LorePlugin plus the same-reference default export; OpenCode’s legacy loader invokes every function export as a plugin and throws on non-function exports. This contract is guarded by the plugin entry module export shape test in test/index.test.ts./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/plugin.ts defines plugins as { readonly id: string; readonly setup: (context: Context) => Promise<Cleanup | void> | Cleanup | void }, where Cleanup = () => Promise<void> | void; define(plugin) returns the plugin unchanged.Context exposes app, location, options, agent, aisdk, catalog, command, event, experimental.terminal.read, integration, mcp, generate, permission, plugin.list, reference, rpc, session, shell, skill, storage, tool, vcs, websearch, and worktree./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts defines SessionRequestKind in exact order as "primary" | "compaction" | "title" | "generate" so auxiliary requests can be distinguished from the main agent loop while sharing session hook identity.prompt, context, "model.request", "http.request", "http.response", and retry.SessionModelRequest exposes readonly sessionID, agent, model, and kind, plus mutable optional baseURL and mutable headers: Record<string, string>.SessionHttpRequest exposes readonly session/model identity and request kind with mutable request: Request; SessionHttpResponse exposes the readonly originating request with mutable response: Response.SessionContext exposes mutable system, messages, tools, generation, and providerOptions; unset generation fields retain route and model defaults.SessionRetryDecision = { retry: false } | { retry: true; delay: number } and gives the hook readonly error and attempt with mutable decision.SessionDomain includes create, get, switchAgent, switchModel, prompt, generate, command, synthetic, interrupt, rename, move, wait, context, and hook: ModelHooks<SessionHooks>./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/registration.ts defines hook callbacks as synchronous or async and returns Promise<Registration> where Registration.dispose() returns Promise<void>.ModelHooks accepts optional ModelHookOptions only for hook specs containing a readonly model; ModelHookOptions.providerID limits a hook to one provider, while unscoped hooks apply to every provider.Transform<Input> has type (callback: (input: Input) => void) => Promise<Registration>.ses_f7a816c46ffeP0EReG5BG666nw and ses_f7a81495affeiTvKs84r8Ec0Yh; both were still running, and their task instructions prohibited polling, sleeping for progress, status requests, or duplicate work on their files/topics./home/byk/Code/opencode-lore/packages/opencode/package.json identifies @loreai/opencode version 0.40.0, ESM, license FSL-1.1-Apache-2.0, description Three-tier memory architecture for OpenCode — distillation, not summarization, raw TypeScript entry ./src/index.ts, and public npm access.@loreai/opencode package exports ./src/index.ts for types, bun, and default; scripts are typecheck: tsc --noEmit and build: echo '@loreai/opencode ships raw TS — no build step needed'.@loreai/opencode dependencies are @loreai/core: workspace:* and @loreai/gateway: workspace:*; peer dependency is @opencode-ai/plugin >=1.1.0; development dependencies include @opencode-ai/plugin ^1.1.39, @opencode-ai/sdk ^1.1.39, and @types/bun ^1.2.0.@loreai/opencode published files are src/, README.md, and LICENSE; repository is git+https://github.com/BYK/loreai.git, directory packages/opencode, author BYK./home/byk/Code/opencode-lore/package.json identifies private ESM workspace lore-monorepo, package manager pnpm@10.28.0, Volta Node 24.16.0, Volta pnpm 10.28.0, workspaces packages/*, and root entry ./packages/opencode/src/index.ts.typecheck: pnpm -r run typecheck, test: vitest run, pretest: pnpm --filter @loreai/gateway run bundle, test:coverage: pnpm --filter @loreai/gateway run bundle && vitest run --coverage, build: pnpm -r run build, lint: oxlint --type-aware, lint:fix: oxlint --type-aware --fix, format: oxfmt, format:check: oxfmt --check, evals: vitest run --config vitest.evals.config.ts, premutation: pnpm --filter @loreai/gateway run bundle, mutation: stryker run, and postinstall: pnpm --filter @loreai/gateway run build.esbuild, onnxruntime-node, and sharp; patches @sentry/node@10.56.0 via patches/@sentry__node@10.56.0.patch; and pins development tooling including TypeScript ^5.8.0, Vitest ^4.1.7, tsx ^4.22.3, oxfmt 0.58.0, oxlint 1.73.0, and oxlint-tsgolint 0.24.0./home/byk/Code/opencode-lore/packages/core/src/index.ts publicly exports installFetchInterceptor, shouldIntercept, and FetchInterceptorConfig from ./fetch-interceptor.main, while keeping the existing .lore.md change and all pilot review files separate.main at change uutomtup, commit 42911412, description fix(gateway): preserve large recall continuations (#1730).feat/1599-shutdown-vector-pool-close at aa419693, feat/claude-code-desktop at 25448de0, feat/cli-mutations at a4cfc8fd, feat/eval-provider-agnostic-harness at b90faa3d, fix-recall-diagnostics at 31aaf342, fix-stream-large-responses-request-bodies at 9dc93430, fix/early-flush-transport-retry at 3190b328, fix/gateway-streaming-hardening at 747b8ec2, fix/lint-incremental-cache at 3ad20944, fix/recall-continuation-cap at e72ef77b, fix/responses-recall-continuation at conflict/divergent change sqpltnqu/0 commit 1293f9ff, fix/vec0-dimension at 3f384375, perf/vec0-orphan-gc at d03d7d04, and deleted bookmark fix/entity-destructive-policy whose remote @origin points to 258be924.lore-final-correctness-v2 in conflict at commit 88cfb983, lore-final-security-v2 divergent at commit 2c71308f, and a sequence of isolated correctness/security review workspaces extending through lore-final-correctness-v27 and lore-final-security-v27./home/byk/Code directory includes the relevant repositories/worktrees opencode, opencode-lore, opencode-v2-pilot, loreai, lore-import-autofix, opencode-lore-codex-terminal, opencode-lore-entity-policy, opencode-lore-live, opencode-lore-recall-continuation, opencode-lore-recall-diagnostics, opencode-lore-remote-management, opencode-lore-shutdown, opencode-lore-stable, opencode-lore-stream-audit, and opencode-lore-vec-delete.