Skip to content

Commit cdf6f08

Browse files
authored
Merge pull request #56 from Ardenexal/claude/generate-extension-classes-SLUWW
feat: add fhir:generate-ig command for IG extension and profile class generation
2 parents 2284160 + 194fcc4 commit cdf6f08

3,745 files changed

Lines changed: 189863 additions & 475 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mcp.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"mcpServers": {
3+
"symfony-ai-mate": {
4+
"command": "php",
5+
"args": [
6+
"vendor/symfony/ai-mate/bin/mate.php",
7+
"serve"
8+
]
9+
}
10+
11+
}
12+
}

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,10 @@ Before submitting changes, confirm:
178178
- **FHIRBundle Guide**: `/docs/component-guides/fhir-bundle.md` - Symfony integration
179179
- **CodeGeneration Guide**: `/docs/component-guides/code-generation.md` - Standalone generation
180180
- **Serialization Guide**: `/docs/component-guides/serialization.md` - JSON serialization
181+
182+
<!-- BEGIN AI_MATE_INSTRUCTIONS -->
183+
AI Mate Summary:
184+
- Role: MCP-powered, project-aware coding guidance and tools.
185+
- Required action: Read and follow `mate/AGENT_INSTRUCTIONS.md` before taking any action in this project, and prefer MCP tools over raw CLI commands whenever possible.
186+
- Installed extensions: matesofmate/phpstan-extension, matesofmate/phpunit-extension, symfony/ai-mate, symfony/ai-symfony-mate-extension.
187+
<!-- END AI_MATE_INSTRUCTIONS -->

CLAUDE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,10 @@ $context = FHIRSerializationContext::forJson()
170170
- Use conventional commits: `feat:`, `fix:`, `chore:`, `test:`
171171
- No AI mentions in commits or PRs
172172
- Sign commits with GPG when possible
173+
174+
<!-- BEGIN AI_MATE_INSTRUCTIONS -->
175+
AI Mate Summary:
176+
- Role: MCP-powered, project-aware coding guidance and tools.
177+
- Required action: Read and follow `mate/AGENT_INSTRUCTIONS.md` before taking any action in this project, and prefer MCP tools over raw CLI commands whenever possible.
178+
- Installed extensions: matesofmate/phpstan-extension, matesofmate/phpunit-extension, symfony/ai-mate, symfony/ai-symfony-mate-extension.
179+
<!-- END AI_MATE_INSTRUCTIONS -->

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ If you've installed `ardenexal/fhir-bundle` in your Symfony application:
5151
# Generate FHIR models
5252
php bin/console fhir:generate --package=hl7.fhir.r4.core -vvv
5353

54+
# Generate typed classes for an Implementation Guide
55+
php bin/console fhir:generate-ig --package=hl7.fhir.us.core
56+
5457
# Evaluate FHIRPath expressions
5558
php bin/console fhir:path:evaluate "5 + 3"
5659

@@ -146,7 +149,8 @@ When you install `ardenexal/fhir-bundle` in your Symfony application, you get th
146149

147150
| Command | Description |
148151
|---------|-------------|
149-
| `fhir:generate` | Generate PHP model classes from FHIR packages |
152+
| `fhir:generate` | Generate PHP model classes from FHIR packages (R4, R4B, R5) |
153+
| `fhir:generate-ig` | Generate typed extension and profile classes for FHIR IGs |
150154
| `fhir:path:evaluate` | Evaluate a FHIRPath expression against FHIR data |
151155
| `fhir:path:validate` | Validate FHIRPath expression syntax |
152156

bin/codex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
6+
PROJECT_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
7+
8+
if ! command -v codex >/dev/null 2>&1; then
9+
echo "Codex CLI is not installed or not available in PATH." >&2
10+
echo "Install Codex and try again." >&2
11+
exit 1
12+
fi
13+
14+
cd "$PROJECT_DIR"
15+
16+
exec codex \
17+
-c "mcp_servers.symfony_ai_mate_local.command='./vendor/bin/mate'" \
18+
-c "mcp_servers.symfony_ai_mate_local.args=['serve','--force-keep-alive']" \
19+
"$@"

