Skip to content

feat: orchestration rules overhaul + agent folder structure + session fixes - #575

Merged
namastex888 merged 4 commits into
devfrom
fix/orchestration-rules
Mar 16, 2026
Merged

namastex888 merged 4 commits into
devfrom
fix/orchestration-rules

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

Major restructure of genie's agent system and orchestration rules. Council-approved simplification from 8+ agents to 4 standard + 4 on-demand.

Changes

Orchestration Rules (Group 1)

  • Slim plugins/genie/rules/genie-orchestration.md (~15 lines) — just "use genie CLI"
  • Deleted hardcoded ORCHESTRATION_PROMPT from smart-install.js
  • Deleted heredoc from install.sh
  • Both installers read from file now

Agent Consolidation (Group 2)

  • implementor → engineer (renamed)
  • spec-reviewer + quality-reviewer → reviewer (merged — one pass, criteria + quality)
  • tester → qa (merged — writes tests AND validates on dev)
  • Deleted: spec-reviewer.md, quality-reviewer.md, tests.md

Agent Folder Structure (Group 3)

  • Every agent is now a folder: plugins/genie/agents/<name>/AGENTS.md
  • Symlinks: <name>.md → <name>/AGENTS.md for CC Agent tool
  • New agents: team-lead/ (AGENTS.md + SOUL.md + HEARTBEAT.md), pm/ (AGENTS.md + SOUL.md + HEARTBEAT.md), qa/
  • Council members: each has SOUL.md with real-person-inspired philosophy
  • builtin-agents.ts rewired as filesystem resolver — no inline prompts

Session Fixes (Group 4)

  • AGENTS.md passed directly via --append-system-prompt-file (no copy to ~/.genie/prompts/)
  • Agent name = folder name (not hardcoded "team-lead")
  • First agent in team window uses existing pane (send-keys), no blank pane

Test plan

  • bun run typecheck passes
  • Tests pass
  • All agent folders have AGENTS.md
  • All symlinks resolve
  • No inline systemPrompt strings in builtin-agents.ts

Test User added 2 commits March 15, 2026 20:18
Group 1 — Orchestration Rules:
- Create plugins/genie/rules/genie-orchestration.md (~15 lines)
- Remove hardcoded ORCHESTRATION_PROMPT from smart-install.js
- Update install.sh to copy from package file with fallback
- Both installers log where the rule was created
- Add removal of ~/.claude/rules/genie-orchestration.md to uninstall

Group 2 — Agent Consolidation:
- Rename implementor → engineer
- Merge spec-reviewer + quality-reviewer → reviewer (SHIP/FIX-FIRST)
- Merge tests → qa (writes tests + validates on dev)
- Delete old agent files
- Update builtin-agents.ts, skills, and all references

Group 4 — Session Fixes:
- getAgentsSystemPrompt() → getAgentsFilePath() (returns path not content)
- team-lead-command.ts: accept systemPromptFile, delete PROMPTS_DIR copy
- --agent-name uses basename(cwd) instead of hardcoded "team-lead"
- launchTmuxSpawn: use send-keys for first agent in team window
…gistry

Group 3 of fix-orchestration-rules wish:

