@vanillagreen/pi-qol 2.0.0 → 2.0.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/README.md CHANGED
@@ -1,120 +1,49 @@
1
- # pi-qol
1
+ # @vanillagreen/pi-qol
2
2
 
3
- ![QOL extension settings panel](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-qol/assets/settings-panel.png)
4
- ![Session search popup](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-qol/assets/session-search.gif)
5
- ![/context usage breakdown](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-qol/assets/context-usage.png)
3
+ A Pi extension for session controls, prompt editing and notifications. Users can configure each feature separately.
6
4
 
7
- Quality-of-life extension for Pi: compact statusline, multiline input, session naming and search, scheduled prompts, notifications, and a permission gate.
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
+ ![QOL extension settings panel](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-qol/assets/settings-panel.png) ![Session search popup](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-qol/assets/session-search.gif) ![/context usage breakdown](https://raw.githubusercontent.com/vanillagreencom/kendex/main/pi-extensions/pi-qol/assets/context-usage.png)
21
6
 
22
7
  ## Install
23
8
 
24
- Requires Pi 0.80.4 or newer. Restart Pi after installation.
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
- ```bash
29
- pi install npm:@vanillagreen/pi-qol
12
+ ```toml
13
+ [pi-extensions."@vanillagreen/pi-qol"]
14
+ source = "kendex"
30
15
  ```
31
16
 
32
- Via [kendex](https://github.com/vanillagreencom/kendex):
17
+ Restart Pi after installation. Use `kendex update-pi --check` to preview the installation.
33
18
 
34
- ```bash
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
- ## Commands
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
- | Command | Action |
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
- Arguments support autocomplete. `/schedule` accepts `ms`, `s`, `m`, `h`, and `d` units; bare numbers mean minutes. Compact composite durations are accepted in largest-to-smallest order, like `1h45m`, `45m10s`, or `1h45m30s`. Pending prompts render above the statusline like steering/follow-up previews until they are sent or cancelled. Manage pending prompts with `/schedule list` and `/schedule cancel <id|all>`. Schedules are stored in the Pi session and re-armed on reload/resume; if Pi is not running at the due time, an overdue prompt sends when that session is next loaded.
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
- Open `/extensions:settings`; settings appear under the **QOL** tab. Names below match the labels shown there, grouped as the editor groups them. Project settings in `.pi/settings.json` apply only after Pi marks the workspace trusted; before trust, kendex Pi extensions read user/global settings only. Glyph style: each package exposes `glyphStyle` (`unicode` default, `ascii` for terminal-safe chrome). `@vanillagreen/pi-tool-renderer.globalGlyphStyleOverride=ascii` forces ASCII chrome across kendex Pi extensions while leaving tool/model/user content unchanged.
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
- ### Long-session budget guard
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
- For long autonomous runs the agent may not go idle, so the transcript can grow until provider or buffer limits hit. The budget guard starts bounded compaction when context usage crosses a configured threshold, while giving Pi's built-in compaction priority and avoiding duplicate attempts. While it runs, QOL keeps a persistent status line above the prompt (and in the normal status footer when the compact statusline is disabled); after Pi prints the compacted-summary block the line changes to `QOL budget guard finalizing compaction…` until finalization completes, so long reload gaps do not look frozen.
38
+ - `enabled`: package toggle for everything below.
39
+ - Statusline and editor: `statusline.enabled`, `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
- Budget-guard compaction always uses QOL's chunked summarizer, even if **Custom compaction summaries** is off, and writes a pre-compaction handoff artifact only when **Write pre-compaction handoff artifact** is enabled. Manual/user-triggered and idle compactions use the QOL chunked path only when **Custom compaction summaries** is on, and follow the same handoff-artifact toggle. `/tree` branch summaries separately use QOL's chunked summarizer when **Custom branch summaries** is on, but do not write handoff artifacts. When the relevant summarization setting is off, Pi uses its default behavior for that compaction type. Recommended for long autonomous runs: keep **Long-session budget guard** on, and lower **Budget guard percent** to `75` if your provider buffers are tight. Optionally turn **Custom compaction summaries** on so user-initiated and idle compactions also use the QOL chunked summarizer — with **Write pre-compaction handoff artifact** enabled, those compactions also write handoff artifacts. Lower **Chunked compaction input cap** to ~`120000` when the summarizer model has a small context window.
49
+ Maintainer notes are in [DEVELOPMENT.md](DEVELOPMENT.md).
@@ -116,7 +116,7 @@ export class BudgetGuardDriver {
116
116
  return true;
117
117
  }
118
118
 
119
- /** Dispatch a trigger previously staged by agent_end. */
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
- function expandHome(input: string): string {
26
- if (input === "~") return homedir();
27
- if (input.startsWith("~/")) return join(homedir(), input.slice(2));
28
- return input;
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
- return resolve(expandHome(process.env.PI_CODING_AGENT_DIR?.trim() || "~/.pi/agent"));
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. Used to give the handoff artifact a quick "if you
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)
@@ -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 previously contributed to resize/input races.
88
+ /// setStatus side effect that can cause resize and input races.
89
89
  function syncQolEditorStatus(
90
90
  ctx: ExtensionContext,
91
91
  text: string,
@@ -1,6 +1,4 @@
1
- import { existsSync, readFileSync } from "node:fs";
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 userDir = resolve(expandHome(process.env.PI_CODING_AGENT_DIR?.trim() || "~/.pi/agent"));
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 readkendexConfig(cwd?: string): kendexConfig {
67
- const merged: kendexConfig = {};
68
- for (const path of piSettingsPaths(cwd)) {
69
- if (!existsSync(path)) continue;
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(path, "utf8"));
72
- const config = parsed?.kendex?.extensionManager?.config?.[CONFIG_ID];
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillagreen/pi-qol",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
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": [