Markdown Verification with TTSR
Relevant source files
The following files were used as context for generating this wiki page:
Markdown Verification with TTSR (Textual Testing and Scanning Resources) is a quality assurance process within the oh-my-pi-plugin-morph repository designed to ensure that documentation and formatting rules are strictly followed. It specifically targets Markdown files to prevent common formatting issues, known as "AI formatting tells," which can block edits or degrade documentation quality.
The system relies on external scanning tools and internal configuration to enforce a "Release Discipline" for the plugin. This discipline ensures that any changes to Markdown files, particularly those in the docs directory or the repository root, are verified against a set of programmatic rules before being committed or pushed to the repository.
Sources: AGENTS.md:3-8, AGENTS.md:34-40
Architecture and Execution
The verification process is bifurcated based on the location of the Markdown files. Files located within the docs directory undergo a direct JSON-based scan, while root-level files like README.md or CHANGELOG.md require a filtered root scan to ensure maximum coverage of formatting rules.
Verification Workflows
The workflow differs significantly for documentation inside the specialized docs folder versus high-level repository documentation.
The diagram above illustrates the decision logic used to select the appropriate TTSR scan method based on the file's location in the repository.
Sources: AGENTS.md:34-40
Key Verification Rules
The project defines specific rules for managing Markdown and project metadata to maintain consistency across versions:
| Category | Rule | Justification |
|---|---|---|
| Release Discipline | Bump package.json version and src/config.ts PLUGIN_VERSION together. | Ensures metadata and runtime constants match. |
| Changelog | Cut CHANGELOG.md from [Unreleased] to a dated heading for the version. | Adheres to "Keep a Changelog" and Semantic Versioning. |
| Formatting | Filter root scans specifically for md-ai-formatting-tells. | Prevents specific formatting errors that have previously blocked edits. |
Sources: AGENTS.md:3-8, AGENTS.md:38-40
Implementation Details
The verification process is supported by runtime constants and specialized formatting utilities that ensure data integrity, particularly when dealing with "lazy" Markdown markers used by the Morph AI.
Markdown Normalization
The system includes logic to normalize Markdown input, specifically handling code fences. This ensures that when tools like fast_edit receive Markdown-wrapped code, the content is correctly extracted for processing.
export function normalizeCodeEditInput(codeEdit: string): string {
const trimmed = codeEdit.trim();
const lines = trimmed.split("\n");
if (lines.length < 3) return codeEdit;
const firstLine = lines[0];
const lastLine = lines[lines.length - 1];
if (/^```[\w-]*$/.test(firstLine) && /^```$/.test(lastLine)) {
return lines.slice(1, -1).join("\n");
}
return codeEdit;
}
Implementation of Markdown fence removal to extract raw code for AI processing.
Sources: src/format.ts:11-25, test/morph.test.ts:182-185
Verification Gates
Before code or documentation changes are accepted, they must pass through specific "gates" exposed by package scripts:
- Code Changes:
bun run typecheckandbun test ./test. - Documentation Changes: The TTSR scans described in the execution section.
The project explicitly avoids "inventing" lint scripts that are not natively exposed in package.json to prevent creating false process overhead.
Sources: AGENTS.md:29-32
Data Integrity and Safety
Verification with TTSR also encompasses the prevention of "Marker Leakage" and "Catastrophic Truncation." These are specific failures where the AI might return Markdown markers as literal text or delete significant portions of a file unintentionally.
Safety Check Logic
The sequence diagram shows the safety gate process that occurs before any file system mutation.
| Check Type | Description | Threshold/Trigger |
|---|---|---|
| Marker Leakage | Detects if placeholder text (// ... existing code ...) exists in the output. | Triggered if original lacked markers but merged contains them. |
| Catastrophic Truncation | Detects if the AI accidentally deleted a large portion of the file. | Triggered if char loss > 60% AND line loss > 50%. |
Sources: src/format.ts:110-137, src/config.ts:18
Summary
Markdown Verification with TTSR in the oh-my-pi-plugin-morph project serves as a critical quality control layer. By combining strict release disciplines, specific scanning commands for different directory levels, and programmatic safety checks for AI-generated Markdown, the system ensures that documentation remains clean and that automated edits do not introduce formatting errors or data loss. This comprehensive approach maintains the integrity of the project's documentation and source files during the rapid iteration cycles facilitated by the Morph AI tools.
Sources: AGENTS.md:3-8, AGENTS.md:34-40, README.md:46-52