agent-diary
v0.2.2
Published
Sentiment + interaction analysis of AI agent conversation logs. Generates an HTML report summarizing your daily conversations across multiple AI CLI tools.
Downloads
922
Maintainers
Readme
Agent Diary
Sentiment + interaction analysis of AI agent conversation logs. Generates a dark-themed HTML report summarizing your daily conversations across multiple AI CLI tools.
Quick Start
# No installation needed — runs directly via npx
npx agent-diary
# Analyze a specific date
npx agent-diary --date 2026-06-11
# Analyze only specific sources
npx agent-diary --sources hermes,claude
# Rolling windows (7, 30, 365 days)
npx agent-diary --range week
npx agent-diary --date 2026-06-11 --range month
# Calendar month (by name or YYYY-MM)
npx agent-diary --range June
npx agent-diary --range 2026-05
# Calendar year
npx agent-diary --range 2025
# Custom output path
npx agent-diary --date 2026-06-11 --output my-report.htmlRequirements: Node.js ≥ 18. That's it. No Python, no virtualenv, no pip.
Supported Sources
| Source | CLI Tool | Data Location |
|--------|----------|---------------|
| hermes | Hermes AI shell | ~/.hermes/state.db |
| pi | pi coding agent | ~/.pi/agent/sessions/*.jsonl |
| claude | Claude Code | ~/.claude/projects/*/<session>.jsonl |
| opencode | OpenCode | ~/.local/share/opencode/opencode.db |
Sources are auto-detected. If a CLI isn't installed, its parser is silently skipped.
How It Works
- Parsers extract session logs from each AI CLI's local storage (one parser per source).
- Analyzers run three passes over agent (assistant) messages:
- Sentiment — polarity scoring via wink-sentiment, normalized to [-1, 1].
- Tone — regex pattern matching for apology, confidence, uncertainty, helpfulness, self-correction, and question-asking. Supports English, Indonesian with automatic language detection via franc.
- Interaction — session quality metrics: correction rate, clarification rate, clean exit rate.
- Reporter renders an interactive HTML dashboard with embedded CSS and JavaScript.
HTML Report Features
- Overall agent sentiment (positive/negative/neutral)
- Effectiveness score with labeled rating (effective/balanced/struggling)
- Polarity distribution chart
- Agent behavior breakdown (tone rates)
- Interaction quality metrics
- Per-source comparison table
- Notable chats — best and worst agent messages by sentiment
- Clickable session transcripts with full message history
- In/out token counts per session
- Source filtering (when multiple sources are active)
CLI Options
| Flag | Short | Default | Description |
|------|-------|---------|-------------|
| --date | -d | today | Anchor date in YYYY-MM-DD format. Used with --range. |
| --range | -r | — | Date range mode. One of: week, month, year, <month-name>, YYYY-MM, YYYY. |
| --sources | -s | all detected | Comma-separated list: hermes,pi,claude,opencode |
| --output | -o | diary-<label>.html | Custom output path. Default: diary-YYYY-MM-DD.html (single day) or diary-range-<value>.html (range). |
| --help | -h | — | Show usage |
Project Layout
agent-diary/
├── src/ # TypeScript source
│ ├── index.ts # Entry point (#!/usr/bin/env node)
│ ├── cli.ts # CLI parsing + pipeline orchestration
│ ├── date-utils.ts # Date-range resolution (--range, --date)
│ ├── types.ts # All interfaces (Session, Message, AnalysisResult, DateRange)
│ ├── utils/ # Shared utilities
│ │ └── pricing.ts # Model pricing tables & cost estimation
│ ├── parsers/ # One parser per source (1:1 mapping)
│ │ ├── detector.ts # Auto-detect installed CLIs
│ │ ├── hermes.ts # SQLite reader (accepts startMs, endMs)
│ │ ├── pi.ts # JSONL reader (accepts startMs, endMs)
│ │ ├── claude.ts # JSONL reader (accepts startMs, endMs)
│ │ └── opencode.ts # SQLite reader (accepts startMs, endMs)
│ ├── analyzers/ # Three analysis passes
│ │ ├── lang_utils.ts # Language detection + pattern tables (EN, ID, KZ)
│ │ ├── sentiment.ts # Polarity scoring
│ │ ├── tone.ts # Behavioral pattern matching
│ │ └── interaction.ts # Session quality metrics
│ └── reporters/
│ └── renderer.ts # HTML generation
├── templates/
│ └── report.html # HTML template with dark theme CSS
├── CONTEXT.md # Domain glossary and rules
├── AGENTS.md # Guide for AI coding agents
├── PRICING.md # Pricing documentation & cost estimation details
├── package.json
└── tsconfig.jsonDevelopment
# Install dependencies
npm install
# Build
npm run build
# Run
node dist/index.js --date 2026-06-11
# Watch mode
npm run devCost Estimation
Cost estimation supports Claude (via Anthropic pricing table) and OpenCode Go (per-token rates for Go subscription models). Every parser prefers native cost data from its own CLI, then falls back to the pricing table based on the session's model name and token counts. See PRICING.md for details.
Architecture Decisions
See CONTEXT.md for the domain glossary and AGENTS.md for architecture details and conventions.
Key decisions:
- 1:1 source-to-parser mapping — each AI CLI gets exactly one parser
- Session is the canonical term (not "Conversation")
- Parser signature — all parsers accept
(startMs: number, endMs: number)for millisecond-precision time windows - Date ranges —
resolveDateRange()indate-utils.tsconverts CLI flags to aDateRange; all timestamps computed in local time - No Python dependency — full TypeScript rewrite from the original Python implementation
- Self-contained HTML — no external CSS, JS, or font dependencies
Multilingual Support
| Language | Code | Tone Patterns | Interaction Patterns |
|----------|------|---------------|---------------------|
| English | en | ✅ Full set | ✅ Full set |
| Indonesian | id | ✅ Full set | ✅ Full set |
Language is auto-detected per session via franc. Falls back to English for unsupported languages.
To add a new language, add pattern tables in src/analyzers/lang_utils.ts.
License
MIT
