**CF-282: Session Reference in Tasks**
- Add session_id column to tasks table (migration 019)
- Store session_id when creating tasks in taskAdd()
- Display session_id in taskShow() output
- Create index for performance
- Backfill existing tasks from task_activity
**CF-278: Enhanced Session Context**
- Updated session-start to load memories (via DB query)
- Performance: 2-3.6s (target <5s) ✓
Changes:
- migrations/019_add_session_id_to_tasks.sql: New migration
- src/tools/crud.ts: taskAdd and taskShow modifications
Requires: Claude Code restart to load new code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Creates deployments and deployment_logs tables for tracking all
deployment types (Docker, MCP, iOS/macOS, services). Includes
deployment status, timing, git integration, and structured logging.
Also adds run-migration.mjs helper for running migrations against
PostgreSQL database.
Part of CF-290, completes CF-291.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When LiteLLM embedding service is unavailable, archive_search now gracefully falls back to PostgreSQL text search (ILIKE) instead of returning an error. Also adds dotenv support for proper credential loading.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Phase 7 complete: Advanced session analysis capabilities
New MCP Tools (3):
1. session_semantic_search - Vector similarity search across all sessions
2. session_productivity_analytics - Metrics (avg duration, tasks, commits, tokens)
3. session_pattern_detection - Detect patterns (tool usage, task types)
Features:
- Semantic search with embedding-based similarity
- Fallback to ILIKE text search if embeddings unavailable
- Analytics over configurable time periods (week/month/quarter)
- Pattern detection with frequency analysis
Use Cases:
- Find similar past work: "sessions about WhatsApp integration"
- Track productivity: avg commits/tasks per session
- Identify tool usage patterns: which tools used most often
- Analyze task type distribution
All 7 phases complete! System ready for testing.
Related: CF-257
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Switch from external Gemini API (3072 dims, $0.15/1M tokens) to local
Ollama mxbai-embed-large (1024 dims, free) for cost savings and HNSW
index support.
Changes:
- Updated embeddings.ts: model 'mxbai-embed-large', API URL fixed
- Updated migration 015: vector(1024) with HNSW index
- Regenerated 268 tool_docs embeddings with new model
Benefits:
- Free embeddings (no API costs)
- HNSW index enabled (1024 < 2000 dim limit)
- Fast similarity search (O(log n) vs O(n))
- No external API dependency
Trade-offs:
- 5% quality loss (MTEB 64.68 vs ~70 Gemini)
- Uses local compute (1.2GB RAM, <1s per embedding)
Task: CF-251
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Added session existence check before INSERT
- Graceful degradation: sets session_id to null if invalid
- Prevents FK constraint violation
- Memory still stored without session link
- Updated db.ts to use infra.agiliton.internal with env var fallback
- Updated run.js to use infra.agiliton.internal for DB_HOST
- Rebuilt dist files with new configuration
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Enhancements:
1. Session Context Table
- Migration 014: session_context table
- Tracks current working task per session
- Auto-updated on task status changes
2. Auto-Linking to Current Working Task
- When task status → in_progress: sets as current_task_id
- When task status → completed: clears current_task_id
- New tasks auto-link to current working task with 'relates_to'
- Shows auto-link message during task creation
3. Session ID Resolution
- Fixed path: ~/.cache/session-memory/current_session
- Falls back to environment variable CLAUDE_SESSION_ID
- Generates timestamp-based ID if unavailable
Example Flow:
```
1. task update CF-123 --status in_progress
→ Sets CF-123 as current working task
2. task add --title "Related work"
→ Created: CF-124
🔗 Auto-linked to: CF-123 (current working task)
3. task update CF-123 --status completed
→ Clears current working task
```
Files Changed:
- migrations/014_session_context.sql (new, 33 lines)
- src/tools/crud.ts (auto-linking logic, session context management)
Benefits:
- Zero manual linking for related work
- Session context preserved automatically
- Investigation workflows auto-organized
- Retroactive work tracking prevented
Note: Requires MCP server restart to take effect.
Remaining CF-166 Features (Phase 3):
- task investigate command
- Investigation workflow helper
- Task creation reminders
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implemented 8 new session management tools:
- session_start: Initialize session with metadata tracking
- session_update: Update session metrics during execution
- session_end: Close session with summary and embedding
- session_list: List sessions with filtering
- session_search: Semantic search across sessions
- session_context: Get complete session context (tasks, commits, builds, memories)
- build_record: Link builds to sessions and versions
- session_commit_link: Link commits to sessions
Enhanced existing tools:
- memory_add: Added session_id and task_id parameters
- Updated all memory queries to use 'memories' table (renamed from session_memories)
Implementation:
- Created src/tools/sessions.ts with all session operations
- Updated src/tools/memories.ts for new schema
- Added 8 session tool definitions to src/tools/index.ts
- Registered all session tools in src/index.ts switch statement
- TypeScript compilation successful
Related: CF-167 (Fix shared session-summary.md file conflict)
- db.ts: Hardcode 10.0.1.1 (infra VM) to prevent env var issues
- index.ts: Start MCP server before DB connection (fixes Claude Code timing)
- run.sh/run.js: Add wrapper scripts with embedded env vars
- start.sh: Update with correct WireGuard config
Fixes task-mcp failing to connect in Claude Code sessions after
WireGuard migration. The server must respond to MCP initialize
before stdin closes, which requires starting before slow DB ops.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously these functions only filtered by project when explicitly
passed. Now they auto-detect from CWD using detectProjectFromCwd(),
matching the behavior of project_context.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PostgreSQL does not support multiple recursive references in the same CTE.
Changed to use simpler subqueries for direct dependencies + dependents.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
epic_close was failing with "column updated_at does not exist".
Migration adds the column with default NOW() and backfills
existing rows from created_at.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New features:
- detectProjectFromCwd(): Maps directory paths to project keys
- project_context: Returns project, tasks, epics, lock status
- Auto-detection for 18 known projects (ST, VPN, OWUI, etc.)
- Falls back to extracting from Apps/X or Infrastructure/X paths
Use project_context at session start to see only relevant tasks.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New MCP tools:
- project_lock: Lock a project for exclusive session access
- project_unlock: Release a project lock
- project_lock_status: Check lock status for project(s)
Features:
- Automatic lock expiration (default 2h)
- Session ownership verification
- Force unlock option for emergencies
- Lock extension on re-lock by same session
Migration 004: project_locks table with expiry tracking
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Migration 003: enables semantic search for epics
- ALTER TABLE epics ADD COLUMN embedding vector(1024)
- HNSW index for similarity search
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Changed default database from litellm to agiliton
- Updated credentials for docker-host postgres
- Requires pgvector/pgvector:pg16 image on docker-host
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Creates core tables for task-mcp:
- projects, task_sequences, epic_sequences
- tasks with vector(1024) embedding for semantic search
- epics, versions, task_checklist, task_links
- HNSW index for fast vector similarity search
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- New epic_close(id) function to mark epics as completed
- Added tool definition and handler
- Usage: epic_close({ id: 'CF-E1' })
Task: CF-258
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Session 374: Task-MCP and Delegation System Integration (Phase 4 & 6)
- Add task_delegations tool: query delegations for a specific task
- Add task_delegation_query tool: query across all tasks by status/backend
- Enhance taskShow() to display recent delegation history
- New delegations.ts module with getRecentDelegations helper
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- task_delegations table for tracking delegation metadata per task
- task_learning_effectiveness table for per-task learning tracking
- Indexes for efficient querying by task_id, status, backend
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Combines close + link operations for duplicate issues:
- Closes the duplicate task (sets status to completed)
- Creates bidirectional 'duplicates' link to dominant task
Usage: task_resolve_duplicate(duplicate_id, dominant_id)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- relates_to and duplicates now create reverse links automatically
- task_show displays Related and Duplicates sections
- blocks remains unidirectional (A blocks B, B is blocked by A)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>