You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'The primary tool for inserting content into documents. '+
148
+
'ALWAYS use action "insert" with type "markdown" to create headings, paragraphs, or any block content — this is faster and creates proper document structure in one call. Do NOT use superdoc_create for headings or paragraphs. '+
149
+
'The markdown parser creates headings from # markers (# = Heading1, ## = Heading2), bold from **text**, italic from *text*, and numbered/bullet lists. '+
150
+
'Position markdown inserts with "target" (a BlockNodeAddress like {kind:"block", nodeType, nodeId}) and "placement" (before, after, insideStart, insideEnd). Without a target, content appends at the end of the document. '+
151
+
'IMPORTANT: After a markdown insert, follow up with ONE superdoc_mutations call using format.apply steps to match the document style. '+
152
+
'Each format.apply step accepts "inline" (fontFamily, fontSize, bold, underline, color) AND "alignment" ("left","center","right","justify") in the same step — combine both in one step per block. '+
153
+
'Look at nearby headings and paragraphs in the get_content response and copy their exact formatting. Do NOT invent values — match what is already in the document. '+
154
+
'Also supports replace, delete, and undo/redo. For replace and delete, pass a "ref" from superdoc_search or superdoc_get_content blocks. '+
155
+
'A search ref covers only the matched substring; a block ref covers the entire block text, so use block refs when rewriting or shortening whole paragraphs. '+
147
156
'Refs expire after any mutation; always re-search before the next edit. '+
148
-
'Modify document text: insert new content, replace existing text, delete a range, or undo/redo. '+
149
-
'Use this for single text modifications. For 2+ edits that must succeed or fail atomically, use superdoc_mutations instead. '+
150
-
'For replace and delete, pass a "ref" from superdoc_search or superdoc_get_content blocks. A search ref covers only the matched substring; a block ref covers the entire block text, so use block refs when rewriting or shortening whole paragraphs. '+
151
-
'Insert supports plain text (default), markdown, or html via the "type" parameter. '+
152
-
'To create a document with multiple headings and paragraphs, use action "insert" with type "markdown" and placement "end". '+
153
-
'The markdown parser creates proper Heading styles from # markers (# = Heading1, ## = Heading2), bold from **text**, italic from *text*, and numbered/bullet lists. '+
154
-
'This is the most efficient way to build document structure: one call creates all sections. Follow up with superdoc_mutations format.apply steps to apply formatting (color, font, alignment) that markdown cannot express. '+
155
-
'Use "placement" (before, after, insideStart, insideEnd) to control position relative to the target. '+
157
+
'For 2+ edits that must succeed or fail atomically, use superdoc_mutations instead. '+
156
158
'Supports "dryRun" to preview changes and "changeMode: tracked" to record edits as tracked changes (not supported for markdown/html inserts). '+
157
159
'Do NOT build "target" objects manually when a ref is available; prefer "ref" for simpler, more reliable targeting.',
158
160
inputExamples: [
159
-
{action: 'replace',ref: '<handle.ref>',text: 'new text here'},
value: '# Executive Summary\n\nThis agreement sets forth the principal terms...',
167
+
},
168
+
{
169
+
action: 'insert',
170
+
type: 'markdown',
166
171
value:
167
172
'# Section Title\n\nParagraph content here.\n\n# Another Section\n\nMore content with **bold** and *italic*.',
168
173
},
174
+
{action: 'replace',ref: '<handle.ref>',text: 'new text here'},
169
175
{action: 'delete',ref: '<handle.ref>'},
170
176
{action: 'undo'},
171
177
],
172
178
},
173
179
create: {
174
180
toolName: 'superdoc_create',
175
181
description:
176
-
'Create a single paragraph, heading, or table. Returns nodeId and ref for the created block. '+
177
-
'For creating multiple headings and paragraphs at once, prefer superdoc_edit with type "markdown" (one call for all structure) instead of calling superdoc_create repeatedly. '+
178
-
'Use superdoc_create when you need to add one block at a specific position relative to another block. '+
182
+
'IMPORTANT: For headings and paragraphs, use superdoc_edit with type "markdown" instead — it is faster, creates proper styles, and handles positioning via target + placement. '+
183
+
'Only use superdoc_create for tables or when markdown cannot express the content. '+
184
+
'Creates a single paragraph, heading, or table. Returns nodeId and ref for the created block. '+
179
185
'After creating, the returned ref is valid for ONE immediate superdoc_format call. For subsequent operations, re-fetch blocks with superdoc_get_content to get fresh refs (refs expire after any mutation). '+
180
186
'When the user asks for a "heading", use action "heading" with a level (default 1). Use action "paragraph" for regular body text. '+
181
187
'Position with "at": {kind:"documentEnd"} (default), {kind:"documentStart"}, or {kind:"after"/"before", target:{kind:"block", nodeType, nodeId}} for relative placement. '+
Copy file name to clipboardExpand all lines: packages/sdk/tools/prompt-templates/system-prompt-core.md
+20-12Lines changed: 20 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,29 +128,37 @@ Use preset "disc" for bullets, "decimal" for numbered. WARNING: the range conver
128
128
129
129
3. To change a bullet list to numbered: `superdoc_list({action: "set_type", target: {kind: "block", nodeType: "listItem", nodeId: "<anyItemId>"}, kind: "ordered"})`
130
130
131
-
### Create a multi-section document efficiently
131
+
### Insert content into a document (new or existing)
132
132
133
-
**Step 1: Create all structure in one call using markdown insert:**
133
+
Markdown insert creates block structure but uses default formatting. You MUST follow up with formatting to match the document's existing style.
134
+
135
+
**Step 1: Read existing formatting** from the initial get_content blocks response. Pay special attention to:
136
+
-**Nearby headings/titles**: look at their fontFamily, fontSize, bold, underline, alignment (especially center vs justify vs left). Your new headings must match these exactly.
137
+
-**Body paragraphs**: note fontFamily, fontSize, color, alignment. Your new paragraphs must match.
138
+
- Match the style of the nearest similar element, not arbitrary values.
value: "# Definitions\n\n\"Confidential Information\" means any non-public information...\n\n# Obligations\n\nThe Receiving Party agrees to maintain confidentiality...\n\n# Governing Law\n\nThis Agreement shall be governed by the laws of..."})
value: "# Executive Summary\n\nThis agreement sets forth the principal terms..."})
138
147
```
139
148
140
-
This creates headings with proper Heading1 style, paragraphs, bold (**text**), italic (*text*), lists, and tables in one call. Markdown cannot express color, font-size, or alignment — those require step 2.
141
-
142
-
**Step 2: Apply formatting in one batch:**
149
+
**Step 3: Apply ALL formatting in a SINGLE superdoc_mutations call.** Each format.apply step accepts both `inline` (text styles) AND `alignment` (paragraph alignment) — one step per block.
143
150
151
+
Example: if the document has centered, underlined, 12pt headings and justified 12pt body text:
Use `require: "all"` with a node selector to format every heading at once instead of formatting one at a time.
159
+
CRITICAL: Do NOT guess formatting values. Copy them from the existing document blocks you read in step 1. Use ONE format.apply step per block with both `inline` and `alignment` combined.
152
160
153
-
Total: 4 calls (open, insert, format batch, save) instead of 40+.
161
+
Total: 3 calls (read + insert + format-all-in-one-batch). Never more.
Use require "all" to format every match at once. Selectors resolve before execution, so format targets must exist in the document before the batch runs.
40
+
One format.apply step per block. Combine `inline` (text styles) and `alignment` (paragraph alignment) in the same step. Do NOT use separate superdoc_format calls.
32
41
33
42
**When to use which tool:**
34
-
- Creating multiple blocks → `superdoc_edit` with type "markdown"
35
-
- Creating one block at a specific position → `superdoc_create`
36
-
-Formatting multiple items → `superdoc_mutations` with format.apply steps
37
-
-Formatting one item → `superdoc_format`
43
+
- Creating headings, paragraphs, or any block content → `superdoc_edit` with type "markdown" (preferred, even for a single heading + paragraph)
44
+
- Creating one block only when markdown is insufficient → `superdoc_create`
45
+
-ALL formatting after insert → `superdoc_mutations` with format.apply (inline + alignment in one step per block)
46
+
-Single quick format (no insert before it) → `superdoc_format`
0 commit comments