After seeing Thorsten Ball at RegisterSpill talk about AI tools and how other great programmers use them, I figured I should give AI code generators a proper shot.
My use of AI so far has been limited to support problems and getting solutions to try to a problem. This is useful when I have already tried googling and haven't found anything relevant.
I would have preferred to run my own local AI but as I am going to be trying to give AI the best chance, I'm willing to spend some money on this little experiment. Luckily Copilot currently has a free tier and so I could try that before I upgrade.
I am also not going to try to bend the tooling to my way of thinking and will instead try it the way it was design which means that I may end up using vscode. There is support for vim and various other editors but I have a feeling vscode might be getting the lions share of dev time.
I set up Copilot.vim which was straightforward. I use pathogen to manage my plugins and so I simply did a git clone into my bundle folder.
git clone https://github.com/github/copilot.vim.git ~/.vim/bundle/copilot.vim
I then did :Copilot setup
to trigger the setup. This generated a special code and then opened the web browser. I entered the code and that seemed to connect my github account to the copilot.vim plugin.
I was then able to start seeing AI completions which was actually pretty cool. Typing something would show me the suggested completion in a faded out gray.
I figured the best way of using it might be to write a comment and see if copilot would generate what I wanted. Then I could use that as a base to build off of. I ran into a hiccup here as copilot was trying to finish my comment for me. This was annoying as I'm trying to get my thought down and the suggestion is now interfering with my own thought process. I'll need to fix this. (I get that this is coming the heels of "not going to bend my tools")
With Copilot installed and working, I set about writing a small bash script to help me navigate sveltekit files. Sveltekit runs into a nesting problem where there are many levels for routes and there are special names for various files. Query parameters also infect the folder structure. All these things make navigating and opening files with vim a pain in the ass.
I want to do open login server
and this should find a login route and then open +page.server.js
. If I did open item/id/ svelte
, I want this to open some path that roughly matches and then the +page.svelte
file.
There is probably something off the shelf available but I didn't want to look.
I set up a header comment and began using copilot to build out the code. It started out pretty promising with various error checks and then it started using regexes to find matches.
I realized pretty quickly that this path wasn't working. It wasn't doing any fuzzy matching and was just looking for substrings. I tried to get it to be more dynamic but that didn't go anywhere. After 15 minutes, I gave up and searched stackoverflow and found 2 line answer that I could build something off.
#!/usr/bin/env bash
ARGS="$@"
IFS=$'\n' files=($(fzf-tmux --query="$ARGS" --multi --select-1 --exit-0))
if [[ -n "$files" ]]; then
read -p "$files === " ans
if [[ "$ans" == "q" ]]; then
exit 0
fi
vim "${files[@]}"
fi
Ideally I would have gotten this from Copilot and then I could add in extra things like error checking.
I'm not going to hold it against Copilot for this attempt as I am bad at prompting and will likely need to spend some time getting the right idea. It would also probably help if I did a cursory google search before jumping into it.
For the next experiment, I'll need to save my prompt and the code Copilot generated as I could probably learn from that.
The key thing that using Copilot gave me was that it gives me straight code instead of explanations and premable. I'm curious how they got the AI to only give out code as so far all the models besides Claude seem to always have some sort of preamble. It could be that github is cleaning up the data in a post processing step.
This one feature alone is already pretty cool. The other thing to note is that completion suggestions do take a hot second to come through. Not painful but I can see this being getting worse.
I haven't figured out if there is a way to try and force a completion. Pressing enter is supposed to trigger the next completion but sometimes Copilot doesn't seem to run but will if I type a character. I'm not sure what the rules are about when it tries to generate the next line or chunk of code.
I also need to see how many completions I ended up using. The free tier has 2000 completions and having it generate a small bash script already would have eaten up 10 of them possibly.
I started to notice the spark symbol was being used for AI all over the place. It had never registered before. It has actually been the main symbol for AI for awhile now.
Here is a medium article going over the symbol and the possible origin of it. It highlights that the spark originally meant cleanliness and polish. Google would then use the symbol for their enhance buttons where photos were cleaned up. This would evolve to mean AI over time. Interesting that it shifted from being clean, to enhance, and now to innovation and magic.