agent-trajectories 0.3.1 → 0.5.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/README.md +226 -1
- package/dist/chunk-4MACDCF4.js +1731 -0
- package/dist/chunk-4MACDCF4.js.map +1 -0
- package/dist/cli/index.js +1306 -58
- package/dist/cli/index.js.map +1 -1
- package/dist/index-Csfr_SjX.d.ts +1692 -0
- package/dist/index.d.ts +4 -1181
- package/dist/index.js +22 -28
- package/dist/index.js.map +1 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +37 -0
- package/dist/sdk/index.js.map +1 -0
- package/package.json +15 -3
- package/dist/chunk-DX4OPGH7.js +0 -954
- package/dist/chunk-DX4OPGH7.js.map +0 -1
package/README.md
CHANGED
|
@@ -30,6 +30,18 @@ Works with any task system: Beads, Linear, Jira, GitHub Issues, or standalone. T
|
|
|
30
30
|
- **Timeline** - Linear-style chronological view
|
|
31
31
|
- **JSON** - Full structured data for tooling
|
|
32
32
|
|
|
33
|
+
### Native Multi-Agent Support
|
|
34
|
+
|
|
35
|
+
Trajectories is built for teams of agents working together:
|
|
36
|
+
|
|
37
|
+
- **Shared trajectory** — Multiple agents collaborate on a single task record
|
|
38
|
+
- **Agent participation** — Each agent logged as lead, contributor, or reviewer with timestamps
|
|
39
|
+
- **Chapter handoffs** — When work moves between agents, chapters capture the context shift
|
|
40
|
+
- **Cross-agent messaging** — Integrates with [agent-relay](https://github.com/khaliqgant/agent-relay) to record inter-agent communication as trajectory events
|
|
41
|
+
- **Parallel coordination** — Multiple agents working in parallel on related tasks can reference each other's trajectories
|
|
42
|
+
|
|
43
|
+
This is a key differentiator: no other tool in the AI dev stack tracks *who* (which agent, which model) made *which decisions* and *why*, across a coordinated multi-agent workflow.
|
|
44
|
+
|
|
33
45
|
### Integration Ready
|
|
34
46
|
- Complements [claude-mem](https://github.com/thedotmack/claude-mem) for observation-level memory
|
|
35
47
|
- Integrates with [agent-relay](https://github.com/khaliqgant/agent-relay) for multi-agent messaging
|
|
@@ -80,6 +92,8 @@ Over time, trajectories become a searchable knowledge base:
|
|
|
80
92
|
|
|
81
93
|
## Quick Start
|
|
82
94
|
|
|
95
|
+
### CLI
|
|
96
|
+
|
|
83
97
|
```bash
|
|
84
98
|
# Install globally (trail command available directly)
|
|
85
99
|
npm install -g agent-trajectories
|
|
@@ -112,6 +126,67 @@ trail export traj_abc123 --format markdown
|
|
|
112
126
|
trail export --format html --open # Opens in browser
|
|
113
127
|
```
|
|
114
128
|
|
|
129
|
+
### SDK
|
|
130
|
+
|
|
131
|
+
For programmatic usage, install the package and use the SDK:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm install agent-trajectories
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Using the Client (with storage):**
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { TrajectoryClient } from 'agent-trajectories';
|
|
141
|
+
|
|
142
|
+
const client = new TrajectoryClient({ defaultAgent: 'my-agent' });
|
|
143
|
+
await client.init();
|
|
144
|
+
|
|
145
|
+
// Start a new trajectory
|
|
146
|
+
const session = await client.start('Implement auth module');
|
|
147
|
+
|
|
148
|
+
// Record work in chapters
|
|
149
|
+
await session.chapter('Research');
|
|
150
|
+
await session.note('Found existing auth patterns');
|
|
151
|
+
await session.finding('Current system uses sessions');
|
|
152
|
+
|
|
153
|
+
// Record decisions
|
|
154
|
+
await session.decide(
|
|
155
|
+
'JWT vs Sessions?',
|
|
156
|
+
'JWT',
|
|
157
|
+
'Better for horizontal scaling'
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// Complete with retrospective
|
|
161
|
+
await session.done('Implemented JWT-based authentication', 0.9);
|
|
162
|
+
|
|
163
|
+
await client.close();
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Using the Builder (in-memory, no storage):**
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { trajectory } from 'agent-trajectories';
|
|
170
|
+
|
|
171
|
+
const result = trajectory('Fix login bug')
|
|
172
|
+
.withSource({ system: 'github', id: 'GH#456' })
|
|
173
|
+
.chapter('Investigation', 'claude')
|
|
174
|
+
.finding('Null pointer in session handler')
|
|
175
|
+
.decide('Fix approach', 'Add null check', 'Minimal change')
|
|
176
|
+
.chapter('Implementation', 'claude')
|
|
177
|
+
.note('Added validation')
|
|
178
|
+
.done('Fixed null pointer exception', 0.95);
|
|
179
|
+
|
|
180
|
+
// Export the trajectory
|
|
181
|
+
console.log(result); // Full trajectory object
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**SDK Features:**
|
|
185
|
+
- **Auto-save**: Changes persist automatically with the client
|
|
186
|
+
- **Fluent API**: Chain operations naturally
|
|
187
|
+
- **Resume support**: Pick up where you left off with `client.resume()`
|
|
188
|
+
- **Multiple exports**: Markdown, JSON, timeline, PR summary
|
|
189
|
+
|
|
115
190
|
## Why "Trail"?
|
|
116
191
|
|
|
117
192
|
> **Trajectory** = the complete path an agent takes through a task
|
|
@@ -216,6 +291,36 @@ When an agent starts a new task, it can query the workspace for:
|
|
|
216
291
|
|
|
217
292
|
Each layer is independent and can be used alone, but together they form a complete agent memory stack.
|
|
218
293
|
|
|
294
|
+
## The Narrative Layer in Your AI Stack
|
|
295
|
+
|
|
296
|
+
Trajectories sits at the top of an emerging ecosystem of AI development tools. Each layer answers a different question:
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
300
|
+
│ AGENT-TRAJECTORIES │
|
|
301
|
+
│ "Why was this built this way?" │
|
|
302
|
+
│ Narrative, decisions, retrospectives, institutional memory │
|
|
303
|
+
│ ▲ │
|
|
304
|
+
│ │ gives meaning to │
|
|
305
|
+
│ ENTIRE (entireio/cli) │
|
|
306
|
+
│ "What happened in this session?" │
|
|
307
|
+
│ Raw session capture, transcripts, recovery, rewind │
|
|
308
|
+
│ ▲ │
|
|
309
|
+
│ │ attributes │
|
|
310
|
+
│ AGENT-TRACE (agent-trace.dev) │
|
|
311
|
+
│ "Who wrote this line of code?" │
|
|
312
|
+
│ Line-level code attribution, model identification │
|
|
313
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Agent Trace** ([agent-trace.dev](https://agent-trace.dev)) is the attribution spec — trajectories implements it automatically, generating `.trace.json` files that comply with the spec on every `trail complete`.
|
|
317
|
+
|
|
318
|
+
**Entire** ([entireio/cli](https://github.com/entireio/cli)) captures raw session transcripts via git hooks — a complementary layer focused on recovery and rewind.
|
|
319
|
+
|
|
320
|
+
**Trajectories** is the narrative layer: structured meaning on top of raw events. Where entire captures *what happened*, trajectories captures *why decisions were made* and *what was learned*. Where agent-trace says *who wrote the code*, trajectories explains *why this approach was chosen*.
|
|
321
|
+
|
|
322
|
+
Used together, these tools give you a complete audit trail of AI-assisted development from attribution through narrative.
|
|
323
|
+
|
|
219
324
|
## The Trajectory Format
|
|
220
325
|
|
|
221
326
|
```json
|
|
@@ -299,10 +404,130 @@ Agent-generated code faces a trust problem. Developers hesitate to ship code the
|
|
|
299
404
|
|
|
300
405
|
The result: teams can ship agent code with the same confidence as human-written code—because they understand it just as well.
|
|
301
406
|
|
|
302
|
-
##
|
|
407
|
+
## Installation
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
npm install agent-trajectories
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
The package provides:
|
|
414
|
+
- **CLI** (`trail` command) - For command-line usage
|
|
415
|
+
- **SDK** - For programmatic integration
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
// Main import (includes SDK)
|
|
419
|
+
import { TrajectoryClient, trajectory } from 'agent-trajectories';
|
|
420
|
+
|
|
421
|
+
// Or import from SDK subpath
|
|
422
|
+
import { TrajectoryClient, TrajectoryBuilder } from 'agent-trajectories/sdk';
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
## SDK Reference
|
|
426
|
+
|
|
427
|
+
### TrajectoryClient
|
|
428
|
+
|
|
429
|
+
The client manages trajectories with persistent storage.
|
|
430
|
+
|
|
431
|
+
```typescript
|
|
432
|
+
const client = new TrajectoryClient({
|
|
433
|
+
defaultAgent: 'my-agent', // Default agent name
|
|
434
|
+
dataDir: '.trajectories', // Storage directory
|
|
435
|
+
autoSave: true, // Auto-save after operations
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
await client.init(); // Required before use
|
|
439
|
+
|
|
440
|
+
// Lifecycle
|
|
441
|
+
const session = await client.start('Task title');
|
|
442
|
+
const session = await client.resume(); // Resume active trajectory
|
|
443
|
+
const traj = await client.get('traj_xxx'); // Get by ID
|
|
444
|
+
|
|
445
|
+
// Query
|
|
446
|
+
const list = await client.list({ status: 'completed' });
|
|
447
|
+
const results = await client.search('auth');
|
|
448
|
+
|
|
449
|
+
// Export
|
|
450
|
+
const md = await client.exportMarkdown('traj_xxx');
|
|
451
|
+
const json = await client.exportJSON('traj_xxx');
|
|
452
|
+
|
|
453
|
+
await client.close();
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### TrajectorySession
|
|
457
|
+
|
|
458
|
+
Sessions provide chainable operations on active trajectories.
|
|
459
|
+
|
|
460
|
+
```typescript
|
|
461
|
+
const session = await client.start('Task');
|
|
462
|
+
|
|
463
|
+
// Chapters organize work phases
|
|
464
|
+
await session.chapter('Research');
|
|
465
|
+
await session.chapter('Implementation');
|
|
466
|
+
|
|
467
|
+
// Events record what happened
|
|
468
|
+
await session.note('Observation or note');
|
|
469
|
+
await session.finding('Important discovery');
|
|
470
|
+
await session.error('Something went wrong');
|
|
471
|
+
|
|
472
|
+
// Decisions capture choices
|
|
473
|
+
await session.decide('Question?', 'Choice', 'Reasoning');
|
|
474
|
+
|
|
475
|
+
// Complete or abandon
|
|
476
|
+
await session.done('Summary of work', 0.9);
|
|
477
|
+
await session.abandon('Reason for abandoning');
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### TrajectoryBuilder
|
|
481
|
+
|
|
482
|
+
The builder creates trajectories in memory without storage.
|
|
483
|
+
|
|
484
|
+
```typescript
|
|
485
|
+
import { trajectory, TrajectoryBuilder } from 'agent-trajectories';
|
|
486
|
+
|
|
487
|
+
// Shorthand function
|
|
488
|
+
const t = trajectory('Task title')
|
|
489
|
+
.chapter('Work', 'agent-name')
|
|
490
|
+
.note('Did something')
|
|
491
|
+
.done('Completed', 0.9);
|
|
492
|
+
|
|
493
|
+
// Or use the class directly
|
|
494
|
+
const t = TrajectoryBuilder.create('Task')
|
|
495
|
+
.withDescription('Detailed description')
|
|
496
|
+
.withSource({ system: 'linear', id: 'ENG-123' })
|
|
497
|
+
.withTags('feature', 'auth')
|
|
498
|
+
.chapter('Phase 1', 'claude')
|
|
499
|
+
.complete({
|
|
500
|
+
summary: 'What was done',
|
|
501
|
+
approach: 'How it was done',
|
|
502
|
+
confidence: 0.85,
|
|
503
|
+
challenges: ['What was hard'],
|
|
504
|
+
learnings: ['What was learned'],
|
|
505
|
+
});
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
## Roadmap
|
|
303
509
|
|
|
304
510
|
This project is in early development. See [PROPOSAL-trajectories.md](./PROPOSAL-trajectories.md) for the full design document.
|
|
305
511
|
|
|
512
|
+
**v1.0 (current)**
|
|
513
|
+
- [x] File-based storage (`.trajectories/`)
|
|
514
|
+
- [x] Core CLI commands (`start`, `decision`, `complete`, `list`, `show`, `export`)
|
|
515
|
+
- [x] Agent Trace spec compliance (`.trace.json` generation)
|
|
516
|
+
- [x] Multi-agent participation tracking
|
|
517
|
+
- [x] Rich export formats (Markdown, JSON, Timeline, HTML)
|
|
518
|
+
|
|
519
|
+
**v1.1 (next)**
|
|
520
|
+
- [ ] **MCP server** — Real-time bidirectional queries so Claude Code, Cursor, and other tools can read and write trajectories directly within agent sessions
|
|
521
|
+
- [ ] **Claude Code hooks** — Auto-capture on `PostToolUse` and session boundaries
|
|
522
|
+
- [ ] **SQLite storage** — Full-text search across all trajectories
|
|
523
|
+
- [ ] **Git hook integration** — Auto-start/complete trajectories on commit events
|
|
524
|
+
- [ ] **`CLAUDE.md` generation** — Extract patterns from trajectories into reusable context files
|
|
525
|
+
|
|
526
|
+
**Future**
|
|
527
|
+
- Workspace knowledge base (decisions, patterns, conventions as queryable memory)
|
|
528
|
+
- PostgreSQL/S3 storage for teams
|
|
529
|
+
- Training data export for project-specific model fine-tuning
|
|
530
|
+
|
|
306
531
|
## License
|
|
307
532
|
|
|
308
533
|
MIT
|