diff options
| author | Dax Raad <[email protected]> | 2025-06-20 15:14:12 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-06-20 15:14:12 -0400 |
| commit | 98734ff28cf3d706d97ac87cf1e57fb69a62c43a (patch) | |
| tree | 459a860797b2677f78df5167750cd071dd4ecb92 | |
| parent | 999135266389ad0b2747068dddd96fdb9713b0a1 (diff) | |
| download | opencode-98734ff28cf3d706d97ac87cf1e57fb69a62c43a.tar.gz opencode-98734ff28cf3d706d97ac87cf1e57fb69a62c43a.zip | |
Consolidate session context handling and add global config support
Refactored context file discovery by removing separate SessionContext module and integrating functionality into SystemPrompt.context(). Added support for finding AGENTS.md and CLAUDE.md files in global config directories.
🤖 Generated with [opencode](https://opencode.ai)
Co-Authored-By: opencode <[email protected]>
| -rw-r--r-- | packages/opencode/src/session/context.ts | 19 | ||||
| -rw-r--r-- | packages/opencode/src/session/system.ts | 15 |
2 files changed, 14 insertions, 20 deletions
diff --git a/packages/opencode/src/session/context.ts b/packages/opencode/src/session/context.ts deleted file mode 100644 index 345eb9ea7..000000000 --- a/packages/opencode/src/session/context.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { App } from "../app/app" -import { Filesystem } from "../util/filesystem" - -export namespace SessionContext { - const FILES = [ - "AGENTS.md", - "CLAUDE.md", - "CONTEXT.md", // deprecated - ] - export async function find() { - const { cwd, root } = App.info().path - const found = [] - for (const item of FILES) { - const matches = await Filesystem.findUp(item, cwd, root) - found.push(...matches.map((x) => Bun.file(x).text())) - } - return Promise.all(found).then((parts) => parts.join("\n\n")) - } -} diff --git a/packages/opencode/src/session/system.ts b/packages/opencode/src/session/system.ts index f902b0225..6eea6085f 100644 --- a/packages/opencode/src/session/system.ts +++ b/packages/opencode/src/session/system.ts @@ -1,6 +1,9 @@ import { App } from "../app/app" import { Ripgrep } from "../external/ripgrep" +import { Global } from "../global" import { Filesystem } from "../util/filesystem" +import path from "path" +import os from "os" import PROMPT_ANTHROPIC from "./prompt/anthropic.txt" import PROMPT_ANTHROPIC_SPOOF from "./prompt/anthropic_spoof.txt" @@ -101,7 +104,17 @@ export namespace SystemPrompt { const matches = await Filesystem.findUp(item, cwd, root) found.push(...matches.map((x) => Bun.file(x).text())) } - return Promise.all(found) + found.push( + Bun.file(path.join(Global.Path.config, "AGENTS.md")) + .text() + .catch(() => ""), + ) + found.push( + Bun.file(path.join(os.homedir(), ".claude", "CLAUDE.md")) + .text() + .catch(() => ""), + ) + return Promise.all(found).then(Boolean) } export function summarize(providerID: string) { |
