This is an automated email from the ASF dual-hosted git repository.

luigidemasi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kit.git

commit 0941b1d404c84433b382e137d0ce40fc2dce2eda
Author: Luigi De Masi <[email protected]>
AuthorDate: Tue Dec 1 09:27:23 2026 +0100

    Fix #201: Package selected skill packs in the Camel CLI plugin
    
    Check the catalog inputs before shading and exercise the installed artifact
    through independent Maven, Camel Launcher and JBang consumers.
    
    Co-authored-by: OpenAI Codex <[email protected]>
---
 .github/workflows/build.yml                        | 31 +++++++
 CHANGELOG.md                                       |  3 +
 docs/modules/ROOT/pages/contributing.adoc          |  8 ++
 docs/modules/ROOT/pages/getting-started.adoc       | 15 ++++
 docs/modules/ROOT/pages/mcp.adoc                   |  4 +-
 docs/releasing.md                                  | 16 ++++
 kit/camel-jbang-plugin-kit/pom.xml                 | 94 ++++++++++++++++++++++
 .../src/build-tools/CheckPackOrigins.java          | 65 +++++++++++++++
 .../src/it/consumer/VerifyPlugin.java              | 81 +++++++++++++++++++
 kit/camel-jbang-plugin-kit/src/it/consumer/pom.xml | 14 ++++
 tools/verify_camel_launcher.py                     | 58 ++++++++++---
 tools/verify_installed_plugin.py                   | 43 ++++++++++
 12 files changed, 420 insertions(+), 12 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 837f599a..11a45f3c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -46,12 +46,43 @@ jobs:
       - name: Build and certify Ship payloads
         run: ./mvnw -B -V -Plinux-ship-certification -Dformat.skip=true 
-Deval.requireVectors=true clean install
 
+      - name: Resolve and exercise the installed Kit plugin
+        run: python3 tools/verify_installed_plugin.py
+
+      - name: Install the plugin through both Camel hosts and query the catalog
+        if: matrix.java == '21'
+        run: |
+          set -euo pipefail
+          host_version=$(sed -n 's/^camel.cli.version=//p' 
distribution.properties)
+          kit_version=$(./mvnw -q -f kit/pom.xml -N help:evaluate 
-Dexpression=project.version -DforceStdout)
+          ./mvnw -B -N dependency:copy -Dmdep.useBaseVersion=true 
-Dartifact="org.apache.camel:camel-launcher:$host_version:zip:bin" 
-DoutputDirectory="$RUNNER_TEMP"
+          unzip -q "$RUNNER_TEMP/camel-launcher-$host_version-bin.zip" -d 
"$RUNNER_TEMP/kit-host"
+          
launcher="$RUNNER_TEMP/kit-host/camel-launcher-$host_version/bin/camel.sh"
+          chmod +x "$launcher"
+          common=(--plugin 
"org.apache.camel:camel-jbang-plugin-kit:$kit_version" --maven-repository 
"$HOME/.m2/repository")
+          PATH="$JAVA_HOME/bin:/usr/bin:/bin" python3 
tools/verify_camel_launcher.py --launcher "$launcher" \
+            "${common[@]}" --work-dir "$RUNNER_TEMP/kit-launcher" 
--knowledge-index "$PWD/knowledge/index/src/main/resources/knowledge-index"
+
+          # Use the same JBang distribution as the published snapshot smoke 
test.
+          container=$(docker create 
docker.io/jbangdev/jbang-action:0.139.3@sha256:f5d2d51955d4b6c8ed005b880e6b5f48f0322585298d7e3c146f8241e2d44b01)
+          docker cp "$container:/jbang/bin" "$RUNNER_TEMP/jbang-bin"
+          docker rm "$container"
+          export PATH="$RUNNER_TEMP/jbang-bin:$PATH" 
KIT_HOST_VERSION="$host_version"
+          cat > "$RUNNER_TEMP/jbang-bin/camel" <<'EOF'
+          #!/bin/sh
+          exec jbang run --repos 
maven-central=https://repo.maven.apache.org/maven2/,apache-snapshots=https://repository.apache.org/snapshots
 --main main.CamelJBang "org.apache.camel:camel-jbang-main:$KIT_HOST_VERSION" 
"$@"
+          EOF
+          chmod +x "$RUNNER_TEMP/jbang-bin/camel"
+          python3 tools/verify_camel_launcher.py --jbang-host 
"$RUNNER_TEMP/jbang-bin/camel" \
+            "${common[@]}" --work-dir "$RUNNER_TEMP/kit-jbang"
+
       - name: Upload build artifacts
         if: success() && matrix.java == '21'
         uses: actions/[email protected]
         with:
           name: build-artifacts-java${{ matrix.java }}-${{ github.sha }}
           path: |
+            kit/camel-jbang-plugin-kit/target/camel-jbang-plugin-kit-*.jar
             kit/camel-kit-main/target/*.jar
             kit/camel-kit-core/target/*.jar
             knowledge/mcp/target/*-runner.jar
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fff169b0..ff32ce21 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,9 @@ and this project adheres to [Semantic 
Versioning](https://semver.org/spec/v2.0.0
 
 ### Changed
 
+- The development Camel CLI plugin ships its skill catalog, parser providers 
and runtime dependencies in one JAR
+  for JBang and Camel Launcher. Packaging rejects duplicate pack resources and 
verifies Mule parsing from the built JAR (#201).
+
 - `init --camel-cli=jbang|launcher` selects and saves the Camel CLI backend. 
Launcher workspaces use
   managed Java runners for MCP and verify Main with a fixed-version Camel 
executable (#110). Standalone init
   can use JBang with no `camel` on PATH. Doctor reports narrowed MCP tool 
lists as warnings.
diff --git a/docs/modules/ROOT/pages/contributing.adoc 
b/docs/modules/ROOT/pages/contributing.adoc
index 4ec7aa3a..a1bf3ebd 100644
--- a/docs/modules/ROOT/pages/contributing.adoc
+++ b/docs/modules/ROOT/pages/contributing.adoc
@@ -284,6 +284,14 @@ at that path. With the standard Kit alone, the loader uses 
`META-INF/camel-kit/d
 To select additional packs while building core itself, add the pack modules as 
build/runtime dependencies and set
 `-Dcamel.kit.packs=pack-a,pack-b`. This property supplies the complete 
selection beyond core. See xref:architecture.adoc#skill-packs[how the catalog 
reaches the assistant].
 
+The Kit release packages the selected catalog and its runtime dependencies in 
the main
+`camel-jbang-plugin-kit` artifact. To ship a separately composed catalog such 
as the example above, add its
+Maven module as a dependency of the plugin distribution. Supply one 
`META-INF/camel-kit/catalog.zip`.
+The plugin build checks the original artifacts for duplicate pack resources 
and provider classes before combining them.
+The diagnostic identifies the path and both owners. Remove the duplicate 
dependency or give the resource its own path.
+Maven `verify` loads the final JAR in isolation and parses a Mule fixture. 
After installing Kit, run
+`python3 tools/verify_installed_plugin.py` from the checkout to repeat the 
check using a fresh Maven consumer.
+
 [[migration-parser]]
 === Contributing a migration parser
 
diff --git a/docs/modules/ROOT/pages/getting-started.adoc 
b/docs/modules/ROOT/pages/getting-started.adoc
index 3df9f0e0..165419d0 100644
--- a/docs/modules/ROOT/pages/getting-started.adoc
+++ b/docs/modules/ROOT/pages/getting-started.adoc
@@ -56,6 +56,21 @@ in place of the quoted Unix path.
 "/path to Camel/bin/camel.sh" kit init orders --ai qwen --camel-cli=launcher 
--with-citrus-mcp
 ----
 
+Both the Aesh-based Camel JBang host and Camel Launcher install the same 
development plugin GAV.
+Its fat JAR contains the selected skill catalog, guides, parser classes and 
graph adapters. The Camel CLI host
+supplies Aesh and JLine. On a machine without JBang, use the Launcher script 
above and a full JDK.
+In a workspace initialized by the plugin, verify the installed Mule parser 
against a Mule source directory:
+
+[source,bash]
+----
+camel kit graph generate --project-dir /path/to/mule-project --require-parser 
mule-xml
+camel kit graph find --type mule:flow --graph-file 
/path/to/mule-project/.camel-kit/project-graph.json
+----
+
+With Launcher, replace `camel` with its distribution script in both commands. 
The second command lists the
+flows the parser recognized. A missing required parser fails generation and 
names its provider ID.
+Check the installed plugin GAV and the pack selection if you see that 
diagnostic.
+
 Doctor warns about a runtime version mismatch during planning. Once the 
workspace contains a Main project, a mismatch fails the check. Before running 
Doctor on a Main project, set `CAMEL_KIT_LAUNCHER` to the executable that 
matches the project Camel version.
 Camel 4.22.1 and the development Kit plugin use different plugin APIs. If you 
use both under one account,
 keep the 4.24 Kit host in your regular Java home and isolate the 4.22.1 
runtime's plugin registry.
diff --git a/docs/modules/ROOT/pages/mcp.adoc b/docs/modules/ROOT/pages/mcp.adoc
index 728a97f7..5e48b5d9 100644
--- a/docs/modules/ROOT/pages/mcp.adoc
+++ b/docs/modules/ROOT/pages/mcp.adoc
@@ -38,7 +38,9 @@ start that server online. To refresh a development snapshot, 
remove its entry be
 
 To run the packaged Qwen acceptance test from a source checkout, use a shell 
with a JDK and no JBang on PATH.
 Run `python3 tools/verify_camel_launcher.py --help` for the Launcher path, 
plugin coordinate, and optional
-local Maven repository and Knowledge index. The test installs the plugin and 
queries all three servers twice.
+local Maven repository and Knowledge index. The test installs the plugin, runs 
the installed migration guide's flow inventory on a Mule fixture, and queries 
all three servers twice.
+Use `--jbang-host /path/to/camel` with an Aesh-compatible JBang host to verify 
the same migration and query the
+Camel component catalog through the generated JBang runner.
 
 The distribution configures these runner coordinates.
 
diff --git a/docs/releasing.md b/docs/releasing.md
index 2f0e3af9..89b2c7b7 100644
--- a/docs/releasing.md
+++ b/docs/releasing.md
@@ -27,6 +27,22 @@ Repeat the catalog checks for all shipped runtime profiles 
and the documented Re
 runner and results in `docs/modules/ROOT/pages/mcp.adoc` and update the 
unreleased entry in `CHANGELOG.md`.
 Generated integration pins are independent.
 
+For Kit, install the candidate and run `python3 
tools/verify_installed_plugin.py`. This resolves the published
+POM shape in an independent Maven project and checks the duplicate-pack 
diagnostic. Repeat the packaged migration
+and MCP checks with the candidate GAV on both Camel hosts when a module 
version changes:
+
+```bash
+python3 tools/verify_camel_launcher.py --jbang-host 
/path/to/jbang-backed/camel \
+  --plugin "org.apache.camel:camel-jbang-plugin-kit:$KIT_VERSION" --work-dir 
"$TMPDIR/kit-jbang" \
+  --maven-repository "$HOME/.m2/repository"
+# In a shell with a full JDK and no jbang on PATH:
+python3 tools/verify_camel_launcher.py --launcher /path/to/Camel/bin/camel.sh \
+  --plugin "org.apache.camel:camel-jbang-plugin-kit:$KIT_VERSION" --work-dir 
"$TMPDIR/kit-launcher" \
+  --maven-repository "$HOME/.m2/repository" --knowledge-index 
"$PWD/knowledge/index/src/main/resources/knowledge-index"
+```
+
+Set `KIT_VERSION` to the candidate version and choose two new working 
directories under a writable `TMPDIR`.
+
 1. Start from reviewed source on a release branch. Change only the selected 
product
    POM version and its child parent versions (or only the root version for a 
parent
    release). Set its SCM tag. Keep the other product's version unchanged.
diff --git a/kit/camel-jbang-plugin-kit/pom.xml 
b/kit/camel-jbang-plugin-kit/pom.xml
index fa9a050a..fd5d35c3 100644
--- a/kit/camel-jbang-plugin-kit/pom.xml
+++ b/kit/camel-jbang-plugin-kit/pom.xml
@@ -26,6 +26,13 @@
             <scope>provided</scope>
         </dependency>
 
+        <!-- Command types and metadata registries belong to the host class 
loader. -->
+        <dependency>
+            <groupId>org.aesh</groupId>
+            <artifactId>aesh</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
         <!-- The host owns JLine; do not override it with the standalone 
TamboUI backend's JLine 3. -->
         <dependency>
             <groupId>org.jline</groupId>
@@ -55,4 +62,91 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <resources>
+            <resource><directory>src/main/resources</directory></resource>
+            <resource>
+                <directory>${maven.multiModuleProjectDirectory}</directory>
+                <includes><include>LICENSE</include></includes>
+                <targetPath>META-INF</targetPath>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>check-pack-origins</id>
+                        <phase>prepare-package</phase>
+                        <goals><goal>run</goal></goals>
+                        <configuration>
+                            <target>
+                                <java 
sourcefile="${project.basedir}/src/build-tools/CheckPackOrigins.java" 
fork="true" failonerror="true">
+                                    <classpath 
refid="maven.runtime.classpath"/>
+                                    <arg 
file="${project.build.directory}/selected-catalog.zip"/>
+                                </java>
+                            </target>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>verify-packaged-plugin</id>
+                        <phase>verify</phase>
+                        <goals><goal>run</goal></goals>
+                        <configuration>
+                            <target>
+                                <java 
sourcefile="${project.basedir}/src/it/consumer/VerifyPlugin.java" fork="true" 
failonerror="true">
+                                    <classpath><pathelement 
location="${project.build.directory}/${project.build.finalName}.jar"/></classpath>
+                                    <arg 
file="${project.basedir}/../camel-kit-graph/src/test/resources/testdata/mule4"/>
+                                    <arg 
file="${project.build.directory}/selected-catalog.zip"/>
+                                </java>
+                            </target>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                
<configuration><forceCreation>true</forceCreation></configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>${maven.shade.plugin.version}</version>
+                <executions>
+                    <execution>
+                        <goals><goal>shade</goal></goals>
+                        <configuration>
+                            
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
+                            
<useDependencyReducedPomInJar>true</useDependencyReducedPomInJar>
+                            <filters>
+                                <filter>
+                                    <artifact>*:*</artifact>
+                                    <excludes>
+                                        <exclude>META-INF/*.DSA</exclude>
+                                        <exclude>META-INF/*.EC</exclude>
+                                        <exclude>META-INF/*.RSA</exclude>
+                                        <exclude>META-INF/*.SF</exclude>
+                                        
<exclude>META-INF/versions/**/module-info.class</exclude>
+                                        <exclude>module-info.class</exclude>
+                                    </excludes>
+                                </filter>
+                            </filters>
+                            <transformers>
+                                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+                                <transformer 
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                                    <resource>META-INF/LICENSE</resource>
+                                </transformer>
+                                <transformer 
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                                    <resource>META-INF/LICENSE.txt</resource>
+                                </transformer>
+                                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer"/>
+                                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    
<manifestEntries><Multi-Release>true</Multi-Release></manifestEntries>
+                                </transformer>
+                            </transformers>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git a/kit/camel-jbang-plugin-kit/src/build-tools/CheckPackOrigins.java 
b/kit/camel-jbang-plugin-kit/src/build-tools/CheckPackOrigins.java
new file mode 100644
index 00000000..671d7665
--- /dev/null
+++ b/kit/camel-jbang-plugin-kit/src/build-tools/CheckPackOrigins.java
@@ -0,0 +1,65 @@
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Pattern;
+import java.util.stream.Stream;
+
+import org.apache.camel.kit.workflow.SkillCatalog;
+
+/** Shade keeps the first copy. Check single-owner resources while the 
original artifacts are still separate. */
+class CheckPackOrigins {
+    public static void main(String[] args) throws Exception {
+        Set<String> classes = new HashSet<>();
+        for (var binding : 
SkillCatalog.bundled().manifest().contributions().values()) {
+            var provider = binding.provider();
+            if (provider != null) {
+                classes.add(provider.implementation().replace('.', '/') + 
".class");
+                classes.add(provider.service().replace('.', '/') + ".class");
+            }
+        }
+        Map<String, Path> owners = new HashMap<>();
+        for (String entry : 
System.getProperty("java.class.path").split(Pattern.quote(File.pathSeparator))) 
{
+            Path path = Path.of(entry);
+            if (Files.isDirectory(path)) {
+                try (var files = Files.walk(path)) {
+                    check(path, 
files.filter(Files::isRegularFile).map(path::relativize)
+                            .map(file -> 
file.toString().replace(File.separatorChar, '/')), classes, owners);
+                }
+            } else {
+                try (var jar = new JarFile(path.toFile())) {
+                    var files = jar.stream().filter(file -> 
!file.isDirectory()).map(JarEntry::getName);
+                    check(path, files, classes, owners);
+                }
+            }
+        }
+        for (String name : classes) {
+            if (!owners.containsKey(name)) {
+                throw new IllegalStateException("Missing pack provider class " 
+ name);
+            }
+        }
+        String selected = owners.containsKey(SkillCatalog.DISTRIBUTION)
+                ? SkillCatalog.DISTRIBUTION : SkillCatalog.DEFAULT;
+        try (var in = SkillCatalog.class.getResourceAsStream("/" + selected)) {
+            Files.copy(in, Path.of(args[0]), 
StandardCopyOption.REPLACE_EXISTING);
+        }
+    }
+
+    private static void check(Path origin, Stream<String> entries, Set<String> 
classes, Map<String, Path> owners) {
+        entries.filter(name -> name.startsWith("META-INF/camel-kit/") || 
name.startsWith("skills/")
+                || name.startsWith("workflow/") || classes.contains(name)
+                || 
name.equals("META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-kit"))
+                .forEach(name -> {
+                    Path previous = owners.putIfAbsent(name, origin);
+                    if (previous != null) {
+                        throw new IllegalStateException("Duplicate " + name + 
" in " + previous + " and " + origin);
+                    }
+                });
+    }
+}
diff --git a/kit/camel-jbang-plugin-kit/src/it/consumer/VerifyPlugin.java 
b/kit/camel-jbang-plugin-kit/src/it/consumer/VerifyPlugin.java
new file mode 100644
index 00000000..c487b955
--- /dev/null
+++ b/kit/camel-jbang-plugin-kit/src/it/consumer/VerifyPlugin.java
@@ -0,0 +1,81 @@
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+import java.util.ServiceLoader;
+import java.util.Set;
+
+import org.apache.camel.kit.workflow.MigrationParsers;
+import org.apache.camel.kit.workflow.SkillCatalog;
+
+import com.fasterxml.jackson.core.JsonFactory;
+
+/** Run with only the published plugin on the class path. A reactor dependency 
would mask missing entries. */
+class VerifyPlugin {
+    public static void main(String[] args) throws Exception {
+        ClassLoader plugin = SkillCatalog.class.getClassLoader();
+        
Thread.currentThread().setContextClassLoader(ClassLoader.getPlatformClassLoader());
+
+        for (String hostClass : List.of("org/aesh/command/Command.class", 
"org/jline/terminal/Terminal.class",
+                
"org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.class")) {
+            if (plugin.getResource(hostClass) != null) {
+                throw new AssertionError("Unexpected host class in the plugin: 
" + hostClass);
+            }
+        }
+        Properties entry = new Properties();
+        String descriptor = 
"META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-kit";
+        try (var in = plugin.getResourceAsStream(descriptor)) {
+            if (in == null) {
+                throw new AssertionError("Missing Camel CLI plugin descriptor: 
" + descriptor);
+            }
+            entry.load(in);
+        }
+        String implementation = entry.getProperty("class");
+        if (implementation == null || 
plugin.getResource(implementation.replace('.', '/') + ".class") == null) {
+            throw new AssertionError("Missing Camel CLI plugin entry class: " 
+ implementation);
+        }
+
+        var factories = ServiceLoader.load(JsonFactory.class, 
plugin).stream().map(p -> p.type().getName()).toList();
+        if 
(!factories.containsAll(List.of("com.fasterxml.jackson.core.JsonFactory",
+                "com.fasterxml.jackson.dataformat.yaml.YAMLFactory"))) {
+            throw new AssertionError("Incomplete JSON/YAML service 
registration: " + factories);
+        }
+
+        var catalog = SkillCatalog.bundled();
+        if (args.length == 2) {
+            var selected = plugin.getResource(SkillCatalog.DISTRIBUTION);
+            if (selected == null) {
+                selected = plugin.getResource(SkillCatalog.DEFAULT);
+            }
+            try (var in = selected.openStream()) {
+                if (!Arrays.equals(in.readAllBytes(), 
Files.readAllBytes(Path.of(args[1])))) {
+                    throw new AssertionError("The packaged skill catalog 
differs from the selected input catalog");
+                }
+            }
+        }
+        for (String pack : catalog.manifest().packs()) {
+            if (plugin.getResource("META-INF/camel-kit/packs/" + pack + 
"/pack.yaml") == null) {
+                throw new AssertionError("Missing descriptor for " + pack);
+            }
+        }
+        for (var binding : catalog.manifest().contributions().values()) {
+            var provider = binding.provider();
+            if (provider != null) {
+                
plugin.loadClass(provider.implementation()).asSubclass(plugin.loadClass(provider.service()));
+            }
+        }
+        var bindings = catalog.manifest().contributions();
+        boolean standard = 
Set.copyOf(catalog.manifest().packs()).equals(Set.of("core", 
"developer-tasks"));
+        if (standard || bindings.containsKey("provider/mule-xml")) {
+            var graph = 
MigrationParsers.newGraphBuilder("mule-xml").buildWithDiagnostics(Path.of(args[0]));
+            if (!graph.successful() || 
!graph.graph().hasNode("mule-flow:order-ingestion-flow")) {
+                throw new AssertionError("Packaged Mule parser did not 
recognize the orders fixture");
+            }
+            if ((standard || bindings.containsKey("provider/mule"))
+                    && 
catalog.graphTypes().requireAdapter("mule").summarize(graph.graph()).isEmpty()) 
{
+                throw new AssertionError("Packaged Mule adapter did not 
summarize the orders fixture");
+            }
+        }
+    }
+}
diff --git a/kit/camel-jbang-plugin-kit/src/it/consumer/pom.xml 
b/kit/camel-jbang-plugin-kit/src/it/consumer/pom.xml
new file mode 100644
index 00000000..3cd318d1
--- /dev/null
+++ b/kit/camel-jbang-plugin-kit/src/it/consumer/pom.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0";>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>example</groupId>
+    <artifactId>installed-kit-consumer</artifactId>
+    <version>1</version>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-jbang-plugin-kit</artifactId>
+            <version>${kit.version}</version>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/tools/verify_camel_launcher.py b/tools/verify_camel_launcher.py
index 4f629688..55abe8d1 100755
--- a/tools/verify_camel_launcher.py
+++ b/tools/verify_camel_launcher.py
@@ -12,9 +12,9 @@ import tempfile
 import threading
 
 
-def check_server(name, spec, project, env, camel, citrus):
-    if spec["command"] != "java":
-        raise AssertionError(f"{name}: expected the generated Java command")
+def check_server(name, spec, project, env, camel, citrus, executable="java"):
+    if spec["command"] != executable:
+        raise AssertionError(f"{name}: expected {executable}, got 
{spec['command']}")
     with tempfile.TemporaryFile(mode="w+") as stderr, subprocess.Popen(
         [spec["command"], *spec["args"]], cwd=project, env=env, 
stdin=subprocess.PIPE,
         stdout=subprocess.PIPE, stderr=stderr, text=True,
@@ -76,18 +76,46 @@ def check_server(name, spec, project, env, camel, citrus):
                 proc.kill()
 
 
+def check_migration(host, project, env):
+    skills = project / ".qwen/skills"
+    assert ".qwen/skills/camel-migrate/SKILL.md" in (project / 
".qwen/commands/camel-migrate.md").read_text()
+    guide = "camel-brainstorm/guides/migration-mule-graph-analysis.md"
+    assert guide in (skills / "camel-migrate/SKILL.md").read_text()
+    assert "Use the literal `camel kit`" in (skills / 
"shared/graph-availability.md").read_text()
+    query = ["graph", "find", "--type", "mule:flow", "--graph-file"]
+    invocation = "[*COMMAND_PREFIX_ARGV, " + ", ".join(map(json.dumps, query)) 
+ ", GRAPH_FILE]"
+    assert invocation in (skills / guide).read_text()
+
+    source = project / "orders"
+    fixture = Path(__file__).resolve().parents[1] / 
"kit/camel-kit-graph/src/test/resources/testdata/mule4"
+    shutil.copytree(fixture, source)
+    graph = source / ".camel-kit/project-graph.json"
+    subprocess.run([host, "kit", "graph", "generate", "--require-parser", 
"mule-xml", "--project-dir", str(source),
+                    "--output", str(graph)], cwd=project, env=env, check=True, 
timeout=90)
+    result = subprocess.run([host, "kit", *query, str(graph)], cwd=project, 
env=env, check=True, timeout=90,
+                            stdout=subprocess.PIPE, text=True)
+    flows = json.loads(result.stdout)["nodes"]
+    assert any(node["id"] == "mule-flow:order-ingestion-flow" and node["type"] 
== "mule:flow" for node in flows)
+    print("Installed /camel-migrate inventory found the Mule orders flow", 
flush=True)
+
+
 def main():
     parser = argparse.ArgumentParser(description=__doc__)
-    parser.add_argument("--launcher", required=True, type=Path, 
help="Aesh-compatible Camel distribution script")
+    hosts = parser.add_mutually_exclusive_group(required=True)
+    hosts.add_argument("--launcher", type=Path, help="Aesh-compatible Camel 
distribution script")
+    hosts.add_argument("--jbang-host", type=Path, help="Aesh-compatible camel 
executable backed by JBang")
     parser.add_argument("--plugin", required=True, help="the packaged Kit 
plugin GAV to install")
     parser.add_argument("--work-dir", required=True, type=Path, help="new 
directory for the user home and workspace")
     parser.add_argument("--maven-repository", type=Path, help="optional Maven 
repository containing a local plugin build")
     parser.add_argument("--knowledge-index", type=Path, help="optional 
prebuilt Lucene index containing Camel docs")
     parser.add_argument("--qwen", type=Path, help="Qwen CLI executable for a 
native host connection check")
     args = parser.parse_args()
-    if shutil.which("jbang"):
+    if args.launcher and shutil.which("jbang"):
         parser.error("run with a JDK and system utilities on PATH, without a 
JBang installation")
-    launcher = str(args.launcher.resolve(strict=True))
+    if args.jbang_host and not shutil.which("jbang"):
+        parser.error("--jbang-host requires jbang on PATH")
+    host = str((args.launcher or args.jbang_host).resolve(strict=True))
+    backend = "launcher" if args.launcher else "jbang"
     root = args.work_dir.resolve()
     root.mkdir(parents=True, exist_ok=False)
     home = root / "user home"
@@ -97,16 +125,20 @@ def main():
     env["HOME"] = str(home)
     env["JDK_JAVA_OPTIONS"] = env.get("JDK_JAVA_OPTIONS", "") + f' 
"-Duser.home={home}"'
     if args.maven_repository:
-        env["JDK_JAVA_OPTIONS"] += f' 
"-Dmaven.repo.local={args.maven_repository.resolve(strict=True)}"'
+        repository = str(args.maven_repository.resolve(strict=True))
+        env["JDK_JAVA_OPTIONS"] += f' "-Dmaven.repo.local={repository}"'
+        if args.jbang_host:
+            env["JBANG_REPO"] = repository
     if args.knowledge_index:
         env["KNOWLEDGE_INDEX_PATH"] = 
str(args.knowledge_index.resolve(strict=True))
     project = root / "qwen project"
-    subprocess.run([launcher, "plugin", "add", "kit", "--gav", args.plugin], 
cwd=root, env=env, check=True)
-    subprocess.run([launcher, "kit", "init", str(project), "--ai", "qwen", 
"--with-citrus-mcp", "--no-fetch"],
-                   cwd=root, env=env, check=True)
+    subprocess.run([host, "plugin", "add", "kit", "--gav", args.plugin], 
cwd=root, env=env, check=True, timeout=180)
+    subprocess.run([host, "kit", "init", str(project), "--ai", "qwen", 
"--with-citrus-mcp", "--no-fetch"],
+                   cwd=root, env=env, check=True, timeout=180)
     props = dict(line.split("=", 1) for line in (project / 
".camel-kit/config.properties").read_text().splitlines()
                  if line and not line.startswith("#"))
-    assert props["camel.cli"] == "launcher"
+    assert props["camel.cli"] == backend
+    check_migration(host, project, env)
     servers = json.loads((project / 
".qwen/settings.json").read_text())["mcpServers"]
     assert set(servers) == {"camel", "camel-knowledge", "citrus"}
     if args.qwen:
@@ -120,6 +152,10 @@ def main():
             if not re.search(rf"(?m)^.*? {re.escape(name)}: .*? - 
Connected\s*$", listed):
                 raise AssertionError(f"Qwen did not connect to {name}: 
{listed}")
             print(f"Qwen connected to {name}", flush=True)
+    if args.jbang_host:
+        check_server("camel", servers["camel"], project, env, 
props["project.camelVersion"], props["citrus.mcp.version"],
+                     executable="jbang")
+        return
     for offline in ("false", "true"):
         env["CAMEL_KIT_OFFLINE"] = offline
         for name, spec in servers.items():
diff --git a/tools/verify_installed_plugin.py b/tools/verify_installed_plugin.py
new file mode 100644
index 00000000..83e488e2
--- /dev/null
+++ b/tools/verify_installed_plugin.py
@@ -0,0 +1,43 @@
+"""Resolve the installed Kit plugin like a downstream Maven consumer and check 
its packaging contract."""
+import os
+from pathlib import Path
+import shutil
+import subprocess
+import tempfile
+import xml.etree.ElementTree as ET
+from zipfile import ZipFile
+
+
+ROOT = Path(__file__).resolve().parents[1]
+PLUGIN = ROOT / "kit/camel-jbang-plugin-kit"
+
+
+def main():
+    version = ET.parse(ROOT / "kit/pom.xml").findtext("{*}version")
+    with tempfile.TemporaryDirectory() as work:
+        consumer = Path(work) / "consumer"
+        shutil.copytree(PLUGIN / "src/it/consumer", consumer)
+        classpath = consumer / "runtime.txt"
+        wrapper = ROOT / ("mvnw.cmd" if os.name == "nt" else "mvnw")
+        subprocess.run([wrapper, "-B", "-f", consumer / "pom.xml", 
f"-Dkit.version={version}",
+                        "dependency:build-classpath", 
"-DincludeScope=runtime", f"-Dmdep.outputFile={classpath}"],
+                       cwd=consumer, check=True)
+        jars = [Path(p) for p in 
classpath.read_text().strip().split(os.pathsep)]
+        if len(jars) != 1 or jars[0].name != 
f"camel-jbang-plugin-kit-{version}.jar":
+            raise AssertionError(f"Expected one installed plugin JAR, resolved 
{jars}")
+        subprocess.run(["java", "-cp", jars[0], consumer / "VerifyPlugin.java",
+                        ROOT / 
"kit/camel-kit-graph/src/test/resources/testdata/mule4"], cwd=consumer, 
check=True)
+
+        # A second module can bring an identical resource after the catalog 
has already been compiled.
+        duplicate = "META-INF/camel-kit/packs/core/pack.yaml"
+        other = consumer / "second-pack.jar"
+        with ZipFile(jars[0]) as plugin, ZipFile(other, "w") as second:
+            second.writestr(duplicate, plugin.read(duplicate))
+        result = subprocess.run(["java", "-cp", os.pathsep.join(map(str, 
[jars[0], other])),
+                                 PLUGIN / 
"src/build-tools/CheckPackOrigins.java", consumer / "selected.zip"], 
capture_output=True, text=True)
+        if result.returncode == 0 or f"Duplicate {duplicate}" not in 
result.stderr or str(other) not in result.stderr:
+            raise AssertionError(f"Expected both origins in the duplicate 
resource diagnostic: {result.stderr}")
+
+
+if __name__ == "__main__":
+    main()

Reply via email to