Skip to content

chore(go): sweep dead code from the CLI, TUI, agent, and pkg - #64

Merged
cooper (czxtm) merged 1 commit into
mainfrom
chore/go-dead-code-sweep
Sep 23, 2026
Merged

cooper (czxtm) merged 1 commit into
mainfrom
chore/go-dead-code-sweep

Conversation

@czxtm

Copy link
Copy Markdown
Member

This sweeps dead Go code: 67 files, +69/-7,294 (Go alone is -6,425). Each item was checked with deadcode plus repo-wide greps of its name and route across Go, web, TUI, CLI registration, tests, scripts, docs and Nix.

Removed:

  • TUI views, daemon API and viewer helpers that nothing uses
  • agent endpoints no client calls: /ws, /api/nix/ui/*, /api/project/{resolve,default} and /api/nixpkgs/meta. The WebSocket upgrader stays, because the process-compose log stream uses it.
  • project_context.go, json_transform.go, unused validators and aliases, and leftovers from the old .age secrets format
  • the CLI secrets command, which was never registered, and duplicated templates
  • unused pkg/nixeval API
  • internal/config and internal/util
  • pkg/common/logger.go, the only user of zap and charmbracelet/log. go.mod, go.sum and gomod2nix.toml are tidy, and gomod2nix generate is a no-op.
  • stale CLI help and docs about project selection. Requests now select their project with X-Stackpanel-Project.

Verification by the implementer, in the devshell on the rebased commit:

  • The devshell builds the Go CLI through gomod2nix, and go build and go vet pass.
  • go test shows the 5 failures that already happen on main, plus TestHealthcheckScriptCancellationAndInheritedPipes. That test is a timing flake: it passed 13 of 13 runs on its own, and in a side-by-side run under full-suite load it also failed on origin/main.

Refs stackpanel-thq.10

Delete Go code that has no callers and no remaining contract. Each item was
checked with deadcode plus repo-wide greps of its name and route (Go, web,
TUI, CLI registration, tests, scripts, docs, Nix).

TUI and CLI
- internal/tui/views and views/secrets: nothing imports them. Their only
  entry point, cmd/cli/secrets.go, was never registered (commented out in
  root.go). Also drop internal/tui/REFACTOR_PLAN.md.
- tui/daemon.go: DaemonMode, DefaultDaemonMode, DaemonProgramOptions,
  NewProgram, LogWriter and IsTTY have no callers. The --daemon flag stays
  because `stack setup --experimental-agent` reads it and every CLI page
  documents it.
- tui/output: CaptureWithWriters, TeeBuffer, RunViewer*, SimpleViewer.
- tui/healthcheck_runner.go: the TTL cache path (LoadHealthcheckCache,
  RunOrLoadHealthchecks). The MOTD and `stack healthcheck` read the cache
  without a TTL.
- tui/status.go: drop the "Deprecated: use views.StatusView" note. The
  model backs `stack status`.
- cmd/cli/templates.go and its *.tmpl files: byte-identical copies of
  internal/docgen/templates, with no callers.
- usersCmd was registered in both root.go and users.go, so `users` showed
  up twice in help and in the generated CLI index.
- setup.go: drop the `var _ = fileops.Manifest{}` keep-alive.

Packages
- internal/config: an unused twin of internal/agent/config.
- internal/util: the test scaffolding helpers have no importers.
- pkg/common/logger.go was the only user of zap and charmbracelet/log.
  Its one call site, a Debug line in deploy.go, never printed anything
  because the charm logger defaults to Info, so the line is deleted
  rather than ported. go.mod, go.sum and gomod2nix.toml now match
  `go mod tidy` and the devshell's `gomod2nix generate`. Tidy also wants
  to promote x/ansi, termenv and go-toml/v2 to direct requirements. That
  drift predates this change and is left as is.
- pkg/nixeval: the unused With* options and the Evaluator fields that only
  they set, NewWatchConfig, the Evaluator's own file watcher (the agent's
  FlakeWatcher watches files and calls Invalidate), evalNixConfig, the
  Must* helpers, and presets that have no callers.
- docgen CLICommand/CLIFlag and the deprecated Run; fileops
  loadJSONObject/describeCodec; reconcile sha256File; pkg/nix NixPath
  (replaced by flakeedit.PatchNixPath); pkg/services GlobalBaseDir and
  IsInitialized; pkg/exec ClearDevshellEnv, SetProjectRoot, ProjectRoot;
  pkg/nixdata Store.WriteEntityJSON (no callers since stackpanel-thq.8.2).
- A stray debug AST dump test under apps/stackpanel-go/apps/stackpanel-go/.

Agent
- Routes that no client calls: /ws (the WebSocket upgrader stays because
  the process-compose log stream uses it), /api/nix/ui/{runtime,extensions},
  /api/project/{resolve,default}, /api/nixpkgs/meta.
- json_transform.go and the unused nix_data.go aliases; project.go
  ValidateProjectStrict/Fast, QuickValidationOptions, the thin
  checkFlake*ForStackpanel wrappers, GetValidationWarnings; the agenix.go
  .age leftovers; runHealthchecksParallel and InvalidateHealthcheckCache.
- project_context.go was never mounted. Per-request project selection now
  lives in the v1 Connect interceptor (connect_v1_project.go). The
  `stack project` help and its docs now say that v1 API requests select
  their project with X-Stackpanel-Project. They no longer claim a
  ?project= query parameter.

Kept
- The registry.go fallback modules, because removing them changes what
  users see.
- connect_service.go, connect_handlers.go and generated code, which are
  changing on stackpanel-thq.8.1.2.
- /api/sst/config, /api/process-compose/process/info/, /api/sops/list and
  /api/secrets/list, because apps/web/src/lib/agent.ts still has client
  methods for them (those methods have no callers yet).

Refs: stackpanel-thq.10
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Preview pr-64 has been destroyed.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview pr-64 has been destroyed.

@czxtm
cooper (czxtm) merged commit 2eb8e64 into main Sep 23, 2026
16 of 17 checks passed
@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

ENG-847

@czxtm
cooper (czxtm) deleted the chore/go-dead-code-sweep branch September 23, 2026 16:07

This branch was successfully deployed

2 active deployments
docs-preview — 24b27a80 Deployed Sep 23, 2026 by czxtm via deploy #212
pr-64 — 24b27a80 Deployed Sep 23, 2026 by czxtm via deploy #226
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