@ethlete/agent-rules 0.1.0-next.32 → 0.1.0-next.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @ethlete/agent-rules
2
2
 
3
+ ## 0.1.0-next.34
4
+
5
+ ### Minor Changes
6
+
7
+ - `app-styling` allows app CSS in `@layer components` again, and `et update` no longer leaves the `app-styling-utilities` task.
8
+
9
+ ### Patch Changes
10
+
11
+ - The git-safety hook now allows the commit that concludes a merge when a plan archive under `plans/**/archive/` is staged next to the merge paths, so an archive run that shrinks a merged plan can go into the merge commit.
12
+ - `agent-sessions restart` refuses while a `❓` question of a Claude session has no later human message, unless the resumed handoff names it under "Open for the human".
13
+ - The `background-design-commands` hook lets a `--help` or `-h` call of a long `design` command run in the foreground; `studio:e2e --help` stays denied because it runs the suite.
14
+ - The agent-sessions `restart` and wake-up commands now see a focused footer pill or agent panel row of the current Claude Code build, and move the focus back to the prompt before they type.
15
+ - Tighten the agent-sessions skill, mainly the restart section.
16
+ - The agent-sessions skill starts each agent with `CLAUDE_CODE_TMPDIR=~/.cache/claude-tmp`, in `run`, the shell functions and `restart --process`, so a full `/tmp` does not stop the agent's shell.
17
+ - Remove `et design check --visible-change` and the `harness.baseBranch` setting it read; `et design compare --base <rev>` still compares against a clone at `<rev>`. The `background-design-commands` hook no longer names `--visible-change`.
18
+ - Tighten the timetrack skill and list transcript and resync in its command table.
19
+
20
+ ## 0.1.0-next.33
21
+
22
+ ### Minor Changes
23
+
24
+ - `agent-sessions restart --process` starts the agent as a new process in its tmux pane, so a plugin, settings or `PATH` change takes effect.
25
+
26
+ ### Patch Changes
27
+
28
+ - The builder Stop hook now blocks a turn that ends with more than one line of chat text. `restart --process` keeps the session's role. Resuming a role handoff loads its role skill.
29
+ - The builder Stop hook now counts the final message of the turn from `last_assistant_message`. Claude Code calls the hook before that message reaches the transcript.
30
+ - `agent-sessions restart` treats a pane that shows "Waiting for" background agents as busy, and the skill says to mail the grill session when a self-restart is denied.
31
+ - `agent-sessions restart` accepts the paired builder or grill/docs session as target and logs each peer restart to `restart.log`.
32
+ - `agent-sessions restart` no longer hangs when the background-agent panel is open, and it tells the caller and `--notify` agents when it waits or gives up.
33
+ - `agent-sessions restart --process` keeps the tmux session of the agent, does not send the first prompt of `run` again, and answers the background work dialog of Claude Code with "exit and stop tasks".
34
+ - `agent-sessions restart --process` no longer passes a stored prompt twice, and `run` switches only the client of the calling tmux session.
35
+ - The design exploration skill documents `et design sketch covers` (ADR 0222).
36
+ - `et design sketch covers` on a multi-target sketch takes the part, `<layer>/<name>:<state>[@x,y,w,h]`, and refuses a bare state; compare matches a covered DIFF against that part.
37
+ - The `background-design-commands` hook matches long design commands only at command position, so a heredoc, an unquoted `echo` or a `git commit` message that names `design check` no longer gets denied.
38
+ - The builder Stop hook now parses each Bash command into its simple commands. A heredoc body or a quoted string that names `agent-sessions.mjs send` or `git commit` no longer counts as a report or a commit.
39
+ - The builder Stop hook also blocks a stop one time when the turn ran `git commit` or `git push` and sent no report with `SendMessage` or `agent-sessions send`.
40
+ - The design-exploration skill now describes build-ready, a current check record from `design check`, instead of the removed `design go` and `design accept` commands.
41
+ - The git-safety hook now allows a pathless `git commit` that concludes a merge, no longer denies commands that only mention `git commit` in a grep pattern or heredoc, and drops the obsolete `go.json` rule.
42
+ - Fix `agent-sessions restart` never restarting an idle session whose own chat text said "Waiting for": only the spinner line and the footer count as busy.
43
+
3
44
  ## 0.1.0-next.32
4
45
 
5
46
  ### Minor Changes
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env python3
2
2
  """PreToolUse hook: long design commands must run in the background.
3
3
 
4
- `design check`, `design compare`, `design ready`, `design sketch ready`, `design harness`,
5
- the `studio:e2e` target and the `--visible-change` gate each take minutes. In the foreground
4
+ `design check`, `design compare`, `design ready`, `design sketch ready`, `design harness`
5
+ and the `studio:e2e` target each take minutes. A `--help` or `-h`
6
+ call of a `design` command only prints usage and passes; `studio:e2e --help` runs the suite. In the foreground
6
7
  they block the whole session, so a Bash call that runs one without `run_in_background: true`
7
8
  is denied and the agent repeats it in the background.
8
9
 
9
10
  Matches the `yarn design ...`, `node dist/libs/cli/src/index.js design ...` and
10
- `npx nx ... studio:e2e` forms. Quoted text is ignored, so a commit message that mentions a
11
- command does not trip the hook.
11
+ `npx nx ... studio:e2e` forms at command position only. Quoted text, heredoc bodies and
12
+ arguments of other commands (`echo`, `git commit`, `grep`) are ignored, so free text that
13
+ mentions a command does not trip the hook.
12
14
 
13
15
  Can be disabled per machine via a gitignored ethlete-agents.config.local.json at the repo
14
16
  root: {"disableHooks": true} or {"disableHooks": ["background-design-commands"]}.
@@ -25,16 +27,52 @@ HOOK_NAME = "background-design-commands"
25
27
  LOCAL_CONFIG_FILE = "ethlete-agents.config.local.json"
26
28
 
27
29
  LONG_COMMANDS = (
28
- ("design check", re.compile(r"(?:^|[\s;&|])design\s+check(?=\s|$|[;&|])")),
29
- ("design compare", re.compile(r"(?:^|[\s;&|])design\s+compare(?=\s|$|[;&|])")),
30
- ("design ready", re.compile(r"(?:^|[\s;&|])design\s+ready(?=\s|$|[;&|])")),
31
- ("design sketch ready", re.compile(r"(?:^|[\s;&|])design\s+sketch\s+ready(?=\s|$|[;&|])")),
32
- ("design harness", re.compile(r"(?:^|[\s;&|])design\s+harness(?=\s|$|[;&|])")),
33
- ("studio:e2e", re.compile(r"studio:e2e(?=\s|$|[;&|:])")),
34
- ("--visible-change", re.compile(r"(?:^|\s)--visible-change(?=\s|=|$)")),
30
+ ("design check", re.compile(r"\bdesign\s+check(?=\s|$)")),
31
+ ("design compare", re.compile(r"\bdesign\s+compare(?=\s|$)")),
32
+ ("design ready", re.compile(r"\bdesign\s+ready(?=\s|$)")),
33
+ ("design sketch ready", re.compile(r"\bdesign\s+sketch\s+ready(?=\s|$)")),
34
+ ("design harness", re.compile(r"\bdesign\s+harness(?=\s|$)")),
35
+ ("studio:e2e", re.compile(r"studio:e2e(?=\s|$|:)")),
36
+ )
37
+
38
+ LAUNCHERS = frozenset(
39
+ ("yarn", "npx", "pnpm", "pnpx", "npm", "node", "nx", "bun", "bunx", "et", "ethlete-agents", "bash", "sh", "zsh", "time", "env", "nohup", "timeout", "sudo", "exec", "xargs")
35
40
  )
36
41
 
37
42
  QUOTED = re.compile(r"\"(?:\\.|[^\"\\])*\"|'[^']*'")
43
+ HEREDOC = re.compile(r"<<-?\s*(?:\"(\w+)\"|'(\w+)'|\\?(\w+))")
44
+ SEPARATORS = re.compile(r"&&|\|\||[;&|\n(){}`]")
45
+ ASSIGNMENT = re.compile(r"^[A-Za-z_]\w*=")
46
+ HELP_PRINTS_USAGE = frozenset(("design check", "design compare", "design ready", "design sketch ready", "design harness"))
47
+ HELP_FLAG = re.compile(r"(?:^|\s)(?:--help|-h)(?=\s|$)")
48
+
49
+
50
+ def without_heredoc_bodies(command):
51
+ lines = command.split("\n")
52
+ kept = []
53
+ delimiter = None
54
+ for line in lines:
55
+ if delimiter is not None:
56
+ if line.strip() == delimiter:
57
+ delimiter = None
58
+ continue
59
+ kept.append(line)
60
+ match = HEREDOC.search(line)
61
+ if match:
62
+ delimiter = match.group(1) or match.group(2) or match.group(3)
63
+ return "\n".join(kept)
64
+
65
+
66
+ def command_segments(command):
67
+ """The shell string split into simple commands, with heredoc bodies and quoted text removed."""
68
+ text = QUOTED.sub(" ", without_heredoc_bodies(command))
69
+ text = text.replace("$(", ";")
70
+ return [segment.strip() for segment in SEPARATORS.split(text) if segment.strip()]
71
+
72
+
73
+ def at_command_position(segment):
74
+ words = [word for word in segment.split() if not ASSIGNMENT.match(word)]
75
+ return bool(words) and os.path.basename(words[0]) in LAUNCHERS
38
76
 
39
77
 
40
78
  def agent_name(argv):
@@ -76,11 +114,13 @@ def disabled_locally(config):
76
114
 
77
115
 
78
116
  def long_command_in(command):
79
- """The name of the first long command the shell string runs, or None."""
80
- unquoted = QUOTED.sub(" ", command)
81
- for name, pattern in LONG_COMMANDS:
82
- if pattern.search(unquoted):
83
- return name
117
+ """The name of the first long command the shell string runs at a command position, or None."""
118
+ for segment in command_segments(command):
119
+ if not at_command_position(segment):
120
+ continue
121
+ for name, pattern in LONG_COMMANDS:
122
+ if pattern.search(segment) and not (name in HELP_PRINTS_USAGE and HELP_FLAG.search(segment)):
123
+ return name
84
124
  return None
85
125
 
86
126
 
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env python3
2
- """Stop hook: logs how many chat words a builder session wrote in the turn that just ended.
2
+ """Stop hook: logs the chat text of a builder turn and blocks a turn that ends with more than one line.
3
3
 
4
4
  Only runs in a session started with `--role builder` (ETHLETE_AGENT_ROLE=builder). Appends one
5
- JSON line to .claude/builder-chat-words.jsonl: timestamp, session_id, words. It never blocks,
6
- never prints and always exits 0.
5
+ JSON line to .claude/builder-chat-words.jsonl: timestamp, session_id, words, lines, committed, reported, blocked.
6
+ It blocks the stop once (not again while stop_hook_active is set) when the turn's text blocks and
7
+ last_assistant_message hold more than one non-empty line, or when the turn ran `git commit` or `git push` and sent
8
+ no report (no SendMessage, no `agent-sessions send`). It always exits 0.
7
9
  """
8
10
 
9
11
  import json
@@ -12,6 +14,16 @@ import sys
12
14
  from datetime import datetime, timezone
13
15
 
14
16
  LOG_FILE = os.path.join(".claude", "builder-chat-words.jsonl")
17
+ BLOCK_REASON = (
18
+ "builder: no chat text. Send the report with SendMessage to the grill session; "
19
+ "end the turn with at most one line."
20
+ )
21
+ REPORT_REASON = (
22
+ "builder: this turn committed or pushed and sent no report. Send it to the grill session with SendMessage "
23
+ "or `agent-sessions.mjs send`, then end the turn."
24
+ )
25
+ SEPARATORS = ";&|()\n"
26
+ GIT_OPTIONS_WITH_VALUE = {"-C", "-c", "--git-dir", "--work-tree", "--namespace", "--exec-path"}
15
27
 
16
28
 
17
29
  def is_prompt(entry):
@@ -25,8 +37,9 @@ def is_prompt(entry):
25
37
  )
26
38
 
27
39
 
28
- def count_words(path):
29
- words = 0
40
+ def turn_entries(path):
41
+ texts = []
42
+ tools = []
30
43
  with open(path, encoding="utf-8") as handle:
31
44
  for line in handle:
32
45
  try:
@@ -36,16 +49,181 @@ def count_words(path):
36
49
  if not isinstance(entry, dict):
37
50
  continue
38
51
  if is_prompt(entry):
39
- words = 0
52
+ texts = []
53
+ tools = []
40
54
  elif entry.get("type") == "assistant":
41
55
  content = (entry.get("message") or {}).get("content")
42
56
  if isinstance(content, str):
43
- words += len(content.split())
57
+ texts.append(content)
44
58
  elif isinstance(content, list):
45
59
  for block in content:
46
- if isinstance(block, dict) and block.get("type") == "text":
47
- words += len(str(block.get("text", "")).split())
48
- return words
60
+ if not isinstance(block, dict):
61
+ continue
62
+ if block.get("type") == "text":
63
+ texts.append(str(block.get("text", "")))
64
+ elif block.get("type") == "tool_use":
65
+ tools.append(block)
66
+ return texts, tools
67
+
68
+
69
+ def bash_commands(tools):
70
+ for tool in tools:
71
+ if tool.get("name") == "Bash":
72
+ command = (tool.get("input") or {}).get("command")
73
+ if isinstance(command, str):
74
+ yield command
75
+
76
+
77
+ def read_heredoc_delimiter(command, index):
78
+ strip_tabs = command.startswith("-", index)
79
+ if strip_tabs:
80
+ index += 1
81
+ while index < len(command) and command[index] in " \t":
82
+ index += 1
83
+ delimiter = []
84
+ while index < len(command) and command[index] not in " \t" + SEPARATORS + "<>":
85
+ char = command[index]
86
+ if char in "'\"":
87
+ end = command.find(char, index + 1)
88
+ end = len(command) if end == -1 else end
89
+ delimiter.append(command[index + 1 : end])
90
+ index = end + 1
91
+ else:
92
+ if char != "\\":
93
+ delimiter.append(char)
94
+ index += 1
95
+ return "".join(delimiter), strip_tabs, index
96
+
97
+
98
+ def skip_heredoc_bodies(command, index, heredocs):
99
+ for delimiter, strip_tabs in heredocs:
100
+ while index < len(command):
101
+ end = command.find("\n", index)
102
+ end = len(command) if end == -1 else end
103
+ row = command[index:end]
104
+ index = end + 1
105
+ if (row.lstrip("\t") if strip_tabs else row) == delimiter:
106
+ break
107
+ return index
108
+
109
+
110
+ def simple_commands(command):
111
+ commands = [[]]
112
+ word = None
113
+ heredocs = []
114
+ index = 0
115
+
116
+ def end_word():
117
+ nonlocal word
118
+ if word is not None:
119
+ commands[-1].append(word)
120
+ word = None
121
+
122
+ def end_command():
123
+ end_word()
124
+ if commands[-1]:
125
+ commands.append([])
126
+
127
+ while index < len(command):
128
+ char = command[index]
129
+ if char == "\\":
130
+ if command.startswith("\n", index + 1):
131
+ index += 2
132
+ continue
133
+ word = (word or "") + command[index + 1 : index + 2]
134
+ index += 2
135
+ elif char == "'":
136
+ end = command.find("'", index + 1)
137
+ end = len(command) if end == -1 else end
138
+ word = (word or "") + command[index + 1 : end]
139
+ index = end + 1
140
+ elif char == '"':
141
+ index += 1
142
+ chars = []
143
+ while index < len(command) and command[index] != '"':
144
+ if command[index] == "\\" and index + 1 < len(command):
145
+ index += 1
146
+ chars.append(command[index])
147
+ index += 1
148
+ word = (word or "") + "".join(chars)
149
+ index += 1
150
+ elif char == "#" and word is None:
151
+ end = command.find("\n", index)
152
+ index = len(command) if end == -1 else end
153
+ elif command.startswith("<<<", index):
154
+ end_word()
155
+ index += 3
156
+ elif command.startswith("<<", index):
157
+ end_word()
158
+ delimiter, strip_tabs, index = read_heredoc_delimiter(command, index + 2)
159
+ heredocs.append((delimiter, strip_tabs))
160
+ elif char == "\n":
161
+ end_command()
162
+ index = skip_heredoc_bodies(command, index + 1, heredocs)
163
+ heredocs = []
164
+ elif char in SEPARATORS:
165
+ end_command()
166
+ index += 1
167
+ elif char in " \t":
168
+ end_word()
169
+ index += 1
170
+ else:
171
+ word = (word or "") + char
172
+ index += 1
173
+ end_command()
174
+ return [words for words in commands if words]
175
+
176
+
177
+ def command_words(words):
178
+ index = 0
179
+ while index < len(words) and "=" in words[index] and not words[index].startswith("-"):
180
+ index += 1
181
+ return words[index:]
182
+
183
+
184
+ def is_git_commit(words):
185
+ words = command_words(words)
186
+ if not words or os.path.basename(words[0]) != "git":
187
+ return False
188
+ index = 1
189
+ while index < len(words) and words[index].startswith("-"):
190
+ index += 2 if words[index] in GIT_OPTIONS_WITH_VALUE else 1
191
+ return index < len(words) and words[index] in ("commit", "push")
192
+
193
+
194
+ def is_report_send(words):
195
+ words = command_words(words)
196
+ if len(words) < 3:
197
+ return False
198
+ if words[0] == "yarn":
199
+ return words[1:3] == ["agents:sessions", "send"]
200
+ if os.path.basename(words[0]) != "node":
201
+ return False
202
+ scripts = [word for word in words[1:] if not word.startswith("-")]
203
+ return len(scripts) >= 2 and os.path.basename(scripts[0]) == "agent-sessions.mjs" and scripts[1] == "send"
204
+
205
+
206
+ def bash_simple_commands(tools):
207
+ for command in bash_commands(tools):
208
+ yield from simple_commands(command)
209
+
210
+
211
+ def has_commit(tools):
212
+ return any(is_git_commit(words) for words in bash_simple_commands(tools))
213
+
214
+
215
+ def has_report(tools):
216
+ return any(tool.get("name") == "SendMessage" for tool in tools) or any(
217
+ is_report_send(words) for words in bash_simple_commands(tools)
218
+ )
219
+
220
+
221
+ def with_final(texts, final):
222
+ if not isinstance(final, str) or not final.strip():
223
+ return texts
224
+ if texts and texts[-1].strip() == final.strip():
225
+ return texts
226
+ return [*texts, final]
49
227
 
50
228
 
51
229
  def main():
@@ -53,18 +231,35 @@ def main():
53
231
  return
54
232
  payload = json.load(sys.stdin)
55
233
  path = payload.get("transcript_path")
56
- if not path or not os.path.isfile(path):
234
+ final = payload.get("last_assistant_message")
235
+ has_transcript = bool(path) and os.path.isfile(path)
236
+ if not has_transcript and not isinstance(final, str):
57
237
  return
58
238
  root = os.environ.get("CLAUDE_PROJECT_DIR") or payload.get("cwd") or os.getcwd()
59
239
  log = os.path.join(root, LOG_FILE)
60
240
  os.makedirs(os.path.dirname(log), exist_ok=True)
241
+ # Claude Code calls the Stop hook before the final text block reaches the transcript.
242
+ texts, tools = turn_entries(path) if has_transcript else ([], [])
243
+ texts = with_final(texts, final)
244
+ lines = sum(1 for text in texts for row in text.splitlines() if row.strip())
245
+ committed = has_commit(tools)
246
+ reported = has_report(tools)
247
+ unreported = committed and not reported
248
+ blocked = (lines > 1 or unreported) and not payload.get("stop_hook_active")
61
249
  record = {
62
250
  "timestamp": datetime.now(timezone.utc).isoformat(),
63
251
  "session_id": payload.get("session_id"),
64
- "words": count_words(path),
252
+ "words": sum(len(text.split()) for text in texts),
253
+ "lines": lines,
254
+ "committed": committed,
255
+ "reported": reported,
256
+ "blocked": blocked,
65
257
  }
66
258
  with open(log, "a", encoding="utf-8") as handle:
67
259
  handle.write(json.dumps(record) + "\n")
260
+ if blocked:
261
+ reason = REPORT_REASON if unreported else BLOCK_REASON
262
+ print(json.dumps({"decision": "block", "reason": reason}))
68
263
 
69
264
 
70
265
  try:
@@ -6,13 +6,13 @@ Denies, for a Bash call:
6
6
  - every `git stash` that writes (bare, `push`, `save`, `pop`, `apply`, `drop`, `clear`, `branch`,
7
7
  `create`, `store`); `git stash list` and `git stash show` stay allowed
8
8
  - `git commit --amend`
9
- - `git commit` without a ` -- <paths>` pathspec
10
- - any `git add` or `git commit` whose paths name an `.ethlete/**/go.json` (a go is granted
11
- in Studio, never committed by an agent)
9
+ - `git commit` without a ` -- <paths>` pathspec, except the commit that concludes a merge: while
10
+ `MERGE_HEAD` exists and every staged path changed between HEAD and MERGE_HEAD, is conflicted, or is a
11
+ plan archive under `plans/**/archive/` (an archive run that shrinks a merged plan writes there)
12
12
 
13
13
  `git commit-tree` and `git update-index` stay allowed, so a merge commit built on a temporary
14
- GIT_INDEX_FILE works. Commit messages (`-m`, `--message`) and other quoted text are ignored for
15
- the command checks, so a message that mentions `git stash` does not trip the hook.
14
+ GIT_INDEX_FILE works. Only real command positions count: commit messages (`-m`, `--message`), quoted text and heredoc
15
+ bodies are ignored, so a grep pattern or message that mentions `git stash` does not trip the hook.
16
16
 
17
17
  Can be disabled per machine via a gitignored ethlete-agents.config.local.json at the repo
18
18
  root: {"disableHooks": true} or {"disableHooks": ["git-safety"]}.
@@ -23,6 +23,7 @@ Fail-safe: any error exits 0 with no output.
23
23
  import json
24
24
  import os
25
25
  import re
26
+ import subprocess
26
27
  import sys
27
28
 
28
29
  HOOK_NAME = "git-safety"
@@ -31,10 +32,11 @@ LOCAL_CONFIG_FILE = "ethlete-agents.config.local.json"
31
32
  MESSAGE_ARG = re.compile(
32
33
  r"""(?:^|(?<=\s))(?:-[a-zA-Z]*m|--message)(?:=|\s*)(?:"(?:\\.|[^"\\])*"|'[^']*'|[^\s;&|]*)"""
33
34
  )
34
- SEGMENT_SPLIT = re.compile(r"[;&|\n]+")
35
+ SEGMENT_SPLIT = re.compile(r"[;&|\n()`]+")
36
+ HEREDOC = re.compile(r"<<-?[ \t]*(['\"]?)(\w+)\1([^\n]*)\n(?:.*?\n)?[ \t]*\2[ \t]*(?=\n|$)", re.DOTALL)
37
+ QUOTED = re.compile(r"\"(?:\\.|[^\"\\])*\"|'[^']*'")
35
38
  GLOBAL_OPTS_WITH_VALUE = ("-C", "-c", "--git-dir", "--work-tree", "--namespace")
36
39
  ADD_ALL = ("-A", "--all", ".")
37
- GO_JSON = re.compile(r"(?:^|/)go\.json$")
38
40
 
39
41
  def agent_name(argv):
40
42
  for index, arg in enumerate(argv):
@@ -76,8 +78,8 @@ def disabled_locally(config):
76
78
 
77
79
  def git_calls_in(command):
78
80
  """Yield (subcommand, args) for every command-position git call in the shell string."""
79
- stripped = MESSAGE_ARG.sub(" ", command)
80
- unquoted = stripped.replace('"', " ").replace("'", " ")
81
+ stripped = MESSAGE_ARG.sub(" ", HEREDOC.sub(r"<<\3", command))
82
+ unquoted = QUOTED.sub(lambda m: re.sub(r"[\s;&|(`]", "_", m.group(0)[1:-1]), stripped)
81
83
  for segment in SEGMENT_SPLIT.split(unquoted):
