`detectHarness` reports a first-match guess as `confidence: "detected"` on multi-harness machines
What LifeOS does here
skills/LifeOS/Tools/InstallEngine.ts exports detectHarness(home), which decides which
agent harness is hosting a LifeOS install and therefore which config root and skills
directory the setup writes into. skills/LifeOS/Tools/DetectEnv.ts is the thin CLI over it,
and skills/LifeOS/Workflows/Setup.md step 1 branches on its output.
Current behavior
detectHarness walks a fixed candidate list — claude-code, opencode, hermes, cursor,
openclaw — in three passes: config dir plus binary on PATH, config dir alone, binary alone.
Each pass returns the first candidate that qualifies. Candidate order is therefore the
tiebreaker whenever more than one harness qualifies in the same pass, and claude-code is
first in the list.
The result of the first pass is labelled confidence: "detected". In the source, "detected"
means "the harness binary was found on PATH" and is documented as fact, in contrast to
"assumed". On a machine with two installed harnesses the label is accurate about the binary
and wrong about the conclusion: the binary was found, but so was another one, and nothing
established which harness is actually running the install.
detectEnv() calls detectHarness(home) with no override parameter, so a caller who knows
the answer has no way to supply it.
Reproduction
Against v7.40.4, with a home containing both ~/.claude and ~/.config/opencode, and both
claude and opencode on PATH:
mkdir -p h/.claude h/.config/opencode bin
for b in claude opencode; do printf '#!/bin/sh\necho %s\n' "$b" > bin/$b; chmod +x bin/$b; done
echo 'import { detectHarness } from "<checkout>/skills/LifeOS/Tools/InstallEngine.ts";
console.log(JSON.stringify(detectHarness("'$PWD'/h")));' > r.ts
PATH="$PWD/bin:$PATH" bun r.ts
Output:
{"name":"claude-code","configRoot":".../h/.claude","skillsDir":".../h/.claude/skills","confidence":"detected"}
The same output appears whether the install is driven from Claude Code or from OpenCode. An
OpenCode user running the LifeOS setup gets a payload deployed into ~/.claude, reported as
a detected fact rather than as an ambiguity to confirm.
Why the existing safeguard does not cover this
The function's own comment cites issue #1448 and the rule it implements: "Anything short of a
binary match is reported as confidence assumed, never as fact." That rule addresses a
different failure — a leftover config directory outranking a live install. It says nothing
about two live installs, which is the case where order alone decides. Setup.md instructs the
operator to confirm an assumed harness with the user; because this path reports detected,
that confirmation step never triggers.
Suggested direction
Two changes. They are not interchangeable: (2) closes the failing path on its own, while (1) only helps if the caller is updated to pass the value.
- Accept an explicit harness from the caller: a
--harness <name>flag onDetectEnv.ts, an override parameter ondetectEnv(), and — the part that actually matters —Setup.mdstep 1 invoking it with the active harness. The harness running the setup knows its own identity, so this is the reliable signal; but adding the flag without changing the invocation leaves the failing path exactly as it is today. - When more than one candidate qualifies in the same pass, do not return the first one as
detected. Either downgrade toassumedand list the tied candidates soSetup.md's confirmation step fires, or add a distinctambiguousconfidence value.
Suggested acceptance tests: two qualifying candidates in the strongest pass must not produce
confidence: "detected" for whichever happens to be first in the array; an explicitly supplied
harness must win over detection; and the documented setup path must reach detection with that
value supplied rather than relying on inference.
Affected versions
Present in v7.40.4, the current release at the time of writing. Not verified before that tag.
Landed: when more than one harness qualifies, detection returns the first as "assumed" so the Setup confirm step fires, and LIFEOS_HARNESS overrides outright. Next release. Thanks.