plaster-from-patch

Convert Brave-core Chromium patches into verified Plaster regex rewrite configs.

3.6k|1.4k|Updated Nov 10, 2017
One-click install
npx skills add https://github.com/brave/brave-core --skill plaster-from-patch
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: plaster-from-patch
Source: https://github.com/brave/brave-core/tree/main/agents/skills/plaster-from-patch
Command: npx skills add https://github.com/brave/brave-core --skill plaster-from-patch

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyyaml.

What problem does it solve?

Hand-written Chromium context patches in Brave-core are brittle and break on rebases. This Skill converts an existing .patch file into a robust Plaster rewrite/*.yaml config that expresses the change as an intent-conveying regex substitution, then proves correctness by regenerating the patch and diffing it against the original.

Core Features & Use Cases

  • Patch-to-Plaster conversion: Reads a .patch file, source path, or infers the change from the working tree, then authors a rewrite/<path>.yaml with one substitution per logical change.
  • Intent-based matching rules: Applies the Plaster dos and don'ts for enums, switch statements, gn arrays, pattern vs re_pattern, whitespace flexibility, and count semantics.
  • Verification by regeneration: Runs plaster.py apply on the specific config and diffs the regenerated patch against the original until they are byte-identical.
  • Use Case: You edited an upstream Chromium source, ran pnpm run update_patches, and now want the change expressed as a maintainable Plaster config instead of a fragile context patch.

Quick Start

Convert my patch at patches/components-foo-foo.cc.patch into a Plaster rewrite config and verify it reproduces the patch exactly.

Frequently Asked Questions about plaster-from-patch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a Chromium patch to a Plaster config?▼

Provide the .patch file path, source path, or let the Skill infer the change from the working tree. It reads the diff and pristine upstream source, authors rewrite/<path>.yaml with one substitution per logical change, then verifies by regenerating the patch.

When should I use pattern vs re_pattern in Plaster?▼

Use pattern for simple literal symbol replacements like renaming a constant. Use re_pattern when you need context, capture groups, or whitespace flexibility, and prefer \b word boundaries when matching a whole symbol to avoid matching inside larger identifiers.

How is a Plaster config verified for correctness?▼

The config is correct only if running tools/cr/plaster.py apply on the specific rewrite file regenerates a patch byte-identical to the original. The Skill diffs the regenerated patch against the original and iterates until the diff is empty.

Does Plaster modify Chromium source files directly?▼

No. This Skill only produces the rewrite/<path>.yaml config and never edits sources or creates chromium_src shadow files. Plaster itself loads the pristine upstream source from git and applies the regex substitution to regenerate the patch.

Why does plaster.py fail with ModuleNotFoundError: No module named yaml?▼

plaster.py requires PyYAML. Retry with the depot_tools interpreter via vpython3 tools/cr/plaster.py, or install PyYAML into the active environment with python3 -m pip install pyyaml.

What are the limitations of regex-based patching with Plaster?▼

Regexes must match the pristine upstream text, so anchoring on removable neighbor keys or incidental whitespace causes false breaks on rebases. Pure file-scope additions like new includes may be better hosted in chromium_src shadow files than in a plaster.