Skip to content

feat(agent-farm): Add send command for architect-to-builder messaging - #31

Merged
waleedkadous merged 2 commits into
mainfrom
builder/0020-send-instructions-to-builder
Dec 4, 2025
Merged

waleedkadous merged 2 commits into
mainfrom
builder/0020-send-instructions-to-builder

Conversation

@waleedkadous

Copy link
Copy Markdown
Contributor

Summary

  • Implements spec 0020 - Send Instructions to Builder feature
  • New af send CLI command to send messages to running builders via tmux buffer paste
  • Supports broadcast (--all), file attachments (--file), interrupt (--interrupt), and raw mode (--raw)

Implementation Details

  • Uses tmux load-buffer + paste-buffer approach for reliable delivery (avoids shell escaping issues)
  • Structured message format (### [ARCHITECT INSTRUCTION | timestamp] ###) helps Claude identify architect instructions
  • Proper error handling for non-existent builders, dead sessions, missing files

Test Plan

  • af send 9999 "Test" - Shows clear error for non-existent builder
  • af send --all "Message" - Handles no active builders gracefully
  • af send - Shows usage error
  • af send 0009 - Shows missing message error
  • Help text displays correctly (af send --help)
  • Manual test with actual builder (requires running builder)

Files Changed

File Change
agent-farm/src/commands/send.ts New - Core send implementation
agent-farm/src/commands/index.ts Export send command
agent-farm/src/index.ts Register CLI command
agent-farm/src/types.ts Add SendOptions interface
codev/plans/0020-send-instructions-to-builder.md Implementation plan

Implements spec 0020 - Send Instructions to Builder feature:
- New 'af send' CLI command to send messages to running builders
- Uses tmux buffer paste for reliable delivery (avoids shell escaping)
- Supports --all flag for broadcast to all builders
- Supports --file flag to include file content
- Supports --interrupt flag to send Ctrl+C first
- Supports --raw flag to skip structured formatting
- Structured message format helps Claude identify architect instructions
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Architect Review with Expert Consultation

Reviewed with Gemini Pro and GPT-5 Codex. Overall implementation is solid - the buffer-based approach is the correct way to handle this.

✅ What's Good

  • Buffer approach correctly implemented (temp file → load-buffer → paste-buffer)
  • Unique buffer names per builder avoid race conditions
  • Structured message format with timestamp helps Claude identify instructions
  • Error handling covers key cases (builder not found, dead session, file too large)
  • CLI argument handling correctly shifts args for --all mode

🟡 Suggested Improvements (Minor)

1. Variable naming (Line 78)

stats is misleading - readFileSync returns a Buffer, not fs.Stats:

// Change from:
const stats = readFileSync(options.file);
// To:
const fileBuffer = readFileSync(options.file);

2. Quote buffer name in tmux commands (Lines 97-98)

Defensive fix in case builder IDs ever contain special characters:

await run(`tmux load-buffer -b "${bufferName}" "${tempFile}"`);
await run(`tmux paste-buffer -b "${bufferName}" -t "${builder.tmuxSession}"`);

3. Optional: Delete buffer after paste

Reduces leakage of potentially sensitive instructions:

await run(`tmux delete-buffer -b "${bufferName}"`);

🟢 Notes (No Action Required)

  • Interrupt delay (100ms): Acceptable for now, increase to 250-500ms if flaky
  • Stdin blocking: readStdin blocks if no input piped - acceptable behavior
  • Pane targeting: Current approach targets active pane; fine if builders are single-pane

Verdict

Ready to merge after addressing items 1 and 2 (minor fixes). Item 3 is optional but recommended.

- Rename misleading 'stats' variable to 'fileBuffer'
- Quote bufferName in tmux commands for safety
- Add tmux delete-buffer cleanup after paste
@waleedkadous
waleedkadous merged commit b57573b into main Dec 4, 2025
@waleedkadous
waleedkadous deleted the builder/0020-send-instructions-to-builder branch January 8, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant