@automagik/genie 4.260324.12 → 4.260324.13
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/genie.js +5 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/genie/.claude-plugin/plugin.json +1 -1
- package/plugins/genie/package.json +1 -1
- package/src/term-commands/dispatch.ts +28 -28
- package/src/term-commands/team.ts +9 -5
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"plugins": [
|
|
11
11
|
{
|
|
12
12
|
"name": "genie",
|
|
13
|
-
"version": "4.260324.
|
|
13
|
+
"version": "4.260324.13",
|
|
14
14
|
"source": "./plugins/genie",
|
|
15
15
|
"description": "Human-AI partnership for Claude Code. Share a terminal, orchestrate workers, evolve together. Brainstorm ideas, wish them into plans, make with parallel agents, ship as one team. A coding genie that grows with your project."
|
|
16
16
|
}
|
package/dist/genie.js
CHANGED
|
@@ -1029,18 +1029,18 @@ Wish: ${state2.wish}`),console.log("\u2500".repeat(60));let entries=Object.entri
|
|
|
1029
1029
|
`);if(combined.length>50000)return`${combined.slice(0,50000)}
|
|
1030
1030
|
|
|
1031
1031
|
... (diff truncated at 50KB)`;return combined}catch{return""}}function parseWishGroups(content){let groups=[],groupPattern=/^### Group ([A-Za-z0-9]+):/gim,match=groupPattern.exec(content);while(match!==null){let name=match[1],start=match.index,rest=content.slice(start+match[0].length),nextGroupIdx=rest.search(/^### Group [A-Za-z0-9]+:/m),depsMatch=(nextGroupIdx!==-1?rest.slice(0,nextGroupIdx):rest).match(/\*\*depends-on:\*\*\s*(.+)/i),dependsOn=[];if(depsMatch){let depsStr=depsMatch[1].trim();if(depsStr.replace(/\s*\([^)]*\)/g,"").trim().toLowerCase()!=="none")dependsOn=depsStr.split(",").map((d)=>d.trim().replace(/^group\s*/i,"").replace(/\s*\(.*\)\s*$/,"").trim()).filter(Boolean)}groups.push({name,dependsOn}),match=groupPattern.exec(content)}return groups}function parseExecutionStrategy(content){let strategyMatch=content.match(/^## Execution Strategy\s*$/m);if(!strategyMatch||strategyMatch.index===void 0)return buildFallbackWaves(content);let strategyStart=strategyMatch.index+strategyMatch[0].length,nextSectionMatch=content.slice(strategyStart).match(/^## /m),strategyEnd=nextSectionMatch?.index!==void 0?strategyStart+nextSectionMatch.index:content.length,strategyContent=content.slice(strategyStart,strategyEnd),waves=[],wavePattern=/^### (Wave \d+[^\n]*)/gm,waveMatch=wavePattern.exec(strategyContent);while(waveMatch!==null){let waveName=waveMatch[1].trim(),waveStart=waveMatch.index+waveMatch[0].length,nextWaveIdx=strategyContent.slice(waveStart).search(/^### /m),waveEnd=nextWaveIdx!==-1?waveStart+nextWaveIdx:strategyContent.length,waveContent=strategyContent.slice(waveStart,waveEnd),waveGroups=[],tableRowPattern=/^\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|\s*[^|]*\s*\|$/gm,rowMatch=tableRowPattern.exec(waveContent);while(rowMatch!==null){let groupVal=rowMatch[1].trim(),agentVal=rowMatch[2].trim();if(groupVal!=="Group"&&!groupVal.startsWith("-"))waveGroups.push({group:groupVal,agent:agentVal});rowMatch=tableRowPattern.exec(waveContent)}if(waveGroups.length>0)waves.push({name:waveName,groups:waveGroups});waveMatch=wavePattern.exec(strategyContent)}if(waves.length===0)return buildFallbackWaves(content);return waves}function buildFallbackWaves(content){let groups=parseWishGroups(content);if(groups.length===0)return[];return[{name:"Wave 1 (sequential fallback)",groups:groups.map((g)=>({group:g.name,agent:"engineer"}))}]}function detectWorkMode(ref,agent){if(!agent){if(ref.includes("#"))throw Error("Manual dispatch requires an agent: genie work <slug>#<group> <agent>");return{mode:"auto",slug:ref}}if(ref.includes("#"))return{mode:"manual",ref,agent};if(agent.includes("#"))return{mode:"manual",ref:agent,agent:ref};throw Error('Invalid: ref must contain "#" \u2014 use "genie work <slug>" or "genie work <agent> <slug>#<group>"')}async function autoOrchestrateCommand(slug){let wishPath=join24(process.cwd(),".genie","wishes",slug,"WISH.md");if(!existsSync19(wishPath))console.error(`\u274C Wish not found: ${wishPath}`),console.error(` Create it first: genie wish <agent> ${slug}`),process.exit(1);let content=await readFile9(wishPath,"utf-8"),groups=parseWishGroups(content),waves=parseExecutionStrategy(content);if(waves.length===0)console.error("\u274C No execution groups found in wish"),process.exit(1);let state2=await getOrCreateState(slug,groups),nextWave=waves.find((wave)=>wave.groups.some((g)=>{let gs=state2?.groups[g.group];return!gs||gs.status==="ready"}));if(!nextWave){console.log(`\u2705 All waves already dispatched for wish "${slug}"`);return}console.log(`\uD83D\uDE80 Dispatching ${nextWave.name} for wish "${slug}" \u2014 ${nextWave.groups.length} group(s)`),await Promise.all(nextWave.groups.map(({group,agent})=>{let ref=`${slug}#${group}`;return workDispatchCommand(agent,ref)}));let groupList=nextWave.groups.map((g)=>g.group).join(", ");console.log(`
|
|
1032
|
-
\u2705 Agents dispatched for ${nextWave.name} (groups: ${groupList})`),console.log(` Monitor: genie status ${slug}`),console.log(" Logs: genie read <agent>")}async function brainstormCommand(agentName,slug){let draftPath=join24(process.cwd(),".genie","brainstorms",slug,"DRAFT.md");if(!existsSync19(draftPath))console.error(`\u274C Draft not found: ${draftPath}`),console.error(` Create it first: mkdir -p .genie/brainstorms/${slug} && touch .genie/brainstorms/${slug}/DRAFT.md`),process.exit(1);let content=await readFile9(draftPath,"utf-8"),context=buildContextPrompt({filePath:draftPath,sectionContent:content,command:"brainstorm",skill:"brainstorm"}),contextFile=await writeContextFile(context);console.log(`\uD83D\uDCDD Dispatching brainstorm to ${agentName} for "${slug}"`),console.log(` Draft: ${draftPath}`),await handleWorkerSpawn(agentName,{provider:"claude",team:process.env.GENIE_TEAM??"genie",extraArgs:["--append-system-prompt-file",contextFile]});let repoPath=process.cwd()
|
|
1032
|
+
\u2705 Agents dispatched for ${nextWave.name} (groups: ${groupList})`),console.log(` Monitor: genie status ${slug}`),console.log(" Logs: genie read <agent>")}async function brainstormCommand(agentName,slug){let draftPath=join24(process.cwd(),".genie","brainstorms",slug,"DRAFT.md");if(!existsSync19(draftPath))console.error(`\u274C Draft not found: ${draftPath}`),console.error(` Create it first: mkdir -p .genie/brainstorms/${slug} && touch .genie/brainstorms/${slug}/DRAFT.md`),process.exit(1);let content=await readFile9(draftPath,"utf-8"),context=buildContextPrompt({filePath:draftPath,sectionContent:content,command:"brainstorm",skill:"brainstorm"}),contextFile=await writeContextFile(context);console.log(`\uD83D\uDCDD Dispatching brainstorm to ${agentName} for "${slug}"`),console.log(` Draft: ${draftPath}`);let brainstormPrompt=`Brainstorm "${slug}". Your context is in the system prompt. Explore the idea, ask clarifying questions, and build toward a design.`;await handleWorkerSpawn(agentName,{provider:"claude",team:process.env.GENIE_TEAM??"genie",extraArgs:["--append-system-prompt-file",contextFile],initialPrompt:brainstormPrompt});let repoPath=process.cwd(),result=await sendMessage(repoPath,"cli",agentName,brainstormPrompt);if(!result.delivered)console.warn(`\u26A0 Backup delivery to ${agentName} failed: ${result.reason??"unknown"}`)}async function wishCommand(agentName,slug){let designPath=join24(process.cwd(),".genie","brainstorms",slug,"DESIGN.md");if(!existsSync19(designPath))console.error(`\u274C Design not found: ${designPath}`),console.error(` Run brainstorm first: genie brainstorm <agent> ${slug}`),process.exit(1);let content=await readFile9(designPath,"utf-8"),context=buildContextPrompt({filePath:designPath,sectionContent:content,command:"wish",skill:"wish"}),contextFile=await writeContextFile(context);console.log(`\uD83D\uDCDD Dispatching wish to ${agentName} for "${slug}"`),console.log(` Design: ${designPath}`);let wishPrompt=`Create a wish from the design for "${slug}". Your context is in the system prompt. Write the WISH.md with execution groups, acceptance criteria, and validation commands.`;await handleWorkerSpawn(agentName,{provider:"claude",team:process.env.GENIE_TEAM??"genie",extraArgs:["--append-system-prompt-file",contextFile],initialPrompt:wishPrompt});let repoPath=process.cwd(),result=await sendMessage(repoPath,"cli",agentName,wishPrompt);if(!result.delivered)console.warn(`\u26A0 Backup delivery to ${agentName} failed: ${result.reason??"unknown"}`)}async function workDispatchCommand(agentName,ref){let{slug,group}=parseRef(ref),wishPath=join24(process.cwd(),".genie","wishes",slug,"WISH.md");if(!existsSync19(wishPath))console.error(`\u274C Wish not found: ${wishPath}`),console.error(` Create it first: genie wish <agent> ${slug}`),process.exit(1);let content=await readFile9(wishPath,"utf-8"),groupSection=extractGroup(content,group);if(!groupSection){console.error(`\u274C Group "${group}" not found in ${wishPath}`),console.error(" Available groups:");let groups2=content.match(/^### Group [A-Za-z0-9]+:.*$/gm);if(groups2)for(let g of groups2)console.error(` ${g}`);process.exit(1)}let groups=parseWishGroups(content);await getOrCreateState(slug,groups);try{await startGroup(slug,group,agentName),console.log(`\u2705 Group "${group}" set to in_progress (assigned to ${agentName})`)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`\u274C ${message}`),process.exit(1)}let wishContext=extractWishContext(content),context=buildContextPrompt({filePath:wishPath,sectionContent:groupSection,wishContext,command:`work ${ref}`,skill:"work"}),contextFile=await writeContextFile(context);console.log(`\uD83D\uDD27 Dispatching work to ${agentName} for "${ref}"`),console.log(` Wish: ${wishPath}`),console.log(` Group: ${group}`);let effectiveRole=`${agentName}-${group}`,workPrompt=`Execute Group ${group} of wish "${slug}". Your full context is in the system prompt. Read the wish at ${wishPath} if needed. Implement all deliverables, run validation, and report completion.
|
|
1033
1033
|
|
|
1034
1034
|
When done:
|
|
1035
1035
|
1. Run: genie done ${slug}#${group}
|
|
1036
|
-
2. Run: genie send 'Group ${group} complete. <summary>' --to team-lead`)}async function reviewCommand(agentName,ref){let{slug,group}=parseRef(ref),wishPath=join24(process.cwd(),".genie","wishes",slug,"WISH.md");if(!existsSync19(wishPath))console.error(`\u274C Wish not found: ${wishPath}`),process.exit(1);let content=await readFile9(wishPath,"utf-8"),groupSection=extractGroup(content,group);if(!groupSection)console.error(`\u274C Group "${group}" not found in ${wishPath}`),process.exit(1);let diff=getGitDiff(),wishContext=extractWishContext(content),reviewContent=[groupSection,"","## Git Diff (changes to review)","",diff?`\`\`\`diff
|
|
1036
|
+
2. Run: genie send 'Group ${group} complete. <summary>' --to team-lead`;await handleWorkerSpawn(agentName,{provider:"claude",team:process.env.GENIE_TEAM??"genie",role:effectiveRole,extraArgs:["--append-system-prompt-file",contextFile],initialPrompt:workPrompt});let repoPath=process.cwd(),result=await sendMessage(repoPath,"cli",effectiveRole,workPrompt);if(!result.delivered)console.warn(`\u26A0 Backup delivery to ${effectiveRole} failed: ${result.reason??"unknown"}`)}async function reviewCommand(agentName,ref){let{slug,group}=parseRef(ref),wishPath=join24(process.cwd(),".genie","wishes",slug,"WISH.md");if(!existsSync19(wishPath))console.error(`\u274C Wish not found: ${wishPath}`),process.exit(1);let content=await readFile9(wishPath,"utf-8"),groupSection=extractGroup(content,group);if(!groupSection)console.error(`\u274C Group "${group}" not found in ${wishPath}`),process.exit(1);let diff=getGitDiff(),wishContext=extractWishContext(content),reviewContent=[groupSection,"","## Git Diff (changes to review)","",diff?`\`\`\`diff
|
|
1037
1037
|
${diff}
|
|
1038
1038
|
\`\`\``:"(no uncommitted changes found \u2014 review committed changes)"].join(`
|
|
1039
1039
|
`),context=buildContextPrompt({filePath:wishPath,sectionContent:reviewContent,wishContext,command:`review ${ref}`,skill:"review"}),contextFile=await writeContextFile(context);if(console.log(`\uD83D\uDD0D Dispatching review to ${agentName} for "${ref}"`),console.log(` Wish: ${wishPath}`),console.log(` Group: ${group}`),diff)console.log(` Diff: ${diff.split(`
|
|
1040
|
-
`).length} lines`);
|
|
1040
|
+
`).length} lines`);let reviewPrompt=`Review "${ref}". Your context and diff are in the system prompt. Evaluate against acceptance criteria and return SHIP, FIX-FIRST, or BLOCKED with severity-tagged findings.
|
|
1041
1041
|
|
|
1042
1042
|
When done, report your verdict:
|
|
1043
|
-
Run: genie send '<SHIP|FIX-FIRST|BLOCKED> \u2014 <summary>' --to team-lead`)}function registerDispatchCommands(program2){program2.command("brainstorm <agent> <slug>").description("Spawn agent with brainstorm DRAFT.md context").action(async(agent,slug)=>{await brainstormCommand(agent,slug)}),program2.command("wish <agent> <slug>").description("Spawn agent with wish DESIGN.md context").action(async(agent,slug)=>{await wishCommand(agent,slug)}),program2.command("work <ref> [agent]").description("Auto-orchestrate a wish, or dispatch work on a specific group").action(async(ref,agent)=>{try{let work=detectWorkMode(ref,agent);if(work.mode==="auto")await autoOrchestrateCommand(work.slug);else await workDispatchCommand(work.agent,work.ref)}catch(error2){console.error(`\u274C ${error2 instanceof Error?error2.message:error2}`),process.exit(1)}}),program2.command("review <agent> <ref>").description("Spawn agent with review scope for a wish group (format: <slug>#<group>)").action(async(agent,ref)=>{await reviewCommand(agent,ref)})}init_agent_registry();function formatTime(timestamp2){try{return new Date(timestamp2).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}catch{return"??:??"}}function truncate(str2,maxLen){if(str2.length<=maxLen)return str2;return`${str2.slice(0,maxLen-3)}...`}function formatPath(path3){let shortened=path3.replace(/^\/home\/\w+\/workspace\//,"~/").replace(/^\/home\/\w+\//,"~/");return truncate(shortened,50)}function flushPendingReads(ctx){if(ctx.pendingReads.length===0)return;ctx.events.push({timestamp:ctx.lastReadTime,type:"read",summary:ctx.pendingReads.length===1?`Read: ${formatPath(ctx.pendingReads[0])}`:`Read ${ctx.pendingReads.length} files`,details:ctx.pendingReads.length>1?ctx.pendingReads.map(formatPath):void 0}),ctx.pendingReads.length=0}function flushPendingEdits(ctx){if(ctx.pendingEdits.length===0)return;ctx.events.push({timestamp:ctx.lastEditTime,type:"edit",summary:ctx.pendingEdits.length===1?`Edit: ${formatPath(ctx.pendingEdits[0])}`:`Edit ${ctx.pendingEdits.length} files`,details:ctx.pendingEdits.length>1?ctx.pendingEdits.map(formatPath):void 0}),ctx.pendingEdits.length=0}function flushAll(ctx){flushPendingReads(ctx),flushPendingEdits(ctx)}function processToolCallEntry(entry,ctx){if(!entry.toolCall)return;let{name,input}=entry.toolCall,inputRecord=input,normalizedName=name==="shell"||name==="exec_command"?"Bash":name;switch(normalizedName){case"Read":if(ctx.lastReadTime=entry.timestamp,inputRecord.file_path)ctx.pendingReads.push(String(inputRecord.file_path));break;case"Edit":if(flushPendingReads(ctx),ctx.lastEditTime=entry.timestamp,inputRecord.file_path)ctx.pendingEdits.push(String(inputRecord.file_path));break;case"Write":flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"write",summary:`Write: ${formatPath(String(inputRecord.file_path||"unknown"))}`});break;case"Bash":{flushAll(ctx);let cmd=String(inputRecord.command||"").replace(/\n/g," ");ctx.events.push({timestamp:entry.timestamp,type:"bash",summary:`Bash: ${truncate(cmd,60)}`});break}case"AskUserQuestion":{flushAll(ctx);let questions=inputRecord.questions;ctx.events.push({timestamp:entry.timestamp,type:"question",summary:`Question: ${truncate(questions?.[0]?.question||"question",60)}`});break}default:flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"bash",summary:`${normalizedName}: ${truncate(entry.text.replace(/\n/g," "),60)}`})}}function processTranscriptEntry(entry,ctx){if(entry.role==="user"){flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"prompt",summary:truncate(entry.text.replace(/\n/g," "),80)});return}if(entry.role==="tool_call"){processToolCallEntry(entry,ctx);return}if(entry.role==="assistant"&&entry.text.length>100)flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"response",summary:truncate(entry.text.replace(/\n/g," "),80)})}function extractEvents(entries){let ctx={events:[],pendingReads:[],pendingEdits:[],lastReadTime:"",lastEditTime:""};for(let entry of entries)processTranscriptEntry(entry,ctx);return flushAll(ctx),ctx.events}function detectStatus(entries){if(entries.length===0)return"unknown";let lastEntries=entries.slice(-10);for(let entry of lastEntries.reverse())if(entry.role==="tool_call"&&entry.toolCall?.name==="AskUserQuestion")return"question";let last=entries[entries.length-1];if(last.role==="user")return"working";if(last.role==="assistant")return"idle";return"unknown"}function formatEventsForDisplay(events,stats){let lines=[];lines.push(""),lines.push(`Session: ${stats.workerId} [${stats.provider}]${stats.branch?` (${stats.branch})`:""} | ${stats.duration} | ${stats.totalEntries} entries \u2192 ${stats.compressedLines} lines`),lines.push("");for(let event of events){let time=formatTime(event.timestamp),icon=getEventIcon(event.type);if(lines.push(`[${time}] ${icon} ${event.summary}`),event.details&&event.details.length>0){for(let detail of event.details.slice(0,5))lines.push(` ${detail}`);if(event.details.length>5)lines.push(` ... and ${event.details.length-5} more`)}if(event.result)lines.push(` \u2192 ${event.result}`)}return lines.push(""),lines.push(`Status: ${stats.status.toUpperCase()} | ${stats.exchanges} exchanges | ${stats.toolCalls} tool calls | ${stats.compressionRatio.toFixed(0)}x compression`),lines.push(""),lines.join(`
|
|
1043
|
+
Run: genie send '<SHIP|FIX-FIRST|BLOCKED> \u2014 <summary>' --to team-lead`;await handleWorkerSpawn(agentName,{provider:"claude",team:process.env.GENIE_TEAM??"genie",extraArgs:["--append-system-prompt-file",contextFile],initialPrompt:reviewPrompt});let repoPath=process.cwd(),result=await sendMessage(repoPath,"cli",agentName,reviewPrompt);if(!result.delivered)console.warn(`\u26A0 Backup delivery to ${agentName} failed: ${result.reason??"unknown"}`)}function registerDispatchCommands(program2){program2.command("brainstorm <agent> <slug>").description("Spawn agent with brainstorm DRAFT.md context").action(async(agent,slug)=>{await brainstormCommand(agent,slug)}),program2.command("wish <agent> <slug>").description("Spawn agent with wish DESIGN.md context").action(async(agent,slug)=>{await wishCommand(agent,slug)}),program2.command("work <ref> [agent]").description("Auto-orchestrate a wish, or dispatch work on a specific group").action(async(ref,agent)=>{try{let work=detectWorkMode(ref,agent);if(work.mode==="auto")await autoOrchestrateCommand(work.slug);else await workDispatchCommand(work.agent,work.ref)}catch(error2){console.error(`\u274C ${error2 instanceof Error?error2.message:error2}`),process.exit(1)}}),program2.command("review <agent> <ref>").description("Spawn agent with review scope for a wish group (format: <slug>#<group>)").action(async(agent,ref)=>{await reviewCommand(agent,ref)})}init_agent_registry();function formatTime(timestamp2){try{return new Date(timestamp2).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}catch{return"??:??"}}function truncate(str2,maxLen){if(str2.length<=maxLen)return str2;return`${str2.slice(0,maxLen-3)}...`}function formatPath(path3){let shortened=path3.replace(/^\/home\/\w+\/workspace\//,"~/").replace(/^\/home\/\w+\//,"~/");return truncate(shortened,50)}function flushPendingReads(ctx){if(ctx.pendingReads.length===0)return;ctx.events.push({timestamp:ctx.lastReadTime,type:"read",summary:ctx.pendingReads.length===1?`Read: ${formatPath(ctx.pendingReads[0])}`:`Read ${ctx.pendingReads.length} files`,details:ctx.pendingReads.length>1?ctx.pendingReads.map(formatPath):void 0}),ctx.pendingReads.length=0}function flushPendingEdits(ctx){if(ctx.pendingEdits.length===0)return;ctx.events.push({timestamp:ctx.lastEditTime,type:"edit",summary:ctx.pendingEdits.length===1?`Edit: ${formatPath(ctx.pendingEdits[0])}`:`Edit ${ctx.pendingEdits.length} files`,details:ctx.pendingEdits.length>1?ctx.pendingEdits.map(formatPath):void 0}),ctx.pendingEdits.length=0}function flushAll(ctx){flushPendingReads(ctx),flushPendingEdits(ctx)}function processToolCallEntry(entry,ctx){if(!entry.toolCall)return;let{name,input}=entry.toolCall,inputRecord=input,normalizedName=name==="shell"||name==="exec_command"?"Bash":name;switch(normalizedName){case"Read":if(ctx.lastReadTime=entry.timestamp,inputRecord.file_path)ctx.pendingReads.push(String(inputRecord.file_path));break;case"Edit":if(flushPendingReads(ctx),ctx.lastEditTime=entry.timestamp,inputRecord.file_path)ctx.pendingEdits.push(String(inputRecord.file_path));break;case"Write":flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"write",summary:`Write: ${formatPath(String(inputRecord.file_path||"unknown"))}`});break;case"Bash":{flushAll(ctx);let cmd=String(inputRecord.command||"").replace(/\n/g," ");ctx.events.push({timestamp:entry.timestamp,type:"bash",summary:`Bash: ${truncate(cmd,60)}`});break}case"AskUserQuestion":{flushAll(ctx);let questions=inputRecord.questions;ctx.events.push({timestamp:entry.timestamp,type:"question",summary:`Question: ${truncate(questions?.[0]?.question||"question",60)}`});break}default:flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"bash",summary:`${normalizedName}: ${truncate(entry.text.replace(/\n/g," "),60)}`})}}function processTranscriptEntry(entry,ctx){if(entry.role==="user"){flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"prompt",summary:truncate(entry.text.replace(/\n/g," "),80)});return}if(entry.role==="tool_call"){processToolCallEntry(entry,ctx);return}if(entry.role==="assistant"&&entry.text.length>100)flushAll(ctx),ctx.events.push({timestamp:entry.timestamp,type:"response",summary:truncate(entry.text.replace(/\n/g," "),80)})}function extractEvents(entries){let ctx={events:[],pendingReads:[],pendingEdits:[],lastReadTime:"",lastEditTime:""};for(let entry of entries)processTranscriptEntry(entry,ctx);return flushAll(ctx),ctx.events}function detectStatus(entries){if(entries.length===0)return"unknown";let lastEntries=entries.slice(-10);for(let entry of lastEntries.reverse())if(entry.role==="tool_call"&&entry.toolCall?.name==="AskUserQuestion")return"question";let last=entries[entries.length-1];if(last.role==="user")return"working";if(last.role==="assistant")return"idle";return"unknown"}function formatEventsForDisplay(events,stats){let lines=[];lines.push(""),lines.push(`Session: ${stats.workerId} [${stats.provider}]${stats.branch?` (${stats.branch})`:""} | ${stats.duration} | ${stats.totalEntries} entries \u2192 ${stats.compressedLines} lines`),lines.push("");for(let event of events){let time=formatTime(event.timestamp),icon=getEventIcon(event.type);if(lines.push(`[${time}] ${icon} ${event.summary}`),event.details&&event.details.length>0){for(let detail of event.details.slice(0,5))lines.push(` ${detail}`);if(event.details.length>5)lines.push(` ... and ${event.details.length-5} more`)}if(event.result)lines.push(` \u2192 ${event.result}`)}return lines.push(""),lines.push(`Status: ${stats.status.toUpperCase()} | ${stats.exchanges} exchanges | ${stats.toolCalls} tool calls | ${stats.compressionRatio.toFixed(0)}x compression`),lines.push(""),lines.join(`
|
|
1044
1044
|
`)}function getEventIcon(type2){switch(type2){case"prompt":return"\uD83D\uDCAC";case"read":return"\uD83D\uDCD6";case"edit":return"\u270F\uFE0F";case"write":return"\uD83D\uDCDD";case"bash":return"\u26A1";case"question":return"\u2753";case"answer":return"\u2705";case"permission":return"\uD83D\uDD10";case"thinking":return"\uD83E\uDD14";case"response":return"\uD83D\uDCAD";default:return"\u2022"}}function formatToolDetail(toolCall){let input=toolCall.input;if(toolCall.name==="Bash"||toolCall.name==="shell")return` ${toolCall.name}: ${input.command??""}`;if(["Read","Edit","Write"].includes(toolCall.name))return` ${toolCall.name}: ${input.file_path??""}`;return` ${toolCall.name}`}function formatTranscriptEntryForDisplay(entry){let time=formatTime(entry.timestamp);switch(entry.role){case"user":return[`
|
|
1045
1045
|
[${time}] USER:`,entry.text];case"tool_call":return entry.toolCall?[`
|
|
1046
1046
|
[${time}] TOOL:`,formatToolDetail(entry.toolCall)]:[];case"assistant":return[`
|
|
@@ -1217,7 +1217,7 @@ History for "${schedule.name}":
|
|
|
1217
1217
|
Tags: ${tags.map((t)=>t.name).join(", ")}`);let blockers=await ts.getBlockers(task.id,task.repoPath);if(blockers.length>0){console.log(`
|
|
1218
1218
|
Dependencies:`);for(let dep of blockers){let depTask=await ts.getTask(dep.dependsOnId,task.repoPath),label=depTask?`#${depTask.seq} ${depTask.title}`:dep.dependsOnId;console.log(` ${dep.depType}: ${label}`)}}let stageLog=await ts.getStageLog(task.id,task.repoPath);if(stageLog.length>0){console.log(`
|
|
1219
1219
|
Stage History:`);for(let entry of stageLog.slice(0,10)){let who=entry.actorId??"system";console.log(` ${formatTimestamp3(entry.createdAt)}: ${entry.fromStage??"(new)"} \u2192 ${entry.toStage} by ${who}`)}}}async function printTaskMessages(task){let ts=await getTaskService6(),conv=await ts.findOrCreateConversation({linkedEntity:"task",linkedEntityId:task.id,name:`Task #${task.seq}`}),messages2=await ts.getMessages(conv.id,{limit:20});if(messages2.length>0){console.log(`
|
|
1220
|
-
Messages:`);for(let msg of messages2){let time=formatTimestamp3(msg.createdAt),reply=msg.replyToId?` (reply to #${msg.replyToId})`:"";console.log(` [${time}] ${msg.senderId}: ${msg.body}${reply}`)}}}async function printTaskDetail(task){printTaskFields(task),await printTaskRelations(task),await printTaskMessages(task),console.log("")}async function handleTaskCreate(title,options){let ts=await getTaskService6(),actor=currentActor2(),repoPath,projectId;if(options.project){let project=await ts.getProjectByName(options.project);if(!project)project=await ts.createProject({name:options.project});projectId=project.id,repoPath=project.repoPath??void 0}let parentId;if(options.parent){if(parentId=await ts.resolveTaskId(options.parent,repoPath)??void 0,!parentId)console.error(`Error: Parent task not found: ${options.parent}`),process.exit(1)}let task=await ts.createTask({title,typeId:options.type,priority:options.priority,dueDate:options.due,startDate:options.start,parentId,description:options.description,estimatedEffort:options.effort},repoPath,projectId);if(await ts.assignTask(task.id,actor,"creator",{},task.repoPath),options.assign)await ts.assignTask(task.id,localActor2(options.assign),"assignee",{},task.repoPath);if(options.tags){let tagIds=options.tags.split(",").map((t)=>t.trim());await ts.tagTask(task.id,tagIds,actor,task.repoPath)}if(options.comment)await ts.commentOnTask(task.id,actor,options.comment,task.repoPath);if(console.log(`Created task #${task.seq}: ${task.title}`),console.log(` ID: ${task.id}`),console.log(` Stage: ${task.stage} | Priority: ${task.priority}`),options.due)console.log(` Due: ${options.due}`)}function registerTaskCommands(program2){let task=program2.command("task").description("Task lifecycle management");task.command("create <title>").description("Create a new task").option("--type <type>","Task type","software").option("--priority <priority>","Priority: urgent, high, normal, low","normal").option("--due <date>","Due date (YYYY-MM-DD)").option("--start <date>","Start date (YYYY-MM-DD)").option("--tags <tags>","Comma-separated tag IDs").option("--parent <id>","Parent task ID or #seq").option("--assign <name>","Assign to local actor").option("--description <text>","Task description").option("--effort <effort>",'Estimated effort (e.g., "2h", "3 points")').option("--comment <msg>","Initial comment on the task").option("--project <name>","Create task in a specific project (overrides CWD)").action(async(title,options)=>{try{await handleTaskCreate(title,options)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("list").description("List tasks with filters").option("--stage <stage>","Filter by stage").option("--type <type>","Filter by type").option("--status <status>","Filter by status").option("--priority <priority>","Filter by priority").option("--release <release>","Filter by release").option("--due-before <date>","Filter by due date").option("--mine","Show only tasks assigned to me").option("--project <name>","Show tasks for a specific project").option("--all","Show tasks from ALL projects").option("--json","Output as JSON").action(async(options)=>{try{let ts=await getTaskService6(),filters={stage:options.stage,typeId:options.type,status:options.status,priority:options.priority,releaseId:options.release,dueBefore:options.dueBefore,projectName:options.project,allProjects:options.all},tasks;if(options.mine)tasks=await ts.listTasksForActor(currentActor2(),filters);else tasks=await ts.listTasks(filters);if(options.json){console.log(JSON.stringify(tasks,null,2));return}printTaskList(tasks,options.all)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("show <id>").description("Show task detail (accepts task-id or #seq)").option("--json","Output as JSON").action(async(id,options)=>{try{let t=await(await getTaskService6()).getTask(id);if(!t)console.error(`Error: Task not found: ${id}`),process.exit(1);if(options.json){console.log(JSON.stringify(t,null,2));return}await printTaskDetail(t)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("move <id>").description("Move task to a new stage").requiredOption("--to <stage>","Target stage").option("--comment <msg>","Comment on the move").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.moveTask(id,options.to,actor,options.comment);console.log(`Moved task #${t.seq} to stage "${t.stage}".`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("assign <id>").description("Assign an actor to a task").requiredOption("--to <name>","Actor name").option("--role <role>","Actor role","assignee").option("--comment <msg>","Comment on the assignment").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2();if(await ts.assignTask(id,localActor2(options.to),options.role,{}),options.comment)await ts.commentOnTask(id,actor,options.comment);console.log(`Assigned "${options.to}" as ${options.role??"assignee"} on task ${id}.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("tag <id> <tags...>").description("Add tags to a task").action(async(id,tags)=>{try{await(await getTaskService6()).tagTask(id,tags,currentActor2()),console.log(`Tagged task ${id} with: ${tags.join(", ")}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("comment <id> <message>").description("Add a comment to a task").option("--reply-to <msgId>","Reply to a specific message ID").action(async(id,message,options)=>{try{let ts=await getTaskService6(),replyTo=options.replyTo?Number(options.replyTo):void 0,msg=await ts.commentOnTask(id,currentActor2(),message,void 0,replyTo);console.log(`Comment #${msg.id} added to task ${id}.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("block <id>").description("Mark task as blocked").requiredOption("--reason <reason>","Reason for blocking").option("--comment <msg>","Additional comment").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.blockTask(id,options.reason,actor,options.comment);console.log(`Task #${t.seq} blocked: ${options.reason}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("unblock <id>").description("Unblock a task").option("--comment <msg>","Comment on unblock").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.unblockTask(id,actor,options.comment);console.log(`Task #${t.seq} unblocked.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("done <id>").description("Mark task as done").option("--comment <msg>","Comment on completion").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.markDone(id,actor,options.comment);console.log(`Task #${t.seq} marked as done.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("checkout <id>").description("Atomically claim a task for execution").action(async(id)=>{try{let ts=await getTaskService6(),runId=getRunId(),t=await ts.checkoutTask(id,runId);console.log(`Checked out task #${t.seq} for run: ${runId}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("release <id>").description("Release task checkout claim").action(async(id)=>{try{let ts=await getTaskService6(),runId=getRunId(),t=await ts.releaseTask(id,runId);console.log(`Released task #${t.seq} from run: ${runId}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("unlock <id>").description("Force-release a stale checkout (admin override)").action(async(id)=>{try{let t=await(await getTaskService6()).forceUnlockTask(id);console.log(`Force-unlocked task #${t.seq}.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("dep <id>").description("Manage task dependencies").option("--depends-on <id2>","This task depends on id2").option("--blocks <id2>","This task blocks id2").option("--relates-to <id2>","This task relates to id2").option("--remove <id2>","Remove dependency on id2").action(async(id,options)=>{try{let ts=await getTaskService6();if(options.remove){if(await ts.removeDependency(id,options.remove))console.log(`Removed dependency between ${id} and ${options.remove}.`);else console.log("No dependency found to remove.");return}if(options.dependsOn)await ts.addDependency(id,options.dependsOn,"depends_on"),console.log(`${id} now depends on ${options.dependsOn}.`);if(options.blocks)await ts.addDependency(id,options.blocks,"blocks"),console.log(`${id} now blocks ${options.blocks}.`);if(options.relatesTo)await ts.addDependency(id,options.relatesTo,"relates_to"),console.log(`${id} now relates to ${options.relatesTo}.`);if(!options.dependsOn&&!options.blocks&&!options.relatesTo)console.error("Error: Specify --depends-on, --blocks, --relates-to, or --remove."),process.exit(1)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}})}init_team_manager();import{existsSync as existsSync20}from"fs";import{copyFile as copyFile2,mkdir as mkdir11}from"fs/promises";import{join as join32,resolve as resolve6}from"path";function registerTeamNamespace(program2){let team=program2.command("team").description("Team lifecycle management");team.command("create <name>").description("Create a new team with a git worktree").requiredOption("--repo <path>","Path to the git repository").option("--branch <branch>","Base branch to create from","dev").option("--wish <slug>","Wish slug \u2014 auto-spawns a task leader with wish context").option("--session <name>","Tmux session name (avoids session explosion on parallel creates)").action(async(name,options)=>{try{await handleTeamCreate(name,options)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("hire <agent>").description('Add an agent to a team ("council" hires all 10 council members)').option("--team <name>","Team name (auto-detects from leader context if omitted)").action(async(agent,options)=>{try{let teamName=options.team??await autoDetectTeam();if(!teamName)console.error("Error: Could not detect team. Use --team <name> to specify."),process.exit(1);let added=await hireAgent(teamName,agent);if(added.length===0)console.log(`Agent "${agent}" is already a member of "${teamName}".`);else if(agent==="council"){console.log(`Hired ${added.length} council members to "${teamName}":`);for(let name of added)console.log(` + ${name}`)}else console.log(`Hired "${agent}" to team "${teamName}".`)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("fire <agent>").description("Remove an agent from a team").option("--team <name>","Team name (auto-detects from leader context if omitted)").action(async(agent,options)=>{try{let teamName=options.team??await autoDetectTeam();if(!teamName)console.error("Error: Could not detect team. Use --team <name> to specify."),process.exit(1);if(await fireAgent(teamName,agent))console.log(`Fired "${agent}" from team "${teamName}".`);else console.error(`Agent "${agent}" is not a member of "${teamName}".`),process.exit(1)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("ls [name]").alias("list").description("List teams or members of a team").option("--json","Output as JSON").action(async(name,options)=>{try{if(name)await printMembers(name,options.json);else await printTeams(options.json)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("disband <name>").description("Disband a team: kill members, remove worktree, delete config").action(async(name)=>{try{if(await disbandTeam(name))console.log(`Team "${name}" disbanded.`);else console.error(`Team "${name}" not found.`),process.exit(1)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("done <name>").description("Mark a team as done and kill all members").action(async(name)=>{try{await setTeamStatus(name,"done"),await killTeamMembers(name),console.log(`Team "${name}" marked as done. All members killed.`)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("blocked <name>").description("Mark a team as blocked and kill all members").action(async(name)=>{try{await setTeamStatus(name,"blocked"),await killTeamMembers(name),console.log(`Team "${name}" marked as blocked. All members killed.`)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}})}async function handleTeamCreate(name,options){if(options.wish){let resolvedRepo=resolve6(options.repo),wishPath=join32(resolvedRepo,".genie","wishes",options.wish,"WISH.md");if(!existsSync20(wishPath))console.error(`Error: Wish not found at ${wishPath}`),process.exit(1)}let config=await createTeam(name,options.repo,options.branch);if(options.session)config.tmuxSessionName=options.session,await updateTeamConfig(name,config);if(console.log(`Team "${config.name}" created.`),console.log(` Worktree: ${config.worktreePath}`),console.log(` Branch: ${config.name} (from ${config.baseBranch})`),config.tmuxSessionName)console.log(` Session: ${config.tmuxSessionName}`);if(config.nativeTeamsEnabled)console.log(" Native teams: enabled");if(options.wish)await spawnLeaderWithWish(config,options.wish,options.repo,options.session)}async function spawnLeaderWithWish(config,slug,repoPath,sessionOverride){let{handleWorkerSpawn:handleWorkerSpawn2}=await Promise.resolve().then(() => (init_agents(),exports_agents)),{getCurrentSessionName:getCurrentSessionName2}=await Promise.resolve().then(() => (init_tmux(),exports_tmux)),resolvedRepo=resolve6(repoPath),tmuxSession=sessionOverride??await getCurrentSessionName2(config.name)??config.name;config.tmuxSessionName=tmuxSession,await updateTeamConfig(config.name,config);let sourceWishPath=join32(resolvedRepo,".genie","wishes",slug,"WISH.md");if(!existsSync20(sourceWishPath))console.error(`Error: Wish not found at ${sourceWishPath}`),process.exit(1);let destWishDir=join32(config.worktreePath,".genie","wishes",slug);await mkdir11(destWishDir,{recursive:!0});let destWishPath=join32(destWishDir,"WISH.md");await copyFile2(sourceWishPath,destWishPath),console.log(` Wish: copied ${slug}/WISH.md into worktree`);let standardTeam=["team-lead","engineer","reviewer","qa","fix"];for(let role of standardTeam)await hireAgent(config.name,role);console.log(` Team: hired ${standardTeam.join(", ")}`),await handleWorkerSpawn2("team-lead",{provider:"claude",team:config.name,cwd:config.worktreePath,session:tmuxSession});let members=standardTeam.filter((r)=>r!=="team-lead").join(", "),kickoffPrompt=`Your team is "${config.name}". Repo: ${config.repo}. Branch: ${config.name}. Worktree: ${config.worktreePath}. Wish slug: ${slug}. Your team members are: ${members} (already hired \u2014 genie work will spawn them automatically). Read the wish at .genie/wishes/${slug}/WISH.md and execute the full lifecycle autonomously.`;await(await Promise.resolve().then(() => (init_protocol_router(),exports_protocol_router))).sendMessage(config.worktreePath,"cli","team-lead",kickoffPrompt),console.log(" Leader: spawned and working")}async function autoDetectTeam(){let envTeam=process.env.GENIE_TEAM;if(envTeam)return envTeam;let teams=await listTeams2();if(teams.length===1)return teams[0].name;return null}async function printMembers(name,json2){let members=await listMembers(name);if(members===null)console.error(`Team "${name}" not found.`),process.exit(1);if(json2){console.log(JSON.stringify(members,null,2));return}if(members.length===0){console.log(`Team "${name}" has no members. Hire agents with: genie team hire <agent> --team ${name}`);return}console.log(""),console.log(`MEMBERS of "${name}"`),console.log("-".repeat(60));for(let m of members)console.log(` ${m}`);console.log("")}async function printTeams(json2){let teams=await listTeams2();if(json2){console.log(JSON.stringify(teams,null,2));return}if(teams.length===0){console.log("No teams found. Create one with: genie team create <name> --repo <path>");return}console.log(""),console.log("TEAMS"),console.log("-".repeat(60));for(let t of teams)printTeamSummary(t);console.log("")}function printTeamSummary(t){let status=t.status??"in_progress";console.log(` ${t.name} [${status}]`),console.log(` Repo: ${t.repo}`),console.log(` Branch: ${t.name} (from ${t.baseBranch})`),console.log(` Worktree: ${t.worktreePath}`),console.log(` Members: ${t.members.length}`)}var _taskService7;async function getTaskService7(){if(!_taskService7)_taskService7=await Promise.resolve().then(() => (init_task_service(),exports_task_service));return _taskService7}function padRight10(str3,len){return str3.length>=len?str3:str3+" ".repeat(len-str3.length)}function printTypeTable(types3){console.log(` ${padRight10("ID",20)} ${padRight10("NAME",30)} ${padRight10("STAGES",8)} BUILTIN`),console.log(` ${"\u2500".repeat(70)}`);for(let t of types3){let stageCount=Array.isArray(t.stages)?t.stages.length:0,builtin=t.isBuiltin?"yes":"no";console.log(` ${padRight10(t.id,20)} ${padRight10(t.name,30)} ${padRight10(String(stageCount),8)} ${builtin}`)}console.log(`
|
|
1220
|
+
Messages:`);for(let msg of messages2){let time=formatTimestamp3(msg.createdAt),reply=msg.replyToId?` (reply to #${msg.replyToId})`:"";console.log(` [${time}] ${msg.senderId}: ${msg.body}${reply}`)}}}async function printTaskDetail(task){printTaskFields(task),await printTaskRelations(task),await printTaskMessages(task),console.log("")}async function handleTaskCreate(title,options){let ts=await getTaskService6(),actor=currentActor2(),repoPath,projectId;if(options.project){let project=await ts.getProjectByName(options.project);if(!project)project=await ts.createProject({name:options.project});projectId=project.id,repoPath=project.repoPath??void 0}let parentId;if(options.parent){if(parentId=await ts.resolveTaskId(options.parent,repoPath)??void 0,!parentId)console.error(`Error: Parent task not found: ${options.parent}`),process.exit(1)}let task=await ts.createTask({title,typeId:options.type,priority:options.priority,dueDate:options.due,startDate:options.start,parentId,description:options.description,estimatedEffort:options.effort},repoPath,projectId);if(await ts.assignTask(task.id,actor,"creator",{},task.repoPath),options.assign)await ts.assignTask(task.id,localActor2(options.assign),"assignee",{},task.repoPath);if(options.tags){let tagIds=options.tags.split(",").map((t)=>t.trim());await ts.tagTask(task.id,tagIds,actor,task.repoPath)}if(options.comment)await ts.commentOnTask(task.id,actor,options.comment,task.repoPath);if(console.log(`Created task #${task.seq}: ${task.title}`),console.log(` ID: ${task.id}`),console.log(` Stage: ${task.stage} | Priority: ${task.priority}`),options.due)console.log(` Due: ${options.due}`)}function registerTaskCommands(program2){let task=program2.command("task").description("Task lifecycle management");task.command("create <title>").description("Create a new task").option("--type <type>","Task type","software").option("--priority <priority>","Priority: urgent, high, normal, low","normal").option("--due <date>","Due date (YYYY-MM-DD)").option("--start <date>","Start date (YYYY-MM-DD)").option("--tags <tags>","Comma-separated tag IDs").option("--parent <id>","Parent task ID or #seq").option("--assign <name>","Assign to local actor").option("--description <text>","Task description").option("--effort <effort>",'Estimated effort (e.g., "2h", "3 points")').option("--comment <msg>","Initial comment on the task").option("--project <name>","Create task in a specific project (overrides CWD)").action(async(title,options)=>{try{await handleTaskCreate(title,options)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("list").description("List tasks with filters").option("--stage <stage>","Filter by stage").option("--type <type>","Filter by type").option("--status <status>","Filter by status").option("--priority <priority>","Filter by priority").option("--release <release>","Filter by release").option("--due-before <date>","Filter by due date").option("--mine","Show only tasks assigned to me").option("--project <name>","Show tasks for a specific project").option("--all","Show tasks from ALL projects").option("--json","Output as JSON").action(async(options)=>{try{let ts=await getTaskService6(),filters={stage:options.stage,typeId:options.type,status:options.status,priority:options.priority,releaseId:options.release,dueBefore:options.dueBefore,projectName:options.project,allProjects:options.all},tasks;if(options.mine)tasks=await ts.listTasksForActor(currentActor2(),filters);else tasks=await ts.listTasks(filters);if(options.json){console.log(JSON.stringify(tasks,null,2));return}printTaskList(tasks,options.all)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("show <id>").description("Show task detail (accepts task-id or #seq)").option("--json","Output as JSON").action(async(id,options)=>{try{let t=await(await getTaskService6()).getTask(id);if(!t)console.error(`Error: Task not found: ${id}`),process.exit(1);if(options.json){console.log(JSON.stringify(t,null,2));return}await printTaskDetail(t)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("move <id>").description("Move task to a new stage").requiredOption("--to <stage>","Target stage").option("--comment <msg>","Comment on the move").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.moveTask(id,options.to,actor,options.comment);console.log(`Moved task #${t.seq} to stage "${t.stage}".`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("assign <id>").description("Assign an actor to a task").requiredOption("--to <name>","Actor name").option("--role <role>","Actor role","assignee").option("--comment <msg>","Comment on the assignment").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2();if(await ts.assignTask(id,localActor2(options.to),options.role,{}),options.comment)await ts.commentOnTask(id,actor,options.comment);console.log(`Assigned "${options.to}" as ${options.role??"assignee"} on task ${id}.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("tag <id> <tags...>").description("Add tags to a task").action(async(id,tags)=>{try{await(await getTaskService6()).tagTask(id,tags,currentActor2()),console.log(`Tagged task ${id} with: ${tags.join(", ")}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("comment <id> <message>").description("Add a comment to a task").option("--reply-to <msgId>","Reply to a specific message ID").action(async(id,message,options)=>{try{let ts=await getTaskService6(),replyTo=options.replyTo?Number(options.replyTo):void 0,msg=await ts.commentOnTask(id,currentActor2(),message,void 0,replyTo);console.log(`Comment #${msg.id} added to task ${id}.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("block <id>").description("Mark task as blocked").requiredOption("--reason <reason>","Reason for blocking").option("--comment <msg>","Additional comment").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.blockTask(id,options.reason,actor,options.comment);console.log(`Task #${t.seq} blocked: ${options.reason}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("unblock <id>").description("Unblock a task").option("--comment <msg>","Comment on unblock").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.unblockTask(id,actor,options.comment);console.log(`Task #${t.seq} unblocked.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("done <id>").description("Mark task as done").option("--comment <msg>","Comment on completion").action(async(id,options)=>{try{let ts=await getTaskService6(),actor=currentActor2(),t=await ts.markDone(id,actor,options.comment);console.log(`Task #${t.seq} marked as done.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("checkout <id>").description("Atomically claim a task for execution").action(async(id)=>{try{let ts=await getTaskService6(),runId=getRunId(),t=await ts.checkoutTask(id,runId);console.log(`Checked out task #${t.seq} for run: ${runId}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("release <id>").description("Release task checkout claim").action(async(id)=>{try{let ts=await getTaskService6(),runId=getRunId(),t=await ts.releaseTask(id,runId);console.log(`Released task #${t.seq} from run: ${runId}`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("unlock <id>").description("Force-release a stale checkout (admin override)").action(async(id)=>{try{let t=await(await getTaskService6()).forceUnlockTask(id);console.log(`Force-unlocked task #${t.seq}.`)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),task.command("dep <id>").description("Manage task dependencies").option("--depends-on <id2>","This task depends on id2").option("--blocks <id2>","This task blocks id2").option("--relates-to <id2>","This task relates to id2").option("--remove <id2>","Remove dependency on id2").action(async(id,options)=>{try{let ts=await getTaskService6();if(options.remove){if(await ts.removeDependency(id,options.remove))console.log(`Removed dependency between ${id} and ${options.remove}.`);else console.log("No dependency found to remove.");return}if(options.dependsOn)await ts.addDependency(id,options.dependsOn,"depends_on"),console.log(`${id} now depends on ${options.dependsOn}.`);if(options.blocks)await ts.addDependency(id,options.blocks,"blocks"),console.log(`${id} now blocks ${options.blocks}.`);if(options.relatesTo)await ts.addDependency(id,options.relatesTo,"relates_to"),console.log(`${id} now relates to ${options.relatesTo}.`);if(!options.dependsOn&&!options.blocks&&!options.relatesTo)console.error("Error: Specify --depends-on, --blocks, --relates-to, or --remove."),process.exit(1)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}})}init_team_manager();import{existsSync as existsSync20}from"fs";import{copyFile as copyFile2,mkdir as mkdir11}from"fs/promises";import{join as join32,resolve as resolve6}from"path";function registerTeamNamespace(program2){let team=program2.command("team").description("Team lifecycle management");team.command("create <name>").description("Create a new team with a git worktree").requiredOption("--repo <path>","Path to the git repository").option("--branch <branch>","Base branch to create from","dev").option("--wish <slug>","Wish slug \u2014 auto-spawns a task leader with wish context").option("--session <name>","Tmux session name (avoids session explosion on parallel creates)").action(async(name,options)=>{try{await handleTeamCreate(name,options)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("hire <agent>").description('Add an agent to a team ("council" hires all 10 council members)').option("--team <name>","Team name (auto-detects from leader context if omitted)").action(async(agent,options)=>{try{let teamName=options.team??await autoDetectTeam();if(!teamName)console.error("Error: Could not detect team. Use --team <name> to specify."),process.exit(1);let added=await hireAgent(teamName,agent);if(added.length===0)console.log(`Agent "${agent}" is already a member of "${teamName}".`);else if(agent==="council"){console.log(`Hired ${added.length} council members to "${teamName}":`);for(let name of added)console.log(` + ${name}`)}else console.log(`Hired "${agent}" to team "${teamName}".`)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("fire <agent>").description("Remove an agent from a team").option("--team <name>","Team name (auto-detects from leader context if omitted)").action(async(agent,options)=>{try{let teamName=options.team??await autoDetectTeam();if(!teamName)console.error("Error: Could not detect team. Use --team <name> to specify."),process.exit(1);if(await fireAgent(teamName,agent))console.log(`Fired "${agent}" from team "${teamName}".`);else console.error(`Agent "${agent}" is not a member of "${teamName}".`),process.exit(1)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("ls [name]").alias("list").description("List teams or members of a team").option("--json","Output as JSON").action(async(name,options)=>{try{if(name)await printMembers(name,options.json);else await printTeams(options.json)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("disband <name>").description("Disband a team: kill members, remove worktree, delete config").action(async(name)=>{try{if(await disbandTeam(name))console.log(`Team "${name}" disbanded.`);else console.error(`Team "${name}" not found.`),process.exit(1)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("done <name>").description("Mark a team as done and kill all members").action(async(name)=>{try{await setTeamStatus(name,"done"),await killTeamMembers(name),console.log(`Team "${name}" marked as done. All members killed.`)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}}),team.command("blocked <name>").description("Mark a team as blocked and kill all members").action(async(name)=>{try{await setTeamStatus(name,"blocked"),await killTeamMembers(name),console.log(`Team "${name}" marked as blocked. All members killed.`)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}})}async function handleTeamCreate(name,options){if(options.wish){let resolvedRepo=resolve6(options.repo),wishPath=join32(resolvedRepo,".genie","wishes",options.wish,"WISH.md");if(!existsSync20(wishPath))console.error(`Error: Wish not found at ${wishPath}`),process.exit(1)}let config=await createTeam(name,options.repo,options.branch);if(options.session)config.tmuxSessionName=options.session,await updateTeamConfig(name,config);if(console.log(`Team "${config.name}" created.`),console.log(` Worktree: ${config.worktreePath}`),console.log(` Branch: ${config.name} (from ${config.baseBranch})`),config.tmuxSessionName)console.log(` Session: ${config.tmuxSessionName}`);if(config.nativeTeamsEnabled)console.log(" Native teams: enabled");if(options.wish)await spawnLeaderWithWish(config,options.wish,options.repo,options.session)}async function spawnLeaderWithWish(config,slug,repoPath,sessionOverride){let{handleWorkerSpawn:handleWorkerSpawn2}=await Promise.resolve().then(() => (init_agents(),exports_agents)),{getCurrentSessionName:getCurrentSessionName2}=await Promise.resolve().then(() => (init_tmux(),exports_tmux)),resolvedRepo=resolve6(repoPath),tmuxSession=sessionOverride??await getCurrentSessionName2(config.name)??config.name;config.tmuxSessionName=tmuxSession,await updateTeamConfig(config.name,config);let sourceWishPath=join32(resolvedRepo,".genie","wishes",slug,"WISH.md");if(!existsSync20(sourceWishPath))console.error(`Error: Wish not found at ${sourceWishPath}`),process.exit(1);let destWishDir=join32(config.worktreePath,".genie","wishes",slug);await mkdir11(destWishDir,{recursive:!0});let destWishPath=join32(destWishDir,"WISH.md");await copyFile2(sourceWishPath,destWishPath),console.log(` Wish: copied ${slug}/WISH.md into worktree`);let standardTeam=["team-lead","engineer","reviewer","qa","fix"];for(let role of standardTeam)await hireAgent(config.name,role);console.log(` Team: hired ${standardTeam.join(", ")}`);let members=standardTeam.filter((r)=>r!=="team-lead").join(", "),kickoffPrompt=`Your team is "${config.name}". Repo: ${config.repo}. Branch: ${config.name}. Worktree: ${config.worktreePath}. Wish slug: ${slug}. Your team members are: ${members} (already hired \u2014 genie work will spawn them automatically). Read the wish at .genie/wishes/${slug}/WISH.md and execute the full lifecycle autonomously.`;await handleWorkerSpawn2("team-lead",{provider:"claude",team:config.name,cwd:config.worktreePath,session:tmuxSession,initialPrompt:kickoffPrompt});let result=await(await Promise.resolve().then(() => (init_protocol_router(),exports_protocol_router))).sendMessage(config.worktreePath,"cli","team-lead",kickoffPrompt);if(!result.delivered)console.warn(`\u26A0 Backup delivery to team-lead failed: ${result.reason??"unknown"}`);console.log(" Leader: spawned and working")}async function autoDetectTeam(){let envTeam=process.env.GENIE_TEAM;if(envTeam)return envTeam;let teams=await listTeams2();if(teams.length===1)return teams[0].name;return null}async function printMembers(name,json2){let members=await listMembers(name);if(members===null)console.error(`Team "${name}" not found.`),process.exit(1);if(json2){console.log(JSON.stringify(members,null,2));return}if(members.length===0){console.log(`Team "${name}" has no members. Hire agents with: genie team hire <agent> --team ${name}`);return}console.log(""),console.log(`MEMBERS of "${name}"`),console.log("-".repeat(60));for(let m of members)console.log(` ${m}`);console.log("")}async function printTeams(json2){let teams=await listTeams2();if(json2){console.log(JSON.stringify(teams,null,2));return}if(teams.length===0){console.log("No teams found. Create one with: genie team create <name> --repo <path>");return}console.log(""),console.log("TEAMS"),console.log("-".repeat(60));for(let t of teams)printTeamSummary(t);console.log("")}function printTeamSummary(t){let status=t.status??"in_progress";console.log(` ${t.name} [${status}]`),console.log(` Repo: ${t.repo}`),console.log(` Branch: ${t.name} (from ${t.baseBranch})`),console.log(` Worktree: ${t.worktreePath}`),console.log(` Members: ${t.members.length}`)}var _taskService7;async function getTaskService7(){if(!_taskService7)_taskService7=await Promise.resolve().then(() => (init_task_service(),exports_task_service));return _taskService7}function padRight10(str3,len){return str3.length>=len?str3:str3+" ".repeat(len-str3.length)}function printTypeTable(types3){console.log(` ${padRight10("ID",20)} ${padRight10("NAME",30)} ${padRight10("STAGES",8)} BUILTIN`),console.log(` ${"\u2500".repeat(70)}`);for(let t of types3){let stageCount=Array.isArray(t.stages)?t.stages.length:0,builtin=t.isBuiltin?"yes":"no";console.log(` ${padRight10(t.id,20)} ${padRight10(t.name,30)} ${padRight10(String(stageCount),8)} ${builtin}`)}console.log(`
|
|
1221
1221
|
${types3.length} type${types3.length===1?"":"s"}`)}function printTypePipeline(t){if(console.log(`
|
|
1222
1222
|
Type: ${t.name} (${t.id})`),t.description)console.log(`Description: ${t.description}`);if(t.icon)console.log(`Icon: ${t.icon}`);console.log(`Built-in: ${t.isBuiltin?"yes":"no"}`),console.log("\u2500".repeat(60)),console.log(`
|
|
1223
1223
|
Stage Pipeline:`);let stages=t.stages;for(let i2=0;i2<stages.length;i2++){let s=stages[i2],arrow=i2<stages.length-1?" \u2192":"",gate=s.gate?` [gate: ${s.gate}]`:"",action=s.action?` (action: ${s.action})`:"",auto=s.auto_advance?" [auto]":"";console.log(` ${i2+1}. ${s.label??s.name}${gate}${action}${auto}${arrow}`)}console.log("")}async function handleTypeList(options){let types3=await(await getTaskService7()).listTypes();if(options.json){console.log(JSON.stringify(types3,null,2));return}printTypeTable(types3)}async function handleTypeShow(id,options){let t=await(await getTaskService7()).getType(id);if(!t)console.error(`Error: Type not found: ${id}`),process.exit(1);if(options.json){console.log(JSON.stringify(t,null,2));return}printTypePipeline(t)}async function handleTypeCreate(name,options){let ts=await getTaskService7(),stages;try{if(stages=JSON.parse(options.stages),!Array.isArray(stages))throw Error("Stages must be a JSON array")}catch(err){console.error(`Error: Invalid stages JSON. ${err instanceof Error?err.message:String(err)}`),process.exit(1)}for(let s of stages)if(typeof s!=="object"||s===null||!("name"in s))console.error('Error: Each stage must have at least a "name" field.'),process.exit(1);let id=name.toLowerCase().replace(/\s+/g,"-"),t=await ts.createType({id,name,description:options.description,icon:options.icon,stages});console.log(`Created type "${t.name}" (${t.id}) with ${stages.length} stages.`)}function registerTypeCommands(program2){let type2=program2.command("type").description("Task type management");type2.command("list").description("List all task types").option("--json","Output as JSON").action(async(options)=>{try{await handleTypeList(options)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),type2.command("show <id>").description("Show task type detail with stage pipeline").option("--json","Output as JSON").action(async(id,options)=>{try{await handleTypeShow(id,options)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}}),type2.command("create <name>").description("Create a custom task type").requiredOption("--stages <json>","Stages JSON array").option("--description <text>","Type description").option("--icon <icon>","Type icon").action(async(name,options)=>{try{await handleTypeCreate(name,options)}catch(error2){console.error(`Error: ${error2 instanceof Error?error2.message:String(error2)}`),process.exit(1)}})}try{let{execSync:execSyncStartup}=__require("child_process");if(execSyncStartup("git config core.bare",{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()==="true")execSyncStartup("git config core.bare false",{stdio:["pipe","pipe","pipe"]})}catch{}var program2=new Command;program2.name("genie").description("Genie CLI - AI-assisted development").version(VERSION);async function startNamedSession(name){let{buildTeamLeadCommand:buildTeamLeadCommand2,sessionExists:sessionExists2}=await Promise.resolve().then(() => (init_team_lead_command(),exports_team_lead_command)),{getAgentsFilePath:getAgentsFilePath2}=await Promise.resolve().then(() => (init_session(),exports_session)),systemPromptFile=getAgentsFilePath2(),hasPriorSession=sessionExists2(name),cmd=buildTeamLeadCommand2(name,{systemPromptFile:systemPromptFile??void 0,continueName:hasPriorSession?name:void 0});console.log(hasPriorSession?`Resuming session: ${name}`:`Starting new session: ${name}`);let{spawnSync:spawnSync2}=await import("child_process"),result=spawnSync2("sh",["-c",cmd],{stdio:"inherit"});if(result.status)process.exit(result.status)}program2.command("setup").description("Configure genie settings").option("--quick","Accept all defaults").option("--shortcuts","Only configure keyboard shortcuts").option("--codex","Only configure Codex integration").option("--terminal","Only configure terminal defaults").option("--session","Only configure session settings").option("--reset","Reset configuration to defaults").option("--show","Show current configuration").action(async(options)=>{await setupCommand(options)});program2.command("doctor").description("Run diagnostic checks on genie installation").action(doctorCommand);program2.command("update").description("Update Genie CLI to the latest version").option("--next","Switch to dev builds (npm @next tag)").option("--stable","Switch to stable releases (npm @latest tag)").action(updateCommand);program2.command("uninstall").description("Remove Genie CLI and clean up hooks").action(uninstallCommand);var shortcuts=program2.command("shortcuts").description("Manage tmux keyboard shortcuts");shortcuts.action(shortcutsShowCommand);shortcuts.command("show").description("Show available shortcuts and installation status").action(shortcutsShowCommand);shortcuts.command("install").description("Install shortcuts to config files (~/.tmux.conf, shell rc)").action(shortcutsInstallCommand);shortcuts.command("uninstall").description("Remove shortcuts from config files").action(shortcutsUninstallCommand);registerTeamNamespace(program2);registerDirNamespace(program2);registerAgentNamespace(program2);registerSendInboxCommands(program2);registerStateCommands(program2);registerDispatchCommands(program2);registerHookNamespace(program2);registerDbCommands(program2);registerScheduleCommands(program2);registerDaemonCommands(program2);registerTaskCommands(program2);registerTypeCommands(program2);registerTagCommands(program2);registerReleaseCommands(program2);registerProjectCommands(program2);registerNotifyCommands(program2);program2.command("spawn <name>").description("Spawn a new agent by name (resolves from directory or built-ins)").option("--provider <provider>","Provider: claude or codex","claude").option("--team <team>","Team name",process.env.GENIE_TEAM??"genie").option("--model <model>","Model override (e.g., sonnet, opus)").option("--skill <skill>","Skill to load (optional)").option("--layout <layout>","Layout mode: mosaic (default) or vertical").option("--color <color>","Teammate pane border color").option("--plan-mode","Start teammate in plan mode").option("--permission-mode <mode>","Permission mode (e.g., acceptEdits)").option("--extra-args <args...>","Extra CLI args forwarded to provider").option("--cwd <path>","Working directory for the agent (overrides directory entry)").option("--session <session>","Tmux session name to spawn into").option("--no-auto-resume","Disable auto-resume on pane death").action(async(name,options)=>{try{await handleWorkerSpawn(name,options)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}});program2.command("kill <name>").description("Force kill an agent by name").action(async(name)=>{try{await handleWorkerKill(name)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}});program2.command("stop <name>").description("Stop an agent (preserves session for resume)").action(async(name)=>{try{await handleWorkerStop(name)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}});program2.command("resume [name]").description("Resume a suspended/failed agent with its Claude session").option("--all","Resume all eligible agents").action(async(name,options)=>{try{await handleWorkerResume(name,options)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}});program2.command("history <name>").description("Show compressed session history for an agent").option("--full","Show full conversation without compression").option("--since <n>","Show last N user/assistant exchanges",Number.parseInt).option("--last <n>","Show last N transcript entries",Number.parseInt).option("--type <role>","Filter by role (user, assistant, tool_call)").option("--after <timestamp>","Only entries after ISO timestamp").option("--json","Output as JSON").option("--ndjson","Output as newline-delimited JSON (pipeable to jq)").option("--raw","Output raw JSONL entries").option("--log-file <path>","Direct path to log file (for testing)").action(async(name,options)=>{await historyCommand(name,options)});program2.command("log [agent]").description("Unified observability feed \u2014 aggregates transcript, DMs, team chat").option("--team <name>","Show interleaved feed for all agents in a team").option("--type <kind>","Filter by event kind (transcript, message, tool_call, state, system)").option("--since <timestamp>","Only events after ISO timestamp").option("--last <n>","Show last N events",Number.parseInt).option("--ndjson","Output as newline-delimited JSON (pipeable to jq)").option("--json","Output as pretty JSON").option("-f, --follow","Follow mode \u2014 real-time streaming").action(async(agent,options)=>{await logCommand(agent,options)});var qaCmd=program2.command("qa").description("QA \u2014 self-testing system for genie CLI");qaCmd.command("run [target]",{isDefault:!0}).description("Run QA specs (all, a domain, or a single spec)").option("--timeout <seconds>","Max seconds per spec",(v)=>Number(v),60).option("--parallel <n>","Max specs to run in parallel",(v)=>Number(v),5).option("--verbose","Show all collected events").option("--ndjson","Machine-readable NDJSON output").action(async(target,options)=>{await qaCommand(target,options)});qaCmd.command("status").description("Show QA dashboard with last results per spec").option("--json","Output as JSON").action(async(options)=>{await qaStatusCommand(options)});qaCmd.command("history").description("Show recent QA runs").action(async()=>{await qaHistoryCommand()});program2.command("qa-report <json>").description("Publish QA result via NATS (called by QA team-lead)").action(async(json2)=>{let team=process.env.GENIE_TEAM;if(!team)console.error("Error: GENIE_TEAM not set. This command must be run by a QA team-lead agent."),process.exit(1);try{let{publish:publish2,close:close2}=await Promise.resolve().then(() => (init_nats_client(),exports_nats_client)),data=JSON.parse(json2);await publish2(`genie.qa.${team}.result`,data),await close2(),console.log(`QA result published to genie.qa.${team}.result`)}catch(err){console.error(`Failed to publish QA result: ${err}`),process.exit(1)}});program2.command("read <name>").description("Read terminal output from an agent pane").option("-n, --lines <number>","Number of lines to read").option("--from <line>","Start line").option("--to <line>","End line").option("--range <range>",'Line range (e.g., "10-20")').option("--search <text>","Search for text").option("--grep <pattern>","Grep for pattern").option("-f, --follow","Follow mode (like tail -f)").option("--all","Show all output").option("-r, --reverse","Reverse order").option("--json","Output as JSON").action(async(name,options)=>{await readSessionLogs2(name,options)});program2.command("answer <name> <choice>").description('Answer a question for an agent (use "text:..." for text input)').action(async(name,choice)=>{await answerQuestion(name,choice)});program2.command("ls").description("List registered agents with runtime status").option("--json","Output as JSON").action(async(options)=>{try{await handleLsCommand(options)}catch(error2){let message=error2 instanceof Error?error2.message:String(error2);console.error(`Error: ${message}`),process.exit(1)}});var args=process.argv.slice(2);if(args.length===0||args.every((a)=>a==="--reset")){let{sessionCommand:sessionCommand2}=await Promise.resolve().then(() => (init_session(),exports_session));await sessionCommand2({reset:args.includes("--reset")}),process.exit(0)}var sessionIdx=args.indexOf("--session");if(sessionIdx!==-1&&sessionIdx+1<args.length){let sessionName=args[sessionIdx+1];if(!args.filter((_,i2)=>i2!==sessionIdx&&i2!==sessionIdx+1).some((a)=>!a.startsWith("-")))try{await startNamedSession(sessionName),process.exit(0)}catch(err){console.error(`Error: ${err instanceof Error?err.message:err}`),process.exit(1)}else program2.parse()}else program2.parse();
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genie",
|
|
3
|
-
"version": "4.260324.
|
|
3
|
+
"version": "4.260324.13",
|
|
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"
|
|
@@ -408,20 +408,20 @@ export async function brainstormCommand(agentName: string, slug: string): Promis
|
|
|
408
408
|
console.log(`📝 Dispatching brainstorm to ${agentName} for "${slug}"`);
|
|
409
409
|
console.log(` Draft: ${draftPath}`);
|
|
410
410
|
|
|
411
|
+
const brainstormPrompt = `Brainstorm "${slug}". Your context is in the system prompt. Explore the idea, ask clarifying questions, and build toward a design.`;
|
|
411
412
|
await handleWorkerSpawn(agentName, {
|
|
412
413
|
provider: 'claude',
|
|
413
414
|
team: process.env.GENIE_TEAM ?? 'genie',
|
|
414
415
|
extraArgs: ['--append-system-prompt-file', contextFile],
|
|
416
|
+
initialPrompt: brainstormPrompt,
|
|
415
417
|
});
|
|
416
418
|
|
|
417
|
-
// Deliver work prompt via mailbox (durable, queued to disk)
|
|
419
|
+
// Deliver work prompt via mailbox as backup (durable, queued to disk)
|
|
418
420
|
const repoPath = process.cwd();
|
|
419
|
-
await protocolRouter.sendMessage(
|
|
420
|
-
|
|
421
|
-
'
|
|
422
|
-
|
|
423
|
-
`Brainstorm "${slug}". Your context is in the system prompt. Explore the idea, ask clarifying questions, and build toward a design.`,
|
|
424
|
-
);
|
|
421
|
+
const result = await protocolRouter.sendMessage(repoPath, 'cli', agentName, brainstormPrompt);
|
|
422
|
+
if (!result.delivered) {
|
|
423
|
+
console.warn(`⚠ Backup delivery to ${agentName} failed: ${result.reason ?? 'unknown'}`);
|
|
424
|
+
}
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
/**
|
|
@@ -448,20 +448,20 @@ export async function wishCommand(agentName: string, slug: string): Promise<void
|
|
|
448
448
|
console.log(`📝 Dispatching wish to ${agentName} for "${slug}"`);
|
|
449
449
|
console.log(` Design: ${designPath}`);
|
|
450
450
|
|
|
451
|
+
const wishPrompt = `Create a wish from the design for "${slug}". Your context is in the system prompt. Write the WISH.md with execution groups, acceptance criteria, and validation commands.`;
|
|
451
452
|
await handleWorkerSpawn(agentName, {
|
|
452
453
|
provider: 'claude',
|
|
453
454
|
team: process.env.GENIE_TEAM ?? 'genie',
|
|
454
455
|
extraArgs: ['--append-system-prompt-file', contextFile],
|
|
456
|
+
initialPrompt: wishPrompt,
|
|
455
457
|
});
|
|
456
458
|
|
|
457
|
-
// Deliver work prompt via mailbox (durable, queued to disk)
|
|
459
|
+
// Deliver work prompt via mailbox as backup (durable, queued to disk)
|
|
458
460
|
const repoPath = process.cwd();
|
|
459
|
-
await protocolRouter.sendMessage(
|
|
460
|
-
|
|
461
|
-
'
|
|
462
|
-
|
|
463
|
-
`Create a wish from the design for "${slug}". Your context is in the system prompt. Write the WISH.md with execution groups, acceptance criteria, and validation commands.`,
|
|
464
|
-
);
|
|
461
|
+
const result = await protocolRouter.sendMessage(repoPath, 'cli', agentName, wishPrompt);
|
|
462
|
+
if (!result.delivered) {
|
|
463
|
+
console.warn(`⚠ Backup delivery to ${agentName} failed: ${result.reason ?? 'unknown'}`);
|
|
464
|
+
}
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
/**
|
|
@@ -529,21 +529,21 @@ export async function workDispatchCommand(agentName: string, ref: string): Promi
|
|
|
529
529
|
console.log(` Group: ${group}`);
|
|
530
530
|
|
|
531
531
|
const effectiveRole = `${agentName}-${group}`;
|
|
532
|
+
const workPrompt = `Execute Group ${group} of wish "${slug}". Your full context is in the system prompt. Read the wish at ${wishPath} if needed. Implement all deliverables, run validation, and report completion.\n\nWhen done:\n1. Run: genie done ${slug}#${group}\n2. Run: genie send 'Group ${group} complete. <summary>' --to team-lead`;
|
|
532
533
|
await handleWorkerSpawn(agentName, {
|
|
533
534
|
provider: 'claude',
|
|
534
535
|
team: process.env.GENIE_TEAM ?? 'genie',
|
|
535
536
|
role: effectiveRole,
|
|
536
537
|
extraArgs: ['--append-system-prompt-file', contextFile],
|
|
538
|
+
initialPrompt: workPrompt,
|
|
537
539
|
});
|
|
538
540
|
|
|
539
|
-
// Deliver work prompt via mailbox (durable, queued to disk)
|
|
541
|
+
// Deliver work prompt via mailbox as backup (durable, queued to disk)
|
|
540
542
|
const repoPath = process.cwd();
|
|
541
|
-
await protocolRouter.sendMessage(
|
|
542
|
-
|
|
543
|
-
'
|
|
544
|
-
|
|
545
|
-
`Execute Group ${group} of wish "${slug}". Your full context is in the system prompt. Read the wish at ${wishPath} if needed. Implement all deliverables, run validation, and report completion.\n\nWhen done:\n1. Run: genie done ${slug}#${group}\n2. Run: genie send 'Group ${group} complete. <summary>' --to team-lead`,
|
|
546
|
-
);
|
|
543
|
+
const result = await protocolRouter.sendMessage(repoPath, 'cli', effectiveRole, workPrompt);
|
|
544
|
+
if (!result.delivered) {
|
|
545
|
+
console.warn(`⚠ Backup delivery to ${effectiveRole} failed: ${result.reason ?? 'unknown'}`);
|
|
546
|
+
}
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
/**
|
|
@@ -593,20 +593,20 @@ export async function reviewCommand(agentName: string, ref: string): Promise<voi
|
|
|
593
593
|
console.log(` Group: ${group}`);
|
|
594
594
|
if (diff) console.log(` Diff: ${diff.split('\n').length} lines`);
|
|
595
595
|
|
|
596
|
+
const reviewPrompt = `Review "${ref}". Your context and diff are in the system prompt. Evaluate against acceptance criteria and return SHIP, FIX-FIRST, or BLOCKED with severity-tagged findings.\n\nWhen done, report your verdict:\nRun: genie send '<SHIP|FIX-FIRST|BLOCKED> — <summary>' --to team-lead`;
|
|
596
597
|
await handleWorkerSpawn(agentName, {
|
|
597
598
|
provider: 'claude',
|
|
598
599
|
team: process.env.GENIE_TEAM ?? 'genie',
|
|
599
600
|
extraArgs: ['--append-system-prompt-file', contextFile],
|
|
601
|
+
initialPrompt: reviewPrompt,
|
|
600
602
|
});
|
|
601
603
|
|
|
602
|
-
// Deliver work prompt via mailbox (durable, queued to disk)
|
|
604
|
+
// Deliver work prompt via mailbox as backup (durable, queued to disk)
|
|
603
605
|
const repoPath = process.cwd();
|
|
604
|
-
await protocolRouter.sendMessage(
|
|
605
|
-
|
|
606
|
-
'
|
|
607
|
-
|
|
608
|
-
`Review "${ref}". Your context and diff are in the system prompt. Evaluate against acceptance criteria and return SHIP, FIX-FIRST, or BLOCKED with severity-tagged findings.\n\nWhen done, report your verdict:\nRun: genie send '<SHIP|FIX-FIRST|BLOCKED> — <summary>' --to team-lead`,
|
|
609
|
-
);
|
|
606
|
+
const result = await protocolRouter.sendMessage(repoPath, 'cli', agentName, reviewPrompt);
|
|
607
|
+
if (!result.delivered) {
|
|
608
|
+
console.warn(`⚠ Backup delivery to ${agentName} failed: ${result.reason ?? 'unknown'}`);
|
|
609
|
+
}
|
|
610
610
|
}
|
|
611
611
|
|
|
612
612
|
// ============================================================================
|
|
@@ -255,19 +255,23 @@ async function spawnLeaderWithWish(
|
|
|
255
255
|
}
|
|
256
256
|
console.log(` Team: hired ${standardTeam.join(', ')}`);
|
|
257
257
|
|
|
258
|
-
// Spawn leader — AGENTS.md comes from the built-in resolver, prompt delivered
|
|
258
|
+
// Spawn leader — AGENTS.md comes from the built-in resolver, prompt delivered as initialPrompt
|
|
259
|
+
const members = standardTeam.filter((r) => r !== 'team-lead').join(', ');
|
|
260
|
+
const kickoffPrompt = `Your team is "${config.name}". Repo: ${config.repo}. Branch: ${config.name}. Worktree: ${config.worktreePath}. Wish slug: ${slug}. Your team members are: ${members} (already hired — genie work will spawn them automatically). Read the wish at .genie/wishes/${slug}/WISH.md and execute the full lifecycle autonomously.`;
|
|
259
261
|
await handleWorkerSpawn('team-lead', {
|
|
260
262
|
provider: 'claude',
|
|
261
263
|
team: config.name,
|
|
262
264
|
cwd: config.worktreePath,
|
|
263
265
|
session: tmuxSession,
|
|
266
|
+
initialPrompt: kickoffPrompt,
|
|
264
267
|
});
|
|
265
268
|
|
|
266
|
-
// Deliver kickoff prompt via mailbox (durable, queued to disk)
|
|
267
|
-
const members = standardTeam.filter((r) => r !== 'team-lead').join(', ');
|
|
268
|
-
const kickoffPrompt = `Your team is "${config.name}". Repo: ${config.repo}. Branch: ${config.name}. Worktree: ${config.worktreePath}. Wish slug: ${slug}. Your team members are: ${members} (already hired — genie work will spawn them automatically). Read the wish at .genie/wishes/${slug}/WISH.md and execute the full lifecycle autonomously.`;
|
|
269
|
+
// Deliver kickoff prompt via mailbox as backup (durable, queued to disk)
|
|
269
270
|
const protocolRouter = await import('../lib/protocol-router.js');
|
|
270
|
-
await protocolRouter.sendMessage(config.worktreePath, 'cli', 'team-lead', kickoffPrompt);
|
|
271
|
+
const result = await protocolRouter.sendMessage(config.worktreePath, 'cli', 'team-lead', kickoffPrompt);
|
|
272
|
+
if (!result.delivered) {
|
|
273
|
+
console.warn(`⚠ Backup delivery to team-lead failed: ${result.reason ?? 'unknown'}`);
|
|
274
|
+
}
|
|
271
275
|
console.log(' Leader: spawned and working');
|
|
272
276
|
}
|
|
273
277
|
|