Skip to content

Commit 11e4f69

Browse files
committed
feat: implement Phase 3 of mode-to-agent renaming
- Updated all function names from mode to agent terminology - Updated all variable names throughout the codebase - Updated property names in objects and interfaces - Updated event names (TaskModeSwitched → TaskAgentSwitched) - Maintained backward compatibility with aliases for all renamed functions - Preserved "mode" terminology in marketplace-related code and .roomodes files - Fixed test expectations to maintain backward compatibility - Fixed enum duplicate value lint error - All tests passing (3044 passed, 48 skipped)
1 parent 342ee70 commit 11e4f69

26 files changed

+3705
-3546
lines changed

packages/types/src/ipc.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export enum RooCodeEventName {
2020
Message = "message",
2121
TaskCreated = "taskCreated",
2222
TaskStarted = "taskStarted",
23-
TaskModeSwitched = "taskModeSwitched",
23+
TaskAgentSwitched = "taskAgentSwitched",
2424
TaskPaused = "taskPaused",
2525
TaskUnpaused = "taskUnpaused",
2626
TaskAskResponded = "taskAskResponded",
@@ -33,6 +33,9 @@ export enum RooCodeEventName {
3333
EvalFail = "evalFail",
3434
}
3535

36+
// Backward compatibility alias
37+
export const TaskModeSwitched = RooCodeEventName.TaskAgentSwitched
38+
3639
export const rooCodeEventsSchema = z.object({
3740
[RooCodeEventName.Message]: z.tuple([
3841
z.object({
@@ -43,7 +46,7 @@ export const rooCodeEventsSchema = z.object({
4346
]),
4447
[RooCodeEventName.TaskCreated]: z.tuple([z.string()]),
4548
[RooCodeEventName.TaskStarted]: z.tuple([z.string()]),
46-
[RooCodeEventName.TaskModeSwitched]: z.tuple([z.string(), z.string()]),
49+
[RooCodeEventName.TaskAgentSwitched]: z.tuple([z.string(), z.string()]),
4750
[RooCodeEventName.TaskPaused]: z.tuple([z.string()]),
4851
[RooCodeEventName.TaskUnpaused]: z.tuple([z.string()]),
4952
[RooCodeEventName.TaskAskResponded]: z.tuple([z.string()]),
@@ -121,8 +124,8 @@ export const taskEventSchema = z.discriminatedUnion("eventName", [
121124
taskId: z.number().optional(),
122125
}),
123126
z.object({
124-
eventName: z.literal(RooCodeEventName.TaskModeSwitched),
125-
payload: rooCodeEventsSchema.shape[RooCodeEventName.TaskModeSwitched],
127+
eventName: z.literal(RooCodeEventName.TaskAgentSwitched),
128+
payload: rooCodeEventsSchema.shape[RooCodeEventName.TaskAgentSwitched],
126129
taskId: z.number().optional(),
127130
}),
128131
z.object({

packages/types/src/mode.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const groupEntrySchema = z.union([toolGroupsSchema, z.tuple([toolGroupsSc
3939
export type GroupEntry = z.infer<typeof groupEntrySchema>
4040

4141
/**
42-
* ModeConfig
42+
* AgentConfig
4343
*/
4444

4545
const groupEntryArraySchema = z.array(groupEntrySchema).refine(
@@ -61,7 +61,7 @@ const groupEntryArraySchema = z.array(groupEntrySchema).refine(
6161
{ message: "Duplicate groups are not allowed" },
6262
)
6363

64-
export const modeConfigSchema = z.object({
64+
export const agentConfigSchema = z.object({
6565
slug: z.string().regex(/^[a-zA-Z0-9-]+$/, "Slug must contain only letters numbers and dashes"),
6666
name: z.string().min(1, "Name is required"),
6767
roleDefinition: z.string().min(1, "Role definition is required"),
@@ -72,14 +72,18 @@ export const modeConfigSchema = z.object({
7272
source: z.enum(["global", "project"]).optional(),
7373
})
7474

75-
export type ModeConfig = z.infer<typeof modeConfigSchema>
75+
export type AgentConfig = z.infer<typeof agentConfigSchema>
76+
77+
// Keep ModeConfig as an alias for backward compatibility (will be removed in later phase)
78+
export const modeConfigSchema = agentConfigSchema
79+
export type ModeConfig = AgentConfig
7680

7781
/**
78-
* CustomModesSettings
82+
* CustomAgentsSettings
7983
*/
8084

81-
export const customModesSettingsSchema = z.object({
82-
customModes: z.array(modeConfigSchema).refine(
85+
export const customAgentsSettingsSchema = z.object({
86+
customModes: z.array(agentConfigSchema).refine(
8387
(modes) => {
8488
const slugs = new Set()
8589

@@ -98,7 +102,11 @@ export const customModesSettingsSchema = z.object({
98102
),
99103
})
100104

101-
export type CustomModesSettings = z.infer<typeof customModesSettingsSchema>
105+
export type CustomAgentsSettings = z.infer<typeof customAgentsSettingsSchema>
106+
107+
// Keep CustomModesSettings as an alias for backward compatibility (will be removed in later phase)
108+
export const customModesSettingsSchema = customAgentsSettingsSchema
109+
export type CustomModesSettings = CustomAgentsSettings
102110

103111
/**
104112
* PromptComponent
@@ -114,12 +122,16 @@ export const promptComponentSchema = z.object({
114122
export type PromptComponent = z.infer<typeof promptComponentSchema>
115123

116124
/**
117-
* CustomModePrompts
125+
* CustomAgentPrompts
118126
*/
119127

120-
export const customModePromptsSchema = z.record(z.string(), promptComponentSchema.optional())
128+
export const customAgentPromptsSchema = z.record(z.string(), promptComponentSchema.optional())
121129

122-
export type CustomModePrompts = z.infer<typeof customModePromptsSchema>
130+
export type CustomAgentPrompts = z.infer<typeof customAgentPromptsSchema>
131+
132+
// Keep CustomModePrompts as an alias for backward compatibility (will be removed in later phase)
133+
export const customModePromptsSchema = customAgentPromptsSchema
134+
export type CustomModePrompts = CustomAgentPrompts
123135

124136
/**
125137
* CustomSupportPrompts
@@ -133,7 +145,7 @@ export type CustomSupportPrompts = z.infer<typeof customSupportPromptsSchema>
133145
* DEFAULT_MODES
134146
*/
135147

136-
export const DEFAULT_MODES: readonly ModeConfig[] = [
148+
export const DEFAULT_AGENTS: readonly AgentConfig[] = [
137149
{
138150
slug: "architect",
139151
name: "🏗️ Architect",
@@ -193,3 +205,6 @@ export const DEFAULT_MODES: readonly ModeConfig[] = [
193205
"Your role is to coordinate complex workflows by delegating tasks to specialized modes. As an orchestrator, you should:\n\n1. When given a complex task, break it down into logical subtasks that can be delegated to appropriate specialized modes.\n\n2. For each subtask, use the `new_task` tool to delegate. Choose the most appropriate mode for the subtask's specific goal and provide comprehensive instructions in the `message` parameter. These instructions must include:\n * All necessary context from the parent task or previous subtasks required to complete the work.\n * A clearly defined scope, specifying exactly what the subtask should accomplish.\n * An explicit statement that the subtask should *only* perform the work outlined in these instructions and not deviate.\n * An instruction for the subtask to signal completion by using the `attempt_completion` tool, providing a concise yet thorough summary of the outcome in the `result` parameter, keeping in mind that this summary will be the source of truth used to keep track of what was completed on this project.\n * A statement that these specific instructions supersede any conflicting general instructions the subtask's mode might have.\n\n3. Track and manage the progress of all subtasks. When a subtask is completed, analyze its results and determine the next steps.\n\n4. Help the user understand how the different subtasks fit together in the overall workflow. Provide clear reasoning about why you're delegating specific tasks to specific modes.\n\n5. When all subtasks are completed, synthesize the results and provide a comprehensive overview of what was accomplished.\n\n6. Ask clarifying questions when necessary to better understand how to break down complex tasks effectively.\n\n7. Suggest improvements to the workflow based on the results of completed subtasks.\n\nUse subtasks to maintain clarity. If a request significantly shifts focus or requires a different expertise (mode), consider creating a subtask rather than overloading the current one.",
194206
},
195207
] as const
208+
209+
// Keep DEFAULT_MODES as an alias for backward compatibility (will be removed in later phase)
210+
export const DEFAULT_MODES = DEFAULT_AGENTS

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { serializeError } from "serialize-error"
44
import type { ToolName, ClineAsk, ToolProgressStatus } from "@roo-code/types"
55
import { TelemetryService } from "@roo-code/telemetry"
66

7-
import { defaultModeSlug, getModeBySlug } from "../../shared/modes"
7+
import { defaultAgentSlug, getAgentBySlug } from "../../shared/agents"
88
import type { ToolParamName, ToolResponse } from "../../shared/tools"
99

1010
import { fetchInstructionsTool } from "../tools/fetchInstructionsTool"
@@ -209,10 +209,10 @@ export async function presentAssistantMessage(cline: Task) {
209209
case "update_todo_list":
210210
return `[${block.name}]`
211211
case "new_task": {
212-
const mode = block.params.mode ?? defaultModeSlug
212+
const agent = block.params.mode ?? defaultAgentSlug
213213
const message = block.params.message ?? "(no message)"
214-
const modeName = getModeBySlug(mode, customModes)?.name ?? mode
215-
return `[${block.name} in ${modeName} mode: '${message}']`
214+
// We'll get the custom agents when we actually need them
215+
return `[${block.name} in ${agent} agent: '${message}']`
216216
}
217217
}
218218
}
@@ -352,13 +352,13 @@ export async function presentAssistantMessage(cline: Task) {
352352
}
353353

354354
// Validate tool use before execution.
355-
const { mode, customModes } = (await cline.providerRef.deref()?.getState()) ?? {}
355+
const { mode: agent, customModes: customAgents } = (await cline.providerRef.deref()?.getState()) ?? {}
356356

357357
try {
358358
validateToolUse(
359359
block.name as ToolName,
360-
mode ?? defaultModeSlug,
361-
customModes ?? [],
360+
agent ?? defaultAgentSlug,
361+
customAgents ?? [],
362362
{ apply_diff: cline.diffEnabled },
363363
block.params,
364364
)

0 commit comments

Comments
 (0)