Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

ci: run CI's checks before each commit

leepokai1a743256a7a1
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
index 352acf31..5d5bc519 100755
--- a/.githooks/pre-commit
+++ b/.githooks/pre-commit
@@ -1,17 +1,70 @@
#!/bin/sh
+# Runs CI's checks for the parts of the repo a commit touches, on the staged files only: other
+# agents' uncommitted edits in this checkout don't count. Skip with `git commit --no-verify`.
set -eu
-staged_files=$(git diff --cached --name-only --diff-filter=ACMR)
+staged_files=$(git diff --cached --name-only)
+touches() { printf '%s\n' "$staged_files" | grep -Eq "$1"; }
-if printf '%s\n' "$staged_files" | grep -q '^apps/screen-linux/'; then
+repo=$(git rev-parse --show-toplevel)
+git_dir=$(git rev-parse --absolute-git-dir)
+# A fixed path keeps cargo's build cache; the lock keeps two commits from sharing it at once.
+snapshot="$git_dir/precommit-snapshot"
+lock="$git_dir/precommit.lock"
+locked=""
+
+staged_copy() {
+ [ -n "$locked" ] && return
+ until mkdir "$lock" 2>/dev/null; do
+ echo "Waiting for another commit's checks..."
+ sleep 5
+ done
+ locked=1
+ trap 'rm -rf "$lock"' EXIT
+ trap 'exit 1' INT TERM
+ rm -rf "$snapshot"
+ mkdir -p "$snapshot"
+ git archive "$(git write-tree)" | tar -x -C "$snapshot"
+}
+
+if touches '^(host/|packaging/(updates|engram)/|docs/reference/fixtures/remote-relay-vectors\.json)'; then
+ staged_copy
+ echo "Checking the host (cargo fmt, clippy, test)..."
+ # CI's pinned memory runtime (fetched once): without it every test turn waits on installing one.
+ engram=$(python3 "$repo/packaging/engram/test-runtime.py")
+ (cd "$snapshot/host" && export CARGO_TARGET_DIR="$repo/host/target/precommit" CODYNC_TEST_ENGRAM="$engram" &&
+ cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test &&
+ cargo test --test memory_e2e -- --ignored &&
+ cargo test --bin codync-host native_memory_survives_restart -- --ignored)
+fi
+
+if touches '^apps/desktop/'; then
+ staged_copy
+ echo "Checking the desktop app (typecheck, test)..."
+ ln -s "$repo/apps/desktop/node_modules" "$snapshot/apps/desktop/node_modules"
+ (cd "$snapshot/apps/desktop" && npm run typecheck && npm test)
+fi
+
+for dir in cloud relay; do
+ if touches "^(cloud/|relay/|docs/reference/fixtures/remote-relay-vectors\\.json)"; then
+ staged_copy
+ echo "Checking $dir (typecheck, test)..."
+ ln -s "$repo/$dir/node_modules" "$snapshot/$dir/node_modules"
+ (cd "$snapshot/$dir" && npm run typecheck && npm test)
+ fi
+done
+
+if touches '^apps/screen-linux/'; then
+ staged_copy
echo "Checking Linux screen helper formatting..."
- cargo fmt --manifest-path apps/screen-linux/Cargo.toml -- --check
+ cargo fmt --manifest-path "$snapshot/apps/screen-linux/Cargo.toml" -- --check
fi
-if printf '%s\n' "$staged_files" | grep -q '^apps/screen-macos/'; then
+if touches '^apps/screen-macos/'; then
if [ "$(uname -s)" = "Darwin" ]; then
+ staged_copy
echo "Checking macOS screen helper syntax..."
- xcrun swiftc -parse apps/screen-macos/*.swift
+ xcrun swiftc -parse "$snapshot"/apps/screen-macos/*.swift
else
echo "Skipping macOS screen helper syntax check (requires macOS)."
fi
diff --git a/CLAUDE.md b/CLAUDE.md
index 86882f02..7b577f0e 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -89,7 +89,7 @@ Build targets, folder layout, file naming and shared terms: [docs/architecture/f
## Commit messages
-Follow the Conventional Commit and PR rules in [AGENTS.md](AGENTS.md#commit--pull-request-guidelines); stage only your own changes.
+Follow the Conventional Commit and PR rules in [AGENTS.md](AGENTS.md#commit--pull-request-guidelines); stage only your own changes. The pre-commit hook (`git config core.hooksPath .githooks`) runs CI's checks for the parts a commit touches ([pre-commit checks](docs/guides/development.md#pre-commit-checks)); fix what it reports instead of `--no-verify`.
## Keeping this file short
diff --git a/docs/guides/development.md b/docs/guides/development.md
index a1a8263f..5a846e73 100644
--- a/docs/guides/development.md
+++ b/docs/guides/development.md
@@ -80,18 +80,25 @@ Unlock the phone when required. Build, install, launch, and visual inspection ar
| Cloud integration | `cd cloud && env -u CODYNC_CLOUD npm run e2e` | Built host; see [Cloudflare testing](cloudflare-testing.md) |
| APNs relay | `cd relay && npm ci && npm test && npm run typecheck` | Separate package from `cloud/` |
-### Screen helpers
+### Pre-commit checks
-Enable the repository's staged-file checks once per checkout:
+Enable the repository's pre-commit hook once per checkout:
```sh
git config core.hooksPath .githooks
```
-When a screen helper changes, the pre-commit hook checks Linux Rust formatting
-and parses the macOS Swift sources (on macOS). The platform builds remain in
-GitHub Actions: Linux requires GStreamer development packages, and macOS builds
-the `Screen` Xcode target against WebRTC.
+It runs CI's checks for each part a commit touches, so a failure shows up before the push:
+host (`cargo fmt --check`, clippy, `cargo test` and the memory tests, with CI's pinned Engram
+fetched once into `host/target/engram-test-runtime`), desktop, cloud and relay (`npm run typecheck`,
+`npm test`), Linux screen helper formatting, and a parse of the macOS screen helper's Swift
+sources (on macOS). It checks the staged files only, in a copy under `.git/precommit-snapshot`,
+so other agents' uncommitted edits in the same checkout neither break nor rescue a commit; the
+host builds into `host/target/precommit`. The npm checks reuse each package's `node_modules`
+(run `npm ci` there first).
+
+Left to CI: the iOS Kit tests (an iPhone simulator) and the platform builds (Linux screen
+helper: GStreamer development packages; macOS: the `Screen` Xcode target against WebRTC).
Host development: `cargo run --manifest-path host/Cargo.toml -- serve`. Avoid competing with an installed host on port 19222; isolated tests should use a temporary `CODYNC_HOME` and another port. Stop test hosts when finished.