UNPKG

automagik-genie

Version:

Self-evolving AI agent orchestration framework with Model Context Protocol support

286 lines (285 loc) โ€ข 11.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildHelpView = buildHelpView; exports.buildSubcommandHelpView = buildSubcommandHelpView; exports.buildRunHelpView = buildRunHelpView; exports.buildTaskHelpView = buildTaskHelpView; exports.buildResumeHelpView = buildResumeHelpView; exports.buildListHelpView = buildListHelpView; exports.buildViewHelpView = buildViewHelpView; exports.buildStopHelpView = buildStopHelpView; exports.buildGeneralHelpView = buildGeneralHelpView; // Main help view function buildHelpView(params) { const lines = []; lines.push('# GENIE CLI'); lines.push(''); lines.push('*Genie Template :: Command Palette Quickstart*'); lines.push(''); // Meta badges const badges = [ params.backgroundDefault ? 'Background: detached default' : 'Background: attach by default', 'Plan โ†’ Wish โ†’ Forge workflow', 'Evidence-first outputs' ]; lines.push(badges.map(b => `**${b}**`).join(' ยท ')); lines.push(''); // Usage lines.push('๐Ÿงญ **Usage**'); lines.push(''); lines.push('Invoke commands with `genie <command> [options]`.'); lines.push(''); // Command table lines.push('## Command Palette'); lines.push(''); lines.push('| Command | Arguments | Description |'); lines.push('|---------|-----------|-------------|'); for (const row of params.commandRows) { lines.push(`| ${row.command} | ${row.args} | ${row.description} |`); } lines.push(''); // Prompt framework lines.push(`โ„น๏ธ **${params.promptFramework.title}**`); for (const bullet of params.promptFramework.bulletPoints) { lines.push(`โ€ข ${bullet}`); } lines.push(''); // Examples lines.push('โšก **Quick start examples**'); for (const example of params.examples) { lines.push(`- ${example}`); } lines.push(''); // Tips lines.push('๐Ÿ’ก **Tips**'); lines.push('- Watch tasks: `genie list tasks`.'); lines.push('- Run an agent: `genie run <agent-id> "<prompt>"`.'); return lines.join('\n'); } // Helper function to build subcommand help views function buildSubcommandHelpView(params) { const lines = []; lines.push(`# genie ${params.command}`); lines.push(''); lines.push(`*${params.description}*`); lines.push(''); // Usage lines.push('๐Ÿ“– **Usage**'); lines.push(''); lines.push(params.usage); lines.push(''); // Arguments if (params.arguments && params.arguments.length > 0) { lines.push('## Arguments'); lines.push(''); lines.push('| Argument | Description | Required |'); lines.push('|----------|-------------|----------|'); for (const arg of params.arguments) { const required = arg.required !== false ? 'Yes' : 'No'; lines.push(`| ${arg.name} | ${arg.description} | ${required} |`); } lines.push(''); } // Options if (params.options && params.options.length > 0) { lines.push('## Options'); lines.push(''); lines.push('| Option | Description |'); lines.push('|--------|-------------|'); for (const opt of params.options) { lines.push(`| ${opt.flag} | ${opt.description} |`); } lines.push(''); } // Examples if (params.examples && params.examples.length > 0) { lines.push('โšก **Examples**'); for (const example of params.examples) { lines.push(`- ${example}`); } lines.push(''); } // Notes if (params.notes && params.notes.length > 0) { lines.push('๐Ÿ’ก **Notes**'); for (const note of params.notes) { lines.push(`- ${note}`); } lines.push(''); } return lines.join('\n'); } // Specific help views for each subcommand function buildRunHelpView() { return buildSubcommandHelpView({ command: 'run', description: 'Start an agent task with browser UI + live monitoring', usage: 'genie run <agent> "<prompt>" [--help]', arguments: [ { name: '<agent>', description: 'Agent identifier (from genie list agents)' }, { name: '<prompt>', description: 'Initial prompt or task description' } ], options: [ { flag: '--executor, -x', description: 'Override executor for this run' }, { flag: '--model, -m', description: 'Override model for the selected executor' }, { flag: '--name, -n', description: 'Custom task name (defaults to agent-timestamp)' }, { flag: '--background, -b', description: 'Force background execution (default from config/agent)' }, { flag: '--help, -h', description: 'Show this help message' } ], examples: [ 'genie run code/analyze "[Discovery] mission @.genie/product/mission.md"', 'genie run code/review "Audit release branch for regressions"', 'genie run create/writer "Draft the launch announcement outline"', 'genie run code/commit "Stage and commit hotfix" --executor opencode --model gpt-4.1-coding' ], notes: [ 'Precedence: workspace defaults โ†’ agent front matter โ†’ CLI flags', 'Use quotes around prompts containing spaces or special characters', 'Agent identifiers can be found with: genie list agents', 'Executor/model values must exist in Forge or the workspace profile sync will fail' ] }); } function buildTaskHelpView() { return buildSubcommandHelpView({ command: 'task', description: 'Headless task execution (immediate JSON output, optional monitoring)', usage: 'genie task <agent> "<prompt>" | genie task monitor <attempt-id>', arguments: [ { name: '<agent>', description: 'Agent identifier (use genie list agents)' }, { name: '<prompt>', description: 'Detailed task description for the agent' } ], options: [ { flag: '--executor, -x', description: 'Override executor profile' }, { flag: '--model, -m', description: 'Override model for the selected executor' }, { flag: '--name, -n', description: 'Friendly task name (stored in tasks.json)' }, { flag: '--quiet', description: 'Suppress startup messages' }, { flag: '--help, -h', description: 'Show this help message' } ], examples: [ 'genie task implementor "Fix lint errors" --executor opencode', 'genie task master "Daily plan" --quiet', 'genie task monitor 0f4f0d07-1337-42b2-9d58-aaaa1111bbbb' ], notes: [ 'Use genie list tasks to find attempt IDs for monitoring/resume', 'Monitor subcommand streams WebSocket output without opening a browser', 'Outputs structured JSON so scripts can parse task_id/task_url/status' ] }); } function buildResumeHelpView() { return buildSubcommandHelpView({ command: 'resume', description: 'Continue an existing agent task', usage: 'genie resume <task-name> "<prompt>" [--help]', arguments: [ { name: '<task-name>', description: 'Task name from active or recent runs' }, { name: '<prompt>', description: 'Follow-up prompt or new task instruction' } ], options: [ { flag: '--help, -h', description: 'Show this help message' } ], examples: [ 'genie resume code-analyze-2510201015 "Follow up on the architectural risks"', 'genie resume code-review-2510201110 "Re-run the verification checklist"', 'genie resume create-writer-2510201205 "Add a release timeline section"' ], notes: [ 'Task names can be found with: genie list tasks', 'Only active or recently completed tasks can be resumed', 'Use quotes around prompts containing spaces or special characters' ] }); } function buildListHelpView() { return buildSubcommandHelpView({ command: 'list', description: 'Display available agents or active tasks', usage: 'genie list <target> [--help]', arguments: [ { name: '<target>', description: 'What to list: "collectives", "agents", "workflows", "skills", or "tasks"' } ], options: [ { flag: '--help, -h', description: 'Show this help message' } ], examples: [ 'genie list collectives', 'genie list agents', 'genie list tasks' ], notes: [ 'Default target is "collectives" if none specified', 'Tasks show both active runs and recent history', 'Agent list shows all available agents organized by collective' ] }); } function buildViewHelpView() { return buildSubcommandHelpView({ command: 'view', description: 'Show transcript and details for a task', usage: 'genie view <task-name> [--full] [--help]', arguments: [ { name: '<task-name>', description: 'Task name to display' } ], options: [ { flag: '--full', description: 'Show complete task transcript (default: recent messages)' }, { flag: '--help, -h', description: 'Show this help message' } ], examples: [ 'genie view implementor-2510181230', 'genie view plan-2510180915 --full' ], notes: [ 'Task names can be found with: genie list tasks', 'Default view shows recent conversation; use --full for complete history', 'Includes task metadata like execution mode and background status' ] }); } function buildStopHelpView() { return buildSubcommandHelpView({ command: 'stop', description: 'End a running background task', usage: 'genie stop <task-name> [--help]', arguments: [ { name: '<task-name>', description: 'Task name to stop' } ], options: [ { flag: '--help, -h', description: 'Show this help message' } ], examples: [ 'genie stop implementor-2510181230', 'genie stop plan-2510180915' ], notes: [ 'Only affects running background tasks', 'Task names can be found with: genie list tasks', 'Stopped tasks can still be viewed but not resumed' ] }); } function buildGeneralHelpView() { return buildSubcommandHelpView({ command: 'help', description: 'Show help information for commands', usage: 'genie help [<command>] [--help]', arguments: [ { name: '<command>', description: 'Specific command to get help for', required: false } ], options: [ { flag: '--help, -h', description: 'Show this help message' } ], examples: [ 'genie help', 'genie help run', 'genie help list' ], notes: [ 'Without arguments, shows the main command palette', 'With a command name, shows detailed help for that command', 'Most commands also accept --help or -h for quick access' ] }); }