122 Commits

Author SHA1 Message Date
chahinebrini
eec2050a32 feat(mcp): agenthub mcp install — print per-CLI registration config
Removes the registration friction: `agenthub mcp install` prints ready-to-paste
MCP config for Claude Code, Codex and Kimi, with the hub URL filled in from the
project config. `agenthub mcp` (no action) still starts the stdio server, so the
MCP-client spawn command is unchanged. Bump 0.7.2 -> 0.7.3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 01:47:14 +02:00
chahinebrini
96fdf0dbd4 Fix board card expansion layout 2026-06-29 01:31:45 +02:00
chahinebrini
c0ac093f46 docs(templates): MCP-first implementer guides (CLI fallback)
Implementer onboarding now points at the MCP tools first (agenthub_work ->
implement -> agenthub_task_review -> loop), with the CLI as the fallback when
the MCP server isn't registered. Reflects the MCP pivot. Bump 0.7.1 -> 0.7.2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 01:28:27 +02:00
chahinebrini
2d89f808b8 feat(config): named agent roster (config.agents)
Adds an optional `agents` roster to the project config: agent name -> role +
model + provider (kind). The team view can now show named agents (claude,
codex, kimi, windows-claude, backyard, mo, zied, …) with a FIXED role and the
model behind them, instead of inferring role/identity from whichever tasks an
agent happened to touch (which made one agent appear under several roles).

Bump 0.7.0 -> 0.7.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 01:16:49 +02:00
chahinebrini
15f139429e Polish AgentHub board UI 2026-06-29 00:55:55 +02:00
chahinebrini
5586f2c15b feat(mcp): MCP server — agenthub hub tools over stdio
Solid-collaboration foundation: agents invoke STRUCTURED tools instead of
shelling out to the CLI — so a tool can't be narrated away, hallucinated as
"doesn't exist", or mistyped. Confirmed working for Claude / Codex / Kimi
(all speak MCP).

- src/mcp/server.ts: `agenthub mcp` starts a stdio MCP server exposing 16
  tools (work, task_list/show/create/assign/claim/review/reopen/done,
  memory_add/search, handoff_read/create, decision_create, hello, status).
  Thin layer over the SAME core: proxies through the REST API (remoteClient)
  when a hub is configured — so board, SSE, status auto-refresh and CLI keep
  working unchanged — else local services. agenthub_work blocks on SSE until
  a task addressed to the agent is claimable, then returns it + its handoff.
- `agenthub mcp` command; excluded from the update-notify (stdio purity).
- Verified: initialize + tools/list (16) + tools/call (status, task_list)
  proxy to the live hub.

Does NOT change the dormant-agent reality (agents still loop agenthub_work);
it makes every interaction reliable. Bump 0.6.1 -> 0.7.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 00:52:13 +02:00
chahinebrini
986639a5f3 TSK-0028: AgentHub UI foundation + /team page
- Add src/server/ui-shared.ts: design tokens, agentAvatar(), statusPill(),
  escapeHtml(), liveTimerJs(), pageHeader(). No emojis, no deps.
- Add src/server/team.ts: role hierarchy renderer (architect -> implementer/
  reviewer/tester) with per-agent free/busy state derived from in-progress tasks.
- Wire GET /team route in src/server/routes.ts.
- Add tests/team.test.ts and tests/ui-shared.test.ts.

Build: npm run build clean. Tests: 132 passed (was 122).
2026-06-29 00:24:39 +02:00
chahinebrini
b5f75c6c65 fix(update): harden auto-update — fire agenthub update directly on tick
The old auto path checked `HEAD..origin/branch` right after kicking off a
background fetch, so it read a stale origin ref and only fired on the SECOND
invocation (and never if the agent sat in one long-running `work`).

Now: when AGENTHUB_AUTO_UPDATE is set, a throttled tick (≤1h) spawns
`agenthub update` directly in the background. update does its OWN fresh fetch
+ reset + build and no-ops when current — so it self-heals on the FIRST
invocation, no stale-ref lag. Notify-only path (no flag) unchanged.

Removed the now-unused cooldown const. 122/122 green. Bump 0.6.0 -> 0.6.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 00:29:59 +02:00
chahinebrini
78bbebf435 feat(task): agenthub task assign — architect addresses an open task to an agent
Closes the addressing gap that left a waiting `agenthub work` blocked: the
remaining Win tasks were titled "Win L2: …" / unassigned, so they matched
no agent and the daemon waited forever.

