The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix: harden CI validators, shell scripts, and expand test suite
Affaan Mustafaf3a4b33d41ff
diff --git a/.cursor/skills/continuous-learning-v2/agents/start-observer.sh b/.cursor/skills/continuous-learning-v2/agents/start-observer.shindex 42a5f1b3f..6ba6f11f1 100755--- a/.cursor/skills/continuous-learning-v2/agents/start-observer.sh+++ b/.cursor/skills/continuous-learning-v2/agents/start-observer.sh@@ -88,10 +88,12 @@ case "${1:-start}" in# Use Claude Code with Haiku to analyze observations# This spawns a quick analysis sessionif command -v claude &> /dev/null; then- if ! claude --model haiku --max-turns 3 --print \+ exit_code=0+ claude --model haiku --max-turns 3 --print \"Read $OBSERVATIONS_FILE and identify patterns. If you find 3+ occurrences of the same pattern, create an instinct file in $CONFIG_DIR/instincts/personal/ following the format in the observer agent spec. Be conservative - only create instincts for clear patterns." \- >> "$LOG_FILE" 2>&1; then- echo "[$(date)] Claude analysis failed (exit $?)" >> "$LOG_FILE"+ >> "$LOG_FILE" 2>&1 || exit_code=$?+ if [ "$exit_code" -ne 0 ]; then+ echo "[$(date)] Claude analysis failed (exit $exit_code)" >> "$LOG_FILE"fielseecho "[$(date)] claude CLI not found, skipping analysis" >> "$LOG_FILE"diff --git a/.cursor/skills/continuous-learning-v2/hooks/observe.sh b/.cursor/skills/continuous-learning-v2/hooks/observe.shindex 3db1a2cf2..98b6b9d26 100755--- a/.cursor/skills/continuous-learning-v2/hooks/observe.sh+++ b/.cursor/skills/continuous-learning-v2/hooks/observe.sh@@ -103,10 +103,10 @@ PARSED_OK=$(echo "$PARSED" | python3 -c "import json,sys; print(json.load(sys.stif [ "$PARSED_OK" != "True" ]; then# Fallback: log raw input for debuggingtimestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")- echo "$INPUT_JSON" | python3 -c "-import json, sys+ TIMESTAMP="$timestamp" echo "$INPUT_JSON" | python3 -c "+import json, sys, osraw = sys.stdin.read()[:2000]-print(json.dumps({'timestamp': '$timestamp', 'event': 'parse_error', 'raw': raw}))+print(json.dumps({'timestamp': os.environ['TIMESTAMP'], 'event': 'parse_error', 'raw': raw}))" >> "$OBSERVATIONS_FILE"exit 0fi@@ -124,12 +124,12 @@ fi# Build and write observationtimestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")-echo "$PARSED" | python3 -c "-import json, sys+TIMESTAMP="$timestamp" echo "$PARSED" | python3 -c "+import json, sys, osparsed = json.load(sys.stdin)observation = {- 'timestamp': '$timestamp',+ 'timestamp': os.environ['TIMESTAMP'],'event': parsed['event'],'tool': parsed['tool'],'session': parsed['session']@@ -140,9 +140,8 @@ if parsed['input']:if parsed['output']:observation['output'] = parsed['output']-with open('$OBSERVATIONS_FILE', 'a') as f:- f.write(json.dumps(observation) + '\n')-"+print(json.dumps(observation))+" >> "$OBSERVATIONS_FILE"# Signal observer if runningOBSERVER_PID_FILE="${CONFIG_DIR}/.observer.pid"diff --git a/.cursor/skills/continuous-learning/evaluate-session.sh b/.cursor/skills/continuous-learning/evaluate-session.shindex f13208a18..b6c008f34 100755--- a/.cursor/skills/continuous-learning/evaluate-session.sh+++ b/.cursor/skills/continuous-learning/evaluate-session.sh@@ -32,8 +32,12 @@ MIN_SESSION_LENGTH=10# Load config if existsif [ -f "$CONFIG_FILE" ]; then- MIN_SESSION_LENGTH=$(jq -r '.min_session_length // 10' "$CONFIG_FILE")- LEARNED_SKILLS_PATH=$(jq -r '.learned_skills_path // "~/.claude/skills/learned/"' "$CONFIG_FILE" | sed "s|~|$HOME|")+ if ! command -v jq &>/dev/null; then+ echo "[ContinuousLearning] jq is required to parse config.json but not installed, using defaults" >&2+ else+ MIN_SESSION_LENGTH=$(jq -r '.min_session_length // 10' "$CONFIG_FILE")+ LEARNED_SKILLS_PATH=$(jq -r '.learned_skills_path // "~/.claude/skills/learned/"' "$CONFIG_FILE" | sed "s|~|$HOME|")+ fifi# Ensure learned skills directory existsdiff --git a/package.json b/package.jsonindex 5d40ee531..fb38548b2 100644--- a/package.json+++ b/package.json@@ -75,7 +75,7 @@"scripts": {"postinstall": "echo '\\n ecc-universal installed!\\n Run: npx ecc-install typescript\\n Docs: https://github.com/affaan-m/everything-claude-code\\n'","lint": "eslint . && markdownlint '**/*.md' --ignore node_modules",- "test": "node scripts/ci/validate-agents.js && node scripts/ci/validate-commands.js && node scripts/ci/validate-rules.js && node scripts/ci/validate-skills.js"+ "test": "node scripts/ci/validate-agents.js && node scripts/ci/validate-commands.js && node scripts/ci/validate-rules.js && node scripts/ci/validate-skills.js && node scripts/ci/validate-hooks.js && node tests/lib/utils.test.js && node tests/lib/package-manager.test.js && node tests/hooks/hooks.test.js && node tests/integration/hooks.test.js"},"devDependencies": {"@eslint/js": "^9.39.2",diff --git a/scripts/ci/validate-agents.js b/scripts/ci/validate-agents.jsindex 80d03dbca..12bf336cc 100644--- a/scripts/ci/validate-agents.js+++ b/scripts/ci/validate-agents.js@@ -40,7 +40,14 @@ function validateAgents() {for (const file of files) {const filePath = path.join(AGENTS_DIR, file);- const content = fs.readFileSync(filePath, 'utf-8');+ let content;+ try {+ content = fs.readFileSync(filePath, 'utf-8');+ } catch (err) {+ console.error(`ERROR: ${file} - ${err.message}`);+ hasErrors = true;+ continue;+ }const frontmatter = extractFrontmatter(content);if (!frontmatter) {diff --git a/scripts/ci/validate-commands.js b/scripts/ci/validate-commands.jsindex 640e4addf..3e15a43dd 100644--- a/scripts/ci/validate-commands.js+++ b/scripts/ci/validate-commands.js@@ -19,7 +19,14 @@ function validateCommands() {for (const file of files) {const filePath = path.join(COMMANDS_DIR, file);- const content = fs.readFileSync(filePath, 'utf-8');+ let content;+ try {+ content = fs.readFileSync(filePath, 'utf-8');+ } catch (err) {+ console.error(`ERROR: ${file} - ${err.message}`);+ hasErrors = true;+ continue;+ }// Validate the file is non-empty readable markdownif (content.trim().length === 0) {diff --git a/scripts/ci/validate-skills.js b/scripts/ci/validate-skills.jsindex 632bd3123..220a25f1c 100644--- a/scripts/ci/validate-skills.js+++ b/scripts/ci/validate-skills.js@@ -27,7 +27,14 @@ function validateSkills() {continue;}- const content = fs.readFileSync(skillMd, 'utf-8');+ let content;+ try {+ content = fs.readFileSync(skillMd, 'utf-8');+ } catch (err) {+ console.error(`ERROR: ${dir}/SKILL.md - ${err.message}`);+ hasErrors = true;+ continue;+ }if (content.trim().length === 0) {console.error(`ERROR: ${dir}/SKILL.md - Empty file`);hasErrors = true;diff --git a/scripts/release.sh b/scripts/release.shindex 9e6e349e5..cd7c16fcf 100755--- a/scripts/release.sh+++ b/scripts/release.sh@@ -47,15 +47,19 @@ fi# Read current versionOLD_VERSION=$(grep -oE '"version": *"[^"]*"' "$PLUGIN_JSON" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')+if [[ -z "$OLD_VERSION" ]]; then+ echo "Error: Could not extract current version from $PLUGIN_JSON"+ exit 1+fiecho "Bumping version: $OLD_VERSION -> $VERSION"-# Update version in plugin.json (cross-platform sed)+# Update version in plugin.json (cross-platform sed, pipe-delimiter avoids issues with slashes)if [[ "$OSTYPE" == "darwin"* ]]; then# macOS- sed -i '' "s/\"version\": *\"[^\"]*\"/\"version\": \"$VERSION\"/" "$PLUGIN_JSON"+ sed -i '' "s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" "$PLUGIN_JSON"else# Linux- sed -i "s/\"version\": *\"[^\"]*\"/\"version\": \"$VERSION\"/" "$PLUGIN_JSON"+ sed -i "s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" "$PLUGIN_JSON"fi# Stage, commit, tag, and pushdiff --git a/skills/continuous-learning-v2/agents/start-observer.sh b/skills/continuous-learning-v2/agents/start-observer.shindex 42a5f1b3f..6ba6f11f1 100755--- a/skills/continuous-learning-v2/agents/start-observer.sh+++ b/skills/continuous-learning-v2/agents/start-observer.sh@@ -88,10 +88,12 @@ case "${1:-start}" in# Use Claude Code with Haiku to analyze observations# This spawns a quick analysis sessionif command -v claude &> /dev/null; then- if ! claude --model haiku --max-turns 3 --print \+ exit_code=0+ claude --model haiku --max-turns 3 --print \"Read $OBSERVATIONS_FILE and identify patterns. If you find 3+ occurrences of the same pattern, create an instinct file in $CONFIG_DIR/instincts/personal/ following the format in the observer agent spec. Be conservative - only create instincts for clear patterns." \- >> "$LOG_FILE" 2>&1; then- echo "[$(date)] Claude analysis failed (exit $?)" >> "$LOG_FILE"+ >> "$LOG_FILE" 2>&1 || exit_code=$?+ if [ "$exit_code" -ne 0 ]; then+ echo "[$(date)] Claude analysis failed (exit $exit_code)" >> "$LOG_FILE"fielseecho "[$(date)] claude CLI not found, skipping analysis" >> "$LOG_FILE"diff --git a/skills/continuous-learning-v2/hooks/observe.sh b/skills/continuous-learning-v2/hooks/observe.shindex 3db1a2cf2..98b6b9d26 100755--- a/skills/continuous-learning-v2/hooks/observe.sh+++ b/skills/continuous-learning-v2/hooks/observe.sh@@ -103,10 +103,10 @@ PARSED_OK=$(echo "$PARSED" | python3 -c "import json,sys; print(json.load(sys.stif [ "$PARSED_OK" != "True" ]; then# Fallback: log raw input for debuggingtimestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")- echo "$INPUT_JSON" | python3 -c "-import json, sys+ TIMESTAMP="$timestamp" echo "$INPUT_JSON" | python3 -c "+import json, sys, osraw = sys.stdin.read()[:2000]-print(json.dumps({'timestamp': '$timestamp', 'event': 'parse_error', 'raw': raw}))+print(json.dumps({'timestamp': os.environ['TIMESTAMP'], 'event': 'parse_error', 'raw': raw}))" >> "$OBSERVATIONS_FILE"exit 0fi@@ -124,12 +124,12 @@ fi# Build and write observationtimestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")-echo "$PARSED" | python3 -c "-import json, sys+TIMESTAMP="$timestamp" echo "$PARSED" | python3 -c "+import json, sys, osparsed = json.load(sys.stdin)observation = {- 'timestamp': '$timestamp',+ 'timestamp': os.environ['TIMESTAMP'],'event': parsed['event'],'tool': parsed['tool'],'session': parsed['session']@@ -140,9 +140,8 @@ if parsed['input']:if parsed['output']:observation['output'] = parsed['output']-with open('$OBSERVATIONS_FILE', 'a') as f:- f.write(json.dumps(observation) + '\n')-"+print(json.dumps(observation))+" >> "$OBSERVATIONS_FILE"# Signal observer if runningOBSERVER_PID_FILE="${CONFIG_DIR}/.observer.pid"diff --git a/skills/continuous-learning/evaluate-session.sh b/skills/continuous-learning/evaluate-session.shindex f13208a18..b6c008f34 100755--- a/skills/continuous-learning/evaluate-session.sh+++ b/skills/continuous-learning/evaluate-session.sh@@ -32,8 +32,12 @@ MIN_SESSION_LENGTH=10# Load config if existsif [ -f "$CONFIG_FILE" ]; then- MIN_SESSION_LENGTH=$(jq -r '.min_session_length // 10' "$CONFIG_FILE")- LEARNED_SKILLS_PATH=$(jq -r '.learned_skills_path // "~/.claude/skills/learned/"' "$CONFIG_FILE" | sed "s|~|$HOME|")+ if ! command -v jq &>/dev/null; then+ echo "[ContinuousLearning] jq is required to parse config.json but not installed, using defaults" >&2+ else+ MIN_SESSION_LENGTH=$(jq -r '.min_session_length // 10' "$CONFIG_FILE")+ LEARNED_SKILLS_PATH=$(jq -r '.learned_skills_path // "~/.claude/skills/learned/"' "$CONFIG_FILE" | sed "s|~|$HOME|")+ fifi# Ensure learned skills directory exists