Skip to content

Add global Codex Bee Army and cross-harness update manager - #4

Open
chrisl10 wants to merge 2 commits into
legioncodeinc:mainfrom
chrisl10:agent/global-codex-bee-army
Open

Add global Codex Bee Army and cross-harness update manager#4
chrisl10 wants to merge 2 commits into
legioncodeinc:mainfrom
chrisl10:agent/global-codex-bee-army

Conversation

@chrisl10

@chrisl10 chrisl10 commented Jul 12, 2026

Copy link
Copy Markdown

What changed

  • adds a self-contained bee-army CLI for global installation and updates
  • translates canonical .cursor Bees into native Codex TOML agents
  • installs shared Stingers and Codex launcher skills globally
  • keeps Cursor, Claude Code, and Codex pinned to one upstream commit
  • adds status, check, preview, validate, install/update, doctor, and rollback commands
  • protects locally modified managed files and backs up every touched path

Global-only contract

This implementation never creates .codex/, .agents/, or AGENTS.md inside a user project. Codex assets install under the user global homes (~/.codex and ~/.agents/skills), with equivalent global destinations for Claude and Cursor.

Why

The previous project-adapter approach did not work reliably in real Codex usage. Native global Codex agents plus their paired Stingers reproduce the Bee routing model without requiring per-project scaffolding. The cross-harness manager also prevents Claude, Cursor, and Codex from drifting onto different asset revisions.

Safety and update behavior

  • stages and validates translations before installation
  • never executes scripts from the upstream checkout during installation
  • records SHA-256 hashes for every managed file
  • refuses to overwrite managed files changed outside the updater
  • creates a rollback backup before applying changes
  • supports portable home and upstream overrides for non-default layouts and tests

Verification

  • npm test
    • validates the current 85 Bees and 91 skill directories (90 usable)
    • performs a full three-harness installation in an isolated temporary home
    • verifies Codex native agents, paired Stingers, launchers, and update skill
    • proves no project-level scaffolding is created
    • proves local modifications block an update
    • proves rollback restores the pre-install state
  • node --check scripts/bee-army.mjs
  • git diff --check
  • npm pack --dry-run

Supersedes #3 with a fresh global-only implementation.

Summary by CodeRabbit

  • New Features

    • Added the bee-army CLI for installing and updating AI tooling across Cursor, Claude Code, and Codex.
    • Added preview, validation, diagnostics, status, update, and rollback commands.
    • Added safe installation with backups, change detection, rollback support, and global-only safeguards.
    • Added Codex support, including generated agent definitions and cross-harness asset mapping.
  • Documentation

    • Updated project documentation with CLI usage, installation behavior, safety guarantees, configuration options, and Codex compatibility.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@chrisl10, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 34b4f077-e81d-4d3c-a486-a8b38a10ee9b

📥 Commits

Reviewing files that changed from the base of the PR and between e34a5f1 and e174399.

📒 Files selected for processing (4)
  • README.md
  • scripts/bee-army.mjs
  • scripts/frontmatter.mjs
  • test/bee-army.test.mjs
📝 Walkthrough

Walkthrough

Adds a global bee-army Node CLI that translates pinned upstream Bee assets for Cursor, Claude, and Codex, validates staged output, applies changes transactionally with rollback, and tests installation, integrity protection, and global-only behavior.

Changes

Global Bee Army installer

Layer / File(s) Summary
Codex mapping and installer contract
AGENTS.md, README.md
Documents Codex asset mappings, global-only constraints, installer safeguards, environment overrides, and supported harness layouts.
CLI setup and stage generation
package.json, scripts/bee-army.mjs
Adds the bee-army entrypoint and generates validated Cursor, Claude, and Codex deployment stages from a pinned upstream checkout.
Transactional installation lifecycle
scripts/bee-army.mjs
Adds backups, atomic writes, manifests, integrity checks, diagnostics, update, preview, validation, rollback, locking, and command dispatch.
End-to-end lifecycle coverage
test/bee-army.test.mjs
Tests isolated installation, generated files, global-only behavior, manifest targets, modified-file protection, and rollback cleanup.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant BeeArmy as bee-army CLI
  participant Upstream as Upstream checkout
  participant Filesystem
  participant Manifest as manifest.json
  Operator->>BeeArmy: Run install or update --apply
  BeeArmy->>Upstream: Fetch and select pinned commit
  BeeArmy->>BeeArmy: Generate and validate harness stages
  BeeArmy->>Filesystem: Backup and atomically apply managed files
  BeeArmy->>Manifest: Persist hashes and backup metadata
  Operator->>BeeArmy: Run rollback --apply
  BeeArmy->>Filesystem: Restore backup and remove installation
Loading

Poem

I’m a rabbit with a tidy little hive,
Codex and Cursor now neatly arrive.
Backups tucked safely, hashes in a row,
Stingers hop where the Bee winds blow.
Roll back with a twitch, then away we go!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a global Codex Bee Army CLI with cross-harness update management.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@chrisl10

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 9

🧹 Nitpick comments (1)
scripts/bee-army.mjs (1)

213-226: 🚀 Performance & Scalability | 🔵 Trivial

