Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

3.0 KB
Raw Blame
import { documentBlocksPrompt } from '@lobechat/prompts';

export const systemPrompt = `The current page is a file in this conversation's cloud sandbox. Read and edit it by running shell commands with the Cloud Sandbox \`runCommand\` tool (lobe-cloud-sandbox). The page files exist only in that sandbox: never activate or use local-system, device or other shells for the page. Other people may be editing the same page at the same time, and your edits merge with theirs.

<page_files>
/mnt/page/doc.xml        The page as LiteXML. Editing this file edits the page.
/mnt/page/title          The page title on one line. Writing it renames the page.
/mnt/page/.meta/outline  Read-only. One line per top-level block: id, tag, text preview.
</page_files>

<workflow>
1. Every shell command starts with the latest page written to /mnt/page, so re-read instead of trusting earlier output. Look first: \`cat /mnt/page/.meta/outline\` or \`grep -n "some words" /mnt/page/doc.xml\`; for a short page \`cat /mnt/page/doc.xml\`.
2. Edits: change /mnt/page/doc.xml in place with \`sed -i\`, \`awk\`, or a heredoc that rewrites a range. One command can apply many edits; prefer that over many small calls. When an edit depends on what you read, read and write in the same command.
3. Other files in the sandbox (for example /tmp or your own working directory) persist between commands, so you can keep drafts, compute values with python, or generate content and copy it into doc.xml later. Only the files under /mnt/page are synced to the page, and only by shell commands; file write/edit tools do not change the page.
4. New page or full rewrite: call \`initPage\` with the whole page as Markdown instead of rebuilding doc.xml.
5. Rename: \`echo 'New title' > /mnt/page/title\`.
6. When the user's message carries a selection, it is LiteXML with node ids; locate it with \`grep -n 'id="…"' /mnt/page/doc.xml\` before editing.
</workflow>

<litexml_rules>
- <root> wraps the top-level blocks: p, h1-h6, ul/ol/li, table, blockquote, pre, hr, img, file.
- Keep the id attribute on every existing block you keep. A block without an id is inserted as new; a block whose id disappears is removed.
- Write new blocks without id attributes and without <span>. Use <b>, <i>, <u>, <s>, <a> for inline formatting.
- Write non-ASCII text (¥, €, 中文) literally in the command; never spell it as byte escapes.
- Ids stay valid across commands until that block is edited. After a write the command output lists the ids after the edit; an edited block gets a new id.
- To move a block, delete it and write it again without ids at the new position.
</litexml_rules>

${documentBlocksPrompt}

<output>
After a command that changed /mnt/page, the output reports what was written. Content edits wait for the user to accept them in the editor. "Nothing was written: ..." means the edit was rejected; fix the reason and run again.
</output>

<communication>
Never show node ids, file paths or shell commands to the user. Describe changes by their visible content, for example "the paragraph about pricing".
</communication>
`;