Skip to content

Move generated PHP runner fragments into focused template builders #814

@chubes4

Description

@chubes4

Problem

WP Codebox still embeds large generated PHP runner fragments inside host/runtime orchestration files. That makes the surrounding abstraction hard to read, hard to test in isolation, and easy to regress when escaping, payload encoding, or runtime bootstrap assumptions change.

A previous issue handled PHPUnit template duplication, but this is broader than PHPUnit.

Evidence

  • packages/wordpress-plugin/src/trait-wp-codebox-abilities-browser-runner.php contains a large inline PHP browser runner string in browser_agent_runner_php().
  • packages/wordpress-plugin/src/class-wp-codebox-agent-sandbox-runner.php still builds recipe commands, agent runtime payloads, parent-site seed exports, and runtime fragments in the same host adapter class.
  • packages/runtime-playground/src/bench-command-handlers.ts, phpunit-command-handlers.ts, and related command handlers also mix runtime orchestration with generated PHP snippets.
  • Existing issue #770 covered PHPUnit command template fragments only; it does not cover browser runner / agent runner / generic generated PHP template boundaries.

Desired shape

Create focused template/builder modules for generated PHP runners, with explicit input contracts and small smoke coverage.

Possible slices:

  • Browser materializer/agent runner PHP template builder.
  • Agent sandbox runtime PHP template builder.
  • Benchmark/runtime command PHP template helpers, where reusable.
  • Shared escaping/encoding conventions for template inputs.

Acceptance criteria

  • Large inline PHP strings are moved out of orchestration classes/command handlers into named template builders.
  • Template builders have narrow inputs and return strings only.
  • Existing behavior and artifact shapes remain unchanged.
  • At least one smoke test proves the extracted browser/agent runner template still executes.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions