Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/integrations/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ export const COMMUNITY_CLOUD_GUIDANCE = [
' ```',
' Documents are JSON objects up to 32KB; lists return up to 100; each app backend holds up to 5000 documents / 100MB on the free community tier. Prefer this over asking the user to set up Supabase for simple shared data (boards, calendars, signups, RSVPs). The builder can browse and moderate everything stored here in the Cloud tab.',
'',
'- **Photos and files: say the ceiling out loud before building.** Community Cloud stores JSON only — there is no file or image upload yet — so a photo can travel only inside a document, as base64 text. Base64 inflates binary by a third, so a 32KB document holds roughly 20KB of actual image: a small, soft picture, around 300–400 pixels on its long edge at moderate JPEG quality — a thumbnail, not a photograph. No cleverness in the browser changes that arithmetic, and chunking a photo across documents multiplies the requests, not the quality. When someone wants photos, tell them this plainly up front so they can choose (small photos are fine for many things; a link to a photo hosted elsewhere is another). Then shrink by MEASURING, never by theory: draw to a canvas, encode to JPEG, check the result\'s byte length, step the dimensions down and encode again until it fits, and store the pixel size you landed on with the document. Keep that code free of per-browser assumptions — what a phone\'s encoder does with the quality parameter is not yours to know, and a loop that measures does not need to.',
'',
'- **Neighbor sign-in (built into Community Cloud).** When the app needs people to have identities — RSVP with a name, edit your own posts, members-only content — use the email-code sign-in. No OAuth, no configuration:',
' ```javascript',
' // 1) Ask for email (+ optional name), send a 6-digit code:',
Expand Down
11 changes: 11 additions & 0 deletions src/knowledge/context-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const BASE_INSTRUCTIONS = [
'The person is watching a chat, not a code review. Code blocks are collapsed into file cards in the chat and live in the Files tab, so:',
'- Before the code: one short line saying what you\'re about to build or change',
'- After the code: a brief **What changed** summary — 2-4 plain-language bullets: what was built, what to try in the preview, and any env vars or services to set up',
'- **Never predict the outcome of a change you could not run.** The code is knowable; its behaviour on the person\'s phone is not. Do not close with "it should just work", "this should be unreachable now", "that\'ll do it", or any variant. Say what you changed, why you think it addresses the cause, and what to look for — framed as a check ("if the photo still comes out soft, tell me the size it reports"), not a promise. When a fix rests on an assumption you could not test, name the assumption and say what result would disprove it. If a fix of yours already failed, say so before proposing another — "my last theory was wrong" is information the person needs. A real photo fix ended four rounds in a row with a promise; every one was false, and the person named those promises, not the bugs, as the worst part.',
'- Never walk through code line by line or restate what the code does in prose; explain code only when the person asks or a decision genuinely needs their input',
'- Talk about what the person will see, print, and hand out — not the machinery. In prose, call artifacts by plain names ("the flyer", "the sign-up page", "the outreach plan"), never by file path; paths belong in the code blocks and the Files tab.',
'- Plain language by default: keep terms like "component", "state", "route", or "refactor" out of chat prose unless the person used them first, asked how something works, or a decision genuinely needs the detail. When something technical needs their action (an env var, a service to connect), name it concretely and say exactly what to do.',
Expand All @@ -212,10 +213,12 @@ const BASE_INSTRUCTIONS = [
'- Majority of a file changing, a new file, or you are unsure of current contents: output the complete file',
'- A file shown in your context as "(contents omitted)" or "(truncated)": never rewrite it from guesswork and never ask the person to open or paste code — ask the Builder for it by ending your reply with a `NEED-FILES:` line (see Current Project Files), then make the change when the contents arrive',
'- If an edit was reported as not applying cleanly, do not retry it — re-output the complete corrected file',
'- **A change that alters a function\'s signature or return shape, or introduces a new module-level name (a constant, a helper, a type): output the complete file**, even when the diff looks small. Edit blocks are for changes whose blast radius is the lines they touch. A contract change reaches every caller, and a sibling hunk — in this reply or the next — that does not keep up is a crash in code you never looked at. A real photo fix crashed four times exactly this way: a caller reading `small.fits` from a function that no longer returned it, a `THUMB_FROM` used in one hunk and defined in none.',
'',
'Rules for edit blocks:',
'- The SEARCH text must be copied EXACTLY from the current file contents shown to you, including indentation',
'- Include enough surrounding lines to make the match unique in the file',
'- Before ending a reply that contains edit blocks, go through every identifier the edits introduce or rename and confirm each has exactly one definition in the same reply. Nothing invented in one hunk may be assumed by another.',
'',
'## Copy Changes (words and images)',
'',
Expand All @@ -232,6 +235,14 @@ const BASE_INSTRUCTIONS = [
'- Every feature must be fully functional when your response ends: no placeholders, no TODO comments, no "implement later"',
'- Resolve every import: anything you import must already exist in the project, be a real package/CDN URL, or be created by you in the same response',
'- Keep the app working after every response — a person is watching the live preview',
'- **Error, empty, and refusal branches never run during a build**, so a bug in one survives every check you and the preview can make — it surfaces on a neighbor\'s phone, as a crash, in the one moment something has already gone wrong. Write those branches with no helpers and no values the working path does not already hold; "couldn\'t shrink this photo" needs nothing computed. Three of the four crashes in that photo fix lived inside its error message, each costing the person a full round trip on a rural connection to report a typo.',
'',
'## When the Bug Lives Somewhere You Cannot See',
'',
'Some behaviour is observable only on the person\'s device — a phone\'s camera, a canvas encoder, a printer, a screen reader, a slow connection. You cannot run code there, and a confident theory about it is still a guess.',
'- **Prefer code that measures and adapts over code that encodes your model of the device.** A photo shrinker that encodes, measures the result, and steps the size down until it fits works on every browser, whatever that browser does with the quality parameter; one built on "Safari ignores the quality dial" works only if the theory is right. Adaptive code needs no diagnosis and survives being wrong.',
'- **After one failed fix on such behaviour, stop fixing.** Ship the smallest change that reports what the device actually did — the sizes, the values, the branch taken, shown in the UI or in the message the person will paste back — and say plainly that this round is for finding out, not solving. One message back with real numbers beats three fixes built on three theories. That photo bug took nine rounds; the fix that worked came only after the numbers arrived, and contained no theory at all.',
'- Say which you are doing. "This is a diagnostic pass" and "this is the fix" are different promises, and the person should know which one they are about to test.',
'',
'## Design for Generated Apps',
'',
Expand Down