Skip to content

fix: strip opencode-run argv quotes before /loop fallback matching - #20

Merged
jkrandom-sudo merged 1 commit into
fix/issue-18-run-mode-fallbackfrom
fix/loop-run-quoted-text
Jul 30, 2026
Merged

fix: strip opencode-run argv quotes before /loop fallback matching#20
jkrandom-sudo merged 1 commit into
fix/issue-18-run-mode-fallbackfrom
fix/loop-run-quoted-text

Conversation

@jkrandom-sudo

Copy link
Copy Markdown
Owner

Stacked on #19 (review follow-up).

Problem

`opencode run "/loop 5m"` stores the user message with literal outer quotes — opencode re-quotes argv elements containing spaces, so `part.text` is `"/loop 5m"`, not `/loop 5m`. The fallback regex in #19 never matched real run-mode text, so every deterministic guard was still bypassed end-to-end. The #19 unit tests passed because they only simulated unquoted parts.

Evidence from a real session database:

```json
{"type": "text", "text": ""/loop */5 * * * * check something"", "synthetic": null}
```

(`synthetic: null` = the fallback never intercepted; a task was created from cron syntax.)

Fix

  • Export and reuse `stripOuterQuotes` before regex matching, mirroring `handleUserCommand`'s own quote handling
  • Continue scanning remaining text parts instead of returning on the first non-match

Tests

  • New regression tests: double-quoted and single-quoted command text; `/loop` appearing in a later text part
  • 176/176 tests pass, `tsc --noEmit` clean
  • End-to-end verified with the built plugin under a real `opencode run`: quoted cron input is rejected deterministically with no task created; a quoted valid interval (`/loop 1m ping the server`) creates the fixed task with the correct prompt

🤖 Generated with Claude Code

Review follow-up for #19: `opencode run "/loop 5m"` stores the user
message with literal outer quotes (argv elements containing spaces are
re-quoted), so the fallback regex /^\/loop.../ never matched real
run-mode text and every deterministic guard was still bypassed
end-to-end — the unit tests only simulated unquoted parts.

- reuse stripOuterQuotes (now exported) before matching, mirroring
  handleUserCommand
- scan remaining text parts instead of bailing on the first non-match
- regression tests for double- and single-quoted command text and for
  /loop appearing in a later text part (12/12 run-mode tests, 176/176
  overall, tsc clean)
- verified end-to-end against a real `opencode run` with the built
  plugin: quoted cron input is now rejected deterministically and no
  task is created; a quoted valid interval creates the fixed task

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jkrandom-sudo
jkrandom-sudo merged commit 2c512d8 into fix/issue-18-run-mode-fallback Jul 30, 2026
3 checks passed
jkrandom-sudo added a commit that referenced this pull request Jul 30, 2026
fix: land quoted-text fallback fix on main (PR #20 follow-up)
@jkrandom-sudo
jkrandom-sudo deleted the fix/loop-run-quoted-text branch July 30, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant