opencode-plugin-search 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +62 -13
  2. package/dist/index.js +3101 -42
  3. package/package.json +13 -4
package/README.md CHANGED
@@ -47,22 +47,29 @@ Search code in the project using AST patterns for structural matching.
47
47
 
48
48
  ### `ast_grep_find_by_rule`
49
49
 
50
- Search code using complex YAML rules for advanced structural queries.
50
+ Search code using structured AST rules for advanced structural queries.
51
51
 
52
52
  **Arguments**:
53
- - `yaml` (string): The ast-grep YAML rule definition
53
+ - `rule` (object): The ast-grep rule definition as a structured object with required `id`, `language`, and `rule` fields
54
54
  - `max_results` (number, optional): Maximum matches to return
55
55
  - `output_format` (string, optional): `"text"` or `"json"`
56
56
 
57
57
  **Example**:
58
- ```yaml
59
- id: find-async-functions
60
- language: javascript
61
- rule:
62
- kind: function_declaration
63
- has:
64
- pattern: await $EXPR
65
- stopBy: end
58
+ ```json
59
+ {
60
+ "rule": {
61
+ "id": "find-async-functions",
62
+ "language": "javascript",
63
+ "rule": {
64
+ "kind": "function_declaration",
65
+ "has": {
66
+ "pattern": "await $EXPR",
67
+ "stopBy": "end"
68
+ }
69
+ }
70
+ },
71
+ "max_results": 10
72
+ }
66
73
  ```
67
74
 
68
75
  ### `ast_grep_dump_syntax`
@@ -85,24 +92,66 @@ Analyze code structure by dumping syntax trees for debugging and understanding.
85
92
 
86
93
  ### `ast_grep_test_rule`
87
94
 
88
- Test and validate YAML rules against code snippets to ensure correct matching.
95
+ Test and validate structured AST rules against code snippets to ensure correct matching.
89
96
 
90
97
  **Arguments**:
91
98
  - `code` (string): The code to test
92
- - `yaml` (string): The ast-grep YAML rule
99
+ - `rule` (object): The ast-grep rule definition as a structured object with required `id`, `language`, and `rule` fields
93
100
 
94
101
  **Example**:
95
102
  ```json
96
103
  {
97
104
  "code": "async function test() { await fetch(); }",
98
- "yaml": "id: test\nlanguage: javascript\nrule:\n kind: function_declaration\n has:\n pattern: await $EXPR\n stopBy: end"
105
+ "rule": {
106
+ "id": "test",
107
+ "language": "javascript",
108
+ "rule": {
109
+ "kind": "function_declaration",
110
+ "has": {
111
+ "pattern": "await $EXPR",
112
+ "stopBy": "end"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ ## Rule Structure
120
+
121
+ The rule object follows the ast-grep rule configuration interface:
122
+
123
+ ```typescript
124
+ interface RuleObject {
125
+ pattern?: string | Pattern
126
+ kind?: string
127
+ regex?: string
128
+ inside?: RuleObject & Relation
129
+ has?: RuleObject & Relation
130
+ follows?: RuleObject & Relation
131
+ precedes?: RuleObject & Relation
132
+ all?: RuleObject[]
133
+ any?: RuleObject[]
134
+ not?: RuleObject
135
+ matches?: string
99
136
  }
100
137
  ```
101
138
 
139
+ See [ast-grep rule documentation](https://ast-grep.github.io/guide/rule-config.html) for detailed examples.
140
+
102
141
  ## Configuration
103
142
 
104
143
  The plugin automatically looks for `sgconfig.yaml` in the project root to support custom languages and rule directories for ast-grep search functionality. See [ast-grep documentation](https://ast-grep.github.io/advanced/custom-language.html) for configuration details.
105
144
 
145
+ ## Future Plans
146
+
147
+ See [ROADMAP.md](ROADMAP.md) for detailed plans about upcoming features including:
148
+
149
+ - **Pre-configured rule library** - Ready-to-use templates for common patterns
150
+ - **Batch query optimization** - Multiple patterns in single calls
151
+ - **Context-aware search** - Richer results with surrounding code context
152
+ - **Semantic search enhancement** - Component usage tracking and dependency analysis
153
+ - **Performance optimizations** - Parallel execution and smart caching
154
+
106
155
  ## Development
107
156
 
108
157
  ```bash