`agenthub task assign <id> --agent <name>` sets assignedTo WITHOUT claiming
(status stays open) and fires task/updated — so an agent's blocked `work`
re-checks, matches via assignedTo, and auto-claims it. The architect can now
route a specific open task to a specific agent and have its daemon pick it up.

- taskService.assignTask; PATCH /tasks/:id handles assignedTo-without-status;
  remoteClient.assignTask; CLI `task assign`.
- test: assign keeps status open + sets assignedTo; start/work then claims it
  via the assignedTo match. 122/122 green.

Bump 0.5.0 -> 0.6.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 00:12:50 +02:00
chahinebrini
ec378131e4 feat(watch): --await-review — architect review-queue notifier
Closes the architect-side gap: the auto-claim daemon wakes implementers on
new tasks, but the architect had no signal when an implementer submitted.

`agenthub watch --await-review` exits (after printing) the moment a task
enters `review` — including any task already in review on connect (initial
check) — so the architect can run it in the background and be re-invoked by
the harness the instant a submission needs a verdict.

- watch.ts: awaitReview option, initial fetchReviewTasks() check + SSE exit
  on task→review.
- index.ts: --await-review flag.
- tests: returns immediately on already-pending review; exits on a review
  transition while watching. 121/121 green.

Bump 0.4.0 -> 0.5.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 18:53:40 +02:00
chahinebrini
d2b26cc64c feat: agenthub work — auto-claim daemon (TSK-0018)
The missing autonomy step: an implementer no longer needs a human prompt
per task. `agenthub work --agent <name> --role <role>` announces, then:
  - claims an already-open task addressed to the agent immediately, or
  - blocks on the SSE stream until one appears (newly delegated OR
    reopened after review), then claims + prints it.

Loop: work → implement → `task review` → work. New/reopened tasks are
picked up automatically; run it in the background so the wait doesn't tie
up the turn.

- src/cli/commands/start.ts: extracted announceAgent / findAddressedOpenTask
  / claimAndPrintTask (shared by start + work); addressed-match now also
  covers assignedTo (reopened tasks coming back for rework).
- src/cli/commands/work.ts: wait-and-claim via /events, with a gap-close
  re-check after subscribing and an optional --timeout.
- index.ts: `agenthub work` command.
- templates: implementer guides lead with `work` (the autonomous loop),
  keep `start` as the one-shot.
- tests: immediate claim (local) + wait-then-claim (server SSE). 119/119.

Bump 0.3.1 -> 0.4.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 18:18:47 +02:00
chahinebrini
961675ac40 fix(server): auto-regenerate status snapshot on every change
The status snapshot (.agenthub/status/latest.md) was only refreshed on an
explicit `status --update`, so it drifted stale and misled agents that
follow golden rule #2 ("read status/latest.md") — e.g. an implementer
seeing an old task list and picking the wrong task.

- src/server/statusRefresh.ts: subscribe to the event bus and regenerate
  the snapshot on every task/handoff/decision/memory change (REST and
  filesystem-watch paths), debounced 300 ms. Presence ('agent') events
  are skipped; the snapshot lives outside the watched dirs so it can't
  feed back into the watcher.
- wired into startServer lifecycle (start + stop on close).
- test: status/latest.md reflects a new task shortly after POST /tasks.
  117/117 green.

Bump 0.3.0 -> 0.3.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 17:27:19 +02:00
chahinebrini
7723360054 feat: agenthub start — one-command onboarding (no copy-paste prompts)
An agent runs ONE command and is working: it announces presence, claims
the open task addressed to it, and prints the task + its handoff + the
next step. Removes the per-agent kickoff copy-paste.

- src/cli/commands/start.ts: `agenthub start --agent <name> --role <role>`.
  "Addressed to <agent>" = task title starts with "<agent>:" OR a handoff
  has toAgent=<agent>. Claims it, prints task body + handoff + the review
  gate reminder. No addressed task → lists open role tasks to pick.
  Works on local + --server paths.
- templates: implementer guides (AGENTS/CODEX/KIMI.md) now lead with
  "On your first turn, RUN `agenthub start …` — do not just summarize",
  so a fresh session self-onboards from one trigger word.
- tests: start auto-claims the addressed task, ignores others, no-ops on
  empty queue; templates test updated for the new commands. 116/116 green.

Bump 0.2.2 -> 0.3.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 17:15:25 +02:00
chahinebrini
b0973a878c feat(update): opt-in background auto-update (AGENTHUB_AUTO_UPDATE)
Set AGENTHUB_AUTO_UPDATE=1 and the install keeps itself current with no
manual `agenthub update` — ideal for the Windows client.

