Skip to content

uninstall: the CLI and three dashboard handlers each implement the uninstall sequence #442

Closed

Description

@runkids

Problem

The uninstall sequence (resolve → move-out check → move to trash → .gitignore cleanup → metadata prune → oplog) is implemented four times: once in the CLI and three times in dashboard handlers. There is no internal/uninstall; the shared pieces are leaf helpers (trash.MoveToTrash, sourcefs.CheckSkillMoveOut, MetadataStore.RemoveByNames), so the sequencing and the prune rules live in each caller and have drifted.

Evidence (v0.25.0, aeaea40e)

  • cmd/skillshare/uninstall_handlers.go — runUninstallSkills:194, performUninstallQuiet:111, performUninstall:135
  • internal/server/handler_skills.go — handleUninstallRepo:408, handleUninstallSkill:499
  • internal/server/handler_uninstall.go — handleBatchUninstallSkills:148, resolveUninstallSkill:397
  • internal/install/metadata.go — RemoveByNames:166

Observed differences:

  • Metadata prune has three rule sets: RemoveByNames (CLI), handler_skills.go:457-482, handler_uninstall.go:335-364.
  • handleUninstallRepo has no git.IsDirty check; the batch handler (handler_uninstall.go:214) and the CLI (uninstall_handlers.go:618) do.
  • The skill branch of handleUninstallSkill (:562-597) does not touch skillsStore or call reconcileSkillsConfig; the batch handler does (:335-370). Whether this leaves stale metadata has not been verified — another reconcile path may cover it.
  • handler_uninstall.go:166-313 repeats the same six-line failure block nine times.

Related fixes that had to be applied per caller: 3ad3af7, db45b0d, cd6e016, e66529f, 1f4a466, 8e5a09c, 20ae89a. 7dfb764 merged the CLI's global and project flows; the server did not follow.

Proposed change

One domain operation that takes a list of names plus force and performs resolution, followed-link handling, dirty preflight, move to trash, .gitignore cleanup and metadata prune, returning a per-item result. The CLI keeps confirmation and output; the three handlers translate the result to JSON. CLI-only parsing (globs, --group, --all) stays in the CLI.

Tests move to the new interface against a temp dir; the duplicated CLI/server behaviour tests can then shrink.

Risks

  • The CLI resolves names by path and the server by flat name. Unifying resolution may change user-visible behaviour and needs a decision first.
  • Interface design is deliberately left open here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions