clanka 0.22.0 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +7 -0
- package/dist/AgentTools.js.map +1 -1
- package/dist/AgentToolsReadFile.test.js +8 -2
- package/dist/AgentToolsReadFile.test.js.map +1 -1
- package/dist/Compaction.js +1 -1
- package/dist/Compaction.test.js +5 -5
- package/dist/bin/cli.mjs +3 -2
- package/dist/bin/cli.mjs.map +1 -1
- package/package.json +1 -1
- package/src/AgentTools.ts +14 -0
- package/src/AgentToolsReadFile.test.ts +14 -3
- package/src/Compaction.test.ts +6 -6
- package/src/Compaction.ts +1 -1
package/package.json
CHANGED
package/src/AgentTools.ts
CHANGED
|
@@ -720,6 +720,20 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
720
720
|
if (Option.isSome(imageType)) {
|
|
721
721
|
return yield* readImage(path, imageType.value, options)
|
|
722
722
|
}
|
|
723
|
+
if (
|
|
724
|
+
options.lineNumbers === false &&
|
|
725
|
+
!options.startLine &&
|
|
726
|
+
!options.endLine
|
|
727
|
+
) {
|
|
728
|
+
// Return the file verbatim, keeping its trailing newline and line
|
|
729
|
+
// endings so the text can be written back unchanged.
|
|
730
|
+
return yield* fs.readFileString(path).pipe(
|
|
731
|
+
Effect.catchReason("PlatformError", "NotFound", () =>
|
|
732
|
+
Effect.succeed(null),
|
|
733
|
+
),
|
|
734
|
+
Effect.orDie,
|
|
735
|
+
)
|
|
736
|
+
}
|
|
723
737
|
let stream = pipe(fs.stream(path), Stream.decodeText, Stream.splitLines)
|
|
724
738
|
if (options.startLine) {
|
|
725
739
|
stream = Stream.drop(stream, options.startLine - 1)
|
|
@@ -8,7 +8,12 @@ import * as Path from "effect/Path"
|
|
|
8
8
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
9
9
|
|
|
10
10
|
describe("readFile line numbers", () => {
|
|
11
|
-
const cases
|
|
11
|
+
const cases: ReadonlyArray<{
|
|
12
|
+
readonly name: string
|
|
13
|
+
readonly options: Record<string, unknown>
|
|
14
|
+
readonly expected: string
|
|
15
|
+
readonly content?: string
|
|
16
|
+
}> = [
|
|
12
17
|
{
|
|
13
18
|
name: "numbers lines by default",
|
|
14
19
|
options: {},
|
|
@@ -29,9 +34,15 @@ describe("readFile line numbers", () => {
|
|
|
29
34
|
options: { lineNumbers: true, startLine: 2, endLine: 3 },
|
|
30
35
|
expected: "2: beta\n3: gamma",
|
|
31
36
|
},
|
|
37
|
+
{
|
|
38
|
+
name: "preserves the trailing newline when unnumbered",
|
|
39
|
+
options: { lineNumbers: false },
|
|
40
|
+
content: "alpha\nbeta\n",
|
|
41
|
+
expected: "alpha\nbeta\n",
|
|
42
|
+
},
|
|
32
43
|
]
|
|
33
44
|
|
|
34
|
-
for (const { name, options, expected } of cases) {
|
|
45
|
+
for (const { name, options, expected, content } of cases) {
|
|
35
46
|
it.effect(name, () =>
|
|
36
47
|
Effect.gen(function* () {
|
|
37
48
|
const fs = yield* FileSystem.FileSystem
|
|
@@ -39,7 +50,7 @@ describe("readFile line numbers", () => {
|
|
|
39
50
|
const project = yield* fs.makeTempDirectoryScoped()
|
|
40
51
|
yield* fs.writeFileString(
|
|
41
52
|
path.join(project, "sample.txt"),
|
|
42
|
-
"alpha\nbeta\ngamma\ndelta",
|
|
53
|
+
content ?? "alpha\nbeta\ngamma\ndelta",
|
|
43
54
|
)
|
|
44
55
|
const result = yield* Effect.gen(function* () {
|
|
45
56
|
const executor = yield* AgentExecutor.AgentExecutor
|
package/src/Compaction.test.ts
CHANGED
|
@@ -185,7 +185,7 @@ describe("Compaction.estimateTokens", () => {
|
|
|
185
185
|
|
|
186
186
|
describe("Compaction.CompactionConfig", () => {
|
|
187
187
|
it.effect(
|
|
188
|
-
"defaults to a 236k window, a 16k reserve and a
|
|
188
|
+
"defaults to a 236k window, a 16k reserve and a 200k threshold",
|
|
189
189
|
() =>
|
|
190
190
|
Effect.gen(function* () {
|
|
191
191
|
const config = yield* Compaction.CompactionConfig
|
|
@@ -193,7 +193,7 @@ describe("Compaction.CompactionConfig", () => {
|
|
|
193
193
|
enabled: true,
|
|
194
194
|
contextWindow: 236_000,
|
|
195
195
|
reserveTokens: 16_000,
|
|
196
|
-
thresholdTokens:
|
|
196
|
+
thresholdTokens: 200_000,
|
|
197
197
|
keepRecentTokens: 20_000,
|
|
198
198
|
})
|
|
199
199
|
assert.deepStrictEqual(config, Compaction.defaultConfig)
|
|
@@ -210,9 +210,9 @@ describe("Compaction.shouldCompact", () => {
|
|
|
210
210
|
const small = Prompt.fromMessages([user("hi")])
|
|
211
211
|
|
|
212
212
|
for (const [tokens, expected] of [
|
|
213
|
-
[
|
|
214
|
-
[
|
|
215
|
-
[
|
|
213
|
+
[199_999, false],
|
|
214
|
+
[200_000, false],
|
|
215
|
+
[200_001, true],
|
|
216
216
|
] as const) {
|
|
217
217
|
it(`returns ${expected} with default config and ${tokens} reported tokens`, () => {
|
|
218
218
|
assert.strictEqual(
|
|
@@ -826,4 +826,4 @@ describe("Compaction.rewrite", () => {
|
|
|
826
826
|
)
|
|
827
827
|
}),
|
|
828
828
|
)
|
|
829
|
-
})
|
|
829
|
+
})
|