Compare commits

..

34 Commits

Author SHA1 Message Date
Alan Wizemann ee86ef1a9a chore: Bump version to 2.8.0 2026-05-09 20:56:32 +02:00
Alan Wizemann 9eecf8b443 chore(i18n): re-extract localizable strings for v0.13 surfaces
Xcode's `xcstringstool` auto-extracts these on local Debug build whenever
SwiftUI Text literals are added in Swift code. New entries land for the
v0.13 surfaces introduced across v2.8.0:

- "%lld diagnostic signal%@" — Kanban diagnostics tooltip (WS-3)
- "%lld queued" — chat queue chip count (WS-2)
- "%lld skill%@" — Curator archived list count (WS-4)
- "×%lld" — chat status bar compression-count chip (WS-8)

All entries are English-only ("state": "new"); Crowdin / manual
translation lands in a follow-up. Pre-release housekeeping so the
release script's clean-tree check passes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 20:54:39 +02:00
Alan Wizemann f90ed384fd Merge pull request #81 from awizemann/coordination/v2.8.0-plans
docs(v2.8): coordinator review + 8 work-stream plans for Hermes v0.13.0 catch-up
2026-05-09 20:46:42 +02:00
Alan Wizemann 66d6a373c9 Merge pull request #91 from awizemann/fix/slash-menu-new-fallback
feat(chat): surface /new in slash menu pre-session as static fallback
2026-05-09 20:46:37 +02:00
Alan Wizemann ee8f946836 Merge pull request #90 from awizemann/fix/dashboard-debounce-v0.13
fix(dashboard): coalesce file-watcher fires + dedupe in-flight loads (v0.13)
2026-05-09 20:46:29 +02:00
Alan Wizemann e26acaff4e fix(chat): drop forward-looking version labels + add /exit to alwaysAvailable
Two follow-ups from code review on this branch:

1. Drop forward-looking Scarf version labels per the
   `feedback_no_version_bumps.md` rule (release notes own version
   labels, not in-code comments). "Added v2.8 alongside Hermes v0.13."
   becomes "Introduced alongside Hermes v0.13." on
   `HermesSlashCommand.Source.alwaysAvailable`. The `reset()`
   explanatory block in `RichChatViewModel` drops the two "v2.8.0"
   references — the rationale is unchanged, just stops marking the
   change with a Scarf-side version it might never ship under.

2. Add `/exit` to the active-session-only fallback set so the
   implementation matches the doc comment. The doc listed eight
   commands (`/clear`, `/compact`, `/cost`, `/model`, `/tools`,
   `/reload-skills`, `/help`, `/exit`) but only seven were appended.
   Adding `/exit` is the right call since it's a real Hermes ACP
   command; users typing `/exit` on a resumed session will now
   discover and dispatch it before the ACP-advertised version arrives.

Tests: M9SlashCommandTests 30/30 green, Mac scheme builds clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 20:43:34 +02:00
Alan Wizemann ce028b065f fix(dashboard): max-wait safeguard for scheduleCoalescedTick + drop forward-looking version label
Two follow-ups from code review on this branch:

1. Add `maxWait` (1.5 s) safeguard to `HermesFileWatcher.scheduleCoalescedTick`
   so the trailing-debounce can't be starved indefinitely under sustained
   activity. Each scheduled fire now picks the earlier of (a) the
   `coalesceWindow` quiet floor and (b) `maxWait` since the FIRST fire of
   the current burst. A 10 Hz `state.db-wal` write storm coincident with
   a `gateway_state.json` Start/Stop touch now publishes within
   `maxWait` instead of waiting for the WAL activity to subside. The
   single-fire / quiet-burst case is unchanged because both deadlines
   reduce to the same value.

2. Drop the forward-looking "v2.8 dogfood bug report" reference from a
   comment in `DashboardViewModel.load()` per the
   `feedback_no_version_bumps.md` rule (release notes own version
   labels, not in-code comments).

Tests: full ScarfCore suite green (450/450), Mac scheme builds clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 20:41:59 +02:00
Alan Wizemann 096dbe085e feat(chat): richer slash menu in resumed sessions; preserve agent commands across reset
Two fixes uncovered by v2.8.0 dogfooding when clicking a previous chat
in the sidebar (vs. starting a new one):

1. **Preserve `acpCommands` across `RichChatViewModel.reset()`**.
   Hermes ACP only emits `available_commands_update` after `session/new`,
   not after `session/load`. Wiping the cached set on every session
   switch meant resumed sessions landed at a 4-command fallback even
   though the agent identity (and therefore the command list) hadn't
   changed. The new comment in `reset()` documents the rationale; the
   host-switch case still tears down the whole `ContextBoundRoot`, so
   stale carry-over isn't reachable when the agent identity does change.

2. **Expand the static fallback when a session is active**. Adds the
   agent-level command set (`/clear`, `/compact`, `/cost`, `/model`,
   `/tools`, `/reload-skills`, `/help`) to `alwaysAvailableCommands`
   when `sessionId != nil`. `/new` continues to show in both states.
   Pre-session, only `/new` surfaces — the others all require a live
   session, and surfacing them would mislead. Deduped by name against
   the ACP-advertised set so the richer (server-authoritative)
   description / argument hint wins once Hermes does emit them.

The two fixes together cover all paths to the slash menu:
- Cold start, click resume → fix #2 paints the active-session set
- Hot path, switch sessions after a `session/new` → fix #1 keeps the
  ACP-advertised set in `acpCommands`
- Cold start, click "+ New" → ACP populates as before; unchanged

Discovered during v2.8.0 dogfooding against a live Hermes v0.13.0 host.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 20:29:56 +02:00
Alan Wizemann e7096bb44c fix(dashboard): coalesce file-watcher fires + dedupe in-flight loads (v0.13)
Hermes v0.13 writes to state.db-wal and rotating logs at ~10 Hz during
gateway activity (Checkpoints v2 single-store + session-durability writes
hit disk far more often than v0.12). Each FSEvents fire on a watched core
path was ticking HermesFileWatcher.lastChangeDate, which every observing
view (Dashboard, Projects, ProjectSessions, half a dozen widgets) re-fired
its `.onChange` / `.task(id:)` against. On Local hosts the dashboard
stacked 5+ concurrent `viewModel.load()` calls in 200 ms, contending on
the read-only state.db handle and surfacing as `BackendError error 3` (a
sqlite step error from a busy/closed handle) plus visible flickering as
isLoading thrashed.

Two-part fix:

1. **HermesFileWatcher** coalesces FSEvents fires into one
   `lastChangeDate` mutation per 500 ms quiet window. A 10 Hz burst of
   FSEvents collapses into 2 observable mutations per second instead of
   10. Both local FSEvents and remote-poll deltas funnel through the
   same `scheduleCoalescedTick` helper, so SSH contexts get the same
   protection. `stopWatching` cancels the pending timer alongside the
   sources so a tear-down doesn't fire one trailing mutation after.

2. **DashboardViewModel.load()** holds a single in-flight `Task` handle.
   When `.onChange` and `.task` race (or any future caller fires
   concurrently), the second caller awaits the first's completion
   instead of starting a parallel load. `isLoading` is no longer
   thrashed and the data-service refresh runs once per coalesced tick.

Pre-v0.13 hosts see no behavioural change — they already wrote to
state.db-wal at 1-2 Hz, well below the 500 ms coalesce window. v0.13
hosts now see a smooth dashboard that updates ~2 Hz during gateway
activity instead of flickering at 10 Hz.

Discovered during v2.8.0 dogfooding against a live v0.13.0 host.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 20:14:15 +02:00
Alan Wizemann a359177e76 Merge pull request #89 from awizemann/ws-9-ios-v0.13
feat(ios): v0.13 read-only catch-up (WS-9)
2026-05-09 19:44:57 +02:00
Alan Wizemann 394e223551 Merge integration/v2.8.0: land WS-6, WS-7, WS-8 2026-05-09 19:43:28 +02:00
Alan Wizemann c721e7a6ea Merge pull request #87 from awizemann/ws-5-gateway-v0.13
feat(gateway): Google Chat + allowlists + behavior toggles (WS-5)
2026-05-09 19:41:54 +02:00
Alan Wizemann 8c75efbdd8 Merge pull request #85 from awizemann/ws-4-curator-archive
feat(curator): archive + prune + list-archived (WS-4)
2026-05-09 19:41:38 +02:00
Alan Wizemann be0a6e27fc Merge pull request #88 from awizemann/ws-3-kanban-v0.13
feat(kanban): v0.13 diagnostics + recovery UX (WS-3)
2026-05-09 19:41:31 +02:00
Alan Wizemann 53d5fa7262 Merge pull request #82 from awizemann/ws-2-goals-and-queue
feat(chat): add /goal and /queue slash commands (WS-2)
2026-05-09 19:41:24 +02:00
Alan Wizemann a8cdb3e663 feat(ios): v0.13 read-only catch-up — goal pill, queue chip, Kanban diagnostics, Curator archived, Platforms (WS-9)
Mirrors the v0.13 surfaces from WS-2 (Persistent Goals + ACP /queue),
WS-3 (Kanban diagnostics + hallucination gate), WS-4 (Curator archive),
and WS-5 (Google Chat platform + cross-platform allowlists + behavior
toggles) onto ScarfGo. Per Phase H precedent, every iOS surface is
strictly read-only — write verbs (Verify / Reject, /goal --clear, queue
send, allowlist editing, archive Restore / Prune) live on Mac in v2.8.0
and are deferred to v2.8.x.

Five iOS additions, all capability-gated so pre-v0.13 hosts see the
v2.7.5 layout unchanged:

1. Chat — goal pill ("Goal: <text>") and queue chip ("N queued") render
   inside `projectContextBar` whenever a project, goal, or queue is
   present. The bar is no longer project-only; goal/queue chips render
   even outside a project chat. Goal text scales with Dynamic Type
   (semantic `.subheadline`); the full untruncated text rides VoiceOver
   via the chip's accessibility label.
2. Kanban — `ScarfGoKanbanDetailSheet` gains a `retries: N` chip in the
   header `FlowLayout`, a yellow "Worker-created — verify on Mac" badge
   for `pending` hallucination state, a red "Auto-blocked" banner with
   the server-supplied `auto_blocked_reason`, and tappable diagnostics
   chip-lists (task-level + per-run) that present a new
   `DiagnosticDetailSheet` with kind / severity / message / timestamp.
   No Verify or Reject buttons; the badge copy points users to the Mac
   app.
3. Curator — `CuratorView` appends a read-only "Archived" section that
   loads via `viewModel.loadArchive()` on appear and pull-to-refresh.
   Per-row name + category badge + reason + archived-at + size; footer
   signposts users to the Mac app for Restore / Prune.
4. Settings → Platforms — adds a Google Chat status row (configured /
   not configured), busy-ack and restart-notification rows summarized
   across `gatewayPlatforms` (yes / no / mixed (N platforms)), and
   collapsed DisclosureGroups for allowed channels / chats / rooms with
   monospaced "platform: id" entries when expanded. No editor.
5. Settings — green "v0.13 features active" `ScarfBadge` above the
   quick-edits section when `caps.isV013OrLater`. Tap presents a new
   `V013FeaturesSheet` listing the six v0.13 surfaces with one-sentence
   summaries; the section footer is explicit that editing lives on Mac.

Implements WS-9 of Scarf v2.8.0 (Hermes v0.13.0 catch-up).
Plan: scarf/docs/v2.8/WS-9-ios-v0.13-plan.md (on coordination/v2.8.0-plans).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 19:25:16 +02:00
Alan Wizemann 441d11404f Merge remote-tracking branch 'origin/ws-8-ux-v0.13' into integration/v2.8.0
# Conflicts:
#	scarf/scarf/Features/Chat/Views/ChatTranscriptPane.swift
#	scarf/scarf/Features/Chat/Views/SessionInfoBar.swift
2026-05-09 19:12:15 +02:00
Alan Wizemann 6e8480411a Merge remote-tracking branch 'origin/ws-7-settings-v0.13' into integration/v2.8.0
# Conflicts:
#	scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift
#	scarf/Packages/ScarfCore/Sources/ScarfCore/Parsing/HermesConfig+YAML.swift
2026-05-09 19:11:29 +02:00
Alan Wizemann 3a764e81e0 Merge remote-tracking branch 'origin/ws-6-providers-v0.13' into integration/v2.8.0
# Conflicts:
#	scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift
#	scarf/Packages/ScarfCore/Sources/ScarfCore/Parsing/HermesConfig+YAML.swift
2026-05-09 19:10:43 +02:00
Alan Wizemann 6e90741a17 Merge remote-tracking branch 'origin/ws-5-gateway-v0.13' into integration/v2.8.0 2026-05-09 19:09:38 +02:00
Alan Wizemann 93a3b40a67 Merge remote-tracking branch 'origin/ws-4-curator-archive' into integration/v2.8.0 2026-05-09 19:09:38 +02:00
Alan Wizemann 52f0ddb36c Merge remote-tracking branch 'origin/ws-3-kanban-v0.13' into integration/v2.8.0 2026-05-09 19:09:38 +02:00
Alan Wizemann cedee04f2a feat(kanban): v0.13 diagnostics + recovery UX (WS-3)
Layers Hermes v0.13's reliability + recovery affordances on top of the
v2.7.5 Kanban v3 board. New surface — gated end-to-end on
`HermesCapabilities.hasKanbanDiagnostics` (>= v0.13.0):

- **Hallucination gate.** Worker-created cards land in `pending` until
  the user verifies the underlying work exists. Inspector renders a
  yellow Verify / Reject banner above the body; cards dim to 0.6 with
  a question-mark glyph. Verify is optimistic — banner clears
  immediately, polling confirms. Reject routes through
  `comment` + `archive` so there's an audit trail.
- **Generic diagnostics engine.** `HermesKanbanDiagnostic` (new model +
  typed-mirror enum `KanbanDiagnosticKind`) renders cross-run signals
  on the inspector header and per-run signals under each Runs row.
  Card footer gains a stethoscope dot when any signal is attached.
- **`max_retries` create-time field + inspector chip.** Toggle-gated
  Stepper in the create sheet sends `--max-retries N`; chip on the
  inspector header reads it back read-only with a tooltip explaining
  there's no update verb.
- **Multi-line title input.** Create sheet's title becomes a
  `TextField(axis: .vertical, lineLimit: 1...4)`. Newlines are stripped
  client-side on pre-v0.13 hosts (which truncate at the first `\n`).
- **Auto-blocked reason banner.** When `task.auto_blocked_reason` is
  set, replaces the generic "Last run: blocked" with a red banner
  rendering the server reason verbatim. Card footer shows a 1-line
  truncated copy in red.
- **Tolerant decode contract.** Every new field is `Optional` with
  `decodeIfPresent`; diagnostics arrays use `try?` so a single
  malformed entry doesn't poison the row. v0.12 hosts decode unchanged.

Implements WS-3 of Scarf v2.8.0 (Hermes v0.13.0 catch-up).
Plan: scarf/docs/v2.8/WS-3-kanban-v0.13-plan.md (on
coordination/v2.8.0-plans).

TODOs marked inline pending integration against a live v0.13 binary:
WS-3-Q1 (verify verb name), WS-3-Q2 (diagnostics envelope vs task),
WS-3-Q4 (failure_count placement), WS-3-Q5 (darwin-zombie kind
string), WS-3-Q6 (max_retries default).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 19:06:38 +02:00
Alan Wizemann b4482e5ee7 feat(gateway): Google Chat platform + cross-platform allowlists + behavior toggles (WS-5)
Catches the Mac Messaging Gateway and Platforms surfaces up to Hermes
v0.13.0. Adds Google Chat as the 20th platform under Settings → Platforms,
gated on `hasGoogleChatPlatform`. Adds a per-platform "Gateway behavior"
subsection to the six platforms Hermes added v0.13 allowlist support to
(Slack, Mattermost, Google Chat, Telegram, WhatsApp, Matrix) — each
exposes the `allowed_channels` / `allowed_chats` / `allowed_rooms` editor
plus three new toggles (`busy_ack_enabled`, `gateway_restart_notification`,
`slash_command_notice_ttl_seconds`). The Messaging Gateway page header
gains a one-line cross-profile digest sourced from `hermes gateway list
--json`. SkillsView surfaces an informational row on skills whose body
contains the v0.13 `[[as_document]]` directive.

New ScarfCore types: `GatewayAllowlistKind` (channels/chats/rooms +
platform mapping), `GatewayPlatformSettings` (per-platform v0.13 bundle),
`GatewayConfigWriter` (pure YAML list-block editor — `hermes config set`
can't write lists; tested with 15 cases incl. round-trip + idempotence +
quoting + scalar-sibling preservation), `HermesGatewayListService`
(`hermes gateway list --json` parser tolerant of unknown keys + alt
field names; 13 tests), `HermesConfig.gatewayPlatforms` field. Mac VM
renamed to `MessagingGatewayViewModel` (single-feature local rename;
CLAUDE.md "the SidebarSection.gateway enum case stays" invariant
upheld). All 22 new tests pass; full ScarfCore suite green except 3
pre-existing `RemoteSQLiteBackendTests` failures unrelated to WS-5.

Capability-gated end-to-end. Pre-v0.13 hosts see no Google Chat row,
no cross-profile digest, no v0.13 toggles, and no `[[as_document]]`
info row — the v2.7.5 surface is byte-for-byte unchanged. Q1-Q3 wire-
shape unknowns (Google Chat identifier, YAML key path,
`gateway list --json` shape) are marked with `// TODO(WS-5-Q<N>)` and
defended by tolerant parsers + dual-spelling lookups.

Implements WS-5 of Scarf v2.8.0 (Hermes v0.13.0 catch-up).
Plan: scarf/docs/v2.8/WS-5-gateway-v0.13-plan.md (on coordination/v2.8.0-plans).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 19:05:55 +02:00
Alan Wizemann 4757b5ae49 feat(curator): archive + prune + list-archived (WS-4)
Catches the Curator surface up to Hermes v0.13's new write-side verbs
(`archive <skill>`, `prune`, `list-archived`, synchronous `run`). Adds
a new `CuratorService` actor in ScarfCore mirroring `KanbanService`'s
pattern (Sendable, pure I/O, `Task.detached(priority: .utility)` per
verb), tolerantly-decoded `HermesCuratorArchivedSkill` /
`CuratorPruneSummary` models, and `CuratorError` for inline-banner
surfacing.

Mac UX gains an "Archived" section between the leaderboards and the
last-report block (per-row Restore button), an "archivebox" button on
every active-skill leaderboard row to manually archive, a destructive
"Prune Archived…" confirm sheet enumerating each skill (template-
uninstall pattern — Cancel owns `.defaultAction`, Prune is on the red
`ScarfDestructiveButton`), and a synchronous-with-progress "Run Now"
on v0.13+ hosts (600s timeout, `ProgressView` while in-flight).
Failure path routes through a yellow inline error banner instead of a
modal alert. The legacy `CuratorRestoreSheet` stays accessible from
the overflow menu but only on pre-v0.13 hosts; on v0.13+ the per-row
Restore in the new Archived section replaces it.

All new surfaces gate on `HermesCapabilities.hasCuratorArchive` —
pre-v0.13 hosts see the v2.7.x layout unchanged. iOS picks up the new
`runNow(synchronous:)` signature with the v0.13 capability flag; the
read-only Archived section + WS-9 marker is left for the next stream.
14 new parser tests in `HermesCuratorParserTests` cover the JSON
happy path, the `{"archived": [...]}` envelope, the text fallback
(`--json` not supported), `"no archived skills"` sentinel folding,
prune-dry-run with both wrapper + bare-array shapes, and zero-skill
prune. All 369 ScarfCore tests pass; `xcodebuild` for the `scarf`
scheme succeeds.

Wire-shape unknowns (CLI flag presence on real v0.13) carry
`// TODO(WS-4-Q<N>)` markers in `CuratorService` and fall back
defensively when a flag isn't recognized. Implements WS-4 of Scarf
v2.8.0 (Hermes v0.13.0 catch-up). Plan:
scarf/docs/v2.8/WS-4-curator-archive-plan.md (on
coordination/v2.8.0-plans).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 19:03:13 +02:00
Alan Wizemann 0070441243 feat(profiles): add --no-skills toggle to create-profile sheet
Adds an "Empty profile (no skills)" toggle to the Mac create-profile
sheet, gated on `hasProfileNoSkills` (v0.13+). When ON, the create
flow appends `--no-skills` to `hermes profile create`. The toggle is
disabled (greyed out) when "Full copy of active profile" is on, per
WS-7 plan Decision H — a full clone copies skills wholesale, so
`--no-skills` would be a contradiction at the UX layer. The wire
itself stays permissive: a user can stack `--clone --no-skills` to
clone config but skip skills, which is a plausible workflow.

Defensive write-strip: even though the toggle is hidden on pre-v0.13
hosts, the call site reads `createNoSkills` through the capability
gate so a stale state value can't sneak `--no-skills` past argparse
on a CLI that doesn't know it.

iOS Profiles is read-only (per CLAUDE.md "v0.12 iOS catch-up
Phase H") so no toggle there.

TODO marker (WS-7-Q8) flags the assumed `--clone-all` interaction —
verify Hermes's behaviour with both flags during integration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 19:03:06 +02:00
Alan Wizemann 0f78856e6e feat(settings): v0.13 polish — redaction hint, display.language picker, xAI cloning badge (WS-8)
Three Settings-tab surfaces tracking v0.13 release notes:

- **Redaction default-flip awareness** (Advanced → Caching & Redaction):
  inline hint below the existing toggle whose copy depends on
  `HermesCapabilities.isV013OrLater`. v0.13 flipped the server-side
  default from OFF (v0.12) to ON, but Scarf's parser still treats
  "absent key" as `false`. Hint disambiguates so users on v0.13 hosts
  understand redaction is on server-side even when the toggle reads OFF.

- **`display.language` picker** (General → Locale): 8-option enum (`""`
  default + en/zh/ja/de/es/fr/uk/tr) capability-gated on
  `hasDisplayLanguage`. Persists via `hermes config set
  display.language <code>`. Empty string preserves "no key" semantics
  (Hermes-default English); explicit `en` pins it. Required a small
  `optionLabel:` overload on `PickerRow` so non-English labels
  (中文 / 日本語 / etc.) render alongside their codes.

- **xAI Custom Voices badge** (Voice → Text-to-Speech): adds `xai`
  to the TTS provider picker (un-gated — xAI TTS shipped earlier),
  exposes Voice ID + Model fields, and renders a "Cloning supported"
  ScarfBadge gated on `hasXAIVoiceCloning`. Hint copy points at
  `hermes voice` for cloned-voice management since Scarf has no
  in-app surface for that yet (out-of-scope for v2.8).

Capability gates: `isV013OrLater` (hint discriminator),
`hasDisplayLanguage` (picker), `hasXAIVoiceCloning` (badge). Pre-v0.13
hosts see the v2.7.5 layout unchanged.

`TODO(WS-8-Q2)` flags the assumed xAI YAML keys (`tts.xai.voice_id` /
`tts.xai.model` mirroring elevenlabs) for grep-verify against
`~/.hermes/hermes-agent/hermes_cli/voice/tts.py`.

iOS deferred to v2.9 (Q4): `Scarf iOS` Settings is read-mostly and
doesn't have a write surface for either the language picker or the
xAI fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:59:38 +02:00
Alan Wizemann 5877bf6519 feat(updater): forward-compat HermesUpdaterCommandBuilder for hermes update --yes (WS-8)
Pure-function helper that builds argv arrays for `hermes update`,
gated on `HermesCapabilities`. Pre-v0.12 → bare `update`; v0.12+
honors `--check`; v0.13+ honors `--yes` for unattended runs.

No in-app "Update Hermes" affordance ships in v2.7.5 — Sparkle handles
Scarf-self-update and `hermes update` is invoked by users in their
terminal. This is forward-compat plumbing so the eventual UI surface
shares flag selection across Mac / iOS / remote without re-deriving
from scratch.

Test matrix in `M0eUpdaterTests` covers all six combinations
(pre-v0.12, v0.12 ± unattended ± check, v0.13 ± unattended ± check)
plus an empty-capabilities fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:59:12 +02:00
Alan Wizemann f19f19cd56 feat(chat): surface v0.13 compression count + bracket-aware slash hint (WS-8)
Two small chat-surface additions tracking Hermes v0.13:

- Plumb a `compressionCount` field through `ACPPromptResult` and
  `RichChatViewModel.acpCompressionCount` so `SessionInfoBar` can render
  a `🗜 ×N` chip next to the token counter when the agent has performed
  context compactions. Capability-gated on
  `HermesCapabilities.hasContextCompressionCount` and `count > 0` so
  pre-v0.13 hosts (which always emit 0) and fresh sessions never see
  the chip. Wire decode tolerates camelCase + snake_case;
  `TODO(WS-8-Q1)` flags the assumption that the field rides on
  `usage` — if v0.13 emits via a separate `session/update` notification
  the bigger fix is described in the WS-8 plan.

- Slash-menu argument hint is now bracket-aware: hints starting with
  `<` or `[` pass through verbatim, others wrap as `<hint>`. v0.13's
  `/new [name]` ships through unchanged without rendering as
  `<[name]>`. No flag check at the renderer — agent payload is the
  source of truth.

Coordination with WS-2: both WSes touch `SessionInfoBar`. WS-2 owns
the queue chip on the left half; this WS owns the compression chip on
the right half. The added `capabilities` parameter is shared — kept
additive so WS-2's later merge produces no file-level conflict.

Tests: extends `M0dViewModelsTests` (compression count tracking +
reset semantics) and `ScarfCoreSmokeTests` (decode default + explicit
v0.13 init path).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:58:58 +02:00
Alan Wizemann 6c96fcfa43 feat(settings): add Web Tools tab with v0.13 search/extract split
Adds a new "Web Tools" Settings tab (between Browser and Voice) with
two distinct shapes that share the same chrome:

- Pre-v0.13: a single "Backend" picker writing the legacy
  `web_tools.backend` key (so v0.12 users still configure web tools).
- v0.13+: two pickers — Search backend writes
  `web_tools.search.backend` (SearXNG appears here only — Hermes
  registers it as a search-only dispatch), Extract backend writes
  `web_tools.extract.backend`.

Capability gate: `hasWebToolsBackendSplit` chooses which shape
renders. The tab itself is always visible — pre-v0.13 users would
otherwise lose access to the legacy combined-backend picker.

Model layer:
- `HermesConfig.webToolsBackend` / `webToolsSearchBackend` /
  `webToolsExtractBackend` — three fields, each round-tripping its
  own YAML key. Defaults: `duckduckgo` / `duckduckgo` / `reader`.
- YAML parser reads all three keys via the existing `str(...)`
  helper. Pre-v0.13 hosts populate only `webToolsBackend`; the
  split keys default to the same backend so the picker shows the
  same value the user already had.

TODO markers (WS-7-Q6/Q7) flag the inline backend lists + legacy
fallback semantics — verify against `~/.hermes/hermes-agent/
hermes_cli/web_tools.py` during integration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:56:08 +02:00
Alan Wizemann edac142d08 feat(chat): add /goal and /queue slash commands (WS-2)
Adds Hermes v0.13's Persistent Goals and ACP /queue surfaces to the
rich-chat composer. /goal <text> locks the agent on a target across
turns (rendered as an info-tinted "Goal locked" pill in the chat
header, with a context-menu Clear action that dispatches /goal --clear);
/queue <text> queues a prompt to run after the current turn (rendered
as a warning-tinted chip with a popover listing queued prompts +
relative timestamps). Both ride .acpNonInterruptive so the chat keeps
"Agent working…" off, and both surface a 4-second transient toast
mirroring /steer's existing UX.

Capability-gated end-to-end: the rich-chat slash menu reads through
RichChatViewModel.capabilitiesGate (a new @ObservationIgnored field
fed by ChatViewModel.attachCapabilitiesStore on Mac and a parallel
.task(id:) on iOS), so pre-v0.13 hosts never see /goal or /queue.
/steer is greyed-out on idle sessions when hasACPSteerOnIdle is off
(pre-v0.13 hosts only). The "Clear all" queue-popover button is
intentionally absent in v2.8.0 — Hermes' wire-shape for /queue --clear
isn't verified yet, so a button that lies about server-side state is
worse than no button (per WS-2 plan Q2 decision).

Optimistic-only: there is no authoritative read-back path for the
active goal in v2.8.0. The pill paints synchronously off the
optimistic write the moment the user sends /goal …; cross-session
resume won't re-paint it until the user types /goal again. A
TODO(WS-2-Q1) marker in RichChatViewModel.recordActiveGoal points at
the read-back hook for v2.8.1; TODO(WS-2-Q5) flags the verbatim
/queue argument shape for coordinator wire-verification; TODO(WS-2-Q7)
flags the /goal non-interruptive classification. TODO(v2.8.1) in
handlePromptComplete is the deferred "auto-resumed from checkpoint"
indicator (WS-2 plan Q3 decision).

iOS surfaces no UI yet (deferred to WS-9), but the iOS controller's
_sendImpl mirrors the dispatch so the shared RichChatViewModel state
stays aligned across platforms — otherwise an iOS user who ran /goal
then opened the same session on Mac would see an empty pill.

Tests: extends M9SlashCommandTests with 13 new cases covering the
non-interruptive list contents, capability-gated availableCommands
filtering on v0.12 vs v0.13, parseGoalArgument variants, optimistic
mutators (recordActiveGoal / recordQueuedPrompt / popQueuedPrompt),
isNonInterruptiveSlash recognition, and reset() drainage.

Implements WS-2 of Scarf v2.8.0 (Hermes v0.13.0 catch-up).
Plan: scarf/docs/v2.8/WS-2-goals-and-queue-plan.md (on coordination/v2.8.0-plans).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:55:54 +02:00
Alan Wizemann fd33b714e3 feat(cron): add --no-agent watchdog toggle gated on hasCronNoAgent
Adds a "Run script only (no agent call)" toggle to the cron job
editor. When ON, the prompt + skills sections dim + disable
visually but stay rendered (no layout shift mid-edit), the
script field stays fully active, and the form passes
`noAgent: true` to `createJob`/`updateJob`. The toggle is hidden
on pre-v0.13 hosts via `supportsNoAgent: hasCronNoAgent` and
defensively stripped at the call site (`hasCronNoAgent ?
form.noAgent : false` on create, `: nil` on edit) — same shape
as the v0.12 `workdir` strip.

Read-side: `HermesCronJob.noAgent: Bool?` is decoded via
`decodeIfPresent` so pre-v0.13 jobs.json files round-trip
unchanged. The display rule `job.noAgent == true` treats
`nil` and `false` identically — a script-only job must opt in.

Write-side:
- `createJob` appends `--no-agent` and passes an empty positional
  prompt (per WS-7-Q5) to keep argparse happy when the prompt is
  the trailing positional.
- `updateJob` sends `--no-agent` / `--agent` to flip the flag in
  edit mode (per WS-7-Q4 — verify the toggle-off spelling on
  integration; if Hermes is one-way, disable the toggle in edit
  mode with a tooltip).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:43:03 +02:00
Alan Wizemann c81a8a56e8 feat(mcp): add SSE transport support gated on hasMCPSSETransport
Extends MCPTransport with a third .sse case (alongside stdio + http),
plumbed through the YAML parser, add-server form, list view, detail
view, and editor. The add-server form filters .sse out of the segmented
picker on pre-v0.13 hosts (capability-gated on hasMCPSSETransport) so
Hermes never sees a transport flag it can't parse. The editor renders
a third numeric "SSE read timeout" field only for .sse servers.

YAML layer:
- HermesMCPServer.sseReadTimeout: Int? — defaulted in init, decoded
  from `sse_read_timeout` scalar.
- parseMCPServersBlock: 3-way transport discriminator — `transport: sse`
  scalar wins, then url-bearing entries default to .http (v0.12 shape),
  command-bearing to .stdio. Pre-v0.13 entries are byte-for-byte
  unaffected.
- HermesFileService.addMCPServerSSE writes via `hermes mcp add --url
  <u> --transport sse [--sse-read-timeout <t>]`.
- HermesFileService.setMCPServerSSETimeout patches the scalar via the
  same surgical patcher used by setMCPServerTimeouts.

TODO markers (WS-7-Q1/Q2/Q3) flag the wire-format unknowns the plan
called out — verify against a v0.13 Hermes install during integration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:34:27 +02:00
Alan Wizemann cf8a737ace docs(v2.8): add 8 work-stream plans + coordinator review for Hermes v0.13.0 catch-up
Each plan is the product of one Opus 4.7 1M-context planning agent dispatched
in parallel to investigate a single v0.13 surface. Plans are read-only — they
identify file-by-file edits, type additions, capability gates, tests, and
open questions, but no code is written yet. Implementation agents will be
dispatched per stream once the cross-stream open-questions matrix is resolved.

- WS-2: Persistent Goals + ACP /queue slash commands
- WS-3: Kanban v0.13 diagnostics + recovery UX
- WS-4: Curator archive + prune + list-archived
- WS-5: Messaging Gateway v0.13 expansion (Google Chat, allowlists, behavior toggles)
- WS-6: Provider catalog refresh + image_gen.model + OpenRouter response caching
- WS-7: Settings tab additions (MCP SSE, Cron --no-agent, Web Tools split, Profiles --no-skills)
- WS-8: UX polish (compression count, /new <name>, redaction default, display.language)
- WS-9: ScarfGo iOS catch-up (read-only mirrors of WS-2/3/4/5)

COORDINATOR-REVIEW.md compiles the cross-stream collision matrix, the open-
questions matrix (54 questions clustered into wire-shape unknowns,
architectural decisions, and out-of-scope deferrals), and the recommended
sequencing for implementation + review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 18:03:41 +02:00
103 changed files with 13159 additions and 307 deletions
+100
View File
@@ -0,0 +1,100 @@
## What's in 2.8.0
A coordinated catch-up release adopting Hermes v0.13.0 (v2026.5.7) — "The Tenacity Release" — across Scarf's full surface area. v2.8.0 ships **Persistent Goals**, **ACP `/queue`**, **Kanban diagnostics + recovery UX**, **Curator archive/prune**, **Google Chat (20th platform) + cross-platform allowlists**, a refreshed **provider catalog** with five new models, and a slate of settings + UX polish — all behind capability flags so pre-v0.13 hosts continue to render the v2.7.5 surface unchanged.
No data migrations, no schema changes. `~/.hermes/state.db` columns are unchanged from v0.11/v0.12. Existing `~/.hermes/scarf/` sidecars are untouched. Sparkle picks the update up automatically.
### New features
#### Persistent Goals + ACP `/queue` (chat)
- **`/goal <text>` slash command** — locks the agent on a target that persists across turns. Surfaced via the chat slash menu (gated on `HermesCapabilities.hasGoals`) and rendered as an `info`-tinted "Goal locked: …" pill in the chat header. The pill exposes a "Clear goal" context-menu item that dispatches `/goal --clear`. Optimistic local mirror — Hermes is the authoritative owner; Scarf paints the pill the moment the user sends `/goal …` so the affordance feels instant.
- **`/queue <text>` slash command** — queues a prompt to run after the current turn completes. Joins `/steer` and `/goal` in `RichChatViewModel.nonInterruptiveCommands` (the chat keeps "Agent working…" off when sent). A header chip shows the queued count; tap opens a popover listing prompts + relative timestamps. Per-entry deletion isn't exposed (Hermes has no remove-by-id verb), and the popover header makes that explicit so users understand the local mirror's role.
- **`/steer` on idle** — pre-v0.13 was a no-op when no turn was in flight; v0.13 runs it as a regular prompt. The composer's slash button now greys `/steer` only on pre-v0.13 hosts (gated on `hasACPSteerOnIdle`).
- **Static slash-menu fallbacks** — pre-session, the menu surfaces `/new` (with optional `[<name>]` argument hint on v0.13). Active-session-only fallbacks (`/clear`, `/compact`, `/cost`, `/model`, `/tools`, `/reload-skills`, `/help`, `/exit`) round out resumed sessions where Hermes ACP doesn't re-emit `available_commands_update` after `session/load`. Deduped against the ACP-advertised set so the canonical entry always wins once a session opens.
#### Kanban v0.13 diagnostics + recovery UX
- **Hallucination-gate verify / reject** — worker-created cards land with `hallucination_gate_status: pending`. The inspector renders a yellow banner ("Created by a worker — verify before running") with a Verify and Reject button. Cards in pending state dim 0.6 with a yellow ⚠ glyph in the title row.
- **Diagnostics rendering** — new typed-mirror enum `KanbanDiagnosticKind` with severity (info / warning / critical). Per-task and per-run diagnostics surface in the inspector Runs tab as chip-lists; auto-block reasons render verbatim in the existing red banner. Darwin zombie detections show as a distinct `darwin_zombie_detected` kind.
- **Per-task `max_retries`** — added to the create sheet (default 3) and shown as a header chip in the inspector. Write-once at create time, matching Hermes's pattern.
- **Multiline title/body** — the create sheet's Title field accepts multiline input, capped to four visible rows.
- **Tolerant decoding** — every new field uses `decodeIfPresent`. Pre-v0.13 JSON parses cleanly with the new fields defaulting to nil, and the v2.7.5 board surface is unchanged on older hosts.
#### Curator archive + prune
- **Archived skills section** in `CuratorView` showing `hermes curator list-archived` output. Each row exposes Restore (returns to the active leaderboard) and Prune (destructive — opens a custom confirm sheet matching the template-uninstall pattern, with `ScarfDestructiveButton` "Prune permanently" and Cancel as the default keyboard action).
- **Bulk prune** — a header action (gated on archived list non-empty) that enumerates every archived skill in the confirm sheet before a single-tap destructive action. Per-skill prune buttons are present per row when Hermes supports `prune <name>`; otherwise only the bulk action is exposed.
- **Synchronous "Run Now"** — v0.13 `hermes curator run` blocks until done. The Run Now button shows a progress affordance for the duration; pre-v0.13 falls back to fire-and-forget.
- **New `CuratorService` actor** in ScarfCore ([scarf/Packages/ScarfCore/Sources/ScarfCore/Services/CuratorService.swift](scarf/Packages/ScarfCore/Sources/ScarfCore/Services/CuratorService.swift)) — pure-I/O Sendable actor mirroring `KanbanService`'s shape, with defensive `--json` retry-without-flag fallback for verbs that may not support it on all v0.13 patch releases.
- The legacy `CuratorRestoreSheet` flow (SAFE-list-restore for v0.12) is preserved; it predates the v0.13 archive surface and serves a distinct case.
#### Messaging Gateway expansion
- **Google Chat** — 20th platform. New entry in the Mac Platforms tab, gated on `HermesCapabilities.hasGoogleChatPlatform`.
- **Cross-platform allowlists** — per-platform editor for `allowed_channels` (Slack / Mattermost / Google Chat), `allowed_chats` (Telegram / WhatsApp), and `allowed_rooms` (Matrix / DingTalk). New `AllowlistEditor` component plus the `GatewayAllowlistKind` / `GatewayPlatformSettings` ScarfCore types. Persisted to `~/.hermes/config.yaml` via a new `GatewayConfigWriter` since `hermes config set` doesn't write list blocks.
- **Per-platform behavior toggles** — `busy_ack_enabled` (suppress per-message "agent is working…" acks), `gateway_restart_notification` (post a "Gateway restarted" notice on boot), and a slash-command auto-delete TTL (seconds, 0 to disable). Each appears in the new `GatewayBehaviorSection` component.
- **`hermes gateway list` cross-profile digest** — inline status row in `MessagingGatewayView` showing which profile is running which platform across all profiles. New `HermesGatewayListService` actor parses `hermes gateway list --json`. Hidden when the verb fails (pre-v0.13 hosts) or no profiles are registered.
- **`MessagingGatewayViewModel`** — internal rename from `GatewayViewModel` to disambiguate from the v0.10 Tool Gateway feature. The user-facing label was already "Messaging Gateway" since v0.10.
- **`[[as_document]]` hint** — informational tooltip in skill detail surfaces explaining the new media-routing directive for skills that reference it.
#### Provider catalog refresh
- **Five new models** — `deepseek/deepseek-v4-pro`, `x-ai/grok-4.3`, `openrouter/owl-alpha` (free tier), `tencent/hy3-preview`, and `arcee/trinity-large-thinking` (with temperature + compression overrides). Surfaced through `models_dev_cache.json`; no manual entries required.
- **Grok rename** — `x-ai/grok-4.20-beta``x-ai/grok-4.20`. Implemented via read-time alias resolution in `ModelCatalogService.modelAliases` so existing user configs with the `-beta` suffix keep validating without YAML rewrites. Three composite-keyed aliases cover the openrouter / xai / vercel routes.
- **Vercel AI Gateway demoted** — sort comparator change in `loadProviders()` puts Vercel last, after the alphabetical group.
- **`image_gen.model` honored** — pre-v0.13 the key was advertised but ignored; v0.13 actually drives the image-generation path. Surfaced in `Settings → Auxiliary` with a curated picker (`OpenAI gpt-image-1`, `Imagen 3/4`, `Stable Image Ultra`, `FLUX 1.1 Pro`, `DALL·E 3`); free-form entry is also accepted. Gated on `hasImageGenModel`.
- **OpenRouter response caching** — toggle in `Settings → Auxiliary` writing `openrouter.response_cache.enabled` to `config.yaml`. Off by default in Scarf's parser. Gated on `hasOpenRouterResponseCache`.
#### Settings tab additions
- **MCP SSE transport** — MCP add-server flow gains a Transport picker (`stdio` / `http` / `sse`) with `sse_read_timeout` field for SSE servers. The YAML round-trip preserves OAuth + headers identically to the existing `.http` shape. Gated on `hasMCPSSETransport`.
- **Cron `--no-agent` watchdog mode** — toggle in the Cron edit sheet that maps to `hermes cron create/update --no-agent`. When ON, the prompt + context fields hide (the AI call is skipped). Defensive write-path strips the flag on pre-v0.13 hosts mirroring the `--workdir` pattern. New `HermesCronJob.noAgent: Bool` field with `decodeIfPresent` so pre-v0.13 reads keep parsing. Gated on `hasCronNoAgent`.
- **Web Tools per-capability backends** — new `Settings → Web Tools` tab with separate pickers for `web_search` and `web_extract`. SearXNG appears in the search picker only. The legacy single `web_tools.backend` is still readable for round-trip safety on mixed-version installs. Gated on `hasWebToolsBackendSplit`.
- **Profiles `--no-skills`** — "Empty profile (no skills)" toggle in the create-profile flow that appends `--no-skills` to `hermes profile create`. Disabled when "Clone all" is on (mutually exclusive). Gated on `hasProfileNoSkills`.
#### UX polish
- **Context compression count** in the chat status bar. v0.13 emits the count alongside the token tally on the `session/prompt` response; Scarf renders a `🗜 ×N` chip next to the token count when `count > 0`. Gated on `hasContextCompressionCount`.
- **`/new <name>` argument hint** — bracket-aware so v0.13 hosts show `[<name>]` and pre-v0.13 hosts show no hint.
- **`HermesUpdaterCommandBuilder`** — forward-compat plumbing for `hermes update --yes`. No in-app surface in v2.8.0 (Scarf doesn't currently expose a "Run hermes update" command); the builder is wired so a future Settings affordance can opt in cleanly.
- **Redaction default-flip awareness** — the existing `Settings → Advanced → Redaction` toggle hint copy now branches on `HermesCapabilities.isV013OrLater`. v0.13+ hosts read "Recommended: ON. Hermes v0.13 defaults to redacting secrets unless you opt out"; pre-v0.13 keeps the v2.7 hint.
- **`display.language` picker** — new `Settings → General → Locale` row. 8 options: default, zh, ja, de, es, fr, uk, tr. Hermes does the actual translation; Scarf just persists `display.language` to `config.yaml`. Gated on `hasDisplayLanguage`.
- **xAI Custom Voices badge** — `Settings → Voice` shows a "Cloning supported" `ScarfBadge` next to the xAI TTS provider entry. Informational only; voice management itself happens via `hermes voice` CLI. Gated on `hasXAIVoiceCloning`.
#### ScarfGo iOS catch-up (read-only)
Following the Phase H precedent, iOS mirrors selected v2.8 surfaces as read-only — write parity is deferred to v2.8.x.
- **Goal pill + queue chip** in the iOS chat header (`projectContextBar`). Tap is a no-op; the Mac app owns mutations.
- **Kanban v0.13 diagnostics** in `ScarfGoKanbanDetailSheet``retries: N` chip, "Worker-created — verify on Mac" hallucination badge, red `auto_blocked_reason` banner, tappable diagnostics chip-lists with severity-tinted badges and a new `DiagnosticDetailSheet` (replacing Mac's `.help()` tooltip on touch).
- **Curator Archived list** in `Scarf iOS/Curator/CuratorView.swift` — read-only, with footer pointing users to the Mac app for Restore / Prune actions.
- **Settings → Platforms extension** — Google Chat status row, busy-ack and restart-notification summary rows across `gatewayPlatforms` (handles disagreement with "mixed (N platforms)"), allowlist DisclosureGroups with monospaced "platform: id" entries when expanded.
- **"v0.13 features active" badge** in iOS Settings (gated on `caps.isV013OrLater`). Tap presents `V013FeaturesSheet` listing the new affordances.
### Capability gating
v2.8.0 adds 22 new flags on `HermesCapabilities` (each gating one v0.13 surface), plus an `isV013OrLater` convenience predicate. Every new affordance is gated; pre-v0.13 hosts see the v2.7.5 surface byte-identical to before. The HermesVersionBanner threshold remains pre-v0.12 — v0.12 → v0.13 nudging happens via the iOS Settings badge (positive surface) rather than a global yellow banner (which was reserved for "missing every new feature" cases).
### Bug fixes uncovered during v0.13.0 dogfooding
- **Dashboard flicker on v0.13 hosts** — Hermes v0.13 writes to `state.db-wal` and rotating logs at ~10 Hz during gateway activity. Each FSEvents fire ticked `lastChangeDate`, every observing view re-fired its load handler against it, and on Local hosts the dashboard stacked 5+ concurrent `dashboardSnapshot` calls in 200 ms — sqlite contention on the read-only handle surfaced as `BackendError error 3`, plus visible flicker. Two-part fix: `HermesFileWatcher.scheduleCoalescedTick` coalesces FSEvents into one observable mutation per 500 ms quiet window with a 1.5 s max-wait floor (so a coincident `gateway_state.json` Start/Stop touch can't be starved indefinitely under sustained WAL writes); `DashboardViewModel.load()` holds a single in-flight `Task<Void, Never>` handle so concurrent triggers await the in-flight load instead of stacking.
- **Sparse slash menu on resumed sessions** — Hermes ACP only emits `available_commands_update` after `session/new`, not after `session/load`. Combined with `RichChatViewModel.reset()` clearing `acpCommands` on every session switch, resumed sessions landed at a 4-command fallback even though the agent identity hadn't changed. Fix: stop wiping `acpCommands` in `reset()` (they're agent-level, not session-level), and add an active-session-only static fallback set covering the standard agent commands so cold-start LOAD users see a rich menu immediately.
### Migrating from 2.7.5
Sparkle delivers the update automatically. No config migration, no schema changes — same `~/.hermes/state.db` columns as v0.11/v0.12, same Scarf-owned sidecars at `~/.hermes/scarf/`. Existing v2.7.5 Kanban tenants stay valid; existing project manifests are unchanged. Settings tabs grow new rows; existing rows render identically.
If you're connecting to a Hermes v0.13.0 host for the first time after this update, the new surfaces light up automatically — no flag flip in the app. Pre-v0.13 hosts continue to render the v2.7.5 surface; nothing breaks if you upgrade Scarf before upgrading Hermes.
### Known limitations
- **iOS write surfaces** (Verify hallucination gate, Reject, Curator archive/prune actions, allowlist editor, `/goal` send, `/queue` send) are explicitly out of scope for v2.8.0 and slated for v2.8.x. iOS surfaces are read-only mirrors per the Phase H precedent.
- **Auto-resumed-from-checkpoint indicator** — Hermes v0.13's "auto-resume after gateway restart" feature is server-side; whether the ACP adapter advertises a Scarf-visible signal is unclear pending live host verification. Deferred to v2.8.1.
- **xAI voice cloning management UX** — only the "Cloning supported" badge ships in v2.8.0. A full voice-management surface is a follow-up.
- **Bulk re-tag for legacy NULL-tenant Kanban tasks** — carryover from v2.7.5; Hermes still has no `tenant` mutation verb post-create.
- **Cluster A wire-shape TODOs** — 25 `// TODO(WS-N-Q<n>)` markers across the codebase flag fields and CLI flags whose exact shape couldn't be verified from release notes alone. Each has a tolerant-decode default that fails closed (hides the affordance rather than throwing); a pre-merge sweep on a v0.13 host can confirm or fix each in seconds.
### Acknowledgements
v2.8.0 was driven by a 9-stream coordinated multi-agent build: WS-1 capability flag foundation through WS-9 iOS catch-up, with planning artifacts archived under [scarf/docs/v2.8/](scarf/docs/v2.8/) for future reference. Bug fixes for the dashboard flicker and sparse-slash-menu issues were caught during a fresh end-to-end dogfood pass against a live Hermes v0.13.0 install — the kind of surface-level UX bugs that only show up under real-world `state.db-wal` write rates and real-world resume flows. As always, real bugs come from doing instead of speculating.
@@ -311,6 +311,14 @@ public actor ACPClient {
let result = try await sendRequest(method: "session/prompt", params: params) let result = try await sendRequest(method: "session/prompt", params: params)
let dict = result?.dictValue ?? [:] let dict = result?.dictValue ?? [:]
let usage = dict["usage"] as? [String: Any] ?? [:] let usage = dict["usage"] as? [String: Any] ?? [:]
// TODO(WS-8-Q1): Confirm wire field name once v0.13 Hermes is
// available. We tolerate camelCase + snake_case to match the rest
// of the ACP payload's mixed conventions; if Hermes routes the
// count through a `session/update` notification instead, this
// decode is a no-op and the ACPEvent path takes over.
let compression = (usage["compressionCount"] as? Int)
?? (usage["compression_count"] as? Int)
?? 0
statusMessage = "Ready" statusMessage = "Ready"
return ACPPromptResult( return ACPPromptResult(
@@ -318,7 +326,8 @@ public actor ACPClient {
inputTokens: usage["inputTokens"] as? Int ?? 0, inputTokens: usage["inputTokens"] as? Int ?? 0,
outputTokens: usage["outputTokens"] as? Int ?? 0, outputTokens: usage["outputTokens"] as? Int ?? 0,
thoughtTokens: usage["thoughtTokens"] as? Int ?? 0, thoughtTokens: usage["thoughtTokens"] as? Int ?? 0,
cachedReadTokens: usage["cachedReadTokens"] as? Int ?? 0 cachedReadTokens: usage["cachedReadTokens"] as? Int ?? 0,
compressionCount: compression
) )
} }
@@ -243,19 +243,32 @@ public struct ACPPromptResult: Sendable {
public let outputTokens: Int public let outputTokens: Int
public let thoughtTokens: Int public let thoughtTokens: Int
public let cachedReadTokens: Int public let cachedReadTokens: Int
/// Number of automatic context compactions Hermes has performed on this
/// session so far. v0.13+ older Hermes hosts always return 0, which
/// the chat status bar treats as "hide chip". Optional in the wire
/// payload; folded into a non-optional `Int` here with a 0 default so
/// the rest of the pipeline doesn't need to nil-check.
// TODO(WS-8-Q1): Verify that v0.13 Hermes emits the count on
// `session/prompt`'s `usage` blob (assumed here). If it lands on a
// separate `session/update` notification instead, this becomes a new
// ACPEvent case + a branch in RichChatViewModel.handleACPEvent wire
// shape is documented in the WS-8 plan as the bigger fix path.
public let compressionCount: Int
public init( public init(
stopReason: String, stopReason: String,
inputTokens: Int, inputTokens: Int,
outputTokens: Int, outputTokens: Int,
thoughtTokens: Int, thoughtTokens: Int,
cachedReadTokens: Int cachedReadTokens: Int,
compressionCount: Int = 0
) { ) {
self.stopReason = stopReason self.stopReason = stopReason
self.inputTokens = inputTokens self.inputTokens = inputTokens
self.outputTokens = outputTokens self.outputTokens = outputTokens
self.thoughtTokens = thoughtTokens self.thoughtTokens = thoughtTokens
self.cachedReadTokens = cachedReadTokens self.cachedReadTokens = cachedReadTokens
self.compressionCount = compressionCount
} }
} }
@@ -0,0 +1,34 @@
import Foundation
/// Errors thrown by `CuratorService`. Each case carries enough detail
/// to render a user-actionable message the view model surfaces these
/// inline as a banner above the leaderboard rather than blocking with a
/// modal alert.
public enum CuratorError: Error, LocalizedError, Sendable {
/// `hermes` binary couldn't be located.
case cliMissing
/// Subprocess returned non-zero exit. `stderr` may carry a synthetic
/// message when the transport itself failed.
case nonZeroExit(verb: String, code: Int32, stderr: String)
/// JSON decoding failed. Underlying message wrapped for diagnostics.
case decoding(verb: String, message: String)
/// Generic transport error process couldn't start, IO failed, etc.
case transport(message: String)
public var errorDescription: String? {
switch self {
case .cliMissing:
return "Hermes CLI couldn't be found. Install Hermes v0.13+ and ensure it's on your PATH."
case .nonZeroExit(let verb, let code, let stderr):
let trimmed = stderr.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty {
return "`hermes curator \(verb)` exited with code \(code)."
}
return trimmed
case .decoding(let verb, let message):
return "Couldn't decode `hermes curator \(verb)` output: \(message)"
case .transport(let message):
return message
}
}
}
@@ -0,0 +1,76 @@
import Foundation
/// Hermes v0.13 added cross-platform recipient allowlists to the Messaging
/// Gateway. Each platform stores the list under a different YAML key
/// depending on the platform's primary noun for "addressable destination":
///
/// - **`allowed_channels`** Slack, Mattermost, Google Chat
/// - **`allowed_chats`** Telegram, WhatsApp
/// - **`allowed_rooms`** Matrix, DingTalk
///
/// `GatewayAllowlistKind` encodes the (platform key) mapping plus a few
/// presentation hints (placeholder strings, singular noun) so the allowlist
/// editor can render the right copy without the per-platform setup view
/// needing to know the YAML shape.
public enum GatewayAllowlistKind: String, Sendable, Equatable {
case channels // -> allowed_channels
case chats // -> allowed_chats
case rooms // -> allowed_rooms
/// YAML scalar key segment under `gateway.platforms.<platform>.<key>`.
public var yamlKey: String {
switch self {
case .channels: return "allowed_channels"
case .chats: return "allowed_chats"
case .rooms: return "allowed_rooms"
}
}
/// Placeholder copy for the editor's "add row" text field. Picks the
/// most common identifier shape per platform family Slack channel IDs
/// for `channels`, Telegram username/numeric for `chats`, Matrix room
/// IDs for `rooms`. Users can paste in any platform-specific format the
/// gateway accepts; this is a hint, not validation.
public var inputPlaceholder: String {
switch self {
case .channels: return "C0123ABCD or #channel-name"
case .chats: return "@username or 12345678"
case .rooms: return "!RoomId:matrix.org"
}
}
/// Singular noun for prose surfaces ("Add a channel", "1 chat allowed",
/// "0 rooms"). Capitalization is the caller's responsibility.
public var noun: String {
switch self {
case .channels: return "channel"
case .chats: return "chat"
case .rooms: return "room"
}
}
/// Plural noun for headings + counts.
public var pluralNoun: String {
switch self {
case .channels: return "channels"
case .chats: return "chats"
case .rooms: return "rooms"
}
}
/// Map a Hermes platform identifier to the allowlist kind it supports.
/// Returns `nil` for platforms without v0.13 allowlist support
/// (`cli`, `signal`, `email`, `imessage`, `homeassistant`, `webhook`,
/// `yuanbao`, `microsoft-teams`, `feishu`, `discord`).
///
/// `googlechat` and `google-chat` both map to `.channels` so we round-trip
/// regardless of which spelling Hermes lands on. // TODO(WS-5-Q1)
public static func kind(for platform: String) -> GatewayAllowlistKind? {
switch platform {
case "slack", "mattermost", "google-chat", "googlechat": return .channels
case "telegram", "whatsapp": return .chats
case "matrix", "dingtalk": return .rooms
default: return nil
}
}
}
@@ -0,0 +1,71 @@
import Foundation
/// Per-platform Messaging Gateway settings introduced in Hermes v0.13. Bundles
/// the allowlist (the platform-appropriate flavor of `allowed_channels` /
/// `allowed_chats` / `allowed_rooms`) and three behavior toggles
/// (`busy_ack_enabled`, `gateway_restart_notification`,
/// `slash_command_notice_ttl_seconds`).
///
/// The struct carries all three list fields so a single shape fits every
/// platform; only the field matching `GatewayAllowlistKind.kind(for:)` is
/// surfaced in the editor for a given platform. The other two stay empty
/// and round-trip through the YAML parser unchanged.
///
/// **Defaults track Hermes v0.13.** `busyAckEnabled = true`,
/// `gatewayRestartNotification = false`, `slashCommandNoticeTTLSeconds = 0`
/// (disabled). An "all-default" instance therefore produces no `gateway:`
/// block in YAML see `HermesConfig+YAML` parsing logic which only inserts
/// an entry into `gatewayPlatforms` when at least one v0.13 key is present
/// in the file.
public struct GatewayPlatformSettings: Sendable, Equatable {
/// `gateway.platforms.<platform>.allowed_channels` Slack, Mattermost,
/// Google Chat. Empty when the platform doesn't use channels.
public var allowedChannels: [String]
/// `gateway.platforms.<platform>.allowed_chats` Telegram, WhatsApp.
/// Empty when the platform doesn't use chats.
public var allowedChats: [String]
/// `gateway.platforms.<platform>.allowed_rooms` Matrix, DingTalk.
/// Empty when the platform doesn't use rooms.
public var allowedRooms: [String]
/// `gateway.platforms.<platform>.busy_ack_enabled`. Default `true` set
/// to `false` to suppress per-message "agent is working" acks.
public var busyAckEnabled: Bool
/// `gateway.platforms.<platform>.gateway_restart_notification`. Default
/// `false` set to `true` to post a "Gateway restarted" notice on boot.
public var gatewayRestartNotification: Bool
/// `gateway.platforms.<platform>.slash_command_notice_ttl_seconds`.
/// Default `0` (disabled). Positive values auto-delete slash-command
/// notices after N seconds.
public var slashCommandNoticeTTLSeconds: Int
public init(
allowedChannels: [String] = [],
allowedChats: [String] = [],
allowedRooms: [String] = [],
busyAckEnabled: Bool = true,
gatewayRestartNotification: Bool = false,
slashCommandNoticeTTLSeconds: Int = 0
) {
self.allowedChannels = allowedChannels
self.allowedChats = allowedChats
self.allowedRooms = allowedRooms
self.busyAckEnabled = busyAckEnabled
self.gatewayRestartNotification = gatewayRestartNotification
self.slashCommandNoticeTTLSeconds = slashCommandNoticeTTLSeconds
}
/// All-default instance. `HermesConfig.empty` initializes
/// `gatewayPlatforms: [:]` so this is rarely used directly; provided
/// for symmetry with the other settings types.
public static let empty = GatewayPlatformSettings()
/// The list field matching this allowlist kind, or `nil` for
/// platforms without an allowlist surface.
public func items(for kind: GatewayAllowlistKind) -> [String] {
switch kind {
case .channels: return allowedChannels
case .chats: return allowedChats
case .rooms: return allowedRooms
}
}
}
@@ -0,0 +1,26 @@
import Foundation
/// Optimistic local mirror of the agent's currently-locked goal (set via
/// the `/goal <text>` slash command, Hermes v0.13+). Scarf records this
/// the moment the user sends `/goal ` so the chat header pill appears
/// synchronously, without waiting for a server round-trip. There is no
/// authoritative read-back path in v2.8.0 see WS-2 plan Q1.
///
/// Plain value type, no mutation API. Drives the goal pill in
/// `SessionInfoBar` and the inspector contextual menu.
public struct HermesActiveGoal: Sendable, Equatable, Identifiable {
/// The user's verbatim goal text (post-trim).
public let text: String
/// When Scarf observed the `/goal` send. Local clock not the
/// server's authoritative timestamp.
public let setAt: Date
public var id: String {
text + "@" + ISO8601DateFormatter().string(from: setAt)
}
public init(text: String, setAt: Date) {
self.text = text
self.setAt = setAt
}
}
@@ -36,6 +36,13 @@ public struct DisplaySettings: Sendable, Equatable {
public var toolProgressCommand: Bool public var toolProgressCommand: Bool
public var toolPreviewLength: Int public var toolPreviewLength: Int
public var busyInputMode: String // e.g. "interrupt" public var busyInputMode: String // e.g. "interrupt"
/// Static-message translation language. v0.13+. Empty string means
/// "follow Hermes default" the picker collapses both empty-string
/// and `"en"` to "English" in display, but only writes a value when
/// the user explicitly picks one. Persisted via
/// `hermes config set display.language <code>`. Supported values per
/// v0.13 release notes: `en`, `zh`, `ja`, `de`, `es`, `fr`, `uk`, `tr`.
public var language: String
public init( public init(
@@ -46,7 +53,8 @@ public struct DisplaySettings: Sendable, Equatable {
inlineDiffs: Bool, inlineDiffs: Bool,
toolProgressCommand: Bool, toolProgressCommand: Bool,
toolPreviewLength: Int, toolPreviewLength: Int,
busyInputMode: String busyInputMode: String,
language: String = ""
) { ) {
self.skin = skin self.skin = skin
self.compact = compact self.compact = compact
@@ -56,6 +64,7 @@ public struct DisplaySettings: Sendable, Equatable {
self.toolProgressCommand = toolProgressCommand self.toolProgressCommand = toolProgressCommand
self.toolPreviewLength = toolPreviewLength self.toolPreviewLength = toolPreviewLength
self.busyInputMode = busyInputMode self.busyInputMode = busyInputMode
self.language = language
} }
public nonisolated static let empty = DisplaySettings( public nonisolated static let empty = DisplaySettings(
skin: "default", skin: "default",
@@ -65,7 +74,8 @@ public struct DisplaySettings: Sendable, Equatable {
inlineDiffs: true, inlineDiffs: true,
toolProgressCommand: false, toolProgressCommand: false,
toolPreviewLength: 0, toolPreviewLength: 0,
busyInputMode: "interrupt" busyInputMode: "interrupt",
language: ""
) )
} }
@@ -190,6 +200,15 @@ public struct VoiceSettings: Sendable, Equatable {
public var ttsOpenAIVoice: String public var ttsOpenAIVoice: String
public var ttsNeuTTSModel: String public var ttsNeuTTSModel: String
public var ttsNeuTTSDevice: String public var ttsNeuTTSDevice: String
/// xAI TTS voice identifier. v0.13+ xAI shipped TTS earlier but the
/// custom-voice / cloning surface is the v0.13 add-on.
// TODO(WS-8-Q2): Confirm key name vs `tts.xai.voice` /
// `tts.xai.voice_id` / a top-level `tts.xai_voice` once a v0.13
// host is on hand. The setter / YAML reader follow whatever this
// field name implies.
public var ttsXAIVoiceID: String
/// xAI TTS model identifier. v0.13+. Mirrors the elevenlabs shape.
public var ttsXAIModel: String
// STT // STT
public var sttEnabled: Bool public var sttEnabled: Bool
@@ -217,7 +236,9 @@ public struct VoiceSettings: Sendable, Equatable {
sttLocalModel: String, sttLocalModel: String,
sttLocalLanguage: String, sttLocalLanguage: String,
sttOpenAIModel: String, sttOpenAIModel: String,
sttMistralModel: String sttMistralModel: String,
ttsXAIVoiceID: String = "",
ttsXAIModel: String = ""
) { ) {
self.recordKey = recordKey self.recordKey = recordKey
self.maxRecordingSeconds = maxRecordingSeconds self.maxRecordingSeconds = maxRecordingSeconds
@@ -230,6 +251,8 @@ public struct VoiceSettings: Sendable, Equatable {
self.ttsOpenAIVoice = ttsOpenAIVoice self.ttsOpenAIVoice = ttsOpenAIVoice
self.ttsNeuTTSModel = ttsNeuTTSModel self.ttsNeuTTSModel = ttsNeuTTSModel
self.ttsNeuTTSDevice = ttsNeuTTSDevice self.ttsNeuTTSDevice = ttsNeuTTSDevice
self.ttsXAIVoiceID = ttsXAIVoiceID
self.ttsXAIModel = ttsXAIModel
self.sttEnabled = sttEnabled self.sttEnabled = sttEnabled
self.sttProvider = sttProvider self.sttProvider = sttProvider
self.sttLocalModel = sttLocalModel self.sttLocalModel = sttLocalModel
@@ -254,7 +277,9 @@ public struct VoiceSettings: Sendable, Equatable {
sttLocalModel: "base", sttLocalModel: "base",
sttLocalLanguage: "", sttLocalLanguage: "",
sttOpenAIModel: "whisper-1", sttOpenAIModel: "whisper-1",
sttMistralModel: "voxtral-mini-latest" sttMistralModel: "voxtral-mini-latest",
ttsXAIVoiceID: "",
ttsXAIModel: ""
) )
} }
@@ -666,8 +691,29 @@ public struct HermesConfig: Sendable {
/// final reply (provider/model/cost/turn count). Off by default; /// final reply (provider/model/cost/turn count). Off by default;
/// useful for cost auditing and screen-recording demos. /// useful for cost auditing and screen-recording demos.
public var runtimeMetadataFooter: Bool public var runtimeMetadataFooter: Bool
/// Pre-v0.13: single combined Web Tools backend at `web_tools.backend`.
/// v0.13 split this into per-capability keys (see below). Kept readable
/// for round-trip compatibility on hosts that never migrated; v0.13+
/// hosts ignore this scalar and read the split keys instead.
public var webToolsBackend: String
/// v0.13+: `web_tools.search.backend`. SearXNG is search-only and
/// can land here. Pre-v0.13 hosts default to the same value as the
/// combined backend.
public var webToolsSearchBackend: String
/// v0.13+: `web_tools.extract.backend`. Pre-v0.13 hosts default to
/// the same value as the combined backend.
public var webToolsExtractBackend: String
// -- Hermes v0.13 additions ---------------------------------------- // -- Hermes v0.13 additions ----------------------------------------
// Per-platform Messaging Gateway settings dictionary keyed by Hermes
// platform identifier (`slack`, `telegram`, `matrix`, `mattermost`,
// `whatsapp`, `dingtalk`, `google-chat`). Populated only for platforms
// whose `gateway.platforms.<platform>.*` block exists in config.yaml
// platforms without an explicit block don't appear in the dictionary.
// Editing surfaces (per-platform setup forms) read with a `?? .empty`
// fallback so a missing entry behaves identically to an all-default
// entry.
public var gatewayPlatforms: [String: GatewayPlatformSettings]
/// `image_gen.model` (v0.13+) overrides the per-provider default /// `image_gen.model` (v0.13+) overrides the per-provider default
/// image-gen model. Empty string means "let Hermes pick the /// image-gen model. Empty string means "let Hermes pick the
@@ -769,14 +815,22 @@ public struct HermesConfig: Sendable {
cacheTTL: String = "5m", cacheTTL: String = "5m",
redactionEnabled: Bool = false, redactionEnabled: Bool = false,
runtimeMetadataFooter: Bool = false, runtimeMetadataFooter: Bool = false,
gatewayPlatforms: [String: GatewayPlatformSettings] = [:],
imageGenModel: String = "", imageGenModel: String = "",
openrouterResponseCacheEnabled: Bool = false openrouterResponseCacheEnabled: Bool = false,
webToolsBackend: String = "duckduckgo",
webToolsSearchBackend: String = "duckduckgo",
webToolsExtractBackend: String = "reader"
) { ) {
self.cacheTTL = cacheTTL self.cacheTTL = cacheTTL
self.redactionEnabled = redactionEnabled self.redactionEnabled = redactionEnabled
self.runtimeMetadataFooter = runtimeMetadataFooter self.runtimeMetadataFooter = runtimeMetadataFooter
self.gatewayPlatforms = gatewayPlatforms
self.imageGenModel = imageGenModel self.imageGenModel = imageGenModel
self.openrouterResponseCacheEnabled = openrouterResponseCacheEnabled self.openrouterResponseCacheEnabled = openrouterResponseCacheEnabled
self.webToolsBackend = webToolsBackend
self.webToolsSearchBackend = webToolsSearchBackend
self.webToolsExtractBackend = webToolsExtractBackend
self.model = model self.model = model
self.provider = provider self.provider = provider
self.maxTurns = maxTurns self.maxTurns = maxTurns
@@ -28,6 +28,12 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
/// job's prompt. YAML-only field today (no `--context-from` CLI /// job's prompt. YAML-only field today (no `--context-from` CLI
/// flag yet) Scarf displays it but doesn't write it. /// flag yet) Scarf displays it but doesn't write it.
public nonisolated let contextFrom: [String]? public nonisolated let contextFrom: [String]?
/// Hermes v0.13+ script-only watchdog mode. When `true` the
/// pre-run script runs but the AI turn is skipped. `nil` means the
/// jobs.json file is pre-v0.13 (treat as `false`); `false` is the
/// explicit v0.13+ default. Capability-gated on `hasCronNoAgent`
/// at all write call sites.
public nonisolated let noAgent: Bool?
public enum CodingKeys: String, CodingKey { public enum CodingKeys: String, CodingKey {
case id, name, prompt, skills, model, schedule, enabled, state, deliver, silent case id, name, prompt, skills, model, schedule, enabled, state, deliver, silent
@@ -41,6 +47,7 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
case timeoutSeconds = "timeout_seconds" case timeoutSeconds = "timeout_seconds"
case workdir case workdir
case contextFrom = "context_from" case contextFrom = "context_from"
case noAgent = "no_agent"
} }
/// Memberwise init. Swift doesn't synthesize one for us because /// Memberwise init. Swift doesn't synthesize one for us because
@@ -66,7 +73,8 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
timeoutSeconds: Int? = nil, timeoutSeconds: Int? = nil,
silent: Bool? = nil, silent: Bool? = nil,
workdir: String? = nil, workdir: String? = nil,
contextFrom: [String]? = nil contextFrom: [String]? = nil,
noAgent: Bool? = nil
) { ) {
self.id = id self.id = id
self.name = name self.name = name
@@ -88,6 +96,7 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
self.silent = silent self.silent = silent
self.workdir = workdir self.workdir = workdir
self.contextFrom = contextFrom self.contextFrom = contextFrom
self.noAgent = noAgent
} }
public nonisolated init(from decoder: any Decoder) throws { public nonisolated init(from decoder: any Decoder) throws {
@@ -112,6 +121,7 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
self.silent = try c.decodeIfPresent(Bool.self, forKey: .silent) self.silent = try c.decodeIfPresent(Bool.self, forKey: .silent)
self.workdir = try c.decodeIfPresent(String.self, forKey: .workdir) self.workdir = try c.decodeIfPresent(String.self, forKey: .workdir)
self.contextFrom = try c.decodeIfPresent([String].self, forKey: .contextFrom) self.contextFrom = try c.decodeIfPresent([String].self, forKey: .contextFrom)
self.noAgent = try c.decodeIfPresent(Bool.self, forKey: .noAgent)
} }
public nonisolated func encode(to encoder: any Encoder) throws { public nonisolated func encode(to encoder: any Encoder) throws {
@@ -136,6 +146,7 @@ public struct HermesCronJob: Identifiable, Sendable, Codable {
try c.encodeIfPresent(silent, forKey: .silent) try c.encodeIfPresent(silent, forKey: .silent)
try c.encodeIfPresent(workdir, forKey: .workdir) try c.encodeIfPresent(workdir, forKey: .workdir)
try c.encodeIfPresent(contextFrom, forKey: .contextFrom) try c.encodeIfPresent(contextFrom, forKey: .contextFrom)
try c.encodeIfPresent(noAgent, forKey: .noAgent)
} }
public nonisolated var stateIcon: String { public nonisolated var stateIcon: String {
@@ -0,0 +1,124 @@
import Foundation
/// One entry in the `hermes curator list-archived` output. Decoded
/// tolerantly via `decodeIfPresent` so a stripped-down host (or a future
/// Hermes that drops one of the optional columns) doesn't crash the view.
///
/// Only `name` is required every other field is optional and the
/// computed `*Label` accessors render `""` for missing values.
public struct HermesCuratorArchivedSkill: Sendable, Equatable, Identifiable, Codable {
public var id: String { name }
public let name: String
public let category: String?
public let archivedAt: String?
public let reason: String?
public let sizeBytes: Int?
public let path: String?
public init(
name: String,
category: String? = nil,
archivedAt: String? = nil,
reason: String? = nil,
sizeBytes: Int? = nil,
path: String? = nil
) {
self.name = name
self.category = category
self.archivedAt = archivedAt
self.reason = reason
self.sizeBytes = sizeBytes
self.path = path
}
private enum CodingKeys: String, CodingKey {
case name
case category
case archivedAt = "archived_at"
case reason
case sizeBytes = "size_bytes"
case path
}
public init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
self.name = try c.decode(String.self, forKey: .name)
self.category = try c.decodeIfPresent(String.self, forKey: .category)
self.archivedAt = try c.decodeIfPresent(String.self, forKey: .archivedAt)
self.reason = try c.decodeIfPresent(String.self, forKey: .reason)
self.sizeBytes = try c.decodeIfPresent(Int.self, forKey: .sizeBytes)
self.path = try c.decodeIfPresent(String.self, forKey: .path)
}
public func encode(to encoder: Encoder) throws {
var c = encoder.container(keyedBy: CodingKeys.self)
try c.encode(name, forKey: .name)
try c.encodeIfPresent(category, forKey: .category)
try c.encodeIfPresent(archivedAt, forKey: .archivedAt)
try c.encodeIfPresent(reason, forKey: .reason)
try c.encodeIfPresent(sizeBytes, forKey: .sizeBytes)
try c.encodeIfPresent(path, forKey: .path)
}
/// "4.4 KB" / "1.2 MB" / "" for nil. Uses the SI byte formatter so
/// the labels match what Finder shows.
public var sizeLabel: String {
guard let bytes = sizeBytes else { return "" }
let formatter = ByteCountFormatter()
formatter.allowedUnits = [.useAll]
formatter.countStyle = .file
return formatter.string(fromByteCount: Int64(bytes))
}
/// `2026-04-22` (ISO date prefix) / "". Hermes returns full ISO
/// timestamps with seconds + Z; the date prefix is what the user
/// actually wants in the archived list.
public var archivedAtLabel: String {
guard let iso = archivedAt, !iso.isEmpty else { return "" }
// Trim to date prefix if it looks like a full ISO timestamp.
if let tIdx = iso.firstIndex(of: "T") {
return String(iso[..<tIdx])
}
return iso
}
}
/// Result of `hermes curator prune --dry-run` what would be removed
/// if the user confirms. The view derives `totalCount` from
/// `wouldRemove.count` so the wire shape stays flat.
public struct CuratorPruneSummary: Sendable, Equatable, Codable {
public let wouldRemove: [HermesCuratorArchivedSkill]
public let totalBytes: Int
public var totalCount: Int { wouldRemove.count }
public init(wouldRemove: [HermesCuratorArchivedSkill], totalBytes: Int) {
self.wouldRemove = wouldRemove
self.totalBytes = totalBytes
}
private enum CodingKeys: String, CodingKey {
case wouldRemove = "would_remove"
case totalBytes = "total_bytes"
}
public init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
self.wouldRemove = try c.decodeIfPresent([HermesCuratorArchivedSkill].self, forKey: .wouldRemove) ?? []
self.totalBytes = try c.decodeIfPresent(Int.self, forKey: .totalBytes) ?? 0
}
public func encode(to encoder: Encoder) throws {
var c = encoder.container(keyedBy: CodingKeys.self)
try c.encode(wouldRemove, forKey: .wouldRemove)
try c.encode(totalBytes, forKey: .totalBytes)
}
/// "12.3 KB" / "" for empty. Convenience for the confirm sheet header.
public var totalBytesLabel: String {
guard totalBytes > 0 else { return "" }
let formatter = ByteCountFormatter()
formatter.allowedUnits = [.useAll]
formatter.countStyle = .file
return formatter.string(fromByteCount: Int64(totalBytes))
}
}
@@ -0,0 +1,158 @@
import Foundation
/// A structured signal Hermes emits when it observes worker / task
/// distress. Hermes v0.13 introduced a generic diagnostics engine that
/// attaches these to a task (cross-run signals) and/or a run (per-attempt
/// signals). Pre-v0.13 hosts never emit diagnostics so the array decodes
/// empty and downstream UI no-ops.
///
/// **Wire shape (best inference from release notes verify against live
/// JSON during integration):** an array of objects with `kind`, optional
/// `message`, optional `detected_at` (ISO-8601 string OR Unix integer,
/// matching the rest of `HermesKanbanTask`'s timestamp tolerance).
///
/// **Forward compat:** `kind` stays a `String` so a future Hermes can
/// add new diagnostic kinds without a Scarf release. `KanbanDiagnosticKind`
/// is the typed mirror it falls back to `.unknown` for unrecognized
/// kinds and renders the raw string verbatim.
public struct HermesKanbanDiagnostic: Sendable, Equatable, Identifiable, Codable {
/// Synthetic id not on the wire. Lets SwiftUI `ForEach` over a
/// diagnostic array without forcing a deterministic id from the
/// server (Hermes doesn't currently mint one).
public let id: UUID
/// Wire-side `kind` string. Compared case-insensitively via
/// `KanbanDiagnosticKind.from(_:)`.
public let kind: String
/// Human-friendly elaboration ("no heartbeat for 4m20s", "exit code
/// 0 with no complete call", etc.). May be nil; render the raw
/// `kind` then.
public let message: String?
/// ISO-8601 string. Decoder accepts Unix integer seconds (Hermes's
/// SQLite-backed shape) and converts to ISO-8601 so consumers see
/// one type same pattern as `HermesKanbanTask.decodeFlexibleTimestamp`.
public let detectedAt: String?
public init(
kind: String,
message: String? = nil,
detectedAt: String? = nil
) {
self.id = UUID()
self.kind = kind
self.message = message
self.detectedAt = detectedAt
}
enum CodingKeys: String, CodingKey {
case kind
case message
case detectedAt = "detected_at"
}
public init(from decoder: any Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
self.id = UUID()
self.kind = try c.decodeIfPresent(String.self, forKey: .kind) ?? "unknown"
self.message = try c.decodeIfPresent(String.self, forKey: .message)
// Flexible timestamp decode mirrors HermesKanbanTask's pattern.
if !c.contains(.detectedAt) {
self.detectedAt = nil
} else if let unix = try? c.decodeIfPresent(Double.self, forKey: .detectedAt) {
let date = Date(timeIntervalSince1970: unix)
self.detectedAt = Self.isoFormatter.string(from: date)
} else {
self.detectedAt = try c.decodeIfPresent(String.self, forKey: .detectedAt)
}
}
public func encode(to encoder: any Encoder) throws {
var c = encoder.container(keyedBy: CodingKeys.self)
try c.encode(kind, forKey: .kind)
try c.encodeIfPresent(message, forKey: .message)
try c.encodeIfPresent(detectedAt, forKey: .detectedAt)
}
public static func == (lhs: HermesKanbanDiagnostic, rhs: HermesKanbanDiagnostic) -> Bool {
// Compare on wire fields, not synthetic id round-trip decoding
// mints fresh ids.
lhs.kind == rhs.kind
&& lhs.message == rhs.message
&& lhs.detectedAt == rhs.detectedAt
}
private static let isoFormatter: ISO8601DateFormatter = {
let f = ISO8601DateFormatter()
f.formatOptions = [.withInternetDateTime]
return f
}()
}
// MARK: - Typed mirror
/// Typed view of `HermesKanbanDiagnostic.kind`. Models keep the raw
/// string for forward compatibility; UI helpers read this enum to pick
/// the right glyph + tint without string-matching at every callsite.
///
/// `unknown` is the fallback for any kind a future Hermes adds that
/// Scarf doesn't recognize. Views render the raw string verbatim in
/// that case so the user still sees what Hermes flagged.
// TODO(WS-3-Q5): The exact `kind` string for darwin-zombie detection is
// inferred from the v0.13 release notes ("Detect darwin zombie workers");
// confirm against live `hermes kanban show --json` output during
// integration. Same for `worker_exit_no_complete` and the heartbeat-stalled
// kinds typed mirror falls through to `.unknown` if the wire string
// drifts, and the raw string is still rendered.
public enum KanbanDiagnosticKind: String, Sendable, CaseIterable {
case heartbeatStalled = "heartbeat_stalled"
case toolErrorLoop = "tool_error_loop"
case retryCapHit = "retry_cap_hit"
case unboundedRetry = "unbounded_retry"
case darwinZombieDetected = "darwin_zombie_detected"
case spawnFailure = "spawn_failure"
case workerExitNoComplete = "worker_exit_no_complete"
case unknown
/// Map a wire string (case-insensitive) to a typed kind. Unknown
/// values fall through to `.unknown` so callers can still surface
/// the raw string.
public static func from(_ raw: String) -> KanbanDiagnosticKind {
KanbanDiagnosticKind(rawValue: raw.lowercased()) ?? .unknown
}
/// SF Symbol name to render alongside the diagnostic. View code
/// reaches through the typed enum so glyph choices live in one
/// place.
public var glyphName: String {
switch self {
case .heartbeatStalled: return "waveform.path.badge.minus"
case .toolErrorLoop: return "arrow.triangle.2.circlepath.exclamationmark"
case .retryCapHit: return "nosign"
case .unboundedRetry: return "arrow.clockwise.circle.fill"
case .darwinZombieDetected: return "apple.logo"
case .spawnFailure: return "bolt.slash"
case .workerExitNoComplete: return "figure.walk.departure"
case .unknown: return "stethoscope"
}
}
/// Severity tier for this kind drives badge tint. `.danger` for
/// terminal-class signals (retry cap hit, zombie, spawn failure);
/// `.warning` for recoverable signals (heartbeat stalled, tool
/// error loop); `.neutral` only for unknown / forward-compat kinds.
public var severity: DiagnosticSeverity {
switch self {
case .retryCapHit, .darwinZombieDetected, .spawnFailure:
return .danger
case .heartbeatStalled, .toolErrorLoop, .unboundedRetry, .workerExitNoComplete:
return .warning
case .unknown:
return .neutral
}
}
public enum DiagnosticSeverity: Sendable {
case warning
case danger
case neutral
}
}
@@ -24,6 +24,19 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
/// raw string so we don't lock the typed shape. /// raw string so we don't lock the typed shape.
public let metadataJSON: String? public let metadataJSON: String?
// v0.13 (v2026.5.7) fields. Both Optional / empty-default so a v0.12
// host's run row decodes without error.
/// Per-attempt distress signals. Cross-run signals (retry cap hit,
/// etc.) hang off `HermesKanbanTask.diagnostics`; in-flight signals
/// (heartbeat stalled, darwin zombie detected) attach here.
public let diagnostics: [HermesKanbanDiagnostic]
/// Server-side unified failure counter (renamed from three separate
/// spawn / timeout / crash counters in v0.13). Optional when nil,
/// callers fall back to counting failed runs in the runs array.
// TODO(WS-3-Q4): Verify whether v0.13 exposes this field on the per-run
// shape OR only at the task level. Tolerant decode handles either.
public let failureCount: Int?
public init( public init(
id: Int, id: Int,
taskId: String, taskId: String,
@@ -40,7 +53,9 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
outcome: String? = nil, outcome: String? = nil,
summary: String? = nil, summary: String? = nil,
error: String? = nil, error: String? = nil,
metadataJSON: String? = nil metadataJSON: String? = nil,
diagnostics: [HermesKanbanDiagnostic] = [],
failureCount: Int? = nil
) { ) {
self.id = id self.id = id
self.taskId = taskId self.taskId = taskId
@@ -58,6 +73,8 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
self.summary = summary self.summary = summary
self.error = error self.error = error
self.metadataJSON = metadataJSON self.metadataJSON = metadataJSON
self.diagnostics = diagnostics
self.failureCount = failureCount
} }
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
@@ -77,6 +94,8 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
case summary case summary
case error case error
case metadata case metadata
case diagnostics
case failureCount = "failure_count"
} }
public init(from decoder: any Decoder) throws { public init(from decoder: any Decoder) throws {
@@ -120,6 +139,11 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
} else { } else {
self.metadataJSON = nil self.metadataJSON = nil
} }
// v0.13 diagnostics array `try?` so a malformed entry doesn't
// poison the whole run row. Empty default for pre-v0.13 hosts.
self.diagnostics = (try? c.decodeIfPresent([HermesKanbanDiagnostic].self, forKey: .diagnostics)) ?? []
self.failureCount = try c.decodeIfPresent(Int.self, forKey: .failureCount)
} }
public func encode(to encoder: any Encoder) throws { public func encode(to encoder: any Encoder) throws {
@@ -140,5 +164,7 @@ public struct HermesKanbanRun: Sendable, Equatable, Identifiable, Codable {
try c.encodeIfPresent(summary, forKey: .summary) try c.encodeIfPresent(summary, forKey: .summary)
try c.encodeIfPresent(error, forKey: .error) try c.encodeIfPresent(error, forKey: .error)
try c.encodeIfPresent(metadataJSON, forKey: .metadata) try c.encodeIfPresent(metadataJSON, forKey: .metadata)
try c.encode(diagnostics, forKey: .diagnostics)
try c.encodeIfPresent(failureCount, forKey: .failureCount)
} }
} }
@@ -9,8 +9,9 @@ import Foundation
/// `link`/`unlink`, `comment`, `dispatch`). /// `link`/`unlink`, `comment`, `dispatch`).
/// ///
/// Hermes has no `update` verb `priority` / `title` / `body` / /// Hermes has no `update` verb `priority` / `title` / `body` /
/// `tenant` are write-once at create time. Mutations after that are /// `tenant` / `max_retries` are write-once at create time. Mutations
/// expressed as state transitions (status, assignee) or new comments. /// after that are expressed as state transitions (status, assignee) or
/// new comments.
public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable { public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
public let id: String public let id: String
public let title: String public let title: String
@@ -34,6 +35,29 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
public let maxRuntimeSeconds: Int? public let maxRuntimeSeconds: Int?
public let currentRunId: Int? public let currentRunId: Int?
// v0.13 (v2026.5.7) reliability + recovery fields. All Optional with
// `nil` decoded for pre-v0.13 hosts so the v2.7.5 surface keeps
// rendering unchanged when the connected Hermes hasn't shipped them.
/// Per-task retry budget set at create time via `--max-retries N`.
/// Hermes pattern is write-once no `set_max_retries` verb. Scarf
/// surfaces this read-only on the inspector header.
public let maxRetries: Int?
/// Server-supplied reason a task was auto-blocked (e.g. "worker
/// exited (code 0) without calling `kanban complete`"). Surfaced
/// verbatim in the inspector banner.
public let autoBlockedReason: String?
/// `pending` / `verified` / `rejected` / nil. Pending means a worker
/// claimed it created this card but Hermes hasn't confirmed the
/// underlying work exists. Read through `KanbanHallucinationGate.from`
/// to map to a typed mirror kept as a String at the wire level so
/// Hermes can add new gate states (e.g. `quarantined`) without a
/// Scarf release.
public let hallucinationGateStatus: String?
/// Cross-run distress signals (retry cap hit, etc.). Per-run signals
/// hang off `HermesKanbanRun.diagnostics`. Empty array for pre-v0.13
/// hosts AND for tasks the diagnostics engine hasn't flagged.
public let diagnostics: [HermesKanbanDiagnostic]
public init( public init(
id: String, id: String,
title: String, title: String,
@@ -53,7 +77,11 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
idempotencyKey: String? = nil, idempotencyKey: String? = nil,
lastHeartbeatAt: String? = nil, lastHeartbeatAt: String? = nil,
maxRuntimeSeconds: Int? = nil, maxRuntimeSeconds: Int? = nil,
currentRunId: Int? = nil currentRunId: Int? = nil,
maxRetries: Int? = nil,
autoBlockedReason: String? = nil,
hallucinationGateStatus: String? = nil,
diagnostics: [HermesKanbanDiagnostic] = []
) { ) {
self.id = id self.id = id
self.title = title self.title = title
@@ -74,6 +102,10 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
self.lastHeartbeatAt = lastHeartbeatAt self.lastHeartbeatAt = lastHeartbeatAt
self.maxRuntimeSeconds = maxRuntimeSeconds self.maxRuntimeSeconds = maxRuntimeSeconds
self.currentRunId = currentRunId self.currentRunId = currentRunId
self.maxRetries = maxRetries
self.autoBlockedReason = autoBlockedReason
self.hallucinationGateStatus = hallucinationGateStatus
self.diagnostics = diagnostics
} }
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
@@ -89,6 +121,10 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
case lastHeartbeatAt = "last_heartbeat_at" case lastHeartbeatAt = "last_heartbeat_at"
case maxRuntimeSeconds = "max_runtime_seconds" case maxRuntimeSeconds = "max_runtime_seconds"
case currentRunId = "current_run_id" case currentRunId = "current_run_id"
case maxRetries = "max_retries"
case autoBlockedReason = "auto_blocked_reason"
case hallucinationGateStatus = "hallucination_gate_status"
case diagnostics
} }
public init(from decoder: any Decoder) throws { public init(from decoder: any Decoder) throws {
@@ -117,6 +153,17 @@ public struct HermesKanbanTask: Sendable, Equatable, Identifiable, Codable {
self.lastHeartbeatAt = try Self.decodeFlexibleTimestamp(c, forKey: .lastHeartbeatAt) self.lastHeartbeatAt = try Self.decodeFlexibleTimestamp(c, forKey: .lastHeartbeatAt)
self.maxRuntimeSeconds = try c.decodeIfPresent(Int.self, forKey: .maxRuntimeSeconds) self.maxRuntimeSeconds = try c.decodeIfPresent(Int.self, forKey: .maxRuntimeSeconds)
self.currentRunId = try c.decodeIfPresent(Int.self, forKey: .currentRunId) self.currentRunId = try c.decodeIfPresent(Int.self, forKey: .currentRunId)
// v0.13 fields every one is `decodeIfPresent` so a v0.12 host's
// task row decodes successfully with these all nil/empty. The
// tolerant-decode contract is pinned by KanbanModelsTests.
self.maxRetries = try c.decodeIfPresent(Int.self, forKey: .maxRetries)
self.autoBlockedReason = try c.decodeIfPresent(String.self, forKey: .autoBlockedReason)
self.hallucinationGateStatus = try c.decodeIfPresent(String.self, forKey: .hallucinationGateStatus)
// Wrap diagnostics decode in `try?` so a single malformed entry
// (or the whole array being the wrong shape) doesn't poison the
// task row the rest of the decoder still produces a usable
// task. Empty default matches the `skills` pattern.
self.diagnostics = (try? c.decodeIfPresent([HermesKanbanDiagnostic].self, forKey: .diagnostics)) ?? []
} }
/// Decode a timestamp that may arrive as a Unix integer or an /// Decode a timestamp that may arrive as a Unix integer or an
@@ -209,3 +256,27 @@ public enum KanbanBoardColumn: String, Sendable, CaseIterable, Identifiable {
.triage, .upNext, .running, .blocked, .done .triage, .upNext, .running, .blocked, .done
] ]
} }
// MARK: - Hallucination gate (v0.13)
/// Typed mirror of Hermes v0.13's hallucination-gate state. Worker-created
/// cards land in `pending` until something verifies the underlying work
/// exists; Scarf surfaces a Verify / Reject UX above the task body so the
/// user can act as the verification gate.
///
/// Kept separate from `KanbanStatus` because hallucination state is
/// orthogonal to the lifecycle a card can be `ready` *and* `pending`,
/// for example.
public enum KanbanHallucinationGate: String, Sendable, CaseIterable {
case pending
case verified
case rejected
/// Map a raw `hallucination_gate_status` string (case-insensitive) to
/// a typed gate. Returns nil for empty/nil/unknown values so callers
/// can short-circuit "no gate" branches with `if let gate = `.
public static func from(_ raw: String?) -> KanbanHallucinationGate? {
guard let raw, !raw.isEmpty else { return nil }
return KanbanHallucinationGate(rawValue: raw.lowercased())
}
}
@@ -12,17 +12,27 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
/// to the worker as upstream context; surfacing them in the /// to the worker as upstream context; surfacing them in the
/// inspector is useful for understanding why a task started. /// inspector is useful for understanding why a task started.
public let parentResults: [String: String] public let parentResults: [String: String]
/// Envelope-level diagnostics array (sibling to `task`, not nested
/// inside it). Defensive Hermes v0.13's wire shape may attach
/// diagnostics to the task itself OR to the envelope.
/// `allDiagnostics` dedupes both sources by `(kind, detected_at)`.
// TODO(WS-3-Q2): Confirm against live `hermes kanban show --json`
// whether diagnostics live on the task envelope, the inner task, or
// both. Current decode is tolerant of either.
public let envelopeDiagnostics: [HermesKanbanDiagnostic]?
public init( public init(
task: HermesKanbanTask, task: HermesKanbanTask,
comments: [HermesKanbanComment] = [], comments: [HermesKanbanComment] = [],
events: [HermesKanbanEvent] = [], events: [HermesKanbanEvent] = [],
parentResults: [String: String] = [:] parentResults: [String: String] = [:],
envelopeDiagnostics: [HermesKanbanDiagnostic]? = nil
) { ) {
self.task = task self.task = task
self.comments = comments self.comments = comments
self.events = events self.events = events
self.parentResults = parentResults self.parentResults = parentResults
self.envelopeDiagnostics = envelopeDiagnostics
} }
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
@@ -30,6 +40,7 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
case comments case comments
case events case events
case parentResults = "parent_results" case parentResults = "parent_results"
case envelopeDiagnostics = "diagnostics"
} }
public init(from decoder: any Decoder) throws { public init(from decoder: any Decoder) throws {
@@ -48,6 +59,9 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
self.comments = (try? container.decodeIfPresent([HermesKanbanComment].self, forKey: .comments)) ?? [] self.comments = (try? container.decodeIfPresent([HermesKanbanComment].self, forKey: .comments)) ?? []
self.events = (try? container.decodeIfPresent([HermesKanbanEvent].self, forKey: .events)) ?? [] self.events = (try? container.decodeIfPresent([HermesKanbanEvent].self, forKey: .events)) ?? []
self.parentResults = (try? container.decodeIfPresent([String: String].self, forKey: .parentResults)) ?? [:] self.parentResults = (try? container.decodeIfPresent([String: String].self, forKey: .parentResults)) ?? [:]
// Same `try?` shield as the rest a malformed envelope
// diagnostics array shouldn't reject the whole show response.
self.envelopeDiagnostics = try? container.decodeIfPresent([HermesKanbanDiagnostic].self, forKey: .envelopeDiagnostics)
} }
public func encode(to encoder: any Encoder) throws { public func encode(to encoder: any Encoder) throws {
@@ -56,5 +70,20 @@ public struct HermesKanbanTaskDetail: Sendable, Equatable, Codable {
try c.encode(comments, forKey: .comments) try c.encode(comments, forKey: .comments)
try c.encode(events, forKey: .events) try c.encode(events, forKey: .events)
try c.encode(parentResults, forKey: .parentResults) try c.encode(parentResults, forKey: .parentResults)
try c.encodeIfPresent(envelopeDiagnostics, forKey: .envelopeDiagnostics)
}
/// Unified diagnostics view for the inspector. Combines `task.diagnostics`
/// with envelope-level diagnostics (when present) and dedupes on the
/// `(kind, detectedAt)` tuple. Wire-side dupes are unlikely but cheap to
/// filter. Empty for pre-v0.13 hosts.
public var allDiagnostics: [HermesKanbanDiagnostic] {
let onTask = task.diagnostics
let onEnvelope = envelopeDiagnostics ?? []
var seen = Set<String>()
return (onTask + onEnvelope).filter { diag in
let key = "\(diag.kind)|\(diag.detectedAt ?? "")"
return seen.insert(key).inserted
}
} }
} }
@@ -3,6 +3,10 @@ import Foundation
public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable { public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable {
case stdio case stdio
case http case http
/// Server-Sent Events transport. Hermes v0.13+ only.
// TODO(WS-7-Q1): Verify Hermes uses the literal `sse` transport name
// (vs. `streamable-http`/`http-sse`/etc.) once a v0.13 host is on hand.
case sse
public var id: String { rawValue } public var id: String { rawValue }
@@ -11,6 +15,7 @@ public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiabl
switch self { switch self {
case .stdio: return "Local (stdio)" case .stdio: return "Local (stdio)"
case .http: return "Remote (HTTP)" case .http: return "Remote (HTTP)"
case .sse: return "Remote (SSE)"
} }
} }
#endif #endif
@@ -33,6 +38,12 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
public let resourcesEnabled: Bool public let resourcesEnabled: Bool
public let promptsEnabled: Bool public let promptsEnabled: Bool
public let hasOAuthToken: Bool public let hasOAuthToken: Bool
/// Hermes-side keepalive interval (seconds) for SSE transport. `nil`
/// when the YAML doesn't specify `sse_read_timeout` (Hermes default
/// applies). Pre-v0.13 hosts always have this as `nil`.
// TODO(WS-7-Q2): Default is assumed to be 300s per WS-7 plan; placeholder
// copy uses that. Verify against `~/.hermes/hermes-agent/hermes_cli/mcp.py`.
public let sseReadTimeout: Int?
public init( public init(
@@ -51,7 +62,8 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
toolsExclude: [String], toolsExclude: [String],
resourcesEnabled: Bool, resourcesEnabled: Bool,
promptsEnabled: Bool, promptsEnabled: Bool,
hasOAuthToken: Bool hasOAuthToken: Bool,
sseReadTimeout: Int? = nil
) { ) {
self.name = name self.name = name
self.transport = transport self.transport = transport
@@ -69,6 +81,7 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
self.resourcesEnabled = resourcesEnabled self.resourcesEnabled = resourcesEnabled
self.promptsEnabled = promptsEnabled self.promptsEnabled = promptsEnabled
self.hasOAuthToken = hasOAuthToken self.hasOAuthToken = hasOAuthToken
self.sseReadTimeout = sseReadTimeout
} }
public var id: String { name } public var id: String { name }
@@ -79,6 +92,8 @@ public struct HermesMCPServer: Identifiable, Sendable, Equatable {
return (command ?? "") + argString return (command ?? "") + argString
case .http: case .http:
return url ?? "" return url ?? ""
case .sse:
return url ?? ""
} }
} }
} }
@@ -0,0 +1,23 @@
import Foundation
/// One queued prompt the user has staged via `/queue <text>` (Hermes
/// v0.13+ ACP `/queue` slash command). Hermes is the authoritative owner
/// of the actual queue server-side Scarf maintains this mirror so the
/// chat header chip + popover can show "what's pending" without an
/// extra round-trip. The mirror drains best-effort when a turn
/// completes (`RichChatViewModel.popQueuedPrompt`).
///
/// `id` is a Scarf-side UUID minted at queue-time Hermes' wire
/// protocol does not expose a per-queue-entry id, so we never round-trip
/// an entry-level identifier. See WS-2 plan Q5.
public struct HermesQueuedPrompt: Sendable, Equatable, Identifiable {
public let id: UUID
public let text: String
public let queuedAt: Date
public init(id: UUID = UUID(), text: String, queuedAt: Date = Date()) {
self.id = id
self.text = text
self.queuedAt = queuedAt
}
}
@@ -24,6 +24,14 @@ public struct HermesSlashCommand: Identifiable, Sendable, Equatable {
/// "agent working" indicator on; the guidance applies after the /// "agent working" indicator on; the guidance applies after the
/// next tool call. Added in v2.5 alongside Hermes v2026.4.23. /// next tool call. Added in v2.5 alongside Hermes v2026.4.23.
case acpNonInterruptive case acpNonInterruptive
/// ACP-native commands Hermes always supports but only advertises
/// inside an active session via `available_commands_update`.
/// Surfacing a small static fallback pre-session lets the slash
/// menu offer discoverable affordances like `/new` even before
/// the user has opened a session. Once a session starts, the
/// ACP-advertised version takes over (deduped by name in
/// `availableCommands`). Introduced alongside Hermes v0.13.
case alwaysAvailable
} }
public var id: String { name } public var id: String { name }
@@ -60,6 +60,17 @@ public enum KnownPlatforms {
// platform identifiers. // platform identifiers.
HermesToolPlatform(name: "yuanbao", displayName: "Yuanbao 元宝", icon: "bubble.left.and.bubble.right.fill"), HermesToolPlatform(name: "yuanbao", displayName: "Yuanbao 元宝", icon: "bubble.left.and.bubble.right.fill"),
HermesToolPlatform(name: "microsoft-teams", displayName: "Microsoft Teams", icon: "person.2.fill"), HermesToolPlatform(name: "microsoft-teams", displayName: "Microsoft Teams", icon: "person.2.fill"),
// -- v0.13 additions ---------------------------------------------
// Google Chat is the 20th gateway platform. It's a generic
// `env_enablement_fn` / `cron_deliver_env_var`-driven adapter; setup
// runs through `hermes setup` rather than per-field forms because
// the auth dance is OAuth-style and lives outside Scarf. Identifier
// is `google-chat` (kebab-case, mirroring `microsoft-teams`).
// TODO(WS-5-Q1): verify identifier against Hermes v0.13 GA if it
// ships as `googlechat` instead, update both this entry and
// `KnownPlatforms.icon(for:)` below. `GatewayAllowlistKind.kind(for:)`
// already accepts both spellings defensively.
HermesToolPlatform(name: "google-chat", displayName: "Google Chat", icon: "bubble.left.fill"),
] ]
public static func icon(for platform: String) -> String { public static func icon(for platform: String) -> String {
@@ -79,6 +90,7 @@ public enum KnownPlatforms {
case "imessage": return "message.fill" case "imessage": return "message.fill"
case "yuanbao": return "bubble.left.and.bubble.right.fill" case "yuanbao": return "bubble.left.and.bubble.right.fill"
case "microsoft-teams": return "person.2.fill" case "microsoft-teams": return "person.2.fill"
case "google-chat", "googlechat": return "bubble.left.fill"
default: return "bubble.left" default: return "bubble.left"
} }
} }
@@ -17,6 +17,15 @@ public struct KanbanCreateRequest: Sendable, Equatable {
public var maxRuntimeSeconds: Int? public var maxRuntimeSeconds: Int?
public var createdBy: String? public var createdBy: String?
public var skills: [String] public var skills: [String]
/// v0.13: per-task retry budget. `--max-retries N` is write-once at
/// create time no `set_max_retries` verb. Pass `nil` to let Hermes
/// pick its built-in default (3 as of v0.13.0). Capability-gated in
/// the create sheet on `hasKanbanDiagnostics`.
// TODO(WS-3-Q6): Confirm Hermes's global default for `max_retries`
// (v0.13 release notes don't enumerate it). The create sheet defaults
// the field to 3; if Hermes config exposes a different default, mirror
// it.
public var maxRetries: Int?
public init( public init(
title: String, title: String,
@@ -30,7 +39,8 @@ public struct KanbanCreateRequest: Sendable, Equatable {
idempotencyKey: String? = nil, idempotencyKey: String? = nil,
maxRuntimeSeconds: Int? = nil, maxRuntimeSeconds: Int? = nil,
createdBy: String? = nil, createdBy: String? = nil,
skills: [String] = [] skills: [String] = [],
maxRetries: Int? = nil
) { ) {
self.title = title self.title = title
self.body = body self.body = body
@@ -44,6 +54,7 @@ public struct KanbanCreateRequest: Sendable, Equatable {
self.maxRuntimeSeconds = maxRuntimeSeconds self.maxRuntimeSeconds = maxRuntimeSeconds
self.createdBy = createdBy self.createdBy = createdBy
self.skills = skills self.skills = skills
self.maxRetries = maxRetries
} }
/// Build the argv suffix this request maps to (everything after /// Build the argv suffix this request maps to (everything after
@@ -78,6 +89,9 @@ public struct KanbanCreateRequest: Sendable, Equatable {
if let maxRuntimeSeconds { if let maxRuntimeSeconds {
args.append(contentsOf: ["--max-runtime", "\(maxRuntimeSeconds)s"]) args.append(contentsOf: ["--max-runtime", "\(maxRuntimeSeconds)s"])
} }
if let maxRetries {
args.append(contentsOf: ["--max-retries", String(maxRetries)])
}
if let createdBy, !createdBy.isEmpty { if let createdBy, !createdBy.isEmpty {
args.append(contentsOf: ["--created-by", createdBy]) args.append(contentsOf: ["--created-by", createdBy])
} }
@@ -225,6 +225,58 @@ public extension HermesConfig {
cooldownSeconds: int("platforms.homeassistant.extra.cooldown_seconds", default: 30) cooldownSeconds: int("platforms.homeassistant.extra.cooldown_seconds", default: 30)
) )
// -- v0.13: per-platform Messaging Gateway settings --------------
// Read `gateway.platforms.<platform>.{allowed_channels|allowed_chats|
// allowed_rooms|busy_ack_enabled|gateway_restart_notification|
// slash_command_notice_ttl_seconds}` and bundle each platform that
// has at least one v0.13 key present in the file. Platforms without
// an explicit block don't appear in the dictionary, so the
// editor's `?? .empty` fallback hands the user the v0.13 defaults
// without leaving stale keys littered across the YAML.
//
// TODO(WS-5-Q2): the `gateway.platforms.*` path is unverified
// Hermes v0.13 may emit allowlists under `platforms.<platform>.*`
// (sibling to existing `platforms.slack.reply_to_mode`) instead.
// If so, swap the `prefix` line below to `"platforms.\(platform)."`
// and update `GatewayConfigWriter` in lockstep.
let gatewayAllowlistPlatforms = [
"slack", "mattermost", "google-chat",
"telegram", "whatsapp",
"matrix", "dingtalk",
]
var gatewayPlatforms: [String: GatewayPlatformSettings] = [:]
for platform in gatewayAllowlistPlatforms {
let prefix = "gateway.platforms.\(platform)."
let allowedChannels = lists[prefix + "allowed_channels"] ?? []
let allowedChats = lists[prefix + "allowed_chats"] ?? []
let allowedRooms = lists[prefix + "allowed_rooms"] ?? []
let busy = bool(prefix + "busy_ack_enabled", default: true)
let restartNotice = bool(prefix + "gateway_restart_notification",
default: false)
let ttl = int(prefix + "slash_command_notice_ttl_seconds",
default: 0)
// Skip platforms with no v0.13 fields present anywhere in the
// file. Without this guard, every supported platform would
// round-trip an all-default block back through writes even
// when the user never touched the new surface.
let isEmpty = allowedChannels.isEmpty
&& allowedChats.isEmpty
&& allowedRooms.isEmpty
&& values[prefix + "busy_ack_enabled"] == nil
&& values[prefix + "gateway_restart_notification"] == nil
&& values[prefix + "slash_command_notice_ttl_seconds"] == nil
if !isEmpty {
gatewayPlatforms[platform] = GatewayPlatformSettings(
allowedChannels: allowedChannels,
allowedChats: allowedChats,
allowedRooms: allowedRooms,
busyAckEnabled: busy,
gatewayRestartNotification: restartNotice,
slashCommandNoticeTTLSeconds: ttl
)
}
}
self.init( self.init(
model: str("model.default", default: "unknown"), model: str("model.default", default: "unknown"),
provider: str("model.provider", default: "unknown"), provider: str("model.provider", default: "unknown"),
@@ -285,6 +337,7 @@ public extension HermesConfig {
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"), cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
redactionEnabled: bool("redaction.enabled", default: false), redactionEnabled: bool("redaction.enabled", default: false),
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false), runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false),
gatewayPlatforms: gatewayPlatforms,
// -- v0.13 additions ------------------------------------- // -- v0.13 additions -------------------------------------
// TODO(WS-6-Q1): the `openrouter.response_cache.enabled` // TODO(WS-6-Q1): the `openrouter.response_cache.enabled`
// key shape is provisional pending verification against a // key shape is provisional pending verification against a
@@ -295,7 +348,14 @@ public extension HermesConfig {
// `SettingsViewModel.setOpenRouterResponseCache`. Default // `SettingsViewModel.setOpenRouterResponseCache`. Default
// is `false` per WS-6-plan §Open Questions #2. // is `false` per WS-6-plan §Open Questions #2.
imageGenModel: str("image_gen.model", default: ""), imageGenModel: str("image_gen.model", default: ""),
openrouterResponseCacheEnabled: bool("openrouter.response_cache.enabled", default: false) openrouterResponseCacheEnabled: bool("openrouter.response_cache.enabled", default: false),
// Pre-v0.13 hosts wrote a single `web_tools.backend`. v0.13 split
// it into per-capability keys. Read all three so the round-trip
// never loses a value the user already set; the WebTools tab
// chooses which to render based on `hasWebToolsBackendSplit`.
webToolsBackend: str("web_tools.backend", default: "duckduckgo"),
webToolsSearchBackend: str("web_tools.search.backend", default: "duckduckgo"),
webToolsExtractBackend: str("web_tools.extract.backend", default: "reader")
) )
} }
} }
@@ -0,0 +1,358 @@
import Foundation
#if canImport(os)
import os
#endif
/// Async, transport-aware client for `hermes curator `. Wraps the v0.12
/// verbs (`status / run / pause / resume / pin / unpin / restore`) plus
/// the v0.13 archive surface (`archive / prune / list-archived` and a
/// synchronous-blocking `run`).
///
/// **Concurrency.** Pure-I/O `actor` no UI state. View models hold a
/// service reference and `await` methods. Each public method dispatches
/// the underlying CLI invocation through `Task.detached(priority:
/// .utility)` so two concurrent reads from the VM don't queue end-to-end
/// on a single thread. Mirrors `KanbanService` shape exactly.
///
/// **Capability gating happens at the call site, not in the service.**
/// `runNow(synchronous:timeout:)` takes a flag from the VM (the VM reads
/// `HermesCapabilities.hasCuratorArchive` to decide). The service stays
/// version-agnostic only the timeout differs in practice.
public actor CuratorService {
#if canImport(os)
private static let logger = Logger(subsystem: "com.scarf", category: "CuratorService")
#endif
private let context: ServerContext
public init(context: ServerContext) {
self.context = context
}
// MARK: - Reads
/// Run `hermes curator status` and parse stdout via
/// `HermesCuratorStatusParser`. Combines the text output with the
/// on-disk `.curator_state` JSON for richer last-run metadata.
/// Never throws a transport failure resolves to `.empty` so the
/// view always has something to render.
public func status() async -> HermesCuratorStatus {
let context = self.context
return await Task.detached(priority: .utility) { () -> HermesCuratorStatus in
let textResult = Self.runHermesSync(context: context, args: ["curator", "status"], timeout: 30)
let stateData = context.readData(context.paths.curatorStateFile)
return HermesCuratorStatusParser.parse(text: textResult.output, stateFileJSON: stateData)
}.value
}
/// `hermes curator list-archived [--json]`. Prefers JSON; falls back
/// to a defensive text parser. Empty / "no archived skills" sentinel
/// folds to `[]`.
public func listArchived() async throws -> [HermesCuratorArchivedSkill] {
// TODO(WS-4-Q2): confirm `--json` is supported on v0.13
// `list-archived`. If not, drop the flag and rely on the text
// parser path. Until then we pass `--json` and parse the output
// tolerantly.
let args = ["curator", "list-archived", "--json"]
let (code, stdout, stderr) = await runHermes(args: args, timeout: 30)
// If --json isn't recognized, the CLI typically emits
// "unrecognized arguments: --json" or similar to stderr and
// exits non-zero. Retry without the flag and parse text.
if code != 0 {
let lower = (stderr + stdout).lowercased()
if lower.contains("unrecognized") || lower.contains("unknown") || lower.contains("no such option") {
let (c2, out2, err2) = await runHermes(args: ["curator", "list-archived"], timeout: 30)
try ensureSuccess(code: c2, stdout: out2, stderr: err2, verb: "list-archived")
return Self.parseListArchivedText(out2)
}
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "list-archived")
}
let trimmed = stdout.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty || trimmed.lowercased().contains("no archived skills") {
return []
}
// Try JSON first may also be a text dump if Hermes ignored `--json`.
if let data = trimmed.data(using: .utf8),
let arr = try? JSONDecoder().decode([HermesCuratorArchivedSkill].self, from: data) {
return arr
}
// Some builds wrap in `{"archived": [...]}` envelope.
struct Wrapper: Decodable { let archived: [HermesCuratorArchivedSkill] }
if let data = trimmed.data(using: .utf8),
let wrapped = try? JSONDecoder().decode(Wrapper.self, from: data) {
return wrapped.archived
}
// Text fallback defensive parse.
return Self.parseListArchivedText(stdout)
}
// MARK: - Writes (legacy v0.12 verbs; service form)
public func runNow(synchronous: Bool, timeout: TimeInterval) async throws {
// TODO(WS-4-Q4): default 600s for v0.13 sync runs. No Cancel
// button in v2.8 (transport.cancel parity not guaranteed across
// LocalTransport / SSHTransport).
let resolvedTimeout = synchronous ? timeout : 30
let (code, stdout, stderr) = await runHermes(args: ["curator", "run"], timeout: resolvedTimeout)
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "run")
}
public func pause() async throws {
let (code, stdout, stderr) = await runHermes(args: ["curator", "pause"], timeout: 15)
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "pause")
}
public func resume() async throws {
let (code, stdout, stderr) = await runHermes(args: ["curator", "resume"], timeout: 15)
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "resume")
}
public func pin(_ name: String) async throws {
let (code, stdout, stderr) = await runHermes(args: ["curator", "pin", name], timeout: 15)
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "pin")
}
public func unpin(_ name: String) async throws {
let (code, stdout, stderr) = await runHermes(args: ["curator", "unpin", name], timeout: 15)
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "unpin")
}
public func restore(_ name: String) async throws {
let (code, stdout, stderr) = await runHermes(args: ["curator", "restore", name], timeout: 30)
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "restore")
}
// MARK: - Writes (new in v0.13)
/// `hermes curator archive <name>` non-destructive; moves the
/// skill from the active set to the archived set. No `--json` is
/// expected; the verb's success channel is the exit code.
public func archive(_ name: String) async throws {
let (code, stdout, stderr) = await runHermes(args: ["curator", "archive", name], timeout: 30)
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "archive")
}
/// `hermes curator prune [--dry-run]`. Destructive when `dryRun`
/// is `false` removes everything currently archived from disk.
/// Returns a `CuratorPruneSummary` describing what was (or would be)
/// removed. On `dryRun=false`, the wire shape may not include the
/// `would_remove` list the caller should not depend on it; the
/// archived list is empty after a successful destructive prune.
@discardableResult
public func prune(dryRun: Bool) async throws -> CuratorPruneSummary {
// TODO(WS-4-Q1): confirm v0.13 ships `--dry-run`. If not, fall
// back to enumerating via `list-archived` and treat any prune
// call as destructive. The retry-without-flag path below covers
// the "unrecognized argument" case automatically.
var args = ["curator", "prune"]
if dryRun { args.append("--dry-run") }
// `--json` requested for the dry-run path so we can parse the
// would-remove list. Destructive mode runs without --json since
// we only need the exit code.
if dryRun { args.append("--json") }
let (code, stdout, stderr) = await runHermes(args: args, timeout: 60)
// Detect "unrecognized --dry-run" / "unknown --json" gracefully.
if code != 0 {
let lower = (stderr + stdout).lowercased()
let unrecognized = lower.contains("unrecognized") || lower.contains("unknown") || lower.contains("no such option")
if dryRun && unrecognized {
// Q1 fallback: enumerate via list-archived. Caller still
// uses this summary for confirm-sheet display.
let archived = try await listArchived()
let total = archived.compactMap { $0.sizeBytes }.reduce(0, +)
return CuratorPruneSummary(wouldRemove: archived, totalBytes: total)
}
try ensureSuccess(code: code, stdout: stdout, stderr: stderr, verb: "prune")
}
if dryRun {
return Self.parsePruneDryRun(stdout)
}
return CuratorPruneSummary(wouldRemove: [], totalBytes: 0)
}
// MARK: - Pure parsers (nonisolated; safe to call from VMs without awaits)
/// Parse a `list-archived --json` payload. Tolerates the bare-array
/// shape, the `{"archived": [...]}` envelope, and "no archived
/// skills" / empty-string sentinels. Returns `[]` for any of the
/// empty cases. Throws `CuratorError.decoding` only when the input
/// is non-empty and clearly not JSON.
public nonisolated static func parseListArchived(stdout: String) throws -> [HermesCuratorArchivedSkill] {
let trimmed = stdout.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty || trimmed.lowercased().contains("no archived skills") {
return []
}
guard let data = trimmed.data(using: .utf8) else {
throw CuratorError.decoding(verb: "list-archived", message: "non-UTF8 stdout")
}
if let arr = try? JSONDecoder().decode([HermesCuratorArchivedSkill].self, from: data) {
return arr
}
struct Wrapper: Decodable { let archived: [HermesCuratorArchivedSkill] }
if let wrapped = try? JSONDecoder().decode(Wrapper.self, from: data) {
return wrapped.archived
}
// Last resort: text fallback.
let parsed = parseListArchivedText(stdout)
if !parsed.isEmpty {
return parsed
}
throw CuratorError.decoding(verb: "list-archived", message: "stdout was neither JSON nor a recognised text list")
}
/// Defensive text parser for `list-archived` output when `--json`
/// isn't supported. Format inferred from `curator status`: one row
/// per non-blank line, leading whitespace, name in column 1, then
/// optional `archived=YYYY-MM-DD`, `size=NNNN`, `reason=...` k/v
/// pairs. Blank lines, header lines, and the empty-state sentinel
/// are skipped.
public nonisolated static func parseListArchivedText(_ text: String) -> [HermesCuratorArchivedSkill] {
var rows: [HermesCuratorArchivedSkill] = []
for raw in text.split(separator: "\n") {
let line = raw.trimmingCharacters(in: .whitespaces)
if line.isEmpty { continue }
let lower = line.lowercased()
// Skip header / sentinel lines.
if lower.hasPrefix("name") && lower.contains("archived") { continue }
if lower.contains("no archived skills") { continue }
if line.unicodeScalars.allSatisfy({ $0.value == 0x2500 || $0.properties.isWhitespace }) {
continue
}
// Skip lines that look like JSON / non-row chrome `{`,
// `}`, `[`, `]` at the start or quotes / colons mean we're
// parsing a malformed JSON dump, not a row table.
if let first = line.first, "{[}]\":,".contains(first) {
continue
}
// Find the first whitespace-separated token as the name; if
// the name carries an `=` it's a header chip we should skip.
let parts = line.split(whereSeparator: { $0 == "\t" || $0 == " " }).map(String.init)
guard let name = parts.first, !name.contains("=") else { continue }
// Reject names that look like punctuation / JSON fragments.
if name.contains("\"") || name.contains(":") || name.contains("{") || name.contains("}") || name.contains("[") || name.contains("]") {
continue
}
// Pull k=v pairs from the remainder.
var archivedAt: String?
var sizeBytes: Int?
var reason: String?
var category: String?
var path: String?
for token in parts.dropFirst() {
guard let eq = token.firstIndex(of: "=") else { continue }
let key = String(token[..<eq])
let value = String(token[token.index(after: eq)...])
switch key {
case "archived", "archived_at":
archivedAt = value
case "size", "size_bytes":
sizeBytes = Int(value)
case "reason":
reason = value
case "category":
category = value
case "path":
path = value
default:
continue
}
}
rows.append(
HermesCuratorArchivedSkill(
name: name,
category: category,
archivedAt: archivedAt,
reason: reason,
sizeBytes: sizeBytes,
path: path
)
)
}
return rows
}
/// Parse a `prune --dry-run --json` payload. Tolerates an empty
/// payload (returns a zero summary) and the `{would_remove: [],
/// total_bytes: N}` shape.
public nonisolated static func parsePruneDryRun(_ stdout: String) -> CuratorPruneSummary {
let trimmed = stdout.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else {
return CuratorPruneSummary(wouldRemove: [], totalBytes: 0)
}
if let data = trimmed.data(using: .utf8),
let summary = try? JSONDecoder().decode(CuratorPruneSummary.self, from: data) {
return summary
}
// Tolerate a bare-array fallback (some Hermes builds may print
// just the would-remove list when --json is missing the wrapper).
if let data = trimmed.data(using: .utf8),
let arr = try? JSONDecoder().decode([HermesCuratorArchivedSkill].self, from: data) {
let total = arr.compactMap { $0.sizeBytes }.reduce(0, +)
return CuratorPruneSummary(wouldRemove: arr, totalBytes: total)
}
// Last-resort text parse for "would remove N skills (X bytes)".
return CuratorPruneSummary(wouldRemove: [], totalBytes: 0)
}
// MARK: - CLI invocation
private nonisolated func runHermes(
args: [String],
timeout: TimeInterval
) async -> (exitCode: Int32, stdout: String, stderr: String) {
let context = self.context
return await Task.detached(priority: .utility) { () -> (Int32, String, String) in
let result = Self.runHermesSync(context: context, args: args, timeout: timeout)
return (result.exitCode, result.output, result.stderr)
}.value
}
/// Synchronous, transport-level invocation. `output` is stdout; the
/// caller usually only reads `output` for parser input but sometimes
/// needs `stderr` (e.g. to detect "unrecognized argument" patterns).
private nonisolated static func runHermesSync(
context: ServerContext,
args: [String],
timeout: TimeInterval
) -> (exitCode: Int32, output: String, stderr: String) {
let transport = context.makeTransport()
do {
let result = try transport.runProcess(
executable: context.paths.hermesBinary,
args: args,
stdin: nil,
timeout: timeout
)
return (result.exitCode, result.stdoutString, result.stderrString)
} catch let error as TransportError {
let message = error.diagnosticStderr.isEmpty
? (error.errorDescription ?? "transport error")
: error.diagnosticStderr
return (-1, "", message)
} catch {
return (-1, "", error.localizedDescription)
}
}
private nonisolated func ensureSuccess(
code: Int32,
stdout: String,
stderr: String,
verb: String
) throws {
guard code != 0 else { return }
if code == -1 && stderr.lowercased().contains("hermes binary not found") {
throw CuratorError.cliMissing
}
let combined = stderr.isEmpty ? stdout : stderr
#if canImport(os)
Self.logger.warning("curator \(verb) exit=\(code, privacy: .public) stderr=\(combined, privacy: .public)")
#endif
throw CuratorError.nonZeroExit(verb: verb, code: code, stderr: combined)
}
}
@@ -0,0 +1,396 @@
import Foundation
/// Direct YAML editor for `gateway.platforms.<platform>.allowed_<kind>:` list
/// blocks. Hermes v0.13 added these list-valued keys, but `hermes config set`
/// stringifies arrays (the same gotcha that forced Home Assistant's watch
/// lists to stay read-only). The Messaging Gateway editor sidesteps the CLI
/// for these keys by editing `~/.hermes/config.yaml` directly.
///
/// **Pure-function `setList`** is the heart of the editor it splits the
/// YAML into lines, finds (or creates) the targeted block, and splices the
/// new items in while preserving every byte outside the block. The async
/// `saveList` wrapper wires it through `ServerContext.readText` /
/// `writeText`, so the same code path works on `.local` and `.ssh` servers
/// local goes through `LocalTransport`, remote round-trips via SCP.
///
/// **Scalar fields don't go through here.** `busy_ack_enabled`,
/// `gateway_restart_notification`, and `slash_command_notice_ttl_seconds`
/// are scalars that `hermes config set` handles cleanly `GatewayBehaviorViewModel`
/// routes those through `PlatformSetupHelpers.saveForm` like every other
/// platform toggle.
///
/// **Why not use a real YAML library?** Same answer as everywhere else in
/// Scarf: zero external dependencies. The Hermes config flavor is a tightly
/// scoped subset (indent-based blocks, scalar-or-list values, no anchors /
/// aliases / flow style), and the targeted edit doesn't need to understand
/// the full grammar only "find this block, replace it, preserve the rest".
public enum GatewayConfigWriter {
/// Insert or replace `gateway.platforms.<platform>.<key>:` block in the
/// YAML, preserving everything else byte-for-byte.
///
/// - When `items` is empty, the block (and only the block siblings
/// stay) is removed from the YAML if present, and the function is a
/// no-op if the block was already absent.
/// - When the block is absent and `items` is non-empty, the function
/// appends a `gateway:` / `platforms:` / `<platform>:` scaffold at
/// the end of the file, creating any missing ancestors. This keeps
/// the function idempotent on round-trip but means the new block is
/// appended rather than spliced into an existing top-level
/// `gateway:` section. (See WS-5 plan §Notes for the trade-off; the
/// alternative would mean reflowing existing siblings, which is the
/// exact opposite of "preserve the surrounding YAML byte-for-byte".)
/// - When the block is present, its bullet rows are replaced with the
/// new items at the same indent. Items containing YAML-special
/// characters (`:` `#` `@` or leading whitespace) are single-quoted
/// defensively.
public static func setList(
in yaml: String,
platform: String,
key: String,
items: [String]
) -> String {
let blockIndent = 6 // `gateway:\n platforms:\n <platform>:\n <key>:`
let itemIndent = 8
let lines = yaml.components(separatedBy: "\n")
let blockHeaderText = " \(key):" // indented match for find()
let trimmedItems = items.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty }
// Locate ` <key>:` whose lineage is gateway platforms <platform>.
// We find the start of the gateway block, walk down the indent tree, and
// bail out if any ancestor is missing.
let location = locateBlock(
in: lines,
platform: platform,
key: key
)
switch location {
case .found(let blockRange):
return replaceBlock(
in: lines,
blockRange: blockRange,
key: key,
items: trimmedItems,
blockIndent: blockIndent,
itemIndent: itemIndent
)
case .platformPresentKeyMissing(let insertAfter):
if trimmedItems.isEmpty {
// No-op: empty target, no existing block.
return yaml
}
return spliceNewKey(
lines: lines,
insertAfterLineIndex: insertAfter,
key: key,
items: trimmedItems,
itemIndent: itemIndent
)
case .ancestorMissing:
if trimmedItems.isEmpty {
// Nothing to write, no existing block.
return yaml
}
return appendScaffold(
yaml: yaml,
platform: platform,
key: key,
items: trimmedItems
)
}
// (unreachable switch is exhaustive)
_ = blockHeaderText
}
/// Async wrapper that reads, mutates, writes via the given context.
/// Returns `false` on read or write failure.
///
/// The actual I/O happens via `ServerContext.readText` / `writeText`,
/// which are `nonisolated` safe to call from `MainActor` for the
/// short config.yaml writes the platform setup forms run. For remote
/// hosts the call rounds through SCP under `Task.detached` upstream
/// (per Swift 6 concurrency rules in `~/.claude/CLAUDE.md`).
public static func saveList(
context: ServerContext,
platform: String,
key: String,
items: [String]
) -> Bool {
let path = context.paths.configYAML
let existing = context.readText(path) ?? ""
let updated = setList(in: existing, platform: platform, key: key, items: items)
if updated == existing { return true } // no-op: already correct
return context.writeText(path, content: updated)
}
// MARK: - Internals
/// Result of locating the targeted block in the YAML line array.
private enum BlockLocation {
/// Block found; the closed range covers the header line + all bullet
/// rows attributed to it. Replacing this slice with the new block
/// completes the edit.
case found(ClosedRange<Int>)
/// `gateway platforms <platform>` exists, but the leaf `<key>:`
/// is absent under it. The associated value is the line index after
/// which the new key should be inserted (last line in the platform's
/// block, or the platform header itself if the platform's body is
/// empty).
case platformPresentKeyMissing(insertAfter: Int)
/// One of the ancestor section headers is missing. The whole
/// scaffold needs to be appended.
case ancestorMissing
}
private static func locateBlock(
in lines: [String],
platform: String,
key: String
) -> BlockLocation {
// Walk top-to-bottom looking for `gateway:` at indent 0.
guard let gatewayIdx = firstIndex(of: lines, headerLineEqualTo: "gateway:", indent: 0) else {
return .ancestorMissing
}
// Inside `gateway:`, find ` platforms:` at indent 2.
guard let platformsIdx = firstIndex(
of: lines,
after: gatewayIdx,
headerLineEqualTo: "platforms:",
indent: 2,
stopWhenIndentLessThan: 2
) else {
return .ancestorMissing
}
// Inside `platforms:`, find ` <platform>:` at indent 4.
guard let platformIdx = firstIndex(
of: lines,
after: platformsIdx,
headerLineEqualTo: "\(platform):",
indent: 4,
stopWhenIndentLessThan: 4
) else {
return .ancestorMissing
}
// Inside the platform block, find `<key>:` at indent 6, OR the end
// of the platform's body if the key is missing.
var keyIdx: Int?
var lastBodyIdx = platformIdx
var i = platformIdx + 1
while i < lines.count {
let line = lines[i]
let indent = leadingSpaces(line)
let trimmed = line.trimmingCharacters(in: .whitespaces)
if trimmed.isEmpty || trimmed.hasPrefix("#") {
i += 1
continue
}
if indent < 6 {
// Out of the platform's block.
break
}
if indent == 6 && trimmed == "\(key):" {
keyIdx = i
break
}
lastBodyIdx = i
i += 1
}
guard let keyIdx else {
return .platformPresentKeyMissing(insertAfter: lastBodyIdx)
}
// Walk down the bullet rows until we leave the block (indent shrinks
// below the bullet indent OR we hit a sibling key at indent 6).
var endIdx = keyIdx
var j = keyIdx + 1
while j < lines.count {
let line = lines[j]
let trimmed = line.trimmingCharacters(in: .whitespaces)
if trimmed.isEmpty || trimmed.hasPrefix("#") {
j += 1
continue
}
let indent = leadingSpaces(line)
// Block-style YAML allows bullets at the same indent as their
// parent key; tolerate 6-space `- item` rows alongside the
// canonical 8-space ones.
let isBullet = trimmed.hasPrefix("- ")
if isBullet && (indent == 8 || indent == 6) {
endIdx = j
j += 1
continue
}
// Anything not a bullet at indent 8 ends the block.
if indent <= 6 {
break
}
// Indent > 8 with no bullet unusual but tolerate (e.g. inline
// continuation). Treat as still in the block and advance.
endIdx = j
j += 1
}
return .found(keyIdx...endIdx)
}
private static func replaceBlock(
in lines: [String],
blockRange: ClosedRange<Int>,
key: String,
items: [String],
blockIndent: Int,
itemIndent: Int
) -> String {
var newLines = Array(lines.prefix(blockRange.lowerBound))
if !items.isEmpty {
newLines.append("\(spaces(blockIndent))\(key):")
for item in items {
newLines.append("\(spaces(itemIndent))- \(yamlQuoteIfNeeded(item))")
}
}
// Drop the old block but keep everything after it.
let tailStart = blockRange.upperBound + 1
if tailStart < lines.count {
newLines.append(contentsOf: lines.suffix(from: tailStart))
}
return newLines.joined(separator: "\n")
}
private static func spliceNewKey(
lines: [String],
insertAfterLineIndex: Int,
key: String,
items: [String],
itemIndent: Int
) -> String {
var newLines = Array(lines.prefix(insertAfterLineIndex + 1))
newLines.append(" \(key):")
for item in items {
newLines.append("\(spaces(itemIndent))- \(yamlQuoteIfNeeded(item))")
}
if insertAfterLineIndex + 1 < lines.count {
newLines.append(contentsOf: lines.suffix(from: insertAfterLineIndex + 1))
}
return newLines.joined(separator: "\n")
}
private static func appendScaffold(
yaml: String,
platform: String,
key: String,
items: [String]
) -> String {
var trimmed = yaml
// Ensure exactly one trailing newline before the appended block,
// so the scaffold sits on its own line cleanly.
while trimmed.hasSuffix("\n\n") {
trimmed.removeLast()
}
if !trimmed.isEmpty && !trimmed.hasSuffix("\n") {
trimmed.append("\n")
}
var lines: [String] = []
if !trimmed.isEmpty {
lines.append("") // blank separator
}
lines.append("gateway:")
lines.append(" platforms:")
lines.append(" \(platform):")
lines.append(" \(key):")
for item in items {
lines.append(" - \(yamlQuoteIfNeeded(item))")
}
lines.append("") // trailing newline so subsequent edits append cleanly
return trimmed + lines.joined(separator: "\n")
}
// MARK: - YAML scanning helpers
private static func leadingSpaces(_ line: String) -> Int {
var n = 0
for c in line {
if c == " " { n += 1 } else { break }
}
return n
}
/// Find the first line whose trimmed content equals `header` AND whose
/// leading-space count equals `indent`. Comment-only and blank lines
/// are skipped. Returns the line's index or `nil`.
private static func firstIndex(
of lines: [String],
headerLineEqualTo header: String,
indent: Int
) -> Int? {
for (i, line) in lines.enumerated() {
let trimmed = line.trimmingCharacters(in: .whitespaces)
if trimmed.isEmpty || trimmed.hasPrefix("#") { continue }
if leadingSpaces(line) == indent && trimmed == header {
return i
}
}
return nil
}
/// Scoped variant: search starts at `after + 1`, stops if a line at indent
/// `< stopWhenIndentLessThan` is encountered (we've left the parent block).
private static func firstIndex(
of lines: [String],
after: Int,
headerLineEqualTo header: String,
indent: Int,
stopWhenIndentLessThan: Int
) -> Int? {
var i = after + 1
while i < lines.count {
let line = lines[i]
let trimmed = line.trimmingCharacters(in: .whitespaces)
if trimmed.isEmpty || trimmed.hasPrefix("#") {
i += 1
continue
}
let lineIndent = leadingSpaces(line)
if lineIndent < stopWhenIndentLessThan {
return nil
}
if lineIndent == indent && trimmed == header {
return i
}
i += 1
}
return nil
}
private static func spaces(_ n: Int) -> String {
String(repeating: " ", count: n)
}
/// Quote a YAML scalar if it contains characters that the parser would
/// otherwise interpret as structure (colon, hash, leading at-sign, etc.).
/// Plain alphanumeric IDs (the common case for Slack channel IDs and
/// Telegram numeric chat IDs) are emitted unquoted.
private static func yamlQuoteIfNeeded(_ raw: String) -> String {
if raw.isEmpty { return "''" }
let needsQuoting = raw.contains(":")
|| raw.contains("#")
|| raw.contains("&")
|| raw.contains("*")
|| raw.contains(">")
|| raw.contains("|")
|| raw.first == "@"
|| raw.first == "-"
|| raw.first == " "
|| raw.last == " "
|| raw.first == "\""
|| raw.first == "'"
if !needsQuoting { return raw }
// Single-quote, escaping any embedded single quotes by doubling.
let escaped = raw.replacingOccurrences(of: "'", with: "''")
return "'\(escaped)'"
}
}
@@ -0,0 +1,151 @@
import Foundation
/// Cross-profile snapshot returned by `hermes gateway list --json` (Hermes
/// v0.13+). Each profile is one configured Messaging Gateway instance most
/// users have a single `default` profile, but power users keep separate
/// profiles for work / personal / project-specific accounts.
public struct GatewayListSnapshot: Sendable, Equatable {
public struct ProfileEntry: Sendable, Equatable {
public let profile: String
public let isRunning: Bool
public let pid: Int?
public let platforms: [String] // platform names connected/configured
public init(
profile: String,
isRunning: Bool,
pid: Int?,
platforms: [String]
) {
self.profile = profile
self.isRunning = isRunning
self.pid = pid
self.platforms = platforms
}
}
public let profiles: [ProfileEntry]
public let detectedAt: Date
public init(profiles: [ProfileEntry], detectedAt: Date = Date()) {
self.profiles = profiles
self.detectedAt = detectedAt
}
/// One-line digest for the Messaging Gateway page header. Format depends
/// on shape:
/// - 0 profiles: `"no profiles configured"`
/// - 1 profile, running: `"default profile · running · slack, telegram"`
/// - 1 profile, stopped: `"default profile · stopped"`
/// - >1 profile: `"3 profiles (2 running) · default: slack, telegram"`
public var headerDigest: String {
if profiles.isEmpty { return "no profiles configured" }
if profiles.count == 1 {
let p = profiles[0]
let state = p.isRunning ? "running" : "stopped"
if p.isRunning && !p.platforms.isEmpty {
let plats = p.platforms.joined(separator: ", ")
return "\(p.profile) profile · \(state) · \(plats)"
}
return "\(p.profile) profile · \(state)"
}
let runningCount = profiles.filter(\.isRunning).count
// Surface the platforms of the first running profile (or first profile
// if none are running) so the digest carries one specimen of context
// beyond just counts.
let highlight = profiles.first(where: \.isRunning) ?? profiles[0]
let platsClause: String
if highlight.platforms.isEmpty {
platsClause = ""
} else {
platsClause = " · \(highlight.profile): \(highlight.platforms.joined(separator: ", "))"
}
return "\(profiles.count) profiles (\(runningCount) running)\(platsClause)"
}
}
/// Pure parser + sync fetcher for `hermes gateway list --json`. Pre-v0.13
/// hosts exit non-zero on the unknown subcommand; the fetcher returns `nil`
/// in that case so the digest row hides itself.
///
/// The detection is **synchronous** run from a `Task.detached` to avoid
/// blocking MainActor on remote SSH round-trips. The pure `parse(_:)`
/// helper has no I/O and can be used in tests against canned JSON.
public enum HermesGatewayListService {
/// Parse a JSON blob from `hermes gateway list --json` into a snapshot.
/// Tolerant of unknown keys; returns `nil` for unparseable / empty input.
///
/// // TODO(WS-5-Q3): the JSON shape below is the plan's best-guess.
/// Confirm against actual Hermes v0.13 output once available. Possible
/// alternative shapes:
/// - root array of profile objects (no `profiles` wrapper)
/// - `state` enum string instead of `running` bool
/// - `connected_platforms` instead of `platforms`
/// The parser is intentionally tolerant so a small shape change can be
/// absorbed by tweaking field names without breaking older fixtures.
public static func parse(_ json: Data) -> GatewayListSnapshot? {
guard !json.isEmpty,
let raw = try? JSONSerialization.jsonObject(with: json) else {
return nil
}
// Accept both `{"profiles": [...]}` and a bare `[...]` of profiles.
let profilesArray: [Any]
if let dict = raw as? [String: Any], let arr = dict["profiles"] as? [Any] {
profilesArray = arr
} else if let arr = raw as? [Any] {
profilesArray = arr
} else {
return nil
}
var entries: [GatewayListSnapshot.ProfileEntry] = []
for raw in profilesArray {
guard let obj = raw as? [String: Any] else { continue }
let profile = (obj["name"] as? String)
?? (obj["profile"] as? String)
?? "default"
let isRunning: Bool
if let v = obj["running"] as? Bool {
isRunning = v
} else if let s = obj["state"] as? String {
isRunning = s.lowercased() == "running"
} else {
isRunning = false
}
let pid = obj["pid"] as? Int
let platforms = (obj["platforms"] as? [String])
?? (obj["connected_platforms"] as? [String])
?? []
entries.append(GatewayListSnapshot.ProfileEntry(
profile: profile,
isRunning: isRunning,
pid: pid,
platforms: platforms
))
}
return GatewayListSnapshot(profiles: entries)
}
/// Synchronous fetch helper call from a `Task.detached`. Returns
/// `nil` when the subcommand fails (pre-v0.13 host) or when the
/// output isn't parseable.
public static func fetch(context: ServerContext) -> GatewayListSnapshot? {
let transport = context.makeTransport()
let executable = context.paths.hermesBinary
do {
let result = try transport.runProcess(
executable: executable,
args: ["gateway", "list", "--json"],
stdin: nil,
timeout: 10
)
guard result.exitCode == 0 else { return nil }
return parse(result.stdout)
} catch {
return nil
}
}
}
@@ -0,0 +1,34 @@
import Foundation
/// Pure helpers that build argv arrays for `hermes update` invocations.
///
/// Lives in ScarfCore so the eventual UI surface (Mac / iOS / remote)
/// shares flag selection. There is no in-app "Update Hermes" affordance
/// in v2.7.5 Sparkle handles Scarf-self-update and `hermes update` is
/// invoked by users in their terminal but capability-gated flag logic
/// is forward-compat plumbing that the future affordance will call. Each
/// helper is a `nonisolated static` pure function: no transport, no
/// MainActor, no mocking surface required.
public enum HermesUpdaterCommandBuilder {
/// Argv for an `hermes update` invocation, capability-gated.
///
/// Pre-v0.12 hosts only had `update` (no flags). v0.12+ accepts
/// `--check` for preflight. v0.13+ accepts `--yes` / `-y` for
/// unattended runs (skips the interactive confirmation prompt).
/// Flags are silently dropped when the connected host can't honor
/// them so callers don't need to branch on capabilities themselves.
public static func updateArgv(
capabilities: HermesCapabilities,
unattended: Bool,
checkOnly: Bool
) -> [String] {
var args: [String] = ["update"]
if checkOnly && capabilities.hasUpdateCheck {
args.append("--check")
}
if unattended && capabilities.hasUpdateNonInteractive {
args.append("--yes")
}
return args
}
}
@@ -321,6 +321,61 @@ public actor KanbanService {
try ensureSuccess(code: code, stdout: "", stderr: stderr, verb: "unlink") try ensureSuccess(code: code, stdout: "", stderr: stderr, verb: "unlink")
} }
// MARK: - Hallucination gate (v0.13)
/// Mark a worker-created card as user-verified flips
/// `hallucination_gate_status` from `pending` to `verified` so the
/// dispatcher can pick it up. The polling loop picks up the new
/// state on the next tick (and the VM optimistically clears the
/// pending banner immediately on the click).
///
/// **Pre-v0.13 hosts:** the verb doesn't exist; callers MUST gate
/// on `HermesCapabilities.hasKanbanDiagnostics` before invoking this.
/// A pre-v0.13 binary will surface the failure as
/// `KanbanError.nonZeroExit` with stderr containing "unknown command".
// TODO(WS-3-Q1): Confirm the exact CLI verb name for the
// hallucination-gate verify path against a v0.13 binary (`hermes
// kanban --help`). The v0.13 release notes describe "hallucination
// gate + recovery UX" but don't enumerate the verb name. This
// implementation assumes `hermes kanban verify <id>`. If Hermes ships
// it as `hermes kanban gate verify <id>`, `hermes kanban hallucination
// verify <id>`, or another name, update the args here. The Reject
// path does NOT depend on this verb (it routes through
// `archive` + a comment), so the recovery UX stays functional even
// if Verify is a stub for an early v0.13.x.
public func verify(taskId: String) async throws {
let args = ["kanban", "verify", taskId]
let (code, _, stderr) = await runHermes(args: args, timeout: 15)
try ensureSuccess(code: code, stdout: "", stderr: stderr, verb: "verify")
}
/// Reject a worker-created card as a hallucinated reference. There
/// is no dedicated `kanban reject` verb in v0.13; the right action
/// per the v0.13 release notes is to archive the card (the work
/// doesn't exist) with a comment recording the rejection reason for
/// the audit trail. Routing this through the existing `comment` +
/// `archive` verbs keeps the wire shape stable across versions.
///
/// If a future Hermes adds a dedicated `kanban reject` verb, swap
/// the body here the public surface stays "reject" returning Void.
public func rejectHallucinated(taskId: String) async throws {
// Best-effort comment first so the audit trail records the
// rejection. A failure here shouldn't block the archive log
// and continue.
do {
try await comment(
taskId: taskId,
text: "Rejected as hallucinated (no underlying work).",
author: nil
)
} catch {
#if canImport(os)
Self.logger.warning("kanban reject: comment failed, proceeding to archive (\(error.localizedDescription, privacy: .public))")
#endif
}
try await archive(taskIds: [taskId])
}
// MARK: - Drag-drop transition mapper // MARK: - Drag-drop transition mapper
/// Map a board-level column transition to the right Hermes verb call. /// Map a board-level column transition to the right Hermes verb call.
@@ -4,17 +4,19 @@ import Observation
import os import os
#endif #endif
/// Mac + iOS view model for the v0.12 Curator surface. /// Mac + iOS view model for the Curator surface (v0.12 base + v0.13
/// archive/prune additions).
/// ///
/// Drives `hermes curator status / run / pause / resume / pin / unpin / /// Drives `hermes curator status / run / pause / resume / pin / unpin /
/// restore` plus a parsed view of `~/.hermes/skills/.curator_state` /// restore` plus (v0.13+) `archive`, `prune`, `list-archived`. All CLI
/// JSON. The CLI doesn't ship a `--json` flag for `status`, so we /// invocations route through `CuratorService` (the actor) so polling
/// text-parse stdout (HermesCuratorStatusParser) and use the state /// and writes share the same concurrency model and a single error path.
/// file for richer last-run metadata.
/// ///
/// Capability-gated: callers should construct this only when /// Capability-gated: callers should construct this only when
/// `HermesCapabilities.hasCurator` is true. The view model does not /// `HermesCapabilities.hasCurator` is true. Archive-aware UI surfaces
/// gate itself the gate happens at sidebar/tab routing time. /// (Archive button, Archived section, Prune) gate independently on
/// `hasCuratorArchive`. The view model itself doesn't gate it exposes
/// every method and the View decides what to render.
@Observable @Observable
@MainActor @MainActor
public final class CuratorViewModel { public final class CuratorViewModel {
@@ -27,20 +29,50 @@ public final class CuratorViewModel {
public private(set) var status: HermesCuratorStatus = .empty public private(set) var status: HermesCuratorStatus = .empty
public private(set) var isLoading = false public private(set) var isLoading = false
public private(set) var lastReportMarkdown: String? public private(set) var lastReportMarkdown: String?
// Archive state (v0.13+ only populated by `loadArchive()` on hosts
// where `hasCuratorArchive` is true).
public private(set) var archivedSkills: [HermesCuratorArchivedSkill] = []
public private(set) var isLoadingArchive = false
// Prune state `pruneSummary` non-nil while the confirm sheet is
// mid-flight; `isPruning` flips during the destructive step.
public private(set) var pruneSummary: CuratorPruneSummary?
public private(set) var isPruning = false
// Track which active-skill row is currently being archived so the
// row chrome can show an inline spinner without blocking the rest.
public private(set) var pendingArchiveName: String?
/// Happy-path success toast ("Pinned X", "Resumed", "Archived
/// legacy-helper"). Auto-clears 3s after assignment.
public var transientMessage: String? public var transientMessage: String?
/// Failure path populated by every CLI verb when it throws. Shown
/// as an inline yellow banner above the status summary so users
/// don't have to dismiss a modal alert during a high-frequency
/// surface like the leaderboard. Manually dismissed via the View's
/// "x" button (sets to nil).
public var errorMessage: String?
@ObservationIgnored
private let service: CuratorService
public init(context: ServerContext) { public init(context: ServerContext) {
self.context = context self.context = context
self.service = CuratorService(context: context)
} }
// MARK: - Loads
public func load() async { public func load() async {
isLoading = true isLoading = true
defer { isLoading = false } defer { isLoading = false }
let context = self.context let context = self.context
// v2.8 instrumented. Curator load fires `hermes curator // v2.8 instrumented. Curator load fires `hermes curator
// status` (CLI subprocess) plus 1-2 file reads; on remote // status` (CLI subprocess) plus 1-2 file reads; on remote each
// each is a separate SSH RTT. Visibility lets future captures // is a separate SSH RTT. Visibility lets future captures show
// show how often the report file is missing or oversized. // how often the report file is missing or oversized.
let parsed = await ScarfMon.measureAsync(.diskIO, "curator.load") { let parsed = await ScarfMon.measureAsync(.diskIO, "curator.load") {
await Task.detached(priority: .userInitiated) { () -> (HermesCuratorStatus, String?) in await Task.detached(priority: .userInitiated) { () -> (HermesCuratorStatus, String?) in
let textResult = Self.runCuratorStatus(context: context) let textResult = Self.runCuratorStatus(context: context)
@@ -69,46 +101,156 @@ public final class CuratorViewModel {
self.lastReportMarkdown = parsed.1 self.lastReportMarkdown = parsed.1
} }
public func runNow() async { /// Refresh the archived-skills list. No-op on hosts without
await runAndReload(args: ["curator", "run"], successMessage: "Curator run started") /// `hasCuratorArchive` the caller gates the call.
public func loadArchive() async {
isLoadingArchive = true
defer { isLoadingArchive = false }
do {
archivedSkills = try await service.listArchived()
} catch {
archivedSkills = []
errorMessage = (error as? LocalizedError)?.errorDescription
?? error.localizedDescription
}
}
// MARK: - Writes (v0.12)
/// Run the curator manually. On v0.13+ hosts this blocks for the
/// duration of the run (default 600s timeout); pre-v0.13 returns
/// immediately. Caller passes the capability-decided flag.
public func runNow(synchronous: Bool, timeout: TimeInterval = 600) async {
await runWithReload(
verb: "run",
successMessage: synchronous ? "Curator run complete" : "Curator run started"
) {
try await self.service.runNow(synchronous: synchronous, timeout: timeout)
}
} }
public func pause() async { public func pause() async {
await runAndReload(args: ["curator", "pause"], successMessage: "Curator paused") await runWithReload(verb: "pause", successMessage: "Curator paused") {
try await self.service.pause()
}
} }
public func resume() async { public func resume() async {
await runAndReload(args: ["curator", "resume"], successMessage: "Curator resumed") await runWithReload(verb: "resume", successMessage: "Curator resumed") {
try await self.service.resume()
}
} }
public func pin(_ skill: String) async { public func pin(_ skill: String) async {
await runAndReload(args: ["curator", "pin", skill], successMessage: "Pinned \(skill)") await runWithReload(verb: "pin", successMessage: "Pinned \(skill)") {
try await self.service.pin(skill)
}
} }
public func unpin(_ skill: String) async { public func unpin(_ skill: String) async {
await runAndReload(args: ["curator", "unpin", skill], successMessage: "Unpinned \(skill)") await runWithReload(verb: "unpin", successMessage: "Unpinned \(skill)") {
try await self.service.unpin(skill)
}
} }
public func restore(_ skill: String) async { public func restore(_ skill: String) async {
await runAndReload(args: ["curator", "restore", skill], successMessage: "Restored \(skill)") await runWithReload(verb: "restore", successMessage: "Restored \(skill)") {
try await self.service.restore(skill)
}
// Restore drops the entry from the archived list refresh it
// so the row disappears immediately.
await loadArchive()
} }
private func runAndReload(args: [String], successMessage: String) async { // MARK: - Writes (v0.13)
let context = self.context
let exitCode = await Task.detached(priority: .userInitiated) { public func archive(_ skill: String) async {
Self.runHermes(context: context, args: args).exitCode pendingArchiveName = skill
}.value await runWithReload(verb: "archive", successMessage: "Archived \(skill)") {
transientMessage = exitCode == 0 ? successMessage : "Command failed" try await self.service.archive(skill)
await load() }
// Auto-clear toast after 3s. pendingArchiveName = nil
await loadArchive()
}
/// Stage 1 of the bulk-prune flow. Calls `prune --dry-run` and
/// populates `pruneSummary`; the View binds its confirm sheet to
/// the non-nil presence of this property.
public func planPrune() async {
do {
pruneSummary = try await service.prune(dryRun: true)
} catch {
errorMessage = (error as? LocalizedError)?.errorDescription
?? error.localizedDescription
pruneSummary = nil
}
}
/// Stage 2 of the bulk-prune flow. Destructive removes everything
/// currently archived. Clears `pruneSummary` regardless of outcome
/// so the confirm sheet dismisses.
public func confirmPrune() async {
isPruning = true
do {
_ = try await service.prune(dryRun: false)
transientMessage = "Pruned archived skills"
errorMessage = nil
await loadArchive()
await load()
scheduleTransientClear()
} catch {
errorMessage = (error as? LocalizedError)?.errorDescription
?? error.localizedDescription
}
isPruning = false
pruneSummary = nil
}
/// Cancel the in-flight prune-confirm flow without running.
public func cancelPrune() {
pruneSummary = nil
}
/// User-driven dismissal of the inline error banner.
public func dismissError() {
errorMessage = nil
}
// MARK: - Helpers
/// Run a service call, route success `transientMessage`, failure
/// `errorMessage`, and reload `status` either way. Mirrors the
/// previous `runAndReload` helper but goes through the typed
/// service surface.
private func runWithReload(
verb: String,
successMessage: String,
body: @escaping @Sendable () async throws -> Void
) async {
do {
try await body()
transientMessage = successMessage
errorMessage = nil
await load()
scheduleTransientClear()
} catch {
let message = (error as? LocalizedError)?.errorDescription
?? error.localizedDescription
errorMessage = message
transientMessage = nil
await load()
}
}
private func scheduleTransientClear() {
Task { @MainActor [weak self] in Task { @MainActor [weak self] in
try? await Task.sleep(nanoseconds: 3_000_000_000) try? await Task.sleep(nanoseconds: 3_000_000_000)
self?.transientMessage = nil self?.transientMessage = nil
} }
} }
/// Wrap the transport-level `runProcess` so the call sites don't // MARK: - Legacy sync helpers (kept for `load`'s detached path)
/// have to reach for it directly. Combined stdout+stderr.
nonisolated private static func runHermes( nonisolated private static func runHermes(
context: ServerContext, context: ServerContext,
args: [String] args: [String]
@@ -229,6 +229,12 @@ public final class RichChatViewModel {
public private(set) var acpOutputTokens = 0 public private(set) var acpOutputTokens = 0
public private(set) var acpThoughtTokens = 0 public private(set) var acpThoughtTokens = 0
public private(set) var acpCachedReadTokens = 0 public private(set) var acpCachedReadTokens = 0
/// Running count of context compactions Hermes has performed on this
/// session. Surfaced as the `🗜 ×N` chip in `SessionInfoBar` when > 0
/// and `HermesCapabilities.hasContextCompressionCount` is true. Each
/// `session/prompt` response carries the latest server-side total, so
/// we replace (with a `max` guard) rather than accumulate.
public private(set) var acpCompressionCount = 0
/// Slash commands advertised by the ACP server via `available_commands_update`. /// Slash commands advertised by the ACP server via `available_commands_update`.
public private(set) var acpCommands: [HermesSlashCommand] = [] public private(set) var acpCommands: [HermesSlashCommand] = []
@@ -248,15 +254,155 @@ public final class RichChatViewModel {
/// Hermes v2026.4.23+ but listed here unconditionally so older /// Hermes v2026.4.23+ but listed here unconditionally so older
/// hosts that don't advertise it still surface the trigger; the /// hosts that don't advertise it still surface the trigger; the
/// agent will respond appropriately or no-op gracefully. /// agent will respond appropriately or no-op gracefully.
///
/// v2.8 / Hermes v0.13 adds `/goal` (lock the agent on a target
/// across turns) and `/queue` (queue a prompt for after the current
/// turn). Both ride the same `.acpNonInterruptive` source Hermes
/// parses them server-side, the wire shape is plain
/// `session/prompt`, and the chat UI keeps the "Agent working"
/// indicator off when they're sent. They're listed unconditionally
/// here; capability filtering happens in `availableCommands` so
/// pre-v0.13 hosts don't see `/goal` or `/queue` in the slash menu.
// TODO(WS-2-Q7): verify against a real v0.13 ACP host that `/goal`
// is in fact non-interruptive on the wire. If Hermes treats it as a
// regular prompt that flips "Agent working", drop it from this
// list and route it through the standard send path (the pill
// bookkeeping in `recordActiveGoal` is independent of the
// interruptive classification).
public static let nonInterruptiveCommands: [HermesSlashCommand] = [ public static let nonInterruptiveCommands: [HermesSlashCommand] = [
HermesSlashCommand( HermesSlashCommand(
name: "steer", name: "steer",
description: "Nudge the agent mid-run (applies after the next tool call)", description: "Nudge the agent mid-run (applies after the next tool call)",
argumentHint: "<guidance>", argumentHint: "<guidance>",
source: .acpNonInterruptive source: .acpNonInterruptive
),
HermesSlashCommand(
name: "goal",
description: "Lock the agent on a goal that persists across turns",
argumentHint: "<text>",
source: .acpNonInterruptive
),
HermesSlashCommand(
name: "queue",
description: "Queue a prompt to run after the current turn",
argumentHint: "<text>",
source: .acpNonInterruptive
) )
] ]
/// Static fallback commands Hermes ACP always supports but only
/// advertises via `available_commands_update` after `session/new`
/// not after `session/load`. Without this fallback, resumed sessions
/// (and "no active session" cold starts) showed an artificially
/// sparse menu. With this list, the menu is discoverable everywhere;
/// when the ACP-advertised version arrives, dedupe-by-name in
/// `availableCommands` ensures the canonical (richer description,
/// authoritative argument hint) entry wins.
///
/// The set splits on whether a session is active:
/// - **Always** (no session AND active session): `/new`. It's the
/// "open a session" affordance and arms the v0.13+ `[<name>]`
/// argument hint via `hasNewWithSessionName`.
/// - **Active-session-only**: `/clear`, `/compact`, `/cost`, `/model`,
/// `/tools`, `/reload-skills`, `/help`, `/exit`. Each requires a
/// live session; surfacing them pre-session would mislead.
public static func alwaysAvailableCommands(
capabilities: HermesCapabilities,
hasActiveSession: Bool
) -> [HermesSlashCommand] {
var result: [HermesSlashCommand] = [
HermesSlashCommand(
name: "new",
description: "Start a new chat session",
argumentHint: capabilities.hasNewWithSessionName ? "[<name>]" : nil,
source: .alwaysAvailable
)
]
guard hasActiveSession else { return result }
result.append(contentsOf: [
HermesSlashCommand(
name: "clear",
description: "Clear the current conversation",
argumentHint: nil,
source: .alwaysAvailable
),
HermesSlashCommand(
name: "compact",
description: "Compress the conversation history",
argumentHint: nil,
source: .alwaysAvailable
),
HermesSlashCommand(
name: "cost",
description: "Show cost breakdown for this session",
argumentHint: nil,
source: .alwaysAvailable
),
HermesSlashCommand(
name: "model",
description: "Switch the active model",
argumentHint: "[<model>]",
source: .alwaysAvailable
),
HermesSlashCommand(
name: "tools",
description: "Manage tool availability",
argumentHint: nil,
source: .alwaysAvailable
),
HermesSlashCommand(
name: "reload-skills",
description: "Reload the skills index",
argumentHint: nil,
source: .alwaysAvailable
),
HermesSlashCommand(
name: "help",
description: "Show available commands",
argumentHint: nil,
source: .alwaysAvailable
),
HermesSlashCommand(
name: "exit",
description: "End the current session",
argumentHint: nil,
source: .alwaysAvailable
)
])
return result
}
/// Capability snapshot the chat surface uses to filter
/// `availableCommands`. Set by the chat controller (Mac
/// `ChatViewModel`, iOS `ChatController`) at session-start time and
/// kept fresh via the `HermesCapabilitiesStore` env binding. Default
/// `.empty` means "no v0.13 surfaces" pre-v0.13 hosts and harness
/// scenarios (Previews, smoke tests) never expose `/goal` or
/// `/queue` until the controller publishes a real capabilities
/// value. `@ObservationIgnored` so capability refreshes don't trash
/// the streaming-message render budget; controllers call
/// `publishCapabilities(_:)` once per refresh tick.
@ObservationIgnored
public var capabilitiesGate: HermesCapabilities = .empty
/// Optimistic local mirror of the agent's currently-locked goal.
/// Set by `recordActiveGoal(text:)` the moment the user sends
/// `/goal `; cleared on `/goal --clear` or `reset()`. Pre-v0.13
/// hosts can't reach this code path (the slash menu hides `/goal`),
/// but a typed-out `/goal foo` against an older host would still
/// land here briefly until Hermes' "unknown command" reply lands
/// see WS-2 plan "Inconsistency caveat".
public private(set) var activeGoal: HermesActiveGoal?
/// Optimistic mirror of prompts the user has queued via `/queue `
/// while a turn is in flight. Hermes is the authoritative owner
/// server-side; this list drives the chat-header chip + popover and
/// drains FIFO via `popQueuedPrompt()` when a turn completes.
/// Best-effort: if Hermes' server-side queue gets out of sync
/// (deferred prompt aborted, dropped on disconnect) the user sees a
/// stale chip until their next interaction.
public private(set) var queuedPrompts: [HermesQueuedPrompt] = []
/// Transient hint shown above the composer, e.g. "Guidance queued /// Transient hint shown above the composer, e.g. "Guidance queued
/// applies after the next tool call." for `/steer`. The chat view /// applies after the next tool call." for `/steer`. The chat view
/// auto-clears it after a short delay (handled in the view); the /// auto-clears it after a short delay (handled in the view); the
@@ -318,10 +464,105 @@ public final class RichChatViewModel {
!acpNames.contains($0.name) && !projectNames.contains($0.name) !acpNames.contains($0.name) && !projectNames.contains($0.name)
} }
let occupied = acpNames.union(projectNames).union(Set(quicks.map(\.name))) let occupied = acpNames.union(projectNames).union(Set(quicks.map(\.name)))
let nonInterruptive = Self.nonInterruptiveCommands.filter { // Capability gate: `/goal` and `/queue` are v0.13+ surfaces;
!occupied.contains($0.name) // hide them when the connected host is older. `/steer` is
// surfaced unconditionally it works on v0.11+ during an
// active turn; idle-session greying for pre-v0.13 hosts is
// the input bar's concern (it reads `hasACPSteerOnIdle`).
let supported: [HermesSlashCommand] = Self.nonInterruptiveCommands.filter { cmd in
switch cmd.name {
case "goal": return capabilitiesGate.hasGoals
case "queue": return capabilitiesGate.hasACPQueue
case "steer": return true
default: return true
}
} }
return acpCommands + projectAsHermes + quicks + nonInterruptive let nonInterruptive = supported.filter { !occupied.contains($0.name) }
// Static fallbacks. `/new` always shows; the rest of the agent-
// level command set (`/clear`, `/compact`, `/cost`, `/model`,
// `/tools`, `/reload-skills`, `/help`, `/exit`) only when a
// session is active Hermes ACP doesn't re-emit
// `available_commands_update` after `session/load`, so without
// this fallback resumed sessions showed an artificially sparse
// menu. Deduped against ACP / project / quick names so once a
// session starts and the ACP server advertises its richer
// versions, the ACP-sourced entry wins.
let alwaysAvailable = Self.alwaysAvailableCommands(
capabilities: capabilitiesGate,
hasActiveSession: sessionId != nil
).filter { !occupied.contains($0.name) }
return acpCommands + projectAsHermes + quicks + nonInterruptive + alwaysAvailable
}
/// Publish a fresh capabilities snapshot from the controller.
/// Called whenever `HermesCapabilitiesStore.capabilities` changes
/// (initial detection, post-refresh, server switch). The chat input
/// bar's slash menu re-reads `availableCommands` lazily, so this is
/// just a stored-value swap no observable churn.
public func publishCapabilities(_ caps: HermesCapabilities) {
capabilitiesGate = caps
}
/// Optimistic write triggered when the user sends `/goal <text>`.
/// Pass `nil` (or empty) to clear (the `/goal --clear` path). The
/// pill renders synchronously off this state; there is no
/// authoritative server read-back in v2.8.0 see WS-2 plan Q1.
// TODO(WS-2-Q1): hook a Hermes-supplied goal-state read-back path
// here once we know whether v0.13 exposes goal state via an ACP
// session-startup notification, a session-sidecar JSON field, or a
// `/goal --status` reply. Until then `activeGoal` is purely
// user-set and does not survive a session resume.
public func recordActiveGoal(text: String?) {
if let text, !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
activeGoal = HermesActiveGoal(
text: text.trimmingCharacters(in: .whitespacesAndNewlines),
setAt: Date()
)
} else {
activeGoal = nil
}
}
/// Append an optimistically-queued prompt to the local mirror
/// (driven by `/queue <text>`). No-op for empty / whitespace input.
public func recordQueuedPrompt(text: String) {
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else { return }
queuedPrompts.append(HermesQueuedPrompt(text: trimmed))
}
/// Drain the next queued prompt off the local mirror, FIFO. Called
/// from `handlePromptComplete` once a turn settles Hermes runs
/// the actual queued prompt server-side; popping here keeps the
/// header chip count honest. Returns the popped prompt for any
/// caller that wants to log it; the chat UI ignores the return.
@discardableResult
public func popQueuedPrompt() -> HermesQueuedPrompt? {
queuedPrompts.isEmpty ? nil : queuedPrompts.removeFirst()
}
/// Parse the argument slug from a `/goal ` invocation. Pure
/// function exposed for unit tests. The chat dispatch reads this
/// to decide whether to set, clear, or no-op the optimistic pill.
public enum GoalCommandArgument: Equatable {
case set(String)
case clear
/// User typed `/goal` with no argument Hermes will reply
/// with usage; Scarf shows a neutral hint and doesn't touch
/// the pill state.
case empty
}
public static func parseGoalArgument(_ raw: String) -> GoalCommandArgument {
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty { return .empty }
// Accept `--clear`, `clear`, and case-insensitive variants so
// typos don't accidentally lock the goal text to literal
// "Clear". `--clear` is the canonical form (matches Hermes
// CLI flag style).
let lowered = trimmed.lowercased()
if lowered == "--clear" || lowered == "clear" { return .clear }
return .set(trimmed)
} }
/// True when `text` is a non-interruptive command that should NOT /// True when `text` is a non-interruptive command that should NOT
@@ -468,12 +709,36 @@ public final class RichChatViewModel {
acpErrorHint = nil acpErrorHint = nil
acpErrorDetails = nil acpErrorDetails = nil
acpCachedReadTokens = 0 acpCachedReadTokens = 0
acpCommands = [] acpCompressionCount = 0
// `acpCommands` is intentionally NOT cleared. ACP slash commands
// are agent-level (advertised once per process via
// `available_commands_update` typically piggy-backing on
// `session/new`); they don't change when the user switches
// sessions. Hermes does not re-emit on `session/load`, so if
// we wipe here, resumed sessions land at a 4-command fallback
// until the user starts a fresh session observed during
// dogfooding against a Hermes v0.13 host. The caller paths
// (startNewSession, resumeSession, continueLastSession) all
// spawn a fresh ACP subprocess; if that subprocess emits a
// fresh list, our value is replaced; if it doesn't, we keep
// the most recently-known agent-level set, which stays
// accurate as long as the agent identity hasn't changed. The
// host-switch case (Local SSH) tears down the whole
// ContextBoundRoot so this stale carry-over isn't reachable
// there.
projectScopedCommands = [] projectScopedCommands = []
currentTurnStart = nil currentTurnStart = nil
turnDurations = [:] turnDurations = [:]
transientHint = nil transientHint = nil
pendingPermission = nil pendingPermission = nil
// v2.8 / Hermes v0.13 drop optimistic v0.13 surfaces on
// session reset so a fresh chat (or a resume into a different
// session) doesn't paint stale goal / queue state from the
// previous one. The capabilities gate stays on whatever the
// controller most recently published; it's a host-level value
// that doesn't change with session boundaries.
activeGoal = nil
queuedPrompts = []
loadQuickCommands() loadQuickCommands()
} }
@@ -811,7 +1076,30 @@ public final class RichChatViewModel {
acpOutputTokens += response.outputTokens acpOutputTokens += response.outputTokens
acpThoughtTokens += response.thoughtTokens acpThoughtTokens += response.thoughtTokens
acpCachedReadTokens += response.cachedReadTokens acpCachedReadTokens += response.cachedReadTokens
// Compression count is a session-wide running total emitted by
// Hermes; each prompt response carries the latest value, so we
// replace rather than accumulate. The `max` guard tolerates
// pre-v0.13 hosts (which emit 0) being upgraded server-side
// mid-session once a real number lands the count resumes from
// there rather than snapping back to 0.
acpCompressionCount = max(acpCompressionCount, response.compressionCount)
isAgentWorking = false isAgentWorking = false
// v2.8 / Hermes v0.13 Hermes runs the next `/queue`-deferred
// prompt server-side now that this turn has settled. Drain the
// local mirror FIFO so the header chip count matches what the
// user staged. Best-effort: if Hermes' authoritative queue
// diverged (deferred prompt aborted, dropped on disconnect),
// the chip is one tick stale until the user's next interaction.
if !queuedPrompts.isEmpty {
popQueuedPrompt()
}
// TODO(v2.8.1): when this completes after an auto-resumed
// checkpoint (Hermes v0.13's "Auto-resume interrupted sessions
// after gateway restart"), surface a one-shot "Auto-resumed
// from checkpoint" indicator. Wire-shape unknown until a v0.13
// dogfooding pass confirms whether the resume lands as a
// visible ACP event or is purely server-side. Deferred from
// v2.8.0 per WS-2 plan Q3.
buildMessageGroups() buildMessageGroups()
// Final position after the prompt settles. Catches fast responses // Final position after the prompt settles. Catches fast responses
// (slash commands, short replies) where `.defaultScrollAnchor(.bottom)` // (slash commands, short replies) where `.defaultScrollAnchor(.bottom)`
@@ -0,0 +1,70 @@
import Testing
import Foundation
@testable import ScarfCore
/// Pure mapping tests for `GatewayAllowlistKind`. Locks down the (platform
/// kind) table so a refactor doesn't accidentally drop a platform.
@Suite struct GatewayAllowlistKindTests {
@Test func mapsKnownPlatformsToCorrectKind() {
#expect(GatewayAllowlistKind.kind(for: "slack") == .channels)
#expect(GatewayAllowlistKind.kind(for: "mattermost") == .channels)
#expect(GatewayAllowlistKind.kind(for: "google-chat") == .channels)
#expect(GatewayAllowlistKind.kind(for: "telegram") == .chats)
#expect(GatewayAllowlistKind.kind(for: "whatsapp") == .chats)
#expect(GatewayAllowlistKind.kind(for: "matrix") == .rooms)
#expect(GatewayAllowlistKind.kind(for: "dingtalk") == .rooms)
}
@Test func acceptsBothGoogleChatSpellings() {
// // TODO(WS-5-Q1) both spellings round-trip until Hermes confirms
// the wire identifier.
#expect(GatewayAllowlistKind.kind(for: "google-chat") == .channels)
#expect(GatewayAllowlistKind.kind(for: "googlechat") == .channels)
}
@Test func returnsNilForPlatformsWithoutAllowlist() {
#expect(GatewayAllowlistKind.kind(for: "cli") == nil)
#expect(GatewayAllowlistKind.kind(for: "yuanbao") == nil)
#expect(GatewayAllowlistKind.kind(for: "microsoft-teams") == nil)
#expect(GatewayAllowlistKind.kind(for: "discord") == nil)
#expect(GatewayAllowlistKind.kind(for: "signal") == nil)
#expect(GatewayAllowlistKind.kind(for: "homeassistant") == nil)
#expect(GatewayAllowlistKind.kind(for: "") == nil)
#expect(GatewayAllowlistKind.kind(for: "unknown") == nil)
}
@Test func yamlKeyMatchesHermesContract() {
#expect(GatewayAllowlistKind.channels.yamlKey == "allowed_channels")
#expect(GatewayAllowlistKind.chats.yamlKey == "allowed_chats")
#expect(GatewayAllowlistKind.rooms.yamlKey == "allowed_rooms")
}
@Test func nounsAreUserFacingSafe() {
#expect(GatewayAllowlistKind.channels.noun == "channel")
#expect(GatewayAllowlistKind.chats.noun == "chat")
#expect(GatewayAllowlistKind.rooms.noun == "room")
#expect(GatewayAllowlistKind.channels.pluralNoun == "channels")
#expect(GatewayAllowlistKind.chats.pluralNoun == "chats")
#expect(GatewayAllowlistKind.rooms.pluralNoun == "rooms")
}
@Test func placeholdersAreNonEmpty() {
// Smoke test placeholder strings are advisory; we just don't want
// them silently emptied during a refactor.
#expect(!GatewayAllowlistKind.channels.inputPlaceholder.isEmpty)
#expect(!GatewayAllowlistKind.chats.inputPlaceholder.isEmpty)
#expect(!GatewayAllowlistKind.rooms.inputPlaceholder.isEmpty)
}
@Test func gatewayPlatformSettingsItemsForKind() {
let s = GatewayPlatformSettings(
allowedChannels: ["C01"],
allowedChats: ["@user"],
allowedRooms: ["!room:matrix.org"]
)
#expect(s.items(for: .channels) == ["C01"])
#expect(s.items(for: .chats) == ["@user"])
#expect(s.items(for: .rooms) == ["!room:matrix.org"])
}
}
@@ -0,0 +1,276 @@
import Testing
import Foundation
@testable import ScarfCore
/// Round-trip + idempotence tests for `GatewayConfigWriter.setList`. Pure
/// `String` operations only runs cleanly on Linux SwiftPM.
@Suite struct GatewayConfigWriterTests {
// MARK: - Insert
@Test func setListInsertsBlockOnEmpty() {
let yaml = ""
let updated = GatewayConfigWriter.setList(
in: yaml,
platform: "slack",
key: "allowed_channels",
items: ["C0123ABCD", "C0456EFGH"]
)
#expect(updated.contains("gateway:"))
#expect(updated.contains(" platforms:"))
#expect(updated.contains(" slack:"))
#expect(updated.contains(" allowed_channels:"))
#expect(updated.contains("- C0123ABCD"))
#expect(updated.contains("- C0456EFGH"))
}
@Test func setListAppendsScaffoldPreservingPriorContent() {
let yaml = """
model:
default: gpt-4o
provider: openai
"""
let updated = GatewayConfigWriter.setList(
in: yaml,
platform: "slack",
key: "allowed_channels",
items: ["C01"]
)
// Original content preserved verbatim at the top.
#expect(updated.contains("model:"))
#expect(updated.contains(" default: gpt-4o"))
#expect(updated.contains(" provider: openai"))
// New scaffold appended.
#expect(updated.contains("gateway:"))
#expect(updated.contains(" slack:"))
#expect(updated.contains("- C01"))
}
// MARK: - Replace
@Test func setListReplacesExistingBlock() {
let yaml = """
gateway:
platforms:
slack:
allowed_channels:
- C_OLD_1
- C_OLD_2
"""
let updated = GatewayConfigWriter.setList(
in: yaml,
platform: "slack",
key: "allowed_channels",
items: ["C_NEW_1"]
)
#expect(updated.contains("- C_NEW_1"))
#expect(!updated.contains("- C_OLD_1"))
#expect(!updated.contains("- C_OLD_2"))
}
@Test func setListPreservesScalarSiblings() {
// The `busy_ack_enabled` scalar sibling of `allowed_channels` must
// stay byte-for-byte after a list-write to the same platform.
let yaml = """
gateway:
platforms:
slack:
allowed_channels:
- C_OLD
busy_ack_enabled: false
gateway_restart_notification: true
"""
let updated = GatewayConfigWriter.setList(
in: yaml,
platform: "slack",
key: "allowed_channels",
items: ["C_NEW"]
)
#expect(updated.contains("- C_NEW"))
#expect(!updated.contains("- C_OLD"))
// Scalars at the same indent must survive.
#expect(updated.contains("busy_ack_enabled: false"))
#expect(updated.contains("gateway_restart_notification: true"))
}
@Test func setListPreservesOtherPlatformsBlocks() {
// Editing slack must not touch matrix.
let yaml = """
gateway:
platforms:
slack:
allowed_channels:
- C_SLACK
matrix:
allowed_rooms:
- '!room1:matrix.org'
- '!room2:matrix.org'
"""
let updated = GatewayConfigWriter.setList(
in: yaml,
platform: "slack",
key: "allowed_channels",
items: ["C_SLACK_NEW"]
)
#expect(updated.contains("- C_SLACK_NEW"))
// Matrix block intact.
#expect(updated.contains(" matrix:"))
#expect(updated.contains("'!room1:matrix.org'"))
#expect(updated.contains("'!room2:matrix.org'"))
}
// MARK: - Remove
@Test func setListWithEmptyItemsRemovesBlock() {
let yaml = """
gateway:
platforms:
slack:
allowed_channels:
- C01
- C02
busy_ack_enabled: true
"""
let updated = GatewayConfigWriter.setList(
in: yaml,
platform: "slack",
key: "allowed_channels",
items: []
)
// Block removed; sibling scalar preserved.
#expect(!updated.contains("allowed_channels:"))
#expect(!updated.contains("- C01"))
#expect(!updated.contains("- C02"))
#expect(updated.contains("busy_ack_enabled: true"))
}
@Test func setListWithEmptyItemsOnAbsentBlockIsNoOp() {
let yaml = """
model:
default: gpt-4o
"""
let updated = GatewayConfigWriter.setList(
in: yaml,
platform: "slack",
key: "allowed_channels",
items: []
)
#expect(updated == yaml)
}
// MARK: - Idempotence
@Test func setListIsIdempotent() {
let yaml = """
model:
default: gpt-4o
"""
let once = GatewayConfigWriter.setList(
in: yaml,
platform: "telegram",
key: "allowed_chats",
items: ["@alice", "@bob"]
)
let twice = GatewayConfigWriter.setList(
in: once,
platform: "telegram",
key: "allowed_chats",
items: ["@alice", "@bob"]
)
#expect(once == twice)
}
@Test func setListReplaceThenReplaceIsStable() {
let yaml = ""
let a = GatewayConfigWriter.setList(
in: yaml, platform: "matrix", key: "allowed_rooms",
items: ["!a:m", "!b:m"]
)
let b = GatewayConfigWriter.setList(
in: a, platform: "matrix", key: "allowed_rooms",
items: ["!c:m"]
)
#expect(b.contains("- '!c:m'"))
#expect(!b.contains("'!a:m'"))
#expect(!b.contains("'!b:m'"))
}
// MARK: - Quoting
@Test func setListQuotesItemsContainingColons() {
// Matrix room IDs contain `:` must be single-quoted.
let yaml = ""
let updated = GatewayConfigWriter.setList(
in: yaml, platform: "matrix", key: "allowed_rooms",
items: ["!RoomId:matrix.org"]
)
#expect(updated.contains("'!RoomId:matrix.org'"))
}
@Test func setListQuotesItemsStartingWithAt() {
// Telegram usernames `@alice`.
let yaml = ""
let updated = GatewayConfigWriter.setList(
in: yaml, platform: "telegram", key: "allowed_chats",
items: ["@alice"]
)
#expect(updated.contains("'@alice'"))
}
@Test func setListLeavesPlainAlphanumericUnquoted() {
// Slack channel IDs are A-Z0-9 emit unquoted for readability.
let yaml = ""
let updated = GatewayConfigWriter.setList(
in: yaml, platform: "slack", key: "allowed_channels",
items: ["C0123ABCD"]
)
#expect(updated.contains("- C0123ABCD"))
#expect(!updated.contains("'C0123ABCD'"))
}
@Test func setListEscapesEmbeddedSingleQuotes() {
let yaml = ""
let updated = GatewayConfigWriter.setList(
in: yaml, platform: "slack", key: "allowed_channels",
items: ["weird:'name"]
)
// Embedded single quote doubled per YAML spec.
#expect(updated.contains("'weird:''name'"))
}
// MARK: - Insertion when ancestors exist but key is absent
@Test func setListInsertsKeyUnderExistingPlatformBlock() {
// `gateway platforms slack` exists with a busy_ack_enabled
// scalar; `allowed_channels` is missing. Add it without disturbing
// the scalar sibling.
let yaml = """
gateway:
platforms:
slack:
busy_ack_enabled: false
"""
let updated = GatewayConfigWriter.setList(
in: yaml, platform: "slack", key: "allowed_channels",
items: ["C42"]
)
#expect(updated.contains("busy_ack_enabled: false"))
#expect(updated.contains("allowed_channels:"))
#expect(updated.contains("- C42"))
}
// MARK: - Round-trip with the YAML loader
@Test func roundTripsThroughHermesConfigYAMLLoader() {
// Write a list, then parse the result through HermesConfig+YAML and
// confirm we read back what we wrote.
var yaml = ""
yaml = GatewayConfigWriter.setList(
in: yaml, platform: "slack", key: "allowed_channels",
items: ["C01", "C02"]
)
let cfg = HermesConfig(yaml: yaml)
let block = cfg.gatewayPlatforms["slack"]
#expect(block?.allowedChannels == ["C01", "C02"])
}
}
@@ -151,4 +151,169 @@ import Foundation
#expect(parsed?.patchCount == 2) #expect(parsed?.patchCount == 2)
#expect(parsed?.lastActivityLabel == "2026-04-25") #expect(parsed?.lastActivityLabel == "2026-04-25")
} }
// MARK: - v0.13 list-archived / prune fixtures (WS-4)
/// Empty JSON array `[]`. Locks in the happy-path no-archives shape.
@Test func listArchivedEmpty() throws {
let result = try CuratorService.parseListArchived(stdout: "[]")
#expect(result.isEmpty)
}
/// Three archives with full optional fields. Asserts each
/// optional value decodes through `decodeIfPresent` and that
/// the computed labels resolve.
@Test func listArchivedThreeSkills() throws {
let json = """
[
{
"name": "legacy-helper",
"category": "templates",
"archived_at": "2026-04-22T03:14:09Z",
"reason": "stale: 91d unused",
"size_bytes": 4521,
"path": "/Users/u/.hermes/skills/.archived/legacy-helper"
},
{
"name": "old-translator",
"category": "user",
"archived_at": "2026-04-23T10:00:00Z",
"reason": "consolidated with translator",
"size_bytes": 8192
},
{
"name": "minimal"
}
]
"""
let result = try CuratorService.parseListArchived(stdout: json)
#expect(result.count == 3)
#expect(result[0].name == "legacy-helper")
#expect(result[0].category == "templates")
#expect(result[0].reason == "stale: 91d unused")
#expect(result[0].sizeBytes == 4521)
#expect(result[0].archivedAtLabel == "2026-04-22")
#expect(result[0].path == "/Users/u/.hermes/skills/.archived/legacy-helper")
// Tolerant: only `name` set on the third row.
#expect(result[2].name == "minimal")
#expect(result[2].category == nil)
#expect(result[2].reason == nil)
#expect(result[2].archivedAtLabel == "")
#expect(result[2].sizeLabel == "")
}
/// `{"archived": [...]}` envelope is also accepted.
@Test func listArchivedEnvelope() throws {
let json = """
{"archived": [
{"name": "envelope-skill", "size_bytes": 1024}
]}
"""
let result = try CuratorService.parseListArchived(stdout: json)
#expect(result.count == 1)
#expect(result[0].name == "envelope-skill")
}
/// Text fallback when `--json` isn't supported. Each row carries
/// the name in column 1 plus k=v chips for the optional fields.
@Test func listArchivedTextFallback() {
let text = """
legacy-helper archived=2026-04-22 size=4521 reason=stale
old-translator archived=2026-04-23 size=8192
minimal-row
"""
let result = CuratorService.parseListArchivedText(text)
#expect(result.count == 3)
#expect(result[0].name == "legacy-helper")
#expect(result[0].archivedAt == "2026-04-22")
#expect(result[0].sizeBytes == 4521)
#expect(result[0].reason == "stale")
#expect(result[2].name == "minimal-row")
#expect(result[2].sizeBytes == nil)
}
/// Empty-state sentinel folds to `[]` (parallel to KanbanService's
/// `"no matching tasks"` handling).
@Test func listArchivedNoArchivedSentinel() throws {
let result = try CuratorService.parseListArchived(stdout: "no archived skills\n")
#expect(result.isEmpty)
}
/// Whitespace-only stdout also folds to empty.
@Test func listArchivedWhitespaceFoldsToEmpty() throws {
let result = try CuratorService.parseListArchived(stdout: " \n\n")
#expect(result.isEmpty)
}
/// Decode failure (clearly non-JSON, non-text) throws. We accept
/// JSON, the envelope, the empty sentinel, or text rows; anything
/// else surfaces as a `CuratorError.decoding`.
@Test func listArchivedNonsenseThrows() throws {
do {
_ = try CuratorService.parseListArchived(stdout: "{garbage")
Issue.record("expected decoding throw")
} catch let error as CuratorError {
if case .decoding = error {
// expected
} else {
Issue.record("unexpected error \(error)")
}
}
}
/// Prune-dry-run JSON with `would_remove` + `total_bytes`.
@Test func pruneDryRunHappyPath() {
let json = """
{
"would_remove": [
{"name": "stale-a", "size_bytes": 1000},
{"name": "stale-b", "size_bytes": 2000}
],
"total_bytes": 3000
}
"""
let summary = CuratorService.parsePruneDryRun(json)
#expect(summary.totalCount == 2)
#expect(summary.totalBytes == 3000)
#expect(summary.wouldRemove.first?.name == "stale-a")
}
/// Zero-skill prune is a valid dry-run (no archives).
@Test func pruneDryRunZeroSkills() {
let json = """
{"would_remove": [], "total_bytes": 0}
"""
let summary = CuratorService.parsePruneDryRun(json)
#expect(summary.totalCount == 0)
#expect(summary.totalBytes == 0)
#expect(summary.totalBytesLabel == "")
}
/// Bare-array fallback: some Hermes builds may print just the
/// would-remove list when the wrapper is missing.
@Test func pruneDryRunBareArrayFallback() {
let json = """
[{"name": "lonely", "size_bytes": 500}]
"""
let summary = CuratorService.parsePruneDryRun(json)
#expect(summary.totalCount == 1)
#expect(summary.totalBytes == 500)
}
/// Empty / whitespace stdout zero summary (no decoding throw).
@Test func pruneDryRunEmptyStaysSafe() {
let summary = CuratorService.parsePruneDryRun(" \n")
#expect(summary.totalCount == 0)
#expect(summary.totalBytes == 0)
}
/// Verify the size label uses the byte formatter (not raw bytes).
@Test func archivedSkillSizeLabelFormats() {
let big = HermesCuratorArchivedSkill(name: "x", sizeBytes: 1_500_000)
// ByteCountFormatter produces a localized label; just verify
// it's non-empty and not raw "1500000".
#expect(!big.sizeLabel.isEmpty)
#expect(big.sizeLabel != "1500000")
}
} }
@@ -0,0 +1,131 @@
import Testing
import Foundation
@testable import ScarfCore
/// Parser tests for `hermes gateway list --json`. Pure no transport, no
/// process calls.
@Suite struct HermesGatewayListServiceTests {
private func data(_ s: String) -> Data { s.data(using: .utf8)! }
@Test func parsesSingleProfileSinglePlatform() {
let json = data(#"""
{"profiles":[{"name":"default","running":true,"pid":1234,
"platforms":["slack","telegram"]}]}
"""#)
let snap = HermesGatewayListService.parse(json)
#expect(snap?.profiles.count == 1)
#expect(snap?.profiles[0].profile == "default")
#expect(snap?.profiles[0].pid == 1234)
#expect(snap?.profiles[0].isRunning == true)
#expect(snap?.profiles[0].platforms == ["slack", "telegram"])
}
@Test func parsesMultipleProfiles() {
let json = data(#"""
{"profiles":[
{"name":"work","running":true,"pid":2001,"platforms":["slack"]},
{"name":"personal","running":false,"platforms":["telegram"]}
]}
"""#)
let snap = HermesGatewayListService.parse(json)
#expect(snap?.profiles.count == 2)
#expect(snap?.profiles[0].profile == "work")
#expect(snap?.profiles[0].isRunning == true)
#expect(snap?.profiles[1].profile == "personal")
#expect(snap?.profiles[1].isRunning == false)
#expect(snap?.profiles[1].pid == nil)
}
@Test func parsesBareArrayShape() {
// Tolerance for a top-level array (no `profiles` wrapper).
let json = data(#"""
[{"name":"default","running":true,"pid":42,"platforms":["discord"]}]
"""#)
let snap = HermesGatewayListService.parse(json)
#expect(snap?.profiles.count == 1)
#expect(snap?.profiles[0].profile == "default")
}
@Test func toleratesAlternateFieldNames() {
// `profile` instead of `name`, `state` instead of `running`,
// `connected_platforms` instead of `platforms` defensive defaults
// keep the parser happy if Hermes ships any of these.
let json = data(#"""
{"profiles":[{"profile":"alt","state":"running","pid":7,
"connected_platforms":["matrix"]}]}
"""#)
let snap = HermesGatewayListService.parse(json)
#expect(snap?.profiles[0].profile == "alt")
#expect(snap?.profiles[0].isRunning == true)
#expect(snap?.profiles[0].platforms == ["matrix"])
}
@Test func returnsNilOnEmptyData() {
#expect(HermesGatewayListService.parse(Data()) == nil)
}
@Test func returnsNilOnUnparseableJSON() {
let json = data("not-json")
#expect(HermesGatewayListService.parse(json) == nil)
}
@Test func returnsEmptySnapshotOnEmptyProfilesArray() {
let json = data(#"{"profiles":[]}"#)
let snap = HermesGatewayListService.parse(json)
#expect(snap?.profiles.isEmpty == true)
}
@Test func toleratesUnknownKeys() {
// Forward-compat: a future v0.13.x Hermes adds extra fields, parser
// still works.
let json = data(#"""
{"profiles":[{"name":"default","running":true,"platforms":["slack"],
"future_field":"value","another":42}]}
"""#)
let snap = HermesGatewayListService.parse(json)
#expect(snap?.profiles[0].profile == "default")
}
// MARK: - headerDigest
@Test func headerDigestEmptyProfiles() {
let snap = GatewayListSnapshot(profiles: [])
#expect(snap.headerDigest == "no profiles configured")
}
@Test func headerDigestSingleProfileRunning() {
let snap = GatewayListSnapshot(profiles: [
.init(profile: "default", isRunning: true, pid: 100,
platforms: ["slack", "telegram"])
])
#expect(snap.headerDigest == "default profile · running · slack, telegram")
}
@Test func headerDigestSingleProfileStopped() {
let snap = GatewayListSnapshot(profiles: [
.init(profile: "default", isRunning: false, pid: nil, platforms: [])
])
#expect(snap.headerDigest == "default profile · stopped")
}
@Test func headerDigestMultipleProfilesSomeRunning() {
let snap = GatewayListSnapshot(profiles: [
.init(profile: "work", isRunning: true, pid: 1, platforms: ["slack"]),
.init(profile: "home", isRunning: false, pid: nil, platforms: ["matrix"]),
.init(profile: "extra", isRunning: true, pid: 2, platforms: [])
])
// 3 profiles total, 2 running, surface first running profile's
// platform list as the highlight.
#expect(snap.headerDigest == "3 profiles (2 running) · work: slack")
}
@Test func headerDigestMultipleProfilesNoneRunning() {
let snap = GatewayListSnapshot(profiles: [
.init(profile: "a", isRunning: false, pid: nil, platforms: ["slack"]),
.init(profile: "b", isRunning: false, pid: nil, platforms: ["matrix"])
])
// No running profile fall back to the first profile's platforms.
#expect(snap.headerDigest == "2 profiles (0 running) · a: slack")
}
}
@@ -327,4 +327,196 @@ import Foundation
#expect(stats.glanceString.isEmpty) #expect(stats.glanceString.isEmpty)
#expect(stats.activeCount == 0) #expect(stats.activeCount == 0)
} }
// MARK: - v0.13 (Hermes 2026.5.7) tolerant decode
//
// The contract these tests pin: a v0.13 host's task / run / detail
// JSON decodes successfully WITH the new fields populated, AND a
// pre-v0.13 (v0.12) host's task / run / detail JSON decodes
// successfully WITHOUT the new fields (everything resolves to nil
// or empty). Drift from this pair = a regression that bites every
// user not yet on Hermes v0.13.
@Test func decodeV013TaskFields() throws {
let json = """
{
"id": "t_v013",
"title": "v0.13 task",
"status": "blocked",
"max_retries": 5,
"auto_blocked_reason": "worker exited without `kanban complete`",
"hallucination_gate_status": "pending",
"diagnostics": [
{"kind": "worker_exit_no_complete", "message": "exit code 0 with no complete call", "detected_at": 1778160614},
{"kind": "darwin_zombie_detected", "detected_at": "2026-05-09T12:00:00Z"}
]
}
"""
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
#expect(task.maxRetries == 5)
#expect(task.autoBlockedReason?.contains("kanban complete") == true)
#expect(task.hallucinationGateStatus == "pending")
#expect(task.diagnostics.count == 2)
#expect(task.diagnostics.first?.kind == "worker_exit_no_complete")
#expect(task.diagnostics.last?.detectedAt?.contains("2026") == true)
}
@Test func decodeV012TaskHasNoNewFields() throws {
// The most damaging failure mode is a v0.12 user upgrading Scarf
// and having the board stop loading because a v0.13-only field
// is required. Pin the contract.
let json = """
{"id": "t_legacy", "title": "v0.12 task", "status": "ready"}
"""
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
#expect(task.maxRetries == nil)
#expect(task.autoBlockedReason == nil)
#expect(task.hallucinationGateStatus == nil)
#expect(task.diagnostics.isEmpty)
}
@Test func decodeMalformedDiagnosticTolerated() throws {
// If Hermes emits a malformed diagnostics value, the rest of the
// task should still decode. We use try? on the diagnostics decode
// so a single bad entry doesn't reject the whole row.
let json = """
{
"id": "t_x",
"title": "x",
"status": "ready",
"diagnostics": "not-an-array"
}
"""
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
#expect(task.id == "t_x")
// Diagnostics field couldn't decode treat as empty.
#expect(task.diagnostics.isEmpty)
}
@Test func hallucinationGateMirrorMapsKnownValues() {
#expect(KanbanHallucinationGate.from("pending") == .pending)
#expect(KanbanHallucinationGate.from("verified") == .verified)
#expect(KanbanHallucinationGate.from("REJECTED") == .rejected) // case-insensitive
#expect(KanbanHallucinationGate.from(nil) == nil)
#expect(KanbanHallucinationGate.from("") == nil)
// Unknown wire values fall through to nil so the banner stays
// hidden; future Hermes versions can add `quarantined` etc.
// without a Scarf release.
#expect(KanbanHallucinationGate.from("quarantined") == nil)
}
@Test func diagnosticKindMirrorMapsKnownValues() {
#expect(KanbanDiagnosticKind.from("heartbeat_stalled") == .heartbeatStalled)
#expect(KanbanDiagnosticKind.from("DARWIN_ZOMBIE_DETECTED") == .darwinZombieDetected)
// Unknown kinds fall through to .unknown so views can render
// the raw string verbatim.
#expect(KanbanDiagnosticKind.from("future_kind_v014") == .unknown)
}
@Test func diagnosticSeverityMapping() {
#expect(KanbanDiagnosticKind.retryCapHit.severity == .danger)
#expect(KanbanDiagnosticKind.darwinZombieDetected.severity == .danger)
#expect(KanbanDiagnosticKind.heartbeatStalled.severity == .warning)
#expect(KanbanDiagnosticKind.workerExitNoComplete.severity == .warning)
#expect(KanbanDiagnosticKind.unknown.severity == .neutral)
}
@Test func createRequestArgvIncludesMaxRetries() {
let req = KanbanCreateRequest(title: "t", maxRetries: 5)
let argv = req.argv()
#expect(argv.contains("--max-retries"))
#expect(argv.contains("5"))
}
@Test func createRequestArgvOmitsMaxRetriesWhenAbsent() {
let req = KanbanCreateRequest(title: "t")
let argv = req.argv()
#expect(!argv.contains("--max-retries"))
}
@Test func decodeRunWithDiagnostics() throws {
let json = """
{
"id": 1,
"task_id": "t_x",
"status": "failed",
"started_at": 1778160000,
"ended_at": 1778160300,
"outcome": "crashed",
"error": "OOM",
"diagnostics": [
{"kind": "retry_cap_hit", "message": "3/3 retries exhausted"}
],
"failure_count": 3
}
"""
let run = try JSONDecoder().decode(HermesKanbanRun.self, from: Data(json.utf8))
#expect(run.diagnostics.count == 1)
#expect(run.diagnostics.first?.kind == "retry_cap_hit")
#expect(run.failureCount == 3)
}
@Test func decodeRunWithoutDiagnostics() throws {
// v0.12 run row no diagnostics, no failure_count, must still
// decode cleanly.
let json = """
{"id": 1, "task_id": "t_x", "status": "running", "started_at": 1778160000}
"""
let run = try JSONDecoder().decode(HermesKanbanRun.self, from: Data(json.utf8))
#expect(run.diagnostics.isEmpty)
#expect(run.failureCount == nil)
}
@Test func taskDetailMergesEnvelopeAndTaskDiagnostics() throws {
// Hermes's wire shape may put diagnostics on the task envelope OR
// on the inner task. `allDiagnostics` dedupes by (kind, detected_at)
// so a server emitting both sides doesn't surface dupes.
let json = """
{
"task": {
"id": "t_y",
"title": "y",
"status": "blocked",
"diagnostics": [
{"kind": "heartbeat_stalled", "detected_at": "2026-05-09T12:00:00Z"}
]
},
"comments": [],
"events": [],
"diagnostics": [
{"kind": "heartbeat_stalled", "detected_at": "2026-05-09T12:00:00Z"},
{"kind": "retry_cap_hit"}
]
}
"""
let detail = try JSONDecoder().decode(HermesKanbanTaskDetail.self, from: Data(json.utf8))
let merged = detail.allDiagnostics
#expect(merged.count == 2)
#expect(merged.contains(where: { $0.kind == "heartbeat_stalled" }))
#expect(merged.contains(where: { $0.kind == "retry_cap_hit" }))
}
@Test func taskDetailWithoutEnvelopeDiagnosticsDecodes() throws {
// Pre-v0.13 task detail no envelope diagnostics. Must decode.
let json = """
{
"task": {"id": "t_z", "title": "z", "status": "ready"},
"comments": [],
"events": []
}
"""
let detail = try JSONDecoder().decode(HermesKanbanTaskDetail.self, from: Data(json.utf8))
#expect(detail.envelopeDiagnostics == nil)
#expect(detail.allDiagnostics.isEmpty)
}
@Test func diagnosticDecodesUnixTimestamp() throws {
let json = """
{"kind": "spawn_failure", "detected_at": 1778160614}
"""
let diag = try JSONDecoder().decode(HermesKanbanDiagnostic.self, from: Data(json.utf8))
#expect(diag.kind == "spawn_failure")
// Decoder normalizes Unix int ISO-8601 string.
#expect(diag.detectedAt?.contains("2026") == true)
}
} }
@@ -162,6 +162,47 @@ import Foundation
// start false. // start false.
#expect(vm.supportsCompress == false) #expect(vm.supportsCompress == false)
#expect(vm.hasBroaderCommandMenu == false) #expect(vm.hasBroaderCommandMenu == false)
// v0.13: compression count starts at 0 so the SessionInfoBar chip
// stays hidden on fresh sessions.
#expect(vm.acpCompressionCount == 0)
}
@Test @MainActor func richChatTracksCompressionCountFromPromptResults() {
let vm = RichChatViewModel(context: .local)
let response = ACPPromptResult(
stopReason: "end_turn",
inputTokens: 100, outputTokens: 50,
thoughtTokens: 20, cachedReadTokens: 10,
compressionCount: 3
)
vm.handleACPEvent(.promptComplete(sessionId: "s", response: response))
#expect(vm.acpCompressionCount == 3)
// Subsequent prompts overwrite (with a max guard) the server
// emits a session-wide running total, not a per-prompt delta.
let next = ACPPromptResult(
stopReason: "end_turn",
inputTokens: 0, outputTokens: 0,
thoughtTokens: 0, cachedReadTokens: 0,
compressionCount: 5
)
vm.handleACPEvent(.promptComplete(sessionId: "s", response: next))
#expect(vm.acpCompressionCount == 5)
// A pre-v0.13 host mid-session emits 0; the max-guard keeps the
// last real value rather than snapping back.
let stale = ACPPromptResult(
stopReason: "end_turn",
inputTokens: 0, outputTokens: 0,
thoughtTokens: 0, cachedReadTokens: 0,
compressionCount: 0
)
vm.handleACPEvent(.promptComplete(sessionId: "s", response: stale))
#expect(vm.acpCompressionCount == 5)
// reset() clears the counter so a fresh session starts clean.
vm.reset()
#expect(vm.acpCompressionCount == 0)
} }
@Test @MainActor func messageGroupDerivedProperties() { @Test @MainActor func messageGroupDerivedProperties() {
@@ -0,0 +1,87 @@
import Testing
import Foundation
@testable import ScarfCore
/// Pure-function matrix for `HermesUpdaterCommandBuilder.updateArgv`. The
/// builder degrades flags silently when the connected host can't honor
/// them, so the "is the right flag emitted on the right version?" matrix
/// is the meaningful test surface.
@Suite struct M0eUpdaterTests {
// MARK: - Helpers
private func caps(_ versionLine: String?) -> HermesCapabilities {
guard let line = versionLine else { return .empty }
return HermesCapabilities.parseLine(line)
}
// MARK: - Pre-v0.12 (no flags supported)
@Test func preV012_returnsBareUpdateRegardlessOfFlags() {
let pre = caps("Hermes Agent v0.11.0 (2026.4.23)")
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: pre, unattended: false, checkOnly: false
) == ["update"])
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: pre, unattended: true, checkOnly: false
) == ["update"])
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: pre, unattended: true, checkOnly: true
) == ["update"])
}
@Test func unknownVersion_returnsBareUpdate() {
// No detected version means we can't guarantee any flag is
// honored; defensively emit the bare verb.
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: .empty, unattended: true, checkOnly: true
) == ["update"])
}
// MARK: - v0.12 (--check supported, --yes is not)
@Test func v012_checkOnly_emitsCheckFlag() {
let v012 = caps("Hermes Agent v0.12.0 (2026.4.30)")
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: v012, unattended: false, checkOnly: true
) == ["update", "--check"])
}
@Test func v012_unattended_dropsYesFlag() {
// v0.12 doesn't honor --yes; the helper degrades silently.
let v012 = caps("Hermes Agent v0.12.0 (2026.4.30)")
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: v012, unattended: true, checkOnly: false
) == ["update"])
}
@Test func v012_checkOnlyAndUnattended_emitsOnlyCheck() {
let v012 = caps("Hermes Agent v0.12.0 (2026.4.30)")
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: v012, unattended: true, checkOnly: true
) == ["update", "--check"])
}
// MARK: - v0.13 (full flag support)
@Test func v013_unattended_emitsYesFlag() {
let v013 = caps("Hermes Agent v0.13.0 (2026.5.7)")
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: v013, unattended: true, checkOnly: false
) == ["update", "--yes"])
}
@Test func v013_checkOnlyAndUnattended_emitsBothFlags() {
let v013 = caps("Hermes Agent v0.13.0 (2026.5.7)")
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: v013, unattended: true, checkOnly: true
) == ["update", "--check", "--yes"])
}
@Test func v013_neither_emitsBareUpdate() {
let v013 = caps("Hermes Agent v0.13.0 (2026.5.7)")
#expect(HermesUpdaterCommandBuilder.updateArgv(
capabilities: v013, unattended: false, checkOnly: false
) == ["update"])
}
}
@@ -249,6 +249,87 @@ import Foundation
#expect(c.timezone == "America/New_York") #expect(c.timezone == "America/New_York")
} }
// MARK: - v0.13 gateway.platforms.<platform> block
@Test func gatewayPlatformsEmptyByDefault() {
let c = HermesConfig(yaml: "")
#expect(c.gatewayPlatforms.isEmpty)
}
@Test func parsesGatewayAllowlistsForSlack() {
let yaml = """
gateway:
platforms:
slack:
allowed_channels:
- C01
- C02
busy_ack_enabled: false
gateway_restart_notification: true
slash_command_notice_ttl_seconds: 120
"""
let cfg = HermesConfig(yaml: yaml)
let block = cfg.gatewayPlatforms["slack"]
#expect(block?.allowedChannels == ["C01", "C02"])
#expect(block?.busyAckEnabled == false)
#expect(block?.gatewayRestartNotification == true)
#expect(block?.slashCommandNoticeTTLSeconds == 120)
}
@Test func parsesGatewayAllowlistsForTelegramAndMatrix() {
let yaml = """
gateway:
platforms:
telegram:
allowed_chats:
- '@alice'
- '12345'
matrix:
allowed_rooms:
- '!room:matrix.org'
"""
let cfg = HermesConfig(yaml: yaml)
#expect(cfg.gatewayPlatforms["telegram"]?.allowedChats == ["@alice", "12345"])
#expect(cfg.gatewayPlatforms["matrix"]?.allowedRooms == ["!room:matrix.org"])
}
@Test func gatewayBlockCoexistsWithLegacyPlatformBlocks() {
// Regression: legacy `platforms.slack.reply_to_mode` and
// `matrix.require_mention` must keep parsing when the new
// `gateway:` block is also present no key collisions.
let yaml = """
platforms:
slack:
reply_to_mode: all
matrix:
require_mention: false
gateway:
platforms:
slack:
allowed_channels:
- C01
"""
let cfg = HermesConfig(yaml: yaml)
#expect(cfg.slack.replyToMode == "all")
#expect(cfg.matrix.requireMention == false)
#expect(cfg.gatewayPlatforms["slack"]?.allowedChannels == ["C01"])
}
@Test func gatewayPlatformsSkipsPlatformsWithoutV013Keys() {
// The `gateway:` block exists but only Slack has a v0.13 key
// platforms without keys must NOT appear in `gatewayPlatforms`.
let yaml = """
gateway:
platforms:
slack:
busy_ack_enabled: true
"""
let cfg = HermesConfig(yaml: yaml)
#expect(cfg.gatewayPlatforms["slack"] != nil)
#expect(cfg.gatewayPlatforms["mattermost"] == nil)
#expect(cfg.gatewayPlatforms["telegram"] == nil)
}
@Test func cronScheduleMemberwise() { @Test func cronScheduleMemberwise() {
let s = CronSchedule( let s = CronSchedule(
kind: "cron", kind: "cron",
@@ -241,6 +241,150 @@ import Foundation
#expect(a == b) #expect(a == b)
} }
// MARK: - v0.13 non-interruptive commands (WS-2 / Persistent Goals + /queue)
@Test func nonInterruptiveListIncludesGoalAndQueue() {
let names = RichChatViewModel.nonInterruptiveCommands.map(\.name)
#expect(names.contains("steer"))
#expect(names.contains("goal"))
#expect(names.contains("queue"))
}
@MainActor
@Test func availableCommandsHidesGoalWhenCapabilityOff() {
let vm = RichChatViewModel(context: .local)
vm.publishCapabilities(.empty)
let names = vm.availableCommands.map(\.name)
#expect(!names.contains("goal"))
}
@MainActor
@Test func availableCommandsHidesQueueWhenCapabilityOff() {
let vm = RichChatViewModel(context: .local)
vm.publishCapabilities(.empty)
let names = vm.availableCommands.map(\.name)
#expect(!names.contains("queue"))
}
@MainActor
@Test func availableCommandsExposesAllThreeOnV013() {
let vm = RichChatViewModel(context: .local)
let caps = HermesCapabilities.parseLine("Hermes Agent v0.13.0 (2026.5.7)")
vm.publishCapabilities(caps)
let names = vm.availableCommands.map(\.name)
#expect(names.contains("steer"))
#expect(names.contains("goal"))
#expect(names.contains("queue"))
}
@MainActor
@Test func availableCommandsExposesSteerButHidesV013OnV012() {
let vm = RichChatViewModel(context: .local)
let caps = HermesCapabilities.parseLine("Hermes Agent v0.12.0 (2026.4.30)")
vm.publishCapabilities(caps)
let names = vm.availableCommands.map(\.name)
#expect(names.contains("steer"))
#expect(!names.contains("goal"))
#expect(!names.contains("queue"))
}
@Test func parseGoalArgumentRecognizesClearVariants() {
#expect(RichChatViewModel.parseGoalArgument("--clear") == .clear)
#expect(RichChatViewModel.parseGoalArgument("clear") == .clear)
#expect(RichChatViewModel.parseGoalArgument("Clear") == .clear)
#expect(RichChatViewModel.parseGoalArgument(" --clear ") == .clear)
}
@Test func parseGoalArgumentReturnsSetForArbitraryText() {
#expect(
RichChatViewModel.parseGoalArgument("finish v2.8 on time")
== .set("finish v2.8 on time")
)
// Whitespace around set text is trimmed.
#expect(
RichChatViewModel.parseGoalArgument(" ship it ")
== .set("ship it")
)
}
@Test func parseGoalArgumentReturnsEmptyForBlank() {
#expect(RichChatViewModel.parseGoalArgument("") == .empty)
#expect(RichChatViewModel.parseGoalArgument(" ") == .empty)
#expect(RichChatViewModel.parseGoalArgument("\n\t") == .empty)
}
@MainActor
@Test func recordActiveGoalSetsAndClears() {
let vm = RichChatViewModel(context: .local)
#expect(vm.activeGoal == nil)
vm.recordActiveGoal(text: "ship v2.8")
let goal = vm.activeGoal
#expect(goal?.text == "ship v2.8")
vm.recordActiveGoal(text: nil)
#expect(vm.activeGoal == nil)
// Empty / whitespace also clears.
vm.recordActiveGoal(text: "x")
vm.recordActiveGoal(text: " ")
#expect(vm.activeGoal == nil)
}
@MainActor
@Test func recordQueuedPromptAppendsAndPopsFIFO() {
let vm = RichChatViewModel(context: .local)
vm.recordQueuedPrompt(text: "first")
vm.recordQueuedPrompt(text: "second")
vm.recordQueuedPrompt(text: "third")
#expect(vm.queuedPrompts.count == 3)
let popped = vm.popQueuedPrompt()
#expect(popped?.text == "first")
#expect(vm.queuedPrompts.count == 2)
let next = vm.popQueuedPrompt()
#expect(next?.text == "second")
#expect(vm.queuedPrompts.first?.text == "third")
}
@MainActor
@Test func recordQueuedPromptIgnoresBlank() {
let vm = RichChatViewModel(context: .local)
vm.recordQueuedPrompt(text: "")
vm.recordQueuedPrompt(text: " ")
#expect(vm.queuedPrompts.isEmpty)
}
@MainActor
@Test func popQueuedPromptOnEmptyReturnsNil() {
let vm = RichChatViewModel(context: .local)
#expect(vm.popQueuedPrompt() == nil)
}
@Test func isNonInterruptiveSlashRecognizesGoalAndQueue() {
// Non-MainActor: the helper itself isn't MainActor-isolated;
// construct a VM on MainActor and read through it on the test
// actor to keep the assertion focused on classification.
Task { @MainActor in
let vm = RichChatViewModel(context: .local)
#expect(vm.isNonInterruptiveSlash("/goal finish v2.8"))
#expect(vm.isNonInterruptiveSlash("/queue summarize"))
#expect(vm.isNonInterruptiveSlash("/queue"))
#expect(vm.isNonInterruptiveSlash("/steer be careful"))
#expect(!vm.isNonInterruptiveSlash("hello"))
#expect(!vm.isNonInterruptiveSlash("/compress"))
}
}
@MainActor
@Test func resetClearsGoalAndQueue() {
let vm = RichChatViewModel(context: .local)
vm.recordActiveGoal(text: "x")
vm.recordQueuedPrompt(text: "a")
vm.recordQueuedPrompt(text: "b")
#expect(vm.activeGoal != nil)
#expect(vm.queuedPrompts.count == 2)
vm.reset()
#expect(vm.activeGoal == nil)
#expect(vm.queuedPrompts.isEmpty)
}
// MARK: - Helpers // MARK: - Helpers
static func makeTempProject() throws -> String { static func makeTempProject() throws -> String {
@@ -242,6 +242,15 @@ import Foundation
thoughtTokens: 20, cachedReadTokens: 10 thoughtTokens: 20, cachedReadTokens: 10
) )
#expect(prompt.stopReason == "end_turn") #expect(prompt.stopReason == "end_turn")
// v0.13: compressionCount has a 0 default for legacy callers.
#expect(prompt.compressionCount == 0)
let v013Prompt = ACPPromptResult(
stopReason: "end_turn", inputTokens: 0, outputTokens: 0,
thoughtTokens: 0, cachedReadTokens: 0,
compressionCount: 7
)
#expect(v013Prompt.compressionCount == 7)
} }
@Test func projectDashboardInitChain() { @Test func projectDashboardInitChain() {
+188 -36
View File
@@ -44,6 +44,19 @@ struct ChatView: View {
private var supportsImagePrompts: Bool { private var supportsImagePrompts: Bool {
capabilitiesStore?.capabilities.hasACPImagePrompts ?? false capabilitiesStore?.capabilities.hasACPImagePrompts ?? false
} }
/// v0.13 `/goal` capability drives the goal pill in `projectContextBar`.
/// Read-only on iOS in v2.8.0; users send `/goal` from the Mac. The pill
/// drops automatically when `vm.activeGoal` clears.
private var supportsActiveGoal: Bool {
capabilitiesStore?.capabilities.hasGoals ?? false
}
/// v0.13 ACP `/queue` capability drives the queue-count chip. Tap is a
/// no-op in v2.8.0 (no popover); previews live on the Mac app.
private var supportsACPQueue: Bool {
capabilitiesStore?.capabilities.hasACPQueue ?? false
}
/// Drives the composer's keyboard. Bound to the TextField via /// Drives the composer's keyboard. Bound to the TextField via
/// `.focused(...)`; cleared by the scroll-to-dismiss gesture on /// `.focused(...)`; cleared by the scroll-to-dismiss gesture on
/// the message list AND by an explicit keyboard-toolbar button. /// the message list AND by an explicit keyboard-toolbar button.
@@ -109,6 +122,17 @@ struct ChatView: View {
} }
) )
} }
// Forward the env-injected capabilities snapshot into the
// shared `RichChatViewModel` whenever it changes. Drives the
// capability gate `RichChatViewModel.availableCommands` reads.
// Mirrors the Mac `ChatView` plumbing the iOS chat surface
// doesn't render `/goal` / `/queue` UI yet (deferred to WS-9),
// but the VM-side state has to stay aligned across platforms
// so the Mac surface is correct after a cross-device session
// resume.
.task(id: capabilitiesStore?.capabilities.versionLine ?? "") {
controller.vm.publishCapabilities(capabilitiesStore?.capabilities ?? .empty)
}
.task { .task {
// Dashboard row taps set `pendingResumeSessionID`, Project // Dashboard row taps set `pendingResumeSessionID`, Project
// Detail's "New Chat" sets `pendingProjectChat`. Both fire // Detail's "New Chat" sets `pendingProjectChat`. Both fire
@@ -830,37 +854,47 @@ struct ChatView: View {
/// informational. /// informational.
@ViewBuilder @ViewBuilder
private var projectContextBar: some View { private var projectContextBar: some View {
if let projectName = controller.currentProjectName, // v2.8.0 (WS-9): the bar is no longer project-only a non-empty
!projectName.isEmpty // active goal OR a non-empty queue mirror also light it up. Project
{ // chip, goal pill, and queue chip render independently and the bar
// shows when ANY of them is present.
let projectName = controller.currentProjectName ?? ""
let hasProject = !projectName.isEmpty
let hasGoal = supportsActiveGoal && controller.vm.activeGoal != nil
let hasQueue = supportsACPQueue && !controller.vm.queuedPrompts.isEmpty
if hasProject || hasGoal || hasQueue {
HStack(spacing: 8) { HStack(spacing: 8) {
Image(systemName: "folder.fill") if hasProject {
.foregroundStyle(.tint) Image(systemName: "folder.fill")
.font(.caption) .foregroundStyle(.tint)
VStack(alignment: .leading, spacing: 1) { .font(.caption)
Text("Project chat") VStack(alignment: .leading, spacing: 1) {
.font(.caption2) Text("Project chat")
.foregroundStyle(ScarfColor.foregroundMuted) .font(.caption2)
HStack(spacing: 6) { .foregroundStyle(ScarfColor.foregroundMuted)
Text(projectName) HStack(spacing: 6) {
.font(.callout.weight(.medium)) Text(projectName)
.foregroundStyle(.primary) .font(.callout.weight(.medium))
.lineLimit(1) .foregroundStyle(.primary)
.truncationMode(.tail)
if let branch = controller.currentGitBranch, !branch.isEmpty {
Label(branch, systemImage: "arrow.triangle.branch")
.font(.caption2)
.foregroundStyle(.tint)
.labelStyle(.titleAndIcon)
.padding(.horizontal, 5)
.padding(.vertical, 1)
.background(.tint.opacity(0.15), in: Capsule())
.lineLimit(1) .lineLimit(1)
.truncationMode(.tail)
if let branch = controller.currentGitBranch, !branch.isEmpty {
Label(branch, systemImage: "arrow.triangle.branch")
.font(.caption2)
.foregroundStyle(.tint)
.labelStyle(.titleAndIcon)
.padding(.horizontal, 5)
.padding(.vertical, 1)
.background(.tint.opacity(0.15), in: Capsule())
.lineLimit(1)
}
} }
} }
} }
if hasGoal { goalChip }
if hasQueue { queueChip }
Spacer() Spacer()
if !controller.vm.projectScopedCommands.isEmpty { if hasProject && !controller.vm.projectScopedCommands.isEmpty {
Button { Button {
showSlashCommandsSheet = true showSlashCommandsSheet = true
} label: { } label: {
@@ -882,6 +916,8 @@ struct ChatView: View {
.padding(.vertical, 6) .padding(.vertical, 6)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.background(.tint.opacity(0.1)) .background(.tint.opacity(0.1))
.animation(.spring(response: 0.3, dampingFraction: 0.75), value: hasGoal)
.animation(.spring(response: 0.3, dampingFraction: 0.75), value: hasQueue)
.sheet(isPresented: $showSlashCommandsSheet) { .sheet(isPresented: $showSlashCommandsSheet) {
ProjectSlashCommandsBrowser( ProjectSlashCommandsBrowser(
projectName: projectName, projectName: projectName,
@@ -891,6 +927,55 @@ struct ChatView: View {
} }
} }
/// v0.13 goal pill purely informational mirror of the agent's
/// currently-locked `/goal`. Read-only on iOS; `/goal --clear` lives on
/// the Mac app and the pill drops on the next VM update. Semantic
/// `.subheadline` font so the goal text scales with Dynamic Type
/// (it's content the user reads, not chrome). VoiceOver gets the full
/// untruncated text via the accessibility label.
@ViewBuilder
private var goalChip: some View {
if let goal = controller.vm.activeGoal {
Label(truncatedGoalText(goal.text), systemImage: "scope")
.labelStyle(.titleAndIcon)
.font(.subheadline)
.foregroundStyle(ScarfColor.info)
.padding(.horizontal, 8)
.padding(.vertical, 3)
.background(ScarfColor.info.opacity(0.16), in: Capsule())
.lineLimit(1)
.accessibilityLabel("Goal locked: \(goal.text)")
.transition(.opacity.combined(with: .scale(scale: 0.92)))
}
}
/// v0.13 queue chip read-only count of prompts queued via `/queue`.
/// Tap is a no-op in v2.8.0 (no popover); the source of truth lives on
/// the Mac app. Defaults to one fixed pill regardless of count.
@ViewBuilder
private var queueChip: some View {
let count = controller.vm.queuedPrompts.count
if count > 0 {
Label("\(count) queued", systemImage: "tray.full")
.labelStyle(.titleAndIcon)
.font(.caption.weight(.medium))
.foregroundStyle(.tint)
.padding(.horizontal, 8)
.padding(.vertical, 3)
.background(.tint.opacity(0.18), in: Capsule())
.lineLimit(1)
.accessibilityLabel("\(count) prompt\(count == 1 ? "" : "s") queued — manage on the Mac app")
.transition(.opacity.combined(with: .scale(scale: 0.92)))
}
}
/// Trim long goal text to fit a chip beside the project name on iPhone
/// portrait. The full text rides VoiceOver via the chip's accessibility
/// label.
private func truncatedGoalText(_ text: String) -> String {
text.count <= 28 ? text : String(text.prefix(25)) + ""
}
/// Shown while we're opening the SSH exec channel + spawning /// Shown while we're opening the SSH exec channel + spawning
/// `hermes acp` + creating the ACP session. Typically ~0.51.5 s /// `hermes acp` + creating the ACP session. Typically ~0.51.5 s
/// on a warm network silent before this overlay existed, which /// on a warm network silent before this overlay existed, which
@@ -1307,18 +1392,48 @@ final class ChatController {
// even when they didn't type any caption. // even when they didn't type any caption.
vm.addUserMessage(text: "[image attached]") vm.addUserMessage(text: "[image attached]")
} }
// /steer is non-interruptive the agent is still on its // Non-interruptive slash commands: keep the chat working
// current turn; the guidance applies after the next tool call. // indicator off and surface a transient toast confirming the
// Surface a transient toast confirming the guidance was // command was accepted. v2.5 added `/steer`; v2.8 / Hermes
// received. v2.5 / Hermes v2026.4.23+. // v0.13 adds `/goal` (lock the agent on a target across
if vm.isNonInterruptiveSlash(text) { // turns) and `/queue` (queue a prompt for after the current
vm.transientHint = "Guidance queued — applies after the next tool call." // turn). Each gets its own optimistic side-effect on the VM
Task { @MainActor [weak vm] in // so the (Mac-rendered) chat header pill / queue chip update
try? await Task.sleep(nanoseconds: 4_000_000_000) // synchronously. iOS doesn't surface those affordances yet
if vm?.transientHint == "Guidance queued — applies after the next tool call." { // (WS-9), but mirroring the dispatch keeps the shared VM
vm?.transientHint = nil // state aligned across platforms otherwise an iOS user who
} // ran `/goal` then opened the same session on Mac would see
// an empty pill until they typed `/goal` again.
let parsedSlash = Self.parseSlashName(text)
switch parsedSlash.name {
case "goal":
// TODO(WS-2-Q7): verify on a real v0.13 host.
let arg = RichChatViewModel.parseGoalArgument(parsedSlash.args)
switch arg {
case .set(let goalText):
vm.recordActiveGoal(text: goalText)
vm.transientHint = "Goal locked: \(Self.truncatedToastGoal(goalText))"
case .clear:
vm.recordActiveGoal(text: nil)
vm.transientHint = "Goal cleared."
case .empty:
vm.transientHint = "Sent /goal — see the agent reply for current goal."
} }
scheduleTransientHintClear(snapshot: vm.transientHint)
case "queue":
// TODO(WS-2-Q5): verify the verbatim wire shape on a
// real v0.13 ACP host.
let queuedText = parsedSlash.args.trimmingCharacters(in: .whitespacesAndNewlines)
if !queuedText.isEmpty {
vm.recordQueuedPrompt(text: queuedText)
}
vm.transientHint = "Queued — runs after current turn."
scheduleTransientHintClear(snapshot: vm.transientHint)
case "steer" where vm.isNonInterruptiveSlash(text):
vm.transientHint = "Guidance queued — applies after the next tool call."
scheduleTransientHintClear(snapshot: vm.transientHint)
default:
break
} }
// Project-scoped slash commands expand client-side: the user // Project-scoped slash commands expand client-side: the user
// bubble shows the literal `/<name> args` they typed (above); // bubble shows the literal `/<name> args` they typed (above);
@@ -1341,6 +1456,43 @@ final class ChatController {
} }
} }
/// Pull `(name, argTail)` out of a `/<name> [args]` invocation.
/// Mirror of `ChatViewModel.parseSlashName` on Mac. Returns
/// `(nil, "")` for non-slash input.
static func parseSlashName(_ text: String) -> (name: String?, args: String) {
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
guard trimmed.hasPrefix("/") else { return (nil, "") }
let withoutSlash = trimmed.dropFirst()
if let space = withoutSlash.firstIndex(of: " ") {
return (
name: String(withoutSlash[..<space]),
args: String(withoutSlash[withoutSlash.index(after: space)...])
)
}
return (name: String(withoutSlash), args: "")
}
/// Cap goal text in transient toasts so a 1 KB user-typed goal
/// doesn't blow out the hint pill. Mirror of
/// `ChatViewModel.truncatedToastGoal`.
static func truncatedToastGoal(_ text: String) -> String {
text.count <= 60 ? text : String(text.prefix(57)) + ""
}
/// Auto-clear the chat composer's transient hint after 4s. Mirror
/// of `ChatViewModel.scheduleHintClear` uses a value snapshot
/// rather than identity so a later toast that reuses the same
/// string still triggers the clear once the latest value matches.
@MainActor
private func scheduleTransientHintClear(snapshot: String?) {
Task { @MainActor [weak vm] in
try? await Task.sleep(nanoseconds: 4_000_000_000)
if vm?.transientHint == snapshot {
vm?.transientHint = nil
}
}
}
/// Mirror of `ChatViewModel.expandIfProjectScoped(_:)` on Mac. /// Mirror of `ChatViewModel.expandIfProjectScoped(_:)` on Mac.
/// `/<name> args` matching a loaded project-scoped command is /// `/<name> args` matching a loaded project-scoped command is
/// expanded; everything else is sent literally. /// expanded; everything else is sent literally.
+82 -2
View File
@@ -13,11 +13,21 @@ import ScarfDesign
/// `HermesCapabilities.hasCurator` is true. /// `HermesCapabilities.hasCurator` is true.
struct CuratorView: View { struct CuratorView: View {
@State private var viewModel: CuratorViewModel @State private var viewModel: CuratorViewModel
@Environment(\.hermesCapabilities) private var capabilitiesStore
init(context: ServerContext) { init(context: ServerContext) {
_viewModel = State(initialValue: CuratorViewModel(context: context)) _viewModel = State(initialValue: CuratorViewModel(context: context))
} }
/// v0.13 capability gate. Drives both the synchronous `runNow`
/// blocking-with-spinner behavior AND the read-only Archived
/// section. Pre-v0.13 hosts skip the archive load entirely so we
/// don't spam `hermes curator list-archived` against a binary that
/// would error out.
private var archiveAvailable: Bool {
capabilitiesStore?.capabilities.hasCuratorArchive ?? false
}
var body: some View { var body: some View {
List { List {
Section { Section {
@@ -78,18 +88,88 @@ struct CuratorView: View {
.textSelection(.enabled) .textSelection(.enabled)
} }
} }
if archiveAvailable {
archivedSection
}
} }
.navigationTitle("Curator") .navigationTitle("Curator")
.navigationBarTitleDisplayMode(.large) .navigationBarTitleDisplayMode(.large)
.refreshable { .refreshable {
await viewModel.load() await viewModel.load()
if archiveAvailable {
await viewModel.loadArchive()
}
} }
.overlay(alignment: .bottom) { .overlay(alignment: .bottom) {
if let toast = viewModel.transientMessage { if let toast = viewModel.transientMessage {
toastView(toast) toastView(toast)
} }
} }
.task { await viewModel.load() } .task {
await viewModel.load()
if archiveAvailable {
await viewModel.loadArchive()
}
}
}
/// v0.13 read-only Archived list. iOS doesn't expose Restore /
/// Prune-this / Prune-all that's a Mac-only surface in v2.8.0.
/// The footer signposts the user to the Mac app when there are
/// rows to act on.
@ViewBuilder
private var archivedSection: some View {
Section {
if viewModel.archivedSkills.isEmpty {
Text("No archived skills — Curator will move stale skills here after the next review cycle.")
.font(.callout)
.foregroundStyle(.secondary)
} else {
ForEach(viewModel.archivedSkills) { skill in
archivedRow(skill)
}
}
} header: {
Text("Archived")
} footer: {
if !viewModel.archivedSkills.isEmpty {
Text("Restore or prune archived skills from the Mac app.")
.font(.caption)
}
}
}
@ViewBuilder
private func archivedRow(_ skill: HermesCuratorArchivedSkill) -> some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(skill.name)
.font(.body)
.lineLimit(1)
Spacer()
if let category = skill.category, !category.isEmpty {
ScarfBadge(category, kind: .neutral)
}
}
HStack(spacing: 6) {
if let reason = skill.reason, !reason.isEmpty {
Text(reason)
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(2)
}
Spacer()
Text(skill.archivedAtLabel)
.font(.caption2)
.foregroundStyle(.tertiary)
}
if let size = skill.sizeBytes, size > 0 {
Text(skill.sizeLabel)
.font(.caption2)
.foregroundStyle(.tertiary)
}
}
} }
private var statusRow: some View { private var statusRow: some View {
@@ -115,7 +195,7 @@ struct CuratorView: View {
private var actionFooter: some View { private var actionFooter: some View {
HStack(spacing: 8) { HStack(spacing: 8) {
Button { Button {
Task { await viewModel.runNow() } Task { await viewModel.runNow(synchronous: archiveAvailable, timeout: 600) }
} label: { } label: {
Label("Run now", systemImage: "play.fill") Label("Run now", systemImage: "play.fill")
} }
@@ -0,0 +1,86 @@
import SwiftUI
import ScarfCore
import ScarfDesign
/// iOS substitute for the Mac inspector's `.help()` tooltip on a Kanban
/// diagnostic chip. iOS doesn't have hover, so each diagnostic chip in
/// the detail sheet is tappable; tap presents this sheet with the kind,
/// severity, server-supplied message, and detection timestamp.
///
/// Read-only there are no recovery actions on iOS in v2.8.0. The
/// surface is deliberately small (one screen, no scroll padding) so it
/// reads as a fast peek rather than a full editor.
struct DiagnosticDetailSheet: View {
let diagnostic: HermesKanbanDiagnostic
@Environment(\.dismiss) private var dismiss
var body: some View {
NavigationStack {
List {
Section {
LabeledContent("Kind") {
Text(diagnostic.kind)
.font(.body.monospaced())
.foregroundStyle(.primary)
}
LabeledContent("Severity") {
ScarfBadge(severityLabel, kind: severityBadgeKind)
}
if let detectedAt = diagnostic.detectedAt, !detectedAt.isEmpty {
LabeledContent("Detected at") {
Text(detectedAt)
.font(.caption.monospaced())
.foregroundStyle(.secondary)
}
}
} header: {
Text("Diagnostic")
}
if let message = diagnostic.message, !message.isEmpty {
Section {
Text(message)
.font(.body)
.textSelection(.enabled)
} header: {
Text("Message")
}
}
Section {
Label("Recovery actions live on the Mac app — open this task there to verify, reject, or unblock.", systemImage: "info.circle")
.font(.caption)
.foregroundStyle(.secondary)
}
}
.scrollContentBackground(.hidden)
.background(ScarfColor.backgroundPrimary)
.navigationTitle("Diagnostic")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Done") { dismiss() }
}
}
}
}
private var severityLabel: String {
let kind = KanbanDiagnosticKind.from(diagnostic.kind)
switch kind.severity {
case .danger: return "danger"
case .warning: return "warning"
case .neutral: return "neutral"
}
}
private var severityBadgeKind: ScarfBadgeKind {
let kind = KanbanDiagnosticKind.from(diagnostic.kind)
switch kind.severity {
case .danger: return .danger
case .warning: return .warning
case .neutral: return .neutral
}
}
}
@@ -15,12 +15,14 @@ struct ScarfGoKanbanDetailSheet: View {
let context: ServerContext let context: ServerContext
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@Environment(\.hermesCapabilities) private var capabilitiesStore
@State private var detail: HermesKanbanTaskDetail? @State private var detail: HermesKanbanTaskDetail?
@State private var runs: [HermesKanbanRun] = [] @State private var runs: [HermesKanbanRun] = []
@State private var isLoading = true @State private var isLoading = true
@State private var error: String? @State private var error: String?
@State private var selectedTab: DetailTab = .comments @State private var selectedTab: DetailTab = .comments
@State private var selectedDiagnostic: HermesKanbanDiagnostic?
enum DetailTab: String, CaseIterable, Identifiable { enum DetailTab: String, CaseIterable, Identifiable {
case comments = "Comments" case comments = "Comments"
@@ -29,6 +31,13 @@ struct ScarfGoKanbanDetailSheet: View {
var id: String { rawValue } var id: String { rawValue }
} }
/// v0.13 capability gate. Defensive default `false` when no
/// capabilities store is present (preview / smoke harness) so the
/// sheet renders the v2.7.5 layout unchanged.
private var diagnosticsAvailable: Bool {
capabilitiesStore?.capabilities.hasKanbanDiagnostics ?? false
}
var body: some View { var body: some View {
NavigationStack { NavigationStack {
content content
@@ -41,6 +50,9 @@ struct ScarfGoKanbanDetailSheet: View {
} }
} }
.task(id: taskId) { await load() } .task(id: taskId) { await load() }
.sheet(item: $selectedDiagnostic) { diag in
DiagnosticDetailSheet(diagnostic: diag)
}
} }
@ViewBuilder @ViewBuilder
@@ -62,6 +74,8 @@ struct ScarfGoKanbanDetailSheet: View {
ScrollView { ScrollView {
VStack(alignment: .leading, spacing: 16) { VStack(alignment: .leading, spacing: 16) {
headerCard(detail.task) headerCard(detail.task)
hallucinationBadge(detail.task)
autoBlockedBanner(detail.task)
if let body = detail.task.body, !body.isEmpty { if let body = detail.task.body, !body.isEmpty {
if let attributed = try? AttributedString(markdown: body) { if let attributed = try? AttributedString(markdown: body) {
Text(attributed) Text(attributed)
@@ -71,6 +85,9 @@ struct ScarfGoKanbanDetailSheet: View {
.font(.body) .font(.body)
} }
} }
if diagnosticsAvailable, !detail.task.diagnostics.isEmpty {
diagnosticsBlock(detail.task.diagnostics, label: "Diagnostics")
}
Picker("Section", selection: $selectedTab) { Picker("Section", selection: $selectedTab) {
ForEach(DetailTab.allCases) { tab in ForEach(DetailTab.allCases) { tab in
Text(tab.rawValue).tag(tab) Text(tab.rawValue).tag(tab)
@@ -90,7 +107,9 @@ struct ScarfGoKanbanDetailSheet: View {
private func headerCard(_ task: HermesKanbanTask) -> some View { private func headerCard(_ task: HermesKanbanTask) -> some View {
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 6) { // Wrap chips in FlowLayout so the new v0.13 `retries` chip
// doesn't push the row over the iPhone-portrait width budget.
FlowLayout(spacing: 6) {
ScarfBadge(task.status.lowercased(), kind: badgeKind(for: task.status)) ScarfBadge(task.status.lowercased(), kind: badgeKind(for: task.status))
if let assignee = task.assignee, !assignee.isEmpty { if let assignee = task.assignee, !assignee.isEmpty {
ScarfBadge(assignee, kind: .neutral) ScarfBadge(assignee, kind: .neutral)
@@ -101,6 +120,10 @@ struct ScarfGoKanbanDetailSheet: View {
if let tenant = task.tenant, !tenant.isEmpty { if let tenant = task.tenant, !tenant.isEmpty {
ScarfBadge(tenant, kind: .brand) ScarfBadge(tenant, kind: .brand)
} }
if diagnosticsAvailable, let maxRetries = task.maxRetries {
ScarfBadge("retries: \(maxRetries)", kind: .neutral)
.accessibilityLabel("Max retries \(maxRetries)")
}
} }
if let priority = task.priority { if let priority = task.priority {
Text("Priority \(priority)") Text("Priority \(priority)")
@@ -110,6 +133,100 @@ struct ScarfGoKanbanDetailSheet: View {
} }
} }
/// v0.13 hallucination gate. Worker-created cards land in the
/// `pending` state until a human verifies Mac surfaces a Verify /
/// Reject button pair; iOS in v2.8.0 stays read-only and points
/// the user to the Mac app via the badge copy.
@ViewBuilder
private func hallucinationBadge(_ task: HermesKanbanTask) -> some View {
if diagnosticsAvailable,
KanbanHallucinationGate.from(task.hallucinationGateStatus) == .pending {
HStack(spacing: 6) {
Image(systemName: "questionmark.diamond.fill")
.foregroundStyle(ScarfColor.warning)
Text("Worker-created — verify on Mac")
.font(.subheadline)
.foregroundStyle(ScarfColor.warning)
}
.padding(.horizontal, 10)
.padding(.vertical, 6)
.background(
ScarfColor.warning.opacity(0.10),
in: RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
)
.overlay(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.strokeBorder(ScarfColor.warning.opacity(0.4), lineWidth: 1)
)
.accessibilityHint("Open this task on the Mac app to verify or reject the worker's claim.")
}
}
/// v0.13 auto-blocked banner. Surfaces `auto_blocked_reason` verbatim
/// when Hermes auto-blocks a task (retry cap hit, repeated tool
/// errors, etc.). Server-supplied copy render verbatim.
@ViewBuilder
private func autoBlockedBanner(_ task: HermesKanbanTask) -> some View {
if diagnosticsAvailable,
KanbanStatus.from(task.status) == .blocked,
let reason = task.autoBlockedReason, !reason.isEmpty {
HStack(alignment: .top, spacing: 8) {
Image(systemName: "exclamationmark.octagon.fill")
.foregroundStyle(ScarfColor.danger)
VStack(alignment: .leading, spacing: 2) {
Text("Auto-blocked")
.font(.subheadline.weight(.semibold))
.foregroundStyle(ScarfColor.danger)
Text(reason)
.font(.subheadline)
.foregroundStyle(.secondary)
}
}
.padding(10)
.frame(maxWidth: .infinity, alignment: .leading)
.background(
ScarfColor.danger.opacity(0.08),
in: RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
)
}
}
/// Tap-target diagnostic chip list. iOS substitute for the Mac
/// inspector's `.help()` tooltip chips are tappable, tap presents
/// `DiagnosticDetailSheet` with the full message + timestamp.
@ViewBuilder
private func diagnosticsBlock(_ diags: [HermesKanbanDiagnostic], label: String) -> some View {
VStack(alignment: .leading, spacing: 6) {
Text(label)
.font(.caption.weight(.semibold))
.foregroundStyle(.secondary)
FlowLayout(spacing: 6) {
ForEach(diags) { diag in
Button {
selectedDiagnostic = diag
} label: {
ScarfBadge(diag.kind, kind: diagnosticBadgeKind(diag))
}
.buttonStyle(.plain)
.accessibilityLabel(diag.message ?? diag.kind)
.accessibilityHint("Tap to see the full diagnostic message and timestamp.")
}
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}
/// Maps the typed `KanbanDiagnosticKind.severity` enum into the
/// `ScarfBadgeKind` palette. Mirrors the Mac inspector's
/// `diagnosticBadge` helper so the two surfaces tint identically.
private func diagnosticBadgeKind(_ diag: HermesKanbanDiagnostic) -> ScarfBadgeKind {
switch KanbanDiagnosticKind.from(diag.kind).severity {
case .danger: return .danger
case .warning: return .warning
case .neutral: return .neutral
}
}
private func commentsSection(_ comments: [HermesKanbanComment]) -> some View { private func commentsSection(_ comments: [HermesKanbanComment]) -> some View {
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: 8) {
if comments.isEmpty { if comments.isEmpty {
@@ -194,6 +311,10 @@ struct ScarfGoKanbanDetailSheet: View {
.font(.caption) .font(.caption)
.foregroundStyle(.red) .foregroundStyle(.red)
} }
if diagnosticsAvailable, !run.diagnostics.isEmpty {
diagnosticsBlock(run.diagnostics, label: "Run diagnostics")
.padding(.top, 4)
}
} }
.padding(8) .padding(8)
.background(ScarfColor.backgroundSecondary.opacity(0.4)) .background(ScarfColor.backgroundSecondary.opacity(0.4))
+154
View File
@@ -13,6 +13,7 @@ struct SettingsView: View {
@State private var vm: IOSSettingsViewModel @State private var vm: IOSSettingsViewModel
@State private var showRawYAML = false @State private var showRawYAML = false
@State private var editingSpec: SettingSpec? @State private var editingSpec: SettingSpec?
@State private var showV013FeaturesSheet = false
/// v2.7 Scarf-local opt-in to bulk-fetch tool result CONTENT /// v2.7 Scarf-local opt-in to bulk-fetch tool result CONTENT
/// when resuming past chats. Default off; the shared /// when resuming past chats. Default off; the shared
/// `RichChatViewModel` reads this same UserDefaults key on /// `RichChatViewModel` reads this same UserDefaults key on
@@ -21,6 +22,16 @@ struct SettingsView: View {
@AppStorage(RichChatViewModel.loadHistoricalToolResultsKey) @AppStorage(RichChatViewModel.loadHistoricalToolResultsKey)
private var loadHistoricalToolResults: Bool = false private var loadHistoricalToolResults: Bool = false
/// Drives v0.13 read-only surfaces (features-active badge,
/// platforms-section additions). Defensive `?? .empty` resolves
/// every gate to `false` outside `ContextBoundRoot` (preview /
/// smoke harness) so the v2.7.5 layout is the unconditional
/// fallback.
@Environment(\.hermesCapabilities) private var capabilitiesStore
private var caps: HermesCapabilities {
capabilitiesStore?.capabilities ?? .empty
}
private static let sharedContextID: ServerID = ServerID( private static let sharedContextID: ServerID = ServerID(
uuidString: "00000000-0000-0000-0000-0000000000A1" uuidString: "00000000-0000-0000-0000-0000000000A1"
)! )!
@@ -40,6 +51,10 @@ struct SettingsView: View {
} }
} }
if caps.isV013OrLater {
v013ActiveBadgeSection
}
if !vm.isLoading || vm.config.model != "unknown" { if !vm.isLoading || vm.config.model != "unknown" {
quickEditsSection quickEditsSection
modelSection modelSection
@@ -79,6 +94,35 @@ struct SettingsView: View {
onDismiss: {} onDismiss: {}
) )
} }
.sheet(isPresented: $showV013FeaturesSheet) {
V013FeaturesSheet()
}
}
/// v0.13 features-active badge. Only shown when the connected host
/// is on the v0.13 line; tap presents `V013FeaturesSheet`. Read-only
/// there's no settings change behind the badge, just a
/// what's-new affordance.
@ViewBuilder
private var v013ActiveBadgeSection: some View {
Section {
Button {
showV013FeaturesSheet = true
} label: {
HStack(spacing: 8) {
ScarfBadge("v0.13 features active", kind: .success)
Spacer()
Text("Learn more")
.font(.caption)
.foregroundStyle(.tint)
Image(systemName: "chevron.right")
.font(.caption)
.foregroundStyle(.tertiary)
}
}
.buttonStyle(.plain)
}
.listRowBackground(ScarfColor.success.opacity(0.06))
} }
@ViewBuilder @ViewBuilder
@@ -284,9 +328,119 @@ struct SettingsView: View {
yesNoRow("Telegram: require mention", vm.config.telegram.requireMention) yesNoRow("Telegram: require mention", vm.config.telegram.requireMention)
LabeledContent("Slack: reply mode", value: vm.config.slack.replyToMode) LabeledContent("Slack: reply mode", value: vm.config.slack.replyToMode)
yesNoRow("Matrix: require mention", vm.config.matrix.requireMention) yesNoRow("Matrix: require mention", vm.config.matrix.requireMention)
// v0.13 additions: each is independently capability-gated
// and read-only on iOS in v2.8.0. Editing lives on Mac.
if caps.hasGoogleChatPlatform {
LabeledContent("Google Chat", value: googleChatStatusLabel)
}
if caps.hasGatewayBusyAckToggle {
gatewayBusyAckRow
}
if caps.hasGatewayRestartNotification {
gatewayRestartNotificationRow
}
if caps.hasGatewayAllowlists {
gatewayAllowlistsRows
}
} }
} }
/// v0.13 Google Chat status. Whether the platform shows up at all
/// is driven by whether `gateway.platforms.google-chat.*` exists in
/// config.yaml on the remote if absent, we render "Not configured".
/// Hermes accepts either `google-chat` or `googlechat` as the
/// identifier; check both spellings defensively.
private var googleChatStatusLabel: String {
if vm.config.gatewayPlatforms["google-chat"] != nil
|| vm.config.gatewayPlatforms["googlechat"] != nil {
return "configured"
}
return "not configured"
}
/// v0.13 cross-platform busy-ack toggle. We summarize per platform
/// so users on iOS get a faithful read of the per-platform flag
/// "off on slack, on elsewhere" is a real configuration shape.
/// Empty `gatewayPlatforms` shows "default".
@ViewBuilder
private var gatewayBusyAckRow: some View {
let value = summariseGatewayBool(\GatewayPlatformSettings.busyAckEnabled, defaultLabel: "on")
LabeledContent("Gateway: busy ack", value: value)
}
@ViewBuilder
private var gatewayRestartNotificationRow: some View {
let value = summariseGatewayBool(\GatewayPlatformSettings.gatewayRestartNotification, defaultLabel: "off")
LabeledContent("Gateway: restart notification", value: value)
}
/// Render a per-key summary across `gatewayPlatforms`. When all
/// configured platforms agree on the same value we show a single
/// "yes" / "no". When they disagree we show "mixed (N platforms)"
/// to nudge the user to the Mac app for the per-platform detail.
private func summariseGatewayBool(
_ keyPath: KeyPath<GatewayPlatformSettings, Bool>,
defaultLabel: String
) -> String {
let values = vm.config.gatewayPlatforms.values.map { $0[keyPath: keyPath] }
guard !values.isEmpty else { return defaultLabel + " (default)" }
let allTrue = values.allSatisfy { $0 }
let allFalse = values.allSatisfy { !$0 }
if allTrue { return "yes" }
if allFalse { return "no" }
return "mixed (\(values.count) platforms)"
}
/// v0.13 cross-platform allowlist summaries. Each kind
/// (channels / chats / rooms) renders as a DisclosureGroup with the
/// total count in the label and a flat list of "platform: id" rows
/// when expanded. iPhone-friendly: collapsed by default so the
/// section stays compact.
@ViewBuilder
private var gatewayAllowlistsRows: some View {
gatewayAllowlistDisclosure(kind: .channels)
gatewayAllowlistDisclosure(kind: .chats)
gatewayAllowlistDisclosure(kind: .rooms)
}
@ViewBuilder
private func gatewayAllowlistDisclosure(kind: GatewayAllowlistKind) -> some View {
let entries = gatewayAllowlistEntries(kind: kind)
if !entries.isEmpty {
DisclosureGroup {
ForEach(entries, id: \.self) { entry in
Text(entry)
.font(.caption.monospaced())
.foregroundStyle(.secondary)
.lineLimit(1)
.truncationMode(.middle)
}
} label: {
LabeledContent("Allowed \(kind.pluralNoun)") {
Text("\(entries.count)")
.font(.callout)
.foregroundStyle(.secondary)
}
}
}
}
/// Flatten the per-platform allowlists for `kind` across every
/// configured platform. Each entry is rendered as
/// `"platformName: id"` so the user sees which platform the id
/// belongs to without an extra DisclosureGroup level.
private func gatewayAllowlistEntries(kind: GatewayAllowlistKind) -> [String] {
var out: [String] = []
for (platform, settings) in vm.config.gatewayPlatforms.sorted(by: { $0.key < $1.key }) {
guard GatewayAllowlistKind.kind(for: platform) == kind else { continue }
for item in settings.items(for: kind) where !item.isEmpty {
out.append("\(platform): \(item)")
}
}
return out
}
/// Diagnostics Performance entry point. Hidden from the /// Diagnostics Performance entry point. Hidden from the
/// `quickEditsSection` flow because it doesn't touch config.yaml /// `quickEditsSection` flow because it doesn't touch config.yaml
/// it controls the in-process ScarfMon backend set instead. Off /// it controls the in-process ScarfMon backend set instead. Off
@@ -0,0 +1,83 @@
import SwiftUI
import ScarfDesign
/// "Learn more" sheet behind the v0.13 features-active badge in
/// `SettingsView`. Text-only summary of what shipped in Hermes v0.13
/// (Persistent Goals, ACP /queue, Kanban diagnostics, hallucination
/// gate, Curator archive, Google Chat platform). Every row spells out
/// where the editing lives Mac for v2.8.0; iOS write surfaces are
/// deferred to v2.8.x.
///
/// No deep-linking from rows in v2.8.0 that's a v2.8.x polish.
struct V013FeaturesSheet: View {
@Environment(\.dismiss) private var dismiss
var body: some View {
NavigationStack {
List {
Section {
featureRow(
icon: "scope",
title: "Persistent goals",
description: "Type /goal <text> in chat to lock the agent on a target across turns. Send and clear from the Mac app in v2.8."
)
featureRow(
icon: "tray.full",
title: "ACP /queue",
description: "Queue prompts to run after the current turn finishes. Send and manage from the Mac app in v2.8."
)
featureRow(
icon: "stethoscope",
title: "Kanban diagnostics",
description: "Worker distress signals (heartbeat stalls, retry caps, zombies) surface on the task detail."
)
featureRow(
icon: "questionmark.diamond.fill",
title: "Hallucination gate",
description: "Worker-created cards are flagged for verify or reject. Verify on the Mac app."
)
featureRow(
icon: "archivebox",
title: "Curator archive",
description: "Stale skills move to an Archived list. Restore or prune from the Mac app."
)
featureRow(
icon: "bubble.left.and.bubble.right",
title: "Google Chat platform",
description: "New messaging-gateway target. Configure on the Mac app."
)
} header: {
Text("What's new in v0.13")
} footer: {
Text("This iOS release surfaces v0.13 features read-only. Editing lives in the Mac app for v2.8.")
.font(.caption)
}
}
.scrollContentBackground(.hidden)
.background(ScarfColor.backgroundPrimary)
.navigationTitle("v0.13 features")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Done") { dismiss() }
}
}
}
}
private func featureRow(icon: String, title: String, description: String) -> some View {
HStack(alignment: .top, spacing: 12) {
Image(systemName: icon)
.foregroundStyle(.tint)
.font(.title3)
.frame(width: 28)
VStack(alignment: .leading, spacing: 4) {
Text(title).font(.body.weight(.semibold))
Text(description)
.font(.callout)
.foregroundStyle(.secondary)
}
}
.padding(.vertical, 4)
}
}
+112
View File
@@ -0,0 +1,112 @@
# v2.8.0 Coordinator Review — Hermes v0.13.0 catch-up
**Status:** all 8 work-stream plans drafted; WS-1 (capability flags) committed on branch `ws-1-capabilities-v0.13` (PR #80). This document is the coordinator's cross-stream review compiled from each per-stream plan's _Open Questions_ section, file inventory, and confidence rating. It exists so the user can review the v2.8.0 implementation surface in one read instead of eight.
## Plan inventory
| Stream | File | Lines | Confidence | Open Q's | Files touched | Branch |
| --- | --- | --: | --- | --: | --: | --- |
| WS-2 | [WS-2-goals-and-queue-plan.md](WS-2-goals-and-queue-plan.md) | ~600 | medium-high | 7 | ~6 | `ws-2-goals-and-queue` |
| WS-3 | [WS-3-kanban-v0.13-plan.md](WS-3-kanban-v0.13-plan.md) | 947 | medium-high | 7 | 12 (1 new) | `ws-3-kanban-v0.13` |
| WS-4 | [WS-4-curator-archive-plan.md](WS-4-curator-archive-plan.md) | 561 | medium-high | 6 | ~10 | `ws-4-curator-archive` |
| WS-5 | [WS-5-gateway-v0.13-plan.md](WS-5-gateway-v0.13-plan.md) | 520 | medium-high | 8 | ~17 (5 new) | `ws-5-gateway-v0.13` |
| WS-6 | [WS-6-providers-v0.13-plan.md](WS-6-providers-v0.13-plan.md) | 625 | high (arch) / medium (key) | 5 | 8 | `ws-6-providers-v0.13` |
| WS-7 | [WS-7-settings-v0.13-plan.md](WS-7-settings-v0.13-plan.md) | 628 | medium-high | 8 | 17 | `ws-7-settings-v0.13` |
| WS-8 | [WS-8-ux-v0.13-plan.md](WS-8-ux-v0.13-plan.md) | 580 | high (5 of 6) / medium (1) | 5 | 12 | `ws-8-ux-v0.13` |
| WS-9 | [WS-9-ios-v0.13-plan.md](WS-9-ios-v0.13-plan.md) | 926 | medium-high | 8 | 7 | `ws-9-ios-v0.13` |
**Total v2.8.0 surface:** ~89 files touched (with overlap; net unique ~75), ~5400 lines of plan, 54 distinct open questions across 8 streams.
## Cross-stream collisions (coordinator-tracked)
These files appear in more than one work-stream and need explicit sequencing:
| File | Streams | Resolution |
| --- | --- | --- |
| `RichChatViewModel.swift` | WS-2 (`/goal`/`/queue`), WS-8 (`/new <name>` help text) | WS-8 lands AFTER WS-2; the `/new <name>` change is one-line and rebases trivially. |
| `SessionInfoBar` (chat status bar) | WS-2 (queue chip), WS-8 (compression count) | Both add SwiftUI children to the same HStack — order-independent. WS-8 lands after WS-2 to avoid file-level conflicts. |
| `HermesCapabilities.swift` | WS-1 (all flags), WS-8 + WS-9 (request `isV013OrLater` helper) | Decided: add `isV013OrLater` helper to WS-1 PR (one-line, lands cleanly). See _Decision A_ below. |
| `HermesConfig` model | WS-5 (gateway allowlists), WS-6 (`image_gen.model`, `openrouter.response_cache`), WS-7 (mcp/cron/web-tools/profiles) | Each work-stream extends a different namespace. Touch the same file; merge resolution mechanical. |
| iOS surfaces | WS-9 consumes WS-2/WS-3/WS-4/WS-5 model fields | WS-9 lands LAST in the v2.8.0 cycle. Hard sequencing constraint. |
## Open-questions matrix (cluster-organized)
Of 54 questions across the 8 plans, **45 are wire-shape unknowns** that can only be resolved by inspecting a real Hermes v0.13.0 install (i.e. they need a v0.13 host to dogfood against, since the release notes don't pin every CLI flag, JSON field, or YAML key). The remaining 9 are Scarf-side architectural choices that the agents already recommended; they need user adjudication.
### Cluster A — wire-shape unknowns (resolve at integration time, not before implementation starts)
These are the questions where each plan agent gave a best-inference default, marked the spot with a `// TODO` comment, and recommended verification when a v0.13 host is reachable. The implementation can proceed safely with these defaults; if any are wrong, the fix is a one-line edit + a new test fixture.
- **WS-2:** goal-state read-back channel (Q1), `/queue --clear` syntax (Q2), `/queue` argument shape (Q5), `/goal` non-interruptive on the wire (Q7)
- **WS-3:** hallucination verb name (Q1), diagnostics location (task vs run, Q2), `set_max_retries` post-create (Q3), failure-counter unification field (Q4), darwin-zombie kind (Q5), default `max_retries` value (Q6), `kanban diagnose <id>` verb (Q7)
- **WS-4:** `prune --dry-run` flag (Q1), `--json` on read verbs (Q2), single-skill prune (Q3), sync-run timeout (Q4)
- **WS-5:** Google Chat platform identifier (Q1), allowlist YAML key path (Q2), `gateway list --json` shape (Q3), `[[as_document]]` discoverability (Q6)
- **WS-6:** `openrouter.response_cache.enabled` exact key (Q1), default value (Q2), grok rename old-slot redirect (Q4), `models_dev_cache.json` refresh on clean install (Q5)
- **WS-7:** MCP transport names (Q1), `sse_read_timeout` default (Q2), `--transport sse` flag spelling (Q3), `--no-agent` toggle-off shape (Q4), argparse + `--no-agent` (Q5), web-tools backend lists (Q6), `web_tools.backend` legacy fallback (Q7), `--no-skills` × `--clone-all` interaction (Q8)
- **WS-8:** compression-count wire field name (Q1), xAI TTS config keys (Q2), `display.language` empty-string vs `"en"` default (Q3)
**Recommended resolution:** proceed with implementation against the agents' inferred defaults. Each implementation agent should be briefed to mark its TODO callsites. A coordinator pass before merging WS-2…WS-9 (after the user has dogfooded a v0.13 host) confirms or fixes each in <30 minutes total.
### Cluster B — Scarf-side architectural choices (need user adjudication)
These are the 9 questions where the user's input directly shapes the implementation:
| ID | Question | Agent's recommendation |
| --- | --- | --- |
| **A** | Add `isV013OrLater` helper to WS-1? | **Yes** — both WS-8 and WS-9 want it. One-line addition. Land in the existing WS-1 PR before merging. |
| **B** | "Auto-resumed from checkpoint" indicator | **Defer to v2.8.1** (WS-2 Q3). Hermes v0.13's auto-resume signal isn't documented; surfacing it requires a wire-format we don't have yet. |
| **C** | `/queue --clear` button when syntax unconfirmed | **Remove the "Clear all" button from the queue popover until syntax is confirmed.** Local-only clear that lies about server state is worse than no button. |
| **D** | Curator prune confirm UX | **Custom sheet matching template-uninstall** (WS-4 Q5). Enumerated list + asymmetric keyboard shortcut, no typed-name confirmation. |
| **E** | Filter Yuanbao + Teams platforms on pre-v0.12? | **Keep current behavior** (WS-5 Q4). Don't change v0.12 host UX in a v0.13 work-stream. Document the asymmetry. |
| **F** | Capability flag for slash-command notice TTL | **Proxy through `hasGatewayBusyAckToggle ‖ hasGatewayRestartNotification`** (WS-5 Q5). A dedicated flag is YAGNI. |
| **G** | Rename `MessagingGatewayViewModel`? | **Apply rename if <5 callsites change.** Otherwise keep the type name and rely on user-facing label. |
| **H** | Profile `--no-skills` + `--clone-all` interaction | **Conservative: disable `--no-skills` toggle when `--clone-all` is on.** Argparse may reject anyway. |
| **I** | Implementation parallelism — 8 PRs in parallel worktrees, or sequential review? | Recommend **parallel worktree implementation** with **sequential coordinator review** (one PR at a time merging into main). Parallel impl = ~3-4 days of agent-time; sequential review = the natural throttle for production safety. |
### Cluster C — out-of-scope deferrals (no decision needed)
These were identified during planning but the agents already deferred them with sound rationale:
- WS-2: optimistic-vs-authoritative goal reconciliation
- WS-3: failure-counter unification field rendering
- WS-6: Arcee Trinity Large Thinking temperature/compression overrides surface
- WS-7: `web_tools.backend` legacy migration prompt
- WS-9: deep-links from v0.13-features sheet, hallucination-badge tap-target alert
- All streams: iOS write surfaces (always deferred)
## Recommended next steps (post-review)
Once the user resolves Cluster B questions AI:
1. **Patch WS-1 PR #80** with the `isV013OrLater` helper (Decision A). One commit, one push.
2. **Spawn 8 implementation agents in parallel** (Decision I), each in an isolated worktree:
- Each agent gets its plan file + the answers to relevant Cluster B questions + the WS-1 commit ref.
- Each agent produces a single PR from its branch.
- Branch names match the plan inventory table.
3. **Coordinator-review each PR sequentially** in dependency order:
- Wave 1 (WS-2, WS-3, WS-4, WS-5) — review one at a time, merge in any order
- Wave 2 (WS-6, WS-7, WS-8) — same
- Wave 3 (WS-9) — last; consumes Wave 1+2 model fields
4. **WS-10 release** after WS-9 merges:
- Update CLAUDE.md (already partially done in WS-1)
- Update wiki via `scripts/wiki.sh`
- Write `releases/v2.8.0/RELEASE_NOTES.md`
- Run `scripts/release.sh v2.8.0 --draft` to validate
- Run `scripts/release.sh v2.8.0` for the full promotion
## Risk register
- **Production app, thousands of users.** Each PR must build clean, all tests green, manual smoke against a v0.13 host before merge.
- **Cluster A wire-shape risk.** Mitigated by tolerant decoders + capability gates; if any guess is wrong, pre-v0.13 hosts still work and v0.13 hosts surface a benign decode-failure (UI hides instead of crashes).
- **Sparkle update path.** v2.8.0 is delivered via the existing Sparkle appcast; there's no migration path for users on pre-v0.12 Hermes hosts (their v0.13-only surfaces stay hidden).
- **No data migrations.** Per CLAUDE.md, schema is unchanged from v0.11/v0.12 across this release. Per-project `manifest.json` and Scarf-owned sidecars at `~/.hermes/scarf/` are untouched.
## Estimate
- WS-1: shipped (PR #80 awaiting merge after Decision A)
- Wave 1 implementation: ~3 days agent-time × 4 streams in parallel = ~3 calendar days
- Wave 2 implementation: ~2 days agent-time × 3 streams in parallel = ~2 calendar days
- WS-9 implementation: ~2 days agent-time
- WS-10 release coordination: ~½ day
**Calendar-time estimate: ~8 days** with parallel implementation + sequential review. The bottleneck is coordinator review at PR-merge boundaries, not agent throughput.
@@ -0,0 +1,497 @@
# WS-2 Plan: Persistent Goals + ACP `/queue`
Branch suggestion: `ws-2-goals-and-queue-v0.13`. Depends on WS-1 (`ws-1-capabilities-v0.13`, PR #80) for the three v0.13 capability flags consumed below.
## Goals (what this PR ships)
User-visible features (all capability-gated, all degrade silently on pre-v0.13 hosts):
- `/goal <text>` slash command, surfaced in the slash menu, sent as a non-interruptive prompt (no "Agent working…" flip).
- `/goal --clear` slash command (and a quick-clear affordance on the goal pill itself) to drop the active goal.
- A "Goal locked" pill in the chat header (mounted alongside the project / branch chips in [SessionInfoBar](../../scarf/Features/Chat/Views/SessionInfoBar.swift)). Hidden when no active goal.
- `/queue <text>` slash command, surfaced in the slash menu, non-interruptive, with a transient toast (`Queued — runs after current turn`) reusing the existing `transientHint` machinery.
- `/queue` listing affordance: a small chip in the chat header showing queued-prompt count, expanding to a popover with the queued-prompt previews when there are any pending entries (Mac only — iOS gets a read-only listing affordance in WS-9).
- `/steer` on idle: pre-v0.13 hosts grey-out `/steer` and `/queue` and `/goal` in the slash menu when the session is idle (they do nothing useful there); v0.13+ hosts allow `/steer` to fire on idle sessions and treat it as a regular prompt.
- iOS read-only "Goal locked" pill (added in WS-9, plumbed here so the VM is iOS-ready).
Out-of-scope items captured in [Out of scope](#out-of-scope-deferred).
## Files to change
### [scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesSlashCommand.swift](../../Packages/ScarfCore/Sources/ScarfCore/Models/HermesSlashCommand.swift)
- Re-use the existing `Source.acpNonInterruptive` enum case — `/goal` and `/queue` slot in there alongside `/steer`. No new source case is needed (a "non-interruptive" command, regardless of whether it sets a goal or queues a turn, has the same wire shape: send through `ACPClient.sendPrompt`, do not flip "Agent working…").
- No struct changes needed.
### [scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesActiveGoal.swift](../../Packages/ScarfCore/Sources/ScarfCore/Models/HermesActiveGoal.swift) (NEW)
Plain value type:
```swift
public struct HermesActiveGoal: Sendable, Equatable, Identifiable {
public let text: String
public let setAt: Date
public var id: String { text + "@" + ISO8601DateFormatter().string(from: setAt) }
}
```
Lives next to `HermesSession.swift` and `HermesSlashCommand.swift`. Used by the goal pill and the goal viewmodel state (read-only — no mutation API on the struct).
### [scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesQueuedPrompt.swift](../../Packages/ScarfCore/Sources/ScarfCore/Models/HermesQueuedPrompt.swift) (NEW)
Plain value type for one queued prompt:
```swift
public struct HermesQueuedPrompt: Sendable, Equatable, Identifiable {
public let id: UUID
public let text: String
public let queuedAt: Date
}
```
Used by `RichChatViewModel.queuedPrompts` and the queue-popover view. The `id` is a Scarf-side UUID minted at queue-time — Hermes' wire protocol doesn't expose a per-queue-entry id (see [Open questions](#open-questions)).
### [scarf/Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift)
This is the load-bearing change. All changes are MainActor-isolated; no sync I/O is added.
**1. Extend `nonInterruptiveCommands` (currently around [RichChatViewModel:251-258](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift)):**
Today the list contains only `/steer`. Add `/goal` and `/queue`. Per the existing contract these are appended unconditionally — capability gating is applied in `availableCommands` (next change). Each entry uses `source: .acpNonInterruptive` so the existing `isNonInterruptiveSlash(_:)` helper at [RichChatViewModel:331-342](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift) auto-recognizes them.
```swift
public static let nonInterruptiveCommands: [HermesSlashCommand] = [
HermesSlashCommand(name: "steer", description: "...", argumentHint: "<guidance>", source: .acpNonInterruptive),
HermesSlashCommand(name: "goal", description: "Lock the agent on a goal that persists across turns",
argumentHint: "<text>", source: .acpNonInterruptive),
HermesSlashCommand(name: "queue", description: "Queue a prompt to run after the current turn",
argumentHint: "<text>", source: .acpNonInterruptive),
]
```
**2. Capability-gated filtering of the static list.**
`availableCommands` (currently [RichChatViewModel:304-325](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift)) merges the static `nonInterruptiveCommands` unconditionally. Replace that with a filter against a new public `capabilitiesGate` value the controller sets at session-start time:
```swift
@ObservationIgnored public var capabilitiesGate: HermesCapabilities = .empty
```
Inside `availableCommands`, after building `acpNames` / `projectNames` / `quicks`:
```swift
let supported: [HermesSlashCommand] = Self.nonInterruptiveCommands.filter { cmd in
switch cmd.name {
case "goal": return capabilitiesGate.hasGoals
case "queue": return capabilitiesGate.hasACPQueue
case "steer": return true // present pre-v0.13 too; idle gating handled separately
default: return true
}
}
let nonInterruptive = supported.filter { !occupied.contains($0.name) }
return acpCommands + projectAsHermes + quicks + nonInterruptive
```
**3. Active goal state.**
Add observable storage:
```swift
public private(set) var activeGoal: HermesActiveGoal?
```
Reset to nil in `reset()` (around [RichChatViewModel:441-478](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift)).
Add a slim mutator `recordActiveGoal(text: String?)`:
```swift
@MainActor public func recordActiveGoal(text: String?) {
if let text, !text.isEmpty {
activeGoal = HermesActiveGoal(text: text, setAt: Date())
} else {
activeGoal = nil
}
}
```
Two callers will populate this: (a) the slash-command handler in `ChatViewModel.sendViaACP` / `ChatController._sendImpl` does an optimistic write the moment the user presses send (`/goal foo` → record `foo`; `/goal --clear` → record nil), so the pill appears synchronously without waiting for a server round-trip; (b) a future ACP-side signal could correct it (see [Open questions](#open-questions)).
**4. Queued-prompt state.**
Add observable storage:
```swift
public private(set) var queuedPrompts: [HermesQueuedPrompt] = []
```
Reset to empty in `reset()`.
Add mutators:
```swift
@MainActor public func recordQueuedPrompt(text: String) {
queuedPrompts.append(HermesQueuedPrompt(id: UUID(), text: text, queuedAt: Date()))
}
@MainActor public func clearAllQueuedPrompts() { queuedPrompts.removeAll() }
@MainActor public func popQueuedPrompt() -> HermesQueuedPrompt? {
queuedPrompts.isEmpty ? nil : queuedPrompts.removeFirst()
}
```
`recordQueuedPrompt` is called optimistically when the user sends `/queue ...`. `popQueuedPrompt` runs inside `handlePromptComplete` (currently [RichChatViewModel:763-820](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift)) when the agent finishes a turn — Hermes is responsible for actually running the queued prompt (it lives server-side); the Scarf-side list is purely a UI mirror. Popping is best-effort: if Hermes' server-side queue gets out of sync (deferred prompt aborted, dropped on disconnect), the user sees a stale chip until their next interaction. We accept that v1 trade-off; see [Open questions](#open-questions).
**5. `/goal` argument parsing helper (test-friendly).**
```swift
public enum GoalCommandArgument: Equatable {
case set(String)
case clear
case empty // user typed `/goal` with no argument
}
public static func parseGoalArgument(_ raw: String) -> GoalCommandArgument {
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty { return .empty }
if trimmed == "--clear" || trimmed == "clear" { return .clear }
return .set(trimmed)
}
```
Pure function, no MainActor. Lets `M9SlashCommandTests` exercise the parser directly.
### [scarf/scarf/Features/Chat/ViewModels/ChatViewModel.swift](../../scarf/Features/Chat/ViewModels/ChatViewModel.swift) (Mac)
**1. Plumb capabilities into the VM.**
Today the VM doesn't carry a reference to `HermesCapabilitiesStore`. Add a stored property + initializer overload:
```swift
@ObservationIgnored var capabilitiesStore: HermesCapabilitiesStore?
```
`ChatView` passes the env-resolved store in via `.task` (or `.onAppear`) and the VM forwards `capabilitiesStore.capabilities` into `richChatViewModel.capabilitiesGate` whenever the store's `capabilities` changes (use a one-shot `.task(id: capabilities)` modifier on the chat view to re-publish on refresh).
Rationale: the slash menu's `availableCommands` filter (above) needs the live capabilities. `ChatViewModel` is `@Observable`; storing the snapshot directly here would force the entire VM to re-render on capability refreshes — using `@ObservationIgnored` + an explicit "publish" call into RichChatViewModel keeps re-render scope tight.
**2. Detect non-interruptive commands by name in `sendViaACP` (currently [ChatViewModel:556-635](../../scarf/Features/Chat/ViewModels/ChatViewModel.swift)).**
The current `isSteer` branch only special-cases the toast. Extend it to dispatch:
```swift
let trimmedSlash = parseSlashName(text) // small helper, returns (name: String?, args: String)
let isNonInterruptive = richChatViewModel.isNonInterruptiveSlash(text)
switch trimmedSlash.name {
case "goal":
let arg = RichChatViewModel.parseGoalArgument(trimmedSlash.args)
switch arg {
case .set(let goalText):
richChatViewModel.recordActiveGoal(text: goalText)
richChatViewModel.transientHint = "Goal locked: \(goalText)"
case .clear:
richChatViewModel.recordActiveGoal(text: nil)
richChatViewModel.transientHint = "Goal cleared."
case .empty:
// Agent will respond with usage; show neutral hint.
richChatViewModel.transientHint = "Sent /goal — see the agent reply for current goal."
}
scheduleHintClear()
case "queue":
let queuedText = trimmedSlash.args.trimmingCharacters(in: .whitespacesAndNewlines)
if !queuedText.isEmpty {
richChatViewModel.recordQueuedPrompt(text: queuedText)
}
richChatViewModel.transientHint = "Queued — runs after current turn."
scheduleHintClear()
case "steer" where isNonInterruptive:
richChatViewModel.transientHint = "Guidance queued — applies after the next tool call."
scheduleHintClear()
default:
if !isNonInterruptive { acpStatus = ACPPhase.agentWorking }
}
```
`scheduleHintClear()` extracts the existing 4-second auto-clear pattern (currently inlined for `/steer` at [ChatViewModel:585-591](../../scarf/Features/Chat/ViewModels/ChatViewModel.swift)) into a private helper, so all three commands use the same clear behaviour. The wire send (the existing `client.sendPrompt(...)` call at [ChatViewModel:597](../../scarf/Features/Chat/ViewModels/ChatViewModel.swift)) is unchanged — Hermes parses the slash on the server side.
**3. Clear active goal state on session reset.**
`startNewSession` (and `resumeSession`, `continueLastSession`) call `richChatViewModel.reset()` which already resets `activeGoal` and `queuedPrompts` (from change #3 above in the VM). Confirm `stopACP()` doesn't need an additional clear — it doesn't, because reset() is the explicit teardown.
**4. `/steer` on idle pre-v0.13.**
In the slash menu (rendered by `SlashCommandRow` — see Slash menu changes below), grey-out `/steer` when:
```swift
!richChatViewModel.isAgentWorking && !capabilitiesGate.hasACPSteerOnIdle
```
Tooltip / disabled state: "Use `/steer` while the agent is working — your Hermes version doesn't support steering on idle sessions."
### [scarf/scarf/Features/Chat/Views/SlashCommandMenu.swift](../../scarf/Features/Chat/Views/SlashCommandMenu.swift)
Add a new `disabled: Bool` parameter to `SlashCommandRow`. When disabled, render the row at 0.55 opacity, prevent `onTapGesture` from firing, and append a one-line subtitle "(use during a turn)". Also accept a `disabledReason: String?` for the tooltip.
Plumb the disabled state through from the parent (`RichChatInputBar`). Logic stays in the parent: a row is disabled iff `(name == "steer") && isIdle && !hasACPSteerOnIdle`. Goal/queue rows are never grey when present (they're already filtered out when their cap is off).
### [scarf/scarf/Features/Chat/Views/SessionInfoBar.swift](../../scarf/Features/Chat/Views/SessionInfoBar.swift)
Add the goal pill alongside the existing project / branch chips. Two new optional inputs:
```swift
var activeGoal: HermesActiveGoal? = nil
var onClearGoal: (() -> Void)? = nil
```
Render block (positioned right after the existing `gitBranch` Label, before the working dot at [SessionInfoBar:65](../../scarf/Features/Chat/Views/SessionInfoBar.swift)):
```swift
if let activeGoal {
HStack(spacing: 4) {
Image(systemName: "scope")
Text(truncatedGoal(activeGoal.text))
}
.scarfStyle(.caption)
.padding(.horizontal, ScarfSpace.s2)
.padding(.vertical, 2)
.background(Capsule().fill(ScarfColor.info.opacity(0.16)))
.foregroundStyle(ScarfColor.info)
.help("Goal locked: \(activeGoal.text)")
.contextMenu {
if let onClearGoal {
Button("Clear goal", role: .destructive, action: onClearGoal)
}
}
}
private func truncatedGoal(_ text: String) -> String {
text.count <= 36 ? text : String(text.prefix(33)) + "…"
}
```
Color choice: `ScarfColor.info` matches the badge intent — informational state, not a warning, not an error. Per CLAUDE.md, accent (rust) is reserved for primary brand surfaces; project / branch already use accent so reusing it would mean three accent chips in a row. `info` differentiates the goal pill visually.
The `onClearGoal` closure flows from `ChatViewModel`: when invoked, it dispatches `sendText("/goal --clear")` so Hermes' authoritative state stays in sync (the optimistic local clear happens via the send-path in `sendViaACP`).
### [scarf/scarf/Features/Chat/Views/ChatTranscriptPane.swift](../../scarf/Features/Chat/Views/ChatTranscriptPane.swift)
Forward the new `SessionInfoBar` parameters at [ChatTranscriptPane:17-25](../../scarf/Features/Chat/Views/ChatTranscriptPane.swift):
```swift
SessionInfoBar(
session: richChat.currentSession,
isWorking: richChat.isGenerating,
acpInputTokens: richChat.acpInputTokens,
acpOutputTokens: richChat.acpOutputTokens,
acpThoughtTokens: richChat.acpThoughtTokens,
projectName: chatViewModel.currentProjectName,
gitBranch: chatViewModel.currentGitBranch,
activeGoal: richChat.activeGoal,
onClearGoal: { chatViewModel.sendText("/goal --clear") }
)
```
### [scarf/scarf/Features/Chat/Views/ChatQueueIndicator.swift](../../scarf/Features/Chat/Views/ChatQueueIndicator.swift) (NEW)
Small chip + popover for the queued-prompt list. Mounted in `SessionInfoBar` next to the goal pill, but extracted to its own file because it owns popover state.
```swift
struct ChatQueueIndicator: View {
let queuedPrompts: [HermesQueuedPrompt]
var onClearAll: () -> Void
@State private var isPopoverShown = false
var body: some View {
if queuedPrompts.isEmpty { EmptyView() } else {
Button {
isPopoverShown = true
} label: {
HStack(spacing: 4) {
Image(systemName: "tray.full")
Text("\(queuedPrompts.count) queued")
}
.scarfStyle(.caption)
.padding(.horizontal, ScarfSpace.s2)
.padding(.vertical, 2)
.background(Capsule().fill(ScarfColor.warning.opacity(0.16)))
.foregroundStyle(ScarfColor.warning)
}
.buttonStyle(.plain)
.help("Prompts waiting to run after the current turn finishes")
.popover(isPresented: $isPopoverShown, arrowEdge: .bottom) {
queuePopover
}
}
}
@ViewBuilder private var queuePopover: some View { /* list + clear-all action */ }
}
```
Color: `.warning` (amber) — these are pending side-effects the user should notice. Distinct from goal (`.info`) and project (`.accent`) so all three chips are visually decodable.
Caveat: this chip is OPTIMISTIC. The popover header includes a one-line note: "Local view — Hermes manages the actual queue." The popover offers "Clear all" but NOT individual deletion (Hermes has no per-entry remove verb; clearing locally would diverge from server state). "Clear all" sends `/queue --clear` if Hermes accepts that syntax (see [Open questions](#open-questions)) and otherwise just resets the local mirror with a tooltip explaining the discrepancy.
### [scarf/Scarf iOS/Chat/ChatView.swift](../../Scarf%20iOS/Chat/ChatView.swift) — DEFERRED to WS-9
The iOS chat already wires non-interruptive commands at [ChatView:1310-1322](../../Scarf%20iOS/Chat/ChatView.swift) and uses the same `RichChatViewModel`, so the model-side changes are picked up automatically. Surface changes (read-only goal pill, queue chip) belong in WS-9 per the work-stream split. **Do not** add iOS UI changes in this PR — keep the diff scoped.
**Exception:** the iOS controller's `_sendImpl` at [ChatView:1291-1342](../../Scarf%20iOS/Chat/ChatView.swift) needs the same dispatch changes as Mac (record the optimistic goal/queue mutation when the user types `/goal` or `/queue`), otherwise the iOS VM state will diverge from Mac. Mirror change #2 from `ChatViewModel.swift` above into the `_sendImpl` body. iOS just doesn't *render* the goal pill / queue chip yet — that's WS-9.
### [scarf/Packages/ScarfCore/Tests/ScarfCoreTests/M9SlashCommandTests.swift](../../Packages/ScarfCore/Tests/ScarfCoreTests/M9SlashCommandTests.swift)
Extend with v0.13 cases. The current file tests project-scoped commands and the context block; add a new section "v0.13 non-interruptive commands":
- `nonInterruptiveListIncludesGoalAndQueue``RichChatViewModel.nonInterruptiveCommands.map(\.name)` contains both names.
- `availableCommandsHidesGoalWhenCapabilityOff` — set `capabilitiesGate = .empty`, assert `goal` not in `availableCommands`.
- `availableCommandsHidesQueueWhenCapabilityOff` — same for `queue`.
- `availableCommandsExposesAllThreeOnV013` — set `capabilitiesGate = HermesCapabilities.parseLine("Hermes Agent v0.13.0 (2026.5.7)")`, assert all three are present.
- `parseGoalArgumentRecognizesClearVariants``--clear`, `clear`, `Clear`, ` --clear ` all return `.clear`.
- `parseGoalArgumentReturnsSetForArbitraryText``"finish v2.8 on time"``.set("finish v2.8 on time")`.
- `parseGoalArgumentReturnsEmptyForBlank``""` and `" "` return `.empty`.
- `recordActiveGoalSetsAndClears` — call `recordActiveGoal(text: "x")` then `recordActiveGoal(text: nil)` on a fresh VM, assert observable transitions.
- `recordQueuedPromptAppendsAndPopsFIFO` — append three, pop two, verify order + remaining count.
- `clearAllQueuedPromptsEmpties` — straightforward.
- `isNonInterruptiveSlashRecognizesGoalAndQueue` — verify `/goal foo`, `/queue bar`, `/queue` (no args) all return `true`.
- `resetClearsGoalAndQueue` — set both, call `reset()`, assert both empty.
All MainActor-bound; use `@MainActor @Test` annotations. The current suite uses `@Suite` with default isolation, which is fine.
### [scarf/Packages/ScarfCore/Tests/ScarfCoreTests/HermesCapabilitiesTests.swift](../../Packages/ScarfCore/Tests/ScarfCoreTests/HermesCapabilitiesTests.swift)
WS-1 already added cases for `hasGoals` / `hasACPQueue` / `hasACPSteerOnIdle`. No further changes needed unless the existing tests don't assert all three are true on `v0.13.0` and false on `v0.12.0` — verify this is covered before merging WS-2.
## New types / fields
| Type | Where | Purpose |
| --- | --- | --- |
| `HermesActiveGoal` | new ScarfCore model | observable goal-pill state |
| `HermesQueuedPrompt` | new ScarfCore model | one queued-prompt mirror entry |
| `RichChatViewModel.GoalCommandArgument` | nested enum on the VM | pure parser for `/goal` arg |
| `RichChatViewModel.activeGoal` | observable | drives the pill |
| `RichChatViewModel.queuedPrompts` | observable | drives the chip + popover |
| `RichChatViewModel.capabilitiesGate` | non-observable | filters non-interruptive commands |
| `ChatViewModel.capabilitiesStore` | non-observable | bridge from env → VM |
| `ChatQueueIndicator` (Mac view) | new chat view | header chip |
No new ACP RPC types; we ride the existing `session/prompt` shape. No DB schema changes.
## Capability gating
| Affordance | Gate | Pre-v0.13 behaviour |
| --- | --- | --- |
| `/goal` in slash menu | `hasGoals` | hidden |
| `/goal --clear` (also clear-from-pill) | `hasGoals` | n/a (no pill to clear; menu item also hidden) |
| Goal pill in `SessionInfoBar` | `activeGoal != nil` (which only becomes non-nil when user sends `/goal`, which requires the menu, which requires `hasGoals`) | hidden by transitive impossibility |
| `/queue` in slash menu | `hasACPQueue` | hidden |
| Queue chip in `SessionInfoBar` | `queuedPrompts.isEmpty == false` (transitive on `hasACPQueue`) | hidden |
| `/steer` greyed-out on idle | `hasACPSteerOnIdle == false && !isAgentWorking` | greyed; tooltip explains |
| `/steer` on idle (sent normally) | `hasACPSteerOnIdle == true` | works as regular prompt (server handles) |
Belt-and-suspenders defence: `availableCommands` filters BEFORE menu rendering; the dispatch in `sendViaACP` does NOT pre-validate (Hermes' server-side error message is more accurate than any client guard we'd write). If a user types `/goal` directly via a quick-command alias on a pre-v0.13 host, the slash gets sent to Hermes, which will respond with its own "unknown command" reply — acceptable v1 behaviour.
## How to test
### Unit tests
Run `swift test --package-path scarf/Packages/ScarfCore --filter M9SlashCommandTests`. Should be ~12 new tests; existing 23 stay green.
### Manual: v0.13 host
Prereq: Hermes v0.13.0 installed locally OR the dogfooding box (`192.168.0.82`) with `remote-servers` branch.
1. **Goal happy path:**
- Open chat (any project / quick chat).
- Type `/`, verify `/goal` appears in slash menu.
- Send `/goal finish WS-2 by Friday` — confirm:
- "Agent working…" does NOT flip on (non-interruptive).
- Transient toast appears: "Goal locked: finish WS-2 by Friday".
- "Goal locked" chip appears in `SessionInfoBar` next to project / branch.
- Toast auto-dismisses after ~4s.
- Send a normal prompt; verify the chip stays put across turns.
2. **Goal clear path:**
- With a goal active, right-click the chip → "Clear goal".
- Verify chip disappears, transient toast says "Goal cleared.", and the underlying `sendText("/goal --clear")` actually fires (check Hermes log).
- Alternative path: type `/goal --clear` directly — same outcome.
3. **Queue happy path:**
- Send a long-running prompt to occupy the agent.
- While it's working, send `/queue summarize what you just did`.
- Confirm: toast "Queued — runs after current turn.", chip appears showing "1 queued".
- Click chip → popover lists the queued prompt with timestamp.
- When the current turn finishes, verify Hermes runs the queued prompt automatically (server-side) AND the chip count decrements (via `popQueuedPrompt`).
4. **Steer-on-idle:**
- On v0.13, send `/steer` on an idle session — confirm it sends as a regular prompt (no error, no "Agent working" indicator misbehaviour).
5. **Capability refresh:**
- Connect to a remote running Hermes v0.12. Verify `/goal` and `/queue` are absent from the slash menu.
- Verify `/steer` is present but greyed-out on idle, with the tooltip.
6. **Session reset:**
- Set a goal + queue 2 prompts. Click "New chat" — confirm chip and pill clear.
- Resume an old session — confirm pill stays empty (we don't persist active-goal across sessions in v1; see [Open questions](#open-questions)).
### Manual: pre-v0.13 host
1. Connect to a remote running Hermes v0.11.x or v0.12.x.
2. Slash menu should show `/steer` only (no `/goal`, no `/queue`).
3. With idle session, hover `/steer` — verify greyed + tooltip.
4. Manually type `/goal foo` and send — Hermes returns its own "unknown command" reply; Scarf does not crash, the goal pill does not appear (because `recordActiveGoal` is gated on the slash dispatch being routed via the `case "goal":` branch, and that branch fires unconditionally — but the chip is only rendered when `activeGoal != nil` AND we sent the slash, so the user sees an inconsistent local pill until the agent's "unknown command" response).
- **Inconsistency caveat:** the optimistic write means a typed-out `/goal` against a pre-v0.13 host paints the pill briefly. Acceptable: pre-v0.13 users have to type the command literally (no menu surface), so this is power-user territory. Document in release notes.
### Visual
- Goal chip should be `info`-tinted and visually distinct from accent (project) and warning (queue).
- Pill text truncates to ~33 chars + ellipsis for long goals; full text in tooltip.
- Three-chip overflow at narrow window widths: SessionInfoBar already wraps via the `HStack(spacing: 16)` parent — the pills should naturally elide. If they don't, we constrain `lineLimit(1)` per chip (already the pattern for project name).
## Open questions
These need coordinator resolution before implementation closes.
1. **Goal persistence across session restarts.** Hermes v0.13's "Persistent Goals" implies the active goal survives restarts on the server side. Does Hermes expose:
- (a) a session-startup ACP notification with the current goal, or
- (b) a sidecar JSON file (e.g. `~/.hermes/sessions/session_<id>.json` with a `goal: ...` field), or
- (c) a `/goal --status` command that returns the current goal?
The release notes mention "Preserve pending update prompts across restarts" and "Preserve thread routing from cached live session sources" — neither of those is the persistent-goal channel.
**Recommendation:** ship v2.8 with optimistic-only state (no read-back). Open a follow-up to read goal state from whichever channel Hermes exposes once the v0.13 server is dogfooded. Mark the chip as "user-set this session" in the tooltip until then. This means resuming an old session won't paint the goal pill even if the agent still has the goal — the chip will appear the next time the user runs `/goal`. This is the safest v2.8 behaviour and aligns with the "minimal-surface, maximal-ship" approach for the v2.8 catch-up release.
2. **`/queue --clear` syntax.** Does Hermes accept `/queue --clear` (or `/queue clear`) to drain the server-side queue? If not, the "Clear all" button in the popover can only clear the local mirror — which means a queued prompt would still run server-side after the user thought they'd cancelled it.
**Recommendation:** if the syntax is unsupported, **remove the "Clear all" button from v2.8** and document the limitation in the popover header. Don't ship a button that lies about what it does.
3. **Auto-resume after gateway restart — ACP signal.** The release notes say "Auto-resume interrupted sessions after gateway restart" but it's unclear whether that signal:
- lands as a Scarf-visible ACP event (so we can show an "Auto-resumed" toast),
- or is purely server-side (Hermes resumes the session transparently and Scarf sees nothing different).
**Recommendation:** defer the "Auto-resumed from checkpoint" indicator to v2.8.1. Add a `// TODO(WS-2 followup)` comment in the ACP event-loop hooks pointing at this question. Ship v2.8 without the indicator. If user-visible auto-resume is in fact happening silently, the lack of UI is a no-op (correct behaviour by accident); if it's announced via an event, we surface it in the next point release.
4. **Optimistic-vs-authoritative goal state.** If the user types `/goal foo` then immediately disconnects before Hermes acks, our optimistic chip will say `foo` while the server has nothing. Reconciliation isn't implemented in v1.
**Recommendation:** accept the trade-off. Reconciling would require Open Question #1's resolution (a way to read server-side goal state), so it's blocked on the same answer.
5. **`/queue` argument shape.** Release notes call it "queue a prompt" — but is the syntax `/queue <text>` (verbatim text becomes the queued prompt) or does it accept named priorities / IDs? If the latter, our optimistic-mirror logic over-simplifies.
**Recommendation:** assume verbatim. Verify against `hermes acp` in dogfooding before merging.
6. **Active goal injection into the system prompt.** If Hermes injects the active goal into every turn's system prompt (likely — that's how a "locked" goal would survive across turns server-side), Scarf doesn't need to re-send it on resume. If Hermes uses some other mechanism (e.g. a sidecar tool), that's also Hermes' problem. **No Scarf-side action needed regardless.**
7. **`/goal` non-interruptive on the wire — does Hermes actually accept it during an active turn?** `/steer` is documented as non-interruptive; `/goal` is documented as "lock onto a target." The server may treat `/goal` as a prompt that DOES need a turn to take effect. If so, our `nonInterruptiveCommands` classification for `/goal` is wrong — it should flip "Agent working…" like a regular prompt.
**Recommendation:** verify against the v0.13 ACP adapter behaviour on a real host. If `/goal` is in fact interruptive, drop it from `nonInterruptiveCommands` and treat it as a normal prompt that just happens to also mutate `activeGoal`. The pill behaviour is unchanged either way.
## Out of scope (deferred)
- iOS surface for goal pill + queue chip — WS-9.
- Persistent-goal cross-session memory (paint the pill from server state on session resume) — blocked on Open Question #1, deferred to v2.8.1.
- "Auto-resumed from checkpoint" indicator — blocked on Open Question #3, deferred to v2.8.1.
- "Resumed from checkpoint" sessions-list badge — same as above.
- A dedicated Goals feature surface (sidebar entry showing all locked goals across sessions) — out of scope; the chip is enough for v2.8.
- Per-queued-prompt deletion in the popover — Hermes has no remove-by-id verb.
- Goal mutation via UI affordance other than the slash command (e.g. a "Set goal…" toolbar button) — defer to v2.8.1; the slash menu is the canonical entry.
- Goal text Markdown rendering in the pill — pill is a one-line plain-text chip.
- Telemetry: ScarfMon counters for `/goal` / `/queue` invocations — nice-to-have, ship without.
## Estimate
**Medium.** ~5 files changed (3 in ScarfCore, 3 Mac chat views — one new), 2 new model files, ~12 new tests. The capability-flag plumbing is non-trivial because `RichChatViewModel.capabilitiesGate` needs a clean injection seam without forcing the whole VM to re-render on every refresh. Two days of focused work end-to-end including manual verification on both a v0.13 and a v0.12 host. The biggest uncertainty is server-side `/goal` and `/queue` behaviour, captured in Open Questions 1, 2, and 7 — coordinator should answer these before the implementation PR opens.
+947
View File
@@ -0,0 +1,947 @@
# WS-3 Plan: Kanban v0.13 diagnostics + recovery UX
**Workstream:** WS-3 of Scarf v2.8.0
**Hermes target:** v0.13.0 (v2026.5.7)
**Capability gate:** `HermesCapabilities.hasKanbanDiagnostics` (already shipped in WS-1, PR #80; resolves to `>= 0.13.0`)
**Builds on:** v2.7.5 Kanban v3 (drag-and-drop board, per-project tenants, optimistic-merge VM, inspector pane). The existing surface stays intact; this WS layers v0.13 reliability + recovery affordances on top.
**Owner:** TBD
**Reviewers:** Alan (always); whoever is on Kanban duty during v2.8 cycle.
---
## Goals
The Hermes v0.13.0 release notes list eight Kanban-shaped items in scope for Scarf:
1. **Hallucination gate + recovery UX** for worker-created cards — workers now emit a "I created a follow-up card" claim that Hermes flags as `hallucination_gate_status=pending` until something verifies the underlying card exists. Scarf needs to render the flag and offer Verify / Reject so the user is the verification gate.
2. **Generic diagnostics engine** for task distress signals — Hermes now emits a structured diagnostics array on a task / run when it observes distress (heartbeat-stalled, repeated tool errors, unbounded retry loop, OOM proxy, etc.). Scarf needs to render those diagnostics in the inspector so the user can act before the auto-block fires.
3. **Per-task `max_retries` override**`hermes kanban create --max-retries N` (write-once at create) and the field shows up on `kanban show --json`. Surface on the create sheet + inspector header.
4. **Multiline textarea for inline-create title** — v0.13 server tolerates multi-line titles. The Scarf create sheet's title is currently a single-line `ScarfTextField`; convert to a multi-line input so a long title doesn't get clipped on hover-truncate.
5. **Heartbeat / reclaim / zombie / retry-cap reliability fixes** — mostly server-side, but Scarf's run-row + log-tab phrasing ("stale_lock") becomes user-hostile when v0.13 emits a richer outcome ("zombied — reclaimed by reaper"). Render the new outcome string verbatim and add a glossary tooltip.
6. **Auto-block workers that exit without completing** + `auto_blocked_reason` — currently Scarf renders a generic "Last run: blocked" banner; v0.13 attaches a structured reason ("worker exited without `kanban complete`"). Replace the generic banner with the reason when present.
7. **Detect darwin zombie workers** — when a card is reclaimed because the worker zombied (process exited but didn't release the lock), the diagnostics engine emits a `darwin_zombie_detected` kind. Render with a specific glyph + tooltip rather than the generic stale-lock banner.
8. **Unify failure counter across spawn / timeout / crash outcomes** — server-side counter rename; Scarf's run-row outcome label rendering may need to absorb a new normalized counter (`failure_count` rather than three separate counters). Verify the run row still renders all outcomes.
The two release-notes items NOT in WS-3 scope:
- **Multi-project boards** — already shipped in v2.7.5 via per-project tenants. Hermes v0.13's "one install, many kanbans" framing is the server's catch-up to what Scarf already solved client-side via the `scarf:<slug>` tenant convention. No change here.
- **Shared board, workspaces, and worker logs across profiles** — entirely server-side; Scarf already shows whichever assignee owns a row.
- **Dashboard: workspace kind + path inputs, per-platform home-channel notification toggles** — workspace kind/path already shipped in v2.7.5 (`KanbanCreateSheet.workspaceField`); home-channel toggles are in WS-5 (gateway / messaging) not Kanban.
- **Worker task-ownership enforcement on destructive tool calls** — server-side; Scarf observes the failure mode (a run ends with `permission_denied`) but doesn't need new UI.
### Non-goals (explicitly deferred)
- **Within-column reorder.** Hermes still has no `update --priority` verb. CLAUDE.md "Kanban v3" section explicitly forbids client-side ordering sidecars.
- **Drag from Done.** Done is terminal; the WS-2.7.5 transition planner already throws `forbiddenTransition`. No change.
- **Mutating `priority` / `title` / `body` post-create.** No CLI verb exists. We surface `max_retries` on the inspector header in read-only form.
- **iOS read-only counterpart.** WS-9 picks up iOS catch-up. Scope here is Mac.
- **Live `watch` streaming.** v2.7.5 polls every 5s. v0.13 hasn't added a stable `watch --json` shape Scarf can rely on; deferred until a future flag (`hasKanbanWatch`).
---
## Files to change
The plan is intentionally minimal-touch. Most of the lift is in the Mac inspector + card view + create sheet; the model layer adds a handful of `Codable` fields with `nil` defaults so pre-v0.13 hosts decode without error.
### 1. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesKanbanTask.swift`
**Why:** v0.13 adds four task-level fields the inspector / card need (`max_retries`, `auto_blocked_reason`, `hallucination_gate_status`, optional `diagnostics`). All four must be `Optional` with `nil` decoded for pre-v0.13 hosts.
**Edits:**
- Add four new stored properties between `currentRunId` and the end of the property list (preserve existing initializer ordering — append at the tail of the parameter list with nil defaults so call sites in `KanbanModelsTests`, etc. don't break):
- `public let maxRetries: Int?`
- `public let autoBlockedReason: String?`
- `public let hallucinationGateStatus: String?` — wire enum: `pending` / `verified` / `rejected` / nil. Stays a `String` for the same forward-compat reason `status: String` does (Hermes might add `quarantined`).
- `public let diagnostics: [HermesKanbanDiagnostic]` — defaults to `[]` when absent, matching the existing `skills` pattern (line 115).
- Extend `enum CodingKeys` with:
- `case maxRetries = "max_retries"`
- `case autoBlockedReason = "auto_blocked_reason"`
- `case hallucinationGateStatus = "hallucination_gate_status"`
- `case diagnostics`
- Extend the custom `init(from:)` with four `decodeIfPresent` calls. The `[HermesKanbanDiagnostic]` decode mirrors the `skills` decode: `(try? c.decodeIfPresent([HermesKanbanDiagnostic].self, forKey: .diagnostics)) ?? []`. Wrapping in `try?` matters — a single malformed diagnostic shouldn't poison the whole row.
- Extend the public memberwise initializer (the explicit one starting line 37) — add the four parameters at the tail with nil defaults so v2.7.5 callers compile unchanged.
- Add a typed-mirror enum `KanbanHallucinationGate` next to `KanbanStatus` so views don't string-compare:
```swift
public enum KanbanHallucinationGate: String, Sendable, CaseIterable {
case pending, verified, rejected
public static func from(_ raw: String?) -> KanbanHallucinationGate? {
guard let raw, !raw.isEmpty else { return nil }
return KanbanHallucinationGate(rawValue: raw.lowercased())
}
}
```
**Tolerance contract:** A v0.12 row missing all four fields decodes successfully and renders with no v0.13 chrome. A v0.13 row with all four fields decodes and lights up the new chrome.
### 2. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesKanbanDiagnostic.swift` (NEW)
**Why:** Diagnostics are a fresh wire shape. They're attached in two places (per-task `diagnostics: [...]` and per-run `diagnostics: [...]`), but the Swift type is shared between the two sites.
**Shape (best inference from release notes — verify against live JSON during integration):**
```swift
public struct HermesKanbanDiagnostic: Sendable, Equatable, Identifiable, Codable {
public let id: UUID = UUID() // synthetic; not on wire
public let kind: String // heartbeat_stalled | tool_error_loop | retry_cap_hit |
// unbounded_retry | darwin_zombie_detected | spawn_failure |
// worker_exit_no_complete | …
public let message: String? // human-friendly elaboration
public let detectedAt: String? // ISO-8601 (decode flexible — Unix int or string)
enum CodingKeys: String, CodingKey {
case kind
case message
case detectedAt = "detected_at"
}
// custom init(from:) for flexible timestamp decode, mirroring HermesKanbanTask.decodeFlexibleTimestamp
}
```
Plus a typed-mirror enum `KanbanDiagnosticKind` for known kinds (default `.unknown` for forward compat — matches the `KanbanStatus` / `KanbanEventKind` pattern). Glyph + color helpers live alongside it so views don't switch on raw strings.
**Cases for the typed-mirror enum (initial set; add as Hermes ships more):**
- `.heartbeatStalled` — heartbeat older than `max_runtime_seconds / 4`, glyph `waveform.path.badge.minus`, tint `.warning`
- `.toolErrorLoop` — same tool errored ≥ 3 times in a row, glyph `arrow.triangle.2.circlepath.exclamationmark`, tint `.warning`
- `.retryCapHit``failure_count >= max_retries`, glyph `nosign`, tint `.danger`
- `.unboundedRetry` — worker is retrying without backoff (was a v0.12 bug class), glyph `arrow.clockwise.circle.fill`, tint `.warning`
- `.darwinZombieDetected` — process zombied without releasing lock, glyph `apple.logo`, tint `.danger`
- `.spawnFailure``os/exec` returned non-zero spawning the worker, glyph `bolt.slash`, tint `.danger`
- `.workerExitNoComplete` — worker exited 0 without calling `kanban complete`, glyph `figure.walk.departure`, tint `.warning` (pairs with `auto_blocked_reason`)
- `.unknown` — fallback for any kind Hermes adds we don't recognize; render kind raw
### 3. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesKanbanRun.swift`
**Why:** Per-run diagnostics share the same type. The run row in the inspector renders them under the run.
**Edits:**
- Add `public let diagnostics: [HermesKanbanDiagnostic]` (defaults to `[]`).
- Extend `enum CodingKeys` with `case diagnostics`.
- Extend `init(from:)` with the same `decodeIfPresent` + `?? []` pattern.
- Extend the public memberwise initializer with the parameter (default `[]`).
- Extend `encode(to:)` with `try c.encode(diagnostics, forKey: .diagnostics)` (encoding round-trip matters for tests).
- Optional v0.13 housekeeping: `failure_count: Int?` if v0.13's unified counter is exposed on the run shape (unify failure counter across spawn / timeout / crash). If it appears as a top-level key on the run, decode it; if not, this stays a server-internal field and Scarf doesn't need it.
### 4. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesKanbanTaskDetail.swift`
**Why:** No structural change required if `diagnostics` is on the inner `HermesKanbanTask`. But verify the JSON shape: in some Hermes verbs the diagnostics array hangs off the *envelope* (`{task: {…}, comments: […], events: […], diagnostics: […]}`) rather than the task. If it's on the envelope, add an optional sibling field here and surface `detail.task.diagnostics ?? detail.diagnostics ?? []` from the inspector.
**Edits (defensive):** add `public let envelopeDiagnostics: [HermesKanbanDiagnostic]?` decoded from `case envelopeDiagnostics = "diagnostics"`. UI source of truth becomes a computed helper on the detail:
```swift
public var allDiagnostics: [HermesKanbanDiagnostic] {
let onTask = task.diagnostics
let onEnvelope = envelopeDiagnostics ?? []
// Dedup by (kind, detectedAt). Wire-side dupes are unlikely but cheap to filter.
var seen = Set<String>()
return (onTask + onEnvelope).filter {
let key = "\($0.kind)|\($0.detectedAt ?? "")"
return seen.insert(key).inserted
}
}
```
### 5. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/KanbanCreateRequest.swift`
**Why:** The create sheet needs a `--max-retries N` flag.
**Edits:**
- Add `public var maxRetries: Int?` to the struct.
- Add the parameter to the public initializer (tail position, default nil).
- Extend `argv()` between `maxRuntimeSeconds` and `createdBy` (line 80-ish):
```swift
if let maxRetries {
args.append(contentsOf: ["--max-retries", String(maxRetries)])
}
```
- Argv ordering is purely cosmetic from Hermes's perspective (it re-parses), but keep deterministic order so test fixtures stay stable.
### 6. `scarf/Packages/ScarfCore/Sources/ScarfCore/Services/KanbanService.swift`
**Why:** Hallucination-gate verify / reject. Best inference from the release notes is that Hermes added a verb like `kanban verify <id>` or expanded `kanban show` with a sibling write-verb. **This needs verification** — see Open Questions #1.
**Edits (proposed; mark TODO until verified against Hermes v0.13 source):**
- Add a `verify(taskId:)` method that runs `hermes kanban verify <id>`. Returns Void; the polling loop picks up the new `hallucination_gate_status=verified`. If the verb is named differently (`hallucination verify`, `confirm`, `accept`), rename the Swift method to track. **Do not invent a CLI verb name without a real CLI to call against** — gate this behind a guarded TODO and pull from the live binary first.
- Add a `rejectHallucinated(taskId:)` method. Most likely path: the user "rejects" by archiving (since the worker's claim was a hallucination, the right resolution is to archive the bogus card). If Hermes ships a dedicated reject verb, wire it; otherwise route through `archive(taskIds:)` with a comment ("Rejected as hallucinated by Scarf user").
- **Do NOT** add a `setMaxRetries(taskId:)` post-create mutation method. Hermes pattern is write-once. Setting `max_retries` after create has no CLI verb in v0.13. Document this as a Limitation in inspector tooltips.
### 7. `scarf/scarf/Features/Kanban/Views/KanbanCreateSheet.swift`
**Why:** Multi-line title + new `Max retries` numeric field, both gated on `hasKanbanDiagnostics`.
**Edits:**
- Replace the single-line `titleField` (lines 116-122):
```swift
ScarfTextField("What needs doing?", text: $title)
```
with a multi-line variant. Two acceptable approaches:
- **Preferred:** SwiftUI `TextField` with `axis: .vertical` and `lineLimit(1...4)`. Wraps cleanly inside the existing `ScarfTextField` chrome on macOS 14.6+. Pre-existing `ScarfTextField` is a wrapper — extend the wrapper to take an optional `axis` parameter or add a new `ScarfTextEditor` sibling component to `ScarfDesign`. Touch the design package only if the multi-line variant doesn't already exist there. (Audit `Packages/ScarfDesign/` first; if `ScarfTextEditor` exists, use it.)
- **Fallback:** A bare `TextEditor` mirroring the `descriptionField` chrome, with a smaller `minHeight: 36, maxHeight: 96` so single-line titles still feel right.
- Gating: Since macOS 14.6 has no plumbing problem with multi-line text, keep the multi-line input on for **all** versions of Hermes — pre-v0.13 will simply receive a single-line title at the wire (`\n` stripped client-side before submit if Hermes < 0.13 truncates on newlines). Use the `hasKanbanDiagnostics` flag to **decide whether to strip newlines** at submit time, not whether to render the multi-line input. Read the capability via the existing `@Environment` injection pattern (look up how other create sheets read it; if not yet wired here, accept it as a `let capabilities: HermesCapabilitiesStore` init parameter).
- Add a new section between `priorityField` and `skillsField`:
```
┌─────────────────────────────┐
│ Max retries │
│ subtitle: "0 = no retries. │
│ Defaults to 3." │
│ ┌───────────────────────┐ │
│ │ Stepper: [3] [- +] │ │
│ └───────────────────────┘ │
└─────────────────────────────┘
```
- New `@State` storage: `@State private var maxRetries: Int = 3` and `@State private var maxRetriesEnabled: Bool = false`. Toggle gates whether `maxRetries` is sent at all (so we can preserve "let server pick the default" by leaving the flag absent).
- Show this section only when `capabilities.hasKanbanDiagnostics` is true. Pre-v0.13 hosts get the v2.7.5 sheet unchanged (no new field).
- Wire into `makeRequest()` (line 309-347): pass `maxRetries: maxRetriesEnabled ? maxRetries : nil`.
- Strip newlines in title pre-submit when `!capabilities.hasKanbanDiagnostics` to defend against pre-v0.13 hosts: `let titleForSubmit = trimmedTitle.replacingOccurrences(of: "\n", with: " ")` only on the pre-v0.13 path.
### 8. `scarf/scarf/Features/Kanban/Views/KanbanInspectorPane.swift`
**Why:** This is the biggest delta — diagnostics rendering, hallucination Verify/Reject banner, max_retries header chip, expanded auto_blocked_reason banner.
**Edits:**
#### 8a. Header chip row (lines 152-167)
Add a chip for `max_retries` when present (gated on `hasKanbanDiagnostics`):
```swift
if let maxRetries = task.maxRetries {
ScarfBadge("retries: \(maxRetries)", kind: .neutral)
.fixedSize()
.help("Max retries set at create time. Hermes has no update verb — re-create the task to change this.")
}
```
Inserted in the chip-row HStack between `workspaceKind` and `tenant`.
#### 8b. Hallucination-gate banner (NEW, in `healthBanner(for:)`)
Insert above the existing `needsAssignee` / `hadFailedEndedRun` checks. Render only when `KanbanHallucinationGate.from(task.hallucinationGateStatus) == .pending`:
```swift
@ViewBuilder
private func hallucinationBanner(for task: HermesKanbanTask) -> some View {
HStack(alignment: .top, spacing: ScarfSpace.s2) {
Image(systemName: "questionmark.diamond.fill")
.foregroundStyle(ScarfColor.warning)
.font(.system(size: 13, weight: .semibold))
VStack(alignment: .leading, spacing: 4) {
Text("Created by a worker — verify before running")
.scarfStyle(.captionStrong)
.foregroundStyle(ScarfColor.foregroundPrimary)
Text("A worker claimed it created this card; Hermes hasn't confirmed the underlying work exists. Verify the card matches a real follow-up, or reject if it's a hallucinated reference.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
HStack(spacing: ScarfSpace.s2) {
Button("Verify") { onVerifyHallucination() }
.buttonStyle(ScarfPrimaryButton())
Button("Reject") { onRejectHallucination() }
.buttonStyle(ScarfDestructiveButton())
}
.padding(.top, 2)
}
Spacer(minLength: 0)
}
.padding(ScarfSpace.s2)
.background(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.fill(ScarfColor.warning.opacity(0.10))
)
.overlay(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.strokeBorder(ScarfColor.warning.opacity(0.4), lineWidth: 1)
)
}
```
Two new closure parameters on the inspector init: `onVerifyHallucination: () -> Void`, `onRejectHallucination: () -> Void`. They're called from the buttons; `KanbanBoardView` wires them to `viewModel.verify(taskId:)` / `viewModel.rejectHallucinated(taskId:)`.
Render order in `healthBanner`: hallucination first (the user must resolve this before anything else makes sense), then unassigned, then last-failed-run. Stack vertically inside a `VStack(alignment: .leading, spacing: ScarfSpace.s2)` rather than the current `if/else if`.
#### 8c. Auto-blocked reason banner (extension of existing red banner)
Currently `healthBanner` renders a generic "Last run: blocked" message. v0.13 ships `auto_blocked_reason` on the task itself. Update logic:
```swift
if KanbanStatus.from(task.status) == .blocked,
let reason = task.autoBlockedReason, !reason.isEmpty {
bannerRow(
icon: "exclamationmark.octagon.fill",
tint: ScarfColor.danger,
title: "Auto-blocked",
message: reason // verbatim — Hermes-side message is the source of truth
)
}
```
This banner takes precedence over the existing `lastEndedRun.outcome == "blocked"` rendering (server-side reason is more specific than client-side derived).
#### 8d. Diagnostics rendering on Runs tab
Below each `runRow(_:)` (lines 562-594), insert a `diagnosticsRow(for:)` when the run has any:
```swift
if !run.diagnostics.isEmpty {
diagnosticsBlock(run.diagnostics)
}
```
```swift
@ViewBuilder
private func diagnosticsBlock(_ diags: [HermesKanbanDiagnostic]) -> some View {
VStack(alignment: .leading, spacing: 4) {
Text("Diagnostics")
.scarfStyle(.captionUppercase)
.foregroundStyle(ScarfColor.foregroundFaint)
FlowLayout(spacing: 4) { // reuse existing layout primitive if present; otherwise HStack with wrapping
ForEach(diags) { diag in
let kind = KanbanDiagnosticKind.from(diag.kind)
ScarfBadge(diag.kind, kind: kind.badgeKind)
.help(diag.message ?? diag.kind)
}
}
}
.padding(.top, 4)
}
```
If a `FlowLayout` primitive doesn't exist in the codebase, fall back to a single-line `ScrollView(.horizontal, showsIndicators: false)` so a long diag list doesn't blow out card width.
#### 8e. Diagnostics on the task header
Top-level diagnostics (the `task.diagnostics ?? []`, NOT the per-run ones) are about the task, not a specific attempt. Render under the chip row in the header:
```swift
if !task.diagnostics.isEmpty {
diagnosticsBlock(task.diagnostics)
.padding(.top, 4)
}
```
#### 8f. Action bar update
When `hallucination_gate_status == .pending`, suppress the "Start" button (Verify-or-Reject is the gate). The existing `primaryAction` switch already keys on `KanbanStatus.from(task.status)`; add a guard at the top of `@ViewBuilder primaryAction`:
```swift
if KanbanHallucinationGate.from(task.hallucinationGateStatus) == .pending {
EmptyView() // banner provides the actions
} else {
// existing switch
}
```
### 9. `scarf/scarf/Features/Kanban/Views/KanbanCardView.swift`
**Why:** Card-level signals — hallucination dim + glyph, auto-block sub-line, diagnostics indicator.
**Edits:**
- New computed `private var hallucinationGate: KanbanHallucinationGate?` reading off the task.
- In `body`, apply 0.6 opacity when `hallucinationGate == .pending`:
```swift
.opacity(task.isDone ? doneOpacity : (hallucinationGate == .pending ? 0.6 : 1.0))
```
- In `titleRow`, add a yellow ⚠ glyph when `hallucinationGate == .pending`. It overlaps semantically with the existing `needsAssignmentWarning` glyph, so:
- If both are true, prefer the hallucination glyph (more specific).
- Render at the same right-side slot.
```swift
if hallucinationGate == .pending {
Image(systemName: "questionmark.diamond.fill")
.foregroundStyle(ScarfColor.warning)
.font(.system(size: 11, weight: .semibold))
.help("Worker-created — verify before running")
} else if needsAssignmentWarning {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(ScarfColor.warning)
.font(.system(size: 11, weight: .semibold))
.help("Unassigned — Hermes's dispatcher silently skips tasks with no assignee, …")
}
```
- Auto-block sub-line: in the blocked branch of `relativeTimeLabel` (line 254-260), if `task.autoBlockedReason` is present, append the first 30 chars truncated:
- Easier path: don't shoehorn into `relativeTimeLabel`. Add a separate sub-line in the footer above the existing `relativeTimeLabel` when `KanbanStatus.from(status) == .blocked && task.autoBlockedReason != nil`:
```swift
if KanbanStatus.from(task.status) == .blocked,
let reason = task.autoBlockedReason, !reason.isEmpty {
Text(reason.prefix(60))
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.danger)
.lineLimit(1)
.truncationMode(.tail)
.help(reason)
}
```
- Diagnostics indicator (subtle): if `!task.diagnostics.isEmpty`, render a small dot in the footer right side next to the priority indicator:
```swift
if !task.diagnostics.isEmpty {
Image(systemName: "stethoscope")
.font(.system(size: 9))
.foregroundStyle(ScarfColor.warning)
.help("\(task.diagnostics.count) diagnostic signal\(task.diagnostics.count == 1 ? "" : "s")")
}
```
- Done dim: leave alone; v0.13 darwin-zombie fix doesn't change Done semantics.
### 10. `scarf/scarf/Features/Kanban/Views/KanbanBoardView.swift`
**Why:** Wire the new inspector callbacks (`onVerifyHallucination`, `onRejectHallucination`) into the VM.
**Edits:**
- In the inspector instantiation, pass two new closures:
```swift
KanbanInspectorPane(
service: viewModel.service,
taskId: id,
...,
onVerifyHallucination: { viewModel.verifyHallucination(taskId: id) },
onRejectHallucination: { viewModel.rejectHallucination(taskId: id) }
)
```
- Capability gate ambient via the `HermesCapabilitiesStore` `.environment(_:)` injection from `ContextBoundRoot` (already in place per CLAUDE.md). Read with `@Environment(HermesCapabilitiesStore.self)` and pass the relevant flag down to `KanbanCreateSheet` for the max-retries field.
### 11. `scarf/scarf/Features/Kanban/ViewModels/KanbanBoardViewModel.swift`
**Why:** Add `verifyHallucination(taskId:)` and `rejectHallucination(taskId:)` methods. Also extend the optimistic-override mechanism to cover hallucination-gate transitions so the banner disappears immediately on Verify (and the card un-dims).
**Edits:**
- Add a sibling override map for hallucination state:
```swift
/// Mirrors `optimisticOverrides` but for hallucination-gate transitions.
/// Cleared when the polled response confirms the new gate status.
private var optimisticHallucinationOverrides: [String: KanbanHallucinationGate] = [:]
```
- Or simpler: extend `optimisticOverrides` to a richer struct
```swift
private struct OptimisticOverride {
var status: String?
var hallucinationGate: KanbanHallucinationGate?
}
private var optimisticOverrides: [String: OptimisticOverride] = [:]
```
This is cleaner long-term; touches more existing code (~10 lines). Recommend the struct approach.
- Add `verifyHallucination(taskId:)`:
```swift
func verifyHallucination(taskId: String) {
// Optimistic — flip to verified locally so banner disappears.
optimisticOverrides[taskId, default: .init()].hallucinationGate = .verified
Task {
do {
try await service.verify(taskId: taskId) // pending CLI verb confirmation; see Open Questions
await refresh()
} catch let err as KanbanError {
optimisticOverrides[taskId]?.hallucinationGate = nil
lastError = err.errorDescription
} catch {
optimisticOverrides[taskId]?.hallucinationGate = nil
lastError = error.localizedDescription
}
}
}
```
- Add `rejectHallucination(taskId:)`:
```swift
func rejectHallucination(taskId: String) {
// Treat as archive + comment for clarity in the audit trail.
Task {
do {
try await service.comment(taskId: taskId, text: "Rejected as hallucinated (no underlying work).", author: nil)
try await service.archive(taskIds: [taskId])
await refresh()
} catch let err as KanbanError {
lastError = err.errorDescription
} catch {
lastError = error.localizedDescription
}
}
}
```
**Note:** if Hermes v0.13 adds a dedicated `kanban reject` or `kanban hallucination reject` verb, swap the body to call it. Either way, the VM API stays stable — the surface for views is "reject" returning Void.
- Update `mergePolledTasks` to clear `optimisticHallucinationOverrides` entries when the polled task's `hallucination_gate_status` matches:
```swift
for (id, override) in optimisticOverrides {
guard let row = filtered.first(where: { $0.id == id }) else {
if !presentIds.contains(id) {
optimisticOverrides.removeValue(forKey: id)
}
continue
}
// Status side (existing).
if let optStatus = override.status,
columnFromStatus(optStatus) == columnFromStatus(row.status) {
optimisticOverrides[id]?.status = nil
}
// Hallucination gate side (new).
if let optGate = override.hallucinationGate,
KanbanHallucinationGate.from(row.hallucinationGateStatus) == optGate {
optimisticOverrides[id]?.hallucinationGate = nil
}
// Empty override — drop entirely.
if optimisticOverrides[id]?.status == nil,
optimisticOverrides[id]?.hallucinationGate == nil {
optimisticOverrides.removeValue(forKey: id)
}
}
```
- Update `effectiveColumn` and a new `effectiveHallucinationGate(_:)` to consult the override.
### 12. `scarf/Packages/ScarfCore/Tests/ScarfCoreTests/KanbanModelsTests.swift`
**Why:** The tolerant-decode contract is the single most important invariant. Tests must cover both shapes.
**Edits:**
#### 12a. New test — v0.13 task shape decodes with all new fields populated:
```swift
@Test func decodeV013TaskFields() throws {
let json = """
{
"id": "t_v013",
"title": "v0.13 task",
"status": "blocked",
"max_retries": 5,
"auto_blocked_reason": "worker exited without `kanban complete`",
"hallucination_gate_status": "pending",
"diagnostics": [
{"kind": "worker_exit_no_complete", "message": "exit code 0 with no complete call", "detected_at": 1778160614},
{"kind": "darwin_zombie_detected", "detected_at": "2026-05-09T12:00:00Z"}
]
}
"""
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
#expect(task.maxRetries == 5)
#expect(task.autoBlockedReason?.contains("kanban complete") == true)
#expect(task.hallucinationGateStatus == "pending")
#expect(task.diagnostics.count == 2)
#expect(task.diagnostics.first?.kind == "worker_exit_no_complete")
#expect(task.diagnostics.last?.detectedAt?.contains("2026") == true)
}
```
#### 12b. New test — v0.12 (legacy) task shape decodes with new fields = nil/empty:
```swift
@Test func decodeV012TaskHasNoNewFields() throws {
let json = """
{"id": "t_legacy", "title": "v0.12 task", "status": "ready"}
"""
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
#expect(task.maxRetries == nil)
#expect(task.autoBlockedReason == nil)
#expect(task.hallucinationGateStatus == nil)
#expect(task.diagnostics.isEmpty)
}
```
#### 12c. New test — diagnostics with malformed entry doesn't poison the array:
```swift
@Test func decodeMalformedDiagnosticTolerated() throws {
// If Hermes emits a malformed diagnostic, the rest of the task should
// still decode. We use try? on the diagnostics decode so a single
// bad entry doesn't reject the whole row.
let json = """
{
"id": "t_x",
"title": "x",
"status": "ready",
"diagnostics": "not-an-array"
}
"""
let task = try JSONDecoder().decode(HermesKanbanTask.self, from: Data(json.utf8))
#expect(task.id == "t_x")
// Diagnostics field couldn't decode — treat as empty.
#expect(task.diagnostics.isEmpty)
}
```
#### 12d. New test — `KanbanHallucinationGate.from(_:)` mirror:
```swift
@Test func hallucinationGateMirrorMapsKnownValues() {
#expect(KanbanHallucinationGate.from("pending") == .pending)
#expect(KanbanHallucinationGate.from("verified") == .verified)
#expect(KanbanHallucinationGate.from("REJECTED") == .rejected) // case-insensitive
#expect(KanbanHallucinationGate.from(nil) == nil)
#expect(KanbanHallucinationGate.from("") == nil)
#expect(KanbanHallucinationGate.from("quarantined") == nil) // unknown returns nil
}
```
#### 12e. New test — KanbanCreateRequest argv carries `--max-retries`:
```swift
@Test func createRequestArgvIncludesMaxRetries() {
let req = KanbanCreateRequest(title: "t", maxRetries: 5)
let argv = req.argv()
#expect(argv.contains("--max-retries"))
#expect(argv.contains("5"))
}
@Test func createRequestArgvOmitsMaxRetriesWhenAbsent() {
let req = KanbanCreateRequest(title: "t")
let argv = req.argv()
#expect(!argv.contains("--max-retries"))
}
```
#### 12f. New test — Run with diagnostics decodes:
```swift
@Test func decodeRunWithDiagnostics() throws {
let json = """
{
"id": 1,
"task_id": "t_x",
"status": "failed",
"started_at": 1778160000,
"ended_at": 1778160300,
"outcome": "crashed",
"error": "OOM",
"diagnostics": [
{"kind": "retry_cap_hit", "message": "3/3 retries exhausted"}
]
}
"""
let run = try JSONDecoder().decode(HermesKanbanRun.self, from: Data(json.utf8))
#expect(run.diagnostics.count == 1)
#expect(run.diagnostics.first?.kind == "retry_cap_hit")
}
@Test func decodeRunWithoutDiagnostics() throws {
let json = """
{"id": 1, "task_id": "t_x", "status": "running", "started_at": 1778160000}
"""
let run = try JSONDecoder().decode(HermesKanbanRun.self, from: Data(json.utf8))
#expect(run.diagnostics.isEmpty)
}
```
These tests pin the tolerant-decode contract on both sides (with new fields, without new fields). Pre-v0.13 hosts running v2.8 Scarf must keep decoding cleanly — without these tests we'd ship a regression that bites every customer not yet on Hermes v0.13.
### 13. `scarf/Packages/ScarfDesign/` — IF a multi-line text component is missing
**Why:** If `ScarfTextField` doesn't already accept an `axis: .vertical` parameter (likely the case in v2.7.5), add one OR add a `ScarfTextEditor` component to the design package so the create sheet can use the design-system token.
**Conservative approach:** Use `TextField` with `axis: .vertical` directly inside `KanbanCreateSheet`, styled to match `ScarfTextField` chrome (background, border, padding from `ScarfColor`/`ScarfRadius`/`ScarfSpace`). Defer adding a new design-system component to a follow-up — design-system additions deserve their own review pass and aren't on this WS's critical path.
---
## Capability gating
All of the new Mac surface gates on `HermesCapabilities.hasKanbanDiagnostics` (already shipped in WS-1, semver `>= 0.13.0`).
### Gating decisions per surface
| Surface | Gated? | Rationale |
| --- | --- | --- |
| `max_retries` field on create sheet | Yes | Pre-v0.13 Hermes rejects `--max-retries` flag with non-zero exit. Hide the field; don't pass the flag. |
| Multi-line title input rendering | No | Multi-line input is harmless on v0.12 (the ScarfTextField is just visually taller). |
| Multi-line title submitted with `\n` | Yes | Pre-v0.13 may truncate at the first `\n`. Strip newlines client-side when `!hasKanbanDiagnostics`. |
| `max_retries` chip on inspector header | Yes | Pre-v0.13 task rows never carry `max_retries`, so `task.maxRetries` is nil — `if let` already hides it. Belt-and-suspenders: also gate on the flag. |
| Hallucination-gate banner | Yes | Pre-v0.13 task rows never carry `hallucination_gate_status`. Same `if let` belt-and-suspenders. |
| Diagnostics rendering on inspector | Yes | Pre-v0.13 tasks carry empty `diagnostics`, so the rendering would no-op. Gate explicitly anyway so a future server-side change doesn't accidentally surface partial UX on a pre-v0.13 host. |
| Auto-blocked banner with reason | Yes | Pre-v0.13 may write a similar string in a different place. Gate so we don't double-render. |
| Card hallucination dim/glyph | Yes | Same. |
| Card diagnostics dot | Yes | Same. |
| Verify / Reject buttons | Yes (hard gate) | The `kanban verify` verb (or whatever Hermes ships) doesn't exist pre-v0.13. The buttons MUST be hidden, not just disabled — a disabled button conveys "this might work later in this session" which is wrong for a capability-gated feature. |
### Plumbing
`HermesCapabilitiesStore` is already injected via `.environment(_:)` on `ContextBoundRoot` (Mac) — see CLAUDE.md "Capability gating" section. Read in views with `@Environment(HermesCapabilitiesStore.self) private var capabilities` (or whatever key is currently used; verify with the existing `Curator` feature gating).
**No new HermesCapabilities flag.** WS-1 already shipped `hasKanbanDiagnostics` covering all eight v0.13 Kanban additions in a single boolean. Resist the urge to split into `hasHallucinationGate` / `hasDiagnostics` / `hasMaxRetries` — Hermes shipped them together, and finer gating is YAGNI per the CLAUDE.md "Kanban v3" pattern.
---
## How to test
### Unit tests (KanbanModelsTests)
The test additions are listed above (§12.a–§12.f). Run:
```bash
xcodebuild -project scarf/scarf.xcodeproj \
-scheme ScarfCore \
-destination 'platform=macOS' \
test
```
All v0.13 fixtures should decode AND all v0.12 fixtures should continue to decode. The two-shape pair is the critical contract.
### Manual smoke (against a real Hermes v0.13 host)
Per CLAUDE.md "remote-servers dogfooding" memory: dogfood against the Mardon Mac Mini at 192.168.0.82 — set context to that server (or run against local v0.13 install).
1. **Hallucination gate end-to-end**
- Trigger a worker that creates a follow-up card via the agent's tooling. Server flips it to `pending`.
- Card on board: 0.6 opacity, yellow ⚠ glyph in title row.
- Inspector: yellow banner above body with Verify / Reject buttons.
- Click Verify: optimistic flip — banner disappears immediately, card un-dims. Within 5s, polled state confirms `verified`. No regressions in optimistic-override clearing.
- Click Reject (on a different pending task): comment + archive sequence runs; card disappears from active board (visible only with "Show archived").
2. **Diagnostics**
- Trigger a worker that hits a heartbeat stall (e.g. Sleep > heartbeat interval). Verify `heartbeat_stalled` diagnostic appears under the run row in the inspector Runs tab.
- Trigger a tool-error loop (force a tool to error 3+ times). Verify `tool_error_loop` diagnostic shows up.
- Verify the dot-indicator on the card lights up.
3. **`max_retries`**
- Create a task via the create sheet with Max retries = 1.
- Verify the inspector header shows `retries: 1`.
- Force a failure; verify the worker is auto-blocked after 1 retry (server-side behavior).
- The chip is read-only — verify there's no edit affordance.
4. **Auto-blocked reason**
- Trigger a worker that exits 0 without calling `kanban complete`.
- Verify the inspector banner says "Auto-blocked" with the server's `auto_blocked_reason` verbatim.
- Verify the card footer shows the truncated reason in red.
5. **Multi-line title**
- In the create sheet, type a 3-line title.
- Verify the field grows.
- Submit. Verify on the Hermes v0.13 host the title is preserved with newlines (`hermes kanban show` JSON should round-trip them).
6. **Pre-v0.13 host (regression smoke)**
- Switch context to a Hermes v0.12 host.
- Verify: max-retries field hidden in create sheet; max-retries chip absent in inspector; no hallucination banner; no diagnostics rendering; create still works; existing v2.7.5 chrome unchanged.
- Title field: type a multi-line title — submit. Verify newlines were stripped client-side (no exception on the server).
### Integration smoke
Build the app and run the existing Kanban smoke flow from `docs/PRD.md` to verify drag-drop, optimistic merge, and the per-project tenant flow are unaffected. The new code paths should not change v2.7.5 behavior on a v0.13 host that happens to have no diagnostics / hallucination signals (the dominant case in normal use).
### Example v0.13 JSON fixtures (use as test inputs and as documentation)
Drop these into `KanbanModelsTests` as inline fixtures. They're our wire-shape claim until we can validate against real CLI output during integration.
#### Task with all v0.13 fields
```json
{
"id": "t_v013_full",
"title": "Investigate flaky test\nReproduces only on CI",
"body": "Repro: run the integration suite 10x.",
"assignee": "researcher",
"status": "blocked",
"priority": 75,
"tenant": "scarf:demo",
"workspace_kind": "scratch",
"workspace_path": "/Users/alan/.hermes/kanban/workspaces/t_v013_full",
"created_by": "agent:claude-sonnet-4-7",
"created_at": 1778160614,
"skills": ["debugging"],
"max_runtime_seconds": 1800,
"max_retries": 3,
"auto_blocked_reason": "worker exited (code 0) without calling `kanban complete`",
"hallucination_gate_status": "pending",
"diagnostics": [
{
"kind": "worker_exit_no_complete",
"message": "exit code 0 with no complete call",
"detected_at": 1778161000
},
{
"kind": "heartbeat_stalled",
"message": "no heartbeat for 4m20s (max_runtime/4 = 7m30s, slack budget exceeded)",
"detected_at": 1778161200
}
]
}
```
#### Task with no v0.13 fields (legacy v0.12 host)
```json
{
"id": "t_v012_legacy",
"title": "Translate doc",
"status": "ready",
"priority": 50,
"skills": []
}
```
#### Run with diagnostics
```json
{
"id": 7,
"task_id": "t_v013_full",
"profile": "researcher",
"status": "failed",
"started_at": 1778160614,
"ended_at": 1778160914,
"outcome": "crashed",
"error": "subprocess died with SIGKILL",
"summary": null,
"diagnostics": [
{"kind": "darwin_zombie_detected", "message": "PID 9842 left as zombie", "detected_at": 1778160916},
{"kind": "retry_cap_hit", "message": "3/3 retries exhausted"}
]
}
```
---
## Open questions
1. **What's the exact CLI verb name for hallucination-gate verify / reject?** Release notes say "hallucination gate + recovery UX" but don't enumerate the verb. Best inference is `hermes kanban verify <id>` or `hermes kanban gate verify <id>`. **Action:** before implementation, run `hermes kanban --help` against a v0.13 binary and confirm. If absent (and the gate is server-flipped automatically once a worker tries to dispatch a hallucinated card), the Reject path still works (archive + comment), but Verify becomes "do nothing" and the card waits for server-side detection. Document in code comment.
2. **Where do diagnostics live on the wire — task envelope, run envelope, or both?** Release notes: "Generic diagnostics engine for task distress signals." This implies task-level. But heartbeat-stalled is a per-run signal. Best inference: per-run for in-flight signals, per-task for cross-run signals (retry cap hit). **Action:** plan handles both via `HermesKanbanTaskDetail.allDiagnostics` and per-run `run.diagnostics`. Verify against real JSON during integration.
3. **Does Hermes v0.13 expose a `set_max_retries` verb post-create?** Release notes say "Per-task `max_retries` override configuration" — ambiguous. If it's create-only (write-once like `priority`), we surface the chip read-only and document the limitation. If it's a settable field, we add an inspector edit affordance. **Action:** confirm at integration time. Plan assumes write-once (matches Hermes pattern).
4. **Failure-counter unification — does the run row need a new field?** Release notes: "Unify failure counter across spawn / timeout / crash outcomes." Best inference: server-side, the `failure_count` is a single column rather than three columns. From Scarf's view, this changes nothing — we render `outcome` (already present), and the count is implicit (count of failed runs in `runs` array). **Action:** verify at integration. If a `failure_count: Int` field shows up, decode it on `HermesKanbanRun` (already in §3) and surface in the run row label as "x/N retries" when `max_retries` is set.
5. **How does v0.13 distinguish darwin zombie from generic stale_lock?** Release notes: "Detect darwin zombie workers." Best inference: the diagnostics array includes a `darwin_zombie_detected` kind on the run. **Action:** plan renders it via the typed-mirror enum. Verify the kind string at integration.
6. **What's the default `max_retries` value?** Plan defaults the create-sheet field to 3 with a "0 = no retries. Defaults to 3." subtitle. Confirm against `hermes kanban stats --json` defaults block (or `hermes kanban --help` text) at integration. If Hermes config exposes a global default, read it and use that as the field's pre-fill.
7. **Are there sub-commands like `hermes kanban diagnose <id>`?** Release notes don't mention, but generic-diagnostics-engine framing leaves room. If such a verb exists, the inspector's diagnostics block could grow a "Run diagnostics" button to manually trigger a fresh check. **Action:** ship without; revisit when verb existence is confirmed.
---
## Out of scope (deferred — likely v2.8.x or v2.9)
- **iOS read-only counterpart** — covered by WS-9 (iOS catch-up). Render hallucination dim, max_retries chip, and auto_blocked_reason banner on the iOS detail sheet read-only. No buttons.
- **`watch` streaming** — when Hermes ships a stable `kanban watch --json` shape, replace the 5s polling loop. New flag `hasKanbanWatch` will gate the surface.
- **Within-column reorder** — still no `update --priority` verb. If Hermes ships one in a future minor, revisit.
- **In-place title / body edit** — same constraint. CLAUDE.md "Don't" list applies unchanged.
- **Cross-column drag from Done** — terminal state.
- **Diagnostics filter on the board** — could imagine "show only tasks with active diagnostics" toggle in the toolbar. Defer until we see how often the dot indicator fires in real use.
- **Bulk verify / reject** — multi-select card → verify all. Defer; the hallucination gate is rare enough that one-at-a-time UX is fine in v2.8.0.
- **Diagnostics history graph** — over time, "this task had heartbeat-stalled 3 times in 6 attempts" is a valuable signal. Defer to a v2.9 dashboard widget on top of the v0.13 stats endpoint.
- **Worker log → diagnostics correlation** — when a diagnostic fires at time T, scroll the log tab to that timestamp. Nice-to-have; defer.
---
## Estimate
**Engineering hours (one engineer, focused):**
| Block | Hours |
| --- | --- |
| Model additions (§1, §2, §3, §4, §5) — fields + tolerant decode | 3 |
| KanbanService verb additions (§6) — verify + reject (with TODO until CLI confirmed) | 2 |
| KanbanCreateSheet edits (§7) — multi-line title + max_retries field | 3 |
| KanbanInspectorPane edits (§8) — banners + diagnostics + header chip + action-bar gate | 5 |
| KanbanCardView edits (§9) — hallucination dim/glyph + auto-block sub-line + diagnostics dot | 2 |
| KanbanBoardView wiring (§10) | 1 |
| KanbanBoardViewModel edits (§11) — extended optimistic override + verify/reject methods | 3 |
| KanbanModelsTests additions (§12) | 2 |
| Capability gating audit / plumbing | 1 |
| Manual smoke (§How to test) — both v0.13 host and v0.12 host | 2 |
| Code review + revisions | 3 |
| **Total** | **~27 hours (≈3.5 working days)** |
**Confidence:** medium-high. The model additions and view edits are mechanical given v2.7.5's existing scaffolding (the optimistic-override pattern, the inspector pane structure, the tolerant-decode tests). The single biggest risk is the hallucination-gate CLI verb name (Open Question #1) — if Hermes shipped a verb name we can't infer, the Verify path is a stub until we see the binary's `--help`. The Reject path always works (archive + comment) so the recovery UX is functional even with #1 unresolved.
**Critical-path dependency:** none. WS-1 already shipped `hasKanbanDiagnostics`. WS-3 has no other workstream dependency.
**Risk register:**
- **Wire-shape mismatch.** If our inferred JSON shape is wrong (e.g. `diagnostics` is keyed `signals` on the wire), the model code is wrong. Mitigation: tolerant decode + integration smoke against a real v0.13 host before merging. Add a fixture-from-real-output test once we have stdout from `hermes kanban show --json` on a v0.13 host.
- **Verb-name uncertainty.** See Open Question #1. Mitigation: stub method with TODO + comment-only archive flow for Reject; ship Verify behind a feature gate in the inspector if needed.
- **Optimistic-override regressions.** Extending the override mechanism to cover hallucination state could destabilize the existing drag-drop optimistic flow. Mitigation: write the struct refactor as a single commit, run the existing transition-planner tests, then write the new tests.
- **Pre-v0.13 silent regression.** The most damaging failure mode is a v0.12 user upgrading Scarf and seeing the board stop loading. Mitigation: §12 tests pin the v0.12 contract; the gating audit table covers each surface; manual smoke against a v0.12 host is a P0 step.
---
## Appendix A — File-touch summary
| File | Purpose | Lines changed (estimate) |
| --- | --- | --- |
| `Models/HermesKanbanTask.swift` | +4 fields, init/decoder updates, +1 enum | ~50 |
| `Models/HermesKanbanDiagnostic.swift` | NEW model + enum mirror | ~80 (new file) |
| `Models/HermesKanbanRun.swift` | +1 field, init/decoder/encoder updates | ~15 |
| `Models/HermesKanbanTaskDetail.swift` | +1 envelope-level diagnostics field, +1 helper | ~20 |
| `Models/KanbanCreateRequest.swift` | +1 field, +1 argv branch | ~10 |
| `Services/KanbanService.swift` | +2 verb methods (verify, reject) | ~30 |
| `Tests/KanbanModelsTests.swift` | +6 tests | ~120 |
| `Features/Kanban/Views/KanbanCreateSheet.swift` | multi-line title + max-retries field + capability plumbing | ~80 |
| `Features/Kanban/Views/KanbanInspectorPane.swift` | hallucination banner + diagnostics + header chip + auto-block reason + action-bar gate | ~150 |
| `Features/Kanban/Views/KanbanCardView.swift` | hallucination dim/glyph + auto-block sub-line + diagnostics dot | ~50 |
| `Features/Kanban/Views/KanbanBoardView.swift` | wire new closures | ~10 |
| `Features/Kanban/ViewModels/KanbanBoardViewModel.swift` | struct override refactor + verify/reject methods + merge update | ~80 |
**Total: 12 files (1 new), roughly 690 lines changed.**
---
## Appendix B — Wiring diagram
```
Hermes v0.13 binary
│ hermes kanban show --json
KanbanService.show ─┐
hermes kanban runs │
│ │
▼ ▼
HermesKanbanRun HermesKanbanTaskDetail
+ diagnostics + task.diagnostics
+ envelope.diagnostics
+ task.maxRetries
+ task.autoBlockedReason
+ task.hallucinationGateStatus
│ KanbanBoardViewModel polls every 5s
optimisticOverrides (struct, not String)
{ taskId: { status?, hallucinationGate? } }
KanbanBoardView ─── KanbanCardView (dim/glyph/dot/sub-line)
└── KanbanInspectorPane
├── headerChips (+ retries chip)
├── hallucinationBanner (Verify / Reject)
├── autoBlockedBanner
├── failureBanner (existing)
├── unassignedBanner (existing)
├── runsTab (+ per-run diagnostics)
└── actionBar (suppressed when hallucination=pending)
```
---
## Appendix C — UX copy register
Centralizing the user-facing strings here so a copy review pass can run before implementation.
| Surface | Copy |
| --- | --- |
| Hallucination banner title | "Created by a worker — verify before running" |
| Hallucination banner body | "A worker claimed it created this card; Hermes hasn't confirmed the underlying work exists. Verify the card matches a real follow-up, or reject if it's a hallucinated reference." |
| Hallucination banner Verify button | "Verify" |
| Hallucination banner Reject button | "Reject" |
| Card hallucination glyph tooltip | "Worker-created — verify before running" |
| Auto-blocked banner title | "Auto-blocked" |
| Auto-blocked banner body | (server-supplied verbatim from `auto_blocked_reason`) |
| Max retries chip | `retries: N` |
| Max retries chip tooltip | "Max retries set at create time. Hermes has no update verb — re-create the task to change this." |
| Diagnostics block label | "Diagnostics" (uppercase caption style) |
| Card diagnostics dot tooltip | "N diagnostic signal(s)" |
| Create sheet max-retries section header | "Max retries" |
| Create sheet max-retries subtitle | "0 = no retries. Defaults to 3." |
| Reject confirm-comment text | "Rejected as hallucinated (no underlying work)." |
---
## Appendix D — Why no dedicated `set_max_retries` verb is right
Hermes's design pattern is consistent: anything that affects how a worker is dispatched is set at `create` time and immutable afterward. `priority`, `title`, `body`, `tenant`, `max_runtime_seconds`, and now `max_retries` all follow this pattern.
The reasoning is dispatcher-correctness: a worker spawning at moment T captures the configuration at moment T. Mutating `max_retries` post-spawn would either:
- Apply only to *future* retry attempts (confusing because the user thinks they raised the cap), OR
- Apply retroactively (confusing because the dispatcher's internal counter mid-stream needs a flush).
Hermes resolves this by making the question moot — the field is write-once. Scarf's posture should be: surface the value clearly, explain the limitation, and make re-create-with-new-value cheap. We already meet the third bar (the create sheet pre-fills sensible defaults). For v2.8.0 we surface the value (max_retries chip in inspector header) and document the limitation in tooltip copy. If there's user demand for "raise the cap on this stuck task," the right move is a "Re-create with bumped retries" inspector action that reads the existing task body / assignee / etc., archives the original, and creates a sibling — a pattern v0.12 already supports without any new verbs. Defer until v2.8.x.
@@ -0,0 +1,561 @@
# WS-4 Plan: Curator archive + prune + list-archived (v2.8.0 / Hermes v0.13)
> **Scope.** Catch Scarf's Curator surface up to Hermes v0.13's new write-side
> verbs: `archive <skill>`, `prune`, `list-archived`, and the synchronous flavor
> of `run`. WS-4 owns Mac UX end-to-end + the ScarfCore parser/service work that
> backs it. iOS catches up read-only in WS-9 (deferred — note at the end).
---
## Goals
1. **Wire all four new v0.13 curator verbs** (`archive`, `prune`, `list-archived`,
synchronous `run`) into ScarfCore through a typed actor surface so the view
model stops shelling out via `runHermes` ad-hoc.
2. **Replace the v0.12 placeholder restore sheet** (free-form text field that
prompted the user to remember archived skill names) with an actual list
of archived skills returned by `hermes curator list-archived`, each row with
per-row Restore + Prune-this-one actions.
3. **Add an "Archive" affordance** to every active-skill row in the leaderboard
so users can manually archive a skill the curator didn't auto-archive.
4. **Add a destructive "Prune all archived" toolbar button** that opens a
confirm sheet enumerating exactly which archived skills are about to be
deleted forever.
5. **Make the "Run Now" button block-with-progress on v0.13+** since the verb is
now synchronous; preserve fire-and-forget on pre-v0.13 hosts.
6. **Pre-v0.13 hosts must see the v2.7.x curator surface unchanged** — no
"Archive" buttons, no Archived section, no Prune button. The legacy
`CuratorRestoreSheet` stays accessible (it's all the v0.12 host has).
7. **Keep parsing pure & testable**: list-archived / prune-summary parse paths
live in `HermesCuratorStatusParser` (or a sibling) with synthetic-fixture
coverage in `HermesCuratorParserTests`.
Non-goals: iOS surface (WS-9), curator config knobs (out of scope — config tab
already covers `auxiliary.curator`), exporting reports.
---
## CLI integration — wire shape per verb
> **Investigation note.** Hermes v0.13 ships these verbs but neither the release
> notes nor the CLI man-page in our repo capture the exact stdout format. Plan
> assumes both human-text and `--json` are available since that's the v0.12
> Kanban convention; first task at implementation time is to run each verb
> against a real v0.13 install and capture stdout into `Tests/Fixtures/`. If
> `--json` doesn't exist for one of these verbs, fall back to a defensive
> text parser and add a `// TODO upstream` flag. **All assumed CLI flags below
> must be confirmed before wiring the parser.**
### `hermes curator list-archived [--json]`
- **Wire shape:** prefer `--json` and decode to `[HermesCuratorArchivedSkill]`.
Fall back to text parse if the flag isn't present (mirrors `kanban runs` JSON
envelope handling).
- **Assumed JSON shape (verify on first run):**
```json
[
{
"name": "legacy-helper",
"category": "templates",
"archived_at": "2026-04-22T03:14:09Z",
"reason": "stale: 91d unused",
"size_bytes": 4521,
"path": "/Users/u/.hermes/skills/.archived/legacy-helper"
}
]
```
- **New model:** `HermesCuratorArchivedSkill` in
`scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesCuratorReport.swift`
with `name: String`, `category: String?`, `archivedAt: String?`,
`reason: String?`, `sizeBytes: Int?`, `path: String?`. All optional except
`name` so a stripped-down host doesn't crash the view. Identifiable on `name`.
- **Empty-state sentinel:** Hermes may print `"no archived skills"` instead of
`[]` (parallel to `"no matching tasks"` in Kanban). Treat as empty — same
defensive fold KanbanService does at line ~45 today.
### `hermes curator archive <skill-name>`
- **Wire shape:** non-destructive (skill is moved, not deleted). No `--json`
needed — exit code is the success channel; stdout is human-readable.
- **Argv:** `["curator", "archive", name]`. No flags in v0.13.
- **Side effects we surface to the user:** the active count drops by 1, the
archived count rises by 1 — both visible after the next `status` reload.
### `hermes curator prune [--dry-run]`
- **Wire shape:** destructive. Removes everything currently archived. Open
question 1 (below): does Hermes v0.13 ship `--dry-run`? Plan **two code paths**:
1. **If `--dry-run` exists:** Scarf's prune confirm sheet calls
`hermes curator prune --dry-run` first, parses the "would remove N skills"
output, and renders the list. Final confirmation calls
`hermes curator prune` (no flag). This is the preferred path.
2. **If no `--dry-run`:** Scarf calls `hermes curator list-archived` to
enumerate what's about to be deleted, shows that list in the confirm
sheet, then calls `hermes curator prune` once the user confirms.
- **Assumed `--dry-run` JSON output (verify):**
```json
{ "would_remove": [{ "name": "...", "size_bytes": 4521 }, ...], "total_bytes": 12345 }
```
- **Optional per-skill prune:** if Hermes accepts
`hermes curator prune <name>` (single-skill prune), wire it as a per-row
action in the Archived list. **Verify before implementing** — release notes
describe `prune` only in the bulk sense. If single-skill is unavailable, the
per-row "Prune" button on the Archived list is dropped from the v2.8
scope and only the bulk "Prune all archived" toolbar button ships.
### `hermes curator run` (now synchronous)
- **Wire shape:** unchanged argv. Behavior changes from fire-and-forget to
blocking on v0.13+. Plan: bump the `runProcess(timeout:)` value from the
current 30 s default to 600 s on v0.13+ hosts. Surface a `ProgressView` next
to the "Run Now" button while the call is in flight, and disable the button
until completion.
- **Capability branch:** `if caps.hasCuratorArchive { /* blocking with
progress */ } else { /* fire-and-forget, immediate toast */ }`.
- **Cancel UX:** for v0.13+ blocking runs, plan a "Cancel" button that calls
`transport.cancel()` on the running process (existing TransportError path).
If transport-level cancel isn't reliable (Local vs Citadel parity), the
cancel button is dropped and we just show indeterminate progress.
---
## Files to change (with specific edits)
### New files
- **`scarf/Packages/ScarfCore/Sources/ScarfCore/Services/CuratorService.swift`**
— new `public actor CuratorService`. Mirrors `KanbanService` shape exactly:
pure I/O, no UI state, every public method dispatches the CLI invocation
through `Task.detached(priority: .utility)` inside the actor. Exposes:
```swift
public actor CuratorService {
public init(context: ServerContext)
// Reads
public func status() async -> HermesCuratorStatus // moves logic out of VM
public func listArchived() async throws -> [HermesCuratorArchivedSkill]
// Writes — already-wired verbs (refactored from VM helpers)
public func runNow(synchronous: Bool, timeout: TimeInterval) async throws
public func pause() async throws
public func resume() async throws
public func pin(_ name: String) async throws
public func unpin(_ name: String) async throws
public func restore(_ name: String) async throws
// Writes — new in v0.13 (WS-4)
public func archive(_ name: String) async throws
public func prune(dryRun: Bool) async throws -> CuratorPruneSummary
// Pure helpers
public nonisolated static func parseListArchived(stdout: String) throws -> [HermesCuratorArchivedSkill]
public nonisolated static func parsePruneDryRun(stdout: String) throws -> CuratorPruneSummary
}
```
- Errors land in a new `CuratorError` enum (Sendable, LocalizedError) —
`transport(message:)`, `nonZeroExit(verb:code:stderr:)`,
`decoding(verb:message:)`. Identical shape to `KanbanError`.
- `runNow(synchronous:timeout:)` takes the capability-decided sync flag from
the call site; the service itself stays version-agnostic (only the timeout
differs in practice).
- **`scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesCuratorArchive.swift`**
— new file holding `HermesCuratorArchivedSkill` and `CuratorPruneSummary`
structs. Both `Sendable, Equatable, Identifiable, Codable`.
```swift
public struct HermesCuratorArchivedSkill: Sendable, Equatable, Identifiable, Codable {
public var id: String { name }
public let name: String
public let category: String?
public let archivedAt: String?
public let reason: String?
public let sizeBytes: Int?
public let path: String?
// Computed for UI — never persisted.
public var sizeLabel: String { /* "4.4 KB" / "—" */ }
public var archivedAtLabel: String { /* "2026-04-22" / "—" */ }
}
public struct CuratorPruneSummary: Sendable, Equatable, Codable {
public let wouldRemove: [HermesCuratorArchivedSkill]
public let totalBytes: Int
public var totalCount: Int { wouldRemove.count }
}
```
- **`scarf/scarf/Features/Curator/Views/CuratorArchivedSection.swift`** — new
Mac sub-view used by `CuratorView`. Renders a `ScarfCard` containing the
Archived list. Inputs: `[HermesCuratorArchivedSkill]`,
`onRestore(name:)`, `onPruneOne(name:)?`, `onPruneAll()`. Empty-state path
renders an "No archived skills" `ScarfCard` with copy explaining what archive
does (helpful since Curator hasn't run yet on a fresh install).
- **`scarf/scarf/Features/Curator/Views/CuratorPruneConfirmSheet.swift`** —
new destructive-confirm sheet. Presents the about-to-be-removed list, total
count, total bytes, and a final "Prune permanently" red button.
### Edited files
- **`scarf/Packages/ScarfCore/Sources/ScarfCore/ViewModels/CuratorViewModel.swift`**
- Replace inline `runAndReload(args:successMessage:)` helpers with
`service.<verb>()` calls. Keep the toast + reload pattern inside the VM.
- Add new `@Observable` state:
- `archivedSkills: [HermesCuratorArchivedSkill] = []`
- `isLoadingArchive = false`
- `isPruning = false`
- `pruneSummary: CuratorPruneSummary?`
- `pendingArchiveName: String?` (track which skill is currently being
archived so the row can show a small spinner without blocking the rest)
- `errorMessage: String?` (replace transient-toast-only failure path with
an inline-banner state, mirroring KanbanBoardViewModel)
- Add new methods:
- `func loadArchive() async`
- `func archive(_ name: String) async`
- `func planPrune() async` — calls `service.prune(dryRun: true)`, populates
`pruneSummary`, opens the confirm sheet (sheet binding sits in the View)
- `func confirmPrune() async` — calls `service.prune(dryRun: false)`
- `func pruneOne(_ name: String) async` — only wired if upstream supports
single-skill prune; otherwise method elided
- Update `runNow()` to accept a `caps: HermesCapabilities` argument (passed
from the View) and switch between sync/async invocations:
- On v0.13+: `await service.runNow(synchronous: true, timeout: 600)` and
poll `viewModel.isLoading` for a progress spinner.
- On pre-v0.13: existing fire-and-forget; toast says "Curator run started".
- Construct service lazily: `private lazy var service = CuratorService(context: context)`.
- **`scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesCuratorReport.swift`**
- No edits to existing models. Add archive-related types in the new
`HermesCuratorArchive.swift` to keep the diff scoped. (Decision: keep one
file per logical surface.)
- **`scarf/scarf/Features/Curator/Views/CuratorView.swift`**
- Inject `@Environment(\.hermesCapabilities)` and read
`caps?.hasCuratorArchive ?? false` once into a local `let archiveAvailable`.
- Header toolbar additions (only when `archiveAvailable`):
- "Prune Archived…" `ScarfDestructiveButton` in the overflow `Menu`,
disabled when `archivedSkills.isEmpty && !isLoadingArchive`.
- Replace "Restore Archived…" menu item with a deep-link to scroll to the
new Archived section (when `archiveAvailable`); leave the existing
`CuratorRestoreSheet` reachable from the same menu **only on pre-v0.13** as
the legacy fallback. On v0.13+ the menu shows just "Prune Archived…" and
the section becomes the restore entry point.
- Add `archiveAvailable` to `activityTables` rendering: each row in the three
leaderboards gains an "Archive" pin-style button (small `Image(systemName:
"archivebox")`) next to the existing pin button. Tooltip "Archive (move
out of active set)". Hidden on pre-v0.13.
- Append `CuratorArchivedSection` between `activityTables` and
`lastReportSection` whenever `archiveAvailable`. Loaded by an additional
`viewModel.loadArchive()` call inside `.task { … }`.
- Wire confirm sheets:
- `.sheet(isPresented: $showPruneSheet) { CuratorPruneConfirmSheet(...) }`
- Existing `$showRestoreSheet` stays — only shown on pre-v0.13.
- Run Now button: while `viewModel.isLoading && archiveAvailable`, show a
`ProgressView()` next to the button label and disable the button. Tooltip:
"Curator running — usually 10-90s. Hermes v0.13 runs synchronously."
- Inline error banner: render `viewModel.errorMessage` as a yellow
`ScarfCard` above `statusSummary` with an "x" dismiss. (Use existing
`ScarfColor.warning` background; inspect the Kanban inline banner for
pattern.)
- **`scarf/scarf/Features/Curator/Views/CuratorRestoreSheet.swift`**
- **No code changes.** Sheet stays as v0.12 fallback. Add a doc-comment
update at the top noting it's legacy-only on v0.13+ — the new
`CuratorArchivedSection` is the preferred path. Don't delete this file
even after WS-4 ships; pre-v0.13 hosts still need it.
- **`scarf/Scarf iOS/Curator/CuratorView.swift`**
- **No code changes in WS-4.** WS-9 will add a read-only "Archived" section
that mirrors the Mac one without per-row write actions. Leave a
`// TODO(WS-9):` marker.
- **`scarf/Packages/ScarfCore/Tests/ScarfCoreTests/HermesCuratorParserTests.swift`**
- Add tests (see "How to test" below).
---
## New types / fields
### `HermesCuratorArchivedSkill` (new)
In `HermesCuratorArchive.swift`. Codable directly from the assumed
`list-archived --json` shape. All fields except `name` optional so a
stripped-down host doesn't crash decoding. Computed `sizeLabel` /
`archivedAtLabel` for the view layer; never persisted.
### `CuratorPruneSummary` (new)
Lists what `prune --dry-run` would remove, plus aggregated `totalBytes`. The
view derives `totalCount` from `wouldRemove.count` so the wire shape stays
flat.
### `CuratorError` (new)
```swift
public enum CuratorError: Error, Sendable, LocalizedError {
case transport(message: String)
case nonZeroExit(verb: String, code: Int32, stderr: String)
case decoding(verb: String, message: String)
}
```
Identical shape to `KanbanError`. View model maps these to inline-banner copy.
### `CuratorViewModel` additions
Already enumerated above. Note: the existing `transientMessage: String?` stays
for happy-path success ("Pinned X", "Resumed", "Archived legacy-helper");
failures route through the new `errorMessage: String?` so dismissals don't
cross-contaminate.
---
## Capability gating
All branches keyed on `caps?.hasCuratorArchive ?? false` (already defined in
`HermesCapabilities.swift:138` per the WS-1 inventory).
| Surface | Pre-v0.13 (`hasCurator && !hasCuratorArchive`) | v0.13+ (`hasCuratorArchive`) |
|---|---|---|
| Sidebar item | Visible (gated on `hasCurator`) | Visible |
| Status summary, leaderboards, pinned section | Identical | Identical |
| Per-row "Archive" button | **Hidden** | Visible |
| "Archived" section in CuratorView | **Hidden** | Visible (renders empty-state if no archives) |
| "Prune Archived…" menu item | **Hidden** | Visible |
| Existing "Restore Archived…" menu item | Visible (legacy text-prompt sheet) | **Hidden** (replaced by per-row Restore in Archived section) |
| `Run Now` blocking + progress | **No** (fire-and-forget) | **Yes** (synchronous w/ progress + 600s timeout) |
| `CuratorRestoreSheet.swift` | Used | Dead code path but file kept |
The View reads `caps` once at the top of `body` and threads
`archiveAvailable: Bool` down. Don't sprinkle `caps?.hasCuratorArchive` checks
across every sub-view — single source of truth at the entry point.
**Defensive default.** If `caps` is `nil` (preview / smoke test) or detection
hasn't completed yet, `archiveAvailable` resolves to `false` and the surface
behaves like a pre-v0.13 host. Same defensive shape as the Goals / Kanban-watch
gates.
---
## How to test
### CLI fixtures (capture once, commit to repo)
Create `scarf/Packages/ScarfCore/Tests/ScarfCoreTests/Fixtures/Curator/`:
- `list-archived-empty.json``[]`
- `list-archived-three.json` — three skills with varied optional fields
- `list-archived-no-json-flag.txt` — text fallback (one row per line)
- `prune-dry-run.json``{ wouldRemove: [...], totalBytes: 12345 }`
- `status-with-archived.txt` — pre-existing fixture but with the
`archived 4` count populated (drives the badge-count test)
These are captured by running the verbs against a real Hermes v0.13 install
on the dogfooding Mardon Mac Mini (per the "remote-servers dogfooding" memory)
during implementation. **Do not commit fabricated fixtures** — every fixture
must come from a real CLI invocation; otherwise the tests lock in a parser
that doesn't match production.
### Parser tests (`HermesCuratorParserTests.swift`)
Add to the existing `@Suite struct HermesCuratorParserTests`:
- `listArchivedEmpty()` — empty array decodes to `[]`.
- `listArchivedThreeSkills()` — happy path, asserts each field including
optional `category` / `reason`.
- `listArchivedNoJSONFallback()` — text parser on the .txt fixture.
- `listArchivedNoArchivedSkillsSentinel()``"no archived skills"` literal in
stdout folds to `[]` (parallel to KanbanService's `"no matching tasks"`).
- `listArchivedMissingOptionalsStaysSafe()` — JSON with only `name` populated
decodes; size/date labels render `"—"`.
- `pruneDryRunHappyPath()``CuratorPruneSummary` decodes `wouldRemove` list
and `totalBytes`.
- `pruneDryRunZeroSkills()``wouldRemove: [], totalBytes: 0` is valid.
### View-model tests (new file `CuratorViewModelTests.swift` — optional)
If a `MockCuratorService` protocol is plausible (the actor pattern allows
swapping via a protocol), add:
- `archiveCallSucceedsAndReloads()` — verifies `viewModel.transientMessage`
flips to "Archived X" and `loadArchive()` is re-invoked.
- `archiveCallFailsRoutesToErrorBanner()` — failure path populates
`errorMessage` (not `transientMessage`).
- `pruneTwoStepFlow()``planPrune()` populates `pruneSummary` then
`confirmPrune()` clears it.
- `runNowIsSynchronousOnV013()` — VM passes `synchronous: true` to the service.
If extracting a protocol is too much yak-shave, plan only the parser tests.
### UI scenarios (manual verification on Mardon)
1. **Pre-v0.13 host (Mac Mini paused at v0.12):** sidebar shows Curator;
page renders unchanged from v2.7.5; "Restore Archived…" menu item present;
no Archive section, no Prune button; `Run Now` returns immediately.
2. **v0.13 host with no archives:** Archived section shows empty-state copy
("No archived skills — Curator will move stale skills here after the next
review cycle."); "Prune Archived…" menu item disabled.
3. **v0.13 host with 3 archives:** Archived rows render with size + date;
per-row Restore moves the skill back to active (verified by status reload);
"Prune Archived…" opens confirm sheet listing all 3 with sizes; confirming
removes them.
4. **v0.13 host: archive an active skill:** click Archive on a leaderboard
row → row disappears from active list, appears in Archived section, active
count drops by 1, archived count rises by 1.
5. **v0.13 host: blocking `Run Now`:** spinner appears, button stays disabled
for the full duration; on completion the toast fires and the leaderboard
reflects the new pass.
6. **v0.13 host: prune failure mid-flight:** simulate by SIGKILL'ing the
curator process; verify error banner appears with stderr excerpt and the
archived list isn't optimistically wiped.
7. **Restore sheet legacy fallback (pre-v0.13):** unchanged — verify the
existing free-form text sheet still works.
---
## Open questions (must resolve at implementation start)
1. **Does `hermes curator prune` ship a `--dry-run` flag in v0.13?** If yes,
the prune confirm sheet uses it for accurate "will remove these" copy. If
no, the sheet falls back to displaying the current `list-archived` output
and assumes prune removes exactly that set. This is the **biggest unknown**
in the plan — the entire prune confirm UX shape pivots on this answer.
_Resolution path: run `hermes curator prune --help` against v0.13 install
on Mardon as the very first WS-4 implementation step._
2. **Does any curator verb support `--json`?** Plan assumes yes for
`list-archived` and `prune --dry-run` since v0.12 Kanban set the precedent.
If neither does, parser fixtures shift to text-only and decode logic moves
into `HermesCuratorStatusParser`. Resolution: same as Q1.
3. **Is `hermes curator prune <name>` (single-skill prune) supported?** If so,
per-row "Prune permanently" buttons in the Archived section are easy to
add. If not, the only prune affordance is the bulk one. Plan accommodates
both; per-row prune is dropped if upstream doesn't support it. Resolution:
`hermes curator prune --help`.
4. **What's the exact synchronous-`run` timeout?** The release notes say
"synchronous" but don't specify duration. 600 s (10 min) is a defensible
default since curator runs are O(skill-count × LLM RTT). Long-running
timeouts are acceptable here since the spinner is honest. Open: should
Scarf surface a Cancel button? Probably not in v0.13 — transport-level
process cancel isn't reliable across LocalTransport / CitadelServerTransport
parity. Defer cancel to a later release if users complain.
5. **Confirm UX: typed-name confirmation, multi-tap, or destructive-button
confirm sheet?** Scarf precedent (see "Constraints"):
- **Memory reset** (`MemoryView.swift:56-65`) uses a single-step
`.confirmationDialog` with `Button("Reset", role: .destructive)`. One
click after the dialog opens.
- **Template uninstall** (`TemplateUninstallSheet.swift:79-96`) uses a
custom modal sheet listing every file/skill/cron/memory entry that will
be removed, then a `ScarfPrimaryButton` tinted red labeled "Remove".
One click after the sheet opens.
- **Recommendation for prune:** match template-uninstall's shape. Prune is
bulkier than memory-reset (multiple skills enumerated) and the user
benefits from seeing the list. Custom sheet > confirmation dialog. The
confirm button is `ScarfDestructiveButton` labeled "Prune permanently"
with `keyboardShortcut(.defaultAction)` reserved for Cancel (not the
destructive action — flipping it reduces accidental Enter-key prunes).
Cancel is `ScarfGhostButton`, "Cancel". No typed-name confirmation; the
enumerated list + the asymmetric keyboard shortcut is enough friction
for a v0.13 surface that's already gated on a destructive intent ("I
opened the prune sheet on purpose"). Single-tap on the destructive
button is fine.
6. **Should the `lastReportPath` JSON field on `HermesCuratorStatus` get
populated from a v0.13 path under `logs/curator/`?** v0.12 already populates
it via the state file. v0.13 might point at a different directory after
archive/prune runs (a separate `archive_report_path`?). Out of scope unless
v0.13 introduces a new field — plan only handles existing
`lastReportPath`. Defer to dogfooding.
---
## Out of scope (deferred)
- **iOS archive surface (WS-9).** Read-only Archived list mirroring the Mac
one — no Archive / Prune actions. iOS users still get value (visibility
into what the curator pruned). Scoped to a separate work-stream.
- **Curator scheduling knobs.** Already lives in Settings → Auxiliary; no
changes for v2.8.
- **Per-skill curator-config flags** (e.g. "exclude this skill from auto-archive
forever" — distinct from pin which already prevents auto-archive). Hermes
doesn't ship this verb in v0.13. If the user wants permanent exclusion, pin.
- **Bulk-archive multi-select on active skills.** A future v0.14 verb might
enable this; for v2.8 each archive is one CLI call.
- **Archive history / undo.** Hermes doesn't track archive history beyond the
archived state itself. Restore is the undo for archive; once pruned, there's
no recovery.
- **Curator report rendering for archive/prune events.** v0.12's
`lastReportMarkdown` covers run reports; whether v0.13's archive/prune
events land in a separate report is an open question. Stick with
current rendering; revisit if dogfooding shows a gap.
- **`hermes curator pause/resume` on the synchronous run.** The new sync `run`
doesn't interact with the autonomous schedule; pause/resume still work as
before. No UX change.
- **Telemetry on prune.** No ScarfMon event for prune — measure if a user
reports a slow prune. Easy follow-up.
---
## Risk + rollback
- **Highest risk:** parser drift between assumed JSON shape and Hermes v0.13's
actual output. Mitigation: capture real fixtures at implementation start
(see Open Q1 + Q2). Don't commit synthetic fixtures.
- **Second risk:** synchronous `run` timing out on `runProcess(timeout: 600)`.
Mitigation: 10 min is generous; if a real run exceeds 10 min, that's a
Hermes regression worth surfacing. Falls back to inline error banner.
- **Rollback path:** every WS-4 surface is gated on `hasCuratorArchive`. If a
late-cycle bug shows up, a single-line revert in `HermesCapabilities.swift`
(`atLeastSemver(0, 13, 0)``atLeastSemver(99, 0, 0)`) hides every WS-4
surface from production hosts without ripping the code out. Same rollback
shape as Kanban v3 used during v2.7.5 dogfooding.
---
## Estimate
| Bucket | Effort |
|---|---|
| `CuratorService` actor + models + errors | 0.5 day |
| Parser tests (with real fixtures captured from Mardon) | 0.5 day |
| `CuratorViewModel` refactor + new state + new methods | 0.5 day |
| `CuratorView` edits (header, per-row archive, archived section, prune sheet, error banner) | 1 day |
| `CuratorPruneConfirmSheet` + `CuratorArchivedSection` views | 0.5 day |
| Capability-gating audit + manual UI scenarios on pre-v0.13 + v0.13 hosts | 0.5 day |
| Unknown-buffer (CLI shape surprises, single-skill prune verification) | 0.5 day |
**Total: ~4 days of focused work** for one engineer, assuming a v0.13 install
is already running on Mardon and accessible for fixture capture. If `--json`
turns out to be missing on either of the two read verbs, add a 0.5-day
buffer for text-parser hardening.
---
## Sequencing inside WS-4
1. Capture real-world stdout fixtures by running every new v0.13 curator verb
against the dogfooding Mardon install. Commit to
`Tests/ScarfCoreTests/Fixtures/Curator/`. _(Resolves Open Q1 + Q2 + Q3.)_
2. Land `HermesCuratorArchive.swift` (models) + `CuratorService` actor with
parser tests. No UI yet.
3. Refactor `CuratorViewModel` to use the service. Existing v0.12 surface
should still work after this step — verify by rebuilding and clicking
through every existing button.
4. Add the Mac Archived section + per-row Archive button + Prune confirm sheet
behind the `archiveAvailable` flag.
5. Bump `Run Now` to synchronous-with-progress on v0.13+.
6. Pre-v0.13 regression pass on a v0.12 install.
7. v0.13 dogfood pass on Mardon — full UI tour + error injection.
8. Update relevant wiki pages (`Core-Services.md` adds `CuratorService`;
sidebar / Curator user-guide page documents the new actions). Per
CLAUDE.md the wiki update is part of the WS, not a follow-up.
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,625 @@
# WS-6 Plan: Provider catalog refresh + Auxiliary `image_gen.model` + OpenRouter response caching
**Workstream:** WS-6 of Scarf v2.8.0
**Hermes target:** v0.13.0 (v2026.5.7)
**Capability gates (already shipped in WS-1):**
- `HermesCapabilities.hasImageGenModel` (`>= 0.13.0`) — `image_gen.model` honored from `config.yaml`.
- `HermesCapabilities.hasOpenRouterResponseCache` (`>= 0.13.0`) — OpenRouter response caching toggle.
**Builds on:** v2.7.5 ModelCatalogService overlay table (11 entries: nous, openai-codex, qwen-oauth, google-gemini-cli, copilot-acp, arcee, gmi, azure-foundry, lmstudio, minimax-oauth, tencent-tokenhub) + the existing AuxiliaryTab pattern (Hermes v0.12 catch-up: `curator` aux row, `flush_memories` row inverse-gated).
**Owner:** TBD
**Reviewers:** Alan; whoever has provider-config bandwidth in the v2.8 cycle.
---
## Goals
The Hermes v0.13.0 release notes list four item-clusters in WS-6 scope:
1. **Provider catalog refresh** — five new model IDs (`deepseek/deepseek-v4-pro`, `x-ai/grok-4.3`, `openrouter/owl-alpha`, `tencent/hy3-preview`, Arcee Trinity Large Thinking) plus a rename (`x-ai/grok-4.20-beta``x-ai/grok-4.20`). All five new IDs already appear in `models_dev_cache.json` on the local v0.13 dev host (verified: see Appendix A), so the catalog file does the heavy lifting on next `models.dev` cache refresh — Scarf just needs alias-resolution + (sparingly) curated metadata.
2. **Vercel AI Gateway demotion** — Hermes deprioritizes the `vercel` provider (display name `Vercel AI Gateway`) in the picker. Currently Scarf sorts providers `subscriptionGated → alphabetical`; Vercel sits mid-alphabet. We add a `demoted` axis so Vercel sinks to the bottom while keeping all other providers in their alphabetic positions.
3. **`image_gen.model` from `config.yaml`** — Hermes v0.13 honors a top-level `image_gen.model` key. Scarf surfaces a model picker for it on the Auxiliary tab, capability-gated on `hasImageGenModel`.
4. **OpenRouter response caching toggle** — Hermes v0.13 added an OpenRouter response-caching switch in `config.yaml`. Scarf surfaces a `Toggle` next to OpenRouter's other knobs, capability-gated on `hasOpenRouterResponseCache`. **Open Question** on the exact key shape (`openrouter.response_cache.enabled` vs `providers.openrouter.response_cache_enabled` vs nested under `prompt_caching`) — flagged below.
The two release-notes items NOT in WS-6 scope:
- **"Honor runtime default model during delegate provider resolution"** — server-side resolution behavior. Scarf's existing `delegation.model` / `delegation.provider` fields in `DelegationSettings` are unchanged; the picker continues to fill those values straight to `config.yaml`. No Scarf surface change needed. Document in the `Out of scope` section as verified-no-change.
- **"Avoid Bedrock credential probe in provider picker"** — server-side: the `hermes model` CLI no longer probes AWS_ACCESS_KEY_ID at picker open time. Scarf's `ModelPickerSheet` was already not invoking that probe (we read the cached catalog, not `hermes model`). No change needed.
- **`ProviderProfile` ABC + `plugins/model-providers/` + `list_picker_providers`** — these are Hermes-internal pluggability scaffolding. They expand which providers can ship via plugin, but none alter the on-disk shape of `models_dev_cache.json` or the `HERMES_OVERLAYS` table. Scarf's existing read path (cache file + overlay table) reaches them transparently. **Caveat:** the `list_picker_providers` change adds a credential-filter so providers without the right env vars are hidden. Scarf's picker today shows everything regardless of credentials. We choose to **not adopt** the credential filter in the picker (users frequently configure providers in-app and need to see the row before they can fill the secret). Documented in the `Out of scope` section.
- **Shared Hermes dotenv loader / Nous OAuth persistence across profiles** — entirely server-side. Scarf's `NousSubscriptionService` reads `~/.hermes/auth.json`; the new shared dotenv loader doesn't change that file's path or shape. No Scarf surface change.
- **`/provider` alias removal** — server-side CLI cleanup. Scarf already invokes `/model` directly via ACP slash command routing; no Scarf surface used `/provider`. No change.
### Non-goals (explicitly deferred)
- **In-app credential entry sheet** for providers requiring an API key. v2.7.5 surfaces "Set in Terminal: `hermes auth <provider>`" as the path for OAuth providers; for new BYO-key providers (none in this WS — the five new models all flow through OpenRouter / Nous Portal / Arcee already-credentialed) we keep the same convention.
- **Per-model image-gen capability tag** in the catalog. The `models_dev_cache.json` schema doesn't include an `image: true` field today. Filtering the `image_gen.model` picker to "image-capable models only" is therefore not feasible at the catalog level. We pre-populate a small allowlist of well-known image models in Scarf instead (see §New types / fields).
- **iOS surface for new image_gen / openrouter toggles.** ScarfGo's settings is read-mostly; a dedicated iOS tab is deferred to WS-9 (iOS catch-up). The capability flags will work on iOS too once the surface lands.
- **Migration ceremony for the Grok rename.** We resolve the alias at read time (option 1) — no ceremony, no race, lossless. See §Migration.
- **A standalone "Image Gen" Settings tab.** v0.13 has exactly two image-gen-related fields (the model + the existing `image_gen.provider` from v0.12). That's not enough surface to warrant a tab — they belong next to the `vision` row in Auxiliary. If v0.14 adds size/quality/style fields, we revisit and split into its own tab then.
---
## Files to change
The plan is intentionally minimal-touch. The `models_dev_cache.json` refresh handles four of the five new model IDs without any Swift change; the rename + the one new aux field + the toggle are surgical.
### 1. `scarf/Packages/ScarfCore/Sources/ScarfCore/Services/ModelCatalogService.swift`
**Why:** Two changes:
- Adds an alias-resolution path so `x-ai/grok-4.20-beta` keeps working when a user's `config.yaml` references the old name. Lossless, opt-in, zero migration risk.
- Adds a `demoted` axis to provider sort so Vercel AI Gateway sinks to the bottom of the picker.
**Edits:**
- **Alias map.** Add a static table near `overlayOnlyProviders`:
```swift
/// Hermes deprecates model IDs across releases. When a stored config
/// `model.default` references a deprecated ID, resolve to its
/// canonical successor. Lossless — we never rewrite the user's
/// config.yaml; the alias just lets `validateModel` /
/// `model(providerID:modelID:)` succeed against the new ID.
///
/// Keys are dot-separated `providerID/modelID` to disambiguate
/// across providers — even if `vercel` later adds a `grok-4.20-beta`
/// alias on its own, the openrouter resolution shouldn't fire.
///
/// **Schema is Swift-primary.** Mirror new entries into
/// `tools/build-catalog.py` only if the catalog tool grows a model-ID
/// validation pass (it doesn't today — see §`tools/build-catalog.py`
/// mirror below).
public static let modelAliases: [String: String] = [
// v0.13: x-ai dropped the `-beta` suffix once Grok 4.20 GA'd.
// The model is the same one served at the same OpenRouter slot;
// only the marketing identifier changed.
"openrouter/x-ai/grok-4.20-beta": "openrouter/x-ai/grok-4.20",
"xai/grok-4.20-beta": "xai/grok-4.20",
"vercel/xai/grok-4.20-beta": "vercel/xai/grok-4.20",
]
/// Resolve a stored model identifier through the alias map. Returns
/// the input unchanged when no alias exists. Pure function — used at
/// read time everywhere a config'd model ID is rendered, validated,
/// or sent to Hermes.
public func resolveModelAlias(providerID: String, modelID: String) -> String {
let composite = "\(providerID)/\(modelID)"
return Self.modelAliases[composite].map { resolved -> String in
// Strip the providerID prefix from the resolved value before
// returning — callers want the bare model ID.
let prefix = providerID + "/"
return resolved.hasPrefix(prefix)
? String(resolved.dropFirst(prefix.count))
: resolved
} ?? modelID
}
```
Call sites that need to resolve: `validateModel(_:for:)` resolves the input before lookup; `model(providerID:modelID:)` resolves before `provider.models?[modelID]` indexing; `provider(for:)` resolves the input model ID before scanning. Each is a one-line addition at the top of the function.
- **Demoted-provider axis.** Add a static set:
```swift
/// Provider IDs that Hermes v0.13 explicitly deprioritizes in the
/// picker. `loadProviders()` sorts these to the tail of the list,
/// after the alphabetical group, so users who haven't manually
/// chosen Vercel as their gateway don't end up there by default.
/// Mirrors Hermes's `DEMOTED_PROVIDERS` list in
/// `hermes_cli/providers.py`.
public static let demotedProviders: Set<String> = [
"vercel",
]
```
Update the sort comparator in `loadProviders()`:
```swift
return byID.values.sorted { lhs, rhs in
// Subscription-gated first (Nous Portal).
if lhs.subscriptionGated != rhs.subscriptionGated {
return lhs.subscriptionGated
}
// Demoted last (Vercel AI Gateway).
let lDemoted = Self.demotedProviders.contains(lhs.providerID)
let rDemoted = Self.demotedProviders.contains(rhs.providerID)
if lDemoted != rDemoted {
return !lDemoted
}
return lhs.providerName.localizedCaseInsensitiveCompare(rhs.providerName) == .orderedAscending
}
```
- **Image-gen model allowlist.** Add a static curated list of well-known image-gen-capable model IDs (kept short and updated by hand; the catalog file has no `image_capable` flag today):
```swift
/// Known image-generation models, used to pre-populate the
/// `image_gen.model` picker on the Auxiliary tab. The list is
/// curated — `models_dev_cache.json` doesn't tag image-capable
/// models, so we maintain this by hand on Hermes version bumps.
/// Always free-form-typeable on the picker too, so missing entries
/// don't block users with non-listed image providers.
///
/// Order: most-likely-to-be-chosen first.
public static let imageGenModels: [HermesImageGenModel] = [
.init(modelID: "openai/gpt-image-1", display: "OpenAI · gpt-image-1", providerHint: "openai"),
.init(modelID: "google/imagen-4", display: "Google · Imagen 4", providerHint: "google-vertex"),
.init(modelID: "google/imagen-3", display: "Google · Imagen 3", providerHint: "google-vertex"),
.init(modelID: "stability/stable-image-ultra", display: "Stability · Stable Image Ultra", providerHint: "stability"),
.init(modelID: "fal-ai/flux-pro-1.1", display: "fal · FLUX 1.1 Pro", providerHint: "fal"),
.init(modelID: "black-forest-labs/flux-1.1-pro", display: "Black Forest Labs · FLUX 1.1 Pro", providerHint: "openrouter"),
.init(modelID: "openai/dall-e-3", display: "OpenAI · DALL·E 3", providerHint: "openai"),
]
public struct HermesImageGenModel: Sendable, Identifiable, Hashable {
public let modelID: String
public let display: String
/// Hint at which provider serves this model — surfaced as a
/// "Configure provider X first" advisory but never enforced.
public let providerHint: String?
public var id: String { modelID }
}
```
**Tolerance contract:** When a user has a config with `model.default: x-ai/grok-4.20-beta` and provider `openrouter`, `validateModel("x-ai/grok-4.20-beta", for: "openrouter")` resolves to `"x-ai/grok-4.20"` and validates against the catalog. If the alias isn't present in the map, the function behaves identically to today.
---
### 2. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift`
**Why:** Add two new top-level config fields:
- `imageGenModel: String``image_gen.model` value, default `""` (empty means "use provider default").
- `openrouterResponseCacheEnabled: Bool``openrouter.response_cache.enabled` (working name pending Open Question §1), default `false`.
**Edits:**
- Add stored properties next to `cacheTTL` / `redactionEnabled` / `runtimeMetadataFooter`:
```swift
/// `image_gen.model` (v0.13+) — overrides the per-provider default
/// image-gen model. Empty string means "let Hermes pick the
/// provider default". Hermes v0.12 advertised this key but ignored
/// it; Scarf's `AuxiliaryTab` only renders the picker when
/// `HermesCapabilities.hasImageGenModel` is `true`.
public var imageGenModel: String
/// `openrouter.response_cache.enabled` (v0.13+) — when true, Hermes
/// asks OpenRouter to cache responses for repeat prompts within a
/// session. **Open Question:** the exact YAML key shape is
/// unconfirmed. See WS-6 plan §Open Questions #1.
public var openrouterResponseCacheEnabled: Bool
```
- Append `imageGenModel: String = ""` and `openrouterResponseCacheEnabled: Bool = false` to the trailing parameter list in the explicit memberwise `init` (after `runtimeMetadataFooter`). Default values mean every existing call site (`HermesConfig.empty`, `init(yaml:)`) compiles unchanged until updated.
- Update the static `HermesConfig.empty` factory to pass both new defaults explicitly so the empty-config sentinel matches the post-load shape.
**Tolerance contract:** Pre-v0.13 hosts have neither key in `config.yaml`; the parser defaults both to empty / false. UI is gated separately on the capability flag, so the values never reach the screen on pre-v0.13 hosts even if they were somehow non-default.
---
### 3. `scarf/Packages/ScarfCore/Sources/ScarfCore/Parsing/HermesConfig+YAML.swift`
**Why:** Wire the two new keys into the YAML parser.
**Edits:**
- In the trailing `self.init(...)` call, add (next to `cacheTTL` / `redactionEnabled` / `runtimeMetadataFooter`):
```swift
imageGenModel: str("image_gen.model", default: ""),
openrouterResponseCacheEnabled: bool("openrouter.response_cache.enabled", default: false),
```
- The exact key for `openrouter.response_cache.enabled` is **provisional** — see §Open Questions #1. Lock the key only after manual verification on a v0.13 host (`hermes config check` against a sample YAML with the candidate key + a printout of the `Settings`-level key). We may need a fallback: read the legacy key first and fall through to the canonical one, exactly like the `slack.reply_to_mode``platforms.slack.reply_to_mode` pattern at line 187.
**Tolerance contract:** A v0.12 host with neither key produces `imageGenModel == ""` and `openrouterResponseCacheEnabled == false`, matching the runtime defaults. A v0.13 host with both keys present round-trips through `init(yaml:)` cleanly.
---
### 4. `scarf/scarf/Features/Settings/ViewModels/SettingsViewModel.swift`
**Why:** Two new setters, one for each new field.
**Edits:**
- Add to the "Auxiliary model sub-tasks" section (since `image_gen` lives logically next to other aux tasks even though the YAML key is at the top level):
```swift
// MARK: - Image generation (v0.13+)
func setImageGenModel(_ value: String) { setSetting("image_gen.model", value: value) }
func setOpenRouterResponseCache(_ value: Bool) {
setSetting("openrouter.response_cache.enabled", value: value ? "true" : "false")
}
```
- Both setters route through `setSetting``runHermes(["config", "set", key, value])`, matching the existing pattern. `hermes config set` is forward-compatible — pre-v0.13 hosts accept any key without complaint and write it to YAML; the gate keeps the UI hidden so users on pre-v0.13 never invoke these.
**Tolerance contract:** No new error paths. Existing `setSetting`'s `saveMessage` plumbing handles success/failure surfacing.
---
### 5. `scarf/scarf/Features/Settings/Views/Tabs/AuxiliaryTab.swift`
**Why:** Surface the two new fields. Both belong on Auxiliary because they're per-task / per-provider knobs, not main-model-pickers.
**Edits:**
- **Image-gen model row.** Add a new `SettingsSection(title: "Image Generation", icon: "photo")` between the static base tasks and `unknownTasks`, gated on `capabilitiesStore?.capabilities.hasImageGenModel == true`:
```swift
if capabilitiesStore?.capabilities.hasImageGenModel ?? false {
SettingsSection(title: "Image Generation", icon: "photo") {
imageGenRow
}
}
```
`imageGenRow` is a small `@ViewBuilder`:
```swift
@ViewBuilder
private var imageGenRow: some View {
let value = viewModel.config.imageGenModel
Picker("Model", selection: Binding(
get: { value },
set: { viewModel.setImageGenModel($0) }
)) {
Text("Provider default").tag("")
Divider()
ForEach(ModelCatalogService.imageGenModels) { model in
Text(model.display).tag(model.modelID)
}
if !value.isEmpty
&& !ModelCatalogService.imageGenModels.contains(where: { $0.modelID == value }) {
// User has set a custom value; preserve it as a tagged option
// so the picker renders the actual selection, not "Provider default".
Divider()
Text(value + " (custom)").tag(value)
}
}
.pickerStyle(.menu)
EditableTextField(label: "Custom model ID", value: value) { newValue in
viewModel.setImageGenModel(newValue.trimmingCharacters(in: .whitespaces))
}
Text("Used for image generation calls. Leave as Provider default unless your provider documents a specific model ID for image-gen.")
.font(.caption2)
.foregroundStyle(.tertiary)
}
```
The `EditableTextField` lets users free-form-type a model ID we haven't curated. Together they cover both the curated allowlist + the long tail.
- **OpenRouter response cache row.** Add a new section (or fold into a future "Providers" section):
```swift
if capabilitiesStore?.capabilities.hasOpenRouterResponseCache ?? false {
SettingsSection(title: "OpenRouter", icon: "shippingbox") {
ToggleRow(label: "Response caching",
isOn: viewModel.config.openrouterResponseCacheEnabled) { newValue in
viewModel.setOpenRouterResponseCache(newValue)
}
Text("OpenRouter caches identical prompts within a session to reduce token costs. Off by default — enable when your workload has highly repeated prompts.")
.font(.caption2)
.foregroundStyle(.tertiary)
.padding(.horizontal, 12)
.padding(.bottom, 4)
}
}
```
**Tolerance contract:** Pre-v0.13 host hides both sections entirely. Capability flag false → guard fails → section never enters the view tree. Dynamic Type clamp on iOS (n/a here, this is Mac-only) preserved on captions.
---
### 6. `scarf/Packages/ScarfCore/Tests/ScarfCoreTests/M0cServicesTests.swift`
**Why:** The existing model-catalog tests freeze the `loadProviders()` sort order + decoding shape. Add three new tests:
**New tests (Swift Testing macros):**
```swift
@Test func vercelAIGatewayDemotedToBottom() throws {
// Build a minimal catalog with vercel + alphabetically-later providers,
// then assert vercel sorts after them.
let json = """
{
"anthropic": { "name": "Anthropic", "models": {} },
"vercel": { "name": "Vercel AI Gateway", "models": {} },
"zonk": { "name": "Zonk Provider", "models": {} }
}
"""
let tmp = FileManager.default.temporaryDirectory
.appendingPathComponent("scarf-models-\(UUID().uuidString).json")
try json.write(to: tmp, atomically: true, encoding: .utf8)
defer { try? FileManager.default.removeItem(at: tmp) }
let svc = ModelCatalogService(path: tmp.path)
let providers = svc.loadProviders().filter { !$0.isOverlay }
let names = providers.map(\.providerName)
// anthropic first (alpha), zonk next (alpha), vercel last (demoted).
#expect(names.last == "Vercel AI Gateway")
#expect(names.firstIndex(of: "Vercel AI Gateway")! > names.firstIndex(of: "Zonk Provider")!)
}
@Test func grok420BetaAliasResolvesToGrok420() {
let svc = ModelCatalogService(path: "/tmp/scarf-nonexistent-\(UUID().uuidString).json")
#expect(svc.resolveModelAlias(providerID: "openrouter", modelID: "x-ai/grok-4.20-beta")
== "x-ai/grok-4.20")
#expect(svc.resolveModelAlias(providerID: "xai", modelID: "grok-4.20-beta")
== "grok-4.20")
// Non-aliased ID passes through unchanged.
#expect(svc.resolveModelAlias(providerID: "anthropic", modelID: "claude-4.7-opus")
== "claude-4.7-opus")
// Cross-provider isolation: same modelID on a different provider isn't aliased.
#expect(svc.resolveModelAlias(providerID: "fictional", modelID: "x-ai/grok-4.20-beta")
== "x-ai/grok-4.20-beta")
}
@Test func imageGenModelAllowlistShape() {
// Lock the curated list size + a few sentinel entries so unintentional
// edits get caught in review.
let models = ModelCatalogService.imageGenModels
#expect(models.count >= 5)
#expect(models.contains(where: { $0.modelID == "openai/gpt-image-1" }))
#expect(models.contains(where: { $0.modelID == "google/imagen-4" }))
// Every entry has a non-empty display + a non-empty modelID.
for m in models {
#expect(!m.modelID.isEmpty)
#expect(!m.display.isEmpty)
}
}
```
**Tolerance contract:** All three are pure-function tests that run without a Hermes binary or models cache file. They survive a `ModelCatalogService(path: nonexistent)` because the alias + allowlist paths don't read the catalog.
---
### 7. `scarf/Packages/ScarfCore/Tests/ScarfCoreTests/M6ConfigCronTests.swift` (or new `WS6ProvidersConfigTests.swift`)
**Why:** Lock the YAML round-trip for the two new keys.
**New test:**
```swift
@Test func imageGenAndOpenRouterCacheRoundTrip() {
let yaml = """
image_gen:
model: openai/gpt-image-1
openrouter:
response_cache:
enabled: true
"""
let cfg = HermesConfig(yaml: yaml)
#expect(cfg.imageGenModel == "openai/gpt-image-1")
#expect(cfg.openrouterResponseCacheEnabled == true)
}
@Test func imageGenDefaultsToEmptyString() {
let cfg = HermesConfig(yaml: "")
#expect(cfg.imageGenModel == "")
#expect(cfg.openrouterResponseCacheEnabled == false)
}
```
**Tolerance contract:** Tracks the exact YAML keys the parser expects. If the Open Question resolves a different key shape, this test pins the change to one place.
---
### 8. `tools/build-catalog.py` mirror
**Why:** Per CLAUDE.md, every new schema-shaped change must mirror into the Python validator. Audit:
| New surface | Mirror needed? | Rationale |
| -- | -- | -- |
| `modelAliases` | **No** | The catalog tool validates `template.json` manifests, not model IDs. Aliases live entirely in Scarf-side ModelCatalogService. |
| `demotedProviders` | **No** | Same — the catalog tool doesn't render the picker. |
| `imageGenModels` (curated) | **No** | Curated list is Scarf UI-only. |
| `HermesConfig.imageGenModel` | **No** | The catalog tool never reads `config.yaml`; it reads `template.json`. |
| `HermesConfig.openrouterResponseCacheEnabled` | **No** | Same. |
**Verdict:** No `tools/build-catalog.py` changes for WS-6. Document the audit explicitly in the WS-6 PR description so future plans know we checked.
If WS-6 ever adds a new `ProjectDashboardWidget.type` (it doesn't — image_gen is in Settings, not a dashboard widget), the mirror would be required. The widget vocabulary is the only Swift-primary schema the catalog tool tracks.
---
### 9. `scarf/CLAUDE.md` — schema-drift line
**Why:** CLAUDE.md says "Keep `ModelCatalogService.overlayOnlyProviders` in sync with `HERMES_OVERLAYS` in … `providers.py`." After this WS, Scarf also needs to keep `modelAliases` in sync with Hermes's deprecation map (currently a small list inside `hermes_cli/providers.py`). Add one bullet in the "Hermes Version" section:
> Keep `ModelCatalogService.modelAliases` in sync with `HERMES_DEPRECATED_MODEL_IDS` (or whatever the upstream module renames to) in `hermes-agent/hermes_cli/providers.py`. Drift here means a user's old model ID stops resolving in the picker even though Hermes still accepts it at runtime.
(Plus the existing demoted-providers bullet — see below.)
> Keep `ModelCatalogService.demotedProviders` in sync with the deprioritized-provider list in `hermes-agent/hermes_cli/providers.py`. Drift means Vercel AI Gateway sorts in the wrong position in Scarf's picker.
**Touchpoint:** the single block at line ~205 of `scarf/CLAUDE.md` (the "Keep `ModelCatalogService.overlayOnlyProviders` in sync" paragraph). Append two more bullets next to it.
---
## New models / overlay entries
| Model ID | Provider | Cache hit (verified) | Overlay change? | Action |
| -- | -- | -- | -- | -- |
| `deepseek/deepseek-v4-pro` | OpenRouter + Nous Portal | **Yes** (openrouter) | No | Auto-shows on next `models_dev_cache.json` refresh; Nous Portal serves it via the Nous overlay's free-form model list. No code change. |
| `x-ai/grok-4.3` | OpenRouter + Nous Portal + xAI direct + Vercel | **Yes** (openrouter, xai, vercel) | No | Auto-shows. No code change. |
| `openrouter/owl-alpha` | OpenRouter only (free tier) | **Yes** | No | Auto-shows. No code change. |
| `tencent/hy3-preview` | OpenRouter only (paid route) | **Yes** | No | Auto-shows. No code change. |
| `arcee-ai/trinity-large-thinking` | Arcee (overlay) + OpenRouter + DigitalOcean + Venice + Kilo | **Yes** (openrouter, etc.) | No | Auto-shows on non-overlay providers. The Arcee overlay's free-form picker remains the path for direct Arcee API users. **No catalog field captures the v0.13 "temperature + compression overrides" — that's a per-call hint Hermes passes through, not a per-model metadata field.** Scarf doesn't need to surface it. |
| `x-ai/grok-4.20-beta``x-ai/grok-4.20` | OpenRouter + xAI + Vercel | **Both present** | No | Add to `modelAliases` (see file 1). Resolution at read time means a user's stored config keeps working without a rewrite. |
**Why no overlay changes:** All 11 existing overlay entries (`nous`, `openai-codex`, `qwen-oauth`, `google-gemini-cli`, `copilot-acp`, `arcee`, `gmi`, `azure-foundry`, `lmstudio`, `minimax-oauth`, `tencent-tokenhub`) remain. v0.13's `ProviderProfile` ABC + `plugins/model-providers/` framework adds **internal** Hermes pluggability but does not introduce new overlay-only providers in this release. Verify on Hermes upstream by diffing `hermes_cli/providers.py` against the v0.12 baseline; if the `HERMES_OVERLAYS` dict gained entries, mirror them. Lock in `ToolGatewayTests.v013OverlayProvidersCarryCorrectAuthTypes` (mirror of the existing v0.12 lock-in test).
---
## New types / fields
### `HermesProviderOverlay` — no shape change
The release notes mention `ProviderProfile` ABC, but it's an internal Python abstraction. Nothing in the on-disk overlay contract changes. `HermesProviderOverlay` keeps its current five-field shape (`displayName`, `baseURL`, `authType`, `subscriptionGated`, `docURL`).
### `ModelCatalogService.HermesImageGenModel` — new
Curated image-gen model entry, pre-populated for the picker on Auxiliary tab. Five fields: `modelID`, `display`, `providerHint`. Scope is intentionally tiny — we don't enumerate every provider's image model; users with niche providers free-form-type the model ID instead.
### `ModelCatalogService.modelAliases` — new
`[String: String]` map keyed by composite `providerID/modelID`. Used at read time by `validateModel`, `model(_:_:)`, and `provider(for:)`. **Does not** rewrite stored config.
### `ModelCatalogService.demotedProviders` — new
`Set<String>` of provider IDs to sink to the bottom of the picker. Sort comparator update in `loadProviders()` is the only consumer.
### `HermesConfig.imageGenModel` / `HermesConfig.openrouterResponseCacheEnabled` — new
Top-level config fields, defaults `""` and `false`. Read by `init(yaml:)`, written via `setSetting``hermes config set`.
---
## Capability gating
| Capability | Flag | UI surface | Pre-v0.13 host behavior |
| -- | -- | -- | -- |
| `image_gen.model` honored at runtime | `hasImageGenModel` | `AuxiliaryTab` "Image Generation" section | Section never enters the view tree. The model picker would otherwise no-op silently on pre-v0.13 (the value goes to YAML but Hermes ignores it). Hiding spares users a "I set this and nothing happened" trap. |
| OpenRouter response caching | `hasOpenRouterResponseCache` | `AuxiliaryTab` "OpenRouter" section | Section never enters the view tree. Same reasoning — silent no-op on pre-v0.13. |
| `modelAliases` resolution | (none) | `validateModel`, `model(_:_:)`, `provider(for:)` | Always on. The alias is a Scarf-side concept that doesn't depend on Hermes version — even on pre-v0.13 hosts, OpenRouter still serves the model via either the old or new ID. (Verify upstream: if OpenRouter has dropped the `-beta` slot entirely, the alias resolution still helps users on the new ID. If OpenRouter kept the `-beta` slot live, the alias still helps users on the new ID. Win-win.) |
| Vercel demotion | (none) | `loadProviders()` sort | Always on. Vercel's display position is a Scarf-UI choice, not a Hermes-version-gated behavior. |
**Why no flag for the demotion / aliases:** Both are Scarf-UX choices that improve every Hermes version's experience equally. Adding a flag would mean dragging the sort order with the version, which is worse — users on a v0.12 host would see Vercel mid-alphabet, then mysteriously at the bottom after upgrading. Consistency wins.
---
## How to test
### Unit tests (Swift Testing — see file 6 + 7)
- `vercelAIGatewayDemotedToBottom` — locks the new sort axis.
- `grok420BetaAliasResolvesToGrok420` — locks the alias map shape.
- `imageGenModelAllowlistShape` — locks the curated list size + sentinel entries.
- `imageGenAndOpenRouterCacheRoundTrip` — locks the YAML key shape (`image_gen.model` + `openrouter.response_cache.enabled`).
- `imageGenDefaultsToEmptyString` — locks the empty-config default.
### Manual test plan (Mac, against a v0.13 Hermes host)
1. **Picker order.** Open `Settings → General → Model picker`. Confirm Nous Portal (subscription-gated) is at the top, alphabetical group fills the middle, Vercel AI Gateway is the last non-subscription entry. Resize the sheet; the order is stable across re-renders.
2. **Grok rename.** Edit `~/.hermes/config.yaml` directly: set `model.default: x-ai/grok-4.20-beta`, provider `openrouter`. Reload Scarf. The picker should show `x-ai/grok-4.20` selected (the alias resolved). The stored YAML is untouched. Save a new model — confirm Hermes still accepts `x-ai/grok-4.20-beta` at the wire level (it should — OpenRouter keeps the slot live).
3. **Image-gen model picker.** Open `Settings → Auxiliary → Image Generation`. Confirm:
- Section is visible (you're on v0.13).
- The picker has "Provider default" + the 7 curated entries.
- Selecting `openai/gpt-image-1` writes `image_gen.model: openai/gpt-image-1` to `config.yaml` (verify with `grep image_gen ~/.hermes/config.yaml`).
- Free-form-typing a custom value sets it.
- Setting it back to "Provider default" (`""`) clears the key from YAML on next save.
4. **OpenRouter response cache toggle.** Same tab, "OpenRouter" section. Confirm:
- Section is visible.
- Toggle off → on writes `openrouter.response_cache.enabled: true`.
- Toggle on → off writes `openrouter.response_cache.enabled: false`.
5. **Pre-v0.13 fallback.** Switch the active server to a v0.12 host (or stash with `HERMES_VERSION_OVERRIDE=0.12.0` env shim). Confirm:
- Image Generation section is hidden.
- OpenRouter section is hidden.
- The picker still shows Vercel AI Gateway at the bottom (sort axis is unconditional).
- Grok alias resolution still works.
6. **`hermes config set` round-trip.** Set `image_gen.model` from Scarf, then `hermes config check` from Terminal — confirm the new key validates against Hermes's schema.
### Integration / smoke
- `scripts/smoke.sh` (if present) — run the full smoke sweep, verify no provider catalog regressions on the existing 11 overlay entries.
- Build clean: `xcodebuild -project scarf/scarf.xcodeproj -scheme scarf -configuration Debug build`. New Swift Testing tests run via `swift test --package-path scarf/Packages/ScarfCore`.
---
## Open questions
1. **`openrouter.response_cache.enabled` — exact YAML key shape.** The release notes say "OpenRouter response caching support" but don't specify the key. Three plausible shapes:
- `openrouter.response_cache.enabled: true` (top-level provider block)
- `providers.openrouter.response_cache_enabled: true` (under the new `providers:` map v0.13 introduces)
- `prompt_caching.openrouter.enabled: true` (nested under the existing `prompt_caching` block from v0.12)
**Recommendation:** Verify by inspecting the v0.13 Hermes config schema (`hermes config check` against a sample YAML for each shape, or `grep -r response_cache hermes-agent/hermes_cli/`) before merging WS-6. The first shape is consistent with how Hermes handles other per-provider knobs (`xai.voice_cloning.enabled` from v0.13's xAI Voice Cloning); it's our default until verified. If the shape changes, file 3's parser line + file 4's setter key + file 7's test fixture all update in lockstep.
2. **Default value for OpenRouter response caching.** The release notes don't specify whether v0.13 defaults the toggle on or off. **Recommendation:** Default off in Scarf's parser (`bool("openrouter.response_cache.enabled", default: false)`). Worst case, the user explicitly opts in. If Hermes defaults on server-side, our `false` parse still matches because the key would be present in the YAML.
3. **Arcee Trinity Large Thinking "temperature + compression overrides".** The release notes mention "temperature + compression overrides" for this model. Hermes treats these as per-model invocation hints (not catalog metadata). Scarf has no surface for per-model temperature today — it's set by the user via `hermes ask --temperature` or the per-aux-task config. **Recommendation:** Defer to a future cycle if user feedback asks for per-model temperature picker. v2.8 ships without.
4. **Grok rename — does OpenRouter delete the old slot?** If OpenRouter keeps `x-ai/grok-4.20-beta` live (with a redirect to `x-ai/grok-4.20`), our alias is purely cosmetic — Hermes still accepts the old ID. If OpenRouter deletes the old slot, the alias becomes load-bearing — without it, users on the old config get a 404 at runtime. **Either way, the alias is correct.** Verify before merging by sending a request to OpenRouter for both IDs.
5. **`models_dev_cache.json` refresh timing.** Hermes ships with a snapshot; the user's local cache refreshes via Hermes's own cache-refresh logic (background task or on-demand). Confirm that a v0.13 install ships with all five new models pre-populated (not deferred to a first-run network fetch), so the picker doesn't render an empty list on a fresh `~/.hermes/`. **Verified locally:** the dev host's cache has all five new IDs. Re-verify on a clean `~/.hermes/` after `hermes update` to v0.13.
---
## Out of scope (deferred)
- **In-app Hermes restart** after toggling response caching. Some toggles need a Hermes restart to take effect; the response_cache toggle is unclear. Defer the auto-restart prompt to a future cycle once we know which toggles need it. Scarf already has a "Restart Hermes" button at `Settings → General` for users who hit a stale-toggle case.
- **iOS surface for image_gen.model + OpenRouter cache.** ScarfGo's settings is read-mostly. WS-9 picks up iOS catch-up; the capability flags work cross-platform once the surface lands.
- **Per-image-gen-model metadata** (cost, max resolution, prompt-token-cost). Not in `models_dev_cache.json`; out of scope until the catalog adds a tag.
- **Provider profile MCP plugins (`plugins/model-providers/`).** Server-side framework. Scarf reaches whatever providers Hermes exposes via the cache + overlay — the indirection is transparent.
- **Bedrock credential probe avoidance.** Server-side; Scarf was already not invoking that probe.
- **Honor runtime default model during delegate provider resolution.** Server-side; Scarf's `delegation.model` field is already a free-form string we hand to `hermes config set`.
- **`/provider` alias removal.** Server-side; Scarf already used `/model` directly.
- **Credential filter on picker provider list.** v0.13's `list_picker_providers` filters the CLI picker by available credentials. We deliberately don't adopt this in Scarf — users frequently configure providers in-app and need to see the row before they can fill the secret. If user feedback strongly favors hiding unconfigured providers, revisit in a future WS.
- **Migration to one-shot rewrite for the Grok alias.** Option 2 (rewrite YAML) was rejected; option 1 (read-time alias) wins on safety + simplicity. See §Migration.
---
## Migration
### Grok 4.20-beta → 4.20
**Option 1 — alias-resolve at read time. ✅ Recommended.**
- `ModelCatalogService.modelAliases` maps `openrouter/x-ai/grok-4.20-beta``openrouter/x-ai/grok-4.20`.
- `validateModel` resolves the alias before lookup; `model(_:_:)` resolves before indexing; `provider(for:)` resolves before scanning.
- The user's `config.yaml` stays as-is. Scarf treats the alias as an internal display + lookup detail; Hermes (which still accepts both IDs at runtime) handles the wire.
**Pros:**
- Lossless. The user's hand-edits to `config.yaml` are sacred — we never touch them.
- No race. There's no point at which Scarf's "rewrite YAML" path could conflict with the user's editor.
- Trivial to reverse. If a future Hermes brings the old ID back, drop the entry from `modelAliases`.
- Free of edge cases. A user with a custom `model.default` value Hermes never recognized still works.
**Cons:**
- Two IDs in flight on the user's system (one in `config.yaml`, one in the picker's selected state). Cosmetic — the picker shows the resolved name, the YAML keeps the old name.
**Option 2 — one-shot YAML rewrite on next launch.**
Rejected. TOCTOU race (user edits YAML in `vim`, Scarf rewrites mid-edit), no path to undo, and the only "win" (a clean YAML) is invisible to most users.
**Precedent:** No prior model-rename has shipped through Scarf's overlay table. The new alias map is the precedent for this and future renames.
---
## Estimate
- File 1 (`ModelCatalogService.swift`): ~80 lines net add (alias map + helper + curated list + sort axis update).
- File 2 (`HermesConfig.swift`): ~25 lines net add (two stored props + memberwise init params + empty-config update).
- File 3 (`HermesConfig+YAML.swift`): ~5 lines net add (two parser lines).
- File 4 (`SettingsViewModel.swift`): ~5 lines net add (two setters).
- File 5 (`AuxiliaryTab.swift`): ~70 lines net add (two new sections + the image-gen view).
- File 6 (`M0cServicesTests.swift`): ~60 lines net add (three tests).
- File 7 (`M6ConfigCronTests.swift` or new file): ~30 lines net add (two tests).
- File 9 (`scarf/CLAUDE.md`): ~6 lines net add (two new bullets in the schema-drift block).
**Total:** ~280 lines net add across 8 files (Swift + Markdown). No deletes. No file moves. No new package targets.
**Build risk:** Low. All edits are additive; existing call sites use default values. No behavior change for pre-v0.13 hosts (capability flag + alias resolution are both safe).
**Review risk:** Medium-low. The Open Question on the OpenRouter cache key shape is the single highest-risk item; everything else is mechanical. Block the PR until that key is verified.
**Effort:** ~1 day implementation + 0.5 day verification (manual test plan + Open Question verification on a real v0.13 host).
---
## Appendix A — `models_dev_cache.json` verification
Local `~/.hermes/models_dev_cache.json` (v0.13 dev host) confirms:
| Query | Provider | Match |
| -- | -- | -- |
| `deepseek-v4-pro` | openrouter | `deepseek/deepseek-v4-pro` ✅ |
| `grok-4.3` | openrouter, xai, vercel | `x-ai/grok-4.3`, `grok-4.3`, `xai/grok-4.3` ✅ |
| `owl-alpha` | openrouter | `openrouter/owl-alpha` ✅ |
| `hy3-preview` | openrouter | `tencent/hy3-preview` ✅ |
| `trinity-large-thinking` | openrouter, kilo, venice, digitalocean | `arcee-ai/trinity-large-thinking`, etc. ✅ |
| `grok-4.20-beta` | openrouter | `x-ai/grok-4.20-beta` ✅ (live, not yet renamed in cache) |
| `grok-4.20` | openrouter | `x-ai/grok-4.20-multi-agent-beta` (similar but distinct) — the bare `x-ai/grok-4.20` ID is **not yet** in this cache snapshot |
**Implication:** The Grok rename hasn't fully landed in `models_dev_cache.json` on this dev host yet. The alias resolution is therefore **load-bearing** for users who manually update their `model.default` to the new ID before the cache refresh — they'd otherwise get an "unknown model" warning from Scarf's validator. Once the cache catches up, the alias falls back to cosmetic.
`vercel` provider: present, named `Vercel AI Gateway`, 248 models. Demotion target confirmed.
`arcee` overlay: present in Scarf's `overlayOnlyProviders`, NOT in `models_dev_cache.json`. Trinity Large Thinking still reaches users via the Arcee overlay's free-form picker + via OpenRouter / Vercel / DigitalOcean / Venice / Kilo where the cache surfaces it. No code change needed.
---
## Appendix B — schema-drift checklist
Before merging WS-6, verify the following are aligned across Swift and the upstream Hermes Python:
- [ ] `ModelCatalogService.overlayOnlyProviders` matches `HERMES_OVERLAYS` in `hermes_cli/providers.py` (no change in WS-6, but verify nothing drifted since WS-1).
- [ ] `ModelCatalogService.modelAliases` matches Hermes's deprecation map (verify the key location in `hermes_cli/providers.py` or wherever upstream tracks renames).
- [ ] `ModelCatalogService.demotedProviders` matches Hermes's deprioritized-provider list.
- [ ] `HermesConfig.openrouterResponseCacheEnabled` YAML key matches Hermes's config schema (resolve the Open Question).
- [ ] `HermesConfig.imageGenModel` YAML key (`image_gen.model`) matches Hermes's config schema. Currently confident — the release notes name the key explicitly.
---
**End of WS-6 plan.**
+628
View File
@@ -0,0 +1,628 @@
# WS-7 Plan: Settings tab additions
**Workstream:** WS-7 of Scarf v2.8.0
**Hermes target:** v0.13.0 (v2026.5.7)
**Capability gates (already shipped in WS-1):**
- `HermesCapabilities.hasMCPSSETransport` (`>= 0.13.0`)
- `HermesCapabilities.hasCronNoAgent` (`>= 0.13.0`)
- `HermesCapabilities.hasWebToolsBackendSplit` (`>= 0.13.0`)
- `HermesCapabilities.hasProfileNoSkills` (`>= 0.13.0`)
**Builds on:**
- v2.7.5 MCP Servers feature (`Features/MCPServers/`) — list + detail + add (preset / custom) + edit + per-server delete + OAuth token surface.
- v2.7.5 Cron feature (`Features/Cron/`) — `--workdir` already plumbed through `CronJobEditor` + `CronViewModel.createJob` / `updateJob`. Provides the precedent for v0.13 capability-gated form fields.
- v2.7.5 Settings feature (`Features/Settings/`) — 10 tabs, single `SettingsViewModel` write surface routing through `setSetting(key, value)``hermes config set <key> <value>`.
- v2.7.5 Profiles feature (`Features/Profiles/`) — Mac (read/write) + iOS (read-only); Mac create-sheet has `--clone` / `--clone-all` toggles today.
**Owner:** TBD
**Reviewers:** Alan; whoever rides Settings/Profiles during v2.8.
---
## Goals
Four small, independent additions, each gated on its own v0.13 capability flag. Each lands as its own commit inside the WS-7 PR so reviewers can scan them as four self-contained changes.
1. **MCP SSE transport** — third transport option alongside `stdio` and `http` (which Hermes calls "pipe" when it means stdin/stdout JSON-RPC; "http" in our code is the HTTP transport — see Open Questions). Adds `URL` + `sse_read_timeout` fields to the add-server flow and the editor; surfaces the "SSE" segment only on v0.13+ hosts.
2. **Cron `--no-agent`** — script-only watchdog jobs. New toggle in `CronJobEditor`; when ON, the prompt + skills fields collapse with a hint. Maps to `--no-agent` on `hermes cron create / edit`. Read-side adds `noAgent: Bool?` to `HermesCronJob` for round-trip tolerance.
3. **Web Tools backend split**`web_search` and `web_extract` config keys gain distinct backends. Net-new tab "Web Tools" in `SettingsView` with two backend pickers. Pre-v0.13 hosts see a legacy combined picker (single `web_tools.backend` key) rendered inside the same tab so the chrome stays consistent.
4. **Profiles `--no-skills`** — Mac create-profile sheet gains an "Empty profile (no skills)" toggle that appends `--no-skills` to `hermes profile create`. iOS is read-only and out of scope.
### Non-goals
- **Live MCP SSE wire-format probing.** WS-7 only writes the YAML + surfaces the field. Hermes owns the runtime connect; Scarf trusts `hermes mcp test <name>` to verify.
- **MCP `pipe` transport surface.** v0.13 release notes mention "Retry stale pipe transport failures as session-expired" — pipe is Hermes-internal jargon for the existing stdio transport (per parser logic at `HermesFileService.parseMCPServersBlock` and `MCPTransport` enum cases). No new user-facing transport option for "pipe".
- **`web_tools.search.<backend>.<api_key>` deep settings.** Backend-specific tuning (e.g. SearXNG host URL, Tavily API key) stays in raw YAML editor for v2.8. Per-backend config sheets are a follow-up — the "split" is the v0.13 wire change WS-7 must ship.
- **iOS `--no-skills`.** iOS Profiles is read-only (per CLAUDE.md "v0.12 iOS catch-up (Phase H)" and `Scarf iOS/Profiles/ProfilesView.swift`). No new toggles on iOS.
- **Cron `--no-agent` retroactive flagging.** A v0.13 host whose `~/.hermes/cron/jobs.json` already has `no_agent: true` jobs gets the badge for free via the new `noAgent` field; no migration UX.
---
## 1. MCP SSE transport
### Files / changes
#### 1a. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesMCPServer.swift`
**Why:** `MCPTransport` is currently a 2-case enum (`stdio`, `http`). Adding `sse` keeps SwiftUI Picker code paths simple — the existing `Picker(selection: $transport) { ForEach(MCPTransport.allCases) { ... } }` in `MCPServerAddCustomView` then iterates three cases automatically.
**Edits:**
- Extend `MCPTransport`:
```swift
public enum MCPTransport: String, Sendable, Equatable, CaseIterable, Identifiable {
case stdio
case http
case sse // v0.13+
...
}
```
- Add `displayName` case for `.sse`: `"Remote (SSE)"`.
- Add a single new stored property to `HermesMCPServer`:
- `public let sseReadTimeout: Int?` — seconds. `nil` when the YAML doesn't specify `sse_read_timeout`.
- Append `sseReadTimeout: Int? = nil` to the memberwise initializer's tail (defaulted) so existing call sites compile unchanged. Mirrors how `connectTimeout` lives next to `timeout`.
- Update `summary` so `.sse` returns `url ?? ""` (same shape as `.http`).
**Tolerance contract:** A pre-v0.13 server entry with no `url` and no `sse_read_timeout` parses as `.stdio`. A v0.13 entry with `url` + `sse_read_timeout` parses as `.sse` — see parser change below.
#### 1b. `scarf/scarf/Core/Services/HermesFileService.swift`
**Why:** YAML parser at `parseMCPServersBlock` (line 796) currently distinguishes stdio vs http with `let transport: MCPTransport = fields["url"] != nil ? .http : .stdio`. SSE also has a `url`, so we need a second discriminator.
**Edits:**
- Inside the `flush()` closure (around line 815), replace the binary discriminator with a 3-way one:
```swift
let transport: MCPTransport = {
if fields["transport"]?.lowercased() == "sse" { return .sse }
if fields["url"] != nil { return .http }
return .stdio
}()
```
Hermes v0.13's `mcp add --url <https://...> --transport sse` writes a `transport: sse` scalar into the YAML entry; older hosts emit no `transport` key, defaulting to `.http` for url-based entries and `.stdio` otherwise. This preserves byte-for-byte round-trip on existing files.
- Read `sse_read_timeout` from `fields["sse_read_timeout"]`, parse as `Int?`, pass into `HermesMCPServer` initializer.
- New writer method:
```swift
@discardableResult
nonisolated func addMCPServerSSE(name: String, url: String, sseReadTimeout: Int?) -> (exitCode: Int32, output: String) {
var args = ["mcp", "add", name, "--url", url, "--transport", "sse"]
if let t = sseReadTimeout { args += ["--sse-read-timeout", String(t)] }
return runHermesCLI(args: args, timeout: 45, stdinInput: "y\ny\ny\n")
}
```
Verify the exact CLI flag name during integration — `--sse-read-timeout` is the natural form but Hermes may have shipped it as `--sse-read-timeout-seconds` or merged it under `--timeout`. See Open Questions.
- New writer for changing `sse_read_timeout` post-create:
```swift
@discardableResult
nonisolated func setMCPServerSSETimeout(name: String, sseReadTimeout: Int?) -> Bool {
patchMCPServerField(name: name) { entryLines in
if let t = sseReadTimeout {
Self.replaceOrInsertScalar(key: "sse_read_timeout", value: String(t), in: &entryLines)
} else {
Self.removeScalar(key: "sse_read_timeout", in: &entryLines)
}
}
}
```
Mirrors `setMCPServerTimeouts` line-for-line.
**Round-trip invariant:** Adding an SSE server through `addMCPServerSSE`, then editing its `sse_read_timeout` through `setMCPServerSSETimeout`, then re-loading, must produce the same `HermesMCPServer.sseReadTimeout` value. Test fixture below.
#### 1c. `scarf/scarf/Features/MCPServers/Views/MCPServerAddCustomView.swift`
**Why:** This is the add-server form. It currently has a 2-segment transport picker.
**Edits:**
- Add `@Environment(\.hermesCapabilities) private var capabilitiesStore`.
- Add `@State private var sseReadTimeout: String = ""`.
- Replace the static `Picker { ForEach(MCPTransport.allCases) }` segmented control with a filtered list that drops `.sse` when capability is off:
```swift
private var availableTransports: [MCPTransport] {
var t: [MCPTransport] = [.stdio, .http]
if capabilitiesStore?.capabilities.hasMCPSSETransport ?? false { t.append(.sse) }
return t
}
```
Render with `ForEach(availableTransports) { ... }`. Iterating `MCPTransport.allCases` would render the SSE option even on pre-v0.13 hosts, which Hermes argparse would reject.
- Branch the body: when `transport == .sse`, render an `sseSection` next to (not replacing) the existing `httpSection`. Shape:
```swift
private var sseSection: some View {
sectionBox(title: "Endpoint (SSE)") {
VStack(alignment: .leading, spacing: 8) {
VStack(alignment: .leading, spacing: 4) {
Text("URL").font(.caption.bold())
TextField("https://.../sse", text: $url)
.textFieldStyle(.roundedBorder)
.font(.system(.body, design: .monospaced))
}
VStack(alignment: .leading, spacing: 4) {
Text("SSE Read Timeout (seconds)").font(.caption.bold())
TextField("default 300", text: $sseReadTimeout)
.textFieldStyle(.roundedBorder)
.frame(maxWidth: 140)
Text("Hermes-side keepalive interval. Leave blank to use the default.")
.font(.caption2)
.foregroundStyle(.secondary)
}
}
}
}
```
Default placeholder reads `default 300` since Hermes v0.13's `sse_read_timeout` defaults to 300s (verify against `~/.hermes/hermes-agent/hermes_cli/mcp.py` during integration; if it's 60s or 600s adjust the placeholder copy).
- Adjust `canSubmit` + `submit()`:
- `case .sse: return !url.trimmingCharacters(in: .whitespaces).isEmpty`
- In `submit()`, dispatch based on `transport`:
```swift
switch transport {
case .stdio: viewModel.addCustom(...) // existing
case .http: viewModel.addCustom(...) // existing
case .sse: viewModel.addCustomSSE(name: trimmedName, url: ..., sseReadTimeout: Int(sseReadTimeout))
}
```
#### 1d. `scarf/scarf/Features/MCPServers/ViewModels/MCPServersViewModel.swift`
**Edits:**
- New method:
```swift
func addCustomSSE(name: String, url: String, sseReadTimeout: Int?) {
let fileService = self.fileService
Task.detached {
let result = fileService.addMCPServerSSE(name: name, url: url, sseReadTimeout: sseReadTimeout)
await MainActor.run {
if result.exitCode == 0 {
self.flashStatus("Added \(name)")
self.load()
self.selectedServerName = name
self.showRestartBanner = true
self.showAddCustom = false
} else {
self.activeError = "Add failed: \(result.output)"
}
}
}
}
```
- Optional cosmetic: add a third filtered list `sseServers: [HermesMCPServer]` matching the `stdioServers` / `httpServers` pattern, plus a third `Section("Remote (SSE)")` in `MCPServersView.serversList`. Keeping the two existing sections + a new one mirrors the existing UX better than collapsing all remote into one section.
#### 1e. `scarf/scarf/Features/MCPServers/Views/MCPServersView.swift`
**Edits:**
- Add a third `if !viewModel.sseServers.isEmpty { Section("Remote (SSE)") { ... } }` block in `serversList`. The icon for the row stays `network` (same as http) — the "(SSE)" label in the section header is the differentiator.
- No capability gate inside `MCPServersView` — pre-v0.13 hosts simply have no `.sse` entries to render.
#### 1f. `scarf/scarf/Features/MCPServers/Views/MCPServerEditorView.swift`
**Why:** Edit existing server's `sse_read_timeout`. The editor today exposes `timeout` + `connect_timeout` in `timeoutsSection`; SSE servers want a third numeric.
**Edits:**
- Add `@Environment(\.hermesCapabilities)` so the editor can know whether the field is editable.
- Branch `timeoutsSection` on `viewModel.server.transport`:
- For `.stdio` and `.http`: render the existing connect/call timeouts.
- For `.sse`: render the existing connect/call timeouts AND add a third "SSE Read Timeout" field bound to `viewModel.sseReadTimeoutDraft`.
- Update `MCPServerEditorViewModel`:
- Add `var sseReadTimeoutDraft: String` initialized from `server.sseReadTimeout.map(String.init) ?? ""`.
- Inside `save()`, when `transport == .sse`, call `service.setMCPServerSSETimeout(name: name, sseReadTimeout: Int(sseReadTimeoutDraft))` alongside the existing `setMCPServerTimeouts` call. A failure flips `ok = false` like the others.
#### 1g. `scarf/Packages/ScarfCore/Tests/ScarfCoreTests/HermesMCPServerYAMLTests.swift` (NEW or extension to existing)
**Tests:**
1. `parseMCPServersBlock_v013_sseEntry_decodesAsSSE` — fixture YAML with `transport: sse` + `url: https://...` + `sse_read_timeout: 300` parses to `.sse` transport with the right `sseReadTimeout` value.
2. `parseMCPServersBlock_v012_httpEntry_stillDecodesAsHTTP` — pre-v0.13 entry without `transport:` still resolves to `.http` when `url` is present.
3. `parseMCPServersBlock_v012_stdioEntry_stillDecodesAsStdio` — entry with no `url` and no `transport:` resolves to `.stdio`.
4. `setMCPServerSSETimeout_writesAndClears` — round-trip integration test using a temp YAML: write `300`, re-read, assert; write `nil`, re-read, assert key removed.
### Capability gating
- **Add-server form:** `availableTransports` filter drops `.sse` when `hasMCPSSETransport` is false. Pre-v0.13 hosts see only "stdio | http" segments. The toolbar add button stays unconditional — the gate lives inside the form.
- **Editor:** `sse_read_timeout` field renders only for servers whose `transport == .sse`. Since pre-v0.13 hosts can't write SSE servers, the field never appears for those users. (Defensive: if a v0.13 server is somehow viewed on a pre-v0.13 host — e.g. user downgraded Hermes — the editor still reads + writes the field. Hermes will ignore it. Acceptable.)
- **List rendering:** `Section("Remote (SSE)")` only renders when `sseServers` is non-empty, so pre-v0.13 hosts don't see an empty section.
### Tests
- ScarfCore: 4 YAML-parser tests above + 2 model tests (`MCPTransport.allCases.count == 3`, `sseReadTimeout` round-trips through memberwise init).
- ScarfTests (Mac app): `MCPServersViewModelTests.testAddCustomSSE` mock-fileservice test verifying the `--transport sse --sse-read-timeout` flag shape.
### Rollout
- Feature-gate behind `hasMCPSSETransport` so a pre-v0.13 host never sees the SSE option.
- No migration: existing stdio/http servers are unaffected.
- One commit. Should land at ~250-350 LOC additions across 6 files.
---
## 2. Cron `--no-agent` toggle
### Files / changes
#### 2a. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesCronJob.swift`
**Why:** Read-side support so `loadCronJobs()` can round-trip `no_agent: true` from `~/.hermes/cron/jobs.json`. Pre-v0.13 jobs.json files don't have the field — the existing `decodeIfPresent` pattern (line 113 for `workdir`) handles that.
**Edits:**
- Add `public nonisolated let noAgent: Bool?` between `workdir` and `contextFrom`.
- Extend `enum CodingKeys` with `case noAgent = "no_agent"`.
- Extend the public memberwise initializer's tail with `noAgent: Bool? = nil`.
- Extend `init(from decoder:)`: `self.noAgent = try c.decodeIfPresent(Bool.self, forKey: .noAgent)`.
- Extend `encode(to encoder:)`: `try c.encodeIfPresent(noAgent, forKey: .noAgent)`.
**Tolerance contract:** A pre-v0.13 jobs.json with no `no_agent` field decodes with `noAgent == nil`. A v0.13 jobs.json with explicit `no_agent: false` decodes with `noAgent == false`. The "render the badge?" check is `job.noAgent == true` (treats `nil` and `false` identically — a script-only job must opt in).
#### 2b. `scarf/scarf/Features/Cron/Views/CronView.swift`
**Edits:**
- Extend `CronJobEditor.FormState` with `var noAgent: Bool = false`.
- Add `let supportsNoAgent: Bool` next to the existing `let supportsWorkdir: Bool`.
- Inside `body`, add a Toggle row near the bottom of the form (after `Workdir`, before `availableSkills`):
```swift
if supportsNoAgent {
Toggle("Run script only (no agent call)", isOn: $form.noAgent)
.scarfStyle(.body)
.tint(ScarfColor.accent)
if form.noAgent {
Text("Watchdog mode — Hermes runs the pre-run script and skips the AI turn. Prompt + skills are ignored.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.padding(.leading, ScarfSpace.s3)
}
}
```
- Conditionally collapse the prompt + skills sections when `form.noAgent` is true. Don't *remove* them from the view tree — keep them rendered but visually muted (and perhaps disabled). This avoids the layout shift surprise of fields disappearing mid-edit:
```swift
// around the existing Prompt TextEditor
.opacity(form.noAgent ? 0.4 : 1.0)
.disabled(form.noAgent)
.accessibilityHint(form.noAgent ? Text("Disabled — Run script only is on") : Text(""))
```
Apply the same to the Skills picker. Script field stays fully active — it's the load-bearing thing in `--no-agent` mode.
- On entering edit mode (the existing `.onAppear` handler), hydrate `form.noAgent = job.noAgent ?? false`.
- Wire through to the parent: pass `form.noAgent` in the `onSave(form)` callback. The parent's `viewModel.createJob` / `updateJob` then knows the flag.
#### 2c. `scarf/scarf/Features/Cron/Views/CronView.swift` — owner site
**Edits:**
- Add a private capability accessor next to `hasCronWorkdir`:
```swift
private var hasCronNoAgent: Bool {
capabilitiesStore?.capabilities.hasCronNoAgent ?? false
}
```
- Plumb `supportsNoAgent: hasCronNoAgent` into `CronJobEditor` instantiations (both the create and edit sheet paths, mirroring how `supportsWorkdir` is wired).
- Update the create + edit `.sheet` closures to pass `noAgent: form.noAgent` into `viewModel.createJob` / `updateJob`. Mirror the `workdir` strip-on-pre-v0.12 pattern: pass `hasCronNoAgent ? form.noAgent : false`. (For the update path, pass `hasCronNoAgent ? form.noAgent : nil` if the underlying VM signature distinguishes "don't touch" from "set false" — see VM section below.)
#### 2d. `scarf/scarf/Features/Cron/ViewModels/CronViewModel.swift`
**Edits:**
- Extend `createJob` signature with `noAgent: Bool = false` at the tail:
```swift
func createJob(schedule: String, prompt: String, name: String, deliver: String, skills: [String], script: String, repeatCount: String, workdir: String = "", noAgent: Bool = false) {
var args = ["cron", "create"]
...
if noAgent { args.append("--no-agent") }
args.append(schedule)
// When --no-agent is set Hermes ignores the prompt arg, but argparse still
// wants positional args to line up with the schedule. Pass an empty string
// explicitly so the positional parser doesn't treat the prompt as missing.
if noAgent {
args.append("")
} else if !prompt.isEmpty {
args.append(prompt)
}
runAndReload(args, success: "Job created")
}
```
Verify Hermes's argparse behavior during integration — if `cron create --no-agent <schedule>` rejects the trailing empty positional, drop the empty-string append.
- Extend `updateJob` signature with `noAgent: Bool? = nil`:
```swift
func updateJob(id: String, ..., workdir: String? = nil, noAgent: Bool? = nil) {
var args = ["cron", "edit", id]
...
if let noAgent {
// Hermes documents `--no-agent` as a flag on `cron edit` for v0.13+.
// Verify exact toggle-off shape (likely `--no-agent=false` or
// `--agent` to flip back). See Open Questions.
if noAgent { args.append("--no-agent") }
else { args.append("--agent") }
}
runAndReload(args, success: "Updated")
}
```
#### 2e. `scarf/scarf/Features/Cron/Views/CronView.swift` — detail rendering
**Edits (cosmetic, optional but high-value):** When the selected job has `noAgent == true`, render a small `ScarfBadge("script-only", kind: .info)` in `detailHeader` next to the existing `paused` / `running…` badges so the user can tell at a glance which jobs are watchdogs. Same in the `cronRow` list — append a `ScarfBadge("no-agent", kind: .neutral)` when the flag is on, similar to the existing `paused` badge.
### Capability gating
- **Editor toggle:** rendered only when `supportsNoAgent` is true. Pre-v0.13 hosts never see the field.
- **Defensive write-strip:** `CronView` passes `hasCronNoAgent ? form.noAgent : false` on create and `hasCronNoAgent ? form.noAgent : nil` on edit. Mirrors the `workdir` strip from v0.12 (`workdir: hasCronWorkdir ? form.workdir : ""` on create, `nil` on edit).
- **Read-side rendering:** badges + collapsed-fields visual cue render unconditionally when `job.noAgent == true`. A user who downgraded Hermes after creating a `no_agent` job still sees it labeled correctly, even though they can no longer create new ones.
### Tests
- `M6ConfigCronTests` extension: add `decodes_v013_jobs_json_with_no_agent` — fixture jobs.json with one job carrying `no_agent: true`. Assert `job.noAgent == true`.
- `M6ConfigCronTests`: `decodes_v012_jobs_json_no_no_agent_field` — pre-v0.13 fixture, assert `job.noAgent == nil`.
- `CronViewModelNoAgentTests` (new): mock-fileservice test asserting `createJob(..., noAgent: true)` produces `["cron", "create", "--no-agent", schedule, ""]` (or whatever argparse shape we converge on after integration).
- Manual: pre-v0.13 host — toggle absent in editor. v0.13 host — toggle present, creating a script-only job with no AGENTS.md context completes without an LLM call (verify in `~/.hermes/logs/`).
### Rollout
- One commit. ~150-200 LOC across 4 files (model + view + editor + VM).
---
## 3. Web Tools backend split
### Files / changes
A net-new Settings tab. Today there is no Web Tools tab — `web_extract`'s **provider** lives in Aux Models, but `web_tools.search.backend` / `web_tools.extract.backend` (the backend-not-provider keys) are not surfaced by Scarf today (verified: `grep web_tools = ` returns no Scarf hits). v0.13 makes "split per capability" the wire model, so introducing the tab here gives us a clean substrate to add backend-specific rows on later.
Layout shape:
- Pre-v0.13: a single row "Combined backend" → `web_tools.backend` key (legacy v0.12 shape).
- v0.13+: two rows — "Search backend" → `web_tools.search.backend`, "Extract backend" → `web_tools.extract.backend`. SearXNG appears in the Search picker only.
Both shapes coexist in the same tab; the gate decides which renders.
#### 3a. `scarf/scarf/Features/Settings/Views/SettingsView.swift`
**Edits:**
- Add a new case to `SettingsTab`:
```swift
case webTools = "Web Tools"
```
Position: between `.browser` and `.voice` (browser-adjacent in the user's mental model). Update `displayName`, `icon` (`"globe.americas"`), and `tabContent` switch.
- `tabContent` adds: `case .webTools: WebToolsTab(viewModel: viewModel)`.
#### 3b. `scarf/scarf/Features/Settings/Views/Tabs/WebToolsTab.swift` (NEW)
**Why:** Self-contained tab file matching the existing pattern (`BrowserTab.swift`, `TerminalTab.swift`, etc.). Pre-v0.13 + v0.13+ shapes both live here behind a capability check.
**Shape:**
```swift
import SwiftUI
import ScarfCore
import ScarfDesign
struct WebToolsTab: View {
@Bindable var viewModel: SettingsViewModel
@Environment(\.hermesCapabilities) private var capabilitiesStore
private var split: Bool {
capabilitiesStore?.capabilities.hasWebToolsBackendSplit ?? false
}
private static let searchBackends: [String] = [
"duckduckgo", "tavily", "brave", "exa", "you", "searxng"
]
private static let extractBackends: [String] = [
"reader", "browserless", "trafilatura", "firecrawl"
]
private static let combinedBackends: [String] = [
"duckduckgo", "tavily", "brave", "exa", "you", "reader", "browserless", "trafilatura", "firecrawl"
]
var body: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s5) {
SettingsSection(title: "Web Tools", icon: "globe.americas") {
if split {
Picker("Search backend", selection: Binding(
get: { viewModel.config.webToolsSearchBackend },
set: { viewModel.setWebToolsSearchBackend($0) }
)) {
ForEach(Self.searchBackends, id: \.self) { Text($0).tag($0) }
}
Text("SearXNG joined v0.13 as a search-only backend.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
Picker("Extract backend", selection: Binding(
get: { viewModel.config.webToolsExtractBackend },
set: { viewModel.setWebToolsExtractBackend($0) }
)) {
ForEach(Self.extractBackends, id: \.self) { Text($0).tag($0) }
}
} else {
Picker("Backend", selection: Binding(
get: { viewModel.config.webToolsBackend },
set: { viewModel.setWebToolsBackend($0) }
)) {
ForEach(Self.combinedBackends, id: \.self) { Text($0).tag($0) }
}
Text("Hermes v0.13 splits search and extract into separate backends. Update Hermes to access the per-capability picker.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
}
}
}
}
}
```
The backend lists are intentionally small + curated. **The exact set must be reconciled against `~/.hermes/hermes-agent/hermes_cli/web_tools.py` (or wherever Hermes registers the dispatch table)** during integration. See Open Questions.
#### 3c. `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift`
**Edits:**
- Add three new top-level fields to `HermesConfig` (next to `redactionEnabled` near line 663, since they share the v0.12+ migration tail comment):
```swift
/// Pre-v0.13: single combined backend at `web_tools.backend`. v0.13
/// flipped to per-capability split (see below). Kept for round-trip
/// on hosts that never migrated.
public var webToolsBackend: String // default "duckduckgo"
/// v0.13+: `web_tools.search.backend`. SearXNG can land here.
public var webToolsSearchBackend: String // default "duckduckgo"
/// v0.13+: `web_tools.extract.backend`.
public var webToolsExtractBackend: String // default "reader"
```
- Add to the memberwise initializer at the tail with defaults so v2.7.5 call sites still compile.
- Extend `.empty` with `"duckduckgo"` / `"duckduckgo"` / `"reader"` defaults.
#### 3d. `scarf/Packages/ScarfCore/Sources/ScarfCore/Parsing/HermesConfig+YAML.swift`
**Edits:** Read three new keys via the existing `str(...)` helper:
- `webToolsBackend: str("web_tools.backend", default: "duckduckgo")`
- `webToolsSearchBackend: str("web_tools.search.backend", default: "duckduckgo")`
- `webToolsExtractBackend: str("web_tools.extract.backend", default: "reader")`
Pre-v0.13 YAML has only `web_tools.backend`; the two split keys default to the same value. v0.13 YAML may have `web_tools.search.backend` set and `web_tools.backend` absent — the legacy field falls back to its default but is unused on v0.13 hosts (the tab gates on `hasWebToolsBackendSplit`).
#### 3e. `scarf/scarf/Features/Settings/ViewModels/SettingsViewModel.swift`
**Edits:** Three new setters:
```swift
func setWebToolsBackend(_ value: String) { setSetting("web_tools.backend", value: value) }
func setWebToolsSearchBackend(_ value: String) { setSetting("web_tools.search.backend", value: value) }
func setWebToolsExtractBackend(_ value: String) { setSetting("web_tools.extract.backend", value: value) }
```
All three route through `hermes config set <key> <value>` — the v0.13 CLI accepts the dotted path keys as written. Hermes config-set rejects unknown keys, so on a pre-v0.13 host `setWebToolsSearchBackend` would fail; we don't expose the call site there (the picker isn't rendered).
### Capability gating
- **Tab itself:** the tab is always shown — pre-v0.13 hosts see the legacy combined picker so they're not blocked from configuring Web Tools at all. Removing the tab entirely on pre-v0.13 hosts would create a feature regression for users on v0.12.
- **Picker shape:** `split` flag inside `WebToolsTab` chooses between the two shapes.
- **SearXNG visibility:** appears only in `searchBackends` (the v0.13 split case). Never in `combinedBackends`. This matches Hermes — pre-v0.13 doesn't dispatch SearXNG at all.
### Tests
- `HermesConfigYAMLTests`:
1. `parses_v012_combined_backend` — fixture with `web_tools.backend: tavily`, no split keys → `webToolsBackend == "tavily"`, split keys == defaults.
2. `parses_v013_split_backend` — fixture with both `web_tools.search.backend: searxng` + `web_tools.extract.backend: reader` → both split keys populated.
3. `parses_v013_partial` — fixture with only `web_tools.search.backend` set (extract uses default) → search populated, extract == default.
- Manual: load v0.12 host → see combined picker. Load v0.13 host → see split. Confirm SearXNG only in Search.
### Rollout
- One commit. ~200-260 LOC: 1 new file (~80 LOC), edits to 4 existing files. New tab makes this the largest of the four additions.
- Add an entry to the Settings tab strip — verify horizontal scroll still fits 11 tabs comfortably (it should; the strip is `.scrollView(.horizontal)` already).
---
## 4. Profiles `--no-skills` toggle
### Files / changes
#### 4a. `scarf/scarf/Features/Profiles/Views/ProfilesView.swift`
**Edits:**
- Add `@Environment(\.hermesCapabilities) private var capabilitiesStore` next to the existing state.
- Add `@State private var createNoSkills: Bool = false` next to `createCloneConfig` / `createCloneAll`.
- Inside `createSheet`, add a new toggle row between the existing toggles:
```swift
if capabilitiesStore?.capabilities.hasProfileNoSkills ?? false {
Toggle("Empty profile (no skills)", isOn: $createNoSkills)
.disabled(createCloneAll) // mutually exclusive with full clone
}
```
Why disabled when `createCloneAll`: a full clone copies skills wholesale — `--no-skills` would be a contradiction. Hermes likely rejects the combination but the UX is cleaner if we don't let the user reach it.
- Reset on sheet open: in the existing reset (line 126: `createName = ""; createCloneConfig = true; createCloneAll = false`), add `createNoSkills = false`.
- Wire to the VM:
```swift
Button("Create") {
viewModel.create(name: createName, cloneConfig: createCloneConfig, cloneAll: createCloneAll, noSkills: createNoSkills)
showCreate = false
}
```
#### 4b. `scarf/scarf/Features/Profiles/ViewModels/ProfilesViewModel.swift`
**Edits:** Extend `create` signature with `noSkills: Bool = false`:
```swift
func create(name: String, cloneConfig: Bool, cloneAll: Bool, noSkills: Bool = false) {
var args = ["profile", "create", name]
if cloneAll { args.append("--clone-all") }
else if cloneConfig { args.append("--clone") }
if noSkills { args.append("--no-skills") }
runAndReload(args, success: "Profile '\(name)' created")
}
```
The `--no-skills` flag is independent of `--clone` / `--clone-all` per the v0.13 release notes ("`--no-skills` flag for empty profile creation"). The UX disables the toggle under `--clone-all` for clarity, but the wire is unconditional — the user can stack `--clone --no-skills` to clone config but skip skills, which is a plausible workflow.
### Capability gating
- **Toggle visibility:** wrapped in `capabilitiesStore?.capabilities.hasProfileNoSkills ?? false`. Pre-v0.13 hosts never see it.
- **Defensive write-strip:** the VM always reads `noSkills` as the default `false` if the form didn't surface the toggle. No need for a `?? false` strip at the call site — the parameter has a default in the VM signature.
### Tests
- `ProfilesViewModelTests` (new or extension): `create_emitsNoSkillsFlagWhenSet` — mock-fileservice asserting `["profile", "create", "name", "--no-skills"]` for `noSkills: true`.
- `create_combinesCloneAndNoSkills``["profile", "create", "name", "--clone", "--no-skills"]`.
- `create_omitsNoSkillsByDefault` — verifies the v2.7.5 signature still produces the v2.7.5 args.
- Manual: pre-v0.13 host — toggle absent. v0.13 host — toggle creates an empty `~/.hermes/profiles/<name>/skills/` (verify on disk).
### Rollout
- One commit. ~30-50 LOC across 2 files. Smallest of the four additions.
---
## Open questions
1. **MCP transport names.** The release notes say "SSE transport" and reference "stale pipe transport failures." Scarf's `MCPTransport` enum has `stdio` and `http`; Hermes internally calls those `stdio` and `streamable-http` (or just `http`), and the "pipe" callsite likely refers to internal stdio process pipes — not a third user-facing transport. We're proceeding on that assumption. **Verify:** read `~/.hermes/hermes-agent/hermes_cli/mcp.py` (or equivalent) during integration to confirm `pipe` is internal-only and not a fourth user-selectable transport.
2. **`sse_read_timeout` default value.** The plan uses 300s as the placeholder ("default 300"). Hermes v0.13's `_wait_for_lifecycle_event` keepalive cadence may have a different default — could be 60s, could be 600s. Verify in code; the placeholder copy is the only impact.
3. **`hermes mcp add --transport sse` flag spelling.** The plan assumes `--transport sse` and `--sse-read-timeout <int>`. If Hermes shipped them as `--sse` (boolean) + `--read-timeout`, or merged into `--timeout`, adjust `addMCPServerSSE` accordingly. Test by running `hermes mcp add --help` against a v0.13 install.
4. **Cron `--no-agent` toggle-off shape on edit.** The plan assumes `hermes cron edit <id> --agent` flips the flag back. Possible Hermes ships only `--no-agent` (one-way) and you must `hermes cron remove` + `cron create` without the flag to undo. If so, the edit-mode toggle should be disabled or render a tooltip "Toggling off requires recreating the job." Verify against `hermes cron edit --help`.
5. **Cron `--no-agent` + positional prompt argparse.** The plan passes an empty-string positional after `--no-agent <schedule>` to satisfy argparse. Verify whether Hermes's `cron create` parser tolerates a missing prompt positional when `--no-agent` is set.
6. **Web Tools backend lists.** The plan curates a backend list inline based on the v0.13 release notes mentioning "SearXNG joined search-only." The exact dispatch table (which backends Hermes registers for search vs extract) lives in Hermes source. **Verify** during integration; the Picker contents are the only source of drift, and a wrong entry just produces a `hermes config set` failure on save (recoverable, but ugly).
7. **`web_tools.backend` legacy key on v0.13 hosts.** Hermes v0.13 may *also* honor the legacy `web_tools.backend` key as a fallback when neither split key is set, or may *only* honor it on the rare combined-capability backends. The plan keeps the field readable but only writes the split keys when `hasWebToolsBackendSplit` is true. Verify Hermes' fallback semantics — if `web_tools.backend` is silently ignored on v0.13, a user upgrading from v0.12 with `web_tools.backend: tavily` would suddenly see DuckDuckGo on both capabilities. We may want to add a one-time migration ("we noticed your config has the legacy `web_tools.backend` — promote to split keys?") in a follow-up.
8. **Profile `--no-skills` interaction with `--clone-all`.** Plan disables the `noSkills` toggle when `cloneAll` is on. Verify Hermes's behavior when both flags are passed: argparse may reject as mutually exclusive (good — argparse is the source of truth); may take last-flag-wins; or may produce a profile with everything-but-skills cloned (most useful). The disabled-toggle UX is conservative until we know.
---
## Out of scope
- **MCP per-server SSE auth selection** (Bearer vs OAuth vs none for SSE endpoints). The existing `auth` field on `HermesMCPServer` may or may not carry through to SSE; left untouched. Users can edit the YAML directly via "Open in Editor."
- **Cron `--no-agent` health surface.** A watchdog cron that fails silently (script returns non-zero, no LLM to recover) is a meaningful failure mode but the existing `lastError` rendering covers it. No new health check.
- **Web Tools per-backend config sheets.** SearXNG host URL, Tavily API key, Brave key — all stay in raw YAML for v2.8. The two backend pickers are the v0.13 wire-format change WS-7 ships; the deeper config UI is a follow-up (plausible v2.9).
- **Profiles `--no-skills` post-create surface.** No UI to list a profile's skill count, no "convert to skill-less" verb. Profiles stay create-time-only for skill scoping.
- **iOS surfaces.** All four additions are Mac-only:
- MCP SSE: Scarf has no iOS MCP servers UI today.
- Cron `--no-agent`: iOS Cron is read-only (`Scarf iOS/Cron/CronListView.swift`); no editor.
- Web Tools: iOS Settings doesn't currently surface Web Tools.
- Profiles `--no-skills`: iOS Profiles is read-only (`Scarf iOS/Profiles/ProfilesView.swift`).
iOS catch-up is WS-9 territory.
- **Wiki updates.** Per CLAUDE.md, wiki updates land alongside the release once the feature is shipped — not pre-merge. WS-7 PR notes the wiki pages that will need updating in `Scarf-Settings.md`, `Scarf-Cron.md`, `Scarf-MCP-Servers.md`, `Scarf-Profiles.md`, and `Hermes-Version-Compatibility.md`. The wiki PR is its own commit on `gh-pages` after v2.8.0 ships.
---
## Estimate
| Section | LOC est. | Files | Risk |
|---------|----------|-------|------|
| 1. MCP SSE | 250-350 | 6 (model + parser + view × 2 + VM + editor) | Medium — YAML parser change is the riskiest |
| 2. Cron `--no-agent` | 150-200 | 4 (model + view + editor + VM) | Low — mirrors v0.12 `--workdir` pattern |
| 3. Web Tools split | 200-260 | 5 (1 new tab + config model + parser + VM + tabs enum) | Medium — backend lists need verification against Hermes source |
| 4. Profiles `--no-skills` | 30-50 | 2 (view + VM) | Trivial |
| **Total** | **~700-900** | **~17 unique files** | |
**Time estimate (single dev, focused):** 2-3 days of implementation + 1 day of integration verification (the Open Questions section is mostly small empirical checks against a v0.13 Hermes install). Ten files have no overlap between the four additions, so two devs could parallelize after the model-layer work in §1 + §2 + §3 lands.
**Commit shape inside the WS-7 PR (one PR, four commits):**
1. `feat(mcp): add SSE transport support gated on hasMCPSSETransport`
2. `feat(cron): add --no-agent watchdog toggle gated on hasCronNoAgent`
3. `feat(settings): add Web Tools tab with v0.13 search/extract split`
4. `feat(profiles): add --no-skills toggle to create-profile sheet`
Reviewer can scan one commit at a time, and each can be reverted independently if a v0.13 wire-format surprise lands during integration.
+607
View File
@@ -0,0 +1,607 @@
# WS-8 Plan: UX polish (v0.13 small-surface additions)
Branch suggestion: `ws-8-ux-v0.13`. Depends on WS-1 (`ws-1-capabilities-v0.13`, PR #80) for the v0.13 capability flags consumed below — every change here is a leaf surface that reads from `HermesCapabilities` and degrades silently on pre-v0.13 hosts.
## Goals (what this PR ships)
Six small, mostly-independent UX additions tracking the v0.13 release notes' "everything else" bucket:
1. **Context compression count chip** in the chat status bar — `🗜 ×N` rendered alongside the existing token counter when Hermes' status feed surfaces a non-zero compression count.
2. **`/new <name>` argument hint** on the slash menu — extends `argumentHint` for the `/new` entry on v0.13+ hosts so users discover the optional name.
3. **`hermes update --yes` plumbing** — purely forward-compatible. v2.7.5 has no in-app "Update Hermes" affordance (Sparkle handles Scarf-self-update, and `hermes update` is invoked by users in their terminal). This WS adds a stub helper on `UpdaterService` (or a new `HermesUpdaterCommandBuilder` static) that the future affordance will call; the helper takes a `HermesCapabilities` and decides whether to append `--yes`. No user-visible change ships in v2.8 from this item alone — see [Out of scope](#out-of-scope).
4. **Redaction default-flip awareness** — the existing "Redact secrets in patches" toggle in `Settings → Advanced → Caching & Redaction` gets a hint footnote whose copy depends on the connected host's version (server default flipped from OFF in v0.12 → ON in v0.13).
5. **`display.language` picker** in Settings → General → Locale — 8-option enum (`en` / `zh` / `ja` / `de` / `es` / `fr` / `uk` / `tr`), persisted via `hermes config set display.language <code>`.
6. **xAI Custom Voices badge** next to the xAI TTS provider entry in Settings → Voice → Text-to-Speech (and `xai` added to the provider list — it's not currently there).
Out-of-scope items captured in [Out of scope](#out-of-scope).
## 1. Context compression count
### What v0.13 emits
Hermes v0.13 adds a context compression count to the status feed shown in the CLI / TUI. The release notes phrase it as "Show context compression count in status bar" — they don't pin the wire field name. See [Open question Q1](#open-questions) — the plan below assumes it lands on the existing `usage` blob in `session/prompt`'s response and that it's a monotonically-incrementing integer counting how many auto-compactions have run on the active session. This matches the structure of the existing token counters (also on `usage`) and means a single small extension to `ACPPromptResult` covers it.
### Files to change
#### [scarf/Packages/ScarfCore/Sources/ScarfCore/Models/ACPMessages.swift](../../Packages/ScarfCore/Sources/ScarfCore/Models/ACPMessages.swift)
`ACPPromptResult` (around line 240) gains one optional field:
```swift
public struct ACPPromptResult: Sendable {
public let stopReason: String
public let inputTokens: Int
public let outputTokens: Int
public let thoughtTokens: Int
public let cachedReadTokens: Int
/// Number of automatic context compactions Hermes has performed on
/// this session so far. v0.13+ — older Hermes hosts always return 0,
/// which the chat status bar treats as "hide chip". Optional in the
/// wire payload; folded into a non-optional `Int` here with a 0
/// default so the rest of the pipeline doesn't need to nil-check.
public let compressionCount: Int
public init(
stopReason: String,
inputTokens: Int,
outputTokens: Int,
thoughtTokens: Int,
cachedReadTokens: Int,
compressionCount: Int = 0
) { … }
}
```
Default-zero on the initializer keeps existing call sites compiling; the only mutator is `ACPClient.sendPrompt`.
#### [scarf/Packages/ScarfCore/Sources/ScarfCore/ACP/ACPClient.swift](../../Packages/ScarfCore/Sources/ScarfCore/ACP/ACPClient.swift)
`sendPrompt` (around line 311322) gains one decode line. The exact key is the open question — encode tolerantly:
```swift
let usage = dict["usage"] as? [String: Any] ?? [:]
// Tolerate either snake_case or camelCase per the rest of the ACP
// payload's mixed conventions; whichever Hermes ships, we read.
let compression = (usage["compressionCount"] as? Int)
?? (usage["compression_count"] as? Int)
?? 0
```
Pass `compressionCount: compression` into the `ACPPromptResult` initializer.
#### [scarf/Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift)
Add an observable counter alongside the existing token counters (around line 228231):
```swift
public private(set) var acpCompressionCount = 0
```
Reset to 0 in `reset()` (around line 464470) alongside the token counters.
In `handlePromptComplete` (around line 810813) — the same place that aggregates ACP token counts — overwrite (don't add) with the latest server value:
```swift
acpInputTokens += response.inputTokens
acpOutputTokens += response.outputTokens
acpThoughtTokens += response.thoughtTokens
acpCachedReadTokens += response.cachedReadTokens
// Compression count is a session-wide running total emitted by Hermes;
// each prompt response carries the latest value, so we replace rather
// than accumulate. Treat 0 as "no compactions yet" — the view hides
// the chip in that case.
acpCompressionCount = max(acpCompressionCount, response.compressionCount)
```
The `max(...)` guard tolerates pre-v0.13 hosts that return `0` mid-session: if the agent is upgraded server-side without restarting Scarf, the count will resume at the higher value the next time `usage` carries a real number.
#### [scarf/scarf/Features/Chat/Views/SessionInfoBar.swift](../../scarf/Features/Chat/Views/SessionInfoBar.swift)
Add one more pass-through prop alongside the existing `acpInputTokens` / `acpOutputTokens` / `acpThoughtTokens` (lines 911):
```swift
var acpCompressionCount: Int = 0
/// Capability snapshot for v0.13 surfaces. Defaulted so previews and
/// pre-v0.13 hosts render the v2.7.5 layout unchanged.
var capabilities: HermesCapabilities = .empty
```
Inside the `body` `HStack`, after the reasoning-tokens label and before the cost label, render the compression chip:
```swift
if capabilities.hasContextCompressionCount && acpCompressionCount > 0 {
Label("×\(acpCompressionCount)", systemImage: "arrow.down.right.and.arrow.up.left")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.help("Hermes auto-compacted this session's context \(acpCompressionCount) time\(acpCompressionCount == 1 ? "" : "s")")
}
```
Notes on the visual: stick to existing `Label` + `scarfStyle(.caption)` + `ScarfColor.foregroundMuted` so the chip blends with the other counters. **Don't** invent a new `ScarfBadge` style — the row's already badge-like via the surrounding `.padding(.horizontal, ScarfSpace.s4)` background, and ScarfBadge would visually overpower a passive count. Icon: `arrow.down.right.and.arrow.up.left` (the SF Symbol for compaction). If the symbol doesn't render on macOS 14.6 — which we deploy to — fall back to a Unicode box-drawing glyph or `archivebox.fill`; flag as a follow-up rather than picking now.
#### [scarf/scarf/Features/Chat/Views/ChatTranscriptPane.swift](../../scarf/Features/Chat/Views/ChatTranscriptPane.swift)
Plumb the new field plus the env-resolved capabilities through to `SessionInfoBar`:
```swift
SessionInfoBar(
session: richChat.currentSession,
isWorking: richChat.isGenerating,
acpInputTokens: richChat.acpInputTokens,
acpOutputTokens: richChat.acpOutputTokens,
acpThoughtTokens: richChat.acpThoughtTokens,
acpCompressionCount: richChat.acpCompressionCount,
projectName: chatViewModel.currentProjectName,
gitBranch: chatViewModel.currentGitBranch,
capabilities: capabilities?.capabilities ?? .empty
)
```
Pull the capabilities from the existing `@Environment(\.hermesCapabilities)` (declared on the parent view tree per [HermesCapabilities.swift:411](../../Packages/ScarfCore/Sources/ScarfCore/Services/HermesCapabilities.swift)). If the pane doesn't currently observe it, add `@Environment(\.hermesCapabilities) private var capabilities` at the top.
#### iOS
`Scarf iOS` doesn't have a `SessionInfoBar` mirror today; the iOS chat tab uses a different header. Skip iOS in this WS — capture under [Out of scope](#out-of-scope) for follow-up. Reasoning: iOS users are read-only consumers of compression count, the data model already flows through `RichChatViewModel`, and an iOS surface isn't gated on this WS.
### Coordination with WS-2
WS-2 mounts a "Goal locked" pill into `SessionInfoBar` between the project / branch chips and the working dot. The compression chip lives on the **right** half of the bar (next to tokens / cost), not the left, so the two changes don't collide spatially. They both add `var capabilities: HermesCapabilities = .empty` to `SessionInfoBar`, however — pick the same parameter name and order so whichever WS lands first establishes the prop and the second WS just reads it. WS-2 is presumed to land first (WS-2 is a flagship feature, this is polish); if not, both WSs need to add the prop and the merger should keep one declaration.
## 2. `/new <name>` slash command argument
### Current state
`/new` already appears in the slash menu — it's advertised by the ACP server via `available_commands_update` (handled in [RichChatViewModel:234](../../Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift) into `acpCommands`). The argumentHint comes from whatever the server sends. That means the v0.13 server will *automatically* surface a hint update because Hermes will send `"argument_hint": "[name]"` (or similar) once the new flag lands. We don't need to hardcode a Scarf-side override.
### What we change
The user-visible work here is mostly verification / smoke-testing. The mechanical changes are minor, mostly defensive:
#### [scarf/scarf/Features/Chat/Views/SlashCommandMenu.swift](../../scarf/Features/Chat/Views/SlashCommandMenu.swift)
The argument hint renderer at line 8993 wraps the hint in `<…>` literally. Hermes v0.13 likely emits the optional argument as `[name]` (square-bracket convention for "optional"). If we leave the wrapper in place we'd render `<[name]>`. Replace the wrapper with a smarter join:
```swift
if let hint = command.argumentHint {
let display = hint.hasPrefix("<") || hint.hasPrefix("[")
? hint
: "<\(hint)>"
Text(display)
.font(ScarfFont.monoSmall)
.foregroundStyle(ScarfColor.foregroundFaint)
}
```
This way the server's chosen brackets pass through, and existing entries that send `guidance` (without brackets) still render `<guidance>`.
#### Capability gate (none required, but a help-text override is allowed)
We *could* gate the rendering behind `hasNewWithSessionName` and override the hint only on v0.13+ — but the agent is the source of truth for the hint, and pre-v0.13 will send no hint at all (or the old hint). Leaving the renderer un-gated and trusting the agent's value is simpler and forward-compatible. **No flag check at this site.**
The flag exists for one place: a small banner in the slash menu that says "Tip: `/new <name>` lets you label the next session" on v0.13+ if the user hovers `/new` for >1s. **Defer the tip — over-engineering for one slash command.** Capture under [Out of scope](#out-of-scope).
### Coordination with WS-2
WS-2 also touches the slash menu (adds `/goal` and `/queue` to `nonInterruptiveCommands`), but only at the `RichChatViewModel.nonInterruptiveCommands` array site. This WS doesn't touch that array — only the renderer. Independent.
## 3. `hermes update --yes` plumbing
### Current state
There is **no in-app `hermes update` affordance** in v2.7.5. `UpdaterService` ([scarf/Core/Services/UpdaterService.swift](../../scarf/Core/Services/UpdaterService.swift)) wraps Sparkle for Scarf-self-update — that's a separate concern from updating the Hermes binary. The `hermes update` subcommand (added in v0.12 with `--check`, extended in v0.13 with `--yes`) is currently invoked by users in their terminal. The comment at [scarfApp.swift:281](../../scarf/scarfApp.swift) ("explicit refresh after `hermes update`") is aspirational — there's no UI that invokes `hermes update`.
### What this WS adds
A small forward-compatible utility so the future "Update Hermes" affordance (queued for a later release) doesn't have to re-derive flag selection. Add a single static helper on either `HermesUpdaterCommandBuilder` (new, in ScarfCore) or as a static on `UpdaterService` (Mac-only). Picking ScarfCore so iOS gets it for free, even though iOS won't ship the affordance soon either:
#### [scarf/Packages/ScarfCore/Sources/ScarfCore/Services/HermesUpdaterCommandBuilder.swift](../../Packages/ScarfCore/Sources/ScarfCore/Services/HermesUpdaterCommandBuilder.swift) (NEW)
```swift
import Foundation
/// Pure helpers that build argv arrays for `hermes update` invocations.
/// Lives here so the eventual UI surface (Mac / iOS / remote) shares
/// flag selection. Each helper is a `nonisolated static` pure function
/// — no transport, no MainActor, no mocking surface required.
public enum HermesUpdaterCommandBuilder {
/// Argv for an interactive update. Pre-v0.12 hosts only had `update`;
/// v0.12+ accepts `--check` for preflight; v0.13+ accepts `--yes` /
/// `-y` for unattended runs.
public static func updateArgv(
capabilities: HermesCapabilities,
unattended: Bool,
checkOnly: Bool
) -> [String] {
var args: [String] = ["update"]
if checkOnly && capabilities.hasUpdateCheck {
args.append("--check")
}
if unattended && capabilities.hasUpdateNonInteractive {
args.append("--yes")
}
return args
}
}
```
Test target: a small `M0eUpdaterTests` suite (new file under `ScarfCoreTests`) covering the matrix:
- pre-v0.12 → `["update"]` regardless of flags
- v0.12 + checkOnly → `["update", "--check"]`
- v0.12 + unattended → `["update"]` (flag absent — host can't honor it)
- v0.13 + unattended → `["update", "--yes"]`
- v0.13 + checkOnly + unattended → `["update", "--check", "--yes"]`
### What this WS does NOT add
No UI surface. No menu item, no Settings row, no command-palette entry. The plumbing exists so when v2.9 / v3.0 adds the affordance it doesn't need to derive flag logic from scratch. Per the WS-8 prompt: "If no such surface exists in v2.7.5, the v0.13 flag is forward-compat plumbing only — note that and don't over-build."
### Coordination with WS-2
None. Different files.
## 4. Redaction default-flip awareness
### Current state
The toggle lives in [scarf/Features/Settings/Views/Tabs/AdvancedTab.swift:129133](../../scarf/Features/Settings/Views/Tabs/AdvancedTab.swift), inside the `Caching & Redaction` section. It's wired through `viewModel.config.redactionEnabled``redaction.enabled`. The default for the *Scarf-side* `bool("redaction.enabled", default: false)` at [HermesFileService.swift:315](../../scarf/Core/Services/HermesFileService.swift) is `false` — meaning when the YAML key is absent, Scarf reads the toggle as off. That matches v0.12 server behavior.
In v0.13 the *server-side* default flips to ON (Hermes treats absence-of-key as redaction-enabled). Scarf's read default at the line above stays `false` because that's what we display when the user hasn't explicitly set the key — but the *meaning* of "off-with-no-key" diverges:
- pre-v0.13 host + no key → Scarf shows OFF, server treats as OFF. Honest.
- v0.13 host + no key → Scarf shows OFF, server treats as ON. **Confusing.**
### What we change — option A (recommended): hint copy only
Smallest possible surface. Don't change the parsing default; the file ground-truth is "key absent". Add a one-line hint below the toggle whose copy depends on `capabilities.hasContextCompressionCount` (any v0.13 flag works as a discriminant; reuse one rather than adding `hasV013` to `HermesCapabilities`). Pick `hasGoals` as the marker since it's the most central v0.13 flag — but that's an aesthetic choice; any of the v0.13 flags discriminate the same set of hosts.
#### [scarf/scarf/Features/Settings/Views/Tabs/AdvancedTab.swift](../../scarf/Features/Settings/Views/Tabs/AdvancedTab.swift)
Inside `v012CachingSection`'s `SettingsSection` (around line 122139), after the `ToggleRow` for `redaction.enabled`, append a `HintRow` (or whatever the existing inline-hint pattern in that file is — likely just a `Text` wrapped in a styled `HStack` matching the `credentialsHint` shape from `GeneralTab`):
```swift
ToggleRow(
label: "Redact secrets in patches",
isOn: viewModel.config.redactionEnabled
) { viewModel.setSetting("redaction.enabled", value: $0 ? "true" : "false") }
redactionDefaultsHint
```
…and add the computed view:
```swift
@Environment(\.hermesCapabilities) private var capabilitiesStore
@ViewBuilder
private var redactionDefaultsHint: some View {
let v013 = capabilitiesStore?.capabilities.hasGoals == true
HStack {
Text("")
.frame(width: 160, alignment: .trailing)
Text(v013
? "Recommended: ON. Hermes v0.13+ defaults to redacting secrets unless you opt out."
: "Default OFF in Hermes v0.12. Toggle ON to redact secrets in logs and shares.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
Spacer()
}
.padding(.horizontal, 12)
.padding(.vertical, 4)
}
```
The aligned-right empty `Text` mimics the label-column gutter so the hint tucks under the toggle's value column rather than aligning with the section's left edge — matches the existing visual rhythm in this tab.
### Why option A and not option B (changing the parsing default)
Option B would be: read `bool("redaction.enabled", default: capabilities.hasGoals)`. That sounds nicer but wires capabilities into `HermesFileService.parseConfig`, which is currently `nonisolated` and pure. Threading the store through would touch a dozen call sites. Not worth it for a hint that's already accurate via option A.
### Coordination with WS-2
None. Different file, different section.
## 5. `display.language` picker
### What v0.13 adds
Hermes v0.13 honors `display.language` in `config.yaml` for static-message translations. Supported values: `en` (default), `zh`, `ja`, `de`, `es`, `fr`, `uk`, `tr`. Users can already write the YAML by hand; this WS adds an in-app picker so it's discoverable.
### Files to change
#### [scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift](../../Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift)
`DisplaySettings` (around line 30) gains one field:
```swift
public struct DisplaySettings: Sendable, Equatable {
public var skin: String
public var compact: Bool
public var resumeDisplay: String
public var bellOnComplete: Bool
public var inlineDiffs: Bool
public var toolProgressCommand: Bool
public var toolPreviewLength: Int
public var busyInputMode: String
/// Static-message translation language. v0.13+. Empty string means
/// "follow Hermes default" — we display this as `en` in the picker.
/// Persisted via `hermes config set display.language <code>`.
public var language: String
}
```
Add to the initializer (with a default empty-string value and a fall-through assignment) and to the `.empty` static. **Don't** default to `"en"` here — empty string means "config key absent", which is semantically distinct from "user explicitly chose en". The picker collapses both to "English" in display, but the writer only writes a value when the user picks something.
#### [scarf/scarf/Core/Services/HermesFileService.swift](../../scarf/Core/Services/HermesFileService.swift)
Inside the `display` block construction (around line 7984), add:
```swift
let display = DisplaySettings(
skin: str("display.skin", default: "default"),
compact: bool("display.compact", default: false),
resumeDisplay: str("display.resume_display", default: "full"),
bellOnComplete: bool("display.bell_on_complete", default: false),
inlineDiffs: bool("display.inline_diffs", default: true),
toolProgressCommand: bool("display.tool_progress_command", default: false),
toolPreviewLength: int("display.tool_preview_length", default: 0),
busyInputMode: str("display.busy_input_mode", default: "interrupt"),
language: str("display.language", default: "")
)
```
#### [scarf/scarf/Features/Settings/ViewModels/SettingsViewModel.swift](../../scarf/Features/Settings/ViewModels/SettingsViewModel.swift)
Add a setter alongside the existing `setSkin` (line 99):
```swift
func setDisplayLanguage(_ value: String) {
setSetting("display.language", value: value)
}
```
And expose the option list (8 entries; mirror the v0.13 release notes):
```swift
var displayLanguages: [(code: String, label: String)] = [
("", "English (default)"),
("en", "English"),
("zh", "中文 (Chinese)"),
("ja", "日本語 (Japanese)"),
("de", "Deutsch (German)"),
("es", "Español (Spanish)"),
("fr", "Français (French)"),
("uk", "Українська (Ukrainian)"),
("tr", "Türkçe (Turkish)"),
]
```
Two "English" entries (empty string + `en`) is intentional: the empty string means "no key" — picking `en` writes the key explicitly. UX-wise that's fine — the picker shows "English (default)" while the value-stored is still empty, and switching to `en` writes a key. Most users will move between languages, not toggle the key's presence.
#### [scarf/scarf/Features/Settings/Views/Tabs/GeneralTab.swift](../../scarf/Features/Settings/Views/Tabs/GeneralTab.swift)
Inside the existing `Locale` section (line 4042), add a picker row gated on `hasDisplayLanguage`:
```swift
SettingsSection(title: "Locale", icon: "globe.americas") {
EditableTextField(label: "Timezone (IANA)", value: viewModel.config.timezone) {
viewModel.setTimezone($0)
}
if capabilitiesStore?.capabilities.hasDisplayLanguage == true {
PickerRow(
label: "Display language",
selection: viewModel.config.display.language.isEmpty
? "" : viewModel.config.display.language,
options: viewModel.displayLanguages.map(\.code),
optionLabel: { code in
viewModel.displayLanguages.first { $0.code == code }?.label ?? code
}
) { viewModel.setDisplayLanguage($0) }
}
}
```
Add `@Environment(\.hermesCapabilities) private var capabilitiesStore` at the top of `GeneralTab`.
The `PickerRow` overload that takes a `optionLabel:` mapper may not exist today — check at implementation time, and if it doesn't, either (a) add the overload to `PickerRow.swift` (a simple closure parameter), or (b) inline a SwiftUI `Picker` directly rather than `PickerRow` for this one row. Option (a) is preferred so the rest of Settings can use it.
#### iOS
`Scarf iOS` settings are read-mostly (config writes are deferred to the Mac per the existing pattern). Skip iOS for the picker; iOS just shows the value as-is wherever Settings displays it. No iOS work in this WS.
### Capability gate
`hasDisplayLanguage` is checked at the picker site. Pre-v0.13 hosts hide the row entirely — the field would be silently ignored by the agent if written. **Don't** half-render with a "requires v0.13" label; the row should be invisible on older hosts so the user doesn't think the surface is broken.
### Coordination with WS-2
None. Different file.
## 6. xAI Custom Voices badge
### Current state
The xAI provider is **not in `ttsProviders` today** (verify at [SettingsViewModel.swift:32](../../scarf/Features/Settings/ViewModels/SettingsViewModel.swift) — the array reads `["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts", "piper"]`, no `xai`). Hermes v0.13 adds xAI as a TTS provider (it was added earlier in fact, v0.12 — the v0.13 surface is just the *Custom Voices* / cloning support on top). This WS does both at once: add `xai` to the picker and surface the cloning-supported badge.
### Files to change
#### [scarf/scarf/Features/Settings/ViewModels/SettingsViewModel.swift](../../scarf/Features/Settings/ViewModels/SettingsViewModel.swift)
Extend the provider list:
```swift
var ttsProviders = ["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts", "piper", "xai"]
```
Add setter(s) for whichever xAI-specific config keys Hermes uses. Per [Open question Q2](#open-questions) the exact keys — likely `tts.xai.voice_id` (or similar) and possibly `tts.xai.model` — need confirmation. Conservative shape mirroring elevenlabs:
```swift
func setTTSXAIVoiceID(_ value: String) { setSetting("tts.xai.voice_id", value: value) }
func setTTSXAIModel(_ value: String) { setSetting("tts.xai.model", value: value) }
```
#### [scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift](../../Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift)
`VoiceSettings` (around line 178) gains two fields next to the existing TTS provider blobs:
```swift
public var ttsXAIVoiceID: String
public var ttsXAIModel: String
```
Initializer + `.empty` updates. Defaults to empty string.
#### [scarf/scarf/Core/Services/HermesFileService.swift](../../scarf/Core/Services/HermesFileService.swift)
Add the YAML reads inside the voice block construction (mirror the elevenlabs / openai shape).
#### [scarf/scarf/Features/Settings/Views/Tabs/VoiceTab.swift](../../scarf/Features/Settings/Views/Tabs/VoiceTab.swift)
Inside the `switch viewModel.config.voice.ttsProvider` (line 19), add a `case "xai":` arm:
```swift
case "xai":
EditableTextField(label: "Voice ID", value: viewModel.config.voice.ttsXAIVoiceID) {
viewModel.setTTSXAIVoiceID($0)
}
EditableTextField(label: "Model", value: viewModel.config.voice.ttsXAIModel) {
viewModel.setTTSXAIModel($0)
}
if capabilitiesStore?.capabilities.hasXAIVoiceCloning == true {
xaiCloningBadge
}
```
Add `@Environment(\.hermesCapabilities) private var capabilitiesStore` at the top.
The badge view, using `ScarfBadge` (kind `.info`):
```swift
@ViewBuilder
private var xaiCloningBadge: some View {
HStack {
Text("")
.frame(width: 160, alignment: .trailing)
ScarfBadge("Cloning supported", kind: .info)
Text("Manage cloned voices in your terminal: `hermes voice` (xAI subcommands).")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
Spacer()
}
.padding(.horizontal, 12)
.padding(.vertical, 4)
}
```
The hint text references `hermes voice` because Scarf doesn't manage cloned voices — Hermes does, and v2.7.5 has no in-app voice-cloning UI. Capture under [Out of scope](#out-of-scope) for follow-up.
### Capability gate
- `xai` in the provider picker: **not gated**. The provider exists pre-v0.13 (TTS only); cloning is the v0.13 add-on. Listing it always means pre-v0.13 users with xAI keys can still pick it.
- Cloning badge: gated on `hasXAIVoiceCloning`. Pre-v0.13: badge hidden, EditableTextField rows still visible.
### Coordination with WS-2
None.
## Files to change (combined)
New:
- `scarf/Packages/ScarfCore/Sources/ScarfCore/Services/HermesUpdaterCommandBuilder.swift` (item 3)
- `scarf/Packages/ScarfCore/Tests/ScarfCoreTests/M0eUpdaterTests.swift` (item 3 tests)
Modified:
- `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/ACPMessages.swift` (item 1: `compressionCount` field)
- `scarf/Packages/ScarfCore/Sources/ScarfCore/ACP/ACPClient.swift` (item 1: decode)
- `scarf/Packages/ScarfCore/Sources/ScarfCore/ViewModels/RichChatViewModel.swift` (item 1: counter + reset + `handlePromptComplete`)
- `scarf/Packages/ScarfCore/Sources/ScarfCore/Models/HermesConfig.swift` (items 5 + 6: `display.language`, xAI voice/model fields)
- `scarf/scarf/Features/Chat/Views/SessionInfoBar.swift` (item 1: chip + props)
- `scarf/scarf/Features/Chat/Views/ChatTranscriptPane.swift` (item 1: pass-through)
- `scarf/scarf/Features/Chat/Views/SlashCommandMenu.swift` (item 2: bracket-aware hint)
- `scarf/scarf/Features/Settings/Views/Tabs/AdvancedTab.swift` (item 4: redaction hint)
- `scarf/scarf/Features/Settings/Views/Tabs/GeneralTab.swift` (item 5: language picker)
- `scarf/scarf/Features/Settings/Views/Tabs/VoiceTab.swift` (item 6: xai case + badge)
- `scarf/scarf/Features/Settings/ViewModels/SettingsViewModel.swift` (items 5 + 6: setters + lists)
- `scarf/scarf/Core/Services/HermesFileService.swift` (items 5 + 6: YAML reads)
- (possibly) `scarf/scarf/Features/Settings/Views/Components/PickerRow.swift` — add a `optionLabel:` overload (item 5, if the existing API doesn't carry one)
That's roughly **3 ScarfCore files + 7 Mac app files + 1 new file + 1 test file = ~12 files**, most edits being a few lines each.
## Capability gating (combined)
| Item | Flag | Behavior on pre-v0.13 |
|------|------|------------------------|
| 1. Compression chip | `hasContextCompressionCount` + `acpCompressionCount > 0` | Chip hidden (counter stays 0) |
| 2. `/new <name>` hint | none — driven by ACP server payload | Hint is whatever pre-v0.13 server sends (probably empty) |
| 3. `--yes` plumbing | `hasUpdateNonInteractive` (used inside the helper) | Helper omits the flag |
| 4. Redaction hint copy | discriminator on any v0.13 flag (use `hasGoals`) | Shows the v0.12 copy |
| 5. Language picker | `hasDisplayLanguage` | Picker row hidden |
| 6. xAI cloning badge | `hasXAIVoiceCloning` | Badge hidden, xai picker option still visible |
Six surfaces, six independent fall-back paths. None of them break the existing layout if every flag returns false.
## How to test
### Unit (ScarfCoreTests)
- `M0eUpdaterTests` — five-case matrix for `HermesUpdaterCommandBuilder.updateArgv` covering every combination listed in item 3.
- Extend `M0dViewModelsTests` with one test that sets `acpCompressionCount = 5` via a mocked `handlePromptComplete` and asserts the value via the public getter; assert `reset()` clears it.
- Extend the existing `ACPMessages` tests (or add one if there isn't one) with: a `usage` blob carrying `"compressionCount": 3` parses into `ACPPromptResult.compressionCount == 3`; same with `"compression_count": 3`; missing key parses as 0.
### UI smoke (manual against real Hermes)
1. **Pre-v0.13 host**: launch Scarf with a Hermes v0.12 binary on PATH. Verify:
- No compression chip in `SessionInfoBar` even after long sessions.
- Settings → General → Locale shows only the Timezone field; no language picker.
- Settings → Advanced → Caching & Redaction shows the v0.12 hint copy.
- Settings → Voice → Text-to-Speech with provider `xai` shows Voice ID + Model fields, **no** "Cloning supported" badge.
2. **v0.13 host**: launch Scarf against the v0.13 dev branch. Verify:
- Long enough chat to trigger compaction → chip appears in `SessionInfoBar` with the count.
- Settings → General → Locale → "Display language" picker visible, switching writes `display.language` in `config.yaml`.
- Settings → Advanced shows the v0.13 hint copy.
- Settings → Voice → xai provider shows the "Cloning supported" badge.
- `/new Foo Bar Baz` from the slash menu starts a session named "Foo Bar Baz" (no Scarf-side validation; Hermes handles it).
- Slash menu shows `/new` with whatever hint v0.13 server sends — bracket-aware renderer doesn't double-wrap if hint is `[name]`.
3. **`HermesUpdaterCommandBuilder` smoke** (no UI): once integrated, write a one-shot script (or a `#Preview`-only call) that prints `updateArgv` for each capability snapshot and pastes the matrix into the PR description.
### Visual / accessibility
- Compression chip uses `ScarfColor.foregroundMuted` — verify in light + dark; ensure contrast ratio ≥ 4.5:1 against `backgroundSecondary`.
- Picker on Locale section honors keyboard navigation (Tab in / Space to open / Arrows / Return / Esc).
- "Cloning supported" badge uses `ScarfBadge(... kind: .info)` — verify color resolves correctly in both modes; not green (that's `.success`), not yellow (that's `.warning`).
## Open questions
**Q1. Wire field name for compression count.** v0.13 release notes say "Show context compression count in status bar" without naming the field. The plan assumes `usage.compressionCount` (or `usage.compression_count`) on the `session/prompt` response. If Hermes instead emits it as a `session/update` notification on a status feed (separate path from `usage`), the plumbing is bigger: `RichChatViewModel.handleStatusUpdate` (or equivalent) needs a new branch, and `ACPClient.startReadLoop` needs a new event type. **Resolution path**: read `~/.hermes/hermes-agent/hermes_cli/acp/server.py` (or wherever the v0.13 status emission lives) before merging. If the field is on a notification, swap items 1's `ACPPromptResult` extension for a new `ACPEvent.compressionCountChanged(sessionId:count:)` case in `ACPMessages.swift` and a corresponding branch in `RichChatViewModel.handleEvent`.
**Q2. xAI TTS config keys.** The plan assumes `tts.xai.voice_id` / `tts.xai.model` mirroring elevenlabs. v0.13 source might use different names (`tts.xai.voice`, `tts.xai.model_id`, or a top-level `tts.xai_voice`). **Resolution path**: grep `~/.hermes/hermes-agent/hermes_cli/voice/tts.py` for the xAI config block before merging. If keys differ, just rename the setter functions and `VoiceSettings` fields — no architectural change.
**Q3. Empty-string vs `"en"` for `display.language` default.** The plan uses an empty string in `DisplaySettings.language` to represent "key absent" and surfaces the picker entry as "English (default)". Whether the picker should *also* offer `en` as a separate explicit value is a UX call. The plan keeps both for now; v2.8.1 can collapse if it's confusing.
**Q4. iOS coverage.** The plan defers iOS for items 1 (compression chip) and 5 (language picker) — iOS doesn't have a `SessionInfoBar` mirror, and iOS Settings is read-mostly. For v2.8 this is acceptable; for v2.9 we should mirror both surfaces in `Scarf iOS/`. Tracking under [Out of scope](#out-of-scope) below.
**Q5. Redaction hint discriminator.** Using `hasGoals` as a stand-in for "is this a v0.13 host" feels indirect. Consider adding a small convenience `var isV013OrLater: Bool { atLeastSemver(0, 13, 0) }` on `HermesCapabilities` so the call site reads more honestly. Trivial change; either lands in WS-1 (preferred — that's the capabilities home) or here. Flag for WS-1 owner.
## Out of scope (deferred)
- **iOS compression chip** — iOS chat header doesn't currently render any token counter; adding the chip there means designing a header bar, not just inserting one element. Track for v2.9.
- **iOS `display.language` picker** — iOS Settings is read-mostly; full pickers wait until iOS Settings becomes a write surface.
- **In-app "Update Hermes" affordance** — a Sparkle-style auto-updater for the Hermes binary, with the `--yes` flag plumbed through. Long-term feature, probably v3.0. The helper added in item 3 paves the runway.
- **`/new <name>` hover tooltip** — extra discoverability for the optional argument. v0.13 server sends the hint via `available_commands_update`; that's enough for v2.8.
- **xAI Custom Voices management UI** — the badge points users at `hermes voice`. Building cloned-voice management in-app is a feature on its own. Track separately.
- **Schema sync to `tools/build-catalog.py`** — none of this WS adds new widget types or template manifest fields, so the catalog validator doesn't need an update. Verify at PR time.
## Estimate
- ScarfCore changes: ~30 LOC across 3 files + 1 new file + 1 test file ≈ **~120 LOC**.
- Mac app changes: ~15-20 LOC per item 1, 4, 5, 6 + 5 LOC for items 2 = **~80 LOC** spread over 7 files.
- Tests: ~80 LOC for `M0eUpdaterTests` + ~40 LOC for compression decode tests = **~120 LOC**.
Total ≈ **300-350 LOC**, ~12 files. Each item is independently revertable and capability-gated. Implementation: 1 dev-day; review + smoke against v0.13 host: 0.5 day. **1.5 dev-days end-to-end.**
Confidence: **high** that items 2 / 3 / 4 / 5 / 6 land cleanly. **Medium** for item 1 (compression chip) — pinned to Q1's wire-field resolution. If Q1 surfaces an event-stream shape rather than a `usage` blob, item 1's plumbing roughly doubles in size but the *view* is unchanged.
+926
View File
@@ -0,0 +1,926 @@
# WS-9 Plan: ScarfGo iOS catch-up (read-only mirrors of WS-2 / WS-3 / WS-4 / WS-5)
**Workstream:** WS-9 of Scarf v2.8.0
**Hermes target:** v0.13.0 (v2026.5.7)
**Capability gates consumed (already shipped in WS-1, PR #80):**
- `HermesCapabilities.hasGoals` (`>= 0.13.0`) — drives the Goal pill
- `HermesCapabilities.hasACPQueue` (`>= 0.13.0`) — read-only queue indicator stub
- `HermesCapabilities.hasKanbanDiagnostics` (`>= 0.13.0`) — diagnostics on the iOS Kanban detail sheet
- `HermesCapabilities.hasCuratorArchive` (`>= 0.13.0`) — Archived list section in the iOS Curator surface
- `HermesCapabilities.hasGoogleChatPlatform` / `hasGatewayAllowlists` / `hasGatewayBusyAckToggle` / `hasGatewayRestartNotification` (`>= 0.13.0`) — Settings → Platforms additions
**Builds on:**
- v2.7.5 iOS Kanban (`Scarf iOS/Kanban/ScarfGoKanbanView.swift`, `ScarfGoKanbanDetailSheet.swift`).
- v2.7.5 iOS Curator (`Scarf iOS/Curator/CuratorView.swift`).
- v2.7.5 iOS Settings (`Scarf iOS/Settings/SettingsView.swift`) including `platformsSection`.
- v2.5+ iOS Chat (`Scarf iOS/Chat/ChatView.swift`) including `projectContextBar` and `transientHint`.
- WS-1 capability flags + the `.hermesCapabilities(_:)` env injection at `ScarfGoTabRoot.swift:153`.
- Phase H precedent: iOS catch-up "parity-match the Mac surfaces but skip mutating CLI verbs."
**Owner:** TBD
**Reviewers:** Alan (always); whoever owns iOS during v2.8 cycle.
**Sequencing:** WS-9 lands AFTER WS-2 / WS-3 / WS-4 / WS-5 merge to main, since it consumes their model fields, view-model state, and capability flags.
---
## Goals (read-only mirrors of WS-2 / WS-3 / WS-4 / WS-5)
WS-9 is iOS-only and **strictly read-only**. It mirrors selected Mac surfaces from earlier work-streams without introducing any iOS-side write verb. Per the v2.8.0 release plan, iOS write surfaces (Verify / Reject buttons, iOS create-task, iOS curator-archive button, iOS allowlist editor, etc.) are deferred to v2.8.x.
User-visible additions (all capability-gated, all degrade silently on pre-v0.13 hosts):
1. **Goal pill in iOS chat.** When `caps.hasGoals == true` AND `controller.vm.activeGoal != nil`, surface a "Goal: <text>" pill at the top of the chat view (mounted next to the existing folder/branch chips in `projectContextBar`). Read-only — no `/goal` slash command on iOS in v2.8.0; no clear affordance.
2. **Read-only `/queue` count chip.** When `caps.hasACPQueue == true` AND `controller.vm.queuedPrompts.count > 0`, surface a small "N queued" chip in the same `projectContextBar`. No popover, no mutation. Tap is a no-op (or shows a sheet listing the previews — see Open Question #2).
3. **Kanban v0.13 diagnostics on iOS detail sheet.** Extend `ScarfGoKanbanDetailSheet` to render `max_retries`, `auto_blocked_reason`, `hallucination_gate_status`, and the diagnostics array. NO Verify / Reject buttons; the hallucination state is rendered as a badge with the copy "Worker-created — verify on Mac" (since iOS can't verify in v2.8.0).
4. **iOS Curator Archived section.** Append a read-only "Archived" section to the existing `Scarf iOS/Curator/CuratorView.swift`. Per-row: name, kind, archived-date, optional reason (sized small for thumb scrolling). NO Restore / Prune-this / Prune-all buttons. Empty-state copy points the user to the Mac app for restore.
5. **iOS Settings v0.13 features-active badge.** When `caps.semver >= 0.13.0`, surface a small read-only "v0.13 features active" `ScarfBadge` at the top of `SettingsView` with a "Learn more" tap action that opens an action sheet listing the new features.
6. **iOS Platforms read-only mirror (extension to existing `platformsSection`).** Add a Google Chat read-only row, a "Restart notifications" yes/no row, a "Busy ack" yes/no row, and a per-platform allowlist chip-row ("3 allowed channels: …, 4 allowed chats: …"). No editing — that's a Mac-only surface in v2.8.0.
### Non-goals (explicitly deferred)
- **iOS write surfaces** (Verify / Reject, Create Task, Archive Skill, Prune, Allowlist editor, `/goal`, `/queue` send) — deferred to v2.8.x. Per Phase H precedent.
- **iOS Curator surface from scratch** — out of scope. iOS already has `CuratorView.swift`; WS-9 only adds the Archived list. (See Open Question #1 for what the user prompt anticipated.)
- **iOS Gateway/Platforms surface from scratch** — out of scope. iOS Settings already has `platformsSection` (lines 280-288 of `SettingsView.swift`); WS-9 extends it. There is **no separate iOS Gateway feature module** today and WS-9 does not add one.
- **iOS goal/queue clear affordance**`/goal --clear` and "Clear all queued" are write verbs; deferred.
- **iOS Kanban verify on tap** — iOS Kanban is read-only and stays read-only in v2.8.0.
- **iOS Curator Run Now blocking + progress (synchronous run)** — that's a write change in scope of WS-4, not WS-9. iOS keeps fire-and-forget `runNow` regardless of v0.13.
---
## Existing iOS surface inventory
(Verified by walking `Scarf iOS/` at plan time.)
| iOS dir | Files | Mac counterpart |
|---|---|---|
| `App/` | `ScarfIOSApp.swift`, `ScarfGoCoordinator.swift`, `ScarfGoTabRoot.swift`, `Theme/` | `scarfApp.swift`, `AppCoordinator.swift`, `SidebarView.swift` |
| `Chat/` | `ChatView.swift`, `ChatContentFormatter.swift`, `ProjectPickerSheet.swift`, `ProjectSlashCommandsBrowser.swift` | `Features/Chat/` |
| `Components/` | `FlowLayout.swift`, `HermesVersionBanner.swift` | (cross-feature shared) |
| `Cron/` | (read-only views) | `Features/Cron/` |
| **`Curator/`** | **`CuratorView.swift` (read-mostly, runNow/pause/resume/pin/unpin/restore wired)** | `Features/Curator/` |
| `Dashboard/` | iOS dashboard views | `Features/Dashboard/` |
| **`Kanban/`** | **`ScarfGoKanbanView.swift`, `ScarfGoKanbanDetailSheet.swift` (5-column horizontal-paged Picker, read-only)** | `Features/Kanban/` |
| `Memory/` | (read-only views) | `Features/Memory/` |
| `Notifications/` | `APNSTokenStore.swift`, `NotificationRouter.swift` | `Core/Services/Notifications*` |
| `Onboarding/` | (first-run wizard) | `Features/Onboarding/` |
| `Plugins/` | `PluginsView.swift` (Phase H read-only) | `Features/Plugins/` |
| `Profiles/` | `ProfilesView.swift` (Phase H read-only) | `Features/Profiles/` |
| `Projects/` | iOS project surfaces (incl. `ProjectDetailView.swift`) | `Features/Projects/` |
| `Servers/` | server-list + connect surfaces | `Features/Servers/` |
| **`Settings/`** | **`SettingsView.swift`, `SettingEditorSheet.swift`, `ScarfMonDiagnosticsView.swift`** | `Features/Settings/` |
| `Skills/` | iOS Skills surface | `Features/Skills/` |
| `Webhooks/` | `WebhooksView.swift` (Phase H read-only) | `Features/Webhooks/` |
**Surfaces that DO NOT exist on iOS today:**
- No standalone `Scarf iOS/Gateway/` or `Scarf iOS/Platforms/` directory. iOS surfaces gateway / platform configuration through `SettingsView.platformsSection`. WS-9 mirror item 6 extends that section; it does NOT spin up a new feature module.
- No iOS goal / queue surface. WS-2 lays the VM-side scaffolding (`activeGoal`, `queuedPrompts` on the shared `RichChatViewModel` in ScarfCore); WS-9 is what surfaces it on iOS.
- No iOS dedicated "What's new in v0.13" feature surface. The "v0.13 features active" badge in mirror item 5 is the only entry point WS-9 adds.
**Capability injection (verified):**
- `ScarfGoTabRoot.swift:52` constructs a `HermesCapabilitiesStore` per server connection.
- `ScarfGoTabRoot.swift:153` calls `.hermesCapabilities(capabilities)` on the tab view.
- All iOS feature views read with `@Environment(\.hermesCapabilities) private var capabilitiesStore` (see `ChatView.swift:30`, `ProjectDetailView.swift:22`, `Components/HermesVersionBanner.swift:14`).
- WS-9 reuses the same env injection — no new plumbing required.
---
## 1. iOS Goal pill (mirror WS-2)
**Source path read.** The goal text lives on `RichChatViewModel.activeGoal: HermesActiveGoal?` (added in WS-2 — see WS-2 plan §3 "Active goal state"). iOS reads the same VM through `ChatController.vm` (the shared ScarfCore VM). No new ScarfCore field is needed; the WS-2 plumbing flows automatically into iOS.
### File: `Scarf iOS/Chat/ChatView.swift`
#### 1a. Read the capability + goal state in `body`
iOS already injects `@Environment(\.hermesCapabilities) private var capabilitiesStore` at line 30. Add a derived flag near the existing `supportsImagePrompts` computed property (lines 44-46):
```swift
private var supportsActiveGoal: Bool {
capabilitiesStore?.capabilities.hasGoals ?? false
}
private var supportsACPQueue: Bool {
capabilitiesStore?.capabilities.hasACPQueue ?? false
}
```
#### 1b. Mount the goal pill alongside the project chip
The `projectContextBar` (lines 832-892) currently renders only when there's an active project. Adding the goal pill INSIDE that bar would mean a pill-less goal can't render in non-project chats. Solution: split the conditional. Render `projectContextBar` when `projectName != nil OR supportsActiveGoal && controller.vm.activeGoal != nil OR supportsACPQueue && !controller.vm.queuedPrompts.isEmpty`. The bar's tinted-strip background works for any of these states.
```swift
@ViewBuilder
private var projectContextBar: some View {
let hasProject = (controller.currentProjectName?.isEmpty == false)
let hasGoal = supportsActiveGoal && controller.vm.activeGoal != nil
let hasQueue = supportsACPQueue && !controller.vm.queuedPrompts.isEmpty
if hasProject || hasGoal || hasQueue {
HStack(spacing: 8) {
if hasProject { /* existing project chip */ }
if hasGoal { goalChip }
if hasQueue { queueChip }
Spacer()
if hasProject && !controller.vm.projectScopedCommands.isEmpty {
/* existing slash-commands chip */
}
}
.padding(.horizontal, 12)
.padding(.vertical, 6)
.frame(maxWidth: .infinity, alignment: .leading)
.background(.tint.opacity(0.1))
}
}
@ViewBuilder
private var goalChip: some View {
if let goal = controller.vm.activeGoal {
Label(truncatedGoalText(goal.text), systemImage: "scope")
.labelStyle(.titleAndIcon)
.font(.subheadline) // semantic — Dynamic Type works
.foregroundStyle(ScarfColor.info)
.padding(.horizontal, 8)
.padding(.vertical, 3)
.background(ScarfColor.info.opacity(0.16), in: Capsule())
.lineLimit(1)
.accessibilityLabel("Goal locked: \(goal.text)")
}
}
private func truncatedGoalText(_ text: String) -> String {
text.count <= 28 ? text : String(text.prefix(25)) + "…"
}
```
**Font choice (per CLAUDE.md iOS rules).** Use semantic `.subheadline` because the goal text IS content (the user reads it to recall what they locked the agent on). Per CLAUDE.md "Decision tree per text element: 'is this read for content?' → semantic token. 'Is this chrome / a label / a badge?' → ScarfFont." If the design review pushes back and prefers a fixed-display chip look, switch the inner `Text` to `ScarfFont.captionStrong`; the surrounding pill chrome stays the same.
**Color choice.** `ScarfColor.info` matches Mac's WS-2 plan (informational state, not warning, not error). Keeps the pill visually distinct from the green "success" branch chip and the orange tinted-strip background of `projectContextBar`.
**Truncation.** 25-char prefix matches the iPhone 14 portrait width budget for a chip beside a project name. The full goal text is in the accessibility label (VoiceOver users get the full string).
#### 1c. NO clear affordance
iOS does not get a "Clear goal" gesture in v2.8.0. The pill is purely informational. Tapping is a no-op. Users running `/goal --clear` from the Mac will see the iOS pill drop on the next polled state refresh (or whenever `controller.vm.activeGoal` updates — most likely on the next ACP event).
---
## 2. iOS Kanban v0.13 diagnostics (mirror WS-3)
**Source paths read.** All four new fields land on `HermesKanbanTask` (WS-3 plan §1):
- `task.maxRetries: Int?`
- `task.autoBlockedReason: String?`
- `task.hallucinationGateStatus: String?` → wrap in `KanbanHallucinationGate.from(_:)`
- `task.diagnostics: [HermesKanbanDiagnostic]`
The per-run shape adds `run.diagnostics: [HermesKanbanDiagnostic]` (WS-3 plan §3). The typed-mirror enums `KanbanHallucinationGate` and `KanbanDiagnosticKind` are added in ScarfCore and consumable from iOS by `import ScarfCore`.
### File: `Scarf iOS/Kanban/ScarfGoKanbanDetailSheet.swift`
#### 2a. Capability gate
Add `@Environment(\.hermesCapabilities) private var capabilitiesStore` at the top of the struct alongside the existing state (line ~17). Compute once in `body`:
```swift
private var diagnosticsAvailable: Bool {
capabilitiesStore?.capabilities.hasKanbanDiagnostics ?? false
}
```
Defensive default to `false` so a missing capability store (preview, smoke test) renders the v2.7.5 sheet unchanged.
#### 2b. Header chip row — add `max_retries` chip
Update `headerCard(_:)` (lines 91-111). Insert between the workspace-kind badge and the tenant badge, gated on `diagnosticsAvailable`:
```swift
if diagnosticsAvailable, let maxRetries = task.maxRetries {
ScarfBadge("retries: \(maxRetries)", kind: .neutral)
.accessibilityLabel("Max retries \(maxRetries)")
}
```
Tooltip on iOS is the accessibility label (no hover). No tap action; this is purely informational.
#### 2c. Header chip row — add hallucination-gate badge
Below the existing badge row, insert a NEW row when `KanbanHallucinationGate.from(task.hallucinationGateStatus) == .pending`:
```swift
if diagnosticsAvailable,
KanbanHallucinationGate.from(task.hallucinationGateStatus) == .pending {
HStack(spacing: 6) {
Image(systemName: "questionmark.diamond.fill")
.foregroundStyle(ScarfColor.warning)
Text("Worker-created — verify on Mac")
.font(.subheadline) // semantic content text
.foregroundStyle(ScarfColor.warning)
}
.padding(.horizontal, 10)
.padding(.vertical, 6)
.background(ScarfColor.warning.opacity(0.10), in: RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.strokeBorder(ScarfColor.warning.opacity(0.4), lineWidth: 1)
)
.accessibilityHint("Open this task on the Mac app to verify or reject the worker's claim.")
}
```
**Copy choice.** "Worker-created — verify on Mac" is intentional: it surfaces the gate status AND tells the user where the action lives. This is the read-only iOS substitute for Mac's Verify / Reject buttons (which require write CLI verbs deferred to v2.8.x).
**Render order.** Hallucination badge sits BELOW the chip row but ABOVE the markdown body, so users see the worker-created flag before reading the (potentially hallucinated) body content.
#### 2d. Auto-blocked banner
In `headerCard` after the priority line, when status is `blocked` AND `task.autoBlockedReason` is non-empty:
```swift
if diagnosticsAvailable,
KanbanStatus.from(task.status) == .blocked,
let reason = task.autoBlockedReason, !reason.isEmpty {
HStack(alignment: .top, spacing: 8) {
Image(systemName: "exclamationmark.octagon.fill")
.foregroundStyle(ScarfColor.danger)
VStack(alignment: .leading, spacing: 2) {
Text("Auto-blocked")
.font(.subheadline.weight(.semibold))
.foregroundStyle(ScarfColor.danger)
Text(reason)
.font(.subheadline) // semantic — server-supplied verbatim
.foregroundStyle(.secondary)
}
}
.padding(10)
.background(ScarfColor.danger.opacity(0.08), in: RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous))
}
```
#### 2e. Task-level diagnostics block
After the markdown body block (before the Picker tab selector), render the task-level diagnostics list when non-empty:
```swift
if diagnosticsAvailable, !detail.task.diagnostics.isEmpty {
diagnosticsBlock(detail.task.diagnostics, label: "Diagnostics")
}
```
Helper:
```swift
@ViewBuilder
private func diagnosticsBlock(_ diags: [HermesKanbanDiagnostic], label: String) -> some View {
VStack(alignment: .leading, spacing: 6) {
Text(label)
.font(.caption.weight(.semibold))
.foregroundStyle(.secondary)
FlowLayout(spacing: 6) { // existing primitive at Scarf iOS/Components/FlowLayout.swift
ForEach(diags) { diag in
let kind = KanbanDiagnosticKind.from(diag.kind)
ScarfBadge(diag.kind, kind: kind.badgeKind)
.accessibilityLabel(diag.message ?? diag.kind)
}
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}
```
Tap-on-badge → an expandable detail sheet that shows kind + message + timestamp. iPhone-friendly substitute for the Mac `.help()` tooltip:
```swift
ScarfBadge(diag.kind, kind: kind.badgeKind)
.onTapGesture { selectedDiagnostic = diag }
```
Sheet binding: `.sheet(item: $selectedDiagnostic) { DiagnosticDetailSheet(diagnostic: $0) }`. The detail sheet is a simple `NavigationStack` with name + message + ISO timestamp + a "Done" toolbar button. Lightweight (~30 lines).
`HermesKanbanDiagnostic` is `Identifiable` (per WS-3 plan §2 — synthetic UUID).
#### 2f. Per-run diagnostics in the Runs tab
Update `runsSection` (lines 167-204). Inside each run row, after the optional error text, append a diagnostics block when present:
```swift
if diagnosticsAvailable, !run.diagnostics.isEmpty {
diagnosticsBlock(run.diagnostics, label: "Run diagnostics")
.padding(.top, 4)
}
```
Same `diagnosticsBlock` helper.
#### 2g. NO write actions
Per WS-9 contract, iOS does not expose Verify / Reject. The hallucination badge in §2c is informational. Mac's `KanbanInspectorPane.healthBanner.hallucinationBanner` (WS-3 plan §8b) wires Verify/Reject buttons; iOS does not.
---
## 3. iOS Curator Archived list (mirror WS-4) — IF iOS Curator exists
**Confirmed:** iOS Curator surface exists at `Scarf iOS/Curator/CuratorView.swift` (read-mostly, with runNow / pause / resume / pin / unpin actions). **In scope.**
**Source paths read.** WS-4 introduces:
- `HermesCuratorArchivedSkill` model (WS-4 plan "New types / fields")
- `CuratorService.listArchived() async throws -> [HermesCuratorArchivedSkill]` (WS-4 plan §"New files")
- `CuratorViewModel.archivedSkills: [HermesCuratorArchivedSkill]` and `loadArchive() async` (WS-4 plan §"Edited files / CuratorViewModel")
The shared `CuratorViewModel` lives in ScarfCore — iOS reuses it directly. The iOS `CuratorView` already constructs it at line 18. No iOS-side ScarfCore changes required.
### File: `Scarf iOS/Curator/CuratorView.swift`
#### 3a. Capability gate
Add `@Environment(\.hermesCapabilities) private var capabilitiesStore` at the top of the struct. Compute once in `body`:
```swift
private var archiveAvailable: Bool {
capabilitiesStore?.capabilities.hasCuratorArchive ?? false
}
```
#### 3b. Wire `loadArchive()` into the existing `.task`
Update the existing `.task { await viewModel.load() }` (line 92) to also load the archive when capability allows:
```swift
.task {
await viewModel.load()
if archiveAvailable {
await viewModel.loadArchive()
}
}
.refreshable {
await viewModel.load()
if archiveAvailable {
await viewModel.loadArchive()
}
}
```
#### 3c. Add the Archived section
After the "Last report" section (lines 74-80) and before the trailing modifiers, render the new section gated on `archiveAvailable`:
```swift
if archiveAvailable {
archivedSection
}
```
Helper:
```swift
@ViewBuilder
private var archivedSection: some View {
Section {
if viewModel.archivedSkills.isEmpty {
Text("No archived skills — Curator will move stale skills here after the next review cycle.")
.font(.callout)
.foregroundStyle(.secondary)
} else {
ForEach(viewModel.archivedSkills) { skill in
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(skill.name)
.font(.body) // semantic — content
.lineLimit(1)
Spacer()
if let category = skill.category, !category.isEmpty {
ScarfBadge(category, kind: .neutral)
}
}
HStack(spacing: 6) {
if let reason = skill.reason, !reason.isEmpty {
Text(reason)
.font(.caption) // semantic — content
.foregroundStyle(.secondary)
.lineLimit(2)
}
Spacer()
Text(skill.archivedAtLabel)
.font(.caption2)
.foregroundStyle(.tertiary)
}
if let size = skill.sizeBytes, size > 0 {
Text(skill.sizeLabel)
.font(.caption2)
.foregroundStyle(.tertiary)
}
}
}
}
} header: {
Text("Archived")
} footer: {
if !viewModel.archivedSkills.isEmpty {
Text("Restore or prune archived skills from the Mac app.")
.font(.caption)
}
}
}
```
**Copy.** Empty-state mirrors Mac's empty-state copy so the wiki / docs only need one phrasing. The "Restore or prune from the Mac app" footer is the read-only signpost.
**Font choice.** Skill name + reason → semantic `.body` / `.caption` (read for content). Category badge stays `ScarfBadge` (chrome). Date and size → `.caption2` (chrome metadata).
#### 3d. NO write actions
No per-row Restore button (WS-4 Mac surface adds this — iOS does not). No Prune All. The `CuratorRestoreSheet` Mac fallback for v0.12 hosts does NOT have an iOS counterpart and WS-9 does not introduce one. iOS users wanting to restore an archived skill use the Mac app — that's documented in the section footer.
---
## 4. iOS Gateway / Platforms read-only mirror (mirror WS-5) — extending existing iOS Settings → Platforms
**Investigation result:** iOS does NOT have a separate `Gateway/` or `Platforms/` directory. Gateway / platform configuration is surfaced through `SettingsView.platformsSection` (lines 280-288). WS-9 extends this section rather than spinning up a new feature module.
**Caveat.** WS-5's plan markdown does not yet exist at `scarf/docs/v2.8/WS-5-gateway-v0.13-plan.md` (verified — the dir contains WS-2/3/4/6/7/8 only). The Mac-side WS-5 plan is forthcoming. WS-9 is forced to make best-inference assumptions about the Mac-side model field names. The capability flags themselves DO exist (`hasGoogleChatPlatform`, `hasGatewayAllowlists`, `hasGatewayBusyAckToggle`, `hasGatewayRestartNotification`, `hasGatewayList`) and the surface contract per the user prompt is:
- Show Google Chat as a new platform entry (read-only)
- Show allowlists as read-only chip-rows ("3 allowed channels: ..., 4 allowed chats: ...")
- Show platform-specific toggles as read-only state badges ("Restart notifications: ON", "Busy ack: OFF")
WS-9 mirrors that contract. Concrete model fields are flagged in Open Questions §3 below — the implementer should sync with the WS-5 author before merging.
### File: `Scarf iOS/Settings/SettingsView.swift`
#### 4a. Capability gate
Add the env-injected capability store (it's not currently read in `SettingsView`):
```swift
@Environment(\.hermesCapabilities) private var capabilitiesStore
private var caps: HermesCapabilities {
capabilitiesStore?.capabilities ?? .empty
}
```
#### 4b. Extend `platformsSection`
The current section (lines 280-288) renders five rows: Discord require-mention, Discord auto-thread, Telegram require-mention, Slack reply-to-mode, Matrix require-mention. WS-9 appends:
```swift
@ViewBuilder
private var platformsSection: some View {
Section("Platforms") {
// Existing rows (lines 282-286) — UNCHANGED.
yesNoRow("Discord: require mention", vm.config.discord.requireMention)
yesNoRow("Discord: auto-thread", vm.config.discord.autoThread)
yesNoRow("Telegram: require mention", vm.config.telegram.requireMention)
LabeledContent("Slack: reply mode", value: vm.config.slack.replyToMode)
yesNoRow("Matrix: require mention", vm.config.matrix.requireMention)
// v0.13 additions (gated).
if caps.hasGoogleChatPlatform {
googleChatSubsection
}
if caps.hasGatewayBusyAckToggle {
yesNoRow("Gateway: busy ack", vm.config.gateway.busyAckEnabled)
}
if caps.hasGatewayRestartNotification {
yesNoRow("Gateway: restart notification", vm.config.gateway.restartNotificationEnabled)
}
if caps.hasGatewayAllowlists {
allowlistsSubsection
}
}
}
```
**Field-name caveat.** The exact field names on `HermesConfig.gateway.*` and `HermesConfig.googleChat.*` are TBD by WS-5. Provisional field names used above (`busyAckEnabled`, `restartNotificationEnabled`, `googleChat.requireMention`, etc.) MUST be aligned with the WS-5 model definitions before this code lands. See Open Questions §3.
#### 4c. Google Chat subsection
```swift
@ViewBuilder
private var googleChatSubsection: some View {
yesNoRow("Google Chat: require mention", vm.config.googleChat.requireMention)
if let space = vm.config.googleChat.defaultSpace, !space.isEmpty {
LabeledContent("Google Chat: default space", value: space)
}
}
```
#### 4d. Allowlists subsection — chip-row summaries
Read-only, summarized counts. Per the user prompt: "3 allowed channels: …, 4 allowed chats: …". On iOS the summary is collapsed (full lists are wide and a SwiftUI `List` row is narrow). Shape:
```swift
@ViewBuilder
private var allowlistsSubsection: some View {
if let channels = vm.config.gateway.allowedChannels, !channels.isEmpty {
DisclosureGroup {
ForEach(channels, id: \.self) { ch in
Text(ch)
.font(.callout.monospaced())
.foregroundStyle(.secondary)
.lineLimit(1)
}
} label: {
LabeledContent("Allowed channels") {
Text("\(channels.count)")
.font(.callout)
.foregroundStyle(.secondary)
}
}
}
if let chats = vm.config.gateway.allowedChats, !chats.isEmpty {
DisclosureGroup {
ForEach(chats, id: \.self) { chat in
Text(chat)
.font(.callout.monospaced())
.foregroundStyle(.secondary)
.lineLimit(1)
}
} label: {
LabeledContent("Allowed chats") {
Text("\(chats.count)")
.font(.callout)
.foregroundStyle(.secondary)
}
}
}
}
```
**UI choice.** `DisclosureGroup` with the count in the label collapses well on iPhone (default-collapsed; the user can tap to expand). Avoids a wall-of-text in a small-screen list. No tap-to-edit (read-only).
#### 4e. NO write actions on iOS Platforms
No editor sheet for Google Chat. No allowlist editor. No toggle switches that send `hermes config set`. The existing `quickEditsSection` (lines 84-117) does drive `setSetting(key, value)` for "v1Editable" specs — WS-9 does NOT add the v0.13 platform fields to `SettingSpec.v1Editable`. That's a Mac-only concern in v2.8.0.
---
## 5. iOS v0.13 features-active badge (Settings)
### File: `Scarf iOS/Settings/SettingsView.swift`
#### 5a. Capability check — semver, not a single flag
Per the prompt: "Capability-gate on `caps.semver >= 0.13.0`." The `HermesCapabilities` struct (verified at `Packages/ScarfCore/Sources/ScarfCore/Services/HermesCapabilities.swift`) exposes `atLeastSemver(_:_:_:)` — a private helper. The simplest public hook is to use any one of the v0.13-gated flags as the proxy (e.g. `caps.hasGoals`) since they all resolve to the same `>= 0.13.0` threshold; or expose a new `public var isV013OrLater: Bool` on `HermesCapabilities`. Recommend the latter for clarity:
> **Coordination requirement.** WS-9 needs `HermesCapabilities.isV013OrLater: Bool { atLeastSemver(0, 13, 0) }`. If WS-1 didn't ship this, WS-9 adds it as a one-line addition to `HermesCapabilities.swift`. Cheap and keeps the badge gating honest. Alternative: piggy-back on `caps.hasGoals` and accept the semantic drift (the badge says "v0.13 features active" but is gated on the goals flag specifically). Recommend the new helper.
#### 5b. Mount the badge above `quickEditsSection`
```swift
var body: some View {
List {
if let err = vm.lastError { /* unchanged */ }
if caps.isV013OrLater {
v013ActiveBadgeSection
}
if !vm.isLoading || vm.config.model != "unknown" {
quickEditsSection
// ... rest unchanged
}
}
// ... unchanged modifiers
}
@ViewBuilder
private var v013ActiveBadgeSection: some View {
Section {
Button {
showV013FeaturesSheet = true
} label: {
HStack(spacing: 8) {
ScarfBadge("v0.13 features active", kind: .success)
Spacer()
Text("Learn more")
.font(.caption)
.foregroundStyle(.tint)
Image(systemName: "chevron.right")
.font(.caption)
.foregroundStyle(.tertiary)
}
}
.buttonStyle(.plain)
}
.listRowBackground(ScarfColor.success.opacity(0.06))
}
```
**State.** Add `@State private var showV013FeaturesSheet = false` near the top.
**Color.** `.success` (green) — the host has new capabilities, framing as positive. Distinct from the warning-tinted error banner above it.
#### 5c. "Learn more" sheet
```swift
.sheet(isPresented: $showV013FeaturesSheet) {
V013FeaturesSheet()
}
```
New file `Scarf iOS/Settings/V013FeaturesSheet.swift` (~80 lines):
```swift
import SwiftUI
import ScarfDesign
struct V013FeaturesSheet: View {
@Environment(\.dismiss) private var dismiss
var body: some View {
NavigationStack {
List {
Section {
featureRow(
icon: "scope",
title: "Persistent goals",
description: "Type /goal <text> in chat to lock the agent on a target across turns. Mac only in v2.8."
)
featureRow(
icon: "tray.full",
title: "ACP /queue",
description: "Queue prompts to run after the current turn finishes. Mac only in v2.8."
)
featureRow(
icon: "stethoscope",
title: "Kanban diagnostics",
description: "Worker distress signals (heartbeat stalls, retry caps, zombies) surface on the task detail."
)
featureRow(
icon: "questionmark.diamond.fill",
title: "Hallucination gate",
description: "Worker-created cards are flagged for verify/reject. Verify on the Mac app."
)
featureRow(
icon: "archivebox",
title: "Curator archive",
description: "Stale skills move to an Archived list. Restore or prune from the Mac app."
)
featureRow(
icon: "bubble.left.and.bubble.right",
title: "Google Chat platform",
description: "New gateway target — configure on the Mac app."
)
} header: {
Text("What's new in v0.13")
} footer: {
Text("This iOS release surfaces v0.13 features read-only. Editing lives in the Mac app for v2.8.")
.font(.caption)
}
}
.navigationTitle("v0.13 features")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Done") { dismiss() }
}
}
}
}
private func featureRow(icon: String, title: String, description: String) -> some View {
HStack(alignment: .top, spacing: 12) {
Image(systemName: icon)
.foregroundStyle(.tint)
.font(.title3)
.frame(width: 28)
VStack(alignment: .leading, spacing: 4) {
Text(title).font(.body.weight(.semibold))
Text(description)
.font(.callout)
.foregroundStyle(.secondary)
}
}
.padding(.vertical, 4)
}
}
```
**Copy is the load-bearing piece.** Each row is one sentence; the read-only-on-iOS framing is in the section footer. No deep links to the relevant tab — that's a v2.8.x polish, not WS-9.
---
## Coordination with WS-2 / WS-3 / WS-4 / WS-5
WS-9 consumes models / fields / capability flags from earlier work-streams. **WS-9 must land AFTER all of them merge to main.**
| Consumed surface | Source WS | Consumed at |
|---|---|---|
| `HermesActiveGoal` model | WS-2 | iOS goal pill (§1) |
| `HermesQueuedPrompt` model | WS-2 | iOS queue chip (§1, no popover) |
| `RichChatViewModel.activeGoal` observable | WS-2 | iOS goal pill (§1) |
| `RichChatViewModel.queuedPrompts` observable | WS-2 | iOS queue chip (§1) |
| `HermesCapabilities.hasGoals` | WS-1 | iOS chat (§1) |
| `HermesCapabilities.hasACPQueue` | WS-1 | iOS chat (§1) |
| `HermesKanbanTask.maxRetries` | WS-3 | iOS Kanban detail (§2b) |
| `HermesKanbanTask.autoBlockedReason` | WS-3 | iOS Kanban detail (§2d) |
| `HermesKanbanTask.hallucinationGateStatus` + `KanbanHallucinationGate` | WS-3 | iOS Kanban detail (§2c) |
| `HermesKanbanTask.diagnostics` + `HermesKanbanDiagnostic` + `KanbanDiagnosticKind` | WS-3 | iOS Kanban detail (§2e–§2f) |
| `HermesKanbanRun.diagnostics` | WS-3 | iOS Kanban detail (§2f) |
| `HermesCapabilities.hasKanbanDiagnostics` | WS-1 | iOS Kanban detail (§2a) |
| `HermesCuratorArchivedSkill` model | WS-4 | iOS Curator (§3) |
| `CuratorViewModel.archivedSkills` + `loadArchive()` | WS-4 | iOS Curator (§3) |
| `CuratorService.listArchived()` | WS-4 | (transitively via VM in §3) |
| `HermesCapabilities.hasCuratorArchive` | WS-1 | iOS Curator (§3) |
| `HermesConfig.gateway.allowedChannels` / `.allowedChats` (TBD field names) | WS-5 | iOS Settings (§4d) |
| `HermesConfig.gateway.busyAckEnabled` / `.restartNotificationEnabled` (TBD) | WS-5 | iOS Settings (§4b–§4c) |
| `HermesConfig.googleChat.*` (TBD shape) | WS-5 | iOS Settings (§4c) |
| `HermesCapabilities.hasGoogleChatPlatform` / `.hasGatewayAllowlists` / `.hasGatewayBusyAckToggle` / `.hasGatewayRestartNotification` | WS-1 | iOS Settings (§4) |
| `HermesCapabilities.isV013OrLater` (NEW — see §5a) | WS-1 (small follow-up) | iOS Settings badge (§5) |
### Sequencing (recommended)
1. WS-2 (Goals + queue VM scaffolding) merges → iOS chat goal pill becomes wireable.
2. WS-3 (Kanban diagnostics models) merges → iOS Kanban detail extension becomes wireable.
3. WS-4 (Curator archive service + VM state) merges → iOS Curator section becomes wireable.
4. WS-5 (Gateway / Platforms config models + capability flags consumed) merges → iOS Settings extension becomes wireable.
5. WS-9 PR opens, builds against the merged baseline, ships all five additions in one PR.
Splitting WS-9 into per-mirror PRs is overkill — each diff is small, all gated, all read-only.
### Acceptable to land WS-9 in stages
If WS-5 slips, WS-9 can ship items 1-3-4-5 first (the WS-2/3/4 mirrors plus the badge) and follow up with item 6 (Gateway/Platforms mirror) once WS-5 lands. The badge is independent of any mirror item — it can ship the moment WS-1 capability flags are in (already done).
---
## Files to change / create
| File | Status | Purpose |
|---|---|---|
| `Scarf iOS/Chat/ChatView.swift` | EDIT | Goal pill + queue chip in `projectContextBar` (§1) |
| `Scarf iOS/Kanban/ScarfGoKanbanDetailSheet.swift` | EDIT | Diagnostics + max_retries + hallucination badge + auto-blocked banner (§2) |
| `Scarf iOS/Kanban/DiagnosticDetailSheet.swift` | NEW | Tap-target sheet showing one diagnostic's full message + timestamp (§2e) |
| `Scarf iOS/Curator/CuratorView.swift` | EDIT | Archived section + capability gate + extra `.task` load (§3) |
| `Scarf iOS/Settings/SettingsView.swift` | EDIT | v0.13 badge section + Platforms section extension (§4, §5) |
| `Scarf iOS/Settings/V013FeaturesSheet.swift` | NEW | "Learn more" sheet for the v0.13-features badge (§5c) |
| `Packages/ScarfCore/Sources/ScarfCore/Services/HermesCapabilities.swift` | EDIT (1 line) | `public var isV013OrLater: Bool` helper if not already present (§5a) |
**Total:** 7 files (2 new), ~350-450 lines. ~80% of the diff is the new sheets and the iOS Kanban detail extension.
---
## Capability gating
Every WS-9 surface is hard-gated. Pre-v0.13 hosts see the v2.7.5 iOS surface unchanged.
| Surface | Gate | Pre-v0.13 behaviour |
|---|---|---|
| iOS goal pill | `caps.hasGoals && vm.activeGoal != nil` | hidden (transitive impossibility — pill goes nil because Mac doesn't write it) |
| iOS queue chip | `caps.hasACPQueue && !vm.queuedPrompts.isEmpty` | hidden |
| iOS Kanban max_retries chip | `caps.hasKanbanDiagnostics && task.maxRetries != nil` | hidden (`if let` belt-and-suspenders even if cap leaks) |
| iOS Kanban hallucination badge | `caps.hasKanbanDiagnostics && KanbanHallucinationGate.from(...) == .pending` | hidden |
| iOS Kanban auto-blocked banner | `caps.hasKanbanDiagnostics && status == .blocked && reason != nil` | hidden |
| iOS Kanban diagnostics blocks (task + run) | `caps.hasKanbanDiagnostics && !diagnostics.isEmpty` | hidden |
| iOS Curator Archived section | `caps.hasCuratorArchive` | section absent; `loadArchive()` not invoked |
| iOS Settings v0.13 badge | `caps.isV013OrLater` | section absent |
| iOS Settings Google Chat row | `caps.hasGoogleChatPlatform` | row absent |
| iOS Settings Busy ack row | `caps.hasGatewayBusyAckToggle` | row absent |
| iOS Settings Restart notification row | `caps.hasGatewayRestartNotification` | row absent |
| iOS Settings Allowlists rows | `caps.hasGatewayAllowlists` | rows absent |
**Defensive default.** Every `capabilitiesStore?.capabilities ?? .empty` resolves the absent-store case to `false` for every flag. WS-1's `.empty` static is the explicit pre-v0.13 sentinel (verified — used elsewhere in iOS already at `HermesVersionBanner.swift:14`).
**No new capability flags.** WS-9 adds at most one helper (`isV013OrLater`) to `HermesCapabilities`. All other flags are already shipped by WS-1.
---
## How to test
Per CLAUDE.md "remote-servers dogfooding" memory: dogfood against the Mardon Mac Mini at 192.168.0.82 (running the v0.13 binary on the `remote-servers` branch).
### iOS simulator scenarios — v0.13 host
1. **Goal pill**
- Open the iOS chat against a v0.13 host. Switch to the Mac, run `/goal finish v2.8 by Friday` in the same session. Switch back to iOS — within 2-3 polled state refreshes the pill should appear in `projectContextBar` with truncated text "finish v2.8 by Friday".
- VoiceOver: focus the pill, confirm full text reads as "Goal locked: finish v2.8 by Friday".
- Run `/goal --clear` from Mac. Confirm pill drops on iOS.
- Without an active project (chat without `projectContextBar` triggered today), confirm the bar STILL shows when the goal pill is the only chip — i.e. the bar is no longer project-only. Without a goal AND without a project, confirm the bar stays hidden.
2. **Queue chip**
- Trigger a long-running prompt on Mac, send `/queue summarize` while it's working. Confirm iOS shows "1 queued" chip in the bar.
- When the Mac turn finishes and the queued prompt fires, confirm the iOS chip count decrements.
3. **Kanban diagnostics**
- Open the iOS Kanban detail sheet for a task with `max_retries: 3`. Confirm the "retries: 3" chip shows in the header.
- Open a task in `pending` hallucination state. Confirm the yellow "Worker-created — verify on Mac" badge appears below the chip row.
- Open a blocked task with `auto_blocked_reason`. Confirm the red "Auto-blocked" banner shows the reason verbatim.
- Open a task with task-level diagnostics. Confirm the chip-list renders. Tap one — confirm the detail sheet opens with kind + message + timestamp.
- Open a task whose latest run has `darwin_zombie_detected`. Confirm the per-run diagnostics chip-list renders inside the Runs tab row.
4. **Curator Archived list**
- On v0.13 host with no archives: confirm Archived section renders with empty-state copy.
- On v0.13 host with 3 archives: confirm rows show name, category badge, reason, archived-at label, size. No Restore button. Footer hint visible.
- Pull-to-refresh: confirm `loadArchive()` re-fires.
5. **iOS Settings v0.13 badge**
- On v0.13 host: confirm the green "v0.13 features active" badge sits above the Quick edits section. Tap "Learn more" — confirm the sheet opens with 6 feature rows.
- Tap Done — confirm dismissal.
6. **iOS Settings Platforms additions**
- On v0.13 host with Google Chat configured: confirm the Google Chat rows show. Tap is read-only (no nav).
- With at least 3 allowed channels and 4 allowed chats configured: confirm both DisclosureGroup rows show with the correct counts. Expand each — confirm the entries render in monospaced font.
- With Busy ack OFF and Restart notifications ON: confirm both rows show the right yes/no labels.
### iOS simulator scenarios — pre-v0.13 host (regression smoke)
1. Connect to a Hermes v0.12 host (Mardon downgrade or local dev install).
2. Verify:
- `projectContextBar` looks unchanged from v2.7.5 (no goal pill, no queue chip).
- Kanban detail sheet: no max_retries chip, no hallucination badge, no auto-blocked banner, no diagnostics blocks. v2.7.5 layout intact.
- Curator: no Archived section. Existing `runNow` / `pause` / `resume` / `pin` actions work.
- Settings: no v0.13 badge. Platforms section shows the 5 v2.7.5 rows only.
3. Tap through every existing iOS surface to confirm no regressions.
### Dynamic Type accessibility smoke
Per CLAUDE.md: iOS clamps Dynamic Type at the scene root (`ScarfIOSApp.swift`: `.dynamicTypeSize(.xSmall ... .accessibility2)`). Verify at both extremes:
1. Settings → Accessibility → Display & Text Size → set to AX2.
2. Open chat: confirm goal pill text scales (semantic `.subheadline` should). Confirm pill chrome doesn't blow out — the truncation kicks in.
3. Open Kanban detail: confirm body text + diagnostics chip text scale. Badges (`ScarfBadge`) should NOT scale (they're chrome).
4. Open Curator Archived list: confirm skill name + reason scale. Archived-at label stays small.
5. Open Settings v0.13 sheet: confirm description text scales.
6. Switch to xSmall: confirm nothing collapses in a way that's unreadable.
### Build + test gates
- `xcodebuild -project scarf/scarf.xcodeproj -scheme "scarf mobile" -destination 'platform=iOS Simulator,name=iPhone 15' build` must succeed.
- All existing iOS UI smoke tests (if present in the target) stay green.
- New iOS-side snapshot or UI tests are NOT planned for WS-9 — the surfaces are read-only and visual; manual verification is the right pass for v2.8.0.
---
## Open questions
1. **Does iOS Curator surface exist today?** ✅ Confirmed yes. `Scarf iOS/Curator/CuratorView.swift` exists and is read-mostly with runNow / pause / resume / pin / unpin actions. WS-9 mirror item 4 (Curator Archived list) is in scope. (The user prompt anticipated this might be unknown.)
2. **iOS goal/queue chip — is the queue chip tap a no-op or does it open a previews sheet?** Recommend tap = no-op for v2.8.0 (read-only badge, mirroring the goal pill's no-op tap). A previews sheet is nice-to-have but doesn't cross the bar for v2.8 — the user can see queued prompts from the Mac app. If review pushes back, a 30-line sheet listing previews + queued-at timestamps is cheap to add.
3. **WS-5 plan does not yet exist (`scarf/docs/v2.8/WS-5-gateway-v0.13-plan.md` is missing).** The exact `HermesConfig.gateway.*` and `HermesConfig.googleChat.*` field names are TBD. **Action:** before WS-9 implementation starts, sync with the WS-5 author to align on:
- Where do the allowlists live? `HermesConfig.gateway.allowedChannels: [String]?` or `HermesConfig.platforms.<each>.allowedChannels`?
- Are restart-notifications and busy-ack global (one toggle) or per-platform (one per Discord/Slack/Telegram/Matrix/Google-Chat)?
- Is "busy ack" the right wire name? Hermes might call it `busy_acknowledge` or `busy_indicator`.
- Does Google Chat use the same `requireMention` shape as Discord/Telegram/Matrix?
WS-9's Settings extensions (§4) are correct in shape but need the field-name patches once WS-5 confirms. The capability flags are stable.
4. **`HermesCapabilities.isV013OrLater` helper.** WS-1 may or may not have shipped this. If not, WS-9 ships a one-line addition. If `caps.hasGoals` is acceptable as a proxy (since all v0.13 flags resolve to the same threshold), the helper isn't strictly needed — but the badge copy says "v0.13 features active" so semantic alignment matters. Coordinator should pick one.
5. **`projectContextBar` re-render frequency.** Today it renders only when there's a project. After WS-9, it renders when there's a project OR a goal OR a queued prompt. The added re-render churn during streaming (every diff to `vm.activeGoal` / `vm.queuedPrompts`) may matter for ScarfMon's `chatRender` budget. **Action:** add a ScarfMon counter to the bar's body to measure during dogfooding. If churn becomes a hot-path issue, extract `goalChip` and `queueChip` into separately-scoped subviews so they re-render in isolation.
6. **Animation on pill / chip appearance.** Should the goal pill fade in when `vm.activeGoal` becomes non-nil? Recommend yes — `.transition(.opacity.combined(with: .scale(scale: 0.9)))` with a `.spring(response: 0.3, dampingFraction: 0.7)` parent animation. Keeps the bar from feeling like it pops. Apply same to the queue chip and the Kanban hallucination badge.
7. **Tap target for the Kanban hallucination badge.** Currently planned as informational-only. Should tapping it open an alert with explanation copy + a "Open in Mac app" placeholder action? Recommend NO for v2.8.0 — the on-screen "verify on Mac" copy is enough; an alert is unnecessary friction for a read-only surface.
8. **iOS deep links from the v0.13 features sheet.** Tapping a feature row could deep-link to the relevant tab (e.g. tap "Hallucination gate" → switch to Kanban tab). Recommend defer — the v2.8.0 sheet is text-only. v2.8.x can add the routing.
---
## Out of scope (deferred to v2.8.x or later)
- **iOS write surfaces** for everything WS-9 mirrors:
- `/goal` and `/queue` send from iOS chat composer.
- Verify / Reject buttons on the iOS Kanban detail sheet.
- Archive / Restore / Prune on the iOS Curator surface.
- Allowlist editor / platform toggle editor in iOS Settings.
- **Gateway/Platforms iOS feature module from scratch** (separate `Scarf iOS/Gateway/` or `Scarf iOS/Platforms/` dir). v2.8.0 keeps gateway/platform config as an extension to `SettingsView.platformsSection`.
- **iOS Curator Archive `live` updates** beyond pull-to-refresh + the existing `.task` invocation. Hermes hasn't shipped a curator-watch surface; iOS won't either.
- **iOS Kanban hallucination badge tap-to-explain alert** — recommend not adding (see Open Question #7).
- **iOS Kanban diagnostics history graph** — Mac WS-3 also defers this. iOS follows.
- **iOS deep links from v0.13 features sheet** — see Open Question #8.
- **Snapshot tests for the new iOS sheets** — manual verification is the v2.8.0 pass.
- **Localization** — every new copy string is English-only. Existing iOS surfaces aren't localized either; WS-9 stays consistent.
- **iOS Goal pill custom font / pill chrome migration to a `ScarfDesign` component** — keep inline. If Mac WS-2 lands a reusable `ScarfGoalPill` component in the design package, swap iOS to use it as a follow-up.
- **iOS goal-state persistence across app suspends** — relies on the Mac VM state being authoritative. iOS just renders what it polls. If this matters in dogfooding (user perceives a stale pill after a long suspend), revisit.
- **Telemetry counters** for new iOS surfaces (e.g. ScarfMon counter on goal-pill appearance). Add if dogfooding surfaces a perf signal; otherwise ship without.
- **Per-platform notification re-routing toggles on iOS** (e.g. "send Google Chat alerts to APNS"). Out of scope — APNS routing already lives in `Notifications/NotificationRouter.swift` and is platform-agnostic.
---
## Estimate
**Engineering hours (one engineer, focused), assuming WS-2 / WS-3 / WS-4 / WS-5 are merged to main:**
| Block | Hours |
|---|---|
| iOS chat goal pill + queue chip in `projectContextBar` (§1) | 2 |
| iOS Kanban detail sheet — chips + banners + diagnostics blocks + tap sheet (§2) | 5 |
| iOS Kanban `DiagnosticDetailSheet.swift` (NEW, ~30 LOC) | 1 |
| iOS Curator Archived section (§3) | 2 |
| iOS Settings Platforms extension + capability env injection (§4) | 3 |
| iOS Settings v0.13 badge + sheet (§5, including new sheet file) | 2 |
| `HermesCapabilities.isV013OrLater` helper (if not present) | 0.5 |
| Manual smoke on iPhone simulator (v0.13 + v0.12 hosts) + Dynamic Type pass | 3 |
| Code review + revisions | 2 |
| Buffer for WS-5 field-name alignment (Open Q #3) | 1.5 |
| **Total** | **~22 hours (≈3 working days)** |
**Confidence: medium-high.** All five items are mechanical given the existing iOS surface scaffolding (`projectContextBar`, `ScarfGoKanbanDetailSheet`, `CuratorView`, `SettingsView.platformsSection`). The only real risk is WS-5 field-name drift — captured in Open Question #3 — and it's contained to mirror item 4 (Settings → Platforms extensions). If WS-5 slips, mirror items 1-3-5 ship first; item 6 (Platforms) follows once WS-5 lands.
**Critical-path dependency:** WS-2, WS-3, WS-4, WS-5 must all be on `main` before WS-9 PR opens. WS-9 is the final "iOS catch-up" PR of the v2.8.0 release cycle.
**Risk register:**
- **WS-5 field-name drift.** Mitigated by Open Question #3 sync with the WS-5 author before implementation; Settings extensions stub clearly-named provisional field names that fail-fast at compile if WS-5 ships different names.
- **Dynamic Type churn.** Goal pill and Kanban diagnostics blocks are content-text — they scale. Verify nothing collapses at AX2; truncation strategies in §1b and the FlowLayout primitive in §2e are the v2.7.5 patterns and known-good.
- **`projectContextBar` re-render churn.** Open Question #5 captures this. Add a ScarfMon counter; revisit if dogfooding shows a hot-path issue.
- **iOS Kanban polling cadence** — the existing 5s poll picks up the new fields automatically. No new polling logic required.
- **No iOS test coverage regression.** WS-9 doesn't add tests but doesn't remove any either. The shared `RichChatViewModel` / `CuratorViewModel` / `KanbanService` tests in ScarfCore (extended by WS-2/3/4) cover the model + state-machine layer; iOS-specific UI is verified manually in v2.8.0.
+20 -20
View File
@@ -529,7 +529,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Scarf iOS/Scarf_iOS.entitlements"; CODE_SIGN_ENTITLEMENTS = "Scarf iOS/Scarf_iOS.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -546,7 +546,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarfgo.app; PRODUCT_BUNDLE_IDENTIFIER = com.scarfgo.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos; SDKROOT = iphoneos;
@@ -571,7 +571,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Scarf iOS/Scarf_iOS.entitlements"; CODE_SIGN_ENTITLEMENTS = "Scarf iOS/Scarf_iOS.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -588,7 +588,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarfgo.app; PRODUCT_BUNDLE_IDENTIFIER = com.scarfgo.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos; SDKROOT = iphoneos;
@@ -612,7 +612,7 @@
buildSettings = { buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.2; IPHONEOS_DEPLOYMENT_TARGET = 26.2;
@@ -635,7 +635,7 @@
buildSettings = { buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.2; IPHONEOS_DEPLOYMENT_TARGET = 26.2;
@@ -658,7 +658,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.2; IPHONEOS_DEPLOYMENT_TARGET = 26.2;
@@ -680,7 +680,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.2; IPHONEOS_DEPLOYMENT_TARGET = 26.2;
@@ -834,7 +834,7 @@
CODE_SIGN_ENTITLEMENTS = scarf/scarf.entitlements; CODE_SIGN_ENTITLEMENTS = scarf/scarf.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
ENABLE_APP_SANDBOX = NO; ENABLE_APP_SANDBOX = NO;
@@ -848,7 +848,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 14.6; MACOSX_DEPLOYMENT_TARGET = 14.6;
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarf.app; PRODUCT_BUNDLE_IDENTIFIER = com.scarf.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
REGISTER_APP_GROUPS = YES; REGISTER_APP_GROUPS = YES;
@@ -870,7 +870,7 @@
CODE_SIGN_ENTITLEMENTS = scarf/scarf.entitlements; CODE_SIGN_ENTITLEMENTS = scarf/scarf.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
ENABLE_APP_SANDBOX = NO; ENABLE_APP_SANDBOX = NO;
@@ -884,7 +884,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 14.6; MACOSX_DEPLOYMENT_TARGET = 14.6;
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarf.app; PRODUCT_BUNDLE_IDENTIFIER = com.scarf.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
REGISTER_APP_GROUPS = YES; REGISTER_APP_GROUPS = YES;
@@ -902,12 +902,12 @@
buildSettings = { buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.2; MACOSX_DEPLOYMENT_TARGET = 26.2;
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarfTests; PRODUCT_BUNDLE_IDENTIFIER = com.scarfTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
STRING_CATALOG_GENERATE_SYMBOLS = NO; STRING_CATALOG_GENERATE_SYMBOLS = NO;
@@ -924,12 +924,12 @@
buildSettings = { buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 26.2; MACOSX_DEPLOYMENT_TARGET = 26.2;
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarfTests; PRODUCT_BUNDLE_IDENTIFIER = com.scarfTests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
STRING_CATALOG_GENERATE_SYMBOLS = NO; STRING_CATALOG_GENERATE_SYMBOLS = NO;
@@ -945,11 +945,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarfUITests; PRODUCT_BUNDLE_IDENTIFIER = com.scarfUITests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
STRING_CATALOG_GENERATE_SYMBOLS = NO; STRING_CATALOG_GENERATE_SYMBOLS = NO;
@@ -965,11 +965,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 34; CURRENT_PROJECT_VERSION = 35;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 3Q6X2L86C4; DEVELOPMENT_TEAM = 3Q6X2L86C4;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 2.7.5; MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.scarfUITests; PRODUCT_BUNDLE_IDENTIFIER = com.scarfUITests;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
STRING_CATALOG_GENERATE_SYMBOLS = NO; STRING_CATALOG_GENERATE_SYMBOLS = NO;
@@ -84,7 +84,11 @@ struct HermesFileService: Sendable {
inlineDiffs: bool("display.inline_diffs", default: true), inlineDiffs: bool("display.inline_diffs", default: true),
toolProgressCommand: bool("display.tool_progress_command", default: false), toolProgressCommand: bool("display.tool_progress_command", default: false),
toolPreviewLength: int("display.tool_preview_length", default: 0), toolPreviewLength: int("display.tool_preview_length", default: 0),
busyInputMode: str("display.busy_input_mode", default: "interrupt") busyInputMode: str("display.busy_input_mode", default: "interrupt"),
// v0.13: empty default means "key absent agent uses its own
// default" (English). The picker writes a real value when the
// user explicitly chooses one.
language: str("display.language", default: "")
) )
let terminal = TerminalSettings( let terminal = TerminalSettings(
@@ -131,7 +135,12 @@ struct HermesFileService: Sendable {
sttLocalModel: str("stt.local.model", default: "base"), sttLocalModel: str("stt.local.model", default: "base"),
sttLocalLanguage: str("stt.local.language"), sttLocalLanguage: str("stt.local.language"),
sttOpenAIModel: str("stt.openai.model", default: "whisper-1"), sttOpenAIModel: str("stt.openai.model", default: "whisper-1"),
sttMistralModel: str("stt.mistral.model", default: "voxtral-mini-latest") sttMistralModel: str("stt.mistral.model", default: "voxtral-mini-latest"),
// TODO(WS-8-Q2): Verify key names. Mirroring the elevenlabs
// shape (`<provider>.voice_id` + `<provider>.model`); v0.13
// source might use `tts.xai.voice` or `tts.xai.model_id`.
ttsXAIVoiceID: str("tts.xai.voice_id"),
ttsXAIModel: str("tts.xai.model")
) )
func aux(_ name: String) -> AuxiliaryModel { func aux(_ name: String) -> AuxiliaryModel {
@@ -254,6 +263,47 @@ struct HermesFileService: Sendable {
cooldownSeconds: int("platforms.homeassistant.extra.cooldown_seconds", default: 30) cooldownSeconds: int("platforms.homeassistant.extra.cooldown_seconds", default: 30)
) )
// -- v0.13: per-platform Messaging Gateway settings --------------
// Mirrors the canonical extractor in
// `ScarfCore/Parsing/HermesConfig+YAML.swift`. Behaviour parity
// matters: both parsers must populate `gatewayPlatforms` the same
// way so iOS and Mac surfaces stay in lockstep.
// TODO(WS-5-Q2): YAML key path unverified see the comment in the
// ScarfCore extractor for the resolution path.
let gatewayAllowlistPlatforms = [
"slack", "mattermost", "google-chat",
"telegram", "whatsapp",
"matrix", "dingtalk",
]
var gatewayPlatforms: [String: GatewayPlatformSettings] = [:]
for platform in gatewayAllowlistPlatforms {
let prefix = "gateway.platforms.\(platform)."
let allowedChannels = lists[prefix + "allowed_channels"] ?? []
let allowedChats = lists[prefix + "allowed_chats"] ?? []
let allowedRooms = lists[prefix + "allowed_rooms"] ?? []
let busy = bool(prefix + "busy_ack_enabled", default: true)
let restartNotice = bool(prefix + "gateway_restart_notification",
default: false)
let ttl = int(prefix + "slash_command_notice_ttl_seconds",
default: 0)
let isEmpty = allowedChannels.isEmpty
&& allowedChats.isEmpty
&& allowedRooms.isEmpty
&& values[prefix + "busy_ack_enabled"] == nil
&& values[prefix + "gateway_restart_notification"] == nil
&& values[prefix + "slash_command_notice_ttl_seconds"] == nil
if !isEmpty {
gatewayPlatforms[platform] = GatewayPlatformSettings(
allowedChannels: allowedChannels,
allowedChats: allowedChats,
allowedRooms: allowedRooms,
busyAckEnabled: busy,
gatewayRestartNotification: restartNotice,
slashCommandNoticeTTLSeconds: ttl
)
}
}
return HermesConfig( return HermesConfig(
model: str("model.default", default: "unknown"), model: str("model.default", default: "unknown"),
provider: str("model.provider", default: "unknown"), provider: str("model.provider", default: "unknown"),
@@ -313,7 +363,8 @@ struct HermesFileService: Sendable {
homeAssistant: homeAssistant, homeAssistant: homeAssistant,
cacheTTL: str("prompt_caching.cache_ttl", default: "5m"), cacheTTL: str("prompt_caching.cache_ttl", default: "5m"),
redactionEnabled: bool("redaction.enabled", default: false), redactionEnabled: bool("redaction.enabled", default: false),
runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false) runtimeMetadataFooter: bool("agent.runtime_metadata_footer", default: false),
gatewayPlatforms: gatewayPlatforms
) )
} }
@@ -599,7 +650,8 @@ struct HermesFileService: Sendable {
toolsExclude: server.toolsExclude, toolsExclude: server.toolsExclude,
resourcesEnabled: server.resourcesEnabled, resourcesEnabled: server.resourcesEnabled,
promptsEnabled: server.promptsEnabled, promptsEnabled: server.promptsEnabled,
hasOAuthToken: hasToken hasOAuthToken: hasToken,
sseReadTimeout: server.sseReadTimeout
) )
} }
} }
@@ -630,6 +682,37 @@ struct HermesFileService: Sendable {
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n") return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
} }
/// Adds an SSE-transport MCP server. v0.13+ only caller is responsible
/// for capability-gating; pre-v0.13 hosts will reject the `--transport`
/// flag at argparse time. The optional `sseReadTimeout` is passed via
/// `--sse-read-timeout <int>` and persisted as `sse_read_timeout: <int>`
/// in the YAML entry.
// TODO(WS-7-Q3): Verify exact CLI flag spelling against `hermes mcp add --help`
// on a v0.13 install. Plan assumes `--transport sse` + `--sse-read-timeout`;
// alternatives could be `--sse` (boolean) + `--read-timeout`.
@discardableResult
nonisolated func addMCPServerSSE(name: String, url: String, sseReadTimeout: Int?) -> (exitCode: Int32, output: String) {
var cliArgs: [String] = ["mcp", "add", name, "--url", url, "--transport", "sse"]
if let timeout = sseReadTimeout {
cliArgs.append(contentsOf: ["--sse-read-timeout", String(timeout)])
}
return runHermesCLI(args: cliArgs, timeout: 45, stdinInput: "y\ny\ny\n")
}
/// Updates the `sse_read_timeout` scalar in-place via the same surgical
/// patcher used by `setMCPServerTimeouts`. Pass `nil` to remove the
/// scalar entirely (Hermes default applies).
@discardableResult
nonisolated func setMCPServerSSETimeout(name: String, sseReadTimeout: Int?) -> Bool {
patchMCPServerField(name: name) { entryLines in
if let timeout = sseReadTimeout {
Self.replaceOrInsertScalar(key: "sse_read_timeout", value: String(timeout), in: &entryLines)
} else {
Self.removeScalar(key: "sse_read_timeout", in: &entryLines)
}
}
}
@discardableResult @discardableResult
nonisolated func setMCPServerArgs(name: String, args: [String]) -> Bool { nonisolated func setMCPServerArgs(name: String, args: [String]) -> Bool {
patchMCPServerField(name: name) { entryLines in patchMCPServerField(name: name) { entryLines in
@@ -812,11 +895,23 @@ struct HermesFileService: Sendable {
func flush() { func flush() {
guard let name = currentName else { return } guard let name = currentName else { return }
let transport: MCPTransport = fields["url"] != nil ? .http : .stdio // 3-way transport discriminator: an explicit `transport: sse` scalar
// wins (Hermes v0.13+ emits it for SSE servers); otherwise URL-bearing
// entries fall back to .http (v0.12 shape) and command-bearing entries
// to .stdio. This preserves byte-for-byte round-trip on existing files
// pre-v0.13 entries have no `transport:` key so they parse identically.
// TODO(WS-7-Q1): Verify Hermes v0.13 actually emits `transport: sse`
// (vs. inferring from the schema/url shape) once a v0.13 host is on hand.
let transport: MCPTransport = {
if fields["transport"]?.lowercased() == "sse" { return .sse }
if fields["url"] != nil { return .http }
return .stdio
}()
let enabledStr = fields["enabled"]?.lowercased() let enabledStr = fields["enabled"]?.lowercased()
let enabled = enabledStr != "false" let enabled = enabledStr != "false"
let timeout = fields["timeout"].flatMap(Int.init) let timeout = fields["timeout"].flatMap(Int.init)
let connectTimeout = fields["connect_timeout"].flatMap(Int.init) let connectTimeout = fields["connect_timeout"].flatMap(Int.init)
let sseReadTimeout = fields["sse_read_timeout"].flatMap(Int.init)
let server = HermesMCPServer( let server = HermesMCPServer(
name: name, name: name,
transport: transport, transport: transport,
@@ -833,7 +928,8 @@ struct HermesFileService: Sendable {
toolsExclude: excludeList, toolsExclude: excludeList,
resourcesEnabled: resources, resourcesEnabled: resources,
promptsEnabled: prompts, promptsEnabled: prompts,
hasOAuthToken: false hasOAuthToken: false,
sseReadTimeout: sseReadTimeout
) )
servers.append(server) servers.append(server)
@@ -15,6 +15,35 @@ final class HermesFileWatcher {
/// the project list changes. /// the project list changes.
private var remoteProjectPaths: [String] = [] private var remoteProjectPaths: [String] = []
/// Coalescing timer for `lastChangeDate` ticks. v0.13 Hermes writes to
/// `state.db-wal` and rotating logs at ~10 Hz during gateway activity;
/// every observing view (`DashboardView`, `ProjectsView`,
/// `ProjectSessionsView`, half a dozen widgets) re-fires its `.onChange`
/// or `.task(id:)` on every tick, which stacked concurrent dashboard
/// loads on v0.13 hosts and tripped sqlite contention on the read-only
/// state.db handle. We coalesce to at most one tick per
/// `coalesceWindow` so a burst of FSEvents collapses into one observable
/// state mutation.
///
/// **Two limits, not one.** A pure trailing-debounce would starve under
/// sustained WAL writes the timer would keep getting cancelled and
/// rescheduled, and a coincident `gateway_state.json` Start/Stop touch
/// would never propagate until WAL activity quieted down. So we publish
/// when EITHER (a) `coalesceWindow` of quiet has elapsed since the last
/// fire, OR (b) `maxWait` has elapsed since the first fire of the
/// current burst whichever comes first. The max-wait guarantees a
/// floor of one observable mutation per `maxWait` even during sustained
/// activity. Numbers picked to keep the dashboard responsive on a
/// single `touch` while surviving v0.13's WAL-write storm.
private var pendingCoalesceTimer: DispatchWorkItem?
private var pendingTickDate: Date?
/// Wall-clock when the current burst began. Set on the first
/// `scheduleCoalescedTick` fire after a quiet window; cleared whenever
/// the timer fires. Drives the `maxWait` floor below.
private var burstStartDate: Date?
private static let coalesceWindow: TimeInterval = 0.5
private static let maxWait: TimeInterval = 1.5
let context: ServerContext let context: ServerContext
private let transport: any ServerTransport private let transport: any ServerTransport
@@ -92,12 +121,53 @@ final class HermesFileWatcher {
for await _ in stream { for await _ in stream {
ScarfMon.event(.transport, "mac.fileWatcher.remoteDelta", count: 1) ScarfMon.event(.transport, "mac.fileWatcher.remoteDelta", count: 1)
await MainActor.run { [weak self] in await MainActor.run { [weak self] in
self?.lastChangeDate = Date() self?.scheduleCoalescedTick()
} }
} }
} }
} }
/// Coalesce a burst of FSEvents (or remote-poll deltas) into a single
/// `lastChangeDate` mutation. Two limits decide when the publish fires,
/// whichever comes first:
///
/// 1. **Quiet window**: `coalesceWindow` seconds have elapsed since the
/// last fire. Each new fire pushes this out pure debounce shape.
/// 2. **Max wait**: `maxWait` seconds have elapsed since the FIRST fire
/// of the current burst. This bounds the latency floor under
/// sustained activity (v0.13's ~10 Hz WAL-write storm) so a
/// coincident `gateway_state.json` Start/Stop touch can't be starved
/// indefinitely behind a continuously-rescheduling debounce timer.
///
/// Runs on `.main` (the FSEvents queue and the remote-poll
/// MainActor.run) so observers see the publish on MainActor without a
/// hop. The work item self-clears `burstStartDate` when it fires so the
/// next burst starts a fresh max-wait window.
private func scheduleCoalescedTick() {
let now = Date()
pendingTickDate = now
if burstStartDate == nil {
burstStartDate = now
}
pendingCoalesceTimer?.cancel()
// Pick the deadline as the earlier of (a) `coalesceWindow` from now,
// and (b) `maxWait` from the burst start. The latter only matters
// when fires keep arriving faster than `coalesceWindow`; in the
// single-fire / quiet-burst case both reduce to the same value.
let quietDeadline = now.addingTimeInterval(Self.coalesceWindow)
let maxWaitDeadline = (burstStartDate ?? now).addingTimeInterval(Self.maxWait)
let firingDate = min(quietDeadline, maxWaitDeadline)
let delay = max(0, firingDate.timeIntervalSince(now))
let work = DispatchWorkItem { [weak self] in
guard let self, let date = self.pendingTickDate else { return }
self.pendingTickDate = nil
self.burstStartDate = nil
self.lastChangeDate = date
}
pendingCoalesceTimer = work
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: work)
}
func stopWatching() { func stopWatching() {
for source in coreSources + projectSources { for source in coreSources + projectSources {
source.cancel() source.cancel()
@@ -108,6 +178,10 @@ final class HermesFileWatcher {
timer = nil timer = nil
remotePollTask?.cancel() remotePollTask?.cancel()
remotePollTask = nil remotePollTask = nil
pendingCoalesceTimer?.cancel()
pendingCoalesceTimer = nil
pendingTickDate = nil
burstStartDate = nil
} }
/// Watch each project's `dashboard.json` AND its enclosing `.scarf/` /// Watch each project's `dashboard.json` AND its enclosing `.scarf/`
@@ -162,7 +236,7 @@ final class HermesFileWatcher {
// message persisted); high counts when nothing's happening // message persisted); high counts when nothing's happening
// suggest a runaway watcher install. // suggest a runaway watcher install.
ScarfMon.event(.transport, "mac.fileWatcher.localFire", count: 1) ScarfMon.event(.transport, "mac.fileWatcher.localFire", count: 1)
self?.lastChangeDate = Date() self?.scheduleCoalescedTick()
} }
source.setCancelHandler { source.setCancelHandler {
Darwin.close(fd) Darwin.close(fd)
@@ -77,6 +77,27 @@ final class ChatViewModel {
let richChatViewModel: RichChatViewModel let richChatViewModel: RichChatViewModel
private var coordinator: Coordinator? private var coordinator: Coordinator?
/// Capability store the chat surface reads from. Set by `ChatView`
/// at body-evaluation time via `attachCapabilitiesStore(_:)`
/// `@ObservationIgnored` so capability refreshes don't force a
/// full chat re-render. Forwards into
/// `RichChatViewModel.capabilitiesGate` whenever the published
/// snapshot changes; the slash menu reads through that. v2.8 /
/// Hermes v0.13 gates `/goal` + `/queue` slash menu rows.
@ObservationIgnored
var capabilitiesStore: HermesCapabilitiesStore?
/// Wire the Mac chat view's environment-injected capabilities store
/// into both this VM and its child rich-chat VM. Idempotent on the
/// pointer (re-attaching the same store is a no-op); always
/// re-publishes the latest snapshot so a refresh that fired before
/// the chat view became visible still lands.
@MainActor
func attachCapabilitiesStore(_ store: HermesCapabilitiesStore?) {
capabilitiesStore = store
richChatViewModel.publishCapabilities(store?.capabilities ?? .empty)
}
/// `callId` of the tool call currently surfaced in the chat /// `callId` of the tool call currently surfaced in the chat
/// inspector pane, or nil when nothing is focused. Set by /// inspector pane, or nil when nothing is focused. Set by
/// `ToolCallCard` taps in the transcript; cleared by the inspector's /// `ToolCallCard` taps in the transcript; cleared by the inspector's
@@ -321,6 +342,47 @@ final class ChatViewModel {
richChatViewModel.clearACPErrorState() richChatViewModel.clearACPErrorState()
} }
/// Auto-clear the chat composer's transient hint after 4 s. Shared
/// helper for `/steer`, `/goal`, and `/queue` so the toast lifetime
/// stays consistent across non-interruptive commands.
@MainActor
private func scheduleHintClear() {
let snapshot = richChatViewModel.transientHint
Task { @MainActor [weak self] in
try? await Task.sleep(nanoseconds: 4_000_000_000)
if self?.richChatViewModel.transientHint == snapshot {
self?.richChatViewModel.transientHint = nil
}
}
}
/// Pull the slash command name + raw argument tail out of the
/// composer text. Returns `(name: nil, args: "")` for non-slash
/// input. Mirrors the parser shape `RichChatViewModel.parseGoalArgument`
/// expects; kept on `ChatViewModel` (not promoted to ScarfCore)
/// because the Mac and iOS chat surfaces compose this with their
/// own per-platform send paths.
static func parseSlashName(_ text: String) -> (name: String?, args: String) {
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
guard trimmed.hasPrefix("/") else { return (nil, "") }
let withoutSlash = trimmed.dropFirst()
if let space = withoutSlash.firstIndex(of: " ") {
return (
name: String(withoutSlash[..<space]),
args: String(withoutSlash[withoutSlash.index(after: space)...])
)
}
return (name: String(withoutSlash), args: "")
}
/// Cap goal text in transient toasts so a 1 KB user-typed goal
/// doesn't blow out the hint pill. The header pill applies its
/// own 33-char cap; the toast is shorter so the hint stays
/// glanceable.
static func truncatedToastGoal(_ text: String) -> String {
text.count <= 60 ? text : String(text.prefix(57)) + ""
}
@MainActor @MainActor
private func recordACPFailure(_ error: Error, client: ACPClient?, context: String) async { private func recordACPFailure(_ error: Error, client: ACPClient?, context: String) async {
logger.error("\(context): \(error.localizedDescription)") logger.error("\(context): \(error.localizedDescription)")
@@ -575,22 +637,59 @@ final class ChatViewModel {
// and Hermes-version-independent. v2.5. // and Hermes-version-independent. v2.5.
let wireText = expandIfProjectScoped(text) let wireText = expandIfProjectScoped(text)
// /steer is non-interruptive the agent is still on its // Non-interruptive slash commands keep the "Agent working"
// current turn; the guidance applies after the next tool // indicator off and surface a transient toast confirming the
// call. Don't change the "Agent working..." status (it's // command was accepted. v2.5 added `/steer`; v2.8 / Hermes
// already on); show a transient toast so the user knows the // v0.13 adds `/goal` (lock the agent on a target across turns)
// guidance was accepted. v2.5 / Hermes v2026.4.23+. // and `/queue` (queue a prompt for after the current turn).
let isSteer = richChatViewModel.isNonInterruptiveSlash(text) // Each gets its own optimistic side-effect on RichChatViewModel
if isSteer { // so the chat header pill / queue chip update synchronously
richChatViewModel.transientHint = "Guidance queued — applies after the next tool call." // without waiting for a server round-trip.
Task { @MainActor [weak self] in let isNonInterruptive = richChatViewModel.isNonInterruptiveSlash(text)
try? await Task.sleep(nanoseconds: 4_000_000_000) let parsed = Self.parseSlashName(text)
if self?.richChatViewModel.transientHint == "Guidance queued — applies after the next tool call." { switch parsed.name {
self?.richChatViewModel.transientHint = nil case "goal":
} // TODO(WS-2-Q7): once a v0.13 host confirms the
// wire-shape, this branch fires only when the host
// advertises `hasGoals`; pre-v0.13 hosts hide the menu
// row, but a power-user typing `/goal` directly still
// lands here. We keep the optimistic write so the pill
// appears synchronously the agent's "unknown command"
// reply on a pre-v0.13 host paints the inconsistency in
// user-visible chat content (acceptable v1 behavior;
// see WS-2 plan "Inconsistency caveat").
let arg = RichChatViewModel.parseGoalArgument(parsed.args)
switch arg {
case .set(let goalText):
richChatViewModel.recordActiveGoal(text: goalText)
richChatViewModel.transientHint = "Goal locked: \(Self.truncatedToastGoal(goalText))"
case .clear:
richChatViewModel.recordActiveGoal(text: nil)
richChatViewModel.transientHint = "Goal cleared."
case .empty:
richChatViewModel.transientHint = "Sent /goal — see the agent reply for current goal."
} }
} else { scheduleHintClear()
acpStatus = ACPPhase.agentWorking case "queue":
// TODO(WS-2-Q5): verify against a real v0.13 ACP host
// that the verbatim "/queue <text>" wire shape is what
// Hermes accepts (versus a structured arg shape). The
// optimistic mirror logic below assumes verbatim text.
let queuedText = parsed.args.trimmingCharacters(in: .whitespacesAndNewlines)
if !queuedText.isEmpty {
richChatViewModel.recordQueuedPrompt(text: queuedText)
}
richChatViewModel.transientHint = "Queued — runs after current turn."
scheduleHintClear()
case "steer" where isNonInterruptive:
richChatViewModel.transientHint = "Guidance queued — applies after the next tool call."
scheduleHintClear()
default:
// Regular interruptive prompt (or an unrecognized slash).
// Don't flip "Agent working" for any other
// non-interruptive command (defensive; matches the
// legacy contract).
if !isNonInterruptive { acpStatus = ACPPhase.agentWorking }
} }
acpPromptTask = Task { @MainActor in acpPromptTask = Task { @MainActor in
do { do {
@@ -608,7 +707,7 @@ final class ChatViewModel {
// notifier handles the foreground/disabled gating; // notifier handles the foreground/disabled gating;
// we just hand it the latest assistant text and // we just hand it the latest assistant text and
// session title for the body line. // session title for the body line.
if !isSteer { if !isNonInterruptive {
let preview = richChatViewModel.messages let preview = richChatViewModel.messages
.last(where: { $0.isAssistant })? .last(where: { $0.isAssistant })?
.content ?? "" .content ?? ""
@@ -0,0 +1,95 @@
import SwiftUI
import ScarfCore
import ScarfDesign
/// Header chip that surfaces prompts the user has queued via
/// `/queue ` (Hermes v0.13). Tap popover listing the queued
/// prompt previews + their relative timestamps.
///
/// The chip is OPTIMISTIC it's a Scarf-side mirror of what the user
/// typed. Hermes owns the authoritative queue server-side. The popover
/// header makes that explicit so the user understands per-entry
/// removal isn't supported (Hermes has no remove-by-id verb), and the
/// v2.8.0 plan removed the "Clear all" button rather than ship one
/// that would lie about its effect on server-side state. See WS-2 plan
/// Q2 for the wire-shape question that drove that decision.
struct ChatQueueIndicator: View {
let queuedPrompts: [HermesQueuedPrompt]
@State private var isPopoverShown = false
var body: some View {
if queuedPrompts.isEmpty {
EmptyView()
} else {
chipButton
.popover(isPresented: $isPopoverShown, arrowEdge: .bottom) {
queuePopover
}
}
}
private var chipButton: some View {
Button {
isPopoverShown = true
} label: {
HStack(spacing: 4) {
Image(systemName: "tray.full")
Text("\(queuedPrompts.count) queued")
}
.scarfStyle(.caption)
.padding(.horizontal, ScarfSpace.s2)
.padding(.vertical, 2)
.background(Capsule().fill(ScarfColor.warning.opacity(0.16)))
.foregroundStyle(ScarfColor.warning)
}
.buttonStyle(.plain)
.help("Prompts waiting to run after the current turn finishes")
}
@ViewBuilder
private var queuePopover: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
Text("Queued prompts")
.scarfStyle(.headline)
.foregroundStyle(ScarfColor.foregroundPrimary)
Text("Local view — Hermes manages the actual queue server-side. The next prompt runs automatically when the current turn finishes.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.fixedSize(horizontal: false, vertical: true)
ScarfDivider()
ScrollView {
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
ForEach(Array(queuedPrompts.enumerated()), id: \.element.id) { index, prompt in
queueRow(prompt, position: index + 1)
}
}
.padding(.vertical, 2)
}
.frame(maxHeight: 220)
}
.padding(ScarfSpace.s4)
.frame(width: 360)
}
@ViewBuilder
private func queueRow(_ prompt: HermesQueuedPrompt, position: Int) -> some View {
VStack(alignment: .leading, spacing: 2) {
HStack(alignment: .firstTextBaseline, spacing: ScarfSpace.s2) {
Text("#\(position)")
.scarfStyle(.captionUppercase)
.foregroundStyle(ScarfColor.foregroundFaint)
Text(prompt.queuedAt, style: .relative)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
.monospacedDigit()
}
Text(prompt.text)
.scarfStyle(.body)
.foregroundStyle(ScarfColor.foregroundPrimary)
.lineLimit(3)
.truncationMode(.tail)
.fixedSize(horizontal: false, vertical: true)
}
.padding(.vertical, 2)
}
}
@@ -11,6 +11,7 @@ struct ChatTranscriptPane: View {
@Bindable var chatViewModel: ChatViewModel @Bindable var chatViewModel: ChatViewModel
var onSend: (String, [ChatImageAttachment]) -> Void var onSend: (String, [ChatImageAttachment]) -> Void
var isEnabled: Bool var isEnabled: Bool
@Environment(\.hermesCapabilities) private var capabilitiesStore
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
@@ -20,8 +21,13 @@ struct ChatTranscriptPane: View {
acpInputTokens: richChat.acpInputTokens, acpInputTokens: richChat.acpInputTokens,
acpOutputTokens: richChat.acpOutputTokens, acpOutputTokens: richChat.acpOutputTokens,
acpThoughtTokens: richChat.acpThoughtTokens, acpThoughtTokens: richChat.acpThoughtTokens,
acpCompressionCount: richChat.acpCompressionCount,
projectName: chatViewModel.currentProjectName, projectName: chatViewModel.currentProjectName,
gitBranch: chatViewModel.currentGitBranch gitBranch: chatViewModel.currentGitBranch,
activeGoal: richChat.activeGoal,
onClearGoal: { chatViewModel.sendText("/goal --clear") },
queuedPrompts: richChat.queuedPrompts,
capabilities: capabilitiesStore?.capabilities ?? .empty
) )
Divider() Divider()
@@ -58,7 +64,8 @@ struct ChatTranscriptPane: View {
onSend: onSend, onSend: onSend,
isEnabled: isEnabled, isEnabled: isEnabled,
commands: richChat.availableCommands, commands: richChat.availableCommands,
showCompressButton: richChat.supportsCompress && !richChat.hasBroaderCommandMenu showCompressButton: richChat.supportsCompress && !richChat.hasBroaderCommandMenu,
isAgentWorking: richChat.isAgentWorking
) )
.id(richChat.sessionId ?? "scarf.chat.no-session") .id(richChat.sessionId ?? "scarf.chat.no-session")
} }
@@ -5,6 +5,12 @@ struct ChatView: View {
@Environment(ChatViewModel.self) private var viewModel @Environment(ChatViewModel.self) private var viewModel
@Environment(HermesFileWatcher.self) private var fileWatcher @Environment(HermesFileWatcher.self) private var fileWatcher
@Environment(AppCoordinator.self) private var coordinator @Environment(AppCoordinator.self) private var coordinator
/// Capabilities store for the active server (injected on
/// `ContextBoundRoot`). Forwarded into `ChatViewModel` so the
/// rich-chat slash menu can gate v0.13 surfaces (`/goal`, `/queue`,
/// `/steer` on idle). Nil during harness scenarios; treated the
/// same as `.empty` capabilities.
@Environment(\.hermesCapabilities) private var capabilitiesStore
@State private var showErrorDetails = false @State private var showErrorDetails = false
/// Side-pane visibility toggles (issue #58). Drive the new /// Side-pane visibility toggles (issue #58). Drive the new
@@ -45,6 +51,15 @@ struct ChatView: View {
.navigationTitle( .navigationTitle(
viewModel.currentProjectName.map { "Chat · \($0)" } ?? "Chat" viewModel.currentProjectName.map { "Chat · \($0)" } ?? "Chat"
) )
// Forward the env-injected capabilities store into the chat VM
// on every refresh tick so the rich-chat slash menu picks up
// v0.13 surfaces the moment the host advertises them. The id
// value is the capabilities-line string a stable identity
// that flips exactly when the detector fires. Nil store
// `.empty` capabilities, which is what the VM defaults to.
.task(id: capabilitiesStore?.capabilities.versionLine ?? "") {
viewModel.attachCapabilitiesStore(capabilitiesStore)
}
.task { .task {
await viewModel.loadRecentSessions() await viewModel.loadRecentSessions()
viewModel.refreshCredentialPreflight() viewModel.refreshCredentialPreflight()
@@ -16,6 +16,11 @@ struct RichChatInputBar: View {
let isEnabled: Bool let isEnabled: Bool
var commands: [HermesSlashCommand] = [] var commands: [HermesSlashCommand] = []
var showCompressButton: Bool = false var showCompressButton: Bool = false
/// Whether the agent is currently mid-turn. Used to grey-out
/// `/steer` in the slash menu on idle pre-v0.13 hosts (where the
/// command silently no-ops). v0.13+ hosts allow `/steer` on idle
/// and the row stays interactive regardless of `isAgentWorking`.
var isAgentWorking: Bool = false
@Environment(\.hermesCapabilities) private var capabilitiesStore @Environment(\.hermesCapabilities) private var capabilitiesStore
@@ -52,6 +57,8 @@ struct RichChatInputBar: View {
SlashCommandMenu( SlashCommandMenu(
commands: filteredCommands, commands: filteredCommands,
agentHasCommands: !commands.isEmpty, agentHasCommands: !commands.isEmpty,
disabledCommandNames: disabledMenuCommandNames,
disabledReason: disabledMenuReason,
selectedIndex: $selectedIndex, selectedIndex: $selectedIndex,
onSelect: insertCommand onSelect: insertCommand
) )
@@ -392,6 +399,27 @@ struct RichChatInputBar: View {
SlashCommandMenu.filter(commands: commands, query: menuQuery) SlashCommandMenu.filter(commands: commands, query: menuQuery)
} }
/// Names of menu rows that should render greyed-out + ignore taps.
/// v2.8 / Hermes v0.13: `/steer` is greyed only when the connected
/// host is pre-v0.13 AND the session is idle. Pre-v0.13 hosts
/// silently no-op `/steer` outside an active turn surfacing the
/// row as "use during a turn" is friendlier than letting the user
/// click and see nothing happen. v0.13+ hosts allow steer-on-idle
/// (the command just sends as a regular prompt) so the row stays
/// interactive there.
private var disabledMenuCommandNames: Set<String> {
let hasSteerOnIdle = capabilitiesStore?.capabilities.hasACPSteerOnIdle ?? false
if !isAgentWorking && !hasSteerOnIdle {
return ["steer"]
}
return []
}
private var disabledMenuReason: String? {
guard !disabledMenuCommandNames.isEmpty else { return nil }
return "Use `/steer` while the agent is working — your Hermes version doesn't support steering on idle sessions."
}
private func updateMenuState() { private func updateMenuState() {
let shouldShow = shouldShowMenu let shouldShow = shouldShowMenu
@@ -9,6 +9,11 @@ struct SessionInfoBar: View {
var acpInputTokens: Int = 0 var acpInputTokens: Int = 0
var acpOutputTokens: Int = 0 var acpOutputTokens: Int = 0
var acpThoughtTokens: Int = 0 var acpThoughtTokens: Int = 0
/// Number of context compactions Hermes has run on this session. v0.13+
/// surface capability-gated by the bar so pre-v0.13 hosts never see
/// the chip even if a stale value somehow trickles through. Defaults
/// to 0 so existing callers and previews don't need to be updated.
var acpCompressionCount: Int = 0
/// Name of the Scarf project this session is attributed to, when /// Name of the Scarf project this session is attributed to, when
/// applicable. Nil for plain global chats. Drives the folder-chip /// applicable. Nil for plain global chats. Drives the folder-chip
/// indicator rendered before the session title. Resolved by /// indicator rendered before the session title. Resolved by
@@ -20,6 +25,21 @@ struct SessionInfoBar: View {
/// name. Nil for non-project chats and for projects that aren't /// name. Nil for non-project chats and for projects that aren't
/// git repos. /// git repos.
var gitBranch: String? = nil var gitBranch: String? = nil
/// Active locked goal (Hermes v0.13 `/goal`). Nil hides the pill.
/// Optimistic set by `RichChatViewModel.recordActiveGoal(text:)`
/// when the user sends `/goal `.
var activeGoal: HermesActiveGoal? = nil
/// Invoked when the user picks "Clear goal" from the goal pill's
/// context menu. Caller dispatches `/goal --clear` so the optimistic
/// pill clear and the server-side authoritative state stay in sync.
var onClearGoal: (() -> Void)? = nil
/// Local mirror of prompts queued via `/queue ` (Hermes v0.13).
/// Empty list hides the chip.
var queuedPrompts: [HermesQueuedPrompt] = []
/// Capability snapshot for v0.13+ surfaces. Defaulted so previews and
/// pre-v0.13 hosts render the v2.7.5 layout unchanged. Coordinated
/// with WS-2 both WSes add `capabilities` to this view.
var capabilities: HermesCapabilities = .empty
/// Active Hermes profile name (issue #50). Resolved on each body /// Active Hermes profile name (issue #50). Resolved on each body
/// re-evaluation; the resolver caches for 5s so this is cheap. /// re-evaluation; the resolver caches for 5s so this is cheap.
@@ -62,6 +82,42 @@ struct SessionInfoBar: View {
} }
} }
// Goal pill (v2.8 / Hermes v0.13). `.info` keeps it
// visually decodable from the rust accent (project /
// branch) and the warning amber (queue chip). The
// pill renders only when `activeGoal` is non-nil
// pre-v0.13 hosts can't reach the `/goal` send path
// through the slash menu (it's filtered out in
// `availableCommands`), so the pill stays absent there
// by transitive impossibility.
if let activeGoal {
HStack(spacing: 4) {
Image(systemName: "scope")
Text(Self.truncatedGoal(activeGoal.text))
}
.scarfStyle(.caption)
.padding(.horizontal, ScarfSpace.s2)
.padding(.vertical, 2)
.background(Capsule().fill(ScarfColor.info.opacity(0.16)))
.foregroundStyle(ScarfColor.info)
.help("Goal locked: \(activeGoal.text)")
.contextMenu {
if let onClearGoal {
Button("Clear goal", role: .destructive, action: onClearGoal)
}
}
}
// Queue chip (v2.8 / Hermes v0.13). Local mirror only
// Hermes is the authoritative owner of the actual
// queue. Per-entry deletion isn't exposed (Hermes has
// no remove-by-id verb), and the v2.8.0 plan drops the
// global "Clear all" button to avoid lying about
// server-side state. The popover is read-only.
if !queuedPrompts.isEmpty {
ChatQueueIndicator(queuedPrompts: queuedPrompts)
}
HStack(spacing: 4) { HStack(spacing: 4) {
Circle() Circle()
.fill(isWorking ? ScarfColor.success : ScarfColor.foregroundFaint) .fill(isWorking ? ScarfColor.success : ScarfColor.foregroundFaint)
@@ -96,6 +152,21 @@ struct SessionInfoBar: View {
Label("\(formatTokens(reasonToks)) reasoning", systemImage: "brain") Label("\(formatTokens(reasonToks)) reasoning", systemImage: "brain")
} }
// v0.13: Hermes surfaces a running count of automatic
// context compactions. Render only when the host is on
// v0.13+ AND the count is non-zero, so a pre-v0.13 host
// (which always reports 0) sees no chip, and a v0.13 host
// sees the chip the first time the agent compacts.
if capabilities.hasContextCompressionCount && acpCompressionCount > 0 {
Label(
"×\(acpCompressionCount)",
systemImage: "arrow.down.right.and.arrow.up.left"
)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.help("Hermes auto-compacted this session's context \(acpCompressionCount) time\(acpCompressionCount == 1 ? "" : "s")")
}
if let cost = session.displayCostUSD { if let cost = session.displayCostUSD {
let formattedCost = cost.formatted(.currency(code: "USD").precision(.fractionLength(4))) let formattedCost = cost.formatted(.currency(code: "USD").precision(.fractionLength(4)))
Label(session.costIsActual ? formattedCost : "\(formattedCost) est.", systemImage: "dollarsign.circle") Label(session.costIsActual ? formattedCost : "\(formattedCost) est.", systemImage: "dollarsign.circle")
@@ -134,4 +205,11 @@ struct SessionInfoBar: View {
private func formatTokens(_ count: Int) -> String { private func formatTokens(_ count: Int) -> String {
count.formatted(.number.notation(.compactName).precision(.fractionLength(0...1))) count.formatted(.number.notation(.compactName).precision(.fractionLength(0...1)))
} }
/// Cap goal text in the chip to keep the SessionInfoBar from
/// wrapping when the user locks a long goal. Full goal text is
/// available in the tooltip via `.help(...)`.
static func truncatedGoal(_ text: String) -> String {
text.count <= 36 ? text : String(text.prefix(33)) + ""
}
} }
@@ -11,6 +11,13 @@ struct SlashCommandMenu: View {
/// Whether the agent advertised any commands at all. Lets us distinguish /// Whether the agent advertised any commands at all. Lets us distinguish
/// "agent hasn't sent commands yet" from "filter matched nothing". /// "agent hasn't sent commands yet" from "filter matched nothing".
let agentHasCommands: Bool let agentHasCommands: Bool
/// Names that render greyed-out + ignore taps. v2.8 uses this only
/// for `/steer` on pre-v0.13 idle sessions; v0.13 hosts allow steer
/// on idle and the set is empty.
var disabledCommandNames: Set<String> = []
/// Tooltip shown on disabled rows. Reused per-row in v2.8 only
/// one disabled case ships, so a single shared string is enough.
var disabledReason: String? = nil
@Binding var selectedIndex: Int @Binding var selectedIndex: Int
var onSelect: (HermesSlashCommand) -> Void var onSelect: (HermesSlashCommand) -> Void
@@ -50,13 +57,17 @@ struct SlashCommandMenu: View {
ScrollView { ScrollView {
LazyVStack(spacing: 0) { LazyVStack(spacing: 0) {
ForEach(Array(commands.enumerated()), id: \.element.id) { index, command in ForEach(Array(commands.enumerated()), id: \.element.id) { index, command in
let isDisabled = disabledCommandNames.contains(command.name)
SlashCommandRow( SlashCommandRow(
command: command, command: command,
isSelected: index == selectedIndex isSelected: index == selectedIndex,
isDisabled: isDisabled,
disabledReason: isDisabled ? disabledReason : nil
) )
.id(index) .id(index)
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { .onTapGesture {
guard !isDisabled else { return }
selectedIndex = index selectedIndex = index
onSelect(command) onSelect(command)
} }
@@ -77,6 +88,8 @@ struct SlashCommandMenu: View {
private struct SlashCommandRow: View { private struct SlashCommandRow: View {
let command: HermesSlashCommand let command: HermesSlashCommand
let isSelected: Bool let isSelected: Bool
var isDisabled: Bool = false
var disabledReason: String? = nil
var body: some View { var body: some View {
HStack(alignment: .firstTextBaseline, spacing: 8) { HStack(alignment: .firstTextBaseline, spacing: 8) {
@@ -87,7 +100,16 @@ private struct SlashCommandRow: View {
.fontWeight(.semibold) .fontWeight(.semibold)
.foregroundStyle(isSelected ? ScarfColor.accentActive : ScarfColor.foregroundPrimary) .foregroundStyle(isSelected ? ScarfColor.accentActive : ScarfColor.foregroundPrimary)
if let hint = command.argumentHint { if let hint = command.argumentHint {
Text("<\(hint)>") // v0.13: Hermes may emit hints already wrapped in
// brackets (e.g. `[name]` for the optional `/new
// <name>` argument exposed by `hasNewWithSessionName`).
// Avoid double-wrapping bracketed hints pass through
// verbatim while older `guidance`-style hints (no
// brackets) still render as `<guidance>`.
let display = hint.hasPrefix("<") || hint.hasPrefix("[")
? hint
: "<\(hint)>"
Text(display)
.font(ScarfFont.monoSmall) .font(ScarfFont.monoSmall)
.foregroundStyle(ScarfColor.foregroundFaint) .foregroundStyle(ScarfColor.foregroundFaint)
} }
@@ -107,11 +129,19 @@ private struct SlashCommandRow: View {
.foregroundStyle(ScarfColor.foregroundMuted) .foregroundStyle(ScarfColor.foregroundMuted)
.lineLimit(2) .lineLimit(2)
} }
if isDisabled, let reason = disabledReason {
Text(reason)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
.lineLimit(2)
}
} }
Spacer(minLength: 0) Spacer(minLength: 0)
} }
.padding(.horizontal, ScarfSpace.s3) .padding(.horizontal, ScarfSpace.s3)
.padding(.vertical, ScarfSpace.s2) .padding(.vertical, ScarfSpace.s2)
.background(isSelected ? ScarfColor.accentTint : Color.clear) .background(isSelected ? ScarfColor.accentTint : Color.clear)
.opacity(isDisabled ? 0.55 : 1.0)
.help(isDisabled ? (disabledReason ?? "") : "")
} }
} }
@@ -146,7 +146,7 @@ final class CronViewModel {
} }
} }
func createJob(schedule: String, prompt: String, name: String, deliver: String, skills: [String], script: String, repeatCount: String, workdir: String = "") { func createJob(schedule: String, prompt: String, name: String, deliver: String, skills: [String], script: String, repeatCount: String, workdir: String = "", noAgent: Bool = false) {
var args = ["cron", "create"] var args = ["cron", "create"]
if !name.isEmpty { args += ["--name", name] } if !name.isEmpty { args += ["--name", name] }
if !deliver.isEmpty { args += ["--deliver", deliver] } if !deliver.isEmpty { args += ["--deliver", deliver] }
@@ -158,12 +158,25 @@ final class CronViewModel {
// know the flag argparse rejects unknown args, so the form // know the flag argparse rejects unknown args, so the form
// omits the flag when the field is empty. // omits the flag when the field is empty.
if !workdir.isEmpty { args += ["--workdir", workdir] } if !workdir.isEmpty { args += ["--workdir", workdir] }
// v0.13+: --no-agent runs the pre-run script and skips the AI turn.
// Caller (CronView) strips this on pre-v0.13 hosts so the flag is
// never emitted to a Hermes that can't parse it.
if noAgent { args.append("--no-agent") }
args.append(schedule) args.append(schedule)
if !prompt.isEmpty { args.append(prompt) } // TODO(WS-7-Q5): When --no-agent is set Hermes ignores the prompt arg,
// but argparse still wants positional args to line up with the
// schedule. The plan recommends passing an empty string explicitly so
// the positional parser doesn't treat the prompt as missing verify
// this behaviour against `hermes cron create --help` on a v0.13 host.
if noAgent {
args.append("")
} else if !prompt.isEmpty {
args.append(prompt)
}
runAndReload(args, success: "Job created") runAndReload(args, success: "Job created")
} }
func updateJob(id: String, schedule: String?, prompt: String?, name: String?, deliver: String?, repeatCount: String?, newSkills: [String]?, clearSkills: Bool, script: String?, workdir: String? = nil) { func updateJob(id: String, schedule: String?, prompt: String?, name: String?, deliver: String?, repeatCount: String?, newSkills: [String]?, clearSkills: Bool, script: String?, workdir: String? = nil, noAgent: Bool? = nil) {
var args = ["cron", "edit", id] var args = ["cron", "edit", id]
if let schedule, !schedule.isEmpty { args += ["--schedule", schedule] } if let schedule, !schedule.isEmpty { args += ["--schedule", schedule] }
if let prompt, !prompt.isEmpty { args += ["--prompt", prompt] } if let prompt, !prompt.isEmpty { args += ["--prompt", prompt] }
@@ -180,6 +193,16 @@ final class CronViewModel {
// = user cleared an existing workdir; Hermes documents `--workdir ""` // = user cleared an existing workdir; Hermes documents `--workdir ""`
// on edit as the explicit clear gesture, mirroring the `--script` shape. // on edit as the explicit clear gesture, mirroring the `--script` shape.
if let workdir { args += ["--workdir", workdir] } if let workdir { args += ["--workdir", workdir] }
// TODO(WS-7-Q4): The toggle-off shape of `--no-agent` on edit is
// unverified. Plan assumes Hermes accepts `--agent` to flip the flag
// back; if the CLI is one-way (`--no-agent` only), the edit-mode
// toggle should disable itself with a tooltip explaining the
// limitation. Send the flag in the assumed shape for now and adjust
// post-integration.
if let noAgent {
if noAgent { args.append("--no-agent") }
else { args.append("--agent") }
}
runAndReload(args, success: "Updated") runAndReload(args, success: "Updated")
} }
+37 -4
View File
@@ -25,6 +25,10 @@ struct CronView: View {
capabilitiesStore?.capabilities.hasCronWorkdir ?? false capabilitiesStore?.capabilities.hasCronWorkdir ?? false
} }
private var hasCronNoAgent: Bool {
capabilitiesStore?.capabilities.hasCronNoAgent ?? false
}
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
pageHeader pageHeader
@@ -47,7 +51,7 @@ struct CronView: View {
// polling timer. Same wiring ActivityView uses. // polling timer. Same wiring ActivityView uses.
.onChange(of: fileWatcher.lastChangeDate) { viewModel.load() } .onChange(of: fileWatcher.lastChangeDate) { viewModel.load() }
.sheet(isPresented: $viewModel.showCreateSheet) { .sheet(isPresented: $viewModel.showCreateSheet) {
CronJobEditor(mode: .create, availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir) { form in CronJobEditor(mode: .create, availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir, supportsNoAgent: hasCronNoAgent) { form in
viewModel.createJob( viewModel.createJob(
schedule: form.schedule, schedule: form.schedule,
prompt: form.prompt, prompt: form.prompt,
@@ -56,7 +60,12 @@ struct CronView: View {
skills: form.skills, skills: form.skills,
script: form.script, script: form.script,
repeatCount: form.repeatCount, repeatCount: form.repeatCount,
workdir: hasCronWorkdir ? form.workdir : "" workdir: hasCronWorkdir ? form.workdir : "",
// Mirrors the workdir strip-on-pre-version pattern: pre-v0.13
// hosts get a hard `false`, so a stale form value (or a
// hand-edited jobs.json round-tripped through edit-mode)
// can't sneak `--no-agent` into a CLI that doesn't grok it.
noAgent: hasCronNoAgent ? form.noAgent : false
) )
viewModel.showCreateSheet = false viewModel.showCreateSheet = false
} onCancel: { } onCancel: {
@@ -64,7 +73,7 @@ struct CronView: View {
} }
} }
.sheet(item: $viewModel.editingJob) { job in .sheet(item: $viewModel.editingJob) { job in
CronJobEditor(mode: .edit(job), availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir) { form in CronJobEditor(mode: .edit(job), availableSkills: viewModel.availableSkills, supportsWorkdir: hasCronWorkdir, supportsNoAgent: hasCronNoAgent) { form in
viewModel.updateJob( viewModel.updateJob(
id: job.id, id: job.id,
schedule: form.schedule, schedule: form.schedule,
@@ -75,7 +84,8 @@ struct CronView: View {
newSkills: form.skills, newSkills: form.skills,
clearSkills: form.clearSkills, clearSkills: form.clearSkills,
script: form.script, script: form.script,
workdir: hasCronWorkdir ? form.workdir : nil workdir: hasCronWorkdir ? form.workdir : nil,
noAgent: hasCronNoAgent ? form.noAgent : nil
) )
viewModel.editingJob = nil viewModel.editingJob = nil
} onCancel: { } onCancel: {
@@ -643,6 +653,9 @@ struct CronJobEditor: View {
/// v0.12+ workdir flag fills `--workdir <path>`. Empty string /// v0.12+ workdir flag fills `--workdir <path>`. Empty string
/// preserves the v0.11 behaviour of running with no cwd hint. /// preserves the v0.11 behaviour of running with no cwd hint.
var workdir: String = "" var workdir: String = ""
/// v0.13+ `--no-agent` flag script-only watchdog mode. Hermes
/// runs the pre-run script and skips the AI turn.
var noAgent: Bool = false
} }
let mode: Mode let mode: Mode
@@ -650,6 +663,10 @@ struct CronJobEditor: View {
/// Pass `false` on pre-v0.12 hosts; the `--workdir` field is hidden and /// Pass `false` on pre-v0.12 hosts; the `--workdir` field is hidden and
/// the form's value is dropped when the parent calls `createJob`/`updateJob`. /// the form's value is dropped when the parent calls `createJob`/`updateJob`.
let supportsWorkdir: Bool let supportsWorkdir: Bool
/// Pass `false` on pre-v0.13 hosts; the `--no-agent` toggle is hidden
/// and the parent strips the form's value before calling
/// `createJob`/`updateJob`. Mirrors the `supportsWorkdir` pattern.
let supportsNoAgent: Bool
let onSave: (FormState) -> Void let onSave: (FormState) -> Void
let onCancel: () -> Void let onCancel: () -> Void
@@ -681,12 +698,25 @@ struct CronJobEditor: View {
) )
.scrollContentBackground(.hidden) .scrollContentBackground(.hidden)
} }
.opacity(form.noAgent ? 0.4 : 1.0)
.disabled(form.noAgent)
formField("Deliver", text: $form.deliver, placeholder: "origin | local | discord:CHANNEL | telegram:CHAT", mono: true) formField("Deliver", text: $form.deliver, placeholder: "origin | local | discord:CHANNEL | telegram:CHAT", mono: true)
formField("Repeat", text: $form.repeatCount, placeholder: "Optional count") formField("Repeat", text: $form.repeatCount, placeholder: "Optional count")
formField("Script path", text: $form.script, placeholder: "Python script whose stdout is injected", mono: true) formField("Script path", text: $form.script, placeholder: "Python script whose stdout is injected", mono: true)
if supportsWorkdir { if supportsWorkdir {
formField("Workdir", text: $form.workdir, placeholder: "Absolute path; pulls AGENTS.md/CLAUDE.md context", mono: true) formField("Workdir", text: $form.workdir, placeholder: "Absolute path; pulls AGENTS.md/CLAUDE.md context", mono: true)
} }
if supportsNoAgent {
Toggle("Run script only (no agent call)", isOn: $form.noAgent)
.scarfStyle(.body)
.tint(ScarfColor.accent)
if form.noAgent {
Text("Watchdog mode — Hermes runs the pre-run script and skips the AI turn. Prompt + skills are ignored.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.padding(.leading, ScarfSpace.s3)
}
}
if !availableSkills.isEmpty { if !availableSkills.isEmpty {
VStack(alignment: .leading, spacing: 4) { VStack(alignment: .leading, spacing: 4) {
Text("Skills") Text("Skills")
@@ -723,6 +753,8 @@ struct CronJobEditor: View {
.tint(ScarfColor.accent) .tint(ScarfColor.accent)
} }
} }
.opacity(form.noAgent ? 0.4 : 1.0)
.disabled(form.noAgent)
} }
HStack { HStack {
Spacer() Spacer()
@@ -746,6 +778,7 @@ struct CronJobEditor: View {
form.skills = job.skills ?? [] form.skills = job.skills ?? []
form.script = job.preRunScript ?? "" form.script = job.preRunScript ?? ""
form.workdir = job.workdir ?? "" form.workdir = job.workdir ?? ""
form.noAgent = job.noAgent ?? false
} }
} }
} }
@@ -0,0 +1,122 @@
import SwiftUI
import ScarfCore
import ScarfDesign
/// Mac sub-view rendered between the active-skill leaderboards and the
/// last-report block on Hermes v0.13+ hosts. Lists everything currently
/// archived (`hermes curator list-archived`) with per-row Restore + a
/// bulk Prune affordance routed through the parent's confirm sheet.
///
/// Empty-state copy explains what archive means useful when the
/// curator hasn't run yet on a fresh install (no archives a problem).
struct CuratorArchivedSection: View {
let archived: [HermesCuratorArchivedSkill]
let isLoading: Bool
let onRestore: (String) -> Void
let onPruneAll: () -> Void
var body: some View {
ScarfCard {
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
header
if isLoading && archived.isEmpty {
loadingRow
} else if archived.isEmpty {
emptyState
} else {
rows
}
}
}
}
private var header: some View {
HStack(alignment: .firstTextBaseline) {
ScarfSectionHeader("Archived")
Spacer()
Text("\(archived.count) skill\(archived.count == 1 ? "" : "s")")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
if !archived.isEmpty {
Button("Prune All…") {
onPruneAll()
}
.buttonStyle(ScarfDestructiveButton())
.help("Remove every archived skill from disk. Cannot be undone.")
}
}
}
private var loadingRow: some View {
HStack(spacing: ScarfSpace.s2) {
ProgressView().controlSize(.small)
Text("Loading archived skills…")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
Spacer()
}
}
private var emptyState: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s1) {
Text("No archived skills.")
.scarfStyle(.body)
.foregroundStyle(ScarfColor.foregroundMuted)
Text("The curator moves stale or redundant skills here on its weekly review. Until then, this list stays empty.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
}
}
private var rows: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s1) {
ForEach(archived) { skill in
ArchivedSkillRow(
skill: skill,
onRestore: { onRestore(skill.name) }
)
}
}
}
}
private struct ArchivedSkillRow: View {
let skill: HermesCuratorArchivedSkill
let onRestore: () -> Void
var body: some View {
HStack(alignment: .center, spacing: ScarfSpace.s2) {
Image(systemName: "archivebox.fill")
.font(.system(size: 12))
.foregroundStyle(ScarfColor.foregroundFaint)
VStack(alignment: .leading, spacing: 2) {
Text(skill.name)
.scarfStyle(.body)
.foregroundStyle(ScarfColor.foregroundPrimary)
.lineLimit(1)
if let reason = skill.reason, !reason.isEmpty {
Text(reason)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.lineLimit(1)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
Text(skill.archivedAtLabel)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
.frame(width: 96, alignment: .trailing)
Text(skill.sizeLabel)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
.frame(width: 72, alignment: .trailing)
Button("Restore") {
onRestore()
}
.buttonStyle(ScarfPrimaryButton())
.controlSize(.small)
.help("Restore \(skill.name) to the active skill set")
}
.padding(.vertical, 2)
}
}
@@ -0,0 +1,123 @@
import SwiftUI
import ScarfCore
import ScarfDesign
/// Destructive-confirm sheet for `hermes curator prune` (bulk).
///
/// Pattern matches `TemplateUninstallSheet`: enumerate every entry that
/// will be removed, surface the total count + bytes, and require an
/// explicit click on a red `ScarfDestructiveButton` ("Prune
/// permanently") before kicking off the destructive call. Cancel owns
/// the keyboard default action so an accidental Enter-press doesn't
/// nuke the archive.
struct CuratorPruneConfirmSheet: View {
@Environment(\.dismiss) private var dismiss
let summary: CuratorPruneSummary
let isPruning: Bool
let onConfirm: () -> Void
let onCancel: () -> Void
var body: some View {
VStack(alignment: .leading, spacing: 0) {
header
.padding(.bottom, ScarfSpace.s2)
ScarfDivider()
ScrollView {
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
ForEach(summary.wouldRemove) { skill in
row(skill: skill)
}
if summary.wouldRemove.isEmpty {
Text("Nothing currently archived. Nothing to prune.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.padding(.vertical, ScarfSpace.s2)
}
}
.padding(.vertical, ScarfSpace.s2)
}
ScarfDivider()
footer
.padding(.top, ScarfSpace.s2)
}
.frame(minWidth: 520, minHeight: 380)
.padding(ScarfSpace.s4)
}
private var header: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s1) {
HStack(alignment: .firstTextBaseline) {
Text("Prune Archived Skills")
.scarfStyle(.title2)
.foregroundStyle(ScarfColor.foregroundPrimary)
Spacer()
if summary.totalCount > 0 {
ScarfBadge("\(summary.totalCount)", kind: .danger)
}
}
Text("This permanently deletes every archived skill from disk. Restoring an archived skill is no longer possible after pruning.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.fixedSize(horizontal: false, vertical: true)
if summary.totalBytes > 0 {
Text("Total to remove: \(summary.totalBytesLabel)")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
}
}
}
private func row(skill: HermesCuratorArchivedSkill) -> some View {
HStack(spacing: ScarfSpace.s2) {
Image(systemName: "minus.circle")
.foregroundStyle(ScarfColor.danger)
.font(.caption)
VStack(alignment: .leading, spacing: 2) {
Text(skill.name)
.scarfStyle(.body)
.foregroundStyle(ScarfColor.foregroundPrimary)
.lineLimit(1)
if let reason = skill.reason, !reason.isEmpty {
Text(reason)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
.lineLimit(1)
}
}
Spacer()
Text(skill.archivedAtLabel)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
.frame(width: 96, alignment: .trailing)
Text(skill.sizeLabel)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
.frame(width: 72, alignment: .trailing)
}
}
private var footer: some View {
HStack {
Button("Cancel") {
onCancel()
dismiss()
}
.buttonStyle(ScarfGhostButton())
// Cancel owns .defaultAction so accidental Enter-presses
// don't trigger the destructive button (template-uninstall
// pattern recommended in the WS-4 plan).
.keyboardShortcut(.defaultAction)
.disabled(isPruning)
Spacer()
if isPruning {
ProgressView().controlSize(.small)
}
Button("Prune permanently") {
onConfirm()
}
.buttonStyle(ScarfDestructiveButton())
.disabled(isPruning || summary.wouldRemove.isEmpty)
.accessibilityIdentifier("curatorPrune.confirm")
}
}
}
@@ -2,18 +2,16 @@ import SwiftUI
import ScarfCore import ScarfCore
import ScarfDesign import ScarfDesign
/// Modal that lists archived skills (state active) and exposes a /// Legacy v0.12 fallback for restoring an archived skill by typed
/// one-click "Restore" action per row. v0.12 archives are recoverable /// name. Hermes v0.12 didn't ship `curator list-archived`, so the only
/// `hermes curator restore <name>` brings the skill back into /// way to restore was to remember the skill name and pass it through
/// `~/.hermes/skills/<category>/<name>/` and re-marks it active. /// `hermes curator restore <name>`.
/// ///
/// The Curator's `status` text doesn't enumerate archived skills with /// **v0.13+ flow (preferred):** `CuratorArchivedSection` renders a
/// names; we surface what's available (counts + pinned list) and rely /// per-skill list with a one-click Restore button per row no typing
/// on the user knowing the names. Hermes ergo does an interactive /// required. This sheet stays reachable from the overflow menu only on
/// `--name` arg if missing but Scarf prefers explicit selection so /// pre-v0.13 hosts (gated by `!hasCuratorArchive`). Don't delete this
/// users don't have to remember names. For v2.6 we render a free-form /// file even after WS-4 ships; v0.12 hosts still depend on it.
/// text field; once Hermes ships a `curator list-archived` (tracked
/// upstream), swap to a pickable list.
struct CuratorRestoreSheet: View { struct CuratorRestoreSheet: View {
let viewModel: CuratorViewModel let viewModel: CuratorViewModel
@@ -2,57 +2,52 @@ import SwiftUI
import ScarfCore import ScarfCore
import ScarfDesign import ScarfDesign
/// Mac UI for Hermes v0.12's autonomous skill curator. /// Mac UI for Hermes's autonomous skill curator (v0.12 base + v0.13
/// archive/prune surface).
/// ///
/// Surfaces the running state (enabled / paused / disabled), last-run /// Surfaces the running state (enabled / paused / disabled), last-run
/// metadata, agent-created skill counts, and the most/least-active / /// metadata, agent-created skill counts, the most/least-active /
/// least-recently-active leaderboards. Pin-and-restore actions hit /// least-recently-active leaderboards, and on v0.13+ hosts the new
/// `hermes curator pin/unpin/restore` via CuratorViewModel. /// archived-skills section + per-row Archive button on each leaderboard
/// entry. Pin / unpin / restore / archive / prune route through
/// CuratorViewModel CuratorService.
/// ///
/// Capability-gated upstream: AppCoordinator only wires the sidebar /// Capability-gated upstream: AppCoordinator only wires the sidebar
/// item when `HermesCapabilities.hasCurator` is true. This view assumes /// item when `HermesCapabilities.hasCurator` is true. Archive surfaces
/// it's reachable on a v0.12+ host. /// gate independently on `hasCuratorArchive`; pre-v0.13 hosts see the
/// v2.7.x layout unchanged (legacy `CuratorRestoreSheet` reachable from
/// the overflow menu, no Archive section, fire-and-forget Run Now).
struct CuratorView: View { struct CuratorView: View {
@State private var viewModel: CuratorViewModel @State private var viewModel: CuratorViewModel
@State private var showRestoreSheet = false @State private var showRestoreSheet = false
@Environment(\.hermesCapabilities) private var capabilitiesStore
init(context: ServerContext) { init(context: ServerContext) {
_viewModel = State(initialValue: CuratorViewModel(context: context)) _viewModel = State(initialValue: CuratorViewModel(context: context))
} }
/// Single source of truth for "v0.13 archive surface visible". Read
/// once in `body` and threaded into sub-views. Defensive default to
/// `false` so previews / smoke tests behave like a pre-v0.13 host.
private var archiveAvailable: Bool {
capabilitiesStore?.capabilities.hasCuratorArchive ?? false
}
var body: some View { var body: some View {
ScrollView { ScrollView {
VStack(alignment: .leading, spacing: ScarfSpace.s4) { VStack(alignment: .leading, spacing: ScarfSpace.s4) {
ScarfPageHeader( ScarfPageHeader(
"Curator", "Curator",
subtitle: "Autonomous skill maintenance — Hermes v0.12+" subtitle: archiveAvailable
? "Autonomous skill maintenance — archive, prune, restore"
: "Autonomous skill maintenance — Hermes v0.12+"
) { ) {
HStack(spacing: ScarfSpace.s2) { headerActions
if viewModel.isLoading { }
ProgressView().controlSize(.small)
} if let errorMessage = viewModel.errorMessage {
Button("Run Now") { errorBanner(errorMessage)
Task { await viewModel.runNow() }
}
.buttonStyle(ScarfPrimaryButton())
.disabled(viewModel.isLoading)
Menu {
switch viewModel.status.state {
case .paused:
Button("Resume") { Task { await viewModel.resume() } }
case .enabled:
Button("Pause") { Task { await viewModel.pause() } }
default:
EmptyView()
}
Button("Restore Archived…") {
showRestoreSheet = true
}
.disabled(viewModel.status.archivedSkills == 0)
} label: {
Image(systemName: "ellipsis.circle")
}
}
} }
if let toast = viewModel.transientMessage { if let toast = viewModel.transientMessage {
@@ -64,6 +59,19 @@ struct CuratorView: View {
pinnedSection pinnedSection
activityTables activityTables
if archiveAvailable {
CuratorArchivedSection(
archived: viewModel.archivedSkills,
isLoading: viewModel.isLoadingArchive,
onRestore: { name in
Task { await viewModel.restore(name) }
},
onPruneAll: {
Task { await viewModel.planPrune() }
}
)
}
if let report = viewModel.lastReportMarkdown { if let report = viewModel.lastReportMarkdown {
lastReportSection(markdown: report) lastReportSection(markdown: report)
} }
@@ -71,10 +79,84 @@ struct CuratorView: View {
.padding(ScarfSpace.s4) .padding(ScarfSpace.s4)
} }
.background(ScarfColor.backgroundPrimary) .background(ScarfColor.backgroundPrimary)
.task { await viewModel.load() } .task {
await viewModel.load()
if archiveAvailable {
await viewModel.loadArchive()
}
}
.sheet(isPresented: $showRestoreSheet) { .sheet(isPresented: $showRestoreSheet) {
CuratorRestoreSheet(viewModel: viewModel) CuratorRestoreSheet(viewModel: viewModel)
} }
.sheet(
isPresented: Binding(
get: { viewModel.pruneSummary != nil },
set: { isShown in
if !isShown { viewModel.cancelPrune() }
}
)
) {
if let summary = viewModel.pruneSummary {
CuratorPruneConfirmSheet(
summary: summary,
isPruning: viewModel.isPruning,
onConfirm: {
Task { await viewModel.confirmPrune() }
},
onCancel: {
viewModel.cancelPrune()
}
)
}
}
}
@ViewBuilder
private var headerActions: some View {
HStack(spacing: ScarfSpace.s2) {
if viewModel.isLoading {
ProgressView().controlSize(.small)
}
Button("Run Now") {
Task {
await viewModel.runNow(
synchronous: archiveAvailable,
timeout: 600
)
}
}
.buttonStyle(ScarfPrimaryButton())
.disabled(viewModel.isLoading)
.help(archiveAvailable
? "Curator runs synchronously on Hermes v0.13+. Usually 1090s."
: "Trigger a curator run. Returns immediately on pre-v0.13 hosts.")
Menu {
switch viewModel.status.state {
case .paused:
Button("Resume") { Task { await viewModel.resume() } }
case .enabled:
Button("Pause") { Task { await viewModel.pause() } }
default:
EmptyView()
}
if archiveAvailable {
Divider()
Button("Prune Archived…", role: .destructive) {
Task { await viewModel.planPrune() }
}
.disabled(viewModel.archivedSkills.isEmpty && !viewModel.isLoadingArchive)
} else {
Button("Restore Archived…") {
showRestoreSheet = true
}
.disabled(viewModel.status.archivedSkills == 0)
}
} label: {
Image(systemName: "ellipsis.circle")
}
}
} }
private var statusSummary: some View { private var statusSummary: some View {
@@ -206,6 +288,10 @@ struct CuratorView: View {
} }
.buttonStyle(.plain) .buttonStyle(.plain)
.help(viewModel.status.pinnedNames.contains(row.name) ? "Pinned" : "Pin skill") .help(viewModel.status.pinnedNames.contains(row.name) ? "Pinned" : "Pin skill")
if archiveAvailable {
archiveButton(for: row.name)
}
} }
.padding(.vertical, 2) .padding(.vertical, 2)
} }
@@ -213,6 +299,25 @@ struct CuratorView: View {
} }
} }
@ViewBuilder
private func archiveButton(for name: String) -> some View {
if viewModel.pendingArchiveName == name {
ProgressView()
.controlSize(.small)
.frame(width: 14, height: 14)
} else {
Button {
Task { await viewModel.archive(name) }
} label: {
Image(systemName: "archivebox")
.font(.system(size: 12))
}
.buttonStyle(.plain)
.help("Archive (move out of active set)")
.disabled(viewModel.pendingArchiveName != nil)
}
}
private func counterChip(label: String, value: Int) -> some View { private func counterChip(label: String, value: Int) -> some View {
Text("\(label) \(value)") Text("\(label) \(value)")
.font(ScarfFont.monoSmall) .font(ScarfFont.monoSmall)
@@ -277,6 +382,35 @@ struct CuratorView: View {
.background(ScarfColor.accentTint) .background(ScarfColor.accentTint)
.clipShape(RoundedRectangle(cornerRadius: ScarfRadius.md)) .clipShape(RoundedRectangle(cornerRadius: ScarfRadius.md))
} }
/// Inline yellow banner for CLI failures. Non-blocking sits above
/// the status summary and dismisses with the "x" so users can keep
/// interacting with the leaderboard. Mirrors the pattern in
/// KanbanBoardView.
private func errorBanner(_ message: String) -> some View {
HStack(alignment: .top, spacing: ScarfSpace.s2) {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(ScarfColor.warning)
Text(message)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundPrimary)
.frame(maxWidth: .infinity, alignment: .leading)
Button {
viewModel.dismissError()
} label: {
Image(systemName: "xmark.circle.fill")
.foregroundStyle(ScarfColor.foregroundMuted)
}
.buttonStyle(.plain)
.help("Dismiss")
}
.padding(.horizontal, ScarfSpace.s3)
.padding(.vertical, ScarfSpace.s2)
.background(
RoundedRectangle(cornerRadius: ScarfRadius.md)
.fill(ScarfColor.warning.opacity(0.12))
)
}
} }
/// Simple `FlowLayout` for the pinned-skill chips. Custom layout /// Simple `FlowLayout` for the pinned-skill chips. Custom layout
@@ -7,6 +7,18 @@ final class DashboardViewModel {
private let dataService: HermesDataService private let dataService: HermesDataService
private let fileService: HermesFileService private let fileService: HermesFileService
/// Single in-flight load handle. The `.onChange(fileWatcher.lastChangeDate)`
/// observer in `DashboardView` plus `.task` on first appear can both
/// fire concurrent loads and on v0.13 hosts the FSEvents tick rate
/// during gateway activity used to be high enough that 5+ loads
/// stacked inside 200 ms (HermesFileWatcher's coalesce window now
/// handles that, but defending here keeps the behaviour deterministic
/// on any future watcher chattiness). When a load is in flight,
/// subsequent triggers no-op; the in-flight load already has a
/// recent-enough snapshot for the user.
@ObservationIgnored
private var inFlightLoad: Task<Void, Never>?
init(context: ServerContext = .local) { init(context: ServerContext = .local) {
self.context = context self.context = context
self.dataService = HermesDataService(context: context) self.dataService = HermesDataService(context: context)
@@ -42,6 +54,27 @@ final class DashboardViewModel {
var hermesShadows: [ProjectHermesShadowDetector.Shadow] = [] var hermesShadows: [ProjectHermesShadowDetector.Shadow] = []
func load() async { func load() async {
// Coalesce overlapping triggers: the `.task` first-appear and the
// `.onChange(fileWatcher.lastChangeDate)` observer can both fire
// a load in the same tick. Without this guard a Hermes v0.13
// host's WAL-write storm walked over the previous load
// mid-snapshot (see `HermesFileWatcher.scheduleCoalescedTick`).
// If a load is already running, await its completion and return
// the caller already has a fresh snapshot by the time `await`
// returns.
if let existing = inFlightLoad {
await existing.value
return
}
let task: Task<Void, Never> = Task { @MainActor [weak self] in
await self?.loadImpl()
}
inFlightLoad = task
await task.value
inFlightLoad = nil
}
private func loadImpl() async {
isLoading = true isLoading = true
// refresh() is essentially free for the streaming remote backend // refresh() is essentially free for the streaming remote backend
// (no transfer every query is fresh) and a cheap reopen for // (no transfer every query is fresh) and a cheap reopen for
@@ -1,7 +1,13 @@
import Foundation import Foundation
import ScarfCore import ScarfCore
struct GatewayInfo { // **Local rename for v0.13 / WS-5.** The user-facing label is "Messaging
// Gateway"; the type names mirror that. The `SidebarSection.gateway` enum
// case + `gateway_state.json` / `gateway.log` paths intentionally stay
// unchanged those aren't user-facing strings, and renaming them would
// churn unrelated callers without changing what users see.
struct MessagingGatewayInfo {
let pid: Int? let pid: Int?
let state: String let state: String
let exitReason: String? let exitReason: String?
@@ -37,32 +43,48 @@ struct PendingPairing: Identifiable {
} }
@Observable @Observable
final class GatewayViewModel { @MainActor
final class MessagingGatewayViewModel {
let context: ServerContext let context: ServerContext
/// Capability snapshot at view-init time. Read for the v0.13 cross-
/// profile digest (`hasGatewayList`); other v0.13 surfaces live on
/// per-platform setup views. `.empty` is fine outside the per-server
/// `ContextBoundRoot` (Previews, smoke tests).
let capabilities: HermesCapabilities
init(context: ServerContext = .local) { init(context: ServerContext = .local, capabilities: HermesCapabilities = .empty) {
self.context = context self.context = context
self.capabilities = capabilities
} }
var gateway = GatewayInfo(pid: nil, state: "unknown", exitReason: nil, startTime: nil, updatedAt: nil, platforms: [], isLoaded: false, isStale: false) var gateway = MessagingGatewayInfo(pid: nil, state: "unknown", exitReason: nil, startTime: nil, updatedAt: nil, platforms: [], isLoaded: false, isStale: false)
var approvedUsers: [PairedUser] = [] var approvedUsers: [PairedUser] = []
var pendingPairings: [PendingPairing] = [] var pendingPairings: [PendingPairing] = []
var isLoading = false var isLoading = false
var actionMessage: String? var actionMessage: String?
/// `hermes gateway list --json` snapshot. `nil` when the verb fails
/// (pre-v0.13 host or no profiles registered yet) the digest row
/// hides itself in that case.
var gatewayList: GatewayListSnapshot?
func load() { func load() {
isLoading = true isLoading = true
let ctx = context let ctx = context
let caps = capabilities
Task.detached { [weak self] in Task.detached { [weak self] in
// Two sync transport calls + two CLI invocations substantial // Two sync transport calls + two CLI invocations substantial
// remote latency. Detach the whole load and commit at the end. // remote latency. Detach the whole load and commit at the end.
let status = Self.fetchGatewayStatus(context: ctx) let status = Self.fetchGatewayStatus(context: ctx)
let pairing = Self.fetchPairing(context: ctx) let pairing = Self.fetchPairing(context: ctx)
let listSnap = caps.hasGatewayList
? HermesGatewayListService.fetch(context: ctx)
: nil
await MainActor.run { [weak self] in await MainActor.run { [weak self] in
guard let self else { return } guard let self else { return }
self.gateway = status self.gateway = status
self.approvedUsers = pairing.approved self.approvedUsers = pairing.approved
self.pendingPairings = pairing.pending self.pendingPairings = pairing.pending
self.gatewayList = listSnap
self.isLoading = false self.isLoading = false
} }
} }
@@ -70,7 +92,7 @@ final class GatewayViewModel {
/// Static form of the gateway-status walk so the detached load can call /// Static form of the gateway-status walk so the detached load can call
/// it without bouncing back to MainActor. /// it without bouncing back to MainActor.
nonisolated private static func fetchGatewayStatus(context: ServerContext) -> GatewayInfo { nonisolated private static func fetchGatewayStatus(context: ServerContext) -> MessagingGatewayInfo {
let stateJSON = context.readData(context.paths.gatewayStateJSON) let stateJSON = context.readData(context.paths.gatewayStateJSON)
var pid: Int? var pid: Int?
var state = "unknown" var state = "unknown"
@@ -102,7 +124,7 @@ final class GatewayViewModel {
let isLoaded = statusOutput.contains("service is loaded") let isLoaded = statusOutput.contains("service is loaded")
let isStale = statusOutput.contains("stale") let isStale = statusOutput.contains("stale")
return GatewayInfo( return MessagingGatewayInfo(
pid: pid, state: state, exitReason: exitReason, pid: pid, state: state, exitReason: exitReason,
startTime: startTime, updatedAt: updatedAt, startTime: startTime, updatedAt: updatedAt,
platforms: platforms, isLoaded: isLoaded, isStale: isStale platforms: platforms, isLoaded: isLoaded, isStale: isStale
@@ -2,12 +2,24 @@ import SwiftUI
import ScarfCore import ScarfCore
import ScarfDesign import ScarfDesign
/// Messaging Gateway page. Routes outbound chat to Discord / Telegram /
/// Slack / etc. distinct from the v0.10 **Tool Gateway** (Nous Portal
/// subscription routing for web search / image / TTS / browser), which
/// lives under `Features/Health/`. The user-facing label here is always
/// "Messaging Gateway"; the SwiftUI struct stays `GatewayView` because
/// `ContentView` references it by name (rename-on-touch invariant
/// avoid churning unrelated callers).
struct GatewayView: View { struct GatewayView: View {
@State private var viewModel: GatewayViewModel @State private var viewModel: MessagingGatewayViewModel
@Environment(HermesFileWatcher.self) private var fileWatcher @Environment(HermesFileWatcher.self) private var fileWatcher
@Environment(\.hermesCapabilities) private var capabilitiesStore
init(context: ServerContext) { init(context: ServerContext) {
_viewModel = State(initialValue: GatewayViewModel(context: context)) // Capabilities arrive via environment after init runs, so the VM
// is constructed with `.empty` and refreshed on first appear via
// `attach(capabilities:)`. Same pattern as the per-platform setup
// views see `MessagingGatewayViewModel.capabilities` doc comment.
_viewModel = State(initialValue: MessagingGatewayViewModel(context: context))
} }
@@ -15,10 +27,15 @@ struct GatewayView: View {
VStack(spacing: 0) { VStack(spacing: 0) {
ScarfPageHeader( ScarfPageHeader(
"Messaging Gateway", "Messaging Gateway",
subtitle: "Outbound channel bridge — Discord, Telegram, Slack, etc." subtitle: "Outbound channel bridge — Discord, Telegram, Slack, Google Chat, etc."
) )
ScrollView { ScrollView {
VStack(alignment: .leading, spacing: 24) { VStack(alignment: .leading, spacing: ScarfSpace.s4) {
if let snap = viewModel.gatewayList,
viewModel.capabilities.hasGatewayList,
!snap.profiles.isEmpty {
crossProfileDigest(snap)
}
serviceSection serviceSection
platformsSection platformsSection
pairingSection pairingSection
@@ -29,14 +46,58 @@ struct GatewayView: View {
} }
.background(ScarfColor.backgroundPrimary) .background(ScarfColor.backgroundPrimary)
.navigationTitle("Messaging Gateway") .navigationTitle("Messaging Gateway")
.onAppear { viewModel.load() } .onAppear {
attachCapabilitiesIfNeeded()
viewModel.load()
}
.onChange(of: fileWatcher.lastChangeDate) { viewModel.load() } .onChange(of: fileWatcher.lastChangeDate) { viewModel.load() }
} }
/// Re-create the VM with the resolved capabilities the first time the
/// store hands us non-empty data. Same shape as `KanbanBoardView`'s
/// `attach` helper.
private func attachCapabilitiesIfNeeded() {
guard let store = capabilitiesStore,
store.capabilities.detected,
!viewModel.capabilities.detected else { return }
viewModel = MessagingGatewayViewModel(
context: viewModel.context,
capabilities: store.capabilities
)
}
// MARK: - v0.13 cross-profile digest
/// One-line summary above the gateway controls when the host is on
/// v0.13+ and `hermes gateway list --json` returned at least one
/// profile. Doubly-guarded `hasGatewayList` AND `profiles != []`
/// so a v0.13 host with no registered profiles doesn't render
/// an empty pill.
private func crossProfileDigest(_ snap: GatewayListSnapshot) -> some View {
HStack(spacing: ScarfSpace.s2) {
Image(systemName: "dot.radiowaves.left.and.right")
.foregroundStyle(ScarfColor.accent)
Text(snap.headerDigest)
.scarfStyle(.captionStrong)
.foregroundStyle(ScarfColor.foregroundPrimary)
Spacer()
}
.padding(.horizontal, ScarfSpace.s3)
.padding(.vertical, ScarfSpace.s2)
.background(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.fill(ScarfColor.backgroundSecondary)
)
.overlay(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.strokeBorder(ScarfColor.border, lineWidth: 1)
)
}
// MARK: - Service // MARK: - Service
private var serviceSection: some View { private var serviceSection: some View {
VStack(alignment: .leading, spacing: 12) { VStack(alignment: .leading, spacing: ScarfSpace.s3) {
HStack { HStack {
Text("Service") Text("Service")
.font(.headline) .font(.headline)
@@ -46,15 +107,20 @@ struct GatewayView: View {
.font(.caption) .font(.caption)
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} }
HStack(spacing: 8) { HStack(spacing: ScarfSpace.s2) {
Button("Start") { viewModel.startGateway() } Button("Start") { viewModel.startGateway() }
.buttonStyle(ScarfPrimaryButton())
.controlSize(.small)
Button("Stop") { viewModel.stopGateway() } Button("Stop") { viewModel.stopGateway() }
.buttonStyle(ScarfSecondaryButton())
.controlSize(.small)
Button("Restart") { viewModel.restartGateway() } Button("Restart") { viewModel.restartGateway() }
.buttonStyle(ScarfSecondaryButton())
.controlSize(.small)
} }
.controlSize(.small)
} }
HStack(spacing: 16) { HStack(spacing: ScarfSpace.s3) {
StatusBadge( StatusBadge(
label: viewModel.gateway.state, label: viewModel.gateway.state,
isActive: viewModel.gateway.state == "running" isActive: viewModel.gateway.state == "running"
@@ -97,7 +163,7 @@ struct GatewayView: View {
// MARK: - Platforms // MARK: - Platforms
private var platformsSection: some View { private var platformsSection: some View {
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: ScarfSpace.s2) {
Text("Platforms") Text("Platforms")
.font(.headline) .font(.headline)
if viewModel.gateway.platforms.isEmpty { if viewModel.gateway.platforms.isEmpty {
@@ -105,7 +171,7 @@ struct GatewayView: View {
.font(.caption) .font(.caption)
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} else { } else {
HStack(spacing: 12) { HStack(spacing: ScarfSpace.s3) {
ForEach(viewModel.gateway.platforms) { platform in ForEach(viewModel.gateway.platforms) { platform in
VStack(spacing: 6) { VStack(spacing: 6) {
Image(systemName: platform.icon) Image(systemName: platform.icon)
@@ -119,9 +185,9 @@ struct GatewayView: View {
) )
} }
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.padding(12) .padding(ScarfSpace.s3)
.background(.quaternary.opacity(0.5)) .background(.quaternary.opacity(0.5))
.clipShape(RoundedRectangle(cornerRadius: 8)) .clipShape(RoundedRectangle(cornerRadius: ScarfRadius.md))
} }
} }
} }
@@ -131,12 +197,12 @@ struct GatewayView: View {
// MARK: - Pairing // MARK: - Pairing
private var pairingSection: some View { private var pairingSection: some View {
VStack(alignment: .leading, spacing: 12) { VStack(alignment: .leading, spacing: ScarfSpace.s3) {
Text("Paired Users") Text("Paired Users")
.font(.headline) .font(.headline)
if !viewModel.pendingPairings.isEmpty { if !viewModel.pendingPairings.isEmpty {
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: ScarfSpace.s2) {
Label("Pending Approvals", systemImage: "clock.badge.questionmark") Label("Pending Approvals", systemImage: "clock.badge.questionmark")
.font(.caption.bold()) .font(.caption.bold())
.foregroundStyle(.orange) .foregroundStyle(.orange)
@@ -150,12 +216,12 @@ struct GatewayView: View {
viewModel.approvePairing(platform: pending.platform, code: pending.code) viewModel.approvePairing(platform: pending.platform, code: pending.code)
} }
.controlSize(.small) .controlSize(.small)
.buttonStyle(.borderedProminent) .buttonStyle(ScarfPrimaryButton())
} }
.font(.caption) .font(.caption)
.padding(8) .padding(ScarfSpace.s2)
.background(.orange.opacity(0.1)) .background(.orange.opacity(0.1))
.clipShape(RoundedRectangle(cornerRadius: 6)) .clipShape(RoundedRectangle(cornerRadius: ScarfRadius.sm))
} }
} }
} }
@@ -182,9 +248,9 @@ struct GatewayView: View {
} }
.controlSize(.small) .controlSize(.small)
} }
.padding(8) .padding(ScarfSpace.s2)
.background(.quaternary.opacity(0.3)) .background(.quaternary.opacity(0.3))
.clipShape(RoundedRectangle(cornerRadius: 6)) .clipShape(RoundedRectangle(cornerRadius: ScarfRadius.sm))
} }
} }
} }
@@ -55,9 +55,22 @@ final class KanbanBoardViewModel {
var assigneeFilter: String? // nil = all assignees var assigneeFilter: String? // nil = all assignees
var showArchived: Bool = false var showArchived: Bool = false
/// Optimistic moves keyed by task id; cleared when the polled /// Optimistic in-flight overrides keyed by task id; cleared when the
/// response includes the same status the optimistic move set. /// polled response confirms the new state.
private var optimisticOverrides: [String: String] = [:] /// - Status side: drag-drop column moves.
/// - Hallucination-gate side (v0.13): Verify clicks flip `pending`
/// `verified` locally so the banner disappears immediately.
/// The override entry is dropped from the dictionary entirely once
/// both sides are nil (no override needed).
private struct OptimisticOverride {
var status: String?
var hallucinationGate: KanbanHallucinationGate?
var isEmpty: Bool {
status == nil && hallucinationGate == nil
}
}
private var optimisticOverrides: [String: OptimisticOverride] = [:]
/// Tasks dropped into invalid columns produce a transient "denied" /// Tasks dropped into invalid columns produce a transient "denied"
/// banner. Stored as an explicit error to support the Cmd-Z style /// banner. Stored as an explicit error to support the Cmd-Z style
/// undo we don't ship in v2.7.5 but want to leave room for. /// undo we don't ship in v2.7.5 but want to leave room for.
@@ -177,8 +190,10 @@ final class KanbanBoardViewModel {
// Optimistic mutation flip the local row's status to a // Optimistic mutation flip the local row's status to a
// value within the destination column's range. We pick a // value within the destination column's range. We pick a
// representative status per column. // representative status per column.
let optimisticStatus = optimisticStatus(for: destination) let optimisticStatusValue = optimisticStatus(for: destination)
optimisticOverrides[taskId] = optimisticStatus var override = optimisticOverrides[taskId] ?? OptimisticOverride()
override.status = optimisticStatusValue
optimisticOverrides[taskId] = override
let svc = service let svc = service
Task { Task {
@@ -190,11 +205,11 @@ final class KanbanBoardViewModel {
// without waiting for the 5s tick. // without waiting for the 5s tick.
await refresh() await refresh()
} catch let err as KanbanError { } catch let err as KanbanError {
optimisticOverrides.removeValue(forKey: taskId) clearStatusOverride(for: taskId)
lastError = err.errorDescription lastError = err.errorDescription
logger.warning("kanban move failed: \(err.errorDescription ?? "", privacy: .public)") logger.warning("kanban move failed: \(err.errorDescription ?? "", privacy: .public)")
} catch { } catch {
optimisticOverrides.removeValue(forKey: taskId) clearStatusOverride(for: taskId)
lastError = error.localizedDescription lastError = error.localizedDescription
} }
} }
@@ -269,6 +284,48 @@ final class KanbanBoardViewModel {
return task return task
} }
// MARK: - Hallucination gate (v0.13)
/// User confirmed the worker-created card is real. Optimistically
/// flip the gate to `verified` so the banner disappears immediately;
/// the polling loop confirms the new state on the next tick. On
/// failure (e.g. the verb name is wrong on this v0.13.x build), the
/// override is cleared and the error surfaces in `lastError`.
func verifyHallucination(taskId: String) {
var override = optimisticOverrides[taskId] ?? OptimisticOverride()
override.hallucinationGate = .verified
optimisticOverrides[taskId] = override
Task {
do {
try await service.verify(taskId: taskId)
await refresh()
} catch let err as KanbanError {
clearHallucinationOverride(for: taskId)
lastError = err.errorDescription
logger.warning("kanban verify failed: \(err.errorDescription ?? "", privacy: .public)")
} catch {
clearHallucinationOverride(for: taskId)
lastError = error.localizedDescription
}
}
}
/// User rejected the worker-created card as a hallucinated reference.
/// Routes through `comment` + `archive` per `KanbanService.rejectHallucinated`
/// so there's an audit trail for why the card disappeared.
func rejectHallucination(taskId: String) {
Task {
do {
try await service.rejectHallucinated(taskId: taskId)
await refresh()
} catch let err as KanbanError {
lastError = err.errorDescription
} catch {
lastError = error.localizedDescription
}
}
}
// MARK: - Private helpers // MARK: - Private helpers
private func mergePolledTasks(_ polled: [HermesKanbanTask]) { private func mergePolledTasks(_ polled: [HermesKanbanTask]) {
@@ -282,25 +339,75 @@ final class KanbanBoardViewModel {
filtered = polled filtered = polled
} }
let presentIds = Set(filtered.map(\.id)) let presentIds = Set(filtered.map(\.id))
// Drop optimistic overrides for tasks Hermes confirmed. // Drop optimistic overrides for tasks Hermes confirmed. Two
for (id, optimistic) in optimisticOverrides { // independent sides clear them separately so a Verify click
if let row = filtered.first(where: { $0.id == id }) { // still in-flight survives a status-side poll confirmation, and
if columnFromStatus(optimistic) == columnFromStatus(row.status) { // vice versa.
for (id, override) in optimisticOverrides {
guard let row = filtered.first(where: { $0.id == id }) else {
if !presentIds.contains(id) {
// Task no longer in the polled set (archived, deleted,
// or filtered out). Drop the override entirely.
optimisticOverrides.removeValue(forKey: id) optimisticOverrides.removeValue(forKey: id)
} }
} else if !presentIds.contains(id) { continue
// Task no longer in the polled set (archived, deleted, }
// or filtered out). Drop the optimistic entry. // Status side optimistic move confirmed.
if let optStatus = override.status,
columnFromStatus(optStatus) == columnFromStatus(row.status) {
optimisticOverrides[id]?.status = nil
}
// Hallucination-gate side optimistic verify/reject confirmed.
if let optGate = override.hallucinationGate,
KanbanHallucinationGate.from(row.hallucinationGateStatus) == optGate {
optimisticOverrides[id]?.hallucinationGate = nil
}
if optimisticOverrides[id]?.isEmpty ?? true {
optimisticOverrides.removeValue(forKey: id) optimisticOverrides.removeValue(forKey: id)
} }
} }
tasks = filtered tasks = filtered
} }
/// Drop the status side of a task's override (preserving any
/// in-flight hallucination-gate optimistic state).
private func clearStatusOverride(for taskId: String) {
guard var override = optimisticOverrides[taskId] else { return }
override.status = nil
if override.isEmpty {
optimisticOverrides.removeValue(forKey: taskId)
} else {
optimisticOverrides[taskId] = override
}
}
/// Drop the hallucination-gate side of a task's override (preserving
/// any in-flight status-side drag-drop).
private func clearHallucinationOverride(for taskId: String) {
guard var override = optimisticOverrides[taskId] else { return }
override.hallucinationGate = nil
if override.isEmpty {
optimisticOverrides.removeValue(forKey: taskId)
} else {
optimisticOverrides[taskId] = override
}
}
/// Effective hallucination gate for a task the optimistic override
/// wins if one is in flight; otherwise the polled value. View code
/// reads through this so the banner / dim state matches the moment-
/// after-click experience.
func effectiveHallucinationGate(_ task: HermesKanbanTask) -> KanbanHallucinationGate? {
if let override = optimisticOverrides[task.id]?.hallucinationGate {
return override
}
return KanbanHallucinationGate.from(task.hallucinationGateStatus)
}
/// Return the effective board column for a task the optimistic /// Return the effective board column for a task the optimistic
/// override wins if one is in flight; otherwise the polled status. /// override wins if one is in flight; otherwise the polled status.
private func effectiveColumn(_ task: HermesKanbanTask) -> KanbanBoardColumn { private func effectiveColumn(_ task: HermesKanbanTask) -> KanbanBoardColumn {
if let overrideStatus = optimisticOverrides[task.id] { if let overrideStatus = optimisticOverrides[task.id]?.status {
return columnFromStatus(overrideStatus) return columnFromStatus(overrideStatus)
} }
return columnFromStatus(task.status) return columnFromStatus(task.status)
@@ -13,6 +13,7 @@ import ScarfDesign
/// tenant. /// tenant.
struct KanbanBoardView: View { struct KanbanBoardView: View {
@State private var viewModel: KanbanBoardViewModel @State private var viewModel: KanbanBoardViewModel
@Environment(\.hermesCapabilities) private var capabilitiesStore
/// When non-nil, a project board hosts this view. Drives header /// When non-nil, a project board hosts this view. Drives header
/// chrome (subtitle, hidden tenant filter) and create-sheet /// chrome (subtitle, hidden tenant filter) and create-sheet
@@ -33,6 +34,15 @@ struct KanbanBoardView: View {
self.projectName = projectName self.projectName = projectName
} }
/// Convenience read for the v0.13 diagnostics flag gates the
/// max_retries field, hallucination banner, diagnostics rendering,
/// and the auto-blocked reason banner. Pre-v0.13 hosts get the
/// v2.7.5 surface unchanged. Treats a missing store as "off" so
/// harness contexts (Previews) don't accidentally surface gated UI.
private var supportsKanbanDiagnostics: Bool {
capabilitiesStore?.capabilities.hasKanbanDiagnostics ?? false
}
@State private var inspectorTaskId: String? @State private var inspectorTaskId: String?
@State private var showingCreateSheet = false @State private var showingCreateSheet = false
@State private var blockSheetTaskId: String? @State private var blockSheetTaskId: String?
@@ -71,7 +81,8 @@ struct KanbanBoardView: View {
KanbanCreateSheet( KanbanCreateSheet(
assignees: viewModel.assignees, assignees: viewModel.assignees,
tenantPrefill: viewModel.tenantFilter, tenantPrefill: viewModel.tenantFilter,
projectWorkspacePath: viewModel.projectPath projectWorkspacePath: viewModel.projectPath,
supportsKanbanDiagnostics: supportsKanbanDiagnostics
) { request in ) { request in
_ = try await viewModel.createTask(request) _ = try await viewModel.createTask(request)
} }
@@ -188,7 +199,9 @@ struct KanbanBoardView: View {
onDrop: { ref in onDrop: { ref in
handleDrop(ref.id, on: column) handleDrop(ref.id, on: column)
}, },
canCreate: column == .upNext || column == .triage canCreate: column == .upNext || column == .triage,
supportsKanbanDiagnostics: supportsKanbanDiagnostics,
effectiveHallucinationGate: { viewModel.effectiveHallucinationGate($0) }
) )
} }
Spacer(minLength: ScarfSpace.s4) Spacer(minLength: ScarfSpace.s4)
@@ -208,6 +221,8 @@ struct KanbanBoardView: View {
service: viewModel.service, service: viewModel.service,
taskId: taskId, taskId: taskId,
availableAssignees: viewModel.assignees, availableAssignees: viewModel.assignees,
supportsKanbanDiagnostics: supportsKanbanDiagnostics,
effectiveHallucinationGate: { viewModel.effectiveHallucinationGate($0) },
onClose: { inspectorTaskId = nil }, onClose: { inspectorTaskId = nil },
onClaim: { onClaim: {
viewModel.attemptMove(taskId: taskId, to: .running) viewModel.attemptMove(taskId: taskId, to: .running)
@@ -232,6 +247,15 @@ struct KanbanBoardView: View {
}, },
onReassign: { profile in onReassign: { profile in
viewModel.reassignTask(taskId: taskId, to: profile) viewModel.reassignTask(taskId: taskId, to: profile)
},
onVerifyHallucination: {
viewModel.verifyHallucination(taskId: taskId)
},
onRejectHallucination: {
viewModel.rejectHallucination(taskId: taskId)
// Card vanishes from active board after archive close
// the inspector so it doesn't dangle on a deleted task.
inspectorTaskId = nil
} }
) )
} }
@@ -24,12 +24,40 @@ struct KanbanTaskRef: Transferable {
/// - **Running** gets a blue left-edge accent + live shimmer /// - **Running** gets a blue left-edge accent + live shimmer
/// - **Blocked** gets a warning left-edge accent + glyph /// - **Blocked** gets a warning left-edge accent + glyph
/// - **Done** dims to 0.7 opacity (0.55 in dark mode) /// - **Done** dims to 0.7 opacity (0.55 in dark mode)
/// - **Hallucination-gate pending** (v0.13+) dims to 0.6 + glyph and
/// shows a one-line auto-blocked reason in the footer when present.
struct KanbanCardView: View { struct KanbanCardView: View {
let task: HermesKanbanTask let task: HermesKanbanTask
let onTap: () -> Void let onTap: () -> Void
/// True when the connected Hermes is on v0.13+ gates the
/// hallucination dim/glyph, auto-block sub-line, and diagnostics
/// dot on the card. Pre-v0.13 hosts see the v2.7.5 chrome unchanged.
let supportsKanbanDiagnostics: Bool
/// Optimistic-aware accessor. Pre-v0.13 always nil. Otherwise delegates
/// to the board VM so a Verify click un-dims the card immediately.
let effectiveHallucinationGate: (HermesKanbanTask) -> KanbanHallucinationGate?
init(
task: HermesKanbanTask,
supportsKanbanDiagnostics: Bool = false,
effectiveHallucinationGate: @escaping (HermesKanbanTask) -> KanbanHallucinationGate? = { _ in nil },
onTap: @escaping () -> Void
) {
self.task = task
self.supportsKanbanDiagnostics = supportsKanbanDiagnostics
self.effectiveHallucinationGate = effectiveHallucinationGate
self.onTap = onTap
}
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
/// Cached gate read derived once per body eval rather than recomputed
/// in each subview helper.
private var hallucinationGate: KanbanHallucinationGate? {
guard supportsKanbanDiagnostics else { return nil }
return effectiveHallucinationGate(task)
}
var body: some View { var body: some View {
Button(action: onTap) { Button(action: onTap) {
VStack(alignment: .leading, spacing: ScarfSpace.s2) { VStack(alignment: .leading, spacing: ScarfSpace.s2) {
@@ -66,13 +94,22 @@ struct KanbanCardView: View {
} }
.buttonStyle(.plain) .buttonStyle(.plain)
.scarfShadow(.sm) .scarfShadow(.sm)
.opacity(task.isDone ? doneOpacity : 1.0) // v0.13: hallucination-pending cards dim to 0.6 to signal "needs
// verification before running" without making them unreadable.
// Done cards stay at the established doneOpacity (0.7 / 0.55).
.opacity(cardOpacity)
.draggable(KanbanTaskRef(id: task.id)) { .draggable(KanbanTaskRef(id: task.id)) {
// Drag preview the live card with a heavier shadow. // Drag preview the live card with a heavier shadow.
self.dragPreview self.dragPreview
} }
} }
private var cardOpacity: Double {
if task.isDone { return doneOpacity }
if hallucinationGate == .pending { return 0.6 }
return 1.0
}
private var titleRow: some View { private var titleRow: some View {
HStack(alignment: .top, spacing: ScarfSpace.s2) { HStack(alignment: .top, spacing: ScarfSpace.s2) {
statusGlyph statusGlyph
@@ -82,7 +119,15 @@ struct KanbanCardView: View {
.lineLimit(2) .lineLimit(2)
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
Spacer(minLength: 0) Spacer(minLength: 0)
if needsAssignmentWarning { // v0.13 hallucination glyph takes precedence over the
// unassigned glyph the hallucination state is the more
// specific signal (a worker created this card; verify it).
if hallucinationGate == .pending {
Image(systemName: "questionmark.diamond.fill")
.foregroundStyle(ScarfColor.warning)
.font(.system(size: 11, weight: .semibold))
.help("Worker-created — verify before running")
} else if needsAssignmentWarning {
Image(systemName: "exclamationmark.triangle.fill") Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(ScarfColor.warning) .foregroundStyle(ScarfColor.warning)
.font(.system(size: 11, weight: .semibold)) .font(.system(size: 11, weight: .semibold))
@@ -186,13 +231,37 @@ struct KanbanCardView: View {
} }
private var footerRow: some View { private var footerRow: some View {
HStack(spacing: ScarfSpace.s2) { VStack(alignment: .leading, spacing: 2) {
Text(relativeTimeLabel) // v0.13: server-supplied auto-blocked reason. Renders verbatim
.scarfStyle(.caption) // (truncated to one line; full reason in the inspector).
.foregroundStyle(ScarfColor.foregroundFaint) // Pre-v0.13 hosts always have task.autoBlockedReason == nil.
Spacer(minLength: 0) if supportsKanbanDiagnostics,
if let priority = task.priority, priority >= 70 { KanbanStatus.from(task.status) == .blocked,
priorityIndicator(priority) let reason = task.autoBlockedReason, !reason.isEmpty {
Text(reason)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.danger)
.lineLimit(1)
.truncationMode(.tail)
.help(reason)
}
HStack(spacing: ScarfSpace.s2) {
Text(relativeTimeLabel)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
Spacer(minLength: 0)
// v0.13: diagnostics dot small stethoscope glyph when
// any cross-run distress signal is attached. Matches the
// chip count in the inspector.
if supportsKanbanDiagnostics, !task.diagnostics.isEmpty {
Image(systemName: "stethoscope")
.font(.system(size: 9))
.foregroundStyle(ScarfColor.warning)
.help("\(task.diagnostics.count) diagnostic signal\(task.diagnostics.count == 1 ? "" : "s")")
}
if let priority = task.priority, priority >= 70 {
priorityIndicator(priority)
}
} }
} }
} }
@@ -17,6 +17,38 @@ struct KanbanColumnView: View {
let onCreate: () -> Void let onCreate: () -> Void
let onDrop: (KanbanTaskRef) -> Void let onDrop: (KanbanTaskRef) -> Void
let canCreate: Bool let canCreate: Bool
/// True when the connected Hermes is on v0.13+. Forwarded to each
/// `KanbanCardView` so the hallucination dim/glyph + diagnostics dot
/// + auto-block sub-line gate uniformly.
let supportsKanbanDiagnostics: Bool
/// Optimistic-aware accessor forwarded to cards. Default is
/// "no override" so Previews and harness contexts still render
/// without wiring up a board VM.
let effectiveHallucinationGate: (HermesKanbanTask) -> KanbanHallucinationGate?
init(
column: KanbanBoardColumn,
tasks: [HermesKanbanTask],
isLive: Bool,
readyPillCount: Int,
onTaskTap: @escaping (HermesKanbanTask) -> Void,
onCreate: @escaping () -> Void,
onDrop: @escaping (KanbanTaskRef) -> Void,
canCreate: Bool,
supportsKanbanDiagnostics: Bool = false,
effectiveHallucinationGate: @escaping (HermesKanbanTask) -> KanbanHallucinationGate? = { _ in nil }
) {
self.column = column
self.tasks = tasks
self.isLive = isLive
self.readyPillCount = readyPillCount
self.onTaskTap = onTaskTap
self.onCreate = onCreate
self.onDrop = onDrop
self.canCreate = canCreate
self.supportsKanbanDiagnostics = supportsKanbanDiagnostics
self.effectiveHallucinationGate = effectiveHallucinationGate
}
@State private var isTargeted = false @State private var isTargeted = false
@@ -36,7 +68,11 @@ struct KanbanColumnView: View {
.padding(.top, ScarfSpace.s4) .padding(.top, ScarfSpace.s4)
} else { } else {
ForEach(tasks) { task in ForEach(tasks) { task in
KanbanCardView(task: task) { KanbanCardView(
task: task,
supportsKanbanDiagnostics: supportsKanbanDiagnostics,
effectiveHallucinationGate: effectiveHallucinationGate
) {
onTaskTap(task) onTaskTap(task)
} }
} }
@@ -14,6 +14,12 @@ struct KanbanCreateSheet: View {
/// Pre-filled project workspace path on per-project boards. When /// Pre-filled project workspace path on per-project boards. When
/// non-nil, the workspace picker is locked to "Project Dir". /// non-nil, the workspace picker is locked to "Project Dir".
let projectWorkspacePath: String? let projectWorkspacePath: String?
/// True when the connected Hermes is on v0.13+ gates the
/// `--max-retries` field and decides whether to strip newlines from
/// the title at submit time. Pre-v0.13 hosts may truncate at the
/// first `\n`; we keep the multi-line input rendering on either way
/// since a taller `TextField` is harmless on v0.12.
let supportsKanbanDiagnostics: Bool
/// Closure invoked when the user submits VM owner constructs the /// Closure invoked when the user submits VM owner constructs the
/// `KanbanService.create` call. /// `KanbanService.create` call.
let onSubmit: (KanbanCreateRequest) async throws -> Void let onSubmit: (KanbanCreateRequest) async throws -> Void
@@ -33,6 +39,11 @@ struct KanbanCreateSheet: View {
@State private var skillsInput: String = "" @State private var skillsInput: String = ""
@State private var tenant: String = "" @State private var tenant: String = ""
@State private var sendToTriage: Bool = false @State private var sendToTriage: Bool = false
/// v0.13: per-task retry budget. Toggle-gated so the user can opt
/// into "send the flag" vs. "let Hermes pick its default" (the
/// release notes default to 3 see TODO in KanbanCreateRequest).
@State private var maxRetriesEnabled: Bool = false
@State private var maxRetries: Int = 3
@State private var isSubmitting: Bool = false @State private var isSubmitting: Bool = false
@State private var submitError: String? @State private var submitError: String?
@FocusState private var titleFocused: Bool @FocusState private var titleFocused: Bool
@@ -62,6 +73,9 @@ struct KanbanCreateSheet: View {
assigneePicker assigneePicker
workspaceField workspaceField
priorityField priorityField
if supportsKanbanDiagnostics {
maxRetriesField
}
skillsField skillsField
if projectWorkspacePath == nil { if projectWorkspacePath == nil {
tenantField tenantField
@@ -114,10 +128,60 @@ struct KanbanCreateSheet: View {
// MARK: - Fields // MARK: - Fields
private var titleField: some View { private var titleField: some View {
// v0.13 server tolerates multi-line titles. We keep the
// multi-line input rendering on for ALL versions of Hermes
// visually a taller TextField is harmless on v0.12 and decide
// at submit time whether to strip newlines (see `makeRequest`).
VStack(alignment: .leading, spacing: 4) { VStack(alignment: .leading, spacing: 4) {
ScarfSectionHeader("Title") ScarfSectionHeader("Title")
ScarfTextField("What needs doing?", text: $title) TextField(
.focused($titleFocused) "What needs doing?",
text: $title,
axis: .vertical
)
.lineLimit(1...4)
.textFieldStyle(.plain)
.scarfStyle(.body)
.padding(.horizontal, ScarfSpace.s3)
.padding(.vertical, ScarfSpace.s2)
.background(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.fill(ScarfColor.backgroundSecondary)
)
.overlay(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.strokeBorder(ScarfColor.borderStrong, lineWidth: 1)
)
.focused($titleFocused)
}
}
/// v0.13: per-task retry budget. Toggle gates whether `--max-retries`
/// is sent at all so the user can preserve "let Hermes pick the
/// default" semantics by leaving the toggle off.
private var maxRetriesField: some View {
VStack(alignment: .leading, spacing: 4) {
ScarfSectionHeader(
"Max retries",
subtitle: "0 = no retries. Defaults to 3."
)
HStack(spacing: ScarfSpace.s3) {
Toggle("Override default", isOn: $maxRetriesEnabled)
.toggleStyle(.switch)
.labelsHidden()
Stepper(value: $maxRetries, in: 0...20) {
Text("\(maxRetries)")
.scarfStyle(.bodyEmph)
.frame(minWidth: 24, alignment: .trailing)
.foregroundStyle(
maxRetriesEnabled
? ScarfColor.foregroundPrimary
: ScarfColor.foregroundFaint
)
}
.disabled(!maxRetriesEnabled)
Spacer()
}
} }
} }
@@ -307,7 +371,14 @@ struct KanbanCreateSheet: View {
} }
private func makeRequest() -> KanbanCreateRequest { private func makeRequest() -> KanbanCreateRequest {
let trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines) var trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines)
// Pre-v0.13 hosts may truncate titles at the first `\n`. Strip
// newlines client-side when we know the connected Hermes hasn't
// shipped multi-line title support replace with a space to
// keep the user's intent visible. v0.13+ keeps newlines verbatim.
if !supportsKanbanDiagnostics {
trimmedTitle = trimmedTitle.replacingOccurrences(of: "\n", with: " ")
}
let trimmedBody = bodyText.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedBody = bodyText.trimmingCharacters(in: .whitespacesAndNewlines)
let trimmedAssignee = assignee.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedAssignee = assignee.trimmingCharacters(in: .whitespacesAndNewlines)
let trimmedTenant = tenant.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedTenant = tenant.trimmingCharacters(in: .whitespacesAndNewlines)
@@ -330,6 +401,14 @@ struct KanbanCreateSheet: View {
} }
} }
// Belt-and-suspenders: the `maxRetriesField` is only rendered
// when `supportsKanbanDiagnostics` is true, but gate again here
// so a programmatic state change can't smuggle the flag onto a
// pre-v0.13 host (where the verb would error).
let resolvedMaxRetries: Int? = (supportsKanbanDiagnostics && maxRetriesEnabled)
? maxRetries
: nil
return KanbanCreateRequest( return KanbanCreateRequest(
title: trimmedTitle, title: trimmedTitle,
body: trimmedBody.isEmpty ? nil : trimmedBody, body: trimmedBody.isEmpty ? nil : trimmedBody,
@@ -342,7 +421,8 @@ struct KanbanCreateSheet: View {
idempotencyKey: nil, idempotencyKey: nil,
maxRuntimeSeconds: nil, maxRuntimeSeconds: nil,
createdBy: nil, createdBy: nil,
skills: parsedSkills skills: parsedSkills,
maxRetries: resolvedMaxRetries
) )
} }
} }
@@ -8,6 +8,16 @@ import ScarfDesign
struct KanbanInspectorPane: View { struct KanbanInspectorPane: View {
@State private var viewModel: KanbanTaskDetailViewModel @State private var viewModel: KanbanTaskDetailViewModel
let availableAssignees: [HermesKanbanAssignee] let availableAssignees: [HermesKanbanAssignee]
/// True when the connected Hermes is on v0.13+ gates the
/// hallucination banner, max_retries chip, diagnostics block,
/// and auto-blocked reason banner. Pre-v0.13 hosts see the v2.7.5
/// inspector unchanged.
let supportsKanbanDiagnostics: Bool
/// Resolves an effective hallucination gate the board VM owns the
/// optimistic-override merge so the banner disappears immediately on
/// Verify before the polled state confirms the new gate. Falls back
/// to the wire-level value when no override is in flight.
let effectiveHallucinationGate: (HermesKanbanTask) -> KanbanHallucinationGate?
let onClose: () -> Void let onClose: () -> Void
let onClaim: () -> Void let onClaim: () -> Void
let onComplete: () -> Void let onComplete: () -> Void
@@ -15,6 +25,8 @@ struct KanbanInspectorPane: View {
let onUnblock: () -> Void let onUnblock: () -> Void
let onArchive: () -> Void let onArchive: () -> Void
let onReassign: (String?) -> Void let onReassign: (String?) -> Void
let onVerifyHallucination: () -> Void
let onRejectHallucination: () -> Void
@State private var selectedTab: DetailTab = .comments @State private var selectedTab: DetailTab = .comments
@@ -30,16 +42,22 @@ struct KanbanInspectorPane: View {
service: KanbanService, service: KanbanService,
taskId: String, taskId: String,
availableAssignees: [HermesKanbanAssignee] = [], availableAssignees: [HermesKanbanAssignee] = [],
supportsKanbanDiagnostics: Bool = false,
effectiveHallucinationGate: @escaping (HermesKanbanTask) -> KanbanHallucinationGate? = { _ in nil },
onClose: @escaping () -> Void, onClose: @escaping () -> Void,
onClaim: @escaping () -> Void, onClaim: @escaping () -> Void,
onComplete: @escaping () -> Void, onComplete: @escaping () -> Void,
onBlock: @escaping () -> Void, onBlock: @escaping () -> Void,
onUnblock: @escaping () -> Void, onUnblock: @escaping () -> Void,
onArchive: @escaping () -> Void, onArchive: @escaping () -> Void,
onReassign: @escaping (String?) -> Void = { _ in } onReassign: @escaping (String?) -> Void = { _ in },
onVerifyHallucination: @escaping () -> Void = {},
onRejectHallucination: @escaping () -> Void = {}
) { ) {
_viewModel = State(initialValue: KanbanTaskDetailViewModel(service: service, taskId: taskId)) _viewModel = State(initialValue: KanbanTaskDetailViewModel(service: service, taskId: taskId))
self.availableAssignees = availableAssignees self.availableAssignees = availableAssignees
self.supportsKanbanDiagnostics = supportsKanbanDiagnostics
self.effectiveHallucinationGate = effectiveHallucinationGate
self.onClose = onClose self.onClose = onClose
self.onClaim = onClaim self.onClaim = onClaim
self.onComplete = onComplete self.onComplete = onComplete
@@ -47,6 +65,8 @@ struct KanbanInspectorPane: View {
self.onUnblock = onUnblock self.onUnblock = onUnblock
self.onArchive = onArchive self.onArchive = onArchive
self.onReassign = onReassign self.onReassign = onReassign
self.onVerifyHallucination = onVerifyHallucination
self.onRejectHallucination = onRejectHallucination
} }
var body: some View { var body: some View {
@@ -159,6 +179,16 @@ struct KanbanInspectorPane: View {
ScarfBadge(workspace, kind: .neutral) ScarfBadge(workspace, kind: .neutral)
.fixedSize() .fixedSize()
} }
// v0.13: max_retries chip. Read-only Hermes
// has no `update --max-retries` verb. The
// `if let` guards pre-v0.13 hosts (always nil)
// and the explicit capability gate adds
// belt-and-suspenders.
if supportsKanbanDiagnostics, let maxRetries = task.maxRetries {
ScarfBadge("retries: \(maxRetries)", kind: .neutral)
.fixedSize()
.help("Max retries set at create time. Hermes has no update verb — re-create the task to change this.")
}
if let tenant = task.tenant, !tenant.isEmpty { if let tenant = task.tenant, !tenant.isEmpty {
ScarfBadge(tenant, kind: .brand) ScarfBadge(tenant, kind: .brand)
.fixedSize() .fixedSize()
@@ -251,13 +281,18 @@ struct KanbanInspectorPane: View {
// MARK: - Body // MARK: - Body
/// Inline health banner shown above the task body when something /// Inline health banner shown above the task body when something
/// requires user attention. Two conditions trigger today: /// requires user attention. Stack vertically (multiple can apply at
/// 1. Task is in `ready`/`todo` with no assignee explains that /// once on a v0.13 task e.g. unassigned + hallucination pending +
/// the dispatcher silently skips unassigned tasks. /// last-run-blocked).
/// 2. The most recent run ended in a non-success outcome /// Order top-to-bottom:
/// (`stale_lock`/`crashed`/`gave_up`/`timed_out`/`spawn_failed`/ /// 1. **Hallucination gate (v0.13+)** pending worker-created card.
/// `reclaimed`/`failed`) surfaces the error so the user /// User must verify or reject before any other action makes sense.
/// doesn't have to dig into the Runs tab to discover it. /// 2. **Auto-blocked reason (v0.13+)** server-supplied reason
/// overrides the generic "Last run: blocked" banner.
/// 3. Task is in `ready`/`todo` with no assignee explains that the
/// dispatcher silently skips unassigned tasks.
/// 4. The most recent run ended in a non-success outcome surfaces
/// the error so the user doesn't have to dig into the Runs tab.
@ViewBuilder @ViewBuilder
private func healthBanner(for task: HermesKanbanTask) -> some View { private func healthBanner(for task: HermesKanbanTask) -> some View {
let status = KanbanStatus.from(task.status) let status = KanbanStatus.from(task.status)
@@ -292,25 +327,137 @@ struct KanbanInspectorPane: View {
// Also suppress for `done` (terminal success). // Also suppress for `done` (terminal success).
let suppressFailureBanner = (status == .running) || (status == .done) let suppressFailureBanner = (status == .running) || (status == .done)
if needsAssignee { // v0.13: hallucination-gate state. Read through the VM's
bannerRow( // optimistic-aware accessor so a Verify click takes effect
icon: "exclamationmark.triangle.fill", // before the polled state confirms. Belt-and-suspenders gate
tint: ScarfColor.warning, // on capability flag.
title: "Won't run automatically", let hallucination: KanbanHallucinationGate? = supportsKanbanDiagnostics
message: "Unassigned tasks are silently skipped by Hermes's dispatcher. Add an assignee to get this scheduled." ? effectiveHallucinationGate(task)
) : nil
} else if hadFailedEndedRun, let lastEndedRun, !suppressFailureBanner { // v0.13: structured auto-blocked reason. Renders the server's
let label = (lastEndedRun.outcome ?? lastEndedRun.status).lowercased() // string verbatim; takes precedence over the generic "Last run:
let detail = lastEndedRun.error ?? lastEndedRun.summary ?? "no details" // blocked" banner.
bannerRow( let autoBlockedReason: String? = (supportsKanbanDiagnostics
icon: "exclamationmark.octagon.fill", && status == .blocked
tint: ScarfColor.danger, && (task.autoBlockedReason?.isEmpty == false))
title: "Last run: \(label)", ? task.autoBlockedReason
message: detail : nil
) // Suppress the generic last-run banner when the more specific
// server-side reason supersedes it.
let suppressGenericFailure = autoBlockedReason != nil
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
if hallucination == .pending {
hallucinationBanner
}
if let reason = autoBlockedReason {
bannerRow(
icon: "exclamationmark.octagon.fill",
tint: ScarfColor.danger,
title: "Auto-blocked",
// Verbatim Hermes-side message is the source of truth.
message: reason
)
}
if needsAssignee {
bannerRow(
icon: "exclamationmark.triangle.fill",
tint: ScarfColor.warning,
title: "Won't run automatically",
message: "Unassigned tasks are silently skipped by Hermes's dispatcher. Add an assignee to get this scheduled."
)
}
if hadFailedEndedRun, let lastEndedRun,
!suppressFailureBanner, !suppressGenericFailure {
let label = (lastEndedRun.outcome ?? lastEndedRun.status).lowercased()
let detail = lastEndedRun.error ?? lastEndedRun.summary ?? "no details"
bannerRow(
icon: "exclamationmark.octagon.fill",
tint: ScarfColor.danger,
title: "Last run: \(label)",
message: detail
)
}
// v0.13: cross-run diagnostics on the task header.
if supportsKanbanDiagnostics, !task.diagnostics.isEmpty {
diagnosticsBlock(task.diagnostics)
}
} }
} }
/// v0.13 hallucination-gate banner Verify / Reject affordances for
/// worker-created cards waiting on user verification.
private var hallucinationBanner: some View {
HStack(alignment: .top, spacing: ScarfSpace.s2) {
Image(systemName: "questionmark.diamond.fill")
.foregroundStyle(ScarfColor.warning)
.font(.system(size: 13, weight: .semibold))
VStack(alignment: .leading, spacing: 4) {
Text("Created by a worker — verify before running")
.scarfStyle(.captionStrong)
.foregroundStyle(ScarfColor.foregroundPrimary)
Text("A worker claimed it created this card; Hermes hasn't confirmed the underlying work exists. Verify the card matches a real follow-up, or reject if it's a hallucinated reference.")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
HStack(spacing: ScarfSpace.s2) {
Button("Verify", action: onVerifyHallucination)
.buttonStyle(ScarfPrimaryButton())
Button("Reject", action: onRejectHallucination)
.buttonStyle(ScarfDestructiveButton())
}
.padding(.top, 2)
}
Spacer(minLength: 0)
}
.padding(ScarfSpace.s2)
.background(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.fill(ScarfColor.warning.opacity(0.10))
)
.overlay(
RoundedRectangle(cornerRadius: ScarfRadius.md, style: .continuous)
.strokeBorder(ScarfColor.warning.opacity(0.4), lineWidth: 1)
)
}
/// v0.13 diagnostics block renders a list of distress signals.
/// Used both at the task-header level (cross-run signals) and per
/// run on the Runs tab (in-flight signals). Wraps in a horizontal
/// scroll so a long diag list doesn't blow out inspector width.
private func diagnosticsBlock(_ diags: [HermesKanbanDiagnostic]) -> some View {
VStack(alignment: .leading, spacing: 4) {
Text("Diagnostics")
.scarfStyle(.captionUppercase)
.foregroundStyle(ScarfColor.foregroundFaint)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 4) {
ForEach(diags) { diag in
diagnosticBadge(diag)
}
}
}
}
.padding(.top, 4)
}
@ViewBuilder
private func diagnosticBadge(_ diag: HermesKanbanDiagnostic) -> some View {
let kind = KanbanDiagnosticKind.from(diag.kind)
let badgeKind: ScarfBadgeKind = {
switch kind.severity {
case .danger: return .danger
case .warning: return .warning
case .neutral: return .neutral
}
}()
// Render the raw kind string view code stays in sync with
// whatever future kinds Hermes ships. The typed mirror picks
// the badge tint and tooltip glyph; the verbatim wire string
// is the user-facing label.
ScarfBadge(diag.kind, kind: badgeKind)
.help(diag.message ?? diag.kind)
}
private func bannerRow( private func bannerRow(
icon: String, icon: String,
tint: Color, tint: Color,
@@ -562,6 +709,9 @@ struct KanbanInspectorPane: View {
private func runRow(_ run: HermesKanbanRun) -> some View { private func runRow(_ run: HermesKanbanRun) -> some View {
VStack(alignment: .leading, spacing: 2) { VStack(alignment: .leading, spacing: 2) {
HStack(spacing: ScarfSpace.s2) { HStack(spacing: ScarfSpace.s2) {
// Render the wire-side outcome / status string verbatim so
// v0.13's richer outcome strings ("zombied reclaimed by
// reaper", etc.) surface unchanged.
ScarfBadge(run.outcome ?? run.status, kind: outcomeKind(run.outcome ?? run.status)) ScarfBadge(run.outcome ?? run.status, kind: outcomeKind(run.outcome ?? run.status))
if let profile = run.profile { if let profile = run.profile {
Text(profile) Text(profile)
@@ -585,6 +735,12 @@ struct KanbanInspectorPane: View {
.foregroundStyle(ScarfColor.danger) .foregroundStyle(ScarfColor.danger)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
} }
// v0.13: per-run diagnostics. Gated on capability so a future
// server-side change can't accidentally surface partial UX
// on a pre-v0.13 host.
if supportsKanbanDiagnostics, !run.diagnostics.isEmpty {
diagnosticsBlock(run.diagnostics)
}
} }
.padding(ScarfSpace.s2) .padding(ScarfSpace.s2)
.background( .background(
@@ -619,23 +775,32 @@ struct KanbanInspectorPane: View {
@ViewBuilder @ViewBuilder
private var primaryAction: some View { private var primaryAction: some View {
if let task = viewModel.detail?.task { if let task = viewModel.detail?.task {
switch KanbanStatus.from(task.status) { // v0.13: when the hallucination gate is pending, suppress the
case .ready, .todo: // primary action the banner provides Verify / Reject as the
Button("Start", action: onClaim) // gate. Showing "Start" alongside the banner would let the
.buttonStyle(ScarfPrimaryButton()) // user dispatch a card Hermes hasn't confirmed exists.
.help("Atomically claim this task and start the worker. Moves it to Running.") if supportsKanbanDiagnostics,
case .running: effectiveHallucinationGate(task) == .pending {
Button("Complete", action: onComplete)
.buttonStyle(ScarfPrimaryButton())
.help("Mark this task as Done. You'll be prompted for an optional result summary.")
case .blocked:
Button("Unblock", action: onUnblock)
.buttonStyle(ScarfPrimaryButton())
.help("Return this task to the Up Next queue so the dispatcher can pick it up again.")
case .triage:
EmptyView()
default:
EmptyView() EmptyView()
} else {
switch KanbanStatus.from(task.status) {
case .ready, .todo:
Button("Start", action: onClaim)
.buttonStyle(ScarfPrimaryButton())
.help("Atomically claim this task and start the worker. Moves it to Running.")
case .running:
Button("Complete", action: onComplete)
.buttonStyle(ScarfPrimaryButton())
.help("Mark this task as Done. You'll be prompted for an optional result summary.")
case .blocked:
Button("Unblock", action: onUnblock)
.buttonStyle(ScarfPrimaryButton())
.help("Return this task to the Up Next queue so the dispatcher can pick it up again.")
case .triage:
EmptyView()
default:
EmptyView()
}
} }
} }
} }
@@ -21,6 +21,9 @@ final class MCPServerEditorViewModel {
var promptsEnabled: Bool var promptsEnabled: Bool
var timeoutDraft: String var timeoutDraft: String
var connectTimeoutDraft: String var connectTimeoutDraft: String
/// SSE-only renders as a third numeric on `.sse` servers. Empty string
/// means "use Hermes default" (writer drops the scalar).
var sseReadTimeoutDraft: String
var showSecrets: Bool = false var showSecrets: Bool = false
var isSaving: Bool = false var isSaving: Bool = false
var saveError: String? var saveError: String?
@@ -37,6 +40,7 @@ final class MCPServerEditorViewModel {
self.promptsEnabled = server.promptsEnabled self.promptsEnabled = server.promptsEnabled
self.timeoutDraft = server.timeout.map { String($0) } ?? "" self.timeoutDraft = server.timeout.map { String($0) } ?? ""
self.connectTimeoutDraft = server.connectTimeout.map { String($0) } ?? "" self.connectTimeoutDraft = server.connectTimeout.map { String($0) } ?? ""
self.sseReadTimeoutDraft = server.sseReadTimeout.map { String($0) } ?? ""
} }
func appendEnvRow() { func appendEnvRow() {
@@ -69,6 +73,8 @@ final class MCPServerEditorViewModel {
let exclude = excludeDraft.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty } let exclude = excludeDraft.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
let timeoutValue = Int(timeoutDraft.trimmingCharacters(in: .whitespaces)) let timeoutValue = Int(timeoutDraft.trimmingCharacters(in: .whitespaces))
let connectValue = Int(connectTimeoutDraft.trimmingCharacters(in: .whitespaces)) let connectValue = Int(connectTimeoutDraft.trimmingCharacters(in: .whitespaces))
let trimmedSSE = sseReadTimeoutDraft.trimmingCharacters(in: .whitespaces)
let sseTimeoutValue: Int? = trimmedSSE.isEmpty ? nil : Int(trimmedSSE)
let service = fileService let service = fileService
let transport = server.transport let transport = server.transport
@@ -87,6 +93,11 @@ final class MCPServerEditorViewModel {
if !service.setMCPServerEnv(name: name, env: envMap) { ok = false } if !service.setMCPServerEnv(name: name, env: envMap) { ok = false }
case .http: case .http:
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false } if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
case .sse:
// SSE servers carry headers like .http does, plus an
// optional sse_read_timeout written below.
if !service.setMCPServerHeaders(name: name, headers: headerMap) { ok = false }
if !service.setMCPServerSSETimeout(name: name, sseReadTimeout: sseTimeoutValue) { ok = false }
} }
if !service.updateMCPToolFilters( if !service.updateMCPToolFilters(
name: name, name: name,
@@ -42,6 +42,10 @@ final class MCPServersViewModel {
filteredServers.filter { $0.transport == .http } filteredServers.filter { $0.transport == .http }
} }
var sseServers: [HermesMCPServer] {
filteredServers.filter { $0.transport == .sse }
}
var selectedServer: HermesMCPServer? { var selectedServer: HermesMCPServer? {
guard let name = selectedServerName else { return nil } guard let name = selectedServerName else { return nil }
return servers.first(where: { $0.name == name }) return servers.first(where: { $0.name == name })
@@ -167,6 +171,11 @@ final class MCPServersViewModel {
url: preset.url ?? "", url: preset.url ?? "",
auth: preset.auth auth: preset.auth
) )
case .sse:
// No SSE-transport presets ship today; the preset picker
// only surfaces stdio/http servers. Treat as a no-op
// failure if a preset somehow declares .sse.
addResult = (exitCode: 1, output: "SSE-transport presets are not supported.")
} }
guard addResult.exitCode == 0 else { guard addResult.exitCode == 0 else {
await MainActor.run { await MainActor.run {
@@ -196,6 +205,11 @@ final class MCPServersViewModel {
result = fileService.addMCPServerStdio(name: name, command: command, args: args) result = fileService.addMCPServerStdio(name: name, command: command, args: args)
case .http: case .http:
result = fileService.addMCPServerHTTP(name: name, url: url, auth: auth) result = fileService.addMCPServerHTTP(name: name, url: url, auth: auth)
case .sse:
// Routed through addCustomSSE; this branch is unreachable from
// the add-server form (which dispatches per-transport in submit())
// but kept so the switch is exhaustive without `@unknown default`.
result = (exitCode: 1, output: "SSE servers must be added via addCustomSSE.")
} }
await MainActor.run { await MainActor.run {
if result.exitCode == 0 { if result.exitCode == 0 {
@@ -211,6 +225,28 @@ final class MCPServersViewModel {
} }
} }
/// v0.13+ SSE-transport server creation. Caller is responsible for
/// capability-gating; the form filters `.sse` out of `availableTransports`
/// when `hasMCPSSETransport` is false, so this method is unreachable
/// from the UI on pre-v0.13 hosts.
func addCustomSSE(name: String, url: String, sseReadTimeout: Int?) {
let fileService = self.fileService
Task.detached {
let result = fileService.addMCPServerSSE(name: name, url: url, sseReadTimeout: sseReadTimeout)
await MainActor.run {
if result.exitCode == 0 {
self.flashStatus("Added \(name)")
self.load()
self.selectedServerName = name
self.showRestartBanner = true
self.showAddCustom = false
} else {
self.activeError = "Add failed: \(result.output)"
}
}
}
}
func restartGateway() { func restartGateway() {
let fileService = self.fileService let fileService = self.fileService
Task.detached { Task.detached {
@@ -6,12 +6,26 @@ struct MCPServerAddCustomView: View {
let viewModel: MCPServersViewModel let viewModel: MCPServersViewModel
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@Environment(\.hermesCapabilities) private var capabilitiesStore
@State private var name: String = "" @State private var name: String = ""
@State private var transport: MCPTransport = .stdio @State private var transport: MCPTransport = .stdio
@State private var command: String = "npx" @State private var command: String = "npx"
@State private var argsText: String = "" @State private var argsText: String = ""
@State private var url: String = "" @State private var url: String = ""
@State private var auth: String = "none" @State private var auth: String = "none"
@State private var sseReadTimeout: String = ""
/// `.sse` is a v0.13+ surface; pre-v0.13 hosts only see stdio + http.
/// Iterating `MCPTransport.allCases` directly would render the SSE
/// segment unconditionally and Hermes would reject the resulting CLI
/// invocation at argparse time.
private var availableTransports: [MCPTransport] {
var t: [MCPTransport] = [.stdio, .http]
if capabilitiesStore?.capabilities.hasMCPSSETransport ?? false {
t.append(.sse)
}
return t
}
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
@@ -44,17 +58,20 @@ struct MCPServerAddCustomView: View {
} }
sectionBox(title: "Transport") { sectionBox(title: "Transport") {
Picker("", selection: $transport) { Picker("", selection: $transport) {
ForEach(MCPTransport.allCases) { t in ForEach(availableTransports) { t in
Text(t.displayName).tag(t) Text(t.displayName).tag(t)
} }
} }
.pickerStyle(.segmented) .pickerStyle(.segmented)
.labelsHidden() .labelsHidden()
} }
if transport == .stdio { switch transport {
case .stdio:
stdioSection stdioSection
} else { case .http:
httpSection httpSection
case .sse:
sseSection
} }
Text("Env vars, headers, and tool filters can be edited after the server is added.") Text("Env vars, headers, and tool filters can be edited after the server is added.")
.font(.caption) .font(.caption)
@@ -112,6 +129,28 @@ struct MCPServerAddCustomView: View {
} }
} }
private var sseSection: some View {
sectionBox(title: "Endpoint (SSE)") {
VStack(alignment: .leading, spacing: 8) {
VStack(alignment: .leading, spacing: 4) {
Text("URL").font(.caption.bold())
TextField("https://.../sse", text: $url)
.textFieldStyle(.roundedBorder)
.font(.system(.body, design: .monospaced))
}
VStack(alignment: .leading, spacing: 4) {
Text("SSE Read Timeout (seconds)").font(.caption.bold())
TextField("default 300", text: $sseReadTimeout)
.textFieldStyle(.roundedBorder)
.frame(maxWidth: 140)
Text("Hermes-side keepalive interval. Leave blank to use the default.")
.font(.caption2)
.foregroundStyle(.secondary)
}
}
}
}
private var canSubmit: Bool { private var canSubmit: Bool {
let trimmedName = name.trimmingCharacters(in: .whitespaces) let trimmedName = name.trimmingCharacters(in: .whitespaces)
guard !trimmedName.isEmpty else { return false } guard !trimmedName.isEmpty else { return false }
@@ -120,6 +159,8 @@ struct MCPServerAddCustomView: View {
return !command.trimmingCharacters(in: .whitespaces).isEmpty return !command.trimmingCharacters(in: .whitespaces).isEmpty
case .http: case .http:
return !url.trimmingCharacters(in: .whitespaces).isEmpty return !url.trimmingCharacters(in: .whitespaces).isEmpty
case .sse:
return !url.trimmingCharacters(in: .whitespaces).isEmpty
} }
} }
@@ -130,14 +171,25 @@ struct MCPServerAddCustomView: View {
.map { $0.trimmingCharacters(in: .whitespaces) } .map { $0.trimmingCharacters(in: .whitespaces) }
.filter { !$0.isEmpty } .filter { !$0.isEmpty }
let resolvedAuth: String? = (auth == "none") ? nil : auth let resolvedAuth: String? = (auth == "none") ? nil : auth
viewModel.addCustom( switch transport {
name: trimmedName, case .stdio, .http:
transport: transport, viewModel.addCustom(
command: command.trimmingCharacters(in: .whitespaces), name: trimmedName,
args: args, transport: transport,
url: url.trimmingCharacters(in: .whitespaces), command: command.trimmingCharacters(in: .whitespaces),
auth: resolvedAuth args: args,
) url: url.trimmingCharacters(in: .whitespaces),
auth: resolvedAuth
)
case .sse:
let trimmedTimeout = sseReadTimeout.trimmingCharacters(in: .whitespaces)
let parsedTimeout: Int? = trimmedTimeout.isEmpty ? nil : Int(trimmedTimeout)
viewModel.addCustomSSE(
name: trimmedName,
url: url.trimmingCharacters(in: .whitespaces),
sseReadTimeout: parsedTimeout
)
}
dismiss() dismiss()
} }
@@ -127,6 +127,11 @@ struct MCPServerDetailView: View {
if let auth = server.auth, !auth.isEmpty { if let auth = server.auth, !auth.isEmpty {
summaryRow(label: "Auth", value: auth) summaryRow(label: "Auth", value: auth)
} }
case .sse:
summaryRow(label: "URL", value: server.url ?? "")
if let timeout = server.sseReadTimeout {
summaryRow(label: "Read TO", value: "\(timeout)s")
}
} }
} }
.padding(ScarfSpace.s3) .padding(ScarfSpace.s3)
@@ -186,6 +186,16 @@ struct MCPServerEditorView: View {
.textFieldStyle(.roundedBorder) .textFieldStyle(.roundedBorder)
.frame(maxWidth: 140) .frame(maxWidth: 140)
} }
if viewModel.server.transport == .sse {
VStack(alignment: .leading, spacing: 4) {
Text("SSE read timeout")
.font(.caption)
.foregroundStyle(.secondary)
TextField("default 300", text: $viewModel.sseReadTimeoutDraft)
.textFieldStyle(.roundedBorder)
.frame(maxWidth: 140)
}
}
Spacer() Spacer()
} }
} }
@@ -132,6 +132,14 @@ struct MCPServersView: View {
} }
} }
} }
if !viewModel.sseServers.isEmpty {
Section("Remote (SSE)") {
ForEach(viewModel.sseServers) { server in
serverRow(server)
.tag(server.name as String?)
}
}
}
if viewModel.servers.isEmpty && !viewModel.isLoading { if viewModel.servers.isEmpty && !viewModel.isLoading {
Section { Section {
Text("No servers configured yet") Text("No servers configured yet")
@@ -0,0 +1,140 @@
import Foundation
import ScarfCore
import os
/// View-model for the v0.13 Messaging Gateway behavior subsection composed
/// into each per-platform setup view. Owns the four v0.13 controls
/// (allowlist + three behavior toggles) so the existing per-platform VMs
/// don't grow another set of fields.
///
/// Capability-gated. Pre-v0.13 hosts skip the entire subsection (the
/// owning view returns `EmptyView` when none of the v0.13 flags is on),
/// so this VM never has its `save()` called against a host that can't
/// honor it.
@Observable
@MainActor
final class GatewayBehaviorViewModel {
private static let logger = Logger(subsystem: "com.scarf", category: "GatewayBehavior")
let platform: String
let context: ServerContext
let capabilities: HermesCapabilities
/// Allowlist kind for this platform, or `nil` for platforms without
/// an allowlist surface (Discord, Signal, etc. `GatewayBehaviorSection`
/// short-circuits before instantiating this VM in that case, but the
/// field is `nil` for safety).
let kind: GatewayAllowlistKind?
// Allowlist
var items: [String] = []
// Behavior toggles
var busyAckEnabled: Bool = true
var gatewayRestartNotification: Bool = false
var slashCommandNoticeTTLSeconds: Int = 0
var message: String?
var isSaving: Bool = false
init(
platform: String,
capabilities: HermesCapabilities,
context: ServerContext = .local
) {
self.platform = platform
self.capabilities = capabilities
self.context = context
self.kind = GatewayAllowlistKind.kind(for: platform)
}
/// Hydrate from `~/.hermes/config.yaml`. Called from the section's
/// `.onAppear`. Empty when the platform has no `gateway:` block in
/// the file defaults match v0.13 server-side defaults so the form
/// looks identical to a fresh-install host.
func load() {
let cfg = HermesFileService(context: context).loadConfig()
let block = cfg.gatewayPlatforms[platform] ?? .empty
if let kind {
switch kind {
case .channels: items = block.allowedChannels
case .chats: items = block.allowedChats
case .rooms: items = block.allowedRooms
}
} else {
items = []
}
busyAckEnabled = block.busyAckEnabled
gatewayRestartNotification = block.gatewayRestartNotification
slashCommandNoticeTTLSeconds = block.slashCommandNoticeTTLSeconds
}
/// Persist edits in two phases:
///
/// 1. **Allowlist write** via `GatewayConfigWriter.saveList` direct
/// YAML edit, since `hermes config set` can't write list values.
/// Skipped when the platform has no `kind` (no allowlist surface)
/// or the host doesn't advertise `hasGatewayAllowlists`.
/// 2. **Scalar saves** via `PlatformSetupHelpers.saveForm` for the
/// three v0.13 behavior toggles. Each gated on its own capability
/// flag; the TTL field rides on the `hasGatewayBusyAckToggle
/// hasGatewayRestartNotification` proxy (see WS-5 plan §Open Questions
/// Q5 + WS-1 Decision F).
func save() {
isSaving = true
defer {
isSaving = false
DispatchQueue.main.asyncAfter(deadline: .now() + 3) { [weak self] in
self?.message = nil
}
}
// Step 1: list write via direct YAML edit. Detached so the SCP
// round-trip on remote hosts doesn't block MainActor local
// writes are still cheap, but the same posture works for both.
if let kind, capabilities.hasGatewayAllowlists {
let trimmed = items
.map { $0.trimmingCharacters(in: .whitespaces) }
.filter { !$0.isEmpty }
let ok = GatewayConfigWriter.saveList(
context: context,
platform: platform,
key: kind.yamlKey,
items: trimmed
)
if !ok {
Self.logger.warning("GatewayConfigWriter.saveList failed for \(self.platform, privacy: .public)")
message = "Failed to write allowlist to config.yaml"
return
}
}
// Step 2: scalar saves via `hermes config set`.
var configKV: [String: String] = [:]
let prefix = "gateway.platforms.\(platform)."
if capabilities.hasGatewayBusyAckToggle {
configKV[prefix + "busy_ack_enabled"] =
PlatformSetupHelpers.envBool(busyAckEnabled)
}
if capabilities.hasGatewayRestartNotification {
configKV[prefix + "gateway_restart_notification"] =
PlatformSetupHelpers.envBool(gatewayRestartNotification)
}
// TTL field rides on either of the v0.13 toggles being available
// proxy gating per WS-1 Decision F + WS-5 Q5. // TODO(WS-5-Q5)
if capabilities.hasGatewayBusyAckToggle
|| capabilities.hasGatewayRestartNotification {
configKV[prefix + "slash_command_notice_ttl_seconds"] =
String(slashCommandNoticeTTLSeconds)
}
if configKV.isEmpty {
message = "Allowlist saved — restart gateway to apply"
return
}
let result = PlatformSetupHelpers.saveForm(
context: context, envPairs: [:], configKV: configKV
)
message = result
}
}
@@ -0,0 +1,103 @@
import SwiftUI
import ScarfCore
import ScarfDesign
/// Reusable list-of-strings editor for v0.13 cross-platform allowlists.
/// Shape: a vertical stack of rows, each with a delete glyph; an "Add row"
/// button at the bottom appends an empty entry.
///
/// Stateless binds to the parent VM's `items` array. The VM owns
/// persistence and change tracking; this view is pure presentation.
struct AllowlistEditor: View {
@Binding var items: [String]
let kind: GatewayAllowlistKind
var body: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s2) {
HStack {
Text("Allowed \(kind.pluralNoun)")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundMuted)
Spacer()
Text(itemsCountLabel)
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
}
if items.isEmpty {
Text("No restrictions — agent responds in any \(kind.noun).")
.scarfStyle(.caption)
.foregroundStyle(ScarfColor.foregroundFaint)
.padding(.vertical, ScarfSpace.s2)
} else {
VStack(spacing: 4) {
ForEach(Array(items.enumerated()), id: \.offset) { idx, _ in
AllowlistRow(
value: Binding(
get: { items[safe: idx] ?? "" },
set: { newValue in
guard idx < items.count else { return }
items[idx] = newValue
}
),
placeholder: kind.inputPlaceholder,
onDelete: {
guard idx < items.count else { return }
items.remove(at: idx)
}
)
}
}
}
HStack {
Button {
items.append("")
} label: {
Label("Add \(kind.noun)", systemImage: "plus.circle")
.font(.caption)
}
.buttonStyle(.borderless)
Spacer()
}
}
.padding(.horizontal, ScarfSpace.s3)
.padding(.vertical, ScarfSpace.s2)
}
private var itemsCountLabel: String {
let nonEmpty = items.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty }.count
if nonEmpty == 0 { return "0 \(kind.pluralNoun)" }
if nonEmpty == 1 { return "1 \(kind.noun)" }
return "\(nonEmpty) \(kind.pluralNoun)"
}
}
private struct AllowlistRow: View {
@Binding var value: String
let placeholder: String
let onDelete: () -> Void
var body: some View {
HStack(spacing: ScarfSpace.s2) {
TextField(placeholder, text: $value)
.textFieldStyle(.roundedBorder)
.font(ScarfFont.monoSmall)
Button {
onDelete()
} label: {
Image(systemName: "minus.circle.fill")
.foregroundStyle(ScarfColor.danger)
}
.buttonStyle(.plain)
.help("Remove")
}
}
}
private extension Array {
subscript(safe index: Int) -> Element? {
guard index >= 0, index < count else { return nil }
return self[index]
}
}
@@ -0,0 +1,96 @@
import SwiftUI
import ScarfCore
import ScarfDesign
/// v0.13 Messaging Gateway behavior subsection composed into each per-
/// platform setup view (Slack, Mattermost, Telegram, WhatsApp, Matrix,
/// Google Chat). Owns its own `@State` view-model so the existing per-
/// platform VMs don't grow another set of fields.
///
/// **Capability gating.** Hides itself entirely on pre-v0.13 hosts
/// (returns `EmptyView` when none of the three v0.13 flags is on). Each
/// internal control gates on its own flag, so a host that gains, say,
/// `hasGatewayAllowlists` but not `hasGatewayBusyAckToggle` still gets
/// the allowlist editor with the toggles hidden.
struct GatewayBehaviorSection: View {
let platform: String
let capabilities: HermesCapabilities
let context: ServerContext
@State private var viewModel: GatewayBehaviorViewModel
init(platform: String, capabilities: HermesCapabilities, context: ServerContext) {
self.platform = platform
self.capabilities = capabilities
self.context = context
_viewModel = State(initialValue: GatewayBehaviorViewModel(
platform: platform,
capabilities: capabilities,
context: context
))
}
var body: some View {
// Pre-v0.13 host hide the entire subsection so the existing
// platform forms look unchanged. Critical regression invariant
// per WS-5 plan §"How to test" #1.
if !capabilities.hasGatewayAllowlists
&& !capabilities.hasGatewayBusyAckToggle
&& !capabilities.hasGatewayRestartNotification {
EmptyView()
} else {
content
}
}
private var content: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s3) {
SettingsSection(title: "Gateway behavior (v0.13+)", icon: "dot.radiowaves.left.and.right") {
if capabilities.hasGatewayAllowlists,
let kind = viewModel.kind {
AllowlistEditor(
items: $viewModel.items,
kind: kind
)
}
if capabilities.hasGatewayBusyAckToggle {
ToggleRow(
label: "Send 'Agent is working…' ack",
isOn: viewModel.busyAckEnabled
) { viewModel.busyAckEnabled = $0 }
}
if capabilities.hasGatewayRestartNotification {
ToggleRow(
label: "Post 'Gateway restarted' notice on boot",
isOn: viewModel.gatewayRestartNotification
) { viewModel.gatewayRestartNotification = $0 }
}
// TTL field rides on either v0.13 toggle being available
// proxy gating per WS-1 Decision F. // TODO(WS-5-Q5)
if capabilities.hasGatewayBusyAckToggle
|| capabilities.hasGatewayRestartNotification {
StepperRow(
label: "Auto-delete slash-command notices (s)",
value: viewModel.slashCommandNoticeTTLSeconds,
range: 0...3600,
step: 5
) { viewModel.slashCommandNoticeTTLSeconds = $0 }
}
}
HStack {
if let msg = viewModel.message {
Label(msg, systemImage: "checkmark.circle.fill")
.font(.caption)
.foregroundStyle(.green)
}
Spacer()
Button("Save behavior") { viewModel.save() }
.buttonStyle(ScarfPrimaryButton())
.controlSize(.small)
.disabled(viewModel.isSaving)
}
}
.onAppear { viewModel.load() }
}
}
@@ -4,7 +4,13 @@ import ScarfDesign
struct MatrixSetupView: View { struct MatrixSetupView: View {
@State private var viewModel: MatrixSetupViewModel @State private var viewModel: MatrixSetupViewModel
init(context: ServerContext) { _viewModel = State(initialValue: MatrixSetupViewModel(context: context)) } @Environment(\.hermesCapabilities) private var capabilitiesStore
let context: ServerContext
init(context: ServerContext) {
self.context = context
_viewModel = State(initialValue: MatrixSetupViewModel(context: context))
}
var body: some View { var body: some View {
@@ -45,6 +51,13 @@ struct MatrixSetupView: View {
} }
saveBar saveBar
// v0.13 Messaging Gateway behavior self-hides on pre-v0.13.
GatewayBehaviorSection(
platform: "matrix",
capabilities: capabilitiesStore?.capabilities ?? .empty,
context: context
)
} }
.onAppear { viewModel.load() } .onAppear { viewModel.load() }
} }
@@ -4,7 +4,13 @@ import ScarfDesign
struct MattermostSetupView: View { struct MattermostSetupView: View {
@State private var viewModel: MattermostSetupViewModel @State private var viewModel: MattermostSetupViewModel
init(context: ServerContext) { _viewModel = State(initialValue: MattermostSetupViewModel(context: context)) } @Environment(\.hermesCapabilities) private var capabilitiesStore
let context: ServerContext
init(context: ServerContext) {
self.context = context
_viewModel = State(initialValue: MattermostSetupViewModel(context: context))
}
var body: some View { var body: some View {
@@ -28,6 +34,13 @@ struct MattermostSetupView: View {
} }
saveBar saveBar
// v0.13 Messaging Gateway behavior self-hides on pre-v0.13.
GatewayBehaviorSection(
platform: "mattermost",
capabilities: capabilitiesStore?.capabilities ?? .empty,
context: context
)
} }
.onAppear { viewModel.load() } .onAppear { viewModel.load() }
} }
@@ -4,7 +4,13 @@ import ScarfDesign
struct SlackSetupView: View { struct SlackSetupView: View {
@State private var viewModel: SlackSetupViewModel @State private var viewModel: SlackSetupViewModel
init(context: ServerContext) { _viewModel = State(initialValue: SlackSetupViewModel(context: context)) } @Environment(\.hermesCapabilities) private var capabilitiesStore
let context: ServerContext
init(context: ServerContext) {
self.context = context
_viewModel = State(initialValue: SlackSetupViewModel(context: context))
}
var body: some View { var body: some View {
@@ -30,6 +36,13 @@ struct SlackSetupView: View {
} }
saveBar saveBar
// v0.13 Messaging Gateway behavior self-hides on pre-v0.13.
GatewayBehaviorSection(
platform: "slack",
capabilities: capabilitiesStore?.capabilities ?? .empty,
context: context
)
} }
.onAppear { viewModel.load() } .onAppear { viewModel.load() }
} }
@@ -4,7 +4,13 @@ import ScarfDesign
struct TelegramSetupView: View { struct TelegramSetupView: View {
@State private var viewModel: TelegramSetupViewModel @State private var viewModel: TelegramSetupViewModel
init(context: ServerContext) { _viewModel = State(initialValue: TelegramSetupViewModel(context: context)) } @Environment(\.hermesCapabilities) private var capabilitiesStore
let context: ServerContext
init(context: ServerContext) {
self.context = context
_viewModel = State(initialValue: TelegramSetupViewModel(context: context))
}
var body: some View { var body: some View {
@@ -29,6 +35,13 @@ struct TelegramSetupView: View {
} }
saveBar saveBar
// v0.13 Messaging Gateway behavior self-hides on pre-v0.13.
GatewayBehaviorSection(
platform: "telegram",
capabilities: capabilitiesStore?.capabilities ?? .empty,
context: context
)
} }
.onAppear { viewModel.load() } .onAppear { viewModel.load() }
} }
@@ -4,7 +4,13 @@ import ScarfDesign
struct WhatsAppSetupView: View { struct WhatsAppSetupView: View {
@State private var viewModel: WhatsAppSetupViewModel @State private var viewModel: WhatsAppSetupViewModel
init(context: ServerContext) { _viewModel = State(initialValue: WhatsAppSetupViewModel(context: context)) } @Environment(\.hermesCapabilities) private var capabilitiesStore
let context: ServerContext
init(context: ServerContext) {
self.context = context
_viewModel = State(initialValue: WhatsAppSetupViewModel(context: context))
}
var body: some View { var body: some View {
@@ -29,6 +35,14 @@ struct WhatsAppSetupView: View {
} }
saveBar saveBar
// v0.13 Messaging Gateway behavior self-hides on pre-v0.13.
GatewayBehaviorSection(
platform: "whatsapp",
capabilities: capabilitiesStore?.capabilities ?? .empty,
context: context
)
Divider() Divider()
pairingSection pairingSection
} }
@@ -5,6 +5,33 @@ import ScarfDesign
struct PlatformsView: View { struct PlatformsView: View {
@State private var viewModel: PlatformsViewModel @State private var viewModel: PlatformsViewModel
@Environment(HermesFileWatcher.self) private var fileWatcher @Environment(HermesFileWatcher.self) private var fileWatcher
@Environment(\.hermesCapabilities) private var capabilitiesStore
/// Capabilities resolved at view-eval time. Defaults to `.empty` outside
/// the per-server `ContextBoundRoot`. Used to filter `KnownPlatforms.all`
/// for v0.13-only entries (Google Chat) see `visiblePlatforms` for
/// the deliberate asymmetry: pre-v0.12 hosts still see Yuanbao + Teams
/// unfiltered, by design.
private var capabilities: HermesCapabilities {
capabilitiesStore?.capabilities ?? .empty
}
/// Capability-filtered platform list. Today only **Google Chat** is
/// gated Yuanbao and Microsoft Teams stay unfiltered to avoid
/// changing v0.12 host UX in a v0.13 work-stream (WS-5 plan §Q4).
/// If we later decide to gate the v0.12 platforms too, add their
/// flags here; the `default: true` arm keeps every other platform
/// visible.
private var visiblePlatforms: [HermesToolPlatform] {
KnownPlatforms.all.filter { p in
switch p.name {
case "google-chat", "googlechat":
return capabilities.hasGoogleChatPlatform
default:
return true
}
}
}
init(context: ServerContext) { init(context: ServerContext) {
_viewModel = State(initialValue: PlatformsViewModel(context: context)) _viewModel = State(initialValue: PlatformsViewModel(context: context))
@@ -40,12 +67,12 @@ struct PlatformsView: View {
List(selection: Binding( List(selection: Binding(
get: { viewModel.selected.name }, get: { viewModel.selected.name },
set: { name in set: { name in
if let p = viewModel.platforms.first(where: { $0.name == name }) { if let p = visiblePlatforms.first(where: { $0.name == name }) {
viewModel.selected = p viewModel.selected = p
} }
} }
)) { )) {
ForEach(viewModel.platforms) { platform in ForEach(visiblePlatforms) { platform in
HStack(spacing: 8) { HStack(spacing: 8) {
Image(systemName: KnownPlatforms.icon(for: platform.name)) Image(systemName: KnownPlatforms.icon(for: platform.name))
.frame(width: 20) .frame(width: 20)
@@ -149,6 +176,7 @@ struct PlatformsView: View {
case "webhook": WebhookSetupView(context: ctx) case "webhook": WebhookSetupView(context: ctx)
case "yuanbao": yuanbaoPanel case "yuanbao": yuanbaoPanel
case "microsoft-teams": microsoftTeamsPanel case "microsoft-teams": microsoftTeamsPanel
case "google-chat", "googlechat": googleChatPanel
default: default:
SettingsSection(title: LocalizedStringKey(viewModel.selected.displayName), icon: KnownPlatforms.icon(for: viewModel.selected.name)) { SettingsSection(title: LocalizedStringKey(viewModel.selected.displayName), icon: KnownPlatforms.icon(for: viewModel.selected.name)) {
ReadOnlyRow(label: "Setup", value: "No setup form for this platform yet.") ReadOnlyRow(label: "Setup", value: "No setup form for this platform yet.")
@@ -180,6 +208,27 @@ struct PlatformsView: View {
} }
} }
/// Hermes v0.13 Google Chat is the 20th gateway platform. Like
/// Yuanbao + Microsoft Teams, the auth dance is OAuth-style and
/// lives outside Scarf, so the panel surfaces the setup verb rather
/// than a per-field form. The `GatewayBehaviorSection` below it picks
/// up the v0.13 allowlist + behavior toggles, capability-gated.
@ViewBuilder
private var googleChatPanel: some View {
VStack(alignment: .leading, spacing: ScarfSpace.s3) {
SettingsSection(title: "Google Chat", icon: KnownPlatforms.icon(for: "google-chat")) {
ReadOnlyRow(label: "Type", value: "Generic env-driven gateway adapter (v0.13+)")
ReadOnlyRow(label: "Setup", value: "Run `hermes setup` and select Google Chat to walk the OAuth flow.")
ReadOnlyRow(label: "Configured", value: viewModel.hasConfigBlock(for: viewModel.selected) ? "Yes" : "No")
}
GatewayBehaviorSection(
platform: "google-chat",
capabilities: capabilities,
context: viewModel.context
)
}
}
private var cliPanel: some View { private var cliPanel: some View {
SettingsSection(title: "CLI", icon: "terminal") { SettingsSection(title: "CLI", icon: "terminal") {
ReadOnlyRow(label: "Scope", value: "Local terminal sessions") ReadOnlyRow(label: "Scope", value: "Local terminal sessions")
@@ -112,10 +112,17 @@ final class ProfilesViewModel {
} }
} }
func create(name: String, cloneConfig: Bool, cloneAll: Bool) { func create(name: String, cloneConfig: Bool, cloneAll: Bool, noSkills: Bool = false) {
var args = ["profile", "create", name] var args = ["profile", "create", name]
if cloneAll { args.append("--clone-all") } if cloneAll { args.append("--clone-all") }
else if cloneConfig { args.append("--clone") } else if cloneConfig { args.append("--clone") }
// v0.13+: Empty-profile creation. The wire is independent of
// --clone / --clone-all per the v0.13 release notes the user
// can stack `--clone --no-skills` to clone config but skip
// skills, which is a plausible workflow. The UI still disables
// the toggle under --clone-all (Decision H, see ProfilesView)
// but the wire is permissive.
if noSkills { args.append("--no-skills") }
runAndReload(args, success: "Profile '\(name)' created") runAndReload(args, success: "Profile '\(name)' created")
} }
@@ -11,7 +11,12 @@ struct ProfilesView: View {
@State private var createName = "" @State private var createName = ""
@State private var createCloneConfig = true @State private var createCloneConfig = true
@State private var createCloneAll = false @State private var createCloneAll = false
/// v0.13+ `--no-skills` toggle. Mutually exclusive with `--clone-all`
/// at the UX layer (Decision H from the WS-7 plan): a full clone
/// copies skills wholesale `--no-skills` would be a contradiction.
@State private var createNoSkills = false
@State private var showRename = false @State private var showRename = false
@Environment(\.hermesCapabilities) private var capabilitiesStore
init(context: ServerContext) { init(context: ServerContext) {
_viewModel = State(initialValue: ProfilesViewModel(context: context)) _viewModel = State(initialValue: ProfilesViewModel(context: context))
@@ -123,7 +128,7 @@ struct ProfilesView: View {
} }
Spacer() Spacer()
Button { Button {
createName = ""; createCloneConfig = true; createCloneAll = false createName = ""; createCloneConfig = true; createCloneAll = false; createNoSkills = false
showCreate = true showCreate = true
} label: { } label: {
Label("Create", systemImage: "plus") Label("Create", systemImage: "plus")
@@ -300,11 +305,31 @@ struct ProfilesView: View {
Toggle("Clone config, .env, SOUL.md from active profile", isOn: $createCloneConfig) Toggle("Clone config, .env, SOUL.md from active profile", isOn: $createCloneConfig)
.disabled(createCloneAll) .disabled(createCloneAll)
Toggle("Full copy of active profile (all state)", isOn: $createCloneAll) Toggle("Full copy of active profile (all state)", isOn: $createCloneAll)
// TODO(WS-7-Q8): Decision H disable --no-skills when --clone-all
// is on. A full clone copies skills wholesale; --no-skills would
// be a contradiction. Verify Hermes's behaviour with both flags
// (argparse mutual exclusion vs. last-flag-wins vs. clone-but-
// skip-skills) and relax the disabled state if Hermes does
// something useful with the combination.
if capabilitiesStore?.capabilities.hasProfileNoSkills ?? false {
Toggle("Empty profile (no skills)", isOn: $createNoSkills)
.disabled(createCloneAll)
}
HStack { HStack {
Spacer() Spacer()
Button("Cancel") { showCreate = false } Button("Cancel") { showCreate = false }
Button("Create") { Button("Create") {
viewModel.create(name: createName, cloneConfig: createCloneConfig, cloneAll: createCloneAll) viewModel.create(
name: createName,
cloneConfig: createCloneConfig,
cloneAll: createCloneAll,
// Defensive: if the toggle isn't visible (pre-v0.13)
// the state is always `false`, but read it through
// the capability gate anyway so a stale state value
// can't sneak `--no-skills` to a CLI that doesn't
// know it.
noSkills: (capabilitiesStore?.capabilities.hasProfileNoSkills ?? false) ? createNoSkills : false
)
showCreate = false showCreate = false
} }
.buttonStyle(.borderedProminent) .buttonStyle(.borderedProminent)
@@ -29,8 +29,31 @@ final class SettingsViewModel {
// that no-ops on older hosts is low compared to gating overhead. // that no-ops on older hosts is low compared to gating overhead.
var terminalBackends = ["local", "docker", "singularity", "modal", "daytona", "ssh", "vercel"] var terminalBackends = ["local", "docker", "singularity", "modal", "daytona", "ssh", "vercel"]
var browserBackends = ["browseruse", "firecrawl", "local"] var browserBackends = ["browseruse", "firecrawl", "local"]
var ttsProviders = ["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts", "piper"] // v0.13: `xai` joins the TTS provider list. xAI shipped TTS earlier
// (v0.12) but the v0.13 add-on is custom voice cloning see
// `HermesCapabilities.hasXAIVoiceCloning` and the badge in VoiceTab.
// The provider option itself is ungated so pre-v0.13 hosts with xAI
// keys can still pick it.
var ttsProviders = ["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts", "piper", "xai"]
var sttProviders = ["local", "groq", "openai", "mistral"] var sttProviders = ["local", "groq", "openai", "mistral"]
/// Static-message translation languages honored by Hermes v0.13's
/// `display.language` key. The first row's empty value writes no
/// key equivalent to "Hermes default" while explicit `en` writes
/// the code so users who care about determinism can pin it. Keep the
/// label list in sync with the Hermes v0.13 release notes; new
/// languages should be appended in alphabetical order by display
/// label so the picker stays scannable.
var displayLanguages: [(code: String, label: String)] = [
("", "English (default)"),
("en", "English"),
("zh", "中文 (Chinese)"),
("ja", "日本語 (Japanese)"),
("de", "Deutsch (German)"),
("es", "Español (Spanish)"),
("fr", "Français (French)"),
("uk", "Українська (Ukrainian)"),
("tr", "Türkçe (Turkish)"),
]
var memoryProviders = ["", "honcho", "openviking", "mem0", "hindsight", "holographic", "retaindb", "byterover", "supermemory"] var memoryProviders = ["", "honcho", "openviking", "mem0", "hindsight", "holographic", "retaindb", "byterover", "supermemory"]
var saveMessage: String? var saveMessage: String?
var isLoading = false var isLoading = false
@@ -104,6 +127,10 @@ final class SettingsViewModel {
func setToolProgressCommand(_ value: Bool) { setSetting("display.tool_progress_command", value: value ? "true" : "false") } func setToolProgressCommand(_ value: Bool) { setSetting("display.tool_progress_command", value: value ? "true" : "false") }
func setToolPreviewLength(_ value: Int) { setSetting("display.tool_preview_length", value: String(value)) } func setToolPreviewLength(_ value: Int) { setSetting("display.tool_preview_length", value: String(value)) }
func setBusyInputMode(_ value: String) { setSetting("display.busy_input_mode", value: value) } func setBusyInputMode(_ value: String) { setSetting("display.busy_input_mode", value: value) }
/// v0.13: `display.language` for static-message translations. Empty
/// string writes "" via `hermes config set` which Hermes treats as
/// "use default"; explicit codes pin the language.
func setDisplayLanguage(_ value: String) { setSetting("display.language", value: value) }
// MARK: - Agent // MARK: - Agent
@@ -143,6 +170,16 @@ final class SettingsViewModel {
func setBrowserAllowPrivateURLs(_ value: Bool) { setSetting("browser.allow_private_urls", value: value ? "true" : "false") } func setBrowserAllowPrivateURLs(_ value: Bool) { setSetting("browser.allow_private_urls", value: value ? "true" : "false") }
func setCamofoxManagedPersistence(_ value: Bool) { setSetting("browser.camofox.managed_persistence", value: value ? "true" : "false") } func setCamofoxManagedPersistence(_ value: Bool) { setSetting("browser.camofox.managed_persistence", value: value ? "true" : "false") }
// MARK: - Web Tools
/// Pre-v0.13 combined backend. Pre-v0.13 hosts read this; v0.13+
/// hosts read it for back-compat but the WebToolsTab gates writes
/// on `hasWebToolsBackendSplit` so the tab only writes the split
/// keys on v0.13.
func setWebToolsBackend(_ value: String) { setSetting("web_tools.backend", value: value) }
func setWebToolsSearchBackend(_ value: String) { setSetting("web_tools.search.backend", value: value) }
func setWebToolsExtractBackend(_ value: String) { setSetting("web_tools.extract.backend", value: value) }
// MARK: - Voice / TTS / STT // MARK: - Voice / TTS / STT
func setAutoTTS(_ value: Bool) { setSetting("voice.auto_tts", value: value ? "true" : "false") } func setAutoTTS(_ value: Bool) { setSetting("voice.auto_tts", value: value ? "true" : "false") }
@@ -158,6 +195,10 @@ final class SettingsViewModel {
func setTTSOpenAIVoice(_ value: String) { setSetting("tts.openai.voice", value: value) } func setTTSOpenAIVoice(_ value: String) { setSetting("tts.openai.voice", value: value) }
func setTTSNeuTTSModel(_ value: String) { setSetting("tts.neutts.model", value: value) } func setTTSNeuTTSModel(_ value: String) { setSetting("tts.neutts.model", value: value) }
func setTTSNeuTTSDevice(_ value: String) { setSetting("tts.neutts.device", value: value) } func setTTSNeuTTSDevice(_ value: String) { setSetting("tts.neutts.device", value: value) }
// v0.13: xAI TTS / Custom Voices. TODO(WS-8-Q2): grep-verify key
// names against `~/.hermes/hermes-agent/hermes_cli/voice/tts.py`.
func setTTSXAIVoiceID(_ value: String) { setSetting("tts.xai.voice_id", value: value) }
func setTTSXAIModel(_ value: String) { setSetting("tts.xai.model", value: value) }
func setSTTEnabled(_ value: Bool) { setSetting("stt.enabled", value: value ? "true" : "false") } func setSTTEnabled(_ value: Bool) { setSetting("stt.enabled", value: value ? "true" : "false") }
func setSTTProvider(_ value: String) { setSetting("stt.provider", value: value) } func setSTTProvider(_ value: String) { setSetting("stt.provider", value: value) }
func setSTTLocalModel(_ value: String) { setSetting("stt.local.model", value: value) } func setSTTLocalModel(_ value: String) { setSetting("stt.local.model", value: value) }
@@ -152,8 +152,23 @@ struct PickerRow: View {
let label: String let label: String
let selection: String let selection: String
let options: [String] let options: [String]
let optionLabel: ((String) -> String)?
let onChange: (String) -> Void let onChange: (String) -> Void
init(
label: String,
selection: String,
options: [String],
optionLabel: ((String) -> String)? = nil,
onChange: @escaping (String) -> Void
) {
self.label = label
self.selection = selection
self.options = options
self.optionLabel = optionLabel
self.onChange = onChange
}
var body: some View { var body: some View {
HStack { HStack {
SettingsRowLabel(label: label) SettingsRowLabel(label: label)
@@ -162,7 +177,7 @@ struct PickerRow: View {
set: { onChange($0) } set: { onChange($0) }
)) { )) {
ForEach(options, id: \.self) { option in ForEach(options, id: \.self) { option in
Text(option.isEmpty ? "(none)" : option).tag(option) Text(displayLabel(for: option)).tag(option)
} }
} }
.frame(maxWidth: 250) .frame(maxWidth: 250)
@@ -170,6 +185,13 @@ struct PickerRow: View {
} }
.settingsRowChrome() .settingsRowChrome()
} }
private func displayLabel(for option: String) -> String {
if let mapper = optionLabel {
return mapper(option)
}
return option.isEmpty ? "(none)" : option
}
} }
struct ToggleRow: View { struct ToggleRow: View {
@@ -26,6 +26,7 @@ struct SettingsView: View {
case agent = "Agent" case agent = "Agent"
case terminal = "Terminal" case terminal = "Terminal"
case browser = "Browser" case browser = "Browser"
case webTools = "Web Tools"
case voice = "Voice" case voice = "Voice"
case memory = "Memory" case memory = "Memory"
case auxiliary = "Aux Models" case auxiliary = "Aux Models"
@@ -41,6 +42,7 @@ struct SettingsView: View {
case .agent: return "Agent" case .agent: return "Agent"
case .terminal: return "Terminal" case .terminal: return "Terminal"
case .browser: return "Browser" case .browser: return "Browser"
case .webTools: return "Web Tools"
case .voice: return "Voice" case .voice: return "Voice"
case .memory: return "Memory" case .memory: return "Memory"
case .auxiliary: return "Aux Models" case .auxiliary: return "Aux Models"
@@ -56,6 +58,7 @@ struct SettingsView: View {
case .agent: return "brain.head.profile" case .agent: return "brain.head.profile"
case .terminal: return "terminal" case .terminal: return "terminal"
case .browser: return "globe" case .browser: return "globe"
case .webTools: return "globe.americas"
case .voice: return "mic" case .voice: return "mic"
case .memory: return "memorychip" case .memory: return "memorychip"
case .auxiliary: return "sparkles.rectangle.stack" case .auxiliary: return "sparkles.rectangle.stack"
@@ -171,6 +174,7 @@ struct SettingsView: View {
case .agent: AgentTab(viewModel: viewModel) case .agent: AgentTab(viewModel: viewModel)
case .terminal: TerminalTab(viewModel: viewModel) case .terminal: TerminalTab(viewModel: viewModel)
case .browser: BrowserTab(viewModel: viewModel) case .browser: BrowserTab(viewModel: viewModel)
case .webTools: WebToolsTab(viewModel: viewModel)
case .voice: VoiceTab(viewModel: viewModel) case .voice: VoiceTab(viewModel: viewModel)
case .memory: MemoryTab(viewModel: viewModel) case .memory: MemoryTab(viewModel: viewModel)
case .auxiliary: AuxiliaryTab(viewModel: viewModel) case .auxiliary: AuxiliaryTab(viewModel: viewModel)
@@ -131,6 +131,8 @@ struct AdvancedTab: View {
isOn: viewModel.config.redactionEnabled isOn: viewModel.config.redactionEnabled
) { viewModel.setSetting("redaction.enabled", value: $0 ? "true" : "false") } ) { viewModel.setSetting("redaction.enabled", value: $0 ? "true" : "false") }
redactionDefaultsHint
ToggleRow( ToggleRow(
label: "Runtime metadata footer", label: "Runtime metadata footer",
isOn: viewModel.config.runtimeMetadataFooter isOn: viewModel.config.runtimeMetadataFooter
@@ -138,6 +140,30 @@ struct AdvancedTab: View {
} }
} }
/// Inline hint below the redaction toggle. The server-side default
/// flipped from OFF (v0.12) to ON (v0.13), but Scarf's parser still
/// reads "absent key" as `false` meaning a v0.13 host with no
/// explicit key in `config.yaml` shows the toggle OFF while the
/// agent treats redaction as ON. Hint copy disambiguates so users
/// can tell what's actually happening server-side.
@ViewBuilder
private var redactionDefaultsHint: some View {
let isV013 = capabilitiesStore?.capabilities.isV013OrLater ?? false
HStack {
Text("")
.font(.caption)
.frame(width: 160, alignment: .trailing)
Text(isV013
? "Recommended: ON. Hermes v0.13+ defaults to redacting secrets unless you opt out."
: "Default OFF in Hermes v0.12. Toggle ON to redact secrets in logs and shares.")
.font(.caption)
.foregroundStyle(.secondary)
Spacer()
}
.padding(.horizontal, 12)
.padding(.vertical, 4)
}
private var backupSection: some View { private var backupSection: some View {
SettingsSection(title: "Backup & Restore", icon: "externaldrive") { SettingsSection(title: "Backup & Restore", icon: "externaldrive") {
HStack { HStack {
@@ -7,6 +7,7 @@ import ScarfCore
struct GeneralTab: View { struct GeneralTab: View {
@Bindable var viewModel: SettingsViewModel @Bindable var viewModel: SettingsViewModel
@Environment(AppCoordinator.self) private var coordinator @Environment(AppCoordinator.self) private var coordinator
@Environment(\.hermesCapabilities) private var capabilitiesStore
var body: some View { var body: some View {
SettingsSection(title: "Model", icon: "cpu") { SettingsSection(title: "Model", icon: "cpu") {
@@ -39,6 +40,20 @@ struct GeneralTab: View {
SettingsSection(title: "Locale", icon: "globe.americas") { SettingsSection(title: "Locale", icon: "globe.americas") {
EditableTextField(label: "Timezone (IANA)", value: viewModel.config.timezone) { viewModel.setTimezone($0) } EditableTextField(label: "Timezone (IANA)", value: viewModel.config.timezone) { viewModel.setTimezone($0) }
// v0.13: `display.language` picker. Hidden on pre-v0.13 hosts
// because writing the key would no-op silently. Two "English"
// entries by design empty string preserves "no key" semantics
// (Hermes-default), explicit `en` pins it.
if capabilitiesStore?.capabilities.hasDisplayLanguage == true {
PickerRow(
label: "Display language",
selection: viewModel.config.display.language,
options: viewModel.displayLanguages.map(\.code),
optionLabel: { code in
viewModel.displayLanguages.first { $0.code == code }?.label ?? code
}
) { viewModel.setDisplayLanguage($0) }
}
} }
UpdatesSection() UpdatesSection()
@@ -1,9 +1,11 @@
import SwiftUI import SwiftUI
import ScarfCore import ScarfCore
import ScarfDesign
/// Voice tab push-to-talk + TTS + STT provider settings. /// Voice tab push-to-talk + TTS + STT provider settings.
struct VoiceTab: View { struct VoiceTab: View {
@Bindable var viewModel: SettingsViewModel @Bindable var viewModel: SettingsViewModel
@Environment(\.hermesCapabilities) private var capabilitiesStore
var body: some View { var body: some View {
SettingsSection(title: "Push-to-Talk", icon: "mic") { SettingsSection(title: "Push-to-Talk", icon: "mic") {
@@ -28,6 +30,16 @@ struct VoiceTab: View {
case "neutts": case "neutts":
EditableTextField(label: "Model", value: viewModel.config.voice.ttsNeuTTSModel) { viewModel.setTTSNeuTTSModel($0) } EditableTextField(label: "Model", value: viewModel.config.voice.ttsNeuTTSModel) { viewModel.setTTSNeuTTSModel($0) }
PickerRow(label: "Device", selection: viewModel.config.voice.ttsNeuTTSDevice, options: ["cpu", "cuda"]) { viewModel.setTTSNeuTTSDevice($0) } PickerRow(label: "Device", selection: viewModel.config.voice.ttsNeuTTSDevice, options: ["cpu", "cuda"]) { viewModel.setTTSNeuTTSDevice($0) }
case "xai":
// v0.13: xAI TTS surface. Voice ID + Model are always
// visible (xAI TTS shipped earlier); the cloning-supported
// badge is gated on `hasXAIVoiceCloning` so pre-v0.13 hosts
// see the input rows but no cloning advertisement.
EditableTextField(label: "Voice ID", value: viewModel.config.voice.ttsXAIVoiceID) { viewModel.setTTSXAIVoiceID($0) }
EditableTextField(label: "Model", value: viewModel.config.voice.ttsXAIModel) { viewModel.setTTSXAIModel($0) }
if capabilitiesStore?.capabilities.hasXAIVoiceCloning == true {
xaiCloningBadge
}
default: default:
EmptyView() EmptyView()
} }
@@ -49,4 +61,24 @@ struct VoiceTab: View {
} }
} }
} }
/// Inline hint chip+caption shown below xAI's Voice ID + Model fields
/// on v0.13+. References `hermes voice` because Scarf doesn't manage
/// cloned voices in-app yet the badge is discovery-only. Out-of-scope
/// for v2.8: an in-app cloned-voice manager (would be its own feature).
@ViewBuilder
private var xaiCloningBadge: some View {
HStack(alignment: .center, spacing: 8) {
Text("")
.font(.caption)
.frame(width: 160, alignment: .trailing)
ScarfBadge("Cloning supported", kind: .info)
Text("Manage cloned voices in your terminal: `hermes voice` (xAI subcommands).")
.font(.caption)
.foregroundStyle(.secondary)
Spacer()
}
.padding(.horizontal, 12)
.padding(.vertical, 4)
}
} }

Some files were not shown because too many files have changed in this diff Show More