@vtstech/pi-status 1.1.4-dev → 1.1.5

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.
Files changed (3) hide show
  1. package/README.md +4 -4
  2. package/package.json +4 -8
  3. package/status.js +36 -7
package/README.md CHANGED
@@ -18,12 +18,12 @@ CPU/RAM/Swap are only shown when using a local Ollama provider (not for cloud/re
18
18
 
19
19
  **Example (local Ollama):**
20
20
  ```
21
- CtxMax:41k RespMax:16.4k Resp 2m3s CPU 12% RAM 2.2G/15.1G Prompt: 2840 chr 393 tok pi:0.66.1
21
+ CtxMax:41k RespMax:16.4k Resp 2m3s CPU 12% RAM 2.2G/15.1G SEC:MAX Prompt: 2840 chr 393 tok pi:0.66.1
22
22
  ```
23
23
 
24
- **Example (cloud provider):**
24
+ **Example (cloud provider, basic mode):**
25
25
  ```
26
- CtxMax:128k RespMax:16.4k Resp 1m22s Prompt: 2840 chr 393 tok pi:0.66.1
26
+ CtxMax:128k RespMax:16.4k Resp 1m22s SEC:BASIC Prompt: 2840 chr 393 tok pi:0.66.1
27
27
  ```
28
28
 
29
29
  ## Status Slots
@@ -39,7 +39,7 @@ Slots are updated every 5 seconds (1 second for active tool timing). Render orde
39
39
  | **RAM** | Used/total system memory | Local Ollama only |
40
40
  | **Swap** | Used/total swap space | Local only, when active |
41
41
  | **Generation params** | Temperature, top_p, top_k, num_predict, context size, reasoning_effort (dimmed) | After first provider request |
42
- | **SEC** | Session-scoped blocked tool count + 3s flash on block event | When blocks occur |
42
+ | **SEC** | Security mode indicator (`SEC:BASIC`/`SEC:MAX`) + session-scoped blocked count + 3s flash on block event | Always shown |
43
43
  | **Active tool** | Live elapsed timer with `>` indicator | While a tool is running |
44
44
  | **Prompt** | System prompt size as `chars chr tokens tok` | After first agent start |
45
45
  | **Pi version** | `pi:0.66.1` (dimmed, always last) | Always shown |
package/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "@vtstech/pi-status",
3
- "version": "1.1.4-dev",
3
+ "version": "1.1.5",
4
4
  "description": "System monitor / status bar extension for Pi Coding Agent",
5
5
  "main": "status.js",
6
- "keywords": [
7
- "pi-extensions"
8
- ],
6
+ "keywords": ["pi-extensions"],
9
7
  "license": "MIT",
10
8
  "access": "public",
11
9
  "type": "module",
@@ -16,14 +14,12 @@
16
14
  "url": "https://github.com/VTSTech/pi-coding-agent"
17
15
  },
18
16
  "dependencies": {
19
- "@vtstech/pi-shared": "1.1.4"
17
+ "@vtstech/pi-shared": "1.1.5"
20
18
  },
21
19
  "peerDependencies": {
22
20
  "@mariozechner/pi-coding-agent": ">=0.66"
23
21
  },
24
22
  "pi": {
25
- "extensions": [
26
- "./status.js"
27
- ]
23
+ "extensions": ["./status.js"]
28
24
  }
29
25
  }
package/status.js CHANGED
@@ -5,6 +5,7 @@ import os from "node:os";
5
5
  import { getOllamaBaseUrl, fetchModelContextLength, readModelsJson } from "@vtstech/pi-shared/ollama";
6
6
  import { fmtBytes, fmtDur } from "@vtstech/pi-shared/format";
7
7
  import { debugLog } from "@vtstech/pi-shared/debug";
8
+ import { getSecurityMode } from "@vtstech/pi-shared/security";
8
9
  var STATUS_UPDATE_INTERVAL_MS = 5e3;
9
10
  var TOOL_TIMER_INTERVAL_MS = 1e3;
