8 Commits
Author SHA1 Message Date
hermes cfb517e806 Merge pull request '/reload: re-read AGENTS.md, skills, config' (#176) from feat/reload into main
build / version (push) Successful in 11s
build / build (aarch64-apple-darwin) (push) Successful in 4m54s
build / build (x86_64-unknown-linux-musl) (push) Successful in 4m31s
build / release (push) Successful in 19s
2026-11-03 21:22:27 +00:00
hermes dac2320503 tui: /reload re-reads AGENTS.md, skills, config, MCP prompt index 2026-11-03 21:21:28 +00:00
gitea-actions 130704b8b3 ci: bin.json v0.1.1 2026-11-02 15:47:28 +00:00
johannesandClaude Opus 5.5 fe6811540a ci: allow manual build runs
build / version (push) Successful in 7s
build / build (aarch64-apple-darwin) (push) Successful in 5m39s
build / build (x86_64-unknown-linux-musl) (push) Successful in 5m5s
build / release (push) Successful in 20s
The previous commit mentioned the skip marker in its body, so Gitea
skipped it; this one triggers the build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 16:36:15 +01:00
johannesandClaude Opus 5.5 10b2ccf60a nix: use release binaries as default package
The release job records the tarball hashes in bin.json and commits it
([skip ci]); flake.nix fetches the binary from the release on
x86_64-linux and aarch64-darwin and builds from source elsewhere.
Drop x86_64-darwin, nixpkgs no longer evaluates it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 16:33:03 +01:00
johannes d0f23421cd ci: add build caching
ci / check (push) Canceled after 0s
build / version (push) Successful in 6s
build / build (aarch64-apple-darwin) (push) Successful in 5m16s
build / build (x86_64-unknown-linux-musl) (push) Successful in 4m58s
build / release (push) Successful in 12s
2026-11-02 15:37:13 +01:00
johannes ee5d8371d0 ci: add release step
build / version (push) Successful in 6s
build / build (aarch64-apple-darwin) (push) Successful in 5m13s
build / release (push) Canceled after 0s
build / build (x86_64-unknown-linux-musl) (push) Canceled after 2m59s
2026-11-02 15:34:35 +01:00
johannes 926bcbf978 ci: add build pipeline
build / build (aarch64-apple-darwin) (push) Successful in 5m48s
build / build (x86_64-unknown-linux-gnu) (push) Successful in 3m40s
2026-11-02 15:08:21 +01:00
8 changed files with 238 additions and 44 deletions

No files matched your search

+109
View File
@@ -0,0 +1,109 @@
name: build
on:
push:
branches: [main]
paths-ignore: [bin.json]
workflow_dispatch:
env:
MACOS_SDK: "14.5"
jobs:
# next version = highest vX.Y.Z tag with the patch bumped; push a tag by hand for minor/major
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.next.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: next
run: |
last=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n1)
if [ -z "$last" ]; then
next=0.1.0
else
last=${last#v}
next="${last%.*}.$(( ${last##*.} + 1 ))"
fi
echo "version=$next" >> "$GITHUB_OUTPUT"
build:
needs: version
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64-unknown-linux-musl, aarch64-apple-darwin]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# caches ~/.cargo registry/git and target/, keyed on Cargo.lock + toolchain
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
# zig as cross C compiler/linker for both musl and macOS
- run: pip install ziglang cargo-zigbuild
# macOS: Apple SDK for Security.framework etc.
- if: matrix.target == 'aarch64-apple-darwin'
id: sdk-cache
uses: actions/cache@v4
with:
path: ~/MacOSX${{ env.MACOS_SDK }}.sdk
key: macos-sdk-${{ env.MACOS_SDK }}
- if: matrix.target == 'aarch64-apple-darwin' && steps.sdk-cache.outputs.cache-hit != 'true'
run: curl -fsSL "https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK}/MacOSX${MACOS_SDK}.sdk.tar.xz" | tar -xJ -C "$HOME"
- if: matrix.target == 'aarch64-apple-darwin'
run: echo "SDKROOT=$HOME/MacOSX${MACOS_SDK}.sdk" >> "$GITHUB_ENV"
- run: cargo zigbuild --release --locked --target ${{ matrix.target }} -p hx-cli
env:
HX_VERSION: ${{ needs.version.outputs.version }}
- uses: actions/upload-artifact@v3
with:
name: hx-${{ matrix.target }}
path: target/${{ matrix.target }}/release/hx
release:
needs: [build, version]
runs-on: ubuntu-latest
steps:
# main, not the build sha: bin.json is committed on top of it
- uses: actions/checkout@v4
with:
ref: main
- uses: actions/download-artifact@v3
with:
path: dist
# artifacts lose the executable bit, restore it before packaging
- working-directory: dist
run: |
for t in hx-*; do
chmod +x "$t/hx"
tar -czf "$t.tar.gz" -C "$t" hx
done
sha256sum *.tar.gz > SHA256SUMS
- env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
TAG: v${{ needs.version.outputs.version }}
SHA: ${{ gitea.sha }}
# Gitea creates the tag at target_commitish when it doesn't exist
run: |
id=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"target_commitish\":\"$SHA\"}" "$API/releases" | jq -r .id)
for f in dist/*.tar.gz dist/SHA256SUMS; do
curl -fsS -X POST -H "Authorization: token $TOKEN" \
-F "attachment=@$f" "$API/releases/$id/assets?name=$(basename "$f")"
done
# flake.nix reads bin.json to fetch these tarballs instead of building from source
- env:
VERSION: ${{ needs.version.outputs.version }}
run: |
jq -Rn --arg v "$VERSION" \
'{version: $v, sha256: ([inputs | split(" ") | {(.[1] | ltrimstr("hx-") | rtrimstr(".tar.gz")): .[0]}] | add)}' \
< dist/SHA256SUMS > bin.json
git config user.name gitea-actions
git config user.email gitea-actions@git.jokresner.de
git add bin.json
git commit -m "ci: bin.json v$VERSION"
git pull --rebase origin main
git push origin HEAD:main
-21
View File
@@ -1,21 +0,0 @@
name: ci
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy, rust-analyzer
- run: cargo fmt --all --check
- run: cargo clippy --workspace --all-targets -- -D warnings
- run: cargo test --workspace
- run: cargo build && sh tests/e2e.sh
- run: python3 tests/tui_smoke.py
- run: sh tests/lens_e2e.sh
- run: pip install ruff && sh tests/m4_e2e.sh
- run: sh tests/m5_e2e.sh
- run: sh tests/m6_e2e.sh
- run: python3 tests/tui_lspinstall.py
- run: sh tests/m7_e2e.sh
+7
View File
@@ -0,0 +1,7 @@
{
"version": "0.1.1",
"sha256": {
"aarch64-apple-darwin": "d1684b780a1f988babccb24ec4de341fb04e2f0eccc43d82487287337b83216a",
"x86_64-unknown-linux-musl": "6ab0530d4c97839da685462bf3acac9db28173ed443c89f3e0037cccc693a92c"
}
}
+26 -1
View File
@@ -15,7 +15,12 @@ mod rpc;
use std::sync::Arc; use std::sync::Arc;
#[derive(Parser)] #[derive(Parser)]
#[command(name = "hx", version, about = "Minimal coding agent")] #[command(
name = "hx",
// CI sets HX_VERSION to the release version; local builds use Cargo's
version = option_env!("HX_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")),
about = "Minimal coding agent"
)]
struct Cli { struct Cli {
#[command(subcommand)] #[command(subcommand)]
cmd: Option<Cmd>, cmd: Option<Cmd>,
@@ -1112,6 +1117,26 @@ async fn main() -> Result<()> {
}) as _) }) as _)
}) })
}, },
reload: {
let (mcp, cwd, models, kinds) =
(mcp.clone(), cwd.clone(), models.clone(), kinds.clone());
Box::new(move || {
let cfg = Config::load(&cwd).map_err(|e| e.to_string())?;
let mut sys = format!(
"{}{}",
cfg.system_prompt
.as_deref()
.unwrap_or(context::DEFAULT_PROMPT),
context::prompt_tail(&context::hx_home(), &cwd)
);
let idx = mcp.system_prompt();
if !idx.is_empty() {
sys.push_str("\n\n");
sys.push_str(&idx);
}
Ok((sys, command_specs(&mcp, &cwd, &models, &kinds)))
})
},
lsp_status: { lsp_status: {
let (m, l) = (mgr.clone(), lens_ref.clone()); let (m, l) = (mgr.clone(), lens_ref.clone());
Box::new(move || { Box::new(move || {
+4
View File
@@ -243,6 +243,10 @@ impl Agent {
self.effort = e; self.effort = e;
} }
pub fn system(&self) -> &str {
&self.system
}
pub fn set_system(&mut self, system: impl Into<String>) { pub fn set_system(&mut self, system: impl Into<String>) {
self.system = system.into(); self.system = system.into();
self.publish(); self.publish();
+5
View File
@@ -98,6 +98,11 @@ pub fn builtins(models: &[&str]) -> Vec<CmdSpec> {
), ),
b("btw", "side question; no tools, not saved", Free), b("btw", "side question; no tools, not saved", Free),
b("skills", "list skills and where they load from", None), b("skills", "list skills and where they load from", None),
b(
"reload",
"re-read AGENTS.md, skills, config, MCP prompt index",
None,
),
b( b(
"resume", "resume",
"resume a session file; no arg opens /sessions", "resume a session file; no arg opens /sessions",
+38
View File
@@ -47,6 +47,7 @@ pub struct Setup {
pub pricing: fn(&str) -> Option<hx_ai::Pricing>, pub pricing: fn(&str) -> Option<hx_ai::Pricing>,
/// `/lsp` status lines. /// `/lsp` status lines.
pub lsp_status: LspStatus, pub lsp_status: LspStatus,
pub reload: Reload,
/// Extra slash commands (MCP prompts, `/mcp`): `(name, arg)` -> None = not mine, /// Extra slash commands (MCP prompts, `/mcp`): `(name, arg)` -> None = not mine,
/// Some(Ok(Send(text))) = send as a user prompt, Some(Ok(Show(text))) = show, Some(Err) = error. /// Some(Ok(Send(text))) = send as a user prompt, Some(Ok(Show(text))) = show, Some(Err) = error.
pub commands: Commands, pub commands: Commands,
@@ -88,6 +89,9 @@ pub type Commands = Box<
+ Sync, + Sync,
>; >;
/// Rebuilds `(system prompt, slash commands)` from disk for `/reload`.
pub type Reload = Box<dyn Fn() -> Result<(String, Vec<CmdSpec>), String> + Send + Sync>;
pub type LspStatus = Box< pub type LspStatus = Box<
dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<String>> + Send>> + Send, dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<String>> + Send>> + Send,
>; >;
@@ -259,6 +263,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
switcher, switcher,
pricing, pricing,
lsp_status, lsp_status,
reload,
commands, commands,
specs, specs,
open_sessions, open_sessions,
@@ -394,6 +399,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
tx: &tx, tx: &tx,
cwd: &cwd, cwd: &cwd,
lsp_status: &lsp_status, lsp_status: &lsp_status,
reload: &reload,
commands: &commands, commands: &commands,
}; };
let mut term = ratatui::init(); let mut term = ratatui::init();
@@ -1290,6 +1296,7 @@ struct Ctx<'a> {
tx: &'a mpsc::UnboundedSender<Ui>, tx: &'a mpsc::UnboundedSender<Ui>,
cwd: &'a std::path::Path, cwd: &'a std::path::Path,
lsp_status: &'a LspStatus, lsp_status: &'a LspStatus,
reload: &'a Reload,
commands: &'a Commands, commands: &'a Commands,
} }
@@ -1299,6 +1306,7 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
tx, tx,
cwd, cwd,
lsp_status, lsp_status,
reload,
commands, commands,
} = *c; } = *c;
app.scroll.end(); app.scroll.end();
@@ -1376,6 +1384,23 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
let r = status::report(&app.st, status::now_secs()); let r = status::report(&app.st, status::now_secs());
show(app, "usage", r); show(app, "usage", r);
} }
"reload" => match reload() {
Err(e) => app.t.push(Item::Error(format!("/reload: {e}"))),
Ok((sys, specs)) => {
let mut a = agent.lock().await;
// unchanged prompt: leave it alone, a rewrite would drop the prompt cache
let same = a.system() == sys;
if !same {
a.set_system(sys);
}
let (old, new) = (app.specs.len(), specs.len());
app.specs = specs;
app.t.push(Item::Info(format!(
"reloaded: prompt {}, commands {old} → {new}",
if same { "unchanged" } else { "updated" }
)));
}
},
"skills" => { "skills" => {
let dirs = hx_core::context::skill_dirs(&hx_core::context::hx_home(), cwd); let dirs = hx_core::context::skill_dirs(&hx_core::context::hx_home(), cwd);
let mut l = skills_list(&app.specs, &dirs); let mut l = skills_list(&app.specs, &dirs);
@@ -2775,16 +2800,27 @@ mod tests {
let (tx, _rx) = mpsc::unbounded_channel(); let (tx, _rx) = mpsc::unbounded_channel();
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] })); let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
let cmds: Commands = Box::new(|_, _| None); let cmds: Commands = Box::new(|_, _| None);
let rl: Reload = Box::new(|| Ok(("sys".into(), cmd::builtins(&[]))));
let ctx = Ctx { let ctx = Ctx {
agent: &agent, agent: &agent,
tx: &tx, tx: &tx,
cwd: t.path(), cwd: t.path(),
lsp_status: &ls, lsp_status: &ls,
reload: &rl,
commands: &cmds, commands: &cmds,
}; };
let mut app = test_app(); let mut app = test_app();
app.session_path = old.clone(); app.session_path = old.clone();
app.title = Some("first".into()); app.title = Some("first".into());
// /reload swaps prompt + commands; same prompt twice is reported unchanged
app.specs = vec![];
submit(&mut app, "/reload".into(), &ctx).await;
assert_eq!(agent.lock().await.system(), "sys");
assert!(app.specs.iter().any(|s| s.name == "reload"));
submit(&mut app, "/reload".into(), &ctx).await;
assert!(
matches!(app.t.items.last(), Some(Item::Info(m)) if m.contains("prompt unchanged"))
);
submit(&mut app, "/clear".into(), &ctx).await; submit(&mut app, "/clear".into(), &ctx).await;
let new = agent.lock().await.session().path().to_path_buf(); let new = agent.lock().await.session().path().to_path_buf();
assert_ne!(new, old); assert_ne!(new, old);
@@ -2825,11 +2861,13 @@ mod tests {
models.extend(hx_ai::models::fallback(Kind::Codex)); models.extend(hx_ai::models::fallback(Kind::Codex));
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] })); let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
let cmds: Commands = Box::new(|_, _| None); let cmds: Commands = Box::new(|_, _| None);
let rl: Reload = Box::new(|| Ok(("sys".into(), cmd::builtins(&[]))));
let ctx = Ctx { let ctx = Ctx {
agent: &agent, agent: &agent,
tx: &tx, tx: &tx,
cwd: t.path(), cwd: t.path(),
lsp_status: &ls, lsp_status: &ls,
reload: &rl,
commands: &cmds, commands: &cmds,
}; };
let mut app = test_app(); let mut app = test_app();
+49 -22
View File
@@ -6,37 +6,64 @@
outputs = outputs =
{ self, nixpkgs }: { self, nixpkgs }:
let let
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
forAll = f: nixpkgs.lib.genAttrs systems (s: f nixpkgs.legacyPackages.${s}); forAll = f: nixpkgs.lib.genAttrs systems (s: f nixpkgs.legacyPackages.${s});
# release binaries, bin.json is rewritten by the release job in .gitea/workflows/build.yml
bin = builtins.fromJSON (builtins.readFile ./bin.json);
targets = {
x86_64-linux = "x86_64-unknown-linux-musl";
aarch64-darwin = "aarch64-apple-darwin";
};
in in
{ {
packages = forAll (pkgs: rec { packages = forAll (
hx = pkgs.rustPlatform.buildRustPackage { pkgs:
pname = "hx"; let
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version; target = targets.${pkgs.stdenv.hostPlatform.system} or "";
src = pkgs.lib.cleanSource ./.; hasBin = bin.sha256 ? ${target};
cargoLock.lockFile = ./Cargo.lock;
cargoBuildFlags = [ "-p" "hx-cli" ]; hx = pkgs.rustPlatform.buildRustPackage {
# ponytail: tests skipped (need git/network); enable when hermetic. pname = "hx";
doCheck = false; version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
# rustls may build aws-lc-sys (cmake) depending on feature set. src = pkgs.lib.cleanSource ./.;
nativeBuildInputs = [ pkgs.cmake pkgs.perl ]; cargoLock.lockFile = ./Cargo.lock;
dontUseCmakeConfigure = true; cargoBuildFlags = [ "-p" "hx-cli" ];
meta = { # ponytail: tests skipped (need git/network); enable when hermetic.
description = "Minimal Rust coding agent using existing subscriptions"; doCheck = false;
license = pkgs.lib.licenses.unlicense; # rustls may build aws-lc-sys (cmake) depending on feature set.
mainProgram = "hx"; nativeBuildInputs = [ pkgs.cmake pkgs.perl ];
dontUseCmakeConfigure = true;
meta = {
description = "Minimal Rust coding agent using existing subscriptions";
license = pkgs.lib.licenses.unlicense;
mainProgram = "hx";
};
}; };
};
default = hx; hx-bin = pkgs.runCommand "hx-${bin.version}" { meta.mainProgram = "hx"; } ''
}); mkdir -p $out/bin
tar -xzf ${
pkgs.fetchurl {
url = "https://git.jokresner.de/johannes/hx/releases/download/v${bin.version}/hx-${target}.tar.gz";
sha256 = bin.sha256.${target};
}
} -C $out/bin hx
'';
in
{
inherit hx;
# prebuilt binary where the release has one, source build elsewhere
default = if hasBin then hx-bin else hx;
}
// pkgs.lib.optionalAttrs hasBin { inherit hx-bin; }
);
apps = forAll (pkgs: rec { apps = forAll (pkgs: rec {
hx = { type = "app"; program = "${self.packages.${pkgs.system}.hx}/bin/hx"; }; hx = { type = "app"; program = "${self.packages.${pkgs.system}.default}/bin/hx"; };
default = hx; default = hx;
}); });
overlays.default = _: prev: { hx = self.packages.${prev.system}.hx; }; overlays.default = _: prev: { hx = self.packages.${prev.system}.default; };
devShells = forAll (pkgs: { devShells = forAll (pkgs: {
default = pkgs.mkShell { default = pkgs.mkShell {