@oh-my-pi/pi-coding-agent 15.9.0 → 15.9.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/types/cli/update-cli.d.ts +15 -1
  3. package/dist/types/config/append-only-context-mode.d.ts +8 -0
  4. package/dist/types/config/model-registry.d.ts +3 -0
  5. package/dist/types/config/models-config-schema.d.ts +15 -0
  6. package/dist/types/config/settings-schema.d.ts +3 -3
  7. package/dist/types/exa/mcp-client.d.ts +2 -1
  8. package/dist/types/mcp/json-rpc.d.ts +6 -1
  9. package/dist/types/mcp/tool-bridge.d.ts +4 -0
  10. package/dist/types/mnemopi/state.d.ts +2 -2
  11. package/dist/types/modes/components/agent-dashboard.d.ts +1 -0
  12. package/dist/types/modes/components/extensions/extension-dashboard.d.ts +1 -0
  13. package/dist/types/modes/components/plugin-settings.d.ts +40 -8
  14. package/dist/types/modes/components/session-selector.d.ts +8 -3
  15. package/dist/types/modes/components/settings-selector.d.ts +1 -1
  16. package/dist/types/modes/utils/keybinding-matchers.d.ts +4 -0
  17. package/dist/types/session/agent-session.d.ts +4 -1
  18. package/dist/types/session/history-storage.d.ts +3 -4
  19. package/dist/types/session/messages.d.ts +1 -0
  20. package/dist/types/session/session-manager.d.ts +1 -0
  21. package/dist/types/slash-commands/types.d.ts +17 -4
  22. package/dist/types/tiny/text.d.ts +17 -0
  23. package/dist/types/web/search/providers/base.d.ts +14 -0
  24. package/dist/types/web/search/providers/exa.d.ts +9 -0
  25. package/dist/types/web/search/providers/perplexity.d.ts +2 -2
  26. package/dist/types/web/search/types.d.ts +2 -1
  27. package/package.json +9 -9
  28. package/src/cli/session-picker.ts +1 -0
  29. package/src/cli/update-cli.ts +54 -2
  30. package/src/commands/completions.ts +1 -1
  31. package/src/config/append-only-context-mode.ts +37 -0
  32. package/src/config/models-config-schema.ts +1 -0
  33. package/src/config/settings-schema.ts +2 -2
  34. package/src/exa/mcp-client.ts +11 -5
  35. package/src/internal-urls/docs-index.generated.ts +1 -1
  36. package/src/main.ts +4 -2
  37. package/src/mcp/json-rpc.ts +8 -0
  38. package/src/mcp/render.ts +3 -0
  39. package/src/mcp/tool-bridge.ts +10 -2
  40. package/src/mcp/transports/http.ts +33 -16
  41. package/src/mnemopi/state.ts +4 -4
  42. package/src/modes/acp/acp-agent.ts +168 -3
  43. package/src/modes/components/agent-dashboard.ts +103 -31
  44. package/src/modes/components/extensions/extension-dashboard.ts +56 -10
  45. package/src/modes/components/history-search.ts +128 -14
  46. package/src/modes/components/plugin-settings.ts +270 -36
  47. package/src/modes/components/session-selector.ts +45 -14
  48. package/src/modes/components/settings-selector.ts +1 -1
  49. package/src/modes/components/tips.txt +5 -1
  50. package/src/modes/components/transcript-container.ts +22 -4
  51. package/src/modes/controllers/command-controller.ts +4 -3
  52. package/src/modes/controllers/input-controller.ts +10 -5
  53. package/src/modes/controllers/selector-controller.ts +30 -19
  54. package/src/modes/interactive-mode.ts +38 -3
  55. package/src/modes/utils/keybinding-matchers.ts +10 -0
  56. package/src/prompts/steering/user-interjection.md +10 -0
  57. package/src/prompts/system/agent-creation-architect.md +1 -26
  58. package/src/prompts/system/system-prompt.md +143 -145
  59. package/src/prompts/system/title-system.md +3 -2
  60. package/src/prompts/tools/browser.md +29 -29
  61. package/src/prompts/tools/render-mermaid.md +2 -2
  62. package/src/sdk.ts +5 -21
  63. package/src/session/agent-session.ts +30 -7
  64. package/src/session/history-storage.ts +11 -18
  65. package/src/session/messages.ts +80 -0
  66. package/src/session/session-manager.ts +7 -1
  67. package/src/slash-commands/types.ts +27 -10
  68. package/src/tiny/text.ts +112 -1
  69. package/src/tools/memory-recall.ts +1 -1
  70. package/src/tools/memory-reflect.ts +1 -1
  71. package/src/tools/ssh.ts +26 -10
  72. package/src/tools/write.ts +14 -2
  73. package/src/tui/status-line.ts +15 -4
  74. package/src/utils/title-generator.ts +9 -2
  75. package/src/web/search/index.ts +3 -1
  76. package/src/web/search/provider.ts +1 -1
  77. package/src/web/search/providers/base.ts +17 -0
  78. package/src/web/search/providers/exa.ts +111 -7
  79. package/src/web/search/providers/perplexity.ts +8 -4
  80. package/src/web/search/types.ts +2 -1
@@ -20,6 +20,7 @@ import {
20
20
  Text,
21
21
  truncateToWidth,
22
22
  visibleWidth,
23
+ wrapTextWithAnsi,
23
24
  } from "@oh-my-pi/pi-tui";
24
25
  import { Settings } from "../../../config/settings";
25
26
  import { DynamicBorder } from "../../../modes/components/dynamic-border";
@@ -37,11 +38,15 @@ import {
37
38
  } from "./state-manager";
38
39
  import type { DashboardState } from "./types";
39
40
 
41
+ const EXT_FOOTER = " ↑/↓: navigate Space: toggle ←/→: provider Esc: close";
42
+
40
43
  export class ExtensionDashboard extends Container {
41
44
  #state!: DashboardState;
42
45
  #mainList!: ExtensionList;
43
46
  #inspector!: InspectorPanel;
44
47
  #refreshToken = 0;
48
+ #builtRows = -1;
49
+ #builtCols = -1;
45
50
 
46
51
  onClose?: () => void;
47
52
  onRequestRender?: () => void;
@@ -71,7 +76,7 @@ export class ExtensionDashboard extends Container {
71
76
 
72
77
  // Calculate max visible items based on terminal height
73
78
  // Reserve ~10 lines for header, tabs, help text, borders
74
- const maxVisible = Math.max(5, Math.floor((this.terminalHeight - 10) / 2));
79
+ const maxVisible = this.#maxVisibleItems();
75
80
 
76
81
  // Create main list - always focused
77
82
  this.#mainList = new ExtensionList(
@@ -107,6 +112,45 @@ export class ExtensionDashboard extends Container {
107
112
  return tab && tab.id !== "all" ? tab.id : null;
108
113
  }
109
114
 
115
+ /** Live terminal height so the dashboard tracks resize while open. */
116
+ #terminalRows(): number {
117
+ return process.stdout.rows || this.terminalHeight || 24;
118
+ }
119
+
120
+ #uiWidth(): number {
121
+ return Math.max(20, process.stdout.columns || 80);
122
+ }
123
+
124
+ #footerLines(): number {
125
+ return Math.max(1, wrapTextWithAnsi(theme.fg("dim", EXT_FOOTER), this.#uiWidth()).length);
126
+ }
127
+
128
+ /** Height budget for the two-column body, sized to the live terminal. */
129
+ #computeBodyHeight(): number {
130
+ // Chrome: top border + title + tab bar + spacer (4), then spacer + footer + bottom border.
131
+ const chrome = 4 + 1 + this.#footerLines() + 1;
132
+ return Math.max(5, this.#terminalRows() - chrome);
133
+ }
134
+
135
+ #maxVisibleItems(): number {
136
+ // List chrome inside the body: search line, blank line, scroll indicator.
137
+ return Math.max(3, this.#computeBodyHeight() - 3);
138
+ }
139
+
140
+ override render(width: number): string[] {
141
+ // Rebuild when terminal geometry changes so the full-screen overlay
142
+ // re-fits on resize.
143
+ if (this.#terminalRows() !== this.#builtRows || this.#uiWidth() !== this.#builtCols) {
144
+ this.#buildLayout();
145
+ }
146
+ const lines = super.render(width);
147
+ // Pad to the full viewport so the dashboard covers the screen instead of
148
+ // letting the transcript peek through below it.
149
+ const rows = this.#terminalRows();
150
+ while (lines.length < rows) lines.push("");
151
+ return lines;
152
+ }
153
+
110
154
  #buildLayout(): void {
111
155
  this.clear();
112
156
 
@@ -120,16 +164,18 @@ export class ExtensionDashboard extends Container {
120
164
  this.addChild(new Text(this.#renderTabBar(), 0, 0));
121
165
  this.addChild(new Spacer(1));
122
166
 
123
- // 2-column body with height limit
124
- // Reserve ~8 lines for header, tabs, help text, borders
125
- const bodyMaxHeight = Math.max(5, this.terminalHeight - 8);
167
+ // 2-column body sized to fill the live terminal viewport.
168
+ const bodyMaxHeight = this.#computeBodyHeight();
169
+ this.#mainList.setMaxVisible(this.#maxVisibleItems());
126
170
  this.addChild(new TwoColumnBody(this.#mainList, this.#inspector, bodyMaxHeight));
127
171
 
128
172
  this.addChild(new Spacer(1));
129
- this.addChild(new Text(theme.fg("dim", " ↑/↓: navigate Space: toggle Tab: next provider Esc: close"), 0, 0));
173
+ this.addChild(new Text(theme.fg("dim", EXT_FOOTER), 0, 0));
130
174
 
131
175
  // Bottom border
132
176
  this.addChild(new DynamicBorder());
177
+ this.#builtRows = this.#terminalRows();
178
+ this.#builtCols = this.#uiWidth();
133
179
  }
134
180
 
135
181
  #renderTabBar(): string {
@@ -289,12 +335,12 @@ export class ExtensionDashboard extends Container {
289
335
  return;
290
336
  }
291
337
 
292
- // Tab/Shift+Tab: Cycle through tabs
293
- if (matchesKey(data, "tab")) {
338
+ // Tab/Shift+Tab or Left/Right: Cycle through tabs
339
+ if (matchesKey(data, "tab") || matchesKey(data, "right")) {
294
340
  this.#switchTab(1);
295
341
  return;
296
342
  }
297
- if (matchesKey(data, "shift+tab")) {
343
+ if (matchesKey(data, "shift+tab") || matchesKey(data, "left")) {
298
344
  this.#switchTab(-1);
299
345
  return;
300
346
  }
@@ -328,8 +374,8 @@ class TwoColumnBody implements Component {
328
374
  const leftLines = this.leftPane.render(leftWidth);
329
375
  const rightLines = this.rightPane.render(rightWidth);
330
376
 
331
- // Limit to maxHeight lines
332
- const numLines = Math.min(this.maxHeight, Math.max(leftLines.length, rightLines.length));
377
+ // Fill the full body height so the dashboard reads as a full-screen view.
378
+ const numLines = this.maxHeight;
333
379
  const combined: string[] = [];
334
380
  const separator = theme.fg("dim", ` ${theme.boxSharp.vertical} `);
335
381
 
@@ -11,18 +11,82 @@ import {
11
11
  visibleWidth,
12
12
  } from "@oh-my-pi/pi-tui";
13
13
  import { theme } from "../../modes/theme/theme";
14
- import { matchesAppInterrupt, matchesSelectDown, matchesSelectUp } from "../../modes/utils/keybinding-matchers";
14
+ import {
15
+ matchesAppInterrupt,
16
+ matchesSelectDown,
17
+ matchesSelectPageDown,
18
+ matchesSelectPageUp,
19
+ matchesSelectUp,
20
+ } from "../../modes/utils/keybinding-matchers";
15
21
  import type { HistoryEntry, HistoryStorage } from "../../session/history-storage";
16
22
  import { DynamicBorder } from "./dynamic-border";
23
+ import { rawKeyHint } from "./keybinding-hints";
24
+
25
+ /** Visible result rows; also the jump distance for PageUp/PageDown. */
26
+ const MAX_VISIBLE = 10;
27
+
28
+ /** Split a query the same way `HistoryStorage` tokenizes it, so highlights align with matches. */
29
+ function queryTokens(query: string): string[] {
30
+ return query
31
+ .toLowerCase()
32
+ .split(/[^\p{L}\p{N}]+/u)
33
+ .filter(tok => tok.length > 0);
34
+ }
35
+
36
+ /** Wrap every case-insensitive occurrence of any token in `text` with the accent color. */
37
+ function highlightTokens(text: string, tokens: string[]): string {
38
+ if (tokens.length === 0) return text;
39
+
40
+ const lower = text.toLowerCase();
41
+ const ranges: Array<[number, number]> = [];
42
+ for (const tok of tokens) {
43
+ let from = lower.indexOf(tok);
44
+ while (from !== -1) {
45
+ ranges.push([from, from + tok.length]);
46
+ from = lower.indexOf(tok, from + tok.length);
47
+ }
48
+ }
49
+ if (ranges.length === 0) return text;
50
+
51
+ ranges.sort((a, b) => a[0] - b[0]);
52
+ let out = "";
53
+ let pos = 0;
54
+ for (const [start, end] of ranges) {
55
+ if (end <= pos) continue; // fully covered by a previous (merged) range
56
+ const from = Math.max(start, pos);
57
+ if (from > pos) out += text.slice(pos, from);
58
+ out += theme.fg("accent", text.slice(from, end));
59
+ pos = end;
60
+ }
61
+ if (pos < text.length) out += text.slice(pos);
62
+ return out;
63
+ }
64
+
65
+ /** Compact "time since" label (e.g. `now`, `5m`, `2h`, `3d`, `2w`, `6mo`, `1y`) from epoch seconds. */
66
+ function relativeTime(epochSeconds: number): string {
67
+ const seconds = Math.max(0, Math.floor(Date.now() / 1000) - epochSeconds);
68
+ if (seconds < 60) return "now";
69
+ const minutes = Math.floor(seconds / 60);
70
+ if (minutes < 60) return `${minutes}m`;
71
+ const hours = Math.floor(minutes / 60);
72
+ if (hours < 24) return `${hours}h`;
73
+ const days = Math.floor(hours / 24);
74
+ if (days < 7) return `${days}d`;
75
+ if (days < 30) return `${Math.floor(days / 7)}w`;
76
+ if (days < 365) return `${Math.floor(days / 30)}mo`;
77
+ return `${Math.floor(days / 365)}y`;
78
+ }
17
79
 
18
80
  class HistoryResultsList implements Component {
19
81
  #results: HistoryEntry[] = [];
82
+ #tokens: string[] = [];
20
83
  #selectedIndex = 0;
21
- #maxVisible = 10;
84
+ #maxVisible = MAX_VISIBLE;
22
85
 
23
- setResults(results: HistoryEntry[], selectedIndex: number): void {
86
+ setResults(results: HistoryEntry[], selectedIndex: number, tokens: string[]): void {
24
87
  this.#results = results;
25
88
  this.#selectedIndex = selectedIndex;
89
+ this.#tokens = tokens;
26
90
  }
27
91
 
28
92
  setSelectedIndex(selectedIndex: number): void {
@@ -37,10 +101,14 @@ class HistoryResultsList implements Component {
37
101
  const lines: string[] = [];
38
102
 
39
103
  if (this.#results.length === 0) {
40
- lines.push(theme.fg("muted", " No matching history"));
104
+ const message = this.#tokens.length > 0 ? "No matching history" : "No history yet";
105
+ lines.push(theme.fg("muted", ` ${theme.status.info} ${message}`));
41
106
  return lines;
42
107
  }
43
108
 
109
+ const cursorSymbol = `${theme.nav.cursor} `;
110
+ const gutterWidth = visibleWidth(cursorSymbol);
111
+
44
112
  const startIndex = Math.max(
45
113
  0,
46
114
  Math.min(this.#selectedIndex - Math.floor(this.#maxVisible / 2), this.#results.length - this.#maxVisible),
@@ -51,18 +119,32 @@ class HistoryResultsList implements Component {
51
119
  const entry = this.#results[i];
52
120
  const isSelected = i === this.#selectedIndex;
53
121
 
54
- const cursorSymbol = `${theme.nav.cursor} `;
55
- const cursorWidth = visibleWidth(cursorSymbol);
56
- const cursor = isSelected ? theme.fg("accent", cursorSymbol) : padding(cursorWidth);
57
- const maxWidth = width - cursorWidth;
122
+ const timeStr = relativeTime(entry.created_at);
123
+ const timeWidth = visibleWidth(timeStr);
124
+ const showTime = width >= gutterWidth + 12 + timeWidth;
58
125
 
126
+ const promptBudget = Math.max(4, width - gutterWidth - (showTime ? timeWidth + 1 : 0));
59
127
  const normalized = entry.prompt.replace(/\s+/g, " ").trim();
60
- const truncated = truncateToWidth(normalized, maxWidth);
61
- lines.push(cursor + (isSelected ? theme.bold(truncated) : truncated));
128
+ const plain = truncateToWidth(normalized, promptBudget);
129
+ const highlighted = highlightTokens(plain, this.#tokens);
130
+
131
+ const cursor = isSelected ? theme.fg("accent", cursorSymbol) : padding(gutterWidth);
132
+ let line = cursor + (isSelected ? theme.bold(highlighted) : highlighted);
133
+
134
+ if (showTime) {
135
+ // Pad the prompt region so the timestamp sits flush right with a one-cell gap.
136
+ line = `${truncateToWidth(line, width - timeWidth - 1, Ellipsis.Unicode, true)} ${theme.fg("dim", timeStr)}`;
137
+ }
138
+
139
+ lines.push(
140
+ isSelected
141
+ ? theme.bg("selectedBg", truncateToWidth(line, width, Ellipsis.Omit, true))
142
+ : truncateToWidth(line, width),
143
+ );
62
144
  }
63
145
 
64
146
  if (startIndex > 0 || endIndex < this.#results.length) {
65
- const scrollText = ` (${this.#selectedIndex + 1}/${this.#results.length})`;
147
+ const scrollText = ` ${this.#selectedIndex + 1}/${this.#results.length}`;
66
148
  lines.push(theme.fg("muted", truncateToWidth(scrollText, width, Ellipsis.Omit)));
67
149
  }
68
150
 
@@ -99,8 +181,12 @@ export class HistorySearchComponent extends Container {
99
181
 
100
182
  this.#resultsList = new HistoryResultsList();
101
183
 
184
+ const title = theme.bold(theme.fg("accent", `${theme.icon.rewind} Search History`));
185
+ const dot = theme.fg("dim", theme.sep.dot);
186
+ const hint = [rawKeyHint("↑↓", "navigate"), rawKeyHint("enter", "select"), rawKeyHint("esc", "cancel")].join(dot);
187
+
102
188
  this.addChild(new Spacer(1));
103
- this.addChild(new Text(theme.bold("Search History (Ctrl+R)"), 1, 0));
189
+ this.addChild(new Text(title, 1, 0));
104
190
  this.addChild(new Spacer(1));
105
191
  this.addChild(new DynamicBorder());
106
192
  this.addChild(new Spacer(1));
@@ -108,7 +194,7 @@ export class HistorySearchComponent extends Container {
108
194
  this.addChild(new Spacer(1));
109
195
  this.addChild(this.#resultsList);
110
196
  this.addChild(new Spacer(1));
111
- this.addChild(new Text(theme.fg("muted", "up/down navigate enter select esc cancel"), 1, 0));
197
+ this.addChild(new Text(hint, 1, 0));
112
198
  this.addChild(new Spacer(1));
113
199
  this.addChild(new DynamicBorder());
114
200
 
@@ -130,6 +216,34 @@ export class HistorySearchComponent extends Container {
130
216
  return;
131
217
  }
132
218
 
219
+ if (matchesSelectPageUp(keyData)) {
220
+ if (this.#results.length === 0) return;
221
+ this.#selectedIndex = Math.max(0, this.#selectedIndex - MAX_VISIBLE);
222
+ this.#resultsList.setSelectedIndex(this.#selectedIndex);
223
+ return;
224
+ }
225
+
226
+ if (matchesSelectPageDown(keyData)) {
227
+ if (this.#results.length === 0) return;
228
+ this.#selectedIndex = Math.min(this.#results.length - 1, this.#selectedIndex + MAX_VISIBLE);
229
+ this.#resultsList.setSelectedIndex(this.#selectedIndex);
230
+ return;
231
+ }
232
+
233
+ if (matchesKey(keyData, "home")) {
234
+ if (this.#results.length === 0) return;
235
+ this.#selectedIndex = 0;
236
+ this.#resultsList.setSelectedIndex(this.#selectedIndex);
237
+ return;
238
+ }
239
+
240
+ if (matchesKey(keyData, "end")) {
241
+ if (this.#results.length === 0) return;
242
+ this.#selectedIndex = this.#results.length - 1;
243
+ this.#resultsList.setSelectedIndex(this.#selectedIndex);
244
+ return;
245
+ }
246
+
133
247
  if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
134
248
  const selected = this.#results[this.#selectedIndex];
135
249
  if (selected) {
@@ -153,6 +267,6 @@ export class HistorySearchComponent extends Container {
153
267
  ? this.#historyStorage.search(query, this.#resultLimit)
154
268
  : this.#historyStorage.getRecent(this.#resultLimit);
155
269
  this.#selectedIndex = 0;
156
- this.#resultsList.setResults(this.#results, this.#selectedIndex);
270
+ this.#resultsList.setResults(this.#results, this.#selectedIndex, query ? queryTokens(query) : []);
157
271
  }
158
272
  }