pi-scenes 0.4.0 → 0.5.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 +6 -0
- package/extensions/scenes.ts +54 -4
- package/package.json +1 -1
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`
|
|
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)
|
|
@@ -221,6 +224,7 @@ pi 的 `packages` / `skills` 是全局平铺的:所有已安装扩展、所有
|
|
|
221
224
|
- **场景层**:每个场景自己的一组 extension + skill,激活才加载
|
|
222
225
|
- 切换 = 改写 `settings.json` 的 `packages`/`skills` → `ctx.reload()` 热重载,**无需重启 pi**
|
|
223
226
|
- 每次切换成功后状态栏常驻**场景徽标**(`◆ coding`,或每场景自定义 `icon` 如 `💻 coding`),状态栏随时回答「我现在在哪个场景」——会话启动自动恢复,`/scene off` 清除
|
|
227
|
+
- **零记忆可发现性(v0.4.1)**——命令提示行直接拼入场景名清单;Tab 补全列出全部场景(icon + 描述 + 当前标记)与子命令:`/scene c` + Tab → `/scene coding`
|
|
224
228
|
- 数据模型预留 `extends` 继承链(带环检测),为将来「主场景 → 子场景」层级铺路
|
|
225
229
|
|
|
226
230
|
## 安装
|
|
@@ -241,6 +245,8 @@ pi install git:github.com/Feng-H/pi-scenes
|
|
|
241
245
|
|
|
242
246
|
```
|
|
243
247
|
/scene # 弹出选择器:列出所有场景,● 当前,○ 可切
|
|
248
|
+
/scene <Tab> # Tab 补全:列出全部场景(icon + 描述)与子命令
|
|
249
|
+
/scene c<Tab> # 补齐为 /scene coding —— 无需记忆任何场景名
|
|
244
250
|
/scene coding # 直接切到 coding 场景
|
|
245
251
|
/scene office # 切到办公场景
|
|
246
252
|
/scene off # 仅保留通用层(关闭场景)
|
package/extensions/scenes.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*
|
|
21
21
|
* 命令:
|
|
22
22
|
* /scene 弹出选择器(当前场景高亮 ●)
|
|
23
|
-
* /scene <name>
|
|
23
|
+
* /scene <name> 切换到指定场景(参数 Tab 补全:/scene c<Tab> → /scene coding)
|
|
24
24
|
* /scene off|none 仅保留通用层(关闭场景)
|
|
25
25
|
* /scene status 显示当前激活与生效资源
|
|
26
26
|
* /scene init 生成模板 scenes.json 与场景 skill 目录骨架
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
* /scene evolve 生成进化提案并逐条确认应用(备份 + 热重载)
|
|
29
29
|
* /scene evolve auto 开关:会话结束自动应用进化(opt-in,不动 common/无工具包)
|
|
30
30
|
*
|
|
31
|
+
* 可发现性(v0.4.1):命令 description 在注册时动态拼入场景名清单;
|
|
32
|
+
* 参数 Tab 补全列出全部场景(icon+描述+当前标记)与子命令 ——
|
|
33
|
+
* 不需要记忆任何场景名,空格后 Tab 即见全表。
|
|
34
|
+
*
|
|
31
35
|
* 自进化(v0.2):
|
|
32
36
|
* 采集:tool_call 归因(静态扫描安装源码建 tool→pkg 表)+
|
|
33
37
|
* settings 未纳管条目观察 + 会话结束 LLM 反思 skill 有用性
|
|
@@ -978,9 +982,53 @@ export default function (pi: ExtensionAPI) {
|
|
|
978
982
|
return;
|
|
979
983
|
}
|
|
980
984
|
|
|
981
|
-
|
|
985
|
+
/**
|
|
986
|
+
* 参数 Tab 补全(pi 原生 getArgumentCompletions):
|
|
987
|
+
* - 空前缀:列出全部场景(label 带 icon,description 带描述与「当前」标记)+ 全部子命令
|
|
988
|
+
* - 前缀过滤(大小写不敏感,value 整体替换参数文本):/scene c<Tab> → /scene coding
|
|
989
|
+
* - 多词子命令:/scene evolve a<Tab> → /scene evolve auto
|
|
990
|
+
* - 无匹配返回 null(pi 停用补全弹窗,不打断输入)
|
|
991
|
+
*/
|
|
992
|
+
function sceneCompletions(prefix: string): Array<{ value: string; label: string; description?: string }> | null {
|
|
993
|
+
const p = (prefix ?? "").trim().toLowerCase();
|
|
994
|
+
let cfg: ScenesFile = {};
|
|
995
|
+
let active: string | null = null;
|
|
996
|
+
try {
|
|
997
|
+
cfg = core.loadScenes();
|
|
998
|
+
active = core.loadState().active;
|
|
999
|
+
} catch {}
|
|
1000
|
+
const items: Array<{ value: string; label: string; description?: string }> = [];
|
|
1001
|
+
for (const [name, def] of Object.entries(cfg.scenes ?? {})) {
|
|
1002
|
+
const icon = def?.icon?.trim() || "◆";
|
|
1003
|
+
const desc = def?.description ? (active === name ? `当前 · ${def.description}` : def.description) : active === name ? "当前场景" : undefined;
|
|
1004
|
+
items.push({ value: name, label: `${icon} ${name}`, description: desc });
|
|
1005
|
+
}
|
|
1006
|
+
const subs: Array<[string, string]> = [
|
|
1007
|
+
["off", "仅保留通用层(关闭场景)"],
|
|
1008
|
+
["status", "查看当前场景与生效资源"],
|
|
1009
|
+
["init", "生成模板 scenes.json 与 skill 骨架"],
|
|
1010
|
+
["stats", "用量仪表盘(会话/工具调用/反思)"],
|
|
1011
|
+
["evolve", "生成并应用进化提案"],
|
|
1012
|
+
["evolve auto", "开关:会话结束自动应用进化"],
|
|
1013
|
+
];
|
|
1014
|
+
for (const [value, description] of subs) items.push({ value, label: value, description });
|
|
1015
|
+
const filtered = items.filter((i) => i.value.toLowerCase().startsWith(p));
|
|
1016
|
+
return filtered.length > 0 ? filtered : null;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/** 命令提示行(palette 一行可见):动态拼入当前场景名清单,注册时求值 */
|
|
1020
|
+
function sceneCommandDescription(): string {
|
|
1021
|
+
let names: string[] = [];
|
|
1022
|
+
try {
|
|
1023
|
+
names = Object.keys(core.loadScenes().scenes ?? {});
|
|
1024
|
+
} catch {}
|
|
1025
|
+
return `切换场景(空格后 Tab 列出并补全):${names.join("/") || "<name>"}`;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
const sceneCommand = {
|
|
982
1029
|
title: "场景切换",
|
|
983
|
-
description:
|
|
1030
|
+
description: sceneCommandDescription(),
|
|
1031
|
+
getArgumentCompletions: sceneCompletions,
|
|
984
1032
|
handler: async (args: string, ctx: any) => {
|
|
985
1033
|
const arg = (args ?? "").trim();
|
|
986
1034
|
|
|
@@ -1096,7 +1144,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
1096
1144
|
}
|
|
1097
1145
|
await doSwitch(ctx, name);
|
|
1098
1146
|
},
|
|
1099
|
-
}
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
pi.registerCommand("scene", sceneCommand);
|
|
1100
1150
|
|
|
1101
1151
|
// ── v0.2:用量采集与自进化 ──────────────────────────────
|
|
1102
1152
|
|