10
11
  function status_temp_default(pi) {
@@ -165,13 +166,14 @@ function status_temp_default(pi) {
165
166
  } else {
166
167
  ctxUi.setStatus("status-params", void 0);
167
168
  }
169
+ const secMode = getSecurityMode();
168
170
  const now = Date.now();
169
171
  if (securityFlashTool && now < securityFlashUntil) {
170
- ctxUi.setStatus("status-sec", `${dim2("SEC:")}${green2(String(blockedCount))} ${dim2("(blocked: " + securityFlashTool + ")")}`);
172
+ ctxUi.setStatus("status-sec", `${dim2("SEC:")}${green2(String(blockedCount))} ${dim2("(" + secMode.toUpperCase() + ")")} ${dim2("(blocked: " + securityFlashTool + ")")}`);
171
173
  } else if (blockedCount > 0) {
172
- ctxUi.setStatus("status-sec", `${dim2("SEC:")}${green2(String(blockedCount))}`);
174
+ ctxUi.setStatus("status-sec", `${dim2("SEC:")}${green2(String(blockedCount))} ${dim2("(" + secMode.toUpperCase() + ")")}`);
173
175
  } else {
174
- ctxUi.setStatus("status-sec", void 0);
176
+ ctxUi.setStatus("status-sec", `${dim2("SEC:")}${green2(secMode.toUpperCase())}`);
175
177
  }
176
178
  if (activeTool && activeToolStart > 0) {
177
179
  const elapsed = performance.now() - activeToolStart;
@@ -259,15 +261,42 @@ function status_temp_default(pi) {
259
261
  });
260
262
  pi.on("before_provider_request", (event) => {
261
263
  lastPayload = event.payload;
264
+ measurePromptFromPayload(lastPayload);
262
265
  });
266
+ function measurePromptFromPayload(payload) {
267
+ if (!payload || cachedPromptText) return;
268
+ const theme = ctxTheme;
269
+ const dim2 = (s) => theme?.fg?.("dim", s) ?? s;
270
+ const green2 = (s) => theme?.fg?.("success", s) ?? s;
271
+ try {
272
+ const messages = payload.messages;
273
+ if (!messages?.length) return;
274
+ const sysMsg = messages.find((m) => m.role === "system") ?? messages[0];
275
+ if (!sysMsg?.content) return;
276
+ const chr = sysMsg.content.length;
277
+ const tok = sysMsg.content.split(/\s+/).filter(Boolean).length;
278
+ cachedPromptText = `${dim2("Prompt:")} ${green2(`${chr} chr ${tok} tok`)}`;
279
+ debugLog("status", `system prompt measured from payload: ${chr} chars, ~${tok} words`);
280
+ flushStatus();
281
+ } catch (err) {
282
+ debugLog("status", "failed to measure prompt from payload", err);
283
+ }
284
+ }
263
285
  pi.on("agent_start", async (_event, ctx) => {
264
286
  agentStartTime = performance.now();
265
287
  try {
266
288
  const prompt = ctx.getSystemPrompt();
267
- const chr = prompt.length;
268
- const tok = prompt.split(/\s+/).filter(Boolean).length;
269
- cachedPromptText = `${dim("Prompt:")} ${green(`${chr} chr ${tok} tok`)}`;
270
- } catch {
289
+ if (prompt) {
290
+ const chr = prompt.length;
291
+ const tok = prompt.split(/\s+/).filter(Boolean).length;
292
+ cachedPromptText = `${dim("Prompt:")} ${green(`${chr} chr ${tok} tok`)}`;
293
+ debugLog("status", `system prompt measured via getSystemPrompt(): ${chr} chars, ~${tok} words`);
294
+ }
295
+ } catch (err) {
296
+ debugLog("status", "getSystemPrompt() not available, will measure from payload", err);
297
+ }
298
+ if (!cachedPromptText && lastPayload) {
299
+ measurePromptFromPayload(lastPayload);
271
300
  }
272
301
  flushStatus();
273
302
  });