17 lines
1.3 KiB
Markdown
17 lines
1.3 KiB
Markdown
# Code Review: fix-register-guards
|
|||
|
|
|
||
|
|
## Summary
|
||
|
|
Fixes three compounding bugs that prevented OpenCode guard registration.
|
||
|
|
|
||
|
|
## Findings
|
||
|
|
- **Config detection (5a)**: Correctly checks `.json` first, then `.jsonc`. The `for` loop with `break` ensures the first match wins.
|
||
|
|
- **Config key (5b)**: Now writes to `plugin` (singular), preserving existing entries via `cfg.setdefault('plugin', []).append(...)`. This matches the actual opencode config schema.
|
||
|
|
- **JSONC parsing (5c)**: The `re.sub(r'//.*?$', '', text)` regex strips `//` comments. This is a simple approach that works for line comments but does NOT handle `/* */` block comments or `//` inside string values. However, opencode config files typically only use line comments, so this is sufficient. A more robust approach would use `json5` if available.
|
||
|
|
- **Manual hint**: Updated to use `plugin` (singular) — consistent with the actual fix.
|
||
|
|
|
||
|
|
## Minor Note
|
||
|
|
The comment-stripping regex could incorrectly strip `//` inside string values (e.g., a URL like `"http://..."`). However, the opencode config is unlikely to contain such values, and this is strictly better than the previous behavior (complete failure on any comment).
|
||
|
|
|
||
|
|
## Verdict
|
||
|
|
APPROVED — no blocking issues. The comment-stripping limitation is noted but acceptable for this use case.
|