Commit Graph

496 Commits

Author SHA1 Message Date
YeonGyu-Kim bf2c104c9e Merge pull request #3172 from code-yeongyu/fix/bom-strip-jsonc
fix(jsonc-parser): strip UTF-8 BOM before parsing
2026-04-07 14:51:00 +09:00
YeonGyu-Kim daae6ed05b fix(jsonc-parser): strip UTF-8 BOM before parsing to fix Windows "InvalidSymbol at offset 0" errors
Windows editors often save UTF-8 files with a BOM (Byte Order Mark: \uFEFF).
When this is present, jsonc-parser reports InvalidSymbol at offset 0 because
the BOM is not valid JSON/JSONC syntax.

This commit strips the BOM before parsing, fixing issues #3164 where Windows
users report their opencode.jsonc file fails to parse even though it appears
to start with a valid '{' character.

Fixes: #3164
Co-authored-by: Jobdori <agent@yeongyu.kim>
2026-04-07 14:48:30 +09:00
YeonGyu-Kim f8c626086e fix(agent-names): use HTTP-header-safe display names and config keys for API calls (#3138)
Display names with parentheses like 'Atlas (Plan Executor)' cause HTTP
header validation errors in x-opencode-agent-name. This was blocking
Atlas/Prometheus from working via /start-work and auto-retry.

Changes:
- Display names: parens -> dashes ('Atlas - Plan Executor')
- Hooks (start-work, no-hephaestus-non-gpt, no-sisyphus-gpt): use
  config keys ('atlas', 'sisyphus', 'hephaestus') for agent API fields
- auto-retry: use config key instead of display name for promptAsync
- agent-override-protection: handle dash-suffix normalization
- Updated all test expectations to match new format

Closes #3138
2026-04-07 10:08:04 +09:00
YeonGyu-Kim 178b635d72 feat(agents): add ZWSP stable-sort prefixes for core agent list ordering
Populate AGENT_LIST_SORT_PREFIXES for sisyphus/hephaestus/prometheus/atlas
so the TUI agent list renders in canonical order. Update dependent tests
to use getAgentListDisplayName() instead of hardcoded display strings.

🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) assistance
2026-04-06 18:07:07 +09:00
YeonGyu-Kim 61083d499d fix(oauth+errors): OAuth silent refresh, quota STOP patterns, compaction loop cap
Bug fixes:
1. OAuth token refresh (#3149): buildHttpRequestInit() now attempts silent refresh
   via refresh_token before triggering full browser re-auth. Added refresh() method
   to McpOAuthProvider. Includes test isolation fix for discovery mock.

2. Quota error STOP (#3126): Added STOP_MESSAGE_PATTERNS in model-error-classifier
   that take precedence over RETRYABLE_MESSAGE_PATTERNS. Message-only quota errors
   now non-retryable. Runtime-fallback: quota_exceeded with 'retrying in' signal
   still triggers fallback (provider-managed auto-retry). Restored removed patterns.

3. Compaction loop (#3127): MAX_RECOVERY_ATTEMPTS=3 cap + additional suppression
   guard from opencode session in degradation monitor.

Also: refactored extractAutoRetrySignal to auto-retry-signal.ts, new regression
tests for quota classifier and compaction degradation monitor.
2026-04-06 17:40:12 +09:00
YeonGyu-Kim 6c4e0b69a5 fix(agents): enforce Sisyphus->Hephaestus->Prometheus->Atlas assembly order
Extract hephaestus into agentConfig before prometheus so the config
handler naturally assembles agents in the canonical order instead of
relying solely on reorderAgentsByPriority to fix the wrong intermediate
order. Also fix test data that had atlas/prometheus swapped and add
missing hephaestus to agent-config-integration test lists.
2026-04-06 17:18:47 +09:00
YeonGyu-Kim f69234ab7e fix(error-classifier): quota/billing errors are non-retryable STOP (fixes #3126)
Add STOP_MESSAGE_PATTERNS that take precedence over RETRYABLE_MESSAGE_PATTERNS.
Message-only quota errors (no error name) now correctly return false from
isRetryableModelError, preventing unnecessary fallback retries on exhausted quotas.

- quota will reset after...
- quota exceeded
- usage limit has been reached
- free usage limit / billing limit / plan limit / subscription limit
- out of credits / credits exhausted / insufficient credits / insufficient balance

Also add 4 regression tests covering message-only quota STOP cases.
2026-04-06 16:56:17 +09:00
YeonGyu-Kim 22d0895992 Merge pull request #3136 from andrescera/fix/atlas-zwsp-header-leak
fix: remove ZWSP sort prefix that leaks into x-opencode-agent-name header
2026-04-06 13:55:08 +09:00
YeonGyu-Kim de6c74bfb4 fix(todo-continuation): normalize agent name to config key before promptAsync (#3149)
The todo-continuation-enforcer was passing raw agent names (which could be
display names like 'Sisyphus (Ultraworker)') to promptAsync. These names
contain spaces/parentheses that violate HTTP header specs, causing the
x-opencode-agent-name header validation to fail with 'unknown error' toast.

Added normalizeAgentForPromptKey() that converts display names to config keys
(e.g., 'Sisyphus (Ultraworker)' -> 'sisyphus') before API calls.

TDD: Added regression test that verifies config key is sent to promptAsync.
2026-04-06 11:44:52 +09:00
Andres Cera b482e6c609 fix: remove ZWSP sort prefix from Atlas agent name
The \u200B (zero-width space) in AGENT_LIST_SORT_PREFIXES leaked into
the x-opencode-agent-name HTTP header, causing invalid header errors.

Agent ordering is handled by agent-priority-order.ts via numeric order
fields and insertion order — the ZWSP prefix was redundant.
2026-04-05 00:43:05 -05:00
YeonGyu-Kim d7c2b6249b fix(config): fall back to legacy path when migration fails and use canonical basename everywhere (#3133)
Root cause: loadPluginConfig() unconditionally switched userConfigPath to the
canonical name after calling migrateLegacyConfigFile(), even when migration
failed (e.g. file lock on Windows, permission denied). This left the config
path pointing to a non-existent file, so the plugin config silently loaded
as empty defaults.

Additionally, several fallback/default paths were hardcoded to the legacy
'oh-my-opencode' basename instead of using CONFIG_BASENAME ('oh-my-openagent'),
causing CLI config commands (writeOmoConfig, detectCurrentConfig) to write to
the wrong filename.

Changes:
- plugin-config.ts: check migrateLegacyConfigFile() return value; only switch
  to canonical path if migration succeeded OR the canonical file already exists
- opencode-config-dir.ts: use CONFIG_BASENAME for omoConfig path in
  getOpenCodeConfigPaths()
- config-context.ts: getOmoConfigPath() now uses detectPluginConfigFile() to
  find whichever name variant actually exists on disk
- plugin-config.ts: default fallback paths use CONFIG_BASENAME instead of
  hardcoded legacy name
- Added test: loadPluginConfig still loads config when migration fails
  (read-only directory simulation)
2026-04-05 14:27:24 +09:00
YeonGyu-Kim 7b7526e2f6 docs(src): update counts across tools, features, config, cli AGENTS.md
- tools: 15 -> 16 dirs, writing model kimi-k2p5 -> gemini-3-flash
- features: builtin skills 6 -> 8 (+review-work, +ai-slop-remover)
- config: schema files 24 -> 27 (+git-env-prefix, model-capabilities, openclaw)
- cli: commands 5 -> 6 (+refresh-model-capabilities)
- plugin-handlers: 13 -> 14 non-test files
- shared: 95+ -> 100+ utility files
2026-04-05 14:12:31 +09:00
YeonGyu-Kim 33b17519e5 test(config-dir): align opencode config basename
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-05 13:42:37 +09:00
YeonGyu-Kim 852859ed9c refactor(config-manager): remove legacy config path detection and migration logic
🤖 Generated with assistance of OhMyOpenCode
2026-04-05 11:24:10 +09:00
YeonGyu-Kim f22935cb28 Config-manager: migrate legacy OMO config path 2026-04-05 11:24:10 +09:00
YeonGyu-Kim 0cbfdec76e fix(model): treat 'bad request' as retryable error for GitHub Copilot fallback (#3130)
GitHub Copilot performs rolling model updates which sometimes return
'400 Bad Request' when a model is temporarily unavailable. This error
was not in the retryable message patterns, causing model fallback to
not trigger and users getting stuck.

Changes:
- Added 'bad request' to RETRYABLE_MESSAGE_PATTERNS in model-error-classifier.ts
- Added test cases for 'bad request' pattern matching

Fixes #3130
2026-04-05 10:18:15 +09:00
YeonGyu-Kim 130f4ac080 fix: resolve #3124 #3125 #3127 session tools, cache priming, and compaction loop
- #3124: Session tools now merge SDK and file-backed sessions for SQLite backend
- #3125: Cache priming fixed for OpenCode >=1.3.14 empty workspace
- #3127: Activity-based progress detection prevents infinite compaction on Kimi/Minimax

All 29 new tests pass, 4885 total tests passing.
2026-04-05 09:30:19 +09:00
YeonGyu-Kim aeb9c97c30 fix(model): quota errors should STOP not retry 2026-04-05 09:13:14 +09:00
YeonGyu-Kim aa7e2aa07f test: isolate migrate-legacy-plugin-entry.test.ts to prevent mock contamination 2026-04-04 21:32:52 +09:00
YeonGyu-Kim f3840a7325 Merge pull request #2843 from code-yeongyu/refactor/model-alias-pattern-matching
refactor(aliases): migrate to pattern-based model alias resolution
2026-04-04 20:34:38 +09:00
YeonGyu-Kim 1f13e76d11 Merge pull request #3065 from code-yeongyu/fix/issue-2984-v2
fix: reset consecutiveFailures on abort so session recovers after user cancel
2026-04-04 20:34:10 +09:00
YeonGyu-Kim 55d5ecb9fb test: fresh-import remaining contamination-prone modules 2026-04-04 20:14:50 +09:00
YeonGyu-Kim 861ce1c161 test: remove provider and cache mock leak paths 2026-04-04 20:06:56 +09:00
YeonGyu-Kim 29a830dd89 test: remove remaining legacy warning mock leaks 2026-04-04 19:52:25 +09:00
YeonGyu-Kim a4db240d47 test: localize mock.module setup to fresh imports 2026-04-04 19:49:25 +09:00
YeonGyu-Kim 8b8559f39d test: load real modules with unique import ids 2026-04-04 19:42:18 +09:00
YeonGyu-Kim b0f754f506 test: import real modules in contamination-prone tests 2026-04-04 19:41:11 +09:00
YeonGyu-Kim 051a39889d test(shared): use unique temp dirs for legacy plugin warning 2026-04-04 19:33:17 +09:00
YeonGyu-Kim ad025ee0f8 test: isolate flaky shared-state tests 2026-04-04 19:20:59 +09:00
YeonGyu-Kim 733b54865f fix(config): handle tuple-format plugin entries in opencode.json (fixes #3122)
OpenCode supports plugin entries as [string, object] tuples for passing
options, but loadOpencodePlugins assumed all entries were strings.
When a tuple entry hit matchesKnownPlugin, it called .toLowerCase()
on an array, crashing the plugin on startup.

Extract the string name from tuple entries and skip non-string values.
Add regression test covering the tuple plugin format.
2026-04-04 16:44:40 +09:00
YeonGyu-Kim cba9c25543 Merge pull request #3111 from code-yeongyu/fix/prepublish-config-regression
fix(config): use canonical path after legacy migration and make writes atomic
2026-04-04 14:56:52 +09:00
YeonGyu-Kim 726d19c3cc fix(security): make tar parser strictly fail-closed on any unparsed line 2026-04-04 14:48:44 +09:00
YeonGyu-Kim 0c6907adc3 fix(config): use canonical path after legacy migration and make writes atomic 2026-04-04 14:46:29 +09:00
YeonGyu-Kim d368f77fcd fix(security): make tar archive preflight fail-closed on unparsed entries 2026-04-04 14:27:46 +09:00
YeonGyu-Kim 6acca09bd0 fix(ci): resolve mock.module() cross-file leakage in test suite
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 02:35:23 +09:00
YeonGyu-Kim f547cd013d refactor(shared): consolidate plugin entry migration and detection utilities 2026-04-04 02:10:27 +09:00
YeonGyu-Kim fd252ea82e refactor: remove AI-generated code smells from prepublish changes
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 02:02:12 +09:00
YeonGyu-Kim e4d7fdb7e9 Merge pull request #3092 from code-yeongyu/fix/prepublish-legacy-config
fix(shared): close legacy config migration gaps
2026-04-04 01:46:52 +09:00
YeonGyu-Kim f03c6700d4 fix(hooks): reuse shared legacy plugin migration helper
Replace the legacy toast regex writer with the shared atomic helper and route legacy plugin call sites through small wrappers so existing mock.module tests stop leaking across the suite.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:32:59 +09:00
YeonGyu-Kim 290f7f9543 fix(shared): merge project and user opencode plugin detection
Stop dropping user-level plugin conflicts when an empty project config exists by collecting plugin entries from every supported OpenCode config path.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:32:42 +09:00
YeonGyu-Kim fedb73c736 fix(shared): migrate legacy config files atomically
Write the canonical config through a temp file and remove the legacy dual-file trap by archiving or deleting the old basename after migration.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:32:31 +09:00
YeonGyu-Kim d60ca63ed4 test(config): add regression coverage for legacy migration bugs
Lock the current legacy config and plugin migration failures in place before the fixes land so the three regressions stay covered.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:32:17 +09:00
YeonGyu-Kim ccbd646a29 fix(shared): validate tar hard-link targets during preflight
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:16:37 +09:00
YeonGyu-Kim 553a961338 fix(shared): emit PowerShell zip entries as json lines
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:16:30 +09:00
YeonGyu-Kim 0c5deac232 test(shared): add archive preflight security regressions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:16:21 +09:00
YeonGyu-Kim 53eeac3f31 fix(ci): simplify test runner to plain bun test by fixing mock.module() leakage
- Add afterAll(() => { mock.restore() }) to 52 test files missing cleanup
- Rewrite create-tool-guard-hooks.test.ts to use spyOn instead of barrel mock
- Fix skill-mcp-manager OAuth tests with missing mockTokens/mockLogin definitions
- Fix start-work hook: show worktree active block on resume with existing worktree_path
- Extract createWorktreeActiveBlock to worktree-block.ts to avoid circular import
- Replace 80-line isolated test runner CI config with single `bun test` command
2026-04-04 00:34:03 +09:00
YeonGyu-Kim e0feb16dab refactor(shared,config): remove redundant null checks and AI slop from code comments 2026-04-03 19:39:55 +09:00
YeonGyu-Kim d0f795dd8f refactor(shared): decompose model-capabilities into focused modules 2026-04-03 19:38:26 +09:00
YeonGyu-Kim 3cc9e8bc30 refactor(shared): extract shared cache factory to deduplicate cache patterns 2026-04-03 19:36:56 +09:00
YeonGyu-Kim 3180389dea Merge pull request #3052 from code-yeongyu/fix/p0-1-task-system-default-split-brain
fix: resolve task_system default split-brain
2026-04-03 18:52:40 +09:00