astrabot 0.1.0 → 0.1.1
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 +730 -251
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,30 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ✨ Astra
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**AI-native development companion — Agent, Ask, Plan, and Multi-Agent modes in your terminal.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/astrabot)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://bun.sh)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
6
13
|
|
|
7
14
|
---
|
|
8
15
|
|
|
9
16
|
## Table of Contents
|
|
10
17
|
|
|
18
|
+
- [What Is Astra?](#what-is-astra)
|
|
11
19
|
- [Features](#features)
|
|
20
|
+
- [Prerequisites](#prerequisites)
|
|
21
|
+
- [Installation](#installation)
|
|
22
|
+
- [Option 1: Install Globally via npm](#option-1-install-globally-via-npm)
|
|
23
|
+
- [Option 2: Run Directly with npx (No Installation)](#option-2-run-directly-with-npx-no-installation)
|
|
24
|
+
- [Option 3: Install from Source](#option-3-install-from-source)
|
|
12
25
|
- [Quick Start](#quick-start)
|
|
26
|
+
- [Configuration](#configuration)
|
|
27
|
+
- [Required Environment Variables](#required-environment-variables)
|
|
28
|
+
- [Optional Environment Variables](#optional-environment-variables)
|
|
29
|
+
- [Running the Setup Wizard](#running-the-setup-wizard)
|
|
13
30
|
- [Commands](#commands)
|
|
31
|
+
- [`astra wakeup`](#astra-wakeup)
|
|
32
|
+
- [`astra setup`](#astra-setup)
|
|
33
|
+
- [`astra play`](#astra-play)
|
|
34
|
+
- [`astra reset`](#astra-reset)
|
|
14
35
|
- [Interaction Modes](#interaction-modes)
|
|
15
36
|
- [Auto Mode](#auto-mode)
|
|
16
37
|
- [Agent Mode](#agent-mode)
|
|
17
38
|
- [Ask Mode](#ask-mode)
|
|
18
39
|
- [Plan Mode](#plan-mode)
|
|
19
40
|
- [Multi-Agent Mode](#multi-agent-mode)
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
41
|
+
- [Tool System — Complete Reference](#tool-system--complete-reference)
|
|
42
|
+
- [Staging & Approval Pipeline](#staging--approval-pipeline)
|
|
43
|
+
- [Session Management](#session-management)
|
|
44
|
+
- [Multi-Agent Orchestration](#multi-agent-orchestration)
|
|
45
|
+
- [Orchestration Strategies](#orchestration-strategies)
|
|
46
|
+
- [Agent Roles](#agent-roles)
|
|
47
|
+
- [Workflow Templates](#workflow-templates)
|
|
48
|
+
- [Workflow Builder (Fluent API)](#workflow-builder-fluent-api)
|
|
49
|
+
- [Retry & Error Handling](#retry--error-handling)
|
|
28
50
|
- [Project Structure](#project-structure)
|
|
29
51
|
- [Dependencies](#dependencies)
|
|
30
52
|
- [Roadmap](#roadmap)
|
|
@@ -32,77 +54,290 @@ Astra gives a Large Language Model full programmatic access to your filesystem,
|
|
|
32
54
|
|
|
33
55
|
---
|
|
34
56
|
|
|
57
|
+
## What Is Astra?
|
|
58
|
+
|
|
59
|
+
Astra is an **AI-native development companion** that brings **agentic coding capabilities** directly to your terminal. Rather than being a simple chatbot or code-completion engine, Astra gives a Large Language Model (LLM) **full programmatic access** to your filesystem, shell, and the web — all gated behind a **carefully designed approval system** that keeps you in control at all times.
|
|
60
|
+
|
|
61
|
+
Built on **[Bun](https://bun.sh)**, powered by **[OpenRouter](https://openrouter.ai)** (supporting any model on that platform), and leveraging the **[Vercel AI SDK](https://sdk.vercel.ai)**'s `ToolLoopAgent` for autonomous, multi-step tool-driven workflows.
|
|
62
|
+
|
|
63
|
+
Astra provides **five distinct interaction modes** within a single CLI interface:
|
|
64
|
+
|
|
65
|
+
| Mode | Purpose | File Mutations? |
|
|
66
|
+
|------|---------|:---------------:|
|
|
67
|
+
| **Auto** | LLM-powered intent router — automatically picks the best mode for your request | Depends on route |
|
|
68
|
+
| **Agent** | Autonomous multi-step code modifications | ✅ (staged) |
|
|
69
|
+
| **Ask** | Read-only Q&A about your codebase | ❌ (except optional save) |
|
|
70
|
+
| **Plan** | Structured multi-step planning with selective execution | ✅ (staged) |
|
|
71
|
+
| **Multi-Agent** | Multiple agents working together in configurable topologies | ✅ (staged) |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
35
75
|
## Features
|
|
36
76
|
|
|
77
|
+
### 🧠 AI-Powered Development
|
|
37
78
|
- **Five interaction modes** — Auto, Agent, Ask, Plan, and Multi-Agent, each tailored to a different development workflow
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- **
|
|
44
|
-
- **Staging-first mutations** — no file is ever written or deleted without explicit user approval; all changes are staged in memory and presented for review before apply
|
|
79
|
+
- **35+ agent tools** — full filesystem access, shell execution, git integration, web research, project-aware tooling, and more
|
|
80
|
+
- **Auto-router** — automatically classifies your request and routes it to the most appropriate mode
|
|
81
|
+
- **Multi-model support** — different agents can use different LLMs in Multi-Agent mode
|
|
82
|
+
|
|
83
|
+
### 🔒 Safety First
|
|
84
|
+
- **Staging-first mutations** — no file is ever written or deleted without your explicit approval; all changes are staged in memory and presented for review before apply
|
|
45
85
|
- **Per-file diff review** — granular approval flow with unified diffs so you can inspect exactly what changed
|
|
46
|
-
- **
|
|
47
|
-
- **
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- **
|
|
86
|
+
- **Configurable safety** — exclude patterns (`node_modules`, `.git`, `dist`, `build`, `.next`, `*.log`, `.env*`), file size limits (default 1 MB), and per-tool permission toggles per agent role
|
|
87
|
+
- **Path traversal prevention** — strict boundary validation on all filesystem operations
|
|
88
|
+
|
|
89
|
+
### 💾 Session Management
|
|
90
|
+
- **Persistent sessions** — sessions are stored to disk with LLM-generated summaries, enabling resumption after interruption
|
|
91
|
+
- **Auto-resume** — interrupted sessions are detected on startup and offered for resumption
|
|
92
|
+
- **Session tools** — agents can query previous sessions via built-in `session_status`, `session_search`, and `session_resume_context` tools
|
|
93
|
+
- **Multi-turn goal tracking** — tracks every user goal across a session for full context awareness
|
|
94
|
+
|
|
95
|
+
### 👥 Multi-Agent Orchestration
|
|
96
|
+
- **Four orchestration strategies** — Sequential, Parallel, Hierarchical, and Collaborative
|
|
97
|
+
- **DAG (Directed Acyclic Graph)** — agents run when dependencies are satisfied, with cycle detection and deadlock handling
|
|
98
|
+
- **Five agent roles** — Researcher, Implementer, Reviewer, Coordinator, and Custom
|
|
99
|
+
- **Six pre-built workflow templates** — Code Review, Feature Development, Bug Fixing, Collaborative Research, Security Audit, and Full-Stack Feature
|
|
100
|
+
- **Fluent workflow builder** — programmatically construct custom agent topologies with validation
|
|
101
|
+
- **Inter-agent messaging** — publish-subscribe communication channel for collaborative workflows
|
|
102
|
+
- **Per-agent retry** — configurable retry logic with exponential backoff for each agent
|
|
103
|
+
|
|
104
|
+
### 🌐 Web Research
|
|
105
|
+
- **Web search** — via Firecrawl SDK or DuckDuckGo fallback
|
|
106
|
+
- **Web crawling** — scrape any URL into markdown via Firecrawl
|
|
107
|
+
- **URL fetching** — HTTP GET with response body extraction
|
|
108
|
+
|
|
109
|
+
### 🎨 Rich Terminal UI
|
|
110
|
+
- **Interactive prompts** — via `@clack/prompts` (select, confirm, text, multiselect, autocomplete)
|
|
111
|
+
- **Markdown rendering** — agent responses rendered as formatted markdown in the terminal
|
|
112
|
+
- **ASCII art banner** — animated breathing banner with twinkling star field on startup
|
|
113
|
+
- **Animated spinners** — metabolic-rate-based spinner with dynamic color gradients and elapsed time
|
|
114
|
+
- **Colored logging** — green for agent actions, cyan for ask mode, yellow for warnings, red for errors
|
|
115
|
+
|
|
116
|
+
### 🎮 Easter Egg
|
|
117
|
+
- **Arcade mini-games** — Retro Snake Classic and Neon Brick Breaker, served via Bun's native HTTP server
|
|
51
118
|
|
|
52
119
|
---
|
|
53
120
|
|
|
54
|
-
##
|
|
55
|
-
|
|
56
|
-
### Prerequisites
|
|
121
|
+
## Prerequisites
|
|
57
122
|
|
|
58
123
|
| Requirement | Version | Purpose |
|
|
59
124
|
|-------------|---------|---------|
|
|
60
|
-
| [Bun](https://bun.sh) | >=1.0.0 |
|
|
61
|
-
| [OpenRouter](https://openrouter.ai) API key | — | LLM provider access (required) |
|
|
62
|
-
| [Firecrawl](https://www.firecrawl.dev/) API key | — | Web search and crawling (optional) |
|
|
125
|
+
| [Bun](https://bun.sh) | >= 1.0.0 | JavaScript/TypeScript runtime |
|
|
126
|
+
| [OpenRouter](https://openrouter.ai) API key | — | LLM provider access (**required**) |
|
|
127
|
+
| [Firecrawl](https://www.firecrawl.dev/) API key | — | Web search and crawling (**optional**) |
|
|
128
|
+
| [Node.js](https://nodejs.org) | >= 18 | For npm/npx (if not using Bun directly) |
|
|
63
129
|
|
|
64
|
-
|
|
130
|
+
> **Note:** Astra runs on **Bun**, not Node.js. Bun is used as the runtime for executing the TypeScript source directly. npm/npx are used only for package distribution.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Installation
|
|
135
|
+
|
|
136
|
+
### Option 1: Install Globally via npm
|
|
137
|
+
|
|
138
|
+
This is the recommended approach for regular use. Installing globally makes the `astra` command available system-wide.
|
|
65
139
|
|
|
66
140
|
```bash
|
|
67
|
-
|
|
68
|
-
cd astra
|
|
69
|
-
bun install
|
|
141
|
+
npm install -g astrabot
|
|
70
142
|
```
|
|
71
143
|
|
|
72
|
-
|
|
144
|
+
After installation, verify it works:
|
|
73
145
|
|
|
74
|
-
|
|
146
|
+
```bash
|
|
147
|
+
astra --version
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
You can now run Astra from any directory:
|
|
75
151
|
|
|
76
152
|
```bash
|
|
77
|
-
|
|
153
|
+
cd /path/to/your/project
|
|
154
|
+
astra setup # Configure API keys
|
|
155
|
+
astra wakeup # Launch the interactive menu
|
|
78
156
|
```
|
|
79
157
|
|
|
80
|
-
|
|
158
|
+
To update to the latest version:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npm update -g astrabot
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
To uninstall:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npm uninstall -g astrabot
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Option 2: Run Directly with npx (No Installation)
|
|
171
|
+
|
|
172
|
+
If you don't want to install anything permanently, you can run Astra directly using `npx`. This downloads and executes the package on-the-fly each time.
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Run the setup wizard
|
|
176
|
+
npx astrabot setup
|
|
177
|
+
|
|
178
|
+
# Launch the interactive menu
|
|
179
|
+
npx astrabot wakeup
|
|
180
|
+
|
|
181
|
+
# Show the version
|
|
182
|
+
npx astrabot --version
|
|
81
183
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
184
|
+
# Launch the arcade easter egg
|
|
185
|
+
npx astrabot play
|
|
186
|
+
|
|
187
|
+
# Reset all configuration and sessions
|
|
188
|
+
npx astrabot reset
|
|
87
189
|
```
|
|
88
190
|
|
|
89
|
-
|
|
191
|
+
> **Tip:** The first run with `npx` may take a few seconds as it downloads the package. Subsequent runs are faster due to npx's cache.
|
|
192
|
+
|
|
193
|
+
### Option 3: Install from Source
|
|
194
|
+
|
|
195
|
+
For development or if you want to modify the code:
|
|
90
196
|
|
|
91
197
|
```bash
|
|
198
|
+
# Clone the repository
|
|
199
|
+
git clone https://github.com/<your-username>/astrabot.git
|
|
200
|
+
cd astrabot
|
|
201
|
+
|
|
202
|
+
# Install dependencies
|
|
203
|
+
bun install
|
|
204
|
+
|
|
205
|
+
# Link the binary globally (optional)
|
|
206
|
+
bun link
|
|
207
|
+
|
|
208
|
+
# Or run directly
|
|
209
|
+
bun run index.ts setup
|
|
92
210
|
bun run index.ts wakeup
|
|
93
211
|
```
|
|
94
212
|
|
|
95
213
|
---
|
|
96
214
|
|
|
215
|
+
## Quick Start
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# 1. Install Astra
|
|
219
|
+
npm install -g astrabot
|
|
220
|
+
|
|
221
|
+
# 2. Configure your API keys (interactive wizard)
|
|
222
|
+
astra setup
|
|
223
|
+
# → Enter your OpenRouter API key (required)
|
|
224
|
+
# → Select a model (e.g., anthropic/claude-3.5-sonnet)
|
|
225
|
+
# → Optionally set Firecrawl API key for web search
|
|
226
|
+
# → Optionally set custom skills directories
|
|
227
|
+
|
|
228
|
+
# 3. Navigate to your project
|
|
229
|
+
cd /path/to/your/project
|
|
230
|
+
|
|
231
|
+
# 4. Launch Astra
|
|
232
|
+
astra wakeup
|
|
233
|
+
|
|
234
|
+
# 5. Choose a mode:
|
|
235
|
+
# → Interactive CLI Mode → select Agent / Ask / Plan / Multi-Agent / Auto
|
|
236
|
+
# → Follow the prompts and approve changes when asked
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Configuration
|
|
242
|
+
|
|
243
|
+
Astra is configured entirely through environment variables, loaded from `~/.astra/.env`.
|
|
244
|
+
|
|
245
|
+
### Required Environment Variables
|
|
246
|
+
|
|
247
|
+
| Variable | Description | Example |
|
|
248
|
+
|----------|-------------|---------|
|
|
249
|
+
| `OPENROUTER_API_KEY` | OpenRouter API key for LLM access | `sk-or-v1-abc123...` |
|
|
250
|
+
| `OPENROUTER_DEFAULT_MODEL` | Default model identifier | `anthropic/claude-3.5-sonnet` |
|
|
251
|
+
|
|
252
|
+
### Optional Environment Variables
|
|
253
|
+
|
|
254
|
+
| Variable | Description | Example |
|
|
255
|
+
|----------|-------------|---------|
|
|
256
|
+
| `FIRECRAWL_API_KEY` | Enables `web_search`, `web_crawl`, and `fetch_url` tools via Firecrawl SDK | `fc-abc123...` |
|
|
257
|
+
| `SKILLS_DIRS` | Semicolon-separated paths to custom skill directories | `/path/to/skills;/another/dir` |
|
|
258
|
+
|
|
259
|
+
### Retry Configuration Variables
|
|
260
|
+
|
|
261
|
+
| Variable | Default | Description |
|
|
262
|
+
|----------|---------|-------------|
|
|
263
|
+
| `ASTRA_AGENT_RETRY_ENABLED` | `true` | Enable automatic retry for agent AI calls |
|
|
264
|
+
| `ASTRA_AGENT_RETRY_MAX` | `3` | Maximum retry attempts for agent calls |
|
|
265
|
+
| `ASTRA_AGENT_RETRY_PROGRESS` | `true` | Show retry progress in the terminal |
|
|
266
|
+
| `ASTRA_MULTI_RETRY_ENABLED` | `true` | Enable retry for multi-agent steps |
|
|
267
|
+
| `ASTRA_MULTI_RETRY_MAX` | `2` | Maximum retry attempts for multi-agent steps |
|
|
268
|
+
| `ASTRA_MULTI_RETRY_BACKOFF` | `2` | Backoff multiplier for multi-agent retries |
|
|
269
|
+
|
|
270
|
+
### Config File Locations
|
|
271
|
+
|
|
272
|
+
| Path | Purpose |
|
|
273
|
+
|------|---------|
|
|
274
|
+
| `~/.astra/.env` | Environment variables (API keys, model, optional settings) |
|
|
275
|
+
| `~/.astra/sessions/index.json` | Session store (persisted conversation history) |
|
|
276
|
+
| `~/.astra/sessions/<session-id>.json` | Individual session action logs |
|
|
277
|
+
|
|
278
|
+
### Running the Setup Wizard
|
|
279
|
+
|
|
280
|
+
The easiest way to configure Astra is through the interactive setup wizard:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
astra setup
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
The wizard will:
|
|
287
|
+
1. Prompt for your **OpenRouter API key** (required)
|
|
288
|
+
2. Fetch all available models from OpenRouter and let you **search and select** one with pricing information
|
|
289
|
+
3. Optionally configure a **Firecrawl API key** for web search and crawling
|
|
290
|
+
4. Optionally configure **custom skills directories**
|
|
291
|
+
5. Save everything to `~/.astra/.env`, preserving existing values
|
|
292
|
+
|
|
293
|
+
You can re-run `astra setup` at any time to update your configuration.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
97
297
|
## Commands
|
|
98
298
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
299
|
+
### `astra wakeup`
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
astra wakeup
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Launches the main entry point. Displays the animated ASCII art banner and presents the top-level mode selection:
|
|
306
|
+
|
|
307
|
+
- **Interactive CLI Mode** → enters the mode loop (Auto / Agent / Ask / Plan / Multi-Agent)
|
|
308
|
+
- **Telegram Gateway Interface** → placeholder (not yet implemented)
|
|
309
|
+
- **Exit Application** → quits
|
|
310
|
+
|
|
311
|
+
Before the mode menu, it automatically checks for interrupted sessions and offers to resume them.
|
|
312
|
+
|
|
313
|
+
### `astra setup`
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
astra setup
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Interactive configuration wizard for API keys and settings. See [Configuration](#configuration) above.
|
|
320
|
+
|
|
321
|
+
### `astra play`
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
astra play
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Launches the arcade easter egg — an interactive game selector that lets you choose between:
|
|
328
|
+
|
|
329
|
+
- **Retro Snake Classic** — full Snake game with gradient backgrounds, glow effects, snake eyes, input queue, high score in localStorage, mobile touch controls, pause/resume, and High DPI support
|
|
330
|
+
- **Neon Brick Breaker** — Brick Breaker game built with HTML5 Canvas
|
|
331
|
+
|
|
332
|
+
A local Bun HTTP server is spawned on port `4321` and the game is automatically opened in your default browser.
|
|
333
|
+
|
|
334
|
+
### `astra reset`
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
astra reset
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Interactive danger-zone command that completely purges **all** stored configurations, sessions, and credentials from `~/.astra/`. Requires explicit confirmation before proceeding.
|
|
106
341
|
|
|
107
342
|
---
|
|
108
343
|
|
|
@@ -110,302 +345,546 @@ bun run index.ts wakeup
|
|
|
110
345
|
|
|
111
346
|
### Auto Mode
|
|
112
347
|
|
|
113
|
-
Auto mode
|
|
348
|
+
Auto mode uses an LLM-based intent classifier to automatically determine which mode is best suited for your request:
|
|
114
349
|
|
|
115
350
|
```
|
|
116
|
-
|
|
117
|
-
→
|
|
351
|
+
User: "fix the bug in store.ts"
|
|
352
|
+
→ Classified as: agent
|
|
353
|
+
|
|
354
|
+
User: "explain how this app works"
|
|
355
|
+
→ Classified as: ask
|
|
118
356
|
|
|
119
|
-
|
|
120
|
-
→
|
|
357
|
+
User: "design a new authentication system"
|
|
358
|
+
→ Classified as: plan
|
|
359
|
+
|
|
360
|
+
User: "run a security audit with multiple reviewers"
|
|
361
|
+
→ Classified as: multi
|
|
121
362
|
```
|
|
122
363
|
|
|
123
|
-
|
|
364
|
+
The classification prompt instructs the LLM to respond with exactly one word: `ask`, `plan`, `multi`, or `agent`. On classification failure, it defaults to `agent`. The user's original prompt is forwarded to the selected mode, so no information is lost.
|
|
124
365
|
|
|
125
|
-
|
|
126
|
-
2. An LLM classifies the intent into one of four categories
|
|
127
|
-
3. The session is logged with the routing decision
|
|
128
|
-
4. The selected mode executes with your original prompt
|
|
366
|
+
Auto mode creates its own session entry to log the routing decision before delegating.
|
|
129
367
|
|
|
130
368
|
### Agent Mode
|
|
131
369
|
|
|
132
|
-
The primary autonomous coding mode.
|
|
370
|
+
The primary autonomous coding mode. The agent has full access to all tools and can perform multi-step file modifications, shell commands, and web research.
|
|
133
371
|
|
|
134
372
|
**Flow:**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
| Filesystem | `read_file`, `create_file`, `modify_file`, `delete_file`, `create_folder`, `list_files`, `search_files`, `read_multiple_files`, `replace_in_file`, `append_to_file`, `insert_at_line` |
|
|
148
|
-
| Shell | `run_command`, `run_background_command`, `execute_shell` |
|
|
149
|
-
| Git | `git_status`, `git_diff`, `git_log` |
|
|
150
|
-
| Project | `run_tests`, `run_test_file`, `lint_project`, `format_project`, `detect_framework`, `read_package_json`, `analyze_codebase` |
|
|
151
|
-
| Search | `grep` |
|
|
152
|
-
| Web | `web_search`, `fetch_url`, `web_crawl` (requires Firecrawl) |
|
|
153
|
-
| Skills | `list_skills`, `read_skill` |
|
|
154
|
-
| Session | `session_status`, `session_history` |
|
|
155
|
-
| Planning | `create_plan`, `get_plan`, `show_pending_changes`, `discard_changes` |
|
|
373
|
+
1. **Goal input** — "What would you like the agent to do for you?"
|
|
374
|
+
2. **Agent execution** — the LLM autonomously calls tools (up to 50 steps) to accomplish the goal
|
|
375
|
+
3. **Live tool logging** — each tool call is logged in real-time with the tool name and parameters
|
|
376
|
+
4. **Approval flow** — all staged changes are presented for review with diffs
|
|
377
|
+
5. **Apply** — approved changes are written to disk
|
|
378
|
+
|
|
379
|
+
**Key behaviors:**
|
|
380
|
+
- All mutations are staged in an in-memory overlay — nothing touches disk until you approve
|
|
381
|
+
- File creations during the agent loop go through immediate per-file approval
|
|
382
|
+
- On AI provider errors, automatic retry kicks in (configurable, default 3 retries with exponential backoff)
|
|
383
|
+
- If all retries are exhausted, you're offered a manual retry option
|
|
384
|
+
- Sessions are automatically created and can be resumed if interrupted
|
|
156
385
|
|
|
157
386
|
### Ask Mode
|
|
158
387
|
|
|
159
|
-
A
|
|
388
|
+
A read-only Q&A interface. The agent can read files, search the codebase, and browse the web, but **cannot modify any files** (except optionally saving the response).
|
|
160
389
|
|
|
161
390
|
**Flow:**
|
|
391
|
+
1. **Question input** — "What do you like the agent to do for you?"
|
|
392
|
+
2. **Read-only agent** — the LLM uses only read-only tools (up to 25 steps)
|
|
393
|
+
3. **Answer display** — response rendered as formatted markdown in the terminal
|
|
394
|
+
4. **Optional save** — you can save the Q&A as a `.md` file with `## Question` / `## Answer` formatting
|
|
162
395
|
|
|
163
|
-
|
|
164
|
-
2. The agent uses read-only tools to formulate an answer
|
|
165
|
-
3. The answer is rendered as markdown in the terminal
|
|
166
|
-
4. You're given the option to save the Q&A pair as a `.md` file
|
|
167
|
-
|
|
168
|
-
**Available tools:** All read-only tools from Agent mode (filesystem read, search, codebase analysis, git, web, skills, session). All mutation tools are stripped.
|
|
396
|
+
**Retry logic:** Ask mode has a bounded retry loop (max 5 attempts) with exponential backoff and jitter for resilience against transient provider errors.
|
|
169
397
|
|
|
170
398
|
### Plan Mode
|
|
171
399
|
|
|
172
|
-
Breaks a high-level goal into a structured, executable plan
|
|
400
|
+
Breaks a high-level goal into a structured, executable plan with selective step execution.
|
|
173
401
|
|
|
174
402
|
**Flow:**
|
|
403
|
+
1. **Goal input** — "What is your goal?"
|
|
404
|
+
2. **Plan generation** — the LLM researches the codebase and generates a structured plan (1–20 steps) with complexity ratings (`low`, `medium`, `high`)
|
|
405
|
+
3. **Plan display** — numbered steps with color-coded complexity tags
|
|
406
|
+
4. **Step selection** — interactive multiselect to choose which steps to execute (all pre-selected)
|
|
407
|
+
5. **Execution** — each selected step runs as an independent `ToolLoopAgent` (50 steps max each)
|
|
408
|
+
6. **Batch approval** — all changes across all steps are presented together for review
|
|
409
|
+
7. **Apply** — approved changes are written to disk
|
|
175
410
|
|
|
176
|
-
|
|
177
|
-
2. The agent researches the codebase and generates a structured plan (1–20 steps) with complexity ratings (`low`, `medium`, `high`)
|
|
178
|
-
3. The plan is displayed with a research summary and numbered steps
|
|
179
|
-
4. You select which steps to execute (all selected by default)
|
|
180
|
-
5. Each selected step runs as an independent agent loop (up to 50 steps per step)
|
|
181
|
-
6. All mutations across all steps are collected and presented in a single approval flow
|
|
411
|
+
**Web research during planning:** If `FIRECRAWL_API_KEY` is set, the planner can search the web and crawl URLs during plan generation.
|
|
182
412
|
|
|
183
413
|
### Multi-Agent Mode
|
|
184
414
|
|
|
185
|
-
Coordinates multiple AI agents working together on complex
|
|
415
|
+
Coordinates multiple AI agents working together on complex tasks. This is the most powerful mode, supporting sophisticated agent topologies.
|
|
186
416
|
|
|
187
|
-
**
|
|
417
|
+
**Flow:**
|
|
418
|
+
1. **Goal input** — "What complex operations workflow would you like to run?"
|
|
419
|
+
2. **AI-powered workflow design** — the LLM analyzes your goal and either selects a pre-built template or designs a custom agent team with a specific orchestration strategy
|
|
420
|
+
3. **Workflow validation** — 10+ validation checks ensure the workflow is well-formed
|
|
421
|
+
4. **Execution** — agents run according to the chosen strategy
|
|
422
|
+
5. **Results display** — execution summary with status, duration, pool stats, and per-agent results
|
|
423
|
+
6. **Per-agent approval** — changes are reviewed per agent with diffs, then applied
|
|
188
424
|
|
|
189
|
-
|
|
425
|
+
**AI workflow designer:** The LLM analyzes your task and responds with a JSON configuration specifying:
|
|
426
|
+
- Which pre-built template to use (if any), OR
|
|
427
|
+
- A custom agent team with specific roles, models, and an orchestration strategy
|
|
190
428
|
|
|
191
|
-
|
|
192
|
-
|----------|--------|----------|
|
|
193
|
-
| Code Review | Researcher → Implementer → Reviewer | Sequential |
|
|
194
|
-
| Feature Development | Coordinator → Backend Dev + Frontend Dev → QA | Hierarchical |
|
|
195
|
-
| Bug Fix | Debug Agent → Fix Agent → Test Agent | Sequential |
|
|
196
|
-
| Collaborative Research | Researcher 1 + Researcher 2 + Researcher 3 | Parallel |
|
|
197
|
-
| Security Audit | Scanner → Analyzer → Reporter | Sequential |
|
|
198
|
-
| Full-Stack Feature | Database + API + UI (parallel) | Hierarchical |
|
|
429
|
+
---
|
|
199
430
|
|
|
200
|
-
|
|
431
|
+
## Tool System — Complete Reference
|
|
201
432
|
|
|
202
|
-
**
|
|
433
|
+
Astra exposes **35+ tools** to the AI agent, organized into four categories:
|
|
203
434
|
|
|
204
|
-
|
|
205
|
-
|----------|----------|
|
|
206
|
-
| **Sequential** | Agents run one after another; each agent's output is visible to subsequent agents |
|
|
207
|
-
| **Parallel** | Agents run concurrently in batches (default 3 at a time) |
|
|
208
|
-
| **Hierarchical** | Coordinator runs first (planning), then specialists execute |
|
|
209
|
-
| **Collaborative** | Agents take turns; outputs are broadcast via a message broker |
|
|
435
|
+
### File System Tools
|
|
210
436
|
|
|
211
|
-
|
|
437
|
+
| Tool | Description | Mutates? |
|
|
438
|
+
|------|-------------|:--------:|
|
|
439
|
+
| `read_file` | Read a text file from the workspace | ❌ |
|
|
440
|
+
| `read_multiple_files` | Read multiple files in a single call | ❌ |
|
|
441
|
+
| `create_file` | Stage creation of a new file | ✅ |
|
|
442
|
+
| `modify_file` | Stage a full-file replacement | ✅ |
|
|
443
|
+
| `delete_file` | Stage deletion of a file | ✅ |
|
|
444
|
+
| `create_folder` | Stage creation of a directory tree | ✅ |
|
|
445
|
+
| `list_files` | List files and directories under a path | ❌ |
|
|
446
|
+
| `search_files` | Find files matching a glob pattern with optional content filter | ❌ |
|
|
447
|
+
| `analyze_codebase` | Summarize structure: file counts, directory counts | ❌ |
|
|
448
|
+
| `grep` | Search file contents using a text query | ❌ |
|
|
449
|
+
| `replace_in_file` | Replace text inside a file | ✅ |
|
|
450
|
+
| `append_to_file` | Append content to the end of a file | ✅ |
|
|
451
|
+
| `insert_at_line` | Insert content at a specific line number | ✅ |
|
|
212
452
|
|
|
213
|
-
|
|
214
|
-
|------|------------|-------------------|-------|
|
|
215
|
-
| Researcher | Read-only | 30 | 16 |
|
|
216
|
-
| Implementer | Full read/write/execute | 50 | 26 |
|
|
217
|
-
| Reviewer | Read + execute (no write) | 25 | 15 |
|
|
218
|
-
| Coordinator | Read-only + planning | 20 | 8 |
|
|
219
|
-
| Custom | Based on selected tools | 30 | Variable |
|
|
453
|
+
### Shell & Execution Tools
|
|
220
454
|
|
|
221
|
-
|
|
455
|
+
| Tool | Description | Mutates? |
|
|
456
|
+
|------|-------------|:--------:|
|
|
457
|
+
| `run_command` | Run a command synchronously and capture output | ❌ |
|
|
458
|
+
| `run_background_command` | Start a long-running detached process | ❌ |
|
|
459
|
+
| `execute_shell` | Queue a shell command for post-approval execution | ✅ |
|
|
460
|
+
| `run_tests` | Run the project's test suite (auto-detects runner) | ❌ |
|
|
461
|
+
| `run_test_file` | Run a specific test file | ❌ |
|
|
462
|
+
| `lint_project` | Run linting (auto-detects: eslint, etc.) | ❌ |
|
|
463
|
+
| `format_project` | Run formatting (auto-detects: prettier, etc.) | ❌ |
|
|
222
464
|
|
|
223
|
-
|
|
465
|
+
### Git Tools
|
|
224
466
|
|
|
225
|
-
|
|
467
|
+
| Tool | Description |
|
|
468
|
+
|------|-------------|
|
|
469
|
+
| `git_status` | Get `git status --short` |
|
|
470
|
+
| `git_diff` | Get `git diff` (optionally staged) |
|
|
471
|
+
| `git_log` | Get recent commits (`git log --oneline`) |
|
|
226
472
|
|
|
227
|
-
|
|
228
|
-
|------|----------------|
|
|
229
|
-
| `index.ts` | Entry point; registers commands via Commander |
|
|
230
|
-
| `tui/wakeup.ts` | Banner rendering and top-level mode selection |
|
|
231
|
-
| `tui/terminal-md.ts` | Markdown-to-terminal rendering via `marked` + `marked-terminal` |
|
|
232
|
-
| `tui/spinner.ts` | Animated spinner with elapsed time display |
|
|
233
|
-
| `modes/cli.ts` | CLI mode loop (Auto / Agent / Plan / Ask / Multi-Agent) |
|
|
234
|
-
| `modes/auto.ts` | Auto-router: LLM-based intent classification |
|
|
235
|
-
| `modes/setup.ts` | Interactive configuration wizard |
|
|
236
|
-
| `ai/ai.config.ts` | OpenRouter provider initialization |
|
|
237
|
-
| `ai/config-loader.ts` | Manages `~/.astra/.env` file |
|
|
238
|
-
| `ai/auto-retry.ts` | Automatic retry with exponential backoff |
|
|
239
|
-
| `ai/retry-prompt.ts` | Manual retry prompt fallback |
|
|
473
|
+
### Project Intelligence Tools
|
|
240
474
|
|
|
241
|
-
|
|
475
|
+
| Tool | Description |
|
|
476
|
+
|------|-------------|
|
|
477
|
+
| `detect_framework` | Detect framework from `package.json` (Next.js, React, Vue, Svelte, Node.js) |
|
|
478
|
+
| `read_package_json` | Read and summarize `package.json` |
|
|
242
479
|
|
|
243
|
-
|
|
480
|
+
### Web Tools
|
|
244
481
|
|
|
245
|
-
|
|
482
|
+
| Tool | Description | Requires |
|
|
483
|
+
|------|-------------|----------|
|
|
484
|
+
| `web_search` | Search the web (returns title/url/snippet) | Firecrawl key (or DuckDuckGo fallback) |
|
|
485
|
+
| `web_crawl` | Scrape a URL into markdown | Firecrawl key |
|
|
486
|
+
| `fetch_url` | HTTP GET for a URL, returns response body | — |
|
|
246
487
|
|
|
247
|
-
|
|
488
|
+
### Planning Tools
|
|
248
489
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
490
|
+
| Tool | Description |
|
|
491
|
+
|------|-------------|
|
|
492
|
+
| `create_plan` | Create a task execution plan |
|
|
493
|
+
| `get_plan` | Retrieve the current plan |
|
|
252
494
|
|
|
253
|
-
### Staging
|
|
495
|
+
### Staging Tools
|
|
254
496
|
|
|
255
|
-
|
|
497
|
+
| Tool | Description |
|
|
498
|
+
|------|-------------|
|
|
499
|
+
| `show_pending_changes` | Display all staged (pending) operations |
|
|
500
|
+
| `discard_changes` | Discard all staged operations |
|
|
256
501
|
|
|
257
|
-
|
|
502
|
+
### Skill Tools
|
|
258
503
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
504
|
+
| Tool | Description |
|
|
505
|
+
|------|-------------|
|
|
506
|
+
| `list_skills` | List `SKILL.md` files from skill directories |
|
|
507
|
+
| `read_skill` | Read a specific `SKILL.md` file |
|
|
263
508
|
|
|
264
|
-
|
|
509
|
+
### Session Tools
|
|
265
510
|
|
|
266
|
-
|
|
511
|
+
| Tool | Description |
|
|
512
|
+
|------|-------------|
|
|
513
|
+
| `session_status` | Check recent session history (mode, goal, outcome, pending tasks) |
|
|
514
|
+
| `session_resume_context` | Get full context of a previous session (transcript, files, summary) |
|
|
515
|
+
| `session_search` | Search previous sessions by keyword, file name, or goal |
|
|
267
516
|
|
|
268
|
-
|
|
517
|
+
---
|
|
269
518
|
|
|
270
|
-
|
|
519
|
+
## Staging & Approval Pipeline
|
|
271
520
|
|
|
272
|
-
|
|
521
|
+
This is the **safety backbone** of Astra. No mutation ever touches the disk without explicit user consent.
|
|
273
522
|
|
|
274
|
-
|
|
275
|
-
- **Context injection** — on resume, the previous session's summary is injected into the agent's instructions
|
|
276
|
-
- **Session tools** — agents can call `session_status` and `session_history` to recall previous work
|
|
523
|
+
### How It Works
|
|
277
524
|
|
|
278
|
-
|
|
525
|
+
```
|
|
526
|
+
Agent calls mutation tool (create_file, modify_file, etc.)
|
|
527
|
+
│
|
|
528
|
+
▼
|
|
529
|
+
┌──────────────────────────────────┐
|
|
530
|
+
│ 1. Path Safety Validation │ ← Must be within workspace root
|
|
531
|
+
│ 2. Exclude Pattern Check │ ← node_modules, .git, etc. blocked
|
|
532
|
+
│ 3. File Size Check │ ← Max 1 MB for reads
|
|
533
|
+
│ 4. Stage in Memory Overlay │ ← Map<string,string> + Set<string>
|
|
534
|
+
│ 5. Log to ActionTracker │ ← Append-only audit trail
|
|
535
|
+
└──────────────────────────────────┘
|
|
536
|
+
│
|
|
537
|
+
▼
|
|
538
|
+
Agent continues working (more tool calls, more staging)
|
|
539
|
+
│
|
|
540
|
+
▼
|
|
541
|
+
Agent finishes → Approval Flow
|
|
542
|
+
│
|
|
543
|
+
▼
|
|
544
|
+
┌──────────────────────────────────┐
|
|
545
|
+
│ User chooses: │
|
|
546
|
+
│ • "Approve and apply all" │
|
|
547
|
+
│ • "Review one by one" │ ← Per-file with diff viewing
|
|
548
|
+
│ • "Cancel" │ ← All discarded
|
|
549
|
+
└──────────────────────────────────┘
|
|
550
|
+
│
|
|
551
|
+
▼ (if approved)
|
|
552
|
+
┌──────────────────────────────────┐
|
|
553
|
+
│ applyApprovedFromTracker() │
|
|
554
|
+
│ 1. Create folders (recursive) │
|
|
555
|
+
│ 2. Write/delete files │
|
|
556
|
+
│ 3. Execute queued shell cmds │
|
|
557
|
+
│ 4. Return errors (if any) │
|
|
558
|
+
└──────────────────────────────────┘
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Review Groups
|
|
562
|
+
|
|
563
|
+
When reviewing changes one-by-one, pending mutations are grouped by file path:
|
|
564
|
+
- Multiple actions on the same file are collapsed into a single before→after diff
|
|
565
|
+
- Folder creations are shown without diffs
|
|
566
|
+
- Shell commands are shown individually
|
|
567
|
+
|
|
568
|
+
### Diff Format
|
|
569
|
+
|
|
570
|
+
Diffs are generated using unified diff format with 3 lines of context. Large diffs are truncated for readability with a warning message.
|
|
571
|
+
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
## Session Management
|
|
575
|
+
|
|
576
|
+
### Session Lifecycle
|
|
577
|
+
|
|
578
|
+
```
|
|
579
|
+
User starts mode → beginSession()
|
|
580
|
+
│
|
|
581
|
+
▼
|
|
582
|
+
Session created (status: "active")
|
|
583
|
+
│ → Stored in ~/.astra/sessions/index.json
|
|
584
|
+
│ → Unique ID generated (e.g., sess_m5k2x3_abc123)
|
|
585
|
+
│
|
|
586
|
+
Agent works → actions accumulate in tracker
|
|
587
|
+
│ → Transcript messages recorded
|
|
588
|
+
│ → Goals tracked
|
|
589
|
+
│
|
|
590
|
+
Agent finishes → endSession()
|
|
591
|
+
│ → LLM generates 2-3 sentence summary
|
|
592
|
+
│ → Touched files extracted
|
|
593
|
+
│ → Action counts recorded
|
|
594
|
+
│ → Status set to "completed"
|
|
595
|
+
│
|
|
596
|
+
OR: User hits Ctrl+C → markSessionInterrupted()
|
|
597
|
+
│ → Status set to "interrupted"
|
|
598
|
+
│ → All state preserved for resume
|
|
599
|
+
│
|
|
600
|
+
Next wakeup → auto-resume offered
|
|
601
|
+
│ → Context summary injected into agent
|
|
602
|
+
│ → Previous actions hydrated into overlay
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Auto-Resume Heuristics
|
|
606
|
+
|
|
607
|
+
When starting a new session, Astra checks for resumable sessions using a 3-tier priority:
|
|
608
|
+
|
|
609
|
+
1. **Explicit resume** — a specific session ID was provided
|
|
610
|
+
2. **Interrupted session** — an interrupted session exists in the same workspace
|
|
611
|
+
3. **Related session** — keyword overlap ≥30% with a recent session (within 4 hours for completed, 30 minutes for non-interrupted)
|
|
612
|
+
|
|
613
|
+
### Session Context on Resume
|
|
614
|
+
|
|
615
|
+
When resuming, the agent receives a rich context block including:
|
|
616
|
+
- Session metadata (ID, mode, start time)
|
|
617
|
+
- All goals from the session
|
|
618
|
+
- LLM-generated summary of what happened
|
|
619
|
+
- Pending/incomplete tasks
|
|
620
|
+
- Files touched (up to 20)
|
|
621
|
+
- Action counts (applied/rejected)
|
|
622
|
+
- Recent conversation transcript (configurable, default 10 turns)
|
|
623
|
+
- The agent's last response
|
|
279
624
|
|
|
280
|
-
|
|
625
|
+
---
|
|
281
626
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
|
287
|
-
|
|
627
|
+
## Multi-Agent Orchestration
|
|
628
|
+
|
|
629
|
+
### Orchestration Strategies
|
|
630
|
+
|
|
631
|
+
| Strategy | Behavior | Failure Mode |
|
|
632
|
+
|----------|----------|--------------|
|
|
633
|
+
| **Sequential** | Agents run one after another; each agent sees previous agents' outputs | Fail-fast (default) |
|
|
634
|
+
| **Parallel** | Agents run simultaneously in configurable batches with timeout | Continue (default) |
|
|
635
|
+
| **Hierarchical** | Coordinator runs first, then specialists execute with coordinator's plan | Fail-fast (default) |
|
|
636
|
+
| **Collaborative** | Agents take turns; each agent's output is broadcast to all others via MessageBroker | Continue (default) |
|
|
637
|
+
| **DAG** | Agents run as soon as all their dependencies are satisfied; supports cycle detection and deadlock handling | Fail-at-end (default) |
|
|
638
|
+
|
|
639
|
+
### Agent Roles
|
|
640
|
+
|
|
641
|
+
| Role | Permissions | Default Max Steps | Tools Count |
|
|
642
|
+
|------|------------|:-----------------:|:-----------:|
|
|
643
|
+
| `researcher` | Read-only (filesystem, web, git, skills) | 30 | 16 |
|
|
644
|
+
| `implementer` | Full read/write/execute (filesystem, shell, tests) | 50 | 26 |
|
|
645
|
+
| `reviewer` | Read + execute (tests, lint) but no file writes | 25 | 15 |
|
|
646
|
+
| `coordinator` | Read-only + planning tools | 20 | 8 |
|
|
647
|
+
| `custom` | Based on selected tools | 30 | Variable |
|
|
648
|
+
|
|
649
|
+
### Workflow Templates
|
|
650
|
+
|
|
651
|
+
Six pre-built workflow templates are available:
|
|
652
|
+
|
|
653
|
+
| Template | Agents | Strategy | Description |
|
|
654
|
+
|----------|--------|----------|-------------|
|
|
655
|
+
| **Code Review** | Researcher → Implementer → Reviewer | Sequential | Analyze code, implement fixes, review changes |
|
|
656
|
+
| **Feature Development** | Coordinator → Backend Dev + Frontend Dev → QA | DAG | Plan, implement in parallel, test |
|
|
657
|
+
| **Bug Fixing** | Debug Agent → Fix Agent → Test Agent | Sequential | Diagnose, fix, verify |
|
|
658
|
+
| **Collaborative Research** | Researcher 1 + Researcher 2 + Researcher 3 | Parallel | Multiple researchers working simultaneously |
|
|
659
|
+
| **Security Audit** | Scanner → Static Auditor + Dependency Auditor → Report Coordinator | DAG | Scan, audit in parallel, synthesize report |
|
|
660
|
+
| **Full-Stack Feature** | Architect → DB Dev + API Dev + UI Dev → Integration Tester | DAG | Design, implement layers in parallel, test |
|
|
661
|
+
|
|
662
|
+
### Workflow Builder (Fluent API)
|
|
663
|
+
|
|
664
|
+
For programmatic workflow construction:
|
|
665
|
+
|
|
666
|
+
```typescript
|
|
667
|
+
import { WorkflowBuilder, WorkflowTemplates } from "./modes/multi/workflow-builder";
|
|
668
|
+
|
|
669
|
+
// Use a template
|
|
670
|
+
const workflow = WorkflowTemplates.featureDevelopmentWorkflow("wf_001", "Add OAuth2 support");
|
|
671
|
+
|
|
672
|
+
// Or build custom
|
|
673
|
+
const custom = new WorkflowBuilder("wf_custom", "Refactor the API layer")
|
|
674
|
+
.addResearcher("analyzer", "Code Analyzer", "Analyzes the current API structure")
|
|
675
|
+
.addImplementer("refactorer", "Refactoring Agent", "Implements the refactoring", {
|
|
676
|
+
dependsOn: ["analyzer"],
|
|
677
|
+
})
|
|
678
|
+
.addReviewer("validator", "Validation Agent", "Validates the refactoring", {
|
|
679
|
+
dependsOn: ["refactorer"],
|
|
680
|
+
})
|
|
681
|
+
.withDagStrategy(3, 60_000) // max 3 concurrent, 60s timeout
|
|
682
|
+
.withRetryOnFailure(2)
|
|
683
|
+
.withExpectedOutput("Refactored API layer with passing tests")
|
|
684
|
+
.build();
|
|
685
|
+
|
|
686
|
+
// Validate before execution
|
|
687
|
+
const validation = WorkflowBuilder.validateWorkflow(custom);
|
|
688
|
+
if (!validation.isValid) {
|
|
689
|
+
console.error(validation.errors);
|
|
690
|
+
}
|
|
691
|
+
```
|
|
288
692
|
|
|
289
|
-
|
|
693
|
+
### Validation Checks
|
|
694
|
+
|
|
695
|
+
The workflow builder performs 10+ validation checks:
|
|
696
|
+
- Workflow ID and goal are present
|
|
697
|
+
- At least one agent exists
|
|
698
|
+
- No duplicate agent IDs
|
|
699
|
+
- No empty agent names or IDs
|
|
700
|
+
- `maxSteps > 0` for each agent
|
|
701
|
+
- At least 1 tool per agent
|
|
702
|
+
- Valid strategy type
|
|
703
|
+
- Hierarchical strategy requires a coordinator
|
|
704
|
+
- Collaborative strategy with >1 agent needs a timeout
|
|
705
|
+
- Fallback agent IDs exist in the workflow
|
|
706
|
+
- Dependency references exist and are not self-referencing
|
|
707
|
+
- **DAG cycle detection** — detects and reports dependency cycles
|
|
708
|
+
- Warns if DAG strategy is used but no agent has dependencies
|
|
290
709
|
|
|
291
710
|
---
|
|
292
711
|
|
|
293
|
-
##
|
|
712
|
+
## Retry & Error Handling
|
|
713
|
+
|
|
714
|
+
Astra has a comprehensive retry system for resilient operation:
|
|
715
|
+
|
|
716
|
+
### Error Classification
|
|
717
|
+
|
|
718
|
+
Errors are classified into 7 categories:
|
|
294
719
|
|
|
295
|
-
|
|
|
296
|
-
|
|
297
|
-
| `
|
|
298
|
-
| `
|
|
299
|
-
| `
|
|
300
|
-
| `
|
|
720
|
+
| Category | Retryable? | Suggested Delay | Examples |
|
|
721
|
+
|----------|:----------:|-----------------|----------|
|
|
722
|
+
| `TRANSIENT` | ✅ | 1s | 500, 502, 504 server errors |
|
|
723
|
+
| `RATE_LIMIT` | ✅ | 5s | 429 Too Many Requests, 503 Service Unavailable |
|
|
724
|
+
| `NETWORK` | ✅ | 2s | ECONNRESET, ETIMEDOUT, ENOTFOUND |
|
|
725
|
+
| `TIMEOUT` | ✅ | 3s | Request timeout, deadline exceeded |
|
|
726
|
+
| `UNKNOWN` | ✅ | 1s | Unrecognized errors (treated as transient) |
|
|
727
|
+
| `PERMANENT` | ❌ | — | 400 Bad Request, 404 Not Found, malformed input |
|
|
728
|
+
| `AUTH` | ❌ | — | 401 Unauthorized, 403 Forbidden, invalid API key |
|
|
301
729
|
|
|
302
|
-
|
|
730
|
+
### Retry Presets
|
|
731
|
+
|
|
732
|
+
| Preset | Max Retries | Base Delay | Max Delay | Backoff | Jitter |
|
|
733
|
+
|--------|:-----------:|------------|-----------|:-------:|:------:|
|
|
734
|
+
| `aiCall` | 3 | 1s | 30s | 2x | ±1s |
|
|
735
|
+
| `toolExecution` | 2 | 500ms | 5s | 2x | None |
|
|
736
|
+
| `network` | 5 | 2s | 60s | 2x | ±2s |
|
|
737
|
+
| `critical` | 5 | 1s | 60s | 2x | ±1.5s |
|
|
738
|
+
|
|
739
|
+
### Retry Behavior
|
|
740
|
+
|
|
741
|
+
- **Exponential backoff** — delay doubles (or by configured multiplier) with each attempt
|
|
742
|
+
- **Jitter** — random jitter is added to prevent thundering herd problems
|
|
743
|
+
- **Per-attempt timeouts** — optional timeout for individual attempts
|
|
744
|
+
- **Callbacks** — `onRetry` and `onExhausted` callbacks for progress reporting
|
|
745
|
+
- **Fallback to manual retry** — when automatic retries are exhausted, the user is offered a manual retry option
|
|
303
746
|
|
|
304
747
|
---
|
|
305
748
|
|
|
306
749
|
## Project Structure
|
|
307
750
|
|
|
308
751
|
```
|
|
309
|
-
|
|
310
|
-
├── index.ts # CLI entry point (Commander)
|
|
311
|
-
├── package.json #
|
|
312
|
-
├── tsconfig.json # TypeScript config
|
|
752
|
+
astrabot/
|
|
753
|
+
├── index.ts # CLI entry point (Commander). Registers all commands.
|
|
754
|
+
├── package.json # Package config: name "astrabot", bin "astra", dependencies.
|
|
755
|
+
├── tsconfig.json # TypeScript config: ESNext, strict, Bun types.
|
|
756
|
+
├── bun.lock # Bun lockfile.
|
|
757
|
+
├── .gitignore # Standard ignores.
|
|
758
|
+
├── .npmignore # Excludes tests, .github from npm package.
|
|
759
|
+
│
|
|
760
|
+
├── bin/astra # Binary entry point (shebang: #!/usr/bin/env bun)
|
|
313
761
|
│
|
|
314
|
-
├── ai/ # AI provider configuration
|
|
315
|
-
│ ├── index.ts #
|
|
316
|
-
│ ├── ai.config.ts # OpenRouter provider setup
|
|
317
|
-
│ ├── config-loader.ts # ~/.astra/.env management
|
|
318
|
-
│ ├── auto-retry.ts #
|
|
319
|
-
│ └── retry-prompt.ts # Manual retry prompt
|
|
762
|
+
├── ai/ # AI provider configuration and utilities.
|
|
763
|
+
│ ├── index.ts # Public API re-exports.
|
|
764
|
+
│ ├── ai.config.ts # OpenRouter provider setup and model resolution.
|
|
765
|
+
│ ├── config-loader.ts # ~/.astra/.env management (load, read, save).
|
|
766
|
+
│ ├── auto-retry.ts # withAiRetry() and createRetryableAiCall().
|
|
767
|
+
│ └── retry-prompt.ts # Manual retry prompt (promptToRetryAiCall).
|
|
320
768
|
│
|
|
321
|
-
├──
|
|
322
|
-
│ ├──
|
|
323
|
-
│ ├──
|
|
324
|
-
│
|
|
769
|
+
├── core/retry/ # Core retry engine.
|
|
770
|
+
│ ├── index.ts # Public API re-exports.
|
|
771
|
+
│ ├── retry-config.ts # ErrorCategory enum, RetryConfig, presets.
|
|
772
|
+
│ ├── retry-engine.ts # withRetry(), withRetryOrNull(), RetryPresets.
|
|
773
|
+
│ └── error-classifier.ts # Error classification (status codes, patterns, codes).
|
|
325
774
|
│
|
|
326
|
-
├──
|
|
327
|
-
│ ├──
|
|
328
|
-
│ ├──
|
|
329
|
-
│
|
|
775
|
+
├── tui/ # Terminal UI utilities.
|
|
776
|
+
│ ├── terminal-md.ts # Markdown-to-terminal rendering (marked + marked-terminal).
|
|
777
|
+
│ ├── spinner.ts # Animated spinner with metabolic rate engine.
|
|
778
|
+
│ └── wakeup.ts # ASCII banner with breathing animation + star field.
|
|
779
|
+
│
|
|
780
|
+
├── modes/ # All interaction modes.
|
|
781
|
+
│ ├── cli.ts # CLI mode loop (mode selection).
|
|
782
|
+
│ ├── auto.ts # Auto mode (LLM intent classification router).
|
|
783
|
+
│ ├── setup.ts # Interactive setup wizard.
|
|
330
784
|
│ │
|
|
331
|
-
│ ├── agent/ # Agent mode
|
|
332
|
-
│ │ ├── types.ts #
|
|
333
|
-
│ │ ├── action-tracker.ts #
|
|
334
|
-
│ │ ├──
|
|
335
|
-
│ │ ├──
|
|
336
|
-
│ │ ├── diff-view.ts # Unified diff generation
|
|
337
|
-
│ │ ├── approval.ts #
|
|
338
|
-
│ │ └── orchestrator.ts #
|
|
785
|
+
│ ├── agent/ # Agent mode.
|
|
786
|
+
│ │ ├── types.ts # ActionType, ActionStatus, ActionLog, AgentConfig.
|
|
787
|
+
│ │ ├── action-tracker.ts # ActionTracker (append-only log).
|
|
788
|
+
│ │ ├── agent-tools.ts # createAgentTools() — 35+ Vercel AI SDK tools.
|
|
789
|
+
│ │ ├── tool-executor.ts # ToolExecutor — staging overlay + all implementations.
|
|
790
|
+
│ │ ├── diff-view.ts # Unified diff generation.
|
|
791
|
+
│ │ ├── approval.ts # runApprovalFlow() — approve/review/reject.
|
|
792
|
+
│ │ └── orchestrator.ts # runAgentMode() — full agent lifecycle.
|
|
339
793
|
│ │
|
|
340
|
-
│ ├── ask/ # Ask mode
|
|
341
|
-
│ │ └── orchestrator.ts
|
|
794
|
+
│ ├── ask/ # Ask mode.
|
|
795
|
+
│ │ └── orchestrator.ts # runAskMode() — read-only Q&A.
|
|
342
796
|
│ │
|
|
343
|
-
│ ├── plan/ # Plan mode
|
|
344
|
-
│ │ ├── types.ts # Plan
|
|
345
|
-
│ │ ├── planner.ts # LLM-
|
|
346
|
-
│ │ ├── selection.ts #
|
|
347
|
-
│ │ ├── web-tools.ts # Firecrawl
|
|
348
|
-
│ │ └── orchestrator.ts #
|
|
797
|
+
│ ├── plan/ # Plan mode.
|
|
798
|
+
│ │ ├── types.ts # PlanStep, Plan interfaces.
|
|
799
|
+
│ │ ├── planner.ts # generatePlan() — LLM-structured planning.
|
|
800
|
+
│ │ ├── selection.ts # printPlan(), selectSteps().
|
|
801
|
+
│ │ ├── web-tools.ts # Firecrawl-based web_search, web_crawl, fetch_url.
|
|
802
|
+
│ │ └── orchestrator.ts # runPlanMode() — plan → select → execute → approve.
|
|
349
803
|
│ │
|
|
350
|
-
│ └── multi/ # Multi-agent mode
|
|
351
|
-
│ ├── types.ts # Full type system
|
|
352
|
-
│ ├── agent-pool-manager.ts #
|
|
353
|
-
│ ├── message-broker.ts #
|
|
354
|
-
│ ├── multi-agent-orchestrator.ts #
|
|
355
|
-
│ ├── workflow-builder.ts #
|
|
356
|
-
│ ├── examples.ts #
|
|
357
|
-
│ └── orchestrator.ts #
|
|
804
|
+
│ └── multi/ # Multi-agent mode.
|
|
805
|
+
│ ├── types.ts # Full type system (AgentRole, AgentConfig, etc.).
|
|
806
|
+
│ ├── agent-pool-manager.ts # AgentPoolManager — registration, tracking, stats.
|
|
807
|
+
│ ├── message-broker.ts # MessageBroker — pub-sub communication.
|
|
808
|
+
│ ├── multi-agent-orchestrator.ts # MultiAgentOrchestrator — strategy dispatch.
|
|
809
|
+
│ ├── workflow-builder.ts # WorkflowBuilder (fluent API) + WorkflowTemplates.
|
|
810
|
+
│ ├── examples.ts # 8 example workflow demonstrations.
|
|
811
|
+
│ └── orchestrator.ts # runMultiAgentMode() — AI workflow designer + execution.
|
|
358
812
|
│
|
|
359
|
-
├── session/ # Session persistence
|
|
360
|
-
│ ├── index.ts # Public API re-exports
|
|
361
|
-
│ ├── store.ts # JSON file store (atomic writes)
|
|
362
|
-
│ ├── session-manager.ts #
|
|
363
|
-
│ ├── session-context.ts # Context
|
|
364
|
-
│ └── session-tools.ts # session_status
|
|
813
|
+
├── session/ # Session persistence and management.
|
|
814
|
+
│ ├── index.ts # Public API re-exports.
|
|
815
|
+
│ ├── store.ts # JSON file store (atomic writes, CRUD).
|
|
816
|
+
│ ├── session-manager.ts # beginSession, endSession, auto-resume logic.
|
|
817
|
+
│ ├── session-context.ts # Context summary building for resumption.
|
|
818
|
+
│ └── session-tools.ts # session_status, session_resume_context, session_search.
|
|
365
819
|
│
|
|
366
|
-
├──
|
|
367
|
-
│
|
|
368
|
-
│
|
|
369
|
-
│ ├── retry-config.ts # Configuration and presets
|
|
370
|
-
│ ├── retry-engine.ts # Execution with backoff + jitter
|
|
371
|
-
│ └── error-classifier.ts # Error categorisation
|
|
820
|
+
├── game/ # Arcade easter egg.
|
|
821
|
+
│ ├── index.html # Retro Snake Classic (HTML5 Canvas).
|
|
822
|
+
│ └── neon-breaker.html # Neon Brick Breaker (HTML5 Canvas).
|
|
372
823
|
│
|
|
373
|
-
└──
|
|
374
|
-
|
|
375
|
-
└── neon-breaker.html # Brick Breaker
|
|
824
|
+
└── tests/
|
|
825
|
+
└── cli.test.ts # CLI tests.
|
|
376
826
|
```
|
|
377
827
|
|
|
378
828
|
---
|
|
379
829
|
|
|
380
830
|
## Dependencies
|
|
381
831
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
|
385
|
-
|
|
386
|
-
|
|
|
387
|
-
| `@
|
|
388
|
-
| `
|
|
389
|
-
| `
|
|
390
|
-
| `
|
|
391
|
-
| `
|
|
392
|
-
| `
|
|
393
|
-
| `
|
|
394
|
-
| `
|
|
832
|
+
### Runtime Dependencies
|
|
833
|
+
|
|
834
|
+
| Package | Version | Purpose |
|
|
835
|
+
|---------|---------|---------|
|
|
836
|
+
| `@openrouter/ai-sdk-provider` | ^2.9.0 | OpenRouter as LLM provider for Vercel AI SDK |
|
|
837
|
+
| `@clack/prompts` | ^1.4.0 | Interactive terminal prompts |
|
|
838
|
+
| `@clack/core` | ^1.3.1 | Core prompt primitives |
|
|
839
|
+
| `@mendable/firecrawl-js` | ^4.25.1 | Firecrawl SDK for web search and crawling |
|
|
840
|
+
| `commander` | ^15.0.0 | CLI argument parsing |
|
|
841
|
+
| `chalk` | ^5.6.2 | Terminal string styling |
|
|
842
|
+
| `figlet` | ^1.11.0 | ASCII art banner generation |
|
|
843
|
+
| `marked` | ^18.0.4 | Markdown parser |
|
|
844
|
+
| `marked-terminal` | ^7.3.0 | Markdown renderer for terminal output |
|
|
845
|
+
| `diff` | ^9.0.0 | Unified diff generation |
|
|
846
|
+
| `dotenv` | ^17.4.2 | .env file loading |
|
|
847
|
+
| `docx` | ^9.7.1 | Microsoft Word document generation |
|
|
848
|
+
| `@types/node` | ^25.9.1 | Node.js type definitions |
|
|
849
|
+
| `@types/marked-terminal` | ^6.1.1 | Type definitions for marked-terminal |
|
|
850
|
+
|
|
851
|
+
### Dev Dependencies
|
|
852
|
+
|
|
853
|
+
| Package | Version | Purpose |
|
|
854
|
+
|---------|---------|---------|
|
|
855
|
+
| `@types/bun` | latest | Bun runtime type definitions |
|
|
856
|
+
|
|
857
|
+
### Peer Dependencies
|
|
858
|
+
|
|
859
|
+
| Package | Version | Purpose |
|
|
860
|
+
|---------|---------|---------|
|
|
861
|
+
| `typescript` | ^5 | TypeScript compiler |
|
|
395
862
|
|
|
396
863
|
---
|
|
397
864
|
|
|
398
865
|
## Roadmap
|
|
399
866
|
|
|
400
|
-
|
|
867
|
+
Planned features not yet implemented:
|
|
868
|
+
|
|
869
|
+
- [ ] **Telegram mode** — stub present in wakeup menu, not yet implemented
|
|
401
870
|
- [ ] **Undo/redo support** — via action log replay
|
|
402
871
|
- [ ] **Streaming token output** — for real-time agent response display
|
|
403
872
|
- [ ] **Configurable tool allowlists per mode** — currently hardcoded per mode
|
|
404
|
-
- [ ] **Multi-model support with per-mode model selection** — partially implemented in multi-agent
|
|
873
|
+
- [ ] **Multi-model support with per-mode model selection** — partially implemented in multi-agent mode only
|
|
405
874
|
- [ ] **Persistent action history across sessions** — sessions store summaries but not full action logs
|
|
406
875
|
|
|
407
876
|
---
|
|
408
877
|
|
|
409
878
|
## License
|
|
410
879
|
|
|
411
|
-
MIT
|
|
880
|
+
[MIT](LICENSE) — see the LICENSE file for details.
|
|
881
|
+
|
|
882
|
+
---
|
|
883
|
+
|
|
884
|
+
<div align="center">
|
|
885
|
+
|
|
886
|
+
**Astra** — Your AI-native development companion.
|
|
887
|
+
|
|
888
|
+
Built with ❤️ using [Bun](https://bun.sh) · [OpenRouter](https://openrouter.ai) · [Vercel AI SDK](https://sdk.vercel.ai)
|
|
889
|
+
|
|
890
|
+
</div>
|