pi-lean-dimension 0.3.3 → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-tool-masking",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Core library for grouping pi tools into toggleable toolsets with persistent state and cross-extension events.",
@@ -21,7 +21,6 @@
21
21
  "version:minor": "npm version minor --no-git-tag-version",
22
22
  "version:major": "npm version major --no-git-tag-version",
23
23
  "prepublishOnly": "npm test && npx tsc --noEmit",
24
- "publish": "npm publish --access public",
25
24
  "publish:dry": "npm publish --access public --dry-run",
26
25
  "release:patch": "node scripts/release.mjs patch",
27
26
  "release:minor": "node scripts/release.mjs minor",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-lean-dimension",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Pi extension. The full Pi web-tools suite in one install — interactive browsing (pi-lean-portal) plus SearXNG search (pi-lean-search), unified under a /web toggle that removes the tools from context when switched off.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -32,8 +32,8 @@
32
32
  ]
33
33
  },
34
34
  "dependencies": {
35
- "pi-lean-portal": "^0.3.3",
36
- "pi-lean-search": "^0.3.3"
35
+ "pi-lean-portal": "^0.4.0",
36
+ "pi-lean-search": "^0.4.0"
37
37
  },
38
38
  "bundledDependencies": [
39
39
  "pi-lean-portal",
@@ -1,145 +0,0 @@
1
- /**
2
- * Migration-warning test for the legacy `browserToggle.defaultEnabled`
3
- * settings key. Isolated from the main browser-toggle suite so the
4
- * settings-reader mock doesn't touch the other tests.
5
- */
6
-
7
- import { describe, it, expect, vi, beforeEach } from "vitest";
8
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
9
-
10
- // Hoisted mock: the SUT reads `readMergedSettings` at init time.
11
- vi.mock("../core/shared/settings-reader.js", () => ({
12
- readMergedSettings: vi.fn(() => ({})),
13
- }));
14
-
15
- import browserToggle, { _resetToggleStateForTest } from "../browser-toggle.js";
16
- import { readMergedSettings } from "../core/shared/settings-reader.js";
17
-
18
- beforeEach(() => {
19
- _resetToggleStateForTest();
20
- vi.mocked(readMergedSettings).mockReturnValue({});
21
- const REGISTRY_KEY = "__piToolMaskingRegistry";
22
- const RESTORE_EVENT_KEY = "__piToolMaskingLastRestoreEvent";
23
- const MODULE_STATE_KEY = "__piToolMaskingModuleState";
24
- delete (globalThis as any)[REGISTRY_KEY];
25
- delete (globalThis as any)[RESTORE_EVENT_KEY];
26
- delete (globalThis as any)[MODULE_STATE_KEY];
27
- });
28
-
29
- const ALL_TOOLS = [
30
- { name: "web-fetch", description: "fetch" },
31
- { name: "browser-navigate", description: "navigate" },
32
- { name: "browser-snapshot", description: "snapshot" },
33
- { name: "browser-click", description: "click" },
34
- { name: "browser-type", description: "type" },
35
- { name: "browser-scroll", description: "scroll" },
36
- { name: "browser-back", description: "back" },
37
- { name: "browser-press", description: "press" },
38
- { name: "browser-console", description: "console" },
39
- { name: "browser-inspect", description: "inspect" },
40
- { name: "web-guide", description: "guide" },
41
- { name: "web-learn", description: "learn" },
42
- { name: "read", description: "read" },
43
- { name: "bash", description: "shell" },
44
- ];
45
-
46
- function mockPi(): {
47
- pi: ExtensionAPI;
48
- handlers: Map<string, Array<(...args: any[]) => void>>;
49
- } {
50
- const handlers = new Map<string, Array<(...args: any[]) => void>>();
51
- const pi = {
52
- getAllTools: vi.fn(() => ALL_TOOLS as any),
53
- getActiveTools: vi.fn(() => ALL_TOOLS.map((t) => t.name)),
54
- setActiveTools: vi.fn(),
55
- appendEntry: vi.fn(),
56
- registerCommand: vi.fn(),
57
- registerTool: vi.fn(),
58
- on: vi.fn(<T>(event: string, handler: (event: T, ctx: any) => void) => {
59
- if (!handlers.has(event)) handlers.set(event, []);
60
- handlers.get(event)!.push(handler as any);
61
- }),
62
- get events() {
63
- return {
64
- emit: () => {},
65
- on: () => () => {},
66
- };
67
- },
68
- } as unknown as ExtensionAPI;
69
- return { pi, handlers };
70
- }
71
-
72
- function mockCtx(): any {
73
- return {
74
- sessionManager: { getBranch: () => [] },
75
- ui: {
76
- setStatus: vi.fn(),
77
- theme: { fg: (_c: string, t: string) => t },
78
- notify: vi.fn(),
79
- },
80
- mode: "tui",
81
- cwd: "/mock",
82
- hasUI: true,
83
- isIdle: () => true,
84
- modelRegistry: {} as any,
85
- };
86
- }
87
-
88
- describe("legacy browserToggle.defaultEnabled migration warning", () => {
89
- it("warns on session_start when the legacy key is pinned", async () => {
90
- vi.mocked(readMergedSettings).mockReturnValue({
91
- browserToggle: { defaultEnabled: false },
92
- });
93
- const { pi, handlers } = mockPi();
94
- browserToggle(pi);
95
-
96
- const ctx = mockCtx();
97
- for (const h of handlers.get("session_start") ?? []) {
98
- await h({}, ctx);
99
- }
100
-
101
- expect(ctx.ui.notify).toHaveBeenCalledWith(
102
- expect.stringContaining("toolsetDefaults"),
103
- "warning",
104
- );
105
- const msg = (ctx.ui.notify as any).mock.calls[0][0] as string;
106
- expect(msg).toContain("toolset-state:pi-lean-dimension.web");
107
- expect(msg).toContain("toolset-state:pi-lean-dimension.web-learn");
108
- // The warning must make clear the legacy key still works today and the
109
- // new block is not read yet — otherwise users drop the working key.
110
- expect(msg).toContain("KEEP");
111
- expect(msg).toContain("not read yet");
112
- expect(msg).toContain("browserToggle");
113
- });
114
-
115
- it("stays silent when no legacy key is present", async () => {
116
- vi.mocked(readMergedSettings).mockReturnValue({});
117
- const { pi, handlers } = mockPi();
118
- browserToggle(pi);
119
-
120
- const ctx = mockCtx();
121
- for (const h of handlers.get("session_start") ?? []) {
122
- await h({}, ctx);
123
- }
124
-
125
- expect(ctx.ui.notify).not.toHaveBeenCalled();
126
- });
127
-
128
- it("suppresses the warning once the web default is migrated to toolsetDefaults", async () => {
129
- vi.mocked(readMergedSettings).mockReturnValue({
130
- browserToggle: { defaultEnabled: false },
131
- toolsetDefaults: {
132
- "toolset-state:pi-lean-dimension.web": { enabled: false },
133
- },
134
- });
135
- const { pi, handlers } = mockPi();
136
- browserToggle(pi);
137
-
138
- const ctx = mockCtx();
139
- for (const h of handlers.get("session_start") ?? []) {
140
- await h({}, ctx);
141
- }
142
-
143
- expect(ctx.ui.notify).not.toHaveBeenCalled();
144
- });
145
- });