Skip to content

Commit 6b35951

Browse files
committed
feat: add next step suggestions and XML utilities
- Add NextStepSuggest component for displaying suggested next steps - Add XML utilities for improved XML parsing - Update ChatView and ChatRow to handle next step suggestions - Add fast-xml-parser dependency - Update package dependencies update snapshoot feat(ui): enhance next step suggestions UX and documentation - Improve next step UI with collapsible view and show more/less toggle - Add type validation and error handling for suggestion parsing - Update documentation with clearer formatting guidelines and examples - Enhance button styling and accessibility for better user interaction update snapshot refactor: move next step suggestions into chat row for better UX feat: enhance next step suggestions with mode selection - Make next_step parameter required in attempt_completion tool - Update suggestion format to include task and mode fields - Enhance UI to display mode alongside task description - Update parsing logic to handle new suggestion format - Improve error handling for missing or invalid suggestions refactor(NextStepSuggest): improve component with shadcn UI and better styling - Replace native buttons with shadcn Button component - Increase button dimensions for better readability - Add proper text wrapping and overflow handling - Style mode text as VSCode badge - Improve hover and active states - Maintain VSCode theming integration - Show 3 suggestions in non-expanded mode feat: make next step suggestions official - Remove next_step_suggest from experiments - Make next step suggestions a required parameter in attempt_completion - Update documentation to reflect next step suggestions as core functionality - Remove experimental conditionals from objective and rules sections update snapshoot update UI UX update UI UX fix potiential issues use same scrollbar with chat convension better hover color feat(NextStepSuggest): add expand/collapse functionality with instance isolation - Add expand/collapse functionality to show more/less suggestions - Implement instance-specific state management via instanceId prop - Add Show More/Less button with suggestion count - Improve accessibility with ARIA labels - Add Lucide icons for visual indicators refactor: move next step suggestions parsing to wrapper component - Add NextStepSuggestionsWrapper to handle suggestion parsing - Remove suggestion state management from ChatView - Update ChatRow to use wrapper component - Clean up NextStepSuggest component props Implement badge for mode display and theme-aware component variants feat(ui): add toolkit badge variant and apply to NextStepSuggest component Improve NextStepSuggest component UX by adding auto-scroll to toggle button and fixing text alignment refactor(ui): improve NextStepSuggest component styling - Remove padding and borders for cleaner appearance - Add toolkit-no-border variant to Badge component - Add ui-toolkit-primary-no-border variant to Button component - Reposition mode badge from bottom-left to bottom-right - Update styling classes for better visual consistency fix pr comment fix pr comemnt fix UX
1 parent fef4a1c commit 6b35951

File tree

22 files changed

+1268
-72
lines changed

22 files changed

+1268
-72
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@
342342
"diff": "^5.2.0",
343343
"diff-match-patch": "^1.0.5",
344344
"fast-deep-equal": "^3.1.3",
345+
"fast-xml-parser": "^4.5.1",
345346
"fastest-levenshtein": "^1.0.16",
346347
"get-folder-size": "^5.0.0",
347348
"globby": "^14.0.2",

src/core/Cline.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import { DiffStrategy, getDiffStrategy } from "./diff/DiffStrategy"
7878
import { insertGroups } from "./diff/insert-groups"
7979
import { telemetryService } from "../services/telemetry/TelemetryService"
8080
import { validateToolUse, isToolAllowedForMode, ToolName } from "./mode-validator"
81+
import { parseXml } from "../utils/xml"
8182
import { getWorkspacePath } from "../utils/path"
8283

8384
type ToolResponse = string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam>
@@ -2945,6 +2946,7 @@ export class Cline extends EventEmitter<ClineEvents> {
29452946
case "attempt_completion": {
29462947
const result: string | undefined = block.params.result
29472948
const command: string | undefined = block.params.command
2949+
const next_step: string | undefined = block.params.next_step
29482950
try {
29492951
const lastMessage = this.clineMessages.at(-1)
29502952
if (block.partial) {
@@ -2995,8 +2997,44 @@ export class Cline extends EventEmitter<ClineEvents> {
29952997
break
29962998
}
29972999

3000+
if (!next_step) {
3001+
this.consecutiveMistakeCount++
3002+
pushToolResult(
3003+
await this.sayAndCreateMissingParamError("attempt_completion", "next_step"),
3004+
)
3005+
break
3006+
}
3007+
3008+
let normalizedSuggest = null
3009+
3010+
type Suggest = {
3011+
task: string
3012+
mode: string
3013+
}
3014+
3015+
let parsedSuggest: {
3016+
suggest: Suggest[] | Suggest
3017+
}
3018+
3019+
try {
3020+
parsedSuggest = parseXml(next_step, ["suggest.task", "suggest.mode"]) as {
3021+
suggest: Suggest[] | Suggest
3022+
}
3023+
console.log("next_step", next_step)
3024+
} catch (error) {
3025+
this.consecutiveMistakeCount++
3026+
await this.say("error", `Failed to parse operations: ${error.message}`)
3027+
pushToolResult(formatResponse.toolError("Invalid operations xml format"))
3028+
break
3029+
}
3030+
3031+
29983032
this.consecutiveMistakeCount = 0
29993033

3034+
normalizedSuggest = Array.isArray(parsedSuggest?.suggest)
3035+
? parsedSuggest.suggest
3036+
: [parsedSuggest?.suggest].filter((sug): sug is Suggest => sug !== undefined)
3037+
30003038
let commandResult: ToolResponse | undefined
30013039

30023040
if (command) {
@@ -3042,6 +3080,10 @@ export class Cline extends EventEmitter<ClineEvents> {
30423080
break
30433081
}
30443082

3083+
const toolResults: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] = []
3084+
3085+
await this.say("next_step_suggest", JSON.stringify(normalizedSuggest))
3086+
30453087
// We already sent completion_result says, an
30463088
// empty string asks relinquishes control over
30473089
// button and field.
@@ -3056,7 +3098,6 @@ export class Cline extends EventEmitter<ClineEvents> {
30563098
}
30573099

30583100
await this.say("user_feedback", text ?? "", images)
3059-
const toolResults: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] = []
30603101

30613102
if (commandResult) {
30623103
if (typeof commandResult === "string") {

src/core/assistant-message/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const toolParamNames = [
5757
"mode",
5858
"message",
5959
"cwd",
60+
"next_step",
6061
] as const
6162

6263
export type ToolParamName = (typeof toolParamNames)[number]
@@ -127,7 +128,7 @@ export interface AskFollowupQuestionToolUse extends ToolUse {
127128

128129
export interface AttemptCompletionToolUse extends ToolUse {
129130
name: "attempt_completion"
130-
params: Partial<Pick<Record<ToolParamName, string>, "result" | "command">>
131+
params: Partial<Pick<Record<ToolParamName, string>, "result" | "command" | "next_step">>
131132
}
132133

133134
export interface SwitchModeToolUse extends ToolUse {

0 commit comments

Comments
 (0)