graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(native): ship the desktop shell as a signed, notarized macOS app
justrachec4d36567560
diff --git a/apps/native/desktop/Info.plist b/apps/native/desktop/Info.plistindex ed746a66..b38de2dd 100644--- a/apps/native/desktop/Info.plist+++ b/apps/native/desktop/Info.plist@@ -12,10 +12,18 @@<string>0.1.0</string><key>CFBundleShortVersionString</key><string>0.1.0</string>+ <!-- The bundled binary is named for the app: macOS takes the menu-bar+ and ⌘-Tab name from the running executable. The loose dev binary+ stays `graff-native`. --><key>CFBundleExecutable</key>- <string>graff-native</string>+ <string>Codegraff</string><key>CFBundlePackageType</key><string>APPL</string>+ <key>CFBundleIconFile</key>+ <string>icon</string>+ <!-- The window is the whole app; there is nothing to show without it. -->+ <key>LSApplicationCategoryType</key>+ <string>public.app-category.developer-tools</string><key>LSMinimumSystemVersion</key><string>13.0</string><key>NSHighResolutionCapable</key>diff --git a/apps/native/desktop/README.md b/apps/native/desktop/README.mdindex 5a5ab714..386ab982 100644--- a/apps/native/desktop/README.md+++ b/apps/native/desktop/README.md@@ -19,8 +19,33 @@ GRAFF_NATIVE_URL=http://127.0.0.1:3000 ./zig-out/bin/graff-native`icon.png` (the desktop app's own artwork, copied from `gui/src-tauri`)is embedded in the binary and handed to `NSApplication` at startup, so the-Dock and ⌘-Tab show it. A bare binary has no bundle for macOS to read an-icon from, which is why it travels inside the executable.+Dock and ⌘-Tab show it even when the shell runs as a loose binary with no+bundle for macOS to read an icon from.++## A signed, notarized app++```bash+apps/native/desktop/build-app.sh # build + sign+NOTARIZE=1 apps/native/desktop/build-app.sh # …and send it to Apple+```++macOS only, and it refuses to run anywhere else: the shell is AppKit and+WKWebView, and every tool it uses (`iconutil`, `codesign`, `notarytool`)+comes with Xcode's command line tools. It writes `zig-out/macos/Codegraff.app`+— the binary named for the app, so the menu bar and ⌘-Tab say Codegraff,+the artwork converted to an `.icns`, and `Info.plist` beside them — signs+it with a Developer ID under the hardened runtime and a secure timestamp+(what notarization requires), then submits it, staples the ticket, and+checks it with `spctl -a -t install`, which is the check that matches how+the app is distributed. `-t exec` rejects notarized apps that did not come+from the App Store, so it is the wrong question to ask here.++Override `CODESIGN_IDENTITY` and `NOTARY_PROFILE` to sign as someone else.+The profile is made once with `xcrun notarytool store-credentials`.++Launched from Finder an app inherits no environment, so with+`GRAFF_NATIVE_URL` unset the shell looks for a dev server on 3777 and then+3000, and falls back to the first so the window still opens.On Linux the same `main.zig` prints the URL and tries `xdg-open`. WKWebViewis macOS-only — that is a merjs limitation, not a graff one. The existingdiff --git a/apps/native/desktop/build-app.sh b/apps/native/desktop/build-app.shnew file mode 100755index 00000000..1e1a1e33--- /dev/null+++ b/apps/native/desktop/build-app.sh@@ -0,0 +1,61 @@+#!/usr/bin/env bash+# Package the desktop shell as a signed, notarized macOS app.+#+# apps/native/desktop/build-app.sh # build + sign+# NOTARIZE=1 apps/native/desktop/build-app.sh # …and send it to Apple+#+# macOS only: the shell is AppKit + WKWebView, and everything below+# (codesign, iconutil, notarytool) is part of Xcode's command line tools.+set -euo pipefail++[[ "$(uname)" == "Darwin" ]] || { echo "build-app.sh is macOS only (AppKit + WKWebView)"; exit 1; }++here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+root="$(cd "$here/../../.." && pwd)"+out="${OUT_DIR:-$root/zig-out/macos}"+app="$out/Codegraff.app"+# The Developer ID identity to sign with; `security find-identity -v -p codesigning` lists them.+identity="${CODESIGN_IDENTITY:-Developer ID Application: Rachit Pradhan (WWP9DLJ27P)}"+# A keychain profile holding the Apple ID + app-specific password, made once with+# `xcrun notarytool store-credentials <name> --apple-id … --team-id … --password …`.+profile="${NOTARY_PROFILE:-codedb-notary}"++rm -rf "$app"+mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"++echo "▸ building the shell"+zig build-exe "$here/main.zig" -O ReleaseSmall \+ -femit-bin="$app/Contents/MacOS/Codegraff" \+ -framework AppKit -framework WebKit+rm -f "$app/Contents/MacOS/Codegraff.o"++echo "▸ icon"+iconset="$(mktemp -d)/icon.iconset"+mkdir -p "$iconset"+for size in 16 32 128 256 512; do+ sips -z $size $size "$here/icon.png" --out "$iconset/icon_${size}x${size}.png" >/dev/null+ sips -z $((size * 2)) $((size * 2)) "$here/icon.png" --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null+done+iconutil -c icns "$iconset" -o "$app/Contents/Resources/icon.icns"++cp "$here/Info.plist" "$app/Contents/Info.plist"++echo "▸ signing as: $identity"+# Hardened runtime and a secure timestamp are what notarization requires.+codesign --force --options runtime --timestamp --sign "$identity" "$app"+codesign --verify --deep --strict --verbose=2 "$app"++if [[ "${NOTARIZE:-0}" == "1" ]]; then+ zip="$out/Codegraff.zip"+ echo "▸ notarizing (this waits on Apple)"+ ditto -c -k --keepParent "$app" "$zip"+ xcrun notarytool submit "$zip" --keychain-profile "$profile" --wait+ xcrun stapler staple "$app"+ # `-t install` is the check that matches how this is distributed; `-t exec`+ # rejects apps that are notarized but not from the App Store.+ spctl -a -vv -t install "$app"+ ditto -c -k --keepParent "$app" "$zip"+ echo "▸ stapled and zipped: $zip"+fi++echo "▸ $app"diff --git a/apps/native/desktop/main.zig b/apps/native/desktop/main.zigindex 1756a011..bd33aa08 100644--- a/apps/native/desktop/main.zig+++ b/apps/native/desktop/main.zig@@ -20,8 +20,31 @@ fn openLinux(url: []const u8) void {std.log.info("merjs-style shell: open {s} in a browser (WKWebView is macOS-only)", .{url});}+/// Where the UI is served. A bundled app is launched from Finder with no+/// environment to inherit, so when `GRAFF_NATIVE_URL` is unset the shell+/// looks for a dev server on the ports this app uses, newest first, and+/// falls back to the first of them so the window still opens (and shows+/// the browser's own "cannot connect" page) when nothing is listening.+const default_urls = [_][]const u8{ "http://127.0.0.1:3777", "http://127.0.0.1:3000" };++fn listening(url: []const u8) bool {+ // "http://127.0.0.1:<port>" — the port is what follows the last colon.+ const colon = std.mem.lastIndexOfScalar(u8, url, ':') orelse return false;+ const port = std.fmt.parseInt(u16, url[colon + 1 ..], 10) catch return false;+ const io = std.Io.Threaded.global_single_threaded.io();+ const address = std.Io.net.IpAddress.parseIp4("127.0.0.1", port) catch return false;+ const stream = std.Io.net.IpAddress.connect(&address, io, .{ .mode = .stream }) catch return false;+ stream.close(io);+ return true;+}+pub fn main(init: std.process.Init) !void {- const url = init.environ_map.get("GRAFF_NATIVE_URL") orelse "http://127.0.0.1:3000";+ const url = init.environ_map.get("GRAFF_NATIVE_URL") orelse blk: {+ for (default_urls) |candidate| {+ if (listening(candidate)) break :blk candidate;+ }+ break :blk default_urls[0];+ };if (comptime builtin.os.tag == .macos) {try runMac(url);} else {