bin/codex.bat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@echo off
2+
setlocal
3+
4+
set "SCRIPT_DIR=%~dp0"
5+
for %%I in ("%SCRIPT_DIR%..") do set "PROJECT_DIR=%%~fI"
6+
7+
where codex >nul 2>nul
8+
if errorlevel 1 (
9+
echo Codex CLI is not installed or not available in PATH. 1>&2
10+
echo Install Codex and try again. 1>&2
11+
exit /b 1
12+
)
13+
14+
pushd "%PROJECT_DIR%" >nul
15+
codex -c "mcp_servers.symfony_ai_mate_local.command='./vendor/bin/mate'" -c "mcp_servers.symfony_ai_mate_local.args=['serve','--force-keep-alive']" %*
16+
set "CODE=%ERRORLEVEL%"
17+
popd >nul
18+
19+
exit /b %CODE%

composer.json

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"amphp/http-client": "^5.3.4",
2828
"brick/date-time": "^0.9.0",
2929
"composer/semver": "^3.4.4",
30+
"matesofmate/composer-extension": "^0.2.0",
31+
"matesofmate/phpstan-extension": "^0.2.0",
3032
"nette/php-generator": "^4.2.1",
3133
"psr/cache": "^3.0",
3234
"psr/http-client": "^1.0",
@@ -49,20 +51,25 @@
4951
"require-dev": {
5052
"fhir/fhir-test-cases": "1.7.49",
5153
"giorgiosironi/eris": "^1.0",
54+
"helgesverre/toon": "^3.1",
5255
"laravel/pint": "^1.27.1",
56+
"matesofmate/phpunit-extension": "^0.2.0",
5357
"phpbench/phpbench": "^1.4",
5458
"phpstan/phpstan": "^2.1.39",
5559
"phpstan/phpstan-symfony": "^2.0.14",
5660
"phpunit/phpunit": "^11.0|^12.5.14",
5761
"roave/security-advisories": "dev-latest",
62+
"symfony/ai-mate": "^0.7.0",
63+
"symfony/ai-symfony-mate-extension": "^0.7.0",
5864
"symfony/browser-kit": "^6.4|^7.4.4",
5965
"symfony/css-selector": "^6.4|^7.4",
6066
"symfony/dom-crawler": "^6.4|^7.4.4",
6167
"symfony/phpunit-bridge": "^6.4|^7.4.3"
6268
},
6369
"config": {
6470
"allow-plugins": {
65-
"php-http/discovery": true
71+
"php-http/discovery": true,
72+
"symfony/ai-mate-composer-plugin": true
6673
},
6774
"bump-after-update": true,
6875
"sort-packages": true
@@ -83,7 +90,8 @@
8390
"Ardenexal\\FHIRTools\\Bundle\\FHIRBundle\\Tests\\": "src/Bundle/FHIRBundle/tests/",
8491
"Ardenexal\\FHIRTools\\Component\\FHIRPath\\Tests\\": "src/Component/FHIRPath/tests/",
8592
"Ardenexal\\FHIRTools\\Component\\Serialization\\Tests\\": "src/Component/Serialization/tests/",
86-
"Ardenexal\\FHIRTools\\Benchmarks\\": "bench/"
93+
"Ardenexal\\FHIRTools\\Benchmarks\\": "bench/",
94+
"App\\Mate\\": "mate/src/"
8795
}
8896
},
8997
"replace": {
@@ -109,7 +117,7 @@
109117
"phpstan-ai:fhir-path": "php scripts/ai-phpstan-runner.php src/Component/FHIRPath/",
110118
"lint": "php ./vendor/bin/pint -v --parallel --max-processes=4",
111119
"lint:bundle": "php ./vendor/bin/pint src/Bundle/ -v --parallel --max-processes=4",
112-
"lint:models": "php ./vendor/bin/pint src/Component/Models -v --parallel --max-processes=4",
120+
"lint:models": "php ./vendor/bin/pint src/Component/Models -v",
113121
"lint:codegen": "php ./vendor/bin/pint src/Component/CodeGeneration/ -v --parallel --max-processes=4",
114122
"lint:serialization": "php ./vendor/bin/pint src/Component/Serialization/ -v --parallel --max-processes=4",
115123
"lint:fhir-path": "php ./vendor/bin/pint src/Component/FHIRPath/ -v --parallel --max-processes=4",
@@ -164,22 +172,25 @@
164172
"@quality:serialization",
165173
"@quality:fhir-path"
166174
],
175+
"generate-ig-au-base": "php ./demo/bin/console fhir:generate-ig --package=hl7.fhir.au.base -vvv",
176+
"generate-ig-au-core": "php ./demo/bin/console fhir:generate-ig --package=hl7.fhir.au.base --package=hl7.fhir.au.core -vvv",
177+
"generate-ig-us-core": "php ./demo/bin/console fhir:generate-ig --package=hl7.fhir.us.core -vvv",
167178
"generate-models": "php ./demo/bin/console fhir:generate -vvv",
168179
"generate-models-all": [
169180
"echo 'Generating FHIR R4 models...'",
170-
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r4.core --package=hl7.fhir.r4b.core --package=hl7.fhir.r5.core -vvv",
181+
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r4.core --package=hl7.fhir.uv.extensions.r4 --package=hl7.fhir.r4b.core --package=hl7.fhir.uv.extensions.r4b --package=hl7.fhir.r5.core --package=hl7.fhir.uv.extensions.r5 -vvv",
171182
"echo 'All FHIR models generated successfully!'"
172183
],
173184
"generate-models-r4": [
174-
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r4.core -vvv",
185+
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r4.core --package=hl7.fhir.uv.extensions.r4 -vvv",
175186
"@lint:models"
176187
],
177188
"generate-models-r4b": [
178-
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r4b.core -vvv",
189+
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r4b.core --package=hl7.fhir.uv.extensions.r4b -vvv",
179190
"@lint:models"
180191
],
181192
"generate-models-r5": [
182-
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r5.core -vvv",
193+
"php ./demo/bin/console fhir:generate --package=hl7.fhir.r5.core --package=hl7.fhir.uv.extensions.r5 -vvv",
183194
"@lint:models"
184195
],
185196
"fix-newlines": "powershell -ExecutionPolicy Bypass -File scripts/fix-newlines.ps1",
@@ -192,5 +203,16 @@
192203
"bench:fhirpath": "php ./vendor/bin/phpbench run bench/FHIRPath/ --report=aggregate",
193204
"bench:baseline": "php ./vendor/bin/phpbench run bench/ --report=aggregate --store --tag=baseline",
194205
"bench:regression": "php ./vendor/bin/phpbench run bench/ --report=compare --ref=baseline --assert=\"mode(variant.time.avg) < mode(baseline.time.avg) * 1.50\""
206+
},
207+
"extra": {
208+
"ai-mate": {
209+
"extension": false,
210+
"scan-dirs": [
211+
"mate/src"
212+
],
213+
"includes": [
214+
"mate/config.php"
215+
]
216+
}
195217
}
196218
}

demo/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Override root .gitignore — the demo app's lock file should be tracked
33
!composer.lock
44

5+
# Generated FHIR IG classes (run `composer generate-ig-*` to regenerate)
6+
/src/FHIRIG/
7+
58
###> symfony/framework-bundle ###
69
/.env.local
710
/.env.local.php

demo/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
},
4747
"autoload": {
4848
"psr-4": {
49+
"App\\FHIR\\IG\\": "src/FHIRIG/",
4950
"App\\": "src/",
5051
"Ardenexal\\FHIRTools\\Bundle\\FHIRBundle\\": "../src/Bundle/FHIRBundle/src/",
5152
"Ardenexal\\FHIRTools\\Component\\CodeGeneration\\": "../src/Component/CodeGeneration/src/",

demo/config/packages/fhir.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@ fhir:
33
validation:
44
enabled: true
55
strict_mode: false
6+
7+
# Implementation Guide generation — run: php bin/console fhir:generate-ig --package=hl7.fhir.au.base
8+
# Or use the root composer scripts: composer generate-ig-au-base, generate-ig-au-core, generate-ig-us-core
9+
# After generation, clear the Symfony cache: php bin/console cache:clear
10+
ig:
11+
namespace: 'App\FHIR\IG' # must match PSR-4 autoload in composer.json
12+
output_directory: '%kernel.project_dir%/src/FHIRIG'
13+
offline: false # set true to skip network downloads
14+
packages: [] # specify in dependency order via CLI --package args

0 commit comments

Comments
 (0)