octocode-cli 1.1.1 → 1.2.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/out/octocode-cli.js +7906 -8034
- package/package.json +36 -39
- package/skills/README.md +70 -31
- package/skills/octocode-generate/SKILL.md +15 -9
- package/skills/octocode-implement/SKILL.md +288 -0
- package/skills/octocode-implement/references/execution-phases.md +317 -0
- package/skills/octocode-implement/references/tool-reference.md +403 -0
- package/skills/octocode-implement/references/workflow-patterns.md +385 -0
- package/skills/octocode-local-search/SKILL.md +418 -0
- package/skills/octocode-local-search/references/tool-reference.md +328 -0
- package/skills/octocode-local-search/references/workflow-patterns.md +383 -0
- package/skills/octocode-pr-review/SKILL.md +321 -109
- package/skills/octocode-pr-review/references/domain-reviewers.md +105 -0
- package/skills/octocode-pr-review/references/execution-lifecycle.md +116 -0
- package/skills/octocode-pr-review/references/research-flows.md +75 -0
- package/skills/octocode-research/SKILL.md +291 -80
- package/skills/octocode-roast/SKILL.md +369 -0
- package/skills/octocode-roast/references/sin-registry.md +239 -0
- package/skills/octocode-plan/SKILL.md +0 -166
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
# Local Tools Reference
|
|
2
|
+
|
|
3
|
+
Complete parameter reference for Octocode Local tools.
|
|
4
|
+
|
|
5
|
+
**Required Fields (ALL queries)**: `mainResearchGoal`, `researchGoal`, `reasoning`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## localViewStructure
|
|
10
|
+
|
|
11
|
+
Explore local directory structure with filtering and sorting.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
{
|
|
15
|
+
path: string; // Directory path (required)
|
|
16
|
+
depth?: number; // 1-5 (default 1)
|
|
17
|
+
entriesPerPage?: number; // ≤20
|
|
18
|
+
entryPageNumber?: number; // Pagination
|
|
19
|
+
details?: boolean; // Show file sizes
|
|
20
|
+
hidden?: boolean; // Include dotfiles
|
|
21
|
+
extensions?: string[]; // Filter by extension
|
|
22
|
+
pattern?: string; // Filter by name pattern
|
|
23
|
+
filesOnly?: boolean;
|
|
24
|
+
directoriesOnly?: boolean;
|
|
25
|
+
sortBy?: "name" | "size" | "time" | "extension";
|
|
26
|
+
summary?: boolean; // Include summary stats
|
|
27
|
+
showFileLastModified?: boolean; // Show modification times
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Tips:**
|
|
32
|
+
- Start `depth: 1` at root, drill with `depth: 2` on specific dirs
|
|
33
|
+
- Use `details: true` to see file sizes
|
|
34
|
+
- Check `packages/` or `apps/` for monorepos
|
|
35
|
+
- Use `sortBy: "time"` to find recently modified
|
|
36
|
+
|
|
37
|
+
**Example Queries:**
|
|
38
|
+
```json
|
|
39
|
+
// Map root structure
|
|
40
|
+
{ "path": "", "depth": 1, "summary": true }
|
|
41
|
+
|
|
42
|
+
// Drill into src with file details
|
|
43
|
+
{ "path": "src", "depth": 2, "details": true }
|
|
44
|
+
|
|
45
|
+
// Find TypeScript files only
|
|
46
|
+
{ "path": "src", "extensions": ["ts", "tsx"], "filesOnly": true }
|
|
47
|
+
|
|
48
|
+
// Show recently modified
|
|
49
|
+
{ "path": "", "sortBy": "time", "showFileLastModified": true }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## localSearchCode
|
|
55
|
+
|
|
56
|
+
Fast pattern search with discovery mode and pagination.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
{
|
|
60
|
+
pattern: string; // Search pattern (required)
|
|
61
|
+
path: string; // Search root (required)
|
|
62
|
+
filesOnly?: boolean; // Discovery mode - just list files
|
|
63
|
+
type?: string; // "ts", "py", "js" etc
|
|
64
|
+
include?: string[]; // Glob patterns to include
|
|
65
|
+
exclude?: string[]; // Glob patterns to exclude
|
|
66
|
+
excludeDir?: string[]; // Directories to skip
|
|
67
|
+
noIgnore?: boolean; // Search inside node_modules
|
|
68
|
+
matchesPerPage?: number; // 1-100
|
|
69
|
+
filesPerPage?: number; // ≤20
|
|
70
|
+
filePageNumber?: number; // Pagination
|
|
71
|
+
contextLines?: number; // Lines around match
|
|
72
|
+
caseSensitive?: boolean;
|
|
73
|
+
caseInsensitive?: boolean;
|
|
74
|
+
smartCase?: boolean; // Default: true (case-sensitive if pattern has uppercase)
|
|
75
|
+
wholeWord?: boolean;
|
|
76
|
+
multiline?: boolean;
|
|
77
|
+
fixedString?: boolean; // Treat pattern as literal string
|
|
78
|
+
mode?: "discovery" | "paginated" | "detailed";
|
|
79
|
+
matchContentLength?: number; // Max chars per match (default 200)
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Tips:**
|
|
84
|
+
- **Start with `filesOnly: true`** for discovery (fast, token-efficient)
|
|
85
|
+
- Use `noIgnore: true` to search inside `node_modules`
|
|
86
|
+
- Use `type` for common file extensions
|
|
87
|
+
- Returns `location.charOffset/charLength` as BYTE offsets (ripgrep)
|
|
88
|
+
- Use `fixedString: true` for special characters in pattern
|
|
89
|
+
|
|
90
|
+
**Discovery vs Content Search:**
|
|
91
|
+
```json
|
|
92
|
+
// Discovery mode - find files containing pattern (fast)
|
|
93
|
+
{ "pattern": "AuthService", "path": "src", "filesOnly": true }
|
|
94
|
+
|
|
95
|
+
// Content search - get match context
|
|
96
|
+
{ "pattern": "AuthService", "path": "src", "contextLines": 3 }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**node_modules Inspection:**
|
|
100
|
+
```json
|
|
101
|
+
// Search inside React
|
|
102
|
+
{ "pattern": "createContext", "path": "node_modules/react", "noIgnore": true }
|
|
103
|
+
|
|
104
|
+
// Search specific dependency
|
|
105
|
+
{ "pattern": "Router", "path": "node_modules/react-router", "noIgnore": true, "filesOnly": true }
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Filtering Examples:**
|
|
109
|
+
```json
|
|
110
|
+
// TypeScript files only
|
|
111
|
+
{ "pattern": "export", "path": "src", "type": "ts" }
|
|
112
|
+
|
|
113
|
+
// Exclude test files
|
|
114
|
+
{ "pattern": "fetchData", "path": "src", "exclude": ["*.test.ts", "*.spec.ts"] }
|
|
115
|
+
|
|
116
|
+
// Exclude directories
|
|
117
|
+
{ "pattern": "config", "path": "", "excludeDir": ["node_modules", "dist", "coverage"] }
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## localGetFileContent
|
|
123
|
+
|
|
124
|
+
Read local file content with targeted extraction.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
{
|
|
128
|
+
path: string; // File path (required)
|
|
129
|
+
|
|
130
|
+
// Choose ONE strategy:
|
|
131
|
+
matchString?: string; // Pattern to find
|
|
132
|
+
matchStringContextLines?: number; // 1-50 lines of context
|
|
133
|
+
matchStringIsRegex?: boolean;
|
|
134
|
+
matchStringCaseSensitive?: boolean;
|
|
135
|
+
|
|
136
|
+
charOffset?: number; // BYTE offset for pagination
|
|
137
|
+
charLength?: number; // BYTES to read (1000-4000 recommended)
|
|
138
|
+
|
|
139
|
+
startLine?: number; // Line range
|
|
140
|
+
endLine?: number;
|
|
141
|
+
|
|
142
|
+
fullContent?: boolean; // Small files only (<10KB)
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Tips:**
|
|
147
|
+
- **Prefer `matchString` over `fullContent`** for token efficiency
|
|
148
|
+
- `charOffset`/`charLength` are BYTES, not characters
|
|
149
|
+
- Use `charLength: 2000-4000` for pagination windows
|
|
150
|
+
- Large files require `charLength` or `matchString`
|
|
151
|
+
|
|
152
|
+
**Strategy Selection:**
|
|
153
|
+
| Scenario | Strategy | Example |
|
|
154
|
+
|----------|----------|---------|
|
|
155
|
+
| Know function name | `matchString` | `{ matchString: "export function useAuth", matchStringContextLines: 20 }` |
|
|
156
|
+
| Know exact lines | `startLine/endLine` | `{ startLine: 1, endLine: 50 }` |
|
|
157
|
+
| Small config files | `fullContent` | `{ fullContent: true }` |
|
|
158
|
+
| Large file pagination | `charLength/charOffset` | `{ charLength: 3000, charOffset: 0 }` |
|
|
159
|
+
|
|
160
|
+
**Example Queries:**
|
|
161
|
+
```json
|
|
162
|
+
// Find function with context
|
|
163
|
+
{ "path": "src/auth/useAuth.ts", "matchString": "export function useAuth", "matchStringContextLines": 25 }
|
|
164
|
+
|
|
165
|
+
// Read first 50 lines
|
|
166
|
+
{ "path": "src/index.ts", "startLine": 1, "endLine": 50 }
|
|
167
|
+
|
|
168
|
+
// Read small config
|
|
169
|
+
{ "path": "package.json", "fullContent": true }
|
|
170
|
+
|
|
171
|
+
// Paginate large file (first window)
|
|
172
|
+
{ "path": "dist/bundle.js", "charLength": 4000, "charOffset": 0 }
|
|
173
|
+
|
|
174
|
+
// Paginate large file (next window)
|
|
175
|
+
{ "path": "dist/bundle.js", "charLength": 4000, "charOffset": 4000 }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## localFindFiles
|
|
181
|
+
|
|
182
|
+
Find files by metadata (name, time, size, permissions).
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
{
|
|
186
|
+
path: string; // Search root (required)
|
|
187
|
+
name?: string; // "*.ts" pattern
|
|
188
|
+
iname?: string; // Case-insensitive name
|
|
189
|
+
names?: string[]; // Multiple patterns
|
|
190
|
+
type?: "f" | "d" | "l"; // file/directory/link
|
|
191
|
+
modifiedWithin?: string; // "7d", "2h", "30m"
|
|
192
|
+
modifiedBefore?: string;
|
|
193
|
+
accessedWithin?: string;
|
|
194
|
+
sizeGreater?: string; // "10M", "1K"
|
|
195
|
+
sizeLess?: string;
|
|
196
|
+
excludeDir?: string[];
|
|
197
|
+
maxDepth?: number; // 1-10
|
|
198
|
+
minDepth?: number; // 0-10
|
|
199
|
+
filesPerPage?: number; // ≤20
|
|
200
|
+
filePageNumber?: number;
|
|
201
|
+
details?: boolean; // Show file metadata
|
|
202
|
+
showFileLastModified?: boolean; // Default: true
|
|
203
|
+
pathPattern?: string; // Path pattern match
|
|
204
|
+
regex?: string; // Regex file name match
|
|
205
|
+
empty?: boolean; // Find empty files
|
|
206
|
+
executable?: boolean; // Find executable files
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Tips:**
|
|
211
|
+
- Results sorted by modified time (most recent first)
|
|
212
|
+
- Use `modifiedWithin: "7d"` to find recent changes
|
|
213
|
+
- Combine with `localGetFileContent` or `localSearchCode` for content
|
|
214
|
+
- Time suffixes: `d` (days), `h` (hours), `m` (minutes)
|
|
215
|
+
- Size suffixes: `K` (kilobytes), `M` (megabytes), `G` (gigabytes)
|
|
216
|
+
|
|
217
|
+
**Example Queries:**
|
|
218
|
+
```json
|
|
219
|
+
// Recent TypeScript changes
|
|
220
|
+
{ "path": "src", "name": "*.ts", "modifiedWithin": "7d" }
|
|
221
|
+
|
|
222
|
+
// Large files needing attention
|
|
223
|
+
{ "path": "", "sizeGreater": "100K", "type": "f" }
|
|
224
|
+
|
|
225
|
+
// Config files
|
|
226
|
+
{ "path": "", "names": ["*.json", "*.yaml", "*.yml"], "maxDepth": 2 }
|
|
227
|
+
|
|
228
|
+
// Empty files (potential issues)
|
|
229
|
+
{ "path": "src", "empty": true, "type": "f" }
|
|
230
|
+
|
|
231
|
+
// Recently accessed
|
|
232
|
+
{ "path": "src", "accessedWithin": "1d" }
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Query Batching
|
|
238
|
+
|
|
239
|
+
Parallelize independent searches (max 5 queries per call):
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"queries": [
|
|
244
|
+
{ "pattern": "AuthService", "path": "src", "filesOnly": true },
|
|
245
|
+
{ "pattern": "authMiddleware", "path": "src", "filesOnly": true },
|
|
246
|
+
{ "pattern": "AuthUser", "path": "src", "filesOnly": true },
|
|
247
|
+
{ "pattern": "useAuth", "path": "src", "filesOnly": true },
|
|
248
|
+
{ "pattern": "authContext", "path": "src", "filesOnly": true }
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Benefits:**
|
|
254
|
+
- Single network round-trip
|
|
255
|
+
- Parallel execution
|
|
256
|
+
- Combined results with hints
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Error Recovery
|
|
261
|
+
|
|
262
|
+
| Situation | Action |
|
|
263
|
+
|-----------|--------|
|
|
264
|
+
| Empty results | Try semantic variants (auth → login, security, credentials) |
|
|
265
|
+
| Too many results | Add filters (path, type, include, excludeDir) |
|
|
266
|
+
| File too large | Use `matchString` or `charLength` pagination |
|
|
267
|
+
| Path not found | Verify with `localViewStructure` first |
|
|
268
|
+
| Path is directory | Use `localViewStructure` instead |
|
|
269
|
+
| .gitignore blocking | Use `noIgnore: true` (for node_modules) |
|
|
270
|
+
| Special chars in pattern | Use `fixedString: true` |
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Common Patterns
|
|
275
|
+
|
|
276
|
+
### 1. Discovery → Read Pattern
|
|
277
|
+
```json
|
|
278
|
+
// Step 1: Find files
|
|
279
|
+
{ "pattern": "useAuth", "path": "src", "filesOnly": true }
|
|
280
|
+
|
|
281
|
+
// Step 2: Read implementation (from step 1 results)
|
|
282
|
+
{ "path": "src/hooks/useAuth.ts", "matchString": "export function useAuth", "matchStringContextLines": 20 }
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 2. Trace Imports Pattern
|
|
286
|
+
```json
|
|
287
|
+
// Step 1: Find import
|
|
288
|
+
{ "pattern": "import.*from 'axios'", "path": "src", "filesOnly": true }
|
|
289
|
+
|
|
290
|
+
// Step 2: Check node_modules
|
|
291
|
+
{ "pattern": "export default axios", "path": "node_modules/axios/lib", "noIgnore": true }
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### 3. Recent Changes Pattern
|
|
295
|
+
```json
|
|
296
|
+
// Step 1: Find recent files
|
|
297
|
+
{ "path": "src", "name": "*.ts", "modifiedWithin": "3d" }
|
|
298
|
+
|
|
299
|
+
// Step 2: Search within those files
|
|
300
|
+
{ "pattern": "TODO|FIXME", "path": "src/auth", "contextLines": 2 }
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### 4. Large File Pagination
|
|
304
|
+
```json
|
|
305
|
+
// Window 1
|
|
306
|
+
{ "path": "dist/bundle.js", "charLength": 4000, "charOffset": 0 }
|
|
307
|
+
|
|
308
|
+
// Window 2
|
|
309
|
+
{ "path": "dist/bundle.js", "charLength": 4000, "charOffset": 4000 }
|
|
310
|
+
|
|
311
|
+
// Window 3
|
|
312
|
+
{ "path": "dist/bundle.js", "charLength": 4000, "charOffset": 8000 }
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Anti-Patterns
|
|
318
|
+
|
|
319
|
+
| Bad | Good |
|
|
320
|
+
|-----|------|
|
|
321
|
+
| `fullContent: true` on large files | `matchString` or `charLength` |
|
|
322
|
+
| Shell `grep` command | `localSearchCode` |
|
|
323
|
+
| Shell `find` command | `localFindFiles` |
|
|
324
|
+
| Shell `cat` command | `localGetFileContent` |
|
|
325
|
+
| Reading entire codebase | Targeted discovery then content |
|
|
326
|
+
| Ignoring hints | Follow hints for next steps |
|
|
327
|
+
| Hard-coded paths | Verify with `localViewStructure` |
|
|
328
|
+
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
# Workflow Patterns
|
|
2
|
+
|
|
3
|
+
Common research flows for local code exploration.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Pattern 1: Explore-First (Unknown Codebase)
|
|
8
|
+
|
|
9
|
+
**Use when**: Entry points unclear, mixed tech, new repo.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
localViewStructure(depth=1) → drill dirs(depth=2) → localSearchCode → localGetFileContent
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Steps:**
|
|
16
|
+
1. **Map Root**: View top-level folders (`depth: 1`)
|
|
17
|
+
2. **Identify Key Dirs**: Look for `src/`, `lib/`, `packages/`, `apps/`
|
|
18
|
+
3. **Drill Down**: Pick one relevant folder
|
|
19
|
+
4. **Search**: Look for architectural keywords (`App`, `Server`, `Main`, `index`)
|
|
20
|
+
5. **Read**: Get content of entry file
|
|
21
|
+
|
|
22
|
+
**Example Flow:**
|
|
23
|
+
```json
|
|
24
|
+
// 1. Map root
|
|
25
|
+
{ "path": "", "depth": 1, "summary": true }
|
|
26
|
+
|
|
27
|
+
// 2. Drill into src
|
|
28
|
+
{ "path": "src", "depth": 2, "details": true }
|
|
29
|
+
|
|
30
|
+
// 3. Find entry points
|
|
31
|
+
{ "pattern": "createServer|createApp|main", "path": "src", "filesOnly": true }
|
|
32
|
+
|
|
33
|
+
// 4. Read implementation
|
|
34
|
+
{ "path": "src/index.ts", "matchString": "createApp", "matchStringContextLines": 20 }
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Pitfall**: Diving deep without map → keep breadth-first initially.
|
|
38
|
+
|
|
39
|
+
**Success Criteria**: Understand entry point and high-level architecture.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Pattern 2: Search-First (Know WHAT, not WHERE)
|
|
44
|
+
|
|
45
|
+
**Use when**: Feature name, error keyword, class/function known.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
localSearchCode(filesOnly=true) → localGetFileContent(matchString)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Steps:**
|
|
52
|
+
1. **Discovery**: Find files containing the term (fast)
|
|
53
|
+
2. **Target**: Pick the most likely file from results
|
|
54
|
+
3. **Read**: Read specific function with context
|
|
55
|
+
|
|
56
|
+
**Example Flow:**
|
|
57
|
+
```json
|
|
58
|
+
// 1. Discovery
|
|
59
|
+
{ "pattern": "AuthService", "path": "src", "type": "ts", "filesOnly": true }
|
|
60
|
+
|
|
61
|
+
// 2. Read implementation
|
|
62
|
+
{ "path": "src/auth/AuthService.ts", "matchString": "class AuthService", "matchStringContextLines": 30 }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Pitfall**: Reading full files → prefer `matchString` + small context windows.
|
|
66
|
+
|
|
67
|
+
**Success Criteria**: Found the implementation with enough context.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Pattern 3: Trace-from-Match (Follow the Trail)
|
|
72
|
+
|
|
73
|
+
**Use when**: Found definition, need impact graph (imports/usages).
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
localSearchCode(symbol) → localGetFileContent → localSearchCode(usages) → iterate
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Steps:**
|
|
80
|
+
1. **Find Definition**: Search for the symbol
|
|
81
|
+
2. **Read Implementation**: Get context around definition
|
|
82
|
+
3. **Trace Usages**: Search for imports/calls
|
|
83
|
+
4. **Iterate**: Follow 1-3 focused branches (cap depth to avoid explosion)
|
|
84
|
+
|
|
85
|
+
**Example Flow:**
|
|
86
|
+
```json
|
|
87
|
+
// 1. Find definition
|
|
88
|
+
{ "pattern": "export.*useAuth", "path": "src", "filesOnly": true }
|
|
89
|
+
|
|
90
|
+
// 2. Read implementation
|
|
91
|
+
{ "path": "src/hooks/useAuth.ts", "matchString": "export function useAuth", "matchStringContextLines": 25 }
|
|
92
|
+
|
|
93
|
+
// 3. Find usages
|
|
94
|
+
{ "pattern": "import.*useAuth|useAuth\\(", "path": "src", "filesOnly": true }
|
|
95
|
+
|
|
96
|
+
// 4. Read key usage
|
|
97
|
+
{ "path": "src/components/Header.tsx", "matchString": "useAuth", "matchStringContextLines": 15 }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Pitfall**: Unlimited fan-out → cap depth (3 levels) and batch size (5 files).
|
|
101
|
+
|
|
102
|
+
**Success Criteria**: Understand definition + 2-3 key usages.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Pattern 4: Metadata Sweep (Recent Changes)
|
|
107
|
+
|
|
108
|
+
**Use when**: Debugging recent breaks, reviewing recent areas, finding hot paths.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
localFindFiles(modifiedWithin/size) → localSearchCode → localGetFileContent
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Steps:**
|
|
115
|
+
1. **Filter**: Find files by metadata (time, size, type)
|
|
116
|
+
2. **Narrow**: Search within filtered results
|
|
117
|
+
3. **Read**: Examine content of candidates
|
|
118
|
+
|
|
119
|
+
**Example Flow:**
|
|
120
|
+
```json
|
|
121
|
+
// 1. Find recently modified TypeScript files
|
|
122
|
+
{ "path": "src", "name": "*.ts", "modifiedWithin": "7d" }
|
|
123
|
+
|
|
124
|
+
// 2. Search for specific pattern in those areas
|
|
125
|
+
{ "pattern": "TODO|FIXME|HACK", "path": "src/auth", "contextLines": 2 }
|
|
126
|
+
|
|
127
|
+
// 3. Read suspicious file
|
|
128
|
+
{ "path": "src/auth/session.ts", "matchString": "HACK", "matchStringContextLines": 10 }
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Variations:**
|
|
132
|
+
```json
|
|
133
|
+
// Find large files that might need attention
|
|
134
|
+
{ "path": "", "sizeGreater": "100K", "type": "f" }
|
|
135
|
+
|
|
136
|
+
// Find config files at root
|
|
137
|
+
{ "path": "", "names": ["*.json", "*.yaml", "*.config.*"], "maxDepth": 1 }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Pitfall**: Stopping at file names → always validate with content.
|
|
141
|
+
|
|
142
|
+
**Success Criteria**: Identified recent changes and their context.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Pattern 5: Large File Inspection
|
|
147
|
+
|
|
148
|
+
**Use when**: Bundles, generated artifacts, vendor code, migrations.
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
localGetFileContent(charLength windows) → paginate with charOffset
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Steps:**
|
|
155
|
+
1. **First Window**: Read initial chunk with `charLength`
|
|
156
|
+
2. **Paginate**: Use `charOffset` to step through
|
|
157
|
+
3. **Target**: Once you find relevant section, use `matchString`
|
|
158
|
+
|
|
159
|
+
**Example Flow:**
|
|
160
|
+
```json
|
|
161
|
+
// 1. First window (bytes 0-4000)
|
|
162
|
+
{ "path": "dist/bundle.js", "charLength": 4000, "charOffset": 0 }
|
|
163
|
+
|
|
164
|
+
// 2. Second window (bytes 4000-8000)
|
|
165
|
+
{ "path": "dist/bundle.js", "charLength": 4000, "charOffset": 4000 }
|
|
166
|
+
|
|
167
|
+
// 3. Once you find area of interest, use matchString
|
|
168
|
+
{ "path": "dist/bundle.js", "matchString": "createRouter", "matchStringContextLines": 10 }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Pitfall**: Forgetting byte-offset semantics → `charOffset`/`charLength` are BYTES not chars.
|
|
172
|
+
|
|
173
|
+
**Success Criteria**: Found and extracted relevant section from large file.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Pattern 6: node_modules Inspection
|
|
178
|
+
|
|
179
|
+
**Use when**: Debugging dependency behavior, understanding library internals, finding undocumented APIs.
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
localSearchCode(noIgnore=true) → localGetFileContent → localViewStructure
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Steps:**
|
|
186
|
+
1. **Search Inside**: Use `noIgnore: true` to search node_modules
|
|
187
|
+
2. **Map Structure**: Understand library layout
|
|
188
|
+
3. **Read Source**: Get implementation details
|
|
189
|
+
|
|
190
|
+
**Example Flow:**
|
|
191
|
+
```json
|
|
192
|
+
// 1. Search inside dependency
|
|
193
|
+
{ "pattern": "createContext", "path": "node_modules/react", "noIgnore": true, "filesOnly": true }
|
|
194
|
+
|
|
195
|
+
// 2. View library structure
|
|
196
|
+
{ "path": "node_modules/react", "depth": 2, "noIgnore": true }
|
|
197
|
+
|
|
198
|
+
// 3. Read implementation
|
|
199
|
+
{ "path": "node_modules/react/cjs/react.development.js", "matchString": "createContext", "matchStringContextLines": 30 }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Variations:**
|
|
203
|
+
```json
|
|
204
|
+
// Explore express middleware
|
|
205
|
+
{ "pattern": "middleware", "path": "node_modules/express/lib", "noIgnore": true }
|
|
206
|
+
|
|
207
|
+
// Find axios internals
|
|
208
|
+
{ "path": "node_modules/axios/lib", "depth": 2 }
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Pitfall**: Only reading installed version → compare with GitHub source for canonical behavior.
|
|
212
|
+
|
|
213
|
+
**Success Criteria**: Understand how dependency works internally.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Pattern 7: Config Investigation
|
|
218
|
+
|
|
219
|
+
**Use when**: Understanding project configuration, build setup, environment.
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
localFindFiles(config patterns) → localGetFileContent(fullContent)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Steps:**
|
|
226
|
+
1. **Find Configs**: Search for config file patterns
|
|
227
|
+
2. **Read Full**: Config files are usually small, use `fullContent`
|
|
228
|
+
3. **Trace References**: Find what uses these configs
|
|
229
|
+
|
|
230
|
+
**Example Flow:**
|
|
231
|
+
```json
|
|
232
|
+
// 1. Find all config files
|
|
233
|
+
{ "path": "", "names": ["*.config.*", "*.json", "*.yaml", ".env*"], "maxDepth": 2, "excludeDir": ["node_modules", "dist"] }
|
|
234
|
+
|
|
235
|
+
// 2. Read specific config
|
|
236
|
+
{ "path": "tsconfig.json", "fullContent": true }
|
|
237
|
+
|
|
238
|
+
// 3. Read build config
|
|
239
|
+
{ "path": "vite.config.ts", "fullContent": true }
|
|
240
|
+
|
|
241
|
+
// 4. Find what references these
|
|
242
|
+
{ "pattern": "tsconfig|vite.config", "path": "src", "filesOnly": true }
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Success Criteria**: Understand project configuration and build setup.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Pattern 8: Test Coverage Investigation
|
|
250
|
+
|
|
251
|
+
**Use when**: Understanding what's tested, finding test patterns, coverage gaps.
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
localSearchCode(test patterns) → localGetFileContent → compare with source
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Steps:**
|
|
258
|
+
1. **Find Tests**: Search for test files
|
|
259
|
+
2. **Map Coverage**: Compare test files with source files
|
|
260
|
+
3. **Read Patterns**: Understand testing approach
|
|
261
|
+
|
|
262
|
+
**Example Flow:**
|
|
263
|
+
```json
|
|
264
|
+
// 1. Find test files
|
|
265
|
+
{ "path": "", "names": ["*.test.ts", "*.spec.ts", "*.test.tsx"], "excludeDir": ["node_modules"] }
|
|
266
|
+
|
|
267
|
+
// 2. Find source file
|
|
268
|
+
{ "path": "src", "name": "AuthService.ts" }
|
|
269
|
+
|
|
270
|
+
// 3. Read test for that source
|
|
271
|
+
{ "path": "tests/auth/AuthService.test.ts", "matchString": "describe", "matchStringContextLines": 50 }
|
|
272
|
+
|
|
273
|
+
// 4. Compare: does test cover main functions?
|
|
274
|
+
{ "pattern": "it\\(|test\\(", "path": "tests/auth/AuthService.test.ts" }
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Success Criteria**: Understand test coverage and patterns.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Pattern 9: Monorepo Navigation
|
|
282
|
+
|
|
283
|
+
**Use when**: Working in monorepo with multiple packages.
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
localViewStructure(packages) → localSearchCode(cross-package) → trace dependencies
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**Steps:**
|
|
290
|
+
1. **Map Packages**: View packages/apps directory
|
|
291
|
+
2. **Understand Dependencies**: Check package.json files
|
|
292
|
+
3. **Cross-Package Search**: Find shared code usage
|
|
293
|
+
|
|
294
|
+
**Example Flow:**
|
|
295
|
+
```json
|
|
296
|
+
// 1. Map monorepo structure
|
|
297
|
+
{ "path": "packages", "depth": 1 }
|
|
298
|
+
|
|
299
|
+
// 2. View specific package
|
|
300
|
+
{ "path": "packages/core", "depth": 2 }
|
|
301
|
+
|
|
302
|
+
// 3. Read package deps
|
|
303
|
+
{ "path": "packages/app/package.json", "fullContent": true }
|
|
304
|
+
|
|
305
|
+
// 4. Find cross-package imports
|
|
306
|
+
{ "pattern": "from '@myorg/core'", "path": "packages/app/src", "filesOnly": true }
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Success Criteria**: Understand package relationships and shared code.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Pattern 10: Error Investigation
|
|
314
|
+
|
|
315
|
+
**Use when**: Debugging errors, tracing error sources.
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
localSearchCode(error message) → trace throw/catch → find root cause
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Steps:**
|
|
322
|
+
1. **Find Error Source**: Search for error message
|
|
323
|
+
2. **Trace Throws**: Find where error is thrown
|
|
324
|
+
3. **Trace Catches**: Find error handlers
|
|
325
|
+
4. **Root Cause**: Understand triggering conditions
|
|
326
|
+
|
|
327
|
+
**Example Flow:**
|
|
328
|
+
```json
|
|
329
|
+
// 1. Find error message
|
|
330
|
+
{ "pattern": "Invalid credentials", "path": "src", "contextLines": 5 }
|
|
331
|
+
|
|
332
|
+
// 2. Find throw statements
|
|
333
|
+
{ "pattern": "throw.*Error.*Invalid", "path": "src", "filesOnly": true }
|
|
334
|
+
|
|
335
|
+
// 3. Read throw context
|
|
336
|
+
{ "path": "src/auth/validate.ts", "matchString": "throw new Error", "matchStringContextLines": 15 }
|
|
337
|
+
|
|
338
|
+
// 4. Find callers
|
|
339
|
+
{ "pattern": "validateCredentials|validate\\(", "path": "src", "filesOnly": true }
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Success Criteria**: Found error source and triggering conditions.
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## The Verification Gate
|
|
347
|
+
|
|
348
|
+
**BEFORE claiming a finding, pass this gate:**
|
|
349
|
+
|
|
350
|
+
1. **IDENTIFY**: What exact lines of code prove this?
|
|
351
|
+
2. **FETCH**: Did you read the *actual file content*? (Search snippets don't count)
|
|
352
|
+
3. **VERIFY**: Does the logic actually do what you think?
|
|
353
|
+
4. **CONTEXT**: Is this the currently active code (not deprecated/test)?
|
|
354
|
+
5. **ONLY THEN**: Output the finding.
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Anti-Patterns
|
|
359
|
+
|
|
360
|
+
| Bad | Good |
|
|
361
|
+
|-----|------|
|
|
362
|
+
| **Citing Search Results** | **Citing File Content** (Read the file!) |
|
|
363
|
+
| **"I assume..."** | **"The code shows..."** |
|
|
364
|
+
| **"Should work like..."** | **"Logic implements..."** |
|
|
365
|
+
| **Broad Search (`auth`)** | **Targeted Search (`class AuthService`)** |
|
|
366
|
+
| **Shell commands** | **Local tools with pagination** |
|
|
367
|
+
| **Full file dumps** | **matchString + context** |
|
|
368
|
+
| **Guessing paths** | **Verify with structure first** |
|
|
369
|
+
| **Ignoring hints** | **Follow tool hints** |
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## Checklist
|
|
374
|
+
|
|
375
|
+
Before completing research:
|
|
376
|
+
|
|
377
|
+
- [ ] **Goal defined?** (Atomic question)
|
|
378
|
+
- [ ] **Code evidence found?** (Line numbers/paths)
|
|
379
|
+
- [ ] **The Gate passed?** (Read full content)
|
|
380
|
+
- [ ] **Cross-referenced?** (Imports/Usage)
|
|
381
|
+
- [ ] **Gaps documented?**
|
|
382
|
+
- [ ] **User checkpoint offered?** (Continue/Save)
|
|
383
|
+
|