Files
pricebuddy/app/Filament/Traits/FormHelperTrait.php
Jeremy 8b02abb0aa feat: AI self-healing store config
Add AiConfigHealer to bootstrap or repair a store config via a
tool-using structured agent (fetch/css/regex tools, HealingContext,
shared StrategyExtractor).

- Run healing before the one-shot enhancer; AI-bootstrap a store config
  when product create would otherwise fail; StoreUrl validation defers
  to self-healing when enabled
- Per-feature AI provider resolution (AiFeature enum) and settings
- Per-store self-healing opt-out plus cooldown; log heal attempts and
  unusable proposals
- Heal with AI action with non-persisting preview/apply/discard in the
  store test modal; prompt switches to browser scraping when blocked
2026-06-09 15:07:40 +10:00

60 lines
1.8 KiB
PHP
Executable File

<?php
namespace App\Filament\Traits;
use Filament\Forms\Components\Group;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\ViewField;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
trait FormHelperTrait
{
public static function makeFormHeading(string $heading): ViewField
{
return ViewField::make(Str::slug($heading))
->view('components.form_heading')
->viewData(['heading' => $heading]);
}
public static function makeSettingsHeading(string $heading, string|HtmlString|null $description = null): ViewField
{
return ViewField::make(Str::slug($heading).'-heading')
->view('components.settings_heading')
->viewData(['heading' => $heading, 'description' => $description]);
}
public static function makeSettingsSection(
string $label,
string $rootPath,
string $subPath,
array $schema = [],
string|HtmlString|null $description = null,
bool $flat = false,
int $cols = 2,
): Section|Group {
$inner = Group::make([
Toggle::make($subPath.'.enabled')->reactive(),
// Only make additional settings if schema exists.
Group::make($schema)
->columns($cols)
->statePath($subPath)
->hidden(fn ($get) => ! $get($subPath.'.enabled') || empty($schema))
->reactive(),
])->statePath($rootPath);
if ($flat) {
return Group::make([
self::makeSettingsHeading($label, $description),
$inner,
]);
}
return Section::make($label)
->description($description)
->schema([$inner]);
}
}