Giter Site home page Giter Site logo

keonesteam / auto-dev Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unit-mesh/auto-dev

0.0 0.0 0.0 3.04 MB

AutoDev 是一款基于 JetBrains IDE 的 LLM/AI 辅助编程插件。AutoDev 能够与您的需求管理系统(例如 Jira、Trello、Github Issue 等)直接对接。在 IDE 中,您只需简单点击,AutoDev 会根据您的需求自动为您生成代码。您所需做的,仅仅是对生成的代码进行质量检查。

Home Page: https://ide.unitmesh.cc/

License: Mozilla Public License 2.0

Java 0.08% Kotlin 99.51% HTML 0.41%

auto-dev's Introduction

AutoDev

Build Version Downloads

AutoDev 是一款高度自动化的 AI 辅助编程工具。AutoDev 能够与您的需求管理系统(例如 Jira、Trello、Github Issue 等)直接对接。在 IDE 中,您只需简单点击,AutoDev 会根据您的需求自动为您生成代码。您所需做的,仅仅是对生成的代码进行质量检查。

features:

  • languages support: Java, Kotlin, Python, JavaScript, or others...
  • Auto development mode. With DevTi Protocol (like devti://story/github/1102) will auto generate Model-Controller-Service-Repository code.
  • Smart code completion.
    • Pattern specific.Based on your code context like (Controller, Service import), AutoDev will suggest you the best code.
    • Related code. Based on recently file changes, AutoDev will call calculate similar chunk to generate best code.
  • AI assistant. AutoDev will help you find bug, explain code, trace exception, generate commits, and more.
  • Custom prompt. You can customize your prompt in Settings -> Tools -> AutoDev
  • Custom LLM Server. You can customize your LLM Server in Settings -> Tools -> AutoDev
  • Auto Testing
    • auto create unit test.
    • auto run unit test and try to fix test.
  • Smart architecture. With ArchGuard Co-mate DSL, AutoDev will help you design your architecture.

Usage

  1. Install from JetBrains Plugin Repository: AutoDev
  2. Configure GitHub Token (optional) and OpenAI config in Settings -> Tools -> AutoDev

CodeCompletion mode

You can:

  • Right-click on the code editor, select AutoDev -> CodeCompletion -> CodeComplete
  • or use Alt + Enter to open Intention Actions menu, select AutoDev -> CodeCompletion

Code completion

Custom prompt

{
  "auto_complete": {
    "instruction": "",
    "input": ""
  },
  "auto_comment": {
    "instruction": "",
    "input": ""
  },
  "code_review": {
    "instruction": "",
    "input": ""
  },
  "refactor": {
    "instruction": "",
    "input": ""
  },
  "write_test": {
    "instruction": "",
    "input": ""
  },
  "spec": {
    "controller": "- 在 Controller 中使用 BeanUtils.copyProperties 进行 DTO 转换 Entity\n- 禁止使用 Autowired\n-使用 Swagger Annotation 表明 API 含义\n-Controller 方法应该捕获并处理业务异常,不应该抛出系统异常。",
    "service": "- Service 层应该使用构造函数注入或者 setter 注入,不要使用 @Autowired 注解注入。",
    "entity": "- Entity 类应该使用 JPA 注解进行数据库映射\n- 实体类名应该与对应的数据库表名相同。实体类应该使用注解标记主键和表名,例如:@Id、@GeneratedValue、@Table 等。",
    "repository": "- Repository 接口应该继承 JpaRepository 接口,以获得基本的 CRUD 操作",
    "ddl": "-  字段应该使用 NOT NULL 约束,确保数据的完整性"
  }
}

AutoCRUD mode

  1. add // devti://story/github/1 comments in your code.
  2. configure GitHub repository for Run Configuration.
  3. click AutoDev button in the comments' left.

Run Screenshots:

AutoDev

Output Screenshots:

AutoDev

Development

  1. git clone https://github.com/unit-mesh/AutoDev.git
  2. open in IntelliJ IDEA
  3. ./gradlew runIde

Key Concepts:

Release

  1. change pluginVersion in gradle.properties
  2. git tag version
  3. ./gradlew publishPlugin

improve language support for some language

We referenced the multi-language support implementation of JetBrains AI Assistant and combined it with the design principles of AutoDev to design a series of extension points.

We referenced the multi-target support implementation of Intellij Rust plugin and combined it with the design.

For a new language, you need to implement:

  1. create a new module in settings.gradle.kts, like: webstorm, pycharm ...,
  2. config in build.gradle.kts for new module, like:
project(":pycharm") {
    intellij {
        version.set(pycharmVersion)
        plugins.set(pycharmPlugins)
    }
    dependencies {
        implementation(project(":"))
    }
}
  1. sync Gradle in Intellij IDEA
  2. create xml file in resources/META-INF like cc.unitmesh.pycharm.xml, and import to plugin/src/main/resources/META-INF/plugin.xml
  3. create extension points

Extension Points

JetBrains AI Assistant Extension Points:

<extensionPoints>
    <extensionPoint qualifiedName="cc.unitmesh.fileContextBuilder"
                    beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true">
        <with attribute="implementationClass"
              implements="cc.unitmesh.devti.context.builder.FileContextBuilder"/>
    </extensionPoint>

    <extensionPoint qualifiedName="cc.unitmesh.classContextBuilder"
                    beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true">
        <with attribute="implementationClass"
              implements="cc.unitmesh.devti.context.builder.ClassContextBuilder"/>
    </extensionPoint>

    <extensionPoint qualifiedName="cc.unitmesh.methodContextBuilder"
                    beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true">
        <with attribute="implementationClass"
              implements="cc.unitmesh.devti.context.builder.MethodContextBuilder"/>
    </extensionPoint>

    <extensionPoint qualifiedName="cc.unitmesh.variableContextBuilder"
                    beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true">
        <with attribute="implementationClass"
              implements="cc.unitmesh.devti.context.builder.VariableContextBuilder"/>
    </extensionPoint>
</extensionPoints>

AutoDev Extension Points:

<extensionPoints>
    <!-- AutoCRUD flow -->
    <extensionPoint qualifiedName="cc.unitmesh.devFlowProvider"
                    interface="cc.unitmesh.devti.provider.DevFlowProvider"
                    dynamic="true"/>

    <!-- get tech stacks from dep, like build.gradle, package.json ... -->
    <extensionPoint qualifiedName="cc.unitmesh.techStackProvider"
                    interface="cc.unitmesh.devti.provider.TechStackProvider"
                    dynamic="true"/>

    <!-- custom context strategy for Auto CRUD -->
    <extensionPoint qualifiedName="cc.unitmesh.contextPrompter"
                    interface="cc.unitmesh.devti.provider.ContextPrompter"
                    dynamic="true"/>

    <!-- Others strategy, like token count -->
    <extensionPoint qualifiedName="cc.unitmesh.promptStrategy"
                    interface="cc.unitmesh.devti.provider.PromptStrategy"
                    dynamic="true"/>
</extensionPoints>

Java/IDEA Example

<extensions defaultExtensionNs="cc.unitmesh">
    <!-- Language support   -->
    <classContextBuilder language="JAVA"
                         implementationClass="cc.unitmesh.ide.idea.context.JavaClassContextBuilder"/>

    <methodContextBuilder language="JAVA"
                          implementationClass="cc.unitmesh.ide.idea.context.JavaMethodContextBuilder"/>

    <fileContextBuilder language="JAVA"
                        implementationClass="cc.unitmesh.ide.idea.context.JavaFileContextBuilder"/>

    <variableContextBuilder language="JAVA"
                            implementationClass="cc.unitmesh.ide.idea.context.JavaVariableContextBuilder"/>

    <!-- TechStack Binding -->
    <contextPrompter
            language="JAVA"
            implementation="cc.unitmesh.ide.idea.provider.JavaContextPrompter"/>
    <techStackProvider
            language="JAVA"
            implementation="cc.unitmesh.ide.idea.provider.JavaTechStackService"/>
    <devFlowProvider
            language="JAVA"
            implementation="cc.unitmesh.ide.idea.provider.JavaAutoDevFlow"/>
    <promptStrategy
            language="JAVA"
            implementation="cc.unitmesh.ide.idea.provider.PromptStrategyAdvisor"/>
</extensions>

Prompt Strategy

JetBrains LLM and GitHub Copilot try to implmentation like this:

defaultPriorities.json = [
    "BeforeCursor",
    "SimilarFile",
    "ImportedFile",
    "PathMarker",
    "LanguageMarker"
]

We currently support:

  • BeforeCursor
  • SimilarFile
    • JaccardSimilarity Path and Chunks by JetBrains
    • Cosine Similarity Chunk by MethodName
  • ImportedFile
    • Java CRUD
    • all cases
  • PathMarker
  • LanguageMarker

Useful Links

License

This code is distributed under the MPL 2.0 license. See LICENSE in this directory.

auto-dev's People

Contributors

actions-user avatar imneov avatar phodal avatar yugasun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.