This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new a677b944569e CAMEL-25362: camel-jbang - Shift+F8 with AI on the Kafka
and CVE Audit screens (#30546)
a677b944569e is described below
commit a677b944569e5ead5b3cf52146797110afc0d2ce
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 21 10:18:00 2026 +0100
CAMEL-25362: camel-jbang - Shift+F8 with AI on the Kafka and CVE Audit
screens (#30546)
Shift+F8 with AI on the last two screens of CAMEL-25362. On the Kafka tab
it asks the AI to fix the selected consumer when it has an error or is not
running or paused, with its state, error, endpoint, group, last read position,
route source and the route's last error. On the CVE Audit tab it asks the AI to
explain the selected vulnerability: whether the integration uses the vulnerable
part, and how to fix it (a fixed version of a declared dependency, or a newer
Camel version), without [...]
_Claude Code on behalf of Claus Ibsen_
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../ROOT/pages/camel-jbang-tui-ai-ways.adoc | 6 +-
.../ROOT/pages/camel-jbang-tui-observe.adoc | 11 +-
.../dsl/jbang/core/commands/tui/CveAiPrompt.java | 83 +++++++++++
.../dsl/jbang/core/commands/tui/CveAuditTab.java | 32 +++++
.../dsl/jbang/core/commands/tui/KafkaAiPrompt.java | 87 ++++++++++++
.../dsl/jbang/core/commands/tui/KafkaTab.java | 39 +++++
.../src/main/resources/tui/help/cve-audit.md | 12 ++
.../src/main/resources/tui/help/kafka.md | 12 ++
.../jbang/core/commands/tui/CveAiPromptTest.java | 120 ++++++++++++++++
.../jbang/core/commands/tui/KafkaAiPromptTest.java | 158 +++++++++++++++++++++
10 files changed, 556 insertions(+), 4 deletions(-)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-ai-ways.adoc
b/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-ai-ways.adoc
index d3a5c8b68885..61ba995f9ea7 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-ai-ways.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-ai-ways.adoc
@@ -126,9 +126,9 @@ to the TUI; the agent then has both servers.
* *You can see what happened.* The AI log (*F2* -> _AI & MCP_ -> _AI Log_)
records the questions, tool calls and
answers of the panel; the MCP log records the calls agents made through the
MCP server.
* *The same shortcuts open the panel.* *Shift+F8* in the Source editor, the
Log tab, the Errors view, the Health
- tab, and on a failing route or SQL statement writes the question for you
("fix with AI"). On the Timeline, Chaos
- and Circuit Breaker screens and on a slow route or SQL statement, it writes
a question that asks for an explanation
- ("explain with AI"). The panel sends the question to whichever provider or
agent it uses. `/overview`, which
+ tab, and on a failing route, SQL statement or Kafka consumer writes the
question for you ("fix with AI"). On the
+ Timeline, Chaos, Circuit Breaker and CVE Audit screens and on a slow route
or SQL statement, it writes a question that
+ asks for an explanation ("explain with AI"). The panel sends the question to
whichever provider or agent it uses. `/overview`, which
explains the project, needs a model (way 1); an agent explains it with the
`camel_project_overview` and
`camel_save_project_summary` tools when you ask it to.
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-observe.adoc
b/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-observe.adoc
index 466557e20324..517dc4b95f63 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-observe.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-observe.adoc
@@ -210,7 +210,7 @@ listed once.
image::jbang/camel-tui-log-fix-with-ai-pick.png[Shift+F8 in the Log tab with
two different ERRORs on the screen]
-The Routes, SQL Trace, Health and Circuit Breaker tabs have the key too:
+The Routes, SQL Trace, Health, Circuit Breaker, Kafka and CVE Audit tabs have
the key too:
* *Routes*: *Shift+F8* on a route whose exchanges fail asks the AI to fix it,
with the steps they fail at, their source
lines and the last error of the route. On a route without failures, it asks
the AI to explain where the time goes, with
@@ -228,6 +228,15 @@ broker that is not running.
calls failed, timed out or were rejected. The question has its state and
counters, its configuration, its line in the
source and the last error of its route. An open circuit breaker is often the
breaker doing its job, so the AI explains
and suggests, and changes no file unless you agree.
+* *Kafka*: *Shift+F8* asks the AI to fix the selected consumer when it has an
error, or is not running or paused. The
+question has its state and last error, its endpoint and consumer group, where
it last read (topic, partition, offset),
+the line of its route in the source and the last error of the route. The AI
fixes the cause in the routes or
+configuration (brokers, topic, group, deserializers, security), or says how to
fix it when it is outside the
+integration, such as a broker that is not running.
+* *CVE Audit*: *Shift+F8* asks the AI to explain the selected vulnerability:
its severity, the artifacts it affects and
+the dependency that brings each in, the versions that fix it and its
description. The AI tells whether the integration
+uses the vulnerable part of the library, and how to fix it (a fixed version of
a dependency the project declares, or a
+newer Camel version for one that comes with a component), and changes no file
unless you agree.
The Log tab shows the log in one of three views, and *c* goes to the next one:
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAiPrompt.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAiPrompt.java
new file mode 100644
index 000000000000..cd6a12ef3f4a
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAiPrompt.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The question the AI panel is opened with to explain a vulnerability
(Shift+F8 on the CVE Audit tab, CAMEL-25362): its
+ * severity, the artifacts it affects and the dependency that brings each in,
the versions that fix it, and its
+ * description. A vulnerable library is not always reachable from the routes,
and the fix may be a Camel upgrade, so the
+ * AI is asked to explain and suggest, not to change the files on its own. It
is put in the input of the panel, for the
+ * user to send with Enter or change first.
+ */
+final class CveAiPrompt {
+
+ /** The description of a vulnerability can be long: its start says what it
is. */
+ static final int MAX_DETAILS = 1500;
+
+ private CveAiPrompt() {
+ }
+
+ static String of(IntegrationInfo info, CveAuditTab.VulnGroup group) {
+ StringBuilder sb = new StringBuilder();
+ String name = info != null ? info.name != null ? info.name : info.pid
: null;
+ sb.append("Explain the vulnerability
").append(group.canonicalId).append(" (")
+ .append(group.severity != null ? group.severity : "UNKNOWN");
+ if (group.cvssVector != null) {
+ sb.append(", ").append(group.cvssVector);
+ }
+ sb.append(") in the dependencies of the running
integration").append(name != null ? " " + name : "");
+ if (group.summary != null && !group.summary.isBlank()) {
+ sb.append(": ").append(group.summary.strip());
+ }
+ sb.append(".\n");
+ List<String> affected = new ArrayList<>();
+ for (String gav : group.affectedGavs) {
+ String parent = group.gavParents.get(gav);
+ affected.add(parent != null ? gav + " (via " + parent + ")" : gav);
+ }
+ if (!affected.isEmpty()) {
+ sb.append("It affects: ").append(String.join(", ",
affected)).append(".\n");
+ }
+ if (!group.fixedVersions.isEmpty()) {
+ sb.append("Fixed in: ").append(String.join(", ",
group.fixedVersions)).append(".\n");
+ } else {
+ sb.append("No fixed version is known.\n");
+ }
+ List<String> aliases = group.aliases.stream().filter(a ->
!a.equals(group.canonicalId)).toList();
+ if (!aliases.isEmpty()) {
+ sb.append("Also known as: ").append(String.join(", ",
aliases)).append(".\n");
+ }
+ if (group.published != null) {
+ sb.append("Published: ").append(group.published).append(".\n");
+ }
+ if (group.details != null && !group.details.isBlank()) {
+ String details = group.details.strip();
+ sb.append("Its description:\n").append(details.length() >
MAX_DETAILS
+ ? details.substring(0, MAX_DETAILS) + "..." :
details).append('\n');
+ }
+ sb.append("Tell whether the integration is affected: does it use the
vulnerable part of the library, from its")
+ .append(" routes and configuration? Then say how to fix it:
when the project declares the artifact")
+ .append(" itself (//DEPS, camel.jbang.dependencies or --dep),
a fixed version to use; when it comes")
+ .append(" with a Camel component (via camel-...), whether a
newer Camel version has the fix, or how to")
+ .append(" use a fixed version meanwhile. tui_get_table on the
CVE Audit tab has the vulnerabilities.")
+ .append(" Make no changes to the files unless I agree.");
+ return sb.toString();
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAuditTab.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAuditTab.java
index 4c484f315dbe..6c42c2f3ea35 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAuditTab.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAuditTab.java
@@ -138,6 +138,14 @@ class CveAuditTab extends AbstractTableTab {
@Override
protected boolean handleTabKeyEvent(KeyEvent ke) {
+ if (ke.isKey(KeyCode.F8) && ke.hasShift()) {
+ // explain with AI (CAMEL-25362): whether the selected
vulnerability affects the integration, and the fix
+ VulnGroup group = selectedGroup();
+ if (group != null && ctx.askAiCallback != null) {
+
ctx.askAiCallback.ask(CveAiPrompt.of(ctx.findSelectedIntegration(), group));
+ }
+ return true;
+ }
if (ke.isPageUp() || ke.isKey(KeyCode.PAGE_UP)) {
detailScroll = Math.max(0, detailScroll - 10);
return true;
@@ -390,6 +398,21 @@ class CveAuditTab extends AbstractTableTab {
super.renderFooter(spans);
}
+ @Override
+ public void renderFKeyHints(List<Span> spans) {
+ // with the global F-keys, as the AI key of a screen is an F-key of
every screen that has one
+ if (ctx.askAiCallback != null && selectedGroup() != null) {
+ hint(spans, "Shift+F8", "explain with AI");
+ }
+ }
+
+ /** The vulnerability selected in the table, in the order it is shown;
null when none is. */
+ VulnGroup selectedGroup() {
+ List<VulnGroup> visible = sortedGroups();
+ Integer sel = tableState.selected();
+ return sel != null && sel >= 0 && sel < visible.size() ?
visible.get(sel) : null;
+ }
+
private void rescan() {
if (loading.get()) {
return;
@@ -593,6 +616,15 @@ class CveAuditTab extends AbstractTableTab {
});
}
+ /** Shows the vulnerabilities as a scan sets them, without the render
thread; for tests. */
+ void showForTesting(List<VulnGroup> groups) {
+ allGroups = groups;
+ dataLoaded = true;
+ if (!groups.isEmpty()) {
+ tableState.select(0);
+ }
+ }
+
private List<VulnGroup> sortedGroups() {
List<VulnGroup> result = new ArrayList<>(allGroups);
result.sort((a, b) -> {
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaAiPrompt.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaAiPrompt.java
new file mode 100644
index 000000000000..4abe590753f4
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaAiPrompt.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * The question the AI panel is opened with to fix a Kafka consumer (Shift+F8
on the Kafka tab, CAMEL-25362): its state
+ * and last error, its endpoint and group, where it last read, where its route
is in the source, and the last error of
+ * the route. It is put in the input of the panel, for the user to send with
Enter or change first.
+ */
+final class KafkaAiPrompt {
+
+ /** The states of a consumer that is doing its job, or was paused on
purpose. */
+ private static final Set<String> FINE = Set.of("running", "paused",
"resume_requested");
+
+ private KafkaAiPrompt() {
+ }
+
+ /** Whether a consumer has something to fix: an error, or a state other
than running or paused. */
+ static boolean hasTrouble(KafkaConsumerInfo ki) {
+ return ki.lastError != null && !ki.lastError.isBlank()
+ || ki.state != null && !ki.state.isBlank() &&
!FINE.contains(ki.state.toLowerCase(Locale.ROOT));
+ }
+
+ static String of(IntegrationInfo info, KafkaConsumerInfo ki) {
+ StringBuilder sb = new StringBuilder();
+ String name = info.name != null ? info.name : info.pid;
+ sb.append("Fix the Kafka consumer of route ").append(ki.routeId !=
null ? ki.routeId : "")
+ .append(" in the running integration ").append(name).append(":
it is ")
+ .append(ki.state != null && !ki.state.isBlank() ?
ki.state.toLowerCase(Locale.ROOT) : "in an unknown state")
+ .append(".\n");
+ if (ki.lastError != null && !ki.lastError.isBlank()) {
+ sb.append("Its last error:
").append(ki.lastError.strip()).append('\n');
+ }
+ if (ki.uri != null && !ki.uri.isBlank()) {
+ sb.append("Its endpoint: ").append(ki.uri).append('\n');
+ }
+ if (ki.groupId != null && !ki.groupId.isBlank()) {
+ sb.append("Its consumer group: ").append(ki.groupId);
+ if (ki.groupInstanceId != null && !ki.groupInstanceId.isBlank()) {
+ sb.append(" (group instance
").append(ki.groupInstanceId).append(')');
+ }
+ if (ki.memberId != null && !ki.memberId.isBlank()) {
+ sb.append(", member ").append(ki.memberId).append(",
generation ").append(ki.generationId);
+ }
+ sb.append(".\n");
+ }
+ if (ki.lastTopic != null && !ki.lastTopic.isBlank()) {
+ sb.append("It last read topic ").append(ki.lastTopic).append(",
partition ").append(ki.lastPartition)
+ .append(", offset ").append(ki.lastOffset).append(".\n");
+ } else {
+ sb.append("It has not read a record yet.\n");
+ }
+ for (RouteInfo r : info.routes) {
+ if (ki.routeId != null && ki.routeId.equals(r.routeId) && r.source
!= null) {
+ sb.append("Its route is at ").append(r.source).append(".\n");
+ }
+ }
+ ErrorInfo last = RouteAiPrompt.lastError(info, ki.routeId);
+ if (last != null) {
+ sb.append("The last error of the route:
").append(RuntimeFailures.failureOf(last)).append('\n');
+ }
+ sb.append("Find the cause first, from the integration's errors and
log; tui_get_table on the Kafka tab has the")
+ .append(" consumers. When it is in the project's routes or
configuration, such as the brokers, the")
+ .append(" topic, the group, the deserializers or the security
settings, fix it with camel_edit_file and")
+ .append(" check the file with camel_validate_source; dev mode
reloads the file when it is saved. When it")
+ .append(" is outside the integration, such as a broker that is
not running or cannot be reached, or a")
+ .append(" topic that does not exist, say how to fix that, and
make no changes to the files.");
+ return sb.toString();
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaTab.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaTab.java
index 28f097df61d9..4a2a35573b0f 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaTab.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaTab.java
@@ -28,6 +28,8 @@ import dev.tamboui.terminal.Frame;
import dev.tamboui.text.Line;
import dev.tamboui.text.Span;
import dev.tamboui.text.Text;
+import dev.tamboui.tui.event.KeyCode;
+import dev.tamboui.tui.event.KeyEvent;
import dev.tamboui.widgets.block.Block;
import dev.tamboui.widgets.block.BorderType;
import dev.tamboui.widgets.block.Borders;
@@ -180,6 +182,43 @@ class KafkaTab extends AbstractTableTab {
area);
}
+ @Override
+ protected boolean handleTabKeyEvent(KeyEvent ke) {
+ if (ke.isKey(KeyCode.F8) && ke.hasShift()) {
+ // fix with AI (CAMEL-25362): why the selected consumer fails or
does not run
+ IntegrationInfo info = ctx.findSelectedIntegration();
+ KafkaConsumerInfo ki = info != null ? selectedConsumer(info) :
null;
+ if (ki != null && ctx.askAiCallback != null) {
+ if (KafkaAiPrompt.hasTrouble(ki)) {
+ ctx.askAiCallback.ask(KafkaAiPrompt.of(info, ki));
+ } else if (ctx.notificationCallback != null) {
+ ctx.notificationCallback.accept("This Kafka consumer is
running without errors: ask the AI with F8",
+ false);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void renderFKeyHints(List<Span> spans) {
+ // with the global F-keys, as the AI key of a screen is an F-key of
every screen that has one
+ IntegrationInfo info = ctx.findSelectedIntegration();
+ KafkaConsumerInfo ki = info != null && ctx.askAiCallback != null ?
selectedConsumer(info) : null;
+ if (ki != null && KafkaAiPrompt.hasTrouble(ki)) {
+ hint(spans, "Shift+F8", "fix with AI");
+ }
+ }
+
+ /** The consumer selected in the table, in the order it is shown; null
when none is. */
+ KafkaConsumerInfo selectedConsumer(IntegrationInfo info) {
+ List<KafkaConsumerInfo> sorted = new ArrayList<>(info.kafkaConsumers);
+ sorted.sort(this::sortKafka);
+ Integer sel = tableState.selected();
+ return sel != null && sel >= 0 && sel < sorted.size() ?
sorted.get(sel) : null;
+ }
+
private int sortKafka(KafkaConsumerInfo a, KafkaConsumerInfo b) {
int result = switch (sort) {
case "state" -> compareStr(a.state, b.state);
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/cve-audit.md
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/cve-audit.md
index 94d7cc86554b..1b6d9c8f1a44 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/cve-audit.md
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/cve-audit.md
@@ -29,6 +29,17 @@ Results are cached globally so re-visiting the tab is
instant.
Switching to another integration that shares the same JARs will
also benefit from the cache. Press `r` to force a rescan.
+## Explain with AI
+
+Press `Shift+F8` on a vulnerability to ask the AI about it. The AI
+panel opens with a question made of its severity, the artifacts it
+affects and the dependency that brings each in, the versions that fix
+it and its description. The AI tells whether the integration uses the
+vulnerable part of the library, and how to fix it: a fixed version of
+a dependency the project declares, or a newer Camel version for one
+that comes with a Camel component. It changes no file unless you
+agree.
+
## Keys
- `Up/Down` — navigate vulnerabilities
@@ -36,4 +47,5 @@ also benefit from the cache. Press `r` to force a rescan.
- `s` — cycle sort column
- `S` — reverse sort order
- `r` — rescan (clear cache and re-query)
+- `Shift+F8` — explain with AI the selected vulnerability
- `Esc` — back
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/kafka.md
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/kafka.md
index 3472cbbf6a5d..33c51312fbee 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/kafka.md
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/kafka.md
@@ -30,8 +30,20 @@ and health state.
offset stays the same, the consumer may be stuck or the topic
may have no new messages on that partition.
+## Fix with AI
+
+Press `Shift+F8` on a consumer with an error, or one that is not
+running or paused, to ask the AI to fix it. The AI panel opens with a
+question made of its state and last error, its endpoint and consumer
+group, the topic, partition and offset it last read, the line of its
+route in the source and the last error of the route. The AI finds the
+cause and fixes it in the routes or configuration (brokers, topic,
+group, deserializers, security), or says how to fix it when it is
+outside the integration, such as a broker that is not running.
+
## Keys
- `Up/Down` — select consumer
- `s` — cycle sort column
- `S` — reverse sort order
+- `Shift+F8` — fix with AI the selected consumer, when it has an error or does
not run
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAiPromptTest.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAiPromptTest.java
new file mode 100644
index 000000000000..29d5fc00ec65
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/CveAiPromptTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import dev.tamboui.text.Span;
+import dev.tamboui.tui.event.KeyCode;
+import dev.tamboui.tui.event.KeyEvent;
+import dev.tamboui.tui.event.KeyModifiers;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * CAMEL-25362: explain with AI (Shift+F8) on the CVE Audit tab, for the
selected vulnerability.
+ */
+class CveAiPromptTest {
+
+ private final List<String> asked = new ArrayList<>();
+ private IntegrationInfo info;
+ private MonitorContext ctx;
+
+ @BeforeEach
+ void setUp() {
+ Theme.resetForTesting();
+ info = new IntegrationInfo();
+ info.pid = "1234";
+ info.name = "xml-orders";
+ ctx = new MonitorContext(new AtomicReference<>(List.of(info)), new
AtomicReference<>(List.of()));
+ ctx.selectedPid = "1234";
+ ctx.askAiCallback = new MonitorContext.AskAi() {
+ @Override
+ public void fixProblem(Path file, int line, String problem, String
lineText) {
+ asked.add("fix: " + problem);
+ }
+
+ @Override
+ public void ask(String question) {
+ asked.add(question);
+ }
+ };
+ }
+
+ @Test
+ void theQuestionHasTheSeverityArtifactsFixedVersionsAndDescription() {
+ String question = CveAiPrompt.of(info,
vulnerability("x".repeat(CveAiPrompt.MAX_DETAILS + 100)));
+
+ assertThat(question)
+ .startsWith("Explain the vulnerability CVE-2026-1234 (HIGH,
CVSS:3.1/AV:N/AC:L) in the dependencies of"
+ + " the running integration xml-orders: XML
external entity expansion.\n")
+ .contains("It affects: com.example:xml-parser:2.1.0 (via
org.apache.camel:camel-jacksonxml:4.24.0).\n")
+ .contains("Fixed in: 2.1.4, 2.2.0.\n")
+ .contains("Also known as: GHSA-abcd-1234.\n")
+ .contains("Published: 2026-11-01.\n")
+ .contains("x".repeat(CveAiPrompt.MAX_DETAILS) + "...\n")
+ .doesNotContain("x".repeat(CveAiPrompt.MAX_DETAILS + 1))
+ .endsWith("Make no changes to the files unless I agree.");
+ }
+
+ @Test
+ void aVulnerabilityWithoutAFixSaysSo() {
+ CveAuditTab.VulnGroup group = new CveAuditTab.VulnGroup(
+ "CVE-2026-9", "LOW", null, null, null, null,
+ List.of("com.example:lib:1.0"), Map.of(),
List.of("CVE-2026-9"), List.of());
+
+ assertThat(CveAiPrompt.of(info, group))
+ .contains("It affects: com.example:lib:1.0.\n")
+ .contains("No fixed version is known.\n")
+ .doesNotContain("Also known as");
+ }
+
+ @Test
+ void shiftF8AsksAboutTheSelectedVulnerability() {
+ CveAuditTab tab = new CveAuditTab(ctx);
+ assertThat(fKeyHints(tab)).isEmpty();
+ tab.handleKeyEvent(KeyEvent.ofKey(KeyCode.F8, KeyModifiers.SHIFT));
+ assertThat(asked).isEmpty();
+
+ tab.showForTesting(List.of(vulnerability("details")));
+ assertThat(fKeyHints(tab)).contains("Shift+F8").contains("explain with
AI");
+ tab.handleKeyEvent(KeyEvent.ofKey(KeyCode.F8, KeyModifiers.SHIFT));
+ assertThat(asked).singleElement().asString().startsWith("Explain the
vulnerability CVE-2026-1234 (HIGH");
+ }
+
+ private static CveAuditTab.VulnGroup vulnerability(String details) {
+ return new CveAuditTab.VulnGroup(
+ "CVE-2026-1234", "HIGH", "CVSS:3.1/AV:N/AC:L", "XML external
entity expansion", details, "2026-11-01",
+ List.of("com.example:xml-parser:2.1.0"),
+ Map.of("com.example:xml-parser:2.1.0",
"org.apache.camel:camel-jacksonxml:4.24.0"),
+ List.of("CVE-2026-1234", "GHSA-abcd-1234"), List.of("2.1.4",
"2.2.0"));
+ }
+
+ private static String fKeyHints(MonitorTab tab) {
+ List<Span> spans = new ArrayList<>();
+ tab.renderFKeyHints(spans);
+ StringBuilder sb = new StringBuilder();
+ spans.forEach(s -> sb.append(s.content()));
+ return sb.toString();
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaAiPromptTest.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaAiPromptTest.java
new file mode 100644
index 000000000000..32fa158e4f15
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/KafkaAiPromptTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import dev.tamboui.text.Span;
+import dev.tamboui.tui.event.KeyCode;
+import dev.tamboui.tui.event.KeyEvent;
+import dev.tamboui.tui.event.KeyModifiers;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * CAMEL-25362: fix with AI (Shift+F8) on the Kafka tab, for a consumer with
an error or that does not run.
+ */
+class KafkaAiPromptTest {
+
+ private final List<String> asked = new ArrayList<>();
+ private final List<String> notified = new ArrayList<>();
+ private IntegrationInfo info;
+ private MonitorContext ctx;
+
+ @BeforeEach
+ void setUp() {
+ Theme.resetForTesting();
+ info = new IntegrationInfo();
+ info.pid = "1234";
+ info.name = "kafka-orders";
+ ctx = new MonitorContext(new AtomicReference<>(List.of(info)), new
AtomicReference<>(List.of()));
+ ctx.selectedPid = "1234";
+ ctx.askAiCallback = new MonitorContext.AskAi() {
+ @Override
+ public void fixProblem(Path file, int line, String problem, String
lineText) {
+ asked.add("fix: " + problem);
+ }
+
+ @Override
+ public void ask(String question) {
+ asked.add(question);
+ }
+ };
+ ctx.notificationCallback = (message, error) -> notified.add(message);
+ }
+
+ @Test
+ void
theQuestionHasTheStateErrorEndpointGroupSourceAndLastErrorOfTheRoute() {
+ RouteInfo route = new RouteInfo();
+ route.routeId = "orders";
+ route.source = "orders.camel.yaml:3";
+ info.routes.add(route);
+ ErrorInfo error = new ErrorInfo();
+ error.routeId = "orders";
+ error.timestamp = 1000;
+ error.exceptionType =
"org.apache.kafka.common.errors.SerializationException";
+ error.exceptionMessage = "Error deserializing key/value";
+ info.errors = new ArrayList<>(List.of(error));
+
+ String question = KafkaAiPrompt.of(info, failing());
+
+ assertThat(question)
+ .startsWith("Fix the Kafka consumer of route orders in the
running integration kafka-orders: it is"
+ + " stopped.\n")
+ .contains("Its last error: Error deserializing key/value for
partition orders-0 at offset 42\n")
+ .contains("Its endpoint:
kafka:orders?brokers=localhost:9092\n")
+ .contains("Its consumer group: order-service, member
consumer-1, generation 3.\n")
+ .contains("It last read topic orders, partition 0, offset
41.\n")
+ .contains("Its route is at orders.camel.yaml:3.\n")
+ .contains("The last error of the route:
SerializationException: Error deserializing key/value\n")
+ .endsWith("say how to fix that, and make no changes to the
files.");
+ }
+
+ @Test
+ void aRunningOrPausedConsumerWithoutErrorsHasNothingToFix() {
+ KafkaConsumerInfo ki = new KafkaConsumerInfo();
+ ki.state = "Running";
+ assertThat(KafkaAiPrompt.hasTrouble(ki)).isFalse();
+ ki.state = "PAUSED";
+ assertThat(KafkaAiPrompt.hasTrouble(ki)).isFalse();
+ ki.lastError = "Broker may not be available";
+ assertThat(KafkaAiPrompt.hasTrouble(ki)).isTrue();
+ ki.lastError = null;
+ ki.state = "Stopped";
+ assertThat(KafkaAiPrompt.hasTrouble(ki)).isTrue();
+ }
+
+ @Test
+ void aConsumerThatReadNothingSaysSo() {
+ KafkaConsumerInfo ki = failing();
+ ki.lastTopic = null;
+
+ assertThat(KafkaAiPrompt.of(info, ki)).contains("It has not read a
record yet.\n");
+ }
+
+ @Test
+ void shiftF8AsksAboutTheSelectedConsumerWhenItHasTrouble() {
+ KafkaConsumerInfo healthy = new KafkaConsumerInfo();
+ healthy.routeId = "billing";
+ healthy.state = "Running";
+ info.kafkaConsumers.add(healthy);
+ info.kafkaConsumers.add(failing());
+ KafkaTab tab = new KafkaTab(ctx);
+ tab.onTabSelected();
+
+ // sorted by route: billing first, running without errors
+ assertThat(fKeyHints(tab)).isEmpty();
+ tab.handleKeyEvent(KeyEvent.ofKey(KeyCode.F8, KeyModifiers.SHIFT));
+ assertThat(asked).isEmpty();
+ assertThat(notified).singleElement().asString().startsWith("This Kafka
consumer is running without errors");
+
+ tab.tableState.select(1);
+ assertThat(fKeyHints(tab)).contains("Shift+F8").contains("fix with
AI");
+ tab.handleKeyEvent(KeyEvent.ofKey(KeyCode.F8, KeyModifiers.SHIFT));
+ assertThat(asked).singleElement().asString().startsWith("Fix the Kafka
consumer of route orders");
+ }
+
+ private static KafkaConsumerInfo failing() {
+ KafkaConsumerInfo ki = new KafkaConsumerInfo();
+ ki.routeId = "orders";
+ ki.uri = "kafka:orders?brokers=localhost:9092";
+ ki.state = "Stopped";
+ ki.lastError = "Error deserializing key/value for partition orders-0
at offset 42";
+ ki.groupId = "order-service";
+ ki.memberId = "consumer-1";
+ ki.generationId = 3;
+ ki.lastTopic = "orders";
+ ki.lastPartition = 0;
+ ki.lastOffset = 41;
+ return ki;
+ }
+
+ private static String fKeyHints(MonitorTab tab) {
+ List<Span> spans = new ArrayList<>();
+ tab.renderFKeyHints(spans);
+ StringBuilder sb = new StringBuilder();
+ spans.forEach(s -> sb.append(s.content()));
+ return sb.toString();
+ }
+}