[library][tool] Refactor replacer tool.