@liendev/lien 0.12.0 → 0.13.0
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.
- package/CURSOR_RULES_TEMPLATE.md +109 -0
- package/dist/index.js +668 -79
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/CURSOR_RULES_TEMPLATE.md
CHANGED
|
@@ -114,6 +114,115 @@ list_functions({
|
|
|
114
114
|
|
|
115
115
|
---
|
|
116
116
|
|
|
117
|
+
## Enhanced Metadata (AST-Based) ⚡ NEW in v0.13.0
|
|
118
|
+
|
|
119
|
+
Lien now uses **Abstract Syntax Tree (AST) parsing** for TypeScript/JavaScript files to provide rich code metadata:
|
|
120
|
+
|
|
121
|
+
### Metadata Fields in Search Results
|
|
122
|
+
|
|
123
|
+
All search results (`semantic_search`, `get_file_context`, `find_similar`, `list_functions`) now include enhanced metadata when available:
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
{
|
|
127
|
+
content: "function validateEmail(email: string): boolean { ... }",
|
|
128
|
+
metadata: {
|
|
129
|
+
file: "src/validators.ts",
|
|
130
|
+
startLine: 45,
|
|
131
|
+
endLine: 60,
|
|
132
|
+
type: "function", // 'function' | 'class' | 'block'
|
|
133
|
+
language: "typescript",
|
|
134
|
+
|
|
135
|
+
// AST-derived metadata (NEW in v0.13.0):
|
|
136
|
+
symbolName: "validateEmail", // Function/class name
|
|
137
|
+
symbolType: "function", // 'function' | 'method' | 'class' | 'interface'
|
|
138
|
+
parentClass: undefined, // For methods: parent class name
|
|
139
|
+
complexity: 3, // Cyclomatic complexity
|
|
140
|
+
parameters: ["email: string"], // Function parameters
|
|
141
|
+
signature: "function validateEmail(email: string): boolean", // Full signature
|
|
142
|
+
imports: ["@/utils/regex"] // File imports (for context)
|
|
143
|
+
},
|
|
144
|
+
score: 0.85,
|
|
145
|
+
relevance: "highly_relevant"
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### AST Metadata Benefits
|
|
150
|
+
|
|
151
|
+
1. **Never splits functions** - Chunks respect semantic boundaries (no mid-function splits)
|
|
152
|
+
2. **Function context** - Know exactly which function you're looking at
|
|
153
|
+
3. **Complexity metrics** - Identify complex functions that may need refactoring
|
|
154
|
+
4. **Signature awareness** - See parameters and return types at a glance
|
|
155
|
+
5. **Better AI context** - AI assistants get structured code information
|
|
156
|
+
|
|
157
|
+
### Using AST Metadata
|
|
158
|
+
|
|
159
|
+
**Find complex functions:**
|
|
160
|
+
```typescript
|
|
161
|
+
// Search for authentication logic
|
|
162
|
+
const results = await semantic_search({ query: "authentication logic" });
|
|
163
|
+
|
|
164
|
+
// Filter by complexity
|
|
165
|
+
const complexFunctions = results.filter(r => (r.metadata.complexity || 0) > 5);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Identify methods in a class:**
|
|
169
|
+
```typescript
|
|
170
|
+
// Get file context
|
|
171
|
+
const context = await get_file_context({ filepath: "src/auth/AuthService.ts" });
|
|
172
|
+
|
|
173
|
+
// Find all methods
|
|
174
|
+
const methods = context.results.filter(r => r.metadata.symbolType === 'method');
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**List functions with specific parameters:**
|
|
178
|
+
```typescript
|
|
179
|
+
const functions = await list_functions({ pattern: ".*validate.*", language: "typescript" });
|
|
180
|
+
|
|
181
|
+
// Filter by parameter count
|
|
182
|
+
const simpleValidators = functions.filter(r => (r.metadata.parameters?.length || 0) <= 2);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### AST Support
|
|
186
|
+
|
|
187
|
+
**Currently supported:**
|
|
188
|
+
- ✅ TypeScript (`.ts`, `.tsx`)
|
|
189
|
+
- ✅ JavaScript (`.js`, `.jsx`, `.mjs`, `.cjs`)
|
|
190
|
+
|
|
191
|
+
**Coming soon:**
|
|
192
|
+
- 🔜 Python, Go, Rust, Java, PHP, and more
|
|
193
|
+
|
|
194
|
+
**Fallback behavior:**
|
|
195
|
+
- For unsupported languages, Lien automatically falls back to line-based chunking
|
|
196
|
+
- No disruption to existing workflows
|
|
197
|
+
|
|
198
|
+
### Known Limitations
|
|
199
|
+
|
|
200
|
+
**Very large files (1000+ lines):**
|
|
201
|
+
- Tree-sitter may fail with "Invalid argument" error on extremely large files
|
|
202
|
+
- When this occurs, Lien automatically falls back to line-based chunking
|
|
203
|
+
- This is a known Tree-sitter limitation with very large syntax trees
|
|
204
|
+
- Fallback behavior is configurable via `astFallback` setting
|
|
205
|
+
|
|
206
|
+
**Resilient parsing:**
|
|
207
|
+
- Tree-sitter is designed to produce best-effort ASTs even for invalid syntax
|
|
208
|
+
- Parse errors are rare; most malformed code still produces usable chunks
|
|
209
|
+
- The `astFallback: 'error'` option mainly catches edge cases like large file errors
|
|
210
|
+
|
|
211
|
+
### Configuration
|
|
212
|
+
|
|
213
|
+
Control AST behavior in `.lien.config.json`:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"chunking": {
|
|
218
|
+
"useAST": true, // Enable AST-based chunking (default: true)
|
|
219
|
+
"astFallback": "line-based" // Fallback strategy: 'line-based' | 'error'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
117
226
|
## Input Validation & Error Handling
|
|
118
227
|
|
|
119
228
|
Lien uses Zod schemas for runtime type-safe validation of all tool inputs. This provides:
|