Skip to content

ankitbanka17/prompt-based-coding

Repository files navigation

Prompt Based Coding

🚧 Caution: Pre-Alpha — Early Stage Development

An IntelliJ IDEA plugin project that leverages OpenAI to interpret natural language prompts and automatically create or modify Java Spring Boot code within your development workspace. This repository contains the complete source code for the plugin—no marketplace distribution is provided.

Features

  • Natural Language to Code: Interpret developer prompts in plain English and translate them into actionable code changes.
  • Class Creation & Modification: Automatically generate new classes or update existing ones based on structured JSON instructions.
  • Context Awareness: Retrieve existing code context (classes, methods, imports) to ensure accurate modifications.
  • JSON-Based Instruction Extraction: Use GPT-4o-mini to parse prompts into structured instructions (action, newClasses, modifiedClasses, etc.).
  • Embedded Tool Window: A custom Tool Window in IntelliJ for prompt input and instant feedback within the IDE.

Getting Started

Prerequisites

  • IntelliJ IDEA Community or Ultimate (version 2021.3 or newer)
  • Java 11 or higher
  • Gradle (wrapper included)
  • An OpenAI API key

Building the Plugin

  1. Clone this repository:
    git clone https://github.com/ankitbanka17/prompt-based-coding.git
    cd prompt-based-coding
  2. Configure your OpenAI API key (see Configuration below).
  3. Build the plugin JAR:
    ./gradlew clean build
    The resulting plugin artifact will be at build/distributions/prompt-based-coding.zip.

Installing Locally

  1. In IntelliJ IDEA, go to SettingsPlugins.
  2. Click the gear icon and choose Install Plugin from Disk...
  3. Select the generated ZIP (build/distributions/prompt-based-coding.zip).
  4. Restart the IDE to activate the plugin.

Running in Dev Mode

For iterative development, you can launch a sandbox instance of IntelliJ:

./gradlew runIde

This opens a fresh IDE with your plugin loaded, isolating it from your main IDE settings.

Usage

  1. Open the Prompt-Based Coding tool window: ViewTool WindowsPrompt-Based Coding.
  2. Enter a natural language instruction, for example:
    Add a REST controller for user management with CRUD endpoints.
    
  3. Press Submit. The plugin will:
    • Send the prompt to LLMAdapter for instruction extraction.
    • Locate or create target code files via PromptProcessor.
    • Apply modifications or generate new code using CodeModifier.
    • Write changes to your project and display results in the tool window.

Configuration

All settings

  • OpenAI API Key: Your API key (e.g., sk-...). Define in LLMAdapter

Project Structure

prompt-based-coding/
├── src/
│   ├── main/
│   │   ├── kotlin/com/github/ankitbanka17/promptbasedcoding/
│   │   │   ├── adapter/LLMAdapter.kt
│   │   │   ├── handlers/PromptProcessor.kt
│   │   │   ├── services/CodeModifier.kt
│   │   │   ├── tools/MyToolWindow.kt
│   │   │   └── util/PromptBuilder.kt
│   │   └── resources/prompts/
│   │       └── code_instructions.txt
│   └── test/
├── build.gradle.kts
├── settings.gradle.kts
├── gradle/
└── gradlew*  

License

This project is licensed under the MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages