Initial TrueGrowth source import

This commit is contained in:
2026-07-07 09:36:36 +08:00
commit 3b6781d695
2283 changed files with 691996 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
## Context
- The toolbox already hosts component-based tools (batch image, video analyzer). Provider routing/runtime discovery supply resolved `modelRef`/`provider` context. Task history imposes retention limits; mixing benchmark data there pollutes user tasks.
- Requirements: per-modality benchmark sessions, lightweight result store, settings shortcut, ranking modes, default low-cost prompts, manual rating/categorization.
## Goals
- Build a dedicated benchmark workbench tool that opens via toolbox or settings shortcut, orchestrates multiple supplier/model invocations per modality, and records the per-entry metrics needed for ranking.
- Keep benchmark data isolated from the core task queue while reusing adapter execution and caching preview URLs only long enough for comparison (no auto-insertion).
- Present default prompts optimized for fast, low-cost tests yet expose override points; allow sorting by speed/cost/composite and manual rating/heart to surface user favorites.
## Non-Goals
- Do not reuse the main task queue for benchmark execution.
- Do not automatically insert benchmark outputs into the canvas or media history.
- Do not implement full AI scoring in V1—manual ratings drive “效果最好”.
## Decisions
1. The workbench stores `BenchmarkSession``BenchmarkEntry` records in a new service backed by `KVStorage` (similar to prompt storage) keyed by `sessionId`.
2. Execution will call `resolveAdapterForInvocation` with the chosen `modelRef`/`modelId`/`routeType` and run `generateImage/Video/Audio` or `sendChatMessage` (for text) via the existing adapters, capturing start/finish timestamps and HTTP duration.
3. Settings dialog renders quick buttons per provider/model entry; click triggers `toolWindowService.openTool` with component props selecting the session mode (“same model other providers”, etc.).
4. Sorting modes implemented as pure client filtering on `BenchmarkEntry` metadata; default ranking uses success rate + 90th percentile completion time to favor faster results, with cost as tiebreaker.
5. Manual rating (`score` 0-5) and `favorite`/`reject` flags are stored per entry; these influence composite ranking but do not change metrics.

View File

@@ -0,0 +1,14 @@
# Change: Add Model Benchmark Workbench
## Why
- Users have no lightweight way to compare suppliers/models across modalities before spending significant cost; the toolbox and settings page both lack quick, controlled benchmarking.
- We already have runtime model discovery, provider routing, and task adapters, so adding a dedicated benchmark workbench keeps evaluation data separate from production task history while still reusing the invocation plumbing.
## What Changes
- Introduce a “Model Benchmark Workbench” tool in the toolbox that can execute benchmark sessions per modality, reuse provider/model routing, capture timing/cost metrics, and surface quick previews.
- Add a settings-page shortcut on provider/model entries that opens the workbench pre-filled with the selected context so the user can test without copying IDs manually.
- Store benchmark sessions/results in a dedicated datastore, exposing per-entry metadata needed for ranking (status, timings, cost, preview, manual rating) without cluttering the main task queue.
## Impact
- Affected specs: `toolbox`, `settings-dialog`
- Affected code: `packages/drawnix/src/tools`, `packages/drawnix/src/components/settings-dialog`, `packages/drawnix/src/services/tool-window-service`, `packages/drawnix/src/services/benchmark`

View File

@@ -0,0 +1,24 @@
## ADDED Requirements
### Requirement: Model Benchmark Workbench Tool
The system SHALL surface a "Model Benchmark Workbench" tool within the toolbox that can run benchmark sessions for text/image/video/audio modalities without inserting results into the canvas.
#### Scenario: Launching the benchmark workbench
- **GIVEN** the user opens the toolbox and selects the Model Benchmark Workbench
- **WHEN** the workbench loads
- **THEN** it SHALL present a session builder (same-model cross vendors, same-vendor cross models, custom combination) and default low-cost prompts for each modality
- **AND** SHALL allow the user to start, monitor, and stop benchmark entries, showing per-entry status, timings, and preview links.
### Requirement: Dedicated Benchmark Sessions
The system SHALL store benchmark sessions/results separately from the standard task queue, keeping for each entry the provider, model, modality, status, time-to-first-byte, completion time, estimated cost, preview, manual rating, and favorite/reject flags.
#### Scenario: Viewing past benchmark sessions
- **WHEN** the user reopens the benchmark workbench
- **THEN** previous sessions SHALL be listed with metadata and be filterable/sortable by speed, cost, rating, or favorite status.
### Requirement: Settings Shortcut Entry
The system SHALL add shortcut controls to each provider/model in the settings dialog that open the benchmark workbench with the corresponding provider, model, and modality pre-selected.
#### Scenario: Quick test from provider settings
- **GIVEN** a provider model entry rendering in the settings dialog
- **WHEN** the user clicks "快捷测试"
- **THEN** the settings dialog SHALL open the workbench window and pre-populate the session with the selected provider/model context so the user can submit the test immediately.

View File

@@ -0,0 +1,13 @@
## 1. Implementation
- [x] 1.1 Add sandboxed benchmark workbench tool: manifest, component, window plumbing, previews per modality.
- [x] 1.2 Implement benchmark session service/storage capturing status, timings, cost, preview, manual rating, favorite flag.
- [x] 1.3 Wire settings dialog provider/model list so “快捷测试” buttons open workbench with context.
- [x] 1.4 Ensure workbench consumes runtime model discovery/presets and reuses adapter routing to execute tests per modality with default prompts.
- [x] 1.5 Add UI sorting/filtering and ranking (“速度优先”, “成本优先”, “综合”) plus manual rating controls.
- [x] 1.6 Document new capability in specs delta and update design.md as needed.
## 2. Verification
- [ ] 2.1 Benchmarks can run for image/video/audio/text with selected provider/model.
- [ ] 2.2 Settings quick test buttons correctly pre-fill and open workbench.
- [ ] 2.3 Benchmark results stay in independent store and do not appear in task history.
- [x] 2.4 Ranking modes reorder results as expected.