-
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e5af62e
feat: plan agent refinement, feature discovery, and telemetry instrum…
anandgupta42 57a2e78
fix: address CodeRabbit review comments
anandgupta42 7384fe2
feat: e2e tests, performance benchmarks, and UX gap fixes
anandgupta42 1fc5c05
test: plan layer safety e2e tests (68 tests)
anandgupta42 a5b4e44
merge: resolve conflicts with main (skill followups + sql findings)
anandgupta42 bc4287b
fix: add mongodb to devDependencies for typecheck resolution
anandgupta42 77dae71
Merge branch 'main' into feat/plan-agent-and-feature-discovery
anandgupta42 b24d84e
Merge branch 'main' into feat/plan-agent-and-feature-discovery
anandgupta42 17f4a19
fix: track suggestion failures in warehouse-add telemetry
anandgupta42 3b78d42
test: 125 simulated user scenarios for plan + suggestions
anandgupta42 adb6c7e
test: 40 real tool execution simulations with mocked Dispatcher
anandgupta42 3f5fcb3
docs: document plan refinement, feature discovery, and new telemetry …
anandgupta42 24234ff
fix: replace mock.module() with spyOn to prevent cross-file test poll…
anandgupta42 734d173
fix: reset dedup state in tests + replace passwords with fake values
anandgupta42 63b1dbd
Merge branch 'main' into feat/plan-agent-and-feature-discovery
anandgupta42 11bb99d
fix: replace all credential-like test values for GitGuardian
anandgupta42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
packages/opencode/src/altimate/tools/post-connect-suggestions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| /** | ||
| * 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. | ||
| * | ||
| * Deduplication: progressive suggestions are shown at most once per | ||
| * session per tool to avoid repetitive hints. | ||
| */ | ||
|
|
||
| import { Telemetry } from "../../telemetry" | ||
|
|
||
| export namespace PostConnectSuggestions { | ||
| export interface SuggestionContext { | ||
| warehouseType: string | ||
| schemaIndexed: boolean | ||
| dbtDetected: boolean | ||
| connectionCount: number | ||
| toolsUsedInSession: string[] | ||
| } | ||
|
|
||
| /** | ||
| * Set of progressive suggestion keys already shown in this process. | ||
| * Reset when the process restarts (per-session lifetime). | ||
| */ | ||
| const shownProgressiveSuggestions = new Set<string>() | ||
|
|
||
| /** Reset shown suggestions (useful for testing). */ | ||
| export function resetShownSuggestions(): void { | ||
| shownProgressiveSuggestions.clear() | ||
| } | ||
|
|
||
| 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, tool is unknown, or the | ||
| * suggestion was already shown in this session (deduplication). | ||
| */ | ||
| 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 | ||
| } | ||
|
|
||
| const suggestion = progression[lastToolUsed] ?? null | ||
| if (!suggestion) return null | ||
|
|
||
| // Deduplicate: only show each progressive suggestion once per session | ||
| if (shownProgressiveSuggestions.has(lastToolUsed)) { | ||
| return null | ||
| } | ||
| shownProgressiveSuggestions.add(lastToolUsed) | ||
|
|
||
| return suggestion | ||
| } | ||
|
|
||
| /** | ||
| * 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 { | ||
| const sessionId = Telemetry.getContext().sessionId || "unknown-session" | ||
| Telemetry.track({ | ||
| type: "feature_suggestion", | ||
| timestamp: Date.now(), | ||
| session_id: sessionId, | ||
| suggestion_type: opts.suggestionType, | ||
| suggestions_shown: opts.suggestionsShown, | ||
| warehouse_type: opts.warehouseType ?? "unknown", | ||
| }) | ||
| } catch { | ||
| // Telemetry must never break tool execution | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.