agent-shell-parser 0.4.2

Shared parsing substrate for agent hook binaries — JSON input, shell tokenization
Documentation

prodagent

Agent-agnostic productivity hooks for jj-colocated repositories.

When an AI coding agent works in a jj repo, it'll instinctively reach for git commit, git push, etc. These hooks intercept that, block the git command, and tell the agent what jj command to use instead. They also handle workspace isolation so parallel agent sessions don't step on each other.

What's in here

Crate Purpose
agent-jj Single binary with three subcommands: guard (blocks git in jj repos), workspace (creates jj workspaces), cleanup (removes workspaces on teardown)
agent-shell-parser Shared library — tree-sitter-bash parsing, config-driven wrapper resolution, CWD tracking, hook I/O types

The guard handles compound commands (&&, ||, ;, |), command substitutions ($()), wrapper chains (sudo env time git commit), and various bypass attempts. It uses a config-driven approach — all command knowledge lives in config/commands.json, not hardcoded.

Requirements

  • jj-cli >= 0.40.0
  • Rust toolchain (for building from source)

Install

just install

Or directly:

cargo install --path crates/agent-jj

Hook registration (Claude Code)

Add to ~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          { "type": "command", "command": "agent-jj guard" }
        ]
      }
    ],
    "WorktreeCreate": [
      {
        "hooks": [
          { "type": "command", "command": "agent-jj workspace" }
        ]
      }
    ],
    "WorktreeRemove": [
      {
        "hooks": [
          { "type": "command", "command": "agent-jj cleanup" }
        ]
      }
    ]
  }
}

License

MIT OR Apache-2.0