agent-mind 1.0.0
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/LICENSE +21 -0
- package/README.md +229 -0
- package/bin/cli.js +38 -0
- package/package.json +33 -0
- package/src/commands/doctor.js +269 -0
- package/src/commands/init.js +345 -0
- package/src/commands/meta.js +34 -0
- package/src/commands/upgrade.js +177 -0
- package/src/index.js +18 -0
- package/src/utils/detect-tools.js +62 -0
- package/src/utils/inject-adapter.js +65 -0
- package/src/utils/template.js +103 -0
- package/src/utils/version.js +71 -0
- package/template/.am-tools/compact.sh +171 -0
- package/template/.am-tools/guide.md +274 -0
- package/template/.am-tools/health-check.sh +165 -0
- package/template/.am-tools/validate.sh +174 -0
- package/template/BOOT.md +71 -0
- package/template/README.md +109 -0
- package/template/VERSION.md +57 -0
- package/template/adapters/claude.md +56 -0
- package/template/adapters/codex.md +33 -0
- package/template/adapters/cursor.md +35 -0
- package/template/adapters/gemini.md +32 -0
- package/template/config.md +33 -0
- package/template/history/episodes/_index.md +13 -0
- package/template/history/maintenance-log.md +9 -0
- package/template/history/reflections/_index.md +11 -0
- package/template/knowledge/domains/_template/failures/_index.md +19 -0
- package/template/knowledge/domains/_template/patterns.md +21 -0
- package/template/knowledge/insights.md +23 -0
- package/template/knowledge/stack/_template.md +20 -0
- package/template/protocols/compaction.md +101 -0
- package/template/protocols/maintenance.md +99 -0
- package/template/protocols/memory-ops.md +89 -0
- package/template/protocols/quality-gate.md +66 -0
- package/template/protocols/workflow.md +81 -0
- package/template/workspace/.gitkeep +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
##############################################################################
|
|
4
|
+
# health-check.sh
|
|
5
|
+
# Checks Agent Mind system health and reports issues
|
|
6
|
+
#
|
|
7
|
+
# Usage: bash .agent-mind/.am-tools/health-check.sh
|
|
8
|
+
#
|
|
9
|
+
# Exit codes:
|
|
10
|
+
# 0 = Healthy (no issues)
|
|
11
|
+
# 1 = Issues found
|
|
12
|
+
##############################################################################
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
# Colors for output
|
|
17
|
+
RED='\033[0;31m'
|
|
18
|
+
GREEN='\033[0;32m'
|
|
19
|
+
YELLOW='\033[1;33m'
|
|
20
|
+
BLUE='\033[0;34m'
|
|
21
|
+
NC='\033[0m' # No Color
|
|
22
|
+
|
|
23
|
+
# Find .agent-mind root by walking up from script location
|
|
24
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
25
|
+
AGENT_MIND_ROOT="$(cd "$(dirname "$SCRIPT_DIR")" && pwd)"
|
|
26
|
+
|
|
27
|
+
# Thresholds
|
|
28
|
+
BOOT_MD_MAX_LINES=150
|
|
29
|
+
PROTOCOLS_MAX_LINES=200
|
|
30
|
+
PATTERNS_MAX_LINES=200
|
|
31
|
+
|
|
32
|
+
# Status tracking
|
|
33
|
+
HEALTH_STATUS=0
|
|
34
|
+
ISSUES_FOUND=0
|
|
35
|
+
|
|
36
|
+
echo -e "${BLUE}========================================${NC}"
|
|
37
|
+
echo -e "${BLUE}Agent Mind Health Check${NC}"
|
|
38
|
+
echo -e "${BLUE}========================================${NC}"
|
|
39
|
+
echo ""
|
|
40
|
+
|
|
41
|
+
# Helper function to report status
|
|
42
|
+
report_check() {
|
|
43
|
+
local check_name="$1"
|
|
44
|
+
local status="$2"
|
|
45
|
+
local message="$3"
|
|
46
|
+
|
|
47
|
+
case $status in
|
|
48
|
+
pass)
|
|
49
|
+
echo -e "${GREEN}✓ $check_name${NC}: $message"
|
|
50
|
+
;;
|
|
51
|
+
warn)
|
|
52
|
+
echo -e "${YELLOW}⚠ $check_name${NC}: $message"
|
|
53
|
+
ISSUES_FOUND=$((ISSUES_FOUND + 1))
|
|
54
|
+
;;
|
|
55
|
+
fail)
|
|
56
|
+
echo -e "${RED}✗ $check_name${NC}: $message"
|
|
57
|
+
HEALTH_STATUS=1
|
|
58
|
+
ISSUES_FOUND=$((ISSUES_FOUND + 1))
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# 1. Check line counts
|
|
64
|
+
echo "📊 Line Counts:"
|
|
65
|
+
echo ""
|
|
66
|
+
|
|
67
|
+
# BOOT.md
|
|
68
|
+
if [[ -f "$AGENT_MIND_ROOT/BOOT.md" ]]; then
|
|
69
|
+
boot_lines=$(wc -l < "$AGENT_MIND_ROOT/BOOT.md")
|
|
70
|
+
if (( boot_lines < BOOT_MD_MAX_LINES )); then
|
|
71
|
+
report_check "BOOT.md" "pass" "$boot_lines lines (< $BOOT_MD_MAX_LINES)"
|
|
72
|
+
else
|
|
73
|
+
report_check "BOOT.md" "warn" "$boot_lines lines (exceeds $BOOT_MD_MAX_LINES limit)"
|
|
74
|
+
fi
|
|
75
|
+
else
|
|
76
|
+
report_check "BOOT.md" "fail" "File not found"
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# Protocol files
|
|
80
|
+
echo ""
|
|
81
|
+
if [[ -d "$AGENT_MIND_ROOT/protocols" ]]; then
|
|
82
|
+
for protocol_file in "$AGENT_MIND_ROOT/protocols"/*.md; do
|
|
83
|
+
if [[ -f "$protocol_file" ]]; then
|
|
84
|
+
proto_name=$(basename "$protocol_file")
|
|
85
|
+
proto_lines=$(wc -l < "$protocol_file")
|
|
86
|
+
if (( proto_lines < PROTOCOLS_MAX_LINES )); then
|
|
87
|
+
report_check "protocol: $proto_name" "pass" "$proto_lines lines (< $PROTOCOLS_MAX_LINES)"
|
|
88
|
+
else
|
|
89
|
+
report_check "protocol: $proto_name" "warn" "$proto_lines lines (exceeds $PROTOCOLS_MAX_LINES limit)"
|
|
90
|
+
fi
|
|
91
|
+
fi
|
|
92
|
+
done
|
|
93
|
+
else
|
|
94
|
+
report_check "protocols/" "fail" "Directory not found"
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# Knowledge domain patterns
|
|
98
|
+
echo ""
|
|
99
|
+
if [[ -d "$AGENT_MIND_ROOT/knowledge" ]]; then
|
|
100
|
+
for domain_dir in "$AGENT_MIND_ROOT/knowledge"/*; do
|
|
101
|
+
if [[ -d "$domain_dir" ]]; then
|
|
102
|
+
domain_name=$(basename "$domain_dir")
|
|
103
|
+
patterns_file="$domain_dir/patterns.md"
|
|
104
|
+
if [[ -f "$patterns_file" ]]; then
|
|
105
|
+
patterns_lines=$(wc -l < "$patterns_file")
|
|
106
|
+
if (( patterns_lines < PATTERNS_MAX_LINES )); then
|
|
107
|
+
report_check "knowledge: $domain_name" "pass" "$patterns_lines lines (< $PATTERNS_MAX_LINES)"
|
|
108
|
+
else
|
|
109
|
+
report_check "knowledge: $domain_name" "warn" "$patterns_lines lines (exceeds $PATTERNS_MAX_LINES limit)"
|
|
110
|
+
fi
|
|
111
|
+
fi
|
|
112
|
+
fi
|
|
113
|
+
done
|
|
114
|
+
fi
|
|
115
|
+
|
|
116
|
+
# 2. Check for [UNVERIFIED] tags
|
|
117
|
+
echo ""
|
|
118
|
+
echo "🔍 Verification Status:"
|
|
119
|
+
echo ""
|
|
120
|
+
|
|
121
|
+
unverified_count=0
|
|
122
|
+
if [[ -d "$AGENT_MIND_ROOT/knowledge" ]]; then
|
|
123
|
+
unverified_count=$(grep -r "\[UNVERIFIED\]" "$AGENT_MIND_ROOT/knowledge" 2>/dev/null | wc -l || true)
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
if (( unverified_count == 0 )); then
|
|
127
|
+
report_check "Unverified tags" "pass" "No [UNVERIFIED] tags found"
|
|
128
|
+
else
|
|
129
|
+
report_check "Unverified tags" "warn" "Found $unverified_count [UNVERIFIED] tags"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
# 3. Count episodes and insights
|
|
133
|
+
echo ""
|
|
134
|
+
echo "📈 Content Summary:"
|
|
135
|
+
echo ""
|
|
136
|
+
|
|
137
|
+
episodes_count=0
|
|
138
|
+
if [[ -d "$AGENT_MIND_ROOT/history/episodes" ]]; then
|
|
139
|
+
episodes_count=$(find "$AGENT_MIND_ROOT/history/episodes" -name "*.md" -not -name "_index.md" | wc -l || true)
|
|
140
|
+
fi
|
|
141
|
+
report_check "Episodes recorded" "pass" "$episodes_count episode(s)"
|
|
142
|
+
|
|
143
|
+
insights_count=0
|
|
144
|
+
if [[ -d "$AGENT_MIND_ROOT/knowledge" ]]; then
|
|
145
|
+
insights_count=$(find "$AGENT_MIND_ROOT/knowledge" -name "*.md" -not -name "patterns.md" -not -name "_index.md" | wc -l || true)
|
|
146
|
+
fi
|
|
147
|
+
report_check "Knowledge insights" "pass" "$insights_count insight(s)"
|
|
148
|
+
|
|
149
|
+
reflections_count=0
|
|
150
|
+
if [[ -d "$AGENT_MIND_ROOT/history/reflections" ]]; then
|
|
151
|
+
reflections_count=$(find "$AGENT_MIND_ROOT/history/reflections" -name "*.md" -not -name "_index.md" | wc -l || true)
|
|
152
|
+
fi
|
|
153
|
+
report_check "Reflections recorded" "pass" "$reflections_count reflection(s)"
|
|
154
|
+
|
|
155
|
+
# Summary
|
|
156
|
+
echo ""
|
|
157
|
+
echo -e "${BLUE}========================================${NC}"
|
|
158
|
+
if (( HEALTH_STATUS == 0 && ISSUES_FOUND == 0 )); then
|
|
159
|
+
echo -e "${GREEN}✓ Agent Mind is healthy${NC}"
|
|
160
|
+
else
|
|
161
|
+
echo -e "${YELLOW}⚠ Found $ISSUES_FOUND issue(s)${NC}"
|
|
162
|
+
fi
|
|
163
|
+
echo -e "${BLUE}========================================${NC}"
|
|
164
|
+
|
|
165
|
+
exit $HEALTH_STATUS
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
##############################################################################
|
|
4
|
+
# validate.sh
|
|
5
|
+
# Validates Agent Mind structure and required files
|
|
6
|
+
#
|
|
7
|
+
# Usage: bash .agent-mind/.am-tools/validate.sh
|
|
8
|
+
#
|
|
9
|
+
# Exit codes:
|
|
10
|
+
# 0 = All checks passed
|
|
11
|
+
# 1 = One or more checks failed
|
|
12
|
+
##############################################################################
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
# Colors for output
|
|
17
|
+
RED='\033[0;31m'
|
|
18
|
+
GREEN='\033[0;32m'
|
|
19
|
+
YELLOW='\033[1;33m'
|
|
20
|
+
BLUE='\033[0;34m'
|
|
21
|
+
NC='\033[0m' # No Color
|
|
22
|
+
|
|
23
|
+
# Find .agent-mind root by walking up from script location
|
|
24
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
25
|
+
AGENT_MIND_ROOT="$(cd "$(dirname "$SCRIPT_DIR")" && pwd)"
|
|
26
|
+
|
|
27
|
+
# Status tracking
|
|
28
|
+
VALIDATION_STATUS=0
|
|
29
|
+
PASSED_CHECKS=0
|
|
30
|
+
FAILED_CHECKS=0
|
|
31
|
+
|
|
32
|
+
echo -e "${BLUE}========================================${NC}"
|
|
33
|
+
echo -e "${BLUE}Agent Mind Structure Validation${NC}"
|
|
34
|
+
echo -e "${BLUE}========================================${NC}"
|
|
35
|
+
echo ""
|
|
36
|
+
|
|
37
|
+
# Helper function to report validation result
|
|
38
|
+
check_item() {
|
|
39
|
+
local item_name="$1"
|
|
40
|
+
local item_path="$2"
|
|
41
|
+
local item_type="$3" # "dir" or "file"
|
|
42
|
+
|
|
43
|
+
if [[ "$item_type" == "dir" ]]; then
|
|
44
|
+
if [[ -d "$item_path" ]]; then
|
|
45
|
+
echo -e "${GREEN}✓ Directory exists: $item_name${NC}"
|
|
46
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
47
|
+
else
|
|
48
|
+
echo -e "${RED}✗ Directory missing: $item_name${NC}"
|
|
49
|
+
VALIDATION_STATUS=1
|
|
50
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
51
|
+
fi
|
|
52
|
+
elif [[ "$item_type" == "file" ]]; then
|
|
53
|
+
if [[ -f "$item_path" ]]; then
|
|
54
|
+
echo -e "${GREEN}✓ File exists: $item_name${NC}"
|
|
55
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
56
|
+
else
|
|
57
|
+
echo -e "${RED}✗ File missing: $item_name${NC}"
|
|
58
|
+
VALIDATION_STATUS=1
|
|
59
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
60
|
+
fi
|
|
61
|
+
fi
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# 1. Check required directories
|
|
65
|
+
echo "📁 Required Directories:"
|
|
66
|
+
echo ""
|
|
67
|
+
|
|
68
|
+
check_item "protocols/" "$AGENT_MIND_ROOT/protocols" "dir"
|
|
69
|
+
check_item "knowledge/" "$AGENT_MIND_ROOT/knowledge" "dir"
|
|
70
|
+
check_item "workspace/" "$AGENT_MIND_ROOT/workspace" "dir"
|
|
71
|
+
check_item "history/" "$AGENT_MIND_ROOT/history" "dir"
|
|
72
|
+
check_item "history/episodes/" "$AGENT_MIND_ROOT/history/episodes" "dir"
|
|
73
|
+
check_item "history/reflections/" "$AGENT_MIND_ROOT/history/reflections" "dir"
|
|
74
|
+
check_item "adapters/" "$AGENT_MIND_ROOT/adapters" "dir"
|
|
75
|
+
|
|
76
|
+
# 2. Check required files at root
|
|
77
|
+
echo ""
|
|
78
|
+
echo "📄 Required Root Files:"
|
|
79
|
+
echo ""
|
|
80
|
+
|
|
81
|
+
check_item "BOOT.md" "$AGENT_MIND_ROOT/BOOT.md" "file"
|
|
82
|
+
check_item "config.md" "$AGENT_MIND_ROOT/config.md" "file"
|
|
83
|
+
check_item "VERSION.md" "$AGENT_MIND_ROOT/VERSION.md" "file"
|
|
84
|
+
|
|
85
|
+
# 3. Check protocol files
|
|
86
|
+
echo ""
|
|
87
|
+
echo "📋 Protocol Files:"
|
|
88
|
+
echo ""
|
|
89
|
+
|
|
90
|
+
# Define expected protocols (can be customized)
|
|
91
|
+
required_protocols=("reflexion.md" "memory.md" "tools.md")
|
|
92
|
+
for protocol in "${required_protocols[@]}"; do
|
|
93
|
+
protocol_file="$AGENT_MIND_ROOT/protocols/$protocol"
|
|
94
|
+
if [[ -f "$protocol_file" ]]; then
|
|
95
|
+
echo -e "${GREEN}✓ Protocol exists: $protocol${NC}"
|
|
96
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
97
|
+
else
|
|
98
|
+
# Protocols might be optional depending on setup
|
|
99
|
+
echo -e "${YELLOW}⚠ Protocol not found (optional): $protocol${NC}"
|
|
100
|
+
fi
|
|
101
|
+
done
|
|
102
|
+
|
|
103
|
+
# 4. Validate BOOT.md references
|
|
104
|
+
echo ""
|
|
105
|
+
echo "🔗 BOOT.md References:"
|
|
106
|
+
echo ""
|
|
107
|
+
|
|
108
|
+
if [[ -f "$AGENT_MIND_ROOT/BOOT.md" ]]; then
|
|
109
|
+
# Extract file paths from BOOT.md (look for markdown links and file references)
|
|
110
|
+
# This is a basic check for relative paths
|
|
111
|
+
boot_refs=$(grep -oE '\./[^"\s\)]+|\.\/\.\.[^"\s\)]+' "$AGENT_MIND_ROOT/BOOT.md" 2>/dev/null || true)
|
|
112
|
+
|
|
113
|
+
if [[ -z "$boot_refs" ]]; then
|
|
114
|
+
echo -e "${GREEN}✓ BOOT.md reference check: OK (no external references or all valid)${NC}"
|
|
115
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
116
|
+
else
|
|
117
|
+
# Check each reference exists
|
|
118
|
+
ref_valid=true
|
|
119
|
+
while IFS= read -r ref; do
|
|
120
|
+
# Normalize path (remove leading ./)
|
|
121
|
+
normalized_ref="${ref#./}"
|
|
122
|
+
full_path="$AGENT_MIND_ROOT/$normalized_ref"
|
|
123
|
+
|
|
124
|
+
if [[ ! -e "$full_path" ]]; then
|
|
125
|
+
echo -e "${RED}✗ Invalid reference in BOOT.md: $ref${NC}"
|
|
126
|
+
ref_valid=false
|
|
127
|
+
VALIDATION_STATUS=1
|
|
128
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
129
|
+
fi
|
|
130
|
+
done <<< "$boot_refs"
|
|
131
|
+
|
|
132
|
+
if [[ "$ref_valid" == true ]]; then
|
|
133
|
+
echo -e "${GREEN}✓ BOOT.md references are valid${NC}"
|
|
134
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
135
|
+
fi
|
|
136
|
+
fi
|
|
137
|
+
else
|
|
138
|
+
echo -e "${RED}✗ Cannot validate BOOT.md (file not found)${NC}"
|
|
139
|
+
VALIDATION_STATUS=1
|
|
140
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
# 5. Check config.md structure
|
|
144
|
+
echo ""
|
|
145
|
+
echo "⚙️ Configuration:"
|
|
146
|
+
echo ""
|
|
147
|
+
|
|
148
|
+
if [[ -f "$AGENT_MIND_ROOT/config.md" ]]; then
|
|
149
|
+
# Check for at least some basic structure
|
|
150
|
+
if grep -q "^#" "$AGENT_MIND_ROOT/config.md"; then
|
|
151
|
+
echo -e "${GREEN}✓ config.md has valid markdown structure${NC}"
|
|
152
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
153
|
+
else
|
|
154
|
+
echo -e "${YELLOW}⚠ config.md might not have valid structure${NC}"
|
|
155
|
+
fi
|
|
156
|
+
else
|
|
157
|
+
echo -e "${RED}✗ config.md not found${NC}"
|
|
158
|
+
VALIDATION_STATUS=1
|
|
159
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
# Summary
|
|
163
|
+
echo ""
|
|
164
|
+
echo -e "${BLUE}========================================${NC}"
|
|
165
|
+
echo -e "Passed: ${GREEN}$PASSED_CHECKS${NC} | Failed: ${RED}$FAILED_CHECKS${NC}"
|
|
166
|
+
|
|
167
|
+
if (( VALIDATION_STATUS == 0 )); then
|
|
168
|
+
echo -e "${GREEN}✓ All validation checks passed${NC}"
|
|
169
|
+
else
|
|
170
|
+
echo -e "${RED}✗ Validation failed - see errors above${NC}"
|
|
171
|
+
fi
|
|
172
|
+
echo -e "${BLUE}========================================${NC}"
|
|
173
|
+
|
|
174
|
+
exit $VALIDATION_STATUS
|
package/template/BOOT.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Agent Mind — Boot Protocol
|
|
2
|
+
|
|
3
|
+
You have access to a cognitive memory system in `.agent-mind/`. It helps you think better, remember what matters, and improve over time. Read this file first, every session. Non-negotiable.
|
|
4
|
+
|
|
5
|
+
## Session Start
|
|
6
|
+
|
|
7
|
+
1. Read this file (you're doing it now)
|
|
8
|
+
2. Read `.agent-mind/config.md` for project context
|
|
9
|
+
3. Check `.agent-mind/workspace/` — if files exist, a task is in progress. Resume it.
|
|
10
|
+
4. Scan `.agent-mind/knowledge/insights.md` for accumulated learnings
|
|
11
|
+
5. You're now ready to work
|
|
12
|
+
|
|
13
|
+
## When You Receive a Task
|
|
14
|
+
|
|
15
|
+
Follow `.agent-mind/protocols/workflow.md`. The short version:
|
|
16
|
+
|
|
17
|
+
1. **Understand** — What is actually being asked? What's the real goal?
|
|
18
|
+
2. **Load context** — Check `knowledge/domains/` and `knowledge/stack/` for relevant knowledge. Check `knowledge/insights.md`. Check `history/episodes/_index.md` for related past work.
|
|
19
|
+
3. **Think critically** — What could go wrong? Check failure libraries in matched domains. Identify unknowns. Write BLOCKING unknowns to `workspace/questions.md` and HALT.
|
|
20
|
+
4. **Work** — Only after unknowns are resolved. Log decisions to `workspace/decisions.md`.
|
|
21
|
+
5. **Capture** — Follow `protocols/compaction.md`. Summarize, extract insights, clear workspace.
|
|
22
|
+
|
|
23
|
+
## Rules That Never Bend
|
|
24
|
+
|
|
25
|
+
1. **Never implement before clarity.** If you don't understand what you're building, stop and ask.
|
|
26
|
+
2. **BLOCKING unknowns = HALT.** Write them to `workspace/questions.md`. Ask the human. Do not guess on things that matter.
|
|
27
|
+
3. **Capture after every task.** Follow `protocols/compaction.md` to consolidate learning.
|
|
28
|
+
4. **Never delete history.** Files in `history/` are append-only. Never delete, only add.
|
|
29
|
+
5. **Gate your writes.** Before writing to `knowledge/`, check `protocols/quality-gate.md`. Not everything deserves to be remembered. Bad memories poison the system.
|
|
30
|
+
6. **Stay concise.** Keep this file and all `protocols/` files under 200 lines.
|
|
31
|
+
|
|
32
|
+
## Memory System
|
|
33
|
+
|
|
34
|
+
Your memory has three temperatures:
|
|
35
|
+
|
|
36
|
+
**Hot (always loaded):** This file, `config.md`, files in `protocols/`. Your operating system. Loaded every session.
|
|
37
|
+
|
|
38
|
+
**Warm (loaded by relevance):** `knowledge/domains/`, `knowledge/stack/`, `knowledge/insights.md`. Load these based on what the current task needs. Don't load everything — load what's relevant.
|
|
39
|
+
|
|
40
|
+
**Cold (searched on demand):** `history/episodes/`, `history/reflections/`. Search when you need historical context, past decisions, or failure analysis.
|
|
41
|
+
|
|
42
|
+
## Self-Maintenance
|
|
43
|
+
|
|
44
|
+
You are not autonomous. You think, then propose. The human decides.
|
|
45
|
+
|
|
46
|
+
**Trigger:** At session start, check `history/maintenance-log.md`. If the last entry is more than 2 weeks old (or no entries exist and `history/episodes/_index.md` has 5+ entries), suggest to the human: "Memory maintenance is due. Want me to run a health check?"
|
|
47
|
+
|
|
48
|
+
When running maintenance, follow `protocols/maintenance.md` to:
|
|
49
|
+
- Check memory health (stale insights? growing too large? contradictions?)
|
|
50
|
+
- Flag memories you're uncertain about
|
|
51
|
+
- Propose cleanup actions to the human
|
|
52
|
+
- Report on what's working and what's not
|
|
53
|
+
|
|
54
|
+
If you notice something wrong with your memory during normal work — a pattern that led you astray, an insight that contradicts evidence — flag it immediately. Don't wait for scheduled maintenance.
|
|
55
|
+
|
|
56
|
+
## Adapters
|
|
57
|
+
|
|
58
|
+
If you are Claude Code, also read `.agent-mind/adapters/claude.md`.
|
|
59
|
+
If you are Codex / OpenAI Agents, also read `.agent-mind/adapters/codex.md`.
|
|
60
|
+
If you are Gemini CLI, also read `.agent-mind/adapters/gemini.md`.
|
|
61
|
+
If you are Cursor, also read `.agent-mind/adapters/cursor.md`.
|
|
62
|
+
|
|
63
|
+
These contain tool-specific integration instructions.
|
|
64
|
+
|
|
65
|
+
## Extending This System
|
|
66
|
+
|
|
67
|
+
- **New domain knowledge?** Create a folder in `knowledge/domains/[name]/` with `patterns.md` and `failures/_index.md`. See `knowledge/domains/_template/` for the format.
|
|
68
|
+
- **New tech stack knowledge?** Create `knowledge/stack/[tech].md`. See `knowledge/stack/_template.md`.
|
|
69
|
+
- **Custom protocols?** Add `.md` files to `protocols/`. Reference them from this file or from workflow.md.
|
|
70
|
+
|
|
71
|
+
The structure is the product. Extend it by creating markdown files.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Agent Mind
|
|
2
|
+
|
|
3
|
+
A standalone cognitive memory system for LLM agents. Drop this folder into any project. Any LLM tool (Claude Code, Codex, Gemini CLI, Cursor, or others) can use it to think better, remember what matters, and improve over time.
|
|
4
|
+
|
|
5
|
+
## What This Is
|
|
6
|
+
|
|
7
|
+
A folder of markdown files that gives any LLM agent:
|
|
8
|
+
|
|
9
|
+
- **Structured thinking** — a workflow protocol that ensures understanding before implementation
|
|
10
|
+
- **Persistent memory** — knowledge that survives across sessions, organized by domain
|
|
11
|
+
- **Learning from experience** — every completed task feeds back into domain knowledge
|
|
12
|
+
- **Failure prevention** — known failure patterns are checked before new work begins
|
|
13
|
+
- **Self-maintenance** — protocols for checking memory health and preventing degradation
|
|
14
|
+
- **Tool agnosticism** — works with any LLM tool that can read files
|
|
15
|
+
|
|
16
|
+
No databases. No embeddings. No external services. Just `.md` files that any LLM can read.
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
1. Copy the `.agent-mind/` folder into your project root
|
|
21
|
+
2. Edit `config.md` with your project details
|
|
22
|
+
3. Set up your LLM tool's integration (see `adapters/` for your tool)
|
|
23
|
+
4. Start working — the agent follows the protocols in `BOOT.md`
|
|
24
|
+
|
|
25
|
+
## How It Works
|
|
26
|
+
|
|
27
|
+
The agent reads `BOOT.md` at the start of every session. BOOT.md tells it how to:
|
|
28
|
+
- Load relevant knowledge before starting work
|
|
29
|
+
- Think critically (check failure patterns, identify unknowns)
|
|
30
|
+
- Capture learning after every task
|
|
31
|
+
- Maintain memory health over time
|
|
32
|
+
|
|
33
|
+
### Memory Architecture
|
|
34
|
+
|
|
35
|
+
Three tiers, mapped to cognitive science:
|
|
36
|
+
|
|
37
|
+
| Tier | Directory | Temperature | When Loaded |
|
|
38
|
+
|------|-----------|-------------|-------------|
|
|
39
|
+
| Working memory | `workspace/` | Hot | During active task, cleared after |
|
|
40
|
+
| Semantic memory | `knowledge/` | Warm | When domain/tech matches current task |
|
|
41
|
+
| Episodic memory | `history/` | Cold | Searched on demand for past context |
|
|
42
|
+
| Procedural memory | `protocols/` | Hot | Operating instructions, always available |
|
|
43
|
+
|
|
44
|
+
### The Learning Loop
|
|
45
|
+
|
|
46
|
+
1. **Work** → agent follows workflow protocol
|
|
47
|
+
2. **Capture** → compaction protocol extracts insights from completed tasks
|
|
48
|
+
3. **Accumulate** → insights stored with vote counts, patterns stored by domain
|
|
49
|
+
4. **Apply** → next task loads relevant knowledge, including from past work
|
|
50
|
+
5. **Maintain** → periodic health checks prune bad memories, promote good ones
|
|
51
|
+
|
|
52
|
+
This is backed by research: ExpeL (cross-task learning), Reflexion (failure analysis), SimpleMem (quality-gated writes), MemGPT (tiered memory management).
|
|
53
|
+
|
|
54
|
+
## Directory Structure
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
.agent-mind/
|
|
58
|
+
├── BOOT.md ← Agent entry point (read first, every session)
|
|
59
|
+
├── config.md ← Project settings
|
|
60
|
+
├── README.md ← This file (for humans)
|
|
61
|
+
│
|
|
62
|
+
├── protocols/ ← HOW the agent operates (procedural memory)
|
|
63
|
+
│ ├── workflow.md ← Thinking & working process
|
|
64
|
+
│ ├── memory-ops.md ← Memory read/write rules
|
|
65
|
+
│ ├── compaction.md ← Post-task learning capture
|
|
66
|
+
│ ├── maintenance.md ← Memory health & cleanup
|
|
67
|
+
│ └── quality-gate.md ← What deserves to be remembered
|
|
68
|
+
│
|
|
69
|
+
├── knowledge/ ← WHAT the agent knows (semantic memory)
|
|
70
|
+
│ ├── domains/ ← Domain expertise (patterns + failures)
|
|
71
|
+
│ ├── stack/ ← Technology-specific knowledge
|
|
72
|
+
│ └── insights.md ← Cross-domain learnings with vote counts
|
|
73
|
+
│
|
|
74
|
+
├── workspace/ ← Current task (working memory, cleared after)
|
|
75
|
+
│
|
|
76
|
+
├── history/ ← What has happened (episodic memory)
|
|
77
|
+
│ ├── episodes/ ← Task summaries + index
|
|
78
|
+
│ ├── reflections/ ← Failure analysis
|
|
79
|
+
│ └── maintenance-log.md
|
|
80
|
+
│
|
|
81
|
+
└── adapters/ ← Tool-specific integration
|
|
82
|
+
├── claude.md ← Claude Code setup
|
|
83
|
+
├── codex.md ← OpenAI Codex setup
|
|
84
|
+
├── gemini.md ← Gemini CLI setup
|
|
85
|
+
└── cursor.md ← Cursor setup
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Design Principles
|
|
89
|
+
|
|
90
|
+
1. **Everything is markdown.** If it can't be a `.md` file, it doesn't belong here.
|
|
91
|
+
2. **The structure is the product.** Extend by creating folders and files. No code needed.
|
|
92
|
+
3. **Quality over quantity.** Not everything gets remembered. Bad memories poison the system.
|
|
93
|
+
4. **Human drives, agent maintains.** The agent proposes; the human decides.
|
|
94
|
+
5. **Nothing is deleted, only moved.** History is append-only. Cold storage preserves everything.
|
|
95
|
+
6. **Non-disruptive.** Drop in, remove later. No changes to your project files.
|
|
96
|
+
|
|
97
|
+
## Research Foundation
|
|
98
|
+
|
|
99
|
+
Built on findings from:
|
|
100
|
+
- **Letta/MemGPT:** Filesystem-based memory achieves 74% on LoCoMo (beating Mem0's 68.5% graph DB)
|
|
101
|
+
- **Claude Code:** Files under 200 lines achieve >92% instruction adherence
|
|
102
|
+
- **ExpeL:** Cross-task insight extraction with vote-based promotion (+31% on ALFWorld)
|
|
103
|
+
- **Reflexion:** Self-critique after failure (+22% on AlfWorld, +20% on HotPotQA)
|
|
104
|
+
- **SimpleMem:** Quality-gated writes prevent self-degradation (26.4% improvement over Mem0)
|
|
105
|
+
- **Xiong et al.:** Naive "remember everything" causes sustained performance decline
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT — use it, modify it, share it.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Agent Mind — Version & Manifest
|
|
2
|
+
|
|
3
|
+
## Installation Info
|
|
4
|
+
- **Installed version:** {{VERSION}}
|
|
5
|
+
- **Installed date:** {{DATE}}
|
|
6
|
+
- **npm package:** agent-mind
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Core Files (Managed by Upgrade)
|
|
11
|
+
|
|
12
|
+
These files are replaced when you upgrade the agent-mind package. They should not be edited locally — any customizations will be lost.
|
|
13
|
+
|
|
14
|
+
- `BOOT.md` — Agent entry point and session start protocol
|
|
15
|
+
- `protocols/workflow.md` — 5-phase thinking process
|
|
16
|
+
- `protocols/memory-ops.md` — Memory read/write rules and file limits
|
|
17
|
+
- `protocols/compaction.md` — Post-task consolidation protocol
|
|
18
|
+
- `protocols/quality-gate.md` — Memory quality filter
|
|
19
|
+
- `protocols/maintenance.md` — Self-maintenance protocol
|
|
20
|
+
- `.agent-mind/.am-tools/guide.md` — Tool documentation
|
|
21
|
+
- `adapters/claude.md` — Claude Code integration
|
|
22
|
+
- `adapters/codex.md` — OpenAI Codex integration
|
|
23
|
+
- `adapters/gemini.md` — Gemini CLI integration
|
|
24
|
+
- `adapters/cursor.md` — Cursor integration
|
|
25
|
+
- `VERSION.md` — This file
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## User Files (Never Touched on Upgrade)
|
|
30
|
+
|
|
31
|
+
These files are yours. The upgrade process will never modify them, even if major updates happen. You control these entirely.
|
|
32
|
+
|
|
33
|
+
- `config.md` — Project configuration and context
|
|
34
|
+
- `README.md` — Project-specific agent mind setup notes (if you create one)
|
|
35
|
+
- `knowledge/domains/*/patterns.md` — Domain-specific patterns you've learned
|
|
36
|
+
- `knowledge/domains/*/failures/` — Failure libraries you've built
|
|
37
|
+
- `knowledge/stack/` — Stack-specific knowledge
|
|
38
|
+
- `knowledge/insights.md` — Cross-domain learnings
|
|
39
|
+
- `workspace/` — Working memory (ephemeral, cleared after compaction)
|
|
40
|
+
- `history/episodes/` — Episodic memory (task records)
|
|
41
|
+
- `history/episodes/_index.md` — Episode index
|
|
42
|
+
- `history/reflections/` — Failure reflections
|
|
43
|
+
- `history/reflections/_index.md` — Reflections index
|
|
44
|
+
- `history/maintenance-log.md` — Maintenance audit trail
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Upgrade Behavior
|
|
49
|
+
|
|
50
|
+
When you run `npx agent-mind upgrade` or receive a new version:
|
|
51
|
+
|
|
52
|
+
1. Core files are replaced with the new version
|
|
53
|
+
2. User files are never touched
|
|
54
|
+
3. A backup of your previous core files is created in `.agent-mind/_backups/[version]/` (optional, kept for reference)
|
|
55
|
+
4. If you have customized any core files, consider moving those customizations to `config.md` or creating a custom protocol file
|
|
56
|
+
|
|
57
|
+
If you need to extend the system, create new files in `protocols/` (custom protocols) rather than editing existing ones.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Claude Code Integration
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Add this block to your project's `CLAUDE.md`:
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
## Agent Mind Memory System
|
|
9
|
+
This project uses Agent Mind for structured memory management.
|
|
10
|
+
At the start of every session, read `.agent-mind/BOOT.md` and follow its protocols.
|
|
11
|
+
Use `.agent-mind/workspace/` as working memory for the current task.
|
|
12
|
+
After completing a task, follow `.agent-mind/protocols/compaction.md`.
|
|
13
|
+
When asked about memory health, follow `.agent-mind/protocols/maintenance.md`.
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## How It Works
|
|
17
|
+
|
|
18
|
+
- Claude Code reads `CLAUDE.md` at session start — that's its native instruction file
|
|
19
|
+
- The snippet above makes Claude Code aware of the `.agent-mind/` system
|
|
20
|
+
- Claude Code can read arbitrary files, so all `.agent-mind/` content is accessible
|
|
21
|
+
- Keep the CLAUDE.md snippet under 10 lines — it just points to BOOT.md for details
|
|
22
|
+
|
|
23
|
+
## Coexistence With Claude's Native Memory
|
|
24
|
+
|
|
25
|
+
Claude Code has its own memory systems:
|
|
26
|
+
- `~/.claude/CLAUDE.md` — user-level preferences
|
|
27
|
+
- `.claude/rules/*.md` — glob-matched rules
|
|
28
|
+
- `~/.claude/projects/[hash]/memory/` — auto-memory
|
|
29
|
+
|
|
30
|
+
Agent Mind complements these:
|
|
31
|
+
- Claude's auto-memory: session-level, unstructured, tool-specific
|
|
32
|
+
- Agent Mind: project-level, structured (episodic/semantic/procedural), tool-agnostic
|
|
33
|
+
|
|
34
|
+
They don't conflict. Use both. Claude's auto-memory handles session continuity. Agent Mind handles structured learning and cross-tool knowledge.
|
|
35
|
+
|
|
36
|
+
## Claude-Specific Tips
|
|
37
|
+
|
|
38
|
+
- Claude Code follows instructions in CLAUDE.md ~92% of the time for files under 200 lines
|
|
39
|
+
- All Agent Mind protocol files are kept under 200 lines for this reason
|
|
40
|
+
- Claude responds well to clear, imperative instructions ("read X", "write to Y", "HALT if Z")
|
|
41
|
+
- The BOOT.md and protocol files are written in this style deliberately
|
|
42
|
+
- Claude's `/compact` command resets context but re-reads CLAUDE.md from disk — Agent Mind survives compaction
|
|
43
|
+
|
|
44
|
+
## Recommended CLAUDE.md Structure
|
|
45
|
+
|
|
46
|
+
```markdown
|
|
47
|
+
# Project Instructions
|
|
48
|
+
|
|
49
|
+
## Agent Mind
|
|
50
|
+
[snippet above]
|
|
51
|
+
|
|
52
|
+
## Project-Specific Rules
|
|
53
|
+
[your existing CLAUDE.md rules]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Put the Agent Mind block early in CLAUDE.md so it gets high attention from the model.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# OpenAI Codex / Agents Integration
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Add this block to your project's `AGENTS.md`:
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
## Agent Mind Memory System
|
|
9
|
+
This project uses Agent Mind for structured memory management.
|
|
10
|
+
At the start of every session, read `.agent-mind/BOOT.md` and follow its protocols.
|
|
11
|
+
Use `.agent-mind/workspace/` as working memory for the current task.
|
|
12
|
+
After completing a task, follow `.agent-mind/protocols/compaction.md`.
|
|
13
|
+
When asked about memory health, follow `.agent-mind/protocols/maintenance.md`.
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## How It Works
|
|
17
|
+
|
|
18
|
+
- Codex CLI reads `AGENTS.md` at session start — that's its native instruction file
|
|
19
|
+
- The snippet makes Codex aware of the `.agent-mind/` system
|
|
20
|
+
- Codex can read files from the filesystem, so all `.agent-mind/` content is accessible
|
|
21
|
+
|
|
22
|
+
## Coexistence
|
|
23
|
+
|
|
24
|
+
- Codex has its own context management via AGENTS.md
|
|
25
|
+
- Agent Mind adds structured memory on top — they complement each other
|
|
26
|
+
- Agent Mind's `knowledge/` persists across Codex sessions
|
|
27
|
+
- Codex's native context resets each session; Agent Mind's doesn't
|
|
28
|
+
|
|
29
|
+
## Codex-Specific Tips
|
|
30
|
+
|
|
31
|
+
- Codex in `--full-auto` mode may skip some protocol steps. Consider running without `--full-auto` for tasks that benefit from the full thinking workflow
|
|
32
|
+
- For code execution tasks, the workflow's Phase 3 (Think Critically) is especially valuable — Codex tends to jump straight to implementation
|
|
33
|
+
- Keep AGENTS.md snippets concise. Codex's instruction adherence improves with shorter, clearer instructions
|