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

infinimask

v1.0.2

Published

AI-first memory mask system with hierarchical structure and hidden attributes

Readme

InfiniMask

AI-first memory mask system with hierarchical structure and hidden attributes,重构自Book-Chain v9。

架构特点

  • 六层结构: Partition → Domain → Context → Anchor → Index → Atom
  • 隐藏属性系统: Atom包含LLM不可见的元数据(权重、类型、时间戳、标签)
  • 三种召回模式: 默认模式、历史回溯模式、类型限定模式
  • Append-only持久化: 基于日志的崩溃安全存储
  • TypeScript专业实现: 现代化、类型安全、可维护的代码架构

核心组件

Types (src/types.ts)

  • 定义所有核心接口和类型
  • Domain白名单: Personal | Work | Knowledge
  • Atom类型: profile | signal | event
  • 召回模式: default | archive | scoped*

Atom Utilities (src/atom.ts)

  • Atom创建和管理
  • 召回模式解析
  • Atom过滤逻辑

ID Generator (src/idGenerator.ts)

  • 生成唯一ID: {slug}-{hash8}
  • 支持LLM提供的语义前缀
  • 自动处理中英文混合场景

Memory Store (src/memoryStore.ts)

  • Append-only日志存储
  • 定期快照压缩
  • 崩溃恢复机制
  • Schema迁移支持

Memory Navigation (src/memoryNavigation.ts)

  • 内存树遍历和查询
  • 路径解析和ID查找
  • 语义气味提取
  • 模糊匹配支持

InfiniMask Core (src/infiniMask.ts)

  • 主要API入口
  • 写入和读取操作
  • 与原版console.py行为完全对齐

安装与使用

安装依赖

npm install

编译

npm run build

全局安装

npm link              # 或 npm install -g .
infinimask           # 启动交互式 REPL

CLI 命令

infinimask write "我的银行是CCB"           # 自然语言 → 结构化记忆
infinimask query "我的银行是什么"            # 三层探测搜索
infinimask ask "推荐一个理财方案"            # 完整双流对话
infinimask view                              # 渲染记忆树
infinimask stats                             # 密度 + 热度 + 边报告
infinimask edit replace 路径 旧文本 新文本  # 替换原子
infinimask edit deprecate 路径 [原子]       # 标记废弃
infinimask heat "问题"                      # 查询并记录热度
infinimask login                            # 认证并保存 JWT token
infinimask serve --port 3100               # 启动 HTTP API 服务器

HTTP API

# 启动服务
infinimask serve --port 3100

# 注册 & 获取 token
curl -X POST http://localhost:3100/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username":"demo","password":"pass1234"}'

# 写入记忆(带 token)
curl -X POST http://localhost:3100/api/write \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"text":"我的银行是 CCB"}'

# 查询记忆
curl -X POST http://localhost:3100/api/query \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"question":"我的银行是什么"}'

API 使用

import { InfiniMask, MaskServer } from 'infinimask';

// 本地模式
const mask = new InfiniMask('memory_tree.json', './data');
const id = mask.writeEntry('Personal', 'Finance', 'Bank', 'Savings', ['CCB']);

// HTTP 模式
import { createServer } from 'infinimask';
const app = await createServer({ dataDir: './data' });
app.listen(3100);

端点总览 (17 个)

| 路由 | 方法 | 认证 | 说明 | |------|------|------|------| | /api/health | GET | 公开 | 健康检查 | | /api/auth/register | POST | 公开 | 注册用户 | | /api/auth/login | POST | 公开 | 登录获取 token | | /api/masks | GET | JWT | 列出用户的 mask | | /api/masks | POST | JWT | 创建新 mask | | /api/masks/:id | GET | JWT | mask 详情 | | /api/masks/:id/activate | POST | JWT | 切换活跃 mask | | /api/masks/:id | DELETE | JWT | 删除 mask | | /api/write | POST | JWT+mask | NL 写入 | | /api/direct | POST | JWT+mask | 直接写入 | | /api/query | POST | JWT+mask | 探测查询 | | /api/ask | POST | JWT+mask | 双流转发 | | /api/edit/replace | POST | JWT+mask | 替换原子 | | /api/edit/deprecate | POST | JWT+mask | 标记废弃 | | /api/view | GET | JWT+mask | 渲染树 | | /api/stats | GET | JWT+mask | 密度报告 | | /api/heat | POST | JWT+mask | 热度追踪 |

与原版console.py对齐

  • 完全兼容Book-Chain v9的六层结构
  • 相同的ID生成算法和格式
  • 相同的召回模式逻辑
  • 相同的原子权重系统(ACTIVE_WEIGHT = 0.2)
  • 相同的Domain白名单限制
  • 相同的隐藏属性设计

目录结构

InfiniMask/
├── src/                        # 源代码
│   ├── types.ts               # 类型定义
│   ├── atom.ts                # Atom工具
│   ├── idGenerator.ts         # ID生成器
│   ├── memoryStore.ts        # 存储引擎
│   ├── memoryNavigation.ts    # 导航工具
│   ├── infiniMask.ts         # 核心类
│   ├── cli.ts                # CLI入口(12 个子命令)
│   ├── repl.ts               # 交互式 REPL shell
│   ├── index.ts              # 统一导出
│   │
│   ├── server/               # 服务器层
│   │   ├── index.ts         # Express 工厂
│   │   ├── api.ts           # 17 个 REST 端点
│   │   ├── auth.ts          # JWT 认证服务
│   │   └── sessionManager.ts # 会话管理
│   │
│   ├── facade/               # 门面层
│   │   └── MaskServer.ts    # 统一引擎包装器
│   │
│   ├── storage/              # 存储层
│   │   ├── userStore.ts     # 用户管理
│   │   └── maskRegistry.ts  # Mask CRUD
│   │
│   ├── middleware/           # 中间件
│   │   ├── authMiddleware.ts # JWT 验证
│   │   └── maskMiddleware.ts # Mask 解析
│   │
│   └── tests/               # 测试
│       ├── storage.test.ts   # 存储单元测试
│       └── apiIntegration.test.ts # API 集成测试
│
├── dist/                     # 编译输出
├── data/                     # 运行时数据目录
├── package.json             # 依赖配置
├── tsconfig.json            # TypeScript配置
└── README.md               # 项目说明

设计原则

  1. AI使用者优先: 所有设计以LLM的使用体验为最高优先级
  2. 随机性即升维: 路径选择的随机性被视为涌现的来源
  3. 密度决定质量: 召回质量取决于内容密度而非算法复杂度
  4. 专业工程实践: TypeScript类型安全、模块化设计、可测试性
  5. 向后兼容: 完全兼容现有的Book-Chain记忆数据格式

参考架构

基于 F:\Leanchy\VirtuosAgent\BingoCode 的现代化TypeScript架构模式。