Skip to main content

Chat Assisted Programming Tools

Project description

LFG! Tools for better Chat Assisted Programming

We all use ChatGPT, Claude, Copilot, or others to us all more productive programmers. However, the workflow has a lot of jank™ doesn't it? This little program tries to smooth the experience for all of us.

"Buy Me A Coffee"

Problem 1: Code Sections Missing in the chat

I hate it when we are writing code with ChatGPT or the Claude Artifacts and suddenly we get the annoying

// ... (rest of the previous code remains the same)

Suddenly we have either beg or threaten the LLM to give us the full code or else I'll lose my job!. This takes extra time and money and is not ideal; I like to code in a relaxed way and this sortof kills my vibe.

Alternatively, we are manually copy-pasting blocks of code inside our several hundred line programs. This breaks me out of the higher-level conversational state I was in when talking with the LLM, and now I am stuck in syntax hell as I jump around the file trying to make sure I didn't drop an import or miss a couple lines of code. It honestly kills the magic of these LLMs and makes me feel like a junior dev again.

On the plus side, these comments make the LLM's responses faster and keeps the context windows smaller, thus keeping the accuracy high and costs lower.

So let's embrace the comments and solve this with a little tooling. The solution:

# First, copy the new code to the clipboard (with the // Code remains the same blocks)
lfg paste ./dope_new_program.py

This will paste the new code into your file, and will try to keep as much of the old code as it can.

Also if you copied the new code already into your file in your IDE, you can just run:

# Run for the whole repo and compare against the last commit
lfg merge

# Or run for a specific file
lfg merge old_file.py new_code_from_llm_with_missing_sections.py

This looks at git diff and reverts all code blocks where good code was replaced with these // Code Was Here blocks.

Usage within AI Agents

If you are building AI Agents, CoPilots or other automated code generation tools, you can use this tool to help you manage the code that is generated by the LLMs. This way you can keep the code clean and the diffs small and manageable.

# TODO python example of using lfg
import lfg
from lfg import merge_code

Other Problems?

I'd love to know about them! Raise an issue or DM me @seankruzel Let's go make the Chat Assisted Programming experience better!

So why is this needed?

Using Language Models to write code is pretty effective, but ultimately it's not quite the right tool for the job. Since these models don't think about code the same way we do, or even the same way computers view code,

Take this python code example:

TODO write a small two-function multi-step example with a loop

If you're like me, you might read this code and view it in a functional way:

TODO insert flow chart

If you are the python compiler you might view it as an Abstract Syntax Tree

TODO insert tree viz

However if you are a language model, you view it as a linear set of tokens where every couple of characters is replaced by a different integer and stored as an array of numbers

TODO insert a token visualization of the code

So as a result we can have a lot of information lost in translation if we intuitively understand the task as a Graph and have to communicate it in words that are translated into an Array which are then copy-pasted into python code to be compiled into a Tree. It's all quite messy.

In reality when we write code, we incrementally build out functionality so that the code slowly matches our mental model and implements the functions we desire. The compiler views our progress as us jumping around the AST and modifying edges, adding / removing nodes etc.

However there is another program on your computer that sees the world in a similar way to the LLM: git

Version Control to the Rescue

git and other version control systems just see line changes, they do not see syntax trees and so we can observe local changes to the file. git diff just shows us what changed locally and we can reason whether we wanted to delete the code, or whether the code was omitted for brevity by the LLM.

For now lfg paste and lfg merge are wrappers around this git diff view into the code to help us better manage the coding experience.

Other Projects

LFG is a sister project of autocomplete.sh. Definitely check it out if you are new to linux and are learning the magic of the Terminal or if you are a DevOps professional and want to use --help less and get more done.

License

MIT License - ClosedLoop Technologies, Copyright 2024 - All rights reserved

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

justbuild-0.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

justbuild-0.1.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file justbuild-0.1.0.tar.gz.

File metadata

  • Download URL: justbuild-0.1.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.4

File hashes

Hashes for justbuild-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9769c03970e21153a100e01625ef7cd2073545603e99c10a1906446bb6c08b05
MD5 68df38ec60aaf7196a05ea491d285ae0
BLAKE2b-256 1d7c4c94efa9aba388dd2fd548b18ee53761a77c08206a6f52e5178078d0a90b

See more details on using hashes here.

File details

Details for the file justbuild-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: justbuild-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.4

File hashes

Hashes for justbuild-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2bee47c04b392a2963e3e70a18f8fe66842e03dbdefdc4a6ab2e59452bac4d2
MD5 ea25d0de65b7fb3eb58262b946c1e51f
BLAKE2b-256 595787a3de55618e41a6e2d6e5e665f0c3e211f95195fcb7c78d2de78cc8e1b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page