rigcode 0.1.0__py3-none-any.whl
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.
- rigcode/__init__.py +4 -0
- rigcode/__main__.py +4 -0
- rigcode/agent/__init__.py +0 -0
- rigcode/agent/loop.py +627 -0
- rigcode/agent/mentions.py +70 -0
- rigcode/agent/prompts.py +195 -0
- rigcode/agent/runtime.py +535 -0
- rigcode/agent/session.py +165 -0
- rigcode/agent/state.py +161 -0
- rigcode/cli.py +283 -0
- rigcode/config.py +284 -0
- rigcode/doctor.py +158 -0
- rigcode/extensions.py +275 -0
- rigcode/hooks.py +142 -0
- rigcode/llm/__init__.py +0 -0
- rigcode/llm/client.py +259 -0
- rigcode/llm/probe.py +229 -0
- rigcode/llm/stream.py +240 -0
- rigcode/llm/textmode.py +161 -0
- rigcode/llm/types.py +92 -0
- rigcode/llm/wire.py +76 -0
- rigcode/mcp.py +329 -0
- rigcode/permissions.py +221 -0
- rigcode/prompts/agents/coder.md +13 -0
- rigcode/prompts/agents/debugger.md +14 -0
- rigcode/prompts/agents/explore.md +22 -0
- rigcode/prompts/agents/plan.md +21 -0
- rigcode/prompts/agents/researcher.md +14 -0
- rigcode/prompts/agents/reviewer.md +18 -0
- rigcode/prompts/agents/verifier.md +15 -0
- rigcode/prompts/commit.md +5 -0
- rigcode/prompts/compact.md +24 -0
- rigcode/prompts/init.md +10 -0
- rigcode/prompts/system.md +27 -0
- rigcode/tools/__init__.py +0 -0
- rigcode/tools/base.py +245 -0
- rigcode/tools/bashsafety.py +262 -0
- rigcode/tools/editmatch.py +367 -0
- rigcode/tools/files.py +534 -0
- rigcode/tools/interact.py +69 -0
- rigcode/tools/search.py +309 -0
- rigcode/tools/shell.py +424 -0
- rigcode/tools/skill.py +37 -0
- rigcode/tools/task.py +54 -0
- rigcode/tools/todo.py +62 -0
- rigcode/tools/web.py +346 -0
- rigcode/ui/__init__.py +0 -0
- rigcode/ui/base.py +69 -0
- rigcode/ui/commands.py +581 -0
- rigcode/ui/plain.py +321 -0
- rigcode/ui/render.py +207 -0
- rigcode/ui/terminal.py +1154 -0
- rigcode/utils/__init__.py +0 -0
- rigcode/utils/files.py +176 -0
- rigcode/utils/frontmatter.py +38 -0
- rigcode/utils/globmatch.py +91 -0
- rigcode/utils/jsonrepair.py +110 -0
- rigcode/utils/paths.py +83 -0
- rigcode/utils/text.py +105 -0
- rigcode-0.1.0.dist-info/METADATA +203 -0
- rigcode-0.1.0.dist-info/RECORD +64 -0
- rigcode-0.1.0.dist-info/WHEEL +4 -0
- rigcode-0.1.0.dist-info/entry_points.txt +2 -0
- rigcode-0.1.0.dist-info/licenses/LICENSE +21 -0
rigcode/tools/search.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"""Search tools: Glob (find files) and Grep (search contents)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import asyncio
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
from pathlib import Path, PurePosixPath
|
|
9
|
+
|
|
10
|
+
from rigcode.tools.base import Tool, ToolContext, ToolResult
|
|
11
|
+
from rigcode.utils.files import is_binary_file, list_project_files
|
|
12
|
+
from rigcode.utils.globmatch import basename_match, glob_match
|
|
13
|
+
from rigcode.utils.paths import display_path, resolve_path
|
|
14
|
+
from rigcode.utils.text import truncate_line
|
|
15
|
+
|
|
16
|
+
TYPE_GLOBS = {
|
|
17
|
+
"py": ["*.py", "*.pyi"], "python": ["*.py", "*.pyi"],
|
|
18
|
+
"js": ["*.js", "*.mjs", "*.cjs", "*.jsx"], "ts": ["*.ts", "*.tsx", "*.mts", "*.cts"],
|
|
19
|
+
"jsx": ["*.jsx"], "tsx": ["*.tsx"], "rust": ["*.rs"], "rs": ["*.rs"], "go": ["*.go"],
|
|
20
|
+
"java": ["*.java"], "kotlin": ["*.kt", "*.kts"], "c": ["*.c", "*.h"],
|
|
21
|
+
"cpp": ["*.cpp", "*.cc", "*.cxx", "*.hpp", "*.hh", "*.hxx", "*.h"], "cs": ["*.cs"], "csharp": ["*.cs"],
|
|
22
|
+
"rb": ["*.rb"], "ruby": ["*.rb"], "php": ["*.php"], "swift": ["*.swift"], "scala": ["*.scala"],
|
|
23
|
+
"md": ["*.md", "*.markdown"], "markdown": ["*.md", "*.markdown"], "json": ["*.json"],
|
|
24
|
+
"yaml": ["*.yaml", "*.yml"], "toml": ["*.toml"], "xml": ["*.xml"], "html": ["*.html", "*.htm"],
|
|
25
|
+
"css": ["*.css", "*.scss", "*.sass", "*.less"], "sh": ["*.sh", "*.bash", "*.zsh"],
|
|
26
|
+
"ps1": ["*.ps1", "*.psm1"], "sql": ["*.sql"], "lua": ["*.lua"], "r": ["*.r", "*.R"],
|
|
27
|
+
"vue": ["*.vue"], "svelte": ["*.svelte"], "dart": ["*.dart"], "matlab": ["*.m"], "jl": ["*.jl"],
|
|
28
|
+
"txt": ["*.txt"], "ipynb": ["*.ipynb"],
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
MAX_SCAN_FILES = 40_000
|
|
32
|
+
MAX_FILE_BYTES = 4 * 1024 * 1024
|
|
33
|
+
MAX_CONTEXT = 50
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _rel(path: str | Path, ctx: ToolContext) -> str:
|
|
37
|
+
return display_path(Path(path), ctx.cwd)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _mtime(p: Path) -> float:
|
|
41
|
+
try:
|
|
42
|
+
return p.stat().st_mtime
|
|
43
|
+
except OSError:
|
|
44
|
+
return 0.0
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _matches_filters(rel: str, glob: str | None, globs_for_type: list[str] | None) -> bool:
|
|
48
|
+
if glob:
|
|
49
|
+
g = glob.replace("\\", "/")
|
|
50
|
+
ok = glob_match(g, rel) if "/" in g else basename_match(g, rel)
|
|
51
|
+
if not ok:
|
|
52
|
+
return False
|
|
53
|
+
if globs_for_type:
|
|
54
|
+
if not any(basename_match(g, rel) for g in globs_for_type):
|
|
55
|
+
return False
|
|
56
|
+
return True
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class GlobTool(Tool):
|
|
60
|
+
name = "Glob"
|
|
61
|
+
kind = "read"
|
|
62
|
+
read_only = True
|
|
63
|
+
description = (
|
|
64
|
+
"Find files and directories by glob pattern (e.g. '**/*.py', 'src/**/test_*.ts', '*.{json,yaml}', "
|
|
65
|
+
"'**/migrations'). Respects .gitignore. Returns paths sorted by modification time, newest first; "
|
|
66
|
+
"directories end with '/'. Use it to locate files by name."
|
|
67
|
+
)
|
|
68
|
+
parameters = {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"properties": {
|
|
71
|
+
"pattern": {"type": "string", "description": "Glob pattern, relative to path"},
|
|
72
|
+
"path": {"type": "string", "description": "Directory to search (default: working directory)"},
|
|
73
|
+
},
|
|
74
|
+
"required": ["pattern"],
|
|
75
|
+
}
|
|
76
|
+
aliases = {"glob": "pattern", "dir": "path", "directory": "path", "cwd": "path"}
|
|
77
|
+
|
|
78
|
+
def permission_target(self, args: dict) -> str:
|
|
79
|
+
return str(args.get("pattern", ""))
|
|
80
|
+
|
|
81
|
+
async def run(self, args: dict, ctx: ToolContext) -> ToolResult:
|
|
82
|
+
base = resolve_path(args.get("path") or ".", ctx.cwd)
|
|
83
|
+
if not base.is_dir():
|
|
84
|
+
return ToolResult.error(f"Not a directory: {_rel(base, ctx)}")
|
|
85
|
+
pattern = str(args["pattern"]).strip().replace("\\", "/")
|
|
86
|
+
# Absolute pattern inside base -> make relative.
|
|
87
|
+
if os.path.isabs(pattern):
|
|
88
|
+
try:
|
|
89
|
+
pattern = os.path.relpath(pattern, base).replace("\\", "/")
|
|
90
|
+
except ValueError:
|
|
91
|
+
return ToolResult.error("pattern must be relative to path")
|
|
92
|
+
limit = int(ctx.rt.settings.get("tools.glob_max_results", 100))
|
|
93
|
+
files = await asyncio.to_thread(list_project_files, base, MAX_SCAN_FILES)
|
|
94
|
+
# Directories that hold at least one listed file, so ignored and empty ones stay out.
|
|
95
|
+
dirs = sorted({str(PurePosixPath(f).parents[i]) for f in files
|
|
96
|
+
for i in range(len(PurePosixPath(f).parents) - 1)})
|
|
97
|
+
entries = [(f, False) for f in files] + [(d, True) for d in dirs]
|
|
98
|
+
pattern = pattern.rstrip("/") or pattern
|
|
99
|
+
hits = [(e, is_dir) for e, is_dir in entries if glob_match(pattern, e)]
|
|
100
|
+
note = ""
|
|
101
|
+
if not hits and "/" not in pattern and not pattern.startswith("**"):
|
|
102
|
+
hits = [(e, is_dir) for e, is_dir in entries if glob_match("**/" + pattern, e)]
|
|
103
|
+
if hits:
|
|
104
|
+
note = f"(No top-level matches for '{pattern}'; showing matches at any depth via '**/{pattern}'.)\n"
|
|
105
|
+
if not hits:
|
|
106
|
+
return ToolResult(content=f"Nothing matches '{pattern}' under {_rel(base, ctx)}.", summary="No matches")
|
|
107
|
+
paths = sorted(((base / e, is_dir) for e, is_dir in hits), key=lambda h: _mtime(h[0]), reverse=True)
|
|
108
|
+
shown = [_rel(p, ctx) + ("/" if is_dir else "") for p, is_dir in paths[:limit]]
|
|
109
|
+
more = f"\n({len(paths) - limit} more not shown - narrow the pattern)" if len(paths) > limit else ""
|
|
110
|
+
return ToolResult(content=note + "\n".join(shown) + more,
|
|
111
|
+
summary=f"Found {len(paths)} match{'es' if len(paths) != 1 else ''}")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class GrepTool(Tool):
|
|
115
|
+
name = "Grep"
|
|
116
|
+
kind = "read"
|
|
117
|
+
read_only = True
|
|
118
|
+
description = (
|
|
119
|
+
"Search file contents with a regular expression (ripgrep syntax). Respects .gitignore. output_mode: "
|
|
120
|
+
"'files_with_matches' (default; just paths), 'content' (matching lines with line numbers), or 'count'. "
|
|
121
|
+
"Narrow with glob (e.g. '*.py') or type (e.g. 'py', 'ts'). Escape regex characters for literal text "
|
|
122
|
+
"(e.g. 'foo\\(' ). Prefer this over running grep through Bash."
|
|
123
|
+
)
|
|
124
|
+
parameters = {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"properties": {
|
|
127
|
+
"pattern": {"type": "string", "description": "Regular expression to search for"},
|
|
128
|
+
"path": {"type": "string", "description": "File or directory to search (default: working directory)"},
|
|
129
|
+
"glob": {"type": "string", "description": "Only search files matching this glob"},
|
|
130
|
+
"type": {"type": "string", "description": "Only search this file type: py, js, ts, go, rust, java, md..."},
|
|
131
|
+
"output_mode": {"type": "string", "enum": ["files_with_matches", "content", "count"]},
|
|
132
|
+
"ignore_case": {"type": "boolean", "description": "Case-insensitive search"},
|
|
133
|
+
"context": {"type": "integer", "description": "Lines of context around each match (content mode)"},
|
|
134
|
+
"multiline": {"type": "boolean", "description": "Let patterns span lines ('.' matches newline)"},
|
|
135
|
+
"max_results": {"type": "integer", "description": "Maximum files/lines to return (default 100)"},
|
|
136
|
+
},
|
|
137
|
+
"required": ["pattern"],
|
|
138
|
+
}
|
|
139
|
+
aliases = {"query": "pattern", "regex": "pattern", "dir": "path", "directory": "path", "include": "glob",
|
|
140
|
+
"file_pattern": "glob", "-i": "ignore_case", "case_insensitive": "ignore_case",
|
|
141
|
+
"head_limit": "max_results", "-C": "context", "context_lines": "context"}
|
|
142
|
+
|
|
143
|
+
def permission_target(self, args: dict) -> str:
|
|
144
|
+
return str(args.get("pattern", ""))
|
|
145
|
+
|
|
146
|
+
async def run(self, args: dict, ctx: ToolContext) -> ToolResult:
|
|
147
|
+
for alias in ("-A", "-B"):
|
|
148
|
+
if alias in args and "context" not in args:
|
|
149
|
+
try:
|
|
150
|
+
args["context"] = int(args[alias])
|
|
151
|
+
except (TypeError, ValueError):
|
|
152
|
+
pass
|
|
153
|
+
target = resolve_path(args.get("path") or ".", ctx.cwd)
|
|
154
|
+
if not target.exists():
|
|
155
|
+
return ToolResult.error(f"Path does not exist: {_rel(target, ctx)}")
|
|
156
|
+
mode = args.get("output_mode") or "files_with_matches"
|
|
157
|
+
if mode not in ("files_with_matches", "content", "count"):
|
|
158
|
+
mode = "files_with_matches"
|
|
159
|
+
max_results = int(args.get("max_results") or 100)
|
|
160
|
+
ftype = args.get("type")
|
|
161
|
+
type_globs = TYPE_GLOBS.get(str(ftype).lower().lstrip(".")) if ftype else None
|
|
162
|
+
if ftype and type_globs is None:
|
|
163
|
+
type_globs = [f"*.{str(ftype).lstrip('.')}"]
|
|
164
|
+
pattern = str(args["pattern"])
|
|
165
|
+
flags = re.IGNORECASE if args.get("ignore_case") else 0
|
|
166
|
+
if args.get("multiline"):
|
|
167
|
+
flags |= re.DOTALL | re.MULTILINE
|
|
168
|
+
note = ""
|
|
169
|
+
try:
|
|
170
|
+
regex = re.compile(pattern, flags)
|
|
171
|
+
except re.error as e:
|
|
172
|
+
regex = re.compile(re.escape(pattern), flags)
|
|
173
|
+
note = f"(Invalid regex ({e}); searched for the literal text instead.)\n"
|
|
174
|
+
requested = int(args.get("context") or 0)
|
|
175
|
+
ctxl = max(0, min(requested, MAX_CONTEXT))
|
|
176
|
+
rg = shutil.which("rg")
|
|
177
|
+
found = None
|
|
178
|
+
if rg and not note:
|
|
179
|
+
found = await self._ripgrep(rg, args, target, mode, type_globs, ctxl, max_results, ctx)
|
|
180
|
+
if found is None:
|
|
181
|
+
found = await asyncio.to_thread(self._python_search, regex, target, args.get("glob"), type_globs,
|
|
182
|
+
mode, ctxl, max_results, bool(args.get("multiline")), note, ctx)
|
|
183
|
+
result, seen = found
|
|
184
|
+
for path in seen: # the model now has these lines verbatim: enough for an exact-match Edit
|
|
185
|
+
ctx.rt.file_state.record(path, partial=True)
|
|
186
|
+
if requested > MAX_CONTEXT and seen:
|
|
187
|
+
result.content = f"(context capped at {MAX_CONTEXT} lines; Read the file for more)\n" + result.content
|
|
188
|
+
return result
|
|
189
|
+
|
|
190
|
+
async def _ripgrep(self, rg, args, target: Path, mode, type_globs, ctxl, max_results,
|
|
191
|
+
ctx) -> tuple[ToolResult, list[Path]] | None:
|
|
192
|
+
cmd = [rg, "--no-config", "--color", "never", "--no-messages", "--max-columns", "400",
|
|
193
|
+
"--max-columns-preview", "--max-filesize", "4M"]
|
|
194
|
+
if args.get("ignore_case"):
|
|
195
|
+
cmd.append("-i")
|
|
196
|
+
if args.get("multiline"):
|
|
197
|
+
cmd += ["-U", "--multiline-dotall"]
|
|
198
|
+
if mode == "files_with_matches":
|
|
199
|
+
cmd.append("--files-with-matches")
|
|
200
|
+
elif mode == "count":
|
|
201
|
+
cmd.append("--count")
|
|
202
|
+
else:
|
|
203
|
+
cmd += ["--line-number", "--with-filename"]
|
|
204
|
+
if ctxl:
|
|
205
|
+
cmd += ["-C", str(ctxl)]
|
|
206
|
+
if args.get("glob"):
|
|
207
|
+
cmd += ["--glob", str(args["glob"])]
|
|
208
|
+
for g in type_globs or []:
|
|
209
|
+
cmd += ["--glob", g]
|
|
210
|
+
cmd += ["--", str(args["pattern"]), str(target)]
|
|
211
|
+
try:
|
|
212
|
+
proc = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE,
|
|
213
|
+
stderr=asyncio.subprocess.PIPE)
|
|
214
|
+
out, err = await asyncio.wait_for(proc.communicate(), timeout=60)
|
|
215
|
+
except (OSError, asyncio.TimeoutError):
|
|
216
|
+
return None
|
|
217
|
+
if proc.returncode not in (0, 1):
|
|
218
|
+
return None # bad regex for rg etc. -> python fallback
|
|
219
|
+
lines = [l for l in out.decode("utf-8", errors="replace").splitlines() if l]
|
|
220
|
+
if not lines:
|
|
221
|
+
return ToolResult(content="No matches found.", summary="No matches"), []
|
|
222
|
+
if mode == "files_with_matches":
|
|
223
|
+
paths = sorted((Path(l) for l in lines), key=_mtime, reverse=True)
|
|
224
|
+
shown = [_rel(p, ctx) for p in paths[:max_results]]
|
|
225
|
+
more = f"\n({len(paths) - max_results} more files not shown)" if len(paths) > max_results else ""
|
|
226
|
+
return ToolResult(content="\n".join(shown) + more, summary=f"Found {len(paths)} files"), []
|
|
227
|
+
rel_lines = []
|
|
228
|
+
seen: dict[str, Path] = {}
|
|
229
|
+
for l in lines[:max_results]:
|
|
230
|
+
m = re.match(r"^(.*?)([:-])(\d+)([:-])(.*)$", l) if mode == "content" else re.match(r"^(.*):(\d+)$", l)
|
|
231
|
+
if mode == "content" and m and os.path.exists(m.group(1)):
|
|
232
|
+
seen.setdefault(m.group(1), Path(m.group(1)))
|
|
233
|
+
rel_lines.append(f"{_rel(m.group(1), ctx)}{m.group(2)}{m.group(3)}{m.group(4)}{m.group(5)}")
|
|
234
|
+
elif mode == "count" and m:
|
|
235
|
+
rel_lines.append(f"{_rel(m.group(1), ctx)}:{m.group(2)}")
|
|
236
|
+
else:
|
|
237
|
+
rel_lines.append(l)
|
|
238
|
+
more = f"\n({len(lines) - max_results} more lines not shown - narrow the search)" if len(lines) > max_results else ""
|
|
239
|
+
unit = "lines" if mode == "content" else "files"
|
|
240
|
+
return ToolResult(content="\n".join(rel_lines) + more, summary=f"Found {len(lines)} {unit}"), list(seen.values())
|
|
241
|
+
|
|
242
|
+
def _python_search(self, regex: re.Pattern, target: Path, glob, type_globs, mode, ctxl, max_results,
|
|
243
|
+
multiline: bool, note: str, ctx: ToolContext) -> tuple[ToolResult, list[Path]]:
|
|
244
|
+
if target.is_file():
|
|
245
|
+
candidates = [target]
|
|
246
|
+
else:
|
|
247
|
+
rels = list_project_files(target, MAX_SCAN_FILES)
|
|
248
|
+
candidates = [target / r for r in rels if _matches_filters(r, glob, type_globs)]
|
|
249
|
+
file_hits: list[Path] = []
|
|
250
|
+
count_hits: list[tuple[Path, int]] = []
|
|
251
|
+
content_lines: list[str] = []
|
|
252
|
+
seen: list[Path] = []
|
|
253
|
+
total_lines = 0
|
|
254
|
+
for path in candidates:
|
|
255
|
+
try:
|
|
256
|
+
if path.stat().st_size > MAX_FILE_BYTES or is_binary_file(path):
|
|
257
|
+
continue
|
|
258
|
+
text = path.read_text(encoding="utf-8", errors="replace")
|
|
259
|
+
except OSError:
|
|
260
|
+
continue
|
|
261
|
+
if mode == "files_with_matches":
|
|
262
|
+
if regex.search(text):
|
|
263
|
+
file_hits.append(path)
|
|
264
|
+
continue
|
|
265
|
+
lines = text.split("\n")
|
|
266
|
+
if multiline:
|
|
267
|
+
matched = set()
|
|
268
|
+
for m in regex.finditer(text):
|
|
269
|
+
a = text.count("\n", 0, m.start())
|
|
270
|
+
b = text.count("\n", 0, m.end())
|
|
271
|
+
matched.update(range(a, b + 1))
|
|
272
|
+
hit_idx = sorted(matched)
|
|
273
|
+
else:
|
|
274
|
+
hit_idx = [i for i, line in enumerate(lines) if regex.search(line)]
|
|
275
|
+
if not hit_idx:
|
|
276
|
+
continue
|
|
277
|
+
if mode == "count":
|
|
278
|
+
count_hits.append((path, len(hit_idx)))
|
|
279
|
+
continue
|
|
280
|
+
rel = _rel(path, ctx)
|
|
281
|
+
shown: set[int] = set()
|
|
282
|
+
for i in hit_idx:
|
|
283
|
+
for j in range(max(0, i - ctxl), min(len(lines), i + ctxl + 1)):
|
|
284
|
+
if j in shown:
|
|
285
|
+
continue
|
|
286
|
+
shown.add(j)
|
|
287
|
+
sep = ":" if j == i or j in hit_idx else "-"
|
|
288
|
+
total_lines += 1
|
|
289
|
+
if len(content_lines) < max_results:
|
|
290
|
+
content_lines.append(f"{rel}{sep}{j + 1}{sep}{truncate_line(lines[j], 400)}")
|
|
291
|
+
if not seen or seen[-1] != path:
|
|
292
|
+
seen.append(path)
|
|
293
|
+
if mode == "files_with_matches":
|
|
294
|
+
if not file_hits:
|
|
295
|
+
return ToolResult(content=note + "No matches found.", summary="No matches"), []
|
|
296
|
+
file_hits.sort(key=_mtime, reverse=True)
|
|
297
|
+
shown_paths = [_rel(p, ctx) for p in file_hits[:max_results]]
|
|
298
|
+
more = f"\n({len(file_hits) - max_results} more files not shown)" if len(file_hits) > max_results else ""
|
|
299
|
+
return ToolResult(content=note + "\n".join(shown_paths) + more,
|
|
300
|
+
summary=f"Found {len(file_hits)} files"), []
|
|
301
|
+
if mode == "count":
|
|
302
|
+
if not count_hits:
|
|
303
|
+
return ToolResult(content=note + "No matches found.", summary="No matches"), []
|
|
304
|
+
out = [f"{_rel(p, ctx)}:{n}" for p, n in count_hits[:max_results]]
|
|
305
|
+
return ToolResult(content=note + "\n".join(out), summary=f"Matches in {len(count_hits)} files"), []
|
|
306
|
+
if not content_lines:
|
|
307
|
+
return ToolResult(content=note + "No matches found.", summary="No matches"), []
|
|
308
|
+
more = f"\n({total_lines - max_results} more lines not shown - narrow the search)" if total_lines > max_results else ""
|
|
309
|
+
return ToolResult(content=note + "\n".join(content_lines) + more, summary=f"Found {total_lines} lines"), seen
|