From 786d6397b957065fb0e63c54a563470d08748511 Mon Sep 17 00:00:00 2001 From: Robert Richardson Date: Sun, 6 Dec 2026 15:54:32 +1300 Subject: [PATCH] chore: make the repo a mise monorepo with per-module Go deps and tasks --- .claude/skills/new-tool/SKILL.md | 3 ++- CLAUDE.md | 6 +++++- README.md | 8 ++++++++ cbz-fix/mise.toml | 5 +++++ mise.toml | 7 +++++++ mkv-audit/mise.toml | 5 +++++ mkv-movie/mise.toml | 5 +++++ mkv-music/mise.toml | 5 +++++ mkv-tvshow/mise.toml | 5 +++++ sw-update/mise.toml | 5 +++++ tasks/module.toml | 23 +++++++++++++++++++++++ 11 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 cbz-fix/mise.toml create mode 100644 mkv-audit/mise.toml create mode 100644 mkv-movie/mise.toml create mode 100644 mkv-music/mise.toml create mode 100644 mkv-tvshow/mise.toml create mode 100644 sw-update/mise.toml create mode 100644 tasks/module.toml diff --git a/.claude/skills/new-tool/SKILL.md b/.claude/skills/new-tool/SKILL.md index f3868a4..bb100cc 100644 --- a/.claude/skills/new-tool/SKILL.md +++ b/.claude/skills/new-tool/SKILL.md @@ -7,11 +7,12 @@ argument-hint: Arguments: `$ARGUMENTS`. The first word is the new tool's name — written `` below — and the rest is its one-line purpose. If either is missing, ask for it before starting. -The mise tasks and CI find modules by their `go.mod`, so none of them need editing. Everything below does. +The root mise tasks and CI find modules by their `go.mod`, so none of them need editing. Everything below does. ## 1. Module - Create `/go.mod` with `module ` and the same `go` line as the other modules. Copy the line from `cbz-fix/go.mod`; don't type a version. +- Copy `cbz-fix/mise.toml` to `/mise.toml`, and add `""` to `[monorepo].config_roots` in the root `mise.toml`, alphabetically. Without them `mise deps --monorepo` skips the module, and the module-level tasks are missing. - Write `/main.go` in `package main`, following CLAUDE.md's *Common shape of each tool*. That means flags parsed in `main.go`, one-shot modes that return early, and every side effect behind an interface so tests can substitute fakes. If the tool keeps config, cache or state, put it in the app dir the way `mkv-movie/appdir.go` does. - Add tests in the same piece of work, using `t.TempDir()` for the filesystem. Read an existing module's tests for the patterns first. diff --git a/CLAUDE.md b/CLAUDE.md index 73270fb..9c67da4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,6 +17,10 @@ In a worktree, run `mise run` and these skills from the worktree directory, and The tasks are declared in `mise.toml`. Each is a pair of scripts in `tasks/`: `.sh` runs under `sh` on macOS and Linux, and `.ps1` under `pwsh` on Windows, whatever shell `mise run` is typed in. Make every change to both. Every task but `clean`, `openapi` and `tmdb-openapi` takes module directory names and defaults to all of them. +The repo is a mise monorepo: the root `mise.toml` lists each module under `[monorepo].config_roots`, and each module's own `mise.toml` declares `[deps.go]` and includes `tasks/module.toml`. Inside a module, a bare task name means that module's task, so `mise run test` in `mkv-movie/` runs `mise run //:test mkv-movie`; reach a root task from there as `//:`. + +- `mise deps --monorepo` — `go mod download` in each module whose `go.mod`/`go.sum` changed. Run it in a fresh worktree. + - `mise run build [module...]` — build to `dist/` (`dist/.exe` on Windows). - `mise run vet [module...]` — `go vet`, `go mod tidy -diff`, `golangci-lint run` and `golangci-lint fmt --diff` per module, for the Windows build on every OS (fails on unformatted files or an untidy `go.mod`/`go.sum`). The linters and formatters are configured in `.golangci.yml` and pinned in `mise.toml`; `mise install` provides them. Suppress a finding with `//nolint: // reason`, not staticcheck's `//lint:ignore`. - `mise run vet-linux [module...]` — `GOOS=linux go vet ./...` and `GOOS=linux golangci-lint run ./...` per module, to type-check and lint the non-Windows stubs. @@ -44,7 +48,7 @@ Six independent tools, each its own Go module (`package main`) with its own `go. - **mkv-movie and mkv-tvshow duplicate a lot of code** (`rating.go`, `rating_cache.go`, `classification.go`, `set_rating.go`, `reset_rating.go`, `plex*.go` multi-account logic, `filetime*.go`, `appdir.go`). The copies have drifted; a bug fix in one usually needs porting to the other. - **Other code is shared across tools, not just the twins**: `--clean` pruning, offline-drive detection and walk/stat error handling recur, and bugs in them have been fixed one tool at a time. Run the `twin-port-checker` agent after changing any tool; it checks both the twins and these shared shapes. -- The mise tasks find modules by their `go.mod`, so a new tool needs no task change. `/new-tool ` scaffolds the module and covers the README, this file and the `configs/` junction. +- The mise tasks find modules by their `go.mod`; only `mise deps` and the module-level tasks need the module's own `mise.toml` and its `config_roots` entry. `/new-tool ` scaffolds the module and covers those, the README, this file and the `configs/` junction. Common shape of each tool: diff --git a/README.md b/README.md index 95f06a9..b69f503 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ Build specific tools by directory name: mise run build mkv-audit mkv-movie ``` +Download every module's Go dependencies (each module runs `go mod download` only when its `go.mod` or `go.sum` changed): + +```sh +mise deps --monorepo +``` + Run all tests (or name modules, as for `build`): ```sh @@ -51,6 +57,8 @@ Scan all modules for known vulnerabilities in their dependencies with mise run vuln ``` +Inside a module directory, `build`, `test`, `vet`, `vet-linux` and `vuln` act on that module alone; run a repo-wide task from there as `mise //:test`. + --- ## cbz-fix diff --git a/cbz-fix/mise.toml b/cbz-fix/mise.toml new file mode 100644 index 0000000..e8428ab --- /dev/null +++ b/cbz-fix/mise.toml @@ -0,0 +1,5 @@ +# Each module is a monorepo config root (see the root mise.toml). +[deps.go] + +[task_config] +includes = ["../tasks/module.toml"] diff --git a/mise.toml b/mise.toml index 7128231..7593da7 100644 --- a/mise.toml +++ b/mise.toml @@ -1,3 +1,10 @@ +# `mise deps --monorepo` installs each module's Go dependencies. List a new module here too. +monorepo_root = true + +[monorepo] +config_roots = ["cbz-fix", "mkv-audit", "mkv-movie", "mkv-music", "mkv-tvshow", "sw-update"] +lockfile = true + [env] # Error instead of downloading a newer Go when a go.mod's go line is ahead of the Go in use. GOTOOLCHAIN = "local" diff --git a/mkv-audit/mise.toml b/mkv-audit/mise.toml new file mode 100644 index 0000000..e8428ab --- /dev/null +++ b/mkv-audit/mise.toml @@ -0,0 +1,5 @@ +# Each module is a monorepo config root (see the root mise.toml). +[deps.go] + +[task_config] +includes = ["../tasks/module.toml"] diff --git a/mkv-movie/mise.toml b/mkv-movie/mise.toml new file mode 100644 index 0000000..e8428ab --- /dev/null +++ b/mkv-movie/mise.toml @@ -0,0 +1,5 @@ +# Each module is a monorepo config root (see the root mise.toml). +[deps.go] + +[task_config] +includes = ["../tasks/module.toml"] diff --git a/mkv-music/mise.toml b/mkv-music/mise.toml new file mode 100644 index 0000000..e8428ab --- /dev/null +++ b/mkv-music/mise.toml @@ -0,0 +1,5 @@ +# Each module is a monorepo config root (see the root mise.toml). +[deps.go] + +[task_config] +includes = ["../tasks/module.toml"] diff --git a/mkv-tvshow/mise.toml b/mkv-tvshow/mise.toml new file mode 100644 index 0000000..e8428ab --- /dev/null +++ b/mkv-tvshow/mise.toml @@ -0,0 +1,5 @@ +# Each module is a monorepo config root (see the root mise.toml). +[deps.go] + +[task_config] +includes = ["../tasks/module.toml"] diff --git a/sw-update/mise.toml b/sw-update/mise.toml new file mode 100644 index 0000000..e8428ab --- /dev/null +++ b/sw-update/mise.toml @@ -0,0 +1,5 @@ +# Each module is a monorepo config root (see the root mise.toml). +[deps.go] + +[task_config] +includes = ["../tasks/module.toml"] diff --git a/tasks/module.toml b/tasks/module.toml new file mode 100644 index 0000000..9807cab --- /dev/null +++ b/tasks/module.toml @@ -0,0 +1,23 @@ +# Included by each module's mise.toml. In a monorepo a bare task name inside a module resolves to +# that module, so these run the root task for just this one: `mise run test` in mkv-movie/ is +# `mise run //:test mkv-movie`. + +["build"] +description = "Build this module to dist/" +run = "mise run //:build {{ config_root | basename }}" + +["test"] +description = "go test this module" +run = "mise run //:test {{ config_root | basename }}" + +["vet"] +description = "Vet, tidy-check, lint and fmt-check this module" +run = "mise run //:vet {{ config_root | basename }}" + +["vet-linux"] +description = "Type-check and lint this module's non-Windows stubs" +run = "mise run //:vet-linux {{ config_root | basename }}" + +["vuln"] +description = "govulncheck this module (needs network)" +run = "mise run //:vuln {{ config_root | basename }}"