Other B4J v10.5 BETA with integrated Code Bundle tool has been released

Erel

B4X founder
Staff member
Licensed User
Longtime User
Code Bundle is a tool that packs your project together with additional relevant information into a single json file, that can be provided to AI assistants for debugging, learning, refactoring and other tasks.

The bundle is created with a click of a button (Ctrl + R). The bundle includes:
  • Project code + list of public APIs. Keys are sanitized based on heuristic templates.
  • (optional) Logs + compilation output + warnings and errors list. Compilation output is included when the dialog is visible.
  • (optional) Layouts + designer script.
  • (optional) Paths configuration.
  • List of files. Files content is not added.
  • List of libraries with additional information for each library.
  • Current caret location with the code around it - the AI knows where you are focused on right now.
  • Additional information about the IDE and useful links for the AI to find more information.
How to use:
- Click on Ctrl + R. A json file will be created and copied to the clipboard. Paste into the AI assistant and ask questions.

I tested it with several AI platforms and the results are quite good. The answers are mostly to the point. Not always so be cautious.

Other improvements:
  • Autocomplete in #If lines:
    1772023445202.png


  • Fix for String.ToLower not explicitly setting the locale. Mainly fixes the Turkish I: https://www.b4x.com/android/forum/t...ctly-for-the-turkish-language.163961/#content
  • PyBridge template updated.
  • New #Macro / comment link options:
    • librariesrefresh - set to True to automatically refresh the libraries after the task runs.
    • codesync - set to True to force the IDE to synchronize the code modules with the files.
    • autosave - set to True to automatically save the project BEFORE running the task. Note that Tools - IDE Options - Auto Save should be enabled for this to have effect.
    • filessync (not new) - set to True to synchronize the Files tab after the task.
    • cleanproject (not new) - set to True to "clean project" after the task
    • %STATE1% - new variable that causes the IDE to create a temporary file with the IDE state based on the new options under Tools - IDE Options. The file path will be passed to the process. This is used by Code Bundle and can be used by other similar tools. Note that the format is not final and can be modified.
  • Objects\Temp folder is deleted when cleaning project.
  • Json library updated and maps now preserve order when writing or reading.
  • Other bug fixes and minor improvements.

Download link: https://www.b4x.com/b4j/files/beta.exe
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The source code of CodeBundle is attached. You don't need it unless you want to modify or build something similar.

Internally it is called with a command similar to:
B4X:
ide://run?File=%B4X%\\CodeBundle.jar&Args=%STATE1%&autosave=True
 

Attachments

  • CodeBundle-source.zip
    9.3 KB · Views: 12
Upvote 0

aeric

Expert
Licensed User
Longtime User
New #Macro / comment link options:
  • librariesrefresh - set to True to automatically refresh the libraries after the task runs.
I guess:
B4X:
#Macro: Title, GetLibraries, ide://run?file=%JAVABIN%\java.exe&args=-jar&args=%ADDITIONAL%\..\B4X\libget.jar&args=%PROJECT%&args=false&librariesrefresh=True
Once I clicked on the Macro, the IDE will call my libget.jar to download my b4xlib from GitHub and then refreshes the Libraries Manager tab.

Am I correct?
I haven't tested it but my concern is the args for my tool.
And if I am wrong, librariesrefresh=True can only work for file=null?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I am going to install the beta version now.

Objects\Temp folder is deleted when cleaning project.
Nice.

Json library updated and maps now preserve order when writing or reading.
This is a BIG news!
I think this will make my ProcessOrderedJsonFromMap sub in WebApiUtils redundant.
Note that in most implementations of maps the order is not preserved. In most use cases the order is not important.
https://www.b4x.com/android/forum/threads/map-collection-the-most-useful-collection.60304/
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
In the case of B4A and B4J* the map order is preserved. The JSON standard explicitly says that the order of keys isn't important. In the case of "code bundle" the case became important as there is an advantage for putting the important stuff at the beginning and I didn't want to make the structure too complicated.

* The standard map, not Server.CreateThreadSafe map.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I install (not clean) the BETA on the existing B4J path.
I tried to compile a simple non-UI app.
I get an error.

JCore v10.50
Json v1.30

JDK 14:
B4X:
B4J Version: 10.50 BETA #1
Parsing code.    (0.00s)
    Java Version: 14
Building folders structure.    (0.00s)
Compiling code.    (0.01s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    (0.75s)
Compiling debugger engine code.    Error
error: file not found: C:\Program Files\B4X\B4J\debug_java_nonui_modules.txt

arguments: -J-Xmx2048m -d shell\bin\classes  @"C:\Program Files\B4X\B4J\debug_java_nonui_modules.txt"  -Xmaxerrs 1 -nowarn -Xlint:none  -target 9 -source 9 -version -encoding UTF-8 -cp "C:\Program Files\B4X\B4J\libraries\jdebugrapid.jar";shell\bin\classes\  shell\src\b4j\example\main.java shell\src\b4j\example\main_subs_0.java

JDK 19:
B4X:
B4J Version: 10.50 BETA #1
Parsing code.    (0.00s)
    Java Version: 19
Building folders structure.    (0.01s)
Compiling code.    (0.00s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    (1.02s)
Compiling debugger engine code.    Error
error: file not found: C:\Program Files\B4X\B4J\debug_java_nonui_modules.txt

arguments: -J-Xmx2048m -d shell\bin\classes  @"C:\Program Files\B4X\B4J\debug_java_nonui_modules.txt"  -Xmaxerrs 1 -nowarn -Xlint:none  -target 9 -source 9 -version -encoding UTF-8 -cp "C:\Program Files\B4X\B4J\libraries\jdebugrapid.jar";shell\bin\classes\  shell\src\b4j\example\main.java shell\src\b4j\example\main_subs_0.java


Tip: press Ctrl + R to export IDE state for AI assistants.

B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
   
End Sub

Sub AppStart (Args() As String)
    RunTest
End Sub

Sub RunTest
    Dim products As List
    products.Initialize
    products.Add(CreateMap("id": 1, "name": "Unitree Go2", "price": 2800, "made": "China"))
    Dim res As Map = CreateMap()
    res.Put("m", "Product added successfully")
    res.Put("a", 201)
    res.Put("s", "ok")
    res.Put("t", "application/xml")
    res.Put("e", Null)
    res.Put("r", products)
    Dim json As String = res.As(JSON).ToString
    Log(json)
End Sub

1772031144437.png
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Well my java inline injector works with it, so I am happy. :)
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
I see it too. The file is missing from the installation. Will be fixed.

You can download the attached file and put it in the installation folder.
just coppied it and worked...

is it possible to have codesync=true without additional .jar... just click and read .b4j file / refresh modules? and how? Thanks in advance!
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I see it too. The file is missing from the installation. Will be fixed.

You can download the attached file and put it in the installation folder.
Yes, it works now.

Json v1.21 (B4J v10.30)
B4X:
Waiting for debugger to connect...
Program started.
{
    "a": 201,
    "r": [
        {
            "price": 2800,
            "made": "China",
            "name": "Unitree Go2",
            "id": 1
        }
    ],
    "s": "ok",
    "t": "application\/xml",
    "e": null,
    "m": "Product added successfully"
}

Json v1.30
B4X:
Waiting for debugger to connect...
Program started.
{
    "m": "Product added successfully",
    "a": 201,
    "s": "ok",
    "t": "application\/xml",
    "e": null,
    "r": [
        {
            "id": 1,
            "name": "Unitree Go2",
            "price": 2800,
            "made": "China"
        }
    ]
}
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
is it possible to have codesync=true without additional .jar... just click and read .b4j file / refresh modules? and how?
B4X:
#Macro: Title, Refresh all, ide://run?File=null&librariesrefresh=True&codesync=True&cleanproject=True
From Erel's answer.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
a simple example/tutorial of the procedure for a given AI assistant, with a little demo of a sample of query would be nice.
How to use:
- Click on Ctrl + R. A json file will be created and copied to the clipboard. Paste into the AI assistant and ask questions.

or click on menu Project -> Export State (code bundle)

1772046138810.png


Zip both the generated json files inside Objects folder or just upload the <project-name>.json file.

1772046666913.png


Gemini allows upload for zip file.
Other AI chatbot like DeepSeek doesn't support zip file but support json file.
1772046757607.png


It depends on your prompt engineering skill.
Type your question and hit the Send button.
1772046865140.png
 
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hello Erel, thank you for the new release :cool:

Code bundle is working just like previously.

None coding test:
I uploaded the JSON to Gemini from my nearly production ready professinal business desktop aoftware (37k+ lines of code in the B4J project), and I had a full on voice conversation with Gemini about the solution.

The text you see below, is the words from the Gemini voice that I can hear. This was part of a five minutes conversation that also included questions and answers and also tell me about session on how the fully integrated invoice, quote, stock control, contact management, purchasing, bookkeeping, sales modules, faults, and returns screens all work together. Gemini also talked about how how the software can help small to medium sized businesses to run smoothly and efficiently, thus helping staff to be more productive. Gemini just kept going which I was surprised about.

The information in the JSON file really is fully loaded Erel, congratulations on such a great. At one point it was even giving me basic direction (about 70% correct) on how to created invoices, including clicking on the new and saved buttons 😲, impressive.

A Gemini conversation with myself that lasted about 5 minutes or so. Onlookers must have thought that I was going mad or something like that, as I was chatting away to my phone, and it was talking back to me, like KITT lol 🤣
1000092660.png


The next things I asked Gemini to do via the JSON file, was to create a podcast about the software between two people, Gemini did that task with east. Here is part of the chat that I listened too between virtual Sarah and Jake. Using the information in the JSON file, Sarah and Jake had an extremely long conversation regarding my business software. They even talked about the sales, purchases and debt charts, as well as other key features.
1000092662.png

1000092663.png

1000092664.png

I just listened and listened and listened to their conversation, it was actually interesting to me.

I didn't even have time to ask Gemini to find any bugs, or to debug anything issues (as I've not seen any myself). I thought to myself what else could I do apart from asking it about code issues what don't really exist.

Tomorrow, I'll switch over to Copilot to see how that a fares.

Very impressive:
I'm more than sure that this feature will come in handy for developers. Not only for the simple tasks like what I've done above, but also for serious diagnostics, finding solutions to developers problems like hopefully debugging issues, asking IA about missing features or what would be good to add to solutions, plus other helpful features that I'm more than sure B4X developers like @aeric, @Magma, @Alessandro71 et al will find extremely useful. I can see developers posting hint on what they use code bundle for, which could in fact be a thread all by itself).

Anyway Erel, this is an excellent feature that I will definitely be exploring in more detail.


Thank you Erel...
 
Last edited:
Upvote 0
Top