@tangle-network/traces 0.8.13 → 0.8.15

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
@@ -17,6 +17,7 @@ It reads the transcripts your harness leaves on disk, reconstructs the run as sp
17
17
  - [What it finds](#what-it-finds)
18
18
  - [Supported harnesses](#supported-harnesses)
19
19
  - [CLI reference](#cli-reference)
20
+ - [Improvement engine](#improvement-engine)
20
21
  - [Session index](#session-index)
21
22
  - [Policy-mining evidence](#policy-mining-evidence)
22
23
  - [Upload to the Intelligence Platform](#upload-to-the-intelligence-platform)
@@ -42,6 +43,7 @@ Requires Node ≥ 22.
42
43
 
43
44
  ```bash
44
45
  traces analyze --harness claude-code --last 1
46
+ traces improve --harness claude-code --last 5 --dir .traces/improvement
45
47
  ```
46
48
 
47
49
  That's the command in the demo above. The **deterministic pass** — stuck loops, token growth, output decay, missing self-verification, tool monoculture — needs no API key and costs nothing.
@@ -50,6 +52,8 @@ Add `--llm` for the **agentic analysts** (failure-mode / knowledge-gap / knowled
50
52
 
51
53
  Every run also writes a **canonical OpenInference JSONL artifact**, so you can run external engines like [HALO](https://github.com/context-labs/halo) over it directly with `--analyzer halo` — see [External engines](#external-engines-bring-your-own). Analysis is never locked to one engine.
52
54
 
55
+ `traces improve` is the reviewable action path. It writes typed artifacts — findings, recommendations, evidence rows, claims, report, and before/after replay metadata — so another agent, CI job, or hosted product can consume the result without scraping prose.
56
+
53
57
  ## What it finds
54
58
 
55
59
  The deterministic pass (free, no key) surfaces:
@@ -88,6 +92,8 @@ Every adapter captures the full conversation — the **user's prompt** and the *
88
92
  ```bash
89
93
  traces list --harness claude-code --last 20 # discover sessions
90
94
  traces analyze --harness codex --last 1 # $0 deterministic report
95
+ traces investigate --all --last 10 --out report.md # typed findings + recommendations
96
+ traces improve --all --last 10 --dir .traces/improvement
91
97
  traces analyze --all --since 2026-06-18 --out report.md
92
98
  traces convert --harness claude-code --last 1 --otlp spans.jsonl # OTLP only
93
99
  traces index --all --since 24h --out session-index.json
@@ -108,14 +114,50 @@ traces upload --since 24h # upload last day to the Inte
108
114
  | `--cwd <dir>` | Filter by working directory |
109
115
  | `--since <t>` | `upload`: window — `30m`/`2h`/`7d` or ISO (default 24h); `analyze`: ISO cutoff |
110
116
  | `--out <path>` | Write the report to a file |
117
+ | `--dir <path>` | `improve`: write the full artifact pack to this directory |
111
118
  | `--otlp <path>` | OTLP artifact path (also evidence provenance / dry-run upload preview) |
112
119
  | `--format <kind>` | `export`: `auto`, `policy-evidence`, `sandbox-events`, or `openinference` |
113
120
  | `--llm` / `--budget <usd>` | Enable agentic analysts (needs `OPENAI_API_KEY`) / cap their spend |
121
+ | `--config <path>` | `investigate` / `improve`: load BYO analysts, external analyzers, and proposal adapters |
114
122
  | `--interval <s>` / `--window <m>` | `watch`: poll seconds (default 5) / active-session window minutes (default 30) |
115
123
  | `--min-loop <n>` | Identical repeated calls before flagging a loop (default 3) |
116
124
  | `--no-content` | `upload`: send metadata only — strip all prompt/response text |
117
125
  | `--dry-run` / `--yes` | `upload`: preview without sending / skip the confirm prompt |
118
126
 
127
+ ## Improvement engine
128
+
129
+ `traces improve` turns observed sessions into a portable improvement packet:
130
+
131
+ ```bash
132
+ traces improve --all --last 20 --dir .traces/improvement
133
+ ```
134
+
135
+ The directory contains:
136
+
137
+ | File | Purpose |
138
+ |---|---|
139
+ | `findings.json` | typed `AnalystFinding[]`; finding ids, severity, evidence refs, recommended action, validation plan |
140
+ | `recommendations.json` | ranked actions derived from analyst, deterministic, and external findings |
141
+ | `evidence.jsonl` | one row per evidence ref, suitable for downstream mining |
142
+ | `claims.json` | compact claim list for review agents and dashboards |
143
+ | `report.md` | human-readable report rendered from the typed data |
144
+ | `replay-before-after.json` | baseline counts plus proposal-only replay metadata |
145
+
146
+ Bring your own analysts and proposal writer with a config file:
147
+
148
+ ```bash
149
+ traces improve --last 5 --config examples/improvement-config.mjs --dir .traces/improvement
150
+ ```
151
+
152
+ The config can export:
153
+
154
+ - `analysts`: deterministic or LLM analysts that implement the `agent-eval` `Analyst` contract
155
+ - `registry`: a prebuilt `AnalystRegistry`
156
+ - `externalAnalyzers`: HALO or any command/model adapter that reads the OTLP artifact
157
+ - `improvementAdapter`: a proposal writer that maps recommendations to patches, profile edits, prompts, or validation commands
158
+
159
+ `traces` does not apply patches or open PRs by default. The public engine produces reviewable artifacts; hosted products can decide how to deliver, approve, or apply them.
160
+
119
161
  ## Session index
120
162
 
121
163
  `traces index` writes one general JSON catalog over the selected sessions.
@@ -241,6 +283,11 @@ The CLI is a thin consumer of these exports.
241
283
  | Export | Signature | Use |
242
284
  |---|---|---|
243
285
  | `analyzeSpans` | `(spans, { registry?, ai?, budgetUsd? }) → AnalyzeResult` | run analysts — built-in, or **your own** via `registry` |
286
+ | `runTraceInvestigation` | `(TraceInvestigationOptions) → TraceInvestigationResult` | typed findings, recommendations, claims, external analyzer output, and report |
287
+ | `runTraceImprovementLoop` | `(TraceImprovementOptions) → TraceImprovementResult` | writes the full improvement artifact pack and optional proposal output |
288
+ | `buildTraceFindingPacket` | `({ findings }) → TraceFindingPacket` | turn any `AnalystFinding[]` into recommendations, claims, and a report |
289
+ | `runTraceStoreInvestigation` | `({ traceStore }) → TraceStoreInvestigationResult` | run the same packet layer over a hosted/custom `TraceAnalysisStore` |
290
+ | `loadTracesConfig` | `(path?) → TracesConfig \| undefined` | load BYO analysts, external analyzers, and proposal adapters |
244
291
  | `watchSessions` | `(ObserverOptions) → Promise<void>` | live observer; `onLoop` / `onReport` / `signal` / `adapters` |
245
292
  | `collectSessionIndex` | `(ScanOptions) → TraceSessionIndex` | scan sessions and return a reusable JSON-ready catalog |
246
293
  | `inspectSessionIndex` | `(TraceSessionIndex) → TraceInspectionReport` | rank improvement findings from an index without rescanning sessions |
@@ -281,6 +328,7 @@ Runnable, in [`examples/`](./examples):
281
328
  |---|---|
282
329
  | [`observe-and-alert.ts`](./examples/observe-and-alert.ts) | tail live sessions and alert on stuck loops |
283
330
  | [`custom-analyst.ts`](./examples/custom-analyst.ts) | register and run your own analyst |
331
+ | [`improvement-config.mjs`](./examples/improvement-config.mjs) | plug in BYO analysts and proposal generation for `traces improve` |
284
332
  | [`custom-backend.ts`](./examples/custom-backend.ts) | redact + dedup + upload to your own sink |
285
333
  | [`register-harness.ts`](./examples/register-harness.ts) | add a new harness by implementing `HarnessTraceAdapter` |
286
334
  | [`external-engines.ts`](./examples/external-engines.ts) | drive HALO + an external PII scrubber you install yourself |