Resolve CLAUDE.md includes for OpenCode provider#2165
Conversation
What was the problem?NanoClaw’s OpenCode provider was supposed to give OpenCode the same agent instructions that Claude gets. Those instructions are stored in Those lines mean: “load the contents of these other files here.” The bug was that the OpenCode provider didn’t load those files. It just copied the literal So OpenCode was getting something like: instead of the real instructions inside those files. That means OpenCode could miss important behavioral instructions, capabilities, safety rules, or module-specific guidance. Why did it happen?Because the OpenCode provider treated The old flow was basically: That works only if But in this branch, So the mismatch was: That’s the root cause. What was the fix?The PR adds a small include resolver before injecting Now the flow is: The important part is that this is done inside NanoClaw before OpenCode sees the prompt. So instead of OpenCode receiving: it receives the actual content of What changed in the code?The PR changes three files: 1.
|
|
I tested #2153 locally against the same issue. #2153 fixes the problem at a better layer by removing raw This PR is still a valid alternative approach, but it duplicates the goal. I’m happy to close this in favor of #2153 if that’s the preferred direction. |
|
@CopyPasteFail Thanks for the PR. Closing in favor of #2153 as suggested |
Summary
Fixes OpenCode provider prompt construction so CLAUDE.md include references are resolved before being injected into the prompt.
Previously, the provider read
/workspace/agent/CLAUDE.mdas plain text. When that file contained Claude-style include lines like:those lines were sent literally to OpenCode instead of the referenced file contents.
This change adds local include resolution for CLAUDE.md before prompt wrapping.
Behavior
@./file.mdValidation
git diff --check: passpnpm exec eslint src/opencode-provider-includes.test.ts: passpnpm typecheck: passpnpm exec vitest run src/opencode-provider-includes.test.ts: passpnpm test: pass, 24 files / 203 testsNote:
pnpm lintcurrently fails on unrelated pre-existing files insrc/channels/cli.ts,src/container-runner.ts, andsrc/session-manager.ts. This PR does not touch those files.