-
Notifications
You must be signed in to change notification settings - Fork 35
feat: plan agent refinement, feature discovery #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e5af62e
57a2e78
7384fe2
1fc5c05
a5b4e44
bc4287b
77dae71
b24d84e
17f4a19
3b78d42
adb6c7e
3f5fcb3
24234ff
734d173
63b1dbd
11bb99d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| /** | ||
| * Post-connect feature suggestions and progressive disclosure. | ||
| * | ||
| * After warehouse connect, users often don't know what to do next. | ||
| * This module provides contextual suggestions based on the user's | ||
| * environment and progressive next-step hints after tool usage. | ||
| */ | ||
|
|
||
| import { Telemetry } from "../../telemetry" | ||
|
|
||
| export namespace PostConnectSuggestions { | ||
| export interface SuggestionContext { | ||
| warehouseType: string | ||
| schemaIndexed: boolean | ||
| dbtDetected: boolean | ||
| connectionCount: number | ||
| toolsUsedInSession: string[] | ||
| } | ||
|
|
||
| export function getPostConnectSuggestions(ctx: SuggestionContext): string { | ||
| const suggestions: string[] = [] | ||
|
|
||
| if (!ctx.schemaIndexed) { | ||
| suggestions.push( | ||
| "Index your schema — enables SQL analysis, column-level lineage, and data quality checks. Use the schema_index tool.", | ||
| ) | ||
| } | ||
|
|
||
| suggestions.push( | ||
| "Run SQL queries against your " + | ||
| ctx.warehouseType + | ||
| " warehouse using sql_execute", | ||
| ) | ||
| suggestions.push( | ||
| "Analyze SQL quality and find potential issues with sql_analyze", | ||
| ) | ||
|
|
||
| if (ctx.dbtDetected) { | ||
| suggestions.push( | ||
| "dbt project detected — try /dbt-develop to help build models or /dbt-troubleshoot to debug issues", | ||
| ) | ||
| } | ||
|
|
||
| suggestions.push( | ||
| "Trace data lineage across your models with lineage_check", | ||
| ) | ||
| suggestions.push("Audit for PII exposure with schema_detect_pii") | ||
|
|
||
| if (ctx.connectionCount > 1) { | ||
| suggestions.push("Compare data across warehouses with data_diff") | ||
| } | ||
|
|
||
| return ( | ||
| "\n\n---\nAvailable capabilities for your " + | ||
| ctx.warehouseType + | ||
| " warehouse:\n" + | ||
| suggestions.map((s, i) => `${i + 1}. ${s}`).join("\n") | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Progressive disclosure: suggest next tool based on what was just used. | ||
| * Returns null if no suggestion applies or tool is unknown. | ||
| */ | ||
| export function getProgressiveSuggestion( | ||
| lastToolUsed: string, | ||
| ): string | null { | ||
| const progression: Record<string, string | null> = { | ||
| sql_execute: | ||
| "Tip: Use sql_analyze to check this query for potential issues, performance optimizations, and best practices.", | ||
| sql_analyze: | ||
| "Tip: Use schema_inspect to explore the tables and columns referenced in your query.", | ||
| schema_inspect: | ||
| "Tip: Use lineage_check to see how this data flows through your models.", | ||
| schema_index: | ||
| "Schema indexed! You can now use sql_analyze for quality checks, schema_inspect for exploration, and lineage_check for data flow analysis.", | ||
| warehouse_add: null, // Handled by post-connect suggestions | ||
| } | ||
| return progression[lastToolUsed] ?? null | ||
| } | ||
|
|
||
| /** | ||
| * Track that feature suggestions were shown, for measuring discovery rates. | ||
| */ | ||
| export function trackSuggestions(opts: { | ||
| suggestionType: | ||
| | "post_warehouse_connect" | ||
| | "dbt_detected" | ||
| | "progressive_disclosure" | ||
| suggestionsShown: string[] | ||
| warehouseType?: string | ||
| }): void { | ||
| try { | ||
| Telemetry.track({ | ||
| type: "feature_suggestion", | ||
| timestamp: Date.now(), | ||
| session_id: Telemetry.getContext().sessionId, | ||
| suggestion_type: opts.suggestionType, | ||
| suggestions_shown: opts.suggestionsShown, | ||
| warehouse_type: opts.warehouseType ?? "unknown", | ||
| }) | ||
| } catch { | ||
| // Telemetry must never break tool execution | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| import z from "zod" | ||
| import { Tool } from "../../tool/tool" | ||
| import { Dispatcher } from "../native" | ||
| // altimate_change start — post-connect feature suggestions | ||
| import { PostConnectSuggestions } from "./post-connect-suggestions" | ||
| // altimate_change end | ||
|
|
||
| export const WarehouseAddTool = Tool.define("warehouse_add", { | ||
| description: | ||
|
|
@@ -41,10 +44,49 @@ IMPORTANT: For private key file paths, always use "private_key_path" (not "priva | |
| }) | ||
|
|
||
| if (result.success) { | ||
| // altimate_change start — append post-connect feature suggestions | ||
| let output = `Successfully added warehouse '${result.name}' (type: ${result.type}).\n\nUse warehouse_test to verify connectivity.` | ||
| try { | ||
| const schemaCache = await Dispatcher.call("schema.cache_status", {}).catch(() => null) | ||
| const schemaIndexed = (schemaCache?.total_tables ?? 0) > 0 | ||
| const warehouseList = await Dispatcher.call("warehouse.list", {}).catch(() => ({ warehouses: [] })) | ||
|
|
||
| let dbtDetected = false | ||
| try { | ||
| const { detectDbtProject } = await import("./project-scan") | ||
| const dbtInfo = await detectDbtProject(process.cwd()) | ||
| dbtDetected = dbtInfo.found | ||
| } catch { | ||
| // project-scan unavailable — skip dbt detection | ||
| } | ||
|
|
||
| const ctx: PostConnectSuggestions.SuggestionContext = { | ||
| warehouseType: result.type, | ||
| schemaIndexed, | ||
| dbtDetected, | ||
| connectionCount: warehouseList.warehouses.length, | ||
| toolsUsedInSession: [], | ||
| } | ||
| output += PostConnectSuggestions.getPostConnectSuggestions(ctx) | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const suggestionsShown = ["sql_execute", "sql_analyze", "lineage_check", "schema_detect_pii"] | ||
| if (!schemaIndexed) suggestionsShown.unshift("schema_index") | ||
| if (dbtDetected) suggestionsShown.push("dbt_develop", "dbt_troubleshoot") | ||
| if (warehouseList.warehouses.length > 1) suggestionsShown.push("data_diff") | ||
| PostConnectSuggestions.trackSuggestions({ | ||
| suggestionType: "post_warehouse_connect", | ||
| suggestionsShown, | ||
| warehouseType: result.type, | ||
| }) | ||
| } catch { | ||
| // Suggestions must never break the add flow | ||
|
||
| } | ||
| // altimate_change end | ||
|
|
||
| return { | ||
| title: `Add '${args.name}': OK`, | ||
| metadata: { success: true, name: result.name, type: result.type }, | ||
| output: `Successfully added warehouse '${result.name}' (type: ${result.type}).\n\nUse warehouse_test to verify connectivity.`, | ||
| output, | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.