Skip to content

Commit 16872c6

Browse files
DEXDEX
authored andcommitted
feat: agent-native architecture - 7 new tools for multi-agent coordination
- agent-context.sh: Auto-inject project context on agent startup - agent-share.sh: Cross-agent memory sharing - agent-decision.sh: Decision logging with reasoning chains - agent-checkpoint.sh: Checkpoint and rollback system - agent-knowledge.sh: Project knowledge base management - agent-optimize.sh: Smart memory optimization - agent-tasks.sh: Task dependency graph for multi-agent coordination Also fixed path inconsistencies in .zshrc-wrap and session-wrap.sh. Bumped version to 3.4.0 for new features.
1 parent 894cc44 commit 16872c6

File tree

10 files changed

+965
-8
lines changed

10 files changed

+965
-8
lines changed

.zshrc-wrap

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,28 @@ export YD_OBSIDIAN="$YD_WORKSPACE/obsidian"
1111
function wrap() {
1212
case "${1:-}" in
1313
login|logout|status|history|help)
14-
bash "$YD_WORKSPACE/wrap-cli.sh" "$@"
14+
bash "$YD_WORKSPACE/scripts/wrap-cli.sh" "$@"
1515
;;
1616
*)
17-
bash "$YD_WORKSPACE/session-wrap.sh" "$@"
17+
bash "$YD_WORKSPACE/scripts/session-wrap.sh" "$@"
1818
;;
1919
esac
2020
}
2121
alias wrap-summary='wrap "$(date +%Y-%m-%d) — Session summary"'
2222

2323
# Auto-sync
24-
alias sync-kb='bash "$YD_WORKSPACE/obsidian-sync.sh"'
24+
alias sync-kb='bash "$YD_WORKSPACE/scripts/obsidian-sync.sh"'
2525
alias sync-all='wrap && sync-kb'
2626

27+
# Agent tools (v3.4.0)
28+
alias agent-context='bash "$YD_WORKSPACE/scripts/agent-context.sh"'
29+
alias agent-share='bash "$YD_WORKSPACE/scripts/agent-share.sh"'
30+
alias agent-decision='bash "$YD_WORKSPACE/scripts/agent-decision.sh"'
31+
alias agent-checkpoint='bash "$YD_WORKSPACE/scripts/agent-checkpoint.sh"'
32+
alias agent-knowledge='bash "$YD_WORKSPACE/scripts/agent-knowledge.sh"'
33+
alias agent-optimize='bash "$YD_WORKSPACE/scripts/agent-optimize.sh"'
34+
alias agent-tasks='bash "$YD_WORKSPACE/scripts/agent-tasks.sh"'
35+
2736
# Memory shortcuts
2837
alias mem='cat "$YD_MEMORY/MEMORY.md" | head -50'
2938
alias mem-full='cat "$YD_MEMORY/MEMORY.md"'
@@ -56,5 +65,11 @@ function yd-end-session() {
5665
echo " 2. Push: cd $YD_WORKSPACE && git push"
5766
}
5867

59-
echo "✅ YD 2026 wrap aliases loaded"
68+
echo "✅ YD 2026 wrap aliases loaded (v3.4.0 agent-native)"
69+
echo ""
70+
echo "Session management:"
6071
echo " wrap, sync-kb, mem, kb, yd-start-session, yd-end-session"
72+
echo ""
73+
echo "Agent tools:"
74+
echo " agent-context, agent-share, agent-decision, agent-checkpoint"
75+
echo " agent-knowledge, agent-optimize, agent-tasks"

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "session-wrap-skill",
3-
"version": "3.3.0",
3+
"version": "3.4.0",
44
"description": "Universal session wrap-up: automatically persist project context to memory files for seamless resume",
55
"main": "scripts/session-wrap.sh",
66
"scripts": {
@@ -12,6 +12,13 @@
1212
"license": "MIT",
1313
"bin": {
1414
"session-wrap": "scripts/session-wrap.sh",
15-
"obsidian-sync": "scripts/obsidian-sync.sh"
15+
"obsidian-sync": "scripts/obsidian-sync.sh",
16+
"agent-context": "scripts/agent-context.sh",
17+
"agent-share": "scripts/agent-share.sh",
18+
"agent-decision": "scripts/agent-decision.sh",
19+
"agent-checkpoint": "scripts/agent-checkpoint.sh",
20+
"agent-knowledge": "scripts/agent-knowledge.sh",
21+
"agent-optimize": "scripts/agent-optimize.sh",
22+
"agent-tasks": "scripts/agent-tasks.sh"
1623
}
1724
}

