Python SDK: RefactorEngine
The RefactorEngine supports renaming ALP objects and updating cross-references automatically.
Installation
bash
pip install autonomous-lifecycle-protocol-alpQuick Start
python
from alp_sdk import RefactorEngine
engine = RefactorEngine()
result = engine.rename(".alp", "task-1", "task-1-renamed", update_refs=True)
print(f"Renamed {result.occurrences} occurrences")
print(f"Updated {result.references_updated} references")API Reference
RefactorEngine
rename(workspace_path, old_id, new_id, update_refs=False) -> RenameResult
Renames an ALP object and optionally updates all references to it.
workspace_path: Path to workspace containing.alpdirectoryold_id: Current object IDnew_id: New object IDupdate_refs: IfTrue, updates reference fields (depends_on,references,links,parent,child) that point toold_id
RenameResult
occurrences: Number ofid:fields renamedreferences_updated: Number of reference fields updatedfiles_modified: Number of files changed
Reference Fields
The following fields are treated as references when update_refs=True:
depends_onreferenceslinksparentchild
Examples
Basic Rename
python
from alp_sdk import RefactorEngine
engine = RefactorEngine()
result = engine.rename("./my-project", "old-task", "new-task")
print(f"Renamed {result.occurrences} occurrences in {result.files_modified} files")Rename with Reference Updates
python
from alp_sdk import RefactorEngine
engine = RefactorEngine()
result = engine.rename(
"./my-project",
"auth-service",
"auth-service-v2",
update_refs=True
)
print(f"Renamed {result.occurrences} occurrences, updated {result.references_updated} references")