82
84
  words = segment.split()
83
85
  index = 0
@@ -85,11 +87,14 @@ def git_calls_in(command):
85
87
  index += 1
86
88
  if index < len(words) and (words[index] == "git" or words[index].endswith("/git")):
87
89
  rest = words[index + 1 :]
90
+ directory = None
88
91
  while rest and rest[0].startswith("-"):
92
+ if rest[0] == "-C" and len(rest) > 1:
93
+ directory = rest[1]
89
94
  skip = 2 if rest[0] in GLOBAL_OPTS_WITH_VALUE else 1
90
95
  rest = rest[skip:]
91
96
  if rest:
92
- yield rest[0], rest[1:]
97
+ yield rest[0], rest[1:], directory
93
98
 
94
99
 
95
100
  STASH_READS = ("list", "show")
@@ -100,9 +105,37 @@ def stash_subcommand_of(args):
100
105
  return args[0] if args and not args[0].startswith("-") else "push"
101
106
 
102
107
 
103
- def violation_in(command):
108
+ def git_lines(cwd, *args):
109
+ result = subprocess.run(["git", *args], cwd=cwd, capture_output=True, text=True, timeout=10, check=True)
110
+ return {line for line in result.stdout.splitlines() if line}
111
+
112
+
113
+ def concludes_merge(cwd):
114
+ """True while MERGE_HEAD exists and every staged path belongs to the merge. Any error is False."""
115
+ try:
116
+ merge_head = git_lines(cwd, "rev-parse", "--git-path", "MERGE_HEAD")
117
+ if not merge_head or not os.path.isfile(os.path.join(cwd, next(iter(merge_head)))):
118
+ return False
119
+ staged = git_lines(cwd, "diff", "--cached", "--name-only")
120
+ merge_paths = git_lines(cwd, "diff", "--name-only", "HEAD", "MERGE_HEAD") | git_lines(
121
+ cwd, "diff", "--name-only", "--diff-filter=U"
122
+ )
123
+ return all(path in merge_paths or is_plan_archive(path) for path in staged)
124
+ except Exception:
125
+ return False
126
+
127
+
128
+ def is_plan_archive(path):
129
+ return path.startswith("plans/") and "/archive/" in path
130
+
131
+
132
+ def stages_everything(args):
133
+ return any(arg == "--all" or re.fullmatch(r"-[a-zA-Z]*a[a-zA-Z]*", arg) for arg in args if arg != "--")
134
+
135
+
136
+ def violation_in(command, cwd=None):
104
137
  """(rule, allowed form) for the first forbidden git call, or None."""
105
- for sub, args in git_calls_in(command):
138
+ for sub, args, directory in git_calls_in(command):
106
139
  if sub == "add":
107
140
  if any(arg in ADD_ALL for arg in args):
108
141
  return (
@@ -120,16 +153,14 @@ def violation_in(command):
120
153
  "`git commit --amend` rewrites a commit another session may have built on",
121
154
  "make a new commit: `git commit -m \"...\" -- <paths>`",
122
155
  )
123
- if "--" not in args:
156
+ if "--" not in args and not (
157
+ not stages_everything(args)
158
+ and concludes_merge(os.path.join(cwd or os.getcwd(), directory) if directory else cwd or os.getcwd())
159
+ ):
124
160
  return (
125
161
  "`git commit` without a pathspec commits everything staged, including other sessions' work",
126
162
  "name the paths: `git commit -m \"...\" -- <paths>`",
127
163
  )
128
- if sub in ("add", "commit") and any(GO_JSON.search(arg) for arg in args):
129
- return (
130
- "an agent never stages or commits a `go.json`; a go is granted in Studio",
131
- "leave `go.json` out of the paths",
132
- )
133
164
  return None
134
165
 
135
166
 
@@ -155,7 +186,8 @@ def main():
155
186
  if disabled_locally(load_local_config(repo_root(data))):
156
187
  return
157
188
 
