Repository navigation
feat: foundation for the dbt Power User features #30
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
18 commits
Select commit
Hold shift + click to select a range
15c3392
feat: foundation for the dbt Power User features
hkaltai 4328fc3
fix: harden the dbt Power User feature wiring
hkaltai 6f6c89e
fix: read valid shell lines the dbt command parser refused
hkaltai 2b31340
fix: read a here-string inside a substitution as text, not a heredoc
hkaltai b36cbe6
fix: read a heredoc that follows an escaped < inside a substitution
hkaltai f681699
fix: invocation offsets skip prefix words, status parts clear per ses…
hkaltai c3ffdd8
Merge origin/main into feat/pu-mods-foundation
hkaltai 3fa4834
Harden the dbt command parser, feature phases and tool chain
hkaltai 7f472f5
Test that a status line that cannot be drawn does not stop session start
hkaltai 9409397
Describe the settings by what they control
hkaltai e243a67
Keep backslashes the shell keeps in quoted values; test the write rou…
hkaltai 830e784
Report no literal for a word the shell expands; launcher help runs no…
hkaltai 176e8b5
Say once, beside the phase deadline, what it means for a gate
hkaltai 4c8add5
Merge main and preserve integration regression coverage
hkaltai 2c494ec
fix: an expanded assignment ahead of a prefix word marks the call dyn…
hkaltai ac0d379
fix: read only each prefix's and launcher's own options; reword unuse…
hkaltai 2c98769
fix: exec -c clears dbt's environment, so it is not read; per-launche…
hkaltai d563dce
Merge remote-tracking branch 'origin/main' into feat/pu-mods-foundation
hkaltai 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { expect, test } from 'claude-code/testing' | ||
|
|
||
| import { runTool, within } from './altimate-cli' | ||
|
|
||
| /** A stand-in for `$` whose CLI answers every call and whose MCP connection attempts go through `connect`. */ | ||
| function standIn(connect: () => unknown, now = 0) { | ||
| const argvs: string[][] = [] | ||
| let mcpCalls = 0 | ||
| const $: any = { | ||
| process: { | ||
| run: async (argv: string[]) => { | ||
| argvs.push(argv) | ||
| return { exitCode: 0, stdout: JSON.stringify({ status: 'ok', output: 'done', metadata: { n: 1 } }) } | ||
| }, | ||
| }, | ||
| mcp: { | ||
| connect: async () => connect(), | ||
| // No answer: a call that does reach the server falls back to the CLI. | ||
| call: async () => (mcpCalls++, null), | ||
| }, | ||
| // A deadline that never fires, so the fallback is the no-answer one. | ||
| clock: { now: async () => now, after: () => {} }, | ||
| } | ||
| return { $, argvs, mcpCalls: () => mcpCalls } | ||
| } | ||
|
|
||
| test('a read call goes without --allow-write; a write call goes through the CLI with it', async () => { | ||
| const { $, argvs } = standIn(() => null) | ||
| expect(await runTool($, 'dbt_manifest', { a: 1 })).toEqual({ metadata: { n: 1 }, text: 'done', ok: true }) | ||
| expect(await runTool($, 'dbt_manifest', { a: 1 }, { write: true })).toEqual({ metadata: { n: 1 }, text: 'done', ok: true }) | ||
| expect(argvs.map(argv => argv.slice(1))).toEqual([ | ||
| ['tool', 'run', 'dbt_manifest', '--args', '{"a":1}', '--json'], | ||
| ['tool', 'run', 'dbt_manifest', '--args', '{"a":1}', '--json', '--allow-write'], | ||
| ]) | ||
| }) | ||
|
|
||
| test('a write call never asks the MCP server, even when one is connected', async () => { | ||
| let connects = 0 | ||
| const { $, argvs, mcpCalls } = standIn(() => { | ||
| connects++ | ||
| return { isConnected: true, server: 'altimate-code' } | ||
| }, 10 * 60_000) | ||
| await runTool($, 'dbt_manifest', {}, { write: true }) | ||
| expect(connects).toBe(0) | ||
| expect(argvs).toHaveLength(1) | ||
| // The same call without `write` does ask the server: the test above can fail. It gets no answer, so | ||
| // it goes through the CLI without --allow-write. | ||
| await runTool($, 'dbt_manifest', {}) | ||
| expect(connects).toBe(1) | ||
| expect(mcpCalls()).toBe(1) | ||
| expect(argvs.map(argv => argv.slice(1))[1]).toEqual(['tool', 'run', 'dbt_manifest', '--args', '{}', '--json']) | ||
| }) | ||
|
|
||
| test('within handles the work\'s rejection before it sets the deadline, so a throwing clock leaves none unhandled', async () => { | ||
| let handled = false | ||
| // A work that rejects, recording when a rejection handler is attached. | ||
| const rejected = Promise.reject(new Error('rewrite failed')) | ||
| const work = { | ||
| then: (ok: (v: string) => unknown, failed?: (e: unknown) => unknown) => { | ||
| handled = typeof failed === 'function' | ||
| return rejected.then(ok, failed) | ||
| }, | ||
| } as unknown as Promise<string> | ||
| const $: any = { | ||
| clock: { | ||
| after: () => { | ||
| expect(handled).toBe(true) | ||
| throw new Error('clock failed') | ||
| }, | ||
| }, | ||
| } | ||
| await expect(within($, 10, work)).rejects.toThrow('clock failed') | ||
| expect(handled).toBe(true) | ||
| }) |
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.