Browse Source

Merge pull request #624

fix: add service unavailable pattern to foreground fallback
Alvin 1 month ago
parent
commit
9c3542a93e

+ 7 - 7
docs/project-local-customization.md

@@ -4,8 +4,8 @@ This document describes how to configure and customize oh-my-opencode-slim on a
 
 ## Security & Trust Boundary Warning
 
-> ⚠️ **IMPORTANT SECURITY NOTICE**  
-> Because project-local configuration files (`.opencode/oh-my-opencode-slim.jsonc`) and prompt templates (`.opencode/oh-my-opencode-slim/`) are loaded automatically when you open and work in a project directory, they can modify agent behaviors, enable/disable tools, and grant extra model access permissions.  
+> ⚠️ **IMPORTANT SECURITY NOTICE**
+> Because project-local configuration files (`.opencode/oh-my-opencode-slim.jsonc`) and prompt templates (`.opencode/oh-my-opencode-slim/`) are loaded automatically when you open and work in a project directory, they can modify agent behaviors, enable/disable tools, and grant extra model access permissions.
 > **Only work in and run OpenCode within repositories you explicitly trust.**
 
 ---
@@ -30,7 +30,7 @@ This document describes how to configure and customize oh-my-opencode-slim on a
 When oh-my-opencode-slim loads, it resolves configuration properties and prompt templates across multiple layers. The inheritance precedence operates strictly as follows:
 
 ```
-[Built-in Defaults] 
+[Built-in Defaults]
        ↓ (overridden by)
 [User Config] (global)
        ↓ (overridden by)
@@ -52,13 +52,13 @@ The root `agents.*` configuration (defined at the top level of user or project c
 
 When looking up markdown prompt template files (such as `<agent>.md` or `<agent>_append.md`), oh-my-opencode-slim searches directories in a strict hierarchical order. Precedence is evaluated for the replacement prompt file and the append prompt file **independently** in the following sequence:
 
-1. **Project Preset Directory**  
+1. **Project Preset Directory**
    `<project>/.opencode/oh-my-opencode-slim/<preset>/<agent>.md` (if preset is active and safe)
-2. **Project Root Directory**  
+2. **Project Root Directory**
    `<project>/.opencode/oh-my-opencode-slim/<agent>.md`
-3. **User Preset Directory (Global)**  
+3. **User Preset Directory (Global)**
    `<user-config-dir>/oh-my-opencode-slim/<preset>/<agent>.md`
-4. **User Root Directory (Global)**  
+4. **User Root Directory (Global)**
    `<user-config-dir>/oh-my-opencode-slim/<agent>.md`
 
 ---

+ 7 - 6
src/hooks/foreground-fallback/index.test.ts

@@ -89,11 +89,14 @@ describe('isRateLimitError', () => {
     expect(isRateLimitError({ message: 'Insufficient balance.' })).toBe(true);
   });
 
+  test('returns true for "Service Unavailable"', () => {
+    expect(isRateLimitError({ message: 'Service Unavailable' })).toBe(true);
+  });
+
   test('returns true for "Monthly usage limit reached"', () => {
     expect(
       isRateLimitError({
-        message:
-          'Monthly usage limit reached. Resets in X days.',
+        message: 'Monthly usage limit reached. Resets in X days.',
       }),
     ).toBe(true);
   });
@@ -101,8 +104,7 @@ describe('isRateLimitError', () => {
   test('returns true for "5-hour usage limit reached"', () => {
     expect(
       isRateLimitError({
-        message:
-          '5-hour usage limit reached. Resets in 36min.',
+        message: '5-hour usage limit reached. Resets in 36min.',
       }),
     ).toBe(true);
   });
@@ -110,8 +112,7 @@ describe('isRateLimitError', () => {
   test('returns true for "Weekly usage limit reached"', () => {
     expect(
       isRateLimitError({
-        message:
-          'Weekly usage limit reached. Resets in 2 days.',
+        message: 'Weekly usage limit reached. Resets in 2 days.',
       }),
     ).toBe(true);
   });

+ 3 - 0
src/hooks/foreground-fallback/index.ts

@@ -43,6 +43,9 @@ const RATE_LIMIT_PATTERNS = [
   /insufficient.?(quota|balance)/i,
   /high concurrency/i,
   /reduce concurrency/i,
+  // ponytail: transient server errors mixed in; rename to isRetryableError
+  // and split from rate-limit detection when this list grows further
+  /service unavailable/i,
   /monthly usage limit/i,
   /5-hour usage limit/i,
   /weekly usage limit/i,

+ 0 - 1
src/skills/release-smoke-test/SKILL.md

@@ -157,4 +157,3 @@ what else loaded.
 - Crash signature search:
 - Limitations:
 ```
-