Dashboard › opencode › Distillation
c4351247-f92f-4241-8959-de5d1c6af82a["lore_tm_v1_NB3tUgODiHN55szooQPcTq1_c4ZGDL1CNcwXsaFMmEI","lore_tm_v1_cE-BjiTqdViQszF8GQ-fAB0N909YauSoixBlJOGnSsI","lore_tm_v1_4k-OAXbb7IayDk0aQXxAUqSYgy-ytWr3HI0MYZ6NJOI","lore_tm_v1_9TBEKl3YusXXqLYw2v8C4XHP8PfPqnGEKN_Kud4SWpQ","lore_tm_v1_3op0QboP4HKm1AOrIDp0U86HRlqOddeem9nO4Wn-Iic","lore_tm_v1_8QLvuIXVBXDmfv38WOTpmkOTMSmTOHcGvAoLejlL1f0","lore_tm_v1_c7-joXdlqjZOxm_4QSKmrxg5UrY71Ty6k2HYrppZ32w"]
/home/byk/Code/opencode-lore/packages/gateway/src/pidfile.ts, legacy numeric PID files cannot establish process ownership and must never be signalled; readGatewayProcessFile() therefore returns null for them.readGatewayProcessFile() reads gateway.pid with readRuntimeFile(PIDFILE_NAME, { ownerOnly: true }), parses JSON, and returns a valid GatewayProcessRecord or null.inspectGatewayProcessFileAt(path?) reports malformed JSON as "process record is malformed", invalid record fields as "process record has invalid fields", records without generation binding as "legacy process record lacks process-start identity", ENOENT as { state: "absent" }, and other read/security failures as "process record is unreadable or unsafe: ${String(error)}".readFileAtClaim(path) accesses a renamed PID-file claim through readRuntimeFile(basename(path), { ownerOnly: true }), reusing runtime-file validation.inspectGatewayProcessFile({ requireLoopbackHosts: true }) rejects any authenticated process record containing a non-loopback host with reason "process record contains a non-loopback listener".isProcessAlive(pid) uses process.kill(pid, 0); it returns true for a live process and for EPERM, but false for ESRCH and other errors./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/plugin.ts defines Promise-plugin Context with app, location, options, and domains agent, aisdk, catalog, command, event, integration, mcp, permission, reference, rpc, session, shell, skill, storage, tool, vcs, websearch, and worktree; it also exposes generate: GenerateApi, plugin: Pick<PluginApi, "list">, and experimental.terminal: Pick<OpenCodeClient["experimental"]["persistentPty"], "read">.Cleanup = () => Promise<void> | void; Plugin requires id: string and setup(context) returning Promise<Cleanup | void> | Cleanup | void; define(plugin) returns the plugin unchanged.@opencode/client/effect/api, must not redefine functions already present there, and may add only functions meaningful in plugin context.HttpApi in /home/byk/Code/opencode-v2-pilot, run bun run generate from packages/client; generated client files must not be edited directly.sdk composes Client, Core, and Server.packages/core, packages/cli, packages/server, packages/protocol, packages/schema, and related generated client surfaces when required./home/byk/Code/opencode-v2-pilot does not use Changesets; .changeset files must not be added.v2. New branches/worktrees should default to v2, or origin/v2 if local v2 is unavailable; pull requests should target v2 unless explicitly instructed otherwise. Local main may not exist, so diffs should use v2 or origin/v2.feat/ or fix/; examples include session-recovery, fix-scroll-state, and regenerate-sdk.type(scope): summary; valid types are feat, fix, docs, chore, refactor, and test, with optional scopes such as core, opencode, tui, app, desktop, sdk, or plugin.bun run dev:live from a development worktree, optionally with a project directory. It discovers the server using opencode2 service status, injects the credential from opencode2 service get password, and uses the dev TUI storage channel. Prefer it over plain bun run dev; explicit --server warns and continues when client/server versions differ.packages/tui/src/feature-plugins/system/storybook, registration in index.tsx, the real production component rather than a visual copy, locally contained side effects, meaningful state keybindings listed in StoryFooter, and a reset command when state combinations may become confusing.OPENCODE_STORY=<story-id> bun run dev:live; exercise narrow and wide terminal sizes when layout is relevant.theme.hue values and unrelated semantic tokens must not be repurposed; text.feedback and background.feedback are only for outcome/status feedback, formfield states are for form-control text, ordinals, and selection markers, and action states are for actions./home/byk/Code/opencode-v2-pilot: keep logic in one function unless composable/reusable; validate unknown values once at the owning boundary; avoid speculative single-use helpers; avoid try/catch where possible and avoid any; prefer Bun APIs, inference, functional array methods, const, ternaries/early returns, dot notation over unnecessary destructuring, and fewer variables by inlining one-use values.src/config, new modules must follow the self-export pattern such as export * as ConfigAgent from "./agent".yield* (yield* Foo.Service).bar() must not be used.import { foo as bar } from "..." or resolve as pathResolve.import("...") references such as Schema.declare<import("@opencode/plugin/effect/plugin").Plugin["effect"]>. Only a genuine name collision with no other option permits an aliased type import such as import type { Plugin as PluginDefinition } from "...", and even then it is strongly discouraged.import * as Foo from "..." or import type * as Foo from "..."; for namespace-style usage, import the moduleβs own exported namespace by name, e.g. import { Project } from "@opencode/core/project" and use Project.ID.await import("./module").then((mod) => mod.value()) or (await import("./module")).value().Effect from helpers that only perform synchronous parsing, validation, or option construction.Schema.UnknownFromJsonString and Schema.decodeUnknownOption over manual JSON.parse wrapped in Effect.try.project_id: text().notNull() and created_at: integer().notNull(), avoiding redundant explicit column-name strings.globalThis.*, unless no other option exists; tests must exercise actual implementation rather than duplicating implementation logic./home/byk/Code/opencode-v2-pilot repository root because of the do-not-run-tests-from-root guard; run them from package directories such as packages/core.bun typecheck from package directories, for example packages/core; never run tsc directly.Session.prompt(...) publishes session.inbox.enqueued, its projection inserts one durable session_inbox row, and then advisory SessionExecution.wake(sessionID) is scheduled unless resume: false; session.inbox.delivered consumes the inbox row and inserts the visible message in the same transaction.SessionExecution must stay process-global and Session-ID-based. Its local implementation owns the process-local coordinator and discovers placement through SessionStore plus LocationServiceMap.get(session.location) only when a drain starts; no layer should take a Session ID.SessionRunner, model resolution, tool registry, permissions, and filesystem must remain Location-scoped. Omitted Location.workspaceID means implicit-local placement; explicit workspace identity is reserved for future placement semantics.llm.stream(request) call per Physical Attempt and reload projected history before durable continuation. A logical Step may use generic pre-output retries, one full-context retry after continuation rejection, incomplete-stream continuation, or one overflow-compaction rebuild; generic retries retain the logical step number and do not consume another agent-step allowance.SessionRunCoordinator joins explicit same-Session resumes, coalesces prompt wakeups, and permits different Sessions to run concurrently."provider turn" or use bare "turn" for one call; "turn" is reserved for the future assistant-turn unit spanning all steps from prompt promotion until the Session would go idle.src/instructions; instruction producers stay with observed domains; Session owns History selection plus InstructionState and InstructionEntry persistence. The runner composes built-ins, discovery, guidance, and entries explicitly in loadInstructions; there is no instruction registry./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts adapts Promise-plugin cleanup using Effect.acquireRelease: acquisition runs plugin.setup(context2) through Effect.promise(() => Promise.resolve(...)), and release invokes a returned cleanup similarly or uses Effect.void.packages/plugin/src/promise/adapter.ts, Promise session methods create, get, switchAgent, switchModel, prompt, generate, command, synthetic, interrupt, rename, move, wait, and context are adapted from SessionEndpoints; session and shell hooks wrap callbacks with Effect.promise(() => Promise.resolve(callback(event))).attempt<A>(evaluate) in packages/plugin/src/promise/adapter.ts uses Effect.tryPromise({ try: evaluate, catch: (cause) => cause }).executePromiseTool currently accepts input: any, forwards tool progress via Effect.runPromise(context.progress(update)), converts TypedFailure into Tool.Error, derives feedback from error.error.feedback, Error.message, or String(error.error), and treats other failures as defects with Effect.die(error).startGateway in /home/byk/Code/opencode-lore found exactly 60 matches, including callers/tests in packages/gateway, packages/pi, packages/opencode, and packages/core./home/byk/Code/opencode-lore/packages/pi/src/internal.ts resolves gateways in this order: (1) reachable LORE_REMOTE_URL; (2) reachable LORE_GATEWAY_URL; (3) the port from dynamically imported readPortFile() followed by KNOWN_GATEWAY_PORTS; each candidate is probed before use.startInProcess() in packages/pi/src/internal.ts dynamically imports @loreai/gateway, calls startGateway({ quiet: true, local: true }), returns http://127.0.0.1:${handle.port}, logs reuse when handle.owned is false, and on failure logs "pi: failed to start gateway in-process" and returns null.Bun.serve() to node:http.createServer(); startGateway() handles port fallback 3207 β 5673 β random.sessionIDFor(sessionFile) returns pi-ephemeral-${process.pid} when no session file exists; otherwise it returns pi-${sha256(sessionFile).slice(0, 24)}.gatewayAccessHeadersForRemote(gatewayBase, env) injects { [GATEWAY_AUTH_HEADER]: LORE_GATEWAY_AUTH_TOKEN } only when normalized LORE_REMOTE_URL exactly matches the selected normalized gateway base and a token exists.packages/pi/test/real-runtime.e2e.test.ts, extension.e2e.test.ts, no-tui-output.test.ts, tui-silence.test.ts, gateway-discovery.test.ts, internal.test.ts, and packages/pi/src/internal.ts.