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,301 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""claude-switch · statusline 을 이 PC 에 잇는다 (thuthi:setup 의 doctor.py 가 부른다). python3 3.9 표준 라이브러리만.
|
|
3
|
+
|
|
4
|
+
install.py check 점검 결과를 찍는다 (✓ / ✗ / △)
|
|
5
|
+
install.py shims launcher + 터미널 shim 을 만든다
|
|
6
|
+
install.py statusline ~/.claude/settings.json 의 statusLine 을 바꾼다 (백업을 남긴다)
|
|
7
|
+
|
|
8
|
+
플러그인 판 경로는 판마다 바뀐다. 그래서 고정 위치에 launcher(<state>/launch.py) 를 두고, shim 은 launcher 를 부르고,
|
|
9
|
+
launcher 가 실행할 때마다 지금 판을 찾는다 (로컬 경로 마켓플레이스면 원본 폴더, 아니면 installed_plugins.json 의 installPath).
|
|
10
|
+
launcher 내용이 바뀌면 (예: 플러그인 이름이 thuthi → thuthi-accounts 로 바뀐 0.12.0) Stop 훅이 refresh_launcher() 로 다시 쓴다.
|
|
11
|
+
shim 에는 이 스크립트를 돌린 python 의 절대 경로를 박는다 (Windows 는 python3 이라는 이름이 없을 때가 많다).
|
|
12
|
+
|
|
13
|
+
macOS · Linux ~/.local/bin/claude-switch · ~/.local/bin/thuthi-statusline (sh)
|
|
14
|
+
statusLine = ~/.local/bin/thuthi-statusline
|
|
15
|
+
Windows %USERPROFILE%\\.local\\bin\\claude-switch.cmd · thuthi-statusline.cmd (PowerShell · cmd)
|
|
16
|
+
+ 같은 이름의 확장자 없는 sh shim (Git Bash)
|
|
17
|
+
statusLine = <python> <launch.py> statusline (빈칸 없는 짧은 경로, bash 와 PowerShell 둘 다에서 돈다)
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import json
|
|
22
|
+
import os
|
|
23
|
+
import shutil
|
|
24
|
+
import sys
|
|
25
|
+
import time
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
HERE = Path(__file__).resolve().parent
|
|
29
|
+
sys.path.insert(0, str(HERE.parents[1] / "lib"))
|
|
30
|
+
sys.path.insert(0, str(HERE))
|
|
31
|
+
import usage_store as us # noqa: E402
|
|
32
|
+
|
|
33
|
+
MARK = "thuthi-shim"
|
|
34
|
+
MARKET, PLUGIN = "thuthi-plugin", "thuthi-accounts"
|
|
35
|
+
WIN = sys.platform == "win32"
|
|
36
|
+
OK, BAD, OPT = "✓", "✗", "△"
|
|
37
|
+
|
|
38
|
+
LAUNCHER = '''#!/usr/bin/env python3
|
|
39
|
+
# @MARK@ launcher (thuthi:setup 이 만들었다. 고치지 말고 doctor.py fix claude-switch 로 다시 만든다)
|
|
40
|
+
# 지금 판의 thuthi-accounts 플러그인을 찾아 claude-switch 엔진 · statusline 을 실행한다.
|
|
41
|
+
import json, os, runpy, sys
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
|
|
44
|
+
TARGETS = {"claude-switch": "tools/claude-switch/claude_switch.py", "statusline": "tools/statusline/statusline.py"}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def load(p):
|
|
48
|
+
try:
|
|
49
|
+
return json.loads(p.read_text(encoding="utf-8"))
|
|
50
|
+
except (OSError, ValueError):
|
|
51
|
+
return {}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def roots():
|
|
55
|
+
cfg = Path(os.environ.get("CLAUDE_CONFIG_DIR") or Path.home() / ".claude") / "plugins"
|
|
56
|
+
km = load(cfg / "known_marketplaces.json").get("@MARKET@") or {}
|
|
57
|
+
loc = km.get("installLocation")
|
|
58
|
+
out = []
|
|
59
|
+
if loc and (km.get("source") or {}).get("source") == "directory":
|
|
60
|
+
out.append(Path(loc) / "plugins" / "@PLUGIN@") # 로컬 경로 마켓플레이스는 원본 폴더를 바로 쓴다
|
|
61
|
+
for e in load(cfg / "installed_plugins.json").get("plugins", {}).get("@PLUGIN@@@MARKET@") or []:
|
|
62
|
+
if isinstance(e, dict) and e.get("installPath"):
|
|
63
|
+
out.append(Path(e["installPath"]))
|
|
64
|
+
if loc:
|
|
65
|
+
out.append(Path(loc) / "plugins" / "@PLUGIN@")
|
|
66
|
+
return out
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def main():
|
|
70
|
+
what = sys.argv[1] if len(sys.argv) > 1 else ""
|
|
71
|
+
rel = TARGETS.get(what)
|
|
72
|
+
if not rel:
|
|
73
|
+
sys.exit("usage: launch.py claude-switch|statusline [args...]")
|
|
74
|
+
for root in roots():
|
|
75
|
+
f = root / rel
|
|
76
|
+
if f.is_file():
|
|
77
|
+
sys.argv = [str(f)] + sys.argv[2:]
|
|
78
|
+
sys.path.insert(0, str(f.parent))
|
|
79
|
+
runpy.run_path(str(f), run_name="__main__")
|
|
80
|
+
return
|
|
81
|
+
msg = "thuthi-accounts 플러그인을 못 찾았다. claude plugin install @PLUGIN@@@MARKET@ 뒤 thuthi:setup 을 다시 돌린다."
|
|
82
|
+
try:
|
|
83
|
+
sys.stdout.reconfigure(encoding="utf-8") # Windows 는 cp949 로 찍혀 statusline 에서 글자가 깨진다
|
|
84
|
+
sys.stderr.reconfigure(encoding="utf-8")
|
|
85
|
+
except (AttributeError, ValueError):
|
|
86
|
+
pass
|
|
87
|
+
if what == "statusline":
|
|
88
|
+
print(msg)
|
|
89
|
+
return
|
|
90
|
+
sys.exit(msg)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
main()
|
|
94
|
+
'''
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def local_bin() -> Path:
|
|
98
|
+
return Path.home() / ".local" / "bin"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def launcher_path() -> Path:
|
|
102
|
+
return us.state_dir() / "launch.py"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def launcher_text() -> str:
|
|
106
|
+
return LAUNCHER.replace("@MARK@", MARK).replace("@MARKET@", MARKET).replace("@PLUGIN@", PLUGIN)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def python_exe() -> str:
|
|
110
|
+
"""shim 에 박을 python. macOS · Linux 는 PATH 의 python3 (예: /usr/bin/python3, 판이 바뀌어도 그대로인 경로),
|
|
111
|
+
Windows 는 지금 python.exe."""
|
|
112
|
+
if not WIN:
|
|
113
|
+
found = shutil.which("python3")
|
|
114
|
+
if found:
|
|
115
|
+
return found
|
|
116
|
+
return sys.executable
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def short_path(p: str) -> str:
|
|
120
|
+
"""Windows 에서 빈칸이나 한글이 든 경로를 8.3 짧은 경로로 (따옴표 없이 bash · PowerShell 에서 돌고, cmd 가 코드 페이지
|
|
121
|
+
때문에 경로를 잘못 읽지 않게)."""
|
|
122
|
+
if not WIN or (" " not in p and p.isascii()):
|
|
123
|
+
return p
|
|
124
|
+
import ctypes
|
|
125
|
+
buf = ctypes.create_unicode_buffer(1024)
|
|
126
|
+
n = ctypes.windll.kernel32.GetShortPathNameW(p, buf, 1024)
|
|
127
|
+
return buf.value if 0 < n < 1024 else p
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def fwd(p: str) -> str:
|
|
131
|
+
return short_path(p).replace("\\", "/")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def sh_text(target: str) -> str:
|
|
135
|
+
py, la = (fwd(python_exe()), fwd(str(launcher_path()))) if WIN else (python_exe(), str(launcher_path()))
|
|
136
|
+
return f'#!/bin/sh\n# {MARK} (thuthi:setup 이 만들었다. 고치지 말고 doctor.py fix claude-switch 로 다시 만든다)\n' \
|
|
137
|
+
f'exec "{py}" "{la}" {target} "$@"\n'
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def cmd_text(target: str) -> str:
|
|
141
|
+
# cmd 는 배치 파일을 OEM 코드 페이지로 읽으므로 ASCII 만 쓴다
|
|
142
|
+
return f'@echo off\r\nREM {MARK} (made by thuthi:setup; regenerate with doctor.py fix claude-switch)\r\n' \
|
|
143
|
+
f'"{short_path(python_exe())}" "{short_path(str(launcher_path()))}" {target} %*\r\n'
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def shim_files() -> dict:
|
|
147
|
+
"""만들 파일 → 내용"""
|
|
148
|
+
b = local_bin()
|
|
149
|
+
files = {b / "claude-switch": sh_text("claude-switch"), b / "thuthi-statusline": sh_text("statusline")}
|
|
150
|
+
if WIN:
|
|
151
|
+
files[b / "claude-switch.cmd"] = cmd_text("claude-switch")
|
|
152
|
+
files[b / "thuthi-statusline.cmd"] = cmd_text("statusline")
|
|
153
|
+
return files
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def statusline_command() -> str:
|
|
157
|
+
if WIN:
|
|
158
|
+
return f"{fwd(python_exe())} {fwd(str(launcher_path()))} statusline"
|
|
159
|
+
return "~/.local/bin/thuthi-statusline"
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def settings_path() -> Path:
|
|
163
|
+
return Path(os.environ.get("CLAUDE_CONFIG_DIR") or Path.home() / ".claude") / "settings.json"
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def current_statusline() -> str:
|
|
167
|
+
try:
|
|
168
|
+
return ((json.loads(settings_path().read_text(encoding="utf-8")).get("statusLine") or {}).get("command") or "")
|
|
169
|
+
except (OSError, ValueError):
|
|
170
|
+
return ""
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def same(p: Path, text: str) -> bool:
|
|
174
|
+
try:
|
|
175
|
+
with open(p, encoding="utf-8", newline="") as f: # .cmd 의 \r\n 을 그대로 비교한다
|
|
176
|
+
return f.read() == text
|
|
177
|
+
except (OSError, UnicodeDecodeError):
|
|
178
|
+
return False
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def is_ours(p: Path) -> bool:
|
|
182
|
+
try:
|
|
183
|
+
return MARK in p.read_text(encoding="utf-8", errors="replace")
|
|
184
|
+
except OSError:
|
|
185
|
+
return False
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def status() -> list:
|
|
189
|
+
"""(기호, 항목, 설명) 목록"""
|
|
190
|
+
rows = []
|
|
191
|
+
add = lambda m, item, note="": rows.append((m, item, note))
|
|
192
|
+
py = sys.version_info[:2]
|
|
193
|
+
add(OK if py >= (3, 9) else BAD, f"python {py[0]}.{py[1]} ({python_exe()})", "" if py >= (3, 9) else "3.9 이상 필요")
|
|
194
|
+
if sys.platform == "darwin":
|
|
195
|
+
add(OK if shutil.which("security") else BAD, "security (Keychain)")
|
|
196
|
+
has_tui = bool(shutil.which("uv"))
|
|
197
|
+
if not has_tui:
|
|
198
|
+
try:
|
|
199
|
+
import importlib.util
|
|
200
|
+
has_tui = importlib.util.find_spec("textual") is not None
|
|
201
|
+
except (ImportError, ValueError):
|
|
202
|
+
has_tui = False
|
|
203
|
+
add(OK if has_tui else OPT, "TUI 실행 (uv 또는 textual)", "" if has_tui else "uv 설치 (https://docs.astral.sh/uv/, macOS: brew install uv)")
|
|
204
|
+
add(OK if shutil.which("fzf") else OPT, "fzf", "" if shutil.which("fzf") else "없으면 picker 를 번호로 고른다")
|
|
205
|
+
stale = [p for p, t in [(launcher_path(), launcher_text()), *shim_files().items()] if not same(p, t)]
|
|
206
|
+
if stale:
|
|
207
|
+
old = [p.name for p in stale if p.exists() and not is_ours(p)]
|
|
208
|
+
add(BAD, "launcher · 터미널 shim", (f"예전 복사본: {', '.join(old)}. " if old else "") +
|
|
209
|
+
f"없거나 낡았다: {', '.join(p.name for p in stale)} → doctor.py fix claude-switch")
|
|
210
|
+
else:
|
|
211
|
+
add(OK, "launcher · 터미널 shim", str(local_bin()))
|
|
212
|
+
on_path = str(local_bin()).lower() in [p.lower().rstrip("\\/") for p in os.environ.get("PATH", "").split(os.pathsep)]
|
|
213
|
+
add(OK if on_path else OPT, f"{local_bin()} 이 PATH 에 있다", "" if on_path else
|
|
214
|
+
("시스템 환경 변수 PATH 에 더한다" if WIN else 'export PATH="$HOME/.local/bin:$PATH"'))
|
|
215
|
+
sl = current_statusline()
|
|
216
|
+
want = statusline_command()
|
|
217
|
+
add(OK if sl == want else BAD, "statusLine → thuthi statusline", "" if sl == want else
|
|
218
|
+
f"지금: {sl or '없음'} → doctor.py fix statusline")
|
|
219
|
+
if WIN:
|
|
220
|
+
import credstore
|
|
221
|
+
add(OK, "자격증명 저장소", credstore.active_store().label)
|
|
222
|
+
return rows
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def refresh_launcher() -> bool:
|
|
226
|
+
"""이미 깔린 launcher 가 우리 것(MARK)인데 내용이 낡았으면 지금 판으로 다시 쓴다. Stop 훅(--sync-hook)이 턴마다 부른다.
|
|
227
|
+
shim 에는 python · launcher 경로만 들어 있어 그대로 두면 되고, 플러그인 이름 · 찾는 법은 launcher 에만 있다.
|
|
228
|
+
launcher 가 없으면 (setup 을 안 한 PC) 아무것도 하지 않는다."""
|
|
229
|
+
p = launcher_path()
|
|
230
|
+
text = launcher_text()
|
|
231
|
+
if not p.is_file() or not is_ours(p) or same(p, text):
|
|
232
|
+
return False
|
|
233
|
+
us.write_atomic(p, text)
|
|
234
|
+
return True
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def install_shims() -> int:
|
|
238
|
+
us.write_atomic(launcher_path(), launcher_text())
|
|
239
|
+
print(f"launcher: {launcher_path()}")
|
|
240
|
+
keep = us.state_dir() / "replaced" / time.strftime("%Y%m%d-%H%M%S")
|
|
241
|
+
# 예전 install.sh 가 둔 복사본은 PATH 밖으로 옮겨 둔다 (지우지 않는다)
|
|
242
|
+
for p in [*shim_files(), local_bin() / "claude-switch-tui.py"]:
|
|
243
|
+
if (p.exists() or p.is_symlink()) and not is_ours(p):
|
|
244
|
+
keep.mkdir(parents=True, exist_ok=True)
|
|
245
|
+
shutil.move(str(p), str(keep / p.name))
|
|
246
|
+
print(f"옮김: {p} → {keep / p.name}")
|
|
247
|
+
for p, text in shim_files().items():
|
|
248
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
249
|
+
with open(p, "w", encoding="utf-8", newline="") as f:
|
|
250
|
+
f.write(text)
|
|
251
|
+
p.chmod(0o755)
|
|
252
|
+
print(f"shim: {p}")
|
|
253
|
+
return 0
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def install_statusline() -> int:
|
|
257
|
+
f = settings_path()
|
|
258
|
+
try:
|
|
259
|
+
settings = json.loads(f.read_text(encoding="utf-8")) if f.exists() else {}
|
|
260
|
+
except ValueError as e:
|
|
261
|
+
print(f"{f} 를 JSON 으로 못 읽었다: {e}", file=sys.stderr)
|
|
262
|
+
return 1
|
|
263
|
+
want = statusline_command()
|
|
264
|
+
old = settings.get("statusLine") or {}
|
|
265
|
+
if old.get("command") == want:
|
|
266
|
+
print(f"이미 쓴다: {want}")
|
|
267
|
+
return 0
|
|
268
|
+
if f.exists():
|
|
269
|
+
bak = f.with_name(f"settings.json.bak-thuthi-{time.strftime('%Y%m%d-%H%M%S')}")
|
|
270
|
+
shutil.copy2(f, bak)
|
|
271
|
+
print(f"백업: {bak}")
|
|
272
|
+
print(f"이전 statusLine: {json.dumps(old, ensure_ascii=False) if old else '없음'}")
|
|
273
|
+
settings["statusLine"] = {**old, "type": "command", "command": want, "refreshInterval": old.get("refreshInterval", 60)}
|
|
274
|
+
us.write_atomic(f, json.dumps(settings, ensure_ascii=False, indent=2) + "\n")
|
|
275
|
+
print(f"새 statusLine: {json.dumps(settings['statusLine'], ensure_ascii=False)}")
|
|
276
|
+
if not same(launcher_path(), launcher_text()):
|
|
277
|
+
print("주의: launcher 가 아직 없다. doctor.py fix claude-switch 를 먼저 한다.")
|
|
278
|
+
return 0
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def main(argv: list) -> int:
|
|
282
|
+
try:
|
|
283
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
284
|
+
except (AttributeError, ValueError):
|
|
285
|
+
pass
|
|
286
|
+
what = argv[0] if argv else "check"
|
|
287
|
+
if what == "check":
|
|
288
|
+
rows = status()
|
|
289
|
+
for m, item, note in rows:
|
|
290
|
+
print(f"{m} {item}" + (f" · {note}" if note else ""))
|
|
291
|
+
return 1 if any(r[0] == BAD for r in rows) else 0
|
|
292
|
+
if what == "shims":
|
|
293
|
+
return install_shims()
|
|
294
|
+
if what == "statusline":
|
|
295
|
+
return install_statusline()
|
|
296
|
+
print(__doc__)
|
|
297
|
+
return 2
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
if __name__ == "__main__":
|
|
301
|
+
sys.exit(main(sys.argv[1:]))
|