Metadata-Version: 2.5
Name: agentledger-cli
Version: 0.1.0
Summary: Report Claude Code, Cursor, Gemini CLI and Cortex Code sessions to the AgentLedger Snowflake Native App.
Requires-Python: >=3.10
Requires-Dist: snowflake-connector-python>=3.12
Description-Content-Type: text/markdown

# agentledger

Reports your Claude Code, Cursor CLI, Gemini CLI and Cortex Code sessions to the AgentLedger Snowflake
Native App, so your team sees agent cost, prompts and tool use per developer, repo, branch and
pull request.

```bash
uv tool install agentledger-cli    # or: pipx install agentledger-cli
agentledger install
```

`install` checks that your Snowflake connection can report to the app, then sets up every agent
it finds:

| Agent | What it adds |
|---|---|
| Claude Code | `Stop` and `SessionEnd` hooks in `~/.claude/settings.json` |
| Cursor CLI | `stop` and `sessionEnd` hooks in `~/.cursor/hooks.json` |
| Gemini CLI | `AfterAgent` and `SessionEnd` hooks in `~/.gemini/settings.json` (`$GEMINI_CLI_HOME` moves it); Gemini CLI runs hooks in trusted folders |
| Cortex Code | the app's git plugin (`cortex plugin install <APP>.PLUGINS.AGENTLEDGER`); Snowflake records its sessions already |

After each turn the hook queues the session and returns at once. A background process loads it
into the app over your own connection, at most every two minutes per agent, so a session is
always stored as yours. Logs are in `~/.cache/agentledger/`.

## Requirements

- A Snowflake connection in `~/.snowflake/connections.toml` that works without a prompt (key
  pair or cached SSO), whose role an admin has granted the reporter role:
  `GRANT APPLICATION ROLE AGENTLEDGER.APP_REPORTER TO ROLE <role>;`
- Python 3.10 or later.

## Options

```bash
agentledger install --connection work --role DEVELOPER   # pick the connection and role
agentledger install --only ~/work                        # report only sessions in these folders
agentledger install --app AGENTLEDGER_PROD               # the app's name, if it isn't AGENTLEDGER
agentledger status                                       # what's set up, and each agent's latest report
agentledger upload claude ~/.claude/projects/*/*.jsonl   # report earlier sessions
agentledger upload gemini ~/.gemini/tmp/*/chats/*.jsonl
agentledger uninstall                                    # remove the hooks and the plugin
```

Settings live in `~/.snowflake/agentledger.json`, which the Cortex Code plugin reads too.
