agent-file-tools 0.43.0

Agent File Tools — tree-sitter powered code analysis for AI agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
{
  "status": {
    "type": "object",
    "properties": {},
    "additionalProperties": false
  },
  "bash": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "command": {
        "description": "Shell command to execute. Supports pipes, redirection, and normal shell syntax.",
        "type": "string"
      },
      "timeout": {
        "description": "Hard kill cap in milliseconds (positive integer). When omitted, the task can run up to 30 minutes. Foreground bash returns inline if the command finishes within ~8s (configurable via bash.foreground_wait_window_ms); otherwise it's automatically promoted to background and a completion reminder is delivered when the task actually finishes.",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "workdir": {
        "description": "Working directory for command execution. Relative paths resolve through the bridge; defaults to the current tool context/project root when omitted.",
        "type": "string"
      },
      "description": {
        "description": "Short 5-10 word human-readable summary shown in OpenCode UI metadata instead of raw shell syntax.",
        "type": "string"
      },
      "background": {
        "description": "When true, spawn the command in the background and return a taskId for bash_status/bash_kill instead of waiting for completion. Defaults to false.",
        "type": "boolean"
      },
      "compressed": {
        "description": "When true or omitted, return compressed output with noisy terminal control sequences reduced. Set to false for raw output.",
        "type": "boolean"
      },
      "pty": {
        "description": "When true, spawn the command in a real PTY for interactive programs (python/node/bash REPLs, vim). Implies background: true automatically. Unavailable in subagent sessions. Inspect with bash_status({ taskId, outputMode: \"screen\" }) and drive interactively with bash_write — its input accepts either a string OR an array like [ \"iHello\", { key: \"esc\" }, \":wq\", { key: \"enter\" } ] for atomic text+key sequences.",
        "type": "boolean"
      },
      "ptyRows": {
        "description": "PTY terminal height in rows — ignored when pty is false. Defaults to 24 when pty: true. Minimum 1, maximum 60.",
        "type": "integer",
        "minimum": 1,
        "maximum": 60
      },
      "ptyCols": {
        "description": "PTY terminal width in columns — ignored when pty is false. Defaults to 80 when pty: true. Minimum 1, maximum 140.",
        "type": "integer",
        "minimum": 1,
        "maximum": 140
      },
      "foreground_orchestrate": {
        "type": "boolean",
        "description": "Consumer-set flag enabling server-side foreground orchestration."
      },
      "block_to_completion": {
        "type": "boolean",
        "description": "Consumer-set flag forcing foreground bash to wait until terminal instead of promoting."
      }
    },
    "required": [
      "command"
    ]
  },
  "read": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "filePath": {
        "description": "Path to file or directory (absolute or relative to project root)",
        "type": "string"
      },
      "startLine": {
        "description": "1-based line to start reading from",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "endLine": {
        "description": "1-based line to stop reading at (inclusive)",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "limit": {
        "description": "Max lines to return (default: 2000)",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "offset": {
        "description": "1-based line number to start reading from (use with limit). Ignored if startLine is provided",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      }
    },
    "required": [
      "filePath"
    ]
  },
  "write": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "filePath": {
        "description": "Path to the file to write (absolute or relative to project root)",
        "type": "string"
      },
      "content": {
        "description": "The full content to write to the file",
        "type": "string"
      }
    },
    "required": [
      "filePath",
      "content"
    ]
  },
  "edit": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "filePath": {
        "description": "Path to the file to edit (absolute or relative to project root)",
        "type": "string"
      },
      "oldString": {
        "description": "Text to find (exact match, with fuzzy fallback)",
        "type": "string"
      },
      "newString": {
        "description": "Text to replace with (omit or set to empty string to delete the matched text)",
        "type": "string"
      },
      "replaceAll": {
        "description": "Replace all occurrences",
        "type": "boolean"
      },
      "occurrence": {
        "description": "0-indexed occurrence to replace when multiple matches exist",
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "symbol": {
        "description": "Named symbol to replace (function, class, type)",
        "type": "string"
      },
      "content": {
        "description": "Replacement content for symbol mode. For whole-file writes, use the `write` tool.",
        "type": "string"
      },
      "appendContent": {
        "description": "Text to append to the end of filePath; creates the file if needed",
        "type": "string"
      },
      "edits": {
        "description": "Batch edits — array of { oldString: string, newString: string } or { startLine: number (1-based), endLine: number (1-based, inclusive), content: string }",
        "type": "array",
        "items": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        }
      }
    }
  },
  "apply_patch": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "patchText": {
        "description": "The full patch text including Begin/End markers",
        "type": "string"
      }
    },
    "required": [
      "patchText"
    ]
  },
  "grep": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "pattern": {
        "type": "string"
      },
      "include": {
        "type": "string"
      },
      "path": {
        "type": "string"
      }
    },
    "required": [
      "pattern"
    ]
  },
  "glob": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "pattern": {
        "type": "string"
      },
      "path": {
        "type": "string"
      }
    },
    "required": [
      "pattern"
    ]
  },
  "search": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "query": {
        "description": "Concept, regex, literal text, filename, or capability to find. Examples: 'fuzzy match with whitespace tolerance', '^export', 'Cargo.lock'.",
        "type": "string"
      },
      "topK": {
        "description": "Number of results (default: 10, max: 100)",
        "type": "integer",
        "minimum": 1,
        "maximum": 100
      },
      "hint": {
        "description": "Optional routing hint. Defaults to 'auto'.",
        "type": "string",
        "enum": [
          "regex",
          "literal",
          "semantic",
          "auto"
        ]
      },
      "includeTests": {
        "description": "Include test files (*.test.*, *_test.rs, __tests__/, …) plus test-support, fixture, mock, snapshot, and corpus files. Defaults to false.",
        "type": "boolean"
      }
    },
    "required": [
      "query"
    ]
  },
  "outline": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "target": {
        "description": "What to outline: a file path, directory path, URL, or array of paths. The mode is auto-detected: URLs by `http://`/`https://` prefix, directories by stat, arrays as multi-file.",
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ]
      },
      "files": {
        "description": "Directory-only mode: when true, target must be a directory or array of directories and the result is a flat file tree with path, language, symbol count, and byte size instead of a symbol outline.",
        "type": "boolean"
      },
      "includeTests": {
        "description": "Directory outline only: include test files. Defaults to false; tests are hidden.",
        "type": "boolean"
      }
    },
    "required": [
      "target"
    ]
  },
  "zoom": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "filePath": {
        "description": "Path to file (absolute or relative to project root)",
        "type": "string"
      },
      "url": {
        "description": "HTTP/HTTPS URL of an HTML or Markdown document to fetch and zoom into",
        "type": "string"
      },
      "symbols": {
        "description": "Symbol name for code, or heading text for Markdown/HTML. Pass a string for one lookup or an array for batched lookups in the same file/URL.",
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ]
      },
      "targets": {
        "description": "Cross-file batch: `{ filePath, symbol }` or an array of them. Mutually exclusive with filePath/url/symbols.",
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "filePath": {
                "description": "Path to file (absolute or relative to project root)",
                "type": "string"
              },
              "symbol": {
                "description": "Symbol name in that file",
                "type": "string"
              }
            },
            "required": [
              "filePath",
              "symbol"
            ]
          },
          {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "filePath": {
                  "description": "Path to file (absolute or relative to project root)",
                  "type": "string"
                },
                "symbol": {
                  "description": "Symbol name in that file",
                  "type": "string"
                }
              },
              "required": [
                "filePath",
                "symbol"
              ]
            }
          }
        ]
      },
      "contextLines": {
        "description": "Lines of context before/after the symbol (default: 3)",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "callgraph": {
        "description": "Include call-graph annotations (calls-out / called-by within the same file). Default false; off keeps zoom output minimal.",
        "type": "boolean"
      }
    }
  },
  "inspect": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "sections": {
        "description": "Categories to include in detailed drill-down (e.g. 'todos' or ['todos', 'dead_code']). Use 'all' for every active category. Omit for summary-only mode.",
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ]
      },
      "scope": {
        "description": "Restrict scan/results to paths under this scope (file or directory, absolute or relative to project root). Tier 1 scopes the scan; Tier 2 scans project-wide and applies scope as a result filter.",
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ]
      },
      "topK": {
        "description": "Max drill-down items per category. Default 20, max 100.",
        "type": "integer",
        "exclusiveMinimum": 0,
        "maximum": 100
      }
    }
  },
  "callgraph": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "op": {
        "description": "Navigation operation",
        "type": "string",
        "enum": [
          "call_tree",
          "callers",
          "trace_to",
          "trace_to_symbol",
          "impact",
          "trace_data"
        ]
      },
      "filePath": {
        "description": "Path to the source file containing the symbol (absolute or relative to project root)",
        "type": "string"
      },
      "symbol": {
        "description": "Name of the symbol to analyze",
        "type": "string"
      },
      "depth": {
        "description": "Max traversal depth (default: call_tree=5, callers=1, trace_to=10, trace_to_symbol=10 capped at 16, impact=5, trace_data=5)",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "expression": {
        "description": "Expression to track through data flow (required for trace_data op)",
        "type": "string"
      },
      "toSymbol": {
        "description": "Target symbol name for trace_to_symbol; the returned path ends at this symbol",
        "type": "string"
      },
      "toFile": {
        "description": "Optional target file for trace_to_symbol; required when toSymbol exists in multiple files",
        "type": "string"
      },
      "includeTests": {
        "description": "Include test files in callers/paths. Defaults to false; tests are hidden.",
        "type": "boolean"
      },
      "includeUnresolved": {
        "description": "Show every unresolved external/stdlib call individually. Defaults to false; unresolved leaf calls are collapsed into one summary per parent.",
        "type": "boolean"
      }
    },
    "required": [
      "op",
      "filePath",
      "symbol"
    ]
  },
  "conflicts": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "path": {
        "description": "Optional path inside the git repository or worktree to inspect (absolute or relative to project root). Conflicts are discovered from that repository's top level. Defaults to the session project root.",
        "type": "string"
      }
    }
  },
  "ast_search": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "pattern": {
        "description": "AST pattern with meta-variables ($VAR, $$$). Must be complete AST node.",
        "type": "string"
      },
      "lang": {
        "description": "Target language",
        "type": "string",
        "enum": [
          "typescript",
          "tsx",
          "javascript",
          "python",
          "rust",
          "go",
          "pascal",
          "r"
        ]
      },
      "paths": {
        "description": "Paths to search (default: ['.'])",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "globs": {
        "description": "Include/exclude globs (prefix ! to exclude)",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "contextLines": {
        "description": "Number of context lines to show around each match",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      }
    },
    "required": [
      "pattern",
      "lang"
    ]
  },
  "ast_replace": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "pattern": {
        "description": "AST pattern with meta-variables ($VAR, $$$). Must be complete AST node.",
        "type": "string"
      },
      "rewrite": {
        "description": "Replacement pattern (can use $VAR from pattern)",
        "type": "string"
      },
      "lang": {
        "description": "Target language",
        "type": "string",
        "enum": [
          "typescript",
          "tsx",
          "javascript",
          "python",
          "rust",
          "go",
          "pascal",
          "r"
        ]
      },
      "paths": {
        "description": "Paths to search (default: ['.'])",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "globs": {
        "description": "Include/exclude globs (prefix ! to exclude)",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "dryRun": {
        "description": "Preview changes without applying (default: false)",
        "type": "boolean"
      }
    },
    "required": [
      "pattern",
      "rewrite",
      "lang"
    ]
  },
  "delete": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "files": {
        "description": "Paths to delete (one or more). May include directories when recursive=true.",
        "minItems": 1,
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "recursive": {
        "description": "Required to delete a directory and its contents. Defaults to false; passing a directory without this returns an error.",
        "type": "boolean"
      }
    },
    "required": [
      "files"
    ]
  },
  "move": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "filePath": {
        "description": "Source file path to move (absolute or relative to project root)",
        "type": "string"
      },
      "destination": {
        "description": "Destination file path (absolute or relative to project root)",
        "type": "string"
      }
    },
    "required": [
      "filePath",
      "destination"
    ]
  },
  "import": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "op": {
        "description": "Import operation",
        "type": "string",
        "enum": [
          "add",
          "remove",
          "organize"
        ]
      },
      "filePath": {
        "description": "Path to the file (absolute or relative to project root)",
        "type": "string"
      },
      "module": {
        "description": "Module path (required for add, remove — e.g. 'react', './utils', 'std::fmt')",
        "type": "string"
      },
      "names": {
        "description": "Named imports to add. Each entry uses the language's native named-import text, including per-name aliasing where the language uses `as` (e.g. ['useState', 'debounce as db'], Solidity ['ERC20', 'IERC20 as IToken']).",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "defaultImport": {
        "description": "Default import name, ES only (e.g. 'React')",
        "type": "string"
      },
      "namespace": {
        "description": "Namespace binding: `import * as ns from 'mod'` (ES), `import * as N from \"./X.sol\"` (Solidity).",
        "type": "string"
      },
      "alias": {
        "description": "Whole-module alias. Solidity: `import \"./X.sol\" as X` (module=path, alias=X).",
        "type": "string"
      },
      "modifiers": {
        "description": "Statement-level modifier tokens, language-validated: Java/C# 'static'; C# 'global'/'unsafe'; Java/Kotlin/Scala 'wildcard'; Swift '@testable'. Unsupported tokens for the file's language return a clear error.",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "importKind": {
        "description": "Symbol-kind-specific import: PHP 'function'/'const'; Swift 'struct'/'class'/'enum'/'protocol'/'func'; Scala 'given'.",
        "type": "string"
      },
      "typeOnly": {
        "description": "Type-only import (TS only, default: false)",
        "type": "boolean"
      },
      "removeName": {
        "description": "Named import to remove for 'remove' op; omit to remove entire import",
        "type": "string"
      },
      "validate": {
        "description": "Validation level: 'syntax' (default) or 'full'. Syntax = tree-sitter parse check only. Full = also runs LSP type-checking (slower, catches more errors)",
        "type": "string",
        "enum": [
          "syntax",
          "full"
        ]
      }
    },
    "required": [
      "op",
      "filePath"
    ]
  },
  "refactor": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "op": {
        "description": "Refactoring operation",
        "type": "string",
        "enum": [
          "move",
          "extract",
          "inline"
        ]
      },
      "filePath": {
        "description": "Path to the source file (absolute or relative to project root)",
        "type": "string"
      },
      "symbol": {
        "description": "Symbol name — required for 'move' and 'inline' ops",
        "type": "string"
      },
      "destination": {
        "description": "Target file path — required for 'move' op",
        "type": "string"
      },
      "scope": {
        "description": "Disambiguation scope for 'move' op — when multiple top-level symbols share the same name, specify the containing scope to disambiguate (e.g. 'MyClass'). Does NOT enable access to nested symbols or class methods.",
        "type": "string"
      },
      "name": {
        "description": "New function name — required for 'extract' op",
        "type": "string"
      },
      "startLine": {
        "description": "1-based start line — required for 'extract' op",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "endLine": {
        "description": "1-based end line (inclusive) — required for 'extract' op",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "callSiteLine": {
        "description": "1-based call site line — required for 'inline' op",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      }
    },
    "required": [
      "op",
      "filePath"
    ]
  },
  "safety": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "op": {
        "description": "Safety operation",
        "type": "string",
        "enum": [
          "undo",
          "history",
          "checkpoint",
          "restore",
          "list"
        ]
      },
      "filePath": {
        "description": "File path (required for history, optional for undo). Absolute or relative to project root",
        "type": "string"
      },
      "name": {
        "description": "Checkpoint name (required for checkpoint, restore)",
        "type": "string"
      },
      "files": {
        "description": "Specific files to include in checkpoint (optional, defaults to all tracked files)",
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "required": [
      "op"
    ]
  }
}