Mutation and gauge theory I: Yang-Mills invariants