-
Notifications
You must be signed in to change notification settings - Fork 32
feat: skill follow-up suggestions to improve dbt experience #546
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
99aacab
feat(dbt-tools): build entire project when no --model flag given
mdesmet a885a7e
test(dbt-tools): add unit tests for build command routing
mdesmet 8db18a3
Merge branch 'main' into feat/dbt-build-project-shorthand
anandgupta42 b00c1cd
fix: address code review — remove `build-project` command, update hel…
anandgupta42 1afbecb
fix: add missing `fullOutput` field to satisfy `CommandProcessResult`…
anandgupta42 970b3c7
feat: add follow-up suggestions after skill completion to reduce firs…
anandgupta42 ae7ecca
Merge branch 'main' into feat/skill-followup-suggestions
anandgupta42 930a417
fix: address code review — truncation-safe followups, telemetry, immu…
anandgupta42 9341cae
test: add e2e tests for skill follow-up suggestions via `SkillTool.ex…
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { describe, test, expect, mock } from "bun:test" | ||
| import { build } from "../src/commands/build" | ||
| import type { DBTProjectIntegrationAdapter } from "@altimateai/dbt-integration" | ||
|
|
||
| function makeAdapter(overrides: Partial<DBTProjectIntegrationAdapter> = {}): DBTProjectIntegrationAdapter { | ||
| return { | ||
| unsafeBuildModelImmediately: mock(() => Promise.resolve({ stdout: "model built", stderr: "" })), | ||
| unsafeBuildProjectImmediately: mock(() => Promise.resolve({ stdout: "project built", stderr: "" })), | ||
| unsafeRunModelImmediately: mock(() => Promise.resolve({ stdout: "", stderr: "" })), | ||
| unsafeRunModelTestImmediately: mock(() => Promise.resolve({ stdout: "", stderr: "" })), | ||
| dispose: mock(() => Promise.resolve()), | ||
| ...overrides, | ||
| } as unknown as DBTProjectIntegrationAdapter | ||
| } | ||
|
|
||
| describe("build command", () => { | ||
| test("build without --model builds entire project", async () => { | ||
| const adapter = makeAdapter() | ||
| const result = await build(adapter, []) | ||
| expect(adapter.unsafeBuildProjectImmediately).toHaveBeenCalledTimes(1) | ||
| expect(adapter.unsafeBuildModelImmediately).not.toHaveBeenCalled() | ||
| expect(result).toEqual({ stdout: "project built" }) | ||
| }) | ||
|
|
||
| test("build --model <name> builds single model", async () => { | ||
| const adapter = makeAdapter() | ||
| const result = await build(adapter, ["--model", "orders"]) | ||
| expect(adapter.unsafeBuildModelImmediately).toHaveBeenCalledTimes(1) | ||
| expect(adapter.unsafeBuildModelImmediately).toHaveBeenCalledWith({ | ||
| plusOperatorLeft: "", | ||
| modelName: "orders", | ||
| plusOperatorRight: "", | ||
| }) | ||
| expect(adapter.unsafeBuildProjectImmediately).not.toHaveBeenCalled() | ||
| expect(result).toEqual({ stdout: "model built" }) | ||
| }) | ||
|
|
||
| test("build --model <name> --downstream sets plusOperatorRight", async () => { | ||
| const adapter = makeAdapter() | ||
| await build(adapter, ["--model", "orders", "--downstream"]) | ||
| expect(adapter.unsafeBuildModelImmediately).toHaveBeenCalledWith({ | ||
| plusOperatorLeft: "", | ||
| modelName: "orders", | ||
| plusOperatorRight: "+", | ||
| }) | ||
| }) | ||
|
|
||
| test("build surfaces stderr as error", async () => { | ||
| const adapter = makeAdapter({ | ||
| unsafeBuildProjectImmediately: mock(() => | ||
| Promise.resolve({ stdout: "partial output", stderr: "compilation error", fullOutput: "" }), | ||
| ), | ||
| }) | ||
| const result = await build(adapter, []) | ||
| expect(result).toEqual({ error: "compilation error", stdout: "partial output" }) | ||
| }) | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| // altimate_change start — skill follow-up suggestions for conversational engagement | ||
| export namespace SkillFollowups { | ||
| export interface Suggestion { | ||
| skill: string // skill name to suggest | ||
| label: string // short display label | ||
| description: string // why this is a good next step | ||
| condition?: string // optional: when this suggestion applies | ||
| } | ||
|
|
||
| // Map from skill name to follow-up suggestions | ||
| const FOLLOWUPS: Record<string, Suggestion[]> = { | ||
| "dbt-develop": [ | ||
| { | ||
| skill: "dbt-test", | ||
| label: "Add tests", | ||
| description: "Write schema tests and unit tests for the model you just created to ensure data quality.", | ||
| }, | ||
| { | ||
| skill: "dbt-docs", | ||
| label: "Document your model", | ||
| description: "Add descriptions to your model and columns in schema.yml for discoverability.", | ||
| }, | ||
| { | ||
| skill: "dbt-analyze", | ||
| label: "Check downstream impact", | ||
| description: "Analyze the blast radius of your changes on downstream models before merging.", | ||
| }, | ||
| { | ||
| skill: "sql-review", | ||
| label: "Review SQL quality", | ||
| description: "Run a quality gate on your SQL — lint for anti-patterns and grade readability.", | ||
| }, | ||
| ], | ||
| "dbt-troubleshoot": [ | ||
| { | ||
| skill: "dbt-test", | ||
| label: "Add regression tests", | ||
| description: "Now that the bug is fixed, add tests to prevent it from recurring.", | ||
| }, | ||
| { | ||
| skill: "dbt-analyze", | ||
| label: "Check downstream impact", | ||
| description: "Verify your fix didn't break downstream models.", | ||
| }, | ||
| { | ||
| skill: "dbt-develop", | ||
| label: "Improve the model", | ||
| description: "Refactor or extend the model now that it's working correctly.", | ||
| }, | ||
| ], | ||
| "dbt-test": [ | ||
| { | ||
| skill: "dbt-develop", | ||
| label: "Build more models", | ||
| description: "Continue building new models in your dbt project.", | ||
| }, | ||
| { | ||
| skill: "dbt-docs", | ||
| label: "Document tested models", | ||
| description: "Add documentation to the models you just tested.", | ||
| }, | ||
| ], | ||
| "dbt-docs": [ | ||
| { | ||
| skill: "dbt-test", | ||
| label: "Add tests", | ||
| description: "Add data quality tests for the models you just documented.", | ||
| }, | ||
| { | ||
| skill: "dbt-analyze", | ||
| label: "Analyze lineage", | ||
| description: "Review column-level lineage to ensure documentation matches data flow.", | ||
| }, | ||
| ], | ||
| "dbt-analyze": [ | ||
| { | ||
| skill: "dbt-test", | ||
| label: "Add tests for affected models", | ||
| description: "Add tests to downstream models that could be impacted by changes.", | ||
| }, | ||
| { | ||
| skill: "dbt-develop", | ||
| label: "Make the changes", | ||
| description: "Proceed with implementing the changes now that you understand the impact.", | ||
| }, | ||
| ], | ||
| "sql-review": [ | ||
| { | ||
| skill: "query-optimize", | ||
| label: "Optimize performance", | ||
| description: "Improve query performance based on the review findings.", | ||
| }, | ||
| { | ||
| skill: "sql-translate", | ||
| label: "Translate to another dialect", | ||
| description: "Port this SQL to a different database dialect.", | ||
| }, | ||
| ], | ||
| "sql-translate": [ | ||
| { | ||
| skill: "sql-review", | ||
| label: "Review translated SQL", | ||
| description: "Run a quality check on the translated SQL to catch dialect-specific issues.", | ||
| }, | ||
| ], | ||
| "query-optimize": [ | ||
| { | ||
| skill: "sql-review", | ||
| label: "Review optimized query", | ||
| description: "Run a quality gate on the optimized SQL.", | ||
| }, | ||
| { | ||
| skill: "cost-report", | ||
| label: "Check cost impact", | ||
| description: "Analyze how the optimization affects query costs.", | ||
| }, | ||
| ], | ||
| "cost-report": [ | ||
| { | ||
| skill: "query-optimize", | ||
| label: "Optimize expensive queries", | ||
| description: "Optimize the most expensive queries identified in the report.", | ||
| }, | ||
| ], | ||
| "pii-audit": [ | ||
| { | ||
| skill: "sql-review", | ||
| label: "Review SQL for PII exposure", | ||
| description: "Check specific queries for PII leakage.", | ||
| }, | ||
| ], | ||
| "lineage-diff": [ | ||
| { | ||
| skill: "dbt-analyze", | ||
| label: "Full impact analysis", | ||
| description: "Run a comprehensive impact analysis on the changed models.", | ||
| }, | ||
| { | ||
| skill: "dbt-test", | ||
| label: "Add tests for changed paths", | ||
| description: "Add tests covering the changed data flow paths.", | ||
| }, | ||
| ], | ||
| "schema-migration": [ | ||
| { | ||
| skill: "dbt-develop", | ||
| label: "Update dbt models", | ||
| description: "Update your dbt models to reflect the schema changes.", | ||
| }, | ||
| ], | ||
| } | ||
|
|
||
| // A special warehouse nudge for users who haven't connected yet | ||
| const WAREHOUSE_NUDGE = "**Tip:** Connect a warehouse to validate against real data. Run `/discover` to auto-detect your connections." | ||
|
|
||
| export function get(skillName: string): readonly Suggestion[] { | ||
| return Object.freeze(FOLLOWUPS[skillName] ?? []) | ||
| } | ||
|
|
||
| export function format(skillName: string): string { | ||
| const suggestions = get(skillName) | ||
| if (suggestions.length === 0) return "" | ||
|
|
||
| const lines = [ | ||
| "", | ||
| "---", | ||
| "", | ||
| "## What's Next?", | ||
| "", | ||
| "Now that this task is complete, here are suggested next steps:", | ||
| "", | ||
| ...suggestions.map( | ||
| (s, i) => `${i + 1}. **${s.label}** — ${s.description} → Use \`/skill ${s.skill}\` or just ask me.`, | ||
| ), | ||
| "", | ||
| WAREHOUSE_NUDGE, | ||
| "", | ||
| "*You can continue this conversation — just type your next request.*", | ||
| ] | ||
| return lines.join("\n") | ||
| } | ||
| } | ||
| // altimate_change end |
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.