@@ -3,6 +3,7 @@ import * as path from "path"
33import * as fs from "fs/promises"
44
55import * as yaml from "yaml"
6+ import stripBom from "strip-bom"
67
78import { type ModeConfig , customModesSettingsSchema } from "@roo-code/types"
89
@@ -74,18 +75,6 @@ export class CustomModesManager {
7475 return exists ? roomodesPath : undefined
7576 }
7677
77- /**
78- * Strip BOM (Byte Order Mark) from the beginning of a string
79- */
80- private stripBOM ( content : string ) : string {
81- // When Node.js reads UTF-8 or UTF-16 files, it correctly decodes them
82- // and any BOM appears as \uFEFF at the start of the string
83- if ( content . startsWith ( "\uFEFF" ) ) {
84- return content . slice ( 1 )
85- }
86- return content
87- }
88-
8978 /**
9079 * Regex pattern for problematic characters that need to be cleaned from YAML content
9180 * Includes:
@@ -129,7 +118,7 @@ export class CustomModesManager {
129118 */
130119 private parseYamlSafely ( content : string , filePath : string ) : any {
131120 // Clean the content
132- let cleanedContent = this . stripBOM ( content )
121+ let cleanedContent = stripBom ( content )
133122 cleanedContent = this . cleanInvisibleCharacters ( cleanedContent )
134123
135124 try {
@@ -145,10 +134,8 @@ export class CustomModesManager {
145134 vscode . window . showErrorMessage ( t ( "common:customModes.errors.yamlParseError" , { line } ) )
146135 }
147136
148- // Re-throw with a flag to prevent duplicate error handling
149- const enhancedError = new Error ( errorMsg )
150- ; ( enhancedError as any ) . alreadyHandled = true
151- throw enhancedError
137+ // Return empty object to prevent duplicate error handling
138+ return { }
152139 }
153140 }
154141
0 commit comments