You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MANUAL.md
+43-1Lines changed: 43 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -252,6 +252,47 @@ When reading `[install nginx]`, the dependency keyword should answer "what does
252
252
253
253
`first [update cache]` reads as a natural instruction: "first, make sure the cache is updated." It's unambiguous about direction, and it matches how ops people actually talk: "first update the cache, then install the package."
254
254
255
+
### File documentation headers
256
+
257
+
A `.cgr` file can carry a documentation header that `cgr how FILE` renders for users and agents discovering the file for the first time. The header lives before any `set` or `target` declarations and consists of two optional parts:
258
+
259
+
**Title line** — a `--- text ---` line on the very first content line:
260
+
261
+
```
262
+
--- deploy web application ---
263
+
```
264
+
265
+
**Comment block** — contiguous `#` lines immediately following the title (or at the top if there is no title):
266
+
267
+
```
268
+
--- authorize SSH key ---
269
+
#
270
+
# Copies your local public key to each host using ssh-copy-id.
# hosts — comma-separated list of hostnames or IPs (required)
278
+
# ssh_user — remote user (default: $USER from environment)
279
+
# ssh_port — SSH port (default: 22)
280
+
281
+
set hosts = "192.168.1.10,192.168.1.11"
282
+
set ssh_user = env("USER", "ubuntu")
283
+
set ssh_port = "22"
284
+
```
285
+
286
+
`cgr how` renders the header and then a **Defaults** table showing each `set` declaration with its raw expression (`env("USER", "ubuntu")` rather than the evaluated value), so users can see exactly what to override.
287
+
288
+
Conventions for the comment block:
289
+
- Start with a one-line summary sentence.
290
+
- Add a `Usage:` block with copy-pasteable `cgr apply` examples.
291
+
- Add a `Variables:` block listing each user-facing `set` variable with a short description and whether it is required or has a default.
292
+
- For graphs with manual resume steps, add a `Resuming after interruption:` block with `cgr state set` examples.
293
+
294
+
The parser strips the header before building the AST; it has no effect on execution.
295
+
255
296
---
256
297
257
298
## Parallel constructs (.cgr format)
@@ -2024,6 +2065,7 @@ This makes the HTML file a self-contained pitch: send someone `webserver.html`,
|`secrets`| Manage encrypted `.secrets` files for offline secret storage. |
2026
2067
|`ping FILE`| Verify SSH connectivity to all targets defined in the graph. |
2068
+
|`how FILE`| Show the file's documentation header and a **Defaults** table of all `set` declarations with their raw expressions. Works without resolving the graph. |
2027
2069
|`explain FILE STEP`| Show the full dependency chain for a step. |
2028
2070
|`why FILE STEP`| Show what steps depend on a step (reverse of explain). |
2029
2071
|`check FILE`| Re-run all check clauses against the live system and report drift. |
@@ -2256,7 +2298,7 @@ If you are an AI agent tasked with creating a CommandGraph dependency graph, fol
2256
2298
2257
2299
3.**Identify the goal.** What end state must be true on which host(s)?
2258
2300
2259
-
4.**Check the repo.** Run or simulate `cgr repo index --repo ./repo`. Reuse existing templates wherever possible. Do not reinvent `apt-get install` — use `apt/install_package`.
2301
+
4.**Check the repo.** Run or simulate `cgr repo index --repo ./repo`. Reuse existing templates wherever possible. Do not reinvent `apt-get install` — use `apt/install_package`. To understand an existing `.cgr` file's interface before running it, use `cgr how FILE` — it prints the documentation header and a table of all `set` variables with their default expressions.
2260
2302
2261
2303
5.**Decompose backwards.** Start from the end state and work backwards to roots. Draw the tree mentally or in comments.
0 commit comments