reffy-cli 1.5.0 → 1.7.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.
package/README.md CHANGED
@@ -33,9 +33,12 @@ Command summary:
33
33
  - `reffy plan create`: generates proposal, task, design, and spec scaffolds from indexed Reffy artifacts.
34
34
  - `reffy plan validate|list|show|archive`: manages the planning lifecycle under `.reffy/reffyspec/`.
35
35
  - `reffy spec list|show`: inspects current spec state under `.reffy/reffyspec/`.
36
- - `reffy remote init|status|push|ls|cat`: links, publishes, and inspects a Paseo-backed remote `.reffy/` workspace.
36
+ - `reffy remote init|status|push|ls|cat|snapshot`: links, publishes, and inspects a Paseo-backed remote `.reffy/` workspace.
37
+ - `reffy remote workspace create|get` and `reffy remote project register|list`: control-plane operations against the workspace manager actor.
37
38
  - `reffy diagram render`: renders Mermaid diagrams as SVG or ASCII, including spec-aware generation from compatible `spec.md` files.
38
39
 
40
+ Run `reffy <command> --help` for the full flag list of any command. Most commands accept `--repo PATH` so they can be invoked from outside the project root (useful for agent harnesses).
41
+
39
42
  Output modes:
40
43
 
41
44
  - `--output text` (default)
@@ -55,7 +58,7 @@ reffy plan create --change-id add-login-flow --artifacts login-idea.md
55
58
  reffy plan list --output json
56
59
  reffy plan archive add-login-flow
57
60
  reffy spec show auth --output json
58
- reffy remote init --endpoint https://your-paseo-endpoint.example --provision
61
+ reffy remote init --provision
59
62
  reffy remote status --output json
60
63
  reffy remote push
61
64
  reffy remote ls
@@ -65,72 +68,144 @@ reffy diagram render --input .reffy/reffyspec/specs/auth/spec.md --format ascii
65
68
  reffy diagram render --input .reffy/reffyspec/specs/auth/spec.md --format svg --output .reffy/artifacts/auth-spec.svg
66
69
  ```
67
70
 
71
+ ## Diagnostics and Inspection
72
+
73
+ ### `reffy doctor`
74
+
75
+ Audits the local Reffy setup: the `.reffy/` workspace exists, `manifest.json` is valid, managed `AGENTS.md` blocks are in place, and optional tooling (mermaid CLI) is reachable. Useful as a first step when a command is misbehaving in an unfamiliar repo.
76
+
77
+ ```bash
78
+ reffy doctor # human-readable check list
79
+ reffy doctor --output json # machine-readable for CI
80
+ ```
81
+
82
+ ### `reffy summarize`
83
+
84
+ Produces a read-only handoff summary of indexed artifacts — titles, kinds, tags, related changes, derived outputs. Use it to brief a fresh agent or to audit what context has accumulated under `.reffy/artifacts/` without opening every file.
85
+
86
+ ```bash
87
+ reffy summarize # text overview grouped by kind
88
+ reffy summarize --output json # full structured payload
89
+ ```
90
+
91
+ ### `reffy spec list|show`
92
+
93
+ Inspects the current truth in `.reffy/reffyspec/specs/`. Each capability has its own spec file with requirements and scenarios; `list` enumerates capabilities, `show` prints one spec's requirements.
94
+
95
+ ```bash
96
+ reffy spec list
97
+ reffy spec show remote-workspace-manager --output json
98
+ ```
99
+
68
100
  ## Remote Sync
69
101
 
70
- Reffy can publish the local `.reffy/` workspace to a Paseo-backed remote actor and inspect it later with native CLI commands.
102
+ Reffy can publish the local `.reffy/` workspace to a Paseo-backed remote workspace and inspect it later with native CLI commands.
103
+
104
+ The Paseo remote splits into two actor surfaces:
105
+
106
+ - `reffyWorkspaceManager.v1` is the **control plane**. It owns workspace lifecycle (create / get) and project registration.
107
+ - `reffyRemoteBackend.v2` is the **storage plane**. One actor instance represents one shared `workspace_id` and accepts contributions keyed by `project_id`.
108
+
109
+ Reffy stores manager identity once per linkage file and the workspace backend identity per `workspace_id`.
71
110
 
72
111
  The current remote flow is:
73
112
 
74
113
  1. Reffy reads `project_id` and `workspace_ids` from `.reffy/manifest.json`.
75
114
  2. You select one workspace projection to act on. Reffy infers the selection when `workspace_ids` has exactly one entry; otherwise pass `--workspace-id <id>`.
76
- 3. Reffy connects to Paseo using `PASEO_ENDPOINT` or `--endpoint`.
77
- 4. `reffy remote init --provision` creates a pod and a `reffyRemoteBackend.v2` actor for the selected workspace id when needed, then writes local linkage state to `.reffy/state/remote.json`.
78
- 5. `reffy remote push` publishes the full local `.reffy/` tree to the selected projection through `/workspaces/{workspace_id}/...` with `replace_missing=true` by default, scoped to that workspace id.
79
- 6. `reffy remote status|ls|cat` inspects the selected workspace projection using the saved linkage state unless you override it.
115
+ 3. Reffy connects to Paseo using `PASEO_ENDPOINT` or `--endpoint` and configured manager identity.
116
+ 4. `reffy remote init` resolves (or creates) the workspace through the manager, persists the workspace backend identity, and registers the local `project_id` for that workspace.
117
+ 5. `reffy remote push` registers the project if needed (idempotent on 409), then imports the full local `.reffy/` tree through `POST /workspace/projects/{project_id}/import` on the workspace backend actor with `replace_missing=true`.
118
+ 6. `reffy remote status|ls|cat|snapshot` inspects the selected workspace projection per project on the workspace backend actor.
119
+
120
+ ### Bearer-token authentication
80
121
 
81
- One backend actor can serve multiple workspace projections for the same source `project_id`: Reffy stores one target per `workspace_id` in `.reffy/state/remote.json`, and the backend isolates documents and locks by `(workspace_id, path)`.
122
+ Every Paseo request from the CLI carries `Authorization: Bearer ${PASEO_TOKEN}`. The token is the only thing that grants access manager / workspace-backend identifiers in `.reffy/state/remote.json` are inert without it.
82
123
 
83
- ### Minimal connection requirement
124
+ Required env for any remote command:
84
125
 
85
- For the fresh-provision path, the only required connection value is:
126
+ ```bash
127
+ PASEO_ENDPOINT="https://your-paseo-endpoint.example"
128
+ PASEO_TOKEN="<bearer token issued by manager provisioning>"
129
+ ```
86
130
 
87
- - `PASEO_ENDPOINT`
131
+ Both must be present; the CLI fails fast and names the missing variable before issuing any network call. Endpoint is **never** persisted to `remote.json`. The token is **never** persisted anywhere by the CLI.
88
132
 
89
- Example `.env`:
133
+ ### First-time provisioning
90
134
 
91
135
  ```bash
92
- PASEO_ENDPOINT="https://your-paseo-endpoint.example"
136
+ PASEO_ENDPOINT="https://your-paseo-endpoint.example" reffy remote init --provision
93
137
  ```
94
138
 
95
- That is enough for:
139
+ `--provision` creates a fresh pod and `reffyWorkspaceManager.v1` actor. The manager mints a bearer token and the CLI prints it once with strong "save this now" guidance. Save it to your team secret store immediately — the CLI does not keep a copy.
140
+
141
+ After provisioning, export it for subsequent commands:
96
142
 
97
143
  ```bash
