1package cmd
2
3import (
4 "github.com/charmbracelet/crush/internal/acp"
5 "github.com/charmbracelet/crush/internal/event"
6 "github.com/spf13/cobra"
7)
8
9var acpCmd = &cobra.Command{
10 Use: "acp",
11 Short: "Start Crush as an ACP server",
12 Long: `Start Crush in Agent-Client Protocol mode.
13
14This allows external ACP clients (web, desktop, mobile) to drive Crush
15over stdio using JSON-RPC. The client sends prompts and receives
16streaming updates about agent activity.`,
17 RunE: func(cmd *cobra.Command, args []string) error {
18 app, err := setupApp(cmd)
19 if err != nil {
20 return err
21 }
22 defer app.Shutdown()
23
24 if shouldEnableMetrics() {
25 event.Init()
26 }
27
28 event.AppInitialized()
29 defer event.AppExited()
30
31 server := acp.NewServer(cmd.Context())
32 defer server.Shutdown()
33
34 agent := acp.NewAgent(app)
35 return server.Run(agent)
36 },
37}