@driftless-sh/cli 0.1.22 → 0.1.23

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # Driftless CLI
2
2
 
3
- **Context integrity for AI engineering teams.**
3
+ **Living repo context for humans and coding agents.**
4
4
 
5
- Driftless is the shared codebase memory layer for engineering teams. The CLI lets you scan your repo, enforce architectural rules, and manage context watchers — the team's durable knowledge about how the codebase works.
5
+ Driftless scans your codebase, builds durable context about how it works, and delivers the right knowledge to the right person at the right time before changes are made.
6
6
 
7
7
  ```
8
8
  npm install -g @driftless-sh/cli
@@ -12,9 +12,10 @@ npm install -g @driftless-sh/cli
12
12
 
13
13
  ```bash
14
14
  driftless login --key <api-key> # Generate one at driftless.icu → Settings → API keys
15
- driftless init # Scan repo, upload baseline, suggest rules
16
- driftless scan --diff # Check uncommitted changes against rules
17
- driftless context get <name> # Load team context before coding
15
+ driftless init # Scan repo, bootstrap context, suggest rules
16
+ driftless session start # See relevant context before editing
17
+ driftless scan --diff # Check changes against rules before pushing
18
+ driftless session finish # Scan + context report + stale detection
18
19
  driftless install-skill # Write AGENTS.md for Claude Code / Cursor
19
20
  ```
20
21
 
@@ -58,7 +59,23 @@ cd my-nestjs-repo
58
59
  driftless init
59
60
  ```
60
61
 
61
- After init, Driftless suggests architectural rules based on detected patterns.
62
+ After init, Driftless suggests architectural rules based on detected patterns and creates context topics for each module.
63
+
64
+ ---
65
+
66
+ ### `driftless session`
67
+
68
+ The agent loop — start with context, finish with a report.
69
+
70
+ ```bash
71
+ driftless session start # Show context for local changes
72
+ driftless session start --files "src/auth/**" # Show context for specific files
73
+ driftless session finish # Scan changes, check violations, suggest updates
74
+ ```
75
+
76
+ **Before editing:** `session start` tells you which context topics, docs, and gotchas apply to the files you're about to touch.
77
+
78
+ **Before pushing:** `session finish` runs `scan --diff`, reports violations, and flags stale context that needs updating.
62
79
 
63
80
  ---
64
81
 
@@ -71,13 +88,21 @@ driftless scan # Scan staged + uncommitted changes
71
88
  driftless scan --diff # Scan uncommitted changes only
72
89
  ```
73
90
 
74
- Returns:
75
- ```json
76
- { "status": "clean", "violations": [] }
91
+ Output:
92
+ ```
93
+ Scanning uncommitted changes...
94
+ Files: src/sso/sso.controller.ts
95
+
96
+ Clean — 4 rule(s) evaluated, no violations.
77
97
  ```
78
- or
79
- ```json
80
- { "status": "violated", "violations": [{ "rule_id": "...", "explanation": "..." }] }
98
+
99
+ Or:
100
+ ```
101
+ 1 violation(s) found (4 rule(s) evaluated):
102
+
103
+ [HIGH] Controllers must be thin
104
+ Business logic detected in controller: "console.log('debug')" — move to a service
105
+ File: src/sso/sso.controller.ts:13
81
106
  ```
82
107
 
83
108
  Run this before every push. Agents should run it automatically before completing tasks.
@@ -86,31 +111,45 @@ Run this before every push. Agents should run it automatically before completing
86
111
 
87
112
  ### `driftless context`
88
113
 
89
- Manage **context watchers** — the team's shared codebase memory. Each watcher captures what a piece of the system is, how it works, where it lives, and why decisions were made.
114
+ Manage **context topics** — the team's shared codebase memory. Each topic captures what a piece of the system is, how it works, where it lives, and why decisions were made.
90
115
 
91
116
  #### Output format
92
117
 
93
- All commands output **JSON by default** for agent consumption. Use `--human` for readable text.
118
+ All commands output **human-readable text by default**. Use `--json` for machine output (agents, CI).
94
119
 
95
120
  ```bash