98
- reffy remote init --provision
144
+ export PASEO_TOKEN="<token from init output>"
145
+ reffy remote status
99
146
  ```
100
147
 
101
148
  Optional overrides:
102
149
 
103
- - `PASEO_POD_NAME` if you want to reuse an existing Paseo pod
104
- - `PASEO_ACTOR_ID` if you want to reuse an existing backend actor
105
- - `--workspace-id <id>` (or `PASEO_WORKSPACE_ID` for the helper script) when the manifest lists more than one `workspace_ids`
150
+ - `PASEO_MANAGER_POD` and `PASEO_MANAGER_ACTOR` (or `--manager-pod` / `--manager-actor`) to reuse an existing manager actor instead of provisioning one.
151
+ - `--workspace-id <id>` when the manifest lists more than one `workspace_ids`.
152
+ - `--create` or `--resolve` to force-create or force-resolve the workspace through the manager during init. The default is "resolve when present, create when absent."
153
+
154
+ ### Joining an existing manager from another repo
155
+
156
+ Drop the team's shared values into the new repo's `.env`:
106
157
 
107
- Reffy does not require separate `REFFY_PROJECT_ID` values for the normal case because source identity comes from `.reffy/manifest.json`.
158
+ ```bash
159
+ PASEO_ENDPOINT="..."
160
+ PASEO_TOKEN="..."
161
+ PASEO_MANAGER_POD="..."
162
+ PASEO_MANAGER_ACTOR="..."
163
+ ```
164
+
165
+ Then `reffy remote init --workspace-id <id>` resolves the workspace through the manager and registers the local project. No `--provision`, no new token issuance.
108
166
 
109
167
  ### Saved remote linkage
110
168
 
111
- After `reffy remote init`, Reffy stores the local pointer to the linked backend actor in:
169
+ After `reffy remote init`, Reffy stores manager and workspace-backend identifiers in:
112
170
 
113
171
  - `.reffy/state/remote.json`
114
172
 
115
- That file maps each selected `workspace_id` to the backend target Reffy should use for that projection:
116
-
117
173
  ```json
118
174
  {
119
- "version": 2,
175
+ "version": 4,
120
176
  "provider": "paseo",
121
- "endpoint": "https://paseo.example",
177
+ "manager": { "pod_name": "...", "actor_id": "..." },
122
178
  "targets": {
123
- "my-project": { "pod_name": "...", "actor_id": "...", "last_imported_at": "..." },
124
- "portfolio-alpha": { "pod_name": "...", "actor_id": "..." }
179
+ "my-project": {
180
+ "workspace_backend": { "pod_name": "...", "actor_id": "..." },
181
+ "last_imported_at": "..."
182
+ },
183
+ "portfolio-alpha": {
184
+ "workspace_backend": { "pod_name": "...", "actor_id": "..." }
185
+ }
125
186
  }
126
187
  }
127
188
  ```
128
189
 
129
- Multiple targets can share the same `pod_name` and `actor_id` the backend addresses each projection separately through `/workspaces/{workspace_id}/...`.
190
+ Each `workspace_id` is its own backend actor. Manager identity is shared across workspaces in this linkage file.
191
+
192
+ The file deliberately does **not** contain the Paseo endpoint URL or the bearer token. Both are sourced from environment configuration on every command. Without `PASEO_TOKEN`, the identifiers in this file grant nothing.
193
+
194
+ If `workspace_backend` for a workspace is missing or stale, Reffy automatically resolves it through the manager and refreshes the linkage file before continuing.
130
195
 
131
- This file is local runtime state. It is not part of the synced remote workspace and is intentionally excluded from `reffy remote push`.
196
+ ### Control-plane subcommands
132
197
 
133
- The file can also record local sync metadata such as the last successful import timestamp. That metadata is for local diagnostics and does not become part of the remote workspace contract.
198
+ ```bash
199
+ reffy remote workspace create <workspace-id> [--label "Pretty name"]
200
+ reffy remote workspace get <workspace-id>
201
+ reffy remote workspace delete <workspace-id> --yes
202
+ reffy remote project register [--workspace-id <id>] [--project-id <id>]
203
+ reffy remote project list [--workspace-id <id>]
204
+ ```
205
+
206
+ `workspace delete` is destructive (it removes the shared workspace and all of its contributions) and requires `--yes` to proceed. The CLI also drops the workspace entry from the local linkage file on success, and treats a `404` from the manager as an idempotent "already gone" outcome.
207
+
208
+ These talk directly to the manager actor and let you provision or inspect state without re-running `init`.
134
209
 
135
210
  ### Example flow
136
211
 
@@ -141,22 +216,22 @@ reffy remote status
141
216
  reffy remote push
142
217
  reffy remote ls
143
218
  reffy remote cat .reffy/manifest.json
219
+ reffy remote snapshot
144
220
  ```
145
221
 
146
- `reffy remote status` is the primary diagnostic command for this flow. It reports:
222
+ `reffy remote status` reports:
147
223
 
148
- - the saved linkage being used for the selected workspace id
224
+ - the saved manager and workspace backend linkage for the selected workspace id
149
225
  - the local manifest identity (source `project_id` and selected `workspace_id`)
150
- - the remote identity returned from v2 (`source.actor_type`, `source.version`, `source.project_id`, `workspace.workspace_id`)
151
- - remote document counts when reachable
226
+ - the remote workspace identity (`workspace.workspace_id`, `source.actor_type`, `source.version`)
227
+ - remote document counts and registered project counts when available
152
228
 
153
229
  `reffy remote push` reports:
154
230
 
231
+ - whether the project was newly registered or already registered
155
232
  - local document count
156
- - imported count
157
- - created count
158
- - updated count
159
- - deleted count
233
+ - imported / created / updated / deleted counts
234
+ - last imported timestamp
160
235
 
161
236
  That makes the default prune/import behavior auditable without dropping to direct backend API calls.
162
237
 
@@ -195,7 +270,52 @@ A practical pattern is:
195
270
  3. Keep a clear traceable path from exploratory artifacts to formal specs.
196
271
  4. Use Reffy commands for day-to-day workflow.
197
272
 
198
- Reference implementation in this repo:
273
+ ### Planning lifecycle
274
+
275
+ The end-to-end arc for a non-trivial change:
276
+
277
+ ```bash
278
+ # 1. Capture raw context as artifacts. Each artifact is a free-form
279
+ # markdown note; reindex registers it in the manifest.
280
+ echo "..." > .reffy/artifacts/login-flow-idea.md
281
+ reffy reindex
282
+
283
+ # 2. Scaffold a ReffySpec change from selected artifacts. This creates
284
+ # .reffy/reffyspec/changes/add-login-flow/ with proposal, design,
285
+ # tasks, and a placeholder spec delta — all linked back to the
286
+ # artifacts you passed in.
287
+ reffy plan create \
288
+ --change-id add-login-flow \
289
+ --artifacts login-flow-idea.md \
290
+ --title "Add login flow"
291
+
292
+ # 3. Edit the generated files:
293
+ # - proposal.md: Why / What Changes / Impact / Reffy References
294
+ # - design.md: decisions, data model, open questions
295
+ # - tasks.md: implementation + verification checklists
296
+ # - specs/<capability>/spec.md: ADDED / MODIFIED / REMOVED requirements
297
+ # with at least one Scenario each
298
+
299
+ # 4. Validate before implementing. Catches missing scenarios, malformed
300
+ # delta sections, and broken artifact references.
301
+ reffy plan validate add-login-flow
302
+
303
+ # 5. Implement, tick tasks in tasks.md as you go, re-validate.
304
+
305
+ # 6. Archive once shipped. Moves the change under
306
+ # .reffy/reffyspec/changes/archive/<date>-<change-id>/ and merges
307
+ # the delta spec(s) into the canonical specs in
308
+ # .reffy/reffyspec/specs/.
309
+ reffy plan archive add-login-flow
310
+ ```
311
+
312
+ Useful side commands during the arc:
313
+
314
+ - `reffy plan list` — enumerate active and archived changes.
315
+ - `reffy plan show <change-id>` — inspect one change's state without opening every file.
316
+ - `reffy spec list` / `reffy spec show <capability>` — see the canonical specs the deltas will land into.
317
+
318
+ ### Reference implementation in this repo
199
319
 
200
320
  - `AGENTS.md`: contains both managed instruction blocks and encodes sequencing.
201
321
  - `AGENTS.md`: Reffy block routes ideation/exploration requests to `@/.reffy/AGENTS.md`.