Skip to content

Commit 3f18e4e

Browse files
committed
feat: update guideline composer to pass guidelineassist class to blade AI guidelines
1 parent 8bb6c26 commit 3f18e4e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Install/GuidelineComposer.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ class GuidelineComposer
1919

2020
protected GuidelineConfig $config;
2121

22+
protected GuidelineAssist $guidelineAssist;
23+
2224
public function __construct(protected Roster $roster, protected Herd $herd)
2325
{
2426
$this->config = new GuidelineConfig;
27+
$this->guidelineAssist = new GuidelineAssist;
2528
}
2629

2730
public function config(GuidelineConfig $config): self
@@ -47,9 +50,9 @@ public function compose(): string
4750
*/
4851
public static function composeGuidelines(Collection $guidelines): string
4952
{
50-
return $guidelines
51-
->map(fn ($content, $key) => "\n=== {$key} ===\n\n{$content}")
52-
->join("\n\n");
53+
return trim($guidelines
54+
->map(fn ($content, $key) => "\n=== {$key} rules ===\n\n{$content}")
55+
->join("\n\n"));
5356
}
5457

5558
/**
@@ -83,9 +86,11 @@ protected function find(): Collection
8386
$guidelines->put('core', $this->guideline('core'));
8487
$guidelines->put('boost/core', $this->guideline('boost/core'));
8588

86-
$phpMajorMinor = PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;
8789
$guidelines->put('php/core', $this->guideline('php/core'));
88-
$guidelines->put('php/v'.$phpMajorMinor, $this->guidelinesDir('php/'.$phpMajorMinor));
90+
91+
// TODO: AI-48: Use composer target version, not PHP version. Production could be 8.1, but local is 8.4
92+
// $phpMajorMinor = PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;
93+
// $guidelines->put('php/v'.$phpMajorMinor, $this->guidelinesDir('php/'.$phpMajorMinor));
8994

9095
if (str_contains(config('app.url'), '.test') && $this->herd->isInstalled()) {
9196
$guidelines->put('herd/core', $this->guideline('herd/core'));
@@ -201,7 +206,9 @@ protected function guideline(string $path): ?string
201206
];
202207

203208
$content = str_replace(array_keys($placeholders), array_values($placeholders), $content);
204-
$rendered = Blade::render($content);
209+
$rendered = Blade::render($content, [
210+
'assist' => $this->guidelineAssist,
211+
]);
205212
$rendered = str_replace(array_values($placeholders), array_keys($placeholders), $rendered);
206213

207214
return trim($rendered);

0 commit comments

Comments
 (0)