Sync agent state from PC at 2026-05-15 16:32:18
This commit is contained in:
@@ -13,7 +13,6 @@ $HeartbeatFile = Join-Path $PublicStateDir "heartbeat-pc.json"
|
||||
$ErrorFile = Join-Path $PublicStateDir "error-pc.md"
|
||||
$AllowedPaths = @(
|
||||
"AGENT_BOARD.md",
|
||||
"USER_STATUS.md",
|
||||
"README.md",
|
||||
".cursor/rules",
|
||||
"handoff",
|
||||
@@ -67,6 +66,26 @@ function Invoke-Git {
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-StaleSyncError {
|
||||
if (Test-Path $ErrorFile) {
|
||||
Remove-Item $ErrorFile -Force
|
||||
}
|
||||
}
|
||||
|
||||
function Push-WithRetry {
|
||||
& git push
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
return
|
||||
}
|
||||
|
||||
# Another agent may have pushed between our pull and push. Rebase once and retry.
|
||||
Invoke-Git @("pull", "--rebase", "--autostash")
|
||||
if (Test-ConflictMarkers) {
|
||||
throw "merge or rebase conflicts detected after push retry"
|
||||
}
|
||||
Invoke-Git @("push")
|
||||
}
|
||||
|
||||
function Get-AllowedChanges {
|
||||
$changes = & git -C $RepoRoot status --porcelain
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
@@ -148,6 +167,7 @@ function Sync-Once {
|
||||
throw "merge or rebase conflicts detected"
|
||||
}
|
||||
|
||||
Remove-StaleSyncError
|
||||
Write-Heartbeat
|
||||
|
||||
$allowedChanges = @(Get-AllowedChanges)
|
||||
@@ -171,15 +191,12 @@ function Sync-Once {
|
||||
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
Invoke-Git @("commit", "-m", "Sync agent state from PC at $timestamp")
|
||||
Invoke-Git @("push")
|
||||
Push-WithRetry
|
||||
}
|
||||
|
||||
do {
|
||||
try {
|
||||
Sync-Once
|
||||
if (Test-Path $ErrorFile) {
|
||||
Remove-Item $ErrorFile -Force
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-SyncError $_.Exception.Message
|
||||
|
||||
Reference in New Issue
Block a user