Dashboard › opencode › Distillation
e521dc0e-ecfb-400e-b139-720b7137a107["lore_tm_v1_nVsdYV7LQNJtETZTmOsW4MAJZSUZU-7NLrbD_0hMnjU","lore_tm_v1_Lo1wNBSccQDi_z2Ax9yKEgO_k5PcCVfvOXcfrxtpQZs","lore_tm_v1_07ksaxkJmivhBNfliK25Y-PLLCTOYS7qPNFYLVbXr48","lore_tm_v1_mz3zhZ-8hUH-XAceB6zse2cCzKWapvsU2bvXNlOcRLU","lore_tm_v1_ccUDVBBzmF0DadNQEHT1AsCWqbG4DrPeYiia4_UuaZA"]
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts:239-251 installs an AI SDK "sdk" hook only for Provider.ID.githubCopilot with package "@ai-sdk/github-copilot"; it wraps evt.options.fetch with copilotFetch(...), dynamically imports ../../github-copilot/copilot-provider.js, and assigns evt.sdk = mod.createOpenaiCompatible(evt.options)./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts:253-268 uses the "model.request" session hook because it runs for every route, unlike "http.request", which the AI SDK route bypasses. It sets X-Interaction-Type, X-Interaction-Id, and, outside "conversation-agent", x-initiator: agent./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts:269-280 applies GitHub Copilot HTTP headers only when the provider matches and an x-api-key token exists; it clones and decodes the request body and calls applyHeaders(..., true)./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts:282-302 selects the language-model API explicitly from evt.options.endpoint when possible; otherwise GPT model IDs matching gpt-(\d+) with major version >= 5 use Responses except gpt-5-mini, while other IDs use Chat.normalizeDomain(input) in /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts:307-309 strips a leading http:// or https:// and one trailing slash./home/byk/Code/opencode-v2-pilot/packages/ai/src/route/transport/http.ts:26-31 applies request query overlays with URL.searchParams.set(...)./home/byk/Code/opencode-v2-pilot/packages/ai/src/route/transport/http.ts:33-41 permits request.http.body overlays only on JSON object request bodies, merges them with mergeJsonRecords(...), re-encodes through ProviderShared.encodeJson(...), and otherwise returns InvalidRequest with message "http.body can only overlay JSON object request bodies"./home/byk/Code/opencode-v2-pilot/packages/ai/src/route/transport/http.ts:43-61 constructs JSON request parts by rendering the endpoint, applying request.http.query, applying the body overlay, merging route headers with request.http.headers, and passing method "POST", URL, body text, and headers through Auth.toEffect(...)./home/byk/Code/opencode-v2-pilot/packages/ai/src/route/transport/http.ts:73-99 defines transport id "http-json"; prepare creates a JSON POST and preserves framing/middleware, while execute calls runtime.http.execute(...) and returns framed response events, HTTP context, and the framing body./home/byk/Code/opencode-v2-pilot/packages/ai/src/route/transport/http.ts:101-104 defines SSE JSON transport id "http-json/sse" using Framing.sse.HttpClient.HttpClient / HttpClientResponse.HttpClientResponse at package boundaries, Stream.Stream for streaming when possible, Effect Schema JSON codecs instead of direct JSON.parse / JSON.stringify, direct yielding of yieldable errors in Effect.gen, and Effect.void for intentional void success.src/schema/; src/llm.ts helpers must remain thin constructors, and LLMRequest.update(...) is the sole canonical request-derivation path rather than a duplicate LLM.updateRequest(...).AIError stores only a tagged reason union, derives its message from the reason, and exposes the reason as its cause. Each reason owns its readable message, category fields, and optional body, http, and underlying cause.reason.body is the sole original-response or triggering-event payload field: preserve original text before schema decoding removes fields and never replace the complete event with only its nested error.url, status, and response headers; implementations must not invent status codes or derive a separate request ID from headers. Reclassification and transport recovery must preserve body, HTTP context, and underlying cause, explicitly copying non-enumerable message and cause.Protocol for native body/schema/event state machine, Endpoint for host/path/query, Auth for per-request authentication/signing, and Framing for bytes-to-frames. Route.make(...) composes them.packages/core/src/session/runner/llm.ts owns orchestration, model-request.ts lowers Session state to LLMRequest, and model-transport.ts chooses transport behavior. The AI package must remain independent of Session auth, permissions, plugin hooks, telemetry headers, and runtime selection.StreamOptions; OpenResponsesChannel.transport(...) strips WebSocket-disallowed fields and Route.streamPrepared acknowledges completion only after successful full consumption..configure(...); provider protocol composition must not be hidden in a shared profile registry or nested beneath generic compatible facades.OpenResponses protocol is extended by OpenAIResponses; the baseline never imports the OpenAI extension.Message.system(...) updates are distinct from initial LLMRequest.system: Open Responses lowers them to developer, Anthropic Messages lowers them natively for claude-opus-4-8, and other routes/models lower them in place as escaped <system-update>...</system-update> user-compatible text.LLM.stream(request) and LLM.generate(request) each execute exactly one model call. ToolRuntime.dispatch(...) handles one canonical local tool-call; persistence, continuation, history appending, step counting, and subsequent model rounds remain the enclosing productβs responsibility.ToolRuntime.dispatch(...) has three recoverable tool-error paths: unknown tool name, input failing the toolβs parameters Schema, and a handler returning ToolFailure. Anything else is a defect that fails the stream.providerExecuted: true on matching tool-call and tool-result events and must skip local dispatch. Supported hosted tools include Anthropic web_search, code_execution, and web_fetch, plus OpenAI Responses web_search_call, file_search_call, code_interpreter_call, mcp_call, image_generation_call, and computer_use_call.finish or provider-error, normally after step-finish.{ request, response } interactions. Replay is the default; RECORD=true records fresh cassettes and requires configured environment variables.CI before recording.RECORDED_PROVIDER, RECORDED_PREFIX, RECORDED_TAGS, and RECORDED_TEST; they apply in replay and record modes and can be combined with RECORD=true.bodyEncoding: "base64", preserving binary formats such as AWS event-stream frames./home/byk/Code/opencode-lore-v2 is a TypeScript pnpm workspace requiring Node.js >= 22.5; Lore uses SQLite in WAL mode with FTS5, stored at ~/.local/share/lore/lore.db.@loreai/core at packages/core/, @loreai/gateway at packages/gateway/, @loreai/opencode at packages/opencode/, and @loreai/pi at packages/pi/; Core is shared by Gateway, OpenCode, and Pi.temporal_messages with FTS5 and a distilled=0/1 flag; its chunk separator is \x1f.resetOrphans() β undistilled-message retrieval β detectSegments() β distillSegment(), with a maximum of 16K tokens per segment. When generation-0 count exceeds 20, metaDistill() consolidates into generation 1+, while generation-0 segments remain searchable but leave the in-context prefix.packages/core/src/ltm.ts use categories decision, pattern, preference, architecture, and gotcha; fields are id (UUIDv7), project_id, category, title, content (maximum 1200 characters), confidence (0.0-1.0), and cross_project.packages/core/src/curator.ts; 2. regex-based pattern extraction in packages/core/src/pattern-extract.ts; 3. .lore.md import through packages/core/src/agents-file.ts; 4. curator consolidation when entries exceed maxEntries (25).packages/core/test/setup.ts, never the production DB.pnpm test, pnpm run typecheck, pnpm run lint, and pnpm run format:check; formatting is applied with pnpm run format, and lint autofixes use pnpm run lint:fix.CHANGELOG.md; Sentry Craft handles both automatically.gh workflow run release.yml -f version=auto or an explicit version such as gh workflow run release.yml -f version=0.23.0.scripts/bump-version.sh, generates the changelog from conventional commits, creates and pushes release/X.Y.Z, runs CI to build npm tarballs, standalone binaries, and delta patches, then uses a Craft "publish" issue labeled accepted to initiate npm OIDC publishing and a GitHub Release.SYNCED_TABLES via packages/core/test/sync-registry-contract.test.ts, MIGRATIONS via db.test.ts schema-version and migration-specific tests, and AGENTS via agents.test.ts.packages/core/src/sync-data.ts via assertSyncInvariants, and sequence properties in packages/gateway/test/sync.property.test.ts.syncedColumns PRAGMA cache should be frozen so accidental mutation throws a TypeError in strict mode instead of silently corrupting shared state.db().query monkeypatches are shadowed by Loreβs tracing Proxy; SQL-counting tests must use log.registerSink({ withDbSpan }).pnpm test, pnpm run typecheck, pnpm run lint, and pnpm run format:check, verify property-test stability across 10 runs, confirm a hash-verified clean working tree, and report per-point PASS / FAIL / CONCERN / MUST-FIX verdicts with file:line evidence plus an overall MERGE / DO-NOT-MERGE.