PHP code example of agelgil / watchman

1. Go to this page and download the library: Download agelgil/watchman library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

agelgil / watchman example snippets


'channels' => [
    'watchman' => [
        'driver' => 'slack',
        'url' => env('LOG_SLACK_WEBHOOK_URL'),
        'level' => 'warning',
    ],
],

use Illuminate\Support\Facades\Schedule;

Schedule::command('watchman')->hourly()->withoutOverlapping();

Schedule::command('watchman "audit routes/api.php for missing authorization"')->weekly();

'lab'   => env('WATCHMAN_LAB', 'openrouter'),   // openrouter | anthropic | openai | …
'model' => env('WATCHMAN_MODEL', 'deepseek/deepseek-chat'),

'tools' => [
    'read_file' => true, 'write_file' => true, 'list_dir' => true,
    'glob' => true, 'search_content' => true, 'tail_file' => true,
    'file_size' => true, 'fetch' => true, 'introspect' => true,
    'system_metrics' => true, 'git_changes' => true, 'report' => true,
    'open_pr' => true, 'list_pr' => true,
],
// Read-only artisan commands introspect() may run:
'introspect_allowlist' => ['about', 'route:list', 'schedule:list', 'migrate:status', 'db:show'],

'github' => [
    'token'   => env('WATCHMAN_GITHUB_TOKEN'),
    'repo'    => env('WATCHMAN_GITHUB_REPO'),   // e.g. "acme/storefront"
    'api_url' => env('WATCHMAN_GITHUB_API_URL', 'https://api.github.com'),
],

'reporting' => [
    'telegram' => [
        'bot_token'  => env('WATCHMAN_TELEGRAM_BOT_TOKEN'),
        // Comma-separated "chat_id[:thread_id]" or "@channelusername"
        'recipients' => (string) env('WATCHMAN_TELEGRAM_RECIPIENTS', ''),
        // Pause between successive messages of a multi-message report
        'chunk_pacing_ms' => (int) env('WATCHMAN_TELEGRAM_CHUNK_PACING_MS', 300),
    ],
],

'prompt_path' => env('WATCHMAN_PROMPT_PATH'),

'read_root'    => env('WATCHMAN_READ_ROOT', base_path()),                  // read-only root
'storage_path' => env('WATCHMAN_STORAGE_PATH', storage_path('watchman')),  // the ONLY writable dir

'sandbox' => [
    'memory_limit' => (int) env('WATCHMAN_LUA_MEMORY', 32 * 1024 * 1024),  // per run_lua call
    'cpu_limit'    => (float) env('WATCHMAN_LUA_CPU', 10.0),                // seconds, per call
],

'web_timeout' => (int) env('WATCHMAN_WEB_TIMEOUT', 30),                     // per-fetch hang guard, seconds

'limits' => [
    'glob_matches'   => (int) env('WATCHMAN_GLOB_MATCHES', 5000),
    'search_files'   => (int) env('WATCHMAN_SEARCH_FILES', 2000),
    'search_matches' => (int) env('WATCHMAN_SEARCH_MATCHES', 500),
    'file_bytes'     => (int) env('WATCHMAN_FILE_BYTES', 1_048_576),   // per-file cap: read_file / tail_file / search_content
    'fetch_bytes'    => (int) env('WATCHMAN_FETCH_BYTES', 1_048_576),  // fetch() response-body cap
],

use Agelgil\Watchman\Agents\Watchman;
use Laravel\Ai\Attributes\{MaxSteps, Temperature};

#[MaxSteps(20)]
#[Temperature(0.0)]
final class TighterWatchman extends Watchman {}

// In a service provider's register():
$this->app->bind(Watchman::class, TighterWatchman::class);
shell
php artisan watchman
shell
php artisan watchman "review the last 10 commits for bugs and write a report"
php artisan watchman "summarise what app/Domain/Billing does and flag anything risky"
php artisan watchman "audit routes/api.php and its controllers for missing authorization"