Skip to content

feat: auto-discover agent context sidecars#540

Open
alleneubank wants to merge 1 commit into
modem-dev:mainfrom
alleneubank:feat/agent-context-auto-discovery
Open

feat: auto-discover agent context sidecars#540
alleneubank wants to merge 1 commit into
modem-dev:mainfrom
alleneubank:feat/agent-context-auto-discovery

Conversation

@alleneubank

Copy link
Copy Markdown

Summary

  • auto-discover <repoRoot>/.hunk/agent-context.json across Hunk review inputs, including watch reloads
  • keep explicit/configured paths strict while treating the conventional sidecar as best-effort
  • show agent notes when context actually loads, add --no-agent-context, and exclude .hunk/ metadata from Git and Sapling working-tree review content
  • document the convention and include a minor Changeset

Why

Agent context is most useful when it is already present when a review opens. Requiring an agent or human to remember --agent-context on every invocation adds friction, especially in longer sessions and stacked reviews.

This keeps the existing range-based sidecar schema unchanged and adds a conventional repo-local filename. Explicit CLI/config paths still fail loudly; only zero-opt-in discovery is tolerant of a missing or stale file.

User impact

Bare review commands automatically load .hunk/agent-context.json when it exists. Loaded notes are visible by default, existing agent_notes / --no-agent-notes preferences still win, and --no-agent-context disables loading entirely.

Verification

  • bun run format:check
  • bun run lint
  • bun run typecheck
  • bun run test:theme-contrast (3 passed)
  • bun run changeset:status -- --since=upstream/main
  • focused agent/config/CLI/loader tests (153 passed)
  • bun run test:integration (52 passed)
  • bun run test (1,089 passed; 14 local process-level failures in Sapling and session-daemon tests; representative failures reproduce at the merge base)
  • bun run test:tty-smoke (local BSD script rejects the harness's -f flag; reproduced at the merge base)

Make agent review notes appear in `hunk diff` with no flags: when a repo has a
`<repoRoot>/.hunk/agent-context.json` sidecar, hunk auto-loads it as agent context.

- Auto-discover the conventional sidecar (best-effort: a missing or malformed
  conventional sidecar is silently skipped and never breaks a review).
- Add an `agent_context` config key (path resolved against the repo root) and a
  `--no-agent-context` opt-out. Precedence: `--no-agent-context` > `--agent-context <path>`
  > config `agent_context` > conventional `.hunk/agent-context.json`. Explicit paths stay strict.
- Show agent notes by default when a sidecar loads (`--no-agent-notes` / `agent_notes` still win).
- Resolve discovery in a single config seam so it flows to both loading and the `--watch`
  signature; re-resolution is idempotent so watched reloads stay best-effort.
- Exclude hunk's own `.hunk/` metadata from untracked working-tree review noise (git + sl).
- Docs (README, agent-workflows, hunk-review skill) and a changeset.

Sidecar schema is unchanged (range-based `oldRange`/`newRange`).
@alleneubank
alleneubank marked this pull request as ready for review July 14, 2026 16:41
@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

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