@@ -1884,7 +1884,7 @@ export const webviewMessageHandler = async (
18841884 }
18851885 break
18861886 case "generateRules" :
1887- // Generate rules for the current workspace
1887+ // Generate rules for the current workspace by spawning a new task
18881888 try {
18891889 const workspacePath = getWorkspacePath ( )
18901890 if ( ! workspacePath ) {
@@ -1896,20 +1896,27 @@ export const webviewMessageHandler = async (
18961896 break
18971897 }
18981898
1899- // Get the current API configuration
1900- const { apiConfiguration } = await provider . getState ( )
1901-
19021899 // Import the rules generation service
1903- const { generateRulesForWorkspace } = await import ( "../../services/rules/rulesGenerator" )
1900+ const { createRulesGenerationTaskMessage } = await import ( "../../services/rules/rulesGenerator" )
1901+
1902+ // Create a comprehensive message for the rules generation task using existing analysis logic
1903+ const rulesGenerationMessage = await createRulesGenerationTaskMessage ( workspacePath )
19041904
1905- // Generate the rules with LLM support
1906- const rulesPath = await generateRulesForWorkspace ( workspacePath , apiConfiguration )
1905+ // Spawn a new task in code mode to generate the rules
1906+ await provider . initClineWithTask ( rulesGenerationMessage )
19071907
1908- // Send success message back to webview
1908+ // Send success message back to webview indicating task was created
19091909 await provider . postMessageToWebview ( {
19101910 type : "rulesGenerationStatus" ,
19111911 success : true ,
1912- text : rulesPath ,
1912+ text : "Rules generation task created successfully. The new task will analyze your codebase and generate comprehensive rules." ,
1913+ } )
1914+
1915+ // Automatically navigate to the chat tab to show the new task
1916+ await provider . postMessageToWebview ( {
1917+ type : "action" ,
1918+ action : "switchTab" ,
1919+ tab : "chat" ,
19131920 } )
19141921 } catch ( error ) {
19151922 // Send error message back to webview
0 commit comments