refactor: finish the AgentHub rename and drop the MCP server
Two leftovers from the rebrand, done together because they touch the same docs and manifests. **Data directory.** `agent-dashboard` could not simply be renamed in the source: it names a real directory holding the live SQLite database. Startup now moves it once, via `migrateLegacyDataDir()` in `server/lib/claude-home.js` — a same-filesystem rename, so it is instant even at multiple gigabytes and cannot leave two divergent copies. `getDataDir()` stays PURE and resolves to the legacy path until the move happens; the first version of this put the rename inside the getter, which meant `npm run test:server` relocated the developer's real database as a side effect. The call sits behind `require.main === module` and ahead of the router requires, because those pull in db.js, which opens SQLite at module load. A failed rename is silent and the old directory keeps being used: an unfashionable directory name beats a blank database beside an unreachable one. Same treatment for the port-discovery file (`.agent-dashboard.json` → `.agenthub.json`, old one dropped on write). Not renamed on purpose: the Sagi localStorage keys (renaming silently resets everyone's prefs) and the PWA manifest `id` (changing it orphans an installed app). **MCP server.** 4 tool calls in 46 days across 577,132 events, against 4,556 lines of TypeScript, a 2 MB committed build artifact, and a pre-commit guard that had already blocked commits twice. Deleted: `mcp/`, the maintainer skills and `mcp-reviewer` agent, the build check, `plugins/agenthub/.mcp.json`, `docs/MCP.md`, 12 npm scripts, 5 Makefile targets, and every doc section describing it. Kept, because they are unrelated things sharing the name: the Config Explorer's MCP tab and its API, per-lane Playwright MCP, the agenthub-config plugin's MCP audit, and the historical `mcp__plugin_agenthub_*` events that analytics must keep attributing. Verified: server 1432/1432, client 459/459, tsc clean, prettier clean. Both directions of the migration proven — a sandbox-HOME test run leaves the legacy directory untouched, and a real boot moves it with its contents intact.
This commit is contained in:
@@ -19,22 +19,66 @@ function getProjectsDir() {
|
||||
return path.join(getClaudeHome(), "projects");
|
||||
}
|
||||
|
||||
/** Data-directory name before the AgentHub rebrand. Still migrated from. */
|
||||
const LEGACY_DATA_DIR_NAME = "agent-dashboard";
|
||||
|
||||
/**
|
||||
* Canonical, user-global directory for the dashboard's writable state — the
|
||||
* SQLite database, VAPID keys, and transcript snapshots. It resolves to the
|
||||
* SAME absolute path for every launch path (`npm start`, `npm run dev`, and the
|
||||
* macOS/Windows desktop app), so they all share ONE database instead of each
|
||||
* host keeping its own. Lives under the Claude home, next to the hook discovery
|
||||
* file (`~/.claude/.agent-dashboard.json`).
|
||||
* file (`~/.claude/.agenthub.json`).
|
||||
*
|
||||
* An explicit `DASHBOARD_DATA_DIR` still wins — for tests, power users, or
|
||||
* anyone pinning a custom location. The earlier default was the repo-local
|
||||
* `data/` dir, which the desktop app (read-only bundle) couldn't use and which
|
||||
* never coincided with the web server's copy; see db.js for the one-time
|
||||
* migration that carries pre-existing databases into this location.
|
||||
*
|
||||
* Resolution is PURE — it stats, it never moves anything. An install predating
|
||||
* the rebrand still has its state under `agent-dashboard/`, and until
|
||||
* `migrateLegacyDataDir()` moves it, that is where the database is and that is
|
||||
* what this returns. Doing the rename here instead would mean any code path
|
||||
* that merely asks for the path — a test run, `--help`, a doctor probe —
|
||||
* silently relocates a multi-gigabyte database as a side effect.
|
||||
*/
|
||||
function getDataDir() {
|
||||
return process.env.DASHBOARD_DATA_DIR || path.join(getClaudeHome(), "agent-dashboard");
|
||||
if (process.env.DASHBOARD_DATA_DIR) return process.env.DASHBOARD_DATA_DIR;
|
||||
const { current, legacy } = dataDirCandidates();
|
||||
if (fs.existsSync(current)) return current;
|
||||
if (fs.existsSync(legacy)) return legacy;
|
||||
return current;
|
||||
}
|
||||
|
||||
function dataDirCandidates() {
|
||||
const home = getClaudeHome();
|
||||
return { current: path.join(home, "agenthub"), legacy: path.join(home, LEGACY_DATA_DIR_NAME) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a pre-rebrand data directory to its current name. Called deliberately,
|
||||
* once, from server startup — never from a getter (see getDataDir).
|
||||
*
|
||||
* A rename rather than a copy: same filesystem, so it is atomic and instant
|
||||
* even for a multi-gigabyte database, and it cannot leave two divergent copies
|
||||
* behind. Every failure is silent and non-fatal, because `getDataDir()` then
|
||||
* keeps resolving to the legacy directory: an unfashionable directory name is
|
||||
* strictly better than refusing to boot, and far better than a blank database
|
||||
* beside an unreachable one.
|
||||
*
|
||||
* @returns {string|null} the new path when something moved, else null.
|
||||
*/
|
||||
function migrateLegacyDataDir() {
|
||||
if (process.env.DASHBOARD_DATA_DIR) return null;
|
||||
const { current, legacy } = dataDirCandidates();
|
||||
if (fs.existsSync(current) || !fs.existsSync(legacy)) return null;
|
||||
try {
|
||||
fs.renameSync(legacy, current);
|
||||
return current;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,6 +326,7 @@ module.exports = {
|
||||
getClaudeHome,
|
||||
getProjectsDir,
|
||||
getDataDir,
|
||||
migrateLegacyDataDir,
|
||||
getTranscriptSnapshotDir,
|
||||
getSettingsPath,
|
||||
getTranscriptPath,
|
||||
|
||||
@@ -37,6 +37,11 @@ const DEFAULT_PORT = 4820;
|
||||
|
||||
/** Absolute path of the discovery file. */
|
||||
function getServerInfoPath() {
|
||||
return path.join(getClaudeHome(), ".agenthub.json");
|
||||
}
|
||||
|
||||
/** Where the discovery file lived before the AgentHub rebrand. */
|
||||
function getLegacyServerInfoPath() {
|
||||
return path.join(getClaudeHome(), ".agent-dashboard.json");
|
||||
}
|
||||
|
||||
@@ -168,6 +173,10 @@ function writeServerInfo(port) {
|
||||
try {
|
||||
const dir = getClaudeHome();
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
// Retire the pre-rebrand discovery file. It is dropped rather than merged:
|
||||
// its contents are live pids and ports, all of which this write is about to
|
||||
// re-derive, and leaving it would let an older reader resolve a dead port.
|
||||
fs.rmSync(getLegacyServerInfoPath(), { force: true });
|
||||
const existing = readInfoFile().filter(
|
||||
(s) => Number.isInteger(s.port) && s.port > 0 && s.pid !== process.pid && isPidAlive(s.pid)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user