Skip to content

CAMEL-24861: camel_run starts the directory as the app with --source-dir, and camel_control gets a reload action - #26660

Open
davsclaus wants to merge 1 commit into
mainfrom
fix/CAMEL-24861
Open

davsclaus wants to merge 1 commit into
mainfrom
fix/CAMEL-24861

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Description

Two gaps met while an agent built an integration step by step through the camel-jbang-mcp server:

  • camel_run started with the files of the moment. It listed the directory's source files and passed them to camel run, so a file the agent added afterwards, a beans.yaml, a Java class under src/main/java, was not part of the app, and restart replayed the same list. With no files named, the tool now starts camel run --source-dir=. in the directory: the directory is watched, a changed or added file is reloaded in dev mode (with CAMEL-24862: the recursive file watcher watches directories created while it runs, and ignores the compile work directory #26653, a directory created later as well), and a restart starts the same way. Naming files keeps the previous behaviour, for a directory that holds several apps. The result says sourceDir: true and the message says the directory is watched.
  • camel_control had no reload. It has stop, kill, restart, stop-routes, start-routes and reset-stats; the CLI has camel cmd reload, which writes the reload action the CLI connector hands to the reload strategy. A reload loads the routes again from their files without a restart: a changed stylesheet or a dropped data file takes effect, and a file consumed once is read again. The tool gets the same action, answered like reset-stats (the runtime writes no result for it; camel_get_log shows the routes reloaded summary).

Live check through the tool code: camel_run on a directory started camel run --source-dir=. --dev, the reload action returned, stop stopped it; and with camel cmd reload on the same app, a file consumed once was read again after the reload. Tool descriptions, the MCP page's tool table and the upgrade guide updated.

Tests

IntegrationLauncherTest.noFilesRunsTheDirectoryAsTheApp: the --source-dir=. argument line with and without a name and extra arguments; the existing tests for the explicit file list unchanged. Launcher, authoring tools and tool registry tests (33) green, including the prompt budget test with the longer descriptions.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj

…dir, so files added later are part of it, and camel_control gets a reload action

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reload case in camel_control and the tool description updates are clean and well-documented. Two issues with the camel_run --source-dir change.


generated by an AI agent, Hermès

cmd.addAll(sourceDir ? sourceDirArguments(name, dev, extraArgs) : runArguments(sources, name, dev, extraArgs));
JsonObject result = new JsonObject();
if (sources.isEmpty()) {
result.put("directory", directory.toString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: sources.isEmpty() guard fires incorrectly when sourceDir=true

sourceFiles() only lists top-level files (it uses Files.list, not Files.walk). A project where the agent just created a Java class under src/main/java/ — which is exactly the scenario the PR describes — will have sources=[] here and hit the "No source files to run" error, even though camel run --source-dir=. would handle it correctly.

When sourceDir is true, the guard should be skipped (or the directory itself should be the fallback):

if (!sourceDir && sources.isEmpty()) {
    result.put("directory", directory.toString());
    result.put("status", "failed");
    result.put("error", "No source files to run in " + directory + " ...");
    return result;
}

Alternatively keep the guard but use Files.walk when sourceDir to check for any .java file in subdirs — but skipping it for sourceDir=true is simpler and correct.

* @return the arguments after the camel command itself
*/
/** The {@code camel run --source-dir=.} arguments: the directory the process starts in is the app. */
static List<String> sourceDirArguments(String name, boolean dev, List<String> extraArgs) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc misplacement: sourceDirArguments was inserted after the closing */ of the old runArguments Javadoc block, so the structure is now:

/** The camel run arguments for the given files...   <-- @param files, @param name, ...
 * @return the arguments after the camel command itself
 */
/** The camel run --source-dir=. arguments: ...      <-- one-liner Javadoc
static List<String> sourceDirArguments(...)          <-- gets the one-liner (correct)

static List<String> runArguments(...)                <-- now has NO Javadoc

Javadoc tooling attaches the immediately-preceding /**...*/ block, so sourceDirArguments gets the one-liner (fine) and runArguments loses its Javadoc entirely. Move the sourceDirArguments method (with its Javadoc) to a position where the runArguments Javadoc stays directly above runArguments.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • docs
  • dsl/camel-jbang/camel-jbang-core

🔬 Scalpel shadow comparison — Scalpel: 6 of 692 tested, 8 compile-only — current: 6 all tested

Maveniverse Scalpel detected 16 affected modules (current approach: 6).

Skip-tests mode would test 6 modules (2 direct + 6 downstream), skip tests for 8 (generated code, meta-modules)

⚠️ Modules only in Scalpel (10)
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-launcher
  • coverage
  • docs
Modules Scalpel would test (6)
  • camel-jbang-core ← dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/AuthoringTools.java, dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/IntegrationLauncher.java, dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/IntegrationLauncherTest.java
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-route-parser ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-jbang-core
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
  • docs ← docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc, docs/user-manual/modules/ROOT/pages/camel-jbang-mcp.adoc
Modules with tests skipped (8)
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-launcher
  • coverage

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 2 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (16 modules, 1m 55s total)

Total reactor time: 1m 55s

Module Duration Status
Camel :: JBang :: Plugin :: TUI 42.2s FAILURE
Camel :: JBang :: Plugin :: Kubernetes 17.3s SUCCESS
Camel :: JBang :: MCP 17.1s SUCCESS
Camel :: Docs 16.6s SUCCESS
Camel :: JBang :: Plugin :: Testing 8.7s SUCCESS
Camel :: JBang :: Plugin :: Validate 6.7s SUCCESS
Camel :: JBang :: Plugin :: MCP 1.4s SUCCESS
Camel :: JBang :: Plugin :: Generate 1.3s SUCCESS
Camel :: JBang :: Plugin :: Edit 1.3s SUCCESS
Camel :: Coverage 1.0s SUCCESS
Camel :: JBang :: Plugin :: Route Parser 0.9s SUCCESS
Camel :: JBang :: Main 0.7s SUCCESS
Camel :: JBang :: Core n/a
Camel :: JBang :: Integration tests n/a
Camel :: Launcher n/a
Camel :: Launcher :: Container n/a

Top 20 slowest modules:

  • Camel :: JBang :: Plugin :: TUI (42.2s)
  • Camel :: JBang :: Plugin :: Kubernetes (17.3s)
  • Camel :: JBang :: MCP (17.1s)
  • Camel :: Docs (16.6s)
  • Camel :: JBang :: Plugin :: Testing (8.7s)
  • Camel :: JBang :: Plugin :: Validate (6.7s)
  • Camel :: JBang :: Plugin :: MCP (1.4s)
  • Camel :: JBang :: Plugin :: Generate (1.3s)
  • Camel :: JBang :: Plugin :: Edit (1.3s)
  • Camel :: Coverage (1.0s)
  • Camel :: JBang :: Plugin :: Route Parser (0.9s)
  • Camel :: JBang :: Main (0.7s)

⚙️ View full build and test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants