feat(cli): add initial CLI implementation with argument parsing and prompt handling
Some checks failed
CI — Test & Build / Test & Build (pull_request) Has been cancelled
Preview — PR Build Check / PR Preview Build (pull_request) Has been cancelled

- Created package.json and package-lock.json for CLI package.
- Implemented argument parsing in args.ts to handle various flags and commands.
- Developed main CLI logic in cli.ts to execute commands and handle errors.
- Added configuration loading from a JSON file in config.ts, with environment variable support.
- Implemented prompt resolution and provider interaction in prompt.ts.
- Added usage documentation for the CLI.
- Configured TypeScript settings in tsconfig.json for the CLI package.
- Updated README in vscode package to reflect the new CLI functionality.
- Refactored root tsconfig.json to streamline project structure.
This commit is contained in:
john kevin asprec
2026-08-13 19:19:42 +08:00
parent d63d698b57
commit 2c00d2e431
37 changed files with 9303 additions and 166 deletions

View File

@@ -1,41 +1,72 @@
# LexAI — AI Writing Assistant
# LexAI
A Grammarly-like Chrome Extension powered by **your own LLM API key**. No monthly subscription. Full control.
**Bring your own LLM key.** LexAI is an open-source writing (and coding) assistant with **no LexAI backend, no account, and no subscription**. Your text and API key go only to the provider you choose.
## Features (Roadmap)
- ✅ Grammar & spelling correction
- ✅ Rephrase / rewrite text
- ✅ Shorten or expand text
- 🔜 Tone suggestions
- 🔜 Autocomplete
- 🔜 Custom style profiles
| Package | What it is | Docs |
| --- | --- | --- |
| **[packages/chrome](packages/chrome)** | Chrome MV3 extension — select text on any page → Fix / Rephrase / Shorten / Expand / Explain / Make Prompt | [README](packages/chrome/README.md) · [Chrome Web Store](https://chromewebstore.google.com/detail/bagpcheidbkfgijnnmolnkgagibbjfnk) |
| **[packages/vscode](packages/vscode)** | VS Code / Cursor extension — writing actions + workspace-aware **Code Assist** | [README](packages/vscode/README.md) · [Deploy](packages/vscode/DEPLOY.md) |
| **[packages/cli](packages/cli)** | CLI **Prompt Builder** — improve a rough idea into a paste-ready prompt | [README](packages/cli/README.md) |
## Supported LLM Providers
- **OpenAI** (GPT-4o, GPT-4o-mini)
- **Anthropic** (Claude 3.5 Haiku, Sonnet)
- **Groq** (free tier — fast!)
- **OpenRouter** (100+ models)
Shared provider/prompt core: [`src/lib`](src/lib).
## Tech Stack
- WXT + React 18 + TypeScript
- Manifest V3
- Inline-styled UI (no CSS framework)
## Development
## Quick start
```bash
npm install
npm run dev # Dev mode with hot reload
npm run build # Production build
npm run zip # Package for Chrome Web Store
npm test # Run unit tests
# Prerequisites: Node 22+
git clone https://git.juankibin.space/kibin/LexAI.git
cd LexAI
# Install all packages
npm run install:all
# Chrome extension (dev)
npm run chrome:dev
# VS Code extension
npm run vscode:build
# then F5 / Install from VSIX — see packages/vscode/README.md
# CLI Prompt Builder
npm run cli:build
export LEXAI_API_KEY=sk-... # PowerShell: $env:LEXAI_API_KEY="sk-..."
node packages/cli/out/cli.js prompt "add rate limiting to the auth routes"
```
## Load in Chrome
1. Run `npm run build`
2. Open Chrome → `chrome://extensions`
3. Enable **Developer Mode**
4. Click **Load unpacked** → select `.output/chrome-mv3`
## Repository layout
## Project Management
Plane: LEXAI project → https://plane-pro.juankibin.space
```text
LexAI/
├── packages/
│ ├── chrome/ # Manifest V3 extension (WXT + React)
│ ├── vscode/ # VS Code / Cursor extension
│ └── cli/ # lexai prompt CLI
├── src/lib/ # Shared providers, actions, types
├── tests/ # Unit + e2e tests (run via chrome package)
├── docs/ # Project operating docs (agents / planning)
└── .gitea/ # CI workflows + issue/PR templates
```
## Supported providers
OpenAI · Anthropic · Groq · OpenRouter
## Privacy
- No LexAI servers and no LexAI telemetry
- Chrome: key encrypted in `chrome.storage.local`
- VS Code: key in Secret Storage
- CLI: key via `LEXAI_API_KEY` environment variable only
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md).
## License
[MIT](LICENSE) © LexAI contributors
## Links
- Chrome Web Store: https://chromewebstore.google.com/detail/bagpcheidbkfgijnnmolnkgagibbjfnk
- Source: https://git.juankibin.space/kibin/LexAI