-
Notifications
You must be signed in to change notification settings - Fork 0
Add pluggable CLI command system with ESM dynamic loading #162
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
Conversation
Co-authored-by: rgardler-msft <[email protected]>
- Created 14 new command modules in src/commands/: * init.ts - Initialize configuration with git hooks * status.ts - System status display * create.ts - Create work items * list.ts - List and filter work items * show.ts - Show work item details * update.ts - Update work items * delete.ts - Delete work items * next.ts - Find next work item to work on * in-progress.ts - List in-progress items * close.ts - Close items with reason tracking * recent.ts - Show recently changed items * sync.ts - Git sync operations * github.ts - GitHub sync (push/import) * comment.ts - Comment CRUD operations - Extracted shared helpers to commands/helpers.ts: * Display formatters (tree, title, colors) * Human-readable output functions * Conflict resolution display * Format resolution logic - Created plugin infrastructure: * plugin-types.ts - Type definitions for plugin system * plugin-loader.ts - Dynamic command loading * cli-utils.ts - Shared CLI utilities - All commands preserve exact original behavior: * JSON output mode support * Format options (concise/normal/full/raw) * Prefix overrides * Error handling * Progress indicators * Interactive prompts Ready for cli.ts integration (separate task) Co-authored-by: rgardler-msft <[email protected]>
- Created plugin system infrastructure (plugin-types, plugin-loader, cli-utils) - Migrated all 17 built-in commands to separate modules in src/commands/ - Refactored cli.ts to minimal bootstrap with plugin registration - Fixed database initialization bugs (prefix parameter order) - Fixed error output format for uninitialized state - All existing tests passing (151/151) Co-authored-by: rgardler-msft <[email protected]>
- Added 20 unit tests for plugin discovery and loading - Added 9 integration tests for external plugin execution - Created comprehensive PLUGIN_GUIDE.md (300+ lines) - Updated README.md with plugin system overview and quick example - All 180 tests passing (151 original + 29 new plugin tests) Co-authored-by: rgardler-msft <[email protected]>
- Created stats-plugin.mjs example demonstrating database access - Added examples/README.md with usage instructions - Verified end-to-end plugin workflow (install, discover, execute) - All 180 tests passing Co-authored-by: rgardler-msft <[email protected]>
|
@copilot please address all review comments |
…amples - Added type import clarification in Quick Start (optional for JS plugins) - Clarified Plugin Module Structure section about TypeScript vs JavaScript - Added note about folder structure recommendations - Explained plugin command grouping in --help output - Added note about requireInitialized() pattern - Added best practice for verbose logging with example - Moved inline plugin examples to separate files in examples/ - Created bulk-tag-plugin.mjs and export-csv-plugin.mjs examples - Simplified README.md Plugins section, removed duplicate content - Streamlined examples/README.md, removed testing/contributing sections - Removed Contributing and License sections from PLUGIN_GUIDE.md - Removed src/cli-old.ts backup file - All 180 tests passing Co-authored-by: rgardler-msft <[email protected]>
All review comments have been addressed in commit ddbcb84. Summary of changes: ✅ Added type import clarification (optional for JS plugins) All 180 tests passing. Build successful. |
Implementation Status: ✅ COMPLETE
Successfully implemented a complete pluggable CLI command system for Worklog.
Documentation Improvements (Based on PR Feedback)
Clarifications added:
Content organization:
File cleanup:
What Was Accomplished
🏗️ Architecture (Phase 1-3)
🔌 Plugin System Features
🧪 Testing (Phase 5)
📚 Documentation (Phase 6)
🔒 Security (Phase 7)
Files Changed
New: 24 files
Modified: 2 files
Removed: 1 file
Verification Results
✅ Build
npm run build # Successful, 0 errors✅ Tests
✅ Security Scan
codeql analyze # 0 vulnerabilities foundOriginal prompt
This section details on the original issue you should resolve
<issue_title>Add Pluggable CLI Command System (JS plugins), migrate built-in commands, and document</issue_title>
<issue_description>
We want the Worklog CLI (dist/cli.js, implemented in src/cli.ts) to support a pluggable command architecture where new commands can be added by dropping a compiled ESM plugin file (.js / .mjs) into a known directory, with no Worklog rebuild required. On the next CLI invocation, the new command should appear automatically.
This issue also migrates all existing built-in commands out of src/cli.ts into external command modules (shipped with the package), using the same plugin interface, and fully documents the feature.
Goals
Non-goals
Proposed design
Documentation requirements
Migration scope (port all existing commands)
Implementation tasks
Testing / verification
Acceptance criteria
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.