hadron-cli

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT

README

hadron-cli

hadron is the command-line interface to the Hadron AI-memory platform, for humans working in a terminal and AI agents shelling out to it.

Status

Full v1 command surface implemented: auth login|logout|whoami|status, memory ls|get|set|rm|clone|export, node ls|get|add|update|rm, spec ls|get|describe|register|find|new|lint|supersede|import, app ls|install|uninstall|use, config get|set|list, api (raw GraphQL escape hatch), replace, version, completion, agentic-usage.

Specs follow a legal-code citation scheme — flat (<module>:<feature>:<rule>) or product-rooted (<product>:<module>:<feature>:<rule>) for a multi-product corpus — with a general-provisions contract at every tier (feature :00, module :000, product :gen). See docs/how-to/maintain-product-specs.md.

Install

Homebrew (macOS)
brew tap hadron-memory/hadron-cli
brew install --cask hadron
Release archives (macOS, Linux, Windows)

Download the archive for your platform from the latest release, verify against checksums.txt, and put hadron on your PATH.

Go
go install github.com/hadron-memory/hadron-cli/cmd/hadron@latest

(go install builds without the version stamp — hadron version reports dev.)

From source
make build        # produces bin/hadron, version-stamped

Requires Go (see go.mod for the version).

Quick start

hadron auth login            # browser OAuth; token stored in OS keychain
hadron auth whoami
hadron memory ls --json
hadron api 'query { me { id email } }'

For CI/scripting, mint a token with hadron auth token create, then set HADRON_TOKEN or pipe it to hadron auth login --with-token. None of the ways to authenticate require the web portal — a self-hosted hadron-server is enough; see Authentication.

For AI agents

Run hadron agentic-usage — it prints the full output contract, stable exit codes, and recipes in one document. Every command supports --json with stable field names.

Claude Code plugin

This repo is also a Claude Code plugin marketplace. In Claude Code:

/plugin marketplace add hadron-memory/hadron-cli
/plugin install hadron-cli@hadron-cli

The hadron-cli plugin ships a use-hadron-cli skill that teaches the agent the CLI contract (auth checks, --json, --yes on destructive commands, fully-qualified node URNs) and defers to hadron agentic-usage as the runtime source of truth.

Development

make build      # build with version stamp
make test       # go test ./...
make lint       # golangci-lint run
make generate   # regenerate genqlient code from schema/schema.graphql
make schema     # refresh schema snapshot from ../hadron-server, then generate

