49 crates, 876 tests green (+17 kei-cortex + 10 cortex-ui TS, was 859). ## kei-cortex — local HTTP daemon (Rust) Axum-based server on :9797 exposing read-only cortex state (ledger, pet, memory) as JSON for browser UI consumption. Bearer token auth. CORS for https://keisei.app. Binds 127.0.0.1 only. ### Endpoints - GET /healthz — unauthenticated liveness - GET /api/v1/cortex/summary — total_dnas + active_pets + recent_sessions - GET /api/v1/cortex/pet/:user_id — pet manifest - POST /api/v1/cortex/pet/:user_id/interaction — log chat - GET /api/v1/cortex/ledger/recent?limit=N — recent agent runs - GET /api/v1/cortex/memory/search?user_id=X&pet_name=Y&q=... — recall ### Security - Token at ~/.keisei/cortex.token (32-byte hex, chmod 600 atomic via OpenOptions mode 0o600) - tower-http CorsLayer with configured allow_origin - tokio::task::spawn_blocking for rusqlite reads - All non-healthz routes protected by Bearer middleware ### Constructor Pattern 14 files, largest 137 LOC. All functions ≤30 LOC. Split: auth / config / error / state / routes + 5 handlers (health/summary/pet/ledger/memory). 17 tests: token roundtrip + chmod 600 (cfg unix) + 401/403/healthz + summary shape + pet 404 + pet parse + interaction 201 + CORS preflight + ledger limit + empty ledger. ## cortex-ui — Svelte 5 + TypeScript + Vite Static web app, build to dist/ (~500 KB incl sourcemaps, 64 KB minified JS+CSS), deployable to https://keisei.app/cortex/. Connects to local kei-cortex daemon via fetch. ### Features - Setup wizard (first run): daemon URL + token paste, saved to localStorage (origin-scoped) - Dashboard: summary cards + nav - PetEditor: view pet.toml fields (identity/voice/edge/forbidden) - LedgerStream: recent agent runs, auto-refresh 5s - MemorySearch: query form + results list - Hash-based routing (no server needed) - Dark-mode via prefers-color-scheme - URL-param override: ?daemon=URL&token=T for one-click setup ### Stack choice Svelte 5 for minimal runtime (~2 KB). TypeScript strict inherits _ts_packages/tsconfig.base.json. Vite for dev + build. vitest for unit tests (10 passing: api header/error, config precedence/overrides). ## User flow Non-dev: 1. Install keisei, run `kei-cortex serve` 2. Open https://keisei.app/cortex 3. Paste daemon URL + token from ~/.keisei/cortex.token 4. View dashboard, edit pet, search memory — all local data, zero cloud Power user (self-host): 1. `cd _ts_packages/packages/cortex-ui && npm run build` 2. Serve dist/ from localhost OR deploy anywhere 3. Point to own daemon URL Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| _rust | ||
| templates | ||
| design-scrape.sh | ||
| figma-tokens.sh | ||
| frontend-inspect.sh | ||
| harden-base.sh | ||
| kei-ci-lint.sh | ||
| kei-docs-scaffold.sh | ||
| kei-sleep-queue.sh | ||
| kei-sleep-setup.sh | ||
| kei-sleep-sync.sh | ||
| live-preview.sh | ||
| log-ship.sh | ||
| MANIFEST.toml | ||
| metrics-scrape.sh | ||
| provision-hetzner.sh | ||
| provision-vultr.sh | ||
| README.md | ||
| screenshot-decode.sh | ||
| tomd.sh | ||
_primitives — first-class building blocks
_primitives/ holds standalone utilities that agents, hooks, and skills
(including /compose-solution) depend on. Unlike _blocks/ (behavioral
markdown) or _manifests/ (agent TOML), primitives are executable shell
programs installed at $HOME/.claude/agents/_primitives/ by install.sh.
Current primitives
| Primitive | Purpose | Invocation |
|---|---|---|
tomd.sh |
Universal non-native-format → markdown converter (PDF, DOCX, XLSX, PPTX, CSV, images, code). | ~/.claude/agents/_primitives/tomd.sh <file> |
tomd.sh is a first-class primitive. Universal non-native-format →
markdown converter with configurable cache directory
(KEISEI_TOMD_CACHE) and KeiSeiKit-style error tags ([tomd]).
Hook integration
hooks/tomd-preread.sh is a PreToolUse(Read) hook that auto-redirects
Claude to the converted markdown when a Read targets .docx / .doc / .xlsx / .pptx / .csv. Cached under $KEISEI_TOMD_CACHE (default
/tmp/keisei-tomd-cache).
/compose-solution discovery
Phase 3 prior-art sweep greps _primitives/ alongside _blocks/,
_manifests/, skills/, _bridges/, hooks/. If a user task involves
file-format parsing, the meta-composer surfaces tomd automatically —
reuse over rewrite (RULE "No Patching").