From cfd02d2874992f7e293d5098bd328a495825a8d4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 12 Feb 2026 09:32:26 +0200 Subject: 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 --- internal/hexaimcp/run_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'internal/hexaimcp/run_test.go') diff --git a/internal/hexaimcp/run_test.go b/internal/hexaimcp/run_test.go index 2adf678..794fa1f 100644 --- a/internal/hexaimcp/run_test.go +++ b/internal/hexaimcp/run_test.go @@ -15,6 +15,7 @@ import ( "codeberg.org/snonux/hexai/internal/appconfig" "codeberg.org/snonux/hexai/internal/mcp" "codeberg.org/snonux/hexai/internal/promptstore" + "codeberg.org/snonux/hexai/internal/slashcommands" ) // mockServerRunner implements ServerRunner for testing @@ -34,8 +35,8 @@ func TestFullProtocolFlow(t *testing.T) { tmpDir := t.TempDir() // Create test server factory - serverFactory := func(r io.Reader, w io.Writer, logger *log.Logger, store promptstore.PromptStore) ServerRunner { - return mcp.NewServer(r, w, logger, store) + serverFactory := func(r io.Reader, w io.Writer, logger *log.Logger, store promptstore.PromptStore, syncer *slashcommands.Syncer) ServerRunner { + return mcp.NewServer(r, w, logger, store, syncer) } // Setup I/O pipes @@ -271,7 +272,7 @@ func TestDefaultServerFactory(t *testing.T) { t.Fatalf("NewJSONLStore() error = %v", err) } - server := defaultServerFactory(inBuf, outBuf, logger, store) + server := defaultServerFactory(inBuf, outBuf, logger, store, nil) if server == nil { t.Fatal("defaultServerFactory() returned nil") } @@ -282,7 +283,7 @@ func TestRun(t *testing.T) { logPath := filepath.Join(tmpDir, "test.log") // Create a mock server factory that returns immediately - mockFactory := func(r io.Reader, w io.Writer, logger *log.Logger, store promptstore.PromptStore) ServerRunner { + mockFactory := func(r io.Reader, w io.Writer, logger *log.Logger, store promptstore.PromptStore, syncer *slashcommands.Syncer) ServerRunner { return &mockServerRunner{ runFunc: func() error { return nil // Exit immediately @@ -315,7 +316,7 @@ func TestRunWithFactory_ServerError(t *testing.T) { logPath := filepath.Join(tmpDir, "test.log") // Create a mock server factory that returns an error - mockFactory := func(r io.Reader, w io.Writer, logger *log.Logger, store promptstore.PromptStore) ServerRunner { + mockFactory := func(r io.Reader, w io.Writer, logger *log.Logger, store promptstore.PromptStore, syncer *slashcommands.Syncer) ServerRunner { return &mockServerRunner{ runFunc: func() error { return fmt.Errorf("mock server error") -- cgit v1.2.3