@zoulabo/line-hive 0.2.12 → 0.2.15

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.
@@ -1,234 +1,73 @@
1
- # LINE Communication Protocol
1
+ ---
2
+ description: "Use when LINE messaging tools (line_set_status, line_ask) are available. Governs mandatory status updates, progress reports, and permission alerts sent via LINE."
3
+ applyTo: '**'
4
+ ---
5
+ # LINE Communication Protocol (Light)
2
6
 
3
- **HARD RULE: When a LINE session is active, all replies MUST be sent via `line_ask`. Do not respond in this chat.**
4
-
5
- LINE tools are **only used during LINE sessions**. Outside a session, never call any `line_*` tools.
7
+ ## HARD RULE
8
+ - Active LINE session ⇒ all user-facing replies via `line_ask`.
9
+ - Outside LINE session do not use `line_*` tools.
6
10
 
7
11
  ## LINE Session
8
-
9
- ### Activation starts when ANY of these happen:
10
- - User says "continue on LINE", "talk on LINE", "notify me on LINE", or similar
11
- - User says "preapprove for LINE", "prepare for LINE", or "prime LINE", or similar (run pre-flight, then activate)
12
- - You receive a `pendingReply` from `line_set_status`
13
- - You call `line_ask`
12
+ ### Activation
13
+ - User requests LINE continuation/pre-flight.
14
+ - `pendingReply` appears.
15
+ - Agent calls `line_ask`.
14
16
 
15
17
  ### Agent Naming
16
-
17
- Pick a short, cute, gender-neutral name (max 8 chars). Prefer Japanese-English mashups e.g. Mochi, Kumo, Yuzu, Sora, Fuwa, Hana, Suzu, Maru, Niko, Rin, Tama, Koko, Nori, Pip, Riku, Umi, Yuki, Kaze, Haru, Toki, Miso, Dango, Kinako, Azuki, Sakura, Matcha, Wasabi, Ponzu, Goma, Tofu. Check `line_list_agents` first — **name uniqueness is enforced**. On `agent_name_taken` error, pick a different name.
18
+ - Short, cute, gender-neutral (max 8 chars).
19
+ - Prefer JP-EN style names; check `line_list_agents` first.
20
+ - If `agent_name_taken`, choose another name.
18
21
 
19
22
  ### Pre-Flight Tool Approval
