Skip to content

Agent activation: rewrite AGENTS.md snippet/skill and fix CLI traps agents hit - #280

Merged
lemon07r merged 4 commits into
masterfrom
devin/1788955616-agent-activation-cli-fixes
Sep 10, 2026
Merged

Agent activation: rewrite AGENTS.md snippet/skill and fix CLI traps agents hit#280
lemon07r merged 4 commits into
masterfrom
devin/1788955616-agent-activation-cli-fixes

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Driven by the 40-cell agent benchmark analysis: activation was a one-shot first-search decision (all 18 activations happened at or before the first search; no skipped cell recovered), the dominant miss was "acknowledge Vera, then run grep", and the two hard CLI failures (--path /abs/path matching nothing, vera grep ... -n erroring) caused agents to abandon Vera for the rest of the cell. Successful calls were 21/21 useful, so nothing in ranking changes here.

Instructions (AGENTS_MD_SNIPPET in agent.rs, skills/vera/SKILL.md)

  • Opens by binding the first search to Vera (vera overview in an unfamiliar repo, then vera search) and only allows grep after a Vera miss — the old snippet's "before reading files to answer 'where is X'..." was conditional and agents quoted it as permission to skip.
  • Routes by question shape: behavior → search; named symbol → structural definitions / references (the symbol-anchored questions were the ones bypassed for grep); exact text → grep; enumeration → structural routes/env/impls.
  • Replaces "try 2-3 varied queries" with the observed recovery path (usage-site hit → structural definitions <symbol>), adds read-diet guidance (cite from the hit, open files only for missing lines), states --path is root-relative, and is honest about dependency sources not being indexed.
  • AGENTS_MD_SNIPPET_INTRO updated accordingly. Files carrying the vera:begin/end markers are refreshed by vera agent sync as before; marker-less sections with the old wording are left alone (already the case for any prior text change). benchmarks/agent-bench/run.py extracts the const by its declaration form, which is unchanged.

CLI fixes (vera-cli)

  • prepare_indexed_search: absolute --path entries under the index root are rewritten to root-relative (/repo/src/authsrc/auth; root itself is dropped; outside-root entries left for path_filter_hint). absolute_path_filter_rewrite(pattern, roots) -> Keep | Drop | Rewrite.
  • find_index_root(cwd): .vera/ is now discovered by walking up parent directories, so vera search from a subdirectory works (note: using index at <root> on stderr). MISSING_INDEX_MESSAGE const → missing_index_message(cwd) with a paste-ready vera index . instruction; search.rs auto-index offer uses the same discovery.
  • vera grep: limit is num_args = 0..=1, default_missing_value = "20", so a habitual trailing -n is accepted; -n 7 / --limit 30 unchanged. main.rs uses Cli::try_parse() and appends a one-line hint when a clap error mentions --limit (e.g. vera grep -n foo), otherwise err.exit() as before.
  • Stale-index warning is deduped per index via .vera/stale-warning.json (same summary within 600 s is not reprinted; VERA_STALE_WARNING_ALWAYS=1 bypasses). The benchmark saw the identical warning 26 times in one session.
  • Binary-update hint prints only when stderr is a terminal (skill auto-sync unchanged).
  • Reranker per-attempt retry log warn!debug!; the single "reranker unavailable, returning unreranked results" warn at the degrade site remains.

Verification

cargo test --workspace, cargo clippy --workspace --all-targets -- -D warnings, cargo fmt --all -- --check all clean; new unit tests for path rewrite, index walk-up, stale dedupe decision, hint gating, and -n parsing.

Link to Devin session: https://app.devin.ai/sessions/6d470c7641904649a87fe6dcff67145e
Open in Devin Desktop: https://app.devin.ai/desktop/session/6d470c7641904649a87fe6dcff67145e?variant=devin
Requested by: @lemon07r


Summary by cubic

Rewrites the Vera agent instructions and fixes CLI traps that made agents abandon Vera, so the first search in a repository goes through Vera and recovery paths are explicit. No ranking behavior changes; successful calls are unaffected.

Instructions

  • AGENTS.md snippet and SKILL.md now open by binding the first search to Vera (vera overview then vera search), and grep is allowed only after a Vera miss.
  • Routes by question shape: behavior → search, named symbol → structural definitions/references, exact text → grep, enumeration → structural routes/env/impls.
  • Adds recovery guidance (usage-site hit → structural definitions <symbol>), read-diet advice, and states --path is root-relative.

CLI fixes

  • Absolute --path entries under the index root are rewritten to root-relative (case-insensitively on Windows); find_index_root walks up parents so commands, vera overview, vera update, and vera stats work from subdirectories, and it ignores bare .vera/ dirs without a real index.
  • vera grep accepts a bare trailing -n as the default limit; clap errors mentioning --limit get a one-line hint that doesn't fire on --help.
  • Stale-index warnings are deduped per index (10-minute window, bypass with VERA_STALE_WARNING_ALWAYS=1); binary-update hint only prints on a terminal.
  • Reranker per-attempt retry log level lowered to debug!.

Written for commit 92c5b11. Summary will update on new commits.

Review in cubic


Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment thread skills/vera/SKILL.md
Comment thread skills/vera/SKILL.md Outdated
Comment thread crates/vera-cli/src/helpers.rs Outdated
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Executed CLI runtime checks on 233eb1e with VERA_LOCAL=1 and an isolated indexed repository.

  • Absolute --path filters: subtree / root / outside-root behavior as intended.
  • Ancestor-index discovery for search, grep, references, and overview; results stay root-relative.
  • Non-TTY missing-index error exits 1 with the paste-ready message, no prompt.
  • Bare trailing -n defaults to 20; -n 3 returns 3; leading -n TODO gets clap's error plus the hint; --help/--version exit 0.
  • Stale warning printed once, suppressed on the repeat, restored with VERA_STALE_WARNING_ALWAYS=1, cleared by vera update ..
  • No version hint in piped stderr (best-effort: a newer release was not forced).
  • Agent snippet: interactive install writes the new marked snippet; non-TTY agent sync migrates an old marked snippet and preserves surrounding text byte-for-byte, idempotent.

Pre-existing issue found (not from this PR): vera agent install --client agents --scope project with a terminal stdin but piped stdout/stderr installs the skill, then exits 1 with Error: not connected and no AGENTS.md — should_offer_snippet_prompt only gates on stdin being a TTY, and cliclack needs stderr too. Unchanged by this PR; worth a follow-up.

Managed snippet migration
Before sync After sync
Old managed snippet New snippet, custom instructions preserved
Runtime evidence and installation failure
Ancestor-index retrieval Mixed-TTY install failure
Search and references from nested directory Install exits with not connected

Linux only; Windows path-case behavior not exercised.

Written by Devin

Review follow-ups on the agent-activation changes:

- find_index_root now requires a real index (metadata.db present), not a
  bare .vera directory: the legacy Vera home (~/.vera) and stray or
  partially created directories must never match, or read commands would
  fabricate an empty metadata store inside them and silently return
  nothing instead of the clear no-index error.
- vera update resolves the ancestor index root like the read commands do,
  so 'vera update .' works from subdirectories instead of failing with
  no-index, or worse, creating a nested partial index that shadows the
  repository root's index for that subtree. The path is canonicalized
  before the walk so '.' resolves its real parents.
- vera stats resolves the ancestor index root, matching every other read
  command; the agent skill recommends 'vera stats --json'.
- The -n hint in main.rs no longer fires on --help output: help errors
  render the full help text (which lists --limit for grep, search,
  structural, and references), so the hint printed a spurious line after
  a perfectly good help screen.
- Reworded the trailing bare -n help text (a leading '-n' before the
  pattern still errors, by design, with the hint pointing at --limit).
- AGENTS.md snippet and SKILL.md updated: 'vera update .' from any
  directory refreshes the repository root's index.
- Document the stale-warning dedupe window and the
  VERA_STALE_WARNING_ALWAYS=1 bypass in the troubleshooting docs.

Verified end-to-end on a scratch repo: unindexed dir under a legacy
~/.vera home gets the no-index error and ~/.vera stays untouched;
update/grep/stats from a nested subdirectory all resolve the repository
root's index; vera grep --help prints no hint.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: eb6eb891-a408-4688-8efd-b9c309f22d0d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lemon07r

Copy link
Copy Markdown
Collaborator

Pre-merge review (independent read of the full diff plus end-to-end verification) found two high-severity regressions, fixed in b71e13a before merging:

  1. find_index_root accepted any .vera directory up-tree. On machines with the legacy Vera home (~/.vera), every unindexed directory under $HOME resolved to it as an index root: detect_staleness would fabricate a junk metadata.db inside ~/.vera, discovery-walk the whole home tree, and commands would silently return empty results instead of the clear no-index error. find_index_root now requires metadata.db to be present. Verified end-to-end: an unindexed dir under a legacy ~/.vera home now gets the no-index error and ~/.vera stays untouched.

  2. vera update . did not resolve the ancestor index root while all read commands did: from a subdirectory it failed with no-index, and following the snippet's vera index . fallback would have created a nested partial index shadowing the repo root's index. update now canonicalizes the path and walks up like the read commands. Verified end-to-end: update/grep/stats from a nested subdirectory all resolve and refresh the repository root's index; no nested .vera is created.

Also fixed in the same commit: the -n hint no longer misfires on --help (help errors render the full help text, which lists --limit), vera stats walks up like other read commands, the trailing--n help wording is precise, and the stale-warning dedupe window plus VERA_STALE_WARNING_ALWAYS=1 are documented. Full workspace tests, clippy -D warnings, and fmt are clean on the merge head.

@lemon07r
lemon07r merged commit 2e55b19 into master Sep 10, 2026
5 checks passed
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