feat: upload command - #185
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR refactors the image-only
upload-imageCLI command into a universaluploadcommand, enabling seamless uploads of design assets (PNG, JPG, JPEG, WEBP) as well as interactive HTML files via the updated@google/stitch-sdkclient. Additionally, it introduces runtime schema-repair mechanisms in the SDK layer to guarantee client-side resilience against incomplete backend schema payloads.What Changed
1. Universal
uploadCommand Slice (src/commands/upload/)command.ts: Standardizes option parsing (--project,--file,--title) using Commander. Implements lazy, dynamic imports to isolate connection side-effects and boost CLI boot speeds. Wire-connects the command action to the unifiedproject.upload()SDK method.handler.ts: Generalizes the business logic layer to process any valid asset. Maintained strong Dependency Injection ports (UploadFn) for isolated test mapping, transforming errors into result-oriented, typed status values without throwing.spec.ts: Hardens input validation using Zod (UploadInputSchema). Features directory traversal guardrails (..) to reject malicious path escalations before shell or disk operations.2. Core SDK Resilience Layer (Schema Repair)
@google/stitch-sdktool discovery sequence (StitchToolClient.listTools()).$defsdeclarations (e.g.,ScreenInstance,File). This prevents strict AJV validation crashes during discovery and tool compilation, shielding developers and CI setups from malformed upstream schemas.3. Test Suite Alignment & Verification
tests/commands/upload/.Files Changed
New CLI Command Slice
src/commands/upload/command.ts— Options parsing, lazy import, and SDK wiringsrc/commands/upload/handler.ts— Generalized asset handling and DI upload mappingssrc/commands/upload/spec.ts— Zod input validation and directory traversal guardsUnit & Integration Test Suites
tests/commands/upload/handler.test.ts— Comprehensive error classification and mock upload teststests/commands/upload/spec.test.ts— Input schema constraint and path-traversal verificationUnderlying SDK Patches
packages/sdk/src/client.ts— On-the-fly schema repair interceptor