@hasna/assistants 0.6.62 → 1.0.2
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/LICENSE +1 -1
- package/README.md +476 -42
- package/dist/{index.js → cli.js} +24271 -44570
- package/dist/lib.d.ts +232 -0
- package/dist/lib.js +154629 -0
- package/package.json +56 -52
- package/dist/.assistants/ASSISTANTS.md +0 -10
- package/dist/.assistants/commands/reflect.md +0 -13
- package/dist/.assistants/feedback/1c552736-058b-4a60-a67b-f0e7ec228f6d.json +0 -8
- package/dist/.assistants/feedback/324f7179-cb61-4591-803e-30877228610e.json +0 -11
- package/dist/.assistants/feedback/49077cdf-1097-40ee-9173-56bdd8e5740d.json +0 -8
- package/dist/.assistants/feedback/6937c140-58c0-480c-b579-bc31ee2924a6.json +0 -8
- package/dist/.assistants/feedback/6c7c4eb1-9f23-49a4-8fa0-ff350550b038.json +0 -8
- package/dist/.assistants/feedback/6ff5a208-3bc1-4a92-adb9-243d23c2e56f.json +0 -8
- package/dist/.assistants/feedback/bf6c14e2-5264-4ecf-9858-05218e858546.json +0 -8
- package/dist/.assistants/feedback/cf204917-529b-4cdb-a0a3-ff97033b59f4.json +0 -8
- package/dist/.assistants/projects/11a6d12e-a46f-4a6c-bbe8-bc58ebf2eddc.json +0 -9
- package/dist/.assistants/schedules/locks/4b758436-e846-441d-b1a2-aae03df551d1.lock.json +0 -6
- package/dist/.assistants/schedules/locks/ec03a634-6135-4bea-b9be-fb426095bba5.lock.json +0 -6
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_10.json +0 -92
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_11.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_12.json +0 -92
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_13.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_2.json +0 -102
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_3.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_4.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_5.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_6.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_7.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_8.json +0 -82
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_9.json +0 -92
- package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/twitter_archive_entries.json +0 -102
- package/dist/.assistants/skills/calendar/SKILL.md +0 -40
- package/dist/.assistants/skills/email/SKILL.md +0 -41
- package/dist/.assistants/skills/notes/SKILL.md +0 -44
- package/dist/.assistants/skills/search/SKILL.md +0 -23
- package/dist/.assistants/skills/skill-brainstorm/SKILL.md +0 -30
- package/dist/.assistants/skills/skill-draft/SKILL.md +0 -30
- package/dist/.assistants/skills/skill-research/SKILL.md +0 -27
- package/dist/.assistants/skills/skill-summarize/SKILL.md +0 -25
- package/dist/config/hooks.json +0 -15
- package/dist/config/settings.json +0 -43
- package/dist/index.js.map +0 -1016
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,86 +1,520 @@
|
|
|
1
|
-
# assistants
|
|
1
|
+
# @hasna/assistants
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
5
|
+
A general-purpose AI assistant that runs in your terminal. Built with [Ink](https://github.com/vadimdemedes/ink) and powered by [Claude](https://www.anthropic.com/claude).
|
|
6
|
+
|
|
7
|
+
**Not just for coding** - while it excels at development workflows, this assistant helps with research, writing, task management, automation, and any task you need assistance with.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- General-purpose assistant for any task
|
|
12
|
+
- Interactive chat with Claude AI
|
|
13
|
+
- Execute bash commands with approval
|
|
14
|
+
- Read, write, and edit files
|
|
15
|
+
- Fetch and search web content
|
|
16
|
+
- Custom skills and hooks for domain-specific workflows
|
|
17
|
+
- Project and plan management
|
|
18
|
+
- Memory and context persistence across sessions
|
|
19
|
+
- Session history and resumption
|
|
20
|
+
- Identity management for different contexts
|
|
21
|
+
- Voice input/output (optional)
|
|
22
|
+
- Connectors for external services (Notion, Gmail, Linear, etc.)
|
|
13
23
|
|
|
14
24
|
## Installation
|
|
15
25
|
|
|
26
|
+
### Prerequisites
|
|
27
|
+
|
|
28
|
+
- [Bun](https://bun.sh) runtime (v1.0 or later)
|
|
29
|
+
- [Anthropic API key](https://console.anthropic.com/)
|
|
30
|
+
|
|
31
|
+
### Install globally
|
|
32
|
+
|
|
16
33
|
```bash
|
|
17
34
|
bun add -g @hasna/assistants
|
|
18
35
|
```
|
|
19
36
|
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
### Or run directly
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
bunx @hasna/assistants
|
|
41
|
+
```
|
|
22
42
|
|
|
23
43
|
## Quick Start
|
|
24
44
|
|
|
45
|
+
1. Set your Anthropic API key:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. Start the assistant:
|
|
52
|
+
|
|
25
53
|
```bash
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
assistants
|
|
55
|
+
# or use the short alias
|
|
56
|
+
ast
|
|
57
|
+
```
|
|
28
58
|
|
|
29
|
-
|
|
59
|
+
3. Start chatting!
|
|
60
|
+
|
|
61
|
+
## CLI Reference
|
|
62
|
+
|
|
63
|
+
### Basic Usage
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Start interactive mode
|
|
30
67
|
assistants
|
|
68
|
+
|
|
69
|
+
# Run in headless mode (non-interactive)
|
|
70
|
+
assistants -p "What does this codebase do?"
|
|
31
71
|
```
|
|
32
72
|
|
|
33
|
-
|
|
73
|
+
### Options
|
|
74
|
+
|
|
75
|
+
| Option | Description |
|
|
76
|
+
|--------|-------------|
|
|
77
|
+
| `-h, --help` | Show help message |
|
|
78
|
+
| `-v, --version` | Show version number |
|
|
79
|
+
| `-p, --print <prompt>` | Run non-interactively with the given prompt |
|
|
80
|
+
| `--output-format <format>` | Output format: `text` (default), `json`, `stream-json` |
|
|
81
|
+
| `--allowed-tools <tools>` | Comma-separated tools to auto-approve |
|
|
82
|
+
| `--system-prompt <prompt>` | Custom system prompt |
|
|
83
|
+
| `--json-schema <schema>` | JSON Schema for structured output |
|
|
84
|
+
| `-c, --continue` | Continue the most recent conversation |
|
|
85
|
+
| `-r, --resume <session_id>` | Resume a specific session by ID |
|
|
86
|
+
| `--cwd <path>` | Set working directory |
|
|
87
|
+
|
|
88
|
+
### Headless Mode Examples
|
|
89
|
+
|
|
34
90
|
```bash
|
|
35
|
-
|
|
91
|
+
# Ask a question
|
|
92
|
+
assistants -p "What does the auth module do?"
|
|
93
|
+
|
|
94
|
+
# Run with JSON output
|
|
95
|
+
assistants -p "Summarize this project" --output-format json
|
|
96
|
+
|
|
97
|
+
# Stream JSON events
|
|
98
|
+
assistants -p "Explain this code" --output-format stream-json
|
|
99
|
+
|
|
100
|
+
# Auto-approve specific tools
|
|
101
|
+
assistants -p "Fix the bug in auth.py" --allowed-tools "Read,Edit,Bash"
|
|
102
|
+
|
|
103
|
+
# Get structured output with JSON Schema
|
|
104
|
+
assistants -p "List all functions" --output-format json \
|
|
105
|
+
--json-schema '{"type":"array","items":{"type":"string"}}'
|
|
106
|
+
|
|
107
|
+
# Continue a previous conversation
|
|
108
|
+
assistants -p "What else can you tell me?" --continue
|
|
109
|
+
|
|
110
|
+
# Resume a specific session
|
|
111
|
+
assistants -p "Continue from where we left off" --resume abc123
|
|
36
112
|
```
|
|
37
113
|
|
|
38
|
-
##
|
|
114
|
+
## Interactive Mode
|
|
115
|
+
|
|
116
|
+
### Keyboard Shortcuts
|
|
117
|
+
|
|
118
|
+
| Key | Action |
|
|
119
|
+
|-----|--------|
|
|
120
|
+
| `Enter` | Send message |
|
|
121
|
+
| `Ctrl+C` | Stop current operation or exit |
|
|
122
|
+
| `Ctrl+]` | Switch sessions |
|
|
123
|
+
| `Up/Down` | Navigate command history |
|
|
124
|
+
| `Tab` | Autocomplete commands |
|
|
39
125
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
126
|
+
### Slash Commands
|
|
127
|
+
|
|
128
|
+
| Command | Description |
|
|
129
|
+
|---------|-------------|
|
|
130
|
+
| `/help` | Show available commands |
|
|
131
|
+
| `/exit` | Exit the assistant |
|
|
132
|
+
| `/new` | Start a new session |
|
|
133
|
+
| `/clear` | Clear the screen |
|
|
134
|
+
| `/session` | Show current session info |
|
|
135
|
+
| `/tokens` | Show token usage |
|
|
136
|
+
| `/context` | Show/manage context window |
|
|
137
|
+
| `/cost` | Show estimated cost |
|
|
138
|
+
| `/status` | Show system status |
|
|
139
|
+
| `/model` | Show/change model settings |
|
|
140
|
+
| `/config` | Show/edit configuration |
|
|
141
|
+
| `/init` | Initialize project settings |
|
|
142
|
+
|
|
143
|
+
### Project & Plan Commands
|
|
144
|
+
|
|
145
|
+
| Command | Description |
|
|
146
|
+
|---------|-------------|
|
|
147
|
+
| `/projects` | List and manage projects |
|
|
148
|
+
| `/plans` | View and manage plans |
|
|
149
|
+
| `/summarize` | Summarize the conversation |
|
|
150
|
+
| `/compact` | Compact context to save tokens |
|
|
151
|
+
|
|
152
|
+
### Scheduling Commands
|
|
153
|
+
|
|
154
|
+
| Command | Description |
|
|
155
|
+
|---------|-------------|
|
|
156
|
+
| `/schedule` | Create a scheduled task |
|
|
157
|
+
| `/schedules` | List scheduled tasks |
|
|
158
|
+
| `/unschedule` | Remove a scheduled task |
|
|
159
|
+
| `/pause` | Pause a schedule |
|
|
160
|
+
| `/resume` | Resume a paused schedule |
|
|
161
|
+
|
|
162
|
+
### Skills & Connectors
|
|
163
|
+
|
|
164
|
+
| Command | Description |
|
|
165
|
+
|---------|-------------|
|
|
166
|
+
| `/skills` | List available skills |
|
|
167
|
+
| `/skill <name>` | Execute a skill |
|
|
168
|
+
| `/connectors` | List available connectors |
|
|
169
|
+
|
|
170
|
+
### Hooks Commands
|
|
171
|
+
|
|
172
|
+
| Command | Description |
|
|
173
|
+
|---------|-------------|
|
|
174
|
+
| `/hooks` | Open interactive hooks panel |
|
|
175
|
+
| `/hooks list` | List all hooks (native + user) |
|
|
176
|
+
| `/hooks enable <id>` | Enable a hook |
|
|
177
|
+
| `/hooks disable <id>` | Disable a hook |
|
|
178
|
+
| `/hooks test <id>` | Test a hook with sample input |
|
|
179
|
+
| `/hooks help` | Show hooks help |
|
|
180
|
+
|
|
181
|
+
### Advanced Commands
|
|
182
|
+
|
|
183
|
+
| Command | Description |
|
|
184
|
+
|---------|-------------|
|
|
185
|
+
| `/voice` | Toggle voice mode |
|
|
186
|
+
| `/say <text>` | Speak text aloud |
|
|
187
|
+
| `/listen` | Listen for voice input |
|
|
188
|
+
| `/identity` | Manage agent identity |
|
|
189
|
+
| `/whoami` | Show current identity |
|
|
190
|
+
| `/assistant` | Configure assistant settings |
|
|
191
|
+
| `/inbox` | Check email inbox |
|
|
192
|
+
| `/wallet` | Manage crypto wallet |
|
|
193
|
+
| `/secrets` | Manage secrets |
|
|
194
|
+
| `/jobs` | View background jobs |
|
|
195
|
+
| `/messages` | Agent-to-agent messages |
|
|
196
|
+
| `/verification` | Manage verification sessions |
|
|
197
|
+
| `/memory` | View memory usage |
|
|
198
|
+
| `/rest` | Enter rest mode |
|
|
199
|
+
| `/feedback` | Submit feedback |
|
|
200
|
+
| `/security-log` | View security events |
|
|
48
201
|
|
|
49
202
|
## Configuration
|
|
50
203
|
|
|
51
|
-
|
|
52
|
-
|
|
204
|
+
### Directory Structure
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
~/.assistants/
|
|
208
|
+
├── config.json # Global configuration
|
|
209
|
+
├── sessions/ # Session history
|
|
210
|
+
├── skills/ # Custom skills
|
|
211
|
+
├── hooks.json # Global hooks
|
|
212
|
+
└── schedules/ # Scheduled tasks
|
|
213
|
+
|
|
214
|
+
.assistants/ # Project-level (in any directory)
|
|
215
|
+
├── config.json # Project configuration
|
|
216
|
+
├── skills/ # Project-specific skills
|
|
217
|
+
└── hooks.json # Project-specific hooks
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Configuration File
|
|
221
|
+
|
|
222
|
+
Create `~/.assistants/config.json`:
|
|
53
223
|
|
|
54
224
|
```json
|
|
55
225
|
{
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
226
|
+
"model": "claude-sonnet-4-20250514",
|
|
227
|
+
"temperature": 0.7,
|
|
228
|
+
"maxTokens": 8192,
|
|
229
|
+
"connectors": ["notion", "googledrive"],
|
|
230
|
+
"voice": {
|
|
231
|
+
"tts": "elevenlabs",
|
|
232
|
+
"stt": "whisper"
|
|
233
|
+
}
|
|
61
234
|
}
|
|
62
235
|
```
|
|
63
236
|
|
|
237
|
+
### Project Configuration
|
|
238
|
+
|
|
239
|
+
Create `.assistants/config.json` in your project:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"name": "My Project",
|
|
244
|
+
"description": "Project description",
|
|
245
|
+
"systemPrompt": "You are helping with a Node.js backend project.",
|
|
246
|
+
"context": [
|
|
247
|
+
"src/README.md",
|
|
248
|
+
"docs/architecture.md"
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Environment Variables
|
|
254
|
+
|
|
255
|
+
| Variable | Required | Description |
|
|
256
|
+
|----------|----------|-------------|
|
|
257
|
+
| `ANTHROPIC_API_KEY` | Yes | Claude API access |
|
|
258
|
+
| `ELEVENLABS_API_KEY` | No | ElevenLabs TTS |
|
|
259
|
+
| `OPENAI_API_KEY` | No | Whisper STT |
|
|
260
|
+
| `EXA_API_KEY` | No | Enhanced web search |
|
|
261
|
+
| `AWS_ACCESS_KEY_ID` | No | AWS features |
|
|
262
|
+
| `AWS_SECRET_ACCESS_KEY` | No | AWS features |
|
|
263
|
+
| `AWS_REGION` | No | AWS region |
|
|
264
|
+
| `ASSISTANTS_NO_SYNC` | No | Disable synchronized output (set to `1`) |
|
|
265
|
+
|
|
64
266
|
## Skills
|
|
65
267
|
|
|
66
|
-
Skills are `SKILL.md` files
|
|
268
|
+
Skills are reusable prompts defined in `SKILL.md` files:
|
|
67
269
|
|
|
68
|
-
```
|
|
270
|
+
```markdown
|
|
69
271
|
---
|
|
70
|
-
name:
|
|
71
|
-
description:
|
|
72
|
-
|
|
272
|
+
name: code-review
|
|
273
|
+
description: Review code for issues and improvements
|
|
274
|
+
argument-hint: <file-path>
|
|
275
|
+
allowed-tools: Read, Grep
|
|
73
276
|
---
|
|
74
277
|
|
|
75
|
-
|
|
278
|
+
## Instructions
|
|
279
|
+
|
|
280
|
+
Review the code at $ARGUMENTS and provide feedback on:
|
|
281
|
+
1. Potential bugs
|
|
282
|
+
2. Performance issues
|
|
283
|
+
3. Code style
|
|
284
|
+
4. Security concerns
|
|
76
285
|
```
|
|
77
286
|
|
|
78
|
-
|
|
287
|
+
Place in `~/.assistants/skills/code-review/SKILL.md` or `.assistants/skills/code-review/SKILL.md`.
|
|
288
|
+
|
|
289
|
+
Use with `/skill code-review src/auth.ts` or `$code-review src/auth.ts`.
|
|
290
|
+
|
|
291
|
+
## Hooks
|
|
79
292
|
|
|
80
|
-
|
|
293
|
+
Hooks intercept agent behavior at key lifecycle points. Use them to validate inputs, block dangerous actions, log activity, or inject context.
|
|
81
294
|
|
|
82
|
-
|
|
295
|
+
### Managing Hooks
|
|
296
|
+
|
|
297
|
+
Use the interactive panel:
|
|
298
|
+
```
|
|
299
|
+
/hooks
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Or manage via commands:
|
|
303
|
+
```
|
|
304
|
+
/hooks list # List all hooks
|
|
305
|
+
/hooks enable abc123 # Enable a hook by ID
|
|
306
|
+
/hooks disable abc123 # Disable a hook
|
|
307
|
+
/hooks test abc123 # Test a hook with sample input
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Hook Events
|
|
311
|
+
|
|
312
|
+
| Event | When Triggered |
|
|
313
|
+
|-------|----------------|
|
|
314
|
+
| **PreToolUse** | Before any tool executes |
|
|
315
|
+
| **PostToolUse** | After tool succeeds |
|
|
316
|
+
| **PostToolUseFailure** | After tool fails |
|
|
317
|
+
| **PermissionRequest** | When approval needed |
|
|
318
|
+
| **UserPromptSubmit** | User sends message |
|
|
319
|
+
| **SessionStart** | Session begins |
|
|
320
|
+
| **SessionEnd** | Session ends |
|
|
321
|
+
| **SubagentStart** | Subagent spawning |
|
|
322
|
+
| **SubagentStop** | Subagent completes |
|
|
323
|
+
| **PreCompact** | Before context compaction |
|
|
324
|
+
| **Notification** | Notification sent |
|
|
325
|
+
| **Stop** | Agent stopping |
|
|
326
|
+
|
|
327
|
+
### Configuration
|
|
328
|
+
|
|
329
|
+
Create `.assistants/hooks.json` in your project:
|
|
330
|
+
|
|
331
|
+
```json
|
|
332
|
+
{
|
|
333
|
+
"PreToolUse": [
|
|
334
|
+
{
|
|
335
|
+
"matcher": "Bash|Edit|Write",
|
|
336
|
+
"hooks": [
|
|
337
|
+
{
|
|
338
|
+
"id": "validate-commands",
|
|
339
|
+
"name": "Validate dangerous commands",
|
|
340
|
+
"description": "Blocks rm -rf, sudo, etc.",
|
|
341
|
+
"type": "command",
|
|
342
|
+
"command": "./scripts/validate.sh",
|
|
343
|
+
"timeout": 5000,
|
|
344
|
+
"enabled": true
|
|
345
|
+
}
|
|
346
|
+
]
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
"PostToolUse": [
|
|
350
|
+
{
|
|
351
|
+
"matcher": "Edit",
|
|
352
|
+
"hooks": [
|
|
353
|
+
{
|
|
354
|
+
"type": "command",
|
|
355
|
+
"command": "prettier --write \"$INPUT_file_path\"",
|
|
356
|
+
"async": true
|
|
357
|
+
}
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Creating Hooks via Wizard
|
|
365
|
+
|
|
366
|
+
Press `a` in the hooks panel to launch the interactive wizard:
|
|
367
|
+
|
|
368
|
+
1. Select event type (PreToolUse, PostToolUse, etc.)
|
|
369
|
+
2. Enter matcher pattern (regex or `*` for all)
|
|
370
|
+
3. Choose hook type (command, prompt, agent)
|
|
371
|
+
4. Enter command or prompt
|
|
372
|
+
5. Set timeout and async options
|
|
373
|
+
6. Choose save location (user, project, local)
|
|
374
|
+
|
|
375
|
+
### Example: Block Dangerous Commands
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
#!/bin/bash
|
|
379
|
+
# .assistants/scripts/validate.sh
|
|
380
|
+
INPUT=$(cat)
|
|
381
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
382
|
+
|
|
383
|
+
if echo "$COMMAND" | grep -qE 'rm\s+-rf|sudo|shutdown'; then
|
|
384
|
+
echo "Blocked: dangerous command" >&2
|
|
385
|
+
exit 2 # Exit 2 = block
|
|
386
|
+
fi
|
|
387
|
+
|
|
388
|
+
exit 0 # Exit 0 = allow
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Native Hooks
|
|
392
|
+
|
|
393
|
+
Built-in hooks that can be enabled/disabled:
|
|
394
|
+
|
|
395
|
+
| Hook | Event | Description |
|
|
396
|
+
|------|-------|-------------|
|
|
397
|
+
| **scope-verification** | Stop | Verifies goals were met |
|
|
398
|
+
|
|
399
|
+
Manage native hooks via `/hooks` panel or commands.
|
|
400
|
+
|
|
401
|
+
## Programmatic Usage
|
|
402
|
+
|
|
403
|
+
### EmbeddedClient (Full Control)
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
import { EmbeddedClient } from '@hasna/assistants';
|
|
407
|
+
|
|
408
|
+
// Create client with working directory
|
|
409
|
+
const client = new EmbeddedClient(process.cwd(), {
|
|
410
|
+
systemPrompt: 'You are a helpful coding assistant.',
|
|
411
|
+
allowedTools: ['Read', 'Write', 'Edit', 'Bash'],
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// Handle streaming chunks
|
|
415
|
+
client.onChunk((chunk) => {
|
|
416
|
+
if (chunk.type === 'text' && chunk.content) {
|
|
417
|
+
process.stdout.write(chunk.content);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// Initialize and send a message
|
|
422
|
+
await client.initialize();
|
|
423
|
+
await client.send('What files are in this directory?');
|
|
424
|
+
|
|
425
|
+
// Get session info
|
|
426
|
+
console.log('Session ID:', client.getSessionId());
|
|
427
|
+
console.log('Token usage:', client.getTokenUsage());
|
|
428
|
+
|
|
429
|
+
// Cleanup
|
|
430
|
+
client.disconnect();
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Headless Mode (Simple Queries)
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
import { runHeadless } from '@hasna/assistants';
|
|
437
|
+
|
|
438
|
+
// Run a simple query with JSON output
|
|
439
|
+
await runHeadless({
|
|
440
|
+
prompt: 'Summarize this project in 3 bullet points',
|
|
441
|
+
cwd: process.cwd(),
|
|
442
|
+
outputFormat: 'json',
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
// Stream JSON events
|
|
446
|
+
await runHeadless({
|
|
447
|
+
prompt: 'Explain the authentication system',
|
|
448
|
+
cwd: process.cwd(),
|
|
449
|
+
outputFormat: 'stream-json',
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// Auto-approve tools
|
|
453
|
+
await runHeadless({
|
|
454
|
+
prompt: 'Fix the bug in auth.ts',
|
|
455
|
+
cwd: process.cwd(),
|
|
456
|
+
outputFormat: 'text',
|
|
457
|
+
allowedTools: ['Read', 'Edit'],
|
|
458
|
+
});
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### Feature Detection
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
import { getFeatureAvailability, getFeatureStatusMessage } from '@hasna/assistants';
|
|
465
|
+
|
|
466
|
+
// Check what features are available
|
|
467
|
+
const features = getFeatureAvailability();
|
|
468
|
+
console.log('Core chat:', features.coreChat); // true if ANTHROPIC_API_KEY set
|
|
469
|
+
console.log('AWS features:', features.awsFeatures); // true if AWS configured
|
|
470
|
+
|
|
471
|
+
// Get human-readable status
|
|
472
|
+
console.log(getFeatureStatusMessage());
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
## Connectors
|
|
476
|
+
|
|
477
|
+
Connectors integrate external services. Install separately:
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
# Example: Notion connector
|
|
481
|
+
bun add -g @hasna/connect-notion
|
|
482
|
+
|
|
483
|
+
# List available connectors
|
|
484
|
+
assistants
|
|
485
|
+
/connectors
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
## Troubleshooting
|
|
489
|
+
|
|
490
|
+
### "ANTHROPIC_API_KEY not set"
|
|
491
|
+
|
|
492
|
+
Set your API key:
|
|
493
|
+
```bash
|
|
494
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### Terminal rendering issues
|
|
498
|
+
|
|
499
|
+
Try disabling synchronized output:
|
|
500
|
+
```bash
|
|
501
|
+
ASSISTANTS_NO_SYNC=1 assistants
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Slow startup
|
|
505
|
+
|
|
506
|
+
The first run may take longer as dependencies are cached. Subsequent runs will be faster.
|
|
507
|
+
|
|
508
|
+
### Session not found
|
|
509
|
+
|
|
510
|
+
Sessions are stored in `~/.assistants/sessions/`. Use `/session` to see current session info.
|
|
83
511
|
|
|
84
512
|
## License
|
|
85
513
|
|
|
86
514
|
MIT
|
|
515
|
+
|
|
516
|
+
## See Also
|
|
517
|
+
|
|
518
|
+
- [FEATURES.md](./FEATURES.md) - Detailed feature documentation
|
|
519
|
+
- [Anthropic API Documentation](https://docs.anthropic.com/)
|
|
520
|
+
- [Bun Documentation](https://bun.sh/docs)
|