Skip to content

Commit c660173

Browse files
authored
Merge pull request #321 from tninja/kang_feat
Chore: Treat documentation changes as non-code changes
2 parents 14aedcb + 1ba77ec commit c660173

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

ai-code.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ Return one of: `code-change`, `non-code-change`, or `unknown`."
305305
(let* ((raw-answer (ai-code-call-gptel-sync
306306
(concat "Classify whether this user prompt requests program code changes in a repository.\n"
307307
"Reply with exactly one token: CODE_CHANGE or NOT_CODE_CHANGE.\n"
308-
"Treat edit/refactor/implement/fix/add/remove/update/tests as CODE_CHANGE.\n"
308+
"Return CODE_CHANGE only for changes to program code or test code.\n"
309+
"Treat documentation changes and any other non-program-code actions as NOT_CODE_CHANGE.\n"
309310
"Treat explain/summarize/discuss/review without editing as NOT_CODE_CHANGE.\n\n"
310311
"Prompt:\n" prompt-text)))
311312
(answer (upcase (string-trim (or raw-answer "")))))

test/test_ai-code.el

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,31 @@
392392
(should (equal "Please explain why this fails, then update the implementation."
393393
captured-prompt)))))
394394

395+
(ert-deftest ai-code-test-gptel-classifier-prompt-treats-document-edits-as-non-code-change ()
396+
"Test that GPTel instructions reserve CODE_CHANGE for program code edits."
397+
(let ((captured-prompt nil)
398+
(original-require (symbol-function 'require)))
399+
(cl-letf (((symbol-function 'require)
400+
(lambda (feature &optional filename noerror)
401+
(if (eq feature 'gptel)
402+
t
403+
(funcall original-require feature filename noerror))))
404+
((symbol-function 'ai-code-call-gptel-sync)
405+
(lambda (prompt)
406+
(setq captured-prompt prompt)
407+
"NOT_CODE_CHANGE")))
408+
(should (eq 'non-code-change
409+
(ai-code--gptel-classify-prompt-code-change
410+
"Please update the README and other docs.")))
411+
(should
412+
(string-match-p
413+
"Return CODE_CHANGE only for changes to program code or test code\\."
414+
captured-prompt))
415+
(should
416+
(string-match-p
417+
"Treat documentation changes and any other non-program-code actions as NOT_CODE_CHANGE\\."
418+
captured-prompt)))))
419+
395420
(ert-deftest ai-code-test-simple-classifier-reuses-shared-prompt-markers ()
396421
"Test that classifier markers reuse shared prompt-builder constants."
397422
(should (boundp 'ai-code-change--selected-region-note))

0 commit comments

Comments
 (0)