@agenttrail/cli 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,11 +12,24 @@ nothing.
12
12
  Claude Code and Cursor are connected by different means, because they expose different
13
13
  things:
14
14
 
15
- - **Claude Code** points **Claude Code's native OpenTelemetry exporter** at the
16
- agenttrail ingest endpoint. This is a **per-project, opt-in config-writer +
17
- project-identity resolver** — not an MCP server, not an in-process SDK, and not a
18
- long-running process. It writes the correct OTel environment block into your
19
- project's `.claude/settings.json`; Claude Code's own bundled exporter ships the spans.
15
+ - **Claude Code** is connected per project, opt-in — not an MCP server, not an in-process
16
+ SDK, and not a long-running process. Claude Code ignores the OpenTelemetry exporter
17
+ variables in a repository's `.claude/settings.json` and `.claude/settings.local.json`, so a
18
+ per-project `setup` registers `Stop` and `SessionEnd` hooks in `.claude/settings.json`
19
+ instead. After each turn they run `agenttrail capture --agent claude` in the background,
20
+ which uploads the session from its local transcript (the same mapping, ids and edge scrub
21
+ as `backfill --import`; a turn already sent is not sent again). `setup --global` keeps
22
+ pointing Claude Code's own OpenTelemetry exporter at AgentTrail from
23
+ `~/.claude/settings.json`, and a project-only install on such a machine leaves delivery to
24
+ it. The upload logs each run to `~/.agenttrail/session-upload.log`; `status` says which path
25
+ delivers this project's sessions and when the last upload succeeded.
26
+ A project connected by an earlier `setup` (device login or `--key`) gets the hooks by itself at
27
+ its next Claude Code session start, through the SessionStart refresh hook, as long as the repo
28
+ does not track `.claude/settings.json`. A `--team` install, a repo that tracks that file, and a
29
+ session start where `npx` can't reach the registry don't heal: re-run
30
+ `npx -y @agenttrail/cli@latest setup --agent claude` there. `status` says `NOT SENT` until then.
31
+ The upload sends prompt and tool content only when no scope Claude Code honours (managed,
32
+ user or local settings, or the environment) switches it off.
20
33
  - **Cursor** exports no traces you can redirect, so this package supplies the
21
34
  runtime instead: `setup --agent cursor` registers **Cursor hook entries** in the
22
35
  project's `.cursor/hooks.json` that run a small capture hook, which answers `{}`,
@@ -60,6 +73,39 @@ npx -y @agenttrail/cli@latest setup --agent claude --org <your-org-uuid>
60
73
  npx -y @agenttrail/cli@latest status --agent claude
61
74
  ```
62
75
 
76
+ ### What `setup --agent claude` writes in your repo
77
+
78
+ The default setup keeps everything about **this machine** out of git, so a trial run does
79
+ not leave a change for you to commit or a flag for your teammates to inherit:
80
+
81
+ - **Real-time enforcement** (the policy endpoints, the token and the
82
+ `AGENTTRAIL_PEP_ENFORCE` switch) and the ingest token go into
83
+ `.claude/settings.local.json`.
84
+ - `.claude/settings.local.json` and `.agenttrail.json` (and the temporary copies a write
85
+ leaves for a moment) are kept out of git with lines in the repo's own `.git/info/exclude`,
86
+ which git reads like `.gitignore` but never tracks. Setup checks with git that they are
87
+ ignored, and never edits `.gitignore`.
88
+ - The **telemetry settings** (`CLAUDE_CODE_*`, `OTEL_*` and the `SessionStart` refresh hook)
89
+ still go into `.claude/settings.json`, which is usually committed. Apart from moving an
90
+ older install's enforcement keys out of that file (below), that is the only tracked change
91
+ setup makes today. A `.agenttrail.json` the repo already tracks is left as it is.
92
+
93
+ If the repo **already tracks** `.claude/settings.local.json` (or a `.gitignore` rule
94
+ re-includes it), that file would carry your credential into git, so setup **writes nothing**
95
+ and stops with the reason and the fix: `git rm --cached .claude/settings.local.json` and
96
+ commit (or remove the re-including rule), then run setup again. AgentTrail is not connected in
97
+ that repo until then. The same applies to `.agenttrail.json` when it would hold an API key.
98
+
99
+ `--team` is the explicit "write committable config" path: key-free settings meant to be
100
+ committed, and never the `AGENTTRAIL_PEP_ENFORCE` switch or a token.
101
+
102
+ An older version wrote the enforcement settings into `.claude/settings.json` and appended
103
+ lines to `.gitignore`. Running `setup` again moves the settings to
104
+ `.claude/settings.local.json` once enforcement is verified again (if `settings.json` is
105
+ committed, commit that change), and removes the `.gitignore` lines it added if they were never
106
+ committed. `logout` removes the enforcement settings from both files; the
107
+ `.git/info/exclude` lines stay, because the files they hide can still hold your own settings.
108
+
63
109
  ## Cursor (`--agent cursor`)
64
110
 
65
111
  ```bash
@@ -75,11 +121,11 @@ What differs from `--agent claude`:
75
121
 
76
122
  | | Claude Code | Cursor |
77
123
  |---|---|---|
