@ethlete/agent-rules 0.1.0-next.6 → 0.1.0-next.60
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/AGENTS.md +28 -0
- package/CHANGELOG.md +841 -0
- package/CLAUDE.md +1 -0
- package/README.md +244 -36
- package/THIRD-PARTY-LICENSES.md +35 -0
- package/content/defaults.json +1 -1
- package/content/hooks/away-mode.py +410 -0
- package/content/hooks/background-commands.py +177 -0
- package/content/hooks/builder-idle-check.py +529 -0
- package/content/hooks/context-warning.py +666 -134
- package/content/hooks/git-safety.py +213 -0
- package/content/hooks/human-wait-check.py +167 -0
- package/content/hooks/subagent-model-policy.py +261 -0
- package/content/mods/.claude-plugin/marketplace.json +26 -0
- package/content/mods/plugins/codex-runs/.claude-plugin/plugin.json +6 -0
- package/content/mods/plugins/codex-runs/hooks/agent-runs.ts +310 -0
- package/content/mods/plugins/codex-runs/hooks/hooks.json +1 -0
- package/content/mods/plugins/codex-runs/hooks/progress.ts +130 -0
- package/content/mods/plugins/codex-runs/hooks/register.tsx +283 -0
- package/content/mods/plugins/codex-runs/tests/pane.test.ts +21 -0
- package/content/mods/plugins/codex-runs/tsconfig.json +4 -0
- package/content/mods/plugins/codex-runs/types/index.d.ts +37 -0
- package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +6 -0
- package/content/mods/plugins/e2e-progress/hooks/hooks.json +1 -0
- package/content/mods/plugins/e2e-progress/hooks/progress.ts +205 -0
- package/content/mods/plugins/e2e-progress/hooks/register.tsx +498 -0
- package/content/mods/plugins/e2e-progress/tsconfig.json +3 -0
- package/content/mods/plugins/e2e-progress/types/index.d.ts +27 -0
- package/content/mods/plugins/status-line/.claude-plugin/plugin.json +6 -0
- package/content/mods/plugins/status-line/hooks/hooks.json +1 -0
- package/content/mods/plugins/status-line/hooks/line.ts +74 -0
- package/content/mods/plugins/status-line/hooks/register.tsx +141 -0
- package/content/mods/plugins/status-line/types/index.d.ts +5 -0
- package/content/mods/plugins/usage-line/.claude-plugin/plugin.json +6 -0
- package/content/mods/plugins/usage-line/hooks/codex.ts +52 -0
- package/content/mods/plugins/usage-line/hooks/format.ts +24 -0
- package/content/mods/plugins/usage-line/hooks/hooks.json +1 -0
- package/content/mods/plugins/usage-line/hooks/rate-limits.ts +23 -0
- package/content/mods/plugins/usage-line/hooks/register.tsx +83 -0
- package/content/mods/plugins/usage-line/tsconfig.json +4 -0
- package/content/mods/plugins/usage-line/types/index.d.ts +5 -0
- package/content/output-styles/ste-clarity.md +131 -0
- package/content/rules/agent-sessions-wake-up.md +11 -0
- package/content/rules/app-styling.md +66 -0
- package/content/rules/comments.md +4 -1
- package/content/rules/lint-and-format.md +7 -5
- package/content/rules/nx-layout.md +53 -0
- package/content/rules/reactive-state.md +1 -1
- package/content/rules/styling.md +19 -10
- package/content/rules/subagent-models.md +42 -0
- package/content/rules/waiting-on-the-human.md +17 -0
- package/content/skills/agent-sessions/SKILL.md +101 -0
- package/content/skills/agent-sessions/agent-sessions.mjs +1462 -0
- package/content/skills/angular-patterns/SKILL.md +31 -7
- package/content/skills/api-source/SKILL.md +156 -0
- package/content/skills/app-testing/SKILL.md +141 -0
- package/content/skills/codex-subagent/SKILL.md +102 -0
- package/content/skills/codex-subagent/codex-agent.mjs +260 -0
- package/content/skills/codex-subagent/codex-limit.mjs +106 -0
- package/content/skills/design-exploration/SKILL.md +121 -0
- package/content/skills/design-exploration/check-story.mjs +139 -0
- package/content/skills/design-exploration/reference-shots.md +15 -0
- package/content/skills/design-exploration/shoot-template.mjs +61 -0
- package/content/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
- package/content/skills/domain-modeling/SKILL.md +71 -0
- package/content/skills/e2e-triage/SKILL.md +80 -0
- package/content/skills/figma-export/SKILL.md +16 -18
- package/content/skills/git-commit/SKILL.md +21 -7
- package/content/skills/git-flow/SKILL.md +9 -5
- package/content/skills/grill-with-docs/SKILL.md +13 -0
- package/content/skills/grilling/SKILL.md +52 -0
- package/content/skills/handoff/SKILL.md +30 -72
- package/content/skills/handoff/save.md +189 -0
- package/content/skills/query/SKILL.md +165 -74
- package/content/skills/report/SKILL.md +26 -0
- package/content/skills/rxjs-signals/SKILL.md +33 -4
- package/content/skills/sdk-docs/SKILL.md +50 -14
- package/content/skills/sdk-local-build/SKILL.md +26 -8
- package/content/skills/sdk-local-build/sdk-local-baseline.mjs +64 -0
- package/content/skills/sdk-source/SKILL.md +37 -34
- package/content/skills/sdk-update/SKILL.md +103 -0
- package/content/skills/story-styling/SKILL.md +12 -10
- package/content/skills/styleguide/SKILL.md +13 -8
- package/content/skills/styleguide/assets.md +54 -0
- package/content/skills/styleguide/changesets.md +17 -0
- package/content/skills/styleguide/file-structure.md +73 -0
- package/content/skills/styleguide/lint-rule-lookup.md +52 -0
- package/content/skills/styleguide/storybook-structure.md +25 -0
- package/content/skills/theming/SKILL.md +76 -49
- package/content/skills/verify-in-app/SKILL.md +107 -0
- package/content/skills/verify-in-storybook/SKILL.md +1 -1
- package/content/skills/verify-on-apple-devices/SKILL.md +100 -0
- package/content/skills/verify-on-apple-devices/apple-remote.sh +421 -0
- package/content/skills/verify-on-apple-devices/sim-edge-back.m +159 -0
- package/migrations/list-state-query-form.md +20 -0
- package/migrations/nx-layout.md +29 -0
- package/migrations/sdk-components-over-hand-built-ui.md +27 -0
- package/migrations/search-query-field.md +52 -0
- package/migrations/studio-claude-plugin.md +27 -0
- package/migrations.json +47 -0
- package/package.json +8 -3
- package/src/index.js +84 -28
- package/src/index.js.map +1 -1
- package/src/lib/cli-args.d.ts +9 -0
- package/src/lib/cli-args.js +48 -0
- package/src/lib/cli-args.js.map +1 -0
- package/src/lib/commitlint.d.ts +10 -0
- package/src/lib/commitlint.js +51 -0
- package/src/lib/commitlint.js.map +1 -0
- package/src/lib/config.d.ts +53 -22
- package/src/lib/config.js +128 -12
- package/src/lib/config.js.map +1 -1
- package/src/lib/filter.d.ts +3 -0
- package/src/lib/filter.js +7 -5
- package/src/lib/filter.js.map +1 -1
- package/src/lib/frontmatter.d.ts +2 -0
- package/src/lib/frontmatter.js +33 -5
- package/src/lib/frontmatter.js.map +1 -1
- package/src/lib/git-flow/config.js +1 -1
- package/src/lib/git-flow/config.js.map +1 -1
- package/src/lib/git-flow/index.d.ts +1 -0
- package/src/lib/git-flow/index.js +20 -6
- package/src/lib/git-flow/index.js.map +1 -1
- package/src/lib/git-flow/parse.js +38 -12
- package/src/lib/git-flow/parse.js.map +1 -1
- package/src/lib/git-flow/rename.d.ts +24 -0
- package/src/lib/git-flow/rename.js +70 -0
- package/src/lib/git-flow/rename.js.map +1 -0
- package/src/lib/git-flow/start.d.ts +27 -0
- package/src/lib/git-flow/start.js +34 -1
- package/src/lib/git-flow/start.js.map +1 -1
- package/src/lib/git-flow-command.js +10 -2
- package/src/lib/git-flow-command.js.map +1 -1
- package/src/lib/git-flow-repair.d.ts +1 -1
- package/src/lib/git-flow-repair.js +30 -15
- package/src/lib/git-flow-repair.js.map +1 -1
- package/src/lib/git-flow-start.d.ts +1 -1
- package/src/lib/git-flow-start.js +25 -32
- package/src/lib/git-flow-start.js.map +1 -1
- package/src/lib/git.d.ts +37 -0
- package/src/lib/git.js +85 -3
- package/src/lib/git.js.map +1 -1
- package/src/lib/gitlab.js +24 -6
- package/src/lib/gitlab.js.map +1 -1
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +26 -11
- package/src/lib/index.js.map +1 -1
- package/src/lib/migrate.js +8 -2
- package/src/lib/migrate.js.map +1 -1
- package/src/lib/output-style-command.d.ts +3 -0
- package/src/lib/output-style-command.js +69 -0
- package/src/lib/output-style-command.js.map +1 -0
- package/src/lib/output-style.d.ts +38 -0
- package/src/lib/output-style.js +134 -0
- package/src/lib/output-style.js.map +1 -0
- package/src/lib/owned-paths.js +8 -2
- package/src/lib/owned-paths.js.map +1 -1
- package/src/lib/package-runner.d.ts +4 -0
- package/src/lib/package-runner.js +86 -0
- package/src/lib/package-runner.js.map +1 -0
- package/src/lib/plain-text.d.ts +9 -0
- package/src/lib/plain-text.js +22 -0
- package/src/lib/plain-text.js.map +1 -0
- package/src/lib/plan.d.ts +6 -6
- package/src/lib/plan.js +153 -40
- package/src/lib/plan.js.map +1 -1
- package/src/lib/prettier.d.ts +21 -0
- package/src/lib/prettier.js +51 -0
- package/src/lib/prettier.js.map +1 -0
- package/src/lib/prompt.js +10 -2
- package/src/lib/prompt.js.map +1 -1
- package/src/lib/render.d.ts +14 -1
- package/src/lib/render.js +23 -5
- package/src/lib/render.js.map +1 -1
- package/src/lib/report-command.d.ts +34 -0
- package/src/lib/report-command.js +322 -0
- package/src/lib/report-command.js.map +1 -0
- package/src/lib/sessions-command.d.ts +4 -0
- package/src/lib/sessions-command.js +16 -0
- package/src/lib/sessions-command.js.map +1 -0
- package/src/lib/sync.d.ts +1 -2
- package/src/lib/sync.js +37 -17
- package/src/lib/sync.js.map +1 -1
- package/src/lib/targets/agents-skills.js +1 -1
- package/src/lib/targets/agents-skills.js.map +1 -1
- package/src/lib/targets/claude-hooks.d.ts +5 -0
- package/src/lib/targets/claude-hooks.js +27 -4
- package/src/lib/targets/claude-hooks.js.map +1 -1
- package/src/lib/targets/claude-mods.d.ts +20 -0
- package/src/lib/targets/claude-mods.js +47 -0
- package/src/lib/targets/claude-mods.js.map +1 -0
- package/src/lib/targets/claude.js +2 -3
- package/src/lib/targets/claude.js.map +1 -1
- package/src/lib/targets/codex-hooks.js +4 -2
- package/src/lib/targets/codex-hooks.js.map +1 -1
- package/src/lib/targets/codex.js +4 -4
- package/src/lib/targets/codex.js.map +1 -1
- package/src/lib/targets/copilot.js +4 -4
- package/src/lib/targets/copilot.js.map +1 -1
- package/src/lib/targets/cursor.js +3 -3
- package/src/lib/targets/cursor.js.map +1 -1
- package/src/lib/targets/git-hooks.d.ts +1 -1
- package/src/lib/targets/git-hooks.js +6 -5
- package/src/lib/targets/git-hooks.js.map +1 -1
- package/src/lib/targets/hooks-shared.d.ts +34 -5
- package/src/lib/targets/hooks-shared.js +132 -36
- package/src/lib/targets/hooks-shared.js.map +1 -1
- package/src/lib/targets/mcp.d.ts +25 -0
- package/src/lib/targets/mcp.js +114 -0
- package/src/lib/targets/mcp.js.map +1 -0
- package/src/lib/targets/shared.d.ts +1 -9
- package/src/lib/targets/shared.js +4 -8
- package/src/lib/targets/shared.js.map +1 -1
- package/src/lib/timetrack.d.ts +16 -0
- package/src/lib/timetrack.js +149 -0
- package/src/lib/timetrack.js.map +1 -0
- package/content/skills/styleguide/STYLEGUIDE.md +0 -520
- package/src/lib/jira.d.ts +0 -28
- package/src/lib/jira.js +0 -83
- package/src/lib/jira.js.map +0 -1
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Drive the team Mac's iOS Simulator and the real iPad from a Linux PC over LAN.
|
|
3
|
+
# See SKILL.md in this directory for setup, gotchas, and usage examples.
|
|
4
|
+
# SIM_DEVELOPER_DIR picks the Xcode, SIM_RUNTIME the iOS runtime (e.g. iOS-26-3) for every simulator call.
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
MAC_HOST=${ETHLETE_MAC_HOST:-ethlete-mac}
|
|
8
|
+
STORYBOOK_URL=${ETHLETE_STORYBOOK_URL:-}
|
|
9
|
+
DRIVER_PORT=${ETHLETE_SAFARIDRIVER_PORT:-4444}
|
|
10
|
+
STATE_DIR=${TMPDIR:-/tmp}/ethlete-apple-remote
|
|
11
|
+
SID_FILE=$STATE_DIR/ipad-session-id
|
|
12
|
+
|
|
13
|
+
SIM_DEVELOPER_DIR=${SIM_DEVELOPER_DIR:-}
|
|
14
|
+
SIM_RUNTIME=${SIM_RUNTIME:-}
|
|
15
|
+
[[ -z $SIM_RUNTIME || $SIM_RUNTIME == com.apple.CoreSimulator.SimRuntime.* ]] || SIM_RUNTIME=com.apple.CoreSimulator.SimRuntime.$SIM_RUNTIME
|
|
16
|
+
|
|
17
|
+
mac() {
|
|
18
|
+
local prefix=
|
|
19
|
+
[[ -z $SIM_DEVELOPER_DIR ]] || prefix="export DEVELOPER_DIR=$(remote_arg "$SIM_DEVELOPER_DIR"); "
|
|
20
|
+
ssh -T -o BatchMode=yes -o ConnectTimeout=8 "$MAC_HOST" "$prefix$*"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
remote_arg() { printf "'%s'" "${1//\'/\'\\\'\'}"; }
|
|
24
|
+
|
|
25
|
+
usage_error() { printf 'Usage: apple-remote.sh %s\n' "$1" >&2; exit 2; }
|
|
26
|
+
|
|
27
|
+
pc_ip() {
|
|
28
|
+
local mac_ip
|
|
29
|
+
mac_ip=$(ssh -G "$MAC_HOST" | awk '/^hostname /{print $2}')
|
|
30
|
+
ip route get "$mac_ip" | grep -oP 'src \K\S+'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
storybook_base() {
|
|
34
|
+
local lan_ip
|
|
35
|
+
if [[ -n $STORYBOOK_URL ]]; then
|
|
36
|
+
printf '%s\n' "${STORYBOOK_URL%/}"
|
|
37
|
+
else
|
|
38
|
+
lan_ip=$(pc_ip) || return
|
|
39
|
+
printf 'http://%s:4400\n' "$lan_ip"
|
|
40
|
+
fi
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
page_url() {
|
|
44
|
+
local base
|
|
45
|
+
if [[ $1 =~ ^[a-zA-Z][a-zA-Z0-9+.-]*: ]]; then
|
|
46
|
+
printf '%s\n' "$1"
|
|
47
|
+
else
|
|
48
|
+
base=$(storybook_base) || return
|
|
49
|
+
printf '%s/iframe.html?id=%s&viewMode=story\n' "$base" "$1"
|
|
50
|
+
fi
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
wd() {
|
|
54
|
+
curl -s -X "$1" "http://localhost:$DRIVER_PORT$2" \
|
|
55
|
+
${3:+-H "Content-Type: application/json" -d "$3"}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
sid() { cat "$SID_FILE"; }
|
|
59
|
+
|
|
60
|
+
SIM_UDID_FILE=$STATE_DIR/sim-udid
|
|
61
|
+
|
|
62
|
+
sim_udid() {
|
|
63
|
+
mac 'xcrun simctl list devices available -j' | python3 -I -c '
|
|
64
|
+
import json, re, sys
|
|
65
|
+
name, wanted = sys.argv[1], sys.argv[2]
|
|
66
|
+
best = None
|
|
67
|
+
for runtime, devices in json.load(sys.stdin)["devices"].items():
|
|
68
|
+
if wanted and runtime != wanted:
|
|
69
|
+
continue
|
|
70
|
+
match = re.search(r"\.iOS-(\d+(?:-\d+)*)$", runtime)
|
|
71
|
+
if not match:
|
|
72
|
+
continue
|
|
73
|
+
version = tuple(int(part) for part in match.group(1).split("-"))
|
|
74
|
+
for device in devices:
|
|
75
|
+
if device["name"] == name and device.get("isAvailable", True) and (best is None or version > best[0]):
|
|
76
|
+
best = (version, device["udid"])
|
|
77
|
+
if best:
|
|
78
|
+
print(best[1])
|
|
79
|
+
' "$1" "$SIM_RUNTIME"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
sim_create() {
|
|
83
|
+
local type_id
|
|
84
|
+
type_id=$(mac 'xcrun simctl list devicetypes -j' | python3 -I -c '
|
|
85
|
+
import json, sys
|
|
86
|
+
for t in json.load(sys.stdin)["devicetypes"]:
|
|
87
|
+
if t["name"] == sys.argv[1]:
|
|
88
|
+
print(t["identifier"])
|
|
89
|
+
break
|
|
90
|
+
' "$1")
|
|
91
|
+
[[ -n $type_id ]] || { echo "no device type named '$1'" >&2; return 1; }
|
|
92
|
+
echo "no '$1' on $SIM_RUNTIME: creating one" >&2
|
|
93
|
+
mac "xcrun simctl create $(remote_arg "$1") $type_id $SIM_RUNTIME"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
sim_target() {
|
|
97
|
+
[[ -s $SIM_UDID_FILE ]] || { echo 'no simulator booted by this script: run sim-open or sim-probe first' >&2; return 1; }
|
|
98
|
+
cat "$SIM_UDID_FILE"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
sim_edge_back() {
|
|
102
|
+
local udid skill_dir
|
|
103
|
+
udid=$(sim_target) || return
|
|
104
|
+
skill_dir=$(dirname -- "${BASH_SOURCE[0]}")
|
|
105
|
+
mac "set -e
|
|
106
|
+
work=\$(mktemp -d)
|
|
107
|
+
trap 'rm -rf -- \"\$work\"' EXIT
|
|
108
|
+
xcrun clang -x objective-c -fobjc-arc -framework AppKit -o \"\$work/edge-back\" -
|
|
109
|
+
\"\$work/edge-back\" $(remote_arg "$udid") \"\${DEVELOPER_DIR:-\$(xcode-select -p)}\"" < "$skill_dir/sim-edge-back.m"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
sim_boot() {
|
|
113
|
+
# simctl alone boots headless (black framebuffer, blank keyboard area, no window on
|
|
114
|
+
# the Mac) and openurl right after bootstatus times out - SpringBoard isn't up yet.
|
|
115
|
+
# Only the UDID of the requested device is ever passed to simctl: other agents' simulators stay untouched.
|
|
116
|
+
local udid
|
|
117
|
+
udid=$(sim_udid "$1")
|
|
118
|
+
if [[ -z $udid && -n $SIM_RUNTIME ]]; then
|
|
119
|
+
udid=$(sim_create "$1") || return 1
|
|
120
|
+
fi
|
|
121
|
+
[[ -n $udid ]] || { echo "no available device named '$1'" >&2; return 1; }
|
|
122
|
+
mkdir -p "$STATE_DIR"
|
|
123
|
+
printf '%s\n' "$udid" > "$SIM_UDID_FILE"
|
|
124
|
+
if mac "xcrun simctl list devices booted | grep -qF $udid && pgrep -xq Simulator"; then
|
|
125
|
+
return 0
|
|
126
|
+
elif [[ $? == 255 ]]; then
|
|
127
|
+
return 255
|
|
128
|
+
fi
|
|
129
|
+
echo "booting $1 ($udid; cold boot can take ~60s; anything past that is an error, not patience)..." >&2
|
|
130
|
+
mac "xcrun simctl boot $udid 2>/dev/null || true; open -g \"\$(xcode-select -p)/Applications/Simulator.app\" --args -CurrentDeviceUDID $udid; xcrun simctl bootstatus $udid" >/dev/null
|
|
131
|
+
mac "for i in \$(seq 1 20); do
|
|
132
|
+
xcrun simctl spawn $udid launchctl list 2>/dev/null | grep -q com.apple.SpringBoard && exit 0
|
|
133
|
+
sleep 3
|
|
134
|
+
done
|
|
135
|
+
echo 'SpringBoard did not come up within 60s' >&2; exit 1"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
sim_restart_app() {
|
|
139
|
+
local others
|
|
140
|
+
others=$(mac "xcrun simctl list devices booted | grep -oE '[0-9A-F]{8}(-[0-9A-F]{4}){3}-[0-9A-F]{12}' | grep -vF $1 || true")
|
|
141
|
+
if [[ -n $others ]]; then
|
|
142
|
+
echo "not restarting Simulator.app: other devices are booted ($(echo $others)); only $1 was shut down" >&2
|
|
143
|
+
return 0
|
|
144
|
+
fi
|
|
145
|
+
mac 'killall Simulator 2>/dev/null || true'
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
sim_openurl() {
|
|
149
|
+
local udid cmd
|
|
150
|
+
udid=$(sim_target)
|
|
151
|
+
cmd="xcrun simctl openurl $udid $(remote_arg "$1")"
|
|
152
|
+
mac "$cmd" && return 0
|
|
153
|
+
echo 'openurl failed, retrying once...' >&2
|
|
154
|
+
sleep 2
|
|
155
|
+
mac "$cmd"
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
sim_wait_loaded() {
|
|
159
|
+
local udid limit
|
|
160
|
+
udid=$(sim_target)
|
|
161
|
+
limit=${SIM_LOAD_TIMEOUT:-30}
|
|
162
|
+
mac "export PATH=/usr/local/bin:\$PATH; idle=0
|
|
163
|
+
for i in \$(seq 1 $limit); do
|
|
164
|
+
xcrun simctl spawn $udid launchctl list 2>/dev/null | grep -q com.apple.mobilesafari && break
|
|
165
|
+
sleep 1
|
|
166
|
+
done
|
|
167
|
+
for i in \$(seq 1 $limit); do
|
|
168
|
+
if ~/Library/Python/*/bin/idb ui describe-all --udid $udid --json 2>/dev/null | grep -q StopButton; then idle=0; else idle=\$((idle + 1)); fi
|
|
169
|
+
(( idle >= 2 )) && exit 0
|
|
170
|
+
sleep 1
|
|
171
|
+
done
|
|
172
|
+
exit 3" && return 0
|
|
173
|
+
echo "page still loading after ${limit}s (Safari StopButton present): shot may be partial; raise SIM_LOAD_TIMEOUT" >&2
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
sim_tip_present() {
|
|
177
|
+
mac "export PATH=/usr/local/bin:\$PATH; ~/Library/Python/*/bin/idb ui describe-all --udid $(sim_target) --json 2>/dev/null | grep -q PopoverDismissRegion"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
sim_dismiss_tips() {
|
|
181
|
+
local udid i
|
|
182
|
+
udid=$(sim_target)
|
|
183
|
+
for i in $(seq 0 "${SIM_TIP_WAIT:-5}"); do
|
|
184
|
+
if sim_tip_present; then
|
|
185
|
+
mac "export PATH=/usr/local/bin:\$PATH; idb=\$(echo ~/Library/Python/*/bin/idb)
|
|
186
|
+
set -- \$(\$idb ui describe-all --udid $udid --json | python3 -c \"import json,sys; d=json.load(sys.stdin); print(*next(([int(e['frame']['x']+e['frame']['width']/2), int(e['frame']['y']+e['frame']['height']/2)] for e in d if e.get('AXUniqueId')=='xmark.circle.fill'), []))\")
|
|
187
|
+
[ -n \"\$1\" ] && \$idb ui tap \$1 \$2 --udid $udid"
|
|
188
|
+
sleep 1
|
|
189
|
+
sim_tip_present && echo 'a Safari tip popover is still open after one tap on its close button' >&2
|
|
190
|
+
return 0
|
|
191
|
+
fi
|
|
192
|
+
sleep 1
|
|
193
|
+
done
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
find_el() {
|
|
197
|
+
local body
|
|
198
|
+
body=$(python3 -c 'import json,sys; print(json.dumps({"using": "css selector", "value": sys.argv[1]}))' "$1")
|
|
199
|
+
wd POST "/session/$(sid)/element" "$body" \
|
|
200
|
+
| python3 -c "import json,sys; v=json.load(sys.stdin)['value']; assert isinstance(v,dict) and 'error' not in v, v; print(list(v.values())[0])"
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
VIEWPORT_PROBE='return (() => {
|
|
204
|
+
const p = document.createElement("div");
|
|
205
|
+
p.style.cssText = "position:fixed;top:0;width:0;";
|
|
206
|
+
document.body.appendChild(p);
|
|
207
|
+
const h = (v) => { p.style.height = v; return p.getBoundingClientRect().height; };
|
|
208
|
+
const sizes = { vh: h("100vh"), dvh: h("100dvh"), svh: h("100svh"), lvh: h("100lvh") };
|
|
209
|
+
p.style.cssText = "padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)";
|
|
210
|
+
const cs = getComputedStyle(p);
|
|
211
|
+
const safeArea = { top: cs.paddingTop, right: cs.paddingRight, bottom: cs.paddingBottom, left: cs.paddingLeft };
|
|
212
|
+
p.remove();
|
|
213
|
+
const vv = window.visualViewport;
|
|
214
|
+
return { innerWidth, innerHeight, ...sizes, safeArea,
|
|
215
|
+
visualViewport: vv ? { width: vv.width, height: vv.height, offsetTop: vv.offsetTop, scale: vv.scale } : null,
|
|
216
|
+
keyboardLikelyOpen: vv ? innerHeight - vv.height > 100 : null,
|
|
217
|
+
activeElement: document.activeElement?.tagName };
|
|
218
|
+
})()'
|
|
219
|
+
|
|
220
|
+
case ${1:-help} in
|
|
221
|
+
detect) # [--storybook [url]] — check Mac and Apple devices, with an optional Storybook probe
|
|
222
|
+
case ${2:-} in
|
|
223
|
+
--storybook)
|
|
224
|
+
(( $# <= 3 )) || usage_error 'detect [--storybook [url]]'
|
|
225
|
+
STORYBOOK_URL=${3:-$STORYBOOK_URL}
|
|
226
|
+
;;
|
|
227
|
+
'') ;;
|
|
228
|
+
*) usage_error 'detect [--storybook [url]]' ;;
|
|
229
|
+
esac
|
|
230
|
+
mac 'echo "mac: $(hostname) ($(sw_vers -productVersion))"'
|
|
231
|
+
mac 'xcrun simctl list devices available | grep -ci iphone | sed "s/^/iphone sims: /"'
|
|
232
|
+
mac 'xcrun devicectl list devices 2>/dev/null | tail -n +3 | sed "s/^/device: /"' || true
|
|
233
|
+
if [[ ${2:-} == --storybook || -n $STORYBOOK_URL ]]; then
|
|
234
|
+
if URL=$(storybook_base) &&
|
|
235
|
+
STATUS=$(mac "curl -s --max-time 8 -o /dev/null -w '%{http_code}' -- $(remote_arg "$URL/")"); then
|
|
236
|
+
printf 'storybook from mac: %s\n' "$STATUS"
|
|
237
|
+
else
|
|
238
|
+
echo 'storybook from mac: unreachable'
|
|
239
|
+
fi
|
|
240
|
+
fi
|
|
241
|
+
;;
|
|
242
|
+
|
|
243
|
+
sim-open) # <url-or-story-id> [device-name] — open a page in the simulator
|
|
244
|
+
[[ -n ${2:-} && $# -le 3 ]] || usage_error 'sim-open <url-or-story-id> [device-name]'
|
|
245
|
+
URL=$(page_url "$2")
|
|
246
|
+
sim_boot "${3:-iPhone 16}"
|
|
247
|
+
sim_openurl "$URL"
|
|
248
|
+
sim_wait_loaded
|
|
249
|
+
sim_dismiss_tips
|
|
250
|
+
echo "opened on simulator: $URL"
|
|
251
|
+
;;
|
|
252
|
+
|
|
253
|
+
sim-probe) # <story-id> [device-name] — open story wrapped in the live viewport HUD (assets/viewport-probe.html);
|
|
254
|
+
# use with sim-tap/sim-type, read metrics off sim-shot (works without a WebDriver session)
|
|
255
|
+
URL="$(storybook_base)/assets/viewport-probe.html?story=$2"
|
|
256
|
+
sim_boot "${3:-iPhone 16}"
|
|
257
|
+
sim_openurl "$URL"
|
|
258
|
+
sim_wait_loaded
|
|
259
|
+
sim_dismiss_tips
|
|
260
|
+
echo "opened probe: $URL"
|
|
261
|
+
;;
|
|
262
|
+
|
|
263
|
+
sim-shot) # [out.png] — save a full-device screenshot
|
|
264
|
+
(( $# <= 2 )) || usage_error 'sim-shot [out.png]'
|
|
265
|
+
OUTPUT=${2:-sim.png}
|
|
266
|
+
sim_wait_loaded
|
|
267
|
+
if sim_tip_present; then
|
|
268
|
+
echo 'a Safari tip popover covers the page: the shot would hide the bottom bar. Close it with sim-tap on its close button and shoot again' >&2
|
|
269
|
+
exit 4
|
|
270
|
+
fi
|
|
271
|
+
TEMP_SHOT=$(mktemp -- "$OUTPUT.XXXXXX")
|
|
272
|
+
trap 'rm -f -- "$TEMP_SHOT"' EXIT
|
|
273
|
+
mac "xcrun simctl io $(sim_target) screenshot -" > "$TEMP_SHOT"
|
|
274
|
+
mv -f -- "$TEMP_SHOT" "$OUTPUT"
|
|
275
|
+
file -- "$OUTPUT"
|
|
276
|
+
;;
|
|
277
|
+
|
|
278
|
+
sim-tap) # <x> <y> — real touch tap (device points); focusing an input opens the soft keyboard
|
|
279
|
+
UDID=$(sim_target)
|
|
280
|
+
mac "export PATH=/usr/local/bin:\$PATH; ~/Library/Python/*/bin/idb ui tap $2 $3 --udid $UDID 2>/dev/null"
|
|
281
|
+
;;
|
|
282
|
+
|
|
283
|
+
sim-swipe) # edge-back | <x1> <y1> <x2> <y2> [duration-s] — real touch swipe in device points
|
|
284
|
+
if [[ $# == 2 && $2 == edge-back ]]; then
|
|
285
|
+
sim_edge_back
|
|
286
|
+
exit
|
|
287
|
+
fi
|
|
288
|
+
SWIPE_USAGE='sim-swipe edge-back | sim-swipe <x1> <y1> <x2> <y2> [duration-s]'
|
|
289
|
+
(( $# == 5 || $# == 6 )) || usage_error "$SWIPE_USAGE"
|
|
290
|
+
DURATION=${6:-0.3}
|
|
291
|
+
for POINT in "$2" "$3" "$4" "$5" "$DURATION"; do
|
|
292
|
+
[[ $POINT =~ ^-?([0-9]+([.][0-9]*)?|[.][0-9]+)$ ]] || usage_error "$SWIPE_USAGE"
|
|
293
|
+
done
|
|
294
|
+
UDID=$(sim_target)
|
|
295
|
+
mac "export PATH=/usr/local/bin:\$PATH; ~/Library/Python/*/bin/idb ui swipe --duration $DURATION $2 $3 $4 $5 --udid $UDID 2>/dev/null"
|
|
296
|
+
;;
|
|
297
|
+
|
|
298
|
+
sim-type) # <text> — types on the open soft keyboard (tap a field first via sim-tap)
|
|
299
|
+
UDID=$(sim_target)
|
|
300
|
+
TEXT=$(printf %q "$2")
|
|
301
|
+
mac "export PATH=/usr/local/bin:\$PATH; ~/Library/Python/*/bin/idb ui text $TEXT --udid $UDID 2>/dev/null"
|
|
302
|
+
;;
|
|
303
|
+
|
|
304
|
+
sim-keyboard-reset) # [device-name] — bring back soft-keyboard keys hidden by sim-type's HID keyboard events.
|
|
305
|
+
# `idb ui text` registers as a hardware keyboard; iOS then hides the keys (only the „Fertig"
|
|
306
|
+
# accessory bar shows). That state lives in the RUNNING Simulator.app process — it survives
|
|
307
|
+
# device reboots and pref writes, and dies only with the app. Restart it + reboot the device.
|
|
308
|
+
if [[ -s $SIM_UDID_FILE ]]; then
|
|
309
|
+
mac "xcrun simctl shutdown $(sim_target) 2>/dev/null || true"
|
|
310
|
+
sim_restart_app "$(sim_target)"
|
|
311
|
+
else
|
|
312
|
+
sim_restart_app none
|
|
313
|
+
fi
|
|
314
|
+
sim_boot "${2:-iPhone 16}"
|
|
315
|
+
echo "keyboard reset for ${2:-iPhone 16} — reopen your URL (sim-open/sim-probe) and tap a field"
|
|
316
|
+
;;
|
|
317
|
+
|
|
318
|
+
sim-keyboard) # on|off [device-name] — detach the hardware keyboard so the soft keyboard shows (restarts sims)
|
|
319
|
+
# Modern Simulator reads the per-device DevicePreferences key, NOT the legacy global
|
|
320
|
+
# ConnectHardwareKeyboard — writing only the global one silently does nothing.
|
|
321
|
+
[ "$2" = on ] && V=false && D=0 || { V=true; D=1; }
|
|
322
|
+
DEVICE=${3:-iPhone 16}
|
|
323
|
+
UDID=$(sim_udid "$DEVICE")
|
|
324
|
+
[ -n "$UDID" ] || { echo "no available device named '$DEVICE'" >&2; exit 1; }
|
|
325
|
+
mac "defaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool $V; defaults write com.apple.iphonesimulator DevicePreferences -dict-add '$UDID' '{ConnectHardwareKeyboard = $D;}'; xcrun simctl shutdown $UDID 2>/dev/null || true"
|
|
326
|
+
sim_restart_app "$UDID"
|
|
327
|
+
echo "soft keyboard $2 for $DEVICE ($UDID); re-run sim-open / sim-probe"
|
|
328
|
+
;;
|
|
329
|
+
|
|
330
|
+
sim-stop)
|
|
331
|
+
[[ ! -s $SIM_UDID_FILE ]] || mac "xcrun simctl shutdown $(sim_target) 2>/dev/null || true"
|
|
332
|
+
;;
|
|
333
|
+
|
|
334
|
+
ipad-start) # [sim] — tunnel + safaridriver + session (against the real iPad, or the booted simulator with `sim`)
|
|
335
|
+
mkdir -p "$STATE_DIR"
|
|
336
|
+
if ! curl -sf "http://localhost:$DRIVER_PORT/status" >/dev/null 2>&1; then
|
|
337
|
+
mac 'pkill -x safaridriver 2>/dev/null || true' # stale driver from a dead tunnel
|
|
338
|
+
ssh -f -T -o BatchMode=yes -o ExitOnForwardFailure=yes \
|
|
339
|
+
-L "$DRIVER_PORT:localhost:$DRIVER_PORT" "$MAC_HOST" \
|
|
340
|
+
"/usr/bin/safaridriver --port $DRIVER_PORT"
|
|
341
|
+
for _ in $(seq 1 10); do
|
|
342
|
+
curl -sf "http://localhost:$DRIVER_PORT/status" >/dev/null 2>&1 && break
|
|
343
|
+
sleep 1
|
|
344
|
+
done
|
|
345
|
+
fi
|
|
346
|
+
CAPS='{"browserName":"safari","platformName":"ios"}'
|
|
347
|
+
[ "${2:-}" = sim ] && CAPS='{"browserName":"safari","platformName":"ios","safari:useSimulator":true}'
|
|
348
|
+
RESP=$(wd POST /session "{\"capabilities\":{\"alwaysMatch\":$CAPS}}")
|
|
349
|
+
SID=$(echo "$RESP" | python3 -c "import json,sys; print(json.load(sys.stdin)['value'].get('sessionId',''))" 2>/dev/null || true)
|
|
350
|
+
if [ -z "$SID" ] && echo "$RESP" | grep -q "already paired"; then
|
|
351
|
+
# stale pairing from a dead session: drop it and restart the driver, then retry once
|
|
352
|
+
[ -f "$SID_FILE" ] && wd DELETE "/session/$(sid)" >/dev/null 2>&1 && rm -f "$SID_FILE"
|
|
353
|
+
pkill -f "ssh.*-L $DRIVER_PORT:localhost:$DRIVER_PORT" 2>/dev/null || true
|
|
354
|
+
mac 'pkill -x safaridriver 2>/dev/null || true'
|
|
355
|
+
ssh -f -T -o BatchMode=yes -o ExitOnForwardFailure=yes \
|
|
356
|
+
-L "$DRIVER_PORT:localhost:$DRIVER_PORT" "$MAC_HOST" \
|
|
357
|
+
"/usr/bin/safaridriver --port $DRIVER_PORT"
|
|
358
|
+
for _ in $(seq 1 10); do
|
|
359
|
+
curl -sf "http://localhost:$DRIVER_PORT/status" >/dev/null 2>&1 && break
|
|
360
|
+
sleep 1
|
|
361
|
+
done
|
|
362
|
+
RESP=$(wd POST /session "{\"capabilities\":{\"alwaysMatch\":$CAPS}}")
|
|
363
|
+
SID=$(echo "$RESP" | python3 -c "import json,sys; print(json.load(sys.stdin)['value'].get('sessionId',''))" 2>/dev/null || true)
|
|
364
|
+
fi
|
|
365
|
+
if [ -z "$SID" ]; then echo "session failed: $RESP" >&2; exit 1; fi
|
|
366
|
+
echo "$SID" > "$SID_FILE"
|
|
367
|
+
echo "$RESP" | python3 -c "import json,sys; c=json.load(sys.stdin)['value']['capabilities']; print(c.get('safari:deviceName'), c.get('browserVersion'))"
|
|
368
|
+
echo "session: $SID"
|
|
369
|
+
;;
|
|
370
|
+
|
|
371
|
+
ipad-open) # <story-id-or-url>
|
|
372
|
+
URL=$(page_url "$2")
|
|
373
|
+
BODY=$(python3 -c 'import json,sys; print(json.dumps({"url": sys.argv[1]}))' "$URL")
|
|
374
|
+
wd POST "/session/$(sid)/url" "$BODY" >/dev/null
|
|
375
|
+
echo "opened on iPad: $URL"
|
|
376
|
+
;;
|
|
377
|
+
|
|
378
|
+
ipad-js) # <script> — sync script, `return` its result
|
|
379
|
+
SCRIPT=$(python3 -c 'import json,sys; print(json.dumps({"script": sys.argv[1], "args": []}))' "$2")
|
|
380
|
+
wd POST "/session/$(sid)/execute/sync" "$SCRIPT"
|
|
381
|
+
echo
|
|
382
|
+
;;
|
|
383
|
+
|
|
384
|
+
ipad-viewport) # probe vh/dvh/svh/lvh, safe-area, visualViewport, keyboard state
|
|
385
|
+
SCRIPT=$(python3 -c 'import json,sys; print(json.dumps({"script": sys.argv[1], "args": []}))' "$VIEWPORT_PROBE")
|
|
386
|
+
wd POST "/session/$(sid)/execute/sync" "$SCRIPT" | python3 -m json.tool
|
|
387
|
+
;;
|
|
388
|
+
|
|
389
|
+
ipad-type) # <css-selector> <text> — tap the field and type; opens the real soft keyboard
|
|
390
|
+
EID=$(find_el "$2")
|
|
391
|
+
wd POST "/session/$(sid)/element/$EID/click" '{}' >/dev/null
|
|
392
|
+
BODY=$(python3 -c 'import json,sys; print(json.dumps({"text": sys.argv[1]}))' "$3")
|
|
393
|
+
wd POST "/session/$(sid)/element/$EID/value" "$BODY"
|
|
394
|
+
echo
|
|
395
|
+
;;
|
|
396
|
+
|
|
397
|
+
ipad-tap) # <css-selector>
|
|
398
|
+
EID=$(find_el "$2")
|
|
399
|
+
wd POST "/session/$(sid)/element/$EID/click" '{}'
|
|
400
|
+
echo
|
|
401
|
+
;;
|
|
402
|
+
|
|
403
|
+
ipad-shot) # <out.png> [css-selector] — element screenshot (full-screen endpoint is broken on real devices)
|
|
404
|
+
EID=$(find_el "${3:-html}")
|
|
405
|
+
wd GET "/session/$(sid)/element/$EID/screenshot" \
|
|
406
|
+
| python3 -c "import json,sys,base64; open(sys.argv[1],'wb').write(base64.b64decode(json.load(sys.stdin)['value']))" "$2"
|
|
407
|
+
file "$2"
|
|
408
|
+
;;
|
|
409
|
+
|
|
410
|
+
ipad-end)
|
|
411
|
+
[ -f "$SID_FILE" ] && wd DELETE "/session/$(sid)" >/dev/null && rm -f "$SID_FILE"
|
|
412
|
+
pkill -f "ssh.*-L $DRIVER_PORT:localhost:$DRIVER_PORT" 2>/dev/null || true
|
|
413
|
+
mac 'pkill -x safaridriver 2>/dev/null || true'
|
|
414
|
+
echo "session + tunnel closed"
|
|
415
|
+
;;
|
|
416
|
+
|
|
417
|
+
*)
|
|
418
|
+
sed -n "s/^ \([a-z-]*\)) #\?/\1 /p" "$0"
|
|
419
|
+
echo "state: $STATE_DIR mac host: $MAC_HOST (override: ETHLETE_MAC_HOST)"
|
|
420
|
+
;;
|
|
421
|
+
esac
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#import <AppKit/AppKit.h>
|
|
2
|
+
#import <dlfcn.h>
|
|
3
|
+
|
|
4
|
+
@protocol SimDevice
|
|
5
|
+
- (NSUUID *)UDID;
|
|
6
|
+
- (NSUInteger)state;
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@protocol SimDeviceSet
|
|
10
|
+
- (NSArray<id<SimDevice>> *)devices;
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
@protocol SimServiceContext
|
|
14
|
+
+ (id<SimServiceContext>)sharedServiceContextForDeveloperDir:(NSString *)directory error:(NSError **)error;
|
|
15
|
+
- (id<SimDeviceSet>)defaultDeviceSetWithError:(NSError **)error;
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@protocol SimHIDClient
|
|
19
|
+
- (id<SimHIDClient>)initWithDevice:(id<SimDevice>)device error:(NSError **)error;
|
|
20
|
+
- (void)sendWithMessage:(void *)message
|
|
21
|
+
freeWhenDone:(BOOL)freeWhenDone
|
|
22
|
+
completionQueue:(dispatch_queue_t)queue
|
|
23
|
+
completion:(void (^)(NSError *))completion;
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
typedef void *(*MakeTouch)(CGPoint *, CGPoint *, uint32_t, NSEventType, CGSize, uint32_t);
|
|
27
|
+
|
|
28
|
+
enum {
|
|
29
|
+
SimDeviceBooted = 3,
|
|
30
|
+
IndigoDigitizerTarget = 0x32,
|
|
31
|
+
IndigoLeftEdge = 2,
|
|
32
|
+
IndigoHeaderSize = 0x20,
|
|
33
|
+
IndigoPayloadSize = 0x90,
|
|
34
|
+
IndigoSizeOffset = 0x18,
|
|
35
|
+
IndigoTypeOffset = 0x1c,
|
|
36
|
+
IndigoTouchOffset = 0x10,
|
|
37
|
+
IndigoSingleTouch = 2,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
static void *makeSingleTouch(MakeTouch makeTouch, CGPoint position, NSEventType event) {
|
|
41
|
+
unsigned char *source = makeTouch(&position, NULL, IndigoDigitizerTarget, event, CGSizeMake(1, 1), IndigoLeftEdge);
|
|
42
|
+
if (!source) return NULL;
|
|
43
|
+
|
|
44
|
+
// SimulatorKit's mouse builder emits a multi-touch frame. The single-contact path needs a second payload with indices 1 and 2.
|
|
45
|
+
unsigned char *message = calloc(1, IndigoHeaderSize + 2 * IndigoPayloadSize);
|
|
46
|
+
if (message) {
|
|
47
|
+
memcpy(message, source, IndigoHeaderSize + IndigoPayloadSize);
|
|
48
|
+
const uint32_t payloadSize = IndigoPayloadSize;
|
|
49
|
+
memcpy(message + IndigoSizeOffset, &payloadSize, sizeof(payloadSize));
|
|
50
|
+
message[IndigoTypeOffset] = IndigoSingleTouch;
|
|
51
|
+
unsigned char *secondPayload = message + IndigoHeaderSize + IndigoPayloadSize;
|
|
52
|
+
memcpy(secondPayload, message + IndigoHeaderSize, IndigoPayloadSize);
|
|
53
|
+
const uint32_t contactIndices[] = {1, 2};
|
|
54
|
+
memcpy(secondPayload + IndigoTouchOffset, contactIndices, sizeof(contactIndices));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
free(source);
|
|
58
|
+
return message;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static BOOL sendTouch(id<SimHIDClient> client, MakeTouch makeTouch, CGPoint position, NSEventType event) {
|
|
62
|
+
void *message = makeSingleTouch(makeTouch, position, event);
|
|
63
|
+
if (!message) {
|
|
64
|
+
fputs("edge-back: could not build an Indigo digitizer event\n", stderr);
|
|
65
|
+
return NO;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
dispatch_semaphore_t done = dispatch_semaphore_create(0);
|
|
69
|
+
__block NSError *sendError = nil;
|
|
70
|
+
[client sendWithMessage:message
|
|
71
|
+
freeWhenDone:YES
|
|
72
|
+
completionQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)
|
|
73
|
+
completion:^(NSError *error) {
|
|
74
|
+
sendError = error;
|
|
75
|
+
dispatch_semaphore_signal(done);
|
|
76
|
+
}];
|
|
77
|
+
if (dispatch_semaphore_wait(done, dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC))) {
|
|
78
|
+
fputs("edge-back: SimulatorKit did not acknowledge the touch\n", stderr);
|
|
79
|
+
return NO;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (sendError) NSLog(@"edge-back: %@", sendError);
|
|
83
|
+
return sendError == nil;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
int main(int argc, char **argv) {
|
|
87
|
+
@autoreleasepool {
|
|
88
|
+
if (argc != 3) return 2;
|
|
89
|
+
NSUUID *udid = [[NSUUID alloc] initWithUUIDString:@(argv[1])];
|
|
90
|
+
if (!udid) {
|
|
91
|
+
fputs("edge-back: expected a simulator UDID\n", stderr);
|
|
92
|
+
return 2;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
NSString *developerDir = @(argv[2]);
|
|
96
|
+
if (!dlopen("/Library/Developer/PrivateFrameworks/CoreSimulator.framework/CoreSimulator", RTLD_NOW)) {
|
|
97
|
+
fprintf(stderr, "edge-back: %s\n", dlerror());
|
|
98
|
+
return 1;
|
|
99
|
+
}
|
|
100
|
+
NSString *kitPath = [developerDir stringByAppendingPathComponent:
|
|
101
|
+
@"Library/PrivateFrameworks/SimulatorKit.framework/SimulatorKit"];
|
|
102
|
+
void *kit = dlopen(kitPath.fileSystemRepresentation, RTLD_NOW);
|
|
103
|
+
if (!kit) {
|
|
104
|
+
fprintf(stderr, "edge-back: %s\n", dlerror());
|
|
105
|
+
return 1;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
MakeTouch makeTouch = dlsym(kit, "IndigoHIDMessageForMouseNSEvent");
|
|
109
|
+
Class<SimServiceContext> contextClass = NSClassFromString(@"SimServiceContext");
|
|
110
|
+
Class clientClass = NSClassFromString(@"SimulatorKit.SimDeviceLegacyHIDClient");
|
|
111
|
+
if (!makeTouch ||
|
|
112
|
+
![(Class)contextClass respondsToSelector:@selector(sharedServiceContextForDeveloperDir:error:)] ||
|
|
113
|
+
![clientClass instancesRespondToSelector:@selector(initWithDevice:error:)] ||
|
|
114
|
+
![clientClass instancesRespondToSelector:@selector(sendWithMessage:freeWhenDone:completionQueue:completion:)]) {
|
|
115
|
+
fputs("edge-back: this Xcode does not expose the SimulatorKit Indigo HID API\n", stderr);
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
NSError *error = nil;
|
|
120
|
+
id<SimServiceContext> context = [contextClass sharedServiceContextForDeveloperDir:developerDir error:&error];
|
|
121
|
+
id<SimDeviceSet> devices = [context defaultDeviceSetWithError:&error];
|
|
122
|
+
if (!devices) {
|
|
123
|
+
NSLog(@"edge-back: could not load the simulator device set (%@)", error);
|
|
124
|
+
return 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
id<SimDevice> target = nil;
|
|
128
|
+
for (id<SimDevice> device in devices.devices) {
|
|
129
|
+
if ([device.UDID isEqual:udid] && device.state == SimDeviceBooted) {
|
|
130
|
+
target = device;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!target) {
|
|
135
|
+
NSLog(@"edge-back: simulator %@ is not booted", udid);
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
id<SimHIDClient> client = [(id<SimHIDClient>)[clientClass alloc] initWithDevice:target error:&error];
|
|
140
|
+
if (!client) {
|
|
141
|
+
NSLog(@"edge-back: could not connect to simulator %@ (%@)", udid, error);
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const int steps = 24;
|
|
146
|
+
CGPoint position = CGPointMake(0, 0.5);
|
|
147
|
+
BOOL delivered = YES;
|
|
148
|
+
for (int step = 0; step <= steps; step++) {
|
|
149
|
+
position.x = 0.8 * step / steps;
|
|
150
|
+
if (!sendTouch(client, makeTouch, position, NSEventTypeLeftMouseDown)) {
|
|
151
|
+
delivered = NO;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
[NSThread sleepForTimeInterval:0.015];
|
|
155
|
+
}
|
|
156
|
+
BOOL released = sendTouch(client, makeTouch, position, NSEventTypeLeftMouseUp);
|
|
157
|
+
return delivered && released ? 0 : 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Lists with URL state use `defineQueryForm`
|
|
2
|
+
|
|
3
|
+
The `ethlete-query` skill now says every filtered, searched, sorted or paged list uses
|
|
4
|
+
`defineQueryForm`, not `injectQueryParams()`, `router.navigate` and a draft signal wired by hand.
|
|
5
|
+
Moving a list is a rewrite of its component, so it happens when someone next edits that list. The
|
|
6
|
+
skill says how to keep the old URL working when you do.
|
|
7
|
+
|
|
8
|
+
No code changes in this task. To see how many components still wire their params by hand, count
|
|
9
|
+
the files that both read and write query params:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
grep -rlE 'injectQueryParams?\(|queryParamMap|snapshot\.queryParams|\.queryParams\.(pipe|subscribe)\(' apps libs --include='*.ts' |
|
|
13
|
+
xargs grep -lE '\bqueryParams(Handling)?\b' | wc -l
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Done when
|
|
17
|
+
|
|
18
|
+
- The count is in your final message, or in the report you give the developer.
|
|
19
|
+
|
|
20
|
+
Then delete this task file.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Compare the workspace with the Nx layout rule
|
|
2
|
+
|
|
3
|
+
`@ethlete/agent-rules` now ships an `nx-layout` rule for Nx workspaces: thin apps, feature code in
|
|
4
|
+
one `libs/domain/<app>` lib per app with a folder per feature, shared `queries`, `types`, `uikit`, `theme` and `env` libs, aliases that
|
|
5
|
+
mirror the path, and one `scope:*` tag per project. New code follows it.
|
|
6
|
+
|
|
7
|
+
This is a recommendation, not a rewrite. Moving projects changes import paths, project names, tags
|
|
8
|
+
and CI caches across the whole repo, and the rule itself says not to restructure an existing
|
|
9
|
+
workspace unless the team asks for it.
|
|
10
|
+
|
|
11
|
+
## What to decide
|
|
12
|
+
|
|
13
|
+
1. Read the rule (in `AGENTS.md`, or under `.claude/rules/ethlete/`). If it is missing, run
|
|
14
|
+
`ethlete-agents sync` with this repo's package manager (`yarn`, `pnpm exec` or `npx`).
|
|
15
|
+
2. List where the workspace deviates: feature code inside `apps/`, queries or themes inside an app,
|
|
16
|
+
`feature/ui/data-access/util` folders, aliases that do not mirror the path, missing `scope:*` tags.
|
|
17
|
+
3. Decide per deviation: move it now, move it when that area is next touched, or keep it.
|
|
18
|
+
4. Keep what you decided where an agent reads it, so it stops flagging it: in `AGENTS.md` above the
|
|
19
|
+
`<!-- ethlete:agent-rules:start -->` line or below `<!-- ethlete:agent-rules:end -->`, or in the
|
|
20
|
+
repo's `CONTEXT.md` or an ADR. Never between the two markers: `ethlete-agents sync` rewrites that
|
|
21
|
+
block and drops the edit. If `AGENTS.md` holds nothing but the block, add the decisions above it.
|
|
22
|
+
|
|
23
|
+
An agent may prepare the list in step 2. It must not move a project without that decision.
|
|
24
|
+
|
|
25
|
+
## Done when
|
|
26
|
+
|
|
27
|
+
- Each deviation from step 2 has a decision, recorded as step 4 says.
|
|
28
|
+
|
|
29
|
+
Then delete this task file.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Use the SDK component where one exists
|
|
2
|
+
|
|
3
|
+
The `ethlete-sdk-docs` skill now lists every component domain, with a table that maps common needs
|
|
4
|
+
to them ("Check this list before you build any UI by hand"). Apps built their own bar charts,
|
|
5
|
+
avatars and progress bars because the old list did not name them. Replacing one restyles its view,
|
|
6
|
+
so it happens when someone next edits that view, not in this task.
|
|
7
|
+
|
|
8
|
+
When you do replace one, check every feature of the hand-built one against the SDK component's
|
|
9
|
+
inputs, slots and `--et-*` tokens first, and keep the hand-built one where a feature has no
|
|
10
|
+
counterpart. Known gaps:
|
|
11
|
+
|
|
12
|
+
- `et-bar-chart` renders every category label and only truncates it, and has no slot for a title,
|
|
13
|
+
a note or an empty state.
|
|
14
|
+
- `et-avatar` derives initials from `name` only, and takes its colours from a colour theme only.
|
|
15
|
+
|
|
16
|
+
No code changes in this task. To count the candidates, skipping hits that already use an `et-`
|
|
17
|
+
element:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
grep -rlE 'bar-?chart|bar-?graph|avatar|initials|progress-?bar' apps libs --include='*.html' --include='*.ts' | xargs grep -LE '<et-(bar-chart|avatar|progress-bar)' | wc -l
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Done when
|
|
24
|
+
|
|
25
|
+
- The count is in your final message, or in the report you give the developer.
|
|
26
|
+
|
|
27
|
+
Then delete this task file.
|