Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions vscode/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,57 @@ return to the defaults as delivered by this app, do the following:
1. Execute the following command in the terminal window: `reset-settings`.
1. Done!

## Using AI coding assistants

This app is built on [code-server][code-server], which is a build of
VS Code that uses the [Open VSX][open-vsx] extension registry instead of the
Microsoft Marketplace. Microsoft only allows their marketplace to be used by
their own branded builds of Visual Studio Code, so which assistants you can
use is decided by what is published on Open VSX.

- **GitHub Copilot is not available.** The `GitHub.copilot` and
`GitHub.copilot-chat` extensions are published exclusively on the Microsoft
Marketplace and are not on Open VSX, so they cannot be found or installed
from within this app. VS Code may still advertise its built-in AI
features; attempting to enable them fails with
`extension GitHub.copilot-chat not found`.
- **Claude Code works.** The `Anthropic.claude-code` extension is published on
Open VSX and can be installed from the Extensions view as usual. It bundles
its own `claude` binary, so no separate Node.js installation is needed.

Because the app runs behind Home Assistant ingress, browser-based sign-in
flows that redirect back to a `vscode://` URL do not work. Sign in from a
terminal inside the editor instead:

1. Open the Visual Studio Code editor.
1. Click on `Terminal` in the top menu bar and click on `New Terminal`.
1. Run `claude` and use the `/login` command, which prints a URL and asks you
to paste back the code it gives you.
Comment thread
frenck marked this conversation as resolved.
Comment thread
frenck marked this conversation as resolved.

Claude Code keeps its settings and credentials in a configuration folder that
this app points at its own data folder, so your login survives app restarts
and updates.

The bundled `claude` binary lives inside the extension folder. If you want it
on your `PATH` for use in the terminal, add the following to the app's
`init_commands` option:

```yaml
init_commands:
- for f in /data/vscode/extensions/anthropic.claude-code-*/resources/native-binary/claude; do test -x $f && ln -sf $f /usr/local/bin/claude; done; true
```

Init commands run before the editor starts, so the link appears after the
first restart following the installation of the extension.

Claude Code's optional voice input needs ALSA, which the app does not ship.
Add it using the `packages` option if you want to use it:

```yaml
packages:
- libasound2t64
```

## Known issues and limitations

- Can this app run on a Raspberry Pi? Yes, but only if you run a 64 bits
Expand Down Expand Up @@ -181,12 +232,14 @@ SOFTWARE.

[addon-badge]: https://my.home-assistant.io/badges/supervisor_addon.svg
[addon]: https://my.home-assistant.io/redirect/supervisor_addon/?addon=a0d7b954_vscode&repository_url=https%3A%2F%2Fgithub.com%2Fhassio-addons%2Frepository
[code-server]: https://github.com/coder/code-server
[contributors]: https://github.com/hassio-addons/app-vscode/graphs/contributors
[discord-ha]: https://discord.gg/c5DvZ4e
[discord]: https://discord.me/hassioaddons
[forum]: https://community.home-assistant.io/t/home-assistant-community-add-on-visual-studio-code/107863?u=frenck
[frenck]: https://github.com/frenck
[issue]: https://github.com/hassio-addons/app-vscode/issues
[open-vsx]: https://open-vsx.org
[reddit]: https://reddit.com/r/homeassistant
[releases]: https://github.com/hassio-addons/app-vscode/releases
[semver]: https://semver.org/spec/v2.0.0
Expand Down
5 changes: 5 additions & 0 deletions vscode/rootfs/etc/s6-overlay/s6-rc.d/code-server/run
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ options+=(--auth none)
export HASS_SERVER="http://supervisor/core"
export HASS_TOKEN="${SUPERVISOR_TOKEN:-}"

# Keep the Claude Code configuration in the persistent data folder. The
# extension host and the integrated terminals inherit this, so both the
# extension and the bundled claude binary use it.
export CLAUDE_CONFIG_DIR="/data/claude"

# Run the code server
cd "${config_path}" || bashio::exit.nok "Could not change working directory"
exec code-server "${options[@]}" "${config_path}"
26 changes: 26 additions & 0 deletions vscode/rootfs/etc/s6-overlay/s6-rc.d/init-user/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Persists user settings and installs custom user packages.
# ==============================================================================
readonly -a DIRECTORIES=(addon_configs addons backup homeassistant media share ssl)
readonly CLAUDE_USER_PATH=/data/claude
readonly GIT_USER_PATH=/data/git
readonly SSH_USER_PATH=/data/.ssh
readonly ZSH_HISTORY_FILE=/root/.zsh_history
Expand Down Expand Up @@ -69,6 +70,31 @@ if ! bashio::fs.file_exists "${GIT_USER_PATH}/.gitconfig"; then
fi
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig || bashio::log.warning "Failed linking .gitconfig"

# Store Claude Code settings & credentials in app data folder. The service
# points Claude Code here through CLAUDE_CONFIG_DIR, which covers both of the
# locations it would otherwise use: ~/.claude and ~/.claude.json.
if ! bashio::fs.directory_exists "${CLAUDE_USER_PATH}"; then
mkdir -p "${CLAUDE_USER_PATH}" \
|| bashio::exit.nok 'Failed to create a persistent Claude Code folder'

chmod 700 "${CLAUDE_USER_PATH}" \
|| bashio::exit.nok \
'Failed setting permissions on persistent Claude Code folder'
fi

# Migrate the non-persistent locations left behind by an older app version.
# Existing files are never overwritten, and the originals are left alone;
# they are simply no longer read once CLAUDE_CONFIG_DIR is set.
if bashio::fs.directory_exists ~/.claude; then
cp -a -n ~/.claude/. "${CLAUDE_USER_PATH}/" \
|| bashio::log.warning 'Failed migrating the Claude Code folder'
fi

if bashio::fs.file_exists ~/.claude.json; then
cp -a -n ~/.claude.json "${CLAUDE_USER_PATH}/.claude.json" \
|| bashio::log.warning 'Failed migrating the Claude Code configuration'
Comment thread
frenck marked this conversation as resolved.
fi

# Install user configured/requested packages
if bashio::config.has_value 'packages'; then
apt update \
Expand Down