Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/publish-npm.yml
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

Copilot AI Feb 2, 2026

Copy link

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: read and id-token: write. Add contents: write to the permissions section to allow creating release comments or updating release descriptions.

Suggested change
contents: read
contents: write

Copilot uses AI. Check for mistakes.
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

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback from npm ci to npm install using || could mask errors. If npm ci fails due to a package-lock.json mismatch or corruption, it will silently fall back to npm install, which could install different dependency versions than expected. Consider either ensuring package-lock.json is committed and up-to-date, or use npm ci without fallback for reproducible builds.

Suggested change
run: npm ci || npm install
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi

Copilot uses AI. Check for mistakes.

- name: Run tests
run: npm test
continue-on-error: true

Copilot AI Feb 2, 2026

Copy link

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.

Suggested change
continue-on-error: true

Copilot uses AI. Check for mistakes.

- name: Verify package contents
run: |
echo "📦 Package contents:"
npm pack --dry-run
echo ""
echo "✅ Package verification complete"

- name: Check if version already published
id: check-version
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")

if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
echo "⚠️ Version $PACKAGE_VERSION is already published"
echo "already_published=true" >> $GITHUB_OUTPUT
else
echo "✅ Version $PACKAGE_VERSION is not published yet"
echo "already_published=false" >> $GITHUB_OUTPUT
fi
continue-on-error: true
Comment on lines +46 to +59

Copilot AI Feb 2, 2026

Copy link

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 uses AI. Check for mistakes.

- name: Publish to npm
if: steps.check-version.outputs.already_published != 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create success comment
if: steps.check-version.outputs.already_published != 'true' && github.event_name == 'release'
uses: actions/github-script@v7
with:
script: |
const packageJson = require('./package.json');
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\`\`\``
Comment on lines +73 to +77

Copilot AI Feb 2, 2026

Copy link

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.

Suggested change
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,

Copilot uses AI. Check for mistakes.
});

- name: Version already published
if: steps.check-version.outputs.already_published == 'true'
run: |
echo "ℹ️ Skipping publish - version already exists on npm"
exit 0
46 changes: 46 additions & 0 deletions .npmignore
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
225 changes: 225 additions & 0 deletions CONTRIBUTING.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! 🎉
Loading
Loading