diff --git a/sisi/hooks.py b/sisi/hooks.py index 0b01940..a910002 100644 --- a/sisi/hooks.py +++ b/sisi/hooks.py @@ -152,19 +152,19 @@ def prompt(p): # A brief states no look when it makes something (MAKING), names two or more of SCREEN and has neither a `Look:` / `Design system:` line nor three # of the four GROUPS (type, colour, spacing, grid). Each entry is a regular expression, tried against the lowercase brief. -SCREEN = ("layouts?", "screenshots?", "viewports?", "phone[- ]widths?", "responsive", "stylesheets?", "css", "dark mode", "light and dark", - "typefaces?", "toolbars?", "sidebars?", "modals?", "dialog box(?:es)?", "cards?", "panels?", "charts?", "buttons?", "headlines?", "wraps", "scroll\\w*") -_SCREEN = re.compile(r"\b(" + r")|(".join(SCREEN) + r")\b") -MAKING = re.compile(r"\b(?:build\w*|creat\w*|mak(?:e|es|ing)\b|(?:re)?design\w*|restyle\w*|adds?\b|adding\b|lay(?:s|ing)? out|implement\w*)") -GROUPS = tuple(re.compile(p) for p in (r"fonts?|typefaces?|typography|type scale|helvetica|arial|roboto|georgia|garamond|times new roman|system-ui|sans-serif|segoe ui|sf pro|\binter\b", - r"#[0-9a-f]{3,8}\b|palettes?|colou?r schemes?", r"padding|margins?|\bgaps?\b|spacing|radius", r"\bgrids?\b|columns?|breakpoints?")) +SCREEN = ("layouts?", "screens?", "screenshots?", "windows?", "viewports?", "phone[- ]widths?", "responsive", "stylesheets?", "css", "dark mode", "light and dark", + "typefaces?", "toolbars?", "sidebars?", "modals?", "dialog box(?:es)?", "cards?", "panels?", "charts?", "buttons?", "headlines?", "wraps", "scroll\\w*", + "ui", "onboarding", "pdfs?", r"print(?:able|er|ing|ed)", "footer", "terminal") +_SCREEN = re.compile(r"\b(?:(" + r")|(".join(SCREEN) + r"))\b") +MAKING = re.compile(r"\b(?:build\w*|creat\w*|mak(?:e|es|ing)\b|(?:re)?design\w*|restyle\w*|adds?\b|adding\b|lay(?:s|ing)? out|implement\w*|writ(?:e|es|ing)\b|generat(?:e|es|ing)\b|produc(?:e|es|ing)\b)") +GROUPS = re.compile(r"((?:fonts?|typefaces?|typography|type scale|helvetica|arial|roboto|georgia|garamond|times new roman|system-ui|sans-serif|segoe ui|sf pro|\binter\b))|((?:#[0-9a-f]{3,8}\b|palettes?|colou?r schemes?))|((?:padding|margins?|\bgaps?\b|spacing|radius))|((?:\bgrids?\b|columns?|breakpoints?))") LOOK_LINE = re.compile(r"(?im)^\W{0,6}(?:look|design system)\s*:") def screen_brief_without_look(text): """True when a brief asks for something the person will look at and states no look for it. Anything that is not text is False.""" t = text.lower() if isinstance(text, str) else "" - return bool(MAKING.search(t)) and len({m.lastindex for m in _SCREEN.finditer(t)}) >= 2 and not LOOK_LINE.search(t) and sum(bool(g.search(t)) for g in GROUPS) < 3 + return bool(MAKING.search(t)) and len({m.lastindex for m in _SCREEN.finditer(t)}) >= 2 and not LOOK_LINE.search(t) and len({m.lastindex for m in GROUPS.finditer(t)}) < 3 def watch(p): diff --git a/tests/test_core.py b/tests/test_core.py index 9d8b1b8..6c95717 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1968,6 +1968,8 @@ cli.main(["tick"]) self.assertFalse(f(self.PAGE + "Type: Inter at 14/16/20. Spacing: 8px padding, 12px gaps. Grid: two columns above 900px.")) # three of four groups self.assertTrue(f(self.PAGE + "Type: Inter at 14/16/20. Grid: two columns above 900px.")) # two groups are not a look self.assertFalse(f(self.SERVER)) # "page" and "browser" alone are not screen work + self.assertFalse(f("Write a build guide: how the suite builds, what it prints and how long a window it needs")) # terms are whole words + self.assertTrue(f("Add PDF output for invoices: a customer prints it on A4, with a payment footer on every page.")) # paper a person reads self.assertFalse(f("Review the settings page: at phone width the toolbar overlaps the sidebar and the headline wraps. " "Report findings only.")) # looks, never makes for bad in ("", None, 12, {"prompt": self.PAGE}, [self.PAGE]):