hermes-pilot 0.0.0-stage → 0.2.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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +390 -0
  3. package/README.md +398 -2
  4. package/__init__.py +15 -0
  5. package/apps/bridge/src/api-errors.js +165 -0
  6. package/apps/bridge/src/architect.js +1298 -0
  7. package/apps/bridge/src/auth.js +202 -0
  8. package/apps/bridge/src/capabilities.js +256 -0
  9. package/apps/bridge/src/capture.js +145 -0
  10. package/apps/bridge/src/chat-profile.js +95 -0
  11. package/apps/bridge/src/config.js +73 -0
  12. package/apps/bridge/src/discord.js +89 -0
  13. package/apps/bridge/src/gitinfo.js +211 -0
  14. package/apps/bridge/src/hermes.js +97 -0
  15. package/apps/bridge/src/inbox.js +347 -0
  16. package/apps/bridge/src/kanban.js +361 -0
  17. package/apps/bridge/src/lang.js +60 -0
  18. package/apps/bridge/src/live.js +285 -0
  19. package/apps/bridge/src/memos.js +150 -0
  20. package/apps/bridge/src/ops.js +201 -0
  21. package/apps/bridge/src/pair-codes.js +125 -0
  22. package/apps/bridge/src/pipeline-optimizer.js +358 -0
  23. package/apps/bridge/src/pipeline-watcher.js +1018 -0
  24. package/apps/bridge/src/qr.js +808 -0
  25. package/apps/bridge/src/repos.js +544 -0
  26. package/apps/bridge/src/review-watcher.js +271 -0
  27. package/apps/bridge/src/review.js +1749 -0
  28. package/apps/bridge/src/search.js +162 -0
  29. package/apps/bridge/src/server.js +1738 -0
  30. package/apps/bridge/src/snippets.js +373 -0
  31. package/apps/bridge/src/specs.js +734 -0
  32. package/apps/bridge/src/tail.js +28 -0
  33. package/apps/bridge/src/telemetry.js +667 -0
  34. package/apps/bridge/src/term-snippets.js +228 -0
  35. package/apps/bridge/src/transcript.js +231 -0
  36. package/apps/bridge/src/usage.js +294 -0
  37. package/apps/bridge/src/workerFeed.js +72 -0
  38. package/apps/dashboard/index.js +2014 -0
  39. package/apps/dashboard/manifest.json +14 -0
  40. package/apps/dashboard/pilot_dashboard.py +1466 -0
  41. package/apps/dashboard/plugin_api.py +237 -0
  42. package/apps/dashboard/plugin_init.py +15 -0
  43. package/apps/dashboard/style.css +928 -0
  44. package/apps/web/dist/assets/TermPane-DYP7pi_n.css +32 -0
  45. package/apps/web/dist/assets/TermPane-U500JD2P.js +12 -0
  46. package/apps/web/dist/assets/index-6iFDsB0G.css +1 -0
  47. package/apps/web/dist/assets/index-X4Bi2FWB.js +94 -0
  48. package/apps/web/dist/favicon.ico +0 -0
  49. package/apps/web/dist/icon-180-v6.png +0 -0
  50. package/apps/web/dist/icon-192-v6.png +0 -0
  51. package/apps/web/dist/icon-512-v6.png +0 -0
  52. package/apps/web/dist/icon-maskable-192-v6.png +0 -0
  53. package/apps/web/dist/icon-maskable-512-v6.png +0 -0
  54. package/apps/web/dist/icon-v6.svg +15 -0
  55. package/apps/web/dist/index.html +21 -0
  56. package/apps/web/dist/manifest.webmanifest +49 -0
  57. package/apps/web/dist/sw.js +69 -0
  58. package/bin/hermes-pilot.mjs +964 -0
  59. package/dashboard/dist/index.js +2014 -0
  60. package/dashboard/dist/style.css +928 -0
  61. package/dashboard/manifest.json +14 -0
  62. package/dashboard/pilot_dashboard.py +1466 -0
  63. package/dashboard/plugin_api.py +237 -0
  64. package/package.json +75 -4
  65. package/plugin.json +70 -0
  66. package/plugin.yaml +4 -0
  67. package/scripts/deploy.mjs +58 -0
  68. package/scripts/migrate-to-hermes-pilot.mjs +472 -0
  69. package/scripts/postinstall.mjs +32 -0
  70. package/scripts/sync-dashboard.mjs +98 -0
  71. package/skills/annotation/SKILL.md +103 -0
  72. package/skills/quick-review/SKILL.md +170 -0
  73. package/skills/quick-review/assets/sheet-template.html +175 -0
  74. package/skills/spec-architect/SKILL.md +175 -0
