AI-Powered Programming — A little help

VXRL
3 min readJul 12, 2024

--

AI tools like ChatGPT, Claude 3.5 Sonnet are excellent programming assistance. However, long conversations can lead to browser memory crashes and message limits, disrupting the workflow. To tackle this, I’ve developed a script that consolidates all source files in a folder into a single text file, preserving context for new chat sessions.

The Problem: Memory Crashes and Message Limits

AI chat tools provide detailed responses for complex queries, but lengthy conversations can cause browser memory crashes and encounter response length limits. Starting new chats can result in loss of context and progress.

A little help

To preserve context, this script exports all source files in a specified folder into a single text file. The script scans the folder for source files, such as .py, .js, and .java, reads the content of each file, consolidates it, and saves it into a single text file. This ensures all relevant information is available in one place, ready for a new AI chat session.

The script is available on GitHub: https://github.com/alanh0vx/Files2Txt

sample results

Using the Consolidated Text File

To use the consolidated text file, start a new AI chat session. Copy and paste the content of the text file into the chat, or upload the file if the AI tool supports it. The AI will use the provided context to continue assisting you from where the previous session left off.

Continue without losing the context

Limitations and Precautions

If the project directory is too large, the script may take a long time to execute and the output file may become very large, potentially causing performance issues or exceeding file size limits.

The script reads all specified files into memory, which could lead to high memory usage for very large files or many files.

If you plan to use the output file with an AI service, be aware of token or character limits imposed by the AI provider, as exceeding these limits could result in truncated responses or errors.

To optimize performance, add any other large or unnecessary directories to the ignore_dirs list in the config.yml file.

Conclusion

While AI tools like ChatGPT are incredibly useful, they have limitations such as memory crashes and message limits. Exporting source files into a single text file helps overcome these issues by preserving context, ensuring a seamless transition between sessions, and enhancing productivity. Additionally, incorporating tools like GitHub Copilot, collaborating with experienced programmers through pair programming, and utilizing robust debugging tools and practices can further improve your coding efficiency. By combining these strategies, you can experience a smoother, more effective AI-assisted programming workflow. Try this method to see the benefits for yourself!

--

--

VXRL
VXRL

Written by VXRL

VXRL Team is founded by group of enthusiastic security researchers, providing information security services and contribute to the community. https://www.vxrl.hk