Skip to content

Commit acc6eeb

Browse files
committed
fix(context-scout): handle empty-state cleanly (upstream issue darrenhinde#310)
When the Context Discovery Protocol's Step 4 returns `source: none`, context-scout was silently falling back to a generic `Glob: .opencode/**/*` and reporting "no .opencode directory exists". That misleads users (especially in monorepos) into thinking the project must have a literal `.opencode/` folder, when the actual problem is that no context bundle has been installed at any of the standard locations. Adds a dedicated "Pattern 5: No Context Found (Empty State)" section to the agent body with: - The full set of locations that were searched (mirrors protocol Step 4) - The three recovery options (`/install-context`, `.oac.json`, or proceed without) - A monorepo-specific note explaining context lookup happens at the launch directory - Two new "What NOT to Do" rules: never run a blanket glob when the protocol returns `source: none`, and never continue the downstream task without first surfacing the empty-state message. Backports the spirit of upstream issue darrenhinde#310 (darrenhinde#310).
1 parent 13b2852 commit acc6eeb

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

plugins/claude-code/agents/context-scout.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,59 @@ Return results in this structured format:
219219
5. Merge and rank by priority
220220
6. Return: unified list with clear domain labels
221221

222+
### Pattern 5: No Context Found (Empty State)
223+
224+
**Trigger**: Step 0 protocol returns `source: none` — none of `.oac.json`,
225+
`.claude/context/navigation.md`, `context/navigation.md`,
226+
`.opencode/context/navigation.md`, `~/.claude/context/navigation.md`, nor
227+
`{PLUGIN_ROOT}/context/navigation.md` exist.
228+
229+
**Do NOT** then run a generic glob like `Glob: .opencode/**/*` and report
230+
"no `.opencode` directory" — that misleads the user into thinking the
231+
project needs an `.opencode/` directory specifically. The protocol already
232+
covered every valid location.
233+
234+
**Do NOT** silently proceed with the user's downstream task (review, plan,
235+
etc.) without context. Surface the empty-state message first and let the
236+
main agent decide how to proceed.
237+
238+
**Required response** (mirror protocol Step 4):
239+
240+
```markdown
241+
# No Context Found
242+
243+
Searched all standard locations and found no project context:
244+
- `.oac.json` — not present
245+
- `.claude/context/navigation.md` — not found
246+
- `context/navigation.md` — not found
247+
- `.opencode/context/navigation.md` — not found
248+
- `~/.claude/context/navigation.md` — not found (no global install)
249+
250+
Pick one to proceed:
251+
252+
**Option 1 — Download standard context (recommended):**
253+
Run `/install-context` to fetch coding standards, security patterns,
254+
workflows, and more.
255+
256+
**Option 2 — Point to existing docs:**
257+
Create `.oac.json` at the project root:
258+
\`\`\`json
259+
{
260+
"version": "1",
261+
"context": { "root": "path/to/your/docs" }
262+
}
263+
\`\`\`
264+
265+
**Option 3 — Proceed without context:**
266+
Standards won't be applied; code quality may be inconsistent.
267+
268+
---
269+
270+
**Monorepo note:** opencode and Claude Code look for context at the
271+
directory you launch from. If each package needs its own context, run
272+
`/install-context` from each package root or set a per-package `.oac.json`.
273+
```
274+
222275
---
223276

224277
## What NOT to Do
@@ -230,6 +283,8 @@ Return results in this structured format:
230283
- ❌ Don't use Write, Edit, Bash, or Task tools — read-only only
231284
- ❌ Don't try to call other subagents — you work independently
232285
- ❌ Don't load the files yourself — return paths for the main agent to load
286+
- ❌ Don't run a generic `Glob: .opencode/**/*` (or any blanket glob) when the protocol returns `source: none`. The discovery protocol is the only valid discovery mechanism — fall through to the no-context message.
287+
- ❌ Don't continue with the user's downstream task when no context was found — return the empty-state message and let the main agent ask how to proceed.
233288

234289
---
235290

0 commit comments

Comments
 (0)