The GraphQL schema snapshot at schema/schema.graphql is exported from hadron-server (pnpm schema:export there) and committed here; typed operations live in internal/api/queries/*.graphql and are compiled by genqlient. CI fails if generated code drifts from the committed schema.

Releasing

Build and test locally first, then cut the release by pushing a semver tag:

git checkout main && git pull        # release from a green main
make build && make test              # verify the build works
./bin/hadron --help                  # sanity check
git tag -a v0.3.0 -m "v0.3.0"        # bump per semver
git push origin v0.3.0

The tag triggers .github/workflows/release.yml, which runs goreleaser (.goreleaser.yaml) to:

  • cross-compile darwin/linux/windows (amd64/arm64) binaries — version-stamped from the tag — into archives + checksums.txt;
  • publish a GitHub Release with those assets and an auto-generated changelog;
  • push the Homebrew cask bump to homebrew-hadron-cli, so brew upgrade --cask hadron picks it up.

The cask push uses the HOMEBREW_TAP_TOKEN repo secret (a token with write access to the tap). If a release fails at the cask step, that token has expired or lost access — rotate it; nothing else needs a secret beyond the workflow's GITHUB_TOKEN.

Verify from the Actions run, the new release, and the goreleaserbot cask commit in the tap.

Architecture notes

  • Auth (v1): OAuth authorization-code + PKCE with a loopback redirect on 127.0.0.1. The server matches redirect URIs exactly, so each login binds the port first and registers a fresh public client via dynamic client registration. The resulting token is a long-lived hdr_user_* personal access token (no refresh tokens in v1). Stored in the OS keychain, falling back to ~/.config/hadron/auth.json (0600). A device-flow strategy can slot in behind internal/auth.Strategy once the server supports RFC 8628.
  • Output: commands marshal explicit DTOs, never generated GraphQL structs, so --json shapes stay stable across schema regenerations.
  • Exit codes are documented contract — see hadron agentic-usage.

Hadron slash commands (separate plugin)

The Hadron Claude Code slash commands — /hadron:h-task, /hadron:h-search, /hadron:h-open-node — live in their own marketplace, hadron-memory/hadron-plugins, so they're available without the CLI:

/plugin marketplace add hadron-memory/hadron-plugins
/plugin install hadron@hadron

Directories

Path Synopsis
cmd
hadron command
internal
api
Package api wraps the Hadron GraphQL endpoint: a genqlient client for typed operations, a raw escape hatch for `hadron api`, and the mapping from transport/GraphQL errors to exit codes.
Package api wraps the Hadron GraphQL endpoint: a genqlient client for typed operations, a raw escape hatch for `hadron api`, and the mapping from transport/GraphQL errors to exit codes.
auth
Package auth implements `hadron auth login` flows against the Hadron OAuth endpoints (spec 025: authorization-code + PKCE, public client via dynamic client registration).
Package auth implements `hadron auth login` flows against the Hadron OAuth endpoints (spec 025: authorization-code + PKCE, public client via dynamic client registration).
auth/store
Package store persists the Hadron access token, preferring the OS keychain and falling back to a 0600 file when no keychain is available (CI containers, headless boxes).
Package store persists the Hadron access token, preferring the OS keychain and falling back to a 0600 file when no keychain is available (CI containers, headless boxes).
build
Package build holds version metadata stamped at build time via -ldflags (see Makefile and .goreleaser.yaml).
Package build holds version metadata stamped at build time via -ldflags (see Makefile and .goreleaser.yaml).
cmd
Package cmd assembles the hadron command tree and owns the single error → exit-code → rendering path.
Package cmd assembles the hadron command tree and owns the single error → exit-code → rendering path.
cmd/access
Package access implements `hadron access` — inspecting who can do what.
Package access implements `hadron access` — inspecting who can do what.
cmd/agentic
Package agentic implements `hadron agentic-usage` (D8): a single document an agent can read to learn the CLI.
Package agentic implements `hadron agentic-usage` (D8): a single document an agent can read to learn the CLI.
cmd/aiconfig
Package aiconfig implements `hadron ai-config ...` — the AI service config surface.
Package aiconfig implements `hadron ai-config ...` — the AI service config surface.
cmd/apicmd
Package apicmd implements `hadron api`, the raw GraphQL escape hatch (same role as `gh api`).
Package apicmd implements `hadron api`, the raw GraphQL escape hatch (same role as `gh api`).
cmd/app
Package app implements `hadron app ...`.
Package app implements `hadron app ...`.
cmd/auth
Package auth implements `hadron auth ...`.
Package auth implements `hadron auth ...`.
cmd/configcmd
Package configcmd implements `hadron config ...`.
Package configcmd implements `hadron config ...`.
cmd/edge
Package edge implements `hadron edge ...` — directed, labeled connections between two nodes.
Package edge implements `hadron edge ...` — directed, labeled connections between two nodes.
cmd/memory
Package memory implements `hadron memory ...`.
Package memory implements `hadron memory ...`.
cmd/node
Package node implements `hadron node ...`.
Package node implements `hadron node ...`.
cmd/org
Package org implements `hadron org ...` — organization and membership management.
Package org implements `hadron org ...` — organization and membership management.
cmd/replacecmd
Package replacecmd implements `hadron replace`, bulk search-and-replace across many nodes (the CLI mirror of the MCP tool hadron_replace_globally).
Package replacecmd implements `hadron replace`, bulk search-and-replace across many nodes (the CLI mirror of the MCP tool hadron_replace_globally).
cmd/spec
Package spec implements `hadron spec ...` — an opinionated layer over the generic node/edge commands for maintaining product-spec nodes that follow the loc-as-citation convention: a spec's loc IS its citation number, <module>:<feature>:<rule>:<flow> (e.g.
Package spec implements `hadron spec ...` — an opinionated layer over the generic node/edge commands for maintaining product-spec nodes that follow the loc-as-citation convention: a spec's loc IS its citation number, <module>:<feature>:<rule>:<flow> (e.g.
cmd/version
Package version implements `hadron version`.
Package version implements `hadron version`.
cmdutil
Package cmdutil provides the Factory injected into every command: lazily-resolved config, token store, and API client, plus the values of the persistent --json/--server/--app flags.
Package cmdutil provides the Factory injected into every command: lazily-resolved config, token store, and API client, plus the values of the persistent --json/--server/--app flags.
config
Package config reads and writes ~/.config/hadron/config.toml.
Package config reads and writes ~/.config/hadron/config.toml.
exitcode
Package exitcode defines the hadron CLI's stable, documented exit codes.
Package exitcode defines the hadron CLI's stable, documented exit codes.
nodedoc
Package nodedoc is the codec for a single node's portable file form — the frontmatter-markdown (and canonical JSON) representation that `hadron memory export`, `hadron node export`, and `hadron node import` all share.
Package nodedoc is the codec for a single node's portable file form — the frontmatter-markdown (and canonical JSON) representation that `hadron memory export`, `hadron node export`, and `hadron node import` all share.
output
Package output renders command results as human-readable text or JSON.
Package output renders command results as human-readable text or JSON.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL