Kakashiix26 commited on
Commit
7bf27de
Β·
verified Β·
1 Parent(s): 366ff47

freeze styles + scoped oncall prompt

Browse files
agent/__pycache__/premium_scaffold.cpython-314.pyc CHANGED
Binary files a/agent/__pycache__/premium_scaffold.cpython-314.pyc and b/agent/__pycache__/premium_scaffold.cpython-314.pyc differ
 
agent/__pycache__/prompts.cpython-314.pyc CHANGED
Binary files a/agent/__pycache__/prompts.cpython-314.pyc and b/agent/__pycache__/prompts.cpython-314.pyc differ
 
agent/premium_scaffold.py CHANGED
@@ -1477,14 +1477,16 @@ def preserve_premium_scaffold(original: dict, updated: dict) -> dict:
1477
  """Make an LLM refine/repair safe for a premium app.
1478
 
1479
  Layer the LLM's changes over the ORIGINAL files (so nothing the LLM silently
1480
- dropped is lost), then re-overlay the FROZEN import-critical kit (/ui/*,
1481
- /lib/*) from the baked scaffold LAST so the barrel + primitives can never be
1482
- clobbered, and guarantee the required deps so the kit always resolves. The
1483
- refinable surface (styles, App, views, mock data) stays whatever the LLM
1484
- produced, so refines still take effect.
 
 
1485
  """
1486
  merged = {**original, **updated}
1487
  for path, code in PREMIUM_SCAFFOLD_FILES.items():
1488
- if path.startswith(_FROZEN_PREFIXES):
1489
  merged[path] = code
1490
  return ensure_premium_deps(merged)
 
1477
  """Make an LLM refine/repair safe for a premium app.
1478
 
1479
  Layer the LLM's changes over the ORIGINAL files (so nothing the LLM silently
1480
+ dropped is lost), then re-overlay the FROZEN kit β€” the import-critical /ui/* +
1481
+ /lib/* AND the baked /styles.css (which holds ALL the kit's component styling:
1482
+ app-shell layout, sidebar, cards, tables, badges…). A refine that rewrites
1483
+ /styles.css almost always drops most of it β†’ the whole app loses its styling
1484
+ (the "add dark mode broke the CSS" bug). Freezing it guarantees the app can
1485
+ never lose its look. Refinable surface: /App.js, /views/*, /data/mock.js β€” and
1486
+ a NEW /overrides.css for any custom styling (App.js imports it after styles.css).
1487
  """
1488
  merged = {**original, **updated}
1489
  for path, code in PREMIUM_SCAFFOLD_FILES.items():
1490
+ if path.startswith(_FROZEN_PREFIXES) or path == "/styles.css":
1491
  merged[path] = code
1492
  return ensure_premium_deps(merged)
agent/prompts.py CHANGED
@@ -437,7 +437,7 @@ Use EXACTLY the delimiter format above for each file. No other text outside the
437
 
438
 
439
  def oncall_prompt(files: dict[str, str], error: str) -> str:
440
- """Build the OnCallAgent single-call prompt.
441
 
442
  ponytail: delegates to vibe_prompt so file-embedding + format rules are DRY.
443
  The instruction is an error-fix directive that asks for root-cause analysis.
@@ -450,6 +450,50 @@ def oncall_prompt(files: dict[str, str], error: str) -> str:
450
  return vibe_prompt(files, instruction)
451
 
452
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  def uxmaster_prompt(files: dict[str, str], instruction: str, image_provided: bool = True) -> str:
454
  """Build the single-call UX MASTER prompt.
455
 
@@ -603,8 +647,14 @@ RULES:
603
  actually appends to the relevant data/state on submit with a success useToast() toast).
604
  - Compose the frozen primitives (Modal, Button, Badge, DataTable, etc.) from "../ui"/"./ui"; NEVER
605
  redefine them. Colors from CSS tokens var(--...), never raw hex.
