@lijian-ui/pi-preamble

pi 扩展:/preamble 切换助手开场白(条目存 ~/.pi/agent/preambles/<名称>.md),并自动剥离 pi 系统提示中的 <docs> 区块

Packages

Package details

extension

Install @lijian-ui/pi-preamble from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@lijian-ui/pi-preamble
Package
@lijian-ui/pi-preamble
Version
0.1.1
Published
Nov 11, 2026
Downloads
461/mo · 461/wk
Author
lijian-ui
License
MIT
Types
extension
Size
11.4 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@lijian-ui/pi-preamble

pi 扩展:/preamble 切换助手开场白 + 自动剥离 pi 系统提示里的 <docs> 区块。

功能

1. /preamble 开场白切换

在 pi-cli 里运行 /preamble,从 ~/.pi/agent/preambles/ 目录下已保存的条目里选一条应用:

  • /preamble —— 交互式选择条目(生效中的条目会带徽标;末尾有「使用默认开场白(不替换)」)
  • /preamble <名称> —— 直接应用同名条目(支持参数补全,兼容 print / JSON 等非交互模式)
  • 选择后条目内容写入 ~/.pi/agent/preamble.md,下一条消息即生效,无需重启

条目文件由你手动创建:

mkdir -p ~/.pi/agent/preambles
# 每个条目一个 <名称>.md,内容随意(Markdown 都行)
nano ~/.pi/agent/preambles/工作.md
nano ~/.pi/agent/preambles/默认.md

条目内容会被整句替换到系统提示最开头的默认身份描述处。pi 的默认开场白有两版措辞,扩展都已锚定匹配:

  • SDK ≤1.4:You are an expert coding assistant operating inside pi, …
  • SDK ≥1.5:You are a coding assistant running inside pi, …

选择「使用默认开场白」= 把 ~/.pi/agent/preamble.md 写空,回到 pi 默认。

2. 自动剥离 <docs> 区块

pi SDK 会在每回合的系统提示里硬编码注入一个 <docs>…</docs> 文档区块(约 500 token,指向 pi 自身的 README/docs 路径),且没有关闭开关。本扩展在 before_agent_start 钩子里把这段剥掉 —— 与 /preamble 同一个钩子,写入即生效。

安装

pi install npm:@lijian-ui/pi-preamble

或本地试用:

pi -e npm:@lijian-ui/pi-preamble

数据约定

内容 位置
条目库 ~/.pi/agent/preambles/<名称>.md(手动创建)
生效开场白 ~/.pi/agent/preamble.md(/preamble 写入,每回合重读)

「哪个条目生效」不存状态文件:生效内容与条目内容比对即可。

相关

License

MIT