scripts/agent-checkpoint.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
3+
# agent-checkpoint.sh — Checkpoint and rollback system
4+
# Usage: agent-checkpoint save [label]
5+
# agent-checkpoint list
6+
# agent-checkpoint restore <id>
7+
# agent-checkpoint diff <id>
8+
9+
set -e
10+
11+
MEMORY_DIR="${YD_MEMORY:-/Users/dex/.claude/projects/-Users-dex-YD-2026/memory}"
12+
WORKSPACE="${YD_WORKSPACE:-/Users/dex/YD 2026}"
13+
CHECKPOINTS_DIR="$MEMORY_DIR/checkpoints"
14+
MANIFEST="$CHECKPOINTS_DIR/manifest.json"
15+
16+
mkdir -p "$CHECKPOINTS_DIR"
17+
18+
# Initialize manifest if not exists
19+
if [ ! -f "$MANIFEST" ]; then
20+
echo '{"checkpoints": {}}' > "$MANIFEST"
21+
fi
22+
23+
# Save a checkpoint
24+
cmd_save() {
25+
local label="${1:-Auto-checkpoint}"
26+
local timestamp=$(date +%s)
27+
local id=$(date +%Y%m%d-%H%M%S)
28+
local snapshot_file="$CHECKPOINTS_DIR/$id.snapshot"
29+
30+
# Create a snapshot of current git state
31+
cd "$WORKSPACE"
32+
git status > "$snapshot_file" 2>&1
33+
git diff HEAD >> "$snapshot_file" 2>&1 || true
34+
35+
# Update manifest
36+
local tmp_manifest=$(mktemp)
37+
cat "$MANIFEST" | sed "s/\"checkpoints\": {/\"checkpoints\": {\"$id\": {\"label\": \"$label\", \"timestamp\": $timestamp},/" > "$tmp_manifest"
38+
mv "$tmp_manifest" "$MANIFEST"
39+
40+
echo "✅ Checkpoint saved: $id"
41+
echo " Label: $label"
42+
echo " File: $snapshot_file"
43+
}
44+
45+
# List checkpoints
46+
cmd_list() {
47+
echo "📸 Saved Checkpoints:"
48+
if [ ! -f "$MANIFEST" ]; then
49+
echo " (none yet)"
50+
return
51+
fi
52+
53+
grep -o '"[0-9]\{8\}-[0-9]\{6\}"' "$MANIFEST" | sed 's/"//g' | while read id; do
54+
label=$(grep -o "\"$id\": {\"label\": \"[^\"]*" "$MANIFEST" | sed 's/.*"label": "//' | head -1)
55+
age=$(date -r "$CHECKPOINTS_DIR/$id.snapshot" +%Y-%m-%d\ %H:%M 2>/dev/null || echo "unknown")
56+
echo " - $id: $label [$age]"
57+
done
58+
}
59+
60+
# Restore a checkpoint (dry-run only, shows what would change)
61+
cmd_restore() {
62+
local id="$1"
63+
64+
if [ -z "$id" ]; then
65+
echo "❌ Usage: agent-checkpoint restore <id>"
66+
exit 1
67+
fi
68+
69+
if [ ! -f "$CHECKPOINTS_DIR/$id.snapshot" ]; then
70+
echo "❌ Checkpoint not found: $id"
71+
exit 1
72+
fi
73+
74+
echo "⚠️ To restore checkpoint $id:"
75+
echo " 1. git reset HEAD~N (replace N with number of commits since checkpoint)"
76+
echo " 2. git checkout <branch> (to discard local changes)"
77+
echo ""
78+
echo "Snapshot saved at: $CHECKPOINTS_DIR/$id.snapshot"
79+
echo "Review with: git diff $CHECKPOINTS_DIR/$id.snapshot"
80+
}
81+
82+
# Show diff since checkpoint
83+
cmd_diff() {
84+
local id="$1"
85+
86+
if [ -z "$id" ]; then
87+
echo "❌ Usage: agent-checkpoint diff <id>"
88+
exit 1
89+
fi
90+
91+
if [ ! -f "$CHECKPOINTS_DIR/$id.snapshot" ]; then
92+
echo "❌ Checkpoint not found: $id"
93+
exit 1
94+
fi
95+
96+
echo "📊 Changes since checkpoint $id:"
97+
tail -50 "$CHECKPOINTS_DIR/$id.snapshot"
98+
}
99+
100+
# Main dispatch
101+
case "${1:-}" in
102+
save)
103+
cmd_save "$2"
104+
;;
105+
list)
106+
cmd_list
107+
;;
108+
restore)
109+
cmd_restore "$2"
110+
;;
111+
diff)
112+
cmd_diff "$2"
113+
;;
114+
*)
115+
echo "Usage:"
116+
echo " agent-checkpoint save [label] — create checkpoint"
117+
echo " agent-checkpoint list — list all checkpoints"
118+
echo " agent-checkpoint restore <id> — restore a checkpoint"
119+
echo " agent-checkpoint diff <id> — show changes since checkpoint"
120+
exit 1
121+
;;
122+
esac

