From 836cc6fedf840c0dd4c057f084552ca6acb2c3b4 Mon Sep 17 00:00:00 2001 From: Ammar Date: Sat, 15 Nov 2025 19:52:27 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A4=96=20docs:=20condense=20agent=20i?= =?UTF-8?q?nstructions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/AGENTS.md | 611 ++++++++----------------------------------------- 1 file changed, 94 insertions(+), 517 deletions(-) diff --git a/docs/AGENTS.md b/docs/AGENTS.md index 8d74d8ace..13418381f 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -1,578 +1,155 @@ # AGENT INSTRUCTIONS -**Edits to this file must be minimal and token-efficient.** Think carefully about how to represent information concisely. Avoid redundant examples or verbose explanations when the knowledge can be conveyed in a sentence or two. +**Prime directive:** keep edits minimal and token-efficient—say only what conveys actionable signal. -## Project Context +## Project Snapshot -- Project is named `mux` -- Electron + React desktop application for parallel agentic development -- UX should be fast, responsive, and intuitive +- `mux`: Electron + React desktop app for parallel agent workflows; UX must be fast, responsive, predictable. +- Minor breaking changes are expected, but critical flows must allow upgrade↔downgrade without friction; skip migrations when breakage is tightly scoped. +- Public work (issues/PRs/commits) must use 🤖 in the title and include "_Generated with `mux`_" in the body when applicable. -## Breaking Changes +## PR + Release Workflow -The project is in early development phase. Breaking changes of minor features are expected. Strive -for backwards and forwards compatibility whenever possible on critical features. Users should be -able to upgrade, downgrade, upgrade between any two versions of mux. -Do not worry about migrations for breakage confined to the scope of the PR. - -## AI-Generated Content Attribution - -When creating public operations (commits, PRs, issues), always include: - -- 🤖 emoji in the title -- "_Generated with `mux`_" in the body (if applicable) - -This ensures transparency about AI-generated contributions. - -## PR Management - -**Prefer to reuse existing PRs** by force-pushing to the same branch, even if the branch name becomes irrelevant. Avoid closing and recreating PRs unnecessarily - PR spam clutters the repository history. **Never close PRs without explicit user instruction.** Always force-push to the existing branch instead of creating new PRs. - -After submitting or updating PRs, **always check merge status**: +- Reuse existing PRs; never close or recreate without instruction. Force-push updates. +- After every push run: ```bash gh pr view --json mergeable,mergeStateStatus | jq '.' -``` - -This is especially important with rapid development where branches quickly fall behind. - -**Wait for PR checks to complete:** - -```bash ./scripts/wait_pr_checks.sh ``` -This script polls every 5 seconds and fails immediately on CI failure, bad merge status, or unresolved review comments. - -**Key status values:** - -- `mergeable: "MERGEABLE"` = No conflicts, can merge -- `mergeable: "CONFLICTING"` = Has conflicts, needs resolution -- `mergeStateStatus: "CLEAN"` = Ready to merge ✅ -- `mergeStateStatus: "BLOCKED"` = Waiting for CI checks -- `mergeStateStatus: "BEHIND"` = Branch is behind base, rebase needed -- `mergeStateStatus: "DIRTY"` = Has conflicts - -**If branch is behind:** - -```bash -git fetch origin -git rebase origin/main -git push --force-with-lease -``` - -### ⚠️ NEVER Auto-Merge PRs - -**DO NOT** enable auto-merge (`gh pr merge --auto`) or merge PRs (`gh pr merge`) without **explicit user instruction**. - -Reason: PRs may need human review, discussion, or additional changes based on review comments (e.g., Codex feedback). Always: - -1. Submit the PR -2. Wait for checks to pass -3. Report PR status to user -4. **Wait for user to decide** whether to merge - -Only merge if the user explicitly says "merge it" or similar. - -### Writing PR Descriptions - -Write PR bodies for **busy reviewers**. Be concise and avoid redundancy: - -- **Each section should add new information** - Don't restate the same thing in different words -- **Structure emerges from content** - Some fixes need problem/solution/testing, others just need "what changed and why" -- **If it's obvious, omit it** - Problem obvious from solution? Don't state it. Solution obvious from problem? Skip to implementation details. -- **Avoid over-explaining** - Comprehensive testing checklists, multiple code examples, and detailed edge case lists make PRs harder to review. State the change and why it matters. - -❌ **Bad** (redundant): - -``` -Problem: Markdown rendering is slow, causing 50ms tasks -Solution: Make markdown rendering faster -Impact: Reduces task time to <16ms -``` - -✅ **Good** (each section adds value): - -``` -ReactMarkdown was re-parsing content on every parent render because plugin arrays -were created fresh each time. Moved to module scope for stable references. - -Verify with React DevTools Profiler - MarkdownCore should only re-render when content changes. -``` - -### PR Title Structure - -Use these prefixes based on what best describes the PR: - -- **perf:** (improvement to performance, no functionality changes) -- **refactor:** (improvement to codebase, no behavior changes) -- **fix:** (conforming behavior to user expectations) -- **feat:** (net new functionality) -- **ci:** (concerned with build process or CI) -- **bench:** (benchmarking infrastructure or Terminal-Bench integration) - -Examples: - -- `🤖 perf: cache markdown plugin arrays to avoid re-parsing` -- `🤖 refactor: extract IPC handlers to separate module` -- `🤖 fix: handle workspace rename edge cases` -- `🤖 feat: add keyboard shortcuts for workspace navigation` -- `🤖 ci: update wait_pr_checks script timeout` -- `🤖 bench: simplify timeout handling in terminal-bench integration` +- Status decoding: `mergeable=MERGEABLE` clean; `CONFLICTING` needs resolution. `mergeStateStatus=CLEAN` ready, `BLOCKED` waiting for CI, `BEHIND` rebase, `DIRTY` conflicts. +- If behind: `git fetch origin && git rebase origin/main && git push --force-with-lease`. +- Never enable auto-merge or merge at all unless the user explicitly says "merge it". +- PR descriptions: include only information a busy reviewer cannot infer; focus on implementation nuances or validation steps. +- Title prefixes: `perf|refactor|fix|feat|ci|bench`, e.g., `🤖 fix: handle workspace rename edge cases`. -## Project Structure +## Repo Reference -- `src/main.ts` - Main Electron process -- `src/preload.ts` - Preload script for IPC -- `src/App.tsx` - Main React component -- `src/config.ts` - Configuration management -- `~/.mux/config.json` - User configuration file -- `~/.mux/src//` - Local workspace directories (git worktrees) -- `~/.mux/sessions//chat.jsonl` - Session chat histories +- Core files: `src/main.ts`, `src/preload.ts`, `src/App.tsx`, `src/config.ts`. +- Persistent data: `~/.mux/config.json`, `~/.mux/src//` (worktrees), `~/.mux/sessions//chat.jsonl`. -## Documentation Guidelines +## Documentation Rules -**Free-floating markdown docs are not permitted.** Documentation must be organized. Do not create standalone markdown files in the project root or random locations, even for implementation summaries or planning documents - use the propose_plan tool or inline comments instead. +- No free-floating Markdown. User docs live in `docs/` (read `docs/README.md`, update `docs/SUMMARY.md`, use standard Markdown + mermaid). Developer/test notes belong inline as comments. +- For planning artifacts, use the `propose_plan` tool or inline comments instead of ad-hoc docs. +- Do not add new root-level docs without explicit request; during feature work rely on code + tests + inline comments. +- Test documentation stays inside the relevant test file as commentary explaining setup/edge cases. +- External API docs already live inside `/tmp/ai-sdk-docs/**.mdx`; never browse `https://sdk.vercel.ai/docs/ai-sdk-core` directly. -- **User-facing docs** → `./docs/` directory - - **IMPORTANT**: Read `docs/README.md` first before writing user-facing documentation - - User docs are built with mdbook and deployed to https://mux.io - - Must be added to `docs/SUMMARY.md` to appear in the docs - - Use standard markdown + mermaid diagrams -- **Developer docs** → inline with the code its documenting as comments. Consider them notes as notes to future Assistants to understand the logic more quickly. - **DO NOT** create standalone documentation files in the project root or random locations. -- **Test documentation** → inline comments in test files explaining complex test setup or edge cases, NOT separate README files. +## Key Features & Performance -**NEVER create markdown documentation files (README, guides, summaries, etc.) in the project root during feature development unless the user explicitly requests documentation.** Code + tests + inline comments are complete documentation. +- Core UX: projects sidebar (left panel), workspace management (local git worktrees or SSH clones), config stored in `~/.mux/config.json`. +- Fetch bulk data in one IPC call—no O(n) frontend→backend loops. -### External API Docs +## Tooling & Commands -DO NOT visit https://sdk.vercel.ai/docs/ai-sdk-core. All of that content is already -in `/tmp/ai-sdk-docs/**.mdx`. +- Package manager: bun only. Use `bun install`, `bun add`, `bun run` (which proxies to Make when relevant). Run `bun install` if modules/types go missing. +- Makefile is source of truth (new commands land there, not `package.json`). +- Primary targets: `make dev|start|build|lint|lint-fix|fmt|fmt-check|typecheck|test|test-integration|clean|help`. -(Generate them with `./scripts/update_vercel_docs.sh` if they don't exist.) +## Refactoring & Runtime Etiquette -### Documentation Guidelines +- Use `git mv` to retain history when moving files. +- Never kill the running mux process; rely on `make test` / `make typecheck` for validation. -**Developer documentation should live inline with relevant code as comments.** The `docs/` directory contains user-facing documentation. - -## Key Features - -- Projects sidebar (left panel) -- Workspaces (local uses git worktrees, SSH uses remote git clones) -- Configuration persisted to `~/.mux/config.json` - -## Performance Patterns - -**Avoid O(n) IPC calls from Frontend->Backend.** When displaying lists of items, fetch them in a single IPC call and process in the frontend. Never loop over items in the frontend making separate IPC calls for each. - -## Package Manager - -- **Using bun** - All dependencies are managed with bun (not npm) -- Use bun over npm whenever possible, including to: - - Install dependencies: `bun install` - - Add packages: `bun add ` - - Run scripts: `bun run