Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ tests/visual_report.html
# Local scratch (screenshots, etc.)
tmp/
tmp-*/
.claude/scheduled_tasks.lock
207 changes: 207 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,210 @@ Notes:
- README download button points to `releases/latest/download/cmux-macos.dmg`.
- Versioning: bump the minor version for updates unless explicitly asked otherwise.
- Changelog: update `CHANGELOG.md`; docs changelog is rendered from it.

<!-- BEGIN BEADS INTEGRATION -->
## Issue Tracking with bd (beads)

**IMPORTANT**: This project uses **bd (beads)** for ALL issue tracking. Do NOT use markdown TODOs, task lists, or other tracking methods.

### Why bd?

- Dependency-aware: Track blockers and relationships between issues
- Git-friendly: Auto-syncs to JSONL for version control
- Agent-optimized: JSON output, ready work detection, discovered-from links
- Prevents duplicate tracking systems and confusion

### Quick Start

**Check for ready work:**

```bash
bd ready --json
```

**Create new issues:**

```bash
bd create "Issue title" --description="Detailed context" -t bug|feature|task -p 0-4 --json
bd create "Issue title" --description="What this issue is about" -p 1 --deps discovered-from:bd-123 --json
```

**Claim and update:**

```bash
bd update bd-42 --status in_progress --json
bd update bd-42 --priority 1 --json
```

**Complete work:**

```bash
bd close bd-42 --reason "Completed" --json
```

### Issue Types

- `bug` - Something broken
- `feature` - New functionality
- `task` - Work item (tests, docs, refactoring)
- `epic` - Large feature with subtasks
- `chore` - Maintenance (dependencies, tooling)

### Priorities

- `0` - Critical (security, data loss, broken builds)
- `1` - High (major features, important bugs)
- `2` - Medium (default, nice-to-have)
- `3` - Low (polish, optimization)
- `4` - Backlog (future ideas)

### Workflow for AI Agents

1. **Check ready work**: `bd ready` shows unblocked issues
2. **Claim your task**: `bd update <id> --status in_progress`
3. **Work on it**: Implement, test, document
4. **Discover new work?** Create linked issue:
- `bd create "Found bug" --description="Details about what was found" -p 1 --deps discovered-from:<parent-id>`
5. **Complete**: `bd close <id> --reason "Done"`

### Auto-Sync

bd automatically syncs with git:

- Exports to `.beads/issues.jsonl` after changes (5s debounce)
- Imports from JSONL when newer (e.g., after `git pull`)
Comment on lines +287 to +288

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLAUDE.md states bd auto-syncs to .beads/issues.jsonl, but there is no .beads/ directory in the repo currently. If bd is being introduced, consider adding the directory (and documenting it) or adjusting this section to reflect the current on-disk location/config.

Suggested change
- Exports to `.beads/issues.jsonl` after changes (5s debounce)
- Imports from JSONL when newer (e.g., after `git pull`)
- Exports issues to a JSONL file in the bd data directory (see `bd config show`) after changes (5s debounce)
- (Optional convention) You can configure bd to use `.beads/issues.jsonl`; if you do, ensure the `.beads/` directory exists in your repo
- Imports from that JSONL file when newer (e.g., after `git pull`)

Copilot uses AI. Check for mistakes.
- No manual export/import needed!

### Important Rules

- ✅ Use bd for ALL task tracking
- ✅ Always use `--json` flag for programmatic use
- ✅ Link discovered work with `discovered-from` dependencies
- ✅ Check `bd ready` before asking "what should I work on?"
- ❌ Do NOT create markdown TODO lists
- ❌ Do NOT use external issue trackers
- ❌ Do NOT duplicate tracking systems

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says “Do NOT use markdown TODOs / task lists” for issue tracking, but the repo currently contains TODO.md and .todo.md-style docs (e.g. docs/socket-focus-steal-audit.todo.md). Please clarify whether these are legacy/allowed, or plan to migrate/remove them, so contributors aren’t left with conflicting guidance.

Suggested change
Note: Existing `TODO.md` / `*.todo.md` docs in this repo are legacy and are being migrated into bd issues or removed. Do not create new markdown TODO files or extend the existing ones; use bd instead.

Copilot uses AI. Check for mistakes.
For more details, see README.md and docs/QUICKSTART.md.

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This references docs/QUICKSTART.md and suggests “see README.md” for beads details, but neither appears to exist / mention beads in the repo right now. Either add the referenced docs (and a README section) or update these pointers to the actual location of bd/beads documentation.

Suggested change
For more details, see README.md and docs/QUICKSTART.md.
For more details on bd usage, run `bd --help` and consult your project’s documentation.

Copilot uses AI. Check for mistakes.

