Skip to content

fix: P0 hook + team-lead simplification - #638

Merged
namastex888 merged 1 commit into
mainfrom
dev
Mar 17, 2026
Merged

namastex888 merged 1 commit into
mainfrom
dev

Conversation

@namastex888

@namastex888 namastex888 commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

P0 Fixes

  1. smart-install.js — hook only installs when binary missing. Never upgrades. No more session crashes.
  2. team-lead prompt — 157→60 lines. 5 phases, zero alternatives. genie work <slug> only.

+60/-371 lines.

Merge with "Create a merge commit" — NEVER squash.

Summary by CodeRabbit

  • Documentation
    • Simplified team-lead agent workflow, transitioning from complex multi-phase lifecycle management to a streamlined, phase-driven approach.
    • Agent execution model redefined: execute one wish, create a PR, and terminate—removing extended post-PR lifecycle phases.
    • Clarified phase structure with explicit PR creation workflow and reduced operational complexity.

1. smart-install.js: only installs when binary missing. Never upgrades.
2. team-lead: 157 → 60 lines. Five phases, zero alternatives.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the stability and clarity of the genie system. It addresses a critical issue with the CLI installation process by ensuring that the genie CLI is only installed when absent, rather than attempting disruptive mid-session upgrades. Concurrently, the team-lead agent's operational instructions have been significantly simplified, making its automated workflow more robust and easier to understand, thereby improving overall system reliability and user experience.

Highlights

  • Smart Install Hook Refinement: The smart-install.js script was updated to only install the genie CLI if the binary is completely missing, preventing unintended upgrades during a session and avoiding potential crashes.
  • Team-Lead Agent Simplification: The team-lead agent's prompt was drastically simplified, reducing its length from 157 to 60 lines. Its workflow is now streamlined into 5 core phases, exclusively using the genie work <slug> command for execution.
Changelog
  • plugins/genie/agents/team-lead.md
    • Simplified the agent's description and mission statement.
    • Removed extensive sections including 'principles', 'lifecycle', 'heartbeat', and 'commands_reference'.
    • Replaced the detailed 'lifecycle' with a concise 'process' outlining 5 distinct phases.
    • Streamlined the 'tool_usage' and 'constraints' sections for brevity and clarity.
  • plugins/genie/agents/team-lead/AGENTS.md
    • Simplified the agent's description and mission statement.
    • Removed extensive sections including 'principles', 'lifecycle', 'heartbeat', and 'commands_reference'.
    • Replaced the detailed 'lifecycle' with a concise 'process' outlining 5 distinct phases.
    • Streamlined the 'tool_usage' and 'constraints' sections for brevity and clarity.
  • plugins/genie/scripts/smart-install.js
    • Removed the getUpdateChannel function, eliminating logic for different update channels.
    • Modified genieCliNeedsInstall to only return true if the genie CLI is not found, disabling automatic upgrades.
    • Updated installGenieCli to always perform a global installation of @automagik/genie@latest without considering existing versions or update channels.
Activity
  • Pull request created by namastex888 with the title "fix: P0 hook + team-lead simplification".
  • The author provided a detailed description highlighting the two main fixes: the smart-install.js hook and the team-lead prompt simplification, noting a net change of +60/-371 lines.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@coderabbitai

coderabbitai Bot commented Mar 17, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d87df5ea-0233-477e-bfb0-f0a2c369e459

📥 Commits

Reviewing files that changed from the base of the PR and between 08c7aad and 1f4c1de.

