thuthi-plugin 0.0.0-stage → 0.1.0
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/.claude-plugin/marketplace.json +55 -0
- package/README.md +13 -2
- package/bin/parallel-browser.js +109 -0
- package/extension/background.js +1329 -0
- package/extension/config.json +1 -0
- package/extension/guard.js +44 -0
- package/extension/manifest.json +10 -0
- package/extension/overlay.js +104 -0
- package/extension/popup.html +34 -0
- package/extension/popup.js +39 -0
- package/extension-reloader/manifest.json +13 -0
- package/extension-reloader/sw.js +17 -0
- package/package.json +13 -4
- package/plugins/thuthi/.claude-plugin/plugin.json +8 -0
- package/plugins/thuthi/context.md +3 -0
- package/plugins/thuthi/hooks/hooks.json +15 -0
- package/plugins/thuthi/skills/setup/SKILL.md +55 -0
- package/plugins/thuthi/skills/setup/scripts/doctor.py +249 -0
- package/plugins/thuthi/skills/setup/scripts/selftest.py +188 -0
- package/plugins/thuthi/tools/claude-switch/claude_switch.py +8 -0
- package/plugins/thuthi/tools/legacy_launcher.py +65 -0
- package/plugins/thuthi/tools/statusline/statusline.py +8 -0
- package/plugins/thuthi-accounts/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-accounts/bin/claude-switch +5 -0
- package/plugins/thuthi-accounts/bin/claude-switch.cmd +4 -0
- package/plugins/thuthi-accounts/hooks/hooks.json +15 -0
- package/plugins/thuthi-accounts/lib/tls.py +68 -0
- package/plugins/thuthi-accounts/lib/usage_store.py +150 -0
- package/plugins/thuthi-accounts/setup_check.py +21 -0
- package/plugins/thuthi-accounts/skills/claude-switch/SKILL.md +48 -0
- package/plugins/thuthi-accounts/tools/claude-switch/claude-switch-tui.py +397 -0
- package/plugins/thuthi-accounts/tools/claude-switch/claude_switch.py +1204 -0
- package/plugins/thuthi-accounts/tools/claude-switch/credstore.py +417 -0
- package/plugins/thuthi-accounts/tools/claude-switch/install.py +301 -0
- package/plugins/thuthi-accounts/tools/claude-switch/tests/selftest.py +491 -0
- package/plugins/thuthi-accounts/tools/statusline/statusline.py +212 -0
- package/plugins/thuthi-agenda-picker/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-agenda-picker/context.md +3 -0
- package/plugins/thuthi-agenda-picker/hooks/hooks.json +15 -0
- package/plugins/thuthi-agenda-picker/lib/pbpage.py +397 -0
- package/plugins/thuthi-agenda-picker/setup_check.py +18 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/SKILL.md +280 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/design-rules.md +110 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/diagram/base.css +33 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/agenda.json +146 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/A-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/A-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/B-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/B-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/C-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/C-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/base.css +33 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/name-B.html +15 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/now-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/now-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/picker.py +1286 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/selftest.py +771 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/shot.py +117 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/template.html +1029 -0
- package/plugins/thuthi-arch-diagram/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-arch-diagram/lib/pbpage.py +397 -0
- package/plugins/thuthi-arch-diagram/lib/tls.py +68 -0
- package/plugins/thuthi-arch-diagram/setup_check.py +10 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/SKILL.md +125 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/references/design-rules.md +110 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/references/example-shop.py +167 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/check.py +194 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/diagramkit.py +682 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/interact_test.py +115 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/render.py +113 -0
- package/plugins/thuthi-browser/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-browser/context.md +3 -0
- package/plugins/thuthi-browser/hooks/hooks.json +15 -0
- package/plugins/thuthi-browser/lib/pbpage.py +397 -0
- package/plugins/thuthi-browser/setup_check.py +93 -0
- package/plugins/thuthi-browser/skills/parallel-browser/SKILL.md +271 -0
- package/plugins/thuthi-browser/skills/parallel-browser/references/api.md +243 -0
- package/plugins/thuthi-browser/skills/parallel-browser/references/install.md +106 -0
- package/plugins/thuthi-demo-video/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-demo-video/lib/pbpage.py +397 -0
- package/plugins/thuthi-demo-video/setup_check.py +14 -0
- package/plugins/thuthi-demo-video/skills/demo-video/SKILL.md +261 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/caption.html +16 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/cursor.js +132 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/demo_video.py +2416 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/example_scenario.py +97 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/frame.html +95 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/overlay.js +129 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/title.html +30 -0
- package/plugins/thuthi-no-more-slop/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-no-more-slop/setup_check.py +10 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/LICENSE +21 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/SKILL.md +235 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/SOURCE.txt +1 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/agents/openai.yaml +6 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/examples.md +289 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/tokens.md +46 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/unslop-fallback.md +36 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/scripts/count_tells.py +426 -0
- package/plugins/thuthi-orca/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-orca/context.md +5 -0
- package/plugins/thuthi-orca/hooks/hooks.json +18 -0
- package/plugins/thuthi-orca/hooks/orca-team-grid.ts +21 -0
- package/plugins/thuthi-orca/setup_check.py +12 -0
- package/plugins/thuthi-orca/skills/orca-new-work/SKILL.md +492 -0
- package/plugins/thuthi-orca/tools/orca-team-grid/bin/tmux +338 -0
- package/plugins/thuthi-orca/tools/orca-team-grid/tests/selftest.py +299 -0
- package/runtime/client.js +69 -0
- package/runtime/daemon.js +503 -0
- package/runtime/focus-monitor.js +53 -0
- package/runtime/keys.js +86 -0
- package/runtime/owner.js +64 -0
- package/runtime/recorder.js +267 -0
- package/runtime/relay.js +95 -0
- package/runtime/session.js +1599 -0
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""picker.py 와 template.html 을 실제 브라우저(parallel-browser) 로 끝까지 돌려 본다.
|
|
3
|
+
|
|
4
|
+
python3 selftest.py [안건폴더] [--shots /tmp/agenda-shots]
|
|
5
|
+
|
|
6
|
+
안건폴더(기본 references/example) 를 임시 폴더에 복사해 serve (독립 프로세스) + wait 를 띄우고, 대화에서 정한 안 미리 고르기 ·
|
|
7
|
+
라이트/다크 전환 · 바닥 카드에서 바로 고르기 · 안건 보기(머리 한 줄 · 반반 · 그림 높이 맞춤 · 그림 짝 · 설명 띠 + 펼치기 · 양쪽 같이 확대) · 고르기 · 메모 · 새로고침 유지 ·
|
|
8
|
+
보내기 · wait 출력 · 보안 검사(토큰 · Host) · 정적 사본 · 영상 그림(Range · 재생 · 확대) · 안건 변경 배너 · check 경고를 확인한다. 이어서 가짜 orca 로 Orca 터미널
|
|
9
|
+
전달 (에이전트인지 확인 · 한 줄 · 탭 닫기 · 셸이면 넣지 않음) 과 요청 없을 때 서버가 스스로 끝나는 것을 본다.
|
|
10
|
+
--shots 를 주면 바닥 · 안건 보기 · 확대 · 펼친 띠 · 영상 확대를 PNG 로 남긴다 (Read 로 열어 본다).
|
|
11
|
+
exit 0 = 전부 통과. 브라우저는 parallel-browser (사용자 Chrome · Edge 의 에이전트 창, 포커스를 가져가지 않는다) 로 몰고,
|
|
12
|
+
화면은 1360×900 · 라이트 테마로 고정한다. 끝나면 띄운 탭 · 세션을 닫는다.
|
|
13
|
+
"""
|
|
14
|
+
import functools
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
import shutil
|
|
18
|
+
import subprocess
|
|
19
|
+
import sys
|
|
20
|
+
import tempfile
|
|
21
|
+
import time
|
|
22
|
+
import urllib.error
|
|
23
|
+
import threading
|
|
24
|
+
import urllib.request
|
|
25
|
+
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "lib"))
|
|
29
|
+
from pbpage import Browser # noqa: E402
|
|
30
|
+
|
|
31
|
+
HERE = Path(__file__).resolve().parent
|
|
32
|
+
PICKER = HERE / "picker.py"
|
|
33
|
+
PY = "/usr/bin/python3" if os.path.exists("/usr/bin/python3") else sys.executable # 시스템 3.9 호환까지 본다
|
|
34
|
+
# 바깥 Orca 세션의 값이 섞이면 진짜 Claude 터미널에 보내기가 들어간다. 검사는 늘 이 값들을 지운 환경에서 시작한다.
|
|
35
|
+
# 바깥 Orca 와 이 Claude 세션의 인박스 소켓 변수는 지운다 (검사가 진짜 터미널 · 세션에 아무것도 넣지 않게)
|
|
36
|
+
ORCA_VARS = ("TERM_PROGRAM", "ORCA_TERMINAL_HANDLE", "ORCA_WORKTREE_ID", "AGENDA_PICKER_ORCA",
|
|
37
|
+
"CLAUDE_CODE_MESSAGING_SOCKET", "CLAUDE_CODE_MESSAGING_TOKEN", "CLAUDE_CODE_SESSION_ID")
|
|
38
|
+
BASE_ENV = {k: v for k, v in os.environ.items() if k not in ORCA_VARS}
|
|
39
|
+
|
|
40
|
+
FAKE_ORCA = r'''#!/usr/bin/env python3
|
|
41
|
+
import json, os, sys
|
|
42
|
+
args = sys.argv[1:]
|
|
43
|
+
with open(os.environ["FAKE_ORCA_LOG"], "a") as f:
|
|
44
|
+
f.write(json.dumps(args, ensure_ascii=False) + "\n")
|
|
45
|
+
res = {}
|
|
46
|
+
if args[:2] == ["terminal", "show"]:
|
|
47
|
+
who = open(os.environ["FAKE_ORCA_ID"]).read().strip()
|
|
48
|
+
res = {"terminal": {"handle": args[args.index("--terminal") + 1], "agentIdentity": who or None}}
|
|
49
|
+
if args[:2] == ["terminal", "send"] and os.path.exists(os.environ["FAKE_ORCA_ID"] + ".delay"):
|
|
50
|
+
import time; time.sleep(float(open(os.environ["FAKE_ORCA_ID"] + ".delay").read())) # 진짜 send 도 몇 초 걸린다
|
|
51
|
+
print(json.dumps({"ok": True, "result": res}))
|
|
52
|
+
'''
|
|
53
|
+
|
|
54
|
+
fails = []
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def check(ok, msg):
|
|
58
|
+
print((" ok " if ok else " FAIL ") + msg)
|
|
59
|
+
if not ok:
|
|
60
|
+
fails.append(msg)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def wait_for(fn, timeout=6.0, step=0.1):
|
|
64
|
+
end = time.time() + timeout
|
|
65
|
+
while time.time() < end:
|
|
66
|
+
v = fn()
|
|
67
|
+
if v:
|
|
68
|
+
return v
|
|
69
|
+
time.sleep(step)
|
|
70
|
+
return fn()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def http(url, method="GET", headers=None, body=None):
|
|
74
|
+
req = urllib.request.Request(url, method=method, headers=headers or {}, data=body)
|
|
75
|
+
try:
|
|
76
|
+
with urllib.request.urlopen(req, timeout=3) as r:
|
|
77
|
+
return r.status
|
|
78
|
+
except urllib.error.HTTPError as e:
|
|
79
|
+
return e.code
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def serve(d, env=None, *extra):
|
|
83
|
+
"""serve 는 서버를 떼어 내고 바로 끝나야 한다. (URL, 서버 pid) 를 돌려준다."""
|
|
84
|
+
t0 = time.time()
|
|
85
|
+
r = subprocess.run([PY, str(PICKER), "serve", str(d), *extra], capture_output=True, text=True, timeout=20, env=env or BASE_ENV)
|
|
86
|
+
url = next((ln.split(" ", 1)[1].strip() for ln in r.stdout.splitlines() if ln.startswith("URL: ")), None)
|
|
87
|
+
pid = (json.loads((d / ".picker" / "server.json").read_text()) if url else {}).get("pid", 0)
|
|
88
|
+
return url, pid, time.time() - t0, r
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def static_server(d):
|
|
92
|
+
"""정적 사본(index.html) 을 picker 서버 없이 여는 서버. 확장은 file:// 을 못 열 수 있어 http 로 연다."""
|
|
93
|
+
class Quiet(SimpleHTTPRequestHandler):
|
|
94
|
+
def log_message(self, *a):
|
|
95
|
+
pass
|
|
96
|
+
h = functools.partial(Quiet, directory=str(d))
|
|
97
|
+
srv = ThreadingHTTPServer(("127.0.0.1", 0), h)
|
|
98
|
+
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
|
99
|
+
return srv, f"http://127.0.0.1:{srv.server_address[1]}/index.html"
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def alive(pid):
|
|
103
|
+
try:
|
|
104
|
+
os.kill(pid, 0)
|
|
105
|
+
return True
|
|
106
|
+
except OSError:
|
|
107
|
+
return False
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def check_cli(d):
|
|
111
|
+
"""picker.py check: 옛 방식 라이트/다크 그림 경고, decided 오류."""
|
|
112
|
+
d2 = d.parent / "check"
|
|
113
|
+
shutil.copytree(d, d2)
|
|
114
|
+
sp = json.loads((d2 / "agenda.json").read_text())
|
|
115
|
+
ag = sp["agendas"][0]
|
|
116
|
+
f = sorted(x for x in (d2 / "shots").iterdir() if x.is_file())[0].relative_to(d2).as_posix() # 어느 안건 폴더든 있는 그림
|
|
117
|
+
ag["options"][0]["shots"] = [{"src": f, "caption": "다크"}, {"src": f, "caption": "라이트"}]
|
|
118
|
+
(d2 / "agenda.json").write_text(json.dumps(sp, ensure_ascii=False))
|
|
119
|
+
r = subprocess.run([PY, str(PICKER), "check", str(d2)], capture_output=True, text=True)
|
|
120
|
+
check(r.returncode == 0 and "한 항목으로 묶으면" in r.stdout, "check: 라이트 · 다크를 따로 넣으면 묶으라고 경고")
|
|
121
|
+
ag["decided"] = "없는안"
|
|
122
|
+
(d2 / "agenda.json").write_text(json.dumps(sp, ensure_ascii=False))
|
|
123
|
+
r = subprocess.run([PY, str(PICKER), "check", str(d2)], capture_output=True, text=True)
|
|
124
|
+
check(r.returncode == 1 and "decided" in r.stdout, "check: decided 가 없는 안 id 면 오류")
|
|
125
|
+
del ag["decided"]
|
|
126
|
+
(d2 / "shots" / "clip.mp4").write_bytes(b"")
|
|
127
|
+
ag["options"][0]["shots"] = [{"light": f, "dark": "shots/clip.mp4"}]
|
|
128
|
+
(d2 / "agenda.json").write_text(json.dumps(sp, ensure_ascii=False))
|
|
129
|
+
r = subprocess.run([PY, str(PICKER), "check", str(d2)], capture_output=True, text=True)
|
|
130
|
+
check(r.returncode == 1 and "한쪽만 영상" in r.stdout, "check: light · dark 중 한쪽만 영상이면 오류")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def make_clip(path, negate=False):
|
|
134
|
+
"""2초짜리 시험 영상 (ffmpeg testsrc2). 다크 쪽은 색을 뒤집어 라이트와 구별한다."""
|
|
135
|
+
vf = ["-vf", "negate"] if negate else []
|
|
136
|
+
r = subprocess.run(["ffmpeg", "-v", "error", "-y", "-f", "lavfi", "-i", "testsrc2=size=640x400:rate=24", "-t", "2", *vf,
|
|
137
|
+
"-pix_fmt", "yuv420p", "-c:v", "libx264", "-movflags", "+faststart", str(path)], capture_output=True, text=True)
|
|
138
|
+
return r.returncode == 0
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def check_video(b, vd, shots):
|
|
142
|
+
"""영상 그림: 서버의 Range 응답, 바닥 카드는 첫 장면만, 안건 보기는 소리 없이 반복 재생 · 테마 따라 바뀜 · 양쪽 같이 확대."""
|
|
143
|
+
(vd / "shots").mkdir(parents=True)
|
|
144
|
+
if not shutil.which("ffmpeg"):
|
|
145
|
+
print(" -- ffmpeg 가 없어 영상 검사를 건너뛴다 (thuthi:setup 으로 설치)")
|
|
146
|
+
return None
|
|
147
|
+
if not (make_clip(vd / "shots" / "v-light.mp4") and make_clip(vd / "shots" / "v-dark.mp4", True)):
|
|
148
|
+
check(False, "ffmpeg 로 시험 영상을 만든다")
|
|
149
|
+
return None
|
|
150
|
+
clip = {"light": "shots/v-light.mp4", "dark": "shots/v-dark.mp4"}
|
|
151
|
+
(vd / "agenda.json").write_text(json.dumps({"title": "영상 검사", "agendas": [{
|
|
152
|
+
"id": "vid", "title": "움직이는 화면", "current": {"title": "지금", "shots": [clip]},
|
|
153
|
+
"options": [{"id": "A", "title": "영상 안", "shots": [clip]}, {"id": "B", "title": "그림 없는 안"}]}]}, ensure_ascii=False))
|
|
154
|
+
url, _, _, _ = serve(vd)
|
|
155
|
+
check(bool(url), "영상 안건 폴더도 serve 된다")
|
|
156
|
+
if not url:
|
|
157
|
+
return vd
|
|
158
|
+
|
|
159
|
+
size = (vd / "shots" / "v-light.mp4").stat().st_size
|
|
160
|
+
def get(rng):
|
|
161
|
+
req = urllib.request.Request(url + "shots/v-light.mp4", headers={"Range": rng} if rng else {})
|
|
162
|
+
try:
|
|
163
|
+
with urllib.request.urlopen(req, timeout=3) as r:
|
|
164
|
+
return r.status, r.headers.get("Content-Range"), r.headers.get("Content-Type"), len(r.read())
|
|
165
|
+
except urllib.error.HTTPError as e:
|
|
166
|
+
return e.code, e.headers.get("Content-Range"), None, 0
|
|
167
|
+
check(get("bytes=0-1") == (206, f"bytes 0-1/{size}", "video/mp4", 2), "Range 요청이면 206 으로 그 구간만 (Safari 영상 재생)")
|
|
168
|
+
check(get("bytes=-10") == (206, f"bytes {size - 10}-{size - 1}/{size}", "video/mp4", 10), "끝에서 n 바이트 Range")
|
|
169
|
+
check(get("bytes=0-")[0] == 206 and get("bytes=0-")[3] == size, "열린 Range 는 끝까지")
|
|
170
|
+
check(get(f"bytes={size}-")[:2] == (416, f"bytes */{size}"), "파일 밖 Range 는 416")
|
|
171
|
+
check(get(None)[0] == 200 and get(None)[3] == size, "Range 가 없으면 200 으로 전체")
|
|
172
|
+
|
|
173
|
+
pg = b.new_page(viewport=(1360, 900))
|
|
174
|
+
pg.goto(url)
|
|
175
|
+
pg.wait_for_timeout(600)
|
|
176
|
+
vstate = lambda sel_: pg.evaluate(f"""(v => v && v.tagName === 'VIDEO' ? {{ paused: v.paused, t: v.currentTime, muted: v.muted, loop: v.loop,
|
|
177
|
+
ready: v.readyState, w: v.videoWidth, src: v.getAttribute('src'), l: v.dataset.l, d: v.dataset.d }} : null)(document.querySelector({json.dumps(sel_)}))""")
|
|
178
|
+
check(pg.locator(".card video, .card img").count() == 0, "바닥 카드에는 그림 · 영상이 없다 (안 목록만)")
|
|
179
|
+
pg.locator(".card .card-head").first.click()
|
|
180
|
+
pg.wait_for_timeout(1200)
|
|
181
|
+
r1 = vstate("#cmp-right .pane-shot .media")
|
|
182
|
+
ok = wait_for(lambda: (vstate("#cmp-right .pane-shot .media") or {}).get("t", 0) > 0.2, 4)
|
|
183
|
+
check(bool(r1) and not r1["paused"] and r1["muted"] and r1["loop"] and bool(ok), f"안건 보기의 영상은 소리 없이 반복 재생 ({r1})")
|
|
184
|
+
check(bool(vstate("#cmp-left .pane-shot .media")), "지금 쪽도 영상")
|
|
185
|
+
pg.locator('#cmp [data-set-theme="dark"]').click()
|
|
186
|
+
ok = wait_for(lambda: (lambda v: v and v["src"] == v["d"] and not v["paused"])(vstate("#cmp-right .pane-shot .media")), 4)
|
|
187
|
+
check(bool(ok), "다크로 바꾸면 다크 영상으로 바뀌고 계속 재생")
|
|
188
|
+
pg.locator('#cmp [data-set-theme="light"]').click()
|
|
189
|
+
pg.wait_for_timeout(300)
|
|
190
|
+
r = pg.evaluate("(e => (r => [r.x, r.y, r.width, r.height])(e.getBoundingClientRect()))(document.querySelector('#cmp-right .pane-shot .media'))")
|
|
191
|
+
check(r[2] > 300, f"영상이 칸에 맞게 커진다 ({r[2]:.0f}px)")
|
|
192
|
+
pg.mouse.click(r[0] + r[2] * 0.6, r[1] + r[3] * 0.5)
|
|
193
|
+
pg.wait_for_timeout(200)
|
|
194
|
+
t = pg.evaluate("[...document.querySelectorAll('.pane-shot .media')].map(v => getComputedStyle(v).transform)")
|
|
195
|
+
check(len(t) == 2 and all(x.startswith("matrix(2,") for x in t), f"영상을 누르면 양쪽이 같이 2배 ({t})")
|
|
196
|
+
if shots:
|
|
197
|
+
pg.screenshot(path=str(shots / "7-video-zoom.png"))
|
|
198
|
+
pg.keyboard.press("Escape")
|
|
199
|
+
pg.wait_for_timeout(150)
|
|
200
|
+
check(set(pg.evaluate("[...document.querySelectorAll('.pane-shot .media')].map(v => getComputedStyle(v).transform)")) == {"none"},
|
|
201
|
+
"Esc 로 영상 확대도 풀린다")
|
|
202
|
+
errs = pg.errors()
|
|
203
|
+
check(not errs, f"영상 페이지 JS 오류 없음 {errs}")
|
|
204
|
+
pg.close()
|
|
205
|
+
return vd
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def steps_of(ag, op):
|
|
209
|
+
"""페이지와 같은 규칙으로 (지금 그림 있음, 안 그림 있음) 짝 목록을 만든다."""
|
|
210
|
+
def caps(b):
|
|
211
|
+
return [("" if isinstance(s, str) else str(s.get("caption") or "")) for s in ((b or {}).get("shots") or [])]
|
|
212
|
+
L, R = caps(ag.get("current")), caps(op)
|
|
213
|
+
if L + R and all(L + R):
|
|
214
|
+
names = []
|
|
215
|
+
for c in L + R:
|
|
216
|
+
if c not in names:
|
|
217
|
+
names.append(c)
|
|
218
|
+
return [(c in L, c in R) for c in names]
|
|
219
|
+
return [(i < len(L), i < len(R)) for i in range(max(len(L), len(R), 1))]
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def main():
|
|
223
|
+
for _f in (sys.stdout, sys.stderr): # Windows 콘솔(cp949)에서 ✓ · 한글을 찍다 죽지 않게
|
|
224
|
+
try:
|
|
225
|
+
_f.reconfigure(encoding="utf-8", errors="replace")
|
|
226
|
+
except (AttributeError, ValueError):
|
|
227
|
+
pass
|
|
228
|
+
args = sys.argv[1:]
|
|
229
|
+
shots = None
|
|
230
|
+
if "--shots" in args:
|
|
231
|
+
i = args.index("--shots")
|
|
232
|
+
shots = Path(args[i + 1])
|
|
233
|
+
shots.mkdir(parents=True, exist_ok=True)
|
|
234
|
+
del args[i:i + 2]
|
|
235
|
+
src = Path(args[0]) if args else HERE.parent / "references" / "example"
|
|
236
|
+
tmp = Path(tempfile.mkdtemp(prefix="agenda-selftest-"))
|
|
237
|
+
d = tmp / "agenda"
|
|
238
|
+
shutil.copytree(src, d, ignore=shutil.ignore_patterns(".picker", "selections.json", "submissions", "index.html"))
|
|
239
|
+
spec = json.loads((d / "agenda.json").read_text())
|
|
240
|
+
ag1, ag2 = spec["agendas"][0], spec["agendas"][-1]
|
|
241
|
+
op1, op2 = ag1["options"][0], ag2["options"][-1]
|
|
242
|
+
pre = {a["id"]: a["decided"] for a in spec["agendas"] if a.get("decided")}
|
|
243
|
+
print(f"폴더: {d}")
|
|
244
|
+
check_cli(d)
|
|
245
|
+
|
|
246
|
+
# serve 는 서버를 독립 프로세스(새 세션)로 떼어 내고 바로 끝난다
|
|
247
|
+
url, spid, took, r = serve(d)
|
|
248
|
+
check(bool(url) and r.returncode == 0, f"serve 가 URL 을 찍고 끝난다 ({url}, {took:.1f}초)")
|
|
249
|
+
check(alive(spid) and os.getpgid(spid) == spid and os.getsid(spid) == spid, "서버는 새 세션의 독립 프로세스다 (setsid)")
|
|
250
|
+
check("wait" in r.stdout and "Orca 터미널" not in r.stdout, "Orca 밖이면 보내기는 wait 가 받는다고 알린다")
|
|
251
|
+
url2, spid2, _, r2 = serve(d)
|
|
252
|
+
check(url2 == url and spid2 == spid and "이미 떠 있다" in r2.stdout, "다시 serve 하면 떠 있는 서버를 그대로 쓴다")
|
|
253
|
+
waiter = subprocess.Popen([PY, str(PICKER), "wait", str(d)], stdout=subprocess.PIPE, text=True, env=BASE_ENV)
|
|
254
|
+
od = vd = None
|
|
255
|
+
|
|
256
|
+
errs = []
|
|
257
|
+
grab = lambda page, tag="": errs.extend(f"{tag}{e}" for e in page.errors()) # 새로 읽기 전에 페이지 JS 오류를 모은다
|
|
258
|
+
try:
|
|
259
|
+
with Browser("agenda-picker selftest") as b:
|
|
260
|
+
pg = b.new_page(viewport=(1360, 900))
|
|
261
|
+
pg.goto(url)
|
|
262
|
+
pg.wait_for_timeout(300)
|
|
263
|
+
|
|
264
|
+
n = len(spec["agendas"])
|
|
265
|
+
sel = d / "selections.json"
|
|
266
|
+
check(pg.locator(".card").count() == n, f"바닥에 안건 카드 {n}개")
|
|
267
|
+
check(pg.inner_text("#progress").startswith(f"결정 {len(pre)} / {n}"), f"진행 표시 {len(pre)} (대화에서 정한 안은 미리 골라져 있다)")
|
|
268
|
+
if pre:
|
|
269
|
+
aid, oid = next(iter(pre.items()))
|
|
270
|
+
card = pg.locator(f'.card[data-ag="{aid}"]').inner_text()
|
|
271
|
+
check("대화에서 정함" in card, "미리 고른 안건 카드에 '대화에서 정함'")
|
|
272
|
+
ok = wait_for(lambda: sel.exists() and json.loads(sel.read_text())["picks"].get(aid) == oid)
|
|
273
|
+
check(bool(ok), "미리 고른 안이 selections.json 에도 써진다")
|
|
274
|
+
wait_for(lambda: "저장됨" in pg.inner_text("#save"), 4)
|
|
275
|
+
check("저장됨" in pg.inner_text("#save"), "저장 상태 표시")
|
|
276
|
+
if shots:
|
|
277
|
+
pg.screenshot(path=str(shots / "1-base.png"), full_page=True)
|
|
278
|
+
|
|
279
|
+
# 라이트 / 다크 전환: 페이지와 그림이 같이 바뀐다
|
|
280
|
+
theme = lambda: pg.evaluate("document.documentElement.dataset.theme")
|
|
281
|
+
check(theme() == "light", "처음 테마는 시스템 설정 (검사는 라이트로 고정)")
|
|
282
|
+
pg.locator('.bar [data-set-theme="dark"]').click()
|
|
283
|
+
pg.wait_for_timeout(100)
|
|
284
|
+
check(theme() == "dark", "다크로 바꾸면 페이지가 다크로")
|
|
285
|
+
grab(pg)
|
|
286
|
+
pg.reload()
|
|
287
|
+
pg.wait_for_timeout(300)
|
|
288
|
+
check(theme() == "dark", "고른 테마는 새로고침해도 남는다")
|
|
289
|
+
if shots:
|
|
290
|
+
pg.screenshot(path=str(shots / "1b-base-dark.png"), full_page=True)
|
|
291
|
+
pg.locator('.bar [data-set-theme="light"]').click()
|
|
292
|
+
|
|
293
|
+
# 바닥 카드: 안마다 한 줄, 누르면 그 자리에서 고르고 다시 누르면 푼다. 줄 끝 링크는 그 안을 연 안건 보기로
|
|
294
|
+
c0 = f'.card[data-ag="{ag1["id"]}"]'
|
|
295
|
+
check(pg.locator(f"{c0} .hopt").count() == len(ag1["options"]), f"바닥 카드에 안 {len(ag1['options'])}줄")
|
|
296
|
+
check(all(o["title"][:6] in pg.inner_text(c0) for o in ag1["options"]), "바닥 카드에 안 제목이 다 보인다")
|
|
297
|
+
was = pre.get(ag1["id"])
|
|
298
|
+
last = ag1["options"][-1]["id"]
|
|
299
|
+
hp = f'{c0} [data-hpick="{last}"]'
|
|
300
|
+
if was == last:
|
|
301
|
+
pg.click(hp); pg.wait_for_timeout(80)
|
|
302
|
+
pg.click(hp)
|
|
303
|
+
ok = wait_for(lambda: sel.exists() and json.loads(sel.read_text())["picks"].get(ag1["id"]) == last)
|
|
304
|
+
check(bool(ok) and pg.get_attribute(hp, "aria-pressed") == "true" and "picked" in pg.get_attribute(f"{c0} .hopt:has({hp.split(' ', 1)[1]})", "class"),
|
|
305
|
+
"바닥 카드에서 안 줄을 누르면 고르고 selections.json 에 써진다")
|
|
306
|
+
check(pg.evaluate("document.activeElement && document.activeElement.dataset.hpick") == last, "고른 뒤에도 포커스가 그 줄에 남는다")
|
|
307
|
+
pg.click(hp)
|
|
308
|
+
ok = wait_for(lambda: last not in (json.loads(sel.read_text())["picks"].get(ag1["id"]) or ""))
|
|
309
|
+
check(bool(ok), "다시 누르면 푼다")
|
|
310
|
+
if was:
|
|
311
|
+
pg.click(f'{c0} [data-hpick="{was}"]')
|
|
312
|
+
wait_for(lambda: json.loads(sel.read_text())["picks"].get(ag1["id"]) == was)
|
|
313
|
+
if len(ag1["options"]) > 1:
|
|
314
|
+
pg.click(f'{c0} .hopt-view[data-view="1"]')
|
|
315
|
+
pg.wait_for_timeout(250)
|
|
316
|
+
check(pg.evaluate("document.getElementById('cmp').open") and pg.get_attribute("#cell-opt", "data-key") == ag1["options"][1]["id"],
|
|
317
|
+
"줄 끝 링크는 그 안을 연 안건 보기로")
|
|
318
|
+
pg.keyboard.press("Escape")
|
|
319
|
+
pg.wait_for_timeout(200)
|
|
320
|
+
|
|
321
|
+
# 안건 보기: 카드를 누르면 팝업 없이 바로 반반 보기 (왼쪽 지금, 오른쪽 안)
|
|
322
|
+
cmp_open = lambda: pg.evaluate("document.getElementById('cmp').open")
|
|
323
|
+
viewing = lambda: pg.get_attribute("#cell-opt", "data-key")
|
|
324
|
+
oidx = lambda ag, oid: [o["id"] for o in ag["options"]].index(oid)
|
|
325
|
+
tab = lambda ag, oid: pg.click(f'#cmp-tabs .otab[data-opt="{oidx(ag, oid)}"]')
|
|
326
|
+
box = lambda sel_: pg.evaluate(f"(e => e ? (r => [r.x, r.y, r.width, r.height])(e.getBoundingClientRect()) : null)(document.querySelector({json.dumps(sel_)}))")
|
|
327
|
+
op1b = ag1["options"][1]
|
|
328
|
+
pg.locator(".card .card-head").first.click()
|
|
329
|
+
pg.wait_for_timeout(250)
|
|
330
|
+
check(cmp_open() and pg.evaluate("document.getElementById('pop') === null"), "카드 제목을 누르면 바로 반반 보기 (팝업은 없다)")
|
|
331
|
+
check(pg.evaluate("location.hash") == "#" + ag1["id"], "주소에 #안건id")
|
|
332
|
+
check(pg.evaluate("getComputedStyle(document.documentElement).overflow") == "hidden", "보는 동안 배경 스크롤 잠김")
|
|
333
|
+
check(pg.locator("#cmp-tabs .otab").count() == len(ag1["options"]), f"머리에 안 바꾸기 버튼 {len(ag1['options'])}개")
|
|
334
|
+
first = pre.get(ag1["id"]) or next((o["id"] for o in ag1["options"] if o.get("recommended")), ag1["options"][0]["id"])
|
|
335
|
+
check(viewing() == first, "처음에는 고른 안 → 권장안 → 첫 안 순으로 보인다")
|
|
336
|
+
check(("no-left" not in pg.get_attribute("#cmp-stage", "class")) == bool(ag1.get("current")), "지금 상태가 있으면 왼쪽 칸")
|
|
337
|
+
|
|
338
|
+
# 머리 한 줄 · 배경 줄과 바닥 줄 없음 · 그림 칸은 그림 높이에 맞는다 · 설명은 접지 않는다
|
|
339
|
+
head = box(".cmp-head")
|
|
340
|
+
check(head[3] <= 56, f"머리는 한 줄이다 ({head[3]:.0f}px)")
|
|
341
|
+
check(all(box(x)[1] < head[1] + head[3] for x in ("#cmp-title", "#cmp-tabs", "#cmp-pos", "#cmp .seg", "#cmp .x")),
|
|
342
|
+
"머리 한 줄에 제목 · 안 버튼 · 안건 n/m · 테마 · × 가 있다")
|
|
343
|
+
check(pg.locator("#cmp-ctx, .cmp-foot, #cmp-full").count() == 0, "배경 설명 줄 · 바닥 줄 · 전체 화면은 없다")
|
|
344
|
+
# 보이는 그림 중 가장 세로로 긴 것은 칸을 꽉 채운다 (아래가 비지 않는다). 그림이 없으면 건너뛴다
|
|
345
|
+
pg.wait_for_timeout(300)
|
|
346
|
+
gaps = pg.evaluate("""[...document.querySelectorAll('#cmp-stage .pane-shot')].filter(p => p.offsetWidth).map(p => {
|
|
347
|
+
const m = p.querySelector('.media'); return m ? p.clientHeight - m.getBoundingClientRect().height : null; }).filter(g => g !== null)""")
|
|
348
|
+
if gaps:
|
|
349
|
+
check(min(gaps) <= 3, f"그림 칸 높이가 그림에 맞는다 (남는 세로 {min(gaps):.0f}px)")
|
|
350
|
+
check(pg.locator("#cmp-left .pane-label").count() == 0 or box("#cmp-left .pane-label")[1] + box("#cmp-left .pane-label")[3] <= box("#cmp-left .pane-shot, #cmp-left .noimg")[1] + 1,
|
|
351
|
+
"지금 · 안 표는 그림 위 머리 줄이라 그림을 가리지 않는다")
|
|
352
|
+
rich_h = pg.evaluate("(e => e ? e.clientHeight : 0)(document.querySelector('#band-right .rich'))")
|
|
353
|
+
clipped = pg.evaluate("(e => e ? e.scrollHeight - e.clientHeight : 0)(document.querySelector('#band-right .rich'))")
|
|
354
|
+
check(rich_h > 0 and clipped <= 1, f"안 설명은 접지 않고 다 보인다 ({rich_h}px)")
|
|
355
|
+
check(pg.locator("#cmp-pickbtn").is_visible() and pg.locator("#cmp-next").is_visible()
|
|
356
|
+
and box("#cmp-pickbtn")[0] > box("#band-right")[0], "[이 안으로] · [다음 안건] 은 안 칸 오른쪽")
|
|
357
|
+
check(not pg.locator("#memo").is_visible(), "접혀 있으면 메모 칸은 숨어 있다")
|
|
358
|
+
|
|
359
|
+
# 그림 짝: caption 이 모두 있으면 이름으로, 아니면 순서로. 짝이 없는 칸은 비우고 사유를 적는다
|
|
360
|
+
for o in ag1["options"]:
|
|
361
|
+
tab(ag1, o["id"])
|
|
362
|
+
pg.wait_for_timeout(80)
|
|
363
|
+
steps = steps_of(ag1, o)
|
|
364
|
+
for i, (has_l, has_r) in enumerate(steps):
|
|
365
|
+
if i:
|
|
366
|
+
pg.keyboard.press("ArrowRight")
|
|
367
|
+
pg.wait_for_timeout(80)
|
|
368
|
+
where = f"[{o['id']} 그림 {i + 1}/{len(steps)}]"
|
|
369
|
+
if len(steps) > 1:
|
|
370
|
+
check(f"그림 {i + 1} / {len(steps)}" in pg.inner_text("#cmp-right .pane-label"), f"{where} 그림 번호")
|
|
371
|
+
if ag1.get("current"):
|
|
372
|
+
check(pg.locator("#cmp-left .noimg").count() == (0 if has_l else 1), f"{where} 왼쪽: {'지금 그림' if has_l else '짝 없음 안내'}")
|
|
373
|
+
check(pg.locator("#cmp-right .noimg").count() == (0 if has_r else 1), f"{where} 오른쪽: {'안 그림' if has_r else '짝 없음 안내'}")
|
|
374
|
+
check(viewing() == o["id"], f"[{o['id']}] ← → 는 그림만 넘기고 안은 바꾸지 않는다")
|
|
375
|
+
for _ in range(len(steps) - 1):
|
|
376
|
+
pg.keyboard.press("ArrowLeft")
|
|
377
|
+
pg.wait_for_timeout(80)
|
|
378
|
+
if len(op1b["id"]) == 1:
|
|
379
|
+
tab(ag1, op1["id"])
|
|
380
|
+
pg.keyboard.press(op1b["id"].lower())
|
|
381
|
+
pg.wait_for_timeout(80)
|
|
382
|
+
check(viewing() == op1b["id"], "A · B · C 키로 안을 바꾼다")
|
|
383
|
+
tab(ag1, op1["id"])
|
|
384
|
+
pg.wait_for_timeout(80)
|
|
385
|
+
if pg.get_attribute("#cmp-pickbtn", "aria-pressed") != "true":
|
|
386
|
+
pg.click("#cmp-pickbtn")
|
|
387
|
+
pg.wait_for_timeout(100)
|
|
388
|
+
check(pg.inner_text("#cmp-pickbtn") == "✓ 선택됨"
|
|
389
|
+
and "picked" in pg.get_attribute(f'#cmp-tabs .otab[data-opt="{oidx(ag1, op1["id"])}"]', "class")
|
|
390
|
+
and "picked" in pg.get_attribute("#cmp-right", "class") and "picked" in pg.get_attribute("#cell-opt", "class"),
|
|
391
|
+
"[이 안으로] 를 누르면 버튼 · 안 버튼 · 그림 칸 · 설명 칸에 반영")
|
|
392
|
+
|
|
393
|
+
# 펼치기: 설명 전체 + 안건 배경 + 메모
|
|
394
|
+
more = pg.locator("#cell-opt [data-more]")
|
|
395
|
+
check("메모" in more.inner_text(), f"오른쪽 펼치기는 메모도 있다고 알린다 ({more.inner_text()})")
|
|
396
|
+
more.click()
|
|
397
|
+
pg.wait_for_timeout(150)
|
|
398
|
+
check("open" in pg.get_attribute("#band", "class") and pg.locator("#memo").is_visible(), "[펼치기] 로 열면 메모 칸이 보인다")
|
|
399
|
+
if ag1.get("context"):
|
|
400
|
+
check("안건 배경" in pg.inner_text("#band-ctx"), "펼치면 안건 배경이 나온다")
|
|
401
|
+
full_h = pg.evaluate("document.querySelector('#band-right .rich').clientHeight")
|
|
402
|
+
check(full_h >= rich_h, f"펼치면 설명이 다 보인다 ({rich_h}px → {full_h}px)")
|
|
403
|
+
pg.fill("#memo", "칩 글자도 조금 키워 줘\n두 번째 줄")
|
|
404
|
+
ok = wait_for(lambda: sel.exists() and json.loads(sel.read_text())["picks"].get(ag1["id"]) == op1["id"]
|
|
405
|
+
and "두 번째 줄" in json.loads(sel.read_text())["memos"].get(ag1["id"], ""))
|
|
406
|
+
check(bool(ok), "selections.json 에 선택 · 메모가 써진다")
|
|
407
|
+
if shots:
|
|
408
|
+
pg.screenshot(path=str(shots / "3b-band-open.png"))
|
|
409
|
+
pg.locator("#cell-opt [data-more]").click()
|
|
410
|
+
pg.wait_for_timeout(100)
|
|
411
|
+
check("open" not in pg.get_attribute("#band", "class") and "메모 있음" in more.inner_text(), "접으면 '메모 있음' 으로 알린다")
|
|
412
|
+
|
|
413
|
+
pg.locator("#cmp-stage").focus()
|
|
414
|
+
pg.locator('#cmp [data-set-theme="dark"]').click()
|
|
415
|
+
pg.wait_for_timeout(100)
|
|
416
|
+
if pg.locator("#cmp-right img").count():
|
|
417
|
+
check(theme() == "dark" and pg.get_attribute("#cmp-right img", "src") == pg.get_attribute("#cmp-right img", "data-d"),
|
|
418
|
+
"안건 보기에서도 테마 전환 · 그림 따라 바뀜")
|
|
419
|
+
if shots:
|
|
420
|
+
pg.screenshot(path=str(shots / "2-view-dark.png"))
|
|
421
|
+
pg.locator('#cmp [data-set-theme="light"]').click()
|
|
422
|
+
pg.wait_for_timeout(100)
|
|
423
|
+
if shots:
|
|
424
|
+
pg.screenshot(path=str(shots / "2-view.png"))
|
|
425
|
+
|
|
426
|
+
# 그림을 누르면 양쪽 같은 자리를 같이 2배로. 휠 배율 · 끌어 옮기기도 같이. Esc · 다시 누르면 원래대로
|
|
427
|
+
if pg.locator("#cmp-right .pane-shot img").count() and pg.locator("#cmp-left .pane-shot img").count():
|
|
428
|
+
zs = lambda: pg.evaluate("[...document.querySelectorAll('.pane-shot img')].map(i => getComputedStyle(i).transform)")
|
|
429
|
+
# 그림 위 한 점을 (그림 크기에 대한 비율로) 화면 좌표로: 양쪽에서 같은 비율 점이 칸 안 같은 자리에 와야 한다
|
|
430
|
+
where = lambda side, u, v: pg.evaluate(f"""(() => {{ const im = document.querySelector('#cmp-{side} .pane-shot img');
|
|
431
|
+
const r = im.getBoundingClientRect(), p = im.closest('.pane').getBoundingClientRect();
|
|
432
|
+
return [r.left + r.width * {u} - p.left, r.top + r.height * {v} - p.top]; }})()""")
|
|
433
|
+
scale = lambda: pg.evaluate("(m => m ? +m[1] : 1)(/matrix\\(([\\d.]+)/.exec(getComputedStyle(document.querySelector('#cmp-right .pane-shot img')).transform))")
|
|
434
|
+
ib = box("#cmp-right .pane-shot img")
|
|
435
|
+
cx, cy = ib[0] + ib[2] * 0.7, ib[1] + ib[3] * 0.4
|
|
436
|
+
before = where("right", 0.7, 0.4)
|
|
437
|
+
pg.mouse.click(cx, cy)
|
|
438
|
+
pg.wait_for_timeout(150)
|
|
439
|
+
t = zs()
|
|
440
|
+
check(abs(scale() - 2) < 0.01 and len(set(t)) <= 2 and all(x != "none" for x in t), f"그림을 누르면 양쪽이 같이 2배 ({t})")
|
|
441
|
+
after = where("right", 0.7, 0.4)
|
|
442
|
+
check(abs(after[0] - before[0]) < 2 and abs(after[1] - before[1]) < 2, "누른 자리가 제자리에 있다 (그 자리를 키운다)")
|
|
443
|
+
l, rr = where("left", 0.7, 0.4), where("right", 0.7, 0.4)
|
|
444
|
+
check(abs(l[0] - rr[0]) < 3 and abs(l[1] - rr[1]) < 3, f"왼쪽도 같은 자리를 키운다 (왼 {l[0]:.0f},{l[1]:.0f} · 오 {rr[0]:.0f},{rr[1]:.0f})")
|
|
445
|
+
check(pg.is_visible("#zoom-hint") and "2.0배" in pg.inner_text("#zoom-hint"), "확대 중 안내 (배율 · 휠 · 끌기 · Esc)")
|
|
446
|
+
if shots:
|
|
447
|
+
pg.screenshot(path=str(shots / "3-zoom.png"))
|
|
448
|
+
pg.mouse.move(cx, cy)
|
|
449
|
+
pg.mouse.wheel(0, -300)
|
|
450
|
+
pg.wait_for_timeout(150)
|
|
451
|
+
s2 = scale()
|
|
452
|
+
check(s2 > 2.1, f"휠을 올리면 더 커진다 ({s2:.2f}배)")
|
|
453
|
+
l0, r0 = where("left", 0.5, 0.5), where("right", 0.5, 0.5)
|
|
454
|
+
pg.mouse.move(cx, cy)
|
|
455
|
+
pg.mouse.down()
|
|
456
|
+
pg.mouse.move(cx + 40, cy + 30, steps=4)
|
|
457
|
+
pg.mouse.move(cx + 80, cy + 60, steps=4)
|
|
458
|
+
pg.mouse.up()
|
|
459
|
+
pg.wait_for_timeout(150)
|
|
460
|
+
l1, r1 = where("left", 0.5, 0.5), where("right", 0.5, 0.5)
|
|
461
|
+
check(r1[0] - r0[0] > 20 and abs((l1[0] - l0[0]) - (r1[0] - r0[0])) < 3 and abs((l1[1] - l0[1]) - (r1[1] - r0[1])) < 3,
|
|
462
|
+
f"끌면 양쪽이 같이 옮겨진다 (오른쪽 {r1[0] - r0[0]:.0f},{r1[1] - r0[1]:.0f} · 왼쪽 {l1[0] - l0[0]:.0f},{l1[1] - l0[1]:.0f})")
|
|
463
|
+
check(abs(scale() - s2) < 0.01, "끌기는 배율을 바꾸지 않는다 (누르기로 치지 않는다)")
|
|
464
|
+
tab(ag1, op1b["id"])
|
|
465
|
+
pg.wait_for_timeout(200)
|
|
466
|
+
check(abs(scale() - s2) < 0.01, "확대 중에 안을 바꿔도 같은 자리를 계속 본다")
|
|
467
|
+
tab(ag1, op1["id"])
|
|
468
|
+
pg.wait_for_timeout(150)
|
|
469
|
+
pg.keyboard.press("Escape")
|
|
470
|
+
pg.wait_for_timeout(150)
|
|
471
|
+
check(cmp_open() and set(zs()) == {"none"} and not pg.is_visible("#zoom-hint"), "Esc 는 확대만 풀고 안건 보기는 남는다")
|
|
472
|
+
pg.mouse.click(cx, cy)
|
|
473
|
+
pg.wait_for_timeout(100)
|
|
474
|
+
pg.mouse.click(cx, cy)
|
|
475
|
+
pg.wait_for_timeout(100)
|
|
476
|
+
check(set(zs()) == {"none"}, "확대 중에 다시 누르면 원래대로")
|
|
477
|
+
|
|
478
|
+
pg.keyboard.press("Enter")
|
|
479
|
+
pg.wait_for_timeout(300)
|
|
480
|
+
nxt = spec["agendas"][1] if n > 1 else None
|
|
481
|
+
if nxt:
|
|
482
|
+
check(cmp_open() and pg.evaluate("location.hash") == "#" + nxt["id"] and nxt["title"][:6] in pg.inner_text("#cmp-title"),
|
|
483
|
+
"Enter 는 지금 안을 고르고 다음 안건으로")
|
|
484
|
+
check(not pg.locator("#memo").is_visible(), "다음 안건은 띠가 접힌 채로 열린다")
|
|
485
|
+
ok = wait_for(lambda: json.loads(sel.read_text())["picks"].get(ag1["id"]) == op1["id"])
|
|
486
|
+
check(bool(ok), "Enter 로 고른 안이 저장된다")
|
|
487
|
+
for _ in range(n - 1): # 남은 안건을 [다음 안건 →] 으로 훑는다
|
|
488
|
+
cur = spec["agendas"][[a["id"] for a in spec["agendas"]].index(pg.evaluate("location.hash")[1:])]
|
|
489
|
+
has_left = "no-left" not in pg.get_attribute("#cmp-stage", "class")
|
|
490
|
+
check(has_left == bool(cur.get("current")), f"[{cur['id']}] 지금 상태가 있으면 반반, 없으면 안만 넓게")
|
|
491
|
+
check(("no-left" not in pg.get_attribute("#band", "class")) == bool(cur.get("current")), f"[{cur['id']}] 설명 띠도 같이")
|
|
492
|
+
if cur.get("decided"):
|
|
493
|
+
check(viewing() == cur["decided"] and "대화에서 정함" in pg.inner_text("#band-right")
|
|
494
|
+
and "대화에서 정한 안" in pg.evaluate("document.getElementById('band-ctx').textContent"),
|
|
495
|
+
f"[{cur['id']}] 대화에서 정한 안부터, '대화에서 정함' 표시")
|
|
496
|
+
for o in cur["options"]:
|
|
497
|
+
if not o.get("shots"):
|
|
498
|
+
tab(cur, o["id"])
|
|
499
|
+
pg.wait_for_timeout(100)
|
|
500
|
+
check("그림이 없다" in pg.inner_text("#cmp-right .noimg"), f"[{cur['id']}] 그림 없는 안 {o['id']} 는 빈 칸 안내")
|
|
501
|
+
if shots:
|
|
502
|
+
pg.screenshot(path=str(shots / f"4-view-{cur['id']}.png"))
|
|
503
|
+
if cur is spec["agendas"][-1]:
|
|
504
|
+
break
|
|
505
|
+
pg.click("#cmp-next")
|
|
506
|
+
pg.wait_for_timeout(250)
|
|
507
|
+
if n > 1:
|
|
508
|
+
pg.click("#cmp-prev")
|
|
509
|
+
pg.wait_for_timeout(200)
|
|
510
|
+
check(pg.evaluate("location.hash") == "#" + spec["agendas"][-2]["id"], "머리의 ‹ 로 이전 안건")
|
|
511
|
+
pg.keyboard.press("Escape")
|
|
512
|
+
pg.wait_for_timeout(200)
|
|
513
|
+
check(not cmp_open(), "Esc 로 목록으로")
|
|
514
|
+
check(pg.evaluate("location.hash") == "", "닫으면 주소의 # 가 지워진다")
|
|
515
|
+
check(op1["title"][:6] in pg.locator(".card").first.inner_text(), "바닥 카드에 고른 안이 보인다")
|
|
516
|
+
|
|
517
|
+
# 새로고침해도 남는다
|
|
518
|
+
grab(pg)
|
|
519
|
+
pg.reload()
|
|
520
|
+
pg.wait_for_timeout(300)
|
|
521
|
+
first_card = pg.locator(".card").first.inner_text()
|
|
522
|
+
check(op1["title"][:6] in first_card and "두 번째 줄" in first_card, "새로고침 뒤에도 선택 · 메모 유지")
|
|
523
|
+
|
|
524
|
+
# 주소로 바로 열기 + 마지막 안건 고르기
|
|
525
|
+
grab(pg)
|
|
526
|
+
pg.goto(url + "#" + ag2["id"])
|
|
527
|
+
pg.wait_for_timeout(300)
|
|
528
|
+
check(cmp_open() and ag2["title"][:6] in pg.inner_text("#cmp-title"), "#안건id 로 열면 그 안건이 바로 열린다")
|
|
529
|
+
tab(ag2, op2["id"])
|
|
530
|
+
pg.wait_for_timeout(80)
|
|
531
|
+
# 그림 데이터 (figure): 페이지가 줄 · 상자를 HTML 로 만들어 그린다 (Claude 는 데이터만 쓴다)
|
|
532
|
+
fig_op = next((o for o in ag2["options"] if any(isinstance(x, dict) and x.get("figure") for x in o.get("shots") or [])), None)
|
|
533
|
+
if fig_op:
|
|
534
|
+
tab(ag2, fig_op["id"])
|
|
535
|
+
fig = next(x["figure"] for x in fig_op["shots"] if isinstance(x, dict) and x.get("figure"))
|
|
536
|
+
want = sum(len(ln.get("nodes") or []) for ln in fig.get("lanes") or [])
|
|
537
|
+
ok = wait_for(lambda: pg.evaluate("(f => f && f.contentDocument ? f.contentDocument.querySelectorAll('.node').length : -1)(document.querySelector('#cmp-right .media.frame[data-fig] iframe'))") == want, 4)
|
|
538
|
+
check(bool(ok), f"figure 데이터로 그래프를 그린다 (상자 {want}개)")
|
|
539
|
+
tab(ag2, op2["id"])
|
|
540
|
+
pg.wait_for_timeout(80)
|
|
541
|
+
# HTML 개념 그림: iframe 으로 칸 너비에 바로 그린다 (글자 원래 크기), 칸 높이는 내용 높이, 테마를 문서에 넘긴다
|
|
542
|
+
html_src = next((x if isinstance(x, str) else (x.get("src") or x.get("light") or "") for x in op2.get("shots") or []), "")
|
|
543
|
+
if html_src.lower().endswith((".html", ".htm")):
|
|
544
|
+
ok = wait_for(lambda: pg.evaluate("(f => !!(f && f.contentDocument && f.contentDocument.body && f.contentDocument.body.children.length))(document.querySelector('#cmp-right .media.frame iframe'))"), 4)
|
|
545
|
+
check(bool(ok), "HTML 그림은 안건 보기 칸에 iframe 으로 그려진다")
|
|
546
|
+
fr = pg.evaluate("""(() => { const f = document.querySelector('#cmp-right .media.frame iframe'), ps = f.closest('.pane-shot');
|
|
547
|
+
const doc = f.contentDocument; return { sandbox: f.getAttribute('sandbox'), w: f.clientWidth, psw: ps.clientWidth, tf: f.style.transform,
|
|
548
|
+
h: f.clientHeight, content: Math.max(doc.documentElement.scrollHeight, doc.body.scrollHeight), theme: doc.documentElement.dataset.theme }; })()""")
|
|
549
|
+
check(fr["sandbox"] == "allow-same-origin", f"HTML 그림 iframe 은 스크립트를 막는다 (sandbox={fr['sandbox']!r})")
|
|
550
|
+
check(abs(fr["w"] - fr["psw"]) <= 1 and not fr["tf"], f"HTML 그림은 칸 너비로 그려 글자가 원래 크기다 ({fr['w']} / {fr['psw']}px)")
|
|
551
|
+
check(abs(fr["h"] - fr["content"]) <= 2, f"iframe 높이가 내용 높이에 맞는다 ({fr['h']} / {fr['content']}px)")
|
|
552
|
+
check(fr["theme"] == "light", "그림 문서에 페이지 테마 (light) 를 단다")
|
|
553
|
+
pg.locator('#cmp [data-set-theme="dark"]').click()
|
|
554
|
+
pg.wait_for_timeout(150)
|
|
555
|
+
check(pg.evaluate("document.querySelector('#cmp-right .media.frame iframe').contentDocument.documentElement.dataset.theme") == "dark",
|
|
556
|
+
"다크로 바꾸면 그림 문서도 다크")
|
|
557
|
+
pg.locator('#cmp [data-set-theme="light"]').click()
|
|
558
|
+
with urllib.request.urlopen(url + html_src, timeout=3) as r:
|
|
559
|
+
check(r.headers.get("Content-Security-Policy") == "sandbox allow-same-origin", "서버는 폴더 안 HTML 에 CSP sandbox 를 붙인다 (주소로 바로 열어도 스크립트가 돌지 않는다)")
|
|
560
|
+
if shots:
|
|
561
|
+
pg.screenshot(path=str(shots / "4b-view-html.png"))
|
|
562
|
+
if pg.get_attribute("#cmp-pickbtn", "aria-pressed") != "true":
|
|
563
|
+
pg.click("#cmp-pickbtn")
|
|
564
|
+
pg.click("#cmp-next") # 마지막 안건이면 목록으로
|
|
565
|
+
pg.wait_for_timeout(200)
|
|
566
|
+
check(not cmp_open(), "마지막 안건의 [목록으로]")
|
|
567
|
+
pg.fill("#note", "전체적으로 좋다")
|
|
568
|
+
pg.wait_for_timeout(700)
|
|
569
|
+
check(pg.inner_text("#progress") == f"결정 2 / {n}" if n == 2 else True, "진행 표시 갱신")
|
|
570
|
+
if shots:
|
|
571
|
+
pg.screenshot(path=str(shots / "5-base-picked.png"), full_page=True)
|
|
572
|
+
|
|
573
|
+
# 보내기 → wait 가 찍고 끝난다 (Orca 밖)
|
|
574
|
+
pg.click("#send")
|
|
575
|
+
try:
|
|
576
|
+
out, _ = waiter.communicate(timeout=8)
|
|
577
|
+
except subprocess.TimeoutExpired:
|
|
578
|
+
waiter.kill()
|
|
579
|
+
out = ""
|
|
580
|
+
check(waiter.returncode == 0, "wait 가 보내기를 받고 끝난다")
|
|
581
|
+
check(f"선택: {op1['id']}. {op1['title']}" in out and f"선택: {op2['id']}. {op2['title']}" in out, "wait 출력에 두 선택")
|
|
582
|
+
check("메모: 칩 글자도 조금 키워 줘" in out and "두 번째 줄" in out, "wait 출력에 메모 (여러 줄)")
|
|
583
|
+
if ag2.get("decided") and ag2["decided"] != op2["id"]:
|
|
584
|
+
check(f"대화에서 정한 {ag2['decided']} 에서 바꿈" in out, "wait 출력에 '대화에서 정한 안에서 바꿈'")
|
|
585
|
+
check("전체 메모: 전체적으로 좋다" in out, "wait 출력에 전체 메모")
|
|
586
|
+
sub1 = json.loads((d / "submissions" / "0001.json").read_text())
|
|
587
|
+
check(sub1.get("via") == "wait" and "선택:" in sub1.get("message", ""), "submissions/0001.json 에 전달 경로 · 읽을 메시지")
|
|
588
|
+
ok = wait_for(lambda: "전달됐다" in pg.inner_text("#send-info"), 6)
|
|
589
|
+
check(bool(ok), "페이지에 'Claude 에 전달됐다'")
|
|
590
|
+
print("\n--- wait 출력 ---\n" + out + "---")
|
|
591
|
+
|
|
592
|
+
# 기다리는 wait 가 없을 때 보낸 것은 다음 wait 가 바로 받는다
|
|
593
|
+
pg.click("#send")
|
|
594
|
+
wait_for(lambda: (d / "submissions" / "0002.json").exists())
|
|
595
|
+
late = subprocess.run([PY, str(PICKER), "wait", str(d)], capture_output=True, text=True, timeout=8, env=BASE_ENV)
|
|
596
|
+
check("(#2," in late.stdout, "밀린 보내기를 다음 wait 가 바로 받는다")
|
|
597
|
+
|
|
598
|
+
# 보안: 토큰 · Host
|
|
599
|
+
tok = (d / ".picker" / "token").read_text().strip()
|
|
600
|
+
check(http(url + "api/submit", "POST", {"Content-Type": "application/json"}, b"{}") == 403, "토큰 없으면 403")
|
|
601
|
+
check(http(url + "api/meta", headers={"X-Picker-Token": tok, "Host": "evil.example:80"}) == 403, "다른 Host 면 403")
|
|
602
|
+
check(http(url + ".picker/token") == 404, ".picker 는 내려주지 않는다")
|
|
603
|
+
check(http(url + "api/meta", headers={"X-Picker-Token": tok}) == 200, "토큰 있으면 200")
|
|
604
|
+
|
|
605
|
+
# 안건이 바뀌면 배너
|
|
606
|
+
sp = json.loads((d / "agenda.json").read_text())
|
|
607
|
+
sp["title"] += " (수정)"
|
|
608
|
+
(d / "agenda.json").write_text(json.dumps(sp, ensure_ascii=False))
|
|
609
|
+
ok = wait_for(lambda: pg.is_visible("#banner"), 5)
|
|
610
|
+
check(bool(ok), "agenda.json 이 바뀌면 새로고침 배너")
|
|
611
|
+
|
|
612
|
+
# 정적 사본 (서버 없이 연 index.html)
|
|
613
|
+
ssrv, surl = static_server(d)
|
|
614
|
+
pg2 = b.new_page(viewport=(1360, 900))
|
|
615
|
+
pg2.goto(surl)
|
|
616
|
+
pg2.wait_for_timeout(300)
|
|
617
|
+
check(pg2.inner_text("#send") == "메시지 복사", "서버 없이 연 정적 사본은 보내기 대신 복사")
|
|
618
|
+
check(op1["title"][:6] in pg2.locator(".card").first.inner_text(), "정적 사본에도 마지막 선택이 들어 있다")
|
|
619
|
+
grab(pg2, "static: ")
|
|
620
|
+
pg2.close()
|
|
621
|
+
ssrv.shutdown()
|
|
622
|
+
|
|
623
|
+
# 영상 그림 (ffmpeg 로 만든 시험 영상)
|
|
624
|
+
vd = check_video(b, tmp / "video", shots)
|
|
625
|
+
|
|
626
|
+
# ---- Orca 안: 서버가 Claude 터미널 입력창에 한 줄을 넣는다 (가짜 orca 로)
|
|
627
|
+
od = tmp / "orca"
|
|
628
|
+
shutil.copytree(src, od, ignore=shutil.ignore_patterns(".picker", "selections.json", "submissions", "index.html"))
|
|
629
|
+
fake, log, ident = tmp / "fake-orca", tmp / "orca.log", tmp / "orca-id"
|
|
630
|
+
fake.write_text(FAKE_ORCA)
|
|
631
|
+
fake.chmod(0o755)
|
|
632
|
+
ident.write_text("claude-agent-teams") # Orca 팀 에이전트로 연 Claude (claude 가 아니어도 에이전트면 넣는다)
|
|
633
|
+
log.write_text("")
|
|
634
|
+
oenv = dict(BASE_ENV, TERM_PROGRAM="Orca", ORCA_TERMINAL_HANDLE="term_selftest", AGENDA_PICKER_ORCA=str(fake),
|
|
635
|
+
FAKE_ORCA_LOG=str(log), FAKE_ORCA_ID=str(ident))
|
|
636
|
+
ourl, opid, _, r = serve(od, oenv)
|
|
637
|
+
check(bool(ourl) and "Orca 터미널 입력창 (term_selftest)" in r.stdout, "Orca 안이면 보내기를 이 터미널 입력창에 넣는다고 알린다")
|
|
638
|
+
(od / ".picker" / "tab.json").write_text(json.dumps({"pageId": "page_selftest", "worktree": ""}))
|
|
639
|
+
calls = lambda: [json.loads(x) for x in log.read_text().splitlines() if x.strip()]
|
|
640
|
+
pg3 = b.new_page(viewport=(1360, 900))
|
|
641
|
+
pg3.goto(ourl)
|
|
642
|
+
pg3.wait_for_timeout(400)
|
|
643
|
+
check("받을 준비가 안 돼" not in pg3.inner_text("#send-info"), "wait 없이도 받을 준비가 돼 있다 (Orca 터미널)")
|
|
644
|
+
Path(str(ident) + ".delay").write_text("2")
|
|
645
|
+
pg3.evaluate("document.getElementById('send').click()") # 응답을 기다리지 않고 누른다
|
|
646
|
+
ok = wait_for(lambda: "넣는 중" in pg3.inner_text("#send-info"), 3)
|
|
647
|
+
check(bool(ok) and "전달됐다" not in pg3.inner_text("#send-info"), "넣는 동안은 '넣는 중' (먼저 '전달됐다' 로 보이지 않는다)")
|
|
648
|
+
ok = wait_for(lambda: any(c[:2] == ["terminal", "send"] for c in calls()), 6)
|
|
649
|
+
Path(str(ident) + ".delay").unlink()
|
|
650
|
+
cs = calls()
|
|
651
|
+
show_i = next((i for i, c in enumerate(cs) if c[:2] == ["terminal", "show"]), -1)
|
|
652
|
+
send_i = next((i for i, c in enumerate(cs) if c[:2] == ["terminal", "send"]), -1)
|
|
653
|
+
check(bool(ok) and 0 <= show_i < send_i, "넣기 전에 terminal show 로 에이전트인지 확인하고 terminal send (팀 에이전트도)")
|
|
654
|
+
sc = cs[send_i] if send_i >= 0 else []
|
|
655
|
+
text = sc[sc.index("--text") + 1] if "--text" in sc else ""
|
|
656
|
+
check("--terminal" in sc and sc[sc.index("--terminal") + 1] == "term_selftest" and "--enter" in sc, "serve 를 부른 터미널에 --enter 로 넣는다")
|
|
657
|
+
check("\n" not in text and "\r" not in text and str(od / "submissions" / "0001.json") in text and "결정" in text,
|
|
658
|
+
f"넣는 글은 한 줄 (요약 + submissions 경로): {text}")
|
|
659
|
+
check("칩 글자" not in text, "사용자가 쓴 메모는 터미널에 넣지 않는다 (파일에서 읽는다)")
|
|
660
|
+
ok = wait_for(lambda: any(c[:2] == ["tab", "close"] and "page_selftest" in c for c in calls()), 5)
|
|
661
|
+
check(bool(ok), "넣은 뒤 Orca 탭을 닫는다")
|
|
662
|
+
ok = wait_for(lambda: "입력창에 넣었다" in pg3.inner_text("#send-info"), 6)
|
|
663
|
+
check(bool(ok), "페이지에 'Claude 입력창에 넣었다'")
|
|
664
|
+
osub = json.loads((od / "submissions" / "0001.json").read_text())
|
|
665
|
+
check(osub.get("via") == "orca" and "이 세션에 다시 들어온다" in osub.get("message", ""), "submission 메시지는 Orca 전달에 맞는 안내")
|
|
666
|
+
late = subprocess.run([PY, str(PICKER), "wait", str(od), "--timeout", "1.5"], capture_output=True, text=True, timeout=8, env=BASE_ENV)
|
|
667
|
+
check(late.returncode == 3, "Orca 로 넣은 것은 뒤에 띄운 wait 가 다시 받지 않는다")
|
|
668
|
+
|
|
669
|
+
# 그 터미널이 셸로 돌아갔으면(agentIdentity 없음) 넣지 않고 페이지에 알린다. 탭은 닫지 않는다
|
|
670
|
+
ident.write_text("")
|
|
671
|
+
(od / ".picker" / "tab.json").write_text(json.dumps({"pageId": "page_selftest2", "worktree": ""}))
|
|
672
|
+
n_send = sum(1 for c in calls() if c[:2] == ["terminal", "send"])
|
|
673
|
+
pg3.click("#send")
|
|
674
|
+
ok = wait_for(lambda: "넣지 못했다" in pg3.inner_text("#send-info"), 6)
|
|
675
|
+
check(bool(ok), "셸이면 페이지에 '넣지 못했다'")
|
|
676
|
+
check(sum(1 for c in calls() if c[:2] == ["terminal", "send"]) == n_send, "셸이면 terminal send 를 하지 않는다")
|
|
677
|
+
pg3.wait_for_timeout(1800)
|
|
678
|
+
check(not any("page_selftest2" in c for c in calls()), "못 넣었으면 탭을 닫지 않는다")
|
|
679
|
+
if shots:
|
|
680
|
+
pg3.locator("#send-info").scroll_into_view_if_needed()
|
|
681
|
+
pg3.screenshot(path=str(shots / "6-orca-not-claude.png"))
|
|
682
|
+
late = subprocess.run([PY, str(PICKER), "wait", str(od), "--timeout", "3"], capture_output=True, text=True, timeout=8, env=BASE_ENV)
|
|
683
|
+
check("(#2," in late.stdout, "못 넣은 것은 뒤에 띄운 wait 가 받을 수 있다")
|
|
684
|
+
grab(pg3, "orca: ")
|
|
685
|
+
pg3.close()
|
|
686
|
+
grab(pg)
|
|
687
|
+
|
|
688
|
+
# ---- Claude 세션 인박스 소켓: 타이핑 없이 보낸 내용 전체를 바로 넣는다 (가짜 소켓 서버로, POSIX)
|
|
689
|
+
if hasattr(__import__("socket"), "AF_UNIX") and sys.platform != "win32":
|
|
690
|
+
import socket as _so
|
|
691
|
+
ibd = tmp / "inbox"
|
|
692
|
+
shutil.copytree(src, ibd, ignore=shutil.ignore_patterns(".picker", "selections.json", "submissions", "index.html"))
|
|
693
|
+
sock_path = Path(tempfile.mkdtemp(prefix="cc-sock-")) / "1.sock"
|
|
694
|
+
got_lines: list = []
|
|
695
|
+
srv = _so.socket(_so.AF_UNIX, _so.SOCK_STREAM)
|
|
696
|
+
srv.bind(str(sock_path))
|
|
697
|
+
srv.listen(5)
|
|
698
|
+
|
|
699
|
+
def accept_loop():
|
|
700
|
+
while True:
|
|
701
|
+
try:
|
|
702
|
+
c, _ = srv.accept()
|
|
703
|
+
except OSError:
|
|
704
|
+
return
|
|
705
|
+
buf = b""
|
|
706
|
+
while True:
|
|
707
|
+
chunk = c.recv(65536)
|
|
708
|
+
if not chunk:
|
|
709
|
+
break
|
|
710
|
+
buf += chunk
|
|
711
|
+
got_lines.extend(json.loads(x) for x in buf.decode().splitlines() if x.strip())
|
|
712
|
+
c.close()
|
|
713
|
+
threading.Thread(target=accept_loop, daemon=True).start()
|
|
714
|
+
log.write_text("")
|
|
715
|
+
ident.write_text("claude")
|
|
716
|
+
ienv = dict(oenv, CLAUDE_CODE_MESSAGING_SOCKET=str(sock_path), CLAUDE_CODE_MESSAGING_TOKEN="tok-selftest",
|
|
717
|
+
CLAUDE_CODE_SESSION_ID="sess-selftest")
|
|
718
|
+
iurl2, _, _, r = serve(ibd, ienv)
|
|
719
|
+
check(bool(iurl2) and "인박스" in r.stdout, f"인박스 소켓이 있으면 그리로 보낸다고 알린다 {r.stdout[-200:] if '인박스' not in r.stdout else ''}")
|
|
720
|
+
ibf = ibd / ".picker" / "inbox.json"
|
|
721
|
+
check(ibf.is_file() and (ibf.stat().st_mode & 0o777) == 0o600, "인박스 토큰은 0600 파일에 적는다")
|
|
722
|
+
pg4 = b.new_page(viewport=(1360, 900))
|
|
723
|
+
pg4.goto(iurl2)
|
|
724
|
+
pg4.wait_for_timeout(400)
|
|
725
|
+
pg4.evaluate("document.querySelector('#note') && (document.querySelector('#note').value = '인박스 메모 글')")
|
|
726
|
+
pg4.evaluate("document.getElementById('send').click()")
|
|
727
|
+
ok = wait_for(lambda: len(got_lines) >= 2, 5)
|
|
728
|
+
check(bool(ok) and got_lines[0] == {"type": "auth", "token": "tok-selftest"} and got_lines[1].get("type") == "user",
|
|
729
|
+
f"소켓에 auth(토큰) + user 메시지 두 줄 {json.dumps(got_lines, ensure_ascii=False)[:200]}")
|
|
730
|
+
content = (got_lines[1].get("message") or {}).get("content", "") if len(got_lines) > 1 else ""
|
|
731
|
+
check(content.startswith("[agenda-picker] 사용자가 안건 선택을 보냈다") and "\n" in content and "결정" in content,
|
|
732
|
+
"보낸 내용 전체가 여러 줄 그대로 들어간다")
|
|
733
|
+
check(not any(c[:2] == ["terminal", "send"] for c in calls()), "인박스로 넣었으면 Orca 입력창에 타이핑하지 않는다")
|
|
734
|
+
ok = wait_for(lambda: "세션에 바로 넣었다" in pg4.inner_text("#send-info"), 6)
|
|
735
|
+
check(bool(ok), "페이지에 'Claude 세션에 바로 넣었다'")
|
|
736
|
+
dl = json.loads((ibd / ".picker" / "delivery.json").read_text())
|
|
737
|
+
check(dl.get("via") == "inbox" and dl.get("ok") and dl.get("tookSec", 9) < 2, f"인박스 전달은 빠르다 ({dl.get('tookSec')}초)")
|
|
738
|
+
# 세션이 끝나 소켓이 사라지면 Orca 입력창으로 넘어간다
|
|
739
|
+
srv.close()
|
|
740
|
+
sock_path.unlink()
|
|
741
|
+
(ibd / ".picker" / "tab.json").write_text(json.dumps({"pageId": "page_selftest3", "worktree": ""}))
|
|
742
|
+
pg4.click("#send")
|
|
743
|
+
ok = wait_for(lambda: any(c[:2] == ["terminal", "send"] for c in calls()), 8)
|
|
744
|
+
check(bool(ok), "소켓이 없으면 Orca 입력창으로 넘어간다")
|
|
745
|
+
pg4.close()
|
|
746
|
+
subprocess.run([PY, str(PICKER), "stop", str(ibd)], capture_output=True, env=BASE_ENV)
|
|
747
|
+
|
|
748
|
+
check(not errs, f"페이지 JS 오류 없음 {errs}")
|
|
749
|
+
finally:
|
|
750
|
+
subprocess.run([PY, str(PICKER), "stop", str(d)], capture_output=True, env=BASE_ENV)
|
|
751
|
+
for x in (od, vd):
|
|
752
|
+
if x:
|
|
753
|
+
subprocess.run([PY, str(PICKER), "stop", str(x)], capture_output=True, env=BASE_ENV)
|
|
754
|
+
if waiter.poll() is None:
|
|
755
|
+
waiter.kill()
|
|
756
|
+
check(wait_for(lambda: not alive(spid), 3), "stop 으로 서버가 끝난다")
|
|
757
|
+
|
|
758
|
+
# 요청 없이 idle 초가 지나면 서버가 스스로 끝난다 (기본 12시간, 여기서는 2초)
|
|
759
|
+
idle_d = tmp / "idle"
|
|
760
|
+
shutil.copytree(src, idle_d, ignore=shutil.ignore_patterns(".picker", "selections.json", "submissions", "index.html"))
|
|
761
|
+
iurl, ipid, _, _ = serve(idle_d, None, "--idle", "2")
|
|
762
|
+
check(bool(iurl) and alive(ipid), "idle 서버가 뜬다")
|
|
763
|
+
check(wait_for(lambda: not alive(ipid), 8, 0.2), "요청 없이 idle 초가 지나면 서버가 스스로 끝난다")
|
|
764
|
+
check(not (idle_d / ".picker" / "server.json").exists(), "끝나면 server.json 을 지운다")
|
|
765
|
+
|
|
766
|
+
print(f"\n{'통과' if not fails else '실패 %d개' % len(fails)} (임시 폴더 {tmp})")
|
|
767
|
+
return 1 if fails else 0
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
if __name__ == "__main__":
|
|
771
|
+
sys.exit(main())
|