<!-- END BEADS INTEGRATION -->

## Landing the Plane (Session Completion)

**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.

**MANDATORY WORKFLOW:**

1. **File issues for remaining work** - Create issues for anything that needs follow-up
2. **Run quality gates** (if code changed) - Tests, linters, builds
3. **Update issue status** - Close finished work, update in-progress items
4. **PUSH TO REMOTE** - This is MANDATORY:
```bash
git pull --rebase
bd sync
git push
git status # MUST show "up to date with origin"
```
5. **Clean up** - Clear stashes, prune remote branches
6. **Verify** - All changes committed AND pushed
7. **Hand off** - Provide context for next session

**CRITICAL RULES:**
- Work is NOT complete until `git push` succeeds
- NEVER stop before pushing - that leaves work stranded locally
- NEVER say "ready to push when you are" - YOU must push
- If push fails, resolve and retry until it succeeds

## Socket control — reading and steering terminal panes

The cmux socket lets agents read terminal output and send input to any pane without touching the keyboard.

### Find the socket

```bash
ls /tmp/cmux*.sock
# Debug build (untagged): /tmp/cmux-debug.sock
# Tagged debug build: /tmp/cmux-debug-<tag>.sock
# Release: /tmp/cmux.sock
```

### Key commands

```bash
SOCK="/tmp/cmux-debug.sock" # adjust to your build

# Discover layout
printf "list_workspaces\n" | nc -U $SOCK
printf "list_surfaces <ws-uuid>\n" | nc -U $SOCK

# Read a pane's screen (current workspace only, by index or surface UUID)
printf "read_screen 0 --lines 30\n" | nc -U $SOCK
printf "read_screen 0 --lines 60 --scrollback\n" | nc -U $SOCK

# Send text / keys to a specific surface (no workspace switch needed)
printf "send_surface <surface-uuid> <text>\n" | nc -U $SOCK
printf "send_key_surface <surface-uuid> ctrl-c\n" | nc -U $SOCK

# Send to whatever pane is currently focused
printf "send some text here\n" | nc -U $SOCK
printf "send_key ctrl-c\n" | nc -U $SOCK
```

### Agent monitoring rules

- **Never use `select_workspace`** to spy on other agents — it visibly switches the user's active tab.
- `read_screen` by UUID only works for surfaces in the **current** workspace. To monitor a pane in another workspace without switching, coordinate via **MCP mail** (`cmux` / `cmuxcoder` agents) instead.
- Use `list_surfaces <ws-uuid>` to get surface UUIDs, then `send_surface <uuid>` to steer without changing focus.
- The coding agent's tab is named **`cmux_coder`** — it is a surface tab inside the `cmux:ubuntu` workspace, not a separate workspace.

### Finding a tab — always use workspace NAME

**Never rely on workspace index or surface index.** The user can switch workspaces at any time,
shifting indices. Always look up by workspace name:

```bash
# 1. Find workspace by name
printf "list_workspaces\n" | nc -U $SOCK
# Output example:
# 0: D267DC10-... cmux: ubuntu
# * 1: 9075D919-... exp: statusline ← user may be here, irrelevant
# 2: 258EB4B4-... o: mctrl

# 2. Get surfaces in the named workspace
WS_UUID=$(printf "list_workspaces\n" | nc -U $SOCK | grep "cmux: ubuntu" | grep -oE '[A-F0-9-]{36}')
printf "list_surfaces $WS_UUID\n" | nc -U $SOCK
# Output:
# * 0: 87DB76A9-... supervisor
# 1: F05FCE84-... cmux_coder

# 3. Send by UUID — works regardless of which workspace user has focused
printf "send_surface F05FCE84-ECA7-4944-BCAA-7DFFC105D0D9 your message\n" | nc -U $SOCK
```

`read_screen` and `send_surface` behave differently across workspaces:

| Command | Cross-workspace by UUID? |
|---|---|
| `read_screen <uuid>` | ❌ fails — only works in current workspace |
| `send_surface <uuid> <text>` | ✅ works — delivers even if not current workspace |

Comment on lines +399 to +403

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This markdown table uses || (double leading pipe), which renders an unintended empty first column on GitHub. If that’s not intended, switch to a single leading | for proper table formatting.

Copilot uses AI. Check for mistakes.
### Typing into another agent's pane (human simulation)

`send_surface` types text into the input box but does **not** submit. Use `send_key_surface enter` to submit.

```bash
UUID="F05FCE84-ECA7-4944-BCAA-7DFFC105D0D9" # cmux_coder

# Pattern: clear → type → enter
printf "send_key_surface $UUID ctrl-a\n" | nc -U $SOCK
printf "send_key_surface $UUID ctrl-k\n" | nc -U $SOCK
printf "send_surface $UUID your message here\n" | nc -U $SOCK
sleep 0.2
printf "send_key_surface $UUID enter\n" | nc -U $SOCK
```

