v0.20 alpha skill-driven python core

This commit is contained in:
kai
2026-05-06 16:26:41 +08:00
parent d1169646b8
commit db626f1d58
87 changed files with 5213 additions and 2865 deletions
+37 -18
View File
@@ -17,8 +17,13 @@ except ModuleNotFoundError: # pragma: no cover - Python < 3.11 fallback.
REPO_ROOT = Path(__file__).resolve().parent.parent
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))
from scripts.deploy_adapters import default_codex_home, deploy_codex
from scripts.runtime.skills import SkillRegistry
CODEX_TEMPLATE = REPO_ROOT / "codex_adapter_templates" / "codex"
CODEX_ROOT = REPO_ROOT / ".codex"
OPENCODE_ROOT = REPO_ROOT / ".opencode"
AGENTS_SKILLS = REPO_ROOT / ".agents" / "skills"
OPENCODE_SKILLS = OPENCODE_ROOT / "skills"
@@ -28,11 +33,14 @@ REQUIRED_PATHS = [
"README.md",
"PLAN.md",
".opencode/opencode.json",
".codex/config.toml",
".codex/agents/dr-pm.toml",
".codex/commands/dr-run.md",
"codex_adapter_templates/codex/config.toml",
"codex_adapter_templates/codex/agents/dr-pm.toml",
"codex_adapter_templates/codex/commands/dr-run.md",
".agents/skills/search-strategy/SKILL.md",
"skills/deep-research/SKILL.md",
"skills/document-ingest/SKILL.md",
"scripts/dr.py",
"scripts/deploy_adapters.py",
"scripts/install_codex_adapter.py",
]
@@ -111,19 +119,26 @@ def check_deployment() -> int:
if not (REPO_ROOT / item).exists():
issues.append(f"missing required path: {item}")
tracked = git_tracked([".codex", ".opencode", ".agents/skills"])
tracked = git_tracked(["codex_adapter_templates", ".opencode", ".agents/skills", "skills"])
legacy_tracked = git_tracked([".codex"])
if legacy_tracked:
warnings.append("legacy .codex files are still tracked; run: git rm -r --cached .codex")
for item in REQUIRED_PATHS:
if item.startswith((".codex/", ".opencode/", ".agents/")) and item not in tracked:
if item.startswith(("codex_adapter_templates/", ".opencode/", ".agents/")) and item not in tracked:
warnings.append(f"not tracked by git: {item}")
skill_files = sorted(AGENTS_SKILLS.glob("*/SKILL.md"))
if len(skill_files) < 10:
issues.append(f"expected at least 10 Codex skills, found {len(skill_files)}")
skills = SkillRegistry().list()
if len(skills) < 10:
issues.append(f"expected at least 10 Codex skills, found {len(skills)}")
check_toml(CODEX_ROOT / "config.toml", issues)
for path in sorted((CODEX_ROOT / "agents").glob("*.toml")):
check_toml(CODEX_TEMPLATE / "config.toml", issues)
for path in sorted((CODEX_TEMPLATE / "agents").glob("*.toml")):
check_toml(path, issues)
codex_home = default_codex_home()
if not (codex_home / "commands" / "dr-run.md").exists():
warnings.append(f"Codex adapter not deployed to {codex_home}; run scripts/deploy_adapters.py codex")
env_values = {key: os.environ.get(key, "") for key in REQUIRED_ENV_KEYS}
env_values.update({k: v for k, v in parse_env(REPO_ROOT / "secrets.env").items() if not env_values.get(k)})
missing_env = [key for key in REQUIRED_ENV_KEYS if not env_values.get(key)]
@@ -132,9 +147,11 @@ def check_deployment() -> int:
print("Deep Research deployment check")
print(f" repo: {REPO_ROOT}")
print(f" codex files tracked: {sum(1 for p in tracked if p.startswith('.codex/'))}")
print(f" codex template files tracked: {sum(1 for p in tracked if p.startswith('codex_adapter_templates/'))}")
print(f" legacy .codex files tracked: {len(legacy_tracked)}")
print(f" codex home: {codex_home}")
print(f" opencode files tracked: {sum(1 for p in tracked if p.startswith('.opencode/'))}")
print(f" codex skills: {len(skill_files)}")
print(f" codex skills: {len(skills)}")
if warnings:
print("\nWarnings:")
@@ -151,9 +168,9 @@ def check_deployment() -> int:
return 0
def repair(force: bool) -> int:
def repair(force: bool, codex_home: Path | None) -> int:
try:
codex_written = copy_tree_contents(CODEX_TEMPLATE, CODEX_ROOT, force=force)
codex_result = deploy_codex(target=codex_home, force=force)
skills_written = copy_tree_contents(OPENCODE_SKILLS, AGENTS_SKILLS, force=force)
except PermissionError as exc:
print(f"repair failed: permission denied: {exc}", file=sys.stderr)
@@ -163,19 +180,21 @@ def repair(force: bool) -> int:
return 1
print("Repair completed.")
print(f" .codex files written: {len(codex_written)}")
print(f" Codex home files written: {len(codex_result.written)}")
print(f" Codex home: {codex_result.target}")
print(f" .agents skills written: {len(skills_written)}")
return check_deployment()
def main() -> int:
parser = argparse.ArgumentParser(description="Check or repair Deep Research deployment files")
parser.add_argument("--repair", action="store_true", help="copy Codex templates and skills into hidden dirs")
parser.add_argument("--repair", action="store_true", help="deploy Codex templates outside the repo and sync skills")
parser.add_argument("--force", action="store_true", help="overwrite existing files during --repair")
parser.add_argument("--codex-home", type=Path, help="Codex home target for --repair; defaults to $CODEX_HOME or ~/.codex")
args = parser.parse_args()
if args.repair:
return repair(force=args.force)
return repair(force=args.force, codex_home=args.codex_home)
return check_deployment()