This commit is contained in:
justsisyphus 2026-01-19 20:18:26 +09:00
parent 4566094054
commit 732ec85e07
3 changed files with 145 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# PROJECT KNOWLEDGE BASE
**Generated:** 2026-01-17T21:55:00+09:00
**Commit:** 255f535a
**Generated:** 2026-01-19T18:10:00+09:00
**Commit:** 45660940
**Branch:** dev
## OVERVIEW
@ -69,7 +69,7 @@ oh-my-opencode/
- **Build**: `bun build` (ESM) + `tsc --emitDeclarationOnly`
- **Exports**: Barrel pattern in index.ts; explicit named exports
- **Naming**: kebab-case directories, `createXXXHook`/`createXXXTool` factories
- **Testing**: BDD comments `#given/#when/#then`, 84 test files
- **Testing**: BDD comments `#given/#when/#then`, 83 test files
- **Temperature**: 0.1 for code agents, max 0.3
## ANTI-PATTERNS (THIS PROJECT)
@ -123,7 +123,7 @@ bun run typecheck # Type check
bun run build # ESM + declarations + schema
bun run rebuild # Clean + Build
bun run build:schema # Schema only
bun test # Run tests (84 test files)
bun test # Run tests (83 test files)
```
## DEPLOYMENT
@ -172,7 +172,7 @@ Three-tier MCP system:
## NOTES
- **Testing**: Bun native test (`bun test`), BDD-style, 84 test files
- **Testing**: Bun native test (`bun test`), BDD-style, 83 test files
- **OpenCode**: Requires >= 1.0.150
- **Multi-lang docs**: README.md (EN), README.ko.md (KO), README.ja.md (JA), README.zh-cn.md (ZH-CN)
- **Config**: `~/.config/opencode/oh-my-opencode.json` (user) or `.opencode/oh-my-opencode.json` (project)

View File

@ -0,0 +1,70 @@
# CLAUDE CODE HOOKS COMPATIBILITY LAYER
## OVERVIEW
Full Claude Code settings.json hook compatibility. Executes user-defined hooks at 5 lifecycle events: PreToolUse, PostToolUse, UserPromptSubmit, Stop, PreCompact.
## STRUCTURE
```
claude-code-hooks/
├── index.ts # Main factory (401 lines) - createClaudeCodeHooksHook()
├── config.ts # Loads ~/.claude/settings.json
├── config-loader.ts # Extended config from multiple sources
├── pre-tool-use.ts # PreToolUse hook executor (172 lines)
├── post-tool-use.ts # PostToolUse hook executor (199 lines)
├── user-prompt-submit.ts # UserPromptSubmit hook executor
├── stop.ts # Stop hook executor (session idle)
├── pre-compact.ts # PreCompact hook executor (context compaction)
├── transcript.ts # Tool use recording (252 lines)
├── tool-input-cache.ts # Caches tool inputs between pre/post
├── types.ts # Hook types, context interfaces
├── todo.ts # Todo JSON parsing fix
└── plugin-config.ts # Plugin config access
```
## HOOK LIFECYCLE
| Event | When | Can Block | Context Fields |
|-------|------|-----------|----------------|
| **PreToolUse** | Before tool | Yes | sessionId, toolName, toolInput, cwd |
| **PostToolUse** | After tool | Warn only | + toolOutput, transcriptPath |
| **UserPromptSubmit** | On user message | Yes | sessionId, prompt, parts, cwd |
| **Stop** | Session idle | inject_prompt | sessionId, parentSessionId |
| **PreCompact** | Before summarize | No | sessionId, cwd |
## CONFIG SOURCES
Priority (highest first):
1. `.claude/settings.json` (project)
2. `~/.claude/settings.json` (user)
```json
{
"hooks": {
"PreToolUse": [{ "matcher": "Edit", "command": "./check.sh" }],
"PostToolUse": [{ "command": "post-hook.sh $TOOL_NAME" }]
}
}
```
## HOOK EXECUTION
1. User-defined hooks loaded from settings.json
2. Matchers filter by tool name (supports wildcards)
3. Commands executed via subprocess with environment:
- `$SESSION_ID`, `$TOOL_NAME`, `$TOOL_INPUT`, `$CWD`
4. Exit codes: 0=pass, 1=warn, 2=block
## KEY PATTERNS
- **Session tracking**: `Map<sessionID, state>` for first-message, error, interrupt
- **Input caching**: Tool inputs cached pre→post via `tool-input-cache.ts`
- **Transcript recording**: All tool uses logged for debugging
- **Todowrite fix**: Parses string todos to array (line 174-196)
## ANTI-PATTERNS
- **Heavy PreToolUse logic**: Runs before EVERY tool call
- **Blocking non-critical**: Use warnings in PostToolUse instead
- **Missing error handling**: Always wrap subprocess calls

70
src/mcp/AGENTS.md Normal file
View File

@ -0,0 +1,70 @@
# BUILT-IN MCP CONFIGURATIONS
## OVERVIEW
3 remote MCP servers for web search, documentation, and code search. All use HTTP/SSE transport, no OAuth.
## STRUCTURE
```
mcp/
├── index.ts # createBuiltinMcps() factory
├── websearch.ts # Exa AI web search
├── context7.ts # Library documentation
├── grep-app.ts # GitHub code search
├── types.ts # McpNameSchema
└── index.test.ts # Tests
```
## MCP SERVERS
| Name | URL | Purpose | Auth |
|------|-----|---------|------|
| **websearch** | `mcp.exa.ai` | Real-time web search | `EXA_API_KEY` header |
| **context7** | `mcp.context7.com` | Official library docs | None |
| **grep_app** | `mcp.grep.app` | GitHub code search | None |
## CONFIG PATTERN
All MCPs follow identical structure:
```typescript
export const mcp_name = {
type: "remote" as const,
url: "https://...",
enabled: true,
oauth: false as const, // Explicit disable
headers?: { ... }, // Optional auth
}
```
## USAGE
```typescript
import { createBuiltinMcps } from "./mcp"
// Enable all
const mcps = createBuiltinMcps()
// Disable specific
const mcps = createBuiltinMcps(["websearch"])
```
## HOW TO ADD
1. Create `src/mcp/my-mcp.ts`:
```typescript
export const my_mcp = {
type: "remote" as const,
url: "https://mcp.example.com",
enabled: true,
oauth: false as const,
}
```
2. Add to `allBuiltinMcps` in `index.ts`
3. Add to `McpNameSchema` in `types.ts`
## NOTES
- **Remote only**: All built-in MCPs use HTTP/SSE, no stdio
- **Disable config**: User can disable via `disabled_mcps: ["name"]`
- **Exa requires key**: Set `EXA_API_KEY` env var for websearch