diff --git a/.github/workflows/fixtures.yml b/.github/workflows/fixtures.yml new file mode 100644 index 00000000..3fc8602c --- /dev/null +++ b/.github/workflows/fixtures.yml @@ -0,0 +1,58 @@ +name: fixtures + +on: + push: + branches: + - main + paths: + - 'web/src/chat/**' + - 'web/src/lib/message-window-store.ts' + - 'web/src/lib/sessionPatch.ts' + - 'web/src/lib/messages.ts' + - 'shared/src/**' + - 'web/scripts/**' + - 'shared/fixtures/**' + - '.github/workflows/fixtures.yml' + pull_request: + paths: + - 'web/src/chat/**' + - 'web/src/lib/message-window-store.ts' + - 'web/src/lib/sessionPatch.ts' + - 'web/src/lib/messages.ts' + - 'shared/src/**' + - 'web/scripts/**' + - 'shared/fixtures/**' + - '.github/workflows/fixtures.yml' + +permissions: + contents: read + +concurrency: + group: fixtures-${{ github.ref }} + cancel-in-progress: true + +jobs: + drift-gate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.3.14 + - run: bun install + - name: Regenerate fixtures from the web pipeline + run: bun run gen:fixtures + - name: Fail on fixtures drift + id: drift + # --intent-to-add makes brand-new fixture files (new cases) visible + # to git diff; deletions of stale files are visible either way. + run: | + git add --intent-to-add shared/fixtures + git diff --exit-code -- shared/fixtures + - name: Explain drift + if: failure() && steps.drift.conclusion == 'failure' + run: echo '::error::web pipeline behavior changed — run `bun run gen:fixtures` and commit the updated fixtures so native ports see the diff' + - name: Web self-conformance (fixture-related tests) + # src/lib/sessionPatch matches nothing until K7 lands its tests; + # vitest unions filters, so the extra filter is future-proof, not fatal. + run: cd web && bun run test -- src/chat/fixtures.test.ts src/lib/message-window-store.test.ts src/lib/messages.test.ts src/lib/sessionPatch diff --git a/AGENTS.md b/AGENTS.md index dd7eb586..5fc80cf3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,15 +11,18 @@ Local-first platform for running AI coding agents (Claude Code, Codex, Gemini) w ## Repo layout ``` -cli/ - CLI binary, agent wrappers, runner daemon -hub/ - HTTP API + Socket.IO + SSE + Telegram bot -web/ - React PWA for remote control -shared/ - Common types, schemas, utilities -docs/ - VitePress documentation site -website/ - Marketing site +cli/ - CLI binary, agent wrappers, runner daemon +hub/ - HTTP API + Socket.IO + SSE + Telegram bot +web/ - React PWA for remote control +ios/ - Native SwiftUI app (in development) +android/ - Native Kotlin Compose app (in development) +shared/ - Common types, schemas, utilities +shared/fixtures/ - Golden chat fixtures, generated from web pipeline (never hand-edit) +docs/ - VitePress documentation site +website/ - Marketing site ``` -Bun workspaces; `shared` consumed by cli, hub, web. +Bun workspaces; `shared` consumed by cli, hub, web. `ios`/`android` outside workspaces (Xcode / Gradle toolchains). ## Architecture overview @@ -64,11 +67,15 @@ Bun workspaces; `shared` consumed by cli, hub, web. ```bash bun typecheck # All packages -bun run test # cli + hub tests +bun run test # cli + hub + web + shared tests bun run dev # hub + web concurrently bun run build:single-exe # All-in-one binary +bun run gen:fixtures # Regenerate shared/fixtures/ from web pipeline +cd android && ./gradlew :core:protocol:test # Android protocol conformance ``` +iOS tests run in CI (`ios.yml`: macOS `swift test`); no local Xcode/Swift toolchain assumed. + ## Key source dirs ### CLI (`cli/src/`) @@ -109,6 +116,22 @@ bun run build:single-exe # All-in-one binary - `messages.ts` - Message parsing utilities - `modes.ts` - Permission/model mode definitions +### iOS (`ios/`) +- `Packages/HapiKit/` - local SPM package: `HapiProtocol` (wire models + chat pipeline, fixtures-verified), `HapiClient` (API/auth/SSE/stores) +- `Hapi/` + `Hapi.xcodeproj` - thin SwiftUI app target + +### Android (`android/`) +- `:core:protocol` - pure JVM wire types + chat pipeline (fixtures-verified) +- `:core:data` - transport (OkHttp/SSE), auth, stores +- `:app` - Compose UI, navigation, deep links, FCM + +## Protocol conformance (native apps) + +- `shared/fixtures/**` machine-generated from the web chat pipeline (source of truth). NEVER hand-edit; edit `web/scripts/fixtures/cases/` + regenerate. +- Changing `web/src/chat/**`, `web/src/lib/message-window-store.ts`, or `web/src/lib/sessionPatch.ts`: run `bun run gen:fixtures`, commit the diff. CI enforces (`.github/workflows/fixtures.yml`); fixture diffs auto-trigger iOS/Android conformance suites (`ios.yml`/`android.yml`). +- Native client contract docs: `docs/api/client-contract/` (auth, rest, sse, pagination, messages, errors). +- Tracks: `ios/` (SwiftUI, iOS 17+) + `android/` (Kotlin Compose, minSdk 26) — independent codebases, share only contract + fixtures. Plan: `~/.claude/plans/web-pwa-abundant-yeti.md`. + ## Pre-push self-review (agents) Before commit/push/PR: use the **`pre-push-review`** skill (`~/.cursor/skills/pre-push-review/`). @@ -124,7 +147,7 @@ Before commit/push/PR: use the **`pre-push-review`** skill (`~/.cursor/skills/pr - Run: `bun run test` (from root) or `bun run test` (from package) - Hub tests: `hub/src/**/*.test.ts` - CLI tests: `cli/src/**/*.test.ts` -- No web tests currently +- Web tests: `web/src/**/*.test.{ts,tsx}` (fixtures self-check: `web/src/chat/fixtures.test.ts`) ## Common tasks diff --git a/README.md b/README.md index 206694e0..13eda0f9 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,10 @@ For self-hosted options (Cloudflare Tunnel, Tailscale), see [Installation](docs/ - [Why HAPI](docs/guide/why-hapi.md) - [FAQ](docs/guide/faq.md) +## Native apps (iOS / Android) + +Fully native SwiftUI and Kotlin Compose clients are in development under `ios/` and `android/`. They pair with your hub by scanning the same terminal QR code as the web app, and follow the same protocol — see the [client contract docs](docs/api/client-contract/index.md). + ## Build from source ```bash