@hasna/assistants 0.6.61 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +384 -43
  3. package/dist/{index.js → cli.js} +37312 -77269
  4. package/dist/lib.d.ts +58 -0
  5. package/dist/lib.js +140335 -0
  6. package/package.json +56 -52
  7. package/dist/.assistants/ASSISTANTS.md +0 -10
  8. package/dist/.assistants/commands/reflect.md +0 -13
  9. package/dist/.assistants/feedback/1c552736-058b-4a60-a67b-f0e7ec228f6d.json +0 -8
  10. package/dist/.assistants/feedback/324f7179-cb61-4591-803e-30877228610e.json +0 -11
  11. package/dist/.assistants/feedback/49077cdf-1097-40ee-9173-56bdd8e5740d.json +0 -8
  12. package/dist/.assistants/feedback/6937c140-58c0-480c-b579-bc31ee2924a6.json +0 -8
  13. package/dist/.assistants/feedback/6c7c4eb1-9f23-49a4-8fa0-ff350550b038.json +0 -8
  14. package/dist/.assistants/feedback/6ff5a208-3bc1-4a92-adb9-243d23c2e56f.json +0 -8
  15. package/dist/.assistants/feedback/bf6c14e2-5264-4ecf-9858-05218e858546.json +0 -8
  16. package/dist/.assistants/feedback/cf204917-529b-4cdb-a0a3-ff97033b59f4.json +0 -8
  17. package/dist/.assistants/projects/11a6d12e-a46f-4a6c-bbe8-bc58ebf2eddc.json +0 -9
  18. package/dist/.assistants/schedules/locks/4b758436-e846-441d-b1a2-aae03df551d1.lock.json +0 -6
  19. package/dist/.assistants/schedules/locks/ec03a634-6135-4bea-b9be-fb426095bba5.lock.json +0 -6
  20. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_10.json +0 -92
  21. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_11.json +0 -82
  22. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_12.json +0 -92
  23. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_13.json +0 -82
  24. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_2.json +0 -102
  25. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_3.json +0 -82
  26. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_4.json +0 -82
  27. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_5.json +0 -82
  28. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_6.json +0 -82
  29. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_7.json +0 -82
  30. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_8.json +0 -82
  31. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/ai_tweets_batch_9.json +0 -92
  32. package/dist/.assistants/scripts/f6be5a82-b00e-4b74-ba93-c610a7874776/twitter_archive_entries.json +0 -102
  33. package/dist/.assistants/skills/calendar/SKILL.md +0 -40
  34. package/dist/.assistants/skills/email/SKILL.md +0 -41
  35. package/dist/.assistants/skills/notes/SKILL.md +0 -44
  36. package/dist/.assistants/skills/search/SKILL.md +0 -23
  37. package/dist/.assistants/skills/skill-brainstorm/SKILL.md +0 -30
  38. package/dist/.assistants/skills/skill-draft/SKILL.md +0 -30
  39. package/dist/.assistants/skills/skill-research/SKILL.md +0 -27
  40. package/dist/.assistants/skills/skill-summarize/SKILL.md +0 -25
  41. package/dist/config/hooks.json +0 -15
  42. package/dist/config/settings.json +0 -43
  43. package/dist/index.js.map +0 -1011
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Hasna
3
+ Copyright (c) 2024-2026 Hasna
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,86 +1,427 @@
1
- # assistants
1
+ # @hasna/assistants-terminal
2
2
 
3
- A general-purpose AI assistant designed to help with any task - from research and writing to coding, automation, and beyond. Built terminal-first with powerful integrations.
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
5
- **This is not just a coding tool.** While it excels at development workflows, it's designed as a versatile assistant that can help with:
6
- - Research and analysis
7
- - Writing and content creation
8
- - Task management and productivity
9
- - Business operations
10
- - Personal assistance
11
- - Software development
12
- - Automation and integrations
5
+ A powerful 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
+ ## Features
8
+
9
+ - Interactive chat with Claude AI
10
+ - Execute bash commands with approval
11
+ - Read, write, and edit files
12
+ - Fetch and search web content
13
+ - Custom skills and hooks
14
+ - Project and plan management
15
+ - Session history and resumption
16
+ - Voice input/output (optional)
17
+ - Connectors for external services
13
18
 
14
19
  ## Installation
15
20
 
21
+ ### Prerequisites
22
+
23
+ - [Bun](https://bun.sh) runtime (v1.0 or later)
24
+ - [Anthropic API key](https://console.anthropic.com/)
25
+
26
+ ### Install globally
27
+
16
28
  ```bash
17
- bun add -g @hasna/assistants
29
+ bun install -g @hasna/assistants-terminal
18
30
  ```
19
31
 
20
- **Requirements:**
21
- - [Bun](https://bun.sh) 1.0+
32
+ ### Or run directly
33
+
34
+ ```bash
35
+ bunx @hasna/assistants-terminal
36
+ ```
22
37
 
23
38
  ## Quick Start
24
39
 
40
+ 1. Set your Anthropic API key:
41
+
25
42
  ```bash
26
- # Set your API key (or add to ~/.secrets)
27
- export ANTHROPIC_API_KEY="your-key"
43
+ export ANTHROPIC_API_KEY="sk-ant-..."
44
+ ```
28
45
 
29
- # Run
46
+ 2. Start the assistant:
47
+
48
+ ```bash
30
49
  assistants
50
+ # or use the short alias
51
+ ast
31
52
  ```
32
53
 
33
- Or add to `~/.secrets`:
54
+ 3. Start chatting!
55
+
56
+ ## CLI Reference
57
+
58
+ ### Basic Usage
59
+
34
60
  ```bash
35
- export ANTHROPIC_API_KEY="your-key"
61
+ # Start interactive mode
62
+ assistants
63
+
64
+ # Run in headless mode (non-interactive)
65
+ assistants -p "What does this codebase do?"
36
66
  ```
37
67
 
38
- ## Features
68
+ ### Options
69
+
70
+ | Option | Description |
71
+ |--------|-------------|
72
+ | `-h, --help` | Show help message |
73
+ | `-v, --version` | Show version number |
74
+ | `-p, --print <prompt>` | Run non-interactively with the given prompt |
75
+ | `--output-format <format>` | Output format: `text` (default), `json`, `stream-json` |
76
+ | `--allowed-tools <tools>` | Comma-separated tools to auto-approve |
77
+ | `--system-prompt <prompt>` | Custom system prompt |
78
+ | `--json-schema <schema>` | JSON Schema for structured output |
79
+ | `-c, --continue` | Continue the most recent conversation |
80
+ | `-r, --resume <session_id>` | Resume a specific session by ID |
81
+ | `--cwd <path>` | Set working directory |
82
+
83
+ ### Headless Mode Examples
84
+
85
+ ```bash
86
+ # Ask a question
87
+ assistants -p "What does the auth module do?"
88
+
89
+ # Run with JSON output
90
+ assistants -p "Summarize this project" --output-format json
91
+
92
+ # Stream JSON events
93
+ assistants -p "Explain this code" --output-format stream-json
94
+
95
+ # Auto-approve specific tools
96
+ assistants -p "Fix the bug in auth.py" --allowed-tools "Read,Edit,Bash"
97
+
98
+ # Get structured output with JSON Schema
99
+ assistants -p "List all functions" --output-format json \
100
+ --json-schema '{"type":"array","items":{"type":"string"}}'
39
101
 
40
- - **General-purpose**: Handles any task - research, writing, coding, automation, and more
41
- - **Terminal-first**: Fast, keyboard-driven interface with an Ink-based TUI
42
- - **Connector-powered**: Integrates with services via `connect-*` CLIs (Notion, Google Drive, Gmail, Linear, Slack, etc.)
43
- - **Skills**: Reusable instructions with `SKILL.md` files for domain-specific workflows
44
- - **Hooks**: Event-driven automation for custom behaviors
45
- - **Memory**: Persistent context across sessions for continuity
46
- - **Multi-session**: Work on multiple tasks simultaneously
47
- - **Identity management**: Switch between personas and contexts
102
+ # Continue a previous conversation
103
+ assistants -p "What else can you tell me?" --continue
104
+
105
+ # Resume a specific session
106
+ assistants -p "Continue from where we left off" --resume abc123
107
+ ```
108
+
109
+ ## Interactive Mode
110
+
111
+ ### Keyboard Shortcuts
112
+
113
+ | Key | Action |
114
+ |-----|--------|
115
+ | `Enter` | Send message |
116
+ | `Ctrl+C` | Stop current operation or exit |
117
+ | `Ctrl+]` | Switch sessions |
118
+ | `Up/Down` | Navigate command history |
119
+ | `Tab` | Autocomplete commands |
120
+
121
+ ### Slash Commands
122
+
123
+ | Command | Description |
124
+ |---------|-------------|
125
+ | `/help` | Show available commands |
126
+ | `/exit` | Exit the assistant |
127
+ | `/new` | Start a new session |
128
+ | `/clear` | Clear the screen |
129
+ | `/session` | Show current session info |
130
+ | `/tokens` | Show token usage |
131
+ | `/context` | Show/manage context window |
132
+ | `/cost` | Show estimated cost |
133
+ | `/status` | Show system status |
134
+ | `/model` | Show/change model settings |
135
+ | `/config` | Show/edit configuration |
136
+ | `/init` | Initialize project settings |
137
+
138
+ ### Project & Plan Commands
139
+
140
+ | Command | Description |
141
+ |---------|-------------|
142
+ | `/projects` | List and manage projects |
143
+ | `/plans` | View and manage plans |
144
+ | `/summarize` | Summarize the conversation |
145
+ | `/compact` | Compact context to save tokens |
146
+
147
+ ### Scheduling Commands
148
+
149
+ | Command | Description |
150
+ |---------|-------------|
151
+ | `/schedule` | Create a scheduled task |
152
+ | `/schedules` | List scheduled tasks |
153
+ | `/unschedule` | Remove a scheduled task |
154
+ | `/pause` | Pause a schedule |
155
+ | `/resume` | Resume a paused schedule |
156
+
157
+ ### Skills & Connectors
158
+
159
+ | Command | Description |
160
+ |---------|-------------|
161
+ | `/skills` | List available skills |
162
+ | `/skill <name>` | Execute a skill |
163
+ | `/connectors` | List available connectors |
164
+
165
+ ### Advanced Commands
166
+
167
+ | Command | Description |
168
+ |---------|-------------|
169
+ | `/voice` | Toggle voice mode |
170
+ | `/say <text>` | Speak text aloud |
171
+ | `/listen` | Listen for voice input |
172
+ | `/identity` | Manage agent identity |
173
+ | `/whoami` | Show current identity |
174
+ | `/assistant` | Configure assistant settings |
175
+ | `/inbox` | Check email inbox |
176
+ | `/wallet` | Manage crypto wallet |
177
+ | `/secrets` | Manage secrets |
178
+ | `/jobs` | View background jobs |
179
+ | `/messages` | Agent-to-agent messages |
180
+ | `/verification` | Manage verification sessions |
181
+ | `/memory` | View memory usage |
182
+ | `/rest` | Enter rest mode |
183
+ | `/feedback` | Submit feedback |
184
+ | `/security-log` | View security events |
48
185
 
49
186
  ## Configuration
50
187
 
51
- User config: `~/.assistants/config.json`
52
- Project config: `.assistants/config.json`
188
+ ### Directory Structure
189
+
190
+ ```
191
+ ~/.assistants/
192
+ ├── config.json # Global configuration
193
+ ├── sessions/ # Session history
194
+ ├── skills/ # Custom skills
195
+ ├── hooks.json # Global hooks
196
+ └── schedules/ # Scheduled tasks
197
+
198
+ .assistants/ # Project-level (in any directory)
199
+ ├── config.json # Project configuration
200
+ ├── skills/ # Project-specific skills
201
+ └── hooks.json # Project-specific hooks
202
+ ```
203
+
204
+ ### Configuration File
205
+
206
+ Create `~/.assistants/config.json`:
207
+
208
+ ```json
209
+ {
210
+ "model": "claude-sonnet-4-20250514",
211
+ "temperature": 0.7,
212
+ "maxTokens": 8192,
213
+ "connectors": ["notion", "googledrive"],
214
+ "voice": {
215
+ "tts": "elevenlabs",
216
+ "stt": "whisper"
217
+ }
218
+ }
219
+ ```
220
+
221
+ ### Project Configuration
222
+
223
+ Create `.assistants/config.json` in your project:
53
224
 
54
225
  ```json
55
226
  {
56
- "llm": {
57
- "provider": "anthropic",
58
- "model": "claude-opus-4-5"
59
- },
60
- "connectors": ["notion", "googledrive", "gmail", "linear", "slack"]
227
+ "name": "My Project",
228
+ "description": "Project description",
229
+ "systemPrompt": "You are helping with a Node.js backend project.",
230
+ "context": [
231
+ "src/README.md",
232
+ "docs/architecture.md"
233
+ ]
61
234
  }
62
235
  ```
63
236
 
237
+ ## Environment Variables
238
+
239
+ | Variable | Required | Description |
240
+ |----------|----------|-------------|
241
+ | `ANTHROPIC_API_KEY` | Yes | Claude API access |
242
+ | `ELEVENLABS_API_KEY` | No | ElevenLabs TTS |
243
+ | `OPENAI_API_KEY` | No | Whisper STT |
244
+ | `EXA_API_KEY` | No | Enhanced web search |
245
+ | `AWS_ACCESS_KEY_ID` | No | AWS features |
246
+ | `AWS_SECRET_ACCESS_KEY` | No | AWS features |
247
+ | `AWS_REGION` | No | AWS region |
248
+ | `ASSISTANTS_NO_SYNC` | No | Disable synchronized output (set to `1`) |
249
+
64
250
  ## Skills
65
251
 
66
- Skills are `SKILL.md` files with YAML frontmatter:
252
+ Skills are reusable prompts defined in `SKILL.md` files:
67
253
 
68
- ```yaml
254
+ ```markdown
69
255
  ---
70
- name: daily-standup
71
- description: Generate daily standup
72
- allowed-tools: bash, googlecalendar, linear
256
+ name: code-review
257
+ description: Review code for issues and improvements
258
+ argument-hint: <file-path>
259
+ allowed-tools: Read, Grep
73
260
  ---
74
261
 
75
- Generate a daily standup report for $ARGUMENTS
262
+ ## Instructions
263
+
264
+ Review the code at $ARGUMENTS and provide feedback on:
265
+ 1. Potential bugs
266
+ 2. Performance issues
267
+ 3. Code style
268
+ 4. Security concerns
269
+ ```
270
+
271
+ Place in `~/.assistants/skills/code-review/SKILL.md` or `.assistants/skills/code-review/SKILL.md`.
272
+
273
+ Use with `/skill code-review src/auth.ts` or `$code-review src/auth.ts`.
274
+
275
+ ## Hooks
276
+
277
+ Hooks allow you to run scripts before/after tool execution:
278
+
279
+ ```json
280
+ {
281
+ "hooks": {
282
+ "PreToolUse": [
283
+ {
284
+ "matcher": "Bash",
285
+ "hooks": [
286
+ {
287
+ "type": "command",
288
+ "command": "./scripts/validate-command.sh"
289
+ }
290
+ ]
291
+ }
292
+ ],
293
+ "PostToolUse": [
294
+ {
295
+ "matcher": "Edit",
296
+ "hooks": [
297
+ {
298
+ "type": "command",
299
+ "command": "./scripts/on-file-change.sh"
300
+ }
301
+ ]
302
+ }
303
+ ]
304
+ }
305
+ }
76
306
  ```
77
307
 
78
- Invoke with `/skill-name`.
308
+ ## Programmatic Usage
79
309
 
80
- ## Documentation
310
+ ### EmbeddedClient (Full Control)
311
+
312
+ ```typescript
313
+ import { EmbeddedClient } from '@hasna/assistants-terminal';
314
+
315
+ // Create client with working directory
316
+ const client = new EmbeddedClient(process.cwd(), {
317
+ systemPrompt: 'You are a helpful coding assistant.',
318
+ allowedTools: ['Read', 'Write', 'Edit', 'Bash'],
319
+ });
320
+
321
+ // Handle streaming chunks
322
+ client.onChunk((chunk) => {
323
+ if (chunk.type === 'text' && chunk.content) {
324
+ process.stdout.write(chunk.content);
325
+ }
326
+ });
327
+
328
+ // Initialize and send a message
329
+ await client.initialize();
330
+ await client.send('What files are in this directory?');
331
+
332
+ // Get session info
333
+ console.log('Session ID:', client.getSessionId());
334
+ console.log('Token usage:', client.getTokenUsage());
335
+
336
+ // Cleanup
337
+ client.disconnect();
338
+ ```
339
+
340
+ ### Headless Mode (Simple Queries)
341
+
342
+ ```typescript
343
+ import { runHeadless } from '@hasna/assistants-terminal';
344
+
345
+ // Run a simple query with JSON output
346
+ await runHeadless({
347
+ prompt: 'Summarize this project in 3 bullet points',
348
+ cwd: process.cwd(),
349
+ outputFormat: 'json',
350
+ });
351
+
352
+ // Stream JSON events
353
+ await runHeadless({
354
+ prompt: 'Explain the authentication system',
355
+ cwd: process.cwd(),
356
+ outputFormat: 'stream-json',
357
+ });
358
+
359
+ // Auto-approve tools
360
+ await runHeadless({
361
+ prompt: 'Fix the bug in auth.ts',
362
+ cwd: process.cwd(),
363
+ outputFormat: 'text',
364
+ allowedTools: ['Read', 'Edit'],
365
+ });
366
+ ```
81
367
 
82
- - [Admin Dashboard](./docs/ADMIN.md) - User management, audit logging, and system monitoring
368
+ ### Feature Detection
369
+
370
+ ```typescript
371
+ import { getFeatureAvailability, getFeatureStatusMessage } from '@hasna/assistants-terminal';
372
+
373
+ // Check what features are available
374
+ const features = getFeatureAvailability();
375
+ console.log('Core chat:', features.coreChat); // true if ANTHROPIC_API_KEY set
376
+ console.log('AWS features:', features.awsFeatures); // true if AWS configured
377
+
378
+ // Get human-readable status
379
+ console.log(getFeatureStatusMessage());
380
+ ```
381
+
382
+ ## Connectors
383
+
384
+ Connectors integrate external services. Install separately:
385
+
386
+ ```bash
387
+ # Example: Notion connector
388
+ bun install -g @hasna/connect-notion
389
+
390
+ # List available connectors
391
+ assistants
392
+ /connectors
393
+ ```
394
+
395
+ ## Troubleshooting
396
+
397
+ ### "ANTHROPIC_API_KEY not set"
398
+
399
+ Set your API key:
400
+ ```bash
401
+ export ANTHROPIC_API_KEY="sk-ant-..."
402
+ ```
403
+
404
+ ### Terminal rendering issues
405
+
406
+ Try disabling synchronized output:
407
+ ```bash
408
+ ASSISTANTS_NO_SYNC=1 assistants
409
+ ```
410
+
411
+ ### Slow startup
412
+
413
+ The first run may take longer as dependencies are cached. Subsequent runs will be faster.
414
+
415
+ ### Session not found
416
+
417
+ Sessions are stored in `~/.assistants/sessions/`. Use `/session` to see current session info.
83
418
 
84
419
  ## License
85
420
 
86
421
  MIT
422
+
423
+ ## See Also
424
+
425
+ - [FEATURES.md](./FEATURES.md) - Detailed feature documentation
426
+ - [Anthropic API Documentation](https://docs.anthropic.com/)
427
+ - [Bun Documentation](https://bun.sh/docs)