@hagicode/cli provides the published hagi command for project, proposal, chat, and AutoTask management against a HagiCode backend API.
The same repository also carries the canonical embedded Hagi skill under skills/, so package usage and AI-oriented guidance live in one writable source.
- Node.js 20+
- npm compatible with
10.9.2 - Access to a HagiCode backend API
Use the published npm package for normal CLI usage. You do not need to clone repos/cli to run hagi.
npx @hagicode/cli --help
npx @hagicode/cli project list --jsonnpm install @hagicode/cli
npx @hagicode/cli proposal list --jsonnpm install -g @hagicode/cli
hagi --helpThe examples below use hagi ... after the package is available on your PATH. For one-off execution, replace hagi with npx @hagicode/cli.
hagi --help
hagi project list --json
hagi proposal list --json
hagi chat list --json
hagi autotask create --title "Auto commit" --project-id <project-id> --prompt-id auto-compose-commit.en-USIf you are integrating Hagi CLI into an agent workflow, start from the embedded skill package in this repository:
skills/README.md- repository-level discovery entrypointskills/hagi/SKILL.md- canonical Hagi skill contractskills/hagi/references/- focused package usage, proposal flow, maintainer, and validation guidance
repos/cli/skills/** is the canonical writable source for future Hagi skill updates.
repos/skills/** remains a historical/reference-only mirror during this consolidation.
Repository-local npm run dev -- ... and node ./dist/cli.js ... commands stay in the maintainer section below.
Every command family supports the same global runtime flags:
--base-url <url>--token <token>--lang <lang>--json
Example:
hagi --base-url https://api.example.com --token "$HAGI_TOKEN" project list --jsonhagi
|-- project list | create | update | delete
|-- proposal list | create | generate-name | optimize-description | generate | annotate | execute | archive | status | complete | send
|-- chat list | create | archive | delete | send
`-- autotask create | send
List projects through the aggregation endpoint:
hagi project list
hagi project list --jsonCreate a project:
hagi project create \
--name "CLI Demo" \
--path /workspace/cli-demo \
--description "Automation sandbox"Update only part of a project record. The CLI resolves current project data first so omitted fields are preserved:
hagi project update --id <project-id> --description "Updated description"
hagi project update --id <project-id> --name "Renamed project" --path /workspace/new-pathDelete a project:
hagi project delete --id <project-id>List proposal sessions:
hagi proposal list --project-id <project-id>
hagi proposal list --include-archived --jsonCreate a proposal session only:
hagi proposal create \
--project-id <project-id> \
--chief-complaint "Add CLI completion for session workflows" \
--default-titleGenerate a proposal name explicitly:
hagi proposal generate-name --session-id <session-id>Optimize the description explicitly:
hagi proposal optimize-description \
--session-id <session-id> \
--description "Improve the proposal framing" \
--optimization-direction "Focus on implementation risk"Generate and execute the proposal as separate steps:
hagi proposal generate --session-id <session-id> --enable-explore-mode
hagi proposal execute --session-id <session-id>Submit structured annotation payloads from a file or stdin:
hagi proposal annotate --session-id <session-id> --input annotations.json
cat annotations.json | hagi proposal annotate --session-id <session-id> --input - --jsonArchive, update status, complete, or send a follow-up message:
hagi proposal archive --session-id <session-id> --hero-id <hero-id>
hagi proposal status --session-id <session-id> --status Reviewing
hagi proposal complete --session-id <session-id>
hagi proposal send --session-id <session-id> --content "Please continue"The CLI keeps proposal lifecycle actions explicit and non-interactive:
hagi proposal listhagi proposal createhagi proposal generate-namehagi proposal optimize-description(optional)hagi proposal generatehagi proposal annotate(optional review loop)hagi proposal executehagi proposal archivehagi proposal complete
Each command maps to one backend action. The CLI may suggest a next command, but it never chains later lifecycle APIs automatically.
List chat sessions:
hagi chat list --active-only
hagi chat list --include-archived --jsonCreate a chat session:
hagi chat create \
--title "Repository Q&A" \
--project-id <project-id> \
--executor-type CodexCliArchive, delete, or send a message:
hagi chat archive --session-id <session-id>
hagi chat delete --session-id <session-id>
hagi chat send --session-id <session-id> --content "Summarize the current diff"Create an AutoTask session with package-first automation flags:
hagi autotask create \
--title "Auto compose commit" \
--project-id <project-id> \
--prompt-id auto-compose-commit.en-US \
--repository-path repos/cli \
--need-push \
--target-branch-mode new-custom \
--target-branch-name feature/cli-completion \
--script-key autotask.auto-compose-commitSend a follow-up message to an AutoTask session:
hagi autotask send --session-id <session-id> --content "Retry with a smaller diff"Use the commands in this section only when you are editing or validating the CLI source tree inside this repository.
Package consumers and automation should stay on npx @hagicode/cli ... or an installed hagi ... unless they are working on repos/cli itself.
Build the local repository output:
cd repos/cli
npm install
npm run build
node ./dist/cli.js --helpFor local development without building:
cd repos/cli
npm run dev -- proposal list --json
npm run dev -- chat list --jsonrepos/cli/.github/workflows/release-drafter.yml maintains the next GitHub draft release for @hagicode/cli.
repos/cli/.github/workflows/npm-publish.yml publishes two channels with GitHub Actions OIDC plus provenance:
- pushes to
mainpublish a unique development prerelease under the npmdevdist-tag - published GitHub Releases for strict
vX.Y.Ztags publish the stable package under the npmlatestdist-tag
Run the stable release gates locally before publishing a GitHub Release:
cd repos/cli
version="$(npm run --silent publish:verify-release -- v0.1.0)"
npm version --no-git-tag-version "$version"
npm run build
npm run typecheck
npm test
npm run pack:checkThe CLI resolves runtime settings centrally before every command. Explicit flags always override environment variables.
| Variable | Purpose |
|---|---|
HAGI_API_BASE_URL |
Backend base URL. Defaults to http://127.0.0.1:35168 when unset. |
HAGI_API_TOKEN |
Bearer token attached as Authorization: Bearer <token>. |
HAGI_API_LANG |
Shared Accept-Language header value. |
The CLI owns its own OpenAPI configuration in openapi-ts.config.json.
cd repos/cli
npm run generate:api
npm run generate:api:onceDefault Swagger source:
http://127.0.0.1:35168/swagger/v1/swagger.json
Stable non-zero exits used by the CLI:
| Exit code | Meaning |
|---|---|
2 |
CLI usage or validation failure |
20 |
HTTP 400 |
21 |
HTTP 401 |
23 |
HTTP 403 |
24 |
HTTP 404 |
29 |
HTTP 409 |
40 |
Other HTTP 4xx |
50 |
HTTP 5xx |
60 |
Transport or connection failure |
70 |
Unknown error |