@hagicode/cli 0.2.0 → 0.3.0

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
@@ -94,7 +94,7 @@ If none of the three is set, the command exits with code `2` and sends no backen
94
94
 
95
95
  Operation commands send requests without a credential by default. Pass `--token` (or set `HAGI_API_TOKEN`) only when your backend requires one.
96
96
 
97
- When the backend cannot be reached, the CLI names the base URL and exits with code `60`. A backend HTTP error is reported differently: it prints the HTTP status and the backend error message, and exits with a status-mapped code.
97
+ When the backend cannot be reached, the CLI names the base URL and exits with code `60`. A backend failure is reported differently: it prints the HTTP-equivalent status of the gRPC status and the backend error message, and exits with a status-mapped code.
98
98
 
99
99
  ```text
100
100
  $ hagi --base-url http://127.0.0.1:1 project list
@@ -109,6 +109,7 @@ $ echo $?
109
109
  ```text
110
110
  hagi
111
111
  |-- project list | repositories | create | update | delete
112
+ | `-- monospecs show | init | set | validate | reload | clone | remove-checkout
112
113
  |-- proposal list | create | optimize-description | generate | annotate | execute | archive | status | complete | send
113
114
  |-- vault list | create | update | delete
114
115
  | `-- files list | preview
@@ -175,6 +176,39 @@ Delete the demo project:
175
176
  hagi project delete --id "$DEMO_PROJECT_ID"
176
177
  ```
177
178
 
179
+ ## MonoSpecs Commands
180
+
181
+ `project monospecs` manages a project's MonoSpecs configuration (`monospecs.yaml`) and the local checkouts of its repositories. The CLI only sends requests: the backend reads and writes the files and runs Git on its own host, so `--base-url` may point at a remote backend.
182
+
183
+ | Command | Purpose |
184
+ | --- | --- |
185
+ | `show --id <id>` | Print the version, repo directory, config path, commit-when-archive flag and one row per repository with its local Git state. `--yaml` adds the YAML preview. |
186
+ | `init --id <id>` | Initialize the configuration. An initialized project returns its existing document. |
187
+ | `set --id <id>` | Change metadata or repositories. Options: `--version`, `--repo-directory`, `--commit-when-archive <true\|false>`, repeatable `--add-repository <path>` and `--remove-repository <path>`, and `--clone`. `--url`, `--name`, `--display-name` and `--type` apply to a single `--add-repository`. |
188
+ | `validate --id <id>` | Validate the configuration. Exits `30` and still prints every error when it is invalid. |
189
+ | `reload --id <id>` | Reread `monospecs.yaml` on the backend host and refresh the Git state. |
190
+ | `clone --id <id>` | Clone configured repositories that are missing. Repeatable `--path <path>` selects repositories; `--include-optional` adds optional ones when no `--path` is given. |
191
+ | `remove-checkout --id <id> --path <path>` | Delete the local checkout of one configured repository. `--force` allows a checkout with uncommitted changes, unpushed commits or no upstream branch. |
192
+
193
+ ```bash
194
+ hagi project monospecs show --id "$PROJECT_ID"
195
+ hagi project monospecs set --id "$PROJECT_ID" --commit-when-archive true
196
+ hagi project monospecs set --id "$PROJECT_ID" --add-repository repos/api --url https://github.com/example/api.git --clone
197
+ hagi project monospecs set --id "$PROJECT_ID" --remove-repository repos/api
198
+ hagi project monospecs validate --id "$PROJECT_ID" --json
199
+ hagi project monospecs clone --id "$PROJECT_ID" --path repos/web
200
+ hagi project monospecs remove-checkout --id "$PROJECT_ID" --path repos/web
201
+ ```
202
+
203
+ Safety rules:
204
+
205
+ - `set` reads the current document, applies only the options given and saves the complete document. Local Git state (branch, sync state and similar) is never written back; `code` and `metadata` are kept.
206
+ - `set` rejects a duplicate `--add-repository`, a `--remove-repository` that is not configured, and companion options with more than one addition, before anything is saved. With `--clone`, the configuration is saved first; a failed clone leaves it saved and exits `30`.
207
+ - `clone` and `remove-checkout` act only on repositories listed in the configuration. The backend confines paths to the project root and clones only over `https`, `http`, `ssh` and `git`, so a `file://` URL or a plain path is reported as `failed`.
208
+ - `remove-checkout` refuses a checkout with uncommitted changes, unpushed commits or no upstream unless `--force` is given, and it never removes a path that is not a standalone repository root. It deletes a directory on the backend host and leaves `monospecs.yaml` unchanged.
209
+
210
+ Exit codes for these commands: `2` usage error (no request was sent), `20` backend validation error (every field error is listed), `24` project not found, `29` another clone or removal is running or a checkout is blocked, `30` invalid configuration or a failed clone.
211
+
178
212
  ## Proposal Commands
179
213
 
180
214
  List proposal sessions for the example project:
@@ -551,9 +585,15 @@ The CLI resolves runtime settings centrally before every command. Explicit flags
551
585
  | `HAGI_API_TOKEN` | Bearer token attached as `Authorization: Bearer <token>`. |
552
586
  | `HAGI_API_LANG` | Shared `Accept-Language` header value. |
553
587
 
588
+ ## Backend Transport
589
+
590
+ The CLI talks to the backend over gRPC-Web only. It appends `/grpc` to the base URL (for example `http://127.0.0.1:35167/grpc`) and calls the `hagicode.*.v1` services; no REST route is used. gRPC-Web runs over HTTP/1.1, so it works against the plain-HTTP local backend and through reverse proxies. The bearer token, `Accept-Language` and the `X-Hagi-Client` marker travel as request headers. The backend therefore has to expose its `/grpc` endpoints.
591
+
592
+ gRPC status codes keep the exit codes below: `InvalidArgument` is `20`, `Unauthenticated` `21`, `PermissionDenied` `23`, `NotFound` `24`, `FailedPrecondition`, `AlreadyExists` and `Aborted` `29`, other client-side statuses `40`, and `Internal`, `Unavailable`, `DeadlineExceeded` and the rest `50`. The status line in error output (`status=404`) shows the HTTP-equivalent number.
593
+
554
594
  ## Exit Codes
555
595
 
556
- Stable non-zero exits used by the CLI:
596
+ Stable non-zero exits used by the CLI. The HTTP numbers are the equivalents of the gRPC status the backend answered with:
557
597
 
558
598
  | Exit code | Meaning |
559
599
  | --- | --- |
@@ -563,7 +603,7 @@ Stable non-zero exits used by the CLI:
563
603
  | `23` | HTTP 403 |
564
604
  | `24` | HTTP 404 |
565
605
  | `29` | HTTP 409 |
566
- | `30` | Operation failed: the backend returned a refusal, for example `skills local enable` or `disable` on a name that is not a built-in skill |
606
+ | `30` | Operation failed: the backend returned a refusal, for example `skills local enable` or `disable` on a name that is not a built-in skill, an invalid MonoSpecs configuration from `project monospecs validate`, or a failed clone from `project monospecs clone` or `set --clone` |
567
607
  | `40` | Other HTTP 4xx |
568
608
  | `50` | HTTP 5xx |
569
609
  | `60` | Transport or connection failure |