@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.
@@ -0,0 +1,130 @@
1
+ # OpenSpec workflow behind `hagi proposal`
2
+
3
+ Use this reference when a user asks what a `hagi proposal` command does on the OpenSpec side, which stage it starts, where it stops, or how to follow a run until it settles.
4
+
5
+ Source of these facts: `ProposalSessionGrain` in `repos/hagicode-core` (`PCode.Orleans/Grains/ProposalSessionGrain.cs`, `ProposalSessionHandler.cs`) and the `openspec-v1-*` stage prompts (`new`, `explore`, `ff`, `apply`, `archive`). The command descriptions come from `hagi proposal <command> --help`. When these change, update this file.
6
+
7
+ ## Stage map
8
+
9
+ Each command starts at most one stage. "Does not" lists what the command must not be assumed to do.
10
+
11
+ | Command | Starts | Does not |
12
+ | --- | --- | --- |
13
+ | `proposal create` | no stage; creates the session | generate or execute |
14
+ | `proposal optimize-description` | no stage; rewrites the title, description and name in one backend step | generate |
15
+ | `proposal generate` | planning stages: `new`, then `explore` when explore mode is on, then `ff` | implement, execute or archive |
16
+ | `proposal annotate` | no stage; submits review notes, which return the session to planning | execute |
17
+ | `proposal execute` | implementation stage: `apply` | archive, or commit code |
18
+ | `proposal archive` | archive stage: `archive` | complete the session |
19
+ | `proposal complete` | no stage; marks the session completed through its own endpoint | start any stage |
20
+ | `proposal status` | no stage; sets the status directly with a read-before-write merge | start any stage |
21
+ | `proposal send` | no stage; sends a follow-up message on the active session | start a stage by itself, except as noted under "Who drives each step" |
22
+ | `proposal get` | no stage; reads one session, and with `--wait` polls until its status settles | change the session |
23
+ | `proposal messages` | no stage; reads the session's messages | change the session |
24
+
25
+ Explore mode is chosen with `--enable-explore-mode` or `--disable-explore-mode` on `proposal generate`.
26
+
27
+ A command returning means the request was accepted and the stage was queued. It does not mean the stage finished. Follow the run with `proposal get` (see "Who drives each step").
28
+
29
+ ## Boundaries of each stage
30
+
31
+ - **Planning** (`generate`) writes the proposal artifacts. It implements no source files. The next step is `annotate` or `execute`, and the user chooses which.
32
+ - **Implementation** (`execute`) implements the change. It skips tasks that are not implementation, such as archiving or committing, and reports them as out of scope. It does not archive.
33
+ - **Archive** (`archive`) archives the change. It does not implement anything.
34
+
35
+ No command starts the next stage on its own. An agent that has finished one lifecycle command runs the next command only when the user asked for that step.
36
+
37
+ ## Two kinds of commit
38
+
39
+ Two different things are called "commit" in this workflow. Neither replaces the other.
40
+
41
+ - **Archive commit.** The archive stage may make one commit, only in the MonoSpecs repository that holds `openspec/`, and only when the project's option to commit on archive is on. The backend runs it inside the archive stage. It never covers code repositories, and the agent does not run it as a command.
42
+ - **Super Commit.** A separate session that commits the uncommitted changes in a code repository. It is started with `hagi hagitask create --prompt-id auto-compose-commit.<locale>`, and the agent starts it only on request. See [super-commit.md](super-commit.md).
43
+
44
+ After `proposal execute`, the code changes are still uncommitted. The archive commit does not commit them. To commit code, use Super Commit, and only when the user asks.
45
+
46
+ ## Confirm a stage before moving on
47
+
48
+ 1. Take the session id from the command's `--json` output.
49
+ 2. Pass that same id to the next command.
50
+ 3. Treat the suggested next command in the output as a suggestion. Do not run it unless the user asked for that step.
51
+
52
+ The repositories a proposal may change are listed in [Repository scope](proposal-flow.md#repository-scope). Read that section; this file does not restate it.
53
+
54
+ ## Who drives each step
55
+
56
+ Every step is one of five kinds:
57
+
58
+ - **Agent-issued command**: the agent runs it, and only when the user asked for that step.
59
+ - **AI run inside the backend**: the backend runs an AI agent for the stage. The agent does not run it by hand.
60
+ - **Automatic**: the backend moves the status with no command.
61
+ - **Needs a person**: the run stops until a person answers or decides.
62
+ - **Needs monitoring**: the agent follows the run with `proposal get --wait` and reports the result.
63
+
64
+ | Step | Kind | Notes |
65
+ | --- | --- | --- |
66
+ | `proposal create` | agent-issued command | creates the session |
67
+ | `proposal optimize-description` | agent-issued command | moves Init to Optimizing |
68
+ | Optimizing to Drafting | automatic | when the optimization finishes |
69
+ | `proposal generate` | agent-issued command | starts the planning run, an AI run inside the backend |
70
+ | Planning run (Openspecing) | AI run inside the backend, needs monitoring | Openspecing |
71
+ | Openspecing to Reviewing | automatic | when planning ends |
72
+ | `proposal annotate` | agent-issued command | moves Reviewing back to Openspecing |
73
+ | `proposal execute` | agent-issued command | moves Reviewing to Executing, and starts the implementation run |
74
+ | Implementation run (Executing) | AI run inside the backend, needs monitoring | Executing |
75
+ | Run asks a question | needs a person | Executing moves to WaitingForReply |
76
+ | A person answers | needs a person | WaitingForReply moves back to Executing |
77
+ | Executing to ExecutionCompleted | automatic | when the implementation run ends |
78
+ | `proposal archive` | agent-issued command | moves ExecutionCompleted to Archiving |
79
+ | Archiving to Archived | automatic | when the archive run ends |
80
+ | `proposal complete` | agent-issued command | marks the session completed |
81
+ | `proposal status` | agent-issued command | sets the status directly |
82
+ | `proposal send` | agent-issued command | on a session in ExecutionCompleted or Completed, it starts a new execution run; see the warning below |
83
+ | `proposal get --wait` | needs monitoring | reads the status until it settles |
84
+ | `proposal messages` | agent-issued command | reads the messages, for example the final result |
85
+
86
+ Status moves, and who causes each one:
87
+
88
+ | From | To | Trigger |
89
+ | --- | --- | --- |
90
+ | Init | Optimizing | agent runs `optimize-description` |
91
+ | Optimizing | Drafting | automatic |
92
+ | Drafting | Openspecing | agent runs `generate` |
93
+ | Openspecing | Reviewing | automatic when planning ends |
94
+ | Reviewing | Openspecing | agent runs `annotate` |
95
+ | Reviewing | Executing | agent runs `execute` |
96
+ | Executing | WaitingForReply | the run asks a question |
97
+ | WaitingForReply | Executing | a person answers |
98
+ | Executing | ExecutionCompleted | automatic when the implementation run ends |
99
+ | ExecutionCompleted | Archiving | agent runs `archive` |
100
+ | ExecutionCompleted | Executing | agent runs `send` (a new execution run) |
101
+ | Archiving | Archived | automatic when the archive run ends |
102
+
103
+ Only the moves labelled with a command are caused by the agent. The rest are caused by the backend, or wait for a person.
104
+
105
+ ### Warnings
106
+
107
+ - `proposal send` on a session in **ExecutionCompleted** or **Completed** starts a new execution run. Use it only when the user asks to run again.
108
+ - `proposal annotate` on a session in **Reviewing** returns it to planning. The session goes back to Openspecing and is planned again. Use it only when the user asks for revisions.
109
+
110
+ ### The monitoring rule
111
+
112
+ After any start command (`generate`, `execute`, `archive`), follow the run:
113
+
114
+ ```bash
115
+ hagi proposal get --session-id <id> --wait --json
116
+ ```
117
+
118
+ Read the `status` and the `wait` object in the output:
119
+
120
+ - **Openspecing, Executing or Archiving**: the run is still going. The wait ends on its own at the timeout.
121
+ - **WaitingForReply**: a person must answer. Tell the user; waiting longer does not help.
122
+ - **Reviewing, ExecutionCompleted or Archived**: the stage has settled.
123
+ - **Timeout (exit code `31`)**: report the last status to the user. Do not retry in a loop.
124
+
125
+ A returned start command accepts the request. It does not prove the run succeeded. Confirm the outcome from the settled status and, when the result matters, from `proposal messages`.
126
+
127
+ Other options of the monitoring commands:
128
+
129
+ - `--timeout <seconds>`, `--interval <seconds>`, `--grace <seconds>`: only with `--wait`. `--interval` must be less than `--timeout`.
130
+ - `proposal messages --session-id <id> --last <n>`: reads the n newest messages. `--json` prints the list unchanged.
@@ -0,0 +1,210 @@
1
+ # Proposal Flow
2
+
3
+ Treat the proposal lifecycle as explicit, non-interactive backend actions.
4
+ One CLI command maps to one backend action.
5
+ Do not imply hidden chaining between `create`, `optimize-description`, `generate`, `annotate`, `execute`, `archive`, and `complete`.
6
+
7
+ ## Configuration first
8
+
9
+ Confirm the backend target before discussing proposal commands:
10
+
11
+ - `--base-url <url>` or `HAGI_API_BASE_URL`
12
+ - `--token <token>` or `HAGI_API_TOKEN`
13
+ - `--lang <lang>` or `HAGI_API_LANG`
14
+ - `--json` for automation and machine-readable output
15
+
16
+ ## Explicit lifecycle sequence
17
+
18
+ Use this order when explaining or validating proposal flows:
19
+
20
+ 1. `proposal list`
21
+ 2. `proposal create`
22
+ 3. `proposal optimize-description` (optional)
23
+ 4. `proposal generate`
24
+ 5. `proposal annotate` (optional review loop)
25
+ 6. `proposal execute`
26
+ 7. `proposal archive`
27
+ 8. `proposal complete`
28
+ 9. `proposal send` for follow-up conversation on the active session
29
+
30
+ `proposal status` sets the session status directly and is not part of the sequence above.
31
+
32
+ Which stage each command starts, and what it leaves behind, is in [`openspec-workflow.md`](openspec-workflow.md).
33
+
34
+ Between two lifecycle commands, follow the run with `hagi proposal get --session-id <id> --wait --json` and wait until the status settles. A returned command only accepts the request. Read [`openspec-workflow.md`](openspec-workflow.md#who-drives-each-step) for what each status means.
35
+
36
+ After `proposal execute` settles and the code changes are still uncommitted, a Super Commit can commit them. Start it only when the user asks; see [`super-commit.md`](super-commit.md).
37
+
38
+ The CLI may suggest a next command, but it does not call later lifecycle APIs automatically.
39
+
40
+ ## Repository scope
41
+
42
+ Every proposal names the repositories it may edit (writable) and the repositories it may only read (read-only). Both lists are always present, and an empty list is written as `none`.
43
+
44
+ 1. Run `project repositories` for the proposal's project first:
45
+
46
+ ```bash
47
+ npx @hagicode/cli project repositories --id <project-id> --json
48
+ ```
49
+
50
+ Every `path` in that output (for example `repos/cli`) is a candidate. The human-readable output prints the same paths in its Path column.
51
+
52
+ 2. Begin `--chief-complaint` with a `Repository scope` section. Its `Writable repositories:` and `Read-only repositories:` lists hold paths taken from step 1, one `- ` entry per line. An empty list is written as `- none`. The chief complaint text follows after a blank line.
53
+
54
+ 3. Run `proposal create` with that chief complaint.
55
+
56
+ The scope is a text convention inside the chief complaint, not a structured field the CLI sends. `proposal create` has no scope flags: do not invent `--writable-repo` or `--readonly-repo`.
57
+
58
+ Where the scope comes from, in this order:
59
+
60
+ - The user's request names the writable and read-only repositories. Check each path against the step 1 list.
61
+ - Otherwise, the session's own repository scope, when the session states one. Name that scope with the action and its target before running `proposal create`.
62
+ - Otherwise, ask the user and show the step 1 repositories as the choices. Wait for the answer.
63
+
64
+ Rules:
65
+
66
+ - A path that is not in the step 1 list is asked about, never corrected or guessed.
67
+ - Never widen the writable list as a precaution, and never leave the `Repository scope` section out.
68
+ - When the project lists no repositories, the project root `.` is the only candidate: write `- .` as the writable entry and `- none` for read-only. Ask the user only if the request implies something else.
69
+
70
+ Worked example. The project has three repositories, and the user asks for a change to the CLI that only reads the core API:
71
+
72
+ ```json
73
+ {
74
+ "projectId": "proj-1",
75
+ "name": "HagiCode",
76
+ "isMonoSpecs": true,
77
+ "hasError": false,
78
+ "repositories": [
79
+ { "name": "cli", "path": "repos/cli", "displayName": "CLI", "type": "library", "branch": "main", "isValidGitRepo": true },
80
+ { "name": "hagicode-core", "path": "repos/hagicode-core", "displayName": "Core", "type": "backend", "branch": "main", "isValidGitRepo": true },
81
+ { "name": "web", "path": "repos/web", "displayName": "Web", "type": "frontend", "branch": "main", "isValidGitRepo": true }
82
+ ]
83
+ }
84
+ ```
85
+
86
+ ```bash
87
+ npx @hagicode/cli proposal create \
88
+ --project-id proj-1 \
89
+ --chief-complaint "Repository scope
90
+ Writable repositories:
91
+ - repos/cli
92
+ Read-only repositories:
93
+ - repos/hagicode-core
94
+
95
+ Add CLI completion for session workflows" \
96
+ --default-title \
97
+ --json
98
+ ```
99
+
100
+ When the change touches only one repository and reads nothing else, the read-only list is written as `none`:
101
+
102
+ ```bash
103
+ npx @hagicode/cli proposal create \
104
+ --project-id proj-1 \
105
+ --chief-complaint "Repository scope
106
+ Writable repositories:
107
+ - repos/web
108
+ Read-only repositories:
109
+ - none
110
+
111
+ Tighten the settings page copy" \
112
+ --default-title \
113
+ --json
114
+ ```
115
+
116
+ ## Published package examples
117
+
118
+ List sessions:
119
+
120
+ ```bash
121
+ npx @hagicode/cli proposal list --json
122
+ ```
123
+
124
+ Create a proposal session. The chief complaint begins with the `Repository scope` section; see [Repository scope](#repository-scope):
125
+
126
+ ```bash
127
+ npx @hagicode/cli proposal create \
128
+ --project-id <project-id> \
129
+ --chief-complaint "Repository scope
130
+ Writable repositories:
131
+ - repos/cli
132
+ Read-only repositories:
133
+ - none
134
+
135
+ Add CLI completion for session workflows" \
136
+ --default-title \
137
+ --json
138
+ ```
139
+
140
+ Optimize the description explicitly:
141
+
142
+ ```bash
143
+ npx @hagicode/cli proposal optimize-description \
144
+ --session-id <session-id> \
145
+ --description "Improve the proposal framing" \
146
+ --optimization-direction "Focus on implementation risk" \
147
+ --json
148
+ ```
149
+
150
+ Generate the proposal body:
151
+
152
+ ```bash
153
+ npx @hagicode/cli proposal generate \
154
+ --session-id <session-id> \
155
+ --enable-explore-mode \
156
+ --json
157
+ ```
158
+
159
+ Submit annotations from a file or stdin:
160
+
161
+ ```bash
162
+ npx @hagicode/cli proposal annotate --session-id <session-id> --input annotations.json
163
+ cat annotations.json | npx @hagicode/cli proposal annotate --session-id <session-id> --input - --json
164
+ ```
165
+
166
+ Execute, archive, complete, or continue the session:
167
+
168
+ ```bash
169
+ npx @hagicode/cli proposal execute --session-id <session-id> --json
170
+ npx @hagicode/cli proposal archive --session-id <session-id> --hero-id <hero-id>
171
+ npx @hagicode/cli proposal status --session-id <session-id> --status Reviewing
172
+ npx @hagicode/cli proposal complete --session-id <session-id>
173
+ npx @hagicode/cli proposal send --session-id <session-id> --content "Please continue"
174
+ ```
175
+
176
+ ## Session metadata
177
+
178
+ `proposal create` accepts `--metadata key=value` (repeatable) and `--metadata-json <file|->` (a JSON object of string values; `-` reads stdin). Use them to mark the sessions of one orchestrated run: a master marker on the orchestrator and worker markers on each proposal, so the run can find its sessions again.
179
+
180
+ ```bash
181
+ 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')
182
+
183
+ hagi proposal create \
184
+ --project-id <project-id> \
185
+ --chief-complaint "Repository scope
186
+ Writable repositories:
187
+ - repos/web
188
+ Read-only repositories:
189
+ - none
190
+
191
+ Tighten the settings page copy" \
192
+ --default-title \
193
+ --metadata role=worker \
194
+ --metadata master="$MASTER_ID" \
195
+ --json
196
+ ```
197
+
198
+ - Keys: 1 to 64 characters matching `^[a-z][a-z0-9._-]{0,63}$`. Values: 1 to 512 characters with no control characters. At most 16 entries. The backend checks these and its message is shown as it is.
199
+ - Each key appears once across both options. A repeat, a missing `=`, or a non-string JSON value exits `2` with no request sent.
200
+ - Metadata is write-once and visible to every reader of the session. Do not put secrets in it.
201
+ - The output `session` object carries `userMetadata` when the session has entries. Read it to confirm the markers were stored.
202
+
203
+ ## Validation focus
204
+
205
+ After each lifecycle step:
206
+
207
+ - inspect JSON output or the suggested next command
208
+ - confirm the session identifier used by the next command
209
+ - check exit codes when the caller needs scripting guarantees
210
+ - switch to `repos/cli` maintainer workflows only if package-level behavior is insufficient
@@ -0,0 +1,156 @@
1
+ # Session Data
2
+
3
+ Use this reference when an agent runs inside a HagiCode session and the user asks about their own projects, proposals, chat sessions, vaults, scheduled plans or installed skills.
4
+ Read-only inspection comes first. Change state only when the user asked for that change in the conversation.
5
+
6
+ ## Runtime variables
7
+
8
+ A HagiCode session can give you four variables. Each one is defined here, once:
9
+
10
+ | Variable | Carries |
11
+ | --- | --- |
12
+ | `HAGI_API_BASE_URL` | Address of the backend that started the session. `hagi` reads it when no `--base-url` is given. |
13
+ | `HAGI_VERSION` | Version of the HagiCode server that started the session. |
14
+ | `HAGI_DEPLOYMENT_TYPE` | Deployment type of that server. |
15
+ | `HAGI_API_LANG` | The user's effective AI language, `zh-CN` or `en-US`. `hagi` sends it as `Accept-Language`. |
16
+
17
+ The server adds them to an agent run only when all of these hold:
18
+
19
+ - the built-in `hagi` skill is installed and enabled;
20
+ - the run is on Claude Code, Pi, OpenCode, GitHub Copilot or omp, the agent CLIs that load built-in skills at launch;
21
+ - the value is one the server can determine. A value it cannot determine is left out, and the run still starts.
22
+
23
+ A value the user already set in the environment is kept, not replaced.
24
+ The variables carry facts about the server and the language only. They never carry a token or a file path.
25
+
26
+ If a variable you rely on is absent, say that it is absent and ask the user. Do not guess a value, install software, or retry in a loop.
27
+
28
+ ## Connection
29
+
30
+ Run `hagi` with no `--base-url` flag and no token when `HAGI_API_BASE_URL` is set; the variable is enough.
31
+
32
+ - Pass `--base-url <url>` only when the user gives you an address.
33
+ - If the CLI exits with code `2` and says no backend base URL is configured, the variable is missing from this session. Tell the user, and ask for the address. Do not guess one.
34
+ - Use `--json` for every command whose output you will read or summarize.
35
+
36
+ ## Choosing the runner
37
+
38
+ 1. If `hagi` is on `PATH`, run `hagi ...`.
39
+ 2. Otherwise, if `node --version` reports 24 or newer, run `npx @hagicode/cli ...`.
40
+ 3. If neither is available, say that the CLI cannot run here and why. Continue without inventing data, and do not install Node.js or the CLI unless the user asks.
41
+
42
+ ## Read-only commands
43
+
44
+ Run these freely to answer questions. Each list or get command is safe to repeat.
45
+
46
+ ### Projects
47
+
48
+ ```bash
49
+ hagi project list --json
50
+ hagi project repositories --id <project-id> --json
51
+ ```
52
+
53
+ `project repositories` lists one project's repositories. Its paths are the only values a proposal's repository scope may name.
54
+
55
+ ### Proposals
56
+
57
+ ```bash
58
+ hagi proposal list --json
59
+ hagi proposal list --project-id <project-id> --active-only --json
60
+ hagi proposal get --session-id <session-id> --json
61
+ hagi proposal messages --session-id <session-id> --last 1 --json
62
+ ```
63
+
64
+ `proposal get` and `proposal messages` only read. `proposal get --wait` polls the status until it settles and changes nothing.
65
+
66
+ ### Vaults
67
+
68
+ ```bash
69
+ hagi vault list --json
70
+ hagi vault files list --id <vault-id> --path <relative-dir> --json
71
+ hagi vault files preview --id <vault-id> --path <relative-file> --json
72
+ ```
73
+
74
+ `vault files preview` reads one file. Preview only the files the user's question needs.
75
+
76
+ ### Chat sessions
77
+
78
+ ```bash
79
+ hagi chat list --json
80
+ hagi chat list --project-id <project-id> --active-only --json
81
+ ```
82
+
83
+ ### HagiTasks
84
+
85
+ ```bash
86
+ hagi hagitask list --json
87
+ hagi hagitask schema --task-id <task-id> --json
88
+ hagi hagitask get --session-id <session-id> --json
89
+ hagi hagitask messages --session-id <session-id> --last 1 --json
90
+ ```
91
+
92
+ Read the schema before creating a HagiTask session. Its `parameters` give the input keys, and `inputSchema` is the JSON Schema the input must satisfy.
93
+
94
+ ### Scheduled plans
95
+
96
+ ```bash
97
+ hagi plan list --json
98
+ hagi plan get --id <plan-id> --json
99
+ ```
100
+
101
+ ### Skills
102
+
103
+ ```bash
104
+ hagi skills local list --json
105
+ hagi skills gallery search --query <keyword> --json
106
+ hagi skills gallery detail --id <gallery-id> --source <source> --json
107
+ hagi skills trusted list --json
108
+ ```
109
+
110
+ `hagi skills local list --json` returns one item per installed skill. Read these fields from each item:
111
+
112
+ - `origin`: `user` for a skill the user installed, `built-in` for a skill the server ships. An item with no `origin` is a user skill.
113
+ - `builtIn.enabled`: whether a built-in skill is on. It is present only for built-in skills. For user skills, availability does not apply.
114
+ - `builtIn.version`: the version the release recorded for a built-in skill. It may be absent.
115
+ - `managedInstallMetadata.version`: the version of a user skill installed through the gallery, when recorded.
116
+
117
+ ## State-changing commands
118
+
119
+ Run these only when the user has asked for that action in this conversation.
120
+ First name the action and its target (the id, the title or the name), then run it.
121
+ A question such as "what is in my plan" is not a request to run, enable, disable or delete it.
122
+
123
+ | Family | Commands that change state |
124
+ | --- | --- |
125
+ | `project` | `create`, `update`, `delete` |
126
+ | `proposal` | `create`, `optimize-description`, `generate`, `annotate`, `execute`, `archive`, `status`, `complete`, `send` |
127
+ | `vault` | `create`, `update`, `delete` (`delete --delete-local-files` also removes files) |
128
+ | `chat` | `create`, `archive`, `delete`, `send` |
129
+ | `hagitask` | `create`, `send` |
130
+ | `plan` | `create`, `update`, `enable`, `disable`, `delete`, `run` |
131
+ | `skills` | `local enable`, `local disable`, `local uninstall`, `gallery install`, `trusted upsert`, `trusted delete`, `trusted reset` |
132
+
133
+ A `send` or `run` starts agent work, and `execute` and `generate` start it too. Treat those as changes of the same kind.
134
+
135
+ A `send` with Steer (`--steer`, or `HAGI_SEND_STEER` set in the calling shell) inserts its text into a running turn. The result says which happened: `steered` means a running task took it, and `queued` means no running task did, so it went out as the next message. `HAGI_SEND_STEER` belongs to the calling shell; the backend does not set it inside agent sessions.
136
+
137
+ `hagitask create` with a Super Commit prompt (`--prompt-id auto-compose-commit.<locale>`) creates commits in a code repository, and with `--need-push` publishes them. Start it only when the user asked for it in this conversation, and add `--need-push` only when the user asked for a push. See [`super-commit.md`](super-commit.md).
138
+
139
+ `skills local enable` and `skills local disable` change whether a built-in skill loads. The change applies to agent runs that start afterwards; a run already in progress keeps its skills. Built-in skills cannot be uninstalled through the CLI.
140
+
141
+ Before `proposal create`, the proposal's repository scope is settled. Take the writable and read-only repositories from the user's request, or infer them from the session's repository scope when the session states one. When neither gives the scope, ask the user and offer the project's repositories from `project repositories --id <project-id> --json` as the choices. Do not guess the scope, and do not widen the writable list. The scope is written into the chief complaint as a `Repository scope` section; see [`proposal-flow.md`](proposal-flow.md#repository-scope).
142
+
143
+ When you name the action and its target before running `proposal create`, name its repository scope too.
144
+
145
+ ## Failure handling
146
+
147
+ | Exit code | Meaning | What to tell the user |
148
+ | --- | --- | --- |
149
+ | `2` | No base URL, or a usage error | The session did not provide `HAGI_API_BASE_URL`, or the command was malformed. Name the missing piece. |
150
+ | `21` / `23` | Unauthorized / forbidden | The backend rejected the request. Report the code; do not try a token. |
151
+ | `24` | Not found | Name the id that was not found and suggest a `list` command to find the right one. |
152
+ | `30` | Operation failed: the backend refused a change and returned a result with `succeeded` false, for example `skills local enable` or `disable` on a name that is not a built-in skill | Quote the backend message from the output and stop. Nothing changed. |
153
+ | `60` | Transport or connection failure | Say the backend is unreachable at the named base URL. Do not retry in a loop, and do not guess another address. |
154
+ | other non-zero | HTTP or unknown error | Quote the error message and stop. |
155
+
156
+ When a command fails, report the failure. Do not fill the gap with guesses about the user's data.
@@ -0,0 +1,106 @@
1
+ # Super Commit through `hagi`
2
+
3
+ Use this reference when a user asks to commit the uncommitted changes of a code repository, to publish them, or to explain or check a Super Commit run.
4
+
5
+ Super Commit commits the uncommitted changes in a code repository. It runs as a separate session, not as part of the proposal lifecycle. It creates commits, and with `--need-push` it also publishes them. Treat it as a state-changing action: start it only when the user asked for it.
6
+
7
+ For what the archive commit does, and how it differs from Super Commit, see [openspec-workflow.md](openspec-workflow.md#two-kinds-of-commit).
8
+
9
+ ## Start it: a prompt, not a preset task
10
+
11
+ Super Commit is started with a prompt id:
12
+
13
+ ```bash
14
+ hagi hagitask create --title <title> --project-id <project-id> --prompt-id auto-compose-commit.en-US --json
15
+ ```
16
+
17
+ Use the locale that matches the user's language in place of `en-US`. The prompt id alone marks the session as a Super Commit.
18
+
19
+ Super Commit is a prompt, not a preset task. It has no preset task id and no schema, so `hagi hagitask schema` does not apply to it. Do not pass `--task-id` or `--input` for it.
20
+
21
+ Use the name Super Commit in your explanation to the user. The prompt id appears only inside commands.
22
+
23
+ ## Options
24
+
25
+ Every option below is accepted by `hagi hagitask create`. The CLI checks these rules before any network call, and a violation is a usage error with exit code `2`.
26
+
27
+ | Option | Meaning |
28
+ | --- | --- |
29
+ | `--repository-path <path>` | MonoSpecs sub-repository to commit in, for example `repos/cli`. |
30
+ | `--need-push` | Publish the commits after they are created. Add it only when the user asked for a push. |
31
+ | `--pull-rebase` | Run `git pull --rebase` before the push. It has effect only with `--need-push`, and only when the run stays on the current branch. |
32
+ | `--target-branch-mode <mode>` | Which branch the commits go on. Modes are below. |
33
+ | `--target-branch-name <name>` | Name of the branch to create. It needs `--target-branch-mode new-custom`. |
34
+
35
+ Branch modes:
36
+
37
+ - `current`: commit on the branch that is checked out now.
38
+ - `new-custom`: create the branch named by `--target-branch-name` before the first commit. It needs a name. `--target-branch-name` without this mode is a usage error.
39
+ - `ai-generated-new`: create a new branch with a name the backend generates, before the first commit.
40
+
41
+ ## Server-owned choices
42
+
43
+ The Git identity, the co-author trailer and the sign-off setting come from the user's saved server settings. The CLI has no option for them.
44
+
45
+ Do not invent a flag for them, and do not put them in `--message`. If the user wants a different co-author for a run, tell them that the CLI has no option for it and ask them to change the saved setting.
46
+
47
+ ## Read the result
48
+
49
+ After the session settles (see "Who drives each step"), read the final message:
50
+
51
+ ```bash
52
+ hagi hagitask messages --session-id <id> --last 1
53
+ ```
54
+
55
+ The run ends with a result block:
56
+
57
+ - `## Commits Created`: every planned commit was made, and the push happened if one was requested.
58
+ - `## Commits Incomplete`: at least one commit failed, files were left uncommitted, or a requested push was skipped or failed.
59
+
60
+ Then read these lines:
61
+
62
+ - `**Commits:**` the commit count, for example `2`, or `1 of 2` when the run is incomplete.
63
+ - `**Push:**` the push outcome, for example `pushed to origin/<branch>`, or `skipped (reason)`.
64
+ - A numbered list of the commits, without hashes.
65
+
66
+ Report the result as it is:
67
+
68
+ - For `## Commits Created`: report the commit count and, if a push was requested, the push outcome.
69
+ - For `## Commits Incomplete`: report what was left undone. Do not say the commit succeeded.
70
+ - Retry through `hagi hagitask send --session-id <id> --content <text>` only when the user asks for it.
71
+
72
+ The result contains no commit hashes. To read them, run `git log` in the target repository.
73
+
74
+ ## Explicit request
75
+
76
+ Starting a Super Commit creates commits in a repository, and with `--need-push` publishes them. So:
77
+
78
+ - Start one only when the user asked for it in this conversation.
79
+ - Add `--need-push` only when the user asked for a push. If the user asks for a Super Commit and does not mention a push, leave `--need-push` out.
80
+ - After `hagi proposal execute` and a settled wait, if code changes remain uncommitted, offer a Super Commit and wait for the user's answer. Do not start one.
81
+ - Never start one as a side effect of another lifecycle command.
82
+
83
+ The web Git tab runs the same feature.
84
+
85
+ ## Who drives each step
86
+
87
+ | Step | Who |
88
+ | --- | --- |
89
+ | `hagi hagitask create --prompt-id auto-compose-commit.<locale>` | the agent, only on request |
90
+ | The commit work | an AI run inside the backend |
91
+ | Following the run | the agent, with `hagi hagitask get --session-id <id> --wait --json` |
92
+ | Archiving the finished session | automatic, by the default rule `ai-commit-auto-archive` |
93
+
94
+ Monitor the run with:
95
+
96
+ ```bash
97
+ hagi hagitask get --session-id <id> --wait --json
98
+ ```
99
+
100
+ Read the `status` and the `wait` object:
101
+
102
+ - Optimizing, Openspecing, Executing and Archiving mean the run is still going.
103
+ - WaitingForReply means a person must answer.
104
+ - A timeout (exit code `31`) is reported with the last status. Do not retry in a loop.
105
+
106
+ The default rule `ai-commit-auto-archive` archives the finished session automatically. So the agent runs no `archive` or `complete` for a Super Commit session. The rule is a user setting and may be off. Do not assume the session is archived: read `status`, and if the status is not Archived, report it as it is.