Skip to content

Commit d2d33a1

Browse files
authored
Merge pull request #6 from TayDa64/copilot/add-cli-package-for-liku
2 parents 8ea6e8d + e4ffc26 commit d2d33a1

File tree

10 files changed

+1453
-4
lines changed

10 files changed

+1453
-4
lines changed

.github/workflows/publish-npm.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Tag to publish (leave empty for latest)'
10+
required: false
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
contents: read
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.event.inputs.tag || github.ref }}
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '22'
30+
registry-url: 'https://registry.npmjs.org'
31+
32+
- name: Install dependencies
33+
run: npm ci || npm install
34+
35+
- name: Run tests
36+
run: npm test
37+
continue-on-error: true
38+
39+
- name: Verify package contents
40+
run: |
41+
echo "📦 Package contents:"
42+
npm pack --dry-run
43+
echo ""
44+
echo "✅ Package verification complete"
45+
46+
- name: Check if version already published
47+
id: check-version
48+
run: |
49+
PACKAGE_NAME=$(node -p "require('./package.json').name")
50+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
51+
52+
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
53+
echo "⚠️ Version $PACKAGE_VERSION is already published"
54+
echo "already_published=true" >> $GITHUB_OUTPUT
55+
else
56+
echo "✅ Version $PACKAGE_VERSION is not published yet"
57+
echo "already_published=false" >> $GITHUB_OUTPUT
58+
fi
59+
continue-on-error: true
60+
61+
- name: Publish to npm
62+
if: steps.check-version.outputs.already_published != 'true'
63+
run: npm publish --access public
64+
env:
65+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66+
67+
- name: Create success comment
68+
if: steps.check-version.outputs.already_published != 'true' && github.event_name == 'release'
69+
uses: actions/github-script@v7
70+
with:
71+
script: |
72+
const packageJson = require('./package.json');
73+
github.rest.issues.createComment({
74+
issue_number: context.issue.number,
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
body: `🎉 Successfully published \`${packageJson.name}@${packageJson.version}\` to npm!\n\nInstall with:\n\`\`\`bash\nnpm install -g ${packageJson.name}\n\`\`\``
78+
});
79+
80+
- name: Version already published
81+
if: steps.check-version.outputs.already_published == 'true'
82+
run: |
83+
echo "ℹ️ Skipping publish - version already exists on npm"
84+
exit 0

.npmignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Test files
2+
scripts/test-*.js
3+
scripts/*.ps1
4+
5+
# Documentation (most can be included, but some might be too large)
6+
FINAL_SUMMARY.txt
7+
GPT-reports.md
8+
IMPLEMENTATION_SUMMARY.md
9+
baseline-app.md
10+
changelog.md
11+
OVERLAY_PROOF.png
12+
13+
# Project management
14+
# Note: .github/ is excluded to reduce package size.
15+
# Workflow files are still visible in the GitHub repository for transparency.
16+
.github/
17+
.git/
18+
.gitignore
19+
20+
# Development files
21+
*.swp
22+
*.swo
23+
.DS_Store
24+
Thumbs.db
25+
.vscode/
26+
.idea/
27+
28+
# Build artifacts
29+
out/
30+
build/
31+
dist/
32+
*.log
33+
34+
# Specific directories
35+
ultimate-ai-system/
36+
docs/
37+
38+
# Keep these important files for npm users
39+
# README.md
40+
# LICENSE.md
41+
# QUICKSTART.md
42+
# INSTALLATION.md
43+
# CONTRIBUTING.md
44+
# ARCHITECTURE.md
45+
# CONFIGURATION.md
46+
# TESTING.md

CONTRIBUTING.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Contributing to Copilot-Liku CLI
2+
3+
Thank you for your interest in contributing to Copilot-Liku CLI! This guide will help you get started with local development.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- **Node.js** v22 or higher
10+
- **npm** v10 or higher
11+
- **Git**
12+
- (On Windows) **PowerShell** v6 or higher
13+
14+
### Initial Setup
15+
16+
1. **Fork and clone the repository:**
17+
```bash
18+
git clone https://github.com/YOUR-USERNAME/copilot-Liku-cli.git
19+
cd copilot-Liku-cli
20+
```
21+
22+
2. **Install dependencies:**
23+
```bash
24+
npm install
25+
```
26+
27+
3. **Link for global usage (recommended for testing):**
28+
```bash
29+
npm link
30+
```
31+
32+
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.
33+
34+
4. **Verify the setup:**
35+
```bash
36+
liku --version
37+
liku --help
38+
```
39+
40+
### Development Workflow
41+
42+
#### Testing Your Changes
43+
44+
After making changes to the CLI code:
45+
46+
1. **Test the CLI commands:**
47+
```bash
48+
liku --help # Test help output
49+
liku start # Test starting the app
50+
liku click "Button" # Test automation commands
51+
```
52+
53+
2. **Run existing tests:**
54+
```bash
55+
npm test # Run test suite
56+
npm run test:ui # Run UI automation tests
57+
```
58+
59+
3. **Manual testing:**
60+
```bash
61+
# Start the application
62+
liku start
63+
64+
# Test specific commands
65+
liku screenshot
66+
liku window "VS Code"
67+
```
68+
69+
#### Unlinking When Done
70+
71+
If you need to unlink your development version:
72+
```bash
73+
npm unlink -g copilot-liku-cli
74+
```
75+
76+
Or to install the published version:
77+
```bash
78+
npm unlink -g copilot-liku-cli
79+
npm install -g copilot-liku-cli
80+
```
81+
82+
### Project Structure
83+
84+
```
85+
copilot-Liku-cli/
86+
├── src/
87+
│ ├── cli/ # CLI implementation
88+
│ │ ├── liku.js # Main CLI entry point
89+
│ │ ├── commands/ # Command implementations
90+
│ │ └── util/ # CLI utilities
91+
│ ├── main/ # Electron main process
92+
│ ├── renderer/ # Electron renderer process
93+
│ └── shared/ # Shared utilities
94+
├── scripts/ # Build and test scripts
95+
├── docs/ # Additional documentation
96+
└── package.json # Package configuration with bin entry
97+
```
98+
99+
### Making Changes
100+
101+
#### Adding a New CLI Command
102+
103+
1. Create a new command file in `src/cli/commands/`:
104+
```javascript
105+
// src/cli/commands/mycommand.js
106+
async function run(args, options) {
107+
// Command implementation
108+
console.log('Running my command with args:', args);
109+
return { success: true };
110+
}
111+
112+
module.exports = { run };
113+
```
114+
115+
2. Register the command in `src/cli/liku.js`:
116+
```javascript
117+
const COMMANDS = {
118+
// ... existing commands
119+
mycommand: {
120+
desc: 'Description of my command',
121+
file: 'mycommand',
122+
args: '[optional-arg]'
123+
},
124+
};
125+
```
126+
127+
3. Test your command:
128+
```bash
129+
liku mycommand --help
130+
```
131+
132+
#### Modifying the CLI Parser
133+
134+
The main CLI logic is in `src/cli/liku.js`. Key functions:
135+
- `parseArgs()` - Parses command-line arguments
136+
- `executeCommand()` - Loads and runs command modules
137+
- `showHelp()` - Displays help text
138+
139+
### Code Style
140+
141+
- Follow existing code conventions
142+
- Use meaningful variable names
143+
- Add comments for complex logic
144+
- Keep functions focused and small
145+
146+
### Testing Guidelines
147+
148+
1. **Test your changes locally** before submitting a PR
149+
2. **Ensure existing tests pass**: `npm test`
150+
3. **Add tests for new features** when applicable
151+
4. **Test cross-platform** if possible (Windows, macOS, Linux)
152+
153+
### Submitting Changes
154+
155+
1. **Create a feature branch:**
156+
```bash
157+
git checkout -b feature/my-feature
158+
```
159+
160+
2. **Make your changes and commit:**
161+
```bash
162+
git add .
163+
git commit -m "Add feature: description"
164+
```
165+
166+
3. **Push to your fork:**
167+
```bash
168+
git push origin feature/my-feature
169+
```
170+
171+
4. **Open a Pull Request** on GitHub with:
172+
- Clear description of changes
173+
- Reasoning for the changes
174+
- Any testing performed
175+
- Screenshots if UI changes
176+
177+
### Troubleshooting
178+
179+
#### `liku` command not found after `npm link`
180+
181+
Make sure npm's global bin directory is in your PATH:
182+
```bash
183+
npm bin -g
184+
```
185+
186+
Add the output directory to your PATH if needed.
187+
188+
#### Changes not reflected when running `liku`
189+
190+
1. Verify you're linked to the local version:
191+
```bash
192+
which liku # Unix/Mac
193+
where liku # Windows
194+
```
195+
196+
2. Re-link if needed:
197+
```bash
198+
npm unlink -g copilot-liku-cli
199+
npm link
200+
```
201+
202+
#### Permission errors with `npm link`
203+
204+
On some systems, you may need to configure npm to use a user-local prefix:
205+
```bash
206+
mkdir ~/.npm-global
207+
npm config set prefix '~/.npm-global'
208+
```
209+
210+
Then add `~/.npm-global/bin` to your PATH.
211+
212+
### Additional Resources
213+
214+
- [npm link documentation](https://docs.npmjs.com/cli/v10/commands/npm-link)
215+
- [npm bin configuration](https://docs.npmjs.com/cli/v10/configuring-npm/folders#executables)
216+
- [Project Architecture](ARCHITECTURE.md)
217+
- [Testing Guide](TESTING.md)
218+
219+
### Getting Help
220+
221+
- Check existing [GitHub Issues](https://github.com/TayDa64/copilot-Liku-cli/issues)
222+
- Join discussions in the repository
223+
- Review documentation files in the repo
224+
225+
Thank you for contributing! 🎉

0 commit comments

Comments
 (0)