Repository navigation
Conversation
Each feature gets its own file under hooks/features/, called by name from features/index.ts in a fixed order: its own hooks, the session and turn events, its band line and its tool-call phases. One tool.call hook (tool-chain.ts) runs Bash and file handling in fixed phases: bashRewrite, bashGate, the call, bashAfter, editAfter, readOrEditAfter. The status line is built from parts (status-line.ts). runTool moves to altimate-cli.ts with a `write` option that goes through the CLI with --allow-write. dbt-command.ts finds the dbt invocations in a shell command line. New userConfig fields: maxScanBytes, healthBlocksPush, healthConfigPath, commentsPollSeconds, commentsInContext. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r and /target Claude's dbt commands get --defer --state <dir> (and --favor-state) right after the subcommand when the project's Power User defer setting is on, unless the command already sets them. /defer status|on|off|reset and /target <name> change this for the session; the status line shows the target and defer state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Subshells after keywords, case patterns, process substitution, arrays, arithmetic and function definitions parse again; quotes in a heredoc inside a substitution are text; a function or case pattern named dbt is not an invocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ps old dbt's skip list, and survives a new session The rewrite checks where the command runs (cd, pushd, --project-dir, DBT_PROJECT_DIR, Windows paths); deps, clean, debug, init, docs, source and retry get no --defer; a new session clears the status part; a failed read is tried again after a minute; the read in flight is owned by its own session. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…anges and exports it cannot follow, and keeps /defer reset from overwriting a newer session Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review round 1 (independent
Attack-the-fix gates: run 1 found residual gaps (fixed), run 2 found quoted-word bypasses (fixed), run 3 found three more quoting cases (fixed in the last commit; not re-gated because the gate cap is two re-runs). The lexical shell reading here is a heuristic: where it cannot tell, it leaves the command as written, and a skipped rewrite means defer does not apply, never a wrong one.
|
…this one, and DBT_DEFER settings of the user Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Final review round (claude -p and codex exec, fresh processes). Fixed in a74e10c: a cd inside a subshell or backticks now skips the rewrite; --project-dir must name this project exactly (a folder below it may be its own project); DBT_DEFER / DBT_DEFER_STATE / DBT_FAVOR_STATE set inline or exported are treated as the user's own choice. Tests added. Not changed: --target between a group word and its subcommand (dbt source/docs) is accepted by dbt 1.10 (checked against the installed CLI); the shell's carried folder versus the session root is a known limit of the line reading, where it cannot tell it skips. These fixes were not re-gated, so the PR stays draft. |
|
review-loop: APPROVED at a74e10c |
| })) | ||
| const state = await started | ||
| // Another session's read must not be dropped by a caller that was waiting on this one. | ||
| if (loading === started) loading = null |
There was a problem hiding this comment.
[WARNING]: A rejected shared read is never cleared, so defer dies silently for the rest of the session.
started is stored in loading before it settles. If load() rejects, or publish inside the .then rejects, await started throws here and this line never runs, so loading keeps the rejected promise; every later ensure() reuses it through ??= and rejects again. featuresBashRewrite swallows that error (features/index.ts:242), so no dbt command is rewritten and /defer//target fail until the next session.start. This is reachable when a $ call on a session that is going away throws (the same engine-gone case altimate-cli.ts:38-41 documents), or when the status-line update fails. Clear loading in a finally, and cover the rejection path in defer.test.ts (the existing retry test only covers a returned failure).
There was a problem hiding this comment.
Fixed in 970e648: ensure() now clears loading in a finally, so a rejected shared read is not reused by later calls (defer.tsx, ensure). I could not add a harness test for it: the test engine swallows a throwing process.run or ui.status handler inside runCli/setStatusPart, so the rejection never reaches ensure() from a test. The existing retry test still covers the returned-failure path.
| const first = [...invocations].sort((a, b) => a.start - b.start)[0] | ||
| const project = resolvePath(projectDir, '.') | ||
| if (!first || !project) return false | ||
| const inside = (dir: string | null) => !!dir && (dir === project || dir.startsWith(`${project.replace(/\/+$/, '')}/`)) |
There was a problem hiding this comment.
[WARNING]: inside() also accepts a folder below the project, so a cd into a nested dbt project still gets this project's --defer --state (and the session --target).
runsInProject('cd analytics && dbt run', '/repo', '/repo') returns true even when /repo/analytics/dbt_project.yml exists, so dbt runs the nested project against /repo's production state directory. That contradicts the function's own goal (never rewrite for the wrong project) and is inconsistent with the exact-match rule added for --project-dir at line 154 with the rationale that a folder below it may be a separate dbt project. Check the effective project from dir (for example $.fs.exists(dir + '/dbt_project.yml') in bashRewrite, where $ is available) or require dir === project here too.
There was a problem hiding this comment.
Declined for this PR. cd models && dbt run into a folder below the project is deliberately rewritten and tested (defer.test.ts 'cd models && dbt run'), and telling that apart from a nested dbt project needs a filesystem check that the pure runsInProject does not have. A dbt project nested inside another is not a layout this feature supports; the exact-match rule for --project-dir stays because there the user names the folder outright. Noted as a known limit.
| await publish($, state) | ||
| return { text: `Defer cannot be turned on: ${state.reason ?? 'no state directory is configured for this project (dbt.deferConfigPerProject).'}` } | ||
| } | ||
| state = { ...state, override: word === 'on' } |
There was a problem hiding this comment.
[SUGGESTION]: /defer on|off (and /target <name> at line 296) publish after an awaited ensure() without the generation guard that /defer reset uses at lines 268-271. If the session restarts while that settings read is in flight (/clear, resume), the old handler resumes and writes its override/target into the new session's atom and status line, contradicting the 'for this session' promise. Capture generation before ensure() and skip publish when it changed, the same way reset does.
There was a problem hiding this comment.
Fixed in 970e648: /defer on|off and /target <name> capture generation before ensure() and skip publish when the session restarted meanwhile, as reset does.
| targets?: string[] | ||
| } | ||
|
|
||
| const dirname = (path: string) => path.replace(/[\\/]+[^\\/]*$/, '') || '/' |
There was a problem hiding this comment.
[SUGGESTION]: This dirname duplicates lineage.tsx:169 but behaves differently (dirname('/repo') is '/' here and '/repo' there), and findProject also duplicates the upward walk and downward scan of projectRoot/projectsBelow (lineage.tsx:173-225, which additionally skips SKIP_DIRS and caches). The copies have already diverged: the CD regex here follows if cd x; then dbt run; fi while the lineage one does not, so /lineage and /defer can resolve the same command to different folders/projects. The PR lists sharing this helper as a follow-up; doing it now prevents further drift.
There was a problem hiding this comment.
Declined for this PR; the PR description lists sharing the lineage helpers as a follow-up. The two dirname/findProject copies differ on purpose in small ways (root handling, the if cd x; then form) and merging them touches lineage.tsx and its tests, which this change should not.
| * folder (`cd`, `pushd`, `--project-dir`, `DBT_PROJECT_DIR`, uv's `--directory`) or one it cannot work out. | ||
| */ | ||
| export function runsInProject(command: string, root: string, projectDir: string): boolean { | ||
| if (/\s--(?:directory|project)[\s=]/.test(command)) return false |
There was a problem hiding this comment.
[SUGGESTION]: The --directory/--project guard reads the raw line, so a quoted flag slips past it: uv run "--directory=../b" dbt run does not match this regex (a quote follows the space, not --), while parseDbtCommand still finds the dbt run after the quoted launcher option, and the command is rewritten with this project's --defer --state even though uv runs dbt in ../b. The rest of the function deliberately checks the quote-stripped plain copy for exactly this class of bypass; run this check against plain too (or read --directory from the parsed invocation).
There was a problem hiding this comment.
Fixed in 970e648: the --directory/--project check now also runs on the quote-stripped copy, so uv run "--directory=../b" dbt run is not rewritten. Test: 'a quoted --directory or --project option is not followed'.
| export async function bashRewrite($: EngineInterface, e: BashCall): Promise<string | null> { | ||
| // Most commands name no dbt: they never cost the settings read. | ||
| if (!/\bdbt\b/.test(e.command)) return null | ||
| const state = await ensure($) |
There was a problem hiding this comment.
[SUGGESTION]: Any command that merely contains the word dbt triggers the settings read before the parser confirms an invocation. cat dbt_project.yml, grep -rn dbt models/ and git commit -m "dbt" all call ensure() and, on the first one in a session, wait up to the 60 s CLI timeout for dbt_defer_state (cliOnly) even though rewriteDeferCommand would return the command unchanged. parseDbtCommand is already imported; return null when it finds no invocation, and only then read the setting.
There was a problem hiding this comment.
Fixed in 970e648: bashRewrite returns null before the settings read unless parseDbtCommand finds an invocation, so cat dbt_project.yml and git commit -m "dbt" never read. Test: 'a command that only mentions dbt does not read the setting'.
| if (entry.kind !== 'dir' || entry.name.startsWith('.') || entry.name === 'node_modules') continue | ||
| if (await $.fs.exists(`${root}/${entry.name}/dbt_project.yml`).catch(() => false)) below.push(`${root}/${entry.name}`) | ||
| } | ||
| return below.length === 1 ? below[0]! : null |
There was a problem hiding this comment.
[SUGGESTION]: With two dbt projects directly under the session root (a common monorepo layout), findProject returns null, bashRewrite bails on !state.projectDir (line 331), so even cd dbt_a && dbt build gets no defer and /target answers 'No dbt project found' (line 295) for the whole session. runsInProject could judge that command if the project were resolved from its cd/--project-dir. Either resolve the project per command when there is more than one, or state this limit alongside the other known limits.
There was a problem hiding this comment.
Declined as a behavior change. With two projects directly under the session root there is no single project to read settings for, and picking per command would need a new resolution rule (and a read per project). /target already says 'No dbt project found' in that case. I will note it as a known limit in the description.
| if (next) { | ||
| await update($, status, () => next) | ||
| showStatusLine($, next) | ||
| await showStatusLine($, next) |
There was a problem hiding this comment.
[SUGGESTION]: refresh checks mine !== latestRefresh at line 104, then awaits update(status) and now this async showStatusLine (which itself awaits update and read inside setStatusPart). A refresh that passes the check can be suspended while a newer refresh runs to completion, then resume and overwrite the newer status atom/status-line part with its stale counts. Re-check mine !== latestRefresh right before showStatusLine (the previous synchronous $.ui.status call left no such window).
There was a problem hiding this comment.
Fixed in 970e648: refresh re-checks mine !== latestRefresh right before showStatusLine, after the awaited update (integrations.tsx). No separate test: the harness has no way to interleave two in-flight status reads at that point.
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (3 files changed in 970e648; 21 files in the PR)
Fix these issues in Kilo Cloud Previous Review Summary (commit a74e10c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit a74e10c)Status: 8 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (21 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 66.5K · Output: 15.6K · Cached: 508.7K |
…llowed, only real dbt invocations read the setting, /defer and /target skip a restarted session, stale status refresh is dropped Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
| // A folder change this does not follow (`popd`, `env -C`, `command cd`, a `cd` with no folder) leaves the folder unknown. | ||
| // Quotes and backslashes are dropped for this check: `command 'cd' ../b` and `env "-C" ../b` change folder like their plain forms. | ||
| const plain = command.replace(/["'\\]/g, '') | ||
| if (/\s--(?:directory|project)[\s=]/.test(command) || /\s--(?:directory|project)[\s=]/.test(plain)) return false |
There was a problem hiding this comment.
[SUGGESTION]: The raw-line test is redundant: plain is command with only quotes and backslashes removed, and this pattern's characters (whitespace, -, letters, =) are never among them, so every match in command is also a match in plain. The new plain check alone covers both the quoted and unquoted forms:
| if (/\s--(?:directory|project)[\s=]/.test(command) || /\s--(?:directory|project)[\s=]/.test(plain)) return false | |
| if (/\s--(?:directory|project)[\s=]/.test(plain)) return false |
|
review-loop: APPROVED at 970e648 |
What this does
Package P-04 (plugin half). When the project's dbt Power User defer setting is on, the dbt commands Claude runs get
--defer --state <dir>(and--favor-statewhen set) inserted right after the subcommand.hooks/features/defer.tsx: reads the setting once per session, on first need, through thedbt_defer_statetool (altimate-code PR feat: dbt_defer_state tool — Power User defer setting and profile target altimate-code#1734); abashRewritehandler in the shared tool chain inserts the flags for each dbt invocation (dbt build -s x,cd a && dbt run,uv run dbt test) that does not already carry--defer,--no-defer,--state,DBT_STATEand so on.deps,clean,debug,init,retry,docsandsourceare left alone./defer [status|on|off|reset]shows or overrides the setting for the session;/defer onsays why when no usable state directory is configured./target [<name>|reset]sets a session target; the rewrite adds--target <name>when it differs from the profile's default and the command names none. Names are checked against the profile's outputs.dbt dev · defer prod.DeferStateintypes/index.d.ts.Remote defer mode is reported by the tool as not supported yet, so it never rewrites commands.
The branch includes the foundation commit; retarget once the foundation PR merges. Merge after the altimate-code PR, since the plugin calls the CLI tool.
Known limits
dbt_project.ymlor symlinked folder below the project is treated as the project.cdtracking duplicates a smaller version inlineage.tsx; sharing it is a follow-up.Demo video
Testing
claude plugin test ./plugins/altimate-code: 233 pass, includinghooks/features/defer.test.ts(rewrite ofdbt build -s x,cd a && dbt run,uv run dbt test; no rewrite with--statepresent or defer off;/deferand/target; through-the-plugin rewrite).claude plugin validate --strict .passes.--strict ./plugins/altimate-codefails on warnings that the foundation commit already has (the existing lineage test file and the missing icon); this change adds none that fail.bash tests/*.shall pass.Demo video (hosted)
P-04.mp4 — watch on Notion (Altimate workspace; recorded from the approved head of this PR).
🤖 Generated with Claude Code