@@ -70,7 +70,11 @@ const modernizeInputSchema = z.object({
7070 // Casting to [string, ...string[]] since the enum definition requires a nonempty array.
7171 transformations : z
7272 . array ( z . enum ( TRANSFORMATIONS . map ( ( t ) => t . name ) as [ string , ...string [ ] ] ) )
73- . optional ( ) ,
73+ . optional ( )
74+ . describe (
75+ 'A list of specific transformations to get instructions for. ' +
76+ 'If omitted, general guidance is provided.' ,
77+ ) ,
7478} ) ;
7579
7680export type ModernizeInput = z . infer < typeof modernizeInputSchema > ;
@@ -116,28 +120,38 @@ export async function runModernization(input: ModernizeInput) {
116120export const MODERNIZE_TOOL = declareTool ( {
117121 name : 'modernize' ,
118122 title : 'Modernize Angular Code' ,
119- description :
120- '<Purpose>\n' +
121- 'This tool modernizes Angular code by applying the latest best practices and syntax improvements, ' +
122- 'ensuring it is idiomatic, readable, and maintainable.\n\n' +
123- '</Purpose>\n' +
124- '<Use Cases>\n' +
125- '* After generating new code: Run this tool immediately after creating new Angular components, directives, ' +
126- 'or services to ensure they adhere to modern standards.\n' +
127- '* On existing code: Apply to existing TypeScript files (.ts) and Angular templates (.html) to update ' +
128- 'them with the latest features, such as the new built-in control flow syntax.\n\n' +
129- '* When the user asks for a specific transformation: When the transformation list is populated, ' +
130- 'these specific ones will be ran on the inputs.\n' +
131- '</Use Cases>\n' +
132- '<Transformations>\n' +
133- TRANSFORMATIONS . map ( ( t ) => `* ${ t . name } : ${ t . description } ` ) . join ( '\n' ) +
134- '\n</Transformations>\n' ,
123+ description : `
124+ <Purpose>
125+ Provides instructions and commands for modernizing Angular code to align with the latest best
126+ practices and syntax. This tool helps ensure code is idiomatic, readable, and maintainable by
127+ generating the exact steps needed to perform specific migrations.
128+ </Purpose>
129+ <Use Cases>
130+ * **Applying Specific Migrations:** Get the precise commands to update code to modern patterns
131+ (e.g., selecting 'control-flow-migration' to replace *ngIf with @if).
132+ * **Upgrading Existing Code:** Modernize an entire project by running the 'standalone' migration,
133+ which provides a multi-step command sequence.
134+ * **Discovering Available Migrations:** Call the tool with no transformations to get a link to the
135+ general best practices guide.
136+ </Use Cases>
137+ <Operational Notes>
138+ * **Execution:** This tool **provides instructions**, which you **MUST** then execute as shell commands.
139+ It does not modify code directly.
140+ * **Standalone Migration:** The 'standalone' transformation is a special, multi-step process.
141+ You **MUST** execute the commands in the exact order provided and validate your application
142+ between each step.
143+ * **Transformation List:** The following transformations are available:
144+ ${ TRANSFORMATIONS . map ( ( t ) => ` * ${ t . name } : ${ t . description } ` ) . join ( '\n' ) }
145+ </Operational Notes>` ,
135146 inputSchema : modernizeInputSchema . shape ,
136147 outputSchema : {
137148 instructions : z
138149 . array ( z . string ( ) )
139150 . optional ( )
140- . describe ( 'A list of instructions on how to run the migrations.' ) ,
151+ . describe (
152+ 'A list of instructions and shell commands to run the requested modernizations. ' +
153+ 'Each string in the array is a separate step or command.' ,
154+ ) ,
141155 } ,
142156 isLocalOnly : true ,
143157 isReadOnly : true ,
0 commit comments