Commit Graph

73 Commits

Author SHA1 Message Date
Christian Gick
c0c6918e2c chore: Use per-product Sentry DSN (CF-835)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:46:06 +02:00
Christian Gick
507e98ef8e fix: Use actual project key for session Jira issues instead of hardcoded CF
The project parameter was passed to createSessionIssue() but ignored -
all sessions were created in the CF Jira project regardless of the
actual session project (ST, LLB, GB, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 17:09:34 +02:00
Christian Gick
9042bf0878 fix(CF-816): Self-healing session number sequence to prevent drift
session_sequences table fell behind when sessions were inserted with
explicit session_number (e.g., retro imports), causing duplicate key
violations on next auto-assigned number. Function now syncs forward
by checking MAX(session_number) before assigning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 07:48:54 +02:00
Christian Gick
3ca40d9100 revert: Keep CF project for session-tracking Jira issues
CU is a separate project. Session tracking stays in CF.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 07:32:21 +02:00
Christian Gick
c57f9c6a75 fix(CF-762): Use CU project for session-tracking Jira issues
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 07:31:59 +02:00
Christian Gick
63cba97b56 feat(CF-762): Add Jira integration for session tracking
Sessions now auto-create CF Jira issues on start and post full session
output as comments on end, transitioning the issue to Done.

- Add src/services/jira.ts with createSessionIssue, addComment, transitionToDone
- Update session_start to create CF Jira issue and store key in sessions table
- Update session_end to post session output and close Jira issue
- Add migration 031 to archive local task tables (moved to Jira Cloud)
- Update .env.example with Jira Cloud env vars

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 07:23:18 +02:00
Christian Gick
1227e5b339 feat(CF-762): Complete Jira migration - consolidate projects, cleanup
- Remove task CRUD/epic/search/relation/version tools (moved to Jira)
- Add migration scripts: migrate-tasks-to-jira, jira-admin, prepare-all-projects
- Add consolidate-projects.ts for merging duplicate Jira projects
- Add validate-migration.ts for post-migration integrity checks
- Add jira_issue_key columns migration (030)
- Consolidate 11 duplicate projects (LIT→LITE, CARD→CS, etc.)
- Delete 92 placeholder issues, 11 empty source projects
- Remove SG project completely
- 2,798 tasks migrated across 46 Jira projects

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 12:33:49 +02:00
Christian Gick
bd5d95beff fix: Fallback to cached session ID in session_note_add
When session_id is not provided, falls back to getSessionId() which
reads from CLAUDE_SESSION_ID env or ~/.cache/session-memory/current_session.
Fixes NOT NULL constraint violation on session_notes.session_id.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 21:02:12 +02:00
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
ab17865c7d fix(CF-627): Replace infra.agiliton.internal with postgres.agiliton.internal
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:18:38 +02:00
Christian Gick
d72a16d7e8 feat(CF-580): Remove legacy notes.md fallback from orphan recovery
Phase 3 cleanup: Transition complete to transcript-based recovery.

- Remove fallback to recoverNotesFromTempFile()
- All recovery now uses JSONL transcripts only
- Log warning if transcript not found for recovery
- Simplify recovery logic (no more dual-method path)

This completes the daemon elimination:
- LaunchAgent plist: Deleted
- session-notes-sync script: Deleted
- Legacy fallback code: Removed
- Result: Simpler architecture, no daemon overhead

Migration complete. System now uses only transcript-based recovery.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-29 18:01:22 +02:00
Christian Gick
e04a8ab524 feat(CF-580): Implement transcript-based session recovery for MCP
Add direct transcript ingestion and orphan recovery using Claude Code's JSONL
transcripts instead of relying on daemon-based note synchronization.

Changes:

1. **Database migration** (027_session_transcript_storage.sql):
   - Add transcript_jsonl, transcript_ingested_at, transcript_file_path columns
   - Add indexes for efficient ingestion tracking

2. **Transcript parser utility** (src/utils/transcript-parser.ts):
   - parseTranscriptFile(): Parse JSONL line-by-line, handle corrupt lines
   - encodeWorkingDir(): Convert paths to Claude Code directory encoding
   - findOrphanedTranscripts(): Scan for stale transcript files
   - ingestTranscriptToDatabase(): Main ingestion function for Node.js

3. **Orphan recovery enhancement** (src/tools/sessions.ts):
   - sessionRecoverOrphaned() now tries transcript ingestion first
   - Finds most recently modified JSONL in project directory
   - Falls back to legacy notes.md recovery for backward compatibility
   - Properly handles path encoding (/ and . → -)

Benefits:
- No daemon needed for recovery (Phase 2 will remove LaunchAgent)
- Full transcript audit trail stored in database
- Immediate recovery capability for orphaned sessions
- Cleaner architecture (no markdown parsing complexity)
- Compatible with Claude Code's UUID-based session files

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-29 17:53:37 +02:00
Christian Gick
30650cf47f feat(CF-580): Add schema support and metadata tracking for session notes recovery
- Migration 025: Add 'abandoned' status to sessions CHECK constraint (fixes blocking issue)
- Migration 026: Add recovery metadata columns (recovered_from, recovered_at) to track note recovery source
- Update sessionRecoverOrphaned to recover notes from temp files when marking sessions abandoned
- Update notes-parser to track recovery source and timestamp for analytics

These changes complete Priority 3, 5 and part of Priority 1 for CF-572 Session Notes Loss fix.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-29 17:12:21 +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
c83d36a2e8 feat(CF-567): Add project key validation to prevent corrupt data
- Add PROJECT_KEY_REGEX for valid format (2-5 uppercase letters)
- Add validateProjectKey() and isValidProjectKey() functions
- Update getProjectKey() to validate input and generated keys
- Reject invalid formats with clear error messages

Invalid formats now rejected:
- Single letters (A, C, U)
- Numbers (1, 20, 123)
- Full names (ClaudeFramework, Circles)
- Mixed case (Circles)
- Too long (>5 chars)

Also fixes Sentry SDK v8 API changes (httpIntegration, postgresIntegration).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 15:03:03 +02:00
Christian Gick
840767cea3 feat(CF-536): Integrate comprehensive Sentry into task-mcp
- Create sentry.ts with MCP-aware initialization and PII scrubbing
- Replace basic inline Sentry initialization with initSentry()
- Update .env.vault-mapping for sentry.backend-node.dsn secret
- Includes PostgreSQL integration and transaction tracing

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-29 05:50:46 +02:00
Christian Gick
cc2c98c4bf feat(CF-529): Add Sentry integration to task-mcp MCP server 2026-01-28 17:02:16 +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
a6d24ab86c fix(CF-518): Add ON UPDATE CASCADE to all projects foreign keys
Fixes task project rename command by adding ON UPDATE CASCADE to all foreign key constraints that reference projects(key).

Updated 10 FK constraints: task_sequences, epic_sequences, versions, epics, tasks, project_locks, project_archives, sessions, session_sequences, project_documentation.

Migration drops old constraints and adds new ones with both ON DELETE CASCADE and ON UPDATE CASCADE (except sessions which uses ON DELETE SET NULL).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-27 19:14:00 +02:00
Christian Gick
2b97a48614 feat: Add 'done' status with 7-day auto-close workflow
Added 'done' status to task lifecycle for verification period before completion.

**Changes:**
- Added 'done' to task_status enum (pending, open, in_progress, testing, blocked, done, completed)
- Added auto_close_at timestamp column for scheduling auto-close
- Created index for efficient cron job queries

**Workflow:**
1. Task marked 'done' → auto_close_at = NOW() + 7 days
2. Cron job runs daily to check tasks past auto_close_at
3. If no related issues → auto-close to 'completed'
4. If related issues → keep as 'done' (prevents premature closure)

**Lifecycle:**
  open → in_progress → done (7-day verification) → completed (auto-closed)

task:CF-454

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-25 14:57:46 +02:00
Christian Gick
49284d2911 feat(CF-450): Check completed tasks on task creation to avoid circular work
Enhanced task_add to search both open AND completed tasks when checking for
duplicates. Previously only checked non-completed tasks.

**Changes:**
- Removed `status != 'completed'` filter from similarity search
- Increased search limit from 3 to 5 tasks
- Separated display: open tasks vs previously completed
- Show 150-char context snippet from completed task descriptions
- Suggest using "task show <id>" to see full solution

**Benefits:**
- Prevents recreating already-solved tasks
- Surfaces solutions from previous attempts
- Reduces circular work on recurring issues
- Maintains context from closed tasks

**Example output:**
```
⚠️  Similar tasks found:

**Open/In Progress:**
  - CF-442: Next.js cache issue (92% match, open)

**Previously Completed:**
  - CF-378: Pre-test validation (85% match)
    Context: "Created comprehensive pre-test quality validation workflow..."

  💡 Use "task show <id>" to see full solution before recreating work
```

Fixes: CF-450

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-25 13:26:23 +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
90c700e445 fix: Replace hardcoded IPs with DNS hostnames
- DB_HOST: 10.0.1.1 → infra.agiliton.internal

Improves maintainability and enables dynamic DNS resolution.

Relates to CF-382

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-24 16:52:20 +02:00
Christian Gick
704fd0a994 feat: Add OpenBao integration for secret management
- Add .env.vault-mapping for LLM API key
- Add .env.example template
- Secret: litellm/master_key for embeddings

Migrated from plaintext .env to OpenBao integration.

Related: OpenBao Phase 4 MCP Servers Integration

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-24 10:37:08 +02:00
Christian Gick
2fa5279724 feat(CF-368): Use pgbouncer connection pooling via POSTGRES_PORT env
Changed hardcoded port 5432 to read from POSTGRES_PORT environment
variable to support pgbouncer connection pooling (port 6432).

Connection pooling reduces overhead for frequent queries and better
handles concurrent connections.

.env now configured with POSTGRES_PORT=6432 (pgbouncer).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-23 08:53:41 +02:00
Christian Gick
33b3ef5234 fix(CF-352): Auto-create session in sessionCommitLink to prevent FK constraint error
- Check if session exists before inserting commit link
- Auto-create minimal session record if missing (status=active, no project)
- Prevents FK constraint violation when cache/DB drift occurs
- Return message indicates if session was auto-created for monitoring
- Handles edge cases: concurrent calls, missing committed_at, NULL project

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-21 17:19:44 +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
b145e1effd feat(CF-338): Improve project detection to respect CF vs project scope
Problem: task-mcp treated all Infrastructure folders equally, causing framework/tooling work to be mis-scoped to random project codes instead of CF.

Solution:

1. Framework paths explicitly map to CF:

   - ClaudeFramework, AgilitonScripts, doco-cd, mcp-servers

   - deployment-system, monitoring-stack, backup-system

2. Infrastructure/* defaults to CF (framework work by default)

3. Project-specific infra services have explicit mappings:

   - caddy-gateway → CADDY

   - litellm → LLM

4. Apps/ still auto-detect project-specific codes (ST, GB, VPN, etc.)

This ensures:

- Framework tool changes → CF (correct scope)

- App features → Project codes (ST, GB, etc.)

- Infrastructure services → Own scope if needed

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 16:14:32 +02:00
Christian Gick
7f86d256c9 fix(CF-303): Remove internal IP from run.sh log message
Removed hardcoded internal IP address from debug log to comply with
CF-303 IP exposure validation. Changed to generic message.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 10:18:33 +02:00
Christian Gick
2439d4a645 fix(CF-306): Validate session_id in memory_add to prevent FK violations
Added validation to check if session_id exists in sessions table before
inserting memories. Falls back to NULL if session not found, preventing
foreign key constraint violations while preserving memory content.

Logs warning when invalid session_id provided for debugging.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 10:17:53 +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
213a84f464 docs(CF-236): Add CLI wrapper documentation to README
Added CLI Wrapper section documenting the task CLI available at
~/Development/Infrastructure/AgilitonScripts/bin/task

Includes examples for:
- Creating tasks
- Listing with filters
- Showing task details
- Updating tasks
- Closing tasks
- Adding checklist items
- Searching similar tasks
- Investigation workflow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 21:47:37 +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
caf9356aad feat(CF-282, CF-278): Add session context and task-session linking
**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>
2026-01-19 18:48:43 +02:00
Christian Gick
16c579e6d5 Add deployment tracking schema (Migration 018)
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>
2026-01-19 16:05:19 +02:00
Christian Gick
25bed341e9 Add migration scripts for archive database migration
Three migration scripts for complete file-to-database migration:
- migrate-all-docs-batch.mjs: Main migration (1,172 files)
- migrate-missed-docs.mjs: Supplementary for hidden dirs (34 files)
- migrate-external-archive.mjs: External archive cleanup (5 files)

Total migrated: 1,211 files (~15MB) to project_archives table
All with semantic embeddings for vector search

Related: CF-267, CF-268

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 15:01:18 +02:00
Christian Gick
eb6b51837f Add Phase 3 migration: project documentation
- migrate-project-docs-batch.mjs: 60 files across 23 projects
- migrate-cf-docs-batch.mjs: ClaudeFramework documentation
- migrate-plans-batch.mjs: Session plan files
- 017_fix_archives_embedding_dimension.sql: Fix vector dimension
- run-migration.js: Node.js migration runner utility

Total migrated: 332 files, 8.85MB with semantic embeddings

Fixes: CF-277
2026-01-19 14:09:03 +02:00
Christian Gick
6c497ec6c5 Fix CF-271: Add fallback text search to archive_search
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>
2026-01-19 13:14:29 +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
afce0bd3e5 Migrate embeddings from Gemini to local mxbai-embed-large
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>
2026-01-19 09:40:02 +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
fe2b1a0423 fix: Remove redundant session_id validation in memoryAdd (CF-195)
Problem: session_id validation added extra SELECT query before each
memory insertion, causing session-start delays.

Root cause: Foreign key constraint already enforces referential
integrity (migrations/011_memories.sql:16-19). Validation was redundant.

Solution: Remove validation (lines 50-59 in memories.ts). Let database
handle referential integrity with proper error messages.

Benefits:
- Faster memoryAdd calls (one less query)
- Proper error messages from PostgreSQL on constraint violations
- No silent NULL conversion for invalid session_ids

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-18 10:37:50 +02:00
Christian Gick
2e2f0192d9 fix: Validate session_id exists before memory insert (CF-194)
- 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
2026-01-18 10:33:59 +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
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