feat(audience): add full audience resource support#730
Merged
meryldakin merged 18 commits intomainfrom Mar 10, 2026
Merged
Conversation
2 tasks
This was referenced Mar 9, 2026
Add complete audience resource implementation following existing patterns: ## Commands - audience list: List all audiences with pagination - audience get: Display a single audience - audience open: Open audience in dashboard - audience pull: Download from Knock to filesystem - audience push: Upload from filesystem to Knock - audience validate: Validate local audience files - audience new: Scaffold new audience (prompts for static/dynamic type) - audience archive: Archive audience (affects ALL environments, requires confirmation) ## Infrastructure - Add AudienceData types with static/dynamic support and segments - Add API methods: listAudiences, getAudience, upsertAudience, validateAudience, archiveAudience - Add audience to ResourceType, ALL_RESOURCE_TYPES, and RESOURCE_SUBDIRS - Add audience directory detection in run-context loader - Add audience marshal layer (processor, reader, writer, helpers, generator) - Add viewAudienceUrl helper ## Tests - Full test coverage for all 8 commands - Add audience factory for test support Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add listAudiences stub to pull.test.ts and AudienceValidate.validateAll stub to push.test.ts to fix test failures caused by audience resource integration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f9f4049 to
fb5233d
Compare
Remove leftover debug logging from the error handler in writeAudiencesIndexDir to match the pattern used in other marshal writers (email-layout, workflow). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1. Return render() call in list command to properly await pagination 2. Use original dirent.name for filesystem path in pruneAudiencesIndexDir, only use lowercased version for key lookup comparison Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refactor evaluateRecursively to use else-if chain instead of separate if blocks. This prevents later resource type checks from overwriting an already-detected resource directory context. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When using --push with audience new, now properly forwards the --branch and --environment flags to AudiencePush.run() so the push targets the correct branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove the development-only restriction from audience push and validate commands. Unlike some other resources, audiences can be created in any environment. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove copied TODO comment that has no associated ticket. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Dynamic audiences should be created with empty segments rather than example conditions. Users can add their own conditions as needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change readAllForCommandTarget to use ux.error() instead of throw new Error() to match the pattern used by other resource readers. This provides clean, formatted CLI error messages instead of stack traces. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Check isSuccessResp before writing API response to disk. Without this check, an error response (e.g., 404 not found) would be silently written to the filesystem as if it were valid audience data. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cjbell
approved these changes
Mar 9, 2026
Contributor
cjbell
left a comment
There was a problem hiding this comment.
one thing but we don't need to do it yet
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
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.

Summary
Add complete audience resource support to the Knock CLI. Tested locally to validate that all are working as expected.
Commands Implemented
audience listaudience getaudience openaudience pullaudience pushaudience validateaudience newaudience archive