Skip to content

refactor(cli): remove provably unused kilocode code - #12599

Merged
marius-kilocode merged 6 commits into
mainfrom
remove-unused-cli-code
Jul 30, 2026
Merged

refactor(cli): remove provably unused kilocode code#12599
marius-kilocode merged 6 commits into
mainfrom
remove-unused-cli-code

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

The CLI accumulates helpers that lose their last caller as features get refactored, and there is no package-level tooling that catches them in kilocode-owned modules. This PR removes 149 lines of dead code found by a one-off audit.

Everything deleted was verified unreachable before removal: each symbol and file has zero references across the whole monorepo, including packages/tui (which imports kilocode TUI mirrors via the @/ alias), tests, docs, scripts, CI, dynamic imports, and string-based lookups, plus no usage inside its own file. In-file consumers and namespace-internal members were checked separately so legitimately exported API stays intact.

What went away:

  • background-process/windows-job.ts in full: an 88-line Windows Job Object FFI module left unreferenced after the background process runner refactor
  • Uncalled helpers: createShellDecoders and the CODE_SWITCH_TEXT alias (plus the StringDecoder import it owned) in session/prompt.ts, openUtf8 in text-stream.ts, enterInsert in the TUI vim mode handler
  • Unread constants: TEXT_PLAIN (remote-attachments), PLAN_PREFIX (plan-followup), KILO_CONFIG_FILES, AGENT_PATTERNS, COMMAND_PATTERNS (kilocode config)
  • Unreferenced schemas and types: SessionParams (background-process API group), SessionImportPayloads (session-import API group), RepositoryInput (cloud contracts)

No behavior change: only declarations with no reachable caller were removed, all in Kilo-owned paths so upstream merges are unaffected.

This PR also fixes a latent HttpApi exerciser hang that CI cache hits on main were masking. Any branch that invalidates the turbo cache exposes it: auth mode probes every protected route with valid credentials, and two routes (tui.control.next, instance.reload) intentionally block after a valid request. The timed-out probe request stayed alive inside the cached web handler, so the final disposeApps() waited forever and the job was cancelled at the 15 minute timeout. Blocking routes now opt out of the valid-credential probe while still proving they return 401 without credentials.

Delete code with zero references anywhere in the monorepo (including
tests, docs, scripts, and dynamic import or string-based usage):

- background-process/windows-job.ts: entire Windows Job Object FFI
  module left unreferenced after the background process runner refactor
- session/prompt.ts: createShellDecoders helper, CODE_SWITCH_TEXT alias,
  and the now-unused StringDecoder import
- text-stream.ts: openUtf8 wrapper
- cli/cmd/tui/component/prompt/vim.ts: enterInsert helper
- config/config.ts: KILO_CONFIG_FILES, AGENT_PATTERNS, COMMAND_PATTERNS
- remote-attachments.ts: TEXT_PLAIN constant
- plan-followup.ts: PLAN_PREFIX constant
- server/httpapi/groups/background-process.ts: SessionParams schema
- server/httpapi/groups/session-import.ts: SessionImportPayloads map
- cloud/contracts.ts: RepositoryInput type alias
@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Incremental review since the last pass: the only new changes are in the HttpApi exerciser test harness (packages/opencode/test/server/httpapi-exercise/{dsl,index,runner,types}.ts and packages/opencode/test/kilocode/server/httpapi-exercise-scenarios.ts), adding a skipValidAuthProbe() builder option so blocking routes (tui.control.next, instance.reload) only assert the 401-on-missing-credentials case and skip the valid-credential probe that would otherwise hang inside the handler and block disposeApps() at the 15-minute CI timeout. The change is minimal, correctly scoped, and consistently annotated with kilocode_change markers on the shared (non-kilocode) files it touches. No further changes were made to the previously-reviewed dead-code removal files.

Files Reviewed (5 files)
  • packages/opencode/test/kilocode/server/httpapi-exercise-scenarios.ts
  • packages/opencode/test/server/httpapi-exercise/dsl.ts
  • packages/opencode/test/server/httpapi-exercise/index.ts
  • packages/opencode/test/server/httpapi-exercise/runner.ts
  • packages/opencode/test/server/httpapi-exercise/types.ts
Previous Review Summary (commit 526572c)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 526572c)

Status: No Issues Found | Recommendation: Merge

Verified each removed symbol (WindowsJob, createShellDecoders, CODE_SWITCH_TEXT, openUtf8, enterInsert, KILO_CONFIG_FILES, AGENT_PATTERNS, COMMAND_PATTERNS, TEXT_PLAIN, PLAN_PREFIX, SessionParams, SessionImportPayloads, RepositoryInput) has zero remaining references in the repo, and that removing the StringDecoder import in session/prompt.ts left no other usage in that file. All changes are confined to packages/opencode/src/kilocode/, so no upstream merge-hygiene concerns apply, and this is a pure deletion with no behavior change.

Files Reviewed (10 files)
  • packages/opencode/src/kilocode/background-process/windows-job.ts
  • packages/opencode/src/kilocode/cli/cmd/tui/component/prompt/vim.ts
  • packages/opencode/src/kilocode/cloud/contracts.ts
  • packages/opencode/src/kilocode/config/config.ts
  • packages/opencode/src/kilocode/plan-followup.ts
  • packages/opencode/src/kilocode/remote-attachments.ts
  • packages/opencode/src/kilocode/server/httpapi/groups/background-process.ts
  • packages/opencode/src/kilocode/server/httpapi/groups/session-import.ts
  • packages/opencode/src/kilocode/session/prompt.ts
  • packages/opencode/src/kilocode/text-stream.ts

Reviewed by claude-sonnet-5 · Input: 32 · Output: 7.3K · Cached: 835.4K

Review guidance: REVIEW.md from base branch main

The auth mode probes every protected route with valid credentials to
prove the route accepts them. Two routes intentionally block after a
valid request: tui.control.next waits for queued TUI input, and
instance.reload can outlive the one second probe. The probe won by
timeout, marked the scenario passed, and left the request alive inside
the cached web handler. Final disposeApps() then waited for those
requests forever, so any run that rebuilt the app (cold turbo cache)
never exited and CI cancelled the job at 15 minutes.

Add a scenario flag that keeps the missing-credentials check (the route
must still return 401) but skips the valid-credential probe for routes
whose valid requests intentionally block, and mark tui.control.next and
instance.reload with it.
@marius-kilocode
marius-kilocode merged commit 6f9ee94 into main Jul 30, 2026
41 of 44 checks passed
@marius-kilocode
marius-kilocode deleted the remove-unused-cli-code branch July 30, 2026 10:54
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
refactor(cli): remove provably unused kilocode code
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.

2 participants