Skip to content

feat(agent-guard): add harness-neutral --check and --exec CLI modes#765

Open
justinmclean wants to merge 1 commit into
apache:mainfrom
justinmclean:harness-guard-exec-mode
Open

feat(agent-guard): add harness-neutral --check and --exec CLI modes#765
justinmclean wants to merge 1 commit into
apache:mainfrom
justinmclean:harness-guard-exec-mode

Conversation

@justinmclean

Copy link
Copy Markdown
Member

Summary

Any runtime without a harness-specific hook API can now enforce guard rules by wrapping command execution with the new entry points:

  • --check <cmd…> — inspects the command; exits 0 (allow, silent) or 2 (deny, reason on stdout). Shell scripts can capture the reason and gate execution on the exit code.
  • --exec <cmd…> — inspects then exec-replaces this process with the command on allow; exits 2 with the deny reason on stderr on deny. Suitable as a transparent PATH-shadowing wrapper or shell alias for git and gh.

Both modes use the same dispatch() core as the Claude Code and OpenCode adapters, so guard decisions are identical across all paths.

Also adds __main__.py so the package is runnable as python -m agent_guard, and documents the new enforcement path in the README under a "Harness-neutral path (any runtime)" wiring section.

Validation: all 74 agent-guard tests pass; vendor-neutrality score remains 100% (agent-guard stays portable).

Generated-by: Claude (claude-sonnet-4-6)

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other:

Test plan

  • prek run --all-files passes
  • For Python packages touched: uv run pytest / ruff check / mypy passes
  • For Groovy bridges touched: command-line invocation tested end-to-end
  • For skill changes: eval suite passes for the affected skill
    (PYTHONPATH=tools/skill-evals/src python3 -m skill_evals.runner tools/skill-evals/evals/<skill>/)
  • For skill behaviour changes: a new or updated eval fixture is included in this PR
    (a regression test for the bug fixed / the behaviour added — see CONTRIBUTING.md)
  • Other:

Any runtime without a harness-specific hook API can now enforce guard
rules by wrapping command execution with the new entry points:

- `--check <cmd…>` — inspects the command; exits 0 (allow, silent) or
  2 (deny, reason on stdout). Shell scripts can capture the reason and
  gate execution on the exit code.
- `--exec <cmd…>` — inspects then exec-replaces this process with the
  command on allow; exits 2 with the deny reason on stderr on deny.
  Suitable as a transparent PATH-shadowing wrapper or shell alias for
  `git` and `gh`.

Both modes use the same `dispatch()` core as the Claude Code and
OpenCode adapters, so guard decisions are identical across all paths.

Also adds `__main__.py` so the package is runnable as `python -m
agent_guard`, and documents the new enforcement path in the README
under a "Harness-neutral path (any runtime)" wiring section.

Validation: all 74 agent-guard tests pass; vendor-neutrality score
remains 100% (agent-guard stays portable).

Generated-by: Claude (claude-sonnet-4-6)
@justinmclean justinmclean self-assigned this Jul 6, 2026

import pytest

import agent_guard
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.

2 participants