pi-lean-search 0.3.0 → 0.3.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/index.ts +14 -14
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Registers the `web-search` tool and a `/searxng-status` diagnostic command.
|
|
5
5
|
* Manages the `search` status bar slot with health-colored glyphs.
|
|
6
6
|
*
|
|
7
|
-
* Owns the `search
|
|
7
|
+
* Owns the `pi-lean-dimension.search` toolset (co-activated off `pi-lean-dimension.web`):
|
|
8
8
|
* ● searxng (accent/blue) — healthy and reachable
|
|
9
9
|
* ● searxng (warning/yellow) — server up but pipeline degraded
|
|
10
10
|
* ● searxng (error/red) — unreachable
|
|
@@ -24,9 +24,9 @@ import { webSearchTool } from "./web-search-tool.js";
|
|
|
24
24
|
// ─── Toolset spec ────────────────────────────────────────────────
|
|
25
25
|
|
|
26
26
|
const SEARCH_WEB_SPEC: ToolsetSpec = {
|
|
27
|
-
id: "search
|
|
27
|
+
id: "pi-lean-dimension.search",
|
|
28
28
|
names: new Set(["web-search"]),
|
|
29
|
-
persistKey: "toolset-state:search
|
|
29
|
+
persistKey: "toolset-state:pi-lean-dimension.search",
|
|
30
30
|
defaultEnabled: true,
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -35,7 +35,7 @@ const SEARCH_WEB_SPEC: ToolsetSpec = {
|
|
|
35
35
|
/** Cached SearXNG URL (read once at startup, stable mid-session). */
|
|
36
36
|
let _searxngUrl: string | undefined;
|
|
37
37
|
|
|
38
|
-
/** Last known search
|
|
38
|
+
/** Last known pi-lean-dimension.search enabled state (updated by library events). */
|
|
39
39
|
let _lastSearchEnabled = true;
|
|
40
40
|
|
|
41
41
|
/** Last known health state: true=healthy, false=unreachable, null=unconfigured. */
|
|
@@ -128,10 +128,10 @@ function displayUrl(url: string): string {
|
|
|
128
128
|
/**
|
|
129
129
|
* Render the `search` status slot based on toolset state + health.
|
|
130
130
|
*
|
|
131
|
-
* search
|
|
132
|
-
* search
|
|
133
|
-
* search
|
|
134
|
-
* search
|
|
131
|
+
* pi-lean-dimension.search off → ○ searxng
|
|
132
|
+
* pi-lean-dimension.search on + healthy → ● searxng (accent/blue)
|
|
133
|
+
* pi-lean-dimension.search on + degraded → ● searxng (warning/yellow)
|
|
134
|
+
* pi-lean-dimension.search on + unreachable → ● searxng (error/red)
|
|
135
135
|
* unconfigured → (clear slot)
|
|
136
136
|
*/
|
|
137
137
|
function renderSearchGlyph(ctx: {
|
|
@@ -154,13 +154,13 @@ function renderSearchGlyph(ctx: {
|
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
// search
|
|
157
|
+
// pi-lean-dimension.search disabled — show off state
|
|
158
158
|
if (!_lastSearchEnabled) {
|
|
159
159
|
safeSetStatus("○ searxng");
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
// search
|
|
163
|
+
// pi-lean-dimension.search enabled — show health-colored glyph
|
|
164
164
|
if (!_lastHealth) {
|
|
165
165
|
safeSetStatus(ctx.ui.theme.fg("error", "●") + " searxng");
|
|
166
166
|
return;
|
|
@@ -193,15 +193,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
193
193
|
// ── Register the web-search tool ─────────────────────────
|
|
194
194
|
pi.registerTool(webSearchTool);
|
|
195
195
|
|
|
196
|
-
// ── Define the search
|
|
196
|
+
// ── Define the pi-lean-dimension.search toolset ───────────
|
|
197
197
|
// Registers restore handler on session_start / session_tree.
|
|
198
198
|
const searchToolset = defineToolset(pi, SEARCH_WEB_SPEC);
|
|
199
199
|
|
|
200
|
-
// ── Co-activation: mirror
|
|
200
|
+
// ── Co-activation: mirror pi-lean-dimension.web changed events ─
|
|
201
201
|
// Listen on changed ONLY, not restored (§10.1).
|
|
202
202
|
pi.events.on(TOOLSET_EVENTS.changed, (data: unknown) => {
|
|
203
203
|
const event = data as ToolsetChangedEvent;
|
|
204
|
-
if (event.id === "
|
|
204
|
+
if (event.id === "pi-lean-dimension.web") {
|
|
205
205
|
if (event.enabled) {
|
|
206
206
|
searchToolset.enable(pi);
|
|
207
207
|
} else {
|
|
@@ -213,7 +213,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
213
213
|
// ── Keep cached state in sync with library events ────────
|
|
214
214
|
const syncSearchState = (data: unknown) => {
|
|
215
215
|
const event = data as ToolsetChangedEvent;
|
|
216
|
-
if (event.id === "search
|
|
216
|
+
if (event.id === "pi-lean-dimension.search") {
|
|
217
217
|
_lastSearchEnabled = event.enabled;
|
|
218
218
|
if (_lastCtx) renderSearchGlyph(_lastCtx);
|
|
219
219
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-lean-search",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Pi extension. SearXNG search tool for Pi — pairs with pi-lean-portal's /web toggle; search-only installs are valid, or add it to a portal install for the full web-tools suite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|