# Lifelog Daily

> ---

- Skill: `iapplegenius/lifelog-daily` (Agent Skill, multi-file: 22 files)
- Install (CLI): `npx skillmds@latest add iapplegenius/lifelog-daily`
- Raw SKILL.md: https://api.skillmd.com/api/skills/iapplegenius/lifelog-daily/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: iapplegenius (https://skillmd.com/u/iapplegenius)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/iapplegenius/lifelog-daily

---

---
name: lifelog-daily
description: >
  根据用户提供的终端 history 文本和/或视频截图，自动生成当天的个人日志，
  输出详细的 Markdown 文件（daily_YYYY-MM-DD.md）和可视化美观的 HTML 日报
  （daily_YYYY-MM-DD.html）。
  支持跨平台（Windows/macOS/Linux）自动采集 Shell History、浏览器历史、最近文件、
  AI Agent 对话记录（Codex、Claude Code 等），
  首次运行强制配置输出目录，支持多日趋势追踪和历史数据迁移。
  当用户提到"生成日记"、"生成日报"、"记录今天"、"分析我的 history"、
  "把今天的操作整理成日志"、"lifelog"、上传了截图或粘贴了命令历史并希望整理，
  或提供 shell history / 视频截图并希望输出日志/日记/报告时，必须使用此 skill。
  即使用户只说"帮我整理一下今天"也应触发。
---

# LifeLog Daily v2.0 Skill

跨平台个人效能日报生成工具：自动采集数据 -> 智能分析 -> 生成日报 + 趋势追踪

---

## 核心特性

- **跨平台兼容**：自动适配 Windows / macOS / Linux\n- **首次运行强制配置**：必须指定输出目录，配置持久化到 ~/.lifelog/config.json
- **多源数据采集**：Shell History、浏览器历史、最近文件、AI Agent 对话
- **多日趋势追踪**：通过 lifelog-index.json 存储历史统计
- **历史数据迁移**：自动扫描现有日记文件，解析 Markdown 重建索引
- **技能短板检测**：从操作日志中识别技能短板

---

## 数据源支持

| 数据源 | 说明 | 依赖 | 显示位置 |
|--------|------|------|----------|
| Shell History | PowerShell / bash / zsh / fish | 无 | Overview + Timeline |
| 浏览器历史 | Chrome / Edge / Safari / Firefox | better-sqlite3 | Overview + Timeline |
| 最近文件 | Windows Recent / Linux XBEL | 无 | Overview + Timeline |
| AI Agent 对话 | Codex / Claude / Hermes 等 | 无 | Overview + Timeline |

**注意**：所有数据源的统计都会显示在 Overview 的统计卡片中，包括：
- Total Events：所有事件总数
- Shell Commands：Shell 命令数
- AI Conversations：AI 对话数
- Recent Files：最近文件数
- Active Time：活跃时间

### Overview 显示示例

```
Total Events: 29
Shell Commands: 0
AI Conversations: 134
Recent Files: 9
Active Time: 5h 48m
```

### Narrative 显示示例

```
Had 134 AI conversations with codex. Opened 9 files. Active from 02:06 to 07:54 (6h 48m).
```

**注意**：所有数据源的统计都会显示在 Overview 的统计卡片中，包括：
- Total Events：所有事件总数
- Shell Commands：Shell 命令数
- AI Conversations：AI 对话数
- Recent Files：最近文件数
- Active Time：活跃时间

---

## 运行方式

使用 Node.js 运行 scripts/lifelog.js：

`ash
node <skill_dir>/scripts/lifelog.js [options]
`

### 命令行参数

| 参数 | 说明 |
|------|------|
| --output-dir <dir> | 指定输出目录 |
| --save-config | 将目录保存到配置文件 |
| --no-save | 不保存到配置（临时使用） |
| --reconfigure | 重新进行交互式配置 |
| --show-config | 显示当前配置 |
| --date <YYYY-MM-DD> | 生成指定日期的日报 |
| --history-file <file> | 使用指定的 history 文件 |
| --rebuild-index | 从现有日记重建索引 |
| --trend-only | 只生成趋势报告 |
| --days <n> | 趋势报告天数（默认 7） |
| --help | 显示帮助 |

### 使用示例

`ash
# 首次运行（交互式配置输出目录）
node scripts/lifelog.js

# 指定目录并保存配置
node scripts/lifelog.js --output-dir ~/Documents/lifelog --save-config

# 重建索引（从现有日记迁移数据）
node scripts/lifelog.js --rebuild-index

# 生成趋势报告
node scripts/lifelog.js --trend-only --days 30
`

---

## AI Agent 对话采集

### 支持的 Agent

| Agent | 数据位置 | 格式 |
|-------|----------|------|
| Codex (OpenAI) | ~/.codex/logs_2.sqlite | SQLite |
| Claude Code | ~/.claude/conversations.db | SQLite |

