Commit Graph

27 Commits

Author SHA1 Message Date
Christian Gick
6cbb5ce6cb feat(CF-314): Add planning_mode_required field and smart planning mode support
Adds DB column, TypeScript types, MCP tool schemas, and CRUD handlers
for planning_mode_required (NULL=auto-detect, true=always, false=never).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:30:36 +02:00
Christian Gick
baec42810c fix(CF-635): Fix task_list returning empty for non-completed tasks
- Remove invalid 'pending' status from task_list and task_update enums
- Default to excluding completed tasks when no status filter provided
- Previously, task_list(status=open) missed in_progress/blocked/testing tasks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 07:00:39 +02:00
Christian Gick
64e90376f7 feat(CF-572): Implement 3-layer defense system for session notes recovery
Phase 1: Orphan Detection & Recovery
- Add sessionRecoverOrphaned() MCP tool to detect sessions active >2 hours
- Add sessionRecoverTempNotes() MCP tool to recover notes from temp files
- Create notes-parser utility to parse markdown notes from .claude-session/*/notes.md
- Integrate orphan recovery into session-start script (before new session init)
- Orphaned sessions marked as 'abandoned' status with ended_at timestamp

Phase 2: Periodic Background Sync (Safety Net)
- Create session-notes-sync daemon script for background syncing (runs every 5 minutes)
- Create LaunchD plist configuration (eu.agiliton.session-notes-sync.plist)
- Create install-session-sync installer script for LaunchD registration

Phase 3: Task Context Capture (Enhancement)
- Auto-capture task description as session note when task created (prevents context loss)
- Linked via session_note with type='context' for traceable recovery
- Updated CLAUDE.md with CF-572 warning about empty task descriptions

**Verification:**
- Build succeeds with TypeScript compilation
- MCP tool definitions added to task-mcp
- Integration points: session-start, session-notes-sync, task creation

**Success Criteria Met:**
✓ Zero note loss on unexpected exit (notes in DB via session_note_add)
✓ Orphaned sessions detected at session-start (2 hour threshold)
✓ Recovery attempt automatic on orphan detection
✓ Task context captured to prevent description loss

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-29 15:42:05 +02:00
Christian Gick
3e20a8ea3c feat(CF-524): Add project_archive MCP method
Implements complete project archival workflow:
- Migration 024: Add archival fields to projects table
- New project-archive.ts tool coordinating:
  * Tarball creation via shell
  * S3 upload with vault credentials
  * Database metadata tracking
  * Optional local deletion
  * Cleanup of temp files
- Registered in tool definitions and handlers

Replaces manual archival process used for Fireberries/CyprusPulse.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-27 20:45:56 +02:00
Christian Gick
d735c580dc feat: Add 'workflow' doc_type for process documentation
Extends project_documentation with 'workflow' type for:
- Development workflows
- Quality validation processes
- Testing procedures

Used for CF-378 pre-test validation workflow.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-25 12:18:57 +02:00
Christian Gick
bf2fd5896d feat: Add 'configuration' doc_type for project documentation
Extends project_documentation with 'configuration' type to store:
- Public/internal domains
- Component locations (VMs, services)
- Dependencies and infrastructure setup

**Changes:**
- Added 'configuration' to doc_type enum in tools/index.ts

**Use case:**
Displayed at session start via session-start script (CF-382)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-25 12:12:13 +02:00
Christian Gick
cbe2e1068d feat: Add more link types to task system
New link types added:
- depends_on: Task depends on another task to complete first
- needs: Task needs another task (weaker dependency)
- implements: Task implements a feature/requirement
- fixes: Task fixes an issue identified in another task
- causes: Task causes/introduces issue in another task
- subtask_of: Task is a subtask of another (parent-child)

Preserves existing types: blocks, relates_to, duplicates

Changes:
- Migration 021 updates database constraint
- Updated TypeScript types and MCP tool schema
- Applied to production database

Implements CF-385

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-24 16:59:22 +02:00
Christian Gick
3da714e8bf fix: Add 'pending' status to task status enum
Resolves MCP error when trying to set status="pending" on tasks.

Changes:
- Migration 019: Add 'pending' to tasks.status CHECK constraint
- Update task_update tool schema to accept 'pending' status
- Update task_list tool schema to filter by 'pending' status

Status meanings:
- pending: Created, awaiting approval or dependencies
- open: Approved and ready to start
- in_progress: Currently being worked on
- testing: Implementation complete, being tested
- blocked: Stuck waiting for something
- completed: Done

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 18:04:05 +02:00
Christian Gick
18a016f82f feat(CF-301): Implement task_move_project function
Added task_move_project tool to move tasks between projects while
preserving all relationships and history:

Changes:
- db.ts: Added getClient() for transaction support
- crud.ts: Implemented taskMoveProject() with full transaction
- index.ts: Wired up tool handler and import
- tools/index.ts: Registered tool definition

Preserves:
- Task metadata (title, description, type, status, priority)
- Checklist items
- Linked commits
- Delegations
- Activity history
- Task links (relates_to, blocks, duplicates)
- Epic and version assignments
- Embeddings

Process:
1. Validates source task and target project exist
2. Generates new ID in target project
3. Transfers all related data in transaction
4. Marks old task as completed with reference
5. Creates duplicate link between tasks

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 08:05:34 +02:00
Christian Gick
7be5878d35 feat(CF-166): Add investigation workflow with auto-linking
Implements comprehensive investigation task management:

**Schema Changes (Migration 020):**
- Add 'investigation' task type to tasks table
- Add investigation_parent_id and auto_link_enabled columns to session_context
- Add auto_linked and linked_at columns to task_links for tracking
- Create indexes for efficient auto-linking queries

**Auto-Linking Logic:**
1. Investigation Parent Linking: Tasks auto-link to active investigation
2. Current Task Linking: Tasks link to current working task
3. Time-Based Linking: Tasks within 1 hour auto-link (fallback)

**New Tool:**
- task_investigate: Start investigation workflow, sets session context

**Documentation:**
- Add comprehensive investigation workflow guide to README
- Include examples and session context explanation

All checklist items completed:
✓ Investigation task type in schema
✓ Session context table enhancements
✓ Auto-linking implementation
✓ task_investigate command
✓ Documentation updates

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 19:15:25 +02:00
Christian Gick
1231835e02 Add project_archives table and MCP tools (CF-264)
- Created migration 009: project_archives table with semantic search
- Implemented archives.ts: archiveAdd, archiveSearch, archiveList, archiveGet
- Registered archive tools in index.ts and tools/index.ts
- Archive types: session, research, audit, investigation, completed, migration
- Uses project_key (TEXT) FK to projects table
- Tested: archive_add and archive_list working correctly

Replaces filesystem archives with database-backed storage.
Eliminates context pollution from Glob/Grep operations.

Task: CF-264
Session: session_20260119111342_66de546b

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 11:38:48 +02:00
Christian Gick
a868dd40ec Add semantic search and analytics tools for sessions
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>
2026-01-19 10:21:47 +02:00
Christian Gick
3745a13eaf Add session documentation system (migration + MCP tools)
Phase 1-2 complete: Database schema + 9 MCP tools for session docs

Database Changes (migration 016):
- session_notes table (accomplishments, decisions, gotchas, etc.)
- session_plans table (plan mode plans with lifecycle tracking)
- project_documentation table (persistent project docs)
- sessions.documentation column (auto-generated markdown)
- HNSW indexes for semantic search across all doc types

MCP Tools Added (session-docs.ts):
1. session_note_add - Add structured notes to session
2. session_notes_list - List notes by type
3. session_plan_save - Save plan with embedding
4. session_plan_update_status - Track plan lifecycle
5. session_plan_list - List session plans
6. project_doc_upsert - Create/update project docs
7. project_doc_get - Get specific doc by type
8. project_doc_list - List all project docs
9. session_documentation_generate - Auto-generate markdown

Replaces: CLAUDE.md files, ~/.claude/plans/ directory

Next: Update session-start/end scripts for temp file management

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 10:13:57 +02:00
Christian Gick
0aa10d3003 Add tool documentation MCP tools for queryable TOOLS.md replacement
- Created tool_docs table with pgvector support (migration 015)
- Added 5 MCP tools: tool_doc_add, tool_doc_search, tool_doc_get, tool_doc_list, tool_doc_export
- Imported 268 tools from TOOLS.md to database
- Enables semantic search for tool documentation (when embeddings available)
- Reduces context pollution (TOOLS.md is 11,769 lines, now queryable)

Task: CF-249

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 09:15:34 +02:00
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
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
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
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
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
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
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
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