@@ -18,7 +18,7 @@ class ZigServer {
1818 this . server = new Server (
1919 {
2020 name : 'zig-mcp-server' ,
21- version : '0.1 .0' ,
21+ version : '0.2 .0' ,
2222 } ,
2323 {
2424 capabilities : {
@@ -230,8 +230,8 @@ class ZigServer {
230230
231231 private async fetchZigDocs ( section : 'language' | 'std' ) : Promise < string > {
232232 try {
233- // Fetch from Zig's official documentation
234- const response = await axios . get ( `https://ziglang.org/documentation/master /${ section === 'language' ? 'index' : 'std' } .html` ) ;
233+ // Fetch from Zig's official documentation for version 0.14.1
234+ const response = await axios . get ( `https://ziglang.org/documentation/0.14.1 /${ section === 'language' ? 'index' : 'std' } .html` ) ;
235235 return response . data ;
236236 } catch ( error ) {
237237 const errorMessage = error instanceof Error ? error . message : 'Unknown error' ;
@@ -344,19 +344,25 @@ ${analysis.allocations}
344344
345345 private analyzeMemoryUsage(code: string): string {
346346 const patterns = {
347- heapAlloc: /std\.(ArrayList|StringHashMap|AutoHashMap)/g,
347+ heapAlloc: /std\.(ArrayList|StringHashMap|AutoHashMap|HashMap )/g,
348348 stackAlloc: /var\s+\w+\s*:\s*\[(\d+)\]/g,
349- slices: /\[\](?:u8|i32|f64)/g,
349+ slices: /\[\](?:u8|i32|f64|usize|isize)/g,
350+ multiArrayList: /std\.MultiArrayList/g,
351+ boundedArray: /std\.BoundedArray/g,
350352 };
351353
352354 const heapAllocs = (code.match(patterns.heapAlloc) || []).length;
353355 const stackAllocs = (code.match(patterns.stackAlloc) || []).length;
354356 const sliceUsage = (code.match(patterns.slices) || []).length;
357+ const multiArrayLists = (code.match(patterns.multiArrayList) || []).length;
358+ const boundedArrays = (code.match(patterns.boundedArray) || []).length;
355359
356360 return `
357361- Heap Allocations : ${heapAllocs } detected
358362- Stack Allocations : ${stackAllocs } detected
359363- Slice Usage : ${sliceUsage } instances
364+ - MultiArrayList : ${multiArrayLists } instances
365+ - BoundedArray : ${boundedArrays } instances
360366- Memory Profile : ${heapAllocs > stackAllocs ? 'Heap-heavy' : 'Stack-optimized' }
361367 `.trim();
362368 }
@@ -515,7 +521,12 @@ pub const MyStruct = struct {
515521 }
516522
517523 pub fn deinit ( self : * MyStruct ) void {
518- // Cleanup
524+ // Cleanup allocated resources
525+ _ = self ; // suppress unused variable warning
526+ }
527+
528+ pub fn getData ( self : * const MyStruct ) [ ] const u8 {
529+ return self . data ;
519530 }
520531} ;
521532 `.trim();
@@ -530,6 +541,7 @@ pub const MyStruct = struct {
530541$ { fnHeader } {
531542 $ { requirements . errorHandling ? 'if (input.len == 0) return Error.InvalidInput;' : '' }
532543 // Function implementation
544+ _ = input ; // suppress unused parameter warning if not used
533545}
534546 `.trim();
535547 }
@@ -616,6 +628,14 @@ ${analysis.performance}
616628 if (code.includes('std.fmt.allocPrint')) {
617629 patterns.push('- Consider using formatters or bufPrint when possible');
618630 }
631+
632+ // Check for outdated Zig syntax (pre-0.11)
633+ if (code.match(/@intCast\(\s*\w+\s*,/)) {
634+ patterns.push('- Update @intCast syntax: use @intCast(value) instead of @intCast(Type, value)');
635+ }
636+ if (code.match(/@floatCast\(\s*\w+\s*,/)) {
637+ patterns.push('- Update @floatCast syntax: use @floatCast(value) instead of @floatCast(Type, value)');
638+ }
619639
620640 return patterns.length > 0 ? patterns.join('\n') : '- No significant pattern issues detected';
621641 }
@@ -662,16 +682,22 @@ ${analysis.performance}
662682 recommendations.push('- Use comptime when possible');
663683 recommendations.push('- Consider using packed structs for memory optimization');
664684 recommendations.push('- Implement custom allocators for specific use cases');
685+ recommendations.push('- Use @inline for small hot functions');
686+ recommendations.push('- Consider using @Vector for SIMD operations');
665687 }
666688 if (prompt.toLowerCase().includes('safety')) {
667689 recommendations.push('- Add bounds checking for array access');
668- recommendations.push('- Use explicit error handling');
669- recommendations.push('- Implement proper resource cleanup');
690+ recommendations.push('- Use explicit error handling with try/catch');
691+ recommendations.push('- Implement proper resource cleanup with defer');
692+ recommendations.push('- Use const where possible to prevent mutations');
693+ recommendations.push('- Avoid undefined behavior with proper initialization');
670694 }
671695 if (prompt.toLowerCase().includes('maintainability')) {
672696 recommendations.push('- Add comprehensive documentation');
673697 recommendations.push('- Break down complex functions');
674698 recommendations.push('- Use meaningful variable names');
699+ recommendations.push('- Organize code into modules and namespaces');
700+ recommendations.push('- Write unit tests for public functions');
675701 }
676702
677703 return recommendations.join('\n') ;
0 commit comments