diff --git a/.gitignore b/.gitignore index 7434051..258ef73 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,7 @@ dist/ .venv/ venv/ env/ -skills/swarm/scripts/skills/ -skills/swarm/scripts/rules/ -skills/swarm/scripts/agents/ +skills/cloud-swarm/scripts/skills/ +skills/cloud-swarm/scripts/rules/ +skills/cloud-swarm/scripts/agents/ diff --git a/README.md b/README.md index 332619b..d6ace9b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Where pstack brought anti-slop rigor to editor chats, **agystack expands it into a distributed, multi-tier engineering fleet**: -- **Google Cloud Run Fleets (`/swarm`).** When local machines hit limits, fan out across headless cloud containers. Fleet workers run in parallel, stream real-time milestones, and deliver isolated candidate patches to GCS without git worktree collisions. +- **Google Cloud Run Fleets (`/cloud-swarm`).** When local machines hit limits, fan out across headless cloud containers. Fleet workers run in parallel, stream real-time milestones, and deliver isolated candidate patches to GCS without git worktree collisions. - **The `/loop` Hillclimb Engine.** Run automated hypothesis-and-verify loops against a concrete test command (`--verify ""`). agystack applies discrete edits, reverts regressions, and reactively iterates until green without manual babysitting. - **Automated PR Babysitting & Stack Shipping (`watch-pr`).** Eliminate GitHub PR friction. Dedicated tooling monitors CI checks, detects merge conflicts across Graphite stacks, and triages review comments. Real defects get fixed with runtime reproduction, while bot noise gets dismissed with concrete reasons. - **Adversarial Reviews & Bakeoffs (`/interrogate`, `/arena`).** Prevent single-agent blind spots. Dispatch concurrent reviewers to attack diffs from independent angles before shipping, or run competing candidate implementations in parallel worktrees and graft winning pieces sequentially. @@ -157,7 +157,10 @@ local subagents work great for up to 8 workers. but when you want massive parall workers run in isolated containers, never push to git directly, and upload `patch.diff` artifacts and streaming milestones to GCS. the coordinator ranks the winning diffs so you can review and apply them locally. -set it up with [`/setup-agystack`](./skills/setup-agystack/SKILL.md) with your Google Cloud auth and run [`/swarm`](./skills/swarm/SKILL.md) to dispatch. +set it up with [`/setup-agystack`](./skills/setup-agystack/SKILL.md) with your Google Cloud auth and run [`/cloud-swarm`](./skills/cloud-swarm/SKILL.md) to dispatch. + +> [!NOTE] +> **Upgrade Note for 0.17.0:** `/swarm` is now Google Antigravity's built-in collaborative swarm skill. agystack's Cloud Run fleet skill is now `/cloud-swarm`. If upgrading via zip archive over an existing installation, remove the legacy `skills/swarm/` directory (`setup_runtime.py --doctor` will flag it if present). ### summoning cloud agents (Gemini & DeepSeek) @@ -165,22 +168,22 @@ Cloud swarms run on Google Cloud Run with zero-friction serverless models: ```bash # list supported cloud models and tiers -python3 skills/swarm/scripts/cloud_dispatch.py --list-models +python3 skills/cloud-swarm/scripts/cloud_dispatch.py --list-models # fan out 5 Gemini Argon agents -python3 skills/swarm/scripts/cloud_dispatch.py --tasks 5 --model gemini-4-argon +python3 skills/cloud-swarm/scripts/cloud_dispatch.py --tasks 5 --model gemini-4-argon # fan out 5 DeepSeek Flash 4.1 agents -python3 skills/swarm/scripts/cloud_dispatch.py --tasks 5 --model deepseek-v4.1-flash +python3 skills/cloud-swarm/scripts/cloud_dispatch.py --tasks 5 --model deepseek-v4.1-flash ``` -Or trigger `/swarm` right in chat: -- `/swarm 5 workers using Gemini Argon to test src/` -- `/swarm 5 workers using DeepSeek Flash to explore hypotheses` +Or trigger `/cloud-swarm` right in chat: +- `/cloud-swarm 5 workers using Gemini Argon to test src/` +- `/cloud-swarm 5 workers using DeepSeek Flash to explore hypotheses` ## skills -[`/poteto-mode`](./skills/poteto-mode/SKILL.md) runs most of these for you when a step needs them (`how`, `why`, `architect`, `arena`, `swarm`, `interrogate`, `unslop`, `no-comments`, `technical-writing`, `tdd`, and the principles). the table below is for when you want one directly: +[`/poteto-mode`](./skills/poteto-mode/SKILL.md) runs most of these for you when a step needs them (`how`, `why`, `architect`, `arena`, `cloud-swarm`, `interrogate`, `unslop`, `no-comments`, `technical-writing`, `tdd`, and the principles). the table below is for when you want one directly: @@ -206,7 +209,7 @@ Or trigger `/swarm` right in chat: | `/grill-me` | your requirements are underspecified or ambiguous and you want Socratic pressure testing before kicking off architecture or autonomous execution ([guide](./docs/guide/04-design.md#flesh-out-ambiguous-requirements-with-grill-me)). | | [`/architect`](./skills/architect/SKILL.md) | you're about to write code that crosses a function boundary and want the caller's usage, types, and module shape settled first. | | [`/arena`](./skills/arena/SKILL.md) | you want N parallel attempts at the same thing, then to grab the best parts of each. | -| [`/swarm`](./skills/swarm/SKILL.md) | you want N parallel workers across different slices or races, then one aggregated report. | +| [`/cloud-swarm`](./skills/cloud-swarm/SKILL.md) | you want N parallel workers across different slices or races in Cloud Run, then one aggregated report. | | [`/interrogate`](./skills/interrogate/SKILL.md) | you have a diff and want several different models to try to break it, including a strict code-quality lens. | | [`/automate-me`](./skills/automate-me/SKILL.md) | you want your own `-mode` skill, drafted from how you've actually worked. | | [`/deslop`](./skills/deslop/SKILL.md) | you want to clean defensive code, redundant guards, and AI bloat out of diffs before commit. | @@ -262,7 +265,7 @@ architect: design this instrumentation to be high signal with no false p this first. arena: /arena take my prompt to the arena verbatim. i want to compare their proposals with yours. -swarm: /swarm check every package under packages/ against its check.sh. one worker per +cloud-swarm: /cloud-swarm check every package under packages/ against its check.sh. one worker per package. one report. interrogate: /interrogate review this pr. tdd: /tdd implement diff --git a/docs/guide/01-setup.md b/docs/guide/01-setup.md index c534a1b..704f996 100644 --- a/docs/guide/01-setup.md +++ b/docs/guide/01-setup.md @@ -54,7 +54,7 @@ Run: You only override what you care about. A role with no line in the rule keeps the skill's default. To restore a default later, delete that role's line, or just run `/setup-agystack` again. -You might be wondering what happens if you use Auto. Set a role to `inherit-parent` or `auto` and agystack omits the subagent `model` field, so the subagent inherits your parent chat model. Both values mean the same thing, and neither is a model slug. For a panel role the value is a list, and one subagent runs per entry, so the list length sets the panel size. Setup also configures `swarm workers`, the default model for every `/swarm` worker unless a race names a model for each arm. +You might be wondering what happens if you use Auto. Set a role to `inherit-parent` or `auto` and agystack omits the subagent `model` field, so the subagent inherits your parent chat model. Both values mean the same thing, and neither is a model slug. For a panel role the value is a list, and one subagent runs per entry, so the list length sets the panel size. Setup also configures `swarm workers`, the default model for every `/cloud-swarm` or local fan-out worker unless a race names a model for each arm. ## Accept the verification offer, or don't diff --git a/docs/guide/04-design.md b/docs/guide/04-design.md index 90aa395..7293a85 100644 --- a/docs/guide/04-design.md +++ b/docs/guide/04-design.md @@ -1,6 +1,6 @@ # Design before you write code -One attempt at a hard design locks in the first shape the model thought of. `/architect` settles types and boundaries before implementation. `/arena` runs several attempts at the same brief and merges the best parts. `/interrogate` has other models try to break the result. When the job is coverage rather than design synthesis, `/swarm` fans out slices or races and aggregates their results. +One attempt at a hard design locks in the first shape the model thought of. `/architect` settles types and boundaries before implementation. `/arena` runs several attempts at the same brief and merges the best parts. `/interrogate` has other models try to break the result. When the job is coverage rather than design synthesis, `/cloud-swarm` (or local fan-out) fans out slices or races and aggregates their results. ![Three robots draft competing bridge models at their own tables under /architect, /arena, and /interrogate panels, while a judge robot with a clipboard inspects skeptically.](./images/design.jpg) @@ -56,15 +56,15 @@ The panel comes from your [`/setup-agystack`](../../skills/setup-agystack/SKILL. /arena this, 5 candidates. the cache key format is expensive to change later. ``` -## Cover slices and races with `/swarm` +## Cover slices and races with `/cloud-swarm` ```text -/swarm check every package under packages/ against its check.sh. one worker per package. one report. +/cloud-swarm check every package under packages/ against its check.sh. one worker per package. one report. ``` -[`/swarm`](../../skills/swarm/SKILL.md) fans N workers across independent slices, coverage matrices, gauntlet lanes, exploration partitions, or declared race arms. Each worker gets its own scope and check, then reports `PASS`, `ISSUES`, or `BLOCKED`. The parent waits for the workers and returns one compact report with any gaps or dropouts. +[`/cloud-swarm`](../../skills/cloud-swarm/SKILL.md) fans N workers across Google Cloud Run for independent slices, coverage matrices, gauntlet lanes, exploration partitions, or declared race arms (or uses local `invoke_subagent` fan-out for 8 or fewer workers). Each worker gets its own scope and check, then reports `PASS`, `ISSUES`, or `BLOCKED`. The parent waits for the workers and returns one compact report with any gaps or dropouts. -Reach for it when parallelism buys coverage or lets independent checks race. `/arena` gives every worker the same design or code brief, then picks a base and grafts the best parts. `/swarm` covers slices or runs a race with a selection rule declared up front. It does not use the base-selection and grafting ceremony. +Reach for it when parallelism buys coverage or lets independent checks race. `/arena` gives every worker the same design or code brief, then picks a base and grafts the best parts. `/cloud-swarm` covers slices or runs a race with a selection rule declared up front. It does not use the base-selection and grafting ceremony. ## Break it with `/interrogate` @@ -83,7 +83,7 @@ You might be wondering whether every change needs this. No. Most changes need no - A small, finished change you're unsure about needs `/interrogate` alone. - A change that crosses function boundaries or moves ownership earns `/architect`, which brings `/arena` with it. - A standalone decision where independent attempts would help, like naming, formats, or an algorithm, is `/arena` directly. -- A coverage matrix, set of parallel checks, or race with declared arms is `/swarm`. +- A coverage matrix, set of parallel checks, or race with declared arms is `/cloud-swarm` (or local fan-out). - A contested design that's expensive to reverse gets `/architect`, then `/interrogate` before shipping. `/poteto-mode` already applies this ladder. Boundary-crossing work triggers `/architect` on its own, so you reach for these directly mainly when you want more or less scrutiny than the default. diff --git a/docs/guide/06-verify-and-ship.md b/docs/guide/06-verify-and-ship.md index eb99aee..cbb6ff4 100644 --- a/docs/guide/06-verify-and-ship.md +++ b/docs/guide/06-verify-and-ship.md @@ -48,7 +48,7 @@ It writes `.agents/skills/verify-/`, agent-facing instructions with exact L From then on, "verify it in the app" is a step any agent can execute, in this repo, with no setup conversation. -Once the verify skill works, a [`/swarm`](../../skills/swarm/SKILL.md) can split a full pass by feature-map entry and aggregate the results. +Once the verify skill works, a [`/cloud-swarm`](../../skills/cloud-swarm/SKILL.md) or local fan-out can split a full pass by feature-map entry and aggregate the results. ## Keep the verification skill honest diff --git a/docs/guide/10-recipes-and-pitfalls.md b/docs/guide/10-recipes-and-pitfalls.md index 8010e1c..ee42bce 100644 --- a/docs/guide/10-recipes-and-pitfalls.md +++ b/docs/guide/10-recipes-and-pitfalls.md @@ -23,7 +23,7 @@ Your current design becomes one candidate among several, and the synthesis tells ## Check independent slices in parallel ```text -/swarm check every package under packages/ against its check.sh. one worker per package. one report. +/cloud-swarm check every package under packages/ against its check.sh. one worker per package. one report. ``` Each worker owns one package. The parent waits for every slice and returns one `PASS`, `ISSUES`, or `BLOCKED` report instead of raw worker dumps. @@ -159,7 +159,7 @@ The hook intercepts `write_to_file` and `replace_file_content` to keep coordinat - **Enumerating skills in the prompt.** "use /how then /architect then /arena" reorders steps the playbook already sequences. State the goal and constraints. Name a skill only to override a default. - **A vague finish condition.** "make it better" gives `/loop` or `/goal` nothing to check. `/loop` requires a command that exits 0. `/goal` requires a checkable predicate or artifact. Give a command or artifact that can pass or fail. - **Parallel agents in one worktree.** They overwrite each other and the diff becomes archaeology. Say "own worktree per attempt" and the isolation is free. -- **Using `/arena` for coverage.** `/arena` repeats one design or code brief, then picks a base and grafts the best parts. `/swarm` partitions slices or declared race arms and aggregates one report. +- **Using `/arena` for coverage.** `/arena` repeats one design or code brief, then picks a base and grafts the best parts. `/cloud-swarm` (or local fan-out) partitions slices or declared race arms and aggregates one report. - **Accepting every review comment.** Bots and humans both file real catches and noise in one list. `/interrogate` sorts findings into act-on and dismissed buckets with reasons, and you can override either way. - **Treating `auto` as a model slug.** `auto` and `inherit-parent` mean "omit the model field so the subagent inherits the parent chat model." [Setup](./01-setup.md) covers the roles. - **Reporting success off a green build.** A build proves it compiles. Ask for the real command, flow, stored value, or profile, and expect the evidence in the reply. diff --git a/docs/guide/README.md b/docs/guide/README.md index 2073029..029ede3 100644 --- a/docs/guide/README.md +++ b/docs/guide/README.md @@ -7,7 +7,7 @@ Here's what you'll learn: 1. [Set up agystack](./01-setup.md). Install the plugin and pick your models. 2. [Route work through `/poteto-mode`](./02-poteto-mode.md). Give it a goal and watch it pick a playbook. 3. [Understand the code](./03-understand.md). `/how`, `/why`, `/teach`, and `/recall` before you edit anything. -4. [Design the change](./04-design.md). `/architect`, `/arena`, `/swarm`, and `/interrogate` before code locks in a shape. +4. [Design the change](./04-design.md). `/architect`, `/arena`, `/cloud-swarm`, and `/interrogate` before code locks in a shape. 5. [Build and clean the change](./05-build-and-clean.md). The build playbooks, `/tdd`, `/deslop`, `/unslop`, and `/no-comments`. 6. [Verify and ship](./06-verify-and-ship.md). Prove behavior on the real app, then open a focused PR and drive it to merged. 7. [Run work while you sleep](./07-overnight.md). An overnight contract, a decision log you can audit, and the playbooks that scale past one agent. diff --git a/docs/marketplace-listing.md b/docs/marketplace-listing.md index 5885f82..c430e44 100644 --- a/docs/marketplace-listing.md +++ b/docs/marketplace-listing.md @@ -28,7 +28,7 @@ Rigorous agentic engineering framework for Google Antigravity: poteto-mode, play - **Twenty-Three Rigorous Playbooks:** Structured procedural engines for bug fixes, performance investigations, refactoring, autonomous loops, and stacked shipping. - **Twenty-Four Anti-Slop Principles:** Invariant rules that prevent speculative code, enforce domain data models, and mandate real-world runtime verification. - **Subagent Context Isolation:** Guard coordinator chat context windows by delegating code changes over 50 lines to isolated background workers. -- **Google Cloud Run Swarms (`/swarm`):** Scale beyond local machine concurrency with serverless container fleets executing parallel parameter sweeps and candidate patches. +- **Google Cloud Run Swarms (`/cloud-swarm`):** Scale beyond local machine concurrency with serverless container fleets executing parallel parameter sweeps and candidate patches. - **Multi-Model Adversarial Interrogation (`/interrogate`):** Dispatch concurrent reviewer panels across distinct model tiers to challenge diffs before merge. - **Native Antigravity Artifacts:** Structured deliverables (`implementation_plan.md`, `walkthrough.md`, `_report.md`) rendered directly in the IDE canvas. diff --git a/docs/marketplace-submission.json b/docs/marketplace-submission.json index c280a4d..685aa5c 100644 --- a/docs/marketplace-submission.json +++ b/docs/marketplace-submission.json @@ -3,7 +3,7 @@ "id": "agystack", "name": "agystack", "displayName": "agystack", - "version": "0.16.0", + "version": "0.17.0", "category": "developer-tools", "description": "Rigorous agentic engineering framework for Google Antigravity: poteto-mode, playbooks, isolated subagents, adversarial reviews, and cloud swarms. Spinoff of poteto's pstack.", "author": { diff --git a/plugin.json b/plugin.json index 8afccba..cdb744e 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "$schema": "https://antigravity.google/schemas/v1/plugin.json", "name": "agystack", "displayName": "agystack", - "version": "0.16.0", + "version": "0.17.0", "description": "Rigorous agentic engineering framework for Google Antigravity: poteto-mode, playbooks, isolated subagents, adversarial reviews, and cloud swarms. Spinoff of poteto's pstack.", "author": { "name": "Joel Taroreh", diff --git a/pyproject.toml b/pyproject.toml index 865e354..993551b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "agystack" -version = "0.16.0" +version = "0.17.0" description = "Agentic swarm orchestration and poteto workflow plugin for Google Antigravity" readme = "README.md" requires-python = ">=3.11" diff --git a/rules/AGENTS.md b/rules/AGENTS.md index 557c98b..3f22cd1 100644 --- a/rules/AGENTS.md +++ b/rules/AGENTS.md @@ -14,7 +14,7 @@ Mirroring pstack in Cursor, enforce strict separation between coordination and c 2. **Mandatory Subagent Fan-Out:** You MUST invoke distinct background subagents via `invoke_subagent` for: - **Code reviews and adversarial interrogation (`/interrogate`):** Dispatch concurrent reviewers across distinct model tiers (`pro`, `flash`, `inherit`). Simulating reviewer personas in the parent context is strictly forbidden. - **Multi-candidate design and code bakeoffs (`/arena`):** Dispatch parallel subagents in isolated workspaces or scratch paths. - - **High-volume exploration sweeps and test matrices (`/swarm`):** Offload large payload reads to subagents to guard the main context window. + - **High-volume exploration sweeps and test matrices (`/cloud-swarm` for Cloud Run, local fan-out for <= 8 workers):** Offload large payload reads to subagents to guard the main context window. - **Blinded behavioral evaluations (`/eval`):** Run candidate attempts through blinded subagents. - **Cross-model decision audits (`/show-me-your-work`):** Dispatch an independent subagent on a different model family to audit the decision log. 3. **Candidate Integration Invariant:** Parallel candidate diffs from swarms, arenas, or subagent fan-outs must never be bulk-merged. The coordinator must evaluate candidate branches in isolation, rank them by delta, and graft winning modifications sequentially—verifying and benchmarking each change independently before attempting the next (`principle-sequence-verifiable-units`). diff --git a/skills/swarm/SKILL.md b/skills/cloud-swarm/SKILL.md similarity index 77% rename from skills/swarm/SKILL.md rename to skills/cloud-swarm/SKILL.md index 2fc9de5..ae11eb9 100644 --- a/skills/swarm/SKILL.md +++ b/skills/cloud-swarm/SKILL.md @@ -1,11 +1,11 @@ --- -name: swarm -description: "Fan out N parallel workers, drain them, and return one report. Use for /swarm, 'swarm this', or parallel coverage, races, gauntlets, and exploration." +name: cloud-swarm +description: "Fan out more than 8 parallel workers across Google Cloud Run for large exploration sweeps, races, gauntlets, and coverage matrices. For 8 or fewer workers use a local `invoke_subagent` fan-out. For agents that collaborate on a shared board use Antigravity's built-in /swarm." --- -# Swarm +# Cloud Swarm -Fan out N parallel workers locally or across Google Cloud Run. Workers cover separate slices or race the same brief. The parent coordinator waits, aggregates, and returns one consolidated report. +Fan out more than 8 parallel workers across Google Cloud Run. Workers cover separate slices or race the same brief. The parent coordinator waits, aggregates, and returns one consolidated report. ## Start @@ -22,23 +22,11 @@ Open a todolist with one entry per phase before launching anything. 2. Choose the shape: partition into slices, race N workers on identical briefs, or mix both. For a race, declare `first pass`, `rank all`, or `best-of`. 3. Set N. N is total workers. 4. Pick worker model from `swarm workers` in `~/.gemini/config/plugins/agystack/agystack-models.md` (default: `flash`). -5. Check execution runtime: - - If `agystack-runtime.json` does not exist or specifies `"runtime": "local"`, use local subagents for N <= 8. - - If N > 8 or `agystack-runtime.json` specifies `"runtime": "cloud-run"`, use Cloud Run dispatch. +5. Execution routing: + - For 8 or fewer workers (and unless `agystack-runtime.json` specifies `"runtime": "cloud-run"`), use local `invoke_subagent` fan-out (see `skills/poteto-mode/references/antigravity-tools.md`). + - For more than 8 workers or when `agystack-runtime.json` specifies `"runtime": "cloud-run"`, use Cloud Run dispatch. -## Phase B: Fan out - -### Local Subagents (N <= 8) - -Spawn all N workers in one `invoke_subagent` call with `TypeName: "poteto-agent"` (or `"self"`), `Role: "Swarm Worker ()"`, `Workspace: "branch"`, and the configured model. In each worker prompt, explicitly provide `{PARENT_CONVERSATION_ID}` and mandate that upon task completion, the worker MUST invoke `send_message` with `Recipient: "{PARENT_CONVERSATION_ID}"` to deliver its slice status and findings (mirroring `skills/interrogate/references/reviewer-prompt.md`) so the coordinator receives reactive wakeups without timing out. - -**Reactive Dispatch & Watchdog Protocol:** -- **Turn 1 (Dispatch & Arm):** Dispatch local workers via `invoke_subagent` and arm a single global watchdog deadline using `schedule(DurationSeconds: 300..600, Prompt="Watchdog: swarm workers timed out", TimerCondition: "never")`. -- **Turn 2 (Yield):** Output a status update with ZERO tool calls (`tool_calls: []`). Never run busy polling loops on local subagents. -- **Incremental Arrivals:** On each worker arrival via `send_message`, record slice results and yield immediately with ZERO tool calls if workers remain active. -- **Teardown & Completion:** Once all N workers complete, cancel the watchdog timer via `manage_task(Action: "kill", TaskId: )` and proceed to Phase C. If the watchdog fires, diagnose via `manage_subagents(Action: "list")`, terminate unresponsive workers (`manage_subagents(Action: "kill", ConversationIds: [])`), and aggregate available slice results. - -### Cloud Run Dispatch (N > 8 or Cloud Run Runtime) +## Phase B: Fan out (Cloud Run Dispatch) Cloud Run swarms enable parallel execution across dozens or hundreds of container tasks. @@ -82,14 +70,14 @@ Before launching cloud swarms, match the model to the project's Model Garden ena 2. **Execute Active Pre-Flight Check:** Run active pre-flight validation to ensure credentials, git remotes, model endpoints, and GCS buckets are reachable before spinning up compute: ```bash - python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" --preflight --gcs-bucket --model gemini-3.8-flash --vertex + python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/cloud-swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" --preflight --gcs-bucket --model gemini-3.8-flash --vertex ``` (Pre-flight runs automatically by default during dispatch unless `--no-preflight` is specified.) 3. **Launch the Swarm & Stream Real-Time Milestones:** Launch cloud dispatch CLI with unbuffered streaming and fail-fast candidate evaluation: ```bash - python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ + python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/cloud-swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ --manifest \ --tasks \ --gcs-bucket \ @@ -102,18 +90,18 @@ Before launching cloud swarms, match the model to the project's Model Garden ena When coordinating asynchronously, pass `--no-wait` to `cloud_dispatch.py` to prevent blocking the agent turn: ```bash # Dispatch asynchronously and return execution handle immediately - python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ + python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/cloud-swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ --manifest \ --tasks \ --gcs-bucket \ --no-wait # Harvest and rank candidate patches from an existing session without launching compute - python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ + python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/cloud-swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ --harvest-session --gcs-bucket --baseline-score # Attach to a running execution to stream milestones and harvest upon completion - python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ + python3 "${AGYSTACK_DISPATCH_SCRIPT:-$(find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/cloud-swarm/scripts" -name cloud_dispatch.py 2>/dev/null | head -n 1)}" \ --wait-execution --session --gcs-bucket ``` The dispatcher automatically executes pre-flight checks, retrieves `GH_TOKEN` via `gh auth token`, executes the Cloud Run Job, streams real-time unbuffered `[MILESTONE]` execution progress directly to stdout as events occur, and aggregates final candidate patches into a ranked summary report. Dispatchers and coordinators must never block passively on buffered command execution. @@ -141,11 +129,10 @@ Every brief stands alone. Include goal, scope, exact slice, verification command ## Phase C: Aggregate & Early Harvest -1. For local workers: collect terminal reports from `invoke_subagent`. -2. For cloud workers: `cloud_dispatch.py` automatically harvests candidate patches from GCS into `.slices//task-/` and displays candidate patch file locations in the execution summary. -3. Apply selection rule (first pass, rank all, best-of): rank candidates by score delta descending. -4. **Candidate Integration Protocol:** Apply the winning `patch.diff` to a local worktree (`git apply .slices//task-/patch.diff`), run local verification, and commit. If verified, re-baseline and evaluate subsequent candidates sequentially. Never merge or compose multiple candidate patches simultaneously without intermediate verification (`principle-sequence-verifiable-units`). -5. Build a compact result table, one-line evidenced issues, and explicit dropouts. +1. `cloud_dispatch.py` automatically harvests candidate patches from GCS into `.slices//task-/` and displays candidate patch file locations in the execution summary. +2. Apply selection rule (first pass, rank all, best-of): rank candidates by score delta descending. +3. **Candidate Integration Protocol:** Apply the winning `patch.diff` to a local worktree (`git apply .slices//task-/patch.diff`), run local verification, and commit. If verified, re-baseline and evaluate subsequent candidates sequentially. Never merge or compose multiple candidate patches simultaneously without intermediate verification (`principle-sequence-verifiable-units`). +4. Build a compact result table, one-line evidenced issues, and explicit dropouts. ## Phase D: Report diff --git a/skills/swarm/scripts/Dockerfile b/skills/cloud-swarm/scripts/Dockerfile similarity index 100% rename from skills/swarm/scripts/Dockerfile rename to skills/cloud-swarm/scripts/Dockerfile diff --git a/skills/swarm/scripts/cloud_dispatch.py b/skills/cloud-swarm/scripts/cloud_dispatch.py similarity index 96% rename from skills/swarm/scripts/cloud_dispatch.py rename to skills/cloud-swarm/scripts/cloud_dispatch.py index bf9e957..0c6f9a5 100644 --- a/skills/swarm/scripts/cloud_dispatch.py +++ b/skills/cloud-swarm/scripts/cloud_dispatch.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -CLI dispatcher script called by /swarm or /orchestrate to launch Cloud Run Job +CLI dispatcher script called by /cloud-swarm or /orchestrate to launch Cloud Run Job for parallel swarm agent execution. Constructs and executes gcloud run jobs execute, streams status, and aggregates results. """ @@ -18,6 +18,10 @@ from pathlib import Path from typing import Any, Dict, List, Optional, Set, Union +SCRIPT_DIR = Path(__file__).resolve().parent +if str(SCRIPT_DIR) not in sys.path: + sys.path.insert(0, str(SCRIPT_DIR)) + try: from storage_messenger import StorageMessenger except ImportError: @@ -26,16 +30,15 @@ try: from worker.partner_engine import PARTNER_MODEL_ALIASES, is_partner_model except ImportError: - try: - from skills.swarm.scripts.worker.partner_engine import PARTNER_MODEL_ALIASES, is_partner_model - except ImportError: - is_partner_model = None - PARTNER_MODEL_ALIASES = {} + is_partner_model = None + PARTNER_MODEL_ALIASES = {} try: from worker.execution import LIMIT_ENV, TERMINAL_STATES, resolve_execution_limits except ImportError: - from skills.swarm.scripts.worker.execution import LIMIT_ENV, TERMINAL_STATES, resolve_execution_limits + LIMIT_ENV = {} + TERMINAL_STATES = set() + resolve_execution_limits = None TIER3_DEDICATED_MODELS = { @@ -405,71 +408,37 @@ def _flush(): return results -try: - from transcript_projector import ( - TELEMETRY_REGEX, - ShadowTranscriptProjector, - cleanup_session, - format_conversation_url, - get_task_brain_dir, - get_task_conversation_id, - initialize_shadow_transcript, - is_telemetry_line, - parse_telemetry_line, - resolve_app_data_dir, - ) -except ImportError: - from skills.swarm.scripts.transcript_projector import ( - TELEMETRY_REGEX, - ShadowTranscriptProjector, - cleanup_session, - format_conversation_url, - get_task_brain_dir, - get_task_conversation_id, - initialize_shadow_transcript, - is_telemetry_line, - parse_telemetry_line, - resolve_app_data_dir, - ) - -try: - from swarm_dashboard import ( - MILESTONE_REGEX, - STATUS_BADGES, - SwarmDashboardWriter, - TaskDashboardState, - colorize, - format_cloud_logging_url, - format_cloud_run_execution_url, - format_cloud_run_url, - format_elapsed_time, - format_gcs_console_url, - format_gcs_url, - format_log_viewer_url, - format_monitored_line, - format_status_badge, - format_tool_snippet, - parse_milestone_log, - ) -except ImportError: - from skills.swarm.scripts.swarm_dashboard import ( - MILESTONE_REGEX, - STATUS_BADGES, - SwarmDashboardWriter, - TaskDashboardState, - colorize, - format_cloud_logging_url, - format_cloud_run_execution_url, - format_cloud_run_url, - format_elapsed_time, - format_gcs_console_url, - format_gcs_url, - format_log_viewer_url, - format_monitored_line, - format_status_badge, - format_tool_snippet, - parse_milestone_log, - ) +from transcript_projector import ( + TELEMETRY_REGEX, + ShadowTranscriptProjector, + cleanup_session, + format_conversation_url, + get_task_brain_dir, + get_task_conversation_id, + initialize_shadow_transcript, + is_telemetry_line, + parse_telemetry_line, + resolve_app_data_dir, +) + +from swarm_dashboard import ( + MILESTONE_REGEX, + STATUS_BADGES, + SwarmDashboardWriter, + TaskDashboardState, + colorize, + format_cloud_logging_url, + format_cloud_run_execution_url, + format_cloud_run_url, + format_elapsed_time, + format_gcs_console_url, + format_gcs_url, + format_log_viewer_url, + format_monitored_line, + format_status_badge, + format_tool_snippet, + parse_milestone_log, +) __all__ = [ "TELEMETRY_REGEX", @@ -1175,21 +1144,14 @@ def resolve_swarm_model( handle_mailbox_steer, ) except ImportError: - try: - from skills.swarm.scripts.dispatch.mailbox_controller import ( - handle_mailbox_list, - handle_mailbox_reply, - handle_mailbox_steer, - ) - except ImportError: - _disp_dir = Path(__file__).resolve().parent / "dispatch" - if str(_disp_dir) not in sys.path: - sys.path.insert(0, str(_disp_dir)) - from mailbox_controller import ( # type: ignore - handle_mailbox_list, - handle_mailbox_reply, - handle_mailbox_steer, - ) + _disp_dir = Path(__file__).resolve().parent / "dispatch" + if str(_disp_dir) not in sys.path: + sys.path.insert(0, str(_disp_dir)) + from mailbox_controller import ( # type: ignore + handle_mailbox_list, + handle_mailbox_reply, + handle_mailbox_steer, + ) def failed_task_count(report_items: List[Dict[str, Any]], task_count: int) -> int: diff --git a/skills/swarm/scripts/cloud_worker.py b/skills/cloud-swarm/scripts/cloud_worker.py similarity index 94% rename from skills/swarm/scripts/cloud_worker.py rename to skills/cloud-swarm/scripts/cloud_worker.py index 3f61849..7394de0 100644 --- a/skills/swarm/scripts/cloud_worker.py +++ b/skills/cloud-swarm/scripts/cloud_worker.py @@ -21,6 +21,10 @@ from pathlib import Path from typing import Any, Dict, List, Optional, Tuple +SCRIPT_DIR = Path(__file__).resolve().parent +if str(SCRIPT_DIR) not in sys.path: + sys.path.insert(0, str(SCRIPT_DIR)) + try: from storage_messenger import StorageMessenger except ImportError: @@ -171,7 +175,8 @@ def emit_agent_response( try: from worker.execution import CREDENTIAL_PATTERNS as CREDENTIAL_PATTERNS, scrub_credentials except ImportError: - from skills.swarm.scripts.worker.execution import CREDENTIAL_PATTERNS as CREDENTIAL_PATTERNS, scrub_credentials + CREDENTIAL_PATTERNS = [] + def scrub_credentials(text): return text class TokenShield: @@ -262,20 +267,12 @@ def emit_tool_result( -try: - from worker.agent_hooks import ( - StagnancyTracker as StagnancyTracker, - ToolInvocationRecord as ToolInvocationRecord, - create_agent_hooks as create_agent_hooks, - create_ask_orchestrator_tool as create_ask_orchestrator_tool, - ) -except ImportError: - from skills.swarm.scripts.worker.agent_hooks import ( - StagnancyTracker as StagnancyTracker, - ToolInvocationRecord as ToolInvocationRecord, - create_agent_hooks as create_agent_hooks, - create_ask_orchestrator_tool as create_ask_orchestrator_tool, - ) +from worker.agent_hooks import ( + StagnancyTracker as StagnancyTracker, + ToolInvocationRecord as ToolInvocationRecord, + create_agent_hooks as create_agent_hooks, + create_ask_orchestrator_tool as create_ask_orchestrator_tool, +) def get_env_var(name: str, default: Optional[str] = None, required: bool = False) -> str: @@ -690,42 +687,22 @@ def parse_porcelain_status(stdout: str) -> List[str]: return modified_files -try: - from worker.execution import ExecutionLimits, evaluate_agent_status, limits_for_task, run_bounded_shell, write_diagnostic -except ImportError: - from skills.swarm.scripts.worker.execution import ExecutionLimits, evaluate_agent_status, limits_for_task, run_bounded_shell, write_diagnostic - - -try: - from worker.partner_engine import ( - PARTNER_MODEL_ALIASES as PARTNER_MODEL_ALIASES, - PARTNER_MODELS as PARTNER_MODELS, - WORKSPACE_TOOLS as WORKSPACE_TOOLS, - execute_claude_model_agent as execute_claude_model_agent, - execute_deepseek_model_agent as execute_deepseek_model_agent, - execute_fable_model_agent as execute_fable_model_agent, - execute_partner_model_agent as execute_partner_model_agent, - execute_workspace_tool as execute_workspace_tool, - is_deepseek_model as is_deepseek_model, - is_fable_model as is_fable_model, - is_partner_model as is_partner_model, - measure_partner_client_startup as measure_partner_client_startup, - ) -except ImportError: - from skills.swarm.scripts.worker.partner_engine import ( - PARTNER_MODEL_ALIASES as PARTNER_MODEL_ALIASES, - PARTNER_MODELS as PARTNER_MODELS, - WORKSPACE_TOOLS as WORKSPACE_TOOLS, - execute_claude_model_agent as execute_claude_model_agent, - execute_deepseek_model_agent as execute_deepseek_model_agent, - execute_fable_model_agent as execute_fable_model_agent, - execute_partner_model_agent as execute_partner_model_agent, - execute_workspace_tool as execute_workspace_tool, - is_deepseek_model as is_deepseek_model, - is_fable_model as is_fable_model, - is_partner_model as is_partner_model, - measure_partner_client_startup as measure_partner_client_startup, - ) +from worker.execution import ExecutionLimits, evaluate_agent_status, limits_for_task, run_bounded_shell, write_diagnostic + +from worker.partner_engine import ( + PARTNER_MODEL_ALIASES as PARTNER_MODEL_ALIASES, + PARTNER_MODELS as PARTNER_MODELS, + WORKSPACE_TOOLS as WORKSPACE_TOOLS, + execute_claude_model_agent as execute_claude_model_agent, + execute_deepseek_model_agent as execute_deepseek_model_agent, + execute_fable_model_agent as execute_fable_model_agent, + execute_partner_model_agent as execute_partner_model_agent, + execute_workspace_tool as execute_workspace_tool, + is_deepseek_model as is_deepseek_model, + is_fable_model as is_fable_model, + is_partner_model as is_partner_model, + measure_partner_client_startup as measure_partner_client_startup, +) def resolve_worker_model(raw_model: Optional[str] = None, task_item: Any = None) -> str: """ Resolves the worker model for a task, respecting per-task overrides in task_item, diff --git a/skills/swarm/scripts/dispatch/__init__.py b/skills/cloud-swarm/scripts/dispatch/__init__.py similarity index 100% rename from skills/swarm/scripts/dispatch/__init__.py rename to skills/cloud-swarm/scripts/dispatch/__init__.py diff --git a/skills/swarm/scripts/dispatch/mailbox_controller.py b/skills/cloud-swarm/scripts/dispatch/mailbox_controller.py similarity index 100% rename from skills/swarm/scripts/dispatch/mailbox_controller.py rename to skills/cloud-swarm/scripts/dispatch/mailbox_controller.py diff --git a/skills/swarm/scripts/manifest_generator.py b/skills/cloud-swarm/scripts/manifest_generator.py similarity index 100% rename from skills/swarm/scripts/manifest_generator.py rename to skills/cloud-swarm/scripts/manifest_generator.py diff --git a/skills/swarm/scripts/requirements.txt b/skills/cloud-swarm/scripts/requirements.txt similarity index 100% rename from skills/swarm/scripts/requirements.txt rename to skills/cloud-swarm/scripts/requirements.txt diff --git a/skills/swarm/scripts/result_harvester.py b/skills/cloud-swarm/scripts/result_harvester.py similarity index 100% rename from skills/swarm/scripts/result_harvester.py rename to skills/cloud-swarm/scripts/result_harvester.py diff --git a/skills/swarm/scripts/simulate_cloud_swarm.py b/skills/cloud-swarm/scripts/simulate_cloud_swarm.py similarity index 100% rename from skills/swarm/scripts/simulate_cloud_swarm.py rename to skills/cloud-swarm/scripts/simulate_cloud_swarm.py diff --git a/skills/swarm/scripts/steer_cloud_task.py b/skills/cloud-swarm/scripts/steer_cloud_task.py similarity index 100% rename from skills/swarm/scripts/steer_cloud_task.py rename to skills/cloud-swarm/scripts/steer_cloud_task.py diff --git a/skills/swarm/scripts/storage_messenger.py b/skills/cloud-swarm/scripts/storage_messenger.py similarity index 100% rename from skills/swarm/scripts/storage_messenger.py rename to skills/cloud-swarm/scripts/storage_messenger.py diff --git a/skills/swarm/scripts/storage_uploader.py b/skills/cloud-swarm/scripts/storage_uploader.py similarity index 98% rename from skills/swarm/scripts/storage_uploader.py rename to skills/cloud-swarm/scripts/storage_uploader.py index aa766c2..e7b8d55 100644 --- a/skills/swarm/scripts/storage_uploader.py +++ b/skills/cloud-swarm/scripts/storage_uploader.py @@ -10,10 +10,14 @@ from pathlib import Path from typing import Dict, List, Optional, Union +SCRIPT_DIR = Path(__file__).resolve().parent +if str(SCRIPT_DIR) not in sys.path: + sys.path.insert(0, str(SCRIPT_DIR)) + try: from worker.execution import CREDENTIAL_PATTERNS except ImportError: - from skills.swarm.scripts.worker.execution import CREDENTIAL_PATTERNS + CREDENTIAL_PATTERNS = [] def is_sensitive_path(path: Path, root: Path) -> bool: diff --git a/skills/swarm/scripts/swarm_dashboard.py b/skills/cloud-swarm/scripts/swarm_dashboard.py similarity index 98% rename from skills/swarm/scripts/swarm_dashboard.py rename to skills/cloud-swarm/scripts/swarm_dashboard.py index 2be587e..757380c 100644 --- a/skills/swarm/scripts/swarm_dashboard.py +++ b/skills/cloud-swarm/scripts/swarm_dashboard.py @@ -17,20 +17,16 @@ from pathlib import Path from typing import Any, Dict, List, Optional, Union -try: - from transcript_projector import ( - format_conversation_url, - is_telemetry_line, - parse_telemetry_line, - resolve_app_data_dir, - ) -except ImportError: - from skills.swarm.scripts.transcript_projector import ( - format_conversation_url, - is_telemetry_line, - parse_telemetry_line, - resolve_app_data_dir, - ) +SCRIPT_DIR = Path(__file__).resolve().parent +if str(SCRIPT_DIR) not in sys.path: + sys.path.insert(0, str(SCRIPT_DIR)) + +from transcript_projector import ( + format_conversation_url, + is_telemetry_line, + parse_telemetry_line, + resolve_app_data_dir, +) STATUS_BADGES: Dict[str, str] = { "QUEUED": "⏳ Queued", diff --git a/skills/swarm/scripts/transcript_projector.py b/skills/cloud-swarm/scripts/transcript_projector.py similarity index 100% rename from skills/swarm/scripts/transcript_projector.py rename to skills/cloud-swarm/scripts/transcript_projector.py diff --git a/skills/swarm/scripts/worker/__init__.py b/skills/cloud-swarm/scripts/worker/__init__.py similarity index 100% rename from skills/swarm/scripts/worker/__init__.py rename to skills/cloud-swarm/scripts/worker/__init__.py diff --git a/skills/swarm/scripts/worker/agent_hooks.py b/skills/cloud-swarm/scripts/worker/agent_hooks.py similarity index 100% rename from skills/swarm/scripts/worker/agent_hooks.py rename to skills/cloud-swarm/scripts/worker/agent_hooks.py diff --git a/skills/swarm/scripts/worker/execution.py b/skills/cloud-swarm/scripts/worker/execution.py similarity index 100% rename from skills/swarm/scripts/worker/execution.py rename to skills/cloud-swarm/scripts/worker/execution.py diff --git a/skills/swarm/scripts/worker/partner_engine.py b/skills/cloud-swarm/scripts/worker/partner_engine.py similarity index 100% rename from skills/swarm/scripts/worker/partner_engine.py rename to skills/cloud-swarm/scripts/worker/partner_engine.py diff --git a/skills/poteto-mode/SKILL.md b/skills/poteto-mode/SKILL.md index 38c03fb..42c3a97 100644 --- a/skills/poteto-mode/SKILL.md +++ b/skills/poteto-mode/SKILL.md @@ -22,7 +22,7 @@ Remaining triggers: - Code modifications and delegation → delegate all non-trivial source code edits (> 50 lines on a single file, multi-file changes) to `poteto-agent` via `invoke_subagent`. Trivial edits (<= 50 lines on a single file, existing or new file creation, single flag adjustments, `.gitignore`, scratch scripts in `scratch/`) and markdown documentation are permitted directly by the coordinator. - Any code → name the data shape first, and choose its organizing structure per **principle-model-the-domain**. - Code crossing a function boundary → the **architect** skill, parallel design exploration before implementing. -- Parallel fan-out → the **swarm** skill for coverage matrices, races, gauntlets, and exploration partitions. Use **arena** for design or code bakeoffs with base selection and grafting. Dispatch real background subagents via `invoke_subagent`; never simulate candidates in-context. +- Parallel fan-out → Local fan-out (`references/antigravity-tools.md`) for <= 8 workers or the **/cloud-swarm** skill for > 8 workers (coverage matrices, races, gauntlets, and exploration partitions). Use **arena** for design or code bakeoffs with base selection and grafting. Dispatch real background subagents via `invoke_subagent`; never simulate candidates in-context. - Code review or contested design → the **interrogate** skill (multi-model adversarial) before shipping. Dispatch concurrent review subagents via `invoke_subagent` across configured model tiers; never simulate reviewer personas in-context. - Nontrivial multi-step interactive work (`Feature`, `Refactoring`, `Multi-phase`) → write the throughput checkpoint (Feature step 3) and create or update the `implementation_plan.md` artifact (`/brain//implementation_plan.md`) with `ArtifactMetadata: { Summary: "...", UserFacing: true, RequestFeedback: true }` before coding. - Completed and verified work in state-changing playbooks → create or update the `walkthrough.md` artifact (`/brain//walkthrough.md`) recording changes made, verification commands, and pass receipts before closing. @@ -96,9 +96,9 @@ Read the leaf skill in full for any principle you apply. Each entry names when i ## Subagents -**Use `TypeName: "poteto-agent"` for any subagent you spawn inside a playbook step** (code-writing delegates, ad-hoc helpers). `/poteto-mode` and `poteto-agent` route through the same wrapper. Routed workflow skills (`how`, `why`, `interrogate`, `reflect`, `swarm`) set their own `TypeName` (`research`, `self`, `poteto-agent`) and distinct model tiers for diverse review; respect what the skill prescribes, don't override to `poteto-agent`. +**Use `TypeName: "poteto-agent"` for any subagent you spawn inside a playbook step** (code-writing delegates, ad-hoc helpers). `/poteto-mode` and `poteto-agent` route through the same wrapper. Routed workflow skills (`how`, `why`, `interrogate`, `reflect`, `cloud-swarm`) set their own `TypeName` (`research`, `self`, `poteto-agent`) and distinct model tiers for diverse review; respect what the skill prescribes, don't override to `poteto-agent`. -**Defaults for every subagent call.** `Workspace: "inherit"` (or `"branch"` for isolated worktrees), file pointers not inlined context, explicit model per role (configurable via `/setup-agystack`; defaults `flash` for fast code and mechanical scans, `pro` for prose, judgment, and hard tasks). Code delegates tier by difficulty. The hardest changes (cross-cutting design, gnarly concurrency, subtle algorithms) go to your strongest judgment/reasoning model (`pro`) when the task needs judgment or the intent is vague, and to `pro` when the work is a precisely specified sequence of steps to execute to the letter; trivial mechanical edits go to your fast code model (`flash`). Per-role lines in the `/setup-agystack` rule override these defaults and the model choices in the routed skills (`how`, `why`, `arena`, `swarm`, `architect`, `interrogate`, `reflect`); a role with no line keeps its default, and a role line of `inherit` or `auto` runs that role on the parent chat model (omit subagent `Model` or pass `"inherit"`). +**Defaults for every subagent call.** `Workspace: "inherit"` (or `"branch"` for isolated worktrees), file pointers not inlined context, explicit model per role (configurable via `/setup-agystack`; defaults `flash` for fast code and mechanical scans, `pro` for prose, judgment, and hard tasks). Code delegates tier by difficulty. The hardest changes (cross-cutting design, gnarly concurrency, subtle algorithms) go to your strongest judgment/reasoning model (`pro`) when the task needs judgment or the intent is vague, and to `pro` when the work is a precisely specified sequence of steps to execute to the letter; trivial mechanical edits go to your fast code model (`flash`). Per-role lines in the `/setup-agystack` rule override these defaults and the model choices in the routed skills (`how`, `why`, `arena`, `cloud-swarm`, `architect`, `interrogate`, `reflect`); a role with no line keeps its default, and a role line of `inherit` or `auto` runs that role on the parent chat model (omit subagent `Model` or pass `"inherit"`). You own every subagent's work. Review the diff and write your own summary, don't pass through what it said. Use `send_message` to iterate with an active worker on sequential adjustments to preserve context and reduce prompt overhead. When closing a major phase or starting a distinct unit of work, spawn a fresh subagent with consolidated scope rather than resume-chaining. A subagent already running as a delegate, or executing in an environment where subagent spawning is disallowed (such as `allow_subagents=False` in cloud workers or subagents without nesting tools), satisfies this invariant by executing and owning the diff directly. A second opinion is the same prompt against a different model. Agreement is high-signal. @@ -143,7 +143,7 @@ A large or cross-cutting effort (a migration across many call sites, an ambitiou - **Shipping.** The half after Babysit. Independently verifying a green stack, then landing the contiguous verified run with Graphite merge-when-ready. `playbooks/shipping.md`. - **Autonomous run.** A long task to drive to completion without stopping ("run until done", "/goal" for overnight / long autonomous runs, "/loop" for inner-loop verification hillclimbs). `playbooks/autonomous-run.md`. - **Orchestrate.** A standing project handed to one coordinator chat: multi-day, many stacked PRs, dozens to hundreds of subagents, minimal human turns ("run this whole project", "own this migration until it lands"). Distinct from Autonomous run, which drives one task to a predicate; work one agent could finish inside the session's budget routes there, not here, however program-shaped the phrasing sounds. `playbooks/orchestrate.md`. -- **Autopilot-full.** A queue of independent PRs run to merged with full autonomy: one owner per PR carries build through merge, and the root swarm-verifies each merge-ready head before its owner merges ("autopilot this queue", "full autopilot", one-owner-per-PR programs). `playbooks/autopilot-full.md`. +- **Autopilot-full.** A queue of independent PRs run to merged with full autonomy: one owner per PR carries build through merge, and the root fan-out verifies each merge-ready head before its owner merges ("autopilot this queue", "full autopilot", one-owner-per-PR programs). `playbooks/autopilot-full.md`. - **Autopilot-stack.** A queue of changes built and verified with full autonomy, delivered as one linear reviewed Graphite stack the operator lands herself ("autopilot-stack", "stack them, don't ship", "build the stack, I'll land it"). `playbooks/autopilot-stack.md`. - **Session pickup.** Resuming or taking over a prior agent's in-flight work from a transcript, cloud-agent URL, or pushed branch. `playbooks/session-pickup.md`. - **Pause safely.** Suspending in-flight work cleanly so it can be resumed, on an explicit pause, going offline, an Antigravity restart, or imminent context compaction. The complement to Session pickup. Full steps: `playbooks/pause-safely.md`. diff --git a/skills/poteto-mode/playbooks/autopilot-full.md b/skills/poteto-mode/playbooks/autopilot-full.md index 17cfa25..23b79fd 100644 --- a/skills/poteto-mode/playbooks/autopilot-full.md +++ b/skills/poteto-mode/playbooks/autopilot-full.md @@ -5,7 +5,7 @@ 1. **Mark the operator's items and honor state-then-wait.** Items the operator names stay with the operator. The operator reviews and clicks, and no owner merges one. When the operator asks for the protocol or the plan to be stated, deliver the statement and stop. Execution starts only on the operator's explicit go. On that go, arm a `/goal` with the full program objective. The goal continues across turns until the queue is done. 2. **Spawn one owner per PR with the full lifecycle.** One subagent per PR owns build, gt registration, self-proof on the real artifact (the **prove-it-works** principle skill), skeptical Bugbot triage per `../references/bugbot-triage.md`, a slop-strip (the **deslop** skill (`/deslop`)), `/no-comments` (the **no-comments** skill), a restack onto current trunk, the babysit loop to green (`playbooks/babysit.md`), and the merge itself. The owner does the first rebase before the code-ready report and babysit, whether or not trunk has drifted. In fix rounds, the owner keeps that merge base. The owner rebases again only on merge conflicts, on a confirmed stale-base CI failure (`git fetch origin ` confirming `git merge-base --is-ancestor origin/ HEAD` exits 1), on a merge-prep rebase request from the root, or at merge prep (step 5). Every owner keeps a decisions.tsv trail per the **show-me-your-work** skill, never committed, returned with its reports. The merge is the one step an owner may not take alone; step 4 gates it. 3. **Run owners in true parallel and never stack.** Many owners at once when PRs are self-contained: one writer per branch, disjoint files, cross-PR drift absorbed by rebase. Only genuinely overlapping work serializes. Self-contained PRs branch straight off main, and sequenced work is merge-then-branch. Every PR is still gt-registered; the Graphite-metadata rule is about the UI, not stacks. One exception: an owner that must split a genuinely dependent change may hold a short private stack. -4. **Swarm-verify every round before its merge.** Pragmatism rules: Block PRs only on reproducible runtime failures or incorrect shipped documentation. Wording-only and documentation changes bypass the dedicated verifier subagent. Push each finished unit before starting the next. A round starts at the owner's code-ready head SHA and at each later push that changes the PR's patch. At that SHA, fan out parallel independent verifiers per the **swarm** skill and aggregate to one verdict. The merge needs a clean verdict from the round whose patch matches the merge-ready head. Audit the receipts in the owner's report for that round before the verdict. The lanes: re-run the gates at that SHA. Prove the load-bearing behavior live on the real surface the change touches (browser verification or CLI execution as the change demands). Audit the diff, distrusting the PR body. Run the audit as two or more review lanes with the full brief. Give each lane one main focus, such as consumer parity with trunk, lifetimes and races, or data and config safety. **Regression lane against trunk.** Run the same load-bearing scenario on current trunk. If trunk does not have the feature, record that fact and gate the behavior the diff adds plus the end state the user waits for instead of pretending trunk can produce it. The live lane is the floor, and a verdict without it is not clean. No merge without the root's clean verdict. When the lanes return, send every proven finding against the PR to the owner in one fix-forward. A defect that a lane filed as a note is a finding. For each behavior finding, ask for a red test that covers every site with the same defect. Where no test can show the defect, ask for a repro receipt instead. Add that defect to the next round's review brief. The new head gets a fresh swarm and a fresh verdict. A pure rebase with an unchanged patch-id preserves lane results per `playbooks/shipping.md`; any fix-forward modifying code or tests runs a fresh round. +4. **Swarm-verify every round before its merge.** Pragmatism rules: Block PRs only on reproducible runtime failures or incorrect shipped documentation. Wording-only and documentation changes bypass the dedicated verifier subagent. Push each finished unit before starting the next. A round starts at the owner's code-ready head SHA and at each later push that changes the PR's patch. At that SHA, fan out parallel independent verifiers per the Local fan-out section of `skills/poteto-mode/references/antigravity-tools.md` (or `/cloud-swarm` for > 8 lanes) and aggregate to one verdict. The merge needs a clean verdict from the round whose patch matches the merge-ready head. Audit the receipts in the owner's report for that round before the verdict. The lanes: re-run the gates at that SHA. Prove the load-bearing behavior live on the real surface the change touches (browser verification or CLI execution as the change demands). Audit the diff, distrusting the PR body. Run the audit as two or more review lanes with the full brief. Give each lane one main focus, such as consumer parity with trunk, lifetimes and races, or data and config safety. **Regression lane against trunk.** Run the same load-bearing scenario on current trunk. If trunk does not have the feature, record that fact and gate the behavior the diff adds plus the end state the user waits for instead of pretending trunk can produce it. The live lane is the floor, and a verdict without it is not clean. No merge without the root's clean verdict. When the lanes return, send every proven finding against the PR to the owner in one fix-forward. A defect that a lane filed as a note is a finding. For each behavior finding, ask for a red test that covers every site with the same defect. Where no test can show the defect, ask for a repro receipt instead. Add that defect to the next round's review brief. The new head gets a fresh swarm and a fresh verdict. A pure rebase with an unchanged patch-id preserves lane results per `playbooks/shipping.md`; any fix-forward modifying code or tests runs a fresh round. 5. **On a clean verdict the owner merges and takes the next item.** The owner merges only from a head freshly rebased onto trunk. Merge prep never comes before a round's lanes start, and it ends with a rebase onto current trunk right before the merge. After the merge-prep rebase, the owner reports the new head SHA. CI must pass on that head before the merge, and the patch-id rule decides whether the round's verdict still holds. If trunk moves again before the merge, the patch-id rule in `playbooks/shipping.md` governs re-verification. A new head voids the verdict unless the patch-id is unchanged. The owner squash-merges its own PR through the resolved forge and picks up its next self-contained item from the queue. The operator's full-autonomy grant plus the root's clean verdict is the merge authorization that babysitting alone never has. Operator-named items stop at merge-ready and wait for the operator's click. 6. **Run the root layer.** A genuinely new raise of a pinned gate or budget value (a limit CI only lets tighten) needs your fresh countersign, granted only after verifier proof. Absorbing values that already landed on main is drift, not a raise. Run an audit tick over all owners roughly every 30 minutes or hourly. The root arms each tick via Antigravity's scheduled tasks (`schedule` tool / `/schedule`, e.g. `DurationSeconds="1800"` or recurring cron) or `/goal`. Never leave the cadence to memory or lossy completion notifications. At each tick, re-read this playbook from trunk with `git show origin/main:skills/poteto-mode/playbooks/autopilot-full.md`, then re-read the armed `/goal`. Audit the operation against both. Fix drift during that tick and treat it as urgent. Probe each owner with a generic liveness or status check, and collect the decision trails. Count only side effects as progress: commits, pushes, PR or check deltas, and store reports. Treat an owner or lane that errors, or that passes its expected runtime without a side effect, as stuck. Stand it down and dispatch a replacement at once. Do not wait for a polite return. Probe each owner's status via native platform agent lists or liveness messages. If an owner is stuck, terminate and replace the owner; root does not micromanage the owner's internal delegates. A stall never proves or drops the work. When merges batch, run a retro pass and a post-merge bot-comment sweep. Conclude each audit tick with a /ketchup status report summarizing queue progress under 100 words with linked artifacts and pending operator decisions. Disarm the scheduled audit cadence only when no delegated work is left, even after the last merge; each individual tick finishes its audit pass and yields the turn immediately. 7. **Stand down instantly on the operator's stop.** The operator's hold or stand-down reaches every owner as a zero-writes order immediately. Owners hold their briefs until the operator releases them. diff --git a/skills/poteto-mode/playbooks/autopilot-stack.md b/skills/poteto-mode/playbooks/autopilot-stack.md index 93e926b..671f665 100644 --- a/skills/poteto-mode/playbooks/autopilot-stack.md +++ b/skills/poteto-mode/playbooks/autopilot-stack.md @@ -5,7 +5,7 @@ 1. **Run the owner loop unchanged.** One subagent per PR owns its change end to end: build, `gt` registration of its own PR, self-proof (gates, CI, receipts), skeptical Bugbot triage per `../references/bugbot-triage.md`, a slop-strip (the **deslop** skill (`/deslop`)), `/no-comments` (the **no-comments** skill), and babysit to green per `playbooks/babysit.md`. Owners parallelize when the work is self-contained. Every owner keeps a `decisions.tsv` trail per the **show-me-your-work** skill, never committed, returned in its report. 2. **Audit on the wake chain.** The root runs an audit tick roughly every 30 minutes or hourly. The root arms each tick via Antigravity's scheduled tasks (`schedule` tool / `/schedule`, e.g. `DurationSeconds="1800"` or recurring cron) or `/goal`. Never leave the cadence to memory or lossy completion notifications. At each tick, re-read this playbook from trunk with `git show origin/main:skills/poteto-mode/playbooks/autopilot-stack.md`, then re-read the armed `/goal`. Audit the operation against both. Fix drift during that tick and treat it as urgent. Probe each owner with a generic liveness or status check. Count only side effects as progress: commits, pushes, PR or check deltas, and store reports. Treat an owner or lane that errors, or that passes its expected runtime without a side effect, as stuck. Stand it down and dispatch a replacement at once. Do not wait for a polite return. Probe each owner's status via native platform agent lists or liveness messages. If an owner is stuck, terminate and replace the owner; root does not micromanage the owner's internal delegates. A stall never proves or drops the work. Conclude each audit tick with a /ketchup status report summarizing chain progress under 100 words with linked artifacts and pending operator decisions. Disarm the scheduled audit cadence only when no delegated work is left; each individual tick finishes its audit pass and yields the turn immediately. 3. **Hold the operator gates.** State-then-wait, so a request to state the plan is not a go. On the operator's explicit go, arm a `/goal` with the full program objective. The goal continues across turns until the chain is done. On the operator's stop, every owner takes an immediate zero-writes hold. -4. **Verify at STACK-READY.** The owner reports STACK-READY with the exact head SHA. The root swarm-verifies that SHA, fan-out per the **swarm** skill: parallel independent verifiers re-running the gates at that SHA, a live runtime floor over the load-bearing behavior, and a receipts-and-diff audit that distrusts the PR body. The swarm aggregates to one verdict. Findings go back to the owner, and nothing enters the stack unverified. +4. **Verify at STACK-READY.** The owner reports STACK-READY with the exact head SHA. The root verifies that SHA, fan-out per the Local fan-out section of `skills/poteto-mode/references/antigravity-tools.md` (or `/cloud-swarm` for > 8 lanes): parallel independent verifiers re-running the gates at that SHA, a live runtime floor over the load-bearing behavior, and a receipts-and-diff audit that distrusts the PR body. The swarm aggregates to one verdict. Findings go back to the owner, and nothing enters the stack unverified. 5. **Append on a clean verdict, never ship.** No owner merges, arms auto-merge, or closes. A clean verdict appends the PR to the one linear Graphite stack, in verified order or an order the operator specified. 6. **Single writer on topology, parallel writers on builds.** Stack mechanics follow Graphite (`gt`), with the division of labor the cloud environment forces. An owner pushes only its own branch, `git push --force-with-lease` after an ls-remote check, and reports its tip and intended parent. The root owns stack topology and registers each append locally: `gt track -p `, then `gt submit --no-interactive --stack` from the tip. `gt submit` walks from trunk, and a cloud agent must never pull branches below its own into that walk; when instructed, it may set its bottom PR's base directly instead. 7. **Absorb drift at the root, then re-verify what moved.** The root absorbs trunk movement by restacking the chain (`gt restack`, `gt sync`); when a restack surfaces conflicts in an owner's files, that owner fixes its own slice and the root pushes the result. A restack rewrites every SHA above it and voids the verdicts at the old SHAs. Compare `git patch-id` at each verdict SHA against the new head. Anything that actually drifted goes back through step 4 before delivery. The countersign rule is unchanged from Autopilot-full. A genuinely new pin raises a stop for the root's fresh countersign; absorbing drift of landed values is not a raise. diff --git a/skills/poteto-mode/playbooks/multi-phase-plan.md b/skills/poteto-mode/playbooks/multi-phase-plan.md index 20226f6..f4fd30a 100644 --- a/skills/poteto-mode/playbooks/multi-phase-plan.md +++ b/skills/poteto-mode/playbooks/multi-phase-plan.md @@ -10,7 +10,7 @@ 6. Run `node skills/poteto-mode/scripts/check-plan.mjs ` and fix every line it prints (the **encode-lessons-in-structure** principle skill). It enforces the skeleton's shape, the verification rule in every verification block, and the punctuation rules. 7. Hand back. Point to the `implementation_plan.md` artifact and post the script's output, then stop. Execution starts on the operator's explicit go, under the execution playbook the plan names. -**Verification.** Tests alone are not sufficient verification. A PR is verified only when its unit, live, and perf boxes are all checked (the **prove-it-works** principle skill). That sentence is the verification rule. Every verification block opens with it. The live block is mandatory. Parallel verification lanes at the PR head drive the real surface through the matching verification tool, per the **swarm** skill. Each lane is one box with a concrete scenario, the screenshot or recording it saves, and its pass predicate. The perf block names the metric, the probe, the trunk baseline measured first, and the rule with the number that fails. A PR that changes an interaction is review-gated. The operator reviews it in chat with screenshots and a video before merge. A PR that changes no interaction writes `**Review gate.** None. is not review-gated.` and no boxes under it. +**Verification.** Tests alone are not sufficient verification. A PR is verified only when its unit, live, and perf boxes are all checked (the **prove-it-works** principle skill). That sentence is the verification rule. Every verification block opens with it. The live block is mandatory. Parallel verification lanes at the PR head drive the real surface through the matching verification tool, per the Local fan-out section of `references/antigravity-tools.md` (or `/cloud-swarm` for > 8 lanes). Each lane is one box with a concrete scenario, the screenshot or recording it saves, and its pass predicate. The perf block names the metric, the probe, the trunk baseline measured first, and the rule with the number that fails. A PR that changes an interaction is review-gated. The operator reviews it in chat with screenshots and a video before merge. A PR that changes no interaction writes `**Review gate.** None. is not review-gated.` and no boxes under it. **Control and Verification.** Pick by surface. Browser and web UIs use `browser_subagent` or Chrome DevTools MCP. CLIs and TUIs use `run_command` / `manage_task` or project-local verify skills (`verify-*` via `/create-verification-skill`). Native mobile uses simulator test runners. A PR that touches two surfaces gets lanes on both. A surface with no automated test harness is a risk in Appendix C, and its live block still names how each lane drives it. @@ -35,7 +35,7 @@ Tests alone are not sufficient verification. A PR is verified only when its unit - [ ] On the operator's go, arm a `/goal` with this exact text. "" - [ ] Read these from trunk at program start. Re-read them at every tick. - [ ] `git show origin/main:skills/poteto-mode/playbooks/.md` - - [ ] `git show origin/main:skills/swarm/SKILL.md` + - [ ] `git show origin/main:skills/poteto-mode/references/antigravity-tools.md` - [ ] `git show origin/main:` - [ ] `git show origin/main:skills/poteto-mode/playbooks/opening-a-pr.md` - [ ] `git show origin/main:skills/` @@ -62,7 +62,7 @@ Tests alone are not sufficient verification. A PR is verified only when its unit ### Verdict and merge, for every PR -- [ ] At the merge-ready head SHA, run the swarm per `skills/swarm/SKILL.md`. One gates lane. The ten live lanes from the PR's **Verify, live** block. The perf lane from its **Verify, perf** block. One audit lane that reads the diff and the receipts and distrusts the PR body. +- [ ] At the merge-ready head SHA, run the verification lanes per the Local fan-out section of `skills/poteto-mode/references/antigravity-tools.md` (or `/cloud-swarm` for > 8 lanes). One gates lane. The ten live lanes from the PR's **Verify, live** block. The perf lane from its **Verify, perf** block. One audit lane that reads the diff and the receipts and distrusts the PR body. - [ ] Clean only when every lane is `PASS`. Findings go back to the owner. A new head gets a fresh swarm and a fresh verdict. - [ ] diff --git a/skills/poteto-mode/references/antigravity-tools.md b/skills/poteto-mode/references/antigravity-tools.md index aa92784..2286f0e 100644 --- a/skills/poteto-mode/references/antigravity-tools.md +++ b/skills/poteto-mode/references/antigravity-tools.md @@ -24,9 +24,9 @@ Always operate on the most direct, authoritative surface for the task: | Subagent workspace isolation | `Workspace: "branch"` (isolated git branch/worktree) or `Workspace: "share"` | | `environment: "local"` | `Workspace: "inherit"` (default parent workspace) | | Worker iteration / message passing | `send_message` with `Recipient` and `Message` | -| Parallel fan-out (Local N <= 8) | Single `invoke_subagent` call with multiple entries in `Subagents` array | -| Parallel fan-out (Cloud N > 8) | `python3 "$(find ~/.gemini/config/plugins/agystack .agents/plugins/agystack skills/swarm -name "cloud_dispatch.py" 2>/dev/null | head -1)" --manifest --parallelism 16` | -| Cloud container worker | `python skills/swarm/scripts/cloud_worker.py` entrypoint in Cloud Run | +| Parallel fan-out (Local N <= 8) | Single `invoke_subagent` call with multiple entries in `Subagents` array (see Local fan-out) | +| Parallel fan-out (Cloud N > 8) | `python3 "$(find ~/.gemini/config/plugins/agystack .agents/plugins/agystack skills/cloud-swarm/scripts -name "cloud_dispatch.py" 2>/dev/null | head -1)" --manifest --parallelism 16` | +| Cloud container worker | `python skills/cloud-swarm/scripts/cloud_worker.py` entrypoint in Cloud Run | | `AskQuestion` | `ask_question` tool for interactive questions | | Background Wake / Scheduling | `schedule` tool (one-shot timer `DurationSeconds` or recurring `CronExpression`) | | Background processes | `run_command` (async) + `manage_task` (status/kill/input) with reactive wakeup | @@ -58,6 +58,29 @@ When a command encounters exit code 126/127 or sandbox permission denial (`Permi 2. **Check if the query is investigatory and can be satisfied via native read tools.** Read-only queries against repository contents, code symbols, files, or commit logs can be satisfied using native filesystem tools (`view_file`, `find_by_name`, `grep_search`). 3. **If external mutation is required, explain the exact required permission grant or present the command.** Explicitly state the missing grant under `permissioned-github` (e.g. `gh.create` or `git.update`) or present the exact command for the human operator to run directly on the host. +## Local fan-out + +For 8 or fewer independent parallel workers, verification lanes, or candidate races, use a local `invoke_subagent` fan-out rather than spinning up cloud infrastructure. + +### Routing Table + +| Need | Use | +| --- | --- | +| 8 or fewer independent workers, verification lanes | Local fan-out (`invoke_subagent`) | +| Workers that talk to each other on a board | Native `/swarm` (preview, quota heavy, opt-in) | +| More than 8 workers, headless, patch harvest from GCS | `/cloud-swarm` | + +### Recipe + +1. **Batch Spawn:** Dispatch all workers in a single `invoke_subagent` call with `TypeName: "poteto-agent"` (or `"self"`), `Role: "Worker ()"`, `Workspace: "branch"`, and the model resolved from `swarm workers` in `~/.gemini/config/plugins/agystack/agystack-models.md` (default: `flash`). +2. **Mandatory Reporting Contract:** In each worker's prompt, provide `{PARENT_CONVERSATION_ID}` and mandate that upon completing work and verification, the worker MUST invoke `send_message` with `Recipient: "{PARENT_CONVERSATION_ID}"` and its findings/status. +3. **Reactive Watchdog Protocol:** + - Arm a single unconditional watchdog deadline: `schedule(DurationSeconds: 300..600, Prompt="Watchdog: local fan-out timed out", TimerCondition: "never")`. + - Yield the coordinator turn immediately with ZERO tool calls (`tool_calls: []`). + - On each `send_message` arrival, process results and yield immediately with ZERO tool calls while workers remain active. + - When all workers complete, cancel the watchdog timer via `manage_task(Action: "kill", TaskId: )`. + - See Rule 4 in `rules/AGENTS.md` for full reactive wakeup and watchdog requirements. + ## Parallel Cloud Agent Execution (Cloud Run Runtime) When running massive swarms (N > 8) or when Cloud Run runtime is configured, agystack uses Google Cloud Run Jobs for serverless parallel execution. @@ -67,7 +90,7 @@ When running massive swarms (N > 8) or when Cloud Run runtime is configured, agy - **On-Demand Batch Runner Only:** Cloud Run does not run continuously and is never an always-on server. Containers spin up strictly on demand. - **Zero Idle Cost:** Costs $0 when idle. Charges apply only to active container execution seconds during a swarm job. - **Local Daily Work:** Daily tasks (pair programming, routine edits, bug fixes, refactoring, code reviews via `/interrogate`, and local subagents) always run locally on your machine. -- **Explicit Swarm Trigger:** Cloud Run only spins up containers when you explicitly trigger `/swarm` (or ask to swarm a task across many parallel workers). +- **Explicit Swarm Trigger:** Cloud Run only spins up containers when you explicitly trigger `/cloud-swarm` (or ask to swarm a task across many parallel workers). ### Architecture @@ -197,7 +220,7 @@ There is a strict boundary between user-facing slash commands and programmatic a ### agystack Skills vs Native Platform Modes -agystack skills (`/interrogate`, `/arena`, `/architect`, `/swarm`) build directly on Antigravity's programmatic primitives (`invoke_subagent`, `run_command`, `schedule`, artifacts). They orchestrate independent subagents across isolated context windows, diverse model tiers (`pro`, `flash`, `inherit`), and segregated workspaces with automated verification and synthesis. +agystack skills (`/interrogate`, `/arena`, `/architect`, `/cloud-swarm`) build directly on Antigravity's programmatic primitives (`invoke_subagent`, `run_command`, `schedule`, artifacts). They orchestrate independent subagents across isolated context windows, diverse model tiers (`pro`, `flash`, `inherit`), and segregated workspaces with automated verification and synthesis. ## Paths @@ -207,7 +230,7 @@ agystack skills (`/interrogate`, `/arena`, `/architect`, `/swarm`) build directl | Runtime execution config | `~/.gemini/config/plugins/agystack/agystack-runtime.json` | | Agent conversation transcripts | `/brain//.system_generated/logs/transcript.jsonl` (discovered across `~/.gemini/antigravity/brain/` and `~/.gemini/antigravity-ide/brain/`) | | Session artifacts | `/brain//` | -| Cloud worker scripts | `skills/swarm/scripts/` | +| Cloud worker scripts | `skills/cloud-swarm/scripts/` | | Project-local skills | `.agents/skills/` in the project, or this plugin's `skills/` | | User global skills | `~/.gemini/config/skills/` or `~/.gemini/config/plugins/agystack/skills/` | @@ -225,7 +248,7 @@ agystack enforces strict separation between coordinator planning and subagent co 3. **Mandatory Subagent Fan-Out:** Call `invoke_subagent` for: - **Adversarial Code Review (`/interrogate`):** Dispatch concurrent reviewers across distinct model tiers (`pro`, `flash`, `inherit`). In-context persona emulation is strictly prohibited. - **Design & Candidate Bakeoffs (`/arena`):** Dispatch parallel subagents in isolated workspaces or scratch paths. - - **Large Payload Sweeps (`/swarm`):** Offload wide search matrices or multi-slice tests to subagents to guard the main context window. + - **Large Payload Sweeps (`/cloud-swarm`):** Offload wide search matrices or multi-slice tests to subagents to guard the main context window. - **Blinded Behavioral Evals (`/eval`):** Run candidate tasks blindly through isolated subagents. - **Cross-Model Trail Audits (`/show-me-your-work`):** Dispatch an independent subagent on a different model tier before closing. @@ -238,6 +261,6 @@ agystack enforces strict separation between coordinator planning and subagent co Because `TimerCondition: "never"` is used, incremental completions wake the coordinator reactively without cancelling the timer. Once all workers arrive, cancel the active watchdog timer via `manage_task(Action: "kill", TaskId: )`. - **Timeout Diagnosis:** Call `manage_subagents(Action: "list")` ONLY when the watchdog timer fires or an explicit error occurs. Child transcripts may only be read for post-mortem diagnostics, never while waiting. - **State-Aware Inspection:** Before calling `manage_subagents(kill)`, inspect `state` and `stateDetail`. If `state` is `running` and `stateDetail` shows an active tool execution (like test runs or compilation), do not kill. -- **Local Verification Before Teardown:** In candidate races (`/arena`, `/swarm`), verify the winning candidate's patch locally before tearing down surviving runners. +- **Local Verification Before Teardown:** In candidate races (`/arena`, `/cloud-swarm`, local fan-out), verify the winning candidate's patch locally before tearing down surviving runners. - **Phase-Boundary Teardown:** Restrict cancellations strictly to phase transitions (Synthesis or Abort). - **Subagent Context Guard Invariant:** `inheritCustomizations: false` is recommended for dedicated background worker agents (e.g. `comment-sicko` or ephemeral task delegates) to guard child context windows against injecting 50+ unrelated global skills and coordinator rules (`rules/AGENTS.md`), while the primary chat coordinator agent maintains access to skills. The coordinator passes pure technical specs, signatures, and test commands directly in the dispatch prompt. diff --git a/skills/setup-agystack/SKILL.md b/skills/setup-agystack/SKILL.md index b864ed9..b954da9 100644 --- a/skills/setup-agystack/SKILL.md +++ b/skills/setup-agystack/SKILL.md @@ -26,11 +26,11 @@ python3 "$(find ~/.gemini/config/plugins/agystack .agents/plugins/agystack skill Choose the execution runtime for parallel swarms: - **Local Runtime (Default):** Runs via native `invoke_subagent` in Antigravity for up to 8 concurrent workers. Zero cloud setup required. -- **Cloud Run Runtime:** Runs via Google Cloud Run Jobs for 10 to 100+ parallel workers in isolated container instances. Cloud Run is strictly an on-demand batch runner. It only spins up containers when you explicitly trigger `/swarm` (or ask to swarm a task across many parallel workers). It does not run continuously and is never an always-on server. It costs $0 when idle. Daily tasks (pair programming, routine edits, bug fixes, refactoring, code reviews via `/interrogate`, and local subagents) always run locally on your machine. +- **Cloud Run Runtime:** Runs via Google Cloud Run Jobs for 10 to 100+ parallel workers in isolated container instances. Cloud Run is strictly an on-demand batch runner. It only spins up containers when you explicitly trigger `/cloud-swarm` (or ask to swarm a task across many parallel workers). It does not run continuously and is never an always-on server. It costs $0 when idle. Daily tasks (pair programming, routine edits, bug fixes, refactoring, code reviews via `/interrogate`, and local subagents) always run locally on your machine. **CRITICAL INSTRUCTION FOR AI AGENT WHEN PRESENTING RUNTIME CHOICE:** When presenting the runtime choice to the user, explicitly explain the cost and execution model before asking them to choose: -1. Explain that Cloud Run is strictly an on-demand batch runner. It only spins up containers when the user explicitly triggers `/swarm` (or asks to swarm a task across many parallel workers). +1. Explain that Cloud Run is strictly an on-demand batch runner. It only spins up containers when the user explicitly triggers `/cloud-swarm` (or asks to swarm a task across many parallel workers). 2. Clarify that Cloud Run does NOT run continuously and is never an always-on server. 3. State that Cloud Run costs $0 when idle. 4. Reassure the user that daily tasks (pair programming, routine edits, bug fixes, refactoring, code reviews via `/interrogate`, and local subagents) ALWAYS run locally on their machine. @@ -47,7 +47,7 @@ If Cloud Run is selected: - Query available projects by running `python3 skills/setup-agystack/scripts/setup_runtime.py --list-projects`. - Ask the user which project they want to use, or if they want you to create a new one. 4. **Provisioning**: Once a project ID is known, run the full provisioner (do this yourself, do not ask the user to do it!): - `python3 skills/setup-agystack/scripts/setup_runtime.py --project --auto-provision --scripts-dir skills/swarm/scripts` + `python3 skills/setup-agystack/scripts/setup_runtime.py --project --auto-provision --scripts-dir skills/cloud-swarm/scripts` (or use `--create-project ` instead of `--project` if creating a new one). Do not leave the user to do the work. Complete the deployment end-to-end for them. Ensure `GEMINI_API_KEY` is exported in the user's environment with paid tier enabled (Pay-as-you-go), or Vertex AI permissions and global endpoint access are verified. diff --git a/skills/setup-agystack/scripts/setup_runtime.py b/skills/setup-agystack/scripts/setup_runtime.py index 79ca468..b02797e 100644 --- a/skills/setup-agystack/scripts/setup_runtime.py +++ b/skills/setup-agystack/scripts/setup_runtime.py @@ -535,30 +535,53 @@ def parse_model_config(config_path=None): } -def check_platform(hook_path=None, brain_dir=None, model_config_path=None, run_cmd_fn=None): +def check_skill_collisions(plugin_root=None): + root = Path(plugin_root).resolve() if plugin_root else Path(__file__).resolve().parents[3] + swarm_path = root / "skills" / "swarm" + if swarm_path.exists(): + return { + "ok": False, + "path": str(swarm_path), + "collision": True, + "error": f"Legacy skills/swarm directory shadows Antigravity built-in swarm; remove {swarm_path}", + "required": True, + } + return { + "ok": True, + "path": str(swarm_path), + "collision": False, + "error": None, + "required": True, + } + + +def check_platform(hook_path=None, brain_dir=None, model_config_path=None, plugin_root=None, run_cmd_fn=None): hook_result = check_hook_contract(hook_path=hook_path, run_cmd_fn=run_cmd_fn) artifact_result = check_artifact_dir(brain_dir=brain_dir) model_result = parse_model_config(config_path=model_config_path) + collision_result = check_skill_collisions(plugin_root=plugin_root) checks = { "hook_contract": hook_result, "artifact_dir": artifact_result, "model_config": model_result, + "skill_collisions": collision_result, } all_ok = all(c.get("ok", False) for c in checks.values() if isinstance(c, dict) and c.get("required")) checks["ok"] = all_ok return checks -def run_doctor(run_cmd_fn=None, include_python=True, import_fn=None, hook_path=None, brain_dir=None, model_config_path=None): +def run_doctor(run_cmd_fn=None, include_python=True, import_fn=None, hook_path=None, brain_dir=None, model_config_path=None, plugin_root=None): deps = check_dependencies(run_cmd_fn=run_cmd_fn, include_python=include_python, import_fn=import_fn) - platform = check_platform(hook_path=hook_path, brain_dir=brain_dir, model_config_path=model_config_path, run_cmd_fn=run_cmd_fn) + platform = check_platform(hook_path=hook_path, brain_dir=brain_dir, model_config_path=model_config_path, plugin_root=plugin_root, run_cmd_fn=run_cmd_fn) result = dict(deps) result["platform"] = platform result["safety_hook"] = platform["hook_contract"] result["artifact_dir"] = platform["artifact_dir"] result["model_config"] = platform["model_config"] + result["skill_collisions"] = platform["skill_collisions"] all_deps_ok = all(dep.get("ok", False) for dep in deps.values() if isinstance(dep, dict) and dep.get("required")) platform_ok = platform.get("ok", False) @@ -834,7 +857,7 @@ def run_provisioning( bucket_name = f"{project_id}-swarm-results" if not scripts_dir or not (Path(scripts_dir) / "Dockerfile").is_file(): - candidate = Path(__file__).resolve().parents[2] / "swarm" / "scripts" + candidate = Path(__file__).resolve().parents[2] / "cloud-swarm" / "scripts" if (candidate / "Dockerfile").is_file(): scripts_dir = str(candidate) diff --git a/tests/test_architecture_remediation.py b/tests/test_architecture_remediation.py index 9a8eee9..35b00e4 100755 --- a/tests/test_architecture_remediation.py +++ b/tests/test_architecture_remediation.py @@ -9,7 +9,7 @@ from unittest.mock import MagicMock, patch REPO_ROOT = Path(__file__).resolve().parent.parent -SWARM_SCRIPTS = REPO_ROOT / "skills" / "swarm" / "scripts" +SWARM_SCRIPTS = REPO_ROOT / "skills" / "cloud-swarm" / "scripts" sys.path.insert(0, str(SWARM_SCRIPTS)) import cloud_dispatch @@ -304,9 +304,9 @@ def test_live_cloud_bidirectional_skips_when_live_bucket_unset(self): self.assertIn("skipped=3", res.stderr + res.stdout) def test_script_resolver_path_resolution_in_skill_md(self): - skill_md = REPO_ROOT / "skills" / "swarm" / "SKILL.md" + skill_md = REPO_ROOT / "skills" / "cloud-swarm" / "SKILL.md" content = skill_md.read_text(encoding="utf-8") - resolver_pattern = 'find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/swarm/scripts" -name cloud_dispatch.py' + resolver_pattern = 'find -L "$HOME/.gemini/config/plugins/agystack" ".agents/plugins/agystack" "skills/cloud-swarm/scripts" -name cloud_dispatch.py' self.assertIn(resolver_pattern, content) def test_run_preflight_missing_gcs_bucket_fails_fast(self): diff --git a/tests/test_cloud_preflight_and_worker.py b/tests/test_cloud_preflight_and_worker.py index 2e8fc70..3f3ef0b 100644 --- a/tests/test_cloud_preflight_and_worker.py +++ b/tests/test_cloud_preflight_and_worker.py @@ -10,7 +10,7 @@ from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch -sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts")) +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts")) import cloud_worker from cloud_dispatch import ( build_gcloud_command, @@ -954,7 +954,7 @@ def test_manifest_staging_avoids_large_task_manifest_env(self): manifest_path = self.temp_dir / "manifest.json" manifest_path.write_text(manifest_serialized, encoding="utf-8") - dispatch_script = Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts" / "cloud_dispatch.py" + dispatch_script = Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts" / "cloud_dispatch.py" cmd = [ sys.executable, str(dispatch_script), @@ -1259,7 +1259,7 @@ def test_build_gcloud_command_vertex_mode_completely_absent_from_update_env_vars self.assertNotIn("AIzaSySuperSecretKey", update_env_env) def test_cli_dispatch_omits_secrets_from_env_vars_when_using_set_secrets_or_runtime_config(self): - dispatch_script = Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts" / "cloud_dispatch.py" + dispatch_script = Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts" / "cloud_dispatch.py" manifest_path = self.temp_dir / "manifest_empty.json" manifest_path.write_text("[]", encoding="utf-8") diff --git a/tests/test_cloud_worker_vertex_partner.py b/tests/test_cloud_worker_vertex_partner.py index 8a93910..afe6cd4 100644 --- a/tests/test_cloud_worker_vertex_partner.py +++ b/tests/test_cloud_worker_vertex_partner.py @@ -10,7 +10,7 @@ from unittest.mock import AsyncMock, MagicMock, patch REPO_ROOT = Path(__file__).resolve().parent.parent -sys.path.insert(0, str(REPO_ROOT / "skills" / "swarm" / "scripts")) +sys.path.insert(0, str(REPO_ROOT / "skills" / "cloud-swarm" / "scripts")) sys.path.insert(0, str(REPO_ROOT / "skills" / "setup-agystack" / "scripts")) import cloud_worker diff --git a/tests/test_container_spec.py b/tests/test_container_spec.py index 0c672ac..0d37f09 100644 --- a/tests/test_container_spec.py +++ b/tests/test_container_spec.py @@ -7,7 +7,7 @@ class TestContainerSpec(unittest.TestCase): @classmethod def setUpClass(cls): cls.project_root = Path(__file__).resolve().parent.parent - cls.scripts_dir = cls.project_root / "skills" / "swarm" / "scripts" + cls.scripts_dir = cls.project_root / "skills" / "cloud-swarm" / "scripts" cls.dockerfile_path = cls.scripts_dir / "Dockerfile" if not cls.dockerfile_path.is_file(): diff --git a/tests/test_conversational_steering_tool.py b/tests/test_conversational_steering_tool.py index aacc777..f596e94 100644 --- a/tests/test_conversational_steering_tool.py +++ b/tests/test_conversational_steering_tool.py @@ -28,7 +28,7 @@ from unittest.mock import MagicMock, patch # Ensure scripts directory is on sys.path -SCRIPT_DIR = Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts" +SCRIPT_DIR = Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts" if str(SCRIPT_DIR) not in sys.path: sys.path.insert(0, str(SCRIPT_DIR)) diff --git a/tests/test_live_cloud_bidirectional.py b/tests/test_live_cloud_bidirectional.py index 60a73d1..47feb0f 100644 --- a/tests/test_live_cloud_bidirectional.py +++ b/tests/test_live_cloud_bidirectional.py @@ -18,7 +18,7 @@ from pathlib import Path # Add scripts directory to path -SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts" +SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts" sys.path.insert(0, str(SCRIPTS_DIR)) from storage_messenger import StorageMessenger, MessageStatus, MessageType diff --git a/tests/test_reactive_coordination_rules.py b/tests/test_reactive_coordination_rules.py index b4e57ee..b29a372 100644 --- a/tests/test_reactive_coordination_rules.py +++ b/tests/test_reactive_coordination_rules.py @@ -29,7 +29,7 @@ def test_agents_md_scopes_cloud_swarm_liveness(self): content, ) - swarm_file = SKILLS_DIR / "swarm" / "SKILL.md" + swarm_file = SKILLS_DIR / "cloud-swarm" / "SKILL.md" swarm_content = swarm_file.read_text(encoding="utf-8") self.assertIn( "Active Liveness & Non-Blocking Monitoring (Cloud Run Swarms Only):", @@ -56,19 +56,13 @@ def test_interrogate_skill_has_zero_tool_yield(self): ) self.assertIn("{PARENT_CONVERSATION_ID}", content) - def test_arena_and_swarm_skills_have_reactive_protocol(self): + def test_arena_skill_has_reactive_protocol(self): arena_content = (SKILLS_DIR / "arena" / "SKILL.md").read_text(encoding="utf-8") self.assertIn('TimerCondition: "never"', arena_content) self.assertIn("ZERO tool calls", arena_content) self.assertIn("send_message", arena_content) self.assertIn("{PARENT_CONVERSATION_ID}", arena_content) - swarm_content = (SKILLS_DIR / "swarm" / "SKILL.md").read_text(encoding="utf-8") - self.assertIn('TimerCondition: "never"', swarm_content) - self.assertIn("ZERO tool calls", swarm_content) - self.assertIn("send_message", swarm_content) - self.assertIn("{PARENT_CONVERSATION_ID}", swarm_content) - def test_agents_md_has_delegation_thresholds(self): agents_file = RULES_DIR / "AGENTS.md" content = agents_file.read_text(encoding="utf-8") diff --git a/tests/test_setup_runtime.py b/tests/test_setup_runtime.py index 636c7b4..4705286 100644 --- a/tests/test_setup_runtime.py +++ b/tests/test_setup_runtime.py @@ -1,3 +1,4 @@ +import contextlib import io import json import os @@ -7,10 +8,22 @@ from pathlib import Path from unittest.mock import MagicMock, patch -sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "setup-agystack" / "scripts")) +REPO_ROOT = Path(__file__).resolve().parent.parent +sys.path.insert(0, str(REPO_ROOT / "skills" / "setup-agystack" / "scripts")) import setup_runtime +@contextlib.contextmanager +def isolated_home(): + with tempfile.TemporaryDirectory() as tmp_home: + clean_env = os.environ.copy() + clean_env["HOME"] = tmp_home + clean_env.pop("ANTIGRAVITY_APP_DATA_DIR", None) + clean_env.pop("ANTIGRAVITY_CONVERSATION_ID", None) + with patch.dict(os.environ, clean_env, clear=True): + yield Path(tmp_home).resolve() + + class TestSetupRuntimeDoctor(unittest.TestCase): @patch("setup_runtime.run_cmd") def test_check_dependencies_all_installed(self, mock_run_cmd): @@ -200,7 +213,7 @@ class TestSetupRuntimeProvisioning(unittest.TestCase): def test_run_provisioning_autoresolves_scripts_dir(self, mock_run_cmd, mock_write_cfg): mock_run_cmd.return_value = MagicMock(returncode=0, stdout="", stderr="") - expected_scripts_dir = str(Path(setup_runtime.__file__).resolve().parents[2] / "swarm" / "scripts") + expected_scripts_dir = str(Path(setup_runtime.__file__).resolve().parents[2] / "cloud-swarm" / "scripts") self.assertTrue( (Path(expected_scripts_dir) / "Dockerfile").is_file(), f"Expected Dockerfile to exist at {expected_scripts_dir}", @@ -226,7 +239,7 @@ def test_run_provisioning_autoresolves_scripts_dir(self, mock_run_cmd, mock_writ def test_run_provisioning_preserves_valid_scripts_dir(self, mock_run_cmd, mock_write_cfg): mock_run_cmd.return_value = MagicMock(returncode=0, stdout="", stderr="") - valid_dir = str(Path(setup_runtime.__file__).resolve().parents[2] / "swarm" / "scripts") + valid_dir = str(Path(setup_runtime.__file__).resolve().parents[2] / "cloud-swarm" / "scripts") setup_runtime.run_provisioning( project_id="test-proj-valid", scripts_dir=valid_dir, @@ -330,7 +343,7 @@ def setUp(self): self.repo_root = Path(self.temp_dir.name).resolve() self.skills_dir = self.repo_root / "skills" - self.swarm_scripts_dir = self.skills_dir / "swarm" / "scripts" + self.swarm_scripts_dir = self.skills_dir / "cloud-swarm" / "scripts" self.swarm_scripts_dir.mkdir(parents=True, exist_ok=True) (self.swarm_scripts_dir / "Dockerfile").write_text("FROM python:3.11-slim\n", encoding="utf-8") @@ -378,7 +391,7 @@ def fake_run(cmd, *args, **kwargs): observed_staged["staged_rules_exists"] = staged_rules.is_dir() observed_staged["staged_agents_exists"] = staged_agents.is_dir() observed_staged["other_skill_copied"] = (staged_skills / "poteto-mode" / "SKILL.md").is_file() - observed_staged["recursion_prevented"] = not (staged_skills / "swarm" / "scripts").exists() + observed_staged["recursion_prevented"] = not (staged_skills / "cloud-swarm" / "scripts").exists() observed_staged["git_ignored"] = not (staged_skills / ".git").exists() observed_staged["pycache_ignored"] = not (staged_skills / "__pycache__").exists() observed_staged["pytest_cache_ignored"] = not (staged_skills / ".pytest_cache").exists() @@ -507,16 +520,44 @@ def test_check_artifact_dir_not_writable(self): self.assertIn("not writable", res["error"]) def test_parse_model_config_success(self): - res = setup_runtime.parse_model_config() - self.assertTrue(res["installed"]) - self.assertTrue(res["ok"]) - self.assertGreater(res["roles_count"], 0) - self.assertIn("arena runners", res["roles"]) - self.assertEqual(res["roles"]["arena runners"], ["inherit", "flash", "pro"]) - self.assertIn("swarm workers", res["roles"]) - self.assertEqual(res["roles"]["swarm workers"], ["flash"]) - self.assertIn("feature", res["roles"]) - self.assertEqual(res["roles"]["feature"], ["inherit"]) + with isolated_home(): + res = setup_runtime.parse_model_config() + self.assertTrue(res["installed"]) + self.assertTrue(res["ok"]) + self.assertGreater(res["roles_count"], 0) + self.assertIn("arena runners", res["roles"]) + self.assertEqual(res["roles"]["arena runners"], ["inherit", "flash", "pro"]) + self.assertIn("swarm workers", res["roles"]) + self.assertEqual(res["roles"]["swarm workers"], ["flash"]) + self.assertIn("feature", res["roles"]) + self.assertEqual(res["roles"]["feature"], ["inherit"]) + + + def test_check_skill_collisions_absent(self): + with tempfile.TemporaryDirectory() as tmp_root: + (Path(tmp_root) / "skills" / "poteto-mode").mkdir(parents=True, exist_ok=True) + res = setup_runtime.check_skill_collisions(plugin_root=tmp_root) + self.assertTrue(res["ok"]) + self.assertFalse(res["collision"]) + self.assertIsNone(res["error"]) + self.assertTrue(res["required"]) + self.assertEqual(res["path"], str((Path(tmp_root).resolve() / "skills" / "swarm"))) + + repo_res = setup_runtime.check_skill_collisions() + self.assertTrue(repo_res["ok"]) + self.assertFalse(repo_res["collision"]) + + def test_check_skill_collisions_present(self): + with tempfile.TemporaryDirectory() as tmp_root: + swarm_dir = Path(tmp_root) / "skills" / "swarm" + swarm_dir.mkdir(parents=True, exist_ok=True) + res = setup_runtime.check_skill_collisions(plugin_root=tmp_root) + self.assertFalse(res["ok"]) + self.assertTrue(res["collision"]) + self.assertTrue(res["required"]) + self.assertEqual(res["path"], str(swarm_dir.resolve())) + self.assertIn("Legacy skills/swarm directory shadows Antigravity built-in swarm", res["error"]) + self.assertIn(str(swarm_dir.resolve()), res["error"]) def test_parse_model_config_missing_file(self): res = setup_runtime.parse_model_config(config_path="/nonexistent/agystack-models.md") @@ -536,37 +577,51 @@ def test_parse_model_config_empty_file(self): self.assertIn("No model roles defined", res["error"]) def test_check_platform_all_passing(self): - res = setup_runtime.check_platform() - self.assertTrue(res["ok"]) - self.assertTrue(res["hook_contract"]["ok"]) - self.assertEqual(res["hook_contract"]["decision"], "deny") - self.assertTrue(res["artifact_dir"]["ok"]) - self.assertTrue(res["artifact_dir"]["writable"]) - self.assertTrue(res["model_config"]["ok"]) + with isolated_home() as tmp_home: + res = setup_runtime.check_platform() + self.assertTrue(res["ok"]) + self.assertTrue(res["hook_contract"]["ok"]) + self.assertEqual(res["hook_contract"]["decision"], "deny") + self.assertTrue(res["artifact_dir"]["ok"]) + self.assertTrue(res["artifact_dir"]["writable"]) + self.assertTrue(Path(res["artifact_dir"]["path"]).is_relative_to(tmp_home)) + self.assertTrue(res["model_config"]["ok"]) + self.assertEqual(res["model_config"]["path"], str((REPO_ROOT / "agystack-models.md").resolve())) + self.assertTrue(res["skill_collisions"]["ok"]) + self.assertFalse(res["skill_collisions"]["collision"]) def test_doctor_platform_overall_status_ok_exit_0(self): - with patch("sys.argv", ["setup_runtime.py", "--doctor"]): - with patch("sys.stdout", new_callable=io.StringIO) as mock_out: - with self.assertRaises(SystemExit) as cm: - setup_runtime.main() - self.assertEqual(cm.exception.code, 0) - report = json.loads(mock_out.getvalue().strip()) - self.assertEqual(report["status"], "OK") - self.assertTrue(report["platform"]["ok"]) - self.assertEqual(report["safety_hook"]["decision"], "deny") - self.assertTrue(report["artifact_dir"]["writable"]) - self.assertIn("arena runners", report["model_config"]["roles"]) - - def test_doctor_platform_failure_exits_1(self): - with patch("setup_runtime.check_hook_contract", return_value={"ok": False, "required": True, "error": "Hook failure"}): + with isolated_home() as tmp_home: with patch("sys.argv", ["setup_runtime.py", "--doctor"]): with patch("sys.stdout", new_callable=io.StringIO) as mock_out: with self.assertRaises(SystemExit) as cm: setup_runtime.main() - self.assertEqual(cm.exception.code, 1) + self.assertEqual(cm.exception.code, 0) report = json.loads(mock_out.getvalue().strip()) - self.assertEqual(report["status"], "ERROR") - self.assertFalse(report["platform"]["ok"]) + self.assertEqual(report["status"], "OK") + self.assertTrue(report["platform"]["ok"]) + self.assertEqual(report["safety_hook"]["decision"], "deny") + self.assertTrue(report["artifact_dir"]["writable"]) + self.assertTrue(Path(report["artifact_dir"]["path"]).is_relative_to(tmp_home)) + self.assertEqual(report["model_config"]["path"], str((REPO_ROOT / "agystack-models.md").resolve())) + self.assertIn("arena runners", report["model_config"]["roles"]) + self.assertIn("swarm workers", report["model_config"]["roles"]) + self.assertTrue(report["skill_collisions"]["ok"]) + + def test_doctor_platform_failure_exits_1(self): + with isolated_home(): + with patch( + "setup_runtime.check_hook_contract", + return_value={"ok": False, "required": True, "error": "Hook failure"}, + ): + with patch("sys.argv", ["setup_runtime.py", "--doctor"]): + with patch("sys.stdout", new_callable=io.StringIO) as mock_out: + with self.assertRaises(SystemExit) as cm: + setup_runtime.main() + self.assertEqual(cm.exception.code, 1) + report = json.loads(mock_out.getvalue().strip()) + self.assertEqual(report["status"], "ERROR") + self.assertFalse(report["platform"]["ok"]) class TestSetupRuntimeProvisioner(unittest.TestCase): @@ -717,7 +772,7 @@ def test_build_and_deploy_worker_creates_job_with_memory_and_cpu(self, mock_run_ project_id="my-project-123", region="us-central1", image_tag="us-central1-docker.pkg.dev/my-project-123/agystack/worker:latest", - scripts_dir="skills/swarm/scripts", + scripts_dir="skills/cloud-swarm/scripts", service_account="custom-sa@example.com", ) @@ -744,7 +799,7 @@ def test_build_and_deploy_worker_updates_job_with_memory_and_cpu(self, mock_run_ project_id="my-project-123", region="us-central1", image_tag="us-central1-docker.pkg.dev/my-project-123/agystack/worker:latest", - scripts_dir="skills/swarm/scripts", + scripts_dir="skills/cloud-swarm/scripts", service_account="custom-sa@example.com", ) @@ -799,7 +854,7 @@ def test_run_provisioning_full_flow(self, mock_run_cmd, mock_write_cfg): summary = setup_runtime.run_provisioning( project_id="test-proj-full", region="us-central1", - scripts_dir="skills/swarm/scripts", + scripts_dir="skills/cloud-swarm/scripts", bucket_name="custom-bucket", service_account="custom-sa@developer.gserviceaccount.com", ) diff --git a/tests/test_shadow_transcript_projection.py b/tests/test_shadow_transcript_projection.py index 1b5e35e..4b7bb97 100644 --- a/tests/test_shadow_transcript_projection.py +++ b/tests/test_shadow_transcript_projection.py @@ -12,7 +12,7 @@ from pathlib import Path from unittest.mock import patch -sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts")) +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts")) from cloud_dispatch import ( ShadowTranscriptProjector, diff --git a/tests/test_simulation_scenario.py b/tests/test_simulation_scenario.py index 3c8b59a..868fb32 100644 --- a/tests/test_simulation_scenario.py +++ b/tests/test_simulation_scenario.py @@ -8,7 +8,7 @@ import unittest from unittest.mock import MagicMock, patch -SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts" +SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts" if str(SCRIPTS_DIR) not in sys.path: sys.path.insert(0, str(SCRIPTS_DIR)) diff --git a/tests/test_skill_catalog.py b/tests/test_skill_catalog.py index f6b73d8..58d3196 100644 --- a/tests/test_skill_catalog.py +++ b/tests/test_skill_catalog.py @@ -79,3 +79,25 @@ def test_all_skills_match_directory(): skill_name = name_match.group(1).strip().strip("'\"") assert skill_name == dir_name, f"{skill_file} name '{skill_name}' does not match dir '{dir_name}'" + +def test_cloud_swarm_skill_name(): + cloud_swarm_file = REPO_ROOT / "skills" / "cloud-swarm" / "SKILL.md" + assert cloud_swarm_file.exists() + content = cloud_swarm_file.read_text(encoding="utf-8") + parts = content.split("---", 2) + name_match = re.search(r"^name:\s*(.+)$", parts[1], re.MULTILINE) + assert name_match and name_match.group(1).strip().strip("'\"") == "cloud-swarm" + + +def test_no_swarm_skill_collision(): + skills_dir = REPO_ROOT / "skills" + assert not (skills_dir / "swarm").exists(), "skills/swarm must not exist (shadows Antigravity built-in swarm skill)" + for skill_file in sorted(skills_dir.glob("*/SKILL.md")): + content = skill_file.read_text(encoding="utf-8") + parts = content.split("---", 2) + assert len(parts) >= 3, f"{skill_file} invalid frontmatter structure" + name_match = re.search(r"^name:\s*(.+)$", parts[1], re.MULTILINE) + assert name_match, f"{skill_file} missing 'name:' in frontmatter" + skill_name = name_match.group(1).strip().strip("'\"") + assert skill_name != "swarm", f"{skill_file} declares 'name: swarm' and shadows Antigravity's built-in swarm skill" + diff --git a/tests/test_storage_messenger.py b/tests/test_storage_messenger.py index 6f9e353..72d182f 100644 --- a/tests/test_storage_messenger.py +++ b/tests/test_storage_messenger.py @@ -10,7 +10,7 @@ import unittest from unittest.mock import MagicMock, patch -sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts")) +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts")) from storage_messenger import ( MailboxEnvelope, diff --git a/tests/test_storage_uploader.py b/tests/test_storage_uploader.py index 382c445..28a46f7 100644 --- a/tests/test_storage_uploader.py +++ b/tests/test_storage_uploader.py @@ -9,7 +9,7 @@ import sys -sys.path.insert(0, str(Path(__file__).parent.parent / "skills" / "swarm" / "scripts")) +sys.path.insert(0, str(Path(__file__).parent.parent / "skills" / "cloud-swarm" / "scripts")) import storage_uploader import cloud_worker diff --git a/tests/test_swarm_dashboard_generation.py b/tests/test_swarm_dashboard_generation.py index 945cc13..7e789cc 100644 --- a/tests/test_swarm_dashboard_generation.py +++ b/tests/test_swarm_dashboard_generation.py @@ -9,7 +9,7 @@ from pathlib import Path from unittest.mock import MagicMock, patch -sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts")) +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts")) import swarm_dashboard from cloud_dispatch import ( diff --git a/tests/test_swarm_generic.py b/tests/test_swarm_generic.py index 96edf3c..02aa075 100644 --- a/tests/test_swarm_generic.py +++ b/tests/test_swarm_generic.py @@ -4,9 +4,9 @@ import unittest from pathlib import Path -SWARM_SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "skills" / "swarm" / "scripts" +SWARM_SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "skills" / "cloud-swarm" / "scripts" if not SWARM_SCRIPTS_DIR.exists(): - SWARM_SCRIPTS_DIR = Path.home() / ".gemini" / "config" / "plugins" / "agystack" / "skills" / "swarm" / "scripts" + SWARM_SCRIPTS_DIR = Path.home() / ".gemini" / "config" / "plugins" / "agystack" / "skills" / "cloud-swarm" / "scripts" sys.path.insert(0, str(SWARM_SCRIPTS_DIR)) diff --git a/tests/test_worker_execution_lifecycle.py b/tests/test_worker_execution_lifecycle.py index e2770de..ae97f3c 100644 --- a/tests/test_worker_execution_lifecycle.py +++ b/tests/test_worker_execution_lifecycle.py @@ -11,7 +11,7 @@ import pytest -SCRIPTS = Path(__file__).resolve().parents[1] / "skills/swarm/scripts" +SCRIPTS = Path(__file__).resolve().parents[1] / "skills/cloud-swarm/scripts" sys.path.insert(0, str(SCRIPTS)) import cloud_dispatch import cloud_worker diff --git a/uv.lock b/uv.lock index 28bee9c..2ee8baf 100644 --- a/uv.lock +++ b/uv.lock @@ -18,7 +18,7 @@ wheels = [ [[package]] name = "agystack" -version = "0.16.0" +version = "0.17.0" source = { editable = "." } dependencies = [ { name = "google-cloud-run" },