@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/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/main-DZ0mAAOh.js");s.runCli().then(e=>{e!==0&&(process.exitCode=e)}).catch(e=>{const n=e instanceof Error?e.stack??e.message:String(e);process.stderr.write(`${n}
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/main-CGAPe6tb.js");s.runCli().then(e=>{e!==0&&(process.exitCode=e)}).catch(e=>{const n=e instanceof Error?e.stack??e.message:String(e);process.stderr.write(`${n}
3
3
  `),process.exitCode=s.EXIT_CODES.UNKNOWN});
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/main-DZ0mAAOh.js");exports.createCliApp=e.createCliApp;exports.runCli=e.runCli;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/main-CGAPe6tb.js");exports.createCliApp=e.createCliApp;exports.runCli=e.runCli;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hagicode/cli",
3
- "version": "0.1.0-dev.39.1.c7a4f44",
3
+ "version": "0.1.0-dev.42.1.b13f8d2",
4
4
  "description": "HagiCode CLI for project, proposal, vault, chat, and AutoTask management.",
5
5
  "homepage": "https://github.com/HagiCode-org/cli#readme",
6
6
  "bugs": {
@@ -16,7 +16,8 @@
16
16
  "main": "./dist/main.js",
17
17
  "files": [
18
18
  "dist",
19
- "README.md"
19
+ "README.md",
20
+ "skills"
20
21
  ],
21
22
  "packageManager": "pnpm@12.16.1",
22
23
  "engines": {
@@ -0,0 +1,51 @@
1
+ # Embedded Skills
2
+
3
+ `repos/cli/skills/` is the repository-level discovery entrypoint for Hagi CLI skills.
4
+ Use this directory when you need the canonical agent-facing contract for the published `@hagicode/cli` package and the installed `hagi` command.
5
+
6
+ ## Package-first usage
7
+
8
+ Treat the published package as the default execution path:
9
+
10
+ ```bash
11
+ npx @hagicode/cli --help
12
+ npx @hagicode/cli proposal list --json
13
+ ```
14
+
15
+ If `@hagicode/cli` is already installed, the same contract is available through:
16
+
17
+ ```bash
18
+ hagi --help
19
+ ```
20
+
21
+ Repository-local commands under `repos/cli` are maintainer workflows only.
22
+
23
+ ## Available skill packages
24
+
25
+ - [`hagi/SKILL.md`](hagi/SKILL.md) - canonical Hagi CLI skill entrypoint
26
+ - [`hagi/agents/openai.yaml`](hagi/agents/openai.yaml) - agent display and invocation metadata
27
+ - [`hagi/references/cli-usage.md`](hagi/references/cli-usage.md) - published package usage and runtime flags
28
+ - [`hagi/references/session-data.md`](hagi/references/session-data.md) - inside a HagiCode session: read-only data commands and the actions that need an explicit request
29
+ - [`hagi/references/proposal-flow.md`](hagi/references/proposal-flow.md) - explicit proposal lifecycle guidance
30
+ - [`hagi/references/openspec-workflow.md`](hagi/references/openspec-workflow.md) - the OpenSpec stage each proposal command starts and how to follow a run
31
+ - [`hagi/references/super-commit.md`](hagi/references/super-commit.md) - Super Commit through the CLI: prompt-id start, options, result and explicit-request rule
32
+ - [`hagi/references/local-development.md`](hagi/references/local-development.md) - maintainer-only source-tree workflows
33
+ - [`hagi/references/validation.md`](hagi/references/validation.md) - post-change validation steps
34
+
35
+ ## Canonical writable source
36
+
37
+ Update `repos/cli/skills/**` when the Hagi CLI skill contract changes.
38
+
39
+ ## Built-in copy
40
+
41
+ The server also ships this folder as its built-in skill `hagi`. The copy lives in `repos/built-in-skills/content/hagi/` and is an exact byte copy of `repos/cli/skills/hagi/`. Edit this folder, then recopy and rehash the built-in copy.
42
+
43
+ ## Skill installation and discovery
44
+
45
+ If an agent runtime or skill loader needs the Hagi skill source, point it at `repos/cli/skills/hagi/`.
46
+ Start discovery from this README, then open `repos/cli/skills/hagi/SKILL.md`.
47
+
48
+ ## Maintainer note
49
+
50
+ When you are editing the CLI itself, use the maintainer-only workflows in `hagi/references/local-development.md`.
51
+ For normal usage and automation, stay package-first.
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: hagi
3
+ description: Use when the user wants to run, verify, or update the HagiCode CLI against the Hagi API, or asks about their own projects, proposals, chat sessions, vaults, scheduled plans, or installed skills, including user skills versus built-in skills, and enabling or disabling a built-in skill. Also covers the OpenSpec workflow behind proposal commands and Super Commit, which commits a code repository through a HagiTask session. Keep package-first command guidance primary, then follow the proposal flow, local development, and validation references as needed. Inside a HagiCode session, read the session-data reference first for questions about the user's own data.
4
+ ---
5
+
6
+ # Hagi
7
+
8
+ Use this skill when the user asks to:
9
+
10
+ - answer questions about their own projects, proposals, chat sessions, vaults, scheduled plans, or installed skills
11
+ - list which installed skills are user skills and which are built-in skills, or which built-in skills are enabled
12
+ - enable or disable a built-in skill
13
+ - run or verify the `hagi` CLI
14
+ - explain or execute `project`, `proposal`, `chat`, `hagitask`, `vault`, `plan`, or `skills` commands
15
+ - explain the OpenSpec workflow behind `proposal` commands, which stage each command starts, or how to follow a run until it settles
16
+ - run, explain or check a Super Commit, which commits the uncommitted changes of a code repository through a HagiTask session
17
+ - inspect CLI flags, environment variables, exit codes, or JSON automation behavior
18
+ - validate proposal-session flows against a backend API
19
+ - modify or debug the CLI implementation in `repos/cli`
20
+
21
+ ## Core rules
22
+
23
+ - Prefer `npx @hagicode/cli ...` for normal usage and package-level verification.
24
+ - Use `hagi ...` only when `@hagicode/cli` is already installed and on `PATH`.
25
+ - Run repository-local install, build, and test commands with the working directory set to `repos/cli`.
26
+ - Never run `pnpm install`, `pnpm run`, or other build commands at the monorepo root.
27
+ - Prioritize API invocation guidance over codebase tours unless the user explicitly wants implementation work.
28
+ - Built-in skills can be enabled or disabled with `hagi skills local enable --skill-name <name>` and `hagi skills local disable --skill-name <name>`. They cannot be uninstalled or updated through the CLI. A change applies to agent runs that start afterwards; a run already in progress keeps the skills it started with.
29
+ - Every proposal names its writable repositories and its read-only repositories, in a `Repository scope` section at the start of `--chief-complaint`. Both lists are always present, and an empty list is written as `none`. Take the paths from `hagi project repositories --id <project-id> --json`. When neither the user's request nor the session gives the scope, ask the user and offer those repositories as the choices; never guess a scope or widen the writable list. Details: [`references/proposal-flow.md`](references/proposal-flow.md#repository-scope).
30
+
31
+ ## Choose the workflow
32
+
33
+ 1. Published package usage -> read [`references/cli-usage.md`](references/cli-usage.md)
34
+ 2. Explicit proposal lifecycle work -> read [`references/proposal-flow.md`](references/proposal-flow.md)
35
+ 3. Which OpenSpec stage a proposal command starts, or following a run to its end -> read [`references/openspec-workflow.md`](references/openspec-workflow.md)
36
+ 4. Super Commit, committing a code repository through a HagiTask session -> read [`references/super-commit.md`](references/super-commit.md)
37
+ 5. Source-tree development in `repos/cli` -> read [`references/local-development.md`](references/local-development.md)
38
+ 6. Post-change validation -> read [`references/validation.md`](references/validation.md)
39
+ 7. The user's own data, inside a HagiCode session -> read [`references/session-data.md`](references/session-data.md)
40
+
41
+ When `hagi` is loaded as a built-in skill inside a HagiCode session, read item 7 first for any question about the user's own data or skills, before the other references.
42
+
43
+ ## Runtime configuration
44
+
45
+ Shared runtime flags:
46
+
47
+ - `--base-url <url>`
48
+ - `--token <token>`
49
+ - `--lang <lang>`
50
+ - `--json`
51
+
52
+ Equivalent environment variables:
53
+
54
+ - `HAGI_API_BASE_URL`
55
+ - `HAGI_API_TOKEN`
56
+ - `HAGI_API_LANG`
57
+
58
+ A base URL can also come from `"baseUrl"` in `$XDG_CONFIG_HOME/hagi/config.json`, or `~/.config/hagi/config.json` when `XDG_CONFIG_HOME` is unset.
59
+
60
+ Precedence: flag, then `HAGI_API_BASE_URL`, then the config file. The base URL has no default. When none of the three is set, the CLI exits with code `2`.
61
+
62
+ Inside a HagiCode session, the server can add four runtime variables to an agent run. They are present only while the built-in `hagi` skill is installed and enabled, and only on Claude Code, Pi, OpenCode, GitHub Copilot and omp:
63
+
64
+ | Variable | Carries |
65
+ | --- | --- |
66
+ | `HAGI_API_BASE_URL` | Address of the backend that started the session |
67
+ | `HAGI_VERSION` | Version of the HagiCode server |
68
+ | `HAGI_DEPLOYMENT_TYPE` | Deployment type of the server |
69
+ | `HAGI_API_LANG` | Effective AI language: `zh-CN` or `en-US`, sent as `Accept-Language` |
70
+
71
+ A variable the server cannot determine is left out, and the run still starts. Report an absent variable as absent; do not guess a value. Conditions and the rest of the session rules are in [`references/session-data.md`](references/session-data.md).
72
+
73
+ ## Command surface
74
+
75
+ The current top-level command families are:
76
+
77
+ - `project`
78
+ - `proposal`
79
+ - `vault`
80
+ - `chat`
81
+ - `hagitask`
82
+ - `plan`
83
+ - `skills`
84
+
85
+ `project repositories --id <project-id>` is read-only. It lists one project's repositories with each path relative to the project root (for example `repos/cli`). Those paths are the values a proposal's `Repository scope` names; see [`references/proposal-flow.md`](references/proposal-flow.md#repository-scope).
86
+
87
+ Scheduled plans (`hagi plan`) save a proposal or HagiTask input with a schedule. `list`, `get`, `create`, `update`, `enable`, `disable`, `delete` and `run` manage them; `run --background` returns the accepted plan id before the session exists. A manual run never changes a plan's state or next run time. See [`references/cli-usage.md`](references/cli-usage.md#plan-commands) for the action list and a plan document example.
88
+
89
+ HagiTask sessions (`hagi hagitask`) run a preset task with a structured input. `list` shows the active tasks, `schema --task-id <id>` shows one task's scope, commands, parameters and required marks, and `create --task-id <id> --input <file>` creates the session. Read the schema first, write the input from it, then create. `send` posts a follow-up message; `--steer` (or `HAGI_SEND_STEER=1`) inserts it into a running turn instead, and `queued` means no running task took it. The backend rejects any input key the schema does not list. See [`references/cli-usage.md`](references/cli-usage.md#hagitask-commands) for the flow and an input example, and [`references/cli-usage.md`](references/cli-usage.md#steer-for-send-commands) for the Steer options.
90
+
91
+ Each family also reads one session by id. `proposal get` and `hagitask get` read a session; with `--wait` they poll until its status settles, so a run can be followed without guessing. `proposal messages` and `hagitask messages` read a session's messages, and `--last 1` reads the final message of a run. The stage behind each proposal command is in [`references/openspec-workflow.md`](references/openspec-workflow.md). Super Commit is started with `hagitask create --prompt-id auto-compose-commit.<locale>`; see [`references/super-commit.md`](references/super-commit.md).
92
+
93
+ ## Source of truth
94
+
95
+ - Canonical writable skill source: `repos/cli/skills/hagi/`
96
+ - The server ships a byte-for-byte copy of this folder as its built-in skill `hagi`; edit here, never in the copy
97
+
98
+ ## References
99
+
100
+ - [`references/cli-usage.md`](references/cli-usage.md) - package-first installation, quick start, runtime flags, and exit codes
101
+ - [`references/session-data.md`](references/session-data.md) - inside a HagiCode session: read-only data commands, state-changing actions that need an explicit request, and failure handling
102
+ - [`references/proposal-flow.md`](references/proposal-flow.md) - explicit proposal lifecycle sequence and command examples
103
+ - [`references/openspec-workflow.md`](references/openspec-workflow.md) - the OpenSpec stage each proposal command starts, stage boundaries, who drives each step, and the monitoring rule
104
+ - [`references/super-commit.md`](references/super-commit.md) - Super Commit: starting it by prompt id, its options, result reading and the explicit-request rule
105
+ - [`references/local-development.md`](references/local-development.md) - maintainer-only development, build, and repository internals
106
+ - [`references/validation.md`](references/validation.md) - targeted verification after documentation or code changes
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "Hagi CLI"
3
+ short_description: "Answer questions about your HagiCode data and skills, operate the hagi CLI, follow the OpenSpec workflow, and run a Super Commit."
4
+ default_prompt: "Use $hagi to look up your projects, proposals, sessions, vaults, plans, or skills, to follow the OpenSpec workflow of a proposal, to run a Super Commit, to enable or disable a built-in skill, or to inspect, run, or update the HagiCode CLI in repos/cli."
5
+
6
+ policy:
7
+ allow_implicit_invocation: true
@@ -0,0 +1,300 @@
1
+ # CLI Usage
2
+
3
+ Use the published package contract first.
4
+ The repository exists to build and maintain `@hagicode/cli`, but normal command execution should start from the package surface rather than the source tree.
5
+
6
+ ## Installation paths
7
+
8
+ ### Zero-install
9
+
10
+ ```bash
11
+ npx @hagicode/cli --help
12
+ npx @hagicode/cli project list --json
13
+ ```
14
+
15
+ ### Project-local install
16
+
17
+ ```bash
18
+ npm install @hagicode/cli
19
+ npx @hagicode/cli proposal list --json
20
+ ```
21
+
22
+ ### Optional global install
23
+
24
+ ```bash
25
+ npm install -g @hagicode/cli
26
+ hagi --help
27
+ ```
28
+
29
+ ## Quick start
30
+
31
+ When `@hagicode/cli` is already available on `PATH`, these examples work as `hagi ...`.
32
+ For one-off execution, replace `hagi` with `npx @hagicode/cli`.
33
+
34
+ ```bash
35
+ hagi --help
36
+ hagi project list --json
37
+ hagi proposal list --json
38
+ hagi chat list --json
39
+ hagi hagitask list --json
40
+ hagi hagitask create --title "Auto commit" --project-id <project-id> --prompt-id auto-compose-commit.en-US
41
+ ```
42
+
43
+ ## Shared runtime flags
44
+
45
+ Every command family supports the same runtime flags:
46
+
47
+ - `--base-url <url>`
48
+ - `--token <token>`
49
+ - `--lang <lang>`
50
+ - `--json`
51
+
52
+ Example:
53
+
54
+ ```bash
55
+ hagi --base-url https://api.example.com --token "$HAGI_TOKEN" project list --json
56
+ ```
57
+
58
+ ## Environment variables
59
+
60
+ The CLI resolves runtime settings centrally before every command.
61
+ Explicit flags always override environment variables.
62
+
63
+ | Variable | Purpose |
64
+ | --- | --- |
65
+ | `HAGI_API_BASE_URL` | Backend base URL, used when `--base-url` is not given. Overrides the config file. |
66
+ | `HAGI_API_TOKEN` | Bearer token attached as `Authorization: Bearer <token>`. |
67
+ | `HAGI_API_LANG` | Shared `Accept-Language` header value. |
68
+ | `HAGI_SEND_STEER` | Turns Steer on (`1`, `true`, `yes`, `on`) or off (`0`, `false`, `no`, `off`) for `chat`, `proposal` and `hagitask send`. Any other value exits with code `2`. See [Steer for send commands](#steer-for-send-commands). |
69
+
70
+ ## Config file
71
+
72
+ The base URL can also be stored in a local config file:
73
+
74
+ ```json
75
+ { "baseUrl": "https://api.example.com", "steer": false }
76
+ ```
77
+
78
+ The file is `$XDG_CONFIG_HOME/hagi/config.json`, or `~/.config/hagi/config.json` when `XDG_CONFIG_HOME` is unset. The `steer` key must be `true` or `false`; any other value exits with code `2` and names the file.
79
+
80
+ Base URL precedence, highest first: `--base-url`, then `HAGI_API_BASE_URL`, then `baseUrl` in the config file.
81
+ There is no default. When none of the three is set, the CLI exits with code `2` and names all three sources.
82
+
83
+ ## Command overview
84
+
85
+ ```text
86
+ hagi
87
+ |-- project list | repositories | create | update | delete
88
+ | `-- monospecs show | init | set | validate | reload | clone | remove-checkout
89
+ |-- proposal list | create | optimize-description | generate | annotate | execute | archive | status | complete | send | get | messages
90
+ |-- vault list | create | update | delete
91
+ | `-- files list | preview
92
+ |-- chat list | create | archive | delete | send
93
+ |-- hagitask list | schema | create | send | get | messages
94
+ |-- plan list | get | create | update | enable | disable | delete | run
95
+ `-- skills local list | enable | disable | uninstall
96
+ gallery search | detail | install
97
+ trusted list | upsert | delete | reset
98
+ ```
99
+
100
+ ## Project repositories
101
+
102
+ `project repositories --id <project-id>` is read-only. It reads the same aggregation snapshot as `project list` and prints one project's repositories: name, path relative to the project root (for example `repos/cli`), display name, type and branch, with the project's MonoSpecs flag. The `path` values are the ones a proposal's `Repository scope` names.
103
+
104
+ ```bash
105
+ npx @hagicode/cli project repositories --id <project-id> --json
106
+ ```
107
+
108
+ An unknown project id exits with code `24` and prints no list.
109
+
110
+ ## MonoSpecs commands
111
+
112
+ `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 files and runs Git on its own host.
113
+
114
+ - `show --id <id>` prints the document: version, repo directory, config path, commit-when-archive, and one row per repository with its local Git state. A repository that is not a valid Git checkout is marked `missing or not a Git repository`. `--yaml` adds the YAML preview; `--json` emits the same fields plus `code` and `metadata`.
115
+ - `init --id <id>` initializes the configuration; an already initialized project returns its document.
116
+ - `set --id <id>` changes the document. Options: `--version`, `--repo-directory`, `--commit-when-archive <true|false>`, repeatable `--add-repository <path>` and `--remove-repository <path>`, `--clone`. `--url`, `--name`, `--display-name` and `--type` require exactly one `--add-repository`. `--clone` needs at least one addition. The CLI reads the document, applies the change and saves the complete document; it strips local Git state fields before saving. Duplicate additions and unknown removals fail before any save.
117
+ - `validate --id <id>` validates the configuration. It exits `30` when the backend reports it invalid, after printing every error.
118
+ - `reload --id <id>` rereads `monospecs.yaml` on the backend host and refreshes Git state.
119
+ - `clone --id <id>` clones missing repositories. Repeat `--path <path>` to select some; `--include-optional` adds optional repositories when no `--path` is given. Every result row is printed; any `failed` row exits `30`.
120
+ - `remove-checkout --id <id> --path <path>` deletes one configured repository's local checkout. Dirty, unpushed or no-upstream checkouts are refused (exit `29`); the hint suggests `--force` when the refusal can be overridden. The configuration file is not changed.
121
+
122
+ Only configured repositories can be cloned or removed, and the backend confines paths to the project root. Exit codes: `2` usage (no request sent), `20` backend validation with field errors, `24` project not found, `29` conflict, `30` invalid configuration or failed clone.
123
+
124
+ ```bash
125
+ hagi project monospecs show --id <project-id> --json
126
+ hagi project monospecs set --id <project-id> --add-repository repos/api --url <git-url> --clone
127
+ hagi project monospecs remove-checkout --id <project-id> --path repos/api --force
128
+ ```
129
+
130
+ ## Proposal commands
131
+
132
+ `proposal get` reads one proposal session. With `--wait` it polls until the status settles, so a stage can be followed without guessing. `proposal messages` reads its messages, newest first.
133
+
134
+ ```bash
135
+ hagi proposal get --session-id <session-id> --wait --timeout 900 --json
136
+ hagi proposal messages --session-id <session-id> --last 1 --json
137
+ ```
138
+
139
+ - `--wait` settles on any status other than Optimizing, Openspecing, Executing or Archiving. WaitingForReply counts as settled, because a person must answer.
140
+ - `--timeout`, `--interval` and `--grace` are seconds and need `--wait`. `--interval` must be less than `--timeout`. A timeout exits `31`.
141
+ - Which stage each command starts, and how to follow a run, is in [openspec-workflow.md](openspec-workflow.md).
142
+
143
+ ## Session metadata
144
+
145
+ `chat create` and `proposal create` take write-once metadata entries. An orchestrator marks the sessions it starts with them, for example a master marker and worker markers, and finds them again through `userMetadata`.
146
+
147
+ ```bash
148
+ hagi chat create --title "Master" --project-id <project-id> --metadata role=master --metadata batch=2026-11-07 --json
149
+ hagi chat create --title "Worker 1" --project-id <project-id> --metadata role=worker --metadata master=<master-session-id> --json
150
+ printf '{"role":"worker","master":"<master-session-id>"}' | hagi chat create --title "Worker 2" --project-id <project-id> --metadata-json - --json
151
+ hagi proposal create --project-id <project-id> --chief-complaint "<text>" --default-title --metadata role=worker --metadata master=<master-session-id> --json
152
+ ```
153
+
154
+ - `--metadata key=value` is repeatable. The text is split at the first `=`, so a value may contain `=`.
155
+ - `--metadata-json <file|->` reads a JSON object of string values from a file, or from stdin with `-`. It is repeatable.
156
+ - 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 exits `2` before any request is sent.
157
+ - Backend limits: 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. The backend's message is printed as it is, and the session is not created.
158
+ - Write-once: the entries are set at creation and cannot be changed later. Do not put secrets in them: every reader of the session can see them.
159
+ - Output: `--json` of `chat create`, `chat list`, `proposal create` and `proposal get` carries `userMetadata` (an object of string values) when the session has entries. The human output adds one `userMetadata` line, keys sorted. A session without entries has no `userMetadata` field.
160
+
161
+ ## HagiTask commands
162
+
163
+ A HagiTask is a preset task with a structured input. Use the schema-first flow: list the tasks, read one task's schema, write the input file from the schema, then create the session.
164
+
165
+ ```bash
166
+ hagi hagitask list --json
167
+ hagi hagitask schema --task-id <task-id>
168
+ hagi hagitask schema --task-id <task-id> --json
169
+ hagi hagitask create --title "<title>" --project-id <project-id> --task-id <task-id> --input input.json --json
170
+ hagi hagitask get --session-id <session-id> --wait --json
171
+ hagi hagitask messages --session-id <session-id> --last 1 --json
172
+ hagi hagitask send --session-id <session-id> --content "Retry with a smaller diff"
173
+ ```
174
+
175
+ `hagi hagitask get` and `hagi hagitask messages` take the same options as the proposal commands above.
176
+
177
+ Super Commit is a prompt, not a preset task, so it has no schema and takes no `--input`. Start it with a prompt id:
178
+
179
+ ```bash
180
+ hagi hagitask create --title "Commit the CLI changes" --project-id <project-id> --prompt-id auto-compose-commit.en-US --json
181
+ ```
182
+
183
+ Start one only when the user asked for it. See [super-commit.md](super-commit.md) for its options, its result and when to start it.
184
+
185
+ - `schema` (human view) lists the target scope, commands and parameters, with each required parameter marked `yes`, then the requirements, scenes, endpoint and an example command. `--json` adds the input JSON Schema and the example request body.
186
+ - `create` needs `--title`, `--project-id`, and either `--task-id` or `--prompt-id`. `--input <file|->` needs `--task-id`. The input must be a JSON object. The CLI does not check its keys; the backend does, and it rejects a key that the schema does not list and a missing required value. A rejection is printed unchanged and no session is reported.
187
+ - `create --json` prints `{ session, presetTaskId, promptId, requested }`. Read the session id from `session.sessionId`.
188
+
189
+ Example `input.json` for a task with one required input:
190
+
191
+ ```json
192
+ {
193
+ "inputs": {
194
+ "commitScope": "cli"
195
+ }
196
+ }
197
+ ```
198
+
199
+ Migration: `hagi hagitask create` and `hagi hagitask send` replace the former `autotask` commands. There is no alias, so `hagi autotask` fails as an unknown command.
200
+
201
+ ## Steer for send commands
202
+
203
+ `hagi chat send`, `hagi proposal send` and `hagi hagitask send` have two delivery modes. A normal send waits behind the running turn, as before. A Steer inserts the text into the running turn through one `SteerSession` call. Steer is off by default.
204
+
205
+ Options: `--steer` requests Steer for one call; `--no-steer` forces a normal send for one call. Without either flag, the first set source decides: `HAGI_SEND_STEER` (values above), then the `steer` config key, then `false`. `--no-steer` overrides `HAGI_SEND_STEER=1`.
206
+
207
+ Outcomes:
208
+
209
+ - `steered`: a running task took the message. It is not proof the text was used; the backend can requeue it when the run ends.
210
+ - `queued`: no running task took it, so it was sent as the next message. Exit code `0`. An idle session also answers `queued`, and the message then starts a run at once, so do not read `queued` as "waiting".
211
+
212
+ ```bash
213
+ hagi chat send --session-id <session-id> --content "Check the diff" --steer --json
214
+ ```
215
+
216
+ The `--json` output keeps `sessionId`, `message` and `requested`, and adds a `steer` object: `{ requested, source, effective, outcome?, messageId?, reason? }`. `source` is `flag`, `env`, `config` or `default`. On the Steer path `message` is `Steered` or `Queued`. `reason` appears only when Steer was requested but not used.
217
+
218
+ Conflicts and fallback:
219
+
220
+ - `--steer` with `--mode` or `--executor-type` exits with code `2` and sends nothing.
221
+ - Steer from `HAGI_SEND_STEER` or the config file, combined with `--mode` or `--executor-type`, sends a normal message with those options and sets `reason`.
222
+ - Steer from `HAGI_SEND_STEER` or the config file, against a backend without `SteerSession`, sends a normal message with the reason `the backend does not support Steer`. An explicit `--steer` returns the backend error instead.
223
+
224
+ A queued Steer is always sent in `Edit` mode. To keep another mode, use `--no-steer --mode <mode>`.
225
+
226
+ For unattended session-to-session messages, set `HAGI_SEND_STEER=1` in the orchestrator's environment. Use `--no-steer` on a single call that must take the normal queue.
227
+
228
+ ## Plan commands
229
+
230
+ Scheduled plans save a proposal or HagiTask input with a schedule and, for HagiTask plans, an agent pool.
231
+
232
+ ```text
233
+ hagi plan
234
+ |-- list
235
+ |-- get --id <id>
236
+ |-- create --input <file|-> [--name <name>] [--hero-id <id>] [--disabled]
237
+ |-- update --id <id> [--input <file|->] [--name <name>] [--hero-id <id>] [--enabled | --disabled]
238
+ |-- enable --id <id>
239
+ |-- disable --id <id>
240
+ |-- delete --id <id>
241
+ `-- run --id <id> [--background]
242
+ ```
243
+
244
+ - `create` enables the plan unless the document sets `enabled` or `--disabled` is passed.
245
+ - `update`, `enable` and `disable` read the current plan and send it back whole, so unchanged fields are kept. `update --input` replaces each top-level key it contains as a whole value.
246
+ - `run` creates a session now and waits for it. `run --background` returns `{ planId, accepted: true }` once the backend accepts the run, before the session exists.
247
+ - A manual run does not change the plan's state or next run time, and works for disabled and completed plans.
248
+
249
+ A one-time proposal plan document for `plan create --input`:
250
+
251
+ ```json
252
+ {
253
+ "type": "proposal",
254
+ "name": "Weekly triage",
255
+ "enabled": true,
256
+ "schedule": { "mode": "once", "runAt": "2026-06-12T10:30:00Z" },
257
+ "payload": {
258
+ "title": "Weekly triage",
259
+ "chiefComplaint": "Triage the open issues and propose the next sprint",
260
+ "projectId": "<project-id>"
261
+ }
262
+ }
263
+ ```
264
+
265
+ The README's `## Plan Commands` section has a recurring HagiTask example and the full `update`, `enable`, `disable` and `delete` workflow.
266
+
267
+ ## Skills commands
268
+
269
+ `skills local list` shows each installed skill with its origin (`user` or `built-in`), its enabled state for built-in skills (`yes` or `no`, shown as `-` for user skills), its version, scope, agents and path. `--json` returns the same data with the `origin` and `builtIn` fields.
270
+
271
+ ```bash
272
+ hagi skills local list
273
+ hagi skills local list --json
274
+ hagi skills local enable --skill-name hagi
275
+ hagi skills local disable --skill-name hagi --json
276
+ ```
277
+
278
+ - `enable` and `disable` take `--skill-name` and change one built-in skill. They apply to agent runs that start afterwards.
279
+ - `uninstall` removes a user skill. Built-in skills cannot be uninstalled; use `disable` to stop one from loading.
280
+ - Skill recommendation and install progress streaming are not part of the CLI. `skills gallery search`, `detail` and `install` are the discovery and install path.
281
+ - `skills gallery detail` adds skills.sh audit ratings. `--json` keeps the detail fields and adds `audit: { providers: [...] }`, one entry per provider with `provider` and, when supplied, `risk`, `alerts`, `score` and `analyzedAt`. Human output appends one `skills.sh audit (<provider>)` line per provider, with `--` for missing values. If the audit fails or has no data, the command still exits `0` and `audit.providers` is `[]`. A detail failure fails the command as before. The audit never changes the install command preview or installability.
282
+
283
+ ## Exit codes
284
+
285
+ Stable non-zero exits used by the CLI. The HTTP numbers are the equivalents of the gRPC status the backend answered with:
286
+
287
+ | Exit code | Meaning |
288
+ | --- | --- |
289
+ | `2` | CLI usage or validation failure |
290
+ | `20` | HTTP 400 |
291
+ | `21` | HTTP 401 |
292
+ | `23` | HTTP 403 |
293
+ | `24` | HTTP 404 |
294
+ | `29` | HTTP 409 |
295
+ | `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, or a failed MonoSpecs clone |
296
+ | `31` | Wait timed out: `--wait` on `proposal get` or `hagitask get` reached `--timeout` before the session settled. The last status is printed. Not a success, and not a backend error |
297
+ | `40` | Other HTTP 4xx |
298
+ | `50` | HTTP 5xx |
299
+ | `60` | Transport or connection failure |
300
+ | `70` | Unknown error |
@@ -0,0 +1,79 @@
1
+ # Local Development
2
+
3
+ This document is maintainer-only.
4
+ Use it when you are editing or validating the CLI source tree inside `repos/cli`.
5
+ Normal users should stay on the published package path.
6
+
7
+ ## Working directory rule
8
+
9
+ Always change into `repos/cli` before running install, build, or test commands.
10
+ Do not run npm commands at the monorepo root.
11
+
12
+ ```bash
13
+ cd repos/cli
14
+ ```
15
+
16
+ ## Development modes
17
+
18
+ ### Source-level development
19
+
20
+ Use the TypeScript entrypoint directly while changing behavior:
21
+
22
+ ```bash
23
+ cd repos/cli
24
+ pnpm run dev proposal list --json
25
+ pnpm run dev chat list --json
26
+ ```
27
+
28
+ ### Release-style verification
29
+
30
+ Build the local distribution and run the bundled CLI:
31
+
32
+ ```bash
33
+ cd repos/cli
34
+ pnpm run build
35
+ node ./dist/cli.js --help
36
+ node ./dist/cli.js proposal --help
37
+ ```
38
+
39
+ ## Repository map
40
+
41
+ Inspect these areas when implementation details matter:
42
+
43
+ - `src/commands/` - command registration, flags, and request shaping
44
+ - `src/runtime/` - API runtime, shared context, and error handling
45
+ - `src/formatters/` - human-readable and JSON output formatting
46
+ - `buildTools/` - gRPC stub generation and DTO type generation scripts
47
+ - `scripts/verify-package.mjs` - publish-surface verification
48
+
49
+ ## API client generation
50
+
51
+ The CLI calls the backend over gRPC-Web (`<base-url>/grpc`). The stubs in `src/generated/grpc` come from the proto contracts in `repos/hagicode-core/protos`.
52
+ Use these commands when a proto changes:
53
+
54
+ ```bash
55
+ cd repos/cli
56
+ pnpm run generate:grpc
57
+ pnpm run generate:grpc:check
58
+ ```
59
+
60
+ `HAGICODE_PROTO_DIR` points generation at another checkout of the protos.
61
+
62
+ The DTO types in `src/generated/api/models` are committed and maintained by hand (types only, no REST client). They are no longer
63
+ generated: the backend's OpenAPI document now lists only the retained REST routes, so regenerating from it would delete the
64
+ types of every removed route. When a proto DTO changes, edit or add the matching type there.
65
+
66
+ ## Release automation
67
+
68
+ GitHub workflows under `.github/workflows/` handle release drafting and npm publishing.
69
+ For a stable release dry run, use:
70
+
71
+ ```bash
72
+ cd repos/cli
73
+ version="$(pnpm run --silent publish:verify-release -- v0.1.0)"
74
+ npm version --no-git-tag-version "$version"
75
+ pnpm run build
76
+ pnpm run typecheck
77
+ pnpm test
78
+ pnpm run pack:check
79
+ ```