@each1024/pi-mini-mode 2.0.15 → 2.0.16
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/extensions/footer-status.ts +4 -2
- package/lib/minimal-output.ts +12 -5
- package/lib/settings.html +7 -2
- package/lib/settings.ts +19 -2
- package/package.json +3 -2
|
@@ -8,7 +8,7 @@ import { installTerminalCapabilities } from "../lib/terminal-capabilities.ts";
|
|
|
8
8
|
import { linkMessageFiles } from "../lib/file-links.ts";
|
|
9
9
|
import attachFooterTidy from "../lib/footer-tidy.ts";
|
|
10
10
|
import attachTitlePlain from "../lib/title-plain.ts";
|
|
11
|
-
import { COPY, DEFAULT_SETTINGS, FOOTER_FIELDS, FOOTER_STYLE_OPTIONS, RECOMMENDED_THEMES, SETTING_IDS, isLegacyMinimalSetting, isRecordLimit, loadSettings, parseSettings, saveSettings, settingsItems, settingsPath, type MiniLensSettings, type RecommendedTheme } from "../lib/settings.ts";
|
|
11
|
+
import { COPY, DEFAULT_SETTINGS, FOOTER_FIELDS, FOOTER_STYLE_OPTIONS, RECOMMENDED_THEMES, SETTING_IDS, isLegacyMinimalSetting, isRecordLimit, isUiLanguage, loadSettings, parseSettings, saveSettings, settingsItems, settingsPath, uiLanguage, type MiniLensSettings, type RecommendedTheme } from "../lib/settings.ts";
|
|
12
12
|
import { attachSpeedHover, speedHit, type SpeedHover } from "../lib/speed-popup.ts";
|
|
13
13
|
import { createTokenSpeedTracker, SPEED_REFRESH_MS } from "../lib/token-speed.ts";
|
|
14
14
|
import { addUsage, cacheWaste, EMPTY_USAGE, finiteNumber, formatSpeed, sessionUsage, type UsageLike } from "../lib/usage.ts";
|
|
@@ -178,7 +178,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
178
178
|
cwd: () => ctx.cwd,
|
|
179
179
|
requestRender: () => tui.requestRender(),
|
|
180
180
|
write: data => tui.terminal.write(data),
|
|
181
|
-
}, () => settings["pi-mini-mode-minimal-record-limit"]);
|
|
181
|
+
}, () => settings["pi-mini-mode-minimal-record-limit"], () => uiLanguage(settings));
|
|
182
182
|
// Native info notifications use dim; warning/error notifications retain
|
|
183
183
|
// their position in the transcript. No plugin names or message matching.
|
|
184
184
|
const dimPrefix = theme.fg("dim", "\u0000").split("\u0000")[0];
|
|
@@ -347,6 +347,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
347
347
|
if (entry !== "hover" && entry !== "inline") throw new TypeError("Invalid preview mode");
|
|
348
348
|
} else if (key === "pi-mini-mode-minimal-record-limit") {
|
|
349
349
|
if (!isRecordLimit(entry)) throw new TypeError("Invalid record limit");
|
|
350
|
+
} else if (key === "pi-mini-mode-language") {
|
|
351
|
+
if (!isUiLanguage(entry)) throw new TypeError("Invalid language");
|
|
350
352
|
} else if (isLegacyMinimalSetting(key) && typeof entry === "boolean") {
|
|
351
353
|
// Accept stale settings pages; these former child switches no longer gate output.
|
|
352
354
|
continue;
|
package/lib/minimal-output.ts
CHANGED
|
@@ -7,12 +7,18 @@ import { linkToolFiles } from "./file-links.ts";
|
|
|
7
7
|
import { diagramMarkdown, isFencedMarkdown, renderMinimalMarkdown } from "./minimal-markdown.ts";
|
|
8
8
|
import { minimalSurface, paintExpandedHeading } from "./minimal-theme.ts";
|
|
9
9
|
import { formatElapsed, formatThinkingElapsed, formatToolElapsed, piLoopSummary, type MinimalTurn } from "./minimal-turns.ts";
|
|
10
|
-
import { DEFAULT_SETTINGS } from "./settings.ts";
|
|
10
|
+
import { DEFAULT_SETTINGS, uiLanguage, type UiLanguage } from "./settings.ts";
|
|
11
11
|
import { thinkingPreview } from "./thinking-preview.ts";
|
|
12
12
|
import type { NoticeRows, TurnNotices } from "./transcript-adapter.ts";
|
|
13
13
|
import { addUsage, EMPTY_USAGE, formatTokens } from "./usage.ts";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/** Shown when a thinking block has no displayable summary. */
|
|
16
|
+
const THINKING_FALLBACK: Record<UiLanguage, Record<"active" | "aborted" | "error" | "ended", string>> = {
|
|
17
|
+
zh: { active: "正在思考,等待可显示摘要", aborted: "思考已中断,未返回可显示摘要", error: "思考失败,未返回可显示摘要", ended: "思考已结束,未返回可显示摘要" },
|
|
18
|
+
en: { active: "Waiting for a displayable summary", aborted: "Interrupted, no displayable summary returned", error: "Failed, no displayable summary returned", ended: "Finished, no displayable summary returned" },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], getTurns: () => MinimalTurn[], isExpanded: () => boolean = () => false, showUsage: () => boolean = () => true, subAgentsExpanded: () => boolean = () => false, agentDeadlines = new Map<string, number>(), transformText: (text: string) => string = text => text, imageOptions?: { cwd(): string; requestRender(): void; write?(data: string): void }, getRecordLimit: () => number = () => DEFAULT_SETTINGS["pi-mini-mode-minimal-record-limit"], getLanguage: () => UiLanguage = () => uiLanguage({})) {
|
|
16
22
|
const placeholderText = (text: string) => imageOptions ? imagePlaceholders(text, imageOptions.cwd()) : text;
|
|
17
23
|
const markdown = (text: string, width: number, process = false) => renderMinimalMarkdown(text, width, getMarkdownTheme(), theme.getBgAnsi?.("userMessageBg") ?? "",
|
|
18
24
|
{ color: (value) => theme.fg(process ? "muted" : "text", value) }, (source, available) => transformText(placeholderText(diagramMarkdown(source, available))));
|
|
@@ -316,9 +322,10 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
316
322
|
const display = reuse ? cached.text : thinkingPreview(entry.detail, available, previewRows, activeThinking);
|
|
317
323
|
if (!reuse) thinkingPreviews.set(entry.id, { text: display, source: entry.detail, width: available, rows: previewRows, live: activeThinking });
|
|
318
324
|
const outcome = turn.thinkingOutcomes?.[entry.processIndex];
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
: outcome === "
|
|
325
|
+
const fallbackCopy = THINKING_FALLBACK[getLanguage()];
|
|
326
|
+
const fallback = activeThinking ? fallbackCopy.active
|
|
327
|
+
: outcome === "aborted" ? fallbackCopy.aborted
|
|
328
|
+
: outcome === "error" ? fallbackCopy.error : fallbackCopy.ended;
|
|
322
329
|
const color = entry.state === "error" ? "error" : activeThinking ? "accent" : "muted";
|
|
323
330
|
const rows = available > 0
|
|
324
331
|
? renderMinimalMarkdown(display || fallback, available, getMarkdownTheme(), theme.getBgAnsi?.("userMessageBg") ?? "",
|
package/lib/settings.html
CHANGED
|
@@ -275,7 +275,7 @@ $('copyPrompt').onclick=async()=>{
|
|
|
275
275
|
clearTimeout(copyTimer);
|
|
276
276
|
copyTimer=setTimeout(()=>button.textContent=t('copyPrompt'),1600);
|
|
277
277
|
};
|
|
278
|
-
function setLang(next){lang=next;localStorage.piMiniModeLang=lang;render()}
|
|
278
|
+
function setLang(next){lang=next;localStorage.piMiniModeLang=lang;if(state){state['pi-mini-mode-language']=lang;render();change()}else render()}
|
|
279
279
|
$('lang-zh').onclick=()=>setLang('zh');
|
|
280
280
|
$('lang-en').onclick=()=>setLang('en');
|
|
281
281
|
$('retry').onclick=save;
|
|
@@ -283,6 +283,11 @@ function mergeOrder(base,all){const next=[...new Set((base||[]).filter(id=>(all|
|
|
|
283
283
|
$('reset').onclick=()=>{if(!confirm(t('confirmReset')))return;state={...data.defaults};order=mergeOrder(data.order,data.order);render();change()};
|
|
284
284
|
window.addEventListener('beforeunload',event=>{if(dirty||saving){event.preventDefault();event.returnValue=''}});
|
|
285
285
|
applyLang();status(t('connecting'));
|
|
286
|
-
request('GET').then(value=>{data=value;state={...data.settings};order=mergeOrder(state.footerOrder||data.order,data.order);
|
|
286
|
+
request('GET').then(value=>{data=value;state={...data.settings};order=mergeOrder(state.footerOrder||data.order,data.order);
|
|
287
|
+
// The saved choice drives Pi's transcript copy; a page-only choice from older versions is saved once.
|
|
288
|
+
const saved=state['pi-mini-mode-language'],local=localStorage.piMiniModeLang;
|
|
289
|
+
if(saved==='en'||saved==='zh'){lang=saved;localStorage.piMiniModeLang=lang}
|
|
290
|
+
render();$('reset').disabled=false;status('');
|
|
291
|
+
if(!saved&&(local==='en'||local==='zh')){state['pi-mini-mode-language']=local;change()}}).catch(error=>status(error instanceof TypeError?t('reconnect'):error.message||t('reconnect'),true));
|
|
287
292
|
</script>
|
|
288
293
|
</html>
|
package/lib/settings.ts
CHANGED
|
@@ -28,6 +28,22 @@ export interface MiniLensSettings {
|
|
|
28
28
|
"pi-mini-mode-image-preview": "hover" | "inline";
|
|
29
29
|
onboardingCompleted: boolean;
|
|
30
30
|
footerOrder?: string[];
|
|
31
|
+
/** Language picked in the settings page; unset follows the system locale. */
|
|
32
|
+
"pi-mini-mode-language"?: UiLanguage;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type UiLanguage = "en" | "zh";
|
|
36
|
+
|
|
37
|
+
export function isUiLanguage(value: unknown): value is UiLanguage {
|
|
38
|
+
return value === "en" || value === "zh";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The saved choice wins; otherwise a zh* system locale keeps Chinese and everything else is English. */
|
|
42
|
+
export function uiLanguage(settings: Pick<MiniLensSettings, "pi-mini-mode-language">, env: NodeJS.ProcessEnv = process.env): UiLanguage {
|
|
43
|
+
const saved = settings["pi-mini-mode-language"];
|
|
44
|
+
if (saved) return saved;
|
|
45
|
+
const locale = env.LC_ALL || env.LC_MESSAGES || env.LANG || Intl.DateTimeFormat().resolvedOptions().locale;
|
|
46
|
+
return /^zh/i.test(locale) ? "zh" : "en";
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
export const DEFAULT_SETTINGS: Readonly<MiniLensSettings> = {
|
|
@@ -53,7 +69,7 @@ export const DEFAULT_SETTINGS: Readonly<MiniLensSettings> = {
|
|
|
53
69
|
onboardingCompleted: false,
|
|
54
70
|
};
|
|
55
71
|
|
|
56
|
-
export const SETTING_IDS = Object.keys(DEFAULT_SETTINGS) as Array<Exclude<keyof MiniLensSettings, "footerOrder">>;
|
|
72
|
+
export const SETTING_IDS = Object.keys(DEFAULT_SETTINGS) as Array<Exclude<keyof MiniLensSettings, "footerOrder" | "pi-mini-mode-language">>;
|
|
57
73
|
export const FOOTER_FIELDS = ["project-branch", "model", "thinking", "branch", "session-tokens", "cache-tokens", "cache-miss", "ch", "cost", "mcp", "context", "context-percent", "speed"] as const;
|
|
58
74
|
export const FOOTER_STYLE_OPTIONS = ["context-dots", "speed-unit"] as const;
|
|
59
75
|
|
|
@@ -96,6 +112,7 @@ export function parseSettings(value: unknown): MiniLensSettings {
|
|
|
96
112
|
typeof id === "string" && (FOOTER_FIELDS as readonly string[]).includes(id)))];
|
|
97
113
|
for (const id of FOOTER_FIELDS) if (!settings.footerOrder.includes(id)) settings.footerOrder.push(id);
|
|
98
114
|
}
|
|
115
|
+
if (isUiLanguage(candidate["pi-mini-mode-language"])) settings["pi-mini-mode-language"] = candidate["pi-mini-mode-language"];
|
|
99
116
|
if (settings["pi-mini-mode-branch-show"]) settings["pi-mini-mode-project-branch-show"] = false;
|
|
100
117
|
return settings;
|
|
101
118
|
}
|
|
@@ -140,7 +157,7 @@ export function isLegacyMinimalSetting(id: string): boolean {
|
|
|
140
157
|
|
|
141
158
|
export function settingsItems(settings: MiniLensSettings): SettingItem[] {
|
|
142
159
|
const values = ["on", "off"];
|
|
143
|
-
const labels: Record<Exclude<keyof MiniLensSettings, "onboardingCompleted" | "footerOrder" | "pi-mini-mode-image-preview" | "pi-mini-mode-minimal-record-limit">, string> = {
|
|
160
|
+
const labels: Record<Exclude<keyof MiniLensSettings, "onboardingCompleted" | "footerOrder" | "pi-mini-mode-language" | "pi-mini-mode-image-preview" | "pi-mini-mode-minimal-record-limit">, string> = {
|
|
144
161
|
"pi-mini-mode-project-branch-show": "显示项目名称和分支(互斥)",
|
|
145
162
|
"pi-mini-mode-branch-show": "仅显示分支(思考等级后,互斥)",
|
|
146
163
|
"pi-mini-mode-model-show": COPY.model, "pi-mini-mode-thinking-show": COPY.thinking, "pi-mini-mode-session-tokens-show": COPY.total, "pi-mini-mode-cache-tokens-show": COPY.cached, "pi-mini-mode-cache-miss-show": COPY.miss, "pi-mini-mode-ch-show": COPY.cacheHit, "pi-mini-mode-cost-show": COPY.price, "pi-mini-mode-mcp-show": COPY.mcp, "pi-mini-mode-context-show": COPY.context, "pi-mini-mode-context-dots-show": COPY.dots, "pi-mini-mode-context-percent-show": COPY.percent, "pi-mini-mode-speed-show": COPY.speed, "pi-mini-mode-speed-unit-show": COPY.speedUnit, "pi-mini-mode-minimal-show": COPY.minimal, "pi-mini-mode-input-enhancements": COPY.inputEnhancements,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@each1024/pi-mini-mode",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
4
4
|
"description": "A compact Pi footer with live usage metrics, theme-aware settings previews, and configurable progress bars.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"check": "
|
|
7
|
+
"check": "node scripts/typecheck.mjs --noEmit -p tsconfig.json",
|
|
8
8
|
"test": "node scripts/check-focused.mjs",
|
|
9
9
|
"check:focused": "node scripts/check-focused.mjs",
|
|
10
10
|
"check:syntax": "node scripts/check-syntax.mjs",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@earendil-works/pi-server": "0.85.0",
|
|
58
58
|
"@earendil-works/pi-tui": "^0.85.0",
|
|
59
59
|
"@types/node": "^26.4.1",
|
|
60
|
+
"tsrs": "0.18.0-ts7.1.0-dev.20260929",
|
|
60
61
|
"typescript": "^5.9.3"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|