- 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.
2.3 KiB
LexAI CLI — Prompt Builder
Part of the LexAI monorepo (packages/cli). Complements the Chrome and VS Code packages.
Improve a rough idea into a paste-ready engineered prompt before you fire it at Claude Code, Cursor, or another agent.
BYO-LLM only — no LexAI servers. Uses the same Prompt Builder core as the Chrome and VS Code extensions.
Install (from this repo)
# from repo root
npm run cli:install
npm run cli:build
# make `lexai` available on your PATH
cd packages/cli && npm link
Or run without linking:
node packages/cli/out/cli.js prompt "your rough idea"
Setup
# PowerShell
$env:LEXAI_API_KEY = "sk-..."
$env:LEXAI_PROVIDER = "openai" # optional: openai | anthropic | groq | openrouter
$env:LEXAI_MODEL = "gpt-4o" # optional
Optional defaults file (no API key allowed here): ~/.lexai/config.json
{
"provider": "openai",
"model": "gpt-4o",
"pattern": "role",
"persona": "Expert Developer",
"format": "Markdown",
"style": "Concise"
}
Precedence: flags > config file > env > defaults. Key is always from LEXAI_API_KEY.
Usage
lexai prompt "add rate limiting to the express auth routes"
echo "debug flaky playwright on CI" | lexai prompt --pattern role --persona "Expert Developer"
lexai prompt -f draft.txt --format Markdown --model gpt-4o
lexai prompt --list
lexai prompt --help
The engineered prompt is written to stdout (pipe-safe). Progress and errors go to stderr.
# Windows: copy to clipboard
lexai prompt "write a unit test for parseConfig" | Set-Clipboard
Flags
| Flag | Meaning |
|---|---|
-f, --file <path> |
Read input from file |
--pattern <id> |
Pattern id (auto, role, cot, …) — see --list |
--persona <name|text> |
Persona preset or free text |
--format <name> |
Output format hint |
--style <name> |
Style the engineered prompt should request |
--provider / --model |
Provider overrides |
-l, --list |
List patterns, personas, formats, styles |
-h, --help |
Help |
Exit codes: 0 success · 1 user/config error · 2 provider/network error
Scope
In: Make Prompt / Prompt Builder only.
Out: Fix/Rephrase/Code Assist, reading VS Code/Chrome keys, auto-running shell commands.