All files / src extension-commands.ts

100% Statements 21/21
100% Branches 1/1
100% Functions 1/1
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103                            1x 4x   4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x                                                                                                                                      
// Import types needed locally in this file
import type {
    TooltipAlert,
    TooltipOperation,
    TooltipFinding,
} from "@dataflint/mcp-server";
 
// Re-export tooltip types (DRY - single source of truth)
export type {
    TooltipAlert,
    TooltipOperation,
    TooltipFinding,
} from "@dataflint/mcp-server";
 
export class ExtensionCommands {
    private static readonly PREFIX = "dataflint-copilot";
 
    public static readonly OPEN_URL = `${ExtensionCommands.PREFIX}.openUrl`;
    public static readonly SHOW_INFO = `${ExtensionCommands.PREFIX}.showInfo`;
    public static readonly SHOW_PART_INFO = `${ExtensionCommands.PREFIX}.showPartInfo`;
    public static readonly ADD_DECORATIONS_DIRECT = `${ExtensionCommands.PREFIX}.addDecorationsDirect`;
    public static readonly TOGGLE_HIGHLIGHT = `${ExtensionCommands.PREFIX}.toggleHighlight`;
    public static readonly FILTER_BY_QUERY = `${ExtensionCommands.PREFIX}.filterHighlightsByQuery`;
    public static readonly RESTART_SERVER = `${ExtensionCommands.PREFIX}.restartServer`;
    public static readonly LOGIN = `${ExtensionCommands.PREFIX}.login`;
    public static readonly SHOW_LOGS = `${ExtensionCommands.PREFIX}.showLogs`;
    public static readonly FIX_HIGHLIGHT = `${ExtensionCommands.PREFIX}.fixHighlight`;
    public static readonly EXPLAIN_HIGHLIGHT = `${ExtensionCommands.PREFIX}.explainHighlight`;
    public static readonly REPORT_HIGHLIGHT_ISSUE = `${ExtensionCommands.PREFIX}.reportHighlightIssue`;
    public static readonly SHOW_ISSUES_IN_FILE = `${ExtensionCommands.PREFIX}.showIssuesInFile`;
    public static readonly REVEAL_ALL_HIGHLIGHTS = `${ExtensionCommands.PREFIX}.revealAllHighlights`;
    public static readonly REFRESH_TREE_VIEW = `${ExtensionCommands.PREFIX}.refreshTreeView`;
    public static readonly TREE_ITEM_CLICKED = `${ExtensionCommands.PREFIX}.treeItemClicked`;
    public static readonly REVEAL_IN_EXPLORER = `${ExtensionCommands.PREFIX}.revealInExplorer`;
    public static readonly OPEN_ONBOARDING = `${ExtensionCommands.PREFIX}.openOnboarding`;
}
 
// ============================================================================
// INTENT-DRIVEN ARCHITECTURE TYPES
// ============================================================================
 
/**
 * Intent type for Fix It / Explain actions
 */
export type IntentType = "fix" | "explain" | "highlight" | "optimize";
 
/**
 * Scope of the intent - what level of granularity
 */
export type IntentScope = "line" | "alert" | "operation" | "finding";
 
/**
 * Target information - what the user wants to address
 */
export interface IntentTarget {
    /** Display text describing the issue */
    displayText: string;
    /** Whether this is a performance hotspot */
    isHotspot: boolean;
    /** Alerts from the highlight */
    alerts?: TooltipAlert[];
    /** Operations from the highlight */
    operations?: TooltipOperation[];
    /** LLM findings from the highlight */
    findings?: TooltipFinding[];
}
 
/**
 * Base intent for line-level actions (from CodeLens)
 */
export interface HighlightIntent {
    /** Intent type: fix, explain, highlight, optimize */
    type: IntentType;
    /** Scope: line for CodeLens, or specific object type */
    scope: IntentScope;
    /** Job ID for MCP tool calls */
    jobId: number;
    /** File path where the issue is located */
    filePath: string;
    /** Line number (1-indexed) */
    codeLine: number;
    /** The actual code on this line */
    codeText?: string;
    /** What user wants to address */
    target: IntentTarget;
    /** SQL query IDs involved */
    sqlIds: number[];
    /** Node IDs involved */
    nodeIds: number[];
    /** Deep link URL to DataFlint */
    url?: string;
}
 
/**
 * Extended intent for object-level actions (from tooltip clicks)
 */
export interface ObjectIntent extends HighlightIntent {
    /** Scope must be specific object type */
    scope: "alert" | "operation" | "finding";
    /** The specific object user clicked */
    clickedObject: TooltipAlert | TooltipOperation | TooltipFinding;
}