@@ -257,6 +257,89 @@ type FindResult struct {
257257 Truncated bool `json:"truncated"`
258258}
259259
260+ // ---------------------------------------------------------------------------
261+ // Replace types
262+ // ---------------------------------------------------------------------------
263+
264+ // ReplaceOptions controls replace_content behaviour.
265+ type ReplaceOptions struct {
266+ Literal bool `json:"literal,omitempty"`
267+ CaseSensitive * bool `json:"caseSensitive,omitempty"`
268+ WordRegexp bool `json:"wordRegexp,omitempty"`
269+ DryRun bool `json:"dryRun,omitempty"`
270+ Backup bool `json:"backup,omitempty"`
271+ ContextLines * int `json:"contextLines,omitempty"`
272+ FileGlob string `json:"fileGlob,omitempty"`
273+ ExcludeGlob string `json:"excludeGlob,omitempty"`
274+ SearchPath string `json:"searchPath,omitempty"`
275+ NoIgnore bool `json:"noIgnore,omitempty"`
276+ MaxPerFile int `json:"maxPerFile,omitempty"`
277+ }
278+
279+ // DiffLine is one line in a contextual diff produced by ReplaceContent.
280+ type DiffLine struct {
281+ Kind string `json:"kind"` // "context", "removed", "added", "separator"
282+ LineNumber int `json:"lineNumber"`
283+ Content string `json:"content"`
284+ }
285+
286+ // FileChange describes the replacements made (or previewed) in one file.
287+ type FileChange struct {
288+ Path string `json:"path"`
289+ Replacements int `json:"replacements"`
290+ Diff []DiffLine `json:"diff"`
291+ }
292+
293+ // ReplaceResult is returned by ReplaceContent.
294+ type ReplaceResult struct {
295+ FilesChanged int `json:"filesChanged"`
296+ TotalReplacements int `json:"totalReplacements"`
297+ Changes []FileChange `json:"changes"`
298+ DryRun bool `json:"dryRun"`
299+ }
300+
301+ // ---------------------------------------------------------------------------
302+ // Extract types
303+ // ---------------------------------------------------------------------------
304+
305+ // ExtractOptions controls extract_content behaviour.
306+ type ExtractOptions struct {
307+ Groups []int `json:"groups,omitempty"`
308+ Separator string `json:"separator,omitempty"`
309+ Format string `json:"format,omitempty"` // "text", "json", "csv", "tsv"
310+ Count bool `json:"count,omitempty"`
311+ Dedup bool `json:"dedup,omitempty"`
312+ Sort bool `json:"sort,omitempty"`
313+ CaseSensitive * bool `json:"caseSensitive,omitempty"`
314+ FileGlob string `json:"fileGlob,omitempty"`
315+ ExcludeGlob string `json:"excludeGlob,omitempty"`
316+ SearchPath string `json:"searchPath,omitempty"`
317+ NoIgnore bool `json:"noIgnore,omitempty"`
318+ Limit int `json:"limit,omitempty"`
319+ }
320+
321+ // ExtractMatch is one extracted row.
322+ type ExtractMatch struct {
323+ Path string `json:"path"`
324+ LineNumber int `json:"lineNumber"`
325+ Groups []string `json:"groups"`
326+ }
327+
328+ // CountEntry is a frequency entry returned when ExtractOptions.Count is true.
329+ type CountEntry struct {
330+ Value string `json:"value"`
331+ Count int `json:"count"`
332+ }
333+
334+ // ExtractResult is returned by ExtractContent.
335+ type ExtractResult struct {
336+ Matches []ExtractMatch `json:"matches,omitempty"`
337+ Counts []CountEntry `json:"counts,omitempty"`
338+ Total int `json:"total"`
339+ FilesSearched int `json:"filesSearched"`
340+ Truncated bool `json:"truncated"`
341+ }
342+
260343// CartographerError is returned when a Cartographer FFI call fails.
261344type CartographerError struct {
262345 Message string
0 commit comments