606
- - Emit ONLY the files you CHANGE or CREATE. Do NOT re-emit unchanged files, and NEVER emit any /ui/*
607
- or /lib/* file (frozen). Keep imports/refs coherent with the files you don't emit.
 
 
 
 
 
 
608
  - Every emitted file must be complete and valid.
609
 
610
  Output EXACTLY this format β€” one REPLY block, then ONLY the changed/new files. No prose, no fences:
 
437
 
438
 
439
  def oncall_prompt(files: dict[str, str], error: str) -> str:
440
+ """Build the OnCallAgent single-call prompt (STANDARD apps).
441
 
442
  ponytail: delegates to vibe_prompt so file-embedding + format rules are DRY.
443
  The instruction is an error-fix directive that asks for root-cause analysis.
 
450
  return vibe_prompt(files, instruction)
451
 
452
 
453
+ def oncall_prompt_scoped(relevant_files: dict[str, str], error: str) -> str:
454
+ """SURGICAL OnCall prompt for a PREMIUM app.
455
+
456
+ A premium app is ~22 files on a FROZEN kit; regenerating the whole thing for one
457
+ error breaks unrelated code (why "removing one comma β†’ OnCall breaks something
458
+ else + touches package.json"). Here we send ONLY the file(s) implicated by the
459
+ error + the primitive cheatsheet, and demand the SMALLEST possible fix, emitting
460
+ ONLY the changed file(s).
461
+ """
462
+ files_text = "\n".join(
463
+ f"=== FILE: {path} ===\n{content}" for path, content in relevant_files.items()
464
+ )
465
+ file_list = ", ".join(relevant_files.keys())
466
+ return f"""You are ON-CALL, an SRE fixing a RUNTIME/COMPILE ERROR in a PREMIUM React dashboard
467
+ running in Sandpack. The app is built on a FROZEN pre-built primitive kit imported from
468
+ "../ui" / "./ui" β€” those primitives + /lib/* + /styles.css + /package.json are IMMUTABLE and
469
+ NOT shown; do NOT touch or emit them.
470
+
471
+ THE ERROR:
472
+ {error}
473
+
474
+ The primitive kit's API (for reference β€” compose, never redefine):
475
+ {premium_primitives_cheatsheet()}
476
+
477
+ The file(s) implicated by the error (fix within these):
478
+ {files_text}
479
+
480
+ RULES (surgical β€” this is a REPAIR, not a rewrite):
481
+ - Diagnose the ROOT CAUSE of the error, then make the SMALLEST possible change that fixes it
482
+ (e.g. a missing comma/bracket/import, an undefined variable, a wrong prop). Preserve ALL other
483
+ behavior and code β€” do NOT refactor, restyle, rename, or "improve" anything unrelated.
484
+ - Do NOT touch /ui/*, /lib/*, /styles.css, or /package.json (frozen). Do NOT add/remove npm
485
+ dependencies. Compose the existing primitives; keep imports coherent with files NOT shown.
486
+ - Emit ONLY the file(s) you actually change. If the fix is one file, emit one file.
487
+ - Every emitted file must be complete and valid.
488
+
489
+ Output EXACTLY this format β€” the changed file(s) only, no REPLY block, no prose, no fences:
490
+
491
+ === FILE: /views/Whatever.js ===
492
+ (full corrected file body)
493
+
494
+ (Files you may fix: {file_list}. Emit ONLY the one(s) you changed.)"""
495
+
496
+
497
  def uxmaster_prompt(files: dict[str, str], instruction: str, image_provided: bool = True) -> str:
498
  """Build the single-call UX MASTER prompt.
499
 
 
647
  actually appends to the relevant data/state on submit with a success useToast() toast).
648
  - Compose the frozen primitives (Modal, Button, Badge, DataTable, etc.) from "../ui"/"./ui"; NEVER
649
  redefine them. Colors from CSS tokens var(--...), never raw hex.
650
+ - Make the SMALLEST change that fully delivers the instruction β€” do NOT refactor, rename, or rewrite
651
+ unrelated code. Preserve everything not directly part of the request.
652
+ - /ui/*, /lib/*, /styles.css and /package.json are FROZEN β€” NEVER emit them (a rewritten /styles.css
653
+ drops the kit's styling and breaks the whole app). For CUSTOM styling create/append a NEW
654
+ "/overrides.css" (a domain file) and add `import "./overrides.css";` to /App.js AFTER the existing
655
+ styles import β€” those rules layer on top without touching the baked kit.
656
+ - Emit ONLY the files you CHANGE or CREATE. Do NOT re-emit unchanged files. Keep imports/refs coherent
657
+ with the files you don't emit.
658
  - Every emitted file must be complete and valid.
659
 
660
  Output EXACTLY this format β€” one REPLY block, then ONLY the changed/new files. No prose, no fences: