pi-scenes 0.2.1 → 0.2.2

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
@@ -128,6 +128,7 @@ In short: **installed forever, loaded per scene**. One caveat: extensions you in
128
128
  - Same spec in `common` and a scene → deduplicated at the union (loaded once).
129
129
  - Same package, different spellings (e.g. `npm:x@1.0.3` vs bare `npm:x`) → identity-level dedupe keeps the first (common > scene); a manually pinned variant in settings is treated as `borrowed` (no duplicate injection). `/scene` and `/scene status` warn about such spelling mismatches so you can unify them.
130
130
  - **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.
131
+ - **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`).
131
132
 
132
133
  ## How it works
133
134
 
@@ -170,7 +171,7 @@ Before uninstalling, `/scene off` and prune entries you don't want to keep from
170
171
 
171
172
  ```bash
172
173
  git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
173
- npm test # node:test, 16 cases: injection/reclaim + usage/evolution + conflict guards (no TUI needed)
174
+ npm test # node:test, 18 cases: injection/reclaim + usage/evolution + conflict guards + command-layer smoke (no TUI needed)
174
175
  ```
175
176
 
176
177
  Tests isolate via the `PI_SCENES_DIR` env var — your real `~/.pi/agent` is never touched.
@@ -309,6 +310,7 @@ pi install git:github.com/Feng-H/pi-scenes
309
310
  - 同一写法在 common 与场景重复 → 并集时去重,只加载一次。
310
311
  - 同包异写法(如 `npm:x@1.0.3` 与裸名 `npm:x`)→ 身份级去重取首个(common 优先);settings 里手动 pin 的异写法条目视为 `borrowed`,不重复注入。`/scene` 切换与 `/scene status` 会对异写法发出提醒,建议统一。
311
312
  - **本地路径与 npm 写法并存(v0.2.1):** 若 settings 已通过本地路径加载某包(如你的开发目录 `/Users/you/dev/pi-carryover`),场景预设里的 `npm:pi-carryover` 会*借用*你的条目而不安装——跳过 `pi install`,绝不向 settings 追加第二种写法。这一点很关键:同一包双写法 = 同一扩展被加载两份 = pi 启动时工具重名冲突退出。若 settings 已陷入该状态(如手动 `pi install` 造成的重复),`/scene` 会拒绝切换并明确告知需要删除哪个条目。
313
+ - **热修(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`)。
312
314
 
313
315
  ## 工作原理
314
316
 
@@ -351,7 +353,7 @@ managed 注入的条目在卸载前建议先 `/scene off` + 手工清理 `packag
351
353
 
352
354
  ```bash
353
355
  git clone https://github.com/Feng-H/pi-scenes && cd pi-scenes
354
- npm test # node:test,16 用例:注入/回收 + 用量/进化 + 异写法冲突防护(无需 TUI)
356
+ npm test # node:test,18 用例:注入/回收 + 用量/进化 + 异写法冲突防护 + command 层冒烟(无需 TUI)
355
357
  ```
356
358
 
357
359
  测试用 `PI_SCENES_DIR` 环境变量隔离基目录,不碰真实 `~/.pi/agent`。
@@ -910,7 +910,7 @@ export default function (pi: ExtensionAPI) {
910
910
  // 缺失包:确认后逐个 pi install(全局 scope pi 不自动装,必须显式装)
911
911
  // 身份级判定:settings 已手配同包异写法(如本地路径)→ 视为可用,跳过安装;
912
912
  // 否则 pi install 会向 settings 追加第二种写法 → 同一扩展加载两份 → pi 启动冲突退出
913
- const missing = core.findMissingPackages(target, prePkgs);
913
+ const missing = core.findMissingPackages(target.packages, prePkgs);
914
914
  let preInstallPackages: PackageEntry[] | undefined;
915
915
  if (missing.length > 0) {
916
916
  const ok = await ctx.ui.confirm(
@@ -930,7 +930,7 @@ export default function (pi: ExtensionAPI) {
930
930
  }
931
931
  }
932
932
  const postPkgs = (readJson<Record<string, unknown>>(core.paths.settingsFile, {}).packages ?? []) as PackageEntry[];
933
- const still = core.findMissingPackages(target, postPkgs);
933
+ const still = core.findMissingPackages(target.packages, postPkgs);
934
934
  if (still.length > 0) {
935
935
  ctx.ui.notify(`仍有包未安装:${still.map(specOf).join(", ")},已中止切换`, "error");
936
936
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-scenes",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "pi 扩展:场景切换器 + 资源自进化。通用层+分场景层打包 extension/skill,/scene 热切换;按实际用量(工具调用归因 + 会话结束 LLM 反思)生成吸收/淘汰提案,让场景定义随使用习惯进化。",
5
5
  "keywords": [
6
6
  "pi-package"