diff --git a/AGENTS.md b/AGENTS.md index 7ac90cd..8cee59e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,6 +19,6 @@ between lil-koneko.com, CarsHub, iriks-it.nl and bouwbedrijf.iriks-it.nl, as one ## Open decisions -1. Frontend: decided to ship the Inertia/Vue screens inside the package (prebuilt bundle, host needs no Node) with per-user and site themes; being built after v0.4.0's AI tooling slice. -2. Moving the rest from bouwbedrijf.iriks-it.nl, module by module: pages, reviews, then revisions, audit log, login and profile. Users, media and posts (with labels) are done. Leave out what is site-specific (the IriksIT API disk, the owner's simple screens, client names): this repo is public. +1. Frontend: decided and built: the screens are in the package (`ui/`, built into `resources/dist`, committed; PR CI checks it is up to date). Still open: a theme editor in the manager, and a `host` mode that publishes the sources for a site to build itself. +2. Moving the rest from bouwbedrijf.iriks-it.nl: real pages and reviews (now skeletons) and revisions. Users, media, posts, audit log and statistics are done, with their screens. Leave out what is site-specific (the IriksIT API disk, the owner's simple screens, client names): this repo is public. 3. How the host's own `User` and a package `Group` relate when the host has its own roles. diff --git a/README.md b/README.md index e2bab97..af4287b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ on the JSON routes. A browser that opens a manager address gets the page; anythi - **The house style of the site.** `php artisan manager:make-theme acme --brand=#e4002b --name="Acme" --logo=/img/logo.svg --font="Inter, sans-serif"` writes `resources/manager-themes/acme.json`; set `MANAGER_THEME=acme`. A theme is colours, a radius, fonts, a name and a logo, and every value is checked, so a theme file can never put CSS or markup in the page. Themes can also be listed in `manager.themes`. -- **Not built yet:** screens for the other modules (they show a notice for now) and a theme editor in the manager. +- **Not built yet:** a theme editor in the manager (themes are files for now), and screens for modules your own site adds (they show a notice). - **Working on the screens:** the sources are in `ui/`; `npm ci && npm run build` there writes `resources/dist`, which is committed (PR CI fails when it is out of date). @@ -152,13 +152,12 @@ scheduled daily), so a code cannot be traced back afterwards. A browser that sen ## State of this version -Done: module registry and switches, permissions per module, users (accounts, groups, command), media -(library and public file route) posts (with categories and tags) and the audit log with bans and the statistics, 99 tests (`composer test`). +Done: module registry and switches, permissions per module, users (accounts, groups, command), media (library and public file +route), posts (with categories and tags), the audit log with bans, the statistics, the built-in screens for all of these (with a +login and profile), themes, and the install and doctor commands for AI agents. `composer test` runs the tests. -The answers of every action are JSON, in the shape the screens of bouwbedrijf.iriks-it.nl got as -Inertia props. The screens themselves are not in the package yet: the frontend is an open decision -(`AGENTS.md`). Pages and reviews are still skeletons (a list), and login, profile and revisions are not -ported yet. +Pages and reviews are still skeletons (a read-only list), and revisions are not ported yet. The answers of every action are JSON +in the shape the screens use, so an app can build its own screens with `MANAGER_UI=none`. ## Development cycle diff --git a/TOKENS.md b/TOKENS.md index 2122dbf..92a1b64 100644 --- a/TOKENS.md +++ b/TOKENS.md @@ -27,3 +27,5 @@ Per stuk werk een rij; zie `dev/token-usage.py`. | 2026-12-04 | Schermen in het pakket: eigen login, profiel, menu en berichten, thema's per gebruiker en voor de huisstijl van de site | - | claude-sonnet-5-5 | 51 | 60.198 | 102 | 94.747 | 7.947.787 | 0,19 | | 2026-12-04 | Schermen voor gebruikers, groepen, categorieën en tags, pagina's en reviews | - | claude-sonnet-5-5 | 11 | 13.236 | 24 | 21.715 | 2.310.933 | 0,06 | | 2026-12-04 | Schermen voor media (met kiezer voor de omslag), de auditlog met blokkades en de statistieken | - | claude-sonnet-5-5 | 23 | 23.335 | 46 | 42.961 | 5.678.787 | 0,06 | +| 2026-12-04 | De stappengids en de installatie verbeterd na de proef met een verse agent | - | claude-sonnet-5-5 | 25 | 21.844 | 50 | 35.997 | 6.551.164 | 0,10 | +| 2026-12-04 | De stappengids en de installatie verbeterd na de proef met een verse agent | - | claude-haiku-5-5 | 11 | 8.233 | 22 | 51.184 | 444.805 | 0,00 | diff --git a/resources/ai/INTEGRATION.md b/resources/ai/INTEGRATION.md index 485892d..3c5db6a 100644 --- a/resources/ai/INTEGRATION.md +++ b/resources/ai/INTEGRATION.md @@ -1,22 +1,31 @@ # Integrating iriks-it/laravel-manager (guide for AI agents) -Goal: the manager runs in this Laravel app and `php artisan manager:doctor` is green. Do the steps in order and -never edit files inside `vendor/`. +Goal: the manager runs in this Laravel app and `php artisan manager:doctor --json` says `"ok": true`. Do the steps in +order and never edit files inside `vendor/`. 1. `composer require iriks-it/laravel-manager` -2. Pick the modules. `users` and `media` are on; `pages`, `posts` default on; `reviews`, `audit`, `statistics` default off + (A version that is not on Packagist yet: first `composer config repositories.manager --json '{"type":"path","url":"/path/to/laravel-manager","options":{"symlink":false}}'`, then require `@dev`.) +2. Pick the modules. `users` and `media` are on; `pages` and `posts` are on by default; `reviews`, `audit` and `statistics` are off (audit and statistics store visitor data: only switch them on when the owner says so). 3. `php artisan manager:install --modules=users,media,posts --user-model="App\Models\User"` - (writes `MANAGER_*` to `.env`, publishes `config/manager.php`, runs the doctor). Add `--path=admin` to move the URL. + It writes the `MANAGER_*` switches to `.env` and publishes `config/manager.php`. Add `--path=admin` to move the URL. + It does not run the check itself (this process still has the old config): that is step 7. 4. Add the trait to the user model: `use \IriksIT\Manager\Concerns\HasManagerAccess;`. Never put `is_super_admin` in `$fillable`. -5. `php artisan migrate` (a new process, so it sees the switches you wrote in step 3). +5. `php artisan config:clear && php artisan migrate && php artisan storage:link` (a new process, so it sees the switches of step 3). 6. Create the first super admin: `php artisan manager:create-user --name="..." --email="..." --password="<12+ chars>"`. -7. Run `php artisan manager:doctor --json`. Every check must be `ok` or an understood `warn`; each `fail`/`warn` has a `fix`. +7. `php artisan manager:doctor --json`. Every check must be `ok` or an understood `warn`; each `fail` and `warn` has a `fix`. Repeat until `"ok": true`. Facts that matter: -- The manager lives at `/manager` (`MANAGER_PATH`) behind `web` + `auth` (`manager.middleware`); the app needs a route named `login`. +- The screens are part of the package (`MANAGER_UI=package`, the default): open `/manager` in a browser. The app does not need a + login of its own: when it has no route named `login`, the manager's own login at `/manager/login` is used. With + `MANAGER_UI=none` there are only the JSON routes. +- A browser address gets the screens, a request with `Accept: application/json` gets the data. To call the JSON routes from a + script: `GET /manager/login` once for the `XSRF-TOKEN` cookie, then `POST /manager/login` with header `X-XSRF-TOKEN` (the cookie + value, URL-decoded), `Accept: application/json` and body `{"email": "...", "password": "..."}`; the answer is `{"redirect": "/manager"}`. +- The look: `MANAGER_THEME=dark|light` or your own (`php artisan manager:make-theme acme --brand=#e4002b --name="Acme" --logo=/img/logo.svg`, + then `MANAGER_THEME=acme`). Each account can pick its own in its profile (`MANAGER_USER_THEMES=false` stops that). - Anything that is off has no routes, tables or permissions. A module that needs another one fails at boot when that one is off. -- Answers are JSON. Do not add site-specific code to the package: a site's own part is its own module class (`Contracts\Module`, - extend `Modules\BaseModule`, add it to `manager.available`). +- Do not add site-specific code to the package: a site's own part is its own module class (`Contracts\Module`, extend + `Modules\BaseModule`, add it to `manager.available`). - Behind a proxy set trusted proxies before switching `audit` on. diff --git a/resources/boost/guidelines/core.blade.php b/resources/boost/guidelines/core.blade.php index 1279a3c..6b6a276 100644 --- a/resources/boost/guidelines/core.blade.php +++ b/resources/boost/guidelines/core.blade.php @@ -3,6 +3,7 @@ A modular backend (users, media, pages, posts, reviews, audit, statistics) installed as a package. - To integrate it, follow `vendor/iriks-it/laravel-manager/resources/ai/INTEGRATION.md` step by step. -- Set it up with `php artisan manager:install --modules=... --user-model=...`; verify with `php artisan manager:doctor --json` (non-zero exit on failure, every problem has a `fix`). +- Set it up with `php artisan manager:install --modules=... --user-model=...`, then `config:clear`, `migrate`, `storage:link`; verify in a new process with `php artisan manager:doctor --json` (non-zero exit on failure, every problem has a `fix`). +- The screens come with the package (`MANAGER_UI`), including a login when the app has none; themes: `php artisan manager:make-theme`, `MANAGER_THEME`. - The user model needs the `HasManagerAccess` trait; `is_super_admin` is never mass assignable. The first super admin comes from `php artisan manager:create-user`. - Switch parts with `MANAGER_=true|false`; never edit `vendor/`. Site-specific parts are your own `Module` class. diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 15223fa..82745e4 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -71,6 +71,13 @@ class InstallCommand extends Command $this->line('Run `php artisan migrate` (a new process) so the migrations of the modules you switched on are loaded.'); } + if ($env !== []) { + // This process still has the old config: its check would report the old state. A new process is right. + $this->line('Next: add the HasManagerAccess trait to the user model, run `php artisan config:clear && php artisan migrate && php artisan storage:link`, then `php artisan manager:doctor --json`.'); + + return self::SUCCESS; + } + return Artisan::call('manager:doctor', $this->option('json') ? ['--json' => true] : [], $this->output) === 0 ? self::SUCCESS : self::FAILURE; } diff --git a/tests/Feature/DoctorTest.php b/tests/Feature/DoctorTest.php index 8dc5077..2c266ec 100644 --- a/tests/Feature/DoctorTest.php +++ b/tests/Feature/DoctorTest.php @@ -7,8 +7,14 @@ use IriksIT\Manager\Tests\TestCase; uses(TestCase::class); // The installer publishes the config into the app, here the skeleton in vendor/: leave it as it was. -beforeEach(fn () => $this->hadConfig = file_exists(config_path('manager.php'))); -afterEach(fn () => $this->hadConfig || @unlink(config_path('manager.php'))); +beforeEach(function () { + $this->hadConfig = file_exists(config_path('manager.php')); + $this->env = file_exists(base_path('.env')) ? file_get_contents(base_path('.env')) : null; +}); +afterEach(function () { + $this->hadConfig || @unlink(config_path('manager.php')); + $this->env === null ? @unlink(base_path('.env')) : file_put_contents(base_path('.env'), $this->env); +}); function doctorReport(): array { @@ -54,12 +60,16 @@ it('refuses an unknown module in the installer', function () { it('writes the switches to .env', function () { $env = base_path('.env'); - $before = file_exists($env) ? file_get_contents($env) : null; Artisan::call('manager:install', ['--modules' => 'users,media,posts', '--path' => 'admin']); $written = file_get_contents($env); - $before === null ? unlink($env) : file_put_contents($env, $before); expect($written)->toContain('MANAGER_PATH=admin')->toContain('MANAGER_AUDIT=false')->toContain('MANAGER_POSTS=true'); }); + +it('leaves the check to a new process after it changed the switches', function () { + Artisan::call('manager:install', ['--path' => 'admin']); + + expect(Artisan::output())->toContain('manager:doctor')->not->toContain('[OK]'); +});