@shakecodeslikecray/whiterose 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +67 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +66 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -886,8 +886,23 @@ Set "survived": true if you CANNOT disprove it (it's a real bug).`;
|
|
|
886
886
|
const candidates = [];
|
|
887
887
|
let depth = 0;
|
|
888
888
|
let start = -1;
|
|
889
|
+
let inString = false;
|
|
890
|
+
let escapeNext = false;
|
|
889
891
|
for (let i = 0; i < text3.length; i++) {
|
|
890
892
|
const char = text3[i];
|
|
893
|
+
if (escapeNext) {
|
|
894
|
+
escapeNext = false;
|
|
895
|
+
continue;
|
|
896
|
+
}
|
|
897
|
+
if (char === "\\" && inString) {
|
|
898
|
+
escapeNext = true;
|
|
899
|
+
continue;
|
|
900
|
+
}
|
|
901
|
+
if (char === '"' && !escapeNext) {
|
|
902
|
+
inString = !inString;
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
if (inString) continue;
|
|
891
906
|
if (char === "{") {
|
|
892
907
|
if (depth === 0) {
|
|
893
908
|
start = i;
|
|
@@ -1082,13 +1097,58 @@ Set "survived": true if you CANNOT disprove it (it's a real bug).`;
|
|
|
1082
1097
|
if (codeBlockMatch) {
|
|
1083
1098
|
return codeBlockMatch[1].trim();
|
|
1084
1099
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1100
|
+
return this.findBalancedJson(text3);
|
|
1101
|
+
}
|
|
1102
|
+
// Find the first balanced JSON object or array in text
|
|
1103
|
+
findBalancedJson(text3) {
|
|
1104
|
+
const objectStart = text3.indexOf("{");
|
|
1105
|
+
const arrayStart = text3.indexOf("[");
|
|
1106
|
+
let start = -1;
|
|
1107
|
+
let openChar = "{";
|
|
1108
|
+
let closeChar = "}";
|
|
1109
|
+
if (objectStart === -1 && arrayStart === -1) {
|
|
1110
|
+
return null;
|
|
1111
|
+
} else if (objectStart === -1) {
|
|
1112
|
+
start = arrayStart;
|
|
1113
|
+
openChar = "[";
|
|
1114
|
+
closeChar = "]";
|
|
1115
|
+
} else if (arrayStart === -1) {
|
|
1116
|
+
start = objectStart;
|
|
1117
|
+
} else {
|
|
1118
|
+
if (arrayStart < objectStart) {
|
|
1119
|
+
start = arrayStart;
|
|
1120
|
+
openChar = "[";
|
|
1121
|
+
closeChar = "]";
|
|
1122
|
+
} else {
|
|
1123
|
+
start = objectStart;
|
|
1124
|
+
}
|
|
1088
1125
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1126
|
+
let depth = 0;
|
|
1127
|
+
let inString = false;
|
|
1128
|
+
let escapeNext = false;
|
|
1129
|
+
for (let i = start; i < text3.length; i++) {
|
|
1130
|
+
const char = text3[i];
|
|
1131
|
+
if (escapeNext) {
|
|
1132
|
+
escapeNext = false;
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
if (char === "\\" && inString) {
|
|
1136
|
+
escapeNext = true;
|
|
1137
|
+
continue;
|
|
1138
|
+
}
|
|
1139
|
+
if (char === '"' && !escapeNext) {
|
|
1140
|
+
inString = !inString;
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
if (inString) continue;
|
|
1144
|
+
if (char === openChar) {
|
|
1145
|
+
depth++;
|
|
1146
|
+
} else if (char === closeChar) {
|
|
1147
|
+
depth--;
|
|
1148
|
+
if (depth === 0) {
|
|
1149
|
+
return text3.slice(start, i + 1);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1092
1152
|
}
|
|
1093
1153
|
return null;
|
|
1094
1154
|
}
|
|
@@ -4233,7 +4293,7 @@ ${chalk.red(" \u255A\u2550\u2550\u255D\u255A\u2550\u2550\u255D \u255A\u2550\u255
|
|
|
4233
4293
|
${chalk.dim(` "I've been staring at your code for a long time."`)}
|
|
4234
4294
|
`;
|
|
4235
4295
|
var program = new Command();
|
|
4236
|
-
program.name("whiterose").description("AI-powered bug hunter that uses your existing LLM subscription").version("0.2.
|
|
4296
|
+
program.name("whiterose").description("AI-powered bug hunter that uses your existing LLM subscription").version("0.2.3").hook("preAction", () => {
|
|
4237
4297
|
const args = process.argv.slice(2);
|
|
4238
4298
|
if (!args.includes("--help") && !args.includes("-h") && args.length > 0) {
|
|
4239
4299
|
console.log(BANNER);
|