fix(coding-agent): corrected variable initialization order in formatPromptContent
- Corrected variable initialization order in formatPromptContent to prevent stale trimmedStart value when ASCII symbol replacement occurs. - Updated bash.md documentation to use ellipsis (...) instead of three dots (...) for consistency with ASCII symbol replacement behavior. - Added test case verifying table row compaction and content deduplication during pre-render with ASCII symbol replacement.
This commit is contained in:
@@ -33,8 +33,8 @@ You **MUST** use specialized tools instead of bash for ALL file operations:
|
||||
|`rg 'pattern' dir/`|`grep(pattern="pattern", path="dir/")`|
|
||||
|`find dir -name '*.ts'`|`find(pattern="dir/**/*.ts")`|
|
||||
|`ls dir/`|`read(path="dir/")`|
|
||||
|`cat <<'EOF' > file`|`write(path="file", content="...")`|
|
||||
|`sed -i 's/old/new/' file`|`edit(path="file", edits=[...])`|
|
||||
|`cat <<'EOF' > file`|`write(path="file", content="…")`|
|
||||
|`sed -i 's/old/new/' file`|`edit(path="file", edits=[…])`|
|
||||
- If `ast_grep` / `ast_edit` tools are available in the session, you **MUST** use them for structural code search/rewrites instead of bash `grep`/`sed`/`awk`/`perl` pipelines
|
||||
- Bash is for command execution, not syntax-aware code transformation; prefer `ast_grep` for discovery and `ast_edit` for codemods
|
||||
- You **MUST NOT** use Bash for these operations like read, grep, find, edit, write, where specialized tools exist.
|
||||
|
||||
@@ -86,9 +86,7 @@ export function formatPromptContent(content: string, options: PromptFormatOption
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
let line = lines[i].trimEnd();
|
||||
const trimmed = line.trim();
|
||||
const trimmedStart = line.trimStart();
|
||||
|
||||
let trimmedStart = line.trimStart();
|
||||
if (CODE_FENCE.test(trimmedStart)) {
|
||||
inCodeBlock = !inCodeBlock;
|
||||
result.push(line);
|
||||
@@ -103,6 +101,8 @@ export function formatPromptContent(content: string, options: PromptFormatOption
|
||||
if (replaceAsciiSymbols) {
|
||||
line = replaceCommonAsciiSymbols(line);
|
||||
}
|
||||
trimmedStart = line.trimStart();
|
||||
const trimmed = line.trim();
|
||||
|
||||
const isOpeningXml = OPENING_XML.test(trimmedStart) && !trimmedStart.endsWith("/>");
|
||||
if (isOpeningXml && line.length === trimmedStart.length) {
|
||||
|
||||
Reference in New Issue
Block a user