pelulu-cli 1.1.0 → 1.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.
package/docs/AGENT.md DELETED
@@ -1,237 +0,0 @@
1
- # Pelulu-CLI Agent System
2
-
3
- Pelulu-CLI now includes an OpenHands-style agent system that provides autonomous coding capabilities.
4
-
5
- ## Architecture
6
-
7
- ```
8
- ┌─────────────────────────────────────────────────────────────┐
9
- │ Agent Controller │
10
- │ Orchestrates all agent components │
11
- └──────────────────────────┬──────────────────────────────────┘
12
-
13
- ┌─────────────────┼─────────────────┐
14
- │ │ │
15
- ▼ ▼ ▼
16
- ┌─────────────┐ ┌──────────────┐ ┌──────────────┐
17
- │ Agent Loop │ │ Plan Manager │ │ LLM Client │
18
- │ (observe→ │ │ (task │ │ (XiaoZhi AI │
19
- │ think→act)│ │ decomposition│ │ via MQTT) │
20
- └──────┬──────┘ └──────────────┘ └──────────────┘
21
-
22
-
23
- ┌─────────────────────────────────────────────────────────────┐
24
- │ Tool System │
25
- │ file, shell, git, search, agent, ai, ... │
26
- └─────────────────────────────────────────────────────────────┘
27
- ```
28
-
29
- ## Components
30
-
31
- ### 1. Agent Loop (`agent-loop.js`)
32
- The core observe→think→act cycle:
33
- - **Observe**: Builds context from history, workspace, and plan
34
- - **Think**: Sends context to LLM for reasoning
35
- - **Act**: Executes tool calls returned by LLM
36
- - **Loop**: Repeats until "finish" is called or max iterations reached
37
-
38
- ### 2. Plan Manager (`plan-manager.js`)
39
- Task decomposition and tracking:
40
- - Auto-generates plans for complex tasks
41
- - Tracks step progress (pending → in_progress → completed/failed)
42
- - Supports dynamic plan modification during execution
43
- - Provides visual progress indicators
44
-
45
- ### 3. LLM Client (`llm-client.js`)
46
- Wraps XiaoZhi AI into a standard interface:
47
- - MQTT-based communication
48
- - Tool call parsing from text responses
49
- - Token usage tracking
50
- - Request timeout and abort support
51
-
52
- ### 4. Context Builder (`context-builder.js`)
53
- Builds rich workspace context:
54
- - Git status and history
55
- - Project type detection
56
- - File structure analysis
57
- - Runtime environment info
58
- - Cached for performance
59
-
60
- ### 5. History Condenser (`history-condenser.js`)
61
- Manages long conversations:
62
- - Automatic condensation when history is too long
63
- - Preserves important context (files modified, errors)
64
- - Optional LLM-based summarization
65
- - Token-aware windowing
66
-
67
- ### 6. System Prompt (`system-prompt.js`)
68
- Builds comprehensive prompts:
69
- - Agent identity and capabilities
70
- - Tool descriptions with schemas
71
- - Workspace context
72
- - Microagents/skills (trigger-based)
73
- - Plan status
74
- - Guidelines and constraints
75
-
76
- ## Usage
77
-
78
- ### Basic Usage
79
- The agent system is automatically initialized when you start Pelulu-CLI:
80
-
81
- ```bash
82
- pelulu
83
- ```
84
-
85
- Then simply describe your task:
86
- ```
87
- > Fix the bug in auth.js where login fails with special characters
88
- ```
89
-
90
- ### Disable Agent Mode
91
- If you want to use the legacy direct tool call mode:
92
-
93
- ```bash
94
- pelulu --no-agent
95
- ```
96
-
97
- ### Debug Mode
98
- Enable debug logging:
99
-
100
- ```bash
101
- pelulu --debug
102
- ```
103
-
104
- ## Agent Tool
105
-
106
- The agent system is exposed as a tool that can be called directly:
107
-
108
- ```json
109
- {
110
- "tool": "agent",
111
- "action": "run",
112
- "task": "Implement user authentication with JWT"
113
- }
114
- ```
115
-
116
- ### Actions
117
-
118
- | Action | Description |
119
- |--------|-------------|
120
- | `run` | Execute a task with the agent loop |
121
- | `plan` | Create, view, or manage plans |
122
- | `status` | Get agent status and summary |
123
- | `abort` | Abort the current run |
124
- | `reset` | Reset agent state |
125
- | `history` | Get conversation history |
126
- | `context` | Get workspace context |
127
-
128
- ## Plan Management
129
-
130
- ### Auto-Planning
131
- Complex tasks automatically get plans:
132
- ```
133
- > Implement a REST API with user authentication, CRUD operations, and tests
134
-
135
- 📋 Plan: Implement REST API
136
- ────────────────────────────
137
- 🔄 1. Set up Express project structure
138
- ⬜ 2. Create User model with Mongoose
139
- ⬜ 3. Implement authentication middleware
140
- ⬜ 4. Create CRUD routes for users
141
- ⬜ 5. Add input validation
142
- ⬜ 6. Write unit tests
143
- ⬜ 7. Test the API
144
- ────────────────────────────
145
- Progress: 14%
146
- ```
147
-
148
- ### Manual Planning
149
- Create plans explicitly:
150
- ```json
151
- {
152
- "tool": "agent",
153
- "action": "plan",
154
- "goal": "Refactor auth module",
155
- "steps": [
156
- { "description": "Extract auth logic to separate file" },
157
- { "description": "Add JWT support" },
158
- { "description": "Update tests" }
159
- ]
160
- }
161
- ```
162
-
163
- ## Skills/Microagents
164
-
165
- Pelulu-CLI loads skills from:
166
- - `.pelulu/skills/*.md`
167
- - `.openhands/microagents/*.md`
168
- - `.agents/skills/*.md`
169
-
170
- ### Skill File Format
171
- ```markdown
172
- ---
173
- triggers:
174
- - authentication
175
- - jwt
176
- - login
177
- ---
178
- # Authentication Best Practices
179
-
180
- When implementing authentication:
181
- 1. Always hash passwords with bcrypt
182
- 2. Use JWT with short expiration
183
- 3. Implement refresh tokens
184
- 4. Add rate limiting to login endpoints
185
- ```
186
-
187
- Skills with triggers are only loaded when the user's message matches the trigger keywords.
188
-
189
- ## Configuration
190
-
191
- Add to your `pelulu.config.json`:
192
-
193
- ```json
194
- {
195
- "agent": {
196
- "name": "Pelulu",
197
- "max_iterations": 100,
198
- "max_history": 50,
199
- "auto_plan": true,
200
- "max_tokens": 100000
201
- }
202
- }
203
- ```
204
-
205
- | Option | Default | Description |
206
- |--------|---------|-------------|
207
- | `max_iterations` | 100 | Maximum agent loop iterations |
208
- | `max_history` | 50 | Maximum messages before condensation |
209
- | `auto_plan` | true | Auto-generate plans for complex tasks |
210
- | `max_tokens` | 100000 | Token limit for history |
211
-
212
- ## Differences from OpenHands
213
-
214
- | Feature | OpenHands | Pelulu-CLI |
215
- |---------|-----------|------------|
216
- | LLM | OpenAI/Anthropic/etc | XiaoZhi AI (MQTT) |
217
- | Runtime | Docker sandbox | Local execution |
218
- | UI | Web React | Terminal Ink |
219
- | Planning | Optional | Auto for complex tasks |
220
- | Skills | Global + repo | Local files |
221
- | Multi-agent | Yes | Single agent |
222
-
223
- ## Troubleshooting
224
-
225
- ### Agent not responding
226
- 1. Check MQTT connection: `pelulu --debug`
227
- 2. Verify XiaoZhi is activated
228
- 3. Check network connectivity
229
-
230
- ### Plan not generating
231
- - Ensure `auto_plan: true` in config
232
- - Task must be complex enough (50+ chars, contain action words)
233
-
234
- ### History too long
235
- - The agent auto-condenses history
236
- - Use `agent.history` with `condensed: true`
237
- - Adjust `max_history` in config
@@ -1,46 +0,0 @@
1
- # XiaoZhi MQTT Broker Specifications
2
-
3
- ## MCP Tools/List Response Size Limit
4
-
5
- - **Limit:** ~8KB (8,192 bytes estimated)
6
- - **Behavior:** Broker disconnects client immediately after receiving `tools/list` response that exceeds the limit
7
- - **Tested:**
8
- - 15,423 bytes → ❌ Disconnected
9
- - 10,344 bytes → ❌ Disconnected
10
- - 9,104 bytes → ❌ Disconnected
11
- - 8,894 bytes → ❌ Disconnected
12
- - 8,079 bytes → ✅ Connected
13
- - 7,656 bytes → ✅ Connected
14
- - 7,928 bytes → ✅ Connected (Pelulu-CLI baseline)
15
-
16
- ## Content Filtering
17
-
18
- - **No content filtering detected.** Tool names like `bruteforce`, `exploit`, `sqli`, `injection`, `fuzzer`, `evasion`, `vuln` are accepted as long as response is under 8KB.
19
-
20
- ## Optimization Techniques (to stay under 8KB)
21
-
22
- 1. Remove `description` from inputSchema properties
23
- 2. Remove `action` enum values (keep as plain `{ type: "string" }`)
24
- 3. Trim tool descriptions to essential keywords only
25
-
26
- ## MQTT Connection
27
-
28
- - **Endpoint:** `mqtt.xiaozhi.me:8883` (MQTTS)
29
- - **Keepalive:** 60s recommended (240s may cause issues)
30
- - **Protocol:** MQTT v3.1.1 (v5 rejected)
31
- - **Subscribe topic:** `devices/p2p/#`
32
- - **Publish topic:** `device-server` (from OTA response)
33
- - **subscribe_topic from OTA:** Always `"null"` (string, not null)
34
-
35
- ## Device Activation
36
-
37
- - **OTA URL:** `https://api.tenclass.net/xiaozhi/ota/`
38
- - **Activation URL:** `https://xiaozhi.me`
39
- - **Device name:** Set in `board.name` field of OTA request
40
- - **Credentials:** Fresh credentials from OTA for each connection (do not cache/reuse)
41
-
42
- ## Tool Execution Notes
43
-
44
- - **Port scanning:** Use `nc -z -w1` (netcat) instead of `bash /dev/tcp` for reliable scanning
45
- - **Timeout:** 15 default ports × 1s timeout = ~15-20s total (within 30s tool timeout)
46
- - **Shell escaping:** Use semicolons (`;`) not newlines when passing multi-command scripts to `bash -c` via `JSON.stringify`