@pi-unipi/utility 2.6.2 → 2.10.0

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 +11 -77
  2. package/package.json +5 -7
  3. package/src/index.ts +3 -4
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # @pi-unipi/utility
2
2
 
3
- Environment info, diagnostics, cleanup, name badge, and diff rendering. The grab-bag package for maintaining your development environment and making tool output readable.
4
-
5
- The diff rendering is the standout feature — Shiki-powered syntax-highlighted diffs for `write` and `edit` tool output. Side-by-side view for edits, unified view for writes, with color presets and auto-fallback on narrow terminals.
3
+ Environment info, diagnostics, cleanup, and the session name badge. The grab-bag package for maintaining your development environment and keeping an eye on provider cache behavior.
6
4
 
7
5
  ## Commands
8
6
 
@@ -15,7 +13,9 @@ The diff rendering is the standout feature — Shiki-powered syntax-highlighted
15
13
  | `/unipi:reload` | Explain how to reload extensions |
16
14
  | `/unipi:name-badge` | Toggle name badge overlay |
17
15
  | `/unipi:badge-gen` | Generate session name via LLM and enable badge |
18
- | `/unipi:util-settings` | Unified settings for badge and diff rendering |
16
+ | `/unipi:badge-name` | Set the session name shown in the badge |
17
+ | `/unipi:badge-settings` | Configure badge behavior |
18
+ | `/unipi:util-settings` | Unified settings TUI (badge) |
19
19
  | `/unipi:prefix-cache` | Show privacy-safe request-prefix transitions and provider cache token counters |
20
20
 
21
21
  ### Examples
@@ -31,7 +31,7 @@ The diff rendering is the standout feature — Shiki-powered syntax-highlighted
31
31
 
32
32
  ## Special Triggers
33
33
 
34
- Utility registers with the info-screen dashboard, showing module status and diagnostic results. The footer subscribes to utility events for its extension status segment.
34
+ Utility registers with the info-screen dashboard, showing module status and diagnostic results. The footer subscribes to utility events for its extension status segment. When Herdr is present, the badge module syncs the session name to the pane title.
35
35
 
36
36
  ## Provider prefix-cache diagnostics
37
37
 
@@ -41,71 +41,31 @@ The fingerprints are keyed HMAC-SHA-256 values using a random in-memory key that
41
41
 
42
42
  `/unipi:cleanup` includes private `~/.unipi/tool-results/` artifacts in the normal temporary-file retention policy (7 days by default). Use dry-run mode to review candidates before deletion.
43
43
 
44
- The diff rendering feature wraps Pi's built-in `write` and `edit` tools. When enabled, these tools show syntax-highlighted diffs instead of plain output. This is a transparent replacement — the agent doesn't need to know about it.
45
-
46
44
  ## Agent Tools
47
45
 
48
46
  | Tool | Description |
49
47
  |------|-------------|
50
- | `ctx_batch` | Atomic batch execution with rollback support |
51
48
  | `ctx_env` | Environment inspection for debugging |
52
- | `write` | Write file with syntax-highlighted diff (when diff enabled) |
53
- | `edit` | Edit file with split/unified diff view (when diff enabled) |
54
-
55
- ### Batch Execution
56
-
57
- ```typescript
58
- import { BatchBuilder } from "@pi-unipi/utility/tools/batch";
59
-
60
- const report = await new BatchBuilder()
61
- .addCommand("search", { query: "refactor" })
62
- .addTool("memory_search", { query: "patterns" })
63
- .withOptions({ failFast: true, commandTimeoutMs: 30000 })
64
- .execute(myExecutor);
65
-
66
- if (!report.success) {
67
- console.log("Failed:", report.results.find(r => !r.success)?.error);
68
- }
69
- ```
49
+ | `set_session_name` | Set the session name for badge display (when badge agent-tool is enabled) |
70
50
 
71
51
  ## Configurables
72
52
 
73
- ### Diff Rendering
53
+ ### Name Badge
74
54
 
75
55
  ```
76
56
  /unipi:util-settings # Open unified settings TUI
77
57
  ```
78
58
 
79
- Or edit `.unipi/config/util-settings.json` directly:
59
+ Or edit `.unipi/config/util-settings.json` directly (migrated automatically from the legacy `.unipi/config/badge.json` on first read):
80
60
 
81
61
  ```json
82
62
  {
83
- "diff": {
84
- "enabled": true,
85
- "theme": "default",
86
- "shikiTheme": "github-dark",
87
- "splitMinWidth": 150
63
+ "badge": {
64
+ "badgeEnabled": true
88
65
  }
89
66
  }
90
67
  ```
91
68
 
