瀏覽代碼

Fix TypeScript errors and clean up unused imports

- Remove unused fs import from app.ts
- Remove unused LLM import and missing module reference from server.ts
- Fix parameter naming inconsistency in fetch.ts execute function
- Add missing metadata property to fetch.ts return statement
- Update test file to use correct API signatures and parameter names
- Remove unused parameters from example.ts

🤖 Generated with opencode
Co-Authored-By: opencode <[email protected]>
Dax Raad 8 月之前
父節點
當前提交
a1c4f345a8

+ 1 - 0
package.json

@@ -5,6 +5,7 @@
   "type": "module",
   "type": "module",
   "packageManager": "[email protected]",
   "packageManager": "[email protected]",
   "scripts": {
   "scripts": {
+    "typecheck": "bun run typecheck --filter='*'",
     "dev": "sst dev"
     "dev": "sst dev"
   },
   },
   "workspaces": {
   "workspaces": {

+ 3 - 1
packages/opencode/package.json

@@ -4,7 +4,9 @@
   "name": "opencode",
   "name": "opencode",
   "type": "module",
   "type": "module",
   "private": true,
   "private": true,
-  "scripts": {},
+  "scripts": {
+    "typecheck": "tsc --noEmit"
+  },
   "exports": {
   "exports": {
     "./*": [
     "./*": [
       "./src/*.ts",
       "./src/*.ts",

+ 0 - 1
packages/opencode/src/app/app.ts

@@ -1,4 +1,3 @@
-import fs from "fs/promises"
 import { Log } from "../util/log"
 import { Log } from "../util/log"
 import { Context } from "../util/context"
 import { Context } from "../util/context"
 import { Filesystem } from "../util/filesystem"
 import { Filesystem } from "../util/filesystem"

+ 0 - 1
packages/opencode/src/server/server.ts

@@ -6,7 +6,6 @@ import { streamSSE } from "hono/streaming"
 import { Session } from "../session/session"
 import { Session } from "../session/session"
 import { resolver, validator as zValidator } from "hono-openapi/zod"
 import { resolver, validator as zValidator } from "hono-openapi/zod"
 import { z } from "zod"
 import { z } from "zod"
-import { LLM } from "../llm/llm"
 import { Message } from "../session/message"
 import { Message } from "../session/message"
 import { Provider } from "../provider/provider"
 import { Provider } from "../provider/provider"
 
 

+ 1 - 1
packages/opencode/src/tool/example.ts

@@ -8,7 +8,7 @@ export const ExampleTool = Tool.define({
     foo: z.string().describe("The foo parameter"),
     foo: z.string().describe("The foo parameter"),
     bar: z.number().describe("The bar parameter"),
     bar: z.number().describe("The bar parameter"),
   }),
   }),
-  async execute(params) {
+  async execute() {
     return {
     return {
       metadata: {
       metadata: {
         lol: "hey",
         lol: "hey",

+ 2 - 2
packages/opencode/src/tool/fetch.ts

@@ -53,7 +53,7 @@ export const FetchTool = Tool.define({
       .describe("Optional timeout in seconds (max 120)")
       .describe("Optional timeout in seconds (max 120)")
       .optional(),
       .optional(),
   }),
   }),
-  async execute(param) {
+  async execute(params) {
     // Validate URL
     // Validate URL
     if (
     if (
       !params.url.startsWith("http://") &&
       !params.url.startsWith("http://") &&
@@ -110,7 +110,7 @@ export const FetchTool = Tool.define({
           const markdown = convertHTMLToMarkdown(content)
           const markdown = convertHTMLToMarkdown(content)
           return { output: markdown, metadata: {} }
           return { output: markdown, metadata: {} }
         }
         }
-        return { output: "```\n" + content + "\n```" }
+        return { output: "```\n" + content + "\n```", metadata: {} }
 
 
       case "html":
       case "html":
         return { output: content, metadata: {} }
         return { output: content, metadata: {} }

+ 13 - 31
packages/opencode/test/tool/tool.test.ts

@@ -1,34 +1,22 @@
 import { describe, expect, test } from "bun:test"
 import { describe, expect, test } from "bun:test"
 import { App } from "../../src/app/app"
 import { App } from "../../src/app/app"
 import { GlobTool } from "../../src/tool/glob"
 import { GlobTool } from "../../src/tool/glob"
-import { ls } from "../../src/tool/ls"
+import { ListTool } from "../../src/tool/ls"
 
 
 describe("tool.glob", () => {
 describe("tool.glob", () => {
   test("truncate", async () => {
   test("truncate", async () => {
-    await App.provide({ directory: process.cwd() }, async () => {
-      let result = await GlobTool.execute(
-        {
-          pattern: "./node_modules/**/*",
-        },
-        {
-          toolCallId: "test",
-          messages: [],
-        },
-      )
+    await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
+      let result = await GlobTool.execute({
+        pattern: "./node_modules/**/*",
+      })
       expect(result.metadata.truncated).toBe(true)
       expect(result.metadata.truncated).toBe(true)
     })
     })
   })
   })
   test("basic", async () => {
   test("basic", async () => {
-    await App.provide({ directory: process.cwd() }, async () => {
-      let result = await GlobTool.execute(
-        {
-          pattern: "*.json",
-        },
-        {
-          toolCallId: "test",
-          messages: [],
-        },
-      )
+    await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
+      let result = await GlobTool.execute({
+        pattern: "*.json",
+      })
       expect(result.metadata).toMatchObject({
       expect(result.metadata).toMatchObject({
         truncated: false,
         truncated: false,
         count: 2,
         count: 2,
@@ -39,16 +27,10 @@ describe("tool.glob", () => {
 
 
 describe("tool.ls", () => {
 describe("tool.ls", () => {
   test("basic", async () => {
   test("basic", async () => {
-    const result = await App.provide({ directory: process.cwd() }, async () => {
-      return await ls.execute(
-        {
-          path: "./example",
-        },
-        {
-          toolCallId: "test",
-          messages: [],
-        },
-      )
+    const result = await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
+      return await ListTool.execute({
+        path: "./example",
+      })
     })
     })
     expect(result.output).toMatchSnapshot()
     expect(result.output).toMatchSnapshot()
   })
   })