@liendev/lien 0.23.0 → 0.24.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/README.md +5 -8
- package/dist/index.js +41 -158
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/CURSOR_RULES_TEMPLATE.md +0 -157
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liendev/lien",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Local semantic code search for AI assistants via MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
|
18
18
|
"README.md",
|
|
19
|
-
"LICENSE"
|
|
20
|
-
"CURSOR_RULES_TEMPLATE.md"
|
|
19
|
+
"LICENSE"
|
|
21
20
|
],
|
|
22
21
|
"repository": {
|
|
23
22
|
"type": "git",
|
package/CURSOR_RULES_TEMPLATE.md
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: MANDATORY code search rules - use Lien MCP tools instead of grep
|
|
3
|
-
globs: ["**/*"]
|
|
4
|
-
alwaysApply: true
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# MANDATORY: Use Lien MCP for Code Search
|
|
8
|
-
|
|
9
|
-
You have access to Lien semantic search tools. USE THEM INSTEAD OF grep/ripgrep/built-in search.
|
|
10
|
-
|
|
11
|
-
## Tool Selection (FOLLOW THIS)
|
|
12
|
-
|
|
13
|
-
| User wants... | Use this | NOT this |
|
|
14
|
-
|---------------|----------|----------|
|
|
15
|
-
| "Where is X implemented?" | `semantic_search` | grep |
|
|
16
|
-
| "How does X work?" | `semantic_search` | reading random files |
|
|
17
|
-
| "Find all Controllers" | `list_functions` | grep |
|
|
18
|
-
| Edit a file | `get_files_context` FIRST | direct edit |
|
|
19
|
-
| Find similar code | `find_similar` | manual search |
|
|
20
|
-
| "What depends on this file?" | `get_dependents` | manual grep |
|
|
21
|
-
| "What's complex?" / "Tech debt?" | `get_complexity` | manual analysis |
|
|
22
|
-
|
|
23
|
-
## Before ANY Code Change
|
|
24
|
-
|
|
25
|
-
REQUIRED sequence:
|
|
26
|
-
1. `semantic_search` → find relevant files
|
|
27
|
-
2. `get_files_context` → understand the file + check `testAssociations`
|
|
28
|
-
3. Make changes
|
|
29
|
-
4. Remind user to run affected tests
|
|
30
|
-
|
|
31
|
-
## Tool Reference
|
|
32
|
-
|
|
33
|
-
**`semantic_search({ query: "what the code does", limit: 5 })`**
|
|
34
|
-
- Use natural language: "handles authentication", "validates email"
|
|
35
|
-
- NOT function names (use grep for exact names)
|
|
36
|
-
- Returns relevance category: `highly_relevant`, `relevant`, `loosely_related`, `not_relevant`
|
|
37
|
-
|
|
38
|
-
**`get_files_context({ filepaths: "path/to/file.ts" })`** or **`get_files_context({ filepaths: ["file1.ts", "file2.ts"] })`**
|
|
39
|
-
- MANDATORY before editing any file
|
|
40
|
-
- Returns `testAssociations`: which tests import/cover this file (reverse dependency lookup)
|
|
41
|
-
- Shows file dependencies and relationships
|
|
42
|
-
- Accepts single filepath or array of filepaths for batch operations
|
|
43
|
-
- Single file returns: `{ file: string, chunks: [], testAssociations: [] }`
|
|
44
|
-
- Multiple files returns: `{ files: { [path]: { chunks: [], testAssociations: [] } } }`
|
|
45
|
-
|
|
46
|
-
**`list_functions({ pattern: ".*Controller.*" })`**
|
|
47
|
-
- Fast symbol lookup by naming pattern
|
|
48
|
-
- Use for structural queries: "show all services", "find handlers"
|
|
49
|
-
- 10x faster than semantic_search for name-based lookups
|
|
50
|
-
|
|
51
|
-
**`find_similar({ code: "snippet to match" })`**
|
|
52
|
-
- Find similar implementations for consistency
|
|
53
|
-
- Use when refactoring or detecting duplication
|
|
54
|
-
|
|
55
|
-
**`get_dependents({ filepath: "path/to/file.ts", depth: 1 })`**
|
|
56
|
-
- Find all files that import/depend on a target file
|
|
57
|
-
- Use for impact analysis: "What breaks if I change this?"
|
|
58
|
-
- Returns risk level (low/medium/high/critical) based on:
|
|
59
|
-
- Dependency count (how many files import it)
|
|
60
|
-
- Complexity metrics (how complex the dependent code is)
|
|
61
|
-
- Highlights top 5 most complex dependents when complexity data available
|
|
62
|
-
|
|
63
|
-
**`get_complexity({ top: 10 })`**
|
|
64
|
-
- Find most complex functions in the codebase
|
|
65
|
-
- Analyzes multiple complexity metrics:
|
|
66
|
-
- **Test paths**: Number of test cases needed for full coverage (cyclomatic)
|
|
67
|
-
- **Mental load**: How hard to follow - penalizes nesting (cognitive)
|
|
68
|
-
- **Time to understand**: Estimated reading time (Halstead effort)
|
|
69
|
-
- **Estimated bugs**: Predicted bug count (Halstead volume / 3000)
|
|
70
|
-
- Use for tech debt analysis and refactoring prioritization
|
|
71
|
-
- Returns `metricType` ('cyclomatic', 'cognitive', 'halstead_effort', or 'halstead_bugs')
|
|
72
|
-
- Human-readable output: "23 (needs ~23 tests)", "🧠 45", "~2h 30m", "2.27 bugs"
|
|
73
|
-
- Optional: `files` to filter specific files, `threshold` to set minimum complexity
|
|
74
|
-
|
|
75
|
-
## Test Associations
|
|
76
|
-
|
|
77
|
-
`get_files_context` returns `testAssociations` showing which tests import/cover the file.
|
|
78
|
-
- Uses reverse dependency lookup to find test files that import the source file
|
|
79
|
-
- Returns array of test file paths for each requested file
|
|
80
|
-
- ALWAYS check this before modifying source code
|
|
81
|
-
- After changes, remind the user: "This file is covered by [test files] - run these to verify."
|
|
82
|
-
|
|
83
|
-
Example:
|
|
84
|
-
```typescript
|
|
85
|
-
get_files_context({ filepaths: "src/auth.ts" })
|
|
86
|
-
// Returns: { file: "src/auth.ts", chunks: [...], testAssociations: ["src/__tests__/auth.test.ts"] }
|
|
87
|
-
|
|
88
|
-
get_files_context({ filepaths: ["src/auth.ts", "src/user.ts"] })
|
|
89
|
-
// Returns: { files: { "src/auth.ts": { chunks: [...], testAssociations: [...] }, ... } }
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Workflow Patterns
|
|
93
|
-
|
|
94
|
-
### Pattern 1: "Where is X?" / "How does X work?"
|
|
95
|
-
```
|
|
96
|
-
1. semantic_search({ query: "X implementation" })
|
|
97
|
-
2. Review results (check relevance scores)
|
|
98
|
-
3. get_files_context({ filepaths: "identified/file.ts" })
|
|
99
|
-
4. Answer with specific code locations
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Pattern 2: Edit or Change Code
|
|
103
|
-
```
|
|
104
|
-
1. semantic_search({ query: "area being modified" })
|
|
105
|
-
2. get_files_context({ filepaths: "target/file.ts" })
|
|
106
|
-
3. Check testAssociations in response
|
|
107
|
-
4. Make changes
|
|
108
|
-
5. Tell user which tests to run
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Pattern 3: Impact Analysis Before Refactoring
|
|
112
|
-
```
|
|
113
|
-
1. get_dependents({ filepath: "target/file.ts" })
|
|
114
|
-
2. Review risk level and dependent count
|
|
115
|
-
3. Check highComplexityDependents (if any)
|
|
116
|
-
4. Use get_files_context on high-risk dependents
|
|
117
|
-
5. Plan refactoring strategy based on impact
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Query Construction
|
|
121
|
-
|
|
122
|
-
### Good Queries (DO THIS)
|
|
123
|
-
- "handles user authentication"
|
|
124
|
-
- "validates email addresses"
|
|
125
|
-
- "processes payment transactions"
|
|
126
|
-
- "React components with form state"
|
|
127
|
-
- "API endpoints for user data"
|
|
128
|
-
|
|
129
|
-
### Bad Queries (DON'T DO THIS)
|
|
130
|
-
- "auth" (too vague)
|
|
131
|
-
- "validateEmail" (use grep for exact names)
|
|
132
|
-
- "code" (way too generic)
|
|
133
|
-
|
|
134
|
-
**Formula:** `[action verb] + [domain object] + [optional context]`
|
|
135
|
-
|
|
136
|
-
## AST Metadata
|
|
137
|
-
|
|
138
|
-
Results include rich metadata: `symbolName`, `symbolType`, `complexity`, `cognitiveComplexity`, `halsteadVolume`, `halsteadDifficulty`, `halsteadEffort`, `halsteadBugs`, `parameters`, `signature`.
|
|
139
|
-
|
|
140
|
-
Use for filtering:
|
|
141
|
-
- Complex functions (cyclomatic): `results.filter(r => r.metadata.complexity > 10)`
|
|
142
|
-
- Complex functions (cognitive): `results.filter(r => r.metadata.cognitiveComplexity > 15)`
|
|
143
|
-
- Long to understand (>1 hour): `results.filter(r => r.metadata.halsteadEffort > 64800)`
|
|
144
|
-
- Methods only: `results.filter(r => r.metadata.symbolType === 'method')`
|
|
145
|
-
|
|
146
|
-
## When to Use grep Instead
|
|
147
|
-
|
|
148
|
-
ONLY use grep/ripgrep when:
|
|
149
|
-
- User provides an exact string/function name to find
|
|
150
|
-
- Looking for specific imports or string literals
|
|
151
|
-
- Semantic search returned no results
|
|
152
|
-
|
|
153
|
-
For everything else: **Lien first.**
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
REMINDER: semantic_search and get_files_context FIRST. grep is the fallback, not the default.
|