pi-scenes 0.7.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 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
- - Switching rewrites `packages`/`skills` in `settings.json`, then `ctx.reload()` hot-reloads — **no pi restart, session untouched**
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
@@ -60,15 +61,17 @@ Then `/reload` and `/scene` is live.
60
61
 
61
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:
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` | `openclaw/agent-skills` → autoreview, handoff;`anthropics/skills` → frontend-design, webapp-testing, mcp-builder |
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` | `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.
72
75
 
73
76
  Design notes:
74
77
 
@@ -122,6 +125,25 @@ Anchors make re-switching instant: the git clone stays warm in `~/.pi/agent/git`
122
125
 
123
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.
124
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
+
125
147
  ### Status-bar scene badge
126
148
 
127
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.
@@ -186,6 +208,9 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
186
208
  ├─ missing packages → confirm → `pi install` each (global scope isn't auto-installed)
187
209
  ├─ rewrite settings.json (see "Injection & reclamation")
188
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)
189
214
  ```
190
215
 
191
216
  ### Injection & reclamation (your manual config stays untouched)
@@ -203,9 +228,30 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
203
228
  | `scenes.<name>.packages` | accepts `"npm:<pkg>"`, `"git:github.com/u/r"`, local paths, and object form (resource filtering, same grammar as pi settings) |
204
229
  | `scenes.<name>.icon` | status-bar badge & picker prefix (emoji recommended; default `◆`) |
205
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) |
206
232
  | `scenes.<name>.extends` | 🧪 inherit a parent scene (union merge + cycle detection) — forward-compatible entry for parent→child hierarchies |
207
233
  | `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | self-evolution tunables (see "Self-evolution") |
208
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
+
209
255
  ## Rollback
210
256
 
211
257
  ```bash
@@ -219,7 +265,7 @@ Before uninstalling, `/scene off` and prune entries you don't want to keep from
219
265
 
220
266
  ```bash
221
267
  git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
222
- npm test # node:test, 20 cases: injection/reclaim + usage/evolution + conflict guards + command-layer smoke (no TUI needed)
268
+ npm test # node:test, 32 cases: injection/reclaim + usage/evolution + conflict guards + command-layer smoke (no TUI needed)
223
269
  ```
224
270
 
225
271
  Tests isolate via the `PI_SCENES_DIR` env var — your real `~/.pi/agent` is never touched.
@@ -232,8 +278,8 @@ MIT
232
278
 
233
279
  # 中文说明
234
280
 
235
- > [pi](https://pi.dev) 场景切换器:**通用层 + 分场景层**的 extension / skill 打包切换。
236
- > 写代码时 `/scene coding`,办公时 `/scene office`——一键换装,热重载生效。
281
+ > [pi](https://pi.dev) 场景切换器:**通用层 + 分场景层**的 extension / skill / prompt 模板打包切换。
282
+ > 写代码时 `/scene coding`,办公时 `/scene office`——一键换装,热重载生效;v0.8 起场景还携带流程模板(`/pre-commit`、`/deep-dive`…),步骤清单固化、AI 无法跳步。
237
283
 
238
284
  ## 这是什么
239
285
 
@@ -250,7 +296,8 @@ pi 的 `packages` / `skills` 是全局平铺的:所有已安装扩展、所有
250
296
  - **场景层**:每个场景自己的一组 extension + skill,激活才加载
251
297
  - **默认项目级(v0.7)**——`/scene office` 把激活条目写进 `<cwd>/.pi/settings.json`,场景只属于当前目录;新建目录零残留、干净启动。`--global` 保留 ≤0.6 的全目录生效语义
252
298
  - **资产/激活分离(v0.7)**——包只全局装一份、所有项目共享;git 技能包在全局层钉为零暴露**锚点**(`{source, autoload:false, skills:[]}`),项目层写 **delta**(`{source, autoload:false, skills:[白名单]}`)按场景启用——借 pi 原生 delta 机制做到「一份克隆、每项目各自的精选」
253
- - 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**
299
+ - **场景化 prompt 模板(v0.8)**——每个场景可携带流程模板(`prompts` 字段):把固定流程的步骤清单固化成 `/命令`,模型无法挑最快路径跳步。场景成为**工具 + 技能 + 流程模板**三位一体
300
+ - 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**;prompt 模板走另一条路:经 pi 的 `resources_discover` 事件动态注入,**零 settings 写入**
254
301
  - 每次切换成功后状态栏常驻**场景徽标**(`◆ coding`,或每场景自定义 `icon` 如 `💻 coding`),状态栏随时回答「我现在在哪个场景」——会话启动自动恢复,`/scene off` 清除
255
302
  - **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene coding`
256
303
  - 数据模型预留 `extends` 继承链(带环检测),为将来「主场景 → 子场景」层级铺路
@@ -299,7 +346,9 @@ pi install git:github.com/Feng-H/pi-scenes
299
346
  | `writing` | `npm:pi-web-access` | 素材检索与事实核查(引用溯源) |
300
347
  | `data` | `npm:pi-docparser`、`npm:pi-mcp-adapter` | 表格结构化抽取、接任意 MCP server(数据库/BI) |
301
348
 
302
- 每个场景同时生成 skill 目录骨架 `~/.pi/agent/scenes/<名>/skills/`,按需编辑:
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}/`,按需编辑:
303
352
 
304
353
  ```jsonc
305
354
  // ~/.pi/agent/scenes.json
@@ -330,6 +379,25 @@ pi install git:github.com/Feng-H/pi-scenes
330
379
  场景 skill 目录里放 `SKILL.md` 文件夹(或 `.md` 文件)即可,切换场景时整目录启停。
331
380
  `/scene init` 会创建 `~/.pi/agent/scenes/{common,coding,office,pm,research,writing,data}/skills/` 骨架。
332
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
+
333
401
  ### 状态栏场景徽标
334
402
 
335
403
  切换成功后状态栏常驻徽标(项目场景 `◆ coding`,全局场景 `◇ coding ⌘`),每次会话启动自动恢复,`/scene off` 清除。状态栏应该回答「我现在在哪个场景、哪一层」——而不是展示工具的内部状态。
@@ -409,6 +477,8 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
409
477
  ├─ 缺失的包 → confirm 后逐个 `pi install`(全局 scope pi 不自动装)
410
478
  ├─ 改写 settings.json(见「注入与回收」)
411
479
  └─ await ctx.reload() → 扩展/skill 热重载,会话不中断
480
+ ↘ pi 询问 resources_discover → 场景流程模板出现为
481
+ /命令(零 settings 写入;切走后不再返回 → 自动消失)
412
482
  ```
413
483
 
414
484
  ### 注入与回收(不动你的手工配置)
@@ -426,9 +496,30 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
426
496
  | `scenes.<name>.packages` | 支持 `"npm:<pkg>"`、`"git:github.com/u/r"`、本地路径字符串,及 object form(资源过滤,同 pi settings 规范) |
427
497
  | `scenes.<name>.icon` | 状态栏徽标与选择器前缀(建议 emoji;缺省 `◆`) |
428
498
  | `scenes.<name>.skills` | 路径/目录数组,支持 `~` 展开 |
499
+ | `scenes.<name>.prompts` | prompt 模板文件/目录(`.md`),支持 `~` 展开;经 `resources_discover` 动态注入,永不写 settings(v0.8) |
429
500
  | `scenes.<name>.extends` | 🧪 继承父场景(union 合并,带环检测)——「主场景→子场景」层级的前向兼容入口 |
430
501
  | `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | 自进化阈值(见「自进化」节) |
431
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
+
432
523
  ## 回退方案
433
524
 
434
525
  ```bash
@@ -442,7 +533,7 @@ managed 注入的条目在卸载前建议先 `/scene off` + 手工清理 `packag
442
533
 
443
534
  ```bash
444
535
  git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
445
- npm test # node:test,25 用例:注入/回收 + 用量/进化 + 异写法冲突防护 + 对象形态替换语义 + scaffold 预置技能 + command 层冒烟(无需 TUI)
536
+ npm test # node:test,32 用例:注入/回收 + 用量/进化 + 异写法冲突防护 + 对象形态替换语义 + scaffold 预置技能 + command 层冒烟(无需 TUI)
446
537
  ```
447
538
 
448
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
+ 注意:数字、单位、时间最容易错,这三类断言必须找到原文出处才算 ✅。
@@ -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(active: string | null, cfg: ScenesFile): { packages: PackageEntry[]; skills: string[]; commonSkills: string[]; sceneSkills: string[] } {
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
- return { packages, skills, commonSkills, sceneSkills };
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 目录 / 本地路径) */
@@ -987,6 +997,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
987
997
  "npm:pi-carryover", // 跨会话工作承接(上次干到哪、下次接着干)
988
998
  ],
989
999
  skills: ["~/.pi/agent/scenes/common/skills"],
1000
+ prompts: ["~/.pi/agent/scenes/common/prompts"],
990
1001
  },
991
1002
  scenes: {
992
1003
  coding: {
@@ -1007,6 +1018,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
1007
1018
  },
1008
1019
  ],
1009
1020
  skills: ["~/.pi/agent/scenes/coding/skills"],
1021
+ prompts: ["~/.pi/agent/scenes/coding/prompts"], // scaffold 预置 pre-commit 提交前自检
1010
1022
  },
1011
1023
  office: {
1012
1024
  description: "办公:文档解析与生成、内部沟通",
@@ -1019,6 +1031,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
1019
1031
  },
1020
1032
  ],
1021
1033
  skills: ["~/.pi/agent/scenes/office/skills"],
1034
+ prompts: ["~/.pi/agent/scenes/office/prompts"], // scaffold 预置 doc-from-notes 笔记成文
1022
1035
  },
1023
1036
  pm: {
1024
1037
  description: "产品经理:竞品调研、目标规划与需求跟踪",
@@ -1030,6 +1043,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
1030
1043
  "npm:@juicesharp/rpiv-ask-user-question", // 结构化提问:类型化选项代替自由猜测(需求澄清)
1031
1044
  ],
1032
1045
  skills: ["~/.pi/agent/scenes/pm/skills"],
1046
+ prompts: ["~/.pi/agent/scenes/pm/prompts"], // scaffold 预置 prd-skeleton 需求骨架
1033
1047
  },
1034
1048
  research: {
1035
1049
  description: "咨询调研:多源检索、并行多角度深挖、学术文献",
@@ -1039,6 +1053,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
1039
1053
  "npm:pi-subagents", // 多角度并行调研(每个子代理一源)
1040
1054
  ],
1041
1055
  skills: ["~/.pi/agent/scenes/research/skills"], // scaffold 预置 arxiv-research / openalex-paper-search
1056
+ prompts: ["~/.pi/agent/scenes/research/prompts"], // scaffold 预置 deep-dive 深度调研
1042
1057
  },
1043
1058
  writing: {
1044
1059
  description: "写作:素材检索、事实核查、文体打磨",
@@ -1051,6 +1066,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
1051
1066
  },
1052
1067
  ],
1053
1068
  skills: ["~/.pi/agent/scenes/writing/skills"], // scaffold 预置 humanizer
1069
+ prompts: ["~/.pi/agent/scenes/writing/prompts"], // scaffold 预置 fact-check 事实核查
1054
1070
  },
1055
1071
  data: {
1056
1072
  description: "数据分析:表格抽取、MCP 接数据库/BI",
@@ -1060,6 +1076,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
1060
1076
  "npm:pi-mcp-adapter", // 接任意 MCP server(数据库/BI/内部数据服务)
1061
1077
  ],
1062
1078
  skills: ["~/.pi/agent/scenes/data/skills"],
1079
+ prompts: ["~/.pi/agent/scenes/data/prompts"], // scaffold 预置 data-audit 数据审计
1063
1080
  },
1064
1081
  },
1065
1082
  };
@@ -1068,10 +1085,12 @@ export function makeCore(baseDir: string, projectDir?: string) {
1068
1085
  created.push(paths.scenesFile);
1069
1086
  }
1070
1087
  for (const s of ["common", "coding", "office", "pm", "research", "writing", "data"]) {
1071
- const dir = path.join(paths.scenesRoot, s, "skills");
1072
- if (!fs.existsSync(dir)) {
1073
- fs.mkdirSync(dir, { recursive: true });
1074
- created.push(dir);
1088
+ for (const kind of ["skills", "prompts"] as const) {
1089
+ const dir = path.join(paths.scenesRoot, s, kind);
1090
+ if (!fs.existsSync(dir)) {
1091
+ fs.mkdirSync(dir, { recursive: true });
1092
+ created.push(dir);
1093
+ }
1075
1094
  }
1076
1095
  }
1077
1096
  // 预置精选技能:从包内 assets/scene-skills/<场景>/ 复制到场景 skill 目录。
@@ -1092,6 +1111,17 @@ export function makeCore(baseDir: string, projectDir?: string) {
1092
1111
  }
1093
1112
  }
1094
1113
  }
1114
+ // v0.8:预置场景模板 assets/scene-prompts/<场景>/*.md → scenes/<场景>/prompts/(幂等复制,不覆盖用户已有)
1115
+ const promptsAssetsRoot = path.join(pkgRoot, "assets", "scene-prompts");
1116
+ if (fs.existsSync(promptsAssetsRoot)) {
1117
+ for (const scene of fs.readdirSync(promptsAssetsRoot)) {
1118
+ const srcScene = path.join(promptsAssetsRoot, scene);
1119
+ if (!fs.statSync(srcScene).isDirectory()) continue;
1120
+ const dst = path.join(paths.scenesRoot, scene, "prompts");
1121
+ const copied = copyTreeIfMissing(srcScene, dst);
1122
+ if (copied > 0) created.push(dst);
1123
+ }
1124
+ }
1095
1125
  } catch {
1096
1126
  // 资产复制失败不阻断 scaffold(如测试环境无 assets)
1097
1127
  }
@@ -1245,8 +1275,9 @@ export default function (pi: ExtensionAPI) {
1245
1275
 
1246
1276
  const r = core.applyToSettings(target, name, preInstallPackages, scope);
1247
1277
  updateSceneBadge(ctx);
1278
+ const promptCount = target.prompts.filter((p) => fs.existsSync(p)).length;
1248
1279
  ctx.ui.notify(
1249
- `已切换到 ${label}\n +${r.addedPackages.length} 包 +${r.addedSkills.length} skill · -${r.removedPackages.length} 包 -${r.removedSkills.length} skill\n 正在热重载…`,
1280
+ `已切换到 ${label}\n +${r.addedPackages.length} 包 +${r.addedSkills.length} skill · -${r.removedPackages.length} 包 -${r.removedSkills.length} skill · 模板目录 ${promptCount}/${target.prompts.length}\n 正在热重载…`,
1250
1281
  "info",
1251
1282
  );
1252
1283
  await ctx.reload();
@@ -1347,6 +1378,7 @@ export default function (pi: ExtensionAPI) {
1347
1378
  `生效场景:${active ? `${cfg.scenes?.[active]?.icon?.trim() || "◆"} ${active}` : "(无,仅通用层)"}`,
1348
1379
  `生效 packages(${target.packages.length}):${target.packages.map(specOf).join(", ") || "—"}`,
1349
1380
  `生效 skills(${target.skills.length}):${target.skills.join(", ") || "—"}`,
1381
+ `生效 prompt 模板(${target.prompts.length},resources_discover 注入):${target.prompts.join(", ") || "—"}`,
1350
1382
  `可用场景:${Object.keys(cfg.scenes ?? {}).join(", ") || "—"}`,
1351
1383
  ];
1352
1384
  if ((user.anchors?.length ?? 0) > 0) {
@@ -1616,6 +1648,19 @@ export default function (pi: ExtensionAPI) {
1616
1648
  } catch {}
1617
1649
  }
1618
1650
 
1651
+ // v0.8:场景化 prompt 模板 —— resources_discover 事件动态注入。
1652
+ // 每次 startup/reload pi 都会询问本扩展;按当前激活场景返回 promptPaths,
1653
+ // 切走后不再返回 → 模板自动消失,零 settings 写入、零残留。
1654
+ // 同名时用户手写模板(~/.pi/agent/prompts、项目 .pi/prompts)与包模板优先于场景模板。
1655
+ pi.on("resources_discover", async () => {
1656
+ try {
1657
+ const cfg = core.loadScenes();
1658
+ return { promptPaths: core.computeTarget(core.effectiveActive(), cfg).prompts };
1659
+ } catch {
1660
+ return {};
1661
+ }
1662
+ });
1663
+
1619
1664
  pi.on("session_start", async (_event, ctx) => {
1620
1665
  try {
1621
1666
  const all = readAllSettingsPackages();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-scenes",
3
- "version": "0.7.0",
4
- "description": "pi 扩展:场景切换器 + 资源自进化。通用层+分场景层打包 extension/skill,/scene 热切换;按实际用量(工具调用归因 + 会话结束 LLM 反思)生成吸收/淘汰提案,让场景定义随使用习惯进化。",
3
+ "version": "0.8.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
+ }