caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

80 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Smart auto-compaction with thresholds
# Only compacts if there are enough eligible issues
#
# Usage: ./auto-compact.sh [--threshold N] [--tier 1|2]
# Default configuration
THRESHOLD=10 # Minimum eligible issues to trigger compaction
TIER=1
DRY_RUN=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--threshold)
THRESHOLD="$2"
shift 2
;;
--tier)
TIER="$2"
shift 2
;;
--dry-run)
DRY_RUN=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--threshold N] [--tier 1|2] [--dry-run]"
exit 1
;;
esac
done
# Check API key
if [ -z "$ANTHROPIC_API_KEY" ]; then
echo "❌ Error: ANTHROPIC_API_KEY not set"
exit 1
fi
# Check bd is installed
if ! command -v bd &> /dev/null; then
echo "❌ Error: bd command not found"
exit 1
fi
# Check eligible issues
echo "Checking eligible issues (Tier $TIER)..."
ELIGIBLE=$(bd admin compact --dry-run --all --tier "$TIER" --json 2>/dev/null | jq '. | length' || echo "0")
if [ -z "$ELIGIBLE" ] || [ "$ELIGIBLE" = "null" ]; then
ELIGIBLE=0
fi
echo "Found $ELIGIBLE eligible issues (threshold: $THRESHOLD)"
if [ "$ELIGIBLE" -lt "$THRESHOLD" ]; then
echo "⏭️ Below threshold, skipping compaction"
exit 0
fi
if [ "$DRY_RUN" = true ]; then
echo "🔍 Dry run mode - showing candidates:"
bd admin compact --dry-run --all --tier "$TIER"
exit 0
fi
# Run compaction
echo "🗜️ Compacting $ELIGIBLE issues (Tier $TIER)..."
bd admin compact --all --tier "$TIER"
# Show stats
echo
echo "📊 Statistics:"
bd admin compact --stats
echo
echo "✅ Auto-compaction complete"
echo "Remember to commit: git add .beads/issues.jsonl issues.db && git commit -m 'Auto-compact'"