Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
061649cb07 | ||
|
|
9d8b7dfbd8 | ||
|
|
179e5cddc7 | ||
|
|
05165d7b8f | ||
|
|
c06381117b |
No files matched your search
@@ -15,6 +15,12 @@ hx -r # pick a session to resume
|
|||||||
hx -r parser # resume the session whose title best matches "parser"
|
hx -r parser # resume the session whose title best matches "parser"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
- Rust toolchain (to build from source; `cmake` and `perl` may be needed for the TLS stack).
|
||||||
|
- `git`.
|
||||||
|
- Linux: [`bubblewrap`](https://github.com/containers/bubblewrap) (`bwrap`) on `PATH` (`apt install bubblewrap`, `pacman -S bubblewrap`, `dnf install bubblewrap`). The Nix package wraps `hx` so it is provided automatically.
|
||||||
|
|
||||||
TUI: `enter` send, `shift-enter`/`alt-enter`/`ctrl-j` newline (or end a line with `\` and press enter), `esc` abort, `ctrl-o` expand tool output.
|
TUI: `enter` send, `shift-enter`/`alt-enter`/`ctrl-j` newline (or end a line with `\` and press enter), `esc` abort, `ctrl-o` expand tool output.
|
||||||
|
|
||||||
Shift-enter needs a terminal that reports it; hx turns on the kitty keyboard protocol when the terminal answers the probe. Works in ghostty, kitty, WezTerm (`enable_kitty_keyboard = true`), iTerm2, foot, Alacritty 0.13+, Windows Terminal (map shift-enter to `\u001b[13;2u`) and zellij 0.41+. tmux 3.2+ needs `set -g extended-keys on` and `set -g extended-keys-format csi-u`. Elsewhere use `alt-enter`, `ctrl-j` or a trailing `\`. `/keys` prints every key as hx receives it, to see what a terminal or multiplexer (e.g. herdr) passes through. Long input lines wrap; the box grows up to 10 rows.
|
Shift-enter needs a terminal that reports it; hx turns on the kitty keyboard protocol when the terminal answers the probe. Works in ghostty, kitty, WezTerm (`enable_kitty_keyboard = true`), iTerm2, foot, Alacritty 0.13+, Windows Terminal (map shift-enter to `\u001b[13;2u`) and zellij 0.41+. tmux 3.2+ needs `set -g extended-keys on` and `set -g extended-keys-format csi-u`. Elsewhere use `alt-enter`, `ctrl-j` or a trailing `\`. `/keys` prints every key as hx receives it, to see what a terminal or multiplexer (e.g. herdr) passes through. Long input lines wrap; the box grows up to 10 rows.
|
||||||
@@ -44,6 +50,8 @@ Lens findings and affected-test results appear after each turn as a `┄ lens
|
|||||||
|
|
||||||
Config: `~/.hx/config.toml`, overridden per project by `.hx/config.toml`. `hx config init [--project] [--force]` writes a fully commented sample with every key. Example:
|
Config: `~/.hx/config.toml`, overridden per project by `.hx/config.toml`. `hx config init [--project] [--force]` writes a fully commented sample with every key. Example:
|
||||||
|
|
||||||
|
**Session storage:** `sessions_dir` in config (or `HX_SESSIONS_DIR`, wins) moves sessions off `~/.hx/sessions`, e.g. to a synced or mounted cloud folder (rclone, Nextcloud, Syncthing). `~` expands; an unwritable path is an error, no silent fallback. `sessions_host = true` prefixes project folders with the host name so machines sharing one folder stay apart. Sessions are append-only JSONL: one hx per session file.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
provider = "claude" # or "codex"
|
provider = "claude" # or "codex"
|
||||||
# claude_model = "claude-sonnet-5-5" # default: the account's latest Sonnet
|
# claude_model = "claude-sonnet-5-5" # default: the account's latest Sonnet
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": "0.1.14",
|
"version": "0.1.16",
|
||||||
"sha256": {
|
"sha256": {
|
||||||
"aarch64-apple-darwin": "53a023dc0e8d915cbb62a8c41cb0e8132be68bc1e5b4584b098bbdeb92a6e750",
|
"aarch64-apple-darwin": "5750c046c3e592cbdc9b658ba9c499d44287e85fc0d47052d9cfbf0d9383cc77",
|
||||||
"x86_64-unknown-linux-musl": "d50e6dcd6af38dc9670b358c9e806d2e000538dd193a2987d4bec7884c9b2d78"
|
"x86_64-unknown-linux-musl": "93f0727fdb7cd47d682f7f37996a4060a948886a0a126ba6105c5c45d121053a"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
# compact_at = 900000 # auto-compact at this many tokens; default: 90% of the context window
|
# compact_at = 900000 # auto-compact at this many tokens; default: 90% of the context window
|
||||||
# max_tokens = 16384
|
# max_tokens = 16384
|
||||||
# permissions = "ask" # ask | auto (refuse dangerous calls, run safe ones) | yolo (nothing asks)
|
# permissions = "ask" # ask | auto (refuse dangerous calls, run safe ones) | yolo (nothing asks)
|
||||||
|
# sessions_dir = "~/Nextcloud/hx-sessions" # default ~/.hx/sessions; point at a synced/mounted cloud folder (env HX_SESSIONS_DIR wins)
|
||||||
|
# sessions_host = false # true: prefix project folders with the host name (machines sharing one sessions_dir)
|
||||||
# mouse = true # wheel scrolling; false keeps terminal text selection
|
# mouse = true # wheel scrolling; false keeps terminal text selection
|
||||||
# codemode = false # `codemode` tool: JS scripts that call other tools in a sandbox
|
# codemode = false # `codemode` tool: JS scripts that call other tools in a sandbox
|
||||||
# system_prompt = "..." # replaces the built-in prompt; AGENTS.md is still appended
|
# system_prompt = "..." # replaces the built-in prompt; AGENTS.md is still appended
|
||||||
|
|||||||
@@ -169,6 +169,10 @@ struct Config {
|
|||||||
codemode: Option<bool>,
|
codemode: Option<bool>,
|
||||||
/// Capture the mouse for wheel scrolling (default true; false = terminal selection works without shift).
|
/// Capture the mouse for wheel scrolling (default true; false = terminal selection works without shift).
|
||||||
mouse: Option<bool>,
|
mouse: Option<bool>,
|
||||||
|
/// Where sessions live (default `~/.hx/sessions`); `~` expands. Point at a synced/mounted cloud folder. `HX_SESSIONS_DIR` wins.
|
||||||
|
sessions_dir: Option<String>,
|
||||||
|
/// Prefix session folders with the host name, so machines sharing `sessions_dir` stay apart (default false).
|
||||||
|
sessions_host: Option<bool>,
|
||||||
/// Reuse the last model chosen with /model or /provider (default true).
|
/// Reuse the last model chosen with /model or /provider (default true).
|
||||||
remember_model: Option<bool>,
|
remember_model: Option<bool>,
|
||||||
/// `/model auto`: tier pins (`fast`, `balanced`, `deep` = model ids) and `down_after`.
|
/// `/model auto`: tier pins (`fast`, `balanced`, `deep` = model ids) and `down_after`.
|
||||||
@@ -244,6 +248,8 @@ impl Config {
|
|||||||
subagents: o.subagents.or(c.subagents),
|
subagents: o.subagents.or(c.subagents),
|
||||||
codemode: o.codemode.or(c.codemode),
|
codemode: o.codemode.or(c.codemode),
|
||||||
mouse: o.mouse.or(c.mouse),
|
mouse: o.mouse.or(c.mouse),
|
||||||
|
sessions_dir: o.sessions_dir.or(c.sessions_dir),
|
||||||
|
sessions_host: o.sessions_host.or(c.sessions_host),
|
||||||
remember_model: o.remember_model.or(c.remember_model),
|
remember_model: o.remember_model.or(c.remember_model),
|
||||||
auto: o.auto.or(c.auto),
|
auto: o.auto.or(c.auto),
|
||||||
permissions: o.permissions.or(c.permissions),
|
permissions: o.permissions.or(c.permissions),
|
||||||
@@ -591,8 +597,33 @@ impl<H: Hook> Hook for ArcHook<H> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn session_dir(cwd: &std::path::Path) -> std::path::PathBuf {
|
fn session_dir(cwd: &std::path::Path, cfg: &Config) -> Result<std::path::PathBuf> {
|
||||||
hx_core::session::dir(&context::hx_home(), cwd)
|
let home = context::hx_home();
|
||||||
|
let root = match std::env::var("HX_SESSIONS_DIR")
|
||||||
|
.ok()
|
||||||
|
.or(cfg.sessions_dir.clone())
|
||||||
|
{
|
||||||
|
Some(s) if !s.is_empty() => match s.strip_prefix('~') {
|
||||||
|
Some(r) => std::env::var_os("HOME")
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.join(r.trim_start_matches('/')),
|
||||||
|
None => s.into(),
|
||||||
|
},
|
||||||
|
_ => home.join("sessions"),
|
||||||
|
};
|
||||||
|
let host = cfg.sessions_host.unwrap_or(false).then(|| {
|
||||||
|
["HOSTNAME", "HOST", "COMPUTERNAME"]
|
||||||
|
.iter()
|
||||||
|
.find_map(|k| std::env::var(k).ok())
|
||||||
|
.or_else(|| std::fs::read_to_string("/etc/hostname").ok())
|
||||||
|
.map_or("host".into(), |h| h.trim().to_string())
|
||||||
|
});
|
||||||
|
let dir = hx_core::session::dir(&root, cwd, host.as_deref());
|
||||||
|
// fail loud: a silent fallback would leave sessions off the cloud folder
|
||||||
|
std::fs::create_dir_all(&dir)
|
||||||
|
.map_err(|e| anyhow::anyhow!("sessions dir {}: {e}", dir.display()))?;
|
||||||
|
Ok(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -912,7 +943,7 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
.unwrap_or_else(|| hx_ai::models::default_for(kind, &models))
|
.unwrap_or_else(|| hx_ai::models::default_for(kind, &models))
|
||||||
});
|
});
|
||||||
let dir = session_dir(&cwd);
|
let dir = session_dir(&cwd, &cfg)?;
|
||||||
let query = cli.resume.as_deref().filter(|q| !q.is_empty());
|
let query = cli.resume.as_deref().filter(|q| !q.is_empty());
|
||||||
let path = match (cli.session, cli.r#continue, query) {
|
let path = match (cli.session, cli.r#continue, query) {
|
||||||
_ if acp_id.is_some() => dir.join(format!(
|
_ if acp_id.is_some() => dir.join(format!(
|
||||||
|
|||||||
@@ -173,14 +173,18 @@ impl Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `<hx home>/sessions/<slug of cwd>`.
|
/// `<root>/<slug of cwd>`, with `<host>-` in front when `host` is set (shared roots).
|
||||||
pub fn dir(home: &Path, cwd: &Path) -> PathBuf {
|
pub fn dir(root: &Path, cwd: &Path, host: Option<&str>) -> PathBuf {
|
||||||
let slug: String = cwd
|
let cwd = cwd.to_string_lossy();
|
||||||
.to_string_lossy()
|
let slug: String = host
|
||||||
|
.into_iter()
|
||||||
|
.chain([cwd.trim_matches('/')])
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("/")
|
||||||
.chars()
|
.chars()
|
||||||
.map(|c| if c.is_ascii_alphanumeric() { c } else { '-' })
|
.map(|c| if c.is_ascii_alphanumeric() { c } else { '-' })
|
||||||
.collect();
|
.collect();
|
||||||
home.join("sessions").join(slug.trim_matches('-'))
|
root.join(slug.trim_matches('-'))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A fresh, not yet created session file in `dir` (created on first append).
|
/// A fresh, not yet created session file in `dir` (created on first append).
|
||||||
@@ -279,7 +283,7 @@ pub fn list(dir: &Path) -> Vec<Meta> {
|
|||||||
v
|
v
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sessions of every project under `<hx home>/sessions`, newest first.
|
/// Sessions of every project under the sessions root, newest first.
|
||||||
pub fn list_all(root: &Path) -> Vec<Meta> {
|
pub fn list_all(root: &Path) -> Vec<Meta> {
|
||||||
let mut v: Vec<Meta> = std::fs::read_dir(root)
|
let mut v: Vec<Meta> = std::fs::read_dir(root)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -370,8 +374,12 @@ mod tests {
|
|||||||
.collect();
|
.collect();
|
||||||
assert_eq!(t, [("newer", "other"), ("fix parser", "proj")]);
|
assert_eq!(t, [("newer", "other"), ("fix parser", "proj")]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
dir(Path::new("/h"), Path::new("/a/b c")),
|
dir(Path::new("/h"), Path::new("/a/b c"), None),
|
||||||
Path::new("/h/sessions/a-b-c")
|
Path::new("/h/a-b-c")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
dir(Path::new("/h"), Path::new("/a/b"), Some("box")),
|
||||||
|
Path::new("/h/box-a-b")
|
||||||
);
|
);
|
||||||
let n = new_path(&proj);
|
let n = new_path(&proj);
|
||||||
assert!(n.starts_with(&proj) && !n.exists());
|
assert!(n.starts_with(&proj) && !n.exists());
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
packages = [
|
packages = [
|
||||||
pkgs.git
|
pkgs.git
|
||||||
pkgs.stdenv.cc
|
pkgs.stdenv.cc
|
||||||
];
|
] ++ lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.bubblewrap;
|
||||||
|
|
||||||
languages.rust.enable = true;
|
languages.rust.enable = true;
|
||||||
}
|
}
|
||||||
@@ -31,8 +31,12 @@
|
|||||||
# ponytail: tests skipped (need git/network); enable when hermetic.
|
# ponytail: tests skipped (need git/network); enable when hermetic.
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
# rustls may build aws-lc-sys (cmake) depending on feature set.
|
# rustls may build aws-lc-sys (cmake) depending on feature set.
|
||||||
nativeBuildInputs = [ pkgs.cmake pkgs.perl ];
|
nativeBuildInputs = [ pkgs.cmake pkgs.perl ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.makeWrapper ];
|
||||||
dontUseCmakeConfigure = true;
|
dontUseCmakeConfigure = true;
|
||||||
|
# bubblewrap sandbox runtime dependency (Linux only).
|
||||||
|
postInstall = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
|
||||||
|
wrapProgram $out/bin/hx --suffix PATH : ${pkgs.lib.makeBinPath [ pkgs.bubblewrap ]}
|
||||||
|
'';
|
||||||
meta = {
|
meta = {
|
||||||
description = "Minimal Rust coding agent using existing subscriptions";
|
description = "Minimal Rust coding agent using existing subscriptions";
|
||||||
license = pkgs.lib.licenses.unlicense;
|
license = pkgs.lib.licenses.unlicense;
|
||||||
@@ -67,7 +71,7 @@
|
|||||||
|
|
||||||
devShells = forAll (pkgs: {
|
devShells = forAll (pkgs: {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
packages = with pkgs; [ cargo rustc clippy rustfmt rust-analyzer git ];
|
packages = with pkgs; [ cargo rustc clippy rustfmt rust-analyzer git ] ++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.bubblewrap;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user