feat: Implement Prompt Builder functionality in Popup and Options
Some checks failed
CI — Test & Build / Test & Build (push) Failing after 39s

- Added a new "Prompt Builder" tab in the Popup for generating AI prompts with customizable parameters.
- Introduced new state variables for managing prompt styles, personas, formats, and models.
- Enhanced the Options page to fetch and display models based on the provided API key.
- Updated the actions and types to include the new 'prompt' action and its associated parameters.
- Implemented migration logic for legacy plaintext API keys to encrypted storage.
- Updated the getSystemPrompt function to incorporate prompt parameters for better instruction generation.
- Added tests for the new functionality, including context menu entries and prompt generation logic.
This commit is contained in:
john kevin asprec
2026-07-15 15:27:41 +08:00
parent 0fef9848cb
commit acea99d7ad
40 changed files with 1971 additions and 177 deletions

48
docs/EVALS.md Normal file
View File

@@ -0,0 +1,48 @@
# Project evaluations — LexAI
> Small, repeatable checks. Prefer a deterministic command or test over a prose reminder. The standing checks below are the baseline gates for any change.
## Standing gates (run on every change)
### E-BASE-01 — Typecheck
- **How to run:** `npm run typecheck`
- **Pass condition:** `tsc --noEmit` exits 0.
- **Cost:** fast.
### E-BASE-02 — Unit tests
- **How to run:** `npm test -- --run`
- **Pass condition:** vitest exits 0.
- **Note:** current unit tests exercise the `chrome.storage` mock, not the real handlers — passing does **not** prove provider routing or key decrypt. See TASKS #8.
### E-BASE-03 — Production build
- **How to run:** `npm run build`
- **Pass condition:** builds to `.output/chrome-mv3/`; bundle roughly ~166 KB baseline.
- **Cost:** fast (~3s).
### E-BASE-04 — Manual real-page check (behavior changes)
- **How to run:** `npm run build` → load unpacked `.output/chrome-mv3` → select text on a textarea and a contenteditable site → run an action → Replace.
- **Pass condition:** toolbar shows, result modal returns, Replace edits both target types.
- **Why manual:** selection/replace is DOM-timing-sensitive and has no automated coverage.
## Active failure-derived checks
_No failure-derived checks yet. Add one here when a verified regression gives a deterministic trigger — e.g. a guard that fails if the built `content.js` still contains `[LexAI` logs (T-03), or a test asserting the `onMessage` listener returns `true`._
## Eval template
```markdown
### E-YYYY-MM-DD-NN — [short check name]
- **Prevents:** [lesson ID and failure mode]
- **How to run:** `[exact command or steps]`
- **Pass condition:** [observable]
- **Cost:** fast | moderate | expensive
- **Last verified:** [date + result]
```
## Retired checks
_Move obsolete checks here with the reason and the lesson they covered._