scripts/agent-context.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
3+
# agent-context.sh — Auto-inject project context for agents
4+
# Usage: source agent-context.sh
5+
# agent-context [context|full]
6+
7+
set -e
8+
9+
MEMORY_DIR="${YD_MEMORY:-/Users/dex/.claude/projects/-Users-dex-YD-2026/memory}"
10+
11+
# Print compact context (default)
12+
print_context() {
13+
echo "=== Agent Context Injection ==="
14+
echo ""
15+
16+
# Recent decisions (last 3)
17+
echo "## Recent Decisions"
18+
if [ -d "$MEMORY_DIR/decisions" ]; then
19+
ls -t "$MEMORY_DIR/decisions"/*.md 2>/dev/null | head -3 | while read f; do
20+
echo "- $(basename "$f" | sed 's/.md$//')"
21+
done
22+
else
23+
echo "- No decisions logged yet"
24+
fi
25+
echo ""
26+
27+
# Project conventions
28+
echo "## Project Conventions"
29+
if [ -f "$MEMORY_DIR/knowledge/conventions.md" ]; then
30+
grep -E '^\- |^## ' "$MEMORY_DIR/knowledge/conventions.md" | head -5 || echo "- See knowledge/conventions.md"
31+
else
32+
echo "- No conventions set"
33+
fi
34+
echo ""
35+
36+
# Known issues
37+
echo "## Known Issues"
38+
if [ -f "$MEMORY_DIR/knowledge/known-issues.md" ]; then
39+
grep -E '^\- |^## ' "$MEMORY_DIR/knowledge/known-issues.md" | head -5 || echo "- See knowledge/known-issues.md"
40+
else
41+
echo "- No issues recorded"
42+
fi
43+
echo ""
44+
45+
# Next tasks
46+
echo "## Next Tasks"
47+
if [ -f "$MEMORY_DIR/tasks/tasks.json" ]; then
48+
grep '"status": "pending"' "$MEMORY_DIR/tasks/tasks.json" | head -3 | sed 's/.*"id": "//; s/".*//' || echo "- No pending tasks"
49+
else
50+
echo "- No task graph yet"
51+
fi
52+
echo ""
53+
}
54+
55+
# Print full context (with all decisions and knowledge)
56+
print_full() {
57+
echo "=== Full Project Context ==="
58+
echo ""
59+
60+
# All decisions
61+
if [ -d "$MEMORY_DIR/decisions" ]; then
62+
echo "## All Decisions"
63+
ls -t "$MEMORY_DIR/decisions"/*.md 2>/dev/null | while read f; do
64+
echo ""
65+
echo "### $(basename "$f" | sed 's/.md$//')"
66+
sed -n '/^## Decision/,/^##/p' "$f" | head -5
67+
done
68+
fi
69+
echo ""
70+
71+
# All knowledge bases
72+
if [ -d "$MEMORY_DIR/knowledge" ]; then
73+
echo "## Knowledge Base"
74+
ls "$MEMORY_DIR/knowledge"/*.md 2>/dev/null | while read f; do
75+
echo ""
76+
echo "### $(basename "$f" | sed 's/.md$//')"
77+
head -20 "$f"
78+
done
79+
fi
80+
}
81+
82+
# Main
83+
case "${1:-context}" in
84+
context)
85+
print_context
86+
;;
87+
full)
88+
print_full
89+
;;
90+
*)
91+
print_context
92+
;;
93+
esac

scripts/agent-decision.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
3+
# agent-decision.sh — Decision logging with reasoning chain
4+
# Usage: agent-decision log <topic> <decision> <reasoning>
5+
# agent-decision list
6+
# agent-decision search <keyword>
7+
8+
set -e
9+
10+
MEMORY_DIR="${YD_MEMORY:-/Users/dex/.claude/projects/-Users-dex-YD-2026/memory}"
11+
DECISIONS_DIR="$MEMORY_DIR/decisions"
12+
mkdir -p "$DECISIONS_DIR"
13+
14+
# Detect agent type
15+
detect_agent_type() {
16+
if [ -n "$CLAUDE_CODE_TOKEN" ]; then echo "claude-code"; return; fi
17+
if [ -n "$CURSOR_TOKEN" ]; then echo "cursor"; return; fi
18+
if [ -n "$WINDSURF_TOKEN" ]; then echo "windsurf"; return; fi
19+
if [ -n "$CLINE_TOKEN" ]; then echo "cline"; return; fi
20+
if [ -n "$AIDER_TOKEN" ]; then echo "aider"; return; fi
21+
echo "unknown"
22+
}
23+
24+
# Log a decision
25+
cmd_log() {
26+
local topic="$1"
27+
local decision="$2"
28+
local reasoning="$3"
29+
30+
if [ -z "$topic" ] || [ -z "$decision" ] || [ -z "$reasoning" ]; then
31+
echo "❌ Usage: agent-decision log <topic> <decision> <reasoning>"
32+
exit 1
33+
fi
34+
35+
local agent=$(detect_agent_type)
36+
local date=$(date +%Y-%m-%d)
37+
local time=$(date +%H:%M)
38+
local filename="$DECISIONS_DIR/${date}-${topic}.md"
39+
40+
# Append to decision file
41+
{
42+
echo ""
43+
echo "## [$time] $(echo "$agent" | tr '[:lower:]' '[:upper:]')"
44+
echo ""
45+
echo "**Decision:** $decision"
46+
echo ""
47+
echo "**Reasoning:** $reasoning"
48+
echo ""
49+
echo "**Trade-offs:**"
50+
echo "- (none documented yet)"
51+
} >> "$filename"
52+
53+
echo "✅ Logged decision to $(basename $filename)"
54+
}
55+
56+
# List recent decisions
57+
cmd_list() {
58+
echo "📋 Recent Decisions:"
59+
if [ ! -d "$DECISIONS_DIR" ] || [ -z "$(ls -A "$DECISIONS_DIR" 2>/dev/null)" ]; then
60+
echo " (none yet)"
61+
return
62+
fi
63+
64+
ls -t "$DECISIONS_DIR"/*.md 2>/dev/null | while read f; do
65+
echo ""
66+
echo "### $(basename "$f" | sed 's/.md$//')"
67+
# Show last decision from file
68+
tac "$f" | grep -A 5 '^##' | head -6
69+
done
70+
}
71+
72+
# Search decisions
73+
cmd_search() {
74+
local keyword="$1"
75+
76+
if [ -z "$keyword" ]; then
77+
echo "❌ Usage: agent-decision search <keyword>"
78+
exit 1
79+
fi
80+
81+
echo "🔍 Searching for: $keyword"
82+
if [ ! -d "$DECISIONS_DIR" ]; then
83+
echo " (no decisions yet)"
84+
return
85+
fi
86+
87+
grep -r "$keyword" "$DECISIONS_DIR" 2>/dev/null | head -10 || echo " (no matches)"
88+
}
89+
90+
# Main dispatch
91+
case "${1:-}" in
92+
log)
93+
cmd_log "$2" "$3" "$4"
94+
;;
95+
list)
96+
cmd_list
97+
;;
98+
search)
99+
cmd_search "$2"
100+
;;
101+
*)
102+
echo "Usage:"
103+
echo " agent-decision log <topic> <decision> <reasoning> — log a decision"
104+
echo " agent-decision list — list recent decisions"
105+
echo " agent-decision search <keyword> — search decisions"
106+
exit 1
107+
;;
108+
esac

0 commit comments

Comments
 (0)