@pi-unipi/utility 0.2.9 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/utility",
3
- "version": "0.2.9",
3
+ "version": "2.0.0",
4
4
  "description": "Utility commands and tools for Pi coding agent — lifecycle, diagnostics, cache, analytics, display, batch execution",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/commands.ts CHANGED
@@ -109,7 +109,7 @@ export function registerNameBadgeCommands(
109
109
 
110
110
  // Redirect to unified settings
111
111
  ctx.ui.custom(
112
- (tui: any, _theme: any, _keybindings: any, done: any) => {
112
+ (tui, _theme, _keybindings, done) => {
113
113
  const overlay = new UtilSettingsTui();
114
114
  overlay.onClose = () => done(undefined);
115
115
  overlay.requestRender = () => tui.requestRender();
@@ -145,7 +145,7 @@ export function registerNameBadgeCommands(
145
145
  }
146
146
 
147
147
  ctx.ui.custom(
148
- (tui: any, _theme: any, _keybindings: any, done: any) => {
148
+ (tui, _theme, _keybindings, done) => {
149
149
  const overlay = new UtilSettingsTui();
150
150
  overlay.onClose = () => done(undefined);
151
151
  overlay.requestRender = () => tui.requestRender();
@@ -249,7 +249,7 @@ export function normalizeShikiContrast(
249
249
  // ─── Shiki Highlighter ──────────────────────────────────────────────────────────
250
250
 
251
251
  /** Shiki highlighter instance (lazy singleton) */
252
- let shikiHighlighter: any = null;
252
+ let shikiHighlighter: import("shiki").Highlighter | null = null;
253
253
  let shikiInitPromise: Promise<any> | null = null;
254
254
 
255
255
  /**
package/src/diff/theme.ts CHANGED
File without changes
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * - TUI: settings inspector pattern, name badge
13
13
  */
14
14
 
15
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
15
+ import type { ExtensionAPI, InputEvent, AgentEndEvent } from "@mariozechner/pi-coding-agent";
16
16
  import {
17
17
  UNIPI_EVENTS,
18
18
  MODULES,
@@ -44,7 +44,7 @@ let firstMessageSeen = false;
44
44
  let firstUserText = "";
45
45
 
46
46
  /** Stored UI context from first input, used to show badge overlay after agent responds */
47
- let firstInputCtx: any = null;
47
+ let firstInputCtx: import("@mariozechner/pi-coding-agent").ExtensionContext | null = null;
48
48
 
49
49
  /** All commands registered by this module */
50
50
  const ALL_COMMANDS = [
@@ -124,7 +124,7 @@ export default function (pi: ExtensionAPI) {
124
124
  });
125
125
 
126
126
  // First-message hook: capture user text for deferred badge generation
127
- pi.on("input", async (_event: any, ctx: any) => {
127
+ pi.on("input", async (_event, ctx) => {
128
128
  // Only trigger on first user message
129
129
  if (firstMessageSeen) return;
130
130
  firstMessageSeen = true;
@@ -138,12 +138,14 @@ export default function (pi: ExtensionAPI) {
138
138
  if (sessionName) return;
139
139
 
140
140
  // Store first message text for later use in agent_end
141
- firstUserText = typeof _event?.content === "string"
142
- ? _event.content
143
- : Array.isArray(_event?.content)
144
- ? _event.content
145
- .filter((c: any) => c.type === "text")
146
- .map((c: any) => c.text)
141
+ // Note: InputEvent.text is the documented property; content may exist at runtime
142
+ const content = (_event as unknown as Record<string, unknown>).content;
143
+ firstUserText = typeof content === "string"
144
+ ? content
145
+ : Array.isArray(content)
146
+ ? (content as Array<Record<string, unknown>>)
147
+ .filter((c) => c.type === "text")
148
+ .map((c) => String(c.text))
147
149
  .join(" ")
148
150
  : "";
149
151
 
@@ -152,7 +154,7 @@ export default function (pi: ExtensionAPI) {
152
154
  });
153
155
 
154
156
  // After agent completes first response, generate badge name with full conversation context
155
- pi.on("agent_end", async (event: any, _ctx: any) => {
157
+ pi.on("agent_end", async (event, _ctx) => {
156
158
  // Only act if we captured a first input and are waiting for badge generation
157
159
  if (!firstInputCtx) return;
158
160
  const ctx = firstInputCtx;
@@ -168,7 +170,7 @@ export default function (pi: ExtensionAPI) {
168
170
  }
169
171
 
170
172
  // Build conversation summary from full message history (user + assistant)
171
- const messages: any[] = event?.messages ?? [];
173
+ const messages = event.messages;
172
174
  const summaryParts: string[] = [];
173
175
 
174
176
  // Include the user's first message
@@ -177,16 +179,17 @@ export default function (pi: ExtensionAPI) {
177
179
  }
178
180
 
179
181
  // Include assistant's response text
180
- const assistantMsgs = messages.filter((m: any) => m.role === "assistant");
182
+ const assistantMsgs = messages.filter((m) => m.role === "assistant");
181
183
  for (const msg of assistantMsgs) {
182
- if (Array.isArray(msg.content)) {
183
- const textParts = msg.content
184
- .filter((c: any) => c.type === "text")
185
- .map((c: any) => c.text)
184
+ const content = msg.content;
185
+ if (Array.isArray(content)) {
186
+ const textParts = content
187
+ .filter((c): c is { type: "text"; text: string } => "text" in c && c.type === "text")
188
+ .map((c) => c.text)
186
189
  .join(" ");
187
190
  if (textParts) summaryParts.push(`Assistant: ${textParts}`);
188
- } else if (typeof msg.content === "string" && msg.content) {
189
- summaryParts.push(`Assistant: ${msg.content}`);
191
+ } else if (typeof content === "string" && content) {
192
+ summaryParts.push(`Assistant: ${content}`);
190
193
  }
191
194
  }
192
195