-
Notifications
You must be signed in to change notification settings - Fork 3
fix: make altimate-dbt available in bash tool PATH
#308
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,8 +17,52 @@ import { Shell } from "@/shell/shell" | |||||||||||||||||||||||||
| import { BashArity } from "@/permission/arity" | ||||||||||||||||||||||||||
| import { Truncate } from "./truncation" | ||||||||||||||||||||||||||
| import { Plugin } from "@/plugin" | ||||||||||||||||||||||||||
| import { existsSync } from "fs" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const MAX_METADATA_LENGTH = 30_000 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // altimate_change start - resolve dbt-tools/bin for PATH injection | ||||||||||||||||||||||||||
| // dbt-tools is a sibling workspace package that provides the `altimate-dbt` CLI. | ||||||||||||||||||||||||||
| // Without this, the agent can't find `altimate-dbt` and falls back to raw `dbt`. | ||||||||||||||||||||||||||
| const dbtToolsBin = lazy(() => { | ||||||||||||||||||||||||||
| const candidates: string[] = [] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 1. Explicit env var override (highest priority) | ||||||||||||||||||||||||||
| if (process.env.ALTIMATE_DBT_TOOLS_BIN) { | ||||||||||||||||||||||||||
| candidates.push(process.env.ALTIMATE_DBT_TOOLS_BIN) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 2. Dev mode: resolve from source tree | ||||||||||||||||||||||||||
| // import.meta.dirname = packages/opencode/src/tool → ../../../../dbt-tools/bin | ||||||||||||||||||||||||||
| if (import.meta.dirname && !import.meta.dirname.startsWith("/$bunfs")) { | ||||||||||||||||||||||||||
| candidates.push(path.resolve(import.meta.dirname, "../../../../dbt-tools/bin")) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 3. Compiled binary: resolve from the real binary location | ||||||||||||||||||||||||||
| // Binary at: .../dist/@altimateai/altimate-code-<platform>/bin/altimate | ||||||||||||||||||||||||||
| // Walk up to the package root and look for dbt-tools as sibling | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| const binDir = path.dirname(process.execPath) | ||||||||||||||||||||||||||
| // Walk up to find a directory containing dbt-tools/bin | ||||||||||||||||||||||||||
| let dir = binDir | ||||||||||||||||||||||||||
| for (let i = 0; i < 8; i++) { | ||||||||||||||||||||||||||
| candidates.push(path.join(dir, "dbt-tools", "bin")) | ||||||||||||||||||||||||||
| candidates.push(path.join(dir, "packages", "dbt-tools", "bin")) | ||||||||||||||||||||||||||
| dir = path.dirname(dir) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } catch {} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 4. Fallback: node_modules/.bin in cwd | ||||||||||||||||||||||||||
| candidates.push(path.resolve(process.cwd(), "node_modules", ".bin")) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| for (const candidate of candidates) { | ||||||||||||||||||||||||||
| if (existsSync(path.join(candidate, "altimate-dbt"))) { | ||||||||||||||||||||||||||
| return candidate | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+58
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Windows compatibility: binary may have On Windows, npm creates 🛠️ Proposed fix to handle Windows extensions+const DBT_BINARY = process.platform === "win32" ? "altimate-dbt.cmd" : "altimate-dbt"
+
for (const candidate of candidates) {
- if (existsSync(path.join(candidate, "altimate-dbt"))) {
+ if (existsSync(path.join(candidate, DBT_BINARY))) {
return candidate
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| return undefined | ||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||
| // altimate_change end | ||||||||||||||||||||||||||
| const DEFAULT_TIMEOUT = Flag.OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS || 2 * 60 * 1000 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export const log = Log.create({ service: "bash-tool" }) | ||||||||||||||||||||||||||
|
|
@@ -164,12 +208,19 @@ export const BashTool = Tool.define("bash", async () => { | |||||||||||||||||||||||||
| { cwd, sessionID: ctx.sessionID, callID: ctx.callID }, | ||||||||||||||||||||||||||
| { env: {} }, | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| // altimate_change start - prepend dbt-tools/bin to PATH so `altimate-dbt` is findable | ||||||||||||||||||||||||||
| const extraPath = dbtToolsBin() | ||||||||||||||||||||||||||
| const envPATH = extraPath | ||||||||||||||||||||||||||
| ? `${extraPath}${path.delimiter}${process.env.PATH ?? ""}` | ||||||||||||||||||||||||||
| : process.env.PATH | ||||||||||||||||||||||||||
| // altimate_change end | ||||||||||||||||||||||||||
| const proc = spawn(params.command, { | ||||||||||||||||||||||||||
| shell, | ||||||||||||||||||||||||||
| cwd, | ||||||||||||||||||||||||||
| env: { | ||||||||||||||||||||||||||
| ...process.env, | ||||||||||||||||||||||||||
| ...shellEnv.env, | ||||||||||||||||||||||||||
| ...(extraPath ? { PATH: envPATH } : {}), | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| stdio: ["ignore", "pipe", "pipe"], | ||||||||||||||||||||||||||
| detached: process.platform !== "win32", | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor grammar: "Floating-point" should be hyphenated.
"Floating-point" is a compound adjective modifying "precision" and should be hyphenated.
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[uncategorized] ~108-~108: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...y. The project must be fully green. - Floating point precision: Use CAST(x AS DECIMAL) or ...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
🤖 Prompt for AI Agents