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
chore: run after-change as one review, one fix pass and one e2e walk
leepokai74da88a4eb1c
diff --git a/.claude/workflows/after-change.js b/.claude/workflows/after-change.jsindex 40511a1c..d5f8a3bf 100644--- a/.claude/workflows/after-change.js+++ b/.claude/workflows/after-change.js@@ -1,12 +1,11 @@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)',+ description: 'Review, fix and clean up a finished code change in one pass, then end-to-end test it (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' },+ { title: 'Review', detail: 'correctness, completeness and refactor reviewers at once, then one verifier that refutes the bug findings' },+ { title: 'Fix', detail: 'one agent: confirmed findings, refactors worth doing and a cleanup pass, one rebuild' },+ { title: 'E2E', detail: 'the changed flows on the real apps, once; a fixed failure is walked again alone' },],}@@ -17,32 +16,24 @@ 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 = {+const FINDING = {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'],- },- },+ 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; for a refactor, what it costs to leave as is' },+ fix: { type: 'string' },},- required: ['findings'],+ required: ['file', 'severity', 'summary', 'failure_scenario', 'fix'],}+const FINDINGS = { type: 'object', properties: { findings: { type: 'array', items: FINDING } }, required: ['findings'] }const VERDICTS = {type: 'object',properties: {- confirmed: { type: 'array', items: FINDINGS.properties.findings.items },+ confirmed: { type: 'array', items: FINDING },refuted: { type: 'array', items: { type: 'object', properties: { summary: { type: 'string' }, why: { type: 'string' } }, required: ['summary', 'why'] } },},required: ['confirmed', 'refuted'],@@ -68,8 +59,8 @@ const CHECKS = {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' },+ result: { type: 'string', enum: ['pass', 'fail', 'preexisting', 'not_run'], description: 'preexisting: broken the same way without this change, so not its failure' },+ detail: { type: 'string', description: 'what was seen; for fail or preexisting the symptom, for not_run why' },},required: ['platform', 'flow', 'result', 'detail'],},@@ -78,18 +69,20 @@ const CHECKS = {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' },+const REVIEWERS = [+ { name: 'correctness', text: 'Lens: correctness: bugs, regressions, broken edge cases, error handling, data loss, security, and compatibility with older clients and hosts (docs/reference/compatibility.md). Report only real defects with a concrete failure scenario; style nits are not findings.' },+ { name: 'completeness', text: 'Lens: 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. Report only real gaps; style nits are not findings.' },+ { name: 'refactor', text: 'Lens: refactor (docs/guides/clean-code.md "After every change"): responsibility splits, files past ~500 lines, long functions, layer leaks, missed reuse, language best practices (Swift 6, Rust rust-skills, strict TypeScript, Compose). Only suggestions worth their diff.' },]phase('Review')-const reviews = await parallel(LENSES.map((lens) => () =>- agent(`Review a code change, read-only (edit nothing). Lens: ${lens.text}.+const reviews = await parallel(REVIEWERS.map((r) => () =>+ agent(`Review a code change, read-only (edit nothing). ${r.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)+Most important first. Return an empty list when there is nothing.`,+ { label: `review:${r.name}`, phase: 'Review', schema: FINDINGS })))+const [bugs, gaps, refactors] = reviews.map((r) => r?.findings ?? [])+const found = [...bugs, ...gaps]let confirmed = []let refuted = []if (found.length) {@@ -100,49 +93,44 @@ ${JSON.stringify(found, null, 2)}`, { label: 'verify', phase: 'Review', schema:confirmed = verdict?.confirmed ?? foundrefuted = 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 })+log(`Review: ${found.length} found, ${confirmed.length} confirmed, ${refactors.length} refactors suggested`)phase('Fix')-const reviewFix = confirmed.length ? await fix('review findings', confirmed) : null+// One editor for findings, refactors and cleanup: one pass over the files and one rebuild, not three.+const fixed = await agent(`Edit the change in one pass, then rerun once the builds and tests of the parts you touched (CLAUDE.md lists each part's checks).+${scope}+1. Fix each confirmed finding: the smallest correct fix at its root cause.+${JSON.stringify(confirmed, null, 2)}+2. Apply the refactor suggestions worth their diff; skip the rest with one line why each.+${JSON.stringify(refactors, null, 2)}+3. Clean up the change's own lines (docs/guides/clean-code.md "After every change"): dead code, duplication, unclear names, comments that restate the code or no longer match it, unused imports, places an existing helper should be reused. Keep behavior identical and match the surrounding code.`,+ { label: 'fix', phase: 'Fix', schema: FIXED })-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).+const walk = (flows, 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 when done leave this worktree's \`npm run dev\` running (it is stopped after the merge) but stop anything else you started. 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.' : ''}`,+${flows}+Walk each flow once, as a person would, until it clearly passes or fails, and note what you saw; don't explore beyond the listed flows. Keep it quick: short messages to bots, no sleeps or long-running tasks to stretch a turn, and when \`host/\` is unchanged start \`npm run dev\` with \`CODYNC_HOST_BIN\` pointing at an already built host instead of building one (docs/guides/dev-app.md). A failure the change didn't cause (the same without it) is \`preexisting\`, not \`fail\`. 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 when done leave this worktree's \`npm run dev\` running (it is stopped after the merge) but stop anything else you started. A change with nothing to walk (CI, tools, docs) reports one not_run check saying so.`,{ label: `e2e:${round}`, phase: 'E2E', schema: CHECKS })phase('E2E')-let walked = await walk(1)+const first = await walk('Walk the flows the change touches.', 1)+let checks = first?.checks ?? []+const failures = checks.filter((c) => c.result === 'fail')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.+ e2eFix = await agent(`Fix these e2e failures in the change, the smallest correct fix at the root cause, then rerun the builds and tests the fix touches.${scope}-${JSON.stringify(refactors, null, 2)}`, { label: 'apply-refactors', phase: 'Cleanup', schema: FIXED })- : null+${JSON.stringify(failures, null, 2)}`, { label: 'fix:e2e', phase: 'E2E', schema: FIXED })+ // Walk again only what was fixed: an unchanged change fails the same way.+ if (e2eFix?.applied.length) {+ const again = await walk(`This is the second walk, after fixes for these failures of the first. Walk only these flows:\n${JSON.stringify(failures.map((f) => `${f.platform}: ${f.flow}`), null, 2)}`, 2)+ checks = [...checks.filter((c) => c.result !== 'fail'), ...(again?.checks ?? failures)]+ }+}return {- review: { found: found.length, confirmed, refuted, fix: reviewFix },- e2e: { checks: walked?.checks ?? [], fix: e2eFix },- cleanup,- refactor: { suggested: refactors, applied },+ review: { found: found.length, confirmed, refuted },+ fix: { refactors, ...fixed },+ e2e: { checks, fix: e2eFix },next: 'Unless an e2e check failed or a skipped fix matters: commit in this worktree, rebase on origin/dev, fast-forward dev, push origin dev, pull dev in the main checkout. Only once that merge is pushed (never before, and not at all if the merge or push fails): stop this worktree\'s `npm run dev` (its Vite, Electron app and sandbox host) and check none of it remains, then leave the worktree and, from the main checkout, delete it: `git worktree remove --force <worktree>`, `git branch -D <branch>`, then `npm run dev -- --prune` in apps/desktop.',}diff --git a/AGENTS.md b/AGENTS.mdindex 124ed8a2..f3b848bd 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -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 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).+- After every code change (tests green, before commit): review → fix, refactor and cleanup → end-to-end test (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 2b77c9a1..12c19429 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 commit): review → fix → end-to-end test → cleanup and refactor, by running the `after-change` workflow from the change's worktree; then merge into `dev`, and only after the merge is pushed stop its `npm run dev` and delete the worktree: [after every change](docs/guides/clean-code.md#after-every-change-review-e2e-cleanup).+- After every code change (tests green, before commit): review → fix, refactor and cleanup → end-to-end test, by running the `after-change` workflow from the change's worktree; then merge into `dev`, and only after the merge is pushed stop its `npm run dev` and delete the worktree: [after every change](docs/guides/clean-code.md#after-every-change-review-e2e-cleanup).## Architecturediff --git a/docs/guides/clean-code.md b/docs/guides/clean-code.mdindex b60b37a3..51061f6e 100644--- a/docs/guides/clean-code.md+++ b/docs/guides/clean-code.md@@ -41,11 +41,11 @@ Rules every change follows, in every part of the repository (host, iOS, desktop,Once a code change works (its tests pass) and before commit, it goes through three stages, in this order:-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.+1. **Review**: three read-only reviewers at once: correctness (bugs, regressions, error handling, security, compatibility with older clients and hosts), completeness (every client the change should reach, stale docs, missing tests, version and What's New rules) and refactor (responsibility splits, files past ~500 lines, long functions, layer leaks, missed reuse, language best practices: Swift 6, Rust `rust-skills`, strict TypeScript, Compose). A verifier then tries to refute each correctness and completeness finding against the code.+2. **Fix and cleanup**, one editor in one pass: the surviving findings at their root cause, the refactors worth their diff, and a cleanup of the change's own lines (dead code, duplication, unclear names, comments that restate the code, unused imports, places an existing helper should be reused); then the affected builds and tests run once.+3. **End-to-end test** of the final code: the changed flows on the real apps, minimal or full as CLAUDE.md defines it, each walked once with short bot turns. A failure the change didn't cause is reported as preexisting. A real failure is fixed, and only the fixed flows are walked again.-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. The worktree's `npm run dev` keeps running through it.+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, what the fix pass changed or skipped (refactors included), and the e2e checks. The worktree's `npm run dev` keeps running through it.Once it's green, the change is committed, merged into `dev` and pushed. Only after that merge is pushed are the worktree's `npm run dev` (its Electron app and sandbox host) stopped and the worktree deleted (a failed merge or push keeps both): stop it, leave the worktree, then from the main checkout `git worktree remove --force <path>`, `git branch -D <branch>` and `npm run dev -- --prune` in `apps/desktop` (deletes its sandbox). Nothing started from the worktree keeps running.