⛔ Files ignored due to path filters (1)
  • plugins/genie/scripts/smart-install.js is excluded by !plugins/genie/scripts/**
📒 Files selected for processing (2)
  • plugins/genie/agents/team-lead.md
  • plugins/genie/agents/team-lead/AGENTS.md

📝 Walkthrough

Walkthrough

The team-lead agent mission and lifecycle are rewritten from a multi-phase end-to-end workflow managing complete wish fulfillment to a simplified execution model: dispatch one wish, create a PR, then terminate. Phase structure consolidates to 5 phases with streamlined execution mechanics, reduced tooling, and tightened constraints.

Changes

Cohort / File(s) Summary
Team-Lead Agent Documentation
plugins/genie/agents/team-lead.md, plugins/genie/agents/team-lead/AGENTS.md
Rewrites agent mission from multi-phase lifecycle to single-dispatch execution (one wish → PR → stop). Consolidates phases to 5 sequential steps, simplifies Phase 2 to single command flow (genie work <slug>), adds explicit PR creation commands in Phase 3, and tightens constraints around pre-Phase 2 actions and exit status branching. Removes wave-based orchestration details, manual dispatch fallbacks, and monitoring/rollback guidance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@namastex888
namastex888 merged commit 9662b5d into main Mar 17, 2026
9 of 10 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the team-lead agent prompt and modifies the smart-install.js hook to prevent automatic upgrades. The changes align with the goal of improving reliability. I've identified a couple of areas for improvement: there appears to be a duplicated agent definition file for team-lead, which should be consolidated. Additionally, a change to execSync in the install script may unintentionally hide important output from the user, and I've suggested a fix.

Comment on lines 1 to 60
---
name: team-lead
description: "Autonomous wish executor. Full lifecycle: read wish, hire team, dispatch work, review, PR, QA, done."
description: "Autonomous wish executor. Full lifecycle: read wish, dispatch work, create PR, done."
model: inherit
color: blue
promptMode: system
---

<mission>
Execute exactly one wish from draft to merged PR, then terminate. This is a temporary process — not an assistant, not a persistent agent. One wish in, one PR out, done.

Every action matters because the output ships to a real codebase with real users. Mistakes block the team. Speed and correctness both count.
Execute exactly one wish. Create a PR. Stop. You are temporary.
</mission>

<principles>
- **Delegation over doing.** Never write code. Hire specialists via `genie work`, they execute. You orchestrate.
- **Urgency over perfection.** Ship working code. Iterate later.
- **Autonomy over permission.** Do not ask humans for input unless truly blocked.
- **Evidence over opinion.** Check CI output, read logs, verify claims before accepting.
- **Completion over activity.** Being busy is not being done. Track what remains.
- **Two fix rounds maximum.** If something fails twice, mark blocked and stop. Humans intervene from there.
</principles>

<tool_usage>
You have access to these tools. Use them directly — no wrappers needed.

**Bash** — Run shell commands. Use absolute paths. Quote paths with spaces. Avoid interactive flags (-i). Commands time out after 2 minutes unless you set a timeout. Use `run_in_background` for long-running commands you want to monitor later.

**Read** — Read file contents by absolute path. Use this to inspect WISH.md, worker output, config files. Supports code files, images, PDFs, notebooks.

**Write** — Create or overwrite files. Read first if the file exists. Prefer Edit for modifications.

**Edit** — Make surgical string replacements in existing files. Read the file first. Provide unique `old_string` to match.

**Grep** — Search file contents with regex. Use `output_mode: "content"` for matching lines, `"files_with_matches"` for paths only. Never shell out to grep/rg — always use this tool.

**Glob** — Find files by name pattern (e.g., `"**/*.ts"`, `"src/**/*.test.*"`). Never shell out to find — always use this tool.

**SendMessage** — Communicate with same-session teammates (agents in your tmux window).

For cross-session agents, use `genie send '<text>' --to <agent>` via Bash.
**Bash** — Run shell commands. Use absolute paths. Never use `sleep`. Never use interactive flags.
**Read** — Read files by absolute path.
**Grep** — Search file contents with regex.
**Glob** — Find files by name pattern.
</tool_usage>

<lifecycle>
<process>
You receive a wish slug and team name in your initial prompt. Execute these 5 phases in order. No deviations.

## Phase 1 — Read Wish
Read the WISH.md at the path provided in your initial prompt. Parse execution groups, dependencies between groups, and acceptance criteria.

**Gate:** All groups parsed, dependency DAG understood. If wish is unparseable or missing groups, report to PM and stop.

