Dashboard › opencode › Session 09Hb36T5SCwQ
09Hb36T5SCwQ3cbyvRead-only investigation in /home/byk/Code/opencode-v2-pilot. Inspect Promise plugin tests, registration cleanup tests, session model/http hook invocation tests, package resolution/exports tests, and config agent naming. Determine a minimal faithful mock/test harness Lore can keep in /home/byk/Code/opencode-lore for a V2 Plugin.define adapter. Do not edit files. Return exact file:line evidence and recommended mock shapes/cases, especially cleanup and multiple location scopes.
/home/byk/Code/opencode-v2-pilot/services/www/src/docs/AGENTS.md /home/byk/Code/opencode-v2-pilot/services/www/AGENTS.md /home/byk/Code/opencode-v2-pilot/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/desktop/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/stats/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/session-ui/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/ui/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/core/src/tool/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/schema/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/plugin/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/tui/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/codemode/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/ai/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/app/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/app/e2e/performance/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/app/e2e/AGENTS.md /home/byk/Code/opencode-v2-pilot/packages/cli/AGENTS.md
/home/byk/Code/opencode-lore/AGENTS.md
<path>/home/byk/Code/opencode-v2-pilot/AGENTS.md</path> <type>file</type> <content> 1: - After changing the public Protocol or Server `HttpApi`, run `bun run generate` from `packages/client`. Do not edit generated client files directly. 2: - Keep runtime dependencies directed from Schema to Core and Protocol, then from Core and Protocol to Server. Client runtime code may depend on Schema and Protocol but never Core or Server; `sdk` composes Client, Core, and Server. 3: - Current implementation changes belong in `packages/core`, `packages/cli`, `packages/server`, `packages/protocol`, `packages/schema`, and related generated client surfaces when required. 4: - This repository does not use Changesets. Do not add `.changeset` files; follow the existing release workflow instead. 5: - The default branch in this repo is `v2`. 6: - Default new branches and worktrees to `v2`, or `origin/v2` when the local `v2` ref is unavailable, and default pull requests to target `v2`. ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/AGENTS.md</path> <type>file</type> <content> 1: # Plugin Package Guide 2: 3: - The plugin package has two versions: Effect and Promise. 4: - In the Effect version, every domain must extend the corresponding Effect API client interface from `@opencode/client/effect/api`. 5: - Do not redefine functions that already exist on the Effect API client interface. 6: - Plugin domains add only the additional functions that make sense in the plugin context. (End of file - total 6 lines) </content> <system-reminder> Instructions from: /home/byk/Code/opencode-v2-pilot/AGENTS.md - After changing the public Protocol or Server `HttpApi`, run `bun run generate` from `packages/client`. Do not edit generated client files directly. - Keep runtime dependencies directed from Schema to Core and Protocol, then from Core and Protocol to Server. ...
<path>/home/byk/Code/opencode-lore/AGENTS.md</path> <type>file</type> <content> 1: <!-- This section is maintained by the coding agent via lore (https://github.com/BYK/loreai) --> 2: ## Long-term Knowledge 3: 4: For long-term knowledge entries managed by [lore](https://github.com/BYK/loreai) (gotchas, patterns, decisions, architecture), see [`.lore.md`](.lore.md) in the project root. 5: <!-- End lore-managed section --> 6: 7: ## Review 8: 9: See [`quality/REVIEW.md`](quality/REVIEW.md) for the review heuristics and workflow — regression-test discipline, adversarial-order state setup, fan-out registry coverage, recurring bug-class batteries, and the two-reviewer rule. Every non-trivial PR requires an adversarial correctness review before merge. 10: 11: # Project Overview 12: 13: Lore is a **three-tier memory architecture** for AI coding agents. ...
/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/package.json /home/byk/Code/opencode-v2-pilot/packages/plugin/tsconfig.json /home/byk/Code/opencode-v2-pilot/packages/plugin/tsconfig.build.json /home/byk/Code/opencode-v2-pilot/packages/plugin/sst-env.d.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/worktree.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/storage.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/source.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/source.node.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/source.bun.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/rpc.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/host.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/tui/context.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/tui/solid.ts /home/byk/Code/opencode-v2-pilot/packages/plugin/src/tui/plugin.ts /home/byk/Code/opencode-v2-p...
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin-failure.test.ts /home/byk/Code/opencode-v2-pilot/packages/tui/test/plugin-source.test.ts /home/byk/Code/opencode-v2-pilot/packages/server/test/plugin-activation.test.ts
No files found
/home/byk/Code/opencode-v2-pilot/packages/schema/test/session-terminal.test.ts /home/byk/Code/opencode-v2-pilot/packages/schema/test/session-error.test.ts /home/byk/Code/opencode-v2-pilot/packages/protocol/test/session-cursor.test.ts /home/byk/Code/opencode-v2-pilot/packages/util/test/session-title-fallback.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-wait.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-view.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-tool-progress.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-title.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-system-prompt.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-store.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-step.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-stats.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/session-skill.test.ts /hom...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/transport.test.ts:
Line 18: return Promise.reject(new Error("The caller's Fetch must not receive embedded SDK requests"))
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/promise.test.ts:
Line 2: import { mkdir } from "node:fs/promises"
Line 7: test("Promise host uses the embedded router", async () => {
Line 8: await using directory = await tmpdir("opencode-promise-sdk-")
Line 36: test("Promise event streams support cancellation", async () => {
Line 37: await using directory = await tmpdir("opencode-promise-stream-")
Line 53: test("closing cancels active Promise event streams", async () => {
Line 54: await using directory = await tmpdir("opencode-promise-stream-close-")
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/logging.test.ts:
Line 8: await Effect.runPromise(
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances.test.ts:
...
Found 8 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances-effect.test.ts:
Line 60: Plugin.define({
Line 175: Plugin.define({
Line 265: Plugin.define({
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/worktree.test.ts:
Line 23: Plugin.define({
/home/byk/Code/opencode-v2-pilot/packages/server/test/provider.test.ts:
Line 41: Plugin.define({
/home/byk/Code/opencode-v2-pilot/packages/server/test/plugin-activation.test.ts:
Line 67: Plugin.define({
Line 132: Plugin.define({
Line 172: Plugin.define({
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/plugin.ts</path>
<type>file</type>
<content>
1: import type { OpenCodeClient } from "@opencode/client"
2: import type { GenerateApi, PluginApi } from "@opencode/client/promise/api"
3: import type { Location } from "@opencode/schema/location"
4: import type { PluginOptions } from "../options.js"
5: import type { App } from "../app.js"
6: import type { AgentDomain } from "./agent.js"
7: import type { AISDKDomain } from "./aisdk.js"
8: import type { CatalogDomain } from "./catalog.js"
9: import type { CommandDomain } from "./command.js"
10: import type { EventDomain } from "./event.js"
11: import type { IntegrationDomain } from "./integration.js"
12: import type { MCPDomain } from "./mcp.js"
13: import type { PermissionDomain } from "./permission.js"
14: import type { ReferenceDomain } from "./reference.js"
15: import type { RpcDomain } from "./rpc.js"
16: import type { SessionDomain } from "./session.js"
17: import type ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/index.ts</path>
<type>file</type>
<content>
1: export type { PluginOptions } from "../options.js"
2: export type { StorageEntry, StorageScanOptions, StorageScanResult } from "../storage.js"
3: export * as Plugin from "./plugin.js"
4:
5: export { Agent } from "@opencode/schema/agent"
6: export { Command } from "@opencode/schema/command"
7: export { Connection } from "@opencode/schema/connection"
8: export { Credential } from "@opencode/schema/credential"
9: export { Integration } from "@opencode/schema/integration"
10: export { Location } from "@opencode/schema/location"
11: export { Mcp } from "@opencode/schema/mcp"
12: export { Model } from "@opencode/schema/model"
13: export { PersistentPty } from "@opencode/schema/persistent-pty"
14: export { Provider } from "@opencode/schema/provider"
15: export { Reference } from "@opencode/schema/reference"
16: export { Rpc } from "@opencode/schema/rpc"
17: export { Skill } from ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/registration.ts</path>
<type>file</type>
<content>
1: export interface Registration {
2: readonly dispose: () => Promise<void>
3: }
4:
5: export interface ModelHookOptions {
6: /** Limits the hook to one provider. Unscoped hooks apply to every provider. */
7: readonly providerID?: string
8: }
9:
10: export type Hooks<Spec> = <Name extends keyof Spec>(
11: name: Name,
12: callback: (input: Spec[Name]) => Promise<void> | void,
13: ) => Promise<Registration>
14:
15: export type ModelHooks<Spec> = <Name extends keyof Spec>(
16: name: Name,
17: callback: (input: Spec[Name]) => Promise<void> | void,
18: options?: Spec[Name] extends { readonly model: unknown } ? ModelHookOptions : never,
19: ) => Promise<Registration>
20:
21: export type Transform<Input> = (callback: (input: Input) => void) => Promise<Registration>
(End of file - total 21 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts</path>
<type>file</type>
<content>
1: import { Tool } from "@opencode/schema/tool"
2: import type { Rpc } from "@opencode/schema/rpc"
3: import type { RpcCallOptions, RpcEventPayload } from "@opencode/client/promise/api"
4: import { Effect, Schema, SchemaAST, Stream } from "effect"
5: import type { Scope } from "effect"
6: import { HttpApiEndpoint, HttpApiSchema } from "effect/unstable/httpapi"
7: import { define } from "../effect/plugin.js"
8: import type { Plugin } from "./plugin.js"
9: import type { Info } from "./tool.js"
10: import type { RpcDomain, RpcHandlers } from "./rpc.js"
11:
12: type HostRegistration = { readonly dispose: Effect.Effect<void> }
13: type Registration = { readonly dispose: () => Promise<void> }
14: type PromiseContext = Parameters<Plugin["setup"]>[0]
15: type PromiseEvent = ReturnType<PromiseContext["event"]["subscribe"]> extends AsyncIterable<infer Event> ? ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts</path>
<type>file</type>
<content>
501: ),
502: hook: (name, callback) =>
503: register(host.tool.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
504: },
505: vcs: {
506: get: adaptApiMethod(VcsEndpoints["vcs.get"], host.vcs.get),
507: base: adaptApiMethod(VcsEndpoints["vcs.base"], host.vcs.base),
508: branches: adaptApiMethod(VcsEndpoints["vcs.branches"], host.vcs.branches),
509: status: adaptApiMethod(VcsEndpoints["vcs.status"], host.vcs.status),
510: diff: adaptApiMethod(VcsEndpoints["vcs.diff"], host.vcs.diff),
511: reload: () => run(host.vcs.reload()),
512: transform: (callback) =>
513: register(
514: host.vcs.transform((editor) => {
515: callback({
516: add: ...
Found 6 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/worktree.test.ts:
Line 3: import { Plugin } from "@opencode/plugin"
Line 22: const plugin = PluginPromise.fromPromise(
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts:
Line 16: import { fromPromise } from "@opencode/plugin/promise/adapter"
Line 441: const definition = fromPromise({
Line 469: const definition = fromPromise({
Line 499: ...fromPromise({
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import path from "path"
3: import { Cause, Clock, Deferred, Effect, Exit, Schema } from "effect"
4: import { TestClock } from "effect/testing"
5: import { Agent } from "@opencode/core/agent"
6: import { Command } from "@opencode/core/command"
7: import { Bus } from "@opencode/core/bus"
8: import { Credential } from "@opencode/core/credential"
9: import { Integration } from "@opencode/core/integration"
10: import { Permission } from "@opencode/core/permission"
11: import { Plugin } from "@opencode/core/plugin"
12: import { PluginModule } from "@opencode/core/plugin/module"
13: import { SessionMessage } from "@opencode/core/session/message"
14: import { Tool } from "@opencode/core/tool"
15: import { Watcher } from "@opencode/core/filesystem/watcher"
16: import { fromPromise } from "@opencode/plugin/promise/adapter"
17: import { Session } ...
Found 12 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances.test.ts:
Line 38: await ctx.session.hook("prompt", (event) => {
Line 166: await ctx.session.hook("prompt", (event) => {
Line 242: await ctx.session.hook("prompt", (event) => {
Line 325: await ctx.session.hook("prompt", (event) => {
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances-effect.test.ts:
Line 70: yield* ctx.session.hook("context", (event) =>
Line 180: yield* ctx.session.hook("prompt", (event) =>
Line 268: ctx.session.hook("prompt", (event) =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-activation.test.ts:
Line 43: await ctx.session.hook("prompt", (event) => {
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin-failure.test.ts:
Line 34: yield* ctx.shell.hook("create.before", () => ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { mkdir } from "node:fs/promises"
3: import { join } from "node:path"
4: import { Schema } from "effect"
5: import { tmpdir } from "../../core/test/fixture/tmpdir"
6: import { OpenCode, Session, SessionMessage } from "../src"
7:
8: const metadata = Schema.decodeUnknownSync(Schema.Struct({ account: Schema.String }))
9: const hostOptions = (directory: string) => ({
10: database: { path: join(directory, "opencode.sqlite") },
11: config: { directory, project: false, content: "{}" },
12: models: { fetch: false },
13: fs: { filewatcher: false },
14: })
15:
16: test("Promise instances are lazy, share by key and Location, and stay isolated between hosts", async () => {
17: await using directory = await tmpdir("opencode-promise-instances-")
18: const otherDirectory = join(directory.path, "other")
19: await ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts</path>
<type>file</type>
<content>
1: import type { SessionApi } from "@opencode/client/promise/api"
2: import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai"
3: import type { Agent } from "@opencode/schema/agent"
4: import type { Model } from "@opencode/schema/model"
5: import type { PromptInput } from "@opencode/schema/prompt-input"
6: import type { Session } from "@opencode/schema/session"
7: import type { SessionInbox } from "@opencode/schema/session-inbox"
8: import type { SessionError } from "@opencode/schema/session-error"
9: import type { SessionMessage } from "@opencode/schema/session-message"
10: import type { JsonSchema, Types } from "effect"
11: import type { ModelHooks } from "./registration.js"
12:
13: export interface SessionPrompt {
14: readonly sessionID: Session.ID
15: readonly messageID: SessionMessage.ID
16: prompt: ...
Found 16 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts:
Line 47: yield* hooks.register("session", "http.request", (event) =>
Line 52: yield* hooks.register("session", "http.response", (event) =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-openai.test.ts:
Line 47: const event = yield* hooks.trigger("session", "model.request", {
Line 59: (yield* hooks.has("session", "http.request", providerID)) ||
Line 60: (yield* hooks.has("session", "http.response", providerID)),
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-github-copilot.test.ts:
Line 50: return yield* hooks.trigger("session", "model.request", {
Line 155: const event = yield* hooks.trigger("session", "http.request", {
Line 230: const event = yield* hooks.trigger("session", "model.request", ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect } from "bun:test"
2: import { OpenAIChat } from "@opencode/ai/protocols"
3: import { Agent } from "@opencode/schema/agent"
4: import { Money } from "@opencode/schema/money"
5: import { Session } from "@opencode/schema/session"
6: import type { SessionRequestKind } from "@opencode/plugin/effect/session"
7: import { Location } from "@opencode/core/location"
8: import { PluginHooks } from "@opencode/core/plugin/hooks"
9: import { Project } from "@opencode/core/project"
10: import { AbsolutePath } from "@opencode/core/schema"
11: import { SessionModelRequest } from "@opencode/core/session/model-request"
12: import { SessionModelTransport } from "@opencode/core/session/model-transport"
13: import { SessionRunnerModel } from "@opencode/core/session/runner/model"
14: import { DateTime, Effect } from "effect"
15: import { ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect, test } from "bun:test"
2: import { Message, ToolResultPart } from "@opencode/ai"
3: import { boundImages, unsupportedParts } from "@opencode/core/session/model-request"
4:
5: const capabilities = (input: string[]) => ({ tools: true, input, output: ["text"] })
6:
7: describe("SessionModelRequest.unsupportedParts", () => {
8: test("replaces unsupported user media with a visible error", () => {
9: const messages = unsupportedParts(
10: [
11: Message.user([
12: Message.text("Describe these files"),
13: { type: "media", mediaType: "image/png", data: "aGVsbG8=", filename: "logo.png" },
14: { type: "media", mediaType: "application/pdf", data: "JVBERg==", filename: "document.pdf" },
15: ]),
16: ],
17: capabilities(["text"]),
18: )
19:
20: ...
Found 3 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:
Line 224: const event = yield* hooks.trigger("session", "model.request", {
Line 249: const before = yield* hooks.trigger("session", "http.request", {
Line 261: const after = yield* hooks.trigger("session", "http.response", {
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts</path>
<type>file</type>
<content>
190: return { type: "text" as const, text: IMAGE_REMOVED }
191: }),
192: },
193: }
194: }),
195: }),
196: )
197: }
198:
199: /** The identity a plugin hook sees for one outbound request. */
200: interface HookScope {
201: readonly sessionID: SessionSchema.ID
202: readonly agent: Agent.ID
203: readonly model: Model.Ref
204: readonly kind: SessionRequestKind
205: }
206:
207: const sessionHeaders = (session: Pick<SessionSchema.Info, "id" | "parentID" | "projectID">, app: App.Info) => ({
208: "x-session-affinity": session.id,
209: "X-Session-Id": session.id,
210: ...(session.parentID ? { "x-parent-session-id": session.parentID } : {}),
211: "User-Agent": App.useragent(app),
212: "x-opencode-project": session.projectID,
213: "x-opencode-session": session.id,
214: "x-opencode-client": ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts</path>
<type>file</type>
<content>
285: export const layer = Layer.effect(
286: Service,
287: Effect.gen(function* () {
288: const hooks = yield* PluginHooks.Service
289: const transport = yield* SessionModelTransport.Service
290: const app = yield* App.Metadata
291: const prepare = Effect.fn("SessionModelRequest.prepare")(function* (input: PrepareInput) {
292: const session = input.scope.session
293: const resolved = input.scope.model
294: const model = resolved.model
295: const tools = input.scope.tools ?? {
296: definitions: [],
297: execute: () => new Tool.Error({ message: "Tools are not available for this request" }),
298: }
299: const registry = new Map(tools.definitions.map((tool) => [tool.name, tool]))
300: // The definition objects we hand to hooks, mapped back to their tools. ...
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/import-boundaries.test.ts /home/byk/Code/opencode-v2-pilot/packages/session-ui/src/import-boundaries.test.ts /home/byk/Code/opencode-v2-pilot/packages/server/test/session-import.test.ts /home/byk/Code/opencode-v2-pilot/packages/ui/src/theme/v2/resolve.test.ts /home/byk/Code/opencode-v2-pilot/packages/tui/test/theme/v2/resolve.test.ts /home/byk/Code/opencode-v2-pilot/packages/client/test/import-boundaries.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/model-resolver.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/mcp-import-boundary.test.ts /home/byk/Code/opencode-v2-pilot/packages/cli/test/import-export.test.ts /home/byk/Code/opencode-v2-pilot/packages/cli/test/import-boundaries.test.ts /home/byk/Code/opencode-v2-pilot/packages/app/test-browser/session-resolution.test.ts /home/byk/Code/opencode-v2-pilot/packages/app/src/session/commands/export.test.ts /home/byk/Code/opencode-v2-pilot/packages/app/src/session/se...
Found 22 matches
/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts:
Line 30: it("resolves conventional entrypoints without package.json", async () => {
Line 32: assert.deepEqual(Host.resolve(plugin.target), {
Line 39: it("resolves a TUI-only directory without an index or package.json", async () => {
Line 41: assert.deepEqual(Host.resolve(plugin.target), {
Line 49: it(`resolves packages without exports using ${main ?? "the default index"}`, async () => {
Line 52: "package.json": JSON.stringify({ name, main }),
Line 59: assert.deepEqual(Host.resolve(plugin.target), {
Line 67: it("resolves local conventional entrypoints with package.json but no exports", async () => {
Line 69: "package.json": JSON.stringify({ name, type: "module" }),
Line 74: assert.deepEqual(Host.resolve(plugin.target), {
Line 81: it("honors exports and prefers the explicit server entrypoint over the root", async () => {
...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts</path>
<type>file</type>
<content>
1: import assert from "node:assert/strict"
2: import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"
3: import { tmpdir } from "node:os"
4: import path from "node:path"
5: import { describe, it } from "node:test"
6: import { pathToFileURL } from "node:url"
7: import { Host } from "../src/host.js"
8:
9: // Every entrypoint throws if evaluated: resolution must never execute plugins.
10: const source = 'throw new Error("Plugin code must not run during resolution")'
11: const name = "@fixture/plugin"
12:
13: async function fixture(files: Record<string, string>, installed = false) {
14: const root = await mkdtemp(path.join(tmpdir(), "opencode-host-"))
15: const directory = installed ? path.join(root, "node_modules", name) : root
16: await Promise.all(
17: Object.entries(files).map(async ([file, content]) => {
18: await ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/package.json</path>
<type>file</type>
<content>
1: {
2: "$schema": "https://json.schemastore.org/package.json",
3: "name": "@opencode/plugin",
4: "version": "1.18.15",
5: "type": "module",
6: "license": "MIT",
7: "scripts": {
8: "test": "bun test --only-failures",
9: "typecheck": "tsgo --noEmit",
10: "build": "tsc -p tsconfig.build.json"
11: },
12: "exports": {
13: ".": "./src/promise/index.ts",
14: "./effect": "./src/effect/index.ts",
15: "./host": "./src/host.ts",
16: "./tui": "./src/tui/index.ts",
17: "./*": "./src/*.ts"
18: },
19: "imports": {
20: "#plugin-source": {
21: "bun": "./src/source.bun.ts",
22: "node": "./src/source.node.ts",
23: "default": "./src/source.node.ts"
24: }
25: },
26: "files": [
27: "dist"
28: ],
29: "dependencies": {
30: "@ai-sdk/provider": "3.0.8",
31: "@opencode/ai": "workspace:*",
32: ...
/home/byk/Code/opencode-lore/packages/opencode/package.json /home/byk/Code/opencode-lore/packages/opencode/tsconfig.json /home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/routing.e2e.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/internal.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/gateway-smoke.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/subagent-detection.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/tui-silence.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/session-state.test.ts /home/byk/Code/opencode-lore/packages/opencode/src/internal.ts /home/byk/Code/opencode-lore/packages/opencode/src/index.ts /home/byk/Code/opencode-lore/packages/opencode/scripts/list-sessions.ts /home/byk/Code/opencode-lore/packages/opencode/eval/session_eval.ts /home/byk/Code/opencode-lore/packages/opencode/eval/extract_session.ts /home/byk/Code/opencode-lore/packages/o...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore/packages/opencode/package.json:
Line 49: "agent",
/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts:
Line 8: * Minimal mock of the OpenCode client. Only stubs the methods the plugin
Line 28: * Initialize the plugin with a mock client and temp directory.
Line 67: test("registers hidden worker agents", async () => {
Line 73: const agents = cfg.agent as Record<
Line 77: expect(agents["lore-distill"]).toEqual({
Line 78: mode: "subagent",
Line 82: expect(agents["lore-curator"]).toEqual({
Line 83: mode: "subagent",
Line 87: expect(agents["lore-query-expand"]).toEqual({
Line 88: mode: "subagent",
Line 93: // `hidden` is only honored by OpenCode for subagent-mode agents; assert
Line 94: // every internal worker is explicitly mode:"subagent" (not "all"/"primary")
Line 95: // so it never ...
<path>/home/byk/Code/opencode-lore/packages/opencode/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "@loreai/opencode",
3: "version": "0.40.0",
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Three-tier memory architecture for OpenCode — distillation, not summarization",
7: "main": "./src/index.ts",
8: "types": "./src/index.ts",
9: "exports": {
10: ".": {
11: "types": "./src/index.ts",
12: "bun": "./src/index.ts",
13: "default": "./src/index.ts"
14: }
15: },
16: "scripts": {
17: "typecheck": "tsc --noEmit",
18: "build": "echo '@loreai/opencode ships raw TS — no build step needed'"
19: },
20: "peerDependencies": {
21: "@opencode-ai/plugin": ">=1.1.0"
22: },
23: "dependencies": {
24: "@loreai/core": "workspace:*",
25: "@loreai/gateway": "workspace:*"
26: },
27: "devDependencies": {
28: "@opencode-ai/plugin": "^1.1.39",
29: "@opencode-ai/sdk": "^1.1.39",
30: ...
<path>/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts</path>
<type>file</type>
<content>
1: import { describe, test, expect } from "vitest";
2: import { fileURLToPath } from "node:url";
3: import { LorePlugin } from "../src/index";
4: import { applyLoreProviderConfig } from "../src/internal";
5: import type { Plugin } from "@opencode-ai/plugin";
6:
7: /**
8: * Minimal mock of the OpenCode client. Only stubs the methods the plugin
9: * actually calls during initialization.
10: */
11: function createMockClient() {
12: return {
13: tui: {
14: showToast: () => Promise.resolve(),
15: },
16: session: {
17: get: () => Promise.resolve({ data: {} }),
18: list: () => Promise.resolve({ data: [] }),
19: create: () => Promise.resolve({ data: { id: "worker_1" } }),
20: messages: () => Promise.resolve({ data: [] }),
21: message: () => Promise.resolve({ data: null }),
22: prompt: () => Promise.resolve({ data: {} }),
23: ...
Found 31 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/config/normalize.ts:
Line 7: import { ConfigAgent } from "@opencode/schema/config/agent"
Line 20: import { ConfigAgentV1 } from "../v1/config/agent.js"
Line 132: decodeMap(input.agent, ConfigAgentV1.Info, ["agent"], diagnostics, decodeValue),
Line 133: (value) => canonical(ConfigAgent.Info, ConfigMigrateV1.migrateAgent(value)),
Line 152: const modeAgents = mapValues(decodeMap(input.mode, ConfigAgentV1.Info, ["mode"], diagnostics, decodeValue), (value) =>
Line 153: canonical(ConfigAgent.Info, ConfigMigrateV1.migrateAgent({ ...value, mode: "primary" })),
Line 155: const migratedAgents = mergeMaps(legacyAgents, modeAgents, ["agents"], diagnostics)
Line 156: const nativeAgents = decodeMap(input.agents, ConfigAgent.Info, ["agents"], diagnostics, decodeEncoded)
Line 157: diagnoseAgentUnsupported(input.agent, ["agent"], diagnostics)
Line 161: "agents",
Line 204: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/config/normalize.ts</path>
<type>file</type>
<content>
110: nativeReferences,
111: isRecord(input.reference) || isRecord(input.references),
112: diagnostics,
113: )
114:
115: const legacyCommands = decodeMap(input.command, ConfigCommandV1.Info, ["command"], diagnostics, decodeValue)
116: diagnoseSelectionMap(input.command, ["command"], diagnostics)
117: const migratedCommands = mapValues(legacyCommands, (value) => {
118: const migrated = ConfigMigrateV1.commands({ value })?.value
119: return migrated === undefined ? undefined : canonical(ConfigCommand.Info, migrated)
120: })
121: const nativeCommands = decodeMap(input.commands, ConfigCommand.Info, ["commands"], diagnostics, decodeEncoded)
122: mergeMap(
123: encoded,
124: "commands",
125: migratedCommands,
126: nativeCommands,
127: isRecord(input.command) || isRecord(input.commands),
128: diagnostics,
129: )
130:
131: ...
/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/worktree.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/websearch.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/provider.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/experimental.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/command.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/watcher.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/warming.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/tool-output.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/reference.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/policy.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/plugin.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/model.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/media.ts /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/mcp.ts /...
Found 9 matches
/home/byk/Code/opencode-v2-pilot/packages/schema/src/session-stats.ts:
Line 57: subagents: NonNegativeInt,
/home/byk/Code/opencode-v2-pilot/packages/schema/src/session-message.ts:
Line 78: agents: Prompt.fields.agents,
/home/byk/Code/opencode-v2-pilot/packages/schema/src/prompt.ts:
Line 68: agents: Schema.Array(AgentAttachment).pipe(optional),
Line 79: ...(input.agents === undefined ? {} : { agents: input.agents }),
/home/byk/Code/opencode-v2-pilot/packages/schema/src/prompt-input.ts:
Line 32: agents: Schema.Array(AgentAttachment).pipe(optional),
/home/byk/Code/opencode-v2-pilot/packages/schema/src/config.ts:
Line 7: import { ConfigAgent } from "./config/agent.js"
Line 35: default_agent: Schema.String.pipe(optional).annotate({
Line 57: agents: Schema.Record(Schema.String, ConfigAgent.Info).pipe(optional).annotate({
/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/agent.ts:
Line 1: export * as ConfigAgent ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config.ts</path>
<type>file</type>
<content>
1: export * as Config from "./config.js"
2:
3: import { Schema } from "effect"
4: import { ephemeral, inventory } from "./event.js"
5: import { Permission } from "./permission.js"
6: import { AbsolutePath, optional } from "./schema.js"
7: import { ConfigAgent } from "./config/agent.js"
8: import { ConfigMedia } from "./config/media.js"
9: import { ConfigCompaction } from "./config/compaction.js"
10: import { ConfigCommand } from "./config/command.js"
11: import { ConfigExperimental } from "./config/experimental.js"
12: import { ConfigFormatter } from "./config/formatter.js"
13: import { ConfigLSP } from "./config/lsp.js"
14: import { ConfigMCP } from "./config/mcp.js"
15: import { ConfigModel } from "./config/model.js"
16: import { ConfigPlugin } from "./config/plugin.js"
17: import { ConfigProvider } from "./config/provider.js"
18: import { ConfigReference } from ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/agent.ts</path>
<type>file</type>
<content>
1: export * as ConfigAgent from "./agent.js"
2:
3: import { Schema } from "effect"
4: import { Permission } from "../permission.js"
5: import { optional, PositiveInt } from "../schema.js"
6: import { ConfigModel } from "./model.js"
7: import { ConfigProvider } from "./provider.js"
8:
9: export const Color = Schema.String.check(Schema.isPattern(/^#[0-9a-fA-F]{6}$/))
10:
11: export class Info extends Schema.Class<Info>("Config.Agent")({
12: model: ConfigModel.Selection.pipe(optional),
13: request: ConfigProvider.Request.pipe(optional),
14: system: Schema.String.pipe(optional),
15: description: Schema.String.pipe(optional),
16: mode: Schema.Literals(["subagent", "primary", "all"]).pipe(optional),
17: hidden: Schema.Boolean.pipe(optional),
18: color: Color.pipe(optional),
19: steps: PositiveInt.pipe(optional),
20: disabled: Schema.Boolean.pipe(optional),
21: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/config/watch.test.ts:
Line 13: agents: [AbsolutePath.make(path.join(project, ".agents"))],
Line 20: { path: project, type: "entries", names: [".agents", ".claude", ".opencode", "opencode.json", "opencode.jsonc"] },
/home/byk/Code/opencode-v2-pilot/packages/core/test/config/skill.test.ts:
Line 169: const agents = path.join(tmp.path, "agents")
Line 175: path.join(agents, "skills"),
Line 186: new AgentsDirectory({ type: "agents", path: AbsolutePath.make(agents) }),
Line 244: const parentSkills = path.join(checkout, ".agents", "skills")
Line 245: const worktreeSkills = path.join(worktree, ".agents", "skills")
/home/byk/Code/opencode-v2-pilot/packages/core/test/config/reload.test.ts:
Line 48: { root: ".agents", global: false },
Line 50: { root: "home/.agents", global: true },
Line 270: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/config/normalization.test.ts</path>
<type>file</type>
<content>
55: type: "rejected",
56: diagnostics: [
57: {
58: kind: "invalid",
59: path: ["$"],
60: message: "rejected configuration because its root is not an object",
61: },
62: ],
63: })
64: }
65: })
66:
67: test("keeps unrelated native fields when a legacy field is present", () => {
68: const result = decoded({ snapshot: false, agents: { reviewer: { system: "Use V2" } } })
69: expect(result.snapshots).toBe(false)
70: expect(result.agents?.reviewer?.system).toBe("Use V2")
71: })
72:
73: test("canonicalizes transformed native values through decode then encode", () => {
74: const result = normalized({ warming: { interval: "4 minutes", duration: "30 minutes" } })
75: expect(result.encoded.warming).toEqual({ interval: "240000 millis", duration: "1800000 ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/agent.ts</path>
<type>file</type>
<content>
1: export * as Agent from "./agent.js"
2:
3: import { Schema } from "effect"
4: import { ephemeral, inventory } from "./event.js"
5: import { optional } from "./schema.js"
6: import { Model } from "./model.js"
7: import { Permission } from "./permission.js"
8: import { Provider } from "./provider.js"
9: import { PositiveInt, statics } from "./schema.js"
10:
11: const Updated = ephemeral({ type: "agent.updated", schema: {} })
12:
13: export const ID = Schema.String.pipe(Schema.brand("Agent.ID"))
14: export type ID = typeof ID.Type
15:
16: export const Name = Schema.String.pipe(Schema.brand("Agent.Name"))
17: export type Name = typeof Name.Type
18:
19: export const Color = Schema.String.annotate({ identifier: "Agent.Color" })
20: export type Color = typeof Color.Type
21:
22: export interface Info extends Schema.Schema.Type<typeof Info> {}
23: export const Info = ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/agent.ts</path>
<type>file</type>
<content>
1: export * as ConfigAgentPlugin from "./agent.js"
2:
3: import { define } from "@opencode/plugin/effect/plugin"
4: import { Document, Info, type Entry } from "@opencode/schema/config"
5: import { ConfigAgent } from "@opencode/schema/config/agent"
6: import path from "path"
7: import { Effect, Option, PubSub, Schema, Stream } from "effect"
8: import { Agent } from "../../agent.js"
9: import { Config } from "../../config.js"
10: import { ConfigMarkdown } from "../markdown.js"
11: import { FSUtil } from "@opencode/util/fs-util"
12: import { ConfigAgentV1 } from "../../v1/config/agent.js"
13: import { ConfigMigrateV1 } from "../../v1/config/migrate.js"
14: import { Global } from "@opencode/util/global"
15: import { Permission } from "../../permission.js"
16: import type { FileAccess } from "../../file-access.js"
17: import type { ReadTool } from ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/script/publish.ts</path>
<type>file</type>
<content>
1: #!/usr/bin/env bun
2: import { Script } from "@opencode/script"
3: import { $ } from "bun"
4: import { fileURLToPath } from "url"
5:
6: const dir = fileURLToPath(new URL("..", import.meta.url))
7: process.chdir(dir)
8:
9: async function published(name: string, version: string) {
10: return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
11: }
12:
13: await $`bun run build`
14: const originalText = await Bun.file("package.json").text()
15: const pkg = JSON.parse(originalText) as {
16: name: string
17: version: string
18: exports: Record<string, string>
19: imports: Record<string, Record<string, string>>
20: }
21: if (await published(pkg.name, pkg.version)) {
22: console.log(`already published ${pkg.name}@${pkg.version}`)
23: } else {
24: for (const [key, value] of Object.entries(pkg.exports)) {
25: const file = ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/host.ts</path>
<type>file</type>
<content>
1: export * as Host from "./host.js"
2:
3: import path from "node:path"
4: import { importModule, resolveModule } from "@opencode/util/runtime-import"
5:
6: export interface Target {
7: readonly directory: string
8: readonly name?: string
9: }
10:
11: export interface Entrypoints {
12: readonly server?: string
13: readonly tui?: string
14: readonly rpc?: string
15: }
16:
17: export function resolve(target: Target): Entrypoints {
18: const entry = (subpaths: readonly string[]) => {
19: for (const subpath of subpaths) {
20: const specifier = target.name
21: ? [target.name, subpath].filter(Boolean).join("/")
22: : path.resolve(target.directory, subpath || "index")
23: try {
24: return resolveModule(specifier, target.directory)
25: } catch (error) {
26: if (
27: !(error instanceof Error) ||
28: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts</path>
<type>file</type>
<content>
1: export * as PluginModule from "./module.js"
2:
3: import type { Plugin } from "@opencode/plugin/effect/plugin"
4: import { Host } from "@opencode/plugin/host"
5: import { createPluginSources } from "@opencode/plugin/source"
6: import { Npm } from "@opencode/util/npm"
7: import { Deferred, Effect, FiberSet, PubSub, Schema, Stream } from "effect"
8: import path from "path"
9: import { stat } from "node:fs/promises"
10: import { fileURLToPath, pathToFileURL } from "url"
11: import type { ConfigPluginSource } from "../config/plugin/source.js"
12: import type { Generation } from "../plugin.js"
13: import { PluginPromise } from "./promise.js"
14: import { Watcher } from "../filesystem/watcher.js"
15:
16: export const make = Effect.fn("PluginModule.make")(function* () {
17: const watcher = yield* Watcher.Service
18: const scope = yield* Effect.scope
19: const runPromise = ...
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/worktree.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/websearch.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/websearch-fixture.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/variant.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/supervisor.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/supervisor-reload.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/skill.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-zenmux.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-xai.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-vllm.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-vercel.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-snowflake-cortex.test.ts /home/byk/Code/opencode-v2-pilot/pac...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/module.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import path from "node:path"
3: import { Deferred, Effect, Exit, Fiber, Layer, Schedule, Scope, Stream } from "effect"
4: import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder"
5: import { Watcher } from "@opencode/core/filesystem/watcher"
6: import { PluginModule } from "@opencode/core/plugin/module"
7: import { Global } from "@opencode/util/global"
8: import { Npm } from "@opencode/util/npm"
9: import { tempGlobalLayer } from "../fixture/global"
10: import { tmpdirScoped } from "../fixture/tmpdir"
11: import { testEffect } from "../lib/effect"
12:
13: const it = testEffect(
14: Layer.merge(
15: AppNodeBuilder.build(Npm.node, [Global.node.replace(tempGlobalLayer)]),
16: Watcher.layer().pipe(Layer.provide(Watcher.nativeLayer)),
17: ),
18: )
19:
20: it.live("watches creation of an external helper with ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/worktree.test.ts:
Line 631: "refresh ignores stale git worktree registrations",
Line 707: const registration = yield* worktrees.transform((editor) => editor.configure({ directory: parent }))
Line 714: yield* registration.dispose
Line 722: it.live("selects the last active registration and restores earlier strategies on disposal", () =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/websearch.test.ts:
Line 24: const registration = yield* websearch.transform((editor) => {
Line 43: return { providerID, calls, failure, dispose: registration.dispose }
Line 373: it.effect("uses updated registrations for the sticky provider", () =>
Line 609: it.effect("removes scoped provider registrations", () =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/vcs.test.ts:
Line 124: const registration = yield* vcs.transform((editor) => {
...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin-failure.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import { Deferred, Effect, Exit, Fiber, Schema } from "effect"
3: import { Bus } from "@opencode/core/bus"
4: import { Command } from "@opencode/core/command"
5: import { Plugin } from "@opencode/core/plugin"
6: import { PluginHooks } from "@opencode/core/plugin/hooks"
7: import { Rpc } from "@opencode/core/rpc"
8: import { testEffect } from "./lib/effect"
9: import { PluginTestLayer } from "./plugin/fixture"
10:
11: const it = testEffect(PluginTestLayer)
12:
13: it.live("removes a failed plugin's hooks and RPC handlers without affecting healthy plugins", () =>
14: Effect.gen(function* () {
15: const plugins = yield* Plugin.Service
16: const commands = yield* Command.Service
17: const hooks = yield* PluginHooks.Service
18: const rpc = yield* Rpc.Service
19: const cleaned = yield* Deferred.make<void>()
20: ...
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts
<path>/home/byk/Code/opencode-lore/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
1: import type { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
2: import {
3: log,
4: getGitRemote,
5: discoverWorkspaceRoot,
6: installFetchInterceptor,
7: } from "@loreai/core";
8: // Helpers live in a separate module so they are NOT re-exported from this
9: // plugin entry. OpenCode's legacy plugin loader invokes every function
10: // exported from the entry module as a plugin; leaking these helpers pushed
11: // `undefined` into the host hooks array and crashed it on event dispatch
12: // (`undefined is not an object (evaluating 'A.event')`). See ./internal.ts.
13: import {
14: applyLoreProviderConfig,
15: gatewayAccessHeadersForRemote,
16: probeGateway,
17: shouldForwardUpstreamExtraHeader,
18: surfaceGatewayUnavailable,
19: } from "./internal";
20:
21: /**
22: * Lore plugin for OpenCode — transparent LLM proxy routing. ...
<path>/home/byk/Code/opencode-lore/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
481: if (cur.gitRemote) headers["x-lore-git-remote"] = cur.gitRemote;
482: }
483: return headers;
484: },
485: });
486: log.info(`routing through ${gatewayBase}`);
487: log.info(`dashboard: ${gatewayBase}/ui`);
488: }
489:
490: processInitDone = true;
491: }
492:
493: return hooks;
494: } catch (e) {
495: // Log the full error before re-throwing so OpenCode's plugin loader
496: // (which catches and swallows the error) doesn't hide the root cause.
497: // `log.error` captures it to the file + Sentry sink even when stderr is
498: // silenced for the TUI, so the cause survives in `lore logs`.
499: const detail = e instanceof Error ? e.stack || e.message : String(e);
500: log.error(`init failed: ${detail}`);
501: throw e;
502: }
503: };
504:
505: // WARNING: do ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/hooks.ts</path>
<type>file</type>
<content>
1: export * as PluginHooks from "./hooks.js"
2:
3: import type { AISDKHooks } from "@opencode/plugin/effect/aisdk"
4: import type { SessionHooks } from "@opencode/plugin/effect/session"
5: import type { ShellHooks } from "@opencode/plugin/effect/shell"
6: import type { ToolFailures, ToolHooks } from "@opencode/plugin/effect/tool"
7: import type { ModelHookOptions } from "@opencode/plugin/effect/registration"
8: import type { PermissionHooks } from "@opencode/plugin/effect/permission"
9: import { Context, Effect, Layer, Scope } from "effect"
10: import { makeLocationNode } from "@opencode/util/effect/app-node"
11: import { State } from "../state.js"
12:
13: export interface Domains {
14: readonly aisdk: AISDKHooks
15: readonly session: SessionHooks
16: readonly permission: PermissionHooks
17: readonly shell: ShellHooks
18: readonly tool: ToolHooks
19: }
20:
21: type ...
Found 18 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/tool-registry.test.ts:
Line 861: yield* hooks.register("tool", "execute.after", (event) =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-title.test.ts:
Line 276: yield* hooks.register("session", "model.request", (event) =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-runner.test.ts:
Line 525: session: { hook: (name, callback) => hooks.register("session", name, callback) },
Line 1517: yield* hooks.register("session", "model.request", (event) =>
Line 2396: yield* hooks.register("session", "context", (event) =>
Line 2405: yield* hooks.register("session", "model.request", (event) =>
Line 2538: yield* hooks.register("session", "retry", (event) =>
Line 2584: yield* hooks.register("session", "retry", (event) =>
Line 2613: yield* hooks.register("session", "retry", (event) ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-owned.test.ts</path>
<type>file</type>
<content>
630: active: coordinator.active,
631: isActive: coordinator.isActive,
632: resume: (id) =>
633: Effect.gen(function* () {
634: resumes.push(id)
635: if (resumes.length === 2) yield* Deferred.succeed(joining, undefined)
636: yield* coordinator.run(id)
637: }),
638: wake: coordinator.wake,
639: awaitIdle: coordinator.awaitIdle,
640: interrupt: (id, options) =>
641: Effect.sync(() => void interrupts.push({ sessionID: id, options })).pipe(
642: Effect.andThen(coordinator.interrupt(id)),
643: ),
644: }),
645: })
646: const first = yield* fixture.sessions.forSession(sessionID).resume().pipe(Effect.forkScoped)
647: yield* Deferred.await(started)
648: const second = yield* ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/worktree.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import { Cause, Deferred, Effect, Exit, Fiber } from "effect"
3: import { Plugin } from "@opencode/plugin"
4: import type { WorktreeDefinition } from "@opencode/plugin/effect/worktree"
5: import { PluginPromise } from "@opencode/core/plugin/promise"
6: import { State } from "@opencode/core/state"
7: import { it } from "../lib/effect"
8: import { host } from "./host"
9:
10: it.live("Promise worktree callbacks receive interruption through their AbortSignal", () =>
11: Effect.gen(function* () {
12: const started = yield* Deferred.make<AbortSignal>()
13: const state = State.create({
14: initial: () => new Map<string, WorktreeDefinition>(),
15: editor: (value) => ({
16: add: (definition: WorktreeDefinition) => {
17: value.set(definition.id, definition)
18: },
19: }),
20: })
21: ...
Found 2 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts:
Line 436: it.live("retains Promise plugin groups for later registrations and ignores a disabled group's attempts", () =>
Line 465: it.effect("exposes canonical permission assertions to Promise plugins", () =>
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/plugin.ts</path>
<type>file</type>
<content>
1: export * as ConfigPlugin from "./plugin.js"
2:
3: import { Schema } from "effect"
4: import { optional } from "../schema.js"
5:
6: export class Entry extends Schema.Class<Entry>("Config.Plugin.Entry")({
7: package: Schema.String,
8: options: Schema.Record(Schema.String, Schema.Unknown).pipe(optional),
9: }) {}
10:
11: export const Plugin = Schema.Union([Schema.String, Entry])
12: export type Plugin = typeof Plugin.Type
13:
14: export const Plugins = Plugin.pipe(Schema.Array)
(End of file - total 14 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/agent.ts</path>
<type>file</type>
<content>
1: import type { AgentApi } from "@opencode/client/promise/api"
2: import type { Agent } from "@opencode/schema/agent"
3: import type { Transform } from "./registration.js"
4: import type { DeepMutable } from "./types.js"
5:
6: export interface AgentEditor {
7: list(): readonly DeepMutable<Agent.Info>[]
8: get(id: string): DeepMutable<Agent.Info> | undefined
9: default(id: string | undefined): void
10: update(id: string, update: (agent: DeepMutable<Agent.Info>) => void): void
11: remove(id: string): void
12: }
13:
14: export interface AgentDomain extends AgentApi {
15: readonly transform: Transform<AgentEditor>
16: readonly reload: () => Promise<void>
17: }
(End of file - total 17 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts</path>
<type>file</type>
<content>
1: export * as Agent from "./agent.js"
2:
3: import path from "path"
4: import { makeLocationNode } from "@opencode/util/effect/app-node"
5: import { Array, Context, Effect, Layer, Types } from "effect"
6: import { Agent } from "@opencode/schema/agent"
7: import { Global } from "@opencode/util/global"
8: import { Bus } from "./bus.js"
9: import { State } from "./state.js"
10:
11: const SHELL_OUTPUT_GLOB = (data: string) => path.join(data, "shell", "*", "*")
12: const TOOL_OUTPUT_GLOB = (data: string) => path.join(data, "tool-output", "*")
13:
14: export const ID = Agent.ID
15: export type ID = typeof ID.Type
16: export const Name = Agent.Name
17: export type Name = Agent.Name
18: export const defaultID = ID.make("build")
19:
20: export const Color = Agent.Color
21:
22: export const Info = Agent.Info
23: export type Info = Agent.Info
24:
25: export { Event } from ...
Found 2 matches /home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances-effect.test.ts: Line 65: yield* ctx.agent.transform((editor) => /home/byk/Code/opencode-v2-pilot/packages/server/test/session-instances.test.ts: Line 85: yield* ctx.agent.transform((editor) =>
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances-effect.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import path from "path"
3: import { LanguageModel, LLMClient } from "@opencode/ai"
4: import { OpenAIChat } from "@opencode/ai/protocols"
5: import { TestLLM } from "@opencode/ai/testing"
6: import { llmClient } from "@opencode/core/effect/app-node-platform"
7: import { makeMemoryDriver } from "@opencode/core/environment/index"
8: import { SessionRunnerModel } from "@opencode/core/session/runner/model"
9: import { WorkspaceDriver } from "@opencode/core/workspace/driver"
10: import { Plugin } from "@opencode/plugin/effect"
11: import { Context, Deferred, Effect, Exit, Layer, Schema, Scope } from "effect"
12: import { tmpdirScoped } from "../../core/test/fixture/tmpdir"
13: import { testEffect } from "../../core/test/lib/effect"
14: import { AbsolutePath, Agent, Location, OpenCode } from "../src/effect"
15:
16: const it = ...
Found 42 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/transport.test.ts:
Line 10: for (const entrypoint of ["create", "layer"] as const) {
Line 11: it.live(`${entrypoint} keeps requests and streams on its own transport despite an ambient Fetch`, () =>
Line 32: entrypoint === "create"
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/import-boundaries.test.ts:
Line 22: const entrypoint = join(temporary, "index.ts")
Line 25: await Bun.write(entrypoint, `export * from ${JSON.stringify(specifier)}`)
Line 30: entrypoint,
/home/byk/Code/opencode-v2-pilot/packages/schema/test/v1-isolation.test.ts:
Line 11: test("compatibility entrypoints preserve isolated V1 schema identity", () => {
/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts:
Line 9: // Every entrypoint throws if evaluated: resolution must never execute plugins.
Line 30: it("resolves conventional entrypoints without package.json", async () => {
...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/host.ts</path>
<type>file</type>
<content>
1: import { Plugin } from "@opencode/plugin/effect"
2: import type { IntegrationMethod } from "@opencode/plugin/effect/integration"
3: import { Agent } from "@opencode/core/agent"
4: import { Catalog } from "@opencode/core/catalog"
5: import { Credential } from "@opencode/core/credential"
6: import { Integration } from "@opencode/core/integration"
7: import { Location } from "@opencode/core/location"
8: import { Model } from "@opencode/core/model"
9: import { Project } from "@opencode/core/project"
10: import { Provider } from "@opencode/core/provider"
11: import { AbsolutePath } from "@opencode/core/schema"
12: import { WebSearch } from "@opencode/core/websearch"
13: import { Effect, Stream } from "effect"
14:
15: type Overrides = Partial<Omit<Plugin.Context, "options" | "session">> & {
16: readonly session?: Partial<Plugin.Context["session"]>
17: }
18: export function ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/app.ts</path>
<type>file</type>
<content>
1: export interface App {
2: readonly name: string
3: readonly version: string
4: readonly channel: string
5: }
(End of file - total 5 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/location.ts</path>
<type>file</type>
<content>
1: export * as Location from "./location.js"
2:
3: import { Schema } from "effect"
4: import { AbsolutePath, optional } from "./schema.js"
5: import { ProjectID } from "./project-id.js"
6: import { WorkspaceID } from "./workspace-id.js"
7:
8: export interface Ref extends Schema.Schema.Type<typeof Ref> {}
9: export const Ref = Schema.Struct({
10: directory: AbsolutePath,
11: workspaceID: optional(WorkspaceID),
12: }).annotate({ identifier: "Location.Ref" })
13:
14: export class Info extends Schema.Class<Info>("Location.Info")({
15: directory: AbsolutePath,
16: workspaceID: optional(WorkspaceID),
17: project: Schema.Struct({
18: id: ProjectID,
19: directory: AbsolutePath,
20: canonical: AbsolutePath,
21: }),
22: }) {}
23:
24: export function response<S extends Schema.Top>(data: S) {
25: return Schema.Struct({ location: Info, data })
26: }
(End of file ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts</path>
<type>file</type>
<content>
1: export * as Plugin from "./plugin.js"
2: export { Event, ID, Info, Source, State } from "@opencode/schema/plugin"
3:
4: import { Plugin } from "@opencode/schema/plugin"
5: import { Node } from "@opencode/util/effect/app-node"
6: import { LayerNode } from "@opencode/util/effect/layer-node"
7: import type { PersistentPty } from "./persistent-pty.js"
8: import { Cause, Context, Effect, Exit, Latch, Layer, Logger, Queue, References, Scope, Semaphore } from "effect"
9: import { Bus } from "./bus.js"
10: import { KV } from "./kv.js"
11: import { PluginHost } from "./plugin/host.js"
12: import { type Failure, type Generation, Service } from "./plugin/service.js"
13: import { State } from "./state.js"
14:
15: export { awaitActivation, type Generation, type Interface, Service } from "./plugin/service.js"
16:
17: const layer = Layer.effect(
18: Service,
19: Effect.gen(function* () ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/src/worktree/sql.ts:
Line 13: directory: absoluteColumn().notNull(),
Line 19: (table) => [primaryKey({ columns: [table.project_id, table.directory] })],
/home/byk/Code/opencode-v2-pilot/packages/core/src/worktree/refresh.ts:
Line 15: if (location.workspaceID) return
/home/byk/Code/opencode-v2-pilot/packages/core/src/worktree/git.ts:
Line 7: import { canonical, DirectoryUnavailableError } from "./directory.js"
Line 18: if (!repository) return yield* new DirectoryUnavailableError({ directory: input.sourceDirectory })
Line 19: yield* git.worktree.create({ repository, directory: input.directory, ref: input.branch })
Line 20: return { directory: yield* canonical(fs, input.directory) }
Line 23: const repository = yield* git.repo.discover(input.directory)
Line 24: if (!repository) return yield* new DirectoryUnavailableError({ directory: ...
/home/byk/Code/opencode-v2-pilot/packages/core/src/location.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/location-services.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/location-service-map.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/location-mutation.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/location-activity.ts
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/location-service-map.ts</path>
<type>file</type>
<content>
1: import { Context, Effect, Layer, LayerMap } from "effect"
2: import { LayerNode } from "@opencode/util/effect/layer-node"
3: import { Node } from "@opencode/util/effect/app-node"
4: import { AbsolutePath } from "@opencode/schema/schema"
5: import path from "path"
6: import { Location } from "./location.js"
7: import type { Instance } from "./instance.js"
8:
9: export class Service extends Context.Service<
10: Service,
11: LayerMap.LayerMap<Location.Ref, Instance.Services, Instance.Error>
12: >()("@opencode/example/LocationServiceMap") {
13: static get(ref: Location.Ref) {
14: return Layer.unwrap(Effect.map(Service, (locations) => locations.get(ref)))
15: }
16: }
17:
18: export const node = LayerNode.unbound(Service, Node.tags.values.global)
19:
20: /** Normalize equivalent placements before they become resource-cache keys. ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/instance.ts</path>
<type>file</type>
<content>
1: import { Effect, Layer } from "effect"
2: import { Agent } from "./agent.js"
3: import { AISDK } from "./aisdk.js"
4: import { Catalog } from "./catalog.js"
5: import { Command } from "./command.js"
6: import { Config } from "./config.js"
7: import { LayerNode } from "@opencode/util/effect/layer-node"
8: import { Node } from "@opencode/util/effect/app-node"
9: import { FileMutation } from "./file-mutation.js"
10: import { Environment } from "./environment/index.js"
11: import { Formatter } from "./formatter.js"
12: import { FileSystem } from "./filesystem.js"
13: import { FileSystemSearch } from "./filesystem/search.js"
14: import { Generate } from "./generate.js"
15: import { Form } from "./form.js"
16: import { Image } from "./image.js"
17: import { LocationWatcher } from "./filesystem/location-watcher.js"
18: import { Integration } from "./integration.js"
19: import { Location ...
Found 50 matches
/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/sdk/index.mdx:
Line 65: const plugin = Plugin.define({
Line 68: await ctx.agent.transform((agents) => {
/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/sdk/effect.mdx:
Line 68: const plugin = Plugin.define({
Line 73: yield* agent.transform((agents) => {
/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/sdk/cloudflare.mdx:
Line 68: const plugin = Plugin.define({
Line 71: await ctx.agent.transform((agents) => {
/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/plugins/rpc.mdx:
Line 135: export default Plugin.define({
Line 192: export default Plugin.define({
/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/plugins/index.mdx:
Line 11: export default Plugin.define({
Line 53: export default Plugin.define({
Line 110: export default Plugin.define({
Line 131: export default ...
<path>/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/plugins/index.mdx</path>
<type>file</type>
<content>
1: ---
2: title: "Overview"
3: ---
4:
5: Plugins can modify OpenCode's behavior and add new features. To change the terminal UI, build a [CLI
6: plugin](/build/plugins/cli).
7:
8: ```ts title=".opencode/plugins/example/index.ts"
9: import { Plugin } from "@opencode/plugin"
10:
11: export default Plugin.define({
12: id: "example",
13: async setup(ctx) {
14: await ctx.storage.set("loaded", true)
15: },
16: })
17: ```
18:
19: Plugins under `.opencode/plugins/` are loaded automatically, like the local example above. To load published packages
20: or plugin directories from other locations, add them to `plugins` in `opencode.json(c)`:
21:
22: ```jsonc title="opencode.jsonc"
23: {
24: "$schema": "https://opencode.ai/config.json",
25: "plugins": [
26: "opencode-acme-plugin",
27: "opencode-acme-plugin@1.2.0",
28: ...
<path>/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/plugins/index.mdx</path>
<type>file</type>
<content>
1120: for await (const event of ctx.event.subscribe({ signal: controller.signal })) {
1121: console.log(event.type)
1122: }
1123: })()
1124: return () => controller.abort()
1125: ```
1126:
1127: #### Reference
1128:
1129: Schema: [`V2EventEncoded`](/api#schema-V2EventEncoded)
1130:
1131: ```ts
1132: interface EventContext {
1133: subscribe(options?: { signal?: AbortSignal }): AsyncIterable<OpenCodeEvent>
1134: }
1135: ```
1136:
1137: ## Hooks
1138:
1139: Hooks intercept live operations. Register a hook on its domain and dispose the
1140: returned registration when it is no longer needed.
1141:
1142: ```ts
1143: const registration = await ctx.session.hook("context", () => {})
1144: await registration.dispose()
1145: ```
1146:
1147: Multiple plugins can register the same hook. ...
<path>/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/plugins/index.mdx</path>
<type>file</type>
<content>
1340: interface SessionContextHook {
1341: readonly sessionID: string
1342: readonly agent: string
1343: readonly model: { providerID: string; id: string; variant?: string }
1344: system: SystemPart[]
1345: messages: Message[]
1346: tools: Record<string, { description: string; input: JsonSchema }>
1347: generation: {
1348: maxTokens?: number
1349: temperature?: number
1350: topP?: number
1351: topK?: number
1352: frequencyPenalty?: number
1353: presencePenalty?: number
1354: seed?: number
1355: stop?: string[]
1356: }
1357: providerOptions: Record<string, unknown>
1358: }
1359:
1360: interface SessionHookContext {
1361: hook<Name extends keyof SessionHooks>(
1362: name: Name,
1363: callback: (event: SessionHooks[Name]) => Promise<void> | void,
1364: options?: Name extends "prompt" ? ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/config/agent.test.ts</path>
<type>file</type>
<content>
175: expect(Permission.evaluate("edit", "src/index.ts", build.permissions).effect).toBe("allow")
176: expect(Permission.evaluate("webfetch", "https://example.com", build.permissions).effect).toBe("allow")
177: expect(Permission.evaluate("read", ".env", build.permissions).effect).toBe("deny")
178: expect(Permission.evaluate("external_directory", opencodeData, build.permissions).effect).toBe("deny")
179: expect(Permission.evaluate("external_directory", "/outside/*", build.permissions).effect).toBe("allow")
180: }),
181: )
182:
183: it.effect("applies all global permissions before agent-specific permissions", () =>
184: Effect.gen(function* () {
185: const agents = yield* Agent.Service
186: const global = yield* Global.Service
187: const build = Agent.ID.make("build")
188: yield* agents.transform((editor) ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/index.ts</path>
<type>file</type>
<content>
1: export type { PluginOptions } from "../options.js"
2: export type { StorageEntry, StorageScanOptions, StorageScanResult } from "../storage.js"
3: export * as Plugin from "./plugin.js"
4:
5: export { Agent } from "@opencode/schema/agent"
6: export { Command } from "@opencode/schema/command"
7: export { Connection } from "@opencode/schema/connection"
8: export { Credential } from "@opencode/schema/credential"
9: export { Integration } from "@opencode/schema/integration"
10: export { Location } from "@opencode/schema/location"
11: export { Mcp } from "@opencode/schema/mcp"
12: export { Model } from "@opencode/schema/model"
13: export { PersistentPty } from "@opencode/schema/persistent-pty"
14: export { Provider } from "@opencode/schema/provider"
15: export { Reference } from "@opencode/schema/reference"
16: export { Rpc } from "@opencode/schema/rpc"
17: export { Skill } from ...
No files found
Found 58 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/transport.test.ts:
Line 56: yield* Scope.close(scope, Exit.void)
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/promise.test.ts:
Line 31: await opencode.close()
Line 32: await opencode.close()
Line 62: await opencode.close()
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances.test.ts:
Line 21: const setups: string[] = []
Line 22: const cleanups: string[] = []
Line 35: async setup(ctx) {
Line 37: setups.push(activation)
Line 42: cleanups.push(activation)
Line 90: expect(setups).toEqual([])
Line 124: expect(setups.toSorted()).toEqual(
Line 132: expect(cleanups).toEqual([])
Line 134: await first.close()
Line 135: expect(cleanups.toSorted()).toEqual(setups.filter((activation) => activation.startsWith("first:")).toSorted())
Line 141: await second.close()
Line 142: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances-lifecycle.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import { Instance } from "@opencode/core/instance/service"
3: import { Session } from "@opencode/core/session"
4: import { Location } from "@opencode/schema/location"
5: import { AbsolutePath } from "@opencode/schema/schema"
6: import { Context, Deferred, Effect, Exit, Fiber, Layer } from "effect"
7: import { tmpdirScoped } from "../../core/test/fixture/tmpdir"
8: import { testEffect } from "../../core/test/lib/effect"
9: import { EmbeddedHost } from "../src/internal/host"
10:
11: const it = testEffect(Layer.empty)
12:
13: it.live("a cancelled borrower cannot strand a later failed instance construction", () =>
14: Effect.gen(function* () {
15: const directory = yield* tmpdirScoped()
16: const started = yield* Deferred.make<Fiber.Fiber<unknown, unknown>>()
17: const release = yield* Deferred.make<void>()
18: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/promise.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { mkdir } from "node:fs/promises"
3: import { join } from "node:path"
4: import { tmpdir } from "../../core/test/fixture/tmpdir"
5: import { OpenCode, Session } from "../src"
6:
7: test("Promise host uses the embedded router", async () => {
8: await using directory = await tmpdir("opencode-promise-sdk-")
9: const config = join(directory.path, "config")
10: await mkdir(config)
11: const opencode = await OpenCode.create({
12: events: { persist: true },
13: config: { directory: config, project: false, content: "{}" },
14: })
15:
16: try {
17: const location = { directory: directory.path }
18: const session = await opencode.sessions.create({ location })
19: const selected = await opencode.sessions.get({ sessionID: session.id })
20: const page = await opencode.sessions.list({ directory: ...
Found 15 matches /home/byk/Code/opencode-v2-pilot/packages/sdk/package.json: Line 33: "@opencode/plugin": "workspace:*", /home/byk/Code/opencode-v2-pilot/package.json: Line 132: "@opencode/plugin": "workspace:*", /home/byk/Code/opencode-v2-pilot/packages/plugin-browser/package.json: Line 3: "name": "@opencode/plugin-browser", Line 30: "@opencode/plugin": "workspace:*", /home/byk/Code/opencode-v2-pilot/packages/latex/package.json: Line 16: "@opencode/plugin": "workspace:*", /home/byk/Code/opencode-v2-pilot/packages/plugin/package.json: Line 3: "name": "@opencode/plugin", /home/byk/Code/opencode-v2-pilot/packages/merman/package.json: Line 18: "@opencode/plugin": "workspace:*", /home/byk/Code/opencode-v2-pilot/packages/desktop/package.json: Line 42: "@opencode/plugin-browser": "workspace:*", /home/byk/Code/opencode-v2-pilot/packages/cli/package.json: Line 29: "@opencode/plugin": ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/import-boundaries.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { mkdtemp, rm } from "node:fs/promises"
3: import { join, resolve, sep } from "node:path"
4:
5: const directory = resolve(import.meta.dir, "..")
6: const client = resolve(import.meta.dir, "../../client")
7: const core = resolve(import.meta.dir, "../../core")
8: const server = resolve(import.meta.dir, "../../server")
9:
10: test("bundles the Promise and Effect clients with the in-memory host", async () => {
11: const bundles = await Promise.all([bundleInputs("@opencode/sdk"), bundleInputs("@opencode/sdk/effect")])
12:
13: for (const inputs of bundles) {
14: expect(within(inputs, client).length).toBeGreaterThan(0)
15: expect(within(inputs, core).length).toBeGreaterThan(0)
16: expect(within(inputs, server).length).toBeGreaterThan(0)
17: }
18: })
19:
20: async function bundleInputs(specifier: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/contract-identity.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { Location as CoreLocation } from "@opencode/core/location"
3: import { SessionInbox as CoreSessionInbox } from "@opencode/core/session/inbox"
4: import { SessionMessage as CoreSessionMessage } from "@opencode/core/session/message"
5: import { Agent } from "@opencode/schema/agent"
6: import { Config } from "@opencode/schema/config"
7: import { Event } from "@opencode/schema/event"
8: import { Location } from "@opencode/schema/location"
9: import { Model } from "@opencode/schema/model"
10: import { Project } from "@opencode/schema/project"
11: import { Provider } from "@opencode/schema/provider"
12: import { WebSearch } from "@opencode/schema/websearch"
13: import { Session } from "@opencode/schema/session"
14: import { SessionInbox } from "@opencode/schema/session-inbox"
15: import { SessionMessage } from ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/catalog.ts</path>
<type>file</type>
<content>
1: import type { CatalogApi } from "@opencode/client/promise/api"
2: import type { Model } from "@opencode/schema/model"
3: import type { Provider } from "@opencode/schema/provider"
4: import type { Transform } from "./registration.js"
5: import type { DeepMutable } from "./types.js"
6:
7: export interface CatalogProviderRecord {
8: readonly provider: DeepMutable<Provider.Info>
9: readonly models: ReadonlyMap<string, DeepMutable<Model.Info>>
10: }
11:
12: export interface CatalogEditor {
13: readonly provider: {
14: list(): readonly CatalogProviderRecord[]
15: get(providerID: string): CatalogProviderRecord | undefined
16: update(providerID: string, update: (provider: DeepMutable<Provider.Info>) => void): void
17: remove(providerID: string): void
18: }
19: readonly model: {
20: get(providerID: string, modelID: string): DeepMutable<Model.Info> ...
Found 10 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/src/workerd.ts:
Line 11: readonly plugins?: PromiseSdk.CreateOptions["plugins"]
/home/byk/Code/opencode-v2-pilot/packages/sdk/src/promise.ts:
Line 10: readonly plugins: ReadonlyArray<Plugin.Plugin>
Line 21: readonly plugins?: ReadonlyArray<Plugin.Plugin>
Line 28: readonly plugin: ((plugin: Plugin.Plugin) => Promise<void>) & OpenCodeClient["plugin"]
Line 46: return { plugins: configuration.plugins.map(PluginPromise.fromPromise) }
Line 55: const register = async (plugin: Plugin.Plugin) => {
Line 57: return host.runtime.runPromise(host.plugins.register(PluginPromise.fromPromise(plugin)))
/home/byk/Code/opencode-v2-pilot/packages/sdk/src/internal/instances.ts:
Line 14: readonly plugins: InstancePlugins.List
Line 66: plugins: configuration.plugins,
/home/byk/Code/opencode-v2-pilot/packages/sdk/src/internal/host.ts:
Line 60: plugins: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/src/promise.ts</path>
<type>file</type>
<content>
1: export * as PromiseSdk from "./promise"
2:
3: import { OpenCode, type OpenCodeClient } from "@opencode/client"
4: import type { Plugin } from "@opencode/plugin"
5: import { Session } from "@opencode/schema/session"
6: import { Effect, Schema } from "effect"
7: import { EmbeddedHost } from "./internal/host"
8:
9: export interface InstanceConfiguration {
10: readonly plugins: ReadonlyArray<Plugin.Plugin>
11: }
12:
13: export interface InstanceOptions {
14: /** Select a sharing key within the Session's current Location. Must not initialize plugins. */
15: readonly key: (session: typeof Session.Info.Encoded) => string
16: /** Reconstruct configuration on a cache miss, including after a host restart. */
17: readonly configure: (key: string) => InstanceConfiguration | Promise<InstanceConfiguration>
18: }
19:
20: export interface CreateOptions extends ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/promise.ts</path>
<type>file</type>
<content>
1: export * as PluginPromise from "./promise.js"
2:
3: export { fromPromise } from "@opencode/plugin/promise/adapter"
(End of file - total 3 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/host.ts</path>
<type>file</type>
<content>
1: export * as PluginHost from "./host.js"
2:
3: import { Plugin } from "@opencode/plugin/effect"
4: import type { IntegrationMethodRegistration } from "@opencode/plugin/effect/integration"
5: import { EventManifest } from "@opencode/schema/event-manifest"
6: import type { Event } from "@opencode/schema/event"
7: import { ServerConfig } from "@opencode/schema/mcp"
8: import { App } from "../app.js"
9: import { Effect, Schema, Stream } from "effect"
10: import { Agent } from "../agent.js"
11: import { AISDK } from "../aisdk.js"
12: import { Catalog } from "../catalog.js"
13: import { Command } from "../command.js"
14: import { Credential } from "../credential.js"
15: import { Bus } from "../bus.js"
16: import { Integration } from "../integration.js"
17: import { KV } from "../kv.js"
18: import { Location } from "../location.js"
19: import { LocationServiceMap } from ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/host.ts</path>
<type>file</type>
<content>
430: callback({
431: list: () => mutable(editor.list()),
432: get: editor.get,
433: add: (value) => editor.add(Schema.decodeUnknownSync(Skill.Info)(value)),
434: update: editor.update,
435: remove: editor.remove,
436: })
437: }),
438: },
439: storage: storage(kv, pluginID),
440: shell: {
441: hook: (name, callback) => hooks.register("shell", name, callback),
442: },
443: tool: {
444: transform: tools.transform,
445: reload: tools.reload,
446: hook: (name, callback) => hooks.register("tool", name, callback),
447: },
448: vcs: {
449: get: () => response(vcs.info()),
450: base: () => response(vcs.base()),
451: branches: (input) => response(vcs.branches({ search: input?.search, limit: input?.limit })),
452: status: () => ...
File not found: /home/byk/Code/opencode-v2-pilot/packages/sdk/src/internal/plugins.ts
No files found
Found 2 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/src/internal/host.ts:
Line 3: import { SdkPlugins } from "@opencode/core/plugin/sdk"
Line 60: plugins: Context.get(services, SdkPlugins.Service),
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/sdk.ts</path>
<type>file</type>
<content>
1: export * as SdkPlugins from "./sdk.js"
2:
3: import type { Plugin } from "@opencode/plugin/effect/plugin"
4: import { Context, Effect, Layer } from "effect"
5: import { makeGlobalNode } from "@opencode/util/effect/app-node"
6: import { Bus } from "../bus.js"
7: import type { Generation } from "../plugin.js"
8:
9: export const Updated = Bus.ephemeral({ type: "sdk.plugin.updated", schema: {} })
10:
11: /**
12: * Holds the plugins an embedder (the `@opencode/sdk` host) contributes,
13: * so the application loader can add them on every Location boot through its
14: * ordinary generation path. Registration publishes an unlocated update so every booted Location
15: * reloads its plugin generation from the shared store.
16: *
17: * Each host-global layer owns one private store. ...
Found 10 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/vcs.test.ts:
Line 831: it.live("reports missing explicit bases and missing default bases without calling them clean", () =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts:
Line 16: import { fromPromise } from "@opencode/plugin/promise/adapter"
Line 102: it.live("loads a local plugin with its configured options", () =>
Line 441: const definition = fromPromise({
Line 469: const definition = fromPromise({
Line 499: ...fromPromise({
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/worktree.test.ts:
Line 22: const plugin = PluginPromise.fromPromise(
/home/byk/Code/opencode-v2-pilot/packages/core/test/config/reload.test.ts:
Line 268: it.live("reloads config-backed domains without reloading external plugins", () =>
/home/byk/Code/opencode-v2-pilot/packages/cli/test/acp/service-directory.test.ts:
Line 125: test.each(["empty", "missing the ...
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/fixtures/greeting.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/fixtures/provider-factory.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/fixtures/models-dev.json /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/fixtures/models-dev-reasoning.json
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/fixtures/greeting.ts</path>
<type>file</type>
<content>
1: import { Plugin } from "@opencode/plugin"
2:
3: export default Plugin.define({
4: id: "greeting",
5: async setup(ctx) {
6: await ctx.command.transform((editor) =>
7: editor.add({
8: name: "greet",
9: description: ctx.options.description,
10: execute: async () => {},
11: }),
12: )
13: },
14: })
(End of file - total 14 lines)
</content>
<path>/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts</path>
<type>file</type>
<content>
260: });
261:
262: test("returns only config and tool hooks (no event/transform hooks)", async () => {
263: const { hooks, cleanup } = await initPlugin();
264: try {
265: expect(hooks.config).toBeDefined();
266: expect(hooks.tool).toBeDefined();
267: // Only config, tool, and chat.headers hooks should be registered
268: expect(hooks.event).toBeUndefined();
269: expect(hooks["experimental.chat.system.transform"]).toBeUndefined();
270: expect(hooks["experimental.chat.messages.transform"]).toBeUndefined();
271: expect(hooks["experimental.session.compacting"]).toBeUndefined();
272: } finally {
273: cleanup();
274: }
275: });
276: });
277:
278: describe("plugin entry module export shape", () => {
279: // Regression guard for the v1.17.4 crash (`undefined is not an object
280: // (evaluating 'A.event')`). ...
<path>/home/byk/Code/opencode-v2-pilot/packages/server/test/session-instances.test.ts</path>
<type>file</type>
<content>
60: Watcher.node.replace(Watcher.configured({ enabled: false })),
61: llmClient.replace(Layer.succeed(LLMClient.Service, llm)),
62: SessionRunnerModel.node.replace(
63: Layer.succeed(SessionRunnerModel.Service, { resolve: () => Effect.succeed(model) }),
64: ),
65: Instance.node.replace(
66: makeGlobalNode({
67: service: Instance.Service,
68: deps: [LocationServiceMap.node],
69: layer: Layer.effect(
70: Instance.Service,
71: Effect.gen(function* () {
72: const locations = yield* LocationServiceMap.Service
73: const instances = yield* LayerMap.make(
74: (id: Session.ID) => {
75: const config = configs.find((config) => config.id === id)
76: if (!config) throw ...
Found 60 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/websearch.test.ts:
Line 277: expect(requests[1]?.headers["x-tavily-access-mode"]).toBeUndefined()
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/websearch-fixture.ts:
Line 39: headers: request.headers,
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-vllm.test.ts:
Line 237: authorization: request.headers.get("authorization"),
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-opencode.test.ts:
Line 207: authorization.push(request.headers.get("authorization"))
Line 423: requests.push({ body: await request.json(), variant: request.headers.get("x-variant") })
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-openai.test.ts:
Line 47: const event = yield* hooks.trigger("session", "model.request", {
Line 59: (yield* hooks.has("session", "http.request", ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect } from "bun:test"
2: import { OpenAIChat } from "@opencode/ai/protocols"
3: import { Agent } from "@opencode/schema/agent"
4: import { Money } from "@opencode/schema/money"
5: import { Session } from "@opencode/schema/session"
6: import type { SessionRequestKind } from "@opencode/plugin/effect/session"
7: import { Location } from "@opencode/core/location"
8: import { PluginHooks } from "@opencode/core/plugin/hooks"
9: import { Project } from "@opencode/core/project"
10: import { AbsolutePath } from "@opencode/core/schema"
11: import { SessionModelRequest } from "@opencode/core/session/model-request"
12: import { SessionModelTransport } from "@opencode/core/session/model-transport"
13: import { SessionRunnerModel } from "@opencode/core/session/runner/model"
14: import { DateTime, Effect } from "effect"
15: import { ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect, test } from "bun:test"
2: import { Message, ToolResultPart } from "@opencode/ai"
3: import { boundImages, unsupportedParts } from "@opencode/core/session/model-request"
4:
5: const capabilities = (input: string[]) => ({ tools: true, input, output: ["text"] })
6:
7: describe("SessionModelRequest.unsupportedParts", () => {
8: test("replaces unsupported user media with a visible error", () => {
9: const messages = unsupportedParts(
10: [
11: Message.user([
12: Message.text("Describe these files"),
13: { type: "media", mediaType: "image/png", data: "aGVsbG8=", filename: "logo.png" },
14: { type: "media", mediaType: "application/pdf", data: "JVBERg==", filename: "document.pdf" },
15: ]),
16: ],
17: capabilities(["text"]),
18: )
19:
20: ...
Found 31 matches
/home/byk/Code/opencode-lore/packages/opencode/eval/data/sessions/cli-sentry-issue.json:
Line 521: "content": "Clean. Now run the linter:\n[tool:bash] $ bunx ultracite check\ntest/commands/event/view.test.ts:228:9 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━\n\n × The ResolutionError variable is undeclared.\n \n 227 │ await expect(resolveProjectBySlug(\"my-project\", HINT)).rejects.toThrow(\n > 228 │ ResolutionError\n │ ^^^^^^^^^^^^^^^\n 229 │ );\n 230 │ });\n \n i By default, Biome recognizes browser and Node.js globals.\n You can ignore more globals using the javascript.globals configuration.\n \n\ntest/commands/event/view.test.ts:239:38 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━\n\n × The ResolutionError variable is undeclared.\n \n 237 │ expect.unreachable(\"Should have thrown\");\n 238 │ } catch (error) {\n > 239 │ ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts</path>
<type>file</type>
<content>
1: import { Tool } from "@opencode/schema/tool"
2: import type { Rpc } from "@opencode/schema/rpc"
3: import type { RpcCallOptions, RpcEventPayload } from "@opencode/client/promise/api"
4: import { Effect, Schema, SchemaAST, Stream } from "effect"
5: import type { Scope } from "effect"
6: import { HttpApiEndpoint, HttpApiSchema } from "effect/unstable/httpapi"
7: import { define } from "../effect/plugin.js"
8: import type { Plugin } from "./plugin.js"
9: import type { Info } from "./tool.js"
10: import type { RpcDomain, RpcHandlers } from "./rpc.js"
11:
12: type HostRegistration = { readonly dispose: Effect.Effect<void> }
13: type Registration = { readonly dispose: () => Promise<void> }
14: type PromiseContext = Parameters<Plugin["setup"]>[0]
15: type PromiseEvent = ReturnType<PromiseContext["event"]["subscribe"]> extends AsyncIterable<infer Event> ? ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts</path>
<type>file</type>
<content>
520: name: definition.name,
521: info: (input) => attempt((signal) => definition.info(input, { signal })),
522: base: base ? (input) => attempt((signal) => base(input, { signal })) : undefined,
523: branches: (input) => attempt((signal) => definition.branches(input, { signal })),
524: status: (input) => attempt((signal) => definition.status(input, { signal })),
525: diff: (input) => attempt((signal) => definition.diff(input, { signal })),
526: })
527: },
528: default: editor.default,
529: })
530: }),
531: ),
532: },
533: websearch: {
534: providers: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/registration.ts</path>
<type>file</type>
<content>
1: export interface Registration {
2: readonly dispose: () => Promise<void>
3: }
4:
5: export interface ModelHookOptions {
6: /** Limits the hook to one provider. Unscoped hooks apply to every provider. */
7: readonly providerID?: string
8: }
9:
10: export type Hooks<Spec> = <Name extends keyof Spec>(
11: name: Name,
12: callback: (input: Spec[Name]) => Promise<void> | void,
13: ) => Promise<Registration>
14:
15: export type ModelHooks<Spec> = <Name extends keyof Spec>(
16: name: Name,
17: callback: (input: Spec[Name]) => Promise<void> | void,
18: options?: Spec[Name] extends { readonly model: unknown } ? ModelHookOptions : never,
19: ) => Promise<Registration>
20:
21: export type Transform<Input> = (callback: (input: Input) => void) => Promise<Registration>
(End of file - total 21 lines)
</content>
Found 24 matches /home/byk/Code/opencode-lore/packages/opencode/src/index.ts: Line 31: * Per-request context (session ID, agent name, provider ID) is injected Line 129: // sub-agent or new project init overwrote the global between turns. Line 186: * OpenCode Task sub-agents run in a child session whose `parentID` points at Line 189: * session as a sub-agent and sizes its LTM injection accordingly (#1300) — the Line 190: * same signal Claude Code emits natively for its Task sub-agents. Line 196: * rather than permanently latching a real sub-agent as "not a sub-agent". Line 340: // worker agents, and redirect all provider baseURLs through the gateway. Line 344: // `mode: "subagent"` is REQUIRED for `hidden` to take effect: OpenCode Line 345: // defaults agents to `mode: "all"` (visible in BOTH the primary Tab Line 347: // for subagent-mode agents. ...
<path>/home/byk/Code/opencode-lore/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
320: existingState?.projectPath === thisProjectPath
321: ? existingState.gitRemote
322: : (getGitRemote(thisProjectPath) ?? "");
323:
324: projectState.set(ctx.project.id, {
325: projectPath: thisProjectPath,
326: gitRemote: thisGitRemote,
327: lastSeenAt: Date.now(),
328: });
329: reapStaleProjectState();
330:
331: // Module-level fallback (used only when chat.headers is bypassed).
332: // Updated on every plugin call so the most-recently-active project wins
333: // for fetches that arrive without a known session ID (e.g., direct
334: // SDK fetches that skip the plugin's chat.headers hook). ...
<path>/home/byk/Code/opencode-lore/packages/opencode/src/internal.ts</path> <type>file</type> <content> 1: /** 2: * Internal helpers for the Lore OpenCode plugin. 3: * 4: * These functions are intentionally kept OUT of the plugin entry module 5: * (`./index.ts`). OpenCode's legacy plugin loader treats EVERY function 6: * exported from a plugin module as a plugin instance and invokes it (see 7: * `getServerPlugin`/`getLegacyPlugins` in opencode's plugin loader). Exporting 8: * these helpers from the entry module caused them to be invoked as plugins and 9: * their return values pushed into the host's hooks array: 10: * `applyLoreProviderConfig` returns `undefined`, so the host crashed on the 11: * first hook dispatch with `undefined is not an object (evaluating 'A.event')` 12: * (the `?.` guards the `.event` property, not the `undefined` hook element). ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/package.json</path>
<type>file</type>
<content>
1: {
2: "$schema": "https://json.schemastore.org/package.json",
3: "name": "@opencode/plugin",
4: "version": "1.18.15",
5: "type": "module",
6: "license": "MIT",
7: "scripts": {
8: "test": "bun test --only-failures",
9: "typecheck": "tsgo --noEmit",
10: "build": "tsc -p tsconfig.build.json"
11: },
12: "exports": {
13: ".": "./src/promise/index.ts",
14: "./effect": "./src/effect/index.ts",
15: "./host": "./src/host.ts",
16: "./tui": "./src/tui/index.ts",
17: "./*": "./src/*.ts"
18: },
19: "imports": {
20: "#plugin-source": {
21: "bun": "./src/source.bun.ts",
22: "node": "./src/source.node.ts",
23: "default": "./src/source.node.ts"
24: }
25: },
26: "files": [
27: "dist"
28: ],
29: "dependencies": {
30: "@ai-sdk/provider": "3.0.8",
31: "@opencode/ai": "workspace:*",
32: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/tsconfig.build.json</path>
<type>file</type>
<content>
1: {
2: "$schema": "https://json.schemastore.org/tsconfig",
3: "extends": "./tsconfig.json",
4: "compilerOptions": {
5: "allowImportingTsExtensions": false,
6: "noEmit": false
7: }
8: }
(End of file - total 8 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts</path>
<type>file</type>
<content>
1: import assert from "node:assert/strict"
2: import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"
3: import { tmpdir } from "node:os"
4: import path from "node:path"
5: import { describe, it } from "node:test"
6: import { pathToFileURL } from "node:url"
7: import { Host } from "../src/host.js"
8:
9: // Every entrypoint throws if evaluated: resolution must never execute plugins.
10: const source = 'throw new Error("Plugin code must not run during resolution")'
11: const name = "@fixture/plugin"
12:
13: async function fixture(files: Record<string, string>, installed = false) {
14: const root = await mkdtemp(path.join(tmpdir(), "opencode-host-"))
15: const directory = installed ? path.join(root, "node_modules", name) : root
16: await Promise.all(
17: Object.entries(files).map(async ([file, content]) => {
18: await ...
Found 40 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/warming.ts:
Line 21: const settings = warming === true ? defaults : { ...defaults, ...warming }
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/vercel.ts:
Line 21: const mod = yield* Effect.promise(() => import("@ai-sdk/vercel"))
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/vcs/git.ts:
Line 59: const [current, root] = yield* Effect.all([ctx.git.branch(ctx.directory), ctx.git.defaultBranch(ctx.directory)], {
Line 101: const base = options?.base ?? (yield* git.defaultBranch(ctx.directory))?.ref
Line 199: const result = yield* run(["config", "init.defaultBranch"], { cwd })
Line 235: const defaultBranch = Effect.fn("VcsGit.defaultBranch")(function* (cwd: string) {
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/venice.ts:
Line 7: const { createVenice } = await ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts</path>
<type>file</type>
<content>
70: ),
71: }),
72: ]),
73: })
74:
75: export class LoadError extends Schema.TaggedError<LoadError>()("PluginModule.LoadError", {
76: message: Schema.String,
77: cause: Schema.optional(Schema.Defect()),
78: }) {}
79:
80: const load = Effect.fn("PluginModule.load")(function* (
81: operation: Extract<ConfigPluginSource.Operation, { type: "add" }>,
82: sources: ReturnType<typeof createPluginSources>,
83: options?: { readonly install?: boolean },
84: ) {
85: const local = path.isAbsolute(operation.target)
86: const npm = yield* Npm.Service
87: const installed = local
88: ? undefined
89: : options?.install === false
90: ? yield* npm.resolve(operation.target)
91: : yield* npm.add(operation.target)
92: // Legacy auto-discovery still admits standalone server sources. Configured
93: // local plugins always arrive here as directories. ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts</path>
<type>file</type>
<content>
1: export * as PluginModule from "./module.js"
2:
3: import type { Plugin } from "@opencode/plugin/effect/plugin"
4: import { Host } from "@opencode/plugin/host"
5: import { createPluginSources } from "@opencode/plugin/source"
6: import { Npm } from "@opencode/util/npm"
7: import { Deferred, Effect, FiberSet, PubSub, Schema, Stream } from "effect"
8: import path from "path"
9: import { stat } from "node:fs/promises"
10: import { fileURLToPath, pathToFileURL } from "url"
11: import type { ConfigPluginSource } from "../config/plugin/source.js"
12: import type { Generation } from "../plugin.js"
13: import { PluginPromise } from "./promise.js"
14: import { Watcher } from "../filesystem/watcher.js"
15:
16: export const make = Effect.fn("PluginModule.make")(function* () {
17: const watcher = yield* Watcher.Service
18: const scope = yield* Effect.scope
19: const runPromise = ...
<path>/home/byk/Code/opencode-lore/packages/opencode/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "@loreai/opencode",
3: "version": "0.40.0",
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Three-tier memory architecture for OpenCode — distillation, not summarization",
7: "main": "./src/index.ts",
8: "types": "./src/index.ts",
9: "exports": {
10: ".": {
11: "types": "./src/index.ts",
12: "bun": "./src/index.ts",
13: "default": "./src/index.ts"
14: }
15: },
16: "scripts": {
17: "typecheck": "tsc --noEmit",
18: "build": "echo '@loreai/opencode ships raw TS — no build step needed'"
19: },
20: "peerDependencies": {
21: "@opencode-ai/plugin": ">=1.1.0"
22: },
23: "dependencies": {
24: "@loreai/core": "workspace:*",
25: "@loreai/gateway": "workspace:*"
26: },
27: "devDependencies": {
28: "@opencode-ai/plugin": "^1.1.39",
29: "@opencode-ai/sdk": "^1.1.39",
30: ...
Found 10 matches
/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts:
Line 54: describe("LorePlugin config hook", () => {
Line 55: test("disables built-in compaction", async () => {
Line 61: expect(cfg.compaction).toEqual({ auto: false, prune: false });
Line 67: test("registers hidden worker agents", async () => {
Line 77: expect(agents["lore-distill"]).toEqual({
Line 97: "lore-distill",
Line 122: expect(agents["lore-distill"]).toBeDefined();
/home/byk/Code/opencode-lore/packages/opencode/test/routing.e2e.test.ts:
Line 173: test("the plugin's config hook pins provider baseURL to the discovered gateway", async () => {
Line 191: // And built-in compaction is disabled by the same hook.
Line 192: expect(cfg.compaction).toEqual({ auto: false, prune: false });
<path>/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts</path>
<type>file</type>
<content>
1: import { describe, test, expect } from "vitest";
2: import { fileURLToPath } from "node:url";
3: import { LorePlugin } from "../src/index";
4: import { applyLoreProviderConfig } from "../src/internal";
5: import type { Plugin } from "@opencode-ai/plugin";
6:
7: /**
8: * Minimal mock of the OpenCode client. Only stubs the methods the plugin
9: * actually calls during initialization.
10: */
11: function createMockClient() {
12: return {
13: tui: {
14: showToast: () => Promise.resolve(),
15: },
16: session: {
17: get: () => Promise.resolve({ data: {} }),
18: list: () => Promise.resolve({ data: [] }),
19: create: () => Promise.resolve({ data: { id: "worker_1" } }),
20: messages: () => Promise.resolve({ data: [] }),
21: message: () => Promise.resolve({ data: null }),
22: prompt: () => Promise.resolve({ data: {} }),
23: ...
Found 2 matches /home/byk/Code/opencode-v2-pilot/packages/schema/src/config/command.ts: Line 10: agent: Schema.String.pipe(optional), Line 12: subagent: Schema.Boolean.pipe(optional),
Found 10 matches
/home/byk/Code/opencode-v2-pilot/packages/schema/src/session-stats.ts:
Line 57: subagents: NonNegativeInt,
/home/byk/Code/opencode-v2-pilot/packages/schema/src/session-message.ts:
Line 78: agents: Prompt.fields.agents,
/home/byk/Code/opencode-v2-pilot/packages/schema/src/prompt.ts:
Line 68: agents: Schema.Array(AgentAttachment).pipe(optional),
Line 75: fromUserMessage: (input: Pick<Prompt, "text" | "files" | "agents" | "skills">) =>
Line 79: ...(input.agents === undefined ? {} : { agents: input.agents }),
/home/byk/Code/opencode-v2-pilot/packages/schema/src/config.ts:
Line 7: import { ConfigAgent } from "./config/agent.js"
Line 57: agents: Schema.Record(Schema.String, ConfigAgent.Info).pipe(optional).annotate({
Line 124: type: Schema.Literal("agents"),
/home/byk/Code/opencode-v2-pilot/packages/schema/src/prompt-input.ts:
Line 32: agents: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config.ts</path>
<type>file</type>
<content>
45: url: Schema.String.pipe(optional),
46: })
47: .pipe(optional)
48: .annotate({
49: description: "Enterprise sharing service configuration",
50: }),
51: username: Schema.String.pipe(optional).annotate({
52: description: "Username displayed in conversations and used for telemetry identity",
53: }),
54: permissions: Permission.Ruleset.pipe(optional).annotate({
55: description: "Ordered tool permission rules applied to agent tool use",
56: }),
57: agents: Schema.Record(Schema.String, ConfigAgent.Info).pipe(optional).annotate({
58: description: "Named built-in agent overrides and custom agent definitions",
59: }),
60: snapshots: Schema.Boolean.pipe(optional).annotate({
61: description: "Enable snapshots used for undo and revert behavior",
62: }),
63: watcher: ConfigWatcher.Info.pipe(optional).annotate({
64: description: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/agent.ts</path>
<type>file</type>
<content>
1: export * as ConfigAgent from "./agent.js"
2:
3: import { Schema } from "effect"
4: import { Permission } from "../permission.js"
5: import { optional, PositiveInt } from "../schema.js"
6: import { ConfigModel } from "./model.js"
7: import { ConfigProvider } from "./provider.js"
8:
9: export const Color = Schema.String.check(Schema.isPattern(/^#[0-9a-fA-F]{6}$/))
10:
11: export class Info extends Schema.Class<Info>("Config.Agent")({
12: model: ConfigModel.Selection.pipe(optional),
13: request: ConfigProvider.Request.pipe(optional),
14: system: Schema.String.pipe(optional),
15: description: Schema.String.pipe(optional),
16: mode: Schema.Literals(["subagent", "primary", "all"]).pipe(optional),
17: hidden: Schema.Boolean.pipe(optional),
18: color: Color.pipe(optional),
19: steps: PositiveInt.pipe(optional),
20: disabled: Schema.Boolean.pipe(optional),
21: ...
Found 1 matches /home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts: Line 37: export type SessionRequestKind = "primary" | "compaction" | "title" | "generate"
Found 28 matches
/home/byk/Code/opencode-v2-pilot/packages/schema/src/session-stats.ts:
Line 11: steps: NonNegativeInt,
Line 17: steps: NonNegativeInt,
Line 59: steps: NonNegativeInt,
/home/byk/Code/opencode-v2-pilot/packages/schema/src/session-message.ts:
Line 43: export interface AgentSelected extends Schema.Schema.Type<typeof AgentSelected> {}
/home/byk/Code/opencode-v2-pilot/packages/schema/src/prompt.ts:
Line 50: export interface AgentAttachment extends Schema.Schema.Type<typeof AgentAttachment> {}
/home/byk/Code/opencode-v2-pilot/packages/schema/src/config.ts:
Line 25: export class Info extends Schema.Class<Info>("Config.Info")({
/home/byk/Code/opencode-v2-pilot/packages/schema/src/location.ts:
Line 14: export class Info extends Schema.Class<Info>("Location.Info")({
/home/byk/Code/opencode-v2-pilot/packages/schema/src/reference.ts:
Line 16: hidden: Schema.Boolean.pipe(optional),
Line 25: hidden: Schema.Boolean.pipe(optional),
Line 37: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/agent.ts</path>
<type>file</type>
<content>
1: export * as Agent from "./agent.js"
2:
3: import { Schema } from "effect"
4: import { ephemeral, inventory } from "./event.js"
5: import { optional } from "./schema.js"
6: import { Model } from "./model.js"
7: import { Permission } from "./permission.js"
8: import { Provider } from "./provider.js"
9: import { PositiveInt, statics } from "./schema.js"
10:
11: const Updated = ephemeral({ type: "agent.updated", schema: {} })
12:
13: export const ID = Schema.String.pipe(Schema.brand("Agent.ID"))
14: export type ID = typeof ID.Type
15:
16: export const Name = Schema.String.pipe(Schema.brand("Agent.Name"))
17: export type Name = typeof Name.Type
18:
19: export const Color = Schema.String.annotate({ identifier: "Agent.Color" })
20: export type Color = typeof Color.Type
21:
22: export interface Info extends Schema.Schema.Type<typeof Info> {}
23: export const Info = ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config.ts</path>
<type>file</type>
<content>
20: import { ConfigToolOutput } from "./config/tool-output.js"
21: import { ConfigWatcher } from "./config/watcher.js"
22: import { ConfigWarming } from "./config/warming.js"
23: import { ConfigWorktree } from "./config/worktree.js"
24:
25: export class Info extends Schema.Class<Info>("Config.Info")({
26: $schema: optional(Schema.String).annotate({
27: description: "JSON schema reference for configuration validation",
28: }),
29: shell: Schema.String.pipe(optional).annotate({
30: description: "Default shell to use for terminal and shell tool execution",
31: }),
32: model: ConfigModel.Selection.pipe(optional).annotate({
33: description: "Default model to use when no session or agent model is selected",
34: }),
35: default_agent: Schema.String.pipe(optional).annotate({
36: description: "Default primary agent to use when no session agent is selected",
37: ...
Found 1 matches /home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts: Line 37: export type SessionRequestKind = "primary" | "compaction" | "title" | "generate"
Found 18 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/config.ts:
Line 227: ...agents.map((path) => new AgentsDirectory({ type: "agents", path })),
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/prompt.ts:
Line 23: agents?: PromptInput.Prompt["agents"]
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/command.ts:
Line 16: agents?: PromptInput.Prompt["agents"]
/home/byk/Code/opencode-v2-pilot/packages/core/src/v1/config/config.ts:
Line 108: ).annotate({ description: "Agent configuration, see https://opencode.ai/docs/agents" }),
/home/byk/Code/opencode-v2-pilot/packages/core/src/session.ts:
Line 183: agents?: PromptInput.Prompt["agents"]
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/internal.ts:
Line 14: import { ConfigAgentPlugin } from "../config/plugin/agent.js"
Line 230: ConfigAgentPlugin.Plugin,
/home/byk/Code/opencode-v2-pilot/packages/core/src/config/normalize.ts:
Line 155: const ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/agent.ts</path>
<type>file</type>
<content>
1: export * as ConfigAgentPlugin from "./agent.js"
2:
3: import { define } from "@opencode/plugin/effect/plugin"
4: import { Document, Info, type Entry } from "@opencode/schema/config"
5: import { ConfigAgent } from "@opencode/schema/config/agent"
6: import path from "path"
7: import { Effect, Option, PubSub, Schema, Stream } from "effect"
8: import { Agent } from "../../agent.js"
9: import { Config } from "../../config.js"
10: import { ConfigMarkdown } from "../markdown.js"
11: import { FSUtil } from "@opencode/util/fs-util"
12: import { ConfigAgentV1 } from "../../v1/config/agent.js"
13: import { ConfigMigrateV1 } from "../../v1/config/migrate.js"
14: import { Global } from "@opencode/util/global"
15: import { Permission } from "../../permission.js"
16: import type { FileAccess } from "../../file-access.js"
17: import type { ReadTool } from ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts</path>
<type>file</type>
<content>
400:
401: it.effect("does not let asynchronous plugin cleanup block recovered registry readiness", () =>
402: Effect.gen(function* () {
403: const plugins = yield* Plugin.Service
404: const commands = yield* Command.Service
405: const cleaned = yield* Deferred.make<void>()
406: yield* plugins.activate([
407: {
408: id: "async-cleanup",
409: revision: "1",
410: effect: (ctx) =>
411: Effect.gen(function* () {
412: yield* ctx.command.transform(() => {
413: throw new Error("failed")
414: })
415: yield* Effect.addFinalizer(() =>
416: plugins.awaitActivation.pipe(Effect.andThen(Deferred.succeed(cleaned, undefined))),
417: )
418: }),
419: },
420: {
421: id: "healthy",
422: revision: "1",
423: effect: (ctx) ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts</path>
<type>file</type>
<content>
1: import type { SessionApi } from "@opencode/client/promise/api"
2: import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai"
3: import type { Agent } from "@opencode/schema/agent"
4: import type { Model } from "@opencode/schema/model"
5: import type { PromptInput } from "@opencode/schema/prompt-input"
6: import type { Session } from "@opencode/schema/session"
7: import type { SessionInbox } from "@opencode/schema/session-inbox"
8: import type { SessionError } from "@opencode/schema/session-error"
9: import type { SessionMessage } from "@opencode/schema/session-message"
10: import type { JsonSchema, Types } from "effect"
11: import type { ModelHooks } from "./registration.js"
12:
13: export interface SessionPrompt {
14: readonly sessionID: Session.ID
15: readonly messageID: SessionMessage.ID
16: prompt: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/worktree.test.ts:
Line 19: import { Location } from "@opencode/core/location"
Line 714: yield* registration.dispose
Line 731: const scope = yield* Effect.acquireRelease(Scope.make(), (scope) => Scope.close(scope, Exit.void))
Line 738: yield* Scope.close(scope, Exit.void)
Line 739: yield* second.dispose
Line 742: yield* first.dispose
Line 792: it.live("cannot remove a worktree from another project through the current location", () =>
Line 808: it.live("rejects workspace-qualified locations before running worktree operations", () =>
Line 838: it.live("list invokes the location's strategies before returning inventory", () =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/websearch.test.ts:
Line 43: return { providerID, calls, failure, dispose: registration.dispose }
Line 368: yield* exa.dispose
Line 388: ...
Found 3 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts:
Line 120: it.effect("unloading a plugin removes its commands and runs cleanup", () =>
Line 401: it.effect("does not let asynchronous plugin cleanup block recovered registry readiness", () =>
Line 408: id: "async-cleanup",
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin.test.ts</path>
<type>file</type>
<content>
80: )
81: }
82:
83: it.effect("updates inventory metadata without restarting an unchanged generation", () =>
84: Effect.gen(function* () {
85: const plugins = yield* Plugin.Service
86: let loads = 0
87: const plugin = {
88: id: "metadata",
89: revision: "1",
90: source: { type: "package" as const, target: "fixture" },
91: effect: () => Effect.sync(() => loads++),
92: }
93:
94: yield* plugins.activate([plugin])
95: yield* plugins.activate([{ ...plugin, source: { ...plugin.source, outdated: true } }])
96:
97: expect(loads).toBe(1)
98: expect((yield* plugins.list())[0]?.source).toEqual({ type: "package", target: "fixture", outdated: true })
99: }),
100: )
101:
102: it.live("loads a local plugin with its configured options", () =>
103: Effect.gen(function* () {
104: const plugins = yield* Plugin.Service
105: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/worktree.test.ts:
Line 707: const registration = yield* worktrees.transform((editor) => editor.configure({ directory: parent }))
Line 714: yield* registration.dispose
Line 728: const first = yield* worktrees.transform((editor) =>
Line 733: .transform((editor) => editor.add({ ...git, id: Worktree.StrategyID.make("second") }))
Line 735: yield* worktrees.transform((editor) => editor.configure({ directory: parent }))
Line 739: yield* second.dispose
Line 742: yield* first.dispose
Line 752: it.live("does not fall back to Git when a registered strategy fails", () =>
Line 757: yield* worktrees.transform((editor) =>
Line 846: yield* worktrees.transform((editor) =>
Line 870: yield* worktrees.transform((editor) =>
Line 889: const reloaded = yield* Queue.unbounded<void>()
Line 904: yield* ...
<path>/home/byk/Code/opencode-lore/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
1: import type { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
2: import {
3: log,
4: getGitRemote,
5: discoverWorkspaceRoot,
6: installFetchInterceptor,
7: } from "@loreai/core";
8: // Helpers live in a separate module so they are NOT re-exported from this
9: // plugin entry. OpenCode's legacy plugin loader invokes every function
10: // exported from the entry module as a plugin; leaking these helpers pushed
11: // `undefined` into the host hooks array and crashed it on event dispatch
12: // (`undefined is not an object (evaluating 'A.event')`). See ./internal.ts.
13: import {
14: applyLoreProviderConfig,
15: gatewayAccessHeadersForRemote,
16: probeGateway,
17: shouldForwardUpstreamExtraHeader,
18: surfaceGatewayUnavailable,
19: } from "./internal";
20:
21: /**
22: * Lore plugin for OpenCode — transparent LLM proxy routing. ...
Found 2 matches
/home/byk/Code/opencode-lore/packages/opencode/src/index.ts:
Line 242: export const LorePlugin: Plugin = async (ctx) => {
Line 511: export default LorePlugin;
/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/routing.e2e.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/internal.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/gateway-smoke.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/subagent-detection.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/tui-silence.test.ts /home/byk/Code/opencode-lore/packages/opencode/test/session-state.test.ts
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/promise.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { mkdir } from "node:fs/promises"
3: import { join } from "node:path"
4: import { tmpdir } from "../../core/test/fixture/tmpdir"
5: import { OpenCode, Session } from "../src"
6:
7: test("Promise host uses the embedded router", async () => {
8: await using directory = await tmpdir("opencode-promise-sdk-")
9: const config = join(directory.path, "config")
10: await mkdir(config)
11: const opencode = await OpenCode.create({
12: events: { persist: true },
13: config: { directory: config, project: false, content: "{}" },
14: })
15:
16: try {
17: const location = { directory: directory.path }
18: const session = await opencode.sessions.create({ location })
19: const selected = await opencode.sessions.get({ sessionID: session.id })
20: const page = await opencode.sessions.list({ directory: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { mkdir } from "node:fs/promises"
3: import { join } from "node:path"
4: import { Schema } from "effect"
5: import { tmpdir } from "../../core/test/fixture/tmpdir"
6: import { OpenCode, Session, SessionMessage } from "../src"
7:
8: const metadata = Schema.decodeUnknownSync(Schema.Struct({ account: Schema.String }))
9: const hostOptions = (directory: string) => ({
10: database: { path: join(directory, "opencode.sqlite") },
11: config: { directory, project: false, content: "{}" },
12: models: { fetch: false },
13: fs: { filewatcher: false },
14: })
15:
16: test("Promise instances are lazy, share by key and Location, and stay isolated between hosts", async () => {
17: await using directory = await tmpdir("opencode-promise-instances-")
18: const otherDirectory = join(directory.path, "other")
19: await ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances-lifecycle.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import { Instance } from "@opencode/core/instance/service"
3: import { Session } from "@opencode/core/session"
4: import { Location } from "@opencode/schema/location"
5: import { AbsolutePath } from "@opencode/schema/schema"
6: import { Context, Deferred, Effect, Exit, Fiber, Layer } from "effect"
7: import { tmpdirScoped } from "../../core/test/fixture/tmpdir"
8: import { testEffect } from "../../core/test/lib/effect"
9: import { EmbeddedHost } from "../src/internal/host"
10:
11: const it = testEffect(Layer.empty)
12:
13: it.live("a cancelled borrower cannot strand a later failed instance construction", () =>
14: Effect.gen(function* () {
15: const directory = yield* tmpdirScoped()
16: const started = yield* Deferred.make<Fiber.Fiber<unknown, unknown>>()
17: const release = yield* Deferred.make<void>()
18: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/agent.ts</path>
<type>file</type>
<content>
1: import type { AgentApi } from "@opencode/client/promise/api"
2: import type { Agent } from "@opencode/schema/agent"
3: import type { Transform } from "./registration.js"
4: import type { DeepMutable } from "./types.js"
5:
6: export interface AgentEditor {
7: list(): readonly DeepMutable<Agent.Info>[]
8: get(id: string): DeepMutable<Agent.Info> | undefined
9: default(id: string | undefined): void
10: update(id: string, update: (agent: DeepMutable<Agent.Info>) => void): void
11: remove(id: string): void
12: }
13:
14: export interface AgentDomain extends AgentApi {
15: readonly transform: Transform<AgentEditor>
16: readonly reload: () => Promise<void>
17: }
(End of file - total 17 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-native-compaction.test.ts</path>
<type>file</type>
<content>
180: if (!session) return yield* Effect.die("Missing fixture session")
181: const instructions = Instructions.make({
182: key: Instructions.Key.make("test/native"),
183: codec: Schema.toCodecJson(Schema.String),
184: read: Effect.succeed("Current instructions"),
185: render: { initial: String, changed: (_previous, value) => value, removed: () => "removed" },
186: })
187: yield* InstructionState.prepare(db, bus, instructions, sessionID)
188: yield* hooks.register("session", "model.request", (event) =>
189: Effect.sync(() => {
190: event.headers["x-test-hook"] = event.kind
191: }),
192: )
193: yield* hooks.register("session", "http.request", (event) =>
194: Effect.sync(() => event.request.headers.set("x-http-hook", event.kind)),
195: )
196: const prompt = Effect.fnUntraced(function* (text: string, synthetic = ...
No files found
/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts</path>
<type>file</type>
<content>
199: /** The identity a plugin hook sees for one outbound request. */
200: interface HookScope {
201: readonly sessionID: SessionSchema.ID
202: readonly agent: Agent.ID
203: readonly model: Model.Ref
204: readonly kind: SessionRequestKind
205: }
206:
207: const sessionHeaders = (session: Pick<SessionSchema.Info, "id" | "parentID" | "projectID">, app: App.Info) => ({
208: "x-session-affinity": session.id,
209: "X-Session-Id": session.id,
210: ...(session.parentID ? { "x-parent-session-id": session.parentID } : {}),
211: "User-Agent": App.useragent(app),
212: "x-opencode-project": session.projectID,
213: "x-opencode-session": session.id,
214: "x-opencode-client": app.name,
215: })
216:
217: const promptCacheKey = (sessionID: SessionSchema.ID) =>
218: /^ses_[0-9a-f]{64}$/.test(sessionID) ? sessionID.slice(4) : sessionID
219:
220: // Lets ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts</path>
<type>file</type>
<content>
1: export * as Agent from "./agent.js"
2:
3: import path from "path"
4: import { makeLocationNode } from "@opencode/util/effect/app-node"
5: import { Array, Context, Effect, Layer, Types } from "effect"
6: import { Agent } from "@opencode/schema/agent"
7: import { Global } from "@opencode/util/global"
8: import { Bus } from "./bus.js"
9: import { State } from "./state.js"
10:
11: const SHELL_OUTPUT_GLOB = (data: string) => path.join(data, "shell", "*", "*")
12: const TOOL_OUTPUT_GLOB = (data: string) => path.join(data, "tool-output", "*")
13:
14: export const ID = Agent.ID
15: export type ID = typeof ID.Type
16: export const Name = Agent.Name
17: export type Name = Agent.Name
18: export const defaultID = ID.make("build")
19:
20: export const Color = Agent.Color
21:
22: export const Info = Agent.Info
23: export type Info = Agent.Info
24:
25: export { Event } from ...
Found 100 matches (more matches available) /home/byk/Code/opencode-v2-pilot/packages/core/src/workspace.ts: Line 163: Effect.onError((cause) => Scope.close(scope, Exit.failCause(cause))), Line 210: yield* Scope.close(connection.scope, Exit.void) Line 308: if (connection) yield* Scope.close(connection.scope, Exit.void) /home/byk/Code/opencode-v2-pilot/packages/core/src/snapshot.ts: Line 124: scopes: [yield* scope(repo.worktree)], /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts: Line 24: // the prefix diff below stays index-aligned and a failed revision is not retried until it changes. Line 77: Exit.isFailure(exit) && !activation.failure ? Scope.close(activation.scope, exit) : Effect.void, Line 110: return entry?.plugin.id !== definition.id || entry.plugin.revision !== definition.revision Line 135: yield* Scope.close(slot.activation.scope, ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts</path>
<type>file</type>
<content>
1: export * as Plugin from "./plugin.js"
2: export { Event, ID, Info, Source, State } from "@opencode/schema/plugin"
3:
4: import { Plugin } from "@opencode/schema/plugin"
5: import { Node } from "@opencode/util/effect/app-node"
6: import { LayerNode } from "@opencode/util/effect/layer-node"
7: import type { PersistentPty } from "./persistent-pty.js"
8: import { Cause, Context, Effect, Exit, Latch, Layer, Logger, Queue, References, Scope, Semaphore } from "effect"
9: import { Bus } from "./bus.js"
10: import { KV } from "./kv.js"
11: import { PluginHost } from "./plugin/host.js"
12: import { type Failure, type Generation, Service } from "./plugin/service.js"
13: import { State } from "./state.js"
14:
15: export { awaitActivation, type Generation, type Interface, Service } from "./plugin/service.js"
16:
17: const layer = Layer.effect(
18: Service,
19: Effect.gen(function* () ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/import-boundaries.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { mkdtemp, rm } from "node:fs/promises"
3: import { join, resolve, sep } from "node:path"
4:
5: const directory = resolve(import.meta.dir, "..")
6: const client = resolve(import.meta.dir, "../../client")
7: const core = resolve(import.meta.dir, "../../core")
8: const server = resolve(import.meta.dir, "../../server")
9:
10: test("bundles the Promise and Effect clients with the in-memory host", async () => {
11: const bundles = await Promise.all([bundleInputs("@opencode/sdk"), bundleInputs("@opencode/sdk/effect")])
12:
13: for (const inputs of bundles) {
14: expect(within(inputs, client).length).toBeGreaterThan(0)
15: expect(within(inputs, core).length).toBeGreaterThan(0)
16: expect(within(inputs, server).length).toBeGreaterThan(0)
17: }
18: })
19:
20: async function bundleInputs(specifier: ...
/home/byk/Code/opencode-lore/packages/opencode/tsconfig.json
<path>/home/byk/Code/opencode-lore/packages/opencode/tsconfig.json</path>
<type>file</type>
<content>
1: {
2: "extends": "../../tsconfig.base.json",
3: "compilerOptions": {
4: "noEmit": true,
5: "types": ["bun"],
6: "paths": {
7: "@loreai/core": ["../core/src/index.ts"]
8: }
9: },
10: "include": ["src", "test", "script", "scripts", "eval"]
11: }
(End of file - total 11 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances-effect.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import path from "path"
3: import { LanguageModel, LLMClient } from "@opencode/ai"
4: import { OpenAIChat } from "@opencode/ai/protocols"
5: import { TestLLM } from "@opencode/ai/testing"
6: import { llmClient } from "@opencode/core/effect/app-node-platform"
7: import { makeMemoryDriver } from "@opencode/core/environment/index"
8: import { SessionRunnerModel } from "@opencode/core/session/runner/model"
9: import { WorkspaceDriver } from "@opencode/core/workspace/driver"
10: import { Plugin } from "@opencode/plugin/effect"
11: import { Context, Deferred, Effect, Exit, Layer, Schema, Scope } from "effect"
12: import { tmpdirScoped } from "../../core/test/fixture/tmpdir"
13: import { testEffect } from "../../core/test/lib/effect"
14: import { AbsolutePath, Agent, Location, OpenCode } from "../src/effect"
15:
16: const it = ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/effect/plugin.ts</path>
<type>file</type>
<content>
1: import type { ExperimentalApi, GenerateApi, PluginApi } from "@opencode/client/effect/api"
2: import type { Location } from "@opencode/schema/location"
3: import type { Effect, Scope } from "effect"
4: import type { PluginOptions } from "../options.js"
5: import type { App } from "../app.js"
6: import type { AgentDomain } from "./agent.js"
7: import type { AISDKDomain } from "./aisdk.js"
8: import type { CatalogDomain } from "./catalog.js"
9: import type { CommandDomain } from "./command.js"
10: import type { EventDomain } from "./event.js"
11: import type { IntegrationDomain } from "./integration.js"
12: import type { MCPDomain } from "./mcp.js"
13: import type { PermissionDomain } from "./permission.js"
14: import type { ReferenceDomain } from "./reference.js"
15: import type { RpcDomain } from "./rpc.js"
16: import type { SessionDomain } from "./session.js"
17: import ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/hooks.ts</path>
<type>file</type>
<content>
1: export * as PluginHooks from "./hooks.js"
2:
3: import type { AISDKHooks } from "@opencode/plugin/effect/aisdk"
4: import type { SessionHooks } from "@opencode/plugin/effect/session"
5: import type { ShellHooks } from "@opencode/plugin/effect/shell"
6: import type { ToolFailures, ToolHooks } from "@opencode/plugin/effect/tool"
7: import type { ModelHookOptions } from "@opencode/plugin/effect/registration"
8: import type { PermissionHooks } from "@opencode/plugin/effect/permission"
9: import { Context, Effect, Layer, Scope } from "effect"
10: import { makeLocationNode } from "@opencode/util/effect/app-node"
11: import { State } from "../state.js"
12:
13: export interface Domains {
14: readonly aisdk: AISDKHooks
15: readonly session: SessionHooks
16: readonly permission: PermissionHooks
17: readonly shell: ShellHooks
18: readonly tool: ToolHooks
19: }
20:
21: type ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/index.ts</path>
<type>file</type>
<content>
1: export type { PluginOptions } from "../options.js"
2: export type { StorageEntry, StorageScanOptions, StorageScanResult } from "../storage.js"
3: export * as Plugin from "./plugin.js"
4:
5: export { Agent } from "@opencode/schema/agent"
6: export { Command } from "@opencode/schema/command"
7: export { Connection } from "@opencode/schema/connection"
8: export { Credential } from "@opencode/schema/credential"
9: export { Integration } from "@opencode/schema/integration"
10: export { Location } from "@opencode/schema/location"
11: export { Mcp } from "@opencode/schema/mcp"
12: export { Model } from "@opencode/schema/model"
13: export { PersistentPty } from "@opencode/schema/persistent-pty"
14: export { Provider } from "@opencode/schema/provider"
15: export { Reference } from "@opencode/schema/reference"
16: export { Rpc } from "@opencode/schema/rpc"
17: export { Skill } from ...
Found 46 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/transport.test.ts:
Line 18: return Promise.reject(new Error("The caller's Fetch must not receive embedded SDK requests"))
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/promise.test.ts:
Line 7: test("Promise host uses the embedded router", async () => {
Line 36: test("Promise event streams support cancellation", async () => {
Line 53: test("closing cancels active Promise event streams", async () => {
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/logging.test.ts:
Line 8: await Effect.runPromise(
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/instances.test.ts:
Line 16: test("Promise instances are lazy, share by key and Location, and stay isolated between hosts", async () => {
Line 22: const cleanups: string[] = []
Line 35: async setup(ctx) {
Line 38: await ctx.session.hook("prompt", (event) => {
Line 42: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/server/test/plugin-activation.test.ts</path>
<type>file</type>
<content>
1: import { expect } from "bun:test"
2: import { mkdir } from "node:fs/promises"
3: import path from "node:path"
4: import { SdkPlugins } from "@opencode/core/plugin/sdk"
5: import { Plugin } from "@opencode/plugin/effect"
6: import { Context, Deferred, Effect, Fiber, Layer } from "effect"
7: import { HttpEffect, HttpRouter, HttpServer } from "effect/unstable/http"
8: import { tmpdirScoped } from "../../core/test/fixture/tmpdir"
9: import { it } from "../../core/test/lib/effect"
10: import { createRoutes } from "../src/routes"
11:
12: const fixture = Effect.fn(function* (plugin: Plugin.Plugin) {
13: const tmp = yield* tmpdirScoped("opencode-plugin-activation-")
14: const first = path.join(tmp.path, "first")
15: const second = path.join(tmp.path, "second")
16: const config = path.join(tmp.path, "config")
17: yield* Effect.promise(() => Promise.all([first, ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/test/contract-identity.test.ts</path>
<type>file</type>
<content>
1: import { expect, test } from "bun:test"
2: import { Location as CoreLocation } from "@opencode/core/location"
3: import { SessionInbox as CoreSessionInbox } from "@opencode/core/session/inbox"
4: import { SessionMessage as CoreSessionMessage } from "@opencode/core/session/message"
5: import { Agent } from "@opencode/schema/agent"
6: import { Config } from "@opencode/schema/config"
7: import { Event } from "@opencode/schema/event"
8: import { Location } from "@opencode/schema/location"
9: import { Model } from "@opencode/schema/model"
10: import { Project } from "@opencode/schema/project"
11: import { Provider } from "@opencode/schema/provider"
12: import { WebSearch } from "@opencode/schema/websearch"
13: import { Session } from "@opencode/schema/session"
14: import { SessionInbox } from "@opencode/schema/session-inbox"
15: import { SessionMessage } from ...
Found 12 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-openai.test.ts:
Line 56: baseURL: event.baseURL,
Line 57: headers: event.headers,
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-github-copilot.test.ts:
Line 178: expect(event.headers).toEqual({ "X-Interaction-Type": "conversation-agent", "X-Interaction-Id": event.sessionID })
Line 186: expect(event.headers).toEqual({
Line 198: expect(event.headers).toEqual({
Line 210: expect(event.headers).toEqual({
Line 222: expect(event.headers).toEqual({ "X-Interaction-Type": "conversation-agent", "X-Interaction-Id": event.sessionID })
Line 237: expect(event.headers).toEqual({})
Line 267: expect(event.headers).toEqual({ "X-Interaction-Type": "conversation-agent", "X-Interaction-Id": event.sessionID })
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-runner.test.ts:
Line 1519: event.baseURL = ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/host.ts</path>
<type>file</type>
<content>
450: editor.add({
451: id: WebSearch.ID.make(definition.id),
452: name: definition.name,
453: execute: definition.execute,
454: }),
455: default: {
456: get: editor.default.get,
457: set: (selection) =>
458: editor.default.set(
459: selection === false || selection === "random" ? selection : WebSearch.ID.make(selection),
460: ),
461: },
462: })
463: }),
464: }
465: }
466:
467: function internalMethod(value: IntegrationMethod): Integration.Method {
468: if (value.type === "oauth" || value.type === "command") {
469: return { ...value, id: Integration.MethodID.make(value.id) }
470: }
471: return value
472: }
473:
474: function agentInfo(value: Agent.Info) {
475: return {
476: ...value,
477: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/host.ts</path>
<type>file</type>
<content>
1: export * as Host from "./host.js"
2:
3: import path from "node:path"
4: import { importModule, resolveModule } from "@opencode/util/runtime-import"
5:
6: export interface Target {
7: readonly directory: string
8: readonly name?: string
9: }
10:
11: export interface Entrypoints {
12: readonly server?: string
13: readonly tui?: string
14: readonly rpc?: string
15: }
16:
17: export function resolve(target: Target): Entrypoints {
18: const entry = (subpaths: readonly string[]) => {
19: for (const subpath of subpaths) {
20: const specifier = target.name
21: ? [target.name, subpath].filter(Boolean).join("/")
22: : path.resolve(target.directory, subpath || "index")
23: try {
24: return resolveModule(specifier, target.directory)
25: } catch (error) {
26: if (
27: !(error instanceof Error) ||
28: ...
<path>/home/byk/Code/opencode-lore/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
82: /**
83: * Start the gateway server in-process by importing @loreai/gateway as a library.
84: *
85: * Uses startGateway() which handles the full port fallback chain
86: * (3207 → 5673 → random) and port file management automatically.
87: * Returns the URL of the started gateway, or null on failure.
88: */
89: async function startInProcess(): Promise<string | null> {
90: try {
91: // Dynamic import — the gateway may be resolved from src (workspace) or
92: // dist/index.cjs (npm). Use a variable to prevent tsc from resolving the
93: // module at compile time (the .d.cts only exists after building).
94: const gw = "@loreai/gateway";
95: const { startGateway } = await import(/* webpackIgnore: true */ gw);
96: const handle = await startGateway({ quiet: true, local: true });
97: const url = `http://127.0.0.1:${handle.port}`;
98:
99: if ...
<path>/home/byk/Code/opencode-lore/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
420: if (providerID) {
421: output.headers["x-lore-provider"] = providerID;
422: }
423: // For local/self-hosted providers (vllm, ollama, llamacpp, etc.),
424: // forward LORE_UPSTREAM_<PROVIDER> as the x-lore-upstream-url header
425: // so the gateway can route the request to the user's local server.
426: // Convention matches the Pi plugin's registerProviders() block.
427: if (providerID) {
428: const envKey = `LORE_UPSTREAM_${providerID.toUpperCase().replace(/-/g, "_")}`;
429: const upstream = process.env[envKey];
430: if (upstream && !output.headers["x-lore-upstream-url"]) {
431: output.headers["x-lore-upstream-url"] = upstream;
432: }
433: }
434: // Forward LORE_UPSTREAM_EXTRA_HEADERS values as literal headers so
435: // corporate proxies / ...
Found 27 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/src/internal/instances.ts:
Line 11: import { Context, Duration, Effect, Layer, LayerMap, Scope } from "effect"
Line 21: * Reconstruct configuration on a cache miss. Resources belong to the instance Scope; other requirements
Line 24: readonly configure: (key: string) => Effect.Effect<Configuration, unknown, R | Scope.Scope>
Line 31: // The ambient side wins the merge, so the instance Scope owns configured resources rather than the
Line 32: // build Scope that was captured alongside the services.
Line 36: .pipe(Effect.updateContext((ambient: Context.Context<Scope.Scope>) => Context.merge(context, ambient))),
Line 94: // Eviction can close the lookup's scope; do not make that fiber wait on itself.
/home/byk/Code/opencode-v2-pilot/packages/sdk/src/internal/host.ts:
Line 10: import { Context, Effect, Layer, ManagedRuntime, Scope } from "effect"
Line 22: /** Host hooks ...
<path>/home/byk/Code/opencode-v2-pilot/packages/sdk/src/internal/host.ts</path>
<type>file</type>
<content>
1: export * as EmbeddedHost from "./host"
2:
3: import { SdkPlugins } from "@opencode/core/plugin/sdk"
4: import { SessionRestart } from "@opencode/core/session/execution/restart"
5: import { Workspace } from "@opencode/core/workspace"
6: import { WorkspaceDriver } from "@opencode/core/workspace/driver"
7: import { createEmbeddedRoutes } from "@opencode/server/routes"
8: import type { ServerOptions } from "@opencode/server/options"
9: import type { LayerNode } from "@opencode/util/effect/layer-node"
10: import { Context, Effect, Layer, ManagedRuntime, Scope } from "effect"
11: import { HttpEffect, HttpRouter, HttpServer, HttpServerRequest } from "effect/unstable/http"
12: import { context, layer, type LogOptions } from "../logging"
13: import { OwnedFetch } from "./fetch"
14: import { SdkInstances } from "./instances"
15:
16: export interface CreateOptions<R = never> extends ...
/home/byk/Code/opencode-v2-pilot/packages/core/test/state.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/state-replay.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/state-group.test.ts /home/byk/Code/opencode-v2-pilot/packages/core/test/instruction-state.test.ts
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/state.test.ts:
Line 7: it.effect("commits a transform atomically when its updater is interrupted", () =>
Line 18: const scope = yield* Scope.make()
Line 20: .transform((editor) => {
Line 23: .pipe(Scope.provide(scope), Effect.forkChild)
Line 31: yield* Scope.close(scope, Exit.void)
Line 45: yield* state.transform((editor) => {
Line 55: it.effect("runs transforms during every reload", () =>
Line 63: yield* state.transform((editor) => {
Line 69: yield* state.reload()
Line 74: it.effect("disposes a transform once and rebuilds remaining state", () =>
Line 80: yield* state.transform((editor) => {
Line 83: const registration = yield* state.transform((editor) => {
Line 88: yield* registration.dispose
Line 91: yield* registration.dispose
Line 112: yield* ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/state.test.ts</path>
<type>file</type>
<content>
45: yield* state.transform((editor) => {
46: editor.add("value")
47: })
48:
49: // Update events publish from notify, so consumers reading on the event
50: // must observe the rebuilt state, not the previous one.
51: expect(observed).toEqual([["value"]])
52: }),
53: )
54:
55: it.effect("runs transforms during every reload", () =>
56: Effect.gen(function* () {
57: let value = "first"
58: const state = State.create({
59: initial: () => ({ values: [] as string[] }),
60: editor: (editor) => ({ add: (item: string) => editor.values.push(item) }),
61: })
62:
63: yield* state.transform((editor) => {
64: editor.add(value)
65: })
66: expect(state.get().values).toEqual(["first"])
67:
68: value = "second"
69: yield* state.reload()
70: ...
<path>/home/byk/Code/opencode-lore/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "lore-monorepo",
3: "private": true,
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Monorepo root for Lore — three-tier memory architecture",
7: "main": "./packages/opencode/src/index.ts",
8: "exports": {
9: ".": "./packages/opencode/src/index.ts"
10: },
11: "packageManager": "pnpm@10.28.0",
12: "volta": {
13: "node": "24.16.0",
14: "pnpm": "10.28.0"
15: },
16: "pnpm": {
17: "onlyBuiltDependencies": [
18: "esbuild",
19: "onnxruntime-node",
20: "sharp"
21: ],
22: "overrides": {
23: "basic-ftp": "5.3.1",
24: "ip-address": "10.2.0",
25: "fast-xml-parser": "5.7.3",
26: "@huggingface/hub": "2.11.0",
27: "onnxruntime-node": "1.27.0",
28: "yaml": ">=2.8.3",
29: "esbuild": ">=0.28.1",
30: "@opentelemetry/core": ">=2.8.0",
31: "protobufjs": ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/compaction.ts</path>
<type>file</type>
<content>
1: export * as ConfigCompaction from "./compaction.js"
2:
3: import { Schema } from "effect"
4: import { NonNegativeInt, optional } from "../schema.js"
5:
6: export class Keep extends Schema.Class<Keep>("Config.Compaction.Keep")({
7: tokens: NonNegativeInt.pipe(optional),
8: }) {}
9:
10: export class Info extends Schema.Class<Info>("Config.Compaction")({
11: auto: Schema.Boolean.pipe(optional),
12: keep: Keep.pipe(optional),
13: buffer: NonNegativeInt.pipe(optional),
14: }) {}
(End of file - total 14 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/plugin.ts</path>
<type>file</type>
<content>
1: export * as ConfigPlugin from "./plugin.js"
2:
3: import { Schema } from "effect"
4: import { optional } from "../schema.js"
5:
6: export class Entry extends Schema.Class<Entry>("Config.Plugin.Entry")({
7: package: Schema.String,
8: options: Schema.Record(Schema.String, Schema.Unknown).pipe(optional),
9: }) {}
10:
11: export const Plugin = Schema.Union([Schema.String, Entry])
12: export type Plugin = typeof Plugin.Type
13:
14: export const Plugins = Plugin.pipe(Schema.Array)
(End of file - total 14 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts</path>
<type>file</type>
<content>
1: import { Tool } from "@opencode/schema/tool"
2: import type { Rpc } from "@opencode/schema/rpc"
3: import type { RpcCallOptions, RpcEventPayload } from "@opencode/client/promise/api"
4: import { Effect, Schema, SchemaAST, Stream } from "effect"
5: import type { Scope } from "effect"
6: import { HttpApiEndpoint, HttpApiSchema } from "effect/unstable/httpapi"
7: import { define } from "../effect/plugin.js"
8: import type { Plugin } from "./plugin.js"
9: import type { Info } from "./tool.js"
10: import type { RpcDomain, RpcHandlers } from "./rpc.js"
11:
12: type HostRegistration = { readonly dispose: Effect.Effect<void> }
13: type Registration = { readonly dispose: () => Promise<void> }
14: type PromiseContext = Parameters<Plugin["setup"]>[0]
15: type PromiseEvent = ReturnType<PromiseContext["event"]["subscribe"]> extends AsyncIterable<infer Event> ? ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts</path>
<type>file</type>
<content>
260: }),
261: )
262:
263: const adaptApiMethod = <PromiseMethod>(
264: endpoint: HttpApiEndpoint.Top,
265: method: (input: never) => Effect.Effect<unknown, unknown>,
266: ) => {
267: const compiled = compileEndpoint(endpoint)
268: return ((input?: unknown) =>
269: Effect.gen(function* () {
270: const decoded = yield* Effect.forEach(compiled.decode, (decode) => decode(input ?? {}))
271: const result = yield* method(Object.assign({}, ...decoded) as never)
272: if (compiled.noContent) return undefined
273: return yield* compiled.encode(result)
274: }).pipe(Effect.runPromiseWith(context))) as PromiseMethod
275: }
276:
277: const transform =
278: <Editor>(domain: {
279: transform: ...
<path>/home/byk/Code/opencode-lore/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
330:
331: // Module-level fallback (used only when chat.headers is bypassed).
332: // Updated on every plugin call so the most-recently-active project wins
333: // for fetches that arrive without a known session ID (e.g., direct
334: // SDK fetches that skip the plugin's chat.headers hook).
335: currentProject = { path: thisProjectPath, gitRemote: thisGitRemote };
336:
337: try {
338: const hooks: Hooks = {
339: // Disable built-in compaction (gateway handles it), register hidden
340: // worker agents, and redirect all provider baseURLs through the gateway.
341: config: async (input) => {
342: const cfg = input as Record<string, unknown>;
343: cfg.compaction = { auto: false, prune: false };
344: // `mode: "subagent"` is REQUIRED for `hidden` to take effect: OpenCode
345: // defaults agents to `mode: "all"` (visible in ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/package.json</path>
<type>file</type>
<content>
1: {
2: "$schema": "https://json.schemastore.org/package.json",
3: "name": "@opencode/plugin",
4: "version": "1.18.15",
5: "type": "module",
6: "license": "MIT",
7: "scripts": {
8: "test": "bun test --only-failures",
9: "typecheck": "tsgo --noEmit",
10: "build": "tsc -p tsconfig.build.json"
11: },
12: "exports": {
13: ".": "./src/promise/index.ts",
14: "./effect": "./src/effect/index.ts",
15: "./host": "./src/host.ts",
16: "./tui": "./src/tui/index.ts",
17: "./*": "./src/*.ts"
18: },
19: "imports": {
20: "#plugin-source": {
21: "bun": "./src/source.bun.ts",
22: "node": "./src/source.node.ts",
23: "default": "./src/source.node.ts"
24: }
25: },
26: "files": [
27: "dist"
28: ],
29: "dependencies": {
30: "@ai-sdk/provider": "3.0.8",
31: "@opencode/ai": "workspace:*",
32: ...
Found 26 matches
/home/byk/Code/opencode-v2-pilot/packages/sdk/test/import-boundaries.test.ts:
Line 8: const server = resolve(import.meta.dir, "../../server")
/home/byk/Code/opencode-v2-pilot/packages/desktop/test/browser-native.test.ts:
Line 15: entrypoints: [path.join(import.meta.dir, "browser/native.ts")],
/home/byk/Code/opencode-v2-pilot/packages/schema/test/v1-isolation.test.ts:
Line 11: test("compatibility entrypoints preserve isolated V1 schema identity", () => {
/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts:
Line 29: describe("Host.resolve", () => {
Line 30: it("resolves conventional entrypoints without package.json", async () => {
Line 32: assert.deepEqual(Host.resolve(plugin.target), {
Line 41: assert.deepEqual(Host.resolve(plugin.target), {
Line 59: assert.deepEqual(Host.resolve(plugin.target), {
Line 67: it("resolves local conventional entrypoints with package.json but no exports", async () => {
...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts</path>
<type>file</type>
<content>
1: import assert from "node:assert/strict"
2: import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"
3: import { tmpdir } from "node:os"
4: import path from "node:path"
5: import { describe, it } from "node:test"
6: import { pathToFileURL } from "node:url"
7: import { Host } from "../src/host.js"
8:
9: // Every entrypoint throws if evaluated: resolution must never execute plugins.
10: const source = 'throw new Error("Plugin code must not run during resolution")'
11: const name = "@fixture/plugin"
12:
13: async function fixture(files: Record<string, string>, installed = false) {
14: const root = await mkdtemp(path.join(tmpdir(), "opencode-host-"))
15: const directory = installed ? path.join(root, "node_modules", name) : root
16: await Promise.all(
17: Object.entries(files).map(async ([file, content]) => {
18: await ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/wellknown.test.ts:
Line 21: return Response.json({
Line 26: headers: { authorization: "Bearer {env:TOKEN}" },
Line 30: if (url.pathname === "/config/secret" && request.headers.get("authorization") === "Bearer secret") {
Line 31: return Response.json({ config: { model: "remote/model" } })
Line 33: return new Response("Not found", { status: 404 })
Line 45: headers: { authorization: "Bearer {env:TOKEN}" },
Line 62: fetch: () => Response.json({ auth: { command: ["login"], env: "TOKEN" } }),
Line 95: fetch: () => Response.json({ auth: { command: [command], env: "TOKEN" } }),
/home/byk/Code/opencode-v2-pilot/packages/core/test/websearch.test.ts:
Line 71: new WebSearch.Response({
Line 267: expect(yield* websearch.query({ query: "limited" ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect } from "bun:test"
2: import { OpenAIChat } from "@opencode/ai/protocols"
3: import { Agent } from "@opencode/schema/agent"
4: import { Money } from "@opencode/schema/money"
5: import { Session } from "@opencode/schema/session"
6: import type { SessionRequestKind } from "@opencode/plugin/effect/session"
7: import { Location } from "@opencode/core/location"
8: import { PluginHooks } from "@opencode/core/plugin/hooks"
9: import { Project } from "@opencode/core/project"
10: import { AbsolutePath } from "@opencode/core/schema"
11: import { SessionModelRequest } from "@opencode/core/session/model-request"
12: import { SessionModelTransport } from "@opencode/core/session/model-transport"
13: import { SessionRunnerModel } from "@opencode/core/session/runner/model"
14: import { DateTime, Effect } from "effect"
15: import { ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect, test } from "bun:test"
2: import { Message, ToolResultPart } from "@opencode/ai"
3: import { boundImages, unsupportedParts } from "@opencode/core/session/model-request"
4:
5: const capabilities = (input: string[]) => ({ tools: true, input, output: ["text"] })
6:
7: describe("SessionModelRequest.unsupportedParts", () => {
8: test("replaces unsupported user media with a visible error", () => {
9: const messages = unsupportedParts(
10: [
11: Message.user([
12: Message.text("Describe these files"),
13: { type: "media", mediaType: "image/png", data: "aGVsbG8=", filename: "logo.png" },
14: { type: "media", mediaType: "application/pdf", data: "JVBERg==", filename: "document.pdf" },
15: ]),
16: ],
17: capabilities(["text"]),
18: )
19:
20: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/v1-migration.test.ts:
Line 483: { message: "api", statusCode: 503, isRetryable: true, responseBody: "discard" },
/home/byk/Code/opencode-v2-pilot/packages/core/test/tool-webfetch.test.ts:
Line 38: Effect.map((response) => HttpClientResponse.fromWeb(request, response)),
Line 585: it.effect("does not retry ordinary 403 responses", () =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/tool-subagent.test.ts:
Line 43: const childText = "child final response"
/home/byk/Code/opencode-v2-pilot/packages/core/test/effect-app-node-platform.test.ts:
Line 24: WebSocketConstructor.proxy("wss://provider.test/responses", {
Line 30: WebSocketConstructor.proxy("wss://provider.test/responses", { HTTPS_PROXY: "http://https-proxy.test" }),
Line 32: expect(WebSocketConstructor.proxy("ws://provider.test/responses", { HTTP_PROXY: "http://http-proxy.test" ...
<path>/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/registration.ts</path>
<type>file</type>
<content>
1: export interface Registration {
2: readonly dispose: () => Promise<void>
3: }
4:
5: export interface ModelHookOptions {
6: /** Limits the hook to one provider. Unscoped hooks apply to every provider. */
7: readonly providerID?: string
8: }
9:
10: export type Hooks<Spec> = <Name extends keyof Spec>(
11: name: Name,
12: callback: (input: Spec[Name]) => Promise<void> | void,
13: ) => Promise<Registration>
14:
15: export type ModelHooks<Spec> = <Name extends keyof Spec>(
16: name: Name,
17: callback: (input: Spec[Name]) => Promise<void> | void,
18: options?: Spec[Name] extends { readonly model: unknown } ? ModelHookOptions : never,
19: ) => Promise<Registration>
20:
21: export type Transform<Input> = (callback: (input: Input) => void) => Promise<Registration>
(End of file - total 21 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/config/normalize.ts</path>
<type>file</type>
<content>
120: })
121: const nativeCommands = decodeMap(input.commands, ConfigCommand.Info, ["commands"], diagnostics, decodeEncoded)
122: mergeMap(
123: encoded,
124: "commands",
125: migratedCommands,
126: nativeCommands,
127: isRecord(input.command) || isRecord(input.commands),
128: diagnostics,
129: )
130:
131: const legacyAgents = mapValues(
132: decodeMap(input.agent, ConfigAgentV1.Info, ["agent"], diagnostics, decodeValue),
133: (value) => canonical(ConfigAgent.Info, ConfigMigrateV1.migrateAgent(value)),
134: )
135: const legacySmallModel = own(input, "small_model")
136: ? decodeValue(Schema.String, input.small_model, ["small_model"], diagnostics)
137: : undefined
138: const migratedSmallModel = legacySmallModel
139: ? ConfigMigrateV1.migrate({ small_model: legacySmallModel }).agents?.title?.model
140: : ...
Found 21 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/config/normalize.ts:
Line 9: import { ConfigCompaction } from "@opencode/schema/config/compaction"
Line 324: if (!isRecord(input.compaction)) {
Line 328: unsupportedIfPresent(input.compaction, "tail_turns", ["compaction", "tail_turns"], diagnostics)
Line 329: unsupportedIfPresent(input.compaction, "prune", ["compaction", "prune"], diagnostics)
Line 331: if (own(input.compaction, "auto")) {
Line 333: ConfigCompaction.Info.fields.auto,
Line 334: input.compaction.auto,
Line 340: const legacyTokens = own(input.compaction, "preserve_recent_tokens")
Line 342: ConfigCompaction.Keep.fields.tokens,
Line 343: input.compaction.preserve_recent_tokens,
Line 348: const nativeKeep = isRecord(input.compaction.keep) ? input.compaction.keep : undefined
Line 349: if (own(input.compaction, "keep") && !nativeKeep) invalid(["compaction", "keep"], diagnostics)
...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/config/normalize.ts</path>
<type>file</type>
<content>
310: }
311: recognized.forEach(([key, field]) => {
312: const leaf = decodeEncoded(field, value[key], [...path, key], diagnostics)
313: if (leaf === undefined) return
314: overlay(timeout, key, leaf, [...path, key], diagnostics)
315: })
316: }
317:
318: function normalizeCompaction(
319: input: Record<string, unknown>,
320: encoded: Record<string, unknown>,
321: diagnostics: Diagnostic[],
322: ) {
323: if (!own(input, "compaction")) return
324: if (!isRecord(input.compaction)) {
325: invalid(["compaction"], diagnostics)
326: return
327: }
328: unsupportedIfPresent(input.compaction, "tail_turns", ["compaction", "tail_turns"], diagnostics)
329: unsupportedIfPresent(input.compaction, "prune", ["compaction", "prune"], diagnostics)
330: const result: Record<string, unknown> = {}
331: if (own(input.compaction, "auto")) {
332: ...
Found 56 matches /home/byk/Code/opencode-lore/packages/core/src/index.ts: Line 356: installFetchInterceptor, Line 359: } from "./fetch-interceptor"; /home/byk/Code/opencode-lore/packages/core/src/fetch-interceptor.ts: Line 2: * Fetch-level interception for transparent LLM API proxy routing. Line 5: * and URL context), this interceptor wraps `globalThis.fetch` to redirect Line 9: * provider), and the interceptor transparently reroutes them through the Line 14: /** Configuration for the fetch interceptor. */ Line 17: gatewayBase: string; Line 19: * Dynamic headers to inject on every intercepted request. Line 28: * LLM API path patterns that should be intercepted. Line 70: * Canonical gateway endpoint for each protocol. When a request is intercepted Line 142: * LLM-like — a fast body-parse to decide whether to intercept anyway. ...
<path>/home/byk/Code/opencode-lore/packages/core/src/fetch-interceptor.ts</path> <type>file</type> <content> 306: * Install a fetch interceptor that transparently reroutes LLM API calls 307: * through the Lore gateway. 308: * 309: * The interceptor: 310: * 1. Checks if the outgoing URL matches a known LLM API path 311: * 2. Rewrites the URL to the gateway, preserving the path 312: * 3. Adds `X-Lore-Upstream-URL` (base) and `X-Lore-Upstream-Path` (original 313: * endpoint pathname, for verbatim forwarding) 314: * 4. Injects dynamic `X-Lore-*` context headers from `getHeaders()` 315: * 5. Preserves ALL original headers (auth, content-type, etc.) 316: * 317: * Returns a cleanup function that restores the original `globalThis.fetch`. 318: */ 319: /** 320: * Process-global slot holding the original `globalThis.fetch` captured before 321: * any interceptor was installed. ...
<path>/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts</path>
<type>file</type>
<content>
200: };
201:
202: applyLoreProviderConfig(cfg, "http://127.0.0.1:3207");
203:
204: const provider = cfg.provider as Record<string, Record<string, unknown>>;
205: expect(
206: (provider.openai.options as Record<string, unknown>).headerTimeout,
207: ).toBe(false);
208: });
209:
210: test("is a no-op when gatewayBase is empty (test env / startup failure)", () => {
211: // In NODE_ENV=test the plugin's init skips gateway start, so
212: // gatewayBase is "". We must not overwrite the user's provider config
213: // with a broken "/v1" value in that case.
214: const cfg: Record<string, unknown> = {
215: provider: { openai: { npm: "@ai-sdk/openai" } },
216: };
217: applyLoreProviderConfig(cfg, "");
218: const provider = cfg.provider as Record<string, unknown>;
219: const openai = provider.openai as Record<string, ...
<path>/home/byk/Code/opencode-v2-pilot/packages/schema/src/location.ts</path>
<type>file</type>
<content>
1: export * as Location from "./location.js"
2:
3: import { Schema } from "effect"
4: import { AbsolutePath, optional } from "./schema.js"
5: import { ProjectID } from "./project-id.js"
6: import { WorkspaceID } from "./workspace-id.js"
7:
8: export interface Ref extends Schema.Schema.Type<typeof Ref> {}
9: export const Ref = Schema.Struct({
10: directory: AbsolutePath,
11: workspaceID: optional(WorkspaceID),
12: }).annotate({ identifier: "Location.Ref" })
13:
14: export class Info extends Schema.Class<Info>("Location.Info")({
15: directory: AbsolutePath,
16: workspaceID: optional(WorkspaceID),
17: project: Schema.Struct({
18: id: ProjectID,
19: directory: AbsolutePath,
20: canonical: AbsolutePath,
21: }),
22: }) {}
23:
24: export function response<S extends Schema.Top>(data: S) {
25: return Schema.Struct({ location: Info, data })
26: }
(End of file ...
The V2 loader accepts only a default-exported definition containing either { id, setup } or { id, effect }:
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts:60-71/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts:107-116The Promise API is:
Cleanup = () => Promise<void> | voidPlugin = { id, setup }Plugin.define() returns the definition unchangedEvidence:
/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/plugin.ts:54-63The current Lore root entry exports a V1 plugin function:
/home/byk/Code/opencode-lore/packages/opencode/src/index.ts:242/home/byk/Code/opencode-lore/packages/opencode/src/index.ts:505-511That function fails the V2 module schema. The V2 loader would report:
Plugin must export a default definition with an id and an effect or setup function.
Lore should keep the legacy root and add a distinct ./server export whose default is:
export default Plugin.define({
id: "lore",
async setup(ctx) {
// V2 integration
},
})
V2 resolves package/server before the package root:
/home/byk/Code/opencode-v2-pilot/packages/plugin/src/host.ts:17-43/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts:81-104Lore currently exports only ".":
/home/byk/Code/opencode-lore/packages/opencode/package.json:9-15The V2 Promise context exposes direct domains rather than client, project, directory, or worktree fields:
/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/plugin.ts:25-52Lore only needs a narrow internal interface:
type LoreContext = {
readonly location: Plugin.Context["location"]
readonly agent: Pick<Plugin.Context["agent"], "transform">
readonly session: Pick<Plugin.Context["session"], "hook">
}
Keep the implementation against this type and let the default V2 definition pass ...
### Current State - **Sep 9, 2026, 09:28 onward — active investigation:** User requested a strictly read-only investigation of `/home/byk/Code/opencode-v2-pilot`; no files may be edited. The goal is to determine the smallest faithful mock/test harness that `/home/byk/Code/opencode-lore` can retain for a V2 `Plugin.define` adapter. - The requested evidence areas are: 1. Promise plugin API and a…
* 🔴 (10:21) User stated plugin resolution must “never execute plugins.” * 🔴 (10:21) `/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts` uses fixture source `throw new Error("Plugin code must not run during resolution")` for every entrypoint so any evaluation during `Host.resolve` causes test failure. * 🔴 (10:21) `/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.…
* 🔴 (10:18) `/home/byk/Code/opencode-v2-pilot/packages/schema/src/config/compaction.ts` exports namespace `ConfigCompaction`; defines `Keep extends Schema.Class<Keep>("Config.Compaction.Keep")` with optional `tokens: NonNegativeInt`; and defines `Info extends Schema.Class<Info>("Config.Compaction")` with optional `auto: Schema.Boolean`, `keep: Keep`, and `buffer: NonNegativeInt`. * 🔴 (10:19) `/…
* 🔴 (10:17) User showed `/home/byk/Code/opencode-lore/package.json`; it defines private ESM package `lore-monorepo`, description `Monorepo root for Lore — three-tier memory architecture`, license `FSL-1.1-Apache-2.0`, and maps both `main` and export `"."` to `./packages/opencode/src/index.ts`. * 🔴 (10:17) `/home/byk/Code/opencode-lore/package.json` pins tooling through `packageManager: "pnpm@10…
* 🔴 (10:10) User showed `/home/byk/Code/opencode-v2-pilot/packages/server/test/plugin-activation.test.ts`, whose fixture creates independent `first` and `second` directories, registers an SDK plugin, and sends authenticated requests with `location[directory]` using Basic credentials `opencode:secret`. * 🔴 (10:10) `/home/byk/Code/opencode-v2-pilot/packages/server/test/plugin-activation.test.ts:6…
* 🔴 (10:30) User showed `/home/byk/Code/opencode-v2-pilot/packages/schema/src/location.ts`: `Location.Ref` contains `directory: AbsolutePath` and optional `workspaceID: WorkspaceID`; `Location.Info` contains the same location fields plus `project: { id: ProjectID, directory: AbsolutePath, canonical: AbsolutePath }`; `response<S extends Schema.Top>(data: S)` returns `Schema.Struct({ location: Inf…
* 🔴 (10:24) User showed `/home/byk/Code/opencode-v2-pilot/packages/core/src/config/normalize.ts` function `normalizeCompaction()` rejects non-record `compaction`, marks legacy `compaction.tail_turns` and `compaction.prune` unsupported, decodes `compaction.auto`, and emits `encoded.compaction` when the normalized result is nonempty or the input object is empty. * 🔴 (10:24) User showed `normalize…
* 🔴 (10:07) User identified `/home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts`. * 🔴 (10:07) User showed `/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts` defines `HookScope` with `sessionID: SessionSchema.ID`, `agent: Agent.ID`, `model: Model.Ref`, and `kind: SessionRequestKind`. * 🔴 (10:07) User showed `sessionHeaders()` emits `"x-session-affinity…
* 🔴 (10:02) User showed a search with 100 matches across core tests involving location-scoped services, transform registration/disposal, reloads, and scope cleanup. Notable exact tests included `packages/core/test/worktree.test.ts`: `"cannot remove a worktree from another project through the current location"`, `"rejects workspace-qualified locations before running worktree operations"`, and `"l…
* 🔴 (10:02) User showed `packages/plugin/src/promise/session.ts` defines `SessionPrompt` with readonly `sessionID: Session.ID` and `messageID: SessionMessage.ID`, mutable `prompt: Types.DeepMutable<PromptInput.Prompt>`, optional `metadata?: Record<string, unknown>`, and `delivery: SessionInbox.Delivery`. * 🔴 (10:02) User showed `SessionContext` contains readonly `sessionID: Session.ID`, `…
* 🔴 (09:58) User stated every internal Lore worker must explicitly use `mode: "subagent"` with `hidden: true` so it never surfaces in the host project's agent/skill picker. * 🔴 (09:58) User showed `packages/opencode/package.json` for `@loreai/opencode` version `0.40.0`: ESM package (`"type": "module"`), license `FSL-1.1-Apache-2.0`, description `Three-tier memory architecture for OpenCode — dis…
* 🔴 (09:55) User showed `packages/plugin/src/promise/adapter.ts` implementing `fromPromise(plugin: Plugin)`, which adapts Promise plugins into the existing Effect-only Core runtime while attaching setup-time hook registrations to the plugin scope and preserving the captured fiber context for boot-time transform batching. * 🔴 (09:55) User showed stream lifecycle behavior in `packages/plugin/src/…
* 🔴 (09:55) User stated a nightly-version behavior requirement: always return a version newer than the installed binary’s `CLI_VERSION`. * 🔴 (09:55) User showed a search yielding exactly 31 matches across `/home/byk/Code/opencode-lore/packages/opencode/eval/data/sessions/cli-sentry-issue.json` and `/home/byk/Code/opencode-lore/packages/opencode/eval/data/sessions/cli-nightly.json`. * 🔴 (09:55)…
* 🔴 (09:54) User showed `/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request.test.ts` imports `Message` and `ToolResultPart` from `@opencode/ai`, and `boundImages` and `unsupportedParts` from `@opencode/core/session/model-request`; helper `capabilities(input: string[])` returns `{ tools: true, input, output: ["text"] }`. * 🔴 (09:54) User showed `SessionModelRequest.unsuppo…
* 🔴 (09:53) User showed `/home/byk/Code/opencode-lore/packages/opencode/test/index.test.ts` test `"returns only config and tool hooks (no event/transform hooks)"` verifies `hooks.config` and `hooks.tool` are defined, while `hooks.event`, `hooks["experimental.chat.system.transform"]`, `hooks["experimental.chat.messages.transform"]`, and `hooks["experimental.session.compacting"]` are undefined; th…
* 🔴 (09:45) User showed `/home/byk/Code/opencode-v2-pilot/packages/sdk/test/promise.test.ts` contains 3 Promise SDK tests: 1. `"Promise host uses the embedded router"` creates an embedded host with `events: { persist: true }` and `config: { directory: config, project: false, content: "{}" }`, creates/gets/lists a session, observes `"session.created"`, verifies a missing `Session.ID.create()` pro…
* 🔴 (09:42) User showed `SessionHookContext.hook<Name extends keyof SessionHooks>()` in `/home/byk/Code/opencode-v2-pilot/services/www/src/docs/content/build/plugins/index.mdx` accepts `options?: Name extends "prompt" ? never : { providerID?: string }`; provider-scoping options are therefore never allowed for `"prompt"` hooks. * 🔴 (09:42) User showed permission hooks run after configured permis…
* 🔴 (09:40) User showed `/home/byk/Code/opencode-v2-pilot/packages/core/src/location-service-map.ts` defines `Service` as `LayerMap.LayerMap<Location.Ref, Instance.Services, Instance.Error>` under context key `"@opencode/example/LocationServiceMap"`; `Service.get(ref)` unwraps `locations.get(ref)`, and `node` is `LayerNode.unbound(Service, Node.tags.values.global)`. * 🔴 (09:40) User showed `Loc…
* 🔴 (09:38) User showed `/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/worktree.test.ts` verifies Promise worktree callback interruption propagates through its `AbortSignal`: plugin `"cancel-worktree"` registers strategy `"cancel"` whose `create` promise rejects with `Error("cancelled")` on abort; interrupting the scoped fiber changes `signal.aborted` from `false` to `true`, and the…
Date: Sep 9, 2026 * 🔴 (09:37) User showed `/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/module.test.ts` has 2 live loader/watcher tests: 1. loading a plugin that imports missing `shared/new/nested/helper.ts` initially fails, creation of that helper produces a change within `"5 seconds"`, and reloading yields plugin `{ id: "appeared" }`; 2. closing the loader `Scope` while native mo…
* 🔴 (09:35) User showed `/home/byk/Code/opencode-v2-pilot/packages/schema/src/config.ts` defines native `agents` as `Schema.Record(Schema.String, ConfigAgent.Info).pipe(optional)` with description “Named built-in agent overrides and custom agent definitions”; `default_agent` is an optional string described as the default primary agent when no session agent is selected. * 🔴 (09:35) User showed `…
* 🔴 (09:34) User stated Lore’s internal worker agents must use `mode: "subagent"` with `hidden: true`, so each one never surfaces in the host project’s agent/skill picker; OpenCode honors `hidden` only for subagent-mode agents, while its default `mode: "all"` would expose them in both the primary Tab picker and `@` subagent picker. * 🔴 (09:34) User showed `/home/byk/Code/opencode-lore/packages/…
* 🔴 (09:31) User provided `/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts` (102 lines). It imports `SessionApi`, `GenerationOptionsFields`, `Message`, `SystemPart`, `Agent`, `Model`, `PromptInput`, `Session`, `SessionInbox`, `SessionError`, `SessionMessage`, `JsonSchema`, `Types`, and `ModelHooks`. * 🔴 (09:31) User showed `SessionPrompt` contains readonly `sessionID: Se…
* 🔴 (09:30) User provided `/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/index.ts` (20 lines). It exports types `PluginOptions` from `../options.js` and `StorageEntry`, `StorageScanOptions`, `StorageScanResult` from `../storage.js`; exports namespace `Plugin` from `./plugin.js`; and re-exports schema namespaces `Agent`, `Command`, `Connection`, `Credential`, `Integration`, `Locati…
* 🔴 (09:30) User provided `/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/plugin.ts` (63 lines), which imports `OpenCodeClient` from `@opencode/client`, `GenerateApi` and `PluginApi` from `@opencode/client/promise/api`, `Location` from `@opencode/schema/location`, `PluginOptions` from `../options.js`, `App` from `../app.js`, and Promise-domain types from `./agent.js`, `./aisdk.js`,…
* 🔴 (09:29) User stated the `/home/byk/Code/opencode-v2-pilot` runtime dependency direction is Schema → Core and Protocol → Server; Client runtime code may depend on Schema and Protocol but never Core or Server; `sdk` composes Client, Core, and Server (`AGENTS.md:2`). * 🔴 (09:29) User required always running `bun typecheck` from package directories such as `packages/core`, never invoking `tsc` …
Date: Sep 9, 2026 * 🔴 [enforced-read-only-workflow] (09:28) User required a read-only investigation in /home/byk/Code/opencode-v2-pilot and explicitly instructed not to edit files. * 🟡 (09:28) User asked to inspect Promise plugin tests, registration cleanup tests, session model/HTTP hook invocation tests, package resolution/exports tests, and config agent naming in /home/byk/Code/opencode-v2-pi…