@docyrus/docyrus 0.0.22 → 0.0.24

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 (28) hide show
  1. package/README.md +12 -0
  2. package/main.js +234 -11
  3. package/main.js.map +4 -4
  4. package/package.json +6 -4
  5. package/resources/pi-agent/assets/docyrus-logo.svg +16 -0
  6. package/resources/pi-agent/extensions/architect.ts +771 -0
  7. package/resources/pi-agent/extensions/notify.ts +57 -55
  8. package/resources/pi-agent/extensions/pi-custom-compaction/CHANGELOG.md +27 -0
  9. package/resources/pi-agent/extensions/pi-custom-compaction/LICENSE +21 -0
  10. package/resources/pi-agent/extensions/pi-custom-compaction/README.md +244 -0
  11. package/resources/pi-agent/extensions/pi-custom-compaction/VENDORED_FROM.md +6 -0
  12. package/resources/pi-agent/extensions/pi-custom-compaction/banner.png +0 -0
  13. package/resources/pi-agent/extensions/pi-custom-compaction/commands/register-commands.ts +63 -0
  14. package/resources/pi-agent/extensions/pi-custom-compaction/events/register-events.ts +229 -0
  15. package/resources/pi-agent/extensions/pi-custom-compaction/index.ts +10 -0
  16. package/resources/pi-agent/extensions/pi-custom-compaction/package.json +57 -0
  17. package/resources/pi-agent/extensions/pi-custom-compaction/paths.ts +13 -0
  18. package/resources/pi-agent/extensions/pi-custom-compaction/policy/config.ts +32 -0
  19. package/resources/pi-agent/extensions/pi-custom-compaction/policy/merge.ts +67 -0
  20. package/resources/pi-agent/extensions/pi-custom-compaction/policy/parse.ts +354 -0
  21. package/resources/pi-agent/extensions/pi-custom-compaction/policy/types.ts +131 -0
  22. package/resources/pi-agent/extensions/pi-custom-compaction/runtime/model-resolution.ts +77 -0
  23. package/resources/pi-agent/extensions/pi-custom-compaction/runtime/pure.ts +56 -0
  24. package/resources/pi-agent/extensions/pi-custom-compaction/runtime/session-state.ts +244 -0
  25. package/resources/pi-agent/extensions/pi-custom-compaction/summary/generate.ts +184 -0
  26. package/resources/pi-agent/extensions/pi-custom-compaction/summary/template.ts +124 -0
  27. package/server-loader.js +4017 -0
  28. package/server-loader.js.map +7 -0
@@ -9,80 +9,82 @@
9
9
  */
10
10
 
11
11
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
12
- import { Markdown, type MarkdownTheme } from "@mariozechner/pi-tui";
12
+
13
+ export const DOCYRUS_NOTIFICATION_TITLE = "docyrus";
13
14
 
14
15
  /**
15
16
  * Send a desktop notification via OSC 777 escape sequence.
16
17
  */
17
18
  const notify = (title: string, body: string): void => {
18
19
  // OSC 777 format: ESC ] 777 ; notify ; title ; body BEL
19
- process.stdout.write(`\x1b]777;notify;${title};${body}\x07`);
20
+ process.stdout.write(`\x1b]777;notify;${title};${body}\x07`);
20
21
  };
21
22
 
22
23
  const isTextPart = (part: unknown): part is { type: "text"; text: string } =>
