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-hindsight-stats

v0.1.0

Published

Hindsight memory analytics CLI — tags, entities, and bank statistics for Pi agent sessions

Readme

pi-hindsight-stats

npm version License: MIT TypeScript

Hindsight memory analytics for Pi agent sessions — fetches tags, entities, entity-graph hotspots, and mental models from Hindsight banks and renders a compact project-insight cover.

Injected into Pi agent context on session start (async, non-blocking) or queried on-demand via CLI and slash commands.

Features

  • Tag analytics — top tags with level-grouping and ranking
  • Entity tracking — most-mentioned named entities with mention counts
  • Graph visualization — hotspot chains from entity relationship graph
  • Mental models — active mental model summaries
  • TTL-based disk cache — avoids redundant API calls with configurable TTL
  • Token-budgeted rendering — respects configurable max token budget for context injection
  • Non-blocking injection — async fire-and-forget on session_start, never blocks Pi workflow
  • Configurable steps — enable/disable individual stat sections independently

Example Output

[Top Tags]
- repo:vendor-omo (182)
- topic:auth (91)

[Top Entities]
- Stripe (31)
- AuthService (28)

[Hotspots]
- AuthService ↔ Stripe ↔ SessionToken

[Top Mental Models]
- active-project-goals
- coding-constraints

Installation

For Humans

npm install pi-hindsight-stats

For AI Agents

Add to your Pi settings.json packages array:

{
  "packages": [
    "pi-hindsight-stats"
  ]
}

For pi git-sourced

Add the git URL to your Pi settings.json packages array:

{
  "packages": [
    "https://github.com/buihongduc132/pi-hindsight-stats"
  ]
}

Or local path for development:

{
  "packages": [
    "/path/to/pi-hindsight-stats"
  ]
}

Prerequisites

  • A running Hindsight server
  • Pi CLI agent (@mariozechner/pi-coding-agent)

Configuration

Create ~/.hindsight/stats-config.json:

{
  "enabled": true,
  "baseUrl": "http://localhost:8888",
  "bankId": "my-bank",
  "injectOnSessionStart": true,
  "cache": {
    "dir": "~/.hindsight/cache/stats",
    "ttlSeconds": 600
  },
  "steps": {
    "topTags": { "enabled": true, "limit": 5, "maxTokens": 120, "level": 2 },
    "topEntities": { "enabled": true, "limit": 5, "maxTokens": 120 },
    "hotspots": { "enabled": true, "limit": 5, "maxTokens": 160, "level": 2 },
    "topMentalModels": { "enabled": true, "limit": 5, "maxTokens": 120 }
  },
  "render": {
    "totalMaxTokens": 420,
    "compact": true
  }
}

Config precedence

env vars (HINDSIGHT_BASE_URL, HINDSIGHT_API_KEY, HINDSIGHT_BANK_ID)
  > ~/.hindsight/stats-config.json
  > defaults

Step options

| Step | Config key | Description | |------|-----------|-------------| | Top Tags | topTags | Most frequent tags across all facts | | Top Entities | topEntities | Most mentioned named entities | | Hotspots | hotspots | Highly connected entity clusters from the entity graph | | Top Mental Models | topMentalModels | Active mental model summaries |

Each step supports: enabled, limit, maxTokens, and optional level (graph traversal depth).

Usage

Pi Extension (automatic)

When installed as a Pi package, the extension auto-registers hooks and commands:

  • Session start — if injectOnSessionStart is true, fetches and injects a stats cover into context (non-blocking)
  • hindsight-stats:cover — show stats cover on demand via Pi slash command
  • hindsight-stats:cache-clear — clear the stats cache via Pi slash command

CLI

# Full cover report
npx hindsight-stats cover

# Individual sections
npx hindsight-stats top-tags --limit 10
npx hindsight-stats top-entities --limit 10
npx hindsight-stats hotspots --limit 5
npx hindsight-stats top-mental-models --limit 5

# Cache management
npx hindsight-stats cache-clear

# Diagnostics
npx hindsight-stats doctor

Architecture

src/
├── index.ts    # Pi extension — session_start hook, async injection
├── client.ts   # Hindsight REST API client (tags, entities, mental models)
├── config.ts   # Config resolution with file/env/defaults
├── cache.ts    # TTL-based disk cache
└── steps.ts    # Individual stat extraction + rendering
cli/
└── index.ts    # Standalone CLI entry point
tests/          # Vitest test suite

Development

npm install
npm run typecheck
npm test

License

MIT © 2025 buihongduc132