### Install Dependencies Source: https://github.com/b08x/gitagent-workbench/blob/main/README.md Run this command in your project directory to install all necessary Node.js dependencies. ```bash npm install ``` -------------------------------- ### Run the App Locally Source: https://github.com/b08x/gitagent-workbench/blob/main/README.md Execute this command to start the development server and run your AI Studio app locally. Ensure you have set the GEMINI_API_KEY. ```bash npm run dev ``` -------------------------------- ### Run Full Agent Generation Pipeline Source: https://context7.com/b08x/gitagent-workbench/llms.txt Orchestrates all generation steps and yields progress events. Configure with provider, model, and context limit. Handles events for step start, progress, completion, and errors. ```typescript import { runGeneration, OrchestratorConfig } from './lib/generation/orchestrator'; import { AgentWorkspace } from './lib/gitagent/types'; // Configure the generation const config: OrchestratorConfig = { providerId: 'anthropic', apiKey: 'sk-ant-...', modelId: 'claude-3-5-sonnet-20240620', fallbackModelIds: ['openai/gpt-4o', 'google/gemini-1.5-pro'], contextLimit: 100000 // Token limit for context window }; // Initial workspace with user inputs const workspace: AgentWorkspace = { meta: { structureType: 'standard', status: 'intake', currentStep: null, lastDownloadedAt: null }, manifest: { name: 'research-agent', version: '0.1.0', description: 'AI research assistant' }, soul: null, rules: null, prompt_md: null, duties: null, skills: {}, tools: {}, // ... other fields }; // Run generation and handle events for await (const event of runGeneration(workspace, config)) { switch (event.status) { case 'start': console.log(`Starting step: ${event.step}`); break; case 'progress': console.log(`${event.step}: ${event.content}`); break; case 'done': console.log(`Completed: ${event.step}`); if (event.workspace) { // Updated workspace with generated content workspace = event.workspace; } break; case 'error': console.error(`Error in ${event.step}: ${event.content}`); break; } } ``` -------------------------------- ### GET /api/providers - Check Provider Status Source: https://context7.com/b08x/gitagent-workbench/llms.txt Retrieves the availability status of configured AI providers, indicating whether their respective API keys are set. ```APIDOC ## GET /api/providers ### Description Returns the availability status of all configured AI providers based on whether API keys are set. ### Method GET ### Endpoint /api/providers ### Response #### Success Response (200) - **providerName** (boolean) - Indicates if the API key for the provider is set (true) or not (false). ### Response Example ```json { "openai": true, "anthropic": true, "google": false, "mistral": false, "groq": true, "openrouter": true } ``` ``` -------------------------------- ### Set Gemini API Key Source: https://github.com/b08x/gitagent-workbench/blob/main/README.md Configure your Gemini API key by adding it to the .env.local file. This is required for the application to authenticate with the Gemini API. ```bash GEMINI_API_KEY ``` -------------------------------- ### Configure Generation Steps Source: https://context7.com/b08x/gitagent-workbench/llms.txt Defines all available generation steps and retrieves steps applicable to a workspace based on its structure type. Different structure types ('minimal', 'standard', 'full') affect which steps are executed. ```typescript import { GENERATION_STEPS, getApplicableSteps } from './lib/generation/steps'; // All available steps const steps = [ { id: 'SANITIZE_INPUTS', label: 'Sanitizing Inputs', isCritical: true }, { id: 'GEN_YAML', label: 'Generating YAML Manifest', isCritical: true }, { id: 'GEN_SOUL', label: 'Defining Agent Soul', isCritical: true }, { id: 'GEN_INSTRUCTIONS', label: 'Generating Core Instructions', isCritical: true }, { id: 'GEN_CONFIG', label: 'Configuring Agent Runtime', isCritical: false }, { id: 'GEN_SKILLS', label: 'Generating Skill Logic', isCritical: false }, { id: 'GEN_KNOWLEDGE_DOCS', label: 'Drafting Knowledge Docs', isCritical: false }, { id: 'GEN_TOOLS', label: 'Defining Tool Schemas', isCritical: true }, { id: 'GEN_SUBAGENTS', label: 'Configuring Sub-Agents', isCritical: false }, { id: 'GEN_WORKFLOWS', label: 'Planning Workflows', isCritical: false }, { id: 'GEN_EXAMPLES', label: 'Generating Examples', isCritical: false }, { id: 'VALIDATE_OUT', label: 'Final Validation', isCritical: true } ]; // Get steps applicable to a workspace based on structure type const applicableSteps = getApplicableSteps(workspace); // 'minimal' structure skips: GEN_INSTRUCTIONS, GEN_WORKFLOWS, GEN_EXAMPLES // 'standard' structure skips: GEN_WORKFLOWS, GEN_EXAMPLES // 'full' structure runs all steps ``` -------------------------------- ### Generate Skill Instructions using LLM Source: https://context7.com/b08x/gitagent-workbench/llms.txt Generates skill instructions using the configured LLM provider. This function is an asynchronous generator that yields progress events. ```typescript import { generateSkillInstructions } from './lib/generation/skill-generator'; const skill = { id: 'unique-id', name: 'data-analysis', description: 'Analyze datasets and generate insights', allowedTools: ['read_file', 'execute_code', 'web_search'], metadata: { category: 'data' }, instructions: '', references: [], examples: [], scripts: [] }; for await (const event of generateSkillInstructions(skill, workspace, config)) { if (event.status === 'progress') { console.log('Generating:', event.content); } else if (event.status === 'done') { skill.instructions = event.content; } else if (event.status === 'error') { console.error('Generation failed:', event.content); } } ``` -------------------------------- ### Generate Text with LLM Source: https://context7.com/b08x/gitagent-workbench/llms.txt Generates text using a specified LLM model and provider. Supports optional structured output via Zod schemas for precise response formatting. The `prompt` object can include `system`, `user`, and `schema` properties. ```typescript // Generate agent YAML manifest with structured output const response = await fetch('/api/generate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt: { system: 'You are an agent manifest generator. Output valid YAML.', user: 'Generate a manifest for an agent named "research-assistant" that helps with academic research.', schema: AgentManifestSchema // Optional Zod schema for structured output }, modelId: 'claude-3-5-sonnet-20240620', providerId: 'anthropic', options: { temperature: 0.3, maxTokens: 4096 } }) }); const result = await response.json(); // { "text": "...", "object": { name: "research-assistant", version: "0.1.0", ... } } ``` -------------------------------- ### Assemble CLAUDE.md for Claude Code Source: https://context7.com/b08x/gitagent-workbench/llms.txt Use this function to generate a CLAUDE.md file optimized for Claude Code and Cursor. Ensure the workspace object is correctly structured. ```typescript import { assembleCLAUDEmd } from './lib/gitagent/assembleCLAUDEmd'; const claudeMd = assembleCLAUDEmd(workspace); // Output format: // # agent-name — Description // // ## Soul // // // ## Rules // // // ## Skills // ### skill-name // Description // Allowed tools: tool1 tool2 // Full instructions: skills/skill-name/SKILL.md // // ## Tools // ### tool-name // Description // Input schema: // type: object // properties: ... // // ## Compliance // Risk tier: standard // Human oversight: conditional ``` -------------------------------- ### Serialize Workspace to ZIP Package Source: https://context7.com/b08x/gitagent-workbench/llms.txt Exports the agent workspace into a complete ZIP package compliant with gitagent specifications. This includes serializing the workspace to a blob and optionally downloading it in a browser environment. ```typescript import { serializeWorkspace, downloadZip } from './lib/gitagent/serializer'; // Serialize workspace to ZIP blob const blob = await serializeWorkspace(workspace); // Download in browser const filename = `${workspace.manifest.name}-v${workspace.manifest.version}.zip`; downloadZip(blob, filename); // ZIP structure generated: // agent.yaml - Main manifest // SOUL.md - Agent identity // RULES.md - Behavioral constraints // PROMPT.md - System prompt content // DUTIES.md - Role definitions // config.yaml - Hermes runtime config // skills/ // skill-name/ // SKILL.md - Skill instructions with YAML frontmatter // references/README.md // templates/README.md // scripts/README.md // examples/example-1.md // tools/ // tool-name.yaml - MCP-compatible tool schema // knowledge/ // index.yaml - Knowledge document index // docs/ - Knowledge documents // memory/ // memory.yaml - Memory layer config // MEMORY.md - Session memory // agents/ - Sub-agent configurations ``` -------------------------------- ### Manage Workspace Snapshots for Persistence Source: https://context7.com/b08x/gitagent-workbench/llms.txt Utilize these functions to save, load, and clear workspace snapshots using `localStorage`. This is useful for auto-saving progress or restoring the workspace state on page load. ```typescript import { saveWorkspaceSnapshot, loadWorkspaceSnapshot, clearWorkspaceSnapshot } from './lib/generation/persistence'; // Auto-save after each generation step saveWorkspaceSnapshot(workspace); // Restore on page load const savedWorkspace = loadWorkspaceSnapshot(); if (savedWorkspace) { dispatch({ type: 'SET_WORKSPACE', payload: savedWorkspace }); } // Clear storage clearWorkspaceSnapshot(); ``` -------------------------------- ### Generate Hermes Agent Runtime Configuration Source: https://context7.com/b08x/gitagent-workbench/llms.txt Use this function to generate a `config.yaml` file for the Hermes agent runtime. Ensure all necessary workspace properties like deployment targets, tool permissions, and generation configuration are set before calling. ```typescript import { generateHermesConfig } from './lib/gitagent/config-generator'; // Workspace with deployment targets and tool permissions workspace.deploymentTargets = ['cli', 'telegram', 'discord']; workspace.toolPermissions = { matrix: { 'web_search': { cli: true, telegram: true, discord: false }, 'terminal': { cli: true, telegram: false, discord: false }, 'read_file': { cli: true, telegram: true, discord: true } } }; workspace.generationConfig = { providerId: 'openrouter', modelId: 'anthropic/claude-3-5-sonnet-20240620' }; const configYaml = generateHermesConfig(workspace); ``` -------------------------------- ### POST /api/generate - Generate Text with LLM Source: https://context7.com/b08x/gitagent-workbench/llms.txt Generates text using a specified LLM model and provider, with optional structured output using Zod schemas. ```APIDOC ## POST /api/generate ### Description Generates text using the specified model and provider with optional structured output via Zod schemas. ### Method POST ### Endpoint /api/generate ### Parameters #### Request Body - **prompt** (object) - Required - The prompt object containing system, user, and optional schema. - **system** (string) - Optional - The system message for the LLM. - **user** (string) - Required - The user message for the LLM. - **schema** (object) - Optional - A Zod schema for structured output. - **modelId** (string) - Required - The identifier of the LLM model to use (e.g., 'claude-3-5-sonnet-20240620'). - **providerId** (string) - Required - The identifier of the AI provider (e.g., 'anthropic', 'openai'). - **options** (object) - Optional - Generation options. - **temperature** (number) - Optional - The sampling temperature. - **maxTokens** (number) - Optional - The maximum number of tokens to generate. ### Request Example ```json { "prompt": { "system": "You are an agent manifest generator. Output valid YAML.", "user": "Generate a manifest for an agent named \"research-assistant\" that helps with academic research.", "schema": "AgentManifestSchema" }, "modelId": "claude-3-5-sonnet-20240620", "providerId": "anthropic", "options": { "temperature": 0.3, "maxTokens": 4096 } } ``` ### Response #### Success Response (200) - **text** (string) - The generated text output. - **object** (object) - The structured output if a schema was provided. ### Response Example ```json { "text": "...", "object": { "name": "research-assistant", "version": "0.1.0", ... } } ``` ``` -------------------------------- ### POST /api/keys - Store Provider API Key Source: https://context7.com/b08x/gitagent-workbench/llms.txt Stores an API key for a specified AI provider in the server's session memory. ```APIDOC ## POST /api/keys ### Description Stores an API key for a specific provider in the server's session memory. ### Method POST ### Endpoint /api/keys ### Parameters #### Request Body - **providerId** (string) - Required - The unique identifier of the AI provider (e.g., 'anthropic', 'openai'). - **key** (string) - Required - The API key for the specified provider. ### Request Example ```json { "providerId": "anthropic", "key": "sk-ant-api03-..." } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the API key was stored successfully. ### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Parse SKILL.md Files with YAML Frontmatter Source: https://context7.com/b08x/gitagent-workbench/llms.txt Parses SKILL.md files, extracting structured skill objects from YAML frontmatter and markdown content. Also includes a utility to resolve GitHub raw URLs for skill imports. ```typescript import { parseSkillMd, resolveGitHubRawUrl } from './lib/gitagent/parseSkillMd'; const skillContent = `--- name: code-review description: Expert code reviewer for Python license: MIT allowed-tools: read_file patch terminal metadata: hermes: category: code --- # Code Review Instructions 1. Analyze the code structure 2. Check for best practices 3. Suggest improvements `; const { skill, warnings, hasFrontmatter } = parseSkillMd(skillContent); // skill = { // name: 'code-review', // description: 'Expert code reviewer for Python', // license: 'MIT', // allowedTools: ['read_file', 'patch', 'terminal'], // instructions: '# Code Review Instructions\n\n1. Analyze the code structure...', // category: 'code', // references: [] // } // Resolve GitHub URLs for skill import const rawUrl = resolveGitHubRawUrl('owner/repo#skills/my-skill'); // Returns: https://raw.githubusercontent.com/owner/repo/main/skills/my-skill/SKILL.md ``` -------------------------------- ### Validate Agent Configuration Workspace Source: https://context7.com/b08x/gitagent-workbench/llms.txt Validates the complete workspace against gitagent schema requirements, returning detailed errors and warnings. Use this to ensure agent configurations are correct. ```typescript import { validateWorkspace } from './lib/generation/validator'; const result = validateWorkspace(workspace); // result = { // valid: false, // errors: [ // { file: 'agent.yaml', field: 'name', message: 'Name "My Agent" must be kebab-case' }, // { file: 'skills/research/SKILL.md', message: 'Skill "research" declared in agent.yaml but not generated' }, // { file: 'agent.yaml', field: 'compliance.recordkeeping', message: 'compliance.recordkeeping is required for high/critical risk_tier' } // ], // warnings: [ // { file: 'DUTIES.md', message: 'DUTIES.md is recommended for high/critical risk_tier agents' }, // { file: 'skills/helper/SKILL.md', message: 'Skill "helper" exists in workspace but not declared in agent.yaml skills[]' } // ] // } if (!result.valid) { result.errors.forEach(err => console.error(`${err.file}: ${err.message}`)); } ``` -------------------------------- ### Parse CLAUDE.md from CLAUDE.md File Source: https://context7.com/b08x/gitagent-workbench/llms.txt Parses a CLAUDE.md file into a partial workspace structure. This is useful for importing agent configurations from existing CLAUDE.md files. ```typescript import { parseCLAUDEmd } from './lib/gitagent/parseCLAUDEmd'; const content = `# my-agent — A helpful assistant ## Soul I am a helpful assistant focused on productivity. ## Rules 1. Always be concise 2. Cite sources ## Skills ### research Expert at finding information Allowed tools: web_search read_file Full instructions: skills/research/SKILL.md `; const { partial, warnings } = parseCLAUDEmd(content); // partial.manifest = { name: 'my-agent', description: 'A helpful assistant', version: '0.1.0' } // partial.soul = 'I am a helpful assistant focused on productivity.' // partial.rules = '1. Always be concise\n2. Cite sources' // partial.skills = { research: { name: 'research', description: 'Expert at finding information', ... } } ``` -------------------------------- ### Manage Agent Workspace State with React Context Source: https://context7.com/b08x/gitagent-workbench/llms.txt This React hook and provider facilitate managing the agent workspace state. Use `AgentProvider` to wrap your application and `useAgentWorkspace` within components to access and dispatch actions for state updates. ```typescript import { useAgentWorkspace, AgentProvider } from './app/context/AgentContext'; // Wrap your app with the provider function App() { return ( ); } // Use the workspace in components function AgentWorkbench() { const { state, dispatch } = useAgentWorkspace(); // Update manifest dispatch({ type: 'UPDATE_MANIFEST', payload: { name: 'my-agent', description: 'A helpful assistant' } }); // Update entire workspace section dispatch({ type: 'UPDATE_WORKSPACE', payload: { skillsList: [ { name: 'research', description: 'Research skill', instructions: '...', category: 'research' } ], complianceConfig: { risk_tier: 'high', supervision: { human_in_the_loop: 'always', kill_switch: true, override_capability: true }, recordkeeping: { audit_logging: true, retention_period: '7y', log_format: 'structured_json' } } } }); // Set template type dispatch({ type: 'SET_TEMPLATE', payload: 'data-analyst' }); // Add skill from import dispatch({ type: 'ADD_SKILL', payload: { name: 'imported-skill', description: '...', instructions: '...', allowedTools: [], category: 'general', references: [] } }); // Save/restore snapshots dispatch({ type: 'SAVE_SNAPSHOT', payload: 'Before major changes' }); dispatch({ type: 'RESTORE_SNAPSHOT', payload: 1699999999999 }); // timestamp return (

