You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a CLI developer I want refactored command parsing with explicit CommandConfig discriminated union types organized by command So that KB source resolution logic is type-safe, testable, and maintains clear contracts between CLI parsing and configuration building with proper dispatch to command handlers
Where: apps/pair-cli/src/commands/{command}/ (parser.ts, handler.ts, index.ts per command) with shared helpers
Refined: Story is detailed, estimated, and ready for development
In Progress: Story is actively being developed ✅ Current
Done: Story delivered and accepted
Acceptance Criteria
Functional Requirements
Given-When-Then Format:
Given user runs pair install (no flags) When command parser executes Then parser creates InstallCommandConfig with default resolution detected (monorepo or release)
Given user runs pair install --source https://example.com/kb.zip When command parser executes Then parser creates InstallCommandConfig with remote URL source
Given user runs pair install --source /absolute/path/to/kb When command parser executes Then parser creates InstallCommandConfig with local directory source
Given user runs pair install --offline --source ./local/kb When command parser executes Then parser creates InstallCommandConfig with offline mode enabled and local source
Given user runs pair install --offline (no --source) When command parser executes Then parser throws validation error "Offline mode requires explicit --source with local path"
Given user runs pair install --offline --source https://example.com/kb.zip When command parser executes Then parser throws validation error "Cannot use --offline with remote URL source"
Given user runs pair update --source https://example.com/kb.zip When command parser executes Then parser creates UpdateCommandConfig with remote URL source
Given user runs pair update-link --dry-run When command parser executes Then parser creates UpdateLinkCommandConfig with dry-run mode enabled
Given user runs pair kb validate When command parser executes Then parser creates KbValidateCommandConfig with default settings
Given user runs pair kb package --output dist/kb.zip When command parser executes Then parser creates KbPackageCommandConfig with output path specified
Given user runs pair config validate When command parser executes Then parser creates ConfigValidateCommandConfig with default settings
GivenCommandConfig is union of command-specific types When TypeScript type checking occurs Then compiler enforces correct properties for each command type (discriminated union)
Given config builder receives InstallCommandConfig with default resolution When config builder executes Then builder calls getKnowledgeHubDatasetPath() only if in monorepo pair context
Given KB manager needs KB source When handler dispatches based on CommandConfig type Then appropriate handler (install/update/kb-validate/kb-package/update-link/config-validate) executes with correct configuration
Given helper function detectSourceType(source: string) is called When evaluating a source string Then function returns 'remote' | 'local' based on URL prefix check (http/https) without modifying the CommandConfig type structure
Business Rules
CommandConfig is discriminated union organized by command type (InstallCommandConfig, UpdateCommandConfig, KbValidateCommandConfig, KbPackageCommandConfig, UpdateLinkCommandConfig, ConfigValidateCommandConfig)
Each command has specific config shape with command discriminator field identifying the command
No optional parameters - use union types and discriminators instead of optional fields
Source type detection happens via helper function detectSourceType(), not as a type field
Parser validates before creating CommandConfig - invalid combinations throw early with clear errors
--offline flag only valid with local source (directory or ZIP file)
Relative paths resolved at config builder level, not in parser (parser stores raw input)
getKnowledgeHubDatasetPath() called only when in monorepo pair context with default resolution
Command dispatch happens via handlers organized by command type using exhaustiveness checking
Parser is pure function - no file system access, no network calls, only argument transformation
Default source detection (monorepo vs release) happens in config builder, not parser
Edge Cases and Error Handling
--offline with remote URL: Parser validation error "Cannot use --offline with remote URL source"
--offline without --source: Parser validation error "Offline mode requires explicit --source with local path"
Invalid URL format: Detected by helper function detectSourceType(), creates appropriate config variant
Conflicting flags: Parser validates all flag combinations before creating CommandConfig
Technical Analysis
Implementation Approach
Technical Strategy: Refactor command parsing into pure functions that transform CLI arguments into well-typed CommandConfig objects using TypeScript discriminated unions. Use helper functions for source type detection. Organize code by command in dedicated folders with parser and handler modules.
Documentation (from US KB Source Docs) matches implementation
Type definitions exported for potential extension
Module organization documented (parser.ts vs handler.ts vs index.ts)
Demo-ready: show type safety and dispatch in action
Story Sizing and Sprint Readiness
Final Story Points: 5 Confidence Level: High Sizing Justification:
Type definitions and unions (~1 pt)
Parser functions (~1.5 pt)
Handler implementation and dispatch (~1.5 pt)
Config builder refactoring (~0.5 pt)
Comprehensive testing (~0.5 pt)
Sprint Fit Assessment: Yes - fits in 2-3 days of single sprint Development Time Estimate: 2-2.5 days Testing Time Estimate: 1 day Total Effort Assessment: 3-3.5 days total
T-10: Documentation and monorepo context guard validation
Total Task Points: 27 pts (task granularity, not story estimate) Story Estimate: 5 pts (represents cohesive refactoring deliverable)
T-1: Define CommandConfig types for all 6 commands ✅ COMPLETE
Priority: P0 | Estimated Hours: 3h | Bounded Context: Type System & Architecture
Summary: Define command-specific config types for install, update, kb-validate, kb-package, update-link, config-validate commands in their respective parser.ts files.
Type: Feature Implementation
Description: Create types in commands/{command}/parser.ts modules (one per command) with command-specific config types. Each module defines a unique config interface with command discriminator field. Root CommandConfig union type combines all 6 command types in commands/index.ts.
Acceptance Criteria:
Primary deliverable: 6 command config type definitions in parser.ts + root CommandConfig union in commands/index.ts
Summary: Implement utility helper functions for source type detection and command option validation.
Type: Feature Implementation
Description: Create commands/helpers.ts with detectSourceType() and validateCommandOptions() utility functions. detectSourceType() determines if source is remote URL or local path. validateCommandOptions() validates flag combinations before parser creates CommandConfig.
Acceptance Criteria:
Primary deliverable: Helper functions with clear separation of concerns
Quality standard: Pure functions, accurate detection/validation, clear error messages
Integration requirement: Used by all parser functions
Verification method: Unit tests for all validation rules and detection cases
Technical Requirements:
Functionality: Validate options, detect source type accurately
Performance: O(1) complexity
Security: Prevent empty/malformed inputs
Compatibility: Standard URL formats
Implementation Approach:
Files to Create:
apps/pair-cli/src/commands/helpers.ts
Implementation Steps:
Create helpers.ts module
Implement detectSourceType(source: string): 'remote' | 'local' with URL regex
Implement validateCommandOptions(command, options): void with all rules
Add comprehensive error messages
Export functions for parser use
Add JSDoc documentation
Dependencies:
Technical: None Tasks: None (independent)
Notes: detectSourceType is a pure utility function, not a type field
T-4: Implement parser functions for all commands in respective parser.ts files ✅ COMPLETE
Summary: Implement index.ts exports for each command module to expose parser, handler, and types.
Type: Feature Implementation
Description: Create index.ts files in each commands/{command}/ directory. Each index.ts exports the parser function, handler function, and CommandConfig type for that command. This provides a clean public API for each command.
Acceptance Criteria:
Primary deliverable: index.ts files with proper exports for all 6 commands
Quality standard: Clear public API, no internal details exposed
Integration requirement: Used by dispatcher and CLI handlers
Verification method: Import tests verify exports work
Technical Requirements:
Functionality: Export parser, handler, type cleanly
Summary: Implement dispatcher function that routes CommandConfig to appropriate handler using exhaustiveness checking.
Type: Feature Implementation
Description: Create commands/dispatcher.ts with dispatchCommand() function. Dispatcher uses switch statement on CommandConfig.command field with exhaustiveness checking (assertNever pattern). TypeScript compiler validates all command types are handled.
Acceptance Criteria:
Primary deliverable: dispatchCommand function with exhaustiveness checking in commands/dispatcher.ts
Summary: Update CLI command handlers to call parsers and dispatcher with proper error handling.
Type: Feature Implementation
Description: Modify cli.ts command handlers to call appropriate parser function and then dispatchCommand. Add error handling for parser validation failures with user-friendly messages. Maintain backward compatibility.
Acceptance Criteria:
Primary deliverable: CLI handlers integrated with parser and dispatcher
Summary: Extract command metadata (description, options, examples) from existing commands and configure Commander.js dynamically from command modules.
Type: Feature Implementation
Description: Add metadata property to each command module export containing description, usage, examples, and option definitions. Extract help text and option descriptions from existing command implementations. Configure Commander.js dynamically using this metadata instead of hardcoded definitions.
Acceptance Criteria:
Primary deliverable: Metadata definitions for all 6 commands with Commander.js dynamic configuration
Quality standard: Complete help text, accurate option descriptions, useful examples
Integration requirement: Commander.js help command shows correct information
Verification method: Manual testing of --help output for all commands
Summary: Implement comprehensive test suite covering all CommandConfig types, parsers, handlers, dispatcher.
Type: Testing
Description: Create test files for commands/ directories. Unit tests for types, parsers, validation, helpers, handlers, dispatcher. Integration tests for full CLI flow. Regression tests for existing behavior.
Acceptance Criteria:
Primary deliverable: ≥90% code coverage for commands/ module
Quality standard: All edge cases and error scenarios tested
Integration requirement: Regression tests pass
Verification method: All tests passing, coverage ≥90%
Summary: Add JSDoc documentation for all public types and functions, verify monorepo guard works correctly.
Type: Documentation
Description: Add comprehensive JSDoc comments with examples for all exported types and functions. Verify isInPairMonorepo() guard prevents getKnowledgeHubDatasetPath() call in release mode through tests and manual verification.
Acceptance Criteria:
Primary deliverable: Complete JSDoc for all public API, monorepo guard verified
Quality standard: All public exports documented with examples
Integration requirement: Documentation visible in IDE
Verification method: JSDoc review, manual testing
Technical Requirements:
Functionality: Complete documentation, accurate guard behavior
Performance: N/A
Security: N/A
Compatibility: JSDoc standard
Implementation Approach:
Implementation Steps:
Add JSDoc to all command modules (parser.ts, handler.ts, index.ts)
Add JSDoc to all helper functions
Add JSDoc to dispatcher
Document isInPairMonorepo() guard logic
Manual testing in monorepo and release modes
Update README with module structure
Dependencies:
Technical: None Tasks: All previous tasks
Notes: Guard behavior critical for correctness in both modes
Resolution
Delivered by PR #96 (merged). Board: Done.
feat: CommandConfig Contract & Parser Refactoring.
Story Statement
As a CLI developer
I want refactored command parsing with explicit CommandConfig discriminated union types organized by command
So that KB source resolution logic is type-safe, testable, and maintains clear contracts between CLI parsing and configuration building with proper dispatch to command handlers
Where: apps/pair-cli/src/commands/{command}/ (parser.ts, handler.ts, index.ts per command) with shared helpers
Epic Context
Parent Epic: #65 Enhanced CLI Packaging & Distribution
Status: Refined
Priority: P0 (Must-Have)
Status Workflow
Acceptance Criteria
Functional Requirements
Given-When-Then Format:
Given user runs
pair install(no flags)When command parser executes
Then parser creates
InstallCommandConfigwith default resolution detected (monorepo or release)Given user runs
pair install --source https://example.com/kb.zipWhen command parser executes
Then parser creates
InstallCommandConfigwith remote URL sourceGiven user runs
pair install --source /absolute/path/to/kbWhen command parser executes
Then parser creates
InstallCommandConfigwith local directory sourceGiven user runs
pair install --offline --source ./local/kbWhen command parser executes
Then parser creates
InstallCommandConfigwith offline mode enabled and local sourceGiven user runs
pair install --offline(no --source)When command parser executes
Then parser throws validation error
"Offline mode requires explicit --source with local path"Given user runs
pair install --offline --source https://example.com/kb.zipWhen command parser executes
Then parser throws validation error
"Cannot use --offline with remote URL source"Given user runs
pair update --source https://example.com/kb.zipWhen command parser executes
Then parser creates
UpdateCommandConfigwith remote URL sourceGiven user runs
pair update-link --dry-runWhen command parser executes
Then parser creates
UpdateLinkCommandConfigwith dry-run mode enabledGiven user runs
pair kb validateWhen command parser executes
Then parser creates
KbValidateCommandConfigwith default settingsGiven user runs
pair kb package --output dist/kb.zipWhen command parser executes
Then parser creates
KbPackageCommandConfigwith output path specifiedGiven user runs
pair config validateWhen command parser executes
Then parser creates
ConfigValidateCommandConfigwith default settingsGiven
CommandConfigis union of command-specific typesWhen TypeScript type checking occurs
Then compiler enforces correct properties for each command type (discriminated union)
Given config builder receives
InstallCommandConfigwith default resolutionWhen config builder executes
Then builder calls
getKnowledgeHubDatasetPath()only if in monorepo pair contextGiven KB manager needs KB source
When handler dispatches based on CommandConfig type
Then appropriate handler (install/update/kb-validate/kb-package/update-link/config-validate) executes with correct configuration
Given helper function
detectSourceType(source: string)is calledWhen evaluating a source string
Then function returns
'remote' | 'local'based on URL prefix check (http/https) without modifying the CommandConfig type structureBusiness Rules
detectSourceType(), not as a type fieldEdge Cases and Error Handling
"Cannot use --offline with remote URL source""Offline mode requires explicit --source with local path""Source path/URL cannot be empty"detectSourceType(), creates appropriate config variantTechnical Analysis
Implementation Approach
Technical Strategy: Refactor command parsing into pure functions that transform CLI arguments into well-typed CommandConfig objects using TypeScript discriminated unions. Use helper functions for source type detection. Organize code by command in dedicated folders with parser and handler modules.
Architecture Overview:
Key Components:
CommandConfig Type Definitions (apps/pair-cli/src/commands/{command}/parser.ts)
InstallCommandConfig- install command configurationUpdateCommandConfig- update command configurationKbValidateCommandConfig- kb validate command configurationKbPackageCommandConfig- kb package command configurationUpdateLinkCommandConfig- update-link command configurationConfigValidateCommandConfig- config validate command configurationcommanddiscriminator fieldCommandConfig= union of all command types (in commands/index.ts)Helper Functions (apps/pair-cli/src/commands/helpers.ts)
detectSourceType(source: string): 'remote' | 'local'- URL vs path detectionvalidateCommandOptions(command, options): void- shared validation logicCommand Parsers (apps/pair-cli/src/commands/{command}/parser.ts)
parseInstallCommand(options): InstallCommandConfig- pure functionparseUpdateCommand(options): UpdateCommandConfig- pure functionparseKbValidateCommand(options): KbValidateCommandConfig- pure functionparseKbPackageCommand(options): KbPackageCommandConfig- pure functionparseUpdateLinkCommand(options): UpdateLinkCommandConfig- pure functionparseConfigValidateCommand(options): ConfigValidateCommandConfig- pure functionCommand Handlers (apps/pair-cli/src/commands/{command}/handler.ts)
handleInstallCommand(config): Promise- process InstallCommandConfighandleUpdateCommand(config): Promise- process UpdateCommandConfighandleKbValidateCommand(config): Promise- process KbValidateCommandConfighandleKbPackageCommand(config): Promise- process KbPackageCommandConfighandleUpdateLinkCommand(config): Promise- process UpdateLinkCommandConfighandleConfigValidateCommand(config): Promise- process ConfigValidateCommandConfigCommand Module Exports (apps/pair-cli/src/commands/{command}/index.ts)
Command Dispatcher (apps/pair-cli/src/commands/dispatcher.ts)
dispatchCommand(config): Promise- route by command type using exhaustiveness checkingConfig Builders (config-utils.ts - refactored)
CommandConfigvariants instead of raw optionsgetKnowledgeHubDatasetPath()only in monorepo pair contextCLI Integration (cli.ts)
Data Flow:
Module Organization Rationale:
Helper Function Pattern (instead of type field):
This keeps the CommandConfig type structure clean (no extra fields) while providing source type detection as a utility.
Technical Requirements
getKnowledgeHubDatasetPath()called only when in monorepo pair contextTechnical Risks and Mitigation
Definition of Done Checklist
Development Completion
InstallCommandConfigdiscriminated union defined in install/parser.tsUpdateCommandConfigdiscriminated union defined in update/parser.tsKbValidateCommandConfigtype defined in kb-validate/parser.tsKbPackageCommandConfigtype defined in kb-package/parser.tsUpdateLinkCommandConfigtype defined in update-link/parser.tsConfigValidateCommandConfigtype defined in config-validate/parser.tsCommandConfigunion type defined in commands/index.tsdetectSourceType()implemented in commands/helpers.tsvalidateCommandOptions()implemented in commands/helpers.tsgetKnowledgeHubDatasetPath()callQuality Assurance
Deployment and Release
Story Sizing and Sprint Readiness
Final Story Points: 5
Confidence Level: High
Sizing Justification:
Sprint Fit Assessment: Yes - fits in 2-3 days of single sprint
Development Time Estimate: 2-2.5 days
Testing Time Estimate: 1 day
Total Effort Assessment: 3-3.5 days total
Dependencies and Coordination
Prerequisite Stories:
Dependent Stories:
Shared Components:
Task Breakdown
Total Task Points: 27 pts (task granularity, not story estimate)
Story Estimate: 5 pts (represents cohesive refactoring deliverable)
T-1: Define CommandConfig types for all 6 commands ✅ COMPLETE
Priority: P0 | Estimated Hours: 3h | Bounded Context: Type System & Architecture
Summary: Define command-specific config types for install, update, kb-validate, kb-package, update-link, config-validate commands in their respective parser.ts files.
Type: Feature Implementation
Description: Create types in commands/{command}/parser.ts modules (one per command) with command-specific config types. Each module defines a unique config interface with command discriminator field. Root CommandConfig union type combines all 6 command types in commands/index.ts.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Create:
apps/pair-cli/src/commands/install/parser.ts- InstallCommandConfig type + parserapps/pair-cli/src/commands/update/parser.ts- UpdateCommandConfig type + parserapps/pair-cli/src/commands/kb-validate/parser.ts- KbValidateCommandConfig type + parserapps/pair-cli/src/commands/kb-package/parser.ts- KbPackageCommandConfig type + parserapps/pair-cli/src/commands/update-link/parser.ts- UpdateLinkCommandConfig type + parserapps/pair-cli/src/commands/config-validate/parser.ts- ConfigValidateCommandConfig type + parserapps/pair-cli/src/commands/index.ts- Exports root CommandConfig unionImplementation Steps:
Dependencies:
Technical: None
Tasks: None (independent)
Notes: Source type variants not needed in install/update config types; source type determined at parse-time via helper function
T-2: Implement command handlers for all commands in respective handler.ts files ✅ COMPLETE
Priority: P0 | Estimated Hours: 3h | Bounded Context: Command Execution
Summary: Implement handler functions for all 6 commands that process CommandConfig and orchestrate execution in their respective handler.ts files.
Type: Feature Implementation
Description: Implement handleInstallCommand, handleUpdateCommand, handleKbValidateCommand, handleKbPackageCommand, handleUpdateLinkCommand, handleConfigValidateCommand functions in respective commands/{command}/handler.ts modules. Handlers receive CommandConfig, coordinate config building, and execute command logic. Handlers are entry points for command execution after dispatch.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Create:
apps/pair-cli/src/commands/install/handler.tsapps/pair-cli/src/commands/update/handler.tsapps/pair-cli/src/commands/kb-validate/handler.tsapps/pair-cli/src/commands/kb-package/handler.tsapps/pair-cli/src/commands/update-link/handler.tsapps/pair-cli/src/commands/config-validate/handler.tsImplementation Steps:
Dependencies:
Technical: None
Tasks: T-1 (CommandConfig types)
Notes: Handlers delegate to config builders and existing execution logic
T-3: Implement helper functions (detectSourceType, validateCommandOptions) ✅ COMPLETE
Priority: P0 | Estimated Hours: 2h | Bounded Context: Input Validation & Parsing
Summary: Implement utility helper functions for source type detection and command option validation.
Type: Feature Implementation
Description: Create commands/helpers.ts with detectSourceType() and validateCommandOptions() utility functions. detectSourceType() determines if source is remote URL or local path. validateCommandOptions() validates flag combinations before parser creates CommandConfig.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Create:
apps/pair-cli/src/commands/helpers.tsImplementation Steps:
Dependencies:
Technical: None
Tasks: None (independent)
Notes: detectSourceType is a pure utility function, not a type field
T-4: Implement parser functions for all commands in respective parser.ts files ✅ COMPLETE
Priority: P0 | Estimated Hours: 4h | Bounded Context: CLI Parsing
Summary: Implement pure parser functions for all 6 commands that transform options into CommandConfig objects in their respective parser.ts files.
Type: Feature Implementation
Description: Implement parseInstallCommand, parseUpdateCommand, parseKbValidateCommand, parseKbPackageCommand, parseUpdateLinkCommand, parseConfigValidateCommand functions in respective commands/{command}/parser.ts modules. Parsers validate options using helpers, handle command-specific logic, return appropriate CommandConfig variant. All parsers are pure functions.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Modify/Create:
apps/pair-cli/src/commands/install/parser.tsapps/pair-cli/src/commands/update/parser.tsapps/pair-cli/src/commands/kb-validate/parser.tsapps/pair-cli/src/commands/kb-package/parser.tsapps/pair-cli/src/commands/update-link/parser.tsapps/pair-cli/src/commands/config-validate/parser.tsImplementation Steps:
Dependencies:
Technical: None
Tasks: T-1 (CommandConfig types), T-3 (helper functions)
Notes: Parsers delegate to helpers; validation happens before CommandConfig creation (fail-fast)
T-5: Implement command module exports in respective index.ts files ✅ COMPLETE
Priority: P0 | Estimated Hours: 1h | Bounded Context: Module Exports
Summary: Implement index.ts exports for each command module to expose parser, handler, and types.
Type: Feature Implementation
Description: Create index.ts files in each commands/{command}/ directory. Each index.ts exports the parser function, handler function, and CommandConfig type for that command. This provides a clean public API for each command.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Create:
apps/pair-cli/src/commands/install/index.tsapps/pair-cli/src/commands/update/index.tsapps/pair-cli/src/commands/kb-validate/index.tsapps/pair-cli/src/commands/kb-package/index.tsapps/pair-cli/src/commands/update-link/index.tsapps/pair-cli/src/commands/config-validate/index.tsImplementation Steps:
Dependencies:
Technical: None
Tasks: T-4 (parsers), T-2 (handlers)
Notes: index.ts is the public API surface for each command module
T-6: Implement command dispatcher with exhaustiveness checking in commands/dispatcher.ts ✅ COMPLETE
Priority: P0 | Estimated Hours: 2h | Bounded Context: Command Routing
Summary: Implement dispatcher function that routes CommandConfig to appropriate handler using exhaustiveness checking.
Type: Feature Implementation
Description: Create commands/dispatcher.ts with dispatchCommand() function. Dispatcher uses switch statement on CommandConfig.command field with exhaustiveness checking (assertNever pattern). TypeScript compiler validates all command types are handled.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Create:
apps/pair-cli/src/commands/dispatcher.tsImplementation Steps:
Dependencies:
Technical: None
Tasks: T-2 (handler functions), T-5 (command exports)
Notes: assertNever pattern ensures TypeScript compiler validates all variants handled
T-7: Refactor config builders to accept CommandConfig and dispatch ✅ COMPLETE
Priority: P0 | Estimated Hours: 3h | Bounded Context: Configuration Management
Summary: Refactor existing config builder functions to accept CommandConfig and dispatch based on command type.
Type: Refactoring
Description: Modify config-utils.ts builder functions (buildInstallOptions, buildUpdateOptions, etc.) to accept CommandConfig variants. Add guard clause for monorepo context before calling getKnowledgeHubDatasetPath(). Dispatch logic handles each command type.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Modify:
apps/pair-cli/src/config-utils.tsImplementation Steps:
Dependencies:
Technical: None
Tasks: T-1 (CommandConfig types)
Notes: Guard clause critical to prevent getKnowledgeHubDatasetPath() call in release mode
T-8: Integrate parsers and dispatcher into CLI handlers
Priority: P0 | Estimated Hours: 2h | Bounded Context: CLI Integration
Summary: Update CLI command handlers to call parsers and dispatcher with proper error handling.
Type: Feature Implementation
Description: Modify cli.ts command handlers to call appropriate parser function and then dispatchCommand. Add error handling for parser validation failures with user-friendly messages. Maintain backward compatibility.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Files to Modify:
apps/pair-cli/src/cli.tsImplementation Steps:
Dependencies:
Technical: None
Tasks: T-4 (parsers), T-6 (dispatcher)
Notes: Exit code 1 for parser errors, 2 for system errors
T-8b: Extract and configure Commander.js metadata dynamically
Priority: P0 | Estimated Hours: 2h | Bounded Context: CLI Metadata & Help
Summary: Extract command metadata (description, options, examples) from existing commands and configure Commander.js dynamically from command modules.
Type: Feature Implementation
Description: Add metadata property to each command module export containing description, usage, examples, and option definitions. Extract help text and option descriptions from existing command implementations. Configure Commander.js dynamically using this metadata instead of hardcoded definitions.
Acceptance Criteria:
--helpoutput for all commandsTechnical Requirements:
Implementation Approach:
Files to Modify:
apps/pair-cli/src/commands/install/index.ts(add metadata)apps/pair-cli/src/commands/update/index.ts(add metadata)apps/pair-cli/src/commands/update-link/index.ts(add metadata)apps/pair-cli/src/commands/package/index.ts(add metadata)apps/pair-cli/src/commands/validate-config/index.ts(add metadata)apps/pair-cli/src/cli.ts(dynamic Commander.js configuration)Implementation Steps:
metaproperty to each command module export with structure:--helpoutput for all commandsDependencies:
Technical: Commander.js
Tasks: T-5 (command module exports)
Notes: Metadata centralizes CLI documentation; keeps help text with command implementation
T-9: Comprehensive testing (unit, integration, regression)
Priority: P0 | Estimated Hours: 4h | Bounded Context: Quality Assurance
Summary: Implement comprehensive test suite covering all CommandConfig types, parsers, handlers, dispatcher.
Type: Testing
Description: Create test files for commands/ directories. Unit tests for types, parsers, validation, helpers, handlers, dispatcher. Integration tests for full CLI flow. Regression tests for existing behavior.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Test Organization:
Implementation Steps:
Dependencies:
Technical: None
Tasks: All previous tasks
Notes: Regression tests critical; manual testing validates against spec
T-10: Documentation and monorepo context guard validation
Priority: P0 | Estimated Hours: 1h | Bounded Context: Documentation & Validation
Summary: Add JSDoc documentation for all public types and functions, verify monorepo guard works correctly.
Type: Documentation
Description: Add comprehensive JSDoc comments with examples for all exported types and functions. Verify isInPairMonorepo() guard prevents getKnowledgeHubDatasetPath() call in release mode through tests and manual verification.
Acceptance Criteria:
Technical Requirements:
Implementation Approach:
Implementation Steps:
Dependencies:
Technical: None
Tasks: All previous tasks
Notes: Guard behavior critical for correctness in both modes
Refinement Completed By: Product Manager (AI-assisted)
Refinement Date: 2025-12-09
Review and Approval: Pending developer confirmation