β–¦β–¦βš™οΈ
srcβ€Ίfiltersβ€Ίvfilters.js... β€’ ● Harness: On
βŽ‡ test*β“§ 0 ⚠ 0⟳ 0Ln 27, Col 3 (539 selected)Spaces: 2UTF-8CRLFJavaScriptGo LiveCursor Tab
⬇ Backend β€” what it'll takeβ—‰ HarnessπŸ””πŸ‘€
Template · Proposed · Not connected

⬇ Backend — what it’ll take

Plausible plan for Harness. We’ll fix the details later — this is the shape of it, not the final wiring. The editor + chat you see now are local-only toys.

At a glance

πŸ“„ 1 — Editor + filesystem

Real files on disk, not the files{} object in this page. Tabs, gutter, and highlight stay β€” they just read/write via API.

πŸ€– 2 — LLM proxy

One server endpoint that talks to the model, streams tokens, and enforces cost caps. Browser never holds the API key.

πŸ” 3 — Index + search

Parse every file for symbols, chunk it, embed it. That’s how @Deno / @file and “Chat with your codebase” actually work.

πŸ’¬ 4 — Chat + Composer

Conversations, proposed diffs, Accept/Reject. Composer applies a diff as one transaction, not one replace() at a time.

πŸ‘€ 5 — Auth + projects

Users, projects, API keys, usage limits. So your APP_H5 isn’t everyone’s APP_H5.

▢️ 6 — Run + preview

Sandboxed run for β–Ά Run and Go Live. No eval() on the client, no shell on the server without a sandbox.

What it’ll take, step by step

  • Step 1 β€” Server: Deno / Node server. Serves this page + /api/*. WebSocket for live edits + streaming chat.
  • Step 2 β€” Files: GET /api/files lists the tree, GET /api/file?path= reads, POST /api/file writes. Every write goes through git or a backup copy.
  • Step 3 β€” Index: On save, re-parse the file, update symbols + embeddings. GET /api/index/search?q= powers ⌘K + @ context.
  • Step 4 β€” Chat: POST /api/chat packs context (open tabs + @ + recent files) + prompt, streams back, saves the thread.
  • Step 5 β€” Composer: POST /api/composer/apply takes a diff, validates it, applies it, returns the new file. Reject just drops it.
  • Step 6 β€” Run: POST /api/run runs in a sandbox with timeout + no network unless you allow it, streams stdout back.

Effort β€” plausible, will fix later

PieceFilesPlausible effort
Server + file APIserver.ts, routes/files.ts~2–3 hrs
Index + embeddingsindex.ts, embed.ts~3–4 hrs
Chat + streamingroutes/chat.ts~2–3 hrs
Composer diffsroutes/composer.ts~2 hrs
Auth + projects + capsauth.ts, db/*~3 hrs
Run sandbox + previewroutes/run.ts~2–3 hrs
Total~12 files~2–3 weekends

Tables β€” proposed

CREATE TABLE users (id TEXT PRIMARY KEY, email TEXT, created_at DATETIME);
CREATE TABLE projects (id TEXT PRIMARY KEY, owner_id TEXT, name TEXT, path TEXT);
CREATE TABLE files (id INTEGER PRIMARY KEY, project_id TEXT, path TEXT, hash TEXT);
CREATE TABLE chats (id TEXT PRIMARY KEY, project_id TEXT, title TEXT, created_at DATETIME);
CREATE TABLE messages (id INTEGER PRIMARY KEY, chat_id TEXT, role TEXT, content TEXT, created_at DATETIME);
CREATE TABLE embeddings (file_id INTEGER, chunk TEXT, vec BLOB); -- or pgvector
CREATE TABLE runs (id TEXT PRIMARY KEY, project_id TEXT, cmd TEXT, status TEXT, log TEXT);

API β€” proposed

GET  /api/files?project=APP_H5       -> tree
GET  /api/file?path=src/filters/vfilters.js -> content
POST /api/file {path, content}        -> 200 {hash} | 409 CONFLICT
GET  /api/index/search?q=formatDate -> [{file, symbol, snippet}]
POST /api/chat {project, messages, context} -> stream (SSE)
POST /api/composer/apply {file, diff} -> 200 {newContent} | 422 BAD_DIFF
POST /api/run {project, cmd}         -> stream stdout, timeout 30s
πŸ› οΈ Fix later β€” open questions: Which LLM? Self-host vs hosted? Where do embeddings live (SQLite vs pgvector)? How do we sandbox β–Ά Run safely? What’s the per-user cost cap? None decided β€” modal is the placeholder until we pick.

Template only β€” editor + chat above are still local-only until this is wired.