Skip to main content

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

Metadata

Release files for justbuild 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for justbuild 0.3.2
File Size Uploaded Provenance Actions
justbuild-0.3.2.tar.gz 19.7 kB Without provenance Details for justbuild-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for justbuild 0.3.2
File Interpreter ABI Platform Actions
justbuild-0.3.2-py3-none-any.whl Python 3 none any Details for justbuild-0.3.2-py3-none-any.whl

Total release size: 41.9 kB

Release files / justbuild-0.3.2.tar.gz

Download URL justbuild-0.3.2.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
76646cad88c8512203b9c3095775648685138fe23cc90e78bcd17b1fb60af1a2
BLAKE2b-256 checksum
How to use checksums
51c28777dde7cb3e640eb59992d57fa55493e720cc65673884c59a05e384ff88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / justbuild-0.3.2-py3-none-any.whl

Download URL justbuild-0.3.2-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bc64cb33d337ceda0d598779a244231af74e1ff37488672e1d0d63fa5c18ab5
BLAKE2b-256 checksum
How to use checksums
4d97acc477afa2171d1708cddf5ae085a60b3471a107e4e0a3ec46f0f8b1ddba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Security for justbuild 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page