Skip to content

Commit b377571

Browse files
committed
Update AGENTS.md documentation hierarchy with auth and hooks details
- Update root AGENTS.md with timestamp 2026-01-01T21:15:00+09:00, commit 490c0b6 - Add auto-slash-command and ralph-loop hooks to structure documentation - Add complexity hotspots, unique styles, and notes sections - Create src/auth/AGENTS.md documenting Antigravity OAuth architecture (57 lines) - Update src/hooks/AGENTS.md with new hooks documentation 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent 490c0b6 commit b377571

File tree

3 files changed

+76
-10
lines changed

3 files changed

+76
-10
lines changed

AGENTS.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PROJECT KNOWLEDGE BASE
22

3-
**Generated:** 2025-12-31T14:05:00+09:00
4-
**Commit:** 502e9f5
3+
**Generated:** 2026-01-01T21:15:00+09:00
4+
**Commit:** 490c0b6
55
**Branch:** dev
66

77
## OVERVIEW
@@ -14,12 +14,12 @@ OpenCode plugin implementing Claude Code/AmpCode features. Multi-model agent orc
1414
oh-my-opencode/
1515
├── src/
1616
│ ├── agents/ # AI agents (7): Sisyphus, oracle, librarian, explore, frontend, document-writer, multimodal-looker
17-
│ ├── hooks/ # 21 lifecycle hooks - see src/hooks/AGENTS.md
17+
│ ├── hooks/ # 22 lifecycle hooks - see src/hooks/AGENTS.md
1818
│ ├── tools/ # LSP, AST-Grep, Grep, Glob, etc. - see src/tools/AGENTS.md
1919
│ ├── mcp/ # MCP servers: context7, websearch_exa, grep_app
2020
│ ├── features/ # Claude Code compatibility - see src/features/AGENTS.md
2121
│ ├── config/ # Zod schema, TypeScript types
22-
│ ├── auth/ # Google Antigravity OAuth (antigravity/)
22+
│ ├── auth/ # Google Antigravity OAuth - see src/auth/AGENTS.md
2323
│ ├── shared/ # Utilities: deep-merge, pattern-matcher, logger, etc. - see src/shared/AGENTS.md
2424
│ ├── cli/ # CLI installer, doctor, run - see src/cli/AGENTS.md
2525
│ └── index.ts # Main plugin entry (OhMyOpenCodePlugin)
@@ -38,14 +38,16 @@ oh-my-opencode/
3838
| Add MCP | `src/mcp/` | Create config, add to index.ts and types.ts |
3939
| LSP behavior | `src/tools/lsp/` | client.ts (connection), tools.ts (handlers) |
4040
| AST-Grep | `src/tools/ast-grep/` | napi.ts for @ast-grep/napi binding |
41-
| Google OAuth | `src/auth/antigravity/` | OAuth plugin for Google models |
41+
| Google OAuth | `src/auth/antigravity/` | OAuth plugin for Google/Gemini models |
4242
| Config schema | `src/config/schema.ts` | Zod schema, run `bun run build:schema` after changes |
4343
| Claude Code compat | `src/features/claude-code-*-loader/` | Command, skill, agent, mcp loaders |
4444
| Background agents | `src/features/background-agent/` | manager.ts for task management |
4545
| Interactive terminal | `src/tools/interactive-bash/` | tmux session management |
4646
| CLI installer | `src/cli/install.ts` | Interactive TUI installation |
4747
| Doctor checks | `src/cli/doctor/checks/` | Health checks for environment |
4848
| Shared utilities | `src/shared/` | Cross-cutting utilities |
49+
| Slash commands | `src/hooks/auto-slash-command/` | Auto-detect and execute `/command` patterns |
50+
| Ralph Loop | `src/hooks/ralph-loop/` | Self-referential dev loop until completion |
4951

5052
## CONVENTIONS
5153

@@ -70,6 +72,8 @@ oh-my-opencode/
7072
- **Over-exploration**: Stop searching when sufficient context found
7173
- **High temperature**: Don't use >0.3 for code-related agents
7274
- **Broad tool access**: Prefer explicit `include` over unrestricted access
75+
- **Sequential agent calls**: Use `background_task` for parallel execution
76+
- **Heavy PreToolUse logic**: Slows every tool call
7377

7478
## UNIQUE STYLES
7579

@@ -80,6 +84,7 @@ oh-my-opencode/
8084
- **Agent tools**: `tools: { include: [...] }` or `tools: { exclude: [...] }`
8185
- **Temperature**: Most agents use `0.1` for consistency
8286
- **Hook naming**: `createXXXHook` function convention
87+
- **Factory pattern**: Components created via `createXXX()` functions
8388

8489
## AGENT MODELS
8590

@@ -123,11 +128,12 @@ bun test # Run tests
123128

