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

@uiyzzi/pi-shroud

v0.2.1

Published

High-performance secret firewall for pi — secrets usable as shell vars, never visible to models

Readme

shroud

pi 的 secret firewall。agent 能用你的 API key,但永远看不到值。

@arvoretech/pi-secret-firewall fork 出来,完全重写。

它做什么

启动时自动发现你的 secrets,之后所有流向模型的内容都会被 redact:

  • process.env 里名字像 secret 的变量(*_TOKEN*_API_KEYDATABASE_URL...)
  • ~/.pi/agent/auth.json(pi 自己的 API key store)
  • .env / .env.local / .env.development*
  • ~/.netrc~/.aws/credentials~/.docker/config.json

模型看到的永远是占位符:

sk-abc123...  →  «SECRET OPENAI_API_KEY redacted — ... read it in bash as "$OPENAI_API_KEY"»

模型在 bash 里引用 $OPENAI_API_KEY,shell 解析真实值,值从不进模型上下文。16 个内置 pattern(JWT、AWS key、GitHub token、PEM block、连接串...)兜底匹配未知格式。

pi install npm:@uiyzzi/pi-shroud

命令

/shroud:当前保护了多少 secret,拦截了多少次 /shroud-toggle:开关 redact /shroud-rescan:重新扫描 env 和凭据文件

和 askpass 联动(自动)

装了 pi-askpass 时自动同步,走 globalThis 周知 Symbol 桥。桥是 duck-typed 的,没装对方就静默跳过,加载顺序无所谓。

  • push:askpass 每捕获一个密钥,立刻推进 shroud 的 redactor(addRuntimeSecret),没有 rescan 空窗
  • pull:shroud rescan 时拉 askpass 的已捕获列表,加载前捕获的也覆盖;同名冲突以 askpass 为准,用户刚输的总是最新

配置

~/.pi/agent/shroud.json(全局)和 .pi/shroud.json(项目),deep merge,项目优先。

{
  "patterns": [
    { "name": "ACME", "regex": "acme-[0-9a-f]{12}" },
    { "name": "CORP", "regex": "corp_[A-Za-z0-9]{24}", "flags": "i" }
  ],

  "discovery": {
    "disabled": ["netrc", "aws-credentials", "docker-config"],

    "extraFiles": [
      { "path": "/etc/secrets.env",      "format": "dotenv" },
      { "path": "/etc/config.json",      "format": "json", "jsonKeys": ["apiKey"] },
      { "path": "/etc/credentials.ini",  "format": "ini" },
      { "path": "/etc/api-token",        "format": "raw", "secretName": "DEPLOY_TOKEN" }
    ]
  }
}

三种自定义维度:

| 配置 | 控制 | |---|---| | patterns | 事后:正则匹配新 token 格式 | | discovery.disabled | 事前:关掉内置凭据文件解析 | | discovery.extraFiles | 事前:加自定义文件,dotenv / json / ini / raw 四种格式 |

和同类项目的区别

pi-redact-all 检测层更多(熵、X.509、PII),但标记格式是 [REDACTED:type]。模型看到这个标记后没法用它调 API,只能再问你要。

shroud 走 shell var 占位符路线。模型写 $VAR,shell 解析 $VAR。值不在上下文里,但能动。

误报风险高的层没移植。熵检测杀 git hash 和 base64 输出,PII 杀 git config 里的邮箱。X.509 裸 DER 在 agent 场景几乎不出现。保留的都是特征明确、误报极低的模式。

架构

src/
├── index.ts         入口(thin)
├── engine.ts        联合正则引擎,一次扫描
├── discovery.ts     事前发现(env / auth.json / .netrc / aws / docker / .env)
├── config.ts         配置加载
├── hooks.ts          四个事件钩子 + 环境变量碰撞保护 + addRuntimeSecret
├── bridge.ts         askpass 联动(globalThis symbol 桥,双向)
├── commands.ts       三个 /shroud 命令
└── util.ts           工具函数

性能

所有 literal 值编译为一个联合正则,单次 String.replace。16 个 pattern 跑第二轮。

| 场景 | 耗时 | |---|---| | 50 secrets × 100 段文本 | 0.12ms | | 26 patterns(16 内置 + 10 自定义) | 0.014ms | | refresh(20 secrets) | 0.022ms |

开发

npm install
npm run build      # tsc → dist/
npm test           # 77 测试(单元 + 性能 + 边界)