158
- found = violation_in(command)
189
+ cwd = data.get("cwd")
190
+ found = violation_in(command, cwd if isinstance(cwd, str) and cwd else None)
159
191
 
160
192
  if not found:
161
193
  return
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "e2e-progress",
3
- "version": "0.1.0-next.32",
3
+ "version": "0.1.0-next.34",
4
4
  "description": "Live Playwright e2e progress from a run log, as a status line entry and a pane",
5
5
  "types": "./types/index.d.ts"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: app-styling
3
- description: App components are styled with Tailwind utilities in their templates; app CSS stays out of @layer components; the SDK needs a 10px rem root; hardcoded colours are never primary values.
3
+ description: App components are styled with Tailwind utilities in their templates; app CSS goes in @layer components, @layer utilities or unlayered; the SDK needs a 10px rem root; hardcoded colours are never primary values.
4
4
  kind: rule
5
5
  scope: consumer
6
6
  requires: ['@ethlete/core']
@@ -31,12 +31,12 @@ tell the user once at first contact, with the size of the conversion (files, cla
31
31
  colours), and record it as owed work in the plan or handoff. Never skip it silently. This holds
32
32
  for a deviation from any rule here: report it once and record it.
33
33
 
34
- Write CSS only for what utilities cannot express. With Tailwind 4, keep that CSS **unlayered**
35
- or in `@layer utilities` — never in `@layer components`, and that includes the global
36
- stylesheet. SDK component styles are injected into `@layer components` at runtime, after your
37
- stylesheet, so an app rule in the same layer ties on layer and loses on source order. With
38
- Tailwind 3, `@layer` is a Tailwind directive that emits unlayered CSS, so app CSS already beats
39
- the SDK's layered styles.
34
+ Write CSS only for what utilities cannot express. With Tailwind 4, put that CSS in
35
+ `@layer components`, `@layer utilities` or leave it unlayered: SDK component styles sit in
36
+ `@layer components.sdk`, a layer nested in `components`, so each of the three beats them. In
37
+ `@layer components` a utility on the same element still wins over the app rule. With Tailwind
38
+ 3, `@layer` is a Tailwind directive that emits unlayered CSS, so app CSS already beats the
39
+ SDK's layered styles.
40
40
 
41
41
  To change an SDK component's look, set its `--et-*` tokens first (documented per
42
42
  component), then use a utility class or unlayered CSS on the element — see "Overriding
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: styling
3
- description: Component CSS is plain CSS in @layer components, and hardcoded colours are never primary values.
3
+ description: Component CSS is plain CSS in @layer components.sdk, and hardcoded colours are never primary values.
4
4
  kind: rule
5
5
  scope: sdk
6
6
  requires: ['@ethlete/core']
@@ -13,13 +13,15 @@ Component styles are **plain CSS** — global `et-`-prefixed classes with
13
13
  in component source.** Utilities belong in application templates and story files, not in
14
14
  the stylesheet a component ships.
15
15
 
16
- **Wrap every component CSS file in `@layer components { … }`** — the whole file inside one
17
- block. Component CSS is injected as a global `<style>` tag; unlayered, it beats Tailwind v4
16
+ **Wrap every component CSS file in `@layer components.sdk { … }`** — the whole file inside
17
+ one block. Component CSS is injected as a global `<style>` tag; unlayered, it beats Tailwind v4
18
18
  utilities (which live in `@layer utilities`) regardless of specificity, because layer
19
19
  precedence is resolved before specificity — so overriding `.et-button` would need
20
20
  `flex!` instead of `flex`. `:where()` does not help across layers. Tailwind v4 pre-declares
21
21
  `@layer theme, base, components, utilities`, so the wrap puts component styles where a
22
- utility can win.
22
+ utility can win. `components.sdk` is nested in `components`, and a layer's own rules beat its
23
+ nested layers, so an app rule in `@layer components` also wins. Never wrap SDK CSS in plain
24
+ `@layer components`: it would tie with the app's rules again.
23
25
 
24
26
  `:where()` has a separate job: keeping a component's own config modifiers
25
27
  (`[data-size]`, `[data-variant]`, `[disabled]`) at the same single-class weight as its base