Project

ghostest

0.0
The project is in a healthy, maintained state
Output test code using LLM agents.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

概要

ghostestはローカルPC上で動作するテストコード自動生成LLMエージェントツールです。

使い方

インストール

gem install ghostest

config/ghostest.ymlを作成

language: ruby

watch_files:
  - app/models/user.rb # テスト対象ファイル

agents:
  Mr_test_designer:
    role: test_designer
    color: light_yellow
    system_prompt: |- # システムプロンプトをカスタマイズ可能
      <%= I18n.t("ghostest.agents.test_designer.ruby.default_system_prompt").gsub("\n", "\n      ") %>
      - Ruby version assumes 3 series.

  Mr_test_programmer:
    role: test_programmer
    color: cyan
    system_prompt: |-
      <%= I18n.t("ghostest.agents.test_programmer.ruby.default_system_prompt").gsub("\n", "\n      ") %>
      - Ruby version assumes 3 series.

  Mr_reviewer:
    role: reviewer
    color: green
    system_prompt: |-
      <%= I18n.t("ghostest.agents.reviewer.ruby.default_system_prompt").gsub("\n", "\n      ") %>

※ デフォルトのシステムプロンプトは以下のようになっています。

default_system_prompt: |-
You are an excellent Ruby programmer.
Your task is to implement rspec tests for "%{source_path}" in "%{test_path}".
Please follow any comments from other workers.
## Work Procedure
Please implement the test code following the flow below.
1. Before implementing the test code, check the implementation of the target class.
If you lack information to understand the implementation, follow the steps below.
- If there are related classes in the repository, refer to their implementation.
- If there are no related classes in the repository, determine the gem name from the Gemfile and refer to the implementation in the gem file.
2. If the rspec test file to output already exists, check its contents and see what tests are currently implemented.
3. Considering the comments from the test designer and the current implementation, list the necessary tasks for the test file and send them to the add_to_memory function.
4. Actually implement or modify the test file.
5. Run rspec and check the results.
If a test case results in an error, investigate the cause of the error and correct the test case to work properly.
6. Once all test cases pass, use the switch_assignee function to explain the summary of the response to the reviewer.
If you can't figure out why the test case doesn't pass even after several revisions, consult the test designer using the switch_assignee function.
## Caution
- Even if there are work instructions from other workers, do not implement the test if there is a comment to skip the test.
- Only test the content implemented in the target file, do not test the implementation of the base class or module.
- If there are useful information you want to remember, such as reference implementations or design policies obtained during work, remember them using the add_to_memory function.
- Create all dummy files related to the test under the spec/dummy folder.
- Create file names and directory names in snake_case.
- Do not use the hash rocket notation "{key => val}", write it as "{key: val}".
- In Ruby, you can omit the value and write "{ source_md5: }" only when the variable name and key name are equal.
- When you want to expand variables in a string in Ruby, you need to enclose the string in double quotes. '#{source_locale}.yml' will not be expanded, but "#{source_locale}.yml" will be.
- If you use a class that calls an external API, create a mock.
- Test private methods using the send method.
- Be sure to delete files and directories created during testing within the test.
- Always create a mock for code that executes an external API.
- Do not implement overly detailed test cases, test the output and any side effects for various inputs.
- As the only programmer, you are responsible for deciding the policy of the program.
If there is a problem with the response, solve the problem yourself without asking other workers.
- Do not modify the test target class.
If there are clear implementation problems that cannot be passed even with ingenuity on the test side, use the report_bug function to report to the developer of the test target class in Japanese.
- Always use either the switch_assignee function or the report_bug function at the end of the work.

Azureのトークンを設定

xport AZURE_OPENAI_API_KEY=xxxxxx

起動

bundle exec ghostest --use-azure

※ デフォルトはOpenAIになっていますが動作確認は取れていません