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

work-agent

v0.1.11

Published

AI work agent with local file system access, powered by Next.js

Readme

智能助手

基于 Code as Action 设计理念的通用智能助手,通过与 AI 对话分析问题、生成代码并安全执行。

核心设计理念

Code as Action

系统通过代码执行来解决问题,AI 分析用户需求后生成并执行相应的命令或脚本。所有执行都是可追溯、可审计的。

Skill 扩展系统

通过 Skill 定义垂直领域的专业能力,每个 Skill 包含:

  • 能力描述和使用指南
  • 领域特定的命令模板
  • 风险评估规则

安全执行机制

  • 危险命令拦截:高危操作(如 kubectl delete、rm -rf)自动拦截
  • 工单审批流程:危险操作必须创建工单,经人工审批后执行
  • 审计日志:所有操作都有完整的审计记录

技术架构

┌─────────────────────────────────────────────────────────────┐
│                      用户界面层                              │
│   (Next.js 15 + React 19 + Tailwind CSS)                   │
├─────────────────────────────────────────────────────────────┤
│                      API 层                                  │
│   /api/pi-chat    - AI 对话接口                             │
│   /api/tickets    - 工单管理                                │
│   /api/skills     - Skill 管理                              │
├─────────────────────────────────────────────────────────────┤
│                      核心引擎                                │
│   pi-session      - AI 会话管理 (pi-coding-agent)          │
│   secure-bash     - 安全命令执行 (spawnHook 拦截)          │
│   skill-engine    - Skill 执行引擎                          │
├─────────────────────────────────────────────────────────────┤
│                      安全层                                  │
│   dangerous-commands - 危险命令检测规则                     │
│   ticket-tool        - 工单创建工具                         │
│   workflow           - 工单状态流转                         │
├─────────────────────────────────────────────────────────────┤
│                      数据层                                  │
│   sql.js (SQLite) - 工单、审计日志存储                      │
└─────────────────────────────────────────────────────────────┘

技术栈

  • 前端: Next.js 15 (App Router) + React 19 + Tailwind CSS v4
  • AI 引擎: pi-coding-agent (基于 Claude/GPT 等 LLM)
  • 数据库: sql.js (SQLite 纯 JavaScript 实现)
  • 安全: 危险命令检测 + 工单审批流程

快速开始

本地开发

# 安装依赖
npm install

# 配置 AI 模型 (方式1: 环境变量)
export AI_PROVIDER=anthropic
export AI_API_KEY=your-api-key

# 或创建 models.json (方式2: 配置文件)
mkdir -p ~/.pi/agent
cat > ~/.pi/agent/models.json << EOF
{
  "providers": {
    "anthropic": {
      "baseUrl": "https://api.anthropic.com",
      "api": "anthropic-messages",
      "apiKey": "your-api-key",
      "models": [{ "id": "claude-sonnet-4-20250514" }]
    }
  }
}
EOF

# 启动开发服务器
npm run dev

访问 http://localhost:3000

Docker 部署

# 一键部署 (推荐: 使用环境变量)
docker run -d \
  --name work-agent \
  -p 11024:11024 \
  -v ./data:/app/data \
  -e AI_PROVIDER=zhipu \
  -e AI_API_KEY=your-api-key-here \
  work-agent:latest

支持的 AI 提供商环境变量:

| 变量 | 说明 | 示例 | |------|------|------| | AI_PROVIDER | 提供商 ID | zhipu, anthropic, deepseek, openai | | AI_API_KEY | API 密钥 | your-key-here | | AI_MODEL | 模型 ID (可选) | glm-4.7, claude-sonnet-4-20250514 | | AI_BASE_URL | 自定义 API 地址 (可选) | https://... |

详细部署文档请查看 docs/DEPLOY.md

工作流程

用户请求 → AI 分析 → 判断风险等级
                         │
          ┌──────────────┼──────────────┐
          ↓              ↓              ↓
       安全命令       危险命令       API 调用
       直接执行       创建工单       拦截阻止
          │              │
          ↓              ↓
       返回结果      等待审批
                         │
                    ┌────┴────┐
                    ↓         ↓
                  批准       拒绝
                    │
                    ↓
                  执行命令

工单状态流转

draft → pending → approved → executing → completed
                    │                        │
                    └──→ rejected            └──→ failed
                                                      │
                                                      └──→ pending (可重新提交)

Skill 系统

Skill 目录结构

.pi/skills/
├── k8s-ops/
│   ├── SKILL.json      # Skill 元数据
│   └── SKILL.md        # Skill 描述和使用指南
├── sim/
│   ├── SKILL.json
│   └── SKILL.md
└── ...

创建新 Skill

  1. .pi/skills/ 下创建目录
  2. 创建 SKILL.json 定义元数据
  3. 创建 SKILL.md 描述能力和用法

安全机制

危险命令规则

系统内置了丰富的危险命令检测规则:

  • 容器编排: kubectl delete/apply/create/scale 等
  • 文件系统: rm -rf、chmod 777 等
  • 系统操作: shutdown、reboot 等
  • 数据库: DROP TABLE、TRUNCATE 等

自定义规则

.pi/dangerous-commands.json 中添加自定义规则:

{
  "rules": [
    {
      "pattern": "your-custom-pattern",
      "description": "规则描述",
      "riskLevel": "high"
    }
  ]
}

项目结构

assistant-system/
├── app/                    # Next.js App Router
│   ├── api/               # API 路由
│   │   ├── pi-chat/       # AI 对话 API
│   │   ├── tickets/       # 工单 API
│   │   └── skills/        # Skill API
│   ├── tickets/           # 工单管理页面
│   └── skills/            # Skill 管理页面
├── components/            # React 组件
├── lib/                   # 核心库
│   ├── pi-session.ts     # AI 会话管理
│   ├── secure-bash-tool.ts # 安全命令执行
│   ├── ticket-tool.ts    # 工单创建工具
│   ├── scheduled-task-tool.ts # 定时任务工具
│   ├── dangerous-commands.ts # 危险命令检测
│   ├── skill-engine.ts   # Skill 执行引擎
│   ├── scheduler.ts      # 定时任务调度器
│   ├── db.ts             # 数据库层
│   └── workflow.ts       # 工单工作流
├── .pi/                   # PI 配置目录
│   ├── skills/           # Skill 定义
│   └── dangerous-commands.json # 危险命令配置
└── data/                  # SQLite 数据库文件

命令

# 开发
npm run dev          # 启动开发服务器

# 构建
npm run build        # 构建生产版本
npm start            # 启动生产服务器

# 代码检查
npm run lint         # 运行 ESLint

License

MIT