Move to new file structure

This commit is contained in:
Tobias Nyholm
2025-05-29 12:54:29 +02:00
parent 03d0a33f00
commit d937e789c7
96 changed files with 451 additions and 168 deletions

1
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1 @@
src @chr-hertel @Nyholm

32
.github/ISSUE_TEMPLATE/1-bug_report.md vendored Normal file
View File

@@ -0,0 +1,32 @@
---
name: '🐞 Bug Report'
about: Report a bug in existing features
title: ''
labels: ['Bug']
assignees: ''
---
<!-- ======================== Guidelines ============================
Thank you for taking the time to report a bug! 🙏
Please follow these guidelines to help us understand & fix the issue:
Describe Your Problem 🎯
- Clearly explain the problem you're facing;
- Describe what you expected to happen versus what actually occurred;
- List the steps to reproduce the bug.
Provide Detailed Information 📋
- Share relevant details: Component version, errors, screenshots;
- If possible, provide a minimal reproducer in a GitHub repository.
Be Kind and Respectful 🙂
- Stay patient & open to feedback, and act with kindness and respect;
- Remember that this is a volunteer-driven project.
============================= Guidelines ======================== -->

View File

@@ -0,0 +1,8 @@
---
name: '🚀 Feature Request'
about: Suggest ideas for new features or enhancements
title: ''
labels: ['RFC']
assignees: ''
---

View File

@@ -0,0 +1,9 @@
---
name: '📖 Documentation'
about: Help us improve the documentation!
title: ''
labels: 'docs'
assignees: ''
---

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: 🛟 Support / help
url: https://symfony.com/support
about: Ask your questions about Symfony AI

20
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,20 @@
| Q | A
| ------------- | ---
| Bug fix? | yes/no
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
| Docs? | yes/no <!-- required for new features -->
| Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- For new features, provide some code snippets to help understand usage.
- Features and deprecations must be submitted against branch main.
- Update/add documentation as required (we can help!)
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
- Never break backward compatibility (see https://symfony.com/bc).
-->

64
.github/build-packages.php vendored Normal file
View File

@@ -0,0 +1,64 @@
<?php
/**
* Updates the composer.json files to use the local version of the Symfony AI packages.
*/
require __DIR__.'/../vendor/autoload.php';
use Symfony\Component\Finder\Finder;
$finder = (new Finder())
->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/'])
->depth(0)
->name('composer.json')
;
// 1. Find all AI packages
$aiPackages = [];
foreach ($finder as $composerFile) {
$json = file_get_contents($composerFile->getPathname());
if (null === $packageData = json_decode($json, true)) {
passthru(sprintf('composer validate %s', $composerFile->getPathname()));
exit(1);
}
if (str_starts_with($composerFile->getPathname(), __DIR__ . '/../src/')) {
$packageName = $packageData['name'];
$aiPackages[$packageName] = [
'path' => realpath($composerFile->getPath()),
];
}
}
// 2. Update all composer.json files from the repository, to use the local version of the AI packages
foreach ($finder as $composerFile) {
$json = file_get_contents($composerFile->getPathname());
if (null === $packageData = json_decode($json, true)) {
passthru(sprintf('composer validate %s', $composerFile->getPathname()));
exit(1);
}
$repositories = $packageData['repositories'] ?? [];
foreach ($aiPackages as $packageName => $packageInfo) {
if (isset($packageData['require'][$packageName])
|| isset($packageData['require-dev'][$packageName])
) {
$repositories[] = [
'type' => 'path',
'url' => $packageInfo['path'],
];
$key = isset($packageData['require'][$packageName]) ? 'require' : 'require-dev';
$packageData[$key][$packageName] = '@dev';
}
}
if ($repositories) {
$packageData['repositories'] = $repositories;
}
$json = json_encode($packageData, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
file_put_contents($composerFile->getPathname(), $json."\n");
}

21
.github/workflows/.utils.sh vendored Normal file
View File

@@ -0,0 +1,21 @@
_run_task() {
local ok=0
local title="$1"
local start=$(date -u +%s)
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
local end=$(date -u +%s)
if [[ $ok -ne 0 ]]; then
printf "\n%-70s%10s\n" $title $(($end-$start))s
echo "$OUTPUT"
echo "Job exited with: $ok"
echo -e "\n::error::KO $title\\n"
else
printf "::group::%-68s%10s\n" $title $(($end-$start))s
echo "$OUTPUT"
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
fi
exit $ok
}
export -f _run_task

77
.github/workflows/code-quality.yaml vendored Normal file
View File

@@ -0,0 +1,77 @@
name: Code Quality
on:
push:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
pull_request:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
cs-php:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: php-cs-fixer
- name: php-cs-fixer
run: php-cs-fixer check --diff
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: [ '8.1', '8.2', '8.3', '8.4']
dependency-version: ['']
symfony-version: ['']
minimum-stability: ['stable']
include:
# lowest deps
- php-version: '8.1'
dependency-version: 'lowest'
# LTS version of Symfony
- php-version: '8.1'
symfony-version: '6.4.*'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure environment
run: |
echo COLUMNS=120 >> $GITHUB_ENV
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
echo COMPOSER_VALIDATE='composer validate --strict' >> $GITHUB_ENV
echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV
echo "Packages: $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: flex
- name: Install root dependencies
run: composer install
- name: Build root packages
run: php .github/build-packages.php
- name: Run PHPStan on packages
run: |
source .github/workflows/.utils.sh
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $COMPOSER_VALIDATE && $PHPSTAN)'"

37
.github/workflows/doctor-rst.yaml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: RST Linter
on:
push:
paths:
- '**.rst'
- 'src/*/doc/**'
pull_request:
paths:
- '**.rst'
- 'src/*/doc/**'
jobs:
doctor-rst:
name: DOCtor-RST
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create cache dir
run: mkdir .cache
- name: Extract base branch name
run: echo "branch=$(echo ${GITHUB_BASE_REF:=${GITHUB_REF##*/}})" >> $GITHUB_OUTPUT
id: extract_base_branch
- name: Cache DOCtor-RST
uses: actions/cache@v4
with:
path: .cache
key: doctor-rst-${{ steps.extract_base_branch.outputs.branch }}
- name: DOCtor-RST
uses: docker://oskarstark/doctor-rst
with:
args: --short --error-format=github --cache-file=/github/workspace/.cache/doctor-rst.cache

View File

@@ -1,67 +0,0 @@
name: pipeline
on: pull_request
permissions:
contents: read
pull-requests: write
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.2', '8.3', '8.4']
dependencies: ['lowest', 'highest']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: "none"
- name: Install Composer
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
- name: Composer Validation
run: composer validate --strict
- name: Install PHP Dependencies
run: composer install --no-scripts
- name: Tests
run: vendor/bin/phpunit
qa:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: "none"
- name: Install Composer
uses: "ramsey/composer-install@v3"
- name: Composer Validation
run: composer validate --strict
- name: Install PHP Dependencies
run: composer install --no-scripts
- name: Code Style PHP
run: vendor/bin/php-cs-fixer fix --dry-run
- name: Rector
run: vendor/bin/rector --dry-run
- name: PHPStan
run: vendor/bin/phpstan analyse

70
.github/workflows/unit-tests.yaml vendored Normal file
View File

@@ -0,0 +1,70 @@
name: Unit Tests
on:
push:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
pull_request:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
php:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']
dependency-version: ['']
symfony-version: ['']
minimum-stability: ['stable']
include:
# dev packages (probably not needed to have multiple such jobs)
- minimum-stability: 'dev'
php-version: '8.4'
# lowest deps
- php-version: '8.1'
dependency-version: 'lowest'
# LTS version of Symfony
- php-version: '8.1'
symfony-version: '6.4.*'
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }}
steps:
- uses: actions/checkout@v4
- name: Configure environment
run: |
echo COLUMNS=120 >> $GITHUB_ENV
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
echo PHPUNIT='vendor/bin/phpunit' >> $GITHUB_ENV
[ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak
echo "Packages: $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: flex
- name: Install root dependencies
run: composer install
- name: Build root packages
run: php .github/build-packages.php
- name: Run packages tests
run: |
source .github/workflows/.utils.sh
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT)'"

8
.gitignore vendored
View File

@@ -1,4 +1,6 @@
.phpunit.cache
.doctor-rst.cache
.php-cs-fixer.cache
composer.lock
vendor
.phpunit.result.cache
/composer.lock
/vendor

View File

@@ -1,8 +1,8 @@
<?php
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var')
->in('src')
->exclude(['var', 'vendor'])
;
return (new PhpCsFixer\Config())

View File

@@ -1,4 +1,4 @@
Copyright (c) 2025 Christopher Hertel
Copyright (c) 2025-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,28 +0,0 @@
.PHONY: deps-stable deps-low cs rector phpstan tests coverage run-examples ci ci-stable ci-lowest
deps-stable:
composer update --prefer-stable
deps-low:
composer update --prefer-lowest
cs:
PHP_CS_FIXER_IGNORE_ENV=true vendor/bin/php-cs-fixer fix --diff --verbose
rector:
vendor/bin/rector
phpstan:
vendor/bin/phpstan --memory-limit=-1
tests:
vendor/bin/phpunit
coverage:
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage
ci: ci-stable
ci-stable: deps-stable rector cs phpstan tests
ci-lowest: deps-low rector cs phpstan tests

View File

@@ -1,43 +1,12 @@
{
"name": "php-llm/mcp-sdk",
"type": "library",
"description": "Model Context Protocol SDK for Client and Server applications in PHP",
"name": "symfony/ai",
"license": "MIT",
"authors": [
{
"name": "Christopher Hertel",
"email": "mail@christopher-hertel.de"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com"
}
"keywords": [
"dev"
],
"require": {
"php": "^8.2",
"psr/log": "^3.0",
"symfony/uid": "^6.4 || ^7.0"
},
"require-dev": {
"php-cs-fixer/shim": "^3.70",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.5",
"symfony/console": "^6.4 || ^7.0",
"rector/rector": "^2.0",
"psr/cache": "^3.0"
},
"suggest": {
"symfony/console": "To use SymfonyConsoleTransport for STDIO",
"psr/cache": "To use CachePoolStore with SSE Transport"
},
"autoload": {
"psr-4": {
"PhpLlm\\McpSdk\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PhpLlm\\McpSdk\\Tests\\": "tests/"
}
"php": ">=8.1",
"symfony/filesystem": "^6.4|^7.0",
"symfony/finder": "^6.4|^7.0"
}
}

View File

@@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitSelfCallRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
return RectorConfig::configure()
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
])
->withPhpSets(php82: true)
->withSets([
PHPUnitSetList::PHPUNIT_110,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
])
->withRules([
PreferPHPUnitSelfCallRector::class,
])
->withImportNames(importShortClasses: false)
->withSkip([
ClosureToArrowFunctionRector::class,
PreferPHPUnitThisCallRector::class,
])
->withTypeCoverageLevel(0);

View File

@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/symfony/ai
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!

View File

@@ -0,0 +1,20 @@
name: Close Pull Request
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.
However, you should instead open your PR on the main repository:
https://github.com/symfony/ai
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!

4
src/mcp-sdk/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.phpunit.cache
.php-cs-fixer.cache
composer.lock
vendor

19
src/mcp-sdk/LICENSE Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2025-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

42
src/mcp-sdk/composer.json Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "php-llm/mcp-sdk",
"type": "library",
"description": "Model Context Protocol SDK for Client and Server applications in PHP",
"license": "MIT",
"authors": [
{
"name": "Christopher Hertel",
"email": "mail@christopher-hertel.de"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com"
}
],
"require": {
"php": "^8.2",
"psr/log": "^3.0",
"symfony/uid": "^6.4 || ^7.0"
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.5",
"symfony/console": "^6.4 || ^7.0",
"rector/rector": "^2.0",
"psr/cache": "^3.0"
},
"suggest": {
"symfony/console": "To use SymfonyConsoleTransport for STDIO",
"psr/cache": "To use CachePoolStore with SSE Transport"
},
"autoload": {
"psr-4": {
"PhpLlm\\McpSdk\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PhpLlm\\McpSdk\\Tests\\": "tests/"
}
}
}