Skip to content

Redesign detection API around ecosystems and detectors - #48

Merged
pushpak1300 merged 46 commits into
1.xfrom
refactor
Jul 17, 2026
Merged

pushpak1300 merged 46 commits into
1.xfrom
refactor

Conversation

@pushpak1300

@pushpak1300 pushpak1300 commented May 16, 2026 •

Copy link
Copy Markdown
Member

Currently Roster is a flat list of composer packages: you ask $roster->uses(Packages::INERTIA) and get a bool. There's no place for JS packages, no notion of a stack, no way to ask about frontend, browser test framework, configured agents and editors, or the conventions a codebase has adopted.

This PR redesigns detection around a single Project facade that reads lockfiles, configuration markers, and (opt-in) the project's own source code.

Before:

$roster = Roster::scan();

$roster->uses(Packages::INERTIA);
$roster->usesVersion(Packages::PEST, '3.0.0', '>=');
$roster->packages()->dev();
$roster->nodePackageManager();

After:

use Laravel\Roster\Enums\Agent;
use Laravel\Roster\Enums\Approach;
use Laravel\Roster\Enums\BrowserTestFramework;
use Laravel\Roster\Enums\Editor;
use Laravel\Roster\Enums\Frontend;
use Laravel\Roster\Enums\JsPackageManager;
use Laravel\Roster\Enums\Stack;
use Laravel\Roster\Facades\Project;

// Packages, per ecosystem:
Project::php()->uses('pestphp/pest');
Project::php()->uses('laravel/framework', '^12.0');
Project::php()->uses(['pestphp/pest' => '^3.0', 'phpunit/phpunit' => '^10.0']);
Project::php()->usesAll(['pestphp/pest', 'laravel/framework']);
Project::php()->usesDirect('livewire/livewire');

Project::js()->uses('@inertiajs/react');
Project::js()->packageManager() === JsPackageManager::Pnpm;

// Enum surfaces:
Project::stacks()->uses(Stack::InertiaReact);
Project::frontends()->uses(Frontend::React);
Project::browserTestFrameworks()->uses(BrowserTestFramework::Playwright);
Project::agents()->uses(Agent::ClaudeCode);
Project::editors()->uses(Editor::PhpStorm);

// Conventions, from the source code itself:
Project::approaches()->uses(Approach::MassAssignmentFillable);
Project::approaches()->uses(Approach::ValidationPipeSyntax);

uses and the old usesVersion collapse into one signature: uses($packages, $constraint = null) accepting any composer-semver constraint (^1.2.3, ~1.2, >=11 <14, 1.0 || ^2.0, bare 1.2.3 = exact match). Batch checks land via array shapes: indexed array for any-of names, associative for per-package constraints, plus a separate usesAll for the "every one of these" question. The enum surfaces (stacks, frontends, browserTestFrameworks, agents, editors) share the same uses / usesAll / all shape via EnumSet.

JS lockfile scanners (npm, pnpm, yarn, bun) walk the full lockfile rather than just root dependencies, so js()->uses() finds transitive packages the same way php()->uses() finds them in composer.lock. Direct vs indirect is classified from package.json. Bun is detected via both bun.lock and bun.lockb.

Agents and editors are separate enums, detected from repo markers like .claude, .cursor, .idea, or AGENTS.md. Agent holds AI coding tools (Claude Code, Cursor, Codex, Copilot, Gemini, etc.) and Editor holds IDEs (PHPStorm, VSCode, Zed, Sublime Text).

Project::approaches() reports stylistic conventions read from the source itself, with evidence thresholds: $fillable vs $guarded mass assignment, enum case casing, pipe vs array validation rules, inline validation vs form requests, #[Signature] vs $signature commands, notify() vs the Notification facade, the authorization style (gate / $user->can() / attribute / trait), authenticated-user retrieval (facade / request / helper), and the model key style (UUID / ULID / default incrementing). A style only reports when it has at least 3 votes and more than 80% agreement, and each ApproachResult exposes the confidence ratio, vote counts, and the files that voted. Because source files change without touching a lockfile, approaches are computed lazily per process and never persisted with the cached scan; roster:scan takes an --approaches flag to include them.

Scans memoize per process and persist via the app's cache driver, keyed on a hash of lockfile contents and detector markers, so edits to composer.lock or a newly added .claude directory invalidate automatically. Project::fresh() bypasses both, and everything falls back to a direct scan when the cache driver is missing or fails.

An earlier revision of this PR also shipped a System facade for binaries on PATH; that surface was dropped to keep the package purely project-scoped.

Warning

BC break across the public API. The Roster facade is replaced by Project. The Packages and Ides enums and the alias registry are gone; pass raw package names and Roster::extend() is removed. usesVersion folds into uses. Approaches becomes Approach, NodePackageManager becomes JsPackageManager, and PHPStorm and VSCode move from Agent to the new Editor enum. TestFramework and StarterKit detection have been removed.

Full migration table in UPGRADE.md.

@pushpak1300
pushpak1300 force-pushed the refactor branch 2 times, most recently from 86813eb to e1dc1b3 Compare May 18, 2026 19:06
@pushpak1300
pushpak1300 marked this pull request as ready for review June 19, 2026 09:46
pushpak1300 and others added 4 commits July 6, 2026 16:44
Applies the over-engineering audit findings:

- Fold directory conventions (action, ddd, modular) into approaches()
  as full-confidence results, removing the parallel approach() EnumSet
  and ApproachDetector
- Replace the Wilson score interval with a plain >80% vote-share gate
- Replace the enum-case tokenizer with a line-based regex (enum cases
  end in ; or =, switch labels end in :)
- Remove the unused ttl()/withoutCache()/fresh() cache knobs
- Remove InstalledSet in favor of EnumSet::uses on System surfaces
- Remove the Hosts\Js wrapper in favor of System::jsPackageManagers()
- Remove the empty PhpEcosystem subclass; Ecosystem is now concrete
- Remove unused PackageCollection::direct()/indirect(), Package::matches(),
  SystemProbe::pathExists()/resetCache(), and JsLockfile memoization
- Reuse MarkerDetector::markerMatches for the cache marker hash
- Drop the unused illuminate/routing dependency
- Restructure README and UPGRADE guides in the Laravel docs style

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Roster now reports only on the project itself. The System facade, its
manager, the PATH binary probes (SystemProbe, PackageManagersDetector,
the detectors' system-binary tables), and the roster:scan --no-system
flag are removed. Host-machine detection can return in a future release.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
#65)

Correctness:
- Replace Log facade calls in scanners with a container-safe warn helper
  so Project::scan() no longer crashes outside a Laravel container
- Report Stack::LIVEWIRE for Volt-only apps instead of falling through
  to Stack::BLADE
- Stop ProjectManager::scan($path) from repointing the memoized default
  instance when scanning another directory
- Resolve composer vendor-dir from a memoized manifest so computePath()
  no longer depends on call order
- Add missing declare(strict_types=1) to PackageCollection, PackageJson,
  and YarnPackageLock

API:
- Rename stack()/frontend() to stacks()/frontends() across Project,
  ProjectManager, the facade, and toArray() keys
- Add EnumSet::usesAll(), ApproachSet::usesAll(), and
  ApproachSet::result() for typed result lookup
- Type EnumSet::uses() as BackedEnum|array instead of mixed
- Add ProjectManager::fresh() to bypass the cache, and proxy toArray()
- Accept any-of arrays in Ecosystem::usesDirect() and add
  PackageCollection::direct()
- Make Package::major() return null for unknown versions
- Make the roster:scan directory argument optional, defaulting to the
  application base path
- Mark Project::normalizeBasePath() as internal

Architecture:
- Extract a shared PackageScanner base and fold the duplicated
  direct-dependency, constraint, and path logic out of the Composer and
  JS scanners; rename Composer to ComposerLock with a directory-based
  constructor matching every other scanner
- Unify scanner error handling: consistent warning level, lockfile path
  in every message, and distinct decode-failure vs missing-key messages
- Derive the cache lockfile list from JsPackageManager::cases() and
  version the cache key
- Inline the single-use CachesScan trait into ProjectManager
- Remove SourceFiles::contains() to avoid double file reads on the
  approaches scan path
- Drop the lockFile() abstract that PackageJson had to fake

Tests:
- Cover YarnPackageLock (v1, berry, scoped headers) and BunPackageLock
  (JSONC, malformed) using the previously orphaned fixtures
- Cover EditorsDetector including glob markers
- Cover cache hit, lockfile-content invalidation, fresh(), no-driver
  fallback, and default-instance isolation on ProjectManager
- Pin normalizeVersion behavior for prerelease/range/protocol shapes
- Add StackDetector branches: inertia vue/svelte, legacy adapter,
  passport, folio/volt API suppression, blade suppression
- Replace in-place fixture renaming with temp-dir copies, drop the
  unused toBeOne expectation and no-op TestCase overrides, and remove
  orphaned fixtures
@pushpak1300
pushpak1300 marked this pull request as ready for review July 6, 2026 13:34
@pushpak1300
pushpak1300 requested a review from WendellAdriel July 8, 2026 10:55
Comment thread src/Detectors/Approaches/Convention.php Resolved
Comment thread src/Support/ApproachSet.php Resolved
pushpak1300 and others added 4 commits July 8, 2026 18:54
Project (the low-level, uncached scan primitive) shared its name with
the Facades\Project facade, so importing the wrong one silently lost
caching. Renaming it to ProjectScan and routing ScanCommand and the
README's non-container example through ProjectManager instead leaves
exactly one obvious public entry point.

Also removes the invokable-vs-resourceful controller-style detector:
its 2-of-7 REST-action-name heuristic was loose enough to misclassify
controllers with just a couple of coincidentally-named custom actions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@joetannenbaum joetannenbaum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good overall. It's a massive PR that I wish was split up into incremental steps that was easier to consume, but from what I see it looks good. Just a couple of questions/comments.

Comment thread src/Detectors/AgentsDetector.php Resolved
Comment thread src/Detectors/Approaches/Convention.php Resolved
Comment thread src/Detectors/ApproachesDetector.php Resolved
Comment thread src/Ecosystems/JsEcosystem.php Resolved
pushpak1300 and others added 5 commits July 16, 2026 13:31
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pushpak1300
pushpak1300 changed the base branch from main to 1.x July 17, 2026 11:52
@pushpak1300
pushpak1300 merged commit 873e1bd into 1.x Jul 17, 2026
13 checks passed
@pushpak1300
pushpak1300 deleted the refactor branch July 17, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@tailwindcss/vite doesn't resolve to tailwindcss being installed Composer::processPackages strips version for Laravel Wayfinder dev-next

3 participants