@hasna/assistants 1.0.0 → 1.0.3

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 (5) hide show
  1. package/README.md +128 -35
  2. package/dist/cli.js +106979 -83303
  3. package/dist/lib.d.ts +198 -24
  4. package/dist/lib.js +50290 -35956
  5. package/package.json +4 -4
package/README.md CHANGED
@@ -1,20 +1,25 @@
1
- # @hasna/assistants-terminal
1
+ # @hasna/assistants
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
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).
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.
6
8
 
7
9
  ## Features
8
10
 
11
+ - General-purpose assistant for any task
9
12
  - Interactive chat with Claude AI
10
13
  - Execute bash commands with approval
11
14
  - Read, write, and edit files
12
15
  - Fetch and search web content
13
- - Custom skills and hooks
16
+ - Custom skills and hooks for domain-specific workflows
14
17
  - Project and plan management
18
+ - Memory and context persistence across sessions
15
19
  - Session history and resumption
20
+ - Identity management for different contexts
16
21
  - Voice input/output (optional)
17
- - Connectors for external services
22
+ - Connectors for external services (Notion, Gmail, Linear, etc.)
18
23
 
19
24
  ## Installation
20
25
 
@@ -26,13 +31,13 @@ A powerful AI assistant that runs in your terminal. Built with [Ink](https://git
26
31
  ### Install globally
27
32
 
28
33
  ```bash
29
- bun install -g @hasna/assistants-terminal
34
+ bun add -g @hasna/assistants
30
35
  ```
31
36
 
32
37
  ### Or run directly
33
38
 
34
39
  ```bash
35
- bunx @hasna/assistants-terminal
40
+ bunx @hasna/assistants
36
41
  ```
37
42
 
38
43
  ## Quick Start
@@ -162,6 +167,17 @@ assistants -p "Continue from where we left off" --resume abc123
162
167
  | `/skill <name>` | Execute a skill |
163
168
  | `/connectors` | List available connectors |
164
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
+
165
181
  ### Advanced Commands
166
182
 
167
183
  | Command | Description |
@@ -274,43 +290,120 @@ Use with `/skill code-review src/auth.ts` or `$code-review src/auth.ts`.
274
290
 
275
291
  ## Hooks
276
292
 
277
- Hooks allow you to run scripts before/after tool execution:
293
+ Hooks intercept agent behavior at key lifecycle points. Use them to validate inputs, block dangerous actions, log activity, or inject context.
294
+
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:
278
330
 
279
331
  ```json
280
332
  {
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
- }
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
+ ]
305
361
  }
306
362
  ```
307
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
+
308
401
  ## Programmatic Usage
309
402
 
310
403
  ### EmbeddedClient (Full Control)
311
404
 
312
405
  ```typescript
313
- import { EmbeddedClient } from '@hasna/assistants-terminal';
406
+ import { EmbeddedClient } from '@hasna/assistants';
314
407
 
315
408
  // Create client with working directory
316
409
  const client = new EmbeddedClient(process.cwd(), {
@@ -340,7 +433,7 @@ client.disconnect();
340
433
  ### Headless Mode (Simple Queries)
341
434
 
342
435
  ```typescript
343
- import { runHeadless } from '@hasna/assistants-terminal';
436
+ import { runHeadless } from '@hasna/assistants';
344
437
 
345
438
  // Run a simple query with JSON output
346
439
  await runHeadless({
@@ -368,7 +461,7 @@ await runHeadless({
368
461
  ### Feature Detection
369
462
 
370
463
  ```typescript
371
- import { getFeatureAvailability, getFeatureStatusMessage } from '@hasna/assistants-terminal';
464
+ import { getFeatureAvailability, getFeatureStatusMessage } from '@hasna/assistants';
372
465
 
373
466
  // Check what features are available
374
467
  const features = getFeatureAvailability();
@@ -385,7 +478,7 @@ Connectors integrate external services. Install separately:
385
478
 
386
479
  ```bash
387
480
  # Example: Notion connector
388
- bun install -g @hasna/connect-notion
481
+ bun add -g @hasna/connect-notion
389
482
 
390
483
  # List available connectors
391
484
  assistants