diff --git a/Cargo.lock b/Cargo.lock index 8640cd4467..066ddaf9d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,6 +149,7 @@ dependencies = [ "tree-sitter-kotlin-sg", "tree-sitter-lua", "tree-sitter-md", + "tree-sitter-nix", "tree-sitter-objc", "tree-sitter-pascal", "tree-sitter-php", @@ -6271,6 +6272,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-nix" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4952a9733f3a98f6683a0ccd1035d84ab7a52f7e84eeed58548d86765ad92de3" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "tree-sitter-objc" version = "3.0.2" diff --git a/README.md b/README.md index 06c950676d..d4a73e3e1c 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ _Coming soon._ | YAML (incl. Kubernetes) | ✓ | ✓ | | ✓ | | | | JSON | ✓ | ✓ | ✓ | | | | | TOML | ✓ | ✓ | | ✓ | | | +| Nix | ✓ | ✓ | ✓ | ✓ | | | | Solidity | ✓ | ✓ | ✓ | ✓ | ✓ | | | Pascal | ✓ | ✓ | ✓ | ✓ | | | | R | ✓ | ✓ | ✓ | ✓ | | | @@ -187,7 +188,7 @@ Every listed language works with `aft_outline`, `aft_zoom`, and `read`/`edit`/`w Objective-C `.h` headers continue to use the C grammar in v1, so Objective-C interfaces declared only in headers may outline imperfectly compared with `.m`/`.mm` implementation files. -Metal uses the C++ grammar because there is no maintained tree-sitter-metal grammar; covered shader qualifiers still produce ordinary function symbols. CUDA uses the dedicated tree-sitter-cuda grammar so kernel launches remain call expressions, and `__global__` definitions render as `kernel` symbols. TOML is structural for outline, zoom, and semantic chunking, but is intentionally absent from AST pattern tools because its key grammar does not accept ast-grep's identifier metavariable sentinels. +Metal uses the C++ grammar because there is no maintained tree-sitter-metal grammar; covered shader qualifiers still produce ordinary function symbols. CUDA uses the dedicated tree-sitter-cuda grammar so kernel launches remain call expressions, and `__global__` definitions render as `kernel` symbols. TOML is structural for outline, zoom, and semantic chunking, but is intentionally absent from AST pattern tools because its key grammar does not accept ast-grep's identifier metavariable sentinels. Nix supports outline, zoom, AST search/replace, and semantic chunking, but its Imports and Refactor columns are intentionally blank and it contributes no call-graph edges: bindings are not declarations; standalone bindings and `inherit` clauses use contextual patterns, while complete Nix expressions use the normal AST pattern path. `$NAME` metavariables are rewritten to `_NAME`, so an identifier of `_` followed by an all-uppercase name (`_FOO`) is read as a metavariable, while `_module.args`, `_Foo`, and `__functor` stay literal. Indexes honor `.gitignore` and an optional `.aftignore` (same syntax) for paths git can't exclude, such as submodules. Naming a file explicitly in `grep` searches it even when ignored, matching ripgrep. diff --git a/assets/aft.schema.json b/assets/aft.schema.json index a537b29c89..4666daca28 100644 --- a/assets/aft.schema.json +++ b/assets/aft.schema.json @@ -129,6 +129,7 @@ "rustfmt", "goimports", "gofmt", + "nixfmt", "none" ] } @@ -1004,6 +1005,7 @@ "rustfmt", "goimports", "gofmt", + "nixfmt", "none" ] } diff --git a/crates/aft-base/src/config.rs b/crates/aft-base/src/config.rs index 36f19fdab3..1cc571352d 100644 --- a/crates/aft-base/src/config.rs +++ b/crates/aft-base/src/config.rs @@ -992,8 +992,10 @@ pub struct Config { /// Optional automatic validation mode after edits (default: None, disabled). /// When "syntax", only tree-sitter parse check. When "full", runs type checker. pub validate_on_edit: Option, - /// Per-language formatter overrides. Keys: "typescript", "python", "rust", "go". - /// Values: "biome", "oxfmt", "prettier", "deno", "ruff", "black", "rustfmt", "goimports", "gofmt", "none". + /// Per-language formatter overrides. Keys: "typescript", "python", "rust", + /// "go", "nix". Values: "biome", "oxfmt", "prettier", "deno", "ruff", + /// "black", "rustfmt", "goimports", "gofmt", "nixfmt", "none". Nix has no + /// auto-detection and formats only when "nix" is set explicitly. pub formatter: HashMap, /// Per-language type checker overrides. Keys: "typescript", "python", "rust", "go". /// Values: "tsc", "tsgo", "biome", "pyright", "ruff", "cargo", "go", "staticcheck", "none". diff --git a/crates/aft-base/src/config_resolve.rs b/crates/aft-base/src/config_resolve.rs index ac02a9e92c..41a19bd4a0 100644 --- a/crates/aft-base/src/config_resolve.rs +++ b/crates/aft-base/src/config_resolve.rs @@ -320,6 +320,7 @@ pub enum RawFormatter { Rustfmt, Goimports, Gofmt, + Nixfmt, None, } @@ -335,6 +336,7 @@ impl RawFormatter { Self::Rustfmt => "rustfmt", Self::Goimports => "goimports", Self::Gofmt => "gofmt", + Self::Nixfmt => "nixfmt", Self::None => "none", } } @@ -4069,6 +4071,30 @@ where #[cfg(test)] mod tests { + #[test] + fn nixfmt_is_a_recognized_formatter_and_reaches_the_resolved_map() { + let raw = serde_json::from_str::(r#"{"formatter":{"nix":"nixfmt"}}"#); + assert!(raw.is_ok(), "formatter.nix must accept nixfmt: {raw:?}"); + + let result = super::resolve_config_for_harness( + &[tier("user", r#"{"formatter":{"nix":"nixfmt"}}"#)], + Some(&Harness::Opencode), + ); + assert!(result.errors.is_empty(), "{:?}", result.errors); + assert_eq!( + result.config.formatter.get("nix").map(String::as_str), + Some("nixfmt") + ); + assert!( + !result + .dropped + .iter() + .any(|dropped| dropped.key.starts_with("formatter")), + "formatter.nix must not be dropped: {:?}", + result.dropped + ); + } + #[test] fn storage_cache_dir_is_a_recognized_user_setting() { let raw = serde_json::from_str::( diff --git a/crates/aft-base/src/lang_id.rs b/crates/aft-base/src/lang_id.rs index d71e520009..9a141b8d70 100644 --- a/crates/aft-base/src/lang_id.rs +++ b/crates/aft-base/src/lang_id.rs @@ -41,6 +41,7 @@ pub enum LangId { ObjC, Toml, Luau, + Nix, } #[cfg(any(test, feature = "test-support"))] @@ -50,7 +51,7 @@ pub const TEST_EXTENSIONS: &[&str] = &[ "htm", "md", "markdown", "mdx", "qmd", "Qmd", "rmd", "Rmd", "sol", "scss", "vue", "json", "jsonc", "scala", "sc", "java", "rb", "kt", "kts", "swift", "inc", "php", "lua", "pl", "pm", "t", "yaml", "yml", "pas", "pp", "dpr", "dpk", "lpr", "R", "r", "groovy", "gvy", "gy", "gsh", - "gradle", "m", "mm", "toml", "luau", "H", "unknown", "", + "gradle", "m", "mm", "toml", "luau", "nix", "H", "unknown", "", ]; /// Classify by name without reading the file. A `.h` result is provisional C; @@ -98,6 +99,7 @@ pub fn native_language_by_extension(ext: &str) -> Option { "groovy" | "gvy" | "gy" | "gsh" | "gradle" => Some(LangId::Groovy), "m" | "mm" => Some(LangId::ObjC), "toml" => Some(LangId::Toml), + "nix" => Some(LangId::Nix), _ => None, } } diff --git a/crates/aft-parse/Cargo.toml b/crates/aft-parse/Cargo.toml index 98fd24218d..aa7b84b2f1 100644 --- a/crates/aft-parse/Cargo.toml +++ b/crates/aft-parse/Cargo.toml @@ -41,6 +41,7 @@ tree-sitter-solidity = "1.2" tree-sitter-vue = { package = "tree-sitter-vue-next", version = "0.1" } tree-sitter-json = "0.24" tree-sitter-toml = { package = "tree-sitter-toml-ng", version = "0.7.0" } +tree-sitter-nix = "0.3.0" tree-sitter-scala = "0.26" tree-sitter-java = "0.23" tree-sitter-ruby = "0.23" diff --git a/crates/aft-parse/src/ast_grep_hints.rs b/crates/aft-parse/src/ast_grep_hints.rs index 3acfae4e85..ba0c477860 100644 --- a/crates/aft-parse/src/ast_grep_hints.rs +++ b/crates/aft-parse/src/ast_grep_hints.rs @@ -139,6 +139,21 @@ pub fn detect_language_specific_mistake(pattern: &str, lang: &AstGrepLang) -> Op ); } } + AstGrepLang::Nix => { + // An attrset body (`a = 1; b = 2;` / `a = 1; inherit b;`) is several + // sibling expressions with no single AST node to bind, so the + // contextual fallback refuses it. Scope the pattern to one member. + if nix_pattern_has_multiple_bindings(src) { + return Some( + "Hint: A nix pattern must contain one binding or one inherit clause \ + (e.g. \"$NAME = $VALUE;\" or \"inherit $NAME;\"). An attrset body is \ + several expressions with no single AST node to match, so it will not \ + parse — search for one binding at a time, or match the enclosing \ + attrset expression." + .to_string(), + ); + } + } _ => {} } @@ -166,6 +181,101 @@ fn has_regex_escape(src: &str) -> bool { false } +/// A Nix attrset body carries several sibling members (`a = 1; b = 2;` or +/// `a = 1; inherit b;`), so the contextual fallback has no single node to bind +/// and refuses the pattern. The shape reads as a top-level `;` with a further +/// binding-shaped member after it. String contents are skipped so a `;` inside +/// `"x;y"` is not mistaken for a binding terminator. +fn nix_pattern_has_multiple_bindings(src: &str) -> bool { + let bytes = src.as_bytes(); + let mut depth: i32 = 0; + let mut in_string = false; + let mut in_indented_string = false; + let mut escaped = false; + let mut i = 0; + while i < bytes.len() { + let b = bytes[i]; + if in_indented_string { + // `''` closes an indented string only when not immediately + // followed by `'` (the `'''` literal apostrophe) or `$` (the + // `''${` literal interpolation marker; interpolation itself is + // `${`, which never closes). + if b == b'\'' && bytes.get(i + 1) == Some(&b'\'') { + match bytes.get(i + 2) { + Some(&b'\'') | Some(&b'$') => i += 3, + _ => { + in_indented_string = false; + i += 2; + } + } + continue; + } + i += 1; + continue; + } + if in_string { + if escaped { + escaped = false; + } else if b == b'\\' { + escaped = true; + } else if b == b'"' { + in_string = false; + } + i += 1; + continue; + } + match b { + // Consume both opening quotes so escape detection stays anchored + // at delimiter boundaries (`''''` is an empty indented string, + // not an opening followed by an escape). + b'\'' if bytes.get(i + 1) == Some(&b'\'') => { + in_indented_string = true; + i += 2; + continue; + } + b'"' => in_string = true, + b'{' | b'[' | b'(' => depth += 1, + b'}' | b']' | b')' => depth = (depth - 1).max(0), + b';' if depth == 0 => { + // The next member can hide behind whitespace and `#` line + // comments, or open as a quoted attribute name (`"a" = 1;`). + let mut j = i + 1; + while j < bytes.len() { + let c = bytes[j]; + if c.is_ascii_whitespace() { + j += 1; + } else if c == b'#' { + while j < bytes.len() && bytes[j] != b'\n' { + j += 1; + } + } else { + break; + } + } + if let Some(&c) = bytes.get(j) { + // A top-level `let …; in …` expression is one member: the + // `in` that terminates the let is not a sibling binding. + if c == b'i' + && bytes.get(j + 1) == Some(&b'n') + && !matches!(bytes.get(j + 2), + Some(w) if w.is_ascii_alphanumeric() || *w == b'_') + { + i = j + 2; + continue; + } + if c.is_ascii_alphabetic() || c == b'_' || c == b'$' || c == b'"' || c == b'\'' + { + return true; + } + } + } + _ => {} + } + i += 1; + } + false +} + /// Recognize compact regex ranges, not subtraction inside an AST subscript. /// A receiver followed by a terminal index is valid code even when the index /// resembles a range; only unmistakable character-class shapes warrant advice. diff --git a/crates/aft-parse/src/ast_grep_lang.rs b/crates/aft-parse/src/ast_grep_lang.rs index e608833f43..5d267bbf33 100644 --- a/crates/aft-parse/src/ast_grep_lang.rs +++ b/crates/aft-parse/src/ast_grep_lang.rs @@ -43,6 +43,7 @@ pub enum AstGrepLang { R, Groovy, ObjC, + Nix, } #[derive(Clone, Debug)] @@ -125,11 +126,33 @@ impl AstGrepLang { "r" => Some(Self::R), "groovy" => Some(Self::Groovy), "objc" | "objective-c" | "objectivec" | "obj-c" => Some(Self::ObjC), + "nix" => Some(Self::Nix), _ => None, } } pub fn compile_pattern(&self, pattern: &str) -> Result { + if matches!(self, Self::Nix) { + // A bare binding (`$NAME = true;`) or `inherit` clause is not a + // complete Nix expression, so a whole-expression pattern fails to + // parse. Match the member inside an attrset context instead: the + // selector scopes the pattern to that member's own kind, which + // keeps sibling bindings intact on replace. + return Pattern::try_new(pattern, self.clone()).or_else(|_| { + // Comments carry no match semantics; strip them (outside + // string contents) before building the attrset context, so + // `$A = true; # note` matches like `$A = true;`. + let stripped = nix_pattern_without_comments(pattern); + let context = format!("{{ {stripped} }}"); + match nix_wrapper_selector(&context) { + Some(selector) => Pattern::contextual(&context, selector, self.clone()), + // Several members would each match on their own, silently + // widening or narrowing what the user asked for. + None => Err(PatternError::Parse(pattern.to_string())), + } + }); + } + if matches!(self, Self::Pascal) { if pascal_pattern_is_declaration(pattern) { return Pattern::try_new(pattern, self.clone()); @@ -182,6 +205,7 @@ impl AstGrepLang { Self::R => &["R", "r"], Self::Groovy => &["groovy", "gvy", "gy", "gsh", "gradle"], Self::ObjC => &["m", "mm", "h"], + Self::Nix => &["nix"], } } @@ -211,6 +235,154 @@ impl AstGrepLang { } } +/// Replace ast-grep metavariables with an ordinary identifier so the grammar +/// can parse the pattern without its metavariable sentinels. +/// Drop `#` line comments from a Nix pattern outside string contents, so a +/// trailing comment does not change what the pattern matches. The string +/// model matches the hint scanner's: `"` with backslash escapes, `''` +/// indented strings where `'''` and `''$` stay inside the string. +fn nix_pattern_without_comments(pattern: &str) -> String { + let bytes = pattern.as_bytes(); + let mut out = String::with_capacity(pattern.len()); + let mut i = 0; + while i < bytes.len() { + let b = bytes[i]; + if b == b'#' { + while i < bytes.len() && bytes[i] != b'\n' { + i += 1; + } + continue; + } + if b == b'\'' && bytes.get(i + 1) == Some(&b'\'') { + // Copy verbatim until the unescaped closing `''`. + let start = i; + i += 2; + while i < bytes.len() { + if bytes[i] == b'\'' && bytes.get(i + 1) == Some(&b'\'') { + if matches!(bytes.get(i + 2), Some(&b'\'') | Some(&b'$')) { + i += 3; + } else { + break; + } + } else { + i += 1; + } + } + out.push_str(&pattern[start..i]); + if i < bytes.len() { + out.push_str("''"); + i += 2; + } + continue; + } + if b == b'"' { + let start = i; + i += 1; + while i < bytes.len() { + if bytes[i] == b'\\' { + i += 2; + while i < bytes.len() && !pattern.is_char_boundary(i) { + i += 1; + } + } else if bytes[i] == b'"' { + break; + } else { + i += 1; + } + } + out.push_str(&pattern[start..i.min(bytes.len())]); + if i < bytes.len() { + out.push('"'); + i += 1; + } + continue; + } + let start = i; + while i < bytes.len() + && !matches!(bytes[i], b'#' | b'"') + && !(bytes[i] == b'\'' && bytes.get(i + 1) == Some(&b'\'')) + { + i += 1; + } + out.push_str(&pattern[start..i]); + } + out +} +fn nix_pattern_without_meta_variables(pattern: &str) -> String { + let mut plain = String::with_capacity(pattern.len()); + let mut chars = pattern.chars().peekable(); + while let Some(character) = chars.next() { + if character != '$' { + plain.push(character); + continue; + } + let mut signature = String::new(); + while chars.peek() == Some(&'$') { + signature.push(chars.next().expect("peeked")); + } + let mut name = String::new(); + while let Some(next) = chars.peek() { + // `'` is deliberately excluded: it can both continue a Nix + // identifier and close an indented-string delimiter (`''`), and + // greediness here ate the closing delimiter of `''echo $out''`, + // rejecting a valid pattern. Metavariable names never contain + // `'`, so stopping early keeps string bodies intact. + if next.is_alphanumeric() || *next == '_' { + name.push(chars.next().expect("peeked")); + } else { + break; + } + } + if signature.is_empty() && name.is_empty() { + plain.push('$'); + } else { + plain.push_str("_aft_meta"); + } + } + plain +} + +/// The selector a contextual Nix pattern must use: the sole member's own node +/// kind. `inherit`/`inherit_from` clauses are real syntax worth finding, so +/// they are addressable on their own; a wrapper holding any other number of +/// members is rejected because the selector would match one of them and +/// silently narrow or widen the query. +/// Node-kind names here couple to the tree-sitter-nix version, as in the +/// parser.rs Nix block head. +fn nix_wrapper_selector(source: &str) -> Option<&'static str> { + let plain = nix_pattern_without_meta_variables(source); + let mut parser = tree_sitter::Parser::new(); + parser + .set_language(&tree_sitter_nix::LANGUAGE.into()) + .ok()?; + let tree = parser.parse(&plain, None)?; + let root = tree.root_node(); + if root.has_error() { + return None; + } + let expression = root.child_by_field_name("expression")?; + let mut cursor = expression.walk(); + let set = expression + .named_children(&mut cursor) + .find(|child| child.kind() == "binding_set")?; + let mut set_cursor = set.walk(); + // Comments carry no members: `$A = true; # note` is a single-binding + // pattern, exactly as in the language itself. + let members: Vec = set + .named_children(&mut set_cursor) + .filter(|child| child.kind() != "comment") + .collect(); + let [only] = members.as_slice() else { + return None; + }; + match only.kind() { + "binding" => Some("binding"), + "inherit" => Some("inherit"), + "inherit_from" => Some("inherit_from"), + _ => None, + } +} + fn php_snippet_selector(pattern: &str) -> Result { Pattern::try_new(pattern, PhpPatternLang::Snippet)?; let processed = PhpPatternLang::Snippet.pre_process_pattern(pattern); @@ -363,7 +535,7 @@ impl Language for AstGrepLang { | Self::Perl | Self::R | Self::ObjC => '\u{00B5}', // µ - Self::Pascal => '_', + Self::Pascal | Self::Nix => '_', // $ is valid in TS, JS, Go, Solidity, Groovy, and Vue template identifiers. // Groovy also uses $ inside GStrings, so keeping $ avoids rejecting // literal interpolation patterns while still letting $NAME meta-vars bind. @@ -402,6 +574,197 @@ impl LanguageExt for AstGrepLang { Self::R => tree_sitter_r::LANGUAGE.into(), Self::Groovy => dekobon_tree_sitter_groovy::LANGUAGE.into(), Self::ObjC => tree_sitter_objc::LANGUAGE.into(), + Self::Nix => tree_sitter_nix::LANGUAGE.into(), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use ast_grep_core::tree_sitter::LanguageExt; + + #[test] + fn test_nix_contextual_pattern_tolerates_comments_outside_strings() { + use ast_grep_core::tree_sitter::LanguageExt; + let lang = AstGrepLang::Nix; + let pattern = lang + .compile_pattern("$A = true; # note") + .expect("a trailing comment must not defeat the contextual fallback"); + let grep = lang.ast_grep("{ a = true; b = false; }"); + let matched: Vec = grep + .root() + .find_all(&pattern) + .map(|n| n.text().to_string()) + .collect(); + assert_eq!(matched, vec!["a = true;"]); + + // A `#` inside string contents survives stripping: the pattern still + // describes the quoted attribute exactly. + let pattern = lang + .compile_pattern("$A = \"x#y\";") + .expect("a `#` inside a string is pattern content, not a comment"); + let grep = lang.ast_grep("{ a = \"x#y\"; b = 2; }"); + let matched: Vec = grep + .root() + .find_all(&pattern) + .map(|n| n.text().to_string()) + .collect(); + assert_eq!(matched, vec!["a = \"x#y\";"]); + } + + #[test] + fn test_nix_contextual_nested_value_binds_outer_binding() { + use ast_grep_core::tree_sitter::LanguageExt; + let lang = AstGrepLang::Nix; + // The selector gate counts direct members only, so the inner `b = 1` + // is invisible to it; the contextual fallback must still resolve the + // pattern to the OUTER binding, not silently match the nested one. + let source = "{ outer = { b = 1; }; inner = 2; }"; + let pattern = AstGrepLang::Nix + .compile_pattern("$A = { b = 1; };") + .expect("attrset-valued single binding compiles via contextual fallback"); + let grep = lang.ast_grep(source); + let matched: Vec = grep + .root() + .find_all(&pattern) + .map(|node| node.text().to_string()) + .collect(); + assert_eq!( + matched.len(), + 1, + "exactly the outer binding matches: {matched:?}" + ); + assert!( + matched[0].starts_with("outer"), + "the match must be the outer binding, not the nested one: {:?}", + matched[0] + ); + } + + #[test] + fn test_nix_language_and_contextual_binding_patterns() { + let lang = AstGrepLang::Nix; + assert_eq!(AstGrepLang::from_str("nix"), Some(AstGrepLang::Nix)); + assert!(lang.extensions().contains(&"nix")); + + // A bare binding is not a complete Nix expression; the contextual + // fallback must scope the pattern to one binding. + let source = "{ foo = true; bar = false; baz.qux = true; }"; + let pattern = lang + .compile_pattern("$NAME = true;") + .expect("contextual binding pattern compiles"); + let grep = lang.ast_grep(source); + let root = grep.root(); + let matched: Vec = root + .find_all(&pattern) + .map(|node| node.text().to_string()) + .collect(); + assert_eq!(matched, vec!["foo = true;", "baz.qux = true;"]); + + // Replacing must touch only the matched bindings, never siblings. + let mut edits = root.replace_all(&pattern, "$NAME = false;"); + edits.sort_by(|a, b| b.position.cmp(&a.position)); + let mut bytes = source.as_bytes().to_vec(); + for edit in edits { + bytes.splice( + edit.position..edit.position + edit.deleted_length, + edit.inserted_text.iter().copied(), + ); } + assert_eq!( + String::from_utf8(bytes).unwrap(), + "{ foo = false; bar = false; baz.qux = false; }" + ); + + // Several bindings in one pattern must not degrade into per-binding + // matches that silently drop the adjacency the user asked for. + assert!( + lang.compile_pattern("$A = true; $B = false;").is_err(), + "multi-binding patterns are rejected" + ); + assert!( + lang.compile_pattern("$A = true; inherit $B;").is_err(), + "a wrapper with an inherit member is rejected" + ); + + // The `_` sentinel only rewrites `$`-metavariables; a literal identifier + // written with a leading underscore stays literal and matches itself. + let underscore = lang + .compile_pattern("_module.args = $V;") + .expect("underscore pattern compiles"); + let literal = lang + .ast_grep("{ _module.args = 1; other.args = 2; }") + .root() + .find_all(&underscore) + .count(); + assert_eq!(literal, 1, "a literal `_`-prefixed key matches itself only"); + let unrelated = lang + .ast_grep("{ other.args = 1; }") + .root() + .find_all(&underscore) + .count(); + assert_eq!(unrelated, 0, "the literal key does not widen the match"); + // `_` followed by an uppercase letter is still a metavariable. + let upper = lang + .compile_pattern("_FOO = $V;") + .expect("uppercase pattern compiles"); + let upper_matches = lang + .ast_grep("{ _FOO = 1; bar = 2; }") + .root() + .find_all(&upper) + .count(); + assert_eq!(upper_matches, 2, "`_` + uppercase binds as a metavariable"); + } + + #[test] + fn test_nix_contextual_inherit_patterns() { + let lang = AstGrepLang::Nix; + let source = "{ foo = true; inherit bar; inherit (lib) mkIf; }"; + + let plain = lang + .compile_pattern("inherit $NAME;") + .expect("an inherit clause pattern compiles"); + let matched: Vec = lang + .ast_grep(source) + .root() + .find_all(&plain) + .map(|node| node.text().to_string()) + .collect(); + assert_eq!(matched, vec!["inherit bar;"]); + + let from = lang + .compile_pattern("inherit ($SRC) $NAME;") + .expect("an inherit-from pattern compiles"); + let matched: Vec = lang + .ast_grep(source) + .root() + .find_all(&from) + .map(|node| node.text().to_string()) + .collect(); + assert_eq!(matched, vec!["inherit (lib) mkIf;"]); + } + + #[test] + fn test_nix_indented_string_dollar_is_not_a_metavariable_hungry_scan() { + let lang = AstGrepLang::Nix; + // `$out` sits inside an indented string; the metavariable scan must + // stop at the name and leave the closing `''` in place, or the + // wrapper parse sees an unfinished string and the pattern is + // rejected. + lang.compile_pattern("script = ''echo $out'';") + .expect("indented-string interpolation pattern compiles"); + lang.compile_pattern("a = \"$x\";") + .expect("quoted-string metavariable pattern compiles"); + let pattern = lang + .compile_pattern("$NAME = $VAL;") + .expect("generic binding pattern compiles"); + let matched: Vec = lang + .ast_grep("{ script = ''echo $out''; other = 1; }") + .root() + .find_all(&pattern) + .map(|node| node.text().to_string()) + .collect(); + assert_eq!(matched, vec!["script = ''echo $out'';", "other = 1;"]); } } diff --git a/crates/aft-parse/src/callgraph.rs b/crates/aft-parse/src/callgraph.rs index c0d8298085..e07a4280f7 100644 --- a/crates/aft-parse/src/callgraph.rs +++ b/crates/aft-parse/src/callgraph.rs @@ -859,7 +859,8 @@ pub fn is_entry_point(name: &str, kind: &SymbolKind, exported: bool, lang: LangI | LangId::Groovy | LangId::ObjC | LangId::Toml - | LangId::Luau => false, + | LangId::Luau + | LangId::Nix => false, } } diff --git a/crates/aft-parse/src/callgraph_store/join.rs b/crates/aft-parse/src/callgraph_store/join.rs index 9bd742430b..7d824f3424 100644 --- a/crates/aft-parse/src/callgraph_store/join.rs +++ b/crates/aft-parse/src/callgraph_store/join.rs @@ -553,6 +553,7 @@ pub fn language_id(language: &str) -> Option { "groovy" => LangId::Groovy, "objc" => LangId::ObjC, "toml" => LangId::Toml, + "nix" => LangId::Nix, _ => return crate::grammar::extractor_language(language), }) } diff --git a/crates/aft-parse/src/callgraph_store/mod.rs b/crates/aft-parse/src/callgraph_store/mod.rs index 85fca8b42b..0df0564fd6 100644 --- a/crates/aft-parse/src/callgraph_store/mod.rs +++ b/crates/aft-parse/src/callgraph_store/mod.rs @@ -5039,6 +5039,7 @@ pub fn lang_label(lang: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } @@ -5077,6 +5078,7 @@ pub fn lang_from_label(label: &str) -> Option { "groovy" => Some(LangId::Groovy), "objc" => Some(LangId::ObjC), "toml" => Some(LangId::Toml), + "nix" => Some(LangId::Nix), _ => None, } } diff --git a/crates/aft-parse/src/calls.rs b/crates/aft-parse/src/calls.rs index 3efc65c784..f7b2a2ff7b 100644 --- a/crates/aft-parse/src/calls.rs +++ b/crates/aft-parse/src/calls.rs @@ -109,7 +109,8 @@ pub fn call_node_kinds(lang: LangId) -> &'static [&'static str] { | LangId::R | LangId::Groovy | LangId::ObjC - | LangId::Toml => &[], + | LangId::Toml + | LangId::Nix => &[], } } diff --git a/crates/aft-parse/src/imports/mod.rs b/crates/aft-parse/src/imports/mod.rs index 6a1a8a6bac..d60410ad60 100644 --- a/crates/aft-parse/src/imports/mod.rs +++ b/crates/aft-parse/src/imports/mod.rs @@ -641,7 +641,8 @@ pub fn syntax_for(lang: LangId) -> Option<&'static dyn ImportSyntax> { | LangId::Groovy | LangId::ObjC | LangId::Toml - | LangId::Luau => None, + | LangId::Luau + | LangId::Nix => None, } } diff --git a/crates/aft-parse/src/indent.rs b/crates/aft-parse/src/indent.rs index af96d839a9..90caff47ee 100644 --- a/crates/aft-parse/src/indent.rs +++ b/crates/aft-parse/src/indent.rs @@ -41,7 +41,8 @@ impl IndentStyle { | LangId::Lua | LangId::Scss | LangId::Yaml - | LangId::Toml => IndentStyle::Spaces(2), + | LangId::Toml + | LangId::Nix => IndentStyle::Spaces(2), LangId::Rust => IndentStyle::Spaces(4), LangId::Go => IndentStyle::Tabs, LangId::C @@ -183,3 +184,16 @@ pub fn source_line_ending(source: &str) -> &'static str { "\n" } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn nix_defaults_to_two_spaces() { + assert_eq!( + IndentStyle::default_for(LangId::Nix), + IndentStyle::Spaces(2) + ); + } +} diff --git a/crates/aft-parse/src/parser.rs b/crates/aft-parse/src/parser.rs index 7001e17bb7..573f25cc6f 100644 --- a/crates/aft-parse/src/parser.rs +++ b/crates/aft-parse/src/parser.rs @@ -878,6 +878,7 @@ fn query_for(lang: LangId) -> Option<&'static str> { LangId::ObjC => Some(OBJC_QUERY), LangId::Toml => None, LangId::Luau => None, + LangId::Nix => None, } } @@ -977,7 +978,8 @@ fn cached_query_for(lang: LangId) -> Result, AftError> { | LangId::Json | LangId::Yaml | LangId::Toml - | LangId::Luau => None, + | LangId::Luau + | LangId::Nix => None, }; query @@ -2757,6 +2759,9 @@ fn extract_symbols_from_tree_unbounded<'tree>( if lang == LangId::Toml { return extract_toml_symbols(source, &root); } + if lang == LangId::Nix { + return extract_nix_symbols(source, &root); + } if lang == LangId::Luau { return Ok(crate::luau::declarations(source, root) .into_iter() @@ -2803,7 +2808,8 @@ fn extract_symbols_from_tree_unbounded<'tree>( | LangId::Vue | LangId::Json | LangId::Yaml - | LangId::Toml => unreachable!("handled before query lookup"), + | LangId::Toml + | LangId::Nix => unreachable!("handled before query lookup"), } } @@ -2940,7 +2946,8 @@ fn node_range_with_decorators_inner<'tree>( | LangId::Vue | LangId::Json | LangId::Yaml - | LangId::Toml => false, + | LangId::Toml + | LangId::Nix => false, }; if should_include { @@ -6947,6 +6954,318 @@ fn extract_toml_symbols(source: &str, root: &Node) -> Result, AftErr Ok(symbols) } +// Node-kind and field names in this block (`binding_set`, +// `function_expression`, `formal`, `let_attrset_expression`, …) couple to the +// pinned tree-sitter-nix version in Cargo.lock; a grammar bump can reshape +// them, and the `nix_` tests in this module are the pin that catches it. +/// Depth of nested bindings the Nix outline expands beneath their parent. +/// A named constant so widening it later does not touch the rest of the module. +const NIX_OUTLINE_DEPTH: usize = 1; + +/// Read an `attrpath` node as the dotted name written in the source. +fn nix_attrpath_name(source: &str, attrpath: &Node) -> String { + let mut cursor = attrpath.walk(); + let parts: Vec = attrpath + .children_by_field_name("attr", &mut cursor) + .map(|attr| node_text(source, &attr).trim().to_string()) + .filter(|part| !part.is_empty()) + .collect(); + parts.join(".") +} + +/// Unwrap parenthesized expressions until reaching the inner value. +fn nix_unwrap_parentheses(mut node: Node) -> Node { + while node.kind() == "parenthesized_expression" { + match node.child_by_field_name("expression") { + Some(inner) => node = inner, + None => break, + } + } + node +} + +/// The `binding_set` a value produces after unwrapping parentheses, a function +/// body, an application's final argument, or a `let … in` body. `None` when the +/// value is not an attribute set. +fn nix_value_binding_set(node: Node) -> Option { + let mut current = nix_unwrap_parentheses(node); + loop { + match current.kind() { + "function_expression" | "with_expression" | "assert_expression" => { + current = current.child_by_field_name("body")?; + current = nix_unwrap_parentheses(current); + } + "let_expression" => { + current = current.child_by_field_name("body")?; + current = nix_unwrap_parentheses(current); + } + // Module and package values are commonly wrapped in a call + // (`config = lib.mkIf cond { … }`); the final argument is the + // configuration attrset, the same rule the entry walk applies. + "apply_expression" => { + current = current.child_by_field_name("argument")?; + current = nix_unwrap_parentheses(current); + } + "attrset_expression" | "rec_attrset_expression" | "let_attrset_expression" => { + let mut cursor = current.walk(); + return current + .named_children(&mut cursor) + .find(|child| child.kind() == "binding_set"); + } + _ => return None, + } + } +} + +/// Collect byte ranges of comment nodes below `node`, skipping `body_id`. The +/// subtree branches, so the descent uses an explicit worklist rather than +/// recursion: a function whose formal defaults or non-body children nest deeply +/// would otherwise spend a stack frame per level and overflow a scan thread. +fn nix_comment_ranges(node: Node, body_id: Option, ranges: &mut Vec<(usize, usize)>) { + let mut worklist = vec![node]; + while let Some(node) = worklist.pop() { + let mut cursor = node.walk(); + for child in node.named_children(&mut cursor) { + if Some(child.id()) == body_id { + continue; + } + if child.kind() == "comment" { + ranges.push((child.start_byte(), child.end_byte())); + } else { + worklist.push(child); + } + } + } +} + +/// `{ config, ... }:` or `x:` for a function expression, taken from the source +/// between the function's start and the end of its parameters. +fn nix_function_signature(source: &str, node: Node) -> Option { + let function = nix_unwrap_parentheses(node); + if function.kind() != "function_expression" { + return None; + } + // Take the header from the function start to the end of its parameters, so + // a comment between the formals and the body stays out of the signature, + // and splice comments that sit inside the formals out of the header. + let body_id = function.child_by_field_name("body").map(|body| body.id()); + let mut end = function.start_byte(); + let mut cursor = function.walk(); + for child in function.named_children(&mut cursor) { + if Some(child.id()) == body_id || child.kind() == "comment" { + continue; + } + end = end.max(child.end_byte()); + } + if end <= function.start_byte() { + return None; + } + let start = function.start_byte(); + let mut comments = Vec::new(); + nix_comment_ranges(function, body_id, &mut comments); + comments.sort_unstable(); + let mut header = String::new(); + let mut cursor_byte = start; + for (comment_start, comment_end) in comments { + if comment_start < cursor_byte || comment_end > end { + continue; + } + header.push_str(source.get(cursor_byte..comment_start)?); + cursor_byte = comment_end; + } + header.push_str(source.get(cursor_byte..end)?); + // The outline renders a signature instead of the name, as it does for + // `fn foo(…)`, so the header keeps the binding name and stays one line even + // when the formals span several. + let signature = header + .split_whitespace() + .collect::>() + .join(" ") + .replace(" ,", ","); + // Display-only collapse of wrapped-formal commas; it also rewrites a + // literal " ," inside a formal default's string. Cosmetic on a + // display field; quote-aware spans are out of scope here. + Some(format!("{signature}:")) +} + +fn nix_emit_binding( + source: &str, + binding: Node, + scope_chain: &[String], + parent: Option<&str>, + depth: usize, + symbols: &mut Vec, +) { + // Inherit clauses are aliases, not definitions; only `binding` nodes count. + if binding.kind() != "binding" { + return; + } + let Some(attrpath) = binding.child_by_field_name("attrpath") else { + return; + }; + let name = nix_attrpath_name(source, &attrpath); + if name.is_empty() { + return; + } + + let value = binding.child_by_field_name("expression"); + let is_function = value + .map(nix_unwrap_parentheses) + .is_some_and(|node| node.kind() == "function_expression"); + let (kind, signature) = if is_function { + ( + SymbolKind::Function, + value + .and_then(|v| nix_function_signature(source, v)) + .map(|header| format!("{name} = {header}")), + ) + } else { + (SymbolKind::Variable, None) + }; + + symbols.push(Symbol { + name: name.clone(), + kind, + range: node_range(&binding), + signature, + scope_chain: scope_chain.to_vec(), + exported: false, + parent: parent.map(str::to_string), + }); + + if depth >= NIX_OUTLINE_DEPTH { + return; + } + let Some(set) = value.and_then(nix_value_binding_set) else { + return; + }; + let mut child_scope = scope_chain.to_vec(); + child_scope.push(name.clone()); + let mut cursor = set.walk(); + let children: Vec = set.named_children(&mut cursor).collect(); + for child in children { + nix_emit_binding(source, child, &child_scope, Some(&name), depth + 1, symbols); + } +} + +/// Collect entry binding sets, looking through wrappers, plus the bindings of a +/// top-level `let` block, which belong to the file rather than the body. The +/// wrappers form a single chain (one descent per level), so the walk is a loop +/// rather than recursion: a file of nested parens, `let … in`, or applied +/// functions would otherwise spend one stack frame per level and overflow the +/// 2 MiB stack a store-scan thread runs on. +fn nix_collect_entry<'a>(node: Node<'a>, sets: &mut Vec>, loose: &mut Vec>) { + let mut node = node; + loop { + match node.kind() { + "source_code" => { + let Some(expression) = node.child_by_field_name("expression") else { + return; + }; + node = expression; + } + "function_expression" | "with_expression" | "assert_expression" => { + let Some(body) = node.child_by_field_name("body") else { + return; + }; + node = body; + } + "parenthesized_expression" => { + let Some(inner) = node.child_by_field_name("expression") else { + return; + }; + node = inner; + } + "let_expression" => { + let mut cursor = node.walk(); + if let Some(set) = node + .named_children(&mut cursor) + .find(|child| child.kind() == "binding_set") + { + let mut set_cursor = set.walk(); + loose.extend(set.named_children(&mut set_cursor)); + } + let Some(body) = node.child_by_field_name("body") else { + return; + }; + node = body; + } + // Package and module files usually return an applied function whose + // last argument is the attrset that carries the bindings. The argument + // goes through entry discovery itself so a `let … in { … }` argument + // also contributes its own file-level bindings. + "apply_expression" => { + let Some(argument) = node.child_by_field_name("argument") else { + return; + }; + node = argument; + } + "attrset_expression" | "rec_attrset_expression" | "let_attrset_expression" => { + let mut cursor = node.walk(); + let set = node + .named_children(&mut cursor) + .find(|child| child.kind() == "binding_set"); + if let Some(set) = set { + sets.push(set); + } + return; + } + _ => return, + } + } +} + +fn extract_nix_symbols(source: &str, root: &Node) -> Result, AftError> { + let mut symbols = Vec::new(); + let mut sets = Vec::new(); + let mut loose = Vec::new(); + nix_collect_entry(*root, &mut sets, &mut loose); + + let full_name = |binding: Node<'_>| { + binding + .child_by_field_name("attrpath") + .map(|attrpath| nix_attrpath_name(source, &attrpath)) + .filter(|name| !name.is_empty()) + }; + + // Nix attributes and `let` variables are separate namespaces, and two `let` + // bindings can share a name too, so identical names are legal. The outline + // keys nesting by parent name and cannot tell them apart: keep both + // definitions and skip their nested expansion only when the full names are + // identical. + // Entry-set and `let` bindings are one flat file-level list: emit them in + // source order, as every other language's outline does. + let mut top_level: Vec = Vec::new(); + for set in sets { + let mut cursor = set.walk(); + top_level.extend(set.named_children(&mut cursor)); + } + top_level.extend(loose); + top_level.sort_by_key(|binding| binding.start_byte()); + + let mut counts: std::collections::HashMap = std::collections::HashMap::new(); + for binding in &top_level { + if let Some(name) = full_name(*binding) { + *counts.entry(name).or_default() += 1; + } + } + let collided: std::collections::HashSet<&str> = counts + .iter() + .filter(|(_, count)| **count > 1) + .map(|(name, _)| name.as_str()) + .collect(); + + for binding in top_level { + let depth = if full_name(binding).is_some_and(|name| collided.contains(name.as_str())) { + NIX_OUTLINE_DEPTH + } else { + 0 + }; + nix_emit_binding(source, binding, &[], None, depth, &mut symbols); + } + Ok(symbols) +} + /// Return the first non-comment value in a JSON document. /// /// JSONC permits comments before the document value. Tree-sitter exposes those @@ -9903,3 +10222,446 @@ pub mod work_counters { GRAMMAR_LOADS.with(Cell::get) } } + +#[cfg(test)] +mod tests { + use super::*; + + fn nix_symbols(source: &str) -> Vec { + let mut parser = Parser::new(); + parser + .set_language(&grammar_for(LangId::Nix).unwrap()) + .expect("nix grammar loads"); + let tree = parser.parse(source, None).expect("parse nix source"); + assert!( + !tree.root_node().has_error(), + "fixture must parse without errors: {source}" + ); + extract_symbols_from_tree(source, &tree, LangId::Nix).expect("extract nix symbols") + } + + fn nix_names(source: &str) -> Vec { + nix_symbols(source) + .into_iter() + .map(|symbol| symbol.name) + .collect() + } + + #[test] + fn nix_detection_and_clean_parse() { + assert_eq!(detect_language(Path::new("flake.nix")), Some(LangId::Nix)); + let symbols = nix_symbols("{\n description = \"demo\";\n}\n"); + assert_eq!(symbols.len(), 1); + assert_eq!(symbols[0].name, "description"); + } + + #[test] + fn nix_entry_discovery_covers_every_wrapper_and_container() { + let cases: &[(&str, &str)] = &[ + ("function body", "{ lib, ... }: {\n a = 1;\n}\n"), + ("let", "let\n version = \"1\";\nin\n{\n a = 1;\n}\n"), + ("with", "with pkgs;\n{\n a = 1;\n}\n"), + ("assert", "assert true;\n{\n a = 1;\n}\n"), + ("parenthesized", "({\n a = 1;\n})\n"), + ("attrset", "{\n a = 1;\n}\n"), + ("rec attrset", "rec {\n a = 1;\n}\n"), + ("let attrset", "let {\n a = 1;\n}\n"), + ]; + for (label, source) in cases { + assert!( + nix_names(source).contains(&"a".to_string()), + "{label} should outline `a`" + ); + } + + let let_names = nix_names("let\n version = \"1\";\nin\n{\n pname = \"demo\";\n}\n"); + assert!(let_names.contains(&"version".to_string())); + assert!(let_names.contains(&"pname".to_string())); + } + + #[test] + fn nix_module_outline_uses_dotted_attrpaths() { + let source = "{ config, lib, pkgs, ... }:\n{\n options.services.demo.enable = lib.mkEnableOption \"demo\";\n config.services.demo = { enable = true; port = 80; nested = { deep = 1; }; };\n}\n"; + let symbols = nix_symbols(source); + let names: Vec<&str> = symbols.iter().map(|symbol| symbol.name.as_str()).collect(); + assert!(names.contains(&"options.services.demo.enable")); + assert!(names.contains(&"config.services.demo")); + assert!(names.contains(&"enable")); + assert!(names.contains(&"port")); + assert!(!names.contains(&"deep"), "depth stops after one level"); + + let enable = symbols + .iter() + .find(|symbol| symbol.name == "enable") + .unwrap(); + assert_eq!(enable.scope_chain, vec!["config.services.demo"]); + assert_eq!(enable.parent.as_deref(), Some("config.services.demo")); + assert_eq!( + symbol_query_matches(enable, "config.services.demo.enable"), + true + ); + assert_eq!( + symbol_query_matches( + &symbols + .iter() + .find(|symbol| symbol.name == "config.services.demo") + .unwrap() + .clone(), + "config.services.demo" + ), + true + ); + } + + #[test] + fn nix_applied_attrset_arguments_are_outlined() { + let derivation = "{\n lib,\n stdenv,\n}:\nstdenv.mkDerivation {\n pname = \"demo\";\n version = \"1.0\";\n src = ./.;\n}\n"; + let names = nix_names(derivation); + assert!(names.contains(&"pname".to_string()), "{names:?}"); + assert!(names.contains(&"version".to_string()), "{names:?}"); + + assert!( + nix_names("stdenv.mkDerivation (finalAttrs: { pname = \"x\"; })\n") + .contains(&"pname".to_string()) + ); + + let conditional = + nix_names("{ lib, ... }: lib.mkIf true { services.demo.enable = true; }\n"); + assert!( + conditional.contains(&"services.demo.enable".to_string()), + "{conditional:?}" + ); + + let wrapped = nix_names("with pkgs; stdenv.mkDerivation { pname = \"x\"; }\n"); + assert!(wrapped.contains(&"pname".to_string()), "{wrapped:?}"); + + // Deliberate limits: non-attrset shapes and non-final arguments. + for source in [ + "lib.mkMerge [ { a = 1; } { b = 2; } ]\n", + "if true then { a = 1; } else { b = 2; }\n", + "{ a = 1; } // { b = 2; }\n", + "f { config = 1; } other\n", + ] { + assert!( + nix_names(source).is_empty(), + "expected no outline for {source:?}" + ); + } + } + + #[test] + fn nix_nested_application_values_expand_one_level() { + let names = nix_names("{\n config = lib.mkIf true { services.demo.enable = true; };\n}\n"); + assert!( + names.contains(&"services.demo.enable".to_string()), + "an application-wrapped value must nest one level: {names:?}" + ); + + // The depth stop still applies: the nested binding's own child is not + // expanded even though its value is an attrset. + let deep = nix_names("{\n config = f { a = { b = 1; }; };\n}\n"); + assert!(deep.contains(&"a".to_string()), "{deep:?}"); + assert!(!deep.contains(&"b".to_string()), "{deep:?}"); + + // Only an attribute-set argument is followed; lists and `//` splits + // nested in a binding still contribute nothing. + let shapes = nix_names( + "{\n config = lib.mkMerge [ { a = 1; } { b = 2; } ];\n other = { x = 1; } // { y = 2; };\n}\n", + ); + assert_eq!(shapes, vec!["config".to_string(), "other".to_string()]); + } + + #[test] + fn nix_applied_let_argument_keeps_file_level_bindings() { + let names = nix_names("stdenv.mkDerivation (let v = \"1\"; in { version = v; })\n"); + assert!(names.contains(&"v".to_string()), "{names:?}"); + assert!(names.contains(&"version".to_string()), "{names:?}"); + } + + #[test] + fn nix_collisions_use_full_names_across_every_top_level_binding() { + let dotted = nix_symbols("let foo.bar = { x = 1; }; in { foo.baz = { y = 2; }; }\n"); + let names: Vec<&str> = dotted.iter().map(|symbol| symbol.name.as_str()).collect(); + assert!(names.contains(&"x"), "let binding expands: {names:?}"); + assert!(names.contains(&"y"), "entry binding expands: {names:?}"); + + let same_name = nix_symbols("let x = { a = 1; }; in let x = { b = 2; }; in { y = 1; }\n"); + let lines: Vec = same_name + .iter() + .filter(|symbol| symbol.name == "x") + .map(|symbol| symbol.range.start_line) + .collect(); + assert_eq!(lines.len(), 2, "{same_name:?}"); + assert!( + !same_name + .iter() + .any(|symbol| matches!(symbol.name.as_str(), "a" | "b")), + "identical names expand neither: {same_name:?}" + ); + } + + #[test] + fn nix_function_bindings_carry_signatures() { + let source = "{\n config = { lib, pkgs, ... }: { a = 1; };\n split =\n { lib\n , pkgs\n }: { };\n mkDefault = value: { b = value; };\n run = (x: x);\n enable = true;\n}\n"; + let symbols = nix_symbols(source); + let find = |name: &str| symbols.iter().find(|symbol| symbol.name == name).unwrap(); + + assert_eq!(find("config").kind, SymbolKind::Function); + assert_eq!( + find("config").signature.as_deref(), + Some("config = { lib, pkgs, ... }:") + ); + assert_eq!( + find("split").signature.as_deref(), + Some("split = { lib, pkgs }:"), + "multiline formals collapse to one line" + ); + + let commented = nix_symbols("{\n foo = { lib\n # note\n , pkgs }: { a = 1; };\n}\n"); + let foo = commented + .iter() + .find(|symbol| symbol.name == "foo") + .unwrap(); + assert_eq!( + foo.signature.as_deref(), + Some("foo = { lib, pkgs }:"), + "comments inside the formals are stripped" + ); + assert!(!foo.signature.as_deref().unwrap().contains('#')); + assert_eq!(find("mkDefault").kind, SymbolKind::Function); + assert_eq!( + find("mkDefault").signature.as_deref(), + Some("mkDefault = value:") + ); + assert_eq!(find("run").kind, SymbolKind::Function); + assert_eq!(find("run").signature.as_deref(), Some("run = x:")); + assert_eq!(find("enable").kind, SymbolKind::Variable); + assert_eq!(find("enable").signature, None); + } + + #[test] + fn nix_flake_outline_nests_outputs_one_level() { + let source = "{\n outputs = inputs@{ self, nixpkgs }: {\n devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { };\n };\n}\n"; + let symbols = nix_symbols(source); + let outputs = symbols + .iter() + .find(|symbol| symbol.name == "outputs") + .unwrap(); + assert_eq!(outputs.kind, SymbolKind::Function); + assert!( + outputs + .signature + .as_deref() + .unwrap() + .starts_with("outputs = inputs@"), + "{:?}", + outputs.signature + ); + + let dev_shell = symbols + .iter() + .find(|symbol| symbol.name == "devShells.x86_64-linux.default") + .expect("nested flake output"); + assert_eq!(dev_shell.scope_chain, vec!["outputs"]); + assert_eq!(dev_shell.parent.as_deref(), Some("outputs")); + assert!(symbol_query_matches( + dev_shell, + "outputs.devShells.x86_64-linux.default" + )); + } + + #[test] + fn nix_signature_excludes_comments_and_shadowed_names_keep_entry_children() { + let commented = "{\n foo = { lib }: # docs\n { a = 1; };\n}\n"; + let symbols = nix_symbols(commented); + let foo = symbols.iter().find(|symbol| symbol.name == "foo").unwrap(); + assert_eq!(foo.signature.as_deref(), Some("foo = { lib }:")); + + // Attributes and `let` variables are separate namespaces: both rows + // exist, and neither expands nested bindings while the parent name is + // ambiguous. + let shadowed = + nix_symbols("let\n enable = { x = 1; };\nin\n{\n enable = { y = 2; };\n}\n"); + let names: Vec<&str> = shadowed.iter().map(|symbol| symbol.name.as_str()).collect(); + assert_eq!(names, vec!["enable", "enable"]); + let lines: Vec = shadowed + .iter() + .map(|symbol| symbol.range.start_line) + .collect(); + assert_eq!(lines, vec![1, 4], "outline follows source order"); + assert_eq!( + shadowed + .iter() + .filter(|symbol| symbol.parent.is_some()) + .count(), + 0, + "ambiguous parents do not expand" + ); + } + + #[test] + fn nix_inherit_clauses_are_not_outlined() { + let names = nix_names("{\n inherit (lib) mkIf;\n inherit pkgs;\n}\n"); + assert!(!names.contains(&"mkIf".to_string())); + assert!(!names.contains(&"pkgs".to_string())); + assert!(names.is_empty()); + } + + #[test] + fn nix_indented_string_semicolons_neither_trigger_nor_suppress_the_hint() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + // The only top-level `;` shape here sits inside an indented string; + // the scanner must not read it as a second binding. + assert!( + detect_pattern_hint("$A = ''a; b'';", &lang).is_none(), + "a semicolon inside an indented string must not earn the hint" + ); + // Two real bindings still earn it even when each value is an + // indented string. + let hint = detect_pattern_hint("$A = ''x''; $B = ''y'';", &lang) + .expect("two real bindings earn the nix hint"); + assert!( + hint.contains("nix pattern must contain one binding or one inherit clause"), + "hint missing the exact wording: {hint}" + ); + } + + #[test] + fn nix_two_binding_pattern_error_carries_hint() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + let pattern = "$A = true; $B = false;"; + assert!( + lang.compile_pattern(pattern).is_err(), + "an attrset body has no single node to bind" + ); + let hint = detect_pattern_hint(pattern, &lang) + .expect("a multi-binding pattern earns the nix hint"); + assert!( + hint.contains("nix pattern must contain one binding or one inherit clause"), + "hint missing the exact wording: {hint}" + ); + } + + #[test] + fn nix_binding_plus_inherit_pattern_error_carries_hint() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + let pattern = "$A = true; inherit $B;"; + assert!( + lang.compile_pattern(pattern).is_err(), + "a binding plus an inherit clause is two members" + ); + let hint = detect_pattern_hint(pattern, &lang) + .expect("a binding-plus-inherit pattern earns the nix hint"); + assert!( + hint.contains("nix pattern must contain one binding or one inherit clause"), + "hint missing the exact wording: {hint}" + ); + } + + #[test] + fn nix_dynamic_attrpath_names_stay_as_written() { + let syms = nix_symbols("{ \"${x}\" = 1; a.\"${b}\".c = 2; plain = 3; }\n"); + let names: Vec<&str> = syms.iter().map(|s| s.name.as_str()).collect(); + assert_eq!( + names, + vec!["\"${x}\"", "a.\"${b}\".c", "plain"], + "interpolated and dynamic path segments keep the source-written name" + ); + } + + #[test] + fn nix_comment_or_quoted_member_after_semicolon_still_carries_hint() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + for pattern in ["$A = true; # c\n $B = false;", "$A = true; \"quoted\" = 2;"] { + let hint = detect_pattern_hint(pattern, &lang) + .expect("a member hidden by a comment or quote still earns the hint"); + assert!( + hint.contains("nix pattern must contain one binding or one inherit clause"), + "hint missing the exact wording: {hint}" + ); + } + assert!( + detect_pattern_hint("$A = true; # trailing comment only\n", &lang).is_none(), + "a single binding with a trailing comment earns no hint" + ); + assert!( + detect_pattern_hint("$A = { b = 1; }; } ; $B = 2;", &lang).is_some(), + "a stray closer must not mask the second member" + ); + } + + #[test] + fn nix_indented_string_escapes_keep_the_hint_scanner_in_range() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + assert!( + detect_pattern_hint("$A = ''x''${y};'';", &lang).is_none(), + "a `;` inside an indented string (past a double-quote-dollar escape) is not a separator" + ); + assert!( + detect_pattern_hint("$A = ''x'';''; $B = 2;", &lang).is_some(), + "the real separator after the closed indented string still earns the hint" + ); + assert!( + detect_pattern_hint("$A = ''''; $B = 1;", &lang).is_some(), + "'''' is an empty indented string; the ; after it is top level" + ); + } + + #[test] + fn nix_let_in_terminator_after_semicolon_carries_no_hint() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + for pattern in ["let a = 1; in b", "let a = 1; in $B"] { + assert!( + detect_pattern_hint(pattern, &lang).is_none(), + "`{pattern}` is one let-expression member, not two bindings" + ); + } + } + + #[test] + fn nix_single_binding_pattern_compiles_without_hint() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + let pattern = "$NAME = true;"; + assert!( + lang.compile_pattern(pattern).is_ok(), + "a single binding compiles via the contextual fallback" + ); + assert!( + detect_pattern_hint(pattern, &lang).is_none(), + "a valid single binding earns no hint" + ); + } + + #[test] + fn nix_composed_pattern_error_names_nix() { + use crate::ast_grep_hints::detect_pattern_hint; + use crate::ast_grep_lang::AstGrepLang; + let lang = AstGrepLang::Nix; + let pattern = "$A = true; $B = false;"; + let err = lang + .compile_pattern(pattern) + .expect_err("two bindings cannot compile"); + let hint = detect_pattern_hint(pattern, &lang).expect("the hint fires"); + // Mirrors how the ast-search/replace commands compose the user-facing + // message: the generic pattern error plus the hint on a blank line. + let message = format!("invalid AST pattern: {err}\n\n{hint}"); + assert!( + message.to_lowercase().contains("nix"), + "composed error must identify nix: {message}" + ); + } +} diff --git a/crates/aft-parse/src/parser/grammar_selection.rs b/crates/aft-parse/src/parser/grammar_selection.rs index ca513bbb31..f3e1fc5941 100644 --- a/crates/aft-parse/src/parser/grammar_selection.rs +++ b/crates/aft-parse/src/parser/grammar_selection.rs @@ -45,6 +45,7 @@ pub fn grammar_for(lang: LangId) -> Result { LangId::Groovy => dekobon_tree_sitter_groovy::LANGUAGE.into(), LangId::ObjC => tree_sitter_objc::LANGUAGE.into(), LangId::Toml => tree_sitter_toml::LANGUAGE.into(), + LangId::Nix => tree_sitter_nix::LANGUAGE.into(), _ => unreachable!("downloaded languages use the extractor table"), }) } diff --git a/crates/aft/src/commands/ast_replace.rs b/crates/aft/src/commands/ast_replace.rs index 93ff181e9d..a1e8c7a4ea 100644 --- a/crates/aft/src/commands/ast_replace.rs +++ b/crates/aft/src/commands/ast_replace.rs @@ -60,7 +60,7 @@ fn dry_run_diff(original: &str, proposed: &str, path: &Path) -> DryRunResult { /// Params: /// - `pattern` (string, required) — ast-grep pattern, e.g. `console.log($MSG)` /// - `rewrite` (string, required) — replacement template, e.g. `logger.info($MSG)` -/// - `lang` (string, required) — selects the source language that ast-grep should parse; accepted values are typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, vue, pascal, r, groovy, objc +/// - `lang` (string, required) — selects the source language that ast-grep should parse; accepted values are typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, scss, vue, json, java, ruby, kotlin, swift, php, lua, perl, pascal, r, groovy, objc, nix /// - `paths` (array of strings, optional) — restrict to these paths /// - `globs` (array of strings, optional) — include/exclude glob patterns /// - `dry_run` (bool, optional, default true) — preview without writing @@ -170,7 +170,7 @@ pub fn handle_ast_replace(req: &RawRequest, ctx: &AppContext) -> Response { &req.id, "invalid_request", format!( - "ast_replace: unsupported language '{}'. Supported: typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, vue, pascal, r, groovy, objc", + "ast_replace: unsupported language '{}'. Supported: typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, scss, vue, json, java, ruby, kotlin, swift, php, lua, perl, pascal, r, groovy, objc, nix", lang_str ), ); diff --git a/crates/aft/src/commands/ast_search.rs b/crates/aft/src/commands/ast_search.rs index 0e99d35d0b..e93cbef3c5 100644 --- a/crates/aft/src/commands/ast_search.rs +++ b/crates/aft/src/commands/ast_search.rs @@ -15,7 +15,7 @@ use crate::protocol::{RawRequest, Response}; /// /// Params: /// - `pattern` (string, required) — ast-grep pattern (e.g. `console.log($MSG)`) -/// - `lang` (string, required) — selects which language parser ast-grep should use for matching; accepted values are typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, vue, pascal, r, groovy, objc +/// - `lang` (string, required) — selects which language parser ast-grep should use for matching; accepted values are typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, scss, vue, json, java, ruby, kotlin, swift, php, lua, perl, pascal, r, groovy, objc, nix /// - `paths` (string[], optional) — directories/files to search (default: project root) /// - `globs` (string[], optional) — include/exclude glob filters; prefix `!` to exclude /// - `context` (integer, optional) — lines of context around each match (default: 0) @@ -53,7 +53,7 @@ pub fn handle_ast_search(req: &RawRequest, ctx: &AppContext) -> Response { &req.id, "invalid_request", format!( - "ast_search: unsupported language '{lang_str}'. Supported: typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, vue, pascal, r, groovy, objc" + "ast_search: unsupported language '{lang_str}'. Supported: typescript, tsx, javascript, python, rust, go, c, cpp, cuda, metal, zig, csharp, solidity, scss, vue, json, java, ruby, kotlin, swift, php, lua, perl, pascal, r, groovy, objc, nix" ), ); } diff --git a/crates/aft/src/commands/configure.rs b/crates/aft/src/commands/configure.rs index 4d04790e7f..8081957973 100644 --- a/crates/aft/src/commands/configure.rs +++ b/crates/aft/src/commands/configure.rs @@ -952,6 +952,7 @@ fn lang_key(lang: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } @@ -1019,7 +1020,7 @@ fn explicit_formatter_candidate(name: &str) -> Vec { match name { "none" | "off" | "false" => Vec::new(), "biome" | "oxfmt" | "prettier" | "deno" | "ruff" | "black" | "rustfmt" | "goimports" - | "gofmt" => { + | "gofmt" | "nixfmt" => { vec![configure_tool_candidate(name, "formatter config", true)] } _ => Vec::new(), @@ -1146,7 +1147,8 @@ fn formatter_candidates_with_pyproject( | LangId::Groovy | LangId::ObjC | LangId::Toml - | LangId::Luau => Vec::new(), + | LangId::Luau + | LangId::Nix => Vec::new(), LangId::Html | LangId::Markdown | LangId::Yaml => Vec::new(), } } @@ -1225,7 +1227,8 @@ fn checker_candidates( | LangId::Groovy | LangId::ObjC | LangId::Toml - | LangId::Luau => Vec::new(), + | LangId::Luau + | LangId::Nix => Vec::new(), LangId::Html | LangId::Markdown | LangId::Yaml => Vec::new(), } } diff --git a/crates/aft/src/commands/outline.rs b/crates/aft/src/commands/outline.rs index e2cf35a403..89d71fa144 100644 --- a/crates/aft/src/commands/outline.rs +++ b/crates/aft/src/commands/outline.rs @@ -2374,6 +2374,7 @@ fn language_id(lang: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } @@ -4043,6 +4044,41 @@ impl MultiFileTreeWriter { #[cfg(test)] mod tests { + #[test] + fn same_named_siblings_nest_children_under_the_first_indexed_entry() { + let symbol = |name: &str, parent: Option<&str>, scope: &[&str], line: u32| Symbol { + name: name.into(), + kind: SymbolKind::Variable, + range: Range { + start_line: line, + start_col: 0, + end_line: line, + end_col: 3, + }, + signature: None, + scope_chain: scope.iter().map(|part| (*part).to_string()).collect(), + exported: false, + parent: parent.map(str::to_string), + }; + + // Builder semantics, not a Nix-specific flow: the Nix extractor's + // full-dotted-name collision rule never pairs these names as + // parent/child, so this synthetic input pins the shared rule that a + // child attaches to the FIRST-indexed symbol of the parent's name. + let tree = build_outline_tree(&[ + symbol("enable", None, &[], 4), + symbol("y", Some("enable"), &["enable"], 5), + symbol("enable", None, &[], 1), + ]); + + assert_eq!(tree.len(), 2, "{tree:?}"); + assert_eq!(tree[0].name, "enable"); + assert_eq!(tree[0].range.start_line, 4); + assert_eq!(tree[0].members.len(), 1, "{tree:?}"); + assert_eq!(tree[0].members[0].name, "y"); + assert!(tree[1].members.is_empty()); + } + thread_local! { pub(super) static REGION_LOOKUP_CHECKS: std::cell::Cell = const { std::cell::Cell::new(0) }; } diff --git a/crates/aft/src/data_layer/content.rs b/crates/aft/src/data_layer/content.rs index ccd789584d..3ccef32855 100644 --- a/crates/aft/src/data_layer/content.rs +++ b/crates/aft/src/data_layer/content.rs @@ -1449,6 +1449,152 @@ mod tests { .unwrap(); } + /// The same 2 MiB-stack constraint as [`extract_on_a_small_stack`], but + /// returns the outline names so a Nix case can assert the binding nested + /// inside the nest was still found. A walk that abandoned descent under + /// stack pressure would return `Ok` with a truncated outline; asserting + /// the name catches that where `is_ok` alone would pass. + fn extract_names_on_a_small_stack(path: &'static str, source: String) -> Vec { + let language = + language_for(path, source.as_bytes()).unwrap_or_else(|| panic!("{path}: no language")); + std::thread::Builder::new() + .name(format!("deep-names-{path}")) + .stack_size(2 << 20) + .spawn(move || { + let record = extract(source.as_bytes(), &language) + .unwrap_or_else(|error| panic!("{path}: {error}")); + let RecordBody::Parsed { body, .. } = record.data else { + panic!("{path}: a parsed language gives a parsed record"); + }; + body.outline + .unwrap_or_else(|| panic!("{path}: no outline")) + .into_iter() + .map(|symbol| symbol.name) + .collect() + }) + .unwrap() + .join() + .unwrap() + } + + #[test] + fn nix_deeply_nested_parens_extracts_binding_on_a_small_stack() { + // nix_collect_entry descends the paren/let/apply wrapper chain once + // per level; a nest this deep had to be carried on the heap, and the + // binding wrapped inside it still has to be reported. + // Alternate the wrappers exactly as the wrappers come: parentheses + // and `let … in` layers interleaved, one binding wrapped inside. + let mut source = "{ deep = 1; }".to_string(); + for level in 0..NESTING { + source = if level % 2 == 0 { + format!("({source})") + } else { + // The `let` layers bind a sibling flag and leave the wrapped + // expression as the body: entry discovery descends bodies + // syntactically and never resolves variable references (no + // evaluation), so the entry must stay an expression. + format!("let flag_{level} = true; in {source}") + }; + } + let names = extract_names_on_a_small_stack("deep.nix", format!("{source}\n")); + assert!(names.iter().any(|name| name == "deep"), "{names:?}"); + } + + #[test] + fn nix_deeply_nested_formal_default_extracts_binding_on_a_small_stack() { + // nix_comment_ranges branches over every non-body child of a function + // header, including a formal's default value; a default nested this + // deep had to be carried on the heap, and the function binding inside + // it still has to be reported. + let names = extract_names_on_a_small_stack( + "deep_formal.nix", + // A comment sits inside the innermost wrapper so the doc-comment + // walk traverses the full depth with real comments in range. + format!("{{ f = {{ x ? {} }}: x; }}\n", nested("(", "# c\n1", ")")), + ); + assert!(names.iter().any(|name| name == "f"), "{names:?}"); + } + + #[test] + fn nix_deeply_nested_attrset_and_list_values_complete_comments_on_a_small_stack() { + // The spec's literal shape: attrset and list values alternating ten + // thousand deep with comments inside. The nest hangs off a formal + // default so `nix_comment_ranges` — the walker hardened for exactly + // this traversal — carries it on the heap worklist, and the function + // binding's signature and doc-comment attachment still have to + // complete on the 2 MiB stack. Three oracles, each able to fail: + // the name proves entry descent completed (with the RED-transplant + // evidence pinning the overflow this fixture used to cause); the + // `# early` comment sits inside the header window that survives + // signature truncation, so a comment-free root signature fails if + // the splice walk skips header comments; the `# TODO deep` marker + // harvested from the core proves the marker walk reached the + // ten-thousand-deep level. + let mut nest = String::new(); + let mut closes: Vec<&str> = Vec::with_capacity(NESTING); + for layer in 0..NESTING { + if layer % 2 == 0 { + // The outermost attrset carries `# early` inside the header + // byte range: retained by signature truncation, so a splice + // regression leaves `#` in the stored signature. + if layer == 0 { + nest.push_str("{ # early\n wrap = "); + } else { + nest.push_str("{ wrap = "); + } + closes.push("; }"); + } else { + nest.push_str("[ "); + closes.push(" ]"); + } + } + nest.push_str("{ # TODO deep\ndeep = 1; }"); + for close in closes.iter().rev() { + nest.push_str(close); + } + // Formal default position: a non-body child of the function header, + // which the signature walk traverses for comment splicing. + let src = format!("{{ root = {{ x ? {nest} }}: x; }}\n"); + let (names, todo_at_core, root_signature) = std::thread::Builder::new() + .name("deep-comments-deep_values.nix".to_string()) + .stack_size(2 << 20) + .spawn(move || { + let record = extract(src.as_bytes(), "nix") + .unwrap_or_else(|error| panic!("deep_values.nix: {error}")); + let RecordBody::Parsed { body, .. } = record.data else { + panic!("deep_values.nix: a parsed language gives a parsed record"); + }; + let outline = body.outline.unwrap_or_default(); + let names: Vec = outline.iter().map(|symbol| symbol.name.clone()).collect(); + let root_signature = outline + .iter() + .find(|symbol| symbol.name == "root") + .and_then(|symbol| symbol.signature.clone()); + let todo = record + .todos + .as_ref() + .and_then(|todos| todos.items.as_ref()) + .is_some_and(|items| items.iter().any(|marker| marker.marker == "TODO")); + (names, todo, root_signature) + }) + .unwrap() + .join() + .unwrap(); + assert!( + names.iter().any(|name| name == "root"), + "entry binding must survive the value nest: {names:?}" + ); + assert!( + todo_at_core, + "the TODO comment at the ten-thousand-deep core must be harvested" + ); + let root_signature = root_signature.expect("the formal-default header is the signature"); + assert!( + !root_signature.contains('#'), + "header comments must be spliced out at depth: {root_signature}" + ); + } + /// One test per language, so a stack overflow names the language that /// caused it. macro_rules! deep_nesting_tests { diff --git a/crates/aft/src/data_layer/grammar_tests.rs b/crates/aft/src/data_layer/grammar_tests.rs index 5857ad60bb..8a6ec3fa0c 100644 --- a/crates/aft/src/data_layer/grammar_tests.rs +++ b/crates/aft/src/data_layer/grammar_tests.rs @@ -217,6 +217,7 @@ fn luau_s4_keyed_language_preserves_every_builtin_key() { "groovy", "objc", "toml", + "nix", "markers-lexical", "markers-markdown", "config", diff --git a/crates/aft/src/format.rs b/crates/aft/src/format.rs index c7ea3e27a0..5f24665119 100644 --- a/crates/aft/src/format.rs +++ b/crates/aft/src/format.rs @@ -772,6 +772,7 @@ fn lang_key(lang: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } @@ -784,6 +785,7 @@ fn has_formatter_support(lang: LangId) -> bool { | LangId::Python | LangId::Rust | LangId::Go + | LangId::Nix ) } @@ -1011,7 +1013,8 @@ fn formatter_candidates(lang: LangId, config: &Config, path: &Path) -> Vec Vec::new(), + | LangId::Luau + | LangId::Nix => Vec::new(), LangId::Html => Vec::new(), LangId::Markdown => Vec::new(), LangId::Yaml => Vec::new(), @@ -1135,7 +1138,8 @@ fn checker_candidates(lang: LangId, config: &Config, file_str: &str) -> Vec Vec::new(), + | LangId::Luau + | LangId::Nix => Vec::new(), LangId::Html => Vec::new(), LangId::Markdown => Vec::new(), LangId::Yaml => Vec::new(), @@ -1191,6 +1195,12 @@ fn explicit_formatter_candidate(name: &str, file_str: &str) -> Vec vec![ToolCandidate { + tool: name.to_string(), + source: "formatter config".to_string(), + args: vec![file_str.to_string()], + required: true, + }], _ => Vec::new(), } } @@ -1386,6 +1396,7 @@ fn placeholder_file_for_language(project_root: &Path, lang: LangId) -> PathBuf { LangId::Groovy => "aft-tool-detection.groovy", LangId::ObjC => "aft-tool-detection.m", LangId::Toml => "aft-tool-detection.toml", + LangId::Nix => "aft-tool-detection.nix", }; project_root.join(filename) } @@ -2809,6 +2820,32 @@ pub fn validate_full( #[cfg(test)] mod tests { + #[test] + fn nixfmt_is_a_configured_formatter_candidate() { + assert!(super::has_formatter_support(crate::parser::LangId::Nix)); + assert!(!super::has_checker_support(crate::parser::LangId::Nix)); + + let path = std::path::Path::new("flake.nix"); + assert!( + super::formatter_candidates( + crate::parser::LangId::Nix, + &crate::config::Config::default(), + path + ) + .is_empty(), + "Nix has no auto-detected formatter" + ); + + let mut config = crate::config::Config::default(); + config + .formatter + .insert("nix".to_string(), "nixfmt".to_string()); + let candidates = super::formatter_candidates(crate::parser::LangId::Nix, &config, path); + assert_eq!(candidates.len(), 1, "{candidates:?}"); + assert_eq!(candidates[0].tool, "nixfmt"); + assert_eq!(candidates[0].args, vec!["flake.nix".to_string()]); + } + #[cfg(unix)] #[test] fn cached_ruff_version_still_checks_policy_without_running() { diff --git a/crates/aft/src/grammar/tests.rs b/crates/aft/src/grammar/tests.rs index 03fccfcf3e..9d752e81d9 100644 --- a/crates/aft/src/grammar/tests.rs +++ b/crates/aft/src/grammar/tests.rs @@ -290,6 +290,7 @@ fn grammar_detection_golden_builtins_and_opt_in() { ("groovy gvy gy gsh gradle", Groovy), ("m mm", ObjC), ("toml", Toml), + ("nix", Nix), ]; for (extensions, language) in mappings { for extension in extensions.split_whitespace() { diff --git a/crates/aft/src/inspect/job.rs b/crates/aft/src/inspect/job.rs index 2b5841e636..06a1ee05c5 100644 --- a/crates/aft/src/inspect/job.rs +++ b/crates/aft/src/inspect/job.rs @@ -349,6 +349,7 @@ pub(crate) fn language_name(language: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } diff --git a/crates/aft/src/inspect/manager.rs b/crates/aft/src/inspect/manager.rs index 2197f6500c..ffd57e967c 100644 --- a/crates/aft/src/inspect/manager.rs +++ b/crates/aft/src/inspect/manager.rs @@ -5478,6 +5478,7 @@ fn duplicates_supports_language(language: crate::parser::LangId) -> bool { | crate::parser::LangId::Groovy | crate::parser::LangId::ObjC | crate::parser::LangId::Toml + | crate::parser::LangId::Nix ) } @@ -5526,6 +5527,7 @@ fn language_name(language: crate::parser::LangId) -> &'static str { crate::parser::LangId::Groovy => "groovy", crate::parser::LangId::ObjC => "objc", crate::parser::LangId::Toml => "toml", + crate::parser::LangId::Nix => "nix", } } diff --git a/crates/aft/src/inspect/scanners/complexity.rs b/crates/aft/src/inspect/scanners/complexity.rs index ea83c875b5..9fd2c3aae1 100644 --- a/crates/aft/src/inspect/scanners/complexity.rs +++ b/crates/aft/src/inspect/scanners/complexity.rs @@ -341,7 +341,8 @@ fn language_spec(language: LangId) -> Option { | LangId::Json | LangId::Yaml | LangId::Toml - | LangId::Pascal => return None, + | LangId::Pascal + | LangId::Nix => return None, }; Some(spec) } @@ -794,6 +795,18 @@ fn push_children_with_state<'tree, T: Copy>( #[cfg(test)] mod tests { + #[test] + fn nix_is_skipped_by_complexity() { + let scan = fixture_scan( + "module.nix", + "{ lib, ... }: { services.demo.enable = true; f = x: if x then 1 else 0; }\n", + ); + assert!(scan.functions.is_empty(), "{scan:?}"); + assert!(scan.parse_error.is_none(), "{scan:?}"); + assert_eq!(scan.language, None, "{scan:?}"); + assert_eq!(scan.language_skipped.as_deref(), Some("nix"), "{scan:?}"); + } + #[test] fn h_header_complexity_uses_cpp_snapshot() { let root = tempfile::tempdir().unwrap(); diff --git a/crates/aft/src/inspect/scanners/cycles.rs b/crates/aft/src/inspect/scanners/cycles.rs index 0bf87e9322..37c361cfc0 100644 --- a/crates/aft/src/inspect/scanners/cycles.rs +++ b/crates/aft/src/inspect/scanners/cycles.rs @@ -838,6 +838,7 @@ fn language_name(language: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } diff --git a/crates/aft/src/inspect/scanners/duplicates.rs b/crates/aft/src/inspect/scanners/duplicates.rs index 036c051624..f395fc071a 100644 --- a/crates/aft/src/inspect/scanners/duplicates.rs +++ b/crates/aft/src/inspect/scanners/duplicates.rs @@ -1284,6 +1284,7 @@ fn is_supported_language(lang: LangId) -> bool { | LangId::R | LangId::Groovy | LangId::ObjC + | LangId::Nix ) } fn language_name(lang: LangId) -> &'static str { @@ -1322,11 +1323,17 @@ fn language_name(lang: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } #[cfg(test)] mod tests { + #[test] + fn nix_is_excluded_from_duplicate_scanning() { + assert!(!super::is_supported_language(crate::parser::LangId::Nix)); + } + use super::*; use crate::cache_freshness::FileFreshness; use serde_json::json; diff --git a/crates/aft/src/inspect/scanners/metrics.rs b/crates/aft/src/inspect/scanners/metrics.rs index 6308b7094e..ea0b055c16 100644 --- a/crates/aft/src/inspect/scanners/metrics.rs +++ b/crates/aft/src/inspect/scanners/metrics.rs @@ -284,6 +284,7 @@ fn language_key(path: &Path) -> &'static str { Some(LangId::Groovy) => "groovy", Some(LangId::ObjC) => "objc", Some(LangId::Toml) => "toml", + Some(LangId::Nix) => "nix", None => "unknown", } } diff --git a/crates/aft/src/inspect/scanners/unused_exports.rs b/crates/aft/src/inspect/scanners/unused_exports.rs index b78e79a94b..8546e53309 100644 --- a/crates/aft/src/inspect/scanners/unused_exports.rs +++ b/crates/aft/src/inspect/scanners/unused_exports.rs @@ -1685,6 +1685,7 @@ fn language_name(lang: LangId) -> &'static str { LangId::Groovy => "groovy", LangId::ObjC => "objc", LangId::Toml => "toml", + LangId::Nix => "nix", } } diff --git a/crates/aft/src/semantic_index.rs b/crates/aft/src/semantic_index.rs index 4bb46cbcfa..9dfa477e88 100644 --- a/crates/aft/src/semantic_index.rs +++ b/crates/aft/src/semantic_index.rs @@ -10088,7 +10088,8 @@ pub fn is_semantic_indexed_extension(path: &Path) -> bool { | "gradle" | "m" | "mm" - | "toml", + | "toml" + | "nix", ) ) } @@ -13637,6 +13638,23 @@ Connection: close assert_eq!((dependency.start_line, dependency.end_line), (4, 5)); } + #[test] + fn nix_semantic_chunk_indexes_fixture() { + let project_root = Path::new("/project"); + let file = project_root.join("flake.nix"); + let source = "{\n outputs = inputs: {\n devShells.default = inputs.nixpkgs.mkShell { };\n };\n}\n"; + let chunks = collect_file_chunks_from_source( + project_root, + &file, + crate::parser::LangId::Nix, + source, + ) + .expect("collect Nix chunks"); + + assert!(chunks.iter().any(|chunk| chunk.name == "outputs")); + assert!(chunks.iter().any(|chunk| chunk.name == "devShells.default")); + } + #[test] fn optimized_file_chunk_collection_matches_file_parser_path() { let project_root = PathBuf::from(crate::test_support::manifest_dir()); diff --git a/crates/aft/src/subc_tool_schemas.json b/crates/aft/src/subc_tool_schemas.json index a0662b585d..8778eca3f3 100644 --- a/crates/aft/src/subc_tool_schemas.json +++ b/crates/aft/src/subc_tool_schemas.json @@ -602,7 +602,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -630,7 +631,7 @@ "pattern", "lang" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'" + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'" }, "ast_replace": { "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -658,7 +659,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { diff --git a/crates/aft/tests/fixtures/flake.nix b/crates/aft/tests/fixtures/flake.nix new file mode 100644 index 0000000000..7a491e42d1 --- /dev/null +++ b/crates/aft/tests/fixtures/flake.nix @@ -0,0 +1,9 @@ +{ + description = "demo flake"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + + outputs = inputs@{ self, nixpkgs }: { + devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { }; + }; +} diff --git a/crates/aft/tests/fixtures/nix_module.nix b/crates/aft/tests/fixtures/nix_module.nix new file mode 100644 index 0000000000..a83544322d --- /dev/null +++ b/crates/aft/tests/fixtures/nix_module.nix @@ -0,0 +1,9 @@ +{ config, lib, pkgs, ... }: +{ + options.services.demo.enable = lib.mkEnableOption "demo"; + + config.services.demo = { + enable = true; + port = 80; + }; +} diff --git a/crates/aft/tests/fixtures/tool_provider_catalog.json b/crates/aft/tests/fixtures/tool_provider_catalog.json index e72f51dec1..539ad0cd47 100644 --- a/crates/aft/tests/fixtures/tool_provider_catalog.json +++ b/crates/aft/tests/fixtures/tool_provider_catalog.json @@ -16,8 +16,8 @@ "version": "0.58.1" }, "reply": { - "generation": "96a393419ebcda02c65397f94255155cb3554388917bdb67211cf76450d5671f", - "catalog_digest": "96a393419ebcda02c65397f94255155cb3554388917bdb67211cf76450d5671f", + "generation": "b4a1a4a4416baa04fb766079b0570555415ec14bd09010cf59ec3daa27bf00e0", + "catalog_digest": "b4a1a4a4416baa04fb766079b0570555415ec14bd09010cf59ec3daa27bf00e0", "tools": [ { "name": "status", @@ -713,7 +713,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -723,7 +723,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -746,7 +746,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -778,7 +779,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -815,7 +816,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -1239,8 +1241,8 @@ "version": "0.58.1" }, "reply": { - "generation": "4e4e86736f44efc37283149fc9d819706ee4d302d61a6af54c0d2c65cf329a21", - "catalog_digest": "4e4e86736f44efc37283149fc9d819706ee4d302d61a6af54c0d2c65cf329a21", + "generation": "7ef6779bc1dbdafdd4d02c3f38969cd7e51400d336c6482e39782e064f3c95f3", + "catalog_digest": "7ef6779bc1dbdafdd4d02c3f38969cd7e51400d336c6482e39782e064f3c95f3", "tools": [ { "name": "status", @@ -1936,7 +1938,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -1946,7 +1948,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -1969,7 +1971,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -2001,7 +2004,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -2038,7 +2041,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -2464,8 +2468,8 @@ "version": "0.58.1" }, "reply": { - "generation": "06ec2fc15c4b4c17290c89080e4f0d414828a7521a444a94ccced4b2a86c27e1", - "catalog_digest": "06ec2fc15c4b4c17290c89080e4f0d414828a7521a444a94ccced4b2a86c27e1", + "generation": "752c3b78abffa4be05740d6b7ab4c55b2e96d52d358817b490b7dabe0cfb9280", + "catalog_digest": "752c3b78abffa4be05740d6b7ab4c55b2e96d52d358817b490b7dabe0cfb9280", "tools": [ { "name": "status", @@ -3079,7 +3083,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -3089,7 +3093,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -3112,7 +3116,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -3144,7 +3149,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -3181,7 +3186,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -3606,8 +3612,8 @@ "version": "0.58.1" }, "reply": { - "generation": "b1e619f2309c2d698706dd28794828edfdfe957c20bf646d0e5f1eae3579c657", - "catalog_digest": "b1e619f2309c2d698706dd28794828edfdfe957c20bf646d0e5f1eae3579c657", + "generation": "e4e69edf7e8563792ff3d03e3fb2d9af36d7636852339a66d3e4ad77648a0a29", + "catalog_digest": "e4e69edf7e8563792ff3d03e3fb2d9af36d7636852339a66d3e4ad77648a0a29", "tools": [ { "name": "status", @@ -4256,7 +4262,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -4266,7 +4272,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -4289,7 +4295,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -4321,7 +4328,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -4358,7 +4365,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -4783,8 +4791,8 @@ "version": "0.58.1" }, "reply": { - "generation": "c31dea461d49a67d8ea36f960c289d364b37d92fa0a0c2cb12c49f312530114e", - "catalog_digest": "c31dea461d49a67d8ea36f960c289d364b37d92fa0a0c2cb12c49f312530114e", + "generation": "34fb1baaa196c45c35e0a8f81c78a9cb218d386587c6fc3e259477dfa212f453", + "catalog_digest": "34fb1baaa196c45c35e0a8f81c78a9cb218d386587c6fc3e259477dfa212f453", "tools": [ { "name": "status", @@ -5430,7 +5438,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -5440,7 +5448,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -5463,7 +5471,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -5495,7 +5504,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -5532,7 +5541,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -5958,8 +5968,8 @@ "version": "0.58.1" }, "reply": { - "generation": "9178063f357e7bdb3ebffaee6f9e4b54df3b12a48a253dad0414afc57406cf75", - "catalog_digest": "9178063f357e7bdb3ebffaee6f9e4b54df3b12a48a253dad0414afc57406cf75", + "generation": "b26d854306a5fc65c0acc2a96fff65e3bc37261ef794b35ca57879fa87072763", + "catalog_digest": "b26d854306a5fc65c0acc2a96fff65e3bc37261ef794b35ca57879fa87072763", "tools": [ { "name": "status", @@ -6548,7 +6558,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -6558,7 +6568,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -6581,7 +6591,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -6613,7 +6624,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -6650,7 +6661,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -7075,8 +7087,8 @@ "version": "0.58.1" }, "reply": { - "generation": "fa070032cb0b0a833d701b55db72b25b1eed634956982bcc753109f396b88c57", - "catalog_digest": "fa070032cb0b0a833d701b55db72b25b1eed634956982bcc753109f396b88c57", + "generation": "66cfb4b32ffb12ce13c3a295a70ade84d0bbdd29329ba97bf1574b954f1f08bd", + "catalog_digest": "66cfb4b32ffb12ce13c3a295a70ade84d0bbdd29329ba97bf1574b954f1f08bd", "tools": [ { "name": "status", @@ -7662,7 +7674,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -7672,7 +7684,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -7695,7 +7707,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -7727,7 +7740,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -7764,7 +7777,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -8189,8 +8203,8 @@ "version": "0.58.1" }, "reply": { - "generation": "c93df283d8b960290472345f343c3514778c8edce0dc50b01d4bf33e19be2448", - "catalog_digest": "c93df283d8b960290472345f343c3514778c8edce0dc50b01d4bf33e19be2448", + "generation": "e6380d26d5cf2dc0636faace7fbfab8d426ad1f9284461f4e0e9920fc111aff4", + "catalog_digest": "e6380d26d5cf2dc0636faace7fbfab8d426ad1f9284461f4e0e9920fc111aff4", "tools": [ { "name": "status", @@ -8772,7 +8786,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -8782,7 +8796,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -8805,7 +8819,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -8837,7 +8852,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -8874,7 +8889,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -9299,8 +9315,8 @@ "version": "0.58.1" }, "reply": { - "generation": "afbaeb38450cc0ff82cb4f4433e6dea1f1d0cf0da751b216861bbefcfed082d8", - "catalog_digest": "afbaeb38450cc0ff82cb4f4433e6dea1f1d0cf0da751b216861bbefcfed082d8", + "generation": "354941f63af327985549648ae5791c730cd258ef33975fa298da0393b580b729", + "catalog_digest": "354941f63af327985549648ae5791c730cd258ef33975fa298da0393b580b729", "tools": [ { "name": "status", @@ -9879,7 +9895,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -9889,7 +9905,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -9912,7 +9928,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -9944,7 +9961,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -9981,7 +9998,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -10403,8 +10421,8 @@ "version": "0.58.1" }, "reply": { - "generation": "1b1c2a26886a9d27df0c357e3c0a22ce6029159ca5b956b49672f9ea291290c9", - "catalog_digest": "1b1c2a26886a9d27df0c357e3c0a22ce6029159ca5b956b49672f9ea291290c9", + "generation": "cce59cef22ca1d806c94d6c2a9e7e69cb519bb6e3bcb7cf1ede6a9c8861a7070", + "catalog_digest": "cce59cef22ca1d806c94d6c2a9e7e69cb519bb6e3bcb7cf1ede6a9c8861a7070", "tools": [ { "name": "status", @@ -11174,7 +11192,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -11184,7 +11202,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -11207,7 +11225,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -11239,7 +11258,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -11276,7 +11295,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -11701,8 +11721,8 @@ "version": "0.58.1" }, "reply": { - "generation": "75f9e421a5a7f7c4532b698e45a66ca93ca81f7fa8e93de57de8f556f3316493", - "catalog_digest": "75f9e421a5a7f7c4532b698e45a66ca93ca81f7fa8e93de57de8f556f3316493", + "generation": "eed1eb9440ef235a9ccaf814fdd97a330c8e7f38b47d70ac44b78c28226bca1e", + "catalog_digest": "eed1eb9440ef235a9ccaf814fdd97a330c8e7f38b47d70ac44b78c28226bca1e", "tools": [ { "name": "status", @@ -12472,7 +12492,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -12482,7 +12502,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -12505,7 +12525,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -12537,7 +12558,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -12574,7 +12595,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -13001,8 +13023,8 @@ "version": "0.58.1" }, "reply": { - "generation": "620e6ad226ebdf1877d24ec0711f9afe2a5359263d1808629e7fa0af6cb134c7", - "catalog_digest": "620e6ad226ebdf1877d24ec0711f9afe2a5359263d1808629e7fa0af6cb134c7", + "generation": "20035d053f2f922a85a86240caad2488ccc9cecffa319d460877fe9b8a6412e6", + "catalog_digest": "20035d053f2f922a85a86240caad2488ccc9cecffa319d460877fe9b8a6412e6", "tools": [ { "name": "status", @@ -13690,7 +13712,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -13700,7 +13722,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -13723,7 +13745,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -13755,7 +13778,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -13792,7 +13815,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -14218,8 +14242,8 @@ "version": "0.58.1" }, "reply": { - "generation": "93ee1801ef0199e16023d21a061b58111bac4f5c8e2184b59f0875ed48b67be7", - "catalog_digest": "93ee1801ef0199e16023d21a061b58111bac4f5c8e2184b59f0875ed48b67be7", + "generation": "7e38ad6819414c1fefcf5f294e214290f2483aa534ff00dc9ec6ae69e072ec7a", + "catalog_digest": "7e38ad6819414c1fefcf5f294e214290f2483aa534ff00dc9ec6ae69e072ec7a", "tools": [ { "name": "status", @@ -14942,7 +14966,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -14952,7 +14976,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -14975,7 +14999,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -15007,7 +15032,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -15044,7 +15069,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -15470,8 +15496,8 @@ "version": "0.58.1" }, "reply": { - "generation": "25b45146a812fb60f188a87f46b69419d8a5d9f1af0bea620834b3d0dcb1a942", - "catalog_digest": "25b45146a812fb60f188a87f46b69419d8a5d9f1af0bea620834b3d0dcb1a942", + "generation": "9698466a655c063e73f672a58d732ab0129a5537c16f6d414eeac187b168fa7e", + "catalog_digest": "9698466a655c063e73f672a58d732ab0129a5537c16f6d414eeac187b168fa7e", "tools": [ { "name": "status", @@ -16191,7 +16217,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -16201,7 +16227,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -16224,7 +16250,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -16256,7 +16283,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -16293,7 +16320,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -16720,8 +16748,8 @@ "version": "0.58.1" }, "reply": { - "generation": "e2c801841911f5891ee4e645789a5b2fae84897a36675e72ab9706fabf98029a", - "catalog_digest": "e2c801841911f5891ee4e645789a5b2fae84897a36675e72ab9706fabf98029a", + "generation": "2ec7199846cb4ba00cb1552c3f9a4b1a406a20f541863d32e3644afa77593572", + "catalog_digest": "2ec7199846cb4ba00cb1552c3f9a4b1a406a20f541863d32e3644afa77593572", "tools": [ { "name": "status", @@ -17384,7 +17412,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -17394,7 +17422,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -17417,7 +17445,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -17449,7 +17478,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -17486,7 +17515,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -17912,8 +17942,8 @@ "version": "0.58.1" }, "reply": { - "generation": "d81dcf20e79285b24f085f1430c08c954bf90a463cb3249418560f8049a5a360", - "catalog_digest": "d81dcf20e79285b24f085f1430c08c954bf90a463cb3249418560f8049a5a360", + "generation": "45481ed7f61e451924ef1dc946e4fa93d1ce45e3f694f8507a79ea312be7d98a", + "catalog_digest": "45481ed7f61e451924ef1dc946e4fa93d1ce45e3f694f8507a79ea312be7d98a", "tools": [ { "name": "status", @@ -18573,7 +18603,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -18583,7 +18613,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -18606,7 +18636,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -18638,7 +18669,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -18675,7 +18706,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -19101,8 +19133,8 @@ "version": "0.58.1" }, "reply": { - "generation": "5d0a7b921e251fcf26b654df71eb0ac0e85e55a839b399283a3333776a1c9ce0", - "catalog_digest": "5d0a7b921e251fcf26b654df71eb0ac0e85e55a839b399283a3333776a1c9ce0", + "generation": "28d8ac938c23d9e4bbeee99b34f664edaf7739b35db0f3c8fbc7bbf5e80915ba", + "catalog_digest": "28d8ac938c23d9e4bbeee99b34f664edaf7739b35db0f3c8fbc7bbf5e80915ba", "tools": [ { "name": "status", @@ -19758,7 +19790,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -19768,7 +19800,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -19791,7 +19823,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -19823,7 +19856,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -19860,7 +19893,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -20286,8 +20320,8 @@ "version": "0.58.1" }, "reply": { - "generation": "ae54f33b83ab33a58003e2228c72a91c59302897712ac2b8a7b39f98b860ee45", - "catalog_digest": "ae54f33b83ab33a58003e2228c72a91c59302897712ac2b8a7b39f98b860ee45", + "generation": "000705872dafd4a829a8f46a3edddb3e2f545cfd1f4f1319e49c2a3bca0fd763", + "catalog_digest": "000705872dafd4a829a8f46a3edddb3e2f545cfd1f4f1319e49c2a3bca0fd763", "tools": [ { "name": "status", @@ -20940,7 +20974,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -20950,7 +20984,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -20973,7 +21007,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -21005,7 +21040,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -21042,7 +21077,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { diff --git a/crates/aft/tests/fixtures/tool_provider_catalog_presets.json b/crates/aft/tests/fixtures/tool_provider_catalog_presets.json index 95a4dfc12f..fd57811f5f 100644 --- a/crates/aft/tests/fixtures/tool_provider_catalog_presets.json +++ b/crates/aft/tests/fixtures/tool_provider_catalog_presets.json @@ -10,8 +10,8 @@ "disabled_tools": [], "powershell_available": false, "reply": { - "generation": "1a1f91d9ef9329a9483514e44440e6e4cb9b4a1abb61850ff545943559505a18", - "catalog_digest": "1a1f91d9ef9329a9483514e44440e6e4cb9b4a1abb61850ff545943559505a18", + "generation": "5eb36fe06356a75f368bc26c05510f8d52e89a653c194ecb6fcba9d922adb876", + "catalog_digest": "5eb36fe06356a75f368bc26c05510f8d52e89a653c194ecb6fcba9d922adb876", "tools": [ { "name": "status", @@ -707,7 +707,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -717,7 +717,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -740,7 +740,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -772,7 +773,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -809,7 +810,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -1288,8 +1290,8 @@ "disabled_tools": [], "powershell_available": true, "reply": { - "generation": "cbfdfca755c28bf6dcc408e28007094df90a819c311dca32845dc304cc67f42f", - "catalog_digest": "cbfdfca755c28bf6dcc408e28007094df90a819c311dca32845dc304cc67f42f", + "generation": "4f099a09a632c56778caddd4d8a2413787bfd4900517cbf056dbc07a112f1f0d", + "catalog_digest": "4f099a09a632c56778caddd4d8a2413787bfd4900517cbf056dbc07a112f1f0d", "tools": [ { "name": "status", @@ -2059,7 +2061,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -2069,7 +2071,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -2092,7 +2094,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -2124,7 +2127,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -2161,7 +2164,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -3562,8 +3566,8 @@ "powershell_available": false, "remote_runs": true, "reply": { - "generation": "adaf1a2f05f47e2af785618ba9a30340f7ba89479bf83160cd7cad774f1da1d4", - "catalog_digest": "adaf1a2f05f47e2af785618ba9a30340f7ba89479bf83160cd7cad774f1da1d4", + "generation": "2013a50a1da5629a2f0dc42c04de867dbabb26bad5a130ab72a5d6b75f45d7e3", + "catalog_digest": "2013a50a1da5629a2f0dc42c04de867dbabb26bad5a130ab72a5d6b75f45d7e3", "tools": [ { "name": "status", @@ -4271,7 +4275,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -4281,7 +4285,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -4304,7 +4308,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -4336,7 +4341,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -4373,7 +4378,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -4853,8 +4859,8 @@ "powershell_available": true, "remote_runs": true, "reply": { - "generation": "486a1f6fd39dd7439a3c13af4a17df40bcfe206cc615efde4effa37a71a03588", - "catalog_digest": "486a1f6fd39dd7439a3c13af4a17df40bcfe206cc615efde4effa37a71a03588", + "generation": "cdc56c25eefd092406a0daf33a1a835c6c9901dd4ce82d76f9bb901deb50f5b5", + "catalog_digest": "cdc56c25eefd092406a0daf33a1a835c6c9901dd4ce82d76f9bb901deb50f5b5", "tools": [ { "name": "status", @@ -5636,7 +5642,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -5646,7 +5652,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -5669,7 +5675,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -5701,7 +5708,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -5738,7 +5745,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -6218,8 +6226,8 @@ "disabled_tools": [], "powershell_available": false, "reply": { - "generation": "1f4117191dce93e591a3f464ba18b852cd040b6fa014c483f04ec133f69ed5b9", - "catalog_digest": "1f4117191dce93e591a3f464ba18b852cd040b6fa014c483f04ec133f69ed5b9", + "generation": "afdf1ff3c10a6d36f471eebaa6a12a3b64f9d61ce5eac9e15e8920149fada7d8", + "catalog_digest": "afdf1ff3c10a6d36f471eebaa6a12a3b64f9d61ce5eac9e15e8920149fada7d8", "tools": [ { "name": "status", @@ -6915,7 +6923,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -6925,7 +6933,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -6948,7 +6956,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -6980,7 +6989,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -7017,7 +7026,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -7430,8 +7440,8 @@ "disabled_tools": [], "powershell_available": true, "reply": { - "generation": "a91ae13cba6cc7c57c313a4b0ee9b7b739e2b1edc0d9a4c499e140a07d1a756b", - "catalog_digest": "a91ae13cba6cc7c57c313a4b0ee9b7b739e2b1edc0d9a4c499e140a07d1a756b", + "generation": "feec6466cf78e57923ef5dd96f02bc9c1831f7d959f865740e1eccc725dfc8d3", + "catalog_digest": "feec6466cf78e57923ef5dd96f02bc9c1831f7d959f865740e1eccc725dfc8d3", "tools": [ { "name": "status", @@ -8201,7 +8211,7 @@ { "read_only": true, "name": "ast_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -8211,7 +8221,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -8234,7 +8244,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -8266,7 +8277,7 @@ }, { "name": "ast_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -8303,7 +8314,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -8723,8 +8735,8 @@ "disabled_tools": [], "powershell_available": false, "reply": { - "generation": "7b55ca9f7252399ab1ffe6d7da9529939af5c936e22f904edd531d35a723f237", - "catalog_digest": "7b55ca9f7252399ab1ffe6d7da9529939af5c936e22f904edd531d35a723f237", + "generation": "016df98f3645c531920c95610c467ce04e905b91ea68b687a02e595ecad7f404", + "catalog_digest": "016df98f3645c531920c95610c467ce04e905b91ea68b687a02e595ecad7f404", "tools": [ { "name": "bash", @@ -9288,7 +9300,7 @@ { "read_only": true, "name": "ast_grep_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -9298,7 +9310,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -9321,7 +9333,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -9353,7 +9366,7 @@ }, { "name": "ast_grep_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -9390,7 +9403,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -9859,8 +9873,8 @@ "disabled_tools": [], "powershell_available": false, "reply": { - "generation": "f2b3dd280a517810d1429863899eeb7ec4f5ae2ded764c1458c9587766f677b5", - "catalog_digest": "f2b3dd280a517810d1429863899eeb7ec4f5ae2ded764c1458c9587766f677b5", + "generation": "f16c2f4ea62d2bd95af6881cc3fcb1519dca3322ddbfc1b23eb296308d907440", + "catalog_digest": "f16c2f4ea62d2bd95af6881cc3fcb1519dca3322ddbfc1b23eb296308d907440", "tools": [ { "name": "bash", @@ -10512,7 +10526,7 @@ { "read_only": true, "name": "ast_grep_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -10522,7 +10536,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -10545,7 +10559,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -10577,7 +10592,7 @@ }, { "name": "ast_grep_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -10614,7 +10629,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -11087,8 +11103,8 @@ "hashline": true }, "reply": { - "generation": "91a936147272e86f6186e11aac74d955b5b939cf4659daaa4e4ccf0ef3fd6af4", - "catalog_digest": "91a936147272e86f6186e11aac74d955b5b939cf4659daaa4e4ccf0ef3fd6af4", + "generation": "7d8da5b952b0c73d7a7cf5972de6af2f8209621848e0fc22e33dc8aa4505d10e", + "catalog_digest": "7d8da5b952b0c73d7a7cf5972de6af2f8209621848e0fc22e33dc8aa4505d10e", "tools": [ { "name": "bash", @@ -11686,7 +11702,7 @@ { "read_only": true, "name": "ast_grep_search", - "schema_digest": "96463c1682f4d87f5216797bb29cc474cd88690a8c9469f1824d9d4b9faa0b35", + "schema_digest": "9baa9cf880ce69d7eb41c25fd7c43d358b325be852d79298a8b0196e11a99c4c", "semantics": 1, "modes": [ "classic", @@ -11696,7 +11712,7 @@ "capabilities": [ "aft:code.ast_grep/v1" ], - "description": "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "description": "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\nUse meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\nIMPORTANT: Patterns must be complete AST nodes (valid code fragments).\nFor functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\nExamples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", "input_schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", @@ -11719,7 +11735,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { @@ -11751,7 +11768,7 @@ }, { "name": "ast_grep_replace", - "schema_digest": "86703537e883e53529c1045ee962ec1b062401108112606deffb16ff847892c9", + "schema_digest": "524ddc3bc03d6558c238293b068fc42fe26892a7b51f29e15256809e88db514a", "semantics": 1, "modes": [ "classic", @@ -11788,7 +11805,8 @@ "metal", "pascal", "r", - "objc" + "objc", + "nix" ] }, "paths": { diff --git a/crates/aft/tests/integration/format_test.rs b/crates/aft/tests/integration/format_test.rs index 879904adf0..afc889aded 100644 --- a/crates/aft/tests/integration/format_test.rs +++ b/crates/aft/tests/integration/format_test.rs @@ -1569,3 +1569,55 @@ fn validate_full_flows_through_add_import() { let status = aft.shutdown(); assert!(status.success()); } + +#[cfg(unix)] +#[test] +fn format_integration_nixfmt_config_runs_nixfmt() { + let dir = format_test_dir("nixfmt_config_runs"); + let bin_dir = dir.join("node_modules").join(".bin"); + fs::create_dir_all(&bin_dir).unwrap(); + let stub = bin_dir.join("nixfmt"); + link_cached_executable( + &stub, + br#"#!/bin/sh +file="$1" +printf 'formatted = true;\n' > "$file" +"#, + ) + .unwrap(); + warm_executable(&stub, &[]); + + let target = dir.join("config.nix"); + let _ = fs::remove_file(&target); + let path = prepend_path(&std::ffi::OsString::new(), &dir); + let mut aft = AftProcess::spawn_with_env(&[("PATH", path.as_os_str())]); + let cfg = aft.send( + &serde_json::json!({ + "id": "cfg-nixfmt", + "command": "configure", + "harness": "opencode", + "project_root": dir.display().to_string(), + "config": user_config(serde_json::json!({ + "format_on_edit": true, + "formatter": { "nix": "nixfmt" } + })) + }) + .to_string(), + ); + assert_eq!(cfg["success"], true, "configure should succeed: {cfg:?}"); + + let resp = aft.send(&format!( + r#"{{"id":"fmt-nix","command":"write","file":{},"content":"{{ a = 1; }}\n"}}"#, + crate::helpers::json_string(&target.display()) + )); + assert_eq!(resp["success"], true, "write should succeed: {resp:?}"); + assert_eq!( + resp["formatted"], true, + "nixfmt should have formatted the file" + ); + assert_eq!(fs::read_to_string(&target).unwrap(), "formatted = true;\n"); + + let _ = fs::remove_file(&target); + let status = aft.shutdown(); + assert!(status.success()); +} diff --git a/crates/aft/tests/integration/is_semantic_indexed_extension_test.rs b/crates/aft/tests/integration/is_semantic_indexed_extension_test.rs index 0d882d4171..be5b0093f5 100644 --- a/crates/aft/tests/integration/is_semantic_indexed_extension_test.rs +++ b/crates/aft/tests/integration/is_semantic_indexed_extension_test.rs @@ -9,7 +9,7 @@ fn semantic_extension_policy_stays_in_sync_with_parser_code_arms() { "ts", "tsx", "js", "jsx", "py", "rs", "go", "c", "h", "cc", "cpp", "cxx", "hpp", "hh", "cu", "cuh", "metal", "zig", "cs", "sh", "bash", "zsh", "sol", "vue", "pas", "pp", "dpr", "dpk", "lpr", "java", "kt", "kts", "rb", "swift", "scala", "sc", "lua", "pl", "pm", "t", - "r", "R", "m", "mm", "toml", "yaml", "yml", + "r", "R", "m", "mm", "toml", "nix", "yaml", "yml", ]; for extension in code_extensions { let path = format!("fixture.{extension}"); diff --git a/crates/aft/tests/integration/main.rs b/crates/aft/tests/integration/main.rs index 109dab8e95..279da11cc7 100644 --- a/crates/aft/tests/integration/main.rs +++ b/crates/aft/tests/integration/main.rs @@ -125,6 +125,7 @@ mod markdown_test; mod metal_test; mod move_file_test; mod move_symbol_test; +mod nix_test; mod objc_test; mod outline_files_mode_test; mod outline_languages_test; diff --git a/crates/aft/tests/integration/nix_test.rs b/crates/aft/tests/integration/nix_test.rs new file mode 100644 index 0000000000..726c28f03e --- /dev/null +++ b/crates/aft/tests/integration/nix_test.rs @@ -0,0 +1,367 @@ +//! Integration tests for the Nix language column: outline, zoom, AST +//! search/replace, semantic extension policy, and the unsupported columns. + +use serde_json::json; +use std::fs; +use std::path::Path; + +use aft::data_layer::content::extract; +use aft::language::LanguageProvider; +use aft::parser::{detect_language, LangId, TreeSitterProvider}; +use aft_store::content::RecordBody; + +use super::helpers::AftProcess; + +fn write_project() -> tempfile::TempDir { + let dir = tempfile::tempdir().expect("temp dir"); + for name in ["flake.nix", "nix_module.nix"] { + let source = fs::read_to_string(crate::helpers::fixture_path(name)).expect("fixture"); + fs::write(dir.path().join(name), source).unwrap(); + } + dir +} + +fn outline_files(aft: &mut AftProcess, directory: &Path) -> serde_json::Value { + aft.send( + &json!({ + "id": "outline-nix-files", + "command": "outline", + "directory": directory, + "files": true, + }) + .to_string(), + ) +} + +#[test] +fn nix_outline_zoom_and_language_label() { + assert_eq!(detect_language(Path::new("flake.nix")), Some(LangId::Nix)); + + let dir = write_project(); + let mut aft = AftProcess::spawn(); + assert_eq!(aft.configure(dir.path())["success"], true); + + let outline = aft.send( + &json!({ + "id": "outline-nix-module", + "command": "outline", + "file": dir.path().join("nix_module.nix"), + }) + .to_string(), + ); + assert_eq!(outline["success"], true, "outline failed: {outline:?}"); + let text = outline["text"].as_str().expect("outline text"); + assert!( + text.contains("options.services.demo.enable"), + "dotted module option missing: {text}" + ); + assert!(text.contains("config.services.demo"), "{text}"); + assert!(text.contains("port"), "nested key missing: {text}"); + + let flake_outline = aft.send( + &json!({ + "id": "outline-nix-flake", + "command": "outline", + "file": dir.path().join("flake.nix"), + }) + .to_string(), + ); + assert_eq!(flake_outline["success"], true, "{flake_outline:?}"); + let flake_text = flake_outline["text"].as_str().unwrap(); + assert!( + flake_text.contains("devShells.x86_64-linux.default"), + "{flake_text}" + ); + assert!( + flake_text.contains("outputs = inputs@"), + "function binding must keep its name in the outline: {flake_text}" + ); + + let files = outline_files(&mut aft, dir.path()); + assert_eq!(files["success"], true, "{files:?}"); + for name in ["flake.nix", "nix_module.nix"] { + let entry = files["files"] + .as_array() + .expect("files array") + .iter() + .find(|entry| entry["path"] == name) + .unwrap_or_else(|| panic!("missing {name}: {files:?}")); + assert_eq!(entry["language"], "nix", "{entry:?}"); + assert!(entry["symbols"].as_u64().unwrap_or(0) > 0, "{entry:?}"); + } + + let zoom = aft.send( + &json!({ + "id": "zoom-nix", + "command": "zoom", + "file": dir.path().join("flake.nix"), + "symbol": "outputs.devShells.x86_64-linux.default", + "context_lines": 0, + }) + .to_string(), + ); + assert_eq!(zoom["success"], true, "zoom failed: {zoom:?}"); + assert_eq!( + zoom["range"]["start_line"], 7, + "zoom must resolve the nested binding: {zoom:?}" + ); + assert!( + zoom["content"] + .as_str() + .unwrap_or_default() + .trim_start() + .starts_with("devShells.x86_64-linux.default ="), + "zoom must return the nested binding, not the whole outputs expression: {zoom:?}" + ); + + let missing = aft.send( + &json!({ + "id": "zoom-nix-missing", + "command": "zoom", + "file": dir.path().join("flake.nix"), + "symbol": "outputs.notThere", + }) + .to_string(), + ); + assert_eq!(missing["success"], false, "{missing:?}"); + assert_eq!(missing["code"], "symbol_not_found", "{missing:?}"); + + assert!(aft.shutdown().success()); +} + +#[test] +fn nix_ast_search_and_replace_preserve_siblings() { + let dir = tempfile::tempdir().expect("temp dir"); + let file = dir.path().join("ast.nix"); + fs::write(&file, "{ foo = true; bar = false; baz.qux = true; }\n").unwrap(); + + let mut aft = AftProcess::spawn(); + assert_eq!(aft.configure(dir.path())["success"], true); + + let search = aft.send( + &json!({ + "id": "ast-search-nix", + "command": "ast_search", + "pattern": "$NAME = true;", + "lang": "nix", + "paths": [file.display().to_string()], + }) + .to_string(), + ); + assert_eq!(search["success"], true, "search failed: {search:?}"); + let matches = search["matches"].as_array().expect("matches array"); + assert_eq!(matches.len(), 2, "{search:?}"); + + let replace = aft.send( + &json!({ + "id": "ast-replace-nix", + "command": "ast_replace", + "pattern": "$NAME = true;", + "rewrite": "$NAME = false;", + "lang": "nix", + "paths": [file.display().to_string()], + "dry_run": false, + }) + .to_string(), + ); + assert_eq!(replace["success"], true, "replace failed: {replace:?}"); + assert_eq!( + fs::read_to_string(&file).unwrap(), + "{ foo = false; bar = false; baz.qux = false; }\n" + ); + + assert!(aft.shutdown().success()); +} + +#[test] +fn nix_unsupported_columns_report_no_edges() { + let dir = write_project(); + let file = dir.path().join("nix_module.nix"); + let file_str = file.display().to_string(); + + let mut aft = AftProcess::spawn(); + assert_eq!(aft.configure(dir.path())["success"], true); + + let import = aft.send( + &json!({ + "id": "add-import-nix", + "command": "add_import", + "file": file_str, + "module": "nixpkgs", + }) + .to_string(), + ); + assert_eq!(import["success"], false, "{import:?}"); + assert_eq!(import["code"], "unsupported_language", "{import:?}"); + + let refactor = aft.send( + &json!({ + "id": "extract-function-nix", + "command": "extract_function", + "file": file_str, + "name": "demo", + "start_line": 3, + "end_line": 5, + }) + .to_string(), + ); + assert_eq!(refactor["success"], false, "{refactor:?}"); + assert_eq!(refactor["code"], "unsupported_language", "{refactor:?}"); + + // Nix contributes no call edges, so a zoom on a nested flake output carries + // neither outgoing nor incoming calls. + let zoom = aft.send( + &json!({ + "id": "zoom-nix-callgraph", + "command": "zoom", + "file": dir.path().join("flake.nix"), + "symbol": "outputs.devShells.x86_64-linux.default", + }) + .to_string(), + ); + assert_eq!(zoom["success"], true, "{zoom:?}"); + assert_eq!( + zoom["annotations"]["calls_out"], + json!([]), + "no outgoing call edges: {zoom:?}" + ); + assert_eq!( + zoom["annotations"]["called_by"], + json!([]), + "no incoming call edges: {zoom:?}" + ); + + assert!(aft.shutdown().success()); +} + +#[test] +fn nix_validation_stays_unsupported() { + let dir = write_project(); + let file = dir.path().join("nix_module.nix"); + let mut aft = AftProcess::spawn(); + assert_eq!(aft.configure(dir.path())["success"], true); + + let params = json!({ + "id": "write-nix-validate", + "command": "write", + "file": file.display().to_string(), + "content": format!("{}\n# validated\n", fs::read_to_string(&file).unwrap()), + "validate": "full", + }); + + let response = aft.send(¶ms.to_string()); + assert_eq!(response["success"], true, "{response:?}"); + assert_eq!( + response["validate_skipped_reason"], "unsupported_language", + "Nix has no checker support: {response:?}" + ); + + assert!(aft.shutdown().success()); +} + +#[test] +fn nix_semantic_extension_is_indexed() { + // The semantic indexing policy accepts `.nix`; chunk collection itself is + // covered by the unit test with the same name in semantic_index.rs, where + // the collector is reachable without the census feature. + let dir = write_project(); + assert!(aft::semantic_index::is_semantic_indexed_extension( + &dir.path().join("flake.nix") + )); +} + +#[test] +fn nix_indexing_yields_a_content_record() { + // The old views-plane callgraph-payload test retired when outlines became + // content records; this is its replacement on the new store. Indexing the + // real module fixture must produce a parsed Nix record: its outline + // symbols, the file's TODO markers, and no import or call facts (Nix + // contributes neither). + let mut source = + fs::read_to_string(crate::helpers::fixture_path("nix_module.nix")).expect("fixture"); + // A TODO in a `#` comment: Nix comments are TODO-counted, so the record + // must carry the marker. Added in memory so the on-disk fixture stays put. + source.push_str("\n# TODO: demo marker\n"); + + let record = extract(source.as_bytes(), "nix").expect("extract a Nix content record"); + assert_eq!(record.language, "nix"); + + let RecordBody::Parsed { body, .. } = &record.data else { + panic!( + "a Nix source must produce a parsed record: {:?}", + record.data + ) + }; + + // Outline symbols, as the parser lists them for the module fixture. Names + // and enclosing scopes both count toward the dotted path, so the assertion + // holds whether the extractor qualified a binding or left it loose. + let joined: String = outline_blob(body); + for expected in ["config.services.demo", "enable", "port"] { + assert!( + joined.contains(expected), + "outline missing {expected}: {joined}" + ); + } + + // TODO markers, read from the file's `#` comments as Nix. + let todos = record.todos.expect("Nix comments are TODO-counted"); + assert_eq!(todos.language, "nix"); + let markers = todos.items.expect("UTF-8 source yields a marker list"); + assert!( + markers.iter().any(|marker| marker.marker == "TODO"), + "expected a TODO marker: {markers:?}" + ); + + // Nix has no import or call support: the record carries no facts. + assert!( + body.imports.is_empty(), + "Nix has no imports: {:?}", + body.imports + ); + assert!( + body.call_sites.is_empty(), + "Nix contributes no call sites: {:?}", + body.call_sites + ); + assert!( + body.references.is_empty(), + "Nix contributes no references: {:?}", + body.references + ); +} + +/// Every outline symbol's name and enclosing scopes, flattened into one +/// newline-joined blob so dotted-path membership can be checked regardless of +/// how the extractor split a qualified binding between name and `scope_chain`. +fn outline_blob(body: &aft_store::content::Body) -> String { + body.outline + .as_ref() + .expect("Nix records carry an outline") + .iter() + .map(|symbol| { + let mut path = symbol.scope_chain.join("."); + if !path.is_empty() { + path.push('.'); + } + path.push_str(&symbol.name); + path + }) + .collect::>() + .join("\n") +} + +#[test] +fn nix_symbols_from_provider_use_dotted_paths() { + let dir = write_project(); + let provider = TreeSitterProvider::new(); + let symbols = provider + .list_symbols(&dir.path().join("nix_module.nix")) + .expect("list Nix symbols"); + let enable = symbols + .iter() + .find(|symbol| symbol.name == "enable") + .expect("nested enable"); + assert_eq!(enable.scope_chain, vec!["config.services.demo"]); + assert_eq!(enable.parent.as_deref(), Some("config.services.demo")); +} diff --git a/crates/aft/tests/semantic_chunk_census.rs b/crates/aft/tests/semantic_chunk_census.rs index bcb94dd127..b5d1736b09 100644 --- a/crates/aft/tests/semantic_chunk_census.rs +++ b/crates/aft/tests/semantic_chunk_census.rs @@ -1277,6 +1277,18 @@ fn language_label(language: u8) -> &'static str { 30 => "Groovy", 31 => "Objective-C", 32 => "TOML", + 33 => "Luau", + 34 => "Nix", other => panic!("unknown cached language code {other}"), } } + +#[test] +// NOTE: this file is `#![cfg(feature = "semantic-chunk-census")]` with +// `autotests = false` and no registered `[[test]]` target, so no current +// command compiles or runs this — it documents and guards the decode arm +// for whenever the census target is registered (openspec design D5: the +// arm itself is verified by grep + compile-when-enabled). +fn language_label_covers_nix() { + assert_eq!(language_label(language_code(LangId::Nix)), "Nix"); +} diff --git a/crates/aft/tests/store_diet/CORPUS.md b/crates/aft/tests/store_diet/CORPUS.md index 4ec4e2a6c4..09ee7d487e 100644 --- a/crates/aft/tests/store_diet/CORPUS.md +++ b/crates/aft/tests/store_diet/CORPUS.md @@ -11,8 +11,10 @@ the selectors and narrowly justified new inputs. No fixture program is executed. The corpus contains the existing 33-language scoped-node table from `callgraph_store/position_identity_tests.rs`, the eight-language receiver table -from `callgraph_store/dispatch/tests.rs`, and the explicitly named richer projects -in the manifest. Projects are isolated from one another so similarly named types +from `callgraph_store/dispatch/tests.rs`, the explicitly named richer projects +in the manifest, and the `smoke-nix` `new_for` text case registered in +`corpus_sources.json` (Nix postdates the scoped-node table, so the generator +materializes it from its stored text). Projects are isolated from one another so similarly named types from unrelated fixture projects cannot change resolution. | Family | Existing richer inputs sampled | @@ -42,8 +44,8 @@ f/g call shape; stale marking uses the production `mark_files_stale` API. - Typed receiver inference is implemented for TS/TSX/JS, Python, Rust, Go, Java, C# and Kotlin. No typed-dispatch claim is made for the other language samples. -- Bash, SCSS, Vue, HTML, Markdown, JSON, YAML, Pascal, R, Groovy, ObjC and TOML - have no call-expression node kinds in `calls.rs`. Their structural symbols, +- Bash, SCSS, Vue, HTML, Markdown, JSON, YAML, Pascal, R, Groovy, ObjC, TOML + and Nix have no call-expression node kinds in `calls.rs`. Their structural symbols, file-language values and empty/incomplete answers are still part of parity. - Markdown is excluded by the views graph plane, not silently parsed as TS. - No established PHP constructor/closure-call or Swift/Lua/Perl closure-call diff --git a/crates/aft/tests/store_diet/corpus.py b/crates/aft/tests/store_diet/corpus.py index be9250f9f2..e88a9df3fc 100644 --- a/crates/aft/tests/store_diet/corpus.py +++ b/crates/aft/tests/store_diet/corpus.py @@ -12,7 +12,7 @@ c='c', cpp='cpp', cuda='cu', metal='metal', zig='zig', csharp='cs', bash='sh', html='html', markdown='md', solidity='sol', scss='scss', vue='vue', json='json', scala='scala', java='java', ruby='rb', kotlin='kt', swift='swift', php='php', - lua='lua', perl='pl', yaml='yaml', pascal='pas', r='r', groovy='groovy', objc='m', toml='toml') + lua='lua', perl='pl', yaml='yaml', pascal='pas', r='r', groovy='groovy', objc='m', toml='toml', nix='nix') def function_table(source, function): diff --git a/crates/aft/tests/store_diet/corpus/smoke-nix/a.nix b/crates/aft/tests/store_diet/corpus/smoke-nix/a.nix new file mode 100644 index 0000000000..fa3780f761 --- /dev/null +++ b/crates/aft/tests/store_diet/corpus/smoke-nix/a.nix @@ -0,0 +1 @@ +{ f = { g = 1; }; } diff --git a/crates/aft/tests/store_diet/corpus_manifest.json b/crates/aft/tests/store_diet/corpus_manifest.json index f2933de7d6..bcda2c4eb6 100644 --- a/crates/aft/tests/store_diet/corpus_manifest.json +++ b/crates/aft/tests/store_diet/corpus_manifest.json @@ -961,6 +961,21 @@ } ] }, + { + "name": "smoke-nix", + "language": "nix", + "shapes": [ + "existing scoped-node identity smoke" + ], + "files": [ + { + "target": "a.nix", + "new_for": "Missing stored values: nix absent from the scoped-node smoke table (position_identity_tests.rs predates Nix support)", + "text": "{ f = { g = 1; }; }\n", + "sha256": "035fd5a00d2069b27da4f2ddfaa4bdb58a57458ba1d31a055598e247bc0b0266" + } + ] + }, { "name": "smoke-objc", "language": "objc", diff --git a/crates/aft/tests/store_diet/corpus_sources.json b/crates/aft/tests/store_diet/corpus_sources.json index 1ca29bedb0..4a59b4ca01 100644 --- a/crates/aft/tests/store_diet/corpus_sources.json +++ b/crates/aft/tests/store_diet/corpus_sources.json @@ -868,6 +868,20 @@ "contains": "macro_rules! runtime_methods" } ] + }, + { + "name": "smoke-nix", + "language": "nix", + "shapes": [ + "existing scoped-node identity smoke" + ], + "files": [ + { + "target": "a.nix", + "new_for": "Missing stored values: nix absent from the scoped-node smoke table (position_identity_tests.rs predates Nix support)", + "text": "{ f = { g = 1; }; }\n" + } + ] } ] } diff --git a/docs/config.md b/docs/config.md index d5bb15e023..1137875f4d 100644 --- a/docs/config.md +++ b/docs/config.md @@ -294,9 +294,10 @@ Omit an optional setting instead of using `null`. // Auto-validate after edits: "syntax" (tree-sitter, fast) or "full" (runs type checker) "validate_on_edit": "syntax", - // Per-language formatter overrides (auto-detected from project config files if omitted) - // Keys: "typescript", "python", "rust", "go" - // Values: "biome" | "oxfmt" | "prettier" | "deno" | "ruff" | "black" | "rustfmt" | "goimports" | "gofmt" | "none" + // Per-language formatter overrides (auto-detected from project config files if omitted; + // "nix" has no auto-detection and formats only when set explicitly to "nixfmt") + // Keys: "typescript", "python", "rust", "go", "nix" + // Values: "biome" | "oxfmt" | "prettier" | "deno" | "ruff" | "black" | "rustfmt" | "goimports" | "gofmt" | "nixfmt" | "none" "formatter": { "typescript": "biome", "rust": "rustfmt" diff --git a/packages/opencode-plugin/src/config.ts b/packages/opencode-plugin/src/config.ts index 2da05760e1..905b1c72f9 100644 --- a/packages/opencode-plugin/src/config.ts +++ b/packages/opencode-plugin/src/config.ts @@ -103,6 +103,7 @@ const FormatterEnum = z.enum([ "rustfmt", "goimports", "gofmt", + "nixfmt", "none", ]); diff --git a/packages/opencode-plugin/src/tools/ast.ts b/packages/opencode-plugin/src/tools/ast.ts index 2b2e247a9f..14275c5544 100644 --- a/packages/opencode-plugin/src/tools/ast.ts +++ b/packages/opencode-plugin/src/tools/ast.ts @@ -64,16 +64,17 @@ const SUPPORTED_LANGS = [ "pascal", "r", "objc", + "nix", ] as const; export function astTools(ctx: PluginContext): Record { const searchTool: ToolDefinition = { description: - "Search code patterns across filesystem using AST-aware matching. Supports 11 languages.\n\n" + + "Search code patterns across filesystem using AST-aware matching. Supports 12 languages.\n\n" + "Use meta-variables: $VAR matches a single AST node, $$$ matches multiple nodes (variadic).\n" + "IMPORTANT: Patterns must be complete AST nodes (valid code fragments).\n" + "For functions, include params and body: 'export async function $NAME($$$) { $$$ }' not just 'export async function $NAME'.\n\n" + - "Examples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc'", + "Examples: pattern='console.log($MSG)' lang='typescript', pattern='async function $NAME($$$) { $$$ }' lang='javascript', pattern='def $FUNC($$$): $$$' lang='python', pattern='Writeln($MSG);' lang='pascal', pattern='$X <- $Y' lang='r', pattern='[obj foo:$ARG]' lang='objc', pattern='$NAME = true;' lang='nix'", args: { pattern: z .string() diff --git a/packages/opencode-plugin/test/tool-surface/fixtures/v2-direct-base.json b/packages/opencode-plugin/test/tool-surface/fixtures/v2-direct-base.json index 054b68d559..0bfa20bd5f 100644 --- a/packages/opencode-plugin/test/tool-surface/fixtures/v2-direct-base.json +++ b/packages/opencode-plugin/test/tool-surface/fixtures/v2-direct-base.json @@ -17,8 +17,8 @@ "aft_safety": "cc4870f40641f036b3f9aaa6acf2038c5bbd56cd02e55eba1af3c945e2a3d895", "aft_import": "6ce13c95038a4043cd64699c4e42d86dcf2f6a09d8fa8bea16db13d3264f0cf3", "aft_callgraph": "03b2d5c44df4d24514cca33a5d2a4717eb6e9db3f1d40e69aa440215abd2a7f7", - "ast_grep_search": "60127d7fddb331eaad4e2d4b2436622f8694f220cd10c8dc36033a616873efdf", - "ast_grep_replace": "f2e2a4980635a166f1cb8f915865d55162b9ecd5dbba4275f499bbacb752b635", + "ast_grep_search": "0667165ed767c18ad0479941cb80cbe92455f72dba5ce9c44e4092ea1a1b58a1", + "ast_grep_replace": "fbfc810989fb177dc5fcc2cdbeae12eaa755484b3b7e9930bbfc3fb4bb6921af", "aft_search": "79b2fc098073aa34d629e8c4d528f66612d7731e63befc4ee21341cfb1a4889b", "aft_inspect": "98aea248ee2d1a93ec8821367defe4818473091ef0ea2fdbdb2603a8bbffccd5", "grep": "c84800e6f3936444a4203889411bfdfeab4d2fcb87044849665ad09467d1225b", diff --git a/packages/pi-plugin/src/config.ts b/packages/pi-plugin/src/config.ts index 88a80dda65..5b176dc843 100644 --- a/packages/pi-plugin/src/config.ts +++ b/packages/pi-plugin/src/config.ts @@ -104,6 +104,7 @@ export type Formatter = | "rustfmt" | "goimports" | "gofmt" + | "nixfmt" | "none"; export type Checker = @@ -698,6 +699,7 @@ const FormatterEnum = z.enum([ "rustfmt", "goimports", "gofmt", + "nixfmt", "none", ]); diff --git a/packages/pi-plugin/src/tools/ast.ts b/packages/pi-plugin/src/tools/ast.ts index 5ae2ce9026..29f7b3c6f1 100644 --- a/packages/pi-plugin/src/tools/ast.ts +++ b/packages/pi-plugin/src/tools/ast.ts @@ -1,6 +1,6 @@ /** * ast_grep_search + ast_grep_replace — AST-aware pattern search/rewrite. - * 11 languages: typescript, tsx, javascript, python, rust, go, CUDA, Metal, pascal, R, Objective-C. + * 12 languages: typescript, tsx, javascript, python, rust, go, CUDA, Metal, pascal, R, Objective-C, Nix. */ import { coerceBoolean } from "@cortexkit/aft-bridge"; @@ -52,6 +52,7 @@ const AstLang = StringEnum( "pascal", "r", "objc", + "nix", ] as const, { description: "Target language",