Note a delegation whose brief asks for something the person will look at but states no look
Rule 5 gains one sentence: the brief states the look, chosen with the person from previews. The delegation hook adds a note (never a block) when the brief makes something, names two or more screen terms and states no look (no Look:/Design system: line, fewer than three of the four groups). Five lines are merged elsewhere in hooks.py; the labelled-set test skips while tests/data/screen_briefs.jsonl is absent.
This commit is contained in:
1 parent
8e2654892e
commit
58ee83fa38
3 files changed
+101
-19
No files matched your search
+25
-9
@@ -17,6 +17,8 @@ GATE = ("sisi: this piece of work changed things and has no retro yet. Run `sisi
|
||||
NODONE = "sisi: no done is recorded yet. Define what the person wants and what comes next now: `sisi done --goal \"<their goal>\" --check \"<a check that can fail>\" [--check ...] --next \"<what comes next and what you do about it>\"`."
|
||||
NOPICK = ("sisi: this delegation went to a worker the wheel did not give you (recorded so `sisi judge` still works). Use `sisi pick routine|ordinary|hard` next time "
|
||||
"(--review-of WORKER for a review, --not WORKER if one is out); one pick, one delegation.")
|
||||
NOLOOK = ("sisi: this brief asks for something the person will look at but states no look (typefaces, sizes, colours, spacing, layout at each width). "
|
||||
"Choose it with the person from previews and put it in the brief, or add a line 'Look: <the existing design it follows>'.")
|
||||
UNKNOWN = "sisi: the worker you named is not in the models table (recorded so `sisi judge` still works), so the table is out of date. Rebuild it now with a research worker (`sisi models research` prints the brief; `sisi models research --record FILE` records the answer), and use `sisi pick` next time."
|
||||
NOSHELL = "sisi: do not shell out to a worker; start it with the host's delegation tool next time."
|
||||
FAILED = "sisi: check %s failed. A failed check is a gap: record `sisi retro --gap \"<where it fell short>\" --cause \"<the root cause>\" --improve \"<the rule that prevents it>\" --term <term> --problem N|\"<name>\"` (or pause: `sisi retro --later \"<what it waits for>\"`)."
|
||||
@@ -68,8 +70,7 @@ def tool_class(tool):
|
||||
_classes = {n: c for c, names in raw.items() for n in names}
|
||||
except (ValueError, AttributeError, TypeError):
|
||||
_classes = {} # a missing or broken table meters nothing rather than breaking the session
|
||||
tool = tool.lower()
|
||||
return _classes.get(tool) or ("delegate" if tool.endswith("delegate_task") else "")
|
||||
return _classes.get(t := tool.lower()) or ("delegate" if t.endswith("delegate_task") else "")
|
||||
|
||||
|
||||
def own(command):
|
||||
@@ -118,9 +119,7 @@ def tick(p):
|
||||
store.append(env, "export SISI_SESSION_ID=%s" % sid, once=True) # so `sisi retro` knows its session
|
||||
if not os.path.exists(os.path.join(store.DATA, "generated", "core.md")):
|
||||
rules.build_rulebook()
|
||||
text = "\n".join(x for x in (rules.project_text(cwd), rules.due(cwd, claim=True), models.stale(), "" if worker else _faults(cwd, False, free, sid)) if x)
|
||||
if text:
|
||||
print(text)
|
||||
(text := "\n".join(x for x in (rules.project_text(cwd), rules.due(cwd, claim=True), models.stale(), "" if worker else _faults(cwd, False, free, sid)) if x)) and print(text)
|
||||
return 0
|
||||
|
||||
|
||||
@@ -151,6 +150,23 @@ def prompt(p):
|
||||
return 0
|
||||
|
||||
|
||||
# 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?"))
|
||||
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
|
||||
|
||||
|
||||
def watch(p):
|
||||
"""Before a tool call by the lead: count it, record delegations, and remind when off-course (never blocking)."""
|
||||
sid, tool, ti = p["session_id"], p["tool_name"].lower(), p["tool_input"]
|
||||
@@ -167,13 +183,14 @@ def watch(p):
|
||||
shell and not cfg["shell_workers"] and notes.append(NOSHELL)
|
||||
(kind in ("delegate", "edit") or shell) and not s.get("done") and notes.append(NODONE)
|
||||
if kind == "delegate" or shell:
|
||||
brief = command if shell else " ".join(v for k in ("prompt", "task", "message", "instructions", "description", "content", "text") if isinstance(v := ti.get(k), str))
|
||||
screen_brief_without_look(brief) and notes.append(NOLOOK)
|
||||
target = ti.get("target") if isinstance(ti.get("target"), dict) else {}
|
||||
names = (ti.get("model"),) if tool == "agent" else (ti.get("model"), target.get("model"), ti.get("agent"))
|
||||
text = command if shell else next((n for n in names if n and isinstance(n, str)), "")
|
||||
table_text = store.read(models.table())
|
||||
if tool != "workflow" and not models.claim(s, text, not shell and bool(names[0])):
|
||||
probe = {"picked": [models.short(r[0]) for r in models.rows(table_text)]}
|
||||
known = models.claim(probe, text, True)
|
||||
known = models.claim(probe := {"picked": [models.short(r[0]) for r in models.rows(table_text)]}, text, True)
|
||||
if models.usable(table_text):
|
||||
not shell and text.strip() and not known and models.stale(text)
|
||||
notes.append(UNKNOWN if not shell and text.strip() and not known else NOPICK)
|
||||
@@ -190,8 +207,7 @@ def watch(p):
|
||||
s["changed"] = True
|
||||
s.pop("paused", None)
|
||||
s["direct"], s["direct_since"] = s.get("direct", 0) + 1, s.get("direct_since", 0) + 1
|
||||
if notes:
|
||||
print(json.dumps({"hookSpecificOutput": {"hookEventName": "PreToolUse", "additionalContext": say("\n".join(notes))}}))
|
||||
notes and print(json.dumps({"hookSpecificOutput": {"hookEventName": "PreToolUse", "additionalContext": say("\n".join(notes))}}))
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user