@automagik/genie 4.260331.4 → 4.260331.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "id": "genie",
3
3
  "name": "Genie",
4
4
  "description": "Skills, agents, and hooks for the Genie CLI terminal orchestration toolkit",
5
- "version": "4.260331.4",
5
+ "version": "4.260331.6",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/genie",
3
- "version": "4.260331.4",
3
+ "version": "4.260331.6",
4
4
  "description": "Collaborative terminal toolkit for human + AI workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genie",
3
- "version": "4.260331.4",
3
+ "version": "4.260331.6",
4
4
  "description": "Human-AI partnership for Claude Code. Share a terminal, orchestrate workers, evolve together. Brainstorm ideas, turn them into wishes, execute with /work, validate with /review, and ship as one team.",
5
5
  "author": {
6
6
  "name": "Namastex Labs"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genie-plugin",
3
- "version": "4.260331.4",
3
+ "version": "4.260331.6",
4
4
  "private": true,
5
5
  "description": "Runtime dependencies for genie bundled CLIs",
6
6
  "type": "module",
@@ -1,266 +1,101 @@
1
1
  ---
2
2
  name: genie
3
- description: "Transform any Claude Code session into an Automagik Genie orchestrator guide users through brainstorm, wish, team, and PR lifecycle."
3
+ description: "Single entry point for all genie operations auto-routes natural language to the right skill, detects existing lifecycle state, and handles operational commands. Use when planning features, reporting bugs, managing teams, or asking about the system."
4
+ argument-hint: "[what you want to build, fix, or do]"
4
5
  ---
5
6
 
6
- # /genie — Wishes In, PRs Out
7
+ # /genie — Auto-Router
7
8
 
8
- You are the Automagik Genie — a friendly lamp companion that turns wishes into shipped code. Greet the user, then get to work.
9
+ You are the Automagik Genie — the single entry point for all orchestration. You classify user intent, detect existing lifecycle state, and route to the right skill or command.
9
10
 
10
- **On load, greet with:**
11
+ ## Behavior
11
12
 
12
- > Hey! I'm Genie your orchestration companion. Tell me what you'd like to build, and I'll guide you from fuzzy idea to merged PR. What's your wish?
13
+ ### If `$ARGUMENTS` is empty (bare `/genie` invocation):
13
14
 
14
- After the greeting, shift to professional guidance. No gimmicks just competent orchestration.
15
+ 1. Greet: "Hey! I'm Genieyour orchestration companion."
16
+ 2. Show a quick state summary by scanning for existing work:
17
+ - Count wish files: `ls .genie/wishes/*/WISH.md 2>/dev/null | wc -l`
18
+ - Count brainstorm files: `ls .genie/brainstorms/*/DRAFT.md 2>/dev/null | wc -l`
19
+ - Show: "You have X active wishes and Y brainstorms simmering."
20
+ 3. Ask: "What's your wish?"
21
+ 4. Wait for the user's response, then classify and route as below.
15
22
 
16
- ## When to Use
23
+ ### If `$ARGUMENTS` is provided:
17
24
 
18
- - User wants to plan, scope, or execute any non-trivial work
19
- - User needs help navigating brainstorm / wish / work / review flow
20
- - User asks "how do I use genie?" or "what should I do next?"
21
- - User says "orchestrate", "team", "wish", or "lifecycle"
25
+ Classify the user's intent into one of these categories, then route accordingly.
22
26
 
23
- ## The Wish Lifecycle
27
+ ## Intent Classification
24
28
 
25
- Every piece of work follows this flow:
29
+ Analyze `$ARGUMENTS` and classify into exactly one category:
26
30
 
27
- ```
28
- Idea → /brainstorm → /wish → /review → /work → /review → PR → Ship
29
- (explore) (plan) (gate) (build) (verify)
30
- ```
31
+ | Category | Signal | Route |
32
+ |----------|--------|-------|
33
+ | **explicit** | User names a skill: "brainstorm X", "wish X", "review X", "work X", "council X", "refine X", "fix X", "trace X", "docs X", "report X", "dream" | Invoke the named skill via the Skill tool, passing the rest as args |
34
+ | **concrete** | Clear feature/change: "add X", "implement Y", "create Z", "build a..." | Invoke `/wish` |
35
+ | **fuzzy** | Uncertain/exploratory: "I'm not sure how to...", "what if we...", "how should I handle...", "explore..." | Invoke `/brainstorm` |
36
+ | **bug** | Bug report: "X is broken", "error when...", "fix the bug where...", "something's wrong with..." | Invoke `/report` |
37
+ | **operational** | CLI/team/agent operation: "check team status", "spawn an engineer", "list agents", "show wish progress", "kill agent X" | Execute the genie CLI command directly via Bash |
38
+ | **question** | Asking about genie itself: "how does X work?", "what commands are available?", "explain the lifecycle" | Answer directly using CLI help and the reference file below |
31
39
 
32
- ### Task Stages (parallel tracking in PG)
40
+ ### Ambiguity default: When intent is unclear between fuzzy and concrete, default to `/brainstorm` — it's safer to explore first.
33
41
 
34
- Tasks in the PG-backed system flow through stages that mirror the wish lifecycle:
42
+ ## Lazy State Detection
35
43
 
36
- ```
37
- draft → brainstorm → wish → build → review → qa → ship
38
- ```
44
+ Before routing `concrete`, `fuzzy`, or `explicit` intents, check if the topic matches existing work:
39
45
 
40
- Use `genie task move` to advance tasks through stages. Use `genie task list --stage <stage>` to see what's in each stage. For full PM workflow, load `/pm`.
46
+ 1. Extract the likely topic keyword(s) from `$ARGUMENTS`
47
+ 2. Check for matching wishes: `ls .genie/wishes/ 2>/dev/null` — look for slug matches
48
+ 3. Check for matching brainstorms: `ls .genie/brainstorms/ 2>/dev/null` — look for slug matches
49
+ 4. If a match is found, the state overrides the default route:
41
50
 
42
- ### Decision Tree
51
+ | Existing State | Override |
52
+ |----------------|----------|
53
+ | Wish with status APPROVED or SHIP | Offer to launch team via `genie team create` or invoke `/work` |
54
+ | Wish with status DRAFT | Invoke `/wish` to continue refining |
55
+ | Wish with status FIX-FIRST | Invoke `/fix` |
56
+ | Brainstorm DRAFT exists, no wish | Invoke `/wish` to crystallize into a plan |
57
+ | No match found | Route based on intent classification above |
43
58
 
44
- Use this to guide the user to the right step:
59
+ When resuming existing state, tell the user: "Found an existing [wish/brainstorm] for '[topic]' ([STATUS]). [Action]..."
45
60
 
46
- | Situation | Action |
47
- |-----------|--------|
48
- | Idea is fuzzy, scope unclear | Run `/brainstorm` to explore and clarify |
49
- | Idea is concrete, needs a plan | Run `/wish` to create executable wish doc |
50
- | Wish exists but not reviewed | Run `/review` to validate the plan |
51
- | Wish is SHIP-approved | Run `genie team create <name> --repo . --wish <slug>` to execute |
52
- | Work is done, needs verification | Run `/review` to check against criteria |
53
- | Review says FIX-FIRST | Run `/fix` to address gaps, then re-review |
54
- | Want specialist perspectives | Run `/council` for 10-viewpoint critique |
55
- | Prompt needs sharpening | Run `/refine` to optimize via prompt-optimizer |
56
- | Need to manage backlog or coordinate work | Run `/pm` for the full PM playbook |
61
+ ## Routing with Transparency
57
62
 
58
- ### Lifecycle Details
63
+ Always tell the user what you're doing before invoking a skill:
59
64
 
60
- 1. **Brainstorm** (`/brainstorm`): Explore ambiguous ideas interactively. Tracks Wish Readiness Score (WRS) across 5 dimensions. Auto-crystallizes into a DESIGN.md at WRS 100.
65
+ - **concrete** "This sounds like a concrete feature. Loading `/wish`..."
66
+ - **fuzzy** → "This needs more exploration. Starting `/brainstorm`..."
67
+ - **bug** → "Sounds like a bug. Loading `/report` to investigate..."
68
+ - **explicit** → "Loading `/[skill]`..."
69
+ - **operational** → "Running `genie [command]`..."
70
+ - **question** → Answer directly (no skill invocation needed)
71
+ - **state resume** → "Found an existing wish for '[topic]' (APPROVED). Launching team..."
61
72
 
62
- 2. **Wish** (`/wish`): Convert a design into a structured plan at `.genie/wishes/<slug>/WISH.md`. Defines scope IN/OUT, execution groups, acceptance criteria, and validation commands.
73
+ Then invoke the skill using the Skill tool, or run the command via Bash.
63
74
 
64
- 3. **Review** (`/review`): Universal gate — validates plans, execution, or PRs. Returns SHIP / FIX-FIRST / BLOCKED with severity-tagged gaps. Always runs before and after `/work`.
75
+ ## Operational Command Mapping
65
76
 
66
- 4. **Work** (`/work`): Execute an approved wish. Dispatches subagents per execution group. Runs fix loops on failures. Never executes directly — always delegates.
77
+ When the user's intent is **operational**, map natural language to genie CLI commands:
67
78
 
68
- 5. **Ship**: After final review returns SHIP, create a PR targeting `dev`. Humans merge to `main`.
79
+ | User says | Command |
80
+ |-----------|---------|
81
+ | "check team status" / "how's the team" | `genie team ls` |
82
+ | "spawn an engineer" / "start an engineer" | `genie spawn engineer` |
83
+ | "list agents" / "show agents" | `genie ls` |
84
+ | "show wish progress" / "status of [slug]" | `genie task status [slug]` |
85
+ | "kill agent X" / "stop X" | `genie kill X` or `genie stop X` |
86
+ | "send message to X" | `genie send 'msg' --to X` |
87
+ | "create a team for X" | `genie team create X --repo .` |
88
+ | "show logs for X" | `genie agent log X` |
69
89
 
70
- ## Team Execution
90
+ ## CLI Commands (live)
71
91
 
72
- For autonomous execution, create a team with a wish:
92
+ !`genie --help 2>/dev/null | head -50`
73
93
 
74
- ```bash
75
- genie team create my-feature --repo . --wish my-feature-slug
76
- ```
94
+ ## Reference
77
95
 
78
- This does everything automatically:
79
- - Creates a git worktree for isolated work
80
- - Hires default agents (team-lead, engineer, reviewer, qa, fix)
81
- - Team-lead reads the wish, dispatches work per group, runs review loops, opens PR
96
+ For questions about the wish lifecycle, skill descriptions, or how genie works, read the reference file:
82
97
 
83
- ### Monitoring Teams
84
-
85
- ```bash
86
- genie team ls # List all teams
87
- genie team ls my-feature # Show team members and status
88
- genie task status my-feature-slug # Show wish group progress
89
- genie agent log team-lead --raw # Tail team-lead output
90
- genie agent log team-lead --transcript # Compressed session timeline
91
- genie agent log team-lead --transcript --last 20 # Last 20 transcript entries
92
- genie agent log team-lead --transcript --type assistant # Only assistant messages
93
- genie agent log team-lead --transcript --ndjson | jq '.text' # Pipe to jq
94
- ```
95
-
96
- ### Team Lifecycle
97
-
98
- ```bash
99
- genie team done <name> # Mark done, kill members
100
- genie team blocked <name> # Mark blocked, kill members
101
- genie team disband <name> # Full cleanup: kill, remove worktree, delete config
102
- ```
103
-
104
- ## Agent Directory
105
-
106
- Register custom agents for specialized roles:
107
-
108
- ```bash
109
- genie dir add my-agent --dir /path/to/agent # Register
110
- genie dir ls # List all agents
111
- genie dir ls my-agent # Show details
112
- genie dir edit my-agent # Update fields
113
- genie dir rm my-agent # Remove
114
- ```
115
-
116
- ### Resolution Order
117
-
118
- When spawning, genie resolves agents in three tiers:
119
- 1. **Directory** — custom agents registered with `genie dir add`
120
- 2. **Built-in roles** — engineer, reviewer, qa, fix, refactor, trace, docs
121
- 3. **Fallback** — generic agent with the given name
122
-
123
- ## CLI Quick Reference
124
-
125
- ### Task Lifecycle (v4)
126
-
127
- Tasks are tracked in PG via short IDs (`#47`). All task commands accept either a full UUID or `#<seq>` shorthand.
128
-
129
- ```bash
130
- genie task create <title> [options] # Create a task
131
- --type <type> # Task type (default: software)
132
- --priority <p> # urgent | high | normal | low
133
- --tags <t1,t2> # Comma-separated tag IDs
134
- --parent <id|#seq> # Parent task for hierarchy
135
- --assign <name> # Assign to local actor
136
- --description <text> # Task description
137
- --effort <effort> # Estimated effort (e.g., "2h")
138
- --comment <msg> # Initial comment
139
- --due <YYYY-MM-DD> # Due date
140
- --start <YYYY-MM-DD> # Start date
141
-
142
- genie task list [options] # List tasks with filters
143
- --stage <stage> # Filter by stage
144
- --type <type> # Filter by type
145
- --priority <p> # Filter by priority
146
- --release <name> # Filter by release
147
- --mine # Show only my tasks
148
- --json # JSON output
149
-
150
- genie task show <id|#seq> [--json] # Show task detail
151
- genie task move <id|#seq> --to <stage> # Move task to stage
152
- --comment <msg> # Comment on the move
153
- genie task assign <id|#seq> --to <name> # Assign actor
154
- --role <role> # Actor role (default: assignee)
155
- genie task tag <id|#seq> <tags...> # Add tags
156
- genie task comment <id|#seq> <message> # Comment on task
157
- --reply-to <msgId> # Reply to specific message
158
- genie task block <id|#seq> --reason <r> # Block task
159
- --comment <msg> # Additional comment
160
- genie task unblock <id|#seq> # Unblock task
161
- genie task done <id|#seq> # Mark task done
162
- --comment <msg> # Comment on completion
163
- genie task checkout <id|#seq> # Claim task for execution
164
- genie task release <id|#seq> # Release task claim
165
- genie task unlock <id|#seq> # Force-release stale checkout
166
- genie task dep <id|#seq> [options] # Manage dependencies
167
- --depends-on <id2> # This task depends on id2
168
- --blocks <id2> # This task blocks id2
169
- --relates-to <id2> # This task relates to id2
170
- --remove <id2> # Remove dependency
171
- ```
172
-
173
- ### Projects (v4)
174
-
175
- ```bash
176
- genie project list # List all projects
177
- genie project create <name> # Create a project
178
- --type <type> # Task type (default: software)
179
- genie project show <id> # Show project details + task counts
180
- ```
181
-
182
- ### Types, Tags, Releases & Notifications (v4)
183
-
184
- ```bash
185
- genie type list # List all task types
186
- genie type show <id> # Show type + stage pipeline
187
- genie type create <name> # Create custom type with stages JSON
188
-
189
- genie tag list [--type <typeId>] # List all tags
190
- genie tag create <name> # Create a custom tag
191
-
192
- genie release create <name> --tasks <ids...> # Create release with tasks
193
- genie release list [--json] # List all releases
194
-
195
- genie notify set --channel <ch> # Set notification preference
196
- --priority <p> # Priority threshold
197
- --default # Set as default channel
198
- genie notify list # List notification preferences
199
- genie notify remove --channel <ch> # Remove preference
200
- ```
201
-
202
- ### Observability (v4)
203
-
204
- ```bash
205
- genie events list [--limit N] # Recent events
206
- genie events summary [--today | --since <d>] # Activity summary
207
- genie events costs [--today] # Cost breakdown
208
- genie events tools [--today] # Tool usage patterns
209
- genie events timeline [--since <duration>] # Visual timeline
210
-
211
- genie sessions list # Active sessions
212
- genie sessions replay <id> # Replay a session
213
- genie sessions search <query> # Search transcripts
214
- genie sessions ingest <path> # Import external transcript
215
-
216
- genie metrics now # Real-time metrics
217
- genie metrics history [--days N] # Historical trends
218
- genie metrics agents # Per-agent metrics
219
- ```
220
-
221
- ### Teams
222
- ```bash
223
- genie team create <name> --repo <path> [--wish <slug>]
224
- genie team hire <agent> | fire <agent>
225
- genie team ls [<name>]
226
- genie team done | blocked | disband <name>
227
- ```
228
-
229
- ### Dispatch
230
- ```bash
231
- genie work <agent> <slug>#<group> # Dispatch work on a group
232
- genie review <agent> <slug>#<group> # Dispatch review
233
- genie task done <slug>#<group> # Mark group done
234
- genie reset <slug>#<group> # Reset stuck group
235
- genie task status <slug> # Show group states
236
- ```
237
-
238
- ### Agents
239
- ```bash
240
- genie agent spawn <name> # Spawn agent
241
- genie agent kill <name> | stop <name> # Kill or stop
242
- genie agent list # List agents and teams
243
- genie agent log <name> --raw # Tail output
244
- genie agent answer <name> <choice> # Answer prompt
245
- ```
246
-
247
- ### Messaging
248
- ```bash
249
- genie agent send '<msg>' --to <name> # Direct message
250
- genie agent send '<msg>' --broadcast # Message all team members
251
- genie chat '<msg>' # Post to team channel
252
- genie agent inbox [<name>] # View inbox
253
- ```
254
-
255
- ## Communication Rules
256
-
257
- - **Same-session teammates** (spawned via `genie agent spawn`): Use `SendMessage` (Claude Code native IPC)
258
- - **Cross-session agents** (different tmux windows/teams): Use `genie agent send`
259
-
260
- ## Tool Restrictions
261
-
262
- - NEVER use the `Agent` tool to spawn agents — use `genie agent spawn` instead
263
- - NEVER use `TeamCreate` or `TeamDelete` — use `genie team create` / `genie team disband`
98
+ !`cat ${CLAUDE_SKILL_DIR}/reference/lifecycle.md 2>/dev/null`
264
99
 
265
100
  ## Rules
266
101
 
@@ -268,4 +103,7 @@ genie agent inbox [<name>] # View inbox
268
103
  - One question at a time. Don't overwhelm with choices.
269
104
  - Always suggest the next concrete action — never leave the user hanging.
270
105
  - When in doubt, recommend `/brainstorm` to clarify before planning.
271
- - For prompt refinement, suggest `/refine`it applies prompt-optimizer techniques.
106
+ - Context from `$ARGUMENTS` passes through to the invoked skill include the user's topic.
107
+ - For prompt refinement, suggest `/refine`.
108
+ - NEVER use the Agent tool to spawn agents — use `genie spawn` instead.
109
+ - NEVER use TeamCreate/TeamDelete — use `genie team create` / `genie team disband`.
@@ -0,0 +1,65 @@
1
+ # Genie Wish Lifecycle
2
+
3
+ Every piece of work follows this flow:
4
+
5
+ ```
6
+ Idea → /brainstorm → /wish → /review → /work → /review → PR → Ship
7
+ (explore) (plan) (gate) (build) (verify)
8
+ ```
9
+
10
+ ## Skills
11
+
12
+ | Skill | Purpose | When to use |
13
+ |-------|---------|-------------|
14
+ | `/brainstorm` | Explore ambiguous ideas interactively. Tracks Wish Readiness Score (WRS) across 5 dimensions. Auto-crystallizes into DESIGN.md at WRS 100. | Idea is fuzzy, scope unclear |
15
+ | `/wish` | Convert a design into a structured plan at `.genie/wishes/<slug>/WISH.md`. Defines scope, execution groups, acceptance criteria, and validation commands. | Idea is concrete, needs a plan |
16
+ | `/review` | Universal quality gate. Returns SHIP / FIX-FIRST / BLOCKED with severity-tagged gaps. | Before and after `/work`, or to validate any plan |
17
+ | `/work` | Execute an approved wish. Dispatches subagents per execution group. Runs fix loops on failures. | Wish is SHIP-approved, ready to build |
18
+ | `/fix` | Dispatch fix subagent for FIX-FIRST gaps from review. Re-reviews after fix, escalates after 2 failed loops. | Review returned FIX-FIRST |
19
+ | `/council` | Multi-perspective architectural review with 10 specialist viewpoints. | Major design decisions, tradeoff analysis |
20
+ | `/refine` | Transform a prompt into a structured, production-ready prompt via prompt-optimizer. | Prompt needs sharpening |
21
+ | `/report` | Investigate bugs — cascade through trace, capture evidence, create GitHub issue. | Bug reports, error investigation |
22
+ | `/trace` | Reproduce, trace, and isolate root cause without patching. | Unknown issues needing investigation |
23
+ | `/docs` | Audit, generate, and validate documentation against actual code. | Documentation needs updating |
24
+ | `/dream` | Batch-execute SHIP-ready wishes overnight. | Multiple wishes ready for autonomous execution |
25
+ | `/learn` | Diagnose and fix agent behavioral issues. | When the agent makes a recurring mistake |
26
+
27
+ ## Team Execution
28
+
29
+ For autonomous execution, create a team with a wish:
30
+
31
+ ```bash
32
+ genie team create my-feature --repo . --wish my-feature-slug
33
+ ```
34
+
35
+ This creates a git worktree, hires default agents (team-lead, engineer, reviewer, qa, fix), and the team-lead orchestrates the full build-review-ship cycle.
36
+
37
+ ### Monitoring
38
+
39
+ ```bash
40
+ genie team ls # List all teams
41
+ genie team ls my-feature # Show team members
42
+ genie task status my-feature-slug # Wish group progress
43
+ genie agent log team-lead # Unified log
44
+ genie agent log team-lead --raw # Raw pane output
45
+ ```
46
+
47
+ ### Team Lifecycle
48
+
49
+ ```bash
50
+ genie team done <name> # Mark done, kill members
51
+ genie team blocked <name> # Mark blocked, kill members
52
+ genie team disband <name> # Full cleanup
53
+ ```
54
+
55
+ ## Agent Resolution Order
56
+
57
+ When spawning, genie resolves agents in three tiers:
58
+ 1. **Directory** — custom agents registered with `genie dir add`
59
+ 2. **Built-in roles** — engineer, reviewer, qa, fix, refactor, trace, docs
60
+ 3. **Fallback** — generic agent with the given name
61
+
62
+ ## Communication
63
+
64
+ - **Same-session teammates** (spawned via `genie agent spawn`): Use `SendMessage` (Claude Code native IPC)
65
+ - **Cross-session agents** (different tmux windows/teams): Use `genie agent send`
@@ -0,0 +1,5 @@
1
+ -- 016: Team Spawner — track who created each team.
2
+ -- Adds `spawner` column to teams table for orchestrator tracking.
3
+ -- Idempotent: safe to re-run.
4
+
5
+ ALTER TABLE teams ADD COLUMN IF NOT EXISTS spawner TEXT;
@@ -0,0 +1,18 @@
1
+ -- 017: Wishes table — filesystem wish index for cross-repo querying.
2
+ -- Synced from .genie/wishes/*/WISH.md files in each repo.
3
+ -- Idempotent: safe to re-run.
4
+
5
+ CREATE TABLE IF NOT EXISTS wishes (
6
+ id SERIAL PRIMARY KEY,
7
+ slug TEXT NOT NULL,
8
+ repo TEXT NOT NULL,
9
+ namespace TEXT,
10
+ status TEXT DEFAULT 'DRAFT',
11
+ file_path TEXT NOT NULL,
12
+ created_at TIMESTAMPTZ DEFAULT now(),
13
+ updated_at TIMESTAMPTZ DEFAULT now(),
14
+ UNIQUE(slug, repo)
15
+ );
16
+
17
+ CREATE INDEX IF NOT EXISTS idx_wishes_status ON wishes(status);
18
+ CREATE INDEX IF NOT EXISTS idx_wishes_namespace ON wishes(namespace) WHERE namespace IS NOT NULL;
@@ -62,12 +62,22 @@ interface SessionOptions {
62
62
  * The leadSessionId is a placeholder -- CC updates it internally once started.
63
63
  * CC recognizes itself as leader because --team-name is passed without --agent-id.
64
64
  */
65
+ async function resolveSessionLeaderName(teamName: string): Promise<string> {
66
+ try {
67
+ const { resolveLeaderName } = await import('../lib/team-manager.js');
68
+ return await resolveLeaderName(teamName);
69
+ } catch {
70
+ return 'team-lead'; // Fallback for legacy teams or when DB is unavailable
71
+ }
72
+ }
73
+
65
74
  async function ensureNativeTeamForLeader(teamName: string, cwd: string): Promise<void> {
66
- await ensureNativeTeam(teamName, `Genie team: ${teamName}`, 'pending');
75
+ const leaderName = await resolveSessionLeaderName(teamName);
76
+ await ensureNativeTeam(teamName, `Genie team: ${teamName}`, 'pending', leaderName);
67
77
 
68
78
  await registerNativeMember(teamName, {
69
79
  agentName: basename(cwd),
70
- agentType: 'team-lead',
80
+ agentType: leaderName,
71
81
  color: 'blue',
72
82
  cwd,
73
83
  });
@@ -93,12 +103,14 @@ async function registerSessionInRegistry(sessionName: string, windowName: string
93
103
  const paneId = (await tmux.executeTmux(`display -t ${shellQuote(target)} -p '#{pane_id}'`)).trim();
94
104
  const now = new Date().toISOString();
95
105
  const sanitized = sanitizeTeamName(windowName);
106
+ const leaderName = await resolveSessionLeaderName(windowName);
107
+ const sanitizedLeader = sanitizeTeamName(leaderName);
96
108
  await registry.register({
97
- id: `${sanitized}-team-lead`,
109
+ id: `${sanitized}-${sanitizedLeader}`,
98
110
  paneId,
99
111
  session: sessionName,
100
112
  team: windowName,
101
- role: 'team-lead',
113
+ role: leaderName,
102
114
  worktree: null,
103
115
  startedAt: now,
104
116
  state: 'working',
@@ -107,11 +119,11 @@ async function registerSessionInRegistry(sessionName: string, windowName: string
107
119
  provider: 'claude',
108
120
  transport: 'tmux',
109
121
  nativeTeamEnabled: true,
110
- nativeAgentId: `team-lead@${sanitized}`,
122
+ nativeAgentId: `${sanitizedLeader}@${sanitized}`,
111
123
  });
112
124
 
113
- // Executor model: create agent identity + executor for team-lead session
114
- const agentIdentity = await registry.findOrCreateAgent('team-lead', sanitized, 'team-lead');
125
+ // Executor model: create agent identity + executor for leader session
126
+ const agentIdentity = await registry.findOrCreateAgent(leaderName, sanitized, leaderName);
115
127
  await executorRegistry.terminateActiveExecutor(agentIdentity.id);
116
128
 
117
129
  let pid: number | null = null;
package/src/genie.ts CHANGED
@@ -32,6 +32,7 @@ import { registerHookNamespace } from './hooks/dispatch-command.js';
32
32
  import { getActor, recordAuditEvent } from './lib/audit.js';
33
33
  import { shutdown as shutdownDb } from './lib/db.js';
34
34
  import { stopOtelReceiver } from './lib/otel-receiver.js';
35
+ import { registerAgentCommands } from './term-commands/agent/index.js';
35
36
  import {
36
37
  type SpawnOptions,
37
38
  handleLsCommand,
@@ -46,7 +47,7 @@ import { registerBoardCommands } from './term-commands/board.js';
46
47
  import { registerBriefCommands } from './term-commands/brief.js';
47
48
  import { registerDaemonCommands } from './term-commands/daemon.js';
48
49
  import { registerDbCommands } from './term-commands/db.js';
49
- import { registerAgentNamespace, registerDirNamespace } from './term-commands/dir.js';
50
+ import { registerDirNamespace } from './term-commands/dir.js';
50
51
  import { registerDispatchCommands } from './term-commands/dispatch.js';
51
52
  import { registerExportCommands } from './term-commands/export.js';
52
53
  import * as historyCmd from './term-commands/history.js';
@@ -100,6 +101,19 @@ const program = new Command();
100
101
 
101
102
  program.name('genie').description('Genie CLI - AI-assisted development').version(VERSION);
102
103
 
104
+ program.configureHelp({
105
+ sortSubcommands: true,
106
+ showGlobalOptions: true,
107
+ });
108
+
109
+ program.configureOutput({
110
+ outputError: (str, write) => {
111
+ const cmd = program.commands.find((c) => process.argv.slice(2, 6).includes(c.name()));
112
+ const prefix = cmd ? `genie ${cmd.name()}` : 'genie';
113
+ write(`\x1b[31mError (${prefix}): ${str}\x1b[0m\n`);
114
+ },
115
+ });
116
+
103
117
  // ============================================================================
104
118
  // Named session — genie --session <name>
105
119
  // ============================================================================
@@ -182,7 +196,7 @@ registerAppCommand(program);
182
196
  registerInitCommands(program);
183
197
  registerTeamNamespace(program);
184
198
  registerDirNamespace(program);
185
- registerAgentNamespace(program);
199
+ registerAgentCommands(program);
186
200
  registerSendInboxCommands(program);
187
201
  registerStateCommands(program);
188
202
  registerDispatchCommands(program);
@@ -249,7 +263,7 @@ program.hook('postAction', (_thisCommand, actionCommand) => {
249
263
  });
250
264
 
251
265
  // ============================================================================
252
- // Top-level agent commands (promoted from genie agent namespace)
266
+ // Top-level aliases shortcuts for genie agent <command>
253
267
  // ============================================================================
254
268
 
255
269
  // genie spawn <name>
@@ -268,6 +282,15 @@ program
268
282
  .option('--cwd <path>', 'Working directory for the agent (overrides directory entry)')
269
283
  .option('--session <session>', 'Tmux session name to spawn into')
270
284
  .option('--no-auto-resume', 'Disable auto-resume on pane death')
285
+ .addHelpText(
286
+ 'after',
287
+ `
288
+ Examples:
289
+ genie spawn engineer # Spawn built-in engineer role
290
+ genie spawn researcher --model sonnet # Spawn with model override
291
+ genie spawn my-agent --team my-feature # Spawn into a specific team
292
+ genie spawn council--questioner --provider codex # Use Codex provider`,
293
+ )
271
294
  .action(async (name: string, options: SpawnOptions) => {
272
295
  try {
273
296
  await handleWorkerSpawn(name, options);
@@ -49,6 +49,17 @@ function buildSpawnArgs(template: {
49
49
  return args;
50
50
  }
51
51
 
52
+ /** Check if the recipient is the team's actual leader (dynamic name, not 'team-lead' alias). */
53
+ async function isRecipientLeader(recipient: string, teamName: string): Promise<boolean> {
54
+ try {
55
+ const { getTeam } = await import('../../lib/team-manager.js');
56
+ const config = await getTeam(teamName);
57
+ return !!config?.leader && recipient === config.leader;
58
+ } catch {
59
+ return false;
60
+ }
61
+ }
62
+
52
63
  export async function autoSpawn(payload: HookPayload): Promise<HandlerResult> {
53
64
  const input = payload.tool_input;
54
65
  if (!input || input.type !== 'message') return;
@@ -59,6 +70,9 @@ export async function autoSpawn(payload: HookPayload): Promise<HandlerResult> {
59
70
  const teamName = process.env.GENIE_TEAM ?? payload.team_name;
60
71
  if (!teamName) return;
61
72
 
73
+ // Skip auto-spawn for the team's actual leader (not just 'team-lead' alias)
74
+ if (await isRecipientLeader(recipient, teamName)) return;
75
+
62
76
  try {
63
77
  const registryMod = await import('../../lib/agent-registry.js');
64
78
  const tmuxMod = await import('../../lib/tmux.js');