trellis 2.0.8 → 2.0.13

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 (42) hide show
  1. package/README.md +279 -116
  2. package/dist/cli/index.js +655 -4
  3. package/dist/core/index.js +471 -2
  4. package/dist/embeddings/index.js +5 -1
  5. package/dist/{index-s603ev6w.js → index-5b01h414.js} +1 -1
  6. package/dist/index-5m0g9r0y.js +1100 -0
  7. package/dist/{index-zf6htvnm.js → index-7gvjxt27.js} +166 -2
  8. package/dist/index-hybgxe40.js +1174 -0
  9. package/dist/index.js +7 -2
  10. package/dist/transformers.node-bx3q9d7k.js +33130 -0
  11. package/package.json +9 -4
  12. package/src/cli/index.ts +939 -0
  13. package/src/core/agents/harness.ts +380 -0
  14. package/src/core/agents/index.ts +18 -0
  15. package/src/core/agents/types.ts +90 -0
  16. package/src/core/index.ts +85 -2
  17. package/src/core/kernel/trellis-kernel.ts +593 -0
  18. package/src/core/ontology/builtins.ts +248 -0
  19. package/src/core/ontology/index.ts +34 -0
  20. package/src/core/ontology/registry.ts +209 -0
  21. package/src/core/ontology/types.ts +124 -0
  22. package/src/core/ontology/validator.ts +382 -0
  23. package/src/core/persist/backend.ts +10 -0
  24. package/src/core/persist/sqlite-backend.ts +298 -0
  25. package/src/core/plugins/index.ts +17 -0
  26. package/src/core/plugins/registry.ts +322 -0
  27. package/src/core/plugins/types.ts +126 -0
  28. package/src/core/query/datalog.ts +188 -0
  29. package/src/core/query/engine.ts +370 -0
  30. package/src/core/query/index.ts +34 -0
  31. package/src/core/query/parser.ts +481 -0
  32. package/src/core/query/types.ts +200 -0
  33. package/src/embeddings/auto-embed.ts +248 -0
  34. package/src/embeddings/index.ts +7 -0
  35. package/src/embeddings/model.ts +21 -4
  36. package/src/embeddings/types.ts +8 -1
  37. package/src/index.ts +9 -0
  38. package/src/sync/http-transport.ts +144 -0
  39. package/src/sync/index.ts +11 -0
  40. package/src/sync/multi-repo.ts +200 -0
  41. package/src/sync/ws-transport.ts +145 -0
  42. package/dist/index-5bhe57y9.js +0 -326
package/README.md CHANGED
@@ -1,62 +1,79 @@
1
1
  <p align="center">
2
- <img src="logo.png" alt="Trellis" width="128" />
2
+ <img src="https://trentbrew.pockethost.io/api/files/swvnum16u65or8w/75p6fv4xnwa3mq7/logomark_alpha_green_T3C3ypsMwI.png?token=" alt="Trellis" width="128" />
3
3
  </p>
4
4
 
5
5
  # Trellis
6
6
 
7
- > **Graph-native, code-first version control.**
8
- > Every file save is an op. Every op is a node. History is a causal graph, not a linear diff.
9
-
10
- Trellis is a from-scratch VCS built on five pillars:
11
-
12
- 1. **Causal Stream** — an immutable, content-addressed log of ops where every change is causally chained to its predecessor.
13
- 2. **Semantic Patching** — changes are recorded as structured AST patches (`symbolRename`, `symbolModify`, …) rather than line diffs, enabling conflict-free merges.
14
- 3. **Narrative Milestones** — you never "commit". Instead you carve checkpoints and milestones out of a continuous stream of work.
15
- 4. **Governance Subgraph** — op signing, identity management, and policy rules enforced before ops enter the stream.
16
- 5. **Idea Garden** — abandoned work clusters are automatically detected and surfaced for later revival.
7
+ > **A comprehensive graph-native platform for code, knowledge, and collaboration.**
8
+ > Trellis combines version control, semantic analysis, knowledge graphs, and intelligent automation into a unified system that treats every action as a first-class graph entity.
17
9
 
18
10
  ---
19
11
 
20
12
  ## Table of Contents
21
13
 
22
- - [Trellis Overview](#trellis-overview)
14
+ - [Platform Overview](#platform-overview)
15
+ - [Core Capabilities](#core-capabilities)
23
16
  - [Project Surfaces](#project-surfaces)
24
17
  - [Quick Start](#quick-start)
18
+ - [Package Architecture](#package-architecture)
25
19
  - [CLI Overview](#cli-overview)
26
20
  - [VS Code Extension](#vs-code-extension)
27
21
  - [Module & Subpath Guide](#module--subpath-guide)
28
- - [Architecture Overview](#architecture-overview)
29
22
  - [Development & Releases](#development--releases)
30
23
  - [Roadmap](#roadmap)
31
24
 
32
25
  ---
33
26
 
34
- ## Trellis Overview
27
+ ## Platform Overview
28
+
29
+ Trellis is a comprehensive platform that unifies version control, knowledge management, semantic analysis, and intelligent automation. Built on a graph-native foundation, it treats every action—code changes, decisions, links, and embeddings—as first-class entities in a causal graph.
30
+
31
+ The platform consists of multiple integrated surfaces:
32
+
33
+ - **`trellis` npm package** — the published package exposing all platform APIs through modular subpaths
34
+ - **`trellis` CLI** — command-line interface for repository management, semantic tooling, knowledge operations, and automation
35
+ - **VS Code extension** — visual interface for timeline exploration, issue management, knowledge navigation, and collaborative features
36
+ - **Core platform modules** — reusable building blocks for graph storage, semantic analysis, sync, knowledge graphs, embeddings, and decision traces
37
+
38
+ ### Core Capabilities
39
+
40
+ #### 1. **Graph-Native Foundation**
41
+
42
+ - **EAV Store** — Entity-Attribute-Value graph database with SQLite backend
43
+ - **TrellisKernel** — Generic graph CRUD operations independent of VCS
44
+ - **Query Engine** — EQL-S query language and Datalog evaluator
45
+ - **Ontology System** — Schema validation and built-in ontologies
35
46
 
36
- Trellis is an umbrella project with a few distinct surfaces that all sit on the same underlying model:
47
+ #### 2. **Advanced Version Control**
37
48
 
38
- - **`trellis` npm package** — the published package for engine APIs, subpath exports, and reusable modules.
39
- - **`trellis` CLI** — the command-line interface for repo setup, history, milestones, semantic diffing, and automation.
40
- - **VS Code extension** — the visual shell for status, issues, timeline, kanban, and wiki-link navigation.
41
- - **Core modules** — reusable building blocks for graph storage, semantic analysis, sync, links, embeddings, and decision traces.
49
+ - **Causal Stream** — Immutable, content-addressed operations with causal chaining
50
+ - **Semantic Patching** — AST-aware changes enabling conflict-free merges
51
+ - **Narrative Milestones** — Human-readable checkpoints over continuous work streams
52
+ - **Governance** — Op signing, identity management, and policy enforcement
42
53
 
43
- The core idea stays the same across all of them:
54
+ #### 3. **Knowledge & Intelligence**
44
55
 
45
- 1. **Causal Stream** — immutable, content-addressed ops linked by causal history.
46
- 2. **Semantic Patching** — AST-aware changes instead of line-only diffs.
47
- 3. **Narrative Milestones** — human checkpoints over a continuous stream of work.
48
- 4. **Governance Subgraph** — signing, identities, and policy enforcement.
49
- 5. **Idea Garden** — abandoned work detection and revival.
56
+ - **Wiki-Links** — Bidirectional reference system for cross-linking entities
57
+ - **Embeddings** — Semantic indexing and vector search for intelligent discovery
58
+ - **Decision Traces** — Automated capture and querying of agent decisions
59
+ - **Idea Garden** — Detection and revival of abandoned work clusters
60
+
61
+ #### 4. **Collaboration & Sync**
62
+
63
+ - **Peer Sync** — CRDT-based reconciliation with HTTP/WebSocket transports
64
+ - **Multi-Repo Federation** — Cross-repository entity references and linking
65
+ - **Agent System** — Tool registry and decision trace capture
66
+ - **Plugin Architecture** — Extensible system with event bus and workspace config
50
67
 
51
68
  ## Project Surfaces
52
69
 
53
- | Surface | Location | Purpose |
54
- | :-------------------- | :------------------------------------------------------------ | :----------------------------------------------------------------- |
55
- | **npm package** | `package.json`, `src/`, `dist/` | Published as `trellis`; exposes engine APIs and subpath exports |
56
- | **CLI** | `src/cli/index.ts` | Repository lifecycle, branch/milestone workflows, semantic tooling |
57
- | **VS Code extension** | `vscode-extension/` | Timeline, kanban, issue browser, wiki-link UX |
58
- | **Core store** | `src/core/` | Inlined EAV store, kernel persistence, middleware types |
59
- | **Platform modules** | `src/vcs/`, `src/links/`, `src/embeddings/`, `src/decisions/` | Reusable building blocks behind the product surfaces |
70
+ | Surface | Location | Purpose |
71
+ | :-------------------- | :------------------------------------------------------------ | :----------------------------------------------------------------------- |
72
+ | **npm package** | `package.json`, `src/`, `dist/` | Published as `trellis`; exposes all platform APIs via subpaths |
73
+ | **CLI** | `src/cli/index.ts` | Repository lifecycle, semantic tooling, knowledge operations, automation |
74
+ | **VS Code extension** | `vscode-extension/` | Timeline, knowledge navigation, issue management, collaborative UX |
75
+ | **Core platform** | `src/core/` | EAV store, kernel, ontology, query, agents, plugins |
76
+ | **Platform modules** | `src/vcs/`, `src/links/`, `src/embeddings/`, `src/decisions/` | Specialized subsystems for version control, knowledge, and intelligence |
60
77
 
61
78
  ---
62
79
 
@@ -96,27 +113,35 @@ bun run src/cli/index.ts import --from /path/to/git-repo
96
113
 
97
114
  ---
98
115
 
99
- ## Architecture Overview
116
+ ## Package Architecture
100
117
 
101
118
  ```
102
119
  trellis/
103
120
  ├── src/
104
- │ ├── core/ # EAV store + kernel types exposed as trellis/core
105
- │ ├── vcs/ # Ops, branches, milestones, checkpoints, diff, merge
106
- │ ├── git/ # Git import/export bridge
121
+ │ ├── core/ # EAV store, kernel, ontology, query, agents, plugins
122
+ ├── kernel/ # TrellisKernel with entity CRUD and middleware
123
+ ├── ontology/ # Schema registry, validation, built-in ontologies
124
+ │ │ ├── query/ # EQL-S query engine and Datalog evaluator
125
+ │ │ ├── agents/ # Agent harness, tool registry, decision traces
126
+ │ │ └── plugins/ # Plugin registry, event bus, workspace config
127
+ │ ├── vcs/ # Version control: ops, branches, milestones, diff, merge
107
128
  │ ├── links/ # Wiki-link parsing, resolution, backlink index
108
- │ ├── embeddings/ # Semantic indexing and vector search
129
+ │ ├── embeddings/ # Semantic indexing, vector search, auto-embed, RAG
109
130
  │ ├── decisions/ # Decision trace capture and querying
110
131
  │ ├── semantic/ # AST parsers, semantic diff, semantic merge
111
- │ ├── sync/ # Peer sync and reconciler
132
+ │ ├── sync/ # Peer sync, CRDT reconciler, HTTP/WebSocket transports, multi-repo
133
+ │ ├── garden/ # Idea Garden: abandoned work detection and revival
134
+ │ ├── git/ # Git import/export bridge
135
+ │ ├── identity/ # Ed25519 identity management and governance
112
136
  │ ├── watcher/ # File watching + ingestion pipeline
137
+ │ ├── mcp/ # Model Context Protocol server integration
113
138
  │ ├── cli/ # CLI entrypoint
114
139
  │ ├── engine.ts # Composition root
115
140
  │ └── index.ts # Main package entrypoint
116
141
  ├── vscode-extension/ # VS Code extension surface
117
- ├── test/ # Phase and subsystem tests
118
- ├── DESIGN.md # Detailed architecture spec
119
- └── justfile # Local build/release recipes
142
+ ├── test/ # Comprehensive test suites
143
+ ├── DESIGN.md # Detailed architecture specification
144
+ └── justfile # Local build and development recipes
120
145
  ```
121
146
 
122
147
  ### The Op Stream
@@ -218,20 +243,61 @@ trellis garden stats # Garden statistics
218
243
  ```bash
219
244
  trellis sync status # Local sync state
220
245
  trellis sync reconcile --remote <path> # Reconcile with another local repo
246
+ trellis sync push --peer <id> # Push ops to a peer (HTTP/WebSocket)
247
+ trellis sync pull --peer <id> # Pull ops from a peer
248
+ trellis link-repo <alias> <location> # Link a remote repo for cross-repo refs
249
+ ```
250
+
251
+ ### Query & Search
252
+
253
+ ```bash
254
+ trellis query "find Project where status = 'active'" # EQL-S structured query
255
+ trellis query-repl # Interactive query REPL
256
+ trellis ask "authentication code" # Natural language semantic search
257
+ trellis ask "show me auth code" --rag # Output as RAG context for LLMs
258
+ ```
259
+
260
+ ### Ontology
261
+
262
+ ```bash
263
+ trellis ontology list # List registered ontologies
264
+ trellis ontology show <id> # Show ontology details
265
+ trellis ontology validate # Validate store against ontologies
266
+ ```
267
+
268
+ ### Agents
269
+
270
+ ```bash
271
+ trellis agent list # List registered agents
272
+ trellis agent create <name> # Create a new agent definition
273
+ trellis agent run <id> --input "task" # Execute an agent run
274
+ trellis agent inspect <run-id> # View run details and decision traces
275
+ ```
276
+
277
+ ### Plugins
278
+
279
+ ```bash
280
+ trellis plugin list # List loaded plugins
281
+ trellis plugin add <id> # Register and load a plugin
282
+ trellis plugin remove <id> # Unload and unregister a plugin
221
283
  ```
222
284
 
223
285
  ---
224
286
 
225
287
  ## VS Code Extension
226
288
 
227
- The VS Code extension is the visual surface for Trellis.
289
+ The VS Code extension provides a rich visual interface for the entire Trellis platform, making knowledge navigation, collaboration, and project management intuitive and efficient.
290
+
291
+ ### Core Features
228
292
 
229
- - **Status view** — current branch, op count, tracked files, recent activity
230
- - **Causal stream** — browse ops as a readable event timeline
231
- - **Issues view** — inspect and manage issue state directly in the editor
232
- - **Kanban board** — move work across lifecycle stages visually
233
- - **Timeline panel** — inspect history as a richer interactive visualization
234
- - **Wiki-link UX** — click, hover, validate, and autocomplete `[[wiki-links]]`
293
+ - **Status Dashboard** — Real-time view of repository health, activity metrics, and system state
294
+ - **Causal Timeline** — Interactive exploration of the complete operation history with filtering and search
295
+ - **Knowledge Navigator** — Browse and traverse the wiki-link graph with visual connections
296
+ - **Issue Management** — Full lifecycle issue management with drag-and-drop workflow automation
297
+ - **Semantic Explorer** — Navigate code structure and relationships through AST-aware visualizations
298
+ - **Decision Inspector** — Review decision traces and understand the reasoning behind changes
299
+ - **Collaboration Hub** — Multi-repo federation view and cross-project relationship mapping
300
+ - **Intelligence Panel** — Semantic search, RAG context, and AI-powered insights
235
301
 
236
302
  The extension lives in [`vscode-extension/`](./vscode-extension) and publishes separately from the npm package.
237
303
 
@@ -239,7 +305,7 @@ The extension lives in [`vscode-extension/`](./vscode-extension) and publishes s
239
305
 
240
306
  ## Module & Subpath Guide
241
307
 
242
- The `trellis` package is intentionally split into subpaths so consumers can depend on the surface they actually need.
308
+ The `trellis` package is intentionally split into subpaths so consumers can depend on the specific capabilities they need, from core graph operations to advanced AI features.
243
309
 
244
310
  ### Published Package Surface
245
311
 
@@ -248,88 +314,104 @@ bun add trellis
248
314
  ```
249
315
 
250
316
  ```typescript
251
- // Main entry — engine + top-level API
317
+ // Main entry — full platform engine
252
318
  import { TrellisVcsEngine } from 'trellis';
253
319
 
254
- // Core store and kernel types
255
- import { EAVStore } from 'trellis/core';
256
- import type { Fact, Link } from 'trellis/core';
320
+ // Core graph foundation (independent of VCS)
321
+ import { EAVStore, TrellisKernel } from 'trellis/core';
322
+ import type { Fact, Link, EntityRecord } from 'trellis/core';
257
323
 
258
- // VCS primitives
324
+ // Version control primitives
259
325
  import type { VcsOp, VcsOpKind } from 'trellis/vcs';
260
326
 
261
- // Semantic search
327
+ // Knowledge and intelligence
262
328
  import { EmbeddingManager } from 'trellis/ai';
263
-
264
- // Wiki-linking
265
329
  import { parseFileRefs, resolveRef, RefIndex } from 'trellis/links';
266
-
267
- // Decision traces
268
330
  import { recordDecision, queryDecisions } from 'trellis/decisions';
269
331
  ```
270
332
 
271
- ### `trellis` — Engine Entry Point (`TrellisVcsEngine`)
333
+ ### `trellis` — Platform Engine (`TrellisVcsEngine`)
272
334
 
273
- The main entry point. Ties together the kernel, file watcher, op log, branches, milestones, identity, garden, semantic parser, and sync.
335
+ The main entry point that orchestrates the entire platform: kernel, file watcher, version control, knowledge graphs, semantic analysis, and collaboration features.
274
336
 
275
337
  ```typescript
276
338
  import { TrellisVcsEngine } from 'trellis';
277
339
 
278
340
  const engine = new TrellisVcsEngine({ rootPath: '/my/project' });
279
341
 
280
- // New repo
342
+ // Repository management
281
343
  await engine.initRepo();
282
-
283
- // Existing repo
284
344
  engine.open();
285
345
 
286
- // Core queries
287
- engine.getOps(); // All ops
346
+ // Core operations
347
+ engine.getOps(); // All operations
288
348
  engine.status(); // Branch, op count, files
289
- engine.log(); // Formatted op history
349
+ engine.log(); // Formatted history
290
350
  engine.getFiles(); // Currently tracked files
291
351
 
292
- // Branches
352
+ // Version control
293
353
  await engine.createBranch('feature/x');
294
- engine.switchBranch('feature/x');
295
- engine.listBranches();
296
- await engine.deleteBranch('feature/x');
297
-
298
- // Milestones
299
354
  await engine.createMilestone('Implement auth', { fromOpHash, toOpHash });
300
- engine.listMilestones();
301
355
 
302
- // Semantic parsing
356
+ // Semantic analysis
303
357
  engine.parseFile(content, 'src/auth.ts');
304
358
  engine.semanticDiff(oldContent, newContent, 'src/auth.ts');
305
359
 
306
- // Idea Garden
360
+ // Knowledge operations
307
361
  const garden = engine.garden();
308
362
  garden.listClusters();
309
363
  garden.search({ keyword: 'auth' });
310
- garden.revive(clusterId);
364
+
365
+ // Intelligence features
366
+ const embeddings = engine.embeddings();
367
+ await embeddings.search('authentication flow');
311
368
  ```
312
369
 
313
- ### `trellis/core` — Core Store
370
+ ### `trellis/core` — Graph Foundation
314
371
 
315
- The inlined core store layer exposes the EAV primitives and kernel-adjacent types that the rest of Trellis is built on.
372
+ The core graph layer exposes EAV primitives, ontology schemas, query engine, agent harness, and plugin system. This module is independent of version control and can be used for any graph-based application.
316
373
 
317
374
  ```typescript
318
- import { EAVStore } from 'trellis/core';
319
- import type { Fact, Link, KernelOp } from 'trellis/core';
375
+ import { EAVStore, TrellisKernel } from 'trellis/core';
376
+ import { OntologyRegistry, builtinOntologies } from 'trellis/core';
377
+ import { QueryEngine, parseQuery } from 'trellis/core';
378
+ import { AgentHarness } from 'trellis/core';
379
+ import { PluginRegistry, EventBus } from 'trellis/core';
380
+ import type { Fact, Link, KernelOp, AgentDef, PluginDef } from 'trellis/core';
381
+
382
+ // Graph operations
383
+ const kernel = new TrellisKernel({ backend, agentId: 'me' });
384
+ await kernel.createEntity('proj:1', 'Project', {
385
+ name: 'Trellis',
386
+ status: 'active',
387
+ });
388
+
389
+ // Ontology validation
390
+ const registry = new OntologyRegistry();
391
+ for (const o of builtinOntologies) registry.register(o);
320
392
 
321
- const store = new EAVStore();
393
+ // Graph queries
394
+ const query = parseQuery('find Project where status = "active"');
395
+ const results = new QueryEngine(store).eval(query);
396
+
397
+ // Agent orchestration
398
+ const harness = new AgentHarness(kernel);
399
+ await harness.createAgent({ name: 'Reviewer', status: 'active' });
400
+
401
+ // Plugin system
402
+ const plugins = new PluginRegistry();
403
+ plugins.register({ id: 'my:plugin', name: 'My Plugin', version: '1.0.0' });
322
404
  ```
323
405
 
324
- ### `trellis/vcs` — VCS Model
406
+ ### `trellis/vcs` — Version Control Model
325
407
 
326
- The VCS subpath exposes operation types and domain-level building blocks for branches, milestones, checkpoints, issues, diffing, merging, and blob storage.
408
+ The VCS subpath exposes operation types and domain-level building blocks for version control: branches, milestones, checkpoints, issues, diffing, merging, and blob storage.
327
409
 
328
- Use this subpath when you want Trellis domain types and behavior without importing the full engine surface.
410
+ Use this subpath when you want Trellis version control capabilities without the full platform surface.
329
411
 
330
- ### `trellis/links` — Wiki-Link References
412
+ ### `trellis/links` — Knowledge Graph & Wiki-Links
331
413
 
332
- Parse `[[wiki-links]]` from markdown, doc-comments, and source files. Resolve references to issues, files, symbols, milestones, and decisions. Build a bidirectional reference index.
414
+ Parse `[[wiki-links]]` from markdown, doc-comments, and source files. Resolve references to issues, files, symbols, milestones, and decisions. Build a bidirectional knowledge graph that connects all entities in your workspace.
333
415
 
334
416
  ```typescript
335
417
  import { parseFileRefs, resolveRef, RefIndex } from 'trellis/links';
@@ -339,11 +421,14 @@ const resolved = resolveRef(ref, context);
339
421
  const index = new RefIndex();
340
422
  index.indexFile('README.md', refs, context);
341
423
  index.getIncoming('issue:TRL-5');
424
+
425
+ // Cross-repository references
426
+ index.addCrossRepoLink('frontend', 'proj:app', 'backend', 'api:users');
342
427
  ```
343
428
 
344
- ### `trellis/ai` — Embeddings & Semantic Search
429
+ ### `trellis/ai` — Semantic Intelligence
345
430
 
346
- Embed issues, milestones, files, code entities, and decisions into a vector store for semantic search.
431
+ Advanced semantic capabilities: embed issues, milestones, files, code entities, and decisions into a vector store for intelligent search, discovery, and RAG (Retrieval-Augmented Generation).
347
432
 
348
433
  ```typescript
349
434
  import { EmbeddingManager } from 'trellis/ai';
@@ -351,11 +436,14 @@ import { EmbeddingManager } from 'trellis/ai';
351
436
  const manager = new EmbeddingManager(engine, { dbPath: 'embeddings.db' });
352
437
  await manager.reindex();
353
438
  const results = await manager.search('auth flow');
439
+
440
+ // RAG context for LLMs
441
+ const context = await manager.getRAGContext('authentication implementation');
354
442
  ```
355
443
 
356
- ### `trellis/decisions` — Decision Traces
444
+ ### `trellis/decisions` — Decision Intelligence
357
445
 
358
- Automatically capture tool invocations as auditable decision records. Enrich them with rationale via hooks and query them later by tool, entity, or chain.
446
+ Automatically capture tool invocations and agent decisions as auditable traces. Enrich them with rationale via hooks and query them later by tool, entity, or decision chain. Perfect for understanding how and why decisions were made.
359
447
 
360
448
  ```typescript
361
449
  import { recordDecision, queryDecisions } from 'trellis/decisions';
@@ -364,9 +452,12 @@ const dec = await recordDecision(ctx, {
364
452
  toolName: 'trellis_issue_create',
365
453
  input: { title: 'Add parser' },
366
454
  output: { id: 'TRL-5' },
455
+ rationale: 'Needed for TypeScript support',
367
456
  });
368
457
 
458
+ // Query decision patterns
369
459
  const decs = queryDecisions(ctx, { tool: 'trellis_issue_*' });
460
+ const chain = queryDecisions(ctx, { entity: 'TRL-5' }); // Full decision chain
370
461
  ```
371
462
 
372
463
  ### `src/garden/` — Idea Garden
@@ -384,6 +475,14 @@ garden.stats(); // { total, abandoned, draft, revived, totalOps, totalFiles }
384
475
  garden.revive('cluster:abc');
385
476
  ```
386
477
 
478
+ ### Platform Subsystem Guides
479
+
480
+ The following sections provide detailed guides for Trellis' internal subsystems. These are useful if you're contributing to the platform or extending its capabilities.
481
+
482
+ #### Knowledge Graph & Wiki-Links (`src/links/`)
483
+
484
+ Builds a bidirectional knowledge graph from wiki-link references across all workspace entities.
485
+
387
486
  **Detection heuristics:**
388
487
 
389
488
  | Heuristic | Trigger | Signal |
@@ -392,29 +491,29 @@ garden.revive('cluster:abc');
392
491
  | `revertDetector` | Complementary ops | Ops undone by a subsequent inverse op (add→delete, modify→revert) |
393
492
  | `staleBranchDetector` | Time + no milestone | Ops on non-`main` branches untouched >7 days without a milestone |
394
493
 
395
- ### `src/semantic/` — Semantic Patching
494
+ #### Semantic Intelligence (`src/semantic/`)
396
495
 
397
- Parses TypeScript/JavaScript into structural entities and computes semantic diffs.
496
+ Advanced TypeScript/JavaScript analysis with structural entity extraction and semantic diffing for intelligent code understanding.
398
497
 
399
498
  ```typescript
400
499
  import { typescriptParser, semanticMerge } from './src/semantic/index.js';
401
500
 
402
- // Parse
501
+ // Parse code into structural entities
403
502
  const result = typescriptParser.parse(source, 'file.ts');
404
503
  result.declarations; // ASTEntity[] — functions, classes, interfaces, enums, …
405
504
  result.imports; // ImportRelation[]
406
505
  result.exports; // ExportRelation[]
407
506
 
408
- // Diff
507
+ // Compute semantic differences
409
508
  const patches = typescriptParser.diff(oldResult, newResult);
410
509
  // SemanticPatch[] — symbolAdd | symbolRemove | symbolModify |
411
510
  // symbolRename | importAdd | importRemove | …
412
511
 
413
- // Merge (patch commutativity per DESIGN.md §4.4)
512
+ // Intelligent merging with conflict resolution
414
513
  const merged = semanticMerge(ourPatches, theirPatches, 'file.ts');
415
514
  merged.clean; // true if no conflicts
416
515
  merged.patches; // Merged patch list
417
- merged.conflicts; // SemanticMergeConflict[] — entity-level, with suggestion
516
+ merged.conflicts; // SemanticMergeConflict[] — entity-level, with suggestions
418
517
  ```
419
518
 
420
519
  ### `src/sync/` — Peer Sync
@@ -447,7 +546,55 @@ await engine.pullFrom('peer-b');
447
546
  engine.reconcileWith(remoteOps);
448
547
  ```
449
548
 
450
- These `src/*` sections are internal subsystem guides rather than published npm subpaths. They are useful if you are contributing to Trellis itself or navigating the codebase.
549
+ #### Collaboration & Sync (`src/sync/`)
550
+
551
+ Enterprise-grade synchronization with CRDT reconciliation, multiple transport protocols, and multi-repo federation for distributed teams.
552
+
553
+ ```typescript
554
+ import {
555
+ SyncEngine,
556
+ MemoryTransport,
557
+ reconcile,
558
+ HttpSyncTransport,
559
+ WebSocketSyncTransport,
560
+ MultiRepoManager,
561
+ formatCrossRepoRef,
562
+ } from './src/sync/index.js';
563
+
564
+ // CRDT reconciler for conflict-free merging
565
+ const result = reconcile(localOps, remoteOps);
566
+ result.merged; // Interleaved by timestamp
567
+ result.forkPoint; // Last common op hash
568
+ result.conflicts; // File-level conflicts
569
+
570
+ // HTTP transport for network sync
571
+ const httpTransport = new HttpSyncTransport('peer-a');
572
+ httpTransport.addPeer('peer-b', 'http://192.168.1.10:4200');
573
+
574
+ // WebSocket transport for real-time collaboration
575
+ const wsTransport = new WebSocketSyncTransport('peer-a');
576
+ await wsTransport.connect('peer-b', 'ws://192.168.1.10:4201');
577
+
578
+ // Multi-repo federation — connect knowledge across repositories
579
+ const repoManager = new MultiRepoManager(kernel);
580
+ await repoManager.linkRepo(
581
+ 'backend',
582
+ '/path/to/backend-api',
583
+ 'Backend service',
584
+ );
585
+ await repoManager.addCrossRepoLink(
586
+ 'proj:frontend',
587
+ 'dependsOn',
588
+ 'backend',
589
+ 'lib:api-client',
590
+ );
591
+ // Creates: proj:frontend --dependsOn--> @backend:lib:api-client
592
+
593
+ // Discover cross-repository relationships
594
+ const refs = repoManager.findReferencesTo('backend', 'lib:api-client');
595
+ ```
596
+
597
+ These subsystem guides provide insight into Trellis' internal architecture. They're particularly useful for platform contributors, extenders, or those building custom integrations.
451
598
 
452
599
  ---
453
600
 
@@ -513,14 +660,20 @@ Engine A sends 'have' { heads: { main: 'h42' }, opCount: 42 }
513
660
 
514
661
  ## Design Doc
515
662
 
516
- See [`DESIGN.md`](./DESIGN.md) for the full architecture specification, including:
663
+ See [`DESIGN.md`](./DESIGN.md) for the complete platform architecture specification, including:
517
664
 
518
665
  - §3 — Causal stream and branch concurrency model
519
- - §4 — Semantic patching: parser adapter interface, patch types, commutativity table
666
+ - §4 — Semantic patching: parser adapter interface, patch types, commutativity
520
667
  - §5 — Milestone narrative model
521
668
  - §6 — Identity, signing, and governance
522
669
  - §7 — Idea Garden cluster detection heuristics
523
- - §10Open questions and architectural trade-offs
670
+ - §8Knowledge graph and wiki-link system
671
+ - §9 — Embeddings and semantic search architecture
672
+ - §10 — Decision trace capture and querying
673
+ - §11 — Sync protocols and multi-repo federation
674
+ - §12 — Core graph kernel and ontology system
675
+ - §13 — Agent harness and plugin architecture
676
+ - §14 — Open questions and architectural trade-offs
524
677
 
525
678
  ---
526
679
 
@@ -575,23 +728,33 @@ just publish-dry-run
575
728
  just publish
576
729
  ```
577
730
 
578
- > **Requires [Bun](https://bun.sh) ≥ 1.0** — Trellis uses `bun:sqlite` for the vector store and Bun's native TS support.
731
+ > **Requires [Bun](https://bun.sh) ≥ 1.0** — Trellis uses `bun:sqlite` for the vector store and Bun's native TypeScript support for optimal performance.
579
732
 
580
733
  ---
581
734
 
582
735
  ## Roadmap
583
736
 
584
- | Phase | Deliverable | Status | Commit |
585
- | :---- | :---------------------------------------------- | :----- | :-------- |
586
- | P0 | Causal stream + CLI | ✅ | `51475d3` |
587
- | P0.5 | VS Code extension / visual timeline | ✅ | `947d5a1` |
588
- | P1 | Git import bridge | ✅ | `f4cc4a6` |
589
- | P2 | Branches, milestones, checkpoints | ✅ | `3f91e9a` |
590
- | P2.5 | Blob store, engine modularization, git exporter | ✅ | `5c43a31` |
591
- | P3 | File-level diff + text-based merge | ✅ | `c953654` |
592
- | P4 | Identity + op signing + governance | ✅ | `3acddda` |
593
- | P5 | Idea Garden — cluster detection + query | ✅ | `105a207` |
594
- | P6 | Semantic patching — parser adapter + diff/merge | ✅ | `22192ae` |
595
- | P7 | Peer sync + CRDT reconciler | ✅ | `d02f3f7` |
596
- | P8 | Wiki-links, embeddings, decision traces | ✅ | `b9cd5b7` |
597
- | P9 | npm package + VSCode extension publish | 🚧 | |
737
+ | Phase | Deliverable | Status | Commit |
738
+ | :---- | :------------------------------------------------- | :----- | :---------- |
739
+ | P0 | Causal stream + CLI | ✅ | `51475d3` |
740
+ | P0.5 | VS Code extension / visual timeline | ✅ | `947d5a1` |
741
+ | P1 | Git import bridge | ✅ | `f4cc4a6` |
742
+ | P2 | Branches, milestones, checkpoints | ✅ | `3f91e9a` |
743
+ | P2.5 | Blob store, engine modularization, git exporter | ✅ | `5c43a31` |
744
+ | P3 | File-level diff + text-based merge | ✅ | `c953654` |
745
+ | P4 | Identity + op signing + governance | ✅ | `3acddda` |
746
+ | P5 | Idea Garden — cluster detection + query | ✅ | `105a207` |
747
+ | P6 | Semantic patching — parser adapter + diff/merge | ✅ | `22192ae` |
748
+ | P7 | Peer sync + CRDT reconciler | ✅ | `d02f3f7` |
749
+ | P8 | Wiki-links, embeddings, decision traces | ✅ | `b9cd5b7` |
750
+ | P9 | npm package + VSCode extension publish | | `57bad37` |
751
+ | P10 | Graph kernel + SQLite backend + entity CRUD | ✅ | |
752
+ | P11 | EQL-S query engine + Datalog evaluator | ✅ | |
753
+ | P12 | Ontology system + validation middleware | ✅ | |
754
+ | P13 | Transformers.js upgrade + auto-embed + RAG | ✅ | |
755
+ | P14 | Agent harness + tool registry + decision traces | ✅ | |
756
+ | P15 | Plugin system + event bus + workspace config | ✅ | |
757
+ | P16 | Sync federation + multi-repo linking | ✅ | |
758
+ | P17 | Advanced knowledge graph + cross-repo intelligence | 🚧 | In Progress |
759
+ | P18 | Enterprise collaboration features + RBAC | 📋 | Planned |
760
+ | P19 | Advanced AI capabilities + intelligent automation | 📋 | Planned |