Skip to content

creator 5 #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8ff6362
progress 1
Himanshu-Singh-Chauhan Mar 21, 2025
f188080
chat response showing
Himanshu-Singh-Chauhan Mar 21, 2025
7bd0c94
not working
Himanshu-Singh-Chauhan Mar 23, 2025
391b2d5
progress
Himanshu-Singh-Chauhan Mar 24, 2025
bd40af1
progress
Himanshu-Singh-Chauhan Mar 25, 2025
4e3787f
progress - nice
Himanshu-Singh-Chauhan Mar 25, 2025
48388f0
progress
Himanshu-Singh-Chauhan Mar 26, 2025
be78834
remove show task plan
Himanshu-Singh-Chauhan Mar 26, 2025
9e4d901
progress split view file not opening
Himanshu-Singh-Chauhan Mar 27, 2025
89e67db
progress promtps
Himanshu-Singh-Chauhan Mar 27, 2025
bc61003
editing plan works
Himanshu-Singh-Chauhan Mar 28, 2025
aecc9d1
empty file warning
Himanshu-Singh-Chauhan Mar 28, 2025
403d768
ui improves
Himanshu-Singh-Chauhan Mar 28, 2025
834488f
execute creator plan
Himanshu-Singh-Chauhan Mar 28, 2025
81bbe39
renames
Himanshu-Singh-Chauhan Mar 29, 2025
2393dd5
Nang creator (#41)
Himanshu-Singh-Chauhan Mar 29, 2025
83c223a
Added text changes
nang-dev Mar 29, 2025
a041e87
Progress
nang-dev Mar 29, 2025
45b2988
Progress, include planning phases checkbox logic is working
nang-dev Mar 29, 2025
5dab793
Progress, include planning phases checkbox logic is working and creat…
nang-dev Mar 29, 2025
e92e1d0
Progress, true on server
nang-dev Mar 29, 2025
9def681
Renamed isCreatorView
nang-dev Mar 29, 2025
656d12c
Renamed isCreatorView
nang-dev Mar 29, 2025
0617060
Progress
nang-dev Mar 29, 2025
68ad3b5
Progress
nang-dev Mar 29, 2025
ca25ed6
Progress
nang-dev Mar 29, 2025
81b99e9
Working
nang-dev Mar 29, 2025
a522ddb
Removed prints
nang-dev Mar 30, 2025
dcc73f6
Removed prints
nang-dev Mar 30, 2025
f2a7f60
Merge pull request #42 from trypear/creator-checkbox
nang-dev Mar 30, 2025
c9bd693
format planning prompt
Himanshu-Singh-Chauhan Mar 31, 2025
7f3e6e0
Merge branch 'creator-3'
Himanshu-Singh-Chauhan Apr 1, 2025
5bf118f
remove plan file
Himanshu-Singh-Chauhan Apr 1, 2025
7af573c
post merge fixes
Himanshu-Singh-Chauhan Apr 1, 2025
69e4250
add back react dev inspector
Himanshu-Singh-Chauhan Apr 1, 2025
7722264
Merge branch 'acorn/creator-5-test' into HEAD
Acorn221 Apr 1, 2025
60fbc88
Merge commit '7722264c695930076a5f73d2c6eec1b29e5c7c91' into acorn/cr…
Acorn221 Apr 1, 2025
464d688
Merge branch 'acorn/creator-5-test' into creator-5
Acorn221 Apr 2, 2025
e61c749
Plumbing fix
nang-dev Apr 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,843 changes: 1,622 additions & 221 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
"pretty-bytes": "^6.1.1",
"puppeteer-chromium-resolver": "^23.0.0",
"puppeteer-core": "^23.4.0",
"react-dev-inspector": "^2.0.1",
"react-tooltip": "^5.28.0",
"reconnecting-eventsource": "^1.6.4",
"say": "^0.16.0",
Expand Down
58 changes: 50 additions & 8 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,48 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
"roo-cline.registerHumanRelayCallback": registerHumanRelayCallback,
"roo-cline.unregisterHumanRelayCallback": unregisterHumanRelayCallback,
"roo-cline.handleHumanRelayResponse": handleHumanRelayResponse,
"roo-cline.createInAgent": async (args: any) => {
const sidebarProvider = ClineProvider.getSidebarInstance()
if (sidebarProvider) {
// Start a new chat in the sidebar
vscode.commands.executeCommand("pearai-roo-cline.SidebarProvider.focus")
await sidebarProvider.handleModeSwitch("code", args.creatorMode)
await sidebarProvider.postStateToWebview()
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })

await sidebarProvider.initClineWithTask(args.text, undefined, undefined, args.creatorMode)
}
},
"roo-cline.executeCreatorPlan": async (args: any) => {
const sidebarProvider = ClineProvider.getSidebarInstance()
if (sidebarProvider) {
// Start a new chat in the sidebar
vscode.commands.executeCommand("pearai-roo-cline.SidebarProvider.focus")
await sidebarProvider.handleModeSwitch("code")
await sidebarProvider.postStateToWebview()
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })

// Create the template message using the args
// Todo: add structure to it i.e. You should have these sections: Architecutre, Features, etc.
let executePlanTemplate = `This file contains detailed plan to my task. please read it and Execute the plan accordingly.
File: ${args.filePath || "No file specified"}`

if (args.code) {
executePlanTemplate += `Code: \`\`\`
${args.code}
\`\`\`
`
}

if (args.context) {
executePlanTemplate += `Additional context: ${args.context}`
}

args.text = executePlanTemplate

await sidebarProvider.initClineWithTask(args.text, undefined, undefined, true)
}
},
}
}

Expand All @@ -93,20 +135,20 @@ const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterComman
// deserialize cached webview, but since we use retainContextWhenHidden, we
// don't need to use that event).
// https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
const tabProvider = new ClineProvider(context, outputChannel, "editor")
const tabProvider = new ClineProvider(context, outputChannel, "editor", true)
const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0))

// Check if there are any visible text editors, otherwise open a new group
// to the right.
const hasVisibleEditors = vscode.window.visibleTextEditors.length > 0
// const hasVisibleEditors = vscode.window.visibleTextEditors.length > 0

if (!hasVisibleEditors) {
await vscode.commands.executeCommand("workbench.action.newGroupRight")
}
// if (!hasVisibleEditors) {
// await vscode.commands.executeCommand("workbench.action.newGroupRight")
// }

const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two
// const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two

const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Roo Code", targetCol, {
const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Roo Code", vscode.ViewColumn.One, {
enableScripts: true,
retainContextWhenHidden: true,
localResourceRoots: [context.extensionUri],
Expand All @@ -131,5 +173,5 @@ const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterComman

// Lock the editor group so clicking on files doesn't open them over the panel.
await delay(100)
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
// await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
}
5 changes: 4 additions & 1 deletion src/api/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
case "claude-3-haiku-20240307":
betas.push("prompt-caching-2024-07-31")
return {
headers: { "anthropic-beta": betas.join(",") },
headers: {
"anthropic-beta": betas.join(","),
"creator-mode": String(this.options.creatorMode),
},
authorization: `Bearer ${this.options.apiKey}`,
}
default:
Expand Down
4 changes: 4 additions & 0 deletions src/api/providers/pearai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
apiKey: options.pearaiApiKey,
anthropicBaseUrl: PEARAI_URL,
apiModelId: "claude-3-5-sonnet-20241022",
creatorMode: options.creatorMode,
})

