Skip to main content

code-search

Structural code search using tree-sitter queries — find AST patterns like specific function calls, composite literals, or node shapes across the workspace or in a single file. More precise than regex. Use when grep is too imprecise for the pattern. Activated by runectl syntax search/query.

跳到安装

来源信息

仓库
unstablebuild/rune
最近来源活动
2026年3月26日 19:53
检测到的 SKILL.md 语言
英语
星标
591
分支
34

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
code-search
description
Structural code search using tree-sitter queries — find AST patterns like specific function calls, composite literals, or node shapes across the workspace or in a single file. More precise than regex. Use when grep is too imprecise for the pattern. Activated by runectl syntax search/query.
allowed-tools
Bash(runectl:*)
# Code Search Tree-sitter structural search via `runectl syntax`. ## runectl syntax search Search workspace using a tree-sitter query. ``` Usage: runectl syntax search <query> [flags] Flags: -c, --capture stringArray Capture name filter (repeatable) -F, --format string Output format: table, json, or Go template -L, --lang stringArray Language filter (repeatable, e.g. go, python) ``` For simple "find all functions" queries, prefer `runectl syntax searchnode` from the code-structure skill instead. Example — find all struct type definitions in Go files: ```bash $ runectl syntax search '(type_declaration (type_spec name: (type_identifier) @name type: (struct_type)))' -L go file:///src/rune-agent/agent/agent.go Config 44:5-44:11 name file:///src/rune-agent/agent/agent.go Agent 72:5-72:10 name file:///src/rune-agent/dialogue/dialoguetui/cell_grid.go cellGrid 62:5-62:13 name ... ``` Each line shows `file text line:col-endLine:endCol capture_name`. The `@name` capture matched the type identifier. ## runectl syntax query Query a single file using a tree-sitter query. ``` Usage: runectl syntax query <file> <query> [flags] Flags: -c, --capture stringArray Capture name filter (repeatable) -F, --format string Output format: table, json, or Go template ``` Example — find all function calls in `bash.go`: ```bash $ runectl syntax query agent/agentools/bash.go '(call_expression function: (selector_expression) @fn)' file:///src/rune-agent/agent/agentools/bash.go json.Unmarshal 108:11-108:25 fn file:///src/rune-agent/agent/agentools/bash.go fmt.Sprintf 117:35-117:46 fn file:///src/rune-agent/agent/agentools/bash.go context.WithTimeout 133:16-133:35 fn file:///src/rune-agent/agent/agentools/bash.go t.exec.Start 149:11-149:23 fn ... ``` ## Tree-sitter query syntax Queries are S-expressions matching syntax tree nodes. Each pattern is parentheses containing the node type and optional child matchers. ```bash # All function declarations '(function_declaration name: (identifier) @name)' # Calls to a specific function '(call_expression function: (identifier) @fn (#eq? @fn "Println"))' # Composite literals of a specific type '(composite_literal type: (type_identifier) @type (#eq? @type "Config"))' # Binary expressions with two number literals '(binary_expression (number_literal) (number_literal))' ```
在 GitHub 查看