9 Commits
Author SHA1 Message Date
gitea-actions ca6b917b17 ci: bin.json v0.1.3 2026-11-03 22:47:35 +00:00
johannes 042f1ed3b5 Merge branch 'fix/lenient-skill-frontmatter'
build / version (push) Successful in 9s
build / build (aarch64-apple-darwin) (push) Successful in 5m29s
build / build (x86_64-unknown-linux-musl) (push) Successful in 4m54s
build / release (push) Successful in 21s
2026-11-03 23:36:29 +01:00
johannesandClaude Sonnet 5.5 9843e5305c skills: fall back to line-based frontmatter when YAML is invalid
Descriptions with an unquoted ': ' (e.g. floorplan) failed strict YAML and
the skill was silently dropped. Read single-line known keys instead; skills
with no recognised key are still skipped and reported in /skills.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 23:36:18 +01:00
gitea-actions 047e781ca4 ci: bin.json v0.1.2 2026-11-03 21:32:24 +00:00
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
9 changed files with 180 additions and 47 deletions

No files matched your search

+19
View File
@@ -2,6 +2,8 @@ name: build
on:
push:
branches: [main]
paths-ignore: [bin.json]
workflow_dispatch:
env:
MACOS_SDK: "14.5"
jobs:
@@ -64,6 +66,10 @@ jobs:
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
@@ -88,3 +94,16 @@ jobs:
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.3",
"sha256": {
"aarch64-apple-darwin": "0fa455f5cc4c63df942224602ecad0b83ee91847cef6fde8f0e4704bf0913810",
"x86_64-unknown-linux-musl": "8bc56e52a403088229e25470ccd12b2b7fe9e1195062206827beff9be630f3f7"
}
}
+20
View File
@@ -1117,6 +1117,26 @@ async fn main() -> Result<()> {
}) 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: {
let (m, l) = (mgr.clone(), lens_ref.clone());
Box::new(move || {
+4
View File
@@ -243,6 +243,10 @@ impl Agent {
self.effort = e;
}
pub fn system(&self) -> &str {
&self.system
}
pub fn set_system(&mut self, system: impl Into<String>) {
self.system = system.into();
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("skills", "list skills and where they load from", None),
b(
"reload",
"re-read AGENTS.md, skills, config, MCP prompt index",
None,
),
b(
"resume",
"resume a session file; no arg opens /sessions",
+38 -4
View File
@@ -97,6 +97,34 @@ struct Front {
argument_hint: Option<String>,
}
/// Fallback for frontmatter that is not valid YAML: `key: value` on one line, value taken verbatim
/// (surrounding quotes stripped). None when no known key is found.
fn lenient_front(fm: &str) -> Option<Front> {
let mut f = Front::default();
let mut found = false;
for line in fm.lines() {
let Some((k, v)) = line.split_once(':') else {
continue;
};
let v = v.trim();
let v = v
.strip_prefix('"')
.and_then(|x| x.strip_suffix('"'))
.unwrap_or(v)
.to_string();
match k {
"name" => f.name = Some(v),
"description" => f.description = Some(v),
"load" => f.load = Some(v),
"disable-model-invocation" => f.disable_model_invocation = Some(v == "true"),
"argument-hint" => f.argument_hint = Some(v),
_ => continue,
}
found = true;
}
found.then_some(f)
}
/// Skill dirs, lowest priority first: `~/.claude/skills`, `~/.agents/skills` (shared with other agents),
/// `<hx home>/skills`, `<project>/.agents/skills`, `<project>/.claude/skills`, `<project>/.hx/skills`.
pub fn skill_dirs(home: &Path, cwd: &Path) -> Vec<PathBuf> {
@@ -133,7 +161,11 @@ pub fn parse_skill(p: &Path, s: &str) -> Result<Skill, String> {
let f: Front = if fm.trim().is_empty() {
Front::default()
} else {
serde_norway::from_str(fm).map_err(|e| e.to_string())?
match serde_norway::from_str(fm) {
Ok(f) => f,
// strict YAML failed (e.g. unquoted `: ` in a description): read single-line top-level keys
Err(e) => lenient_front(fm).ok_or_else(|| e.to_string())?,
}
};
let load = match f.load.as_deref() {
Some("always") => Load::Always,
@@ -307,7 +339,7 @@ mod tests {
assert!(!k.model_invocable && k.load == Load::Auto);
let k = parse_skill(p, "---\nname: n\ndescription: |\n a\n b\n---\n").unwrap();
assert_eq!(k.description, "a b");
assert!(parse_skill(p, "---\ndescription: [oops\n---\nB").is_err());
assert!(parse_skill(p, "---\noops: [oops\n---\nB").is_err());
let k = parse_skill(p, "no frontmatter").unwrap();
assert_eq!((k.name.as_str(), k.body.as_str()), ("n", "no frontmatter"));
assert!(
@@ -329,7 +361,8 @@ load: manual
for (n, fm) in [
("ok", "description: fine"),
("hid", "description: secret\ndisable-model-invocation: true"),
("bad", "description: [oops"),
("bad", "oops: [oops"),
("colon", "description: before code exists: when asked"),
] {
let d = t.path().join("s").join(n);
std::fs::create_dir_all(&d).unwrap();
@@ -337,7 +370,8 @@ load: manual
}
let (sk, warn) = scan_skills(&[t.path().join("s")]);
let names: Vec<_> = sk.iter().map(|k| k.name.as_str()).collect();
assert_eq!(names, ["hid", "ok"]);
assert_eq!(names, ["colon", "hid", "ok"]);
assert_eq!(sk[0].description, "before code exists: when asked");
assert!(
warn.len() == 1 && warn[0].contains("bad/SKILL.md"),
"{warn:?}"
+38
View File
@@ -47,6 +47,7 @@ pub struct Setup {
pub pricing: fn(&str) -> Option<hx_ai::Pricing>,
/// `/lsp` status lines.
pub lsp_status: LspStatus,
pub reload: Reload,
/// 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.
pub commands: Commands,
@@ -88,6 +89,9 @@ pub type Commands = Box<
+ 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<
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,
pricing,
lsp_status,
reload,
commands,
specs,
open_sessions,
@@ -394,6 +399,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
tx: &tx,
cwd: &cwd,
lsp_status: &lsp_status,
reload: &reload,
commands: &commands,
};
let mut term = ratatui::init();
@@ -1290,6 +1296,7 @@ struct Ctx<'a> {
tx: &'a mpsc::UnboundedSender<Ui>,
cwd: &'a std::path::Path,
lsp_status: &'a LspStatus,
reload: &'a Reload,
commands: &'a Commands,
}
@@ -1299,6 +1306,7 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
tx,
cwd,
lsp_status,
reload,
commands,
} = *c;
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());
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" => {
let dirs = hx_core::context::skill_dirs(&hx_core::context::hx_home(), cwd);
let mut l = skills_list(&app.specs, &dirs);
@@ -2775,16 +2800,27 @@ mod tests {
let (tx, _rx) = mpsc::unbounded_channel();
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
let cmds: Commands = Box::new(|_, _| None);
let rl: Reload = Box::new(|| Ok(("sys".into(), cmd::builtins(&[]))));
let ctx = Ctx {
agent: &agent,
tx: &tx,
cwd: t.path(),
lsp_status: &ls,
reload: &rl,
commands: &cmds,
};
let mut app = test_app();
app.session_path = old.clone();
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;
let new = agent.lock().await.session().path().to_path_buf();
assert_ne!(new, old);
@@ -2825,11 +2861,13 @@ mod tests {
models.extend(hx_ai::models::fallback(Kind::Codex));
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
let cmds: Commands = Box::new(|_, _| None);
let rl: Reload = Box::new(|| Ok(("sys".into(), cmd::builtins(&[]))));
let ctx = Ctx {
agent: &agent,
tx: &tx,
cwd: t.path(),
lsp_status: &ls,
reload: &rl,
commands: &cmds,
};
let mut app = test_app();
+49 -22
View File
@@ -6,37 +6,64 @@
outputs =
{ self, nixpkgs }:
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});
# 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
{
packages = forAll (pkgs: rec {
hx = pkgs.rustPlatform.buildRustPackage {
pname = "hx";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoBuildFlags = [ "-p" "hx-cli" ];
# ponytail: tests skipped (need git/network); enable when hermetic.
doCheck = false;
# rustls may build aws-lc-sys (cmake) depending on feature set.
nativeBuildInputs = [ pkgs.cmake pkgs.perl ];
dontUseCmakeConfigure = true;
meta = {
description = "Minimal Rust coding agent using existing subscriptions";
license = pkgs.lib.licenses.unlicense;
mainProgram = "hx";
packages = forAll (
pkgs:
let
target = targets.${pkgs.stdenv.hostPlatform.system} or "";
hasBin = bin.sha256 ? ${target};
hx = pkgs.rustPlatform.buildRustPackage {
pname = "hx";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoBuildFlags = [ "-p" "hx-cli" ];
# ponytail: tests skipped (need git/network); enable when hermetic.
doCheck = false;
# rustls may build aws-lc-sys (cmake) depending on feature set.
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 {
hx = { type = "app"; program = "${self.packages.${pkgs.system}.hx}/bin/hx"; };
hx = { type = "app"; program = "${self.packages.${pkgs.system}.default}/bin/hx"; };
default = hx;
});
overlays.default = _: prev: { hx = self.packages.${prev.system}.hx; };
overlays.default = _: prev: { hx = self.packages.${prev.system}.default; };
devShells = forAll (pkgs: {
default = pkgs.mkShell {