penpot/.serena/memories/scripts/paren-repair.md
Andrey Antukh 992170a9a4 🐛 Remove OpenCode V1 plugin support
Remove the legacy @opencode-ai/plugin import and V1 server export so
the local plugin loads under OpenCode V2 without project dependencies.

Add a focused smoke test for the V2 export and tool registration, and
update the related script memories.

AI-assisted-by: space-bunny-free
2026-09-23 18:53:25 +02:00

1.3 KiB

Paren-Repair

scripts/paren-repair fixes mismatched parentheses, brackets, and braces in Clojure/ClojureScript files, then reformats them with cljfmt.

When to use

  • After LLM edits introduce broken delimiters — proactively run it on files you just touched.
  • When lint (clj-kondo), the Clojure compiler, or shadow-cljs report syntax errors mentioning mismatched/unclosed delimiters, reader errors, or unexpected EOF.
  • Before running lint/format checks — delimiter errors make linter output misleading. Fix them first, then lint.

How to use (CLI)

# File mode (in-place fix + format)
bb scripts/paren-repair path/to/file.clj

# Pipe mode (stdin → fixed code to stdout)
echo '(def x 1' | bb scripts/paren-repair

# Help
bb scripts/paren-repair --help

bb must be invoked from the repo root so the path scripts/paren-repair resolves.

Native Tool Available (OpenCode V2)

A native OpenCode V2 tool paren-repair is available. It is defined in .opencode/plugins/penpot.js and registered through setup(). The LLM can call it directly with:

  • files: comma-separated file paths to fix (a string, not an array)
  • code: Code string to fix via stdin

Example usage by the LLM:

paren-repair(files="src/foo.clj, src/bar.cljs")
paren-repair(code="(defn foo [x")