Skip to content

Commit bf400de

Browse files
committed
fix tests
1 parent 963446d commit bf400de

6 files changed

Lines changed: 49 additions & 44 deletions

File tree

HISTORY.org

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
* Release history
33

44
** Main branch change
5+
- Breaking: Remove =ai-code-mcp-editor-tools.el= and merge its remaining MCP tools into the core server and debug modules
6+
- =editor_state= and =visible_buffers= are now built-in MCP tools in =ai-code-mcp-server.el=
7+
- =eval_elisp= now lives in =ai-code-mcp-debug-tools.el= and is gated by =ai-code-mcp-debug-tools-enable-eval-elisp=
8+
- Remove the legacy =messages_tail= tool in favor of =get_recent_messages=
9+
- Remove the old =ai-code-mcp-editor-tools-enabled= and =ai-code-mcp-editor-tools-allow-effect-eval= settings
10+
- Move the dedicated editor-tools tests into the server/debug MCP test files
11+
- Update MCP docs and release notes to match the new tool layout
512

613
** 1.74
714
- Fix: Guard eat/ghostel process filters against deleted buffers on exit and add regression tests

README.org

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ The generated prompt will include the function/region scope, visible file list,
198198

199199
**** Built-in Emacs MCP Tools
200200

201-
AI Code includes an Emacs MCP server with these core built-in tools:
201+
AI Code includes an Emacs MCP server with these built-in tools:
202202
- =project_info=: summarize the current project, active buffer, and file count
203203
- =editor_state=: inspect the currently selected buffer, point, mode, region, and buffer flags
204204
- =visible_buffers=: list the buffers visible in the selected frame windows
@@ -211,14 +211,14 @@ AI Code includes an Emacs MCP server with these core built-in tools:
211211
- =xref_find_definitions_at_point=: find definitions at a file location
212212
- =treesit_info=: inspect tree-sitter node information for a file location
213213

214-
Optional debugging tools are registered from a separate module and are enabled by default:
214+
Additional debugging tools come from =ai-code-mcp-debug-tools.el= and are enabled by default:
215215

216216
#+begin_src emacs-lisp
217217
(setq ai-code-mcp-debug-tools-enabled t) ;; default
218218
;; (setq ai-code-mcp-debug-tools-enabled nil) ;; disable them
219219
#+end_src
220220

221-
When enabled, AI Code also registers:
221+
These tools add:
222222
- =get_variable_value=: return the printed value of an Emacs variable by name
223223
- =get_variable_binding_info=: inspect current and default bindings for an Emacs variable
224224
- =get_function_info=: inspect function metadata such as kind, aliasing, and advice state
@@ -227,15 +227,15 @@ When enabled, AI Code also registers:
227227
- =get_last_error_backtrace=: return the most recently recorded Emacs command error snapshot
228228
- =eval_elisp=: evaluate a single Emacs Lisp form in a chosen buffer context when explicitly enabled
229229

230-
This split keeps the MCP core small while still exposing debugging-oriented tools by default.
230+
The old =ai-code-mcp-editor-tools.el= module has been removed. Its live-editor read tools are now built in, while =eval_elisp= remains an explicit opt-in.
231231

232-
By default, =eval_elisp= is not registered. To opt in explicitly:
232+
To register =eval_elisp=:
233233

234234
#+begin_src emacs-lisp
235235
(setq ai-code-mcp-debug-tools-enable-eval-elisp t)
236236
#+end_src
237237

238-
By default, =eval_elisp= only allows =query= mode. To allow editor-local side effects too, opt in explicitly:
238+
=eval_elisp= only allows =query= mode by default. To allow editor-local side effects too:
239239

240240
#+begin_src emacs-lisp
241241
(setq ai-code-mcp-debug-tools-allow-effect-eval t)
@@ -252,7 +252,7 @@ Set the backend to =claude-code=, =codex=, or =github-copilot-cli= and start a s
252252
- register the current project/buffer as the MCP session context
253253
- inject a session-scoped MCP config into that agent session automatically
254254

255-
Today this auto-wiring is enabled for =claude-code=, =codex=, and =github-copilot-cli=. The adapter layer is designed so other backends can be added later.
255+
Auto-wiring is currently enabled for =claude-code=, =codex=, and =github-copilot-cli=.
256256

257257
If you disabled it before, enable it again with:
258258

@@ -272,10 +272,9 @@ If it shows =:backend=, =:session-id=, and a local =:server-url=, then Emacs has
272272
- use =imenu_list_symbols= for the current file
273273
- use =get_diagnostics= and summarize the current file diagnostics
274274

275-
The status command only proves the Emacs side is wired.
276-
The real proof is that the started agent returns your current project path, buffer context, or current-file symbols from those tools.
275+
The status command only proves the Emacs side is wired. The real proof is that the agent returns your current project path, buffer context, or current-file symbols from those tools.
277276

278-
***** Add New MCP function
277+
***** Add a New MCP Tool
279278

280279
1. Define an Emacs Lisp function.
281280

@@ -309,8 +308,7 @@ If the agent session is already running, restart it after registering the new to
309308
(ai-code-mcp-dispatch "tools/list")
310309
#+end_src
311310

312-
If =current_buffer_name= appears in the tool list, Emacs has registered it.
313-
If the started agent can call it and returns the expected buffer name, the tool is available inside the AI coding agent.
311+
If =current_buffer_name= appears in the tool list, Emacs has registered it. If the agent can call it and returns the expected buffer name, the tool is available inside the AI coding session.
314312

315313
***** Use the MCP Core Directly from Elisp
316314

test/test_ai-code-backends-infra.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
(setq captured-entry (car display-buffer-alist))
274274
'fake-window))
275275
((symbol-function 'window-body-width)
276-
(lambda (_window) 96))
276+
(lambda (&rest _args) 96))
277277
((symbol-function 'window-resize)
278278
(lambda (window delta horizontal)
279279
(setq resize-call (list window delta horizontal)))))

test/test_ai-code-file.el

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ everything is cleaned up afterward."
195195
(opened-in-other-window nil)
196196
(ai-code-task-use-gptel-filename nil))
197197
(cl-letf (((symbol-function 'completing-read)
198-
(lambda (prompt collection &rest args)
198+
(lambda (prompt collection &rest args)
199199
"file"))
200200
((symbol-function 'read-string)
201-
(lambda (prompt &optional initial-input)
201+
(lambda (prompt &optional initial-input &rest _args)
202202
(cond
203203
((string-match-p "Describe" prompt) "test file")
204204
((string-match-p "Confirm" prompt) "test.txt"))))
@@ -223,10 +223,10 @@ everything is cleaned up afterward."
223223
(opened-in-dired nil)
224224
(ai-code-task-use-gptel-filename nil))
225225
(cl-letf (((symbol-function 'completing-read)
226-
(lambda (prompt collection &rest args)
226+
(lambda (prompt collection &rest args)
227227
"directory"))
228228
((symbol-function 'read-string)
229-
(lambda (prompt &optional initial-input)
229+
(lambda (prompt &optional initial-input &rest _args)
230230
(cond
231231
((string-match-p "Describe" prompt) "test directory")
232232
((string-match-p "Confirm" prompt) "test_dir"))))
@@ -250,10 +250,10 @@ everything is cleaned up afterward."
250250
(let ((created-file nil)
251251
(ai-code-task-use-gptel-filename t))
252252
(cl-letf (((symbol-function 'completing-read)
253-
(lambda (prompt collection &rest args)
253+
(lambda (prompt collection &rest args)
254254
"file"))
255255
((symbol-function 'read-string)
256-
(lambda (prompt &optional initial-input)
256+
(lambda (prompt &optional initial-input &rest _args)
257257
(cond
258258
((string-match-p "Describe" prompt) "user authentication module")
259259
((string-match-p "Confirm" prompt) initial-input)))) ; Accept suggested name
@@ -278,10 +278,10 @@ everything is cleaned up afterward."
278278
(let ((created-file nil)
279279
(ai-code-task-use-gptel-filename t))
280280
(cl-letf (((symbol-function 'completing-read)
281-
(lambda (prompt collection &rest args)
281+
(lambda (prompt collection &rest args)
282282
"file"))
283283
((symbol-function 'read-string)
284-
(lambda (prompt &optional initial-input)
284+
(lambda (prompt &optional initial-input &rest _args)
285285
(cond
286286
((string-match-p "Describe" prompt) "test file")
287287
((string-match-p "Confirm" prompt) initial-input)))) ; Accept fallback
@@ -306,10 +306,10 @@ everything is cleaned up afterward."
306306
(let ((created-file nil)
307307
(ai-code-task-use-gptel-filename nil))
308308
(cl-letf (((symbol-function 'completing-read)
309-
(lambda (_prompt _collection &rest _args)
309+
(lambda (_prompt _collection &rest _args)
310310
"file"))
311311
((symbol-function 'read-string)
312-
(lambda (prompt &optional initial-input)
312+
(lambda (prompt &optional initial-input &rest _args)
313313
(cond
314314
((string-match-p "Describe" prompt)
315315
"rdar://12345 Fix crash on startup")
@@ -334,10 +334,10 @@ everything is cleaned up afterward."
334334
(ai-code-file-with-test-env
335335
(let ((ai-code-task-use-gptel-filename nil))
336336
(cl-letf (((symbol-function 'completing-read)
337-
(lambda (prompt collection &rest args)
337+
(lambda (prompt collection &rest args)
338338
"file"))
339339
((symbol-function 'read-string)
340-
(lambda (prompt &optional initial-input)
340+
(lambda (prompt &optional initial-input &rest _args)
341341
""))) ; Empty description
342342
;; Should raise user-error
343343
(should-error (ai-code-create-file-or-dir) :type 'user-error)))))
@@ -347,10 +347,10 @@ everything is cleaned up afterward."
347347
(ai-code-file-with-test-env
348348
(let ((ai-code-task-use-gptel-filename nil))
349349
(cl-letf (((symbol-function 'completing-read)
350-
(lambda (prompt collection &rest args)
350+
(lambda (prompt collection &rest args)
351351
"file"))
352352
((symbol-function 'read-string)
353-
(lambda (prompt &optional initial-input)
353+
(lambda (prompt &optional initial-input &rest _args)
354354
(cond
355355
((string-match-p "Describe" prompt) "test file")
356356
((string-match-p "Confirm" prompt) " "))))) ; Whitespace only
@@ -363,10 +363,10 @@ everything is cleaned up afterward."
363363
(let ((created-file nil)
364364
(ai-code-task-use-gptel-filename nil))
365365
(cl-letf (((symbol-function 'completing-read)
366-
(lambda (prompt collection &rest args)
366+
(lambda (prompt collection &rest args)
367367
"file"))
368368
((symbol-function 'read-string)
369-
(lambda (prompt &optional initial-input)
369+
(lambda (prompt &optional initial-input &rest _args)
370370
(cond
371371
((string-match-p "Describe" prompt) "nested file")
372372
((string-match-p "Confirm" prompt) "src_lib_utils.js"))))
@@ -389,10 +389,10 @@ everything is cleaned up afterward."
389389
(ai-code-task-use-gptel-filename t)
390390
(confirmation-shown nil))
391391
(cl-letf (((symbol-function 'completing-read)
392-
(lambda (prompt collection &rest args)
392+
(lambda (prompt collection &rest args)
393393
"file"))
394394
((symbol-function 'read-string)
395-
(lambda (prompt &optional initial-input)
395+
(lambda (prompt &optional initial-input &rest _args)
396396
(cond
397397
((string-match-p "Describe" prompt) "database connection")
398398
((string-match-p "Confirm" prompt)
@@ -423,10 +423,10 @@ everything is cleaned up afterward."
423423
(let ((created-file nil)
424424
(ai-code-task-use-gptel-filename t))
425425
(cl-letf (((symbol-function 'completing-read)
426-
(lambda (prompt collection &rest args)
426+
(lambda (prompt collection &rest args)
427427
"file"))
428428
((symbol-function 'read-string)
429-
(lambda (prompt &optional initial-input)
429+
(lambda (prompt &optional initial-input &rest _args)
430430
(cond
431431
((string-match-p "Describe" prompt) "test")
432432
((string-match-p "Confirm" prompt)
@@ -453,10 +453,10 @@ everything is cleaned up afterward."
453453
(let ((created-dir nil)
454454
(ai-code-task-use-gptel-filename t))
455455
(cl-letf (((symbol-function 'completing-read)
456-
(lambda (prompt collection &rest args)
456+
(lambda (prompt collection &rest args)
457457
"directory"))
458458
((symbol-function 'read-string)
459-
(lambda (prompt &optional initial-input)
459+
(lambda (prompt &optional initial-input &rest _args)
460460
(cond
461461
((string-match-p "Describe" prompt) "test")
462462
((string-match-p "Confirm" prompt)
@@ -492,10 +492,10 @@ everything is cleaned up afterward."
492492
(lambda ()
493493
dired-dir))
494494
((symbol-function 'completing-read)
495-
(lambda (prompt collection &rest args)
495+
(lambda (prompt collection &rest args)
496496
"file"))
497497
((symbol-function 'read-string)
498-
(lambda (prompt &optional initial-input)
498+
(lambda (prompt &optional initial-input &rest _args)
499499
(cond
500500
((string-match-p "Describe" prompt) "test")
501501
((string-match-p "Confirm" prompt)

test/test_ai-code-input.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
(let ((ai-code-prompt-filepath-completion-enabled t))
224224
;; Mock minibufferp to return true
225225
(cl-letf (((symbol-function 'minibufferp)
226-
(lambda (&optional buffer) t))
226+
(lambda (&rest _args) t))
227227
((symbol-function 'ai-code--any-ai-session-active-p)
228228
(lambda () t))
229229
((symbol-function 'magit-toplevel)
@@ -568,7 +568,7 @@
568568
(completion-called nil))
569569
;; Mock minibufferp to return true
570570
(cl-letf (((symbol-function 'minibufferp)
571-
(lambda (&optional buffer) t))
571+
(lambda (&rest _args) t))
572572
((symbol-function 'ai-code--any-ai-session-active-p)
573573
(lambda () t))
574574
((symbol-function 'completion-at-point)

test/test_ai-code-prompt-mode.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ and ensures everything is cleaned up afterward."
377377
((string-match-p "Create task file in" prompt)
378378
(format "ai-code-files-dir: %s" files-dir)))))
379379
((symbol-function 'read-string)
380-
(lambda (prompt &optional initial-input)
380+
(lambda (prompt &optional initial-input &rest _args)
381381
(cond
382382
((string-match-p "URL" prompt) "https://example.com")
383383
((string-match-p "Confirm task filename" prompt) initial-input))))
@@ -571,7 +571,7 @@ and ensures everything is cleaned up afterward."
571571
((string-match-p "Create task file in" prompt)
572572
(format "ai-code-files-dir: %s" files-dir)))))
573573
((symbol-function 'read-string)
574-
(lambda (prompt &optional _initial-input)
574+
(lambda (prompt &optional _initial-input &rest _args)
575575
(cond
576576
((string-match-p "URL" prompt) "")
577577
;; User removes .org extension
@@ -615,7 +615,7 @@ and ensures everything is cleaned up afterward."
615615
((string-match-p "Create task file in" prompt)
616616
(format "current directory: %s" default-directory)))))
617617
((symbol-function 'read-string)
618-
(lambda (prompt &optional _initial-input)
618+
(lambda (prompt &optional _initial-input &rest _args)
619619
(cond
620620
((string-match-p "URL" prompt) "")
621621
((string-match-p "Confirm task filename" prompt) "task_20260101_my_task/"))))
@@ -1295,7 +1295,7 @@ and ensures everything is cleaned up afterward."
12951295

12961296
(ert-deftest ai-code-test-prompt-auto-trigger-hash-in-minibuffer ()
12971297
"Test that # auto-trigger doesn't work in minibuffer in prompt mode."
1298-
(cl-letf (((symbol-function 'minibufferp) (lambda (&optional buffer) t)))
1298+
(cl-letf (((symbol-function 'minibufferp) (lambda (&rest _args) t)))
12991299
(with-temp-buffer
13001300
(insert "@src/test.el#")
13011301

@@ -1339,7 +1339,7 @@ and ensures everything is cleaned up afterward."
13391339
(ert-deftest ai-code-test-prompt-filepath-capf-in-minibuffer ()
13401340
"Test that capf returns nil in minibuffer in prompt mode."
13411341
(ai-code-with-test-repo
1342-
(cl-letf (((symbol-function 'minibufferp) (lambda (&optional buffer) t)))
1342+
(cl-letf (((symbol-function 'minibufferp) (lambda (&rest _args) t)))
13431343
(with-temp-buffer
13441344
(insert "@src/")
13451345
(goto-char (point-max))

0 commit comments

Comments
 (0)