Repository navigation
fix(lint): reduce cognitive complexity in buildClaudeCommand and launchTmuxSpawn - #595
Conversation
…chTmuxSpawn Extract helper functions to bring both functions under the biome complexity limit of 15: - buildClaudeCommand (27→~12): extract appendSystemPromptFlags() - launchTmuxSpawn (22→~8): extract createTmuxPane() and applySpawnLayout() Closes #594
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure the |
Summary of ChangesHello, 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 improving code readability and maintainability by refactoring two key functions, Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request is a good refactoring effort to reduce the cognitive complexity of buildClaudeCommand and launchTmuxSpawn by extracting helper functions. The refactoring of launchTmuxSpawn is clean and improves readability. For buildClaudeCommand, I've left a couple of comments on the new appendSystemPromptFlags helper regarding a side effect and the handling of temporary files. Overall, the changes are a positive step towards better code maintainability.
| const dir = '/tmp/genie-prompts'; | ||
| mkdirSync(dir, { recursive: true }); | ||
| const ts = Date.now().toString(36); | ||
| const promptFile = join(dir, `${params.role || 'agent'}-${ts}.md`); |
There was a problem hiding this comment.
This function creates temporary files in /tmp/genie-prompts but doesn't seem to have a mechanism to clean them up. Over time, this could lead to a large number of files accumulating in the /tmp directory.
Consider implementing a cleanup strategy. This could be done, for example, by registering a cleanup function on process exit, or by using a library like tmp which can manage temporary files and directories automatically.
| if (fileIdx !== -1 && params.extraArgs[fileIdx + 1]) { | ||
| content = `${content}\n\n${readFileSync(params.extraArgs[fileIdx + 1], 'utf-8')}`; | ||
| // Remove the extra arg since we merged it | ||
| params.extraArgs.splice(fileIdx, 2); |
There was a problem hiding this comment.
This function mutates the params.extraArgs array by calling splice. While this is documented in the JSDoc ("consuming it so it isn't duplicated later"), functions with side effects on their inputs can be harder to reason about and reuse safely. Consider making this function pure by having it return the unconsumed arguments instead of modifying the input array directly. This would make the data flow more explicit.
* chore(version): bump to 3.260314.9 [skip ci] * fix(skills): rewrite orchestration rules, kill onboarding, rewrite learn+brain Group 1 — Orchestration Rules Rewrite: - Rewrite ORCHESTRATION_PROMPT in smart-install.js and install.sh with current CLI commands (spawn, kill, stop, ls, team create/hire/fire/disband, send, broadcast, chat, done, status, reset) - Add skill auto-invocation chain, team lifecycle, and rules sections - Remove stale genie agent spawn, genie team ensure, genie agent dashboard refs - Both files have identical orchestration content Group 2 — Kill Onboarding + Inline References: - Delete skills/onboarding/ directory entirely - Inline prompt optimizer content into skills/refine/SKILL.md - Inline design template into skills/brainstorm/SKILL.md - Inline wish template into skills/wish/SKILL.md - Remove all references/ file paths from SKILL.md files Group 5 — Learn Rewrite + Brain Update: - Rewrite skills/learn/SKILL.md: primary trigger is user correction, diagnoses which behavioral surface needs change (CLAUDE.md, AGENTS.md, SOUL.md, rules/, memory/, hooks, configs). Remove BOOTSTRAP.md ref. Connect to Claude native memory. - Update skills/brain/SKILL.md: add brain vs memory distinction (brain=context graph, memory=behavioral learnings). Add auto-install: detect notesmd-cli, offer install from https://github.com/Yakitrak/notesmd-cli * fix(skills): update core chain, support skills, and dream lifecycle Group 3 — Core Chain Skills: - brainstorm: remove genie brainstorm crystallize, auto-invoke /review at WRS=100, suggest /council when Decisions stuck after 2+ exchanges - wish: fuzzy gate check auto-triggers /brainstorm, step 7 declares depends-on, handoff auto-invokes /review instead of suggesting /work - work: clarify as implementor skill via genie work dispatch, add local /review per group, genie send signaling, leader uses genie done (not worker), remove "no state management" confusion - review: add SHIP next-steps per context (plan→wish/work, execution→PR, PR→merge), auto-invoke /fix on FIX-FIRST, /trace for unclear root cause Group 4 — Support Skills: - council: add auto-invocation triggers (review arch decisions, brainstorm stuck decisions), document genie team hire council, add 2min timeout for full spawn, clarify lightweight=simulate vs full spawn=real agents - trace: add genie send for reporting findings, clarify spawned agent IS the tracer, /review can invoke /trace - report: document agent-browser as genie dependency, add wish criteria linking during QA, add QA failure auto-invocation chain - docs: add doc types (README, CLAUDE.md, API, architecture, JSDoc), CLAUDE.md as first-class surface, post-work suggestion - refine: verified inlined content, no remaining references/ paths Group 6 — Dream Lifecycle: - Phase 1: use genie work dispatch per group (state tracking for free), genie status/done/reset for monitoring - Phase 2: leader creates PR, reads bot comments critically, /fix valid issues, CI green required (poll, don't sleep) - Phase 3: merge to dev, spawn tester, QA loop until all criteria proven, each fix = new PR to dev - Phase 4: DREAM-REPORT.md with per-wish QA status - Remove Status: SHIPPED and sleep 5 references - Add full team lifecycle: create→execute→review→merge→QA→disband * fix(skills): correct command names and template backticks from PR review - Change genie agent history/read/answer to genie history/read/answer (top-level commands, not under agent namespace) in both install.sh and smart-install.js - Fix escaped backticks in wish SKILL.md template (remove backslashes) - Add --repo <path> to genie team create in both orchestration prompts (--repo is required) * chore(version): bump to 3.260314.10 [skip ci] * feat: add task leader role with autonomous wish lifecycle orchestration - Add "leader" built-in role with full orchestration system prompt - Add --wish <slug> flag to "genie team create" for auto-spawning leaders - Add team status tracking (in_progress/done/blocked) with setTeamStatus() - Add "genie team done" and "genie team blocked" CLI commands - Add autoMergeDev config option to GenieConfigSchema - Update "genie team ls" to show team status column * fix: address PR review feedback for task leader feature - Add file lock to setTeamStatus to prevent concurrent read-modify-write races - Replace require("node:path").resolve with ESM import in team.ts - Validate wish file exists before createTeam to avoid orphaned teams - Add --team flag to all genie team commands in leader prompt since GENIE_TEAM won't be set * fix: reorder imports to satisfy biome lint Co-Authored-By: Paperclip <noreply@paperclip.ing> * chore(version): bump to 3.260315.1 [skip ci] * fix: eliminate inline --system-prompt flags, use temp files for all prompts Inline --append-system-prompt and --system-prompt flags broke when passed through tmux send-keys with multi-line prompts containing code blocks. All system prompts are now written to temp files at /tmp/genie-prompts/ and passed via --append-system-prompt-file or --system-prompt-file. When both systemPrompt and systemPromptFile are set, they are merged into a single temp file. Extra --append-system-prompt-file args are also merged. Closes #568 * fix: use template literals to satisfy biome lint * chore(version): bump to 3.260315.2 [skip ci] * feat: auto-kickoff leader on wish spawn + orchestration rules audit - Add initialPrompt field to SpawnParams/SpawnOptions, appended as Claude Code positional [prompt] arg in buildClaudeCommand() - spawnLeaderWithWish() now passes a kickoff prompt so the leader begins working immediately — no manual genie send needed - Audit and update orchestration rules in smart-install.js and install.sh: add team done/blocked, dir commands, update --next/ --stable, task leader workflow, autoMergeDev config - Both install scripts now have identical orchestration content * chore(version): bump to 3.260315.3 [skip ci] * feat: slim orchestration rules, consolidate agents, session fixes 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 * feat: agent folder structure, new agents, filesystem-based builtin registry 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) * fix: biome lint formatting and import ordering * fix: use dynamic agent name in session.ts to match team-lead-command.ts 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. * chore(version): bump to 3.260316.1 [skip ci] * fix: resolve package root via process.argv[1] for compiled dist (#576) import.meta.dir returns CWD in compiled bundles, not the module's directory. Use the actual script path (process.argv[1]) resolved via realpathSync to find the package root and discover agent folders. * chore(version): bump to 3.260316.2 [skip ci] * chore(version): bump to 3.260316.3 [skip ci] * chore(version): bump to 3.260316.4 [skip ci] * fix: spawn team-lead not leader (matches folder name) * chore(version): bump to 3.260316.5 [skip ci] * feat: spawn into current session when --team not provided - agents.ts: Add spawnIntoCurrentWindow flag to skip team window resolution and split the current window when team is auto-detected from GENIE_TEAM env var (no explicit --team) - session.ts: Register interactive genie session in ~/.genie/workers.json so spawned agents can resolve the team-lead for bidirectional SendMessage communication - genie-orchestration.md: Update rules to allow SendMessage for same-session teammates while keeping genie send for cross-session * fix: replace agent symlinks with real files for npm/bun compatibility Symlinks (council.md → council/AGENTS.md) don't survive npm pack + bun install — bun resolves them at install time and loses the folder structure. Both flat .md files (for CC Agent tool) and folder/AGENTS.md (for genie spawn) now have the same content as real files. * chore(version): bump to 3.260316.6 [skip ci] * fix(update): use bun update -g instead of remove+install * chore(version): bump to 3.260316.7 [skip ci] * chore(version): bump to 3.260316.8 [skip ci] * fix(update): use bun add --force --no-cache to bypass stale cache * fix: single prompt file for team-lead — context in initial message, no extraArgs * fix: team-lead spawn improvements - Pre-hire standard team (engineer, reviewer, qa, fix) on --wish - Remove redundant context file — wish context in initial prompt - Include team name, repo, branch, worktree, members in kickoff message - Use bun add --force --no-cache for updates (bypass stale cache) * fix: remove unused imports * chore(version): bump to 3.260316.9 [skip ci] * fix: inline SOUL + HEARTBEAT into team-lead AGENTS.md — @imports dont work in system prompts * chore(version): bump to 3.260316.10 [skip ci] * fix: team-lead uses genie work directly + wish template QA section * chore(version): bump to 3.260316.11 [skip ci] * fix: set GENIE_TEAM env var on spawn — agents dispatch to correct team * chore(version): bump to 3.260316.12 [skip ci] * fix: kickoff message says genie work spawns automatically, not use genie spawn * fix(update): delete bun global lockfile before install — prevents stale versions * feat: project-scoped agent directory with three-tier resolution Agent directory now defaults to project scope (<repo>/.genie/agents.json) with fallback to global (~/.genie/agent-directory.json) then built-ins. - add/rm/edit default to project scope, accept { global: true } option - resolve() checks project → global → built-in roles → built-in council - ls() returns entries from all scopes with scope label - dir CLI commands accept --global flag - dir ls shows SCOPE column Closes #578 * fix: biome formatting * fix: biome formatting * chore(version): bump to 3.260316.13 [skip ci] * fix(reset): clean up all team dirs on --reset, not just current window (#593) * fix(reset): clean up all team dirs on --reset, not just current window When `genie --reset` was called, handleReset() killed the entire tmux session but only deleted one native team directory (the current windowName). Any other windows in the session left their team configs behind in ~/.claude/teams/. Fix: collect all window names via listWindows() before killing the session, then delete each window's team directory. Closes #545 * fix: use session ID instead of name in tmux calls to prevent injection Gemini review flagged potential command injection when sessionName is passed to tmux.listWindows/killSession. If a session name contains single quotes it could break shell quoting in executeTmux. Fix: use existing.id (system-assigned identifier) instead of sessionName for the tmux calls. Session name still used for the log message (cosmetic only). --------- Co-authored-by: Felipe Rosa <felipe@namastex.ai> * chore(version): bump to 3.260316.14 [skip ci] * chore: trigger @next publish for v3.260316.14 * fix(lint): reduce cognitive complexity in buildClaudeCommand and launchTmuxSpawn (#595) Extract helper functions to bring both functions under the biome complexity limit of 15: - buildClaudeCommand (27→~12): extract appendSystemPromptFlags() - launchTmuxSpawn (22→~8): extract createTmuxPane() and applySpawnLayout() Closes #594 Co-authored-by: Test User <test@test.com> * chore: trigger @next publish for v3.260316.14 * fix(lint): resolve all remaining lint errors and complexity warnings (#596) - Fix JSON formatting in package.json, openclaw.plugin.json, plugin.json - Fix noAssignInExpressions in dispatch.ts (refactor while loop) - Reduce complexity in performUninstall (21→≤15): extract tryRemoveStep() - Reduce complexity in autoSpawn (25→≤15): extract buildSearchNames(), buildSpawnArgs() - Reduce complexity in executeBlockingChain (18→≤15): extract runHandler() - Reduce complexity in syncPlugin (16→≤15): extract updatePluginRegistry() - Reduce complexity in chat action (17→≤15): extract resolveTeamName() Biome now reports zero errors and zero warnings. Co-authored-by: Test User <test@test.com> * chore(tests): remove flaky stress/load tests (#597) Delete scale.test.ts and file-lock-concurrency.test.ts — these are environment-dependent stress tests that cause CI failures due to shared /tmp state and concurrent file lock race conditions. They belong in a separate CI job, not the main test suite. Co-authored-by: Test User <test@test.com> * feat(worktree): move default worktree path out of repo (#601) * feat(worktree): move default worktree path to ~/.genie/worktrees/<project>/ Worktrees currently default to <repo>/.worktrees/ which causes accidental git commits and bloated npm publishes. Change the default to ~/.genie/worktrees/<project-name>/ when no explicit worktreeBase is set. - Make worktreeBase optional in config schema (undefined = new default) - Update getWorktreeBase() to derive project name from basename(repoPath) - Update setup wizard to show new default path * feat(worktree): add auto-prune, fix gitignore, remove dead code - Add pruneStaleWorktrees() to clean up team configs for non-existent worktree paths and run git worktree prune - Call pruneStaleWorktrees() from disbandTeam() after cleanup - Update .gitignore: add .worktrees/, remove dead .genie/worktrees/ - Untrack committed .worktrees/ directory from git - Delete dead worktree-manager.ts and its test (unused legacy code) --------- Co-authored-by: Test User <test@test.com> * chore: remove local state from git tracking and update .gitignore (#598) Remove files that should never have been tracked: - .worktrees/ — Claude Code worktree metadata - .genie/agents.json — local agent directory - .genie/teams/ — local team configs - .genie/brainstorms/ — local brainstorm drafts - .genie/wishes/ — local wish plans These are local runtime state, not part of the published package. Files remain on disk (git rm --cached), only removed from tracking. Co-authored-by: Test User <test@test.com> --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Test User <test@test.com> Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Automagik Genie 🧞 <genie@namastex.ai> Co-authored-by: clawtom <atotom740@gmail.com>
* chore(version): bump to 3.260314.9 [skip ci] * fix(skills): rewrite orchestration rules, kill onboarding, rewrite learn+brain Group 1 — Orchestration Rules Rewrite: - Rewrite ORCHESTRATION_PROMPT in smart-install.js and install.sh with current CLI commands (spawn, kill, stop, ls, team create/hire/fire/disband, send, broadcast, chat, done, status, reset) - Add skill auto-invocation chain, team lifecycle, and rules sections - Remove stale genie agent spawn, genie team ensure, genie agent dashboard refs - Both files have identical orchestration content Group 2 — Kill Onboarding + Inline References: - Delete skills/onboarding/ directory entirely - Inline prompt optimizer content into skills/refine/SKILL.md - Inline design template into skills/brainstorm/SKILL.md - Inline wish template into skills/wish/SKILL.md - Remove all references/ file paths from SKILL.md files Group 5 — Learn Rewrite + Brain Update: - Rewrite skills/learn/SKILL.md: primary trigger is user correction, diagnoses which behavioral surface needs change (CLAUDE.md, AGENTS.md, SOUL.md, rules/, memory/, hooks, configs). Remove BOOTSTRAP.md ref. Connect to Claude native memory. - Update skills/brain/SKILL.md: add brain vs memory distinction (brain=context graph, memory=behavioral learnings). Add auto-install: detect notesmd-cli, offer install from https://github.com/Yakitrak/notesmd-cli * fix(skills): update core chain, support skills, and dream lifecycle Group 3 — Core Chain Skills: - brainstorm: remove genie brainstorm crystallize, auto-invoke /review at WRS=100, suggest /council when Decisions stuck after 2+ exchanges - wish: fuzzy gate check auto-triggers /brainstorm, step 7 declares depends-on, handoff auto-invokes /review instead of suggesting /work - work: clarify as implementor skill via genie work dispatch, add local /review per group, genie send signaling, leader uses genie done (not worker), remove "no state management" confusion - review: add SHIP next-steps per context (plan→wish/work, execution→PR, PR→merge), auto-invoke /fix on FIX-FIRST, /trace for unclear root cause Group 4 — Support Skills: - council: add auto-invocation triggers (review arch decisions, brainstorm stuck decisions), document genie team hire council, add 2min timeout for full spawn, clarify lightweight=simulate vs full spawn=real agents - trace: add genie send for reporting findings, clarify spawned agent IS the tracer, /review can invoke /trace - report: document agent-browser as genie dependency, add wish criteria linking during QA, add QA failure auto-invocation chain - docs: add doc types (README, CLAUDE.md, API, architecture, JSDoc), CLAUDE.md as first-class surface, post-work suggestion - refine: verified inlined content, no remaining references/ paths Group 6 — Dream Lifecycle: - Phase 1: use genie work dispatch per group (state tracking for free), genie status/done/reset for monitoring - Phase 2: leader creates PR, reads bot comments critically, /fix valid issues, CI green required (poll, don't sleep) - Phase 3: merge to dev, spawn tester, QA loop until all criteria proven, each fix = new PR to dev - Phase 4: DREAM-REPORT.md with per-wish QA status - Remove Status: SHIPPED and sleep 5 references - Add full team lifecycle: create→execute→review→merge→QA→disband * fix(skills): correct command names and template backticks from PR review - Change genie agent history/read/answer to genie history/read/answer (top-level commands, not under agent namespace) in both install.sh and smart-install.js - Fix escaped backticks in wish SKILL.md template (remove backslashes) - Add --repo <path> to genie team create in both orchestration prompts (--repo is required) * chore(version): bump to 3.260314.10 [skip ci] * feat: add task leader role with autonomous wish lifecycle orchestration - Add "leader" built-in role with full orchestration system prompt - Add --wish <slug> flag to "genie team create" for auto-spawning leaders - Add team status tracking (in_progress/done/blocked) with setTeamStatus() - Add "genie team done" and "genie team blocked" CLI commands - Add autoMergeDev config option to GenieConfigSchema - Update "genie team ls" to show team status column * fix: address PR review feedback for task leader feature - Add file lock to setTeamStatus to prevent concurrent read-modify-write races - Replace require("node:path").resolve with ESM import in team.ts - Validate wish file exists before createTeam to avoid orphaned teams - Add --team flag to all genie team commands in leader prompt since GENIE_TEAM won't be set * fix: reorder imports to satisfy biome lint Co-Authored-By: Paperclip <noreply@paperclip.ing> * chore(version): bump to 3.260315.1 [skip ci] * fix: eliminate inline --system-prompt flags, use temp files for all prompts Inline --append-system-prompt and --system-prompt flags broke when passed through tmux send-keys with multi-line prompts containing code blocks. All system prompts are now written to temp files at /tmp/genie-prompts/ and passed via --append-system-prompt-file or --system-prompt-file. When both systemPrompt and systemPromptFile are set, they are merged into a single temp file. Extra --append-system-prompt-file args are also merged. Closes #568 * fix: use template literals to satisfy biome lint * chore(version): bump to 3.260315.2 [skip ci] * feat: auto-kickoff leader on wish spawn + orchestration rules audit - Add initialPrompt field to SpawnParams/SpawnOptions, appended as Claude Code positional [prompt] arg in buildClaudeCommand() - spawnLeaderWithWish() now passes a kickoff prompt so the leader begins working immediately — no manual genie send needed - Audit and update orchestration rules in smart-install.js and install.sh: add team done/blocked, dir commands, update --next/ --stable, task leader workflow, autoMergeDev config - Both install scripts now have identical orchestration content * chore(version): bump to 3.260315.3 [skip ci] * feat: slim orchestration rules, consolidate agents, session fixes 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 * feat: agent folder structure, new agents, filesystem-based builtin registry 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) * fix: biome lint formatting and import ordering * fix: use dynamic agent name in session.ts to match team-lead-command.ts 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. * chore(version): bump to 3.260316.1 [skip ci] * fix: resolve package root via process.argv[1] for compiled dist (#576) import.meta.dir returns CWD in compiled bundles, not the module's directory. Use the actual script path (process.argv[1]) resolved via realpathSync to find the package root and discover agent folders. * chore(version): bump to 3.260316.2 [skip ci] * chore(version): bump to 3.260316.3 [skip ci] * chore(version): bump to 3.260316.4 [skip ci] * fix: spawn team-lead not leader (matches folder name) * chore(version): bump to 3.260316.5 [skip ci] * feat: spawn into current session when --team not provided - agents.ts: Add spawnIntoCurrentWindow flag to skip team window resolution and split the current window when team is auto-detected from GENIE_TEAM env var (no explicit --team) - session.ts: Register interactive genie session in ~/.genie/workers.json so spawned agents can resolve the team-lead for bidirectional SendMessage communication - genie-orchestration.md: Update rules to allow SendMessage for same-session teammates while keeping genie send for cross-session * fix: replace agent symlinks with real files for npm/bun compatibility Symlinks (council.md → council/AGENTS.md) don't survive npm pack + bun install — bun resolves them at install time and loses the folder structure. Both flat .md files (for CC Agent tool) and folder/AGENTS.md (for genie spawn) now have the same content as real files. * chore(version): bump to 3.260316.6 [skip ci] * fix(update): use bun update -g instead of remove+install * chore(version): bump to 3.260316.7 [skip ci] * chore(version): bump to 3.260316.8 [skip ci] * fix(update): use bun add --force --no-cache to bypass stale cache * fix: single prompt file for team-lead — context in initial message, no extraArgs * fix: team-lead spawn improvements - Pre-hire standard team (engineer, reviewer, qa, fix) on --wish - Remove redundant context file — wish context in initial prompt - Include team name, repo, branch, worktree, members in kickoff message - Use bun add --force --no-cache for updates (bypass stale cache) * fix: remove unused imports * chore(version): bump to 3.260316.9 [skip ci] * fix: inline SOUL + HEARTBEAT into team-lead AGENTS.md — @imports dont work in system prompts * chore(version): bump to 3.260316.10 [skip ci] * fix: team-lead uses genie work directly + wish template QA section * chore(version): bump to 3.260316.11 [skip ci] * fix: set GENIE_TEAM env var on spawn — agents dispatch to correct team * chore(version): bump to 3.260316.12 [skip ci] * fix: kickoff message says genie work spawns automatically, not use genie spawn * fix(update): delete bun global lockfile before install — prevents stale versions * feat: project-scoped agent directory with three-tier resolution Agent directory now defaults to project scope (<repo>/.genie/agents.json) with fallback to global (~/.genie/agent-directory.json) then built-ins. - add/rm/edit default to project scope, accept { global: true } option - resolve() checks project → global → built-in roles → built-in council - ls() returns entries from all scopes with scope label - dir CLI commands accept --global flag - dir ls shows SCOPE column Closes #578 * fix: biome formatting * fix: biome formatting * chore(version): bump to 3.260316.13 [skip ci] * fix(reset): clean up all team dirs on --reset, not just current window (#593) * fix(reset): clean up all team dirs on --reset, not just current window When `genie --reset` was called, handleReset() killed the entire tmux session but only deleted one native team directory (the current windowName). Any other windows in the session left their team configs behind in ~/.claude/teams/. Fix: collect all window names via listWindows() before killing the session, then delete each window's team directory. Closes #545 * fix: use session ID instead of name in tmux calls to prevent injection Gemini review flagged potential command injection when sessionName is passed to tmux.listWindows/killSession. If a session name contains single quotes it could break shell quoting in executeTmux. Fix: use existing.id (system-assigned identifier) instead of sessionName for the tmux calls. Session name still used for the log message (cosmetic only). --------- Co-authored-by: Felipe Rosa <felipe@namastex.ai> * chore(version): bump to 3.260316.14 [skip ci] * chore: trigger @next publish for v3.260316.14 * fix(lint): reduce cognitive complexity in buildClaudeCommand and launchTmuxSpawn (#595) Extract helper functions to bring both functions under the biome complexity limit of 15: - buildClaudeCommand (27→~12): extract appendSystemPromptFlags() - launchTmuxSpawn (22→~8): extract createTmuxPane() and applySpawnLayout() Closes #594 Co-authored-by: Test User <test@test.com> * chore: trigger @next publish for v3.260316.14 * fix(lint): resolve all remaining lint errors and complexity warnings (#596) - Fix JSON formatting in package.json, openclaw.plugin.json, plugin.json - Fix noAssignInExpressions in dispatch.ts (refactor while loop) - Reduce complexity in performUninstall (21→≤15): extract tryRemoveStep() - Reduce complexity in autoSpawn (25→≤15): extract buildSearchNames(), buildSpawnArgs() - Reduce complexity in executeBlockingChain (18→≤15): extract runHandler() - Reduce complexity in syncPlugin (16→≤15): extract updatePluginRegistry() - Reduce complexity in chat action (17→≤15): extract resolveTeamName() Biome now reports zero errors and zero warnings. Co-authored-by: Test User <test@test.com> * chore(tests): remove flaky stress/load tests (#597) Delete scale.test.ts and file-lock-concurrency.test.ts — these are environment-dependent stress tests that cause CI failures due to shared /tmp state and concurrent file lock race conditions. They belong in a separate CI job, not the main test suite. Co-authored-by: Test User <test@test.com> * feat(worktree): move default worktree path out of repo (#601) * feat(worktree): move default worktree path to ~/.genie/worktrees/<project>/ Worktrees currently default to <repo>/.worktrees/ which causes accidental git commits and bloated npm publishes. Change the default to ~/.genie/worktrees/<project-name>/ when no explicit worktreeBase is set. - Make worktreeBase optional in config schema (undefined = new default) - Update getWorktreeBase() to derive project name from basename(repoPath) - Update setup wizard to show new default path * feat(worktree): add auto-prune, fix gitignore, remove dead code - Add pruneStaleWorktrees() to clean up team configs for non-existent worktree paths and run git worktree prune - Call pruneStaleWorktrees() from disbandTeam() after cleanup - Update .gitignore: add .worktrees/, remove dead .genie/worktrees/ - Untrack committed .worktrees/ directory from git - Delete dead worktree-manager.ts and its test (unused legacy code) --------- Co-authored-by: Test User <test@test.com> * chore: remove local state from git tracking and update .gitignore (#598) Remove files that should never have been tracked: - .worktrees/ — Claude Code worktree metadata - .genie/agents.json — local agent directory - .genie/teams/ — local team configs - .genie/brainstorms/ — local brainstorm drafts - .genie/wishes/ — local wish plans These are local runtime state, not part of the published package. Files remain on disk (git rm --cached), only removed from tracking. Co-authored-by: Test User <test@test.com> * fix(agent-dir): resolve agents from main repo when inside a worktree (#603) Worktrees don't have .genie/agents.json (it's gitignored), so agent resolution fails for project-scoped agents. Fix: detect worktree via git rev-parse --git-common-dir and fall back to the main repo's agents.json when the worktree's doesn't contain the requested agent. Closes #600 Co-authored-by: Test User <test@test.com> * fix: session hook respects updateChannel, release skip-ci fix (#604) - smart-install.js: read updateChannel from ~/.genie/config.json, skip CLI reinstall when channel is 'next' - release.yml: use startsWith instead of contains for [skip ci] - remove hardcoded worktreeBase from createDefaultConfig() Co-authored-by: Test User <test@test.com> * fix: auto-publish @next on dev merge, fix rolling PR history sync (#605) - ci.yml: add publish-next job that runs on dev push after quality gate passes — publishes to npm @next automatically - rolling-pr.yml: update PR body to warn against squash merge — squash breaks dev/main history sync causing duplicate diffs on every PR Co-authored-by: Test User <test@test.com> * fix(ci): skip @next publish when version already published --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Test User <test@test.com> Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Automagik Genie 🧞 <genie@namastex.ai> Co-authored-by: clawtom <atotom740@gmail.com>
Summary
appendSystemPromptFlags()frombuildClaudeCommand()— reduces complexity from 27 to ~12createTmuxPane()andapplySpawnLayout()fromlaunchTmuxSpawn()— reduces complexity from 22 to ~8noExcessiveCognitiveComplexityrule (max 15)No behavioral changes — pure refactor moving branching logic into named helpers.
Closes #594
Test plan
bun run typecheck— passesbun run lint— no complexity warnings for the two target functionsbun run build— bundles successfullybun test— 756/758 pass (2 pre-existing flaky stress tests unrelated)