aboutsummaryrefslogtreecommitdiff
path: root/opencode/tools
diff options
context:
space:
mode:
authorJosh Rahm <rahm@josher.dev>2026-08-11 11:19:51 -0600
committerJosh Rahm <rahm@josher.dev>2026-08-11 11:19:51 -0600
commit19ca36dfe8cc99321fcbde26a9387e3fac74509d (patch)
treec650df1c655df572bfaed31a0291bf84e7a036e3 /opencode/tools
parentd7829c069b09d2115daa1aa33a729dd9ffee301e (diff)
downloadhobs.nvim-19ca36dfe8cc99321fcbde26a9387e3fac74509d.tar.gz
hobs.nvim-19ca36dfe8cc99321fcbde26a9387e3fac74509d.tar.bz2
hobs.nvim-19ca36dfe8cc99321fcbde26a9387e3fac74509d.zip
[feat] add the opencode tools directory.HEADmain
Diffstat (limited to 'opencode/tools')
-rw-r--r--opencode/tools/files_of_intrigue.ts16
-rw-r--r--opencode/tools/hello.ts15
-rw-r--r--opencode/tools/live_read.ts27
3 files changed, 58 insertions, 0 deletions
diff --git a/opencode/tools/files_of_intrigue.ts b/opencode/tools/files_of_intrigue.ts
new file mode 100644
index 0000000..43bae61
--- /dev/null
+++ b/opencode/tools/files_of_intrigue.ts
@@ -0,0 +1,16 @@
+import { tool } from "@opencode-ai/plugin"
+
+export default tool({
+ description: "Use this tool when you found an interesting file",
+
+ args: {
+ filepath: tool.schema.string().describe("The file path of an interesting file."),
+ description: tool.schema.string().describe("Why is this file intriguing"),
+ },
+
+ async execute(args) {
+ const message = `FILE OF INTRIGUE ${Date.now()}: ${args.filepath}, because ${args.description}!`
+ console.error(`[hobs.nvim] intrigue files =${JSON.stringify(args.filepath)}`)
+ return message
+ },
+})
diff --git a/opencode/tools/hello.ts b/opencode/tools/hello.ts
new file mode 100644
index 0000000..0b49316
--- /dev/null
+++ b/opencode/tools/hello.ts
@@ -0,0 +1,15 @@
+import { tool } from "@opencode-ai/plugin"
+
+export default tool({
+ description: "Say hello to a person. Use this tool when explicitly asked to call the hello tool.",
+
+ args: {
+ name: tool.schema.string().describe("The name of the person to greet"),
+ },
+
+ async execute(args) {
+ const message = `HELLO_TOOL_CALLED ${Date.now()}: Hello, ${args.name}!`
+ console.error(`[hobs.nvim] hello tool called with name=${JSON.stringify(args.name)}`)
+ return message
+ },
+})
diff --git a/opencode/tools/live_read.ts b/opencode/tools/live_read.ts
new file mode 100644
index 0000000..2174015
--- /dev/null
+++ b/opencode/tools/live_read.ts
@@ -0,0 +1,27 @@
+import { tool } from "@opencode-ai/plugin"
+
+export default tool({
+ description: "Read the current live Neovim buffer. Use this instead of read when you need the current unsaved contents of the user's active buffer.",
+
+ args: {},
+
+ async execute() {
+ const nvim = process.env.NVIM
+
+ if (!nvim) {
+ throw new Error("$NVIM is not set; live_read must be run from a Neovim-spawned OpenCode process")
+ }
+
+ const expr = `join(getline(1, "$"), "\n")`
+ console.error(`[hobs.nvim] live_read tool called =${expr} =${nvim}`)
+
+ // const result = await Bun.$`echo "hello, there"`.text()
+ const result =
+ await Bun.$`nvim --headless --server ${nvim} --remote-expr ${expr}`.text()
+
+ console.error(`live tool returned ${result}`)
+ console.error(`done`)
+
+ return result
+ },
+})