feat(core): support percentage compaction buffer
This commit is contained in:
parent
b3a012cbdd
commit
21da80678a
4 changed files with 20 additions and 4 deletions
|
|
@ -4,6 +4,7 @@ import { describe, expect } from "bun:test"
|
|||
import { Effect, Layer, Schema } from "effect"
|
||||
import { FastCheck } from "effect/testing"
|
||||
import { Config } from "@opencode-ai/core/config"
|
||||
import { ConfigCompaction } from "@opencode-ai/core/config/compaction"
|
||||
import { ConfigProvider } from "@opencode-ai/core/config/provider"
|
||||
import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
|
||||
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
||||
|
|
@ -52,6 +53,16 @@ const provider = {
|
|||
}
|
||||
|
||||
describe("Config", () => {
|
||||
it.effect("accepts token and percentage compaction buffers", () =>
|
||||
Effect.sync(() => {
|
||||
expect(Schema.decodeUnknownSync(ConfigCompaction.Info)({ buffer: 20_000 }).buffer).toBe(20_000)
|
||||
expect(Schema.decodeUnknownSync(ConfigCompaction.Info)({ buffer: { percent: 10 } }).buffer).toEqual({
|
||||
percent: 10,
|
||||
})
|
||||
expect(() => Schema.decodeUnknownSync(ConfigCompaction.Info)({ buffer: { percent: 101 } })).toThrow()
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("returns the latest defined scalar from priority-ordered documents", () =>
|
||||
Effect.sync(() => {
|
||||
const entries = [
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ const config = Layer.succeed(
|
|||
type: "document",
|
||||
info: new Config.Info({
|
||||
compaction: new ConfigCompaction.Info({
|
||||
buffer: 3_000,
|
||||
buffer: new ConfigCompaction.BufferPercent({ percent: 75 }),
|
||||
keep: new ConfigCompaction.Keep({ tokens: 1_000 }),
|
||||
}),
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue