-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: support custom ultrawork trigger aliases via config #1766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat: support custom ultrawork trigger aliases via config #1766
Conversation
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
|
All contributors have signed the CLA. Thank you! ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this 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.tscan 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-aiwith guidance or docs links (includingllms.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.
Summary
keyword_detector.extra_ultrawork_aliasesconfig option that lets users define additional trigger words (e.g.,lfg) that activate ultrawork mode alongside the built-inultraworkandulwkeywordsMotivation
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
Now typing
lfg implement the auth flowwill activate ultrawork mode, just likeulworultrawork.Changes
src/config/schema/keyword-detector.tsKeywordDetectorConfigSchemawithextra_ultrawork_aliasesfieldsrc/config/schema/oh-my-opencode-config.tskeyword_detectorto root configsrc/config/schema.tssrc/hooks/keyword-detector/constants.tscreateKeywordDetectors()factory that builds regex dynamicallysrc/hooks/keyword-detector/detector.tsdetectKeywords/detectKeywordsWithTypeaccept optional custom detectors paramsrc/hooks/keyword-detector/hook.tsKeywordDetectorConfig, builds custom detectors once at creationsrc/plugin/hooks/create-transform-hooks.tspluginConfig.keyword_detectorto hook factorysrc/hooks/keyword-detector/index.test.tsVerification
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 passbun run typecheck— cleanbun run build— cleanDesign Decisions
KEYWORD_DETECTORSconstant is preserved. The newdetectorsparam defaults to it. All existing callers are unaffected.escapeRegExp()to prevent regex injection.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
Bug Fixes
Written for commit 5f7c0ff. Summary will update on new commits.