Repository navigation
Description
Description
The /annotate command rejects .yaml, .yml, .json, .toml, and many other plain-text file formats with the error:
Only .md, .mdx, .txt, .html, .htm files are supported.
These are all plain text files that the annotation engine can handle just fine — the restriction is purely an extension whitelist in the code, not a technical limitation.
Root cause
Two places in index.ts restrict which files can be annotated:
1. File type guard (line ~587):
} else {
if (!/\.(mdx?|txt)$/i.test(absolutePath)) {
ctx.ui.notify("Only .md, .mdx, .txt, .html, .htm files are supported.", "error");
return;
}
markdown = readFileSync(absolutePath, "utf-8");
}This is the catch-all else block — after checking for folders and HTML files, it rejects anything that is not .md, .mdx, or .txt.
2. Folder scanner (line ~566):
if (!hasMarkdownFiles(absolutePath, FILE_BROWSER_EXCLUDED, /\.(mdx?|txt|html?)$/i)) {
ctx.ui.notify(`No markdown, text, or HTML files found in ${absolutePath}`, "error");Folder annotation also limits discovery to the same narrow set.
Affected file types
Text-based files that are unnecessarily rejected:
.yaml,.yml— YAML configs, CI/CD, OpenAPI specs.json,.jsonc,.json5— JSON configs, package.json, tsconfig.toml— pyproject.toml, Cargo.toml, ruff.toml.xml,.svg— XML configs, Maven POMs.ini,.cfg,.conf— INI-style configs.env,.env.example— environment files.css,.scss,.less— stylesheets.js,.jsx,.ts,.tsx— source code (comments as annotations).py,.rs,.go,.java,.rb,.php,.sh,.bash— any source codeDockerfile,Makefile,.gitignore, etc.
Why it matters
The annotation system uses startMarkdownAnnotationSession with plain text content read via readFileSync(absolutePath, "utf-8"). It works with any UTF-8 text — the annotator renders text and lets the user place annotations on it. There is no markdown-specific processing done on the content; it is sent as-is to the annotation UI.
Suggested fix
Option A (conservative): Expand the regex to include common text-based config and code formats:
/\.(mdx?|txt|ya?ml|jsonc?|json5|toml|xml|cfg|ini|conf|env|css|s[ac]ss|less|[jt]sx?|py|rs|go|java|rb|php|sh|bash|zsh)$/iOption B (permissive): Allow any file that is readable as UTF-8 text and not explicitly excluded (e.g., not binary). This would handle Dockerfile, Makefile, .gitignore, and any future text format without manual whitelist updates:
const isTextFile = (path: string): boolean => {
const buf = readFileSync(path);
// Skip binary files (null bytes in first 8KB)
return !buf.subarray(0, Math.min(buf.length, 8192)).includes(0);
};Steps to reproduce
- Open a Pi session with plannotator extension active
- Try
/annotate some-file.yaml - See error: "Only .md, .mdx, .txt, .html, .htm files are supported."
Diagnostics
- plannotator version: 0.22.0
- File location:
index.tslines ~566 and ~587 - Package:
@plannotator/pi-extension - Repository:
backnotprop/plannotator, pathapps/pi-extension
Activity
feat: annotate accepts YAML, JSON, TOML and other plain-text files (b…
chore: upgrade to upstream 0.24.2 (#12)