Appearance
Same-Branch Editing
This example walks through two agents editing the same function in src/currency.ts on main.
Same-Branch AST Merging on main
Prompt on main
Agent 1: "Add locale"
Agent 2: "Add decimals"
1 File (currency.ts)
Concurrent Edits
Both save on main
✓ No File Locks
Tree-sitter AST
✓ Structural AST
Unified on Disk
Both Kept
✓ Zero Overwrites
Starting File
Suppose src/currency.ts on main contains:
ts
export function formatCurrency(cents: number, currency: string = "USD"): string {
const amount = (cents / 100).toFixed(2);
return `${currency} ${amount}`;
}Prompting Two Agents
Open two AI agent tabs and give both a prompt that modifies formatCurrency:
- Tab 1: "Add a
locale: string = 'en-US'parameter toformatCurrencyinsrc/currency.ts." - Tab 2: "Add a
decimals: number = 2parameter toformatCurrencyinsrc/currency.ts."
How It Works
- Both agents claim
src/currency.tsagainst the same starting commit onmain. - Agent 1 writes its edit and runs
tes hook post-tool --path src/currency.ts. - Agent 2 writes its edit and runs
tes hook post-tool --path src/currency.ts. - Tessera parses the base version and both agents' versions using Tree-sitter and merges the parameter list and function body automatically.
Merged Result
ts
export function formatCurrency(
cents: number,
currency: string = "USD",
locale: string = "en-US",
decimals: number = 2
): string {
const amount = (cents / 100).toFixed(decimals);
return `[${locale}] ${currency} ${amount}`;
}Committing
Check the status and commit:
bash
tes status
tes diff
tes commit -m "feat(currency): support locale and decimals parameters"Next Steps
- Feature Branches - Isolate two features on separate branches
- Conflict Resolution - Handle overlapping edits to the same expression