Files
thatguygriffandClaude Opus 5 0506f44db3 Build the Apple Container extension
Turns the empty scaffold into a working Nova extension for Apple Container
and container-compose, in the shape of the Docker Suite extension.

Sidebar (Scripts/Sidebar):
- System, Containers, Images, Volumes and Networks sections
- Containers grouped into compose projects via the com.docker.compose.project
  label container-compose stamps; project rows drive compose up/down/build
  against the matching workspace file
- Lifecycle, shell, logs, inspect, browse and copy commands per resource
- Apple Container publishes no event stream, so the sidebar polls while
  visible and only reloads a section when a fingerprint of its data changes,
  which keeps selection and expansion intact

Hostnames (Scripts/Hostnames.js):
- A container's hostname is <name>.<domain> and the domain lives in Apple
  Container's config.toml, which has no CLI setter, so the Hostname Domain
  preference reads and writes that file directly
- Changing it offers to register the domain with macOS and restart the
  services; the write preserves the file's other tables and its mode

Language support:
- Dockerfile and Compose syntaxes backed by tree-sitter grammars built by
  Tools/build-syntaxes.sh, pinned to revisions that generate ABI 14
- The Compose syntax is named dockercompose because that is the languageId
  docker-language-server recognises compose files by
- docker-language-server is downloaded on first use rather than bundled, at
  roughly 40 MB

Icons are generated by Tools/make-icons.py so they can be regenerated rather
than hand-maintained.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UnSBcR5Lywz5Fbj5FmVbfc
2026-08-18 22:45:14 -03:00

79 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
#
# Builds the tree-sitter grammars the syntaxes depend on.
#
# Nova loads grammars as dylibs named libtree-sitter-<language>.dylib and
# expects ABI 14, so both grammars are pinned to a revision that generates it.
# Run from anywhere: ./Tools/build-syntaxes.sh
#
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
work="${TMPDIR:-/tmp}/apple-container-grammars"
out="$root/Syntaxes"
dockerfile_repo="https://github.com/camdencheek/tree-sitter-dockerfile.git"
dockerfile_ref="971acdd908568b4531b0ba28a445bf0bb720aba5"
yaml_repo="https://github.com/tree-sitter-grammars/tree-sitter-yaml.git"
yaml_ref="v0.7.2"
# Universal so the extension works on Apple silicon and Intel alike.
arches=(-arch arm64 -arch x86_64)
fetch() {
local name="$1"
local repo="$2"
local ref="$3"
local dir="$work/$name"
if [ ! -d "$dir" ]; then
git clone --quiet "$repo" "$dir"
fi
git -C "$dir" fetch --quiet --tags origin
git -C "$dir" checkout --quiet "$ref"
local version
version="$(grep -m1 'define LANGUAGE_VERSION' "$dir/src/parser.c" | awk '{print $3}')"
if [ "$version" != "14" ]; then
echo "error: $name generates tree-sitter ABI $version, Nova expects 14" >&2
exit 1
fi
}
mkdir -p "$work" "$out"
fetch dockerfile "$dockerfile_repo" "$dockerfile_ref"
fetch yaml "$yaml_repo" "$yaml_ref"
echo "building libtree-sitter-dockerfile.dylib"
cc "${arches[@]}" -dynamiclib -O2 -fPIC -std=c11 \
-I "$work/dockerfile/src" \
"$work/dockerfile/src/parser.c" "$work/dockerfile/src/scanner.c" \
-o "$out/libtree-sitter-dockerfile.dylib"
# Nova already ships a grammar registered as "yaml", so the compose grammar is
# built from the same sources under its own symbol names. That keeps the
# Compose syntax on the grammar these queries were written against instead of
# whichever yaml grammar happens to win.
echo "building libtree-sitter-compose.dylib"
renames=(
-Dtree_sitter_yaml=tree_sitter_compose
-Dtree_sitter_yaml_external_scanner_create=tree_sitter_compose_external_scanner_create
-Dtree_sitter_yaml_external_scanner_destroy=tree_sitter_compose_external_scanner_destroy
-Dtree_sitter_yaml_external_scanner_scan=tree_sitter_compose_external_scanner_scan
-Dtree_sitter_yaml_external_scanner_serialize=tree_sitter_compose_external_scanner_serialize
-Dtree_sitter_yaml_external_scanner_deserialize=tree_sitter_compose_external_scanner_deserialize
)
cc "${arches[@]}" -dynamiclib -O2 -fPIC -std=c11 -DYAML_SCHEMA=core "${renames[@]}" \
-I "$work/yaml/src" \
"$work/yaml/src/parser.c" "$work/yaml/src/scanner.c" \
-o "$out/libtree-sitter-compose.dylib"
for library in "$out"/libtree-sitter-*.dylib; do
echo "$(basename "$library"): $(lipo -archs "$library")"
done