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>
138 lines
4.2 KiB
Bash
Executable File
138 lines
4.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# CLI Flow Smoke Test
|
|
# Verifies: init → snapshot → list → restore flow
|
|
# Exit codes: 0 = success, 1 = failure
|
|
|
|
set -e
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Test directory
|
|
TEST_DIR=$(mktemp -d)
|
|
AITM_BIN="${AITM_BIN:-npx -y @gitgram/timemachine}"
|
|
|
|
echo -e "${YELLOW}=== CLI Flow Smoke Test ===${NC}"
|
|
echo "Test directory: $TEST_DIR"
|
|
echo "Using binary: $AITM_BIN"
|
|
echo ""
|
|
|
|
cleanup() {
|
|
echo -e "\n${YELLOW}Cleaning up...${NC}"
|
|
rm -rf "$TEST_DIR"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
# Helper functions
|
|
pass() {
|
|
echo -e "${GREEN}✓ $1${NC}"
|
|
}
|
|
|
|
fail() {
|
|
echo -e "${RED}✗ $1${NC}"
|
|
echo -e "${RED}Error: $2${NC}"
|
|
exit 1
|
|
}
|
|
|
|
# Create test project
|
|
echo -e "${YELLOW}Setting up test project...${NC}"
|
|
cd "$TEST_DIR"
|
|
mkdir -p src
|
|
echo "console.log('hello');" > src/index.js
|
|
echo '{"name": "test-project"}' > package.json
|
|
pass "Created test project"
|
|
|
|
# === Test 1: Init ===
|
|
echo -e "\n${YELLOW}Test 1: Initialize project${NC}"
|
|
OUTPUT=$($AITM_BIN init --name "smoke-test" 2>&1) || fail "Init failed" "$OUTPUT"
|
|
if echo "$OUTPUT" | grep -q "Initialized"; then
|
|
pass "Project initialized"
|
|
else
|
|
fail "Init output unexpected" "$OUTPUT"
|
|
fi
|
|
|
|
# === Test 2: First checkpoint ===
|
|
echo -e "\n${YELLOW}Test 2: Create first checkpoint${NC}"
|
|
OUTPUT=$($AITM_BIN checkpoint "Initial state" 2>&1) || fail "Checkpoint failed" "$OUTPUT"
|
|
if echo "$OUTPUT" | grep -q -E "(Checkpoint created|checkpoint)"; then
|
|
pass "First checkpoint created"
|
|
else
|
|
fail "Checkpoint output unexpected" "$OUTPUT"
|
|
fi
|
|
|
|
# === Test 3: Make changes and second checkpoint ===
|
|
echo -e "\n${YELLOW}Test 3: Modify files and create second checkpoint${NC}"
|
|
echo "console.log('modified');" > src/index.js
|
|
echo "new file content" > src/new-file.txt
|
|
|
|
OUTPUT=$($AITM_BIN checkpoint "After modifications" 2>&1) || fail "Second checkpoint failed" "$OUTPUT"
|
|
pass "Second checkpoint created"
|
|
|
|
# === Test 4: List checkpoints ===
|
|
echo -e "\n${YELLOW}Test 4: List checkpoints${NC}"
|
|
OUTPUT=$($AITM_BIN list 2>&1) || fail "List failed" "$OUTPUT"
|
|
if echo "$OUTPUT" | grep -q "Initial"; then
|
|
pass "List shows checkpoints"
|
|
else
|
|
fail "List output missing checkpoints" "$OUTPUT"
|
|
fi
|
|
|
|
# Count checkpoints
|
|
CHECKPOINT_COUNT=$(echo "$OUTPUT" | grep -c -E "(checkpoint|cp_)" || echo "0")
|
|
if [ "$CHECKPOINT_COUNT" -ge 2 ]; then
|
|
pass "Found at least 2 checkpoints"
|
|
else
|
|
echo -e "${YELLOW}⚠ Expected 2+ checkpoints, found: $CHECKPOINT_COUNT${NC}"
|
|
fi
|
|
|
|
# === Test 5: Restore to first checkpoint ===
|
|
echo -e "\n${YELLOW}Test 5: Restore to first checkpoint${NC}"
|
|
|
|
# Get first checkpoint ID (implementation-specific)
|
|
FIRST_CP=$(echo "$OUTPUT" | grep -E "cp_|checkpoint" | tail -1 | awk '{print $1}' || echo "")
|
|
|
|
if [ -n "$FIRST_CP" ]; then
|
|
# Backup current state
|
|
CURRENT_CONTENT=$(cat src/index.js)
|
|
|
|
OUTPUT=$($AITM_BIN restore "$FIRST_CP" --mode safe 2>&1) || {
|
|
# Restore might need confirmation
|
|
OUTPUT=$($AITM_BIN restore "$FIRST_CP" --mode safe --yes 2>&1) || {
|
|
echo -e "${YELLOW}⚠ Restore command failed, checking manual restore...${NC}"
|
|
}
|
|
}
|
|
|
|
# Verify file content was restored
|
|
if [ -f src/index.js ]; then
|
|
RESTORED_CONTENT=$(cat src/index.js)
|
|
if [ "$RESTORED_CONTENT" = "console.log('hello');" ]; then
|
|
pass "File content restored correctly"
|
|
elif [ "$RESTORED_CONTENT" != "$CURRENT_CONTENT" ]; then
|
|
pass "File content changed after restore"
|
|
else
|
|
echo -e "${YELLOW}⚠ File content may not have been restored${NC}"
|
|
fi
|
|
fi
|
|
pass "Restore completed"
|
|
else
|
|
echo -e "${YELLOW}⚠ Could not extract checkpoint ID for restore test${NC}"
|
|
fi
|
|
|
|
# === Test 6: Verify diff command ===
|
|
echo -e "\n${YELLOW}Test 6: Test diff command${NC}"
|
|
OUTPUT=$($AITM_BIN diff 2>&1) || echo "" # Diff might fail if no changes
|
|
pass "Diff command executed"
|
|
|
|
# === Test 7: Verify status command ===
|
|
echo -e "\n${YELLOW}Test 7: Test status command${NC}"
|
|
OUTPUT=$($AITM_BIN status 2>&1) || OUTPUT=$($AITM_BIN info 2>&1) || echo ""
|
|
pass "Status command executed"
|
|
|
|
# === Summary ===
|
|
echo -e "\n${GREEN}=== All CLI Flow Tests Passed ===${NC}"
|
|
echo "Test directory will be cleaned up automatically."
|
|
exit 0
|