Skip to content

feat(harness): add Kimi CLI as a verified crewmate harness - #122

Closed
nickolastheodoulou wants to merge 1 commit into
kunchenguid:mainfrom
nickolastheodoulou:feat/kimi-cli-harness
Closed

nickolastheodoulou wants to merge 1 commit into
kunchenguid:mainfrom
nickolastheodoulou:feat/kimi-cli-harness

Conversation

@nickolastheodoulou

Copy link
Copy Markdown

Adds Kimi CLI as a first-class crewmate harness so tasks can run as background tmux agents.

Changes:

  • Detect kimi/kimi-cli/kimi-code in bin/fm-harness.sh process ancestry
  • Add kimi launch template to bin/fm-spawn.sh using kimi-cli --afk --print
  • Add config/kimi-empty-mcp.json so a broken server in ~/.kimi/mcp.json cannot block launch
  • Document Kimi CLI harness facts in .agents/skills/harness-adapters/SKILL.md
  • Fix bin/fm-brief.sh shell-parse error from apostrophe inside heredoc
  • Fix bin/fm-spawn.sh oh-my-zsh auto-update prompt mangling treehouse get

Verification:

  • End-to-end test spawn completed: agent read brief, ran shell commands, wrote status, exited, and triggered the watcher.

- Detect kimi/kimi-cli/kimi-code in fm-harness.sh process ancestry
- Add kimi launch template to fm-spawn.sh using kimi-cli --afk --print
- Use empty MCP config to avoid broken servers in ~/.kimi/mcp.json blocking launch
- Document Kimi CLI harness facts in harness-adapters skill
- Fix fm-brief.sh shell-parse error from apostrophe inside heredoc
- Fix fm-spawn.sh oh-my-zsh auto-update prompt mangling treehouse get
@dominikbullo

Copy link
Copy Markdown

PLAN
Approach: decision-first /flip, entirely from stored fields; BUY logic (flip_pricer) untouched.

  • Near-miss computed on read in app/api/main.py (_flip_near_miss): skip rows that fail exactly ONE soft gate within a tolerance: sell-through in [FLIP_NEAR_MISS_MIN_SELL_THROUGH_PCT=35, floor), p25 profit in [-FLIP_NEAR_MISS_P25_SEK=200, 0), or price < p10 as the only risk reason with price >= 90% of p10. Any other failing gate (confidence, labour, other risk, profit floor) => not near-miss. Row gets near_miss = gate name or null.
  • Outcomes: existing path is a mutable owner_action/result_sold_sek on flip_items (no price/fees, not append-only), so add append-only table flip_outcomes (uid, kind bought|sold, price_sek, fees_sek, note, ts) + POST /flip-items/{uid}/outcome; it also keeps the legacy columns in sync. Realised profit = sold - fees - matching bought cost (+ legacy result_sold_sek rows without records). Config FLIP_SUBSCRIPTION_SEK_PER_MONTH (default 0) -> net since first outcome in /flip/stats (feat(x-mode): dismiss skipped X mentions through the relay #120).
  • /flip page rewritten (template/JS only): header N BUY · M near-miss · last scan X min ago · realised X kr, chips BUY|Near-miss|All (default BUY), new card (photo, ask -> pay up to, profit/worst, comps n+spread, age, distance, seller, time left, % confidence chip, no +fees/VAT), Open+Bought primary, Sold in 2 taps, sort profit/newest/ending/distance, phone sticky bar + filter drawer; detail page theme aligned.
  • Observability: counter deals_flip_outcomes_total{kind}, gauge realised profit, events log rows "flip outcome bought/sold ..." on /events.
    Files: app/store.py, app/config.py, app/metrics.py, app/api/main.py, tests/, docs.
    Proof: pytest full suite once; run app against copy of live /flip-items data, desktop 1440 + phone 390 screenshots before/after via chrome-devtools-axi; curl POST outcome + /events + /metrics.
    Out of scope: pricing/liveness (fix(fm-brief): bash 3.2 here-doc parse error breaks default brief scaffolding #121), BUY thresholds.

@dominikbullo

Copy link
Copy Markdown

PR
https://github.com/dominikbullo/deals/pull/125 — decision-first /flip: BUY/Near-miss/All tabs with header counts + realised profit, new cards (ask → pay up to, profit/worst pair, comps, age, distance, seller, time left, % confidence chip, no +fees/VAT), Open+Bought primary with price/fees sheet, append-only flip_outcomes ledger + POST /flip-items/{uid}/outcome, sort/search bar + drawer for phone, detail page on the list theme. Metrics: deals_flip_outcomes_total{kind}; /events rows per outcome.

Deviations from PLAN: (1) pre-purchase checklist kept as the confirm gate inside the Bought sheet rather than removed; (2) paste-a-link row moved into the filters drawer (⚙ Filters · paste link); (3) item page's own Bought/Record sale still use legacy PATCH (counted via fallback, no ledger row); (4) added a p10_ratio knob (FLIP_NEAR_MISS_P10_RATIO=0.9) and distance/ending sort keys to /flip-items.

@dominikbullo

Copy link
Copy Markdown

VERIFY
Data: /flip-items fetched from live (10 726 rows) seeded into a local SQLite copy + live writer term set; app run on it (uvicorn :8765). Screenshots in /home/dominikbullo/Projects/firstmate/data/deals-flip-ux/: before-{desktop,phone}.png, after-{desktop,phone}.png, after-{desktop,phone}-nearmiss.png, after-phone-drawer.png, after-desktop-{bought-sheet,sold-sheet,detail}.png, after-phone-detail.png.

  • Default view: 6 BUY · 17 near-miss (259 total) vs 8 mostly-SKIP cards before; phone first card at ~113 px (was ~1000 px); scrollWidth 390 = viewport, no page errors. The 3 live BUY cards with worst > profit render red (+935 / -1 013, +830 / -1 118, +725 / -1 223).
  • Bought (4 500 + 227 fees) then Sold (6 000 − 300) through the UI: header realised 0 → 973 kr (= 6000−300−4500−227). /events shows outcome bought/sold uid=blocket:27147823 …; /metrics deals_flip_outcomes_total{kind="bought"} 1, {kind="sold"} 1, deals_flip_realized_profit_sek 973.
  • Full suite: 810 passed, 10 skipped (new: near-miss matrix, ledger/realised/subscription/validation, browser Bought→Sold and near-miss tab).
    Not verified: chrome-devtools-axi has no Chrome on this host, so screenshots are Playwright Chromium; the live site was not touched (no outcome writes against prod); fix(fm-brief): bash 3.2 here-doc parse error breaks default brief scaffolding #121 not yet on main so no rebase conflict seen; subscription figure shown only via /flip/stats test (no real SEK configured).

fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
kunchenguid#122)

* feat(bin): serve the Action Deck as a private /deck page on the bridge

Add `fm-deck.sh --json`, which emits the pane's payload as one structured
`fm-deck.v1` model, and split fm-deck-render.py's section builders into
shared row/group helpers so the terminal frame and the model apply the same
reading rules. The terminal rendering is unchanged.

Add `GET /deck` and `GET /api/deck` to fm-bridge-view.py behind the existing
session cookie, Host check, CSP and security headers. The deck read runs as
the same scrubbed bounded child as the bearings snapshot, is cached, and
returns 503 with the collector's reason on failure. Live asks are the
headline; held backlog decisions, finished workers, completions and loose
ends are folded away from the actionable lists. Only ordinary https URLs
become links; tray targets and local paths render as text. The page carries
no approve, run or merge control and says why: the gateway has no executor
and approval needs the captain secret on the desk.

Tests cover the JSON model, the route, the auth boundary, link vetting, the
read-only guarantee, the 503 path and the page rendering. Docs point at the
new page from bridge-view.md, ops-command-center.md and scripts.md.

* no-mistakes(review): deck header reports collector sample age; drop setCount

* no-mistakes(review): deck first-load 503 keeps the reason visible, no overlay

On a first-load failure the deck raised the full-page 'Cannot reach the
desk.' overlay and wrote the collector's reason underneath it, so the
captain never saw the reason. The header and every region already say
the desk is unreachable and #deck-error carries the reason; the overlay
is now reserved for a tab whose refreshes stop after a successful load.
The rendering test drives refresh() against a fake 503 and asserts the
overlay stays off while the reason is shown.

* no-mistakes(document): docs: bridge headers and architecture name the /deck page

* fix(bin): keep jq first in the bridge child PATH so a fixture tmux outranks /usr/bin

Adding python3 ahead of jq in CHILD_PATH_TOOLS let /usr/bin lead the child
PATH on Linux, where python3 lives there, so the real /usr/bin/tmux outranked
the test's fake tmux and the live observation read a paused worker as Stuck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants