Dashboard › opencode › Session 0GuotSgRj7gN
0GuotSgRj7gNbCBeFPerform a read-only adversarial correctness review of the current uncommitted Lore V2 port in /home/byk/Code/opencode-lore-v2. Inspect all changed files versus parent @-. Focus on dual V1/V2 exports, Request routing equivalence, location isolation, gateway lease concurrency/cleanup, setup failure/unload, package tarball/runtime resolution, parent-session behavior, and regression gaps. Do not modify files. Return findings ordered by severity with exact file:line evidence and a final PASS/CONCERN/MUST-FIX verdict. Run focused tests only if needed; never run tests from a repository root if package guidance forbids it, and use --printConsoleTrace for Vitest diagnostics.
<skill_content name="jj-guide"> # Skill: jj-guide # jj Guide for AI Agents Jujutsu (jj) is a Git-compatible VCS with mutable commits, automatic snapshotting, no staging area, and first-class conflicts. This skill teaches you how to use it safely from a non-interactive agent environment. If `.jj/` exists in the repo root, this is a jj repo. **Use `jj` commands, not `git`.** In a colocated repo (`.jj/` *and* `.git/`), git tools can read the state, but mutations should go through `jj` so the operation log stays consistent. ## Critical Rules - **NEVER** use interactive flags (`-i`, `--interactive`). TUI prompts hang in agent environments. This applies to `jj split -i`, `jj squash -i`, `jj commit -i`, `jj resolve`, `jj diffedit`, etc. - **ALWAYS** pass `-m "msg"` when describing/committing. Without `-m`, an editor opens and hangs. - **VERIFY** mutations with `jj st` and `jj log` after `squash`, `abandon`, `rebase`, `restore`, `commit`. ...
<path>/home/byk/Code/opencode-lore-v2</path> <type>directory</type> <entries> .craft.yml .git .github/ .gitignore .jj/ .lore.md .oxfmtrc.json .oxlintrc.json AGENTS.md CHANGELOG.md codecov.yml LICENSE node_modules/ package.json packages/ patches/ pnpm-lock.yaml pnpm-workspace.yaml quality/ README.md scripts/ stryker.config.mjs supabase/ tsconfig.base.json tsconfig.json vitest.config.ts vitest.evals.config.ts vitest.mutation.config.ts (28 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/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. ...
<path>/home/byk/Code/opencode-lore-v2/quality/REVIEW.md</path> <type>file</type> <content> 1: # Review Heuristics — Lore 2: 3: This document codifies the review bar for pull requests. It exists because 4: adversarial review has repeatedly caught correctness bugs that a green test 5: suite missed — skip/early-return branches, lifecycle sequences, and fan-out 6: registry gaps. Institutionalizing these patterns so they compound. 7: 8: The review workflow (§6) is referenced from AGENTS.md. 9: 10: --- 11: 12: ## 1. Regression-test discipline 13: 14: Every adversarial-review finding that surfaces a defect **must** land a 15: deterministic regression test in the same PR. The test: 16: - fails on the base branch (proving it reproduces the bug), 17: - passes on the fix (proving the fix works), 18: - drives the *real* precondition, not an artificially-constructed state (e.g. ...
/home/byk/Code/opencode-lore-v2/AGENTS.md
Working copy changes: M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M pnpm-lock.yaml Working copy (@) : wlpqmtos 35358505 lore-v2-plugin | feat(opencode): add V2 server plugin Parent commit (@-): uutomtup 42911412 main | fix(gateway): preserve large recall continuations (#1730)
wlpqmtosolpk 35358505e1c3 feat(opencode): add V2 server plugin uutomtupslqm 429114122aa1 fix(gateway): preserve large recall continuations (#1730)
M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M pnpm-lock.yaml
diff --git a/packages/core/src/fetch-interceptor.ts b/packages/core/src/fetch-interceptor.ts
index 602362b0f6..f10263cde3 100644
--- a/packages/core/src/fetch-interceptor.ts
+++ b/packages/core/src/fetch-interceptor.ts
@@ -195,6 +195,12 @@
upstreamPath: string;
};
+export type DynamicRequestHeaders = Readonly<Record<string, string>>;
+
+export type DynamicRequestHeadersSource =
+ | DynamicRequestHeaders
+ | (() => DynamicRequestHeaders);
+
/**
* Rewrite an intercepted URL to the gateway, handling both standard /v1/...
* paths and non-standard paths (e.g. /codex/responses). Used by the
@@ -284,17 +290,7 @@
// Never intercept requests already going to the gateway
if (url.startsWith(gatewayBase)) return false;
// Never intercept local requests (could be local LLM or gateway itself)
- const host = parsed.hostname;
- if (
- host === "localhost" ||
- host === "127.0.0.1" ||
- host === "0.0.0.0" ||
- // URL.hostname KEEPS brackets on IPv6 ...
diff --git a/packages/opencode/package.json b/packages/opencode/package.json
index 2dc3111e7d..df2bad1d3c 100644
--- a/packages/opencode/package.json
+++ b/packages/opencode/package.json
@@ -11,14 +11,25 @@
"types": "./src/index.ts",
"bun": "./src/index.ts",
"default": "./src/index.ts"
+ },
+ "./server": {
+ "types": "./dist/server.d.ts",
+ "bun": "./dist/server.js",
+ "default": "./dist/server.js"
}
},
"scripts": {
"typecheck": "tsc --noEmit",
- "build": "echo '@loreai/opencode ships raw TS — no build step needed'"
+ "build": "tsx script/build.ts"
},
"peerDependencies": {
- "@opencode-ai/plugin": ">=1.1.0"
+ "@opencode-ai/plugin": ">=1.1.0",
+ "@opencode/plugin": ">=0.0.0"
+ },
+ "peerDependenciesMeta": {
+ "@opencode/plugin": {
+ "optional": true
+ }
},
"dependencies": {
"@loreai/core": "workspace:*",
@@ -27,10 +38,12 @@
"devDependencies": {
"@opencode-ai/plugin": ...
...output truncated...
Full output saved to: /home/byk/.local/share/opencode/tool-output/tool_08655ef1d001WHpE3LOnYhdu3W
@@ -5481,7 +6166,20 @@
'@aws-sdk/middleware-eventstream': 3.972.16
'@aws-sdk/middleware-websocket': 3.972.26
'@aws-sdk/token-providers': 3.1048.0
- '@aws-sdk/types': 3.973.11
+ '@aws-sdk/types': 3.973.13
+ '@smithy/core': 3.24.6
+ '@smithy/fetch-http-handler': 5.4.6
+ '@smithy/node-http-handler': 4.7.7
+ '@smithy/types': 4.15.0
+ tslib: 2.8.1
+
+ '@aws-sdk/client-cognito-identity@3.1057.0':
+ dependencies:
+ '@aws-crypto/sha256-browser': 5.2.0
+ '@aws-crypto/sha256-js': 5.2.0
+ '@aws-sdk/core': 3.974.18
+ '@aws-sdk/credential-provider-node': 3.972.52
+ '@aws-sdk/types': 3.973.13
'@smithy/core': 3.24.6
'@smithy/fetch-http-handler': 5.4.6
'@smithy/node-http-handler': 4.7.7
@@ -5490,7 +6188,7 @@
'@aws-sdk/core@3.974.18':
dependencies:
- ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts</path>
<type>file</type>
<content>
1: /**
2: * Fetch-level interception for transparent LLM API proxy routing.
3: *
4: * Instead of overwriting provider baseURLs early (which loses original auth
5: * and URL context), this interceptor wraps `globalThis.fetch` to redirect
6: * outgoing LLM API calls through the Lore gateway at the HTTP level.
7: *
8: * The SDK builds requests normally (correct auth, correct URL for each
9: * provider), and the interceptor transparently reroutes them through the
10: * gateway while preserving all original headers.
11: */
12: import * as log from "./log";
13:
14: /** Configuration for the fetch interceptor. */
15: export type FetchInterceptorConfig = {
16: /** Base URL of the Lore gateway (e.g., "http://127.0.0.1:3207"). */
17: gatewayBase: string;
18: /**
19: * Dynamic headers to inject on every intercepted request. ...
<path>/home/byk/Code/opencode-lore-v2/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: parseUpstreamExtraHeaders,
17: probeGateway,
18: shouldForwardUpstreamExtraHeader,
19: surfaceGatewayUnavailable,
20: } from "./internal";
21:
22: /**
23: * Lore plugin for OpenCode — transparent LLM proxy ...
<path>/home/byk/Code/opencode-lore-v2/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-lore-v2/packages/opencode/src/server-runtime.ts</path>
<type>file</type>
<content>
1: import { getGitRemote, log } from "@loreai/core";
2: import {
3: gatewayAccessHeadersForRemote,
4: parseUpstreamExtraHeaders,
5: probeGateway,
6: shouldForwardUpstreamExtraHeader,
7: } from "./internal";
8:
9: const gatewayPackage = "@loreai/gateway";
10: const knownGatewayPorts = [3207, 5673];
11:
12: export interface LoreServerRuntime {
13: gatewayBase: string;
14: projectPath: string;
15: gitRemote: string;
16: gatewayHeaders: Record<string, string>;
17: release: () => Promise<void>;
18: }
19:
20: export interface ServerRuntimeDependencies {
21: resolveGateway?: () => Promise<{
22: gatewayBase: string;
23: gatewayHeaders: Record<string, string>;
24: shutdown?: () => Promise<void>;
25: }>;
26: gitRemote?: (path: string) => string | null;
27: }
28:
29: interface GatewayHandle {
30: port: number;
31: owned: boolean;
32: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts</path>
<type>file</type>
<content>
1: import { rewriteRequest } from "@loreai/core";
2: import type { Plugin } from "@opencode/plugin";
3: import { acquireServerRuntime, buildServerHeaders } from "./server-runtime";
4:
5: const workers = [
6: ["lore-distill", "Lore memory distillation worker"],
7: ["lore-curator", "Lore knowledge curator worker"],
8: ["lore-query-expand", "Lore query expansion worker"],
9: ] as const;
10:
11: export default {
12: id: "lore",
13: setup: async (ctx) => {
14: const runtime = await acquireServerRuntime(ctx.location.project.directory);
15: if (!runtime) return;
16:
17: const registrations: Array<{ dispose: () => Promise<void> }> = [];
18: try {
19: registrations.push(
20: await ctx.agent.transform((editor) => {
21: for (const [id, description] of workers) {
22: editor.update(id, (agent) => {
23: ...
<path>/home/byk/Code/opencode-lore-v2/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: "./server": {
16: "types": "./src/server.ts",
17: "bun": "./dist/server.js",
18: "default": "./dist/server.js"
19: }
20: },
21: "scripts": {
22: "typecheck": "tsc --noEmit",
23: "build": "tsx script/build.ts"
24: },
25: "peerDependencies": {
26: "@opencode-ai/plugin": ">=1.1.0",
27: "@opencode/plugin": ">=0.0.0"
28: },
29: "peerDependenciesMeta": {
30: "@opencode/plugin": {
31: ...
BadResource: FileSystem.stat (/home/byk/Code/opencode-lore-v2/.git/HEAD)
<path>/home/byk/Code/opencode-lore-v2/.git</path> <type>file</type> <content> 1: gitdir: /home/byk/Code/opencode-lore/.git/worktrees/opencode-lore-v2 (End of file - total 1 lines) </content>
M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M pnpm-lock.yaml 429114122aa1170fd171aa3f0a2bb97e5a6bd6aa
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts</path>
<type>file</type>
<content>
1: import * as esbuild from "esbuild";
2: import { mkdirSync, rmSync } from "node:fs";
3: import { dirname, join } from "node:path";
4: import { fileURLToPath } from "node:url";
5:
6: const packageDir = dirname(dirname(fileURLToPath(import.meta.url)));
7: const dist = join(packageDir, "dist");
8:
9: rmSync(dist, { recursive: true, force: true });
10: mkdirSync(dist, { recursive: true });
11:
12: await esbuild.build({
13: entryPoints: [join(packageDir, "src/server.ts")],
14: outfile: join(dist, "server.js"),
15: bundle: true,
16: format: "esm",
17: platform: "node",
18: target: "esnext",
19: sourcemap: true,
20: external: ["@opencode/plugin", "@loreai/core", "@loreai/gateway"],
21: logLevel: "info",
22: });
(End of file - total 22 lines)
</content>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/internal.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2: import type { PluginInput } from "@opencode-ai/plugin";
3: import { log } from "@loreai/core";
4: import {
5: gatewayAccessHeadersForRemote,
6: parseUpstreamExtraHeaders,
7: shouldForwardUpstreamExtraHeader,
8: surfaceGatewayUnavailable,
9: } from "../src/internal";
10:
11: describe("remote gateway access headers", () => {
12: test("parses empty values and CRLF without changing legacy semantics", () => {
13: expect(
14: parseUpstreamExtraHeaders("x-empty:\r\nx-team: platform\r\ninvalid"),
15: ).toEqual([
16: ["x-empty", ""],
17: ["x-team", "platform"],
18: ]);
19: });
20:
21: const token = "opencode-remote-gateway-token-at-least-32";
22:
23: test("injects the access token only for the matching LORE_REMOTE_URL", () => {
24: expect(
25: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/package.test.ts</path>
<type>file</type>
<content>
1: import { execFileSync } from "node:child_process";
2: import { mkdtempSync, readFileSync, rmSync } from "node:fs";
3: import { tmpdir } from "node:os";
4: import { join } from "node:path";
5: import { afterAll, beforeAll, describe, expect, test } from "vitest";
6:
7: const packageDir = join(import.meta.dirname, "..");
8: const temporary = mkdtempSync(join(tmpdir(), "lore-opencode-package-"));
9: const packageName = "loreai-opencode.tgz";
10:
11: beforeAll(() => {
12: execFileSync("pnpm", ["run", "build"], {
13: cwd: packageDir,
14: stdio: "pipe",
15: });
16: execFileSync("pnpm", ["pack", "--out", join(temporary, packageName)], {
17: cwd: packageDir,
18: stdio: "pipe",
19: });
20: execFileSync("tar", ["-xzf", join(temporary, packageName), "-C", temporary], {
21: stdio: "pipe",
22: });
23: });
24:
25: afterAll(() => {
26: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, describe, expect, test, vi } from "vitest";
2: import {
3: acquireServerRuntime,
4: buildServerHeaders,
5: resetServerRuntimeForTest,
6: } from "../src/server-runtime";
7:
8: const savedEnv = { ...process.env };
9:
10: afterEach(async () => {
11: await resetServerRuntimeForTest();
12: process.env = { ...savedEnv };
13: });
14:
15: describe("V2 server runtime", () => {
16: test.each(["1", "true"])(
17: "stays inactive when LORE_DISABLED=%s",
18: async (value) => {
19: process.env.LORE_DISABLED = value;
20:
21: expect(
22: await acquireServerRuntime("/project", {
23: resolveGateway: vi.fn(),
24: gitRemote: vi.fn(),
25: }),
26: ).toBeUndefined();
27: },
28: );
29:
30: test("shares an owned gateway until every location releases it", async () => {
31: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2:
3: const { release, acquireServerRuntime, buildServerHeaders, rewriteRequest } =
4: vi.hoisted(() => {
5: const release = vi.fn(async () => {});
6: return {
7: release,
8: acquireServerRuntime: vi.fn(async () => ({
9: gatewayBase: "http://127.0.0.1:3207",
10: projectPath: "/workspace/project",
11: gitRemote: "github.com/example/project",
12: gatewayHeaders: {},
13: release,
14: })),
15: buildServerHeaders: vi.fn(() => ({
16: "x-lore-session-id": "ses_1",
17: "x-lore-agent": "build",
18: "x-lore-provider": "openai",
19: "x-lore-upstream-url": "https://api.openai.com",
20: })),
21: rewriteRequest: vi.fn(
22: async (request: Request) =>
23: new ...
diff --git a/packages/core/src/fetch-interceptor.ts b/packages/core/src/fetch-interceptor.ts
index 602362b0..f10263cd 100644
--- a/packages/core/src/fetch-interceptor.ts
+++ b/packages/core/src/fetch-interceptor.ts
@@ -195,6 +195,12 @@ type Rewrite = {
upstreamPath: string;
};
+export type DynamicRequestHeaders = Readonly<Record<string, string>>;
+
+export type DynamicRequestHeadersSource =
+ | DynamicRequestHeaders
+ | (() => DynamicRequestHeaders);
+
/**
* Rewrite an intercepted URL to the gateway, handling both standard /v1/...
* paths and non-standard paths (e.g. /codex/responses). Used by the
@@ -284,17 +290,7 @@ export function shouldIntercept(url: string, gatewayBase: string): boolean {
// Never intercept requests already going to the gateway
if (url.startsWith(gatewayBase)) return false;
// Never intercept local requests (could be local LLM or gateway itself)
- const host = parsed.hostname;
- if (
- host === "localhost" ||
- host === ...
<path>/home/byk/Code/opencode-lore-v2/pnpm-lock.yaml</path> <type>file</type> <content> 1: lockfileVersion: '9.0' 2: 3: settings: 4: autoInstallPeers: true 5: excludeLinksFromLockfile: false 6: 7: overrides: 8: basic-ftp: 5.3.1 9: ip-address: 10.2.0 10: fast-xml-parser: 5.7.3 11: '@huggingface/hub': 2.11.0 12: onnxruntime-node: 1.27.0 13: yaml: '>=2.8.3' 14: esbuild: '>=0.28.1' 15: '@opentelemetry/core': '>=2.8.0' 16: protobufjs: '>=8.6.6' 17: qs: '>=6.15.2' 18: tar: '>=7.5.19' 19: js-yaml: '>=4.3.0 <5' 20: brace-expansion: '>=5.0.7' 21: fast-uri: '>=3.1.4 <4' 22: sharp: '>=0.35.0' 23: svgo: '>=4.0.2' 24: adm-zip: '>=0.6.0' 25: postcss: '>=8.5.18' 26: 27: patchedDependencies: 28: '@sentry/node@10.56.0': 29: hash: 885a8f837b9ae328d8e5ae59ab745caca04f00a4ad32b31ba6c1ffb9913802cd 30: path: patches/@sentry__node@10.56.0.patch 31: 32: importers: 33: 34: .: 35: devDependencies: 36: '@stryker-mutator/core': 37: ...
/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-request.test.ts /home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-paths.test.ts /home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-install.test.ts /home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-global.test.ts /home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-body.test.ts
/home/byk/Code/opencode-lore-v2/packages/opencode/test/package.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/tui-silence.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/subagent-detection.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/session-state.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/routing.e2e.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/internal.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/index.test.ts /home/byk/Code/opencode-lore-v2/packages/opencode/test/gateway-smoke.test.ts
File not found: /home/byk/Code/opencode-lore-v2/node_modules/@opencode/plugin
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules</path> <type>directory</type> <entries> .bin/ @loreai/ @opencode-ai/ @opencode/ @types/ (5 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin</path> <type>directory</type> <entries> dist/ package.json (2 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/package.json</path>
<type>file</type>
<content>
1: {
2: "$schema": "https://json.schemastore.org/package.json",
3: "name": "@opencode/plugin",
4: "version": "0.0.0-beta-19378",
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: ".": {
14: "import": "./dist/promise/index.js",
15: "types": "./dist/promise/index.d.ts"
16: },
17: "./effect": {
18: "import": "./dist/effect/index.js",
19: "types": "./dist/effect/index.d.ts"
20: },
21: "./host": {
22: "import": "./dist/host.js",
23: "types": "./dist/host.d.ts"
24: },
25: "./tui": {
26: "import": "./dist/tui/index.js",
27: "types": "./dist/tui/index.d.ts"
28: },
29: "./*": {
30: "import": ...
No files found
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist</path> <type>directory</type> <entries> app.d.ts app.js effect/ host.d.ts host.js options.d.ts options.js promise/ rpc.d.ts rpc.js source.bun.d.ts source.bun.js source.d.ts source.js source.node.d.ts source.node.js storage.d.ts storage.js tui/ worktree.d.ts worktree.js (21 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise</path> <type>directory</type> <entries> adapter.d.ts adapter.js agent.d.ts agent.js aisdk.d.ts aisdk.js catalog.d.ts catalog.js command.d.ts command.js event.d.ts event.js index.d.ts index.js integration.d.ts integration.js mcp.d.ts mcp.js permission.d.ts permission.js plugin.d.ts plugin.js reference.d.ts reference.js registration.d.ts registration.js rpc.d.ts rpc.js session.d.ts session.js shell.d.ts shell.js skill.d.ts skill.js storage.d.ts storage.js tool.d.ts tool.js types.d.ts types.js vcs.d.ts vcs.js websearch.d.ts websearch.js worktree.d.ts worktree.js (46 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/plugin.d.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 { ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/session.d.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: export interface SessionPrompt {
13: readonly sessionID: Session.ID;
14: readonly messageID: SessionMessage.ID;
15: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/agent.d.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: export interface AgentEditor {
6: list(): readonly DeepMutable<Agent.Info>[];
7: get(id: string): DeepMutable<Agent.Info> | undefined;
8: default(id: string | undefined): void;
9: update(id: string, update: (agent: DeepMutable<Agent.Info>) => void): void;
10: remove(id: string): void;
11: }
12: export interface AgentDomain extends AgentApi {
13: readonly transform: Transform<AgentEditor>;
14: readonly reload: () => Promise<void>;
15: }
(End of file - total 15 lines)
</content>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/registration.d.ts</path>
<type>file</type>
<content>
1: export interface Registration {
2: readonly dispose: () => Promise<void>;
3: }
4: export interface ModelHookOptions {
5: /** Limits the hook to one provider. Unscoped hooks apply to every provider. */
6: readonly providerID?: string;
7: }
8: export type Hooks<Spec> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Promise<void> | void) => Promise<Registration>;
9: export type ModelHooks<Spec> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Promise<void> | void, options?: Spec[Name] extends {
10: readonly model: unknown;
11: } ? ModelHookOptions : never) => Promise<Registration>;
12: export type Transform<Input> = (callback: (input: Input) => void) => Promise<Registration>;
(End of file - total 12 lines)
</content>
File not found: /home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/schema/dist/location.d.ts
No files found
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode</path> <type>directory</type> <entries> plugin/ (1 entries) </entries>
<path>/home/byk/Code/opencode/packages/schema/src/location.ts</path>
<type>file</type>
<content>
1: export * as Location from "./location"
2:
3: import { Schema } from "effect"
4: import { AbsolutePath, optional } from "./schema"
5: import { ProjectID } from "./project-id"
6: import { WorkspaceID } from "./workspace-id"
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: }),
21: }) {}
22:
23: export function response<S extends Schema.Top>(data: S) {
24: return Schema.Struct({ location: Info, data })
25: }
(End of file - total 25 ...
/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/@opencode+plugin@0.0.0-beta-19378_@opentelemetry+api-logs@0.214.0_@opentelemetry+resour_adca8235564d91579da6ab6087184da7/node_modules/@opencode/plugin
<path>/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/@opencode+plugin@0.0.0-beta-19378_@opentelemetry+api-logs@0.214.0_@opentelemetry+resour_adca8235564d91579da6ab6087184da7/node_modules/@opencode</path> <type>directory</type> <entries> ai/ client/ plugin/ protocol/ schema/ util/ (6 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/@opencode+plugin@0.0.0-beta-19378_@opentelemetry+api-logs@0.214.0_@opentelemetry+resour_adca8235564d91579da6ab6087184da7/node_modules/@opencode/schema</path> <type>directory</type> <entries> dist/ package.json (2 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/@opencode+plugin@0.0.0-beta-19378_@opentelemetry+api-logs@0.214.0_@opentelemetry+resour_adca8235564d91579da6ab6087184da7/node_modules/@opencode/schema/dist/location.d.ts</path>
<type>file</type>
<content>
1: export * as Location from "./location.js";
2: import { Schema } from "effect";
3: export interface Ref extends Schema.Schema.Type<typeof Ref> {
4: }
5: export declare const Ref: Schema.Struct<{
6: readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
7: readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
8: ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
9: create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
10: }>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
11: ascending: (id?: string) => string & ...
Found 82 matches /home/byk/Code/opencode/packages/core/src/plugin/models-dev.ts: Line 91: package: model.provider.npm, Line 152: package: item.npm, /home/byk/Code/opencode/packages/core/src/plugin/variant.ts: Line 31: if (model.api.type !== "aisdk" || model.api.package !== "@ai-sdk/openai-compatible") return [] /home/byk/Code/opencode/packages/core/src/plugin/skill.ts: Line 23: "Use ONLY when the user is editing or creating opencode's own configuration: opencode.json, opencode.jsonc, files under .opencode/, or files under ~/.config/opencode/. Also use when creating or fixing opencode agents, subagents, commands, skills, plugins, MCP servers, or permission rules. Do not use for the user's own application code, or for any project that is not configuring opencode itself.", /home/byk/Code/opencode/packages/core/src/plugin/command.ts: Line 16: command.description = "guided AGENTS.md ...
/home/byk/Code/opencode/packages/core/src/plugin/models-dev.ts /home/byk/Code/opencode/packages/core/src/plugin/internal.ts /home/byk/Code/opencode/packages/core/src/plugin/variant.ts /home/byk/Code/opencode/packages/core/src/plugin/skill.ts /home/byk/Code/opencode/packages/core/src/plugin/provider.ts /home/byk/Code/opencode/packages/core/src/plugin/promise.ts /home/byk/Code/opencode/packages/core/src/plugin/host.ts /home/byk/Code/opencode/packages/core/src/plugin/command.ts /home/byk/Code/opencode/packages/core/src/plugin/agent.ts /home/byk/Code/opencode/packages/core/src/plugin/layer-map.example.ts
Found 16 matches
/home/byk/Code/opencode/packages/tui/src/feature-plugins/builtins.ts:
Line 1: import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui"
Line 15: export type BuiltinTuiPlugin = Omit<TuiPluginModule, "id"> & {
/home/byk/Code/opencode/packages/core/src/config/plugin/external.ts:
Line 15: const PluginModule = Schema.Struct({
Line 81: const value = (yield* Schema.decodeUnknownEffect(PluginModule)(mod)).default
/home/byk/Code/opencode/packages/core/src/plugin/promise.ts:
Line 90: yield* Effect.promise(() => Promise.resolve(plugin.setup(context2)))
/home/byk/Code/opencode/packages/plugin/src/tui.ts:
Line 630: export type TuiPluginModule = {
/home/byk/Code/opencode/packages/plugin/src/index.ts:
Line 76: export type PluginModule = {
/home/byk/Code/opencode/packages/opencode/test/provider/provider.test.ts:
Line 1915: // Tests that need plugin file setup or multi-instance flows fall back to ...
<path>/home/byk/Code/opencode/packages/core/src/config/plugin/external.ts</path>
<type>file</type>
<content>
1: export * as ConfigExternalPlugin from "./external"
2:
3: import type { Plugin as EffectPlugin } from "@opencode-ai/plugin/v2/effect"
4: import type { Plugin as PromisePlugin } from "@opencode-ai/plugin/v2/promise"
5: import { Effect, Schema } from "effect"
6: import path from "path"
7: import { fileURLToPath, pathToFileURL } from "url"
8: import { Config } from "../../config"
9: import { FSUtil } from "../../fs-util"
10: import { Location } from "../../location"
11: import { Npm } from "../../npm"
12: import { define } from "../../plugin/internal"
13: import { PluginPromise } from "../../plugin/promise"
14:
15: const PluginModule = Schema.Struct({
16: default: Schema.Union([
17: Schema.Struct({
18: id: Schema.String,
19: effect: Schema.declare<EffectPlugin["effect"]>(
20: (input): input is EffectPlugin["effect"] => typeof input === "function",
21: ...
/home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/worktree.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/websearch.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/tool-output.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/source.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/snapshot.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/skill.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/skill-file.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/shell.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/reference.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/provider.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/policy.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/mcp.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/location-watcher.ts...
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/warming.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/vcs/hg.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/vcs/git.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/variant.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/update.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/source-directory.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/skill.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/service.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/sdk.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/promise.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/plan.ts /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/optimize.ts /home/byk/Code/opencode-v2-pilo...
<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-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: ...
Found 83 matches
/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts:
Line 39: export interface SessionModelRequest {
Line 48: export interface SessionHttpRequest {
Line 79: readonly "model.request": SessionModelRequest
Line 80: readonly "http.request": SessionHttpRequest
/home/byk/Code/opencode-v2-pilot/packages/plugin/src/effect/session.ts:
Line 39: export interface SessionModelRequest {
Line 48: export interface SessionHttpRequest {
Line 79: readonly "model.request": SessionModelRequest
Line 80: readonly "http.request": SessionHttpRequest
/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/config/compaction.test.ts:
Line 12: import { SessionModelRequest } from "@opencode/core/session/model-request"
Line 42: AppNodeBuilder.build(LayerNode.group([SessionCompaction.node, ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts</path>
<type>file</type>
<content>
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 session.model.request hooks rewrite the base URL and headers before dispatch. ...
Found 4 matches
/home/byk/Code/opencode-v2-pilot/packages/schema/src/session.ts:
Line 31: export interface Info extends Schema.Schema.Type<typeof Info> {}
Line 34: parentID: ID.pipe(optional),
/home/byk/Code/opencode-v2-pilot/packages/schema/src/v1/session.ts:
Line 461: parentID: MessageID,
Line 550: parentID: optional(SessionID),
<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: ...
Your prior result was empty. Resume the same read-only adversarial correctness review of /home/byk/Code/opencode-lore-v2 and return a substantive result. Inspect every changed file versus @-. Cover dual legacy/V2 exports, Request routing equivalence, location isolation, gateway lease concurrency and cleanup, setup failure/unload, parent-session failure behavior, and package tarball/runtime resolution. Do not edit files. Your result must contain exact file:line evidence and classify each point PASS, CONCERN, or MUST-FIX, then end with exactly MERGE or DO-NOT-MERGE. If you cannot complete the review, return the exact blocking tool or error instead of an empty result.
<skill_content name="jj-guide"> # Skill: jj-guide # jj Guide for AI Agents Jujutsu (jj) is a Git-compatible VCS with mutable commits, automatic snapshotting, no staging area, and first-class conflicts. This skill teaches you how to use it safely from a non-interactive agent environment. If `.jj/` exists in the repo root, this is a jj repo. **Use `jj` commands, not `git`.** In a colocated repo (`.jj/` *and* `.git/`), git tools can read the state, but mutations should go through `jj` so the operation log stays consistent. ## Critical Rules - **NEVER** use interactive flags (`-i`, `--interactive`). TUI prompts hang in agent environments. This applies to `jj split -i`, `jj squash -i`, `jj commit -i`, `jj resolve`, `jj diffedit`, etc. - **ALWAYS** pass `-m "msg"` when describing/committing. Without `-m`, an editor opens and hangs. - **VERIFY** mutations with `jj st` and `jj log` after `squash`, `abandon`, `rebase`, `restore`, `commit`. ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/dist</path> <type>directory</type> <entries> server.js server.js.map (2 entries) </entries>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/dist/server.js</path>
<type>file</type>
<content>
1: // src/server.ts
2: import { rewriteRequest } from "@loreai/core";
3:
4: // src/server-runtime.ts
5: import { getGitRemote, log as log2 } from "@loreai/core";
6:
7: // src/internal.ts
8: import { GATEWAY_AUTH_HEADER, log } from "@loreai/core";
9: import * as http from "node:http";
10: import * as https from "node:https";
11: function isLoopbackUrl(value) {
12: try {
13: const hostname = new URL(value).hostname.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
14: return hostname === "localhost" || hostname === "localhost." || hostname === "::1" || /^127(?:\.\d{1,3}){3}$/.test(hostname);
15: } catch {
16: return false;
17: }
18: }
19: function gatewayAccessHeadersForRemote(gatewayBase, env = process.env) {
20: const remoteUrl = env.LORE_REMOTE_URL?.replace(/\/+$/, "");
21: const token = env.LORE_GATEWAY_AUTH_TOKEN;
22: return remoteUrl === ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "@loreai/core",
3: "version": "0.40.0",
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Shared memory engine for Lore — three-tier storage, distillation, gradient context management",
7: "main": "./dist/node/index.js",
8: "types": "./dist/node/index.d.ts",
9: "exports": {
10: ".": {
11: "types": "./dist/types/index.d.ts",
12: "development": "./src/index.ts",
13: "bun": "./dist/bun/index.js",
14: "default": "./dist/node/index.js"
15: }
16: },
17: "imports": {
18: "#db/driver": {
19: "bun": "./src/db/driver.bun.ts",
20: "default": "./src/db/driver.node.ts"
21: }
22: },
23: "scripts": {
24: "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.eval.json",
25: "build": "tsx script/build.ts"
26: },
27: "dependencies": {
28: "@hpke/core": "^1.9.0",
29: ...
<path>/home/byk/Code/opencode-lore-v2/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-lore-v2/.craft.yml</path> <type>file</type> <content> 1: minVersion: '2.21.1' 2: changelog: 3: policy: auto 4: versioning: 5: policy: auto 6: # Custom version bump script — bypasses craft's built-in npm-based auto-bumping 7: # which fails on our `workspace:*` deps. See scripts/bump-version.sh for details. 8: preReleaseCommand: bash scripts/bump-version.sh 9: statusProvider: 10: name: github 11: config: 12: contexts: 13: # Must match the check-run names from ci.yml that produce release artifacts. 14: # Update these if you rename the jobs. 15: - "test" 16: - "Generate Release Patches" 17: artifactProvider: 18: name: github 19: config: 20: artifacts: 21: # CI workflow uploads three artifact groups on release branches: 22: # npm-tarball — workspace .tgz files for npm publish 23: # release-binaries — gzipped standalone CLI binaries + checksums 24: # release-patches — delta patches ...
Found 14 matches
/home/byk/Code/opencode-lore-v2/.github/workflows/cch-seed-check.yml:
Line 37: - run: pnpm --filter @loreai/core run build
Line 104: - run: pnpm --filter @loreai/core run build
/home/byk/Code/opencode-lore-v2/.github/workflows/ci.yml:
Line 155: - run: pnpm run build
Line 338: run: pnpm --filter @loreai/gateway run build:binary:sea --platforms linux-x64
Line 411: pnpm --filter @loreai/gateway run build:binary:sea \
Line 431: run: pnpm run build
Line 437: # We use `pnpm pack` (not `npm pack`) because pnpm automatically rewrites
Line 451: (cd "$pkg" && pnpm pack --pack-destination ../../dist-tarballs)
Line 506: pnpm --filter @loreai/gateway run build:binary:sea \
Line 529: name: npm-tarball
Line 583: - run: pnpm --filter @loreai/core run build
Line 769: run: pnpm --filter @loreai/gateway run build:binary:sea --platforms ${{ matrix.target ...
<path>/home/byk/Code/opencode-lore-v2/.github/workflows/ci.yml</path>
<type>file</type>
<content>
415: FOSSILIZE_CACHE_DIR: ${{ github.workspace }}/.node-cache
416:
417: - name: Upload staging artifact
418: if: github.ref == 'refs/heads/main' && github.event_name == 'push'
419: uses: actions/upload-artifact@v7
420: with:
421: name: sea-staging
422: path: packages/gateway/.sea-staging/
423: # .sea-staging is a dot-prefixed (hidden) directory
424: include-hidden-files: true
425:
426: # -----------------------------------------------------------------
427: # Release: build all packages + pack tarballs + multi-platform binaries
428: # -----------------------------------------------------------------
429: - name: Build all packages
430: if: startsWith(github.ref, 'refs/heads/release/')
431: run: pnpm run build
432:
433: # Pack each workspace package into its own ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/script/build.ts</path> <type>file</type> <content> 1: /** 2: * Build @loreai/core into publishable ESM bundles. 3: * 4: * Two targets: 5: * - dist/node/index.js — uses node:sqlite (for Pi extension, ACP server, etc.) 6: * - dist/bun/index.js — uses bun:sqlite (for OpenCode plugin) 7: * 8: * esbuild resolves the `#db/driver` subpath import map per target via 9: * `conditions: ["node"]` or `conditions: ["bun"]`. 10: * 11: * TypeScript declarations (.d.ts) are emitted separately by `tsc` below. 12: * esbuild alone can't produce declarations. 13: * 14: * The build runs under Node (via tsx, e.g. `pnpm run build`) — it does not 15: * require the Bun runtime. esbuild is a plain npm package, so the build is 16: * runtime-agnostic; the dist/bun target is produced via esbuild's 17: * `conditions: ["bun"]`, not by running under Bun. ...
<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-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js</path>
<type>file</type>
<content>
1: import { Tool } from "@opencode/schema/tool";
2: import { Effect, Schema, SchemaAST, Stream } from "effect";
3: import { HttpApiEndpoint, HttpApiSchema } from "effect/unstable/httpapi";
4: import { define } from "../effect/plugin.js";
5: const compiledEndpoints = new WeakMap();
6: const JsonInput = Schema.fromJsonString(Schema.Unknown);
7: class ReturnedRpcError extends Error {
8: type;
9: data;
10: constructor(type, message, data) {
11: super(message);
12: this.type = type;
13: this.data = data;
14: }
15: }
16: const makeStreams = Effect.fn("Plugin.Event.makeStreams")(function* () {
17: const context = yield* Effect.context();
18: const subscriptions = new Set();
19: // Async iterators own separate scopes, so close them when the plugin unloads.
20: yield* Effect.addFinalizer(() => ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js</path>
<type>file</type>
<content>
220: },
221: transform: transform(host.catalog),
222: reload: () => run(host.catalog.reload()),
223: },
224: command: {
225: list: adaptApiMethod(CommandEndpoints["command.list"], host.command.list),
226: transform: (callback) => register(host.command.transform((editor) => callback({
227: add: (definition) => editor.add({
228: ...definition,
229: execute: (input) => Effect.tryPromise({ try: () => definition.execute(input), catch: (cause) => cause }),
230: }),
231: }))),
232: reload: () => run(host.command.reload()),
233: },
234: event: ...
<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 62 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/types.ts:
Line 540: gitRemote?: string;
Line 799: "x-lore-project",
Line 800: "x-lore-git-remote",
/home/byk/Code/opencode-lore-v2/packages/gateway/src/synthetic-tools.ts:
Line 534: gitRemote?: string;
Line 542: * or `[remote "origin"]`. Only yields `gitRemote`.
Line 582: result.gitRemote = normalizeRemoteUrl(rawUrl);
Line 615: result.gitRemote = normalizeRemoteUrl(remoteRaw);
/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts:
Line 4153: gitRemote?: string,
Line 4173: ensureProject(projectPath, undefined, gitRemote);
Line 4493: if (result.gitRemote && !sessionState.gitRemote) {
Line 4494: sessionState.gitRemote = result.gitRemote;
Line 4502: const effectiveRemote = result.gitRemote ?? sessionState.gitRemote;
Line 4646: gitRemote?: string,
Line 4652: const toId = ensureProject(toPath, undefined, gitRemote);
...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/config.ts</path>
<type>file</type>
<content>
1170: // ---------------------------------------------------------------------------
1171:
1172: export type ProjectPathSource = "header" | "inferred" | "cwd";
1173:
1174: export type ProjectPathResult = {
1175: path: string;
1176: source: ProjectPathSource;
1177: /** Normalized git remote URL from `X-Lore-Git-Remote` header, if provided. */
1178: gitRemote?: string;
1179: /**
1180: * Set when an `X-Lore-Project` header was present but OVERRIDDEN by an
1181: * authoritative system-prompt inference that disagreed with it. Carries the
1182: * (rejected) header path so the session layer can detect and correct an
1183: * existing confident binding to a stale/static header — and so the gateway
1184: * can log a one-time warning about the misconfiguration. Absent when the
1185: * header agreed with (or matched) the inference, or when no header was sent. ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-install.test.ts</path>
<type>file</type>
<content>
1: /**
2: * End-to-end tests for installFetchInterceptor.
3: *
4: * These exercise the actual interception flow — URL rewriting, header
5: * injection, X-Lore-Upstream-URL derivation, and the body-shape fallback —
6: * by installing the interceptor over a stubbed originalFetch and asserting
7: * what URL/headers/body the gateway would receive.
8: */
9: import { describe, test, expect, beforeEach, afterEach, vi } from "vitest";
10: import {
11: installFetchInterceptor,
12: interceptUrlForProtocol,
13: } from "../src/fetch-interceptor";
14:
15: const GATEWAY = "http://127.0.0.1:3207";
16:
17: type Captured = { url: string; init: RequestInit | undefined };
18:
19: describe("installFetchInterceptor — end-to-end routing", () => {
20: let cleanup: () => void;
21: let captured: Captured | null;
22: let realFetch: typeof globalThis.fetch;
23: let ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/generate.ts</path>
<type>file</type>
<content>
1: export * as SessionGenerate from "./generate.js"
2:
3: import { LLMClient, Message, type AIError } from "@opencode/ai"
4: import { Effect } from "effect"
5: import { Database } from "../database/database.js"
6: import { Instance } from "../instance/service.js"
7: import { Plugin } from "../plugin/service.js"
8: import type { Instructions } from "../instructions/index.js"
9: import { SessionContext } from "./context.js"
10: import type { AgentNotFoundError } from "./error.js"
11: import { SessionHistory } from "./history.js"
12: import { SessionProviderContext } from "./provider-context.js"
13: import { SessionModelRequest } from "./model-request.js"
14: import type { SessionRunnerModel } from "./runner/model.js"
15: import type { SessionSchema } from "./schema.js"
16:
17: export type Error = AgentNotFoundError | Instructions.InitializationBlocked | ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts</path>
<type>file</type>
<content>
1: export * as SessionTitle from "./title.js"
2:
3: import { isDeepStrictEqual } from "node:util"
4: import { LLMClient, LLMEvent, Message, SystemPart } from "@opencode/ai"
5: import type { Agent } from "@opencode/schema/agent"
6: import { Context, DateTime, Effect, Layer, Stream } from "effect"
7: import { Database } from "../database/database.js"
8: import { Bus } from "../bus.js"
9: import { makeLocationNode } from "@opencode/util/effect/app-node"
10: import { isExactRootFallback } from "@opencode/util/session-title-fallback"
11: import { llmClient } from "../effect/app-node-platform.js"
12: import { SessionContext } from "./context.js"
13: import { SessionEvent } from "./event.js"
14: import { SessionHistory } from "./history.js"
15: import type { SessionRunnerModel } from "./runner/model.js"
16: import { SessionSchema } from "./schema.js"
17: import { SessionUsage } from ...
Found 6 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts:
Line 128: const selection = yield* context.selectTitle(session)
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/context.ts:
Line 60: readonly selectTitle: (session: SessionSchema.Info) => Effect.Effect<
Line 95: const selectTitle = Effect.fn("SessionContext.selectTitle")(function* (session: SessionSchema.Info) {
Line 96: const agent = yield* agents.get(Agent.ID.make("title"))
Line 176: return Service.of({ select, load, resolveModel, selectTitle, prepare: modelRequests.prepare })
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/agent.ts:
Line 139: editor.update(Agent.ID.make("title"), (item) => {
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/context.ts</path>
<type>file</type>
<content>
80: const db = (yield* Database.Service).db
81: const discovery = yield* InstructionDiscovery.Service
82: const entries = yield* InstructionEntry.Service
83: const location = yield* Location.Service
84: const mcpInstructions = yield* McpInstructions.Service
85: const mcpTools = yield* McpTool.Service
86: const models = yield* SessionRunnerModel.Service
87: const modelRequests = yield* SessionModelRequest.Service
88: const referenceInstructions = yield* ReferenceInstructions.Service
89: const skillInstructions = yield* SkillInstructions.Service
90: const store = yield* SessionStore.Service
91: const registry = yield* Tool.Service
92:
93: const resolveModel = (session: SessionSchema.Info) => models.resolve(session, catalog.model.available)
94:
95: const selectTitle = Effect.fn("SessionContext.selectTitle")(function* ...
Found 4 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/compaction.ts:
Line 429: kind: "compaction",
Line 432: agentID: Agent.ID.make("compaction"),
Line 479: agent: Agent.ID.make("compaction"),
Line 577: agent: Agent.ID.make("compaction"),
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/agent.ts</path>
<type>file</type>
<content>
1: export * as AgentPlugin from "./agent.js"
2:
3: import { define } from "@opencode/plugin/effect/plugin"
4: import { Effect } from "effect"
5: import { Agent } from "../agent.js"
6: import { Permission } from "../permission.js"
7:
8: const PROMPT_EXPLORE = `You are a file search specialist. You excel at thoroughly navigating and exploring codebases.
9:
10: Your strengths:
11: - Rapidly finding files using glob patterns
12: - Searching code and text with powerful regex patterns
13: - Reading and analyzing file contents
14:
15: Guidelines:
16: - Use Glob for broad file pattern matching
17: - Use Grep for searching file contents with regex
18: - Use Read when you know the specific file path you need to read
19: - Adapt your search approach based on the thoroughness level specified by the caller
20: - Return file paths as absolute paths in your final response
21: - For clear ...
Found 11 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:
Line 41: update: (id: ID, fn: (agent: Types.DeepMutable<Info>) => void) => void
Line 74: update: (id, fn) => {
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/agent.ts:
Line 87: editor.update(Agent.defaultID, (item) => {
Line 94: editor.update(Agent.ID.make("general"), (item) => {
Line 105: editor.update(Agent.ID.make("explore"), (item) => {
Line 133: editor.update(Agent.ID.make("compaction"), (item) => {
Line 139: editor.update(Agent.ID.make("title"), (item) => {
Line 147: editor.update(Agent.ID.make("summary"), (item) => {
/home/byk/Code/opencode-v2-pilot/packages/core/src/config/plugin/agent.ts:
Line 76: const updates = yield* PubSub.subscribe(changes)
Line 91: editor.update(current.id, (agent) => agent.permissions.push(...permissions))
Line 103: editor.update(agentID, (agent) => {
<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 ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/supervisor.ts</path>
<type>file</type>
<content>
1: export * as PluginSupervisor from "./supervisor.js"
2:
3: import { Event } from "@opencode/schema/config"
4: import { Cause, Effect, Layer, Queue, Stream } from "effect"
5: import path from "path"
6: import { ConfigPluginSource } from "../config/plugin/source.js"
7: import { makeLocationNode } from "@opencode/util/effect/app-node"
8: import { Bus } from "../bus.js"
9: import { Npm } from "@opencode/util/npm"
10: import { Plugin } from "../plugin.js"
11: import { InstancePlugins } from "./instance.js"
12: import { PluginInternal } from "./internal.js"
13: import { PluginModule } from "./module.js"
14: import { SdkPlugins } from "./sdk.js"
15: import { PluginUpdate } from "./update.js"
16: import { Watcher } from "../filesystem/watcher.js"
17:
18: const resolve = Effect.fn("PluginSupervisor.resolve")(function* (
19: modules: Effect.Success<ReturnType<typeof ...
Found 20 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts:
Line 29: let closed = false
Line 31: if (closed) return Effect.void
Line 34: ready.closeUnsafe()
Line 61: release: holdUnsafe(),
Line 77: Exit.isFailure(exit) && !activation.failure ? Scope.close(activation.scope, exit) : Effect.void,
Line 89: const activate = Effect.fn("Plugin.activate")(function* (
Line 105: if (closed) return
Line 135: yield* Scope.close(slot.activation.scope, Exit.void)
Line 178: (release) => release,
Line 193: if (closed) return
Line 211: Scope.close(item.scope, Exit.void).pipe(
Line 231: Effect.ensuring(item.release),
Line 238: const close = (exit: Exit.Exit<unknown, unknown>) =>
Line 241: closed = true
Line 245: yield* State.shutdown(Scope.close(scope, exit))
Line 248: yield* ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin.ts</path>
<type>file</type>
<content>
80: )
81: if (activation.failure || Exit.isSuccess(exit)) return { activation } as const
82: yield* Effect.logWarning("failed to load plugin", {
83: "plugin.id": plugin.id,
84: cause: exit.cause,
85: })
86: return { error: Cause.pretty(exit.cause) } as const
87: })
88:
89: const activate = Effect.fn("Plugin.activate")(function* (
90: plugins: readonly Generation[],
91: failures: readonly Failure[] = [],
92: ) {
93: const definitions = plugins.map((plugin) => ({ ...plugin, id: Plugin.ID.make(plugin.id) }))
94: const ids = new Set<Plugin.ID>()
95: for (const definition of definitions) {
96: if (ids.has(definition.id)) yield* Effect.die(new Error(`Duplicate plugin ID: ${definition.id}`))
97: ids.add(definition.id)
98: }
99:
100: yield* Effect.acquireUseRelease(
101: ...
RUN v4.1.8 /home/byk/Code/opencode-lore-v2
Test Files 2 passed (2)
Tests 35 passed (35)
Start at 14:25:37
Duration 1.23s (transform 1.32s, setup 1.54s, import 85ms, tests 194ms, environment 0ms)
RUN v4.1.8 /home/byk/Code/opencode-lore-v2
Test Files 3 passed (3)
Tests 25 passed (25)
Start at 14:25:50
Duration 3.89s (transform 3.96s, setup 1.50s, import 6.30s, tests 229ms, environment 0ms)
M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/index.ts</path>
<type>file</type>
<content>
344: vecReadLatencyTotalSamples,
345: formatVecReadLatencyHeartbeat,
346: _resetVecReadLatencyForTest,
347: } from "./vec-latency";
348: export { distillLimiter, curatorLimiter } from "./session-limiter";
349: export {
350: estimateTokens,
351: encodingForModel,
352: TOKEN_ESTIMATE_CACHE_VERSION,
353: } from "./tokenize";
354: export { SemanticTokenCache } from "./semantic-token-cache";
355: export {
356: installFetchInterceptor,
357: rewriteRequest,
358: shouldIntercept,
359: type DynamicRequestHeaders,
360: type DynamicRequestHeadersSource,
361: type FetchInterceptorConfig,
362: } from "./fetch-interceptor";
363: export * as workerModel from "./worker-model";
364: export {
365: ftsQuery,
366: ftsQueryOr,
367: ftsQueryRelaxed,
368: EMPTY_QUERY,
369: reciprocalRankFusion,
370: expandQuery,
371: extractTopTerms,
372: exactTermMatchRank,
373: } from ...
<path>/home/byk/Code/opencode-lore-v2/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 12 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/index.test.ts:
Line 158: defaultHeaders: { "X-Custom": "value" },
Line 170: expect(options.defaultHeaders).toEqual({ "X-Custom": "value" });
Line 173: test("disables OpenCode's default OpenAI header timeout when Lore routes the provider", () => {
Line 278: describe("plugin entry module export shape", () => {
Line 287: // named `LorePlugin` and the same-reference `default`) — nothing else.
Line 288: test("exports only the plugin (LorePlugin + same-ref default)", async () => {
Line 291: // The default export must be the LorePlugin function reference.
Line 292: expect(typeof mod.default).toBe("function");
Line 293: expect(mod.default).toBe(mod.LorePlugin);
Line 295: // The ONLY export keys allowed are `LorePlugin` and `default`. Any other
Line 300: expect(Object.keys(mod).sort()).toEqual(["LorePlugin", "default"]);
Line 303: // host ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/index.test.ts</path>
<type>file</type>
<content>
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')`). OpenCode's legacy plugin loader iterates
281: // `Object.values(mod)` (`getLegacyPlugins`/`getServerPlugin`): every
282: // FUNCTION export is invoked as a plugin (and its return value pushed into
283: // the host hooks array — `applyLoreProviderConfig` returned `undefined`,
284: // which then crashed the dispatch loops), and every NON-function export
285: // makes the loader throw `Plugin export is not a function`, dropping the
286: // plugin entirely. ...
<path>/home/byk/Code/opencode-lore-v2/.github/workflows/ci.yml</path>
<type>file</type>
<content>
130: # Override the workflow-default permissions (contents: read, packages: write)
131: # to also grant what the Codecov upload step needs to post PR comments and
132: # commit statuses. A job-level block REPLACES the default, so the inherited
133: # perms are re-listed here.
134: permissions:
135: contents: read
136: pull-requests: write
137: statuses: write
138: actions: read
139: outputs:
140: nightly-version: ${{ steps.nightly.outputs.version }}
141: steps:
142: - uses: actions/checkout@v6
143: with:
144: fetch-tags: true # fetch all tag refs for craft changelog
145:
146: - uses: pnpm/action-setup@v6
147: - uses: actions/setup-node@v6
148: with:
149: node-version: '24'
150: registry-url: 'https://registry.npmjs.org'
151:
152: - run: pnpm install ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/host.js</path>
<type>file</type>
<content>
1: export * as Host from "./host.js";
2: import path from "node:path";
3: import { importModule, resolveModule } from "@opencode/util/runtime-import";
4: export function resolve(target) {
5: const entry = (subpaths) => {
6: for (const subpath of subpaths) {
7: const specifier = target.name
8: ? [target.name, subpath].filter(Boolean).join("/")
9: : path.resolve(target.directory, subpath || "index");
10: try {
11: return resolveModule(specifier, target.directory);
12: }
13: catch (error) {
14: if (!(error instanceof Error) ||
15: !("code" in error) ||
16:  (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. ...
<path>/home/byk/Code/opencode-lore-v2/quality/REVIEW.md</path> <type>file</type> <content> 1: # Review Heuristics — Lore 2: 3: This document codifies the review bar for pull requests. It exists because 4: adversarial review has repeatedly caught correctness bugs that a green test 5: suite missed — skip/early-return branches, lifecycle sequences, and fan-out 6: registry gaps. Institutionalizing these patterns so they compound. 7: 8: The review workflow (§6) is referenced from AGENTS.md. 9: 10: --- 11: 12: ## 1. Regression-test discipline 13: 14: Every adversarial-review finding that surfaces a defect **must** land a 15: deterministic regression test in the same PR. The test: 16: - fails on the base branch (proving it reproduces the bug), 17: - passes on the fix (proving the fix works), 18: - drives the *real* precondition, not an artificially-constructed state (e.g. ...
diff --git a/packages/core/src/fetch-interceptor.ts b/packages/core/src/fetch-interceptor.ts
index 602362b0f6..f10263cde3 100644
--- a/packages/core/src/fetch-interceptor.ts
+++ b/packages/core/src/fetch-interceptor.ts
@@ -195,6 +195,12 @@
upstreamPath: string;
};
+export type DynamicRequestHeaders = Readonly<Record<string, string>>;
+
+export type DynamicRequestHeadersSource =
+ | DynamicRequestHeaders
+ | (() => DynamicRequestHeaders);
+
/**
* Rewrite an intercepted URL to the gateway, handling both standard /v1/...
* paths and non-standard paths (e.g. /codex/responses). Used by the
@@ -284,17 +290,7 @@
// Never intercept requests already going to the gateway
if (url.startsWith(gatewayBase)) return false;
// Never intercept local requests (could be local LLM or gateway itself)
- const host = parsed.hostname;
- if (
- host === "localhost" ||
- host === "127.0.0.1" ||
- host === "0.0.0.0" ||
- // URL.hostname KEEPS brackets on IPv6 ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts</path>
<type>file</type>
<content>
1: import * as esbuild from "esbuild";
2: import { mkdirSync, rmSync } from "node:fs";
3: import { dirname, join } from "node:path";
4: import { fileURLToPath } from "node:url";
5:
6: const packageDir = dirname(dirname(fileURLToPath(import.meta.url)));
7: const dist = join(packageDir, "dist");
8:
9: rmSync(dist, { recursive: true, force: true });
10: mkdirSync(dist, { recursive: true });
11:
12: await esbuild.build({
13: entryPoints: [join(packageDir, "src/server.ts")],
14: outfile: join(dist, "server.js"),
15: bundle: true,
16: format: "esm",
17: platform: "node",
18: target: "esnext",
19: sourcemap: true,
20: external: ["@opencode/plugin", "@loreai/gateway"],
21: logLevel: "info",
22: });
(End of file - total 22 lines)
</content>
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts</path>
<type>file</type>
<content>
1: export * as SessionModelRequest from "./model-request.js"
2:
3: import { HttpOptions, LanguageModel, LLM, LLMRequest, Message, SystemPart } from "@opencode/ai"
4: import type { StreamOptions } from "@opencode/ai/route"
5: import type { SessionRequestKind } from "@opencode/plugin/effect/session"
6: import type { Agent } from "@opencode/schema/agent"
7: import type { Model } from "@opencode/schema/model"
8: import type { Content } from "@opencode/schema/tool"
9: import { Cause, Config, Context, Effect, Layer, Result, Stream } from "effect"
10: import { HttpClientRequest, HttpClientResponse } from "effect/unstable/http"
11: import { makeLocationNode } from "@opencode/util/effect/app-node"
12: import { App } from "../app.js"
13: import { Permission } from "../permission.js"
14: import { PluginHooks } from "../plugin/hooks.js"
15: import { QuestionTool } from ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts</path>
<type>file</type>
<content>
300: // The definition objects we hand to hooks, mapped back to their tools. Hooks rename a
301: // tool by moving its definition to a new key; recognizing the object recovers the tool.
302: const given = new Map(
303: tools.definitions.map(
304: (tool) => [{ description: tool.description, input: { ...tool.inputSchema } }, tool] as const,
305: ),
306: )
307: // Hooks mutate this record in place: edit descriptions and schemas, rename, or remove.
308: const definitions = Object.fromEntries(Array.from(given, ([definition, tool]) => [tool.name, definition]))
309: const context: PluginHooks.Domains["session"]["context"] = {
310: sessionID: session.id,
311: agent: input.scope.contextAgentID ?? input.scope.agentID,
312: model: resolved.ref,
313: system: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts</path>
<type>file</type>
<content>
1: import { getGitRemote, log } from "@loreai/core";
2: import {
3: gatewayAccessHeadersForRemote,
4: parseUpstreamExtraHeaders,
5: probeGateway,
6: shouldForwardUpstreamExtraHeader,
7: } from "./internal";
8:
9: const gatewayPackage = "@loreai/gateway";
10: const knownGatewayPorts = [3207, 5673];
11:
12: export interface LoreServerRuntime {
13: gatewayBase: string;
14: projectPath: string;
15: gitRemote: string;
16: gatewayHeaders: Record<string, string>;
17: release: () => Promise<void>;
18: }
19:
20: export interface ServerRuntimeDependencies {
21: resolveGateway?: () => Promise<{
22: gatewayBase: string;
23: gatewayHeaders: Record<string, string>;
24: shutdown?: () => Promise<void>;
25: }>;
26: gitRemote?: (path: string) => string | null;
27: }
28:
29: interface GatewayHandle {
30: port: number;
31: owned: boolean;
32: ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts</path>
<type>file</type>
<content>
240: * the original path so the gateway can forward to the real provider.
241: *
242: * Used only when `interceptUrl` could not map the path from the URL alone —
243: * i.e. genuinely non-standard endpoints like `/v2/chat/completions` or
244: * `/llm/messages` that nonetheless carry a recognizable body shape.
245: */
246: export function interceptUrlForProtocol(
247: upstream: URL,
248: gateway: URL,
249: protocol: BodyProtocol,
250: ): Rewrite {
251: const gatewayPath = PROTOCOL_GATEWAY_PATHS[protocol];
252: // Strip the recognized endpoint suffix from the path so X-Lore-Upstream-URL
253: // points at the provider base (everything before the endpoint). If no known
254: // suffix is present, fall back to the origin.
255: let upstreamBase = upstream.origin;
256: for (const suffix of LLM_ENDPOINT_SUFFIXES) {
257: if ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
370: applyLoreProviderConfig(cfg, gatewayBase);
371: },
372:
373: tool: {},
374:
375: // Inject per-request identifiers so the gateway can distinguish meta
376: // requests (title generation, summary agents, etc.) from real
377: // conversation turns and route by provider.
378: // Project path, git remote, and upstream URL are injected by the
379: // fetch interceptor (installed once per process).
380: "chat.headers": async (input, output) => {
381: Object.assign(
382: output.headers,
383: gatewayAccessHeadersForRemote(gatewayBase),
384: );
385: // Inject stable session ID — OpenCode's DB session ID survives restarts,
386: // unlike x-session-affinity (nanoid regenerated per process).
387: output.headers["x-lore-session-id"] = input.sessionID;
388: ...
Found 10 matches
/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts:
Line 49: info(message: string, attrs?: Record<string, unknown>): void;
Line 108: // The host enables this switch once, on activation, via `silenceStderr()`.
Line 124: // so one `silenceStderr()` call silences them all.
Line 140: export function silenceStderr(silenced = true): void {
Line 464: export function info(...args: unknown[]): void {
Line 467: console.error("[lore]", ...safeArgs(args));
Line 468: sink?.info(msg);
Line 476: console.error("[lore] WARN:", ...safeArgs(args));
Line 491: if (!readStderrSilenced()) console.error("[lore]", ...safeArgs(args));
Line 499: if (!readStderrSilenced()) console.error("[lore]", ...safeArgs(args));
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts</path>
<type>file</type>
<content>
100:
101: // When the gateway runs *in-process* inside a host that owns a full-screen TUI
102: // — the Pi extension and the OpenCode plugin both `import("@loreai/gateway")`
103: // and call `startGateway()` rather than spawning a separate process — ANY byte
104: // written to stdout/stderr corrupts that TUI. This is the exact class of bug
105: // that broke Pi on Windows (raw `console.*` lines bleeding into the render),
106: // and `log.error` is just as fatal there as a stray `console.log`.
107: //
108: // The host enables this switch once, on activation, via `silenceStderr()`.
109: // From then on the logger writes ONLY to the persistent log file and the
110: // registered {@link LogSink} (e.g. Sentry) — NEVER to stderr, for every level
111: // including `error`, and even when `LORE_DEBUG=1`. ...
Found 1 matches /home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts: Line 259: if (!inTestEnv) log.silenceStderr();
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
240: );
241: }
242:
243: export const LorePlugin: Plugin = async (ctx) => {
244: // Initialize lore — only probe/start once per process.
245: const loreDisabled =
246: process.env.LORE_DISABLED === "1" || process.env.LORE_DISABLED === "true";
247: let loreActive = processLoreActive;
248: let gatewayBase = processLoreBase;
249: if (!processInitDone) {
250: const inTestEnv = isInertTestEnv();
251:
252: // We're loaded by a real OpenCode process, which owns a full-screen TUI:
253: // any byte on stdout/stderr corrupts the render. Flip the core logger's
254: // process-global silence flag — which the in-process gateway's own (bundled)
255: // copy of `core` reads off `globalThis` too — so NOTHING (not even
256: // `log.error` or gateway warnings) reaches the terminal. Everything still
257: // lands in the log file + Sentry sink (`lore ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js</path>
<type>file</type>
<content>
1: import { Tool } from "@opencode/schema/tool";
2: import { Effect, Schema, SchemaAST, Stream } from "effect";
3: import { HttpApiEndpoint, HttpApiSchema } from "effect/unstable/httpapi";
4: import { define } from "../effect/plugin.js";
5: const compiledEndpoints = new WeakMap();
6: const JsonInput = Schema.fromJsonString(Schema.Unknown);
7: class ReturnedRpcError extends Error {
8: type;
9: data;
10: constructor(type, message, data) {
11: super(message);
12: this.type = type;
13: this.data = data;
14: }
15: }
16: const makeStreams = Effect.fn("Plugin.Event.makeStreams")(function* () {
17: const context = yield* Effect.context();
18: const subscriptions = new Set();
19: // Async iterators own separate scopes, so close them when the plugin unloads.
20: yield* Effect.addFinalizer(() => ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js</path>
<type>file</type>
<content>
260: cancel: adaptApiMethod(IntegrationEndpoints["integration.command.cancel"], host.integration.command.cancel),
261: },
262: transform: (callback) => register(host.integration.transform((editor) => callback({
263: list: editor.list,
264: get: editor.get,
265: update: editor.update,
266: remove: editor.remove,
267: method: {
268: list: editor.method.list,
269: update: (input) => {
270: if (!("authorize" in input))
271: return editor.method.update(input);
272: const refresh = input.refresh;
273: ...
> @loreai/opencode@0.40.0 typecheck /home/byk/Code/opencode-lore-v2/packages/opencode > tsc --noEmit
RUN v4.1.8 /home/byk/Code/opencode-lore-v2
Test Files 1 passed (1)
Tests 2 passed (2)
Start at 14:39:31
Duration 9.56s (transform 544ms, setup 608ms, import 8ms, tests 8.73s, environment 0ms)
M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M pnpm-lock.yaml
No files found
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/schema.ts
Found 21 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:
Line 207: const sessionHeaders = (session: Pick<SessionSchema.Info, "id" | "parentID" | "projectID">, app: App.Info) => ({
Line 210: ...(session.parentID ? { "x-parent-session-id": session.parentID } : {}),
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/transfer.ts:
Line 73: if (input.data.info.parentID) yield* sessions.get(input.data.info.parentID)
Line 94: parentID: input.data.info.parentID,
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/projector.ts:
Line 113: .where(eq(SessionTable.id, event.data.parentID))
Line 116: if (!parent) return yield* Effect.die(new Error(`Fork parent session not found: ${event.data.parentID}`))
Line 122: eq(SessionMessageTable.session_id, event.data.parentID),
Line 135: eq(SessionMessageTable.session_id, event.data.parentID),
Line 152: fork_session_id: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/schema.ts</path>
<type>file</type>
<content>
1: export * as SessionSchema from "@opencode/schema/session"
2:
3: import { Session } from "@opencode/schema/session"
4:
5: export const ID = Session.ID
6: export type ID = typeof ID.Type
7:
8: export const Info = Session.Info
9: export type Info = Session.Info
(End of file - total 9 lines)
</content>
Found 3 matches /home/byk/Code/opencode-v2-pilot/packages/schema/src/session.ts: Line 34: parentID: ID.pipe(optional), /home/byk/Code/opencode-v2-pilot/packages/schema/src/v1/session.ts: Line 461: parentID: MessageID, Line 550: parentID: optional(SessionID),
https://gateway.example.com.evil/v1/messages true https://gateway.example.com:444/v1/messages true https://gateway.example.com/v11/messages true
<path>/home/byk/Code/opencode-lore-v2/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: "./server": {
16: "types": "./src/server.ts",
17: "bun": "./dist/server.js",
18: "default": "./dist/server.js"
19: }
20: },
21: "scripts": {
22: "typecheck": "tsc --noEmit",
23: "build": "tsx script/build.ts"
24: },
25: "peerDependencies": {
26: "@opencode-ai/plugin": ">=1.1.0",
27: "@opencode/plugin": ">=0.0.0"
28: },
29: "peerDependenciesMeta": {
30: "@opencode/plugin": {
31: ...
Found 8 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts:
Line 43: ) => load(operation, sources, options),
Line 61: default: Schema.Union([
Line 68: setup: Schema.declare<Parameters<typeof PluginPromise.fromPromise>[0]["setup"]>(
Line 69: (input): input is Parameters<typeof PluginPromise.fromPromise>[0]["setup"] => typeof input === "function",
Line 105: : Host.load(entrypoint).then((module) => ({ module, version: installed?.revision })),
Line 111: message: "Plugin must export a default definition with an id and an effect or setup function.",
Line 115: )).default
Line 116: const plugin = "effect" in value ? value : PluginPromise.fromPromise(value)
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/module.ts</path>
<type>file</type>
<content>
45: }
46: })
47:
48: // A missing dependency may have missing parents too. Watch the nearest existing
49: // ancestor recursively so creating the rest of the path can trigger recovery.
50: function watchTarget(file: string): Promise<Watcher.WatchInput> {
51: return stat(file).then(
52: (info) => ({ path: file, type: info.isDirectory() ? "directory" : "file" }),
53: (cause) => {
54: if (path.dirname(file) === file) throw cause
55: return watchTarget(path.dirname(file))
56: },
57: )
58: }
59:
60: const Module = Schema.Struct({
61: default: Schema.Union([
62: Schema.Struct({
63: id: Schema.String,
64: effect: Schema.declare<Plugin["effect"]>((input): input is Plugin["effect"] => typeof input === "function"),
65: }),
66: Schema.Struct({
67: id: Schema.String,
68: setup: Schema.declare<Parameters<typeof ...
Found 10 matches
/home/byk/Code/opencode-lore-v2/packages/core/src/git.ts:
Line 101: export function getGitRemote(path: string): string | null {
/home/byk/Code/opencode-lore-v2/packages/core/src/index.ts:
Line 202: getGitRemote,
/home/byk/Code/opencode-lore-v2/packages/core/src/db.ts:
Line 13: import { getGitRemote } from "./git";
Line 5043: * `getGitRemote()` is per-path cached and already returns null in hosted mode,
Line 5050: const disk = getGitRemote(path); // null in hosted mode OR when not a repo
Line 5338: const remote = getGitRemote(path); // null in hosted mode OR when not a repo
/home/byk/Code/opencode-lore-v2/packages/core/src/data.ts:
Line 31: import { getGitRemote } from "./git";
Line 1725: gitRemote = getGitRemote(project.path);
/home/byk/Code/opencode-lore-v2/packages/core/src/import/scope.ts:
Line 18: * against a client-controlled cwd — mirrors `getGitRemote`).
Line 71: // gateway (same invariant as getGitRemote()).
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/git.ts</path>
<type>file</type>
<content>
80: * Clear the in-memory git remote cache.
81: *
82: * Intended for test harnesses that need deterministic behavior across
83: * test cases without leaking cached results.
84: */
85: export function clearGitRemoteCache(): void {
86: gitRemoteCache.clear();
87: }
88:
89: /**
90: * Get the canonical git remote URL for a repository at the given path.
91: *
92: * Prefers `origin` (the canonical clone source) over `upstream`, then falls
93: * back to any other remote. Origin-first is deliberate: unrelated repos
94: * bootstrapped from a common template share an `upstream` but keep distinct
95: * `origin`s, so keying on the shared upstream would falsely merge them into one
96: * project. Returns null if the path is not in a git repo or has no remotes. ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/git.ts</path>
<type>file</type>
<content>
145: if (!url) {
146: gitRemoteCache.set(path, null);
147: return null;
148: }
149:
150: const result = normalizeRemoteUrl(url);
151: gitRemoteCache.set(path, result);
152: return result;
153: } catch {
154: // Not a git repo, git not installed, timeout, etc.
155: gitRemoteCache.set(path, null);
156: return null;
157: }
158: }
159:
160: // ---------------------------------------------------------------------------
161: // Git user identity
162: // ---------------------------------------------------------------------------
163:
164: /** Cached git user identity (process-lifetime, like gitRemoteCache). */
165: const gitUserCache = new Map<
166: string,
167: { name: string | null; email: string | null }
168: >();
169:
170: /**
171: * Clear the in-memory git user cache. For test isolation. ...
17320087 /home/byk/Code/opencode-lore-v2/packages/opencode/dist/server.js [ 'default' ] lore
> @loreai/opencode@0.40.0 build /home/byk/Code/opencode-lore-v2/packages/opencode > tsx script/build.ts dist/server.js 16.5mb ⚠️ dist/server.js.map 31.9mb ⚡ Done in 1899ms
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts</path>
<type>file</type>
<content>
1: /**
2: * Fetch-level interception for transparent LLM API proxy routing.
3: *
4: * Instead of overwriting provider baseURLs early (which loses original auth
5: * and URL context), this interceptor wraps `globalThis.fetch` to redirect
6: * outgoing LLM API calls through the Lore gateway at the HTTP level.
7: *
8: * The SDK builds requests normally (correct auth, correct URL for each
9: * provider), and the interceptor transparently reroutes them through the
10: * gateway while preserving all original headers.
11: */
12: import * as log from "./log";
13:
14: /** Configuration for the fetch interceptor. */
15: export type FetchInterceptorConfig = {
16: /** Base URL of the Lore gateway (e.g., "http://127.0.0.1:3207"). */
17: gatewayBase: string;
18: /**
19: * Dynamic headers to inject on every intercepted request. ...
Found 14 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/routing.e2e.test.ts:
Line 118: "LORE_REMOTE_URL",
Line 125: delete process.env.LORE_REMOTE_URL;
/home/byk/Code/opencode-lore-v2/packages/opencode/test/internal.test.ts:
Line 11: describe("remote gateway access headers", () => {
Line 23: test("injects the access token only for the matching LORE_REMOTE_URL", () => {
Line 26: LORE_REMOTE_URL: "https://lore.example/",
Line 33: LORE_REMOTE_URL: "https://lore.example",
Line 42: LORE_REMOTE_URL: "https://lore.example",
/home/byk/Code/opencode-lore-v2/packages/opencode/test/gateway-smoke.test.ts:
Line 2: import { probeGateway } from "../src/internal";
Line 29: test("probeGateway returns false for a port with nothing listening", async () => {
Line 31: const result = await probeGateway("http://127.0.0.1:19876", 500);
Line 51: const healthy = await probeGateway(base, 2000);
Line 99: const ...
<path>/home/byk/Code/opencode-lore-v2/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). ...
Found 5 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:
Line 243: // Exposes each outbound HTTP exchange to session.http.request/response hooks
Line 245: const httpMiddleware =
Line 249: const before = yield* hooks.trigger("session", "http.request", {
Line 365: (yield* hooks.has("session", "http.request", resolved.ref.providerID)) ||
Line 375: ? httpMiddleware(hooks, {
Found 18 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/types.ts:
Line 796: "x-lore-upstream-url",
Line 797: "x-lore-upstream-path",
/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts:
Line 6207: req.rawHeaders["x-lore-upstream-url"]
Line 6249: if (req.rawHeaders["x-lore-upstream-url"] && !headerUpstream) {
Line 6589: // the client's original endpoint path (x-lore-upstream-path) AND we are a pure
Line 13377: "x-lore-upstream-url": sessionState.lastUpstream?.url ?? "",
Line 13383: fallbackHeaders["x-lore-upstream-url"] = trustedUpstream;
Line 14220: "x-lore-upstream-url": trustedUpstreamBase,
Line 14282: rawHeaders["x-lore-upstream-url"] &&
/home/byk/Code/opencode-lore-v2/packages/gateway/src/config.ts:
Line 567: const raw = headers["x-lore-upstream-url"];
Line 712: const raw = headers["x-lore-upstream-path"];
Line 1017: * the same way an incoming `x-lore-upstream-url` ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
6160: gitRemote: trustedAdoptionRemote(projectPath, headers),
6161: known: null,
6162: msgCount,
6163: requestGeneration,
6164: config,
6165: credentialFingerprint,
6166: });
6167: if (adopted) return adopted;
6168:
6169: // No matching session → create new.
6170: const sessionID = generateSessionID();
6171: return { sessionID, isNew: true, tier: 3 };
6172: }
6173:
6174: // ---------------------------------------------------------------------------
6175: // Upstream forwarding
6176: // ---------------------------------------------------------------------------
6177:
6178: type EffectiveUpstreamProtocol = UpstreamSnapshot["protocol"];
6179:
6180: type ResolvedRequestUpstreamRoute = {
6181: /** Explicit, sanitized X-Lore-Provider value (not inferred signals). */
6182: providerHeader?: string;
6183: /** Provider identity actually selected, ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
6290: throw new Error(`Unsupported provider "${providerID}"`);
6291: }
6292: if (
6293: providerID &&
6294: providerRoute?.url == null &&
6295: !headerUpstream &&
6296: !selfUrlBuildingProtocol
6297: ) {
6298: throw new Error(
6299: `Provider "${providerID}" requires an explicit upstream URL`,
6300: );
6301: }
6302: const providerRouteUsable =
6303: providerRoute &&
6304: (providerRoute.url != null || headerUpstream || selfUrlBuildingProtocol)
6305: ? providerRoute
6306: : null;
6307: const nativeIngressAnthropicOverride =
6308: providerHeader != null && providerRouteUsable?.protocol === "anthropic";
6309: const effectiveProtocol: EffectiveUpstreamProtocol =
6310: req.protocol === "openai-responses"
6311: ? nativeIngressAnthropicOverride
6312: ? ...
Found 3 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:
Line 243: // Exposes each outbound HTTP exchange to session.http.request/response hooks
Line 249: const before = yield* hooks.trigger("session", "http.request", {
Line 365: (yield* hooks.has("session", "http.request", resolved.ref.providerID)) ||
No files found
Found 56 matches /home/byk/Code/opencode-lore-v2/packages/gateway/src/worker-health.ts: Line 91: * They are NOT fully silenced (unlike `worker-incapable`, which early-returns): Line 729: // embedded the failure count, duration, AND session ID, so EVERY event /home/byk/Code/opencode-lore-v2/packages/gateway/src/transient-errors.ts: Line 24: * a fetch is never silenced. /home/byk/Code/opencode-lore-v2/packages/gateway/src/telemetry-privacy.ts: Line 59: /^Worker upstream exhausted \d+ retries: HTTP \d+(?: embedded \d+)?$/, Line 192: /** Redact credentials and query-bearing URLs embedded in free-form text. */ /home/byk/Code/opencode-lore-v2/packages/gateway/src/stream/openai-responses.ts: Line 2424: // only fires during genuine upstream silence. /home/byk/Code/opencode-lore-v2/packages/gateway/src/side-channel.ts: Line 84: * somehow embedded a coding-prompt signal would merely fall through to ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts</path>
<type>file</type>
<content>
65: * Bound for the bounded vector-pool shutdown on graceful shutdown (#1599).
66: * The pool teardown must wait for every worker's SQLite reader to close before
67: * the writer can TRUNCATE the WAL — leaving readers up would strand the `-wal`
68: * file and force WAL recovery on the next boot. Sized to fit under the global
69: * deadline after the embedding drain (60%) so a stuck worker still leaves room
70: * for the writer's checkpoint+close. Mirrors {@link EMBED_DRAIN_DEADLINE_MS}'s
71: * safety floor of 500ms so an aggressive `LORE_SHUTDOWN_TIMEOUT_MS` (e.g.
72: * 1000ms) doesn't shrink the pool budget into a guaranteed timeout.
73: */
74: const VECTOR_POOL_SHUTDOWN_DEADLINE_MS = Math.max(
75: Math.min(
76: DEFAULT_VECTOR_POOL_SHUTDOWN_DEADLINE_MS,
77: SHUTDOWN_DEADLINE_MS - 500,
78: ),
79: 500,
80: );
81:
82: export interface StartOptions {
83: ...
Found 6 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:
Line 21: export class RegistrationError extends Schema.TaggedError<RegistrationError>()("Tool.RegistrationError", {
/home/byk/Code/opencode-v2-pilot/packages/core/src/state.ts:
Line 14: export interface Registration {
Line 15: readonly dispose: Effect.Effect<void>
Line 222: if (group?.failed) return { dispose: Effect.void }
/home/byk/Code/opencode-v2-pilot/packages/core/src/mcp/index.ts:
Line 228: entry.registration = { dispose: Scope.close(scope, Exit.void) }
/home/byk/Code/opencode-v2-pilot/packages/core/src/snapshot.ts:
Line 200: transform: () => Effect.succeed({ dispose: Effect.void }),
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/state.ts</path>
<type>file</type>
<content>
1: export * as State from "./state.js"
2:
3: import { Cause, Context, Effect, Exit, Fiber, Scope } from "effect"
4:
5: /**
6: * A synchronous, replayable edit to the current domain state.
7: *
8: * Domain editors expose readable and writable state while preserving concise
9: * plugin/config code. Transforms synchronously rebuild derived state.
10: */
11: type TransformCallback<Editor> = (editor: Editor) => void
12: export type MakeEditor<State, Editor> = (state: State) => Editor
13:
14: export interface Registration {
15: readonly dispose: Effect.Effect<void>
16: }
17:
18: /**
19: * Registers a scoped transform. Reads rebuild by applying every registered transform in order.
20: * Closing the owning Scope removes the transform and invalidates the current value.
21: */
22: export type Transform<Editor> = (
23: transform: TransformCallback<Editor>,
24: ) => ...
Found 12 matches /home/byk/Code/opencode-v2-pilot/packages/ai/src/route/executor.ts: Line 16: middleware?: HttpMiddleware, Line 23: export type HttpMiddleware = ( Line 235: middleware?: HttpMiddleware, Line 239: const response = yield* executor.execute(request, middleware) Line 248: const executeOnce = (request: HttpClientRequest.HttpClientRequest, middleware?: HttpMiddleware) => Line 250: if (!middleware) Line 256: const response = yield* middleware(request, (input) => /home/byk/Code/opencode-v2-pilot/packages/ai/src/route/client.ts: Line 414: middleware: options?.http, /home/byk/Code/opencode-v2-pilot/packages/ai/src/route/transport/index.ts: Line 42: readonly middleware?: HttpMiddleware /home/byk/Code/opencode-v2-pilot/packages/ai/src/route/transport/http.ts: Line 23: readonly middleware?: HttpMiddleware Line 87: middleware: prepareInput.middleware, Line 92: const response = yield* ...
<path>/home/byk/Code/opencode-v2-pilot/packages/ai/src/route/executor.ts</path>
<type>file</type>
<content>
1: import { Cause, Context, Effect, Layer, Option, Schema, Stream } from "effect"
2: import {
3: FetchHttpClient,
4: Headers,
5: HttpClient,
6: HttpClientError,
7: HttpClientRequest,
8: HttpClientResponse,
9: } from "effect/unstable/http"
10: import { HttpContext, HttpRateLimitDetails, AIError, TransportError } from "../schema/index.js"
11: import { classifyProviderFailure } from "../provider-error.js"
12:
13: export interface Interface {
14: readonly execute: (
15: request: HttpClientRequest.HttpClientRequest,
16: middleware?: HttpMiddleware,
17: ) => Effect.Effect<HttpClientResponse.HttpClientResponse, AIError>
18: }
19:
20: export type HttpHandler = (
21: request: HttpClientRequest.HttpClientRequest,
22: ) => Effect.Effect<HttpClientResponse.HttpClientResponse, Error>
23: export type HttpMiddleware = (
24: request: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/ai/src/route/executor.ts</path>
<type>file</type>
<content>
230: )
231:
232: export const stream = (
233: executor: Interface,
234: request: HttpClientRequest.HttpClientRequest,
235: middleware?: HttpMiddleware,
236: ): Stream.Stream<Uint8Array, AIError> =>
237: Stream.unwrap(
238: Effect.gen(function* () {
239: const response = yield* executor.execute(request, middleware)
240: return responseStream(response)
241: }),
242: )
243:
244: export const layer: Layer.Layer<Service, never, HttpClient.HttpClient> = Layer.effect(
245: Service,
246: Effect.gen(function* () {
247: const http = yield* HttpClient.HttpClient
248: const executeOnce = (request: HttpClientRequest.HttpClientRequest, middleware?: HttpMiddleware) =>
249: Effect.gen(function* () {
250: if (!middleware)
251: return yield* http.execute(request).pipe(
252: Effect.mapError((error) => httpError({ ...
Found 39 matches
/home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/bedrock-event-stream.ts:
Line 132: id: "aws-event-stream",
/home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/bedrock-converse.ts:
Line 73: signature: Schema.optional(Schema.String),
Line 190: signature: Schema.optional(Schema.String),
Line 266: if (ProviderShared.isRecord(metadata) && typeof metadata.signature === "string") return metadata.signature
Line 375: const signature = reasoningSignature(part, providerMetadataKey)
Line 377: if (signature === undefined && redactedData !== undefined) {
Line 381: if (signature === undefined || signature.trim().length === 0) {
Line 382: // Interrupted streams and model switches can leave unsigned reasoning.
Line 387: content.push({ reasoningContent: { reasoningText: { text: part.text, signature } } })
Line 590: if (reasoning.signature) return ...
<path>/home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/utils/bedrock-auth.ts</path>
<type>file</type>
<content>
50: reason: new AuthenticationError({
51: message: `AWS default credential chain failed: ${ProviderShared.errorText(error)}`,
52: cause: error,
53: }),
54: }),
55: })
56:
57: const signRequest = (input: {
58: readonly url: string
59: readonly body: string
60: readonly headers: Headers.Headers
61: readonly credentials: Credentials
62: readonly service: string
63: readonly name: string
64: }) =>
65: Effect.tryPromise({
66: try: async () => {
67: const signed = await new AwsV4Signer({
68: url: input.url,
69: method: "POST",
70: headers: Object.entries(input.headers),
71: body: input.body,
72: region: input.credentials.region,
73: accessKeyId: input.credentials.accessKeyId,
74: secretAccessKey: input.credentials.secretAccessKey,
75: ...
@opencode/plugin false -1 @loreai/core false -1 @loreai/gateway true 25478
Found 4 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/dist/server.js:
Line 158: silenceStderr: () => silenceStderr,
Line 217: var STDERR_SILENCED_KEY = "__loreStderrSilenced";
Line 221: function silenceStderr(silenced = true) {
Line 812: log_exports.info("No Lore gateway found, starting in-process\u2026");
0db6083724c4f3cff6e0fa4723a0df424edf4951f685ec804822224c868c6160 AGENTS.md 9e4f2da707df714528a2960788ad2cca489fd8ba5b8745e7551f912fc07ac58d .lore.md 33dd563b5acf04a3403187b675c4245966053d835c073e5b1f6775eac982416a packages/core/src/fetch-interceptor.ts 3733b1b2aeda2abd2a29f3faa2e3490b1882efaae819cc33922d98e0ff2b40e7 packages/core/src/index.ts 8e941b002a8f2c5de612e217c26b562547bd69cfce40f3283aebca985eab9618 packages/core/test/fetch-interceptor-request.test.ts 37f411dc7f5f03cfbe01c06c12c15e6670064ef835129d43aa4dd91b2b2bed16 packages/opencode/package.json ffb408e62bd3278d386e5716c78296835b264660b7f93496d01007d180521fef packages/opencode/script/build.ts f7c5e6fd88f68281804dfbca12af2ec9e6617bcc14e054b1aa3332bc600bfd8c packages/opencode/src/index.ts 4eaf5c314373f7c62c7b31310537bc0f0f7a1f09e28caa5d903258d98b740688 packages/opencode/src/internal.ts 657288e5191734cb56d76126b07e1a8ea6cb4587e298cbff2f6e0f9972c205ab ...
Found 54 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts:
Line 203: function isManagementPath(pathname: string): boolean {
Line 205: pathname === "/" ||
Line 206: pathname === "/api" ||
Line 207: pathname.startsWith("/api/") ||
Line 208: pathname === "/ui" ||
Line 209: pathname.startsWith("/ui/")
Line 213: function isDataPlanePath(pathname: string): boolean {
Line 215: pathname === "/v1/messages" ||
Line 216: pathname === "/v1/chat/completions" ||
Line 217: pathname === "/chat/completions" ||
Line 218: pathname === "/v1/responses" ||
Line 219: pathname === "/v1/codex/responses" ||
Line 220: pathname === "/v1/responses/compact" ||
Line 221: pathname === "/v1/compact" ||
Line 222: pathname === "/v1/models" ||
Line 223: GEMINI_PATH_RE.test(pathname) ||
Line 224: BEDROCK_RUNTIME_PATH_RE.test(pathname)
Line 351: parsed.pathname !== "/" ||
Line ...
No files found
Found 7 matches /home/byk/Code/opencode-v2-pilot/packages/ai/src/providers/index.ts: Line 3: export * as AmazonBedrock from "./amazon-bedrock.js" Line 4: export * as AmazonBedrockMantle from "./amazon-bedrock-mantle.js" Line 13: export * as Google from "./google.js" Line 14: export * as GoogleVertex from "./google-vertex.js" Line 15: export * as GoogleVertexChat from "./google-vertex-chat.js" Line 16: export * as GoogleVertexMessages from "./google-vertex-messages.js" Line 17: export * as GoogleVertexResponses from "./google-vertex-responses.js"
<path>/home/byk/Code/opencode-v2-pilot/packages/ai/src/providers/google.ts</path>
<type>file</type>
<content>
1: import type { RouteDefaultsInput } from "../route/client.js"
2: import { Auth } from "../route/auth.js"
3: import type { ProviderAuthOption } from "../route/auth-options.js"
4: import type { ProviderPackage } from "../provider-package.js"
5: import { HttpOptions, ProviderID, mergeHttpOptions, type ModelID } from "../schema/index.js"
6: import { Gemini } from "../protocols/gemini.js"
7: import { GoogleImages } from "../protocols/google-images.js"
8:
9: export type { GoogleImageOptions } from "../protocols/google-images.js"
10: export type GeminiOptionsInput = Gemini.OptionsInput
11: export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput
12:
13: export const id = ProviderID.make("google")
14:
15: export const routes = [Gemini.route]
16:
17: export type Config = RouteDefaultsInput &
18: ProviderAuthOption<"optional"> & {
19: readonly baseURL?: ...
Found 3 matches
/home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/gemini.ts:
Line 840: // Gemini's path embeds the model id and pins SSE framing at the URL level.
Line 841: endpoint: Endpoint.path(({ request }) => `/models/${request.model.id}:streamGenerateContent?alt=sse`, {
Line 842: baseURL: DEFAULT_BASE_URL,
<path>/home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/gemini.ts</path>
<type>file</type>
<content>
830: step,
831: onHalt: (state) => Effect.succeed(finish(state)),
832: },
833: })
834:
835: export const route = Route.make({
836: id: ADAPTER,
837: provider: "google",
838: providerMetadataKey: "google",
839: protocol,
840: // Gemini's path embeds the model id and pins SSE framing at the URL level.
841: endpoint: Endpoint.path(({ request }) => `/models/${request.model.id}:streamGenerateContent?alt=sse`, {
842: baseURL: DEFAULT_BASE_URL,
843: }),
844: auth: Auth.none,
845: framing: Framing.sse,
846: })
847:
848: export * as Gemini from "./gemini.js"
(End of file - total 848 lines)
</content>
Found 2 matches /home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/gemini.ts: Line 30: export const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta" Line 842: baseURL: DEFAULT_BASE_URL,
Found 3 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts:
Line 67: BEDROCK_RUNTIME_PATH_RE,
Line 224: BEDROCK_RUNTIME_PATH_RE.test(pathname)
Line 998: if (method === "POST" && BEDROCK_RUNTIME_PATH_RE.test(pathname)) {
Found 5 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/bedrock-runtime.ts:
Line 105: export const BEDROCK_RUNTIME_PATH_RE =
Line 170: const match = BEDROCK_RUNTIME_PATH_RE.exec(new URL(req.url).pathname);
/home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts:
Line 67: BEDROCK_RUNTIME_PATH_RE,
Line 224: BEDROCK_RUNTIME_PATH_RE.test(pathname)
Line 998: if (method === "POST" && BEDROCK_RUNTIME_PATH_RE.test(pathname)) {
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/bedrock-runtime.ts</path>
<type>file</type>
<content>
95: * Bedrock Runtime API operations. Captures modelId and verb for downstream
96: * URL building.
97: *
98: * The `[a-zA-Z0-9._:-]` class on modelId is intentionally permissive: AWS
99: * catalog ids routinely contain dots (e.g. `anthropic.claude-opus-4-6-v1`,
100: * `google.gemma-3-4b-it`, `us.anthropic.claude-haiku-4-5`), dashes, and
101: * version-suffix colons (e.g. `anthropic.claude-opus-4-5-20251101-v1:0`).
102: * A bare `model/{modelId}/{verb}` segment is enough specificity that this
103: * cannot accidentally collide with `/v1/models` (plural) or `/v1/messages`.
104: */
105: export const BEDROCK_RUNTIME_PATH_RE =
106: /^\/v1\/model\/([a-zA-Z0-9._:-]+)\/(converse|converse-stream|invoke|invoke-with-response-stream)$/;
107:
108: /**
109: * Build the Bedrock Runtime API origin for a region. ...
Found 1 matches /home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/bedrock-converse.ts: Line 782: endpoint: Endpoint.path<BedrockConverseBody>(
<path>/home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/bedrock-converse.ts</path>
<type>file</type>
<content>
770: onHalt: (state) => Effect.succeed(onHalt(state)),
771: },
772: })
773:
774: export const route = Route.make({
775: id: ADAPTER,
776: provider: "bedrock",
777: providerMetadataKey: "bedrock",
778: protocol,
779: // Bedrock's URL embeds the region in the route endpoint host and the
780: // validated modelId in the path. We read the validated body so the URL
781: // matches the body that gets signed.
782: endpoint: Endpoint.path<BedrockConverseBody>(
783: ({ body }) => `/model/${encodeURIComponent(body.modelId)}/converse-stream`,
784: ),
785: auth: BedrockAuth.auth,
786: framing,
787: })
788:
789: export const sigV4Auth = BedrockAuth.sigV4
790:
791: export * as BedrockConverse from "./bedrock-converse.js"
(End of file - total 791 lines)
</content>
Found 5 matches
/home/byk/Code/opencode-v2-pilot/packages/ai/src/providers/amazon-bedrock.ts:
Line 23: readonly baseURL?: string
Line 29: readonly baseURL?: string
Line 40: const { apiKey, auth, credentials, profile, region, baseURL, ...rest } = input
Line 49: endpoint: { baseURL: baseURL ?? bedrockBaseURL(resolvedRegion) },
Line 68: baseURL: settings.baseURL,
Found 8 matches /home/byk/Code/opencode-v2-pilot/packages/plugin/src/effect/session.ts: Line 37: export type SessionRequestKind = "primary" | "compaction" | "title" | "generate" Line 43: readonly kind: SessionRequestKind Line 52: readonly kind: SessionRequestKind Line 60: readonly kind: SessionRequestKind /home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts: Line 37: export type SessionRequestKind = "primary" | "compaction" | "title" | "generate" Line 43: readonly kind: SessionRequestKind Line 52: readonly kind: SessionRequestKind Line 60: readonly kind: SessionRequestKind
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-v2/packages/gateway/src/quota.ts:
Line 7: * entitlement and feed it into Lore's throttle + worker-pause decisions.
/home/byk/Code/opencode-lore-v2/packages/gateway/src/side-channel.ts:
Line 6: * conversation title/topic generation, and subagent naming/summary. These are
/home/byk/Code/opencode-lore-v2/packages/gateway/src/ui.ts:
Line 204: <summary><span class="badge badge-toolcall">${esc(chunk.name)}</span></summary>
Line 212: <summary><span class="badge badge-reasoning">reasoning</span></summary>
Line 261: * `title` and `value` are escaped. `detailLeftHtml`/`detailRightHtml` accept
Line 265: title: string;
Line 283: <div class="cost-bar-label"><span class="bar-title">${esc(opts.title)}</span><span class="bar-value">${esc(opts.value)}</span></div>
Line 340: title: "Your Spend",
Line 354: title: "Cache Hit Rate",
Line 367: title: "Actual vs ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts</path>
<type>file</type>
<content>
360: */
361: export function extractPreviousSummary(
362: req: GatewayRequest,
363: ): string | undefined {
364: const userText = lastUserText(req);
365: const match = PREVIOUS_SUMMARY_RE.exec(userText);
366: return match?.[1] ?? undefined;
367: }
368:
369: // ---------------------------------------------------------------------------
370: // isMetaRequest (replaces isTitleOrSummaryRequest)
371: // ---------------------------------------------------------------------------
372:
373: /** Header injected by the OpenCode plugin identifying the calling agent. */
374: export const LORE_AGENT_HEADER = "x-lore-agent";
375:
376: /**
377: * Agent names known to be primary conversation agents (NOT meta).
378: * When `x-lore-agent` matches, the request is always a normal turn. ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts</path>
<type>file</type>
<content>
441: export function isMetaRequest(req: GatewayRequest): boolean {
442: // Compaction requests are handled separately
443: if (isCompactionRequest(req)) return false;
444:
445: // --- Layer 1: Explicit agent header ---
446: const agentHeader = req.rawHeaders[LORE_AGENT_HEADER];
447: if (agentHeader) {
448: const agent = agentHeader.toLowerCase();
449: if (PRIMARY_AGENTS.has(agent)) return false;
450: if (META_AGENTS.has(agent)) return true;
451: // Unknown agent → fall through to heuristics
452: }
453:
454: // --- Layer 2: Heuristic scoring ---
455: let score = 0;
456:
457: if (req.tools.length <= META_MAX_TOOLS) score += SCORE_FEW_TOOLS;
458: if (req.messages.length <= META_MAX_MESSAGES) score += SCORE_FEW_MESSAGES;
459: if (req.system.length < META_MAX_SYSTEM_LENGTH) score += SCORE_SHORT_SYSTEM;
460: if (req.maxTokens > 0 && ...
Found 11 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts:
Line 61: source: "title",
Line 67: kind: "title",
Line 68: scope: { session: input.session, agentID: input.agent.id, model: input.model },
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:
Line 68: readonly agentID: Agent.ID
Line 311: agent: input.scope.contextAgentID ?? input.scope.agentID,
Line 333: { sessionID: session.id, agent: input.scope.agentID, model: resolved.ref, kind: input.kind },
Line 377: agent: input.scope.agentID,
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/generate.ts:
Line 48: scope: { session: selection.session, agentID: selection.agent.id, model, tools: selection.tools },
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/context.ts:
Line 96: const agent = yield* ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts</path>
<type>file</type>
<content>
45: const store = yield* SessionStore.Service
46: const db = (yield* Database.Service).db
47:
48: const attempt = Effect.fn("SessionTitle.attempt")(function* (input: {
49: readonly session: SessionSchema.Info
50: readonly agent: Agent.Info
51: readonly text: string
52: readonly model: SessionRunnerModel.Resolved
53: }) {
54: const chunks: string[] = []
55: let failed = false
56: let usage: SessionUsage.Recorded | undefined
57: const recordUsage = Effect.suspend(() =>
58: usage
59: ? bus.publish(SessionEvent.UsageRecorded, {
60: sessionID: input.session.id,
61: source: "title",
62: ...usage,
63: })
64: : Effect.void,
65: )
66: const prepared = yield* context.prepare({
67: kind: "title",
68: scope: { ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts</path>
<type>file</type>
<content>
450: fd = openLogFileForAppend(path);
451: writeFileSync(fd, line, "utf8");
452: } catch {
453: // Silently degrade — logging failure shouldn't crash the app
454: } finally {
455: if (fd !== undefined) closeSync(fd);
456: }
457: }
458:
459: // ---------------------------------------------------------------------------
460: // Public API
461: // ---------------------------------------------------------------------------
462:
463: /** Log an informational status message. Suppressed unless LORE_DEBUG=1. */
464: export function info(...args: unknown[]): void {
465: const msg = redactSensitiveLogText(formatArgs(args));
466: if (isDebug && !readStderrSilenced())
467: console.error("[lore]", ...safeArgs(args));
468: sink?.info(msg);
469: writeToFile("info", msg);
470: }
471:
472: /** Log a warning. Suppressed unless LORE_DEBUG=1. */
473: export function ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts:
Line 897: console.error(`[lore] ${method} ${pathname}`);
Line 906: console.error(
Line 1215: console.error(
/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/upgrade.ts:
Line 200: console.error(`Usage: lore upgrade [version] [options]
Line 234: console.error(
Line 247: console.error(`[lore] Current version: ${VERSION}`);
Line 248: console.error(`[lore] Channel: ${channel}`);
Line 258: console.error(`[lore] Offline mode: using cached target ${target}`);
Line 273: console.error(
Line 294: console.error(`[lore] Already up to date (${VERSION})`);
Line 297: console.error(`[lore] ${direction} available: ${VERSION} -> ${target}`);
Line 298: console.error(`[lore] Run 'lore upgrade' to update.`);
Line 301: console.error("[lore] (resolved from cache — ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts</path>
<type>file</type>
<content>
870: if (dataPlanePath) {
871: if (
872: (config.remoteGateway || config.hostedMode) &&
873: (!config.gatewayAuthToken ||
874: !gatewayAccessMatches(
875: req.headers,
876: config.gatewayAuthToken,
877: rawHeaders,
878: ))
879: ) {
880: return gatewayAccessDeniedResponse();
881: }
882: if (
883: hasConflictingAuthHeaders(headersToRecord(req.headers)) ||
884: (rawHeaders !== undefined && hasRawConflictingProviderAuth(rawHeaders))
885: ) {
886: return conflictingProviderAuthResponse();
887: }
888: req = withoutGatewayAccessHeader(req);
889: }
890:
891: // Preserve no-Origin OPTIONS behavior without enabling browser CORS. ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts</path>
<type>file</type>
<content>
1190: "\r\n",
1191: );
1192: return;
1193: }
1194: if (hasRawConflictingProviderAuth(req.rawHeaders)) {
1195: const body = JSON.stringify({
1196: type: "error",
1197: error: {
1198: type: "invalid_request_error",
1199: message: "Conflicting provider authentication headers",
1200: },
1201: });
1202: socket.end(
1203: "HTTP/1.1 400 Bad Request\r\n" +
1204: "Content-Type: application/json\r\n" +
1205: `Content-Length: ${Buffer.byteLength(body)}\r\n` +
1206: "Cache-Control: no-store\r\n" +
1207: "Connection: close\r\n" +
1208: "\r\n" +
1209: body,
1210: );
1211: return;
1212: ...
0db6083724c4f3cff6e0fa4723a0df424edf4951f685ec804822224c868c6160 AGENTS.md 9e4f2da707df714528a2960788ad2cca489fd8ba5b8745e7551f912fc07ac58d .lore.md 33dd563b5acf04a3403187b675c4245966053d835c073e5b1f6775eac982416a packages/core/src/fetch-interceptor.ts 3733b1b2aeda2abd2a29f3faa2e3490b1882efaae819cc33922d98e0ff2b40e7 packages/core/src/index.ts 8e941b002a8f2c5de612e217c26b562547bd69cfce40f3283aebca985eab9618 packages/core/test/fetch-interceptor-request.test.ts 37f411dc7f5f03cfbe01c06c12c15e6670064ef835129d43aa4dd91b2b2bed16 packages/opencode/package.json ffb408e62bd3278d386e5716c78296835b264660b7f93496d01007d180521fef packages/opencode/script/build.ts f7c5e6fd88f68281804dfbca12af2ec9e6617bcc14e054b1aa3332bc600bfd8c packages/opencode/src/index.ts 4eaf5c314373f7c62c7b31310537bc0f0f7a1f09e28caa5d903258d98b740688 packages/opencode/src/internal.ts 657288e5191734cb56d76126b07e1a8ea6cb4587e298cbff2f6e0f9972c205ab ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-core.ts</path>
<type>file</type>
<content>
1: export { GATEWAY_AUTH_HEADER } from "../../core/src/credential-headers";
2: export { rewriteRequest } from "../../core/src/fetch-interceptor";
3: export { getGitRemote } from "../../core/src/git";
4: export * as log from "../../core/src/log";
(End of file - total 4 lines)
</content>
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
170: * lifetime (reaped by the same TTL as projectState) to avoid an SDK round-trip
171: * on every turn. */
172: const sessionParent = new Map<
173: string,
174: { parentID: string | null; lastSeenAt: number }
175: >();
176:
177: function reapStaleSessionParent(): void {
178: const cutoff = Date.now() - SESSION_STATE_TTL_MS;
179: for (const [id, entry] of sessionParent) {
180: if (entry.lastSeenAt < cutoff) sessionParent.delete(id);
181: }
182: }
183:
184: /**
185: * Resolve a session's parent session ID via the OpenCode SDK.
186: *
187: * OpenCode Task sub-agents run in a child session whose `parentID` points at
188: * the session that spawned them; primary sessions have no parent. ...
RUN v4.1.8 /home/byk/Code/opencode-lore-v2
Test Files 3 passed (3)
Tests 22 passed (22)
Start at 15:07:52
Duration 7.64s (transform 6.50s, setup 4.05s, import 6.06s, tests 584ms, environment 0ms)
Found 11 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts:
Line 21: "@loreai/core": join(packageDir, "src/server-core.ts"),
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts:
Line 3: const { release, acquireServerRuntime, buildServerHeaders, rewriteRequest } =
Line 21: rewriteRequest: vi.fn(
Line 32: vi.mock("@loreai/core", () => ({ rewriteRequest }));
Line 198: expect(rewriteRequest).toHaveBeenCalledWith(
/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-core.ts:
Line 1: export { GATEWAY_AUTH_HEADER } from "../../core/src/credential-headers";
Line 2: export { rewriteRequest } from "../../core/src/fetch-interceptor";
/home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts:
Line 1: import { rewriteRequest } from "@loreai/core";
Line 49: event.request = await rewriteRequest(
/home/byk/Code/opencode-lore-v2/packages/opencode/src/internal.ts:
Line 18: import { ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts</path>
<type>file</type>
<content>
1: import * as esbuild from "esbuild";
2: import { mkdirSync, rmSync } from "node:fs";
3: import { dirname, join } from "node:path";
4: import { fileURLToPath } from "node:url";
5:
6: const packageDir = dirname(dirname(fileURLToPath(import.meta.url)));
7: const dist = join(packageDir, "dist");
8:
9: rmSync(dist, { recursive: true, force: true });
10: mkdirSync(dist, { recursive: true });
11:
12: await esbuild.build({
13: entryPoints: [join(packageDir, "src/server.ts")],
14: outfile: join(dist, "server.js"),
15: bundle: true,
16: format: "esm",
17: platform: "node",
18: target: "esnext",
19: sourcemap: true,
20: alias: {
21: "@loreai/core": join(packageDir, "src/server-core.ts"),
22: },
23: external: ["@opencode/plugin", "@loreai/gateway"],
24: logLevel: "info",
25: });
(End of file - total 25 lines)
</content>
No files found
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts</path>
<type>file</type>
<content>
1: import { rewriteRequest } from "@loreai/core";
2: import type { Plugin } from "@opencode/plugin";
3: import { acquireServerRuntime, buildServerHeaders } from "./server-runtime";
4:
5: const workers = [
6: ["lore-distill", "Lore memory distillation worker"],
7: ["lore-curator", "Lore knowledge curator worker"],
8: ["lore-query-expand", "Lore query expansion worker"],
9: ] as const;
10:
11: export default {
12: id: "lore",
13: setup: async (ctx) => {
14: const runtime = await acquireServerRuntime(ctx.location.project.directory);
15: if (!runtime) return;
16:
17: const registrations: Array<{ dispose: () => Promise<void> }> = [];
18: try {
19: registrations.push(
20: await ctx.agent.transform((editor) => {
21: for (const [id, description] of workers) {
22: editor.update(id, (agent) => {
23: ...
0db6083724c4f3cff6e0fa4723a0df424edf4951f685ec804822224c868c6160 AGENTS.md 9e4f2da707df714528a2960788ad2cca489fd8ba5b8745e7551f912fc07ac58d .lore.md 33dd563b5acf04a3403187b675c4245966053d835c073e5b1f6775eac982416a packages/core/src/fetch-interceptor.ts 3733b1b2aeda2abd2a29f3faa2e3490b1882efaae819cc33922d98e0ff2b40e7 packages/core/src/index.ts 8e941b002a8f2c5de612e217c26b562547bd69cfce40f3283aebca985eab9618 packages/core/test/fetch-interceptor-request.test.ts 37f411dc7f5f03cfbe01c06c12c15e6670064ef835129d43aa4dd91b2b2bed16 packages/opencode/package.json ffb408e62bd3278d386e5716c78296835b264660b7f93496d01007d180521fef packages/opencode/script/build.ts f7c5e6fd88f68281804dfbca12af2ec9e6617bcc14e054b1aa3332bc600bfd8c packages/opencode/src/index.ts 4eaf5c314373f7c62c7b31310537bc0f0f7a1f09e28caa5d903258d98b740688 packages/opencode/src/internal.ts 767eaba533f86fc7ef171d6718267853f80436cf3dcfcfc661d8aca08d9abdf4 ...
Found 9 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts:
Line 1: export * as SessionTitle from "./title.js"
Line 30: export class Service extends Context.Service<Service, Interface>()("@opencode/SessionTitle") {}
Line 48: const attempt = Effect.fn("SessionTitle.attempt")(function* (input: {
Line 101: const generate = Effect.fn("SessionTitle.generate")(function* (sessionID: SessionSchema.ID) {
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/runner/llm.ts:
Line 21: import { SessionTitle } from "../title.js"
Line 46: const title = yield* SessionTitle.Service
Line 167: if (promoted > 0 && !selected.session.parentID && SessionTitle.isUntitled(selected.session))
Line 168: yield* FiberMap.run(titles, sessionID, title.generate(sessionID), {
Line 365: SessionTitle.node,
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts</path>
<type>file</type>
<content>
95: .join("")
96: .split("\n")
97: .map((line) => line.trim())
98: .find((line) => line.length > 0)
99: })
100:
101: const generate = Effect.fn("SessionTitle.generate")(function* (sessionID: SessionSchema.ID) {
102: const session = yield* store.get(sessionID)
103: if (!session) return
104: const firstUser = yield* SessionHistory.firstUserMessage(db, session.id)
105: if (!firstUser) return
106: const text = !isUntitled(session)
107: ? yield* store.context(session.id).pipe(
108: Effect.map((messages) => {
109: const original = `Original request:\n${firstUser.text.slice(0, MAX_FIRST_MESSAGE_LENGTH)}`
110: const recent = messages
111: .flatMap((message) => {
112: if (message.type === "user" && message.id !== firstUser.id) return ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/context.ts</path>
<type>file</type>
<content>
1: export * as SessionContext from "./context.js"
2:
3: import { Model } from "@opencode/schema/model"
4: import { Context, Effect, Layer } from "effect"
5: import { Agent } from "../agent.js"
6: import { Catalog } from "../catalog.js"
7: import { CodeModeInstructions } from "../codemode/instructions.js"
8: import { Database } from "../database/database.js"
9: import { makeLocationNode } from "@opencode/util/effect/app-node"
10: import { InstructionDiscovery } from "../instruction-discovery.js"
11: import { Instructions } from "../instructions/index.js"
12: import { InstructionBuiltIns } from "../instructions/builtins.js"
13: import { Location } from "../location.js"
14: import { McpInstructions } from "../mcp/instructions.js"
15: import { McpTool } from "../tool/mcp.js"
16: import { ReferenceInstructions } from "../reference/instructions.js"
17: import { SkillInstructions } ...
Found 5 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts:
Line 17: "x-lore-agent": "build",
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts:
Line 148: "x-lore-agent": "build",
/home/byk/Code/opencode-lore-v2/packages/opencode/test/session-state.test.ts:
Line 119: expect(output.headers["x-lore-agent"]).toBe("coder");
/home/byk/Code/opencode-lore-v2/packages/opencode/test/routing.e2e.test.ts:
Line 208: expect(output.headers["x-lore-agent"]).toBe("build");
Line 226: "x-lore-agent": "build",
Found 1 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/index.test.ts:
Line 33: const tmpDir = `${fileURLToPath(new URL(".", import.meta.url))}/__tmp_plugin_${Date.now()}__`;
Found 16 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-github-copilot.test.ts:
Line 48: const modelRequest = Effect.fn(function* (sessionID: Session.ID, kind: SessionRequestKind, agent = "build") {
Line 206: it.effect("classifies compaction requests by kind rather than agent", () =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts:
Line 46: const seen: Array<{ hook: string; kind: SessionRequestKind; agent: Agent.ID }> = []
Line 49: seen.push({ hook: "request", kind: event.kind, agent: event.agent })
Line 54: seen.push({ hook: "response", kind: event.kind, agent: event.agent })
Line 74: { hook: "request", kind, agent: Agent.ID.make("build") },
Line 75: { hook: "response", kind, agent: Agent.ID.make("build") },
/home/byk/Code/opencode-v2-pilot/packages/core/test/session-execution.test.ts:
Line 186: kind: "subagent",
Line 702: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-github-copilot.test.ts</path>
<type>file</type>
<content>
35: function required<T>(value: T | undefined): T {
36: if (value === undefined) throw new Error("Expected value")
37: return value
38: }
39:
40: const sessions = Effect.fn(function* () {
41: const service = yield* Session.Service
42: const location = yield* Location.Service
43: const parent = yield* service.create({ location: { directory: location.directory } })
44: const child = yield* service.create({ parentID: parent.id })
45: return { parent: parent.id, child: child.id }
46: })
47:
48: const modelRequest = Effect.fn(function* (sessionID: Session.ID, kind: SessionRequestKind, agent = "build") {
49: const hooks = yield* PluginHooks.Service
50: return yield* hooks.trigger("session", "model.request", {
51: sessionID,
52: agent: Agent.ID.make(agent),
53: model: Model.Ref.make({ providerID: Provider.ID.githubCopilot, id: ...
Found 11 matches /home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/bedrock-runtime.ts: Line 46: signal: AbortSignal, Line 56: signal, Line 58: signal.throwIfAborted(); Line 79: cancelAndReleaseReader(reader, signal.reason); Line 124: "proxy-authorization", Line 160: * End-to-end AWS headers, including `Authorization` and signed `x-amz-*` Line 190: const abortScope = createForegroundAbortScope(req.signal); Line 193: ? await readBedrockRuntimeRequestBody(req.body, abortScope.signal) Line 202: signal: abortScope.signal, Line 204: abortScope.signal, Line 214: abortScope.signal,
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/bedrock-runtime.ts</path>
<type>file</type>
<content>
115: }
116:
117: const BEDROCK_STRIPPED_HEADERS = new Set([
118: "connection",
119: "cookie",
120: "cookie2",
121: "host",
122: "keep-alive",
123: "proxy-authenticate",
124: "proxy-authorization",
125: "proxy-connection",
126: "te",
127: "trailer",
128: "transfer-encoding",
129: "upgrade",
130: ]);
131:
132: export function bedrockRuntimeHeaders(headers: Headers): Headers {
133: const connectionHeaders = new Set(
134: (headers.get("connection") ?? "")
135: .split(",")
136: .map((name) => name.trim().toLowerCase())
137: .filter(Boolean),
138: );
139: const upstream = new Headers();
140: headers.forEach((value, key) => {
141: const normalized = key.toLowerCase();
142: if (
143: BEDROCK_STRIPPED_HEADERS.has(normalized) ||
144: connectionHeaders.has(normalized) ||
145: ...
Found 2 matches /home/byk/Code/opencode-lore-v2/packages/core/src/credential-headers.ts: Line 4: export const GATEWAY_AUTH_HEADER = "x-lore-gateway-token"; Line 46: GATEWAY_AUTH_HEADER,
Found 2 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts:
Line 133: gatewayHeaders: { "x-lore-access": "gateway-token" },
Line 145: "x-lore-access": "gateway-token",
https://gateway.example
/usr/bin/bash: line 1: ${g.origin}${u.pathname}: bad substitution
Found 11 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/index.test.ts:
Line 133: // to `${gatewayBase}/v1` because opencode's resolveSDK() bypasses the
Line 210: test("is a no-op when gatewayBase is empty (test env / startup failure)", () => {
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts:
Line 34: gatewayBase: "http://127.0.0.1:3207",
Line 68: gatewayBase: "http://127.0.0.1:3207",
Line 92: gatewayBase: "http://127.0.0.1:3207",
Line 97: gatewayBase: "http://127.0.0.1:5673",
Line 117: expect(second?.gatewayBase).toBe("http://127.0.0.1:5673");
Line 132: gatewayBase: "https://gateway.example",
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts:
Line 9: gatewayBase: "http://127.0.0.1:3207",
Line 254: gatewayBase: "http://127.0.0.1:3207",
Line 261: gatewayBase: "http://127.0.0.1:3207",
Found 1 matches /home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/plugin.ts: Line 27: readonly location: Location.Info
<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/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 ...
No files found
<skill_content name="jj-guide"> # Skill: jj-guide # jj Guide for AI Agents Jujutsu (jj) is a Git-compatible VCS with mutable commits, automatic snapshotting, no staging area, and first-class conflicts. This skill teaches you how to use it safely from a non-interactive agent environment. If `.jj/` exists in the repo root, this is a jj repo. **Use `jj` commands, not `git`.** In a colocated repo (`.jj/` *and* `.git/`), git tools can read the state, but mutations should go through `jj` so the operation log stays consistent. ## Critical Rules - **NEVER** use interactive flags (`-i`, `--interactive`). TUI prompts hang in agent environments. This applies to `jj split -i`, `jj squash -i`, `jj commit -i`, `jj resolve`, `jj diffedit`, etc. - **ALWAYS** pass `-m "msg"` when describing/committing. Without `-m`, an editor opens and hangs. - **VERIFY** mutations with `jj st` and `jj log` after `squash`, `abandon`, `rebase`, `restore`, `commit`. ...
Working copy changes: M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-core.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M pnpm-lock.yaml Working copy (@) : wlpqmtos 52e6687e lore-v2-plugin | feat(opencode): add V2 server plugin Parent commit (@-): uutomtup 42911412 main | fix(gateway): preserve large recall continuations (#1730) wlpqmtosolpk 52e6687e1eae feat(opencode): add V2 server plugin uutomtupslqm 429114122aa1 fix(gateway): preserve large recall continuations (#1730) packages/core/src/fetch-interceptor.ts | 250 ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/package.test.ts</path>
<type>file</type>
<content>
1: import { execFileSync } from "node:child_process";
2: import { mkdtempSync, readFileSync, rmSync } from "node:fs";
3: import { tmpdir } from "node:os";
4: import { join } from "node:path";
5: import { afterAll, beforeAll, describe, expect, test } from "vitest";
6:
7: const packageDir = join(import.meta.dirname, "..");
8: const temporary = mkdtempSync(join(tmpdir(), "lore-opencode-package-"));
9: const packageName = "loreai-opencode.tgz";
10:
11: beforeAll(() => {
12: execFileSync("pnpm", ["run", "build"], {
13: cwd: packageDir,
14: stdio: "pipe",
15: });
16: execFileSync("pnpm", ["pack", "--out", join(temporary, packageName)], {
17: cwd: packageDir,
18: stdio: "pipe",
19: });
20: execFileSync("tar", ["-xzf", join(temporary, packageName), "-C", temporary], {
21: stdio: "pipe",
22: });
23: });
24:
25: afterAll(() => {
26: ...
RUN v4.1.8 /home/byk/Code/opencode-lore-v2
Test Files 5 passed (5)
Tests 89 passed (89)
Start at 15:40:43
Duration 2.09s (transform 1.63s, setup 2.51s, import 355ms, tests 307ms, environment 1ms)
Found 3 matches
/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts:
Line 291: if (url.startsWith(gatewayBase)) return false;
Line 354: if (request.url.startsWith(gatewayBase)) {
Line 531: const targetsGateway = url.startsWith(gatewayBase);
<path>/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-request.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect, test, vi } from "vitest";
2: import { rewriteRequest } from "../src/fetch-interceptor";
3:
4: const GATEWAY = "https://gateway.example.com";
5: const dynamicHeaders = {
6: "x-lore-project": "/home/me/project",
7: "x-lore-session-id": "session-123",
8: };
9:
10: describe("rewriteRequest", () => {
11: test("routes a V2-style Request without losing method, body, auth, path, or query", async () => {
12: const body = JSON.stringify({
13: model: "gpt-5",
14: messages: [{ role: "user", content: "Hello" }],
15: });
16: const observed = vi.fn();
17: const request = new Request(
18: "https://openrouter.ai/api/v1/chat/completions?stream=true&trace=abc",
19: {
20: method: "POST",
21: headers: {
22: authorization: "Bearer sk-test",
23: "content-type": ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts</path>
<type>file</type>
<content>
1: import { getGitRemote, log } from "@loreai/core";
2: import {
3: gatewayAccessHeadersForRemote,
4: parseUpstreamExtraHeaders,
5: probeGateway,
6: shouldForwardUpstreamExtraHeader,
7: } from "./internal";
8:
9: const gatewayPackage = "@loreai/gateway";
10: const knownGatewayPorts = [3207, 5673];
11:
12: export interface LoreServerRuntime {
13: gatewayBase: string;
14: projectPath: string;
15: gitRemote: string;
16: gatewayHeaders: Record<string, string>;
17: release: () => Promise<void>;
18: }
19:
20: export interface ServerRuntimeDependencies {
21: resolveGateway?: () => Promise<{
22: gatewayBase: string;
23: gatewayHeaders: Record<string, string>;
24: shutdown?: () => Promise<void>;
25: }>;
26: gitRemote?: (path: string) => string | null;
27: }
28:
29: interface GatewayHandle {
30: port: number;
31: owned: boolean;
32: ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts</path>
<type>file</type>
<content>
270: /**
271: * Set of `${host}${pathname}` strings we've already warned about (avoids
272: * log spam on every request to a non-intercepted LLM endpoint).
273: */
274: const warnedPaths = new Set<string>();
275:
276: /**
277: * Determine whether a fetch request should be intercepted and rerouted
278: * through the Lore gateway.
279: *
280: * Only intercepts requests to known LLM API paths on remote hosts.
281: * Never intercepts:
282: * - Requests already going to the gateway
283: * - Local requests (localhost, 127.0.0.1, etc.) — these may be local LLM
284: * servers or the gateway itself (infinite loop risk)
285: * - Non-LLM API paths (arbitrary HTTP calls from plugins, health checks, etc.)
286: */
287: export function shouldIntercept(url: string, gatewayBase: string): boolean {
288: try {
289: const parsed = new URL(url);
290: // Never intercept ...
Found 8 matches
/home/byk/Code/opencode-lore-v2/packages/core/src/warmup-histogram.ts:
Line 126: export function normalizeWarmupHistogram(counts: readonly bigint[]): {
/home/byk/Code/opencode-lore-v2/packages/core/src/search.ts:
Line 488: export function normalizeRank(
/home/byk/Code/opencode-lore-v2/packages/core/src/markdown.ts:
Line 152: export function normalize(md: string): string {
/home/byk/Code/opencode-lore-v2/packages/core/src/credential-headers.ts:
Line 63: function normalizeHeaderName(name: string): string {
/home/byk/Code/opencode-lore-v2/packages/core/src/git.ts:
Line 37: export function normalizeRemoteUrl(url: string): string {
Line 150: const result = normalizeRemoteUrl(url);
/home/byk/Code/opencode-lore-v2/packages/core/src/index.ts:
Line 201: normalizeRemoteUrl,
/home/byk/Code/opencode-lore-v2/packages/core/src/import/auth/opencode.ts:
Line 74: function normalizeProvider(key: string): string {
> @loreai/core@0.40.0 typecheck /home/byk/Code/opencode-lore-v2/packages/core > tsc --noEmit && tsc --noEmit -p tsconfig.eval.json
M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-core.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M pnpm-lock.yaml error: unexpected argument '--check' found tip: to pass '--check' as a value, use '-- --check' Usage: jj diff [OPTIONS] [FILESETS]... For more information, try '--help'.
(no output)
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2:
3: const { release, acquireServerRuntime, buildServerHeaders, rewriteRequest } =
4: vi.hoisted(() => {
5: const release = vi.fn(async () => {});
6: return {
7: release,
8: acquireServerRuntime: vi.fn(async () => ({
9: gatewayBase: "http://127.0.0.1:3207",
10: projectPath: "/workspace/project",
11: gitRemote: "github.com/example/project",
12: gatewayHeaders: {},
13: release,
14: })),
15: buildServerHeaders: vi.fn(() => ({
16: "x-lore-session-id": "ses_1",
17: "x-lore-agent": "build",
18: "x-lore-provider": "openai",
19: "x-lore-upstream-url": "https://api.openai.com",
20: })),
21: rewriteRequest: vi.fn(
22: async (request: Request) =>
23: new ...
node:internal/modules/esm/resolve:271
throw new ERR_MODULE_NOT_FOUND(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/byk/Code/opencode-lore-v2/packages/core/src/log' imported from /home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts
at finalizeResolution (node:internal/modules/esm/resolve:271:11)
at moduleResolve (node:internal/modules/esm/resolve:865:10)
at defaultResolve (node:internal/modules/esm/resolve:992:11)
at #cachedDefaultResolve (node:internal/modules/esm/loader:691:20)
at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:708:38)
at ModuleLoader.resolveSync (node:internal/modules/esm/loader:740:52)
at #resolve (node:internal/modules/esm/loader:673:17)
at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:593:35)
at ModuleJob.syncLink (node:internal/modules/esm/module_job:163:33)
at ModuleJob.link (node:internal/modules/esm/module_job:253:17) {
code: ...
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Transform failed with 1 error:
/eval.ts:1:337: ERROR: Top-level await is currently not supported with the "cjs" output format
at failureErrorWithLog (/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/lib/main.js:1748:15)
at /home/byk/Code/opencode-lore-v2/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/lib/main.js:1017:50
at responseCallbacks.<computed> (/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/lib/main.js:884:9)
at handleIncomingPacket (/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/lib/main.js:939:12)
at Socket.readFromStdout (/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/lib/main.js:862:7)
at Socket.emit (node:events:509:28)
at addChunk (node:internal/streams/readable:563:12)
...
https://gateway.example.com.evil/v1/messages => https://gateway.example.com.evil/v1/messages true https://gateway.example.com:444/v1/messages => https://gateway.example.com:444/v1/messages true https://gateway.example.com/v11/messages => https://gateway.example.com/v11/messages true
Found 39 matches
/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-request.test.ts:
Line 30: const routed = await rewriteRequest(
Line 65: const routed = await rewriteRequest(request, GATEWAY, dynamicHeaders);
Line 78: const result = await rewriteRequest(
Line 102: expect(await rewriteRequest(request, GATEWAY, dynamicHeaders)).toBe(
Line 110: expect(await rewriteRequest(request, GATEWAY, dynamicHeaders)).toBe(
Line 129: const routed = await rewriteRequest(request, GATEWAY, dynamicHeaders);
Line 157: const result = await rewriteRequest(request, GATEWAY, dynamicHeaders);
/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-body.test.ts:
Line 184: shouldIntercept(
Line 193: shouldIntercept(
Line 202: shouldIntercept("https://chatgpt.com/backend-api/codex/foo", GATEWAY),
Line 208: shouldIntercept("http://127.0.0.1:3207/v1/codex/responses", ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-paths.test.ts</path>
<type>file</type>
<content>
180:
181: test("does NOT match /api/foo/embeddings (sub-paths under /api/v1 don't match if no /v1/)", () => {
182: expect(
183: shouldIntercept("https://api.example.com/api/foo/embeddings", GATEWAY),
184: ).toBe(false);
185: });
186: });
187:
188: describe("Localhost exclusion (infinite-loop prevention)", () => {
189: test("does NOT intercept localhost (could be local LLM server)", () => {
190: expect(
191: shouldIntercept("http://localhost:8000/v1/messages", GATEWAY),
192: ).toBe(false);
193: });
194:
195: test("does NOT intercept 127.0.0.1", () => {
196: expect(
197: shouldIntercept("http://127.0.0.1:8000/v1/messages", GATEWAY),
198: ).toBe(false);
199: });
200:
201: test("does NOT intercept 0.0.0.0", () => {
202: ...
Found 29 matches
/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-paths.test.ts:
Line 16: const GATEWAY = "http://127.0.0.1:3207";
Line 22: shouldIntercept("https://api.anthropic.com/v1/messages", GATEWAY),
Line 30: GATEWAY,
Line 37: shouldIntercept("https://api.anthropic.com/v1/messages/foo", GATEWAY),
Line 45: shouldIntercept("https://api.openai.com/v1/chat/completions", GATEWAY),
Line 53: GATEWAY,
Line 62: shouldIntercept("https://api.openai.com/v1/responses", GATEWAY),
Line 72: GATEWAY,
Line 79: shouldIntercept("https://api.example.com/api/v1/messages", GATEWAY),
Line 85: shouldIntercept("https://api.example.com/api/v1/responses", GATEWAY),
Line 95: GATEWAY,
Line 102: shouldIntercept("https://api.example.com/api/messages", GATEWAY),
Line 112: GATEWAY,
Line 121: GATEWAY,
Line 132: GATEWAY,
...
Found 25 matches /home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts: Line 810: * When set, every call to `forwardToUpstream` passes through the interceptor Line 6186: headerUpstreamPath?: string; Line 6237: * retain the exact route intent used by forwardToUpstream. Line 6244: const headerUpstreamPath = extractUpstreamPathHeader(req.rawHeaders); Line 6281: headerUpstreamPath && Line 6283: new URL(headerUpstreamPath, new URL(headerUpstream).origin).href, Line 6294: providerRoute?.url == null && Line 6345: headerUpstreamPath, Line 6354: /** Result from forwardToUpstream — includes the serialized body for cache analytics. */ Line 6378: async function forwardToUpstream( Line 6395: headerUpstreamPath, Line 6407: providerRoute?.url == null && Line 6460: url = result.url; Line 6495: url = result.url; Line 6537: url = vt.url; Line 6555: url = result.url; Line 6575: url = ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
6430: );
6431:
6432: // Defense-in-depth: warn when a bearer token prefix clearly mismatches
6433: // the resolved upstream. Catches misrouting before the upstream rejects it.
6434: if (
6435: routingAuth?.scheme === "bearer" &&
6436: routingAuth.value.startsWith("gho_") &&
6437: !effectiveUpstreamBase.includes("githubcopilot")
6438: ) {
6439: log.error(
6440: `auth/upstream mismatch: GitHub OAuth token (gho_) routed to ${upstreamUrlForLog(effectiveUpstreamBase)} — ` +
6441: `provider: ${providerID ?? "none"}`,
6442: );
6443: }
6444:
6445: if (effectiveProtocol === "openai-responses") {
6446: // Inject LTM into system prompt for non-Anthropic paths.
6447: // Anthropic handles LTM via separate system blocks in buildAnthropicRequest;
6448: // OpenAI paths receive a single system string, so we concatenate here. ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/config.ts</path>
<type>file</type>
<content>
540: config: Pick<GatewayConfig, "remoteGateway" | "hostedMode"> &
541: Partial<Pick<GatewayConfig, "callerUpstreamAllowlist">>,
542: upstreamUrl: string,
543: ): boolean {
544: if (!config.remoteGateway && !config.hostedMode) return true;
545: try {
546: const parsed = new URL(upstreamUrl);
547: if (parsed.protocol !== "https:") return false;
548: return (config.callerUpstreamAllowlist ?? []).includes(parsed.origin);
549: } catch {
550: return false;
551: }
552: }
553:
554: /**
555: * Extract and validate the `X-Lore-Upstream-URL` header from a request.
556: *
557: * Used by local/custom providers (vllm, llama.cpp, ollama, etc.) to tell the
558: * gateway where to forward the request when `resolveUpstreamRoute()` returns
559: * null. ...
No files found
No files found
No files found
Found 9 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/test/bedrock-runtime.test.ts:
Line 18: proxyBedrockRuntimeRequest,
Line 191: describe("proxyBedrockRuntimeRequest — handler logic", () => {
Line 197: const resp = await proxyBedrockRuntimeRequest(req, "us-east-1");
Line 232: const response = await proxyBedrockRuntimeRequest(request, "us-east-1", {
Line 283: const pending = proxyBedrockRuntimeRequest(request, "us-east-1", {
Line 316: const pending = proxyBedrockRuntimeRequest(
Line 371: const response = await proxyBedrockRuntimeRequest(
Line 411: const response = await proxyBedrockRuntimeRequest(request, "us-east-1", {
Line 444: const response = await proxyBedrockRuntimeRequest(
<path>/home/byk/Code/opencode-lore-v2/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: parseUpstreamExtraHeaders,
17: probeGateway,
18: shouldForwardUpstreamExtraHeader,
19: surfaceGatewayUnavailable,
20: } from "./internal";
21:
22: /**
23: * Lore plugin for OpenCode — transparent LLM proxy ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-transport.ts</path>
<type>file</type>
<content>
1: export * as SessionModelTransport from "./model-transport.js"
2:
3: import {
4: WebSocketTransport,
5: type ChannelObservation,
6: type ChannelCheckpoint,
7: type WebSocketChannelExchange,
8: type WebSocketChannelExecution,
9: type WebSocketChannelExecutor,
10: type WebSocketConnection,
11: type WebSocketConnector,
12: } from "@opencode/ai/route"
13: import { AIError, AIErrorReason, TransportError, type TransportOperation } from "@opencode/ai"
14: import { Hash } from "@opencode/util/hash"
15: import { Cause, Clock, Context, Effect, Fiber, Layer, Metric, Queue, Scope, Semaphore, Stream } from "effect"
16: import { Socket } from "effect/unstable/socket"
17: import { makeGlobalNode } from "@opencode/util/effect/app-node"
18: import { SessionSchema } from "./schema.js"
19: import { webSocketConstructor } from "../effect/app-node-platform.js"
20:
21: ...
Found 4 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:
Line 340: // Disable built-in compaction (gateway handles it), register hidden
Line 344: cfg.compaction = { auto: false, prune: false };
Line 376: // requests (title generation, summary agents, etc.) from real
Line 386: // unlike x-session-affinity (nanoid regenerated per process).
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
365: description: "Lore query expansion worker",
366: },
367: };
368: // Pin the Anthropic provider's baseURL to the gateway. See
369: // applyLoreProviderConfig in ./internal.ts for the full rationale.
370: applyLoreProviderConfig(cfg, gatewayBase);
371: },
372:
373: tool: {},
374:
375: // Inject per-request identifiers so the gateway can distinguish meta
376: // requests (title generation, summary agents, etc.) from real
377: // conversation turns and route by provider.
378: // Project path, git remote, and upstream URL are injected by the
379: // fetch interceptor (installed once per process).
380: "chat.headers": async (input, output) => {
381: Object.assign(
382: output.headers,
383: gatewayAccessHeadersForRemote(gatewayBase),
384: );
385: ...
Found 32 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/test/anthropic-client-openai-upstream-stream.test.ts:
Line 220: // treated as a meta request and takes the passthrough path.
/home/byk/Code/opencode-lore-v2/packages/gateway/test/anthropic-caching.test.ts:
Line 8: * 4. No caching for passthrough (meta requests: title gen, summaries, etc.)
/home/byk/Code/opencode-lore-v2/packages/gateway/test/compaction.test.ts:
Line 7: isMetaRequest,
Line 215: test("returns false for meta requests (title/summary)", () => {
Line 303: // isMetaRequest
Line 306: describe("isMetaRequest", () => {
Line 315: expect(isMetaRequest(req)).toBe(true);
Line 324: expect(isMetaRequest(req)).toBe(true);
Line 337: expect(isMetaRequest(req)).toBe(false);
Line 350: expect(isMetaRequest(req)).toBe(false);
Line 360: expect(isMetaRequest(req)).toBe(false);
Line 370: // Compaction-detected → isCompactionRequest returns true → ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/test/compaction.test.ts</path>
<type>file</type>
<content>
300: });
301:
302: // ---------------------------------------------------------------------------
303: // isMetaRequest
304: // ---------------------------------------------------------------------------
305:
306: describe("isMetaRequest", () => {
307: // -- Backward-compatible: existing structural patterns still detected ------
308:
309: test("detects short system prompt + single message as title request", () => {
310: const req = makeRequest({
311: system: "Generate a short title for the conversation.",
312: tools: [],
313: messages: [userMsg("Help me sort an array in JavaScript")],
314: });
315: expect(isMetaRequest(req)).toBe(true);
316: });
317:
318: test("detects with 2 messages and 1 tool (within limits)", () => {
319: const req = makeRequest({
320: system: "Summarize this conversation.",
321: tools: [{ name: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/warming.ts:
Line 14: export const Plugin = define({
Line 15: id: "opencode.warming",
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/zenmux.ts:
Line 5: export const ZenmuxPlugin = define({
Line 6: id: "opencode.provider.zenmux",
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/command.ts:
Line 11: export const Plugin = define({
Line 12: id: "opencode.command",
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/xai.ts:
Line 76: export const XAIPlugin = define({
Line 77: id: "opencode.provider.xai",
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/plan.ts:
Line 27: export const Plugin = define({
Line 28: id: "opencode.plan",
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/optimize.ts:
Line 15: export const OpenAIPlugin = make("opencode.prompt.openai", (model) => {
Line 21: ...
Found 18 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/cli/vite.node.config.ts:
Line 141: export const define = sdk.Plugin.define`
/home/byk/Code/opencode-v2-pilot/packages/simulation/src/backend/simulated-provider.ts:
Line 540: Plugin.define({
/home/byk/Code/opencode-v2-pilot/packages/plugin-browser/src/index.ts:
Line 6: export default Plugin.define({
/home/byk/Code/opencode-v2-pilot/packages/latex/src/plugin.ts:
Line 4: export default 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: ...
<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 ...
https://gateway.example.com.evil/v1/messages false https://gateway.example.com:444/v1/messages false https://gateway.example.com/v11/messages false
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js</path>
<type>file</type>
<content>
1: import { Tool } from "@opencode/schema/tool";
2: import { Effect, Schema, SchemaAST, Stream } from "effect";
3: import { HttpApiEndpoint, HttpApiSchema } from "effect/unstable/httpapi";
4: import { define } from "../effect/plugin.js";
5: const compiledEndpoints = new WeakMap();
6: const JsonInput = Schema.fromJsonString(Schema.Unknown);
7: class ReturnedRpcError extends Error {
8: type;
9: data;
10: constructor(type, message, data) {
11: super(message);
12: this.type = type;
13: this.data = data;
14: }
15: }
16: const makeStreams = Effect.fn("Plugin.Event.makeStreams")(function* () {
17: const context = yield* Effect.context();
18: const subscriptions = new Set();
19: // Async iterators own separate scopes, so close them when the plugin unloads.
20: yield* Effect.addFinalizer(() => ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
240: );
241: }
242:
243: export const LorePlugin: Plugin = async (ctx) => {
244: // Initialize lore — only probe/start once per process.
245: const loreDisabled =
246: process.env.LORE_DISABLED === "1" || process.env.LORE_DISABLED === "true";
247: let loreActive = processLoreActive;
248: let gatewayBase = processLoreBase;
249: if (!processInitDone) {
250: const inTestEnv = isInertTestEnv();
251:
252: // We're loaded by a real OpenCode process, which owns a full-screen TUI:
253: // any byte on stdout/stderr corrupts the render. Flip the core logger's
254: // process-global silence flag — which the in-process gateway's own (bundled)
255: // copy of `core` reads off `globalThis` too — so NOTHING (not even
256: // `log.error` or gateway warnings) reaches the terminal. Everything still
257: // lands in the log file + Sentry sink (`lore ...
No files found
Found 4 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts:
Line 984: shutdown: async () => {},
Line 1012: shutdown: async () => {},
Line 1123: const shutdown = (): Promise<void> => {
Line 1270: shutdown: async () => {},
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts</path>
<type>file</type>
<content>
1100: io.removePort(actualPort, controlToken);
1101: } finally {
1102: if (
1103: published?.pid === process.pid &&
1104: published.token === controlToken &&
1105: published.processIdentity === processIdentity
1106: ) {
1107: lifecycleLock.assertOwned();
1108: io.removeProcess(process.pid, published);
1109: }
1110: }
1111: } else {
1112: server = undefined;
1113: throw new AggregateError(
1114: [publicationError, closeError],
1115: "Gateway publication failed and the live listener could not be closed; discovery evidence was retained.",
1116: );
1117: }
1118: throw publicationError;
1119: }
1120:
1121: const boundServer = server;
1122: let ...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts</path>
<type>file</type>
<content>
1160: } catch (error) {
1161: shutdownError ??= error;
1162: }
1163: try {
1164: shutdownLock.assertOwned();
1165: await embedding.settleDocumentEmbeds(EMBED_DRAIN_DEADLINE_MS);
1166: } catch (error) {
1167: shutdownError ??= error;
1168: }
1169: try {
1170: shutdownLock.assertOwned();
1171: await embedding.resetProvider();
1172: } catch (error) {
1173: shutdownError ??= error;
1174: }
1175: try {
1176: shutdownLock.assertOwned();
1177: await shutdownVectorPoolAsync(VECTOR_POOL_SHUTDOWN_DEADLINE_MS);
1178: } catch (error) {
1179: shutdownError ??= error;
1180: }
1181: try {
1182: ...
0db6083724c4f3cff6e0fa4723a0df424edf4951f685ec804822224c868c6160 AGENTS.md 9e4f2da707df714528a2960788ad2cca489fd8ba5b8745e7551f912fc07ac58d .lore.md 33dd563b5acf04a3403187b675c4245966053d835c073e5b1f6775eac982416a packages/core/src/fetch-interceptor.ts 3733b1b2aeda2abd2a29f3faa2e3490b1882efaae819cc33922d98e0ff2b40e7 packages/core/src/index.ts 8e941b002a8f2c5de612e217c26b562547bd69cfce40f3283aebca985eab9618 packages/core/test/fetch-interceptor-request.test.ts 37f411dc7f5f03cfbe01c06c12c15e6670064ef835129d43aa4dd91b2b2bed16 packages/opencode/package.json ffb408e62bd3278d386e5716c78296835b264660b7f93496d01007d180521fef packages/opencode/script/build.ts f7c5e6fd88f68281804dfbca12af2ec9e6617bcc14e054b1aa3332bc600bfd8c packages/opencode/src/index.ts 4eaf5c314373f7c62c7b31310537bc0f0f7a1f09e28caa5d903258d98b740688 packages/opencode/src/internal.ts 767eaba533f86fc7ef171d6718267853f80436cf3dcfcfc661d8aca08d9abdf4 ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts</path>
<type>file</type>
<content>
228: model.enabled = false
229: })
230: }
231: })
232: const refresh = () => loading.withPermit(load().pipe(Effect.andThen(ctx.catalog.reload())))
233: yield* bus.subscribe(Credential.Event.Switched).pipe(
234: Stream.filter((event) => event.data.integrationID === Integration.ID.make("github-copilot")),
235: Stream.runForEach(refresh),
236: Effect.forkScoped({ startImmediately: true }),
237: )
238: yield* refresh().pipe(Effect.forkScoped)
239: yield* ctx.aisdk.hook(
240: "sdk",
241: Effect.fn(function* (evt) {
242: if (evt.model.providerID !== Provider.ID.githubCopilot) return
243: if (evt.package !== "@ai-sdk/github-copilot") return
244: evt.options.fetch = copilotFetch(
245: typeof evt.options.apiKey === "string" ? evt.options.apiKey : ...
RUN v4.1.8 /home/byk/Code/opencode-lore-v2
Test Files 1 passed (1)
Tests 2 passed (2)
Start at 15:57:42
Duration 3.14s (transform 526ms, setup 593ms, import 7ms, tests 2.34s, environment 0ms)
> @loreai/opencode@0.40.0 typecheck /home/byk/Code/opencode-lore-v2/packages/opencode > tsc --noEmit
Checking formatting... All matched files use the correct format. Finished in 36ms on 7 files using 4 threads.
Checking formatting... All matched files use the correct format. Finished in 42ms on 3 files using 4 threads.
<path>/home/byk/Code/opencode-lore-v2/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: "./server": {
16: "types": "./src/server.ts",
17: "bun": "./dist/server.js",
18: "default": "./dist/server.js"
19: }
20: },
21: "scripts": {
22: "typecheck": "tsc --noEmit",
23: "build": "tsx script/build.ts"
24: },
25: "peerDependencies": {
26: "@opencode-ai/plugin": ">=1.1.0",
27: "@opencode/plugin": ">=0.0.0"
28: },
29: "peerDependenciesMeta": {
30: "@opencode/plugin": {
31: ...
0db6083724c4f3cff6e0fa4723a0df424edf4951f685ec804822224c868c6160 AGENTS.md 9e4f2da707df714528a2960788ad2cca489fd8ba5b8745e7551f912fc07ac58d .lore.md 33dd563b5acf04a3403187b675c4245966053d835c073e5b1f6775eac982416a packages/core/src/fetch-interceptor.ts 3733b1b2aeda2abd2a29f3faa2e3490b1882efaae819cc33922d98e0ff2b40e7 packages/core/src/index.ts 8e941b002a8f2c5de612e217c26b562547bd69cfce40f3283aebca985eab9618 packages/core/test/fetch-interceptor-request.test.ts 37f411dc7f5f03cfbe01c06c12c15e6670064ef835129d43aa4dd91b2b2bed16 packages/opencode/package.json ffb408e62bd3278d386e5716c78296835b264660b7f93496d01007d180521fef packages/opencode/script/build.ts f7c5e6fd88f68281804dfbca12af2ec9e6617bcc14e054b1aa3332bc600bfd8c packages/opencode/src/index.ts 4eaf5c314373f7c62c7b31310537bc0f0f7a1f09e28caa5d903258d98b740688 packages/opencode/src/internal.ts 767eaba533f86fc7ef171d6718267853f80436cf3dcfcfc661d8aca08d9abdf4 ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
485: return hooks;
486: } catch (e) {
487: // Log the full error before re-throwing so OpenCode's plugin loader
488: // (which catches and swallows the error) doesn't hide the root cause.
489: // `log.error` captures it to the file + Sentry sink even when stderr is
490: // silenced for the TUI, so the cause survives in `lore logs`.
491: const detail = e instanceof Error ? e.stack || e.message : String(e);
492: log.error(`init failed: ${detail}`);
493: throw e;
494: }
495: };
496:
497: // WARNING: do NOT add any other export to this module. OpenCode's legacy
498: // plugin loader invokes every FUNCTION export as a plugin (pushing its return
499: // value into the host hooks array) and THROWS on any non-function export,
500: // dropping the plugin entirely. Keep helpers in ./internal.ts. ...
Found 1 matches /home/byk/Code/opencode-lore-v2/packages/pi/src/index.ts: Line 79: if (!inTestEnv) log.silenceStderr();
Found 14 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/tui-silence.test.ts:
Line 8: * stdout/stderr corrupts the render. On activation it must flip
Line 9: * `log.silenceStderr()` so neither the plugin nor the in-process gateway it
Line 16: describe("opencode plugin — TUI stderr silencing on activation", () => {
Line 24: log.silenceStderr(false);
Line 27: test("activating the plugin silences stderr so [lore] can't reach the TUI", async () => {
Line 31: log.silenceStderr(false);
/home/byk/Code/opencode-lore-v2/packages/opencode/test/internal.test.ts:
Line 65: * silenced on stderr (so it can't corrupt the render), which would otherwise
Line 72: let stderr: ReturnType<typeof vi.spyOn>;
Line 81: stderr = vi.spyOn(console, "error").mockImplementation(() => {});
Line 82: // log.error only reaches stderr when NOT silenced; assert that path here.
Line 83: log.silenceStderr(false);
Line 87: ...
Found 7 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/package.json:
Line 7: "main": "./dist/index.cjs",
Line 8: "types": "./dist/index.d.cts",
Line 9: "exports": {
Line 11: "types": "./dist/index.d.cts",
Line 77: "@types/bun": "^1.2.0",
Line 78: "@types/qrcode-terminal": "^0.12.2",
Line 79: "@types/semver": "^7.7.1",
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "@loreai/gateway",
3: "version": "0.40.0",
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Lore as a transparent LLM proxy — context management for any AI coding client",
7: "main": "./dist/index.cjs",
8: "types": "./dist/index.d.cts",
9: "exports": {
10: ".": {
11: "types": "./dist/index.d.cts",
12: "bun": "./dist/index.bun.js",
13: "require": "./dist/index.cjs",
14: "default": "./dist/index.cjs"
15: }
16: },
17: "bin": {
18: "lore": "./dist/bin.cjs",
19: "lore-gateway": "./dist/bin.cjs"
20: },
21: "scripts": {
22: "typecheck": "tsc --noEmit",
23: "build": "tsx script/build.ts",
24: "bundle": "tsx script/bundle.ts",
25: "build:binary": "tsx script/build.ts --binary",
26: "build:binary:sea": "tsx script/build-binary-sea.ts",
27: "start": "tsx ...
Found 3 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts:
Line 868: export async function startGateway(
/home/byk/Code/opencode-lore-v2/packages/gateway/src/portfile.ts:
Line 98: export function readPortFile(): number | null {
/home/byk/Code/opencode-lore-v2/packages/gateway/src/index.ts:
Line 24: export { readPortFile } from "./portfile";
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/index.ts</path>
<type>file</type>
<content>
1: /**
2: * Lore Gateway — package entry point.
3: *
4: * Library exports for programmatic use, plus `runCli()` for the CLI binary.
5: *
6: * Library usage:
7: * import { startServer, loadConfig } from "@loreai/gateway";
8: *
9: * CLI usage (via bin wrapper):
10: * lore start
11: * lore run claude
12: */
13: import "../instrument";
14: import { fileURLToPath } from "node:url";
15:
16: // ---------------------------------------------------------------------------
17: // Library API
18: // ---------------------------------------------------------------------------
19:
20: export { loadConfig, DEFAULT_PORTS, DEFAULT_PORT } from "./config";
21: export type { GatewayConfig } from "./config";
22: export { startServer } from "./server";
23: export { handleRequest, resetPipelineState } from "./pipeline";
24: export { readPortFile } from "./portfile";
25: export { ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, describe, expect, test, vi } from "vitest";
2: import {
3: acquireServerRuntime,
4: buildServerHeaders,
5: resetServerRuntimeForTest,
6: } from "../src/server-runtime";
7:
8: const savedEnv = { ...process.env };
9:
10: afterEach(async () => {
11: await resetServerRuntimeForTest();
12: process.env = { ...savedEnv };
13: });
14:
15: describe("V2 server runtime", () => {
16: test.each(["1", "true"])(
17: "stays inactive when LORE_DISABLED=%s",
18: async (value) => {
19: process.env.LORE_DISABLED = value;
20:
21: expect(
22: await acquireServerRuntime("/project", {
23: resolveGateway: vi.fn(),
24: gitRemote: vi.fn(),
25: }),
26: ).toBeUndefined();
27: },
28: );
29:
30: test("shares an owned gateway until every location releases it", async () => {
31: ...
Found 1 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts:
Line 108: export interface GatewayHandle {
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts</path>
<type>file</type>
<content>
100: * the gateway until healthy, prints the address + PID + log path, and exits 0.
101: * CLI: `--bg` / `--daemon`.
102: */
103: bg?: boolean;
104: /** @internal CLI-owned process boundary; never set by in-process plugins. */
105: processBoundary?: boolean;
106: }
107:
108: export interface GatewayHandle {
109: config: GatewayConfig;
110: port: number;
111: /** Whether this process owns the server (started it). False when reusing an existing instance. */
112: owned: boolean;
113: /** Owner-only token used to authenticate the gateway control endpoint. */
114: managementToken: string;
115: /** Shut down the gateway. No-op when `owned` is false. */
116: shutdown: () => Promise<void>;
117: /** @internal One-shot CLI process shutdown shared by signals and control. */
118: processShutdown?: ProcessShutdownController;
119: }
120:
121: export ...
Found 1 matches /home/byk/Code/opencode-lore-v2/packages/opencode/dist/server.js: Line 754: var gatewayPackage = "@loreai/gateway";
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/dist/server.js</path>
<type>file</type>
<content>
730: response.resume();
731: const status = response.statusCode ?? 0;
732: resolve(status >= 200 && status < 300);
733: }
734: );
735: request.on("error", reject);
736: request.end();
737: });
738: }
739: async function probeGateway(baseURL, timeoutMs = 1500) {
740: const controller = new AbortController();
741: const timer = setTimeout(() => controller.abort(), timeoutMs);
742: try {
743: const url = `${baseURL}/health`;
744: if (isLoopbackUrl(url)) return await probeLoopback(url, controller.signal);
745: return (await fetch(url, { signal: controller.signal })).ok;
746: } catch {
747: return false;
748: } finally {
749: clearTimeout(timer);
750: }
751: }
752:
753: // src/server-runtime.ts
754: var gatewayPackage = "@loreai/gateway";
755: var knownGatewayPorts = [3207, 5673];
756: var ...
<path>/home/byk/Code/opencode-lore-v2/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. ...
Found 3 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts:
Line 374: export const LORE_AGENT_HEADER = "x-lore-agent";
Line 441: export function isMetaRequest(req: GatewayRequest): boolean {
Line 446: const agentHeader = req.rawHeaders[LORE_AGENT_HEADER];
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts</path> <type>file</type> <content> 370: // isMetaRequest (replaces isTitleOrSummaryRequest) 371: // --------------------------------------------------------------------------- 372: 373: /** Header injected by the OpenCode plugin identifying the calling agent. */ 374: export const LORE_AGENT_HEADER = "x-lore-agent"; 375: 376: /** 377: * Agent names known to be primary conversation agents (NOT meta). 378: * When `x-lore-agent` matches, the request is always a normal turn. 379: */ 380: const PRIMARY_AGENTS = new Set(["coder", "code"]); 381: 382: /** 383: * Agent names known to be meta/housekeeping agents. 384: * When `x-lore-agent` matches, the request is always passthrough. ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts</path>
<type>file</type>
<content>
1: import { rewriteRequest } from "@loreai/core";
2: import type { Plugin } from "@opencode/plugin";
3: import { acquireServerRuntime, buildServerHeaders } from "./server-runtime";
4:
5: const workers = [
6: ["lore-distill", "Lore memory distillation worker"],
7: ["lore-curator", "Lore knowledge curator worker"],
8: ["lore-query-expand", "Lore query expansion worker"],
9: ] as const;
10:
11: export default {
12: id: "lore",
13: setup: async (ctx) => {
14: const runtime = await acquireServerRuntime(ctx.location.project.directory);
15: if (!runtime) return;
16:
17: const registrations: Array<{ dispose: () => Promise<void> }> = [];
18: try {
19: registrations.push(
20: await ctx.agent.transform((editor) => {
21: for (const [id, description] of workers) {
22: editor.update(id, (agent) => {
23: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts</path>
<type>file</type>
<content>
1: import * as esbuild from "esbuild";
2: import { mkdirSync, rmSync } from "node:fs";
3: import { dirname, join } from "node:path";
4: import { fileURLToPath } from "node:url";
5:
6: const packageDir = dirname(dirname(fileURLToPath(import.meta.url)));
7: const dist = join(packageDir, "dist");
8:
9: rmSync(dist, { recursive: true, force: true });
10: mkdirSync(dist, { recursive: true });
11:
12: await esbuild.build({
13: entryPoints: [join(packageDir, "src/server.ts")],
14: outfile: join(dist, "server.js"),
15: bundle: true,
16: format: "esm",
17: platform: "node",
18: target: "esnext",
19: sourcemap: true,
20: alias: {
21: "@loreai/core": join(packageDir, "src/server-core.ts"),
22: },
23: external: ["@opencode/plugin", "@loreai/gateway"],
24: logLevel: "info",
25: });
(End of file - total 25 lines)
</content>
No files found
Found 10 matches /home/byk/Code/opencode-lore-v2/packages/pi/script/build.ts: Line 22: import * as esbuild from "esbuild"; /home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts: Line 1: import * as esbuild from "esbuild"; /home/byk/Code/opencode-lore-v2/packages/gateway/script/ort-web-plugin.ts: Line 19: import type * as esbuild from "esbuild"; /home/byk/Code/opencode-lore-v2/packages/gateway/script/ort-npm-plugin.ts: Line 34: import type * as esbuild from "esbuild"; /home/byk/Code/opencode-lore-v2/packages/gateway/test/jsonc-parser-plugin.test.ts: Line 2: import * as esbuild from "esbuild"; /home/byk/Code/opencode-lore-v2/packages/gateway/script/ort-native-plugin.ts: Line 32: import type * as esbuild from "esbuild"; /home/byk/Code/opencode-lore-v2/packages/gateway/script/jsonc-parser-plugin.ts: Line 1: import type * as esbuild from "esbuild"; /home/byk/Code/opencode-lore-v2/packages/gateway/script/bundle.ts: Line 19: import * as esbuild from ...
Found 4 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/src/internal.ts:
Line 163: return (await fetch(url, { signal: controller.signal })).ok;
Line 174: * In embedded/TUI mode the core logger's stderr is hard-silenced (see
Line 180: * terminal and cannot corrupt the screen (unlike the `process.stderr.write`
Line 191: // File + Sentry sink (silenced on stderr in embedded mode).
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-core.ts</path>
<type>file</type>
<content>
1: export { GATEWAY_AUTH_HEADER } from "../../core/src/credential-headers";
2: export { rewriteRequest } from "../../core/src/fetch-interceptor";
3: export { getGitRemote } from "../../core/src/git";
4: export * as log from "../../core/src/log";
(End of file - total 4 lines)
</content>
<path>/home/byk/Code/opencode-lore-v2/quality/REVIEW.md</path> <type>file</type> <content> 1: # Review Heuristics — Lore 2: 3: This document codifies the review bar for pull requests. It exists because 4: adversarial review has repeatedly caught correctness bugs that a green test 5: suite missed — skip/early-return branches, lifecycle sequences, and fan-out 6: registry gaps. Institutionalizing these patterns so they compound. 7: 8: The review workflow (§6) is referenced from AGENTS.md. 9: 10: --- 11: 12: ## 1. Regression-test discipline 13: 14: Every adversarial-review finding that surfaces a defect **must** land a 15: deterministic regression test in the same PR. The test: 16: - fails on the base branch (proving it reproduces the bug), 17: - passes on the fix (proving the fix works), 18: - drives the *real* precondition, not an artificially-constructed state (e.g. ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts</path>
<type>file</type>
<content>
1: import { getGitRemote, log } from "@loreai/core";
2: import {
3: gatewayAccessHeadersForRemote,
4: parseUpstreamExtraHeaders,
5: probeGateway,
6: shouldForwardUpstreamExtraHeader,
7: } from "./internal";
8:
9: const gatewayPackage = "@loreai/gateway";
10: const knownGatewayPorts = [3207, 5673];
11:
12: export interface LoreServerRuntime {
13: gatewayBase: string;
14: projectPath: string;
15: gitRemote: string;
16: gatewayHeaders: Record<string, string>;
17: release: () => Promise<void>;
18: }
19:
20: export interface ServerRuntimeDependencies {
21: resolveGateway?: () => Promise<{
22: gatewayBase: string;
23: gatewayHeaders: Record<string, string>;
24: shutdown?: () => Promise<void>;
25: }>;
26: gitRemote?: (path: string) => string | null;
27: }
28:
29: interface GatewayHandle {
30: port: number;
31: owned: boolean;
32: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/package.test.ts</path>
<type>file</type>
<content>
1: import { execFileSync } from "node:child_process";
2: import { mkdtempSync, readFileSync, rmSync } from "node:fs";
3: import { tmpdir } from "node:os";
4: import { join } from "node:path";
5: import { afterAll, beforeAll, describe, expect, test } from "vitest";
6:
7: const packageDir = join(import.meta.dirname, "..");
8: const temporary = mkdtempSync(join(tmpdir(), "lore-opencode-package-"));
9: const packageName = "loreai-opencode.tgz";
10:
11: beforeAll(() => {
12: execFileSync("pnpm", ["run", "build"], {
13: cwd: packageDir,
14: stdio: "pipe",
15: });
16: execFileSync("pnpm", ["pack", "--out", join(temporary, packageName)], {
17: cwd: packageDir,
18: stdio: "pipe",
19: });
20: execFileSync("tar", ["-xzf", join(temporary, packageName), "-C", temporary], {
21: stdio: "pipe",
22: });
23: });
24:
25: afterAll(() => {
26: ...
<path>/home/byk/Code/opencode-lore-v2/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: "./server": {
16: "types": "./src/server.ts",
17: "bun": "./dist/server.js",
18: "default": "./dist/server.js"
19: }
20: },
21: "scripts": {
22: "typecheck": "tsc --noEmit",
23: "build": "tsx script/build.ts"
24: },
25: "peerDependencies": {
26: "@opencode-ai/plugin": ">=1.1.0",
27: "@opencode/plugin": ">=0.0.0"
28: },
29: "peerDependenciesMeta": {
30: "@opencode/plugin": {
31: ...
<skill_content name="jj-guide"> # Skill: jj-guide # jj Guide for AI Agents Jujutsu (jj) is a Git-compatible VCS with mutable commits, automatic snapshotting, no staging area, and first-class conflicts. This skill teaches you how to use it safely from a non-interactive agent environment. If `.jj/` exists in the repo root, this is a jj repo. **Use `jj` commands, not `git`.** In a colocated repo (`.jj/` *and* `.git/`), git tools can read the state, but mutations should go through `jj` so the operation log stays consistent. ## Critical Rules - **NEVER** use interactive flags (`-i`, `--interactive`). TUI prompts hang in agent environments. This applies to `jj split -i`, `jj squash -i`, `jj commit -i`, `jj resolve`, `jj diffedit`, etc. - **ALWAYS** pass `-m "msg"` when describing/committing. Without `-m`, an editor opens and hangs. - **VERIFY** mutations with `jj st` and `jj log` after `squash`, `abandon`, `rebase`, `restore`, `commit`. ...
packages/core/src/fetch-interceptor.ts | 250 +-- packages/core/src/index.ts | 3 + ...ges/core/test/fetch-interceptor-request.test.ts | 163 ++ packages/opencode/package.json | 17 +- packages/opencode/script/build.ts | 25 + packages/opencode/src/index.ts | 22 +- packages/opencode/src/internal.ts | 13 + packages/opencode/src/server-core.ts | 4 + packages/opencode/src/server-runtime.ts | 222 ++ packages/opencode/src/server.ts | 79 + packages/opencode/test/internal.test.ts | 10 + packages/opencode/test/package.test.ts | 62 + packages/opencode/test/server-runtime.test.ts | 159 + packages/opencode/test/server.test.ts | 316 +++ pnpm-lock.yaml | 1755 +++++++++++++++++++++- 15 files changed, 2904 insertions(+), 196 deletions(-) Working copy ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts</path>
<type>file</type>
<content>
225: evt.model.update(item.provider.id, Model.ID.make("gpt-5-chat-latest"), (model) => {
226: // This chat-only alias conflicts with the Copilot GPT-5 Responses route,
227: // so hide it only for Copilot rather than for every provider catalog.
228: model.enabled = false
229: })
230: }
231: })
232: const refresh = () => loading.withPermit(load().pipe(Effect.andThen(ctx.catalog.reload())))
233: yield* bus.subscribe(Credential.Event.Switched).pipe(
234: Stream.filter((event) => event.data.integrationID === Integration.ID.make("github-copilot")),
235: Stream.runForEach(refresh),
236: Effect.forkScoped({ startImmediately: true }),
237: )
238: yield* refresh().pipe(Effect.forkScoped)
239: yield* ctx.aisdk.hook(
240: "sdk",
241: Effect.fn(function* (evt) {
242: ...
No files found
Found 19 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts:
Line 16: "x-lore-session-id": "ses_1",
Line 53: const callbacks = new Map<string, (event: never) => Promise<void> | void>();
Line 100: callback: (event: never) => Promise<void> | void,
Line 161: expect(state.callbacks.has("model.request")).toBe(true);
Line 166: sessionID: "ses_1",
Line 172: await state.callbacks.get("model.request")?.(
Line 176: sessionID: "ses_1",
Line 180: sessionID: "ses_1",
Line 188: "x-lore-session-id": "ses_1",
Line 234: const event = {
Line 235: sessionID: "ses_1",
Line 241: await state.callbacks.get("model.request")?.(event as unknown as never);
Line 246: expect(event.headers).toMatchObject({ "x-lore-session-id": "ses_1" });
Line 286: await ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts</path>
<type>file</type>
<content>
140: mode: "subagent",
141: hidden: true,
142: },
143: ],
144: [
145: "lore-curator",
146: {
147: description: "Lore knowledge curator worker",
148: mode: "subagent",
149: hidden: true,
150: },
151: ],
152: [
153: "lore-query-expand",
154: {
155: description: "Lore query expansion worker",
156: mode: "subagent",
157: hidden: true,
158: },
159: ],
160: ]);
161: expect(state.callbacks.has("model.request")).toBe(true);
162: expect(state.callbacks.has("http.request")).toBe(true);
163: expect(acquireServerRuntime).toHaveBeenCalledWith("/workspace/project");
164:
165: const modelEvent = {
166: sessionID: "ses_1",
167: agent: "build",
168: model: { providerID: "openai" },
169: ...
Found 5 matches /home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts: Line 23: readonly agent: Agent.ID Line 41: readonly agent: Agent.ID Line 50: readonly agent: Agent.ID Line 58: readonly agent: Agent.ID Line 69: readonly agent: Agent.ID
<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-lore-v2/packages/gateway/test/bedrock-runtime.test.ts:
Line 4: * Unit tests cover the path matcher and region URL builder; the e2e test
Line 40: test("builds the regional bedrock-runtime origin (no trailing slash)", () => {
Line 624: // URL builder + forwarder so the regression cannot re-ship silently.
Line 708: // with no URL-encoding of the colon — verify the builder + forwarder
/home/byk/Code/opencode-lore-v2/packages/gateway/test/cli-bundle-smoke.test.ts:
Line 4: * Spawns the actual `dist/bin.cjs` produced by esbuild and asserts that
Line 109: "`lore version` through the bundle returns the build version",
Line 113: // The version is a semver string from build-injected VERSION.
Line 166: // and the buildOutputCommand wrapper renders the human format with
/home/byk/Code/opencode-lore-v2/packages/gateway/test/cli-auth-contract.test.ts:
Line 100: const { ...
/home/byk/Code/opencode-lore-v2/packages/gateway/test/keepalive-compaction.test.ts /home/byk/Code/opencode-lore-v2/packages/gateway/test/cost-tracker-per-model-compaction.test.ts /home/byk/Code/opencode-lore-v2/packages/gateway/test/compaction.test.ts
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-v2/packages/gateway/test/xxhash.test.ts:
Line 55: expect(result).toBe(xxHash64(new TextEncoder().encode("a")));
Line 147: const bytes = new TextEncoder().encode(str);
Line 156: const full = new TextEncoder().encode("XXXhello");
/home/byk/Code/opencode-lore-v2/packages/gateway/test/worker-recovery.test.ts:
Line 139: controller.enqueue(new TextEncoder().encode('{"content":'));
/home/byk/Code/opencode-lore-v2/packages/gateway/test/api.test.ts:
Line 104: title: "Test Decision",
Line 150: const entries = await apiJSON<Array<{ id: string; title: string }>>(
Line 154: expect(entries[0].title).toBe("Test Decision");
Line 188: const entry = await apiJSON<{ id: string; title: string; content: string }>(
Line 192: expect(entry.title).toBe("Test Decision");
Line 513: { title: "Struct import A", content: "body a", category: "pattern" },
...
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/test/compaction.test.ts</path>
<type>file</type>
<content>
375: const req = makeRequest({
376: system: "A".repeat(499),
377: tools: [],
378: messages: [userMsg("Hello")],
379: });
380: expect(isMetaRequest(req)).toBe(true);
381: });
382:
383: // -- Layer 1: x-lore-agent header -----------------------------------------
384:
385: test("x-lore-agent: known meta agent → true regardless of structure", () => {
386: const req = makeRequest({
387: system: "A".repeat(2000), // would fail structural heuristics
388: tools: [
389: { name: "bash", description: "Run shell", inputSchema: {} },
390: { name: "read", description: "Read files", inputSchema: {} },
391: { name: "write", description: "Write files", inputSchema: {} },
392: ],
393: messages: [userMsg("Turn 1"), assistantMsg("Turn 2"), userMsg("Turn 3")],
394: rawHeaders: { [LORE_AGENT_HEADER]: ...
Found 29 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts:
Line 17: "x-lore-agent": "build",
/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts:
Line 148: "x-lore-agent": "build",
/home/byk/Code/opencode-lore-v2/packages/opencode/test/subagent-detection.test.ts:
Line 5: * spawning session. The plugin's `chat.headers` hook resolves that parent via
Line 62: type ChatHeadersHook = NonNullable<Hooks["chat.headers"]>;
Line 80: await hooks["chat.headers"]?.(chatInput(sessionID), output);
/home/byk/Code/opencode-lore-v2/packages/opencode/test/session-state.test.ts:
Line 9: * - The `chat.headers` hook injects the right headers per request
Line 39: * working directory. The plugin's `chat.headers` hook is the system
Line 61: * Build a minimal `chat.headers` input — matches the shape OpenCode
Line 65: type ChatHeadersHook = NonNullable<Hooks["chat.headers"]>;
Line 111: test("single ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/session-state.test.ts</path>
<type>file</type>
<content>
105: // best-effort cleanup
106: }
107: }
108: tmpDirs = [];
109: });
110:
111: test("single project: chat.headers injects x-lore-project for that project", async () => {
112: const dirA = makeTmp("a");
113: const hooks = await initPluginForProject("project-a", dirA);
114:
115: const { input, output } = buildChatHeadersInput("session-1", "coder");
116: await hooks["chat.headers"]?.(input, output);
117:
118: expect(output.headers["x-lore-session-id"]).toBe("session-1");
119: expect(output.headers["x-lore-agent"]).toBe("coder");
120: expect(output.headers["x-lore-project"]).toBe(dirA);
121: });
122:
123: test("two projects: each chat.headers call injects ITS project's path", async () => {
124: const dirA = makeTmp("a");
125: const dirB = makeTmp("b");
126: const hooksA = await ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/agent.ts</path>
<type>file</type>
<content>
130: )
131: })
132:
133: editor.update(Agent.ID.make("compaction"), (item) => {
134: item.name = Agent.Name.make("Compaction")
135: item.mode = "primary"
136: item.hidden = true
137: })
138:
139: editor.update(Agent.ID.make("title"), (item) => {
140: item.name = Agent.Name.make("Title")
141: item.mode = "primary"
142: item.hidden = true
143: item.system = PROMPT_TITLE
144: item.permissions.push({ action: "*", resource: "*", effect: "deny" })
145: })
146:
147: editor.update(Agent.ID.make("summary"), (item) => {
148: item.name = Agent.Name.make("Summary")
149: item.mode = "primary"
150: item.hidden = true
151: item.system = PROMPT_SUMMARY
152: item.permissions.push({ action: "*", resource: "*", effect: "deny" })
153: })
154: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
375: // Inject per-request identifiers so the gateway can distinguish meta
376: // requests (title generation, summary agents, etc.) from real
377: // conversation turns and route by provider.
378: // Project path, git remote, and upstream URL are injected by the
379: // fetch interceptor (installed once per process).
380: "chat.headers": async (input, output) => {
381: Object.assign(
382: output.headers,
383: gatewayAccessHeadersForRemote(gatewayBase),
384: );
385: // Inject stable session ID — OpenCode's DB session ID survives restarts,
386: // unlike x-session-affinity (nanoid regenerated per process).
387: output.headers["x-lore-session-id"] = input.sessionID;
388: output.headers["x-lore-agent"] = input.agent;
389: // Flag OpenCode Task sub-agents so the gateway sizes ...
Found 9 matches
/home/byk/Code/opencode-lore-v2/packages/core/src/git.ts:
Line 77: const gitRemoteCache = new Map<string, string | null>();
Line 86: gitRemoteCache.clear();
Line 101: export function getGitRemote(path: string): string | null {
Line 105: const cached = gitRemoteCache.get(path);
Line 129: gitRemoteCache.set(path, null);
Line 146: gitRemoteCache.set(path, null);
Line 151: gitRemoteCache.set(path, result);
Line 155: gitRemoteCache.set(path, null);
Line 164: /** Cached git user identity (process-lifetime, like gitRemoteCache). */
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/git.ts</path>
<type>file</type>
<content>
90: * Get the canonical git remote URL for a repository at the given path.
91: *
92: * Prefers `origin` (the canonical clone source) over `upstream`, then falls
93: * back to any other remote. Origin-first is deliberate: unrelated repos
94: * bootstrapped from a common template share an `upstream` but keep distinct
95: * `origin`s, so keying on the shared upstream would falsely merge them into one
96: * project. Returns null if the path is not in a git repo or has no remotes.
97: *
98: * Results are cached in-memory for the process lifetime to avoid repeated
99: * subprocess calls — `git remote -v` only runs once per unique path.
100: */
101: export function getGitRemote(path: string): string | null {
102: // In hosted mode, never run git subprocesses with client-controlled cwd.
103: if (isHostedMode()) return null;
104:
105: const cached = gitRemoteCache.get(path);
106: ...
Found 1 matches /home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts: Line 205: "x-lore-git-remote": input.runtime.gitRemote,
Found 7 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts:
Line 87: quiet?: boolean;
Line 885: // In-process callers (OpenCode plugin, Pi extension) pass `quiet: true`.
Line 889: // suppressed) when quiet; otherwise keep the visible `console.error` notices
Line 891: const quiet = opts.quiet === true;
Line 893: if (quiet) log.warn(msg);
Line 1322: if (!opts.quiet) {
Line 1336: if (!opts.quiet) {
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts</path>
<type>file</type>
<content>
875: }
876:
877: async function startGatewayLocked(
878: opts: StartOptions,
879: ioOverrides: Partial<StartGatewayIO>,
880: lifecycleLock: LifecycleLock,
881: ): Promise<GatewayHandle> {
882: const io: StartGatewayIO = { ...realStartGatewayIO, ...ioOverrides };
883: const config = loadConfig();
884:
885: // In-process callers (OpenCode plugin, Pi extension) pass `quiet: true`.
886: // They run inside the host agent's full-screen TUI, where ANY stdout/stderr
887: // write corrupts the rendered screen. Route the gateway's own startup/
888: // shutdown notices through the core `log` module (file-based, terminal-
889: // suppressed) when quiet; otherwise keep the visible `console.error` notices
890: // for the `lore start` CLI.
891: const quiet = opts.quiet === true;
892: const notify = (msg: string): void => {
893: if (quiet) log.warn(msg);
894: ...
No files found
Found 2 matches /home/byk/Code/opencode-lore-v2/packages/opencode/src/internal.ts: Line 175: * `log.silenceStderr()` at plugin activation), so `log.error` alone lands only /home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts: Line 259: if (!inTestEnv) log.silenceStderr();
Found 2 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts:
Line 128: log.info("No Lore gateway found, starting in-process…");
Line 149: log.info(
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts</path>
<type>file</type>
<content>
270: /**
271: * Set of `${host}${pathname}` strings we've already warned about (avoids
272: * log spam on every request to a non-intercepted LLM endpoint).
273: */
274: const warnedPaths = new Set<string>();
275:
276: /**
277: * Determine whether a fetch request should be intercepted and rerouted
278: * through the Lore gateway.
279: *
280: * Only intercepts requests to known LLM API paths on remote hosts.
281: * Never intercepts:
282: * - Requests already going to the gateway
283: * - Local requests (localhost, 127.0.0.1, etc.) — these may be local LLM
284: * servers or the gateway itself (infinite loop risk)
285: * - Non-LLM API paths (arbitrary HTTP calls from plugins, health checks, etc.)
286: */
287: export function shouldIntercept(url: string, gatewayBase: string): boolean {
288: try {
289: const parsed = new URL(url);
290: // Never intercept ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/test/fetch-interceptor-request.test.ts</path>
<type>file</type>
<content>
1: import { describe, expect, test, vi } from "vitest";
2: import { rewriteRequest } from "../src/fetch-interceptor";
3:
4: const GATEWAY = "https://gateway.example.com";
5: const dynamicHeaders = {
6: "x-lore-project": "/home/me/project",
7: "x-lore-session-id": "session-123",
8: };
9:
10: describe("rewriteRequest", () => {
11: test("routes a V2-style Request without losing method, body, auth, path, or query", async () => {
12: const body = JSON.stringify({
13: model: "gpt-5",
14: messages: [{ role: "user", content: "Hello" }],
15: });
16: const observed = vi.fn();
17: const request = new Request(
18: "https://openrouter.ai/api/v1/chat/completions?stream=true&trace=abc",
19: {
20: method: "POST",
21: headers: {
22: authorization: "Bearer sk-test",
23: "content-type": ...
M packages/core/src/fetch-interceptor.ts M packages/core/src/index.ts A packages/core/test/fetch-interceptor-request.test.ts M packages/opencode/package.json A packages/opencode/script/build.ts M packages/opencode/src/index.ts M packages/opencode/src/internal.ts A packages/opencode/src/server-core.ts A packages/opencode/src/server-runtime.ts A packages/opencode/src/server.ts M packages/opencode/test/internal.test.ts A packages/opencode/test/package.test.ts A packages/opencode/test/server-runtime.test.ts A packages/opencode/test/server.test.ts M pnpm-lock.yaml packages/core/src/fetch-interceptor.ts | 250 +-- packages/core/src/index.ts | 3 + ...ges/core/test/fetch-interceptor-request.test.ts | 163 ++ packages/opencode/package.json | 17 +- packages/opencode/script/build.ts | 25 + packages/opencode/src/index.ts | 22 +- packages/opencode/src/internal.ts | 13 ...
true https://gateway.example.com.evil /v1/messages true https://gateway.example.com:444 /v1/messages true https://gateway.example.com /v11/messages
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, describe, expect, test, vi } from "vitest";
2: import {
3: acquireServerRuntime,
4: buildServerHeaders,
5: resetServerRuntimeForTest,
6: } from "../src/server-runtime";
7:
8: const savedEnv = { ...process.env };
9:
10: afterEach(async () => {
11: await resetServerRuntimeForTest();
12: process.env = { ...savedEnv };
13: });
14:
15: describe("V2 server runtime", () => {
16: test.each(["1", "true"])(
17: "stays inactive when LORE_DISABLED=%s",
18: async (value) => {
19: process.env.LORE_DISABLED = value;
20:
21: expect(
22: await acquireServerRuntime("/project", {
23: resolveGateway: vi.fn(),
24: gitRemote: vi.fn(),
25: }),
26: ).toBeUndefined();
27: },
28: );
29:
30: test("shares an owned gateway until every location releases it", async () => {
31: ...
Found 2 matches /home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/types.ts: Line 800: "x-lore-git-remote", /home/byk/Code/opencode-lore-v2/packages/gateway/src/config.ts: Line 1293: const raw = headers["x-lore-git-remote"];
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/config.ts</path>
<type>file</type>
<content>
1280:
1281: /** Maximum allowed length for a git remote header value. */
1282: const MAX_GIT_REMOTE_LENGTH = 512;
1283:
1284: /**
1285: * Extract and validate the `X-Lore-Git-Remote` header from a request.
1286: * Normalizes SSH/HTTPS/git:// variants to a canonical form and strips
1287: * any control characters (prevents header injection via crafted remote URLs).
1288: * Returns `undefined` when the header is absent or invalid.
1289: */
1290: export function extractGitRemoteHeader(
1291: headers: Record<string, string>,
1292: ): string | undefined {
1293: const raw = headers["x-lore-git-remote"];
1294: if (!raw) return undefined;
1295:
1296: // Strip control characters (newlines, carriage returns, null bytes) to
1297: // prevent header injection and DB corruption. ...
No files found
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
445: output.headers[name] = value;
446: }
447: }
448: },
449: };
450:
451: // Startup banner. Routed through `log` (file + sink, stderr only when not
452: // silenced) — NEVER a raw stderr write: OpenCode owns a full-screen TUI and
453: // any stray byte corrupts it. Visible via `lore logs`.
454: if (!processInitDone) {
455: const projectPath = discoverWorkspaceRoot(ctx.worktree || ctx.directory);
456: log.info(`active: ${projectPath}`);
457:
458: if (loreActive) {
459: // Install the fetch interceptor once per process. It transparently
460: // reroutes outgoing LLM API calls through the gateway while
461: // preserving original auth headers and URLs. ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2:
3: const { release, acquireServerRuntime, buildServerHeaders, rewriteRequest } =
4: vi.hoisted(() => {
5: const release = vi.fn(async () => {});
6: return {
7: release,
8: acquireServerRuntime: vi.fn(async () => ({
9: gatewayBase: "http://127.0.0.1:3207",
10: projectPath: "/workspace/project",
11: gitRemote: "github.com/example/project",
12: gatewayHeaders: {},
13: release,
14: })),
15: buildServerHeaders: vi.fn(() => ({
16: "x-lore-session-id": "ses_1",
17: "x-lore-agent": "build",
18: "x-lore-provider": "openai",
19: "x-lore-upstream-url": "https://api.openai.com",
20: })),
21: rewriteRequest: vi.fn(
22: async (request: Request) =>
23: new ...
Found 35 matches
/home/byk/Code/opencode-v2-pilot/packages/core/test/tool-registry.test.ts:
Line 1081: it.effect("executes the tool advertised in a model request", () =>
Line 1108: it.effect("executes and reports progress for codemode tools advertised in a model request", () =>
/home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-openai.test.ts:
Line 20: import { SessionModelRequest } from "@opencode/core/session/model-request"
Line 47: const event = yield* hooks.trigger("session", "model.request", {
Line 59: (yield* hooks.has("session", "http.request", 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 226: it.effect("ignores other providers' model requests", () =>
Line 230: const event = yield* ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts</path>
<type>file</type>
<content>
35: })
36: const transport = SessionModelTransport.Service.of({
37: bind: () => ({ execute: () => Effect.die("unused WebSocket execution") }),
38: close: () => Effect.void,
39: closeAll: Effect.void,
40: })
41:
42: describe("SessionModelRequest HTTP hooks", () => {
43: it.effect("tags every Session request kind on http.request and http.response", () =>
44: Effect.gen(function* () {
45: const hooks = yield* PluginHooks.Service
46: const seen: Array<{ hook: string; kind: SessionRequestKind; agent: Agent.ID }> = []
47: yield* hooks.register("session", "http.request", (event) =>
48: Effect.sync(() => {
49: seen.push({ hook: "request", kind: event.kind, agent: event.agent })
50: }),
51: )
52: yield* hooks.register("session", "http.response", (event) =>
53: Effect.sync(() => {
54: ...
Found 5 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts:
Line 67: kind: "title",
Line 68: scope: { session: input.session, agentID: input.agent.id, model: input.model },
Line 128: const selection = yield* context.selectTitle(session)
Line 131: (yield* attempt({ session, agent: selection.agent, text, model: selection.selected })) ??
Line 133: ? yield* attempt({ session, agent: selection.agent, text, model: selection.primary })
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/title.ts</path>
<type>file</type>
<content>
55: let failed = false
56: let usage: SessionUsage.Recorded | undefined
57: const recordUsage = Effect.suspend(() =>
58: usage
59: ? bus.publish(SessionEvent.UsageRecorded, {
60: sessionID: input.session.id,
61: source: "title",
62: ...usage,
63: })
64: : Effect.void,
65: )
66: const prepared = yield* context.prepare({
67: kind: "title",
68: scope: { session: input.session, agentID: input.agent.id, model: input.model },
69: transcript: {
70: system: input.agent.system ? [SystemPart.make(input.agent.system)] : [],
71: messages: [Message.user(input.text)],
72: },
73: contextHooks: false,
74: })
75: yield* llm.stream(prepared.request, prepared.options).pipe(
76: Stream.runForEach((event) => ...
Found 4 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/context.ts:
Line 60: readonly selectTitle: (session: SessionSchema.Info) => Effect.Effect<
Line 95: const selectTitle = Effect.fn("SessionContext.selectTitle")(function* (session: SessionSchema.Info) {
Line 96: const agent = yield* agents.get(Agent.ID.make("title"))
Line 176: return Service.of({ select, load, resolveModel, selectTitle, prepare: modelRequests.prepare })
Found 4 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/generate.ts:
Line 1: export * as SessionGenerate from "./generate.js"
Line 20: export const generate = Effect.fn("SessionGenerate.generate")(function* (input: {
Line 47: kind: "generate",
Line 48: scope: { session: selection.session, agentID: selection.agent.id, model, tools: selection.tools },
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/generate.ts</path>
<type>file</type>
<content>
38: )
39: const transcript = SessionModelRequest.baseTranscript({
40: agent: selection.agent.info,
41: model,
42: tools: selection.tools,
43: initial: history.initial,
44: messages: history.messages,
45: })
46: const prepared = yield* context.prepare({
47: kind: "generate",
48: scope: { session: selection.session, agentID: selection.agent.id, model, tools: selection.tools },
49: transcript: {
50: system: transcript.system,
51: messages: [
52: ...transcript.messages,
53: ...(history.instructionUpdate ? [Message.system(history.instructionUpdate)] : []),
54: Message.user(input.prompt),
55: ],
56: },
57: })
(Showing lines 38-57 of 67. Use offset=58 to continue.)
</content>
Found 2 matches
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/compaction.ts:
Line 429: kind: "compaction",
Line 432: agentID: Agent.ID.make("compaction"),
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/session/compaction.ts</path>
<type>file</type>
<content>
422: agent: context.agent.info,
423: model: context.model,
424: tools: context.tools,
425: initial: context.initial,
426: messages,
427: })
428: return input.prepare({
429: kind: "compaction",
430: scope: {
431: session: context.session,
432: agentID: Agent.ID.make("compaction"),
433: contextAgentID: context.agent.id,
434: model: context.model,
435: tools: context.tools,
436: },
437: transcript: {
438: system: transcript.system,
439: messages: [
440: ...transcript.messages,
441: ...(input.instructionUpdate ? [Message.system(input.instructionUpdate)] : []),
(Showing lines 422-441 of 756. Use offset=442 to continue.)
</content>
Found 10 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts:
Line 200: for (const [k, v] of Object.entries(req.rawHeaders)) {
Line 283: // isCompactionRequest — pattern-based detection (fallback)
Line 304: * Used by the pipeline for logging; `isCompactionRequest` is the boolean wrapper.
Line 346: export function isCompactionRequest(req: GatewayRequest): boolean {
Line 374: export const LORE_AGENT_HEADER = "x-lore-agent";
Line 378: * When `x-lore-agent` matches, the request is always a normal turn.
Line 384: * When `x-lore-agent` matches, the request is always passthrough.
Line 434: * 1. Explicit `x-lore-agent` header (OpenCode plugin) — authoritative signal.
Line 443: if (isCompactionRequest(req)) return false;
Line 446: const agentHeader = req.rawHeaders[LORE_AGENT_HEADER];
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts</path>
<type>file</type>
<content>
275: priorState?: { messageCount: number },
276: ): boolean {
277: if (!priorState || priorState.messageCount <= 10) return false;
278: const currCount = req.messages.length;
279: return currCount <= 3 && currCount < priorState.messageCount * 0.5;
280: }
281:
282: // ---------------------------------------------------------------------------
283: // isCompactionRequest — pattern-based detection (fallback)
284: // ---------------------------------------------------------------------------
285:
286: /**
287: * Returns `true` if the request looks like a compaction request.
288: *
289: * Checks in order:
290: * 1. System prompt contains any `COMPACTION_SYSTEM_PATTERNS` → true
291: * 2. Tools empty AND last user message contains any `COMPACTION_USER_PATTERNS` → true
292: * 3. Last user message has `<template>` tag AND ≥4 template sections → true
293: * 4. ...
Found 2 matches
/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts:
Line 19364: if (isMetaRequest(req)) {
/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts:
Line 441: export function isMetaRequest(req: GatewayRequest): boolean {
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
19335: const isClaudeSubagent = isClaudeCodeSubagent(req.rawHeaders);
19336: const structuralCompaction =
19337: !isClaudeSubagent && isStructuralCompaction(req, priorState);
19338: const patternDetection = structuralCompaction
19339: ? undefined
19340: : detectCompactionRequest(req);
19341: if (structuralCompaction || patternDetection?.detected) {
19342: const reason = structuralCompaction
19343: ? `structural (prior=${priorState?.messageCount ?? "?"} curr=${req.messages.length})`
19344: : patternDetection?.detected
19345: ? patternDetection.reason === "system-prompt"
19346: ? `pattern: system-prompt match "${patternDetection.pattern}"`
19347: : patternDetection.reason === "user-keywords"
19348: ? `pattern: user-keyword match "${patternDetection.pattern}"`
19349: ...
Found 5 matches /home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts: Line 13389: return await handlePassthrough( Line 14876: async function handlePassthrough( Line 17275: // Meta request passthrough (handlePassthrough) never reaches here — it Line 19317: return await handlePassthrough(req, config); Line 19369: return await handlePassthrough(req, config);
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
14870: status: response.status,
14871: statusText: response.statusText,
14872: headers: response.headers,
14873: });
14874: }
14875:
14876: async function handlePassthrough(
14877: req: GatewayRequest,
14878: config: GatewayConfig,
14879: ): Promise<Response> {
14880: setSentryLightContext({ model: req.model });
14881:
14882: const abortScope = createForegroundAbortScope(req.signal);
14883: let forwarded: UpstreamResult;
14884: try {
14885: forwarded = await forwardToUpstream(
14886: req,
14887: config,
14888: undefined,
14889: undefined,
14890: abortScope.signal,
14891: );
14892: } catch (error) {
14893: abortScope.dispose();
14894: throw error;
14895: }
14896: const effectiveProtocol = forwarded.effectiveProtocol;
14897: const upstreamResponse = wrapBodyWithCleanup(
14898: ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts</path>
<type>file</type>
<content>
1: import { rewriteRequest } from "@loreai/core";
2: import type { Plugin } from "@opencode/plugin";
3: import { acquireServerRuntime, buildServerHeaders } from "./server-runtime";
4:
5: const workers = [
6: ["lore-distill", "Lore memory distillation worker"],
7: ["lore-curator", "Lore knowledge curator worker"],
8: ["lore-query-expand", "Lore query expansion worker"],
9: ] as const;
10:
11: export default {
12: id: "lore",
13: setup: async (ctx) => {
14: const runtime = await acquireServerRuntime(ctx.location.project.directory);
15: if (!runtime) return;
16:
17: const registrations: Array<{ dispose: () => Promise<void> }> = [];
18: try {
19: registrations.push(
20: await ctx.agent.transform((editor) => {
21: for (const [id, description] of workers) {
22: editor.update(id, (agent) => {
23: ...
Found 3 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts:
Line 20: alias: {
Line 21: "@loreai/core": join(packageDir, "src/server-core.ts"),
Line 23: external: ["@opencode/plugin", "@loreai/gateway"],
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/script/build.ts</path>
<type>file</type>
<content>
1: import * as esbuild from "esbuild";
2: import { mkdirSync, rmSync } from "node:fs";
3: import { dirname, join } from "node:path";
4: import { fileURLToPath } from "node:url";
5:
6: const packageDir = dirname(dirname(fileURLToPath(import.meta.url)));
7: const dist = join(packageDir, "dist");
8:
9: rmSync(dist, { recursive: true, force: true });
10: mkdirSync(dist, { recursive: true });
11:
12: await esbuild.build({
13: entryPoints: [join(packageDir, "src/server.ts")],
14: outfile: join(dist, "server.js"),
15: bundle: true,
16: format: "esm",
17: platform: "node",
18: target: "esnext",
19: sourcemap: true,
20: alias: {
21: "@loreai/core": join(packageDir, "src/server-core.ts"),
22: },
23: external: ["@opencode/plugin", "@loreai/gateway"],
24: logLevel: "info",
25: });
(End of file - total 25 lines)
</content>
Found 15 matches /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/vcs/hg.ts: Line 34: directory: location.directory, Line 35: worktree: location.project.directory, /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/vcs/git.ts: Line 29: directory: location.directory, Line 30: worktree: location.project.directory, /home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/host.ts: Line 76: directory: location.directory, Line 78: project: location.project, Line 84: directory: AbsolutePath.make(input.location.directory ?? location.directory), Line 89: ref.directory === location.directory && ref.workspaceID === location.workspaceID Line 117: directory: location.directory, Line 119: project: location.project, Line 363: directory: location.directory, Line 365: project: location.project, Line 514: input?.location ?? ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/host.ts</path>
<type>file</type>
<content>
60: const location = yield* Location.Service
61: const reference = yield* Reference.Service
62: const rpc = yield* Rpc.Service
63: const skill = yield* Skill.Service
64: const tools = yield* Tool.Service
65: const vcs = yield* Vcs.Service
66: const websearch = yield* WebSearch.Service
67: const generate = yield* Generate.Service
68: const permission = yield* Permission.Service
69: const hooks = yield* PluginHooks.Service
70: const sessions = yield* Session.Service
71: const persistentPty = yield* PersistentPty.Service
72: const locations = yield* LocationServiceMap.Service
73: const worktrees = yield* Worktree.Service
74: const locationInfo = () =>
75: new Location.Info({
76: directory: location.directory,
77: workspaceID: location.workspaceID,
78: project: location.project,
79: })
80: const locationRef = (input?: { ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/internal.ts</path>
<type>file</type>
<content>
15: */
16:
17: import type { PluginInput } from "@opencode-ai/plugin";
18: import { GATEWAY_AUTH_HEADER, log } from "@loreai/core";
19: import * as http from "node:http";
20: import * as https from "node:https";
21:
22: function isLoopbackUrl(value: string): boolean {
23: try {
24: const hostname = new URL(value).hostname
25: .replace(/^\[/, "")
26: .replace(/\]$/, "")
27: .toLowerCase();
28: return (
29: hostname === "localhost" ||
30: hostname === "localhost." ||
31: hostname === "::1" ||
32: /^127(?:\.\d{1,3}){3}$/.test(hostname)
33: );
34: } catch {
35: return false;
36: }
37: }
38:
39: /** Access headers are injected only for the URL selected by LORE_REMOTE_URL. */
40: export function gatewayAccessHeadersForRemote(
41: gatewayBase: string,
42: env: NodeJS.ProcessEnv = process.env,
43: ): Record<string, ...
Found 24 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:
Line 121: let processInitDone = false;
Line 122: let processLoreActive = false;
Line 123: let processLoreBase = "";
Line 132: // `currentProject` is a fallback for the fetch interceptor's `getHeaders()`
Line 143: let currentProject: { path: string; gitRemote: string } | undefined;
Line 146: const projectState = new Map<
Line 163: for (const [id, entry] of projectState) {
Line 164: if (entry.lastSeenAt < cutoff) projectState.delete(id);
Line 170: * lifetime (reaped by the same TTL as projectState) to avoid an SDK round-trip
Line 221: let loreInitPromise: Promise<string | null> | null = null;
Line 247: let loreActive = processLoreActive;
Line 248: let gatewayBase = processLoreBase;
Line 249: if (!processInitDone) {
Line 263: if (!loreInitPromise) {
Line 264: loreInitPromise = (async () => {
Line 281: const result = await ...
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path> <type>file</type> <content> 112: 113: // Captures the underlying reason the in-process gateway failed to start so 114: // the user-facing error can include the real cause (port conflict, DB lock, 115: // stale build, etc.) instead of just "Ensure @loreai/gateway is installed." 116: let lastGatewayStartError: string | null = null; 117: 118: // Process-wide initialization state — shared across all sessions. 119: // The plugin function is called once per OpenCode session/project, but 120: // lore init only needs to run once per process. 121: let processInitDone = false; 122: let processLoreActive = false; 123: let processLoreBase = ""; 124: 125: // Per-project state. The OpenCode plugin function can be called multiple 126: // times in the same process (different projects, or after a project switch), 127: // so we track each project's path + git remote in a Map keyed by 128: // `ctx.project.id`. ...
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts</path>
<type>file</type>
<content>
455: if (fd !== undefined) closeSync(fd);
456: }
457: }
458:
459: // ---------------------------------------------------------------------------
460: // Public API
461: // ---------------------------------------------------------------------------
462:
463: /** Log an informational status message. Suppressed unless LORE_DEBUG=1. */
464: export function info(...args: unknown[]): void {
465: const msg = redactSensitiveLogText(formatArgs(args));
466: if (isDebug && !readStderrSilenced())
467: console.error("[lore]", ...safeArgs(args));
468: sink?.info(msg);
469: writeToFile("info", msg);
470: }
471:
472: /** Log a warning. Suppressed unless LORE_DEBUG=1. */
473: export function warn(...args: unknown[]): void {
474: const msg = redactSensitiveLogText(formatArgs(args));
475: if (isDebug && !readStderrSilenced())
476: console.error("[lore] WARN:", ...
Found 3 matches
/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts:
Line 108: // The host enables this switch once, on activation, via `silenceStderr()`.
Line 124: // so one `silenceStderr()` call silences them all.
Line 140: export function silenceStderr(silenced = true): void {
<path>/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts</path>
<type>file</type>
<content>
98: // Embedded / TUI-safe mode
99: // ---------------------------------------------------------------------------
100:
101: // When the gateway runs *in-process* inside a host that owns a full-screen TUI
102: // — the Pi extension and the OpenCode plugin both `import("@loreai/gateway")`
103: // and call `startGateway()` rather than spawning a separate process — ANY byte
104: // written to stdout/stderr corrupts that TUI. This is the exact class of bug
105: // that broke Pi on Windows (raw `console.*` lines bleeding into the render),
106: // and `log.error` is just as fatal there as a stray `console.log`.
107: //
108: // The host enables this switch once, on activation, via `silenceStderr()`.
109: // From then on the logger writes ONLY to the persistent log file and the
110: // registered {@link LogSink} (e.g. ...
Found 1 matches /home/byk/Code/opencode-lore-v2/packages/opencode/src/internal.ts: Line 180: * terminal and cannot corrupt the screen (unlike the `process.stderr.write`
Found 4 matches /home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts: Line 223: GEMINI_PATH_RE.test(pathname) || Line 631: const GEMINI_PATH_RE = Line 940: // GEMINI_PATH_RE) so the Gemini CLI and @ai-sdk/google both match. Line 942: const gm = pathname.match(GEMINI_PATH_RE);
<path>/home/byk/Code/opencode-lore-v2/packages/gateway/src/server.ts</path>
<type>file</type>
<content>
625: * Matches a native Gemini `generateContent` endpoint path, capturing the model
626: * id and the verb. Version-prefix-agnostic (`/v1beta/models/...`,
627: * `/v1/models/...`, or bare `/models/...`) so both the Gemini CLI
628: * (`GOOGLE_GEMINI_BASE_URL` → `/v1beta/...`) and `@ai-sdk/google` (baseURL
629: * pinned to `${gateway}/v1` → `/v1/...`) are matched.
630: */
631: const GEMINI_PATH_RE =
632: /\/models\/([^/:]+):(generateContent|streamGenerateContent)$/;
633:
634: async function handleGeminiGenerateContent(
635: req: Request,
636: config: GatewayConfig,
637: model: string,
638: stream: boolean,
639: ): Promise<Response> {
640: let body: unknown;
641: try {
642: body = JSON.parse(await decodeRequestBody(req));
(Showing lines 625-642 of 1671. Use offset=643 to continue.)
</content>
Found 4 matches
/home/byk/Code/opencode-v2-pilot/packages/ai/src/protocols/gemini.ts:
Line 33: // retaining complete model responses, but OpenCode reconstructs durable history and may encounter an unsigned call
Line 42: // Gemini 3 accepts media nested inside function responses; matched Gemini 2.5 variants reject it,
Line 322: for (const message of request.messages) {
Line 841: endpoint: Endpoint.path(({ request }) => `/models/${request.model.id}:streamGenerateContent?alt=sse`, {
No files found
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/zenmux.ts:
Line 12: if (item.provider.settings?.baseURL !== "https://zenmux.ai/api/v1") continue
/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/vllm.ts:
Line 45: baseURL: source.current.baseURL,
Line 69: const endpoint = `${current.healthEndpoint}\n${current.modelsEndpoint}`
Line 70: const cached = discovery.get(endpoint)
Line 73: discovery.set(endpoint, {
Line 78: const request = (endpoint: string) =>
Line 80: ? HttpClientRequest.get(endpoint).pipe(
Line 84: : HttpClientRequest.get(endpoint).pipe(HttpClientRequest.acceptJson)
Line 92: discovery.set(endpoint, { checked: Date.now(), apiKey: current.apiKey, models })
Line 114: next.baseURL === source.current.baseURL &&
Line 140: const baseURL = (
Line ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-v2-pilot/packages/core/test/database-migration.test.ts:
Line 439: google: { type: "api", key: "google-key", metadata: { region: "us" } },
Line 485: integration_id: "google",
Line 487: value: JSON.stringify({ type: "key", key: "google-key", metadata: { region: "us" } }),
/home/byk/Code/opencode-v2-pilot/packages/core/test/model-resolver.test.ts:
Line 305: const selected = model(Provider.aisdk("@ai-sdk/google"), {
Line 307: canonical: Provider.ID.google,
Line 419: model(Provider.aisdk("@ai-sdk/google"), {
Line 420: settings: { baseURL: "https://google.example.com/v1" },
Line 427: url: "https://google.example.com/v1",
Line 887: ["@opencode/ai/providers/google-vertex", "accessToken"],
Line 888: ["@opencode/ai/providers/google-vertex/gemini", "accessToken"],
Line 889: ...
<path>/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/agent.ts</path>
<type>file</type>
<content>
83: export const Plugin = define({
84: id: "opencode.agent",
85: effect: Effect.fn(function* (ctx) {
86: yield* ctx.agent.transform((editor) => {
87: editor.update(Agent.defaultID, (item) => {
88: item.name = Agent.Name.make("Build")
89: item.description = "The default agent. Executes tools based on configured permissions."
90: item.mode = "primary"
91: item.permissions.push({ action: "question", resource: "*", effect: "allow" })
92: })
93:
94: editor.update(Agent.ID.make("general"), (item) => {
95: item.name = Agent.Name.make("General")
96: item.description =
97: "General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel."
98: item.mode = "subagent"
99: item.permissions.push(
100: ...
Found 3 matches
/home/byk/Code/opencode-v2-pilot/packages/schema/src/location.ts:
Line 11: workspaceID: optional(WorkspaceID),
Line 14: export class Info extends Schema.Class<Info>("Location.Info")({
Line 16: workspaceID: optional(WorkspaceID),
<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 ...
Found 2 matches
/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:
Line 47: if (process.env.LORE_REMOTE_URL) {
Line 48: const url = process.env.LORE_REMOTE_URL.replace(/\/$/, "");
<path>/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts</path>
<type>file</type>
<content>
35:
36: /** Default ports to probe when looking for a running gateway (must match gateway defaults). */
37: const KNOWN_GATEWAY_PORTS = [3207, 5673];
38:
39: /**
40: * Resolve the gateway URL by probing known ports and reading the port file.
41: *
42: * Order: LORE_GATEWAY_URL env var → port file → known default ports (3207, 5673).
43: * Returns the URL of a running gateway, or null if none found.
44: */
45: async function resolveGatewayUrl(): Promise<string | null> {
46: // 0. Remote gateway — skip local discovery/startup entirely.
47: if (process.env.LORE_REMOTE_URL) {
48: const url = process.env.LORE_REMOTE_URL.replace(/\/$/, "");
49: if (await probeGateway(url)) return url;
50: log.info(
51: `remote gateway at ${url} not reachable, falling through to local discovery`,
52: );
53: }
54:
55: // 1. ...
Found 1 matches /home/byk/Code/opencode-lore-v2/packages/core/src/index.ts: Line 208: GATEWAY_AUTH_HEADER,
* 🔴 (18:20) User specified that when `x-lore-agent` matches a primary conversation agent, the request is “always a normal turn.” * 🔴 (18:20) User specified that when `x-lore-agent` matches a meta/housekeeping agent, the request is “always passthrough.” * 🔴 (18:21) `/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts` defines `detectCompactionRequest(req)` with ordered fallback d…
* 🔴 (17:49) `/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/agent.ts` configures built-in agents `compaction`, `title`, and `summary` as `mode: "primary"` and `hidden: true`; `title` uses `PROMPT_TITLE`, `summary` uses `PROMPT_SUMMARY`, and both receive a deny-all permission `{ action: "*", resource: "*", effect: "deny" }`. * 🔴 (17:50) User requires parent-session resolution for Open…
* 🔴 (17:23) The working copy at `/home/byk/Code/opencode-lore-v2` contained 15 changed files totaling 2,904 insertions and 196 deletions: modified `packages/core/src/fetch-interceptor.ts`, `packages/core/src/index.ts`, `packages/opencode/package.json`, `packages/opencode/src/index.ts`, `packages/opencode/src/internal.ts`, and `pnpm-lock.yaml`; added `packages/core/test/fetch-interceptor-request.…
* 🔴 (17:05) User’s `/home/byk/Code/opencode-lore-v2/quality/REVIEW.md` codifies a mandatory regression-test discipline: every adversarial-review defect must receive a deterministic regression test in the same PR that fails on the base branch, passes on the fix, and drives the real precondition; guard tests must fail if the guard is deleted. * 🔴 (17:05) User requires adversarial-order test setup…
* 🔴 (16:47) `/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-core.ts` contains exactly 4 lines: line 1 exports `{ GATEWAY_AUTH_HEADER }` from `"../../core/src/credential-headers"`; line 2 exports `{ rewriteRequest }` from `"../../core/src/fetch-interceptor"`; line 3 exports `{ getGitRemote }` from `"../../core/src/git"`; line 4 exports all of `"../../core/src/log"` as `log`.
* 🔴 (16:42) Search found exactly 4 matches in `/home/byk/Code/opencode-lore-v2/packages/opencode/src/internal.ts`: line 163 — `return (await fetch(url, { signal: controller.signal })).ok;`; line 174 — `* In embedded/TUI mode the core logger's stderr is hard-silenced (see`; line 180 — `* terminal and cannot corrupt the screen (unlike the \`process.stderr.write\``; line 191 — `// File + Sentry sin…
* 🔴 (16:38) `packages/opencode/script/build.ts` imports `esbuild`, `mkdirSync`/`rmSync` from `node:fs`, `dirname`/`join` from `node:path`, and `fileURLToPath` from `node:url`; it derives `packageDir` from `import.meta.url` and sets `dist = join(packageDir, "dist")`. * 🔴 (16:38) The OpenCode build script deletes `dist` with `rmSync(dist, { recursive: true, force: true })`, then recreates it with…
* 🔴 (16:32) Search found 3 matches in `/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts`: line 374 defines `LORE_AGENT_HEADER`, line 441 defines `isMetaRequest(req: GatewayRequest): boolean`, and line 446 reads `req.rawHeaders[LORE_AGENT_HEADER]`. * 🔴 (16:34) In `packages/gateway/src/compaction.ts`, `LORE_AGENT_HEADER` is exactly `"x-lore-agent"`; the OpenCode plugin injects t…
* 🔴 (16:31) `/home/byk/Code/opencode-lore-v2/AGENTS.md` points long-term knowledge managed by lore to project-root `.lore.md`; the pointer section is maintained between lore markers. * 🔴 (16:31) Project review policy is defined in `quality/REVIEW.md`, covering regression-test discipline, adversarial-order state setup, fan-out registry coverage, recurring bug-class batteries, and the two-reviewe…
* 🔴 (16:07) `/home/byk/Code/opencode-lore-v2/packages/opencode/dist/server.js` defines `probeGateway(baseURL, timeoutMs = 1500)` at lines 739-750; it creates an `AbortController`, aborts after `timeoutMs`, probes `${baseURL}/health`, uses `probeLoopback(url, controller.signal)` for loopback URLs, otherwise calls `fetch(url, { signal: controller.signal })`, returns `false` on exceptions, and alwa…
Date: Sep 9, 2026 * 🔴 (16:05) In `/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts`, `processBoundary?: boolean` is documented at lines 104-105 as an internal CLI-owned process boundary that is never set by in-process plugins. * 🔴 (16:05) `GatewayHandle` in `/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts` contains `config: GatewayConfig`, `port: number`, `own…
* 🔴 (16:04) `/home/byk/Code/opencode-lore-v2/packages/gateway/package.json` defines package `@loreai/gateway` version `0.40.0`, `"type": "module"`, license `FSL-1.1-Apache-2.0`, and description `"Lore as a transparent LLM proxy — context management for any AI coding client"`. * 🔴 (16:04) `/home/byk/Code/opencode-lore-v2/packages/gateway/package.json` exports Bun consumers through `"bun": "./dis…
* 🔴 (16:03) `packages/opencode/src/index.ts` catches plugin initialization errors, derives `detail` as `e.stack || e.message` for `Error` instances or `String(e)` otherwise, logs `log.error(\`init failed: ${detail}\`)`, then rethrows the original error; comments explain this preserves the root cause in the file and Sentry sinks, accessible through `lore logs`, even when OpenCode’s plugin loader …
* 🔴 (15:54) Search in `/home/byk/Code/opencode-lore-v2/packages/gateway/src/cli/start.ts` found 4 `shutdown` matches: no-op implementations at lines 984, 1012, and 1270, plus the real shutdown implementation beginning at line 1123. * 🔴 (15:54) Gateway `shutdown()` in `packages/gateway/src/cli/start.ts` is idempotent through cached `shutdownPromise` and executes under `withLifecycleLock("gateway…
* 🔴 (15:51) `packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js` imports `Tool` from `@opencode/schema/tool`; `Effect`, `Schema`, `SchemaAST`, and `Stream` from `effect`; `HttpApiEndpoint` and `HttpApiSchema` from `effect/unstable/httpapi`; and `define` from `../effect/plugin.js`. * 🔴 (15:51) `packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js` defines …
* 🔴 (15:47) `packages/opencode/src/index.ts` imports `log`, `getGitRemote`, `discoverWorkspaceRoot`, and `installFetchInterceptor` from `@loreai/core`, while importing `applyLoreProviderConfig`, `gatewayAccessHeadersForRemote`, `parseUpstreamExtraHeaders`, `probeGateway`, `shouldForwardUpstreamExtraHeader`, and `surfaceGatewayUnavailable` from `./internal`. * 🔴 (15:47) Helpers are kept in `pack…
* 🔴 (15:44) Direct Node.js v24.16.0 execution of `packages/core/src/fetch-interceptor.ts` failed with `ERR_MODULE_NOT_FOUND` because the extensionless import `/home/byk/Code/opencode-lore-v2/packages/core/src/log` could not be resolved. * 🔴 (15:44) An `esbuild@0.28.1` eval intended to probe `rewriteRequest()` failed at `/eval.ts:1:337` because top-level `await` is unsupported with the `"cjs"` o…
* 🔴 (15:40) User supplied the `jj-guide` workflow: if `.jj/` exists, use `jj` rather than `git` for mutations; never use interactive flags; always pass `-m "msg"` when describing/committing; verify mutations with `jj st` and `jj log`; prefer stable letter-based change IDs over hex commit IDs; never rebase or describe immutable commits; use `jj undo`, `jj op log`, or `jj op restore <op-id>` for r…
* 🔴 (15:31) A shell command output `https://gateway.example` and then failed with `/usr/bin/bash: line 1: ${g.origin}${u.pathname}: bad substitution`. * 🔴 (15:33) A search for `gatewayBase` found exactly `11` matches: `/home/byk/Code/opencode-lore-v2/packages/opencode/test/index.test.ts` lines 133 and 210; `/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts` lines 34,…
* 🔴 (15:17) `/home/byk/Code/opencode-lore-v2/packages/gateway/src/translate/bedrock-runtime.ts:117-151` defines `BEDROCK_STRIPPED_HEADERS` as `connection`, `cookie`, `cookie2`, `host`, `keep-alive`, `proxy-authenticate`, `proxy-authorization`, `proxy-connection`, `te`, `trailer`, `transfer-encoding`, and `upgrade`; `bedrockRuntimeHeaders(headers)` additionally removes headers nominated by `Conne…
## 2026-09-09 * 🔴 (15:00) A search found exactly `11` matches across OpenCode session code: `packages/core/src/session/title.ts` uses `source: "title"`, `kind: "title"`, and `scope: { session: input.session, agentID: input.agent.id, model: input.model }`; `packages/core/src/session/model-request.ts` defines `readonly agentID: Agent.ID` and uses `input.scope.contextAgentID ?? input.scope.agentID`…
* 🔴 (14:50) User provided SHA-256 checksums for repository artifacts: `AGENTS.md` → `0db6083724c4f3cff6e0fa4723a0df424edf4951f685ec804822224c868c6160`; `.lore.md` → `9e4f2da707df714528a2960788ad2cca489fd8ba5b8745e7551f912fc07ac58d`; `packages/core/src/fetch-interceptor.ts` → `33dd563b5acf04a3403187b675c4245966053d835c073e5b1f6775eac982416a`; `packages/core/src/index.ts` → `3733b1b2aeda2abd2a29f3…
Date: Sep 9, 2026 * 🔴 (14:46) `/home/byk/Code/opencode-lore-v2/packages/gateway/src/pipeline.ts:6292-6351` rejects a resolved provider whose route has no URL, no `headerUpstream`, and no self-URL-building protocol with `Provider "${providerID}" requires an explicit upstream URL`; `providerRouteUsable` exists only when the route has a URL, an explicit header upstream, or a self-URL-building proto…
* 🔴 (14:44) `/home/byk/Code/opencode-lore-v2/packages/opencode/src/internal.ts:1-14` keeps internal helpers out of plugin entry module `./index.ts` because OpenCode’s legacy `getServerPlugin` / `getLegacyPlugins` loader invokes every exported function as a plugin instance. Exporting `applyLoreProviderConfig` there previously inserted its `undefined` return into the hooks array and caused `undefi…
* 🔴 (14:30) `/home/byk/Code/opencode-v2-pilot/packages/core/src/plugin/provider/github-copilot.ts:239-251` installs an AI SDK `"sdk"` hook only for `Provider.ID.githubCopilot` with package `"@ai-sdk/github-copilot"`; it wraps `evt.options.fetch` with `copilotFetch(...)`, dynamically imports `../../github-copilot/copilot-provider.js`, and assigns `evt.sdk = mod.createOpenaiCompatible(evt.options)…
* 🔴 (14:42) `@loreai/opencode` is version `0.40.0`, uses ESM (`"type": "module"`), and exports `"."` from `./src/index.ts`; its `"./server"` export uses types from `./src/server.ts` and runtime bundles from `./dist/server.js` for both `"bun"` and `"default"`. * 🔴 (14:42) `/home/byk/Code/opencode-lore-v2/packages/opencode/package.json` defines scripts `"typecheck": "tsc --noEmit"` and `"build": …
* 🔴 (14:37) In `/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:380-448`, the `"chat.headers"` hook injects per-request gateway access headers, stable `x-lore-session-id` from OpenCode’s persistent `input.sessionID`, and `x-lore-agent` from `input.agent`. * 🔴 (14:37) OpenCode Task sub-agent detection in `/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:389-400` call…
* 🔴 (14:35) `/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts:246-268` defines `interceptUrlForProtocol(upstream, gateway, protocol)`: it maps `BodyProtocol` through `PROTOCOL_GATEWAY_PATHS`, strips the first matching `LLM_ENDPOINT_SUFFIXES` suffix so `upstreamBase` identifies the provider base, falls back to `upstream.origin`, preserves the original `upstream.pathname` as …
* 🔴 (14:33) User established in `/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:33-48` that user declines tunneled as defects by `Permission.assert` and the question tool must “never become model-facing tool output.” `ExecuteError` is exactly `Tool.Error | Permission.DeclinedError | QuestionTool.CancelledError`; `declineDefect()` inspects `Cause.isDieReason()` entrie…
* 🔴 (14:32) User established fetch-routing invariants in `/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts`: “Never intercept requests already going to the gateway”; direct-gateway requests remain unchanged but their headers may be observed for in-process extension authentication. * 🔴 (14:32) User established: “Never intercept local requests (could be local LLM or gateway …
* 🔴 (14:27) `/home/byk/Code/opencode-lore-v2/packages/core/src/index.ts:348-373` exports `distillLimiter`, `curatorLimiter`, tokenization APIs `estimateTokens`, `encodingForModel`, and `TOKEN_ESTIMATE_CACHE_VERSION`, `SemanticTokenCache`, fetch-interceptor APIs `installFetchInterceptor`, `rewriteRequest`, `shouldIntercept`, `DynamicRequestHeaders`, `DynamicRequestHeadersSource`, and `FetchInterc…
* 🔴 (14:24) `/home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:11-18` defines `SHELL_OUTPUT_GLOB` as `path.join(data, "shell", "*", "*")`, `TOOL_OUTPUT_GLOB` as `path.join(data, "tool-output", "*")`, re-exports `Agent.ID`, `Agent.Name`, and `Agent.Color`, and sets `defaultID = ID.make("build")`. * 🔴 (14:24) `/home/byk/Code/opencode-v2-pilot/packages/core/src/agent.ts:27-52` defines `S…
* 🔴 (14:22) `/home/byk/Code/opencode-lore-v2/packages/gateway/src/config.ts:1172-1207` defines `ProjectPathSource = "header" | "inferred" | "cwd"` and `ProjectPathResult` with required `path`, `source`, optional normalized `gitRemote`, and optional `overrodeHeaderPath` carrying a rejected stale `X-Lore-Project` path. `UNATTRIBUTED_PREFIX` re-exports `UNATTRIBUTED_PROJECT_PREFIX`; `unattributedBu…
* 🔴 (14:19) `/home/byk/Code/opencode-lore-v2/packages/core/script/build.ts:1-18` documents 2 publishable ESM targets: `dist/node/index.js` using `node:sqlite` and `dist/bun/index.js` using `bun:sqlite`; esbuild resolves `#db/driver` with `conditions: ["node"]` or `conditions: ["bun"]`; declarations are emitted separately by `tsc`; and the Node/`tsx` build does not require Bun. * 🔴 (14:19) `/hom…
* 🔴 (14:17) User stated the Jujutsu (`jj`) invariant: “jj never fails on conflict.” Conflicts are recorded in the resulting commit after operations such as `rebase`, `new`, or `squash`, then detected with `jj st` and resolved by editing files rather than using interactive `jj resolve`. * 🔴 (14:17) User supplied `jj` workflow rules for repositories containing `.jj/`: use `jj` rather than `git` f…
* 🔴 (14:17) [requested-review] User requested resumption of the same read-only adversarial correctness review of `/home/byk/Code/opencode-lore-v2`, noting the prior result was empty. * 🔴 (14:17) User required inspection of every changed file versus `@-`, covering: dual legacy/V2 exports; `Request` routing equivalence; location isolation; gateway lease concurrency and cleanup; setup failure/unlo…
* 🔴 (13:51) `/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`. * 🔴 (13:51) `sessionHeaders()` in `/home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts` emits `"x-session-affinity"` and `"X-Session-Id"` from `session.id`,…
Date: Sep 9, 2026 * 🔴 (13:40) The pnpm physical dependency directory `/home/byk/Code/opencode-lore-v2/node_modules/.pnpm/@opencode+plugin@0.0.0-beta-19378_@opentelemetry+api-logs@0.214.0_@opentelemetry+resour_adca8235564d91579da6ab6087184da7/node_modules/@opencode` contains 6 packages: `ai/`, `client/`, `plugin/`, `protocol/`, `schema/`, and `util/`. * 🔴 (13:40) The nested physical package `/ho…
Date: Sep 9, 2026 * 🔴 (13:34) `packages/opencode/test/` contains 10 test files: 1. `/home/byk/Code/opencode-lore-v2/packages/opencode/test/package.test.ts`, 2. `/home/byk/Code/opencode-lore-v2/packages/opencode/test/server.test.ts`, 3. `/home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts`, 4. `/home/byk/Code/opencode-lore-v2/packages/opencode/test/tui-silence.test.ts`, …
* 🔴 (13:34) User directive for `packages/core/src/fetch-interceptor.ts`: “Never intercept requests already going to the gateway”; direct gateway requests must remain unchanged, though their headers may be observed via `onRequestHeaders`. * 🔴 (13:34) User directive for `packages/core/src/fetch-interceptor.ts`: “Never intercept local requests (could be local LLM or gateway itself)”; local request…
* 🔴 (13:32) `packages/opencode/script/build.ts` defines an esbuild build script: removes and recreates `dist`, bundles `src/server.ts` to `dist/server.js`, and uses `format: "esm"`, `platform: "node"`, `target: "esnext"`, `sourcemap: true`, and `logLevel: "info"`. * 🔴 (13:32) `packages/opencode/script/build.ts` marks `@opencode/plugin`, `@loreai/core`, and `@loreai/gateway` as external dependen…
* 🔴 (13:31) Git working tree showed modified files: `packages/core/src/fetch-interceptor.ts`, `packages/core/src/index.ts`, `packages/opencode/package.json`, `packages/opencode/src/index.ts`, `packages/opencode/src/internal.ts`, `packages/opencode/test/internal.test.ts`, and `pnpm-lock.yaml`. * 🔴 (13:31) Git working tree showed added files: `packages/core/test/fetch-interceptor-request.test.ts`…
* 🔴 (13:28) A `FileSystem.stat` call on `/home/byk/Code/opencode-lore-v2/.git/HEAD` failed with `BadResource`. * 🔴 (13:30) `/home/byk/Code/opencode-lore-v2/.git` is a file, not a directory; its exact content is `gitdir: /home/byk/Code/opencode-lore/.git/worktrees/opencode-lore-v2`, indicating `/home/byk/Code/opencode-lore-v2` is a linked Git worktree whose metadata resides under `/home/byk/Code…
* 🔴 (13:24) User showed `/home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts`, a 222-line runtime module for the server-plugin entrypoint that acquires a shared Lore gateway lease, derives project metadata, builds request headers, and releases gateway resources. * 🔴 (13:24) `LoreServerRuntime` contains `gatewayBase`, `projectPath`, `gitRemote`, `gatewayHeaders`, and an async…
* 🔴 (13:23) User showed `/home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts`, a 587-line fetch-level interceptor that wraps `globalThis.fetch` and transparently reroutes outgoing LLM API requests through the Lore gateway while preserving original provider URLs, authentication, content type, and all other headers. * 🔴 (13:23) `FetchInterceptorConfig` defines `gatewayBase`, pe…
Date: Sep 9, 2026 * 🔴 (13:23) User showed additional `pnpm-lock.yaml` diff output; the displayed tool result was truncated, with full output saved at `/home/byk/.local/share/opencode/tool-output/tool_08655ef1d001WHpE3LOnYhdu3W`. * 🔴 (13:23) The lockfile added `@opencode/plugin@0.0.0-beta-19378` and its exact-version package family: `@opencode/ai@0.0.0-beta-19378`, `@opencode/client@0.0.0-beta-1…
🔴 (13:20) User provided repository instructions at `/home/byk/Code/opencode-lore-v2/AGENTS.md`. 🔴 (13:21) User showed the active Jujutsu working-copy change as change ID `wlpqmtosolpk`, commit `35358505e1c3`, description `feat(opencode): add V2 server plugin`; its parent is change ID `uutomtupslqm`, commit `429114122aa1`, `main | fix(gateway): preserve large recall continuations (#1730)`. 🔴 (1…
🔴 (13:18) User stated `/home/byk/Code/opencode-lore-v2` is a colocated Jujutsu repository containing both `.jj/` and `.git/`; mutations must use `jj`, while Git tools are limited to read-only operations or unsupported tasks. 🔴 (13:18) User stated Jujutsu conflicts are first-class: `jj` never fails on conflict; operations record the conflict in the resulting commit, after which `jj st` must be c…
🟡 (13:17) [requested-review] User requested a read-only adversarial correctness review of the current uncommitted Lore V2 port in `/home/byk/Code/opencode-lore-v2`, inspecting all changed files versus parent `@-`. 🟡 (13:17) User requested review focus on: dual V1/V2 exports; `Request` routing equivalence; location isolation; gateway lease concurrency and cleanup; setup failure and unload; packa…