23
- Boolean(part && typeof part === "object" && "type" in part && part.type === "text" && "text" in part);
24
-
25
- const extractLastAssistantText = (messages: Array<{ role?: string; content?: unknown }>): string | null => {
26
- for (let i = messages.length - 1; i >= 0; i--) {
27
- const message = messages[i];
28
- if (message?.role !== "assistant") {
29
- continue;
30
- }
24
+ Boolean(part && typeof part === "object" && "type" in part && part.type === "text" && "text" in part);
31
25
 
32
- const content = message.content;
33
- if (typeof content === "string") {
34
- return content.trim() || null;
35
- }
26
+ export const extractLastAssistantText = (messages: Array<{ role?: string; content?: unknown }>): string | null => {
27
+ for (let i = messages.length - 1; i >= 0; i--) {
28
+ const message = messages[i];
29
+ if (message?.role !== "assistant") {
30
+ continue;
31
+ }
36
32
 
37
- if (Array.isArray(content)) {
38
- const text = content.filter(isTextPart).map((part) => part.text).join("\n").trim();
39
- return text || null;
40
- }
33
+ const content = message.content;
34
+ if (typeof content === "string") {
35
+ return content.trim() || null;
36
+ }
41
37
 
42
- return null;
43
- }
38
+ if (Array.isArray(content)) {
39
+ const text = content.filter(isTextPart).map((part) => part.text).join("\n").trim();
40
+ return text || null;
41
+ }
44
42
 
45
- return null;
46
- };
43
+ return null;
44
+ }
47
45
 
48
- const plainMarkdownTheme: MarkdownTheme = {
49
- heading: (text) => text,
50
- link: (text) => text,
51
- linkUrl: () => "",
52
- code: (text) => text,
53
- codeBlock: (text) => text,
54
- codeBlockBorder: () => "",
55
- quote: (text) => text,
56
- quoteBorder: () => "",
57
- hr: () => "",
58
- listBullet: () => "",
59
- bold: (text) => text,
60
- italic: (text) => text,
61
- strikethrough: (text) => text,
62
- underline: (text) => text,
46
+ return null;
63
47
  };
64
48
 
65
- const simpleMarkdown = (text: string, width = 80): string => {
66
- const markdown = new Markdown(text, 0, 0, plainMarkdownTheme);
67
- return markdown.render(width).join("\n");
49
+ export const simpleMarkdown = (text: string, _width = 80): string => {
50
+ return text
51
+ .replace(/```[\s\S]*?```/g, (block) => block.replace(/^```[^\n]*\n?/, "").replace(/\n?```$/, ""))
52
+ .replace(/`([^`]+)`/g, "$1")
53
+ .replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1")
54
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
55
+ .replace(/^#{1,6}\s*/gm, "")
56
+ .replace(/^>\s?/gm, "")
57
+ .replace(/^[-*+]\s+/gm, "")
58
+ .replace(/^\d+\.\s+/gm, "")
59
+ .replace(/^---+$/gm, "")
60
+ .replace(/^___+$/gm, "")
61
+ .replace(/^\*{3,}$/gm, "")
62
+ .replace(/(\*\*|__)(.*?)\1/g, "$2")
63
+ .replace(/(\*|_)(.*?)\1/g, "$2")
64
+ .replace(/~~(.*?)~~/g, "$1")
65
+ .split("\n")
66
+ .map((line) => line.trimEnd())
67
+ .join("\n");
68
68
  };
69
69
 
70
- const formatNotification = (text: string | null): { title: string; body: string } => {
71
- const simplified = text ? simpleMarkdown(text) : "";
72
- const normalized = simplified.replace(/\s+/g, " ").trim();
73
- if (!normalized) {
74
- return { title: "Ready for input", body: "" };
75
- }
70
+ // The Docyrus logo SVG is packaged for future notification backends that support
71
+ // icons, but the current OSC 777 transport only supports title/body text.
72
+ export const formatNotification = (text: string | null): { title: string; body: string } => {
73
+ const simplified = text ? simpleMarkdown(text) : "";
74
+ const normalized = simplified.replace(/\s+/g, " ").trim();
75
+ if (!normalized) {
76
+ return { title: DOCYRUS_NOTIFICATION_TITLE, body: "Ready for input" };
77
+ }
76
78
 
77
- const maxBody = 200;
78
- const body = normalized.length > maxBody ? `${normalized.slice(0, maxBody - 1)}…` : normalized;
79
- return { title: "π", body };
79
+ const maxBody = 200;
80
+ const body = normalized.length > maxBody ? `${normalized.slice(0, maxBody - 1)}…` : normalized;
81
+ return { title: DOCYRUS_NOTIFICATION_TITLE, body };
80
82
  };
81
83
 
82
- export default function (pi: ExtensionAPI) {
83
- pi.on("agent_end", async (event) => {
84
- const lastText = extractLastAssistantText(event.messages ?? []);
85
- const { title, body } = formatNotification(lastText);
86
- notify(title, body);
87
- });
84
+ export default function(pi: ExtensionAPI) {
85
+ pi.on("agent_end", async(event) => {
86
+ const lastText = extractLastAssistantText(event.messages ?? []);
87
+ const { title, body } = formatNotification(lastText);
88
+ notify(title, body);
89
+ });
88
90
  }
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 — 2026-03-22
4
+
5
+ - **Profile model overrides** — profiles can now override the `models` list per session model. Use a different summarization model when chatting with Opus vs Codex.
6
+ - **Profile template paths** — profiles can specify explicit `template` and `updateTemplate` paths, overriding convention-based discovery. Tilde-expanded.
7
+ - **Compaction spinner widget** — animated `Loader` spinner displays during extension-initiated compaction, matching pi's built-in appearance.
8
+ - **Post-compaction status fix** — status bar no longer shows `?` for 1-2 messages after compaction. Shows just the label until token counts are available again.
9
+ - **Watchdog widget cleanup** — if compaction hangs and the 2-minute watchdog fires, the spinner widget is now properly removed.
10
+ - **Test suite** — 62 tests across 6 files covering parse, merge, config, pure logic, model resolution, and template discovery. Run with `tsx --test test/*.test.ts`.
11
+
12
+ ## 0.1.0 — 2026-03-21
13
+
14
+ Initial release.
15
+
16
+ Custom compaction for Pi — swap the model used for compaction summaries, define your own summary template structure, and optionally trigger compaction at a specific token count. Everything is driven by a JSON config file with no UI overlay.
17
+
18
+ Core features:
19
+
20
+ - **Custom compaction model** with ordered fallback chain (`models`). If one provider's credits run out, the next model takes over. Per-model `thinkingLevel` and `preservationInstruction` overrides.
21
+ - **Token-based trigger** (`trigger.maxTokens`). Omit to let Pi's built-in decide when to compact. Set a value to proactively compact at that token count.
22
+ - **Custom summary templates** via convention-based markdown files. Separate initial and update templates so the model knows what to extract vs how to merge. Profile-specific templates supported. Entirely optional — Pi's built-in format works without one.
23
+ - **Profiles** — named overrides for trigger and summary settings that activate based on the session model. Match on exact `provider/modelId`.
24
+ - **Global and project config** — `~/.pi/agent/compaction-policy.json` (global) and `<project>/.pi/compaction-policy.json` (project, takes priority).
25
+ - **Status bar** with configurable label (`ui.name`), showing token usage relative to the effective trigger point.
26
+ - **Commands**: `/compact-policy` (show effective config) and `/compact-now [focus]` (trigger immediately).
27
+ - **Builtin skip margin** prevents double-triggering when the extension's trigger is close to Pi's own compaction threshold.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nico Bailon
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.
@@ -0,0 +1,244 @@
1
+ <p>
2
+ <img src="banner.png" alt="pi-custom-compaction" width="1100">
3
+ </p>
4
+
5
+ # pi-custom-compaction
6
+
7
+ Swap the model and template Pi uses for compaction. Optionally trigger compaction at a specific token count.
8
+
9
+ Once enabled, the extension intercepts every compaction — whether triggered by Pi's built-in or by the extension itself — and uses your configured model and template to generate the summary. If all configured models fail to resolve, it falls back to Pi's built-in compaction silently.
10
+
11
+ Off by default. Pi's built-in compaction works normally until you enable it.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pi install npm:pi-custom-compaction
17
+ ```
18
+
19
+ ## Quick start
20
+
21
+ Create `~/.pi/agent/compaction-policy.json` (global) or `<project>/.pi/compaction-policy.json` (project, takes priority):
22
+
23
+ ```json
24
+ {
25
+ "enabled": true,
26
+ "models": [
27
+ { "model": "anthropic/claude-sonnet-4", "thinkingLevel": "medium" }
28
+ ]
29
+ }
30
+ ```
31
+
32
+ Run `/reload`. Done. Pi still decides when to compact — you just swapped the model.
33
+
34
+ To also control **when** it triggers:
35
+
36
+ ```json
37
+ {
38
+ "enabled": true,
39
+ "trigger": { "maxTokens": 350000 },
40
+ "ui": { "name": "ctx" },
41
+ "models": [
42
+ { "model": "anthropic/claude-haiku-4-5", "thinkingLevel": "medium" },
43
+ { "model": "openai-codex/gpt-5.3-codex", "thinkingLevel": "low" }
44
+ ]
45
+ }
46
+ ```
47
+
48
+ Status bar shows: `ctx · 24.7% (86426/350000)`
49
+
50
+ ## Commands
51
+
52
+ | Command | What it does |
53
+ | --- | --- |
54
+ | `/compact-policy` | Shows effective config (models, trigger, profile, template) |
55
+ | `/compact-now [focus]` | Triggers compaction immediately |
56
+
57
+ ## Models
58
+
59
+ Ordered fallback chain. Tries each model in order, uses the first one that resolves. If credits run out on one, the next takes over.
60
+
61
+ Plain strings inherit base `summary` settings. Objects let you override per model:
62
+
63
+ ```json
64
+ "models": [
65
+ { "model": "anthropic/claude-sonnet-4", "thinkingLevel": "medium" },
66
+ "openai-codex/gpt-5.3-codex"
67
+ ]
68
+ ```
69
+
70
+ ## Trigger
71
+
72
+ | Key | What it does | Default |
73
+ | --- | --- | --- |
74
+ | `maxTokens` | Compact at this token count. Omit to let Pi decide. | — |
75
+ | `minTokens` | Won't trigger below this count | 100000 |
76
+ | `cooldownMs` | Min time between proactive compactions | 60000 |
77
+
78
+ `maxTokens` makes compaction happen sooner. Without it, Pi waits until the context window is almost full (~984K on a 1M model). With `maxTokens: 350000`, compaction fires at 350K instead.
79
+
80
+ ## How maxTokens interacts with the context window
81
+
82
+ You don't need to tune `maxTokens` per model. One config works across models with different context sizes:
83
+
84
+ - **Well below context window** (350K on a 1M model) — extension fires at 350K, plenty of room for the summary.
85
+ - **Close to context window** (260K on a 272K model) — extension backs off and lets Pi's built-in fire at 256K with its own reserve, preventing double-compaction.
86
+ - **Larger than context window** (350K on a 272K model) — proactive trigger can never fire, Pi handles it at 256K.
87
+
88
+ <details>
89
+ <summary>Advanced trigger tuning</summary>
90
+
91
+ | Key | What it does | Default |
92
+ | --- | --- | --- |
93
+ | `builtinReserveTokens` | Tokens Pi's built-in reserves before triggering | 16384 |
94
+ | `builtinSkipMarginPercent` | Skip if Pi's builtin would trigger within this margin | 5 |
95
+
96
+ </details>
97
+
98
+ ## Profiles
99
+
100
+ Override trigger, models, and summary settings per session model:
101
+
102
+ ```json
103
+ "profiles": {
104
+ "opus-large-ctx": {
105
+ "match": "anthropic/claude-opus-4-6",
106
+ "trigger": { "maxTokens": 500000 },
107
+ "models": [{ "model": "anthropic/claude-haiku-4-5", "thinkingLevel": "medium" }],
108
+ "template": "~/.pi/agent/templates/opus.md",
109
+ "updateTemplate": "~/.pi/agent/templates/opus-update.md"
110
+ },
111
+ "fast-codex": {
112
+ "match": "openai-codex/gpt-5.3-codex",
113
+ "models": ["openai-codex/gpt-5.3-codex"],
114
+ "summary": { "thinkingLevel": "low" }
115
+ }
116
+ }
117
+ ```
118
+
119
+ `match` is the exact `provider/modelId` of the session model. First alphabetical match wins. Profile `models` replaces the base models list for that session. `template` and `updateTemplate` override template discovery with explicit paths (tilde-expanded). Active profile shows in the status bar.
120
+
121
+ ## Templates (optional)
122
+
123
+ Without a template, Pi's built-in compaction format is used. To customize the summary structure, drop markdown files at convention paths — no config needed.
124
+
125
+ Two template types:
126
+ - **Initial** (`compaction-template.md`) — first compaction, brackets describe what to extract
127
+ - **Update** (`compaction-template-update.md`) — subsequent compactions, brackets describe how to merge (optional, falls back to initial)
128
+
129
+ Discovery order (first found wins):
130
+
131
+ ```
132
+ Initial template:
133
+ <project>/.pi/compaction-templates/PROFILE.md
134
+ ~/.pi/agent/compaction-templates/PROFILE.md
135
+ <project>/.pi/compaction-template.md
136
+ ~/.pi/agent/compaction-template.md
137
+
138
+ Update template:
139
+ <project>/.pi/compaction-templates/PROFILE-update.md
140
+ ~/.pi/agent/compaction-templates/PROFILE-update.md
141
+ <project>/.pi/compaction-template-update.md
142
+ ~/.pi/agent/compaction-template-update.md
143
+ ```
144
+
145
+ Profile-specific paths are only checked when a profile is active. Template files are never modified — they're format definitions read on every compaction. The model fills in the brackets based on the conversation.
146
+
147
+ Example initial template (`compaction-template.md`):
148
+
149
+ ```markdown
150
+ ## Goal
151
+ [What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
152
+
153
+ ## Constraints & Preferences
154
+ - [Any constraints, preferences, or requirements mentioned by user]
155
+ - [Or "(none)" if none were mentioned]
156
+
157
+ ## Progress
158
+ ### Done
159
+ - [x] [Completed tasks/changes]
160
+
161
+ ### In Progress
162
+ - [ ] [Current work]
163
+
164
+ ### Blocked
165
+ - [Issues preventing progress, if any]
166
+
167
+ ## Key Decisions
168
+ - **[Decision]**: [Brief rationale]
169
+
170
+ ## Next Steps
171
+ 1. [Ordered list of what should happen next]
172
+
173
+ ## Critical Context
174
+ - [Any data, examples, or references needed to continue]
175
+ - [Or "(none)" if not applicable]
176
+ ```
177
+
178
+ Example update template (`compaction-template-update.md`):
179
+
180
+ ```markdown
181
+ ## Goal
182
+ [Preserve existing goals, add new ones if the task expanded]
183
+
184
+ ## Constraints & Preferences
185
+ - [Preserve existing, add new ones discovered]
186
+
187
+ ## Progress
188
+ ### Done
189
+ - [x] [Include previously done items AND newly completed items]
190
+
191
+ ### In Progress
192
+ - [ ] [Current work - update based on progress]
193
+
194
+ ### Blocked
195
+ - [Current blockers - remove if resolved]
196
+
197
+ ## Key Decisions
198
+ - **[Decision]**: [Brief rationale] (preserve all previous, add new)
199
+
200
+ ## Next Steps
201
+ 1. [Update based on current state]
202
+
203
+ ## Critical Context
204
+ - [Preserve important context, add new if needed]
205
+ ```
206
+
207
+ `summary.preservationInstruction` is appended as an extra directive after the template.
208
+
209
+ ## UI options
210
+
211
+ ```json
212
+ "ui": {
213
+ "name": "ctx",
214
+ "showStatus": true,
215
+ "minimalStatus": false,
216
+ "quiet": false
217
+ }
218
+ ```
219
+
220
+ | Key | What it does | Default |
221
+ | --- | --- | --- |
222
+ | `name` | Status bar label | `"compact"` |
223
+ | `showStatus` | Show status bar | `true` |
224
+ | `minimalStatus` | Short format (just percentage) | `false` |
225
+ | `quiet` | Suppress non-critical notifications | `false` |
226
+
227
+ Status bar examples:
228
+
229
+ ```
230
+ ctx · 24.7% (86426/350000)
231
+ ctx: opus-large-ctx · 50.1% (250500/500000)
232
+ ctx · 31%
233
+ ```
234
+
235
+ ## Summary options
236
+
237
+ ```json
238
+ "summary": {
239
+ "thinkingLevel": "medium",
240
+ "preservationInstruction": "Preserve exact file paths, function names, and error messages."
241
+ }
242
+ ```
243
+
244
+ These are base settings. Model entries and profiles can override `thinkingLevel` and `preservationInstruction` individually.
@@ -0,0 +1,6 @@
1
+ Vendored from [`nicobailon/pi-custom-compaction`](https://github.com/nicobailon/pi-custom-compaction)
2
+
3
+ - Upstream commit: `ac69e833c4dc00b4961c65daa2807017bed86e8b`
4
+ - Vendored for: `docyrus agent` / `docyrus coder`
5
+ - Local adaptation:
6
+ - prefer `PI_CODING_AGENT_DIR` for global policy/template lookup so scoped Docyrus agent state works
@@ -0,0 +1,63 @@
1
+ import type { ExtensionAPI, ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
2
+ import { resolveEffectivePolicy } from "../runtime/pure.js";
3
+ import type { IRuntimeServices } from "../runtime/session-state.js";
4
+ import { discoverTemplate } from "../summary/template.js";
5
+
6
+ function formatModels(policy: { models: Array<{ model: string; thinkingLevel?: string }> }): string {
7
+ return policy.models
8
+ .map((e) => (e.thinkingLevel ? `${e.model} (thinking: ${e.thinkingLevel})` : e.model))
9
+ .join(" → ");
10
+ }
11
+
12
+ function formatTrigger(policy: {
13
+ trigger: { maxTokens?: number; minTokens: number; cooldownMs: number };
14
+ }): string {
15
+ const { maxTokens, minTokens, cooldownMs } = policy.trigger;
16
+ const threshold = maxTokens && maxTokens > 0 ? `${maxTokens} tokens` : "inherited from pi";
17
+ return `${threshold} | minTokens: ${minTokens} | cooldown: ${cooldownMs}ms`;
18
+ }
19
+
20
+ export function registerCommands(pi: ExtensionAPI, runtime: IRuntimeServices): void {
21
+ pi.registerCommand("compact-policy", {
22
+ description: "Show current compaction policy",
23
+ handler: async(_args, ctx: ExtensionCommandContext) => {
24
+ const basePolicy = runtime.loadEffectivePolicy(ctx);
25
+ const { policy, profileName, sessionModel, profileTemplates } = resolveEffectivePolicy(ctx, basePolicy);
26
+ const template = discoverTemplate(ctx.cwd, profileName, profileTemplates);
27
+ const templatePath = template.fallbackReason
28
+ ? `${template.resolvedPath ?? "(unknown)"} (invalid: ${template.fallbackReason}; using built-in)`
29
+ : template.resolvedPath ?? "(none — using built-in)";
30
+ const updateTemplatePath = template.updateFallbackReason
31
+ ? `${template.updateResolvedPath ?? "(unknown)"} (invalid: ${template.updateFallbackReason}; using initial template)`
32
+ : template.updateResolvedPath ?? "(none — using initial template)";
33
+
34
+ const lines = [
35
+ `enabled: ${policy.enabled}`,
36
+ `models: ${formatModels(policy)}`,
37
+ `trigger: ${formatTrigger(policy)}`,
38
+ `summary: thinking=${policy.summary.thinkingLevel}`,
39
+ `session model: ${sessionModel ?? "unknown"}`,
40
+ `profile: ${profileName ?? "none"}`,
41
+ `template: ${templatePath}`,
42
+ `template update: ${updateTemplatePath}`,
43
+ ];
44
+ ctx.ui.notify(lines.join("\n"), "info");
45
+ },
46
+ });
47
+
48
+ pi.registerCommand("compact-now", {
49
+ description: "Trigger compaction immediately",
50
+ handler: async(args, ctx: ExtensionCommandContext) => {
51
+ const basePolicy = runtime.loadEffectivePolicy(ctx);
52
+ const { policy, profileName } = resolveEffectivePolicy(ctx, basePolicy);
53
+ runtime.setActiveProfileName(profileName);
54
+
55
+ const focus = args.trim() || undefined;
56
+ if (!policy.enabled) {
57
+ ctx.compact({ customInstructions: focus });
58
+ return;
59
+ }
60
+ runtime.triggerCompaction(ctx, policy, "compact-now", focus);
61
+ },
62
+ });
63
+ }