Linux 软件免费装
Banner图

Static Cache Wrangler - Headless Assistant

开发者 derickschaefer
更新时间 2026年1月22日 11:05
PHP版本: 7.4 及以上
WordPress版本: 6.9
版权: GPLv2 or later
版权网址: 版权信息

标签

cms converter exporter headless sanity

下载

2.1.0

详情介绍:

Static Cache Wrangler - Headless Assistant is a companion plugin for Static Cache Wrangler that converts cached HTML files into headless CMS-compatible formats for modern headless CMS workflows. This plugin requires WP-CLI and is intended for developers and administrators who have good working knowledge of operating in shell environments with traditional Linux stream processing commands (e.g. sed, grep, awk, sort) and a willingness to explore the WordPress command-line interface. This plugin enables composable, command-line interface tooling and IS NOT a point and click solution. Testing Results Tested on cachewrangler.com (15-page WordPress site): Top Conversion Rates Achieved: Extensible Architecture Unlike hardcoded solutions, this plugin uses a pluggable engine system where CMS targets can be registered via filters. Ships with Sanity® CMS support (unofficial) out of the box. It is technically feasible to target Contentful, Strapi, and others via extensions. Sanity® is a registered trademark of Sanity.io. This project is not affiliated with or endorsed by Sanity.io. Features Direct Sanity CMS Conversion: Future Roadmap Considerations Generic Portable Text Output: Funding Model Pattern Detection System Built-in Detector Modules: Gutenberg Core - 12 patterns: php // Register custom patterns add_action('stcw_headless_patterns_loaded', function() { \STCW\Headless\Engine\Detector\PatternRegistry::register('custom_block', [ 'selectors' => ['.my-custom-block'], 'extractor' => [MyExtractor::class, 'extract'], 'priority' => 8, 'confidence' => 0.95, ]); }); How It Works
  1. Cache your WordPress site with Static Cache Wrangler
  2. Scan cached files: wp scw-headless scan
  3. Analyze patterns: wp scw-headless analyze /page/
  4. Convert:
  5. Free: wp scw-headless convert --cms=sanity
Supported CMS Targets Included: Perfect For Requirements

安装:

Automatic Installation
  1. Install and activate Static Cache Wrangler
  2. Install (or confirm installation) WP-CLI
  3. Search "STCW Headless Assistant" in WordPress plugin directory
  4. Click "Install Now" and activate
  5. Generate cached pages by browsing your site
  6. Use WP-CLI: wp scw-headless info to verify installation
Manual Installation
  1. Install and activate Static Cache Wrangler first
  2. Upload stcw-headless-assistant folder to /wp-content/plugins/
  3. Activate via WordPress admin
  4. Navigate to Static Cache > Headless Assistant
  5. Run: wp scw-headless scan to verify setup
Recommended Setup
  1. Install WP-CLI (for CLI support)
  2. Install Static Cache Wrangler (for HTML caching)
  3. Install STCW Headless Assistant (this plugin)
  4. Cache your site: wp scw enable
  5. Test conversion: wp scw-headless analyze /

屏幕截图:

  • WP-CLI Command and Example Output
  • Restuls from testing on https://cachewrangler.com

升级注意事项:

2.1.0 Production-ready release with real-world testing on cachewrangler.com. 74% semantic conversion rate confirmed. Generic Portable Text converter added for multi-CMS workflows. Requires Pattern Library Pro for normalize command. Free tier (Sanity conversion) unchanged and fully functional. 2.0.8 Bug fixes for file path resolution and scanner filtering. Recommended update for all users. 2.0.0 Major architectural rewrite. Plugin renamed and CLI namespace changed. Old wp scw-sanity commands deprecated but work via aliases. Update to wp scw-headless commands.

常见问题:

Does this work without Static Cache Wrangler?

No, this is a companion plugin that requires Static Cache Wrangler to be installed and active. It converts the HTML files that Static Cache Wrangler generates.

What WP-CLI commands are available?

Commands:

  • wp scw-headless info - Show system status and statistics
  • wp scw-headless scan - List all cached HTML files ready for conversion
  • wp scw-headless analyze <file> - Detect patterns in specific file
  • wp scw-headless patterns - List all registered patterns with confidence scores
  • wp scw-headless detectors - Show registered detector modules
  • wp scw-headless convert --cms=sanity - Convert all files to Sanity format
  • wp scw-headless targets - List available CMS targets All commands support --format=json for automation.

What gets exported?

Current (Sanity conversion): The plugin creates a complete export package containing:

  • data.ndjson - Sanity import data in newline-delimited JSON format
  • asset-manifest.json - Asset references with URLs and metadata
  • schemas/ - Sanity Studio schema definitions
  • README.md - Import instructions for Sanity
  • .zip archive - Complete package for download
Export packages are saved in wp-content/cache/stcw-headless-exports/ .

How does pattern detection work?

The plugin uses a sophisticated multi-phase pipeline:

  1. HTML Normalization - Strips WordPress-specific classes, IDs, and attributes while preserving semantic HTML
  2. Pattern Detection - Uses XPath queries to find registered patterns (CSS selectors converted to XPath)
  3. Priority Sorting - Processes patterns by priority (10=highest) to handle nested blocks correctly
  4. Confidence Scoring - Each match includes confidence score (0.0-1.0) based on selector specificity
  5. Content Extraction - Registered extractor functions parse matched DOM nodes into structured data
  6. Conversion - Transform to target CMS format

How accurate is pattern detection?

Production Results (cachewrangler.com):

  • Overall semantic conversion: 74%
  • Core Gutenberg blocks: 100% accuracy (confidence: 1.00)
  • Kadence Blocks: 90-95% accuracy (confidence: 0.90-0.98)
  • 40 unique patterns registered
  • 763 blocks processed across 15 pages
  • 174 blocks fell back to raw HTML (navigation menus, advanced widgets) Per-Page Results:
  • Simple pages: 82-86% conversion
  • Mixed content pages: 74-82% conversion
  • Complex pages (23 block types): 52% conversion

What if a pattern isn't detected?

Falls back to rawHtml block type with pattern metadata. You can:

  • Add custom pattern definitions via filters
  • Report missing patterns on GitHub
  • Wire up existing extractors (many already exist)

Can I add support for more blocks?

Yes! Three ways: 1. Register patterns via filter: php add_action('stcw_headless_patterns_loaded', function() { \STCW\Headless\Engine\Detector\PatternRegistry::register('my_block', [ 'selectors' => ['.my-block-class'], 'extractor' => [MyExtractor::class, 'extract_my_block'], 'priority' => 8, 'confidence' => 0.95, ]); }); 2. Create detector modules (for larger block libraries) 3. Use pattern inheritance: php // Extend existing patterns PatternRegistry::register('custom_button', [ 'extends' => 'button', // Inherits base button selectors 'selectors' => ['.my-custom-button'], // Adds custom selectors ]);

Can I add support for other CMS platforms?

Yes! The plugin is designed with a pluggable architecture: php // Register custom CMS target add_action('stcw_headless_register_targets', function() { $my_target = new My_CMS_Target(); \STCW\Headless\Engine\Target\TargetRegistry::register($my_target); }); Your target class must implement TargetInterface with methods for convert(), generate_schemas(), and export().

What paths are excluded from scans?

By default, these paths are excluded:

  • assets/ - Static assets (CSS, JS, images)
  • author/ - Author archives
  • category/, tag/ - Taxonomy archives
  • index.php/ - WordPress quirks
  • feed/, wp-json/ - API endpoints
  • sitemap/, 404/ - Utility pages
  • Blog index pages (Posts Page in Settings → Reading) Filter via stcw_headless_excluded_paths to customize.

Why is the blog page not converting?

WordPress "Posts Page" archives (the page set as your blog index in Settings → Reading) are intentionally skipped because they contain dynamic post loops, not static content. Individual blog posts are converted successfully. To recreate your blog index in Sanity:

  1. Import individual posts (automatically converted)
  2. Use this GROQ query to fetch posts: groq *[_type == "post"] | order(publishedAt desc) { title, slug, excerpt, publishedAt }
  3. Build your blog index view in your frontend

Does this work with page builders?

Kadence Blocks is currently supported. Support is being considered for Elementor, Otter Blocks, Divi, and more.

What's the performance?

v2.1.0 Benchmarks (cachewrangler.com test site):

  • 15 pages converted in ~6 seconds
  • Small page (10 KB): ~0.2 seconds
  • Medium page (50 KB): ~0.5 seconds
  • Large page (100 KB): ~1.0 seconds
  • Batch (100 pages): ~45 seconds
  • Pattern detection: XPath-based (efficient)
  • Memory: ~20 MB per page

Can I preview before converting?

Yes! Use wp scw-headless analyze <file> to see:

  • Patterns detected
  • Confidence scores
  • Asset references
  • Potential issues
  • Extraction preview Example:
```bash wp scw-headless analyze /plugins/kadence-blocks/ --verbose

Pattern Analysis

File: index.html (104 KB) Patterns Found: 71 paragraph 20 Confidence: 1.00 heading 15 Confidence: 1.00 separator 14 Confidence: 1.00 kadence_button 6 Confidence: 0.90 kadence_accordion 2 Confidence: 0.95 ... Confidence Distribution: High (≥0.95): 60 Medium (0.85+): 11 Low (<0.85): 0 ```

How do I get support?

Why are some files showing as 140 B?

Static Cache Wrangler may create gzipped files or use compression. The plugin handles this automatically by reading the actual index.html files within cached directories.

更新日志:

2.1.0 - January 15, 2025 Major Update: Production-Ready after hours of testing 2.0.9 - January 5, 2026 2.0.8 - January 2, 2026 2.0.7 - December 30, 2025 2.0.6 - December 27, 2025 2.0.5 - December 26, 2025 2.0.4 - December 22, 2025 2.0.3 - December 16, 2025 2.0.2 - December 1, 2025 2.0.1 - November 15, 2025 2.0.0 - November 1, 2025 1.0.0 - October 1, 2025