first commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Install this skill without copying local secrets or runtime caches."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
EXCLUDED_FILES = {"connection.local.json"}
|
||||
EXCLUDED_DIRS = {".git", "__pycache__", "venv"}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--codex-home", type=Path)
|
||||
parser.add_argument("--force", action="store_true")
|
||||
args = parser.parse_args()
|
||||
source = Path(__file__).resolve().parent.parent
|
||||
codex_home = args.codex_home or Path(os.environ.get("CODEX_HOME", Path.home() / ".codex"))
|
||||
destination = codex_home.expanduser() / "skills" / "image-gen-custom"
|
||||
if source == destination.resolve():
|
||||
print(f"Skill is already installed at: {destination}")
|
||||
return 0
|
||||
if destination.exists() and not args.force:
|
||||
raise SystemExit(f"Skill already exists at {destination}; use --force to update it")
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
for item in source.rglob("*"):
|
||||
relative = item.relative_to(source)
|
||||
if item.name in EXCLUDED_FILES or any(part in EXCLUDED_DIRS for part in relative.parts):
|
||||
continue
|
||||
target = destination / relative
|
||||
if item.is_dir():
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
else:
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(item, target)
|
||||
print(f"Installed image-gen-custom to: {destination}")
|
||||
print(f"Configure the API with: python {destination / 'scripts' / 'configure_key.py'}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user