Skip to content

feat(cli): introduce warehouse commands - #111

Merged
bespoyasov merged 12 commits into
mainfrom
feat/warehouse-commands
Oct 8, 2026
Merged

bespoyasov merged 12 commits into
mainfrom
feat/warehouse-commands

Conversation

@bespoyasov

@bespoyasov bespoyasov commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator
  • Adds warehouse commands for managing data warehouse connections (validate, create, connectors, assignment tables, crypto keys)
  • Add warehouse setup command that launches a guided chat session with the matching setup-warehouse-* skill
  • Supports BigQuery, Snowflake, Databricks, and Redshift — aligned with the setup-warehouse-* skills in confidence-ai-plugins
  • Extract shared tryHandleMcpError utility to @utils/mcp-error.ts with optional formatError and defaultMessage overrides; recordings now reuses it
  • Extract shared WarehouseTypeParams type into features/warehouse/types.ts

Commands

Command Description
confidence warehouse setup Launch guided warehouse setup in your AI coding agent
confidence warehouse validate Validate warehouse configuration
confidence warehouse create Create a data warehouse connection
confidence warehouse connector create-flag-applied Create flag assignment data connector
confidence warehouse connector create-event Create event data connector
confidence warehouse assignment-table create Create an assignment table for experiment analysis
confidence warehouse crypto-key create Create a crypto key (Snowflake)

@bespoyasov
bespoyasov marked this pull request as draft October 7, 2026 13:20
@bespoyasov
bespoyasov marked this pull request as ready for review October 7, 2026 13:23

@filipmyllari filipmyllari left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review notes (AI-assisted). The comments are inline below. I didn't review the tests or docs, and didn't check the server-side MCP tool schemas.

function buildSetupPrompt(warehouseType: string): string {
const skill = WAREHOUSE_SKILLS[warehouseType];
return `Set up a ${warehouseType} data warehouse for Confidence experimentation analytics.
Use the /onboard-confidence:${skill} skill to guide the setup process.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prompt asks the agent to use /onboard-confidence:setup-warehouse-<type>, but the plugin is called confidence (PLUGIN_NAME), so the skill's real name is confidence:setup-warehouse-bigquery. With the wrong name the agent can't find the skill and improvises. Do what migrate/prompt.ts does: name the skill "from the Confidence plugin", or build the name from PLUGIN_NAME.

const flags = extractFlags(argv);
const format = resolveFormat(flags);

if (format === 'json') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With --format json, this returns before the process.exitCode = 1 check at line 75, so a failed validation exits 0 in JSON mode, which is the mode scripts and CI use. Set the exit code before the JSON early return.

import type { WarehouseTypeParams } from './types.js';

export const createWarehouseCmd = withAuth(async function createWarehouseCmd(argv, token) {
const params = resolveInput<WarehouseTypeParams>(argv, ['warehouse-type', 'config-json']);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With --from-file, the natural way to write the file is {"configJson": {...}}. That object is passed through unchanged, even though WarehouseTypeParams claims it's a string, so the MCP tool gets an object. Either JSON.stringify non-string values or document that it must be string-encoded JSON. The same applies to validate, create-flag-applied and create-event.

type: 'string',
describe: 'Read params from JSON file',
})
.check((argv) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--from-file skips the choices: WAREHOUSE_TYPES check, so "warehouseType": "postgres" in a file goes straight to the server. Validate against WAREHOUSE_TYPES in the feature after resolveInput.

choices: WAREHOUSE_TYPES,
describe: 'Data warehouse type',
})
.option('config-json', {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--config-json is never parsed locally. Malformed JSON costs a network round trip and comes back as an opaque MCP error. Running JSON.parse first would give a clear local error.

import { resolveIde, resolveFlag, resolveProjectDir } from '@features/ide/index.js';
import { resolveAuthToken } from '@features/mcp/index.js';

const WAREHOUSE_SKILLS: Record<string, string> = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WAREHOUSE_SKILLS repeats WAREHOUSE_TYPES. Since --warehouse-type is demandOption with choices, the "Unknown warehouse type" branch at line 22 can't be reached. Define the types once, as a Record<WarehouseType, string>, and drop the dead check.

Follow the skill instructions step by step — collect configuration, validate, create the warehouse, set up connectors, and verify the pipeline.`;
}

export async function runWarehouseSetup(argv: Record<string, unknown>): Promise<void> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost a line-for-line copy of migrate/launch.ts and sdk/setup.ts, which makes it the third copy. Pull it into a shared launchSkillChat(argv, prompt) helper.


export const createAssignmentTableCmd = withAuth(
async function createAssignmentTableCmd(argv, token) {
const params = resolveInput<AssignmentTableParams>(argv, [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of six keys is written out twice. Put it in one const and pass it to both resolveInput and requireKeys.

bespoyasov and others added 8 commits October 8, 2026 07:56
The prompt hardcoded the wrong plugin prefix ("onboard-confidence")
causing the agent to fail skill lookup. Use PLUGIN_NAME constant to
match the pattern in migrate/prompt.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The JSON early return skipped the process.exitCode = 1 check, so
`warehouse validate --format json` exited 0 on failure. Move the
exit code before the format branch and make fail() accept an optional
message so it can set the exit code without printing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When --from-file provides configJson as a nested object, it was passed
through to MCP tools as-is instead of as a JSON string. Add
ensureJsonString to shared-kernel and apply it in all four warehouse
commands (create, validate, create-flag-applied, create-event).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The yargs choices constraint only applies to CLI args, so --from-file
could pass invalid warehouse types straight to the server. Add
validateWarehouseType after resolveInput in all four warehouse commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move ensureJsonString and validateJsonString from shared-kernel to
core/utils with tests. Make validators return their input for inline
chaining. Add WarehouseType union and narrow in validateWarehouseType.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use Record<WarehouseType, string> so the compiler enforces key
completeness. Replace the unsafe cast with validateWarehouseType.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The plugin/MCP/auth-check-then-launch-chat sequence was duplicated
across warehouse/setup, sdk/setup, and migrate/launch. Extract into
a shared launchSkillChat helper in features/ide/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract the six param keys into a single const shared by resolveInput
and requireKeys.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bespoyasov
bespoyasov merged commit a99267e into main Oct 8, 2026
6 checks passed
@bespoyasov
bespoyasov deleted the feat/warehouse-commands branch October 8, 2026 07:44
@github-actions github-actions Bot mentioned this pull request Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants