Commit Graph

75 Commits

Author SHA1 Message Date
Christian Gick
cc88b234ae Add infrastructure changelog system to task-mcp
Implements session-aware infrastructure change tracking for CF-179.

Changes:
- New changelog.ts with 3 MCP tools:
  - changelog_add: Add infrastructure changes
  - changelog_since_session: Query changes since last session
  - changelog_list: Time-based fallback query
- Integrated with session-start command via MCP
- Database-first architecture (PostgreSQL on infra VM)
- Session-relative queries (not fixed time windows)

Database schema:
- infrastructure_changelog table (6 fields)
- Migrated 5 historical changes
- Indexes on date, session_id, created_at

Task: CF-179

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-17 12:13:24 +02:00
Christian Gick
8db391f680 Replace hardcoded IPs with DNS hostnames
- 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>
2026-01-17 09:11:37 +02:00
Christian Gick
90bb7e94f0 Add session-aware task context and auto-linking (CF-166 Phase 2)
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>
2026-01-17 08:44:19 +02:00
Christian Gick
f7f9cfe3d8 Add investigation type and duplicate detection (CF-166 Phase 1)
Enhancements:

1. Investigation Task Type
   - Added 'investigation' to task type enum
   - Migration 013: Updated PostgreSQL constraint
   - Updated TypeScript schemas (task_add, task_list, task_update)
   - Enables tracking research/debugging workflows

2. Duplicate Detection
   - Enhanced task_add to check for similar tasks before creating
   - Uses pgvector semantic search (>70% similarity threshold)
   - Warns about potential duplicates with similarity scores
   - Suggests linking command for related tasks
   - Gracefully handles when embeddings unavailable

Example Output:
```
Created: CF-123
  Title: Fix API rate limiting
  Type: task
  Priority: P2
  Project: CF

⚠️  Similar tasks found:
  - CF-120: Add rate limit monitoring (85% match, in_progress)
  - CF-115: Implement API throttling (72% match, open)

Consider linking with: task link <from> <to> relates_to
```

Benefits:
- Prevents accidental duplicate tasks
- Surfaces related work automatically
- Reduces manual task linking
- Investigation type for research workflows

Files Changed:
- migrations/013_investigation_type.sql (new)
- src/tools/crud.ts (duplicate detection logic)
- src/tools/index.ts (investigation type in enums)

Remaining CF-166 Features (Phase 2):
- Session-aware task context
- Automatic linking within session
- Investigation workflow helper
- Task creation reminders

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-17 08:38:18 +02:00
Christian Gick
04395e8403 Add session management MCP tools (Phase 3)
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)
2026-01-17 07:45:14 +02:00
Christian Gick
00de7f1299 Add database migrations for session context system
Phase 1: Database Schema Implementation
- Migration 010: Sessions table with bulletproof auto-incrementing
  - Unique session IDs across all projects
  - Per-project session numbers (1, 2, 3, ...)
  - Atomic sequence generation (no race conditions)
  - Session-task and session-commit linking
  - Semantic search with pgvector HNSW indexes

- Migration 011: Memories table with enhanced schema
  - Migrated existing session_memories to memories
  - Added session_id and task_id foreign keys
  - Renamed columns for consistency
  - HNSW indexing for semantic search

- Migration 012: Builds table for CI/CD tracking
  - Links builds to sessions and versions
  - Tracks build status, timing, and metadata

All migrations tested and verified on agiliton database.

Related: CF-167 (Fix shared session-summary.md file conflict)
2026-01-17 07:41:03 +02:00
Christian Gick
6c8862dcc0 fix: Hardcode DB config and start server before DB connection
- 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>
2026-01-13 14:11:58 +02:00
Christian Gick
afe2f8bc0b feat: Add session memory system with pgvector
- Add session_memories table for persistent learnings
- Add memory_add, memory_search, memory_list, memory_context tools
- Supports semantic search via embeddings
- Categories: pattern, fix, preference, gotcha, architecture

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 08:34:45 +02:00
Christian Gick
d474c1c368 fix: Auto-detect project from CWD in task_list and epic_list
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>
2026-01-12 08:12:49 +02:00
Christian Gick
149ebdb95f fix: Simplify component_graph query to avoid recursive CTE error
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>
2026-01-11 07:27:10 +02:00
Christian Gick
4fb557c624 feat: Add impact analysis for component dependency tracking
- New tables: components, component_dependencies, component_files,
  verification_checks, change_impacts, impact_analysis_runs
- 8 new MCP tools: component_register, component_list,
  component_add_dependency, component_add_file, component_add_check,
  impact_analysis, impact_learn, component_graph
- Seed data: 17 components, 9 dependencies, 12 file patterns, 5 checks
- Historical impacts from session 397 issues recorded

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:20:00 +02:00
Christian Gick
5015b1416f feat: Add version management, session tracking, and commit linking
Phase 1: Version Management
- Migration 006: Add git_tag, git_sha columns to versions
- New tools: version_add, version_list, version_show, version_update,
  version_release, version_assign_task
- Links versions to git tags for release tracking

Phase 2: Session/Task Activity Tracking
- Migration 007: Create task_activity table
- Track task changes per session (created, updated, status_change, closed)
- Session ID from env/cache file (usage-stats format)
- New tool: session_tasks to query tasks by session

Phase 3: Commit-Task Linking
- Migration 008: Create task_commits junction table
- New tools: task_commit_add, task_commit_remove, task_commits_list,
  task_link_commits (batch parsing)
- Stores SHA references only (Gitea MCP owns full data)
- Commits shown in task_show output

17 new MCP tools total. All migrations applied to docker-host postgres.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 10:28:21 +02:00
Christian Gick
e12cccf718 fix: Add missing updated_at column to epics table
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>
2026-01-10 09:48:08 +02:00
Christian Gick
99f5828f60 feat: Add project_context tool and CWD auto-detection
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>
2026-01-10 09:26:33 +02:00
Christian Gick
837fb8060c feat: Add project lock mechanism for session exclusivity
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>
2026-01-10 09:22:26 +02:00
Christian Gick
fe2cd82587 fix: Add embedding column to epics table
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>
2026-01-10 09:16:37 +02:00
Christian Gick
612199d5ce fix: Use agiliton database instead of litellm
- 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>
2026-01-10 09:03:28 +02:00
Christian Gick
29cd754e39 fix: Add missing 001 base schema migration
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>
2026-01-09 17:21:40 +02:00
Christian Gick
d39e82a767 feat: Add epic_close MCP tool
- 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>
2026-01-09 15:25:05 +02:00
Christian Gick
e21072ea54 feat: Add delegation tracking MCP tools
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>
2026-01-09 10:43:13 +02:00
Christian Gick
df3e557c87 feat: Add task_delegations schema (Session 374)
- 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>
2026-01-09 10:32:10 +02:00
Christian Gick
2c7a2de5b3 feat(task-mcp): Add task_resolve_duplicate tool
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>
2026-01-09 06:34:16 +02:00
Christian Gick
3fc8f2d5e0 feat: Add 'testing' status to task workflow
Workflow: open → in_progress → testing → completed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 00:13:31 +02:00
Christian Gick
f193581805 feat: Make relates_to and duplicates links bidirectional
- 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>
2026-01-08 23:45:15 +02:00
Christian Gick
a03e9e065a feat: Add task-mcp server for task management via MCP
Implements 10 MCP tools for task management:
- CRUD: task_add, task_list, task_show, task_close, task_update
- Search: task_similar (pgvector), task_context
- Relations: task_link, task_checklist_add, task_checklist_toggle

Uses PostgreSQL with pgvector for semantic search via LiteLLM embeddings.
Connects via SSH tunnel to docker-host:5435.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:58:14 +02:00