@vtstech/pi-diag 1.1.7 → 1.1.9

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 (2) hide show
  1. package/diag.js +32 -13
  2. package/package.json +2 -2
package/diag.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  msHuman,
13
13
  pct
14
14
  } from "@vtstech/pi-shared/format";
15
- import { MODELS_JSON_PATH, getOllamaBaseUrl, BUILTIN_PROVIDERS, readModelsJson, EXTENSION_VERSION } from "@vtstech/pi-shared/ollama";
15
+ import { MODELS_JSON_PATH, getOllamaBaseUrl, BUILTIN_PROVIDERS, readModelsJson, EXTENSION_VERSION, isLocalProvider } from "@vtstech/pi-shared/ollama";
16
16
  import {
17
17
  BLOCKED_COMMANDS,
18
18
  BLOCKED_URL_PATTERNS,
@@ -27,6 +27,24 @@ import {
27
27
  readRecentAuditEntries,
28
28
  AUDIT_LOG_PATH
29
29
  } from "@vtstech/pi-shared/security";
30
+ import { readSettings } from "@vtstech/pi-shared/config-io";
31
+ import { debugLog } from "@vtstech/pi-shared/debug";
32
+ var SECRET_KEY_PATTERNS = [
33
+ /key/i,
34
+ /token/i,
35
+ /secret/i,
36
+ /password/i,
37
+ /credential/i,
38
+ /auth/i,
39
+ /apikey/i,
40
+ /api_key/i
41
+ ];
42
+ function redactValue(key, value) {
43
+ if (typeof value !== "string") return JSON.stringify(value);
44
+ if (SECRET_KEY_PATTERNS.some((p) => p.test(key))) return "[REDACTED]";
45
+ if (value.length > 20 && !value.includes(" ") && /^[A-Za-z0-9_\-+/=]+$/.test(value)) return value.slice(0, 8) + "...";
46
+ return value;
47
+ }
30
48
  function diag_temp_default(pi) {
31
49
  const branding = [
32
50
  ` \u26A1 Pi Diagnostics v${EXTENSION_VERSION}`,
@@ -97,7 +115,7 @@ function diag_temp_default(pi) {
97
115
  let ollamaModels = [];
98
116
  let ollamaVersion = "unknown";
99
117
  const ollamaBaseUrl = getOllamaBaseUrl();
100
- const isRemoteOllama = !ollamaBaseUrl.includes("localhost") && !ollamaBaseUrl.includes("127.0.0.1");
118
+ const isRemoteOllama = !isLocalProvider(ollamaBaseUrl);
101
119
  if (isRemoteOllama) {
102
120
  const ollamaRoot = ollamaBaseUrl.replace(/\/v1\/?$/, "");
103
121
  lines.push(info(`Remote Ollama detected: ${ollamaBaseUrl}`));
@@ -140,7 +158,8 @@ function diag_temp_default(pi) {
140
158
  lines.push(info("No model currently loaded in Ollama"));
141
159
  }
142
160
  }
143
- } catch {
161
+ } catch (err) {
162
+ debugLog("diag", "failed to check remote Ollama loaded models", err);
144
163
  }
145
164
  }
146
165
  } else {
@@ -182,7 +201,8 @@ function diag_temp_default(pi) {
182
201
  lines.push(warn("No model currently loaded in Ollama"));
183
202
  }
184
203
  }
185
- } catch {
204
+ } catch (err) {
205
+ debugLog("diag", "failed to check local Ollama loaded models", err);
186
206
  }
187
207
  }
188
208
  }
@@ -233,20 +253,19 @@ function diag_temp_default(pi) {
233
253
  lines.push(info(" \u2192 Run /ollama-sync to create it"));
234
254
  }
235
255
  lines.push(section("SETTINGS"));
236
- const settingsPath = path.join(agentDir, "settings.json");
237
- if (fs.existsSync(settingsPath)) {
238
- try {
239
- const settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
256
+ try {
257
+ const settings = readSettings();
258
+ if (Object.keys(settings).length > 0) {
240
259
  lines.push(info("Global settings found:"));
241
260
  for (const [key, val] of Object.entries(settings)) {
242
- lines.push(info(` ${key}: ${JSON.stringify(val)}`));
261
+ lines.push(info(` ${key}: ${redactValue(key, val)}`));
243
262
  }
244
263
  check(true, "settings.json valid JSON", "");
245
- } catch (e) {
246
- lines.push(fail(`settings.json parse error: ${e.message}`));
264
+ } else {
265
+ lines.push(warn("No global settings.json found (using defaults)"));
247
266
  }
248
- } else {
249
- lines.push(warn("No global settings.json found (using defaults)"));
267
+ } catch (e) {
268
+ lines.push(fail(`settings.json read error: ${e.message}`));
250
269
  }
251
270
  lines.push(section("EXTENSIONS"));
252
271
  const extensionsDir = path.join(agentDir, "extensions");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtstech/pi-diag",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Diagnostics extension for Pi Coding Agent",
5
5
  "main": "diag.js",
6
6
  "keywords": ["pi-extensions"],
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/VTSTech/pi-coding-agent"
15
15
  },
16
16
  "dependencies": {
17
- "@vtstech/pi-shared": "1.1.7"
17
+ "@vtstech/pi-shared": "1.1.9"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@mariozechner/pi-coding-agent": ">=0.66"