The open source coding agent.
TypeScript
only enable ruff if it seems to be used
Dax Raad23c30521d8a4
diff --git a/packages/opencode/src/format/formatter.ts b/packages/opencode/src/format/formatter.tsindex 1c0c9721ffc..83e359f6f59 100644--- a/packages/opencode/src/format/formatter.ts+++ b/packages/opencode/src/format/formatter.ts@@ -105,7 +105,29 @@ export const ruff: Info = {command: ["ruff", "format", "$FILE"],extensions: [".py", ".pyi"],async enabled() {- return Bun.which("ruff") !== null+ if (!Bun.which("ruff")) return false+ const app = App.info()+ const configs = ["pyproject.toml", "ruff.toml", ".ruff.toml"]+ for (const config of configs) {+ const found = await Filesystem.findUp(config, app.path.cwd, app.path.root)+ if (found.length > 0) {+ if (config === "pyproject.toml") {+ const content = await Bun.file(found[0]).text()+ if (content.includes("[tool.ruff]")) return true+ } else {+ return true+ }+ }+ }+ const deps = ["requirements.txt", "pyproject.toml", "Pipfile"]+ for (const dep of deps) {+ const found = await Filesystem.findUp(dep, app.path.cwd, app.path.root)+ if (found.length > 0) {+ const content = await Bun.file(found[0]).text()+ if (content.includes("ruff")) return true+ }+ }+ return false},}