### 安装依赖

AI Agent 对话采集需要 better-sqlite3：

`ash
npm install better-sqlite3
`

### 采集内容

- 对话时间戳
- 用户消息和 AI 回复
- 对话主题关键词提取
- 对话轮次统计

---

## 处理流程

### Step 1 - 平台检测与配置

自动检测操作系统，加载 ~/.lifelog/config.json 获取输出目录。
首次运行时强制进行交互式配置。

### Step 2 - 数据采集

按优先级采集：
1. Shell History（必需）
2. 浏览器历史（可选，需 better-sqlite3）
3. 最近文件（可选）
4. AI Agent 对话（可选，需 better-sqlite3）

### Step 3 - 智能分析

- 命令分类统计
- 项目名自动提取
- 工作时间计算
- 技能短板检测
- AI 对话主题提取
- 敏感信息脱敏

### Step 4 - 生成输出

- Markdown（daily_YYYY-MM-DD.md）
- HTML（daily_YYYY-MM-DD.html）：四个 Tab（概览/时间线/洞察/趋势）

### Step 5 - 更新索引

将当日统计追加到 lifelog-index.json，用于多日趋势分析。

---

## 输出文件结构

`
<outputDir>/
├── daily_2026-05-28.md          # Markdown 日报
├── daily_2026-05-28.html        # HTML 日报
├── daily_2026-05-27.md          # 历史日报
├── daily_2026-05-27.html
└── lifelog-index.json           # 索引文件（所有历史统计）
`

---

## 配置文件

位置：~/.lifelog/config.json

`json
{
  "version": "2.0",
  "firstRun": false,
  "outputDir": "/path/to/output",
  "createdAt": "2026-05-28T10:30:00+08:00",
  "updatedAt": "2026-05-28T10:30:00+08:00",
  "preferences": {
    "autoOpen": false,
    "theme": "light",
    "language": "zh-CN",
    "retentionDays": 90
  }
}
`

---

## 索引文件结构

位置：<outputDir>/lifelog-index.json

`json
{
  "version": "2.0",
  "lastUpdated": "2026-05-28T18:30:00+08:00",
  "entries": [
    {
      "date": "2026-05-28",
      "platform": "windows",
      "shell": "powershell",
      "stats": {
        "totalCommands": 156,
        "uniqueCommands": 45,
        "workHours": { "start": "09:30", "end": "18:45", "durationMinutes": 555 },
        "topProjects": [{ "name": "project-a", "commands": 42 }],
        "commandCategories": { "development": 89, "fileOps": 34 },
        "topCommands": [{ "command": "git", "count": 28 }],
        "skillGaps": [{ "id": "docker-sudo", "level": "basic", "resolved": false }],
        "errorCount": 8,
        "retryPatterns": 3,
        "aiConversations": {
          "codex": { "exchanges": 15, "topics": ["lifelog", "nodejs", "sqlite"] }
        }
      }
    }
  ]
}
`

---

## HTML 模板设计

### 视觉风格
- 配色：深墨色 header（#1a1814）+ 暖米色正文（#f7f4ef）
- 字体：Noto Serif SC + Noto Sans SC + JetBrains Mono
- 强调色：#c0392b（红）、#1d3557（蓝）、#2d6a4f（绿）

### 结构
- **概览 Tab**：分类卡片 + 时间分布图 + AI 摘要
- **时间线 Tab**：命令时间线，带类型标签和颜色
- **洞察 Tab**：技能增强雷达 + 命令统计
- **趋势 Tab**：7 天趋势图表（SVG）+ 智能洞察

---

## 技能增强模块

每次生成日报时自动执行，从操作日志中识别技能短板：

### 诊断信号
1. 错误重试：同一问题出现 2+ 次 -> 基础知识缺失
2. 绕道解决：用复杂方式解决简单问题
3. 遗漏基础操作：有更直接的命令/方法
4. 依赖他人方案：直接复制命令但不理解参数
5. 效率低下：手动重复可自动化的操作

### 短板分级
- **BASIC**：基础能力不足，直接给出命令和解释
- **ADVANCED**：进阶能力短板，给出学习方向

---

## 隐私与安全

- 自动隐去含 password、secret、token、key、api_key 的敏感参数
- export 命令和 curl/wget 带 Authorization header 的命令被脱敏
- 所有数据本地处理，不上传任何信息

---

## 依赖

- Node.js >= 18.0.0
- better-sqlite3（可选，用于浏览器历史和 AI Agent 对话采集）

---

## 触发场景

- 用户粘贴命令历史："帮我整理成今天的日记"
- 用户上传截图 + history："生成今天的 lifelog"
- 用户说："把我今天的终端操作做成日报"
- 用户说："分析我今天做了什么，输出 md 和 html"
- 用户说："帮我整理一下今天"
- 用户说："记录一下我今天和 Codex 的对话"

