Skip to content

Commit 12d0405

Browse files
committed
fix: wrap long docstrings for ruff E501 + add context.task values
1 parent 6987859 commit 12d0405

1 file changed

Lines changed: 89 additions & 16 deletions

File tree

src/roam/mcp_server.py

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,35 @@ def _run_roam(args: list[str], root: str = ".") -> dict:
166166

167167
@_tool(name="roam_understand")
168168
def understand(root: str = ".") -> dict:
169-
"""Get a full codebase briefing in a single call. Call this FIRST when starting work on a new or unfamiliar codebase. Covers tech stack, architecture (layers, clusters, entry points), health score, hotspots, conventions, and patterns. ~2-4K token output. Do NOT explore manually with Glob/Grep/Read -- use this instead. Follow with search_symbol or context to drill into specifics."""
169+
"""Get a full codebase briefing in a single call.
170+
171+
Call this FIRST when starting work on a new or unfamiliar codebase.
172+
Covers tech stack, architecture (layers, clusters, entry points),
173+
health score, hotspots, conventions, and patterns. ~2-4K token output.
174+
Do NOT explore manually with Glob/Grep/Read -- use this instead.
175+
Follow with search_symbol or context to drill into specifics."""
170176
return _run_roam(["understand"], root)
171177

172178

173179
@_tool(name="roam_health")
174180
def health(root: str = ".") -> dict:
175-
"""Codebase health score (0-100) with issue breakdown. Call this to assess overall code quality before deciding where to focus refactoring, or to check whether recent changes degraded health. Skip if you already called understand (includes health) or preflight (includes it per-symbol)."""
181+
"""Codebase health score (0-100) with issue breakdown.
182+
183+
Call this to assess overall code quality before deciding where to
184+
focus refactoring, or to check whether recent changes degraded health.
185+
Skip if you already called understand (includes health) or preflight
186+
(includes it per-symbol)."""
176187
return _run_roam(["health"], root)
177188

178189

179190
@_tool(name="roam_preflight")
180191
def preflight(target: str = "", staged: bool = False, root: str = ".") -> dict:
181-
"""Pre-change safety check. Call this BEFORE modifying any symbol or file. Combines blast radius, affected tests, complexity, coupling, and fitness violations in one call. Replaces 5-6 separate tool calls. Do NOT call context, impact, affected_tests, or complexity_report separately if preflight covers your need."""
192+
"""Pre-change safety check. Call this BEFORE modifying any symbol or file.
193+
194+
Combines blast radius, affected tests, complexity, coupling, and
195+
fitness violations in one call. Replaces 5-6 separate tool calls.
196+
Do NOT call context, impact, affected_tests, or complexity_report
197+
separately if preflight covers your need."""
182198
args = ["preflight"]
183199
if target:
184200
args.append(target)
@@ -189,13 +205,25 @@ def preflight(target: str = "", staged: bool = False, root: str = ".") -> dict:
189205

190206
@_tool(name="roam_search_symbol")
191207
def search_symbol(query: str, root: str = ".") -> dict:
192-
"""Find symbols by name (case-insensitive substring match). Call this when you know part of a symbol name and need the exact qualified name, file location, or kind. Use before context or impact to get the correct identifier. Do NOT use Grep for function definitions -- this is faster and returns structured data with PageRank importance."""
208+
"""Find symbols by name (case-insensitive substring match).
209+
210+
Call this when you know part of a symbol name and need the exact
211+
qualified name, file location, or kind. Use before context or impact
212+
to get the correct identifier. Do NOT use Grep for function
213+
definitions -- this is faster and returns structured data with
214+
PageRank importance."""
193215
return _run_roam(["search", query], root)
194216

195217

196218
@_tool(name="roam_context")
197219
def context(symbol: str, task: str = "", root: str = ".") -> dict:
198-
"""Get the minimal context needed to work with a specific symbol. Call this when you need to understand or modify a function, class, or method. Returns exact files and line ranges to read. More targeted than understand. For pre-change safety checks, prefer preflight instead (includes context plus blast radius and tests)."""
220+
"""Get the minimal context needed to work with a specific symbol.
221+
222+
Call this when you need to understand or modify a function, class,
223+
or method. Returns exact files and line ranges to read. More targeted
224+
than understand. 'task' tailors output: "refactor", "debug", "extend",
225+
"review", or "understand". For pre-change safety checks, prefer
226+
preflight instead (includes context plus blast radius and tests)."""
199227
args = ["context", symbol]
200228
if task:
201229
args.extend(["--task", task])
@@ -204,19 +232,31 @@ def context(symbol: str, task: str = "", root: str = ".") -> dict:
204232

205233
@_tool(name="roam_trace")
206234
def trace(source: str, target: str, root: str = ".") -> dict:
207-
"""Find the shortest dependency path between two symbols. Call this to understand HOW a change in one symbol could affect another. Shows path hops with symbol names, edge types, locations, and coupling strength."""
235+
"""Find the shortest dependency path between two symbols.
236+
237+
Call this to understand HOW a change in one symbol could affect
238+
another. Shows path hops with symbol names, edge types, locations,
239+
and coupling strength."""
208240
return _run_roam(["trace", source, target], root)
209241

210242

211243
@_tool(name="roam_impact")
212244
def impact(symbol: str, root: str = ".") -> dict:
213-
"""Show the blast radius of changing a symbol -- everything that would break if its signature or behavior changed. Affected symbols by hop distance, affected files, severity. For pre-change checks, prefer preflight (includes impact plus tests and fitness)."""
245+
"""Show the blast radius of changing a symbol.
246+
247+
Everything that would break if its signature or behavior changed.
248+
Affected symbols by hop distance, affected files, severity. For
249+
pre-change checks, prefer preflight (includes impact plus tests
250+
and fitness)."""
214251
return _run_roam(["impact", symbol], root)
215252

216253

217254
@_tool(name="roam_file_info")
218255
def file_info(path: str, root: str = ".") -> dict:
219-
"""Show a file skeleton: every symbol definition with its signature. Call this to understand what a file contains without reading the full source. More useful than Read for getting a file overview."""
256+
"""Show a file skeleton: every symbol definition with its signature.
257+
258+
Call this to understand what a file contains without reading the
259+
full source. More useful than Read for getting a file overview."""
220260
return _run_roam(["file", path], root)
221261

222262

@@ -227,7 +267,11 @@ def file_info(path: str, root: str = ".") -> dict:
227267

228268
@_tool(name="roam_pr_risk")
229269
def pr_risk(staged: bool = False, root: str = ".") -> dict:
230-
"""Compute a risk score (0-100) for pending changes. Call this before committing or creating a PR. Produces LOW/MODERATE/HIGH/CRITICAL rating with per-file breakdown, risk factors, and suggested reviewers."""
270+
"""Compute a risk score (0-100) for pending changes.
271+
272+
Call this before committing or creating a PR. Produces LOW/MODERATE/
273+
HIGH/CRITICAL rating with per-file breakdown, risk factors, and
274+
suggested reviewers."""
231275
args = ["pr-risk"]
232276
if staged:
233277
args.append("--staged")
@@ -256,7 +300,12 @@ def breaking_changes(target: str = "HEAD~1", root: str = ".") -> dict:
256300

257301
@_tool(name="roam_affected_tests")
258302
def affected_tests(target: str = "", staged: bool = False, root: str = ".") -> dict:
259-
"""Find test files that exercise changed code. Call this to know which tests to run after making changes. Walks reverse dependency edges from changed code to find test files. For a full pre-change check, prefer preflight (includes affected tests plus blast radius and fitness)."""
303+
"""Find test files that exercise changed code.
304+
305+
Call this to know which tests to run after making changes. Walks
306+
reverse dependency edges from changed code to find test files. For
307+
a full pre-change check, prefer preflight (includes affected tests
308+
plus blast radius and fitness)."""
260309
args = ["affected-tests"]
261310
if target:
262311
args.append(target)
@@ -321,13 +370,21 @@ def dark_matter(min_npmi: float = 0.3, min_cochanges: int = 3, root: str = ".")
321370

