v0.20.6 rebuild platform environments from templates
This commit is contained in:
@@ -17,10 +17,11 @@ if str(REPO_ROOT) not in sys.path:
|
||||
|
||||
from scripts.runtime.skills import SkillRegistry
|
||||
|
||||
CODEX_TEMPLATE = REPO_ROOT / "codex_adapter_templates" / "codex"
|
||||
ANTIGRAVITY_RULES_DIR = REPO_ROOT / ".agent" / "rules"
|
||||
ANTIGRAVITY_WORKFLOWS_DIR = REPO_ROOT / ".agent" / "workflows"
|
||||
ANTIGRAVITY_AGENTS_FILE = REPO_ROOT / ".agent" / "agents.md"
|
||||
CODEX_TEMPLATE = REPO_ROOT / "platform_adapters" / "codex"
|
||||
ANTIGRAVITY_TEMPLATE = REPO_ROOT / "platform_adapters" / "antigravity" / "agent"
|
||||
ANTIGRAVITY_RULES_DIR = ANTIGRAVITY_TEMPLATE / "rules"
|
||||
ANTIGRAVITY_WORKFLOWS_DIR = ANTIGRAVITY_TEMPLATE / "workflows"
|
||||
ANTIGRAVITY_AGENTS_FILE = ANTIGRAVITY_TEMPLATE / "agents.md"
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -163,7 +164,7 @@ def deploy_codex(
|
||||
repo_root: Path = REPO_ROOT,
|
||||
) -> DeployResult:
|
||||
codex_home = (target or default_codex_home()).expanduser()
|
||||
template = repo_root / "codex_adapter_templates" / "codex"
|
||||
template = repo_root / "platform_adapters" / "codex"
|
||||
|
||||
parts = [
|
||||
copy_tree_contents(
|
||||
|
||||
+14
-14
@@ -23,21 +23,21 @@ if str(REPO_ROOT) not in sys.path:
|
||||
from scripts.deploy_adapters import default_codex_home, deploy_codex
|
||||
from scripts.runtime.skills import SkillRegistry
|
||||
|
||||
CODEX_TEMPLATE = REPO_ROOT / "codex_adapter_templates" / "codex"
|
||||
AGENT_SKILLS = REPO_ROOT / ".agent" / "skills"
|
||||
CODEX_TEMPLATE = REPO_ROOT / "platform_adapters" / "codex"
|
||||
AGENT_SKILLS = REPO_ROOT / "platform_adapters" / "antigravity" / "agent" / "skills"
|
||||
|
||||
REQUIRED_PATHS = [
|
||||
"AGENTS.md",
|
||||
"GEMINI.md",
|
||||
"README.md",
|
||||
"PLAN.md",
|
||||
".agent/agents.md",
|
||||
".agent/rules/deep-research-antigravity.md",
|
||||
".agent/workflows/deep-research-native.md",
|
||||
".agent/skills/search-strategy/SKILL.md",
|
||||
"codex_adapter_templates/codex/config.toml",
|
||||
"codex_adapter_templates/codex/agents/dr-pm.toml",
|
||||
"codex_adapter_templates/codex/commands/dr-run.md",
|
||||
"platform_adapters/antigravity/agent/agents.md",
|
||||
"platform_adapters/antigravity/agent/rules/deep-research-antigravity.md",
|
||||
"platform_adapters/antigravity/agent/workflows/deep-research-native.md",
|
||||
"platform_adapters/antigravity/agent/skills/search-strategy/SKILL.md",
|
||||
"platform_adapters/codex/config.toml",
|
||||
"platform_adapters/codex/agents/dr-pm.toml",
|
||||
"platform_adapters/codex/commands/dr-run.md",
|
||||
"skills/deep-research/SKILL.md",
|
||||
"skills/document-ingest/SKILL.md",
|
||||
"scripts/dr.py",
|
||||
@@ -120,12 +120,12 @@ def check_deployment() -> int:
|
||||
if not (REPO_ROOT / item).exists():
|
||||
issues.append(f"missing required path: {item}")
|
||||
|
||||
tracked = git_tracked(["codex_adapter_templates", ".agent", "skills"])
|
||||
tracked = git_tracked(["platform_adapters", "skills"])
|
||||
legacy_tracked = git_tracked([".codex", ".opencode", ".claude", ".gemini", ".agents"])
|
||||
if legacy_tracked:
|
||||
warnings.append("legacy platform adapter files are still tracked; prefer Antigravity clean workspace or remove them from the branch")
|
||||
for item in REQUIRED_PATHS:
|
||||
if item.startswith(("codex_adapter_templates/", ".agent/")) and item not in tracked:
|
||||
if item.startswith("platform_adapters/") and item not in tracked:
|
||||
warnings.append(f"not tracked by git: {item}")
|
||||
|
||||
skills = SkillRegistry().list()
|
||||
@@ -148,10 +148,10 @@ def check_deployment() -> int:
|
||||
|
||||
print("Deep Research deployment check")
|
||||
print(f" repo: {REPO_ROOT}")
|
||||
print(f" codex template files tracked: {sum(1 for p in tracked if p.startswith('codex_adapter_templates/'))}")
|
||||
print(f" platform adapter files tracked: {sum(1 for p in tracked if p.startswith('platform_adapters/'))}")
|
||||
print(f" legacy platform adapter files tracked: {len(legacy_tracked)}")
|
||||
print(f" codex home: {codex_home}")
|
||||
print(f" antigravity .agent files tracked: {sum(1 for p in tracked if p.startswith('.agent/'))}")
|
||||
print(f" antigravity adapter source files tracked: {sum(1 for p in tracked if p.startswith('platform_adapters/antigravity/'))}")
|
||||
print(f" codex skills: {len(skills)}")
|
||||
|
||||
if warnings:
|
||||
@@ -182,7 +182,7 @@ def repair(force: bool, codex_home: Path | None) -> int:
|
||||
print("Repair completed.")
|
||||
print(f" Codex home files written: {len(codex_result.written)}")
|
||||
print(f" Codex home: {codex_result.target}")
|
||||
print(f" .agent skills source: {AGENT_SKILLS}")
|
||||
print(f" Antigravity skills source: {AGENT_SKILLS}")
|
||||
return check_deployment()
|
||||
|
||||
|
||||
|
||||
@@ -16,17 +16,20 @@ FILES = [
|
||||
"README.md",
|
||||
"docs/antigravity-clean-workspace.md",
|
||||
"docs/platform-adapters.md",
|
||||
"docs/platform-branch-strategy.md",
|
||||
"scripts/dr.py",
|
||||
"scripts/deploy_adapters.py",
|
||||
"scripts/update_platform_envs.py",
|
||||
]
|
||||
|
||||
DIRS = [
|
||||
".agent",
|
||||
"configs",
|
||||
"scripts/runtime",
|
||||
"scripts/reporting",
|
||||
]
|
||||
|
||||
ANTIGRAVITY_AGENT_SRC = REPO_ROOT / "platform_adapters" / "antigravity" / "agent"
|
||||
|
||||
EMPTY_DIRS = [
|
||||
"projects",
|
||||
]
|
||||
@@ -80,6 +83,10 @@ def export_workspace(target: Path, *, force: bool, dry_run: bool) -> None:
|
||||
raise FileNotFoundError(src)
|
||||
copy_dir(src, target / rel, dry_run=dry_run)
|
||||
|
||||
if not ANTIGRAVITY_AGENT_SRC.exists():
|
||||
raise FileNotFoundError(ANTIGRAVITY_AGENT_SRC)
|
||||
copy_dir(ANTIGRAVITY_AGENT_SRC, target / ".agent", dry_run=dry_run)
|
||||
|
||||
for rel in EMPTY_DIRS:
|
||||
if dry_run:
|
||||
print(f"dir {rel} -> {target / rel}")
|
||||
|
||||
@@ -8,7 +8,8 @@ from pathlib import Path
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
CANONICAL_SKILLS_DIR = REPO_ROOT / ".agent" / "skills"
|
||||
CANONICAL_SKILLS_DIR = REPO_ROOT / "platform_adapters" / "antigravity" / "agent" / "skills"
|
||||
LEGACY_AGENT_SKILLS_DIR = REPO_ROOT / ".agent" / "skills"
|
||||
LEGACY_AGENTS_SKILLS_DIR = REPO_ROOT / ".agents" / "skills"
|
||||
PROJECT_SKILLS_DIR = REPO_ROOT / "skills"
|
||||
REQUIRED_SKILLS = {
|
||||
@@ -39,6 +40,8 @@ class SkillRegistry:
|
||||
if self.canonical_dir == CANONICAL_SKILLS_DIR and PROJECT_SKILLS_DIR.exists():
|
||||
roots.append(PROJECT_SKILLS_DIR)
|
||||
roots.append(self.canonical_dir)
|
||||
if self.canonical_dir == CANONICAL_SKILLS_DIR and LEGACY_AGENT_SKILLS_DIR.exists():
|
||||
roots.append(LEGACY_AGENT_SKILLS_DIR)
|
||||
if self.canonical_dir == CANONICAL_SKILLS_DIR and LEGACY_AGENTS_SKILLS_DIR.exists():
|
||||
roots.append(LEGACY_AGENTS_SKILLS_DIR)
|
||||
return roots
|
||||
@@ -107,5 +110,5 @@ class SkillRegistry:
|
||||
def default_adapter_skill_dirs() -> list[Path]:
|
||||
return [
|
||||
REPO_ROOT / ".opencode" / "skills",
|
||||
REPO_ROOT / ".agent" / "skills",
|
||||
REPO_ROOT / "platform_adapters" / "antigravity" / "agent" / "skills",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Pull the repo and rebuild isolated platform workspaces under platform_envs/."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
ENV_ROOT = REPO_ROOT / "platform_envs"
|
||||
ADAPTER_ROOT = REPO_ROOT / "platform_adapters"
|
||||
|
||||
COMMON_FILES = [
|
||||
"AGENTS.md",
|
||||
"GEMINI.md",
|
||||
"README.md",
|
||||
"docs/antigravity-clean-workspace.md",
|
||||
"docs/platform-adapters.md",
|
||||
"scripts/dr.py",
|
||||
"scripts/deploy_adapters.py",
|
||||
]
|
||||
|
||||
COMMON_DIRS = [
|
||||
"configs",
|
||||
"scripts/runtime",
|
||||
"scripts/reporting",
|
||||
]
|
||||
|
||||
|
||||
def run_pull() -> None:
|
||||
subprocess.run(["git", "pull", "--ff-only"], cwd=REPO_ROOT, check=True)
|
||||
|
||||
|
||||
def reset_dir(path: Path) -> None:
|
||||
if path.exists():
|
||||
shutil.rmtree(path)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def copy_file(rel: str, target_root: Path) -> None:
|
||||
src = REPO_ROOT / rel
|
||||
if not src.exists():
|
||||
raise FileNotFoundError(src)
|
||||
dst = target_root / rel
|
||||
dst.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(src, dst)
|
||||
|
||||
|
||||
def copy_dir(src: Path, dst: Path) -> None:
|
||||
if not src.exists():
|
||||
raise FileNotFoundError(src)
|
||||
if dst.exists():
|
||||
shutil.rmtree(dst)
|
||||
shutil.copytree(src, dst, ignore=shutil.ignore_patterns("__pycache__", ".pytest_cache"))
|
||||
|
||||
|
||||
def copy_common_workspace(target: Path) -> None:
|
||||
for rel in COMMON_FILES:
|
||||
copy_file(rel, target)
|
||||
for rel in COMMON_DIRS:
|
||||
copy_dir(REPO_ROOT / rel, target / rel)
|
||||
(target / "projects").mkdir(parents=True, exist_ok=True)
|
||||
(target / "projects" / ".gitkeep").touch(exist_ok=True)
|
||||
|
||||
|
||||
def build_antigravity() -> Path:
|
||||
target = ENV_ROOT / "antigravity"
|
||||
reset_dir(target)
|
||||
copy_common_workspace(target)
|
||||
copy_dir(ADAPTER_ROOT / "antigravity" / "agent", target / ".agent")
|
||||
return target
|
||||
|
||||
|
||||
def build_codex() -> Path:
|
||||
target = ENV_ROOT / "codex"
|
||||
reset_dir(target)
|
||||
copy_common_workspace(target)
|
||||
copy_dir(ADAPTER_ROOT / "codex", target / "codex_home")
|
||||
copy_dir(ADAPTER_ROOT / "antigravity" / "agent" / "skills", target / "codex_home" / "skills")
|
||||
return target
|
||||
|
||||
|
||||
def build_opencode() -> Path:
|
||||
target = ENV_ROOT / "opencode"
|
||||
reset_dir(target)
|
||||
copy_common_workspace(target)
|
||||
copy_dir(ADAPTER_ROOT / "opencode", target / ".opencode")
|
||||
return target
|
||||
|
||||
|
||||
def build_claude_code() -> Path:
|
||||
target = ENV_ROOT / "claude-code"
|
||||
reset_dir(target)
|
||||
copy_common_workspace(target)
|
||||
copy_dir(ADAPTER_ROOT / "claude-code", target / ".claude")
|
||||
return target
|
||||
|
||||
|
||||
def build_gemini_cli() -> Path:
|
||||
target = ENV_ROOT / "gemini-cli"
|
||||
reset_dir(target)
|
||||
copy_common_workspace(target)
|
||||
copy_dir(ADAPTER_ROOT / "gemini-cli", target / ".gemini")
|
||||
return target
|
||||
|
||||
|
||||
BUILDERS = {
|
||||
"antigravity": build_antigravity,
|
||||
"codex": build_codex,
|
||||
"opencode": build_opencode,
|
||||
"claude-code": build_claude_code,
|
||||
"gemini-cli": build_gemini_cli,
|
||||
}
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="Update isolated Deep Research platform environments")
|
||||
parser.add_argument(
|
||||
"--platform",
|
||||
choices=["all", *BUILDERS.keys()],
|
||||
default="all",
|
||||
help="which platform env to rebuild",
|
||||
)
|
||||
parser.add_argument("--skip-pull", action="store_true", help="do not run git pull --ff-only first")
|
||||
return parser
|
||||
|
||||
|
||||
def main() -> int:
|
||||
args = build_parser().parse_args()
|
||||
if not args.skip_pull:
|
||||
run_pull()
|
||||
|
||||
names = list(BUILDERS) if args.platform == "all" else [args.platform]
|
||||
ENV_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
for name in names:
|
||||
target = BUILDERS[name]()
|
||||
print(f"rebuilt {name}: {target}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user