trellis 1.0.8 → 2.0.6
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/LICENSE +21 -0
- package/README.md +564 -83
- package/bin/trellis.mjs +2 -0
- package/dist/cli/index.js +4718 -0
- package/dist/core/index.js +12 -0
- package/dist/decisions/index.js +19 -0
- package/dist/embeddings/index.js +43 -0
- package/dist/index-1j1anhmr.js +4038 -0
- package/dist/index-3s0eak0p.js +1556 -0
- package/dist/index-8pce39mh.js +272 -0
- package/dist/index-a76rekgs.js +67 -0
- package/dist/index-cy9k1g6v.js +684 -0
- package/dist/index-fd4e26s4.js +69 -0
- package/dist/{store/eav-store.js → index-gkvhzm9f.js} +4 -6
- package/dist/index-gnw8d7d6.js +51 -0
- package/dist/index-vkpkfwhq.js +817 -0
- package/dist/index.js +118 -2876
- package/dist/links/index.js +55 -0
- package/dist/transformers-m9je15kg.js +32491 -0
- package/dist/vcs/index.js +110 -0
- package/logo.png +0 -0
- package/logo.svg +9 -0
- package/package.json +79 -76
- package/src/cli/index.ts +2340 -0
- package/src/core/index.ts +35 -0
- package/src/core/kernel/middleware.ts +44 -0
- package/src/core/persist/backend.ts +64 -0
- package/src/core/store/eav-store.ts +467 -0
- package/src/decisions/auto-capture.ts +136 -0
- package/src/decisions/hooks.ts +163 -0
- package/src/decisions/index.ts +261 -0
- package/src/decisions/types.ts +103 -0
- package/src/embeddings/chunker.ts +327 -0
- package/src/embeddings/index.ts +41 -0
- package/src/embeddings/model.ts +95 -0
- package/src/embeddings/search.ts +305 -0
- package/src/embeddings/store.ts +313 -0
- package/src/embeddings/types.ts +85 -0
- package/src/engine.ts +1083 -0
- package/src/garden/cluster.ts +330 -0
- package/src/garden/garden.ts +306 -0
- package/src/garden/index.ts +29 -0
- package/src/git/git-exporter.ts +286 -0
- package/src/git/git-importer.ts +329 -0
- package/src/git/git-reader.ts +189 -0
- package/src/git/index.ts +22 -0
- package/src/identity/governance.ts +211 -0
- package/src/identity/identity.ts +224 -0
- package/src/identity/index.ts +30 -0
- package/src/identity/signing-middleware.ts +97 -0
- package/src/index.ts +20 -0
- package/src/links/index.ts +49 -0
- package/src/links/lifecycle.ts +400 -0
- package/src/links/parser.ts +484 -0
- package/src/links/ref-index.ts +186 -0
- package/src/links/resolver.ts +314 -0
- package/src/links/types.ts +108 -0
- package/src/mcp/index.ts +22 -0
- package/src/mcp/server.ts +1278 -0
- package/src/semantic/csharp-parser.ts +493 -0
- package/src/semantic/go-parser.ts +585 -0
- package/src/semantic/index.ts +34 -0
- package/src/semantic/java-parser.ts +456 -0
- package/src/semantic/python-parser.ts +659 -0
- package/src/semantic/ruby-parser.ts +446 -0
- package/src/semantic/rust-parser.ts +784 -0
- package/src/semantic/semantic-merge.ts +210 -0
- package/src/semantic/ts-parser.ts +681 -0
- package/src/semantic/types.ts +175 -0
- package/src/sync/index.ts +32 -0
- package/src/sync/memory-transport.ts +66 -0
- package/src/sync/reconciler.ts +237 -0
- package/src/sync/sync-engine.ts +258 -0
- package/src/sync/types.ts +104 -0
- package/src/vcs/blob-store.ts +124 -0
- package/src/vcs/branch.ts +150 -0
- package/src/vcs/checkpoint.ts +64 -0
- package/src/vcs/decompose.ts +469 -0
- package/src/vcs/diff.ts +409 -0
- package/src/vcs/engine-context.ts +26 -0
- package/src/vcs/index.ts +23 -0
- package/src/vcs/issue.ts +800 -0
- package/src/vcs/merge.ts +425 -0
- package/src/vcs/milestone.ts +124 -0
- package/src/vcs/ops.ts +59 -0
- package/src/vcs/types.ts +213 -0
- package/src/vcs/vcs-middleware.ts +81 -0
- package/src/watcher/fs-watcher.ts +217 -0
- package/src/watcher/index.ts +9 -0
- package/src/watcher/ingestion.ts +116 -0
- package/dist/ai/index.js +0 -688
- package/dist/cli/server.js +0 -3321
- package/dist/cli/tql.js +0 -5282
- package/dist/client/tql-client.js +0 -108
- package/dist/graph/index.js +0 -2248
- package/dist/kernel/logic-middleware.js +0 -179
- package/dist/kernel/middleware.js +0 -0
- package/dist/kernel/operations.js +0 -32
- package/dist/kernel/schema-middleware.js +0 -34
- package/dist/kernel/security-middleware.js +0 -53
- package/dist/kernel/trellis-kernel.js +0 -2239
- package/dist/kernel/workspace.js +0 -91
- package/dist/persist/backend.js +0 -0
- package/dist/persist/sqlite-backend.js +0 -123
- package/dist/query/index.js +0 -1643
- package/dist/server/index.js +0 -3309
- package/dist/workflows/index.js +0 -3160
package/README.md
CHANGED
|
@@ -1,116 +1,597 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="logo.png" alt="Trellis" width="128" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# Trellis
|
|
4
6
|
|
|
5
|
-
|
|
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.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Table of Contents
|
|
21
|
+
|
|
22
|
+
- [Trellis Overview](#trellis-overview)
|
|
23
|
+
- [Project Surfaces](#project-surfaces)
|
|
24
|
+
- [Quick Start](#quick-start)
|
|
25
|
+
- [CLI Overview](#cli-overview)
|
|
26
|
+
- [VS Code Extension](#vs-code-extension)
|
|
27
|
+
- [Module & Subpath Guide](#module--subpath-guide)
|
|
28
|
+
- [Architecture Overview](#architecture-overview)
|
|
29
|
+
- [Development & Releases](#development--releases)
|
|
30
|
+
- [Roadmap](#roadmap)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Trellis Overview
|
|
35
|
+
|
|
36
|
+
Trellis is an umbrella project with a few distinct surfaces that all sit on the same underlying model:
|
|
37
|
+
|
|
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.
|
|
42
|
+
|
|
43
|
+
The core idea stays the same across all of them:
|
|
44
|
+
|
|
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.
|
|
50
|
+
|
|
51
|
+
## Project Surfaces
|
|
52
|
+
|
|
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 |
|
|
60
|
+
|
|
61
|
+
---
|
|
6
62
|
|
|
7
63
|
## Quick Start
|
|
8
64
|
|
|
65
|
+
### Use the npm package
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
bun add trellis
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { TrellisVcsEngine } from 'trellis';
|
|
73
|
+
|
|
74
|
+
const engine = new TrellisVcsEngine({ rootPath: '/my/project' });
|
|
75
|
+
engine.open();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Work on the repo locally
|
|
79
|
+
|
|
9
80
|
```bash
|
|
10
81
|
# Install dependencies
|
|
11
82
|
bun install
|
|
12
83
|
|
|
13
|
-
#
|
|
14
|
-
bun run
|
|
84
|
+
# Initialize a new Trellis repo in the current directory
|
|
85
|
+
bun run src/cli/index.ts init
|
|
15
86
|
|
|
16
|
-
#
|
|
17
|
-
bun run
|
|
18
|
-
|
|
87
|
+
# Watch for file changes (continuous op stream)
|
|
88
|
+
bun run src/cli/index.ts watch
|
|
89
|
+
|
|
90
|
+
# Check status
|
|
91
|
+
bun run src/cli/index.ts status
|
|
19
92
|
|
|
20
|
-
|
|
93
|
+
# Import an existing Git repo
|
|
94
|
+
bun run src/cli/index.ts import --from /path/to/git-repo
|
|
95
|
+
```
|
|
21
96
|
|
|
22
|
-
|
|
23
|
-
- **Event Sourcing** – Content-addressed operation log with causality tracking (hashing, agent metadata, linked chains).
|
|
24
|
-
- **Multi-Modal Querying** –
|
|
25
|
-
- **EQL-S**: A strict SQL-like DSL for entities and relationships.
|
|
26
|
-
- **Datalog**: Direct access to the semi-naive evaluator for recursive and complex logic.
|
|
27
|
-
- **Natural Language**: AI-powered translation of human intent into structured queries.
|
|
28
|
-
- **Declarative Workspaces** – Boot entire environments from `.trellis` files containing ontologies (schemas), projections (views), and graph data.
|
|
29
|
-
- **Middleware System** – Async-aware hooks for security (capability-based), schema enforcement, and logic (formulas, rollups).
|
|
30
|
-
- **Time-Travel** – Query the state of your graph at any specific operation hash or historical timestamp.
|
|
97
|
+
---
|
|
31
98
|
|
|
32
|
-
##
|
|
99
|
+
## Architecture Overview
|
|
33
100
|
|
|
34
101
|
```
|
|
102
|
+
trellis/
|
|
35
103
|
├── src/
|
|
36
|
-
│ ├──
|
|
37
|
-
│ ├──
|
|
38
|
-
│ ├──
|
|
39
|
-
│ ├──
|
|
40
|
-
│ ├──
|
|
41
|
-
│ ├──
|
|
42
|
-
│
|
|
43
|
-
├──
|
|
44
|
-
|
|
104
|
+
│ ├── core/ # EAV store + kernel types exposed as trellis/core
|
|
105
|
+
│ ├── vcs/ # Ops, branches, milestones, checkpoints, diff, merge
|
|
106
|
+
│ ├── git/ # Git import/export bridge
|
|
107
|
+
│ ├── links/ # Wiki-link parsing, resolution, backlink index
|
|
108
|
+
│ ├── embeddings/ # Semantic indexing and vector search
|
|
109
|
+
│ ├── decisions/ # Decision trace capture and querying
|
|
110
|
+
│ ├── semantic/ # AST parsers, semantic diff, semantic merge
|
|
111
|
+
│ ├── sync/ # Peer sync and reconciler
|
|
112
|
+
│ ├── watcher/ # File watching + ingestion pipeline
|
|
113
|
+
│ ├── cli/ # CLI entrypoint
|
|
114
|
+
│ ├── engine.ts # Composition root
|
|
115
|
+
│ └── index.ts # Main package entrypoint
|
|
116
|
+
├── vscode-extension/ # VS Code extension surface
|
|
117
|
+
├── test/ # Phase and subsystem tests
|
|
118
|
+
├── DESIGN.md # Detailed architecture spec
|
|
119
|
+
└── justfile # Local build/release recipes
|
|
45
120
|
```
|
|
46
121
|
|
|
47
|
-
|
|
122
|
+
### The Op Stream
|
|
48
123
|
|
|
49
|
-
|
|
124
|
+
Every action in Trellis is an immutable `VcsOp`:
|
|
50
125
|
|
|
51
126
|
```typescript
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
await kernel.boot(
|
|
61
|
-
[
|
|
62
|
-
{ id: 1, title: 'Build Trellis', status: 'active' },
|
|
63
|
-
{ id: 2, title: 'Release Kernel', status: 'planning' },
|
|
64
|
-
],
|
|
65
|
-
{ entityType: 'Task' },
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// Query with EQL-S
|
|
69
|
-
const res = await kernel.query(
|
|
70
|
-
'FIND Task AS ?t WHERE ?t.status = "active" RETURN ?t.title',
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
console.log(res.rows); // [{ "?t.title": "Build Trellis" }]
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Declarative Workspace (.trellis)
|
|
77
|
-
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"workspace": {
|
|
81
|
-
"name": "My Projects",
|
|
82
|
-
"ontologies": {
|
|
83
|
-
"trellis:schema/project": {
|
|
84
|
-
/* schema def */
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"graph": {
|
|
88
|
-
"nodes": [{ "@id": "p1", "@type": "Project", "name": "Web App" }]
|
|
89
|
-
},
|
|
90
|
-
"projections": {
|
|
91
|
-
"active-view": { "name": "Active", "query": "FIND Project AS ?p ..." }
|
|
92
|
-
}
|
|
93
|
-
}
|
|
127
|
+
interface VcsOp {
|
|
128
|
+
hash: string; // trellis:op:<sha256> — content-addressed
|
|
129
|
+
kind: VcsOpKind; // e.g. 'vcs:fileModify'
|
|
130
|
+
timestamp: string; // ISO 8601
|
|
131
|
+
agentId: string; // Author identity (DID)
|
|
132
|
+
previousHash?: string; // Causal chain link
|
|
133
|
+
vcs: VcsPayload; // Op-specific data (filePath, contentHash, …)
|
|
134
|
+
signature?: string; // Ed25519 signature (P4+)
|
|
94
135
|
}
|
|
95
136
|
```
|
|
96
137
|
|
|
138
|
+
Ops are written to `.trellis/ops.json` and replayed into an in-memory EAV graph on startup. They are **never rewritten or deleted**.
|
|
139
|
+
|
|
140
|
+
### Op Tiers
|
|
141
|
+
|
|
142
|
+
| Tier | Kinds | Description |
|
|
143
|
+
| :---- | :---------------------------------------------------------- | :-------------------------------- |
|
|
144
|
+
| **0** | `fileAdd`, `fileModify`, `fileDelete`, `fileRename` | File-level mutations from watcher |
|
|
145
|
+
| **1** | `dirAdd`, `dirDelete`, `branchCreate`, `milestoneCreate`, … | Structural VCS control ops |
|
|
146
|
+
| **2** | `symbolRename`, `symbolMove`, `symbolExtract` | AST-level semantic patches |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## CLI Overview
|
|
151
|
+
|
|
152
|
+
The CLI is the operational surface for Trellis repositories. It is the fastest way to initialize repos, inspect history, create milestones, diff/merge work, and script automation around the op stream.
|
|
153
|
+
|
|
154
|
+
### Repository Setup
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
trellis init [--path <dir>] # Initialize a new repo
|
|
158
|
+
trellis import --from <git-repo> # Import Git history as milestones
|
|
159
|
+
trellis export --to <dir> # Export milestones to Git commits
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Working
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
trellis status # Current branch, op count, pending changes
|
|
166
|
+
trellis log [--limit N] [--branch b] # Op stream history
|
|
167
|
+
trellis files [--deleted] # All tracked files
|
|
168
|
+
trellis watch # Start continuous file watching
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Branches
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
trellis branch # List branches
|
|
175
|
+
trellis branch <name> # Create a branch
|
|
176
|
+
trellis branch -d <name> # Delete a branch
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Milestones & Checkpoints
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
trellis milestone create -m "message" # Create milestone
|
|
183
|
+
trellis milestone create -m "msg" --from <hash> --to <hash> # Over a specific range
|
|
184
|
+
trellis milestone list # List milestones
|
|
185
|
+
trellis checkpoint create # Manual checkpoint
|
|
186
|
+
trellis checkpoint list # List checkpoints
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Diff & Merge
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
trellis diff [--from <hash>] [--to <hash>] # File-level diff
|
|
193
|
+
trellis merge --branch <name> [--dry-run] # Three-way merge
|
|
194
|
+
trellis parse <file> # Semantic parse (declarations, imports)
|
|
195
|
+
trellis sdiff <fileA> <fileB> # Semantic diff between two versions
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Identity & Governance
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
trellis identity [show|create|list] # Manage identities
|
|
202
|
+
trellis governance [list|add|remove] # Manage policy rules
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Idea Garden
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
trellis garden # List abandoned clusters
|
|
209
|
+
trellis garden list [--status <s>] [--file <f>] # Filter clusters
|
|
210
|
+
trellis garden show <cluster-id> # Inspect a cluster
|
|
211
|
+
trellis garden search --keyword <term> # Search by keyword
|
|
212
|
+
trellis garden revive <cluster-id> # Revive cluster as branch
|
|
213
|
+
trellis garden stats # Garden statistics
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Sync
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
trellis sync status # Local sync state
|
|
220
|
+
trellis sync reconcile --remote <path> # Reconcile with another local repo
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## VS Code Extension
|
|
226
|
+
|
|
227
|
+
The VS Code extension is the visual surface for Trellis.
|
|
228
|
+
|
|
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]]`
|
|
235
|
+
|
|
236
|
+
The extension lives in [`vscode-extension/`](./vscode-extension) and publishes separately from the npm package.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Module & Subpath Guide
|
|
241
|
+
|
|
242
|
+
The `trellis` package is intentionally split into subpaths so consumers can depend on the surface they actually need.
|
|
243
|
+
|
|
244
|
+
### Published Package Surface
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
bun add trellis
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
// Main entry — engine + top-level API
|
|
252
|
+
import { TrellisVcsEngine } from 'trellis';
|
|
253
|
+
|
|
254
|
+
// Core store and kernel types
|
|
255
|
+
import { EAVStore } from 'trellis/core';
|
|
256
|
+
import type { Fact, Link } from 'trellis/core';
|
|
257
|
+
|
|
258
|
+
// VCS primitives
|
|
259
|
+
import type { VcsOp, VcsOpKind } from 'trellis/vcs';
|
|
260
|
+
|
|
261
|
+
// Semantic search
|
|
262
|
+
import { EmbeddingManager } from 'trellis/ai';
|
|
263
|
+
|
|
264
|
+
// Wiki-linking
|
|
265
|
+
import { parseFileRefs, resolveRef, RefIndex } from 'trellis/links';
|
|
266
|
+
|
|
267
|
+
// Decision traces
|
|
268
|
+
import { recordDecision, queryDecisions } from 'trellis/decisions';
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### `trellis` — Engine Entry Point (`TrellisVcsEngine`)
|
|
272
|
+
|
|
273
|
+
The main entry point. Ties together the kernel, file watcher, op log, branches, milestones, identity, garden, semantic parser, and sync.
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
import { TrellisVcsEngine } from 'trellis';
|
|
277
|
+
|
|
278
|
+
const engine = new TrellisVcsEngine({ rootPath: '/my/project' });
|
|
279
|
+
|
|
280
|
+
// New repo
|
|
281
|
+
await engine.initRepo();
|
|
282
|
+
|
|
283
|
+
// Existing repo
|
|
284
|
+
engine.open();
|
|
285
|
+
|
|
286
|
+
// Core queries
|
|
287
|
+
engine.getOps(); // All ops
|
|
288
|
+
engine.status(); // Branch, op count, files
|
|
289
|
+
engine.log(); // Formatted op history
|
|
290
|
+
engine.getFiles(); // Currently tracked files
|
|
291
|
+
|
|
292
|
+
// Branches
|
|
293
|
+
await engine.createBranch('feature/x');
|
|
294
|
+
engine.switchBranch('feature/x');
|
|
295
|
+
engine.listBranches();
|
|
296
|
+
await engine.deleteBranch('feature/x');
|
|
297
|
+
|
|
298
|
+
// Milestones
|
|
299
|
+
await engine.createMilestone('Implement auth', { fromOpHash, toOpHash });
|
|
300
|
+
engine.listMilestones();
|
|
301
|
+
|
|
302
|
+
// Semantic parsing
|
|
303
|
+
engine.parseFile(content, 'src/auth.ts');
|
|
304
|
+
engine.semanticDiff(oldContent, newContent, 'src/auth.ts');
|
|
305
|
+
|
|
306
|
+
// Idea Garden
|
|
307
|
+
const garden = engine.garden();
|
|
308
|
+
garden.listClusters();
|
|
309
|
+
garden.search({ keyword: 'auth' });
|
|
310
|
+
garden.revive(clusterId);
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### `trellis/core` — Core Store
|
|
314
|
+
|
|
315
|
+
The inlined core store layer exposes the EAV primitives and kernel-adjacent types that the rest of Trellis is built on.
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { EAVStore } from 'trellis/core';
|
|
319
|
+
import type { Fact, Link, KernelOp } from 'trellis/core';
|
|
320
|
+
|
|
321
|
+
const store = new EAVStore();
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### `trellis/vcs` — VCS Model
|
|
325
|
+
|
|
326
|
+
The VCS subpath exposes operation types and domain-level building blocks for branches, milestones, checkpoints, issues, diffing, merging, and blob storage.
|
|
327
|
+
|
|
328
|
+
Use this subpath when you want Trellis domain types and behavior without importing the full engine surface.
|
|
329
|
+
|
|
330
|
+
### `trellis/links` — Wiki-Link References
|
|
331
|
+
|
|
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.
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
import { parseFileRefs, resolveRef, RefIndex } from 'trellis/links';
|
|
336
|
+
|
|
337
|
+
const refs = parseFileRefs('src/engine.ts', source);
|
|
338
|
+
const resolved = resolveRef(ref, context);
|
|
339
|
+
const index = new RefIndex();
|
|
340
|
+
index.indexFile('README.md', refs, context);
|
|
341
|
+
index.getIncoming('issue:TRL-5');
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### `trellis/ai` — Embeddings & Semantic Search
|
|
345
|
+
|
|
346
|
+
Embed issues, milestones, files, code entities, and decisions into a vector store for semantic search.
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import { EmbeddingManager } from 'trellis/ai';
|
|
350
|
+
|
|
351
|
+
const manager = new EmbeddingManager(engine, { dbPath: 'embeddings.db' });
|
|
352
|
+
await manager.reindex();
|
|
353
|
+
const results = await manager.search('auth flow');
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### `trellis/decisions` — Decision Traces
|
|
357
|
+
|
|
358
|
+
Automatically capture tool invocations as auditable decision records. Enrich them with rationale via hooks and query them later by tool, entity, or chain.
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
import { recordDecision, queryDecisions } from 'trellis/decisions';
|
|
362
|
+
|
|
363
|
+
const dec = await recordDecision(ctx, {
|
|
364
|
+
toolName: 'trellis_issue_create',
|
|
365
|
+
input: { title: 'Add parser' },
|
|
366
|
+
output: { id: 'TRL-5' },
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const decs = queryDecisions(ctx, { tool: 'trellis_issue_*' });
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### `src/garden/` — Idea Garden
|
|
373
|
+
|
|
374
|
+
Detects abandoned work using three heuristics, then exposes a query API.
|
|
375
|
+
|
|
97
376
|
```typescript
|
|
98
|
-
|
|
99
|
-
|
|
377
|
+
import { detectClusters, IdeaGarden } from './src/garden/index.js';
|
|
378
|
+
|
|
379
|
+
const clusters = detectClusters(ops, milestonedHashes);
|
|
380
|
+
const garden = new IdeaGarden(ops, milestones);
|
|
381
|
+
|
|
382
|
+
garden.search({ file: 'auth.ts', status: 'abandoned', limit: 10 });
|
|
383
|
+
garden.stats(); // { total, abandoned, draft, revived, totalOps, totalFiles }
|
|
384
|
+
garden.revive('cluster:abc');
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Detection heuristics:**
|
|
388
|
+
|
|
389
|
+
| Heuristic | Trigger | Signal |
|
|
390
|
+
| :---------------------- | :------------------ | :---------------------------------------------------------------- |
|
|
391
|
+
| `contextSwitchDetector` | File-set pivot | Group of ops in unrelated dirs followed by a context switch away |
|
|
392
|
+
| `revertDetector` | Complementary ops | Ops undone by a subsequent inverse op (add→delete, modify→revert) |
|
|
393
|
+
| `staleBranchDetector` | Time + no milestone | Ops on non-`main` branches untouched >7 days without a milestone |
|
|
394
|
+
|
|
395
|
+
### `src/semantic/` — Semantic Patching
|
|
396
|
+
|
|
397
|
+
Parses TypeScript/JavaScript into structural entities and computes semantic diffs.
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
import { typescriptParser, semanticMerge } from './src/semantic/index.js';
|
|
401
|
+
|
|
402
|
+
// Parse
|
|
403
|
+
const result = typescriptParser.parse(source, 'file.ts');
|
|
404
|
+
result.declarations; // ASTEntity[] — functions, classes, interfaces, enums, …
|
|
405
|
+
result.imports; // ImportRelation[]
|
|
406
|
+
result.exports; // ExportRelation[]
|
|
407
|
+
|
|
408
|
+
// Diff
|
|
409
|
+
const patches = typescriptParser.diff(oldResult, newResult);
|
|
410
|
+
// SemanticPatch[] — symbolAdd | symbolRemove | symbolModify |
|
|
411
|
+
// symbolRename | importAdd | importRemove | …
|
|
412
|
+
|
|
413
|
+
// Merge (patch commutativity per DESIGN.md §4.4)
|
|
414
|
+
const merged = semanticMerge(ourPatches, theirPatches, 'file.ts');
|
|
415
|
+
merged.clean; // true if no conflicts
|
|
416
|
+
merged.patches; // Merged patch list
|
|
417
|
+
merged.conflicts; // SemanticMergeConflict[] — entity-level, with suggestion
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### `src/sync/` — Peer Sync
|
|
421
|
+
|
|
422
|
+
Implements the have→want→ops→ack protocol with linear and CRDT branch modes.
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
import { SyncEngine, MemoryTransport, reconcile } from './src/sync/index.js';
|
|
426
|
+
|
|
427
|
+
// Standalone CRDT reconciler
|
|
428
|
+
const result = reconcile(localOps, remoteOps);
|
|
429
|
+
result.merged; // Interleaved by timestamp
|
|
430
|
+
result.forkPoint; // Last common op hash
|
|
431
|
+
result.conflicts; // File-level conflicts
|
|
432
|
+
|
|
433
|
+
// Full sync engine
|
|
434
|
+
const transport = new MemoryTransport('peer-a', 'Alice');
|
|
435
|
+
const engine = new SyncEngine({
|
|
436
|
+
localPeerId: 'peer-a',
|
|
437
|
+
transport,
|
|
438
|
+
getLocalOps: () => ops,
|
|
439
|
+
onOpsReceived: (newOps) => {
|
|
440
|
+
/* integrate */
|
|
441
|
+
},
|
|
442
|
+
branchPolicy: { linear: false }, // CRDT mode
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
await engine.pushTo('peer-b');
|
|
446
|
+
await engine.pullFrom('peer-b');
|
|
447
|
+
engine.reconcileWith(remoteOps);
|
|
448
|
+
```
|
|
449
|
+
|
|
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.
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## How It Works
|
|
455
|
+
|
|
456
|
+
### Init Flow
|
|
457
|
+
|
|
458
|
+
```
|
|
459
|
+
trellis init
|
|
460
|
+
→ mkdirSync .trellis/
|
|
461
|
+
→ write config.json (agentId, defaultBranch, ignorePatterns)
|
|
462
|
+
→ create vcs:branchCreate op for "main"
|
|
463
|
+
→ scan filesystem → create vcs:fileAdd op per file
|
|
464
|
+
→ flush ops to .trellis/ops.json
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Watch Flow
|
|
468
|
+
|
|
469
|
+
```
|
|
470
|
+
trellis watch
|
|
471
|
+
→ FileWatcher.scan() populates known-files map
|
|
472
|
+
→ FileWatcher.start() sets up Bun fs.watch
|
|
473
|
+
→ on change → debounce → SHA-256 hash → emit FileChangeEvent
|
|
474
|
+
→ Ingestion.process(event) → createVcsOp(kind, payload)
|
|
475
|
+
→ engine.applyOp(op) → EAV store + op log
|
|
476
|
+
→ auto-checkpoint if threshold crossed
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Milestone Flow
|
|
480
|
+
|
|
481
|
+
```
|
|
482
|
+
trellis milestone create -m "Add auth"
|
|
483
|
+
→ auto-detect fromOpHash (last milestone's toOpHash + 1)
|
|
484
|
+
→ collect affected files from ops in range
|
|
485
|
+
→ createVcsOp('vcs:milestoneCreate', { message, fromOpHash, toOpHash, affectedFiles })
|
|
486
|
+
→ optional: trellis export → Git commit
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### Semantic Diff Flow
|
|
490
|
+
|
|
491
|
+
```
|
|
492
|
+
trellis sdiff old.ts new.ts
|
|
493
|
+
→ typescriptParser.parse(old) → ParseResult { declarations, imports, exports }
|
|
494
|
+
→ typescriptParser.parse(new) → ParseResult
|
|
495
|
+
→ typescriptParser.diff(old, new) → SemanticPatch[]
|
|
496
|
+
- symbolAdd / symbolRemove / symbolModify
|
|
497
|
+
- symbolRename (detected via signature similarity)
|
|
498
|
+
- importAdd / importRemove / importModify
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### Sync / Reconcile Flow
|
|
502
|
+
|
|
503
|
+
```
|
|
504
|
+
Engine A sends 'have' { heads: { main: 'h42' }, opCount: 42 }
|
|
505
|
+
→ Engine B compares to its own heads
|
|
506
|
+
→ B sends 'want' { afterHash: 'h38' }
|
|
507
|
+
→ A sends 'ops' [ op39, op40, op41, op42 ]
|
|
508
|
+
→ B integrates new ops (linear: filter dupes; CRDT: reconcile())
|
|
509
|
+
→ B sends 'ack' { integrated: ['h39', …] }
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Design Doc
|
|
515
|
+
|
|
516
|
+
See [`DESIGN.md`](./DESIGN.md) for the full architecture specification, including:
|
|
517
|
+
|
|
518
|
+
- §3 — Causal stream and branch concurrency model
|
|
519
|
+
- §4 — Semantic patching: parser adapter interface, patch types, commutativity table
|
|
520
|
+
- §5 — Milestone narrative model
|
|
521
|
+
- §6 — Identity, signing, and governance
|
|
522
|
+
- §7 — Idea Garden cluster detection heuristics
|
|
523
|
+
- §10 — Open questions and architectural trade-offs
|
|
524
|
+
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
## Development & Releases
|
|
528
|
+
|
|
529
|
+
### Prerequisites
|
|
530
|
+
|
|
531
|
+
- [Bun](https://bun.sh) ≥ 1.0
|
|
532
|
+
- No other native dependencies
|
|
533
|
+
|
|
534
|
+
### Install
|
|
535
|
+
|
|
536
|
+
```bash
|
|
537
|
+
bun install
|
|
100
538
|
```
|
|
101
539
|
|
|
102
|
-
|
|
540
|
+
### Test
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
just test-core
|
|
544
|
+
# or run the full suite when working on those areas:
|
|
545
|
+
bun test
|
|
546
|
+
```
|
|
103
547
|
|
|
104
|
-
|
|
105
|
-
- [EAV Engine Guide](docs/EAV-README.md) – Deep dive into the storage layer.
|
|
106
|
-
- [Workflows & Agent Graphs](docs/WORKFLOWS.md) – High-level automation.
|
|
548
|
+
**The release flow currently validates against the targeted passing core suite.**
|
|
107
549
|
|
|
108
|
-
|
|
550
|
+
### Typecheck
|
|
109
551
|
|
|
110
552
|
```bash
|
|
111
|
-
bun run typecheck
|
|
112
|
-
bun run test # Run Vitest suites
|
|
113
|
-
bun run clean # Clean build artifacts
|
|
553
|
+
bun run typecheck
|
|
114
554
|
```
|
|
115
555
|
|
|
116
|
-
|
|
556
|
+
### Build
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
# Build for npm (bun build → dist/)
|
|
560
|
+
bun run build
|
|
561
|
+
|
|
562
|
+
# Run CLI directly during development
|
|
563
|
+
bun run src/cli/index.ts <command>
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
### Release Workflow
|
|
569
|
+
|
|
570
|
+
```bash
|
|
571
|
+
# Validate locally without publishing
|
|
572
|
+
just publish-dry-run
|
|
573
|
+
|
|
574
|
+
# Publish to npm locally, then tag/push/create release metadata
|
|
575
|
+
just publish
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
> **Requires [Bun](https://bun.sh) ≥ 1.0** — Trellis uses `bun:sqlite` for the vector store and Bun's native TS support.
|
|
579
|
+
|
|
580
|
+
---
|
|
581
|
+
|
|
582
|
+
## Roadmap
|
|
583
|
+
|
|
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 | 🚧 | |
|
package/bin/trellis.mjs
ADDED