Skip to content

Commit 927e2ad

Browse files
author
SqlRush
committed
Accept keybinding action aliases
1 parent 62a719e commit 927e2ad

5 files changed

Lines changed: 50 additions & 8 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ M7 补充:keybinding resolver/config 和脚本 named-key 输入已覆盖 `ctrl
130130

131131
M7 补充:keybinding config 的 page navigation key name 现在接受 `pgup`/`pg-up`/`prior``pgdn`/`pg-down`/`next`,覆盖常见终端键名/配置别名。
132132

133+
M7 补充:keybinding action parser 现在接受更多 editor-style action aliases,包括 `cursorLeft`/`cursorRight``lineStart`/`lineEnd``deletePreviousChar`/`deleteNextChar``killLine``acceptSelection``search`
134+
133135
M7 补充:interaction script 的 `message` step 现在接受 chat/transcript 风格的 `type`/`speaker` role 别名和 `content`/`body`/`message` text 别名;`image` step 和 iTerm2 image hint 接受 `fileName`/`file_name`/`name`、`mimeType`/`mime_type`/`contentType`、source path/URL 和 `data`/`base64` 内容别名;permission request step 接受 request/permission/tool-use ID、path、description 和 action 字段别名,并允许 `actions` 使用单字符串;`expectPrompt` 接受 `value`/`input`/`content`/`message`、`expandedText`/`fullText`、`cursorIndex`/`cursorPosition`、`isEmpty`/`blank` 等字段别名,且 `pastedContents` 断言接受 `pastedId`/`pastedContentId`、`kind`/`pastedType`、`value`/`data`/`base64`、`contentType`/`mimeType`、`fileName`/`name` 和 `contains` 等字段别名;`expectVim` 接受 `vimEnabled`/`isEnabled`、`vimMode`/`modeName`/`currentMode`、`vimRegister`/`registerValue`/`yankRegister`、`registerLinewise`/`linewise` 等字段别名;`expectTasks` 接受 `taskCount`/`total`/`size`/`length` 和 `statusCounts`/`countsByState` 等字段别名;`expectScreen`/`expectViewport` 接受 `columns`/`rows`、`screenWidth`/`screenHeight`、`scrollOffset`/`viewportOffset`、`visibleRows`/`lineCount` 等字段别名;`expectReverseSearch` 接受 `isActive`/`visible`/`open`、`search`/`term`/`pattern`、`cursorIndex`、`currentResult`、`matchCount`/`matches`、`noMatches` 等字段别名;`expectDialog` 可断言 body contains/not-contains、actions/action contains/not-contains、action count 和 focused action,runtime-aware scripts 会在步骤间保留 dialog focused action,且接受 `isActive`/`visible`、`dialogId`/`dialogID`、`dialogKind`、`heading`/`header`、`content`/`text`/`message` 等字段别名;`expectEvent`/`expectDialogResult` 接受 `eventType`/`event`/`name`、`payload`/`text`/`message`、`dialogId`/`dialogID`/`dialogKind`、`actionValue`/`resultStatus`/`exists`/`isStale` 等字段别名。
134136

135137
M7 补充:interaction script 现在接受 `messages``append_messages`/`appendMessages``transcript_messages`/`transcriptMessages` 批量消息注入字段,且这些字段既可用单个对象也可用对象数组,消息对象沿用 chat/transcript role/text 别名;message 注入也接受 `pastedContent`/`attachments` 粘贴内容别名、单数 `imagePasteId` 图片引用别名,以及 pasted-content 的 `kind`/`value`/`data` 内容字段别名。

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ test/parity/ # golden tests against TS/official behavior
254254
- 已落地轻量 terminal frame renderer、PromptInput/history、ctrl-p/ctrl-n history navigation、shift-enter 多行输入、多行 prompt 行内 ctrl-a/ctrl-e/ctrl-u/ctrl-k 和 wrap/render/cursor、共享 kill ring、ctrl-b/ctrl-f/ctrl-u/ctrl-k/ctrl-w 行编辑、alt-b/alt-f/alt-d/alt-backspace word 编辑、ctrl-left/ctrl-right/alt-left/alt-right word motion、ctrl-y yank 和 alt-y yank-pop 初版、reverse-search cursor/word 编辑/kill/yank/yank-pop 初版、ctrl-c interrupt/双击退出事件、ctrl-d delete-forward/空输入双击退出事件、ctrl-l 重绘事件、ctrl-o/ctrl-t 全局切换事件、ctrl-g/ctrl-s/ctrl-x chord chat 事件、reverse-search 状态/渲染/脚本断言/空结果/选择回填/cursor 断言、paste/image hint 输入和 OSC ST/base64 filename 兼容、text/image pasted-content 引用/metadata 脚本断言/提交展开/history entry restoration、SGR mouse 解析、alternate terminal navigation key sequences including modified Home/End/Delete/PageUp/PageDown、滚轮滚动、修饰键滚轮/左键、左键拖动选择、viewport 半页/顶部/底部可配置滚动、viewport 点击选择和 dialog action 点击、focus/blur 事件、resize 视口保持、keybinding resolver/config/chord pending/null-unbind/key/action camelCase alias、JSON config loader 和 focus/mouse/paste/image key name 覆盖、vim insert/normal/j/k/word/WORD/ge/gE/line-local ^/$/0/I/A/D/quote/bracket text-object/yank/register/paste/delete/count/replace/undo/find/till/repeat/dot-repeat/G/gg/toggle/join/open-line/indent/substitute 动作、normal-mode arrow/backspace/delete 映射和 operator linewise/字符范围、REPL screen、permission/task dialog builder、dialog kind/id routing/runtime/status line、runtime 到 REPL screen 的 dialog/status 同步、runtime-aware interaction script runner、prompt text/cursor/expanded/vim mode/register/task state/dialog result/runtime mutation/task bulk-cancel/permission cancel/keybinding mutation/status negative/snapshot negative/screen size/event-sequence/event-count/no-event/dialog-result-count/no-dialog-result 脚本断言、viewport 脚本断言、named-key 脚本输入、script JSON/JSONL/wrapper loader、script file runner 和 runtime/task camel field aliases、stale dialog race guard、cancel active、permission id/all cancellation、queued permission promotion、active task dialog refresh、task lifecycle/bulk-cancel 初版、idempotent alternate screen lifecycle/reset/reassert interactive 初版、mouse/focus/bracketed-paste terminal mode lifecycle/reconciliation、ANSI snapshot 基础、snapshot corpus write/compare/script-file compare/missing-baseline/diff/batch/strict unexpected-baseline 状态、scripted interaction runner/assertions/multi-key/text/paste/image/pasted-content metadata 初版、viewport/selection;完整 Ink/layout parity 和官方交互脚本仍缺。
255255
- 本轮补充:keybinding config、keymap 解析和 interaction script named-key 输入接受 `ctrl-h`/`ctrl-i`/`ctrl-j`/`ctrl-m`、`ctrl-[`、`ctrl-?`、对应 `control-*` 以及 compact/camel 形式;terminal parser 支持 CSI-u/kitty keyboard protocol 的 ctrl/alt/shift-enter/shift-tab 序列;image hint parser 支持 OSC ST terminator 和 base64 `name=` filename;keybinding JSON loader 支持 wrapper object-map、`shortcuts`、object action 字段、string-array key sequence/chord 和 `null`/`false` unbind;mouse parser 支持 legacy X10/normal tracking 序列;interaction script 支持结构化 mouse/mouse_event 步骤,button 接受 `buttonMask`/`button_mask`/`btn`/`code`/`mask`,坐标接受 `mouseX`/`mouse_x`/`clientX`/`screenX` 和对应 Y/row/line 别名,release 接受 `mouseUp`/`isRelease`/`mouseRelease`/`releaseEvent` 等字段别名;interaction script 还支持字符串 `keys` 和 `input`/`input_text`/`keys_text`/`raw_key`/`paste_text` 字段别名,并允许 status/snapshot/viewport/pasted-content contains 断言使用单字符串或字符串数组,`keybindings`、`expectEvents`、`expectDialogResults`、`expectPrompt.pastedContents` 和 `expectTasks.contains` 使用单对象或对象数组。
256256
- 本轮补充:keybinding config 的 page navigation key name 现在接受 `pgup`/`pg-up`/`prior``pgdn`/`pg-down`/`next`,覆盖常见终端键名/配置别名。
257+
- 本轮补充:keybinding action parser 接受更多 editor-style action aliases,包括 `cursorLeft`/`cursorRight``lineStart`/`lineEnd``deletePreviousChar`/`deleteNextChar``killLine``acceptSelection``search`
257258
- 本轮补充:terminal CSI-u/kitty keyboard parser 接受 `codepoint:alternate``modifier:event-type` 冒号字段,按主 codepoint/modifier 解析 ctrl/alt/shift/rune 键,覆盖 kitty progressive keyboard protocol 的常见变体。
258259
- 本轮补充:terminal CSI-u/kitty keyboard parser 接受无 modifier 字段或 modifier `1` 的 base key 序列,覆盖 printable rune、Enter、Tab、Esc 和 Backspace,避免 extended-key 模式下普通键序列被解析成 unknown。
259260
- 本轮补充:terminal CSI parser 把 DA/device attributes (`CSI c``CSI >c``CSI =c`) 归入 report action,并在 terminal parser dispatcher 中作为 `TerminalActionReport` 暴露。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ M7 progress now includes:
234234
- `internal/tui`: terminal CSI parser now recognizes DEC left/right margin mode (`?69h/l`) as a structured `leftRightMarginMode` action.
235235
- `internal/tui`: keybinding config, keymap resolution, and interaction script named-key input now accept terminal aliases for `ctrl-h`/`ctrl-i`/`ctrl-j`/`ctrl-m`, `ctrl-[`, and `ctrl-?`, including `control-*` and compact/camel variants.
236236
- `internal/tui`: keybinding config now accepts page navigation aliases such as `pgup`, `pg-up`, `prior`, `pgdn`, `pg-down`, and `next`.
237+
- `internal/tui`: keybinding action parsing now accepts broader editor-style aliases such as `cursorLeft`, `lineStart`, `deletePreviousChar`, `killLine`, `acceptSelection`, and `search`.
237238
- `internal/tui`: terminal key parsing now accepts CSI-u/kitty keyboard protocol sequences for existing ctrl/alt editing keys, shift-enter, shift-tab, and printable shift-only runes.
238239
- `internal/tui`: terminal CSI-u/kitty keyboard parsing now also accepts colon-suffixed alternate codepoint and modifier event-type fields such as `CSI 97:65;5:1u`.
239240
- `internal/tui`: terminal CSI-u/kitty keyboard parsing now also accepts base/unmodified sequences such as `CSI 97u` and `CSI 13;1u`, mapping printable runes plus Enter, Tab, Esc, and Backspace instead of treating ordinary extended-key reports as unknown.

internal/tui/keybinding_config.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,33 @@ func ParseActionName(raw string) (Action, error) {
247247
switch name {
248248
case "", "none", "noop", "no_op", "null", "unbind", "unbound":
249249
return ActionNone, nil
250-
case "submit", "submit_prompt":
250+
case "submit", "submit_prompt", "send", "send_message", "submit_message":
251251
return ActionSubmitPrompt, nil
252-
case "newline", "insert_newline":
252+
case "newline", "new_line", "line_break", "insert_newline":
253253
return ActionInsertNewline, nil
254-
case "delete_word_back", "delete_word_backward":
254+
case "left", "cursor_left", "backward", "move_backward":
255+
return ActionMoveLeft, nil
256+
case "right", "cursor_right", "forward", "move_forward":
257+
return ActionMoveRight, nil
258+
case "word_left", "word_backward", "backward_word", "move_word_backward":
259+
return ActionMoveWordLeft, nil
260+
case "word_right", "word_forward", "forward_word", "move_word_forward":
261+
return ActionMoveWordRight, nil
262+
case "home", "start", "line_start", "beginning", "move_to_start":
263+
return ActionMoveStart, nil
264+
case "end", "line_end", "move_to_end":
265+
return ActionMoveEnd, nil
266+
case "backspace", "delete_back", "delete_backward", "delete_previous", "delete_previous_char":
267+
return ActionDeleteBackward, nil
268+
case "delete", "del", "delete_forward", "delete_next", "delete_next_char":
269+
return ActionDeleteForward, nil
270+
case "delete_start", "delete_line_start", "delete_to_beginning", "delete_to_line_start":
271+
return ActionDeleteToStart, nil
272+
case "kill_line", "delete_line_end", "delete_to_line_end":
273+
return ActionDeleteToEnd, nil
274+
case "delete_word_back", "delete_word_backward", "delete_word_left", "kill_word_backward", "backward_kill_word":
255275
return ActionDeleteWordBack, nil
256-
case "delete_word_fwd", "delete_word_forward":
276+
case "delete_word_fwd", "delete_word_forward", "delete_word_right", "kill_word", "kill_word_forward":
257277
return ActionDeleteWordFwd, nil
258278
case "history_prev", "history_previous", "previous_history":
259279
return ActionHistoryPrevious, nil
@@ -263,13 +283,17 @@ func ParseActionName(raw string) (Action, error) {
263283
return ActionPageUp, nil
264284
case "pagedown", "page_down":
265285
return ActionPageDown, nil
286+
case "half_page_up", "half_up":
287+
return ActionHalfPageUp, nil
288+
case "half_page_down", "half_down":
289+
return ActionHalfPageDown, nil
266290
case "scroll_top", "scroll_to_top", "top":
267291
return ActionScrollToTop, nil
268292
case "scroll_bottom", "scroll_to_bottom", "bottom":
269293
return ActionScrollToBottom, nil
270-
case "confirm", "confirm_selection":
294+
case "confirm", "confirm_selection", "accept", "accept_selection", "select", "select_item":
271295
return ActionConfirmSelection, nil
272-
case "reverse_search", "history_search", "search_history":
296+
case "reverse_search", "history_search", "search_history", "search":
273297
return ActionReverseSearch, nil
274298
}
275299
action := Action(name)

internal/tui/tui_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,12 +1368,26 @@ func TestKeymapFromSpecsOverridesAndRemovesBindings(t *testing.T) {
13681368
{name: "insertNewline", want: ActionInsertNewline},
13691369
{name: "deleteWordBackward", want: ActionDeleteWordBack},
13701370
{name: "deleteWordForward", want: ActionDeleteWordFwd},
1371+
{name: "cursorLeft", want: ActionMoveLeft},
1372+
{name: "cursorRight", want: ActionMoveRight},
1373+
{name: "wordBackward", want: ActionMoveWordLeft},
1374+
{name: "wordForward", want: ActionMoveWordRight},
1375+
{name: "lineStart", want: ActionMoveStart},
1376+
{name: "lineEnd", want: ActionMoveEnd},
1377+
{name: "deletePreviousChar", want: ActionDeleteBackward},
1378+
{name: "deleteNextChar", want: ActionDeleteForward},
1379+
{name: "deleteToBeginning", want: ActionDeleteToStart},
1380+
{name: "killLine", want: ActionDeleteToEnd},
1381+
{name: "backwardKillWord", want: ActionDeleteWordBack},
1382+
{name: "killWord", want: ActionDeleteWordFwd},
13711383
{name: "historyPrevious", want: ActionHistoryPrevious},
13721384
{name: "historyNext", want: ActionHistoryNext},
1385+
{name: "halfUp", want: ActionHalfPageUp},
1386+
{name: "halfDown", want: ActionHalfPageDown},
13731387
{name: "scrollToTop", want: ActionScrollToTop},
13741388
{name: "scrollToBottom", want: ActionScrollToBottom},
1375-
{name: "confirmSelection", want: ActionConfirmSelection},
1376-
{name: "reverseSearch", want: ActionReverseSearch},
1389+
{name: "acceptSelection", want: ActionConfirmSelection},
1390+
{name: "search", want: ActionReverseSearch},
13771391
{name: "unbound", want: ActionNone},
13781392
} {
13791393
action, err := ParseActionName(tc.name)

0 commit comments

Comments
 (0)