{"record":{"id":"e727eb319222b27e","repo":"nexu-io/open-design","slug":"refusing-to-overwrite-unmanaged-output-directory","errorCode":null,"errorMessage":"Refusing to overwrite unmanaged output directory: {output_dir}. Only directories containing {BUNDLE_MARKER} can be replaced with --force.","messagePattern":"Refusing to overwrite unmanaged output directory: (.+?)\\. Only directories containing (.+?) can be replaced with --force\\.","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/chat-motion-overlay/scripts/prepare_chat_overlay_bundle.py","lineNumber":62,"sourceCode":"def bundle_marker_path(output_dir: Path) -> Path:\n    return output_dir / BUNDLE_MARKER\n\n\ndef validate_output_dir(output_dir: Path, force: bool) -> None:\n    dangerous_targets = {\n        Path.cwd().resolve(),\n        Path.home().resolve(),\n        repo_root(),\n        skill_root(),\n        template_dir(),\n    }\n    if output_dir in dangerous_targets:\n        raise SystemExit(\n            f\"Refusing to use dangerous output directory: {output_dir}. \"\n            \"Choose a dedicated generated-bundle directory instead.\"\n        )\n    if output_dir.exists() and force and not bundle_marker_path(output_dir).exists():\n        raise SystemExit(\n            f\"Refusing to overwrite unmanaged output directory: {output_dir}. \"\n            f\"Only directories containing {BUNDLE_MARKER} can be replaced with --force.\"\n        )\n\n\ndef copy_template(output_dir: Path, force: bool) -> None:\n    validate_output_dir(output_dir, force)\n    if output_dir.exists():\n        if not force:\n            raise SystemExit(f\"Output directory already exists: {output_dir}. Use --force to overwrite.\")\n        shutil.rmtree(output_dir)\n    shutil.copytree(template_dir(), output_dir)\n    bundle_marker_path(output_dir).write_text(\"generated by chat-motion-overlay\\n\", encoding=\"utf-8\")\n\n\ndef write_chat_spec_ts(spec: dict, output_dir: Path) -> None:\n    target = output_dir / \"src\" / \"chatSpec.ts\"\n    content = \"export const chatSpec = \" + json.dumps(spec, ensure_ascii=False, indent=2) + \" as const;\\n\"","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/chat-motion-overlay/scripts/prepare_chat_overlay_bundle.py#L44-L80","documentation":"Thrown by validate_output_dir() when --force is passed and the output dir already exists, but it does not contain the BUNDLE_MARKER file (.chat-motion-overlay-bundle). The marker is the trust signal that the directory was created by this tool; without it --force refuses to delete the tree to avoid wiping unrelated content.","triggerScenarios":"Run prepare_chat_overlay_bundle.py --output-dir <existing dir> --force where <existing dir> was created by something else (or by this tool before markers existed) and lacks the .chat-motion-overlay-bundle file.","commonSituations":"Reusing a generic build/dist folder that predates the marker; manually creating the output directory; pointing at a directory another generator owns.","solutions":["Point --output-dir at a fresh dedicated directory this tool can own end-to-end.","If the existing directory is safe to delete, remove it manually first (rm -rf) then run without --force, so the tool creates and marks it.","If you are sure the directory is tool-managed but lost its marker, create an empty .chat-motion-overlay-bundle file inside it before re-running with --force."],"exampleFix":"# before\npython prepare_chat_overlay_bundle.py --output-dir ./existing-build --force  # no marker inside\n# after\nrm -rf ./existing-build && python prepare_chat_overlay_bundle.py --output-dir ./existing-build","handlingStrategy":"validation","validationCode":"from pathlib import Path\nMARKER = \".chat-motion-overlay-bundle\"\ndef assert_managed_or_empty(output_dir: Path, force: bool) -> None:\n    if output_dir.exists() and force and not (output_dir / MARKER).exists():\n        raise SystemExit(f\"{output_dir} is not tool-managed (no {MARKER}); remove it manually first\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let the tool create its own output directories so the marker is always present.","Never reuse foreign build folders for bundle output."],"tags":["filesystem-safety","chat-motion-overlay","bundle-prep"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}