From 05acc275307a09eea89080619a35d7dbd20b128b Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Sun, 5 Apr 2026 15:11:19 -0700 Subject: [PATCH] fix: stabilize opencode declarations across package managers --- .opencode/plugins/ecc-hooks.ts | 4 +++- .opencode/tools/changed-files.ts | 6 ++++-- .opencode/tools/check-coverage.ts | 6 ++++-- .opencode/tools/format-code.ts | 6 ++++-- .opencode/tools/git-summary.ts | 6 ++++-- .opencode/tools/lint-check.ts | 6 ++++-- .opencode/tools/run-tests.ts | 6 ++++-- .opencode/tools/security-audit.ts | 6 ++++-- 8 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.opencode/plugins/ecc-hooks.ts b/.opencode/plugins/ecc-hooks.ts index 58a20928..9e4ab3fc 100644 --- a/.opencode/plugins/ecc-hooks.ts +++ b/.opencode/plugins/ecc-hooks.ts @@ -23,7 +23,9 @@ import { } from "./lib/changed-files-store.js" import changedFilesTool from "../tools/changed-files.js" -export const ECCHooksPlugin = async ({ +type ECCHooksPluginFn = (input: PluginInput) => Promise> + +export const ECCHooksPlugin: ECCHooksPluginFn = async ({ client, $, directory, diff --git a/.opencode/tools/changed-files.ts b/.opencode/tools/changed-files.ts index 09cdacd3..a6751bcc 100644 --- a/.opencode/tools/changed-files.ts +++ b/.opencode/tools/changed-files.ts @@ -1,4 +1,4 @@ -import { tool } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import { buildTree, getChangedPaths, @@ -26,7 +26,7 @@ function renderTree(nodes: TreeNode[], indent: string): string { return lines.join("\n") } -export default tool({ +const changedFilesTool: ToolDefinition = tool({ description: "List files changed by agents in this session as a navigable tree. Shows added (+), modified (~), and deleted (-) indicators. Use filter to show only specific change types. Returns paths for git diff.", args: { @@ -79,3 +79,5 @@ export default tool({ return output }, }) + +export default changedFilesTool diff --git a/.opencode/tools/check-coverage.ts b/.opencode/tools/check-coverage.ts index 6465cb6b..46f11cd8 100644 --- a/.opencode/tools/check-coverage.ts +++ b/.opencode/tools/check-coverage.ts @@ -5,11 +5,11 @@ * Supports common coverage report formats. */ -import { tool } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import * as path from "path" import * as fs from "fs" -export default tool({ +const checkCoverageTool: ToolDefinition = tool({ description: "Check test coverage against a threshold and identify files with low coverage. Reads coverage reports from common locations.", args: { @@ -100,6 +100,8 @@ export default tool({ }, }) +export default checkCoverageTool + interface CoverageSummary { total: { lines: number diff --git a/.opencode/tools/format-code.ts b/.opencode/tools/format-code.ts index 6258c71e..f1cb3660 100644 --- a/.opencode/tools/format-code.ts +++ b/.opencode/tools/format-code.ts @@ -5,13 +5,13 @@ * This avoids shell execution assumptions while still giving precise guidance. */ -import { tool } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import * as path from "path" import * as fs from "fs" type Formatter = "biome" | "prettier" | "black" | "gofmt" | "rustfmt" -export default tool({ +const formatCodeTool: ToolDefinition = tool({ description: "Detect formatter for a file and return the exact command to run (Biome, Prettier, Black, gofmt, rustfmt).", args: { @@ -43,6 +43,8 @@ export default tool({ }, }) +export default formatCodeTool + function detectFormatter(cwd: string, ext: string): Formatter | null { if (["ts", "tsx", "js", "jsx", "json", "css", "scss", "md", "yaml", "yml"].includes(ext)) { if (fs.existsSync(path.join(cwd, "biome.json")) || fs.existsSync(path.join(cwd, "biome.jsonc"))) { diff --git a/.opencode/tools/git-summary.ts b/.opencode/tools/git-summary.ts index 488c515e..dd11f657 100644 --- a/.opencode/tools/git-summary.ts +++ b/.opencode/tools/git-summary.ts @@ -4,10 +4,10 @@ * Returns branch/status/log/diff details for the active repository. */ -import { tool } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import { execSync } from "child_process" -export default tool({ +const gitSummaryTool: ToolDefinition = tool({ description: "Generate git summary with branch, status, recent commits, and optional diff stats.", args: { @@ -45,6 +45,8 @@ export default tool({ }, }) +export default gitSummaryTool + function run(command: string, cwd: string): string { try { return execSync(command, { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim() diff --git a/.opencode/tools/lint-check.ts b/.opencode/tools/lint-check.ts index 1ebbfdf7..63539935 100644 --- a/.opencode/tools/lint-check.ts +++ b/.opencode/tools/lint-check.ts @@ -4,13 +4,13 @@ * Detects the appropriate linter and returns a runnable lint command. */ -import { tool } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import * as path from "path" import * as fs from "fs" type Linter = "biome" | "eslint" | "ruff" | "pylint" | "golangci-lint" -export default tool({ +const lintCheckTool: ToolDefinition = tool({ description: "Detect linter for a target path and return command for check/fix runs.", args: { @@ -43,6 +43,8 @@ export default tool({ }, }) +export default lintCheckTool + function detectLinter(cwd: string): Linter { if (fs.existsSync(path.join(cwd, "biome.json")) || fs.existsSync(path.join(cwd, "biome.jsonc"))) { return "biome" diff --git a/.opencode/tools/run-tests.ts b/.opencode/tools/run-tests.ts index 3b17c905..aa8ce520 100644 --- a/.opencode/tools/run-tests.ts +++ b/.opencode/tools/run-tests.ts @@ -5,11 +5,11 @@ * Automatically detects the package manager and test framework. */ -import { tool } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import * as path from "path" import * as fs from "fs" -export default tool({ +const runTestsTool: ToolDefinition = tool({ description: "Run the test suite with optional coverage, watch mode, or specific test patterns. Automatically detects package manager (npm, pnpm, yarn, bun) and test framework.", args: { @@ -97,6 +97,8 @@ export default tool({ }, }) +export default runTestsTool + async function detectPackageManager(cwd: string): Promise { const lockFiles: Record = { "bun.lockb": "bun", diff --git a/.opencode/tools/security-audit.ts b/.opencode/tools/security-audit.ts index 8f450f24..59b76d9e 100644 --- a/.opencode/tools/security-audit.ts +++ b/.opencode/tools/security-audit.ts @@ -8,11 +8,11 @@ * The regex patterns below are used to DETECT potential issues in user code. */ -import { tool } from "@opencode-ai/plugin/tool" +import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" import * as path from "path" import * as fs from "fs" -export default tool({ +const securityAuditTool: ToolDefinition = tool({ description: "Run a comprehensive security audit including dependency vulnerabilities, secret scanning, and common security issues.", args: { @@ -106,6 +106,8 @@ export default tool({ }, }) +export default securityAuditTool + interface AuditCheck { name: string description: string