pi-scenes 0.3.0 → 0.4.1
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 +24 -2
- package/extensions/scenes.ts +79 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ active resources = common layer ∪ current scene
|
|
|
20
20
|
- **Common layer** — extensions + skills that stay loaded in *every* scenario (quota display, session carryover…)
|
|
21
21
|
- **Scene layers** — per-scenario bundles (coding / office / writing…), loaded only while active
|
|
22
22
|
- Switching rewrites `packages`/`skills` in `settings.json`, then `ctx.reload()` hot-reloads — **no pi restart, session untouched**
|
|
23
|
+
- Every switch stamps a persistent **status-bar badge** (`◆ coding`, or a per-scene `icon` like `💻 coding`) so the bar always answers *"which scene am I in"* — restored at session start, cleared by `/scene off`
|
|
24
|
+
- **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`; `/scenes` works as a plural alias
|
|
23
25
|
- The data model reserves an `extends` chain (with cycle detection) for future **parent → child scene** hierarchies
|
|
24
26
|
|
|
25
27
|
## Install
|
|
@@ -40,6 +42,8 @@ Then `/reload` and `/scene` is live.
|
|
|
40
42
|
|
|
41
43
|
```
|
|
42
44
|
/scene # picker: all scenes, ● current, ○ switchable
|
|
45
|
+
/scene <Tab> # tab-complete: lists all scenes (icon + description) and subcommands
|
|
46
|
+
/scene c<Tab> # completes to /scene coding — no scene names to memorize
|
|
43
47
|
/scene coding # switch directly to the coding scene
|
|
44
48
|
/scene office # switch to the office scene
|
|
45
49
|
/scene off # common layer only (scene off)
|
|
@@ -48,6 +52,7 @@ Then `/reload` and `/scene` is live.
|
|
|
48
52
|
/scene stats # usage dashboard: sessions, tool calls, reflections
|
|
49
53
|
/scene evolve # generate & apply evolution proposals (confirm-first)
|
|
50
54
|
/scene evolve auto # toggle auto-apply at session end (opt-in)
|
|
55
|
+
/scenes ... # plural alias — same command, same completions
|
|
51
56
|
```
|
|
52
57
|
|
|
53
58
|
First run of `/scene` offers to generate the template. It ships with **seven preset scenes + common** (all packages verified on npm, 2026-09):
|
|
@@ -75,6 +80,7 @@ Edit it to fit your setup (each scene also gets a skill dir scaffold at `~/.pi/a
|
|
|
75
80
|
"scenes": { // ── scene layers: stacked when active
|
|
76
81
|
"coding": {
|
|
77
82
|
"description": "coding",
|
|
83
|
+
"icon": "💻",
|
|
78
84
|
"packages": ["npm:pi-carryover"],
|
|
79
85
|
"skills": ["~/.pi/agent/scenes/coding/skills"]
|
|
80
86
|
},
|
|
@@ -95,6 +101,8 @@ Drop `SKILL.md` folders (or `.md` files) into a scene's skill directory; the who
|
|
|
95
101
|
|
|
96
102
|
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.
|
|
97
103
|
|
|
104
|
+
The prefix is customizable per scene via the `icon` field — emoji works great (`💻 coding`). The scaffolded presets ship with `💻 📄 🎯 🔍 📝 📊`, and the picker plus `/scene status` display the same icon; unset scenes fall back to `◆`.
|
|
105
|
+
|
|
98
106
|
Scenes often bundle tool-heavy extensions whose own footer output crowds the bar. If you use the preset `coding` scene, 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`:
|
|
99
107
|
|
|
100
108
|
```json
|
|
@@ -135,6 +143,8 @@ Usage data: `~/.pi/agent/scenes-usage.json` (machine-local, inert). View anytime
|
|
|
135
143
|
|
|
136
144
|
In short: **installed forever, loaded per scene**. One caveat: extensions you installed manually (your own entries in settings) are yours — pi-scenes treats them as `borrowed`, never touches them, so they stay loaded in *every* scene.
|
|
137
145
|
|
|
146
|
+
**Package updates are scene-independent.** Every package — whichever scene lists it — is installed once, globally, under `~/.pi/agent/npm/`; scenes only flip the `settings.json` switch. So `pi update --extensions` works no matter which scene is active (pi's update banner scans installed packages, not the active scene), and since scene definitions use version-less specs (`npm:<pkg>`), the new version loads on the next switch/reload. One caveat: `0.x` caret ranges don't cross minor versions — if the banner persists after updating, pin it explicitly: `pi install npm:<pkg>@<version>`.
|
|
147
|
+
|
|
138
148
|
### Duplicate & conflict handling
|
|
139
149
|
|
|
140
150
|
- Same spec in `common` and a scene → deduplicated at the union (loaded once).
|
|
@@ -166,6 +176,7 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
|
|
|
166
176
|
|---|---|
|
|
167
177
|
| `common.packages` / `common.skills` | common-layer resources, always loaded |
|
|
168
178
|
| `scenes.<name>.packages` | accepts `"npm:<pkg>"`, `"git:github.com/u/r"`, local paths, and object form (resource filtering, same grammar as pi settings) |
|
|
179
|
+
| `scenes.<name>.icon` | status-bar badge & picker prefix (emoji recommended; default `◆`) |
|
|
169
180
|
| `scenes.<name>.skills` | paths/directories, `~` expanded |
|
|
170
181
|
| `scenes.<name>.extends` | 🧪 inherit a parent scene (union merge + cycle detection) — forward-compatible entry for parent→child hierarchies |
|
|
171
182
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | self-evolution tunables (see "Self-evolution") |
|
|
@@ -183,7 +194,7 @@ Before uninstalling, `/scene off` and prune entries you don't want to keep from
|
|
|
183
194
|
|
|
184
195
|
```bash
|
|
185
196
|
git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
|
|
186
|
-
npm test # node:test,
|
|
197
|
+
npm test # node:test, 20 cases: injection/reclaim + usage/evolution + conflict guards + command-layer smoke (no TUI needed)
|
|
187
198
|
```
|
|
188
199
|
|
|
189
200
|
Tests isolate via the `PI_SCENES_DIR` env var — your real `~/.pi/agent` is never touched.
|
|
@@ -213,6 +224,8 @@ pi 的 `packages` / `skills` 是全局平铺的:所有已安装扩展、所有
|
|
|
213
224
|
- **通用层**:任何场景下恒加载的 extension + skill(如配额显示、会话延续)
|
|
214
225
|
- **场景层**:每个场景自己的一组 extension + skill,激活才加载
|
|
215
226
|
- 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**
|
|
227
|
+
- 每次切换成功后状态栏常驻**场景徽标**(`◆ coding`,或每场景自定义 `icon` 如 `💻 coding`),状态栏随时回答「我现在在哪个场景」——会话启动自动恢复,`/scene off` 清除
|
|
228
|
+
- **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene coding`;`/scenes` 复数别名同义可用
|
|
216
229
|
- 数据模型预留 `extends` 继承链(带环检测),为将来「主场景 → 子场景」层级铺路
|
|
217
230
|
|
|
218
231
|
## 安装
|
|
@@ -233,6 +246,8 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
233
246
|
|
|
234
247
|
```
|
|
235
248
|
/scene # 弹出选择器:列出所有场景,● 当前,○ 可切
|
|
249
|
+
/scene <Tab> # Tab 补全:列出全部场景(icon + 描述)与子命令
|
|
250
|
+
/scene c<Tab> # 补齐为 /scene coding —— 无需记忆任何场景名
|
|
236
251
|
/scene coding # 直接切到 coding 场景
|
|
237
252
|
/scene office # 切到办公场景
|
|
238
253
|
/scene off # 仅保留通用层(关闭场景)
|
|
@@ -241,6 +256,7 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
241
256
|
/scene stats # 用量仪表盘:会话数 / 工具调用 / 反思评分
|
|
242
257
|
/scene evolve # 生成并应用进化提案(逐条确认)
|
|
243
258
|
/scene evolve auto # 开关:会话结束自动应用(opt-in)
|
|
259
|
+
/scenes ... # 复数别名:与 /scene 完全同义,补全行为一致
|
|
244
260
|
```
|
|
245
261
|
|
|
246
262
|
首次运行 `/scene` 会询问是否生成模板,生成后编辑场景定义。模板内置 **七个预设场景 + 通用层**(包均在 npm 核验存在,2026-09):
|
|
@@ -268,6 +284,7 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
268
284
|
"scenes": { // ── 场景层:激活才叠加
|
|
269
285
|
"coding": {
|
|
270
286
|
"description": "写代码",
|
|
287
|
+
"icon": "💻",
|
|
271
288
|
"packages": ["npm:pi-carryover"],
|
|
272
289
|
"skills": ["~/.pi/agent/scenes/coding/skills"]
|
|
273
290
|
},
|
|
@@ -289,6 +306,8 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
289
306
|
|
|
290
307
|
切换成功后状态栏常驻徽标(`◆ coding`),每次会话启动自动恢复,`/scene off` 清除。状态栏应该回答「我现在在哪个场景」——而不是展示工具的内部状态。
|
|
291
308
|
|
|
309
|
+
徽标前缀可按场景用 `icon` 字段定制——emoji 完全可用(`💻 coding`)。脚手架预设自带 `💻 📄 🎯 🔍 📝 📊`,选择器与 `/scene status` 同步显示同一 icon;未配置的场景回退 `◆`。
|
|
310
|
+
|
|
292
311
|
场景常打包工具型扩展,它们自己的 footer 输出会把状态栏拼得很吵。若使用预设 `coding` 场景,pi-lens 的诊断 widget 与 `LSP Inactive` 状态可在**不损失任何 AI 侧价值**(turn-end 错误注入、`lens_diagnostics`、符号导航)的前提下静音,写入 `~/.pi-lens/config.json`:
|
|
293
312
|
|
|
294
313
|
```json
|
|
@@ -329,6 +348,8 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
329
348
|
|
|
330
349
|
一句话:**永远安装,只按场景加载**。注意:你手工 `pi install` 的条目属于你自己——pi-scenes 视为 `borrowed`,永不触碰,因此在**所有**场景都保持加载。
|
|
331
350
|
|
|
351
|
+
**包更新与场景无关。** 无论包被哪个场景引用,都只在全局安装一份(`~/.pi/agent/npm/`),场景只是拨动 `settings.json` 里的开关。因此 `pi update --extensions` 与当前在哪个场景无关(pi 的更新提示扫的是已安装包,不是活跃场景),且场景定义写的是不带版本的 `npm:<pkg>`,更新后下次切换/重载自动加载新版。注意 `0.x` 的 caret 范围不跨 minor——若更新提示反复出现,显式装指定版本:`pi install npm:<pkg>@<版本>`。
|
|
352
|
+
|
|
332
353
|
### 重复与冲突处理
|
|
333
354
|
|
|
334
355
|
- 同一写法在 common 与场景重复 → 并集时去重,只加载一次。
|
|
@@ -360,6 +381,7 @@ pi-scenes 绝不改第三方包的全局配置——徽标是它放到状态栏
|
|
|
360
381
|
|---|---|
|
|
361
382
|
| `common.packages` / `common.skills` | 通用层资源,恒加载 |
|
|
362
383
|
| `scenes.<name>.packages` | 支持 `"npm:<pkg>"`、`"git:github.com/u/r"`、本地路径字符串,及 object form(资源过滤,同 pi settings 规范) |
|
|
384
|
+
| `scenes.<name>.icon` | 状态栏徽标与选择器前缀(建议 emoji;缺省 `◆`) |
|
|
363
385
|
| `scenes.<name>.skills` | 路径/目录数组,支持 `~` 展开 |
|
|
364
386
|
| `scenes.<name>.extends` | 🧪 继承父场景(union 合并,带环检测)——「主场景→子场景」层级的前向兼容入口 |
|
|
365
387
|
| `evolve.patience` / `evolve.absorbThreshold` / `evolve.skillUnusedThreshold` | 自进化阈值(见「自进化」节) |
|
|
@@ -377,7 +399,7 @@ managed 注入的条目在卸载前建议先 `/scene off` + 手工清理 `packag
|
|
|
377
399
|
|
|
378
400
|
```bash
|
|
379
401
|
git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
|
|
380
|
-
npm test # node:test,
|
|
402
|
+
npm test # node:test,20 用例:注入/回收 + 用量/进化 + 异写法冲突防护 + command 层冒烟(无需 TUI)
|
|
381
403
|
```
|
|
382
404
|
|
|
383
405
|
测试用 `PI_SCENES_DIR` 环境变量隔离基目录,不碰真实 `~/.pi/agent`。
|
package/extensions/scenes.ts
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
*
|
|
21
21
|
* 命令:
|
|
22
22
|
* /scene 弹出选择器(当前场景高亮 ●)
|
|
23
|
-
* /scene <name>
|
|
23
|
+
* /scene <name> 切换到指定场景(参数 Tab 补全:/scene c<Tab> → /scene coding)
|
|
24
|
+
* /scenes 同 /scene(复数别名,误输也能用;补全行为一致)
|
|
24
25
|
* /scene off|none 仅保留通用层(关闭场景)
|
|
25
26
|
* /scene status 显示当前激活与生效资源
|
|
26
27
|
* /scene init 生成模板 scenes.json 与场景 skill 目录骨架
|
|
@@ -28,6 +29,10 @@
|
|
|
28
29
|
* /scene evolve 生成进化提案并逐条确认应用(备份 + 热重载)
|
|
29
30
|
* /scene evolve auto 开关:会话结束自动应用进化(opt-in,不动 common/无工具包)
|
|
30
31
|
*
|
|
32
|
+
* 可发现性(v0.4.1):命令 description 在注册时动态拼入场景名清单;
|
|
33
|
+
* 参数 Tab 补全列出全部场景(icon+描述+当前标记)与子命令 ——
|
|
34
|
+
* 不需要记忆任何场景名,空格后 Tab 即见全表。
|
|
35
|
+
*
|
|
31
36
|
* 自进化(v0.2):
|
|
32
37
|
* 采集:tool_call 归因(静态扫描安装源码建 tool→pkg 表)+
|
|
33
38
|
* settings 未纳管条目观察 + 会话结束 LLM 反思 skill 有用性
|
|
@@ -57,6 +62,8 @@ export type PackageEntry = string | { source: string; [k: string]: unknown };
|
|
|
57
62
|
|
|
58
63
|
export interface SceneDef {
|
|
59
64
|
description?: string;
|
|
65
|
+
/** 状态栏徽标与选择器里的场景前缀(建议 emoji,如 💻);缺省 ◆ */
|
|
66
|
+
icon?: string;
|
|
60
67
|
/** 前向兼容:继承父场景(主场景→子场景层级),资源按链 union 合并 */
|
|
61
68
|
extends?: string;
|
|
62
69
|
packages?: PackageEntry[];
|
|
@@ -775,6 +782,7 @@ export function makeCore(baseDir: string) {
|
|
|
775
782
|
scenes: {
|
|
776
783
|
coding: {
|
|
777
784
|
description: "写代码:实时代码反馈、子代理委派、并行分支",
|
|
785
|
+
icon: "💻",
|
|
778
786
|
packages: [
|
|
779
787
|
"npm:pi-lens", // LSP/linter/格式化实时代码反馈
|
|
780
788
|
"npm:pi-subagents", // 单代理委派 + 脚本化多代理工作流
|
|
@@ -784,6 +792,7 @@ export function makeCore(baseDir: string) {
|
|
|
784
792
|
},
|
|
785
793
|
office: {
|
|
786
794
|
description: "办公:文档处理与日常事务",
|
|
795
|
+
icon: "📄",
|
|
787
796
|
packages: [
|
|
788
797
|
"npm:pi-docparser", // PDF/Office 文档解析抽取
|
|
789
798
|
],
|
|
@@ -791,6 +800,7 @@ export function makeCore(baseDir: string) {
|
|
|
791
800
|
},
|
|
792
801
|
pm: {
|
|
793
802
|
description: "产品经理:竞品调研、目标规划与需求跟踪",
|
|
803
|
+
icon: "🎯",
|
|
794
804
|
packages: [
|
|
795
805
|
"npm:pi-web-access", // 网页搜索/抓取/PDF/YouTube(竞品与市场调研)
|
|
796
806
|
"npm:pi-goal-x", // /goal 目标规划 + 独立完成度审计(roadmap/需求跟踪)
|
|
@@ -800,6 +810,7 @@ export function makeCore(baseDir: string) {
|
|
|
800
810
|
},
|
|
801
811
|
research: {
|
|
802
812
|
description: "咨询调研:多源检索、并行多角度深挖",
|
|
813
|
+
icon: "🔍",
|
|
803
814
|
packages: [
|
|
804
815
|
"npm:pi-web-access", // 搜索/URL 抓取/PDF/视频理解(调研核心)
|
|
805
816
|
"npm:pi-subagents", // 多角度并行调研(每个子代理一源)
|
|
@@ -808,6 +819,7 @@ export function makeCore(baseDir: string) {
|
|
|
808
819
|
},
|
|
809
820
|
writing: {
|
|
810
821
|
description: "写作:素材检索、事实核查、文体打磨",
|
|
822
|
+
icon: "📝",
|
|
811
823
|
packages: [
|
|
812
824
|
"npm:pi-web-access", // 素材检索与事实核查(引用溯源)
|
|
813
825
|
],
|
|
@@ -815,6 +827,7 @@ export function makeCore(baseDir: string) {
|
|
|
815
827
|
},
|
|
816
828
|
data: {
|
|
817
829
|
description: "数据分析:表格抽取、MCP 接数据库/BI",
|
|
830
|
+
icon: "📊",
|
|
818
831
|
packages: [
|
|
819
832
|
"npm:pi-docparser", // Excel/CSV/PDF 表格结构化抽取
|
|
820
833
|
"npm:pi-mcp-adapter", // 接任意 MCP server(数据库/BI/内部数据服务)
|
|
@@ -871,7 +884,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
871
884
|
const core = makeCore(baseDir);
|
|
872
885
|
|
|
873
886
|
/**
|
|
874
|
-
*
|
|
887
|
+
* 状态栏常驻场景徽标(<icon> <场景名>):切换后用户始终知道自己在哪个场景。
|
|
888
|
+
* 前缀可由 scenes.json 每场景 icon 字段定制(建议 emoji),缺省 ◆。
|
|
875
889
|
* 设计动机:场景切换器在界面上只弹一次 notify 就消失了,用户无从得知当前场景;
|
|
876
890
|
* 而场景附带的工具型扩展(如 pi-lens)的状态栏内脏反而在抢占视觉 ——
|
|
877
891
|
* 状态栏应该回答“我在哪”,而不是“工具的内部状态”。
|
|
@@ -883,7 +897,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
883
897
|
if (!ui || typeof ui.setStatus !== "function") return;
|
|
884
898
|
const active = core.loadState().active;
|
|
885
899
|
if (active) {
|
|
886
|
-
const
|
|
900
|
+
const icon = core.loadScenes().scenes?.[active]?.icon?.trim() || "◆";
|
|
901
|
+
const text = `${icon} ${active}`;
|
|
887
902
|
ui.setStatus("pi-scene", ui.theme?.fg ? ui.theme.fg("accent", text) : text);
|
|
888
903
|
} else {
|
|
889
904
|
ui.setStatus("pi-scene", undefined);
|
|
@@ -968,9 +983,53 @@ export default function (pi: ExtensionAPI) {
|
|
|
968
983
|
return;
|
|
969
984
|
}
|
|
970
985
|
|
|
971
|
-
|
|
986
|
+
/**
|
|
987
|
+
* 参数 Tab 补全(pi 原生 getArgumentCompletions):
|
|
988
|
+
* - 空前缀:列出全部场景(label 带 icon,description 带描述与「当前」标记)+ 全部子命令
|
|
989
|
+
* - 前缀过滤(大小写不敏感,value 整体替换参数文本):/scene c<Tab> → /scene coding
|
|
990
|
+
* - 多词子命令:/scene evolve a<Tab> → /scene evolve auto
|
|
991
|
+
* - 无匹配返回 null(pi 停用补全弹窗,不打断输入)
|
|
992
|
+
*/
|
|
993
|
+
function sceneCompletions(prefix: string): Array<{ value: string; label: string; description?: string }> | null {
|
|
994
|
+
const p = (prefix ?? "").trim().toLowerCase();
|
|
995
|
+
let cfg: ScenesFile = {};
|
|
996
|
+
let active: string | null = null;
|
|
997
|
+
try {
|
|
998
|
+
cfg = core.loadScenes();
|
|
999
|
+
active = core.loadState().active;
|
|
1000
|
+
} catch {}
|
|
1001
|
+
const items: Array<{ value: string; label: string; description?: string }> = [];
|
|
1002
|
+
for (const [name, def] of Object.entries(cfg.scenes ?? {})) {
|
|
1003
|
+
const icon = def?.icon?.trim() || "◆";
|
|
1004
|
+
const desc = def?.description ? (active === name ? `当前 · ${def.description}` : def.description) : active === name ? "当前场景" : undefined;
|
|
1005
|
+
items.push({ value: name, label: `${icon} ${name}`, description: desc });
|
|
1006
|
+
}
|
|
1007
|
+
const subs: Array<[string, string]> = [
|
|
1008
|
+
["off", "仅保留通用层(关闭场景)"],
|
|
1009
|
+
["status", "查看当前场景与生效资源"],
|
|
1010
|
+
["init", "生成模板 scenes.json 与 skill 骨架"],
|
|
1011
|
+
["stats", "用量仪表盘(会话/工具调用/反思)"],
|
|
1012
|
+
["evolve", "生成并应用进化提案"],
|
|
1013
|
+
["evolve auto", "开关:会话结束自动应用进化"],
|
|
1014
|
+
];
|
|
1015
|
+
for (const [value, description] of subs) items.push({ value, label: value, description });
|
|
1016
|
+
const filtered = items.filter((i) => i.value.toLowerCase().startsWith(p));
|
|
1017
|
+
return filtered.length > 0 ? filtered : null;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/** 命令提示行(palette 一行可见):动态拼入当前场景名清单,注册时求值 */
|
|
1021
|
+
function sceneCommandDescription(): string {
|
|
1022
|
+
let names: string[] = [];
|
|
1023
|
+
try {
|
|
1024
|
+
names = Object.keys(core.loadScenes().scenes ?? {});
|
|
1025
|
+
} catch {}
|
|
1026
|
+
return `切换场景(空格后 Tab 列出并补全):${names.join("/") || "<name>"}`;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
const sceneCommand = {
|
|
972
1030
|
title: "场景切换",
|
|
973
|
-
description:
|
|
1031
|
+
description: sceneCommandDescription(),
|
|
1032
|
+
getArgumentCompletions: sceneCompletions,
|
|
974
1033
|
handler: async (args: string, ctx: any) => {
|
|
975
1034
|
const arg = (args ?? "").trim();
|
|
976
1035
|
|
|
@@ -1003,7 +1062,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1003
1062
|
const target = core.computeTarget(st.active, cfg);
|
|
1004
1063
|
const collisions = core.findSpecCollisions(cfg);
|
|
1005
1064
|
const lines = [
|
|
1006
|
-
`当前场景:${st.active ? st.active : "(无,仅通用层)"}`,
|
|
1065
|
+
`当前场景:${st.active ? `${cfg.scenes?.[st.active]?.icon?.trim() || "◆"} ${st.active}` : "(无,仅通用层)"}`,
|
|
1007
1066
|
`生效 packages(${target.packages.length}):${target.packages.map(specOf).join(", ") || "—"}`,
|
|
1008
1067
|
`生效 skills(${target.skills.length}):${target.skills.join(", ") || "—"}`,
|
|
1009
1068
|
`可用场景:${Object.keys(cfg.scenes ?? {}).join(", ") || "—"}`,
|
|
@@ -1056,10 +1115,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
1056
1115
|
ctx.ui.notify(`scenes.json 里还没有定义场景,编辑 ${core.paths.scenesFile}`, "info");
|
|
1057
1116
|
return;
|
|
1058
1117
|
}
|
|
1118
|
+
// 选择器条目同步显示场景 icon(label→name 映射解析,免字符串切片)
|
|
1119
|
+
const labelToName = new Map<string, string>();
|
|
1059
1120
|
const items: string[] = names.map((n) => {
|
|
1060
1121
|
const d = cfg.scenes![n]?.description ?? "";
|
|
1122
|
+
const icon = cfg.scenes![n]?.icon?.trim() || "◆";
|
|
1061
1123
|
const cur = st.active === n ? "●" : "○";
|
|
1062
|
-
|
|
1124
|
+
const label = `${cur} ${icon} ${n}${d ? ` · ${d}` : ""}${st.active === n ? " [当前]" : ""}`;
|
|
1125
|
+
labelToName.set(label, n);
|
|
1126
|
+
return label;
|
|
1063
1127
|
});
|
|
1064
1128
|
const extra = [PICKER_OFF + (st.active === null ? " [当前]" : ""), PICKER_CANCEL];
|
|
1065
1129
|
const choice = await ctx.ui.select(`切换场景(通用层恒生效)`, [...items, ...extra]);
|
|
@@ -1072,15 +1136,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
1072
1136
|
await doSwitch(ctx, null);
|
|
1073
1137
|
return;
|
|
1074
1138
|
}
|
|
1075
|
-
//
|
|
1076
|
-
const name =
|
|
1139
|
+
// label → 场景名(含 icon/描述的完整条目作为 key,避免解析歧义)
|
|
1140
|
+
const name = labelToName.get(choice);
|
|
1141
|
+
if (!name) return;
|
|
1077
1142
|
if (st.active === name) {
|
|
1078
1143
|
ctx.ui.notify(`当前已在场景「${name}」`, "info");
|
|
1079
1144
|
return;
|
|
1080
1145
|
}
|
|
1081
1146
|
await doSwitch(ctx, name);
|
|
1082
1147
|
},
|
|
1083
|
-
}
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
// 主命令 + 复数别名:/scenes 与 /scene 完全同义(用户肌肉记忆常多打一个 s)
|
|
1151
|
+
pi.registerCommand("scene", sceneCommand);
|
|
1152
|
+
pi.registerCommand("scenes", sceneCommand);
|
|
1084
1153
|
|
|
1085
1154
|
// ── v0.2:用量采集与自进化 ──────────────────────────────
|
|
1086
1155
|
|