No backup rotation/pruning.

Every update --apply creates a new timestamped directory under BACKUPS_ROOT and nothing ever removes old ones. Over many updates this grows unbounded. Consider retaining only the last N backups.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/bee-army.mjs` around lines 213 - 226, The backup creation flow around
BACKUPS_ROOT and backupRoot currently retains every backup indefinitely. Add
pruning after writing the new backup record to retain only the configured last N
timestamped backup directories, sorting them by creation or backup ID order and
removing older directories while preserving the newly created backup.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 130-137: Clarify the README Rules row and accompanying note to
state that bee-army currently installs rules only for Cursor via .cursor/rules,
and does not generate CLAUDE.md or global Codex instructions. Keep the existing
harness-specific rule locations as reference, but remove wording that implies
Claude/Codex rule translation is performed.

In `@scripts/bee-army.mjs`:
- Around line 269-284: Wrap the `check()` and `preview()` command flows in the
same `withLock` mechanism used by `update`, `validate`, and `rollback`, ensuring
their `fetchUpstream()` calls execute while the shared `SOURCE_ROOT` checkout is
locked. Update the command dispatch so both operations acquire that lock without
changing their existing output or comparison behavior.
- Around line 309-314: Update withLock to provide stale-lock recovery when
LOCK_PATH already exists, using lock metadata such as the owning process
identity and/or age to distinguish an active operation from an abandoned lock;
remove only locks confirmed stale, then retry acquisition while preserving the
existing failure for active locks. Keep cleanup in the finally block for
normally completed operations.
- Around line 211-250: Update applyStage and the recovery path around
restoreBackup so a backup created before file mutations remains discoverable if
the process terminates before MANIFEST_PATH is rewritten. Persist or resolve the
pending backup using the backup directory metadata/name, and make rollback
--apply and update recovery prefer the newest valid backup over the stale
manifest backupId. Preserve existing restoration behavior for completed
manifests and caught errors.
- Around line 27-29: Update run() to provide a finite timeout to execFileSync,
ensuring git operations used by ensureSource, fetchUpstream, and checkoutCommit
cannot hang indefinitely. Preserve any caller-supplied timeout through options
while retaining the existing command execution and output behavior.
- Around line 65-75: Update parseFrontmatter to preserve indented continuation
lines for multiline frontmatter values, especially description, by folding them
into the preceding field before validation and returning fields. Ensure
generated Codex TOML receives the complete value while retaining existing
single-line parsing and required-field checks.

In `@test/bee-army.test.mjs`:
- Line 20: Update the BEE_ARMY_UPSTREAM_BRANCH configuration in the test setup
to avoid assuming the upstream branch is always "main": derive the repository’s
default branch dynamically, or explicitly document and enforce the required
branch when dynamic detection is unavailable.
- Around line 25-48: Update the test around the install invocation to execute
installation from the temporary project directory by using runIn(home, project,
"install", "--apply") instead of run(home, "install", "--apply"). Keep the
existing home-based validation, doctor checks, and project scaffolding
assertions unchanged.
- Around line 12-23: Update the run helper’s child-process environment so
CODEX_HOME, CLAUDE_HOME, CURSOR_HOME, and AGENTS_HOME cannot override
BEE_ARMY_HOME-derived paths; remove these inherited keys or set them to empty
strings while preserving the existing BEE_ARMY_HOME, upstream URL, and branch
values.

---

Nitpick comments:
In `@scripts/bee-army.mjs`:
- Around line 213-226: The backup creation flow around BACKUPS_ROOT and
backupRoot currently retains every backup indefinitely. Add pruning after
writing the new backup record to retain only the configured last N timestamped
backup directories, sorting them by creation or backup ID order and removing
older directories while preserving the newly created backup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6502a804-f245-43fe-94ed-64121316f85c

📥 Commits

Reviewing files that changed from the base of the PR and between e157be6 and e34a5f1.

📒 Files selected for processing (5)
  • AGENTS.md
  • README.md
  • package.json
  • scripts/bee-army.mjs
  • test/bee-army.test.mjs

Comment thread README.md Outdated
Comment thread scripts/bee-army.mjs
Comment thread scripts/bee-army.mjs Outdated
Comment thread scripts/bee-army.mjs
Comment thread scripts/bee-army.mjs
Comment thread scripts/bee-army.mjs Outdated
Comment thread test/bee-army.test.mjs
Comment thread test/bee-army.test.mjs Outdated
Comment thread test/bee-army.test.mjs
@chrisl10

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chrisl10

Copy link
Copy Markdown
Author

Addressed in e174399:

  • isolated all harness homes in tests and run installation from the temporary project cwd
  • added finite Git timeouts, shared locking for check/preview, and owner-aware stale-lock recovery
  • added pending-update recovery for interrupted installs and bounded backup retention
  • added multiline frontmatter folding with direct unit coverage
  • corrected the rules compatibility documentation
  • retained main as the explicit test branch because it is the CLI and official upstream default contract

Fresh verification: npm test passes 2/2, including the full 85-Bee/91-skill isolated lifecycle.

@chrisl10
chrisl10 marked this pull request as ready for review July 13, 2026 20:58
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