davsclaus opened a new pull request, #26558:
URL: https://github.com/apache/camel/pull/26558

   JIRA: https://issues.apache.org/jira/browse/CAMEL-24798
   
   Seen in the TUI AI panel with a local model against `camel run 
--runtime=spring-boot`: "what's the name of the source file that has the route" 
cost 26 requests and a wrong answer. `camel_get_files` listed one directory 
level, so the exported Maven project showed `application.properties` and a 
README with no hint of `src/main/resources/camel`, a guessed 
`routes/timer-log.yaml` was refused as "not a plain file name", and the TUI 
reported a missing *file* as "No source files found". A human answers this with 
one `ls -R`; now the tool does too.
   
   ## `camel_get_files` (shared by `camel mcp`, `camel tui --mcp` and the F8 
panel)
   
   - **Recursive listing with relative paths.** The list walks the project 
(skipping `target`, `build`, `.git`, `.mvn`, `.idea`, `node_modules` and the 
like), names every file by its path relative to the directory, and says whether 
the directory is a `maven` project or a `flat` folder. Still capped at 99 
entries; the message says when there are more.
   - **Route and configuration files first.** `routeFiles` and `configFiles` 
name them up front, found among all files scanned, not just the listed ones: 
YAML, XML and Java files are judged by their first lines (`- route:`, `- 
from:`, `<routes`, `RouteBuilder`, ...), `application*.properties|yaml` is 
configuration, `pom.xml` is `pom`. Each listed entry carries that `kind`. A 
Maven project gets a one-line hint where routes live.
   - **Which file each running route comes from.** The status document's 
`routes[].source` 
(`nested:.../target/app.jar/!BOOT-INF/classes/!/camel/foo.camel.yaml:4`, 
`classpath:`, `file:`, or a Java class name) is mapped onto the project: 
`src/main/resources/<p>`, `src/main/java/<p>`, the path itself, or a file of 
that name anywhere in the project, with the line; `missing` when nothing 
matches. The TUI adds `routes` for the selected integration; the `camel mcp` 
server when a process is selected and its routes come from the given directory.
   - **Relative paths in `file`.** `src/main/resources/camel/foo.camel.yaml` 
reads; an absolute path or one escaping the directory is refused with a message 
saying so. A missing file says "No such file: ... call camel_get_files without 
file to list them (routeFiles names the routes)". In the TUI that comes back as 
`error` with the directory, instead of "No source files found for the selected 
integration".
   - **`camel_write_file`** takes the same relative paths and creates the 
subdirectory.
   - **The integration's name where a directory is asked for.** A model often 
passes `directory: timer-log`; in the TUI that now means that integration's 
source directory instead of a failed path under the working directory.
   - **One implementation.** The TUI's own listing and reading is gone; 
`McpFacade.getFiles` calls the shared tool and adds what only the TUI knows 
(`devMode`, `temporary`, `editing`, `routes`).
   
   Tool descriptions on both servers say all of this in a sentence; 
`AiPanelPromptBudgetTest` still passes.
   
   ## Docs and tests
   
   - `camel-jbang-mcp.adoc` tool table and the TUI page's "Editing source files 
from an AI agent" section.
   - `AuthoringToolsTest`: Maven layout listing, relative-path read and write, 
path safety, and the route-source mapping for a Spring Boot jar entry, a 
classpath resource, an absolute file, a Java class, a moved file and an unknown 
one. `McpFacadeGetFilesTest`: the exported project through the TUI facade, and 
the error for a missing or escaping path. `McpFacadeWriteFileTest` covers the 
subdirectory write.
   
   Expected effect: the question above becomes one listing and one read; the 
Ollama tab's per-question request count (CAMEL-24794/24796) is the measure.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to