···1313GHOSTTY_RESOURCE_PATH := $(CURRENT_MAKEFILE_DIR)/Resources/ghostty
1414GHOSTTY_TERMINFO_PATH := $(CURRENT_MAKEFILE_DIR)/Resources/terminfo
1515GHOSTTY_BUILD_OUTPUTS := $(GHOSTTY_XCFRAMEWORK_PATH) $(GHOSTTY_RESOURCE_PATH) $(GHOSTTY_TERMINFO_PATH)
1616+GHOSTTY_BUILD_STAMP := $(CURRENT_MAKEFILE_DIR)/.ghostty_build_stamp
1717+GHOSTTY_HASH_FILE := $(CURRENT_MAKEFILE_DIR)/.ghostty_hash
1618SPM_CACHE_DIR := /tmp/supacode-spm-cache/SourcePackages
1719VERSION ?=
1820BUILD ?=
1921XCODEBUILD_FLAGS ?=
2022.DEFAULT_GOAL := help
2121-.PHONY: build-ghostty-xcframework build-app build-cli run-app install-dev-build install-release archive export-archive format lint check test test-cli-smoke test-cli-integration bump-version bump-and-release log-stream
2323+.PHONY: build-ghostty-xcframework ensure-ghostty sync-ghostty _check-ghostty-hash _record-ghostty-hash build-app build-cli run-app install-dev-build install-release archive export-archive format lint check test test-cli-smoke test-cli-integration bump-version bump-and-release log-stream
22242325help: # Display this help.
2426 @-+echo "Run make with one of the following targets:"
2527 @-+echo
2628 @-+grep -Eh "^[a-z-]+:.*#" $(CURRENT_MAKEFILE_PATH) | sed -E 's/^(.*:)(.*#+)(.*)/ \1 @@@ \3 /' | column -t -s "@@@"
27292828-build-ghostty-xcframework: $(GHOSTTY_BUILD_OUTPUTS) # Build ghostty framework
3030+build-ghostty-xcframework: $(GHOSTTY_BUILD_STAMP) # Build ghostty framework
3131+ @$(MAKE) _record-ghostty-hash
29323030-$(GHOSTTY_BUILD_OUTPUTS):
3333+# Internal: actually rebuild ghostty.
3434+$(GHOSTTY_BUILD_STAMP):
3135 @cd $(CURRENT_MAKEFILE_DIR)/ThirdParty/ghostty && mise exec -- zig build -Doptimize=ReleaseFast -Demit-xcframework=true -Dsentry=false
3236 rsync -a ThirdParty/ghostty/macos/GhosttyKit.xcframework Frameworks
3337 @src="$(CURRENT_MAKEFILE_DIR)/ThirdParty/ghostty/zig-out/share/ghostty"; \
···3842 rsync -a --delete "$$src/" "$$dst/"; \
3943 mkdir -p "$$terminfo_dst"; \
4044 rsync -a --delete "$$terminfo_src/" "$$terminfo_dst/"
4545+ touch "$(GHOSTTY_BUILD_STAMP)"
41464242-build-app: build-ghostty-xcframework # Build the macOS app (Debug)
4747+# Public entry point: only rebuilds ghostty if submodule SHA changed (or outputs are missing).
4848+ensure-ghostty: _check-ghostty-hash # Ensure GhosttyKit is up-to-date (fast path when unchanged)
4949+5050+# Internal: compare current submodule SHA against the recorded one.
5151+_check-ghostty-hash:
5252+ @current_sha="$$(git -C $(CURRENT_MAKEFILE_DIR)/ThirdParty/ghostty rev-parse HEAD)"; \
5353+ last_sha=""; \
5454+ if [ -f "$(GHOSTTY_HASH_FILE)" ]; then \
5555+ last_sha="$$(cat "$(GHOSTTY_HASH_FILE)")"; \
5656+ fi; \
5757+ artifacts_ok=1; \
5858+ for path in "$(GHOSTTY_XCFRAMEWORK_PATH)" "$(GHOSTTY_RESOURCE_PATH)" "$(GHOSTTY_TERMINFO_PATH)"; do \
5959+ if [ ! -e "$$path" ]; then \
6060+ artifacts_ok=0; \
6161+ fi; \
6262+ done; \
6363+ if [ "$$current_sha" != "$$last_sha" ] || [ "$$artifacts_ok" -ne 1 ]; then \
6464+ echo "Syncing GhosttyKit for submodule $$current_sha"; \
6565+ $(MAKE) -B build-ghostty-xcframework; \
6666+ if [ "$$current_sha" != "$$last_sha" ]; then \
6767+ rm -rf ~/Library/Developer/Xcode/DerivedData/supacode-*; \
6868+ echo "Cleared Xcode DerivedData for ghostty header/module changes"; \
6969+ fi; \
7070+ else \
7171+ echo "GhosttyKit up-to-date (SHA unchanged)"; \
7272+ fi
7373+7474+# Internal: record the current submodule SHA after a successful build.
7575+_record-ghostty-hash:
7676+ @git -C $(CURRENT_MAKEFILE_DIR)/ThirdParty/ghostty rev-parse HEAD > "$(GHOSTTY_HASH_FILE)"
7777+7878+# Force a clean rebuild of GhosttyKit (ignores cached SHA, useful after submodule updates).
7979+sync-ghostty: # Force sync GhosttyKit to current submodule HEAD (always rebuilds)
8080+ @echo "Forcing GhosttyKit rebuild..."
8181+ $(MAKE) -B build-ghostty-xcframework
8282+ rm -rf ~/Library/Developer/Xcode/DerivedData/supacode-*
8383+ @echo "Done. Xcode module cache cleared for fresh compilation."
8484+8585+build-app: ensure-ghostty # Build the macOS app (Debug)
4386 bash -o pipefail -c 'xcodebuild -project supacode.xcodeproj -scheme supacode -configuration Debug build -skipMacroValidation -clonedSourcePackagesDirPath $(SPM_CACHE_DIR) 2>&1 | mise exec -- xcsift -qw --format toon'
44874588build-cli: # Build Swift CLI binary (SPM)
···197240export-archive: # Export xarchive
198241 bash -o pipefail -c 'xcodebuild -exportArchive -archivePath build/supacode.xcarchive -exportPath build/export -exportOptionsPlist build/ExportOptions.plist 2>&1 | mise exec -- xcsift -qw --format toon'
199242200200-test: build-ghostty-xcframework
243243+test: ensure-ghostty
201244 xcodebuild test -project supacode.xcodeproj -scheme supacode -destination "platform=macOS" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" -skipMacroValidation -clonedSourcePackagesDirPath $(SPM_CACHE_DIR) 2>&1
202245203246test-cli-smoke: build-cli # Smoke test CLI executable
+9
README.md
···3131make format # Run swift-format
3232```
33333434+### Local Ghostty sync (avoid submodule/XCFramework drift)
3535+3636+```bash
3737+make ensure-ghostty # fast SHA check, rebuilds only when ThirdParty/ghostty changed
3838+make sync-ghostty # force rebuild + clear DerivedData
3939+```
4040+4141+`build-app` and `test` already run `ensure-ghostty` automatically.
4242+3443## Contributing
35443645- I actual prefer a well written issue describing features/bugs u want rather than a vibe-coded PR