CLI Engine
Vectora uses the Cobra framework for its CLI. Cobra and Systray coexist in the same daemon binary — the CLI provides automation/scripting while Systray provides the visual interface, both synchronized in real-time through shared in-memory state.
Command Architecture
The CLI is organized into a command tree, where the base vectora command acts as the main entry point, delegating functions to specialized subcommands.
graph TD
Root[vectora] --> Auth[auth]
Root --> Config[config]
Root --> Index[index]
Root --> MCP[mcp]
Root --> Service[service]
Auth --> Login[login]
Auth --> Logout[logout]
Config --> Set[set]
Config --> List[list]
Service --> Install[install]
Service --> Uninstall[uninstall]
Why Cobra?
- Nested Subcommands: Allows creating clear namespaces like
vectora auth logininstead of complex flags. - Global vs. Local Flags: Flags like
--debugor--configcan be accessed by any command, while flags like--forceare exclusive toindex. - Smart Suggestions: Provides automatic suggestions (“Did you mean…?”) for mistyped commands.
- Shell Completion: Automatically generates completion scripts for Bash, Zsh, Fish, and PowerShell.
Technical Implementation
Each command in Vectora is defined as an instance of &cobra.Command. The execution logic is kept separate from main.go, residing in directories like cmd/ and functionally linked to the pkg/core package.
Command Structure Example (Go Mockup)
var indexCmd = &cobra.Command{
Use: "index [path]",
Short: "Indexes files in the current namespace",
Run: func(cmd *cobra.Command, args []string) {
// Indexing logic calling the Context Engine
},
}Systray Integration
Systray and CLI coexist in the same daemon process. Actions in the CLI (like vectora auth login) instantly update the Systray UI state through shared memory — no separate process or IPC needed. See Systray UX for details on the unified architecture.
Part of the Vectora ecosystem · Open Source (MIT) · Contributors