pi-scenes 0.4.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 CHANGED
@@ -21,6 +21,7 @@ active resources = common layer ∪ current scene
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
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
24
25
  - The data model reserves an `extends` chain (with cycle detection) for future **parent → child scene** hierarchies
25
26
 
26
27
  ## Install
@@ -41,6 +42,8 @@ Then `/reload` and `/scene` is live.
41
42
 
42
43
  ```
43
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
44
47
  /scene coding # switch directly to the coding scene
45
48
  /scene office # switch to the office scene
46
49
  /scene off # common layer only (scene off)
@@ -49,6 +52,7 @@ Then `/reload` and `/scene` is live.
49
52
  /scene stats # usage dashboard: sessions, tool calls, reflections
50
53
  /scene evolve # generate & apply evolution proposals (confirm-first)
51
54
  /scene evolve auto # toggle auto-apply at session end (opt-in)
55
+ /scenes ... # plural alias — same command, same completions
52
56
  ```
53
57
 
54
58
  First run of `/scene` offers to generate the template. It ships with **seven preset scenes + common** (all packages verified on npm, 2026-09):
@@ -221,6 +225,7 @@ pi 的 `packages` / `skills` 是全局平铺的:所有已安装扩展、所有
221
225
  - **场景层**:每个场景自己的一组 extension + skill,激活才加载
222
226
  - 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**
223
227
  - 每次切换成功后状态栏常驻**场景徽标**(`◆ coding`,或每场景自定义 `icon` 如 `💻 coding`),状态栏随时回答「我现在在哪个场景」——会话启动自动恢复,`/scene off` 清除
228
+ - **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene coding`;`/scenes` 复数别名同义可用
224
229
  - 数据模型预留 `extends` 继承链(带环检测),为将来「主场景 → 子场景」层级铺路
225
230
 
226
231
  ## 安装
@@ -241,6 +246,8 @@ pi install git:github.com/Feng-H/pi-scenes
241
246
 
242
247
  ```
243
248
  /scene # 弹出选择器:列出所有场景,● 当前,○ 可切
249
+ /scene <Tab> # Tab 补全:列出全部场景(icon + 描述)与子命令
250
+ /scene c<Tab> # 补齐为 /scene coding —— 无需记忆任何场景名
244
251
  /scene coding # 直接切到 coding 场景
245
252
  /scene office # 切到办公场景
246
253
  /scene off # 仅保留通用层(关闭场景)
@@ -249,6 +256,7 @@ pi install git:github.com/Feng-H/pi-scenes
249
256
  /scene stats # 用量仪表盘:会话数 / 工具调用 / 反思评分
250
257
  /scene evolve # 生成并应用进化提案(逐条确认)
251
258
  /scene evolve auto # 开关:会话结束自动应用(opt-in)
259
+ /scenes ... # 复数别名:与 /scene 完全同义,补全行为一致
252
260
  ```
253
261
 
254
262
  首次运行 `/scene` 会询问是否生成模板,生成后编辑场景定义。模板内置 **七个预设场景 + 通用层**(包均在 npm 核验存在,2026-09):
@@ -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 有用性
@@ -978,9 +983,53 @@ export default function (pi: ExtensionAPI) {
978
983
  return;
979
984
  }
980
985
 
981
- pi.registerCommand("scene", {
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 = {
982
1030
  title: "场景切换",
983
- description: "通用层+场景 一键切换 extension/skill(/scene、/scene <name>、/scene off、/scene status、/scene init、/scene stats、/scene evolve)",
1031
+ description: sceneCommandDescription(),
1032
+ getArgumentCompletions: sceneCompletions,
984
1033
  handler: async (args: string, ctx: any) => {
985
1034
  const arg = (args ?? "").trim();
986
1035
 
@@ -1096,7 +1145,11 @@ export default function (pi: ExtensionAPI) {
1096
1145
  }
1097
1146
  await doSwitch(ctx, name);
1098
1147
  },
1099
- });
1148
+ };
1149
+
1150
+ // 主命令 + 复数别名:/scenes 与 /scene 完全同义(用户肌肉记忆常多打一个 s)
1151
+ pi.registerCommand("scene", sceneCommand);
1152
+ pi.registerCommand("scenes", sceneCommand);
1100
1153
 
1101
1154
  // ── v0.2:用量采集与自进化 ──────────────────────────────
1102
1155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-scenes",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "pi 扩展:场景切换器 + 资源自进化。通用层+分场景层打包 extension/skill,/scene 热切换;按实际用量(工具调用归因 + 会话结束 LLM 反思)生成吸收/淘汰提案,让场景定义随使用习惯进化。",
5
5
  "keywords": [
6
6
  "pi-package"