CAMEL-23638: camel-jbang - Add CLI meta-tools to camel ask#23600
CAMEL-23638: camel-jbang - Add CLI meta-tools to camel ask#23600gnodet wants to merge 2 commits into
Conversation
Add 3 CLI meta-tools that give camel ask access to the entire CLI via progressive discovery instead of hardcoded tool definitions: - cli_list_commands: discover commands from auto-generated metadata - cli_command_help: get options/types/defaults for a specific command - cli_exec: execute any CLI command in-process with captured output The existing curated tools are preserved for common operations. The meta-tools serve as an escape hatch for the full 126-command CLI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
💡 Manual integration tests recommended:
All tested modules (6 modules)
|
davsclaus
left a comment
There was a problem hiding this comment.
Nice addition — the three CLI meta-tools are a clean way to give the LLM progressive access to the full CLI without bloating the curated tool list. A few minor observations and questions:
-
Tests: No tests for the new metadata loading and command discovery logic (
loadCommandMetadata,collectCommands,findCommand). These are easily unit-testable without an LLM and would catch regressions. -
Metadata caching:
loadCommandMetadata()re-reads and re-parses the classpath JSON on every tool call. Since it's static, caching it in a field would save repeated I/O in a chat session. -
Question — quoted arguments:
cli_execsplits on\s+, soget route --filter="my route"won't work as expected. Worth documenting in the tool description? -
Question — picocli out/err restore: The
finallyblock restores thePrinterbut not thecommandLine.setOut()/setErr()writers. If an exception occurs, they stay swapped.
Overall the design is solid — in-process picocli execution, output truncation at 32KB, and the system prompt update for LLM discoverability are all good choices. Approving.
This review is a project-rules and conventions check. It does not replace specialized review tools such as CodeRabbit or SonarCloud.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Claus Ibsen
- Cache command metadata in a field instead of re-reading JSON each call - Add proper tokenizeCommand() that handles quoted strings - Restore picocli out/err PrintWriters in finally block - Add unit tests for command tokenization Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
LGTM |
CAMEL-23638
Summary
Currently
camel askhas ~26 hardcoded tool definitions. New CLI features (likecamel get error --diagram) are not automatically available to the LLM. This adds 3 CLI meta-tools that give the LLM progressive access to the entire 126-command CLI:cli_list_commands(filter?)— discover available commands from the auto-generatedcamel-jbang-commands-metadata.jsoncli_command_help(command)— get detailed help for a specific commandcli_exec(command)— execute any CLI command in-process and return captured outputThe existing curated tools are preserved for common operations. The meta-tools serve as an escape hatch for everything else.
How the LLM uses it
Example flow for
camel get error --diagram:cli_list_commands("error")→ seesget error: Get captured routing errors...cli_command_help("get error")→ sees--diagram,--detail,--last, etc.cli_exec("get error --diagram")→ gets the diagram + error detailsDesign decisions
CamelJBangMain.getCommandLine().execute()in-process (no subprocess)Printerand picocliPrintWriter(both restored infinally)--filter="my route")Test plan
cli_list_commandsreturns all commands from metadatacli_list_commandswith filter narrows results correctlycli_command_help("get error")returns all optionscli_exec("catalog component --filter=kafka")returns outputClaude Code on behalf of Guillaume Nodet