carono/yii2-ai-dialog

Yii2 widget that embeds an AI assistant dialog for use during development

Maintainers

Package info

github.com/carono/yii2-ai-dialog

Chat

Forum

Wiki

Type:yii2-extension

pkg:composer/carono/yii2-ai-dialog

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-06-07 14:45 UTC

This package is auto-updated.

Last update: 2026-06-07 14:53:30 UTC


README

Yii

Yii AI Dialog


Latest Stable Version Total Downloads Build status Code Coverage Mutation testing badge Static analysis type-coverage psalm-level

This package embeds the ai-dialog AI chat widget into a Yii2 application: a 💬 button in the page corner that sends the current page context to a shared gateway and streams the answer back. It is wired up like the debug toolbar — through bootstrap in the dev section of the config, guarded by IP. Nothing is added to the project's code (layout, assets): the widget bundle widget.js is pulled in as an npm-asset Composer dependency and wired up automatically.

🇷🇺 Документация на русском: docs/README.ru.md.

Requirements

  • PHP 8.1 or higher.

Installation

The widget bundle is distributed as an npm-asset (npm-asset/carono-ai-dialog-widget) and pulled in by Composer. Because Composer does not inherit repositories from dependencies, the consuming project's composer.json must enable asset-packagist once:

{
    "repositories": [
        { "type": "composer", "url": "https://asset-packagist.org" }
    ],
    "config": {
        "allow-plugins": {
            "composer/installers": true,
            "oomphinc/composer-installers-extender": true
        }
    },
    "extra": {
        "installer-types": ["npm-asset"],
        "installer-paths": {
            "vendor/npm-asset/{$name}": ["type:npm-asset"]
        }
    }
}

Then:

composer require carono/yii2-ai-dialog

If Composer reports npm-asset/carono-ai-dialog-widget could not be found, asset-packagist has not indexed the package yet. As a temporary workaround add an inline repository to the project and re-run require:

{
    "type": "package",
    "package": {
        "name": "npm-asset/carono-ai-dialog-widget",
        "version": "0.2.0",
        "type": "npm-asset",
        "dist": { "type": "tar", "url": "https://registry.npmjs.org/carono-ai-dialog-widget/-/carono-ai-dialog-widget-0.2.0.tgz" }
    }
}

Setup

All configuration lives in the config, in the dev section. As with yii2-debug, wrap the registration in YII_ENV_DEV so the widget never reaches production.

config/web.php:

$config = [ /* ... */ ];

if (YII_ENV_DEV) {
    $config['bootstrap'][] = 'aiDialog';
    $config['modules']['aiDialog'] = [
        'class'   => \Carono\AiDialog\Module::class,
        'project' => 'myapp',          // = the project key in the gateway's projects.json
        'token'   => 'project-secret', // = this project's token on the gateway
        // optional:
        // 'gateway'    => 'wss://wss.carono.site', // gateway address (this is the default)
        // 'allowedIPs' => ['127.0.0.1', '::1'],    // who sees the widget (same as debug)
        // 'enabled'    => true,                    // master switch
    ];

    // usually already present for debug/gii:
    // $config['bootstrap'][] = 'debug';
    // $config['modules']['debug'] = ['class' => \yii\debug\Module::class];
}

Three values must match the gateway side (projects.json):

Module option What it is Must match
project project identifier the object key in projects.json
token project secret the token field of that project
gateway WebSocket gateway address the shared wss://wss.carono.site

Registering a project on the gateway and the overall architecture are described in docs/INTEGRATION.md of the ai-dialog repository. In short: add a project entry to projects.json and restart the gateway.

How it works

The module implements BootstrapInterface. On every request it checks the client IP against allowedIPs (the same logic as yii\debug\Module) and, if access is allowed and the response is a regular HTML page, appends a <script src=".../widget.js" data-project data-gateway data-token> tag at the end of <body>. JSON/AJAX responses are left untouched.

Widget access is restricted by allowedIPs only; that is enough for local development. Protection of the gateway itself (the project token) lives on its side.

Documentation

If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.

License

The Yii AI Dialog is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack