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

promptscript

v0.1.2

Published

Line-structure template language for AI prompts

Downloads

417

Readme

PromptScript

中文版本(当前)| English Version

PromptScript 是一种面向复杂 AI 提示词编排的轻量级模板语言,提供:

  • 条件:通过 @if@else 进行各种判断(支持 @else @if(expr) else-if 链)
  • 循环:通过 @for 遍历记录条目(@for k, v in rec)或整数范围(@for i in 1..5),可接 @else 以处理空记录情况
  • 跨文件引用:通过 @include 内联其他文件,更模块化
  • 动态字段:通过 {path} 插值,具有空值回退与三元表达式等语法
  • 变量:通过 @set 声明,可用于减少重复和提高可读性
  • 记录:一种字面量类型 {key: value}
  • 纯函数渲染器:static render()
  • 注释:就是注释而已

等功能,在轻量简洁静态的基础上,方便开发者组织复杂的 AI 提示词。

PromptScript 是舒月项目的一部分。

PromptScript 使用了 Deepseek AI 辅助实现。

快速上手

$ npm i promptscript
import { PromptScript } from "promptscript";

const ps = new PromptScript(`
@set tone = user.level > 50 ? "亲切" : "客气"
// 这是一些注释,将在解析时被剔除
用户为{user.nickname ?? "朋友"},回复语气应{tone}。
@if (showWeather) {
  "天气:{env.weather | 未知}"
} @else {
  "不允许提供天气信息"
}
@for k, v in tags {
  "- {k}:{v}"
} @else {
  "用户暂无标签"
}
`);

const missing = ps.collectMissing(); // missing = ["user.level", "user.nickname", "showWeather", "env.weather", "tags"]
// …… 宿主应自己提供缺失字段
const text = ps.render({
  "user.level": 60,
  "user.nickname": "舒月",
  showWeather: true,
  "env.weather": undefined,
  tags: { 性格: "温柔", 爱好: "写作" },
});
// text = "用户为舒月,回复语气应亲切。\n天气:未知\n- 性格:温柔\n- 爱好:写作"
  • collectMissing() 返回引擎未能解析的标识符清单。
  • render(values) 用于渲染提示词,用于填充标识符的 values 需由宿主提供。

VSCODE 集成

若想在编辑 PromptScript 时获得语法高亮支持,你可以

  • 使用本仓库 vscode/ 目录下的 VS Code 插件 .vsix ,支持 .ps.promptscript 文件
  • 自行打包 vsix:cd vscode && npm install && npm run package

CLI

promptscript check prompt.ps # 语法/作用域检查
promptscript render prompt.ps vals.json -v user.nickname=阿月 # -v 视为字符串

API

静态方法:

  • PromptScript.render(text, values?, args?, opts?) 将传入的文本视为 PromptScript 尝试解析,不支持 @include 语法。
  • await PromptScript.load(path, { loadFile? }) 读文件 + 解析 + include 展开

实例方法:

  • new PromptScript(text, { loadFile?, file? }) 内存解析
  • await promptScriptInstance.resolve() @include 解析(幂等)
  • promptScriptInstance.collectMissing(): string[] 静态缺失清单
  • promptScriptInstance.render(values, args?) 纯同步渲染;args 覆盖 values

许可证

Apache-2