AI-MarkDone
Copilot instructions193 starsChanged 9 months agoMITView on GitHub
Critical: Math formulas are handled by Turndown rules that extract LaTeX from <annotation encoding="application/x-tex"> tags. Extension loading: Load dist/ folder (not root) in chrome://extensions/ with Developer Mode enabled. Vite config: Uses rollupOptions.input to create separate content.js and background.js bundles (no @crxjs plugin).
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this copilot-instructions.md into the rules it gives an agent
9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
All UI components: use Shadow DOM to avoid CSS conflicts with host pages
- Very specific: line 73
Use logger.debug() for detailed traces, logger.info() for major events
- Very specific: line 77
Comments: Follow .agent/rules/commenting.md (prefer Why/constraints + public API JSDoc.
- Very specific: line 78
Shadow DOM components: Always create shadowRoot, inject styles first, then HTML
- Distinctive: line 81
SVG icons: Use inline SVG with stroke (not fill) for consistency
- Very specific: line 93
Create src/content/adapters/newplatform.ts extending SiteAdapter
- Distinctive: line 100
Use placeholder pattern if conflicts with Turndown
- Very specific: line 103
Update src/components/*.ts (Shadow DOM creation)
- Distinctive: line 105
Test style isolation on actual ChatGPT/Gemini pages
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Copy Enhance - AI Coding Agent Instructions
Project Overview
Chrome Extension (Manifest V3) that enhances ChatGPT/Gemini with robust Markdown export. Extracts LaTeX from KaTeX, handles rendering failures, converts tables/code to Markdown, and provides click-to-copy math formulas.
Architecture Patterns
Adapter Pattern for Multi-Platform Support
- Registry:
src/content/adapters/registry.tsmanages platform adapters - Base:
SiteAdapterabstract class defines interface (selectors, HTML extraction, streaming detection) - Implementations:
ChatGPTAdapter,GeminiAdapter(each 100 lines) - Critical: New platforms extend
SiteAdapterand register inAdapterRegistryconstructor - Adapters provide DOM selectors specific to each platform's structure
Shadow DOM Isolation
- All UI components use Shadow DOM to avoid CSS conflicts with host pages
- See
src/content/components/toolbar.ts,modal.ts- each creates shadow root and injects styles - Styles defined in
src/styles/*.css.tsas template literals for Shadow DOM injection - Toolbar: Icon-only buttons with hover tooltips, auto-updating word/char count on right
- Never use global CSS - it won't reach Shadow DOM components
Parser Pipeline Architecture
MarkdownParser orchestrates specialized extractors in sequence:
- CodeExtractor:
<pre><code>→ fenced code blocks with language tags - TableParser: HTML tables → Markdown pipes
- Turndown: HTML → Markdown (with custom rules for KaTeX)
- Post-processing: Cleanup and normalization
Critical: Math formulas are handled by Turndown rules that extract LaTeX from <annotation encoding="application/x-tex"> tags.
MutationObserver Pattern
src/observers/mutation-observer.tswatches for new messages with 200ms debounce- Uses
WeakSetto track processed messages (avoid duplicate toolbars) - Container selection: tries multiple selectors (
main,main > div, etc.) - seegetObserverContainer()
Build & Development Workflow
npm run dev # Vite HMR (reload extension manually in chrome://extensions/)
npm run build # Build to dist/ (postbuild copies manifest + icons)
npm run type-check # TypeScript validationExtension loading: Load dist/ folder (not root) in chrome://extensions/ with Developer Mode enabled.
Vite config: Uses rollupOptions.input to create separate content.js and background.js bundles (no @crxjs plugin).
Critical Implementation Details
Math Handling
- Turndown Rules: Custom rules for
.katex-display(block) and.katex(inline)- Structure:
<span class="katex-display"><span class="katex">...</span></span> - Block rule processes
.katex-display, inline rule processes.katex(not inside display)
- Structure:
- LaTeX Extraction: From
<annotation encoding="application/x-tex">tags - Cleaning: Simple whitespace normalization:
replace(/\s+/g, ' ') - Output:
$inline$and$$\nblock\n$$for Typora compatibility - Fallback:
MathExtractorhandles raw\[...\],\(...\)patterns (ChatGPT-Fail scenario) - Click-to-copy:
MathClickHandleradds listeners to.katexelements
Deep Research Messages
- Detected by
isDeepResearch()- checks for nested<article>tags - Custom recursive parser extracts headings/paragraphs from each
<article> - See
parseDeepResearch()inmarkdown-parser.ts
Word Count (CJK vs Latin)
WordCountercounts CJK characters separately from Latin words- Excludes code blocks and math formulas from count
- Uses Unicode ranges:
\u4e00-\u9fa5(Chinese),\u3040-\u30ff(Japanese),\uac00-\ud7af(Korean)
Logging
- Set level in
src/content/index.tsconstructor:logger.setLevel(LogLevel.DEBUG) - Prefix:
[CopyLLM] - Use
logger.debug()for detailed traces,logger.info()for major events
Coding Conventions
- TypeScript: Strict mode, explicit return types on public methods
- Comments: Follow
.agent/rules/commenting.md(prefer Why/constraints + public API JSDoc; avoid “what” comments) - Shadow DOM components: Always create
shadowRoot, inject styles first, then HTML - Adapter methods: Return
nullwhen element not found (defensive programming) - Cloning before parsing: Clone DOM elements before modification (see
parse()method) - SVG icons: Use inline SVG with stroke (not fill) for consistency
- Placeholder pattern: Math/code use placeholders during Turndown, then restore (see
MathExtractor.generatePlaceholder())
Testing Scenarios
Reference HTML files in root (ChatGPT-Success.html, ChatGPT-Fail.html, ChatGPT-DeepResearch.html) show:
- Success: Rendered KaTeX with
data-latex-source - Fail: Raw LaTeX
\[,\(in DOM (test fallback extraction) - DeepResearch: Nested
<article>structures (test recursive parser)
Common Tasks
Add new platform:
- Create
src/content/adapters/newplatform.tsextendingSiteAdapter - Implement all abstract methods (especially selectors)
- Register in
AdapterRegistryconstructor
Add new parser:
- Create in
src/content/parsers/ - Integrate into
MarkdownParser.parse()pipeline (order matters!) - Use placeholder pattern if conflicts with Turndown
Modify UI components:
- Update
src/components/*.ts(Shadow DOM creation) - Update
src/styles/*.css.ts(CSS-in-JS) - Test style isolation on actual ChatGPT/Gemini pages
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

