Skip to content

fix(opencode): strip backticks from plugin reminder to prevent silent command substitution - #1415

Closed
WSHAPER wants to merge 1 commit into
Graphify-Labs:v8from
WSHAPER:fix/opencode-plugin-backticks
Closed

WSHAPER wants to merge 1 commit into
Graphify-Labs:v8from
WSHAPER:fix/opencode-plugin-backticks

Conversation

@WSHAPER

@WSHAPER WSHAPER commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #1413.

Summary

The opencode plugin template shipped by graphify install --platform opencode embedded the reminder string with backticks around graphify query "<question>". Because the plugin prepends echo "<reminder>" && <cmd> to the user's bash command, those backticks triggered bash command substitution — every grep/rg/find invocation silently ran graphify query "<question>" and substituted its output (No matching nodes found.) into the middle of the reminder text the agent sees.

This both (a) corrupted every bash search's tool output with graphify noise, and (b) actually spawned a graphify process + loaded graph.json + ran a BFS traversal with the literal token <question> on every search.

Root cause

graphify/__main__.py line 1394 (v0.8.44):

'echo "[graphify] knowledge graph at graphify-out/. For focused questions, run \`graphify query \\"<question>\\"\` (scoped subgraph...) " && '

The literal ` chars inside the JS string become live backticks when the JS runs inside an echo "..." shell command — bash evaluates them as command substitution.

Fix

Strip the backticks from the reminder string. Plain words render fine in opencode's TUI; markdown code spans were never useful in shell echo output anyway.

Also adds a guard comment in the JS template (// IMPORTANT: keep the reminder string free of backticks and $(...) constructs) so a future editor doesn't reintroduce the bug by accident.

Verification

  • New regression test test_opencode_plugin_reminder_has_no_backticks parses the generated plugin's echo "..." string and asserts it contains no ` and no $(. The test fails on the pre-fix code (it finds the backticks) and passes after the fix.
  • All 10 existing opencode install tests still pass; no regressions across the broader install/roundtrip/upgrade/reference suites (156 tests pass).

Symptom before fix

Real session output, where bash substituted graphify query "<question>" → No matching nodes found.:

[graphify] knowledge graph at graphify-out/. For focused questions, run No matching nodes found. (scoped subgraph, usually much smaller than GRAPH_REPORT.md) instead of grepping raw files. Read GRAPH_REPORT.md only for broad architecture context.

Notice run No matching nodes found. in the middle of the sentence.

Symptom after fix

[graphify] knowledge graph at graphify-out/. For focused questions, run graphify query with your question (scoped subgraph, usually much smaller than GRAPH_REPORT.md) instead of grepping raw files. Read GRAPH_REPORT.md only for broad architecture context.

Bonus

The same anti-pattern (backticks inside bash echo strings) likely exists in other skill templates. Out of scope for this PR but worth a separate audit.

… command substitution (Graphify-Labs#1413)

The opencode plugin template embedded the reminder string with backticks
around `graphify query "<question>"`. Because the plugin prepends
`echo "<reminder>" && <cmd>` to the user's bash command, those backticks
triggered bash command substitution: every grep/rg/find invocation silently
ran `graphify query "<question>"` and substituted its output
("No matching nodes found.") into the reminder text shown to the agent.

This both corrupted tool output with graphify noise, and actually spawned
a graphify process + loaded graph.json + ran a BFS traversal with the
literal token <question> on every search.

Fix: remove the backticks. Adds a guard comment in the template so future
editors don't reintroduce the bug, and a regression test that asserts the
reminder string contains no backticks and no $() constructs.
@safishamsi

Copy link
Copy Markdown
Member

Merged into v8 as 2323ce1 (cherry-picked onto current v8). Verified the backtick command-substitution fix + the added test. Full suite green. Thanks @WSHAPER!

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.

bug: opencode plugin reminder string has unescaped backticks → bash command substitution silently runs 'graphify query "<question>"' on every search

2 participants