2026-05-14 12:57:46 +09:00
# src/shared/ — 278 Utility Files (170 non-test)
2026-02-17 11:17:01 +09:00
2026-05-14 12:57:46 +09:00
**Generated: ** 2026-05-14
2025-12-31 14:07:14 +09:00
## OVERVIEW
2026-02-01 19:26:57 +09:00
2026-05-14 12:57:46 +09:00
Cross-cutting utilities used throughout the plugin. Barrel-exported from `index.ts` . Logger writes to `/tmp/oh-my-opencode.log` . Includes runtime shims for `Bun.file` , `Bun.write` , `Bun.hash` , `Bun.which` , `Bun.spawn` to support non-Bun runtimes (Electron-hosted OpenCode).
2025-12-31 14:07:14 +09:00
2026-02-17 11:17:01 +09:00
## CATEGORY MAP
2025-12-31 14:07:14 +09:00
2026-02-17 11:17:01 +09:00
| Category | Files | Key Exports |
|----------|-------|-------------|
2026-04-05 14:04:42 +09:00
| **Model Resolution ** | ~22 | `resolveModel()` , `checkModelAvailability()` , `AGENT_MODEL_REQUIREMENTS` |
2026-02-17 11:17:01 +09:00
| **Tmux Integration ** | 11 | `createTmuxSession()` , `spawnPane()` , `closePane()` , server health |
| **Configuration & Paths ** | 10 | `resolveOpenCodeConfigDir()` , `getDataPath()` , `parseJSONC()` |
| **Session Management ** | 8 | `SessionCursor` , `trackInjectedPath()` , `SessionToolsStore` |
| **Git Worktree ** | 7 | `parseGitStatusPorcelain()` , `collectGitDiffStats()` , `formatFileChanges()` |
| **Command Execution ** | 7 | `executeCommand()` , `executeHookCommand()` , embedded command registry |
| **Migration ** | 6 | `migrateConfigFile()` , AGENT_NAME_MAP, HOOK_NAME_MAP, MODEL_VERSION_MAP |
| **String & Tool Utils ** | 6 | `toSnakeCase()` , `normalizeToolName()` , `parseFrontmatter()` |
| **Agent Configuration ** | 5 | `getAgentVariant()` , `AGENT_DISPLAY_NAMES` , `AGENT_TOOL_RESTRICTIONS` |
| **OpenCode Integration ** | 5 | `injectServerAuth()` , `detectExternalPlugins()` , client accessors |
| **Type Helpers ** | 4 | `deepMerge()` , `DynamicTruncator` , `matchPattern()` , `isRecord()` |
| **Misc ** | 8 | `log()` , `readFile()` , `extractZip()` , `downloadBinary()` , `findAvailablePort()` |
2026-02-10 14:53:39 +09:00
2026-02-17 11:17:01 +09:00
## MODEL RESOLUTION PIPELINE
2026-01-17 22:01:56 +09:00
2026-02-17 11:17:01 +09:00
```
resolveModel(input)
1. Override: UI-selected model (primary agents only)
2. Category default: From category config
3. Provider fallback: AGENT_MODEL_REQUIREMENTS chains
4. System default: Ultimate fallback
```
2026-01-17 22:01:56 +09:00
2026-03-02 16:38:22 +09:00
Key files: `model-resolver.ts` (entry), `model-resolution-pipeline.ts` (orchestration), `model-requirements.ts` (fallback chains), `model-availability.ts` (fuzzy matching).
2026-01-15 15:53:51 +09:00
2026-02-17 11:17:01 +09:00
## MIGRATION SYSTEM
2025-12-31 14:07:14 +09:00
2026-02-17 11:17:01 +09:00
Automatically transforms legacy config on load:
- `agent-names.ts` : Old agent names → new (e.g., `junior` → `sisyphus-junior` )
- `hook-names.ts` : Old hook names → new
- `model-versions.ts` : Old model IDs → current
- `agent-category.ts` : Legacy agent configs → category system
## MOST IMPORTED
2026-02-10 14:53:39 +09:00
2026-02-17 11:17:01 +09:00
| Utility | Import Count | Purpose |
|---------|-------------|---------|
| `logger.ts` | 62 | `/tmp/oh-my-opencode.log` |
| `data-path.ts` | 11 | XDG storage resolution |
| `model-requirements.ts` | 11 | Agent fallback chains |
| `system-directive.ts` | 11 | System message filtering |
| `frontmatter.ts` | 10 | YAML metadata extraction |