Files
oh-my-opencode/src/hooks/keyword-detector/AGENTS.md
T
YeonGyu-Kim 33d39597ae docs(agents): regenerate AGENTS.md hierarchy with updated metrics and model configs
- 1208→1243 TS files (+35), 143k→155k LOC (+12k)
- Update all agent models: Sisyphus, Hephaestus, Oracle, Librarian, Atlas, Metis, Momus
- Add 6 new hook directories (39→45 dirs): beast-mode-system, hashline-edit-diff-enhancer, anthropic-image-context, task-reminder, compaction-todo-preserver, runtime-fallback
- Update category models: visual-engineering/artistry gemini-3-pro→gemini-3.1-pro
- Add 2 config schema files: fallback-models.ts, runtime-fallback.ts
- Timestamp: 2026-03-02 | Commit: 1c2caa09

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-03-02 23:40:38 +09:00

2.3 KiB

src/hooks/keyword-detector/ — Mode Keyword Injection

Generated: 2026-03-02

OVERVIEW

8 files + 3 mode subdirs (~1665 LOC). Transform Tier hook on messages.transform. Scans first user message for mode keywords (ultrawork, search, analyze) and injects mode-specific system prompts.

KEYWORDS

Keyword Pattern Effect
ultrawork / ulw `/\b(ultrawork ulw)\b/i`
Search mode SEARCH_PATTERN (from search/) Web/doc search focus prompt injection
Analyze mode ANALYZE_PATTERN (from analyze/) Deep analysis mode prompt injection

STRUCTURE

keyword-detector/
├── index.ts           # Barrel export
├── hook.ts            # createKeywordDetectorHook() — chat.message handler
├── detector.ts        # detectKeywordsWithType() + extractPromptText()
├── constants.ts       # KEYWORD_DETECTORS array, re-exports from submodules
├── types.ts           # KeywordDetector, DetectedKeyword types
├── ultrawork/
│   ├── index.ts
│   ├── message.ts     # getUltraworkMessage() — dynamic prompt by agent/model
│   └── isPlannerAgent.ts
├── search/
│   ├── index.ts
│   ├── pattern.ts     # SEARCH_PATTERN regex
│   └── message.ts     # SEARCH_MESSAGE
└── analyze/
    ├── index.ts
    ├── pattern.ts     # ANALYZE_PATTERN regex
    └── message.ts     # ANALYZE_MESSAGE

DETECTION LOGIC

chat.message (user input)
  → extractPromptText(parts)
  → isSystemDirective? → skip
  → removeSystemReminders(text)  # strip <SYSTEM_REMINDER> blocks
  → detectKeywordsWithType(cleanText, agentName, modelID)
  → isPlannerAgent(agentName)? → filter out ultrawork
  → for each detected keyword: inject mode message into output

GUARDS

  • System directive skip: Messages tagged as system directives are not scanned (prevents infinite loops)
  • Planner agent filter: Prometheus/plan agents do not receive ultrawork injection
  • Session agent tracking: Uses getSessionAgent() to get actual agent (not just input hint)
  • Model-aware messages: getUltraworkMessage(agentName, modelID) adapts message to active model