# Mod Manager One panel for your Herdr app mods: what is in your mods folder, the Community mods from herdr.dev, and install, update and remove, with a review before anything is copied that says whether the mod runs programs, reaches the network or touches files. A port of [speardragon/herdr-plugin-manager](https://github.com/speardragon/herdr-plugin-manager) from herdr plugins to Herdr app mods. The Community list is the GitHub topic `herdr-mod`. ![Mod Manager](preview.png) ## What you see A dialog at 80% × 75% of the window (`cmd-shift-m`), `popover` background, 16px padding, 12px gaps, text 13px. Every screen has a header (15px semibold title, a `dim` detail, `esc` at the right), a body, an optional message line in `foreground`, and a footer with the keys in `dim`; while something runs the footer is the task in `working`, and a y/n question replaces it in `blocked` semibold. - **Mods** (start screen): one 28px row per folder in `mods/`, your mods first, then Herdr's. Columns: position (`dim`), a dot (`done` for installed here, `blocked` when an update exists, `dim` otherwise), name (`foreground`; `muted` for Herdr's), kind (`instalado` in `accent`, `local` in `muted`, `Herdr` in `dim`; `· link` for a symlink), and for installed ones `owner/repo[/folder] @ sha7`, plus `· ↑ sha7` in `blocked` when the repo moved. Below the list, the selected mod's details: source, mods, layouts, keys it added, install date. - **Marketplace** (`m`): ten repos per page, position, `✓` in `done` if installed here, `owner/repo`, `★ stars`, description truncated. Header: query, sort (`mais estrelas` / `atualizados`) and total. A search box (accent border) appears on `/`. Footer line "página 2 de 3". - **Pacotes**: when a repo holds several packages, one row per folder with its mods and layouts. - **Revisão** before install or update: "O que entra" (mods, layouts, file count, commit, the installed commit on an update), "O que o código faz" (each risk in `blocked` with the files: runs programs, reaches the network, reads files, writes files; or one `done` line saying it does none), "Atalhos" (`+ key → action` added, `= key continua …` kept as yours), and "Bloqueado" when a name is taken. ## How it behaves - A **package** is any folder of a repo holding `mods//main.js`: the repo root, or one folder per package. It may bring `layouts/*`, a `keys.json` and a `RECIPE.md`. - **Install** (`enter` on a repo, then `y`): shallow-clone into `~/.config/herdr-app/.mod-manager-cache/`, show the review, then copy `mods//` and `layouts/*`, merge `keys.json`, run `herdr-app check` on each mod and post a toast. Never overwrites: a mod or layout name that exists and was not installed by the manager blocks the install. A key you already use for something else stays yours. Layouts are added, never switched to. - **Records** of what was installed (source, folder, commit, mods, layouts, keys added, risks seen) live in shared state `"mod-manager.installed"`. - **Update** (`u`): the same review against the new commit; the package's own folders are replaced, its own keys follow the package unless you rebound them. Update status is `git ls-remote HEAD` against the recorded commit, checked when the panel opens. - **Update all** (`U`, after y/n): updates every outdated package whose review shows no clash and no risk that wasn't there when you installed it; the rest are listed for `u`. - **Remove** (`x`, after y/n): an installed package goes with its layouts and the keys it added that still run its action; a local folder is deleted; a symlink is only unlinked; Herdr's mods are refused. - **Marketplace** search: `gh api search/repositories` with `topic:herdr-mod `, 50 results per call, loaded as you page; without `gh` (or when it fails) the same URL anonymously through `fetch` (the runtime refuses an `Authorization` header). `s` toggles stars/updated, `/` searches, `←→` page, `o` opens the repo. - The review clone is deleted on install, on cancel and when the panel closes; clones older than an hour (a panel closed mid-clone) go when it opens again. ## Built from - `mods/mod-manager/`: `main.js` (the view), `core.js` (everything that touches files, with no Herdr import, so `node --test` runs it against real git), `mod.json` (`place: "none"`, dialog overlay 0.8 × 0.75). - `keys.json`: `cmd-shift-m` → `mod.open:mod-manager`. - Herdr functions: `exec`, `appHome`, `readTextFile`, `writeTextFile`, `shared`, `setShared`, `props`, `closeOverlay`, `notify`, `theme`; `InputState`/`Input` for the search box; `fetch`. - Programs: `git`, `gh` (optional), `herdr-app check`, `find`, `ls`, `cp`, `rm`, `mkdir`, `open`. - Props, for screenshots and direct entry: `start: "market"` opens on the marketplace; `review: "owner/repo"` opens the review of that repo. ## Watch out - **The mod runs programs, reaches the network and writes files**: it clones repos with git, queries GitHub, and copies into `~/.config/herdr-app/mods`, `layouts` and `keys.json`. That is its job; the review screen exists so you see the same about every mod you add. - The risk scan matches the source text (`exec(`, `hc(`, `fetch(`, `readTextFile(`, `writeTextFile(`…). It can over-report and it cannot prove a mod safe: mods aren't reviewed by Herdr. - AGENTS.md renames a mod on a name clash; the manager refuses instead, since renaming means rewriting paths inside someone else's code. - `exec` has a 30-second limit; a very large repo can fail to clone. - Mods you installed by hand show as `local`, with no source to update from. ## Done when - `herdr-app check mods/mod-manager` passes and `npm test` (node 20+) passes. - `cmd-shift-m` lists the same folders as `ls ~/.config/herdr-app/mods`, Herdr's last. - `m` lists the repos of https://herdr.dev/mods/ Community; `/` with a word narrows them. - Installing a repo whose mod name you already have shows "Bloqueado" and copies nothing. - Installing a new mod copies it, adds its free keys, passes `herdr-app check` and shows a toast; `x` removes it and those keys.