92
- | Setting | Default | Options |
93
- |---------|---------|---------|
94
- | `enabled` | true | true/false |
95
- | `theme` | "default" | default, midnight, subtle, neon |
96
- | `shikiTheme` | "github-dark" | github-dark, dracula, one-dark-pro, catppuccin-mocha, nord, tokyo-night |
97
- | `splitMinWidth` | 150 | Minimum terminal width for split view |
98
-
99
- Environment variable overrides: `DIFF_ADD_BG`, `DIFF_REM_BG`, etc.
100
-
101
- Features:
102
- - Split view (side-by-side) for `edit`, auto-falls back to unified on narrow terminals
103
- - Unified view (stacked) for `write` overwrites
104
- - LRU cache (192 entries) for Shiki highlights
105
- - Large diff fallback (skip highlighting above 80k chars)
106
-
107
- ### Name Badge
108
-
109
69
  The badge is a persistent HUD overlay in the top-right corner showing the current session name. It auto-restores visibility on session restart.
110
70
 
111
71
  ## Programmatic API
@@ -113,35 +73,9 @@ The badge is a persistent HUD overlay in the top-right corner showing the curren
113
73
  | Module | Path | Description |
114
74
  |--------|------|-------------|
115
75
  | ProcessLifecycle | `lifecycle/process` | Parent PID polling, orphan detection, signal handlers |
116
- | cleanupStale | `lifecycle/cleanup` | Stale DB/temp/session/cache cleanup with dry-run |
117
- | TTLCache | `cache/ttl-cache` | Memory or SQLite-backed TTL cache |
76
+ | cleanupStale | `lifecycle/cleanup` | Stale DB/temp/session cleanup with dry-run |
118
77
  | AnalyticsCollector | `analytics/collector` | Privacy-respecting event collection with daily rollup |
119
78
  | runDiagnostics | `diagnostics/engine` | Cross-module health checks with plugin architecture |
120
- | detectCapabilities | `display/capabilities` | Terminal feature detection (color, Nerd Font, unicode) |
121
- | Width Utilities | `display/width` | ANSI-aware clamp, wrap, collapse, pad, center |
122
-
123
- ### TTL Cache
124
-
125
- ```typescript
126
- import { TTLCache } from "@pi-unipi/utility/cache/ttl-cache";
127
-
128
- const cache = new TTLCache({ defaultTtlMs: 60000 });
129
- await cache.set("key", { data: "value" });
130
- const value = await cache.get("key");
131
- ```
132
-
133
- ### Terminal Capabilities
134
-
135
- ```typescript
136
- import { detectCapabilities, getIcon } from "@pi-unipi/utility/display/capabilities";
137
-
138
- const caps = detectCapabilities();
139
- console.log("Nerd Font:", caps.nerdFont);
140
- console.log("Truecolor:", caps.truecolor);
141
- console.log(getIcon("󰘳", "[OK]")); // Uses Nerd Font if available
142
- ```
143
-
144
- Capability detection distinguishes basic color, xterm-256-compatible terminals, and truecolor-capable terminals. Apple Terminal is treated as color-capable but not truecolor-capable so renderers can fall back safely.
145
79
 
146
80
  ## Privacy
147
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/utility",
3
- "version": "2.6.2",
3
+ "version": "2.10.0",
4
4
  "description": "Utility commands and tools for Pi coding agent — lifecycle, diagnostics, cache, analytics, display, batch execution",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -36,14 +36,12 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@pi-unipi/core": "2.6.1"
40
- },
41
- "devDependencies": {
42
- "@types/diff": "^7.0.2"
39
+ "@pi-unipi/core": "2.10.0"
43
40
  },
41
+ "devDependencies": {},
44
42
  "peerDependencies": {
45
- "@earendil-works/pi-coding-agent": "^0.80.0",
46
- "@earendil-works/pi-tui": "^0.80.0",
43
+ "@earendil-works/pi-coding-agent": "^0.84.0",
44
+ "@earendil-works/pi-tui": "^0.84.0",
47
45
  "typebox": "^1.1.38"
48
46
  },
49
47
  "scripts": {
package/src/index.ts CHANGED
@@ -3,13 +3,12 @@
3
3
  *
4
4
  * Comprehensive utilities suite for Pi coding agent:
5
5
  * - Commands: continue, reload, status, cleanup, env, doctor, badge
6
- * - Tools: ctx_batch, ctx_env, set_session_name
6
+ * - Tools: ctx_env, set_session_name
7
7
  * - Lifecycle: process management, stale cleanup
8
- * - Cache: TTL cache with optional persistence
9
8
  * - Analytics: lightweight event collection
10
9
  * - Diagnostics: cross-module health checks
11
- * - Display: terminal capabilities, width utilities
12
- * - TUI: settings inspector pattern, name badge
10
+ * - Prefix-cache observability: privacy-safe provider cache stats
11
+ * - TUI: util settings, name badge (incl. Herdr pane title sync)
13
12
  */
14
13
 
15
14
  import { dirname } from "node:path";