convez.ai
MCP ServerDesenvolvimento WebAvançado
AdrianV101

PretextPlugin

AdrianV101/PretextPlugin

Acesso a medição e layout de texto DOM-free com skills, agent e ferramentas MCP

Ver no GitHub
InicialPluginScore · de 0 a 100

Plugin MCP server que fornece a Claude conhecimento profundo da biblioteca Pretext — uma ferramenta TypeScript pura para medição e layout de texto sem DOM. Inclui 3 skills injetáveis, 1 agent para questões complexas e 5 ferramentas de tempo de execução para validação e debugging de layouts de texto.

Instalação

$npx convez-ai AdrianV101/PretextPlugin

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
42%
Último commit
há 6 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Medir altura de texto e implementar reflow responsivo sem DOM
  • Debugar problemas de medição em diferentes navegadores e scripts (CJK, árabe, tailandês)
  • Desenhar layouts de texto não-retangulares com rendering virtualizado
  • Trabalhar com i18n complexo e validar precisão de medições por locale

Veredito

Plugin especializador bem-arquitetado para um problema específico (medição de texto sem DOM). Excelente para quem trabalha com Pretext, mas nicho — audiência: desenvolvedores de layout e tipografia em web. Implementação sólida com TypeScript, testes e documentação estruturada.

README

A tradução para o português deste README ainda está na fila.

MIT License TypeScript Bun tests pretext

PretextPlugin

A Claude Code plugin that gives Claude deep understanding of pretext — a pure TypeScript library for DOM-free multiline text measurement and layout.

Pretext is too new (March 2026) for LLMs to know. This plugin bridges that gap with injectable skills, an MCP server with 5 runtime tools, and a 12-file curated knowledge base.

How It Works

                      Claude Code
                          |
           +--------------+--------------+
           |              |              |
       Skills (3)    Agent (1)    MCP Server (5 tools)
           |              |              |
           v              v              v
     Context injection  Multi-step   Runtime execution
     on activation      reasoning    & validation
           |              |              |
           +--------------+--------------+
                          |
                   Knowledge Base (12 files)
                   API | Architecture | Scripts
                   Edge Cases | Browser Compat

Skills inject pretext knowledge into Claude's context. The MCP server provides runtime tools for code execution, validation, and documentation lookup. The agent handles complex multi-step questions by combining both.

Quick Start

Install directly from GitHub:

claude plugin marketplace add AdrianV101/PretextPlugin
claude plugin install pretext@pretext-marketplace

Or from a local clone:

git clone https://github.com/AdrianV101/PretextPlugin.git
claude plugin marketplace add ./PretextPlugin
claude plugin install pretext@pretext-marketplace

The same commands work as slash commands inside Claude Code (/plugin marketplace add ..., /plugin install ...).

Once installed, ask Claude about pretext and it will automatically activate the plugin's skills and tools:

"How do I use pretext to measure text height on resize?"

Features

Skills

SkillActivates WhenWhat It Provides
pretextUser asks about pretext APIs, patterns, usageMental model, API decision tree, code patterns, 9 critical pitfalls
pretext-debuggingUser debugs measurement or layout issuesDiagnostic flowchart, mismatch taxonomy, browser-specific fixes
pretext-i18nUser works with non-Latin text (CJK, Arabic, Thai...)Per-script accuracy data, locale configuration, known limitations

Skills activate automatically based on conversation context — no slash commands needed.

Agent

The pretext-advisor agent handles complex architectural questions that span multiple knowledge domains — like designing non-rectangular text wrapping with virtualized rendering, or diagnosing Arabic measurement mismatches across browsers.

MCP Tools

ToolPurposeExample Use
pretext_runExecute text layout, get line count and heightTest layout parameters before writing code
pretext_measureAnalyze text segmentation and per-segment widthsDebug why text wraps at an unexpected point
pretext_validateCheck code for 9 common anti-patternsCatch system-ui font, inlined prepare(), wordBreak/letterSpacing misuse, rich-inline confusion
pretext_explainSearch the knowledge base by topicLook up architecture, browser compat, edge cases
pretext_sourceRead pretext source code by module/functionUnderstand internal behavior

By default, pretext_run and pretext_measure execute in structural mode — a canvas shim provides deterministic width estimates without a real browser, which is fast and reproducible but approximate.

pretext_run

Executes a pretext layout and returns line count and total height. Defaults to structural mode.

Accurate mode (opt-in): Set mode: 'accurate' to run in a real headless browser for pixel-precise font metrics. Useful for debugging cross-browser divergence or shaping-context issues where structural mode's approximate widths diverge from real browsers. Requires Playwright:

bun add playwright
bunx playwright install chromium  # or firefox, or webkit

Select the engine with browser: 'chromium' | 'firefox' | 'webkit' (default: chromium).

pretext_measure

Returns per-segment widths and segmentation details for a given text/font. Defaults to structural mode (canvas shim).

Accurate mode (opt-in): Set mode: 'accurate' to run in a real headless browser for pixel-precise font metrics. Useful for debugging cross-browser divergence or shaping-context issues where structural mode's approximate widths diverge from real browsers. Requires Playwright:

bun add playwright
bunx playwright install chromium  # or firefox, or webkit

Select the engine with browser: 'chromium' | 'firefox' | 'webkit' (default: chromium).

Knowledge Base

12 curated reference files covering pretext's full surface area, served to Claude via the pretext_explain tool:

  • api-reference.md — Complete API signatures and types
  • architecture.md — Two-phase design, internal data structures, caching
  • common-mistakes.md — Anti-patterns with detection and fixes
  • mismatch-taxonomy.md — Why pretext/browser measurements can differ
  • browser-compat.md — Chrome, Safari, Firefox behavior differences
  • script-matrix.md — Per-script accuracy (Latin, CJK, Arabic, Thai, and 8 more)
  • edge-cases.md — Zero-width chars, long words, empty strings, tabs
  • modules/ — Deep dives into source modules (analysis, measurement, line-break, layout, bidi, rich-inline)

Development

Prerequisites: Bun >= 1.0

cd mcp-server && bun install        # Install dependencies
cd mcp-server && bun test           # 109 pass + 6 gated on PRETEXT_ACCURATE_TESTS=1
cd mcp-server && bun run index.ts   # Start MCP server (stdio)

Project Structure

.claude-plugin/plugin.json   Plugin manifest
skills/                      3 skill definitions
agents/                      1 agent definition (pretext-advisor)
mcp-server/                  Bun MCP server with 5 tools
knowledge/                   12 reference files
pretext-bundled/             Bundled pretext v0.0.6 dist (incl. rich-inline)

How It Was Built

PretextPlugin was built through a four-phase process:

  1. Structured Reading — 8 research notes analyzing pretext's source code, architecture, and API surface
  2. Empirical Validation — 23,040 browser tests across Chrome, Safari, and Firefox confirming accuracy for 12 scripts. ~92% of Phase 1 findings confirmed; the rest corrected
  3. Knowledge Architecture — Plugin design spec with 6 architectural decisions (structural vs. accurate mode, knowledge granularity, tool boundaries)
  4. Implementation — 3 skills, 1 agent, MCP server with 5 tools, 12-file knowledge base, 92 tests

Contributing

Contributions are welcome. To get started:

  1. Fork the repository
  2. Create a feature branch
  3. Run cd mcp-server && bun test to ensure tests pass
  4. Open a pull request

For bug reports or feature requests, open an issue.

License

MIT — see LICENSE.

Ver o original no GitHub

Bom para

Relacionados