mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-08 18:33:28 +08:00
fix: stabilize opencode declarations across package managers
This commit is contained in:
@@ -23,7 +23,9 @@ import {
|
|||||||
} from "./lib/changed-files-store.js"
|
} from "./lib/changed-files-store.js"
|
||||||
import changedFilesTool from "../tools/changed-files.js"
|
import changedFilesTool from "../tools/changed-files.js"
|
||||||
|
|
||||||
export const ECCHooksPlugin = async ({
|
type ECCHooksPluginFn = (input: PluginInput) => Promise<Record<string, unknown>>
|
||||||
|
|
||||||
|
export const ECCHooksPlugin: ECCHooksPluginFn = async ({
|
||||||
client,
|
client,
|
||||||
$,
|
$,
|
||||||
directory,
|
directory,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { tool } from "@opencode-ai/plugin/tool"
|
import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool"
|
||||||
import {
|
import {
|
||||||
buildTree,
|
buildTree,
|
||||||
getChangedPaths,
|
getChangedPaths,
|
||||||
@@ -26,7 +26,7 @@ function renderTree(nodes: TreeNode[], indent: string): string {
|
|||||||
return lines.join("\n")
|
return lines.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
export default tool({
|
const changedFilesTool: ToolDefinition = tool({
|
||||||
description:
|
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.",
|
"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: {
|
args: {
|
||||||
@@ -79,3 +79,5 @@ export default tool({
|
|||||||
return output
|
return output
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default changedFilesTool
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
* Supports common coverage report formats.
|
* 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 path from "path"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
|
|
||||||
export default tool({
|
const checkCoverageTool: ToolDefinition = tool({
|
||||||
description:
|
description:
|
||||||
"Check test coverage against a threshold and identify files with low coverage. Reads coverage reports from common locations.",
|
"Check test coverage against a threshold and identify files with low coverage. Reads coverage reports from common locations.",
|
||||||
args: {
|
args: {
|
||||||
@@ -100,6 +100,8 @@ export default tool({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default checkCoverageTool
|
||||||
|
|
||||||
interface CoverageSummary {
|
interface CoverageSummary {
|
||||||
total: {
|
total: {
|
||||||
lines: number
|
lines: number
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
* This avoids shell execution assumptions while still giving precise guidance.
|
* 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 path from "path"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
|
|
||||||
type Formatter = "biome" | "prettier" | "black" | "gofmt" | "rustfmt"
|
type Formatter = "biome" | "prettier" | "black" | "gofmt" | "rustfmt"
|
||||||
|
|
||||||
export default tool({
|
const formatCodeTool: ToolDefinition = tool({
|
||||||
description:
|
description:
|
||||||
"Detect formatter for a file and return the exact command to run (Biome, Prettier, Black, gofmt, rustfmt).",
|
"Detect formatter for a file and return the exact command to run (Biome, Prettier, Black, gofmt, rustfmt).",
|
||||||
args: {
|
args: {
|
||||||
@@ -43,6 +43,8 @@ export default tool({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default formatCodeTool
|
||||||
|
|
||||||
function detectFormatter(cwd: string, ext: string): Formatter | null {
|
function detectFormatter(cwd: string, ext: string): Formatter | null {
|
||||||
if (["ts", "tsx", "js", "jsx", "json", "css", "scss", "md", "yaml", "yml"].includes(ext)) {
|
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"))) {
|
if (fs.existsSync(path.join(cwd, "biome.json")) || fs.existsSync(path.join(cwd, "biome.jsonc"))) {
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
* Returns branch/status/log/diff details for the active repository.
|
* 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"
|
import { execSync } from "child_process"
|
||||||
|
|
||||||
export default tool({
|
const gitSummaryTool: ToolDefinition = tool({
|
||||||
description:
|
description:
|
||||||
"Generate git summary with branch, status, recent commits, and optional diff stats.",
|
"Generate git summary with branch, status, recent commits, and optional diff stats.",
|
||||||
args: {
|
args: {
|
||||||
@@ -45,6 +45,8 @@ export default tool({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default gitSummaryTool
|
||||||
|
|
||||||
function run(command: string, cwd: string): string {
|
function run(command: string, cwd: string): string {
|
||||||
try {
|
try {
|
||||||
return execSync(command, { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim()
|
return execSync(command, { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim()
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
* Detects the appropriate linter and returns a runnable lint command.
|
* 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 path from "path"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
|
|
||||||
type Linter = "biome" | "eslint" | "ruff" | "pylint" | "golangci-lint"
|
type Linter = "biome" | "eslint" | "ruff" | "pylint" | "golangci-lint"
|
||||||
|
|
||||||
export default tool({
|
const lintCheckTool: ToolDefinition = tool({
|
||||||
description:
|
description:
|
||||||
"Detect linter for a target path and return command for check/fix runs.",
|
"Detect linter for a target path and return command for check/fix runs.",
|
||||||
args: {
|
args: {
|
||||||
@@ -43,6 +43,8 @@ export default tool({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default lintCheckTool
|
||||||
|
|
||||||
function detectLinter(cwd: string): Linter {
|
function detectLinter(cwd: string): Linter {
|
||||||
if (fs.existsSync(path.join(cwd, "biome.json")) || fs.existsSync(path.join(cwd, "biome.jsonc"))) {
|
if (fs.existsSync(path.join(cwd, "biome.json")) || fs.existsSync(path.join(cwd, "biome.jsonc"))) {
|
||||||
return "biome"
|
return "biome"
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
* Automatically detects the package manager and test framework.
|
* 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 path from "path"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
|
|
||||||
export default tool({
|
const runTestsTool: ToolDefinition = tool({
|
||||||
description:
|
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.",
|
"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: {
|
args: {
|
||||||
@@ -97,6 +97,8 @@ export default tool({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default runTestsTool
|
||||||
|
|
||||||
async function detectPackageManager(cwd: string): Promise<string> {
|
async function detectPackageManager(cwd: string): Promise<string> {
|
||||||
const lockFiles: Record<string, string> = {
|
const lockFiles: Record<string, string> = {
|
||||||
"bun.lockb": "bun",
|
"bun.lockb": "bun",
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
* The regex patterns below are used to DETECT potential issues in user code.
|
* 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 path from "path"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
|
|
||||||
export default tool({
|
const securityAuditTool: ToolDefinition = tool({
|
||||||
description:
|
description:
|
||||||
"Run a comprehensive security audit including dependency vulnerabilities, secret scanning, and common security issues.",
|
"Run a comprehensive security audit including dependency vulnerabilities, secret scanning, and common security issues.",
|
||||||
args: {
|
args: {
|
||||||
@@ -106,6 +106,8 @@ export default tool({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default securityAuditTool
|
||||||
|
|
||||||
interface AuditCheck {
|
interface AuditCheck {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
|
|||||||
Reference in New Issue
Block a user