はじめに
- この記事では、VSCodeの拡張機能「Continue」のカスタムコマンドを紹介します。
- カスタムコマンドでは、プロンプトに指示するショートカットを定義できます。
- カスタムコマンドを利用すると、LLMへ短く効率的にプロンプトを指定することができます。
/でショートカットを指定できる。
testはハイライトしたコードに対して、ユニットテストを書いてのプロンプトになっている。
Continueとは
-「Continue」は、ソフトウェア開発のためのオープンソースのオートパイロット(コーディング支援AIツール)です。
- VS CodeやJetBrainsにChatGPTの力をもたらすIDE拡張機能であり、深くカスタマイズ可能に構築され、開発データから継続的に学習します。
- 詳細は https://continue.dev で確認できます。
カスタムコマンド定義方法
-
例えば、日本語翻訳を、英語に翻訳、絵文字を追加を定義してみる。
"customCommands": [
{
"name": "test",
"prompt": "Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
"description": "Write unit tests for highlighted code"
},
{
"name": "toJ",
"prompt": "Translate the selected sentence to Japanes. Give the sentence as chat output, don't edit any file.",
"description": "日本語"
},
{
"name": "toE",
"prompt": "Translate the selected sentence to English. Give the sentence just as chat output, don't edit any file.",
"description": "英語"
},
{
"name": "addEmoji",
"prompt": "Use emojis to decorate. Give the tests just as chat output, don't edit any file.",
"description": "絵文字"
}
],
デモ
- 文章を英語に翻訳してみる。
- ファイルを指定して文章に絵文字を追加してみる。
代替案
- その時によってショートカットを切り替えたくなるかもしれないから、あらかじめファイルで用意しておいて、作業する最初に入力するのもいいかも。
参考
- Contineのカスタムコマンドを試してみるところ、この方のXの投稿をみて感銘をうける。ChatGPTのメモリ機能は、備忘録くらいに考えてたんだが、こんな使い方あるんだなとびっくりする。思い浮かばなかったよ・・・。