scripts.split_skeleton
Reference › scripts › split_skeleton
scripts/split_skeleton.py is a one-off refactoring script that split the codemod package's single skeleton.py (under src/orchestrata_ultimate/refactor/codemod) into separate modules. It has no functions, classes or arguments: run as a script, it reads skeleton.py from a relative path, uses a table that maps each target module (report, observability events, persistence repository, workspace, the CSR index, the code-intelligence graph, transform passes and others) to the class definitions it takes, and cuts the text with regular expressions. It has no importers and is kept as a record of that split.
At a glance
| Source | scripts/split_skeleton.py |
| Lines of code | 144 |
| Classes | 0 |
| Functions | 0 |
| Imports (internal) | none |
| Imported by | none |
| Tests that import it | none |
Class diagram
No classes; see Functions.
Dependency diagram
No internal imports and no importers.
API
No public API: the module defines no classes, functions or constants.
Source
"""Split skeleton.py into proper module structure."""
import re
from pathlib import Path
skeleton_path = Path("src/orchestrata_ultimate/refactor/codemod/skeleton.py")
content = skeleton_path.read_text()
# Define module mappings
modules = {
"report.py": [
"class ChangeSet",
"class ChangeEntry",
"class Finding",
"class CommitReport",
"class CodemodEvent",
],
"observability/events.py": [
"class CodemodEvent",
"@runtime_checkable\nclass Observer",
],
"persistence/repository.py": [
"@runtime_checkable\nclass CodemodGraphRepository",
"class BoltSyncCodemodRepository",
],
"workspace.py": [
"class CodemodWorkspace",
],
"_csr_index.py": [
"class _CSRIndex",
],
"_cig.py": [
"class CodeIntelligenceGraph",
],
"passes.py": [
"@runtime_checkable\nclass TransformPass",
"class ReplaceStringLiteralPass",
"class AddImportPass",
"class RemoveUnusedImportPass",
"class DocstringSweepPass",
"class RenameSymbolPass",
],
"review.py": [
"@runtime_checkable\nclass ReviewPass",
"class ParseIntegrity",
"class BannedConstructs",
"class DiffBudget",
"class PrologSemanticReview",
],
"daemon.py": [
"class CodemodDaemon",
],
"server.py": [
"class CodemodServer",
],
"client.py": [
"class CodemodClient",
],
"watcher.py": [
"class FileWatcher",
],
"observability/tracing.py": [
"class TracingObserver",
],
"observability/metrics.py": [
"class MetricsObserver",
],
"observability/debug_panel.py": [
"class DebugPanelObserver",
],
"observability/error_detector.py": [
"class ErrorDetector",
],
"observability/graph_writer.py": [
"class GraphWriterObserver",
],
}
# Parse classes from skeleton
class_pattern = re.compile(
r"((?:@runtime_checkable\s+)?class \w+.*?)(?=\n(?:@runtime_checkable\s+)?class |\Z)",
re.DOTALL,
)
classes = {}
for match in class_pattern.finditer(content):
class_text = match.group(1)
class_name_match = re.search(r"class (\w+)", class_text)
if class_name_match:
class_name = class_name_match.group(1)
# Check if it has @runtime_checkable
has_decorator = class_text.startswith("@runtime_checkable")
key = (
f"@runtime_checkable\nclass {class_name}"
if has_decorator
else f"class {class_name}"
)
classes[key] = class_text
# Extract imports
import_section = ""
for line in content.split("\n"):
if line.startswith("from ") or line.startswith("import "):
import_section += line + "\n"
elif import_section and not line.strip():
import_section += "\n"
elif import_section:
break
# Create module files
base_dir = Path("src/orchestrata_ultimate/refactor/codemod")
for module_file, class_keys in modules.items():
module_path = base_dir / module_file
module_path.parent.mkdir(parents=True, exist_ok=True)
module_content = '"""SPEC-110 codemod engine module."""\n\n'
module_content += "from __future__ import annotations\n\n"
# Add necessary imports based on what's used
if "Protocol" in str(class_keys) or "runtime_checkable" in str(class_keys):
module_content += "from typing import Protocol, runtime_checkable\n"
if "Literal" in str(class_keys):
module_content += "from typing import Literal\n"
if "Iterator" in str(class_keys):
module_content += "from typing import Iterator\n"
if "Callable" in str(class_keys):
module_content += "from typing import Callable\n"
if "Path" in str(class_keys):
module_content += "from pathlib import Path\n"
if "array" in str(class_keys):
module_content += "from array import array\n"
module_content += "\n"
# Add classes
for key in class_keys:
if key in classes:
module_content += classes[key] + "\n\n"
module_path.write_text(module_content)
print(f"Created {module_path}")
print("\nSkeleton split complete!")