npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-session-analyzer

v0.1.1

Published

Session search and analysis extension for pi-coding-agent

Downloads

332

Readme

📖 pi-atelier 实战指南 — 从零教会你使用 pi-atelier 扩展生态,包含完整示例和最佳实践。

English | 程序中文文档

pi-session-analyzer

源码仓库 | npm

Session search and analysis for pi — search historical sessions, reconstruct timelines, audit behavior, and generate takeover reports.

Why You Need It

pi generates rich session logs (JSONL), but they're scattered across directories and hard to navigate. When you need to:

  • Find what you did last week
  • Continue work from a previous session
  • Check who modified a file and why
  • Audit an agent session for rule violations

...you'd have to manually dig through JSONL files. pi-session-analyzer gives the AI structured access to every session pi has ever run.

How It Works

┌─── session_search ──────────────────────────────┐
│                                                  │
│  grep ──→ 全文搜索所有会话(支持正则)           │
│  file ──→ 查找修改过特定文件的会话               │
│  list ──→ 列出最近 N 个会话                      │
│                                                  │
└──────────────────────┬───────────────────────────┘
                       │
                       ▼ 找到 sessionId
┌─── session_analyze ─────────────────────────────┐
│                                                  │
│  summary ──→ 元信息 + 摘要(首次分析首选)       │
│  entries ──→ 条目列表(支持 grep + 分页)        │
│  timeline ─→ 时间线(自动标注 [B1][B2] 分支)    │
│  chain ────→ 子代理调用链追踪                    │
│  audit ────→ 规则违规检查                        │
│  digest ───→ user/assistant 对话序列             │
│  branches ─→ 并行分支分析(/tree 产生)          │
│  takeover ─→ 5 维接手报告                        │
│  raw ──────→ 原始 JSONL 数据                     │
│                                                  │
└──────────────────────────────────────────────────┘

Installation

pi install git:github.com/catlain/pi-session-analyzer

Prerequisite: pi must be installed.

Tools

session_search

| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | action | "grep" | "file" | "list" | ✅ | — | Search mode | | query | string | grep/file | — | Keyword (grep) or file path (file) | | limit | number | ❌ | 20 | Max results | | editOnly | boolean | ❌ | false | grep mode: only search edit/write operations |

Examples:

session_search(action: "grep", query: "roadmap")
session_search(action: "file", query: "src/index.ts")
session_search(action: "list", limit: 10)
session_search(action: "grep", query: "error", editOnly: true)

session_analyze

| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | sessionId | string | ✅ | — | Session ID (supports prefix match) | | action | enum | ✅ | — | See action table below | | limit | number | ❌ | 20 | Max entries | | offset | number | ❌ | — | Start position (0-based, entries mode) | | grep | string | ❌ | — | Keyword filter (entries mode, supports regex) |

Action reference:

| Action | Output | Best for | |--------|--------|----------| | summary | Metadata + abstract | First look at a session | | entries | Filtered entry list | Finding specific events | | timeline | Chronological with branch labels | Understanding session flow | | chain | Sub-agent call trace | Debugging sub-agent workflows | | audit | Rule violations | Checking agent behavior | | digest | User/assistant conversation | Reading what happened | | branches | Per-branch analysis | Analyzing /tree forks | | takeover | 5-dimension handoff report | Continuing from a past session | | raw | Raw JSONL entries | Low-level debugging |

Examples:

session_analyze(sessionId: "abc123", action: "summary")
session_analyze(sessionId: "abc123", action: "entries", grep: "error|fail")
session_analyze(sessionId: "abc123", action: "takeover")
session_analyze(sessionId: "abc", action: "entries", offset: 0, limit: 10)  # pagination

Storage

Session data is stored in pi's data directory:

| Data | Location | |------|----------| | Session JSONL files | ~/.local/share/pi-coding-agent/sessions/ | | Per-session entries | {sessionId}.jsonl | | Session ID matching | Prefix match — pass abc to match abc123def... |

Use Cases

| Scenario | Workflow | |----------|----------| | "What did I do last week?" | listsummarydigest | | "Who changed this file?" | file(query: "path/to/file")timeline | | "Continue where I left off" | takeover → get 5-dimension handoff (intent, files, steps, next steps, decisions) | | "Why did this break?" | entries(grep: "error")audit | | "What did the sub-agent do?" | chain → trace sub-agent execution |

Best Practices

✅ Recommended

  • Always start with summary — it's fast and gives you the full picture before drilling in
  • Use grep filter in entries mode to find specific events without loading everything
  • Use prefix match for sessionId — no need to type the full ID
  • For large sessions (>100 entries), use offset + limit for pagination instead of loading all at once
  • Use takeover when switching machines or resuming work the next day

❌ Not Recommended

  • Don't use raw for large sessions — use entries with pagination instead
  • Don't confuse session_search actions (grep/file/list) with session_analyze actions — they're different tools
  • Don't skip summary and go straight to raw — you'll waste context on irrelevant data

Limitations

| Limitation | Detail | |------------|--------| | Read-only | Cannot modify session data, only analyze it | | No real-time streaming | Analyzes completed sessions only | | Prefix match ambiguity | Short prefixes may match multiple sessions | | Audit rules are static | Custom audit rules require code changes |

Architecture

pi-session-analyzer/
├── index.ts              # Entry: register session_search + session_analyze tools
├── core.ts               # Session resolution, JSONL reader, types
├── core-visible.ts       # Visible sub-agent file resolution
├── search.ts             # list + grep implementation
├── search-file.ts        # file search (find sessions editing specific files)
├── search-utils.ts       # Shared search helpers
├── analyze.ts            # summary/entries/timeline/chain/raw/branches
├── digest.ts             # User/assistant conversation extraction
├── audit.ts              # Rule violation checker
├── audit-rules.ts        # Audit rule definitions
├── audit-types.ts        # Audit-specific types
├── takeover.ts           # Takeover tool entry point
├── takeover-core.ts      # 5-dimension takeover report logic
├── tests/                # Unit tests
└── package.json

Dependencies:

  • @pi-atelier/shared-utils (bundled) — truncatedResult for large outputs
  • @earendil-works/pi-coding-agent — ExtensionAPI (peer)

License

MIT