@vanillagreen/pi-qol 2.0.0 → 2.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/README.md +31 -102
- package/extensions/qol/bridges.ts +19 -0
- package/extensions/qol/budget-guard-runtime.ts +1 -1
- package/extensions/qol/compaction-handoff.ts +9 -8
- package/extensions/qol/compaction.ts +5 -0
- package/extensions/qol/constants.ts +1 -0
- package/extensions/qol/editor.ts +1 -1
- package/extensions/qol/glyphs.ts +1 -76
- package/extensions/qol/settings.ts +17 -7
- package/extensions/qol/statusline.ts +18 -4
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -1,120 +1,49 @@
|
|
|
1
|
-
# pi-qol
|
|
1
|
+
# @vanillagreen/pi-qol
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-

|
|
5
|
-

|
|
3
|
+
A Pi extension for session controls, prompt editing and notifications. Users can configure each feature separately.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Highlights
|
|
10
|
-
|
|
11
|
-
- Compact statusline with repo, branch, model, thinking level, and context percent; can be disabled.
|
|
12
|
-
- Newline-insert in the editor (multi-line drafts without auto-submit), with a fallback binding for terminals that can't distinguish the primary key.
|
|
13
|
-
- Sessions auto-name from your first prompt. `/rename` overrides anytime.
|
|
14
|
-
- Session search reads prompt snippets line-by-line, so very large session JSONL files do not have to be materialized just to browse, search, or import context.
|
|
15
|
-
- Optional rate-limit auto-resume sends a configurable continuation after reset.
|
|
16
|
-
- Permission gate prompts before risky `bash` commands. Default match: `rm -Rf`.
|
|
17
|
-
- Notifications for ready, questions, blocked states, and task completion.
|
|
18
|
-
- Thinking timer next to collapsed `Thinking...` labels.
|
|
19
|
-
- Caveman badge and a mode-cycling shortcut when `pi-caveman` is loaded.
|
|
20
|
-
- Subagent-name badge in `pi-agents-tmux` child panes.
|
|
5
|
+
  
