# GitHub Copilot CLI adapter

Shows the sessions of GitHub Copilot CLI, the program `copilot`, in the notch: working, done at the end of a turn, failed on an error it cannot recover from, needing you while it shows a permission prompt or asks you a question, what the tool in use does, its first prompt, its repository and its branch as its name, its tool calls as steps and how many subagents it runs.
Copilot CLI reports through hooks: each hook posts its event with `curl` to a Unix socket in your own folder, `~/Library/Application Support/Blossom/copilot/socket`, where this adapter listens. Blossom launches the adapter.
**Permissions and questions are answered in Copilot CLI.** Blossom shows that the session needs you, and you answer in the terminal. A hook of Copilot CLI could allow or deny a tool, but it runs before your own rules; holding it for Blossom is left for after the checks below.
The hooks are one file of Blossom's own in the hooks folder of Copilot CLI, `~/.copilot/hooks/blossom.json`. You can try them in one folder, or install them for every session.

**This adapter was written from the documentation of Copilot CLI and was never run against a real one.** What is documented and what is only supposed is in [../../documentation/roadmap/copilot.md](../../documentation/roadmap/copilot.md); the checks at the end say what to look at.

You need:

- Blossom. It includes this adapter and the Bun that runs it; from a clone, `bun run build` makes one.
- Copilot CLI, `copilot`, signed in. The hooks follow the [hooks reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-hooks-reference) as it read on 2 December 2026, when the newest release was 1.0.118.
- `curl`, `printf` and `cat`, which every hook runs by their full paths under `/usr/bin` and `/bin`, `ps`, which the hook of a prompt runs as `/bin/ps`, and a POSIX shell. macOS ships them. Which shell Copilot CLI runs a hook with is not documented; the hooks were tested with `sh`, `bash` and `zsh`.

## Connect from Blossom

The quickest way. Blossom finds `copilot` on your Mac, and connecting it is one click: "Continue" on the second step of the introduction, with Copilot CLI checked, or its switch in Settings > Agents. Blossom then adds this adapter to its configuration, starts it, and writes the hooks of `adapters/copilot/hooks.json` to `~/.copilot/hooks/blossom.json`, a file of its own. Copilot CLI reads every `.json` file of `~/.copilot/hooks` and adds their hooks to yours, so no file of yours is touched, `~/.copilot/settings.json` included.

When the file is missing, Blossom creates it, and the folders above it, readable by you alone. When it is there, Blossom keeps a copy of it in `~/Library/Application Support/Blossom/backups/copilot/`, named after the moment in UTC, before it writes; it writes the new content to a file next to it and moves it into place, so a failure halfway leaves the file as it was. "Repair" in the row puts the hooks back when they are missing or not the ones this Blossom installs. "Disconnect", shown while the agent is off, takes the adapter out of Blossom and its hooks out of the file, which then holds `{"version": 1}` alone and stays. Blossom does not follow `COPILOT_HOME`: a Copilot CLI that uses another folder does not read the file. What Blossom writes and why is in [the decision](../../documentation/decisions/connecting.md).

## Run Blossom with the adapter

From the root of the clone:

```sh
bun install && bun run bootstrap && bun run build
BLOSSOM_CONFIGURATION=adapters/copilot/configuration.json apps/macos/build/Build/Products/Debug/Blossom.app/Contents/MacOS/Blossom
```

`bootstrap` installs the toolchain the build needs; see [../../documentation/contributing.md](../../documentation/contributing.md).

The notch shows nothing until a session of Copilot CLI reports. Run one Blossom at a time: the adapter holds the socket, and the adapter of a second Blossom logs `cannot listen for the hooks of copilot` and exits.

### From Finder

An app opened from Finder reads `~/Library/Application Support/Blossom/configuration.json`. Name the adapter by its package, which Blossom includes, so neither a path nor Bun is needed:

```json
{ "adapters": [{ "package": "copilot" }] }
```

If the file already exists, add the adapter to its `adapters` list instead.

## Try it in one folder

Copilot CLI also reads the hooks of a repository from `.github/hooks/*.json`, once you let it work in that folder. So try the hooks in a folder made for it, and nothing of yours changes:

```sh
cd "$(mktemp -d)"
mkdir -p .github/hooks && cp "<absolute path of the clone>/adapters/copilot/hooks.json" .github/hooks/blossom.json
copilot
```

Trust the folder when Copilot CLI asks. What you should see:

- Nothing when the session opens. The tile appears next to the notch with the first prompt, named after the first line of that prompt and the repository, `blossom · Fix the flaky notch tests`, with its branch beside it.
- No badge while it works, and the tool in use in live.
- The amber badge while Copilot CLI asks you to allow a tool or answer a question, and no request panel: answer there.
- The green badge when a turn ends; the red one after an error Copilot CLI cannot recover from.
- The tile gone when the session ends.

## Install by hand

For a clone without the app. The file is Blossom's own, so there is nothing to merge. The copy never overwrites a file that is there:

```sh
mkdir -p ~/.copilot/hooks && cp -n adapters/copilot/hooks.json ~/.copilot/hooks/blossom.json
```

## Remove by hand

After an install by hand; after connecting from Blossom, Disconnect does it, and removing Blossom takes out the hooks of every tool, see [Removing it](../../documentation/privacy.md#removing-it). Check that the file holds nothing but Blossom's hooks, which name the socket, and delete it:

```sh
jq -e '[.hooks[]?[]? | select((.command // "") | contains("Blossom/copilot/socket") | not)] | length == 0' ~/.copilot/hooks/blossom.json && rm ~/.copilot/hooks/blossom.json
```

If `jq` prints `false`, someone added a hook of their own to the file: take out only the entries whose `command` names `Blossom/copilot/socket`.

## What to know

- **Permissions and questions are shown, not answered.** Copilot CLI tells a hook when it shows a permission prompt or a question, with a `notification` of type `permission_prompt` or `elicitation_dialog`. The session needs you until its next event, such as the end of the tool. No hook output can answer a question. A `permissionRequest` hook can allow or deny, but it runs before your rules, session approvals and auto-approval, so one held for Blossom would make every call wait for it; it is not installed.
- **A session shows up with its first prompt.** An open session with nothing typed shows nothing, and so does a session that was already running when Blossom started, until its next prompt.
- **The name comes from the first prompt and the repository.** The first line of the first prompt is the title, cut to 60 characters, and stays; a prompt that starts with `/` or `!` titles nothing. The project is the repository and the branch of its folder, read from `HEAD` and the pointers of `.git` at most once every five seconds, without running `git`. See [../../documentation/decisions/names.md](../../documentation/decisions/names.md).
- **Steps are tool calls, saying what they do.** Each call of a tool is a step, from its start to its end; two calls of the same tool are paired with their ends oldest first. A step still running when the turn ends is shown failed. A step is the `description` of a `bash` or `task` call, never the command; the verb and the name of the file of `view`, `edit` and `create`, never its folder or its content; or a label for any other tool. Those fields are read from the documentation of the hooks, not seen in a run. Nothing a tool printed is reported.
- **Subagents are counted from their start to their stop.** The tools of a subagent, whose payloads carry an `agentId`, are not steps of the session, and its stop or its error ends nothing. The end of a turn sets the count to zero. Copilot CLI fires no subagent hook for its built-in `general-purpose` agent.
- **A failed turn.** An `errorOccurred` that says it cannot be recovered fails the turn, and the end of the turn after it keeps it failed. An error that recovers, or does not say, changes nothing. What ends an interrupted turn is not documented.
- **The hooks send the whole payload, and the adapter keeps a few fields.** A payload of Copilot CLI does not name its event, so each hook sends `{"event":"<its event>","payload":<the payload>}`, the payload as it came, with your prompt, the input and the output of tools. The adapter keeps the identifier of the session, the title taken from the first line of the prompt, the name of the tool and the words of its step, the folder, the type of a notification, whether the event comes from a subagent and whether an error recovers, and drops the rest at once. Nothing else of your prompt or of a tool is kept, logged or sent to Blossom. The event is the one the hook is installed on, so no text of the payload can pass for another.
- **The hook of a prompt finds the terminal of its session.** Before it posts, the hook of `userPromptSubmitted` walks up its processes with `/bin/ps`, sixteen at most, for the terminal device and the processes above it, and reads the variables terminal programs and multiplexers set, such as `TERM_PROGRAM`, `__CFBundleIdentifier`, `TMUX_PANE` and `KITTY_WINDOW_ID`. Which environment Copilot CLI gives a hook is not documented: if it is not the one Copilot CLI started with, only the device and the processes arrive. With the session sandbox on, Copilot CLI runs the hooks of your settings inside it, as its documentation says; the sandbox may refuse `/bin/ps` or the socket, and the hook then sends less or nothing, and prints nothing. It sends each value in a header only when it is short and of plain characters, and Blossom keeps it in memory, shows it nowhere, and uses it to bring that terminal forward when you ask. It adds about 50 ms to a prompt, and to no other hook. Hooks connected before this version need Repair in Settings > Agents.
- **The hooks print nothing and always succeed.** Copilot CLI reads what a hook prints as its decision, and a `preToolUse` hook that exits with anything but 0 denies the tool. Every command sends everything it runs to `/dev/null` and ends with `|| /usr/bin/true`, so neither a configuration file of `curl` nor whatever answers on the socket can make a hook decide anything, and with Blossom closed every tool still runs. A function of your shell named `curl`, `printf` or `cat` does not run in place of the full paths.
- **The hooks ignore your curl configuration.** `-q` keeps `curl` from reading `~/.curlrc` and its siblings.
- **Without Blossom, Copilot CLI works as before.** With Blossom closed nothing listens on the socket: each hook gives up at once, prints nothing and ends without an error. When the adapter is alive but does not answer, every event waits one second.
- **A session whose `copilot` was killed leaves within seconds, if the process is the one supposed.** Every command names the process that started its shell, in the header `Blossom-Process`. The adapter watches a process only once two events in a row name it, and every five seconds asks the system whether it still exists. That this process is `copilot` for the whole session is supposed, not seen; if it changes with every event, nothing is watched, and a killed `copilot` leaves its tile until you dismiss it.
- **The socket is yours alone.** It lives in a folder only your user can open. A process that runs as you can still post events to it, or listen on it while Blossom is closed and read the payloads, your prompts included. See [../../documentation/decisions/socket.md](../../documentation/decisions/socket.md).
- **Sixty-four sessions at most.** When a sixty-fifth starts, the adapter closes the one it heard from least recently.
- **Where hooks are turned off, nothing shows.** A repository whose settings set `disableAllHooks`, or managed settings that allow managed hooks only, keep these hooks from running.
- **The hooks find the socket through `$HOME`.** A session started with another `HOME` does not report.

### Not confirmed

Written from the documentation, never seen in a run:

1. That the payload arrives on standard input. The documentation reads it with `cat` in its examples and never says so. If it does not, the hooks send nothing.
2. Which shell runs a hook, and that `$PPID` is the `copilot` process for the whole session.
3. That `~/.copilot/hooks/*.json` loads in a folder Copilot CLI was not told to trust, and whether a file added while a session runs is read.
4. That the hooks of a subagent carry the `sessionId` of its session.
5. What ends an interrupted or failed turn: `agentStop`, `errorOccurred`, or nothing.
6. That `notification` carries `sessionId`, and its `notification_type` as the reference writes it; `notificationType` is read too.
7. That Copilot CLI reads a file of `{"version": 1}` alone, as Disconnect leaves it, as a file without hooks.

## Checks by hand

The adapter was tested with its hook commands run by `sh`, `bash` and `zsh` against the socket, with payloads written from the hooks reference, never captured from a run. Each check below needs `copilot` signed in. Write down what the line in italics asks.

Prepare once. To see the raw payloads first, make a folder whose hooks log what they receive, and remove it afterwards:

```sh
T=$(mktemp -d) && cd "$T" && mkdir -p .github/hooks && echo "$T"
jq -n --arg log "$T/events.log" '{version: 1, hooks: (["userPromptSubmitted", "preToolUse", "postToolUse", "postToolUseFailure", "subagentStart", "subagentStop", "notification", "agentStop", "errorOccurred", "sessionEnd"] | map({(.): [{type: "command", command: ("{ /bin/echo \"" + . + " process $PPID shell $0\"; /bin/cat; /bin/echo; } >> " + $log + " 2>/dev/null; /usr/bin/true")}]}) | add)}' > .github/hooks/logger.json
copilot
```

Trust the folder when Copilot CLI asks.

1. **The payloads.** Ask `hi`, then `run the shell command ls`, allow it, and quit. *Is every event of `events.log` followed by one line of JSON with `sessionId`?* If the lines are empty, the payload does not arrive on standard input, and the hooks of the adapter send nothing.
2. **The shell and the process.** In a second terminal, `ps -ax -o pid,ppid,command | grep '[c]opilot'`. *Which shell does the log name, and is the process on every line the `copilot` of the session, the same for the whole session?*
3. **A permission.** Ask `run the shell command touch probe.txt` and wait. *Is there a `notification` with `"notification_type":"permission_prompt"` and the `sessionId` of the session?*
4. **A question.** Ask `ask me to choose between two options before you answer`. *Is there a `notification` with `"notification_type":"elicitation_dialog"`?*
5. **A subagent.** Ask for a task that Copilot CLI hands to a subagent. *Do `subagentStart` and `subagentStop` appear, and do the tools inside carry `agentId` and the `sessionId` of the session?*
6. **An interrupt.** Ask `count from 1 to 300, one number per line` and press `esc`. *Which event follows: `agentStop`, `errorOccurred`, or none?*

Then run Blossom with the adapter and connect Copilot CLI, which writes `~/.copilot/hooks/blossom.json`. Delete the folder of the logger.

7. **A turn.** In a new folder, start `copilot` and ask `hi`. *Does the tile appear with the prompt, titled `hi` and named after the new folder, with no badge, and turn green when the answer ends?* Write down whether Copilot CLI asked to trust the folder first.
8. **A tool.** Ask `run the shell command sleep 5` and allow it. *Does live show the tool, does detail list it as a step, and does the tile turn green at the end?*
9. **A permission.** Ask `run the shell command touch probe.txt` and do not answer yet. *Does the tile turn amber, with no request panel?* Allow it. *Does it go back to working, and turn green at the end?*
10. **A question.** Ask `ask me to choose between two options before you answer`. *Does the tile turn amber while Copilot CLI asks?*
11. **A subagent.** Ask for a task handed to a subagent. *Does peek show one running subagent while it works, and its tools nowhere among the steps?*
12. **The end.** Quit `copilot`. *Does the tile leave at once?* Start it again, ask `hi`, and `kill -9` its process from another terminal. *Does the tile leave within about five seconds?*
13. **Quitting Blossom.** Quit Blossom and ask `run the shell command ls`. *Does the tool run, with nothing printed about a hook?*
14. **Prompt mode.** `copilot -p hi` in a folder. *Does a tile appear and leave when the run ends?*
15. **Disconnect.** Disconnect Copilot CLI in Settings > Agents. *Does `~/.copilot/hooks/blossom.json` hold `{"version": 1}` alone, does a new session no longer show, and does Copilot CLI start without a complaint about the file?*
16. **The terminal of a session.** Send a prompt from Terminal, one from iTerm and one inside tmux. *Does each prompt start as quickly as before, with nothing printed about a hook?* Then start `copilot` with its session sandbox on and send `hi`. *Does the tile still appear, and does nothing print about a hook?*
