mirror of
https://github.com/openai/codex.git
synced 2026-05-04 13:21:54 +03:00
33 lines
1003 B
Python
33 lines
1003 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
common.py: Shared utilities for agentydragon tooling scripts.
|
|
"""
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def repo_root() -> Path:
|
|
"""Return the Git repository root directory."""
|
|
out = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'])
|
|
return Path(out.decode().strip())
|
|
|
|
|
|
def tasks_dir() -> Path:
|
|
"""Path to the agentydragon/tasks directory."""
|
|
return repo_root() / 'agentydragon' / 'tasks'
|
|
|
|
|
|
def worktrees_dir() -> Path:
|
|
"""Path to the agentydragon/tasks/.worktrees directory."""
|
|
return tasks_dir() / '.worktrees'
|
|
|
|
|
|
def resolve_slug(input_id: str) -> str:
|
|
"""Resolve a two-digit task ID into its full slug, or return slug unchanged."""
|
|
if input_id.isdigit() and len(input_id) == 2:
|
|
matches = list(tasks_dir().glob(f"{input_id}-*.md"))
|
|
if len(matches) == 1:
|
|
return matches[0].stem
|
|
raise ValueError(f"Expected one task file for ID {input_id}, found {len(matches)}")
|
|
return input_id
|