Skip to content

Conversation

@vapi-tasker
Copy link

@vapi-tasker vapi-tasker bot commented Jan 17, 2026

Summary

This PR adds GitOps functionality to the Vapi CLI, enabling infrastructure-as-code workflows for managing Vapi resources (Assistants, Tools, Structured Outputs).

  • Migrates the GitOps TypeScript implementation from VapiAI/gitops to native Go
  • Adds three new commands: init, pull, and apply
  • Supports declarative YAML configuration with automatic reference resolution

Changes

New Commands

Command Description
vapi gitops init [path] Initialize a new GitOps project with directory structure and example files
vapi gitops pull Pull all resources from Vapi and save as local YAML files
vapi gitops apply Apply local YAML changes to Vapi (create, update, delete)

Key Features

  • Declarative YAML - Define resources in version-controlled YAML files
  • Reference Resolution - Use human-readable resource IDs instead of UUIDs (e.g., my-weather-tool550e8400-e29b-41d4-...)
  • State Management - .vapi-state.json tracks UUID mappings for existing resources
  • Dependency Ordering - Resources applied in correct order (tools → structured outputs → assistants)
  • Nested Folders - Organize resources in subdirectories (e.g., tools/production/, tools/staging/)
  • Inline Comments - Add comments to references: my-tool ## Weather API integration
  • Orphan Detection - Safe deletion of resources removed from filesystem
  • Two-Pass Linking - Handles circular dependencies (e.g., handoff tools referencing assistants)

Files Added

cmd/gitops.go                    # CLI commands
pkg/gitops/
├── types.go                     # Core type definitions
├── config.go                    # Configuration and paths
├── state.go                     # State file management
├── resources.go                 # YAML loading/writing
├── resolver.go                  # Reference resolution
├── api.go                       # Vapi API client
├── apply.go                     # Apply engine
├── pull.go                      # Pull engine
├── init.go                      # Project scaffolding
└── *_test.go                    # Unit tests

Example Workflow

# Initialize project
vapi gitops init my-project
cd my-project

# Configure API key
cp .env.example .env
# Edit .env with your VAPI_TOKEN

# Pull existing resources
vapi gitops pull

# Edit YAML files...
# resources/assistants/my-assistant.yaml
# resources/tools/weather-tool.yaml

# Apply changes
vapi gitops apply

Example Resource File

# resources/assistants/support-bot.yaml
name: Support Bot
model:
  provider: openai
  model: gpt-4o
  messages:
    - role: system
      content: You are a helpful support assistant.
  toolIds:
    - weather-tool ## Get weather information
    - calendar-tool
firstMessage: Hello! How can I help you today?
voice:
  provider: 11labs
  voiceId: 21m00Tcm4TlvDq8ikWAM

Testing

Unit tests added for all core modules:

  • types_test.go - State management and type operations
  • config_test.go - Configuration and path handling
  • state_test.go - State persistence
  • resources_test.go - YAML loading and resource ID generation
  • resolver_test.go - Reference resolution
  • init_test.go - Project initialization

Related

  • Linear: VAP-11263
  • Original TypeScript implementation: VapiAI/gitops

🤖 Generated with Claude Code

This PR adds GitOps functionality to the Vapi CLI, enabling infrastructure-as-code
workflows for managing Vapi resources (Assistants, Tools, Structured Outputs).

Commands:
- `vapi gitops init [path]` - Initialize a new GitOps project structure
- `vapi gitops pull` - Pull resources from Vapi to local YAML files
- `vapi gitops apply` - Apply local YAML changes to Vapi

Features:
- Declarative YAML configuration for all resource types
- Automatic reference resolution (resource IDs → UUIDs)
- State file tracking (.vapi-state.json) for UUID mappings
- Dependency-ordered operations (tools → outputs → assistants)
- Nested folder organization support
- Inline comment support (## comments in references)
- Orphan detection with safe deletion
- Two-pass linking for circular dependencies (e.g., handoff tools)

Migrated from VapiAI/gitops TypeScript implementation to native Go.

Resolves: VAP-11263

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant