clanka 0.4.0 → 0.5.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/Agent.d.ts +2 -2
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js.map +1 -1
- package/dist/AgentExecutor.d.ts +10 -4
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +22 -7
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentSkills.d.ts +5 -2
- package/dist/AgentSkills.d.ts.map +1 -1
- package/dist/AgentSkills.js +23 -6
- package/dist/AgentSkills.js.map +1 -1
- package/dist/AgentSkills.test.js +154 -7
- package/dist/AgentSkills.test.js.map +1 -1
- package/dist/AgentTools.d.ts +32 -1
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +26 -10
- package/dist/AgentTools.js.map +1 -1
- package/package.json +1 -1
- package/src/Agent.ts +2 -1
- package/src/AgentExecutor.ts +50 -32
- package/src/AgentSkills.test.ts +336 -15
- package/src/AgentSkills.ts +26 -6
- package/src/AgentTools.ts +34 -10
package/src/AgentTools.ts
CHANGED
|
@@ -32,6 +32,15 @@ export class CurrentDirectory extends Context.Service<
|
|
|
32
32
|
string
|
|
33
33
|
>()("clanka/AgentTools/CurrentDirectory") {}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
* @category Context
|
|
38
|
+
*/
|
|
39
|
+
export class DirectoryChanger extends Context.Service<
|
|
40
|
+
DirectoryChanger,
|
|
41
|
+
(directory: string) => Effect.Effect<string>
|
|
42
|
+
>()("clanka/AgentTools/DirectoryChanger") {}
|
|
43
|
+
|
|
35
44
|
/**
|
|
36
45
|
* @since 1.0.0
|
|
37
46
|
* @category Context
|
|
@@ -57,6 +66,7 @@ export class SubagentExecutor extends Context.Service<
|
|
|
57
66
|
export const makeContextNoop = (cwd?: string) =>
|
|
58
67
|
SubagentExecutor.context(() => Effect.die("Not implemented")).pipe(
|
|
59
68
|
Context.add(CurrentDirectory, cwd ?? "/"),
|
|
69
|
+
Context.add(DirectoryChanger, () => Effect.die("Not implemented")),
|
|
60
70
|
Context.add(TaskCompleter, () => Effect.void),
|
|
61
71
|
)
|
|
62
72
|
|
|
@@ -73,6 +83,13 @@ class TodoItem extends Schema.Opaque<TodoItem>()(
|
|
|
73
83
|
* @category Toolkit
|
|
74
84
|
*/
|
|
75
85
|
export const AgentTools = Toolkit.make(
|
|
86
|
+
Tool.make("changeDirectory", {
|
|
87
|
+
description:
|
|
88
|
+
"Change the executor's working directory to an existing directory and return its absolute path. Relative paths resolve from the current directory without shell expansion. Await this before dependent tools. The change persists across scripts and is shared with delegates using this executor. Startup AGENTS.md, skills, and the semantic-search index root remain fixed. Navigation does not survive a session reload.",
|
|
89
|
+
parameters: Schema.String.annotate({ identifier: "directory" }),
|
|
90
|
+
success: Schema.String,
|
|
91
|
+
dependencies: [DirectoryChanger],
|
|
92
|
+
}),
|
|
76
93
|
Tool.make("readFile", {
|
|
77
94
|
description:
|
|
78
95
|
"Read a file and optionally filter the lines to return. Returns null if the file doesn't exist.",
|
|
@@ -284,6 +301,15 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
284
301
|
}, Effect.scoped)
|
|
285
302
|
|
|
286
303
|
return AgentToolsWithSearch.of({
|
|
304
|
+
changeDirectory: Effect.fn("AgentTools.changeDirectory")(
|
|
305
|
+
function* (directory) {
|
|
306
|
+
yield* Effect.logInfo(`Calling "changeDirectory"`).pipe(
|
|
307
|
+
Effect.annotateLogs({ directory }),
|
|
308
|
+
)
|
|
309
|
+
const changeDirectory = yield* DirectoryChanger
|
|
310
|
+
return yield* changeDirectory(directory)
|
|
311
|
+
},
|
|
312
|
+
),
|
|
287
313
|
readFile: Effect.fn("AgentTools.readFile")(function* (options) {
|
|
288
314
|
yield* Effect.logInfo(`Calling "readFile"`).pipe(
|
|
289
315
|
Effect.annotateLogs(options),
|
|
@@ -321,7 +347,7 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
321
347
|
recursive: true,
|
|
322
348
|
})
|
|
323
349
|
yield* fs.writeFileString(path, options.content)
|
|
324
|
-
yield* SemanticSearch.maybeUpdateFile(
|
|
350
|
+
yield* SemanticSearch.maybeUpdateFile(path)
|
|
325
351
|
}, Effect.orDie),
|
|
326
352
|
removeFile: Effect.fn("AgentTools.removeFile")(function* (path) {
|
|
327
353
|
yield* Effect.logInfo(`Calling "removeFile"`).pipe(
|
|
@@ -330,9 +356,7 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
330
356
|
const cwd = yield* CurrentDirectory
|
|
331
357
|
const absolutePath = pathService.resolve(cwd, path)
|
|
332
358
|
yield* fs.remove(absolutePath, { force: true })
|
|
333
|
-
yield* SemanticSearch.maybeRemoveFile(
|
|
334
|
-
pathService.relative(cwd, absolutePath),
|
|
335
|
-
)
|
|
359
|
+
yield* SemanticSearch.maybeRemoveFile(absolutePath)
|
|
336
360
|
}, Effect.orDie),
|
|
337
361
|
renameFile: Effect.fn("AgentTools.renameFile")(function* (options) {
|
|
338
362
|
yield* Effect.logInfo(`Calling "renameFile"`).pipe(
|
|
@@ -345,8 +369,8 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
345
369
|
recursive: true,
|
|
346
370
|
})
|
|
347
371
|
yield* fs.rename(from, to)
|
|
348
|
-
yield* SemanticSearch.maybeRemoveFile(
|
|
349
|
-
yield* SemanticSearch.maybeUpdateFile(
|
|
372
|
+
yield* SemanticSearch.maybeRemoveFile(from)
|
|
373
|
+
yield* SemanticSearch.maybeUpdateFile(to)
|
|
350
374
|
}, Effect.orDie),
|
|
351
375
|
ls: Effect.fn("AgentTools.ls")(function* (directory) {
|
|
352
376
|
yield* Effect.logInfo(`Calling "ls"`).pipe(
|
|
@@ -597,7 +621,7 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
597
621
|
recursive: true,
|
|
598
622
|
})
|
|
599
623
|
yield* fs.writeFileString(step.path, step.next)
|
|
600
|
-
yield* SemanticSearch.maybeUpdateFile(
|
|
624
|
+
yield* SemanticSearch.maybeUpdateFile(step.path)
|
|
601
625
|
break
|
|
602
626
|
}
|
|
603
627
|
case "move": {
|
|
@@ -606,13 +630,13 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
606
630
|
})
|
|
607
631
|
yield* fs.writeFileString(step.movePath, step.next)
|
|
608
632
|
yield* fs.remove(step.path)
|
|
609
|
-
yield* SemanticSearch.maybeRemoveFile(
|
|
610
|
-
yield* SemanticSearch.maybeUpdateFile(
|
|
633
|
+
yield* SemanticSearch.maybeRemoveFile(step.path)
|
|
634
|
+
yield* SemanticSearch.maybeUpdateFile(step.movePath)
|
|
611
635
|
break
|
|
612
636
|
}
|
|
613
637
|
case "delete": {
|
|
614
638
|
yield* fs.remove(step.path)
|
|
615
|
-
yield* SemanticSearch.maybeRemoveFile(
|
|
639
|
+
yield* SemanticSearch.maybeRemoveFile(step.path)
|
|
616
640
|
break
|
|
617
641
|
}
|
|
618
642
|
}
|