Repository navigation
feat(cli): introduce warehouse commands - #111
Conversation
filipmyllari
left a comment
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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']); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
--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', { |
There was a problem hiding this comment.
--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> = { |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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, [ |
There was a problem hiding this comment.
The list of six keys is written out twice. Put it in one const and pass it to both resolveInput and requireKeys.
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>
warehousecommands for managing data warehouse connections (validate, create, connectors, assignment tables, crypto keys)warehouse setupcommand that launches a guided chat session with the matchingsetup-warehouse-*skillsetup-warehouse-*skills inconfidence-ai-pluginstryHandleMcpErrorutility to@utils/mcp-error.tswith optionalformatErroranddefaultMessageoverrides; recordings now reuses itWarehouseTypeParamstype intofeatures/warehouse/types.tsCommands
confidence warehouse setupconfidence warehouse validateconfidence warehouse createconfidence warehouse connector create-flag-appliedconfidence warehouse connector create-eventconfidence warehouse assignment-table createconfidence warehouse crypto-key create