Skip to content

Feat: Quick prompts - #367

Merged
tninja merged 9 commits into
mainfrom
kang_feat_11
May 22, 2026
Merged

tninja merged 9 commits into
mainfrom
kang_feat_11

Conversation

@tninja

@tninja tninja commented May 22, 2026

Copy link
Copy Markdown
Owner

We might want to send out same prompt every couple of days or weeks. Eg. Summarise the recent AI coding related news. But we might not want to manually type or find the prompt. This feature is to make this thing easier.

Also do couple of code refactoring / improvement.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “quick prompts” shortcut for sending frequently reused prompts to the active AI session, while refactoring shared path/context helpers into a new utility module and tightening some backend-infra behaviors (terminal dispatch + session naming).

Changes:

  • Introduce ai-code-quick-prompts + ai-code-send-quick-prompt and wire it into the transient menu.
  • Refactor shared helpers (git root, project root, clipboard/window context, repo context formatting) into new ai-code-utils.el and update call sites.
  • Improve backend infra: generic terminal operation dispatch, working-directory resolution via shared helper, and default instance-name preferring current git branch.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ai-code.el Adds quick prompts customization/command; refactors checkpoint/debug prompt sending to reuse confirm/send helper; updates menu.
ai-code-utils.el New shared utilities module (git/project roots, clipboard + context files, repo context formatting, task files dir).
ai-code-input.el Requires new utils module and introduces ai-code--confirm-and-send helper for “edit then send” flows.
ai-code-prompt-mode.el Switches to utils-provided helpers/constants; removes duplicated task-dir helpers.
ai-code-file.el Uses shared helpers and ai-code--confirm-and-send for lint/build/test prompt flows; removes duplicated repo-context formatting.
ai-code-discussion.el Replaces repeated read/edit/send patterns with ai-code--confirm-and-send; updates declarations to utils.
ai-code-github.el Uses ai-code--confirm-and-send for review/PR prompt editing flow.
ai-code-backends-infra.el Adds terminal operation dispatcher, uses shared session-root logic, and prefers branch name for default instance names.
ai-code-backends.el Updates ai-code--git-root declaration to point at utils module.
ai-code-change.el Updates clipboard/git-root/repo-context declarations to utils module.
ai-code-agile.el Updates context-files/git-root declarations to utils module.
ai-code-behaviors.el Updates clipboard/git-root declarations to utils module.
ai-code-gptel-agent.el Updates git-root declaration to utils module.
ai-code-git.el Updates ensure-files-directory/git-root declarations to utils module.
ai-code-harness.el Updates ensure-files-directory/git-root declarations to utils module.
test/test_00-bootstrap.el Makes packaged-library selection robust by filtering to directories.
test/test_ai-code.el Updates checkpoint test to assert prompt insertion (vs direct CLI send/switch).
test/test_ai-code-utils.el New test coverage for extracted utils helpers.
test/test_ai-code-file.el Updates tests to stub ai-code-plain-read-string; adds session-project-root tests.
test/test_ai-code-prompt-mode.el Adjusts note-search tests to assert inserted prompt; normalizes temp external dir via truename.
test/test_ai-code-onboarding.el Makes packaged-transient selection robust by filtering to directories.
test/test_ai-code-backends-infra.el Adds coverage for new default instance naming, session working dir delegation, and terminal dispatch routing.

Comment thread ai-code-backends-infra.el
Comment on lines 18 to 33
@@ -27,6 +26,10 @@
(require 'ai-code-backends-infra-ghostel)

(declare-function ai-code--session-handle-at-input "ai-code-input" ())
(declare-function ai-code--session-project-root "ai-code-utils" ())

;; DONE: In previous PR: https://github.com/tninja/ai-code-interface.el/pull/349, it set default new AI session instance names from prompt buffer filenames
;; But now we want to set the default new AI session instance names as current branch name. If this name has been used for an existing session, then we can fallback to using the prompt buffer filename as the default new AI session instance name.

Comment thread ai-code.el
Comment on lines +223 to +232
;;;###autoload
(defun ai-code-send-quick-prompt ()
"Select and send a pre-defined prompt from `ai-code-quick-prompts`."
;; DONE: use ai-code-read-string to allow user to modify the prompt before sending
(interactive)
(unless ai-code-quick-prompts
(user-error "No quick prompts configured; customize `ai-code-quick-prompts' first"))
(let ((selected (completing-read "Quick prompt: " ai-code-quick-prompts nil t)))
(ai-code--confirm-and-send "Edit quick prompt: " selected)))

Comment thread test/test_ai-code-file.el
((symbol-function 'ai-code-read-string)
(lambda (prompt &optional initial-input &rest _args)
((symbol-function 'ai-code-plain-read-string)
(lambda (prompt &optional initial-input)
Comment thread test/test_ai-code-file.el
Comment thread test/test_ai-code-file.el
Comment thread test/test_ai-code-file.el
Comment thread test/test_ai-code.el
@tninja
tninja merged commit fdace2c into main May 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants