trace-codebook 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.ko.md +212 -0
- package/README.md +211 -2
- package/bin/messages.mjs +96 -0
- package/bin/trace-codebook.mjs +209 -0
- package/dist/assets/index-C8QZxOcS.js +20 -0
- package/dist/assets/index-CPfzDIhf.css +1 -0
- package/dist/favicon.svg +1 -0
- package/dist/index.html +15 -0
- package/dist/samples/anthropic.jsonl +2 -0
- package/dist/samples/langfuse-trace.json +46 -0
- package/dist/samples/otlp.json +92 -0
- package/dist/samples/phoenix.jsonl +2 -0
- package/dist/samples/support-agent.annotations.jsonl +40 -0
- package/dist/samples/support-agent.jsonl +40 -0
- package/dist/samples/support-agent.taxonomy.csv +6 -0
- package/package.json +65 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LeeGyeongPil
|
|
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.ko.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# trace-codebook
|
|
2
|
+
|
|
3
|
+
[English](README.md) | **한국어**
|
|
4
|
+
|
|
5
|
+
LLM 앱의 실제 트레이스를 브라우저에서 읽고, 잘못된 점을 메모하고, 메모를 실패 유형으로 묶어 건수를 셉니다. 서버·계정·API 키가 필요 없고, 트레이스 파일은 브라우저 탭 밖으로 나가지 않습니다.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
*동봉된 예시 주석을 불러온 뒤의 축 코딩 보드: 실패 메모 16건이 실패 유형 5개로 묶였습니다.*
|
|
9
|
+
|
|
10
|
+
## 이런 분께
|
|
11
|
+
|
|
12
|
+
- LLM 앱·에이전트를 만들고, 지표나 LLM 심판을 쓰기 전에 실제로 무엇이 깨지는지 알고 싶은 분
|
|
13
|
+
- 대화를 읽는 일은 잘하지만 서버나 노트북 환경은 쓰고 싶지 않은 PM·도메인 전문가
|
|
14
|
+
- 로그에서 내보낸 파일(OpenAI/Anthropic 메시지, OTLP, Langfuse, Phoenix)이 있고 건수가 붙은 실패 유형표가 필요한 분
|
|
15
|
+
|
|
16
|
+
## 오류 분석은 왜 읽기부터 시작하나
|
|
17
|
+
|
|
18
|
+
오류 분석은 연구자가 인터뷰 메모를 코딩하듯, 실제 실행 기록을 읽고 실패를 손으로 분류하는 일입니다. 두 단계로 나뉩니다.
|
|
19
|
+
|
|
20
|
+
1. **오픈 코딩**: 트레이스를 하나씩 읽고, 처음 잘못된 지점을 자유롭게 메모합니다.
|
|
21
|
+
2. **축 코딩**: 메모를 이름 붙은 실패 유형("정책 지어내기", "도구 인자 잘못")으로 묶고 유형별 건수를 셉니다.
|
|
22
|
+
|
|
23
|
+
건수를 보면 무엇을 먼저 고치거나 자동화할지 알 수 있습니다. trace-codebook 은 이 흐름을 한 화면에 담고, 문서에 붙이거나 평가 도구에 넘길 수 있는 분류표로 끝냅니다.
|
|
24
|
+
|
|
25
|
+
## 설치
|
|
26
|
+
|
|
27
|
+
Node.js 22.22 이상이 필요합니다([내려받기](https://nodejs.org/) 또는 `brew install node`). 최소 리눅스 환경에서는 소스에서 빌드할 때만 `git` 이 추가로 필요하고, 다른 시스템 패키지는 없습니다.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# 설치 없이 실행 (npm 에 게시된 뒤)
|
|
31
|
+
npx trace-codebook
|
|
32
|
+
|
|
33
|
+
# 또는 소스에서 빌드
|
|
34
|
+
git clone https://github.com/LeeGyeongPil/trace-codebook.git
|
|
35
|
+
cd trace-codebook
|
|
36
|
+
npm install
|
|
37
|
+
npm run build
|
|
38
|
+
node bin/trace-codebook.mjs
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
게시되는 패키지는 실행 의존성이 0개입니다. React 등은 빌드할 때 `dist/` 안에 묶입니다.
|
|
42
|
+
|
|
43
|
+
## 빠르게 시작하기
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
node bin/trace-codebook.mjs --no-open --port 4178
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
*서버가 주소를 출력합니다. 브라우저로 여세요(`--no-open` 을 빼면 자동으로 열립니다). 이 그림은 `npx` 형태에 `--lang ko` 를 붙이고(포트도 다르게) 찍어서 주소 끝에 `?lang=ko` 가 있습니다. 위 명령은 시스템 언어가 한국어가 아니면 이 접미사 없이 주소를 출력합니다.*
|
|
51
|
+
|
|
52
|
+
브라우저에서:
|
|
53
|
+
|
|
54
|
+
1. **샘플 트레이스로 해 보기** 를 누릅니다. 가상의 고객지원 에이전트 트레이스 40건이 열립니다.
|
|
55
|
+
2. **예시 주석 불러오기** 로 완성된 분석을 보거나, 직접 검토를 시작합니다.
|
|
56
|
+
|
|
57
|
+
샘플은 이 프로젝트용으로 만든 **가상의 연습용 데이터**이며 실제 사용자 기록이 아닙니다. 이것이 "연습용 목(mock) 모드"입니다. 오프라인에서 전체 흐름을 해 볼 수 있도록 실패를 일부러 심어 두었습니다. 내 파일을 열어도 화면과 키는 같지만, 내용과 실패 유형은 내 데이터에서 나옵니다.
|
|
58
|
+
|
|
59
|
+
내 파일을 바로 열려면:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npx trace-codebook traces.jsonl # npm 에서, 게시된 뒤
|
|
63
|
+
node bin/trace-codebook.mjs traces.jsonl # 소스 빌드에서
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
파일은 `127.0.0.1` 에서 읽기 전용으로만 제공되며 수정되지 않습니다.
|
|
67
|
+
|
|
68
|
+
## 따라 하기
|
|
69
|
+
|
|
70
|
+
### 1. 파일 열기
|
|
71
|
+
|
|
72
|
+

|
|
73
|
+
*요약 줄에 감지된 형식(`openai-jsonl`), 트레이스 수, 건너뛴 깨진 줄 수가 나옵니다.*
|
|
74
|
+
|
|
75
|
+
파일을 끌어 놓거나 고르거나 샘플을 누릅니다. 감지된 형식, 트레이스 수, 깨진 줄의 줄 번호가 보입니다. 깨진 줄은 건너뛸 뿐 멈추지 않습니다.
|
|
76
|
+
|
|
77
|
+
### 2. 읽고 메모하기 (오픈 코딩)
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+
*실패 트레이스 한 건. 도구 호출·인자·결과가 한 상자에 있고, 메모에는 처음 잘못된 지점을 적습니다.*
|
|
81
|
+
|
|
82
|
+
트레이스마다 판정을 고르고 짧게 메모합니다. 단축키:
|
|
83
|
+
|
|
84
|
+
| 키 | 동작 |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `P` / `F` / `D` | 통과 / 실패 / 보류(나중에 결정) |
|
|
87
|
+
| `J` / `K` | 다음 / 이전 트레이스 |
|
|
88
|
+
| `N` | 메모 칸으로 이동 |
|
|
89
|
+
| `1`-`9` | N번째 실패 유형 지정(실패로 표시됨) |
|
|
90
|
+
| `?` | 단축키 표 보기 |
|
|
91
|
+
| `Esc` | 메모 칸에서 나오기, 도움말 닫기 |
|
|
92
|
+
|
|
93
|
+
### 3. 메모를 실패 유형으로 묶기 (축 코딩)
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
*메모 카드를 열로 끌어 놓거나 카드의 유형 메뉴로 고릅니다. 메모 하나는 유형 하나에만 속합니다.*
|
|
97
|
+
|
|
98
|
+
이름과 한 줄 정의("어떤 트레이스가 여기에 속하나?")로 유형을 만듭니다. 유형을 삭제하면 카드는 "미분류 실패"로 돌아가고 판정·메모는 유지됩니다.
|
|
99
|
+
|
|
100
|
+
### 4. 세어 보고 포화 확인하기
|
|
101
|
+
|
|
102
|
+

|
|
103
|
+
*유형별 건수와 전체 실패 대비 비율. 곡선은 N건을 검토했을 때 찾은 서로 다른 유형 수입니다.*
|
|
104
|
+
|
|
105
|
+
곡선이 연속 20건 검토 동안 평평하면 "포화" 배지가 나타납니다. 새 실패 유형이 더는 나오지 않으니 더 읽어도 분류표가 바뀔 가능성이 낮다는 뜻입니다. 20은 앱에 들어 있는 경험칙이지 통계적 보증이 아닙니다.
|
|
106
|
+
|
|
107
|
+
### 5. 내보내기
|
|
108
|
+
|
|
109
|
+
**내보내기 / 가져오기** 메뉴가 만드는 것:
|
|
110
|
+
|
|
111
|
+
| 출력 | 내용 |
|
|
112
|
+
|---|---|
|
|
113
|
+
| 주석(JSONL) | 줄마다 `trace_id, source, verdict, note, failure_mode, review_order, reviewed_at`, 다시 가져올 수 있음 |
|
|
114
|
+
| 분류표(CSV) | `failure_mode,definition,count,share_of_failures,example_trace_ids` |
|
|
115
|
+
| 분류표(Markdown) | 같은 표를 보고서로, 선택한 화면 언어로 출력 |
|
|
116
|
+
| 라벨(CSV) | `trace_id,verdict,failure_mode`, 심판·일치도 도구의 입력용 |
|
|
117
|
+
|
|
118
|
+
가져올 때 같은 트레이스에 주석이 둘이면 더 최근 것을 남기고, 어떤 트레이스와도 맞지 않는 ID 수를 알려 줍니다.
|
|
119
|
+
|
|
120
|
+
## 사용법
|
|
121
|
+
|
|
122
|
+
| 명령·옵션 | 하는 일 | 예 |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| `trace-codebook` | 로컬 서버를 띄우고 앱 열기 | `npx trace-codebook` |
|
|
125
|
+
| `trace-codebook <파일>` | 이 파일을 불러온 채 앱 열기 | `npx trace-codebook traces.jsonl` |
|
|
126
|
+
| `--port N` | 포트(기본 4178, `0` = 빈 포트 아무거나) | `--port 0` |
|
|
127
|
+
| `--no-open` | 브라우저를 열지 않음 | `--no-open` |
|
|
128
|
+
| `--lang en\|ko` | 메시지 언어 | `--lang ko` |
|
|
129
|
+
| `-h`, `--help` | 도움말 | `trace-codebook --help` |
|
|
130
|
+
| `-v`, `--version` | 버전 | `trace-codebook --version` |
|
|
131
|
+
|
|
132
|
+
지원 입력 형식(자동 감지):
|
|
133
|
+
|
|
134
|
+
| 형식 | 비고 |
|
|
135
|
+
|---|---|
|
|
136
|
+
| OpenAI 메시지 JSONL | 한 줄에 대화 하나, `tool_calls` 와 `tool` 메시지 포함 |
|
|
137
|
+
| Anthropic 메시지 JSONL | `tool_use` / `tool_result` 블록, 최상위 `system` |
|
|
138
|
+
| OTLP JSON | OpenTelemetry GenAI·OpenInference 속성, `traceId` 로 묶음 |
|
|
139
|
+
| Langfuse 트레이스 JSON | 들여쓰기된 트레이스 내보내기 |
|
|
140
|
+
| Phoenix span JSONL | 중첩 또는 평탄화된 속성 |
|
|
141
|
+
|
|
142
|
+
span 트레이스에 "메시지 내용 없음"이 뜨면 계측 도구가 내용을 기록하지 않은 것입니다. 대부분 직접 켜야 기록합니다(content capture 설정).
|
|
143
|
+
|
|
144
|
+
메모는 파일 지문을 키로 브라우저(IndexedDB)에 저장되므로 같은 파일을 다시 열면 이어서 할 수 있습니다. 브라우저 데이터를 지우기 전에 주석 JSONL 을 백업으로 내보내세요.
|
|
145
|
+
|
|
146
|
+
## 설정
|
|
147
|
+
|
|
148
|
+
| 설정 | 효과 |
|
|
149
|
+
|---|---|
|
|
150
|
+
| 언어 메뉴(오른쪽 위) | English / 한국어, 고른 값은 브라우저에 저장됩니다. 첫 실행은 브라우저 언어가 `ko` 로 시작하면 한국어, 아니면 영어 |
|
|
151
|
+
| 주소의 `?lang=en` 또는 `?lang=ko` | 저장하지 않고 화면 언어를 고정 |
|
|
152
|
+
| `--lang en\|ko` | CLI 메시지 언어 |
|
|
153
|
+
| `TRACE_CODEBOOK_LANG=ko` | `--lang` 이 없을 때의 CLI 메시지 언어. 그다음 `LC_ALL`, `LC_MESSAGES`, `LANG` 을 보고, 한국어가 아니면 영어 |
|
|
154
|
+
|
|
155
|
+
어느 모드에서도 API 키와 네트워크가 필요 없습니다.
|
|
156
|
+
|
|
157
|
+
## 동작 원리
|
|
158
|
+
|
|
159
|
+
```mermaid
|
|
160
|
+
flowchart LR
|
|
161
|
+
F[트레이스 파일] --> A[형식 어댑터]
|
|
162
|
+
A --> T[공통 트레이스 모양]
|
|
163
|
+
T --> R[검토: 판정 + 메모]
|
|
164
|
+
R --> X[축 코딩 보드: 실패 유형]
|
|
165
|
+
X --> S[건수 + 포화]
|
|
166
|
+
R --> D[(IndexedDB)]
|
|
167
|
+
X --> D
|
|
168
|
+
S --> E[JSONL / CSV / Markdown 내보내기]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
- **형식 어댑터**가 다섯 형식을 하나의 공통 모양(메시지, 결과와 짝지은 도구 호출)으로 바꿉니다. 형식마다 `src/adapters/` 에 파일이 따로 있습니다.
|
|
172
|
+
- **검토**는 트레이스마다 판정과 메모를 저장합니다. ID 는 레코드 자체의 id 이거나 내용 해시입니다.
|
|
173
|
+
- **축 코딩 보드**는 실패 메모를 최대 하나의 실패 유형에 배정합니다.
|
|
174
|
+
- **건수와 포화**는 `src/core/` 의 순수 함수가 주석으로부터 계산합니다.
|
|
175
|
+
- **IndexedDB** 는 모든 것을 내 브라우저에 둡니다. 빌드 때 넣는 CSP(`connect-src 'self'`) 때문에 브라우저가 다른 호스트로의 요청을 거부하므로 데이터가 실수로 나갈 수 없습니다.
|
|
176
|
+
|
|
177
|
+
## 언제 쓰나
|
|
178
|
+
|
|
179
|
+
- 이럴 때: 트레이스 파일이 있고 자동 평가를 만들기 전에 앱이 어떻게 실패하는지 알고 싶을 때, 트레이스를 호스팅 서비스에 보내고 싶지 않을 때.
|
|
180
|
+
- 이럴 땐 다른 도구: 로그인이 있는 팀 주석 큐와 실시간 데이터는 [Langfuse](https://langfuse.com/) 나 [Arize Phoenix](https://phoenix.arize.com/), 대량 자동 채점은 이 도구가 하지 않습니다(그 단계에 필요한 라벨과 정의를 만들어 줄 뿐입니다).
|
|
181
|
+
|
|
182
|
+
## 자주 겪는 문제
|
|
183
|
+
|
|
184
|
+
| 증상 | 원인 | 해결 |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| `unknown trace format: keys=...` | 파일이 다섯 형식 어디에도 맞지 않음 | 출력된 키 목록을 위 형식과 비교하고, 데이터 대신 그 키 이름으로 이슈를 남겨 주세요 |
|
|
187
|
+
| 요약에 "깨진 줄 N개" | JSON 이 아닌 줄이 있음 | 표시된 줄 번호를 파일에서 확인하세요. 나머지는 정상 로드됩니다 |
|
|
188
|
+
| "span 만 있고 메시지 내용이 없습니다" | 계측이 프롬프트·응답을 기록하지 않음 | 트레이싱 설정에서 content capture 를 켜고 다시 내보내세요 |
|
|
189
|
+
| 다시 열었더니 메모가 없음 | 파일 내용이 다르면 지문이 달라지거나 브라우저 데이터가 지워짐 | 같은 파일을 여세요. 백업한 주석 JSONL 을 가져오세요 |
|
|
190
|
+
| "이 브라우저에 저장하지 못했습니다" | 저장소가 막힘(예: 사생활 보호 창) | 계속 작업한 뒤 주석 JSONL 로 내보내세요. 탭을 닫기 전까지 메모는 메모리에 남습니다 |
|
|
191
|
+
| 포트가 이미 사용 중 | 다른 프로세스가 4178 을 씀 | `--port 0` 으로 빈 포트를 고르세요 |
|
|
192
|
+
|
|
193
|
+
## 개발
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
npm install
|
|
197
|
+
npm test # 10개 파일 73개 테스트, 네트워크 없음
|
|
198
|
+
npm run lint
|
|
199
|
+
npm run typecheck
|
|
200
|
+
npm run build
|
|
201
|
+
npm run check:docs
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
`npm run shots` 는 README 스크린샷을 다시 만듭니다(Playwright Chromium 필요: `npx playwright install chromium-headless-shell`).
|
|
205
|
+
|
|
206
|
+
알려진 한계: 다섯 형식은 공식 문서를 따라 손으로 만든 픽스처와 동봉 샘플로 검증했고, 실제 Langfuse·Phoenix 서버에서 받은 내보내기 파일로는 검증하지 않았습니다. 수만 건의 아주 큰 파일은 아직 최적화하지 않았습니다. 같은 파일을 두 탭에서 열면 나중에 저장한 탭이 이깁니다.
|
|
207
|
+
|
|
208
|
+
버그·제안은 이슈로 남겨 주세요. 변경 기록은 [CHANGELOG.md](CHANGELOG.md).
|
|
209
|
+
|
|
210
|
+
## 라이선스
|
|
211
|
+
|
|
212
|
+
MIT. 샘플 트레이스는 가상의 데이터이며 같은 라이선스로 공개합니다.
|
package/README.md
CHANGED
|
@@ -1,3 +1,212 @@
|
|
|
1
|
-
#
|
|
1
|
+
# trace-codebook
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** | [한국어](https://github.com/LeeGyeongPil/trace-codebook/blob/v0.1.1/README.ko.md)
|
|
4
|
+
|
|
5
|
+
Read your LLM app's real traces in the browser, write down what went wrong, group the notes into failure modes, and count them. No server, no account, no API key: your trace file never leaves the browser tab.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
*The axial coding board after loading the bundled example annotations: 16 failure notes grouped into 5 failure modes.*
|
|
9
|
+
|
|
10
|
+
## Who it is for
|
|
11
|
+
|
|
12
|
+
- You build an LLM app or agent and want to know what actually breaks before you write metrics or an LLM judge.
|
|
13
|
+
- You are a PM or domain expert who reads conversations well but should not need a server or a notebook.
|
|
14
|
+
- You have an export file from your logs (OpenAI/Anthropic messages, OTLP, Langfuse, Phoenix) and want a failure-mode table with counts.
|
|
15
|
+
|
|
16
|
+
## Why error analysis starts with reading
|
|
17
|
+
|
|
18
|
+
Error analysis means reading real runs and sorting the failures by hand, the way a researcher codes interview notes. It has two passes:
|
|
19
|
+
|
|
20
|
+
1. **Open coding**: read one trace at a time and write a free-form note about the first thing that went wrong.
|
|
21
|
+
2. **Axial coding**: group those notes into named failure modes ("Policy hallucination", "Wrong tool arguments") and count each group.
|
|
22
|
+
|
|
23
|
+
The counts tell you which problem to fix or to automate first. trace-codebook puts this loop in one screen and ends with a taxonomy table you can paste into a doc or hand to an eval tool.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
Requires Node.js 22.22 or newer ([download](https://nodejs.org/) or `brew install node`). On a minimal Linux image you also need `git` only if you build from source; there are no other system packages.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Run without installing (once the package is published to npm)
|
|
31
|
+
npx trace-codebook
|
|
32
|
+
|
|
33
|
+
# Or build from source
|
|
34
|
+
git clone https://github.com/LeeGyeongPil/trace-codebook.git
|
|
35
|
+
cd trace-codebook
|
|
36
|
+
npm install
|
|
37
|
+
npm run build
|
|
38
|
+
node bin/trace-codebook.mjs
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The published package has zero runtime dependencies: React and the other libraries are bundled into `dist/` at build time.
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
node bin/trace-codebook.mjs --no-open --port 4178
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
*The server prints its address. Open it in a browser (without `--no-open` it opens for you). The picture was taken with the `npx` form plus `--lang en` (and a different port), so its address ends in `?lang=en`; the command above prints the address without that suffix when your system language is not Korean.*
|
|
51
|
+
|
|
52
|
+
Then in the browser:
|
|
53
|
+
|
|
54
|
+
1. Click **Try sample traces**. This loads 40 traces of a fictional support agent.
|
|
55
|
+
2. Click **Load example annotations** to see a finished analysis, or start reviewing yourself.
|
|
56
|
+
|
|
57
|
+
The sample is **synthetic practice data** written for this project, not real user logs. It is the "practice (mock) mode": it lets you try the whole flow offline, with failures planted so you can see what a finished analysis looks like. With your own file the screens and keys are the same, but the content and the failure modes come from your data.
|
|
58
|
+
|
|
59
|
+
To open your own file directly:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npx trace-codebook traces.jsonl # from npm, once published
|
|
63
|
+
node bin/trace-codebook.mjs traces.jsonl # from a source build
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The file is served read-only from `127.0.0.1` and is never modified.
|
|
67
|
+
|
|
68
|
+
## Walkthrough
|
|
69
|
+
|
|
70
|
+
### 1. Open a file
|
|
71
|
+
|
|
72
|
+

|
|
73
|
+
*The summary line shows the detected format (`openai-jsonl`), the number of traces, and how many lines were broken and skipped.*
|
|
74
|
+
|
|
75
|
+
What you do: drop a file on the page, choose one, or click the sample. What you see: the detected format, the trace count, and the line numbers of any broken lines. Broken lines are skipped, not fatal.
|
|
76
|
+
|
|
77
|
+
### 2. Review and write notes (open coding)
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+
*One failed trace. The tool call, its arguments and its result sit together in one box. The note records the first thing that went wrong.*
|
|
81
|
+
|
|
82
|
+
For each trace choose a verdict and write a short note. Keys:
|
|
83
|
+
|
|
84
|
+
| Key | Action |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `P` / `F` / `D` | Mark pass / fail / defer (decide later) |
|
|
87
|
+
| `J` / `K` | Next / previous trace |
|
|
88
|
+
| `N` | Focus the note field |
|
|
89
|
+
| `1`-`9` | Assign the Nth failure mode (marks as fail) |
|
|
90
|
+
| `?` | Show the shortcut list |
|
|
91
|
+
| `Esc` | Leave the note field, close help |
|
|
92
|
+
|
|
93
|
+
### 3. Group notes into failure modes (axial coding)
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
*Drag a note card into a column, or use the Mode menu on each card. A note belongs to one mode only.*
|
|
97
|
+
|
|
98
|
+
Create a mode with a name and a one-line definition ("when does a trace belong here?"). Deleting a mode moves its cards back to "Unassigned failures"; verdicts and notes are kept.
|
|
99
|
+
|
|
100
|
+
### 4. Count and check saturation
|
|
101
|
+
|
|
102
|
+

|
|
103
|
+
*Counts per failure mode and the share of all failures. The curve shows how many distinct modes you had found after N reviewed traces.*
|
|
104
|
+
|
|
105
|
+
When the curve stays flat for 20 reviews in a row, a "Saturated" badge appears: new failure modes stopped appearing, so reading more traces is unlikely to change the taxonomy. 20 is a rule of thumb built into the app, not a statistical guarantee.
|
|
106
|
+
|
|
107
|
+
### 5. Export
|
|
108
|
+
|
|
109
|
+
The **Export / import** menu writes:
|
|
110
|
+
|
|
111
|
+
| Output | Content |
|
|
112
|
+
|---|---|
|
|
113
|
+
| Annotations (JSONL) | `trace_id, source, verdict, note, failure_mode, review_order, reviewed_at` per line; importable again |
|
|
114
|
+
| Taxonomy (CSV) | `failure_mode,definition,count,share_of_failures,example_trace_ids` |
|
|
115
|
+
| Taxonomy (Markdown) | The same table as a report, in the chosen UI language |
|
|
116
|
+
| Labels (CSV) | `trace_id,verdict,failure_mode`, as input for judge or agreement tools |
|
|
117
|
+
|
|
118
|
+
Importing keeps the newer note when the same trace was annotated twice and counts ids that match no trace.
|
|
119
|
+
|
|
120
|
+
## Usage
|
|
121
|
+
|
|
122
|
+
| Command / option | What it does | Example |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| `trace-codebook` | Start the local server and open the app | `npx trace-codebook` |
|
|
125
|
+
| `trace-codebook <file>` | Open the app with this file loaded | `npx trace-codebook traces.jsonl` |
|
|
126
|
+
| `--port N` | Port to listen on (default 4178, `0` = any free port) | `--port 0` |
|
|
127
|
+
| `--no-open` | Do not open a browser | `--no-open` |
|
|
128
|
+
| `--lang en\|ko` | Message language | `--lang ko` |
|
|
129
|
+
| `-h`, `--help` | Show help | `trace-codebook --help` |
|
|
130
|
+
| `-v`, `--version` | Show the version | `trace-codebook --version` |
|
|
131
|
+
|
|
132
|
+
Supported input formats (detected automatically):
|
|
133
|
+
|
|
134
|
+
| Format | Notes |
|
|
135
|
+
|---|---|
|
|
136
|
+
| OpenAI messages JSONL | one conversation per line, with `tool_calls` and `tool` messages |
|
|
137
|
+
| Anthropic messages JSONL | `tool_use` / `tool_result` blocks, top-level `system` |
|
|
138
|
+
| OTLP JSON | OpenTelemetry GenAI and OpenInference attributes, grouped by `traceId` |
|
|
139
|
+
| Langfuse trace JSON | a pretty-printed trace export |
|
|
140
|
+
| Phoenix span JSONL | nested or flattened attributes |
|
|
141
|
+
|
|
142
|
+
If a span trace shows "no message content", your instrumentation did not record it. Most do so only when you opt in (the content capture setting).
|
|
143
|
+
|
|
144
|
+
Your notes are saved in the browser (IndexedDB), keyed by a fingerprint of the file, so reopening the same file resumes where you stopped. Export the annotations JSONL as a backup before clearing browser data.
|
|
145
|
+
|
|
146
|
+
## Settings
|
|
147
|
+
|
|
148
|
+
| Setting | Effect |
|
|
149
|
+
|---|---|
|
|
150
|
+
| Language menu (top right) | English / 한국어; the choice is saved in the browser. On first run Korean is used if the browser language starts with `ko`, otherwise English |
|
|
151
|
+
| `?lang=en` or `?lang=ko` in the address | Forces the screen language without saving it |
|
|
152
|
+
| `--lang en\|ko` | CLI message language |
|
|
153
|
+
| `TRACE_CODEBOOK_LANG=ko` | CLI message language when `--lang` is not given; then `LC_ALL`, `LC_MESSAGES`, `LANG` are checked, and anything that is not Korean means English |
|
|
154
|
+
|
|
155
|
+
No API key or network access is needed in any mode.
|
|
156
|
+
|
|
157
|
+
## How it works
|
|
158
|
+
|
|
159
|
+
```mermaid
|
|
160
|
+
flowchart LR
|
|
161
|
+
F[Trace file] --> A[Format adapters]
|
|
162
|
+
A --> T[Common trace shape]
|
|
163
|
+
T --> R[Review: verdict + note]
|
|
164
|
+
R --> X[Axial board: failure modes]
|
|
165
|
+
X --> S[Counts + saturation]
|
|
166
|
+
R --> D[(IndexedDB)]
|
|
167
|
+
X --> D
|
|
168
|
+
S --> E[Export JSONL / CSV / Markdown]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
- **Format adapters** turn each of the five formats into one common shape (messages, tool calls with their results). Each format has its own file in `src/adapters/`.
|
|
172
|
+
- **Review** stores a verdict and a note per trace; the id is the record's own id or a hash of its content.
|
|
173
|
+
- **Axial board** assigns each failure note to at most one failure mode.
|
|
174
|
+
- **Counts and saturation** are computed from those annotations by pure functions in `src/core/`.
|
|
175
|
+
- **IndexedDB** keeps everything in your browser; a build-time Content-Security-Policy (`connect-src 'self'`) makes the browser refuse requests to other hosts, so data cannot be sent out by mistake.
|
|
176
|
+
|
|
177
|
+
## When to use it
|
|
178
|
+
|
|
179
|
+
- Good fit: you have trace files and want to find out how your app fails before building automated evals; you want to do it without sending traces to a hosted service.
|
|
180
|
+
- Other tools fit better for: team annotation queues with logins and live data in [Langfuse](https://langfuse.com/) or [Arize Phoenix](https://phoenix.arize.com/); automated scoring at scale, which this tool does not do (it produces the labels and definitions that such a step needs).
|
|
181
|
+
|
|
182
|
+
## Troubleshooting
|
|
183
|
+
|
|
184
|
+
| Symptom | Cause | Fix |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| `unknown trace format: keys=...` | The file matches none of the five formats | Check the listed keys against the formats above; open an issue with those key names (not your data) |
|
|
187
|
+
| "N broken lines" in the summary | Some lines are not valid JSON | Open the listed line numbers in the file; the rest still loads |
|
|
188
|
+
| "spans but no message content" | The instrumentation did not capture prompts and replies | Turn on content capture in your tracing setup and export again |
|
|
189
|
+
| Notes seem gone after reopening | Different file contents give a different fingerprint, or browser data was cleared | Open the same file; import your annotations JSONL backup |
|
|
190
|
+
| "Could not save to this browser" | Storage is blocked (for example a private window) | Keep working, then export the annotations JSONL; notes stay in memory until the tab closes |
|
|
191
|
+
| Port already in use | Another process uses 4178 | `--port 0` picks a free port |
|
|
192
|
+
|
|
193
|
+
## Development
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
npm install
|
|
197
|
+
npm test # 73 tests in 10 files, no network
|
|
198
|
+
npm run lint
|
|
199
|
+
npm run typecheck
|
|
200
|
+
npm run build
|
|
201
|
+
npm run check:docs
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
`npm run shots` regenerates the README screenshots (needs Playwright's Chromium: `npx playwright install chromium-headless-shell`).
|
|
205
|
+
|
|
206
|
+
Known limits: the five formats are verified against hand-built fixtures that follow the official docs and the bundled samples, not against exports from real Langfuse or Phoenix servers. Very large files (tens of thousands of traces) are not optimized yet. Opening the same file in two tabs means the tab that saves last wins.
|
|
207
|
+
|
|
208
|
+
Bugs and ideas are welcome as issues. Changes are listed in [CHANGELOG.md](https://github.com/LeeGyeongPil/trace-codebook/blob/v0.1.1/CHANGELOG.md).
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT. The sample traces are synthetic and are released under the same license.
|
package/bin/messages.mjs
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// CLI 메시지(영어·한국어)와 언어 결정.
|
|
2
|
+
// 우선순위: --lang > TRACE_CODEBOOK_LANG > LC_ALL > LC_MESSAGES > LANG. ko 로 시작하면 한국어, 아니면 영어.
|
|
3
|
+
|
|
4
|
+
export const MESSAGES = {
|
|
5
|
+
en: {
|
|
6
|
+
usage: 'Usage: trace-codebook [file] [options]',
|
|
7
|
+
summary: 'Open LLM traces in your browser for open coding, axial coding and failure-mode counts.\nEverything runs locally: the server listens on 127.0.0.1 only and the app sends nothing out.',
|
|
8
|
+
options: 'Options:',
|
|
9
|
+
optPort: ' --port N port to listen on (default 4178, 0 = any free port)',
|
|
10
|
+
optNoOpen: ' --no-open do not open a browser',
|
|
11
|
+
optLang: ' --lang en|ko message language (also TRACE_CODEBOOK_LANG)',
|
|
12
|
+
optHelp: ' -h, --help show this help',
|
|
13
|
+
optVersion: ' -v, --version show the version',
|
|
14
|
+
examples: 'Examples:',
|
|
15
|
+
ex1: ' npx trace-codebook open the app, then drop a file or try the sample',
|
|
16
|
+
ex2: ' npx trace-codebook traces.jsonl open the app with this file loaded',
|
|
17
|
+
formats: 'Formats: OpenAI / Anthropic message JSONL, OTLP JSON, Langfuse trace JSON, Phoenix span JSONL.',
|
|
18
|
+
running: 'trace-codebook is running at {url}',
|
|
19
|
+
serving: 'Serving {file} (read-only — the file is never modified)',
|
|
20
|
+
stop: 'Press Ctrl+C to stop.',
|
|
21
|
+
openFailed: 'Could not open a browser automatically. Open this address yourself: {url}',
|
|
22
|
+
noDist: 'The built app (dist/) was not found at {dir}. Run `npm run build` first.',
|
|
23
|
+
noFile: 'File not found: {file}',
|
|
24
|
+
notFile: 'Not a regular file: {file}',
|
|
25
|
+
badPort: 'Invalid port: {port} (use 0-65535)',
|
|
26
|
+
badLang: 'Unknown language: {lang} (use en or ko)',
|
|
27
|
+
badOption: 'Unknown option: {option}. See --help.',
|
|
28
|
+
tooMany: 'Only one trace file can be opened at a time.',
|
|
29
|
+
portInUse: 'Port {port} is already in use. Try --port 0 for any free port.',
|
|
30
|
+
stopped: 'Stopped.',
|
|
31
|
+
},
|
|
32
|
+
ko: {
|
|
33
|
+
usage: '사용법: trace-codebook [파일] [옵션]',
|
|
34
|
+
summary: 'LLM 트레이스를 브라우저에서 열어 오픈 코딩·축 코딩·실패 유형 세기를 합니다.\n모두 이 컴퓨터 안에서 돌아갑니다: 서버는 127.0.0.1 에서만 듣고 앱은 밖으로 아무것도 보내지 않습니다.',
|
|
35
|
+
options: '옵션:',
|
|
36
|
+
optPort: ' --port N 사용할 포트 (기본 4178, 0 = 빈 포트 아무거나)',
|
|
37
|
+
optNoOpen: ' --no-open 브라우저를 열지 않음',
|
|
38
|
+
optLang: ' --lang en|ko 메시지 언어 (TRACE_CODEBOOK_LANG 로도 지정)',
|
|
39
|
+
optHelp: ' -h, --help 이 도움말',
|
|
40
|
+
optVersion: ' -v, --version 버전 보기',
|
|
41
|
+
examples: '예:',
|
|
42
|
+
ex1: ' npx trace-codebook 앱을 열고 파일을 끌어 놓거나 샘플로 해 보기',
|
|
43
|
+
ex2: ' npx trace-codebook traces.jsonl 이 파일을 연 채로 앱 열기',
|
|
44
|
+
formats: '형식: OpenAI / Anthropic 메시지 JSONL, OTLP JSON, Langfuse 트레이스 JSON, Phoenix span JSONL.',
|
|
45
|
+
running: 'trace-codebook 실행 중: {url}',
|
|
46
|
+
serving: '{file} 제공 중 (읽기 전용 — 파일은 바뀌지 않습니다)',
|
|
47
|
+
stop: '끝내려면 Ctrl+C 를 누르세요.',
|
|
48
|
+
openFailed: '브라우저를 자동으로 열지 못했습니다. 이 주소를 직접 여세요: {url}',
|
|
49
|
+
noDist: '빌드된 앱(dist/)이 {dir} 에 없습니다. 먼저 `npm run build` 를 실행하세요.',
|
|
50
|
+
noFile: '파일이 없습니다: {file}',
|
|
51
|
+
notFile: '일반 파일이 아닙니다: {file}',
|
|
52
|
+
badPort: '잘못된 포트: {port} (0-65535)',
|
|
53
|
+
badLang: '알 수 없는 언어: {lang} (en 또는 ko)',
|
|
54
|
+
badOption: '알 수 없는 옵션: {option}. --help 를 보세요.',
|
|
55
|
+
tooMany: '트레이스 파일은 한 번에 하나만 열 수 있습니다.',
|
|
56
|
+
portInUse: '포트 {port} 가 이미 쓰이고 있습니다. --port 0 으로 빈 포트를 쓰세요.',
|
|
57
|
+
stopped: '멈췄습니다.',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** 환경변수에서 언어를 고른다(--lang 이 없을 때). */
|
|
62
|
+
export function langFromEnv(env) {
|
|
63
|
+
const explicit = (env.TRACE_CODEBOOK_LANG || '').trim();
|
|
64
|
+
if (explicit) return explicit.toLowerCase().startsWith('ko') ? 'ko' : 'en';
|
|
65
|
+
// POSIX 규칙: LC_ALL > LC_MESSAGES > LANG 중 처음으로 값이 있는 것
|
|
66
|
+
const locale = env.LC_ALL || env.LC_MESSAGES || env.LANG || '';
|
|
67
|
+
return locale.toLowerCase().startsWith('ko') ? 'ko' : 'en';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 메시지 하나를 꺼내 {name} 자리를 채운다 */
|
|
71
|
+
export function msg(lang, id, vars = {}) {
|
|
72
|
+
const text = (MESSAGES[lang] ?? MESSAGES.en)[id] ?? MESSAGES.en[id] ?? id;
|
|
73
|
+
return text.replace(/\{(\w+)\}/g, (m, name) => (name in vars ? String(vars[name]) : m));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function helpText(lang) {
|
|
77
|
+
const m = (id) => msg(lang, id);
|
|
78
|
+
return [
|
|
79
|
+
m('usage'),
|
|
80
|
+
'',
|
|
81
|
+
m('summary'),
|
|
82
|
+
'',
|
|
83
|
+
m('options'),
|
|
84
|
+
m('optPort'),
|
|
85
|
+
m('optNoOpen'),
|
|
86
|
+
m('optLang'),
|
|
87
|
+
m('optHelp'),
|
|
88
|
+
m('optVersion'),
|
|
89
|
+
'',
|
|
90
|
+
m('examples'),
|
|
91
|
+
m('ex1'),
|
|
92
|
+
m('ex2'),
|
|
93
|
+
'',
|
|
94
|
+
m('formats'),
|
|
95
|
+
].join('\n');
|
|
96
|
+
}
|