Skip to content

chore: remove dead code and unused exports (no behavior change)#1574

Draft
jariy17 wants to merge 1 commit into
aws:mainfrom
jariy17:ponytail/prune-dead-deps-and-code
Draft

chore: remove dead code and unused exports (no behavior change)#1574
jariy17 wants to merge 1 commit into
aws:mainfrom
jariy17:ponytail/prune-dead-deps-and-code

Conversation

@jariy17

@jariy17 jariy17 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Whole-repo over-engineering audit (ponytail-style). Removes only verified-dead codeno CLI command, flag, argument, help text, stdout/stderr output, serialized schema, or public API change. Every cut was grep-confirmed zero-caller across src/ + unit/e2e/integ/browser tests before removal, then validated by a full build + test run.

  • 41 files changed, net ~1,000 LOC removed
  • tsc --noEmit (src + tests) — clean
  • eslint src/ — 0 errors (3 pre-existing warnings in untouched files)
  • npm run build — lib + esbuild bundle + assets all succeed
  • npm test5345 passed, 0 failed

What was removed

Whole files (zero importers):

File What
tui/hooks/useAttach.ts 12 unused data-fetch hooks
tui/hooks/usePanelNavigation.ts (+test) unused hook
tui/hooks/use-gradient.ts self-labelled "kept for potential future use"
tui/components/ScrollableText.tsx, TwoColumn.tsx (+tests) unrendered components (barrel lines also pruned)
lib/packaging/types/archiver.d.ts ambient typing for archiver, never imported (zipping uses fflate)
schema/schemas/primitives/index.ts unreachable re-export barrel
cli/cloudformation/types.ts 4 unused exports (barrel line pruned)
cli/commands/index.ts stale register* barrel nothing imports

Dead exports / members: unused session-id helpers (getSessionId/saveSessionId/clearSessionId/getOrCreateSessionId), stopRuntimeSession (+ its types, SDK import, barrel entry), PolicyEnginePrimitive.getDeployedGatewayArn, a dangling stub doc-comment, HARNESS_DIR, NPM_INSTALL_HINT, isLinux, getShellCommand/getShellArgs/normalizeCommand (+ test), runCommand wrapper, HarnessSkillInput, CdkToolkitWrapper.getProjectDir, harness session-manager.get/listAll, screen.formatNumbered, availability.unavailableReason, CFN_RESOURCE_IDENTIFIERS, AddDatasetResult, deprecated AddIdentityOptions, and dead re-export lines in templates/, external-requirements/, primitives/.

Tightened visibility: dropped the unnecessary export keyword on internal-only helpers (otel transforms, span-collector executeQuery, feedback build-payload, ab-test resolve) — same module-private behavior, smaller public surface.

Stdlib: replaced two hand-rolled sleep() helpers with node:timers/promises setTimeout (dataset/push, insights/run-insights).

Deliberately NOT included (left for a follow-up / human call)

These showed up in the audit but were excluded to keep this PR 100% safe:

  • Dependency removals (commander, yaml, @aws-cdk/cdk-assets-lib, @aws-sdk/region-config-resolver) — all have zero direct imports, but each is load-bearing: commander is a peer dep of @commander-js/extra-typings, yaml/cdk-assets-lib are transitive of @aws-cdk/toolkit-lib, and region-config-resolver is a deliberate bundling-crash workaround. Removing any requires npm-shrinkwrap.json regeneration → out of scope for a no-behavior-change PR.
  • ?? defaultProvider() credential-fallback removals — statically unreachable, but it's a security-adjacent path and sibling call sites have tests that mock getCredentialProvider → undefined to exercise it. Not worth the risk for ~9 LOC.
  • Cross-repo src/lib + src/schema de-duplication vs @aws/agentcore-cdk — ~6k LOC of vendored copies, but the two have diverged; consolidating needs reconciling two schema sources of truth.

Test plan

npm ci && npm run build && npm test → 5345 passing.

Whole-repo over-engineering audit. Removes verified-dead code only —
no CLI command, flag, help text, output, or public API surface changes.
All cuts confirmed zero-caller across src + tests + e2e/integ/browser
suites before removal.

Deletions (whole files, zero importers):
- tui/hooks/useAttach.ts (12 unused hooks)
- tui/hooks/usePanelNavigation.ts (+ test)
- tui/hooks/use-gradient.ts ("kept for future use")
- tui/components/ScrollableText.tsx, TwoColumn.tsx (+ tests, + barrel lines)
- lib/packaging/types/archiver.d.ts (archiver never imported; uses fflate)
- schema/schemas/primitives/index.ts (unreachable re-export barrel)
- cli/cloudformation/types.ts (4 unused exports, + barrel line)
- cli/commands/index.ts (stale unused register* barrel)

Dead exports / members removed:
- operations/session: getSessionId/saveSessionId/clearSessionId/getOrCreateSessionId
- aws/agentcore: stopRuntimeSession (+ types, + barrel + SDK import)
- primitives: PolicyEnginePrimitive.getDeployedGatewayArn, RuntimeEndpoint stub
- lib/constants: HARNESS_DIR, NPM_INSTALL_HINT
- lib/utils/platform: isLinux, getShellCommand, getShellArgs, normalizeCommand (+ test)
- lib/packaging/helpers: runCommand wrapper
- schema harness: HarnessSkillInput
- cdk wrapper: getProjectDir
- tui-harness: session-manager get/listAll, screen formatNumbered, availability.unavailableReason
- dead barrel re-export lines in templates/, external-requirements/, primitives/, commands/add/types
- dropped unused `export` keyword on internal-only helpers (otel transforms, span-collector
  executeQuery, feedback build-payload, ab-test resolve)

Stdlib: replace two hand-rolled sleep() helpers with node:timers/promises
setTimeout (dataset/push, insights/run-insights).

Verified: tsc --noEmit (src+tests), eslint (0 errors), npm run build,
npm test (5345 passed).
@github-actions github-actions Bot added the size/xl PR size: XL label Jun 17, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 17, 2026
@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 17, 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 Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.20.0.tgz

How to install

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

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