124129
| File | Lines | Description |
125130
|------|-------|-------------|
126-
| `src/index.ts` | 690 | Main plugin orchestration, all hook/tool initialization |
127-
| `src/hooks/anthropic-context-window-limit-recovery/executor.ts` | 670 | Session compaction, multi-stage recovery pipeline |
128-
| `src/cli/config-manager.ts` | 669 | JSONC parsing, environment detection, installation |
129-
| `src/auth/antigravity/fetch.ts` | 621 | Token refresh, URL rewriting, endpoint fallbacks |
130-
| `src/tools/lsp/client.ts` | 611 | LSP protocol, stdin/stdout buffering, JSON-RPC |
131+
| `src/index.ts` | 697 | Main plugin orchestration, all hook/tool initialization |
132+
| `src/cli/config-manager.ts` | 670 | JSONC parsing, environment detection, installation |
133+
| `src/auth/antigravity/fetch.ts` | 622 | Token refresh, URL rewriting, endpoint fallbacks |
134+
| `src/tools/lsp/client.ts` | 612 | LSP protocol, stdin/stdout buffering, JSON-RPC |
135+
| `src/hooks/anthropic-context-window-limit-recovery/executor.ts` | 555 | Session compaction, multi-stage recovery pipeline |
136+
| `src/agents/sisyphus.ts` | 505 | Orchestrator prompt, delegation strategies |
131137

132138
## NOTES
133139

@@ -137,3 +143,4 @@ bun test # Run tests
137143
- **Config**: `~/.config/opencode/oh-my-opencode.json` (user) or `.opencode/oh-my-opencode.json` (project)
138144
- **Trusted deps**: @ast-grep/cli, @ast-grep/napi, @code-yeongyu/comment-checker
139145
- **JSONC support**: Config files support comments (`// comment`, `/* block */`) and trailing commas
146+
- **Claude Code Compat**: Full compatibility layer for settings.json hooks, commands, skills, agents, MCPs

src/auth/AGENTS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# AUTH KNOWLEDGE BASE
2+
3+
## OVERVIEW
4+
5+
Google Antigravity OAuth implementation for Gemini models. Token management, fetch interception, thinking block extraction, and response transformation.
6+
7+
## STRUCTURE
8+
9+
```
10+
auth/
11+
└── antigravity/
12+
├── plugin.ts # Main plugin export, hooks registration
13+
├── oauth.ts # OAuth flow, token acquisition
14+
├── token.ts # Token storage, refresh logic
15+
├── fetch.ts # Fetch interceptor (622 lines) - URL rewriting, retry
16+
├── response.ts # Response transformation, streaming
17+
├── thinking.ts # Thinking block extraction/transformation
18+
├── thought-signature-store.ts # Signature caching for thinking blocks
19+
├── message-converter.ts # Message format conversion
20+
├── request.ts # Request building, headers
21+
├── project.ts # Project ID management
22+
├── tools.ts # Tool registration for OAuth
23+
├── constants.ts # API endpoints, model mappings
24+
└── types.ts # TypeScript interfaces
25+
```
26+
27+
## KEY COMPONENTS
28+
29+
| File | Purpose |
30+
|------|---------|
31+
| `fetch.ts` | Core interceptor - rewrites URLs, manages tokens, handles retries |
32+
| `thinking.ts` | Extracts `<antThinking>` blocks, transforms for OpenCode compatibility |
33+
| `response.ts` | Handles streaming responses, SSE parsing |
34+
| `oauth.ts` | Browser-based OAuth flow for Google accounts |
35+
| `token.ts` | Token persistence, expiry checking, refresh |
36+
37+
## HOW IT WORKS
38+
39+
1. **Intercept**: `fetch.ts` intercepts requests to Anthropic/Google endpoints
40+
2. **Rewrite**: URLs rewritten to Antigravity proxy endpoints
41+
3. **Auth**: Bearer token injected from stored OAuth credentials
42+
4. **Response**: Streaming responses parsed, thinking blocks extracted
43+
5. **Transform**: Response format normalized for OpenCode consumption
44+
45+
## ANTI-PATTERNS (AUTH)
46+
47+
- **Direct API calls**: Always go through fetch interceptor
48+
- **Storing tokens in code**: Use `token.ts` storage layer
49+
- **Ignoring refresh**: Check token expiry before requests
50+
- **Blocking on OAuth**: OAuth flow is async, never block main thread
51+
52+
## NOTES
53+
54+
- **Multi-account**: Supports up to 10 Google accounts for load balancing
55+
- **Fallback**: On rate limit, automatically switches to next available account
56+
- **Thinking blocks**: Preserved and transformed for extended thinking features
57+
- **Proxy**: Uses Antigravity proxy for Google AI Studio access

src/hooks/AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Lifecycle hooks that intercept/modify agent behavior. Inject context, enforce ru
1010
hooks/
1111
├── agent-usage-reminder/ # Remind to use specialized agents
1212
├── anthropic-context-window-limit-recovery/ # Auto-compact Claude at token limit
13+
├── auto-slash-command/ # Auto-detect and execute /command patterns
1314
├── auto-update-checker/ # Version update notifications
1415
├── background-notification/ # OS notify on background task complete
1516
├── claude-code-hooks/ # Claude Code settings.json integration
@@ -24,6 +25,7 @@ hooks/
2425
├── keyword-detector/ # Detect ultrawork/search keywords
2526
├── non-interactive-env/ # CI/headless environment handling
2627
├── preemptive-compaction/ # Pre-emptive session compaction
28+
├── ralph-loop/ # Self-referential dev loop until completion
2729
├── rules-injector/ # Conditional rules from .claude/rules/
2830
├── session-recovery/ # Recover from session errors
2931
├── think-mode/ # Auto-detect thinking triggers

0 commit comments

Comments
 (0)