feat: per-change-block hunk actions (#50), codex lanes without a pipeline, macOS LaunchAgent

- git (#50): stage-hunk/discard-hunk take an optional `block` — one run of
  consecutive +/- lines inside an @@ hunk. `onlyBlock` (server/lib/git-diff.js)
  cuts git's fresh hunk down to it, folding the other blocks into the side
  being checked; LaneDiffView hangs one review bar per block (unified + split)
  and its arrows walk blocks.
- git exclude: entries AgentHub writes for a lane go to the COMMON git dir with
  the lane's path prefix (server/lib/git-exclude.js, used by router-apply and
  lane-mcp) — a linked worktree's own info/exclude is never read by git, and a
  subdir lane has no .git. MCP sync no longer fails with ENOTDIR on a worktree
  lane or creates a stray .git in a non-repo lane.
- codex lanes carry no pipeline: codex-ingest mirrors only idle/running,
  codex-nudge is removed, agents install writes nothing for codex, the
  Workspace hides stage/pipeline/feature pickers/PipelineMap for them, and
  every server start clears leftover codex stage data and the old AGENTS.md
  stage block.
- Changes panel: a whole file opens for reading and enters the editor on a
  click on its text (caret at the clicked line), not automatically.
- macOS: LaunchAgent start-at-login (scripts/launchd-service.js, picked by
  scripts/service-manager.js).
- Adds the AgentHub introduction slides and their image-embedding script.
This commit is contained in:
2026-09-25 17:30:28 +07:00
parent 3f6e903c22
commit 952e8584f0
48 changed files with 3336 additions and 1579 deletions
+23 -11
View File
@@ -9,7 +9,8 @@
* The worker installs runtime dependencies, removes hook entries left behind by
* an older `npm run install-hooks` (they would double-count every event), puts
* the `agenthub` CLI on PATH, and starts the dashboard server — as a systemd
* `--user` service when available (see `systemd-service.js`), so it survives
* `--user` service or a macOS LaunchAgent when available (see
* `service-manager.js`), so it survives
* reboots without Claude Code being opened first; otherwise a detached spawn
* scoped to this session, same as before.
*
@@ -169,7 +170,7 @@ function fastPathOk(rt = runtimeDir()) {
// until the next reboot — and then the dashboard is simply gone, from a path
// Claude Code deleted long ago. Reading one file is cheap enough for a hot
// path; `unitIsStale` deliberately spawns nothing.
if (require("./systemd-service").unitIsStale("agenthub", PLUGIN_ROOT)) return false;
if (require("./service-manager").unitIsStale("agenthub", PLUGIN_ROOT)) return false;
// Leftover checkout hooks are the one defect that corrupts the DATA rather
// than the install: events carry no id, so a second handler doubles every
// event, every subagent row and every turn. `stripLegacyHooks` removes them —
@@ -591,7 +592,7 @@ function pruneRetiredPluginRoots(rt, root = PLUGIN_ROOT) {
/* no record to read — the other three protections still apply */
}
try {
const unitRoot = require("./systemd-service").unitRoot("agenthub");
const unitRoot = require("./service-manager").unitRoot("agenthub");
if (unitRoot) keep.add(path.resolve(unitRoot));
} catch {
/* best effort */
@@ -724,7 +725,7 @@ function bootstrap(rt = runtimeDir(), { force = false } = {}) {
log(rt, "built the dashboard UI bundle");
}
const svc = require("./systemd-service");
const svc = require("./service-manager");
// Who owns the running server decides how it may be retired. A unit of
// ours means systemd owns it — and this process is a descendant of that
// server, so it sits in the unit's cgroup. SIGTERM-ing the main process
@@ -763,6 +764,7 @@ function bootstrap(rt = runtimeDir(), { force = false } = {}) {
description: "AgentHub dashboard server (Claude Code plugin)",
workingDir: PLUGIN_ROOT,
execStart: `${process.execPath} ${path.join(PLUGIN_ROOT, "server", "index.js")}`,
argv: [process.execPath, path.join(PLUGIN_ROOT, "server", "index.js")],
env: {
NODE_ENV: "production",
NODE_PATH: path.join(rt, "node_modules"),
@@ -792,13 +794,14 @@ function bootstrap(rt = runtimeDir(), { force = false } = {}) {
log(
rt,
result === "unchanged"
? "systemd --user service already up to date"
? `${svc.label} already up to date`
: unitStale && !needsServer
? "repointed the systemd --user service at the current plugin version (it named a retired one)"
: "installed a systemd --user service — the dashboard now survives reboots without Claude Code"
? `repointed the ${svc.label} at the current plugin version (it named a retired one)`
: `installed a ${svc.label} — the dashboard now survives reboots without Claude Code`
);
} else if (needsServer) {
// No systemd (macOS/Windows/WSL without it), or the unit exists but
// No service manager (Windows, WSL without systemd, a Mac over SSH with
// no GUI login), or the unit exists but
// wasn't ours to touch — same detached-spawn fallback as before,
// scoped to this session only. Guarded by `needsServer`: entering this
// block for a stale unit alone must never spawn a second server onto
@@ -806,7 +809,7 @@ function bootstrap(rt = runtimeDir(), { force = false } = {}) {
const pid = startDashboard(rt);
log(
rt,
`started the dashboard server (pid ${pid})${result === "foreign" ? " — a foreign systemd unit named 'agenthub' already exists" : ""}`
`started the dashboard server (pid ${pid})${result === "foreign" ? ` — a foreign ${svc.label} named 'agenthub' already exists` : ""}`
);
}
}
@@ -843,8 +846,17 @@ function bootstrap(rt = runtimeDir(), { force = false } = {}) {
// file is written and the lock is gone, so even being killed here leaves
// no debris and no half-recorded bootstrap.
if (pendingSystemdRestart) {
log(rt, "handing the server over to systemd (restarting the unit)");
require("./systemd-service").restartUserService("agenthub");
const svc = require("./service-manager");
log(rt, `handing the server over to ${svc.kind} (restarting the unit)`);
// On launchd the restart is bootout + bootstrap, and a failed bootstrap
// leaves NOTHING running (systemd's restart either happens or leaves the
// old server up). This process survives it there, so fall back.
if (svc.restartUserService("agenthub") === "failed" && !serverIsLive()) {
log(
rt,
`${svc.kind} could not start the server — started it detached (pid ${startDashboard(rt)})`
);
}
}
}
}