From 347c0330b19dd5318a25aac2f26a3961decfab6c Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Sun, 16 Nov 2025 19:39:05 -0600 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=93=9D=20Add=20AGENTS.md=20with=20age?= =?UTF-8?q?nt=20guidelines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..1e4712b --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,30 @@ +# Agent Guidelines for vid-queue + +This document outlines the conventions and commands for agentic coding in this repository. + +## Build/Lint/Test Commands + +* **Run all tests:** `php artisan test` or `php ./vendor/bin/pest` +* **Run a single test file:** `php artisan test ` (e.g., `php artisan test tests/Feature/Commands/GetShowTest.php`) +* **Linting:** Adhere to PSR-12 coding standards. No explicit linting command is configured, but static analysis tools like PHPStan or Psalm may be used locally. + +## Code Style Guidelines + +* **Imports:** Use fully qualified class names and `use` statements at the top of files. +* **Formatting:** + * Indent with 4 spaces. + * Use `lf` for line endings. + * Ensure a final newline at the end of files. + * Trim trailing whitespace. +* **Types:** Utilize PHP 7.4+ type hints for arguments, return types, and properties where appropriate. +* **Naming Conventions:** + * Classes: PascalCase (e.g., `GetShow`, `TraktLogin`). + * Methods/Functions: camelCase. + * Variables: camelCase. +* **Error Handling:** Use exceptions for error handling. +* **Dependency Injection:** Prefer dependency injection over using Facades or resolving from the IOC Container directly. + +## Git Commit Guidelines +- **Format**: Prepend commit messages with a gitmoji emoji (see https://gitmoji.dev) +- **Style**: Write detailed commit messages that explain what changed and why +- **Examples**: `✨ Add JSON export functionality for log entries`, `🐛 Fix date parsing for RFC3339 timestamps`, `📝 Update README with configuration examples` From caa1f0e4429d0a7fa8bc018650c3e54fc78e70e1 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Sun, 16 Nov 2025 20:45:27 -0600 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20Refactor=20Trakt=20configuratio?= =?UTF-8?q?n=20to=20use=20config=20file=20and=20dependency=20injection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Commands/TraktLogin.php | 10 +++++----- app/Commands/TraktRefreshLogin.php | 18 +++++++++--------- app/Providers/AppServiceProvider.php | 3 ++- app/Services/Trakt.php | 9 +++++---- config/trakt.php | 11 +++++++++++ 5 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 config/trakt.php diff --git a/app/Commands/TraktLogin.php b/app/Commands/TraktLogin.php index 592080a..1be6a85 100644 --- a/app/Commands/TraktLogin.php +++ b/app/Commands/TraktLogin.php @@ -5,16 +5,16 @@ declare(strict_types=1); namespace App\Commands; use App\Services\Trakt; +use Illuminate\Contracts\Config\Repository; class TraktLogin extends Command { protected $signature = 'trakt:login'; protected $description = 'Login and get new token.'; - - public function handle(Trakt $trakt): int + public function handle(Trakt $trakt, Repository $config): int { $data = [ - 'client_id' => env('TRAKT_APP_ID'), + 'client_id' => $config->get('trakt.app_id'), ]; $resp = $trakt->requestNoAuth()->post('/oauth/device/code', $data); @@ -33,8 +33,8 @@ class TraktLogin extends Command $this->line("TRAKT_DEVICE_RESP='" . json_encode($body) . "'"); $data = [ - 'client_id' => env('TRAKT_APP_ID'), - 'client_secret' => env('TRAKT_APP_SECRET'), + 'client_id' => $config->get('trakt.app_id'), + 'client_secret' => $config->get('trakt.app_secret'), 'code' => $body['device_code'], ]; diff --git a/app/Commands/TraktRefreshLogin.php b/app/Commands/TraktRefreshLogin.php index b17b3c4..3baf499 100644 --- a/app/Commands/TraktRefreshLogin.php +++ b/app/Commands/TraktRefreshLogin.php @@ -5,25 +5,25 @@ declare(strict_types=1); namespace App\Commands; use App\Services\Trakt; +use Illuminate\Contracts\Config\Repository; class TraktRefreshLogin extends Command { protected $signature = 'trakt:refresh'; protected $description = 'Refresh access token.'; - - public function handle(Trakt $trakt): int + public function handle(Trakt $trakt, Repository $config): int { - $oauth_resp = json_decode(env('TRAKT_OAUTH_RESP'), true); - if (empty($oauth_resp)) { - $this->line("Failed to get OAuth response"); + $refresh_token = $config->get('trakt.login.oauth.refresh_token'); + if (empty($refresh_token)) { + $this->line("Failed to get refresh token"); return static::FAILURE; } $data = [ - 'refresh_token' => $oauth_resp['refresh_token'], - 'client_id' => env('TRAKT_APP_ID'), - 'client_secret' => env('TRAKT_APP_SECRET'), - 'redirect_uri' => env('TRAKT_REDIRECT_URI'), + 'refresh_token' => $refresh_token, + 'client_id' => $config->get('trakt.app_id'), + 'client_secret' => $config->get('trakt.app_secret'), + 'redirect_uri' => $config->get('trakt.redirect_uri'), 'grant_type' => 'refresh_token', ]; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 8c37147..93d92fa 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,6 +7,7 @@ use Illuminate\Support\ServiceProvider; use Illuminate\Contracts\Queue\Factory as QueueFactoryContract; use App\Queue\DatabaseConnector; use App\Services\Trakt; +use Illuminate\Contracts\Config\Repository; class AppServiceProvider extends ServiceProvider { @@ -29,6 +30,6 @@ class AppServiceProvider extends ServiceProvider public function register() { $this->app->instance(ProcessInput::class, new ProcessInput()); - $this->app->instance(Trakt::class, new Trakt()); + $this->app->singleton(Trakt::class, fn ($app) => new Trakt($app->make(Repository::class))); } } diff --git a/app/Services/Trakt.php b/app/Services/Trakt.php index 127406d..3a4c3f9 100644 --- a/app/Services/Trakt.php +++ b/app/Services/Trakt.php @@ -6,18 +6,19 @@ use App\Data\WatchData; use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\Response; use Illuminate\Support\Facades\Http; +use Illuminate\Contracts\Config\Repository; use Symfony\Component\Console\Output\OutputInterface; class Trakt { - protected $headers = []; + protected array $headers = []; - public function __construct() + public function __construct(Repository $config) { $this->headers = [ 'trakt-api-version' => 2, - 'trakt-api-key' => env('TRAKT_APP_ID'), - 'Authorization' => 'Bearer ' . env('TRAKT_OAUTH_TOKEN'), + 'trakt-api-key' => $config->get('trakt.app_id'), + 'Authorization' => 'Bearer ' . $config->get('trakt.login.oauth.access_token'), ]; } diff --git a/config/trakt.php b/config/trakt.php new file mode 100644 index 0000000..5b91722 --- /dev/null +++ b/config/trakt.php @@ -0,0 +1,11 @@ + env('TRAKT_APP_ID'), + 'app_secret' => env('TRAKT_APP_secret'), + 'redirect_uri' => env('TRAKT_REDIRECT_URI', 'urn:ietf:wg:oauth:2.0:oob'), + 'login' => [ + 'device' => json_decode(env('TRAKT_DEVICE_RESP', '{}}'), true), + 'oauth' => json_decode(env('TRAKT_OAUTH_RESP', '{}}'), true), + ], +]; From 320a62956119499dbf127d8160852a520052056b Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Sun, 16 Nov 2025 20:46:20 -0600 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20Update=20AGENTS.md=20with=20?= =?UTF-8?q?minor=20adjustments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1e4712b..1d1bca7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,8 +4,7 @@ This document outlines the conventions and commands for agentic coding in this r ## Build/Lint/Test Commands -* **Run all tests:** `php artisan test` or `php ./vendor/bin/pest` -* **Run a single test file:** `php artisan test ` (e.g., `php artisan test tests/Feature/Commands/GetShowTest.php`) +* **Tests:** There are no working tests. The user will do manual tests. * **Linting:** Adhere to PSR-12 coding standards. No explicit linting command is configured, but static analysis tools like PHPStan or Psalm may be used locally. ## Code Style Guidelines