Skip to content

Commit ea8e8f3

Browse files
authored
Move creator prompt to server (#38)
* Removed prompts * Added creator prompt * Creator Mode working * Correct url
1 parent 834488f commit ea8e8f3

File tree

6 files changed

+45
-62
lines changed

6 files changed

+45
-62
lines changed

src/api/providers/anthropic.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,31 @@ export class AnthropicHandler implements ApiHandler, SingleCompletionHandler {
105105
// prompt caching: https://x.com/alexalbert__/status/1823751995901272068
106106
// https://github.com/anthropics/anthropic-sdk-typescript?tab=readme-ov-file#default-headers
107107
// https://github.com/anthropics/anthropic-sdk-typescript/commit/c920b77fc67bd839bfeb6716ceab9d7c9bbe7393
108-
return {
109-
headers: {
110-
"anthropic-beta": "prompt-caching-2024-07-31",
111-
authorization: `Bearer ${this.options.apiKey}`,
112-
},
108+
109+
const betas = []
110+
111+
// Check for the thinking-128k variant first
112+
// if (virtualId === "claude-3-7-sonnet-20250219:thinking") {
113+
// betas.push("output-128k-2025-02-19")
114+
// }
115+
116+
// Then check for models that support prompt caching
117+
switch (modelId) {
118+
case "claude-3-7-sonnet-20250219":
119+
case "claude-3-5-sonnet-20241022":
120+
case "claude-3-5-haiku-20241022":
121+
case "claude-3-opus-20240229":
122+
case "claude-3-haiku-20240307":
123+
betas.push("prompt-caching-2024-07-31")
124+
return {
125+
headers: {
126+
"anthropic-beta": betas.join(","),
127+
authorization: `Bearer ${this.options.apiKey}`,
128+
"creator-mode": String(this.options.creatorMode),
129+
},
130+
}
131+
default:
132+
return undefined
113133
}
114134
})(),
115135
)

