Frappucc1no/recall-loom / skills/recallloom
recallloom
FlaggedUse when a task involves continuing a project, restoring project context, maintaining file-based project memory, updating current-state summaries, or recording meaningful progress across sessions. Works best for long-horizon, file-based projects and supports research writing, product document collaboration, software project coordination, and broader cross-functional project continuity.
scripts/remove_context.py
View on GitHub#!/usr/bin/env python3
"""Safely remove a RecallLoom workspace from a project."""
from __future__ import annotations
import argparse
import json
import shutil
from pathlib import Path
from core.bridge.blocks import (
bridge_block_integrity,
)
from core.protocol.contracts import BRIDGE_START, ROOT_ENTRY_CANDIDATES
from _common import (
cli_failure_payload,
cli_failure_payload_for_exception,
ConfigContractError,
EnvironmentContractError,
enforce_package_support_gate,
exit_with_cli_error,
find_recovery_workspace,
LockBusyError,
read_text,
StorageResolutionError,
ensure_supported_python_version,
find_recallloom_root,
public_json_payload,
remove_git_exclude_block,
unknown_storage_assets,
validate_storage_mode,
workspace_write_lock,
)
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description="Safely remove a RecallLoom workspace from a project."
)
parser.add_argument(
"path",
nargs="?",
default=".",
help="Project path or a descendant path. Defaults to the current working directory.",
)
parser.add_argument(
"--yes",
action="store_true",
help="Perform the removal. Without this flag, the script only reports what would be removed.",
)
parser.add_argument(
"--force",
action="store_true",
help="Allow removal even if the storage root contains non-managed files or directories.",
)
parser.add_argument(
"--storage-mode",
choices=["hidden", "visible"],
help="Recovery-only hint for choosing which sidecar to remove when normal workspace detection fails or both sidecars exist.",
)
parser.add_argument(
"--json",
action="store_true",
help="Print structured JSON output.",
)
return parser
def unique_tombstone_path(project_root: Path, storage_root_name: str) -> Path:
base = project_root / f".recallloom-delete-{storage_root_name}"
if not base.exists():
return base
counter = 1
while True:
candidate = project_root / f".recallloom-delete-{storage_root_name}-{counter}"
if not candidate.exists():
return candidate
counter += 1
def managed_bridge_targets(project_root: Path) -> tuple[list[str], list[str]]:
healthy_targets: list[str] = []
malformed_targets: list[str] = []
for rel_path in ROOT_ENTRY_CANDIDATES:
path = project_root / rel_path
if not path.is_file():
continue
text = read_text(path)
ok, reason = bridge_block_integrity(text)
has_bridge_block = BRIDGE_START in text
if not ok:
malformed_targets.append(f"{path} ({reason or 'bridge_malformed'})")
continue
if has_bridge_block:
healthy_targets.append(str(path))
return healthy_targets, malformed_targets
def main() -> None:
parser = build_parser()
args = parser.parse_args()
try:
ensure_supported_python_version()
except EnvironmentContractError as exc:
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=str(exc),
payload=cli_failure_payload("python_runtime_unavailable", error=str(exc)),
)
enforce_package_support_gate(parser, json_mode=args.json)
requested_storage_mode = validate_storage_mode(args.storage_mode) if args.storage_mode else None
try:
workspace = find_recallloom_root(
args.path,
allow_unsupported_version=True,
allow_storage_mode_mismatch=True,
)
except (StorageResolutionError, ConfigContractError):
workspace = None
if workspace is None:
try:
workspace = find_recovery_workspace(
args.path,
requested_storage_mode=requested_storage_mode,
)
except StorageResolutionError as exc:
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=str(exc),
payload=cli_failure_payload_for_exception(exc, default_reason="damaged_sidecar"),
)
if workspace is None:
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=1,
message="No RecallLoom project root found.",
payload=cli_failure_payload("no_project_root", error="No RecallLoom project root found."),
)
try:
with workspace_write_lock(workspace.project_root, "remove_context.py"):
storage_root = workspace.storage_root
if storage_root == workspace.project_root:
message = "Refusing to remove RecallLoom because storage_root resolves to the project root."
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=message,
payload=cli_failure_payload("invalid_storage_boundary", error=message),
)
if storage_root.parent != workspace.project_root:
message = "Refusing to remove RecallLoom because storage_root is not a direct child of the project root."
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=message,
payload=cli_failure_payload("invalid_storage_boundary", error=message),
)
if storage_root.name not in {".recallloom", "recallloom"}:
message = f"Refusing to remove unexpected storage root: {storage_root}"
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=message,
payload=cli_failure_payload("invalid_storage_boundary", error=message),
)
removed_storage = False
storage_relocated = False
removed_git_exclude_block = False
tombstone_path = None
storage_cleanup_error = None
exclude_cleanup_error = None
unknown_assets = [str(path) for path in unknown_storage_assets(storage_root)]
bridge_targets, malformed_bridge_targets = managed_bridge_targets(workspace.project_root)
if bridge_targets or malformed_bridge_targets:
detail_lines = []
if bridge_targets:
detail_lines.append("Managed bridge blocks still exist in:")
detail_lines.extend(bridge_targets)
if malformed_bridge_targets:
detail_lines.append("Malformed bridge blocks still exist in:")
detail_lines.extend(malformed_bridge_targets)
detail_lines.append(
"Remove or repair bridge blocks before removing the RecallLoom sidecar. "
"In v1 uninstall remains a two-step flow: remove bridge first, then remove the sidecar."
)
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=3,
message="\n".join(detail_lines),
payload=cli_failure_payload(
"malformed_managed_file" if malformed_bridge_targets else "invalid_prepared_input",
error="\n".join(detail_lines),
details={
"bridge_targets": bridge_targets,
"malformed_bridge_targets": malformed_bridge_targets,
},
),
)
if args.yes and unknown_assets and not args.force:
message = (
"Refusing to remove RecallLoom because the storage root contains non-managed assets. "
"Review the reported paths or re-run with --force."
)
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=3,
message=message,
payload=cli_failure_payload(
"invalid_prepared_input",
error=message,
details={"unknown_assets": unknown_assets},
),
)
if args.yes:
if workspace.storage_mode == "hidden":
try:
removed_git_exclude_block = remove_git_exclude_block(workspace.project_root)
except ConfigContractError as exc:
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=str(exc),
payload=cli_failure_payload_for_exception(exc, default_reason="malformed_managed_file"),
)
except LockBusyError as exc:
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=3,
message=str(exc),
payload=cli_failure_payload("write_lock_busy", error=str(exc)),
)
except OSError as exc:
message = f"Filesystem error: {exc}"
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=message,
payload=cli_failure_payload("damaged_sidecar", error=message),
)
tombstone = unique_tombstone_path(workspace.project_root, storage_root.name)
storage_root.rename(tombstone)
tombstone_path = str(tombstone)
try:
if tombstone.is_dir():
shutil.rmtree(tombstone)
else:
tombstone.unlink()
removed_storage = True
storage_relocated = False
tombstone_path = None
except OSError as exc:
storage_relocated = True
storage_cleanup_error = (
f"Sidecar was moved to {tombstone}, but cleanup of the tombstone failed: {exc}"
)
payload = {
"project_root": str(workspace.project_root),
"storage_root": str(storage_root),
"storage_mode": workspace.storage_mode,
"dry_run": not args.yes,
"force": args.force,
"unknown_asset_count": len(unknown_assets),
"unknown_assets": unknown_assets,
"removed_storage": removed_storage,
"storage_relocated": storage_relocated,
"tombstone_path": tombstone_path,
"storage_cleanup_error": storage_cleanup_error,
"removed_git_exclude_block": removed_git_exclude_block,
"exclude_cleanup_error": exclude_cleanup_error,
}
if storage_cleanup_error:
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=storage_cleanup_error,
payload=cli_failure_payload(
"storage_cleanup_incomplete",
error=storage_cleanup_error,
details=payload,
extra=payload,
),
)
except LockBusyError as exc:
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=3,
message=str(exc),
payload=cli_failure_payload("write_lock_busy", error=str(exc)),
)
except (OSError, UnicodeDecodeError) as exc:
message = f"Filesystem error: {exc}"
exit_with_cli_error(
parser,
json_mode=args.json,
exit_code=2,
message=message,
payload=cli_failure_payload("damaged_sidecar", error=message),
)
if args.json:
print(
json.dumps(
public_json_payload(payload, project_root=workspace.project_root),
ensure_ascii=False,
indent=2,
)
)
else:
if args.yes:
if removed_storage:
print(f"Removed RecallLoom storage root: {storage_root}")
elif storage_relocated:
print(
"RecallLoom storage root was moved out of the project, but final cleanup is incomplete: "
f"{tombstone_path}"
)
if workspace.storage_mode == "hidden":
print(
"Removed RecallLoom git exclude block: "
f"{'yes' if removed_git_exclude_block else 'no'}"
)
if storage_cleanup_error:
print(f"Warning: {storage_cleanup_error}")
if exclude_cleanup_error:
print(f"Warning: {exclude_cleanup_error}")
else:
print("Dry run only. Use --yes to remove.")
print(f"Would remove storage root: {storage_root}")
if unknown_assets:
print("Unknown assets detected inside the storage root:")
for item in unknown_assets:
print(f" - {item}")
print("Re-run with --yes --force only if you intentionally want to remove them too.")
if workspace.storage_mode == "hidden":
print("Would also remove the RecallLoom block from .git/info/exclude if present.")
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| add-product-e2e-evalpaperclipai/paperclipAdd or extend a Paperclip full-stack runner E2E workflow, fixture, matcher, or report evidence path for local or Daytona execution. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |
| add-runner-evalpaperclipai/paperclipAdd or extend a Paperclip Runner protocol evaluation definition, roster, assertion, or report fixture with provenance and narrow validation. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |
| diagnose-why-work-stoppedpaperclipai/paperclipCompatibility entry point for failed, stalled, looping, or over-recovered Paperclip work. Use fix-failed-paperclip-run for the full diagnosis, regression, repair, real verification, and green-PR workflow; honor an explicitly requested diagnosis-only scope. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |
| fix-failed-paperclip-runpaperclipai/paperclipDiagnose and fix failed, stuck, slow, or incorrectly blocked Paperclip tasks and runs. Use with a task/run URL or failure report to trace the root cause, prove a regression red then green, check second-order effects, verify the real workflow, and deliver a PR with passing checks. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |