@vtstech/pi-shared 1.0.3 → 1.0.4

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/format.js CHANGED
@@ -1,39 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
1
  // shared/format.ts
20
- var format_exports = {};
21
- __export(format_exports, {
22
- bytesHuman: () => bytesHuman,
23
- fail: () => fail,
24
- fmtBytes: () => fmtBytes,
25
- fmtDur: () => fmtDur,
26
- info: () => info,
27
- msHuman: () => msHuman,
28
- ok: () => ok,
29
- padRight: () => padRight,
30
- pct: () => pct,
31
- sanitizeForReport: () => sanitizeForReport,
32
- section: () => section,
33
- truncate: () => truncate,
34
- warn: () => warn
35
- });
36
- module.exports = __toCommonJS(format_exports);
37
2
  function section(title) {
38
3
  return `
39
4
  \u2500\u2500 ${title} ${"\u2500".repeat(Math.max(1, 60 - title.length - 4))}`;
@@ -98,8 +63,7 @@ function sanitizeForReport(s, maxLines = 40) {
98
63
  function padRight(s, n) {
99
64
  return s + " ".repeat(Math.max(0, n - s.length));
100
65
  }
101
- // Annotate the CommonJS export names for ESM import in node:
102
- 0 && (module.exports = {
66
+ export {
103
67
  bytesHuman,
104
68
  fail,
105
69
  fmtBytes,
@@ -113,4 +77,4 @@ function padRight(s, n) {
113
77
  section,
114
78
  truncate,
115
79
  warn
116
- });
80
+ };
package/ollama.js CHANGED
@@ -1,47 +1,8 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
1
  // shared/ollama.ts
30
- var ollama_exports = {};
31
- __export(ollama_exports, {
32
- MODELS_JSON_PATH: () => MODELS_JSON_PATH,
33
- detectModelFamily: () => detectModelFamily,
34
- fetchOllamaModels: () => fetchOllamaModels,
35
- getOllamaBaseUrl: () => getOllamaBaseUrl,
36
- isReasoningModel: () => isReasoningModel,
37
- readModelsJson: () => readModelsJson,
38
- writeModelsJson: () => writeModelsJson
39
- });
40
- module.exports = __toCommonJS(ollama_exports);
41
- var fs = __toESM(require("node:fs"));
42
- var path = __toESM(require("node:path"));
43
- var import_node_os = __toESM(require("node:os"));
44
- var MODELS_JSON_PATH = path.join(import_node_os.default.homedir(), ".pi", "agent", "models.json");
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ import os from "node:os";
5
+ var MODELS_JSON_PATH = path.join(os.homedir(), ".pi", "agent", "models.json");
45
6
  function getOllamaBaseUrl() {
46
7
  try {
47
8
  if (fs.existsSync(MODELS_JSON_PATH)) {
@@ -118,8 +79,7 @@ function detectModelFamily(modelName) {
118
79
  }
119
80
  return "unknown";
120
81
  }
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
82
+ export {
123
83
  MODELS_JSON_PATH,
124
84
  detectModelFamily,
125
85
  fetchOllamaModels,
@@ -127,4 +87,4 @@ function detectModelFamily(modelName) {
127
87
  isReasoningModel,
128
88
  readModelsJson,
129
89
  writeModelsJson
130
- });
90
+ };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@vtstech/pi-shared",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Shared utilities for Pi Coding Agent extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "keywords": ["pi-package", "pi-extensions"],
8
8
  "license": "MIT",
9
9
  "access": "public",
10
+ "type": "module",
10
11
  "author": "VTSTech",
11
12
  "homepage": "https://www.vts-tech.org",
12
13
  "repository": {
package/security.js CHANGED
@@ -1,50 +1,7 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
1
  // shared/security.ts
30
- var security_exports = {};
31
- __export(security_exports, {
32
- BLOCKED_COMMANDS: () => BLOCKED_COMMANDS,
33
- BLOCKED_URL_PATTERNS: () => BLOCKED_URL_PATTERNS,
34
- appendAuditEntry: () => appendAuditEntry,
35
- checkBashToolInput: () => checkBashToolInput,
36
- checkFileToolInput: () => checkFileToolInput,
37
- checkHttpToolInput: () => checkHttpToolInput,
38
- checkInjectionPatterns: () => checkInjectionPatterns,
39
- isSafeUrl: () => isSafeUrl,
40
- readRecentAuditEntries: () => readRecentAuditEntries,
41
- sanitizeCommand: () => sanitizeCommand,
42
- validatePath: () => validatePath
43
- });
44
- module.exports = __toCommonJS(security_exports);
45
- var fs = __toESM(require("node:fs"));
46
- var path = __toESM(require("node:path"));
47
- var import_node_os = __toESM(require("node:os"));
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ import os from "node:os";
48
5
  var BLOCKED_COMMANDS = /* @__PURE__ */ new Set([
49
6
  // System modification
50
7
  "rm",
@@ -190,9 +147,9 @@ function validatePath(filePath, allowedDirs) {
190
147
  "/etc/passwd",
191
148
  "/.ssh/",
192
149
  "/.gnupg/",
193
- path.join(import_node_os.default.homedir(), ".ssh"),
194
- path.join(import_node_os.default.homedir(), ".gnupg"),
195
- path.join(import_node_os.default.homedir(), ".pi", "agent", "models.json")
150
+ path.join(os.homedir(), ".ssh"),
151
+ path.join(os.homedir(), ".gnupg"),
152
+ path.join(os.homedir(), ".pi", "agent", "models.json")
196
153
  ];
197
154
  for (const sensitive of sensitivePaths) {
198
155
  if (resolved.startsWith(sensitive) || resolved === sensitive) {
@@ -283,7 +240,7 @@ function sanitizeCommand(command) {
283
240
  }
284
241
  return { isSafe: true, error: "", command };
285
242
  }
286
- var AUDIT_DIR = path.join(import_node_os.default.homedir(), ".pi", "agent");
243
+ var AUDIT_DIR = path.join(os.homedir(), ".pi", "agent");
287
244
  var AUDIT_LOG_PATH = path.join(AUDIT_DIR, "audit.log");
288
245
  function appendAuditEntry(entry) {
289
246
  try {
@@ -367,8 +324,7 @@ function checkInjectionPatterns(input) {
367
324
  }
368
325
  return { safe: true, rule: "", detail: "" };
369
326
  }
370
- // Annotate the CommonJS export names for ESM import in node:
371
- 0 && (module.exports = {
327
+ export {
372
328
  BLOCKED_COMMANDS,
373
329
  BLOCKED_URL_PATTERNS,
374
330
  appendAuditEntry,
@@ -380,4 +336,4 @@ function checkInjectionPatterns(input) {
380
336
  readRecentAuditEntries,
381
337
  sanitizeCommand,
382
338
  validatePath
383
- });
339
+ };
package/types.js CHANGED
@@ -1,33 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
4
 
21
5
  // shared/types.ts
22
- var types_exports = {};
23
- __export(types_exports, {
24
- EmptyResponseError: () => EmptyResponseError,
25
- ModelTimeoutError: () => ModelTimeoutError,
26
- OllamaConnectionError: () => OllamaConnectionError,
27
- SecurityBlockError: () => SecurityBlockError,
28
- ToolParseError: () => ToolParseError
29
- });
30
- module.exports = __toCommonJS(types_exports);
31
6
  var OllamaConnectionError = class extends Error {
32
7
  constructor(message, cause) {
33
8
  super(message);
@@ -85,11 +60,10 @@ var ToolParseError = class extends Error {
85
60
  this.rawText = rawText;
86
61
  }
87
62
  };
88
- // Annotate the CommonJS export names for ESM import in node:
89
- 0 && (module.exports = {
63
+ export {
90
64
  EmptyResponseError,
91
65
  ModelTimeoutError,
92
66
  OllamaConnectionError,
93
67
  SecurityBlockError,
94
68
  ToolParseError
95
- });
69
+ };