@pi-unipi/info-screen 0.1.22 → 2.0.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/core-groups.ts +3 -2
- package/index.ts +10 -9
- package/package.json +1 -1
- package/registry.ts +3 -4
package/core-groups.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { readFileSync, readdirSync, existsSync, statSync } from "node:fs";
|
|
9
9
|
import { join, basename } from "node:path";
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
11
12
|
import { infoRegistry } from "./registry.js";
|
|
12
13
|
import { parseUsageStats, formatTokens, formatCost } from "./usage-parser.js";
|
|
13
14
|
import type { InfoGroup } from "./types.js";
|
|
@@ -309,12 +310,12 @@ const registeredTools: Array<{ name: string; source: string }> = [];
|
|
|
309
310
|
/**
|
|
310
311
|
* Reference to pi API for getting tools.
|
|
311
312
|
*/
|
|
312
|
-
let piApi:
|
|
313
|
+
let piApi: ExtensionAPI | null = null;
|
|
313
314
|
|
|
314
315
|
/**
|
|
315
316
|
* Set the pi API reference.
|
|
316
317
|
*/
|
|
317
|
-
export function setPiApi(api:
|
|
318
|
+
export function setPiApi(api: ExtensionAPI): void {
|
|
318
319
|
piApi = api;
|
|
319
320
|
}
|
|
320
321
|
|
package/index.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* /unipi:info-settings - Configure info display
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
13
|
-
import { UNIPI_EVENTS, MODULES, UNIPI_PREFIX, emitEvent, getPackageVersion } from "@pi-unipi/core";
|
|
12
|
+
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
|
13
|
+
import { UNIPI_EVENTS, MODULES, UNIPI_PREFIX, emitEvent, getPackageVersion, type UnipiModuleEvent, type UnipiInfoGroupEvent } from "@pi-unipi/core";
|
|
14
14
|
import { infoRegistry } from "./registry.js";
|
|
15
15
|
import { registerCoreGroups, trackModule, trackTool, setPiApi, registerSkillDir, startLoadTracking, recordLoadTime, finishLoadTracking, recordModuleStart } from "./core-groups.js";
|
|
16
16
|
|
|
@@ -69,7 +69,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// Listen for module announcements — track and trigger reactive updates
|
|
72
|
-
pi.events.on(UNIPI_EVENTS.MODULE_READY, (
|
|
72
|
+
pi.events.on(UNIPI_EVENTS.MODULE_READY, (data) => {
|
|
73
|
+
const event = data as UnipiModuleEvent;
|
|
73
74
|
if (event.name && event.name !== MODULES.INFO_SCREEN) {
|
|
74
75
|
moduleReadyBatch.push({
|
|
75
76
|
name: event.name,
|
|
@@ -84,7 +85,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
|
|
87
|
-
pi.events.on(UNIPI_EVENTS.INFO_GROUP_REGISTERED, (
|
|
88
|
+
pi.events.on(UNIPI_EVENTS.INFO_GROUP_REGISTERED, (_data) => {
|
|
88
89
|
// Group already registered via globalThis in registerGroup()
|
|
89
90
|
});
|
|
90
91
|
|
|
@@ -104,9 +105,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
104
105
|
* Cache-first: opens with whatever data is cached (even empty).
|
|
105
106
|
* Background: each group fetches independently, overlay re-renders reactively.
|
|
106
107
|
*/
|
|
107
|
-
function showOverlay(ctx:
|
|
108
|
-
ctx.ui.custom(
|
|
109
|
-
(tui
|
|
108
|
+
function showOverlay(ctx: ExtensionContext): void {
|
|
109
|
+
ctx.ui.custom<void>(
|
|
110
|
+
(tui, theme, _keybindings, done) => {
|
|
110
111
|
const overlay = new InfoOverlay();
|
|
111
112
|
overlay.setTheme(theme);
|
|
112
113
|
overlay.onClose = () => {
|
|
@@ -126,9 +127,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
126
127
|
{
|
|
127
128
|
overlay: true,
|
|
128
129
|
overlayOptions: {
|
|
129
|
-
width: "80%",
|
|
130
|
+
width: "80%" as const,
|
|
130
131
|
minWidth: 60,
|
|
131
|
-
anchor: "center",
|
|
132
|
+
anchor: "center" as const,
|
|
132
133
|
margin: 2,
|
|
133
134
|
},
|
|
134
135
|
}
|
package/package.json
CHANGED
package/registry.ts
CHANGED
|
@@ -263,10 +263,9 @@ class InfoRegistry {
|
|
|
263
263
|
export const infoRegistry = new InfoRegistry();
|
|
264
264
|
|
|
265
265
|
// Expose globally so other modules can access without direct imports
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
globalObj.__unipi_info_registry = infoRegistry;
|
|
266
|
+
if (!globalThis.__unipi_info_registry) {
|
|
267
|
+
globalThis.__unipi_info_registry = infoRegistry;
|
|
269
268
|
}
|
|
270
269
|
export const getGlobalRegistry = (): InfoRegistry => {
|
|
271
|
-
return
|
|
270
|
+
return (globalThis.__unipi_info_registry as InfoRegistry | undefined) ?? infoRegistry;
|
|
272
271
|
};
|