llm-trace 0.1.1 → 0.1.3

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) 2025
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 CHANGED
@@ -1,29 +1,55 @@
1
1
  # llm-trace
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/llm-trace.svg)](https://www.npmjs.com/package/llm-trace)
4
+ [![CI](https://github.com/moondef/llm-trace/actions/workflows/ci.yml/badge.svg)](https://github.com/moondef/llm-trace/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
3
7
  LLMs can read your code but they can't run it in their head. When something breaks, they end up asking you to paste errors and add `console.log` statements one at a time while they guess at what's going on.
4
8
 
5
9
  llm-trace fixes this. It gives LLMs a way to instrument your code with structured traces, see actual runtime values, and figure out what went wrong without the back-and-forth.
6
10
 
7
- ## Try It
11
+ ## Install
12
+
13
+ Install the [debugging skill](skills/debugging-with-llm-trace/SKILL.md) so your LLM tool knows how to use llm-trace. The skill will ask to `npm install llm-trace` into your project — it's the SDK that provides the `trace()`, `span()`, and `checkpoint()` calls for code instrumentation.
14
+
15
+ **Claude Code:**
16
+ ```bash
17
+ /plugin marketplace add moondef/llm-trace
18
+ /plugin install debugging-with-llm-trace@llm-trace
19
+ ```
20
+
21
+ **Codex:**
22
+ ```
23
+ $skill-installer install https://github.com/moondef/llm-trace/tree/main/skills/debugging-with-llm-trace
24
+ ```
25
+
26
+ **Any tool** (via npx):
27
+ ```bash
28
+ npx skills add moondef/llm-trace
29
+ ```
8
30
 
31
+ **Or clone and copy manually:**
9
32
  ```bash
10
- npm install llm-trace
33
+ git clone https://github.com/moondef/llm-trace.git
34
+ cp -r llm-trace/skills/debugging-with-llm-trace ~/.claude/skills/
11
35
  ```
12
36
 
13
- Add the [debugging skill](skills/debugging-with-llm-trace/SKILL.md) to Claude Code (or any LLM coding tool) and ask it to debug something. That's it — the skill teaches it the workflow.
37
+ ## Usage
14
38
 
15
- ### What happens next
39
+ Just ask your LLM to debug something. The skill handles the rest.
16
40
 
17
- You tell the LLM "this endpoint returns 500 sometimes" and it:
41
+ You say "this endpoint returns 500 sometimes" and it:
18
42
 
19
- 1. Runs `npx llm-trace start`
20
- 2. Wraps the endpoint in `trace()` with `span()` and `checkpoint()` calls
21
- 3. Triggers the bug
22
- 4. Reads the trace — sees actual values at each step, which span failed, the error
43
+ 1. Starts a tracing session (`llm-trace start`)
44
+ 2. Instruments the suspect code with `trace()`, `span()`, and `checkpoint()`
45
+ 3. Runs the code to trigger the bug
46
+ 4. Reads the trace — actual values at each step, which span failed, the error
23
47
  5. Fixes the root cause based on what it saw
24
- 6. Removes instrumentation, runs `npx llm-trace stop`
48
+ 6. Cleans up instrumentation and stops the session
25
49
 
26
- ## Three Primitives
50
+ ## What It Captures
51
+
52
+ Three primitives, all the LLM needs:
27
53
 
28
54
  ```typescript
29
55
  import { trace } from "llm-trace";
@@ -46,7 +72,7 @@ await trace("checkout", async (handle) => {
46
72
 
47
73
  **`handle.span(name, fn)`** — a timed step within a trace. Nests to any depth.
48
74
 
49
- **`handle.checkpoint(name, data?)`** — snapshots a value (truncated at 64KB).
75
+ **`handle.checkpoint(name, data?)`** — snapshots a value at a point in time (truncated at 64KB).
50
76
 
51
77
  Errors are captured automatically — if anything throws, the trace records the error and stack.
52
78
 
@@ -63,9 +89,9 @@ llm-trace stop # end session, delete traces
63
89
 
64
90
  Output is JSON by default (for LLM consumption). Add `--human` for readable output.
65
91
 
66
- ## How It Fits Together
92
+ ## How It Works
67
93
 
68
- The LLM writes `trace()` / `span()` / `checkpoint()` calls into your code. When the code runs, events stream over HTTP to a local server that writes `.ndjson` files. The LLM reads those files via the CLI. After debugging, everything is cleaned up — traces are ephemeral.
94
+ The LLM writes `trace()` / `span()` / `checkpoint()` calls into your code. When the code runs, events stream over HTTP to a local server that writes `.ndjson` files. The LLM reads those files via the CLI. After debugging, everything gets cleaned up — traces are ephemeral.
69
95
 
70
96
  No dependencies. No config. Nothing persisted after `stop`.
71
97
 
@@ -74,3 +100,7 @@ No dependencies. No config. Nothing persisted after `stop`.
74
100
  | Variable | Default | Description |
75
101
  |----------|---------|-------------|
76
102
  | `LLM_TRACE_PORT` | `13579` | HTTP server port |
103
+
104
+ ## Contributing
105
+
106
+ Issues and PRs welcome at [github.com/moondef/llm-trace](https://github.com/moondef/llm-trace).
package/dist/index.cjs CHANGED
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- let node_crypto = require("node:crypto");
3
2
 
4
3
  //#region src/utils/errors.ts
5
4
  function serializeError(err) {
@@ -133,7 +132,11 @@ function createSystemClock() {
133
132
  //#region src/utils/id.ts
134
133
  function createCryptoIdGenerator() {
135
134
  return { generate(prefix) {
136
- return `${prefix}-${(0, node_crypto.randomBytes)(4).toString("hex").slice(0, 6)}`;
135
+ const bytes = new Uint8Array(3);
136
+ crypto.getRandomValues(bytes);
137
+ let suffix = "";
138
+ for (const b of bytes) suffix += b.toString(16).padStart(2, "0");
139
+ return `${prefix}-${suffix}`;
137
140
  } };
138
141
  }
139
142
 
package/dist/index.js CHANGED
@@ -1,5 +1,3 @@
1
- import { randomBytes } from "node:crypto";
2
-
3
1
  //#region src/utils/errors.ts
4
2
  function serializeError(err) {
5
3
  if (err instanceof Error) return {
@@ -132,7 +130,11 @@ function createSystemClock() {
132
130
  //#region src/utils/id.ts
133
131
  function createCryptoIdGenerator() {
134
132
  return { generate(prefix) {
135
- return `${prefix}-${randomBytes(4).toString("hex").slice(0, 6)}`;
133
+ const bytes = new Uint8Array(3);
134
+ crypto.getRandomValues(bytes);
135
+ let suffix = "";
136
+ for (const b of bytes) suffix += b.toString(16).padStart(2, "0");
137
+ return `${prefix}-${suffix}`;
136
138
  } };
137
139
  }
138
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-trace",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "description": "Structured execution traces for LLM debugging",
6
6
  "license": "MIT",