As we set up our Supabase instance with all the features I want you to also follow the guide for Modal Context Protoocal Usage and Hosting by following the guides
.
We are using Drizzle and Next.js - Get the files in line for our upcoming success.
Okay, consolidating everything into the most compact, machine-interpretable, rule-based format focused on triggering context gathering for an advanced AI coding assistant. This uses concise keys and references concepts/tools discussed.
1{2 "System_Goal": "Enhance AI coding assistant via proactive, multi-step, tool-driven context awareness to accelerate user, minimize errors/hallucinations.",3 "User_Motivation": "Achieve more aware, knowledgeable, interactive, alive, participatory AI partner.",4 "Discussion_Context": "Explore feasibility & methodology using VSCode API, AI SDK, Tool Calling, MCP, and rule-based context profiles ('Tiles').",5 "Core_Concepts": [6 "Proactive_Context_Gathering",7 "Intent_Inference",8 "Rule_Based_Profiles",9 "Multi_Step_Tool_Use",10 "Dynamic_Context_Enrichment",11 "VSCode_API_Integration",12 "MCP_Tool_Integration",13 "Generative_UI (via AI SDK)"14 ],15 "Methodology": "Trigger rule profiles based on user query + baseline context. Gather mandatory context via local API access. Proactively enrich context using AI Tool Calls (Cursor-like, MCP) based on profile rules. Iterate in multi-step flow if needed.",16 "Key_Practices": [17 "Prioritize_Visible_Local_Context",18 "Request_Specific_Context_Via_Tools",19 "Use_Strongest_Source (API > MCP > Tools > Search)",20 "Ask_To_Clarify_Ambiguous_Intent",21 "Report_Tool_Failures",22 "Retain_Context_Across_Steps"23 ],24 "Tools_Involved": {25 "Local_Agent": {26 "Mechanism": "VSCode Extension (like Cursor Agent)",27 "API": "vscode.* (window, workspace, languages, commands)",28 "Purpose": "Baseline context, executing some tool requests locally"29 },30 "AI_Assistant_Tools": {31 "Mechanism": "Tool Calling API (e.g., AI SDK backend invokes)",32 "Examples": ["edit_file", "read_file", "grep_search", "run_terminal_cmd", "file_search", "web_search"],33 "Purpose": "AI interacts with workspace/web via agent/backend"34 },35 "MCP_Server": {36 "Mechanism": "Model Context Protocol (SSE/Stdio/Custom Transport)",37 "Purpose": "Access specialized/remote/standardized tools (code analysis, DBs, etc.)"38 },39 "AI_SDK_Backend": {40 "Mechanism": "Vercel AI SDK (streamText, generateText, tool helpers)",41 "Purpose": "Orchestrate AI calls, tool execution, multi-step logic, response streaming (incl. custom data/UI)"42 }43 },44 "Rule_System_Overview": "Tile-based approach. Each 'Tile' is a profile activated by triggers. Defines mandatory & proactive context fetching strategy to fulfill inferred user intent.",45 "Rule_Profiles": {46 "P0_Baseline": {47 "Intent": "Establish_Foundation",48 "Triggers": ["ANY_Interaction"],49 "Action": "Gather Mandatory_Ctx -> Infer Intent -> Activate P1-P5",50 "Mandatory_Ctx": [51 "[API:window] ActiveFileURI", "[API:window] LangID", "[API:window] CursorPos", "[API:window] Selection(Range+Content)", "[API:window] VisibleCode(Range+Content)", "[API:languages] DiagnosticsNearCursor(Msg,Code,Severity,Range)"52 ]53 },54 "P1_Debug_Fix": {55 "Intent": "Fix_Error",56 "Triggers": ["error", "fix", "debug", "fail", "P0_Ctx has errors"],57 "Base_Ctx": "P0_Baseline",58 "Mandatory_Ctx": ["[API] ErrorSnippet(diagnostic.range)", "[API] SurroundingCode(error +/- lines)", "[API] DiagnosticRelatedInfo"],59 "Enrich_With": {60 "LocalDef": "[Tool:read_file(+search)] OR [MCP:lookupDef] OR [API:execDefProv]",61 "ImportDef": "[Tool:read_file(target)] OR [MCP:lookupDef(target)]",62 "TypeInfo": "[MCP:getTypeDef] OR [API:execTypeProv]"63 },64 "Output_Action": "Analyze -> Propose Fix -> [Tool:edit_file]"65 },66 "P2_Write_Complete": {67 "Intent": "Generate_Code",68 "Triggers": ["write", "create", "implement", "add", "complete", "Cursor suggests completion"],69 "Base_Ctx": "P0_Baseline",70 "Mandatory_Ctx": ["[API:agent] ScopeCode(enclosing block)", "[API:agent] Imports"],71 "Enrich_With": {72 "AvailableSymbols": "[MCP:getSymbolsInScope] OR [API:execComplProv(analyze)]",73 "Signature": "[MCP:getSig] OR [API:execSigProv] OR [API:execDefProv]",74 "Conventions": "[Tool:file_search+read_file(linters)] OR [MCP:getProjConventions]",75 "SimilarCode": "[Tool:grep_search] OR [API:execWsSymProv]"76 },77 "Output_Action": "Generate Code -> [Tool:edit_file]"78 },79 "P3_Refactor": {80 "Intent": "Improve_Code_Structure",81 "Triggers": ["refactor", "improve", "cleanup", "extract", "P0_Ctx has selection"],82 "Base_Ctx": "P0_Baseline",83 "Mandatory_Ctx": ["[API:agent] EnclosingScopeCode"],84 "Enrich_With": {85 "FindUsages": "[Tool:grep_search] OR [MCP:findRefs] OR [API:execRefProv] (*CRITICAL*)",86 "ExternalDefs": "Use P1/Enrich_With/LocalDef logic"87 },88 "Output_Action": "Analyze Usages -> Propose Refactor -> [Tool:edit_file(multiple?)]"89 },90 "P4_Understand_Explain": {91 "Intent": "Explain_Code",92 "Triggers": ["explain", "what does", "how works", "Query about code", "Default"],93 "Base_Ctx": "P0_Baseline",94 "Mandatory_Ctx": ["[API] CodeUnderScrutiny (selection or near cursor)"],95 "Enrich_With": {96 "FetchDefs": "Use P1/Enrich_With/LocalDef logic",97 "DocsComments": "[API:agent] Parse OR [API:execHoverProv]",98 "FilePurpose": "[Tool:read_file(header/README)] OR [MCP:summarizeFile]"99 },100 "Output_Action": "Generate Explanation"101 },102 "P5_Dependencies_APIs": {103 "Intent": "Handle_External_Code",104 "Triggers": ["Library name", "API call pattern", "import X", "package.json", "requirements.txt"],105 "Base_Ctx": "P0_Baseline",106 "Mandatory_Ctx": ["[Tool:file_search+read_file(dep files)] -> Parse Versions"],107 "Enrich_With": {108 "TypeDefs": "[MCP:getLibTypes] OR [API:agent] Search node_modules/@types",109 "Docs": "[Tool:web_search(lib+ver+func)] OR [MCP:fetchDocs]",110 "WorkspaceExamples": "[Tool:grep_search(func call)]"111 },112 "Output_Action": "Explain API, Show Examples, Warn Versions"113 }114 },115 "Concrete_Scenarios": [116 {117 "Scenario": "User selects code, asks 'fix this'",118 "Profile": "P1_Debug_Fix",119 "Key_Context": ["P0_Baseline(Selection, Diagnostics)", "ErrorSnippet", "SurroundingCode"],120 "Tool_Chain_Example": "[API]->Baseline -> [AI->NeedsTypeDef?] -> [MCP:getTypeDef] -> [AI->ProposeFix] -> [Tool:edit_file]"121 },122 {123 "Scenario": "User asks 'implement function foo(bar: string)'",124 "Profile": "P2_Write_Complete",125 "Key_Context": ["P0_Baseline(CursorPos, LangID)", "ScopeCode", "Imports"],126 "Tool_Chain_Example": "[API]->Baseline -> [AI->NeedsSimilarExample?] -> [Tool:grep_search(func foo)] -> [AI->GenerateCode] -> [Tool:edit_file]"127 },128 {129 "Scenario": "User selects method, asks 'refactor this to be async'",130 "Profile": "P3_Refactor",131 "Key_Context": ["P0_Baseline(Selection)", "EnclosingScopeCode", "FindUsages(*CRITICAL*)"],132 "Tool_Chain_Example": "[API]->Baseline -> [AI->FindUsages] -> [MCP:findRefs] -> [AI->AnalyzeRefs] -> [AI->ProposeAsyncChanges] -> [Tool:edit_file(multiple)]"133 },134 {135 "Scenario": "User asks 'what does this selected regex do?'",136 "Profile": "P4_Understand_Explain",137 "Key_Context": ["P0_Baseline(Selection, LangID)", "SurroundingCode (how it's used)"],138 "Tool_Chain_Example": "[API]->Baseline -> [AI->ExplainRegex]"139 },140 {141 "Scenario": "User asks 'how to use fetch API with AbortSignal'",142 "Profile": "P5_Dependencies_APIs",143 "Key_Context": ["P0_Baseline(LangID=JS/TS)", "Code Snippet (if any)", "Docs/Examples"],144 "Tool_Chain_Example": "[API]->Baseline -> [AI->SearchDocs] -> [Tool:web_search(MDN Fetch AbortSignal)] -> [AI->Explain+Example]"145 },146 {147 "Scenario": "User places cursor, asks 'add error handling'",148 "Profile": "P2_Write_Complete",149 "Key_Context": ["P0_Baseline(CursorPos, LangID)", "ScopeCode (likely function)", "Conventions (try/catch style)"],150 "Tool_Chain_Example": "[API]->Baseline -> [AI->CheckConventions?] -> [Tool:read_file(.eslintrc?)] -> [AI->GenerateTryCatch] -> [Tool:edit_file]"151 },152 {153 "Scenario": "User asks 'why is my build failing?' (no specific location)",154 "Profile": "P1_Debug_Fix (Broad)",155 "Key_Context": ["P0_Baseline(maybe irrelevant)", "Build Log Output"],156 "Tool_Chain_Example": "[AI->AskForBuildLog] OR [AI->RunBuildCmd] -> [Tool:run_terminal_cmd(build script)] -> [AI->AnalyzeLogOutput] -> Trigger P1 on specific error found"157 },158 {159 "Scenario": "User selects class name, asks 'rename to MyNewClass'",160 "Profile": "P3_Refactor",161 "Key_Context": ["P0_Baseline(Selection=ClassName)", "FindUsages(*CRITICAL*)"],162 "Tool_Chain_Example": "[API]->Baseline -> [AI->FindUsages] -> [MCP:findRefs] -> [AI->ConfirmRename] -> [Tool:edit_file(multiple across workspace)]"163 },164 {165 "Scenario": "User asks 'explain the difference between libA and libB'",166 "Profile": "P5_Dependencies_APIs",167 "Key_Context": ["Docs/Summaries for libA, libB"],168 "Tool_Chain_Example": "[API]->Baseline -> [AI->SearchDocsA] -> [Tool:web_search(libA docs)] -> [AI->SearchDocsB] -> [Tool:web_search(libB docs)] -> [AI->Compare&Explain]"169 },170 {171 "Scenario": "User asks 'generate unit tests for this function' (points at function)",172 "Profile": "P2_Write_Complete",173 "Key_Context": ["P0_Baseline(CursorPos -> Function Def)", "FunctionCode", "Project Testing Framework (if detectable)", "Imports"],174 "Tool_Chain_Example": "[API]->Baseline(find func def) -> [AI->IdentifyTestFramework?] -> [Tool:file_search(jest.config?)] -> [AI->GenerateTests] -> [Tool:edit_file(test file)]"175 }176 ]177}
Okay, I understand. I will provide 10 additional scenario variations, one per response. Each response will focus on a single scenario, outlining the triggering profile, the reasoning, and the key context/tools involved, following the structure you liked.