{state.manifest.name}

Status: {state.meta.status}

Skills: {Object.keys(state.skills).length}

); } ``` -------------------------------- ### POST /api/stream - Stream Text Generation Source: https://context7.com/b08x/gitagent-workbench/llms.txt Streams text generation results in real-time using Server-Sent Events. ```APIDOC ## POST /api/stream ### Description Streams text generation using Server-Sent Events for real-time output. ### Method POST ### Endpoint /api/stream ### Parameters #### Request Body - **prompt** (object) - Required - The prompt object containing system and user messages. - **system** (string) - Optional - The system message for the LLM. - **user** (string) - Required - The user message for the LLM. - **modelId** (string) - Required - The identifier of the LLM model to use (e.g., 'gpt-4o'). - **providerId** (string) - Required - The identifier of the AI provider (e.g., 'openai'). - **options** (object) - Optional - Generation options. - **temperature** (number) - Optional - The sampling temperature. ### Request Example ```json { "prompt": { "system": "You are writing the SOUL.md for an AI agent. Define its core identity.", "user": "Create SOUL.md for \"code-reviewer\" agent focused on Python best practices." }, "modelId": "gpt-4o", "providerId": "openai", "options": { "temperature": 0.7 } } ``` ### Response #### Success Response (200) Server-Sent Events stream containing chunks of generated text. ### Response Example ``` data: {"chunk": "The agent \"code-reviewer\" is designed to..."} data: {"chunk": " It focuses on adhering to PEP 8..."} data: [DONE] ``` ``` -------------------------------- ### AgentManifest Interface Definition Source: https://context7.com/b08x/gitagent-workbench/llms.txt Defines the schema for an AgentManifest, specifying configuration options for AI agents including metadata, skills, tools, model constraints, and compliance settings. Use this interface to ensure agent configurations adhere to the gitagent specification. ```typescript interface AgentManifest { name: string; // kebab-case identifier version: string; // semver format description: string; spec_version?: string; author?: string; license?: string; extends?: string; // Parent agent to inherit from skills?: string[]; // Declared skill names tools?: string[]; // Declared tool names model?: { preferred?: string; fallback?: string[]; constraints?: { temperature?: number; max_tokens?: number; top_p?: number; }; }; compliance?: { risk_tier: 'low' | 'standard' | 'high' | 'critical'; frameworks?: string[]; supervision?: { human_in_the_loop: 'always' | 'conditional' | 'advisory' | 'none'; kill_switch?: boolean; override_capability?: boolean; }; recordkeeping?: { audit_logging?: boolean; log_format?: 'structured_json' | 'plaintext'; retention_period?: string; }; }; deployment_targets?: string[]; tags?: string[]; } ``` -------------------------------- ### Stream Text Generation with SSE Source: https://context7.com/b08x/gitagent-workbench/llms.txt Streams text generation results in real-time using Server-Sent Events (SSE). This is useful for progressive output, such as generating agent documentation or code. The response is processed chunk by chunk. ```typescript // Stream agent SOUL.md generation const response = await fetch('/api/stream', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt: { system: 'You are writing the SOUL.md for an AI agent. Define its core identity.', user: 'Create SOUL.md for "code-reviewer" agent focused on Python best practices.' }, modelId: 'gpt-4o', providerId: 'openai', options: { temperature: 0.7 } }) }); const reader = response.body.getReader(); const decoder = new TextDecoder(); let content = ''; while (true) { const { done, value } = await reader.read(); if (done) break; const chunk = decoder.decode(value); const lines = chunk.split(' '); for (const line of lines) { if (line.startsWith('data: ')) { const data = line.slice(6); if (data === '[DONE]') break; const parsed = JSON.parse(data); if (parsed.chunk) { content += parsed.chunk; console.log(content); // Progressive output } } } } ``` -------------------------------- ### Check AI Provider Status Source: https://context7.com/b08x/gitagent-workbench/llms.txt Use this endpoint to verify which AI providers have API keys configured. The response indicates availability with a boolean value for each provider. ```typescript // Check which providers have API keys configured const response = await fetch('/api/providers'); const status = await response.json(); // Response format: { "openai": true, // API key is set "anthropic": true, "google": false, // No API key configured "mistral": false, "groq": true, "openrouter": true } ``` -------------------------------- ### AgentWorkspace Type Definition Source: https://context7.com/b08x/gitagent-workbench/llms.txt Defines the core structure of the `AgentWorkspace`, including metadata, manifest, skills, tools, and configuration for generation and deployment. ```typescript interface AgentWorkspace { meta: { structureType: 'minimal' | 'standard' | 'full' | 'data-analyst' | 'web-scraper' | 'researcher'; status: 'intake' | 'generating' | 'validating' | 'complete' | 'error'; currentStep: string | null; lastDownloadedAt: Date | null; }; manifest: Partial; soul: string | null; rules: string | null; prompt_md: string | null; duties: string | null; skills: Record; tools: Record; workflows: Record; knowledge: KnowledgeIndex | null; memory: MemoryConfig | null; subAgents: Record; deploymentTargets: Array<'cli' | 'telegram' | 'discord' | 'slack' | 'api' | 'background' | 'homeassistant'>; generationConfig: { providerId: string; modelId: string; fallbackModelIds?: string[]; }; validationResult: ValidationResult | null; } ``` -------------------------------- ### Store AI Provider API Key Source: https://context7.com/b08x/gitagent-workbench/llms.txt This endpoint stores an API key for a specified AI provider in the server's session memory. Ensure the request body includes the correct `providerId` and `key`. ```typescript // Set an API key for a provider const response = await fetch('/api/keys', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ providerId: 'anthropic', key: 'sk-ant-api03-...' }) }); const result = await response.json(); // { "success": true } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.