@lokiyou/pi-nano-footer 0.15.3 → 0.15.5

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 (2) hide show
  1. package/index.ts +21 -13
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -14,6 +14,7 @@ const icons = {
14
14
  model: "\uec19", // nf-md-chip
15
15
  mcp: "\u{f048d}", // nf-md-server-network
16
16
  folder: "\uf115", // nf-fa-folder_open
17
+ thinking: "\uf0eb", // nf-fa-lightbulb
17
18
  context: "\ue70f", // nf-dev-database
18
19
  cache: "\uf1c0", // nf-fa-database
19
20
  input: "\uf090", // nf-fa-sign_in
@@ -163,25 +164,24 @@ function ansi(hex: string, text: string): string {
163
164
  return `\x1b[38;2;${r};${g};${b}m${text}\x1b[0m`;
164
165
  }
165
166
 
167
+ function paint(hex: string, text: string, bold = false): string {
168
+ return bold ? `\x1b[1m${ansi(hex, text)}` : ansi(hex, text);
169
+ }
170
+
166
171
  /** 渲染思考等级 */
167
172
  function renderThinkingN(level: string): string {
168
- const label = level === "minimal" ? "min"
169
- : level === "medium" ? "med"
170
- : level;
171
- const text = `think:${label}`;
172
-
173
173
  switch (level) {
174
174
  case "high":
175
175
  case "xhigh":
176
- return rainbow(text);
177
- case "minimal":
178
- return ansi(C.thinkingMinimal, text);
179
- case "low":
180
- return ansi(C.thinkingLow, text);
176
+ return paint("#fff6b0", icons.thinking, true);
181
177
  case "medium":
182
- return ansi(C.thinkingMedium, text);
178
+ return paint(C.thinkingMedium, icons.thinking, true);
179
+ case "low":
180
+ return paint(C.thinkingLow, icons.thinking);
181
+ case "minimal":
182
+ return paint(C.thinkingMinimal, icons.thinking);
183
183
  default:
184
- return ansi(C.thinking, text);
184
+ return paint(C.thinking, icons.thinking);
185
185
  }
186
186
  }
187
187
 
@@ -194,7 +194,7 @@ function renderContextN(ctx: any): string {
194
194
  : pct >= 70 ? C.contextWarn
195
195
  : C.context;
196
196
  const maxStr = ctx.model?.contextWindow
197
- ? `/${(ctx.model.contextWindow / 1_000_000).toFixed(1)}M`
197
+ ? `/${formatContextWindow(ctx.model.contextWindow)}`
198
198
  : "";
199
199
  return ansi(color, `${icons.context} ${pct?.toFixed(1) ?? "?"}%${maxStr}`);
200
200
  }
@@ -256,6 +256,14 @@ function fmt(n: number): string {
256
256
  return `${(n / 1_000_000).toFixed(1)}m`;
257
257
  }
258
258
 
259
+ function formatContextWindow(n: number): string {
260
+ if (n < 1000) return `${n}`;
261
+ if (n < 1_000_000) return `${Math.floor(n / 1000)}K`;
262
+ const scaled = n / 1_000_000;
263
+ const text = Number.isInteger(scaled) ? `${scaled.toFixed(0)}` : scaled.toFixed(scaled >= 10 ? 0 : 1).replace(/\.0$/, "");
264
+ return `${text}M`;
265
+ }
266
+
259
267
  /** 缩短模型名 */
260
268
  function shorten(m: string): string {
261
269
  return m
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokiyou/pi-nano-footer",
3
- "version": "0.15.3",
3
+ "version": "0.15.5",
4
4
  "description": "Lightweight powerline-style footer for Pi Coding Agent that shows model, thinking level, directory, MCP status, context usage, tokens, and cost while keeping the built-in Working indicator.",
5
5
  "type": "module",
6
6
  "keywords": [