# HeadSpacer for Codex and Claude Code

Version 0.3.1 · private/local distribution. One self-contained package includes
both host manifests and the same workflow. Requires **Node 22.13+** on PATH,
a HeadSpacer account. Runtime dependencies
are bundled; users do not run npm install inside the plugin.

After connection, the plugin exposes prepared board tools including image
upload/read. `upload_image` accepts either canonical base64 or an explicitly
authorized absolute `file_path` for a prepared PNG, JPEG, WebP or GIF within
256 KiB and 1280px per side. The local file is converted outside model context;
the hosted endpoint never reads a path from the user's machine.

Select conversation excerpts or investigation findings and ask:

> Make a HeadSpacer thinking board from these two findings. Explore the question
> “How can we make release ownership clear without adding another meeting?”

The plugin previews native source cards, the question, optional interpretations
and next steps. It creates a private board or adds to a selected editable board,
then reads the accepted cards back and returns the board link. Sources remain
editable snapshots. No transcript scanning, background sync or extra model API
is involved. Your host's usual agent/model usage still applies.

## Install in Codex

From a checkout containing the `plugins` marketplace:

```sh
codex plugin marketplace add /absolute/path/to/headspacer/plugins
codex plugin add headspacer@headspacer
```

In the desktop app, choose the HeadSpacer local marketplace in the plugin browser
and install/enable HeadSpacer if your host manages installation there. Restart
the host or start a fresh chat after installation. The package uses the current
portable `plugin.json` and `mcp.json` layout. This is local distribution, not an
OpenAI public directory listing. Plugin support varies by Codex surface.

## Install in Claude Code

```sh
claude plugin marketplace add /absolute/path/to/headspacer/plugins
claude plugin install headspacer@headspacer
```

For a session-only development install:

```sh
claude --plugin-dir /absolute/path/to/headspacer/plugins/headspacer
```

Invoke `/headspacer:think` with the selected material. `/headspacer:setup` explains
connection setup. Restart Claude Code after changing an installed package.

## Connect in your browser

1. In Codex, choose **Set up** on HeadSpacer, or say **“Connect me to
   HeadSpacer.”** In Claude Code, use `/headspacer:setup`.
2. The plugin opens a HeadSpacer page in your browser. Sign in if needed;
   you return to the same connection. Choose **New boards only** (the default),
   particular existing boards, or all boards you own, then press **Connect**.
3. When the page says **You’re ready to think**, return to your agent. The plugin
   saved the connection automatically. No manual agent creation, token copying,
   command or configuration editing is needed.

If the browser does not open, the agent supplies the same approval link. Keep
Codex/Claude open while connecting. Links expire after ten minutes; a plugin
restart resumes the pending request. If the website restarts, begin a new
connection. Permission lasts 90 days and can be revoked in
[Your agents](https://headspacer.com/boards?view=agents).

The browser explicitly approves read/edit access and board creation. The default
allows only new boards created through that credential. This does not grant
access to your other conversations, files, external apps or paid HeadSpacer AI.

The package uses first-party browser pairing with the existing scoped agent
credentials; it is **not a public OAuth authorization server**. The private
polling proof and resulting credential never enter model tool inputs/results or
the browser. The server issues a credential only after account consent, then
sends it to the requesting plugin. The plugin stores it in
`~/.headspacer/plugins/<host>/credential.json` with private permissions and uses
`https://headspacer.com/mcp`. The local runtime can read that file; this is not
secure-enclave storage. See the [connection contract](../../canvas/docs/agent-connection.md).

## Capture, retry and remove

- A preview saves only the selected content and immutable operations in a private
  local record. Committing sends that selection to HeadSpacer. Existing-board
  imports use that board's audience; source access does not restrict its viewers.
- The capture ID is the recovery handle. After a timeout/restart, retry that exact
  ID. Do not recreate the intent with a new ID or changed content. An accepted
  receipt remains usable even if later read-back fails. Conflicts preserve human
  work; explicitly review/replan rather than silently rebasing.
- Each capture supports 1–8 excerpts (up to 6,000 characters each), up to eight
  interpretations and a 96 KiB input. Long cards scroll in place when selected on the board.
  Local records are capped at 200 per host and are not automatically deleted.
- Attribution uses existing native source URLs and readable capture/reference
  text. Typed provider provenance, source refresh and cross-capture deduplication
  are future work. Reusing the same intent is deduplicated; deliberately creating
  a different capture ID creates a new copy.

Remove only this host's saved credential:

```sh
node /absolute/path/to/plugin/scripts/setup.mjs codex --disconnect
```

Substitute `claude` for that host. Also unset any environment token. Revoke the
agent in **Your agents** to end its access everywhere. Uninstall through the
host's plugin manager (`codex plugin remove headspacer@headspacer` or
`claude plugin uninstall headspacer@headspacer`).

To remove one completed local capture record:

```sh
node /absolute/path/to/plugin/scripts/setup.mjs codex --forget-capture CAPTURE_ID
```

Do not remove an uncertain write's record until reconciled. These actions do not
delete remote boards/cards or exported copies. Remove unwanted cards in the board
separately. The plugin has no automatic remote deletion or external posting.

## Troubleshooting and maintenance

- `setup_required`: ask to connect HeadSpacer and approve in the browser.
- An expired/cancelled connection can be started again. If issuance could not be
  confirmed, check Your agents for an unfinished grant before starting again.
  The server does not silently issue a second credential after an uncertain reply.
- `connection_failed`: check networking, current credential and service; the
  message alone does not prove revocation. Preserve uncertain capture IDs.
- `denied`: verify the chosen board and the deliberately granted role/scope.
- `credential_changed`: the capture is bound to its original credential/endpoint.
  Restore the original authorized profile to reconcile it; do not redirect it.
- `capture_profile_mismatch`: recover through the original host/profile. Each
  host has its own remote retry identity, even if it uses the same credential.
- `conflict`: board fields changed since preview; inspect the board before making
  a new deliberate capture. Do not retry with rewritten content under the old ID.
- `placement_required`: inspect a large board and provide an explicit empty origin.
- `accepted_but_unverified`: the service accepted the capture; retry its ID only
  to verify. Do not create another board.
- `accepted_but_changed`: previously accepted cards have been removed or edited.
  The plugin preserves current work; inspect the board rather than reimporting.

Legacy manual setup is available for diagnostics: `scripts/setup.mjs <host>`
accepts a hidden terminal prompt, or `--token-stdin` from a trusted secret manager.
It is not the normal user flow. A secret manager may provide `HEADSPACER_MCP_TOKEN`
instead; it overrides the local credential and must be unset separately to reset.
Never put a credential into chat, command arguments or committed configuration.

The source of the shared runtime, skills and package generator is
`integrations/agent-plugins/` in the HeadSpacer repository. Rebuild with
`npm run build:plugins`; test with `npm run test:plugins`. The generated
`plugins/headspacer/` directory is installable without source dependencies.
Keep personal state out of the package. For a new release, increment `VERSION`
in `src/runtime.mjs` before rebuilding; hosts can cache packages by version.
Upgrade by replacing the package and refreshing/updating it in the host; private records stay outside
the install directory. `HEADSPACER_PLUGIN_STATE_DIR` can explicitly select an
isolated profile. `HEADSPACER_MCP_URL` permits only the canonical service or a
loopback test endpoint; source material cannot change either setting.

Official formats: [Codex packaging](https://developers.openai.com/plugins/build/plugins),
[local desktop distribution](https://developers.openai.com/plugins/deploy/desktop-only),
[Claude manifest](https://code.claude.com/docs/en/plugins-reference),
[Claude marketplaces](https://code.claude.com/docs/en/plugin-marketplaces).
Public directory review and publisher identity verification are separate from
this implementation; no public listing or marketplace approval is claimed.
