pi-scenes 0.7.0 → 0.9.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 +143 -18
- package/assets/scene-prompts/coding/pre-commit.md +12 -0
- package/assets/scene-prompts/data/data-audit.md +15 -0
- package/assets/scene-prompts/learning/feynman.md +16 -0
- package/assets/scene-prompts/learning/flashcards.md +17 -0
- package/assets/scene-prompts/learning/socratic.md +14 -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/assets/scene-skills/learning/eli5/SKILL.md +35 -0
- package/extensions/scenes.ts +67 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,7 +21,8 @@ active resources = common layer ∪ current scene
|
|
|
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
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
|
-
-
|
|
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**
|
|
25
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`
|
|
26
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`
|
|
27
28
|
- The data model reserves an `extends` chain (with cycle detection) for future **parent → child scene** hierarchies
|
|
@@ -58,17 +59,20 @@ Then `/reload` and `/scene` is live.
|
|
|
58
59
|
/scene evolve auto # toggle auto-apply at session end (opt-in)
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
First run of `/scene` offers to generate the template. It ships with **
|
|
62
|
+
First run of `/scene` offers to generate the template. It ships with **eight 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:
|
|
62
63
|
|
|
63
|
-
| Scene | Extensions | Skills |
|
|
64
|
-
|
|
65
|
-
| `common` | `npm:pi-scenes`, `npm:pi-carryover` | — (your own dir) |
|
|
66
|
-
| `coding` | `npm:pi-lens`, `npm:pi-subagents`, `npm:pi-git-worktree`, `npm:pi-simplify` | `
|
|
67
|
-
| `office` | `npm:pi-docparser` | `anthropics/skills` → docx, pptx, xlsx, pdf, internal-comms |
|
|
68
|
-
| `pm` | `npm:pi-web-access`, `npm:pi-goal-x`, `npm:@juicesharp/rpiv-todo`, `npm:@juicesharp/rpiv-ask-user-question` | — |
|
|
69
|
-
| `research` | `npm:pi-web-access`, `npm:pi-subagents` | 预置:arxiv-research, openalex-paper-search |
|
|
70
|
-
| `writing` | `npm:pi-web-access` | `anthropics/skills` → doc-coauthoring;预置:humanizer |
|
|
71
|
-
| `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` | `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
|
+
| `learning` | `npm:pi-web-access`, `npm:pi-subagents` | 预置:eli5 | `/feynman`, `/socratic`, `/flashcards` |
|
|
74
|
+
|
|
75
|
+
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.
|
|
72
76
|
|
|
73
77
|
Design notes:
|
|
74
78
|
|
|
@@ -122,6 +126,25 @@ Anchors make re-switching instant: the git clone stays warm in `~/.pi/agent/git`
|
|
|
122
126
|
|
|
123
127
|
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.
|
|
124
128
|
|
|
129
|
+
### Resource loading: shared vs copied (no symlinks, ever)
|
|
130
|
+
|
|
131
|
+
What actually lands on disk when you switch scenes:
|
|
132
|
+
|
|
133
|
+
| Resource | Mechanism | On disk in the project |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| 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 |
|
|
136
|
+
| 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/` |
|
|
137
|
+
| Custom skill paths outside the scenes root (e.g. `~/my-shared-skills`) | Referenced as-is, not copied | — |
|
|
138
|
+
|
|
139
|
+
Two consequences worth internalizing:
|
|
140
|
+
|
|
141
|
+
- **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.
|
|
142
|
+
- **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.
|
|
143
|
+
|
|
144
|
+
### Known limitation: cross-scene npm extensions are a global singleton
|
|
145
|
+
|
|
146
|
+
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`.
|
|
147
|
+
|
|
125
148
|
### Status-bar scene badge
|
|
126
149
|
|
|
127
150
|
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.
|
|
@@ -186,6 +209,9 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
|
|
|
186
209
|
├─ missing packages → confirm → `pi install` each (global scope isn't auto-installed)
|
|
187
210
|
├─ rewrite settings.json (see "Injection & reclamation")
|
|
188
211
|
└─ await ctx.reload() → extensions/skills hot-reload, session uninterrupted
|
|
212
|
+
↘ pi asks resources_discover → scene's prompt templates
|
|
213
|
+
appear as /commands (no settings writes; switching
|
|
214
|
+
away stops returning them → they vanish)
|
|
189
215
|
```
|
|
190
216
|
|
|
191
217
|
### Injection & reclamation (your manual config stays untouched)
|
|
@@ -203,9 +229,30 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
|
|
|
203
229
|
| `scenes.<name>.packages` | accepts `"npm:<pkg>"`, `"git:github.com/u/r"`, local paths, and object form (resource filtering, same grammar as pi settings) |
|
|
204
230
|
| `scenes.<name>.icon` | status-bar badge & picker prefix (emoji recommended; default `◆`) |
|
|
205
231
|
| `scenes.<name>.skills` | paths/directories, `~` expanded |
|
|
232
|
+
| `scenes.<name>.prompts` | prompt-template files/directories (`.md`), `~` expanded; injected via `resources_discover`, never written to settings (v0.8) |
|
|
206
233
|
| `scenes.<name>.extends` | 🧪 inherit a parent scene (union merge + cycle detection) — forward-compatible entry for parent→child hierarchies |
|
|
207
234
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | self-evolution tunables (see "Self-evolution") |
|
|
208
235
|
|
|
236
|
+
## Scene-scoped prompt templates (v0.8)
|
|
237
|
+
|
|
238
|
+
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.
|
|
239
|
+
|
|
240
|
+
```jsonc
|
|
241
|
+
"scenes": {
|
|
242
|
+
"research": {
|
|
243
|
+
"packages": ["npm:pi-web-access"],
|
|
244
|
+
"skills": ["~/.pi/agent/scenes/research/skills"],
|
|
245
|
+
"prompts": ["~/.pi/agent/scenes/research/prompts"] // ← new
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**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).
|
|
251
|
+
|
|
252
|
+
- 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)
|
|
253
|
+
- Same-name resolution: your hand-written templates (`~/.pi/agent/prompts/`, project `.pi/prompts/`) and package templates **win over** scene templates — user intent beats presets
|
|
254
|
+
- 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
|
|
255
|
+
|
|
209
256
|
## Rollback
|
|
210
257
|
|
|
211
258
|
```bash
|
|
@@ -215,11 +262,27 @@ cp ~/.pi/agent/settings.json.scenes-bak ~/.pi/agent/settings.json # restore if
|
|
|
215
262
|
|
|
216
263
|
Before uninstalling, `/scene off` and prune entries you don't want to keep from `packages`/`skills`. `scenes.json` / `scenes-state.json` / the `scenes/` tree are inert leftovers — safe to keep or delete.
|
|
217
264
|
|
|
265
|
+
## Changelog
|
|
266
|
+
|
|
267
|
+
### v0.9.0 (2026-09-23)
|
|
268
|
+
|
|
269
|
+
- **New preset scene: `learning` 📚** (8th preset) — knowledge internalization, verification, and spaced review. Ships `pi-web-access` (learning materials) + `pi-subagents` (parallel multi-perspective study), three workflow templates (`/feynman` four-step internalization, `/socratic` question-only verification, `/flashcards` Q&A+cloze cards with a spaced-repetition schedule), and a vendored `eli5` skill (analogy-first, zero-jargon first pass, 5yo/12yo/adult three-tier explanations)
|
|
270
|
+
- **Preset fix: removed `openclaw/agent-skills` from coding** — verified as an OpenClaw-project-internal workflow library rather than general-purpose coding skills (autoreview hard-codes an OpenAI/Codex preference; handoff is a clipboard-prompt workflow). Its duties were already covered by `pi-simplify` / `pi-subagents`. Lesson recorded: existence verification ≠ positioning verification
|
|
271
|
+
- Full preset audit: 10 npm extensions, 9 anthropics/skills subsets, 3 vendored skills — all verified real and accurately described
|
|
272
|
+
|
|
273
|
+
### v0.8.0 (2026-09-23)
|
|
274
|
+
|
|
275
|
+
- **Scene-scoped prompt templates** — `prompts` field per scene: scene = tools + skills + workflow templates as one unit. Injected via pi's `resources_discover` event: **zero settings writes, templates vanish when you switch away** (unlike packages/skills which land in settings.json)
|
|
276
|
+
- Same-name resolution: your hand-written templates and package templates win over scene presets — user intent beats presets
|
|
277
|
+
- Six preset workflow templates (`/pre-commit`, `/deep-dive`, `/fact-check`, `/prd-skeleton`, `/doc-from-notes`, `/data-audit`), each an explicit step-by-step checklist the model cannot skip
|
|
278
|
+
- Scaffold creates `prompts/` directory skeletons and vendors preset templates idempotently (never overwrites your edits); `/scene status` shows effective templates; switch notification counts template dirs
|
|
279
|
+
- Backward compatible: existing scenes.json without `prompts` behaves exactly as v0.7
|
|
280
|
+
|
|
218
281
|
## Development
|
|
219
282
|
|
|
220
283
|
```bash
|
|
221
284
|
git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
|
|
222
|
-
npm test # node:test,
|
|
285
|
+
npm test # node:test, 32 cases: injection/reclaim + usage/evolution + conflict guards + command-layer smoke (no TUI needed)
|
|
223
286
|
```
|
|
224
287
|
|
|
225
288
|
Tests isolate via the `PI_SCENES_DIR` env var — your real `~/.pi/agent` is never touched.
|
|
@@ -232,8 +295,8 @@ MIT
|
|
|
232
295
|
|
|
233
296
|
# 中文说明
|
|
234
297
|
|
|
235
|
-
> [pi](https://pi.dev) 场景切换器:**通用层 + 分场景层**的 extension / skill
|
|
236
|
-
> 写代码时 `/scene coding`,办公时 `/scene office
|
|
298
|
+
> [pi](https://pi.dev) 场景切换器:**通用层 + 分场景层**的 extension / skill / prompt 模板打包切换。
|
|
299
|
+
> 写代码时 `/scene coding`,办公时 `/scene office`——一键换装,热重载生效;v0.8 起场景还携带流程模板(`/pre-commit`、`/deep-dive`…),步骤清单固化、AI 无法跳步。
|
|
237
300
|
|
|
238
301
|
## 这是什么
|
|
239
302
|
|
|
@@ -250,7 +313,8 @@ pi 的 `packages` / `skills` 是全局平铺的:所有已安装扩展、所有
|
|
|
250
313
|
- **场景层**:每个场景自己的一组 extension + skill,激活才加载
|
|
251
314
|
- **默认项目级(v0.7)**——`/scene office` 把激活条目写进 `<cwd>/.pi/settings.json`,场景只属于当前目录;新建目录零残留、干净启动。`--global` 保留 ≤0.6 的全目录生效语义
|
|
252
315
|
- **资产/激活分离(v0.7)**——包只全局装一份、所有项目共享;git 技能包在全局层钉为零暴露**锚点**(`{source, autoload:false, skills:[]}`),项目层写 **delta**(`{source, autoload:false, skills:[白名单]}`)按场景启用——借 pi 原生 delta 机制做到「一份克隆、每项目各自的精选」
|
|
253
|
-
-
|
|
316
|
+
- **场景化 prompt 模板(v0.8)**——每个场景可携带流程模板(`prompts` 字段):把固定流程的步骤清单固化成 `/命令`,模型无法挑最快路径跳步。场景成为**工具 + 技能 + 流程模板**三位一体
|
|
317
|
+
- 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**;prompt 模板走另一条路:经 pi 的 `resources_discover` 事件动态注入,**零 settings 写入**
|
|
254
318
|
- 每次切换成功后状态栏常驻**场景徽标**(`◆ coding`,或每场景自定义 `icon` 如 `💻 coding`),状态栏随时回答「我现在在哪个场景」——会话启动自动恢复,`/scene off` 清除
|
|
255
319
|
- **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene coding`
|
|
256
320
|
- 数据模型预留 `extends` 继承链(带环检测),为将来「主场景 → 子场景」层级铺路
|
|
@@ -287,7 +351,7 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
287
351
|
/scene evolve auto # 开关:会话结束自动应用(opt-in)
|
|
288
352
|
```
|
|
289
353
|
|
|
290
|
-
首次运行 `/scene` 会询问是否生成模板,生成后编辑场景定义。模板内置
|
|
354
|
+
首次运行 `/scene` 会询问是否生成模板,生成后编辑场景定义。模板内置 **八个预设场景 + 通用层**(包均在 npm 核验存在,2026-09):
|
|
291
355
|
|
|
292
356
|
| 层 | 预设 packages | 理由 |
|
|
293
357
|
|---|---|---|
|
|
@@ -298,8 +362,11 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
298
362
|
| `research` | `npm:pi-web-access`、`npm:pi-subagents` | 多源搜索/抓取/PDF/视频,并行多角度深挖 |
|
|
299
363
|
| `writing` | `npm:pi-web-access` | 素材检索与事实核查(引用溯源) |
|
|
300
364
|
| `data` | `npm:pi-docparser`、`npm:pi-mcp-adapter` | 表格结构化抽取、接任意 MCP server(数据库/BI) |
|
|
365
|
+
| `learning` | `npm:pi-web-access`、`npm:pi-subagents` | 学习材料获取、并行多视角学习;预置 skill:eli5(大白话解释) |
|
|
301
366
|
|
|
302
|
-
|
|
367
|
+
v0.8 起每个预设场景还携带流程模板(coding→`/pre-commit`、office→`/doc-from-notes`、pm→`/prd-skeleton`、research→`/deep-dive`、writing→`/fact-check`、data→`/data-audit`;v0.9 learning 场景→`/feynman` 费曼内化 + `/socratic` 苏格拉底检验 + `/flashcards` 闪卡复习,三件套),切换后直接可用;自己加模板只需往 `~/.pi/agent/scenes/<名>/prompts/` 丢 `.md` 文件。
|
|
368
|
+
|
|
369
|
+
每个场景同时生成 skill / prompts 目录骨架 `~/.pi/agent/scenes/<名>/{skills,prompts}/`,按需编辑:
|
|
303
370
|
|
|
304
371
|
```jsonc
|
|
305
372
|
// ~/.pi/agent/scenes.json
|
|
@@ -330,6 +397,25 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
330
397
|
场景 skill 目录里放 `SKILL.md` 文件夹(或 `.md` 文件)即可,切换场景时整目录启停。
|
|
331
398
|
`/scene init` 会创建 `~/.pi/agent/scenes/{common,coding,office,pm,research,writing,data}/skills/` 骨架。
|
|
332
399
|
|
|
400
|
+
### 资源加载方式:大件共享、小件复制、全程无软链接
|
|
401
|
+
|
|
402
|
+
切换场景时各资源到底怎么落到磁盘:
|
|
403
|
+
|
|
404
|
+
| 资源 | 机制 | 项目磁盘上 |
|
|
405
|
+
|---|---|---|
|
|
406
|
+
| 场景扩展(npm/git 包,如 anthropics/skills 技能包) | **声明式引用,永不复制**——settings 条目指向全局唯一安装(`~/.pi/agent/{npm,git}`),pi 直接从那里加载代码/SKILL.md | 什么都没有 |
|
|
407
|
+
| 场景技能目录(脚手架预置 + 你投进 `~/.pi/agent/scenes/<名>/skills` 的一切) | **每项目首次切换时复制一次**(幂等——只补缺失文件,绝不覆盖你的修改) | `<cwd>/.pi/scenes/<名>/skills/` |
|
|
408
|
+
| scenesRoot 之外的自定义技能路径(如 `~/my-shared-skills`) | 原样引用,不复制 | — |
|
|
409
|
+
|
|
410
|
+
两个值得记住的推论:
|
|
411
|
+
|
|
412
|
+
- **「存在」≠「加载」。** 切换换的是声明,磁盘留着切过的所有副本。office→coding 后,office 技能目录仍在 `<cwd>/.pi/scenes/office/`,但没有任何 settings 条目指向它——不被扫描、不被加载、零提示成本;意义仅是切回时秒级。
|
|
413
|
+
- **复制即所有。** 复制进项目的技能随意改删,升级 pi-scenes 永远不会碰它;想让改进全局生效,改全局源(`~/.pi/agent/scenes/<名>/skills/`),其他项目首切时自然复制到。
|
|
414
|
+
|
|
415
|
+
### 已知限制:跨场景 npm 扩展是全局单例
|
|
416
|
+
|
|
417
|
+
技能暴露(场景的核心差异)已通过 delta 完全项目级隔离;但 npm 扩展的激活条目在全局层——每包一个坑位。两个 pi 实例在不同项目跑不同场景(A 用 coding、B 用 office)时,后切换的一方会把先切换方的 npm 条目从全局 settings 摘掉(技能不受影响;pi-lens/pi-docparser 这类扩展会互换)。单项目工作流永远碰不到这个问题;确实需要多项目并行各自扩展集的,可以做到(代价:每项目重复装 node_modules),需要请在 issue 里说一声。
|
|
418
|
+
|
|
333
419
|
### 状态栏场景徽标
|
|
334
420
|
|
|
335
421
|
切换成功后状态栏常驻徽标(项目场景 `◆ coding`,全局场景 `◇ coding ⌘`),每次会话启动自动恢复,`/scene off` 清除。状态栏应该回答「我现在在哪个场景、哪一层」——而不是展示工具的内部状态。
|
|
@@ -409,6 +495,8 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
409
495
|
├─ 缺失的包 → confirm 后逐个 `pi install`(全局 scope pi 不自动装)
|
|
410
496
|
├─ 改写 settings.json(见「注入与回收」)
|
|
411
497
|
└─ await ctx.reload() → 扩展/skill 热重载,会话不中断
|
|
498
|
+
↘ pi 询问 resources_discover → 场景流程模板出现为
|
|
499
|
+
/命令(零 settings 写入;切走后不再返回 → 自动消失)
|
|
412
500
|
```
|
|
413
501
|
|
|
414
502
|
### 注入与回收(不动你的手工配置)
|
|
@@ -426,9 +514,30 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
426
514
|
| `scenes.<name>.packages` | 支持 `"npm:<pkg>"`、`"git:github.com/u/r"`、本地路径字符串,及 object form(资源过滤,同 pi settings 规范) |
|
|
427
515
|
| `scenes.<name>.icon` | 状态栏徽标与选择器前缀(建议 emoji;缺省 `◆`) |
|
|
428
516
|
| `scenes.<name>.skills` | 路径/目录数组,支持 `~` 展开 |
|
|
517
|
+
| `scenes.<name>.prompts` | prompt 模板文件/目录(`.md`),支持 `~` 展开;经 `resources_discover` 动态注入,永不写 settings(v0.8) |
|
|
429
518
|
| `scenes.<name>.extends` | 🧪 继承父场景(union 合并,带环检测)——「主场景→子场景」层级的前向兼容入口 |
|
|
430
519
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | 自进化阈值(见「自进化」节) |
|
|
431
520
|
|
|
521
|
+
## 场景化 prompt 模板(v0.8)
|
|
522
|
+
|
|
523
|
+
固定流程(发版体检、审查步骤、调研套路)也属于场景。v0.8 为每个场景新增 `prompts` 字段,场景成为**工具 + 技能 + 流程模板**三位一体:
|
|
524
|
+
|
|
525
|
+
```jsonc
|
|
526
|
+
"scenes": {
|
|
527
|
+
"research": {
|
|
528
|
+
"packages": ["npm:pi-web-access"],
|
|
529
|
+
"skills": ["~/.pi/agent/scenes/research/skills"],
|
|
530
|
+
"prompts": ["~/.pi/agent/scenes/research/prompts"] // ← 新增
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
**接线方式——零 settings 污染。** 与 packages/skills 落 settings.json 不同,模板走 pi 的 `resources_discover` 事件:每次启动/重载 pi 会询问各扩展需要加载哪些额外资源,pi-scenes 按当前激活场景返回模板路径。切走场景后不再返回——模板自动消失,**不写 settings、无需清理、零残留**。
|
|
536
|
+
|
|
537
|
+
- 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/`(幂等,复制后归你所有,可改可删)
|
|
538
|
+
- 同名解析:你手写的模板(`~/.pi/agent/prompts/`、项目 `.pi/prompts/`)与包模板**优先于**场景模板——用户意图压过预设
|
|
539
|
+
- 为什么需要模板:把步骤清单固化成模板,模型就无法挑最快路径跳步;人只记命令名,清单由模板携带
|
|
540
|
+
|
|
432
541
|
## 回退方案
|
|
433
542
|
|
|
434
543
|
```bash
|
|
@@ -438,11 +547,27 @@ cp ~/.pi/agent/settings.json.scenes-bak ~/.pi/agent/settings.json # 如需恢
|
|
|
438
547
|
|
|
439
548
|
managed 注入的条目在卸载前建议先 `/scene off` + 手工清理 `packages`/`skills` 里不想保留的条目;`scenes.json` / `scenes-state.json` / `scenes/` 目录留着不影响 pi 运行。
|
|
440
549
|
|
|
550
|
+
## 版本历史
|
|
551
|
+
|
|
552
|
+
### v0.9.0(2026-09-23)
|
|
553
|
+
|
|
554
|
+
- **新增预设场景 `learning` 📚**(第八个)——知识内化、检验、间隔复习。携带 `pi-web-access`(学习材料)+ `pi-subagents`(并行多视角学习)、三个流程模板(`/feynman` 费曼四步内化、`/socratic` 只问不讲的苏格拉底检验、`/flashcards` Q&A+填空双卡型配间隔复习排程)、vendored 技能 `eli5`(类比先行、零术语首过、5 岁/12 岁/成人三档递进)
|
|
555
|
+
- **预设修正:coding 场景移除 `openclaw/agent-skills`**(随本版发布)——核验其为 OpenClaw 项目内部工作流库而非通用编码技能(autoreview 硬编码 OpenAI/Codex 偏好;handoff 是剪贴板提示词流程),其职责已由 `pi-simplify` / `pi-subagents` 覆盖。教训:存在核验 ≠ 定位核验
|
|
556
|
+
- 全预设体检:npm 扩展×10、anthropics/skills 子集×9、vendored×3,全部真实存在且描述如述
|
|
557
|
+
|
|
558
|
+
### v0.8.0(2026-09-23)
|
|
559
|
+
|
|
560
|
+
- **场景化 prompt 模板**——场景新增 `prompts` 字段:场景成为工具+技能+流程模板三位一体。注入走 pi 的 `resources_discover` 事件:**零 settings 写入、切走模板自动消失**(与落 settings.json 的 packages/skills 不同路径)
|
|
561
|
+
- 同名解析:用户手写模板与包模板优先于场景预设——用户意图压过预设
|
|
562
|
+
- 六个预置流程模板(`/pre-commit` 提交自检、`/deep-dive` 深度调研、`/fact-check` 事实核查、`/prd-skeleton` 需求骨架、`/doc-from-notes` 笔记成文、`/data-audit` 数据审计),每个都是显式步骤清单、模型无法跳步
|
|
563
|
+
- scaffold 生成 `prompts/` 目录骨架 + 预置模板 vendored 幂等复制(不覆盖你的修改);`/scene status` 显示生效模板;切换通知带模板目录计数
|
|
564
|
+
- 向后兼容:存量 scenes.json 无 `prompts` 字段时行为与 v0.7 完全一致
|
|
565
|
+
|
|
441
566
|
## 开发
|
|
442
567
|
|
|
443
568
|
```bash
|
|
444
569
|
git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
|
|
445
|
-
npm test # node:test,
|
|
570
|
+
npm test # node:test,32 用例:注入/回收 + 用量/进化 + 异写法冲突防护 + 对象形态替换语义 + scaffold 预置技能 + command 层冒烟(无需 TUI)
|
|
446
571
|
```
|
|
447
572
|
|
|
448
573
|
测试用 `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,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 费曼学习法四步——用大白话讲出来,卡壳处即知识缺口
|
|
3
|
+
argument-hint: "<要学习的概念>"
|
|
4
|
+
---
|
|
5
|
+
用费曼学习法帮我内化以下概念:$@
|
|
6
|
+
|
|
7
|
+
**铁律:用大白话,禁止照搬术语解释术语;卡壳 = 找到了缺口,是收获不是失败。**
|
|
8
|
+
|
|
9
|
+
四步循环:
|
|
10
|
+
|
|
11
|
+
1. **选概念**:把「$@」拆成 2-4 个子概念,确认我的现有理解水平(先问我或让我先说)。
|
|
12
|
+
2. **讲解**:让我用自己的话解释每个子概念(或你先示范一段大白话讲解,再让我复述)。
|
|
13
|
+
3. **找卡点**:我讲不清、绕圈子、或你追问三连(为什么?举个例子?反过来会怎样?)答不上的地方,逐个标记为缺口。
|
|
14
|
+
4. **回源补漏**:每个缺口回到原始材料(文档/教程/代码)定向补学,然后**重新讲解验证**,直到全部子概念都能过三连追问。
|
|
15
|
+
|
|
16
|
+
输出:学习笔记 = 子概念清单(✅已内化/⚠️有缺口+缺口描述)+ 我的原话讲解中被纠正的表述对照。
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 生成复习闪卡——Q&A 卡 + 填空卡,附间隔复习排程
|
|
3
|
+
argument-hint: "<材料来源:文件/主题/近期会话>"
|
|
4
|
+
---
|
|
5
|
+
把以下材料做成复习闪卡:$@
|
|
6
|
+
|
|
7
|
+
规则:
|
|
8
|
+
|
|
9
|
+
1. **提取**:先通读材料,列出可考察的知识点(定义、机制、对比、数值、流程步骤),按重要性排序,数量 10-20 张。
|
|
10
|
+
2. **两种卡型**:
|
|
11
|
+
- Q&A 卡:问题正面,答案背面;问题要具体到能唯一作答(禁止「谈谈 XX」式开放题)
|
|
12
|
+
- 填空卡(cloze):挖掉关键词的陈述句,关键词放背面
|
|
13
|
+
3. **反直觉优先**:材料中违反直觉、容易混淆、我此前答错过的知识点,必须出卡且可出双卡(同一知识点 Q&A + cloze 各一)。
|
|
14
|
+
4. **输出格式**:Markdown 表格(| 正面 | 背面 | 类型 |),可直接导入 Anki(或存为 .txt 制卡)。
|
|
15
|
+
5. **排程**:按间隔重复(1 天 / 3 天 / 7 天 / 14 天 / 30 天)给出一轮复习计划表,注明每轮重点卡范围。
|
|
16
|
+
|
|
17
|
+
铁律:每张卡的答案必须能在原材料中找到出处;材料没有的内容不出卡。
|
|
@@ -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
|
+
禁止:一次列一堆问题让我书面作答;我答错时直接纠正(要引导我自己发现矛盾)。
|
|
@@ -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
|
+
注意:数字、单位、时间最容易错,这三类断言必须找到原文出处才算 ✅。
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: eli5
|
|
3
|
+
description: "ELI5 大白话解释:类比优先、零术语、三档深度递进。Use when the user asks to explain like I'm 5, 用大白话解释, 讲得通俗一点, 我是小白, or is confused by jargon-heavy explanations and needs a ground-up restart."
|
|
4
|
+
version: 1
|
|
5
|
+
license: MIT
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ELI5 — Explain Like I'm 5
|
|
9
|
+
|
|
10
|
+
把任何概念讲到五岁小孩能懂。核心不是「简化」,是**换锚点**:从对方已有的生活经验出发重建理解,而不是从术语出发往下稀释。
|
|
11
|
+
|
|
12
|
+
## 何时触发
|
|
13
|
+
|
|
14
|
+
- 用户明确要求 ELI5 / 大白话 / 通俗讲
|
|
15
|
+
- 用户对先前解释回复「没懂」「太抽象」「说人话」
|
|
16
|
+
- 概念解释连续两轮失败后的强制降档
|
|
17
|
+
|
|
18
|
+
## 解释规则
|
|
19
|
+
|
|
20
|
+
1. **类比先行**:先用一个生活类比把直觉立起来,再谈概念本身。类比要选用户世界里的东西(做饭、寄快递、班级管理、打电话),不要选另一个技术概念当类比。
|
|
21
|
+
2. **零术语首过**:第一段解释不允许出现任何领域术语;必须引用术语时,先用大白话定义它再使用。
|
|
22
|
+
3. **三档递进**:默认输出三档——
|
|
23
|
+
- 🧒 **5 岁版**:一个类比 + 三句话
|
|
24
|
+
- 🧑 **12 岁版**:类比展开 + 工作机制 + 一个具体例子
|
|
25
|
+
- 🧑💻 **成人版**:完整机制 + 边界条件 + 与相邻概念的关系
|
|
26
|
+
用户没指定档位时三档都给,让用户自己选停留深度。
|
|
27
|
+
4. **一个例子一个反例**:正向例子说清「是什么」,反例划清「不是什么」(例如解释哈希表:正向是「按名字首字母归档的电话簿」,反例是「不是按存放顺序找的抽屉」)。
|
|
28
|
+
5. **检查理解**:结尾抛一个 One-shot 小问题(用刚讲的类比回答),答对才算过。
|
|
29
|
+
|
|
30
|
+
## 禁止
|
|
31
|
+
|
|
32
|
+
- 用术语解释术语(「指针是指向内存地址的变量」❌)
|
|
33
|
+
- 类比链超过一层(用 A 比 B,再用 B 比 C,用户会在第二层丢失)
|
|
34
|
+
- 省略反例(没有反例的类比必然过度泛化)
|
|
35
|
+
- 「就是这样,记住就行」——记不住的,能记住的只有锚点
|
package/extensions/scenes.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* 核心思想:
|
|
5
5
|
* 生效资源 = 通用层(common) ∪ 当前场景(scene)
|
|
6
6
|
* 切换场景 = 改写 settings 的 packages/skills 数组 → ctx.reload() 热重载
|
|
7
|
+
* v0.8:场景化 prompt 模板 —— 不写 settings,监听 resources_discover 事件
|
|
8
|
+
* 按当前激活场景动态返回 promptPaths(零持久化,切走即无)
|
|
7
9
|
*
|
|
8
10
|
* 双层模型(v0.7):资产层(user 全局)与激活层(project 项目)分离
|
|
9
11
|
* 旧版(≤0.6)把场景条目全部写进 ~/.pi/agent/settings.json —— 换目录启动 pi
|
|
@@ -90,6 +92,9 @@ export interface SceneDef {
|
|
|
90
92
|
packages?: PackageEntry[];
|
|
91
93
|
/** skill 文件/目录路径,支持 ~ 前缀 */
|
|
92
94
|
skills?: string[];
|
|
95
|
+
/** prompt 模板文件/目录路径(.md),支持 ~ 前缀;经 resources_discover 动态注入,不落 settings。
|
|
96
|
+
* 同名时优先级低于用户手写模板(~/.pi/agent/prompts、项目 .pi/prompts)与包模板 */
|
|
97
|
+
prompts?: string[];
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
export interface EvolveConfig {
|
|
@@ -510,7 +515,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
510
515
|
|
|
511
516
|
/** 解析场景(沿 extends 链 union 合并,带环检测)——主场景/子场景的落点 */
|
|
512
517
|
function resolveScene(name: string, cfg: ScenesFile): SceneDef {
|
|
513
|
-
const merged: SceneDef = { packages: [], skills: [] };
|
|
518
|
+
const merged: SceneDef = { packages: [], skills: [], prompts: [] };
|
|
514
519
|
const seen = new Set<string>();
|
|
515
520
|
let cur: string | null = name;
|
|
516
521
|
while (cur) {
|
|
@@ -520,6 +525,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
520
525
|
if (!def) throw new Error(`场景不存在:${cur}`);
|
|
521
526
|
merged.packages = dedupeEntries([...(merged.packages ?? []), ...(def.packages ?? [])]);
|
|
522
527
|
merged.skills = [...new Set([...(merged.skills ?? []), ...(def.skills ?? [])])];
|
|
528
|
+
merged.prompts = [...new Set([...(merged.prompts ?? []), ...(def.prompts ?? [])])];
|
|
523
529
|
if (def.description && !merged.description) merged.description = def.description;
|
|
524
530
|
cur = def.extends ?? null;
|
|
525
531
|
}
|
|
@@ -533,7 +539,10 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
533
539
|
}
|
|
534
540
|
|
|
535
541
|
/** 生效集合 = 通用层 ∪ 场景链(skills 展开 ~,去重;拆分 common/scene 归属供双层落点) */
|
|
536
|
-
function computeTarget(
|
|
542
|
+
function computeTarget(
|
|
543
|
+
active: string | null,
|
|
544
|
+
cfg: ScenesFile,
|
|
545
|
+
): { packages: PackageEntry[]; skills: string[]; commonSkills: string[]; sceneSkills: string[]; prompts: string[] } {
|
|
537
546
|
const common = cfg.common ?? {};
|
|
538
547
|
let scene: SceneDef = {};
|
|
539
548
|
if (active) scene = resolveScene(active, cfg);
|
|
@@ -541,7 +550,8 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
541
550
|
const commonSkills = [...new Set([...(common.skills ?? [])].map(expandHome))];
|
|
542
551
|
const sceneSkills = [...new Set([...(scene.skills ?? [])].map(expandHome))];
|
|
543
552
|
const skills = [...new Set([...commonSkills, ...sceneSkills])];
|
|
544
|
-
|
|
553
|
+
const prompts = [...new Set([...(common.prompts ?? []), ...(scene.prompts ?? [])].map(expandHome))];
|
|
554
|
+
return { packages, skills, commonSkills, sceneSkills, prompts };
|
|
545
555
|
}
|
|
546
556
|
|
|
547
557
|
/** 包是否已安装(探测 npm 目录 / git clone 目录 / 本地路径) */
|
|
@@ -974,7 +984,9 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
974
984
|
/**
|
|
975
985
|
* 生成模板 scenes.json + 场景 skill 目录骨架 + 预置精选技能。
|
|
976
986
|
* 预设均为真实存在的包(npm/git,2026-09 核验);git 技能包用 object form
|
|
977
|
-
* 按场景裁剪 skills 子集(anthropics/skills 16M
|
|
987
|
+
* 按场景裁剪 skills 子集(anthropics/skills 16M 全量)。曾用 openclaw/agent-skills
|
|
988
|
+
* (v0.8.1 移除:定位为 OpenClaw 项目专用工作流库而非通用编码技能;autoreview/handoff
|
|
989
|
+
* 的职责已由 pi-simplify / pi-subagents 覆盖)。
|
|
978
990
|
* 预置技能 vendored 自高质量开源技能(MIT,见各自 SKILL.md 尾部归属声明)。
|
|
979
991
|
*/
|
|
980
992
|
function scaffold(): string[] {
|
|
@@ -987,6 +999,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
987
999
|
"npm:pi-carryover", // 跨会话工作承接(上次干到哪、下次接着干)
|
|
988
1000
|
],
|
|
989
1001
|
skills: ["~/.pi/agent/scenes/common/skills"],
|
|
1002
|
+
prompts: ["~/.pi/agent/scenes/common/prompts"],
|
|
990
1003
|
},
|
|
991
1004
|
scenes: {
|
|
992
1005
|
coding: {
|
|
@@ -997,16 +1010,13 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
997
1010
|
"npm:pi-subagents", // 单代理委派 + 脚本化多代理工作流
|
|
998
1011
|
"npm:pi-git-worktree", // git worktree 并行开发
|
|
999
1012
|
"npm:pi-simplify", // 近期变更代码审查(清晰度/一致性/可维护性)
|
|
1000
|
-
{
|
|
1001
|
-
source: "git:github.com/openclaw/agent-skills", // OpenClaw 官方编码工作流技能(1.9M)
|
|
1002
|
-
skills: ["skills/autoreview", "skills/handoff"], // 独立代码审查 / 跨代理任务交接
|
|
1003
|
-
},
|
|
1004
1013
|
{
|
|
1005
1014
|
source: "git:github.com/anthropics/skills", // Anthropic 官方技能库(16M),按需子集
|
|
1006
1015
|
skills: ["skills/frontend-design", "skills/webapp-testing", "skills/mcp-builder"],
|
|
1007
1016
|
},
|
|
1008
1017
|
],
|
|
1009
1018
|
skills: ["~/.pi/agent/scenes/coding/skills"],
|
|
1019
|
+
prompts: ["~/.pi/agent/scenes/coding/prompts"], // scaffold 预置 pre-commit 提交前自检
|
|
1010
1020
|
},
|
|
1011
1021
|
office: {
|
|
1012
1022
|
description: "办公:文档解析与生成、内部沟通",
|
|
@@ -1019,6 +1029,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1019
1029
|
},
|
|
1020
1030
|
],
|
|
1021
1031
|
skills: ["~/.pi/agent/scenes/office/skills"],
|
|
1032
|
+
prompts: ["~/.pi/agent/scenes/office/prompts"], // scaffold 预置 doc-from-notes 笔记成文
|
|
1022
1033
|
},
|
|
1023
1034
|
pm: {
|
|
1024
1035
|
description: "产品经理:竞品调研、目标规划与需求跟踪",
|
|
@@ -1030,6 +1041,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1030
1041
|
"npm:@juicesharp/rpiv-ask-user-question", // 结构化提问:类型化选项代替自由猜测(需求澄清)
|
|
1031
1042
|
],
|
|
1032
1043
|
skills: ["~/.pi/agent/scenes/pm/skills"],
|
|
1044
|
+
prompts: ["~/.pi/agent/scenes/pm/prompts"], // scaffold 预置 prd-skeleton 需求骨架
|
|
1033
1045
|
},
|
|
1034
1046
|
research: {
|
|
1035
1047
|
description: "咨询调研:多源检索、并行多角度深挖、学术文献",
|
|
@@ -1039,6 +1051,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1039
1051
|
"npm:pi-subagents", // 多角度并行调研(每个子代理一源)
|
|
1040
1052
|
],
|
|
1041
1053
|
skills: ["~/.pi/agent/scenes/research/skills"], // scaffold 预置 arxiv-research / openalex-paper-search
|
|
1054
|
+
prompts: ["~/.pi/agent/scenes/research/prompts"], // scaffold 预置 deep-dive 深度调研
|
|
1042
1055
|
},
|
|
1043
1056
|
writing: {
|
|
1044
1057
|
description: "写作:素材检索、事实核查、文体打磨",
|
|
@@ -1051,6 +1064,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1051
1064
|
},
|
|
1052
1065
|
],
|
|
1053
1066
|
skills: ["~/.pi/agent/scenes/writing/skills"], // scaffold 预置 humanizer
|
|
1067
|
+
prompts: ["~/.pi/agent/scenes/writing/prompts"], // scaffold 预置 fact-check 事实核查
|
|
1054
1068
|
},
|
|
1055
1069
|
data: {
|
|
1056
1070
|
description: "数据分析:表格抽取、MCP 接数据库/BI",
|
|
@@ -1060,6 +1074,17 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1060
1074
|
"npm:pi-mcp-adapter", // 接任意 MCP server(数据库/BI/内部数据服务)
|
|
1061
1075
|
],
|
|
1062
1076
|
skills: ["~/.pi/agent/scenes/data/skills"],
|
|
1077
|
+
prompts: ["~/.pi/agent/scenes/data/prompts"], // scaffold 预置 data-audit 数据审计
|
|
1078
|
+
},
|
|
1079
|
+
learning: {
|
|
1080
|
+
description: "学习:知识内化、费曼检验、闪卡复习",
|
|
1081
|
+
icon: "📚",
|
|
1082
|
+
packages: [
|
|
1083
|
+
"npm:pi-web-access", // 查教程/文档/视频理解(学习材料获取)
|
|
1084
|
+
"npm:pi-subagents", // 并行学习:子代理各读一种资料再汇总多视角笔记
|
|
1085
|
+
],
|
|
1086
|
+
skills: ["~/.pi/agent/scenes/learning/skills"],
|
|
1087
|
+
prompts: ["~/.pi/agent/scenes/learning/prompts"], // scaffold 预置 feynman / socratic / flashcards
|
|
1063
1088
|
},
|
|
1064
1089
|
},
|
|
1065
1090
|
};
|
|
@@ -1067,11 +1092,13 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1067
1092
|
writeJson(paths.scenesFile, template);
|
|
1068
1093
|
created.push(paths.scenesFile);
|
|
1069
1094
|
}
|
|
1070
|
-
for (const s of ["common", "coding", "office", "pm", "research", "writing", "data"]) {
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
fs.
|
|
1074
|
-
|
|
1095
|
+
for (const s of ["common", "coding", "office", "pm", "research", "writing", "data", "learning"]) {
|
|
1096
|
+
for (const kind of ["skills", "prompts"] as const) {
|
|
1097
|
+
const dir = path.join(paths.scenesRoot, s, kind);
|
|
1098
|
+
if (!fs.existsSync(dir)) {
|
|
1099
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1100
|
+
created.push(dir);
|
|
1101
|
+
}
|
|
1075
1102
|
}
|
|
1076
1103
|
}
|
|
1077
1104
|
// 预置精选技能:从包内 assets/scene-skills/<场景>/ 复制到场景 skill 目录。
|
|
@@ -1092,6 +1119,17 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1092
1119
|
}
|
|
1093
1120
|
}
|
|
1094
1121
|
}
|
|
1122
|
+
// v0.8:预置场景模板 assets/scene-prompts/<场景>/*.md → scenes/<场景>/prompts/(幂等复制,不覆盖用户已有)
|
|
1123
|
+
const promptsAssetsRoot = path.join(pkgRoot, "assets", "scene-prompts");
|
|
1124
|
+
if (fs.existsSync(promptsAssetsRoot)) {
|
|
1125
|
+
for (const scene of fs.readdirSync(promptsAssetsRoot)) {
|
|
1126
|
+
const srcScene = path.join(promptsAssetsRoot, scene);
|
|
1127
|
+
if (!fs.statSync(srcScene).isDirectory()) continue;
|
|
1128
|
+
const dst = path.join(paths.scenesRoot, scene, "prompts");
|
|
1129
|
+
const copied = copyTreeIfMissing(srcScene, dst);
|
|
1130
|
+
if (copied > 0) created.push(dst);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1095
1133
|
} catch {
|
|
1096
1134
|
// 资产复制失败不阻断 scaffold(如测试环境无 assets)
|
|
1097
1135
|
}
|
|
@@ -1245,8 +1283,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
1245
1283
|
|
|
1246
1284
|
const r = core.applyToSettings(target, name, preInstallPackages, scope);
|
|
1247
1285
|
updateSceneBadge(ctx);
|
|
1286
|
+
const promptCount = target.prompts.filter((p) => fs.existsSync(p)).length;
|
|
1248
1287
|
ctx.ui.notify(
|
|
1249
|
-
`已切换到 ${label}\n +${r.addedPackages.length} 包 +${r.addedSkills.length} skill · -${r.removedPackages.length} 包 -${r.removedSkills.length} skill\n 正在热重载…`,
|
|
1288
|
+
`已切换到 ${label}\n +${r.addedPackages.length} 包 +${r.addedSkills.length} skill · -${r.removedPackages.length} 包 -${r.removedSkills.length} skill · 模板目录 ${promptCount}/${target.prompts.length}\n 正在热重载…`,
|
|
1250
1289
|
"info",
|
|
1251
1290
|
);
|
|
1252
1291
|
await ctx.reload();
|
|
@@ -1347,6 +1386,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1347
1386
|
`生效场景:${active ? `${cfg.scenes?.[active]?.icon?.trim() || "◆"} ${active}` : "(无,仅通用层)"}`,
|
|
1348
1387
|
`生效 packages(${target.packages.length}):${target.packages.map(specOf).join(", ") || "—"}`,
|
|
1349
1388
|
`生效 skills(${target.skills.length}):${target.skills.join(", ") || "—"}`,
|
|
1389
|
+
`生效 prompt 模板(${target.prompts.length},resources_discover 注入):${target.prompts.join(", ") || "—"}`,
|
|
1350
1390
|
`可用场景:${Object.keys(cfg.scenes ?? {}).join(", ") || "—"}`,
|
|
1351
1391
|
];
|
|
1352
1392
|
if ((user.anchors?.length ?? 0) > 0) {
|
|
@@ -1616,6 +1656,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
1616
1656
|
} catch {}
|
|
1617
1657
|
}
|
|
1618
1658
|
|
|
1659
|
+
// v0.8:场景化 prompt 模板 —— resources_discover 事件动态注入。
|
|
1660
|
+
// 每次 startup/reload pi 都会询问本扩展;按当前激活场景返回 promptPaths,
|
|
1661
|
+
// 切走后不再返回 → 模板自动消失,零 settings 写入、零残留。
|
|
1662
|
+
// 同名时用户手写模板(~/.pi/agent/prompts、项目 .pi/prompts)与包模板优先于场景模板。
|
|
1663
|
+
pi.on("resources_discover", async () => {
|
|
1664
|
+
try {
|
|
1665
|
+
const cfg = core.loadScenes();
|
|
1666
|
+
return { promptPaths: core.computeTarget(core.effectiveActive(), cfg).prompts };
|
|
1667
|
+
} catch {
|
|
1668
|
+
return {};
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
|
|
1619
1672
|
pi.on("session_start", async (_event, ctx) => {
|
|
1620
1673
|
try {
|
|
1621
1674
|
const all = readAllSettingsPackages();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-scenes",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "pi
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Scene switcher for pi: bundle extensions, skills, and prompt templates into a common layer + per-scene layers. /scene hot-switches with live reload (project-scoped, zero settings residue); scene-scoped workflow templates arrive via resources_discover with no config writes; scene definitions self-evolve from real usage (tool-call attribution + session-end LLM reflection).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
7
7
|
],
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
"@earendil-works/pi-coding-agent": "*",
|
|
35
35
|
"@earendil-works/pi-ai": "*"
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|