From 351cf75759e21aa8fac6c2097ef1b1f1c7c2f689 Mon Sep 17 00:00:00 2001 From: Michael Brooks Date: Fri, 28 Aug 2026 14:58:29 -0700 Subject: [PATCH] fix: always show the blocks command in help The blocks command was hidden from help unless the CLI detected it was being run by an AI coding agent. Nothing about the command is agent-specific: its descriptions are audience-neutral and its reference docs already advertise it as a normal public command. Cobra's Hidden only suppresses help listing and never blocks dispatch, so the gate hid the command from humans who could already run it. It also made generated docs depend on the environment. docgen skips commands failing IsAvailableCommand(), which is false for hidden commands, so `make rc` from a plain terminal would have deleted slack_blocks.md and slack_blocks_preview.md and dropped blocks from slack.md. Agent detection is still used for the User-Agent header, telemetry, and tracing; only the visibility gate is removed. --- cmd/blocks/blocks.go | 11 +++-------- cmd/blocks/blocks_test.go | 29 ----------------------------- cmd/blocks/preview_test.go | 9 --------- 3 files changed, 3 insertions(+), 46 deletions(-) diff --git a/cmd/blocks/blocks.go b/cmd/blocks/blocks.go index 47d71b44..d0666fd0 100644 --- a/cmd/blocks/blocks.go +++ b/cmd/blocks/blocks.go @@ -17,19 +17,14 @@ package blocks import ( "github.com/slackapi/slack-cli/internal/shared" "github.com/slackapi/slack-cli/internal/style" - "github.com/slackapi/slack-cli/internal/useragent" "github.com/spf13/cobra" ) -// aiAgentFunc is a package variable so it can be stubbed in tests. -var aiAgentFunc = useragent.GetAIAgent - func NewCommand(clients *shared.ClientFactory) *cobra.Command { cmd := &cobra.Command{ - Use: "blocks [flags]", - Short: "Build with Block Kit", - Long: "Build layouts using Block Kit and iterate on designs with Block Kit Builder.", - Hidden: aiAgentFunc() == nil, + Use: "blocks [flags]", + Short: "Build with Block Kit", + Long: "Build layouts using Block Kit and iterate on designs with Block Kit Builder.", Example: style.ExampleCommandsf([]style.ExampleCommand{ { Meaning: "Preview blocks in Block Kit Builder", diff --git a/cmd/blocks/blocks_test.go b/cmd/blocks/blocks_test.go index d2980383..fe741f1e 100644 --- a/cmd/blocks/blocks_test.go +++ b/cmd/blocks/blocks_test.go @@ -19,10 +19,8 @@ import ( "testing" "github.com/slackapi/slack-cli/internal/shared" - "github.com/slackapi/slack-cli/internal/useragent" "github.com/slackapi/slack-cli/test/testutil" "github.com/spf13/cobra" - "github.com/stretchr/testify/assert" ) func Test_Blocks_Command(t *testing.T) { @@ -39,30 +37,3 @@ func Test_Blocks_Command(t *testing.T) { return NewCommand(cf) }) } - -func Test_Blocks_Command_Hidden(t *testing.T) { - tests := map[string]struct { - aiAgent *useragent.AIAgent - expectedHidden bool - }{ - "hidden when no AI coding tool is detected": { - aiAgent: nil, - expectedHidden: true, - }, - "visible when an AI coding tool is detected": { - aiAgent: &useragent.AIAgent{Name: "claude-code"}, - expectedHidden: false, - }, - } - for name, tc := range tests { - t.Run(name, func(t *testing.T) { - restore := stubAIAgent(tc.aiAgent) - defer restore() - - clientsMock := shared.NewClientsMock() - clients := shared.NewClientFactory(clientsMock.MockClientFactory()) - cmd := NewCommand(clients) - assert.Equal(t, tc.expectedHidden, cmd.Hidden) - }) - } -} diff --git a/cmd/blocks/preview_test.go b/cmd/blocks/preview_test.go index ed4bb673..3e016f7d 100644 --- a/cmd/blocks/preview_test.go +++ b/cmd/blocks/preview_test.go @@ -23,7 +23,6 @@ import ( "github.com/slackapi/slack-cli/internal/shared/types" "github.com/slackapi/slack-cli/internal/slackerror" "github.com/slackapi/slack-cli/internal/slacktrace" - "github.com/slackapi/slack-cli/internal/useragent" "github.com/slackapi/slack-cli/test/testutil" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" @@ -31,14 +30,6 @@ import ( "github.com/stretchr/testify/require" ) -// stubAIAgent stubs the detected AI coding tool and returns a function that -// restores the original detection. -func stubAIAgent(agent *useragent.AIAgent) func() { - original := aiAgentFunc - aiAgentFunc = func() *useragent.AIAgent { return agent } - return func() { aiAgentFunc = original } -} - func Test_Blocks_PreviewCommand(t *testing.T) { // teamlessURL is the Block Kit Builder URL rendered when no team can be // resolved. The browser resolves the team from its own session.