@pi-unipi/core 2.6.0 → 2.6.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/constants.ts CHANGED
@@ -297,6 +297,7 @@ export const NOTIFY_COMMANDS = {
297
297
  SET_NTFY: "notify-set-ntfy",
298
298
  TEST: "notify-test",
299
299
  RECAP_MODEL: "notify-recap-model",
300
+ NOTIFY_EVENT: "notify-event",
300
301
  } as const;
301
302
 
302
303
  /** Notify tool names */
package/model-cache.ts CHANGED
@@ -9,14 +9,18 @@
9
9
  import * as fs from "node:fs";
10
10
  import * as path from "node:path";
11
11
 
12
- /** Path to the model cache directory */
13
- const CACHE_DIR = path.join(
14
- process.env.HOME ?? process.env.USERPROFILE ?? "~",
15
- ".unipi/config",
16
- );
12
+ /** Resolve the model cache directory at call time (respects HOME changes). */
13
+ function cacheDir(): string {
14
+ return path.join(
15
+ process.env.HOME ?? process.env.USERPROFILE ?? "~",
16
+ ".unipi/config",
17
+ );
18
+ }
17
19
 
18
- /** Path to the model cache file */
19
- const CACHE_FILE = path.join(CACHE_DIR, "models-cache.json");
20
+ /** Resolve the model cache file path at call time. */
21
+ function cacheFile(): string {
22
+ return path.join(cacheDir(), "models-cache.json");
23
+ }
20
24
 
21
25
  /** A single cached model entry */
22
26
  export interface CachedModel {
@@ -42,8 +46,9 @@ export interface ModelCache {
42
46
  */
43
47
  export function readModelCache(): CachedModel[] {
44
48
  try {
45
- if (!fs.existsSync(CACHE_FILE)) return [];
46
- const parsed = JSON.parse(fs.readFileSync(CACHE_FILE, "utf-8"));
49
+ const file = cacheFile();
50
+ if (!fs.existsSync(file)) return [];
51
+ const parsed = JSON.parse(fs.readFileSync(file, "utf-8"));
47
52
  return Array.isArray(parsed.models) ? parsed.models : [];
48
53
  } catch {
49
54
  return [];
@@ -56,14 +61,15 @@ export function readModelCache(): CachedModel[] {
56
61
  */
57
62
  export function writeModelCache(models: CachedModel[]): void {
58
63
  try {
59
- if (!fs.existsSync(CACHE_DIR)) {
60
- fs.mkdirSync(CACHE_DIR, { recursive: true });
64
+ const dir = cacheDir();
65
+ if (!fs.existsSync(dir)) {
66
+ fs.mkdirSync(dir, { recursive: true });
61
67
  }
62
68
  const cache: ModelCache = {
63
69
  updatedAt: new Date().toISOString(),
64
70
  models,
65
71
  };
66
- fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2) + "\n", "utf-8");
72
+ fs.writeFileSync(cacheFile(), JSON.stringify(cache, null, 2) + "\n", "utf-8");
67
73
  } catch {
68
74
  // Best effort — cache is optional
69
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/core",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "Shared utilities, event types, and constants for Unipi extension suite",
5
5
  "type": "module",
6
6
  "license": "MIT",