summaryrefslogtreecommitdiff
path: root/internal/appconfig
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-12 09:32:26 +0200
committerPaul Buetow <paul@buetow.org>2026-02-12 09:32:26 +0200
commitcfd02d2874992f7e293d5098bd328a495825a8d4 (patch)
treebb241a61ce35c717c16539ab5d4413264514168d /internal/appconfig
parent0cd9db181218eaf0fb1ec1cddcd83035d984e94c (diff)
feat: add automatic MCP prompt to slash command syncing
Adds optional syncing of MCP prompts to Markdown slash command files for AI agents that don't yet support MCP prompts (e.g., Cursor IDE). Features: - Syncs prompts on create/update/delete operations - Configurable via TOML config, environment vars, or CLI flags - Backfill support with --sync-all flag - Thread-safe atomic file writes - Non-fatal sync failures (logged but don't break operations) - Comprehensive test coverage (81.1% total) Configuration: - Config: [mcp] slashcommand_sync = true, slashcommand_dir = "~/.cursor/commands" - Env: HEXAI_MCP_SLASHCOMMAND_SYNC, HEXAI_MCP_SLASHCOMMAND_DIR - CLI: --slashcommand-sync, --slashcommand-dir, --sync-all Fixes config merging bug where project config would reset global MCP settings. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/appconfig')
-rw-r--r--internal/appconfig/config.go33
1 files changed, 31 insertions, 2 deletions
diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go
index 8ae9597..490ed4e 100644
--- a/internal/appconfig/config.go
+++ b/internal/appconfig/config.go
@@ -126,7 +126,9 @@ type App struct {
TmuxEditAgents []TmuxEditAgentCfg `json:"-" toml:"-"`
// MCP: Model Context Protocol server settings
- MCPPromptsDir string `json:"-" toml:"-"` // Directory for prompt storage
+ MCPPromptsDir string `json:"-" toml:"-"` // Directory for prompt storage
+ MCPSlashCommandSync bool `json:"-" toml:"-"` // Enable slash command sync
+ MCPSlashCommandDir string `json:"-" toml:"-"` // Directory for slash command files
}
// CustomAction describes a user-defined code action.
@@ -383,7 +385,9 @@ type sectionTmuxEditAgent struct {
// sectionMCP configures the MCP server settings.
type sectionMCP struct {
- PromptsDir string `toml:"prompts_dir"`
+ PromptsDir string `toml:"prompts_dir"`
+ SlashCommandSync bool `toml:"slashcommand_sync"`
+ SlashCommandDir string `toml:"slashcommand_dir"`
}
type sectionOpenAI struct {
@@ -719,6 +723,12 @@ func (fc *fileConfig) toApp() App {
if strings.TrimSpace(fc.MCP.PromptsDir) != "" {
out.MCPPromptsDir = strings.TrimSpace(fc.MCP.PromptsDir)
}
+ if fc.MCP.SlashCommandSync {
+ out.MCPSlashCommandSync = fc.MCP.SlashCommandSync
+ }
+ if strings.TrimSpace(fc.MCP.SlashCommandDir) != "" {
+ out.MCPSlashCommandDir = strings.TrimSpace(fc.MCP.SlashCommandDir)
+ }
return out
}
@@ -1058,6 +1068,16 @@ func (a *App) mergeBasics(other *App) {
if other.IgnoreLSPNotify != nil {
a.IgnoreLSPNotify = other.IgnoreLSPNotify
}
+ // MCP settings
+ if s := strings.TrimSpace(other.MCPPromptsDir); s != "" {
+ a.MCPPromptsDir = s
+ }
+ if other.MCPSlashCommandSync {
+ a.MCPSlashCommandSync = other.MCPSlashCommandSync
+ }
+ if s := strings.TrimSpace(other.MCPSlashCommandDir); s != "" {
+ a.MCPSlashCommandDir = s
+ }
}
// mergeSurfaceModels copies per-surface model and temperature overrides.
@@ -1599,6 +1619,15 @@ func loadFromEnv(logger *log.Logger) *App {
out.MCPPromptsDir = s
any = true
}
+ if s := getenv("HEXAI_MCP_SLASHCOMMAND_SYNC"); s != "" {
+ b := s == "true" || s == "1"
+ out.MCPSlashCommandSync = b
+ any = true
+ }
+ if s := getenv("HEXAI_MCP_SLASHCOMMAND_DIR"); s != "" {
+ out.MCPSlashCommandDir = s
+ any = true
+ }
if !any {
return nil