Files
anomalyco_opencode/packages/opencode/src/session/context.ts
T
Dax Raad bfb36a8566 Refactor app context system to use Zod schemas and sync access pattern
🤖 Generated with opencode
Co-Authored-By: opencode <noreply@opencode.ai>
2025-06-03 11:59:03 -04:00

30 lines
709 B
TypeScript

import { App } from "../app/app"
import path from "path"
export namespace SessionContext {
const FILES = [
"AGENTS.md",
"CLAUDE.md",
"CONTEXT.md", // deprecated
]
export async function find() {
const { cwd, root } = App.info().path
let current = cwd
const found = []
while (true) {
for (const item of FILES) {
const file = Bun.file(path.join(current, item))
if (await file.exists()) {
found.push(file.text())
}
}
if (current === root) break
const parent = path.dirname(current)
if (parent === current) break
current = parent
}
return Promise.all(found).then((parts) => parts.join("\n\n"))
}
}