Dashboard › opencode › Distillation
e6def917-6bfa-42a8-bd7d-f49a6d8ecef0["lore_tm_v1_V9xUzDIQkhxCZcqgJaC1jtLXXXeklOA1iGUCkaQTD-k","lore_tm_v1_VZlTS7tuHYc2jJOGqcgZTx5bUknFPhs6dquGeHtXNE0","lore_tm_v1_I1tjn4EI51jlaKiX46hSw0gie_aWrw1aNZYwZLYbouI","lore_tm_v1_LwetbZZ8AAsXZ4mmcgd68X-kWqGvOV_LDqNllNoWVSI","lore_tm_v1_I469v7EPj2nyjdcBoyr1WU2FRNy25wmRLzf3l_f2fac"]
Date: Sep 15, 2026
packages/opencode/src/effect/app-runtime.ts defines AppLayer with AppNodeBuilderV1.build(LayerNode.group([...])); nodes appear in this exact order: 1. Npm.node, 2. FSUtil.node, 3. Database.node, 4. Auth.node, 5. Account.node, 6. Config.node, 7. Git.node, 8. Storage.node, 9. Snapshot.node, 10. Plugin.node, 11. ModelsDev.node, 12. Provider.node, 13. ProviderAuth.node, 14. Agent.node, 15. Skill.node, 16. Discovery.node, 17. Question.node, 18. Permission.node, 19. Todo.node, 20. Session.node, 21. SessionProjector.node, 22. SessionStatus.node, 23. BackgroundJob.node, 24. RuntimeFlags.node, 25. EventV2Bridge.node, 26. SessionRunState.node, 27. SessionProcessor.node, 28. SessionCompaction.node, 29. SessionRevert.node, 30. SessionSummary.node, 31. SessionPrompt.node, 32. Instruction.node, 33. LLM.node, 34. LSP.node, 35. MCP.node, 36. McpAuth.node, 37. Command.node, 38. Truncate.node, 39. ToolRegistry.node, 40. Format.node, 41. InstanceStore.node, 42. Project.node, 43. Vcs.node, 44. Workspace.node, 45. Worktree.node, 46. Installation.node, 47. ShareNext.node, 48. SessionShare.node.packages/opencode/src/effect/app-runtime.ts completes AppLayer with .pipe(Layer.provideMerge(AppNodeBuilderV1.build(Ripgrep.node)), Layer.provideMerge(Observability.layer)).packages/core/src/**/*.sql.ts; migrations live in packages/core and are applied by core.bun dev from packages/opencode starts the live interactive TUI and must not be left as a blocking foreground command when inspection is needed. Use tmux new-session -d -s opencode-dev 'bun dev', inspect with tmux capture-pane -pt opencode-dev, and stop with tmux kill-session -t opencode-dev.export namespace Foo { ... }; it prevents tree-shaking and breaks Nodeβs native TypeScript runner. Use flat top-level exports plus a self-reexport such as export * as Foo from "./foo". For a single-namespace index.ts, use export * as Foo from ".".src/session/ and src/config/ keep each sibling in its own self-reexporting file and must not add a barrel index.ts; consumers import specific siblings such as @/session/retry and @/session/status because barrels evaluate every sibling, defeating tree-shaking and slowing module load.Effect.gen(function* () { ... }); use Effect.fn("Domain.method") for named/traced effects and Effect.fnUntraced for internal helpers; pass pipeable operators directly to Effect.fn/Effect.fnUntraced rather than adding unnecessary outer .pipe() wrappers; use Effect.callback for callback APIs; use Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0); use DateTime.nowAsDate instead of new Date(yield* Clock.currentTimeMillis) when a Date is needed.Schema.Class for multi-field data, branded schemas via Schema.brand for single-value types, Schema.TaggedErrorClass for typed errors, and Schema.Defect instead of unknown for defect-like causes. In Effect.gen/Effect.fn direct early-failure branches, prefer yield* new MyError(...) over yield* Effect.fail(new MyError(...)).makeRuntime from src/effect/run-service.ts, returning { runPromise, runFork, runCallback } backed by a shared memoMap that deduplicates layers.InstanceState from src/effect/instance-state.ts for per-directory or per-project state that needs cleanup. It uses a ScopedCache keyed by directory, so each open project gets separate state and disposal cleanup; services that must not be shared between two open directories require InstanceState.InstanceState implementation rules: perform work directly in the InstanceState.make closure because ScopedCache provides run-once semantics; do not add fibers, ensure() callbacks, or started flags. Use Effect.addFinalizer or Effect.acquireRelease inside the closure for cleanup and Effect.forkScoped for background stream consumers.InstanceState.get(state) at the init() call site with Effect.forkIn(scope), not inside InstanceState.make, because internal forking leaves incomplete state visible to other methods. src/project/bootstrap.ts already wraps every service init() in Effect.forkDetach, so production initialization is fire-and-forget and init() methods should remain synchronous internally.Effect.fork and Effect.forkDaemon do not exist; use Effect.forkIn(scope) to fork into a specific scope.FileSystem.FileSystem instead of raw fs/promises, ChildProcessSpawner.ChildProcessSpawner with ChildProcess.make(...) instead of custom process wrappers, and HttpClient.HttpClient instead of raw fetch; prefer Path.Path, Config, Clock, and DateTime when already in Effect code. Background loops or scheduled tasks use Effect.repeat or Effect.schedule with Effect.forkScoped in the layer definition.Effect.cached when concurrent callers should share one in-flight computation rather than manually storing Fiber | undefined or Promise | undefined; specs/effect/migration.md contains the full pattern.EffectBridge for native/external callbacks such as @parcel/watcher, node-pty, native fs.watch, and plugin callbacks that need to re-enter Effect services with instance/workspace context. Plain async code should pass explicit context or remain in an Effect fiber; do not add ambient instance-context shims.packages/schema/src/session-event.ts defines PromptAdmitted with event type "session.next.prompt.admitted", shared options, and schema PromptFields; its exported type is typeof PromptAdmitted.Type.packages/schema/src/session-event.ts, PromptFields consists of Base plus messageID: SessionMessage.ID, prompt: Prompt, and delivery: Delivery; Base consists of timestamp: DateTimeUtcFromMillis and sessionID: SessionID. Both Prompted ("session.next.prompted") and PromptAdmitted ("session.next.prompt.admitted") use PromptFields./home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/effect/src/Effect.ts defines repeat near line 7605 and repeatOrElse near line 7675.