Skip to content

refactor: remove dead code and add knip for dead export detection#282

Merged
rhuanbarreto merged 2 commits into
mainfrom
refactor/remove-dead-code
May 8, 2026
Merged

refactor: remove dead code and add knip for dead export detection#282
rhuanbarreto merged 2 commits into
mainfrom
refactor/remove-dead-code

Conversation

@rhuanbarreto

@rhuanbarreto rhuanbarreto commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remove dead functions: Delete _resetPlatformCache, _resetGitFilesCache, _resetAdrParseCache, getLogLevel, opencodeStorageDir, _setPublicProbeForTest, _setRepoContextSnapshot — all never called
  • Unexport dead types: 25+ interfaces that were only used within their defining module (zero runtime impact, tighter public API surface)
  • Add knip as a dev dependency for automated dead export detection
  • Wire bun run knip into validate so dead exports are caught at CI time going forward
  • Tag test hooks consumed via dynamic import() with /** @internal */ so knip excludes them

Configuration

knip.json is configured to:

  • Include tests/**/*.test.ts as entry points (catches test-only imports)
  • Ignore .archgate/adrs/*.rules.ts (dynamically loaded at runtime)
  • Ignore @internal-tagged exports (test hooks using dynamic import())
  • Use ignoreExportsUsedInFile to avoid false positives on structurally-consumed types

Test plan

  • bun run validate passes (729 tests, 0 lint errors, 0 ADR violations, knip clean)
  • bun run knip returns clean with no unused exports
  • TypeScript compiles cleanly after all unexports
  • Grep confirms no remaining references to removed functions

- Delete 3 unused test-hook functions that were never called:
  _resetPlatformCache (superseded by _resetAllCaches),
  _resetGitFilesCache, and _resetAdrParseCache

- Unexport 25 interfaces that are only used within their own module:
  LoadedAdr, BlockedAdr, ParsedAdrEntry, AdrBriefing, DomainContext,
  ReviewContext, BriefAdrOptions, BuildReviewContextOptions,
  BuildSummaryOptions, RuleResult, SourcePos, DeviceCodeResponse,
  GitHubUserInfo, CreateAdrResult, UpdateAdrResult, InitOptions,
  PluginResult, InitResult, SignupResult, ClaudeSessionSummary,
  CursorSessionSummary, ReadCursorSessionOptions,
  CopilotSessionSummary, ReadCopilotSessionOptions,
  OpencodeSessionSummary, ReadOpencodeSessionOptions

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 8, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 35c157d
Status: ✅  Deploy successful!
Preview URL: https://70f9532e.archgate-cli.pages.dev
Branch Preview URL: https://refactor-remove-dead-code.archgate-cli.pages.dev

View logs

- Install knip and configure it to catch unused exports at CI time
- Wire `bun run knip` into the `validate` and `validate:coverage` pipelines
- Fix additional dead exports found by knip:
  - Remove `getLogLevel` (log.ts), `opencodeStorageDir` (paths.ts),
    `_setPublicProbeForTest` (repo-probe.ts, repo.ts),
    `_setRepoContextSnapshot` (telemetry.ts)
  - Unexport `DOMAIN_PREFIX_PATTERN` (project-config.ts)
- Tag upgrade.ts test hooks with `@internal` for dynamic import() usage
- Update CLAUDE.md and agent memory with knip in the validation pipeline

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@rhuanbarreto rhuanbarreto changed the title refactor: remove dead code across src/ refactor: remove dead code and add knip for dead export detection May 8, 2026
@rhuanbarreto rhuanbarreto merged commit a87790e into main May 8, 2026
12 of 16 checks passed
@rhuanbarreto rhuanbarreto deleted the refactor/remove-dead-code branch May 8, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant