Skip to content

Latest commit

 

History

History
574 lines (448 loc) · 20.4 KB

File metadata and controls

574 lines (448 loc) · 20.4 KB

DevContext — Detailed Build Process

Implementation guide for Roadmap Phases 16–18 and Long-Term Vision


Phase 16: Usability & Adoption

16.1 — One-Command Installer

  • npx create-devcontext scaffolder (detects DB preference, integrations, generates .env)
  • Homebrew formula for CLI binary
  • Effort: 2 weeks | Files: packages/create-devcontext/

16.2 — Guided First-Run Experience

  • Seed sample data on empty database (20-30 activities across files/users)
  • React Joyride walkthrough overlay highlighting: search (Cmd+K), timeline, knowledge graph, Q&A, expertise map
  • Dismissable, stored in cookie
  • Effort: 1–2 weeks | Files: web/src/components/Onboarding.tsx, web/src/lib/seed.ts

16.3 — devcontext doctor

  • Health checks: database connection, watcher process, web server, git, GitHub/GitLab tokens, disk space, Node.js version
  • Clear pass/fail output with suggested fixes
  • Effort: 1 week | Files: cli/src/commands/doctor.ts

16.4 — Desktop App (Tauri)

  • Tauri wraps Next.js dashboard; system tray with status indicator
  • Tray menu: Open Dashboard, Start/Stop Watcher, Status, Quit
  • Watcher runs as background process managed by Tauri
  • Auto-start on login option
  • Build for macOS/Windows/Linux via Tauri CI
  • Effort: 4–5 weeks | Files: desktop/, desktop/src-tauri/

16.5 — Smart Capture Filters & Session Grouping

  • .devcontextignore file (gitignore syntax) applied in watcher
  • Session detection: group activities with gaps >30min into named sessions
  • Auto-generate session labels from top files touched
  • Dashboard session view with collapsible cards
  • Effort: 2 weeks | Files: .devcontextignore, web/src/lib/sessions.ts

16.6 — Quick-Capture Notes

  • CLI: devcontext note "reason text" attaches note to most recent file
  • API: POST /api/notes with content, file, tags
  • Prisma Note model (content, file, tags, user, timestamp, workspace)
  • Dashboard: notes in timeline with distinct icon; Cmd+N modal
  • VS Code: Cmd+Shift+N quick note input attached to current file
  • Effort: 1–2 weeks | Files: cli/src/commands/note.ts, web/src/app/api/notes/route.ts

16.7 — Shareable Context Snapshots

  • CLI: devcontext export --last 7d --format html > summary.html
  • HTML export: self-contained with embedded CSS, timeline, file summary, user breakdown, session list, knowledge graph SVG
  • Markdown export: clean standup/handoff format
  • API: GET /api/export?from=...&to=...&format=html|markdown|json
  • Effort: 2 weeks | Files: cli/src/commands/export.ts, web/src/lib/export-html.ts

16.8 — Integrations

JetBrains plugin (3 weeks):

  • Kotlin IntelliJ Platform Plugin
  • Sidebar: activity stream, search, knowledge graph
  • Capture via VirtualFileListener
  • HTTP to DevContext API (localhost:3000)

Jira/Linear (1 week):

  • Extract ticket IDs from branch names/commit messages (regex: [A-Z]+-\d+)
  • Auto-link activities to tickets in dashboard
  • Optional Jira API fetch for ticket details

Slack bot (1 week):

  • Daily/weekly digest via incoming webhook (no Slack app needed)
  • Block Kit formatted message with activity summary
  • Configurable schedule via cron

Calendar (1 week):

  • Google Calendar / Outlook API integration
  • Correlate coding sessions with calendar events
  • Show meeting context alongside activities in timeline

Total effort: 6 weeks | Files: integrations/jetbrains/, integrations/slack/, web/src/lib/integrations/


Phase 17: Security & Privacy

17.1 — End-to-End Encryption for Sync

  • X25519 key generation per user on first setup
  • AES-256-GCM encryption of all activity data before sync
  • Sync server stores only encrypted blobs (zero-knowledge)
  • X25519 Diffie-Hellman key exchange for team shared secrets
  • Effort: 3–4 weeks | Files: web/src/lib/encryption/, web/src/lib/sync/

