Add "Edit with Shakespeare" info to system prompt

This commit is contained in:
Alex Gleason committed 2025-11-13 15:39:18 -06:00
1 parent 72439d4ec9
commit 866155d907
4 files changed
+64 -4

No files matched your search

+36 -1
View File
@@ -17,10 +17,11 @@ export interface MakeSystemPromptOpts {
user?: NUser;
metadata?: NostrMetadata;
corsProxy?: string;
repositoryUrl?: string;
}
export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise<string> {
const { name, profession, tools, mode, fs, cwd, pluginsPath, user, metadata, corsProxy } = opts;
const { name, profession, tools, mode, fs, cwd, pluginsPath, user, metadata, corsProxy, repositoryUrl } = opts;
let system = mode === "init"
? `You are ${name}, an expert ${profession}. The files in the current directory are a template. Your goal is to transform this template into a working project according to the user's request.`
@@ -62,6 +63,7 @@ You are operating within **Shakespeare**, an AI-powered Nostr website builder th
- **Current Date**: ${currentDate}
- **Current Page**: ${location.href}
- **Current Working Directory**: ${cwd}
- **Repository URL**: ${repositoryUrl}
## What Shakespeare Is
@@ -224,6 +226,39 @@ If you encounter CORS (Cross-Origin Resource Sharing) errors when fetching exter
Replace \`{href}\`, \`{hostname}\`, or other URL components in the template as needed.`;
}
// Add Edit with Shakespeare section
system += `
## Edit with Shakespeare
The "Edit with Shakespeare" button is a way that people can start editing any Shakespeare-compatible site with a single click. It can be added anywhere markdown or HTML is supported, including in READMEs, or within an app itself.`;
if (repositoryUrl) {
const badgeUrl = new URL('/badge.svg', location.origin);
const editUrl = new URL('/clone', location.origin);
editUrl.searchParams.set('url', repositoryUrl);
system += `
This project has a repository URL configured, so you can create an "Edit with Shakespeare" button using the following code snippets:
**Markdown:**
\`\`\`markdown
[![Edit with Shakespeare](${badgeUrl})](${editUrl})
\`\`\`
**HTML/JSX/TSX:**
\`\`\`jsx
<a href="${editUrl}" target="_blank">
<img src="${badgeUrl}" alt="Edit with Shakespeare" />
</a>
\`\`\``;
} else {
system += `
**Important**: This project does not currently have a repository URL configured. If the user asks about adding an "Edit with Shakespeare" button, inform them that they must first initialize a public Git repository from their Shakespeare project. Once a repository URL is available, an "Edit with Shakespeare" button can be created.`;
}
// Add README.md if it exists
try {
const readmePath = join(cwd, "README.md");