@liendev/lien 0.15.1 → 0.17.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 +42 -10
- package/dist/index.js +972 -365
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CURSOR_RULES_TEMPLATE.md
CHANGED
|
@@ -15,14 +15,15 @@ You have access to Lien semantic search tools. USE THEM INSTEAD OF grep/ripgrep/
|
|
|
15
15
|
| "Where is X implemented?" | `semantic_search` | grep |
|
|
16
16
|
| "How does X work?" | `semantic_search` | reading random files |
|
|
17
17
|
| "Find all Controllers" | `list_functions` | grep |
|
|
18
|
-
| Edit a file | `
|
|
18
|
+
| Edit a file | `get_files_context` FIRST | direct edit |
|
|
19
19
|
| Find similar code | `find_similar` | manual search |
|
|
20
|
+
| "What depends on this file?" | `get_dependents` | manual grep |
|
|
20
21
|
|
|
21
22
|
## Before ANY Code Change
|
|
22
23
|
|
|
23
24
|
REQUIRED sequence:
|
|
24
25
|
1. `semantic_search` → find relevant files
|
|
25
|
-
2. `
|
|
26
|
+
2. `get_files_context` → understand the file + check `testAssociations`
|
|
26
27
|
3. Make changes
|
|
27
28
|
4. Remind user to run affected tests
|
|
28
29
|
|
|
@@ -33,10 +34,13 @@ REQUIRED sequence:
|
|
|
33
34
|
- NOT function names (use grep for exact names)
|
|
34
35
|
- Returns relevance category: `highly_relevant`, `relevant`, `loosely_related`, `not_relevant`
|
|
35
36
|
|
|
36
|
-
**`
|
|
37
|
+
**`get_files_context({ filepaths: "path/to/file.ts" })`** or **`get_files_context({ filepaths: ["file1.ts", "file2.ts"] })`**
|
|
37
38
|
- MANDATORY before editing any file
|
|
38
|
-
- Returns `testAssociations`: which tests cover this file
|
|
39
|
+
- Returns `testAssociations`: which tests import/cover this file (reverse dependency lookup)
|
|
39
40
|
- Shows file dependencies and relationships
|
|
41
|
+
- Accepts single filepath or array of filepaths for batch operations
|
|
42
|
+
- Single file returns: `{ file: string, chunks: [], testAssociations: [] }`
|
|
43
|
+
- Multiple files returns: `{ files: { [path]: { chunks: [], testAssociations: [] } } }`
|
|
40
44
|
|
|
41
45
|
**`list_functions({ pattern: ".*Controller.*" })`**
|
|
42
46
|
- Fast symbol lookup by naming pattern
|
|
@@ -47,11 +51,30 @@ REQUIRED sequence:
|
|
|
47
51
|
- Find similar implementations for consistency
|
|
48
52
|
- Use when refactoring or detecting duplication
|
|
49
53
|
|
|
54
|
+
**`get_dependents({ filepath: "path/to/file.ts", depth: 1 })`**
|
|
55
|
+
- Find all files that import/depend on a target file
|
|
56
|
+
- Use for impact analysis: "What breaks if I change this?"
|
|
57
|
+
- Returns risk level (low/medium/high/critical) based on:
|
|
58
|
+
- Dependency count (how many files import it)
|
|
59
|
+
- Complexity metrics (how complex the dependent code is)
|
|
60
|
+
- Highlights top 5 most complex dependents when complexity data available
|
|
61
|
+
|
|
50
62
|
## Test Associations
|
|
51
63
|
|
|
52
|
-
`
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
`get_files_context` returns `testAssociations` showing which tests import/cover the file.
|
|
65
|
+
- Uses reverse dependency lookup to find test files that import the source file
|
|
66
|
+
- Returns array of test file paths for each requested file
|
|
67
|
+
- ALWAYS check this before modifying source code
|
|
68
|
+
- After changes, remind the user: "This file is covered by [test files] - run these to verify."
|
|
69
|
+
|
|
70
|
+
Example:
|
|
71
|
+
```typescript
|
|
72
|
+
get_files_context({ filepaths: "src/auth.ts" })
|
|
73
|
+
// Returns: { file: "src/auth.ts", chunks: [...], testAssociations: ["src/__tests__/auth.test.ts"] }
|
|
74
|
+
|
|
75
|
+
get_files_context({ filepaths: ["src/auth.ts", "src/user.ts"] })
|
|
76
|
+
// Returns: { files: { "src/auth.ts": { chunks: [...], testAssociations: [...] }, ... } }
|
|
77
|
+
```
|
|
55
78
|
|
|
56
79
|
## Workflow Patterns
|
|
57
80
|
|
|
@@ -59,19 +82,28 @@ After changes, remind the user: "This file is covered by [test files] - run thes
|
|
|
59
82
|
```
|
|
60
83
|
1. semantic_search({ query: "X implementation" })
|
|
61
84
|
2. Review results (check relevance scores)
|
|
62
|
-
3.
|
|
85
|
+
3. get_files_context({ filepaths: "identified/file.ts" })
|
|
63
86
|
4. Answer with specific code locations
|
|
64
87
|
```
|
|
65
88
|
|
|
66
89
|
### Pattern 2: Edit or Change Code
|
|
67
90
|
```
|
|
68
91
|
1. semantic_search({ query: "area being modified" })
|
|
69
|
-
2.
|
|
92
|
+
2. get_files_context({ filepaths: "target/file.ts" })
|
|
70
93
|
3. Check testAssociations in response
|
|
71
94
|
4. Make changes
|
|
72
95
|
5. Tell user which tests to run
|
|
73
96
|
```
|
|
74
97
|
|
|
98
|
+
### Pattern 3: Impact Analysis Before Refactoring
|
|
99
|
+
```
|
|
100
|
+
1. get_dependents({ filepath: "target/file.ts" })
|
|
101
|
+
2. Review risk level and dependent count
|
|
102
|
+
3. Check highComplexityDependents (if any)
|
|
103
|
+
4. Use get_files_context on high-risk dependents
|
|
104
|
+
5. Plan refactoring strategy based on impact
|
|
105
|
+
```
|
|
106
|
+
|
|
75
107
|
## Query Construction
|
|
76
108
|
|
|
77
109
|
### Good Queries (DO THIS)
|
|
@@ -107,4 +139,4 @@ For everything else: **Lien first.**
|
|
|
107
139
|
|
|
108
140
|
---
|
|
109
141
|
|
|
110
|
-
REMINDER: semantic_search and
|
|
142
|
+
REMINDER: semantic_search and get_files_context FIRST. grep is the fallback, not the default.
|