@hagicode/cli 0.1.0-dev.39.1.c7a4f44 → 0.1.0-dev.42.1.b13f8d2

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
@@ -86,11 +86,12 @@ Every operation command resolves the backend base URL on each invocation, in thi
86
86
 
87
87
  ```json
88
88
  {
89
- "baseUrl": "https://hagicode.example.com"
89
+ "baseUrl": "https://hagicode.example.com",
90
+ "steer": false
90
91
  }
91
92
  ```
92
93
 
93
- If none of the three is set, the command exits with code `2` and sends no backend request.
94
+ If none of the three is set, the command exits with code `2` and sends no backend request. The `steer` key is the default for `hagi chat send`, `hagi proposal send`, and `hagi hagitask send` (see [Steer](#steer-send-option)); it must be `true` or `false`.
94
95
 
95
96
  Operation commands send requests without a credential by default. Pass `--token` (or set `HAGI_API_TOKEN`) only when your backend requires one.
96
97
 
@@ -121,6 +122,8 @@ hagi
121
122
  trusted list | upsert | delete | reset
122
123
  ```
123
124
 
125
+ The `send` commands of `chat`, `proposal`, and `hagitask` also take `--steer` and `--no-steer`, and `HAGI_SEND_STEER` sets the default. See [Steer](#steer-send-option).
126
+
124
127
  ## Example Setup
125
128
 
126
129
  The examples in the family sections run in order against a local backend. They assume:
@@ -243,6 +246,14 @@ hagi proposal status --session-id "$PROPOSAL_ID" --status Reviewing
243
246
  hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue"
244
247
  ```
245
248
 
249
+ Steer the message into the running turn, from the environment, or with a normal send that overrides the environment:
250
+
251
+ ```bash
252
+ hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue" --steer
253
+ HAGI_SEND_STEER=1 hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue"
254
+ hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue" --no-steer
255
+ ```
256
+
246
257
  The next steps are AI lifecycle actions and need a backend with an AI executor. `optimize-description` writes the optimized title, description, and proposal name to the session in one backend step, and `generate` needs that name. Without the AI executor, or before the name exists, the backend answers with a 400 that names the missing state:
247
258
 
248
259
  ```bash
@@ -288,6 +299,19 @@ The CLI may suggest a next command, but it never chains later lifecycle APIs aut
288
299
 
289
300
  Each command maps to one backend action. The CLI may suggest a next command, but it never chains later lifecycle APIs automatically.
290
301
 
302
+ `proposal create` takes the same `--metadata` and `--metadata-json` options as `chat create`, with the same rules and limits; see [Session Metadata](#session-metadata). A master marker and worker markers, for example:
303
+
304
+ ```bash
305
+ MASTER_ID=$(hagi chat create --title "Batch master" --project-id "$PROJECT_ID" --metadata role=master --metadata batch=2026-11-07 --json | json_field '.session.sessionId')
306
+ hagi proposal create --project-id "$PROJECT_ID" --chief-complaint "Repository scope
307
+ Writable repositories:
308
+ - none
309
+ Read-only repositories:
310
+ - none
311
+
312
+ Tighten the settings page copy" --default-title --metadata role=worker --metadata master="$MASTER_ID" --json
313
+ ```
314
+
291
315
  ## Vault Commands
292
316
 
293
317
  Create a vault with a local folder to browse. The new id is read from `vault.id`:
@@ -352,10 +376,31 @@ Send a message, archive, and delete:
352
376
 
353
377
  ```bash
354
378
  hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff"
379
+ hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff" --steer
380
+ HAGI_SEND_STEER=1 hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff"
381
+ hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff" --no-steer
355
382
  hagi chat archive --session-id "$CHAT_ID"
356
383
  hagi chat delete --session-id "$CHAT_ID"
357
384
  ```
358
385
 
386
+ ### Session Metadata
387
+
388
+ `chat create` and `proposal create` take write-once metadata entries, for example the role markers an orchestrator uses to find its sessions again:
389
+
390
+ ```bash
391
+ hagi chat create --title "Master" --project-id "$PROJECT_ID" --metadata role=master --metadata batch=2026-11-07 --json
392
+ hagi chat create --title "Worker 1" --project-id "$PROJECT_ID" --metadata role=worker --metadata master="$MASTER_ID" --json
393
+ printf '{"role":"worker","master":"%s"}' "$MASTER_ID" | hagi chat create --title "Worker 2" --project-id "$PROJECT_ID" --metadata-json - --json
394
+ ```
395
+
396
+ - `--metadata key=value` is repeatable. The text is split at the first `=`, so a value may contain `=`.
397
+ - `--metadata-json <file|->` reads a JSON object of string values from a file, or from stdin with `-`. It is repeatable.
398
+ - A key may appear once across both options. A missing `=`, an empty key, a repeated key, or JSON that is not an object of string values is a usage error: the command exits `2` and sends no request.
399
+ - Limits, checked by the backend: at most 16 entries; a key of 1 to 64 characters matching `^[a-z][a-z0-9._-]{0,63}$`; a value of 1 to 512 characters with no control characters. A rejection exits with the backend's message as it is, and the session is not created.
400
+ - Metadata is write-once: it is set when the session is created and cannot be changed later. Every reader of the session can see it, so do not put secrets in it.
401
+ - The entries come back as `userMetadata` in the `--json` output of `chat create`, `chat list`, `proposal create` and `proposal get`. The human output adds one `userMetadata` line, keys sorted, when there are entries. A session without metadata has no `userMetadata` field.
402
+
403
+
359
404
  ## HagiTask Commands
360
405
 
361
406
  A HagiTask is a preset task with a structured input. Read its schema first, write the input from the schema, then create the session. `hagitask list` shows the active tasks:
@@ -418,6 +463,14 @@ Send a follow-up message to the HagiTask session:
418
463
  hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff"
419
464
  ```
420
465
 
466
+ Steer the message into the running task, from the environment, or with a normal send that overrides the environment:
467
+
468
+ ```bash
469
+ hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff" --steer
470
+ HAGI_SEND_STEER=1 hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff"
471
+ hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff" --no-steer
472
+ ```
473
+
421
474
  Read one HagiTask session, or wait until its status settles, and read its messages:
422
475
 
423
476
  ```bash
@@ -626,6 +679,45 @@ hagi skills trusted delete --provider-id example-provider
626
679
  hagi skills trusted reset
627
680
  ```
628
681
 
682
+ ## Steer (send option)
683
+
684
+ `hagi chat send`, `hagi proposal send`, and `hagi hagitask send` deliver a message in one of two ways:
685
+
686
+ - **Normal send** (default): the message waits behind the running turn, as before.
687
+ - **Steer**: the message is inserted into the running turn through the backend's `SteerSession` RPC. The CLI makes one call.
688
+
689
+ Steer is off unless you ask for it. The first source that is set decides, in this order:
690
+
691
+ 1. `--steer` (on) or `--no-steer` (off) on the command.
692
+ 2. `HAGI_SEND_STEER`: `1`, `true`, `yes`, `on` turn Steer on; `0`, `false`, `no`, `off` turn it off. Case and surrounding spaces are ignored. Any other value exits with code `2` and sends no request.
693
+ 3. `"steer": true` or `"steer": false` in the config file. Any other type exits with code `2` and names the file.
694
+ 4. The default, `false`.
695
+
696
+ A lower source is not read once a higher one is set, so `--no-steer` works even when `HAGI_SEND_STEER` holds a value the CLI does not recognize.
697
+
698
+ ### Outcomes
699
+
700
+ - `steered`: a running task took the message. It does not guarantee the text was used: the backend can return a steered message to the queue when the run ends.
701
+ - `queued`: no running task took the message, so it was sent as the next message. This is a success and exits with code `0`. The backend also answers `queued` for an idle session, where the message starts a run at once.
702
+
703
+ Human output adds `steer`, `effective`, `outcome`, and `messageId` rows, and a line saying no running task took the message for `queued`. `--json` keeps `sessionId`, `message`, and `requested`, and adds a `steer` object: `{ requested, source, effective, outcome?, messageId?, reason? }`. `source` is `flag`, `env`, `config`, or `default`. `reason` appears only when Steer was requested but not used. On the Steer path `message` is `Steered` or `Queued`.
704
+
705
+ ### Conflicts and fallback
706
+
707
+ Steer carries text only, so it cannot be combined with `--mode` or `--executor-type`:
708
+
709
+ - `--steer` with either option exits with code `2` and sends nothing.
710
+ - When Steer comes only from `HAGI_SEND_STEER` or the config file, the command sends a normal message with the options and records the reason in `steer.reason`.
711
+ - When Steer comes only from `HAGI_SEND_STEER` or the config file and the backend does not implement `SteerSession`, the command sends a normal message and records the reason `the backend does not support Steer`. An explicit `--steer` reports the backend error instead.
712
+
713
+ A queued Steer is always sent in `Edit` mode. A session that must keep another mode should send with `--no-steer --mode <mode>`.
714
+
715
+ Steer works with the executors the backend supports. For any other executor, the backend answers `queued`.
716
+
717
+ ### Unattended messaging
718
+
719
+ For session-to-session messages sent by an orchestrator without a person watching, set `HAGI_SEND_STEER=1` in its environment. Add `--no-steer` to a single call that must go through the normal queue.
720
+
629
721
  ## Environment Variables
630
722
 
631
723
  The CLI resolves runtime settings centrally before every command. Explicit flags always override environment variables.
@@ -635,6 +727,7 @@ The CLI resolves runtime settings centrally before every command. Explicit flags
635
727
  | `HAGI_API_BASE_URL` | Backend base URL, used when `--base-url` is not given. Overrides the config file. Required when neither is set. |
636
728
  | `HAGI_API_TOKEN` | Bearer token attached as `Authorization: Bearer <token>`. |
637
729
  | `HAGI_API_LANG` | Shared `Accept-Language` header value. |
730
+ | `HAGI_SEND_STEER` | Turns Steer on (`1`, `true`, `yes`, `on`) or off (`0`, `false`, `no`, `off`) for the send commands, ignoring case and surrounding spaces. Any other value exits with code `2`. Overridden by `--steer` / `--no-steer`. Order: flag, then this variable, then the `steer` config key, then `false`. |
638
731
 
639
732
  ## Backend Transport
640
733