Files
Profa 2253d05618 feat: flatten project structure — archive v2, promote v3 to root
Remove the nested v3/ subdirectory by moving all active source code,
tests, configs, and assets directly to the project root. Archive v2/
(dead code, 847MB) to v2-archive.tar.gz.

Key changes:
- Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/
- Move v3/tsconfig.json, v3/vitest.config.ts to root
- Merge v3/package.json into root package.json (ESM, scripts, deps, exports)
- Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/
- Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes
- Fix all init installer path resolution (3-level-up → 2-level-up)
- Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe"
- Update settings.json ADR/DDD directories to docs/implementation/
- Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks)
- Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces
- Update 15 guidance shards: v3/src/ → src/ path references
- Fix sync interfaces: remove v3/ and v2/ path references
- Fix test path calculations (process.cwd() + '..' no longer needed)
- Fix flaky perf test threshold (500ms → 1000ms for CI environments)
- Fix complexity-analyzer test to match ADR-051 keyword-based eligibility

Build passes, 17,901 tests pass, CLI and MCP bundles verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 11:35:41 +00:00

114 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
#
# Post-Task Sync Hook
# Syncs Claude Flow memories to AQE V3 database after task completion
#
# This ensures all learning captured by Claude Code tasks
# is persisted to AQE's database for cross-session learning.
#
# Install in settings.json:
# "hooks": {
# "post-task": {
# "command": "bash .claude/hooks/post-task-sync.sh"
# }
# }
# Configuration
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
CLAUDE_FLOW_STORE="$PROJECT_ROOT/.claude-flow/memory/store.json"
AQE_V3_DB="$PROJECT_ROOT/.agentic-qe/memory.db"
SYNC_LOG="$PROJECT_ROOT/.agentic-qe/sync.log"
# Create log directory if needed
mkdir -p "$(dirname "$SYNC_LOG")"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$SYNC_LOG"
}
# Check if files exist
if [[ ! -f "$CLAUDE_FLOW_STORE" ]]; then
log "SKIP: Claude Flow store not found"
exit 0
fi
if [[ ! -f "$AQE_V3_DB" ]]; then
log "SKIP: AQE V3 database not found"
exit 0
fi
# Get entry counts before sync
CF_ENTRIES=$(cat "$CLAUDE_FLOW_STORE" 2>/dev/null | jq '.entries | length // (keys | length)' 2>/dev/null || echo "0")
AQE_CF_ENTRIES=$(sqlite3 "$AQE_V3_DB" "SELECT COUNT(*) FROM kv_store WHERE key LIKE 'cf:%'" 2>/dev/null || echo "0")
# Skip if already in sync
if [[ "$CF_ENTRIES" == "$AQE_CF_ENTRIES" ]]; then
log "SKIP: Already in sync ($CF_ENTRIES entries)"
exit 0
fi
log "SYNC: Claude Flow has $CF_ENTRIES entries, AQE has $AQE_CF_ENTRIES synced"
# Run sync via Node.js if available
if command -v node &> /dev/null; then
# Try TypeScript sync first
if [[ -f "$PROJECT_ROOT/dist/sync/claude-flow-bridge.js" ]]; then
node -e "
const { syncClaudeFlowToAQE } = require('$PROJECT_ROOT/dist/sync/claude-flow-bridge.js');
syncClaudeFlowToAQE({ projectRoot: '$PROJECT_ROOT' })
.then(r => console.log('Synced:', r.entriesSynced))
.catch(e => console.error('Sync error:', e.message));
" 2>> "$SYNC_LOG"
log "DONE: Node.js sync completed"
exit 0
fi
fi
# Fallback: Direct SQLite sync
log "FALLBACK: Using SQLite direct sync"
# Read Claude Flow entries and insert into AQE
node << 'EOFNODE'
const fs = require('fs');
const path = require('path');
const projectRoot = process.env.PROJECT_ROOT || process.cwd();
const claudeFlowPath = path.join(projectRoot, '.claude-flow', 'memory', 'store.json');
const aqeDbPath = path.join(projectRoot, '.agentic-qe', 'memory.db');
try {
const store = JSON.parse(fs.readFileSync(claudeFlowPath, 'utf-8'));
const entries = store.entries || store;
const Database = require('better-sqlite3');
const db = new Database(aqeDbPath);
db.pragma('busy_timeout = 5000');
db.pragma('journal_mode = WAL');
const insert = db.prepare(`
INSERT OR REPLACE INTO kv_store (key, namespace, value, created_at)
VALUES (?, ?, ?, ?)
`);
let count = 0;
for (const [key, value] of Object.entries(entries)) {
if (key.startsWith('_') || key === 'version') continue;
insert.run(
'cf:' + key,
'claude-flow',
JSON.stringify(value),
Date.now()
);
count++;
}
db.close();
console.log('Synced', count, 'entries');
} catch (e) {
console.error('Sync failed:', e.message);
process.exit(1);
}
EOFNODE
log "DONE: Fallback sync completed"