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.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
docs: review, test end to end, then clean up after every change
leepokaib2d1b55e64b3
diff --git a/.claude/workflows/after-change.js b/.claude/workflows/after-change.jsnew file mode 100644index 00000000..e3e7c049--- /dev/null+++ b/.claude/workflows/after-change.js@@ -0,0 +1,147 @@+export const meta = {+ name: 'after-change',+ description: 'Review, fix, end-to-end test, then clean up and refactor a finished code change (docs/guides/clean-code.md)',+ whenToUse: 'After every code change once its tests pass, before commit. Run it from the change\'s worktree. args: {change: what changed and which flows to walk, base?: git ref (default origin/dev), e2e?: "minimal" | "full"}',+ phases: [+ { title: 'Review', detail: 'two reviewers, then one verifier that refutes what it can' },+ { title: 'Fix', detail: 'confirmed findings, then e2e failures' },+ { title: 'E2E', detail: 'the changed flows on the real apps' },+ { title: 'Cleanup', detail: 'cleanup edits and a read-only refactor review, then the refactors worth doing' },+ ],+}++const input = typeof args === 'string' ? { change: args } : (args ?? {})+const change = input.change ?? 'the uncommitted and unpushed change in this worktree'+const base = input.base ?? 'origin/dev'+const e2e = input.e2e === 'full' ? 'full' : 'minimal'+const scope = `The change: ${change}+Its diff: \`git diff ${base}\` (committed and uncommitted) plus the new files \`git status --short\` lists, in the current directory (the change's git worktree). Touch nothing outside that worktree and no other agent's work.`++const FINDINGS = {+ type: 'object',+ properties: {+ findings: {+ type: 'array',+ items: {+ type: 'object',+ properties: {+ file: { type: 'string' },+ line: { type: 'integer' },+ severity: { type: 'string', enum: ['high', 'medium', 'low'] },+ summary: { type: 'string' },+ failure_scenario: { type: 'string', description: 'concrete inputs or state and the wrong result' },+ fix: { type: 'string' },+ },+ required: ['file', 'severity', 'summary', 'failure_scenario', 'fix'],+ },+ },+ },+ required: ['findings'],+}++const VERDICTS = {+ type: 'object',+ properties: {+ confirmed: { type: 'array', items: FINDINGS.properties.findings.items },+ refuted: { type: 'array', items: { type: 'object', properties: { summary: { type: 'string' }, why: { type: 'string' } }, required: ['summary', 'why'] } },+ },+ required: ['confirmed', 'refuted'],+}++const FIXED = {+ type: 'object',+ properties: {+ applied: { type: 'array', items: { type: 'string' } },+ skipped: { type: 'array', items: { type: 'object', properties: { item: { type: 'string' }, why: { type: 'string' } }, required: ['item', 'why'] } },+ tests: { type: 'string', description: 'which builds and tests ran and their result' },+ },+ required: ['applied', 'skipped', 'tests'],+}++const CHECKS = {+ type: 'object',+ properties: {+ checks: {+ type: 'array',+ items: {+ type: 'object',+ properties: {+ platform: { type: 'string' },+ flow: { type: 'string' },+ result: { type: 'string', enum: ['pass', 'fail', 'not_run'] },+ detail: { type: 'string', description: 'what was seen; for fail the symptom, for not_run why' },+ },+ required: ['platform', 'flow', 'result', 'detail'],+ },+ },+ },+ required: ['checks'],+}++const LENSES = [+ { name: 'correctness', text: 'correctness: bugs, regressions, broken edge cases, error handling, data loss, security, and compatibility with older clients and hosts (docs/reference/compatibility.md)' },+ { name: 'completeness', text: 'completeness: every client the change should reach (iPhone, Android, desktop, terminal UI, per CLAUDE.md cross-platform rules), docs made stale by it, missing or weak tests, and the version bump and What\'s New rules' },+]++phase('Review')+const reviews = await parallel(LENSES.map((lens) => () =>+ agent(`Review a code change, read-only (edit nothing). Lens: ${lens.text}.+${scope}+Report only real defects with a concrete failure scenario, most severe first; style nits are not findings. Return an empty list when there are none.`,+ { label: `review:${lens.name}`, phase: 'Review', schema: FINDINGS })))+const found = reviews.filter(Boolean).flatMap((r) => r.findings)+let confirmed = []+let refuted = []+if (found.length) {+ const verdict = await agent(`Verify review findings on a code change, read-only. For each finding, read the code and try to refute it: is the failure scenario real in this code? Default to refuted when you can't reproduce the reasoning. Merge duplicates.+${scope}+Findings:+${JSON.stringify(found, null, 2)}`, { label: 'verify', phase: 'Review', schema: VERDICTS })+ confirmed = verdict?.confirmed ?? found+ refuted = verdict?.refuted ?? []+}+log(`Review: ${found.length} found, ${confirmed.length} confirmed`)++const fix = (what, items) => agent(`Fix these ${what} in the change, the smallest correct fix at the root cause, then rerun the builds and tests the fix touches (CLAUDE.md lists each part's checks).+${scope}+${JSON.stringify(items, null, 2)}`, { label: `fix:${what}`, phase: 'Fix', schema: FIXED })++phase('Fix')+const reviewFix = confirmed.length ? await fix('review findings', confirmed) : null++const walk = (round) => agent(`End-to-end test a code change on the real apps, ${e2e} e2e as CLAUDE.md "End-to-end test every change" defines it (minimal: only this computer's platform; full: also Lima Linux and the UTM Windows VM, skipping and reporting a VM that isn't installed).+${scope}+Walk the flows the change touches, as a person would, and note what you saw. Stop the old build before installing the new one. In this worktree \`npm run dev\` in apps/desktop runs an isolated sandbox (docs/guides/dev-app.md#worktree-sandboxes); never stop or replace the shared Codync Dev, the production Codync app or another session's sandbox, and stop everything you started when done. A change with nothing to walk (CI, tools, docs) reports one not_run check saying so.${round > 1 ? ' This is the second walk, after fixes for the failures of the first.' : ''}`,+ { label: `e2e:${round}`, phase: 'E2E', schema: CHECKS })++phase('E2E')+let walked = await walk(1)+let e2eFix = null+const failures = (walked?.checks ?? []).filter((c) => c.result === 'fail')+if (failures.length) {+ e2eFix = await fix('e2e failures', failures)+ walked = await walk(2)+}++phase('Cleanup')+const [cleanup, refactor] = await parallel([+ () => agent(`Cleanup pass on a code change (docs/guides/clean-code.md "After every change"): edit directly. Remove dead code, duplication, unclear names, comments that restate the code or no longer match it, unused imports; reuse existing helpers. Keep behavior identical and match the surrounding code. Rerun the affected builds and tests.+${scope}+Return what you changed, one line each, and the test result.`,+ { label: 'cleanup', phase: 'Cleanup', agentType: 'code-simplifier:code-simplifier' }),+ () => agent(`Refactor review of a code change (docs/guides/clean-code.md "After every change"), read-only: responsibility splits, files past ~500 lines, long functions, layer leaks, missed reuse, language best practices (Swift 6, Rust rust-skills, strict TypeScript, Compose), and any bug you notice. Only suggestions worth their diff.+${scope}`, { label: 'refactor-review', phase: 'Cleanup', schema: FINDINGS }),+])+const refactors = refactor?.findings ?? []+const applied = refactors.length+ ? await agent(`Apply the refactor suggestions worth doing to the change, skip the rest with one line why each, then rerun the affected builds and tests. A cleanup agent just edited the same files: work on the current state.+${scope}+${JSON.stringify(refactors, null, 2)}`, { label: 'apply-refactors', phase: 'Cleanup', schema: FIXED })+ : null++return {+ review: { found: found.length, confirmed, refuted, fix: reviewFix },+ e2e: { checks: walked?.checks ?? [], fix: e2eFix },+ cleanup,+ refactor: { suggested: refactors, applied },+}diff --git a/AGENTS.md b/AGENTS.mdindex 45236840..124ed8a2 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -43,7 +43,7 @@ After every change, test it end to end on the real apps, not just builds and uni## Versioning & releases- **Every source change ships as a release.** A version bump on `main` is the only release trigger (Auto Tag → desktop app for macOS, Linux and Windows, host, Homebrew, in-app update), so any change to shipped code (`apps/`, `host/`, `packaging/`) bumps the version before it reaches `main`, without being asked. Docs, `web/`, `cloud/`, `relay/` and CI-only changes don't bump.-- Phone ↔ host compatibility: each side names the oldest version of the other it works with (`minApp` in the host's `hello`, `minHost` in each client). Additive changes need nothing; a rename/removal raises `minApp` in the same release, and hosts hold that release until the App Store has the iPhone app: [docs/reference/compatibility.md](docs/reference/compatibility.md)+- Phone ↔ host compatibility: each side names the oldest version of the other it works with (`minApp` in the host's `hello`, `minHost` in each client). Additive changes need nothing; a rename/removal raises `minApp` in the same release, and the release gate holds that release until the App Store has the iPhone app: [docs/reference/compatibility.md](docs/reference/compatibility.md)- Pick the bump yourself: patch for fixes and small tweaks, minor for new features or protocol additions. Never bump major (stay on 2.x). One bump per merge into `main`: if `MARKETING_VERSION` is already ahead of the latest `v*` tag, leave it. A change to `host/crates/memory` also raises `codync-mem`'s own 0.x version once per release (leave it if it's already ahead of `main`'s); CI blocks a PR into `main` that forgets, and the merge publishes it to crates.io ([codync-mem releases](docs/guides/development.md#codync-mem-releases)).- How: set `MARKETING_VERSION` in `apps/project.yml` and `version` in `host/Cargo.toml` (+ its `Cargo.lock` entry) and `apps/desktop/package.json` (+ `package-lock.json`) to the same value, run `xcodegen generate --spec apps/project.yml`, commit as `build: bump version to X.Y.Z`. Never touch `CURRENT_PROJECT_VERSION` (Xcode Cloud sets the iOS build number). When the iOS app changes, also write that version's section in `apps/ios/WhatsNew.md` (zh-Hant + en-US, what iPhone users notice); it becomes the App Store "What's New".@@ -58,7 +58,7 @@ Name Swift files after their main `UpperCamelCase` type; use `snake_case.rs` and## Clean code- Keep code modular and clean on every change: reuse before writing, one responsibility per file/type, no new code appended to files past ~500 lines (split first), views/components hold no I/O or logic, short single-purpose functions, enums over flags, no dead code, no swallowed errors. Full rules: [docs/guides/clean-code.md](docs/guides/clean-code.md).-- After every code change (tests green, before e2e and commit), run a cleanup agent and a read-only refactor review agent in parallel on the diff, apply what's worth it, and rerun the tests: [after every change](docs/guides/clean-code.md#after-every-change-cleanup-and-refactor-review).+- After every code change (tests green, before commit): review → fix → end-to-end test → cleanup and refactor (in Claude Code, the `after-change` workflow runs all of it): [after every change](docs/guides/clean-code.md#after-every-change-review-e2e-cleanup).## Cross-platform UI changesdiff --git a/CLAUDE.md b/CLAUDE.mdindex 35fe5bd3..19a7f304 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -17,7 +17,7 @@ Bot-based remote for coding agents: persistent named bots on your computer, mess## Clean code- Keep code modular and clean on every change: reuse before writing, one responsibility per file/type, no new code appended to files past ~500 lines (split first), views/components hold no I/O or logic, short single-purpose functions, enums over flags, no dead code, no swallowed errors. Full rules: [docs/guides/clean-code.md](docs/guides/clean-code.md).-- After every code change (tests green, before e2e and commit), run a cleanup agent and a read-only refactor review agent in parallel on the diff, apply what's worth it, and rerun the tests: [after every change](docs/guides/clean-code.md#after-every-change-cleanup-and-refactor-review).+- After every code change (tests green, before commit): review → fix → end-to-end test → cleanup and refactor, by running the `after-change` workflow from the change's worktree: [after every change](docs/guides/clean-code.md#after-every-change-review-e2e-cleanup).## Architecture@@ -70,7 +70,7 @@ After every change, test it end to end on the real apps, not just builds and uni## Versioning- Xcode Cloud archives the `iOS` scheme on every `v*` tag and uploads it to App Store Connect with its own build number, then the `Submit iOS` workflow submits it to App Review for the App Store; don't upload from the local machine or edit `CURRENT_PROJECT_VERSION` for it. Details: [development guide](docs/guides/development.md#ios-releases-xcode-cloud).-- Phone ↔ host compatibility: each side names the oldest version of the other it works with (`minApp` in the host's `hello`, `minHost` in each client). Additive changes need nothing; a rename/removal raises `minApp` in the same release, and hosts hold that release until the App Store has the iPhone app: [docs/reference/compatibility.md](docs/reference/compatibility.md)+- Phone ↔ host compatibility: each side names the oldest version of the other it works with (`minApp` in the host's `hello`, `minHost` in each client). Additive changes need nothing; a rename/removal raises `minApp` in the same release, and the release gate holds that release until the App Store has the iPhone app: [docs/reference/compatibility.md](docs/reference/compatibility.md)- **Every source change ships as a release.** A version bump on `main` is the only release trigger (Auto Tag → desktop app for macOS, Linux and Windows, host, Homebrew, in-app update), so any change to shipped code (`apps/`, `host/`, `packaging/`) bumps the version before it reaches `main`, without being asked. Docs, `web/`, `cloud/`, `relay/` and CI-only changes don't bump.- Pick the bump yourself: patch for fixes and small tweaks, minor for new features or protocol additions. Never bump major (stay on 2.x). One bump per merge into `main`: if `MARKETING_VERSION` is already ahead of the latest `v*` tag, leave it. A change to `host/crates/memory` also raises `codync-mem`'s own 0.x version once per release (leave it if it's already ahead of `main`'s); CI blocks a PR into `main` that forgets, and the merge publishes it to crates.io ([codync-mem releases](docs/guides/development.md#codync-mem-releases)).- How: set `MARKETING_VERSION` in `apps/project.yml` and `version` in `host/Cargo.toml` (+ its `Cargo.lock` entry) and `apps/desktop/package.json` (+ `package-lock.json`) to the same value, run `xcodegen generate --spec apps/project.yml`, commit as `build: bump version to X.Y.Z`. Never touch `CURRENT_PROJECT_VERSION` (Xcode Cloud sets the iOS build number). When the iOS app changes, also write that version's section in `apps/ios/WhatsNew.md` (zh-Hant + en-US, what iPhone users notice); it becomes the App Store "What's New".diff --git a/docs/guides/clean-code.md b/docs/guides/clean-code.mdindex 076ed40c..1c02e9e1 100644--- a/docs/guides/clean-code.md+++ b/docs/guides/clean-code.md@@ -37,11 +37,14 @@ Rules every change follows, in every part of the repository (host, iOS, desktop,- Prefer deleting and simplifying over adding. The smallest diff that fixes the problem in the right place wins.- Every changed piece of logic gets a test that would fail without the change; test behavior, not private details.-## After every change: cleanup and refactor review+## After every change: review, e2e, cleanup-Once a code change works (its tests pass) and before e2e and commit, launch two subagents in parallel on the change's diff:+Once a code change works (its tests pass) and before commit, it goes through three stages, in this order:-- **Cleanup agent** (Claude Code: `code-simplifier:code-simplifier`) edits directly: dead code, duplication, unclear names, comments that restate the code, unused imports, places an existing helper should be reused.-- **Refactor review agent** (Claude Code: `general-purpose`, read-only) reports and does not edit: responsibility splits, files past ~500 lines, long functions, layer leaks, missed reuse, language best practices (Swift 6, Rust `rust-skills`, strict TypeScript, Compose), and any bug it notices.+1. **Review**: two read-only reviewers, one for correctness (bugs, regressions, error handling, security, compatibility with older clients and hosts) and one for completeness (every client the change should reach, stale docs, missing tests, version and What's New rules). A verifier then tries to refute each finding against the code; what survives is fixed at its root cause.+2. **End-to-end test**: the changed flows on the real apps, minimal or full as CLAUDE.md defines it. A failure is fixed and the flows are walked once more.+3. **Cleanup and refactor**: in parallel, a cleanup agent (Claude Code: `code-simplifier:code-simplifier`) edits directly (dead code, duplication, unclear names, comments that restate the code, unused imports, places an existing helper should be reused), and a read-only refactor reviewer reports responsibility splits, files past ~500 lines, long functions, layer leaks, missed reuse, language best practices (Swift 6, Rust `rust-skills`, strict TypeScript, Compose) and any bug it notices. The refactors worth doing are applied and the affected builds and tests rerun.-Give each agent the exact files and hunks of the change and point it at this guide and CLAUDE.md; agents touch only those hunks, never another agent's uncommitted work. Apply the refactors worth doing, keep them in `refactor` commits apart from the behavior change, and rerun the affected builds/tests before e2e. The final report lists what the cleanup changed and each refactor suggestion applied or skipped, with one line why for each skip. Docs- or config-only changes skip this; a tool without subagents does both passes itself.+In Claude Code, the `after-change` workflow (`.claude/workflows/after-change.js`) runs all three: start it from the change's worktree with `{"change": "<what changed and which flows to walk>", "e2e": "minimal"}` (`"full"` for platform code, packaging or the desktop main process; `"base"` if the change isn't against `origin/dev`). It returns the confirmed and refuted findings, the e2e checks, what the cleanup changed and each refactor applied or skipped.++Agents touch only the change's own hunks, never another agent's uncommitted work. Keep refactors in `refactor` commits apart from the behavior change. The final report lists the review findings (fixed, or refuted and why), each e2e check that ran or couldn't and why, what the cleanup changed, and each refactor applied or skipped with one line why. Docs- or config-only changes skip this; a tool without subagents does the stages itself.