useful-pi-extensions 1.1.0 → 1.1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "useful-pi-extensions",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A small collection of pi extensions, installed with one command — a labelled status line with context pressure, cache, cost, effort, TTFT and tokens/sec.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* stepStartTime; decodeMs = completedTime - firstTokenTime; tok/s = usage.output / (decodeMs / 1000)
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
import { readFile, stat } from 'node:fs/promises'
|
|
21
22
|
import { homedir } from 'node:os'
|
|
22
23
|
import { join } from 'node:path'
|
|
23
24
|
|
|
@@ -58,8 +59,19 @@ const CONFIG_PATH = join(homedir(), '.pi', 'agent', 'statusline.json')
|
|
|
58
59
|
* bug. Editing the file therefore takes effect on `/reload`.
|
|
59
60
|
*/
|
|
60
61
|
async function loadCurrency(notify: (message: string) => void): Promise<Currency> {
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
try {
|
|
63
|
+
await stat(CONFIG_PATH)
|
|
64
|
+
} catch {
|
|
65
|
+
// No config file is the normal case, and it means USD.
|
|
66
|
+
return USD
|
|
67
|
+
}
|
|
68
|
+
let text: string
|
|
69
|
+
try {
|
|
70
|
+
text = await readFile(CONFIG_PATH, 'utf8')
|
|
71
|
+
} catch {
|
|
72
|
+
notify('statusline.json exists but could not be read, showing USD')
|
|
73
|
+
return USD
|
|
74
|
+
}
|
|
63
75
|
const { currency, problem } = currencyFromConfig(text)
|
|
64
76
|
if (problem !== null) notify(problem)
|
|
65
77
|
return currency
|