Skip to content

Commit 05f3887

Browse files
committed
Merge main into will/mode-plumbing - Use createTask naming and CreateTaskOptions
2 parents ec3721f + 44086e4 commit 05f3887

File tree

18 files changed

+281
-177
lines changed

18 files changed

+281
-177
lines changed

packages/types/npm/package.metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@roo-code/types",
3-
"version": "1.48.0",
3+
"version": "1.49.0",
44
"description": "TypeScript type definitions for Roo Code.",
55
"publishConfig": {
66
"access": "public",

packages/types/src/task.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { RooCodeEventName } from "./events.js"
44
import { type ClineMessage, type BlockingAsk, type TokenUsage } from "./message.js"
55
import { type ToolUsage, type ToolName } from "./tool.js"
66
import { type Experiments } from "./experiment.js"
7+
import type { StaticAppProperties, GitProperties, TelemetryProperties } from "./telemetry.js"
78

89
/**
910
* TaskProviderLike
@@ -13,7 +14,7 @@ export interface TaskProviderState {
1314
mode?: string
1415
}
1516

16-
export interface InitTaskOptions {
17+
export interface CreateTaskOptions {
1718
modeSlug?: string
1819
enableDiff?: boolean
1920
enableCheckpoints?: boolean
@@ -23,24 +24,23 @@ export interface InitTaskOptions {
2324
}
2425
export interface TaskProviderLike {
2526
readonly cwd: string
27+
readonly appProperties: StaticAppProperties
28+
readonly gitProperties: GitProperties | undefined
2629

27-
getCurrentCline(): TaskLike | undefined
30+
getCurrentTask(): TaskLike | undefined
2831
getCurrentTaskStack(): string[]
32+
getRecentTasks(): string[]
2933

30-
initClineWithTask(
31-
text?: string,
32-
images?: string[],
33-
parentTask?: TaskLike,
34-
options?: InitTaskOptions,
35-
): Promise<TaskLike>
34+
createTask(text?: string, images?: string[], parentTask?: TaskLike, options?: CreateTaskOptions): Promise<TaskLike>
3635
cancelTask(): Promise<void>
3736
clearTask(): Promise<void>
38-
postStateToWebview(): Promise<void>
3937

4038
getState(): Promise<TaskProviderState>
41-
39+
postStateToWebview(): Promise<void>
4240
postMessageToWebview(message: unknown): Promise<void>
4341

42+
getTelemetryProperties(): Promise<TelemetryProperties>
43+
4444
on<K extends keyof TaskProviderEvents>(
4545
event: K,
4646
listener: (...args: TaskProviderEvents[K]) => void | Promise<void>,
@@ -50,14 +50,6 @@ export interface TaskProviderLike {
5050
event: K,
5151
listener: (...args: TaskProviderEvents[K]) => void | Promise<void>,
5252
): this
53-
54-
context: {
55-
extension?: {
56-
packageJSON?: {
57-
version?: string
58-
}
59-
}
60-
}
6153
}
6254

6355
export type TaskProviderEvents = {

packages/types/src/telemetry.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,37 @@ export enum TelemetryEventName {
7272
* TelemetryProperties
7373
*/
7474

75-
export const appPropertiesSchema = z.object({
75+
export const staticAppPropertiesSchema = z.object({
7676
appName: z.string(),
7777
appVersion: z.string(),
7878
vscodeVersion: z.string(),
7979
platform: z.string(),
8080
editorName: z.string(),
81+
})
82+
83+
export type StaticAppProperties = z.infer<typeof staticAppPropertiesSchema>
84+
85+
export const dynamicAppPropertiesSchema = z.object({
8186
language: z.string(),
8287
mode: z.string(),
88+
})
89+
90+
export type DynamicAppProperties = z.infer<typeof dynamicAppPropertiesSchema>
91+
92+
export const cloudAppPropertiesSchema = z.object({
8393
cloudIsAuthenticated: z.boolean().optional(),
8494
})
8595

96+
export type CloudAppProperties = z.infer<typeof cloudAppPropertiesSchema>
97+
98+
export const appPropertiesSchema = z.object({
99+
...staticAppPropertiesSchema.shape,
100+
...dynamicAppPropertiesSchema.shape,
101+
...cloudAppPropertiesSchema.shape,
102+
})
103+
104+
export type AppProperties = z.infer<typeof appPropertiesSchema>
105+
86106
export const taskPropertiesSchema = z.object({
87107
taskId: z.string().optional(),
88108
apiProvider: z.enum(providerNames).optional(),
@@ -99,20 +119,23 @@ export const taskPropertiesSchema = z.object({
99119
.optional(),
100120
})
101121

122+
export type TaskProperties = z.infer<typeof taskPropertiesSchema>
123+
102124
export const gitPropertiesSchema = z.object({
103125
repositoryUrl: z.string().optional(),
104126
repositoryName: z.string().optional(),
105127
defaultBranch: z.string().optional(),
106128
})
107129

130+
export type GitProperties = z.infer<typeof gitPropertiesSchema>
131+
108132
export const telemetryPropertiesSchema = z.object({
109133
...appPropertiesSchema.shape,
110134
...taskPropertiesSchema.shape,
111135
...gitPropertiesSchema.shape,
112136
})
113137

114138
export type TelemetryProperties = z.infer<typeof telemetryPropertiesSchema>
115-
export type GitProperties = z.infer<typeof gitPropertiesSchema>
116139

117140
/**
118141
* TelemetryEvent

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/link-packages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function startWatch(pkg: PackageConfig): WatcherResult {
212212
throw new Error(`Invalid watch command for ${pkg.name}`)
213213
}
214214

215-
console.log(`Watching for changes to ${pkg.sourcePath} with ${cmd} ${args.join(" ")}`)
215+
console.log(`👀 Watching for changes to ${pkg.sourcePath} with ${cmd} ${args.join(" ")}`)
216216

217217
const child = spawn(cmd, args, {
218218
cwd: path.resolve(__dirname, "..", pkg.sourcePath),
@@ -251,7 +251,7 @@ function startWatch(pkg: PackageConfig): WatcherResult {
251251
debounceTimer = setTimeout(() => {
252252
linkPackage(pkg)
253253

254-
console.log(`📋 Copied ${pkg.name} to ${pkg.targetPaths.length} paths\n`)
254+
console.log(`♻️ Copied ${pkg.name} to ${pkg.targetPaths.length} paths\n`)
255255

256256
debounceTimer = null
257257
}, DEBOUNCE_DELAY)

src/core/task/Task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
19871987
const history = await provider?.getTaskWithId(this.taskId)
19881988

19891989
if (history) {
1990-
await provider?.initClineWithHistoryItem(history.historyItem)
1990+
await provider?.createTaskWithHistoryItem(history.historyItem)
19911991
}
19921992
}
19931993
} finally {

src/core/tools/__tests__/newTaskTool.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const mockAskApproval = vi.fn<AskApproval>()
2222
const mockHandleError = vi.fn<HandleError>()
2323
const mockPushToolResult = vi.fn()
2424
const mockRemoveClosingTag = vi.fn((_name: string, value: string | undefined) => value ?? "")
25-
const mockInitClineWithTask = vi.fn<() => Promise<MockClineInstance>>().mockResolvedValue({ taskId: "mock-subtask-id" })
25+
const mockCreateTask = vi.fn<() => Promise<MockClineInstance>>().mockResolvedValue({ taskId: "mock-subtask-id" })
2626
const mockEmit = vi.fn()
2727
const mockRecordToolError = vi.fn()
2828
const mockSayAndCreateMissingParamError = vi.fn()
@@ -40,7 +40,7 @@ const mockCline = {
4040
deref: vi.fn(() => ({
4141
getState: vi.fn(() => ({ customModes: [], mode: "ask" })),
4242
handleModeSwitch: vi.fn(),
43-
initClineWithTask: mockInitClineWithTask,
43+
createTask: mockCreateTask,
4444
})),
4545
},
4646
}
@@ -88,8 +88,8 @@ describe("newTaskTool", () => {
8888
// Verify askApproval was called
8989
expect(mockAskApproval).toHaveBeenCalled()
9090

91-
// Verify the message passed to initClineWithTask reflects the code's behavior in unit tests
92-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
91+
// Verify the message passed to createTask reflects the code's behavior in unit tests
92+
expect(mockCreateTask).toHaveBeenCalledWith(
9393
"Review this: \\@file1.txt and also \\\\\\@file2.txt", // Unit Test Expectation: \\@ -> \@, \\\\@ -> \\\\@
9494
undefined,
9595
mockCline,
@@ -122,7 +122,7 @@ describe("newTaskTool", () => {
122122
mockRemoveClosingTag,
123123
)
124124

125-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
125+
expect(mockCreateTask).toHaveBeenCalledWith(
126126
"This is already unescaped: \\@file1.txt", // Expected: \@ remains \@
127127
undefined,
128128
mockCline,
@@ -149,7 +149,7 @@ describe("newTaskTool", () => {
149149
mockRemoveClosingTag,
150150
)
151151

152-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
152+
expect(mockCreateTask).toHaveBeenCalledWith(
153153
"A normal mention @file1.txt", // Expected: @ remains @
154154
undefined,
155155
mockCline,
@@ -176,7 +176,7 @@ describe("newTaskTool", () => {
176176
mockRemoveClosingTag,
177177
)
178178

179-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
179+
expect(mockCreateTask).toHaveBeenCalledWith(
180180
"Mix: @file0.txt, \\@file1.txt, \\@file2.txt, \\\\\\@file3.txt", // Unit Test Expectation: @->@, \@->\@, \\@->\@, \\\\@->\\\\@
181181
undefined,
182182
mockCline,

src/core/tools/newTaskTool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function newTaskTool(
8383
cline.pausedModeSlug = (await provider.getState()).mode ?? defaultModeSlug
8484

8585
// Create new task instance first (this preserves parent's current mode in its history)
86-
const newCline = await provider.initClineWithTask(unescapedMessage, undefined, cline)
86+
const newCline = await provider.createTask(unescapedMessage, undefined, cline)
87+
8788
if (!newCline) {
8889
pushToolResult(t("tools:newTask.errors.policy_restriction"))
8990
return

0 commit comments

Comments
 (0)