Skip to content

Draft: POC - add code tasks

Jan Provaznik requested to merge jp-tasks into master

What does this MR do and why?

Related to &11734 (closed)

A POC of adding code tasks:

  • accepts current_file's arguments (filename, selected text, content above and below)
  • adds a new EditCode tool useful for doing any code changes
  • adds a couple of slash commands for this tool

Can be tested with mutation like this:

mutation {
  aiAction(input: {chat: {content: "/refactor", currentFile: {
    fileName: "test.py",
    selectedText: "
def extract
  lines = content.to_s.lines
  comment_block = []
  trimmed_lines = 0
end
",
    contentAboveCursor: "
module CodeSuggestions
  class InstructionsExtractor
    EMPTY_LINES_LIMIT = 1
    MIN_LINES_OF_CODE = 5
",
  }}}) {
    clientMutationId
    errors
  }
}

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jan Provaznik

Merge request reports