Skip to content

feat: compile-time feature flag for preview/GA consolidation#1341

Open
jesseturner21 wants to merge 9 commits into
mainfrom
feature/preview-feature-flag
Open

feat: compile-time feature flag for preview/GA consolidation#1341
jesseturner21 wants to merge 9 commits into
mainfrom
feature/preview-feature-flag

Conversation

@jesseturner21
Copy link
Copy Markdown
Contributor

Summary

  • Implements a compile-time __PREVIEW__ feature flag that replaces the dual-branch (main/preview) workflow with a single branch
  • esbuild's define block inlines the constant at build time, enabling dead code elimination — GA builds contain zero harness code
  • npm run bundle now produces dual tarballs: GA (aws-agentcore-<ver>-<ts>.tgz) and Preview (aws-agentcore-<ver>-preview-<ts>.tgz)
  • All harness/preview source files ported from the preview branch and gated behind isPreviewEnabled()

Key design decisions

  • Wrapper function (isPreviewEnabled()) over raw constant access — provides a seam for testing and future extension
  • globalThis shim in index.ts for tsx dev mode (esbuild define only applies during bundling)
  • ESBUILD_OUTFILE env var added to prevent test interference (preview-flag tests build to temp dirs, not dist/)
  • Dead code elimination verified: GA bundle has 0 occurrences of HarnessPrimitive, harness-deployer, or imperativeManager

Test plan

  • All 4069 unit tests pass (282 test files)
  • preview-flag.test.ts verifies dead code elimination in both GA and preview builds
  • GA tarball: agentcore add --help shows no harness/tool commands; agentcore create --defaults produces no harness.json
  • Preview tarball: agentcore add --help shows harness+tool; agentcore create --model-provider Bedrock produces harness project
  • TypeScript compilation passes with 0 errors
  • Prettier + ESLint pass

…lidation

Replace the dual-branch (main/preview) workflow with a single branch using
a compile-time __PREVIEW__ constant. esbuild's define block replaces the
constant at build time, enabling dead code elimination for GA builds while
keeping all harness/preview code in the same source tree.

Key changes:
- Add src/cli/feature-flags.ts with isPreviewEnabled() wrapper
- Configure esbuild define block and vitest define for __PREVIEW__
- Gate harness commands (add tool, remove tool/harness) behind isPreviewEnabled()
- Gate harness UI screens and create flow behind the flag
- Add globalThis shim in index.ts for tsx dev mode
- Update bundle.mjs to produce dual tarballs (GA + preview)
- Support ESBUILD_OUTFILE env var for isolated test builds
- Port all harness-related source files from preview branch
- Add preview-flag.test.ts verifying dead code elimination
@jesseturner21 jesseturner21 requested a review from a team May 21, 2026 13:24
@github-actions github-actions Bot added the size/xl PR size: XL label May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.14.1.tgz

How to install

gh release download pr-1341-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.14.1.tgz

@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: the review run failed before completing. See the run for details.

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
Prettier requires unquoted object keys when valid identifiers.
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 21, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: the review run failed before completing. See the run for details.

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.17% 9777 / 23182
🔵 Statements 41.42% 10383 / 25062
🔵 Functions 39.62% 1691 / 4268
🔵 Branches 38.68% 6313 / 16317
Generated in workflow #3205 for commit dad4319 by the Vitest Coverage Report Action

Harness features are gated behind BUILD_PREVIEW=1 and eliminated from
GA bundles. Integration and e2e tests that exercise harness commands
must skip when running against the default (GA) build.
@github-actions github-actions Bot removed the size/xl PR size: XL label May 21, 2026
@github-actions github-actions Bot added the size/xl PR size: XL label May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: the review run failed before completing. See the run for details.

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
…mory cleanup

- Wrap harness-related CLI options in invoke command behind isPreviewEnabled()
  so they don't leak into GA build's --help output
- Wrap harness-related CLI options in create command behind isPreviewEnabled()
- Fix remove harness leaving orphaned memory entries in agentcore.json
- Fix deploy preflight rejecting harness-only projects
- Add integration test for harness re-add after removal
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
The derived effectiveMode approach didn't trigger re-renders, leaving the
deploy screen stuck after completion. Switch to queueMicrotask + setMode
(matching the preview branch pattern) so the transition fires correctly.
Also handles browser mode by calling onLaunchBrowser after deploy.
@github-actions github-actions Bot removed the size/xl PR size: XL label May 21, 2026
@github-actions github-actions Bot added the size/xl PR size: XL label May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: the review run failed before completing. See the run for details.

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
- Deploy screen in TUI dev mode now matches preview branch: shows
  "Deploying project resources..." with DeployStatus CFN messages,
  filters redundant step, yellow error text, and log path link.
- Persist deployHash in deployed-state.json after successful deploys
  so canSkipDeploy can detect unchanged projects and skip re-deploy.
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: the review run failed before completing. See the run for details.

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
- InvokeScreen: Ctrl+N for new session (was bare N), hint messages
  rendered in gray, context-sensitive "Loading..."/"Thinking..." label,
  directional scroll arrows instead of numeric range
- DevScreen: disable keyboard input while exiting (!isExiting guard)
- deploy/actions: imperative harness teardown before stack destroy
  (gated behind isPreviewEnabled) so harnesses aren't orphaned
- browser-mode: resolve harness traces via resolveAgentOrHarness
  instead of ignoring harnessName parameter
- resolve-agent: add resolveHarness and resolveAgentOrHarness helpers
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: the review run failed before completing. See the run for details.

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
- isHint check now comes after isExec (matching preview branch) so
  exec messages always render as magenta, not gray
- When a project has both runtimes and harnesses and no flag is given,
  show a clear error listing both --runtime and --harness options
@github-actions github-actions Bot removed the size/xl PR size: XL label May 21, 2026
@github-actions github-actions Bot added the size/xl PR size: XL label May 21, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: the review run failed before completing. See the run for details.

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant