pi-minimal-footer 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 +41 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/extensions/index.ts +226 -0
- package/package.json +33 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-06-15
|
|
11
|
+
|
|
12
|
+
First npm-ready release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Minimal footer extension for pi — replaces the default footer with a clean, compact status line
|
|
17
|
+
- **Working directory** segment — shows relative path from home (`~/...`)
|
|
18
|
+
- **Active skills** segment — shows extension statuses
|
|
19
|
+
- **Git branch** segment — current branch with Nerd Fonts icon (``)
|
|
20
|
+
- **Model** segment — active model ID
|
|
21
|
+
- **Context usage** segment — tokens used / context window (e.g. `12/128k`)
|
|
22
|
+
- **Configuration** — all segments individually toggleable via `~/.pi/agent/settings.json`
|
|
23
|
+
- **`/minfooter` command** — toggle the extension on/off from chat
|
|
24
|
+
- MIT License
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Context usage display deduplicates `k`/`M` suffix — shows `4/200k` instead of `4k/200k`
|
|
29
|
+
- Context usage format removes spaces around `/` separator
|
|
30
|
+
- README updated with Nerd Fonts git icon and npm install instructions
|
|
31
|
+
- Package metadata expanded for npm release (`author`, `files`, `engines`, `keywords`, `homepage`, `bugs`)
|
|
32
|
+
|
|
33
|
+
## [0.0.0] - 2026-06-13
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- Project scaffold — `extensions/index.ts` with basic footer structure, `package.json` with pi extension manifest, `README.md`, `LICENSE` (MIT)
|
|
38
|
+
|
|
39
|
+
[Unreleased]: https://github.com/Ryu-CZ/pi-minimal-footer/compare/v0.1.0...HEAD
|
|
40
|
+
[0.1.0]: https://github.com/Ryu-CZ/pi-minimal-footer/compare/v0.0.0...v0.1.0
|
|
41
|
+
[0.0.0]: https://github.com/Ryu-CZ/pi-minimal-footer/releases/tag/v0.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ryu-CZ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# pi-minimal-footer
|
|
2
|
+
|
|
3
|
+
A minimal footer extension for [pi](https://github.com/earendil-works/pi-coding-agent) that replaces the default footer with a clean, compact status line:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
~/path/to/dir (skill1 | skill2) main sonnet 12/128k
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# From npm (recommended)
|
|
13
|
+
pi install npm:pi-minimal-footer
|
|
14
|
+
|
|
15
|
+
# From git
|
|
16
|
+
pi install git:github.com/Ryu-CZ/pi-minimal-footer
|
|
17
|
+
|
|
18
|
+
# Manual — copy into your extensions directory
|
|
19
|
+
cp -r extensions/* ~/.pi/agent/extensions/
|
|
20
|
+
|
|
21
|
+
# Development — symlink for live edits
|
|
22
|
+
ln -s "$PWD/extensions" ~/.pi/agent/extensions/minimal-footer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **Working directory** — relative path from home (`~/...`)
|
|
28
|
+
- **Active skills** — extension statuses from `ctx.ui.setStatus()`
|
|
29
|
+
- **Git branch** — current branch name
|
|
30
|
+
- **Model** — active model ID
|
|
31
|
+
- **Context usage** — tokens used / context window (e.g. `12/128k`)
|
|
32
|
+
|
|
33
|
+
## Commands
|
|
34
|
+
|
|
35
|
+
| Command | Description |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `/minfooter` | Toggle the extension on/off |
|
|
38
|
+
| `/minfooter on` | Enable |
|
|
39
|
+
| `/minfooter off` | Disable |
|
|
40
|
+
|
|
41
|
+
> The `/minfooter` command only controls the `enabled` setting. To tweak individual segments (path, model, etc.), edit `~/.pi/agent/settings.json` directly.
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Settings are persisted in `~/.pi/agent/settings.json` under the `minFooter` key:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"minFooter": {
|
|
50
|
+
"enabled": true,
|
|
51
|
+
"showGitBranch": true,
|
|
52
|
+
"showSkills": true,
|
|
53
|
+
"showPath": true,
|
|
54
|
+
"showModel": true,
|
|
55
|
+
"showContext": true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Edit the file directly to show or hide individual segments. The `/minfooter` command is a shortcut that toggles only the `enabled` flag.
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal footer — replaces pi's default footer with a clean status line:
|
|
3
|
+
*
|
|
4
|
+
* ~/path/to/dir (skill1 | skill2) main sonnet 12k / 128k
|
|
5
|
+
*
|
|
6
|
+
* Settings are persisted in ~/.pi/agent/settings.json under "minFooter".
|
|
7
|
+
*
|
|
8
|
+
* Commands:
|
|
9
|
+
* /minfooter — toggle on/off
|
|
10
|
+
* /minfooter on|off — force state
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ExtensionAPI, ExtensionContext, ReadonlyFooterDataProvider } from "@earendil-works/pi-coding-agent";
|
|
14
|
+
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
15
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
|
|
16
|
+
import { join, dirname } from "node:path";
|
|
17
|
+
import { homedir } from "node:os";
|
|
18
|
+
|
|
19
|
+
// ── Settings ──────────────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
interface Settings {
|
|
22
|
+
minFooter?: {
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
showGitBranch?: boolean;
|
|
25
|
+
showSkills?: boolean;
|
|
26
|
+
showPath?: boolean;
|
|
27
|
+
showModel?: boolean;
|
|
28
|
+
showContext?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const DEFAULT_SETTINGS: Settings["minFooter"] = {
|
|
33
|
+
enabled: true,
|
|
34
|
+
showGitBranch: true,
|
|
35
|
+
showSkills: true,
|
|
36
|
+
showPath: true,
|
|
37
|
+
showModel: true,
|
|
38
|
+
showContext: true,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function settingsPath(): string {
|
|
42
|
+
return join(homedir(), ".pi", "agent", "settings.json");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function readSettings(): Settings {
|
|
46
|
+
try {
|
|
47
|
+
if (!existsSync(settingsPath())) return {};
|
|
48
|
+
return JSON.parse(readFileSync(settingsPath(), "utf-8")) as Settings;
|
|
49
|
+
} catch {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function writeSettings(patch: Partial<Settings>): void {
|
|
55
|
+
try {
|
|
56
|
+
const path = settingsPath();
|
|
57
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
58
|
+
const current = readSettings();
|
|
59
|
+
writeFileSync(path, JSON.stringify({ ...current, ...patch }, null, 2) + "\n");
|
|
60
|
+
} catch {
|
|
61
|
+
// best-effort
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function readEnabled(): boolean {
|
|
66
|
+
const s = readSettings();
|
|
67
|
+
return s.minFooter?.enabled !== false; // default to true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function readConfig(): Settings["minFooter"] {
|
|
71
|
+
const s = readSettings();
|
|
72
|
+
return { ...DEFAULT_SETTINGS, ...s.minFooter };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function writeEnabled(v: boolean): void {
|
|
76
|
+
const cfg = readConfig();
|
|
77
|
+
cfg.enabled = v;
|
|
78
|
+
writeSettings({ minFooter: cfg });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ── Formatting helpers ────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
function formatSize(n: number | null | undefined): string {
|
|
84
|
+
if (n == null) return "?";
|
|
85
|
+
if (n >= 1_000_000) return `${Math.round(n / 1_000_000)}M`;
|
|
86
|
+
if (n >= 1_000) return `${Math.round(n / 1_000)}k`;
|
|
87
|
+
return String(n);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ── State ─────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
let enabled = readEnabled();
|
|
93
|
+
let config = readConfig();
|
|
94
|
+
let state = {
|
|
95
|
+
cwd: process.cwd(),
|
|
96
|
+
model: "no-model",
|
|
97
|
+
context: "?",
|
|
98
|
+
branch: "",
|
|
99
|
+
footerData: null as ReadonlyFooterDataProvider | null,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function updateState(ctx: ExtensionContext): void {
|
|
103
|
+
state.cwd = ctx.cwd ?? process.cwd();
|
|
104
|
+
state.model = ctx.model?.id ?? "no-model";
|
|
105
|
+
const usage = ctx.getContextUsage();
|
|
106
|
+
if (usage) {
|
|
107
|
+
const fTokens = formatSize(usage.tokens);
|
|
108
|
+
const fWindow = formatSize(usage.contextWindow);
|
|
109
|
+
const lastT = fTokens[fTokens.length - 1];
|
|
110
|
+
const lastW = fWindow[fWindow.length - 1];
|
|
111
|
+
// Deduplicate k/M suffix: show suffix only on denominator when both use the same unit
|
|
112
|
+
if ((lastT === "k" || lastT === "M") && lastT === lastW) {
|
|
113
|
+
state.context = `${fTokens.slice(0, -1)}/${fWindow}`;
|
|
114
|
+
} else {
|
|
115
|
+
state.context = `${fTokens}/${fWindow}`;
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
state.context = "?";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ── Footer builders ───────────────────────────────────────────────────
|
|
123
|
+
|
|
124
|
+
function buildLeft(): string {
|
|
125
|
+
if (!config.showPath) return "";
|
|
126
|
+
const home = homedir();
|
|
127
|
+
if (state.cwd.startsWith(home)) {
|
|
128
|
+
return "~" + state.cwd.slice(home.length);
|
|
129
|
+
}
|
|
130
|
+
return state.cwd;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function buildRight(footerData: ReadonlyFooterDataProvider): string {
|
|
134
|
+
const segments: string[] = [];
|
|
135
|
+
|
|
136
|
+
if (config.showSkills) {
|
|
137
|
+
const statuses = footerData.getExtensionStatuses();
|
|
138
|
+
if (statuses.size > 0) {
|
|
139
|
+
segments.push("(" + [...statuses.values()].join(" | ") + ")");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (config.showGitBranch) {
|
|
144
|
+
const branch = footerData.getGitBranch();
|
|
145
|
+
if (branch) segments.push(` ${branch}`);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (config.showModel) {
|
|
149
|
+
segments.push(state.model);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (config.showContext) {
|
|
153
|
+
segments.push(state.context);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return segments.join(" ");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ── Extension ─────────────────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
export default function (pi: ExtensionAPI) {
|
|
162
|
+
function setFooter(ctx: ExtensionContext): void {
|
|
163
|
+
updateState(ctx);
|
|
164
|
+
config = readConfig(); // re-read on each set
|
|
165
|
+
|
|
166
|
+
if (!ctx.hasUI) return;
|
|
167
|
+
|
|
168
|
+
if (enabled) {
|
|
169
|
+
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
170
|
+
state.footerData = footerData;
|
|
171
|
+
|
|
172
|
+
const unsub = footerData.onBranchChange(() => tui.requestRender());
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
render(width: number): string[] {
|
|
176
|
+
const left = buildLeft();
|
|
177
|
+
const right = buildRight(footerData);
|
|
178
|
+
const leftW = visibleWidth(left);
|
|
179
|
+
const rightW = visibleWidth(right);
|
|
180
|
+
const gap = Math.max(1, width - leftW - rightW);
|
|
181
|
+
const spacer = " ".repeat(gap);
|
|
182
|
+
const line = theme.fg("dim", `${left}${spacer}${right}`);
|
|
183
|
+
return [line];
|
|
184
|
+
},
|
|
185
|
+
invalidate(): void {},
|
|
186
|
+
dispose: unsub,
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
} else {
|
|
190
|
+
ctx.ui.setFooter(undefined);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ── Lifecycle events ────────────────────────────────────────────────
|
|
195
|
+
|
|
196
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
197
|
+
enabled = readEnabled();
|
|
198
|
+
setFooter(ctx);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
pi.on("model_select", async (_event, ctx) => {
|
|
202
|
+
setFooter(ctx);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
pi.on("message_end", async (_event, ctx) => {
|
|
206
|
+
setFooter(ctx);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
pi.on("session_compact", async (_event, ctx) => {
|
|
210
|
+
setFooter(ctx);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// ── Command ─────────────────────────────────────────────────────────
|
|
214
|
+
|
|
215
|
+
pi.registerCommand("minfooter", {
|
|
216
|
+
description: "Toggle minimal footer",
|
|
217
|
+
handler: async (args, ctx) => {
|
|
218
|
+
if (args === "on") enabled = true;
|
|
219
|
+
else if (args === "off") enabled = false;
|
|
220
|
+
else enabled = !enabled;
|
|
221
|
+
writeEnabled(enabled);
|
|
222
|
+
setFooter(ctx);
|
|
223
|
+
ctx.ui.notify(`Minimal footer ${enabled ? "enabled" : "disabled"}`, "info");
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-minimal-footer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A minimal footer extension for pi — clean status line with path, skills, model, and context usage.",
|
|
5
|
+
"keywords": ["pi-package", "pi-extension", "pi", "footer", "minimal"],
|
|
6
|
+
"homepage": "https://github.com/Ryu-CZ/pi-minimal-footer#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/Ryu-CZ/pi-minimal-footer/issues"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "Ryu-CZ <thandeus@gmail.com> (https://github.com/Ryu-CZ)",
|
|
12
|
+
"files": [
|
|
13
|
+
"CHANGELOG.md",
|
|
14
|
+
"extensions/",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"README.md",
|
|
17
|
+
"package.json"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/Ryu-CZ/pi-minimal-footer.git"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
28
|
+
"@earendil-works/pi-tui": "*"
|
|
29
|
+
},
|
|
30
|
+
"pi": {
|
|
31
|
+
"extensions": ["./extensions"]
|
|
32
|
+
}
|
|
33
|
+
}
|