96
- driftless context get sdk # JSON (for Claude Code, Codex, etc.)
97
- driftless context get sdk --human # Readable text
121
+ driftless context list # Human-readable
122
+ driftless context list --json # For agents
123
+ driftless context get auth-boundaries # Full topic view
124
+ driftless context get auth-boundaries --json
98
125
  ```
99
126
 
100
127
  #### Subcommands
101
128
 
102
129
  | Command | Description |
103
130
  |---------|-------------|
104
- | `context list` | List all watchers |
105
- | `context get <slug>` | Get watcher with resolved components + history |
106
- | `context add <slug>` | Create new watcher |
107
- | `context update <slug>` | Update watcher fields |
108
- | `context delete <slug>` | Delete watcher |
109
- | `context search <query>` | Full-text search across watchers |
131
+ | `context list` | List all context topics |
132
+ | `context get <slug>` | Get topic with resolved components + history |
133
+ | `context add <slug>` | Create new topic |
134
+ | `context update <slug>` | Update topic fields |
135
+ | `context delete <slug>` | Delete a topic |
136
+ | `context search <query>` | Full-text search across topics |
137
+ | `context anchor <slug>` | Anchor a doc to a topic |
138
+ | `context push --files` | Match topics for given file paths |
139
+
140
+ #### Dry run
110
141
 
111
- #### Creating watchers
142
+ All write commands support `--dry-run` to preview changes without writing to Cloud:
112
143
 
113
- A watcher can track components in two ways:
144
+ ```bash
145
+ driftless context push --files "src/auth/**" --dry-run
146
+ driftless context update auth --what "..." --dry-run
147
+ driftless context anchor auth --doc docs/auth.md --dry-run
148
+ ```
149
+
150
+ #### Creating topics
151
+
152
+ A topic can track components in two ways:
114
153
 
115
154
  - **`--pattern`** — glob pattern that resolves dynamically (e.g. `src/sdk/**`)
116
155
  - **`--where`** — explicit file path
@@ -147,23 +186,26 @@ driftless context add "b2b-guard" \
147
186
  #### Examples
148
187
 
149
188
  ```bash
150
- # List all watchers
189
+ # List all topics
151
190
  driftless context list
152
191
 
153
- # Get watcher with resolved components (JSON)
192
+ # Get topic with resolved components
154
193
  driftless context get sdk
155
194
 
156
- # Get watcher with human-readable output
157
- driftless context get sdk --human
158
-
159
- # Search watchers
195
+ # Search topics
160
196
  driftless context search "auth"
161
197
  driftless context search "business guard"
162
198
 
163
- # Update a watcher
199
+ # Update a topic
164
200
  driftless context update sdk --what "SDK v2 with streaming"
165
201
 
166
- # Delete a watcher
202
+ # Append a gotcha
203
+ driftless context update sdk --gotchas "Reset token on org switch"
204
+
205
+ # Anchor a doc
206
+ driftless context anchor auth --doc docs/auth.md --files "src/auth/**"
207
+
208
+ # Delete a topic
167
209
  driftless context delete old-feature
168
210
  ```
169
211
 
@@ -184,6 +226,18 @@ driftless install-skill
184
226
 
185
227
  ---
186
228
 
229
+ ### `driftless doctor`
230
+
231
+ Check environment health before using Driftless.
232
+
233
+ ```bash
234
+ driftless doctor
235
+ ```
236
+
237
+ Verifies: API key, API reachable, git remote, workspace, repo link, baseline, AGENTS.md, GitHub App.
238
+
239
+ ---
240
+
187
241
  ### `driftless help`
188
242
 
189
243
  Show help for all commands or a specific command.
@@ -222,16 +276,16 @@ This creates `AGENTS.md` with instructions for Claude Code to use Driftless befo
222
276
 
223
277
  ```bash
224
278
  # Before starting work
225
- driftless context get <feature>
279
+ driftless session start --files "src/auth/**"
226
280
 
227
281
  # Before finishing work
228
- driftless scan --diff
282
+ driftless session finish
229
283
 
230
284
  # After discovering new context
231
285
  driftless context add "name" --what "..." --how "..." --where "..."
232
286
  ```
233
287
 
234
- All output is JSON by default, making it easy for agents to parse and use as context.
288
+ Use `--json` flag for machine-readable output that agents can parse.
235
289
 
236
290
  ## Architecture
237
291
 
@@ -252,7 +306,7 @@ driftless scan
252
306
  └── Return violations
253
307
 
254
308
  driftless context
255
- ├── CRUD watchers via REST API
309
+ ├── CRUD topics via REST API
256
310
  ├── Full-text search (Postgres tsvector)
257
311
  └── Pattern resolution (glob → resolved files)
258
312
  ```