pi-hud-plus 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +11 -0
- package/LICENSE +22 -0
- package/README.md +209 -2
- package/package.json +47 -4
- package/src/clock.ts +14 -0
- package/src/config.ts +379 -0
- package/src/extra-cmd.ts +46 -0
- package/src/git.ts +213 -0
- package/src/i18n/en.ts +28 -0
- package/src/i18n/index.ts +38 -0
- package/src/i18n/types.ts +27 -0
- package/src/i18n/zh-Hans.ts +28 -0
- package/src/index.ts +418 -0
- package/src/memory.ts +116 -0
- package/src/render/colors.ts +168 -0
- package/src/render/index.ts +177 -0
- package/src/render/lines/context.ts +46 -0
- package/src/render/lines/environment.ts +21 -0
- package/src/render/lines/git.ts +70 -0
- package/src/render/lines/memory.ts +17 -0
- package/src/render/lines/project.ts +79 -0
- package/src/render/lines/prompt-cache.ts +40 -0
- package/src/render/lines/session-stats.ts +58 -0
- package/src/render/lines/session-time.ts +73 -0
- package/src/render/session-line.ts +42 -0
- package/src/render/tools-line.ts +51 -0
- package/src/sanitize.ts +7 -0
- package/src/session.ts +57 -0
- package/src/speed-tracker.ts +32 -0
- package/src/types.ts +90 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-11-14
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
|
|
7
|
+
- **claude-hud for pi**: replaces pi's footer with a claude-hud-style HUD. It shows the model badge with an optional thinking level, project path and git status, the context bar, prompt cache countdown, approximate RAM, the Environment line (AGENTS.md, skills, prompts, MCPs), the tools line, session times, session tokens, cost, speed and `pi vX`.
|
|
8
|
+
- **claude-hud config**: `~/.pi/agent/pi-hud-plus.json`, with a per-project override at `.pi/pi-hud-plus.json`. Field names match claude-hud's, so a pasted claude-hud config loads and unknown fields are ignored.
|
|
9
|
+
- **Extension statuses**: other extensions' footer statuses get their own dimmed Line.
|
|
10
|
+
- **Extra command**: `extraCommand` runs a shell command and shows its `{ "label": "..." }` output on the first Line.
|
|
11
|
+
- **Simplified Chinese**: `"language": "zh-Hans"`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jarrod Watts (claude-hud)
|
|
4
|
+
Copyright (c) 2026 lkangd
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,210 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-hud-plus
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A [claude-hud](https://github.com/jarrodwatts/claude-hud)-style HUD for [pi](https://pi.dev): it replaces pi's footer with model, context, git, tools, cache and session information, configured with claude-hud's field names.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install npm:pi-hud-plus
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or try it once without installing:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pi -e npm:pi-hud-plus
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The HUD runs only in pi's interactive TUI. Print, JSON and RPC modes are left alone.
|
|
20
|
+
|
|
21
|
+
## Lines and Elements
|
|
22
|
+
|
|
23
|
+
The default `lineLayout` is `"expanded"`: one Line per Element, in `elementOrder`. Lines with nothing to show are left out. Every Line is cut to the terminal width with `…`.
|
|
24
|
+
|
|
25
|
+
| Element | What it shows | Toggled by |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `project` | `[model]` badge, project path, `git:(branch* ↑2 ↓1 [+120 -14])`, then session name, `pi vX`, the Extra command's label, session duration, cost and output speed | `display.showModel`, `display.showProject`, `gitStatus.enabled`, `display.showSessionName`, `display.showVersion`, `extraCommand`, `display.showDuration`, `display.showCost`, `display.showSpeed` |
|
|
28
|
+
| `context` | `Context ██████░░░░ 46%`, coloured by the warning and critical thresholds. At or above the critical threshold it adds the latest reply's `(in: …, cache: …)` split | `display.showContextBar`, `display.contextValue`, `display.showTokenBreakdown` |
|
|
29
|
+
| `promptCache` | `Cache ⏱ 3m 45s`: time left on the prompt cache since the last reply, yellow near the end, then `expired` | `display.showPromptCache`, `display.promptCacheTtlSeconds` |
|
|
30
|
+
| `memory` | `Approx RAM ████░░ 12 GB / 16 GB (75%)`: system RAM. Expanded layout only | `display.showMemoryUsage` |
|
|
31
|
+
| `environment` | `2 AGENTS.md \| 5 skills \| 3 prompts \| 1 MCPs`: what shapes the agent's context. MCPs are the distinct `mcp__<server>__*` tool namespaces | `display.showConfigCounts`, `display.environmentThreshold` |
|
|
32
|
+
| `tools` | Up to two running tools with their target (`◐ bash: npm test`), then finished tools by count (`✓ read ×6`) | `display.showTools`, `display.toolNameMaxLength`, `display.toolsMaxVisible` |
|
|
33
|
+
| `sessionTime` | `Started: 42m ago │ Last reply: 1m ago` | `display.showSessionStartDate`, `display.showLastResponseAt`, `display.timeFormat` |
|
|
34
|
+
|
|
35
|
+
Two Lines aren't Elements and so aren't part of `elementOrder`:
|
|
36
|
+
|
|
37
|
+
- **Session tokens**: `Tokens 722k (in: 41k, out: 19k, cache: 662k)`, summed over the session the way pi's footer sums them. It comes after the Element Lines. Toggled by `display.showSessionTokens`.
|
|
38
|
+
- **Extension statuses**: other extensions' footer statuses, sorted by key, on one dimmed Line. It is always last. Toggled by `display.showExtensionStatuses`.
|
|
39
|
+
|
|
40
|
+
The **Custom line** (`display.customLine`) is static text that goes at the start or end of the `project` Line (the session Line in the compact layout), depending on `display.customLinePosition`.
|
|
41
|
+
|
|
42
|
+
With `"lineLayout": "compact"`, everything goes on one session Line (model badge, context, project and git, then the other enabled Elements), with the tools Line under it. Memory isn't shown, and `elementOrder` and `mergeGroups` don't apply.
|
|
43
|
+
|
|
44
|
+
`display.mergeGroups` joins Elements that sit next to each other in `elementOrder` onto one Line, separated by ` │ `, when they fit. For example, `[["context", "promptCache"]]`. `showSeparators` draws a rule above the tools Line.
|
|
45
|
+
|
|
46
|
+
## Config
|
|
47
|
+
|
|
48
|
+
pi-hud-plus reads two JSON files:
|
|
49
|
+
|
|
50
|
+
- global: `~/.pi/agent/pi-hud-plus.json`
|
|
51
|
+
- project: `<cwd>/.pi/pi-hud-plus.json`
|
|
52
|
+
|
|
53
|
+
The project file is deep-merged over the global one. Objects merge key by key, while arrays and plain values replace. Both files are optional. A file that is missing or doesn't parse counts as empty, so the HUD still renders. Each field is validated on its own: an invalid value falls back to that field's default, and unknown fields are ignored.
|
|
54
|
+
|
|
55
|
+
The files are read when a session starts. After editing one, run `/reload`.
|
|
56
|
+
|
|
57
|
+
### Field reference
|
|
58
|
+
|
|
59
|
+
Top level:
|
|
60
|
+
|
|
61
|
+
| Field | Default | Values |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `language` | `"en"` | `"en"`, `"zh-Hans"` (`"zh"` is accepted as `"zh-Hans"`) |
|
|
64
|
+
| `lineLayout` | `"expanded"` | `"expanded"`, `"compact"` |
|
|
65
|
+
| `showSeparators` | `false` | boolean |
|
|
66
|
+
| `pathLevels` | `1` | `1`, `2`, `3`: how many trailing directories of the cwd to show |
|
|
67
|
+
| `elementOrder` | `["project", "context", "promptCache", "memory", "environment", "tools", "sessionTime"]` | Elements in Line order. Leaving an Element out hides its Line. Unknown ids and duplicates are dropped |
|
|
68
|
+
| `extraCommand` | `""` (off) | shell command, see [Extra command](#extra-command). Global file only |
|
|
69
|
+
|
|
70
|
+
`gitStatus`:
|
|
71
|
+
|
|
72
|
+
| Field | Default | Values |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `enabled` | `true` | boolean. When off, no git commands run |
|
|
75
|
+
| `showDirty` | `true` | boolean: `*` after the branch when the tree is dirty |
|
|
76
|
+
| `showAheadBehind` | `false` | boolean: `↑n ↓n` against the upstream |
|
|
77
|
+
| `showFileStats` | `false` | boolean: line diff `[+n -n]` (expanded) or file counts `!n +n ✘n ?n` (compact) |
|
|
78
|
+
| `branchOverflow` | `"truncate"` | `"truncate"` keeps project and git in one segment; `"wrap"` gives git its own segment |
|
|
79
|
+
| `pushWarningThreshold` | `0` (off) | colour `↑n` with `colors.warning` from this many unpushed commits |
|
|
80
|
+
| `pushCriticalThreshold` | `0` (off) | colour `↑n` with `colors.critical` from this many unpushed commits |
|
|
81
|
+
|
|
82
|
+
`display`:
|
|
83
|
+
|
|
84
|
+
| Field | Default | Values |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `showModel` | `true` | boolean. The badge is prefixed with `provider/` when more than one provider is available, like pi's footer |
|
|
87
|
+
| `modelFormat` | `"full"` | `"full"`; `"compact"` strips a `(… context)` suffix; `"short"` also strips a leading `Claude ` |
|
|
88
|
+
| `modelOverride` | `""` | text shown instead of the model name (max 80 chars) |
|
|
89
|
+
| `showThinkingLevel` | `false` | boolean: `○ low`, `◔ medium`, `◑ high`, `◕ xhigh` in the badge |
|
|
90
|
+
| `showProject` | `true` | boolean |
|
|
91
|
+
| `showSessionName` | `false` | boolean |
|
|
92
|
+
| `showVersion` | `false` | boolean: `pi vX` |
|
|
93
|
+
| `showDuration` | `false` | boolean: `⏱️ 42m` since the session started |
|
|
94
|
+
| `showCost` | `false` | boolean: `Cost $1.87`, with `(sub)` on a subscription |
|
|
95
|
+
| `showSpeed` | `false` | boolean: `out: 61.4 tok/s` of the streaming reply |
|
|
96
|
+
| `showContextBar` | `true` | boolean. Off shows the value only |
|
|
97
|
+
| `contextValue` | `"percent"` | `"percent"`, `"tokens"` (`92k/200k`), `"remaining"`, `"both"` |
|
|
98
|
+
| `contextWarningThreshold` | `70` | 0–100 |
|
|
99
|
+
| `contextCriticalThreshold` | `85` | 0–100 |
|
|
100
|
+
| `showTokenBreakdown` | `true` | boolean: `(in: …, cache: …)` at or above the critical threshold |
|
|
101
|
+
| `showPromptCache` | `false` | boolean |
|
|
102
|
+
| `promptCacheTtlSeconds` | `300` | positive whole number |
|
|
103
|
+
| `showMemoryUsage` | `false` | boolean |
|
|
104
|
+
| `showConfigCounts` | `false` | boolean: the Environment line |
|
|
105
|
+
| `environmentThreshold` | `0` | hide the Environment line until the counts add up to this |
|
|
106
|
+
| `showTools` | `false` | boolean |
|
|
107
|
+
| `toolNameMaxLength` | `0` (no limit) | cut tool names to this many chars. When set, MCP tools show only their tool name |
|
|
108
|
+
| `toolsMaxVisible` | `4` | how many finished tools to list; `0` lists all |
|
|
109
|
+
| `showSessionStartDate` | `false` | boolean |
|
|
110
|
+
| `showLastResponseAt` | `false` | boolean |
|
|
111
|
+
| `timeFormat` | `"relative"` | `"relative"` (`3m ago`), `"absolute"` (`2026-11-14 09:30`), `"both"`; `"elapsed"` and `"elapsedAndAbsolute"` read like `"relative"` and `"both"` |
|
|
112
|
+
| `showSessionTokens` | `false` | boolean |
|
|
113
|
+
| `showExtensionStatuses` | `true` | boolean |
|
|
114
|
+
| `mergeGroups` | `[]` | arrays of at least two Elements, e.g. `[["context", "promptCache"]]` |
|
|
115
|
+
| `customLine` | `""` | static text (max 80 chars) |
|
|
116
|
+
| `customLinePosition` | `"last"` | `"first"`, `"last"` |
|
|
117
|
+
|
|
118
|
+
`colors`: each value is a name (`"dim"`, `"red"`, `"green"`, `"yellow"`, `"magenta"`, `"cyan"`, `"brightBlue"`, `"brightMagenta"`), a 256-colour index (`0`–`255`) or a hex string (`"#rrggbb"`).
|
|
119
|
+
|
|
120
|
+
| Field | Default | Colours |
|
|
121
|
+
|---|---|---|
|
|
122
|
+
| `context` | `"green"` | context value and bar below the warning threshold |
|
|
123
|
+
| `warning` | `"yellow"` | context at or above the warning threshold, cache about to expire |
|
|
124
|
+
| `critical` | `"red"` | context at or above the critical threshold |
|
|
125
|
+
| `model` | `"cyan"` | model badge |
|
|
126
|
+
| `project` | `"yellow"` | project path |
|
|
127
|
+
| `git` | `"magenta"` | `git:(` `)` |
|
|
128
|
+
| `gitBranch` | `"cyan"` | branch and ahead/behind |
|
|
129
|
+
| `label` | `"dim"` | labels and secondary text |
|
|
130
|
+
| `custom` | `208` | Custom line |
|
|
131
|
+
| `barFilled` | `"█"` | one character for the filled part of the bars |
|
|
132
|
+
| `barEmpty` | `"░"` | one character for the empty part of the bars |
|
|
133
|
+
|
|
134
|
+
### Example
|
|
135
|
+
|
|
136
|
+
`~/.pi/agent/pi-hud-plus.json`:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"pathLevels": 2,
|
|
141
|
+
"gitStatus": {
|
|
142
|
+
"showAheadBehind": true,
|
|
143
|
+
"showFileStats": true
|
|
144
|
+
},
|
|
145
|
+
"display": {
|
|
146
|
+
"showThinkingLevel": true,
|
|
147
|
+
"showCost": true,
|
|
148
|
+
"showTools": true,
|
|
149
|
+
"showPromptCache": true,
|
|
150
|
+
"showConfigCounts": true,
|
|
151
|
+
"showSessionTokens": true,
|
|
152
|
+
"mergeGroups": [["context", "promptCache"]]
|
|
153
|
+
},
|
|
154
|
+
"colors": {
|
|
155
|
+
"model": "#a78bfa",
|
|
156
|
+
"barFilled": "■",
|
|
157
|
+
"barEmpty": "□"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Then run `/reload`.
|
|
163
|
+
|
|
164
|
+
## Extra command
|
|
165
|
+
|
|
166
|
+
`extraCommand` runs a shell command (`sh -c`) and shows its label on the `project` Line, or near the end of the compact Line. The command must exit 0 and print JSON with a `label` string:
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{ "extraCommand": "echo '{\"label\": \"on-call: alice\"}'" }
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
It runs when a session starts, after each agent run, and every 30 seconds. Each run has a 3-second timeout. Control and escape characters are stripped from the label, and it is cut to 50 characters. If the command fails, times out or prints anything else, no label is shown.
|
|
173
|
+
|
|
174
|
+
`extraCommand` is **ignored in the project file**. It runs a shell command, and a project file comes with whatever repository you open. Reading it from there would let a cloned repo run commands on your machine just by being opened. Set it in `~/.pi/agent/pi-hud-plus.json`.
|
|
175
|
+
|
|
176
|
+
## Coexisting with other footer extensions
|
|
177
|
+
|
|
178
|
+
pi has one footer, and the last extension to set it wins. Other extensions' footer statuses aren't lost: they show on the HUD's Extension statuses Line.
|
|
179
|
+
|
|
180
|
+
If another footer extension (for example pi-powerbar) takes the footer, pi-hud-plus steps aside. It hides and stops its background work until the next session starts. It also warns once per pi process:
|
|
181
|
+
|
|
182
|
+
> pi-hud-plus: another extension took over pi's footer, so the HUD is hidden. Disable that extension (e.g. pi-powerbar, via `pi config`) to see the HUD.
|
|
183
|
+
|
|
184
|
+
To see the HUD, disable the other footer extension with `pi config`, then start a new session or run `/reload`.
|
|
185
|
+
|
|
186
|
+
## Language
|
|
187
|
+
|
|
188
|
+
`"language": "zh-Hans"` switches the HUD's labels to Simplified Chinese (`上下文`, `3m前`, …). `"zh"` works too. The default is `"en"`. The language is set only in config; pi-hud-plus doesn't detect your locale.
|
|
189
|
+
|
|
190
|
+
## Differences from claude-hud
|
|
191
|
+
|
|
192
|
+
- **No usage limits**: there's no 5h/7d subscription usage, and no external usage snapshots, because pi has no API for them. Every usage field (`showUsage`, `usageValue`, `usageBarEnabled`, `sevenDayThreshold`, `externalUsage*`, `colors.usage`, …) is ignored.
|
|
193
|
+
- **Dropped Elements**: `addedDirs`, `usage`, `agents` and `todos` have no pi equivalent. The output style and Claude Code's mode line are gone too.
|
|
194
|
+
- **Pi equivalents**: `pi vX` instead of `CC vX`; pi's thinking level instead of Claude's effort level; the Environment line counts AGENTS.md files, skills, prompt templates and MCP servers instead of CLAUDE.md, rules, MCPs and hooks.
|
|
195
|
+
- **Renamed fields, no aliases**: `display.showClaudeCodeVersion` is `display.showVersion`, and `display.showEffortLevel` is `display.showThinkingLevel`.
|
|
196
|
+
- **Other dropped fields**: `maxWidth` and `forceMaxWidth` (pi gives the HUD its width), `display.showAddedDirs`, `addedDirsLayout`, `showAgents`, `showTodos`, `showOutputStyle` and `autocompactBuffer`.
|
|
197
|
+
- **Changed defaults**: `mergeGroups` defaults to `[]`, and `elementOrder` has no `usage`, `agents`, `todos` or `addedDirs`.
|
|
198
|
+
- **New fields**: `extraCommand` (claude-hud's `--extra-cmd`, now config, and never read from the project file) and `display.showExtensionStatuses`.
|
|
199
|
+
- **No setup command**: you configure the HUD by editing the JSON files. There's no `/claude-hud:setup`-style command, and no config file watching.
|
|
200
|
+
- **No git files Line**: with `showFileStats` on, claude-hud adds a Line listing the changed files; pi-hud-plus shows only the counts in the git Element.
|
|
201
|
+
- **No branch link**: claude-hud links the branch name to its remote (`branchUrl`) with a terminal hyperlink; pi-hud-plus shows plain text.
|
|
202
|
+
- **`max` thinking level**: pi's `max` level, which claude-hud has no equivalent for, shows as `◕` like `xhigh`.
|
|
203
|
+
- **Chinese relative times**: keep claude-hud's unit style, so `3m前`, not `3分钟前`.
|
|
204
|
+
- A pasted claude-hud config still loads: fields that are unknown or have been dropped are ignored.
|
|
205
|
+
|
|
206
|
+
## Credits and license
|
|
207
|
+
|
|
208
|
+
pi-hud-plus is a port of [claude-hud](https://github.com/jarrodwatts/claude-hud) by Jarrod Watts. The render code, colours, layouts, config fields and most of the tests come from it.
|
|
209
|
+
|
|
210
|
+
[MIT](LICENSE). Copyright Jarrod Watts (claude-hud) and lkangd.
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-hud-plus",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A claude-hud-style HUD for pi's footer",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "lkangd",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/lkangd/pi-hud-plus.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/lkangd/pi-hud-plus#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/lkangd/pi-hud-plus/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"pi-package",
|
|
18
|
+
"pi-extension",
|
|
19
|
+
"hud",
|
|
20
|
+
"statusline"
|
|
21
|
+
],
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"README.md",
|
|
25
|
+
"CHANGELOG.md"
|
|
26
|
+
],
|
|
27
|
+
"pi": {
|
|
28
|
+
"extensions": [
|
|
29
|
+
"./src/index.ts"
|
|
30
|
+
],
|
|
31
|
+
"image": "https://raw.githubusercontent.com/lkangd/pi-hud-plus/main/docs/screenshot.png"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"test": "node --test --import tsx 'test/*.test.ts'",
|
|
36
|
+
"prepublishOnly": "npm run typecheck && npm test"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
40
|
+
"@earendil-works/pi-tui": "*"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@earendil-works/pi-coding-agent": "^1.5.2",
|
|
44
|
+
"@earendil-works/pi-tui": "^1.5.2",
|
|
45
|
+
"@types/node": "^22.20.5",
|
|
46
|
+
"tsx": "^4.23.15",
|
|
47
|
+
"typescript": "^5.9.3"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/clock.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HudConfig } from "./config.ts";
|
|
2
|
+
|
|
3
|
+
/** Whether any enabled Element changes with time alone, so the HUD needs the clock. Add new ticking Elements here. */
|
|
4
|
+
export function hasTickingElement({ display }: HudConfig): boolean {
|
|
5
|
+
const relativeTimes = display.timeFormat !== "absolute" && (display.showSessionStartDate || display.showLastResponseAt);
|
|
6
|
+
return display.showDuration || relativeTimes || display.showPromptCache || display.showMemoryUsage;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** A 1s clock that doesn't keep pi alive. Returns its stop function. */
|
|
10
|
+
export function startClock(onTick: (now: number) => void): () => void {
|
|
11
|
+
const timer = setInterval(() => onTick(Date.now()), 1000);
|
|
12
|
+
timer.unref();
|
|
13
|
+
return () => clearInterval(timer);
|
|
14
|
+
}
|