Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T06:55:46.481Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

keymap.rs

34 lines · 1.1 KB · rust
1use collections::HashMap;
2use std::{ops::Range, sync::LazyLock};
3use tree_sitter::{Query, QueryMatch};
4
5use crate::MigrationPatterns;
6use crate::patterns::KEYMAP_ACTION_STRING_PATTERN;
7
8pub const KEYMAP_PATTERNS: MigrationPatterns =
9    &[(KEYMAP_ACTION_STRING_PATTERN, replace_string_action)];
10
11fn replace_string_action(
12    contents: &str,
13    mat: &QueryMatch,
14    query: &Query,
15) -> Option<(Range<usize>, String)> {
16    let action_name_ix = query.capture_index_for_name("action_name")?;
17    let action_name_node = mat.nodes_for_capture_index(action_name_ix).next()?;
18    let action_name_range = action_name_node.byte_range();
19    let action_name = contents.get(action_name_range.clone())?;
20
21    if let Some(new_action_name) = STRING_REPLACE.get(&action_name) {
22        return Some((action_name_range, new_action_name.to_string()));
23    }
24
25    None
26}
27
28static STRING_REPLACE: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
29    HashMap::from_iter([(
30        "editor::AcceptPartialEditPrediction",
31        "editor::AcceptNextWordEditPrediction",
32    )])
33});
34
Served at tenant.openagents/omega Member data and write actions are omitted.