# Use Fungi in your editor (ACP)

> Use an AI agent in Zed or Neovim over ACP. Configure Fungi as a custom agent, then share the terminal's local login and saved project Sessions.

To use an AI agent in Zed or Neovim over ACP, configure Fungi as a custom agent
with command `fungi` and arguments `["acp"]`. The Agent Client Protocol connects
the editor to Fungi running on your machine. Your project files and saved
conversations use the same local service as the Fungi terminal.

## Set up Zed

You need Node 22.13 or newer, [Shiitake's supported environment](/install/), a
local project folder, and Zed with custom ACP agent support. Fungi models
require a signed-in account and a [funded Team](/account/billing/).

### 1. Install and sign in

Install the CLI, then check that your terminal finds it:

```sh
npm i -g @fungi.computer/spore
fungi --version
fungi acp --help
```

From your project folder, sign in:

```sh
fungi login --provider fungi
fungi status
```

Complete browser sign-in, approve Fungi's access, and choose the Team that pays
for models. With one current Team, selection is automatic. `fungi status` shows
the saved login and selected Team. See
[Sign-in and your account](/account/sign-in/) for account help. Keep credentials
out of editor settings.

Bare `fungi login` opens a provider chooser in an interactive terminal. Use
`--provider fungi` to choose Fungi explicitly. Start Zed under the same OS
account and home directory as that terminal so it finds the saved login and
Sessions.

### 2. Add Fungi to Zed

Open Zed's user settings and add this entry, merging it with any existing
`agent_servers` entries:

```json
{
  "agent_servers": {
    "fungi": {
      "type": "custom",
      "command": "fungi",
      "args": ["acp"],
      "env": {}
    }
  }
}
```

Open your project folder in Zed. Open the Agent panel, then select **fungi**
from the new-thread menu. Zed supplies the project directory to Fungi. The
[Zed external-agent guide](https://zed.dev/docs/ai/external-agents) also covers
custom agents and importing threads.

### 3. Pick a model

A new Session uses the Local Agent's default model. To choose a specific model
for your editor conversation, leave the thread idle and open a terminal in the
same project folder:

```sh
fungi sessions list
```

Find that conversation in the list, then run
`fungi sessions resume <session-id>`, replacing `<session-id>` with its ID. In
the Fungi terminal, enter `/model`, choose **Fungi**, then **Luna**
(`@fungi/luna`) or another available model. Confirm the model shown in the
terminal, then use `/exit` to close the terminal client. Continue the same
thread in Zed.

The choice belongs to that Session. Signing in does not change an existing
choice, and a new thread does not inherit another thread's override. **Use agent
model** clears the override. Choose models in the Fungi terminal; the ACP
connection does not expose a model picker. For another provider, configure its
login in Fungi and select its model in the same Session.

### 4. Send a prompt

In the Zed thread, send:

```text
Do not use tools. Reply exactly ACP_LUNA_OK.
```

The reply streams into the Agent panel. Wait for the turn to finish before
sending another task.

## Cancel and reopen a conversation

Use Zed's **Stop** control while Fungi is working. Wait for the turn to stop;
closing a panel or editor only disconnects that client and can leave accepted
work running. Cancellation does not undo file changes already made. Partial text
from an interrupted reply may disappear when you reopen the conversation;
history restores saved messages.

Reopen the Fungi thread from Zed's history to load its saved messages. To bring
in a Session started in the terminal, open **Thread History**, choose **Import
Threads**, and select Fungi. Use the same project folder. Importing or reopening
history does not send another model prompt. **Reload Agent** in the thread menu
reconnects the agent and restores the conversation.

You can also run `fungi resume` in that project to choose a saved Session in the
terminal. `fungi stop` stops the shared local service for all its clients; saved
Sessions remain on disk.

## Set up Neovim with Agentic.nvim

[Agentic.nvim](https://github.com/carlos-algms/agentic.nvim) connects Neovim to
Fungi through ACP. You need Neovim 0.11 or newer, Git, and
[Shiitake's supported environment](/install/). The steps below use the
Agentic.nvim revision verified with Neovim 0.12.5 on Linux.

### 1. Install the CLI and plugin

[Install Shiitake](/install/), then check both executables:

```sh
nvim --version
fungi --version
fungi acp --help
```

For a standard Neovim configuration, install Agentic.nvim as a native package:

```sh
data_home="${XDG_DATA_HOME:-$HOME/.local/share}"
plugin_dir="$data_home/nvim/site/pack/plugins/start/agentic.nvim"
git clone https://github.com/carlos-algms/agentic.nvim "$plugin_dir"
git -C "$plugin_dir" checkout e280deec82cfe642bba2c0d0157d320b706c094a
```

This pins the plugin to the verified revision. If you already manage it with a
plugin manager, keep that installation and use the same revision there; do not
install a second copy.

### 2. Sign in and configure Fungi

In a terminal opened in your project folder, run:

```sh
fungi login --provider fungi
fungi status
```

Complete browser sign-in, approve access, and choose your funded Team. Check
that `fungi status` shows the Team you want. Start Neovim from the same OS
account and home directory so it can use that saved login. No credentials belong
in the Lua configuration.

This Local setup uses browser sign-in. For a client connecting directly to a
Team-hosted Agent with a Team key, see
[Direct Team-hosted Agent clients](#direct-team-hosted-agent-clients).

Add this to your `init.lua`, or your plugin manager's configuration callback:

```lua
require("agentic").setup({
  provider = "fungi",
  acp_providers = {
    fungi = {
      name = "Fungi",
      command = "fungi",
      args = { "acp" },
    },
  },
})
```

If Neovim cannot find Fungi, replace `"fungi"` in `command` with the
executable's absolute path. In Neovim, `:echo executable('fungi')` returns `1`
when it is on Neovim's PATH. Node must also be available there.

### 3. Open a Session, choose Luna, and send

Start Neovim in your project folder and open the chat:

```vim
:lua require("agentic").open()
```

Before sending a prompt, use the [model selection steps above](#3-pick-a-model)
to select **Fungi → Luna** (`@fungi/luna`) for this Session in the Fungi
terminal. Confirm the model shown, then use `/exit` to return to Neovim.
Agentic's ACP connection does not offer Fungi's model picker.

Write this in Agentic's input pane and press **Ctrl+S** to submit:

```text
Do not use tools. Reply exactly ACP_NEOVIM_OK.
```

The reply streams into the chat pane. Wait for completion before sending another
prompt.

### 4. Cancel and restore history

To cancel a running turn:

```vim
:lua require("agentic").stop_generation()
```

Wait for **Generation stopped by the user request**. Closing Neovim only
disconnects the client; it can leave accepted work running. Cancellation does
not undo changes already made.

To reopen a conversation, including after restarting Neovim in the same project,
open the history picker:

```vim
:lua require("agentic").restore_session()
```

Select the saved Session. Its saved user prompts and completed assistant replies
return without another model call. **Interrupted partial assistant text may not
be saved**: the live text visible before cancellation can disappear on restore.
Use the same project directory, OS account, and home directory to find the same
history. If a history request omits the project directory, set the provider's
arguments explicitly:

```lua
args = { "acp", "-C", "/absolute/path/to/project" },
```

The real-client proof uses Neovim 0.12.5 and Agentic.nvim revision
[`e280deec82cf`](https://github.com/carlos-algms/agentic.nvim/tree/e280deec82cfe642bba2c0d0157d320b706c094a),
with Luna streaming, cancellation, and saved history restored after restarting
Neovim.

## Other ACP clients

Configure a custom agent with executable `fungi`, arguments `["acp"]`, and stdio
transport. Run `fungi login --provider fungi` in a terminal first. A client with
terminal-auth support can invoke `fungi acp login` for sign-in.

Use the same OS account and home directory as your terminal so the editor finds
your saved login. The client supplies an absolute project directory when it
creates or loads a Session. If its history browser omits the directory,
configure arguments `["acp", "-C", "/absolute/path/to/project"]`, replacing the
path with your project folder.

Streaming, cancellation, and Session listing/loading use ACP; the client's UI
determines where those controls appear. Fungi's Local ACP connection accepts one
project root. Leave client-supplied MCP servers and additional directories
empty. Run `fungi acp` through the client: it waits for protocol input rather
than opening a terminal conversation.

## Troubleshooting

### Fungi is missing or cannot start

Run `fungi --version` and `fungi acp --help` in a terminal. If those work but
Zed cannot launch it, set `command` to the absolute path of your installed
`fungi` executable. GUI editors can have a different PATH from your shell. Check
that the editor can also find Node, then reload the agent.

### Sign-in, credit, or model errors

Run `fungi status` and `fungi doctor` from the project folder. Check the
selected Team, its credit, and the Session's model. Sign in again if Fungi
requests it. An unavailable model or login error does not silently switch
providers. A Zed model-provider key does not configure Fungi's login.

### `runtime:rejected` or “Tool runtime failed”

This means the runtime rejected an operation; it can happen during local tool
setup before inference. It is not by itself a sign-in error. Fungi bounds skill
discovery summaries while retaining the skills prompt, so a large catalog does
not need to be removed to work around that summary limit.

Inspect the affected Session with `fungi sessions show <session-id> --errors`.
Update the CLI with the install command above. After active work finishes, run
`fungi stop`, then reload the editor's agent to start the updated service. Keep
your skills and Session history. If the error persists, run `fungi doctor` and
include the Session error when reporting it. Doctor checks configuration and
connectivity; it does not prove that a model prompt succeeds.

### History is empty or the connection drops

Check that the editor opens the same project folder under the same OS account.
Import the Fungi threads or use **Reload Agent**. Reconnecting does not cancel
active work. Use `fungi sessions status <session-id>` to inspect its current
state before retrying a task that changes files.

For protocol diagnostics, run `dev: open acp logs` from Zed's Command Palette.
When [reporting a problem](/account/privacy/), include CLI/editor versions and
the error message; remove credentials and private conversation content from any
logs you share.

## Direct Team-hosted Agent clients

A client connecting directly to a Team-hosted Agent with a Team key needs
`agent.read`, `agent.send` and `agent.manage` for the selected Agents.
`agent.send` sends messages into existing Sessions; starting, stopping or
configuring Sessions and running Session extension commands requires
`agent.manage` (labelled **Create and manage Agents and their sessions** in the
Team keys UI). It does not imply `agent.read` or `agent.send`. A key restricted
to selected Agents keeps that restriction for extensions. The local `fungi acp`
setup above uses your local service and signed-in model access.

**Next:** [Resume and inspect your Sessions](/guides/use-the-terminal/).
