08 — Authoring App
The BKA app the creator opens. Browser-first 4G app, Foundry-shaped (chat-with-doc + library + composer), tailored to publish-flow concerns.
Where it lives
- Repo:
Trikulture-Kyokai-Synthetica/bka(or similar — final repo name TBD) - Deployed at:
bka.binary-blender.com(or similar TLD) - Built on: 4G Web Dev Stack (per 03_TECH_STACK.md)
One app, deployed once, shared across all creators. Each creator's data is in their own GitHub repos + lives transiently in their browser's OPFS-SQLite cache.
App surface — top-level navigation
Mirroring agicore-foundry's titlebar pattern:
┌────────────────────────────────────────────────────────────┐
│ ← apps BKA — <handle> [compose] [library] [stats] │
│ [⌘K] [?] [chip] │
└────────────────────────────────────────────────────────────┘
│ │
│ (active route) │
│ │
└─────────────────────────────────────────────────────────────┘
Tabs (top-right):
- Compose — the chat-with-doc surface for drafting + AI editing
- Library — the asset library (uploaded media, drafts, published posts)
- Stats — site analytics (CF Pages stats embedded) + indexer feedback (if registered)
Top-left: ← apps links back to binary-blender.com/apps (same as Foundry + andon-loop-demo)
Top-right helpers: command palette, help, UserChip
Compose tab (the heart of the app)
Borrowed wholesale from agicore-foundry's Library route — chat-with-doc with the <edit> + <create_document> tag protocol, just specialized for posts.
┌─────────────────────┬─────────────────────┬──────────────────────┐
│ Chat │ Post editor │ Right sidebar │
│ - replies │ - title input │ - session picker │
│ - composer │ - markdown editor │ - media uploads │
│ │ - live preview │ - tags input │
│ │ │ - publish button │
└─────────────────────┴─────────────────────┴──────────────────────┘
Chat (left): the AI conversation. Uses the cross-app activeSessionStore so the session from Foundry/Community follows you here. The model can:
- Suggest titles
- Draft body text
- Edit the active draft via
<edit>...</edit>(replaces editor content) - Create a NEW draft via
<create_document name="..." language="markdown">...</create_document>(mints a new draft, swaps editor focus to it)
Same doc-edit-stream filter as Foundry/Library. Same prompt protocol. Same patterns.
Editor (center): markdown editor (CodeMirror). Above: title input. Below: live preview pane (toggleable).
The editor's content is the body of the draft. Title + metadata sit in fields above; tags + thumbnail picker sit in the right sidebar.
Right sidebar (tabs):
- Drafts — list of in-progress drafts in private repo (newest first); click to switch
- Media — drag-drop media uploader; thumbnails of recently uploaded items
- Meta — title, slug, tags, thumbnail, summary, publish date (defaults to now)
- Publish — big button + pre-publish checklist (validates everything's ready, warns about missing fields)
Library tab
Two-pane view of the creator's content:
┌──────────────────────────┬─────────────────────────────────┐
│ Filters │ Items │
│ - status: │ - thumbnails or list view │
│ [ ] draft │ - one row per post/draft │
│ [ ] published │ - click to open in Compose │
│ [ ] unpublished │ - right-click for actions │
│ - tag: │ (delete, unpublish, edit) │
│ [ ] intro │ │
│ [ ] code │ │
│ - kind: │ │
│ [ ] post │ │
│ [ ] video │ │
└──────────────────────────┴─────────────────────────────────┘
Reads from both private repo (drafts) and public repo (published) via the local git-store cache. Lets the creator manage the full archive without leaving the app.
Media management:
- Upload large files (>100KB) → BKA uploads to GitHub Releases on public repo + stages a draft media reference
- Upload small files → BKA commits to
assets/inline/directly in public repo - Replace media on a published post → BKA edits the meta.json + uploads new release asset + republishes
Stats tab
A small dashboard showing:
- CF Pages stats for the creator's site (via CF Analytics API — page views, top URLs, source countries)
- Indexer feedback if registered (how often the creator's items appear in discovery results, top tags hit, etc.)
- Recent publishes (history list with deploy status)
CF Analytics requires the creator's CF token (already cached during onboarding). All requests browser-direct to CF API. No data aggregated server-side by us.
State + storage
Per-creator data (mirrored from GitHub via git-store)
Following the agicore-foundry git-canonical pattern (4G doc 13):
- Local OPFS-SQLite is the read cache + write-staging area
- Local Lightning-FS git tree mirrors both private + public repos
- Auto-push debounced to GitHub on writes (30s default, matching Foundry)
- Pull on app open to merge any changes made from other devices
Two git-stores: one for the private repo, one for the public repo. Both use the same git-store/ library pattern, just with different repo URLs.
App-level state (browser, not git-backed)
- Active session (cross-app
activeSessionStore) - Wizard state (until wizard completes)
- Theme / viewer-preview settings
- CF + GitHub tokens (localStorage, treated as secrets)
Cross-app behavior
BKA is a peer of Foundry / Community / andon-loop-demo in the binary-blender stack:
- Same Google sign-in carries across all of them
- Active session follows — picked in Chat, used in Library, also used in BKA's Compose tab
- Community board accessible from BKA via the same Community tab (or a link out to the app at
community.binary-blender.com)
Visual register
Per the per-audience-register feedback memory, BKA needs a register distinct from the four already named. Tentative: warm-publication.
- Palette: paper-cream background (
#f5efe0reused from cartoon-industrial), warm dark text (#1d1d1d), one accent color the creator picks (defaults to a deep teal#0d6e6e) - Typography: a sans-serif display font (Inter / Söhne / similar) for chrome; a serif (Charter / Source Serif / similar) for the editor body to feel like writing on paper
- Spacing: generous — the creator is writing, not poking at a tool
- Theme variants: creators pick one of N bundled themes for their viewer site; the authoring app stays in the standard BKA register regardless
To be finalized in a design pass once the layout is stubbed.
Component reuse from agicore-foundry
Specific files to copy/adapt (per the 4G stack pattern):
| Foundry file | BKA use |
|---|---|
src/lib/google-auth.ts |
verbatim |
src/store/authStore.ts |
verbatim |
src/components/SignInGate.tsx |
verbatim |
src/components/UserChip.tsx |
verbatim |
src/store/activeSessionStore.ts |
verbatim |
src/lib/git-store/* |
verbatim (with two store instances) |
src/lib/github-sync.ts |
adapt for two-repo + Releases API |
src/lib/auto-push.ts |
verbatim |
src/lib/doc-edit-stream.ts |
verbatim |
src/lib/chat-send.ts |
verbatim |
src/lib/babyai-client.ts |
verbatim |
src/components/Sidebar/ModelsPanel.tsx |
adapt for BKA's model picker |
src/components/SessionPanel.tsx |
verbatim |
src/components/GithubBackupModal.tsx |
mostly verbatim, repurposed for BKA's per-creator backup view |
The principle: don't reinvent. The Foundry plumbing works. BKA is the next 4G app, not the first.
What's NEW in BKA (no Foundry precedent)
These pieces don't exist in Foundry and need fresh implementation:
- Onboarding wizard (per 04_CREATOR_ONBOARDING.md) — CF API integration, two-repo provisioning, Pages project provisioning
- Two-repo git-sync — adapt the existing single-repo pattern to manage private + public independently
- GitHub Releases asset upload — new API path
- Publish action (per 06_PUBLISH_PIPELINE.md) — atomic multi-file commit + feed regen
- Indexer registration — POST to our worker with Google JWT + feed URL
- CF Pages stats integration — new CF API client
- Viewer-template preview — render the public site live in-app for "what does it look like before I publish"
- Media library — image/audio/video uploads, thumbnails, drag-drop
Each is bounded; total new surface is manageable.
Mobile / tablet
v1 ships desktop-only browser. Mobile authoring is a real use case but adds touch composer + camera/voice capture concerns that deserve their own design pass. Deferred to post-v1.
The viewer site (the creator's public archive) IS mobile-friendly from day 1 — that's a viewer-template concern, not an authoring-app concern.