From bb59d14f686d39598f3f3f8e7ffd86a7796f40f9 Mon Sep 17 00:00:00 2001 From: nekowasabi Date: Thu, 24 Oct 2024 18:49:42 +0900 Subject: [PATCH 1/7] =?UTF-8?q?refactor:=20=E3=83=AA=E3=83=8D=E3=83=BC?= =?UTF-8?q?=E3=83=A0=EF=BC=88sendPrompt=E3=81=A0=E3=81=91=E3=81=A0?= =?UTF-8?q?=E3=81=A8=E4=B8=80=E8=88=AC=E7=9A=84=E3=81=99=E3=81=8E=E3=82=8B?= =?UTF-8?q?=E3=81=9F=E3=82=81=EF=BC=89=20:recycle:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/aider/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denops/aider/main.ts b/denops/aider/main.ts index 9d8654e..680977b 100644 --- a/denops/aider/main.ts +++ b/denops/aider/main.ts @@ -105,7 +105,7 @@ export async function main(denops: Denops): Promise { } const commands: Command[] = [ - await command("sendPrompt", "0", async () => { + await command("sendPromptByBuffer", "0", async () => { await buffer.sendPromptByBuffer(denops, openBufferType); }), From 1c2783f490ed3887cc367600496a3fa7de5c4790 Mon Sep 17 00:00:00 2001 From: nekowasabi Date: Thu, 24 Oct 2024 19:24:56 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=E3=82=B3=E3=83=9E=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=83=A9=E3=82=A4=E3=83=B3=E3=81=8B=E3=82=89=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=83=B3=E3=83=97=E3=83=88=E3=82=92=E9=80=81=E4=BF=A1?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20:sparkles:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/aider/main.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/denops/aider/main.ts b/denops/aider/main.ts index 680977b..fe61257 100644 --- a/denops/aider/main.ts +++ b/denops/aider/main.ts @@ -109,6 +109,24 @@ export async function main(denops: Denops): Promise { await buffer.sendPromptByBuffer(denops, openBufferType); }), + await command( + "sendPromptByCommandline", + "1", + async (prompt: string) => { + await buffer.sendPrompt(denops, prompt, { openBuf: true }); + }, + { pattern: "[]" }, + ), + + await command( + "silentSendPromptByCommandline", + "1", + async (prompt: string) => { + await buffer.sendPrompt(denops, prompt, { openBuf: false }); + }, + { pattern: "[]" }, + ), + await command("run", "0", async () => { await buffer.openAiderBuffer(denops, openBufferType); }), From 41e97bdeb8f9a2109553cc8e671f64f25460b7f9 Mon Sep 17 00:00:00 2001 From: nekowasabi Date: Thu, 24 Oct 2024 19:25:07 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88:=20AiderSendPro?= =?UTF-8?q?mptByCommandline=20=E3=81=8C=E6=AD=A3=E5=B8=B8=E3=81=AB?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=81=99=E3=82=8B=E3=81=93=E3=81=A8=E3=82=92?= =?UTF-8?q?=E7=A2=BA=E8=AA=8D=20=F0=9F=94=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/aider_test.ts | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/aider_test.ts b/tests/aider_test.ts index fca9c09..a82cc5d 100644 --- a/tests/aider_test.ts +++ b/tests/aider_test.ts @@ -35,11 +35,35 @@ test("both", "AiderAddBuffers should return empty for files not under git manage await assertAiderBufferString(denops, "input: /add \n"); }); -test("both", "AiderAddBuffers should return /add `bufferName` if there is a buffer under git management", async (denops) => { +test( + "both", + "AiderAddBuffers should return /add `bufferName` if there is a buffer under git management", + async (denops) => { + await denops.cmd("AiderRun"); + await sleep(SLEEP_BEFORE_ASSERT); + await denops.cmd("e ./tests/aider_test.ts"); + await denops.cmd("AiderAddBuffers"); + await sleep(SLEEP_BEFORE_ASSERT); + await assertAiderBufferString(denops, "input: /add tests/aider_test.ts\n"); + }, +); + +test("both", "AiderSendPromptByCommandline should work", async (denops) => { await denops.cmd("AiderRun"); await sleep(SLEEP_BEFORE_ASSERT); - await denops.cmd("e ./tests/aider_test.ts"); - await denops.cmd("AiderAddBuffers"); + await assertAiderBufferAlive(denops); + await sleep(SLEEP_BEFORE_ASSERT); + await denops.cmd("AiderSendPromptByCommandline test"); + await sleep(SLEEP_BEFORE_ASSERT); + await assertAiderBufferString(denops, "input: test\n"); +}); + +test("both", "AiderSilentSendPromptByCommandline should work", async (denops) => { + await denops.cmd("AiderRun"); + await sleep(SLEEP_BEFORE_ASSERT); + await assertAiderBufferAlive(denops); + await sleep(SLEEP_BEFORE_ASSERT); + await denops.cmd("AiderSilentSendPromptByCommandline silent test"); await sleep(SLEEP_BEFORE_ASSERT); - await assertAiderBufferString(denops, "input: /add tests/aider_test.ts\n"); + await assertAiderBufferString(denops, "input: silent test\n"); }); From 490eedaa6c3e1c72bae73d23cdb3377c8d3e1f06 Mon Sep 17 00:00:00 2001 From: nekowasabi Date: Thu, 24 Oct 2024 19:35:23 +0900 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20=E9=81=B8=E6=8A=9E=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E6=B5=AE=E5=8B=95=E3=82=A6?= =?UTF-8?q?=E3=82=A3=E3=83=B3=E3=83=89=E3=82=A6=E3=81=A7=E9=96=8B=E3=81=8F?= =?UTF-8?q?=E3=81=A8=E3=81=8D=E3=81=AE=E3=82=AD=E3=83=BC=E3=83=9E=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=82=92=E4=BF=AE=E6=AD=A3=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/aider/bufferOperation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denops/aider/bufferOperation.ts b/denops/aider/bufferOperation.ts index ab43f2e..d79747a 100644 --- a/denops/aider/bufferOperation.ts +++ b/denops/aider/bufferOperation.ts @@ -157,7 +157,7 @@ export async function openFloatingWindowWithSelectedCode( await n.nvim_buf_set_keymap(denops, bufnr, "n", "q", "AiderHideVisualSelectFloatingWindow", { silent: true, }); - await n.nvim_buf_set_keymap(denops, bufnr, "n", "", "AiderSendPromptAiderRun", { + await n.nvim_buf_set_keymap(denops, bufnr, "n", "", "AiderSendPromptByBufferAiderRun", { silent: true, }); } From 88eca50b4f09cf43e793afe47477b9d0d97c7108 Mon Sep 17 00:00:00 2001 From: nekowasabi Date: Thu, 24 Oct 2024 19:41:53 +0900 Subject: [PATCH 5/7] =?UTF-8?q?docs:=20rEADME=E3=81=ABAider=E3=81=AE?= =?UTF-8?q?=E9=AB=98=E5=BA=A6=E3=81=AA=E4=BD=BF=E7=94=A8=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=20=F0=9F=93=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 60816b4..fbcd3c1 100644 --- a/README.md +++ b/README.md @@ -135,12 +135,26 @@ To use aider.vim, you can run the following commands within Vim or Neovim: - `:AiderAddWeb` - Displays a prompt for the specified URL and adds it to the aider context. - `:AiderOpenIgnore` - Opens the `.aiderignore` file in the git root directory if it exists. - `:AiderAddIgnoreCurrentFile` - Adds the current file to the `.aiderignore`. +- `:AiderSendPromptByCommandline ` - Sends a prompt from the command line and displays the Aider window. +- `:AiderSilentSendPromptByCommandline ` - Sends a prompt from the command line and refreshes the buffer. - `:AiderAsk ` - Sends a question to aider without adding any files to the context. - `:AiderHide` - Hides the floating window and reloads the buffer. - `:AiderPaste` - Pastes the content from the clipboard into the aider context. - `:AiderHideVisualSelectFloatingWindow` - Hides the visual selection floating window used for displaying selected text. - `:AiderVoice` - Sends voice commands to Aider(using wishper). +### Advanced Usage +If you want to send a custom prompt to Aider, use `AiderSendPromptByCommandline`. +Set it up as follows: + +```vim +" Send a prompt to Aider and display the Aider window +:AiderSendPromptByCommandline "/chat-mode architect" + +" Send a prompt to Aider but do not display the Aider window +:AiderSilentSendPromptByCommandline "/chat-mode code" +``` + ## Additional Prompt You can set an additional prompt that will be automatically added to every From be4bc27a24b6043272205f00dfbda775e8927431 Mon Sep 17 00:00:00 2001 From: nekowasabi Date: Thu, 24 Oct 2024 19:44:32 +0900 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20add=20console=20log=20for=20sent=20?= =?UTF-8?q?prompt=20=F0=9F=92=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/aider/main.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/denops/aider/main.ts b/denops/aider/main.ts index fe61257..5c0708c 100644 --- a/denops/aider/main.ts +++ b/denops/aider/main.ts @@ -123,6 +123,7 @@ export async function main(denops: Denops): Promise { "1", async (prompt: string) => { await buffer.sendPrompt(denops, prompt, { openBuf: false }); + console.log(`Sent prompt: ${prompt}`); }, { pattern: "[]" }, ), From b32c6b2f035b7d042b8a4447b0d09a2ffafebef8 Mon Sep 17 00:00:00 2001 From: nekowasabi Date: Thu, 24 Oct 2024 19:58:02 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20aiderSilentSendPromptByCommandline?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/aider_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/aider_test.ts b/tests/aider_test.ts index a82cc5d..c347b2a 100644 --- a/tests/aider_test.ts +++ b/tests/aider_test.ts @@ -59,7 +59,7 @@ test("both", "AiderSendPromptByCommandline should work", async (denops) => { }); test("both", "AiderSilentSendPromptByCommandline should work", async (denops) => { - await denops.cmd("AiderRun"); + await denops.cmd("AiderSilentRun"); await sleep(SLEEP_BEFORE_ASSERT); await assertAiderBufferAlive(denops); await sleep(SLEEP_BEFORE_ASSERT);