-
Notifications
You must be signed in to change notification settings - Fork 0
fix(agent-mention): accept /opencode and /oc on current main #1558
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
Changes from all commits
08dc654
6e0b0b1
d8d6e00
9aeaa81
2d1aa25
65352d5
0685b5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,8 @@ jobs: | |
| && ( | ||
| contains(github.event.comment.body, '@cwl-noema-review') | ||
| || contains(github.event.comment.body, '@opencode-agent') | ||
| || contains(github.event.comment.body, '/opencode') | ||
| || contains(github.event.comment.body, '/oc') | ||
|
Comment on lines
+26
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Uppercase aliases miss immediate routing On the central repository, Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| ) | ||
| concurrency: | ||
| group: review-agent-mention-router-local-${{ github.repository }} | ||
|
|
||
|
seonghobae marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,13 +15,49 @@ | |
|
|
||
| CENTRAL_AUTOMATION_REPOSITORY = "ContextualWisdomLab/.github" | ||
| TRUSTED_ASSOCIATIONS = frozenset({"OWNER", "MEMBER", "COLLABORATOR"}) | ||
| # "opencode-agent" also accepts /opencode and /oc: upstream OpenCode's own | ||
| # GitHub Action documents those as its trigger phrases | ||
| # (https://open-code.ai/en/docs/github), and this repo's dispatch pipeline | ||
| # accepts them as aliases of the same @opencode-agent request rather than | ||
| # forcing commenters to learn a locally-invented mention instead. | ||
| # | ||
| # None of the three alternatives below may be preceded by a bare "/": a | ||
| # preceding slash almost always means the match is embedded in a URL path | ||
| # (e.g. https://opencode.ai/docs, https://youtube.com/@opencode-agent) or an | ||
| # ordinary path segment (docs/@opencode-agent), not a deliberate trigger. The | ||
| # one deliberate exception is a maintainer separating both supported agent | ||
| # requests with a bare slash and no space (@cwl-noema-review/@opencode-agent). | ||
| # That case is matched as one combined literal — "@cwl-noema-review/@opencode-agent" | ||
| # — guarded by the same left-boundary exclusion as the standalone | ||
| # "@opencode-agent" alternative. A boundary check on the trailing slash alone | ||
| # is not enough: it would still fire for invalid pasted text where | ||
| # "@cwl-noema-review" is itself embedded in a larger token (e.g. | ||
| # foo@cwl-noema-review/@opencode-agent, docs/@cwl-noema-review/@opencode-agent) | ||
| # without checking that the Noema mention has a valid left boundary of its own. | ||
| # The bare /opencode and /oc forms additionally exclude a preceding "=": a | ||
| # URL query string (?next=/opencode, ?redirect=/oc) shares the same "not | ||
| # preceded by a word character" shape as a deliberate standalone command. | ||
| # | ||
| # The shared trailing boundary after any of the three alternatives also | ||
| # excludes a following "/": without it, a root-relative path continuation | ||
| # right after the alias (/oc/config, /opencode/docs, @opencode-agent/config, | ||
| # @cwl-noema-review/@opencode-agent/foo) still matched, since the alias text | ||
| # itself is a complete, valid match and nothing in the original trailing | ||
| # lookahead treated "/" as a word character. This mirrors the | ||
| # leading-boundary "/" exclusion already applied above and closes the same | ||
| # false-positive class from the trailing side, for every alternative rather | ||
| # than only the bare /opencode and /oc forms. | ||
| MENTION_PATTERNS = { | ||
| "cwl-noema-review": re.compile( | ||
| r"(?<![A-Za-z0-9_-])@cwl-noema-review(?![A-Za-z0-9_-])", | ||
| re.IGNORECASE, | ||
| ), | ||
| "opencode-agent": re.compile( | ||
| r"(?<![A-Za-z0-9_-])@opencode-agent(?![A-Za-z0-9_-])", | ||
| r"(?:" | ||
| r"(?<![A-Za-z0-9_/-])@opencode-agent" | ||
| r"|(?<![A-Za-z0-9_/-])@cwl-noema-review/@opencode-agent" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| r"|(?<![A-Za-z0-9_/=-])(?:/opencode|/oc)" | ||
| r")(?![A-Za-z0-9_/-])", | ||
|
Comment on lines
+59
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Path-like aliases launch unintended reviews The Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| re.IGNORECASE, | ||
| ), | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """Regression coverage for root-relative OpenCode slash-command lookalikes.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import importlib.util | ||
| import sys | ||
| from pathlib import Path | ||
| from types import ModuleType | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
| MODULE_PATH = ROOT / "scripts" / "ci" / "agent_mention_router.py" | ||
|
|
||
|
|
||
| def load_module() -> ModuleType: | ||
| """Load the production mention router from its script path.""" | ||
|
|
||
| module_name = "agent_mention_router_slash_path_regression" | ||
| spec = importlib.util.spec_from_file_location(module_name, MODULE_PATH) | ||
| assert spec and spec.loader | ||
| module = importlib.util.module_from_spec(spec) | ||
| sys.modules[module_name] = module | ||
| spec.loader.exec_module(module) | ||
| return module | ||
|
|
||
|
|
||
| def test_root_relative_paths_do_not_dispatch_opencode_aliases() -> None: | ||
| """Path-like suffixes must not be accepted as standalone slash commands.""" | ||
|
|
||
| module = load_module() | ||
| assert module.exact_mentions("/oc/config") == () | ||
| assert module.exact_mentions("/opencode/docs") == () | ||
|
|
||
|
|
||
| def test_standalone_slash_aliases_remain_supported() -> None: | ||
| """The path guard must preserve both documented standalone aliases.""" | ||
|
|
||
| module = load_module() | ||
| assert module.exact_mentions("/oc") == ("opencode-agent",) | ||
| assert module.exact_mentions("/opencode please review") == ("opencode-agent",) |
Uh oh!
There was an error while loading. Please reload this page.