Dashboard › opencode › Distillation
dcbfe897-83f6-46ce-bb14-4c73cacbdfcd["lore_tm_v1_UH1DKKoohNgPmYGeXdIOszhDpquE1rkqIfcRu3pP-JE","lore_tm_v1_rbpLvBQ2Ajo33Tm0EsvIuwESZp46zS6UFpEWIQo3L2Q","lore_tm_v1_Umd06xeHzT0bfYeNF5-D4G6lvOORXrodlNj883Ii898","lore_tm_v1_OVScxK8fi1ks3Q9A2Zcgp5y46lTNbh7XeoUtDHQhpvg","lore_tm_v1_dQl0-KrKROLjb9o_0H-O4To5mUTHAKBRm_1ZqfQ95pA","lore_tm_v1_cDYJUyILvrOuAG60BLd0x-sFCxVB3GTrJFPFUiUb68A","lore_tm_v1_oiiyOiYyjMGXEFo8jG26rtk_8C1NAJ3t0NB11Y8TG9Y"]
/home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:11-18 defines SHELL_OUTPUT_GLOB as path.join(data, "shell", "*", "*"), TOOL_OUTPUT_GLOB as path.join(data, "tool-output", "*"), re-exports Agent.ID, Agent.Name, and Agent.Color, and sets defaultID = ID.make("build")./home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:27-52 defines Selection with id and optional info; mutable state Data contains agents: Map<ID, Types.DeepMutable<Info>> and optional default; Editor supports list, get, default, update, and remove; Interface adds effectful get, resolve, select, and list; Service is registered as "@opencode/Agent"./home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:54-91 creates default external-directory permissions allowing shell output under global.data/shell/*/*, tool output under global.data/tool-output/*, temporary files under global.tmp/*, and configuration files under global.config/*. New agents begin with Info.default(id) plus these permissions; updates force current.id = id; state changes publish Agent.Event.Updated./home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:92-104 considers an agent selectable only when it exists, is not mode "subagent", and is not hidden. Default selection order is: 1. configured default if selectable; 2. agent ID "build" if selectable; 3. first selectable agent in map iteration order./home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:106-129 implements agent lookup behavior: resolve(id) returns the exact configured agent when an ID is supplied and otherwise the selected default; select(id) preserves an explicitly requested ID even if no info exists, while no-ID selection falls back to defaultID ("build"); list() places the selected default first and leaves the remaining agents in map order./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:18-36 defines PluginSupervisor.resolve(modules, pre, post, operations, install, running). Selectors match exact IDs, "*", or a trailing-.* prefix; definitions begin as pre followed by post; resolution tracks enabled IDs, package generations, pending package targets, and failed plugin information./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:38-56 applies plugin source operations in order. "remove" with target "*" clears failures and disables matching plugins; add operations enable already matched definitions; targets are treated as plugin selectors when matched, equal to "*", end in .*, or begin with "opencode."./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:58-89 loads unmatched plugin targets through modules.load(operation, { install }). Load causes are logged with a random reference err_${crypto.randomUUID().slice(0, 8)}; PluginModule.LoadError exposes its message while other failures report "Plugin failed to load". Pending targets are deferred, successful revisions replace prior package generations, and failed revisions retain the package generation already resolved or present in running./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:91-113 orders enabled plugins as pre, then package plugins, then post. Duplicate IDs retain the first occurrence in boot order; later occurrences become failed inventory entries with error Duplicate plugin ID: ${plugin.id}, preserving source and server/plugin feature flags so duplicate registry activation cannot drop the entire generation, including built-ins./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:116-137 initially acquires registry.hold(), registers finalizers to release it and close the registry, tracks the last running package generation per target, and maintains packages, running, outdated, updating, generation, and observed state./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:138-174 activation combines plugins in boot order: internal.pre built-ins with revision "internal", then all SDK plugins, then all instance plugins, followed by internal.post built-ins. Instance plugins come last so later container writes let explicit instance choices override globals. It resolves and activates all locally available plugins before installing missing packages, then resolves pending packages with install: true, reapplies when needed, and stores resolved.packages as running./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:156-193 annotates package sources with outdated: true and/or updating: true from supervisor state. Update availability checks run with { concurrency: "unbounded" }; stale results are discarded when their activation generation is no longer current, and changed outdated state triggers a registry reapplication in a scoped, immediately started fiber./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:196-237 starts source consumers before activation and uses Queue.sliding<number>(1) to retain the latest observed request. notify increments observed, reacquires registry.hold() when needed, and queues the sequence. Watched sources are configuration changes, module changes, a repeated 24 hours sleep, bus events Event.Updated and SdkPlugins.Updated, and package update changes restricted to currently tracked targets./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:225-237 runs initial plugin activation immediately with Stream.succeed(0) and applies a "100 millis" debounce only to later queued requests. One consumer serializes both; activation failures log "failed to reload plugins", and readiness is released only when observed === target./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts:241-258 declares node dependencies in order: Plugin.node, SdkPlugins.node, InstancePlugins.node, ConfigPluginSource.node, PluginUpdate.node, Bus.node, Npm.node, Watcher.node, and PluginInternal.requirements. pluginSource(target) maps absolute targets to { type: "local", path: target } and other targets to { type: "package", target }; the location node is named "plugin-supervisor"./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts:89-99 Plugin.activate(plugins, failures = []) normalizes every generation ID with Plugin.ID.make() and dies with Duplicate plugin ID: ${definition.id} if the supplied generation contains duplicates./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts:100-123 activation acquires a readiness hold() around work protected by lock.withPermit. It records discovered failures, computes the first changed position by plugin ID or revision, refreshes metadata for the unchanged prefix, and if definitions and active slots are otherwise identical, publishes Plugin.Event.Updated only when serialized inventory changed./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts:125-175 batches changed activation state. Because registrations are ordered by setup, only the unchanged prefix remains alive; changed prior slots are removed in reverse order and healthy activation scopes are closed with Scope.close(slot.activation.scope, Exit.void). A reordered plugin whose same revision already failed is retained without retry. New definitions are loaded, and if loading fails, a healthy prior activation is reloaded as fallback while retaining the new definition and its error; failed fallback restoration logs "failed to restore plugin; deactivating". Inventory is rebuilt and Plugin.Event.Updated is published./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts:182-206 continuously consumes pendingFailures, logs "disabled plugin after transform failure" with plugin ID, failure state, reference, and cause, then refreshes inventory and state under the activation lock. A queued failure is tied to its exact activation, so an old item cannot disable a replacement; failed state refresh logs "failed to refresh state after disabling plugin"./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts:207-231 schedules disabled-plugin scope cleanup even if an inventory observer fails. Scope.close(item.scope, Exit.void) catches cleanup causes, logs "failed to clean up disabled plugin", and runs via Effect.forkScoped({ startImmediately: true }); non-interruption reporting failures log "failed to report disabled plugin"; item.release is always ensured./home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts:238-256 registry close runs under the lock, sets closed = true, clears pending work, opens readiness with ready.openUnsafe(), clears active slots, and invokes State.shutdown(Scope.close(scope, exit)). The service exposes activate, close, awaitActivation: ready.await, hold, and list./home/byk/Code/opencode-lore-v2, Vitest v4.1.8 completed 2 test files with exactly 35 tests passing, 0 failures; duration was 1.23s with transform 1.32s, setup 1.54s, import 85ms, tests 194ms, and environment 0ms./home/byk/Code/opencode-lore-v2, Vitest v4.1.8 completed 3 test files with exactly 25 tests passing, 0 failures; duration was 3.89s with transform 3.96s, setup 1.50s, import 6.30s, tests 229ms, and environment 0ms./home/byk/Code/opencode-lore-v2 working tree contains modified files packages/core/src/fetch-interceptor.ts, packages/core/src/index.ts, packages/opencode/package.json, packages/opencode/src/index.ts, packages/opencode/src/internal.ts, packages/opencode/test/internal.test.ts, and pnpm-lock.yaml./home/byk/Code/opencode-lore-v2 working tree contains newly added files packages/core/test/fetch-interceptor-request.test.ts, packages/opencode/script/build.ts, packages/opencode/src/server-runtime.ts, packages/opencode/src/server.ts, packages/opencode/test/package.test.ts, packages/opencode/test/server-runtime.test.ts, and packages/opencode/test/server.test.ts.packages/core/src/fetch-interceptor.ts 135 insertions/115 deletions; packages/core/src/index.ts 3/0; packages/core/test/fetch-interceptor-request.test.ts 163/0; packages/opencode/package.json 15/2; packages/opencode/script/build.ts 22/0; packages/opencode/src/index.ts 7/15; packages/opencode/src/internal.ts 13/0; packages/opencode/src/server-runtime.ts 222/0; packages/opencode/src/server.ts 79/0; packages/opencode/test/internal.test.ts 10/0; packages/opencode/test/package.test.ts 48/0; packages/opencode/test/server-runtime.test.ts 159/0; packages/opencode/test/server.test.ts 316/0; pnpm-lock.yaml 1701/74.