Claus Ibsen created CAMEL-24909:
-----------------------------------
Summary: camel-jbang - an edit tool for the authoring set: replace
a snippet instead of rewriting the whole file
Key: CAMEL-24909
URL: https://issues.apache.org/jira/browse/CAMEL-24909
Project: Camel
Issue Type: Improvement
Components: camel-jbang
Reporter: Claus Ibsen
Fix For: 4.23.0
{{camel_write_file}} takes the complete content of a file, so adding one step
to a route means re-emitting every line of it. In the camel-jbang-mcp stepwise
benchmark that is where a local model corrupts lines it never meant to touch.
Evidence (connect/http-client, three focused runs after CAMEL-24906): the
example's starting file contains
{code}
expression: "$[?(@.sku == '${header.sku}')]"
{code}
which the model must reproduce while adding a split to a *different* route in
the same file. In 9 of 9 attempts it wrote
{code}
expression: "$[?(@.sku == '${header.sku}')]""
{code}
30 refused writes in three runs, all the same line. The validator's message is
now exact ("the value of expression ends with two double quotes; remove the
extra one and write the line as ..."), and the model reads it correctly, saying
"I'm still writing `...` with two double quotes at the end", and then emits the
same bytes again. It cannot copy that line; it can write it: in
connect/stock-api, where the same expression is written fresh rather than
copied, it passed.
So the missing tool is a targeted edit: replace a unique snippet with new text,
or insert steps into a named route, validate the result and write it, instead
of the whole file. Every coding agent has one (Claude Code's Edit takes
old_string/new_string and refuses when it is not unique). It removes this class
of corruption, and for a 60-line file it is a fraction of the tokens.
Proposal: {{camel_edit_file}} (directory, file, find, replace, optional count)
in the shared authoring set, next to {{camel_write_file}}: the find text must
occur exactly once, the result is validated as the write is, and the answer
says which lines changed. The reload outcome comes back as it does for a write
(CAMEL-24859).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)