src/api/providers/deepseek.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class DeepSeekHandler implements ApiHandler, SingleCompletionHandler {
4141
headers: {
4242
"Content-Type": "application/json",
4343
Authorization: `Bearer ${this.options.deepSeekApiKey}`,
44+
"creator-mode": String(this.options.creatorMode),
4445
},
4546
body: JSON.stringify({
4647
model: modelId,
@@ -139,6 +140,7 @@ export class DeepSeekHandler implements ApiHandler, SingleCompletionHandler {
139140
headers: {
140141
"Content-Type": "application/json",
141142
Authorization: `Bearer ${this.options.deepSeekApiKey}`,
143+
"creator-mode": String(this.options.creatorMode),
142144
},
143145
body: JSON.stringify({
144146
model: this.getModel().id,

src/api/providers/pearai.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class PearAiHandler {
3838
apiKey: options.pearaiApiKey,
3939
anthropicBaseUrl: PEARAI_URL,
4040
apiModelId: "claude-3-5-sonnet-20241022",
41+
creatorMode: options.creatorMode,
4142
})
4243

4344
// Then try to initialize the correct handler asynchronously
@@ -64,6 +65,7 @@ export class PearAiHandler {
6465
deepSeekApiKey: options.pearaiApiKey,
6566
deepSeekBaseUrl: PEARAI_URL,
6667
apiModelId: underlyingModel,
68+
creatorMode: options.creatorMode,
6769
})
6870
} else {
6971
// Default to Claude
@@ -72,6 +74,7 @@ export class PearAiHandler {
7274
apiKey: options.pearaiApiKey,
7375
anthropicBaseUrl: PEARAI_URL,
7476
apiModelId: underlyingModel,
77+
creatorMode: options.creatorMode,
7578
})
7679
}
7780
} catch (error) {
@@ -82,6 +85,7 @@ export class PearAiHandler {
8285
apiKey: options.pearaiApiKey,
8386
anthropicBaseUrl: PEARAI_URL,
8487
apiModelId: "claude-3-5-sonnet-20241022",
88+
creatorMode: options.creatorMode,
8589
})
8690
}
8791
} else if (modelId.startsWith("claude")) {

src/core/webview/ClineProvider.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,12 @@ export class ClineProvider implements vscode.WebviewViewProvider {
349349

350350
const modePrompt = customModePrompts?.[mode] as PromptComponent
351351
const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n")
352-
353352
this.cline = new Cline({
354353
provider: this,
355-
apiConfiguration,
354+
apiConfiguration: {
355+
...apiConfiguration,
356+
creatorMode: mode === "creator",
357+
},
356358
customInstructions: effectiveInstructions,
357359
enableDiff: diffEnabled,
358360
enableCheckpoints: checkpointsEnabled,
@@ -382,7 +384,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
382384

383385
this.cline = new Cline({
384386
provider: this,
385-
apiConfiguration,
387+
apiConfiguration: {
388+
...apiConfiguration,
389+
creatorMode: mode === "creator",
390+
},
386391
customInstructions: effectiveInstructions,
387392
enableDiff: diffEnabled,
388393
enableCheckpoints: checkpointsEnabled,
@@ -1809,7 +1814,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
18091814
await this.updateGlobalState("pearaiModelInfo", pearaiModelInfo),
18101815
])
18111816
if (this.cline) {
1812-
this.cline.api = buildApiHandler(apiConfiguration)
1817+
this.cline.api = buildApiHandler({
1818+
...apiConfiguration,
1819+
creatorMode: mode === "creator",
1820+
})
18131821
}
18141822
}
18151823

src/shared/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type ApiProvider =
2020

2121
export interface ApiHandlerOptions {
2222
apiModelId?: string
23+
creatorMode?: boolean
2324
apiKey?: string // anthropic
2425
anthropicBaseUrl?: string
2526
anthropicThinking?: number

src/shared/modes.ts

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -72,57 +72,6 @@ export function getToolsForMode(groups: readonly GroupEntry[]): string[] {
7272
return Array.from(tools)
7373
}
7474

75-
76-
const CreatorModePrompt = `
77-
Depending on the user's request, you may need to do some information gathering (for example using read_file or search_files) to get more context about the task. You may also ask the user clarifying questions to get a better understanding of the task. Once you've gained more context about the user's request, you should create a detailed plan for how to accomplish the task. Focus on breaking down complex tasks into manageable steps, considering technical requirements, potential challenges, and best practices. The plan should be clear enough that it can be directly implemented by switching to Code mode afterward. (Directly write the plan to a markdown file instead of showing it as normal response.)\n\nOnce you create and write the plan, you mark the task as completed. You only make plans and you should not ask or switch to any other mode.
78-
79-
Best practices:
80-
For any webapp project, ALWAYS adhere to these rules, unless otherwise specified:
81-
82-
React with TypeScript for the frontend
83-
Tailwind CSS for styling
84-
Shadcn/UI components (via Radix UI)
85-
Supabase for backend/database
86-
React Query for data management
87-
React Router for navigation
88-
Recharts for data visualization
89-
React Hook Form for form handling
90-
91-
For any other projects always use modern best practices, frameworks, and technologies for the project.
92-
93-
Always use supabase for database or authentication management, unless otherwise specified.
94-
95-
TOOL USE RULES:
96-
97-
Templating:
98-
Whenever the user requests a new project, follow these steps:
99-
1. Call the 'list_templates' tool to see available templates.
100-
2. Match the user request to the closest template.
101-
3. If a relevant template is found, use the 'create_new_project' tool to create the new project locally
102-
4. Navigate into the new project directory.
103-
5. Make all necessary changes to the project files. In this stage, do not implement any database or API integrations, and just focus on the UI. Let the user know about this, and that they can ask to implement these later.
104-
6. If it is a webapp, use the 'deploy_webapp_from_path' tool to deploy the webapp to the server.
105-
7. Ask the user to visit the webapp and ask for any feedback.
106-
8. Confirm success, do not use any computer or browser features to confirm success.
107-
If no template is relevant, try to fetch a generic template based on the use case. If there are no templates available, do not fetch a template.
108-
9. Tell the user this is just the first iteration, and they can use PearAI to add any functionality or features to it.
109-
`
110-
111-
const PearAICodeModePrompt = `
112-
Deployment:
113-
If the user is making a webapp and the webapp is completed for review, use the 'deploy_webapp_from_path' tool to deploy the webapp to the server. You will need to upload a zip of the distribution folder, so create one. W
114-
115-
Whenever the user requests a tool, follow these steps:
116-
1. Call the 'list_tools' tool to see available tools.
117-
2. Match the user request to the closest tool.
118-
3. If a relevant tool is found, use the tool to perform the task.
119-
4. Confirm success.
120-
121-
If no tool is relevant or the user wants a custom approach, do not fetch a tool.
122-
123-
Only proceed if you are over 90 percent confident that you understand what the user wants. If not, ask for clarification.
124-
`
125-
12675
// Main modes configuration as an ordered array
12776
export const modes: readonly ModeConfig[] = [
12877
{
@@ -131,13 +80,12 @@ export const modes: readonly ModeConfig[] = [
13180
roleDefinition:
13281
"You are PearAI Agent (Powered by Roo Code / Cline), a creative and systematic software architect focused on turning high-level ideas into actionable plans. Your primary goal is to help users transform their ideas into structured action plans.",
13382
groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"],
134-
customInstructions: CreatorModePrompt
13583
},
13684
{
13785
slug: "code",
13886
name: "Code",
13987
roleDefinition:
140-
"You are PearAI Agent (Powered by Roo Code / Cline), a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices." + PearAICodeModePrompt,
88+
"You are PearAI Agent (Powered by Roo Code / Cline), a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.",
14189
groups: ["read", "edit", "browser", "command", "mcp"],
14290
},
14391
{

0 commit comments

Comments
 (0)