20
-
21
- When a LINE session is activated by the user, run a pre-flight approval sequence **before** they leave:
22
-
23
- 1. Tell the user: "Accept each permission prompt. Then **send `?` in LINE and tap Continue** to prime a reply token, and confirm here when done."
24
- 2. Trigger approvals in parallel (skip already-approved categories):
25
- - **Terminal**: `ls package.json`
26
- - **File edit**: `create_file(".line-hive-preflight", "")` then `rm .line-hive-preflight`
27
- - **LINE MCP**: `line_set_status({ description: "pre-flight", agentName: "<name>" })` + `line_list_agents()`
28
- 3. **Do NOT call `line_ask` during pre-flight** no reply token exists yet.
29
- 4. Once the user confirms, start the session with `line_ask`.
30
-
31
- **Skip pre-flight when:** session was activated by `pendingReply`, tools are already approved, or agent has auto-approved permissions.
32
-
33
- ### Deactivation ends ONLY when:
34
- - **User types directly into the editor chat** — they're back at the computer
35
- - User explicitly says "stop LINE" or "go quiet"
36
-
37
- **CRITICAL:** "done", "ok", "thanks", "got it" are conversational replies, NOT deactivation signals. Always call `line_ask` again after processing any reply.
38
-
39
- ### Active Session Rules
40
-
41
- 1. **Use `line_ask` for all communication.** Always pass `agentName`. After receiving a reply, always call `line_ask` again — keep the loop going until timeout or deactivation.
42
- 2. **Default timeout policy (D1):** Use the `line_ask` default timeout (24h). Only pass `timeoutMs` when the user explicitly requests a custom timeout.
43
- 3. **Inline status preference (D2):** Prefer `line_ask` `statusDescription`/`progress` over separate `line_set_status` calls where applicable.
44
- - Use `line_set_status` only when no outgoing `line_ask` is appropriate (background progress, long-running work, idle/error transition, or collision/language setup)
45
- - If using `line_set_status`, include progress in ~10% increments and always check returned `pendingReply`
46
- 4. **Keep messages short** — 1-3 sentences. No filler ("Processing...", "Still here...").
47
- 5. **On timeout**, stop the loop. The user's next message creates a `pendingReply` on your next `line_set_status`, re-activating the session.
48
- 6. **Use numbering for actionable LINE content only** — decisions, tasks, options, and gap items must have stable IDs (`D1`, `A1`, `G1`, etc.). Do **not** force numbering on plain narrative/status sentences.
49
-
50
- ### Built-in Queue Drain
51
-
52
- - `line_ask` now auto-prepends a `📬 Drain (N)` quick-reply button when queued messages exist.
53
- - Agents should treat this as built-in behavior and should not implement separate custom drain-button logic.
54
-
55
- ### Numbering Protocol (Mandatory)
56
-
57
- Use stable, human-referenceable IDs in all docs and LINE messages:
58
-
59
- - **Decisions**: `D1`, `D2`, ...
60
- - **Actions/Tasks**: `A1`, `A2`, ...
61
- - **Gaps/Risks**: `G1`, `G2`, ...
62
- - **General numbered notes**: `N1`, `N2`, ...
63
-
64
- Rules:
65
- - Keep IDs stable across follow-up edits within the same discussion.
66
- - Do not renumber unchanged items when inserting new ones; append new IDs.
67
- - In LINE replies, refer to items by ID (e.g., `approve D2`, `skip A3`, `close G4`).
68
- - In rendered docs/HTML, include IDs in headings or first token of each bullet/row.
69
- - Narrative updates that are not asking for action may be plain text (no IDs required).
70
-
71
- ### Quick Reply Usage (Principle-Based)
72
-
73
- Quick-reply examples in this doc are illustrative, not exhaustive. Agents may proactively use quick replies in **any** LINE interaction where constrained options improve speed/accuracy, as long as API limits are respected.
74
-
75
- Guardrails:
76
- - Max 13 quick-reply items.
77
- - Attach quick reply once per `line_ask` call (final message in multi-message sends).
78
- - Provide a text fallback command for each option (`approve D1`, `skip A2`, etc.).
79
-
80
- ### Token Conservation
81
-
82
- Reply tokens are scarce — each `line_ask` call consumes one. LINE allows **up to 5 messages per reply token**. Use the `messages[]` parameter to batch everything into a single call:
83
-
84
- - **Use `messages[]`** — pass an array of up to 5 items. Plain strings are text, `file:` prefix for files (e.g. `"file:.line-hive-tmp/report.xlsx"`). Images auto-detect by extension.
85
- - **Batch files + text** — send text and files together: `messages: ["Here's the report:", "file:.line-hive-tmp/report.xlsx"]`
86
- - **File delivery** — generate files with `send: false`, then deliver via `messages[]`. Never use tool-specific `send: true` AND a separate `line_ask`.
87
- - **Never send a message just to acknowledge** — if the next step is another `line_ask`, skip the intermediate acknowledgment.
88
- - **5-message hard limit** — LINE API rejects >5 messages per token. Plan batches accordingly.
89
-
90
- Example — send text + XLSX + HTML in one token:
91
- ```
92
- line_ask({ messages: ["Dashboard ready!", "file:.line-hive-tmp/dashboard.xlsx", "file:.line-hive-tmp/report.html"], agentName: "<name>" })
93
- ```
94
-
95
- ### Rich Content via HTML
96
-
97
- Use `line_render_markdown` for all rich content — diagrams, reports, diffs, code, math. It auto-injects CDN libraries for Mermaid diagrams, syntax highlighting (highlight.js), and math (KaTeX). Files are served with TTL (default 2h, max 24h).
98
-
99
- **Rule of thumb:** If content is longer than a couple of LINE bubbles (or might exceed LINE's ~2000 char limit), prefer sending an **HTML file** (phone-friendly) instead of a long text message.
100
-
101
- **Fallback (no render tool):** If `line_render_markdown` isn't available, you can still send a hand-written `.html` file via `messages[]`:
102
- ```ts
103
- line_ask({ messages: ["Report:", "file:.line-hive-tmp/report.html"], agentName: "<name>" })
104
- ```
105
-
106
- **Diagrams** — write mermaid in markdown, render to HTML (no `mmdc` needed). Use `flowchart LR` with `direction TB` inside subgraphs (or vice versa) — never make everything the same direction. Separate logical sections into individual diagrams rather than one giant chart:
107
- ```bash
108
- create_file(".line-hive-tmp/diagram.md", "# Architecture\n\n```mermaid\nflowchart LR\n subgraph Flow[\"Flow\"]\n direction TB\n A-->B-->C\n end\n```")
109
- line_render_markdown({ inputPath: ".line-hive-tmp/diagram.md", outputPath: ".line-hive-tmp/diagram.html", title: "Architecture", ttl: 30 })
110
- line_ask({ messages: ["Architecture diagram:", "file:.line-hive-tmp/diagram.html"], agentName: "<name>" })
111
- ```
112
-
113
- **Long reports / docs** — when content exceeds LINE's ~2000 char limit:
114
- ```bash
115
- line_render_markdown({ inputPath: "path/to/report.md", outputPath: ".line-hive-tmp/report.html", title: "Report" })
116
- line_ask({ messages: ["Here's the full report:", "file:.line-hive-tmp/report.html"], agentName: "<name>" })
117
- ```
118
-
119
- **Diffs** — format as markdown code blocks with `diff` language:
120
- ```bash
121
- create_file(".line-hive-tmp/changes.md", "# Changes\n\n```diff\n- old line\n+ new line\n```")
122
- line_render_markdown({ inputPath: ".line-hive-tmp/changes.md", outputPath: ".line-hive-tmp/changes.html", title: "Diff" })
123
- line_ask({ messages: ["Here are the changes:", "file:.line-hive-tmp/changes.html"], agentName: "<name>" })
124
- ```
125
-
126
- **Existing .md files** — skills, READMEs, docs:
127
- ```bash
128
- line_render_markdown({ inputPath: "path/to/file.md", outputPath: ".line-hive-tmp/doc.html", title: "Title" })
129
- line_ask({ messages: ["Here's the doc:", "file:.line-hive-tmp/doc.html"], agentName: "<name>" })
130
- ```
131
-
132
- Send raw images via `messages[]` with `file:` prefix: `messages: ["Screenshot:", "file:.line-hive-tmp/screenshot.png"]` — images auto-detect by extension and display inline.
133
-
134
- ## Git Review Workflow
135
-
136
- When user says "git review", "commit", "review changes", or similar — use `line_git_review` to scan changes, analyze them, and send a decision-ready HTML report.
137
-
138
- ### 3-Call Workflow
139
-
140
- ```
141
- 1. line_git_review({ mode: "scan" }) → JSON: branch, files, +/- stats
142
- 2. [Analyze: group by feature, propose commits, flag decisions]
143
- 3. line_git_review({ mode: "report", decisions, commits, groups, ttl: 120 }) → { url }
144
- 4. line_ask({ messages: ["Git review (N files, +X -Y):", url], agentName })
145
- ```
146
-
147
- ### D/A Numbering
148
-
149
- Every item is either a **D** (decision — user must answer) or an **A** (agent-proposed commit):
150
-
151
- - **D items** — things the agent can't decide: binary files, submodules, ambiguous untracked files, security-sensitive content. Format: `D1 gitignore / D1 keep / D1 delete`
152
- - **A items** — proposed commits grouped by feature. Format: `A1 · feat: add login form` with file list and reasoning
153
-
154
- ### Slot HTML Classes
155
-
156
- Build slot HTML using these pre-built CSS classes:
157
-
158
- **Decisions (`dc-box`):**
159
- ```html
160
- <div class="dc-box"><h2>⚠️ Decisions</h2>
161
- <div class="fi fw"><div class="fl">D1 · description</div>
162
- <b>D1 option1</b> / <b>D1 option2</b></div>
163
- </div>
164
- ```
165
-
166
- **Commits (`cm-box`):**
167
- ```html
168
- <div class="cm-box"><h2>📦 Commits</h2>
169
- <div class="cc"><div class="cm">A1 · feat: description</div>
170
- <div class="cf">file1.ts, file2.ts</div>
171
- <div class="cr">Reasoning</div></div>
172
- </div>
173
- ```
174
-
175
- **Groups (`gr`):**
176
- ```html
177
- <div class="gr">
178
- <div class="gh" onclick="this.nextElementSibling.style.display=
179
- this.nextElementSibling.style.display==='block'?'none':'block'">
180
- <h2>Group Name</h2><span class="bd bf">FEAT</span>
181
- </div>
182
- <div class="gb" style="display:none"><div class="gd">Details</div></div>
183
- </div>
184
- ```
185
- Badge classes: `.bf` (feature), `.bo` (docs), `.bx` (fix), `.bn` (new)
186
-
187
- ### Reply Parsing
188
-
189
- User replies with comma-separated instructions:
190
-
191
- | Pattern | Action |
192
- |---------|--------|
193
- | `ok` / `go` | Execute all A commits + push |
194
- | `skip A2` | Don't commit group A2 |
195
- | `merge A1+A3` | Combine commits |
196
- | `msg A1: new msg` | Override commit message |
197
- | `D1 ignore` | Apply decision |
198
- | `no push` | Commit but don't push |
199
- | `cancel` | Abort |
200
-
201
- **Execution order:** Apply D decisions → stage files per group → commit → push → report result.
202
-
203
- ### Grouping Heuristics
204
-
205
- 1. Shared feature (handler + test + types)
206
- 2. Shared purpose (all docs changes)
207
- 3. Shared directory (when purpose unclear)
208
- 4. Independent (single-file fixes)
209
-
210
- ### Commit Prefixes
211
-
212
- `feat:` / `fix:` / `docs:` / `refactor:` / `chore:` / `style:`
213
-
214
- ## Interactive Mode (ON DEMAND)
215
-
216
- Off by default. Activate only when user explicitly requests confirmations (e.g., "confirm on LINE"). Before modifying files or running commands: `line_ask("⏳ About to: <action summary> — confirm?")`. Deactivates with the LINE session.
23
+ 1. User accepts prompts, sends `?`, then taps `✅ Continue` once to prime a reusable reply token.
24
+ 2. Run approvals in parallel:
25
+ - Terminal: `ls -1 package.json README.md 2>/dev/null || ls -1`
26
+ - File edit: create/delete `.line-hive-preflight`
27
+ - LINE MCP: `line_set_status(pre-flight)` + `line_list_agents`
28
+ 3. Do not call `line_ask` during pre-flight.
29
+
30
+ ### Deactivation
31
+ - Ends only when user returns to editor chat or says stop/quiet.
32
+ - `done/ok/thanks` are not deactivation signals.
33
+
34
+ ## Active Session Rules
35
+ 1. Keep `line_ask` loop alive after each reply.
36
+ 2. Timeout default is 24h unless user asks custom.
37
+ 3. Prefer inline status (`statusDescription`, `progress`).
38
+ 4. Use `line_set_status` only when no outgoing `line_ask` is suitable.
39
+ 5. Keep messages 1–3 sentences.
40
+ 6. On timeout, stop loop and wait for reactivation.
41
+ 7. Use stable IDs for actions (`D#`, `A#`, `G#`, `N#`).
42
+ 8. During todo execution, update status after each completed task.
43
+ 9. Ask decisions one-by-one; include key detail, an HTML detail link specific to that decision, and quick replies for bounded options.
44
+
45
+ ## Quick Replies
46
+ - Default ON for bounded choices (2–6 options).
47
+ - Keep labels short; include text fallback.
48
+ - Max 13 items; attach once per `line_ask` call.
49
+ - Keep built-in queue drain behavior (`📬 Drain (N)`).
50
+ - Action schema: `message` uses `text`; `postback` uses `data` (+ optional `displayText`) and must not include `text`.
51
+
52
+ ## Token/Delivery Rules
53
+ - 0 push quota policy: LINE delivery must use reply tokens only.
54
+ - Batch with `messages[]` (max 5).
55
+ - Avoid duplicate send paths.
56
+ - Prefer HTML for long/rich content.
57
+ - In LINE sessions, do not send raw Markdown unless explicitly requested.
58
+ - For `.md` docs (plans, READMEs, reports), render to HTML and send the HTML file/link by default.
59
+
60
+ ## Writing Style
61
+ - Use plain, direct language with short sentences.
62
+ - Prefer action checklists over process-heavy prose.
63
+ - Avoid corporate jargon (e.g., "posture", "alignment", "leverage", "framework") unless user asks for formal style.
64
+
65
+ ## Git Review (Light)
66
+ - `scan` → analyze (`D#`/`A#`) → `report` → `line_ask`.
67
+ - Keep command patterns (`ok`, `skip A#`, `merge`, `msg`, `D#`, `no push`, `cancel`).
217
68
 
218
69
  ## DO NOT
219
-
220
- - Call `line_*` tools outside of a LINE session
221
- - Interpret reply content ("done", "ok", "thanks") as session termination
222
- - Spam reports more often than every 2 minutes
223
- - Use interactive mode unless explicitly requested
224
- - **Waste reply tokens** — never send a file via tool `send: true` and then a separate `line_ask` about it. Never send multiple `line_ask` calls when one suffices.
225
- - **Pass LINE tools to subagents** — only the top-level agent calls `line_*` tools
226
- - **Install packages during a session** — user can't approve prompts while away. Install during pre-flight instead.
227
- - **Fetch external URLs during a session** — may trigger permission prompts. Only fetch when user confirms no permission issue.
228
- - **Write temp files outside the project** — use `.line-hive-tmp/` (gitignored) for all temp files. Never use `/tmp`, `~/Desktop`, or any path outside the workspace — these trigger permission prompts that block while the user is away.
229
-
230
- ### Screen Lock Warning
231
-
232
- Screen lock may re-lock the keychain or credential store, causing **SSH passphrase prompts** that block any terminal using SSH (`git push/pull`). Mitigate:
233
- - Run git remote operations **before** the user leaves (during pre-flight)
234
- - If a terminal hangs, it's likely a passphrase prompt — don't spawn more terminals
70
+ - Pass LINE tools to subagents.
71
+ - Install packages during active LINE sessions.
72
+ - Fetch external URLs during session without prompt-safety confirmation.
73
+ - Write temp files outside `.line-hive-tmp/`.