@brickhouse-tech/sync-agents 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/md/STATE_TEMPLATE.md +9 -1
- package/src/sh/sync-agents.sh +101 -11
package/package.json
CHANGED
package/src/md/STATE_TEMPLATE.md
CHANGED
|
@@ -7,10 +7,18 @@ trigger: always_on
|
|
|
7
7
|
Track project progress, current objectives, and resumption context.
|
|
8
8
|
Update this file regularly so agents can pick up where they left off.
|
|
9
9
|
|
|
10
|
+
## Save location
|
|
11
|
+
|
|
12
|
+
../STATE_${CONTEXT_DESCRIPTION}_YYYYMMDDHHMMSS.md
|
|
13
|
+
|
|
14
|
+
A new file will be created each time during agent executions as a short summary of the current state, progress, blockers, and next steps. This allows for a historical record of the project's evolution and provides context for future agent executions. The timestamp in the filename helps to keep track of when each state was recorded, and the context description provides a quick reference to the specific project or objective being tracked. Lastly there should exist session information / session id so we can resume openclaw tui and or claude-code sessions with the relevant context and state information.
|
|
15
|
+
|
|
16
|
+
Save both if necessary, but the state file is more important for tracking progress and providing context for future executions. The session information can be useful for resuming interactive sessions, but the state file is essential for maintaining a record of the project's evolution and providing context for future agent executions.
|
|
17
|
+
|
|
10
18
|
## Format
|
|
11
19
|
|
|
12
20
|
### YYYYMMDDHHMMSS STATE: <objective>
|
|
13
21
|
|
|
14
22
|
Description of current state, progress, blockers, and next steps.
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
Be sure to indicate whats left and what done via - [ ] checkboxes in state file
|
package/src/sh/sync-agents.sh
CHANGED
|
@@ -187,6 +187,36 @@ create_symlink() {
|
|
|
187
187
|
# Commands
|
|
188
188
|
# --------------------------------------------------------------------------
|
|
189
189
|
|
|
190
|
+
# Migrate legacy .agents/STATE.md to the new per-file state pattern.
|
|
191
|
+
# - Ensures rules/state.md exists (the convention rule).
|
|
192
|
+
# - If legacy STATE.md has inline history entries, extracts them into a
|
|
193
|
+
# timestamped STATE_legacy-history_YYYYMMDDHHMMSS.md file.
|
|
194
|
+
# - Removes the legacy STATE.md.
|
|
195
|
+
migrate_legacy_state() {
|
|
196
|
+
local agents_dir="$1"
|
|
197
|
+
local legacy="$agents_dir/STATE.md"
|
|
198
|
+
|
|
199
|
+
[[ -f "$legacy" ]] || return 0
|
|
200
|
+
|
|
201
|
+
# Check if legacy file has meaningful content (beyond template boilerplate)
|
|
202
|
+
local content_lines
|
|
203
|
+
content_lines="$(grep -cvE '^(---|trigger:|#|$|Track project|Update this|Be sure|Description of|Save both|A new file|STATE HISTORY)' "$legacy" 2>/dev/null | tail -1 || echo 0)"
|
|
204
|
+
content_lines="${content_lines//[^0-9]/}"
|
|
205
|
+
: "${content_lines:=0}"
|
|
206
|
+
|
|
207
|
+
if [[ "$content_lines" -gt 0 ]]; then
|
|
208
|
+
# Extract history into a timestamped state file
|
|
209
|
+
local timestamp
|
|
210
|
+
timestamp="$(date +%Y%m%d%H%M%S)"
|
|
211
|
+
local migrated="$agents_dir/STATE_legacy-history_${timestamp}.md"
|
|
212
|
+
cp "$legacy" "$migrated"
|
|
213
|
+
info "Migrated legacy STATE.md history → $(basename "$migrated")"
|
|
214
|
+
fi
|
|
215
|
+
|
|
216
|
+
rm "$legacy"
|
|
217
|
+
info "Removed legacy $AGENTS_DIR/STATE.md (replaced by rules/state.md pattern)"
|
|
218
|
+
}
|
|
219
|
+
|
|
190
220
|
cmd_init() {
|
|
191
221
|
info "Initializing $AGENTS_DIR/ directory structure..."
|
|
192
222
|
|
|
@@ -194,28 +224,47 @@ cmd_init() {
|
|
|
194
224
|
mkdir -p "$PROJECT_ROOT/$AGENTS_DIR/skills"
|
|
195
225
|
mkdir -p "$PROJECT_ROOT/$AGENTS_DIR/workflows"
|
|
196
226
|
|
|
197
|
-
#
|
|
198
|
-
|
|
227
|
+
# Create rules/state.md (the state convention rule) if it doesn't exist
|
|
228
|
+
local state_rule="$PROJECT_ROOT/$AGENTS_DIR/rules/state.md"
|
|
229
|
+
if [[ ! -f "$state_rule" ]]; then
|
|
199
230
|
if [[ -f "$TEMPLATES_DIR/STATE_TEMPLATE.md" ]]; then
|
|
200
|
-
cp "$TEMPLATES_DIR/STATE_TEMPLATE.md" "$
|
|
201
|
-
info "Created $AGENTS_DIR/
|
|
231
|
+
cp "$TEMPLATES_DIR/STATE_TEMPLATE.md" "$state_rule"
|
|
232
|
+
info "Created $AGENTS_DIR/rules/state.md from template"
|
|
202
233
|
else
|
|
203
234
|
# Inline fallback if template not found
|
|
204
|
-
cat > "$
|
|
235
|
+
cat > "$state_rule" <<'STATE_EOF'
|
|
205
236
|
---
|
|
206
237
|
trigger: always_on
|
|
207
238
|
---
|
|
208
239
|
|
|
209
240
|
# State
|
|
210
241
|
|
|
211
|
-
|
|
242
|
+
Track project progress, current objectives, and resumption context.
|
|
243
|
+
Update this file regularly so agents can pick up where they left off.
|
|
244
|
+
|
|
245
|
+
## Save location
|
|
246
|
+
|
|
247
|
+
../STATE_${CONTEXT_DESCRIPTION}_YYYYMMDDHHMMSS.md
|
|
248
|
+
|
|
249
|
+
A new file will be created each time during agent executions as a short summary of the current state, progress, blockers, and next steps.
|
|
212
250
|
|
|
251
|
+
## Format
|
|
213
252
|
|
|
253
|
+
### YYYYMMDDHHMMSS STATE: <objective>
|
|
254
|
+
|
|
255
|
+
Description of current state, progress, blockers, and next steps.
|
|
256
|
+
|
|
257
|
+
Be sure to indicate whats left and what done via - [ ] checkboxes in state file
|
|
214
258
|
STATE_EOF
|
|
215
|
-
info "Created $AGENTS_DIR/
|
|
259
|
+
info "Created $AGENTS_DIR/rules/state.md"
|
|
216
260
|
fi
|
|
217
261
|
else
|
|
218
|
-
warn "$AGENTS_DIR/
|
|
262
|
+
warn "$AGENTS_DIR/rules/state.md already exists, skipping"
|
|
263
|
+
fi
|
|
264
|
+
|
|
265
|
+
# Migrate legacy STATE.md if it exists (from older sync-agents versions)
|
|
266
|
+
if [[ -f "$PROJECT_ROOT/$AGENTS_DIR/STATE.md" ]]; then
|
|
267
|
+
migrate_legacy_state "$PROJECT_ROOT/$AGENTS_DIR"
|
|
219
268
|
fi
|
|
220
269
|
|
|
221
270
|
# Create default config if it doesn't exist
|
|
@@ -605,14 +654,39 @@ cmd_fix() {
|
|
|
605
654
|
fi
|
|
606
655
|
fi
|
|
607
656
|
|
|
657
|
+
# --- Phase 3: Migrate legacy STATE.md to per-file state pattern ---
|
|
658
|
+
local state_migrated=0
|
|
659
|
+
if [[ -f "$agents_abs/STATE.md" ]]; then
|
|
660
|
+
# Ensure the state rule exists first
|
|
661
|
+
if [[ ! -f "$agents_abs/rules/state.md" ]]; then
|
|
662
|
+
if [[ -f "$TEMPLATES_DIR/STATE_TEMPLATE.md" ]]; then
|
|
663
|
+
if [[ "$DRY_RUN" == "true" ]]; then
|
|
664
|
+
echo " would create: $AGENTS_DIR/rules/state.md from template"
|
|
665
|
+
else
|
|
666
|
+
mkdir -p "$agents_abs/rules"
|
|
667
|
+
cp "$TEMPLATES_DIR/STATE_TEMPLATE.md" "$agents_abs/rules/state.md"
|
|
668
|
+
info "Created $AGENTS_DIR/rules/state.md (state convention rule)"
|
|
669
|
+
fi
|
|
670
|
+
fi
|
|
671
|
+
fi
|
|
672
|
+
|
|
673
|
+
if [[ "$DRY_RUN" == "true" ]]; then
|
|
674
|
+
echo " would migrate: $AGENTS_DIR/STATE.md → per-file state pattern"
|
|
675
|
+
else
|
|
676
|
+
migrate_legacy_state "$agents_abs"
|
|
677
|
+
fi
|
|
678
|
+
state_migrated=1
|
|
679
|
+
fi
|
|
680
|
+
|
|
608
681
|
# Summary
|
|
609
|
-
if [[ "$fixed" -eq 0 ]] && [[ "$skipped" -eq 0 ]] && [[ "$repaired" -eq 0 ]]; then
|
|
682
|
+
if [[ "$fixed" -eq 0 ]] && [[ "$skipped" -eq 0 ]] && [[ "$repaired" -eq 0 ]] && [[ "$state_migrated" -eq 0 ]]; then
|
|
610
683
|
info "Nothing to fix — all directories and symlinks are correct."
|
|
611
684
|
else
|
|
612
685
|
if [[ "$fixed" -gt 0 ]]; then info "Fixed $fixed item(s)."; fi
|
|
613
686
|
if [[ "$merged" -gt 0 ]]; then info "Merged $merged item(s) (legacy overwrote existing)."; fi
|
|
614
687
|
if [[ "$skipped" -gt 0 ]]; then warn "Skipped $skipped item(s) (use without --no-clobber to merge)."; fi
|
|
615
688
|
if [[ "$repaired" -gt 0 ]]; then info "Repaired $repaired symlink(s)."; fi
|
|
689
|
+
if [[ "$state_migrated" -gt 0 ]]; then info "Migrated legacy STATE.md to per-file state pattern."; fi
|
|
616
690
|
if [[ "$fixed" -gt 0 ]]; then info "Run 'sync-agents sync' to update agent target symlinks."; fi
|
|
617
691
|
fi
|
|
618
692
|
}
|
|
@@ -1308,10 +1382,26 @@ HEADER
|
|
|
1308
1382
|
fi
|
|
1309
1383
|
echo ""
|
|
1310
1384
|
|
|
1311
|
-
# State
|
|
1385
|
+
# State (list individual state snapshot files)
|
|
1312
1386
|
echo "## State"
|
|
1313
1387
|
echo ""
|
|
1314
|
-
|
|
1388
|
+
local has_state="false"
|
|
1389
|
+
if compgen -G "$agents_dir/STATE_*.md" > /dev/null 2>&1; then
|
|
1390
|
+
for f in "$agents_dir"/STATE_*.md; do
|
|
1391
|
+
local name
|
|
1392
|
+
name="$(basename "$f" .md)"
|
|
1393
|
+
echo "- [$name](.agents/$(basename "$f"))"
|
|
1394
|
+
has_state="true"
|
|
1395
|
+
done
|
|
1396
|
+
fi
|
|
1397
|
+
# Legacy fallback: still list STATE.md if it exists (pre-migration)
|
|
1398
|
+
if [[ -f "$agents_dir/STATE.md" ]]; then
|
|
1399
|
+
echo "- [STATE.md](.agents/STATE.md)"
|
|
1400
|
+
has_state="true"
|
|
1401
|
+
fi
|
|
1402
|
+
if [[ "$has_state" == "false" ]]; then
|
|
1403
|
+
echo "_No state snapshots yet. Agents will create STATE_*context*_*timestamp*.md files as they work._"
|
|
1404
|
+
fi
|
|
1315
1405
|
echo ""
|
|
1316
1406
|
} >> "$outfile"
|
|
1317
1407
|
}
|