17.2 — Sensitive File Detection & Redaction

  • Built-in sensitive patterns: .env*, *.pem, *.key, credentials.json, *secret*, .aws/credentials, .ssh/*
  • Content redaction: regex-replace key/secret/token/password = value with [REDACTED]
  • Blocked by default in watcher (skip capture entirely for sensitive files)
  • Effort: 1 week | Files: web/src/lib/sensitive.ts

17.3 — Data Retention Policies

  • Configurable via DEVCONTEXT_RETENTION_DAYS (default: 90)
  • Daily cron job deletes activities older than threshold
  • Retention also applied to notes, sessions, and search indexes
  • Dashboard shows retention policy status
  • Effort: 1 week | Files: web/src/lib/retention.ts

17.4 — Enterprise Security

SAML 2.0 SSO (2 weeks):

  • Add @node-saml/node-saml alongside existing OIDC
  • Support Okta, Azure AD, OneLogin, generic SAML
  • Config via environment variables: DEVCONTEXT_SAML_ENTRY_POINT, DEVCONTEXT_SAML_ISSUER, DEVCONTEXT_SAML_CERT

IP Allowlisting (1 week):

  • Middleware checking req.socket.remoteAddress against DEVCONTEXT_ALLOWED_IPS (comma-separated)
  • Returns 403 for non-allowed IPs
  • Bypassed in development mode

Session Management (1 week):

  • Configurable session timeout: DEVCONTEXT_SESSION_TIMEOUT_MINUTES (default: 480)
  • Concurrent session limit per user
  • devcontext sessions list and devcontext sessions revoke <id> CLI commands
  • Admin dashboard panel for active sessions

Vulnerability scanning (1 week):

  • Add npm audit and Snyk to CI pipeline
  • Dependabot/Renovate config for automated dependency updates

Total effort: 5 weeks

17.5 — Cryptographic Integrity

  • Each activity entry signed with user's Ed25519 key
  • Hash chain: each entry includes SHA-256 hash of previous entry
  • Extends existing audit log integrity hashes to all activity data
  • Export verification: devcontext verify-export snapshot.html
  • Effort: 2 weeks | Files: web/src/lib/integrity.ts, cli/src/commands/verify.ts

17.6 — Backup & Recovery

  • Automated encrypted backups of SQLite/PostgreSQL database
  • Schedule: daily (configurable via DEVCONTEXT_BACKUP_SCHEDULE)
  • Backup location: local directory or S3-compatible storage
  • Encryption: AES-256-GCM with user-provided key
  • Restore: devcontext backup restore <backup-file>
  • Rotation: keep last N backups (configurable)
  • Effort: 2 weeks | Files: cli/src/commands/backup.ts, web/src/lib/backup.ts

Phase 18: Woo Factor & Intelligence

18.1 — "Why Does This Code Exist?" Narratives

Goal: AI-generated archaeological record for any file.

Steps:

  1. Gather context for a file:

    async function gatherFileHistory(filePath: string) {
        const activities = await prisma.activity.findMany({
            where: { file: filePath },
            orderBy: { timestamp: 'asc' },
            include: { notes: true }
        });
        
        const gitLog = execSync(`git log --follow --format="%H|%an|%s|%ai" -- ${filePath}`).toString();
        const commits = parseGitLog(gitLog);
        const prs = await fetchLinkedPRs(filePath);
        const notes = activities.flatMap(a => a.notes);
        
        return { activities, commits, prs, notes };
    }
  2. LLM prompt:

    const prompt = `Based on this file's history, write a 3-5 paragraph narrative explaining:
    - Who created this file and why
    - How it evolved over time
    - Key decisions made (especially from developer notes)
    - Current state and who the experts are
    
    File: ${filePath}
    Created: ${history.commits[0].date} by ${history.commits[0].author}
    Commits: ${history.commits.length}
    Contributors: ${uniqueAuthors.join(', ')}
    Recent changes: ${recentChanges}
    Developer notes: ${notes.map(n => n.content).join('\n')}
    Linked PRs: ${prs.map(pr => `#${pr.number}: ${pr.title}`).join('\n')}`;
  3. Dashboard integration:

    • Click any file in the knowledge graph → "Why does this exist?" button
    • Narrative panel slides in with formatted response
    • Cache narratives (refresh on new activity)
  4. CLI: devcontext explain src/auth/login.ts

Estimated effort: 2–3 weeks Key files: web/src/lib/ai/explain.ts, web/src/components/FileNarrative.tsx


18.2 — Onboarding Autopilot

Goal: Generate personalised onboarding guide for new team members.

Steps:

  1. Analyse team knowledge graph:

    async function generateOnboardingPlan(newUser: string) {
        const experts = await getExpertiseMap();
        const hotFiles = await getRecentHotspots(30); // last 30 days
        const architecture = await getTopLevelDirectories();
        
        const plan = {
            priority: rankByActivity(architecture), // Most active areas first
            experts: mapExpertsToAreas(experts, architecture),
            skipAreas: findLowActivityAreas(architecture, 90), // Dormant >90 days
            keyFiles: hotFiles.slice(0, 10),
            recentDecisions: await getRecentNotes(14), // Last 2 weeks of notes
        };
        
        return await generateWithLLM(plan);
    }
  2. Output format:

    # Onboarding Guide for New Developer
    
    ## Start Here (High Priority)
    1. **`src/auth/`** — Authentication module (Expert: Alice Chen)
       - Recently refactored (Feb 3-7), 47 changes
       - Key file: `login.ts` — Start here to understand the auth flow
    
    2. **`src/api/`** — REST API layer (Expert: Marcus Rivera)
       - Active area, 8 endpoints modified this month
    
    ## Later (Lower Priority)
    3. **`src/legacy/`** — Legacy migration code
       - Low activity (last touch: 3 months ago)
       - Skip for now unless working on data migration
    
    ## Recent Decisions to Know About
    - "Chose Redis over Memcached for pub/sub" — Alice, Feb 3
    - "Rate limiting added to /api/users" — Bob, Feb 5
  3. Dashboard view — dedicated onboarding page with visual guide

  4. CLI: devcontext onboard --new-member "Jane"

Estimated effort: 2–3 weeks Key files: web/src/lib/ai/onboarding.ts, web/src/app/onboarding/page.tsx


18.3 — 3D Knowledge Graph

Goal: Interactive Three.js-powered visualisation.

Steps:

  1. Frontend component:

    // web/src/components/KnowledgeGraph3D.tsx
    import * as THREE from 'three';
    import { ForceGraph3D } from 'react-force-graph';
    
    export function KnowledgeGraph3D({ data }) {
        return (
            <ForceGraph3D
                graphData={data}
                nodeAutoColorBy="type" // file=blue, developer=green, concept=purple
                nodeVal={node => node.activityCount} // Size by activity
                linkWidth={link => link.strength * 2}
                linkColor={link => recencyColor(link.lastActivity)}
                onNodeClick={handleNodeClick}
                nodeThreeObject={node => {
                    // Custom 3D objects: files as cubes, devs as spheres
                    const geometry = node.type === 'file' 
                        ? new THREE.BoxGeometry(5, 5, 5)
                        : new THREE.SphereGeometry(5);
                    const material = new THREE.MeshLambertMaterial({
                        color: node.color,
                        emissive: node.isActive ? 0x444444 : 0x000000,
                    });
                    return new THREE.Mesh(geometry, material);
                }}
            />
        );
    }
  2. Data transformation:

    • Nodes: files (grouped by directory), developers, concepts/tags
    • Edges: developer→file (edited), file→file (co-edited in session), developer→developer (collaborated)
    • Edge weight: recency and frequency of interaction
  3. Interactions:

    • Click node: show detail panel (file narrative, developer profile, concept summary)
    • Rotate/zoom with mouse
    • Search highlights matching nodes
    • Time slider filters to specific date range
  4. Performance: Limit to top 500 nodes, cluster dormant files

Estimated effort: 3–4 weeks Key files: web/src/components/KnowledgeGraph3D.tsx


18.4 — Code DNA Profile

Goal: Visual developer fingerprint.

Steps:

  1. Calculate profile metrics:

    interface CodeDNA {
        expertiseDistribution: { area: string; percentage: number }[]; // e.g., auth: 35%, api: 25%
        activityPattern: { hour: number; count: number }[]; // 24-hour activity heatmap
        collaborationScore: number; // 0-100, how often co-edits with others
        focusDepth: number; // files per session average
        languages: { lang: string; percentage: number }[];
        topFiles: string[];
        sessionsPerWeek: number;
        avgSessionDuration: number;
    }
  2. Radial chart visualisation (Recharts RadarChart):

    • Axes: expertise breadth, collaboration, focus depth, activity volume, code review participation
    • Filled area shows developer's profile shape
  3. Dashboard page: /profile/{username} with:

    • Radial chart
    • Activity heatmap (GitHub-style contribution grid)
    • Top files and areas
    • Recent sessions
    • Notes authored
  4. Shareable — export as PNG or SVG

Estimated effort: 2 weeks Key files: web/src/app/profile/[username]/page.tsx, web/src/components/CodeDNA.tsx


18.5 — Time-Travel Replay

Goal: Animated knowledge graph evolution over time.

Steps:

  1. Build snapshots at regular intervals (daily/weekly):

    async function buildTimeSnapshots(startDate: Date, endDate: Date, interval: 'day' | 'week') {
        const snapshots = [];
        let cursor = startDate;
        while (cursor < endDate) {
            const activities = await getActivitiesUpTo(cursor);
            const graph = buildKnowledgeGraph(activities);
            snapshots.push({ date: cursor, graph });
            cursor = addInterval(cursor, interval);
        }
        return snapshots;
    }
  2. Playback UI:

    • Timeline scrubber at bottom of knowledge graph view
    • Play/pause button with speed control (1x, 2x, 5x)
    • Date label showing current snapshot
    • Graph animates smoothly between snapshots (node positions interpolated)
    • New nodes fade in, removed nodes fade out
    • Activity pulses on edges during their time window
  3. Performance: Pre-compute snapshots, cache in IndexedDB

Estimated effort: 3–4 weeks Key files: web/src/components/TimeTravel.tsx, web/src/lib/snapshots.ts


18.6 — MCP Server

Goal: Expose DevContext as MCP tool for AI assistants.

Steps:

  1. MCP tool definitions:

    // integrations/mcp-server/src/index.ts
    import { Server } from '@modelcontextprotocol/sdk/server';
    
    const server = new Server({ name: 'devcontext', version: '1.0.0' });
    
    server.tool('devcontext_search', 'Search coding context', { query: 'string' },
        async ({ query }) => {
            const results = await searchActivities(query);
            return formatResults(results);
        }
    );
    
    server.tool('devcontext_explain_file', 'Explain why a file exists', { file: 'string' },
        async ({ file }) => {
            const narrative = await generateFileNarrative(file);
            return narrative;
        }
    );
    
    server.tool('devcontext_who_knows', 'Find who knows about a topic', { topic: 'string' },
        async ({ topic }) => {
            const experts = await findExperts(topic);
            return formatExperts(experts);
        }
    );
    
    server.tool('devcontext_recent_context', 'Get recent activity summary', { days: 'number' },
        async ({ days }) => {
            const summary = await getRecentSummary(days);
            return summary;
        }
    );
  2. Transport: stdio for Claude Code/Cursor, SSE for web-based tools

  3. CLI: devcontext mcp-server starts the server

  4. Config example for Claude Code:

    { "mcpServers": { "devcontext": { "command": "devcontext", "args": ["mcp-server"] } } }

Estimated effort: 2–3 weeks Key files: integrations/mcp-server/


18.7 — Browser Extension

Goal: DevContext overlays on GitHub/GitLab code views.

Steps:

  1. Content script for GitHub/GitLab:

    • Detect file paths from breadcrumb/URL
    • Query DevContext API: GET /api/files/{path}/context
    • Inject overlay: last editors, recent changes, linked PRs, notes
  2. Gutter annotations:

    • Show "last edited by X, Y days ago" on hover per line
    • Show note indicators (💬) on lines with attached notes
  3. Popup UI: Summary of file context, link to full dashboard

  4. Manifest V3 (Chrome):

    {
      "manifest_version": 3,
      "name": "DevContext",
      "permissions": ["activeTab"],
      "content_scripts": [{
        "matches": ["*://github.com/*", "*://gitlab.com/*"],
        "js": ["content.js"],
        "css": ["overlay.css"]
      }]
    }
  5. Requires DevContext API running (localhost or team server)

Estimated effort: 3–4 weeks Key files: browser-extension/


18.8 — Context Score Badge & Plugin System

Context Score Badge (1 week):

  • Score based on: activity coverage, note density, expert mapping coverage, session labeling
  • DevContext: 94% Coverage | 3 Active Contributors
  • API endpoint: GET /api/badge
  • Markdown snippet for README

Plugin System (3–4 weeks):

  • Plugin interface:
    interface DevContextPlugin {
        name: string;
        version: string;
        captureSource?: CaptureAdapter;  // Custom data source
        dashboardPanel?: ReactComponent;  // Custom UI panel
        searchProvider?: SearchAdapter;   // Custom search integration
    }
  • Plugin directory: ~/.devcontext/plugins/
  • Built-in adapters: Figma activity, Notion edits, terminal commands, browser tabs
  • Plugin registry (npm-based): devcontext plugin install devcontext-plugin-figma

Long-Term Vision

Cross-Repository Knowledge Graph

  • Unified graph spanning all repos in an org
  • Shared library changes propagate context to downstream projects
  • Requires centralised sync server or shared database
  • Effort: 4–6 weeks

Institutional Memory Preservation

  • When a developer leaves, their knowledge graph and notes remain
  • "Alumni" mode — profile is archived but context is searchable
  • Handoff reports auto-generated for their areas of expertise
  • Effort: 2–3 weeks

AI Pair Programmer with Context

  • Feed knowledge graph into AI coding assistants via MCP
  • AI understands not just code, but team conventions, past decisions, and architectural intent
  • "Why was this approach chosen?" → DevContext provides the answer
  • Effort: Ongoing (extends MCP server)

Meeting Context Capture

  • Transcribe meetings (Whisper/AssemblyAI) and link discussions to code changes
  • "We decided to use Redis in the Feb 3 architecture meeting" → linked to cache/redis-client.ts
  • Effort: 4–6 weeks

Open Protocol for Developer Context

  • Publish specification for context interchange format
  • Enable IDE, CI, and PM tools to share context
  • Effort: 2–3 months (specification + reference implementation)

Infrastructure & DevOps Requirements

Component Technology Purpose
Web framework Next.js, React, Tailwind Dashboard
Database SQLite (local) / PostgreSQL (team) Activity storage
ORM Prisma Database access
CLI Node.js, Commander, Chalk Terminal interface
Desktop app Tauri (Rust + WebView) Standalone application
3D visualisation Three.js, react-force-graph Knowledge graph
LLM API Anthropic / OpenAI AI features
MCP @modelcontextprotocol/sdk AI assistant integration
Browser extension Chrome Manifest V3 GitHub/GitLab overlays
Encryption Node.js crypto (X25519, AES-256-GCM) E2E encryption
Build/Release GitHub Actions, Tauri CI Multi-platform builds

Dependency Map

16.1 (Installer) ──→ 16.2 (First-run seeds data after install)
16.4 (Desktop app) ──→ 16.5 (Watcher managed by desktop app)

16.5 (Sessions) ──→ 16.7 (Export includes sessions)
16.6 (Notes) ──→ 18.1 (Notes feed into file narratives)
              ──→ 18.2 (Notes shown in onboarding guide)

17.1 (E2E encryption) ──→ 17.6 (Encrypted backups)
17.2 (Sensitive detection) — independent
17.4 (Enterprise security) — independent

18.1 (File narratives) ──→ 18.2 (Onboarding uses narratives)
18.3 (3D graph) ──→ 18.5 (Time-travel animates the 3D graph)
18.6 (MCP server) — independent, can be built anytime
18.7 (Browser extension) — needs API server

All Phase 16 items can be built in parallel.
All Phase 17 items can be built in parallel.
Phase 18 items mostly independent except 18.3→18.5 and 18.1→18.2.