maybeNotifyUpdate now:
- auto mode: refreshes the behind-count hourly (vs 24h) and, when behind,
  spawns a detached `agenthub update` (fetch → reset → install → build)
  that doesn't block the current command; the next invocation runs the
  new version. A 10-min cooldown stamp prevents a second build spawning
  while one is in flight.
- otherwise: unchanged "run `agenthub update`" hint.

Safe to enable anywhere: `update` no-ops when current and refuses to
discard unpushed local commits, so the authoring machine is protected.
Cross-platform (no OS scheduler needed). Bump 0.2.1 -> 0.2.2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 17:00:31 +02:00
chahinebrini
353c139796 feat: review-gate (task review/reopen) + autonomous role guides
Implements the architect-controlled workflow: implementers submit work
for review, only the architect closes tasks.

- CLI: `agenthub task review <id>` (implementer submits → status review)
  and `agenthub task reopen <id>` (architect re-triggers → status open).
  Server already supported both statuses; now exposed on local + --server
  paths, with remoteClient.reviewTask/reopenTask.
- templates: AGENTS.md + role guides rewritten so agents self-drive the
  CLI on open (hello → claim → implement → task review → wait), with the
  hard rule that ONLY the architect runs `task done`. Implementer guides
  (codex/kimi) never call done; architect guide documents done/reopen.
- tests: review/reopen SSE events + formatEvent "Task review"/"Task
  reopened" lines. 113/113 green.

Bump 0.2.0 -> 0.2.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 16:48:42 +02:00
chahinebrini
45070222d0 feat: zero-config auto-connect + agent presence (join-announce)
Agents now connect to the hub with no manual env/flag, and announce
themselves on join — restoring the agreed onboarding flow.

Auto-connect (resolveContext):
- An initialized project WITHOUT a configured serverUrl now falls
  through to LAN auto-discovery (previously it went straight to local
  mode, so agents in an initialized repo never found the server). The
  discovered URL is persisted to the project config, so the next
  command is instant.
- IP-change self-heal: when a configured server is unreachable,
  runRemote re-discovers the live server and updates the config so the
  next command reconnects automatically.

Presence (join-announce):
- POST /announce broadcasts an ephemeral 'agent/joined' event (not
  written to disk). New `agenthub hello --agent <name> --role <role>`
  posts it; watchers print "AgentHub: <agent> joined (<role>)".
- AgentHubEvent extended with type 'agent' + actions 'joined'/'left';
  formatEvent renders presence lines; remoteClient.announce() added.

Tests: formatEvent agent lines + /announce SSE e2e. 109/109 green.
Bump 0.1.2 -> 0.2.0 (CLI --version too).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 16:33:03 +02:00
chahinebrini
ff79cbb639 feat(cli): brand all AgentHub console output with "AgentHub:" prefix
Every user-facing line — the watch stream and each command's success
line, on both the local and --server (remote) paths — now carries an
"AgentHub:" prefix so it's recognizable in any agent's console
(Claude / Codex / Kimi), independent of the board.

- watch: formatEvent rewritten to verb-based, branded lines
  ("AgentHub: Task received <id>  <title>  [status]",
   "AgentHub: Task done <id>  by <agent>", "AgentHub: Handoff …"),
  plus an "AgentHub: connected" line on stream start.
- task/handoff/decision/memory/delegate/init + server-listening lines
  branded on the local command path.
- cli/index.ts: same branding on the --server remote path (the path
  agents actually hit), so CLI line and SSE stream now match.
- tests: formatEvent assertions updated to the branded format
  (regex-tolerant of column padding). 106/106 green.

codex + kimi stay implementers by convention (role=implementer +
assignedTo) — no schema change. Bump 0.1.1 -> 0.1.2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 16:09:15 +02:00
chahinebrini
722388cb00 feat(server): emit SSE for CLI/file writes via filesystem watcher (TSK-0006)
Closes the documented /events limitation: mutations made through the
local CLI (direct file + SQLite writes, no --server) bypassed the
in-process event bus and were invisible to SSE subscribers. A watcher
(e.g. a Windows client) was therefore NOT triggered when another agent
created a task via plain `agenthub task create`.

- src/server/fsWatch.ts: watch the entity dirs (tasks/handoffs/
  decisions/memory); on any .md change, parse the entity and emit the
  matching AgentHubEvent. Debounced per-file; self-creates dirs so it
  attaches even before the first write.
- src/server/events.ts: shared dedup cache (signature = type🆔stamp)
  + emitChange() so the REST path and the watcher deliver each change
  exactly once (no echo when REST writes the file the watcher sees).
- src/server/routes.ts: route emits go through emitChange(); update the
  stale limitation comment.
- src/server/index.ts: start/stop the watcher with the server lifecycle.
- tests/sse.test.ts: CLI-write -> SSE, CLI-update -> SSE, and REST
  dedup (exactly-once). 102/102 green.

Effect: a watcher is auto-triggered the instant any agent creates a
task, with or without --server. Bump 0.1.0 -> 0.1.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 15:43:33 +02:00
chahinebrini
9f3dc28030 fix(cli): memory add no longer prompts when --category is supplied (non-interactive agents)
Local-mode branch of 'memory add' omitted category when calling memoryAdd, so it always fell through to an interactive select() prompt — which throws in non-TTY agent contexts and breaks the reporting loop. Forward category; add tests for the non-interactive flag path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 22:59:37 +02:00
chahinebrini
9c749beacb feat(activity): per-task timeline endpoint, board expand, --task/--tokens/--duration/--by flags
GET /tasks/:id/activity returns a time-sorted ActivityItem[] assembled from existing data (task created, handoffs by taskId, memory by relatedTasks, current status). memory add + task done gain optional tokens/duration/by metadata surfaced in the timeline. Board cards expand inline to show the timeline. Index gains taskId + relatedTasks columns with migrations. 74 -> 97 tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 14:49:47 +02:00
chahinebrini
4e5e5ae6bb feat(realtime): SSE event channel + agenthub watch (TSK-0006 part 1)
- src/server/events.ts: in-process EventEmitter bus (AgentHubEventBus);
  singleton per server process, unlimited listeners for SSE fan-out.
- src/server/routes.ts: GET /events SSE endpoint — keepalive every 25 s,
  optional ?role= server-side filter, reply.hijack() for clean streaming;
  eventBus.publish() called on every successful mutating route (POST tasks/
  handoffs/decisions/memory, PATCH tasks/:id).
- src/cli/commands/watch.ts: SSE client using Node fetch + ReadableStream
  reader; exports parseSSEBuffer + formatEvent for testability; --once flag
  exits 0 after first event (turn-based agent use case); --role for client-
  side filtering (additive to server-side filter).
- src/cli/index.ts: register agenthub watch command via resolveContext.
- tests/sse.test.ts: 18 new tests (74 total, all green) — unit tests for
  parseSSEBuffer + formatEvent, integration tests for eventBus on each
  mutation type, E2E SSE stream + role-filter tests over real HTTP.

Limitation (documented): only REST mutations through the server emit events.
Local-CLI writes (direct file+SQLite) are invisible to subscribers — a
filesystem-watch increment is deferred to a later phase.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 00:16:16 +02:00
chahinebrini
b405b268a5 feat(board): fix gaps A+B — full task status transitions + handoff who→whom
GAP A: extend PATCH /tasks/:id to support all five TaskStatus values
(open, in_progress, review, done, cancelled). Add reviewTask, cancelTask,
reopenTask helpers in taskService. Claim semantics preserved: in_progress
requires assignedTo. Board columns for review and cancelled now reachable
via the API.

GAP B: index fromRole/toRole/fromAgent/toAgent on handoff upsert. SQLite
migration guard adds columns to pre-existing DBs without data loss. Board
renderHandoffs shows "fromRole[@agent] → toRole[@agent]" via &rarr; arrow.
GET /handoffs now carries the routing fields in every index entry.

