Description
The code example in the readme describes the following to get a command-prefix specific for an agent type:
|
(setq agent-shell-command-prefix |
|
(lambda (buffer) |
|
(let ((config (agent-shell-get-config buffer))) |
|
(pcase (map-elt config :identifier) |
|
('claude-code '("docker" "exec" "claude-dev" "--")) |
|
('gemini-cli '("docker" "exec" "gemini-dev" "--")) |
|
(_ '("devcontainer" "exec" ".")))))) |
This currently does not work and (agent-shell-get-config buffer) always returns nil inside such a function.
(Correction: The function seems to get called twice, with (agent-shell-get-config buffer) returning nil the first time and the proper config the second time. This is still a valid issue however.)
The reason is likely that agent-shell--state is only filled after the client-maker has already been called, which in turn eventually calls the function in agent-shell-command-prefix with an empty agent-shell--state form:
|
(let ((command (map-elt (funcall (map-elt config :client-maker) (current-buffer)) :command))) |
|
(unless (executable-find command) |
|
(kill-buffer shell-buffer) |
|
(error "%s" (agent-shell--make-missing-executable-error |
|
:executable command |
|
:install-instructions (map-elt config :install-instructions))))) |
|
;; Initialize buffer-local state |
|
(setq-local agent-shell--state (agent-shell--make-state |
So either the readme is wrong/outdated and we need to get the agent identifier in a different way (though I can't think of a non-hacky way off the top of my head), or this is a bug/regression.
Sidenote: A function that returns a command-prefix unconditionally works as expected.
Checklist
Description
The code example in the readme describes the following to get a command-prefix specific for an agent type:
agent-shell/README.org
Lines 486 to 492 in 30fe4bd
This currently does not work and
(agent-shell-get-config buffer)always returnsnilinside such a function.(Correction: The function seems to get called twice, with
(agent-shell-get-config buffer)returning nil the first time and the proper config the second time. This is still a valid issue however.)The reason is likely that
agent-shell--stateis only filled after the client-maker has already been called, which in turn eventually calls the function inagent-shell-command-prefixwith an emptyagent-shell--stateform:agent-shell/agent-shell.el
Lines 2743 to 2750 in 30fe4bd
So either the readme is wrong/outdated and we need to get the agent identifier in a different way (though I can't think of a non-hacky way off the top of my head), or this is a bug/regression.
Sidenote: A function that returns a command-prefix unconditionally works as expected.
Checklist