@jamesaphoenix/tx-types 0.5.0 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +169 -302
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,14 +1,22 @@
1
1
  # tx
2
2
 
3
- **TanStack for AI agents.** Primitives, not frameworks.
3
+ **Primitives, not frameworks.** Headless infrastructure for AI agents.
4
4
 
5
- Headless infrastructure for memory, tasks, and orchestration.
5
+ Memory, tasks, and orchestration. You own the loop.
6
6
 
7
7
  ```bash
8
- npm install -g @jamesaphoenix/tx
8
+ npm install -g @jamesaphoenix/tx-cli
9
9
  tx init
10
10
  ```
11
11
 
12
+ Agent onboarding (optional, both supported):
13
+
14
+ ```bash
15
+ tx init --claude # CLAUDE.md + .claude/skills
16
+ tx init --codex # AGENTS.md + .codex/agents
17
+ tx init --claude --codex # scaffold both
18
+ ```
19
+
12
20
  ---
13
21
 
14
22
  ## The Problem
@@ -26,7 +34,7 @@ Composable primitives that handle the hard parts. You keep control of the orches
26
34
  │ tx primitives │
27
35
  │ │
28
36
  │ tx ready tx done tx context tx learn │
29
- │ tx claim tx block tx handoff tx sync
37
+ │ tx claim tx block tx sync tx trace
30
38
  │ │
31
39
  └─────────────────────────────────────────────────────────┘
32
40
  ```
@@ -40,16 +48,20 @@ Composable primitives that handle the hard parts. You keep control of the orches
40
48
  Learnings that persist and surface when relevant.
41
49
 
42
50
  ```bash
43
- # Store knowledge (with optional file path)
44
- tx learning:add "Use bcrypt for passwords, not SHA256" --file src/auth/hash.ts
45
- tx learning:add "Redis cache invalidation has race conditions"
51
+ # Store knowledge
52
+ tx learning:add "Use bcrypt for passwords, not SHA256"
53
+ tx learning:add "Redis cache invalidation has race conditions" -c database
54
+
55
+ # Attach learnings to file paths
56
+ tx learn "src/auth/*.ts" "Services must use Effect-TS patterns"
46
57
 
47
58
  # Retrieve via search or task context
48
59
  tx learning:search "authentication"
49
60
  tx context tx-abc123 # Get relevant learnings for a task
61
+ tx recall "src/auth/hash.ts" # Recall learnings for a file
50
62
  ```
51
63
 
52
- Learnings can be tagged with file paths for organization. Hybrid search (BM25 + vector) finds relevant knowledge.
64
+ Hybrid search (BM25 + vector with RRF fusion) finds relevant knowledge.
53
65
 
54
66
  ### Tasks
55
67
 
@@ -70,14 +82,54 @@ Full hierarchy support. Epics contain milestones contain tasks contain subtasks.
70
82
 
71
83
  ### Coordination
72
84
 
73
- Primitives for multi-agent workflows without prescribing the pattern.
85
+ Lease-based claims prevent parallel agents from colliding.
86
+
87
+ ```bash
88
+ tx claim tx-abc123 worker-1 # Claim with 30-min lease
89
+ tx claim tx-abc123 worker-1 --lease 60 # Custom lease duration
90
+ tx claim:renew tx-abc123 worker-1 # Extend lease
91
+ tx claim:release tx-abc123 worker-1 # Release early
92
+ ```
93
+
94
+ ### Attempts
95
+
96
+ Track what approaches have been tried on a task.
97
+
98
+ ```bash
99
+ tx try tx-abc123 "Used Redux" --failed "Too complex for this use case"
100
+ tx try tx-abc123 "Used Zustand" --succeeded
101
+ tx attempts tx-abc123 # See all attempts
102
+ ```
103
+
104
+ ### Docs
105
+
106
+ Structured documentation as primitives. YAML-based with versioning, locking, and linking.
107
+
108
+ ```bash
109
+ tx doc add prd auth-system --title "Auth System PRD"
110
+ tx doc render # Generate markdown from YAML
111
+ tx doc lock auth-system # Lock doc (immutable)
112
+ tx doc link auth-prd auth-dd # Link PRD to DD
113
+ tx doc drift # Detect stale docs
114
+ ```
115
+
116
+ ### Invariants
117
+
118
+ Track and verify project invariants across sessions.
74
119
 
75
120
  ```bash
76
- tx claim tx-abc123 # Prevent collisions
77
- tx checkpoint tx-abc123 \
78
- --note "API done, UI next" # Save progress
79
- tx handoff tx-abc123 \
80
- --to reviewer # Transfer with context
121
+ tx invariant list # List all invariants
122
+ tx invariant show INV-001 # Show details
123
+ tx invariant record INV-001 --passed # Record check result
124
+ tx invariant sync # Sync from CLAUDE.md
125
+ ```
126
+
127
+ ### Cycle Scan
128
+
129
+ Sub-agent swarm scanning for codebase analysis.
130
+
131
+ ```bash
132
+ tx cycle --task-prompt "Review auth" --scan-prompt "Find bugs"
81
133
  ```
82
134
 
83
135
  ---
@@ -88,16 +140,20 @@ We ship **example loops**, not **the loop**:
88
140
 
89
141
  ```bash
90
142
  # Simple: one agent, one task
143
+ AGENT_CMD=${AGENT_CMD:-codex} # or: claude
91
144
  while task=$(tx ready --limit 1 --json | jq -r '.[0].id'); do
92
- claude "Work on task $task, then run: tx done $task"
145
+ "$AGENT_CMD" "Work on task $task, then run: tx done $task"
93
146
  done
94
147
  ```
95
148
 
96
149
  ```bash
97
- # Parallel: N agents pulling from queue
150
+ # Parallel: N agents with claims
151
+ AGENT_CMD=${AGENT_CMD:-codex} # or: claude
98
152
  for i in {1..5}; do
99
- (while task=$(tx claim --next); do
100
- claude "Complete $task" && tx done $task
153
+ (while task=$(tx ready --json --limit 1 | jq -r '.[0].id // empty'); do
154
+ [ -z "$task" ] && break
155
+ tx claim "$task" "worker-$i" || continue
156
+ "$AGENT_CMD" "Complete $task" && tx done "$task"
101
157
  done) &
102
158
  done
103
159
  wait
@@ -105,9 +161,10 @@ wait
105
161
 
106
162
  ```bash
107
163
  # Human-in-loop: agent proposes, human approves
108
- task=$(tx ready --limit 1)
109
- claude "Plan implementation for $task" > plan.md
110
- read -p "Approve? [y/n] " && claude "Execute plan.md"
164
+ AGENT_CMD=${AGENT_CMD:-codex} # or: claude
165
+ task=$(tx ready --json --limit 1 | jq -r '.[0].id')
166
+ "$AGENT_CMD" "Plan implementation for $task" > plan.md
167
+ read -p "Approve? [y/n] " && "$AGENT_CMD" "Execute plan.md"
111
168
  tx done $task
112
169
  ```
113
170
 
@@ -120,8 +177,8 @@ tx done $task
120
177
  | | Native Tasks | CLAUDE.md | tx |
121
178
  |---|---|---|---|
122
179
  | **Persistence** | Session-scoped | File grows forever | Git-native, branch-aware |
123
- | **Multi-agent** | Collisions | Manual coordination | Claim, block, handoff |
124
- | **Knowledge** | Lost each session | Static dump | Graph RAG, contextual retrieval |
180
+ | **Multi-agent** | Collisions | Manual coordination | Claim with lease expiry |
181
+ | **Knowledge** | Lost each session | Static dump | Hybrid search, contextual retrieval |
125
182
  | **Orchestration** | None | None | Primitives for any pattern |
126
183
 
127
184
  ---
@@ -145,249 +202,12 @@ tx done $task
145
202
 
146
203
  ---
147
204
 
148
- ## Three Systems
149
-
150
- ### 1. Knowledge System
151
-
152
- **Working today:**
153
- - Learnings stored with file path tags
154
- - Basic hybrid search (BM25 + vector)
155
- - Retrieval by task ID via `tx context`
156
-
157
- ```bash
158
- tx learning:add "Use bcrypt for passwords" --file src/auth/hash.ts
159
- tx learning:search "authentication"
160
- tx context tx-abc123 # Get learnings relevant to a task
161
- ```
162
-
163
- **Research in progress:**
164
- - Symbol anchoring (AST-based code references, not just file paths)
165
- - Knowledge graph expansion (automatic relationship discovery)
166
- - Auto-invalidation when code changes
167
-
168
- ### 2. Task System
169
-
170
- **Working today:**
171
- - N-level hierarchy (epics → tasks → subtasks)
172
- - Explicit dependencies with cycle detection
173
- - Priority scoring
174
- - Claim/release with lease expiry
175
-
176
- ```
177
- Epic: "User Authentication"
178
- ├── Task: "Design schema" ✓ done
179
- ├── Task: "Implement service" ● ready (unblocked)
180
- │ └── blocks: "Write tests", "Add endpoints"
181
- └── Task: "Write tests" ○ blocked
182
- ```
183
-
184
- **Research in progress:**
185
- - LLM-based reprioritization
186
- - Automatic task decomposition
187
-
188
- ### 3. Worker System
189
-
190
- **Working today:**
191
- - `runWorker()` with execute/captureIO hooks
192
- - Lease-based claims (prevents collisions)
193
- - Automatic lease renewal
194
- - Coordinator reconciliation (dead worker recovery)
195
-
196
- ```typescript
197
- runWorker({
198
- execute: async (task, ctx) => {
199
- await ctx.renewLease() // For long tasks
200
- return { success: true }
201
- }
202
- })
203
- ```
204
-
205
- **Research in progress:**
206
- - Daemon watching `~/.claude/projects/**/*.jsonl`
207
- - Automatic learning extraction from sessions
208
- - Confidence scoring for auto-promotion
209
-
210
- ---
211
-
212
- ## Worker Orchestration (TypeScript SDK)
213
-
214
- For programmatic control, the TypeScript SDK provides `runWorker()` — a headless worker that executes tasks using your hooks.
215
-
216
- ### Two Hooks. That's It.
217
-
218
- ```typescript
219
- import { runWorker } from "@jamesaphoenix/tx-core"
220
-
221
- runWorker({
222
- name: "my-worker",
223
- execute: async (task, ctx) => {
224
- // YOUR LOGIC HERE
225
- console.log(`Working on: ${task.title}`)
226
-
227
- // Use ctx.renewLease() for long tasks
228
- await ctx.renewLease()
229
-
230
- // Return success or failure
231
- return { success: true, output: "Done!" }
232
- },
233
- captureIO: (runId, task) => ({
234
- transcriptPath: `.tx/runs/${runId}.jsonl`,
235
- stderrPath: `.tx/runs/${runId}.stderr`
236
- })
237
- })
238
- ```
239
-
240
- | Hook | Required | Purpose |
241
- |------|----------|---------|
242
- | `execute` | Yes | Your task execution logic |
243
- | `captureIO` | No | Paths for transcript/stderr/stdout capture |
244
-
245
- ### WorkerContext
246
-
247
- The `ctx` object provides tx primitives:
248
-
249
- ```typescript
250
- interface WorkerContext {
251
- workerId: string // This worker's ID
252
- runId: string // Unique ID for this execution
253
- renewLease: () => Promise<void> // Extend lease for long tasks
254
- log: (message: string) => void // Log with worker prefix
255
- state: Record<string, unknown> // Mutable state within task
256
- }
257
- ```
258
-
259
- ### Custom Context
260
-
261
- Pass your own primitives via generics:
262
-
263
- ```typescript
264
- interface MyContext {
265
- llm: AnthropicClient
266
- db: Database
267
- }
268
-
269
- runWorker<MyContext>({
270
- context: {
271
- llm: new Anthropic(),
272
- db: myDatabase
273
- },
274
- execute: async (task, ctx) => {
275
- // ctx.llm and ctx.db available here
276
- const response = await ctx.llm.messages.create(...)
277
- return { success: true }
278
- }
279
- })
280
- ```
281
-
282
- ### Claims and Leases
283
-
284
- Workers use a lease-based system to prevent collisions:
285
-
286
- ```
287
- Worker A claims task → Lease expires in 30 min → Renew or lose it
288
- Worker B tries to claim same task → Rejected (already claimed)
289
- Worker A dies → Lease expires → Coordinator reclaims task
290
- ```
291
-
292
- Key points:
293
- - **Claims are atomic** — only one worker can claim a task
294
- - **Leases expire** — prevents stuck tasks from dead workers
295
- - **Auto-renewal** — `runWorker()` renews automatically; use `ctx.renewLease()` for extra-long tasks
296
- - **Coordinator reconciles** — dead workers detected, orphaned tasks recovered
297
-
298
- ### Example Worker Loops
299
-
300
- #### Basic: One Worker
301
-
302
- ```typescript
303
- import { Effect, Layer } from "effect"
304
- import { runWorker, makeMinimalLayer, SqliteClientLive } from "@jamesaphoenix/tx-core"
305
-
306
- const layer = makeMinimalLayer.pipe(
307
- Layer.provide(SqliteClientLive(".tx/tasks.db"))
308
- )
309
-
310
- Effect.runPromise(
311
- runWorker({
312
- execute: async (task, ctx) => {
313
- ctx.log(`Processing: ${task.title}`)
314
- // ... your logic
315
- return { success: true }
316
- }
317
- }).pipe(Effect.provide(layer))
318
- )
319
- ```
320
-
321
- #### With Claude Code
322
-
323
- ```typescript
324
- import { spawn } from "child_process"
325
-
326
- runWorker({
327
- execute: async (task, ctx) => {
328
- return new Promise((resolve) => {
329
- const proc = spawn("claude", [
330
- "--print",
331
- `Work on task ${task.id}: ${task.title}`
332
- ])
333
-
334
- proc.on("close", (code) => {
335
- resolve({
336
- success: code === 0,
337
- error: code !== 0 ? `Exit code ${code}` : undefined
338
- })
339
- })
340
- })
341
- }
342
- })
343
- ```
344
-
345
- #### Parallel Workers
346
-
347
- ```typescript
348
- // Start N workers (each in its own process or fiber)
349
- for (let i = 0; i < 5; i++) {
350
- Effect.fork(
351
- runWorker({
352
- name: `worker-${i}`,
353
- execute: async (task, ctx) => {
354
- // Workers automatically coordinate via claims
355
- return { success: true }
356
- }
357
- })
358
- )
359
- }
360
- ```
361
-
362
- #### Long-Running Tasks
363
-
364
- ```typescript
365
- runWorker({
366
- execute: async (task, ctx) => {
367
- for (let step = 0; step < 100; step++) {
368
- // Periodic lease renewal for tasks > 30 min
369
- if (step % 10 === 0) {
370
- await ctx.renewLease()
371
- }
372
-
373
- // Track progress in mutable state
374
- ctx.state.progress = step
375
-
376
- await doExpensiveWork(step)
377
- }
378
- return { success: true }
379
- }
380
- })
381
- ```
382
-
383
- ---
384
-
385
205
  ## Interfaces
386
206
 
387
207
  | Interface | Use Case |
388
208
  |-----------|----------|
389
- | **CLI** | Scripts, terminal workflows, RALPH loops |
390
- | **MCP Server** | Claude Code integration (16 tools) |
209
+ | **CLI** | Scripts, terminal workflows, agent loops |
210
+ | **MCP Server** | Claude Code integration (42 tools) |
391
211
  | **REST API** | Custom dashboards, external integrations |
392
212
  | **TypeScript SDK** | Programmatic access from your agents |
393
213
  | **Dashboard** | Visual monitoring and management |
@@ -398,25 +218,88 @@ runWorker({
398
218
 
399
219
  ```bash
400
220
  # Tasks
401
- tx add <title> # Create
402
- tx ready # List unblocked
403
- tx done <id> # Complete
221
+ tx add <title> # Create task
222
+ tx list # List all tasks
223
+ tx ready # List unblocked tasks
224
+ tx show <id> # View details
225
+ tx update <id> # Update task fields
226
+ tx done <id> # Complete task
227
+ tx reset <id> # Reset to backlog
228
+ tx delete <id> # Delete task
404
229
  tx block <id> <blocker> # Add dependency
230
+ tx unblock <id> <blocker> # Remove dependency
231
+ tx children <id> # List child tasks
405
232
  tx tree <id> # Show hierarchy
406
233
 
407
- # Memory
408
- tx learning:add <content> # Store
409
- tx learning:search <query> # Find
234
+ # Context & Learnings
235
+ tx learning:add <content> # Store knowledge
236
+ tx learning:search <query> # Search learnings
237
+ tx learning:recent # Recent learnings
238
+ tx learning:helpful # Mark as helpful
239
+ tx learning:embed # Generate embeddings
410
240
  tx context <task-id> # Contextual retrieval
241
+ tx learn <path> <note> # Attach to file
242
+ tx recall [path] # Query by file
411
243
 
412
244
  # Coordination
413
- tx claim <id> # Prevent collisions
414
- tx handoff <id> --to <agent>
415
- tx checkpoint <id> --note "..."
245
+ tx claim <id> <worker> # Lease-based claim
246
+ tx claim:renew <id> <worker> # Extend lease
247
+ tx claim:release <id> <worker> # Release early
248
+ tx try <id> <approach> # Record attempt
249
+ tx attempts <id> # List attempts
250
+
251
+ # Docs
252
+ tx doc add <type> <slug> # Create doc
253
+ tx doc edit <slug> # Edit doc
254
+ tx doc show <slug> # Show doc
255
+ tx doc list # List docs
256
+ tx doc render # Generate markdown
257
+ tx doc lock <slug> # Lock (immutable)
258
+ tx doc version <slug> # Create version
259
+ tx doc link <from> <to> # Link docs
260
+ tx doc attach <slug> <task> # Attach to task
261
+ tx doc patch <slug> # Apply patch
262
+ tx doc validate # Validate all docs
263
+ tx doc drift # Detect stale docs
264
+
265
+ # Invariants
266
+ tx invariant list # List invariants
267
+ tx invariant show <id> # Show details
268
+ tx invariant record <id> # Record check result
269
+ tx invariant sync # Sync from CLAUDE.md
416
270
 
417
271
  # Sync
418
272
  tx sync export # SQLite → JSONL (git-friendly)
419
273
  tx sync import # JSONL → SQLite
274
+ tx sync status # Show sync status
275
+ tx sync auto # Auto-sync on change
276
+ tx sync compact # Compact JSONL files
277
+ tx sync claude --team <name> # Push to Claude Code team
278
+ tx sync codex # Push to Codex
279
+
280
+ # Traces
281
+ tx trace list # Recent runs
282
+ tx trace show <id> # Show trace details
283
+ tx trace transcript <id> # View transcript
284
+ tx trace stderr <id> # View stderr
285
+ tx trace errors # Recent errors
286
+
287
+ # Bulk
288
+ tx bulk done <ids...> # Complete multiple tasks
289
+ tx bulk score <ids...> # Score multiple tasks
290
+ tx bulk reset <ids...> # Reset multiple tasks
291
+ tx bulk delete <ids...> # Delete multiple tasks
292
+
293
+ # Cycle
294
+ tx cycle # Sub-agent swarm scan
295
+
296
+ # Utilities
297
+ tx stats # Queue metrics
298
+ tx validate # Database health checks
299
+ tx migrate status # Migration status
300
+ tx doctor # System diagnostics
301
+ tx dashboard # Launch dashboard
302
+ tx mcp-server # Start MCP server
420
303
  ```
421
304
 
422
305
  ---
@@ -428,50 +311,34 @@ tx sync import # JSONL → SQLite
428
311
  ├── tasks.db # SQLite (gitignored)
429
312
  ├── tasks.jsonl # Git-tracked
430
313
  ├── learnings.jsonl # Git-tracked
431
- └── runs.jsonl # Git-tracked
314
+ ├── runs.jsonl # Git-tracked
315
+ └── docs/ # YAML doc sources
432
316
  ```
433
317
 
434
318
  Local SQLite for speed. JSONL for git sync. Branch your knowledge with your code.
435
319
 
436
320
  ---
437
321
 
438
- ## Status
322
+ ## Packages
439
323
 
440
- **Shipping now (concrete, tested):**
441
- - Core task primitives: add, ready, done, block, claim, handoff
442
- - Dependency management with cycle detection
443
- - Worker orchestration via `runWorker()` with claims/leases
444
- - Learnings with file path tagging
445
- - Hybrid search (BM25 + vector)
446
- - CLI (20+ commands), MCP server (16 tools)
447
- - 389+ tests
448
-
449
- **Research in progress (not yet stable):**
450
- - Symbol anchoring (AST-based code references)
451
- - Knowledge graph expansion
452
- - Auto-invalidation when code changes
453
- - Daemon-based learning extraction
454
- - LLM reprioritization
324
+ | Package | Description |
325
+ |---------|-------------|
326
+ | [`@jamesaphoenix/tx`](https://www.npmjs.com/package/@jamesaphoenix/tx) | Public SDK |
327
+ | [`@jamesaphoenix/tx-cli`](https://www.npmjs.com/package/@jamesaphoenix/tx-cli) | CLI |
328
+ | [`@jamesaphoenix/tx-core`](https://www.npmjs.com/package/@jamesaphoenix/tx-core) | Core service layer (Effect-TS) |
329
+ | [`@jamesaphoenix/tx-types`](https://www.npmjs.com/package/@jamesaphoenix/tx-types) | Shared type definitions |
330
+ | [`@jamesaphoenix/tx-agent-sdk`](https://www.npmjs.com/package/@jamesaphoenix/tx-agent-sdk) | TypeScript Agent SDK |
331
+ | [`@jamesaphoenix/tx-mcp-server`](https://www.npmjs.com/package/@jamesaphoenix/tx-mcp-server) | MCP server (42 tools) |
332
+ | [`@jamesaphoenix/tx-api-server`](https://www.npmjs.com/package/@jamesaphoenix/tx-api-server) | REST API server |
455
333
 
456
334
  ---
457
335
 
458
336
  ## Documentation
459
337
 
338
+ - **[txdocs.dev](https://txdocs.dev)**: Documentation
460
339
  - **[CLAUDE.md](CLAUDE.md)**: Doctrine and quick reference
461
- - **[docs/](docs/)**: Full documentation (17 PRDs, 17 Design Docs)
462
-
463
- ### Docs Site
464
-
465
- Run the documentation site locally:
466
-
467
- ```bash
468
- cd apps/docs
469
- npm run dev # Development server at http://localhost:3000
470
- npm run build # Production build
471
- npm run start # Serve production build
472
- ```
473
-
474
- The docs site is built with [Fumadocs](https://fumadocs.vercel.app/) and Next.js, featuring full-text search, syntax highlighting, and automatic navigation from the markdown files in `docs/`.
340
+ - **[AGENTS.md](AGENTS.md)**: Codex onboarding and quick reference
341
+ - **[docs/](docs/)**: PRDs and Design Docs
475
342
 
476
343
  ---
477
344
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesaphoenix/tx-types",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Shared TypeScript types for tx - Effect Schema definitions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",