omnara 0.1.10 → 0.2.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.
- package/bin/omnara.js +2 -2
- package/dist/auth/auth-provider.d.ts +9 -2
- package/dist/auth/cli-auth-service.d.ts +0 -1
- package/dist/auth/credential-manager.d.ts +10 -1
- package/dist/auth/credentials-store.d.ts +4 -1
- package/dist/auth/ensure-cli-credentials.d.ts +13 -0
- package/dist/cli.js +5132 -1478
- package/dist/cli.js.map +4 -4
- package/dist/commands/agent.d.ts +3 -2
- package/dist/commands/daemon.d.ts +2 -0
- package/dist/commands/index.d.ts +2 -1
- package/dist/config/omnara-config.d.ts +2 -17
- package/dist/daemon/config-store.d.ts +37 -0
- package/dist/daemon/daemon-client.d.ts +26 -0
- package/dist/daemon/daemon-launcher.d.ts +30 -0
- package/dist/daemon/daemon-service.d.ts +30 -0
- package/dist/daemon/directory-registry.d.ts +17 -0
- package/dist/daemon/file-logger.d.ts +24 -0
- package/dist/daemon/local-control-server.d.ts +37 -0
- package/dist/daemon/machine-supervisor.d.ts +60 -0
- package/dist/daemon/paths.d.ts +9 -0
- package/dist/daemon/run-daemon.d.ts +1 -0
- package/dist/daemon/session-log-manager.d.ts +10 -0
- package/dist/daemon/session-pid-registry.d.ts +5 -0
- package/dist/daemon/session-runner.d.ts +28 -0
- package/dist/daemon/state-store.d.ts +14 -0
- package/dist/http/machines.d.ts +3 -0
- package/dist/http/user-sessions.d.ts +5 -2
- package/dist/http/workspaces.d.ts +4 -0
- package/dist/orchestrator/agent-orchestrator.d.ts +7 -1
- package/dist/orchestrator/ai-client.d.ts +3 -0
- package/dist/orchestrator/orchestrator-prompt.md +171 -43
- package/dist/orchestrator/utils/completions-manager.d.ts +8 -0
- package/dist/orchestrator/utils/worktree-manager.d.ts +30 -1
- package/dist/orchestrator/worker-manager.d.ts +9 -4
- package/dist/orchestrator-prompt.md +171 -43
- package/dist/package-info.d.ts +3 -0
- package/dist/relay/relay-bridge.d.ts +12 -0
- package/dist/schemas/index.d.ts +2 -2
- package/dist/utils/claude-code-check.d.ts +1 -20
- package/dist/utils/version-check.d.ts +1 -5
- package/package.json +6 -4
- package/scripts/copy-assets.mjs +41 -0
- package/dist/repl/terminal-repl.d.ts +0 -9
- package/dist/voice/voice-service.d.ts +0 -19
|
@@ -342,86 +342,214 @@ Response:
|
|
|
342
342
|
|
|
343
343
|
Workers can optionally operate in ISOLATED git worktrees, providing complete isolation from the main repository and from other workers. You control this via the `worktree_name` parameter when launching a worker.
|
|
344
344
|
|
|
345
|
+
### Understanding Worktrees and Branches
|
|
346
|
+
|
|
347
|
+
**CRITICAL: worktree_name IS the branch name** - These terms are synonymous in this system. When you specify `worktree_name="feature-auth"`, you're specifying both the worktree directory name AND the branch name.
|
|
348
|
+
|
|
349
|
+
**How Worktree Creation Works:**
|
|
350
|
+
|
|
351
|
+
When you launch a worker with `worktree_name="my-feature"`, the system behaves as follows:
|
|
352
|
+
|
|
353
|
+
1. **Neither worktree nor branch exists** (new feature):
|
|
354
|
+
- Creates new worktree at `.omnara/worktrees/<repo-name>/my-feature`
|
|
355
|
+
- Creates new branch `my-feature` branching off from main
|
|
356
|
+
- Worker operates in fresh isolated environment
|
|
357
|
+
|
|
358
|
+
2. **Branch exists but worktree doesn't** (resuming work):
|
|
359
|
+
- Creates new worktree at `.omnara/worktrees/<repo-name>/my-feature`
|
|
360
|
+
- Mounts existing branch `my-feature` in that worktree
|
|
361
|
+
- Worker picks up where previous work left off
|
|
362
|
+
|
|
363
|
+
3. **Both worktree and branch exist** (continuing work):
|
|
364
|
+
- Reuses existing worktree at `.omnara/worktrees/<repo-name>/my-feature`
|
|
365
|
+
- Worker operates in existing environment on existing branch
|
|
366
|
+
- Multiple workers can work here simultaneously
|
|
367
|
+
|
|
368
|
+
**Key Insight: Shared State**
|
|
369
|
+
- Multiple workers with the SAME `worktree_name` work in the SAME worktree
|
|
370
|
+
- They share the same file system state and can see each other's changes
|
|
371
|
+
- They share the same git branch and staging area
|
|
372
|
+
- This enables collaborative work or sequential tasks in shared context
|
|
373
|
+
|
|
345
374
|
**Controlling Worktree Isolation:**
|
|
346
|
-
- Set `worktree_name` when calling `launch_worker` to specify the worktree
|
|
347
|
-
- Each
|
|
348
|
-
- Multiple workers can share the same worktree context or have separate ones
|
|
375
|
+
- Set `worktree_name` when calling `launch_worker` to specify the worktree/branch
|
|
376
|
+
- Each unique worktree_name provides a completely isolated file system and git state
|
|
349
377
|
- If not specified, the worker operates in the main repository
|
|
350
378
|
|
|
351
379
|
**What Isolated Workers Get:**
|
|
352
|
-
- **Dedicated working directory** - Separate file system view in `.omnara/worktrees
|
|
353
|
-
- **Dedicated git branch** -
|
|
354
|
-
- **Independent git state** - Separate staging area,
|
|
380
|
+
- **Dedicated working directory** - Separate file system view in `.omnara/worktrees/<repo-name>/<worktree_name>/`
|
|
381
|
+
- **Dedicated git branch** - Branch with same name as worktree_name
|
|
382
|
+
- **Independent git state** - Separate staging area, independent commits, isolated from main
|
|
355
383
|
|
|
356
384
|
**Key Benefits:**
|
|
357
385
|
1. **No Conflicts**: Workers in different worktrees can edit the same files simultaneously without interfering
|
|
358
386
|
2. **Safe Operations**: Workers can stage, commit, and manipulate git state independently
|
|
359
387
|
3. **Clean Isolation**: Main repository remains untouched until worker results are reviewed and merged
|
|
360
|
-
4. **Controlled Sharing**: Workers with the same worktree_name share
|
|
388
|
+
4. **Controlled Sharing**: Workers with the same worktree_name share file state and can collaborate
|
|
389
|
+
5. **Resumable Work**: Launch new workers in existing worktrees to continue previous work
|
|
361
390
|
|
|
362
|
-
|
|
363
|
-
- Use worktree isolation when workers need to modify the same files independently
|
|
364
|
-
- Workers in the same worktree_name share the same isolated environment
|
|
365
|
-
- Workers in different worktree contexts are completely isolated from each other
|
|
366
|
-
- Review worker branches before merging changes to main
|
|
367
|
-
- Trust the isolation - workers in different worktrees truly cannot interfere with each other
|
|
391
|
+
### Decision Framework: When to Use Which Pattern
|
|
368
392
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
393
|
+
Use this framework to decide how to structure worker delegation:
|
|
394
|
+
|
|
395
|
+
**Pattern 1: Same Worktree, Parallel Workers**
|
|
396
|
+
```
|
|
397
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
398
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
399
|
+
```
|
|
400
|
+
**When to use:**
|
|
401
|
+
- Work needs to be on the same branch/feature
|
|
402
|
+
- Tasks can be parallelized (don't strictly depend on each other)
|
|
403
|
+
- Workers benefit from seeing each other's changes
|
|
404
|
+
- Example: "Add login endpoint AND add logout endpoint to the auth feature"
|
|
373
405
|
|
|
374
|
-
**
|
|
406
|
+
**Pattern 2: Different Worktrees, Parallel Workers**
|
|
407
|
+
```
|
|
408
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
409
|
+
launch_worker(worktree_name="feature-y", ...)
|
|
410
|
+
```
|
|
411
|
+
**When to use:**
|
|
412
|
+
- Work is logically distinct (different features/bugs)
|
|
413
|
+
- Tasks can be parallelized
|
|
414
|
+
- Changes should be reviewed separately
|
|
415
|
+
- Example: "Fix bug in auth system AND add new logging feature"
|
|
375
416
|
|
|
376
|
-
**
|
|
417
|
+
**Pattern 3: Sequential, Message Existing Worker**
|
|
377
418
|
```
|
|
378
|
-
|
|
419
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
420
|
+
[worker completes]
|
|
421
|
+
message_worker(worker_id, "Now do the next step...")
|
|
422
|
+
```
|
|
423
|
+
**When to use:**
|
|
424
|
+
- Work must be sequential (second task needs first task's results)
|
|
425
|
+
- Context from previous task is valuable for next task
|
|
426
|
+
- Same logical piece of work with multiple steps
|
|
427
|
+
- Example: "Research best auth library, THEN implement the recommended one"
|
|
428
|
+
|
|
429
|
+
**Pattern 4: Sequential, Same Worktree**
|
|
430
|
+
```
|
|
431
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
432
|
+
[worker completes]
|
|
433
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
434
|
+
```
|
|
435
|
+
**When to use:**
|
|
436
|
+
- Work must be sequential (second task needs first task's files)
|
|
437
|
+
- Context from previous task is NOT needed (fresh perspective is better)
|
|
438
|
+
- Continuing work on same feature/branch with new instructions
|
|
439
|
+
- Example: "Implement auth endpoints" [completes] "Now add tests for auth endpoints"
|
|
440
|
+
|
|
441
|
+
### Practical Examples
|
|
442
|
+
|
|
443
|
+
**Example 1: Same Worktree, Parallel Workers**
|
|
444
|
+
```
|
|
445
|
+
User: "Add login and logout endpoints to the auth API"
|
|
446
|
+
|
|
447
|
+
Response:
|
|
448
|
+
- Launch worker 1 with worktree_name="auth-endpoints": "Add login endpoint to auth API"
|
|
449
|
+
- Launch worker 2 with worktree_name="auth-endpoints": "Add logout endpoint to auth API"
|
|
450
|
+
|
|
451
|
+
Why: Both part of same feature, can work in parallel, benefit from shared context
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Example 2: Different Worktrees, Parallel Workers**
|
|
455
|
+
```
|
|
456
|
+
User: "Fix the login bug and also add rate limiting feature"
|
|
379
457
|
|
|
380
458
|
Response:
|
|
381
|
-
- Launch worker 1 with worktree_name="
|
|
382
|
-
- Launch worker 2 with worktree_name="
|
|
383
|
-
|
|
459
|
+
- Launch worker 1 with worktree_name="fix-login-bug": "Fix login authentication bug"
|
|
460
|
+
- Launch worker 2 with worktree_name="add-rate-limiting": "Implement rate limiting middleware"
|
|
461
|
+
|
|
462
|
+
Why: Logically distinct work, different branches, separate PRs/reviews
|
|
384
463
|
```
|
|
385
464
|
|
|
386
|
-
**Example
|
|
465
|
+
**Example 3: Sequential, Message Existing Worker**
|
|
387
466
|
```
|
|
388
|
-
User: "
|
|
467
|
+
User: "Research the best authentication library, then implement it"
|
|
389
468
|
|
|
390
469
|
Response:
|
|
391
|
-
- Launch worker 1 with worktree_name="auth-
|
|
392
|
-
|
|
393
|
-
|
|
470
|
+
- Launch worker 1 with worktree_name="auth-research": "Research Node.js authentication libraries"
|
|
471
|
+
[Worker completes with recommendation: use Passport.js]
|
|
472
|
+
- Message worker 1: "Great research. Now implement Passport.js based on your findings"
|
|
473
|
+
|
|
474
|
+
Why: Implementation needs research context, benefits from same worker's knowledge
|
|
394
475
|
```
|
|
395
476
|
|
|
396
|
-
**Example
|
|
477
|
+
**Example 4: Sequential, Same Worktree**
|
|
397
478
|
```
|
|
398
|
-
User: "
|
|
479
|
+
User: "Implement the authentication endpoints"
|
|
480
|
+
|
|
481
|
+
Response:
|
|
482
|
+
- Launch worker 1 with worktree_name="auth-impl": "Implement authentication endpoints"
|
|
483
|
+
[Worker completes implementation]
|
|
484
|
+
User: "Now add tests for those endpoints"
|
|
485
|
+
- Launch worker 2 with worktree_name="auth-impl": "Add tests for authentication endpoints"
|
|
486
|
+
|
|
487
|
+
Why: Tests need the implementation files, but fresh perspective is fine, same branch
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
**Example 5: Parallel Edits to Same File (Different Worktrees)**
|
|
491
|
+
```
|
|
492
|
+
User: "Add error handling to login.ts and also add logging to the same file"
|
|
399
493
|
|
|
400
494
|
Response:
|
|
401
|
-
- Launch worker 1
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
495
|
+
- Launch worker 1 with worktree_name="add-error-handling": "Add error handling to login.ts"
|
|
496
|
+
- Launch worker 2 with worktree_name="add-logging": "Add logging to login.ts"
|
|
497
|
+
|
|
498
|
+
Why: Different features, will be reviewed/merged separately, avoid conflicts during dev
|
|
405
499
|
```
|
|
406
500
|
|
|
407
|
-
**Example
|
|
501
|
+
**Example 6: Mixed - No Worktree for Quick Fixes**
|
|
408
502
|
```
|
|
409
|
-
User: "
|
|
503
|
+
User: "Fix typo in README and experiment with new WebSocket feature"
|
|
410
504
|
|
|
411
505
|
Response:
|
|
412
|
-
- Launch worker 1 (no worktree_name): "
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
✓ Implementation isolated in worktree for safe experimentation
|
|
506
|
+
- Launch worker 1 (no worktree_name): "Fix typo in README.md"
|
|
507
|
+
- Launch worker 2 with worktree_name="websocket-experiment": "Experiment with WebSocket implementation"
|
|
508
|
+
|
|
509
|
+
Why: Typo fix is trivial (main repo is fine), experiment needs isolation
|
|
417
510
|
```
|
|
418
511
|
|
|
512
|
+
### Best Practices
|
|
513
|
+
|
|
514
|
+
**Worktree Naming:**
|
|
515
|
+
- Use descriptive, semantic names: "auth-feature", "fix-login-bug", "refactor-db"
|
|
516
|
+
- Names become branch names, so follow branch naming conventions
|
|
517
|
+
- Keep names concise but meaningful
|
|
518
|
+
|
|
519
|
+
**Isolation Strategy:**
|
|
520
|
+
- Default: Use worktrees for most code changes (keeps main repo clean)
|
|
521
|
+
- Use same worktree_name when workers should share context
|
|
522
|
+
- Use different worktree_names when changes should be independent
|
|
523
|
+
- Skip worktrees for trivial changes (typos, docs) or pure research tasks
|
|
524
|
+
|
|
525
|
+
**Cleanup:**
|
|
526
|
+
- Worktrees are automatically cleaned up when workers complete
|
|
527
|
+
- Branches persist after cleanup (can be resumed or merged later)
|
|
528
|
+
- Review and merge branches through normal git workflow
|
|
529
|
+
|
|
530
|
+
**Worker Launch Information:**
|
|
531
|
+
When you launch a worker with worktree isolation, you'll receive:
|
|
532
|
+
- `worktree_path`: Location of the worker's isolated directory
|
|
533
|
+
- `branch_name`: Name of the worktree's dedicated branch (same as worktree_name)
|
|
534
|
+
|
|
419
535
|
## Worker Status Tracking
|
|
420
536
|
|
|
421
|
-
**Status
|
|
422
|
-
|
|
537
|
+
**Understanding Status Update Messages**:
|
|
538
|
+
|
|
539
|
+
When workers complete, a special automated notification is added to the conversation. These messages are clearly formatted as system notifications, NOT user input:
|
|
540
|
+
- They start and end with clear visual separators: `═══════════════════════════════════════════════════════════════`
|
|
541
|
+
- They are labeled as `[AUTOMATED SYSTEM NOTIFICATION: WORKER STATUS UPDATE]`
|
|
542
|
+
- They contain instructions for you: "This is an automated notification triggered by a worker completion."
|
|
543
|
+
- They are generated by the orchestration system, not by the user
|
|
544
|
+
- They provide structured information about worker states and progress
|
|
545
|
+
- They trigger you to generate a response (see "How You Get Triggered" section)
|
|
546
|
+
- Users do NOT see these raw status messages (they're internal to orchestration)
|
|
547
|
+
|
|
548
|
+
**What Status Update Messages Contain:**
|
|
549
|
+
- ALL current worker statuses (running, completed, errored, cancelled)
|
|
423
550
|
- Which worker just completed (marked with >>> and "JUST COMPLETED" note)
|
|
424
551
|
- Which workers are still running
|
|
552
|
+
- **Worktree information** - Including worktree_name and branch_name for each worker
|
|
425
553
|
- **FULL PROGRESS LOG** for completed workers - showing everything the worker did
|
|
426
554
|
|
|
427
555
|
**CRITICAL: Read the Full Progress Log**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ControlMessageSchema } from '@omnara/shared-js/schemas';
|
|
2
|
+
export declare class CompletionsManager {
|
|
3
|
+
private slashCommandsCache?;
|
|
4
|
+
private filesCache;
|
|
5
|
+
fetchSlashCommands(): Promise<string[]>;
|
|
6
|
+
fetchFiles(searchPattern?: string): Promise<string[]>;
|
|
7
|
+
getCompletion(query: string, limit?: number): Promise<ControlMessageSchema.CompletionItem[]>;
|
|
8
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SimpleGit } from 'simple-git';
|
|
1
2
|
/**
|
|
2
3
|
* Configuration options for WorktreeManager
|
|
3
4
|
*/
|
|
@@ -14,6 +15,10 @@ export interface WorktreeManagerOptions {
|
|
|
14
15
|
* Whether worktrees are enabled (default: false)
|
|
15
16
|
*/
|
|
16
17
|
enabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Base ref to use when creating new branches (optional)
|
|
20
|
+
*/
|
|
21
|
+
base_ref?: string;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* Information about a created worktree
|
|
@@ -65,12 +70,22 @@ export declare class WorktreeError extends Error {
|
|
|
65
70
|
* ```
|
|
66
71
|
*/
|
|
67
72
|
export declare class WorktreeManager {
|
|
68
|
-
|
|
73
|
+
readonly git: SimpleGit;
|
|
69
74
|
private readonly repoPath;
|
|
70
75
|
private readonly worktreeBasePath;
|
|
71
76
|
private readonly activeWorktrees;
|
|
72
77
|
private readonly enabled;
|
|
78
|
+
private readonly base_ref?;
|
|
79
|
+
private readonly creationQueue;
|
|
80
|
+
private isProcessingQueue;
|
|
81
|
+
private readonly worktreesByName;
|
|
73
82
|
constructor(options: WorktreeManagerOptions);
|
|
83
|
+
/**
|
|
84
|
+
* Find a valid base ref to use when creating new branches
|
|
85
|
+
* Tries in order: configured base_ref, main, master, origin/HEAD
|
|
86
|
+
* @returns The first valid ref found, or undefined if none exist
|
|
87
|
+
*/
|
|
88
|
+
findValidBaseRef(): Promise<string | undefined>;
|
|
74
89
|
/**
|
|
75
90
|
* Validate that the repoPath is a git repository
|
|
76
91
|
* Logs an error if worktrees are enabled but not in a git repository
|
|
@@ -83,12 +98,26 @@ export declare class WorktreeManager {
|
|
|
83
98
|
/**
|
|
84
99
|
* Creates a new worktree for the specified worker
|
|
85
100
|
*
|
|
101
|
+
* This method uses a sequential queue to ensure that worktree creation
|
|
102
|
+
* happens one at a time, eliminating race conditions when multiple workers
|
|
103
|
+
* request the same worktree simultaneously.
|
|
104
|
+
*
|
|
86
105
|
* @param workerId - Unique identifier for the worker
|
|
87
106
|
* @param worktreeName - Semantic name for the worktree (e.g., "main-feature", "bugfix-auth")
|
|
88
107
|
* @returns Information about the created worktree
|
|
89
108
|
* @throws {WorktreeError} If worktree creation fails
|
|
90
109
|
*/
|
|
91
110
|
createWorktree(workerId: string, worktreeName: string): Promise<WorktreeInfo>;
|
|
111
|
+
/**
|
|
112
|
+
* Processes the creation queue sequentially
|
|
113
|
+
* Ensures only one worktree creation happens at a time
|
|
114
|
+
*/
|
|
115
|
+
private processCreationQueue;
|
|
116
|
+
/**
|
|
117
|
+
* Internal method that performs the actual worktree creation
|
|
118
|
+
* This should only be called by processCreationQueue
|
|
119
|
+
*/
|
|
120
|
+
private doCreateWorktree;
|
|
92
121
|
/**
|
|
93
122
|
* Removes a worktree for the specified worker
|
|
94
123
|
*
|
|
@@ -2,6 +2,7 @@ import { EventEmitter } from 'events';
|
|
|
2
2
|
import type { SDKUserMessage, McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
|
|
3
3
|
import type { AgentClient } from './ai-client.js';
|
|
4
4
|
import { AsyncQueue } from './utils/async-queue.js';
|
|
5
|
+
import { WorktreeManager } from './utils/worktree-manager.js';
|
|
5
6
|
export type WorkerStatus = 'running' | 'completed' | 'error' | 'canceled';
|
|
6
7
|
export interface WorkerProgressEntry {
|
|
7
8
|
timestamp: number;
|
|
@@ -49,17 +50,16 @@ interface WorkerManagerOptions {
|
|
|
49
50
|
createClient: (mcpServers?: Record<string, McpServerConfig>, cwd?: string) => AgentClient;
|
|
50
51
|
resolveSessionIdBySdk?: (sdkSessionId?: string) => string | undefined;
|
|
51
52
|
repoPath: string;
|
|
53
|
+
worktreesEnabled: boolean;
|
|
54
|
+
worktreesBaseRef?: string;
|
|
52
55
|
}
|
|
53
56
|
export declare class WorkerManager extends EventEmitter {
|
|
54
57
|
private readonly options;
|
|
55
58
|
private readonly workers;
|
|
56
59
|
private readonly runningQueries;
|
|
57
60
|
private worktreeManager;
|
|
58
|
-
|
|
61
|
+
repoPath: string;
|
|
59
62
|
constructor(options: WorkerManagerOptions);
|
|
60
|
-
/**
|
|
61
|
-
* Initialize the configuration and update WorktreeManager accordingly
|
|
62
|
-
*/
|
|
63
63
|
private initializeConfig;
|
|
64
64
|
listWorkers(): WorkerRecord[];
|
|
65
65
|
getWorker(id: string): WorkerRecord | undefined;
|
|
@@ -102,5 +102,10 @@ export declare class WorkerManager extends EventEmitter {
|
|
|
102
102
|
* This should be called during application shutdown to ensure all worktrees are cleaned up
|
|
103
103
|
*/
|
|
104
104
|
shutdown(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Get the WorktreeManager instance
|
|
107
|
+
* @returns The WorktreeManager instance
|
|
108
|
+
*/
|
|
109
|
+
getWorktreeManager(): WorktreeManager;
|
|
105
110
|
}
|
|
106
111
|
export {};
|
|
@@ -342,86 +342,214 @@ Response:
|
|
|
342
342
|
|
|
343
343
|
Workers can optionally operate in ISOLATED git worktrees, providing complete isolation from the main repository and from other workers. You control this via the `worktree_name` parameter when launching a worker.
|
|
344
344
|
|
|
345
|
+
### Understanding Worktrees and Branches
|
|
346
|
+
|
|
347
|
+
**CRITICAL: worktree_name IS the branch name** - These terms are synonymous in this system. When you specify `worktree_name="feature-auth"`, you're specifying both the worktree directory name AND the branch name.
|
|
348
|
+
|
|
349
|
+
**How Worktree Creation Works:**
|
|
350
|
+
|
|
351
|
+
When you launch a worker with `worktree_name="my-feature"`, the system behaves as follows:
|
|
352
|
+
|
|
353
|
+
1. **Neither worktree nor branch exists** (new feature):
|
|
354
|
+
- Creates new worktree at `.omnara/worktrees/<repo-name>/my-feature`
|
|
355
|
+
- Creates new branch `my-feature` branching off from main
|
|
356
|
+
- Worker operates in fresh isolated environment
|
|
357
|
+
|
|
358
|
+
2. **Branch exists but worktree doesn't** (resuming work):
|
|
359
|
+
- Creates new worktree at `.omnara/worktrees/<repo-name>/my-feature`
|
|
360
|
+
- Mounts existing branch `my-feature` in that worktree
|
|
361
|
+
- Worker picks up where previous work left off
|
|
362
|
+
|
|
363
|
+
3. **Both worktree and branch exist** (continuing work):
|
|
364
|
+
- Reuses existing worktree at `.omnara/worktrees/<repo-name>/my-feature`
|
|
365
|
+
- Worker operates in existing environment on existing branch
|
|
366
|
+
- Multiple workers can work here simultaneously
|
|
367
|
+
|
|
368
|
+
**Key Insight: Shared State**
|
|
369
|
+
- Multiple workers with the SAME `worktree_name` work in the SAME worktree
|
|
370
|
+
- They share the same file system state and can see each other's changes
|
|
371
|
+
- They share the same git branch and staging area
|
|
372
|
+
- This enables collaborative work or sequential tasks in shared context
|
|
373
|
+
|
|
345
374
|
**Controlling Worktree Isolation:**
|
|
346
|
-
- Set `worktree_name` when calling `launch_worker` to specify the worktree
|
|
347
|
-
- Each
|
|
348
|
-
- Multiple workers can share the same worktree context or have separate ones
|
|
375
|
+
- Set `worktree_name` when calling `launch_worker` to specify the worktree/branch
|
|
376
|
+
- Each unique worktree_name provides a completely isolated file system and git state
|
|
349
377
|
- If not specified, the worker operates in the main repository
|
|
350
378
|
|
|
351
379
|
**What Isolated Workers Get:**
|
|
352
|
-
- **Dedicated working directory** - Separate file system view in `.omnara/worktrees
|
|
353
|
-
- **Dedicated git branch** -
|
|
354
|
-
- **Independent git state** - Separate staging area,
|
|
380
|
+
- **Dedicated working directory** - Separate file system view in `.omnara/worktrees/<repo-name>/<worktree_name>/`
|
|
381
|
+
- **Dedicated git branch** - Branch with same name as worktree_name
|
|
382
|
+
- **Independent git state** - Separate staging area, independent commits, isolated from main
|
|
355
383
|
|
|
356
384
|
**Key Benefits:**
|
|
357
385
|
1. **No Conflicts**: Workers in different worktrees can edit the same files simultaneously without interfering
|
|
358
386
|
2. **Safe Operations**: Workers can stage, commit, and manipulate git state independently
|
|
359
387
|
3. **Clean Isolation**: Main repository remains untouched until worker results are reviewed and merged
|
|
360
|
-
4. **Controlled Sharing**: Workers with the same worktree_name share
|
|
388
|
+
4. **Controlled Sharing**: Workers with the same worktree_name share file state and can collaborate
|
|
389
|
+
5. **Resumable Work**: Launch new workers in existing worktrees to continue previous work
|
|
361
390
|
|
|
362
|
-
|
|
363
|
-
- Use worktree isolation when workers need to modify the same files independently
|
|
364
|
-
- Workers in the same worktree_name share the same isolated environment
|
|
365
|
-
- Workers in different worktree contexts are completely isolated from each other
|
|
366
|
-
- Review worker branches before merging changes to main
|
|
367
|
-
- Trust the isolation - workers in different worktrees truly cannot interfere with each other
|
|
391
|
+
### Decision Framework: When to Use Which Pattern
|
|
368
392
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
393
|
+
Use this framework to decide how to structure worker delegation:
|
|
394
|
+
|
|
395
|
+
**Pattern 1: Same Worktree, Parallel Workers**
|
|
396
|
+
```
|
|
397
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
398
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
399
|
+
```
|
|
400
|
+
**When to use:**
|
|
401
|
+
- Work needs to be on the same branch/feature
|
|
402
|
+
- Tasks can be parallelized (don't strictly depend on each other)
|
|
403
|
+
- Workers benefit from seeing each other's changes
|
|
404
|
+
- Example: "Add login endpoint AND add logout endpoint to the auth feature"
|
|
373
405
|
|
|
374
|
-
**
|
|
406
|
+
**Pattern 2: Different Worktrees, Parallel Workers**
|
|
407
|
+
```
|
|
408
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
409
|
+
launch_worker(worktree_name="feature-y", ...)
|
|
410
|
+
```
|
|
411
|
+
**When to use:**
|
|
412
|
+
- Work is logically distinct (different features/bugs)
|
|
413
|
+
- Tasks can be parallelized
|
|
414
|
+
- Changes should be reviewed separately
|
|
415
|
+
- Example: "Fix bug in auth system AND add new logging feature"
|
|
375
416
|
|
|
376
|
-
**
|
|
417
|
+
**Pattern 3: Sequential, Message Existing Worker**
|
|
377
418
|
```
|
|
378
|
-
|
|
419
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
420
|
+
[worker completes]
|
|
421
|
+
message_worker(worker_id, "Now do the next step...")
|
|
422
|
+
```
|
|
423
|
+
**When to use:**
|
|
424
|
+
- Work must be sequential (second task needs first task's results)
|
|
425
|
+
- Context from previous task is valuable for next task
|
|
426
|
+
- Same logical piece of work with multiple steps
|
|
427
|
+
- Example: "Research best auth library, THEN implement the recommended one"
|
|
428
|
+
|
|
429
|
+
**Pattern 4: Sequential, Same Worktree**
|
|
430
|
+
```
|
|
431
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
432
|
+
[worker completes]
|
|
433
|
+
launch_worker(worktree_name="feature-x", ...)
|
|
434
|
+
```
|
|
435
|
+
**When to use:**
|
|
436
|
+
- Work must be sequential (second task needs first task's files)
|
|
437
|
+
- Context from previous task is NOT needed (fresh perspective is better)
|
|
438
|
+
- Continuing work on same feature/branch with new instructions
|
|
439
|
+
- Example: "Implement auth endpoints" [completes] "Now add tests for auth endpoints"
|
|
440
|
+
|
|
441
|
+
### Practical Examples
|
|
442
|
+
|
|
443
|
+
**Example 1: Same Worktree, Parallel Workers**
|
|
444
|
+
```
|
|
445
|
+
User: "Add login and logout endpoints to the auth API"
|
|
446
|
+
|
|
447
|
+
Response:
|
|
448
|
+
- Launch worker 1 with worktree_name="auth-endpoints": "Add login endpoint to auth API"
|
|
449
|
+
- Launch worker 2 with worktree_name="auth-endpoints": "Add logout endpoint to auth API"
|
|
450
|
+
|
|
451
|
+
Why: Both part of same feature, can work in parallel, benefit from shared context
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Example 2: Different Worktrees, Parallel Workers**
|
|
455
|
+
```
|
|
456
|
+
User: "Fix the login bug and also add rate limiting feature"
|
|
379
457
|
|
|
380
458
|
Response:
|
|
381
|
-
- Launch worker 1 with worktree_name="
|
|
382
|
-
- Launch worker 2 with worktree_name="
|
|
383
|
-
|
|
459
|
+
- Launch worker 1 with worktree_name="fix-login-bug": "Fix login authentication bug"
|
|
460
|
+
- Launch worker 2 with worktree_name="add-rate-limiting": "Implement rate limiting middleware"
|
|
461
|
+
|
|
462
|
+
Why: Logically distinct work, different branches, separate PRs/reviews
|
|
384
463
|
```
|
|
385
464
|
|
|
386
|
-
**Example
|
|
465
|
+
**Example 3: Sequential, Message Existing Worker**
|
|
387
466
|
```
|
|
388
|
-
User: "
|
|
467
|
+
User: "Research the best authentication library, then implement it"
|
|
389
468
|
|
|
390
469
|
Response:
|
|
391
|
-
- Launch worker 1 with worktree_name="auth-
|
|
392
|
-
|
|
393
|
-
|
|
470
|
+
- Launch worker 1 with worktree_name="auth-research": "Research Node.js authentication libraries"
|
|
471
|
+
[Worker completes with recommendation: use Passport.js]
|
|
472
|
+
- Message worker 1: "Great research. Now implement Passport.js based on your findings"
|
|
473
|
+
|
|
474
|
+
Why: Implementation needs research context, benefits from same worker's knowledge
|
|
394
475
|
```
|
|
395
476
|
|
|
396
|
-
**Example
|
|
477
|
+
**Example 4: Sequential, Same Worktree**
|
|
397
478
|
```
|
|
398
|
-
User: "
|
|
479
|
+
User: "Implement the authentication endpoints"
|
|
480
|
+
|
|
481
|
+
Response:
|
|
482
|
+
- Launch worker 1 with worktree_name="auth-impl": "Implement authentication endpoints"
|
|
483
|
+
[Worker completes implementation]
|
|
484
|
+
User: "Now add tests for those endpoints"
|
|
485
|
+
- Launch worker 2 with worktree_name="auth-impl": "Add tests for authentication endpoints"
|
|
486
|
+
|
|
487
|
+
Why: Tests need the implementation files, but fresh perspective is fine, same branch
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
**Example 5: Parallel Edits to Same File (Different Worktrees)**
|
|
491
|
+
```
|
|
492
|
+
User: "Add error handling to login.ts and also add logging to the same file"
|
|
399
493
|
|
|
400
494
|
Response:
|
|
401
|
-
- Launch worker 1
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
495
|
+
- Launch worker 1 with worktree_name="add-error-handling": "Add error handling to login.ts"
|
|
496
|
+
- Launch worker 2 with worktree_name="add-logging": "Add logging to login.ts"
|
|
497
|
+
|
|
498
|
+
Why: Different features, will be reviewed/merged separately, avoid conflicts during dev
|
|
405
499
|
```
|
|
406
500
|
|
|
407
|
-
**Example
|
|
501
|
+
**Example 6: Mixed - No Worktree for Quick Fixes**
|
|
408
502
|
```
|
|
409
|
-
User: "
|
|
503
|
+
User: "Fix typo in README and experiment with new WebSocket feature"
|
|
410
504
|
|
|
411
505
|
Response:
|
|
412
|
-
- Launch worker 1 (no worktree_name): "
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
✓ Implementation isolated in worktree for safe experimentation
|
|
506
|
+
- Launch worker 1 (no worktree_name): "Fix typo in README.md"
|
|
507
|
+
- Launch worker 2 with worktree_name="websocket-experiment": "Experiment with WebSocket implementation"
|
|
508
|
+
|
|
509
|
+
Why: Typo fix is trivial (main repo is fine), experiment needs isolation
|
|
417
510
|
```
|
|
418
511
|
|
|
512
|
+
### Best Practices
|
|
513
|
+
|
|
514
|
+
**Worktree Naming:**
|
|
515
|
+
- Use descriptive, semantic names: "auth-feature", "fix-login-bug", "refactor-db"
|
|
516
|
+
- Names become branch names, so follow branch naming conventions
|
|
517
|
+
- Keep names concise but meaningful
|
|
518
|
+
|
|
519
|
+
**Isolation Strategy:**
|
|
520
|
+
- Default: Use worktrees for most code changes (keeps main repo clean)
|
|
521
|
+
- Use same worktree_name when workers should share context
|
|
522
|
+
- Use different worktree_names when changes should be independent
|
|
523
|
+
- Skip worktrees for trivial changes (typos, docs) or pure research tasks
|
|
524
|
+
|
|
525
|
+
**Cleanup:**
|
|
526
|
+
- Worktrees are automatically cleaned up when workers complete
|
|
527
|
+
- Branches persist after cleanup (can be resumed or merged later)
|
|
528
|
+
- Review and merge branches through normal git workflow
|
|
529
|
+
|
|
530
|
+
**Worker Launch Information:**
|
|
531
|
+
When you launch a worker with worktree isolation, you'll receive:
|
|
532
|
+
- `worktree_path`: Location of the worker's isolated directory
|
|
533
|
+
- `branch_name`: Name of the worktree's dedicated branch (same as worktree_name)
|
|
534
|
+
|
|
419
535
|
## Worker Status Tracking
|
|
420
536
|
|
|
421
|
-
**Status
|
|
422
|
-
|
|
537
|
+
**Understanding Status Update Messages**:
|
|
538
|
+
|
|
539
|
+
When workers complete, a special automated notification is added to the conversation. These messages are clearly formatted as system notifications, NOT user input:
|
|
540
|
+
- They start and end with clear visual separators: `═══════════════════════════════════════════════════════════════`
|
|
541
|
+
- They are labeled as `[AUTOMATED SYSTEM NOTIFICATION: WORKER STATUS UPDATE]`
|
|
542
|
+
- They contain instructions for you: "This is an automated notification triggered by a worker completion."
|
|
543
|
+
- They are generated by the orchestration system, not by the user
|
|
544
|
+
- They provide structured information about worker states and progress
|
|
545
|
+
- They trigger you to generate a response (see "How You Get Triggered" section)
|
|
546
|
+
- Users do NOT see these raw status messages (they're internal to orchestration)
|
|
547
|
+
|
|
548
|
+
**What Status Update Messages Contain:**
|
|
549
|
+
- ALL current worker statuses (running, completed, errored, cancelled)
|
|
423
550
|
- Which worker just completed (marked with >>> and "JUST COMPLETED" note)
|
|
424
551
|
- Which workers are still running
|
|
552
|
+
- **Worktree information** - Including worktree_name and branch_name for each worker
|
|
425
553
|
- **FULL PROGRESS LOG** for completed workers - showing everything the worker did
|
|
426
554
|
|
|
427
555
|
**CRITICAL: Read the Full Progress Log**
|