diff options
Diffstat (limited to 'js/example')
| -rw-r--r-- | js/example/broken.ts | 1 | ||||
| -rw-r--r-- | js/example/cli.ts | 44 |
2 files changed, 20 insertions, 25 deletions
diff --git a/js/example/broken.ts b/js/example/broken.ts new file mode 100644 index 000000000..e073ad008 --- /dev/null +++ b/js/example/broken.ts @@ -0,0 +1 @@ +export const x: number = "asd"; diff --git a/js/example/cli.ts b/js/example/cli.ts index bb7522cbb..9c9e07edd 100644 --- a/js/example/cli.ts +++ b/js/example/cli.ts @@ -1,27 +1,21 @@ -import { hc } from "hono/client"; -import type { Server } from "../src/server/server"; +import { App } from "../src/app"; +import path from "path"; +import { edit } from "../src/tool"; +import { FileTimes } from "../src/tool/util/file-times"; -const message = process.argv.slice(2).join(" "); -console.log(message); - -const client = hc<Server.App>(`http://localhost:16713`); -const session = await client.session_create.$post().then((res) => res.json()); -const result = await client.session_chat - .$post({ - json: { - sessionID: session.id, - parts: [ - { - type: "text", - text: message, - }, - ], +await App.provide({ directory: process.cwd() }, async () => { + const file = path.join(process.cwd(), "example/broken.ts"); + FileTimes.read(file); + const tool = await edit.execute( + { + file_path: file, + old_string: "x:", + new_string: "x:", }, - }) - .then((res) => res.json()); - -for (const part of result.parts) { - if (part.type === "text") { - console.log(part.text); - } -} + { + toolCallId: "test", + messages: [], + }, + ); + console.log(tool.output); +}); |
