Repository navigation
Conversation
|
(cancelled CI here since we have a ~7h queue atm and freeze is this week) |
cc7d525 to
0982cfd
Compare
|
@neilcsmith-net I've added a SPI which enables tools via plugins to be provided to the harness. This should makes this extension some entry point for NetBeans developers to expand from. |
jtulach
left a comment
There was a problem hiding this comment.
Just few notes after reading first twenty or so files.
eppleton
left a comment
There was a problem hiding this comment.
Thanks for this, ACP support is an interesting addition. A first, structural pass (I haven't reviewed the UI/API/tool code in detail yet; jtulach already left API-level notes):
-
Cluster placement: the description says the feature lives in
extrabecause it's experimental, butnbbuild/cluster.propertiesaddsacp.api,acp.mcp,acp.mcp.spi,acp.mcp.tools,acp.uiandlibs.acptonb.cluster.ide, andacp.mcp.javatonb.cluster.java. That way they would be part of every NetBeans distribution. If experimental is the intent,extra(or a separate cluster) seems a better fit. -
Jackson move and upgrade:
libs.jacksonis moved from theenterprisecluster toideand upgraded from 2.17.2 to 2.22.3 in the same PR. That affects the existing users of the library inenterpriseand is easier to review and revert on its own, so I'd suggest a separate PR for it. In this diff, git also pairs some files as renames across modules (e.g.enterprise/libs.jackson/build.xml→ide/acp.api/build.xml,enterprise/libs.jackson/external/binaries-list→ide/libs.acp/external/binaries-list), which makes the move hard to follow. -
Eclipse metadata:
nbbuild/misc/prepare-bundles/.classpath,.projectand.settings/*are added; that looks accidental. -
LLM attribution: one of the 27 commits carries an
Assisted-by:line, and the PR description doesn't mention coding assistance. The PR template asks forAssisted-byon assisted commits and a note in the description; could you check whether the other commits need it too?
On the positive side, the MCP HTTP server looks carefully done: it binds to 127.0.0.1 on a random port, uses a random per-session bearer token, and validates the Host and Origin headers.
Given the size (111 files, ~13k lines), splitting it (e.g. libraries first, then API/SPI, then UI and tools) would also make review much more manageable.
7bff0d4 to
b8cfdd2
Compare
Move the Jackson module from the enterprise cluster to the IDE cluster so IDE modules can depend on it. Assisted-by: Codex (GPT-6.1 Terra) Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Update the bundled Jackson libraries and their module metadata. Jackson annotations uses version 2.22. Assisted-by: Codex (GPT-6.1 Terra) Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Add the ACP SDK and its supporting libraries to the IDE cluster. Assisted-by: Codex (GPT-6.1 Terra) Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Add ACP agent configuration, connections and sessions, and expose IDE and Java tools through an MCP server and provider SPI. Include tests for the agent API, MCP registry and server. Assisted-by: Codex (GPT-6.1 Terra) Signed-off-by: Anton Epple <toni.epple@eppleton.de> Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Add agent configuration and chat with editor context, session management, permissions, terminal support and change previews. Assisted-by: Codex (GPT-6.1 Terra) Signed-off-by: Anton Epple <toni.epple@eppleton.de> Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
|
Shouldn't we start a new cluster? The amount of AI support modules is likely to grow... it may warrant its own agentic cluster! |
|
As I've been pinged above. There is already a discussion at https://lists.apache.org/thread.html/tofgwlkghf1qfz2s8cbhhyn0xt49110f about this and where it ends up. Resolution should happen there. If this, or any other AI support, is likely to require a faster release schedule, and releases more than once per quarter, then it doesn't belong in this repo at all. I still believe that ASF-released plugins developed in one or more separate repos is the way forward. Again, a choice for the mailing list. -1 to landing this in +1 to handling the Jackson move separately. And possibly rationalising what JSON support we actually need. On the assisted contributions, there is also evolving guidance at https://www.apache.org/legal/generative-tooling.html and elsewhere that is behind and steering what we ask for. |
eppleton
left a comment
There was a problem hiding this comment.
Thanks for the rework. The structural points from my first pass are addressed (own nb.cluster.acp in extra, Eclipse files gone, Jackson in separate commits, Assisted-by everywhere). The cluster question itself belongs to the dev@ thread Neil linked.
This is a second pass focused on the MCP part (acp.mcp, acp.mcp.spi, acp.mcp.tools, acp.mcp.java). All of it is from reading the code; I have not built or run it. The security basics look good: localhost bind, a random per-session token that is revoked when the connection closes, Host/Origin checks, the project path guard using canonical paths, and git run as an argument list rather than through a shell. Details inline:
- spec conformance of notification handling in the HTTP transport
get_current_file_contextreads the activated TopComponent, which is the chat window while the user types in itgit_diffaccepts atargetstarting with-- refactorings run without showing the user the non-fatal problems or a preview, and they are enabled by default
- offset-based Java tools vs. line/column
acp.mcpexports its implementation package
|
|
||
| return switch (method) { | ||
| case "initialize" -> handleInitialize(id); | ||
| case "notifications/initialized" -> null; |
There was a problem hiding this comment.
In the Streamable HTTP transport (2025-03-26, the version announced in initialize), a POST that contains only notifications must be answered with 202 Accepted and no body. Here notifications/initialized gets 204, and every other notification (e.g. notifications/cancelled) falls through to default and gets a JSON-RPC error with id: null and HTTP 200. A JSON-RPC server must not reply to a notification at all. Treating every message without an id as a notification (202, no body) would cover all cases. Related: that protocol version also allows JSON-RPC batches (arrays). These currently end up as Parse error, because the body is always read as a Map. Either support them or announce a protocol version without batching.
| private Map<String, Object> getCurrentFileContext() throws Exception { | ||
| Map<String, Object>[] result = new Map[1]; | ||
| SwingUtilities.invokeAndWait(() -> { | ||
| TopComponent active = TopComponent.getRegistry().getActivated(); |
There was a problem hiding this comment.
TopComponent.getRegistry().getActivated() returns whatever has focus. While the user is typing a question into the ACP chat window, that is AcpChatTopComponent, so "explain the selected code" would get "Active component is not an editor" in exactly the main use case. The UI module already uses EditorRegistry.lastFocusedComponent() for this (AcpAskAgentAction, AcpAskAgentOutputAction), which would be the consistent choice here too.
Also, unlike get_tabs and open_pos, this tool does not apply ProjectPathGuard. The path and the selected text of a file outside any open project are returned to the agent.
| if (target == null || target.isBlank()) { | ||
| return runGit(repoDir, "git", "diff"); | ||
| } | ||
| if (!SAFE_REV.matcher(target).matches()) { |
There was a problem hiding this comment.
SAFE_REV allows - as the first character, so a target such as --ext-diff or -O<file> is passed to git diff as an option rather than as a revision. I didn't find a concrete exploit with the allowed characters (no =, no spaces), but rejecting a leading -, or passing --end-of-options before the revision, would make this robust against future changes to the pattern. (file_history already uses -- correctly.)
| Collection<RefactoringElement> elements = session.getRefactoringElements(); | ||
| List<String> affectedFiles = collectAffectedFiles(elements); | ||
|
|
||
| Problem result = session.doRefactoring(true); |
There was a problem hiding this comment.
Non-fatal problems from preCheck, checkParameters and prepare are collected but only reported back after doRefactoring has already changed the files. In the IDE these are the warnings that the user sees and confirms in the refactoring dialog before anything happens. Together with isEnabledByDefault() being true for this provider (rename, move, copy, safe delete) and for the Java refactorings, an agent can change many files in the project without the user seeing a preview. Whether the agent asks first depends entirely on the agent's own permission policy.
I'd suggest either making the write refactorings opt-in like the git tools, or routing them through a user confirmation (e.g. the ACP permission request the chat already has, or at least stopping on non-fatal problems and returning them instead of continuing). Minor: executeRefactoring is nearly identical in JavaRefactoringToolProvider, so a shared helper in acp.mcp.spi would keep both in sync.
| "filePath", Map.of("type", "string", | ||
| "description", "Absolute path to the Java source file"), | ||
| "offset", Map.of("type", "integer", | ||
| "description", "Character offset of the symbol to rename (0-based)"), |
There was a problem hiding this comment.
Agents generally work with line/column (that is what they see when reading a file), and computing a 0-based character offset is error-prone for them. I also suspect a mismatch on files with CRLF line endings: NetBeans editor documents and the parser work on text with \n line endings, while an agent that counts characters in the file on disk counts \r\n. I haven't tested this. Accepting line/column (1-based, like open_pos) and converting on the IDE side would avoid both problems.
Small thing: when the path is outside an open project, resolveJavaFile returns null, and the agent gets "Java file not found" / "No Java element found" instead of the explicit outside-project error the other tools return.
| </test-type> | ||
| </test-dependencies> | ||
| <public-packages> | ||
| <package>org.netbeans.modules.acp.mcp</package> |
There was a problem hiding this comment.
This exports org.netbeans.modules.acp.mcp, which contains only implementation classes (McpHttpServer, McpServerManager, …). acp.api talks to it through AcpMcpServerProvider in the lookup, so as far as I can see no other module needs this package. If no other module needs it, it could stay private.
neilcsmith-net
left a comment
There was a problem hiding this comment.
I have concerns about the cluster change as currently done. The important thing is that if we decide to merge this here, it must be part of the release cluster config. I don't want to see us repeat the issues with the Rust cluster with this too.
| # Optional modules built into the extra cluster, excluded from distributions. | ||
| clusters.config.experimental.list=\ | ||
| ${clusters.config.full.list},\ | ||
| nb.cluster.acp | ||
|
|
There was a problem hiding this comment.
A separate cluster might be a good idea, but this should go into the release cluster config or not at all. There is no point in accepting this code somewhere it will not be released. Either we release in the IDE or we release as a plugin.
| nb.cluster.acp.dir=extra | ||
| nb.cluster.acp.depends=${clusters.config.full.list} | ||
| nb.cluster.acp=\ | ||
| ide/acp.api,\ | ||
| ide/acp.mcp,\ | ||
| ide/acp.mcp.spi,\ | ||
| ide/acp.mcp.tools,\ | ||
| ide/acp.ui,\ | ||
| ide/libs.acp,\ | ||
| java/acp.mcp.java | ||
|
|
There was a problem hiding this comment.
This is wrong. The source location and .dir need to match or we get strange effects.
If this cluster is acp, the .dir needs to be acp and module sources need to all go into a new acp folder. How to handle the java module if we go with a separate cluster is something to consider. If it has to go in the java cluster, it would need to disable quietly if the rest are missing.
This enables integration with coding agent using the ACP protocol.
It also provides a way to expose MCP tools through HTTP, either directly or via the ACP protocol itself.
I tested it with IBM Bob, Github Copilot, Antigravity and a friend ACP agent he wrote
This is a new feature that creates a new ACP Chat Window, it is in extra as I consider it experimental.
Assisted-by: Codex (GPT-6.1 Terra)
^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
LLMs, Commit messages and PR description:
git log) that all commits have a valid name and email address for you in the Author field.Assisted-by: MODEL_NAME MODEL_VERSIONline appended to the commit message.Assisted-byline from above)If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)