Skip to main content
Glama
aimasteracc

tree-sitter-analyzer

by aimasteracc

edit

Destructive

Assess code-change safety: verify safe-to-change gates, blast radius, impact, refactor options, PR issues, and AST diffs through one action-driven code-intelligence interface.

Instructions

Code-intelligence (codegraph-compatible) safety and change-management facade. Covers codegraph_pr_review (PR analysis via codegraph), safe-to-edit gates, blast-radius guards, change impact scanning, refactoring suggestions, constraint checks, semantic classification, and AST diff in one tool. Pick a capability via action:

  • action=safe — pre-edit safety gate: is this file safe to edit right now? Returns SAFE/UNSAFE verdict. Params: file_path, edit_type, access_mode, snapshot_id, source_generation, output_format.

  • action=guard — blast-radius guard BEFORE touching a symbol: how many callers, what test coverage, what risk level. Params: symbol* (required), modification_type* (required), file_path.

  • action=impact — post-edit dependency blast-radius scan combining git diff + dependency graph: affected files, must-run tests, risk verdict (SAFE/REVIEW/WARN). Call after every non-trivial edit. Params: mode (diff|staged|branch|pr, default: diff), scope_paths, output_format, access_mode, capture_diff_snapshot (boolean; explicit opt-in, same-process POSIX producer only and forbidden with access_mode).

  • action=verify — explicitly execute a bound verification plan after rebuilding it. Runs project tests, which may write files or access the network. Params: request, output_format.

  • action=refactor — refactoring-opportunity analysis for a source file: extract candidates, complexity hotspots, skeleton. Params: file_path, language, max_suggestions, include_extractions, include_skeleton, output_format.

  • action=rename — rename a unique Python module-level function or class and its direct absolute from-import references, including aliases. Uses fresh AST identifier locations; preserves literals, comments, encoding and newlines. Ambiguous bindings, affected unsupported languages and dynamic references are rejected before writing. Params: symbol* (unqualified name), new_name*, mode (preview|apply, default: preview), output_format. mode=preview lists exact changes without writing; mode=apply WRITES files. This differs from action=refactor, which only suggests changes.

  • action=constraints — scan the project for constraint/rule violations. For RFC-0022 frozen read-only evaluation pass persist=false, diff_snapshot_id, and the impact-produced scope_paths. Params: severity_min, persist, diff_snapshot_id, scope_paths, access_mode, snapshot_id, source_generation, output_format.

  • action=pr — AI review of a PR diff via codegraph: structural issues, blast-radius, test-coverage gaps (codegraph_pr_review equivalent). Params: pr_url or diff (see inner schema).

  • action=classify — semantic change classification: classify a file's diff between git refs (file_path [+ old_ref/new_ref]) or two code strings (old_source + new_source + language). With only file_path, defaults to the file/git-ref mode. Params: file_path | old_source+new_source+language, access_mode, output_format.

  • action=ast_diff — structural AST diff between two snapshots/versions of a file: added/removed/changed nodes. Mode is inferred from args when omitted. Modes: diff_files (old_file + new_file), diff_strings (old_source + new_source + language), diff_git (old_ref + new_ref + file_path). Params: see inner schema; frozen consumption also accepts access_mode.

  • action=release_snapshot — idempotently release a process-local frozen diff. Params: diff_snapshot_id + route_lease_id.

  • action=plan_rename — preview an AST-aware rename of a unique Python module-level function or class and its direct absolute from-import references, including aliases (RFC-0027 §L8). Uses fresh identifier locations and rejects ambiguous bindings, affected unsupported languages and dynamic references. Returns exact edit sites and files_affected. PREVIEW ONLY — it never writes, and passing mode/dry_run/apply/write/force is REJECTED with PLAN_RENAME_IS_PREVIEW_ONLY rather than honoured. Params: symbol, new_name, output_format.

  • action=mutation_probe — on-demand query: does this test constrain this code? (RFC-0029). Applies one AST mutation at a source line in memory (never writes to disk), runs only the named test, and returns constrains/does_not_constrain/unknown. Fail-closed: unknown on any uncertainty; constrains only on AssertionError. Params: test_node_id* (required), source_path* (required), target_line* (required), timeout_seconds (default 60), output_format. NOTE: safe/impact/classify/constraints/pr/ast_diff/plan_rename/mutation_probe are read-only in practice; refactor/guard suggest changes but do not write files; rename with mode=apply writes files, and verify runs user tests with possible file and network side effects. readOnlyHint is False and destructiveHint is True for the whole facade (mixed action set).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoAction sub-mode (e.g. summary|cycles).
