summaryrefslogtreecommitdiffhomepage
path: root/js/example/cli.ts
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-05-26 17:15:41 -0400
committerDax Raad <[email protected]>2025-05-26 17:15:47 -0400
commitde9f144858107b4230f44956283542bd137bffb6 (patch)
tree72f2d0b6e0fdaf9bf249115358576cb748b10dec /js/example/cli.ts
parent0ad87389331c4b18bcecec74476853a2e16a8d10 (diff)
downloadopencode-de9f144858107b4230f44956283542bd137bffb6.tar.gz
opencode-de9f144858107b4230f44956283542bd137bffb6.zip
sync
Diffstat (limited to 'js/example/cli.ts')
-rw-r--r--js/example/cli.ts44
1 files changed, 19 insertions, 25 deletions
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);
+});