322371
@_tool(name="roam_dead_code")
323372
def dead_code(root: str = ".") -> dict:
324-
"""List unreferenced exported symbols (dead code candidates). Call this to find code that can be safely removed. Finds symbols with zero incoming edges, filtering out known entry points and framework lifecycle hooks. Includes safety verdict per symbol."""
373+
"""List unreferenced exported symbols (dead code candidates).
374+
375+
Call this to find code that can be safely removed. Finds symbols
376+
with zero incoming edges, filtering out known entry points and
377+
framework lifecycle hooks. Includes safety verdict per symbol."""
325378
return _run_roam(["dead"], root)
326379

327380

328381
@_tool(name="roam_complexity_report")
329382
def complexity_report(threshold: int = 15, root: str = ".") -> dict:
330-
"""Rank functions by cognitive complexity. Call this to find the most complex functions that should be refactored. For checking a single symbol, prefer context or preflight which include complexity data."""
383+
"""Rank functions by cognitive complexity.
384+
385+
Call this to find the most complex functions that should be
386+
refactored. For checking a single symbol, prefer context or
387+
preflight which include complexity data."""
331388
return _run_roam(["complexity", "--threshold", str(threshold)], root)
332389

333390

@@ -425,7 +482,12 @@ def visualize(
425482

426483
@_tool(name="roam_diagnose")
427484
def diagnose(symbol: str, depth: int = 2, root: str = ".") -> dict:
428-
"""Root cause analysis for a failing symbol or test. Call this when debugging a bug or test failure to find the likely root cause. Ranks upstream/downstream suspects by risk (git churn, complexity, health, co-change entropy). Faster than manually tracing call chains. Returns verdict naming top suspect."""
485+
"""Root cause analysis for a failing symbol or test.
486+
487+
Call this when debugging a bug or test failure to find the likely
488+
root cause. Ranks upstream/downstream suspects by risk (git churn,
489+
complexity, health, co-change entropy). Faster than manually tracing
490+
call chains. Returns verdict naming top suspect."""
429491
args = ["diagnose", symbol, "--depth", str(depth)]
430492
return _run_roam(args, root)
431493

@@ -1432,7 +1494,11 @@ def search_semantic(query: str, top: int = 10, threshold: float = 0.05,
14321494

14331495
@_tool(name="roam_diff")
14341496
def roam_diff(commit_range: str = "", staged: bool = False, root: str = ".") -> dict:
1435-
"""Blast radius of uncommitted or committed changes. Call this after making code changes to see what's affected BEFORE committing. Shows affected symbols, files, tests, coupling warnings, and fitness violations. For pre-PR analysis, use pr_risk instead."""
1497+
"""Blast radius of uncommitted or committed changes.
1498+
1499+
Call this after making code changes to see what's affected BEFORE
1500+
committing. Shows affected symbols, files, tests, coupling warnings,
1501+
and fitness violations. For pre-PR analysis, use pr_risk instead."""
14361502
args = ["diff"]
14371503
if commit_range:
14381504
args.append(commit_range)
@@ -1469,7 +1535,11 @@ def roam_symbol(name: str, full: bool = False, root: str = ".") -> dict:
14691535

14701536
@_tool(name="roam_deps")
14711537
def roam_deps(path: str, full: bool = False, root: str = ".") -> dict:
1472-
"""File-level import/imported-by relationships. Call this to understand a file's dependencies -- what it imports and what imports it. Use for module boundary analysis and refactoring impact."""
1538+
"""File-level import/imported-by relationships.
1539+
1540+
Call this to understand a file's dependencies -- what it imports
1541+
and what imports it. Use for module boundary analysis and
1542+
refactoring impact."""
14731543
args = ["deps", path]
14741544
if full:
14751545
args.append("--full")
@@ -1478,7 +1548,10 @@ def roam_deps(path: str, full: bool = False, root: str = ".") -> dict:
14781548

14791549
@_tool(name="roam_uses")
14801550
def roam_uses(name: str, full: bool = False, root: str = ".") -> dict:
1481-
"""All consumers of a symbol: callers, importers, inheritors grouped by edge type (calls, imports, inheritance, trait usage). Broader than impact. Use for planning API changes."""
1551+
"""All consumers of a symbol: callers, importers, inheritors.
1552+
1553+
Grouped by edge type (calls, imports, inheritance, trait usage).
1554+
Broader than impact. Use for planning API changes."""
14821555
args = ["uses", name]
14831556
if full:
14841557
args.append("--full")

0 commit comments

Comments
 (0)