feat: add blocks preview command to open blocks in Block Kit Builder#620
Open
WilliamBergamin wants to merge 18 commits into
Open
feat: add blocks preview command to open blocks in Block Kit Builder#620WilliamBergamin wants to merge 18 commits into
WilliamBergamin wants to merge 18 commits into
Conversation
Design for reworking `slack blocks preview` input handling (--blocks flag with `-` stdin sentinel) and folding in the seven code-review findings. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Baseline commit of the in-progress `slack blocks preview` feature before the input-rework and review-fix tasks. Opens Block Kit blocks in the Block Kit Builder, gated behind the block-kit-builder experiment. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Adds Os.Stdin() and IOStreams.IsStdinTTY(), mirroring Stdout()/IsTTY(), so callers can distinguish piped/redirected stdin from an interactive terminal even when stdout is still a TTY. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Replaces the positional argument with a --blocks flag, supports the - stdin sentinel and auto-detected piped stdin, and errors on a bare interactive invocation instead of blocking forever on stdin. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Reading blocks from stdin consumes the pipe, so the interactive team picker cannot prompt. Detect stdin input with more than one auth and no --team flag and return an actionable error instead of failing on EOF. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
An org-grid workspace install has an enterprise ID but is not an enterprise install; key off IsEnterpriseInstall so those installs open the Builder in the workspace context. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Guard against empty or scheme-less hosts that would otherwise yield a malformed URL, and wrap the url.Parse error with a structured code. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Hide the blocks command while gated behind the block-kit-builder experiment and drop its generated doc pages, which docgen omits for hidden commands. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Surface and allow the blocks command only when the CLI is invoked by an AI coding tool, reusing the existing useragent.GetAIAgent detection. Replaces the block-kit-builder experiment: the parent command is hidden from help/docs unless an AI tool is detected, and preview's PreRunE now returns command_unavailable for non-AI callers. Removes the BlockKitBuilder experiment. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
These agent-workflow planning artifacts under docs/superpowers/ are not part of the shipped product and are unreferenced. Remove them from the branch. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…tools The blocks preview command was gated two ways on AI-coding-tool detection: visibility (parent command Hidden) and execution (preview PreRunE returning command_unavailable for non-AI callers). Drop the execution gate so anyone can run the command, while keeping the visibility gate so it stays hidden from help and docs unless an AI coding tool is detected. Remove the now-orphaned command_unavailable error code (added by the same commit that introduced the gate, used nowhere else) and regenerate errors.md. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Remove the auto-detected stdin pipe from blocks preview so blocks are read from standard input only via the explicit --blocks - sentinel, matching the prevailing convention of comparable tools (kubectl -f -, gh --input -). This drops the one place the command diverged from those tools. Fix the file-input example to use the sentinel form and correct the inaccurate "piped from a file" wording (< is redirection, not a pipe), and update the Long description and remediation text to match the new behavior. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Remove comments that restate self-explanatory function names and bodies, and trim the rest to the non-obvious rationale. Comments-only change. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
- Guard `--blocks -` with IsStdinTTY() so an interactive terminal returns a clear error instead of blocking forever on stdin. - Return ErrCredentialsNotFound when no teams are logged in, instead of showing an empty team prompt. - Preserve the user's JSON key order in the Block Kit Builder URL by compacting the original input instead of re-marshalling the parsed value. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
WilliamBergamin
marked this pull request as ready for review
July 21, 2026 22:20
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #620 +/- ##
==========================================
+ Coverage 71.78% 71.91% +0.13%
==========================================
Files 227 229 +2
Lines 19283 19433 +150
==========================================
+ Hits 13842 13976 +134
- Misses 4225 4234 +9
- Partials 1216 1223 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Add the
slack blocks previewcommand to open Block Kit blocks in the Block Kit Builder.Summary
This adds a new
blocks previewcommand. It takes a set of Block Kit blocks and opens them in the Block Kit Builder in a web browser.Blocks are passed with the
--blocksflag. The value is a JSON array of blocks or a JSON object with ablocksarray. Pass-to read the blocks from standard input.The command is hidden from the help output unless an AI coding tool is detected. It is meant to be used by AI tools that generate Block Kit layouts.
Preview
(No UI change. The command prints the Builder URL and opens it in the browser.)
Testing
Build the CLI first:
Then run the examples below with
SLACK_DISABLE_TELEMETRY=true.Expected to work:
Preview a bare blocks array passed as a flag value.
Preview a full blocks object passed as a flag value.
Preview blocks read from a file on standard input.
Expected to error:
Pass a value that is not valid JSON. This returns an
unable_to_parse_jsonerror.Pass valid JSON that is not a blocks payload. This returns an
invalid_blockserror.Unit tests:
Notes
/block-kit-builder/{id}/builderwas verified in an authenticated browser.Requirements