move_symbol
Move a declaration between files in the same directory atomically, preserving its doc comment and rolling back on failure.
Instructions
Move a top-level declaration (function, method, type, const, or var) from one file to another within the SAME directory/package, atomically. The symbol's full source — declaration plus, by default, its leading doc comment (include_doc_comment) — moves from source_uri to destination_uri in one all-or-nothing operation: if the destination write fails the source is rolled back. Locates the symbol via the LSP document-symbol tree, falling back to tree-sitter when the language server is cold.
Scope (v1, conservative): source and destination must be in the SAME directory — plumb does not rewrite references or imports, so a move that would change a symbol's package or import path is REFUSED. destination_uri must already exist unless create_destination=true. Also refuses an ambiguous symbol (disambiguate with name_path), a path outside the workspace, or (Go) mismatched build constraints between source and destination.
Dry-run by default (dry_run=true): previews the unified diff without writing; set dry_run=false to apply. Undo is per-file — reverting a move takes two undo_edit calls. Scope rationale: the plumb-refactor skill.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | If true (default), preview the diff of both files only; do not write. | |
| dirty_ok | No | Allow moving when either file has uncommitted changes. Default false — review/commit first, or pass true to proceed. | |
| name_path | Yes | Slash-separated symbol path within the source file (e.g. "ClassName/methodName", or just "funcName" for a top-level declaration). | |
| source_uri | Yes | Absolute path, file:// URI, or workspace-relative path of the file currently holding the symbol. | |
| destination_uri | Yes | Absolute path, file:// URI, or workspace-relative path of the file to move the declaration into. Must be in the SAME directory (package) as source_uri. | |
| create_destination | No | Create destination_uri if it does not exist. Default false (the destination must already exist). A newly created Go file is seeded with the source file's package clause. | |
| include_doc_comment | No | Move the symbol's contiguous leading doc comment along with it. Default true — a relocated declaration should keep its documentation. Where the declaration is WRAPPED (an exported ES declaration under its export statement, a decorated Python def under its @decorator) its doc comment sits above the wrapper, so the moved range covers the wrapper too — which is what keeps @property with the method it decorates. |