@hivey/cli 0.0.0-stage → 0.9.36
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/README.md +235 -2
- package/bin/hivey.js +98 -0
- package/native/darwin-arm64/hivey +0 -0
- package/package.json +36 -4
- package/platforms.json +3 -0
- package/repo/LICENSE +201 -0
- package/repo/NOTICE +18 -0
- package/repo/README.md +148 -0
- package/repo/install.sh +365 -0
- package/repo/pets/README.md +25 -0
- package/repo/pets/hivey-dot/CLAUDE.md +55 -0
- package/repo/pets/hivey-dot/build.sh +34 -0
- package/repo/pets/hivey-dot/main.swift +750 -0
- package/repo/pets/hivey-h/CLAUDE.md +75 -0
- package/repo/pets/hivey-h/build.sh +34 -0
- package/repo/pets/hivey-h/main.swift +739 -0
- package/repo/pets/hivey-prompt/CLAUDE.md +59 -0
- package/repo/pets/hivey-prompt/build.sh +34 -0
- package/repo/pets/hivey-prompt/main.swift +691 -0
- package/repo/pets/pet.py +288 -0
- package/repo/pets/shared/HiveyWatch.swift +437 -0
- package/repo/pets/test_pet.py +122 -0
- package/repo/plugins/README.md +108 -0
- package/repo/plugins/agent-creator/herdr-plugin.toml +17 -0
- package/repo/plugins/dashboard/dashboard.py +507 -0
- package/repo/plugins/dashboard/herdr-plugin.toml +14 -0
- package/repo/plugins/dashboard/test_dashboard.py +134 -0
- package/repo/plugins/github/github.py +261 -0
- package/repo/plugins/github/herdr-plugin.toml +14 -0
- package/repo/plugins/github/test_github.py +49 -0
- package/repo/plugins/skills/herdr-plugin.toml +11 -0
- package/repo/plugins/skills/skills.md +41 -0
- package/repo/plugins/slack-relay/connect.py +198 -0
- package/repo/plugins/slack-relay/create_channel.py +134 -0
- package/repo/plugins/slack-relay/herdr-plugin.toml +15 -0
- package/repo/plugins/slack-relay/relay.py +401 -0
- package/repo/plugins/slack-relay/slack-app-manifest.json +30 -0
- package/repo/plugins/slack-relay/test_connect.py +66 -0
- package/repo/plugins/slack-relay/test_create_channel.py +61 -0
- package/repo/plugins/slack-relay/test_relay.py +254 -0
- package/repo/plugins/swarm-creator/herdr-plugin.toml +17 -0
- package/repo/plugins/swarm-watcher/dashboard.py +333 -0
- package/repo/plugins/swarm-watcher/herdr-plugin.toml +16 -0
- package/repo/plugins/swarm-watcher/usage.py +129 -0
- package/repo/plugins/swarm-watcher/watcher.py +191 -0
- package/repo/plugins/team-template/herdr-plugin.toml +15 -0
- package/repo/plugins/team-template/setup.py +211 -0
- package/repo/plugins/team-template/test_setup.py +73 -0
- package/repo/plugins/tts/herdr-plugin.toml +15 -0
- package/repo/skills/herdr/SKILL.md +214 -0
- package/repo/skills/hivey/SKILL.md +322 -0
- package/repo/skills/hivey/scripts/handoff.py +27 -0
- package/repo/skills/hivey/scripts/new_wiki.py +143 -0
- package/repo/skills/hivey-agent-creator/SKILL.md +303 -0
- package/repo/skills/hivey-agent-creator/references/agent-claude-md.md +256 -0
- package/repo/skills/hivey-agent-creator/references/global-guidelines.md +67 -0
- package/repo/skills/hivey-agent-creator/references/reviewer-agent.md +35 -0
- package/repo/skills/hivey-agent-creator/scripts/agent_context.py +76 -0
- package/repo/skills/hivey-agent-creator/scripts/agent_gate.py +78 -0
- package/repo/skills/hivey-agent-creator/scripts/setup_agent.py +288 -0
- package/repo/skills/hivey-agy/SKILL.md +123 -0
- package/repo/skills/hivey-agy/references/gemini-prompting.md +134 -0
- package/repo/skills/hivey-agy/scripts/agy_run.py +146 -0
- package/repo/skills/hivey-codex/SKILL.md +66 -0
- package/repo/skills/hivey-context7/SKILL.md +56 -0
- package/repo/skills/hivey-create-wiki/SKILL.md +329 -0
- package/repo/skills/hivey-grok/SKILL.md +101 -0
- package/repo/skills/hivey-grok/scripts/grok_run.py +139 -0
- package/repo/skills/hivey-swarm-creator/SKILL.md +384 -0
- package/repo/skills/hivey-swarm-creator/references/agent-claude-md.md +313 -0
- package/repo/skills/hivey-swarm-creator/references/archify-report.md +24 -0
- package/repo/skills/hivey-swarm-creator/references/dashboard.md +46 -0
- package/repo/skills/hivey-swarm-creator/references/retrospective.md +23 -0
- package/repo/skills/hivey-swarm-creator/references/shared-rules.md +39 -0
- package/repo/skills/hivey-swarm-creator/references/wiki-memory.md +30 -0
- package/repo/skills/hivey-swarm-creator/scripts/setup_agent.py +76 -0
- package/repo/skills/hivey-swarm-creator/scripts/shared_rules.py +50 -0
- package/repo/skills/hivey-swarm-creator/scripts/swarm_tasks.py +171 -0
- package/repo/skills/hivey-wiki-ingest/SKILL.md +45 -0
- package/repo/skills/hivey-wiki-lint/SKILL.md +38 -0
- package/repo/skills/hivey-wiki-list/SKILL.md +46 -0
- package/repo/skills/hivey-wiki-log/SKILL.md +45 -0
- package/repo/skills/hivey-wiki-query/SKILL.md +44 -0
package/repo/pets/pet.py
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""hivey pets: choose, build, start, switch and turn off the desktop pet (macOS).
|
|
3
|
+
|
|
4
|
+
usage: pet.py [status] the chosen pet, running or not, and the pets to choose from
|
|
5
|
+
pet.py list [--json] the pets
|
|
6
|
+
pet.py use <id> build (when needed), install and start it; the other pets
|
|
7
|
+
are quit
|
|
8
|
+
pet.py show start the chosen pet if it isn't running (hivey runs it when
|
|
9
|
+
a hivey window opens; the pet quits itself when the last
|
|
10
|
+
hivey window closes)
|
|
11
|
+
pet.py off quit the pet and stop opening it at login
|
|
12
|
+
pet.py choose pick one interactively (install.sh, the ⌥P popup)
|
|
13
|
+
pet.py refresh rebuild and restart the chosen pet if its source changed
|
|
14
|
+
(hivey update runs it)
|
|
15
|
+
|
|
16
|
+
Run through `hivey pet …` (which sets HIVEY_BIN). Each pet lives in pets/<id>/ (main.swift,
|
|
17
|
+
build.sh) and shares pets/shared/HiveyWatch.swift; it is built into its folder and installed
|
|
18
|
+
to ~/Applications. The choice is kept in ~/.hivey/pet.json ({"pet": "<id>"} or {"pet": null}).
|
|
19
|
+
"""
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import platform
|
|
23
|
+
import shutil
|
|
24
|
+
import signal
|
|
25
|
+
import subprocess
|
|
26
|
+
import sys
|
|
27
|
+
import time
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
HERE = Path(__file__).resolve().parent
|
|
31
|
+
PETS = {
|
|
32
|
+
"hivey-h": {"name": "Hivey", "app": "Hivey.app", "bundle": "com.hivey.h",
|
|
33
|
+
"about": "a living 3D H: its sections slide apart to hand out work"},
|
|
34
|
+
"hivey-dot": {"name": "Hivey System", "app": "Hivey System.app", "bundle": "com.hivey.pet",
|
|
35
|
+
"about": "a graphite dot; its mint agents ride a signal wave around it"},
|
|
36
|
+
"hivey-prompt": {"name": "Hivey Prompt", "app": "Hivey Prompt.app", "bundle": "com.hivey.prompt",
|
|
37
|
+
"about": "a >_ terminal sphere leading three agent spheres"},
|
|
38
|
+
}
|
|
39
|
+
ORDER = ["hivey-h", "hivey-dot", "hivey-prompt"]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def home():
|
|
43
|
+
return Path(os.environ.get("HOME", str(Path.home())))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def choice_path():
|
|
47
|
+
return home() / ".hivey" / "pet.json"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def apps_dir():
|
|
51
|
+
return Path(os.environ.get("HIVEY_PETS_APPS", str(home() / "Applications")))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def launch_agent(pet):
|
|
55
|
+
return home() / "Library" / "LaunchAgents" / f"{PETS[pet]['bundle']}.plist"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def installed_app(pet):
|
|
59
|
+
return apps_dir() / PETS[pet]["app"]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def chosen():
|
|
63
|
+
try:
|
|
64
|
+
return json.loads(choice_path().read_text()).get("pet")
|
|
65
|
+
except (OSError, json.JSONDecodeError, AttributeError):
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def save_choice(pet):
|
|
70
|
+
choice_path().parent.mkdir(parents=True, exist_ok=True)
|
|
71
|
+
choice_path().write_text(json.dumps({"pet": pet}) + "\n")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def pids(pet):
|
|
75
|
+
"""Processes whose executable is this pet's app. `pgrep -a` also searches our ancestors: a
|
|
76
|
+
switch from a pet's menu runs as that pet's child, and macOS pgrep skips ancestors by
|
|
77
|
+
default. Matching the executable (`ps -o comm=`), not the command line, keeps a shell whose
|
|
78
|
+
command merely mentions the app from ever matching."""
|
|
79
|
+
marker = f"{PETS[pet]['app']}/Contents/MacOS/"
|
|
80
|
+
found = subprocess.run(["pgrep", "-a", "-f", marker], capture_output=True, text=True)
|
|
81
|
+
result = []
|
|
82
|
+
for pid in found.stdout.split():
|
|
83
|
+
comm = subprocess.run(["ps", "-o", "comm=", "-p", pid], capture_output=True, text=True)
|
|
84
|
+
if marker in comm.stdout:
|
|
85
|
+
result.append(int(pid))
|
|
86
|
+
return result
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def running(pet):
|
|
90
|
+
return bool(pids(pet))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def sources(pet):
|
|
94
|
+
return [HERE / pet / "main.swift", HERE / pet / "build.sh", HERE / "shared" / "HiveyWatch.swift"]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def outdated(pet):
|
|
98
|
+
"""True when the installed app is missing or older than its source."""
|
|
99
|
+
app = installed_app(pet) / "Contents" / "MacOS"
|
|
100
|
+
if not app.is_dir():
|
|
101
|
+
return True
|
|
102
|
+
built = min((f.stat().st_mtime for f in app.iterdir()), default=0)
|
|
103
|
+
return any(src.stat().st_mtime > built for src in sources(pet) if src.exists())
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def check_mac():
|
|
107
|
+
if platform.system() != "Darwin":
|
|
108
|
+
raise SystemExit("hivey pets are macOS apps; this is " + platform.system())
|
|
109
|
+
if not shutil.which("swiftc"):
|
|
110
|
+
raise SystemExit("building a pet needs Swift: install Apple's command line tools "
|
|
111
|
+
"(xcode-select --install), then try again")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def build(pet):
|
|
115
|
+
print(f"building {PETS[pet]['name']} (about a minute)…", flush=True)
|
|
116
|
+
log = Path(os.environ.get("TMPDIR", "/tmp").rstrip("/")) / f"hivey-pet-{pet}.log"
|
|
117
|
+
with open(log, "w") as out:
|
|
118
|
+
done = subprocess.run(["bash", str(HERE / pet / "build.sh")], stdout=out, stderr=out)
|
|
119
|
+
if done.returncode != 0:
|
|
120
|
+
tail = log.read_text().strip().splitlines()[-8:]
|
|
121
|
+
raise SystemExit("\n".join(tail) + f"\nbuilding {PETS[pet]['name']} failed (log: {log})")
|
|
122
|
+
apps_dir().mkdir(parents=True, exist_ok=True)
|
|
123
|
+
target = installed_app(pet)
|
|
124
|
+
if target.exists():
|
|
125
|
+
shutil.rmtree(target)
|
|
126
|
+
# ditto keeps the ad-hoc signature intact
|
|
127
|
+
subprocess.run(["ditto", str(HERE / pet / PETS[pet]["app"]), str(target)], check=True)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def quit_pet(pet):
|
|
131
|
+
"""Quit with a signal, not AppleScript: a switch started from a pet's own menu runs inside
|
|
132
|
+
that app, and macOS may block (or silently ask about) one app scripting another."""
|
|
133
|
+
for sig, tries in ((signal.SIGTERM, 15), (signal.SIGKILL, 10)):
|
|
134
|
+
targets = pids(pet)
|
|
135
|
+
if not targets:
|
|
136
|
+
return
|
|
137
|
+
for pid in targets:
|
|
138
|
+
try:
|
|
139
|
+
os.kill(pid, sig)
|
|
140
|
+
except ProcessLookupError:
|
|
141
|
+
pass
|
|
142
|
+
for _ in range(tries):
|
|
143
|
+
if not running(pet):
|
|
144
|
+
return
|
|
145
|
+
time.sleep(0.2)
|
|
146
|
+
print(f"could not quit {PETS[pet]['name']}", file=sys.stderr)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def set_login(pet, on):
|
|
150
|
+
plist = launch_agent(pet)
|
|
151
|
+
if not on:
|
|
152
|
+
plist.unlink(missing_ok=True)
|
|
153
|
+
return
|
|
154
|
+
plist.parent.mkdir(parents=True, exist_ok=True)
|
|
155
|
+
plist.write_text(f"""<?xml version="1.0" encoding="UTF-8"?>
|
|
156
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
157
|
+
<plist version="1.0">
|
|
158
|
+
<dict>
|
|
159
|
+
<key>Label</key><string>{PETS[pet]['bundle']}</string>
|
|
160
|
+
<key>ProgramArguments</key>
|
|
161
|
+
<array><string>/usr/bin/open</string><string>-a</string><string>{installed_app(pet)}</string></array>
|
|
162
|
+
<key>RunAtLoad</key><true/>
|
|
163
|
+
</dict>
|
|
164
|
+
</plist>
|
|
165
|
+
""")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def use(pet):
|
|
169
|
+
if pet not in PETS:
|
|
170
|
+
raise SystemExit(f"no pet {pet!r}: choose one of {', '.join(ORDER)} (or: hivey pet off)")
|
|
171
|
+
check_mac()
|
|
172
|
+
if outdated(pet):
|
|
173
|
+
build(pet)
|
|
174
|
+
for other in ORDER:
|
|
175
|
+
# Pets come and go with hivey now: no login items (older versions added them)
|
|
176
|
+
set_login(other, False)
|
|
177
|
+
if other != pet:
|
|
178
|
+
quit_pet(other)
|
|
179
|
+
quit_pet(pet) # a rebuilt pet restarts with the new code
|
|
180
|
+
subprocess.run(["open", "-a", str(installed_app(pet))], check=True)
|
|
181
|
+
save_choice(pet)
|
|
182
|
+
print(f"{PETS[pet]['name']} is your pet: it shows while hivey is open (change it: hivey pet)")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def show():
|
|
186
|
+
"""Start the chosen pet if it isn't running; quiet when there is nothing to do."""
|
|
187
|
+
pet = chosen()
|
|
188
|
+
if pet not in PETS or platform.system() != "Darwin" or running(pet):
|
|
189
|
+
return
|
|
190
|
+
if outdated(pet):
|
|
191
|
+
if not shutil.which("swiftc"):
|
|
192
|
+
return
|
|
193
|
+
build(pet)
|
|
194
|
+
subprocess.run(["open", "-g", "-a", str(installed_app(pet))], check=False)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def off():
|
|
198
|
+
for pet in ORDER:
|
|
199
|
+
quit_pet(pet)
|
|
200
|
+
set_login(pet, False)
|
|
201
|
+
save_choice(None)
|
|
202
|
+
print("pet turned off (back any time: hivey pet use <id>, or hivey pet choose)")
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def status():
|
|
206
|
+
current = chosen()
|
|
207
|
+
if current in PETS:
|
|
208
|
+
state = "running" if running(current) else "shows when a hivey window is open"
|
|
209
|
+
print(f"pet: {PETS[current]['name']} ({current}), {state}")
|
|
210
|
+
else:
|
|
211
|
+
print("pet: none")
|
|
212
|
+
print_list(current)
|
|
213
|
+
print("\nhivey pet use <id> · hivey pet off · hivey pet choose")
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def print_list(current):
|
|
217
|
+
for pet in ORDER:
|
|
218
|
+
mark = "●" if pet == current else " "
|
|
219
|
+
print(f" {mark} {pet:<13} {PETS[pet]['name']:<13} {PETS[pet]['about']}")
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def choose():
|
|
223
|
+
current = chosen()
|
|
224
|
+
print("Choose your hivey pet (it lives on your desktop and acts out what your agents do):\n")
|
|
225
|
+
for n, pet in enumerate(ORDER, 1):
|
|
226
|
+
mark = " (current)" if pet == current else ""
|
|
227
|
+
print(f" {n}. {PETS[pet]['name']:<13} {PETS[pet]['about']}{mark}")
|
|
228
|
+
print(" 0. No pet")
|
|
229
|
+
keep = "keep the current one" if current in PETS else "no pet"
|
|
230
|
+
try:
|
|
231
|
+
answer = input(f"\nNumber (Enter: {keep}): ").strip()
|
|
232
|
+
except (EOFError, KeyboardInterrupt):
|
|
233
|
+
print()
|
|
234
|
+
return 1
|
|
235
|
+
if not answer:
|
|
236
|
+
print("unchanged")
|
|
237
|
+
return 0
|
|
238
|
+
if answer == "0":
|
|
239
|
+
off()
|
|
240
|
+
return 0
|
|
241
|
+
if answer.isdigit() and 1 <= int(answer) <= len(ORDER):
|
|
242
|
+
use(ORDER[int(answer) - 1])
|
|
243
|
+
return 0
|
|
244
|
+
print(f"{answer!r} is not one of the numbers; nothing changed")
|
|
245
|
+
return 1
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def refresh():
|
|
249
|
+
pet = chosen()
|
|
250
|
+
if pet not in PETS or platform.system() != "Darwin" or not outdated(pet):
|
|
251
|
+
return
|
|
252
|
+
if not shutil.which("swiftc"):
|
|
253
|
+
print("pet: its source changed, but Swift is missing to rebuild it")
|
|
254
|
+
return
|
|
255
|
+
use(pet)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def main(argv):
|
|
259
|
+
command = argv[0] if argv else "status"
|
|
260
|
+
if command in ("-h", "--help", "help"):
|
|
261
|
+
print(__doc__.split("\n\n")[1])
|
|
262
|
+
return 0
|
|
263
|
+
if command == "status":
|
|
264
|
+
status()
|
|
265
|
+
elif command == "list":
|
|
266
|
+
if "--json" in argv:
|
|
267
|
+
print(json.dumps({"current": chosen(), "pets": [
|
|
268
|
+
{"id": pet, **{k: PETS[pet][k] for k in ("name", "about")}} for pet in ORDER]}))
|
|
269
|
+
else:
|
|
270
|
+
print_list(chosen())
|
|
271
|
+
elif command == "use" and len(argv) == 2:
|
|
272
|
+
use(argv[1])
|
|
273
|
+
elif command == "off":
|
|
274
|
+
off()
|
|
275
|
+
elif command == "show":
|
|
276
|
+
show()
|
|
277
|
+
elif command == "choose":
|
|
278
|
+
return choose()
|
|
279
|
+
elif command == "refresh":
|
|
280
|
+
refresh()
|
|
281
|
+
else:
|
|
282
|
+
print(__doc__.split("\n\n")[1], file=sys.stderr)
|
|
283
|
+
return 2
|
|
284
|
+
return 0
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
if __name__ == "__main__":
|
|
288
|
+
sys.exit(main(sys.argv[1:]))
|