Skip to content

Commit 2dc0351

Browse files
author
FlowMemory Bootstrap Agent
committed
Merge remote-tracking branch 'origin/main' into bootstrap/multi-agent-readiness
# Conflicts: # docs/START_HERE.md
2 parents 6a27be8 + 18b32d2 commit 2dc0351

2 files changed

Lines changed: 181 additions & 0 deletions

File tree

docs/START_HERE.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,80 @@ This is the first document to read after `AGENTS.md`.
1818
- Identify whether the task is docs, protocol, service, app, hardware, research, crypto, infra, or security work.
1919
- If the task touches architecture, security assumptions, public schemas, or cross-agent workflow, update docs in the same pull request.
2020

21+
## Multi-Agent Worktree Setup
22+
23+
Use one Git worktree per Codex agent. Each worktree has its own branch and folder under `E:\FlowMemory`, so agents can work without sharing the same checkout.
24+
25+
Start from the main checkout:
26+
27+
```powershell
28+
cd E:\FlowMemory\flowmemory-main
29+
.\infra\scripts\setup-worktrees.ps1
30+
```
31+
32+
The setup script creates these worktrees if they do not already exist:
33+
34+
```text
35+
E:\FlowMemory\flowmemory-contracts agent/contracts
36+
E:\FlowMemory\flowmemory-indexer agent/indexer
37+
E:\FlowMemory\flowmemory-hardware agent/hardware
38+
E:\FlowMemory\flowmemory-dashboard agent/dashboard
39+
E:\FlowMemory\flowmemory-research agent/research
40+
E:\FlowMemory\flowmemory-crypto agent/crypto
41+
E:\FlowMemory\flowmemory-chain agent/chain
42+
E:\FlowMemory\flowmemory-review agent/review
43+
```
44+
45+
Run each Codex agent from its assigned worktree in a separate PowerShell window:
46+
47+
```powershell
48+
cd E:\FlowMemory\flowmemory-contracts
49+
codex
50+
```
51+
52+
```powershell
53+
cd E:\FlowMemory\flowmemory-indexer
54+
codex
55+
```
56+
57+
```powershell
58+
cd E:\FlowMemory\flowmemory-hardware
59+
codex
60+
```
61+
62+
```powershell
63+
cd E:\FlowMemory\flowmemory-dashboard
64+
codex
65+
```
66+
67+
```powershell
68+
cd E:\FlowMemory\flowmemory-research
69+
codex
70+
```
71+
72+
```powershell
73+
cd E:\FlowMemory\flowmemory-crypto
74+
codex
75+
```
76+
77+
```powershell
78+
cd E:\FlowMemory\flowmemory-chain
79+
codex
80+
```
81+
82+
```powershell
83+
cd E:\FlowMemory\flowmemory-review
84+
codex
85+
```
86+
87+
## Multi-Agent Safety Rules
88+
89+
- Keep `E:\FlowMemory\flowmemory-main` as the main checkout and coordination point.
90+
- Run each agent only inside its assigned worktree folder.
91+
- Check `git status --short --branch` before starting and before handing off work.
92+
- Avoid assigning two agents to edit the same files at the same time.
93+
- Use `git worktree list` from `E:\FlowMemory\flowmemory-main` to inspect all local worktrees.
94+
2195
## During Work
2296

2397
- Keep changes small and reviewable.

