Place this application in the same directory that contains your source code for your project.
Upload the files AI Prompt.txt and AI Code Injector.py to your AI Agent.
Once you do that, your AI agent will fully know how to then code with you so that you can utilize this application.
For each module in your project, as the first and last line of your code you need to manually place header and footer markers.
This isn't that time consuming and it only has to be done once.
Lets say you have a module called B4XMainPage.bas in your: users\owner\projects\My Project\b4a\ directory that consists of ~300 lines of code.
You would place the AI Code Injector.exe into that directory and run it.
Now go into the B4XMainPage and edit the first line to say:
'//<START-B4XMainPage-S01>
Your ~300 lines of code
'//<END-B4XMainPage-S01>
And make that your last line of code.
Now when your AI agent prints code going forward, due to the instructions I had you give it along with the source for this application, your agent will have a working knowledge of how this is used and going forward print your code containing these markers in the correct location within your code.
Now lets say B4XMainPage has 1000 lines of code and your agent chokes after a little while due to context window limitations and loses focus or worse yet, prints incomplete code focusing on one thing it is fixing or building and forgetting to include important code that does other things.
To prevent this from happening, break the code up into 3 manageable sections.
Such as:
'//<START-B4XMainPage-S01>
Lines 1-333
'//<END-B4XMainPage-S01>
'//<START-B4XMainPage-S02>
Lines 334-666
'//<END-B4XMainPage-S02>
'//<START-B4XMainPage-S03>
Lines 667-1000
'//<END-B4XMainPage-S03>
Now your AI prints a section of code. You copy it to your clipboard and click the inject button and it finds the correct module and section of your code, and overwrites it with the edit on your clipboard.
The source code is included with the application for your review and it should be uploaded to your agent along with the file
AI Prompt.txt so that your Agent knows how to code with you so you can use this application.
I designed this for my own coding sessions with AI Agents to promote code integrity safety, time saving, and convenience.
I now use it so often that I wouldn't want to now code with AI without it.
I hope you all get just as much use out of it as I do.
Oh I forgot to mention, long pressing the Inject Code button will put the application into Auto Inject Mode.
Now whenever the application detects the two markers on your clipboard it will begin a 5 second countdown and then automatically inject your newest edit from your AI., The 5 seconds gives you the opportunity to cancel the injection process if you need to.
If you use Gemini like I do, and you have Auto Injection mode on, all you need to do is click the copy code button after it outputs the code and this application will do the rest.
Last edited: