Files
ruflo/v3/@claude-flow/cli/bin
Mathew BeaneandRuFlo 4c5fdb1fac feat(harness): report the live process, not the install (#3521)
* feat(harness): report the live process, not the install

`ruflo harness` reports what is already running for a working tree: the
host session, a live daemon pid, ruflo MCP servers whose cwd is inside the
tree, processes holding the memory databases open, and teams that are
still active. `doctor` and `status` stay as they are.

It is observe-only:
- bin/cli.js runs `harness` before the CLI class loads, so no daemon
  autostart, update check, policy migration, helper refresh or
  proven-config adoption runs, and nothing is written to disk. The CLI
  class also exempts it (OBSERVE_ONLY_COMMANDS) for programmatic callers.
- With --hook it fails silently: exit 0, no output, no stack, even when
  dist/ is missing.

Probing (src/services/live-harness.ts):
- MCP: a launcher plus a ruflo identity token plus `mcp [start]`; the
  process cwd must equal the root or sit under it on a path boundary.
  Shells whose argv mentions the text, other tools' `mcp start`, and
  sibling directories no longer count. npx wrappers count once.
- Output shows a count, pids and a redacted command (program and
  subcommand only); arguments never appear.
- Memory: .swarm/memory.db and .swarm/agentdb-memory.db, with WAL/SHM.
- Teams: `.claude-flow/teams/<name>/team.json` and the legacy flat file.
  A team is live only if not shut down and it has activity within a TTL
  (30 min, RUFLO_HARNESS_TEAM_TTL_SECS) or a running member pid; others
  are reported as stale.
- Daemon: EPERM counts as alive; a live pid that is not our daemon (pid
  reuse, another workspace) reads as stale.
- One ps and at most two batched lsof calls under a 4 s overall deadline;
  /proc is used for cwd on Linux. Missing ps/lsof (Windows, minimal
  Linux) reports `probe-unavailable` and `?` counts instead of idle.
- The root is compared in both spellings (/tmp and /private/tmp).
- Host detection walks up past `sh -c` and other wrappers.

The Codex SessionStart hook is opt-in: `ruflo harness --print-codex-hook`
prints a .codex/hooks.json that runs this install by absolute path with
RUFLO_DAEMON_AUTOSTART=0 and --no-update. No hooks file is committed to
the repo.

Tests: __tests__/harness-live-probe.test.ts and
__tests__/harness-observe-only.test.ts.

Co-Authored-By: RuFlo <ruv@ruv.net>

* feat(harness): list `harness` in the capability brain's command manifest (#3521)

The capability brain (capability-brain.ts) advertises the top-level CLI
commands from a checked manifest that landed on main after this PR was
opened. `harness` is a top-level command here, so it goes on the list and
the count in guidance-brain.test.ts moves from 53 to 54.

---------

Co-authored-by: RuFlo <ruv@ruv.net>
2026-10-20 05:42:13 -04:00
..