@@ -0,0 +1,373 @@
1
+ /**
2
+ * 定型スニペット(入力欄の上のチップ)。
3
+ *
4
+ * - `hot: true` をバーに出す(既定6個・`HOT_LIMIT` は 8)
5
+ * - `trigger: true` は意思決定トリガー(赤ペン起票など)。UI がアクセント枠で描く
6
+ * - 文言は**ユーザー発話として挿入**する(送信はしない。長押しで即送信)
7
+ * - 組み込みは en / ja の両文面を持つ(`listSnippets(custom, lang, overrides)`・SPEC §3.2)
8
+ * - ユーザー定義は最大16個(設定タブ)。保存先は `~/.hermes/plugin-data/hermes-pilot/snippets.json`
9
+ *
10
+ * カスタマイズモデル(SPEC §3.4 / D13): 組み込みは `overrides[id] = {hot, hidden}` で
11
+ * Hot の ON/OFF と非表示を切り替え、`custom[]` で追加・編集・削除する。
12
+ * 保存形式は `{version: 2, overrides, custom}`(version 1 は読取時に補完)。
13
+ */
14
+
15
+ import fs from 'node:fs'
16
+ import path from 'node:path'
17
+
18
+ /** @typedef {{label: string, text: string, placeholder?: string}} SnippetText */
19
+ /** @typedef {{id: string, hot?: boolean, trigger?: boolean, action?: string, en: SnippetText, ja: SnippetText}} BuiltinSnippet */
20
+
21
+ /** @type {BuiltinSnippet[]} */
22
+ const BUILTIN = [
23
+ // --- Hot(バーに出す)-----------------------------------------------------
24
+ {
25
+ id: 'spec-seed',
26
+ hot: true,
27
+ trigger: true,
28
+ // 入力欄に文字を流し込むのではなく、1 行メモのシートを開く(仕様策定)
29
+ action: 'seed',
30
+ en: {
31
+ label: '📝 Spec Seed',
32
+ text:
33
+ 'Start a spec interview from this one-line note: put the 2-3 open design decisions on a Quick Review sheet (each with recommended: true), wait for my 1-tap answer, then write docs/SPEC-<SLUG>.md with Execution Mode, 目的, 変更ファイル and 受入条件 per batch.',
34
+ },
35
+ ja: {
36
+ label: '📝 仕様策定',
37
+ text:
38
+ 'この一行メモから仕様策定インタビューを始めて。設計論点を2〜3問の Quick Review シート(各問 recommended: true)にして1タップ回答を待ち、回答後に docs/SPEC-<SLUG>.md をバッチごとの Execution Mode・目的・変更ファイル・受入条件つきで書いて。',
39
+ },
40
+ },
41
+ {
42
+ id: 'quick-review',
43
+ hot: true,
44
+ trigger: true,
45
+ en: {
46
+ label: '📋 Quick Review',
47
+ text:
48
+ 'Summarize the open design decisions into a Quick Review sheet (HTML + JSON under review/sheets/) using the quick-review skill, file a blocked [review] task on kanban, and wait for my 1-tap answer.',
49
+ },
50
+ ja: {
51
+ label: '📋 Quick Review起票',
52
+ text:
53
+ 'いま判断が必要な論点を quick-review スキルで設問シート(review/sheets/ の HTML + JSON)にまとめ、カンバンに blocked の [review] タスクとして起票して回答を待って。',
54
+ },
55
+ },
56
+ {
57
+ id: 'annotate-shot',
58
+ hot: true,
59
+ trigger: true,
60
+ en: {
61
+ label: '📸 Annotate Shot',
62
+ text:
63
+ 'Deploy the latest build, take a 390x844 screenshot into review/shots/, and file a blocked [review] mode=annotation task using the annotation skill so I can redline it.',
64
+ },
65
+ ja: {
66
+ label: '📸 スクショ注釈起票',
67
+ text:
68
+ '最新ビルドを反映して 390x844 の実機スクショを review/shots/ に撮り、annotation スキルで赤入れ用の blocked [review] タスクを起票して。',
69
+ },
70
+ },
71
+ {
72
+ id: 'approve',
73
+ hot: true,
74
+ en: {
75
+ label: '⚡ Approve & Go',
76
+ text: 'Approved with the recommended option. Proceed with implementation and run verification.',
77
+ },
78
+ ja: {
79
+ label: '⚡ 推奨案で承認・続行',
80
+ text: '推奨案で承認します。このまま実装を進めて検証(verify)まで実行して。',
81
+ },
82
+ },
83
+ {
84
+ id: 'spec-kanban',
85
+ hot: true,
86
+ en: {
87
+ label: '🚀 Spec → Kanban',
88
+ text:
89
+ 'Read the latest docs/SPEC-*.md in this repo, create the kanban batch tasks in order, and start autonomous execution from the first batch.',
90
+ },
91
+ ja: {
92
+ label: '🚀 SPECから自走',
93
+ text:
94
+ 'このリポジトリの最新の docs/SPEC-*.md を読み、バッチ順にカンバンタスクを起票して最初のバッチから自走を開始して。',
95
+ },
96
+ },
97
+ {
98
+ id: 'retry',
99
+ hot: true,
100
+ en: {
101
+ label: '🔄 Alt Approach',
102
+ text: 'Stop repeating the last steps. Propose and execute a different approach to solve the root issue.',
103
+ },
104
+ ja: {
105
+ label: '🔄 別アプローチ',
106
+ text: '同じ手順の繰り返しを止め、根本原因に対する別のアプローチでやり直して。',
107
+ },
108
+ },
109
+ {
110
+ id: 'summary',
111
+ hot: true,
112
+ en: {
113
+ label: '📝 Summary',
114
+ text: 'Summarize the decisions made, remaining open items, and next steps from this conversation in concise bullets.',
115
+ },
116
+ ja: {
117
+ label: '📝 要点まとめ',
118
+ text: 'ここまでの決定事項・未解決の論点・次の一手を簡潔な箇条書きで整理して。',
119
+ },
120
+ },
121
+
122
+ // --- シート(8個)----------------------------------------------------------
123
+ {
124
+ id: 'git-diff',
125
+ en: { label: 'git diff', text: 'Run git diff in the working repo and summarize the key changes in 3 lines.' },
126
+ ja: { label: 'git diff', text: '作業中のリポジトリで git diff を実行し、主要な変更点を3行で要約して。' },
127
+ },
128
+ {
129
+ id: 'git-status',
130
+ en: { label: 'git status', text: 'Run git status --short and list any uncommitted or untracked files.' },
131
+ ja: { label: 'git status', text: 'git status --short を実行して、未コミット・未追跡ファイルを一覧にして。' },
132
+ },
133
+ {
134
+ id: 'test',
135
+ en: { label: 'Run Verify', text: 'Run npm run verify (or the project test suite) and fix any failing tests.' },
136
+ ja: { label: 'テスト・検証', text: 'npm run verify(または関連テスト)を実行し、失敗があれば修正して。' },
137
+ },
138
+ {
139
+ id: 'review',
140
+ en: {
141
+ label: 'Bug Review',
142
+ text: 'Review the latest diff focusing on bugs and regressions. List by severity with file:line (do not edit yet).',
143
+ },
144
+ ja: {
145
+ label: 'バグ監査',
146
+ text: '直前の差分をバグ・デグレ優先で監査して。重大度順・file:line 付きで列挙し、まだコードは変えないで。',
147
+ },
148
+ },
149
+ {
150
+ id: 'explain',
151
+ en: {
152
+ label: 'Explain 3L',
153
+ text: 'Explain the code or behavior we just touched in 3 lines for someone seeing it for the first time.',
154
+ },
155
+ ja: { label: '3行で説明', text: '直前に触ったコードや挙動を、初見の人向けに3行で説明して。' },
156
+ },
157
+ {
158
+ id: 'cause',
159
+ en: {
160
+ label: 'Diagnose',
161
+ text: 'Identify the root cause of this error and propose the single safest fix.\nError: {{paste here}}',
162
+ placeholder: '{{paste here}}',
163
+ },
164
+ ja: {
165
+ label: '原因特定',
166
+ text: '次のエラーの根本原因を特定し、最も安全な修正案を1つ提案して。\nエラー: {{ここに貼り付け}}',
167
+ placeholder: '{{ここに貼り付け}}',
168
+ },
169
+ },
170
+ {
171
+ id: 'handoff',
172
+ en: {
173
+ label: 'Handoff',
174
+ text: 'Write a compact handoff note (current state / decisions / next action) so a background worker can continue.',
175
+ },
176
+ ja: {
177
+ label: '引き継ぎメモ',
178
+ text: '自律ワーカーがそのまま引き継げるよう、現状・決定事項・次の一手をコンパクトにまとめて。',
179
+ },
180
+ },
181
+ {
182
+ id: 'kanban',
183
+ en: {
184
+ label: 'Kanban Next',
185
+ text: 'Check the running and blocked kanban tasks and tell me the single highest-priority item.',
186
+ },
187
+ ja: { label: 'カンバン確認', text: 'カンバンの実行中・ブロック中タスクを確認し、最優先で片付けるべき1件を教えて。' },
188
+ },
189
+ ]
190
+
191
+ export const HOT_LIMIT = 8
192
+ export const CUSTOM_MAX = 16
193
+ export const LABEL_MAX = 20
194
+ export const TEXT_MAX = 400
195
+
196
+ /** 組み込み ID の一覧(overrides の検証に使う)。 */
197
+ export const BUILTIN_IDS = BUILTIN.map((s) => s.id)
198
+
199
+ /**
200
+ * 言語コードを `en` / `ja` に落とす(それ以外は en)。
201
+ * @param {unknown} lang 言語
202
+ * @returns {'en'|'ja'} 言語
203
+ */
204
+ export function langOf(lang) {
205
+ return String(lang ?? '').trim().toLowerCase().startsWith('ja') ? 'ja' : 'en'
206
+ }
207
+
208
+ /**
209
+ * 組み込み 1 件を UI 用の形にする。
210
+ * @param {BuiltinSnippet} s 組み込み
211
+ * @param {'en'|'ja'} lang 言語
212
+ * @returns {{id: string, label: string, hot: boolean, trigger: boolean, hidden: boolean, custom: false, hasPlaceholder: boolean, text: string}} UI 用
213
+ */
214
+ function toUi(s, lang) {
215
+ const src = s[lang] ?? s.en
216
+ return {
217
+ id: s.id,
218
+ label: src.label,
219
+ hot: Boolean(s.hot),
220
+ trigger: Boolean(s.trigger),
221
+ // `action: 'seed'` は入力欄に流し込まず、シートを開くチップ(仕様策定)
222
+ ...(s.action ? { action: String(s.action) } : {}),
223
+ hidden: false,
224
+ custom: false,
225
+ hasPlaceholder: Boolean(src.placeholder),
226
+ text: src.text,
227
+ }
228
+ }
229
+
230
+ /**
231
+ * 組み込みの上書き設定を検証する(未知の id・非真偽値は落とす)。
232
+ * @param {unknown} input `{id: {hot?, hidden?}}`
233
+ * @param {string[]} [ids] 許可する id
234
+ * @returns {Record<string, {hot?: boolean, hidden?: boolean}>} 正規化
235
+ */
236
+ export function normalizeOverrides(input, ids = BUILTIN_IDS) {
237
+ /** @type {Record<string, {hot?: boolean, hidden?: boolean}>} */
238
+ const out = {}
239
+ if (!input || typeof input !== 'object' || Array.isArray(input)) return out
240
+ const allowed = new Set(ids)
241
+ for (const [id, raw] of Object.entries(input)) {
242
+ if (!allowed.has(id) || !raw || typeof raw !== 'object') continue
243
+ /** @type {{hot?: boolean, hidden?: boolean}} */
244
+ const o = {}
245
+ if (typeof raw.hot === 'boolean') o.hot = raw.hot
246
+ if (typeof raw.hidden === 'boolean') o.hidden = raw.hidden
247
+ if (Object.keys(o).length) out[id] = o
248
+ }
249
+ return out
250
+ }
251
+
252
+ /**
253
+ * ユーザー定義を検証・正規化する。
254
+ * @param {unknown} input 入力
255
+ * @param {{max?: number, withRun?: boolean}} [opts] 上限と端末用フィールド
256
+ * @returns {Array<object>} 正規化(`custom: true`)
257
+ */
258
+ export function normalizeCustom(input, { max = CUSTOM_MAX, withRun = false } = {}) {
259
+ if (!Array.isArray(input)) return []
260
+ const out = []
261
+ const seen = new Set()
262
+ for (const raw of input.slice(0, max)) {
263
+ if (!raw || typeof raw !== 'object') continue
264
+ const label = String(raw.label ?? '').trim().slice(0, LABEL_MAX)
265
+ const text = String(raw.text ?? '').trim().slice(0, TEXT_MAX)
266
+ if (!label || !text) continue
267
+ const given = String(raw.id ?? '')
268
+ const id =
269
+ /^c-[a-z0-9]{1,20}$/.test(given) && !seen.has(given)
270
+ ? given
271
+ : `c-${(seen.size + 1).toString(36)}${Math.random().toString(36).slice(2, 6)}`
272
+ seen.add(id)
273
+ /** @type {Record<string, unknown>} */
274
+ const item = { id, label, text, hot: Boolean(raw.hot), custom: true }
275
+ if (raw.hidden === true) item.hidden = true
276
+ if (withRun) {
277
+ item.run = raw.run !== false
278
+ const note = String(raw.note ?? '').trim().slice(0, TEXT_MAX)
279
+ if (note) item.note = note
280
+ }
281
+ out.push(item)
282
+ }
283
+ return out
284
+ }
285
+
286
+ /**
287
+ * UI 向け一覧(組み込み + ユーザー定義)。`hidden` も含む(設定画面用)。
288
+ * @param {Array<object>} [custom] ユーザー定義
289
+ * @param {'en'|'ja'} [lang] 表示言語(既定 en・SPEC D5)
290
+ * @param {Record<string, object>} [overrides] 組み込みの上書き
291
+ * @returns {Array<object>} 一覧
292
+ */
293
+ export function allSnippets(custom = [], lang = 'en', overrides = {}) {
294
+ const l = langOf(lang)
295
+ const ov = normalizeOverrides(overrides)
296
+ const builtin = BUILTIN.map((s) => {
297
+ const o = ov[s.id] ?? {}
298
+ return {
299
+ ...toUi(s, l),
300
+ hot: typeof o.hot === 'boolean' ? o.hot : Boolean(s.hot),
301
+ hidden: o.hidden === true,
302
+ }
303
+ })
304
+ const user = normalizeCustom(custom).map((s) => ({
305
+ id: s.id,
306
+ label: s.label,
307
+ text: s.text,
308
+ hot: Boolean(s.hot),
309
+ trigger: false,
310
+ hidden: s.hidden === true,
311
+ custom: true,
312
+ hasPlaceholder: false,
313
+ }))
314
+ return [...builtin, ...user]
315
+ }
316
+
317
+ /**
318
+ * 会話画面向け一覧(`hidden` を除く)。
319
+ * @param {Array<object>} [custom] ユーザー定義
320
+ * @param {'en'|'ja'} [lang] 表示言語
321
+ * @param {Record<string, object>} [overrides] 組み込みの上書き
322
+ * @returns {Array<object>} 一覧
323
+ */
324
+ export function listSnippets(custom = [], lang = 'en', overrides = {}) {
325
+ return allSnippets(custom, lang, overrides).filter((s) => !s.hidden)
326
+ }
327
+
328
+ /** 既定言語(en)で組み立てた組み込み一覧(後方互換・テスト用)。 */
329
+ export const SNIPPETS = BUILTIN.map((s) => toUi(s, 'en'))
330
+
331
+ /**
332
+ * 保存済みスニペット設定を読む(version 1 は読取時に version 2 へ補完)。
333
+ * @param {string} file 保存先
334
+ * @param {{ids?: string[], withRun?: boolean, max?: number}} [opts] 許可 id・端末用フィールド
335
+ * @returns {{version: 2, overrides: Record<string, object>, custom: Array<object>}} 設定
336
+ */
337
+ export function readSnippetStore(file, { ids = BUILTIN_IDS, withRun = false, max = CUSTOM_MAX } = {}) {
338
+ let raw = null
339
+ try {
340
+ raw = JSON.parse(fs.readFileSync(file, 'utf8'))
341
+ } catch {
342
+ raw = null
343
+ }
344
+ const src = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {}
345
+ return {
346
+ version: 2,
347
+ overrides: normalizeOverrides(src.overrides, ids),
348
+ custom: normalizeCustom(src.custom ?? [], { max, withRun }),
349
+ }
350
+ }
351
+
352
+ /**
353
+ * スニペット設定をアトミックに書く(`0600`・version 2)。
354
+ * @param {string} file 保存先
355
+ * @param {{custom?: unknown, overrides?: unknown}} store 設定
356
+ * @param {{ids?: string[], withRun?: boolean, max?: number}} [opts] 許可 id・端末用フィールド
357
+ * @returns {{version: 2, overrides: Record<string, object>, custom: Array<object>}} 保存した設定
358
+ */
359
+ export function writeSnippetStore(file, { custom, overrides } = {}, { ids = BUILTIN_IDS, withRun = false, max = CUSTOM_MAX } = {}) {
360
+ /** @type {{version: 2, overrides: Record<string, object>, custom: Array<object>}} */
361
+ const data = {
362
+ version: 2,
363
+ overrides: normalizeOverrides(overrides, ids),
364
+ custom: normalizeCustom(custom ?? [], { max, withRun }),
365
+ }
366
+ fs.mkdirSync(path.dirname(file), { recursive: true })
367
+ const tmp = `${file}.tmp`
368
+ fs.writeFileSync(tmp, JSON.stringify(data, null, 2), { mode: 0o600 })
369
+ fs.renameSync(tmp, file)
370
+ return data
371
+ }
372
+
373
+ export { BUILTIN }