Skip to content

db-optimize: support filtering by specific table names #108

Description

@pluginslab

Problem

db-optimize always optimizes ALL database tables, ignoring user intent to target specific tables.

Tool selection works correctly (verified in PR #102 tests), but the ability lacks a tables input parameter.

Current behavior

The PHP backend (includes/abilities/db-optimize.php) runs SHOW TABLES and optimizes every table unconditionally. The input_schema has no properties — it accepts no parameters.

Proposed fix

PHP: Add tables input parameter

'input_schema' => array(
    'type'       => 'object',
    'default'    => array(),
    'properties' => array(
        'tables' => array(
            'type'        => 'array',
            'items'       => array( 'type' => 'string' ),
            'description' => 'Specific table names to optimize. If empty, optimizes all tables.',
        ),
    ),
    'additionalProperties' => false,
),

In the execute callback:

  • If tables is provided, validate each name exists, then optimize only those
  • If tables is empty/missing, optimize all (current behavior)
  • Security: validate table names against actual database tables to prevent SQL injection

JS: Extract table names from user message

The execute function should extract table names from the user message and pass them as the tables parameter. This could be done via:

  1. LLM args — the LLM already receives the user message and could populate args.tables if the system prompt describes the parameter
  2. JS-side extraction — regex to pull table names (anything matching wp_* patterns)

WooCommerce awareness (#73)

For "optimize the WooCommerce tables", the ability should know which tables belong to WooCommerce. Options:

Example user queries

  • "optimize the database table wp_options" → optimize only wp_options
  • "optimize wp_posts and wp_postmeta" → optimize those two
  • "optimize the WooCommerce tables" → optimize all WC-related tables
  • "optimize the database" → optimize all (current behavior, unchanged)

Files to modify

  • includes/abilities/db-optimize.php — add tables param, filter logic
  • src/extensions/abilities/db-optimize.js — extract table names or rely on LLM args

Refs

Closes #69, closes #73

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions