Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
path: packages/ui/src/generated

- name: Setup pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@v5

- name: Setup Node.js
uses: actions/setup-node@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5

- name: Setup Node.js
uses: actions/setup-node@v6
Expand Down
35 changes: 35 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// cSpell Settings
{
// Version of the setting file. Always 0.2
"version": "0.2",
// language - current active spelling language
"language": "en",
// words - list of words to be always considered correct
"words": [
"cdylib",
"chrono",
"fsevent",
"githubusercontent",
"lumo",
"mkdirp",
"reqwest",
"rlib",
"rustls",
"serde",
"shiki",
"snapdom",
"sqlx",
"staticlib",
"streetsidesoftware",
"tauri",
"tsmerge",
"typeshare",
"visualstudio",
"vsmarketplacebadge",
"zumer"
],
// flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors.
// For example "hte" should be "the"
"flagWords": ["hte"]
}
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"biomejs.biome",
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer",
"bradlc.vscode-tailwindcss",
"streetsidesoftware.code-spell-checker"
]
}
35 changes: 35 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
// Biome as default formatter & linter
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.biome": "explicit",
"source.organizeImports.biome": "explicit"
},

// Disable built-in JS/TS validation to avoid conflicts
"js/ts.validate.enabled": false,

// Per-language formatter overrides (ensure Biome is used)
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
},

// Tauri
"rust-analyzer.cargo.features": "all"
}
162 changes: 52 additions & 110 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -1,147 +1,89 @@
# Lumo OTLP Daemon - 快速启动指南
# Lumo — 开发快速入门

## 5 分钟快速开始
## 环境要求

### 1. 安装 Daemon
| 工具 | 最低版本 | 安装方式 |
|------|---------|---------|
| Node.js | >= 24.12 | [nodejs.org](https://nodejs.org/) |
| pnpm | >= 10.26 | `npm install -g pnpm` |
| Rust (stable) | >= 1.77.2 | [rustup.rs](https://rustup.rs/) |
| typeshare-cli | latest | `cargo install typeshare-cli` |
| Tauri 平台依赖 | — | [Tauri v2 Prerequisites](https://v2.tauri.app/start/prerequisites/) |

```bash
# 在项目根目录执行
./scripts/install-daemon.sh
```

这会自动:
- ✅ 编译 daemon
- ✅ 安装到 `/usr/local/bin/lumo-daemon`
- ✅ 配置 launchd 自动启动
- ✅ 启动服务

### 2. 验证运行

```bash
# 检查健康状态
curl http://localhost:4318/health

# 应返回:
# {"status":"healthy","service":"lumo-daemon","version":"0.1.0"}
```

### 3. 配置 Claude Code
## 首次启动

```bash
# 设置环境变量
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

# 然后正常使用 Claude Code
claude code
```
# 1. 安装前端依赖
pnpm install

### 4. 查看接收到的数据
# 2. 编译 daemon(首次必须,后续 daemon 代码变更后也需要重新编译)
cargo build -p lumo-daemon

```bash
# 实时查看日志
tail -f ~/Library/Logs/com.lumo.daemon/stdout.log
# 3. 启动开发环境(会自动生成 TypeScript 类型 + 启动前端 dev server + 启动 Tauri 应用)
pnpm tauri:dev
```

当你使用 Claude Code 执行命令时,会看到类似这样的输出:
> **注意**:`pnpm tauri:dev` 会自动运行 `pnpm generate-types`(Rust → TypeScript 类型生成)和 `pnpm dev`(Next.js dev server),但**不会**自动编译 daemon。首次或 daemon 代码变更后需要手动执行 `cargo build -p lumo-daemon`。

```
2026-01-25T12:00:00.000Z INFO lumo_daemon: Received OTLP trace export request
2026-01-25T12:00:00.000Z INFO lumo_daemon: Service: claude-code
2026-01-25T12:00:00.000Z INFO lumo_daemon: Scope: claude-code-instrumentation
2026-01-25T12:00:00.000Z INFO lumo_daemon: Span[5B8EFFF7]: name='tool.Read', kind=Internal, duration=125000ns, attributes=[tool.name=Read, file.path=/path/to/file]
2026-01-25T12:00:00.000Z INFO lumo_daemon: Processed 1 spans successfully
```
## 日常开发

## 常用命令

### 服务管理
### 全栈开发(推荐)

```bash
# 查看状态
launchctl list | grep com.lumo.daemon

# 停止服务
launchctl unload ~/Library/LaunchAgents/com.lumo.daemon.plist

# 启动服务
launchctl load ~/Library/LaunchAgents/com.lumo.daemon.plist

# 卸载
./scripts/uninstall-daemon.sh
pnpm tauri:dev # 启动 Tauri 应用 + 前端 dev server
```

### 日志查看
### 仅前端

```bash
# 标准输出(主要日志)
tail -f ~/Library/Logs/com.lumo.daemon/stdout.log

# 错误日志
tail -f ~/Library/Logs/com.lumo.daemon/stderr.log
pnpm dev # Next.js dev server (localhost:3000)
pnpm build # 构建静态站点到 packages/ui/out/
pnpm lint # Biome 代码检查
pnpm check # Biome 代码检查 + 格式化(自动修复)
```

### 测试端点
### 仅 Rust

```bash
# 健康检查
curl http://localhost:4318/health

# 发送测试 trace
curl -X POST http://localhost:4318/v1/traces \
-H "Content-Type: application/json" \
-d '{"resourceSpans":[{"scopeSpans":[{"spans":[{"traceId":"TEST123","spanId":"SPAN456","name":"test","kind":1,"startTimeUnixNano":"1000000000"}]}]}]}'
cargo check # 检查所有 crate
cargo check -p app # 检查 Tauri 应用(包名是 "app")
cargo check -p lumo-daemon # 检查 daemon
cargo check -p shared # 检查共享库
cargo run -p lumo-daemon # 直接运行 daemon
```

## 故障排查

### 问题:端口已被占用
### 类型生成

```bash
# 查看谁在使用 4318 端口
lsof -i :4318

# 如需更换端口,编辑 plist
nano ~/Library/LaunchAgents/com.lumo.daemon.plist
# 修改 LUMO_SERVER_ADDRESS 环境变量
# 然后重新加载服务
pnpm generate-types # 从 Rust #[typeshare] 结构体生成 TypeScript 类型
```

### 问题:服务无法启动
修改了 `src-tauri/src/types/` 中的 `#[typeshare]` 结构体后需要重新生成。`pnpm tauri:dev` 启动时会自动运行。

```bash
# 查看错误日志
cat ~/Library/Logs/com.lumo.daemon/stderr.log
## 何时需要重新编译 Daemon

# 手动运行 daemon 查看详细错误
/usr/local/bin/lumo-daemon
```
Daemon 是独立的 HTTP 服务,通过 Tauri 应用管理其生命周期。以下情况需要重新编译:

### 问题:收不到 Claude Code 数据

1. 确认环境变量已设置:
```bash
echo $OTEL_EXPORTER_OTLP_ENDPOINT
# 应输出:http://localhost:4318
```

2. 确认 daemon 正在运行:
```bash
curl http://localhost:4318/health
cargo build -p lumo-daemon
```

3. 查看 daemon 日志是否有请求进来
- 修改了 `crates/daemon/` 下的代码
- 修改了 `crates/shared/` 下的代码(daemon 和 Tauri app 共用)
- 修改了 `crates/shared/migrations/` 中的数据库迁移

## 下一步
> `pnpm tauri build`(生产构建)会自动编译 daemon,但 `pnpm tauri:dev`(开发模式)不会。

- 📖 查看 [daemon/README.md](daemon/README.md) 了解详细文档
- 🔍 探索接收到的 trace 数据结构
- 🚀 等待后续版本支持数据库存储和可视化
## 项目结构概览

## 当前限制(MVP 版本)

- ✅ 接收并打印 OTLP 数据
- ❌ 暂不支持数据持久化
- ❌ 暂无 UI 查看器
- ❌ 仅支持 macOS
```
lumo/
├── packages/ui/ # Next.js 前端(SSG 模式)
├── crates/
│ ├── daemon/ # OTLP 遥测接收服务(Axum HTTP)
│ └── shared/ # 共享库(数据库实体、仓库、迁移)
├── src-tauri/ # Tauri 桌面应用(命令、服务、类型)
└── scripts/ # 构建和安装脚本
```

后续版本会逐步添加这些功能
详细架构说明见 [CLAUDE.md](CLAUDE.md)
Loading