|
|
21
6
|
|
|
22
7
|
## Install
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Via [npm](https://www.npmjs.com/package/@vanillagreen/pi-qol):
|
|
9
|
+
- npm: `pi install npm:@vanillagreen/pi-qol`.
|
|
10
|
+
- kendex: add the declaration below to the project's `kendex.toml`, or to `~/.config/kendex/kendex.toml` for user scope. Run `kendex update-pi`.
|
|
27
11
|
|
|
28
|
-
```
|
|
29
|
-
pi
|
|
12
|
+
```toml
|
|
13
|
+
[pi-extensions."@vanillagreen/pi-qol"]
|
|
14
|
+
source = "kendex"
|
|
30
15
|
```
|
|
31
16
|
|
|
32
|
-
|
|
17
|
+
Restart Pi after installation. Use `kendex update-pi --check` to preview the installation.
|
|
33
18
|
|
|
34
|
-
|
|
35
|
-
cargo install --git https://github.com/vanillagreencom/kendex.git kendex
|
|
36
|
-
kendex add vanillagreencom/kendex --pi-extension pi-qol --harness pi -y
|
|
37
|
-
```
|
|
19
|
+
## Features
|
|
38
20
|
|
|
39
|
-
|
|
21
|
+
- Show repository, model and context information beside the editor.
|
|
22
|
+
- Name and search sessions.
|
|
23
|
+
- Schedule prompts and prepare handoff drafts.
|
|
24
|
+
- Ask before configured shell commands run.
|
|
25
|
+
- Send terminal and desktop notifications.
|
|
26
|
+
- Configure summaries and compaction for long sessions.
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
| --- | --- |
|
|
43
|
-
| `/qol` | Open settings (or print status if extension-manager isn't installed). |
|
|
44
|
-
| `/qol notify-test` | Send a test notification. |
|
|
45
|
-
| `/rename [name]` | Set or show the current session's name. |
|
|
46
|
-
| `/qol:rename` / `/qol:rename:full` | Regenerate the session name from the first prompt, or from the full conversation. |
|
|
47
|
-
| `/context` | Show a Claude-style context-window usage breakdown by category. |
|
|
48
|
-
| `/search [query]` | Open previous-session search with snippet previews; the configured shortcut opens it instantly. |
|
|
49
|
-
| `/search:refresh` | Refresh the session cache. |
|
|
50
|
-
| `/handoff <goal>` | Draft a focused handoff prompt for a new session. |
|
|
51
|
-
| `/schedule <delay> <message>` | Send a user message after a timer without invoking the model now. Example: `/schedule 1h45m retry the previous request`. |
|
|
28
|
+
## How it works
|
|
52
29
|
|
|
53
|
-
|
|
30
|
+
The extension reads your enabled features when Pi starts. It adds their editor controls, commands and event handlers. Session actions update the session or queue messages for the agent. Notifications report events through your selected channels. Compaction settings control when long conversations are summarized.
|
|
54
31
|
|
|
55
32
|
## Settings
|
|
56
33
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
| Group | Setting | What it does |
|
|
60
|
-
| --- | --- | --- |
|
|
61
|
-
| Statusline | Enable QOL editor helpers | Master toggle for QOL statusline, commands, notifications, search, compaction, and editor helpers. |
|
|
62
|
-
| Statusline | Show compact statusline | Render or disable the QOL statusline row. |
|
|
63
|
-
| Statusline | Replace built-in footer | Hide Pi's default footer while the QOL statusline is enabled. |
|
|
64
|
-
| Statusline | Use π prompt editor | Use the compact prompt editor. |
|
|
65
|
-
| Statusline | Show session name title | Show the session name above the prompt and in the tmux pane title; refreshes as soon as Pi reports a session metadata change. |
|
|
66
|
-
| Statusline | Sync session name to tmux window name | Rename the tmux window to `π <session>`. |
|
|
67
|
-
| Statusline | Input bottom padding | Blank lines below the prompt. |
|
|
68
|
-
| Statusline | Show dirty marker | Append `*` to the branch when the worktree is dirty. |
|
|
69
|
-
| Input | shift+enter inserts newline | Insert a newline instead of submitting. |
|
|
70
|
-
| Input | Fallback newline key | Alternate binding for terminals that can't send the primary one. |
|
|
71
|
-
| Input | Style pending queue preview | Highlight Pi's pending-queue preview with a green left bar. |
|
|
72
|
-
| Input | Style image chips | Render `[Image #N]` placeholders as distinct chips. |
|
|
73
|
-
| Input | Show attachment count | Show a status badge when the draft has image placeholders. |
|
|
74
|
-
| Session, Handoff, Context window, Session search | Enable /rename, /schedule, /handoff, /context, session search | One toggle each: register that command. Session search also registers its overlay; `/schedule` is useful for retrying after rate limits reset. |
|
|
75
|
-
| Session | Auto-resume after rate limits | Send the configured continuation after a detected reset; cancels on newer turn. |
|
|
76
|
-
| Session | Auto-name new sessions | Generate a friendly session name from the first prompt. |
|
|
77
|
-
| Session | Auto-rename model / fallback model | Model used for title generation, and the model tried when the primary fails. |
|
|
78
|
-
| Session | Deterministic fallback | Title-case words, truncated prompt, or none if all model calls fail. |
|
|
79
|
-
| Session | Auto-rename prefix | Optional static prefix on every generated name. |
|
|
80
|
-
| Session | Notify on auto-rename | Show a notification when auto-renaming. |
|
|
81
|
-
| Handoff | Review handoff prompt | Open an editor to edit the generated prompt before creating the session. |
|
|
82
|
-
| Session search | Session search shortcut | Configurable; set to `none` to disable. |
|
|
83
|
-
| Session search | Result limit | Max matching prompts returned. |
|
|
84
|
-
| Session search | Visible session rows | Rows shown before scrolling; defaults to `8`. |
|
|
85
|
-
| Session search | Preview snippets | Matching snippets shown on the preview screen. |
|
|
86
|
-
| Session search | Session cache TTL | Seconds before the session list refreshes; `0` keeps it until you run `/search:refresh`. |
|
|
87
|
-
| Permission gate | Prompt before risky bash commands | Ask before bash commands matching the command list. Off by default; when enabled, non-interactive matches are blocked. |
|
|
88
|
-
| Permission gate | Commands to prompt for | Comma-separated literal fragments or `/regex/flags`. |
|
|
89
|
-
| Permission gate | Approval preview lines / characters | Cap the approval-prompt preview height and width. |
|
|
90
|
-
| Compaction | Custom compaction summaries | Use QOL summaries instead of Pi's default, with Pi-standard transient provider retries when available. |
|
|
91
|
-
| Compaction | Compaction model | Summarizer model. Defaults to `current`, meaning Pi's active model; set a provider/model when you want a dedicated larger-context summarizer. Thinking suffixes through `:max` are accepted, and Pi-resolved header/environment authentication is forwarded. |
|
|
92
|
-
| Compaction | Compaction detail profile | `concise`, `balanced`, or `exhaustive`. |
|
|
93
|
-
| Compaction | Include previous summary | Pass the previous summary for iterative continuity. |
|
|
94
|
-
| Compaction | Fallback to Pi default compaction | Run Pi's default compaction if QOL's fails. |
|
|
95
|
-
| Compaction | Show compaction notifications | Notify on compaction start/fail/complete. |
|
|
96
|
-
| Compaction | Custom branch summaries | Use QOL's chunked summarizer for `/tree` branch summaries; branch summaries do not write handoff artifacts. |
|
|
97
|
-
| Compaction | Remote compaction endpoint | Call a remote HTTP summarizer instead of a model. |
|
|
98
|
-
| Compaction | Idle compaction trigger | Auto-compact after the session sits idle above a token threshold. Idle thresholds (token threshold, idle delay, fixed token limit, percent limit) tune when it fires. |
|
|
99
|
-
| Long-session budget guard | Long-session budget guard | Master toggle for threshold-triggered bounded compaction. Default on. |
|
|
100
|
-
| Long-session budget guard | Budget guard percent / token limit | Context-window percentage that fires the guard (default `85`; `-1` disables percent-based firing), and the absolute token count that fires it (default `-1`, meaning percent only). |
|
|
101
|
-
| Long-session budget guard | Chunked compaction input cap | Max serialized characters per summarization request; long transcripts are chunked and summarized in bounded pieces so the compaction call itself cannot exceed provider buffer limits. `0` disables chunking. Default `240000`. |
|
|
102
|
-
| Long-session budget guard | Write pre-compaction handoff artifact | Write a pre-compaction handoff artifact (previous summary, last task state, referenced files and artifacts) for budget-guard and enabled custom session compactions; branch summaries never write one. Write failures surface as a QOL warning notification. Default on. |
|
|
103
|
-
| Long-session budget guard | Transcript-risk warn budget (chars) | `/context` warns when the serialized payload of messages-to-send exceeds this many characters, even if tokens are still below the context window. `0` disables. Default `600000`. |
|
|
104
|
-
| Thinking | Hidden thinking label | Label shown when thinking blocks are hidden. |
|
|
105
|
-
| Thinking | Show thinking timer | Show elapsed time next to collapsed `Thinking...` labels. |
|
|
106
|
-
| Thinking | Working indicator mode | `animated` ticks every 80ms; switch to `static` if you see flashes when the chat overflows. |
|
|
107
|
-
|
|
108
|
-
Advanced auto-rename settings (input cap, title length, output tokens, timeout, custom prompt template, debug logging) and session-search summary settings (model, max tokens, input cap — they tune the summarizer when you import context from a previous session) sit alongside the rows above.
|
|
109
|
-
|
|
110
|
-
`/context` also estimates the serialized payload size of the messages that would be sent on the next request. When that payload crosses **Transcript-risk warn budget (chars)** a `Transcript risk` block appears below the compact buffer section even if token count is still under the context window — useful for catching large blob-shaped tool outputs that inflate the request long before token count alone would page anyone.
|
|
111
|
-
|
|
112
|
-
### Notifications
|
|
113
|
-
|
|
114
|
-
Master toggle: **Enable notifications**. Triggers (notify when): ready, direction needed, question popups, all tasks complete, critical/blocked. Channels: terminal bell, **Mute bell sound**, native terminal notifications (OSC 777/99 or Windows toast), tmux `display-message`, tmux window marking, OSC passthrough, and an optional in-Pi UI notice. Tuning: cooldown seconds, title, ready message, body length, tmux durations. **Terminal notification protocol** picks between OSC 99 (Kitty) and OSC 777 automatically. **Bell when tmux window active** is off so you don't get bells while looking at Pi. **Mute bell sound** keeps notification routing enabled but suppresses QOL-emitted BEL bytes and uses ST terminators for OSC 777/99 where supported; terminals or operating systems may still play their own sound for native notifications outside QOL control. **tmux native via client TTY** sends OSC notifications to attached tmux clients so notifications still appear when the Pi window is inactive. Use `/qol notify-test` to verify your terminal/tmux setup, including silent behavior with **Mute bell sound** enabled.
|
|
34
|
+
The settings editor writes project values to `.pi/settings.json`. The default user file is `~/.pi/agent/settings.json`. `PI_CODING_AGENT_DIR` changes the user directory. Package values are stored under `kendex.extensionManager.config["@vanillagreen/pi-qol"]`.
|
|
115
35
|
|
|
116
|
-
|
|
36
|
+
Open `/extensions:settings`; settings appear under the **QOL** tab. Project settings in `.pi/settings.json` apply only after Pi marks the workspace trusted. `glyphStyle` picks `unicode` or `ascii` symbols, and `@vanillagreen/pi-tool-renderer`'s `globalGlyphStyleOverride` wins when set.
|
|
117
37
|
|
|
118
|
-
|
|
38
|
+
- `enabled`: package toggle for everything below.
|
|
39
|
+
- Statusline and editor: `statusline.enabled`, `statusline.showAccount`, `replaceFooter`, `compactPrompt`, `showSessionNameTitle`, `showSessionNameWindow`, `inputBottomPaddingLines`, `gitRefreshTimeoutMs`, `showDirtyMarker`, `newlineOnShiftEnter`, `newlineFallbackKey`, `pendingQueue.asciiGreen`, `showImageChips`, `showAttachmentCountInStatus`.
|
|
40
|
+
- Commands: `enableSessionNameCommand`, `enableHandoffCommand`, `enableScheduleCommand`, `enableContextCommand`, `handoffReviewPrompt`.
|
|
41
|
+
- Session naming: `sessionAutoRename.*` (model, fallback model, deterministic fallback, prefix, prompt, limits, notify, debug).
|
|
42
|
+
- Session search: `sessionSearch.*` (shortcut, result and row limits, snippets, overlay width, cache TTL, summary model and limits).
|
|
43
|
+
- Rate limits: `rateLimitAutoResume.*`.
|
|
44
|
+
- Permission gate: `permissionGate.enabled`, `permissionGate.commands` (comma-separated literal fragments or `/regex/flags`), `permissionGate.previewLines`, `permissionGate.previewChars`.
|
|
45
|
+
- Notifications: `notification.*` (triggers, channels, tmux options, protocol, cooldown, title and body).
|
|
46
|
+
- Compaction and budget guard: `compaction.*` (custom summaries, model, profile, remote endpoint, branch summaries, idle trigger, budget guard thresholds, chunk input cap, handoff artifact, transcript-risk budget).
|
|
47
|
+
- Thinking: `thinkingLabel.text`, `thinkingTimer.enabled`, `workingIndicator.mode` (`static` if the animated indicator flashes).
|
|
119
48
|
|
|
120
|
-
|
|
49
|
+
Maintainer notes are in [DEVELOPMENT.md](DEVELOPMENT.md).
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CAVEMAN_BRIDGE_SYMBOL,
|
|
3
|
+
CLAUDE_BILLING_IDENTITY_SYMBOL,
|
|
3
4
|
PI_AGENTS_STATUSLINE_SYMBOL,
|
|
4
5
|
QUESTION_SERVICE_SYMBOL,
|
|
5
6
|
KENDEX_MODAL_LOCK_SYMBOL,
|
|
@@ -21,6 +22,18 @@ export interface PiAgentsStatuslineBridge {
|
|
|
21
22
|
getCurrentSubagent(cwd?: string): { name: string; color?: string } | undefined;
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
/** The Claude bridge's published account surface. It answers with a login
|
|
26
|
+
* email only when the SDK confirmed one for the child that ran the request:
|
|
27
|
+
* an API key or a Bedrock, Vertex, Foundry, Anthropic-AWS or Mantle backend
|
|
28
|
+
* authenticates as something no config directory names, and a companion
|
|
29
|
+
* account router can rotate the profile per request without the environment
|
|
30
|
+
* changing. Reading a config directory here instead would name the wrong
|
|
31
|
+
* account in every one of those cases. */
|
|
32
|
+
export interface ClaudeBillingIdentityBridge {
|
|
33
|
+
version: 1;
|
|
34
|
+
currentLoginEmail(sessionId: string | undefined): string | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
export interface QuestionRequestLike {
|
|
25
38
|
header?: string;
|
|
26
39
|
question?: string;
|
|
@@ -47,6 +60,12 @@ export function readCavemanBridge(): CavemanBridge | undefined {
|
|
|
47
60
|
return value && typeof value === "object" ? (value as CavemanBridge) : undefined;
|
|
48
61
|
}
|
|
49
62
|
|
|
63
|
+
export function readClaudeBillingIdentityBridge(): ClaudeBillingIdentityBridge | undefined {
|
|
64
|
+
const host = globalThis as unknown as Record<PropertyKey, unknown>;
|
|
65
|
+
const value = host[CLAUDE_BILLING_IDENTITY_SYMBOL] as ClaudeBillingIdentityBridge | undefined;
|
|
66
|
+
return value?.version === 1 && typeof value.currentLoginEmail === "function" ? value : undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
50
69
|
export function readPiAgentsStatuslineBridge(): PiAgentsStatuslineBridge | undefined {
|
|
51
70
|
const host = globalThis as unknown as Record<PropertyKey, unknown>;
|
|
52
71
|
const value = host[PI_AGENTS_STATUSLINE_SYMBOL];
|
|
@@ -116,7 +116,7 @@ export class BudgetGuardDriver {
|
|
|
116
116
|
return true;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
/** Dispatch a trigger
|
|
119
|
+
/** Dispatch a trigger staged by agent_end. */
|
|
120
120
|
dispatchPending(input: GuardPendingDispatchInput): GuardDispatchResult {
|
|
121
121
|
const completed = (outcome: DispatchOutcome): GuardDispatchResult => ({ completion: Promise.resolve(), outcome });
|
|
122
122
|
const generation = input.generation ?? this.generation;
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
// so it can be unit-tested without the pi-coding-agent / pi-ai peer deps.
|
|
6
6
|
|
|
7
7
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
8
|
-
import { homedir } from "node:os";
|
|
9
8
|
import { basename, dirname, join, resolve } from "node:path";
|
|
10
9
|
|
|
11
10
|
import { QOL_BUDGET_HANDOFF_FOLDER, QOL_BUDGET_HANDOFF_LATEST } from "./constants.js";
|
|
11
|
+
import { expandHome } from "./settings.js";
|
|
12
12
|
|
|
13
13
|
export interface QolBudgetHandoff {
|
|
14
14
|
reason: string;
|
|
@@ -22,14 +22,15 @@ export interface QolBudgetHandoff {
|
|
|
22
22
|
model?: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
25
|
+
/** Root-anchored as `crates/core/src/harness/pi.rs::pi_root_is_absolute_for`
|
|
26
|
+
* means it, which `isAbsolute` is not: it calls a driveless `\root` absolute
|
|
27
|
+
* where the renderer does not, putting the two on different roots. Hoisted, so
|
|
28
|
+
* a circular import cannot reach it inside a temporal dead zone. */
|
|
29
|
+
function rootAnchored(path: string, windows: boolean): boolean { return windows ? /^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+)/.test(path) : path.startsWith("/"); }
|
|
30
30
|
|
|
31
31
|
export function piUserDir(): string {
|
|
32
|
-
|
|
32
|
+
const override = expandHome(process.env.PI_CODING_AGENT_DIR?.trim() || "");
|
|
33
|
+
return resolve(rootAnchored(override, process.platform === "win32") ? override : expandHome("~/.pi/agent"));
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export function safeFileName(value: string): string {
|
|
@@ -83,7 +84,7 @@ const ARTIFACT_REF_PATTERN = /(?:^|\s|["'`(\[<])((?:\.{1,2}\/|\/|~\/)?[\w.\-+@/]
|
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* Collects up to `maxRefs` file path-shaped strings from message contents,
|
|
86
|
-
* walking newest-first.
|
|
87
|
+
* walking newest-first. Gives the handoff artifact a quick "if you
|
|
87
88
|
* are recovering, here are recent files" pointer list.
|
|
88
89
|
*/
|
|
89
90
|
export function collectArtifactRefs(branch: unknown[], maxRefs = 20): string[] {
|
|
@@ -186,6 +186,11 @@ async function singleShotSummary(ctx: ExtensionContext, request: SummarizeReques
|
|
|
186
186
|
if (response.stopReason === "error" || response.stopReason === "aborted") {
|
|
187
187
|
throw new Error(response.errorMessage || `Summary request stopped: ${response.stopReason}`);
|
|
188
188
|
}
|
|
189
|
+
// A length stop carries text, but the text ends wherever the cap fell; as a
|
|
190
|
+
// continuation checkpoint it would silently drop the rest of the context.
|
|
191
|
+
if (response.stopReason === "length") {
|
|
192
|
+
throw new Error("Summary generation hit the token cap and the summary is incomplete");
|
|
193
|
+
}
|
|
189
194
|
const summary = response.content
|
|
190
195
|
.filter((content): content is { type: "text"; text: string } => content.type === "text")
|
|
191
196
|
.map((content) => content.text)
|
|
@@ -15,6 +15,7 @@ export const QOL_NOTIFICATION_SERVICE_SYMBOL = Symbol.for("kendex.pi-qol.notific
|
|
|
15
15
|
export const KENDEX_MODAL_LOCK_SYMBOL = Symbol.for("kendex.pi.modal-lock");
|
|
16
16
|
export const CAVEMAN_BRIDGE_SYMBOL = Symbol.for("kendex.pi.caveman");
|
|
17
17
|
export const PI_AGENTS_STATUSLINE_SYMBOL = Symbol.for("kendex.pi-agents-tmux.statusline");
|
|
18
|
+
export const CLAUDE_BILLING_IDENTITY_SYMBOL = Symbol.for("kendex.pi.claude-bridge.billing-identity.v1");
|
|
18
19
|
|
|
19
20
|
export const CAVEMAN_ICON_ACTIVE = "\uee9a";
|
|
20
21
|
export const CAVEMAN_ICON_INACTIVE = "\u{f19e0}";
|
package/extensions/qol/editor.ts
CHANGED
|
@@ -85,7 +85,7 @@ function handleQolEditorInput(editor: CustomEditor, ctx: ExtensionContext, data:
|
|
|
85
85
|
/// Push the latest attachment-count status only when it actually changes.
|
|
86
86
|
/// Called from render() so we follow the rainbow-editor pattern (pull from
|
|
87
87
|
/// render, don't push from every keystroke) and avoid the per-keystroke
|
|
88
|
-
/// setStatus side effect that
|
|
88
|
+
/// setStatus side effect that can cause resize and input races.
|
|
89
89
|
function syncQolEditorStatus(
|
|
90
90
|
ctx: ExtensionContext,
|
|
91
91
|
text: string,
|
package/extensions/qol/glyphs.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { dirname, join, resolve } from "node:path";
|
|
1
|
+
import { readPackageConfig } from "./settings.js";
|
|
4
2
|
|
|
5
3
|
export type GlyphStyle = "unicode" | "ascii";
|
|
6
4
|
export type GlobalGlyphStyleOverride = "inherit" | GlyphStyle;
|
|
@@ -8,79 +6,6 @@ export type GlobalGlyphStyleOverride = "inherit" | GlyphStyle;
|
|
|
8
6
|
const LOCAL_CONFIG_ID = "@vanillagreen/pi-qol";
|
|
9
7
|
const GLOBAL_CONFIG_ID = "@vanillagreen/pi-tool-renderer";
|
|
10
8
|
|
|
11
|
-
function expandHome(input: string): string {
|
|
12
|
-
if (input === "~") return homedir();
|
|
13
|
-
if (input.startsWith("~/")) return join(homedir(), input.slice(2));
|
|
14
|
-
return input;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function projectSettingsPath(cwd: string): string {
|
|
18
|
-
let current = resolve(cwd);
|
|
19
|
-
while (true) {
|
|
20
|
-
const candidate = join(current, ".pi", "settings.json");
|
|
21
|
-
if (existsSync(candidate)) return candidate;
|
|
22
|
-
if (existsSync(join(current, ".pi")) || existsSync(join(current, ".git")) || existsSync(join(current, ".kendex-lock.json"))) return candidate;
|
|
23
|
-
const parent = dirname(current);
|
|
24
|
-
if (parent === current) return join(resolve(cwd), ".pi", "settings.json");
|
|
25
|
-
current = parent;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const PROJECT_TRUST_SYMBOL = Symbol.for("kendex.pi.project-trust");
|
|
30
|
-
|
|
31
|
-
interface ProjectTrustRegistry {
|
|
32
|
-
projectSettings?: Map<string, boolean>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function projectTrustRegistry(): ProjectTrustRegistry {
|
|
36
|
-
const host = globalThis as unknown as Record<PropertyKey, ProjectTrustRegistry | undefined>;
|
|
37
|
-
const existing = host[PROJECT_TRUST_SYMBOL];
|
|
38
|
-
if (existing) return existing;
|
|
39
|
-
const created: ProjectTrustRegistry = {};
|
|
40
|
-
host[PROJECT_TRUST_SYMBOL] = created;
|
|
41
|
-
return created;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function recordProjectTrust(ctx: { cwd?: string; isProjectTrusted?: () => boolean }): void {
|
|
45
|
-
if (!ctx.cwd) return;
|
|
46
|
-
let trusted = true;
|
|
47
|
-
try {
|
|
48
|
-
trusted = ctx.isProjectTrusted?.() === true;
|
|
49
|
-
} catch {
|
|
50
|
-
trusted = false;
|
|
51
|
-
}
|
|
52
|
-
const registry = projectTrustRegistry();
|
|
53
|
-
if (!registry.projectSettings) registry.projectSettings = new Map();
|
|
54
|
-
registry.projectSettings.set(projectSettingsPath(ctx.cwd), trusted);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function projectSettingsTrusted(settingsPath: string): boolean {
|
|
58
|
-
return projectTrustRegistry().projectSettings?.get(settingsPath) === true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
function piSettingsPaths(cwd = process.cwd()): string[] {
|
|
63
|
-
const userDir = resolve(expandHome(process.env.PI_CODING_AGENT_DIR?.trim() || "~/.pi/agent"));
|
|
64
|
-
const user = join(userDir, "settings.json");
|
|
65
|
-
const project = projectSettingsPath(cwd);
|
|
66
|
-
return projectSettingsTrusted(project) ? [user, project] : [user];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function readPackageConfig(packageId: string, cwd?: string): Record<string, unknown> {
|
|
70
|
-
const merged: Record<string, unknown> = {};
|
|
71
|
-
for (const settingsPath of piSettingsPaths(cwd)) {
|
|
72
|
-
if (!existsSync(settingsPath)) continue;
|
|
73
|
-
try {
|
|
74
|
-
const parsed = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
75
|
-
const config = parsed?.kendex?.extensionManager?.config?.[packageId];
|
|
76
|
-
if (config && typeof config === "object" && !Array.isArray(config)) Object.assign(merged, config);
|
|
77
|
-
} catch {
|
|
78
|
-
// Ignore malformed optional manager config.
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return merged;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
9
|
function asGlyphStyle(value: unknown): GlyphStyle | undefined {
|
|
85
10
|
return value === "unicode" || value === "ascii" ? value : undefined;
|
|
86
11
|
}
|
|
@@ -55,21 +55,27 @@ function projectSettingsTrusted(settingsPath: string): boolean {
|
|
|
55
55
|
return projectTrustRegistry().projectSettings?.get(settingsPath) === true;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/** Root-anchored as `crates/core/src/harness/pi.rs::pi_root_is_absolute_for`
|
|
59
|
+
* means it, which `isAbsolute` is not: it calls a driveless `\root` absolute
|
|
60
|
+
* where the renderer does not, putting the two on different roots. Hoisted, so
|
|
61
|
+
* a circular import cannot reach it inside a temporal dead zone. */
|
|
62
|
+
function rootAnchored(path: string, windows: boolean): boolean { return windows ? /^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+)/.test(path) : path.startsWith("/"); }
|
|
58
63
|
|
|
59
64
|
export function piSettingsPaths(cwd = process.cwd()): string[] {
|
|
60
|
-
const
|
|
65
|
+
const override = expandHome(process.env.PI_CODING_AGENT_DIR?.trim() || "");
|
|
66
|
+
const userDir = resolve(rootAnchored(override, process.platform === "win32") ? override : expandHome("~/.pi/agent"));
|
|
61
67
|
const user = join(userDir, "settings.json");
|
|
62
68
|
const project = projectSettingsPath(cwd);
|
|
63
69
|
return projectSettingsTrusted(project) ? [user, project] : [user];
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
export function
|
|
67
|
-
const merged:
|
|
68
|
-
for (const
|
|
69
|
-
if (!existsSync(
|
|
72
|
+
export function readPackageConfig(packageId: string, cwd?: string): Record<string, unknown> {
|
|
73
|
+
const merged: Record<string, unknown> = {};
|
|
74
|
+
for (const settingsPath of piSettingsPaths(cwd)) {
|
|
75
|
+
if (!existsSync(settingsPath)) continue;
|
|
70
76
|
try {
|
|
71
|
-
const parsed = JSON.parse(readFileSync(
|
|
72
|
-
const config = parsed?.kendex?.extensionManager?.config?.[
|
|
77
|
+
const parsed = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
78
|
+
const config = parsed?.kendex?.extensionManager?.config?.[packageId];
|
|
73
79
|
if (config && typeof config === "object" && !Array.isArray(config)) Object.assign(merged, config);
|
|
74
80
|
} catch {
|
|
75
81
|
// Ignore malformed optional manager config.
|
|
@@ -78,6 +84,10 @@ export function readkendexConfig(cwd?: string): kendexConfig {
|
|
|
78
84
|
return merged;
|
|
79
85
|
}
|
|
80
86
|
|
|
87
|
+
export function readkendexConfig(cwd?: string): kendexConfig {
|
|
88
|
+
return readPackageConfig(CONFIG_ID, cwd) as kendexConfig;
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
export function settingBoolean(key: string, fallback: boolean, cwd?: string): boolean {
|
|
82
92
|
const value = readkendexConfig(cwd)[key];
|
|
83
93
|
return typeof value === "boolean" ? value : fallback;
|
|
@@ -4,7 +4,7 @@ import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-c
|
|
|
4
4
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
5
5
|
import { subagentStatuslineMarker } from "./agent-statusline.js";
|
|
6
6
|
import { stripAnsi } from "./ansi.js";
|
|
7
|
-
import { readCavemanBridge } from "./bridges.js";
|
|
7
|
+
import { readCavemanBridge, readClaudeBillingIdentityBridge } from "./bridges.js";
|
|
8
8
|
import { glyphs } from "./glyphs.js";
|
|
9
9
|
import { CAVEMAN_ICON_ACTIVE, CAVEMAN_ICON_INACTIVE } from "./constants.js";
|
|
10
10
|
import { settingBoolean, settingNumber } from "./settings.js";
|
|
@@ -89,6 +89,17 @@ function statuslineContextInfo(ctx: ExtensionContext): { label: string; percent:
|
|
|
89
89
|
return { label: formatWindow(contextWindow), percent: 100 - usedPercent };
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/** The account segment for an active Claude-bridge model, or "" otherwise.
|
|
93
|
+
* A lane can retain its last Claude identity after the user selects another
|
|
94
|
+
* provider, which does not bill that account. The Claude bridge owns the
|
|
95
|
+
* judgement of what counts as a confirmed login; this reads its answer and
|
|
96
|
+
* displays it only beside its model. */
|
|
97
|
+
function accountLabel(ctx: ExtensionContext): string {
|
|
98
|
+
if (!settingBoolean("statusline.showAccount", true, ctx.cwd)) return "";
|
|
99
|
+
if (ctx.model?.provider !== "pi-claude") return "";
|
|
100
|
+
return readClaudeBillingIdentityBridge()?.currentLoginEmail(ctx.sessionManager.getSessionId()) ?? "";
|
|
101
|
+
}
|
|
102
|
+
|
|
92
103
|
function gitBadge(state: GitState, showDirtyMarker: boolean): string {
|
|
93
104
|
if (!state.branch) return "";
|
|
94
105
|
const icon = state.inLinkedWorktree || state.branch !== "main" ? `🌳 ${state.branch}` : "🦀";
|
|
@@ -200,6 +211,8 @@ export function renderStatusLine(width: number, ctx: ExtensionContext, git: GitS
|
|
|
200
211
|
const thinkingLevel = normalizeThinkingLevel(pi.getThinkingLevel());
|
|
201
212
|
const thinkingChunk = thinkingLevel;
|
|
202
213
|
const contextChunk = ` ${contextLabel}`;
|
|
214
|
+
const account = accountLabel(ctx);
|
|
215
|
+
const accountSegment = account ? `${statusSeparator}${account}` : "";
|
|
203
216
|
const cavemanBridge = readCavemanBridge();
|
|
204
217
|
const cavemanVisible = !!cavemanBridge && (cavemanBridge.isStatusBadgeEnabled?.(ctx.cwd) ?? true);
|
|
205
218
|
const caveman = cavemanVisible ? cavemanBridge : undefined;
|
|
@@ -208,16 +221,17 @@ export function renderStatusLine(width: number, ctx: ExtensionContext, git: GitS
|
|
|
208
221
|
const cavemanTone = cavemanIconTone(caveman?.getMode() ?? "off", cavemanActive);
|
|
209
222
|
const cavemanSegment = caveman ? `${statusSeparator}${cavemanGlyph}` : "";
|
|
210
223
|
const contextSeparator = caveman ? ` ${statusSeparator}` : "";
|
|
211
|
-
const leftPlain = `${projectChunk}${statusSeparator}${thinkingChunk}${cavemanSegment}${contextSeparator}${contextChunk.trimStart()}`;
|
|
224
|
+
const leftPlain = `${projectChunk}${statusSeparator}${thinkingChunk}${cavemanSegment}${contextSeparator}${contextChunk.trimStart()}${accountSegment}`;
|
|
212
225
|
const percentPlain = percent === null ? `${glyphs(ctx.cwd).ellipsis}%` : `${percent}%`;
|
|
213
226
|
const subagentMarker = subagentStatuslineMarker(ctx.cwd);
|
|
214
227
|
const rightPlain = subagentMarker ? `${percentPlain} ${subagentMarker.plain}` : percentPlain;
|
|
215
228
|
const percentColor = percent === null ? "muted" : percent <= 15 ? "error" : percent <= 30 ? "warning" : "success";
|
|
216
229
|
const separatorColored = theme.fg("muted", statusSeparator);
|
|
217
230
|
const thinkingToken = thinkingThemeToken(thinkingLevel) as Parameters<Theme["fg"]>[0];
|
|
231
|
+
const accountColored = account ? `${separatorColored}${theme.fg("muted", account)}` : "";
|
|
218
232
|
const leftColored = caveman
|
|
219
|
-
? `${theme.fg("accent", projectChunk)}${separatorColored}${theme.fg(thinkingToken, thinkingChunk)}${separatorColored}${theme.fg(cavemanTone, cavemanGlyph)}${theme.fg("muted", contextSeparator)}${theme.fg("accent", contextChunk.trimStart())}`
|
|
220
|
-
: `${theme.fg("accent", projectChunk)}${separatorColored}${theme.fg(thinkingToken, thinkingChunk)}${theme.fg("accent", contextChunk)}`;
|
|
233
|
+
? `${theme.fg("accent", projectChunk)}${separatorColored}${theme.fg(thinkingToken, thinkingChunk)}${separatorColored}${theme.fg(cavemanTone, cavemanGlyph)}${theme.fg("muted", contextSeparator)}${theme.fg("accent", contextChunk.trimStart())}${accountColored}`
|
|
234
|
+
: `${theme.fg("accent", projectChunk)}${separatorColored}${theme.fg(thinkingToken, thinkingChunk)}${theme.fg("accent", contextChunk)}${accountColored}`;
|
|
221
235
|
const right = subagentMarker ? `${theme.fg(percentColor, percentPlain)} ${subagentMarker.styled}` : theme.fg(percentColor, percentPlain);
|
|
222
236
|
const minimumGap = 1;
|
|
223
237
|
const gapWidth = Math.max(minimumGap, width - visibleWidth(leftPlain) - visibleWidth(rightPlain) - 2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanillagreen/pi-qol",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Pi quality-of-life extension: compact statusline/π prompt, reliable multiline input, styled pasted-image chips, session naming/search/context import, scheduled prompts, handoff, permission prompts, notifications, custom compaction, and a collapsed-thinking timer.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -56,6 +56,15 @@
|
|
|
56
56
|
"apply": "reload",
|
|
57
57
|
"requiresReload": true
|
|
58
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"key": "statusline.showAccount",
|
|
61
|
+
"label": "Show account email",
|
|
62
|
+
"description": "Append the Claude login this session authenticated as, as the Claude bridge reports it. Nothing is shown before the first turn, or when the request used an API key or a third-party backend such as Bedrock or Vertex.",
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"default": true,
|
|
65
|
+
"category": "Statusline",
|
|
66
|
+
"apply": "live"
|
|
67
|
+
},
|
|
59
68
|
{
|
|
60
69
|
"key": "replaceFooter",
|
|
61
70
|
"label": "Replace built-in footer",
|