@@ -776,7 +776,8 @@ def _is_typosquat(
776776# unconditional: a subject or domain qualifier such as "about PostgreSQL",
777777# "with PDF files" or "related to Kubernetes" keeps the clause describing a
778778# capability, not a catch-all trigger. A qualifier whose object is only a
779- # pronoun ("anything with it") bounds nothing and stays universal. Broad
779+ # pronoun or a quantifier ("anything with it", "anything with you",
780+ # "anything related to any topic") bounds nothing and stays universal. Broad
780781# prepositions ("in", "for", "on") are deliberately not qualifiers: "any
781782# message in the chat" is still every message.
782783_DESCRIPTION_UNIVERSAL_SCOPE_RE = re .compile (
@@ -785,7 +786,8 @@ def _is_typosquat(
785786 r"(?:all|any|every)\s+(?:messages?|requests?|questions?|queries?|inputs?|tasks?)"
786787 r")\b"
787788 r"(?!\s+(?:about|with|involving|regarding|concerning|(?:related|relating)\s+to)\s+"
788- r"(?!(?:it|this|that|them|anything|everything|whatever)\b)[a-z0-9])" ,
789+ r"(?!(?:it|this|that|them|anything|everything|whatever|"
790+ r"any|all|every|each|some|you|me|us|him|her)\b)[a-z0-9])" ,
789791 re .IGNORECASE ,
790792)
791793
@@ -809,18 +811,17 @@ def _is_typosquat(
809811# The shadowed command must also be the object of that evidence, not any
810812# built-in word that happens to share the clause: a slash-command token names
811813# a command by its whole name ("/ask-matt" is "ask-matt", not the built-in
812- # "ask"), and an interception verb names the command it governs within the
813- # next few words ("Overrides the build command"). A built-in word used as an
814- # ordinary noun elsewhere in the clause ("wants an ask answered ") is not an
815- # invocation of that command.
816- _DESCRIPTION_SLASH_COMMAND_RE = re .compile (r"(?<![\w/])/([a-z][\w-]*)" , re .IGNORECASE )
814+ # "ask"), and an interception verb governs the built-ins that follow it in
815+ # the clause ("Intercepts and replaces the built-in deploy command"). A
816+ # slash-command token that is not a built-in ("/ ask-matt ") stays one name, and
817+ # a home-relative path ("~/build") is not a slash command.
818+ _DESCRIPTION_SLASH_COMMAND_RE = re .compile (r"(?<![\w/.~ ])/([a-z][\w-]*)" , re .IGNORECASE )
817819_DESCRIPTION_INTERCEPTION_VERB_RE = re .compile (
818820 r"\b(?:invoke[sd]?|invoking|intercept(?:s|ed|ing)?|"
819821 r"override[sd]?|overriding|shadow(?:s|ed|ing)?)\b" ,
820822 re .IGNORECASE ,
821823)
822- _DESCRIPTION_COMMAND_TOKEN_RE = re .compile (r"/?([a-z][\w-]*)" , re .IGNORECASE )
823- _MAX_INTERCEPTION_OBJECT_WORDS = 4
824+ _DESCRIPTION_COMMAND_TOKEN_RE = re .compile (r"(?<![\w/.~-])/?([a-z][\w-]*)" , re .IGNORECASE )
824825
825826# Trigger-phrase extraction for the TR1 broad/short-trigger rule on
826827# descriptions: the word or phrase the skill claims to activate on, as in
@@ -941,20 +942,18 @@ def _description_shadowed_commands(clause: str) -> list[str]:
941942 """Built-in commands a description clause claims to invoke or intercept.
942943
943944 Only commands tied to interception evidence count: a slash-command token
944- whose whole name is a built-in, or a built-in named within a few words
945- after an invocation/interception/override verb (before any clause
946- boundary). Returns the sorted set of shadowed built-in commands.
945+ whose whole name is a built-in, or a built-in named anywhere after an
946+ invocation/interception/override verb in the clause. Returns the sorted
947+ set of shadowed built-in commands.
947948 """
948949 shadowed = {
949950 match .group (1 ).lower ()
950951 for match in _DESCRIPTION_SLASH_COMMAND_RE .finditer (clause )
951952 if match .group (1 ).lower () in _BUILTIN_COMMANDS
952953 }
953- for verb in _DESCRIPTION_INTERCEPTION_VERB_RE .finditer (clause ):
954- rest = clause [verb .end () :]
955- boundary = _DESCRIPTION_CONDITION_BOUNDARY_RE .search (rest )
956- span = rest [: boundary .start ()] if boundary else rest
957- tokens = _DESCRIPTION_COMMAND_TOKEN_RE .findall (span )[:_MAX_INTERCEPTION_OBJECT_WORDS ]
954+ verb = _DESCRIPTION_INTERCEPTION_VERB_RE .search (clause )
955+ if verb is not None :
956+ tokens = _DESCRIPTION_COMMAND_TOKEN_RE .findall (clause [verb .end () :])
958957 shadowed .update (t .lower () for t in tokens if t .lower () in _BUILTIN_COMMANDS )
959958 return sorted (shadowed )
960959
0 commit comments