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,103 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the path to the template directory
|
|
6
|
+
* Resolves from the package root
|
|
7
|
+
*/
|
|
8
|
+
function getTemplatePath() {
|
|
9
|
+
// From src/utils/template.js, go up to package root, then to template/
|
|
10
|
+
return path.join(__dirname, '../../template');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Copy template directory to target location, preserving structure
|
|
15
|
+
* @param {string} targetDir - Destination directory path
|
|
16
|
+
*/
|
|
17
|
+
function copyTemplate(targetDir) {
|
|
18
|
+
const templatePath = getTemplatePath();
|
|
19
|
+
|
|
20
|
+
if (!fs.existsSync(templatePath)) {
|
|
21
|
+
throw new Error(`Template directory not found at ${templatePath}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Create target directory
|
|
25
|
+
if (!fs.existsSync(targetDir)) {
|
|
26
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Recursively copy all files
|
|
30
|
+
function copyDir(src, dest) {
|
|
31
|
+
const items = fs.readdirSync(src);
|
|
32
|
+
|
|
33
|
+
items.forEach(item => {
|
|
34
|
+
const srcPath = path.join(src, item);
|
|
35
|
+
const destPath = path.join(dest, item);
|
|
36
|
+
const stat = fs.statSync(srcPath);
|
|
37
|
+
|
|
38
|
+
if (stat.isDirectory()) {
|
|
39
|
+
if (!fs.existsSync(destPath)) {
|
|
40
|
+
fs.mkdirSync(destPath, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
copyDir(srcPath, destPath);
|
|
43
|
+
} else {
|
|
44
|
+
fs.copyFileSync(srcPath, destPath);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
copyDir(templatePath, targetDir);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Replace template variables in a file
|
|
54
|
+
* Supports {{VAR}} format
|
|
55
|
+
* @param {string} filePath - Path to file
|
|
56
|
+
* @param {Object} variables - Key-value pairs for replacement
|
|
57
|
+
*/
|
|
58
|
+
function replaceVars(filePath, variables) {
|
|
59
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
60
|
+
|
|
61
|
+
// Replace each variable
|
|
62
|
+
Object.entries(variables).forEach(([key, value]) => {
|
|
63
|
+
const placeholder = `{{${key}}}`;
|
|
64
|
+
const regex = new RegExp(placeholder, 'g');
|
|
65
|
+
content = content.replace(regex, String(value));
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Replace variables in all files in a directory (recursively)
|
|
73
|
+
* @param {string} dirPath - Directory path
|
|
74
|
+
* @param {Object} variables - Key-value pairs for replacement
|
|
75
|
+
*/
|
|
76
|
+
function replaceVarsInDir(dirPath, variables) {
|
|
77
|
+
const items = fs.readdirSync(dirPath);
|
|
78
|
+
|
|
79
|
+
items.forEach(item => {
|
|
80
|
+
const fullPath = path.join(dirPath, item);
|
|
81
|
+
const stat = fs.statSync(fullPath);
|
|
82
|
+
|
|
83
|
+
if (stat.isDirectory()) {
|
|
84
|
+
replaceVarsInDir(fullPath, variables);
|
|
85
|
+
} else if (stat.isFile()) {
|
|
86
|
+
// Only process text files
|
|
87
|
+
if (!['.png', '.jpg', '.jpeg', '.gif', '.zip', '.tar'].some(ext => item.endsWith(ext))) {
|
|
88
|
+
try {
|
|
89
|
+
replaceVars(fullPath, variables);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
// Silently skip binary files
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
getTemplatePath,
|
|
100
|
+
copyTemplate,
|
|
101
|
+
replaceVars,
|
|
102
|
+
replaceVarsInDir
|
|
103
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the package version from package.json
|
|
6
|
+
*/
|
|
7
|
+
function getPackageVersion() {
|
|
8
|
+
const packageJsonPath = path.join(__dirname, '../../package.json');
|
|
9
|
+
try {
|
|
10
|
+
const content = fs.readFileSync(packageJsonPath, 'utf8');
|
|
11
|
+
const pkg = JSON.parse(content);
|
|
12
|
+
return pkg.version;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
throw new Error(`Failed to read package version: ${error.message}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get the current Agent Mind version from .agent-mind/VERSION.md
|
|
20
|
+
* @param {string} [agentMindDir='.agent-mind'] - Path to agent-mind directory
|
|
21
|
+
*/
|
|
22
|
+
function getCurrentVersion(agentMindDir = '.agent-mind') {
|
|
23
|
+
const versionPath = path.join(agentMindDir, 'VERSION.md');
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(versionPath)) {
|
|
26
|
+
throw new Error(`Agent Mind not initialized. Run "agent-mind init" first.`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const content = fs.readFileSync(versionPath, 'utf8');
|
|
31
|
+
// Parse version from lines like:
|
|
32
|
+
// - "- **Installed version:** 1.0.0"
|
|
33
|
+
// - "- **Installed version:** {{VERSION}}"
|
|
34
|
+
let match = content.match(/Installed version:\*\*\s*{{VERSION}}/);
|
|
35
|
+
if (match) {
|
|
36
|
+
// Template hasn't been initialized yet - shouldn't reach here in normal flow
|
|
37
|
+
throw new Error('Agent Mind template not initialized - run "agent-mind init"');
|
|
38
|
+
}
|
|
39
|
+
// Match semver pattern: X.Y.Z (the markdown may have ** before/after)
|
|
40
|
+
match = content.match(/Installed version:\*\*\s*([0-9]+\.[0-9]+\.[0-9]+)/);
|
|
41
|
+
if (match) {
|
|
42
|
+
return match[1];
|
|
43
|
+
}
|
|
44
|
+
throw new Error('Version format not recognized in VERSION.md');
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error.message.includes('Agent Mind template not initialized')) {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Failed to read Agent Mind version: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Check if upgrade is needed
|
|
55
|
+
* @param {string} [agentMindDir='.agent-mind'] - Path to agent-mind directory
|
|
56
|
+
*/
|
|
57
|
+
function needsUpgrade(agentMindDir = '.agent-mind') {
|
|
58
|
+
try {
|
|
59
|
+
const current = getCurrentVersion(agentMindDir);
|
|
60
|
+
const pkg = getPackageVersion();
|
|
61
|
+
return current !== pkg;
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
getPackageVersion,
|
|
69
|
+
getCurrentVersion,
|
|
70
|
+
needsUpgrade
|
|
71
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
##############################################################################
|
|
4
|
+
# compact.sh
|
|
5
|
+
# Mechanical compaction tool for Agent Mind episodes and reflections
|
|
6
|
+
#
|
|
7
|
+
# Usage: bash .agent-mind/.am-tools/compact.sh \
|
|
8
|
+
# --task "slug" \
|
|
9
|
+
# --outcome "completed|failed|abandoned" \
|
|
10
|
+
# --domain "domain" \
|
|
11
|
+
# --summary "one line" \
|
|
12
|
+
# [--clear-workspace]
|
|
13
|
+
##############################################################################
|
|
14
|
+
|
|
15
|
+
set -e
|
|
16
|
+
|
|
17
|
+
# Colors for output
|
|
18
|
+
RED='\033[0;31m'
|
|
19
|
+
GREEN='\033[0;32m'
|
|
20
|
+
YELLOW='\033[1;33m'
|
|
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
|
+
# Parse command-line arguments
|
|
28
|
+
TASK_SLUG=""
|
|
29
|
+
OUTCOME=""
|
|
30
|
+
DOMAIN=""
|
|
31
|
+
SUMMARY=""
|
|
32
|
+
CLEAR_WORKSPACE=false
|
|
33
|
+
|
|
34
|
+
while [[ $# -gt 0 ]]; do
|
|
35
|
+
case $1 in
|
|
36
|
+
--task)
|
|
37
|
+
TASK_SLUG="$2"
|
|
38
|
+
shift 2
|
|
39
|
+
;;
|
|
40
|
+
--outcome)
|
|
41
|
+
OUTCOME="$2"
|
|
42
|
+
shift 2
|
|
43
|
+
;;
|
|
44
|
+
--domain)
|
|
45
|
+
DOMAIN="$2"
|
|
46
|
+
shift 2
|
|
47
|
+
;;
|
|
48
|
+
--summary)
|
|
49
|
+
SUMMARY="$2"
|
|
50
|
+
shift 2
|
|
51
|
+
;;
|
|
52
|
+
--clear-workspace)
|
|
53
|
+
CLEAR_WORKSPACE=true
|
|
54
|
+
shift
|
|
55
|
+
;;
|
|
56
|
+
*)
|
|
57
|
+
echo -e "${RED}Unknown option: $1${NC}"
|
|
58
|
+
exit 1
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
# Validate required arguments
|
|
64
|
+
if [[ -z "$TASK_SLUG" || -z "$OUTCOME" || -z "$DOMAIN" || -z "$SUMMARY" ]]; then
|
|
65
|
+
echo -e "${RED}Error: Missing required arguments${NC}"
|
|
66
|
+
echo "Usage: bash .agent-mind/.am-tools/compact.sh \\"
|
|
67
|
+
echo " --task \"slug\" \\"
|
|
68
|
+
echo " --outcome \"completed|failed|abandoned\" \\"
|
|
69
|
+
echo " --domain \"domain\" \\"
|
|
70
|
+
echo " --summary \"one line\" \\"
|
|
71
|
+
echo " [--clear-workspace]"
|
|
72
|
+
exit 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Validate outcome value
|
|
76
|
+
if [[ ! "$OUTCOME" =~ ^(completed|failed|abandoned)$ ]]; then
|
|
77
|
+
echo -e "${RED}Error: outcome must be 'completed', 'failed', or 'abandoned'${NC}"
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# Get current date and time
|
|
82
|
+
NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
83
|
+
YEAR_MONTH=$(date -u +"%Y-%m")
|
|
84
|
+
|
|
85
|
+
# Create history/episodes directory if needed
|
|
86
|
+
EPISODES_DIR="$AGENT_MIND_ROOT/history/episodes/$YEAR_MONTH"
|
|
87
|
+
mkdir -p "$EPISODES_DIR"
|
|
88
|
+
|
|
89
|
+
# Create episode file
|
|
90
|
+
EPISODE_FILE="$EPISODES_DIR/${TASK_SLUG}.md"
|
|
91
|
+
cat > "$EPISODE_FILE" << EOF
|
|
92
|
+
# Episode: $TASK_SLUG
|
|
93
|
+
|
|
94
|
+
**Domain**: $DOMAIN
|
|
95
|
+
**Outcome**: $OUTCOME
|
|
96
|
+
**Date**: $NOW
|
|
97
|
+
|
|
98
|
+
## Summary
|
|
99
|
+
$SUMMARY
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
_Auto-created by compact.sh_
|
|
103
|
+
EOF
|
|
104
|
+
|
|
105
|
+
echo -e "${GREEN}✓ Created episode: $EPISODE_FILE${NC}"
|
|
106
|
+
|
|
107
|
+
# Append one-liner to _index.md
|
|
108
|
+
INDEX_FILE="$AGENT_MIND_ROOT/history/episodes/_index.md"
|
|
109
|
+
if [[ ! -f "$INDEX_FILE" ]]; then
|
|
110
|
+
echo "# Episodes Index" > "$INDEX_FILE"
|
|
111
|
+
echo "" >> "$INDEX_FILE"
|
|
112
|
+
fi
|
|
113
|
+
echo "- \`$YEAR_MONTH/$TASK_SLUG.md\` [$OUTCOME] $SUMMARY" >> "$INDEX_FILE"
|
|
114
|
+
echo -e "${GREEN}✓ Updated episodes index${NC}"
|
|
115
|
+
|
|
116
|
+
# If outcome is "failed", create reflection
|
|
117
|
+
if [[ "$OUTCOME" == "failed" ]]; then
|
|
118
|
+
REFLECTIONS_DIR="$AGENT_MIND_ROOT/history/reflections"
|
|
119
|
+
mkdir -p "$REFLECTIONS_DIR"
|
|
120
|
+
|
|
121
|
+
REFLECTION_FILE="$REFLECTIONS_DIR/${TASK_SLUG}-reflection.md"
|
|
122
|
+
cat > "$REFLECTION_FILE" << EOF
|
|
123
|
+
# Reflection: $TASK_SLUG (Failed)
|
|
124
|
+
|
|
125
|
+
**Domain**: $DOMAIN
|
|
126
|
+
**Original Summary**: $SUMMARY
|
|
127
|
+
**Date**: $NOW
|
|
128
|
+
|
|
129
|
+
## What Went Wrong
|
|
130
|
+
[To be filled in by agent or human]
|
|
131
|
+
|
|
132
|
+
## Lessons Learned
|
|
133
|
+
[To be filled in by agent or human]
|
|
134
|
+
|
|
135
|
+
## Next Steps
|
|
136
|
+
[To be filled in by agent or human]
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
_Auto-created by compact.sh for failed episode_
|
|
140
|
+
EOF
|
|
141
|
+
|
|
142
|
+
echo -e "${GREEN}✓ Created reflection: $REFLECTION_FILE${NC}"
|
|
143
|
+
|
|
144
|
+
# Append to reflections _index.md
|
|
145
|
+
REFLECTIONS_INDEX="$AGENT_MIND_ROOT/history/reflections/_index.md"
|
|
146
|
+
if [[ ! -f "$REFLECTIONS_INDEX" ]]; then
|
|
147
|
+
echo "# Reflections Index" > "$REFLECTIONS_INDEX"
|
|
148
|
+
echo "" >> "$REFLECTIONS_INDEX"
|
|
149
|
+
fi
|
|
150
|
+
echo "- \`${TASK_SLUG}-reflection.md\` (from \`$YEAR_MONTH/$TASK_SLUG.md\`)" >> "$REFLECTIONS_INDEX"
|
|
151
|
+
echo -e "${GREEN}✓ Updated reflections index${NC}"
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
# Clear workspace if requested
|
|
155
|
+
if [[ "$CLEAR_WORKSPACE" == true ]]; then
|
|
156
|
+
WORKSPACE_DIR="$AGENT_MIND_ROOT/workspace"
|
|
157
|
+
if [[ -d "$WORKSPACE_DIR" ]]; then
|
|
158
|
+
# Find and remove files, but keep the directory structure
|
|
159
|
+
find "$WORKSPACE_DIR" -type f -exec rm -f {} +
|
|
160
|
+
echo -e "${GREEN}✓ Cleared workspace files${NC}"
|
|
161
|
+
fi
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
echo ""
|
|
165
|
+
echo -e "${GREEN}✓ Compaction complete${NC}"
|
|
166
|
+
echo " Episode: $EPISODE_FILE"
|
|
167
|
+
echo " Domain: $DOMAIN"
|
|
168
|
+
echo " Outcome: $OUTCOME"
|
|
169
|
+
if [[ "$CLEAR_WORKSPACE" == true ]]; then
|
|
170
|
+
echo " Workspace: cleared"
|
|
171
|
+
fi
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# Agent Mind Tools — Guide
|
|
2
|
+
|
|
3
|
+
These scripts are **optional utilities** for handling mechanical memory operations. You can do everything manually by editing files directly, or use these scripts to speed up common operations.
|
|
4
|
+
|
|
5
|
+
**When to use them:** After following `protocols/compaction.md` and `protocols/maintenance.md`, when you need quick file operations.
|
|
6
|
+
|
|
7
|
+
**Important:** These tools are helpers, not replacements for the thinking protocols. Always follow the protocol logic first, then use tools to execute the mechanical parts.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Tool: `am-compact`
|
|
12
|
+
|
|
13
|
+
**Purpose:** Create an episode summary file after a completed task.
|
|
14
|
+
|
|
15
|
+
**When:** After Phase 5 of `protocols/workflow.md`, to create the episode file structure.
|
|
16
|
+
|
|
17
|
+
**Usage:**
|
|
18
|
+
```bash
|
|
19
|
+
./am-compact [task-slug] [domain] [outcome] [summary]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Parameters:**
|
|
23
|
+
- `task-slug` — kebab-case identifier for the task (e.g., `auth-token-validation`)
|
|
24
|
+
- `domain` — domain name(s) touched, comma-separated (e.g., `auth,security`)
|
|
25
|
+
- `outcome` — one of: `completed`, `failed`, `abandoned`
|
|
26
|
+
- `summary` — one-line summary (quoted if spaces)
|
|
27
|
+
|
|
28
|
+
**Example:**
|
|
29
|
+
```bash
|
|
30
|
+
./am-compact "auth-token-validation" "auth,security" completed "Implemented JWT expiry validation with clock skew buffer"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**What it does:**
|
|
34
|
+
1. Creates `history/episodes/YYYY-MM/[task-slug].md` with template structure
|
|
35
|
+
2. Appends a line to `history/episodes/_index.md`
|
|
36
|
+
3. Opens the episode file for you to fill in details (key insight, assumptions made, etc.)
|
|
37
|
+
|
|
38
|
+
**Manual alternative:** Create the file directly in `history/episodes/YYYY-MM/[task-slug].md` following the format in `protocols/compaction.md`.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Tool: `am-reflect`
|
|
43
|
+
|
|
44
|
+
**Purpose:** Create a reflection file for a failed task.
|
|
45
|
+
|
|
46
|
+
**When:** After a task fails and you're following Path B of `protocols/compaction.md`.
|
|
47
|
+
|
|
48
|
+
**Usage:**
|
|
49
|
+
```bash
|
|
50
|
+
./am-reflect [task-slug] [domain] [what-went-wrong]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Parameters:**
|
|
54
|
+
- `task-slug` — same identifier used in the episode
|
|
55
|
+
- `domain` — domain where failure occurred
|
|
56
|
+
- `what-went-wrong` — one-line summary of the failure
|
|
57
|
+
|
|
58
|
+
**Example:**
|
|
59
|
+
```bash
|
|
60
|
+
./am-reflect "auth-token-validation" "auth" "Clock skew buffer off by 1ms, caused false rejections in high-latency environments"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**What it does:**
|
|
64
|
+
1. Creates `history/reflections/YYYY-MM-DD-[slug].md` with reflection structure
|
|
65
|
+
2. Appends entry to `history/reflections/_index.md`
|
|
66
|
+
3. Opens the file for you to fill in root cause analysis and detection conditions
|
|
67
|
+
|
|
68
|
+
**Manual alternative:** Create the file directly following the format in `protocols/compaction.md`.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Tool: `am-insight`
|
|
73
|
+
|
|
74
|
+
**Purpose:** Manage cross-domain insights in `knowledge/insights.md`.
|
|
75
|
+
|
|
76
|
+
**When:** During Phase 3 of compaction when you've identified a generalizable learning.
|
|
77
|
+
|
|
78
|
+
**Usage:**
|
|
79
|
+
```bash
|
|
80
|
+
./am-insight add [title] [insight] [domains]
|
|
81
|
+
./am-insight upvote [insight-number]
|
|
82
|
+
./am-insight downvote [insight-number]
|
|
83
|
+
./am-insight remove [insight-number]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Examples:**
|
|
87
|
+
```bash
|
|
88
|
+
./am-insight add "JWT Validation" "Always validate JWT expiry with a clock skew buffer of 30-60 seconds" "auth,security"
|
|
89
|
+
./am-insight upvote 3
|
|
90
|
+
./am-insight downvote 5
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**What it does:**
|
|
94
|
+
- `add`: Creates a new insight entry with `votes: 1`
|
|
95
|
+
- `upvote`: Increments the vote count for an insight (confirms it)
|
|
96
|
+
- `downvote`: Decrements the vote count (contradicts it)
|
|
97
|
+
- `remove`: Deletes an insight with votes < -2
|
|
98
|
+
|
|
99
|
+
**Format it uses:**
|
|
100
|
+
```markdown
|
|
101
|
+
### [Title]
|
|
102
|
+
- **Insight:** [the learning]
|
|
103
|
+
- **Domains:** [domains]
|
|
104
|
+
- **Votes:** [number]
|
|
105
|
+
- **Added:** YYYY-MM-DD | **Last touched:** YYYY-MM-DD
|
|
106
|
+
- **Evidence:** [tasks confirming/contradicting]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Manual alternative:** Edit `knowledge/insights.md` directly.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Tool: `am-pattern`
|
|
114
|
+
|
|
115
|
+
**Purpose:** Add a pattern to a domain's patterns.md file.
|
|
116
|
+
|
|
117
|
+
**When:** During Phase 3 of compaction, when you've identified a reusable approach.
|
|
118
|
+
|
|
119
|
+
**Usage:**
|
|
120
|
+
```bash
|
|
121
|
+
./am-pattern [domain] [pattern-name] [when] [what] [why]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Parameters:**
|
|
125
|
+
- `domain` — target domain (will create if doesn't exist)
|
|
126
|
+
- `pattern-name` — short name for the pattern
|
|
127
|
+
- `when` — conditions when this pattern applies
|
|
128
|
+
- `what` — the approach/technique
|
|
129
|
+
- `why` — reasoning
|
|
130
|
+
|
|
131
|
+
**Example:**
|
|
132
|
+
```bash
|
|
133
|
+
./am-pattern "auth" "jwt-clock-skew" \
|
|
134
|
+
"Validating JWT expiry in distributed systems" \
|
|
135
|
+
"Add 30-60s clock skew buffer to expiry check" \
|
|
136
|
+
"Handles clock drift between services without rejecting valid tokens"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**What it does:**
|
|
140
|
+
1. Opens or creates `knowledge/domains/[domain]/patterns.md`
|
|
141
|
+
2. Appends the pattern with today's date and originating task slug
|
|
142
|
+
3. Keeps the file under 200 lines (suggests archiving old patterns if needed)
|
|
143
|
+
|
|
144
|
+
**Manual alternative:** Edit `knowledge/domains/[domain]/patterns.md` directly.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Tool: `am-failure`
|
|
149
|
+
|
|
150
|
+
**Purpose:** Log a failure pattern to a domain's failure library.
|
|
151
|
+
|
|
152
|
+
**When:** During Path B of compaction, after analyzing what went wrong.
|
|
153
|
+
|
|
154
|
+
**Usage:**
|
|
155
|
+
```bash
|
|
156
|
+
./am-failure [domain] [slug] [trigger-condition] [summary]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Parameters:**
|
|
160
|
+
- `domain` — affected domain
|
|
161
|
+
- `slug` — short slug for this failure
|
|
162
|
+
- `trigger-condition` — what conditions trigger this failure
|
|
163
|
+
- `summary` — one-line summary of the failure
|
|
164
|
+
|
|
165
|
+
**Example:**
|
|
166
|
+
```bash
|
|
167
|
+
./am-failure "auth" "jwt-clock-skew-too-small" \
|
|
168
|
+
"JWT expiry validation with clock skew < 30 seconds in high-latency networks" \
|
|
169
|
+
"False token rejections due to insufficient clock skew buffer"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**What it does:**
|
|
173
|
+
1. Appends entry to `knowledge/domains/[domain]/failures/_index.md`
|
|
174
|
+
2. Creates `knowledge/domains/[domain]/failures/[slug].md` with detail template
|
|
175
|
+
3. Opens the detail file for you to add conditions and prevention steps
|
|
176
|
+
|
|
177
|
+
**Index format:**
|
|
178
|
+
```
|
|
179
|
+
YYYY-MM-DD | slug | trigger condition | one-line summary
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Manual alternative:** Edit the failure index and create detail files manually.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Tool: `am-health`
|
|
187
|
+
|
|
188
|
+
**Purpose:** Quick memory health check (size audit only).
|
|
189
|
+
|
|
190
|
+
**When:** Quick sanity check between full maintenance runs, or before a big task.
|
|
191
|
+
|
|
192
|
+
**Usage:**
|
|
193
|
+
```bash
|
|
194
|
+
./am-health
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**What it does:**
|
|
198
|
+
1. Scans all core memory files against size limits (from `protocols/memory-ops.md`)
|
|
199
|
+
2. Reports any files over limits with line counts
|
|
200
|
+
3. Lists files last modified more than 30 days ago
|
|
201
|
+
4. Shows episode/reflection/insight counts
|
|
202
|
+
|
|
203
|
+
**Output example:**
|
|
204
|
+
```
|
|
205
|
+
Memory Health Check — 2026-03-22
|
|
206
|
+
|
|
207
|
+
Size Audit:
|
|
208
|
+
BOOT.md: 120 / 150 lines — OK
|
|
209
|
+
protocols/workflow.md: 82 / 200 lines — OK
|
|
210
|
+
knowledge/insights.md: 5 entries / 100 max — OK
|
|
211
|
+
|
|
212
|
+
Stale Files (30+ days):
|
|
213
|
+
None
|
|
214
|
+
|
|
215
|
+
Summary:
|
|
216
|
+
Episodes: 12 total
|
|
217
|
+
Reflections: 2 total
|
|
218
|
+
Insights: 5 total
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Manual alternative:** Run `wc -l` on files and check timestamps manually.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Tool: `am-maintain`
|
|
226
|
+
|
|
227
|
+
**Purpose:** Run the full maintenance protocol and generate a report.
|
|
228
|
+
|
|
229
|
+
**When:** After the human requests a health check, or every 2 weeks.
|
|
230
|
+
|
|
231
|
+
**Usage:**
|
|
232
|
+
```bash
|
|
233
|
+
./am-maintain
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**What it does:**
|
|
237
|
+
1. Runs all steps from `protocols/maintenance.md`:
|
|
238
|
+
- Size check (all files vs limits)
|
|
239
|
+
- Stale memory check (zero-vote insights, unverified entries, unused patterns)
|
|
240
|
+
- Contradiction check (failed tasks vs loaded patterns, negative votes, conflicts)
|
|
241
|
+
- Growth review (episodes, knowledge, insights movement)
|
|
242
|
+
2. Generates report (see template in maintenance.md)
|
|
243
|
+
3. Saves report to `history/maintenance-reports/YYYY-MM-DD.md`
|
|
244
|
+
4. Outputs recommendations (but does NOT execute changes)
|
|
245
|
+
|
|
246
|
+
**Your job:** Review the report, decide which recommendations to act on, tell the agent which ones to execute.
|
|
247
|
+
|
|
248
|
+
**Manual alternative:** Follow `protocols/maintenance.md` manually and create the report yourself.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Important Notes
|
|
253
|
+
|
|
254
|
+
1. **These tools are optional.** Every operation can be done manually by editing files. Use them if they speed you up.
|
|
255
|
+
|
|
256
|
+
2. **Tools follow protocols.** They automate the mechanics of the protocols, not the thinking. You still need to understand what you're capturing and why.
|
|
257
|
+
|
|
258
|
+
3. **They create well-formed files.** All tools create markdown with consistent formatting, making it easier for agents to parse and maintain.
|
|
259
|
+
|
|
260
|
+
4. **No destructive operations.** Tools never delete files from `history/` or `knowledge/` — they append only. Maintenance (which proposes deletions) is manual review + human decision.
|
|
261
|
+
|
|
262
|
+
5. **Look at the generated files.** After running a tool, open the created file and verify it's what you expected. These are learning records — get them right.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Troubleshooting
|
|
267
|
+
|
|
268
|
+
**Tool not found:** Make sure `.agent-mind/.am-tools/` is in your PATH, or call with `./am-tools/[tool-name]`.
|
|
269
|
+
|
|
270
|
+
**File already exists:** Tools append to existing files rather than overwriting. This prevents data loss.
|
|
271
|
+
|
|
272
|
+
**Large files:** If a tool warns that a file is over limit, follow the maintenance protocol to archive old entries.
|
|
273
|
+
|
|
274
|
+
**Custom tools:** You can create your own tools in `.agent-mind/.am-tools/`. Keep them as bash scripts following the same conventions.
|