If `send_surface` returns `ERROR: Failed to send input` — the terminal is busy running a command. Wait and retry.

**Surface layout in `cmux: ubuntu` workspace (UUID: D267DC10-B8C2-437C-B481-2AFD3167BA69):**
- Surface `0` (UUID: `87DB76A9-60A8-43FC-BFC2-51A5DECEA9B8`) = supervisor (cmux)
- Surface `1` (UUID: `F05FCE84-ECA7-4944-BCAA-7DFFC105D0D9`) = coder (cmux_coder)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded session-specific UUIDs in agent instructions

Medium Severity

The "Surface layout" section hardcodes ephemeral session-specific UUIDs (e.g., D267DC10-..., 87DB76A9-..., F05FCE84-...) as definitive facts in a version-controlled agent instructions file. These UUIDs are dynamically generated per session and will be stale/wrong after any restart, causing agents following these instructions to reference surfaces that no longer exist.

Additional Locations (1)

Fix in Cursor Fix in Web

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
members = ["cmux-core", "cmux-gtk"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if cmux-gtk directory and Cargo.toml exist
echo "Checking for cmux-gtk crate..."
if [ -d "cmux-gtk" ] && [ -f "cmux-gtk/Cargo.toml" ]; then
    echo "cmux-gtk exists:"
    cat cmux-gtk/Cargo.toml
else
    echo "cmux-gtk directory or Cargo.toml not found"
    fd -t d "cmux-gtk" .
fi

Repository: jleechanorg/cmux

Length of output: 133


🏁 Script executed:

echo "=== Root directory structure ==="
ls -la | head -20

echo -e "\n=== Full Cargo.toml ==="
cat -n Cargo.toml

echo -e "\n=== Checking for cmux-core ==="
if [ -d "cmux-core" ] && [ -f "cmux-core/Cargo.toml" ]; then
    echo "cmux-core EXISTS"
else
    echo "cmux-core NOT FOUND"
fi

Repository: jleechanorg/cmux

Length of output: 1651


🏁 Script executed:

echo "=== .gitmodules content ==="
cat .gitmodules

echo -e "\n=== Git submodule status ==="
git config --file=.gitmodules --name-only --get-regexp path

echo -e "\n=== All directories in repo ==="
find . -maxdepth 1 -type d | sort

echo -e "\n=== Attempting cargo check to see actual error ==="
cargo metadata --format-version=1 2>&1 | grep -A 5 "cmux-gtk" || echo "No cmux-gtk error in metadata"

Repository: jleechanorg/cmux

Length of output: 886


Workspace member cmux-gtk does not exist.

The Cargo.toml declares cmux-gtk as a workspace member on line 2, but the directory is not present in the repository. This will cause cargo build to fail with a manifest-not-found error. Either remove cmux-gtk from the members list or create the crate directory with a valid Cargo.toml.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Cargo.toml` at line 2, The workspace declaration in Cargo.toml lists a
non-existent member "cmux-gtk", which breaks cargo; either remove "cmux-gtk"
from the members array in Cargo.toml or create a new crate directory named
cmux-gtk with its own Cargo.toml (including package name = "cmux-gtk") so the
workspace can find it; update the members = ["cmux-core", "cmux-gtk"] entry
accordingly and run cargo metadata/build to verify the manifest is resolvable.

resolver = "2"

[workspace.package]
version = "0.1.0"
edition = "2021"
authors = ["cmux team"]
license = "MIT"
repository = "https://github.com/manaflow-ai/cmux"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Repository URL may be inconsistent with actual repo.

The repository field points to manaflow-ai/cmux, but this PR appears to be opened against jleechanorg/cmux. Ensure the URL reflects the canonical repository location to avoid confusion for users and tooling (e.g., cargo-deny, documentation generators).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Cargo.toml` at line 10, The Cargo.toml repository field is pointing to
"manaflow-ai/cmux" but this PR targets "jleechanorg/cmux"; update the repository
= "... " value in Cargo.toml to the canonical repository URL for this project
(replace the current "manaflow-ai/cmux" string with the correct
"jleechanorg/cmux" URL) so tooling and docs reference the correct upstream;
ensure the new URL is a valid HTTPS GitHub repo link.

17 changes: 17 additions & 0 deletions cmux-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "cmux-core"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = { version = "1.0", features = ["v4", "serde"] }
chrono = { version = "0.4", features = ["serde"] }
thiserror = "1.0"

[dev-dependencies]
tempfile = "3.8"
Loading