Package org.machanism.machai.gw.reviewer
A Reviewer is a format adapter: it recognizes the guidance
convention supported by a file type, reads the candidate file as UTF-8,
computes project-relative context when required by the prompt format, and
returns a localized prompt fragment. A file that does not contain guidance
for the adapter is represented by null; I/O failures are propagated
as IOException.
Reviewer is the package's service-provider interface. Its
perform operation
receives the project root and candidate file. Implementations advertise the
extensions they can inspect through
Reviewer.getSupportedFileExtensions(); the caller chooses an
appropriate reviewer and decides how non-null prompt fragments are
ordered and submitted. Extension matching alone does not replace each
reviewer's format-specific guidance detection.
The concrete reviewers combine format detection with prompt construction as follows:
JavaReviewerhandles Java comments and givespackage-info.javapackage-level treatment by returning the package-info prompt without its complete source content. Other matching Java files contribute their complete UTF-8 source content.HtmlReviewerhandles HTML and XML comment blocks and includes the complete UTF-8 source in its prompt.MarkdownReviewerhandles guidance in Markdown HTML comments and includes the complete UTF-8 document in its prompt.PythonReviewerhandles guidance in Python line comments and triple-quoted strings, returning the extracted non-blank guidance text.TypeScriptReviewerhandles guidance in TypeScript line and block comments, returning the extracted non-blank guidance text.PumlReviewerhandles PlantUML files containing the guidance tag and includes the complete UTF-8 document in its prompt.TextReviewerhandles only files named@guidance.txtand formats their complete text with the containing directory's context.
All reviewers use the document-prompts resource bundle to create
localized results; the bundle keys and argument order are format-specific.
Callers should therefore treat each returned string as an opaque prompt
fragment rather than depending on its presentation. The reviewers do not
traverse directories, register themselves, or submit prompts.
A caller can select a reviewer by extension, invoke it with the project
directory and candidate file, and forward a non-null result:
File projectDirectory = new File(".");
File sourceFile = new File(projectDirectory, "src/main/java/Example.java");
Reviewer reviewer = new JavaReviewer();
String prompt = reviewer.perform(projectDirectory, sourceFile);
if (prompt != null) {
promptPipeline.accept(prompt);
}
In the example, promptPipeline represents an application-owned
consumer; production code can select a reviewer by checking the extension
returned by Reviewer.getSupportedFileExtensions() and can provide a
different reviewer for each supported format. Additional
Reviewer implementations can consequently be introduced without
changing this package contract.
-
ClassDescription
Reviewerimplementation for Java source files (.java).Reviewerimplementation for Markdown files (.md).Reviewer implementation for PlantUML files (.puml).Reviewerimplementation for Python source files (.py).Service-provider interface (SPI) for components that scan project files and extract@guidanceinstructions for downstream processing.Reviewer implementation for generic guidance text files.Reviewerimplementation for TypeScript source files (.ts).