agentk8 1.0.2 → 1.0.4
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/README.md +229 -100
- package/agentk +28 -14
- package/lib/core.sh +1 -1
- package/lib/ui.sh +193 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,64 +2,93 @@
|
|
|
2
2
|
|
|
3
3
|
**Multi-Agent Claude Code Terminal Suite**
|
|
4
4
|
|
|
5
|
-
Orchestrate multiple specialized Claude agents for software development and ML research. Inspired by Boris Cherny's parallel Claude workflow.
|
|
6
|
-
|
|
7
5
|
```
|
|
8
|
-
|
|
9
|
-
│
|
|
10
|
-
|
|
6
|
+
╭─────────────────────────────────────────────────────────────────────────────────╮
|
|
7
|
+
│ AGENT-K v1.0 │
|
|
8
|
+
╰─────────────────────────────────────────────────────────────────────────────────╯
|
|
9
|
+
```
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Transform your terminal into a team of specialized AI agents. AGENT-K orchestrates multiple Claude instances working in parallel on your software development and ML research tasks.
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
→ Engineer: Implement JWT auth module
|
|
16
|
-
→ Tester: Write auth tests
|
|
17
|
-
→ Security: Review for vulnerabilities
|
|
13
|
+
## What is AGENT-K?
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
[◐] Engineer Writing src/auth.py...
|
|
21
|
-
[ ] Tester Waiting
|
|
22
|
-
[ ] Security Waiting
|
|
15
|
+
AGENT-K extends Claude Code with **multi-agent orchestration**. Instead of a single AI assistant, you get a coordinated team of specialists - each with domain expertise, working together on complex tasks.
|
|
23
16
|
|
|
24
|
-
|
|
17
|
+
```
|
|
18
|
+
╭─ You ────────────────────────────────────────────────────────────────────────────╮
|
|
19
|
+
│ Build a secure REST API with user authentication │
|
|
20
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
21
|
+
|
|
22
|
+
╭─ Orchestrator ───────────────────────────────────────────────────────────────────╮
|
|
23
|
+
│ Breaking down task... │
|
|
24
|
+
│ → Engineer: Implement REST endpoints and JWT authentication │
|
|
25
|
+
│ → Tester: Write API integration tests │
|
|
26
|
+
│ → Security: Review for OWASP vulnerabilities │
|
|
27
|
+
│ → Scout: Find latest best practices for JWT in 2025 │
|
|
28
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
29
|
+
|
|
30
|
+
[●] Orchestrator Coordinating
|
|
31
|
+
[◐] Engineer Writing src/api/auth.py...
|
|
32
|
+
[◐] Scout Searching for JWT best practices...
|
|
33
|
+
[ ] Tester Waiting for implementation
|
|
34
|
+
[ ] Security Queued for review
|
|
25
35
|
```
|
|
26
36
|
|
|
37
|
+
## Why AGENT-K?
|
|
38
|
+
|
|
39
|
+
### The Problem
|
|
40
|
+
|
|
41
|
+
Claude is brilliant, but complex tasks often require:
|
|
42
|
+
- **Multiple perspectives** (implementation, testing, security)
|
|
43
|
+
- **Parallel work** (why write tests sequentially after code?)
|
|
44
|
+
- **Up-to-date information** (Claude's training data becomes stale)
|
|
45
|
+
- **Specialized focus** (security reviews need different prompts than coding)
|
|
46
|
+
|
|
47
|
+
### The Solution
|
|
48
|
+
|
|
49
|
+
AGENT-K spawns specialized Claude agents that:
|
|
50
|
+
- **Work in parallel** on different aspects of your task
|
|
51
|
+
- **Coordinate automatically** through a central orchestrator
|
|
52
|
+
- **Stay current** with a dedicated Scout agent for real-time research
|
|
53
|
+
- **Follow best practices** with domain-specific system prompts
|
|
54
|
+
|
|
27
55
|
## Features
|
|
28
56
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
| Feature | Description |
|
|
58
|
+
|---------|-------------|
|
|
59
|
+
| **Multi-Agent Orchestration** | Coordinate 5-6 specialized agents working in parallel |
|
|
60
|
+
| **Two Modes** | Software Development (default) and ML Research & Training |
|
|
61
|
+
| **Interactive Chat** | Familiar interface like `claude` but with a whole team |
|
|
62
|
+
| **Visual Mode** | tmux-based multi-pane view of all agents working |
|
|
63
|
+
| **Scout Agent** | Real-time web/GitHub/paper search to stay current |
|
|
64
|
+
| **Date Awareness** | Agents know when to verify potentially outdated info |
|
|
65
|
+
| **Focus Mode** | Talk directly to any specialist agent |
|
|
66
|
+
| **File-Based IPC** | Agents coordinate through structured JSON messages |
|
|
35
67
|
|
|
36
|
-
##
|
|
68
|
+
## Agent Teams
|
|
37
69
|
|
|
38
70
|
### Development Mode (Default)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
| **
|
|
43
|
-
| **
|
|
44
|
-
| **
|
|
45
|
-
| **
|
|
71
|
+
|
|
72
|
+
| Agent | Specialty |
|
|
73
|
+
|-------|-----------|
|
|
74
|
+
| **Orchestrator** | Task decomposition, coordination, result aggregation |
|
|
75
|
+
| **Engineer** | Code implementation, debugging, refactoring |
|
|
76
|
+
| **Tester** | Unit/integration tests, coverage analysis |
|
|
77
|
+
| **Security** | OWASP vulnerability review, secrets detection |
|
|
78
|
+
| **Scout** | Real-time search for current best practices |
|
|
46
79
|
|
|
47
80
|
### ML Mode (`--mode ml`)
|
|
48
|
-
| Agent | Role |
|
|
49
|
-
|-------|------|
|
|
50
|
-
| **Orchestrator** | Manages ML project lifecycle |
|
|
51
|
-
| **Researcher** | Literature review, SOTA analysis |
|
|
52
|
-
| **ML Engineer** | Model implementation, training |
|
|
53
|
-
| **Data Engineer** | Data pipelines, preprocessing |
|
|
54
|
-
| **Evaluator** | Metrics, benchmarking, experiments |
|
|
55
|
-
| **Scout** | Searches arXiv, HuggingFace, Papers With Code |
|
|
56
81
|
|
|
57
|
-
|
|
82
|
+
| Agent | Specialty |
|
|
83
|
+
|-------|-----------|
|
|
84
|
+
| **Orchestrator** | ML project lifecycle management |
|
|
85
|
+
| **Researcher** | Literature review, SOTA analysis, paper summaries |
|
|
86
|
+
| **ML Engineer** | Model implementation, training loops, optimization |
|
|
87
|
+
| **Data Engineer** | Data pipelines, preprocessing, augmentation |
|
|
88
|
+
| **Evaluator** | Metrics, benchmarking, experiment tracking |
|
|
89
|
+
| **Scout** | arXiv, HuggingFace, Papers With Code search |
|
|
58
90
|
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
curl -sSL https://raw.githubusercontent.com/de5truct0/agentk/main/install.sh | bash
|
|
62
|
-
```
|
|
91
|
+
## Installation
|
|
63
92
|
|
|
64
93
|
### Homebrew (macOS/Linux)
|
|
65
94
|
```bash
|
|
@@ -77,7 +106,10 @@ npm install -g agentk8
|
|
|
77
106
|
pip install agentk8
|
|
78
107
|
```
|
|
79
108
|
|
|
80
|
-
|
|
109
|
+
### Quick Install Script
|
|
110
|
+
```bash
|
|
111
|
+
curl -sSL https://raw.githubusercontent.com/de5truct0/agentk/main/install.sh | bash
|
|
112
|
+
```
|
|
81
113
|
|
|
82
114
|
### From Source
|
|
83
115
|
```bash
|
|
@@ -86,127 +118,216 @@ cd agentk
|
|
|
86
118
|
make install
|
|
87
119
|
```
|
|
88
120
|
|
|
121
|
+
> **Note**: Package name is `agentk8` on all registries. The installed command is `agentk`.
|
|
122
|
+
|
|
89
123
|
## Requirements
|
|
90
124
|
|
|
91
|
-
- **
|
|
92
|
-
- **
|
|
93
|
-
- **
|
|
94
|
-
- **tmux** (optional, for visual mode)
|
|
125
|
+
- **jq** - JSON processing (`brew install jq`)
|
|
126
|
+
- **claude** - Claude Code CLI ([Install here](https://claude.ai/code))
|
|
127
|
+
- **tmux** - Optional, for visual mode (`brew install tmux`)
|
|
95
128
|
|
|
96
|
-
##
|
|
129
|
+
## Quick Start
|
|
97
130
|
|
|
98
|
-
### Start Interactive Session
|
|
99
131
|
```bash
|
|
100
|
-
|
|
101
|
-
agentk
|
|
102
|
-
|
|
132
|
+
# Start interactive session
|
|
133
|
+
agentk
|
|
134
|
+
|
|
135
|
+
# Start ML research mode
|
|
136
|
+
agentk --mode ml
|
|
137
|
+
|
|
138
|
+
# Start with visual panels (requires tmux)
|
|
139
|
+
agentk --visual
|
|
140
|
+
|
|
141
|
+
# One-shot task
|
|
142
|
+
agentk -c "Refactor the user service to use async/await"
|
|
103
143
|
```
|
|
104
144
|
|
|
105
|
-
|
|
145
|
+
## Usage
|
|
146
|
+
|
|
147
|
+
### Interactive Session
|
|
148
|
+
|
|
106
149
|
```bash
|
|
107
|
-
agentk
|
|
150
|
+
$ agentk
|
|
151
|
+
|
|
152
|
+
╭─────────────────────────────────────────────────╮
|
|
153
|
+
│ AGENT-K v1.0 │
|
|
154
|
+
╰─────────────────────────────────────────────────╯
|
|
155
|
+
Mode: Software Development Mode
|
|
156
|
+
|
|
157
|
+
Type your request or /help for commands.
|
|
158
|
+
|
|
159
|
+
╭─ You ─────────────────────────────────────────────────
|
|
160
|
+
│
|
|
108
161
|
```
|
|
109
162
|
|
|
110
163
|
### Session Commands
|
|
164
|
+
|
|
111
165
|
| Command | Description |
|
|
112
166
|
|---------|-------------|
|
|
113
|
-
| `/status` | Show all agent states |
|
|
167
|
+
| `/status` | Show all agent states and current tasks |
|
|
114
168
|
| `/logs <agent>` | View agent output |
|
|
115
169
|
| `/kill <agent\|all>` | Stop agent(s) |
|
|
116
|
-
| `/focus <agent>` | Talk directly to agent |
|
|
170
|
+
| `/focus <agent>` | Talk directly to one agent |
|
|
117
171
|
| `/unfocus` | Return to orchestrator |
|
|
118
|
-
| `/visual` | Toggle tmux view |
|
|
172
|
+
| `/visual` | Toggle tmux panel view |
|
|
173
|
+
| `/clear` | Clear screen |
|
|
119
174
|
| `/help` | Show all commands |
|
|
120
175
|
| `/exit` | End session |
|
|
121
176
|
|
|
122
|
-
### Scout Commands
|
|
177
|
+
### Scout Commands (Both Modes)
|
|
178
|
+
|
|
123
179
|
| Command | Description |
|
|
124
180
|
|---------|-------------|
|
|
125
|
-
| `/search <query>` | Web search |
|
|
126
|
-
| `/github <query>` | Search GitHub |
|
|
127
|
-
| `/papers <topic>` | Search
|
|
128
|
-
| `/libs <task>` | Find best libraries |
|
|
129
|
-
| `/sota <topic>` |
|
|
181
|
+
| `/search <query>` | Web search for latest info |
|
|
182
|
+
| `/github <query>` | Search GitHub repos and code |
|
|
183
|
+
| `/papers <topic>` | Search arXiv/Semantic Scholar |
|
|
184
|
+
| `/libs <task>` | Find best libraries for task |
|
|
185
|
+
| `/sota <topic>` | Get state-of-the-art approaches |
|
|
186
|
+
|
|
187
|
+
### ML-Specific Commands
|
|
130
188
|
|
|
131
|
-
### ML Commands
|
|
132
189
|
| Command | Description |
|
|
133
190
|
|---------|-------------|
|
|
134
|
-
| `/experiment <name>` | Start experiment |
|
|
135
|
-
| `/metrics` | Show metrics |
|
|
191
|
+
| `/experiment <name>` | Start a new experiment |
|
|
192
|
+
| `/metrics` | Show current training metrics |
|
|
136
193
|
| `/tensorboard` | Open TensorBoard |
|
|
137
|
-
| `/
|
|
194
|
+
| `/checkpoint` | Save model state |
|
|
195
|
+
| `/compare <e1> <e2>` | Compare experiments |
|
|
196
|
+
| `/huggingface <query>` | Search HuggingFace Hub |
|
|
138
197
|
|
|
139
198
|
## Visual Mode
|
|
140
199
|
|
|
200
|
+
Launch with `--visual` to see all agents in a tmux layout:
|
|
201
|
+
|
|
141
202
|
```
|
|
142
|
-
|
|
143
|
-
│
|
|
144
|
-
|
|
145
|
-
│
|
|
146
|
-
|
|
203
|
+
┌───────────────────┬───────────────────┬───────────────────┐
|
|
204
|
+
│ ORCHESTRATOR │ ENGINEER │ TESTER │
|
|
205
|
+
│ │ │ │
|
|
206
|
+
│ Breaking down │ Implementing │ Waiting for │
|
|
207
|
+
│ task into │ auth module... │ implementation... │
|
|
208
|
+
│ subtasks... │ │ │
|
|
209
|
+
├───────────────────┼───────────────────┼───────────────────┤
|
|
210
|
+
│ SECURITY │ SCOUT │ [MAIN] │
|
|
211
|
+
│ │ │ │
|
|
212
|
+
│ Queued for │ Searching JWT │ You: _ │
|
|
213
|
+
│ review │ best practices... │ │
|
|
214
|
+
│ │ │ │
|
|
215
|
+
└───────────────────┴───────────────────┴───────────────────┘
|
|
147
216
|
```
|
|
148
217
|
|
|
149
218
|
## How It Works
|
|
150
219
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
220
|
+
```
|
|
221
|
+
┌─────────────┐
|
|
222
|
+
│ User │
|
|
223
|
+
└──────┬──────┘
|
|
224
|
+
│
|
|
225
|
+
▼
|
|
226
|
+
┌────────────────────────┐
|
|
227
|
+
│ Orchestrator │
|
|
228
|
+
│ (task decomposition) │
|
|
229
|
+
└───────────┬────────────┘
|
|
230
|
+
│
|
|
231
|
+
┌────────────────────┼────────────────────┐
|
|
232
|
+
│ │ │
|
|
233
|
+
▼ ▼ ▼
|
|
234
|
+
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
|
|
235
|
+
│ Engineer │ │ Tester │ │ Security │
|
|
236
|
+
│ (implements) │ │ (validates) │ │ (reviews) │
|
|
237
|
+
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
|
|
238
|
+
│ │ │
|
|
239
|
+
└────────────────────┴────────────────────┘
|
|
240
|
+
│
|
|
241
|
+
▼
|
|
242
|
+
┌────────────────────────┐
|
|
243
|
+
│ File-Based IPC │
|
|
244
|
+
│ workspace/tasks/*.json │
|
|
245
|
+
└────────────────────────┘
|
|
246
|
+
```
|
|
156
247
|
|
|
157
|
-
|
|
248
|
+
1. **You enter a request** in the interactive session
|
|
249
|
+
2. **Orchestrator analyzes** and breaks it into subtasks
|
|
250
|
+
3. **Specialist agents spawn** as parallel Claude subprocesses
|
|
251
|
+
4. Agents work **on your actual project files**
|
|
252
|
+
5. **Results aggregate** back through the orchestrator
|
|
253
|
+
6. You see the **combined output** with full context
|
|
158
254
|
|
|
159
255
|
## Configuration
|
|
160
256
|
|
|
161
|
-
Create `~/.agentk/config.sh
|
|
257
|
+
Create `~/.agentk/config.sh`:
|
|
162
258
|
|
|
163
259
|
```bash
|
|
164
|
-
#
|
|
260
|
+
# Custom model (default: claude-3-sonnet)
|
|
165
261
|
export AGENTK_MODEL="claude-3-opus-20240229"
|
|
166
262
|
|
|
167
|
-
#
|
|
168
|
-
export LOG_LEVEL="
|
|
263
|
+
# Log level: debug, info, warn, error
|
|
264
|
+
export LOG_LEVEL="info"
|
|
169
265
|
|
|
170
266
|
# Custom workspace location
|
|
171
|
-
export AGENTK_WORKSPACE="/path/
|
|
267
|
+
export AGENTK_WORKSPACE="/custom/path/workspace"
|
|
268
|
+
|
|
269
|
+
# Parallel agent limit (default: 4)
|
|
270
|
+
export AGENTK_MAX_PARALLEL=6
|
|
172
271
|
```
|
|
173
272
|
|
|
174
273
|
## Project Structure
|
|
175
274
|
|
|
176
275
|
```
|
|
177
276
|
agentk/
|
|
178
|
-
├── agentk # Main CLI
|
|
277
|
+
├── agentk # Main CLI entry point
|
|
179
278
|
├── lib/
|
|
180
|
-
│ ├── core.sh # Core utilities
|
|
181
|
-
│ ├── ui.sh #
|
|
279
|
+
│ ├── core.sh # Core utilities, logging, date context
|
|
280
|
+
│ ├── ui.sh # Terminal UI, spinners, chat boundaries
|
|
182
281
|
│ ├── ipc.sh # Inter-process communication
|
|
183
|
-
│ ├── spawn.sh # Agent
|
|
282
|
+
│ ├── spawn.sh # Agent subprocess management
|
|
184
283
|
│ └── visual.sh # tmux integration
|
|
185
284
|
├── modes/
|
|
186
285
|
│ ├── shared/
|
|
187
|
-
│ │ └── scout.md # Scout agent prompt
|
|
188
|
-
│ ├── dev/ #
|
|
189
|
-
│
|
|
286
|
+
│ │ └── scout.md # Scout agent system prompt
|
|
287
|
+
│ ├── dev/ # Development mode prompts
|
|
288
|
+
│ │ ├── orchestrator.md
|
|
289
|
+
│ │ ├── engineer.md
|
|
290
|
+
│ │ ├── tester.md
|
|
291
|
+
│ │ └── security.md
|
|
292
|
+
│ └── ml/ # ML mode prompts
|
|
293
|
+
│ ├── orchestrator.md
|
|
294
|
+
│ ├── researcher.md
|
|
295
|
+
│ ├── ml-engineer.md
|
|
296
|
+
│ ├── data-engineer.md
|
|
297
|
+
│ └── evaluator.md
|
|
190
298
|
└── workspace/ # Runtime data (gitignored)
|
|
299
|
+
├── tasks/ # Task queue (JSON)
|
|
300
|
+
├── results/ # Agent outputs
|
|
301
|
+
├── logs/ # Agent logs
|
|
302
|
+
└── experiments/ # ML experiment tracking
|
|
191
303
|
```
|
|
192
304
|
|
|
193
305
|
## Known Limitations
|
|
194
306
|
|
|
195
|
-
|
|
307
|
+
| Limitation | Workaround |
|
|
308
|
+
|------------|------------|
|
|
309
|
+
| File conflicts when agents edit same file | Use `/focus` to serialize work on critical files |
|
|
310
|
+
| Each agent = separate API call (cost) | Use orchestrator's judgment on when to parallelize |
|
|
311
|
+
| Agents don't share real-time context | Orchestrator maintains shared state in workspace |
|
|
312
|
+
| Rate limiting with many parallel agents | `AGENTK_MAX_PARALLEL` limits concurrent spawns |
|
|
313
|
+
|
|
314
|
+
## Roadmap
|
|
196
315
|
|
|
197
|
-
-
|
|
198
|
-
-
|
|
199
|
-
-
|
|
200
|
-
-
|
|
316
|
+
- [ ] Web UI dashboard
|
|
317
|
+
- [ ] Custom agent definitions
|
|
318
|
+
- [ ] Persistent conversation history
|
|
319
|
+
- [ ] Cost tracking per agent
|
|
320
|
+
- [ ] Team collaboration mode
|
|
321
|
+
- [ ] Plugin system for custom tools
|
|
201
322
|
|
|
202
323
|
## Contributing
|
|
203
324
|
|
|
204
|
-
Contributions welcome!
|
|
325
|
+
Contributions welcome!
|
|
205
326
|
|
|
206
327
|
1. Fork the repository
|
|
207
|
-
2. Create a feature branch
|
|
328
|
+
2. Create a feature branch (`git checkout -b feature/amazing`)
|
|
208
329
|
3. Make your changes
|
|
209
|
-
4. Run tests
|
|
330
|
+
4. Run tests (`make test`)
|
|
210
331
|
5. Submit a pull request
|
|
211
332
|
|
|
212
333
|
## License
|
|
@@ -215,10 +336,18 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
215
336
|
|
|
216
337
|
## Acknowledgments
|
|
217
338
|
|
|
218
|
-
- Inspired by [Boris Cherny's Claude
|
|
339
|
+
- Inspired by [Boris Cherny's parallel Claude workflow](https://x.com/bcherny)
|
|
219
340
|
- Built for the Claude Code community
|
|
220
341
|
- Powered by [Anthropic's Claude](https://anthropic.com)
|
|
221
342
|
|
|
222
343
|
---
|
|
223
344
|
|
|
224
|
-
|
|
345
|
+
<p align="center">
|
|
346
|
+
<strong>AGENT-K</strong> - Because one Claude is good, but a team of Claudes is better.
|
|
347
|
+
</p>
|
|
348
|
+
|
|
349
|
+
<p align="center">
|
|
350
|
+
<a href="https://github.com/de5truct0/agentk">GitHub</a> |
|
|
351
|
+
<a href="https://www.npmjs.com/package/agentk8">npm</a> |
|
|
352
|
+
<a href="https://pypi.org/project/agentk8/">PyPI</a>
|
|
353
|
+
</p>
|
package/agentk
CHANGED
|
@@ -279,11 +279,12 @@ cmd_visual() {
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
cmd_exit() {
|
|
282
|
-
|
|
283
|
-
end_session
|
|
282
|
+
echo
|
|
284
283
|
kill_all_agents
|
|
284
|
+
print_session_stats
|
|
285
|
+
end_session
|
|
286
|
+
echo "${GREEN}✦ Goodbye!${RESET}"
|
|
285
287
|
echo
|
|
286
|
-
echo "${GREEN}Goodbye!${RESET}"
|
|
287
288
|
exit 0
|
|
288
289
|
}
|
|
289
290
|
|
|
@@ -297,7 +298,10 @@ cmd_scout() {
|
|
|
297
298
|
fi
|
|
298
299
|
|
|
299
300
|
local scout_task="$cmd: $query"
|
|
300
|
-
|
|
301
|
+
|
|
302
|
+
# Show Scout response box
|
|
303
|
+
print_agent_response_start "Scout"
|
|
304
|
+
printf "${CYAN}│${RESET} Searching: %s\n" "$query"
|
|
301
305
|
|
|
302
306
|
# Create task for scout
|
|
303
307
|
local task_id
|
|
@@ -307,7 +311,7 @@ cmd_scout() {
|
|
|
307
311
|
spawn_agent "scout" "$task_id" "$AGENTK_MODE"
|
|
308
312
|
|
|
309
313
|
# Wait for result
|
|
310
|
-
|
|
314
|
+
printf "${CYAN}│${RESET} ${DIM}Processing...${RESET}\n"
|
|
311
315
|
watch_task "$task_id" 120
|
|
312
316
|
|
|
313
317
|
# Display result
|
|
@@ -316,9 +320,10 @@ cmd_scout() {
|
|
|
316
320
|
if [[ -f "$result_file" ]]; then
|
|
317
321
|
local output
|
|
318
322
|
output=$(jq -r '.output' "$result_file")
|
|
319
|
-
|
|
320
|
-
echo "$output"
|
|
323
|
+
print_chat_content "$output" "${CYAN}│${RESET}"
|
|
321
324
|
fi
|
|
325
|
+
|
|
326
|
+
print_agent_response_end
|
|
322
327
|
}
|
|
323
328
|
|
|
324
329
|
cmd_ml() {
|
|
@@ -380,9 +385,6 @@ run_interactive() {
|
|
|
380
385
|
print_banner
|
|
381
386
|
print_mode_banner "$AGENTK_MODE"
|
|
382
387
|
|
|
383
|
-
echo "Type your request or /help for commands."
|
|
384
|
-
echo
|
|
385
|
-
|
|
386
388
|
# Main loop
|
|
387
389
|
while true; do
|
|
388
390
|
# Show prompt
|
|
@@ -415,11 +417,15 @@ run_interactive() {
|
|
|
415
417
|
continue
|
|
416
418
|
fi
|
|
417
419
|
|
|
420
|
+
# Show user message in a box
|
|
421
|
+
print_user_input_box "$input"
|
|
422
|
+
|
|
418
423
|
# Regular input - send to orchestrator (or focused agent)
|
|
419
424
|
local target_agent="${FOCUSED_AGENT:-orchestrator}"
|
|
420
425
|
|
|
421
|
-
|
|
422
|
-
|
|
426
|
+
# Show agent response
|
|
427
|
+
print_agent_response_start "Orchestrator"
|
|
428
|
+
printf "${CYAN}│${RESET} Analyzing task...\n"
|
|
423
429
|
|
|
424
430
|
# Create task
|
|
425
431
|
local task_id
|
|
@@ -428,7 +434,7 @@ run_interactive() {
|
|
|
428
434
|
# For now, spawn the agent interactively
|
|
429
435
|
spawn_agent_interactive "$target_agent" "$AGENTK_MODE" "$input"
|
|
430
436
|
|
|
431
|
-
|
|
437
|
+
print_agent_response_end
|
|
432
438
|
done
|
|
433
439
|
}
|
|
434
440
|
|
|
@@ -446,15 +452,23 @@ run_one_shot() {
|
|
|
446
452
|
|
|
447
453
|
print_banner
|
|
448
454
|
print_mode_banner "$AGENTK_MODE"
|
|
449
|
-
|
|
455
|
+
|
|
456
|
+
# Show user input with chat boundaries
|
|
457
|
+
print_user_input_box "$prompt"
|
|
450
458
|
|
|
451
459
|
# Create task for orchestrator
|
|
452
460
|
local task_id
|
|
453
461
|
task_id=$(create_task "" "orchestrate" "orchestrator" "$prompt" 1)
|
|
454
462
|
|
|
463
|
+
# Show orchestrator response
|
|
464
|
+
print_agent_response_start "Orchestrator"
|
|
465
|
+
printf "${CYAN}│${RESET} Processing your request...\n"
|
|
466
|
+
|
|
455
467
|
# Spawn orchestrator interactively
|
|
456
468
|
spawn_agent_interactive "orchestrator" "$AGENTK_MODE" "$prompt"
|
|
457
469
|
|
|
470
|
+
print_agent_response_end
|
|
471
|
+
|
|
458
472
|
# Cleanup
|
|
459
473
|
end_session
|
|
460
474
|
}
|
package/lib/core.sh
CHANGED
|
@@ -8,7 +8,7 @@ set -euo pipefail
|
|
|
8
8
|
# CONSTANTS
|
|
9
9
|
# =============================================================================
|
|
10
10
|
|
|
11
|
-
AGENTK_VERSION="1.0.
|
|
11
|
+
AGENTK_VERSION="1.0.4"
|
|
12
12
|
AGENTK_ROOT="${AGENTK_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
|
13
13
|
AGENTK_WORKSPACE="${AGENTK_ROOT}/workspace"
|
|
14
14
|
CLAUDE_KNOWLEDGE_CUTOFF="2024-04"
|
package/lib/ui.sh
CHANGED
|
@@ -34,8 +34,15 @@ STATUS_ACTIVE="[●]"
|
|
|
34
34
|
STATUS_DONE="[✓]"
|
|
35
35
|
STATUS_FAILED="[✗]"
|
|
36
36
|
|
|
37
|
-
# Spinner frames
|
|
37
|
+
# Spinner frames - retro style
|
|
38
38
|
SPINNER_FRAMES=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏")
|
|
39
|
+
SPINNER_ALT=("◐" "◓" "◑" "◒")
|
|
40
|
+
SPINNER_DOTS=("⣾" "⣽" "⣻" "⢿" "⡿" "⣟" "⣯" "⣷")
|
|
41
|
+
SPINNER_STAR=("✶" "✷" "✸" "✹" "✺" "✹" "✸" "✷")
|
|
42
|
+
|
|
43
|
+
# Session token tracking
|
|
44
|
+
_SESSION_TOKENS=0
|
|
45
|
+
_SESSION_START_TIME=""
|
|
39
46
|
|
|
40
47
|
# Progress bar
|
|
41
48
|
PROGRESS_FILLED="█"
|
|
@@ -138,27 +145,26 @@ close_box() {
|
|
|
138
145
|
# =============================================================================
|
|
139
146
|
|
|
140
147
|
print_banner() {
|
|
141
|
-
|
|
142
|
-
width=$(get_terminal_width)
|
|
143
|
-
[[ $width -gt 60 ]] && width=60
|
|
144
|
-
|
|
145
|
-
echo
|
|
146
|
-
draw_box "AGENT-K v${AGENTK_VERSION}" "$width"
|
|
147
|
-
close_box "$width"
|
|
148
|
+
init_session_stats
|
|
148
149
|
echo
|
|
150
|
+
echo "${BOLD}${CYAN}╔═══════════════════════════════════════╗${RESET}"
|
|
151
|
+
echo "${BOLD}${CYAN}║${RESET} ${BOLD}✦ AGENT-K ✦${RESET} ${DIM}v${AGENTK_VERSION}${RESET} ${BOLD}${CYAN}║${RESET}"
|
|
152
|
+
echo "${BOLD}${CYAN}╚═══════════════════════════════════════╝${RESET}"
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
print_mode_banner() {
|
|
152
156
|
local mode="$1"
|
|
153
157
|
local mode_display
|
|
158
|
+
local mode_icon
|
|
154
159
|
|
|
155
160
|
case "$mode" in
|
|
156
|
-
dev) mode_display="
|
|
157
|
-
ml) mode_display="ML Research
|
|
158
|
-
*) mode_display="$mode
|
|
161
|
+
dev) mode_display="Development" ; mode_icon="⚡" ;;
|
|
162
|
+
ml) mode_display="ML Research" ; mode_icon="🧠" ;;
|
|
163
|
+
*) mode_display="$mode" ; mode_icon="◆" ;;
|
|
159
164
|
esac
|
|
160
165
|
|
|
161
|
-
echo
|
|
166
|
+
echo
|
|
167
|
+
echo "${DIM}$mode_icon $mode_display │ /help for commands │ /exit to quit${RESET}"
|
|
162
168
|
echo
|
|
163
169
|
}
|
|
164
170
|
|
|
@@ -203,25 +209,30 @@ print_all_agent_status() {
|
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
# =============================================================================
|
|
206
|
-
# SPINNER
|
|
212
|
+
# SPINNER - Claude Code Style
|
|
207
213
|
# =============================================================================
|
|
208
214
|
|
|
209
215
|
# Global spinner state
|
|
210
216
|
_SPINNER_PID=""
|
|
211
217
|
_SPINNER_MSG=""
|
|
218
|
+
_SPINNER_START=""
|
|
212
219
|
|
|
213
220
|
start_spinner() {
|
|
214
221
|
local message="${1:-Working...}"
|
|
215
222
|
_SPINNER_MSG="$message"
|
|
223
|
+
_SPINNER_START=$(date +%s)
|
|
216
224
|
|
|
217
225
|
hide_cursor
|
|
218
226
|
|
|
219
227
|
(
|
|
220
228
|
local i=0
|
|
229
|
+
local start_time=$(date +%s)
|
|
221
230
|
while true; do
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
231
|
+
local elapsed=$(($(date +%s) - start_time))
|
|
232
|
+
local elapsed_str="${elapsed}s"
|
|
233
|
+
printf "\r${DIM}✢${RESET} ${CYAN}%s${RESET}${DIM} (%s)${RESET} " "$message" "$elapsed_str"
|
|
234
|
+
i=$(( (i + 1) % 4 ))
|
|
235
|
+
sleep 0.25
|
|
225
236
|
done
|
|
226
237
|
) &
|
|
227
238
|
|
|
@@ -239,13 +250,20 @@ stop_spinner() {
|
|
|
239
250
|
_SPINNER_PID=""
|
|
240
251
|
fi
|
|
241
252
|
|
|
253
|
+
# Calculate elapsed time
|
|
254
|
+
local elapsed=""
|
|
255
|
+
if [[ -n "$_SPINNER_START" ]]; then
|
|
256
|
+
elapsed=$(($(date +%s) - _SPINNER_START))
|
|
257
|
+
elapsed=" ${DIM}(${elapsed}s)${RESET}"
|
|
258
|
+
fi
|
|
259
|
+
|
|
242
260
|
# Clear the spinner line
|
|
243
261
|
printf "\r%${COLUMNS:-80}s\r" ""
|
|
244
262
|
|
|
245
263
|
if [[ "$success" == "true" ]]; then
|
|
246
|
-
echo "${GREEN}
|
|
264
|
+
echo "${GREEN}✓${RESET} $final_message$elapsed"
|
|
247
265
|
else
|
|
248
|
-
echo "${RED}
|
|
266
|
+
echo "${RED}✗${RESET} $final_message$elapsed"
|
|
249
267
|
fi
|
|
250
268
|
|
|
251
269
|
show_cursor
|
|
@@ -282,41 +300,132 @@ print_progress_bar() {
|
|
|
282
300
|
printf "${RESET} %3d%%\n" "$percent"
|
|
283
301
|
}
|
|
284
302
|
|
|
303
|
+
# =============================================================================
|
|
304
|
+
# CHAT UI - Claude Code Style
|
|
305
|
+
# =============================================================================
|
|
306
|
+
|
|
307
|
+
# Chat message boundaries
|
|
308
|
+
CHAT_USER_PREFIX="╭─"
|
|
309
|
+
CHAT_USER_SUFFIX="─╮"
|
|
310
|
+
CHAT_AGENT_PREFIX="├─"
|
|
311
|
+
CHAT_AGENT_SUFFIX="─┤"
|
|
312
|
+
CHAT_END="╰"
|
|
313
|
+
CHAT_CONTINUE="│"
|
|
314
|
+
|
|
315
|
+
print_chat_divider() {
|
|
316
|
+
local width
|
|
317
|
+
width=$(get_terminal_width)
|
|
318
|
+
local line_width=$((width - 4))
|
|
319
|
+
printf "${DIM}%s%${line_width}s%s${RESET}\n" "├" "" "┤" | tr ' ' '─'
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
print_user_message_start() {
|
|
323
|
+
local width
|
|
324
|
+
width=$(get_terminal_width)
|
|
325
|
+
local line_width=$((width - 12))
|
|
326
|
+
echo
|
|
327
|
+
printf "${GREEN}╭─ You ${RESET}${DIM}"
|
|
328
|
+
printf "%${line_width}s" | tr ' ' '─'
|
|
329
|
+
printf "${RESET}\n"
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
print_user_message_end() {
|
|
333
|
+
local width
|
|
334
|
+
width=$(get_terminal_width)
|
|
335
|
+
printf "${DIM}╰"
|
|
336
|
+
printf "%$((width - 2))s" | tr ' ' '─'
|
|
337
|
+
printf "${RESET}\n"
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
print_agent_response_start() {
|
|
341
|
+
local agent="${1:-Agent}"
|
|
342
|
+
local width
|
|
343
|
+
width=$(get_terminal_width)
|
|
344
|
+
local agent_label=" $agent "
|
|
345
|
+
local line_width=$((width - ${#agent_label} - 4))
|
|
346
|
+
echo
|
|
347
|
+
printf "${CYAN}╭─${BOLD}${agent_label}${RESET}${DIM}"
|
|
348
|
+
printf "%${line_width}s" | tr ' ' '─'
|
|
349
|
+
printf "${RESET}\n"
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
print_agent_response_end() {
|
|
353
|
+
local width
|
|
354
|
+
width=$(get_terminal_width)
|
|
355
|
+
printf "${DIM}╰"
|
|
356
|
+
printf "%$((width - 2))s" | tr ' ' '─'
|
|
357
|
+
printf "${RESET}\n"
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
print_chat_content() {
|
|
361
|
+
local content="$1"
|
|
362
|
+
local prefix="${2:-${DIM}│${RESET}}"
|
|
363
|
+
|
|
364
|
+
# Print each line with the prefix
|
|
365
|
+
while IFS= read -r line; do
|
|
366
|
+
printf "%s %s\n" "$prefix" "$line"
|
|
367
|
+
done <<< "$content"
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
print_user_input_box() {
|
|
371
|
+
local input="$1"
|
|
372
|
+
print_user_message_start
|
|
373
|
+
print_chat_content "$input" "${GREEN}│${RESET}"
|
|
374
|
+
print_user_message_end
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
print_agent_response_box() {
|
|
378
|
+
local agent="$1"
|
|
379
|
+
local response="$2"
|
|
380
|
+
print_agent_response_start "$agent"
|
|
381
|
+
print_chat_content "$response" "${CYAN}│${RESET}"
|
|
382
|
+
print_agent_response_end
|
|
383
|
+
}
|
|
384
|
+
|
|
285
385
|
# =============================================================================
|
|
286
386
|
# MESSAGES
|
|
287
387
|
# =============================================================================
|
|
288
388
|
|
|
289
389
|
print_task() {
|
|
290
390
|
local task="$1"
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
391
|
+
print_user_message_start
|
|
392
|
+
printf "${GREEN}│${RESET} ${BOLD}Task:${RESET} %s\n" "$task"
|
|
393
|
+
print_user_message_end
|
|
294
394
|
}
|
|
295
395
|
|
|
296
396
|
print_orchestrator_message() {
|
|
297
397
|
local message="$1"
|
|
298
|
-
|
|
398
|
+
print_agent_response_start "Orchestrator"
|
|
399
|
+
print_chat_content "$message" "${MAGENTA}│${RESET}"
|
|
400
|
+
print_agent_response_end
|
|
299
401
|
}
|
|
300
402
|
|
|
301
403
|
print_agent_message() {
|
|
302
404
|
local agent="$1"
|
|
303
405
|
local message="$2"
|
|
304
|
-
|
|
406
|
+
print_agent_response_start "$agent"
|
|
407
|
+
print_chat_content "$message" "${CYAN}│${RESET}"
|
|
408
|
+
print_agent_response_end
|
|
305
409
|
}
|
|
306
410
|
|
|
307
411
|
print_user_prompt() {
|
|
308
|
-
printf "\n${GREEN}
|
|
412
|
+
printf "\n${GREEN}>${RESET} "
|
|
309
413
|
}
|
|
310
414
|
|
|
311
415
|
print_focus_prompt() {
|
|
312
416
|
local agent="$1"
|
|
313
|
-
printf "\n${CYAN}
|
|
417
|
+
printf "\n${CYAN}$agent>${RESET} "
|
|
314
418
|
}
|
|
315
419
|
|
|
316
420
|
print_task_assignment() {
|
|
317
421
|
local agent="$1"
|
|
318
422
|
local task="$2"
|
|
319
|
-
echo "
|
|
423
|
+
echo "${CYAN}│${RESET} ${DIM}→${RESET} ${BOLD}$agent:${RESET} $task"
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
print_thinking() {
|
|
427
|
+
local message="${1:-Thinking...}"
|
|
428
|
+
printf "${DIM}│ %s${RESET}\n" "$message"
|
|
320
429
|
}
|
|
321
430
|
|
|
322
431
|
# =============================================================================
|
|
@@ -405,6 +514,64 @@ print_info() {
|
|
|
405
514
|
echo "${CYAN}${BOLD}Info:${RESET} $message"
|
|
406
515
|
}
|
|
407
516
|
|
|
517
|
+
# =============================================================================
|
|
518
|
+
# SESSION STATS & TOKEN TRACKING
|
|
519
|
+
# =============================================================================
|
|
520
|
+
|
|
521
|
+
init_session_stats() {
|
|
522
|
+
_SESSION_START_TIME=$(date +%s)
|
|
523
|
+
_SESSION_TOKENS=0
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
add_tokens() {
|
|
527
|
+
local tokens="${1:-0}"
|
|
528
|
+
_SESSION_TOKENS=$((_SESSION_TOKENS + tokens))
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
format_tokens() {
|
|
532
|
+
local tokens="$1"
|
|
533
|
+
if [[ $tokens -ge 1000000 ]]; then
|
|
534
|
+
printf "%.1fM" "$(echo "scale=1; $tokens / 1000000" | bc)"
|
|
535
|
+
elif [[ $tokens -ge 1000 ]]; then
|
|
536
|
+
printf "%.1fk" "$(echo "scale=1; $tokens / 1000" | bc)"
|
|
537
|
+
else
|
|
538
|
+
echo "$tokens"
|
|
539
|
+
fi
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
print_session_stats() {
|
|
543
|
+
local elapsed=""
|
|
544
|
+
if [[ -n "${_SESSION_START_TIME:-}" ]]; then
|
|
545
|
+
local now=$(date +%s)
|
|
546
|
+
local secs=$(($now - $_SESSION_START_TIME))
|
|
547
|
+
local mins=$((secs / 60))
|
|
548
|
+
secs=$((secs % 60))
|
|
549
|
+
if [[ $mins -gt 0 ]]; then
|
|
550
|
+
elapsed="${mins}m ${secs}s"
|
|
551
|
+
else
|
|
552
|
+
elapsed="${secs}s"
|
|
553
|
+
fi
|
|
554
|
+
fi
|
|
555
|
+
|
|
556
|
+
local tokens_display
|
|
557
|
+
tokens_display=$(format_tokens "${_SESSION_TOKENS:-0}")
|
|
558
|
+
|
|
559
|
+
echo
|
|
560
|
+
print_divider "─"
|
|
561
|
+
printf "${DIM}Session: %s │ Tokens: ↑ %s${RESET}\n" "$elapsed" "$tokens_display"
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
print_status_line() {
|
|
565
|
+
local message="${1:-}"
|
|
566
|
+
local tokens="${2:-0}"
|
|
567
|
+
local elapsed="${3:-0}"
|
|
568
|
+
|
|
569
|
+
local tokens_display
|
|
570
|
+
tokens_display=$(format_tokens "$tokens")
|
|
571
|
+
|
|
572
|
+
printf "${DIM}✢ %s (ctrl+c to interrupt · %ss · ↑ %s tokens)${RESET}" "$message" "$elapsed" "$tokens_display"
|
|
573
|
+
}
|
|
574
|
+
|
|
408
575
|
# =============================================================================
|
|
409
576
|
# CLEANUP ON EXIT
|
|
410
577
|
# =============================================================================
|