@pi-unipi/core 0.1.8 → 0.1.11

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
@@ -33,6 +33,8 @@ export const MODULES = {
33
33
  COMPACTOR: "@pi-unipi/compactor",
34
34
  NOTIFY: "@pi-unipi/notify",
35
35
  BTW: "@pi-unipi/btw",
36
+ MILESTONE: "@pi-unipi/milestone",
37
+ KANBOARD: "@pi-unipi/kanboard",
36
38
  } as const;
37
39
 
38
40
  /** Workflow command names */
@@ -156,6 +158,10 @@ export const UTILITY_COMMANDS = {
156
158
  CLEANUP: "cleanup",
157
159
  ENV: "env",
158
160
  DOCTOR: "doctor",
161
+ BADGE_NAME: "badge-name",
162
+ BADGE_GEN: "badge-gen",
163
+ BADGE_TOGGLE: "badge-toggle",
164
+ BADGE_SETTINGS: "badge-settings",
159
165
  } as const;
160
166
 
161
167
  /** Utility tool names */
@@ -163,8 +169,12 @@ export const UTILITY_TOOLS = {
163
169
  CONTINUE: "continue_task",
164
170
  BATCH: "ctx_batch",
165
171
  ENV: "ctx_env",
172
+ SET_SESSION_NAME: "set_session_name",
166
173
  } as const;
167
174
 
175
+ /** Badge config path */
176
+ export const BADGE_CONFIG_FILE = ".unipi/config/badge.json" as const;
177
+
168
178
  /** Utility directory paths */
169
179
  export const UTILITY_DIRS = {
170
180
  CACHE: "~/.unipi/cache",
@@ -234,6 +244,24 @@ export const COMPACTOR_DIRS = {
234
244
  DB: "~/.unipi/db/compactor",
235
245
  } as const;
236
246
 
247
+ /** Kanboard command names */
248
+ export const KANBOARD_COMMANDS = {
249
+ KANBOARD: "kanboard",
250
+ KANBOARD_DOCTOR: "kanboard-doctor",
251
+ } as const;
252
+
253
+ /** Kanboard directory paths */
254
+ export const KANBOARD_DIRS = {
255
+ UI_STATIC: "ui/static",
256
+ PID_FILE: ".unipi/kanboard.pid",
257
+ } as const;
258
+
259
+ /** Kanboard defaults */
260
+ export const KANBOARD_DEFAULTS = {
261
+ PORT: 8165,
262
+ MAX_PORT: 8175,
263
+ } as const;
264
+
237
265
  /** Notify command names */
238
266
  export const NOTIFY_COMMANDS = {
239
267
  SETTINGS: "notify-settings",
@@ -252,6 +280,17 @@ export const NOTIFY_DIRS = {
252
280
  CONFIG: "~/.unipi/config/notify",
253
281
  } as const;
254
282
 
283
+ /** Milestone command names */
284
+ export const MILESTONE_COMMANDS = {
285
+ ONBOARD: "milestone-onboard",
286
+ UPDATE: "milestone-update",
287
+ } as const;
288
+
289
+ /** Milestone directory paths */
290
+ export const MILESTONE_DIRS = {
291
+ MILESTONES: ".unipi/docs/MILESTONES.md",
292
+ } as const;
293
+
255
294
  /** Compactor defaults */
256
295
  export const COMPACTOR_DEFAULTS = {
257
296
  MAX_EVENTS_PER_SESSION: 1000,
package/events.ts CHANGED
@@ -75,6 +75,9 @@ export const UNIPI_EVENTS = {
75
75
 
76
76
  /** Notification sent */
77
77
  NOTIFICATION_SENT: "unipi:notify:sent",
78
+
79
+ /** Badge generation requested (from kanboard or other module) */
80
+ BADGE_GENERATE_REQUEST: "unipi:badge:generate:request",
78
81
  } as const;
79
82
 
80
83
  /** Payload for MODULE_READY / MODULE_GONE */
@@ -295,6 +298,14 @@ export interface UnipiUtilityLifecycleEvent {
295
298
  reason?: string;
296
299
  }
297
300
 
301
+ /** Payload for BADGE_GENERATE_REQUEST */
302
+ export interface UnipiBadgeGenerateRequestEvent {
303
+ /** Source of the request (e.g., "kanboard", "input-hook") */
304
+ source: string;
305
+ /** First user message for context (optional) */
306
+ conversationSummary?: string;
307
+ }
308
+
298
309
  /** Payload for NOTIFICATION_SENT */
299
310
  export interface UnipiNotificationSentEvent {
300
311
  /** Event type that triggered notification */
@@ -329,4 +340,5 @@ export type UnipiEventPayload =
329
340
  | UnipiUtilityCleanupEvent
330
341
  | UnipiUtilityDiagnosticsEvent
331
342
  | UnipiUtilityLifecycleEvent
332
- | UnipiNotificationSentEvent;
343
+ | UnipiNotificationSentEvent
344
+ | UnipiBadgeGenerateRequestEvent;
package/index.ts CHANGED
@@ -8,3 +8,4 @@ export * from "./constants.js";
8
8
  export * from "./events.js";
9
9
  export * from "./sandbox.js";
10
10
  export * from "./utils.js";
11
+ export * from "./model-cache.js";
package/model-cache.ts ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @pi-unipi/core — Model Cache
3
+ *
4
+ * File-based model list cache at ~/.unipi/config/models-cache.json.
5
+ * Allows TUI components and other packages to list available models
6
+ * without needing ctx.modelRegistry at runtime.
7
+ */
8
+
9
+ import * as fs from "node:fs";
10
+ import * as path from "node:path";
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
+ );
17
+
18
+ /** Path to the model cache file */
19
+ const CACHE_FILE = path.join(CACHE_DIR, "models-cache.json");
20
+
21
+ /** A single cached model entry */
22
+ export interface CachedModel {
23
+ /** Model provider (e.g. "openai", "anthropic") */
24
+ provider: string;
25
+ /** Model ID (e.g. "gpt-4o", "claude-sonnet-4-6") */
26
+ id: string;
27
+ /** Optional display name */
28
+ name?: string;
29
+ }
30
+
31
+ /** The full model cache structure */
32
+ export interface ModelCache {
33
+ /** ISO timestamp of last cache write */
34
+ updatedAt: string;
35
+ /** List of cached models */
36
+ models: CachedModel[];
37
+ }
38
+
39
+ /**
40
+ * Read cached model list from disk.
41
+ * Returns empty array if no cache file exists or it's malformed.
42
+ */
43
+ export function readModelCache(): CachedModel[] {
44
+ try {
45
+ if (!fs.existsSync(CACHE_FILE)) return [];
46
+ const parsed = JSON.parse(fs.readFileSync(CACHE_FILE, "utf-8"));
47
+ return Array.isArray(parsed.models) ? parsed.models : [];
48
+ } catch {
49
+ return [];
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Write model list to cache file.
55
+ * Creates directory if needed. Best effort — silently ignores errors.
56
+ */
57
+ export function writeModelCache(models: CachedModel[]): void {
58
+ try {
59
+ if (!fs.existsSync(CACHE_DIR)) {
60
+ fs.mkdirSync(CACHE_DIR, { recursive: true });
61
+ }
62
+ const cache: ModelCache = {
63
+ updatedAt: new Date().toISOString(),
64
+ models,
65
+ };
66
+ fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2) + "\n", "utf-8");
67
+ } catch {
68
+ // Best effort — cache is optional
69
+ }
70
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/core",
3
- "version": "0.1.8",
3
+ "version": "0.1.11",
4
4
  "description": "Shared utilities, event types, and constants for Unipi extension suite",
5
5
  "type": "module",
6
6
  "license": "MIT",