From 7f43f88a8384bbb3f7cc137d16bd1fb8b9839473 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 19:58:19 +0530 Subject: [PATCH 1/3] fix: project health follow-ups (per-call start folder, ${#arr}, disabled-session gate), cost planner label kept, altimate-dbt docs Co-Authored-By: Claude Sonnet 5.5 --- .claude-plugin/marketplace.json | 2 +- .../altimate-code/.claude-plugin/plugin.json | 2 +- plugins/altimate-code/CHANGELOG.md | 9 +++ plugins/altimate-code/README.md | 4 ++ .../hooks/features/cost.test.tsx | 6 ++ plugins/altimate-code/hooks/features/cost.tsx | 10 ++-- .../altimate-code/hooks/features/health.tsx | 31 +++++++--- plugins/altimate-code/hooks/health.test.tsx | 57 +++++++++++++++++-- 8 files changed, 101 insertions(+), 20 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 4ff3c997..454b9404 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -7,7 +7,7 @@ }, "metadata": { "description": "Altimate's Claude Code plugin — data tools through the altimate-code MCP server, or the model-free CLI where MCP is disallowed, plus delegation of long dbt jobs to the CLI agent.", - "version": "1.8.1" + "version": "1.8.3" }, "plugins": [ { diff --git a/plugins/altimate-code/.claude-plugin/plugin.json b/plugins/altimate-code/.claude-plugin/plugin.json index ff11cbb0..ca33181f 100644 --- a/plugins/altimate-code/.claude-plugin/plugin.json +++ b/plugins/altimate-code/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "altimate-code", "displayName": "Altimate Code", - "version": "1.8.1", + "version": "1.8.3", "description": "Gives Claude Code altimate-code's model-free data tools (column-level lineage, impact analysis, PII detection, data-diff, FinOps, query equivalence, dialect translation, warehouse queries) through its MCP server, or through `altimate tool run` when MCP servers are not allowed, with delegation to the altimate-code agent for long dbt jobs, access to a linked Altimate workspace's knowledge, and the workspace's team rules in each session.", "author": { "name": "AltimateAI", diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index 6031c1a6..578c39b6 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this plugin will be documented in this file. +## [1.8.3] — 2026-11-19 + +### Fixed +- Project health: a Bash command with its own `cd` is read from the folder it started in even when another Bash call finishes meanwhile (a subagent's); the start folder is kept per call. `echo ${#arr[@]}; git push` is found as a push. A session outside a dbt project no longer looks up the shell folder or holds a push. +- `/scan-cost` with no model keeps the planner label of the last Snowflake or Databricks estimate ("Snowflake plan estimate"). + +### Added +- The README explains `altimate-dbt`, the dbt command line that comes with altimate-code, what the agent uses it for, and that you do not need to run it. + ## [1.8.1] — 2026-11-19 ### Fixed diff --git a/plugins/altimate-code/README.md b/plugins/altimate-code/README.md index 0a86ac8a..ce9396b9 100644 --- a/plugins/altimate-code/README.md +++ b/plugins/altimate-code/README.md @@ -152,6 +152,10 @@ Opening a dbt folder runs two programs the repository supplies, with no action f Compile and validate runs a query on your warehouse after every model edit (`dbt show --limit 1`). On a warehouse that bills by bytes scanned or wakes a suspended warehouse for it, that costs money. Set the plugin's `dbt_mods` option to false (in `/config`) to turn all of the helpers off. +### altimate-dbt + +When Claude mentions `altimate-dbt`, it is the dbt command line that comes with altimate-code (`npm i -g @altimateai/altimate-code`, the same install as the plugin's engine). It finds your dbt project folder, Python environment and warehouse adapter by itself, and altimate-code's agent uses it instead of the raw dbt tool for better error messages. Its commands include `init`, `doctor`, `compile`, `build`, `run`, `test`, `deps`, `columns `, `graph` (lineage) and `execute ""` (a query through the dbt adapter). You do not need to run it yourself: Claude and the altimate-code agent call it when a task needs it, and the plugin's own dbt helpers above do not depend on it. See [altimate-dbt in the altimate-code docs](https://docs.altimate.sh/data-engineering/tools/dbt-tools/#altimate-dbt-cli). + ## Settings The plugin has seven settings, shown when you enable it (`userConfig` in `.claude-plugin/plugin.json`). All are optional: Claude Code may report them as "not set", and each then takes the default below. `dbt_mods` is used by the dbt helpers, `maxScanBytes` by the scan check (BigQuery, Snowflake, Databricks), `healthBlocksPush` and `healthConfigPath` by the project health check, the two comments settings by team comments, and `show_edit_impact` by the per-edit impact note. diff --git a/plugins/altimate-code/hooks/features/cost.test.tsx b/plugins/altimate-code/hooks/features/cost.test.tsx index b17fbfd8..7fa98f60 100644 --- a/plugins/altimate-code/hooks/features/cost.test.tsx +++ b/plugins/altimate-code/hooks/features/cost.test.tsx @@ -1613,6 +1613,12 @@ test('/scan-cost on Snowflake names the plan estimate and the verdict', async ($ ) }) +test('/scan-cost with no model keeps the plan estimate label of the last estimate', async ($, on) => { + await start($, on, { answers: { orders: planned('snowflake', 20 * GIB, '20.0 GiB') } }) + await $.command.run({ command: 'scan-cost', args: 'orders' } as any) + expect((await $.command.run({ command: 'scan-cost', args: '' } as any)).text).toBe('Last estimate: orders would scan 20.0 GiB (Snowflake plan estimate). Run /scan-cost for another.') +}) + test('/scan-cost on an older altimate-code over Databricks says a newer one is needed', async ($, on) => { await start($, on, { fallback: { success: true, supported: false, adapter: 'databricks' } }) expect((await $.command.run({ command: 'scan-cost', args: 'orders' } as any)).text).toBe( diff --git a/plugins/altimate-code/hooks/features/cost.tsx b/plugins/altimate-code/hooks/features/cost.tsx index 1303438f..be3f4136 100644 --- a/plugins/altimate-code/hooks/features/cost.tsx +++ b/plugins/altimate-code/hooks/features/cost.tsx @@ -157,7 +157,7 @@ export function register(on: On, context: FeatureContext) { const target = e.args.trim() if (!target) { const last = (await read($, costAtom))?.lastEstimate - return { text: last ? `Last estimate: ${last.target} would scan ${last.display}. Run /scan-cost for another.` : 'Run /scan-cost to estimate the scan of a model.' } + return { text: last ? `Last estimate: ${last.target} would scan ${last.display}${basisOf(last)}. Run /scan-cost for another.` : 'Run /scan-cost to estimate the scan of a model.' } } const began = await $.clock.now() // The wait is short (the user is looking at the screen); the estimate's own budget starts when the wait ends, at the latest. @@ -168,7 +168,7 @@ export function register(on: On, context: FeatureContext) { const answer = await started.answer if (answer.kind === 'bytes') { await forgetUnsupported($) - await rememberEstimate($, target, answer.bytes, answer.display) + await rememberEstimate($, target, answer.bytes, answer.display, answer.planner) return { text: `${target} would scan ${answer.display}${basisOf(answer)}${verdict(answer.maxBytes)}` } } return { text: answer.kind === 'unsupported' ? `No estimate: ${unsupportedWhy(answer.adapter)}.` : `No estimate: ${answer.reason}` } @@ -353,7 +353,7 @@ async function gate($: EngineInterface, e: BashCall, mine: { note?: object }): P mine.note = { label, bytes: answer.maxBytes, display: answer.display, planner: answer.planner } overNow.set(e.command, mine.note as { label: string; bytes: number; display: string; planner?: string }) } - await rememberEstimate($, label, answer.bytes, answer.display) + await rememberEstimate($, label, answer.bytes, answer.display, answer.planner) if (answer.maxBytes <= limitBytes) lines.push(`cost · ${label} would scan ${answer.display}${basisOf(answer)}`) else over.push({ label, bytes: answer.maxBytes, point: answer.bytes, display: answer.display, planner: answer.planner }) } @@ -763,10 +763,10 @@ async function estimateWithin($: EngineInterface, args: { model?: string; sql?: return done.answer } -async function rememberEstimate($: EngineInterface, target: string, bytes: number, display: string) { +async function rememberEstimate($: EngineInterface, target: string, bytes: number, display: string, planner?: string) { // What is shown never decides the gate: a failure here must not let a scan the gate knows is over the limit through. try { - await update($, costAtom, prev => ({ ...(prev ?? FRESH), lastEstimate: { target, bytes, display } })) + await update($, costAtom, prev => ({ ...(prev ?? FRESH), lastEstimate: { target, bytes, display, ...(planner && { planner }) } })) await setStatusPart($, 'cost', `scan ≈ ${display}`) } catch {} } diff --git a/plugins/altimate-code/hooks/features/health.tsx b/plugins/altimate-code/hooks/features/health.tsx index 030f5588..4178b61e 100644 --- a/plugins/altimate-code/hooks/features/health.tsx +++ b/plugins/altimate-code/hooks/features/health.tsx @@ -264,8 +264,9 @@ export function simpleCommands(line: string): string[][] { } for (let i = 0; i < line.length; i++) { const c = line[i]! - if (c === '#' && !inWord) { + if (c === '#' && !inWord && !(line[i - 1] === '{' && line[i - 2] === '$')) { // An unquoted `#` at the start of a word is a comment to the end of the line: its quotes and commands are text. + // The `#` of `${#name}` (a length) is not one: `{` ends the word before it. const end = line.indexOf('\n', i) i = end < 0 ? line.length : end - 1 } else if (c === "'") { @@ -647,7 +648,7 @@ export async function sessionStart($: EngineInterface, e: Args<'session.start'>) enabled = false toldProblem = null known = [] - shellBefore = null + shellBefore.clear() projects.clear() await update($, healthAtom, () => fresh()) // The status line outlives a process: a part an earlier one left is cleared whether or not this one drew it. @@ -703,9 +704,11 @@ export function pushRefusal(blocks: unknown, command: string, issues: readonly H * they have new health issues. A check that cannot run or does not finish holds it too. */ export async function bashGate($: EngineInterface, e: BashCall): Promise<{ deny: string } | null> { + // A session outside a dbt project has no check to wait for and no folder to note. + if (!enabled) return null if (!(options.healthBlocksPush === true || options.healthBlocksPush === 'true') || !isGitPush(e.command)) { // Where the shell is before this command runs: its own `cd`s are read from there, and `bashAfter` sees the folder after them. - if (CHANGES_FOLDER.test(e.command)) shellBefore = { command: e.command, folder: await within($, GATE_WAIT_MS, shellFolder($)) } + if (CHANGES_FOLDER.test(e.command)) noteFolder(e, await within($, GATE_WAIT_MS, shellFolder($))) return null } // The whole decision, folder lookups included, is bounded inside the chain's deadline: past it the gate is given up on and the push runs. @@ -721,7 +724,7 @@ async function decide($: EngineInterface, e: BashCall): Promise<{ deny: string } const startedAt = await $.clock.now() // An edit in the same command would run before any check of it. const here = await shellFolder($) - if (CHANGES_FOLDER.test(e.command)) shellBefore = { command: e.command, folder: here } + if (CHANGES_FOLDER.test(e.command)) noteFolder(e, here) for (const name of filesWrittenBy(e.command)) if (await isModelFile($, name.startsWith('/') || /^[A-Za-z]:/.test(name) ? name : `${here}/${name}`)) return hold(`this command changes the model file ${name} and pushes in one go, so the change is not checked first. Run them as separate commands.`) // With nothing changed this session there is nothing to wait for or hold. if (((await read($, healthAtom))?.touched.length ?? 0) === 0) return 'run' @@ -737,8 +740,16 @@ async function decide($: EngineInterface, e: BashCall): Promise<{ deny: string } return pushRefusal(options.healthBlocksPush, e.command, state?.issues ?? []) ?? 'run' } -// The folder noted before a command with its own `cd` ran; `folder` is null when the lookup ran out of time. -let shellBefore: { command: string; folder: string | null } | null = null +// The folder noted before each command with its own `cd` ran, by call (by command when the call has no id); `folder` is null when the lookup ran out of time. +// Calls can overlap (a subagent's), so one slot would lose a start folder. +const shellBefore = new Map() +const callKey = (e: BashCall) => e.tool_use_id ?? e.command +function noteFolder(e: BashCall, folder: string | null) { + shellBefore.delete(callKey(e)) + shellBefore.set(callKey(e), folder) + // A call a later gate refused never reaches its after-phase: only the newest notes are kept. + for (const old of [...shellBefore.keys()].slice(0, -50)) shellBefore.delete(old) +} const CHANGES_FOLDER = /\b(cd|pushd)\b/ /** The folder the session's shell is in now; the session's root when the host does not say. */ @@ -748,13 +759,15 @@ async function shellFolder($: EngineInterface): Promise { /** A model file Bash writes (a `sed -i`, a redirect, a `git checkout -- file`) is checked like one Claude edited. */ export async function bashAfter($: EngineInterface, e: BashCall, result: ToolCallResult): Promise { + if (!enabled) return const root = await $.session.root().catch(() => '') // A relative name is relative to the folder the session's shell is in now: an earlier `cd` moved it. // A command with its own `cd` is read from the folder it started in, which the gate noted. // A note belongs to its own command; a command with a `cd` whose start is unknown is read from the session's root, where it began. - const noted = shellBefore?.command === e.command ? shellBefore : null - shellBefore = null - const here = noted ? (noted.folder ?? root) : CHANGES_FOLDER.test(e.command) ? root : await shellFolder($) + const noted = shellBefore.has(callKey(e)) + const folder = shellBefore.get(callKey(e)) ?? null + shellBefore.delete(callKey(e)) + const here = noted ? (folder ?? root) : CHANGES_FOLDER.test(e.command) ? root : await shellFolder($) for (const name of filesWrittenBy(e.command)) await markChanged($, name.startsWith('/') || /^[A-Za-z]:/.test(name) ? name : `${here}/${name}`, root) } diff --git a/plugins/altimate-code/hooks/health.test.tsx b/plugins/altimate-code/hooks/health.test.tsx index 4be2ac8e..42b14bb7 100644 --- a/plugins/altimate-code/hooks/health.test.tsx +++ b/plugins/altimate-code/hooks/health.test.tsx @@ -1,7 +1,7 @@ import { expect, mock, test as engineTest } from 'claude-code/testing' import { PHASE_TIMEOUT_MS } from './tool-chain' -import { GATE_WAIT_MS, bandText, canonical, configPathProblem, filesWrittenBy, isGitPush, modelsOfFiles, newIssues, pairKey, pushRefusal, reportText, simpleCommands, toolArgs } from './features/health' +import { GATE_WAIT_MS, bandText, bashAfter, canonical, configPathProblem, filesWrittenBy, isGitPush, modelsOfFiles, newIssues, pairKey, pushRefusal, reportText, simpleCommands, toolArgs } from './features/health' // These tests are about the health check's own lines: the dbt helpers (their doctor and compile lines) are left off. const test = ((name: string, ...rest: any[]) => { @@ -61,7 +61,7 @@ type Options = { /** Holds the folder lookup while it returns a promise. */ holdCwd?: () => Promise | undefined /** Called when the Bash command itself runs, between the gate and the after-phase. */ - onCall?: () => void + onCall?: () => Promise | void /** Called at each project lookup; a promise it returns holds the lookup. */ onExists?: () => Promise | void } @@ -114,8 +114,8 @@ async function start($: any, on: any, options: Options, session: { isInteractive on('fs.read', () => ({ value: '' })) on('tool.list', () => ({ value: [] })) on('mcp.connect', () => ({ value: { isConnected: false, reason: 'not_connected', message: 'off' } })) - on('tool.call', () => { - options.onCall?.() + on('tool.call', async () => { + await options.onCall?.() return { result: { ok: true } } }) let run = 0 @@ -533,6 +533,8 @@ test('a comment never hides the push that follows it, and a push inside a commen expect(isGitPush('echo x # ; git push')).toBe(false) expect(isGitPush('git status # git push')).toBe(false) expect(isGitPush('echo a#b && git push')).toBe(true) + expect(isGitPush('echo ${#arr[@]}; git push')).toBe(true) + expect(isGitPush('echo $# ${#x}; git push')).toBe(true) }) test('an unnamed YAML file edited before the baseline lands does not empty the baseline', async ($, on) => { @@ -862,3 +864,50 @@ test('the band line and the report', () => { test('the push gate waits for less than the tool chain gives a phase, so a held push is never given up on', () => { expect(GATE_WAIT_MS).toBeLessThan(PHASE_TIMEOUT_MS) }) + +test('a Bash call that finishes while another is running leaves the other its own start folder', async ($, on) => { + let inner = false + const options: Options = { + runs: [[], [NEW_STG]], + cwd: `${ROOT}/models`, + onCall: async () => { + if (inner) return + inner = true + await $.tool.call({ ...command('ls'), tool_use_id: 'b' }) + }, + } + const { clock, calls, toasts } = await start($, on, options) + await $.tool.call({ ...command(`cd staging && sed -i 's/a/b/' stg_orders.sql`), tool_use_id: 'a' }) + await endTurn($, clock, 't1') + expect(calls).toHaveLength(2) + expect(toasts).toEqual(['◆ 1 new health issue · stg_orders: hard coded references · /health']) +}) + +let stall = false + +test('a command with its own cd whose start folder could not be read in time is read from the session root', async ($, on) => { + const never = new Promise(() => {}) + const { clock, calls, toasts } = await start($, on, { runs: [[], [NEW_STG]], cwd: `${ROOT}/models/staging`, holdCwd: () => (stall ? never : undefined) }) + stall = true + const pending = $.tool.call(command(`cd models/staging && sed -i 's/a/b/' stg_orders.sql`)) + await clock.advance(GATE_WAIT_MS + 100) + await pending + stall = false + await endTurn($, clock, 't1') + expect(calls).toHaveLength(2) + expect(toasts).toEqual(['◆ 1 new health issue · stg_orders: hard coded references · /health']) +}) + +test('a YAML file no insight names, edited after the baseline, counts every model as edited', async ($, on) => { + const { clock, calls, toasts } = await start($, on, { runs: [[OLD_STG, OLD_FCT], [OLD_STG, OLD_FCT, NEW_FCT]] }) + await $.tool.call(edit(`${ROOT}/models/_sources.yml`)) + await endTurn($, clock, 't1') + expect(calls).toHaveLength(2) + expect(toasts).toEqual(['◆ 1 new health issue · fct_orders: model fanout · /health']) +}) + +test('with the push gate on, a session opened above its dbt project holds nothing', { options: { healthBlocksPush: true } }, async ($, on) => { + await start($, on, { runs: [[]], projects: [`${ROOT}/dbt`] }) + const allowed: any = await $.tool.call(command(`cd dbt && echo x > models/a.sql && git push`)) + expect(allowed?.deny).toBeUndefined() +}) From 2a089449ed321d0850d38db3f30a765d3d60cc3b Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 20:15:09 +0530 Subject: [PATCH 2/3] fix: the last estimate's type carries its planner Co-Authored-By: Claude Sonnet 5.5 --- plugins/altimate-code/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/altimate-code/types/index.d.ts b/plugins/altimate-code/types/index.d.ts index 3b9c021a..207b47a7 100644 --- a/plugins/altimate-code/types/index.d.ts +++ b/plugins/altimate-code/types/index.d.ts @@ -504,7 +504,7 @@ export interface CostState { /** The warehouse with no estimate (not BigQuery, Snowflake or Databricks, or an altimate-code too old for it), once the tool said so: nothing is estimated after that. */ unsupportedAdapter: string | null /** The newest estimate: what was estimated, in bytes, as the dry run or the planner gave it. */ - lastEstimate: { target: string; bytes: number; display: string } | null + lastEstimate: { target: string; bytes: number; display: string; planner?: string } | null /** The command held for being over the limit, until it is allowed or a later dbt command is estimated under the limit; `bytes` is its scan's upper bound, `planner` the warehouse whose planner made the estimate (none for a dry run). */ held: { command: string; target: string; bytes: number; display: string; planner?: string } | null /** /allow-scan was given for the held command: that same command runs once. */ From df2497aaa5dbed1b07d4ed99a9ed82e5184e60e2 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 20:18:02 +0530 Subject: [PATCH 3/3] test: drop an unused import Co-Authored-By: Claude Sonnet 5.5 --- plugins/altimate-code/hooks/health.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/altimate-code/hooks/health.test.tsx b/plugins/altimate-code/hooks/health.test.tsx index 42b14bb7..627591cb 100644 --- a/plugins/altimate-code/hooks/health.test.tsx +++ b/plugins/altimate-code/hooks/health.test.tsx @@ -1,7 +1,7 @@ import { expect, mock, test as engineTest } from 'claude-code/testing' import { PHASE_TIMEOUT_MS } from './tool-chain' -import { GATE_WAIT_MS, bandText, bashAfter, canonical, configPathProblem, filesWrittenBy, isGitPush, modelsOfFiles, newIssues, pairKey, pushRefusal, reportText, simpleCommands, toolArgs } from './features/health' +import { GATE_WAIT_MS, bandText, canonical, configPathProblem, filesWrittenBy, isGitPush, modelsOfFiles, newIssues, pairKey, pushRefusal, reportText, simpleCommands, toolArgs } from './features/health' // These tests are about the health check's own lines: the dbt helpers (their doctor and compile lines) are left off. const test = ((name: string, ...rest: any[]) => {