Skip to content

Conversation

@tcarac
Copy link

@tcarac tcarac commented Feb 11, 2026

Summary

  • Adds keyword_detector.extra_ultrawork_aliases config option that lets users define additional trigger words (e.g., lfg) that activate ultrawork mode alongside the built-in ultrawork and ulw keywords
  • The regex is built dynamically from defaults + user-provided aliases, with proper word boundary enforcement and regex character escaping
  • Config is resolved once at hook creation time (not per-message) for zero performance overhead

Motivation

The ultrawork trigger keywords (ultrawork, ulw) are currently hardcoded. Users who want a personalized trigger word (e.g., lfg) have no way to add one without forking the project. This PR makes it configurable while keeping the existing defaults.

Config Example

// .opencode/oh-my-opencode.json
{
  "keyword_detector": {
    "extra_ultrawork_aliases": ["lfg"]
  }
}

Now typing lfg implement the auth flow will activate ultrawork mode, just like ulw or ultrawork.

Changes

File Change
src/config/schema/keyword-detector.ts New KeywordDetectorConfigSchema with extra_ultrawork_aliases field
src/config/schema/oh-my-opencode-config.ts Added keyword_detector to root config
src/config/schema.ts Barrel export for new schema
src/hooks/keyword-detector/constants.ts Added createKeywordDetectors() factory that builds regex dynamically
src/hooks/keyword-detector/detector.ts detectKeywords/detectKeywordsWithType accept optional custom detectors param
src/hooks/keyword-detector/hook.ts Accepts KeywordDetectorConfig, builds custom detectors once at creation
src/plugin/hooks/create-transform-hooks.ts Passes pluginConfig.keyword_detector to hook factory
src/hooks/keyword-detector/index.test.ts 10 new tests: factory function + integration + backward compat

Verification

  • bun test src/hooks/keyword-detector/index.test.ts — 34 tests pass (24 existing + 10 new)
  • bun test src/config/schema.test.ts — 46 tests pass
  • bun run typecheck — clean
  • bun run build — clean

Design Decisions

  1. Backward compatible: The static KEYWORD_DETECTORS constant is preserved. The new detectors param defaults to it. All existing callers are unaffected.
  2. Regex escaping: User-provided aliases are escaped via escapeRegExp() to prevent regex injection.
  3. One-time construction: Custom detectors are built once at hook creation (not per-message), matching the performance profile of the current static constant.

Summary by cubic

Adds support for custom ultrawork trigger aliases via config so users can activate ultrawork with their own keywords (e.g., lfg) alongside ultrawork and ulw. The detector is built once from defaults + aliases with safe regex and word boundaries, and ignores empty aliases to avoid false matches.

  • New Features

    • Config: keyword_detector.extra_ultrawork_aliases
    • createKeywordDetectors() builds patterns; detectKeywords* accept optional detectors
    • Hook builds detectors at startup; backward compatible; tests cover factory, integration, and defaults
  • Bug Fixes

    • Filter empty alias values to prevent overly broad regex matching

Written for commit 5f7c0ff. Summary will update on new commits.

Add keyword_detector.extra_ultrawork_aliases config option that lets users
define additional trigger words (e.g., "lfg") that activate ultrawork mode
alongside the built-in "ultrawork" and "ulw" keywords.

Config example:
  { "keyword_detector": { "extra_ultrawork_aliases": ["lfg"] } }

Changes:
- New KeywordDetectorConfigSchema with extra_ultrawork_aliases field
- createKeywordDetectors() factory builds regex dynamically from defaults + aliases
- detectKeywords/detectKeywordsWithType accept optional custom detectors
- Config threaded through hook factory at creation time (not per-message)
- Word boundary enforcement and regex escaping for user-provided aliases
- 10 new test cases covering factory, integration, and backward compatibility
@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@tcarac
Copy link
Author

tcarac commented Feb 11, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 11, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Confidence score: 3/5

  • There is a concrete user-facing risk: empty alias values in src/hooks/keyword-detector/constants.ts can generate a regex with an empty alternative that matches most word boundaries, causing false keyword detections.
  • This elevates merge risk beyond minor issues because it can trigger detection on most messages when configs include "".
  • Pay close attention to src/hooks/keyword-detector/constants.ts - empty aliases should be filtered to avoid overly broad regex matches.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/hooks/keyword-detector/constants.ts">

<violation number="1" location="src/hooks/keyword-detector/constants.ts:39">
P2: Empty alias values are not filtered, so a config value of "" produces a regex with an empty alternative (e.g., /\b(ultrawork|ulw|)\b/i) that matches every word boundary and triggers keyword detection on most messages.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant