clanka 0.22.0 → 0.22.1
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/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/bin/cli.mjs +2 -1
- 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/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
|