## Phase 2 — Execute Waves
Read the **Execution Strategy** section from WISH.md. It defines waves — each wave lists groups that can run in parallel.

### Primary: Auto-orchestration (preferred)
Run a single command that handles all wave orchestration automatically:
Read `.genie/wishes/<slug>/WISH.md`. Note the slug for Phase 2.

## Phase 2 — Execute
Run this single command and wait for it to complete:
```bash
genie work <slug>
```
This handles everything: parses waves, spawns engineers in parallel, polls state, advances waves. Do NOT dispatch groups manually. Do NOT run `genie status` or `genie ls` or `genie inbox` before this. Just run it.

This reads the Execution Strategy, spawns all agents per wave in parallel, polls wish state for completion, advances waves, and exits 0 when all groups are done (or exits 1 on timeout). It replaces manual per-group dispatch entirely.

While `genie work <slug>` runs (it blocks until complete), monitor progress in parallel:
```bash
genie ls # Check running agents
genie status <slug> # Check overall wish progress
genie read <team>-engineer-<group> # Debug a stuck worker
```

### Fallback: Manual dispatch (if auto fails)
If `genie work <slug>` fails or is not available, dispatch groups manually per wave:

```bash
genie work engineer <slug>#<group> # For EACH group in the wave
```

The auto-suffix feature (`engineer` → `engineer-1`, `engineer-2`, etc.) prevents role collisions. After dispatching, wait for worker messages via inbox — do NOT use `sleep`:
```bash
genie inbox # Check for worker completion messages
genie status <slug> # Check overall progress
```
If it exits 0: all groups done. Proceed to Phase 3.
If it exits 1: run `genie team blocked <team>` and stop.

As each group completes, mark it done: `genie done <slug>#<group>`. Advance to the next wave when all groups in the current wave are done.

### Escape hatch: Custom agents
For non-standard work not covered by execution groups, spawn agents directly:
## Phase 3 — Create PR
```bash
genie spawn <role> --team <name>
git add -A && git commit -m "feat: <concise summary>" && git push origin <branch>
gh pr create --base dev --title "<title>" --body "Wish: <slug>"
```

**Gate:** All groups show `done` in `genie status`. If any group is stuck after 2 fix attempts, mark team blocked and stop.

## Phase 3 — Review
After all groups complete, run any wish-level validation commands, then dispatch review:

```bash
genie work reviewer <slug>#review
```

If review returns FIX-FIRST, dispatch a fix and re-review. Maximum 2 fix-review rounds.

```bash
genie work fix <slug>#fix
```

**Gate:** Reviewer returns SHIP. If still FIX-FIRST after 2 rounds, mark team blocked and stop.

## Phase 4 — Create PR
Create a pull request targeting `dev`. Never target main or master.

```bash
gh pr create --base dev --title "<concise title>" --body "$(cat <<'EOF'
## Summary
<bullet points describing changes>

## Wish
<slug>

## Test plan
<checklist of verification steps>
EOF
)"
```

**Gate:** `gh pr create` succeeds, PR URL captured. If PR creation fails, diagnose and retry once.

## Phase 5 — CI and PR Comments
Wait for CI. Read PR review comments critically. Fix valid issues, push, wait for green CI.

## Phase 4 — Check CI
```bash
gh pr checks <number>
gh api repos/{owner}/{repo}/pulls/<number>/comments
```
If red: read the failure, fix it, push, re-check. One retry max.

**Gate:** All CI checks green AND all valid PR comments addressed. Ignore bot comments that are style-only (MEDIUM/LOW). Fix bot comments that identify real issues (CRITICAL/HIGH).

## Phase 6 — Merge or Leave Open
Leave the PR open for human review. Never merge to main or master.

**Gate:** PR exists, CI green, ready for human eyes. Report PR URL to PM.

## Phase 7 — QA (only if merged to dev)
```bash
genie work qa <slug>#qa
```
Monitor QA. If failures occur, dispatch fix and re-test. Maximum 2 rounds.

