Classes
MoveOperation
4
▼
A planned content move operation.
Describes the source and destination of a content file move.
Use…
MoveOperation
4
▼
A planned content move operation.
Describes the source and destination of a content file move. Used as input to preview_move() and stored in MovePreview.
Attributes
| Name | Type | Description |
|---|---|---|
source |
str
|
Source path (relative to content directory). |
destination |
str
|
Destination path (relative to content directory). |
reason |
str
|
Optional explanation of why this move is needed. |
Methods
Internal Methods 1 ▼
__str__
0
str
▼
Format as source → destination.
__str__
0
str
▼
def __str__(self) -> str
Returns
str
LinkUpdate
5
▼
A link that needs to be updated after a content move.
Identifies where a link exists and what it s…
LinkUpdate
5
▼
A link that needs to be updated after a content move.
Identifies where a link exists and what it should change to. Includes context for review before making changes.
Attributes
| Name | Type | Description |
|---|---|---|
file_path |
str
|
Path to the file containing the link. |
old_link |
str
|
Current link target (to be replaced). |
new_link |
str
|
New link target (replacement). |
line |
int
|
Line number where the link appears. |
context |
str
|
Surrounding text (markdown link syntax). |
Redirect
6
▼
A redirect rule for moved content.
Supports generating redirect rules in multiple formats for
diff…
Redirect
6
▼
A redirect rule for moved content.
Supports generating redirect rules in multiple formats for different hosting platforms.
Attributes
| Name | Type | Description |
|---|---|---|
from_path |
str
|
Old URL path (source of redirect). |
to_path |
str
|
New URL path (destination of redirect). |
status_code |
int
|
HTTP status code (301 permanent, 302 temporary). |
Methods
to_nginx
0
str
▼
Generate nginx redirect rule for server config.
to_nginx
0
str
▼
def to_nginx(self) -> str
Returns
str
to_netlify
0
str
▼
Generate Netlify _redirects file format.
to_netlify
0
str
▼
def to_netlify(self) -> str
Returns
str
to_apache
0
str
▼
Generate Apache .htaccess redirect directive.
to_apache
0
str
▼
def to_apache(self) -> str
Returns
str
MovePreview
6
▼
Preview of what a move operation would do.
Generated by preview_move() to show all effects before …
MovePreview
6
▼
Preview of what a move operation would do.
Generated by preview_move() to show all effects before execution. Allows review of link updates, redirects, and any warnings before committing to the move.
Attributes
| Name | Type | Description |
|---|---|---|
operation |
MoveOperation
|
The move operation being previewed. |
affected_links |
list[LinkUpdate]
|
Links that would need updating across the site. |
redirects_needed |
list[Redirect]
|
Redirect rules that would be generated. |
warnings |
list[str]
|
Any warnings about potential issues. |
can_proceed |
bool
|
Whether the move can safely proceed. |
Methods
format_summary
0
str
▼
Format preview as human-readable summary.
format_summary
0
str
▼
def format_summary(self) -> str
Returns
str
Multi-line summary with affected links, redirects, and status.
PageDraft
6
▼
A draft of a new or modified page.
Used by split_page() and merge_pages() to represent the output
…
PageDraft
6
▼
A draft of a new or modified page.
Used by split_page() and merge_pages() to represent the output pages before they're written to disk, allowing for preview and modification before committing changes.
Attributes
| Name | Type | Description |
|---|---|---|
path |
str
|
Target path for the new page (relative to content dir). |
title |
str
|
Page title extracted from heading or frontmatter. |
content |
str
|
Full Markdown content body. |
frontmatter |
dict[str, Any]
|
Merged/generated frontmatter dictionary. |
source_pages |
list[str]
|
Original pages this draft was derived from. |
Methods
format_preview
1
str
▼
Format as preview.
format_preview
1
str
▼
def format_preview(self, max_lines: int = 20) -> str
Parameters
| Name | Type | Description |
|---|---|---|
max_lines |
— |
Default:20
|
Returns
str
ContentMigrator
18
▼
Tool for safely restructuring content with link integrity.
Provides safe content reorganization op…
ContentMigrator
18
▼
Tool for safely restructuring content with link integrity.
Provides safe content reorganization operations that maintain site integrity by automatically updating internal links and generating redirect rules for external references.
Capabilities:
- Move/Rename: Relocate content files with automatic link updates.
- Split Pages: Break large pages into multiple smaller pages.
- Merge Pages: Combine multiple pages into a single page.
- Redirect Generation: Create redirect rules for various platforms.
- Structure Analysis: Find orphan pages, large pages, and issues.
The tool operates in a preview-first mode: all operations can be previewed before execution to review the impact.
Attributes
| Name | Type | Description |
|---|---|---|
name |
— |
Tool identifier ("migrate"). |
description |
— |
Brief tool description. |
site |
— |
Site instance for content access. |
cache |
— |
Optional build cache for dependency info. |
root_path |
— |
Project root directory. |
Methods
analyze
0
DebugReport
▼
Analyze content structure for migration opportunities.
analyze
0
DebugReport
▼
def analyze(self) -> DebugReport
Returns
DebugReport
DebugReport with structure analysis
preview_move
2
MovePreview
▼
Preview what would happen if a file is moved.
preview_move
2
MovePreview
▼
def preview_move(self, source: str, destination: str) -> MovePreview
Parameters
| Name | Type | Description |
|---|---|---|
source |
— |
Source path (relative to content dir) |
destination |
— |
Destination path |
Returns
MovePreview
MovePreview with affected links and redirects
execute_move
4
list[str]
▼
Execute a previewed move operation.
execute_move
4
list[str]
▼
def execute_move(self, preview: MovePreview, update_links: bool = True, create_redirects: bool = True, dry_run: bool = False) -> list[str]
Parameters
| Name | Type | Description |
|---|---|---|
preview |
— |
Move preview from preview_move() |
update_links |
— |
Whether to update links in other files Default:True
|
create_redirects |
— |
Whether to generate redirect rules Default:True
|
dry_run |
— |
If True, only report what would be done Default:False
|
Returns
list[str]
List of actions taken (or that would be taken)
split_page
3
list[PageDraft]
▼
Split a large page into multiple smaller pages.
split_page
3
list[PageDraft]
▼
def split_page(self, page_path: str, sections: list[str], output_dir: str | None = None) -> list[PageDraft]
Parameters
| Name | Type | Description |
|---|---|---|
page_path |
— |
Path to the page to split |
sections |
— |
List of heading names to split at |
output_dir |
— |
Optional output directory for new pages Default:None
|
Returns
list[PageDraft]
List of PageDraft objects for the new pages
merge_pages
3
PageDraft
▼
Merge multiple pages into one.
merge_pages
3
PageDraft
▼
def merge_pages(self, page_paths: list[str], output_path: str, title: str | None = None) -> PageDraft
Parameters
| Name | Type | Description |
|---|---|---|
page_paths |
— |
Paths to pages to merge |
output_path |
— |
Output path for merged page |
title |
— |
Optional title for merged page Default:None
|
Returns
PageDraft
PageDraft for the merged page
generate_redirects
2
str
▼
Generate redirect rules for moved content.
generate_redirects
2
str
▼
def generate_redirects(self, moves: list[MoveOperation], output_format: str = 'netlify') -> str
Parameters
| Name | Type | Description |
|---|---|---|
moves |
— |
List of move operations |
output_format |
— |
Output format (netlify, nginx, apache) Default:'netlify'
|
Returns
str
Redirect rules in requested format
Internal Methods 7 ▼
_find_structure_issues
0
list[DebugFinding]
▼
Find potential structure issues in content.
_find_structure_issues
0
list[DebugFinding]
▼
def _find_structure_issues(self) -> list[DebugFinding]
Returns
list[DebugFinding]
_is_in_navigation
1
bool
▼
Check if page is in site navigation.
_is_in_navigation
1
bool
▼
def _is_in_navigation(self, page: Any) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
page |
— |
Returns
bool
_path_to_url
1
str
▼
Convert file path to URL.
_path_to_url
1
str
▼
def _path_to_url(self, path: str) -> str
Parameters
| Name | Type | Description |
|---|---|---|
path |
— |
Returns
str
_links_match
2
bool
▼
Check if a link matches a target URL.
_links_match
2
bool
▼
def _links_match(self, link: str, target_url: str) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
link |
— |
|
target_url |
— |
Returns
bool
_update_link
2
str
▼
Update a link to point to new location.
_update_link
2
str
▼
def _update_link(self, old_link: str, new_url: str) -> str
Parameters
| Name | Type | Description |
|---|---|---|
old_link |
— |
|
new_url |
— |
Returns
str
_update_file_link
1
▼
Update a link in a file.
_update_file_link
1
▼
def _update_file_link(self, link_update: LinkUpdate) -> None
Parameters
| Name | Type | Description |
|---|---|---|
link_update |
— |
_generate_recommendations
1
list[str]
▼
Generate recommendations based on analysis.
_generate_recommendations
1
list[str]
▼
def _generate_recommendations(self, report: DebugReport) -> list[str]
Parameters
| Name | Type | Description |
|---|---|---|
report |
— |
Returns
list[str]