Repository navigation
docs: tell writing agents how backticks and heredocs fail - #109
Merged
Merged
Conversation
A session investigating an "execute problem with backticks" turned out to be ordinary JS: a backtick nested directly inside a template literal ends it early, so `` `outer `in` `` is a syntax error rather than a nested string. Verified across Node and the code sandbox, which agree exactly. The second failure is the one with a track record of silent damage: a shell heredoc expands `\n` and backticks and corrupts the written file, with an error message that does not name the cause. Added an Escaping section to the three agents that hold `shell: allow` and author code — coder, tester, architect. Left nexus-orchestrator alone: it grants only `subagent`, and it is instructed never to write code, so the rule would describe an error it cannot commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an
Escapingsection to the three agents that holdshell: allowand author code —nexus-coder,nexus-tester,nexus-architect.Two failure modes, in order of how much damage they do:
1. Nested backtick in a template literal (loud). A backtick placed directly inside a template literal terminates it early, so
`outer `in`parses as a binary expression andouterbecomes an undefined identifier. Escape it (`outer \`in\``) or inject it viaString.fromCharCode(96).2. Shell heredocs (silent). A heredoc expands
\nand backticks and writes a corrupted file, with an error message that does not name the cause. Usewrite/edit, which pass content whole.Why
This started as an investigation into an
executetool bug. It isn't one. I ran six template-literal cases through both Node and the code sandbox, and they agree exactly — the sandbox is correct JS semantics, and the one failing case is invalid JS that Node also rejects. The orchestrator's own guidance already carries the "fails loudly, not silently" framing, so the fix is prevention rather than repair.The heredoc case is the one worth guarding. It bit twice in a single session — a test file lost its
\nescapes and Node died withInvalid or unexpected tokenon the line after a backtick run. That failure is destructive and misattributed: the reported line is not the broken line.What is deliberately not done
nexus-orchestratoris unchanged. It grants onlysubagentin its frontmatter and states at line 44 that it never writes code. An escaping rule there would instruct it about a mistake it is structurally unable to make, at the cost of diluting a 240-line file that is already dense with process rules.No
package.jsonbump..github/workflows/release.yml:52-56sets the version from the release tag vianpm version "$VERSION" --no-git-tag-version, so a hand-edit would be overwritten on release.~/.config/opencode/agents/not synced.assets/agents/is canonical (nexusAgentsDir(), index.ts:764). Note thatNEXUS_SUBAGENT_FILES(index.ts:769) excludesnexus-orchestrator.md, which is instead written only if absent (index.ts:925-926) — so a local edit to that one file would survive a re-setup while these three would be overwritten.Verification
Clean — biome over 92 files,
tsc --noEmit, and the dashboard inline-script parse check all pass. These are markdown-only changes, so no build or test behaviour is affected.Reviewer note
Worth a judgement call rather than a rubber stamp: if you think the heredoc rule alone earns its place in three files, the template-literal bullet could be dropped from the architect variant — it is the weakest fit, since the architect returns a direction rather than code.