-
Notifications
You must be signed in to change notification settings - Fork 0
Add npm package infrastructure for global CLI installation #6
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
Changes from all commits
a9f7928
42e9cc7
908ff59
56e8c3c
e4ffc26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||||||||||||||||||
| name: Publish to npm | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||
| release: | ||||||||||||||||||||||||||||
| types: [published] | ||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||
| tag: | ||||||||||||||||||||||||||||
| description: 'Tag to publish (leave empty for latest)' | ||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||
| publish: | ||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| ref: ${{ github.event.inputs.tag || github.ref }} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Setup Node.js | ||||||||||||||||||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| node-version: '22' | ||||||||||||||||||||||||||||
| registry-url: 'https://registry.npmjs.org' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||
| run: npm ci || npm install | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| run: npm ci || npm install | |
| run: | | |
| if [ -f package-lock.json ]; then | |
| npm ci | |
| else | |
| npm install | |
| fi |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are set to continue-on-error: true, meaning the workflow will publish to npm even if tests fail. This is risky and could publish broken versions. Either remove continue-on-error: true or add a clear comment explaining why test failures should be ignored during publication.
| continue-on-error: true |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version check step has continue-on-error: true, which means if the check itself fails (e.g., npm registry is down), the workflow will continue and attempt to publish anyway, potentially causing an error later. Consider removing continue-on-error or adding explicit error handling to ensure the workflow behaves correctly when the npm registry is unavailable.
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow attempts to create a comment on a release, but releases don't have an issue_number. The context.issue.number will be undefined for release events. You should use the release ID instead. Replace issue_number: context.issue.number with a proper release comment mechanism or use the GitHub Releases API to add a comment to the release body.
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `🎉 Successfully published \`${packageJson.name}@${packageJson.version}\` to npm!\n\nInstall with:\n\`\`\`bash\nnpm install -g ${packageJson.name}\n\`\`\`` | |
| const release = context.payload.release; | |
| const successMessage = `🎉 Successfully published \`${packageJson.name}@${packageJson.version}\` to npm!\n\nInstall with:\n\`\`\`bash\nnpm install -g ${packageJson.name}\n\`\`\``; | |
| const updatedBody = (release.body || '') + '\n\n' + successMessage; | |
| await github.rest.repos.updateRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: release.id, | |
| body: updatedBody, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Test files | ||
| scripts/test-*.js | ||
| scripts/*.ps1 | ||
|
|
||
| # Documentation (most can be included, but some might be too large) | ||
| FINAL_SUMMARY.txt | ||
| GPT-reports.md | ||
| IMPLEMENTATION_SUMMARY.md | ||
| baseline-app.md | ||
| changelog.md | ||
| OVERLAY_PROOF.png | ||
|
|
||
| # Project management | ||
| # Note: .github/ is excluded to reduce package size. | ||
| # Workflow files are still visible in the GitHub repository for transparency. | ||
| .github/ | ||
| .git/ | ||
| .gitignore | ||
|
|
||
| # Development files | ||
| *.swp | ||
| *.swo | ||
| .DS_Store | ||
| Thumbs.db | ||
| .vscode/ | ||
| .idea/ | ||
|
|
||
| # Build artifacts | ||
| out/ | ||
| build/ | ||
| dist/ | ||
| *.log | ||
|
|
||
| # Specific directories | ||
| ultimate-ai-system/ | ||
| docs/ | ||
|
|
||
| # Keep these important files for npm users | ||
| # README.md | ||
| # LICENSE.md | ||
| # QUICKSTART.md | ||
| # INSTALLATION.md | ||
| # CONTRIBUTING.md | ||
| # ARCHITECTURE.md | ||
| # CONFIGURATION.md | ||
| # TESTING.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| # Contributing to Copilot-Liku CLI | ||
|
|
||
| Thank you for your interest in contributing to Copilot-Liku CLI! This guide will help you get started with local development. | ||
|
|
||
| ## Development Setup | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - **Node.js** v22 or higher | ||
| - **npm** v10 or higher | ||
| - **Git** | ||
| - (On Windows) **PowerShell** v6 or higher | ||
|
|
||
| ### Initial Setup | ||
|
|
||
| 1. **Fork and clone the repository:** | ||
| ```bash | ||
| git clone https://github.com/YOUR-USERNAME/copilot-Liku-cli.git | ||
| cd copilot-Liku-cli | ||
| ``` | ||
|
|
||
| 2. **Install dependencies:** | ||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| 3. **Link for global usage (recommended for testing):** | ||
| ```bash | ||
| npm link | ||
| ``` | ||
|
|
||
| This creates a symlink from your global `node_modules` to your local development directory. Any changes you make will be immediately reflected when you run the `liku` command. | ||
|
|
||
| 4. **Verify the setup:** | ||
| ```bash | ||
| liku --version | ||
| liku --help | ||
| ``` | ||
|
|
||
| ### Development Workflow | ||
|
|
||
| #### Testing Your Changes | ||
|
|
||
| After making changes to the CLI code: | ||
|
|
||
| 1. **Test the CLI commands:** | ||
| ```bash | ||
| liku --help # Test help output | ||
| liku start # Test starting the app | ||
| liku click "Button" # Test automation commands | ||
| ``` | ||
|
|
||
| 2. **Run existing tests:** | ||
| ```bash | ||
| npm test # Run test suite | ||
| npm run test:ui # Run UI automation tests | ||
| ``` | ||
|
|
||
| 3. **Manual testing:** | ||
| ```bash | ||
| # Start the application | ||
| liku start | ||
|
|
||
| # Test specific commands | ||
| liku screenshot | ||
| liku window "VS Code" | ||
| ``` | ||
|
|
||
| #### Unlinking When Done | ||
|
|
||
| If you need to unlink your development version: | ||
| ```bash | ||
| npm unlink -g copilot-liku-cli | ||
| ``` | ||
|
|
||
| Or to install the published version: | ||
| ```bash | ||
| npm unlink -g copilot-liku-cli | ||
| npm install -g copilot-liku-cli | ||
| ``` | ||
|
|
||
| ### Project Structure | ||
|
|
||
| ``` | ||
| copilot-Liku-cli/ | ||
| ├── src/ | ||
| │ ├── cli/ # CLI implementation | ||
| │ │ ├── liku.js # Main CLI entry point | ||
| │ │ ├── commands/ # Command implementations | ||
| │ │ └── util/ # CLI utilities | ||
| │ ├── main/ # Electron main process | ||
| │ ├── renderer/ # Electron renderer process | ||
| │ └── shared/ # Shared utilities | ||
| ├── scripts/ # Build and test scripts | ||
| ├── docs/ # Additional documentation | ||
| └── package.json # Package configuration with bin entry | ||
| ``` | ||
|
|
||
| ### Making Changes | ||
|
|
||
| #### Adding a New CLI Command | ||
|
|
||
| 1. Create a new command file in `src/cli/commands/`: | ||
| ```javascript | ||
| // src/cli/commands/mycommand.js | ||
| async function run(args, options) { | ||
| // Command implementation | ||
| console.log('Running my command with args:', args); | ||
| return { success: true }; | ||
| } | ||
|
|
||
| module.exports = { run }; | ||
| ``` | ||
|
|
||
| 2. Register the command in `src/cli/liku.js`: | ||
| ```javascript | ||
| const COMMANDS = { | ||
| // ... existing commands | ||
| mycommand: { | ||
| desc: 'Description of my command', | ||
| file: 'mycommand', | ||
| args: '[optional-arg]' | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| 3. Test your command: | ||
| ```bash | ||
| liku mycommand --help | ||
| ``` | ||
|
|
||
| #### Modifying the CLI Parser | ||
|
|
||
| The main CLI logic is in `src/cli/liku.js`. Key functions: | ||
| - `parseArgs()` - Parses command-line arguments | ||
| - `executeCommand()` - Loads and runs command modules | ||
| - `showHelp()` - Displays help text | ||
|
|
||
| ### Code Style | ||
|
|
||
| - Follow existing code conventions | ||
| - Use meaningful variable names | ||
| - Add comments for complex logic | ||
| - Keep functions focused and small | ||
|
|
||
| ### Testing Guidelines | ||
|
|
||
| 1. **Test your changes locally** before submitting a PR | ||
| 2. **Ensure existing tests pass**: `npm test` | ||
| 3. **Add tests for new features** when applicable | ||
| 4. **Test cross-platform** if possible (Windows, macOS, Linux) | ||
|
|
||
| ### Submitting Changes | ||
|
|
||
| 1. **Create a feature branch:** | ||
| ```bash | ||
| git checkout -b feature/my-feature | ||
| ``` | ||
|
|
||
| 2. **Make your changes and commit:** | ||
| ```bash | ||
| git add . | ||
| git commit -m "Add feature: description" | ||
| ``` | ||
|
|
||
| 3. **Push to your fork:** | ||
| ```bash | ||
| git push origin feature/my-feature | ||
| ``` | ||
|
|
||
| 4. **Open a Pull Request** on GitHub with: | ||
| - Clear description of changes | ||
| - Reasoning for the changes | ||
| - Any testing performed | ||
| - Screenshots if UI changes | ||
|
|
||
| ### Troubleshooting | ||
|
|
||
| #### `liku` command not found after `npm link` | ||
|
|
||
| Make sure npm's global bin directory is in your PATH: | ||
| ```bash | ||
| npm bin -g | ||
| ``` | ||
|
|
||
| Add the output directory to your PATH if needed. | ||
|
|
||
| #### Changes not reflected when running `liku` | ||
|
|
||
| 1. Verify you're linked to the local version: | ||
| ```bash | ||
| which liku # Unix/Mac | ||
| where liku # Windows | ||
| ``` | ||
|
|
||
| 2. Re-link if needed: | ||
| ```bash | ||
| npm unlink -g copilot-liku-cli | ||
| npm link | ||
| ``` | ||
|
|
||
| #### Permission errors with `npm link` | ||
|
|
||
| On some systems, you may need to configure npm to use a user-local prefix: | ||
| ```bash | ||
| mkdir ~/.npm-global | ||
| npm config set prefix '~/.npm-global' | ||
| ``` | ||
|
|
||
| Then add `~/.npm-global/bin` to your PATH. | ||
|
|
||
| ### Additional Resources | ||
|
|
||
| - [npm link documentation](https://docs.npmjs.com/cli/v10/commands/npm-link) | ||
| - [npm bin configuration](https://docs.npmjs.com/cli/v10/configuring-npm/folders#executables) | ||
| - [Project Architecture](ARCHITECTURE.md) | ||
| - [Testing Guide](TESTING.md) | ||
|
|
||
| ### Getting Help | ||
|
|
||
| - Check existing [GitHub Issues](https://github.com/TayDa64/copilot-Liku-cli/issues) | ||
| - Join discussions in the repository | ||
| - Review documentation files in the repo | ||
|
|
||
| Thank you for contributing! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow needs write permissions for contents and/or issues to create comments. Currently, it only has
contents: readandid-token: write. Addcontents: writeto the permissions section to allow creating release comments or updating release descriptions.