fix(coding-agent): restored legacy keyText export
- Added the upstream keyText helper to the legacy package-root shim. - Covered active keybinding formatting and documented the compatibility fix. Fixes #6470
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed legacy Pi extensions failing validation when importing the upstream `keyText` keybinding helper ([#6470](https://github.com/can1357/oh-my-pi/issues/6470)).
|
||||
- Fixed a path traversal vulnerability in blob reference resolution by rejecting non-canonical hashes in `parseBlobRef`.
|
||||
- Fixed multiple edge cases in the secret obfuscation and redaction engine, including handling of context-sensitive regexes, placeholder key requirements in unwritable directories, friendly-name forgery vulnerabilities, and regex match boundaries straddling existing placeholders.
|
||||
- Fixed a first-use race condition in `ArtifactManager` where concurrent callers could allocate duplicate artifact IDs.
|
||||
|
||||
@@ -17,7 +17,7 @@ import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import type { AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
||||
import { type AuthCredential, SqliteAuthCredentialStore, type TSchema } from "@oh-my-pi/pi-ai";
|
||||
import { Text } from "@oh-my-pi/pi-tui";
|
||||
import { getKeybindings, type Keybinding, Text } from "@oh-my-pi/pi-tui";
|
||||
import {
|
||||
getAgentDbPath,
|
||||
getAgentDir,
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
parseFrontmatter as parseOmpFrontmatter,
|
||||
} from "@oh-my-pi/pi-utils";
|
||||
import { getPackageDir as getOmpPackageDir } from "../config";
|
||||
import { formatKeyHints } from "../config/keybindings";
|
||||
import type { PromptTemplate } from "../config/prompt-templates";
|
||||
import { type SettingPath, Settings } from "../config/settings";
|
||||
import { EditTool } from "../edit";
|
||||
@@ -373,6 +374,11 @@ async function executeLegacyBashOperations(
|
||||
}
|
||||
}
|
||||
|
||||
/** Format the active shortcut for legacy extensions that render keybinding hints. */
|
||||
export function keyText(action: Keybinding): string {
|
||||
return formatKeyHints(getKeybindings().getKeys(action));
|
||||
}
|
||||
|
||||
/** Parse frontmatter using the historical Pi package-root helper. */
|
||||
export interface ParsedFrontmatter<T extends Record<string, unknown> = Record<string, unknown>> {
|
||||
frontmatter: T;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
||||
import { getDefaultPasteImageKeys, KeybindingsManager } from "@oh-my-pi/pi-coding-agent/config/keybindings";
|
||||
import { keyText } from "@oh-my-pi/pi-coding-agent/extensibility/legacy-pi-coding-agent-shim";
|
||||
import { getKeybindings, setKeybindings, type KeybindingsManager as TuiKeybindingsManager } from "@oh-my-pi/pi-tui";
|
||||
|
||||
describe("KeybindingsManager.getDisplayString", () => {
|
||||
it("formats a single binding as a human-readable key hint", () => {
|
||||
@@ -33,6 +35,24 @@ describe("KeybindingsManager.getDisplayString", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("legacy keyText", () => {
|
||||
let previous: TuiKeybindingsManager;
|
||||
|
||||
beforeEach(() => {
|
||||
previous = getKeybindings();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
setKeybindings(previous);
|
||||
});
|
||||
|
||||
it("formats the active binding for legacy extensions", () => {
|
||||
setKeybindings(KeybindingsManager.inMemory({ "app.tools.expand": "alt+e" }));
|
||||
|
||||
expect(keyText("app.tools.expand")).toBe("Alt+E");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getDefaultPasteImageKeys", () => {
|
||||
it("keeps Ctrl+V registered for image paste on Windows alongside the terminal-safe fallback", () => {
|
||||
expect(getDefaultPasteImageKeys("win32")).toEqual(["ctrl+v", "alt+v"]);
|
||||
|
||||
Reference in New Issue
Block a user