@zoulabo/line-hive 0.2.9 → 0.2.13

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,229 +1,64 @@
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
- ### Numbering Protocol (Mandatory)
51
-
52
- Use stable, human-referenceable IDs in all docs and LINE messages:
53
-
54
- - **Decisions**: `D1`, `D2`, ...
55
- - **Actions/Tasks**: `A1`, `A2`, ...
56
- - **Gaps/Risks**: `G1`, `G2`, ...
57
- - **General numbered notes**: `N1`, `N2`, ...
58
-
59
- Rules:
60
- - Keep IDs stable across follow-up edits within the same discussion.
61
- - Do not renumber unchanged items when inserting new ones; append new IDs.
62
- - In LINE replies, refer to items by ID (e.g., `approve D2`, `skip A3`, `close G4`).
63
- - In rendered docs/HTML, include IDs in headings or first token of each bullet/row.
64
- - Narrative updates that are not asking for action may be plain text (no IDs required).
65
-
66
- ### Quick Reply Usage (Principle-Based)
67
-
68
- 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.
69
-
70
- Guardrails:
71
- - Max 13 quick-reply items.
72
- - Attach quick reply once per `line_ask` call (final message in multi-message sends).
73
- - Provide a text fallback command for each option (`approve D1`, `skip A2`, etc.).
74
-
75
- ### Token Conservation
76
-
77
- 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:
78
-
79
- - **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.
80
- - **Batch files + text** — send text and files together: `messages: ["Here's the report:", "file:.line-hive-tmp/report.xlsx"]`
81
- - **File delivery** — generate files with `send: false`, then deliver via `messages[]`. Never use tool-specific `send: true` AND a separate `line_ask`.
82
- - **Never send a message just to acknowledge** — if the next step is another `line_ask`, skip the intermediate acknowledgment.
83
- - **5-message hard limit** — LINE API rejects >5 messages per token. Plan batches accordingly.
84
-
85
- Example — send text + XLSX + HTML in one token:
86
- ```
87
- line_ask({ messages: ["Dashboard ready!", "file:.line-hive-tmp/dashboard.xlsx", "file:.line-hive-tmp/report.html"], agentName: "<name>" })
88
- ```
89
-
90
- ### Rich Content via HTML
91
-
92
- 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).
93
-
94
- **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.
95
-
96
- **Fallback (no render tool):** If `line_render_markdown` isn't available, you can still send a hand-written `.html` file via `messages[]`:
97
- ```ts
98
- line_ask({ messages: ["Report:", "file:.line-hive-tmp/report.html"], agentName: "<name>" })
99
- ```
100
-
101
- **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:
102
- ```bash
103
- 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```")
104
- line_render_markdown({ inputPath: ".line-hive-tmp/diagram.md", outputPath: ".line-hive-tmp/diagram.html", title: "Architecture", ttl: 30 })
105
- line_ask({ messages: ["Architecture diagram:", "file:.line-hive-tmp/diagram.html"], agentName: "<name>" })
106
- ```
107
-
108
- **Long reports / docs** — when content exceeds LINE's ~2000 char limit:
109
- ```bash
110
- line_render_markdown({ inputPath: "path/to/report.md", outputPath: ".line-hive-tmp/report.html", title: "Report" })
111
- line_ask({ messages: ["Here's the full report:", "file:.line-hive-tmp/report.html"], agentName: "<name>" })
112
- ```
113
-
114
- **Diffs** — format as markdown code blocks with `diff` language:
115
- ```bash
116
- create_file(".line-hive-tmp/changes.md", "# Changes\n\n```diff\n- old line\n+ new line\n```")
117
- line_render_markdown({ inputPath: ".line-hive-tmp/changes.md", outputPath: ".line-hive-tmp/changes.html", title: "Diff" })
118
- line_ask({ messages: ["Here are the changes:", "file:.line-hive-tmp/changes.html"], agentName: "<name>" })
119
- ```
120
-
121
- **Existing .md files** — skills, READMEs, docs:
122
- ```bash
123
- line_render_markdown({ inputPath: "path/to/file.md", outputPath: ".line-hive-tmp/doc.html", title: "Title" })
124
- line_ask({ messages: ["Here's the doc:", "file:.line-hive-tmp/doc.html"], agentName: "<name>" })
125
- ```
126
-
127
- Send raw images via `messages[]` with `file:` prefix: `messages: ["Screenshot:", "file:.line-hive-tmp/screenshot.png"]` — images auto-detect by extension and display inline.
128
-
129
- ## Git Review Workflow
130
-
131
- 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.
132
-
133
- ### 3-Call Workflow
134
-
135
- ```
136
- 1. line_git_review({ mode: "scan" }) → JSON: branch, files, +/- stats
137
- 2. [Analyze: group by feature, propose commits, flag decisions]
138
- 3. line_git_review({ mode: "report", decisions, commits, groups, ttl: 120 }) → { url }
139
- 4. line_ask({ messages: ["Git review (N files, +X -Y):", url], agentName })
140
- ```
141
-
142
- ### D/A Numbering
143
-
144
- Every item is either a **D** (decision — user must answer) or an **A** (agent-proposed commit):
145
-
146
- - **D items** — things the agent can't decide: binary files, submodules, ambiguous untracked files, security-sensitive content. Format: `D1 gitignore / D1 keep / D1 delete`
147
- - **A items** — proposed commits grouped by feature. Format: `A1 · feat: add login form` with file list and reasoning
148
-
149
- ### Slot HTML Classes
150
-
151
- Build slot HTML using these pre-built CSS classes:
152
-
153
- **Decisions (`dc-box`):**
154
- ```html
155
- <div class="dc-box"><h2>⚠️ Decisions</h2>
156
- <div class="fi fw"><div class="fl">D1 · description</div>
157
- <b>D1 option1</b> / <b>D1 option2</b></div>
158
- </div>
159
- ```
160
-
161
- **Commits (`cm-box`):**
162
- ```html
163
- <div class="cm-box"><h2>📦 Commits</h2>
164
- <div class="cc"><div class="cm">A1 · feat: description</div>
165
- <div class="cf">file1.ts, file2.ts</div>
166
- <div class="cr">Reasoning</div></div>
167
- </div>
168
- ```
169
-
170
- **Groups (`gr`):**
171
- ```html
172
- <div class="gr">
173
- <div class="gh" onclick="this.nextElementSibling.style.display=
174
- this.nextElementSibling.style.display==='block'?'none':'block'">
175
- <h2>Group Name</h2><span class="bd bf">FEAT</span>
176
- </div>
177
- <div class="gb" style="display:none"><div class="gd">Details</div></div>
178
- </div>
179
- ```
180
- Badge classes: `.bf` (feature), `.bo` (docs), `.bx` (fix), `.bn` (new)
181
-
182
- ### Reply Parsing
183
-
184
- User replies with comma-separated instructions:
185
-
186
- | Pattern | Action |
187
- |---------|--------|
188
- | `ok` / `go` | Execute all A commits + push |
189
- | `skip A2` | Don't commit group A2 |
190
- | `merge A1+A3` | Combine commits |
191
- | `msg A1: new msg` | Override commit message |
192
- | `D1 ignore` | Apply decision |
193
- | `no push` | Commit but don't push |
194
- | `cancel` | Abort |
195
-
196
- **Execution order:** Apply D decisions → stage files per group → commit → push → report result.
197
-
198
- ### Grouping Heuristics
199
-
200
- 1. Shared feature (handler + test + types)
201
- 2. Shared purpose (all docs changes)
202
- 3. Shared directory (when purpose unclear)
203
- 4. Independent (single-file fixes)
204
-
205
- ### Commit Prefixes
206
-
207
- `feat:` / `fix:` / `docs:` / `refactor:` / `chore:` / `style:`
208
-
209
- ## Interactive Mode (ON DEMAND)
210
-
211
- 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 and sends `?` + Continue.
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
+
44
+ ## Quick Replies
45
+ - Default ON for bounded choices (2–6 options).
46
+ - Keep labels short; include text fallback.
47
+ - Max 13 items; attach once per `line_ask` call.
48
+ - Keep built-in queue drain behavior (`📬 Drain (N)`).
49
+
50
+ ## Token/Delivery Rules
51
+ - Batch with `messages[]` (max 5).
52
+ - Avoid duplicate send paths.
53
+ - Prefer HTML for long/rich content.
54
+ - In LINE sessions, do not send raw Markdown unless explicitly requested.
55
+
56
+ ## Git Review (Light)
57
+ - `scan` → analyze (`D#`/`A#`) `report` → `line_ask`.
58
+ - Keep command patterns (`ok`, `skip A#`, `merge`, `msg`, `D#`, `no push`, `cancel`).
212
59
 
213
60
  ## DO NOT
214
-
215
- - Call `line_*` tools outside of a LINE session
216
- - Interpret reply content ("done", "ok", "thanks") as session termination
217
- - Spam reports more often than every 2 minutes
218
- - Use interactive mode unless explicitly requested
219
- - **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.
220
- - **Pass LINE tools to subagents** — only the top-level agent calls `line_*` tools
221
- - **Install packages during a session** — user can't approve prompts while away. Install during pre-flight instead.
222
- - **Fetch external URLs during a session** — may trigger permission prompts. Only fetch when user confirms no permission issue.
223
- - **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.
224
-
225
- ### Screen Lock Warning
226
-
227
- Screen lock may re-lock the keychain or credential store, causing **SSH passphrase prompts** that block any terminal using SSH (`git push/pull`). Mitigate:
228
- - Run git remote operations **before** the user leaves (during pre-flight)
229
- - If a terminal hangs, it's likely a passphrase prompt — don't spawn more terminals
61
+ - Pass LINE tools to subagents.
62
+ - Install packages during active LINE sessions.
63
+ - Fetch external URLs during session without prompt-safety confirmation.
64
+ - Write temp files outside `.line-hive-tmp/`.