Download the PHP package kngbwsr/laravel-agent-optimizer without Composer

On this page you can find all versions of the php package kngbwsr/laravel-agent-optimizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-agent-optimizer

Laravel Agent Optimizer

A Laravel package that optimizes AI agent directive files by extracting large guideline sections into modular rule files, keeping your top-level agent directives lean and focused.

Works seamlessly with Laravel Boost-generated agent directive files and automatically re-runs after configured trigger commands (e.g. boost:update, boost:install).


Features


Requirements


Installation

Install the package via Composer:

Laravel's auto-discovery will register the service provider automatically.

One-step setup

Run the install command to publish the config file and add the post-update-cmd entry to composer.json in one step:

This does two things:

  1. Publishes config/agent-optimizer.php to your application (skipped if already published)
  2. Adds @php artisan optimizeAgents:optimize --ansi to the post-update-cmd array in composer.json

To remove the post-update-cmd entry later:

Note: Auto-discovery means the package is fully functional before you run optimizeAgents:install. The command is a convenience for initial project setup only — it combines the config publish and the composer.json edit into a single step.


Output folder

All generated files are written to a dedicated agent-optimized/ folder inside your configured base_path:

On each optimizeAgents:optimize run a smart preflight step runs before any extraction. If the agent files contain sections already marked as optimized the corresponding rule files are preserved; only orphaned or stale files are removed. When agent files are regenerated fresh (e.g. after boost:update) no markers are present and the entire agent-optimized/ folder is wiped and recreated.


Configuration

After running optimizeAgents:install (or php artisan vendor:publish --tag=agent-optimizer-config), config/agent-optimizer.php exposes the following options:

Paths & file discovery

Generated file naming

Extraction behaviour

Reference pretext labels

Controls the label inserted before every rule file path in placeholder lines.

The special token <title> may be used anywhere in a label string and is replaced at runtime with the actual section or sub-section title (the text between the === ... === markers, without the equals signs). For example, '**RULES for <title>:**' becomes **RULES for My Section:** in the output file.

Example — embedding the title and using custom labels per strategy:

Header notes

Controls the Markdown note prepended to agent directive files and generated rule files when sections are first extracted.

Note: if you change either of these values after files have already been optimized, run php artisan optimizeAgents:reset first so the old header is removed before the new one is written.

Laravel Boost integration


Usage

Basic run

Scans all configured source_directories for agent directive Markdown files, extracts qualifying sections to {base_path}/agent-optimized/, and replaces each extracted block with a configurable reference placeholder.

Preview without writing files

Reports every section that would be extracted without modifying any file.

Override the root directory

Useful when running the command outside the project root.

Override the minimum line threshold

Overrides line_threshold from config for this run only.

Combined example


Reset

Performs a clean reset of the optimizer's output:

  1. Deletes the entire agent-optimized/ folder and all files within it
  2. Runs the first configured boost_trigger_commands entry (default: boost:update) so Boost regenerates the original agent directive files
  3. Does not re-run optimizeAgents:optimize afterwards, even if auto_run_after_boost is true

Use reset when:


How it works

  1. Preflight: the command scans agent files for <!-- agent-optimized --> markers. Rule files for already-extracted sections are preserved; orphaned files are deleted. When no markers exist (e.g. after a fresh boost:update) the entire agent-optimized/ folder is wiped and recreated.
  2. The command scans each configured directory for *.md files that contain at least one === title === section boundary.
  3. Each section is parsed and checked against the configured exceptions list and line_threshold. Sections that already carry the <!-- agent-optimized --> marker are skipped.
  4. The configured extraction strategy (global or per-section override) determines how the section is extracted:
    • A rule file is written to {base_path}/agent-optimized/ using the configured rule_file_prefix and rule_file_extension.
    • The original section body is replaced with a reference placeholder using the configured pretext label and the file path.
    • The agent_file_header note is prepended to the source agent directive file (once, on first extraction).
    • The rule_file_header note is prepended to each top-level _rule_*.md file (not to _subsection_*.md files).
  5. If the source file was modified (or needs a header added) it is written back to disk.

Extraction strategies

Strategy Behaviour
full_section Entire section body → single flat rule file. One placeholder replaces the whole block.
nested_full Full section extracted to a master file; each qualifying sub-header gets its own file in a rule_file_prefix + slug/ subdirectory. One placeholder at the extraction site.
nested_subsections Qualifying sub-headers extracted individually into a subdirectory. The main header and its direct body stay in the source file; each sub-header is replaced with an inline reference.
nested_split Like nested_subsections but the main section body is also extracted to its own root-level rule file. Only the header title and sub-header references remain in-place.
auto No sub-headers detected → full_section. Sub-headers detected → strategy from auto_nested_strategy (default nested_full).

Boost integration detail

The auto_run_after_boost listener fires on the CommandFinished event after any command listed in boost_trigger_commands. This keeps extracted rule files in sync whenever Boost regenerates your agent directive files from Artisan.

The post-update-cmd entry added by optimizeAgents:install handles the case where composer update itself triggers a Boost update cycle.

optimizeAgents:reset suppresses the auto_run_after_boost listener for the boost run it triggers, so the reset leaves files in a clean unoptimized state rather than immediately re-optimizing.


License

MIT


All versions of laravel-agent-optimizer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/console Version ^13.0
illuminate/support Version ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kngbwsr/laravel-agent-optimizer contains the following files

Loading the files please wait ...