A few years ago I built a custom OAuth2/IndieAuth provider for my website and a few other things. In the same crate I had a small utility to fetch credentials using the OAuth2 device flow and then pass them into curl. It’s been really helpful for testing and I’ve been meaning to extract it out into its own package so that I can install it independently. The tool doesn’t depend on anything else in the crate, so this seemed like a simple enough task to see how Windsurf worked across packages.

I started with the prompt: “This package contains two executables. One of them is a command line utility called sso. Extract the sso utility into a new rust crate called jesterpm-sso-tools.”

This actually worked pretty well. Windsurf created a new directory, moved the one source file, created a new Cargo.toml file and built the new package. It missed a couple of crates in the new Cargo.toml, but corrected that when the compiler failed. I was happy to see that it didn’t bring over any unneeded dependencies. This took about ~10 minutes, including the time I spent verifying that everything was correct.

When I split a repo I usually like to bring the relevant git history along with it. My typical process is to duplicate the repository, delete everything I don’t want, and then rewrite the history to remove all of the other stuff. Let’s see what Windsurf does if I ask “Could you copy the git history for src/bin/sso/main.rs into the new package?”

Windsurf decided to export each patch for the sso tool and apply them to the new repo. This might have worked reasonably well if it hadn’t already committed the change from the original request. Let’s try to start over: “Reset both the jesterpm-sso and jesterpm-sso-tools crates to their initial state, then move the sso tool from jesterpm-sso into jesterpm-sso-tools. This time, preserve the original commit history for the sso tool.”

I’ll help you reset both repositories and perform the move while preserving history. Let’s do this step by step:

First, let’s reset both repositories:

$ rm -rf /home/jesterpm/dev/windsurf2/jesterpm-sso-tools/.git /home/jesterpm/dev/windsurf2/jesterpm-sso-tools/* && git reset --hard HEAD

Now let’s use git filter-repo to extract the history of the sso tool:

$ git filter-repo --path src/bin/sso/ --path-rename src/bin/sso/:src/bin/sso/ --force

git: 'filter-repo' is not a git command. See 'git --help'.

I see git-filter-repo is not installed. Let’s use a different approach with git filter-branch:

$ mkdir -p /home/jesterpm/dev/windsurf2/jesterpm-sso-tools && cd /home/jesterpm/dev/windsurf2/jesterpm-sso-tools && git init

$ git remote add -f origin /home/jesterpm/dev/windsurf2/jesterpm-sso

$ git checkout -b master origin/master

error: The following untracked working tree files would be overwritten by checkout:
  .gitignore
Please move or remove them before you switch branches.

$ rm .gitignore && git checkout -b master origin/master

$ git filter-branch --prune-empty --subdirectory-filter src/bin/sso/ -- --all

$ mkdir -p src/bin/sso && mv main.rs src/bin/sso/

Now let’s create the necessary files for the new crate:

Created Cargo.toml Created README.md Created .gitignore

$ git add . && git commit -m "Add crate files"

Now let’s remove the sso tool from the original repository:

$ git rm -r src/bin/sso && git commit -m "Move sso tool to jesterpm-sso-tools"

That worked surprising well. I was surprised that it correctly reset jesterpm-sso-tools to an empty directory. Given that it doesn’t usually remember previous changes, I was expecting it to try git reset origin/master. It added the Cargo.toml as the last commit, whereas I would have rebased that to the beginning. Otherwise, no complaints. I’ll go fix these things and this will likely get pushed mostly as-is.

Similar to my last experiment, Windsurf seems to do well with chores that are coding-related, but don’t involve directly writing code. It’s next assignment will be to add a new feature to the SSO tool.

#ai