// Then try to initialize the correct handler asynchronously
Expand All @@ -68,6 +69,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
deepSeekApiKey: options.pearaiApiKey,
deepSeekBaseUrl: PEARAI_URL,
apiModelId: underlyingModel,
creatorMode: options.creatorMode,
})
} else {
// Default to Claude
Expand All @@ -76,6 +78,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
apiKey: options.pearaiApiKey,
anthropicBaseUrl: PEARAI_URL,
apiModelId: underlyingModel,
creatorMode: options.creatorMode,
})
}
} catch (error) {
Expand All @@ -86,6 +89,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
apiKey: options.pearaiApiKey,
anthropicBaseUrl: PEARAI_URL,
apiModelId: "claude-3-5-sonnet-20241022",
creatorMode: options.creatorMode,
})
}
} else if (modelId.startsWith("claude")) {
Expand Down
3 changes: 2 additions & 1 deletion src/core/Cline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ export class Cline extends EventEmitter<ClineEvents> {
// (have to do this for partial and complete since sending content in thinking tags to markdown renderer will automatically be removed)
// Remove end substrings of <thinking or </thinking (below xml parsing is only for opening tags)
// (this is done with the xml parsing below now, but keeping here for reference)
// content = content.replace(/<\/?t(?:h(?:i(?:n(?:k(?:i(?:n(?:g)?)?)?$/, "")
// content = content.replace(/<\/?t(?:h(?:i(?:n(?:k(?:i(?:n(?:g)?)?)?)?$/, "")
// Remove all instances of <thinking> (with optional line break after) and </thinking> (with optional line break before)
// - Needs to be separate since we dont want to remove the line break before the first tag
// - Needs to happen before the xml parsing below
Expand Down Expand Up @@ -1390,6 +1390,7 @@ export class Cline extends EventEmitter<ClineEvents> {
return `[${block.name} in ${modeName} mode: '${message}']`
}
}
return `[${block.name}]`
}

if (this.didRejectTool) {
Expand Down
87 changes: 81 additions & 6 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ import { getUri } from "./getUri"
import { telemetryService } from "../../services/telemetry/TelemetryService"
import { TelemetrySetting } from "../../shared/TelemetrySetting"
import { getWorkspacePath } from "../../utils/path"
import { readWorkspaceFile, writeWorkspaceFile } from "../../integrations/misc/workspace-files"

/*
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts

https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
*/

/**
* https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
Expand All @@ -91,16 +98,21 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
private contextProxy: ContextProxy
configManager: ConfigManager
customModesManager: CustomModesManager
private isCreatorView: boolean = false
get cwd() {
return getWorkspacePath()
}
constructor(
readonly context: vscode.ExtensionContext,
private readonly outputChannel: vscode.OutputChannel,
private readonly renderContext: "sidebar" | "editor" = "sidebar",
isCreatorView: boolean = false,
) {
super()

this.outputChannel.appendLine(`creator = ${isCreatorView}`)
this.isCreatorView = isCreatorView
console.dir("CREATOR")
console.dir(this.isCreatorView)
this.outputChannel.appendLine("ClineProvider instantiated")
this.contextProxy = new ContextProxy(context)
ClineProvider.activeInstances.add(this)
Expand Down Expand Up @@ -236,6 +248,16 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
McpServerManager.unregisterProvider(this)
}

public static getSidebarInstance(): ClineProvider | undefined {
const sidebar = Array.from(this.activeInstances).find((instance) => !instance.isCreatorView)

if (!sidebar?.view?.visible) {
vscode.commands.executeCommand("pearai-roo-cline.SidebarProvider.focus")
}

return sidebar
}

public static getVisibleInstance(): ClineProvider | undefined {
return findLast(Array.from(this.activeInstances), (instance) => instance.view?.visible === true)
}
Expand Down Expand Up @@ -455,7 +477,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
// when initializing a new task, (not from history but from a tool command new_task) there is no need to remove the previouse task
// since the new task is a sub task of the previous one, and when it finishes it is removed from the stack and the caller is resumed
// in this way we can have a chain of tasks, each one being a sub task of the previous one until the main task is finished
public async initClineWithTask(task?: string, images?: string[], parentTask?: Cline) {
public async initClineWithTask(task?: string, images?: string[], parentTask?: Cline, creatorMode?: boolean) {
const {
apiConfiguration,
customModePrompts,
Expand All @@ -473,7 +495,10 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements

const cline = new Cline({
provider: this,
apiConfiguration,
apiConfiguration: {
...apiConfiguration,
creatorMode: creatorMode,
},
customInstructions: effectiveInstructions,
enableDiff,
enableCheckpoints,
Expand All @@ -494,7 +519,10 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
return cline
}

public async initClineWithHistoryItem(historyItem: HistoryItem & { rootTask?: Cline; parentTask?: Cline }) {
public async initClineWithHistoryItem(
historyItem: HistoryItem & { rootTask?: Cline; parentTask?: Cline },
creatorMode?: boolean,
) {
await this.removeClineFromStack()

const {
Expand Down Expand Up @@ -540,7 +568,10 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements

const cline = new Cline({
provider: this,
apiConfiguration,
apiConfiguration: {
...apiConfiguration,
creatorMode: creatorMode,
},
customInstructions: effectiveInstructions,
enableDiff,
...checkpoints,
Expand Down Expand Up @@ -603,6 +634,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
window.isCreator="${this.isCreatorView}";
</script>
`

Expand All @@ -615,6 +647,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
`connect-src https://* https://*.posthog.com ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort} http://localhost:8000 http://0.0.0.0:8000 https://stingray-app-gb2an.ondigitalocean.app`,
]

console.dir("CREATORRRRRR")
console.dir(this.isCreatorView)
return /*html*/ `
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -2033,6 +2067,47 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
),
)
break
case "readWorkspaceFile":
if (message.values?.relativePath) {
const result = await readWorkspaceFile(message.values.relativePath, {
create: message.values.create,
ensureDirectory: message.values.ensureDirectory,
content: message.values.content,
})
await this.postMessageToWebview(result)
}
break
case "writeWorkspaceFile":
if (message.values?.relativePath && message.values?.content !== undefined) {
const result = await writeWorkspaceFile(message.values.relativePath, {
create: message.values.create,
ensureDirectory: message.values.ensureDirectory,
content: message.values.content,
})
await this.postMessageToWebview(result)
}
break
case "invoke":
switch (message.invoke) {
case "sendMessage":
if (message.text) {
await this.getCurrentCline()?.ask("followup", message.text, false)
}
break
case "setChatBoxMessage":
if (message.text) {
await this.getCurrentCline()?.ask("followup", message.text, false)
}
break
case "executeCommand":
if (message.command) {
await vscode.commands.executeCommand(message.command, message.args)
}
break
default:
console.warn("Unknown invoke:", message.invoke)
}
break
}
},
null,
Expand Down Expand Up @@ -2096,7 +2171,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
* Handle switching to a new mode, including updating the associated API configuration
* @param newMode The mode to switch to
*/
public async handleModeSwitch(newMode: Mode) {
public async handleModeSwitch(newMode: Mode, creatorMode?: boolean) {
// Capture mode switch telemetry event
const currentTaskId = this.getCurrentCline()?.taskId
if (currentTaskId) {
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function activate(context: vscode.ExtensionContext) {
context.globalState.update("allowedCommands", defaultCommands)
}

const provider = new ClineProvider(context, outputChannel, "sidebar")
const provider = new ClineProvider(context, outputChannel, "sidebar", false)
telemetryService.setProvider(provider)

context.subscriptions.push(
Expand Down Expand Up @@ -177,7 +177,7 @@ export function activate(context: vscode.ExtensionContext) {

// Lock the editor group so clicking on files doesn't open them over the panel
await delay(100)
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
// await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
}

// context.subscriptions.push(vscode.commands.registerCommand("roo-cline.popoutButtonClicked", openClineInNewTab))
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/editor/DiffViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class DiffViewProvider {
Getting diagnostics before and after the file edit is a better approach than
automatically tracking problems in real-time. This method ensures we only
report new problems that are a direct result of this specific edit.
Since these are new problems resulting from Roo's edit, we know they're
Since these are new problems resulting from Agent's edit, we know they're
directly related to the work he's doing. This eliminates the risk of Roo
going off-task or getting distracted by unrelated issues, which was a problem
with the previous auto-debug approach. Some users' machines may be slow to
Expand Down Expand Up @@ -299,7 +299,7 @@ export class DiffViewProvider {
query: Buffer.from(this.originalContent ?? "").toString("base64"),
}),
uri,
`${fileName}: ${fileExists ? "Original ↔ Roo's Changes" : "New File"} (Editable)`,
`${fileName}: ${fileExists ? "Original ↔ Agent's Changes" : "New File"} (Editable)`,
)
// This may happen on very slow machines ie project idx
setTimeout(() => {
Expand Down
Loading