pi-scenes 0.13.1 → 0.15.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
|
@@ -18,7 +18,7 @@ active resources = common layer ∪ current scene
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
- **Common layer** — extensions + skills that stay loaded in *every* scenario (quota display, session carryover…)
|
|
21
|
-
- **Scene layers** — per-scenario bundles (
|
|
21
|
+
- **Scene layers** — per-scenario bundles (code-matt-pocock / code-poteto / 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
|
- **Full spatial isolation for scene packages (v0.11)** — *every* scene package (plain `npm:` specs included, not just filtered git bundles) now lands in the project layer as a universal delta (`{source, autoload:false, skills:["**"], extensions:["**"], ...}`) with a zero-exposure global anchor — one shared install, zero disk duplication, and a fresh directory loads **only the common layer**. Fixes the v0.7-v0.10 behavior where plain npm scene packages leaked into global settings and loaded in every project while the scene was active. Re-activating an existing scene migrates the leaked entries automatically (borrow semantics for user-configured globals is preserved)
|
|
@@ -26,8 +26,8 @@ active resources = common layer ∪ current scene
|
|
|
26
26
|
- 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**
|
|
27
27
|
- **Scene-scoped MCP servers (v0.13)** — each scene can declare its own `mcpServers`. Switching injects the scene's MCP tools into settings, and cleanly unmounts them when switching away. User-configured MCP servers are protected via borrow semantics
|
|
28
28
|
- **Claude Plugin interoperability (v0.13)** — `/scene import <dir>` imports any Claude Code / Cowork plugin (from `anthropics/knowledge-work-plugins` or local) as a native scene, transpiling `plugin.json`, `skills/`, `commands/` (to prompts), and `.mcp.json` automatically
|
|
29
|
-
- Every switch stamps a persistent **status-bar badge** (`◆
|
|
30
|
-
- **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
|
|
29
|
+
- Every switch stamps a persistent **status-bar badge** (`◆ code-matt-pocock`, or a per-scene `icon` like `💻 code-matt-pocock`) so the bar always answers *"which scene am I in"* — restored at session start, cleared by `/scene off`
|
|
30
|
+
- **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 code-matt-pocock`
|
|
31
31
|
- The data model reserves an `extends` chain (with cycle detection) for future **parent → child scene** hierarchies
|
|
32
32
|
|
|
33
33
|
## Install
|
|
@@ -49,9 +49,9 @@ Then `/reload` and `/scene` is live.
|
|
|
49
49
|
```
|
|
50
50
|
/scene # picker: all scenes, ● current project scene, ◐ global, ○ inactive
|
|
51
51
|
/scene <Tab> # tab-complete: lists all scenes (icon + description) and subcommands
|
|
52
|
-
/scene c<Tab> # completes to /scene
|
|
53
|
-
/scene
|
|
54
|
-
/scene
|
|
52
|
+
/scene c<Tab> # completes to /scene code-matt-pocock — no scene names to memorize
|
|
53
|
+
/scene code-matt-pocock # switch to the Matt-Pocock coding scene (project-scoped: <cwd>/.pi only)
|
|
54
|
+
/scene code-matt-pocock --global # switch as a global scene (every project, ≤0.6 behavior)
|
|
55
55
|
/scene office # switch to the office scene
|
|
56
56
|
/scene off # common layer only (clears both layers; anchors kept)
|
|
57
57
|
/scene status # show project/global scenes + effective packages/skills
|
|
@@ -61,14 +61,16 @@ Then `/reload` and `/scene` is live.
|
|
|
61
61
|
/scene update-assets # sync preset templates/skills from the package (edits kept, rest updated)
|
|
62
62
|
/scene evolve # generate & apply evolution proposals (confirm-first)
|
|
63
63
|
/scene evolve auto # toggle auto-apply at session end (opt-in)
|
|
64
|
+
/scene suggest # scene-suggestion hints on/off (non-blocking; fires only when no scene is active)
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
First run of `/scene` offers to generate the template. It ships with **
|
|
67
|
+
First run of `/scene` offers to generate the template. It ships with **nine 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. Since v0.15 coding ships as two scenes: `code-matt-pocock` (Matt's grill→spec→tickets workflow) and `code-poteto` (pstack rigor engineering, poteto-mode + 22 principles):
|
|
67
68
|
|
|
68
69
|
| Scene | Extensions | Skills | Prompt templates (v0.8) |
|
|
69
70
|
|---|---|---|---|
|
|
70
71
|
| `common` | `npm:pi-scenes`, `npm:pi-carryover` | — (your own dir) | — |
|
|
71
|
-
| `
|
|
72
|
+
| `code-matt-pocock` | `npm:pi-lens`, `npm:pi-subagents` | `mattpocock/skills` → engineering/** (20 skills) + productivity/grilling | `/pre-commit` |
|
|
73
|
+
| `code-poteto` | `npm:pi-lens`, `npm:pi-subagents` | `backnotprop/pstack` → poteto-mode + principle-* (22) + tdd/how/why/architect/arena/swarm/interrogate/blast-radius/unslop/no-comments/correct/reflect/statechart/ts-best-practices/figure-it-out/show-me-your-work/technical-writing | — |
|
|
72
74
|
| `office` | `npm:pi-docparser` | `anthropics/skills` → docx, pptx, xlsx, pdf, internal-comms | `/doc-from-notes` |
|
|
73
75
|
| `pm` | `npm:pi-web-access`, `npm:pi-goal-x`, `npm:@juicesharp/rpiv-todo`, `npm:@juicesharp/rpiv-ask-user-question` | — | `/prd-skeleton` |
|
|
74
76
|
| `research` | `npm:pi-web-access`, `npm:pi-subagents` | 预置:arxiv-research, openalex-paper-search | `/deep-dive` |
|
|
@@ -96,11 +98,11 @@ Edit it to fit your setup (each scene also gets a skill dir scaffold at `~/.pi/a
|
|
|
96
98
|
"skills": ["~/.pi/agent/scenes/common/skills"]
|
|
97
99
|
},
|
|
98
100
|
"scenes": { // ── scene layers: stacked when active
|
|
99
|
-
"
|
|
100
|
-
"description": "coding",
|
|
101
|
+
"code-matt-pocock": {
|
|
102
|
+
"description": "coding (Matt Pocock workflow)",
|
|
101
103
|
"icon": "💻",
|
|
102
104
|
"packages": ["npm:pi-carryover"],
|
|
103
|
-
"skills": ["~/.pi/agent/scenes/
|
|
105
|
+
"skills": ["~/.pi/agent/scenes/code-matt-pocock/skills"]
|
|
104
106
|
},
|
|
105
107
|
"office": {
|
|
106
108
|
"description": "office work",
|
|
@@ -113,7 +115,7 @@ Edit it to fit your setup (each scene also gets a skill dir scaffold at `~/.pi/a
|
|
|
113
115
|
}
|
|
114
116
|
```
|
|
115
117
|
|
|
116
|
-
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,
|
|
118
|
+
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,code-matt-pocock,code-poteto,office,pm,research,writing,data}/skills/`.
|
|
117
119
|
|
|
118
120
|
### Project vs global scopes (v0.7)
|
|
119
121
|
|
|
@@ -142,20 +144,20 @@ What actually lands on disk when you switch scenes:
|
|
|
142
144
|
|
|
143
145
|
Two consequences worth internalizing:
|
|
144
146
|
|
|
145
|
-
- **Loaded ≠ present.** Switching scenes swaps the *declarations*; disks keep whatever was copied before. After office→
|
|
147
|
+
- **Loaded ≠ present.** Switching scenes swaps the *declarations*; disks keep whatever was copied before. After office→code-matt-pocock, 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.
|
|
146
148
|
- **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.
|
|
147
149
|
|
|
148
150
|
### Known limitation: cross-scene npm extensions are a global singleton
|
|
149
151
|
|
|
150
|
-
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 `
|
|
152
|
+
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 `code-matt-pocock`, 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`.
|
|
151
153
|
|
|
152
154
|
### Status-bar scene badge
|
|
153
155
|
|
|
154
|
-
A successful switch sets a persistent footer badge (`◆
|
|
156
|
+
A successful switch sets a persistent footer badge (`◆ code-matt-pocock`), 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.
|
|
155
157
|
|
|
156
|
-
The prefix is customizable per scene via the `icon` field — emoji works great (`💻
|
|
158
|
+
The prefix is customizable per scene via the `icon` field — emoji works great (`💻 code-matt-pocock`, `👑 code-poteto`). The scaffolded presets ship with `💻 👑 📄 🎯 🔍 📝 📊`, and the picker plus `/scene status` display the same icon; unset scenes fall back to `◆`.
|
|
157
159
|
|
|
158
|
-
Scenes often bundle tool-heavy extensions whose own footer output crowds the bar. If you use
|
|
160
|
+
Scenes often bundle tool-heavy extensions whose own footer output crowds the bar. If you use either coding preset (`code-matt-pocock` / `code-poteto`), pi-lens's diagnostics widget and `LSP Inactive` status can be silenced **without losing any AI-side value** (turn-end error injection, `lens_diagnostics`, symbol navigation) via `~/.pi-lens/config.json`:
|
|
159
161
|
|
|
160
162
|
```json
|
|
161
163
|
{ "ui": { "hideLspStatus": true }, "widget": { "visible": false } }
|
|
@@ -204,12 +206,21 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
|
|
|
204
206
|
- **Local path vs npm spelling (v0.2.1):** if settings already loads a package via a local path (e.g. your dev checkout `/Users/you/dev/pi-carryover`), a scene preset listing `npm:pi-carryover` will *borrow* your entry instead of installing — `pi install` is skipped so a second spelling is never appended to settings. This matters because two spellings of one package = the same extension loaded twice = pi exits at startup with a tool-name conflict. If settings ever ends up in that state (e.g. a manual `pi install` added the duplicate), `/scene` refuses to switch and tells you exactly which entries to delete.
|
|
205
207
|
- **Hotfix (v0.2.2):** `/scene <name>` crashed with `Extension "command:scene" error: target.filter is not a function` — the v0.2.1 refactor passed `computeTarget()`'s `{packages, skills}` object where the old call site used `target.packages`. Any scene switch hit this. Fixed, plus a command-layer smoke test (isolated via `PI_SCENES_DIR` + dynamic import in a dedicated test file, because the extension's default export resolves its base dir at module-evaluation time — a static import in tests would read/write your real `~/.pi/agent`).
|
|
206
208
|
|
|
209
|
+
## Scene suggestions (v0.14)
|
|
210
|
+
|
|
211
|
+
You don't always remember to switch scenes before diving in. pi-scenes can notice and hint — **non-blocking toast, once per session, never auto-switches**:
|
|
212
|
+
|
|
213
|
+
- **History line** (session start): if this project last used a scene (recorded on every project-scoped switch, 30-day window), a toast suggests restoring it: `💻 上次此项目用的是「code-matt-pocock」场景 → /scene code-matt-pocock`
|
|
214
|
+
- **Intent line** (first message): pure keyword heuristics (no LLM, zero cost). Each preset scene carries built-in strong (weight 2) / weak (weight 1) keyword lists; a scene can also declare `keywords` (weight 2). A hint fires only when the best scene scores ≥ 2 AND strictly beats the runner-up (ties stay silent); inputs starting with `/` are never matched
|
|
215
|
+
|
|
216
|
+
Guardrails: one hint per session max (both lines share the budget); silent while any scene is active; after 3 consecutive ignored hints the project cools down until you actually switch (which resets the counter). `/scene suggest on|off` is the master switch (default on). Everything is a `ctx.ui.notify` toast — your typing flow is never interrupted.
|
|
217
|
+
|
|
207
218
|
## How it works
|
|
208
219
|
|
|
209
220
|
```
|
|
210
|
-
/scene
|
|
221
|
+
/scene code-matt-pocock
|
|
211
222
|
│
|
|
212
|
-
├─ read scenes.json → target set = common ∪
|
|
223
|
+
├─ read scenes.json → target set = common ∪ code-matt-pocock (extends chains resolved)
|
|
213
224
|
├─ missing packages → confirm → `pi install` each (global scope isn't auto-installed)
|
|
214
225
|
├─ rewrite settings.json (see "Injection & reclamation")
|
|
215
226
|
└─ await ctx.reload() → extensions/skills hot-reload, session uninterrupted
|
|
@@ -236,6 +247,8 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
|
|
|
236
247
|
| `scenes.<name>.prompts` | prompt-template files/directories (`.md`), `~` expanded; injected via `resources_discover`, never written to settings (v0.8) |
|
|
237
248
|
| `scenes.<name>.extends` | 🧪 inherit a parent scene (union merge + cycle detection) — forward-compatible entry for parent→child hierarchies |
|
|
238
249
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | self-evolution tunables (see "Self-evolution") |
|
|
250
|
+
| `scenes.<name>.keywords` | v0.14 intent-hint keywords (weight 2), stacked on the built-in preset tables |
|
|
251
|
+
| `suggest.enabled` | master switch for scene suggestions (default on; `/scene suggest on\|off`) |
|
|
239
252
|
|
|
240
253
|
## Scene-scoped prompt templates (v0.8)
|
|
241
254
|
|
|
@@ -253,7 +266,7 @@ Fixed workflows (release checklists, review procedures, research protocols) belo
|
|
|
253
266
|
|
|
254
267
|
**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).
|
|
255
268
|
|
|
256
|
-
- Scaffold preseeds one workflow template per preset scene (`/pre-commit` for
|
|
269
|
+
- Scaffold preseeds one workflow template per preset scene (`/pre-commit` for code-matt-pocock, `/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)
|
|
257
270
|
- Same-name resolution: your hand-written templates (`~/.pi/agent/prompts/`, project `.pi/prompts/`) and package templates **win over** scene templates — user intent beats presets
|
|
258
271
|
- 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
|
|
259
272
|
|
|
@@ -268,6 +281,16 @@ Before uninstalling, `/scene off` and prune entries you don't want to keep from
|
|
|
268
281
|
|
|
269
282
|
## Changelog
|
|
270
283
|
|
|
284
|
+
### v0.15.0 (2026-11-28)
|
|
285
|
+
|
|
286
|
+
- **Coding ships as two scenes** — `coding` renamed to `code-matt-pocock` (Matt Pocock's grill→spec→tickets→implement→review→pr workflow, unchanged bundle), and a new **`code-poteto`** preset: pstack by Lauren Tan (poteto, React core team; MIT, via the `backnotprop/pstack` standalone mirror that officially supports pi). Whitelist groups skills by dependency: `poteto-mode` (22 playbooks: bug-fix/feature/refactoring/perf/shipping/overnight…) + all 22 `principle-*` (its hard dependencies) + the rigor core (tdd/how/why/architect/arena/swarm/interrogate/blast-radius/unslop/no-comments/correct/reflect/statechart/typescript-best-practices/figure-it-out/show-me-your-work/technical-writing). Excluded on purpose: setup-pstack (Cursor model picker), ketchup-video/make-bot-ui/bro (non-coding), automate-me & verification-skill authoring (meta; re-add per taste)
|
|
287
|
+
- Vendored prompt dir `assets/scene-prompts/coding` → `code-matt-pocock`; users upgrading keep their on-disk copies (manifest reports the old key as removed, new key re-seeded on next `/scene init` or `/scene update-assets`)
|
|
288
|
+
- Intent-suggestion tables follow the rename: `code-matt-pocock` keeps the former coding keyword table; `code-poteto` gets a differentiated table (playbook/poteto/pstack/swarm/hillclimb/autopilot…). Overlapping hits tie → no toast (conservative by design); declare your own `keywords` in scenes.json to steer
|
|
289
|
+
|
|
290
|
+
### v0.14.0 (2026-11-28)
|
|
291
|
+
|
|
292
|
+
- **Scene suggestions** — when no scene is active, pi-scenes hints (non-blocking toast, once per session, never auto-switches): a **history line** at session start suggests restoring the scene this project last used (30-day window), and an **intent line** matches your first message against per-scene keyword tables (pure heuristics, no LLM; fires only when the best scene scores ≥ 2 and strictly beats the runner-up). Guardrails: silent while a scene is active, 3 consecutive ignores cool the project down (reset on switch), `/scene suggest on|off` master switch. Scenes accept a new `keywords` field (weight 2) to extend/override the built-in tables
|
|
293
|
+
|
|
271
294
|
### v0.13.1 (2026-11-28)
|
|
272
295
|
|
|
273
296
|
- **Coding preset refresh** — the `coding` scaffold preset now ships `npm:pi-lens` (LSP/ast-grep live code feedback) + `npm:pi-subagents` + `git:github.com/mattpocock/skills` via glob whitelists (`skills/engineering/**` + `skills/productivity/grilling/**`; 20 engineering skills follow upstream automatically). Removed `npm:pi-git-worktree`, `npm:pi-simplify` (duties covered by Matt's `code-review`), and the anthropics trio (frontend-design/webapp-testing/mcp-builder) — re-add per taste if you do web UI / MCP work
|
|
@@ -328,7 +351,7 @@ MIT
|
|
|
328
351
|
# 中文说明
|
|
329
352
|
|
|
330
353
|
> [pi](https://pi.dev) 场景切换器:**通用层 + 分场景层**的 extension / skill / prompt 模板打包切换。
|
|
331
|
-
> 写代码时 `/scene
|
|
354
|
+
> 写代码时 `/scene code-matt-pocock`(Matt 工程流)或 `/scene code-poteto`(pstack 严谨流),办公时 `/scene office`——一键换装,热重载生效;v0.8 起场景还携带流程模板(`/pre-commit`、`/deep-dive`…),步骤清单固化、AI 无法跳步。
|
|
332
355
|
|
|
333
356
|
## 这是什么
|
|
334
357
|
|
|
@@ -350,8 +373,8 @@ pi 的 `packages` / `skills` 是全局平铺的:所有已安装扩展、所有
|
|
|
350
373
|
- **场景级 MCP 动态调度(v0.13)**——每个场景可声明专属 `mcpServers`。切换时动态挂载对应工具,切走时精确卸载;用户预配的 MCP 走借用保护不篡改
|
|
351
374
|
- **Claude Plugin 原生协议互通(v0.13)**——`/scene import <dir>` 一键将 Claude Code / Cowork 插件(如 Anthropic 官方知识工作流插件或社区生态)转换为原生场景,自动转译 `plugin.json`、`skills/`、`commands/`(转为 prompt 模板)及 `.mcp.json`
|
|
352
375
|
- 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**;prompt 模板走另一条路:经 pi 的 `resources_discover` 事件动态注入,**零 settings 写入**
|
|
353
|
-
- 每次切换成功后状态栏常驻**场景徽标**(`◆
|
|
354
|
-
- **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene
|
|
376
|
+
- 每次切换成功后状态栏常驻**场景徽标**(`◆ code-matt-pocock`,或每场景自定义 `icon` 如 `💻 code-matt-pocock`),状态栏随时回答「我现在在哪个场景」——会话启动自动恢复,`/scene off` 清除
|
|
377
|
+
- **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene code-matt-pocock`
|
|
355
378
|
- 数据模型预留 `extends` 继承链(带环检测),为将来「主场景 → 子场景」层级铺路
|
|
356
379
|
|
|
357
380
|
## 安装
|
|
@@ -373,9 +396,9 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
373
396
|
```
|
|
374
397
|
/scene # 弹出选择器:● 当前项目场景,◐ 当前全局场景,○ 可切
|
|
375
398
|
/scene <Tab> # Tab 补全:列出全部场景(icon + 描述)与子命令
|
|
376
|
-
/scene c<Tab> # 补齐为 /scene
|
|
377
|
-
/scene
|
|
378
|
-
/scene
|
|
399
|
+
/scene c<Tab> # 补齐为 /scene code-matt-pocock —— 无需记忆任何场景名
|
|
400
|
+
/scene code-matt-pocock # 切到 code-matt-pocock 场景(项目级:只写入 <cwd>/.pi)
|
|
401
|
+
/scene code-matt-pocock --global # 切为全局场景(所有目录生效,≤0.6 语义)
|
|
379
402
|
/scene office # 切到办公场景
|
|
380
403
|
/scene off # 仅保留通用层(摘两层;资产锚点保留)
|
|
381
404
|
/scene status # 查看项目/全局两级场景 + 生效 packages/skills
|
|
@@ -385,14 +408,16 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
385
408
|
/scene update-assets # 同步包内预置模板/skill(未修改跟随新版,改过的保留)
|
|
386
409
|
/scene evolve # 生成并应用进化提案(逐条确认)
|
|
387
410
|
/scene evolve auto # 开关:会话结束自动应用(opt-in)
|
|
411
|
+
/scene suggest # 场景意图提示开关(无场景激活时非阻塞建议切换)
|
|
388
412
|
```
|
|
389
413
|
|
|
390
|
-
首次运行 `/scene` 会询问是否生成模板,生成后编辑场景定义。模板内置
|
|
414
|
+
首次运行 `/scene` 会询问是否生成模板,生成后编辑场景定义。模板内置 **九个预设场景 + 通用层**(包均在 npm 核验存在,2026-09;v0.15 起编码拆为双场景 `code-matt-pocock` / `code-poteto`):
|
|
391
415
|
|
|
392
416
|
| 层 | 预设 packages | 理由 |
|
|
393
417
|
|---|---|---|
|
|
394
418
|
| `common` | `npm:pi-scenes`、`npm:pi-carryover` | 切换器自身 + 跨会话承接,恒需 |
|
|
395
|
-
| `
|
|
419
|
+
| `code-matt-pocock` | `npm:pi-lens`、`npm:pi-subagents`、`mattpocock/skills`(engineering/** + grilling) | LSP/lint 实时反馈、子代理委派、Matt Pocock 工程流(grill→spec→tickets→implement→review→pr) |
|
|
420
|
+
| `code-poteto` | `npm:pi-lens`、`npm:pi-subagents`、`backnotprop/pstack`(poteto-mode + principle-*×22 + tdd/how/why/architect/arena/swarm/interrogate/blast-radius/unslop/no-comments/correct/reflect/statechart/ts-best-practices/figure-it-out/show-me-your-work/technical-writing) | LSP/lint 实时反馈、子代理委派、pstack 严谨工程流(poteto-mode 22 playbook 路由:bug 修复/特性/重构/性能/过夜跑…+ 22 条 principle 原则) |
|
|
396
421
|
| `office` | `npm:pi-docparser` | PDF/Office 文档解析 |
|
|
397
422
|
| `pm` | `npm:pi-web-access`、`npm:pi-goal-x`、`npm:@juicesharp/rpiv-todo` | 竞品/市场调研、目标规划与完成度审计、需求/任务清单 overlay |
|
|
398
423
|
| `research` | `npm:pi-web-access`、`npm:pi-subagents` | 多源搜索/抓取/PDF/视频,并行多角度深挖 |
|
|
@@ -401,7 +426,7 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
401
426
|
| `learning` | `npm:pi-web-access`、`npm:pi-subagents` | 学习材料获取、并行多视角学习;预置 skill:eli5(大白话解释) |
|
|
402
427
|
| `productivity` | `npm:pi-carryover` | 个人生产力:任务清单驱动工作流与重要上下文沉淀(基于 Anthropic 知识插件规范) |
|
|
403
428
|
|
|
404
|
-
v0.8 起每个预设场景还携带流程模板(
|
|
429
|
+
v0.8 起每个预设场景还携带流程模板(code-matt-pocock→`/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` 文件。
|
|
405
430
|
|
|
406
431
|
每个场景同时生成 skill / prompts 目录骨架 `~/.pi/agent/scenes/<名>/{skills,prompts}/`,按需编辑:
|
|
407
432
|
|
|
@@ -414,11 +439,11 @@ v0.8 起每个预设场景还携带流程模板(coding→`/pre-commit`、offic
|
|
|
414
439
|
"skills": ["~/.pi/agent/scenes/common/skills"]
|
|
415
440
|
},
|
|
416
441
|
"scenes": { // ── 场景层:激活才叠加
|
|
417
|
-
"
|
|
442
|
+
"code-matt-pocock": {
|
|
418
443
|
"description": "写代码",
|
|
419
444
|
"icon": "💻",
|
|
420
445
|
"packages": ["npm:pi-carryover"],
|
|
421
|
-
"skills": ["~/.pi/agent/scenes/
|
|
446
|
+
"skills": ["~/.pi/agent/scenes/code-matt-pocock/skills"]
|
|
422
447
|
},
|
|
423
448
|
"office": {
|
|
424
449
|
"description": "办公",
|
|
@@ -432,7 +457,7 @@ v0.8 起每个预设场景还携带流程模板(coding→`/pre-commit`、offic
|
|
|
432
457
|
```
|
|
433
458
|
|
|
434
459
|
场景 skill 目录里放 `SKILL.md` 文件夹(或 `.md` 文件)即可,切换场景时整目录启停。
|
|
435
|
-
`/scene init` 会创建 `~/.pi/agent/scenes/{common,
|
|
460
|
+
`/scene init` 会创建 `~/.pi/agent/scenes/{common,code-matt-pocock,code-poteto,office,pm,research,writing,data}/skills/` 骨架。
|
|
436
461
|
|
|
437
462
|
### 资源加载方式:大件共享、小件复制、全程无软链接
|
|
438
463
|
|
|
@@ -446,20 +471,20 @@ v0.8 起每个预设场景还携带流程模板(coding→`/pre-commit`、offic
|
|
|
446
471
|
|
|
447
472
|
两个值得记住的推论:
|
|
448
473
|
|
|
449
|
-
- **「存在」≠「加载」。** 切换换的是声明,磁盘留着切过的所有副本。office→
|
|
474
|
+
- **「存在」≠「加载」。** 切换换的是声明,磁盘留着切过的所有副本。office→code-matt-pocock 后,office 技能目录仍在 `<cwd>/.pi/scenes/office/`,但没有任何 settings 条目指向它——不被扫描、不被加载、零提示成本;意义仅是切回时秒级。
|
|
450
475
|
- **复制即所有。** 复制进项目的技能随意改删,升级 pi-scenes 永远不会碰它;想让改进全局生效,改全局源(`~/.pi/agent/scenes/<名>/skills/`),其他项目首切时自然复制到。
|
|
451
476
|
|
|
452
477
|
### 已知限制:跨场景 npm 扩展是全局单例
|
|
453
478
|
|
|
454
|
-
技能暴露(场景的核心差异)已通过 delta 完全项目级隔离;但 npm 扩展的激活条目在全局层——每包一个坑位。两个 pi 实例在不同项目跑不同场景(A 用
|
|
479
|
+
技能暴露(场景的核心差异)已通过 delta 完全项目级隔离;但 npm 扩展的激活条目在全局层——每包一个坑位。两个 pi 实例在不同项目跑不同场景(A 用 code-matt-pocock、B 用 office)时,后切换的一方会把先切换方的 npm 条目从全局 settings 摘掉(技能不受影响;pi-lens/pi-docparser 这类扩展会互换)。单项目工作流永远碰不到这个问题;确实需要多项目并行各自扩展集的,可以做到(代价:每项目重复装 node_modules),需要请在 issue 里说一声。
|
|
455
480
|
|
|
456
481
|
### 状态栏场景徽标
|
|
457
482
|
|
|
458
|
-
切换成功后状态栏常驻徽标(项目场景 `◆
|
|
483
|
+
切换成功后状态栏常驻徽标(项目场景 `◆ code-matt-pocock`,全局场景 `◇ code-matt-pocock ⌘`),每次会话启动自动恢复,`/scene off` 清除。状态栏应该回答「我现在在哪个场景、哪一层」——而不是展示工具的内部状态。
|
|
459
484
|
|
|
460
|
-
徽标前缀可按场景用 `icon` 字段定制——emoji 完全可用(`💻
|
|
485
|
+
徽标前缀可按场景用 `icon` 字段定制——emoji 完全可用(`💻 code-matt-pocock`、`👑 code-poteto`)。脚手架预设自带 `💻 👑 📄 🎯 🔍 📝 📊`,选择器与 `/scene status` 同步显示同一 icon;未配置的场景回退 `◆`。
|
|
461
486
|
|
|
462
|
-
场景常打包工具型扩展,它们自己的 footer
|
|
487
|
+
场景常打包工具型扩展,它们自己的 footer 输出会把状态栏拼得很吵。若使用任一编码预设(`code-matt-pocock` / `code-poteto`),pi-lens 的诊断 widget 与 `LSP Inactive` 状态可在**不损失任何 AI 侧价值**(turn-end 错误注入、`lens_diagnostics`、符号导航)的前提下静音,写入 `~/.pi-lens/config.json`:
|
|
463
488
|
|
|
464
489
|
```json
|
|
465
490
|
{ "ui": { "hideLspStatus": true }, "widget": { "visible": false } }
|
|
@@ -523,12 +548,21 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
523
548
|
- **本地路径与 npm 写法并存(v0.2.1):** 若 settings 已通过本地路径加载某包(如你的开发目录 `/Users/you/dev/pi-carryover`),场景预设里的 `npm:pi-carryover` 会*借用*你的条目而不安装——跳过 `pi install`,绝不向 settings 追加第二种写法。这一点很关键:同一包双写法 = 同一扩展被加载两份 = pi 启动时工具重名冲突退出。若 settings 已陷入该状态(如手动 `pi install` 造成的重复),`/scene` 会拒绝切换并明确告知需要删除哪个条目。
|
|
524
549
|
- **热修(v0.2.2):** `/scene <name>` 曾报 `Extension "command:scene" error: target.filter is not a function`——v0.2.1 重构时把 `computeTarget()` 返回的 `{packages, skills}` 对象传给了旧调用点用 `target.packages` 的地方,任何场景切换必触发。已修复,并补 command 层冒烟测试(独立测试文件 + `PI_SCENES_DIR` 环境变量 + 动态 import 隔离:扩展 default export 在模块求值时解析 base 目录,测试里静态 import 会直接读写真实 `~/.pi/agent`)。
|
|
525
550
|
|
|
551
|
+
## 场景意图提示(v0.14)
|
|
552
|
+
|
|
553
|
+
不是每次都会记得先切场景再干活。pi-scenes 可以察觉并提示 —— **非阻塞 toast、每会话至多一次、永不自动切换**:
|
|
554
|
+
|
|
555
|
+
- **历史线**(会话启动):本项目上次用过某场景(每次项目级切换都会记录,30 天有效),启动时提示恢复:`💻 上次此项目用的是「code-matt-pocock」场景 → /scene code-matt-pocock`
|
|
556
|
+
- **意图线**(首条消息):纯关键词启发式(无 LLM、零成本)。每个预置场景有内置词表(强词权重 2 / 弱词权重 1),场景还可用 `keywords` 字段自定义(权重 2)。best 得分 ≥ 2 且严格高于次名才出手(平手静默);以 `/` 开头的命令输入永不参与匹配
|
|
557
|
+
|
|
558
|
+
防打扰:每会话最多提示一次(两线共享预算);任何场景已激活时静默;连续忽略 3 次项目级冷却,直到你真正切换场景才重置。`/scene suggest on|off` 总开关(缺省开)。全程只是 `ctx.ui.notify` 一行提示,不打断输入流。
|
|
559
|
+
|
|
526
560
|
## 工作原理
|
|
527
561
|
|
|
528
562
|
```
|
|
529
|
-
/scene
|
|
563
|
+
/scene code-matt-pocock
|
|
530
564
|
│
|
|
531
|
-
├─ 读 scenes.json → 生效集合 = common ∪
|
|
565
|
+
├─ 读 scenes.json → 生效集合 = common ∪ code-matt-pocock(extends 链自动展开)
|
|
532
566
|
├─ 缺失的包 → confirm 后逐个 `pi install`(全局 scope pi 不自动装)
|
|
533
567
|
├─ 改写 settings.json(见「注入与回收」)
|
|
534
568
|
└─ await ctx.reload() → 扩展/skill 热重载,会话不中断
|
|
@@ -554,6 +588,8 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
554
588
|
| `scenes.<name>.prompts` | prompt 模板文件/目录(`.md`),支持 `~` 展开;经 `resources_discover` 动态注入,永不写 settings(v0.8) |
|
|
555
589
|
| `scenes.<name>.extends` | 🧪 继承父场景(union 合并,带环检测)——「主场景→子场景」层级的前向兼容入口 |
|
|
556
590
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | 自进化阈值(见「自进化」节) |
|
|
591
|
+
| `scenes.<name>.keywords` | v0.14 意图提示关键词(权重 2),叠加在预置内置词表之上 |
|
|
592
|
+
| `suggest.enabled` | 场景意图提示总开关(缺省开;`/scene suggest on\|off`) |
|
|
557
593
|
|
|
558
594
|
## 场景化 prompt 模板(v0.8)
|
|
559
595
|
|
|
@@ -571,7 +607,7 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
571
607
|
|
|
572
608
|
**接线方式——零 settings 污染。** 与 packages/skills 落 settings.json 不同,模板走 pi 的 `resources_discover` 事件:每次启动/重载 pi 会询问各扩展需要加载哪些额外资源,pi-scenes 按当前激活场景返回模板路径。切走场景后不再返回——模板自动消失,**不写 settings、无需清理、零残留**。
|
|
573
609
|
|
|
574
|
-
- scaffold 为每个预设场景预置一个流程模板(
|
|
610
|
+
- scaffold 为每个预设场景预置一个流程模板(code-matt-pocock→`/pre-commit`、research→`/deep-dive`、writing→`/fact-check`、pm→`/prd-skeleton`、office→`/doc-from-notes`、data→`/data-audit`),vendored 复制到 `~/.pi/agent/scenes/<场景>/prompts/`(幂等,复制后归你所有,可改可删)
|
|
575
611
|
- 同名解析:你手写的模板(`~/.pi/agent/prompts/`、项目 `.pi/prompts/`)与包模板**优先于**场景模板——用户意图压过预设
|
|
576
612
|
- 为什么需要模板:把步骤清单固化成模板,模型就无法挑最快路径跳步;人只记命令名,清单由模板携带
|
|
577
613
|
|
|
@@ -586,6 +622,16 @@ managed 注入的条目在卸载前建议先 `/scene off` + 手工清理 `packag
|
|
|
586
622
|
|
|
587
623
|
## 版本历史
|
|
588
624
|
|
|
625
|
+
### v0.15.0(2026-11-28)
|
|
626
|
+
|
|
627
|
+
- **编码拆为双场景**——`coding` 更名 `code-matt-pocock`(Matt Pocock 工程流 grill→spec→tickets→implement→review→pr,组合不变),新增 **`code-poteto`** 预设:Lauren Tan(poteto,React 核心团队)的 pstack(MIT,经官方支持 pi 的 standalone 镜像 `backnotprop/pstack`)。白名单按技能依赖成组:`poteto-mode`(22 个 playbook:bug 修复/特性/重构/性能/发布/过夜跑…)+ 全部 22 条 `principle-*`(其硬依赖)+ 严谨核心(tdd/how/why/architect/arena/swarm/interrogate/blast-radius/unslop/no-comments/correct/reflect/statechart/typescript-best-practices/figure-it-out/show-me-your-work/technical-writing)。有意排除:setup-pstack(Cursor 模型选择器)、ketchup-video/make-bot-ui/bro(非编码)、automate-me 与验证技能创作类(meta;按需自加)
|
|
628
|
+
- vendored 模板目录 `assets/scene-prompts/coding` → `code-matt-pocock`;升级用户落盘副本保留(manifest 报告旧 key 为 removed,下次 `/scene init` 或 `/scene update-assets` 补种新 key)
|
|
629
|
+
- 意图提示词表随更名:`code-matt-pocock` 沿用原 coding 词表;`code-poteto` 用差异化词表(playbook/poteto/pstack/swarm/hillclimb/autopilot…)。重叠词双方命中 → 平手不出手(保守设计);可在 scenes.json 用 `keywords` 自定义偏好
|
|
630
|
+
|
|
631
|
+
### v0.14.0(2026-11-28)
|
|
632
|
+
|
|
633
|
+
- **场景意图提示**——无激活场景时非阻塞提示(toast、每会话至多一次、永不自动切换):**历史线**在会话启动时建议恢复本项目上次用的场景(30 天有效);**意图线**把首条消息与各场景关键词表匹配(纯启发式、无 LLM;best ≥ 2 且严格高于次名才出手,平手静默)。防打扰:场景已激活即静默、连续忽略 3 次项目冷却(切换重置)、`/scene suggest on|off` 总开关。场景新增 `keywords` 字段(权重 2)可扩展/覆盖内置词表
|
|
634
|
+
|
|
589
635
|
### v0.13.1(2026-11-28)
|
|
590
636
|
|
|
591
637
|
- **coding 预设焕新**——scaffold 预置改为 `npm:pi-lens`(LSP/ast-grep 实时代码反馈)+ `npm:pi-subagents` + `git:github.com/mattpocock/skills`(glob 白名单 `skills/engineering/**` + `skills/productivity/grilling/**`;20 个工程技能随上游自动跟进)。移除 `npm:pi-git-worktree`、`npm:pi-simplify`(职责被 Matt 的 `code-review` 覆盖)与 anthropics 三技能(frontend-design/webapp-testing/mcp-builder)——有 Web UI / MCP 需求可按需加回
|
package/extensions/scenes.ts
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
*
|
|
38
38
|
* 命令:
|
|
39
39
|
* /scene 弹出选择器(当前场景高亮 ●)
|
|
40
|
-
* /scene <name> 切换到指定场景(默认项目级;参数 Tab 补全:/scene c<Tab> → /scene
|
|
40
|
+
* /scene <name> 切换到指定场景(默认项目级;参数 Tab 补全:/scene c<Tab> → /scene code-matt-pocock)
|
|
41
41
|
* /scene <name> --global 切换为全局场景(所有项目生效,≤0.6 语义)
|
|
42
42
|
* /scene off|none 关闭场景(摘两层,仅保留通用层;资产锚点保留)
|
|
43
43
|
* /scene status 显示当前激活与生效资源(项目/全局两级)
|
|
@@ -98,6 +98,8 @@ export interface SceneDef {
|
|
|
98
98
|
prompts?: string[];
|
|
99
99
|
/** 场景专有 MCP servers 配置;激活时动态注入 settings.json,切走时精确回收 */
|
|
100
100
|
mcpServers?: Record<string, unknown>;
|
|
101
|
+
/** v0.14 意图提示自定义关键词(用户声明 → 权重 2,叠加在预置词表之上) */
|
|
102
|
+
keywords?: string[];
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
export interface EvolveConfig {
|
|
@@ -114,6 +116,8 @@ export interface ScenesFile {
|
|
|
114
116
|
scenes?: Record<string, SceneDef>;
|
|
115
117
|
/** 自进化配置(v0.2) */
|
|
116
118
|
evolve?: EvolveConfig;
|
|
119
|
+
/** v0.14 场景意图提示配置(缺省启用) */
|
|
120
|
+
suggest?: { enabled?: boolean };
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
export interface ResourceUsage {
|
|
@@ -150,6 +154,11 @@ export interface SceneState {
|
|
|
150
154
|
version?: number;
|
|
151
155
|
/** ≤0.6 遗留全局场景的迁移提示是否已弹过(仅全局层 state 使用) */
|
|
152
156
|
migrateNotified?: boolean;
|
|
157
|
+
/** v0.14 项目最近使用场景(历史线提示数据源;off 不清除,30 天过期) */
|
|
158
|
+
lastScene?: string | null;
|
|
159
|
+
lastSceneAt?: string;
|
|
160
|
+
/** v0.14 意图提示记账:连续忽略计数(≥3 冷却静默,切换场景重置) */
|
|
161
|
+
suggest?: { ignoreStreak: number; lastSuggestedAt?: string };
|
|
153
162
|
}
|
|
154
163
|
|
|
155
164
|
export interface ApplyResult {
|
|
@@ -489,6 +498,12 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
489
498
|
anchors: Array.isArray(s.anchors) ? s.anchors : [],
|
|
490
499
|
version: s.version,
|
|
491
500
|
migrateNotified: s.migrateNotified,
|
|
501
|
+
lastScene: s.lastScene ?? null,
|
|
502
|
+
lastSceneAt: s.lastSceneAt,
|
|
503
|
+
suggest:
|
|
504
|
+
s.suggest && typeof s.suggest.ignoreStreak === "number"
|
|
505
|
+
? { ignoreStreak: s.suggest.ignoreStreak, lastSuggestedAt: s.suggest.lastSuggestedAt }
|
|
506
|
+
: undefined,
|
|
492
507
|
};
|
|
493
508
|
}
|
|
494
509
|
|
|
@@ -1231,6 +1246,8 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1231
1246
|
* 按场景裁剪 skills 子集(anthropics/skills 16M 全量)。曾用 openclaw/agent-skills
|
|
1232
1247
|
* (v0.8.1 移除:定位为 OpenClaw 项目专用工作流库而非通用编码技能;autoreview/handoff
|
|
1233
1248
|
* 的职责已由 pi-simplify / pi-subagents 覆盖)。
|
|
1249
|
+
* v0.15:编码拆为双场景 code-matt-pocock(Matt 工程流)/ code-poteto(pstack 严谨流),
|
|
1250
|
+
* 白名单按技能依赖成组裁剪(poteto-mode 需全部 principle-*)。
|
|
1234
1251
|
* 预置技能 vendored 自高质量开源技能(MIT,见各自 SKILL.md 尾部归属声明)。
|
|
1235
1252
|
*/
|
|
1236
1253
|
function scaffold(): string[] {
|
|
@@ -1246,7 +1263,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1246
1263
|
prompts: ["~/.pi/agent/scenes/common/prompts"],
|
|
1247
1264
|
},
|
|
1248
1265
|
scenes: {
|
|
1249
|
-
|
|
1266
|
+
"code-matt-pocock": {
|
|
1250
1267
|
description: "写代码:实时代码反馈(pi-lens)、子代理委派 + Matt Pocock 工程流(grill→spec→tickets→implement→review→pr)",
|
|
1251
1268
|
icon: "💻",
|
|
1252
1269
|
packages: [
|
|
@@ -1257,8 +1274,48 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1257
1274
|
skills: ["skills/engineering/**", "skills/productivity/grilling/**"],
|
|
1258
1275
|
},
|
|
1259
1276
|
],
|
|
1260
|
-
skills: ["~/.pi/agent/scenes/
|
|
1261
|
-
prompts: ["~/.pi/agent/scenes/
|
|
1277
|
+
skills: ["~/.pi/agent/scenes/code-matt-pocock/skills"],
|
|
1278
|
+
prompts: ["~/.pi/agent/scenes/code-matt-pocock/prompts"], // scaffold 预置 pre-commit 提交前自检
|
|
1279
|
+
},
|
|
1280
|
+
"code-poteto": {
|
|
1281
|
+
description: "写代码:pstack 严谨工程流(poteto-mode 22 playbook 路由 + 22 条 principle 原则,Lauren Tan 出品)",
|
|
1282
|
+
icon: "👑",
|
|
1283
|
+
packages: [
|
|
1284
|
+
"npm:pi-lens", // LSP/linter/格式化实时代码反馈
|
|
1285
|
+
"npm:pi-subagents", // 子代理委派(swarm/arena/interrogate 的并行多代理落地)
|
|
1286
|
+
{
|
|
1287
|
+
source: "git:github.com/backnotprop/pstack", // Poteto (Lauren Tan) pstack(MIT;standalone 镜像与上游 cursor/plugins/pstack 同步,README 明确支持 pi)
|
|
1288
|
+
skills: [
|
|
1289
|
+
// 主入口 + 硬依赖:poteto-mode 的 22 playbook 引用全部 principle-*
|
|
1290
|
+
"skills/poteto-mode/**",
|
|
1291
|
+
"skills/principle-*/**",
|
|
1292
|
+
// 严谨编码核心(白名单按依赖成组;组合技能的依赖已齐:
|
|
1293
|
+
// architect→arena;blast-radius→arena/how/why/unslop;technical-writing→unslop)
|
|
1294
|
+
"skills/tdd/**",
|
|
1295
|
+
"skills/how/**",
|
|
1296
|
+
"skills/why/**",
|
|
1297
|
+
"skills/architect/**",
|
|
1298
|
+
"skills/arena/**",
|
|
1299
|
+
"skills/swarm/**",
|
|
1300
|
+
"skills/interrogate/**",
|
|
1301
|
+
"skills/blast-radius/**",
|
|
1302
|
+
"skills/unslop/**",
|
|
1303
|
+
"skills/no-comments/**",
|
|
1304
|
+
"skills/correct/**",
|
|
1305
|
+
"skills/reflect/**",
|
|
1306
|
+
"skills/statechart/**",
|
|
1307
|
+
"skills/typescript-best-practices/**",
|
|
1308
|
+
"skills/figure-it-out/**",
|
|
1309
|
+
"skills/show-me-your-work/**",
|
|
1310
|
+
"skills/technical-writing/**",
|
|
1311
|
+
],
|
|
1312
|
+
// 排除(按需自加):ketchup-video、make-bot-ui、bro(非编码)、
|
|
1313
|
+
// setup-pstack(Cursor 模型选择器,pi 不适用)、automate-me、
|
|
1314
|
+
// create-verification-skill 系列(meta 类,用时再加)
|
|
1315
|
+
},
|
|
1316
|
+
],
|
|
1317
|
+
skills: ["~/.pi/agent/scenes/code-poteto/skills"],
|
|
1318
|
+
prompts: ["~/.pi/agent/scenes/code-poteto/prompts"],
|
|
1262
1319
|
},
|
|
1263
1320
|
office: {
|
|
1264
1321
|
description: "办公:文档解析与生成、内部沟通",
|
|
@@ -1343,7 +1400,7 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1343
1400
|
writeJson(paths.scenesFile, template);
|
|
1344
1401
|
created.push(paths.scenesFile);
|
|
1345
1402
|
}
|
|
1346
|
-
for (const s of ["common", "
|
|
1403
|
+
for (const s of ["common", "code-matt-pocock", "code-poteto", "office", "pm", "research", "writing", "data", "learning", "productivity"]) {
|
|
1347
1404
|
for (const kind of ["skills", "prompts"] as const) {
|
|
1348
1405
|
const dir = path.join(paths.scenesRoot, s, kind);
|
|
1349
1406
|
if (!fs.existsSync(dir)) {
|
|
@@ -1484,6 +1541,72 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1484
1541
|
};
|
|
1485
1542
|
}
|
|
1486
1543
|
|
|
1544
|
+
// ── v0.14 场景意图提示(/scene suggest)──────────────────
|
|
1545
|
+
// 纯关键词启发式(无 LLM):场景可声明 keywords(权重 2,用户声明)+ 预置场景内置词表(强词 2 / 弱词 1)。
|
|
1546
|
+
// 出手条件:best 得分 ≥ 2 且严格高于次名(平手不出手,避免误导);非阻塞 notify,每会话至多一次。
|
|
1547
|
+
|
|
1548
|
+
function suggestEnabled(cfg: ScenesFile): boolean {
|
|
1549
|
+
return cfg.suggest?.enabled !== false;
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
function suggestAllowed(): { ok: boolean; why?: "active" | "muted" } {
|
|
1553
|
+
if (effectiveActive()) return { ok: false, why: "active" };
|
|
1554
|
+
if ((loadProjectState().suggest?.ignoreStreak ?? 0) >= 3) return { ok: false, why: "muted" };
|
|
1555
|
+
return { ok: true };
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
function matchScene(text: string, cfg: ScenesFile): { name: string; score: number } | null {
|
|
1559
|
+
const lower = text.toLowerCase();
|
|
1560
|
+
let best: { name: string; score: number } | null = null;
|
|
1561
|
+
let second = 0;
|
|
1562
|
+
for (const [name, def] of Object.entries(cfg.scenes ?? {})) {
|
|
1563
|
+
const preset = PRESET_KEYWORDS[name];
|
|
1564
|
+
const userKw = Array.isArray(def.keywords) ? def.keywords : [];
|
|
1565
|
+
let score = 0;
|
|
1566
|
+
for (const k of userKw) if (lower.includes(k.toLowerCase())) score += 2;
|
|
1567
|
+
if (preset) {
|
|
1568
|
+
for (const k of preset.strong) if (lower.includes(k.toLowerCase())) score += 2;
|
|
1569
|
+
for (const k of preset.weak) if (lower.includes(k.toLowerCase())) score += 1;
|
|
1570
|
+
}
|
|
1571
|
+
if (score <= 0) continue;
|
|
1572
|
+
if (!best || score > best.score) {
|
|
1573
|
+
second = best ? best.score : second;
|
|
1574
|
+
best = { name, score };
|
|
1575
|
+
} else if (score > second) {
|
|
1576
|
+
second = score;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
if (!best || best.score < 2 || best.score <= second) return null;
|
|
1580
|
+
return best;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
function recordSuggested(_scene: string): void {
|
|
1584
|
+
const ps = loadProjectState();
|
|
1585
|
+
saveProjectState({
|
|
1586
|
+
...ps,
|
|
1587
|
+
suggest: { ignoreStreak: ps.suggest?.ignoreStreak ?? 0, lastSuggestedAt: new Date().toISOString() },
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/** 会话收尾结算:提示后用户切到了建议场景 → 重置冷却;否则忽略计数 +1(≥3 冷却静默) */
|
|
1592
|
+
function settleSuggested(scene: string | null, activeNow: string | null): void {
|
|
1593
|
+
if (!scene) return;
|
|
1594
|
+
const ps = loadProjectState();
|
|
1595
|
+
const ignoreStreak = activeNow === scene ? 0 : (ps.suggest?.ignoreStreak ?? 0) + 1;
|
|
1596
|
+
saveProjectState({ ...ps, suggest: { ignoreStreak, lastSuggestedAt: ps.suggest?.lastSuggestedAt } });
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
/** 切换场景时记录项目最近使用(历史线数据源)+ 重置提示冷却;off 不清除 lastScene */
|
|
1600
|
+
function recordSceneUse(name: string): void {
|
|
1601
|
+
const ps = loadProjectState();
|
|
1602
|
+
saveProjectState({
|
|
1603
|
+
...ps,
|
|
1604
|
+
lastScene: name,
|
|
1605
|
+
lastSceneAt: new Date().toISOString(),
|
|
1606
|
+
suggest: { ignoreStreak: 0, lastSuggestedAt: ps.suggest?.lastSuggestedAt },
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1487
1610
|
return {
|
|
1488
1611
|
paths,
|
|
1489
1612
|
loadScenes,
|
|
@@ -1513,6 +1636,12 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1513
1636
|
scaffold,
|
|
1514
1637
|
syncVendoredAssets,
|
|
1515
1638
|
importClaudePlugin,
|
|
1639
|
+
suggestEnabled,
|
|
1640
|
+
suggestAllowed,
|
|
1641
|
+
matchScene,
|
|
1642
|
+
recordSuggested,
|
|
1643
|
+
settleSuggested,
|
|
1644
|
+
recordSceneUse,
|
|
1516
1645
|
};
|
|
1517
1646
|
}
|
|
1518
1647
|
|
|
@@ -1521,9 +1650,53 @@ export function makeCore(baseDir: string, projectDir?: string) {
|
|
|
1521
1650
|
const PICKER_OFF = "∅ 仅通用层(关闭场景)";
|
|
1522
1651
|
const PICKER_CANCEL = "—— 取消";
|
|
1523
1652
|
|
|
1653
|
+
/** v0.14 预置场景内置意图词表:strong 权重 2 / weak 权重 1;用户 scenes.json 可用 keywords 覆盖/叠加 */
|
|
1654
|
+
const PRESET_KEYWORDS: Record<string, { strong: string[]; weak: string[] }> = {
|
|
1655
|
+
"code-matt-pocock": {
|
|
1656
|
+
strong: ["重构", "refactor", "报错", "调试", "debug", "bug", "单元测试", "单测", "tdd", "类型错误", "编译错误", "报异常", "实现一个", "写个脚本"],
|
|
1657
|
+
weak: ["代码", "函数", "测试", "提交", "commit", "部署", "npm", "git", "脚本", "性能", "代码审查", "依赖"],
|
|
1658
|
+
},
|
|
1659
|
+
"code-poteto": {
|
|
1660
|
+
// 差异化词表:只用 pstack 特色工作流词,避免与 code-matt-pocock 重叠
|
|
1661
|
+
// (重叠词双方命中 → 平手不出手,意图提示保守正确;偏好可经 scenes.json keywords 覆盖)
|
|
1662
|
+
strong: ["playbook", "poteto", "pstack", "swarm", "hillclimb", "autopilot", "过夜跑", "多阶段计划", "正式验证", "statechart"],
|
|
1663
|
+
weak: ["严谨", "并行多代理", "验证链", "爆炸半径", "blast radius"],
|
|
1664
|
+
},
|
|
1665
|
+
office: {
|
|
1666
|
+
strong: ["ppt", "docx", "xlsx", "excel", "幻灯片", "会议纪要", "周报", "写邮件", "邮件草稿", "word文档", "pdf转"],
|
|
1667
|
+
weak: ["文档", "表格", "通知", "公告", "简历", "排版"],
|
|
1668
|
+
},
|
|
1669
|
+
pm: {
|
|
1670
|
+
strong: ["竞品分析", "prd", "需求文档", "用户故事", "roadmap", "排期", "目标拆解", "需求拆解"],
|
|
1671
|
+
weak: ["产品", "需求", "迭代", "里程碑", "优先级", "backlog"],
|
|
1672
|
+
},
|
|
1673
|
+
research: {
|
|
1674
|
+
strong: ["调研", "文献综述", "arxiv", "论文", "深度调研", "行业报告", "信源"],
|
|
1675
|
+
weak: ["检索", "搜集", "多角度", "对比分析", "调查"],
|
|
1676
|
+
},
|
|
1677
|
+
writing: {
|
|
1678
|
+
strong: ["润色", "写文章", "公众号", "推文", "文风", "去ai味", "改写"],
|
|
1679
|
+
weak: ["文章", "写作", "文案", "标题", "摘要", "草稿"],
|
|
1680
|
+
},
|
|
1681
|
+
data: {
|
|
1682
|
+
strong: ["数据分析", "数据清洗", "透视表", "可视化", "sql", "图表", "统计一下"],
|
|
1683
|
+
weak: ["数据", "csv", "数据库", "报表", "统计"],
|
|
1684
|
+
},
|
|
1685
|
+
learning: {
|
|
1686
|
+
strong: ["费曼", "闪卡", "苏格拉底", "eli5", "教我", "通俗易懂"],
|
|
1687
|
+
weak: ["学习", "理解", "概念", "复习", "入门", "讲解"],
|
|
1688
|
+
},
|
|
1689
|
+
productivity: {
|
|
1690
|
+
strong: ["待办", "任务清单", "任务管理"],
|
|
1691
|
+
weak: ["任务", "日程", "计划"],
|
|
1692
|
+
},
|
|
1693
|
+
};
|
|
1694
|
+
|
|
1524
1695
|
export default function (pi: ExtensionAPI) {
|
|
1525
1696
|
const baseDir = process.env.PI_SCENES_DIR || path.join(os.homedir(), ".pi", "agent");
|
|
1526
1697
|
const core = makeCore(baseDir);
|
|
1698
|
+
// v0.14 意图提示会话记账:每会话至多提示一次(历史线 + 意图线共享预算)
|
|
1699
|
+
const suggestSession: { used: boolean; scene: string | null } = { used: false, scene: null };
|
|
1527
1700
|
|
|
1528
1701
|
/**
|
|
1529
1702
|
* 状态栏常驻场景徽标:项目场景 ◆ <名>(默认层级);全局场景 ◇ <名> ⌘(--global)。
|
|
@@ -1632,6 +1805,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
1632
1805
|
}
|
|
1633
1806
|
|
|
1634
1807
|
const r = core.applyToSettings(target, name, preInstallPackages, scope);
|
|
1808
|
+
if (scope === "project" && name) {
|
|
1809
|
+
try {
|
|
1810
|
+
core.recordSceneUse(name); // v0.14 项目历史线数据源 + 重置提示冷却
|
|
1811
|
+
} catch { /* 场景历史记录失败不阻断切换 */ }
|
|
1812
|
+
}
|
|
1635
1813
|
updateSceneBadge(ctx);
|
|
1636
1814
|
const promptCount = target.prompts.filter((p) => fs.existsSync(p)).length;
|
|
1637
1815
|
ctx.ui.notify(
|
|
@@ -1673,6 +1851,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1673
1851
|
["update-assets", "同步包内预置模板/skill(未修改的跟随新版,改过的保留)"],
|
|
1674
1852
|
["evolve", "生成并应用进化提案"],
|
|
1675
1853
|
["evolve auto", "开关:会话结束自动应用进化"],
|
|
1854
|
+
["suggest", "场景意图提示开关(on/off):无场景时非阻塞建议切换"],
|
|
1676
1855
|
];
|
|
1677
1856
|
for (const [value, description] of subs) items.push({ value, label: value, description });
|
|
1678
1857
|
const filtered = items.filter((i) => i.value.toLowerCase().startsWith(p));
|
|
@@ -1825,6 +2004,21 @@ export default function (pi: ExtensionAPI) {
|
|
|
1825
2004
|
return;
|
|
1826
2005
|
}
|
|
1827
2006
|
|
|
2007
|
+
if (arg === "suggest" || arg.startsWith("suggest ")) {
|
|
2008
|
+
const sub = arg.replace(/^suggest\s*/, "").trim();
|
|
2009
|
+
if (sub === "on" || sub === "off") {
|
|
2010
|
+
const cfgNow = core.loadScenes();
|
|
2011
|
+
backupScenes();
|
|
2012
|
+
core.saveScenes({ ...cfgNow, suggest: { ...(cfgNow.suggest ?? {}), enabled: sub === "on" } });
|
|
2013
|
+
}
|
|
2014
|
+
const enabled = core.suggestEnabled(core.loadScenes());
|
|
2015
|
+
ctx.ui.notify(
|
|
2016
|
+
`场景意图提示:${enabled ? "开" : "关"}\n无激活场景时,会话启动(项目历史)或首条消息(关键词命中)→ 非阻塞提示一次;连续忽略 3 次自动冷却,切换场景后重置`,
|
|
2017
|
+
"info",
|
|
2018
|
+
);
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
1828
2022
|
if (arg === "off" || arg === "none") {
|
|
1829
2023
|
// off 无论何种 scope 都摘两层(用户意图 = 全部关掉);资产锚点保留
|
|
1830
2024
|
await doSwitch(ctx, null, scope);
|
|
@@ -2059,6 +2253,25 @@ export default function (pi: ExtensionAPI) {
|
|
|
2059
2253
|
} catch { /* 迁移提示失败不阻断 */ }
|
|
2060
2254
|
}
|
|
2061
2255
|
|
|
2256
|
+
// v0.14 历史线:本项目上次用的场景 → 非阻塞提示恢复(reload 不触发;与意图线共享每会话预算)
|
|
2257
|
+
function suggestFromHistory(ctx: any): void {
|
|
2258
|
+
const cfg = core.loadScenes();
|
|
2259
|
+
if (!core.suggestEnabled(cfg)) return;
|
|
2260
|
+
if (!core.suggestAllowed().ok) return;
|
|
2261
|
+
const ps = core.loadProjectState();
|
|
2262
|
+
const name = ps.lastScene;
|
|
2263
|
+
if (!name || !cfg.scenes?.[name]) return;
|
|
2264
|
+
if (ps.lastSceneAt && Date.now() - Date.parse(ps.lastSceneAt) > 30 * 86_400_000) return; // 30 天过期
|
|
2265
|
+
const icon = cfg.scenes[name]?.icon?.trim() || "◆";
|
|
2266
|
+
ctx.ui?.notify(
|
|
2267
|
+
`${icon} 上次此项目用的是「${name}」场景 → /scene ${name} 恢复(提示可用 /scene suggest off 关闭)`,
|
|
2268
|
+
"info",
|
|
2269
|
+
);
|
|
2270
|
+
suggestSession.used = true;
|
|
2271
|
+
suggestSession.scene = name;
|
|
2272
|
+
core.recordSuggested(name);
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2062
2275
|
// v0.8:场景化 prompt 模板 —— resources_discover 事件动态注入。
|
|
2063
2276
|
// 每次 startup/reload pi 都会询问本扩展;按当前激活场景返回 promptPaths,
|
|
2064
2277
|
// 切走后不再返回 → 模板自动消失,零 settings 写入、零残留。
|
|
@@ -2072,13 +2285,47 @@ export default function (pi: ExtensionAPI) {
|
|
|
2072
2285
|
}
|
|
2073
2286
|
});
|
|
2074
2287
|
|
|
2075
|
-
pi.on("session_start", async (
|
|
2288
|
+
pi.on("session_start", async (event, ctx) => {
|
|
2289
|
+
const reason = (event as any)?.reason ?? "startup";
|
|
2290
|
+
suggestSession.used = false;
|
|
2291
|
+
suggestSession.scene = null;
|
|
2076
2292
|
try {
|
|
2077
2293
|
const all = readAllSettingsPackages();
|
|
2078
2294
|
core.beginSession(ctx.sessionManager?.getSessionFile?.() ?? null, [...all.project, ...all.user]);
|
|
2079
2295
|
} catch { /* 会话记账失败不阻断切换 */ }
|
|
2080
2296
|
updateSceneBadge(ctx);
|
|
2081
2297
|
notifyLegacyMigration(ctx);
|
|
2298
|
+
if (reason !== "reload") {
|
|
2299
|
+
try {
|
|
2300
|
+
suggestFromHistory(ctx);
|
|
2301
|
+
} catch { /* 历史场景提示失败不阻断 */ }
|
|
2302
|
+
}
|
|
2303
|
+
});
|
|
2304
|
+
|
|
2305
|
+
// v0.14 意图线:首条非命令消息命中场景关键词 → 非阻塞提示(notify,不打断输入流)。
|
|
2306
|
+
// 每会话至多一次;已激活场景 / 冷却中 / 功能关闭 / 平手时不出手;始终放行输入。
|
|
2307
|
+
pi.on("input", async (event, ctx) => {
|
|
2308
|
+
try {
|
|
2309
|
+
const e = event as any;
|
|
2310
|
+
if (e?.source === "extension") return { action: "continue" };
|
|
2311
|
+
const text = String(e?.text ?? "");
|
|
2312
|
+
if (!text.trim() || text.trimStart().startsWith("/")) return { action: "continue" };
|
|
2313
|
+
if (suggestSession.used) return { action: "continue" };
|
|
2314
|
+
const cfg = core.loadScenes();
|
|
2315
|
+
if (!core.suggestEnabled(cfg)) return { action: "continue" };
|
|
2316
|
+
if (!core.suggestAllowed().ok) return { action: "continue" };
|
|
2317
|
+
const hit = core.matchScene(text, cfg);
|
|
2318
|
+
if (!hit) return { action: "continue" };
|
|
2319
|
+
const icon = cfg.scenes?.[hit.name]?.icon?.trim() || "◆";
|
|
2320
|
+
ctx.ui?.notify(
|
|
2321
|
+
`💡 这条像「${icon} ${hit.name}」的活儿 → /scene ${hit.name} 启用场景(提示可用 /scene suggest off 关闭)`,
|
|
2322
|
+
"info",
|
|
2323
|
+
);
|
|
2324
|
+
suggestSession.used = true;
|
|
2325
|
+
suggestSession.scene = hit.name;
|
|
2326
|
+
core.recordSuggested(hit.name);
|
|
2327
|
+
} catch { /* 意图提示失败不阻断输入 */ }
|
|
2328
|
+
return { action: "continue" };
|
|
2082
2329
|
});
|
|
2083
2330
|
|
|
2084
2331
|
pi.on("tool_call", async (event) => {
|
|
@@ -2090,6 +2337,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
2090
2337
|
pi.on("session_shutdown", async (event, ctx) => {
|
|
2091
2338
|
const reason = (event as any)?.reason ?? "quit";
|
|
2092
2339
|
if (reason === "reload") return;
|
|
2340
|
+
try {
|
|
2341
|
+
core.settleSuggested(suggestSession.scene, core.effectiveActive());
|
|
2342
|
+
} catch { /* 提示记账失败不阻断 */ }
|
|
2093
2343
|
try {
|
|
2094
2344
|
await runReflection(ctx);
|
|
2095
2345
|
} catch { /* 会话反思失败不阻断 */ }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-scenes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
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"
|
|
File without changes
|