78
- | How spans are produced | Claude Code's own exporter, configured by us | our capture hook + a detached sender, both under `~/.agenttrail/cursor/runtime/` |
79
- | What is written in the repo | `.claude/settings.json` (+ `.claude/settings.local.json`) | `.cursor/hooks.json`, kept out of git via `.git/info/exclude` |
124
+ | How spans are produced | per project: our `Stop` / `SessionEnd` hooks upload each session from its transcript; `--global`: Claude Code's own exporter, configured by us | our capture hook + a detached sender, both under `~/.agenttrail/cursor/runtime/` |
125
+ | What is written in the repo | the capture hooks and resource attributes in `.claude/settings.json`; everything per-machine in `.claude/settings.local.json`, kept out of git via `.git/info/exclude` | `.cursor/hooks.json`, kept out of git via `.git/info/exclude` |
80
126
  | State | `~/.agenttrail/credentials.json` | `~/.agenttrail/cursor/` (its own credential, registry, queue and checkpoint) |
81
127
  | Auth | device login, or `--key` / `--team` for CI | device login only — `--key`, `--team` and `--global` are refused |
82
- | Content capture | scrubbed server-side | scrubbed **on this machine** before it is queued, then server-side as well |
128
+ | Content capture | **on by default** (`--no-capture-content` opts out); scrubbed at ingest | off by default (`--capture-content` turns it on); scrubbed **on this machine** before it is queued, then server-side as well |
83
129
  | Cost | tokens × the provider's list price | not computed: Cursor sessions read "Not reported by Cursor" |
84
130
  | Real-time blocking | the enforcement plugin | from Cursor 3.21.16, installed by `setup`; an older Cursor is captured only |
85
131
 
@@ -121,7 +167,8 @@ Each runs as `npx -y @agenttrail/cli@latest <command> --agent <claude|cursor|cod
121
167
  | `--api-endpoint <url>` | API base URL for the device-auth flow (`setup`/`login`/`--refresh`/`logout`). Accepts a **bare origin** (e.g. `https://api.agenttrail.sh` or `http://localhost:3000`); the CLI derives the `/api/v1` base internally (idempotent if you pass `…/api/v1`). Precedence: flag → `$AGENTTRAIL_API_ENDPOINT` → prod default (`https://api.agenttrail.sh`). Distinct from `--endpoint` (ingest). |
122
168
  | `--team` | Write committable, **key-free** config (key supplied per-dev via env). Refused by `setup --agent cursor`. |
123
169
  | `--global` | Configure `~/.claude` + `~/.agenttrail/config.json` (per-user; prints a privacy warning). Refused by `setup --agent cursor` — Cursor is per project only. |
124
- | `--capture-content` | Turn ON prompt/tool-content capture. Ingest scrubs it server-side under your org's config; with `--agent cursor` it is also scrubbed **on this machine** before it is queued — the scrubber reads the whole value, and the 8192-character cap applies to what is kept afterwards. Scrubbing is shape-based, so it reduces exposure rather than guaranteeing none; the cap is a size limit on what is stored, not a safety measure. |
170
+ | `--no-capture-content` | `--agent claude`: turn OFF prompt/tool-content capture, which is **on by default** (prompts, commands, file paths and tool output). Setup writes the three content flags as `"0"`, and a later rerun without a flag keeps that opt-out. |
171
+ | `--capture-content` | `--agent claude`: turn capture back on after `--no-capture-content` (on is already the default). `--agent cursor`: turn ON prompt/tool-content capture. Ingest scrubs it server-side under your org's config; with `--agent cursor` it is also scrubbed **on this machine** before it is queued — the scrubber reads the whole value, and the 8192-character cap applies to what is kept afterwards. Scrubbing is shape-based, so it reduces exposure rather than guaranteeing none; the cap is a size limit on what is stored, not a safety measure. |
125
172
  | `--unregister` | `setup --agent cursor` only: disconnect this project — remove its entries and its registry record, leaving every other project connected and this device signed in. |
126
173
 
127
174
  ## Key facts
@@ -138,9 +185,15 @@ Each runs as `npx -y @agenttrail/cli@latest <command> --agent <claude|cursor|cod
138
185
  nested repos do not inherit a parent's config (resolution stops at the git root).
139
186
  - **`CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` is required** — span emission is a
140
187
  Claude Code beta feature, OFF by default; the writer always sets it.
141
- - **Content is OFF by default** (metadata + tokens only). `--capture-content` is an
142
- explicit opt-in, and the server-side scrubbing it waited on has
143
- landed: ingest scrubs captured content under your org's configured mode, falling
188
+ - **Claude Code content capture is ON by default**: `setup` writes the three
189
+ `OTEL_LOG_*` content flags, so prompts, commands, file paths and tool output reach
190
+ AgentTrail. `--no-capture-content` opts out (metadata + tokens only), and `setup`
191
+ and `status` both print which mode is on. Cursor stays off unless you pass
192
+ `--capture-content`. A committed `.claude/settings.json` (under `--team`, or in a
193
+ repo that tracks it) carries the flags to every teammate; a teammate opts out for
194
+ themselves by setting the three flags to `"0"` in their own
195
+ `.claude/settings.local.json`. Claude Code's own exporter sends the content, so nothing
196
+ scrubs it on your machine; ingest scrubs captured content under your org's configured mode, falling
144
197
  back to the deployment-wide `SCRUB_MODE` — never to no scrubbing. The one
145
198
  passthrough is an org explicitly setting `mode: "off"`, which opts out by choice.
146
199
  Scrubbing is shape-based, so a structureless secret can still get through; the