hermes-pilot 0.0.0-stage → 0.2.2
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/LICENSE +21 -0
- package/README.ja.md +419 -0
- package/README.md +428 -2
- package/__init__.py +15 -0
- package/apps/bridge/src/api-errors.js +165 -0
- package/apps/bridge/src/architect.js +1298 -0
- package/apps/bridge/src/auth.js +202 -0
- package/apps/bridge/src/capabilities.js +256 -0
- package/apps/bridge/src/capture.js +145 -0
- package/apps/bridge/src/chat-profile.js +95 -0
- package/apps/bridge/src/config.js +73 -0
- package/apps/bridge/src/discord.js +89 -0
- package/apps/bridge/src/gitinfo.js +211 -0
- package/apps/bridge/src/hermes.js +97 -0
- package/apps/bridge/src/inbox.js +347 -0
- package/apps/bridge/src/kanban.js +361 -0
- package/apps/bridge/src/lang.js +60 -0
- package/apps/bridge/src/live.js +285 -0
- package/apps/bridge/src/memos.js +150 -0
- package/apps/bridge/src/ops.js +201 -0
- package/apps/bridge/src/pair-codes.js +125 -0
- package/apps/bridge/src/pipeline-optimizer.js +513 -0
- package/apps/bridge/src/pipeline-watcher.js +1022 -0
- package/apps/bridge/src/qr.js +808 -0
- package/apps/bridge/src/repos.js +544 -0
- package/apps/bridge/src/review-watcher.js +271 -0
- package/apps/bridge/src/review.js +1749 -0
- package/apps/bridge/src/search.js +162 -0
- package/apps/bridge/src/server.js +1745 -0
- package/apps/bridge/src/snippets.js +373 -0
- package/apps/bridge/src/specs.js +806 -0
- package/apps/bridge/src/tail.js +28 -0
- package/apps/bridge/src/telemetry.js +667 -0
- package/apps/bridge/src/term-snippets.js +228 -0
- package/apps/bridge/src/transcript.js +231 -0
- package/apps/bridge/src/usage.js +294 -0
- package/apps/bridge/src/workerFeed.js +72 -0
- package/apps/dashboard/index.js +2014 -0
- package/apps/dashboard/manifest.json +14 -0
- package/apps/dashboard/pilot_dashboard.py +1466 -0
- package/apps/dashboard/plugin_api.py +237 -0
- package/apps/dashboard/plugin_init.py +15 -0
- package/apps/dashboard/style.css +928 -0
- package/apps/web/dist/assets/TermPane-DYP7pi_n.css +32 -0
- package/apps/web/dist/assets/TermPane-q4f5Zu0I.js +12 -0
- package/apps/web/dist/assets/index-BzUof8lw.js +94 -0
- package/apps/web/dist/assets/index-DwZdbPU7.css +1 -0
- package/apps/web/dist/favicon.ico +0 -0
- package/apps/web/dist/icon-180-v6.png +0 -0
- package/apps/web/dist/icon-192-v6.png +0 -0
- package/apps/web/dist/icon-512-v6.png +0 -0
- package/apps/web/dist/icon-maskable-192-v6.png +0 -0
- package/apps/web/dist/icon-maskable-512-v6.png +0 -0
- package/apps/web/dist/icon-v6.svg +15 -0
- package/apps/web/dist/index.html +21 -0
- package/apps/web/dist/manifest.webmanifest +49 -0
- package/apps/web/dist/sw.js +69 -0
- package/bin/hermes-pilot.mjs +964 -0
- package/dashboard/dist/index.js +2014 -0
- package/dashboard/dist/style.css +928 -0
- package/dashboard/manifest.json +14 -0
- package/dashboard/pilot_dashboard.py +1466 -0
- package/dashboard/plugin_api.py +237 -0
- package/package.json +75 -4
- package/plugin.json +70 -0
- package/plugin.yaml +4 -0
- package/scripts/deploy.mjs +58 -0
- package/scripts/migrate-to-hermes-pilot.mjs +472 -0
- package/scripts/postinstall.mjs +32 -0
- package/scripts/sync-dashboard.mjs +98 -0
- package/skills/annotation/SKILL.md +138 -0
- package/skills/quick-review/SKILL.md +200 -0
- package/skills/quick-review/assets/sheet-template.html +175 -0
- package/skills/spec-architect/SKILL.md +226 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"""FastAPI routes for the Hermes Pilot tab on the standard dashboard.
|
|
2
|
+
|
|
3
|
+
The dashboard imports this file from disk without adding ``dashboard/`` to
|
|
4
|
+
``sys.path`` (``hermes_cli/web_server_dashboard.py`` → ``import_user_code``), so
|
|
5
|
+
the sibling logic module is loaded explicitly under a unique name instead of a
|
|
6
|
+
bare ``import pilot_dashboard``. That keeps a generic module name from colliding
|
|
7
|
+
with anything else in the dashboard process.
|
|
8
|
+
|
|
9
|
+
All routes are plain ``def`` so FastAPI runs them in its threadpool (the bridge
|
|
10
|
+
calls are blocking ``urllib``). Paths are relative: the host mounts this router
|
|
11
|
+
at ``/api/plugins/hermes-pilot``.
|
|
12
|
+
|
|
13
|
+
Response contract
|
|
14
|
+
-----------------
|
|
15
|
+
``GET /status`` → ``{ok, service:{manager,unit,state}, port, dataDir, lanUrl,
|
|
16
|
+
tailscaleUrl, bridge:{reachable,version}, capabilities}``
|
|
17
|
+
``GET /pairing`` → ``{ok, qrPng, targets, expiresAt, port, tlsPort, tailscale}``
|
|
18
|
+
``GET /config`` → ``{ok, config, dataDir, scanDirsSource, reposPath}``
|
|
19
|
+
``PUT /config`` → ``{ok, config, sync?}`` or ``400 {ok:false, code:"INVALID_CONFIG",
|
|
20
|
+
errors:{field:code}, messages:{field:text}}``
|
|
21
|
+
``POST /service/{install|restart|status}`` → ``{ok, action, code, stdout}``
|
|
22
|
+
``GET /repos`` → ``{ok, source:"bridge"|"file", repos, scanDirs}``
|
|
23
|
+
``POST /repos`` → ``{ok, action, repos, scanDirs}`` (``add|hide|unhide|pin|unpin|createBoard``)
|
|
24
|
+
``GET /snippets?kind=chat|term&lang=en|ja`` → ``{ok, source, kind, lang, allSnippets, custom, ...}``
|
|
25
|
+
``PUT /snippets?kind=…&lang=…`` → same shape, after saving
|
|
26
|
+
``GET /logs?file=gateway|errors|pilot|audit&lines=120`` → ``{ok, file, lines, shown, missing, path}``
|
|
27
|
+
|
|
28
|
+
The app token is never part of any response — see ``pilot_dashboard.redact``.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
import importlib.util
|
|
34
|
+
import sys
|
|
35
|
+
from pathlib import Path
|
|
36
|
+
from typing import Any, Optional
|
|
37
|
+
|
|
38
|
+
from fastapi import APIRouter, Body, Query
|
|
39
|
+
from fastapi.responses import JSONResponse
|
|
40
|
+
|
|
41
|
+
_DIR = Path(__file__).resolve().parent
|
|
42
|
+
_LOGIC_MODULE = "hermes_dashboard_hermes_pilot_logic"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _load_logic() -> Any:
|
|
46
|
+
"""Load ``pilot_dashboard.py`` as a uniquely named module (idempotent)."""
|
|
47
|
+
existing = sys.modules.get(_LOGIC_MODULE)
|
|
48
|
+
if existing is not None:
|
|
49
|
+
return existing
|
|
50
|
+
spec = importlib.util.spec_from_file_location(_LOGIC_MODULE, _DIR / "pilot_dashboard.py")
|
|
51
|
+
if spec is None or spec.loader is None: # pragma: no cover - defensive
|
|
52
|
+
raise ImportError(f"hermes-pilot: cannot load logic from {_DIR}")
|
|
53
|
+
module = importlib.util.module_from_spec(spec)
|
|
54
|
+
sys.modules[_LOGIC_MODULE] = module
|
|
55
|
+
try:
|
|
56
|
+
spec.loader.exec_module(module)
|
|
57
|
+
except Exception: # pragma: no cover - keep sys.modules clean on failure
|
|
58
|
+
sys.modules.pop(_LOGIC_MODULE, None)
|
|
59
|
+
raise
|
|
60
|
+
return module
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
logic = _load_logic()
|
|
64
|
+
|
|
65
|
+
VERSION = "0.1.0"
|
|
66
|
+
router = APIRouter()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def fail(status: int, code: str, message: str, detail: Any = None) -> JSONResponse:
|
|
70
|
+
"""Machine-readable error envelope (SPEC §6.3: ``code`` + English message)."""
|
|
71
|
+
body: dict[str, Any] = {"ok": False, "code": code, "error": message}
|
|
72
|
+
if detail is not None:
|
|
73
|
+
body["detail"] = detail
|
|
74
|
+
return JSONResponse(body, status_code=status)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@router.get("/status")
|
|
78
|
+
def get_status() -> Any:
|
|
79
|
+
"""Service + port + bridge reachability + capabilities. Never carries the token."""
|
|
80
|
+
try:
|
|
81
|
+
return logic.build_status()
|
|
82
|
+
except Exception as exc: # health: surface the reason instead of a 500 traceback
|
|
83
|
+
return fail(500, "STATUS_FAILED", str(exc))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@router.get("/pairing")
|
|
87
|
+
def get_pairing() -> Any:
|
|
88
|
+
"""Proxy the bridge's one-time pairing code as a PNG QR the browser can show."""
|
|
89
|
+
try:
|
|
90
|
+
return logic.build_pairing()
|
|
91
|
+
except logic.BridgeUnavailable as exc:
|
|
92
|
+
return fail(502, "BRIDGE_UNREACHABLE", str(exc))
|
|
93
|
+
except Exception as exc:
|
|
94
|
+
return fail(500, "PAIRING_FAILED", str(exc))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@router.get("/config")
|
|
98
|
+
def get_config() -> Any:
|
|
99
|
+
"""Current config, with ``repos.json``'s ``scanDirs`` as the source of truth (G3)."""
|
|
100
|
+
return logic.build_config()
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@router.put("/config")
|
|
104
|
+
def put_config(payload: Optional[dict] = Body(default=None)) -> Any:
|
|
105
|
+
"""Validate then write atomically (tmp → rename, 0600).
|
|
106
|
+
|
|
107
|
+
A partial body is merged onto the current file, so the tab can save one field
|
|
108
|
+
without shipping the whole document back. When ``scanDirs`` changes it is
|
|
109
|
+
pushed to the bridge and ``repos.json`` in the same request (G3).
|
|
110
|
+
"""
|
|
111
|
+
paths = logic.resolve_paths()
|
|
112
|
+
current = logic.build_config(paths)["config"]
|
|
113
|
+
merged: dict[str, Any] = dict(current)
|
|
114
|
+
if isinstance(payload, dict):
|
|
115
|
+
merged.update(payload)
|
|
116
|
+
result = logic.validate_config(merged)
|
|
117
|
+
if not result["ok"]:
|
|
118
|
+
return JSONResponse(
|
|
119
|
+
{
|
|
120
|
+
"ok": False,
|
|
121
|
+
"code": "INVALID_CONFIG",
|
|
122
|
+
"errors": result["errors"],
|
|
123
|
+
"messages": result["messages"],
|
|
124
|
+
},
|
|
125
|
+
status_code=400,
|
|
126
|
+
)
|
|
127
|
+
try:
|
|
128
|
+
logic.write_config_atomic(paths["configPath"], result["value"])
|
|
129
|
+
except OSError as exc:
|
|
130
|
+
return fail(500, "WRITE_FAILED", str(exc))
|
|
131
|
+
body: dict[str, Any] = {"ok": True, "config": logic.build_config(paths)["config"]}
|
|
132
|
+
if isinstance(payload, dict) and "scanDirs" in payload:
|
|
133
|
+
try:
|
|
134
|
+
body["sync"] = logic.sync_scan_dirs(paths, result["value"].get("scanDirs"))
|
|
135
|
+
except OSError as exc:
|
|
136
|
+
body["sync"] = {"ok": False, "error": f"repos.json could not be written: {exc}"}
|
|
137
|
+
return body
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@router.get("/repos")
|
|
141
|
+
def get_repos() -> Any:
|
|
142
|
+
"""Merged repository list + ``scanDirs`` (bridge when up, ``repos.json`` when not)."""
|
|
143
|
+
try:
|
|
144
|
+
return logic.build_repos()
|
|
145
|
+
except Exception as exc: # health: surface the reason instead of a 500 traceback
|
|
146
|
+
return fail(500, "REPOS_FAILED", str(exc))
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@router.post("/repos")
|
|
150
|
+
def post_repos(payload: Optional[dict] = Body(default=None)) -> Any:
|
|
151
|
+
"""``add|hide|unhide|pin|unpin|createBoard`` — then return the fresh list."""
|
|
152
|
+
try:
|
|
153
|
+
result = logic.repos_action(payload=payload)
|
|
154
|
+
except Exception as exc:
|
|
155
|
+
return fail(500, "REPOS_FAILED", str(exc))
|
|
156
|
+
if not result.get("ok"):
|
|
157
|
+
return JSONResponse(result, status_code=400)
|
|
158
|
+
return result
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
@router.get("/snippets")
|
|
162
|
+
def get_snippets(
|
|
163
|
+
kind: str = Query("chat", pattern="^(chat|term)$"),
|
|
164
|
+
lang: str = Query("en", pattern="^(en|ja)$"),
|
|
165
|
+
) -> Any:
|
|
166
|
+
"""Chat/terminal snippets through the bridge, or the saved store when it is down."""
|
|
167
|
+
try:
|
|
168
|
+
return logic.build_snippets(kind=kind, lang=lang)
|
|
169
|
+
except ValueError as exc:
|
|
170
|
+
return fail(400, "INVALID_KIND", str(exc))
|
|
171
|
+
except Exception as exc:
|
|
172
|
+
return fail(500, "SNIPPETS_FAILED", str(exc))
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@router.put("/snippets")
|
|
176
|
+
def put_snippets(
|
|
177
|
+
payload: Optional[dict] = Body(default=None),
|
|
178
|
+
kind: str = Query("chat", pattern="^(chat|term)$"),
|
|
179
|
+
lang: str = Query("en", pattern="^(en|ja)$"),
|
|
180
|
+
) -> Any:
|
|
181
|
+
"""Save Hot/Hidden overrides and custom snippets (`reset:true` restores defaults)."""
|
|
182
|
+
try:
|
|
183
|
+
return logic.save_snippets(kind=kind, lang=lang, payload=payload)
|
|
184
|
+
except ValueError as exc:
|
|
185
|
+
return fail(400, "INVALID_KIND", str(exc))
|
|
186
|
+
except OSError as exc:
|
|
187
|
+
return fail(500, "WRITE_FAILED", str(exc))
|
|
188
|
+
except Exception as exc:
|
|
189
|
+
return fail(500, "SNIPPETS_FAILED", str(exc))
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@router.get("/pipeline")
|
|
193
|
+
def get_pipeline(board: Optional[str] = Query(None)) -> Any:
|
|
194
|
+
"""Architect runner + SOUL/skill 適用状態 + 未起票 SPEC(SPEC V5 §3.2 / D25)。"""
|
|
195
|
+
try:
|
|
196
|
+
return logic.build_pipeline(board=board)
|
|
197
|
+
except Exception as exc: # health: surface the reason instead of a 500 traceback
|
|
198
|
+
return fail(500, "PIPELINE_FAILED", str(exc))
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@router.post("/pipeline")
|
|
202
|
+
def post_pipeline(payload: Optional[dict] = Body(default=None)) -> Any:
|
|
203
|
+
"""``optimize``(SOUL.md + スキル配置)または ``setRunner``(hermes 固定 / Hermes Native)。"""
|
|
204
|
+
try:
|
|
205
|
+
result = logic.pipeline_action(payload=payload)
|
|
206
|
+
except Exception as exc:
|
|
207
|
+
return fail(500, "PIPELINE_FAILED", str(exc))
|
|
208
|
+
if not result.get("ok"):
|
|
209
|
+
return JSONResponse(result, status_code=400)
|
|
210
|
+
return result
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
@router.get("/logs")
|
|
214
|
+
def get_logs(
|
|
215
|
+
file_name: str = Query("gateway", alias="file", pattern="^(gateway|errors|pilot|audit)$"),
|
|
216
|
+
lines: int = Query(120, ge=1, le=1000),
|
|
217
|
+
) -> Any:
|
|
218
|
+
"""Tail of one whitelisted log — redacted before it leaves the process."""
|
|
219
|
+
try:
|
|
220
|
+
return logic.build_logs(name=file_name, lines=lines)
|
|
221
|
+
except ValueError as exc:
|
|
222
|
+
return fail(400, "INVALID_FILE", str(exc))
|
|
223
|
+
except Exception as exc:
|
|
224
|
+
return fail(500, "LOGS_FAILED", str(exc))
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@router.post("/service/{action}")
|
|
228
|
+
def post_service(action: str) -> Any:
|
|
229
|
+
"""Spawn ``hermes-pilot service <action>`` and return its stdout."""
|
|
230
|
+
try:
|
|
231
|
+
return logic.run_service(action)
|
|
232
|
+
except ValueError as exc:
|
|
233
|
+
return fail(400, "UNKNOWN_ACTION", str(exc))
|
|
234
|
+
except logic.MissingCli as exc:
|
|
235
|
+
return fail(409, "CLI_MISSING", str(exc))
|
|
236
|
+
except Exception as exc:
|
|
237
|
+
return fail(500, "SERVICE_FAILED", str(exc))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Hermes Pilot — plugin package entry (installed as ``__init__.py``).
|
|
2
|
+
|
|
3
|
+
A user plugin's dashboard backend is only mounted when the plugin is a real,
|
|
4
|
+
enabled Hermes plugin, so this module has to exist even though there is no
|
|
5
|
+
agent-side surface: ``hermes plugins enable hermes-pilot`` resolves the name
|
|
6
|
+
through it. ``register`` is intentionally a no-op — the whole plugin is the
|
|
7
|
+
dashboard tab plus its FastAPI router under ``dashboard/``.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def register(ctx) -> None: # noqa: ARG001 - signature fixed by the plugin API
|
|
14
|
+
"""No agent-side tools, hooks or commands; the dashboard half is the plugin."""
|
|
15
|
+
return None
|