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

@@ -4,7 +4,7 @@
## Current state
- **Outcome:** VSIX install built; deploy guide written.
- **Artifact:** `packages/vscode/lexai-vscode-0.1.0.vsix` (~44 KB). Guide: `packages/vscode/DEPLOY.md`.
- **Verified:** `npm run package` in `packages/vscode` succeeded.
- **Next smallest action:** Install from VSIX locally; for public store, create Marketplace publisher + `vsce publish` (set `private: false` first).
- **Outcome:** Monorepo OSS layout — Chrome in `packages/chrome`; VS Code + CLI alongside; root LICENSE/README/CONTRIBUTING/CODE_OF_CONDUCT; Gitea issue/PR templates.
- **Verified:** run `npm run chrome:install` + typecheck/test/build after pull (session in progress).
- **CI:** workflows use `packages/chrome` for install/build/zip paths.
- **Next smallest action:** `npm run chrome:install && npm run chrome:typecheck && npm run chrome:test && npm run chrome:build` then commit when ready.

View File

@@ -4,19 +4,20 @@
## Verified facts
- LexAI has two clients: Chrome MV3 (repo root / WXT) and VS Code (`packages/vscode`).
- Portable core: `src/lib/providers.ts`, `actions.ts`, `types.ts`. Chrome-only: `crypto.ts`, `messaging.ts`.
- Providers: OpenAI, Anthropic, Groq, OpenRouter — routed by `callProvider` / `PROVIDER_SPECS`.
- VS Code v1: Command Palette + editor context submenu; API key in Secret Storage; prefs `lexai.provider|model|writingStyle`.
- Selection minimum length for actions: `MIN_SELECTION_LENGTH` (10) in `src/lib/actions.ts`.
- Chrome message listener must `return true` for async replies; snapshot selection before `await`.
- LexAI monorepo: `packages/chrome` (WXT), `packages/vscode`, `packages/cli`; shared `src/lib`.
- Portable core: `providers.ts`, `actions.ts`, `types.ts`. Chrome-only: `crypto.ts`, `messaging.ts`.
- Providers: OpenAI, Anthropic, Groq, OpenRouter — `callProvider` / `PROVIDER_SPECS`.
- VS Code: Secret Storage; Code Assist; prefs `lexai.*`.
- CLI: `lexai prompt`; `LEXAI_API_KEY`; optional `~/.lexai/config.json` (no apiKey).
- Chrome entrypoints: `packages/chrome/entrypoints/`; build → `packages/chrome/.output/chrome-mv3/`.
- Selection minimum: `MIN_SELECTION_LENGTH` (10). Chrome `onMessage` must `return true`; snapshot before `await`.
## Conventions
- Style Chrome UI with inline styles (Tailwind not wired).
- Prefer encrypted Chrome key path; keep plaintext `apiKey` fallback until migration.
- VS Code must not import `@lib/crypto` or `@lib/messaging`.
- Root scripts: `vscode:install`, `vscode:build`, `vscode:typecheck`, `vscode:package`.
- VS Code / CLI must not import `@lib/crypto` or `@lib/messaging`.
- Root scripts: `install:all`, `chrome:*`, `vscode:*`, `cli:*`.
## Environment quirks
@@ -27,11 +28,12 @@
| What | Where |
| --- | --- |
| Chrome content / background / options / popup | `entrypoints/` |
| Chrome entrypoints | `packages/chrome/entrypoints/` |
| Shared lib | `src/lib/` |
| VS Code extension | `packages/vscode/src/extension.ts` |
| VS Code bundle | `packages/vscode/out/extension.js` |
| Model lanes | `docs/MODEL_ROUTING.md` |
| VS Code | `packages/vscode/` |
| CLI | `packages/cli/` |
| OSS meta | root `README.md`, `LICENSE`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md` |
| Issue/PR templates | `.gitea/ISSUE_TEMPLATE/`, `.gitea/PULL_REQUEST_TEMPLATE.md` |
## Expiring notes