NoFAQ: Synthesizing Command Repairs from Examples

Loris D'Antoni, Rishabh Singh, Michael Vaughn · DOI

Abstract

The command-line interface (CLI) remains a primary tool for developers, yet it often presents cryptic error messages that impede productivity. Existing solutions like TheFuck rely on manually authored Python scripts to provide fixes, creating a maintenance bottleneck. We present NoFAQ, a tool that leverages Programming by Example (PBE) to automatically synthesize repair rules. By utilizing a specialized Domain-Specific Language (DSL) called FIXIT and a novel Lazy Version-Space Algebra (VSA) algorithm, NoFAQ can generate robust repair rules from as few as two examples in polynomial time. Our evaluation on 92 benchmarks shows an 88% success rate, demonstrating that NoFAQ can effectively automate CLI troubleshooting.

1. Introduction

The Command-Line Interface (CLI) is a powerful but often cryptic environment. When a command fails, users are frequently met with verbose, text-based error messages that require significant effort to decipher. While tools like TheFuck (referred to in research as THEFXXX) attempt to alleviate this by providing a library of hard-coded Python scripts for common errors, they suffer from a major bottleneck: every new repair rule must be manually written and debugged by a developer.

NoFAQ addresses this by enabling Programming by Example (PBE) for CLI repairs. Instead of writing code, a user provides a few "before and after" examples of a buggy command and its fix. NoFAQ then automatically synthesizes a permanent repair rule that can be applied to future instances of the error.

2. The FIXIT DSL

At the core of NoFAQ is FIXIT, a declarative Domain-Specific Language designed specifically for command repairs. A FIXIT rule consists of three primary components: a pattern to match the buggy command, a pattern to match the error message, and a transformation that produces the fixed command using variables extracted from the first two patterns.

The FIXIT DSL syntax defines the structure of repair rules, including match expressions and position expressions.

By treating the error message as a first-class input, FIXIT allows rules to be context-aware. For instance, a rule can extract a suggested package name directly from a "command not found" error string to suggest an installation command.

3. Lazy VSA Synthesis

Standard synthesis techniques often face "state explosion," where the search space for possible programs grows exponentially. NoFAQ introduces a Lazy Version-Space Algebra (VSA) algorithm to maintain efficiency.

Unlike "eager" methods that explore all possible generalizations immediately, the lazy approach initially treats every part of a rule as a constant. The algorithm only "promotes" a constant to a variable or a substring operation when a new example contradicts the existing constant. This ensures the synthesis process remains within polynomial time complexity, allowing for real-time rule generation.

An example of lazy synthesis: the algorithm generalizes a constant string to a variable match when presented with a new example.

4. Evaluation and Results

The authors evaluated NoFAQ on a benchmark suite of 92 problems, including 76 rules reverse-engineered from TheFuck and 16 gathered from online help forums (e.g., git, svn, mvn).

Key findings include:

  • High Success Rate: NoFAQ successfully synthesized rules for 81 out of 92 benchmarks (88%).
  • Data Efficiency: Most rules required only 2 to 5 examples to reach a stable, correct state.
  • Performance: The tool operates in milliseconds. In scaling tests, the Lazy VSA approach remained stable while traditional methods timed out as the number of examples increased.
  • Robustness: Synthesized rules were often more precise than manual ones, capturing the exact relationship between command fragments and error strings.

5. Conclusion and Future Work

NoFAQ demonstrates that complex CLI repair logic can be automated through example-based synthesis. While highly effective, the system currently has limitations regarding complex internal logic (e.g., repeating tokens) and context blindness (e.g., file system state not present in the error message). Future work aims to implement unsupervised learning, where NoFAQ "lurks" in the shell to learn repairs automatically by observing user corrections in real-time.

Summary updated

BibTeX
@inproceedings{dantoni2016nofaq,
  author = {Loris D'Antoni and Rishabh Singh and Michael Vaughn},
  title = {{NoFAQ: Synthesizing Command Repairs from Examples}},
  booktitle = {ESEC/SIGSOFT FSE},
  year = {2016},
  doi = {10.1145/3106237.3106241},
}
Figure