Something went wrong. Try again.
opencode v2 mirror
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627export * as ConfigCompactionPlugin from "./compaction.js"
import { define } from "@opencode/plugin/effect/plugin"import { Effect } from "effect"import { Config } from "../../config.js"import { SessionCompaction } from "../../session/compaction.js"import { ConfigEntryObserver } from "./entry-observer.js"
export const Plugin = define({ id: "opencode.config.compaction", effect: Effect.fn(function* (ctx) { const config = yield* Config.Service const compaction = yield* SessionCompaction.Service const loaded = yield* ConfigEntryObserver.observe(config, ctx.event, compaction.reload()) yield* compaction.transform((editor) => { for (const entry of loaded.entries) { if (entry.type !== "document" || !entry.info.compaction) continue editor.configure({ ...(entry.info.compaction.auto === undefined ? {} : { auto: entry.info.compaction.auto }), ...(entry.info.compaction.buffer === undefined ? {} : { buffer: entry.info.compaction.buffer }), ...(entry.info.compaction.keep?.tokens === undefined ? {} : { tokens: entry.info.compaction.keep.tokens }), }) } }) }),})