@j0hanz/fs-context-mcp 2.0.0 → 2.0.2
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 +45 -60
- package/dist/config.d.ts +117 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +31 -0
- package/dist/config.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions.md +32 -35
- package/dist/lib/constants.d.ts +3 -3
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +130 -4
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/errors.d.ts +1 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +9 -9
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/file-operations/file-info.d.ts +7 -1
- package/dist/lib/file-operations/file-info.d.ts.map +1 -1
- package/dist/lib/file-operations/file-info.js +84 -8
- package/dist/lib/file-operations/file-info.js.map +1 -1
- package/dist/lib/file-operations/get-multiple-file-info.d.ts.map +1 -1
- package/dist/lib/file-operations/get-multiple-file-info.js +8 -4
- package/dist/lib/file-operations/get-multiple-file-info.js.map +1 -1
- package/dist/lib/file-operations/glob-engine.d.ts.map +1 -1
- package/dist/lib/file-operations/glob-engine.js +190 -26
- package/dist/lib/file-operations/glob-engine.js.map +1 -1
- package/dist/lib/file-operations/list-directory-entry.d.ts.map +1 -1
- package/dist/lib/file-operations/list-directory-entry.js +5 -3
- package/dist/lib/file-operations/list-directory-entry.js.map +1 -1
- package/dist/lib/file-operations/list-directory-helpers.d.ts.map +1 -1
- package/dist/lib/file-operations/list-directory-helpers.js +11 -4
- package/dist/lib/file-operations/list-directory-helpers.js.map +1 -1
- package/dist/lib/file-operations/list-directory.d.ts +12 -2
- package/dist/lib/file-operations/list-directory.d.ts.map +1 -1
- package/dist/lib/file-operations/list-directory.js +175 -3
- package/dist/lib/file-operations/list-directory.js.map +1 -1
- package/dist/lib/file-operations/read-multiple-files-helpers.d.ts.map +1 -1
- package/dist/lib/file-operations/read-multiple-files-helpers.js +40 -19
- package/dist/lib/file-operations/read-multiple-files-helpers.js.map +1 -1
- package/dist/lib/file-operations/read-multiple-files.d.ts +18 -1
- package/dist/lib/file-operations/read-multiple-files.d.ts.map +1 -1
- package/dist/lib/file-operations/read-multiple-files.js +107 -2
- package/dist/lib/file-operations/read-multiple-files.js.map +1 -1
- package/dist/lib/file-operations/search/engine.d.ts.map +1 -1
- package/dist/lib/file-operations/search/engine.js +7 -2
- package/dist/lib/file-operations/search/engine.js.map +1 -1
- package/dist/lib/file-operations/search/scan-file.d.ts.map +1 -1
- package/dist/lib/file-operations/search/scan-file.js +6 -3
- package/dist/lib/file-operations/search/scan-file.js.map +1 -1
- package/dist/lib/file-operations/search/scan-runner.d.ts.map +1 -1
- package/dist/lib/file-operations/search/scan-runner.js +21 -16
- package/dist/lib/file-operations/search/scan-runner.js.map +1 -1
- package/dist/lib/file-operations/search-content.d.ts +41 -17
- package/dist/lib/file-operations/search-content.d.ts.map +1 -1
- package/dist/lib/file-operations/search-content.js +855 -3
- package/dist/lib/file-operations/search-content.js.map +1 -1
- package/dist/lib/file-operations/search-files-collector.d.ts +2 -2
- package/dist/lib/file-operations/search-files-collector.d.ts.map +1 -1
- package/dist/lib/file-operations/search-files-collector.js +23 -11
- package/dist/lib/file-operations/search-files-collector.js.map +1 -1
- package/dist/lib/file-operations/search-files-helpers.d.ts.map +1 -1
- package/dist/lib/file-operations/search-files-helpers.js +5 -2
- package/dist/lib/file-operations/search-files-helpers.js.map +1 -1
- package/dist/lib/file-operations/search-files.d.ts +20 -2
- package/dist/lib/file-operations/search-files.d.ts.map +1 -1
- package/dist/lib/file-operations/search-files.js +192 -5
- package/dist/lib/file-operations/search-files.js.map +1 -1
- package/dist/lib/file-operations/search-worker.d.ts +30 -0
- package/dist/lib/file-operations/search-worker.d.ts.map +1 -0
- package/dist/lib/file-operations/search-worker.js +98 -0
- package/dist/lib/file-operations/search-worker.js.map +1 -0
- package/dist/lib/fs-helpers/readers/read-modes.d.ts.map +1 -1
- package/dist/lib/fs-helpers/readers/read-modes.js +6 -4
- package/dist/lib/fs-helpers/readers/read-modes.js.map +1 -1
- package/dist/lib/fs-helpers/readers/read-options.d.ts.map +1 -1
- package/dist/lib/fs-helpers/readers/read-options.js +8 -3
- package/dist/lib/fs-helpers/readers/read-options.js.map +1 -1
- package/dist/lib/fs-helpers.d.ts +42 -5
- package/dist/lib/fs-helpers.d.ts.map +1 -1
- package/dist/lib/fs-helpers.js +479 -5
- package/dist/lib/fs-helpers.js.map +1 -1
- package/dist/lib/observability/diagnostics-helpers.d.ts +3 -0
- package/dist/lib/observability/diagnostics-helpers.d.ts.map +1 -0
- package/dist/lib/observability/diagnostics-helpers.js +50 -0
- package/dist/lib/observability/diagnostics-helpers.js.map +1 -0
- package/dist/lib/observability/diagnostics.d.ts.map +1 -1
- package/dist/lib/observability/diagnostics.js +24 -59
- package/dist/lib/observability/diagnostics.js.map +1 -1
- package/dist/lib/observability.d.ts +15 -0
- package/dist/lib/observability.d.ts.map +1 -0
- package/dist/lib/observability.js +196 -0
- package/dist/lib/observability.js.map +1 -0
- package/dist/lib/path-validation/validate-existing.js +1 -1
- package/dist/lib/path-validation/validate-existing.js.map +1 -1
- package/dist/lib/path-validation.d.ts +18 -5
- package/dist/lib/path-validation.d.ts.map +1 -1
- package/dist/lib/path-validation.js +340 -5
- package/dist/lib/path-validation.js.map +1 -1
- package/dist/schemas/inputs/directory.d.ts +1 -1
- package/dist/schemas/inputs/directory.d.ts.map +1 -1
- package/dist/schemas/inputs/directory.js +1 -12
- package/dist/schemas/inputs/directory.js.map +1 -1
- package/dist/schemas/inputs/helpers.d.ts +2 -0
- package/dist/schemas/inputs/helpers.d.ts.map +1 -0
- package/dist/schemas/inputs/helpers.js +13 -0
- package/dist/schemas/inputs/helpers.js.map +1 -0
- package/dist/schemas/inputs/safe-glob.d.ts +2 -0
- package/dist/schemas/inputs/safe-glob.d.ts.map +1 -0
- package/dist/schemas/inputs/safe-glob.js +13 -0
- package/dist/schemas/inputs/safe-glob.js.map +1 -0
- package/dist/schemas/inputs/search.d.ts.map +1 -1
- package/dist/schemas/inputs/search.js +2 -13
- package/dist/schemas/inputs/search.js.map +1 -1
- package/dist/schemas/output-helpers.d.ts +6 -1
- package/dist/schemas/output-helpers.d.ts.map +1 -1
- package/dist/schemas/output-helpers.js +5 -0
- package/dist/schemas/output-helpers.js.map +1 -1
- package/dist/schemas/outputs/file-info.d.ts +2 -2
- package/dist/schemas/outputs/file-info.d.ts.map +1 -1
- package/dist/schemas/outputs/file-info.js +2 -8
- package/dist/schemas/outputs/file-info.js.map +1 -1
- package/dist/schemas/outputs/read.d.ts.map +1 -1
- package/dist/schemas/outputs/read.js +2 -7
- package/dist/schemas/outputs/read.js.map +1 -1
- package/dist/schemas.d.ts +195 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +234 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server/roots.d.ts.map +1 -1
- package/dist/server/roots.js +19 -15
- package/dist/server/roots.js.map +1 -1
- package/dist/server.d.ts +10 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +208 -10
- package/dist/server.js.map +1 -1
- package/dist/tools/get-file-info.d.ts.map +1 -1
- package/dist/tools/get-file-info.js +5 -1
- package/dist/tools/get-file-info.js.map +1 -1
- package/dist/tools/get-multiple-file-info.d.ts.map +1 -1
- package/dist/tools/get-multiple-file-info.js +6 -3
- package/dist/tools/get-multiple-file-info.js.map +1 -1
- package/dist/tools/list-directory-formatting.d.ts.map +1 -1
- package/dist/tools/list-directory-formatting.js +7 -1
- package/dist/tools/list-directory-formatting.js.map +1 -1
- package/dist/tools/list-directory.d.ts.map +1 -1
- package/dist/tools/list-directory.js +5 -4
- package/dist/tools/list-directory.js.map +1 -1
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +9 -4
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +9 -4
- package/dist/tools/read-multiple-files.js.map +1 -1
- package/dist/tools/search-content.d.ts.map +1 -1
- package/dist/tools/search-content.js +19 -17
- package/dist/tools/search-content.js.map +1 -1
- package/dist/tools/search-files.d.ts.map +1 -1
- package/dist/tools/search-files.js +15 -12
- package/dist/tools/search-files.js.map +1 -1
- package/dist/tools/shared/file-info.d.ts +4 -2
- package/dist/tools/shared/file-info.d.ts.map +1 -1
- package/dist/tools/shared/file-info.js +4 -2
- package/dist/tools/shared/file-info.js.map +1 -1
- package/dist/tools/shared/resolve-path.d.ts +2 -0
- package/dist/tools/shared/resolve-path.d.ts.map +1 -0
- package/dist/tools/shared/resolve-path.js +11 -0
- package/dist/tools/shared/resolve-path.js.map +1 -0
- package/dist/tools/shared/search-formatting.d.ts.map +1 -1
- package/dist/tools/shared/search-formatting.js +58 -38
- package/dist/tools/shared/search-formatting.js.map +1 -1
- package/dist/tools/tool-response.d.ts.map +1 -1
- package/dist/tools/tool-response.js +11 -6
- package/dist/tools/tool-response.js.map +1 -1
- package/dist/tools.d.ts +34 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +550 -0
- package/dist/tools.js.map +1 -0
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ A secure, read-only MCP server for filesystem scanning, searching, and analysis
|
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](https://nodejs.org)
|
|
10
10
|
[](https://www.typescriptlang.org/)
|
|
11
|
-
[](https://modelcontextprotocol.io)
|
|
12
12
|
|
|
13
13
|
## One-Click Install
|
|
14
14
|
|
|
@@ -19,7 +19,7 @@ A secure, read-only MCP server for filesystem scanning, searching, and analysis
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
21
|
- Directory listing (immediate contents)
|
|
22
|
-
-
|
|
22
|
+
- File search with glob patterns
|
|
23
23
|
- Content search with regex and context lines
|
|
24
24
|
- File reading with head previews (first N lines)
|
|
25
25
|
- Batch reads and metadata lookups in parallel
|
|
@@ -30,7 +30,7 @@ A secure, read-only MCP server for filesystem scanning, searching, and analysis
|
|
|
30
30
|
| Task | Tool |
|
|
31
31
|
| ------------------------------- | ----------- |
|
|
32
32
|
| Explore project structure | `ls` |
|
|
33
|
-
| Find files
|
|
33
|
+
| Find files | `find` |
|
|
34
34
|
| Search for code patterns/text | `grep` |
|
|
35
35
|
| Read source code | `read` |
|
|
36
36
|
| Batch read multiple files | `read_many` |
|
|
@@ -54,7 +54,7 @@ Or pass explicit directories:
|
|
|
54
54
|
npx -y @j0hanz/fs-context-mcp@latest /path/to/project /path/to/docs
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
If your MCP client supports the Roots protocol, you can omit directory arguments and let the client provide allowed directories. Otherwise, pass explicit directories or use `--allow-cwd` (if neither is provided, the server
|
|
57
|
+
If your MCP client supports the Roots protocol, you can omit directory arguments and let the client provide allowed directories. Otherwise, pass explicit directories or use `--allow-cwd` (if neither is provided, the server starts with no accessible directories until roots are provided).
|
|
58
58
|
|
|
59
59
|
### VS Code (workspace folder)
|
|
60
60
|
|
|
@@ -105,7 +105,7 @@ Access is always restricted to explicitly allowed directories.
|
|
|
105
105
|
3. MCP Roots from the client are used next:
|
|
106
106
|
- If CLI and/or `--allow-cwd` are provided, only roots inside those baseline directories are accepted.
|
|
107
107
|
- If no baseline is provided, roots become the allowed directories.
|
|
108
|
-
4. If nothing is configured and the client provides no roots, the server
|
|
108
|
+
4. If nothing is configured and the client provides no roots, the server starts with no accessible directories and logs a warning until roots are provided.
|
|
109
109
|
|
|
110
110
|
Notes:
|
|
111
111
|
|
|
@@ -123,7 +123,7 @@ All configuration is optional. Sizes in bytes, timeouts in milliseconds.
|
|
|
123
123
|
| `MAX_FILE_SIZE` | 10MB | Max file size for read operations (range: 1MB-100MB) |
|
|
124
124
|
| `MAX_SEARCH_SIZE` | 1MB | Max file size for content search (range: 100KB-10MB) |
|
|
125
125
|
| `DEFAULT_SEARCH_TIMEOUT` | 30000 | Timeout for search/list operations (range: 100-3600000ms) |
|
|
126
|
-
| `FS_CONTEXT_SEARCH_WORKERS` | min(cpu cores, 8) | Search worker threads (range:
|
|
126
|
+
| `FS_CONTEXT_SEARCH_WORKERS` | min(cpu cores, 8) | Search worker threads (range: 0-16; 0 disables) |
|
|
127
127
|
|
|
128
128
|
See [CONFIGURATION.md](CONFIGURATION.md) for examples and CLI usage.
|
|
129
129
|
|
|
@@ -151,17 +151,10 @@ Returns: Allowed directory paths. Structured output includes `ok` and
|
|
|
151
151
|
List the immediate contents of a directory (non-recursive). Omit `path` to use
|
|
152
152
|
the first allowed root.
|
|
153
153
|
|
|
154
|
-
| Parameter
|
|
155
|
-
|
|
|
156
|
-
| `path`
|
|
157
|
-
| `includeHidden`
|
|
158
|
-
| `excludePatterns` | string[] | No | `[]` | Glob patterns to exclude |
|
|
159
|
-
| `pattern` | string | No | - | Glob pattern to include (relative, no `..`) |
|
|
160
|
-
| `maxDepth` | number | No | `10` | Maximum depth when using pattern (0-100) |
|
|
161
|
-
| `maxEntries` | number | No | `10000` | Maximum entries to return (1-100000) |
|
|
162
|
-
| `timeoutMs` | number | No | `30000` | Timeout in milliseconds |
|
|
163
|
-
| `sortBy` | string | No | `name` | Sort by: `name`, `size`, `modified`, `type` |
|
|
164
|
-
| `includeSymlinkTargets` | boolean | No | `false` | Include symlink target paths (symlinks are not followed) |
|
|
154
|
+
| Parameter | Type | Required | Default | Description |
|
|
155
|
+
| --------------- | ------- | -------- | ------------ | ----------------------------------------------- |
|
|
156
|
+
| `path` | string | No | `first root` | Directory path to list (omit to use first root) |
|
|
157
|
+
| `includeHidden` | boolean | No | `false` | Include hidden files and directories |
|
|
165
158
|
|
|
166
159
|
Returns: Entries with name, relativePath, type, size, and modified time.
|
|
167
160
|
Structured output includes `ok`, `path`, `entries`, and `totalEntries`.
|
|
@@ -170,15 +163,17 @@ Structured output includes `ok`, `path`, `entries`, and `totalEntries`.
|
|
|
170
163
|
|
|
171
164
|
### `find`
|
|
172
165
|
|
|
173
|
-
Search for files using glob patterns.
|
|
174
|
-
|
|
175
|
-
|
|
166
|
+
Search for files using glob patterns. Omit `path` to search from the first
|
|
167
|
+
allowed root. By default, `find` excludes common dependency/build directories
|
|
168
|
+
(node_modules, dist, .git, etc.); set `includeIgnored: true` to include ignored
|
|
169
|
+
directories and disable built-in excludes.
|
|
176
170
|
|
|
177
|
-
| Parameter
|
|
178
|
-
|
|
|
179
|
-
| `path`
|
|
180
|
-
| `pattern`
|
|
181
|
-
| `
|
|
171
|
+
| Parameter | Type | Required | Default | Description |
|
|
172
|
+
| ---------------- | ------- | -------- | ------------ | ------------------------------------------------------ |
|
|
173
|
+
| `path` | string | No | `first root` | Base directory to search from (omit to use first root) |
|
|
174
|
+
| `pattern` | string | Yes | - | Glob pattern (e.g., `**/*.ts`, `src/**/*.js`) |
|
|
175
|
+
| `includeIgnored` | boolean | No | `false` | Include ignored dirs and disable built-in excludes |
|
|
176
|
+
| `maxResults` | number | No | `100` | Maximum matches to return (1-10000) |
|
|
182
177
|
|
|
183
178
|
Returns: Matching paths (relative) with size and modified date. Structured
|
|
184
179
|
output includes `ok`, `results`, `totalMatches`, and `truncated`.
|
|
@@ -197,7 +192,8 @@ Read the contents of a text file.
|
|
|
197
192
|
Notes:
|
|
198
193
|
|
|
199
194
|
- Reads are UTF-8 text only; binary files are rejected.
|
|
200
|
-
-
|
|
195
|
+
- Full reads are capped by `MAX_FILE_SIZE` (default 10MB). When `head` is set,
|
|
196
|
+
output stops at the line limit or size budget, whichever comes first.
|
|
201
197
|
|
|
202
198
|
Returns: File content plus structured metadata (`ok`, `path`, `content`,
|
|
203
199
|
`truncated`, `totalLines`).
|
|
@@ -254,28 +250,16 @@ Returns: Array of file info with individual success/error status, plus summary
|
|
|
254
250
|
|
|
255
251
|
### `grep`
|
|
256
252
|
|
|
257
|
-
Search for text content within files
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
|
263
|
-
|
|
|
264
|
-
| `
|
|
265
|
-
| `
|
|
266
|
-
| `
|
|
267
|
-
| `maxResults` | number | No | `100` | Maximum number of results |
|
|
268
|
-
| `maxFileSize` | number | No | 1MB | Maximum file size to scan (default from `MAX_SEARCH_SIZE`) |
|
|
269
|
-
| `maxFilesScanned` | number | No | `20000` | Maximum files to scan before stopping |
|
|
270
|
-
| `timeoutMs` | number | No | `30000` | Timeout in milliseconds |
|
|
271
|
-
| `skipBinary` | boolean | No | `true` | Skip likely-binary files |
|
|
272
|
-
| `includeHidden` | boolean | No | `false` | Include hidden files and directories |
|
|
273
|
-
| `includeIgnored` | boolean | No | `false` | Include ignored dirs (node_modules, dist) and disable built-in excludes |
|
|
274
|
-
| `contextLines` | number | No | `0` | Lines of context before/after match (0-10) |
|
|
275
|
-
| `wholeWord` | boolean | No | `false` | Match whole words only |
|
|
276
|
-
| `isLiteral` | boolean | No | `false` | Treat pattern as literal string (escape regex chars) |
|
|
277
|
-
| `baseNameMatch` | boolean | No | `false` | Match file patterns without slashes against basenames |
|
|
278
|
-
| `caseSensitiveFileMatch` | boolean | No | `true` | Case-sensitive filename matching |
|
|
253
|
+
Search for text content within files. Omit `path` to search from the first
|
|
254
|
+
allowed root.
|
|
255
|
+
|
|
256
|
+
`pattern` is treated as a literal string.
|
|
257
|
+
|
|
258
|
+
| Parameter | Type | Required | Default | Description |
|
|
259
|
+
| --------------- | ------- | -------- | ------------ | ---------------------------------------------------- |
|
|
260
|
+
| `path` | string | No | `first root` | Base directory to search in (omit to use first root) |
|
|
261
|
+
| `pattern` | string | Yes | - | Text pattern to search for |
|
|
262
|
+
| `includeHidden` | boolean | No | `false` | Include hidden files and directories |
|
|
279
263
|
|
|
280
264
|
Returns: Matching lines with file path, line number, content, and optional
|
|
281
265
|
context. Structured output includes `ok`, `matches`, `totalMatches`, and
|
|
@@ -284,12 +268,11 @@ Matched line content is trimmed to 200 characters.
|
|
|
284
268
|
|
|
285
269
|
---
|
|
286
270
|
|
|
287
|
-
Built-in exclude list
|
|
288
|
-
files: `node_modules`, `dist`, `build`, `coverage`, `.git`, `.vscode`,
|
|
289
|
-
`.DS_Store`, `.next`, `.nuxt`, `.output`, `.svelte-kit`, `.cache`,
|
|
290
|
-
`jspm_packages`, `bower_components`, `out`, `tmp`, `.temp`,
|
|
291
|
-
`npm-debug.log`, `yarn-debug.log`, `yarn-error.log`, `Thumbs.db`.
|
|
292
|
-
`excludePatterns: []` or `includeIgnored: true` to disable it.
|
|
271
|
+
Built-in exclude list: `grep` skips common dependency/build/output directories
|
|
272
|
+
and files: `node_modules`, `dist`, `build`, `coverage`, `.git`, `.vscode`,
|
|
273
|
+
`.idea`, `.DS_Store`, `.next`, `.nuxt`, `.output`, `.svelte-kit`, `.cache`,
|
|
274
|
+
`.yarn`, `jspm_packages`, `bower_components`, `out`, `tmp`, `.temp`,
|
|
275
|
+
`npm-debug.log`, `yarn-debug.log`, `yarn-error.log`, `Thumbs.db`.
|
|
293
276
|
|
|
294
277
|
## Error Codes
|
|
295
278
|
|
|
@@ -442,13 +425,15 @@ This server implements multiple layers of security:
|
|
|
442
425
|
src/
|
|
443
426
|
index.ts # CLI entry point
|
|
444
427
|
server.ts # MCP server wiring and roots handling
|
|
428
|
+
tools.ts # MCP tool registration + response helpers
|
|
429
|
+
schemas.ts # Zod input/output schemas
|
|
430
|
+
config.ts # Shared types and formatting helpers
|
|
445
431
|
instructions.md # Tool usage instructions (bundled in dist)
|
|
446
|
-
config/ # Shared types and formatting helpers
|
|
447
432
|
lib/ # Core logic and filesystem operations
|
|
448
|
-
schemas/ # Zod input/output schemas
|
|
449
|
-
tools/ # MCP tool registration
|
|
450
433
|
__tests__/ # node:test + tsx tests
|
|
451
|
-
node-tests/ #
|
|
434
|
+
node-tests/ # Additional Node.js checks
|
|
435
|
+
docs/ # Static docs assets
|
|
436
|
+
dist/ # Build output (generated)
|
|
452
437
|
```
|
|
453
438
|
|
|
454
439
|
## Troubleshooting
|
|
@@ -461,7 +446,7 @@ node-tests/ # Isolated Node.js checks
|
|
|
461
446
|
| "Binary file" warning | `read` only supports UTF-8 text and rejects binary files. |
|
|
462
447
|
| No directories available | Pass explicit paths, use `--allow-cwd`, or ensure the client provides Roots. |
|
|
463
448
|
| Symlink blocked | Symlinks that resolve outside allowed directories are blocked. |
|
|
464
|
-
| Invalid
|
|
449
|
+
| Invalid pattern | Simplify the pattern (note: `grep` treats `pattern` as literal text). |
|
|
465
450
|
|
|
466
451
|
## Contributing
|
|
467
452
|
|
|
@@ -469,7 +454,7 @@ Contributions are welcome! Please follow these steps:
|
|
|
469
454
|
|
|
470
455
|
1. Fork the repository
|
|
471
456
|
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
472
|
-
3. Run
|
|
457
|
+
3. Run format, lint, type-check, build, and tests (`npm run format && npm run lint && npm run type-check && npm run build && npm run test`)
|
|
473
458
|
4. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
474
459
|
5. Push to the branch (`git push origin feature/amazing-feature`)
|
|
475
460
|
6. Open a Pull Request
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export type FileType = 'file' | 'directory' | 'symlink' | 'other';
|
|
2
|
+
export interface FileInfo {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly type: FileType;
|
|
6
|
+
readonly size: number;
|
|
7
|
+
readonly created: Date;
|
|
8
|
+
readonly modified: Date;
|
|
9
|
+
readonly accessed: Date;
|
|
10
|
+
readonly permissions: string;
|
|
11
|
+
readonly isHidden: boolean;
|
|
12
|
+
readonly mimeType?: string;
|
|
13
|
+
readonly symlinkTarget?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface DirectoryEntry {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly relativePath: string;
|
|
19
|
+
readonly type: FileType;
|
|
20
|
+
readonly size?: number;
|
|
21
|
+
readonly modified?: Date;
|
|
22
|
+
readonly symlinkTarget?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ListDirectoryResult {
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly entries: readonly DirectoryEntry[];
|
|
27
|
+
readonly summary: {
|
|
28
|
+
readonly totalEntries: number;
|
|
29
|
+
readonly entriesScanned?: number;
|
|
30
|
+
readonly entriesVisible?: number;
|
|
31
|
+
readonly totalFiles: number;
|
|
32
|
+
readonly totalDirectories: number;
|
|
33
|
+
readonly maxDepthReached: number;
|
|
34
|
+
readonly truncated: boolean;
|
|
35
|
+
readonly stoppedReason?: 'maxEntries' | 'aborted';
|
|
36
|
+
readonly skippedInaccessible: number;
|
|
37
|
+
readonly symlinksNotFollowed: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface SearchResult {
|
|
41
|
+
readonly path: string;
|
|
42
|
+
readonly type: FileType;
|
|
43
|
+
readonly size?: number;
|
|
44
|
+
readonly modified?: Date;
|
|
45
|
+
}
|
|
46
|
+
export interface SearchFilesResult {
|
|
47
|
+
readonly basePath: string;
|
|
48
|
+
readonly pattern: string;
|
|
49
|
+
readonly results: readonly SearchResult[];
|
|
50
|
+
readonly summary: {
|
|
51
|
+
readonly matched: number;
|
|
52
|
+
readonly truncated: boolean;
|
|
53
|
+
readonly skippedInaccessible: number;
|
|
54
|
+
readonly filesScanned: number;
|
|
55
|
+
readonly stoppedReason?: 'maxResults' | 'maxFiles' | 'timeout';
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface ContentMatch {
|
|
59
|
+
readonly file: string;
|
|
60
|
+
readonly line: number;
|
|
61
|
+
readonly content: string;
|
|
62
|
+
readonly contextBefore?: readonly string[];
|
|
63
|
+
readonly contextAfter?: readonly string[];
|
|
64
|
+
readonly matchCount: number;
|
|
65
|
+
}
|
|
66
|
+
export interface SearchContentResult {
|
|
67
|
+
readonly basePath: string;
|
|
68
|
+
readonly pattern: string;
|
|
69
|
+
readonly filePattern: string;
|
|
70
|
+
readonly matches: readonly ContentMatch[];
|
|
71
|
+
readonly summary: {
|
|
72
|
+
readonly filesScanned: number;
|
|
73
|
+
readonly filesMatched: number;
|
|
74
|
+
readonly matches: number;
|
|
75
|
+
readonly truncated: boolean;
|
|
76
|
+
readonly skippedTooLarge: number;
|
|
77
|
+
readonly skippedBinary: number;
|
|
78
|
+
readonly skippedInaccessible: number;
|
|
79
|
+
readonly linesSkippedDueToRegexTimeout: number;
|
|
80
|
+
readonly stoppedReason?: 'maxResults' | 'maxFiles' | 'timeout';
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface MultipleFileInfoResult {
|
|
84
|
+
readonly path: string;
|
|
85
|
+
readonly info?: FileInfo;
|
|
86
|
+
readonly error?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface GetMultipleFileInfoResult {
|
|
89
|
+
readonly results: readonly MultipleFileInfoResult[];
|
|
90
|
+
readonly summary: {
|
|
91
|
+
readonly total: number;
|
|
92
|
+
readonly succeeded: number;
|
|
93
|
+
readonly failed: number;
|
|
94
|
+
readonly totalSize: number;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export declare const ErrorCode: {
|
|
98
|
+
readonly E_ACCESS_DENIED: "E_ACCESS_DENIED";
|
|
99
|
+
readonly E_NOT_FOUND: "E_NOT_FOUND";
|
|
100
|
+
readonly E_NOT_FILE: "E_NOT_FILE";
|
|
101
|
+
readonly E_NOT_DIRECTORY: "E_NOT_DIRECTORY";
|
|
102
|
+
readonly E_TOO_LARGE: "E_TOO_LARGE";
|
|
103
|
+
readonly E_TIMEOUT: "E_TIMEOUT";
|
|
104
|
+
readonly E_INVALID_PATTERN: "E_INVALID_PATTERN";
|
|
105
|
+
readonly E_INVALID_INPUT: "E_INVALID_INPUT";
|
|
106
|
+
readonly E_PERMISSION_DENIED: "E_PERMISSION_DENIED";
|
|
107
|
+
readonly E_SYMLINK_NOT_ALLOWED: "E_SYMLINK_NOT_ALLOWED";
|
|
108
|
+
readonly E_UNKNOWN: "E_UNKNOWN";
|
|
109
|
+
};
|
|
110
|
+
export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
111
|
+
export declare function formatBytes(bytes: number): string;
|
|
112
|
+
export declare function joinLines(lines: readonly string[]): string;
|
|
113
|
+
export declare function formatOperationSummary(summary: {
|
|
114
|
+
truncated?: boolean;
|
|
115
|
+
truncatedReason?: string;
|
|
116
|
+
}): string;
|
|
117
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAElE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,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TIMEOUT',
|
|
8
|
+
E_INVALID_PATTERN: 'E_INVALID_PATTERN',
|
|
9
|
+
E_INVALID_INPUT: 'E_INVALID_INPUT',
|
|
10
|
+
E_PERMISSION_DENIED: 'E_PERMISSION_DENIED',
|
|
11
|
+
E_SYMLINK_NOT_ALLOWED: 'E_SYMLINK_NOT_ALLOWED',
|
|
12
|
+
E_UNKNOWN: 'E_UNKNOWN',
|
|
13
|
+
};
|
|
14
|
+
const BYTE_UNIT_LABELS = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
15
|
+
export function formatBytes(bytes) {
|
|
16
|
+
if (bytes === 0)
|
|
17
|
+
return '0 B';
|
|
18
|
+
const unitIndex = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
19
|
+
const unit = BYTE_UNIT_LABELS[unitIndex] ?? 'B';
|
|
20
|
+
const value = bytes / Math.pow(1024, unitIndex);
|
|
21
|
+
return `${parseFloat(value.toFixed(2))} ${unit}`;
|
|
22
|
+
}
|
|
23
|
+
export function joinLines(lines) {
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
}
|
|
26
|
+
export function formatOperationSummary(summary) {
|
|
27
|
+
if (!summary.truncated)
|
|
28
|
+
return '';
|
|
29
|
+
return `\n[truncated: ${summary.truncatedReason ?? 'limit reached'}]`;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA0GA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;IACtB,iBAAiB,EAAE,mBAAmB;IACtC,eAAe,EAAE,iBAAiB;IAClC,mBAAmB,EAAE,qBAAqB;IAC1C,qBAAqB,EAAE,uBAAuB;IAC9C,SAAS,EAAE,WAAW;CACd,CAAC;AAIX,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAEhE,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,MAAM,IAAI,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChD,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAwB;IAChD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAGtC;IACC,IAAI,CAAC,OAAO,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAClC,OAAO,iBAAiB,OAAO,CAAC,eAAe,IAAI,eAAe,GAAG,CAAC;AACxE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { DEFAULT_SEARCH_TIMEOUT_MS } from './lib/constants.js';
|
|
3
|
-
import { createTimedAbortSignal } from './lib/fs-helpers
|
|
4
|
-
import { setAllowedDirectoriesResolved } from './lib/path-validation
|
|
3
|
+
import { createTimedAbortSignal } from './lib/fs-helpers.js';
|
|
4
|
+
import { setAllowedDirectoriesResolved } from './lib/path-validation.js';
|
|
5
5
|
import { createServer, parseArgs, startServer } from './server.js';
|
|
6
6
|
const SHUTDOWN_TIMEOUT_MS = 5000;
|
|
7
7
|
let activeServer;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,IAAI,YAAmC,CAAC;AACxC,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B,KAAK,UAAU,QAAQ,CAAC,MAAc;IACpC,IAAI,eAAe;QAAE,OAAO;IAC5B,eAAe,GAAG,IAAI,CAAC;IAEvB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAExB,IAAI,CAAC;QACH,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CACX,mBAAmB,MAAM,IAAI,EAC7B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KA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,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;IAC7B,KAAK,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAe,EAAE,EAAE;IACnD,OAAO,CAAC,KAAK,CACX,sBAAsB,EACtB,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAC1D,CAAC;IACF,KAAK,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAY,EAAE,EAAE;IAC/C,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACpD,KAAK,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CACX,cAAc,EACd,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/instructions.md
CHANGED
|
@@ -10,16 +10,16 @@ explicitly allowed directories and never write to disk.
|
|
|
10
10
|
|
|
11
11
|
## Quick Reference
|
|
12
12
|
|
|
13
|
-
| Goal | Tool | Key Parameters
|
|
14
|
-
| ------------------- | ----------- |
|
|
15
|
-
| Check access | `roots` | -
|
|
16
|
-
| List contents | `ls` | `path`
|
|
17
|
-
| Find files | `find` | `pattern` (glob), `maxResults`
|
|
18
|
-
| Search in files | `grep` | `pattern`
|
|
19
|
-
| Read file | `read` | `head`
|
|
20
|
-
| Read multiple files | `read_many` | `paths[]` - preferred for 2+
|
|
21
|
-
| File metadata | `stat` | `path`
|
|
22
|
-
| Batch file metadata | `stat_many` | `paths[]` - preferred for 2+
|
|
13
|
+
| Goal | Tool | Key Parameters |
|
|
14
|
+
| ------------------- | ----------- | ------------------------------ |
|
|
15
|
+
| Check access | `roots` | - |
|
|
16
|
+
| List contents | `ls` | `path` |
|
|
17
|
+
| Find files | `find` | `pattern` (glob), `maxResults` |
|
|
18
|
+
| Search in files | `grep` | `pattern` |
|
|
19
|
+
| Read file | `read` | `head` |
|
|
20
|
+
| Read multiple files | `read_many` | `paths[]` - preferred for 2+ |
|
|
21
|
+
| File metadata | `stat` | `path` |
|
|
22
|
+
| Batch file metadata | `stat_many` | `paths[]` - preferred for 2+ |
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
@@ -27,10 +27,10 @@ explicitly allowed directories and never write to disk.
|
|
|
27
27
|
|
|
28
28
|
- **Allowed directories:** All tools only operate inside the allowed roots.
|
|
29
29
|
Run `roots` first to confirm scope. If nothing is configured and the client
|
|
30
|
-
provides no roots, the server
|
|
31
|
-
|
|
32
|
-
- **Globs vs
|
|
33
|
-
|
|
30
|
+
provides no roots, the server starts with no accessible directories and logs
|
|
31
|
+
a warning until roots are provided.
|
|
32
|
+
- **Globs vs patterns:** `find` uses glob patterns. `grep` treats `pattern` as a
|
|
33
|
+
literal string.
|
|
34
34
|
- **Symlinks:** Symlinks are never followed for security.
|
|
35
35
|
|
|
36
36
|
---
|
|
@@ -55,7 +55,7 @@ read_many([...results])
|
|
|
55
55
|
### Search patterns in code
|
|
56
56
|
|
|
57
57
|
```text
|
|
58
|
-
grep(pattern="TODO
|
|
58
|
+
grep(pattern="TODO")
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
---
|
|
@@ -105,9 +105,10 @@ List the immediate contents of a directory (non-recursive). Returns entry name,
|
|
|
105
105
|
relative path, type, size, and modified date. Omit `path` to use the first
|
|
106
106
|
allowed root. Symlinks are not followed.
|
|
107
107
|
|
|
108
|
-
| Parameter
|
|
109
|
-
|
|
|
110
|
-
| `path`
|
|
108
|
+
| Parameter | Default | Description |
|
|
109
|
+
| --------------- | ------- | ------------------------------------ |
|
|
110
|
+
| `path` | - | Directory path |
|
|
111
|
+
| `includeHidden` | false | Include hidden files and directories |
|
|
111
112
|
|
|
112
113
|
For recursive or filtered file searches, use `find` instead.
|
|
113
114
|
|
|
@@ -119,29 +120,25 @@ Find files using glob patterns. Automatically excludes common dependency/build
|
|
|
119
120
|
directories (node_modules, dist, .git, etc.). Omit `path` to use the first
|
|
120
121
|
allowed root.
|
|
121
122
|
|
|
122
|
-
| Parameter
|
|
123
|
-
|
|
|
124
|
-
| `path`
|
|
125
|
-
| `pattern`
|
|
126
|
-
| `
|
|
123
|
+
| Parameter | Default | Description |
|
|
124
|
+
| ---------------- | ------- | ------------------------- |
|
|
125
|
+
| `path` | - | Base directory |
|
|
126
|
+
| `pattern` | - | Glob: `**/*.ts`, `src/**` |
|
|
127
|
+
| `includeIgnored` | false | Include ignored dirs |
|
|
128
|
+
| `maxResults` | 100 | Limit (up to 10,000) |
|
|
127
129
|
|
|
128
130
|
---
|
|
129
131
|
|
|
130
132
|
### `grep`
|
|
131
133
|
|
|
132
|
-
Grep-like search across file contents
|
|
133
|
-
allowed root.
|
|
134
|
+
Grep-like search across file contents. `pattern` is treated as a literal string.
|
|
135
|
+
Omit `path` to use the first allowed root.
|
|
134
136
|
|
|
135
|
-
| Parameter
|
|
136
|
-
|
|
|
137
|
-
| `path`
|
|
138
|
-
| `pattern`
|
|
139
|
-
| `
|
|
140
|
-
| `caseSensitive` | false | Case-sensitive matching |
|
|
141
|
-
| `isLiteral` | false | Treat pattern as literal string |
|
|
142
|
-
| `maxResults` | 100 | Maximum matches to return |
|
|
143
|
-
| `contextLines` | 0 | Lines of context before/after (0-10) |
|
|
144
|
-
| `includeIgnored` | false | Include ignored dirs (node_modules) |
|
|
137
|
+
| Parameter | Default | Description |
|
|
138
|
+
| --------------- | ------- | ------------------------------------ |
|
|
139
|
+
| `path` | - | Base directory |
|
|
140
|
+
| `pattern` | - | Text pattern |
|
|
141
|
+
| `includeHidden` | false | Include hidden files and directories |
|
|
145
142
|
|
|
146
143
|
---
|
|
147
144
|
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const DEFAULT_LIST_MAX_ENTRIES = 10000;
|
|
|
13
13
|
export declare const DEFAULT_SEARCH_MAX_FILES = 20000;
|
|
14
14
|
export declare const MAX_LINE_CONTENT_LENGTH = 200;
|
|
15
15
|
export declare const BINARY_CHECK_BUFFER_SIZE = 512;
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
16
|
+
export declare const KNOWN_BINARY_EXTENSIONS: Set<string>;
|
|
17
|
+
export declare const DEFAULT_EXCLUDE_PATTERNS: string[];
|
|
18
|
+
export declare function getMimeType(ext: string): string;
|
|
19
19
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,oBAAoB,QAA0B,CAAC;AAG5D,eAAO,MAAM,wBAAwB,QAKpC,CAAC;AACF,eAAO,MAAM,kBAAkB,QAK9B,CAAC;AACF,eAAO,MAAM,yBAAyB,QAKrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAK1B,CAAC;AAGF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAC9C,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAG9C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,oBAAoB,QAA0B,CAAC;AAG5D,eAAO,MAAM,wBAAwB,QAKpC,CAAC;AACF,eAAO,MAAM,kBAAkB,QAK9B,CAAC;AACF,eAAO,MAAM,yBAAyB,QAKrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAK1B,CAAC;AAGF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAC9C,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAG9C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,uBAAuB,aAyClC,CAAC;AAEH,eAAO,MAAM,wBAAwB,UAwBpC,CAAC;AA6DF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C"}
|