Tests: +14 (56 total, 21 files, all green). Covers every new status
transition, index field presence, board markup assertions, and a guard for
the claim-without-assignedTo 400.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 23:41:54 +02:00
chahinebrini
d0e45230bc feat(server): add static Trello-like task board at GET /board
Serves a single self-contained HTML page (inline CSS+JS, no build step,
no framework, no npm deps) that polls /tasks, /handoffs and /decisions on
the same origin and renders a column board by task status
(open/in_progress/review/done/cancelled). Each card shows id, title, role
and assignedTo; small handoffs + decisions panels below; auto-refresh
every 4s with a connection indicator. Purely additive and read-only — the
CLI core path is untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 23:35:28 +02:00
chahinebrini
9d18022076 docs: add WINDOWS_CONTINUE.md — Claude Code handoff prompt for Windows protection validation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 23:31:52 +02:00
chahinebrini
cce4ad78d3 chore(pilots): add self-contained TSK-0003 Windows protection pilot script
One-command Windows validation: claims TSK-0003, runs the magic-reviewed DNS-only protection flow (self-elevating), verifies, and reports back via agenthub memory add + task done. Delivered via git since Mac<->Win clipboard is unavailable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 22:43:24 +02:00
chahinebrini
074b75f909 feat(cli): add agenthub update self-updater + non-blocking update hint
agenthub update: fetch + reset install to origin/<branch> + reinstall + rebuild, so users never touch git or pnpm. Robust to a dirty working tree (the 'commit before pull' wall) by resetting to remote; guards unpushed local commits and refuses to discard them. Adds a daily, non-blocking update hint on startup (detached background fetch + instant local comparison, like gh/npm/brew) that never auto-applies. Tests for the non-git-install path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 22:24:53 +02:00
chahinebrini
79f5c8afde feat(cli): single-instance guard, ambient discovery, graceful errors, cwd-robust
Make the network MVP simple to operate: server start refuses a second instance on a port already serving AgentHub (single source of truth, prevents discovery split-brain); commands auto-discover a LAN server when run outside any project so the CLI works from any directory with zero config; walk up to the nearest .agenthub project (cwd-robust) and serve the project root; replace raw stack traces with actionable messages; add tests for findProjectRoot and the single-instance guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 22:15:14 +02:00
chahinebrini
9b8d587e9d feat(discovery): auto-discover LAN server during init; zero-config network mode 2026-06-25 13:46:39 +02:00
chahinebrini
3ebd33c4be feat(cli): store serverUrl in config during init; auto-connect LAN clients 2026-06-25 13:33:12 +02:00
chahinebrini
c073f9a213 fix(network-mode): wrap remote calls for errors, skip Content-Type on empty body, use program CLI in E2E 2026-06-25 13:21:10 +02:00
chahinebrini
d53fbf6794 docs(plan): add network mode implementation plan 2026-06-25 12:46:16 +02:00
chahinebrini
16d5fa7a45 docs(readme): document network mode 2026-06-25 12:43:05 +02:00
chahinebrini
efd0c7edfd test(e2e): add network mode end-to-end test; log actual server URL 2026-06-25 12:41:48 +02:00
chahinebrini
7eff25129f fix(server): 404/400 error handling and consistent delegate behavior; add server route tests 2026-06-25 12:40:11 +02:00
chahinebrini
b5a70b226b fix(remoteClient): correct IndexEntry import path 2026-06-25 12:37:51 +02:00
chahinebrini
b5e854fb10 feat(server): add full CRUD endpoints for network mode 2026-06-25 12:33:21 +02:00
chahinebrini
c2e3b0298e feat(server): support --host for LAN binding and export buildApp 2026-06-25 12:33:04 +02:00
chahinebrini
407202f092 feat(cli): add --server / AGENTHUB_SERVER remote mode wiring 2026-06-25 12:32:50 +02:00
chahinebrini
fb3da93f59 feat(cli): add RemoteClient for network mode 2026-06-25 12:32:11 +02:00
chahinebrini
a0af702344 fix(services): guard getters, use counter for memory, deduplicate listEntities 2026-06-25 12:30:14 +02:00
chahinebrini
908a89d772 feat(services): add delegate service and refactor CLI 2026-06-25 12:24:14 +02:00
chahinebrini
6708dde532 feat(services): add status service and refactor CLI 2026-06-25 12:23:57 +02:00
chahinebrini
e69e81135a feat(services): add memory service and refactor CLI 2026-06-25 12:23:45 +02:00
chahinebrini
fff8a61ad9 feat(services): add decision service and refactor CLI 2026-06-25 12:23:23 +02:00
chahinebrini
6c8ee37a08 feat(services): add handoff service and refactor CLI 2026-06-25 12:23:02 +02:00
chahinebrini
b4874afbe9 refactor(cli): use taskService in task command 2026-06-25 12:22:37 +02:00
chahinebrini
4a8f5cbb8e feat(services): add task service module 2026-06-25 12:18:49 +02:00
chahinebrini
d73ff27129 chore(git): ignore .worktrees directory 2026-06-25 12:15:35 +02:00
chahinebrini
5531bfa282 docs(spec): add network mode design for multi-agent LAN usage 2026-06-25 11:58:12 +02:00
chahinebrini
22f3c7dda6 chore(deps): lock dependencies and allow better-sqlite3 build scripts 2026-06-25 00:18:01 +02:00