limitNoMax results.
queryNoSearch query/pattern.
scopeNoAction discriminator (e.g. point|graph).
actionYesWhich capability to invoke. One of: ast_diff, classify, constraints, guard, impact, mutation_probe, plan_rename, pr, refactor, release_snapshot, rename, safe, verify
symbolNoSymbol/function name.
persistNoWrite evaluated violations through to the cache. Set false for RFC-0022 read-only evaluation; no database or file is created.
languageNoLanguage hint (usually auto).
file_pathNoTarget file path.
access_modeNoExplicit P0.4 zero-write access mode for routed read adapters.
scope_pathsNoPrimitive-issued frozen scope for action=constraints, or impact capture scope for action=impact.
snapshot_idNoCertified P0.1 index snapshot capability ID.
function_nameNoFunction name (alias of symbol).
output_formatNoOutput format: JSON.
route_lease_idNoOwnership token required by action=release_snapshot.
diff_snapshot_idNoRFC-0022 frozen diff ID for constraints/classify/ast_diff/release_snapshot.
modification_typeNoRequired for action=guard: type of planned modification. One of: add_feature, behavior_change, delete, fix_bug, refactor, rename, signature_change.
source_generationNoCertified P0.1/P0.2 source generation.
capture_diff_snapshotNoExplicitly produce a frozen diff ID for same-process consumers; supported only on POSIX.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed12 schema fields changedv1.30.0
    • addedInput schema / properties / access_mode
      Added value: +{
      +  "description": "Explicit P0.4 zero-write access mode for routed read adapters.",
      +  "enum": [
      +    "read_existing"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / action / description
      Previous value: -"Which capability to invoke. One of: ast_diff, classify, constraints, guard, impact, pr, refactor, safe"New value: +"Which capability to invoke. One of: ast_diff, classify, constraints, guard, impact, mutation_probe, plan_rename, pr, refactor, release_snapshot, rename, safe, verify"
    • changedInput schema / properties / action / enum
      Previous value: -[
      -  "ast_diff",
      -  "classify",
      -  "constraints",
      -  "guard",
      -  "impact",
      -  "pr",
      -  "refactor",
      -  "safe"
      -]New value: +[
      +  "ast_diff",
      +  "classify",
      +  "constraints",
      +  "guard",
      +  "impact",
      +  "mutation_probe",
      +  "plan_rename",
      +  "pr",
      +  "refactor",
      +  "release_snapshot",
      +  "rename",
      +  "safe",
      +  "verify"
      +]
    • addedInput schema / properties / capture_diff_snapshot
      Added value: +{
      +  "description": "Explicitly produce a frozen diff ID for same-process consumers; supported only on POSIX.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / diff_snapshot_id
      Added value: +{
      +  "description": "RFC-0022 frozen diff ID for constraints/classify/ast_diff/release_snapshot.",
      +  "type": "string"
      +}
    • changedInput schema / properties / output_format / description
      Previous value: -"Output format (toon|json)."New value: +"Output format: JSON."
    • addedInput schema / properties / output_format / enum
      Added value: +[
      +  "json"
      +]
    • addedInput schema / properties / persist
      Added value: +{
      +  "default": true,
      +  "description": "Write evaluated violations through to the cache. Set false for RFC-0022 read-only evaluation; no database or file is created.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / route_lease_id
      Added value: +{
      +  "description": "Ownership token required by action=release_snapshot.",
      +  "type": "string"
      +}
    • addedInput schema / properties / scope_paths
      Added value: +{
      +  "description": "Primitive-issued frozen scope for action=constraints, or impact capture scope for action=impact.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / snapshot_id
      Added value: +{
      +  "description": "Certified P0.1 index snapshot capability ID.",
      +  "type": "string"
      +}
    • addedInput schema / properties / source_generation
      Added value: +{
      +  "description": "Certified P0.1/P0.2 source generation.",
      +  "type": "string"
      +}
  2. Changed1 schema field changedv1.25.0
    • addedInput schema / properties / modification_type
      Added value: +{
      +  "description": "Required for action=guard: type of planned modification. One of: add_feature, behavior_change, delete, fix_bug, refactor, rename, signature_change.",
      +  "enum": [
      +    "add_feature",
      +    "behavior_change",
      +    "delete",
      +    "fix_bug",
      +    "refactor",
      +    "rename",
      +    "signature_change"
      +  ],
      +  "type": "string"
      +}
  3. First observedv1.23.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description goes well beyond the coarse annotations, disclosing per-action side effects: rename mode=apply WRITES files, verify runs tests that 'may write files or access the network', mutation_probe never writes to disk, plan_rename rejects mode/dry_run/apply. Critically, it explicitly reconciles the coarse annotations ('readOnlyHint is False and destructiveHint is True for the whole facade (mixed action set)'), removing ambiguity the annotations alone would create.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the facade summary and action selector, then a well-structured per-action bullet list. Length is justified by 13 actions, but there is some redundancy (AST-diff modes restated against the inner-schema reference, repeated 'only suggests' phrasing). Efficient but not maximally tight.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 13-action facade with only 1 schema-required param and no output schema, the description supplies what is missing: per-action params, required vs optional, side-effect profiles, and return shapes (SAFE/UNSAFE verdict, files_affected, constrains/does_not_constrain/unknown, risk levels). An agent has everything needed to select and invoke each action correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Baseline would be 3 given 100% schema coverage, but the description adds substantial meaning the 19 top-level schema properties do not capture: it maps per-action parameter sets and marks which are required (symbol*, modification_type*, test_node_id*, source_path*, target_line*, new_name*) — none of which appear as required in the schema — and documents params absent from the schema entirely (old_ref/new_ref, old_source/new_source, pr_url, diff). This exceeds what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening line names a specific verb+resource ('safety and change-management facade') and each bullet precisely names a distinct capability (PR review, safe-to-edit gate, blast-radius guard, AST diff, rename). An agent can distinguish the 13 actions from one another. It does not explicitly differentiate from the sibling tools (project, search, nav, structure), so it stops short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Every action carries explicit when-to-use guidance: 'pre-edit safety gate' before editing, guard 'BEFORE touching a symbol', impact 'Call after every non-trivial edit', rename preview vs apply, plan_rename 'PREVIEW ONLY'. It also states when to prefer one action over another ('This differs from action=refactor, which only suggests changes'). Nothing is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.