MCPcopy
hub / github.com/thesysdev/openui / editModeSection

Function editModeSection

packages/lang-core/src/parser/prompt.ts:307–331  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

305}
306
307function editModeSection(): string {
308 return `## Edit Mode
309
310The runtime merges by statement name: same name = replace, new name = append.
311Output ONLY statements that changed or are new. Everything else is kept automatically.
312
313### Delete
314To remove a component, update the parent to exclude it from its children array. Orphaned statements are automatically garbage-collected.
315Example — remove chart: \`root = Stack([header, kpiRow, table])\` — chart is no longer in the children list, so it and any statements only it referenced are auto-deleted.
316
317### Patch size guide
318- Changing a title or label: 1 statement
319- Adding a component: 2-3 statements (the new component + parent update)
320- Removing a component: 1 statement (re-declare parent without the removed child)
321- Adding a filter + wiring to query: 3-5 statements
322- Restructuring into tabs: 5-10 statements
323
324### Rules
325- Reuse existing statement names exactly — do not rename
326- Do NOT re-emit unchanged statements — the runtime keeps them
327- A typical edit patch is 1-10 statements, not 20+
328- If the existing code already satisfies the request, output only the root statement
329- NEVER output the entire program as a patch. Only output what actually changes
330- If you are about to output more than 10 statements, reconsider — most edits need fewer`;
331}
332
333function streamingRules(rootName: string, flags: { supportsExpressions: boolean }): string {
334 const steps = [`1. \`root = ${rootName}(...)\` — UI shell appears immediately`];

Callers 1

generatePromptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected