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

@chenpu17/prompt-armor

v0.3.12

Published

LLM 防护提示词工厂 — 生成、优化、评测系统级安全提示词,针对会触发工具调用的 AI 应用

Readme

Prompt Armor | LLM 防护提示词工厂

English | 简体中文

npm version CI License: MIT

Prompt Armor 是一个本地化工作台,专门用于为“会触发工具调用的 AI 应用”生成、评测、优化系统级安全提示词。

  • 基于业务背景生成高质量防护提示词
  • 生成红队攻击样本与正常对照样本
  • 运行带报告和失败明细的对抗评测
  • 通过 Auto-Pilot 自动闭环优化提示词
  • 用 OpenAI 兼容接口分别配置 4 个模型角色
  • 以流式方式执行长耗时生成、优化、评测任务

产品界面

它解决什么问题

如果你的产品让 LLM 输出工具调用 JSON,再由运行时去执行这些工具,那么提示词注入和不安全输出仍然可能导致文件读取、命令执行、密钥泄露、提示词泄露,或者生成违规内容。

Prompt Armor 提供的是一套可重复的工程化流程,而不是一次性的“手写安全提示词”。

核心能力

1. 防护提示词生成

  • 基于业务背景、工具面和风险重点生成 system prompt
  • 支持从失败样本反推并迭代优化提示词

2. 红队样本生成

  • 基于自然语言种子生成攻击样本和正常对照样本
  • 支持合并已有样本集,并保留类目覆盖信息

3. 对抗评测

  • 配置目标模型、裁判模型、提示词、样本集和工具档案
  • 跟踪通过率、拒绝率、禁用工具触发率、信息泄露率和分品类表现

4. 自动优化闭环

  • 自动生成初版提示词与初始测试集
  • 评测、收集失败、刷新薄弱类目、优化提示词,并持续循环直到达到目标阈值或不再提升

5. 内置 Mock 工具面

  • 内置 OpenClaw 风格的 mock 工具,如 fsshellnetworkmemorysecretskill_invoke
  • 工具只暴露给目标模型用于声明调用,不真正执行,系统只记录是否触发

工作流

手动模式

  1. 配置四个模型角色:生成器、攻击样本生成器、目标模型、裁判模型
  2. 生成或组合攻击样本集
  3. 基于样本生成防护提示词
  4. 对目标模型运行评测
  5. 查看失败用例,并把提示词优化到下一版

自动优化

填写运行名称、业务背景、几条种子样本、四个模型端点和迭代轮数后,Prompt Armor 会自动执行 generate -> evaluate -> optimize -> refresh 的完整闭环。

一键启动

# 不安装直接运行
npx @chenpu17/prompt-armor

# 或全局安装
npm i -g @chenpu17/prompt-armor
prompt-armor

启动后默认会打开 http://127.0.0.1:7842,数据存放在 ~/.prompt-armor/data.db

CLI 选项

prompt-armor --help
prompt-armor --version
prompt-armor --port 8080
prompt-armor --host 0.0.0.0
prompt-armor --no-open

环境变量:PORTHOSTNO_OPEN=1PROMPT_ARMOR_DATA_DIR

模型接入方式

Prompt Armor 采用四个独立模型角色,全部通过 OpenAI 兼容接口接入:

  • 提示词生成器
  • 攻击样本生成器
  • 被评测目标模型
  • 裁判模型

可以混合使用 OpenAI、DeepSeek、Qwen、Moonshot、Ollama 或自建兼容网关。

本地开发

git clone https://github.com/chenpu17/prompt-armor.git
cd prompt-armor
npm install

# 一条命令同时启动 server + web 开发模式
npm run dev

# 或拆开运行
npm run dev:server
npm run dev:web

构建发布产物:

npm run build
node bin/prompt-armor.js

发布

CI 会在推送到 main 时执行。npm 发布由推送符合 v* 的版本 tag 触发。

git tag -a vX.Y.Z -m "vX.Y.Z"
git push origin main
git push origin vX.Y.Z

许可

MIT © chenpu17