clanka 0.2.62 → 0.2.64
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/Agent.d.ts.map +1 -1
- package/dist/Agent.js +1 -1
- package/dist/Agent.js.map +1 -1
- package/dist/AgentExecutor.d.ts +11 -11
- package/dist/CopilotAuth.test.js +1 -1
- package/dist/CopilotAuth.test.js.map +1 -1
- package/dist/ScriptPreprocessing.d.ts.map +1 -1
- package/dist/ScriptPreprocessing.js +29 -8
- package/dist/ScriptPreprocessing.js.map +1 -1
- package/dist/ScriptPreprocessing.test.js +1 -0
- package/dist/ScriptPreprocessing.test.js.map +1 -1
- package/package.json +14 -14
- package/src/Agent.ts +1 -3
- package/src/CopilotAuth.test.ts +1 -1
- package/src/ScriptPreprocessing.test.ts +1 -0
- package/src/ScriptPreprocessing.ts +42 -10
- package/src/fixtures/patch21-broken.txt +1016 -0
- package/src/fixtures/patch21-fixed.txt +1016 -0
|
@@ -123,6 +123,31 @@ const findTemplateEnd = (
|
|
|
123
123
|
return end
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
const findStandaloneTemplateEnd = (
|
|
127
|
+
text: string,
|
|
128
|
+
start: number,
|
|
129
|
+
isTerminator: (char: string | undefined) => boolean,
|
|
130
|
+
): number => {
|
|
131
|
+
for (let index = start + 1; index < text.length; index++) {
|
|
132
|
+
if (text[index] !== "`" || isEscaped(text, index)) {
|
|
133
|
+
continue
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const next = skipWhitespace(text, index + 1)
|
|
137
|
+
if (!isTerminator(text[next])) {
|
|
138
|
+
continue
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const lineStart = text.lastIndexOf("\n", index - 1) + 1
|
|
142
|
+
const prefix = text.slice(lineStart, index)
|
|
143
|
+
if (/^[ \t]*$/.test(prefix)) {
|
|
144
|
+
return index
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return -1
|
|
149
|
+
}
|
|
150
|
+
|
|
126
151
|
const findTemplateEndFirst = (
|
|
127
152
|
text: string,
|
|
128
153
|
start: number,
|
|
@@ -492,6 +517,17 @@ const findLiteralInterpolationEnd = (text: string, start: number): number => {
|
|
|
492
517
|
const expressionEnd = skipWhitespace(text, literalEnd + 1)
|
|
493
518
|
return text[expressionEnd] === "}" ? expressionEnd : -1
|
|
494
519
|
}
|
|
520
|
+
|
|
521
|
+
const isAssignedTemplateTerminator = (char: string | undefined): boolean =>
|
|
522
|
+
char === undefined ||
|
|
523
|
+
char === "\n" ||
|
|
524
|
+
char === "\r" ||
|
|
525
|
+
char === ";" ||
|
|
526
|
+
char === "," ||
|
|
527
|
+
char === ")" ||
|
|
528
|
+
char === "}" ||
|
|
529
|
+
char === "]"
|
|
530
|
+
|
|
495
531
|
const escapeTemplateLiteralContent = (text: string): string => {
|
|
496
532
|
const patchNormalized = normalizePatchEscapedQuotes(text)
|
|
497
533
|
const isPatchContent = patchNormalized.includes("*** Begin Patch")
|
|
@@ -1022,19 +1058,15 @@ const rewriteAssignedTemplate = (
|
|
|
1022
1058
|
continue
|
|
1023
1059
|
}
|
|
1024
1060
|
|
|
1025
|
-
const
|
|
1061
|
+
const standaloneTemplateEnd = findStandaloneTemplateEnd(
|
|
1026
1062
|
text,
|
|
1027
1063
|
templateStart,
|
|
1028
|
-
|
|
1029
|
-
char === undefined ||
|
|
1030
|
-
char === "\n" ||
|
|
1031
|
-
char === "\r" ||
|
|
1032
|
-
char === ";" ||
|
|
1033
|
-
char === "," ||
|
|
1034
|
-
char === ")" ||
|
|
1035
|
-
char === "}" ||
|
|
1036
|
-
char === "]",
|
|
1064
|
+
isAssignedTemplateTerminator,
|
|
1037
1065
|
)
|
|
1066
|
+
const templateEnd =
|
|
1067
|
+
standaloneTemplateEnd === -1
|
|
1068
|
+
? findTemplateEnd(text, templateStart, isAssignedTemplateTerminator)
|
|
1069
|
+
: standaloneTemplateEnd
|
|
1038
1070
|
if (templateEnd === -1) {
|
|
1039
1071
|
cursor = templateStart + 1
|
|
1040
1072
|
continue
|