pi-scenes 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -25
- package/assets/scene-prompts/coding/pre-commit.md +12 -0
- package/assets/scene-prompts/data/data-audit.md +15 -0
- package/assets/scene-prompts/office/doc-from-notes.md +13 -0
- package/assets/scene-prompts/pm/prd-skeleton.md +17 -0
- package/assets/scene-prompts/research/deep-dive.md +16 -0
- package/assets/scene-prompts/writing/fact-check.md +14 -0
- package/extensions/scenes.ts +437 -132
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,7 +19,10 @@ active resources = common layer ∪ current scene
|
|
|
19
19
|
|
|
20
20
|
- **Common layer** — extensions + skills that stay loaded in *every* scenario (quota display, session carryover…)
|
|
21
21
|
- **Scene layers** — per-scenario bundles (coding / office / writing…), loaded only while active
|
|
22
|
-
-
|
|
22
|
+
- **Project-scoped by default (v0.7)** — `/scene office` writes activation entries to `<cwd>/.pi/settings.json`, so a scene belongs to *this* directory only; opening a fresh directory starts clean. `--global` keeps the ≤0.6 all-projects behavior
|
|
23
|
+
- **Asset/activation split (v0.7)** — packages are installed once globally and shared across projects; git skill bundles are pinned as zero-exposure *anchors* (`{source, autoload:false, skills:[]}`) in user settings, while the project layer writes a *delta* (`{source, autoload:false, skills:[...]}`) that enables just the scene's whitelist — one clone, per-project curation, via pi's native delta mechanism
|
|
24
|
+
- **Scene-scoped prompt templates (v0.8)** — each scene can also bundle workflow templates (`prompts` field): fixed checklists that pin down step-by-step procedures so the model can't take shortcuts. Scene = **tools + skills + workflow templates** as one unit
|
|
25
|
+
- Switching rewrites `packages`/`skills` in `settings.json`, then `ctx.reload()` hot-reloads — **no pi restart, session untouched**; prompt templates take a different path: injected via pi's `resources_discover` event with **zero settings writes**
|
|
23
26
|
- Every switch stamps a persistent **status-bar badge** (`◆ coding`, or a per-scene `icon` like `💻 coding`) so the bar always answers *"which scene am I in"* — restored at session start, cleared by `/scene off`
|
|
24
27
|
- **Zero-memory discoverability (v0.4.1)** — the command hint lists your scene names, and Tab completion shows every scene (icon + description + current marker) plus subcommands: type `/scene c` + Tab → `/scene coding`
|
|
25
28
|
- The data model reserves an `extends` chain (with cycle detection) for future **parent → child scene** hierarchies
|
|
@@ -41,13 +44,15 @@ Then `/reload` and `/scene` is live.
|
|
|
41
44
|
## Quick start
|
|
42
45
|
|
|
43
46
|
```
|
|
44
|
-
/scene # picker: all scenes, ● current, ○
|
|
47
|
+
/scene # picker: all scenes, ● current project scene, ◐ global, ○ inactive
|
|
45
48
|
/scene <Tab> # tab-complete: lists all scenes (icon + description) and subcommands
|
|
46
49
|
/scene c<Tab> # completes to /scene coding — no scene names to memorize
|
|
47
|
-
/scene coding # switch
|
|
50
|
+
/scene coding # switch to the coding scene (project-scoped: <cwd>/.pi only)
|
|
51
|
+
/scene coding --global # switch as a global scene (every project, ≤0.6 behavior)
|
|
48
52
|
/scene office # switch to the office scene
|
|
49
|
-
/scene off # common layer only (
|
|
50
|
-
/scene status # show
|
|
53
|
+
/scene off # common layer only (clears both layers; anchors kept)
|
|
54
|
+
/scene status # show project/global scenes + effective packages/skills
|
|
55
|
+
/scene migrate # convert a ≤0.6 legacy global scene into this project's scene
|
|
51
56
|
/scene init # scaffold scenes.json template + scene skill dirs
|
|
52
57
|
/scene stats # usage dashboard: sessions, tool calls, reflections
|
|
53
58
|
/scene evolve # generate & apply evolution proposals (confirm-first)
|
|
@@ -56,15 +61,17 @@ Then `/reload` and `/scene` is live.
|
|
|
56
61
|
|
|
57
62
|
First run of `/scene` offers to generate the template. It ships with **seven preset scenes + common** — a curated best-practice collection (all packages verified on npm/GitHub, 2026-09). v0.6.0 upgrades the presets with a full skill layer: git skill bundles install per scene with object-form resource filters, and research/writing ship vendored starter skills:
|
|
58
63
|
|
|
59
|
-
| Scene | Extensions | Skills |
|
|
60
|
-
|
|
61
|
-
| `common` | `npm:pi-scenes`, `npm:pi-carryover` | — (your own dir) |
|
|
62
|
-
| `coding` | `npm:pi-lens`, `npm:pi-subagents`, `npm:pi-git-worktree`, `npm:pi-simplify` | `openclaw/agent-skills` → autoreview, handoff;`anthropics/skills` → frontend-design, webapp-testing, mcp-builder |
|
|
63
|
-
| `office` | `npm:pi-docparser` | `anthropics/skills` → docx, pptx, xlsx, pdf, internal-comms |
|
|
64
|
-
| `pm` | `npm:pi-web-access`, `npm:pi-goal-x`, `npm:@juicesharp/rpiv-todo`, `npm:@juicesharp/rpiv-ask-user-question` | — |
|
|
65
|
-
| `research` | `npm:pi-web-access`, `npm:pi-subagents` | 预置:arxiv-research, openalex-paper-search |
|
|
66
|
-
| `writing` | `npm:pi-web-access` | `anthropics/skills` → doc-coauthoring;预置:humanizer |
|
|
67
|
-
| `data` | `npm:pi-docparser`, `npm:pi-mcp-adapter` | — |
|
|
64
|
+
| Scene | Extensions | Skills | Prompt templates (v0.8) |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `common` | `npm:pi-scenes`, `npm:pi-carryover` | — (your own dir) | — |
|
|
67
|
+
| `coding` | `npm:pi-lens`, `npm:pi-subagents`, `npm:pi-git-worktree`, `npm:pi-simplify` | `openclaw/agent-skills` → autoreview, handoff;`anthropics/skills` → frontend-design, webapp-testing, mcp-builder | `/pre-commit` |
|
|
68
|
+
| `office` | `npm:pi-docparser` | `anthropics/skills` → docx, pptx, xlsx, pdf, internal-comms | `/doc-from-notes` |
|
|
69
|
+
| `pm` | `npm:pi-web-access`, `npm:pi-goal-x`, `npm:@juicesharp/rpiv-todo`, `npm:@juicesharp/rpiv-ask-user-question` | — | `/prd-skeleton` |
|
|
70
|
+
| `research` | `npm:pi-web-access`, `npm:pi-subagents` | 预置:arxiv-research, openalex-paper-search | `/deep-dive` |
|
|
71
|
+
| `writing` | `npm:pi-web-access` | `anthropics/skills` → doc-coauthoring;预置:humanizer | `/fact-check` |
|
|
72
|
+
| `data` | `npm:pi-docparser`, `npm:pi-mcp-adapter` | — | `/data-audit` |
|
|
73
|
+
|
|
74
|
+
Each preset template is a fixed procedure that forbids step-skipping (e.g. `/pre-commit` = build → test → diff review → commit message, each step ✅/❌ with evidence). After switching scenes, try the scene's template command directly; drop your own `.md` files into `~/.pi/agent/scenes/<name>/prompts/` to add more.
|
|
68
75
|
|
|
69
76
|
Design notes:
|
|
70
77
|
|
|
@@ -103,6 +110,40 @@ Edit it to fit your setup (each scene also gets a skill dir scaffold at `~/.pi/a
|
|
|
103
110
|
|
|
104
111
|
Drop `SKILL.md` folders (or `.md` files) into a scene's skill directory; the whole directory toggles with the scene. `/scene init` scaffolds `~/.pi/agent/scenes/{common,coding,office,pm,research,writing,data}/skills/`.
|
|
105
112
|
|
|
113
|
+
### Project vs global scopes (v0.7)
|
|
114
|
+
|
|
115
|
+
Scenes default to **project scope**: activation entries land in `<cwd>/.pi/settings.json`, scene skill dirs in `<cwd>/.pi/scenes/<name>/skills` (vendored skills are copied there on first switch — power-of-copy, edit freely). A new directory starts with the common layer only; nothing leaks across projects.
|
|
116
|
+
|
|
117
|
+
Under the hood the two settings layers split cleanly:
|
|
118
|
+
|
|
119
|
+
| Layer | File | What lands there |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| asset | `~/.pi/agent/settings.json` | npm/local extensions (tools, not prompt tokens), common-layer skills, zero-exposure anchors for git skill bundles |
|
|
122
|
+
| activation | `<cwd>/.pi/settings.json` | per-scene delta entries (`autoload:false` + skills whitelist), scene skill dir paths |
|
|
123
|
+
|
|
124
|
+
Anchors make re-switching instant: the git clone stays warm in `~/.pi/agent/git`, so switching scenes in another project never re-downloads 15MB. `/scene off` keeps anchors on purpose (they expose zero skills); `/scene <name> --global` replaces an anchor with a full whitelist entry for all-project activation. Layers are mutually exclusive — switching always reclaims both layers' previous managed entries first, then writes the new one.
|
|
125
|
+
|
|
126
|
+
Upgrading from ≤0.6? The first session shows a one-time notice; `/scene migrate` converts the legacy global scene into this project's scene in one step.
|
|
127
|
+
|
|
128
|
+
### Resource loading: shared vs copied (no symlinks, ever)
|
|
129
|
+
|
|
130
|
+
What actually lands on disk when you switch scenes:
|
|
131
|
+
|
|
132
|
+
| Resource | Mechanism | On disk in the project |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| Scene extensions (npm/git packages, e.g. `anthropics/skills` skill bundles) | **Declared, never copied** — settings entries point at the single global install (`~/.pi/agent/{npm,git}`); pi loads code/SKILL.md straight from there | nothing |
|
|
135
|
+
| Scene skill dirs (scaffold presets + anything you drop in `~/.pi/agent/scenes/<name>/skills`) | **Copied once per project** on first switch (idempotent — only missing files, never overwrites your edits) | `<cwd>/.pi/scenes/<name>/skills/` |
|
|
136
|
+
| Custom skill paths outside the scenes root (e.g. `~/my-shared-skills`) | Referenced as-is, not copied | — |
|
|
137
|
+
|
|
138
|
+
Two consequences worth internalizing:
|
|
139
|
+
|
|
140
|
+
- **Loaded ≠ present.** Switching scenes swaps the *declarations*; disks keep whatever was copied before. After office→coding, the office skill dir still sits in `<cwd>/.pi/scenes/office/` but has no settings entry pointing at it — never scanned, never loaded, zero prompt cost. It only means switching back is instant.
|
|
141
|
+
- **Copies are yours.** A vendored skill copied into the project can be edited or deleted freely; upgrading pi-scenes never touches it. Want your improvement everywhere? Edit the global source (`~/.pi/agent/scenes/<name>/skills/`) and let other projects copy it on their first switch.
|
|
142
|
+
|
|
143
|
+
### Known limitation: cross-scene npm extensions are a global singleton
|
|
144
|
+
|
|
145
|
+
Skill exposure (the main point of scenes) is fully project-scoped via deltas. npm *extensions*, however, register their activation entries in the global layer — one slot per package. Running two pi instances in different projects with different scenes (A on `coding`, B on `office`): whichever switches last removes the other's npm entries from global settings on its next reload (skills stay fine; extensions like pi-lens/pi-docparser swap). Single-project workflows never hit this. If you need concurrent per-project extension sets, tell me — a future version can project-scope npm extensions at the cost of per-project `node_modules`.
|
|
146
|
+
|
|
106
147
|
### Status-bar scene badge
|
|
107
148
|
|
|
108
149
|
A successful switch sets a persistent footer badge (`◆ coding`), restored automatically at every session start and cleared by `/scene off`. The status bar should answer *"which scene am I in"* — not display tool internals.
|
|
@@ -167,6 +208,9 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
|
|
|
167
208
|
├─ missing packages → confirm → `pi install` each (global scope isn't auto-installed)
|
|
168
209
|
├─ rewrite settings.json (see "Injection & reclamation")
|
|
169
210
|
└─ await ctx.reload() → extensions/skills hot-reload, session uninterrupted
|
|
211
|
+
↘ pi asks resources_discover → scene's prompt templates
|
|
212
|
+
appear as /commands (no settings writes; switching
|
|
213
|
+
away stops returning them → they vanish)
|
|
170
214
|
```
|
|
171
215
|
|
|
172
216
|
### Injection & reclamation (your manual config stays untouched)
|
|
@@ -184,9 +228,30 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
|
|
|
184
228
|
| `scenes.<name>.packages` | accepts `"npm:<pkg>"`, `"git:github.com/u/r"`, local paths, and object form (resource filtering, same grammar as pi settings) |
|
|
185
229
|
| `scenes.<name>.icon` | status-bar badge & picker prefix (emoji recommended; default `◆`) |
|
|
186
230
|
| `scenes.<name>.skills` | paths/directories, `~` expanded |
|
|
231
|
+
| `scenes.<name>.prompts` | prompt-template files/directories (`.md`), `~` expanded; injected via `resources_discover`, never written to settings (v0.8) |
|
|
187
232
|
| `scenes.<name>.extends` | 🧪 inherit a parent scene (union merge + cycle detection) — forward-compatible entry for parent→child hierarchies |
|
|
188
233
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | self-evolution tunables (see "Self-evolution") |
|
|
189
234
|
|
|
235
|
+
## Scene-scoped prompt templates (v0.8)
|
|
236
|
+
|
|
237
|
+
Fixed workflows (release checklists, review procedures, research protocols) belong to scenes too. v0.8 adds a `prompts` field per scene, turning a scene into **tools + skills + workflow templates** as one unit.
|
|
238
|
+
|
|
239
|
+
```jsonc
|
|
240
|
+
"scenes": {
|
|
241
|
+
"research": {
|
|
242
|
+
"packages": ["npm:pi-web-access"],
|
|
243
|
+
"skills": ["~/.pi/agent/scenes/research/skills"],
|
|
244
|
+
"prompts": ["~/.pi/agent/scenes/research/prompts"] // ← new
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**How it's wired — zero settings pollution.** The extension listens to pi's `resources_discover` event: on every startup/reload pi asks which extra resource paths to load, and pi-scenes answers with the active scene's `promptPaths`. Switching away simply stops returning them — templates vanish with **no settings writes, no cleanup, no residue** (unlike packages/skills, which land in settings.json).
|
|
250
|
+
|
|
251
|
+
- Scaffold preseeds one workflow template per preset scene (`/pre-commit` for coding, `/deep-dive` for research, `/fact-check` for writing, `/prd-skeleton` for pm, `/doc-from-notes` for office, `/data-audit` for data), vendored into `~/.pi/agent/scenes/<scene>/prompts/` (idempotent copy, yours to edit)
|
|
252
|
+
- Same-name resolution: your hand-written templates (`~/.pi/agent/prompts/`, project `.pi/prompts/`) and package templates **win over** scene templates — user intent beats presets
|
|
253
|
+
- Why templates at all: they pin down step-by-step procedures so the model can't take shortcuts; human remembers the command name, the template carries the checklist
|
|
254
|
+
|
|
190
255
|
## Rollback
|
|
191
256
|
|
|
192
257
|
```bash
|
|
@@ -200,7 +265,7 @@ Before uninstalling, `/scene off` and prune entries you don't want to keep from
|
|
|
200
265
|
|
|
201
266
|
```bash
|
|
202
267
|
git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
|
|
203
|
-
npm test # node:test,
|
|
268
|
+
npm test # node:test, 32 cases: injection/reclaim + usage/evolution + conflict guards + command-layer smoke (no TUI needed)
|
|
204
269
|
```
|
|
205
270
|
|
|
206
271
|
Tests isolate via the `PI_SCENES_DIR` env var — your real `~/.pi/agent` is never touched.
|
|
@@ -213,8 +278,8 @@ MIT
|
|
|
213
278
|
|
|
214
279
|
# 中文说明
|
|
215
280
|
|
|
216
|
-
> [pi](https://pi.dev) 场景切换器:**通用层 + 分场景层**的 extension / skill
|
|
217
|
-
> 写代码时 `/scene coding`,办公时 `/scene office
|
|
281
|
+
> [pi](https://pi.dev) 场景切换器:**通用层 + 分场景层**的 extension / skill / prompt 模板打包切换。
|
|
282
|
+
> 写代码时 `/scene coding`,办公时 `/scene office`——一键换装,热重载生效;v0.8 起场景还携带流程模板(`/pre-commit`、`/deep-dive`…),步骤清单固化、AI 无法跳步。
|
|
218
283
|
|
|
219
284
|
## 这是什么
|
|
220
285
|
|
|
@@ -229,7 +294,10 @@ pi 的 `packages` / `skills` 是全局平铺的:所有已安装扩展、所有
|
|
|
229
294
|
|
|
230
295
|
- **通用层**:任何场景下恒加载的 extension + skill(如配额显示、会话延续)
|
|
231
296
|
- **场景层**:每个场景自己的一组 extension + skill,激活才加载
|
|
232
|
-
-
|
|
297
|
+
- **默认项目级(v0.7)**——`/scene office` 把激活条目写进 `<cwd>/.pi/settings.json`,场景只属于当前目录;新建目录零残留、干净启动。`--global` 保留 ≤0.6 的全目录生效语义
|
|
298
|
+
- **资产/激活分离(v0.7)**——包只全局装一份、所有项目共享;git 技能包在全局层钉为零暴露**锚点**(`{source, autoload:false, skills:[]}`),项目层写 **delta**(`{source, autoload:false, skills:[白名单]}`)按场景启用——借 pi 原生 delta 机制做到「一份克隆、每项目各自的精选」
|
|
299
|
+
- **场景化 prompt 模板(v0.8)**——每个场景可携带流程模板(`prompts` 字段):把固定流程的步骤清单固化成 `/命令`,模型无法挑最快路径跳步。场景成为**工具 + 技能 + 流程模板**三位一体
|
|
300
|
+
- 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**;prompt 模板走另一条路:经 pi 的 `resources_discover` 事件动态注入,**零 settings 写入**
|
|
233
301
|
- 每次切换成功后状态栏常驻**场景徽标**(`◆ coding`,或每场景自定义 `icon` 如 `💻 coding`),状态栏随时回答「我现在在哪个场景」——会话启动自动恢复,`/scene off` 清除
|
|
234
302
|
- **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene coding`
|
|
235
303
|
- 数据模型预留 `extends` 继承链(带环检测),为将来「主场景 → 子场景」层级铺路
|
|
@@ -251,13 +319,15 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
251
319
|
## 快速开始
|
|
252
320
|
|
|
253
321
|
```
|
|
254
|
-
/scene #
|
|
322
|
+
/scene # 弹出选择器:● 当前项目场景,◐ 当前全局场景,○ 可切
|
|
255
323
|
/scene <Tab> # Tab 补全:列出全部场景(icon + 描述)与子命令
|
|
256
324
|
/scene c<Tab> # 补齐为 /scene coding —— 无需记忆任何场景名
|
|
257
|
-
/scene coding #
|
|
325
|
+
/scene coding # 切到 coding 场景(项目级:只写入 <cwd>/.pi)
|
|
326
|
+
/scene coding --global # 切为全局场景(所有目录生效,≤0.6 语义)
|
|
258
327
|
/scene office # 切到办公场景
|
|
259
|
-
/scene off #
|
|
260
|
-
/scene status #
|
|
328
|
+
/scene off # 仅保留通用层(摘两层;资产锚点保留)
|
|
329
|
+
/scene status # 查看项目/全局两级场景 + 生效 packages/skills
|
|
330
|
+
/scene migrate # 把 ≤0.6 遗留的全局场景转为当前项目场景
|
|
261
331
|
/scene init # 生成模板 scenes.json + 场景 skill 目录骨架
|
|
262
332
|
/scene stats # 用量仪表盘:会话数 / 工具调用 / 反思评分
|
|
263
333
|
/scene evolve # 生成并应用进化提案(逐条确认)
|
|
@@ -276,7 +346,9 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
276
346
|
| `writing` | `npm:pi-web-access` | 素材检索与事实核查(引用溯源) |
|
|
277
347
|
| `data` | `npm:pi-docparser`、`npm:pi-mcp-adapter` | 表格结构化抽取、接任意 MCP server(数据库/BI) |
|
|
278
348
|
|
|
279
|
-
|
|
349
|
+
v0.8 起每个预设场景还携带一个流程模板(coding→`/pre-commit`、office→`/doc-from-notes`、pm→`/prd-skeleton`、research→`/deep-dive`、writing→`/fact-check`、data→`/data-audit`),切换后直接可用;自己加模板只需往 `~/.pi/agent/scenes/<名>/prompts/` 丢 `.md` 文件。
|
|
350
|
+
|
|
351
|
+
每个场景同时生成 skill / prompts 目录骨架 `~/.pi/agent/scenes/<名>/{skills,prompts}/`,按需编辑:
|
|
280
352
|
|
|
281
353
|
```jsonc
|
|
282
354
|
// ~/.pi/agent/scenes.json
|
|
@@ -307,9 +379,28 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
307
379
|
场景 skill 目录里放 `SKILL.md` 文件夹(或 `.md` 文件)即可,切换场景时整目录启停。
|
|
308
380
|
`/scene init` 会创建 `~/.pi/agent/scenes/{common,coding,office,pm,research,writing,data}/skills/` 骨架。
|
|
309
381
|
|
|
382
|
+
### 资源加载方式:大件共享、小件复制、全程无软链接
|
|
383
|
+
|
|
384
|
+
切换场景时各资源到底怎么落到磁盘:
|
|
385
|
+
|
|
386
|
+
| 资源 | 机制 | 项目磁盘上 |
|
|
387
|
+
|---|---|---|
|
|
388
|
+
| 场景扩展(npm/git 包,如 anthropics/skills 技能包) | **声明式引用,永不复制**——settings 条目指向全局唯一安装(`~/.pi/agent/{npm,git}`),pi 直接从那里加载代码/SKILL.md | 什么都没有 |
|
|
389
|
+
| 场景技能目录(脚手架预置 + 你投进 `~/.pi/agent/scenes/<名>/skills` 的一切) | **每项目首次切换时复制一次**(幂等——只补缺失文件,绝不覆盖你的修改) | `<cwd>/.pi/scenes/<名>/skills/` |
|
|
390
|
+
| scenesRoot 之外的自定义技能路径(如 `~/my-shared-skills`) | 原样引用,不复制 | — |
|
|
391
|
+
|
|
392
|
+
两个值得记住的推论:
|
|
393
|
+
|
|
394
|
+
- **「存在」≠「加载」。** 切换换的是声明,磁盘留着切过的所有副本。office→coding 后,office 技能目录仍在 `<cwd>/.pi/scenes/office/`,但没有任何 settings 条目指向它——不被扫描、不被加载、零提示成本;意义仅是切回时秒级。
|
|
395
|
+
- **复制即所有。** 复制进项目的技能随意改删,升级 pi-scenes 永远不会碰它;想让改进全局生效,改全局源(`~/.pi/agent/scenes/<名>/skills/`),其他项目首切时自然复制到。
|
|
396
|
+
|
|
397
|
+
### 已知限制:跨场景 npm 扩展是全局单例
|
|
398
|
+
|
|
399
|
+
技能暴露(场景的核心差异)已通过 delta 完全项目级隔离;但 npm 扩展的激活条目在全局层——每包一个坑位。两个 pi 实例在不同项目跑不同场景(A 用 coding、B 用 office)时,后切换的一方会把先切换方的 npm 条目从全局 settings 摘掉(技能不受影响;pi-lens/pi-docparser 这类扩展会互换)。单项目工作流永远碰不到这个问题;确实需要多项目并行各自扩展集的,可以做到(代价:每项目重复装 node_modules),需要请在 issue 里说一声。
|
|
400
|
+
|
|
310
401
|
### 状态栏场景徽标
|
|
311
402
|
|
|
312
|
-
|
|
403
|
+
切换成功后状态栏常驻徽标(项目场景 `◆ coding`,全局场景 `◇ coding ⌘`),每次会话启动自动恢复,`/scene off` 清除。状态栏应该回答「我现在在哪个场景、哪一层」——而不是展示工具的内部状态。
|
|
313
404
|
|
|
314
405
|
徽标前缀可按场景用 `icon` 字段定制——emoji 完全可用(`💻 coding`)。脚手架预设自带 `💻 📄 🎯 🔍 📝 📊`,选择器与 `/scene status` 同步显示同一 icon;未配置的场景回退 `◆`。
|
|
315
406
|
|
|
@@ -321,6 +412,21 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
321
412
|
|
|
322
413
|
pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏上的唯一东西。
|
|
323
414
|
|
|
415
|
+
### 项目级 vs 全局(v0.7)
|
|
416
|
+
|
|
417
|
+
场景默认**项目级**:激活条目写入 `<cwd>/.pi/settings.json`,场景技能目录在 `<cwd>/.pi/scenes/<名>/skills`(预置技能首次切换时复制过去,复制即所有,随意改删)。新建目录只有通用层,项目间零泄漏。
|
|
418
|
+
|
|
419
|
+
两层 settings 各司其职:
|
|
420
|
+
|
|
421
|
+
| 层 | 文件 | 落点内容 |
|
|
422
|
+
|---|---|---|
|
|
423
|
+
| 资产层 | `~/.pi/agent/settings.json` | npm/本地扩展(工具不占提示 token)、通用层 skills、git 技能包零暴露锚点 |
|
|
424
|
+
| 激活层 | `<cwd>/.pi/settings.json` | 场景 delta 条目(`autoload:false` + skills 白名单)、场景技能目录路径 |
|
|
425
|
+
|
|
426
|
+
锚点让重切秒级:git 克隆常驻 `~/.pi/agent/git`,换个项目再切同一场景不会重新下载 15M。`/scene off` 有意保留锚点(零技能暴露、零成本);`/scene <名> --global` 会把锚点替换为完整白名单条目(全目录生效)。两层互斥:任何切换都先摘净两层旧 managed 再写新层。
|
|
427
|
+
|
|
428
|
+
从 ≤0.6 升级?首个会话会提示一次;`/scene migrate` 一步把遗留全局场景转为当前项目场景。
|
|
429
|
+
|
|
324
430
|
## 自进化(用量驱动)
|
|
325
431
|
|
|
326
432
|
场景不是静态的。pi-scenes 观察你的实际使用并提议更新:
|
|
@@ -371,6 +477,8 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
371
477
|
├─ 缺失的包 → confirm 后逐个 `pi install`(全局 scope pi 不自动装)
|
|
372
478
|
├─ 改写 settings.json(见「注入与回收」)
|
|
373
479
|
└─ await ctx.reload() → 扩展/skill 热重载,会话不中断
|
|
480
|
+
↘ pi 询问 resources_discover → 场景流程模板出现为
|
|
481
|
+
/命令(零 settings 写入;切走后不再返回 → 自动消失)
|
|
374
482
|
```
|
|
375
483
|
|
|
376
484
|
### 注入与回收(不动你的手工配置)
|
|
@@ -388,9 +496,30 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
388
496
|
| `scenes.<name>.packages` | 支持 `"npm:<pkg>"`、`"git:github.com/u/r"`、本地路径字符串,及 object form(资源过滤,同 pi settings 规范) |
|
|
389
497
|
| `scenes.<name>.icon` | 状态栏徽标与选择器前缀(建议 emoji;缺省 `◆`) |
|
|
390
498
|
| `scenes.<name>.skills` | 路径/目录数组,支持 `~` 展开 |
|
|
499
|
+
| `scenes.<name>.prompts` | prompt 模板文件/目录(`.md`),支持 `~` 展开;经 `resources_discover` 动态注入,永不写 settings(v0.8) |
|
|
391
500
|
| `scenes.<name>.extends` | 🧪 继承父场景(union 合并,带环检测)——「主场景→子场景」层级的前向兼容入口 |
|
|
392
501
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | 自进化阈值(见「自进化」节) |
|
|
393
502
|
|
|
503
|
+
## 场景化 prompt 模板(v0.8)
|
|
504
|
+
|
|
505
|
+
固定流程(发版体检、审查步骤、调研套路)也属于场景。v0.8 为每个场景新增 `prompts` 字段,场景成为**工具 + 技能 + 流程模板**三位一体:
|
|
506
|
+
|
|
507
|
+
```jsonc
|
|
508
|
+
"scenes": {
|
|
509
|
+
"research": {
|
|
510
|
+
"packages": ["npm:pi-web-access"],
|
|
511
|
+
"skills": ["~/.pi/agent/scenes/research/skills"],
|
|
512
|
+
"prompts": ["~/.pi/agent/scenes/research/prompts"] // ← 新增
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
**接线方式——零 settings 污染。** 与 packages/skills 落 settings.json 不同,模板走 pi 的 `resources_discover` 事件:每次启动/重载 pi 会询问各扩展需要加载哪些额外资源,pi-scenes 按当前激活场景返回模板路径。切走场景后不再返回——模板自动消失,**不写 settings、无需清理、零残留**。
|
|
518
|
+
|
|
519
|
+
- scaffold 为每个预设场景预置一个流程模板(coding→`/pre-commit`、research→`/deep-dive`、writing→`/fact-check`、pm→`/prd-skeleton`、office→`/doc-from-notes`、data→`/data-audit`),vendored 复制到 `~/.pi/agent/scenes/<场景>/prompts/`(幂等,复制后归你所有,可改可删)
|
|
520
|
+
- 同名解析:你手写的模板(`~/.pi/agent/prompts/`、项目 `.pi/prompts/`)与包模板**优先于**场景模板——用户意图压过预设
|
|
521
|
+
- 为什么需要模板:把步骤清单固化成模板,模型就无法挑最快路径跳步;人只记命令名,清单由模板携带
|
|
522
|
+
|
|
394
523
|
## 回退方案
|
|
395
524
|
|
|
396
525
|
```bash
|
|
@@ -404,7 +533,7 @@ managed 注入的条目在卸载前建议先 `/scene off` + 手工清理 `packag
|
|
|
404
533
|
|
|
405
534
|
```bash
|
|
406
535
|
git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
|
|
407
|
-
npm test # node:test,
|
|
536
|
+
npm test # node:test,32 用例:注入/回收 + 用量/进化 + 异写法冲突防护 + 对象形态替换语义 + scaffold 预置技能 + command 层冒烟(无需 TUI)
|
|
408
537
|
```
|
|
409
538
|
|
|
410
539
|
测试用 `PI_SCENES_DIR` 环境变量隔离基目录,不碰真实 `~/.pi/agent`。
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 提交前自检——构建/测试/diff 审查/提交信息四步全过才允许 git commit
|
|
3
|
+
argument-hint: "[范围说明]"
|
|
4
|
+
---
|
|
5
|
+
对即将提交的变更($@,未指定则取当前暂存区/近期变更)执行四步自检,**逐步执行、禁止跳步、禁止合并步骤**:
|
|
6
|
+
|
|
7
|
+
1. **构建**:运行项目的构建/类型检查命令(无则跳过并说明)。失败 → 停止,报告错误。
|
|
8
|
+
2. **测试**:运行测试套件(或至少覆盖受影响文件的子集)。失败 → 停止,报告失败用例。
|
|
9
|
+
3. **Diff 审查**:逐文件读 diff,检查:误提交的调试代码、密钥/隐私数据、超出本次意图的无关变更、遗留 TODO。发现问题 → 列出并等用户决定。
|
|
10
|
+
4. **提交信息**:按项目惯例(查最近 git log 提炼格式)起草提交信息,给出后由用户确认执行 commit。
|
|
11
|
+
|
|
12
|
+
输出格式:每步一行 ✅/❌ + 证据(命令与关键输出摘要),四步全绿才进入提交流程。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 数据审计——质量/分布/异常三维体检,先看数据再下结论
|
|
3
|
+
argument-hint: "<数据文件路径或数据集说明>"
|
|
4
|
+
---
|
|
5
|
+
对以下数据执行审计:$@
|
|
6
|
+
|
|
7
|
+
**先体检、后分析:任何统计结论必须在数据质量确认之后。**
|
|
8
|
+
|
|
9
|
+
三步流程:
|
|
10
|
+
|
|
11
|
+
1. **质量体检**:行列数、字段类型、缺失值(各列缺失率)、重复行。发现 >10% 缺失的列或大量重复 → 先报告,等用户决定处理方式。
|
|
12
|
+
2. **分布概览**:数值列给 min/max/均值/中位数;类别列给唯一值与频次 top10;日期列给时间范围。标记可疑分布(异常偏斜、不可能值如负年龄)。
|
|
13
|
+
3. **异常检测**:对关键数值列做简单离群点检测(IQR 或 z-score),列出异常样本供人工确认。
|
|
14
|
+
|
|
15
|
+
输出:一页审计报告(表格化),末尾给出「这批数据可以支撑什么分析、不适合什么分析」的建议。
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 笔记/要点整理成正式文档——先定读者与结构,再成文,最后自查
|
|
3
|
+
argument-hint: "<笔记来源>"
|
|
4
|
+
---
|
|
5
|
+
把以下笔记整理成正式文档:$@
|
|
6
|
+
|
|
7
|
+
按三阶段执行,**每阶段输出后等确认再进入下一阶段**:
|
|
8
|
+
|
|
9
|
+
1. **定框架**:先问清(或从笔记推断)文档的读者是谁、使用场景是什么;给出标题 + 章节结构提案。
|
|
10
|
+
2. **成文**:按确认的结构写正文。要求:笔记中的口语/缩写转为规范表达;信息缺口明确标注「待补充」而非编造;保留原始数据的精确性(数字、日期、人名原样)。
|
|
11
|
+
3. **自查**:通读全文检查逻辑断链、术语不一致、格式瑕疵,输出修改清单后落稿。
|
|
12
|
+
|
|
13
|
+
注意:这是办公场景,产出格式优先 docx(可用 docx 技能),用户另有要求除外。
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 生成 PRD 需求文档骨架——背景/目标/范围/功能/非功能/里程碑/风险七段式
|
|
3
|
+
argument-hint: "<需求一句话描述>"
|
|
4
|
+
---
|
|
5
|
+
为以下需求起草 PRD 骨架:$@
|
|
6
|
+
|
|
7
|
+
固定七段结构,**每段都必须落笔(无内容写「待澄清 + 具体问题」)**:
|
|
8
|
+
|
|
9
|
+
1. **背景与问题**:现状、痛点、为什么现在做
|
|
10
|
+
2. **目标与非目标**:可量化的成功指标;明确不做什么(防范围蔓延)
|
|
11
|
+
3. **用户与场景**:目标用户画像、核心使用场景(用户故事格式)
|
|
12
|
+
4. **功能需求**:按优先级 P0/P1/P2 列出,每条含验收标准
|
|
13
|
+
5. **非功能需求**:性能/安全/兼容性/合规约束
|
|
14
|
+
6. **里程碑**:阶段划分与依赖关系
|
|
15
|
+
7. **风险与开放问题**:技术风险、依赖风险、待决策项
|
|
16
|
+
|
|
17
|
+
写完后自查:每条功能需求是否都有验收标准?非目标是否清晰?输出前把「待澄清」问题单独汇总列在文末。
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 深度调研——多源交叉验证、矛盾检测、置信度分级,结论必须可溯源
|
|
3
|
+
argument-hint: "<调研问题>"
|
|
4
|
+
---
|
|
5
|
+
对以下问题执行深度调研:$@
|
|
6
|
+
|
|
7
|
+
**铁律:每个关键结论至少两个独立来源支撑;单一来源的结论必须标注「单源,置信度低」。**
|
|
8
|
+
|
|
9
|
+
流程:
|
|
10
|
+
|
|
11
|
+
1. **拆解问题**:把大问题拆成 3-5 个可独立验证的子问题,列出调研计划。
|
|
12
|
+
2. **多源检索**:每个子问题至少检索两个不同来源(官方文档 > 一手资料 > 二手报道 > 社区讨论,按此优先级)。使用网页搜索与抓取工具,记录每个来源的 URL 与关键原文。
|
|
13
|
+
3. **交叉验证**:逐结论比对来源。发现矛盾 → 不选边,并列出各方说法与出处,标注分歧点。
|
|
14
|
+
4. **综合输出**:结论按置信度分级(高/中/低),每条附来源;末尾列「未能验证的问题」清单。
|
|
15
|
+
|
|
16
|
+
禁止:引用无法溯源的说法、把推测写成事实、省略与自己结论冲突的证据。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 事实核查——逐句提取断言、溯源验证、分级标注,输出核查报告
|
|
3
|
+
argument-hint: "<待核查文本或文件路径>"
|
|
4
|
+
---
|
|
5
|
+
对以下内容执行事实核查:$@
|
|
6
|
+
|
|
7
|
+
流程:
|
|
8
|
+
|
|
9
|
+
1. **断言提取**:逐句读原文,提取所有可验证的事实性断言(数据、日期、事件、引述、因果关系)。纯观点/修辞跳过。
|
|
10
|
+
2. **逐条溯源**:每条断言独立检索验证。找不到可靠来源 → 标注「无法验证」,**禁止**用相似信息凑数。
|
|
11
|
+
3. **分级标注**:每条断言标 ✅属实(附来源)/ ⚠️部分属实(说明偏差)/ ❌不实(附反证)/ ❓无法验证。
|
|
12
|
+
4. **输出报告**:按原文顺序列出断言 + 判定 + 一句话依据,末尾给整体可信度小结。
|
|
13
|
+
|
|
14
|
+
注意:数字、单位、时间最容易错,这三类断言必须找到原文出处才算 ✅。
|