mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
- Add --models CLI arg accepting comma-separated patterns - Implement smart matching: prefers aliases over dated versions - Add Ctrl+P to cycle through scoped models (or all if no scope) - Show model scope hint at startup - Update help text with examples Co-authored-by: Tino Ehrich <tino.ehrich@hey.com>
42 lines
991 B
TypeScript
42 lines
991 B
TypeScript
import { Editor } from "@mariozechner/pi-tui";
|
|
|
|
/**
|
|
* Custom editor that handles Escape and Ctrl+C keys for coding-agent
|
|
*/
|
|
export class CustomEditor extends Editor {
|
|
public onEscape?: () => void;
|
|
public onCtrlC?: () => void;
|
|
public onShiftTab?: () => void;
|
|
public onCtrlP?: () => void;
|
|
|
|
handleInput(data: string): void {
|
|
// Intercept Ctrl+P for model cycling
|
|
if (data === "\x10" && this.onCtrlP) {
|
|
this.onCtrlP();
|
|
return;
|
|
}
|
|
|
|
// Intercept Shift+Tab for thinking level cycling
|
|
if (data === "\x1b[Z" && this.onShiftTab) {
|
|
this.onShiftTab();
|
|
return;
|
|
}
|
|
|
|
// Intercept Escape key - but only if autocomplete is NOT active
|
|
// (let parent handle escape for autocomplete cancellation)
|
|
if (data === "\x1b" && this.onEscape && !this.isShowingAutocomplete()) {
|
|
this.onEscape();
|
|
return;
|
|
}
|
|
|
|
// Intercept Ctrl+C
|
|
if (data === "\x03" && this.onCtrlC) {
|
|
this.onCtrlC();
|
|
return;
|
|
}
|
|
|
|
// Pass to parent for normal handling
|
|
super.handleInput(data);
|
|
}
|
|
}
|