Repository navigation
feat(bin): port the experimental Tern runtime backend - #6
Merged
Merged
Conversation
* feat(backend): add experimental Tern session backend
Adds bin/backends/tern.sh (one Tern session per home, one fm-<id> tab per
task, target tern:<session>/<block>), runtime detection from TERN_PANE with
TERM_PROGRAM=tern, process-level agent state, plugin-fed busy state, a
window-side Tern plugin that publishes agent state and colors task tabs,
PI_TUI_NATIVE=0 for Tern task panes, bin/fm-tern-autostart.sh, the omp idle
hint in the shared composer placeholder set, tests, and docs.
* test: clear the Tern pane marker in the shared test library
Suites run from a Tern pane otherwise auto-detect the tern backend where they
expect the no-marker tmux fallback.
* no-mistakes(review): Close exited Tern task blocks on kill; test fm-send routing
* no-mistakes(test): Gate Tern agent-state file on writer window pid, not age
* no-mistakes(document): Add Tern to stale backend lists across docs
* no-mistakes(lint): Silence intentional SC2016 warnings in Tern backend tests
* no-mistakes(ci): Lint 1 (ci-2) was caused by this PR, and I fixed it. ShellCheck SC2034 fired on `tests/fm-backend-tern.test.sh:101` because the test reset the Tern state-file cache with the assignment `FM_BACKEND_TERN_STATE_FILE_CACHED=`, a variable that is only read inside the sourced `bin/backends/tern.sh`. The invariant is that the shared lint must pass on every changed shell file, and that assignment was the only site that broke it. I changed the line to `unset FM_BACKEND_TERN_STATE_FILE_CACHED`. The behaviour is the same because tern.sh reads the variable as `${FM_BACKEND_TERN_STATE_FILE_CACHED:-}`, so unset and empty both force a fresh lookup. `bin/fm-lint.sh tests/fm-backend-tern.test.sh` now passes with the pinned ShellCheck 0.11.0, and `tests/fm-backend-tern.test.sh` passes with no failures. Behavior portable serial 2 (ci-1) was not caused by this PR, so I made no code change for it. The only failing test was `tests/fm-calm-pi-extension.test.sh`, with the error "grep disappeared from /export calm.html HTML while calm mode was on". The PR doesn't touch any Calm or Pi extension files. CI installs `@earendil-works/pi-coding-agent` unpinned (`.github/workflows/ci.yml:111,224`), so this run got Pi 1.0.4. The 1.0.x line came out on 2026-10-01 at 19:15, after main's last green run at 02:04 that day, and 1.0.4 was published on 2026-10-05. With Pi 1.0.4 installed locally in temp, the test failed the same way on this branch and on the untouched base commit b95d776. The failure comes from upstream Pi 1.0.4 changing its `/export` HTML, not from the Tern backend. It needs a separate Calm/Pi compatibility fix or a pinned Pi version in CI, both outside this PR's scope
…unchenguid#25) * tern plugin: publish current-format state as soon as window_pid is known window.luau's last_signature started equal to the empty string, which is also the signature of a window with no agent panes and no fm-* task tabs. A freshly loaded window that resolves window_pid before any pane/tab activity therefore skipped its first scan's write forever, leaving a stale or old-format agents.json from an earlier window in place for however long the window stayed idle - the reader in bin/backends/tern.sh then trusted that stale file as current. Fix: start last_signature as nil, a sentinel no real signature (including the empty one) can ever equal, so the first scan after window_pid is known always publishes. Writes stay change-driven after that. Adds a regression test that drives the real window.luau through a stubbed window-host API via the luau CLI, reproducing the exact empty-signature race and asserting the first write happens in current format (version, window_pid, blocks). Skips cleanly without luau on PATH, matching this suite's existing jq/tern skip convention. * docs: note window.luau's first-write guarantee and its luau-driven test
…t hint as an idle composer (kunchenguid#28) * fix(spawn): opt omp workers out of ONNX Runtime telemetry so no :memory:.ses lands in the worktree omp's local tiny-model worker runs onnxruntime-node 1.30 with the worktree as its cwd. Inside the worker sandbox its Microsoft 1DS telemetry cannot write its database under ~/Library, falls back to an in-memory store, and writes an untracked ':memory:.ses' stamp into the worktree, which made fm-teardown.sh refuse cleanup of finished work. Every omp launch now carries ORT_DISABLE_TELEMETRY=1, ORT's own whole-process opt-out. * fix(composer): read omp's running-agent hint as an idle composer While a subagent runs, omp 18.6.1 right-aligns '←← to see N running agent(s)' on its empty composer row. Its bright keycap survived ghost stripping, so the row read as pending input and doorbells to a worker waiting on its subagent were skipped until the subagent finished. The hint joins the shared idle-placeholder set beside omp's thinking-effort hint; typed text stays pending. A status row carrying the right-aligned session title is pinned as furniture too.
…mate-agents within the timer budget (kunchenguid#30) * tern: keep firstmate-agents inside the timer budget; stop omp title spinner in Tern workers * docs: record Tern 0.6.2 title-overlay and plugin timing evidence * no-mistakes(review): Test Tern omp overlay; stop pid lookup starving scans * no-mistakes(document): Document why plugin pid lookup skips consecutive ticks * no-mistakes(document): Show Tern overlay in omp launch shape
Main now preflights each backend adapter and its sibling libraries from an explicit per-backend list and refuses any backend missing from it, so the ported Tern adapter could not be sourced at all. Add tern with the three libraries bin/backends/tern.sh sources.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Port the experimental Tern runtime backend from danielkuykendall23-boop/firstmate onto this fork, so a home can run ship and scout workers as Tern tabs.
Secondmate spawns on Tern stay refused; secondmate support is out of scope.
What changed
ternbackend (bin/backends/tern.sh), thefirstmate-agentswindow plugin,bin/fm-tern-autostart.sh, anddocs/tern-backend.md.ORT_DISABLE_TELEMETRY=1on omp launches and reads omp's running-agent hint as an idle composer.ORT_DISABLE_TELEMETRY=1and the Tern overlay.docs/verification/worker-sandbox.mdstays deleted.fm_backend_sourcepreflights an explicit per-backend library list and refuses unknown backends, so the ported adapter could not load (not ok - could not source the tern adapter).Tern now lists the three libraries its adapter sources.
docs/verification/runtime-backends.md.CHANGELOG.mdwith an entry for the Tern backend.Effect on existing backends
The shared idle-placeholder pattern in
bin/fm-composer-lib.shgains two full-row, anchored omp hints (⇧⇥ to change thinking effort,←← to see N running agent(s)).On tmux and Herdr an omp composer showing only that hint now reads
emptyinstead ofpending; typed text still readspending.Tern auto-detection runs only when both
TERN_PANEandTERM_PROGRAM=ternare set, after tmux and Herdr; a home withconfig/backendset is unaffected.Testing
tests/fm-backend-tern.test.sh: 26 ok.tests/fm-composer-lib.test.sh: 46 ok.tests/fm-bootstrap.test.shandtests/fm-teardown-endpoint-safety.test.sh: pass.bin/fm-lint.shandbin/fm-doc-audience-check.sh: pass.tests/fm-backend-tern-smoke.test.shagainst an isolated Tern 0.8.3 (ownTERN_CONFIG_DIR, daemon socket, and window): 7 of 7 ok.--backend tern, twofm-sendsteers were acted on, agent state readalive, and teardown closed the tab and returned the worktree.tests/fm-omp-harness.test.shwas not usable on this machine: its first case fails identically on unchangedmainwhen run under omp, so its later launch-line cases did not run.