Skip to content

Commit fa7b4f5

Browse files
committed
Prompt adjusted to fix json formats for languages like php and js
1 parent 175c972 commit fa7b4f5

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

MapperAI.sln.DotSettings.user

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=ee3fe810_002Dfb62_002D402b_002Db9c5_002D8dab803c815e/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="Test1" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
2+
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=5ca51f47_002De3fa_002D40db_002D8e16_002D940aee47c197/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="Test_Should_Create_4_Files_With_CSharp_Extension" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
3+
&lt;TestAncestor&gt;&#xD;
4+
&lt;TestId&gt;xUnit::8B3E109D-96CA-4B6D-B379-6AF70646DC25::net8.0::MapperAI.Test.FileMapperTests.Test_Should_Create_4_Files_With_CSharp_Extension&lt;/TestId&gt;&#xD;
5+
&lt;/TestAncestor&gt;&#xD;
6+
&lt;/SessionState&gt;</s:String>
7+
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=ee3fe810_002Dfb62_002D402b_002Db9c5_002D8dab803c815e/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="Test1" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
38
&lt;TestAncestor&gt;&#xD;
49
&lt;TestId&gt;xUnit::8B3E109D-96CA-4B6D-B379-6AF70646DC25::net8.0::MapperAI.Test.ClassMapperTests.Test1&lt;/TestId&gt;&#xD;
510
&lt;TestId&gt;xUnit::8B3E109D-96CA-4B6D-B379-6AF70646DC25::net8.0::MapperAI.Test.FileMapperTests.Test1&lt;/TestId&gt;&#xD;

src/MapperAI.Core/Clients/GeminiClientAI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ public async Task<ClientResponse> SendAsync(string prompt, CancellationToken can
5656
var cleanedJson = text
5757
.Replace("```json", string.Empty)
5858
.Replace("```", string.Empty)
59-
.Replace("\n", string.Empty)
59+
.Replace("\\$", "\\\\$")
6060
.Trim();
61+
6162
// var textSanitized = SanitizeJson(text);
6263
return new ClientResponse { Value = cleanedJson};
6364
}

src/MapperAI.Core/Mappers/FileMapper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ private string CreatePrompt(List<ClassContent> filesToMap, FileMapperConfigurati
9494
- Follow **all best practices, conventions, and idiomatic usage** of {configuration.Extension}.
9595
- Use clean code principles: clear naming, proper formatting, consistent style, and modular design.
9696
- Avoid deprecated patterns or anti-patterns.
97+
- **Escape all backslashes properly for JSON**: every single `\` must become `\\` to ensure valid JSON strings (especially in paths, regexes, or PHP variables like `\$`).
9798
- **DO NOT** return markdown, explanations, comments, or any text outside of the JSON array.
9899
- Your response **must be directly deserializable** into List<ClassContent>.
99100

0 commit comments

Comments
 (0)