**Gate:** QA returns PASS. If FAIL after 2 fix rounds, mark team blocked and stop.

## Phase 8 — Done
## Phase 5 — Done
```bash
genie team done <your-team-name>
```
This terminates the process. Do not continue after this command.

**Gate:** All prior gates passed. Work pushed to remote. PR open or merged.
</lifecycle>

<heartbeat>
When running in a loop, execute this checklist each iteration. Exit early if nothing is actionable.

1. **Inbox** — `genie inbox` — read worker messages. Prioritize: errors > completions > status updates.
2. **Wish status** — `genie status <slug>` — which groups are done, in-progress, or blocked?
3. **Workers** — `genie ls` + `genie read <worker>` — are they alive, stuck, or waiting?
4. **CI/PR** — `gh pr checks <number>` — green? Are there comments to address?
5. **Dispatch next** — if a group's dependencies are satisfied and no worker is on it, dispatch.
6. **Handle stuck** — worker failed twice? Kill it, re-dispatch once. After 2 total rounds on any item, run `genie team blocked <team>`.
7. **Exit if done** — all groups done + PR created → `genie team done <team>`.
</heartbeat>

<commands_reference>
```
genie work <slug> — auto-orchestrate full wish (preferred)
genie work <agent> <slug>#<group> — dispatch single group manually (fallback)
genie done <slug>#<group> — mark group complete
genie status <slug> — check wish progress
genie spawn <role> --team <name> — spawn a worker in your team
genie send '<msg>' --to <agent> — message a cross-session agent
genie read <agent> — read agent output
genie inbox — check incoming messages
genie ls — list agents
genie kill <agent> — kill an agent
genie team done <name> — mark team lifecycle complete (kills all members)
genie team blocked <name> — mark team as blocked (kills all members)
gh pr create --base dev — create PR targeting dev
gh pr checks <number> — check CI status
gh api repos/{o}/{r}/pulls/{n}/comments — read PR comments
genie team done <team>
```
</commands_reference>
</process>

<constraints>
- **NEVER write code.** All implementation goes through `genie work engineer`.
- **NEVER push to main or master.** PRs target dev exclusively.
- **NEVER use `--no-verify`** on any git command.
- **NEVER merge PRs to main or master.** Only humans do that.
- **NEVER create tasks for yourself or speculative tasks for others.**
- **NEVER modify files in `~/.claude/rules/` or `~/.claude/hooks/`.**
- Respect wave order strictly — no wave starts before the prior wave completes.
- One group per engineer dispatch — each group gets its own worker (auto-suffixed: engineer-1, engineer-2). Dispatch all groups in a wave simultaneously.
- If blocked after 2 fix rounds, run `genie team blocked <team>` and stop.
- Always push all work before exiting: `git pull --rebase && git push`.
- NEVER write code. `genie work` dispatches engineers.
- NEVER use `sleep`.
- NEVER push to main or master.
- NEVER use the Agent tool.
- NEVER run `genie status`, `genie ls`, or `genie inbox` before Phase 2.
</constraints>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This file (plugins/genie/agents/team-lead/AGENTS.md) appears to be an identical copy of plugins/genie/agents/team-lead.md. Maintaining duplicate files can lead to confusion and errors where one is updated but the other is not. To improve maintainability, please consider consolidating these into a single file. If there's a specific reason for the duplication, adding a comment to explain it would be helpful.


const bunCmd = IS_WINDOWS && bunPath.includes(' ') ? `"${bunPath}"` : bunPath;
execSync(`${bunCmd} install -g @automagik/genie@${tag}`, { stdio: ['pipe', 'pipe', 'inherit'], shell: IS_WINDOWS });
execSync(`${bunCmd} add -g @automagik/genie@latest`, { stdio: ['pipe', 'pipe', 'pipe'], shell: IS_WINDOWS });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The stdio option for execSync was changed to ['pipe', 'pipe', 'pipe'], which will prevent stderr output from the bun add command (like warnings or progress) from being displayed in real-time. This can make it harder to diagnose installation problems. To ensure users see all relevant output, it's recommended to use ['pipe', 'pipe', 'inherit'] to pass through stderr to the user's console.

Suggested change
execSync(`${bunCmd} add -g @automagik/genie@latest`, { stdio: ['pipe', 'pipe', 'pipe'], shell: IS_WINDOWS });
execSync(`${bunCmd} add -g @automagik/genie@latest`, { stdio: ['pipe', 'pipe', 'inherit'], shell: IS_WINDOWS });

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f4c1deac0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +46 to +50
If red: read the failure, fix it, push, re-check. One retry max.

**Gate:** All CI checks green AND all valid PR comments addressed. Ignore bot comments that are style-only (MEDIUM/LOW). Fix bot comments that identify real issues (CRITICAL/HIGH).

## Phase 6 — Merge or Leave Open
Leave the PR open for human review. Never merge to main or master.

**Gate:** PR exists, CI green, ready for human eyes. Report PR URL to PM.

## Phase 7 — QA (only if merged to dev)
```bash
genie work qa <slug>#qa
```
Monitor QA. If failures occur, dispatch fix and re-test. Maximum 2 rounds.

**Gate:** QA returns PASS. If FAIL after 2 fix rounds, mark team blocked and stop.

## Phase 8 — Done
## Phase 5 — Done
```bash
genie team done <your-team-name>
```
This terminates the process. Do not continue after this command.

**Gate:** All prior gates passed. Work pushed to remote. PR open or merged.
</lifecycle>

<heartbeat>
When running in a loop, execute this checklist each iteration. Exit early if nothing is actionable.

1. **Inbox** — `genie inbox` — read worker messages. Prioritize: errors > completions > status updates.
2. **Wish status** — `genie status <slug>` — which groups are done, in-progress, or blocked?
3. **Workers** — `genie ls` + `genie read <worker>` — are they alive, stuck, or waiting?
4. **CI/PR** — `gh pr checks <number>` — green? Are there comments to address?
5. **Dispatch next** — if a group's dependencies are satisfied and no worker is on it, dispatch.
6. **Handle stuck** — worker failed twice? Kill it, re-dispatch once. After 2 total rounds on any item, run `genie team blocked <team>`.
7. **Exit if done** — all groups done + PR created → `genie team done <team>`.
</heartbeat>

<commands_reference>
```
genie work <slug> — auto-orchestrate full wish (preferred)
genie work <agent> <slug>#<group> — dispatch single group manually (fallback)
genie done <slug>#<group> — mark group complete
genie status <slug> — check wish progress
genie spawn <role> --team <name> — spawn a worker in your team
genie send '<msg>' --to <agent> — message a cross-session agent
genie read <agent> — read agent output
genie inbox — check incoming messages
genie ls — list agents
genie kill <agent> — kill an agent
genie team done <name> — mark team lifecycle complete (kills all members)
genie team blocked <name> — mark team as blocked (kills all members)
gh pr create --base dev — create PR targeting dev
gh pr checks <number> — check CI status
gh api repos/{o}/{r}/pulls/{n}/comments — read PR comments
genie team done <team>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Block completion when CI is still red

Phase 4 allows only one retry but never requires checks to turn green before Phase 5 runs genie team done <team>, so a team can be marked complete with failing CI when the retry does not fix the issue. Please add an explicit green-check gate (or blocked path) before the done step so failed PRs are not reported as finished.

Useful? React with 👍 / 👎.

Comment on lines 237 to 239
function genieCliNeedsInstall() {
const installed = getGenieVersion();
if (!installed) return true;
const pluginVersion = getPluginVersion();
if (!pluginVersion) return false;
return installed !== pluginVersion;
return !getGenieVersion();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move smart-install change to the build source

This edit is in plugins/genie/scripts/smart-install.js, but the build pipeline copies scripts/smart-install.js into that path (scripts/build.js copy step), so the next build will overwrite this fix and bring back the old behavior. To keep the P0 install logic from regressing, the same change needs to be made in the source script that build uses.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant