Files
CherryHQ-cherry-studio/packages/shared/__tests__
George·Dong 96502a08ce feat(code-tools): add OpenCode CLI tool support (#12576)
* feat(code-tools): add OpenCode CLI tool support

* fix(opencode): handle existing opencode.json config merge

* refactor(opencode): remove marker field and add debounce cleanup

* fix(opencode): improve config generation for different providers

* fix(opencode): use dynamic provider name to avoid race conditions

* fix(opencode): sanitize provider name and fix reasoningEffort config

- Add sanitizeProviderName function to replace spaces with dashes
- Only add reasoningEffort field when model supports it
- Use friendly provider name from getFancyProviderName

* feat(opencode): add Anthropic thinking budget tokens support

* refactor(code-tools): clean up OpenCode CLI implementation

* fix(opencode): merge config instead of overwriting and clean precisely

* fix(opencode): clean backup content before preserving

* fix(opencode): use jsonc-parser instead of new Function for JSONC parsing

* chore: update lockfile for jsonc-parser dependency

* fix(opencode): optimize test&APIKey

* refactor(opencode): move JSONC utilities to shared package

- Move parseJSONC, getFunctionalKeys, sanitizeEnvForLogging to packages/shared/utils.ts
- Export SENSITIVE_ENV_KEYS and NON_FUNCTIONAL_KEYS constants
- Add comprehensive unit tests for all three functions
- Update CodeToolsService to import from @shared/utils

* test(naming): add unit tests for sanitizeProviderName

* fix(opencode): optimize test & fix race condition

- Remove duplicate test file that duplicated tests in shared/utils
  - Fix duplicate parseJSONC call by using JSON.parse(JSON.stringify())
  - Replace redundant includes('openai') check with strict array matching
  - Consolidate duplicate imports in index.ts
  - Extend cleanup timer from 60s to 5 minutes to avoid race conditions

* refactor(shared): move jsonc-parser import to top level
2026-02-06 10:25:34 +08:00
..