diff --git a/src/blog/2026-03-01-agent-shell-session-selection.md b/src/blog/2026-03-01-agent-shell-session-selection.md new file mode 100644 index 0000000..a64412b --- /dev/null +++ b/src/blog/2026-03-01-agent-shell-session-selection.md @@ -0,0 +1,59 @@ +--- +title: 'How to Select Sessions When Starting the agent-shell ACP Client Running on Emacs' +pubDate: 2026-03-01 +author: 'Nakahara Daisuke' +tags: ["Emacs"] +--- + +I recently returned to Emacs, motivated by CLI-type AI tools like [GitHub Copilot CLI](https://github.com/github/copilot-cli). + +Copilot CLI supports ACP (Agentic Communication Protocol), which enables communication between AI agents and editors ([GitHub official documentation](https://docs.github.com/en/copilot/reference/acp-server)). +And [agent-shell](https://github.com/xenodium/agent-shell) is an ACP client that runs on Emacs. + +agent-shell can be started with `M-x agent-shell`. +By default, starting agent-shell creates a new session. However, with the following configuration change, you can choose to create a new session or select from past sessions when starting. I'll introduce this configuration. + +## Prerequisites + +```bash +$ emacs --version +GNU Emacs 30.2 +Development version 636f166cfc86 on HEAD branch; build date 2025-12-14. +Copyright (C) 2025 Free Software Foundation, Inc. +GNU Emacs comes with ABSOLUTELY NO WARRANTY. +You may redistribute copies of GNU Emacs +under the terms of the GNU General Public License. +For more information about these matters, see the file named COPYING. +``` + +This article assumes the use of Copilot CLI. + +```bash +$ copilot --version +GitHub Copilot CLI 0.0.420. +Run 'copilot update' to check for updates. +``` + +After starting Emacs, the result of running `M-x agent-shell-version` is as follows: + +``` +agent-shell v0.43.1 +``` + +## Method + +Set the value of `agent-shell-session-strategy` to `prompt`. +Here is an example configuration in `init.el`: + +```elisp +(use-package agent-shell + :custom + (agent-shell-session-strategy 'prompt) + :ensure t) +``` + +With this configuration, you can create a new session or select from history in the minibuffer. Selecting a new session behaves the same as the default behavior, but selecting a past session allows you to resume work in that session's context. This enables you to efficiently manage multiple different projects and tasks. + +--- + +> **Note**: The review and translation were assisted by an AI generative model. The author is responsible for the final content.