Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed aider echo and output error #198

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions core/llm/llms/AiderLLM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class Aider extends BaseLLM {
let responseComplete = false;
let potentialCompletion = false;
let potentialCompletionTimeout: NodeJS.Timeout | null = null;
let startedListening = false;

const escapeDollarSigns = (text: string | undefined) => {
if (!text) {
Expand All @@ -182,6 +183,7 @@ class Aider extends BaseLLM {
potentialCompletion = false;
}


if (READY_PROMPT_REGEX.test(newOutput)) {
// Instead of marking complete immediately, set up potential completion
if (!potentialCompletion) {
Expand All @@ -193,10 +195,18 @@ class Aider extends BaseLLM {
}

lastProcessedIndex = Aider.aiderProcess?.aiderOutput.length || 0;
yield {
role: "assistant",
content: escapeDollarSigns(newOutput),
};

// Start listening once we see a newline-prefixed message
if (!startedListening && newOutput.startsWith('\n')) {
startedListening = true;
}

if (startedListening) {
yield {
role: "assistant",
content: escapeDollarSigns(newOutput),
};
}

if (Aider.aiderProcess?.state.state === "stopped" || Aider.aiderProcess?.state.state === "crashed") {
if (potentialCompletionTimeout) {
Expand Down
20 changes: 19 additions & 1 deletion extensions/vscode/src/integrations/aider/aiderProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,28 @@ export const AIDER_END_MARKER = "───────────────
export const COMPLETION_DELAY = 1500; // 1.5 seconds wait time

function updateAiderVersion() {
let shouldUpgrade = false;
try {
if (compareVersions(getAiderVersion(), PEARAI_AIDER_VERSION) != 0) {
const aiderVersion = getAiderVersion();
console.log(`Current aider version: ${aiderVersion}`);
if (compareVersions(aiderVersion, PEARAI_AIDER_VERSION) != 0) {
console.log(`Upgrading aider-chat to version: ${PEARAI_AIDER_VERSION}`);
execSync(`pipx uninstall aider-chat`);
execSync(`pipx install aider-chat==${PEARAI_AIDER_VERSION}`);
}
} catch (error) {
console.error("Error updating Aider version:", error);
shouldUpgrade = true;
}

if (shouldUpgrade) {
try {
execSync(`pipx upgrade aider-chat`);
} catch (error) {
console.log(`Error upgrading aider-chat: ${error}`);
}
}
}

function getAiderVersion(): string {
try {
Expand Down Expand Up @@ -335,6 +347,12 @@ async startAiderChat(model: string, apiKey: string | undefined, isRestarting: bo
}
});
}

if (this.aiderProcess.stderr) {
this.aiderProcess.stderr.on('data', (data: Buffer) => {
console.error('Aider process stderr:', data.toString());
});
}

this.aiderProcess.on('exit', (code, signal) => {
console.log(`Aider process exited with code ${code}, signal ${signal}`);
Expand Down