@dryvcode/cli 0.0.1

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 (3) hide show
  1. package/README.md +253 -0
  2. package/dist/dryv.js +15173 -0
  3. package/package.json +46 -0
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # Dryv CLI
2
+
3
+ The Dryv CLI is the filesystem-owning TypeScript client for Dryv. It reads local Dryv bootstrap inputs and resources, communicates with the Dryv API, displays validation/planning/generation results, previews generated diffs, and applies approved artifact changes back to the project.
4
+
5
+ The API, engine, and template plugins do not receive ambient authority to access the user's real filesystem or Git credentials.
6
+
7
+ ## Install
8
+
9
+ The published package runs on **Node.js 22+** or **Bun 1.3+**, and installs with any package manager:
10
+
11
+ ```bash
12
+ npm install --global @dryvcode/cli
13
+ pnpm add --global @dryvcode/cli
14
+ yarn global add @dryvcode/cli
15
+ bun add --global @dryvcode/cli
16
+ ```
17
+
18
+ Or run it without installing: `npx @dryvcode/cli --help`, or `bunx @dryvcode/cli --help`.
19
+
20
+ The package ships one bundled file, `dist/dryv.js` (a `node` shebang, no runtime dependencies), built from the TypeScript source by `bun run build`. Process, `which` and sleep helpers live in `src/platform/process.ts` and behave the same on both runtimes.
21
+
22
+ ## Development
23
+
24
+ Repository development uses Bun. `bin/dryv.ts` runs the TypeScript source directly.
25
+
26
+ Install dependencies:
27
+
28
+ ```text
29
+ cd apps/cli
30
+ bun install
31
+ ```
32
+
33
+ `bun install` creates/updates `bun.lock`; commit that lockfile for reproducible installs. CI or other frozen environments should use:
34
+
35
+ ```text
36
+ bun install --frozen-lockfile
37
+ ```
38
+
39
+ Run the CLI from the repository:
40
+
41
+ ```text
42
+ bun run start -- --help
43
+ ```
44
+
45
+ or directly:
46
+
47
+ ```text
48
+ bun ./bin/dryv.ts --help
49
+ ```
50
+
51
+ Run all checks:
52
+
53
+ ```text
54
+ bun run check
55
+ ```
56
+
57
+ This performs the TypeScript type-check through Bun and then runs the Bun test runner.
58
+
59
+ `bun run check` also builds `dist/dryv.js` and smoke-tests it with Node.
60
+
61
+ ## Commands
62
+
63
+ ```text
64
+ dryv capabilities
65
+ dryv info
66
+ dryv build
67
+ dryv ir build
68
+ dryv validate
69
+ dryv plan
70
+ dryv generate
71
+ ```
72
+
73
+ The API defaults to `http://127.0.0.1:8750`. Override it with either:
74
+
75
+ ```text
76
+ dryv validate --api https://dryv.example.com
77
+ ```
78
+
79
+ or `DRYV_API_URL`.
80
+
81
+ ### `dryv capabilities`
82
+
83
+ Inspects the local environment only. It reports whether this client can read/write the workspace and whether native local/Git pack resolvers are available. A capability means the mechanism is available; it does not claim every referenced resource is accessible.
84
+
85
+ Native Git resolution uses the user's existing Git environment such as SSH agents and credential helpers. Dryv does not store Git credentials. Git subprocesses are launched through `Bun.spawn()` and inherit the user's environment.
86
+
87
+ ### `dryv info`
88
+
89
+ Reads `GET /` and displays the Dryv API and engine capabilities.
90
+
91
+ ### `dryv build`
92
+
93
+ Compiles an authored source into canonical Runtime IR through the selected author/compiler provider and Runtime ingestion pipeline. The completed build is validated by the Runtime but is not written to disk.
94
+
95
+ ### `dryv ir build`
96
+
97
+ Compiles authored source and writes a portable canonical Runtime IR artifact. By default it writes:
98
+
99
+ ```text
100
+ .dryv/ir/dryv.ir.yaml
101
+ ```
102
+
103
+ Available formats:
104
+
105
+ ```text
106
+ dryv ir build --format yaml
107
+ dryv ir build --format json
108
+ dryv ir build --format jsonl
109
+ dryv ir build --all
110
+ ```
111
+
112
+ This command does not require a generation pack. An author-only usage document may use `packs: {}`.
113
+
114
+ ### `dryv validate`
115
+
116
+ The current API compatibility flow still loads the local workspace as typed `VirtualFile` values and sends an `EngineRequest` to `POST /v1/validate`.
117
+
118
+ ### `dryv plan`
119
+
120
+ The current API compatibility flow uploads the same virtual workspace to `POST /v1/plan` and displays planned artifact paths and trace references without changing local files.
121
+
122
+ ### `dryv generate`
123
+
124
+ Uses Bun's built-in WebSocket client to connect to `WS /v1/generate`, reconstruct streamed generated artifacts, compare those artifacts with the real workspace, and print unified diffs before any mutation.
125
+
126
+ By default an interactive terminal asks before applying changes.
127
+
128
+ ```text
129
+ dryv generate --dry-run # diff only; never write
130
+ dryv generate --check # diff only; exit 1 when output differs
131
+ dryv generate --yes # apply without prompting
132
+ ```
133
+
134
+ A non-interactive invocation never writes unless `--yes` is supplied.
135
+
136
+ ## Bootstrap loading
137
+
138
+ The environment-request protocol is moving Dryv away from whole-workspace upload. The bootstrap loader reads only:
139
+
140
+ ```text
141
+ dryv.yaml
142
+ dryv.lock.yaml # optional
143
+ ```
144
+
145
+ `dryv.yaml` remains the required entrypoint. `dryv.lock.yaml` is supplied when present so the engine can decide what additional resources are required.
146
+
147
+ The older broad workspace loader remains temporarily for the existing API endpoints until the new operation protocol is connected.
148
+
149
+ ## Local pack capabilities
150
+
151
+ The CLI can resolve explicit local pack resources without interpreting `dryv.yaml` itself. A future API/engine environment request supplies the typed pack source; the CLI fulfills it.
152
+
153
+ Local pack resolution:
154
+
155
+ - remains inside the project root;
156
+ - rejects symbolic links and non-regular files;
157
+ - has file-count, per-file-size, and total-size limits;
158
+ - includes text and binary resources;
159
+ - requires a UTF-8 `dryv.pack.yaml`;
160
+ - sorts files deterministically;
161
+ - computes SHA-256 file and resource digests.
162
+
163
+ ## Native Git pack capability
164
+
165
+ The native Git resolver uses the installed `git` executable through Bun's process API and the user's normal Git authentication environment. It does not create a Dryv credential store.
166
+
167
+ Resolved Git packs record:
168
+
169
+ - requested repository;
170
+ - requested revision;
171
+ - concrete resolved commit;
172
+ - optional pack subpath;
173
+ - deterministic pack content digest;
174
+ - resolver provenance (`client.git-native`).
175
+
176
+ Git cache state is stored under `.dryv/.cache/git`. `.dryv/.cache` is reserved for disposable Dryv-owned operational state such as resolved resources, plans, sessions and digests. Repository URLs are not installed as persistent remotes in the cache, and HTTP(S) repository URLs containing embedded credentials are rejected.
177
+
178
+ ## Resource bundles
179
+
180
+ Resolved packs can be converted into a self-describing ZIP transport bundle with media type:
181
+
182
+ ```text
183
+ application/vnd.dryv.resource-bundle+zip
184
+ ```
185
+
186
+ The archive contains:
187
+
188
+ ```text
189
+ dryv.bundle.json
190
+ files/
191
+ dryv.pack.yaml
192
+ templates/...
193
+ resources/...
194
+ ```
195
+
196
+ `dryv.bundle.json` uses `dryv.resource-bundle/v1alpha1` and records the resource request ID, pack identity, content digest, every file's path/kind/SHA-256/size/archive path, and normalized provenance.
197
+
198
+ ZIP is only a transport optimization. The semantic identity remains the typed resource manifest and content hashes; engine behavior must not depend on ZIP metadata or compression implementation.
199
+
200
+ Bundle file paths are canonical project-relative paths and are namespaced below `files/`, so resource entries cannot collide with the bundle manifest.
201
+
202
+ ## Workspace loading compatibility path
203
+
204
+ Inside a Git repository the older workspace loader uses:
205
+
206
+ ```text
207
+ git ls-files -z --cached --others --exclude-standard
208
+ ```
209
+
210
+ This naturally honors Git's normal ignored-file rules. Outside Git, the CLI performs a deterministic recursive filesystem walk.
211
+
212
+ In both modes it also honors `.dryvignore` plus repeatable `--exclude <pattern>` options.
213
+
214
+ Default exclusions include:
215
+
216
+ ```text
217
+ .git/
218
+ node_modules/
219
+ .dryv/.cache/
220
+ .dryv/contracts/
221
+ ```
222
+
223
+ Local packs under `.dryv/packs/` are included by the compatibility workspace upload because the current plan/generate API path still resolves pack manifests and templates from the uploaded virtual workspace.
224
+
225
+ This broad upload behavior is transitional and will be removed from the normal engine workflow once environment requests are connected.
226
+
227
+ ## Typed boundary rule
228
+
229
+ The CLI mirrors the Dryv typed-contract rule used by the Python API:
230
+
231
+ ```text
232
+ untrusted JSON
233
+ ↓
234
+ API protocol parser
235
+ ↓
236
+ typed TypeScript contract classes
237
+ ↓
238
+ CLI/application logic
239
+ ```
240
+
241
+ Raw `unknown` JSON is confined to network/archive parsing boundaries. Outbound wire objects exist only inside encoders. Commands, workspace code, resolvers, and the API client use known TypeScript contract types.
242
+
243
+ ## Filesystem safety
244
+
245
+ Before a generated artifact is written or deleted, the CLI verifies that:
246
+
247
+ - its path is project-relative and portable;
248
+ - it cannot traverse outside the project root;
249
+ - it does not pass through a symbolic link;
250
+ - an existing output target is a regular file;
251
+ - a generation stream has not emitted the same output path twice.
252
+
253
+ Generated files are classified as `CREATE`, `MODIFY`, `DELETE`, or `UNCHANGED`. Only the CLI applies those operations to disk.