mirror of
https://github.com/Jeuners/ECC.git
synced 2026-09-09 23:12:30 +02:00
fix: stabilize opencode declarations across package managers
This commit is contained in:
parent
0f4f95b3de
commit
05acc27530
8 changed files with 31 additions and 15 deletions
|
|
@ -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"))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue