## Board 'New Article' button
- templates/admin/board-page.php: add #prab-board-generate-now button + status div
- includes/admin/class-board-page.php: inject generateNonce + i18n strings into prabBoard;
enqueue companion board-generate.js
- assets/js/board-generate.js: NEW – board button AJAX handler (fires
prautoblogger_generate_now, resets board backoff on success)
- assets/js/board.js: applySnapshot() re-enables button when no active runs
## Chained-cron checkpoint machine (retires SSH workaround)
- includes/core/class-generation-checkpoint-runner.php: NEW (295 lines)
Tick 1 (prautoblogger_gen_orchestrate): orchestrate_only() → persist queue → schedule Tick 2
Tick 2..N (prautoblogger_gen_tick): pop one idea → Article_Worker → reschedule or finalize
Budget/halt contract + lock release on all exit paths
- includes/class-executor.php: on_manual_generation() replaced with 1-line delegate to
Generation_Checkpoint_Runner::on_orchestrate_tick() (SSH workaround retired)
- includes/class-prautoblogger.php: register ORCHESTRATE_ACTION + GENERATE_ACTION hooks
- includes/core/class-pipeline-runner.php: expose orchestrate_only() public wrapper
- includes/core/class-pipeline-status.php: add write_initial() + write_error() helpers
## WP-CLI command
- includes/admin/class-wp-cli-commands.php: wp prautoblogger generate → kick_off()
## IA / perf pass (settings-backed pagination + DB indexes)
- includes/admin/class-board-data-provider.php: replace hardcoded posts_per_page=20 with
get_option('prautoblogger_board_column_limit', DEFAULT)
- includes/admin/class-board-gen-log-query.php: replace LIMIT 10/20 literals with settings-backed values
- includes/admin/class-ideas-browser-query.php: NEW – query helpers extracted from Ideas_Browser
(300-line rule split): query_ideas(), get_type_counts(), load_idea_data(),
find_post_by_run_id(), update_idea_stage()
- includes/admin/class-ideas-browser.php: delegates all query work to Ideas_Browser_Query
- includes/class-activator.php: set_default_options() adds board_column_limit + ideas_per_page
- includes/admin/class-admin-page.php: add new settings to numeric sanitization list
- prautoblogger.php: PRAUTOBLOGGER_DEFAULT_BOARD_COLUMN_LIMIT=20, PRAUTOBLOGGER_DEFAULT_IDEAS_PER_PAGE=30
- includes/class-schema-installer.php: indexes on generation_log + analysis_results (db 1.4.0)
- includes/class-pipeline-schema-installer.php: KEY started_at on runs table
## Guard P2s
- scripts/check-constants.php: --self-test mode + inline CONSTANTS_GUARD_WINDOW comment
- .github/workflows/ci.yml: check-constants-self-test step after main constants check
## PHPUnit test
- tests/unit/Core/GenerationCheckpointRunnerTest.php: NEW (227 lines)
4 tests: kick_off schedules+transient, empty-queue finalizes, halted-run aborts+cleanup,
multi-idea pops-one-and-reschedules
## Docs + version
- prautoblogger.php: Version 0.21.0, PRAUTOBLOGGER_DB_VERSION 1.4.0
- ARCHITECTURE.md: §25 Chained-Cron Checkpoint Generation Path
- CHANGELOG.md: v0.21.0 entry
- INFORMATION-ARCHITECTURE.md: NEW – admin pages, entry points, DB tables, options, CLI
- uninstall.php: purge prautoblogger_gen_orchestrate + prautoblogger_gen_tick cron hooks
Agent-Session: phase2-admin-m4-20260614
105 lines
2.9 KiB
PHP
105 lines
2.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* WP-CLI commands for PRAutoBlogger.
|
|
*
|
|
* Registers custom wp-cli commands exposed to the plugin.
|
|
*/
|
|
class PRAutoBlogger_WP_CLI_Commands {
|
|
|
|
/**
|
|
* Register WP-CLI commands.
|
|
*
|
|
* Called on plugins_loaded hook.
|
|
*/
|
|
public static function register(): void {
|
|
if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
|
|
return;
|
|
}
|
|
|
|
// Command: wp prautoblogger opik:eval
|
|
\WP_CLI::add_command(
|
|
'prautoblogger generate',
|
|
array( self::class, 'generate_command' ),
|
|
array(
|
|
'shortdesc' => 'Queue a new article generation run on chained-cron checkpoints',
|
|
)
|
|
);
|
|
|
|
\WP_CLI::add_command(
|
|
'prautoblogger opik:eval',
|
|
array( self::class, 'opik_eval_command' ),
|
|
array(
|
|
'shortdesc' => 'Run Opik evals on the frozen dataset',
|
|
'synopsis' => array(
|
|
array(
|
|
'type' => 'assoc',
|
|
'name' => 'limit',
|
|
'description' => 'Max items to run (0 = all)',
|
|
'optional' => true,
|
|
'default' => '0',
|
|
),
|
|
array(
|
|
'type' => 'flag',
|
|
'name' => 'dry-run',
|
|
'description' => 'Skip Opik API push; score locally only',
|
|
'optional' => true,
|
|
),
|
|
),
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Run eval on the frozen dataset.
|
|
*
|
|
* @param array $args Positional args (unused).
|
|
* @param array $assoc_args Associative args: limit, dry-run.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function opik_eval_command( array $args, array $assoc_args ): void {
|
|
// Check if Opik is enabled.
|
|
if ( empty( PRAUTOBLOGGER_OPIK_API_KEY ) || empty( PRAUTOBLOGGER_OPIK_WORKSPACE ) ) {
|
|
if ( ! isset( $assoc_args['dry-run'] ) ) {
|
|
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_echo -- CLI output
|
|
echo "Warning: Opik is not configured. Running with --dry-run only.\n";
|
|
$assoc_args['dry-run'] = true;
|
|
}
|
|
}
|
|
|
|
$limit = absint( $assoc_args['limit'] ?? 0 );
|
|
$dry_run = isset( $assoc_args['dry-run'] );
|
|
|
|
$runner = new PRAutoBlogger_Opik_Eval_Runner();
|
|
$result = $runner->run( $limit, $dry_run );
|
|
|
|
exit( $result['items_run'] > 0 ? 0 : 1 );
|
|
}
|
|
|
|
/**
|
|
* Queue a new article generation run on chained-cron checkpoints.
|
|
*
|
|
* Routes through PRAutoBlogger_Generation_Checkpoint_Runner::kick_off()
|
|
* (same path as the board "New Article" button). Does NOT execute
|
|
* synchronously -- check the board or Activity Log for progress.
|
|
* This retires the `do_action("prautoblogger_manual_generation")` workaround.
|
|
*
|
|
* ## OPTIONS
|
|
*
|
|
* ## EXAMPLES
|
|
*
|
|
* wp prautoblogger generate
|
|
*
|
|
* @param array $args Positional args (unused).
|
|
* @param array $assoc_args Associative args (unused).
|
|
* @return void
|
|
*/
|
|
public static function generate_command( array $args, array $assoc_args ): void {
|
|
PRAutoBlogger_Generation_Checkpoint_Runner::kick_off();
|
|
\WP_CLI::success( 'Generation queued on chained-cron checkpoints. Check the board or Activity Log for progress.' );
|
|
}
|
|
|
|
}
|