infra/scripts/setup-worktrees.ps1

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
$ErrorActionPreference = "Stop"
2+
Set-StrictMode -Version Latest
3+
4+
$expectedRepo = "E:\FlowMemory\flowmemory-main"
5+
$flowMemoryRoot = "E:\FlowMemory"
6+
7+
function Resolve-CanonicalPath {
8+
param(
9+
[Parameter(Mandatory = $true)]
10+
[string] $Path
11+
)
12+
13+
return (Resolve-Path -LiteralPath $Path).Path.TrimEnd("\")
14+
}
15+
16+
function Test-GitRef {
17+
param(
18+
[Parameter(Mandatory = $true)]
19+
[string] $Ref
20+
)
21+
22+
& git show-ref --verify --quiet $Ref *> $null
23+
return $LASTEXITCODE -eq 0
24+
}
25+
26+
function Add-AgentWorktree {
27+
param(
28+
[Parameter(Mandatory = $true)]
29+
[string] $Path,
30+
31+
[Parameter(Mandatory = $true)]
32+
[string] $Branch
33+
)
34+
35+
if (Test-Path -LiteralPath $Path) {
36+
Write-Host "Exists, skipping: $Path"
37+
return
38+
}
39+
40+
Write-Host "Creating: $Path ($Branch)"
41+
42+
if (Test-GitRef "refs/heads/$Branch") {
43+
& git worktree add $Path $Branch
44+
}
45+
elseif (Test-GitRef "refs/remotes/origin/$Branch") {
46+
& git worktree add -b $Branch $Path "origin/$Branch"
47+
}
48+
else {
49+
& git worktree add -b $Branch $Path HEAD
50+
}
51+
52+
if ($LASTEXITCODE -ne 0) {
53+
throw "Failed to create worktree $Path for branch $Branch."
54+
}
55+
}
56+
57+
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
58+
throw "git was not found on PATH. Install Git or add it to PATH, then rerun this script."
59+
}
60+
61+
$currentPath = Resolve-CanonicalPath (Get-Location).Path
62+
$expectedPath = Resolve-CanonicalPath $expectedRepo
63+
64+
if ($currentPath -ne $expectedPath) {
65+
throw "Run this script from $expectedRepo. Current path: $currentPath"
66+
}
67+
68+
$gitRootRaw = (& git rev-parse --show-toplevel).Trim()
69+
if ($LASTEXITCODE -ne 0) {
70+
throw "Current directory is not inside a Git repository."
71+
}
72+
73+
$gitRoot = Resolve-CanonicalPath $gitRootRaw
74+
if ($gitRoot -ne $expectedPath) {
75+
throw "Expected Git root $expectedRepo, but found $gitRoot."
76+
}
77+
78+
$worktrees = @(
79+
@{ Path = "$flowMemoryRoot\flowmemory-contracts"; Branch = "agent/contracts" },
80+
@{ Path = "$flowMemoryRoot\flowmemory-indexer"; Branch = "agent/indexer" },
81+
@{ Path = "$flowMemoryRoot\flowmemory-hardware"; Branch = "agent/hardware" },
82+
@{ Path = "$flowMemoryRoot\flowmemory-dashboard"; Branch = "agent/dashboard" },
83+
@{ Path = "$flowMemoryRoot\flowmemory-research"; Branch = "agent/research" },
84+
@{ Path = "$flowMemoryRoot\flowmemory-crypto"; Branch = "agent/crypto" },
85+
@{ Path = "$flowMemoryRoot\flowmemory-chain"; Branch = "agent/chain" },
86+
@{ Path = "$flowMemoryRoot\flowmemory-review"; Branch = "agent/review" }
87+
)
88+
89+
foreach ($worktree in $worktrees) {
90+
Add-AgentWorktree -Path $worktree.Path -Branch $worktree.Branch
91+
}
92+
93+
Write-Host ""
94+
Write-Host "Exact cd commands:"
95+
foreach ($worktree in $worktrees) {
96+
Write-Host "cd $($worktree.Path)"
97+
}
98+
99+
Write-Host ""
100+
Write-Host "How to run Codex in each worktree:"
101+
Write-Host "Open a separate PowerShell window for each agent, then run one cd command followed by codex."
102+
Write-Host ""
103+
foreach ($worktree in $worktrees) {
104+
Write-Host "cd $($worktree.Path)"
105+
Write-Host "codex"
106+
Write-Host ""
107+
}

0 commit comments

Comments
 (0)