- Convert every agent .md into folder/<name>/AGENTS.md with symlinks
- Create team-lead/ with AGENTS.md + SOUL.md + HEARTBEAT.md
- Create pm/ with AGENTS.md + SOUL.md + HEARTBEAT.md
- Add SOUL.md for all council members with real-person philosophy
- Add @SOUL.md import to council AGENTS.md files
- Rewrite builtin-agents.ts: scan plugins/genie/agents/*/ for discovery,
  parse CC frontmatter, no inline systemPrompt strings
- Add resolveBuiltinAgentPath(name) for file-based resolution
- Update agents.ts: use agentPath as systemPromptFile, no inline prompts
- Update tests for new folder structure and naming (council-- double dash)
@coderabbitai

coderabbitai Bot commented Mar 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 68187492-bde6-438d-b81d-1b125f6ea0e9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/orchestration-rules
📝 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.

@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 significantly refactors the agent orchestration and management within the Genie system. The core changes involve simplifying the agent ecosystem by consolidating roles, introducing a more organized folder structure for agent definitions, and streamlining how orchestration rules and agent prompts are handled during installation and session creation. These updates aim to improve the maintainability, clarity, and flexibility of the agent system, making it easier to define and manage agent behaviors.

Highlights

  • Orchestration Rules Streamlined: The genie-orchestration.md rules are now loaded from a file within the plugin directory instead of being hardcoded in install.sh and smart-install.js, simplifying maintenance and deployment.
  • Agent Consolidation: Several agents have been merged or renamed to streamline the agent system. implementor is now engineer, spec-reviewer and quality-reviewer are merged into reviewer, and tester is now qa.
  • Agent Folder Structure: All agents now reside in dedicated folders (plugins/genie/agents/<name>/AGENTS.md), improving organization. Symlinks are created for compatibility, and builtin-agents.ts dynamically resolves agents from this new structure.
  • New Agent Roles: Introduced team-lead and pm agents with their own AGENTS.md, SOUL.md, and HEARTBEAT.md files, defining their responsibilities and operational philosophies.
  • Session Management Enhancements: AGENTS.md files are now passed directly to the claude command via --append-system-prompt-file, avoiding temporary file copies. The GENIE_AGENT_NAME environment variable is dynamically set based on the agent's folder name, and the first agent in a new team window now uses the existing pane instead of creating a new split.
Changelog
  • install.sh
    • Removed the large, hardcoded orchestration prompt and updated the script to copy the genie-orchestration.md file from the plugin directory, with a fallback for a minimal prompt.
  • plugins/genie/agents/council--architect.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--architect.md (added)
    • Created a symlink to council--architect/AGENTS.md.
  • plugins/genie/agents/council--architect/AGENTS.md
    • Added the agent definition file for the council--architect agent.
  • plugins/genie/agents/council--architect/SOUL.md
    • Added the SOUL.md file for the council--architect agent, defining its core philosophy.
  • plugins/genie/agents/council--benchmarker.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--benchmarker.md (added)
    • Created a symlink to council--benchmarker/AGENTS.md.
  • plugins/genie/agents/council--benchmarker/AGENTS.md
    • Added the agent definition file for the council--benchmarker agent.
  • plugins/genie/agents/council--benchmarker/SOUL.md
    • Added the SOUL.md file for the council--benchmarker agent, defining its core philosophy.
  • plugins/genie/agents/council--deployer.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--deployer.md (added)
    • Created a symlink to council--deployer/AGENTS.md.
  • plugins/genie/agents/council--deployer/AGENTS.md
    • Added the agent definition file for the council--deployer agent.
  • plugins/genie/agents/council--deployer/SOUL.md
    • Added the SOUL.md file for the council--deployer agent, defining its core philosophy.
  • plugins/genie/agents/council--ergonomist.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--ergonomist.md (added)
    • Created a symlink to council--ergonomist/AGENTS.md.
  • plugins/genie/agents/council--ergonomist/AGENTS.md
    • Added the agent definition file for the council--ergonomist agent.
  • plugins/genie/agents/council--ergonomist/SOUL.md
    • Added the SOUL.md file for the council--ergonomist agent, defining its core philosophy.
  • plugins/genie/agents/council--measurer.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--measurer.md (added)
    • Created a symlink to council--measurer/AGENTS.md.
  • plugins/genie/agents/council--measurer/AGENTS.md
    • Added the agent definition file for the council--measurer agent.
  • plugins/genie/agents/council--measurer/SOUL.md
    • Added the SOUL.md file for the council--measurer agent, defining its core philosophy.
  • plugins/genie/agents/council--operator.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--operator.md (added)
    • Created a symlink to council--operator/AGENTS.md.
  • plugins/genie/agents/council--operator/AGENTS.md
    • Added the agent definition file for the council--operator agent.
  • plugins/genie/agents/council--operator/SOUL.md
    • Added the SOUL.md file for the council--operator agent, defining its core philosophy.
  • plugins/genie/agents/council--questioner.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--questioner.md (added)
    • Created a symlink to council--questioner/AGENTS.md.
  • plugins/genie/agents/council--questioner/AGENTS.md
    • Added the agent definition file for the council--questioner agent.
  • plugins/genie/agents/council--questioner/SOUL.md
    • Added the SOUL.md file for the council--questioner agent, defining its core philosophy.
  • plugins/genie/agents/council--sentinel.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--sentinel.md (added)
    • Created a symlink to council--sentinel/AGENTS.md.
  • plugins/genie/agents/council--sentinel/AGENTS.md
    • Added the agent definition file for the council--sentinel agent.
  • plugins/genie/agents/council--sentinel/SOUL.md
    • Added the SOUL.md file for the council--sentinel agent, defining its core philosophy.
  • plugins/genie/agents/council--simplifier.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--simplifier.md (added)
    • Created a symlink to council--simplifier/AGENTS.md.
  • plugins/genie/agents/council--simplifier/AGENTS.md
    • Added the agent definition file for the council--simplifier agent.
  • plugins/genie/agents/council--simplifier/SOUL.md
    • Added the SOUL.md file for the council--simplifier agent, defining its core philosophy.
  • plugins/genie/agents/council--tracer.md
    • Removed the old agent definition file.
  • plugins/genie/agents/council--tracer.md (added)
    • Created a symlink to council--tracer/AGENTS.md.
  • plugins/genie/agents/council--tracer/AGENTS.md
    • Added the agent definition file for the council--tracer agent.
  • plugins/genie/agents/council--tracer/SOUL.md
    • Added the SOUL.md file for the council--tracer agent, defining its core philosophy.
  • plugins/genie/agents/council.md
    • Removed the old council agent definition.
  • plugins/genie/agents/council.md (added)
    • Created a symlink to council/AGENTS.md.
  • plugins/genie/agents/council/AGENTS.md
    • Added the agent definition file for the council agent.
  • plugins/genie/agents/council/SOUL.md
    • Added the SOUL.md file for the council agent.
  • plugins/genie/agents/docs.md
    • Removed the old agent definition file.
  • plugins/genie/agents/docs.md (added)
    • Created a symlink to docs/AGENTS.md.
  • plugins/genie/agents/docs/AGENTS.md
    • Added the agent definition file for the docs agent.
  • plugins/genie/agents/engineer.md
    • Added a symlink to engineer/AGENTS.md.
  • plugins/genie/agents/fix.md
    • Removed the old agent definition file.
  • plugins/genie/agents/fix.md (added)
    • Created a symlink to fix/AGENTS.md.
  • plugins/genie/agents/fix/AGENTS.md
    • Added the agent definition file for the fix agent.
  • plugins/genie/agents/implementor.md
    • Renamed the implementor agent definition to engineer/AGENTS.md.
  • plugins/genie/agents/learn.md
    • Removed the old agent definition file.
  • plugins/genie/agents/learn.md (added)
    • Created a symlink to learn/AGENTS.md.
  • plugins/genie/agents/learn/AGENTS.md
    • Added the agent definition file for the learn agent.
  • plugins/genie/agents/pm.md
    • Added a symlink to pm/AGENTS.md.
  • plugins/genie/agents/pm/AGENTS.md
    • Added the agent definition file for the pm agent.
  • plugins/genie/agents/pm/HEARTBEAT.md
    • Added the HEARTBEAT.md file for the pm agent.
  • plugins/genie/agents/pm/SOUL.md
    • Added the SOUL.md file for the pm agent.
  • plugins/genie/agents/qa.md
    • Added a symlink to qa/AGENTS.md.
  • plugins/genie/agents/qa/AGENTS.md
    • Added the agent definition file for the qa agent.
  • plugins/genie/agents/quality-reviewer.md
    • Removed the old quality-reviewer agent definition.
  • plugins/genie/agents/refactor.md
    • Removed the old agent definition file.
  • plugins/genie/agents/refactor.md (added)
    • Created a symlink to refactor/AGENTS.md.
  • plugins/genie/agents/refactor/AGENTS.md
    • Added the agent definition file for the refactor agent.
  • plugins/genie/agents/reviewer.md
    • Added a symlink to reviewer/AGENTS.md.
  • plugins/genie/agents/reviewer/AGENTS.md
    • Added the agent definition file for the reviewer agent, merging spec-reviewer and quality-reviewer functionalities.
  • plugins/genie/agents/spec-reviewer.md
    • Removed the old spec-reviewer agent definition.
  • plugins/genie/agents/team-lead.md
    • Added a symlink to team-lead/AGENTS.md.
  • plugins/genie/agents/team-lead/AGENTS.md
    • Added the agent definition file for the team-lead agent.
  • plugins/genie/agents/team-lead/HEARTBEAT.md
    • Added the HEARTBEAT.md file for the team-lead agent.
  • plugins/genie/agents/team-lead/SOUL.md
    • Added the SOUL.md file for the team-lead agent.
  • plugins/genie/agents/tests.md
    • Removed the old tests agent definition.
  • plugins/genie/agents/trace.md
    • Removed the old agent definition file.
  • plugins/genie/agents/trace.md (added)
    • Created a symlink to trace/AGENTS.md.
  • plugins/genie/agents/trace/AGENTS.md
    • Added the agent definition file for the trace agent.
  • plugins/genie/rules/genie-orchestration.md
    • Added a new, simplified orchestration rules file.
  • plugins/genie/scripts/smart-install.js
    • Removed the hardcoded ORCHESTRATION_PROMPT and updated the injectOrchestrationPrompt function to read the rules from the genie-orchestration.md file.
  • skills/dream/SKILL.md
    • Updated references from implementor to engineer and tester to qa.
  • skills/review/SKILL.md
    • Updated the reference from implementor to engineer.
  • skills/work/SKILL.md
    • Updated references from implementor to engineer.
  • src/genie-commands/tests/session.test.ts
    • Updated test descriptions and assertions to reflect changes in agent naming (team-lead to folder name) and system prompt handling (getAgentsSystemPrompt to getAgentsFilePath, direct file path passing).
  • src/genie-commands/session.ts
    • Renamed getAgentsSystemPrompt to getAgentsFilePath to return the file path directly, and updated buildClaudeCommand to accept systemPromptFile.
  • src/genie-commands/uninstall.ts
    • Added logic to remove the genie-orchestration.md file during uninstallation.
  • src/genie.ts
    • Updated the startNamedSession function to use getAgentsFilePath and pass systemPromptFile to buildTeamLeadCommand.
  • src/lib/agent-directory.test.ts
    • Updated agent names in tests to reflect the implementor to engineer rename and council-architect to council--architect format.
  • src/lib/agent-registry.ts
    • Updated the comment for the role property to reflect new agent names.
  • src/lib/builtin-agents.test.ts
    • Adjusted test counts for built-in roles and council members, updated assertions for agent properties (systemPrompt replaced by agentPath), and added tests for resolveBuiltinAgentPath.
  • src/lib/builtin-agents.ts
    • Refactored agent loading to dynamically scan the plugins/genie/agents/ directory, parse YAML frontmatter from AGENTS.md files, and removed all hardcoded system prompts.
  • src/lib/team-auto-spawn.ts
    • Renamed getSystemPrompt to getSystemPromptFile and updated its usage to pass the file path directly.
  • src/lib/team-lead-command.ts
    • Removed the logic for writing system prompts to a temporary file, updated buildTeamLeadCommand to accept a direct systemPromptFile path, and dynamically set GENIE_AGENT_NAME based on the current working directory's basename.
  • src/lib/team-manager.test.ts
    • Updated the expected number of council members in the hire council test.
  • src/term-commands/agents.ts
    • Modified launchTmuxSpawn to use send-keys for the first agent in a new team window, preventing unnecessary splits.
    • Updated resolveAgentForSpawn to use resolveBuiltinAgentPath and removed systemPrompt from the returned object.
  • src/term-commands/msg.test.ts
    • Updated tests for buildTeamLeadCommand to reflect the dynamic GENIE_AGENT_NAME and direct systemPromptFile passing.
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. ↩

@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 introduces a significant and valuable refactoring of the agent system. Key changes include consolidating agent roles, moving from hardcoded agent definitions to a more maintainable filesystem-based discovery, and improving session management. The new agent structure with AGENTS.md, SOUL.md, and HEARTBEAT.md files is a great step towards modularity. I've identified a couple of issues: one critical discrepancy where files intended as symlinks are created as plain text files, and a bug in how cd commands are constructed that will fail for paths containing spaces. Overall, this is a strong set of improvements.

I am having trouble creating individual review comments. Click here to see my feedback.

plugins/genie/agents/council--architect.md (1)

critical

This file appears to be intended as a symlink to council--architect/AGENTS.md for backward compatibility, as mentioned in the pull request description ("Symlinks: <name>.md → <name>/AGENTS.md for CC Agent tool"). However, it has been committed as a text file containing the path, not a symbolic link. This could cause issues with tooling that expects a symlink.

This comment applies to all similar new agent files in this pull request (e.g., council.md, docs.md, engineer.md, etc.) which are also text files instead of symlinks.

src/term-commands/agents.ts (513)

high

The cd command being sent to tmux does not properly quote the ctx.cwd path. This will cause it to fail if the path contains spaces or other special characters. The replace call for single quotes is ineffective here as the path itself is not quoted.

To fix this, you should shell-quote the path. A robust way to do this is to wrap it in double quotes and escape any internal double quotes.

        execSync(`tmux send-keys -t '${paneId}' 'cd "${ctx.cwd.replace(/"/g, '\\"')}"' Enter`, { encoding: 'utf-8' });

@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: 6736130133

ℹ️ 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 +51 to +52
`--agent-id ${shellQuote(`${folderName}@${sanitized}`)}`,
`--agent-name ${shellQuote(folderName)}`,

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 Keep team-lead identity stable across launcher and team state

buildTeamLeadCommand now derives GENIE_AGENT_NAME/--agent-id from basename(process.cwd()), but the rest of the team/session stack still keys leader state as team-lead (for example, resume lookup in session.ts uses findLastSessionId(..., 'team-lead', ...), and native-team config/inbox code uses team-lead@<team>). In any repo whose folder name is not team-lead, this mismatch breaks leader identity continuity (missed resume and inconsistent native-team leader registration).

Useful? React with 👍 / 👎.

Comment thread install.sh Outdated
Comment on lines +662 to +666
for candidate in \
"$PLUGIN_SYMLINK/rules/genie-orchestration.md" \
"$HOME/.claude/plugins/genie/rules/genie-orchestration.md" \
"$(npm root -g 2>/dev/null)/@automagik/genie/plugins/genie/rules/genie-orchestration.md" \
"$(bun pm -g bin 2>/dev/null)/../lib/node_modules/@automagik/genie/plugins/genie/rules/genie-orchestration.md"; do

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 Load orchestration rules from the resolved package path

This lookup only checks hardcoded candidate paths and does not use the installer’s already-resolved PKG_DIR; in run_install, inject_orchestration_prompt runs before plugin linking, so these candidates can miss the actual install location and trigger the fallback minimal rules file. That silently drops the full orchestration policy during install instead of copying plugins/genie/rules/genie-orchestration.md.

Useful? React with 👍 / 👎.

Test User added 2 commits March 15, 2026 21:21
session.ts hardcoded 'team-lead' as the agent name in ensureNativeTeamForLeader,
findLastSessionId calls, and console.log messages. Since team-lead-command.ts
derives agent name from basename(cwd), session.ts must match to avoid session
resume mismatches and incorrect native team registration.

Also simplify install.sh orchestration rules lookup to use the already-resolved
PKG_DIR instead of scanning hardcoded candidate paths.
@namastex888
namastex888 merged commit ddc8db2 into dev Mar 16, 2026
5 checks passed
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