@raytrace-cli/cli 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RayTrace contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # RayTrace
2
+
3
+ See what your coding agent actually did. RayTrace records every prompt you
4
+ give Claude Code or Codex, every tool call the agent made on the way to its
5
+ answer, what each step cost, and what the model had in front of it when it
6
+ decided. You browse all of it in a dashboard on your own machine.
7
+
8
+ Everything stays on your computer. Your sessions are not sent anywhere unless you
9
+ turn on the optional AI features (see [Privacy](#privacy)).
10
+
11
+ ## Install
12
+
13
+ You need **Node.js 22.13 or newer** (`node --version`). macOS and Linux are
14
+ supported.
15
+
16
+ ```sh
17
+ npm install -g @raytrace/cli
18
+ raytrace setup
19
+ ```
20
+
21
+ `setup` asks two things:
22
+
23
+ 1. **Record Claude Code sessions?** It adds a small hook to
24
+ `~/.claude/settings.json`. Your other settings and hooks are left as they
25
+ are, and the previous file is kept as `settings.json.raytrace-backup`.
26
+ 2. **An OpenRouter API key** (optional, Enter to skip). It turns on one-line
27
+ step summaries and `raytrace codex`. Everything else works without it.
28
+
29
+ Then it starts RayTrace and opens the dashboard at http://127.0.0.1:8797.
30
+
31
+ Install globally (`-g`) rather than running it with `npx`: the Claude Code hook
32
+ runs the `raytrace` command, so it has to stay on your PATH.
33
+
34
+ ## Use
35
+
36
+ Use Claude Code as you normally do. Each prompt shows up in the dashboard a
37
+ moment after the agent answers.
38
+
39
+ | Section | What it answers |
40
+ |---|---|
41
+ | **Prompts** | What you asked and what came back, with a year of activity at a glance |
42
+ | **Tool calls** | How the agent got there: every round trip to the model and every tool call, with cost, time and tokens, as a list or a graph |
43
+ | **Context** | What the model was working from: earlier prompts, files it read, and how full its context window was |
44
+
45
+ For Codex, start it through RayTrace instead of directly (needs the OpenRouter
46
+ key):
47
+
48
+ ```sh
49
+ raytrace codex # any Codex arguments work after it
50
+ ```
51
+
52
+ ## Commands
53
+
54
+ | Command | |
55
+ |---|---|
56
+ | `raytrace setup` | one-time setup; run it again to change settings |
57
+ | `raytrace start` | start recording in the background |
58
+ | `raytrace stop` | stop it |
59
+ | `raytrace status` | is it running, and is Claude Code being recorded |
60
+ | `raytrace open` | open the dashboard |
61
+ | `raytrace doctor` | check the install without changing anything |
62
+ | `raytrace codex [args]` | run Codex through RayTrace |
63
+ | `raytrace uninstall` | remove the Claude Code hook; `--purge` also deletes recorded data |
64
+
65
+ ## Getting the most out of it
66
+
67
+ RayTrace shows what the agent **reported** at each step: the commands it chose,
68
+ their output, and whether it said they succeeded. That is exactly what the
69
+ agent believed, which is usually what you want to debug.
70
+
71
+ It works best when the agent runs in **its own container or virtual machine**
72
+ rather than directly on your laptop. A run you can tell apart from everything
73
+ else on the machine is easier to trust and easier to compare: you know what the
74
+ agent started from, nothing else was changing the files under it, and a second
75
+ attempt starts from the same place. If you already run agents that way, point
76
+ RayTrace at the same sessions and the records line up run for run.
77
+
78
+ ## Privacy
79
+
80
+ - Recorded sessions, settings and logs live in `~/.raytrace` (move it with the
81
+ `RAYTRACE_HOME` environment variable). The dashboard and its API listen on
82
+ `127.0.0.1` only.
83
+ - API keys you give `setup` are stored in `~/.raytrace/config.env`, readable
84
+ only by you. Keys and auth headers in recorded requests are replaced with
85
+ `[REDACTED]` before they are saved.
86
+ - With an OpenRouter key, summaries send short excerpts of each step (and of
87
+ your earlier prompts, for the Context view) to OpenRouter, using your key.
88
+ Rerunning a Codex step in the Lab sends that step's whole request again.
89
+ Without a key, none of this happens.
90
+ - To show how full a model's context window was, the dashboard fetches
91
+ OpenRouter's public list of models once. That request carries none of your
92
+ data.
93
+
94
+ ## Uninstall
95
+
96
+ ```sh
97
+ raytrace uninstall --purge # removes the hook and ~/.raytrace
98
+ npm uninstall -g @raytrace/cli
99
+ ```
100
+
101
+ ## Troubleshooting
102
+
103
+ Run `raytrace doctor` first; it lists anything wrong and how to fix it. The
104
+ background process logs to `~/.raytrace/logs/proxy.log`.
105
+
106
+ - **Nothing shows up for Claude Code:** check `raytrace status` says
107
+ "recording", and that `raytrace` is on your PATH (`which raytrace`). Sessions
108
+ appear when the agent finishes a step, not while it is typing.
109
+ - **Port 8797 is in use:** set `RAYTACE_PORT=<port>` in `~/.raytrace/config.env`,
110
+ then `raytrace stop && raytrace start`.
111
+
112
+ ## Developing
113
+
114
+ ```sh
115
+ npm install
116
+ npm run build # dashboard -> dist/dashboard
117
+ npm run dashboard:dev # dashboard with hot reload, API from a running RayTrace
118
+ npm run typecheck
119
+ node bin/raytrace.mjs <command> # run the CLI from this folder
120
+ npm pack # build the package as it would be published
121
+ ```
122
+
123
+ To try it without touching your real setup, give it its own home and port:
124
+
125
+ ```sh
126
+ mkdir -p /tmp/rt && echo RAYTACE_PORT=18797 > /tmp/rt/config.env
127
+ RAYTRACE_HOME=/tmp/rt node bin/raytrace.mjs setup --no-claude-code
128
+ ```
129
+
130
+ ## License
131
+
132
+ MIT
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ // The `raytrace` command. Each subcommand lives in src/commands.mjs.
3
+ import { readFileSync } from 'node:fs';
4
+ import { parseArgs } from 'node:util';
5
+
6
+ const HELP = `RayTrace: see what your coding agent did.
7
+
8
+ Usage: raytrace <command>
9
+
10
+ setup one-time setup: Claude Code hook, API keys, then start
11
+ start start RayTrace in the background (dashboard + recorder)
12
+ stop stop it
13
+ status is it running, and what is being recorded
14
+ open open the dashboard in your browser
15
+ doctor check the install without changing anything
16
+ codex [...] run Codex through RayTrace (needs an OpenRouter key)
17
+ uninstall remove the Claude Code hook, optionally all recorded data
18
+
19
+ Options for setup: --yes --no-claude-code --no-start --openrouter-key <key>
20
+ Options for uninstall: --yes --purge (also delete ~/.raytrace)
21
+
22
+ Data and settings live in ~/.raytrace (override with RAYTRACE_HOME).`;
23
+
24
+ // node:sqlite, which the recorder stores everything in, needs 22.13.
25
+ const [major, minor] = process.versions.node.split('.').map(Number);
26
+ if (major < 22 || (major === 22 && minor < 13)) {
27
+ console.error(`RayTrace needs Node.js 22.13 or newer; this is ${process.version}.`);
28
+ process.exit(1);
29
+ }
30
+
31
+ const [command, ...rest] = process.argv.slice(2);
32
+
33
+ // The hook runs on every Claude Code tool call: dispatch it before anything else.
34
+ if (command === 'hook') {
35
+ const { hook } = await import('../src/commands.mjs');
36
+ await hook(rest[0]);
37
+ process.exit(0);
38
+ }
39
+
40
+ if (command === '--version' || command === '-v') {
41
+ console.log(JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version);
42
+ process.exit(0);
43
+ }
44
+ if (!command || command === 'help' || command === '--help' || command === '-h') { console.log(HELP); process.exit(0); }
45
+
46
+ const commands = await import('../src/commands.mjs');
47
+
48
+ // `codex` passes everything after it straight to Codex.
49
+ if (command === 'codex') { await commands.codex(rest); process.exit(); }
50
+
51
+ let flags;
52
+ try {
53
+ ({ values: flags } = parseArgs({ args: rest, strict: true, options: {
54
+ yes: { type: 'boolean', short: 'y' },
55
+ 'no-claude-code': { type: 'boolean' },
56
+ 'no-start': { type: 'boolean' },
57
+ 'openrouter-key': { type: 'string' },
58
+ purge: { type: 'boolean' },
59
+ } }));
60
+ } catch (error) { console.error(`${error.message}\n\nRun \`raytrace help\` for usage.`); process.exit(2); }
61
+
62
+ const run = {
63
+ setup: () => commands.setup(flags),
64
+ start: () => commands.startCommand(),
65
+ stop: () => commands.stopCommand(),
66
+ status: () => commands.statusCommand(),
67
+ open: () => commands.openCommand(),
68
+ doctor: () => commands.doctor(),
69
+ uninstall: () => commands.uninstall(flags),
70
+ }[command];
71
+
72
+ if (!run) { console.error(`Unknown command: ${command}\n\n${HELP}`); process.exit(2); }
73
+ try { await run(); }
74
+ catch (error) { console.error(`raytrace ${command}: ${error.message}`); process.exitCode = 1; }