Skip to content

Reason Network: your team's coding agents, talking to each other. The engine behind `reason network`.

Review fixes: a safe move-over, honest names, a careful installer

Lars Talian195205cea6d6
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 06ac266..196f779 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,6 +1,6 @@
name: release
-# Push a tag like v0.11.0 to build reason-network for macOS, Linux and Windows and publish a GitHub release, with the
+# Push a tag like v0.10.4 to build reason-network for macOS, Linux and Windows and publish a GitHub release, with the
# install scripts a standalone install (and its updates) uses. The reason CLI pins the macOS and Linux archives' sha256.
on:
push:
diff --git a/DESIGN.md b/DESIGN.md
index 81c8795..8bf6794 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -62,11 +62,12 @@ unread mail**, so "tell the api agent X" survives restarts (idea from agentbus).
│ codex ── reason-network mcp ──┤ unix socket ┌──────────────┐ │ iroh QUIC (ed25519-authenticated)
│ cursor ── reason-network mcp ──┼──────────────────▶ │ Reason Network daemon │◀──┼──▶ direct on LAN (mDNS)
│ hooks: reason-network hook … ──┘ ~/.reason/network/sock │ SQLite │ │ hole-punched over internet
-│ you: Reason Network who/send ──────────────────▶ └──────────────┘ │ relay fallback over HTTPS :443
+│ you: reason-network who/send ──────────────────▶ └──────────────┘ │ relay fallback over HTTPS :443
└───────────────────────────────────────────────────────────────┘
```
-One static Rust binary, `Reason Network`, with subcommands:
+One static Rust binary, `reason-network` (fronted by `reason network` where the Reason CLI is installed), with
+subcommands:
- `reason network daemon`: per machine. Owns the iroh endpoint, roster, directory, mailboxes (SQLite). Started on
demand by any other subcommand, or installed as a launchd/systemd user service (on Windows, started at logon
@@ -231,13 +232,15 @@ not approve. Nothing changes how an agent works when it isn't messaging.
## Install UX (M3)
```sh
-curl -fsSL https://…/install.sh | sh # dist-built static binary; also Homebrew
-Reason Network init vibes --as alex # first person: creates the team
-Reason Network invite # prints: Reason Network join cm1…
-Reason Network join cm1… --as alice # friends: joins, installs service, wires up agents
+curl -fsSL https://…/install.sh | sh # asks: sign in with Reason (the Reason CLI), or no account
+reason-network init vibes --as alex # no account: the first person creates the team
+reason-network invite # prints: reason-network join cm1…
+reason-network join cm1… --as alice # friends: joins, installs the service, wires up agents
```
-`join`/`init` run `reason network setup`, which detects installed agents and wires each one (backing up every file it
+With Reason, `reason network` does all of it: the workspace is the team.
+
+`join`/`init` run `setup`, which detects installed agents and wires each one (backing up every file it
edits): Claude Code plugin or `claude mcp add --scope user` + hooks, `~/.codex/config.toml` + `hooks.json`,
`~/.cursor/mcp.json` + `hooks.json`, `~/.gemini/settings.json`, opencode plugin + MCP, Copilot
`mcp-config.json` + hooks. Or paste one line into any agent: "install Reason Network and join cm1…".
@@ -249,15 +252,16 @@ edits): Claude Code plugin or `claude mcp add --scope user` + hooks, `~/.codex/c
- **M1, the team** (done): iroh endpoint, signed roster, `init`/`invite`/`join`/`remove`/`leave`, presence
sync, routing with acks and outbox, hold/refuse policies, rate limit, mDNS, custom relay.
- **M2, adapters** (done): Codex (`codex queue` + hooks), Cursor, Gemini, Copilot (hooks), opencode (plugin);
- `reason network setup [--remove]`, launchd/systemd service, `reason network doctor`. Amp: MCP only, by hand.
-- **M3, ship** (done, pending a first tagged release): GitHub Actions builds for macOS and Linux, `install.sh`
- (install and join in one line), GitHub Pages site. Later: Homebrew, a Claude Code plugin marketplace.
+ `setup [--remove]`, launchd/systemd service, `doctor`. Amp: MCP only, by hand.
+- **M3, ship** (done): GitHub Actions builds for macOS, Linux and Windows; `install.sh` / `install.ps1` (install and
+ join in one line, or hand over to the Reason CLI), with the release. Standalone installs update themselves; the
+ Reason CLI pins its own. Later: Homebrew.
- **M4, team features**: file-overlap warnings ("bob/api-codex is also editing src/auth.rs", from
`PostToolUse` edit paths), anchor mailbox and history, hold/approve notifications, web dashboard.
## Defaults (easy to change)
-- Names: `Reason Network` for the binary, `Reason Network` for the repo.
+- Names: `reason-network` for the binary and the repo, Reason Network in prose.
- License: MIT OR Apache-2.0.
- Inbound policy between teammates: `accept` (per-person `hold`/`refuse` available).
- Teammates see repo@branch and the last component of the working directory; full paths are opt-in.
diff --git a/README.md b/README.md
index 30e0a17..a60823b 100644
--- a/README.md
+++ b/README.md
@@ -14,24 +14,20 @@ opencode, pi and Reason.
curl -fsSL https://github.com/reason-machines/reason-network/releases/latest/download/install.sh | sh
```
-It asks one thing: sign in with Reason, or not.
+First it asks: sign in with Reason, or not.
- **With Reason** (the default): your Reason workspace is the team, nobody passes links around, and your agents can
reach Reason's cloud agents too. The [Reason CLI](https://reasonmachines.com) installs and runs it; from then on
it's `reason network`.
- **Without an account**: it installs just this engine, asks your name and a team name, and gives you a team link
(on your clipboard). Teammates open it, paste one command, type their name, and they're in. Or they tell their
- agent "join my Reason Network team: <link>".
+ agent "join my Reason Network team: <link>". On Windows, in PowerShell:
+ `irm https://github.com/reason-machines/reason-network/releases/latest/download/install.ps1 | iex`
That's it. Ask any agent "who's on the team?", or tell it to ask someone's agent something.
-On Windows (no account), in PowerShell:
-
-```powershell
-irm https://github.com/reason-machines/reason-network/releases/latest/download/install.ps1 | iex
-```
-
-**Coming from tincan?** Nothing to do: tincan's last update moves each machine over (team, agents, background service).
+**Coming from tincan?** Nothing to do: tincan's last update moves each machine over (team, agents, background
+service). The command is now `reason-network` (`tincan` keeps working), and Codex asks once to trust the new hooks.
## What you get
@@ -57,8 +53,8 @@ reason-network link # the team link a
reason-network setup # which agents are on it, and how messages are handled
```
-With the Reason CLI, `reason network` runs the same commands (and `reason network alice/api-claude "…"` asks and waits
-for the answer).
+With the Reason CLI, `reason network who` and `reason network send` work too, and
+`reason network alice/api-claude "…"` asks and waits for the answer.
## How it works
@@ -74,8 +70,8 @@ State lives in `~/.reason/network`. Details: [DESIGN.md](DESIGN.md).
## For AI agents
If your user gave you a Reason Network team link (`https://…/network/join/#tincan1…`) and wants to join: ask them
-what name teammates should see, then run this with the whole link, exactly as given. It asks no questions and needs no
-account:
+what name teammates should see, then run this with the whole link, exactly as given (first check it ends in `#tincan1`
+followed only by letters, digits, `-` and `_`). It asks no questions and needs no account:
```sh
curl -fsSL https://github.com/reason-machines/reason-network/releases/latest/download/install.sh | sh -s -- '<the whole link>' --as <name>
@@ -96,12 +92,12 @@ service. `reason-network who` shows the team. Agents without its tools, like clo
## Uninstall
```sh
-reason-network setup --remove && reason-network leave && rm -rf ~/.reason/network ~/.local/bin/reason-network
+reason-network leave && reason-network setup --remove && rm -rf ~/.reason/network ~/.local/bin/reason-network
```
-On Windows, in PowerShell: `reason-network setup --remove; reason-network leave; Remove-Item -Recurse -Force ~\.reason\network, ~\.local\bin\reason-network*`
+On Windows, in PowerShell: `reason-network leave; reason-network setup --remove; Remove-Item -Recurse -Force ~\.reason\network, ~\.local\bin\reason-network*`
-With the Reason CLI: `reason network setup --remove`, then `reason network leave`.
+With the Reason CLI: `reason network leave`, then `reason network setup --remove`.
## Build
diff --git a/install.ps1 b/install.ps1
index 88433a3..bac84a9 100644
--- a/install.ps1
+++ b/install.ps1
@@ -40,6 +40,9 @@
Add-Type -AssemblyName System.IO.Compression.FileSystem
[IO.Compression.ZipFile]::ExtractToDirectory($zip, $tmp)
+ $new = Join-Path $tmp 'reason-network.exe'
+ & $new --version | Out-Null
+ if ($LASTEXITCODE) { die "the downloaded binary doesn't run here; not installing" }
New-Item -ItemType Directory -Force $bin | Out-Null
$exe = Join-Path $bin 'reason-network.exe'
# Windows can't replace a program that is running, but it can rename it: move the old one aside, and delete
diff --git a/install.sh b/install.sh
index cac0b08..0673413 100755
--- a/install.sh
+++ b/install.sh
@@ -1,12 +1,12 @@
#!/bin/sh
-# Installs Reason Network on its own (no account needed) for macOS or Linux.
+# Installs Reason Network for macOS or Linux: with the Reason CLI (sign in), or on its own (no account).
#
# curl -fsSL <this url> | sh install, then set up (with Reason, or start or join a team)
# curl -fsSL <this url> | sh -s -- <team link> install, then join that team
# curl -fsSL <this url> | sh -s -- <team link> --as <name> the same, without questions (for agents)
# curl -fsSL <this url> | sh -s -- init <team> --as <name> install and start a team, without questions
#
-# Environment: REASON_NETWORK_BIN_DIR (default ~/.local/bin), REASON_NETWORK_VERSION (default latest), REASON_NETWORK_REPO,
+# Environment: REASON_NETWORK_BIN_DIR (default ~/.local/bin), REASON_NETWORK_VERSION (a tag like v0.10.4; default latest), REASON_NETWORK_REPO,
# REASON_NETWORK_DOWNLOAD_BASE (a mirror serving the release files), REASON_NETWORK_NO_PROMPT (never ask anything: updates).
set -eu
@@ -33,18 +33,18 @@ target="$arch-$os"
# your agents reach Reason's cloud agents, and the Reason CLI installs and updates this engine. Without it, a team
# link and no account. Never asked when joining with a link, for agents, or for updates.
if [ $# -eq 0 ] && [ -z "${REASON_NETWORK_NO_PROMPT:-}" ] && [ ! -e "$bin_dir/reason-network" ] && (exec </dev/tty) 2>/dev/null; then
- say "With Reason, your Reason workspace is the team (no links to pass around) and your agents can reach Reason's"
- say "cloud agents. Without it: a team link, no account."
- printf 'Sign in with Reason? [Y/n] '
+ say "Use your Reason account? Your workspace becomes the team, no links to pass around."
+ printf 'Answer n for no account and a team link. [Y/n] '
read -r answer </dev/tty || answer=n
case "$answer" in
[nN]*) ;;
*)
reason="$(command -v reason || true)"
if [ -z "$reason" ]; then
- curl -fsSL https://reasonmachines.com/install.sh | bash -s -- --minimal --no-login ||
+ installer="$(curl -fsSL https://reasonmachines.com/install.sh)" && printf '%s\n' "$installer" | bash -s -- --minimal --no-login ||
die "installing Reason failed; run this again and answer n to go without an account"
- reason="${REASON_INSTALL_DIR:-$HOME/.local/bin}/reason"
+ reason="${REASON_INSTALL_DIR:-${ARA_INSTALL_DIR:-$HOME/.local/bin}}/reason"
+ [ -x "$reason" ] || die "Reason installed, but not at $reason; run: reason network"
fi
exec "$reason" network </dev/tty
;;
@@ -73,8 +73,11 @@ else
fi
[ -n "$want" ] && [ "$want" = "$got" ] || die "checksum mismatch; not installing"
tar -xzf "$tmp/reason-network.tar.gz" -C "$tmp"
+"$tmp/reason-network" --version >/dev/null 2>&1 || die "the downloaded binary doesn't run here; not installing"
mkdir -p "$bin_dir"
-install -m 755 "$tmp/reason-network" "$bin_dir/reason-network"
+# A new file moved into place: whatever runs the old one (a hook, an agent's tools) never sees a half-written binary.
+install -m 755 "$tmp/reason-network" "$bin_dir/.reason-network.new"
+mv -f "$bin_dir/.reason-network.new" "$bin_dir/reason-network"
say "Installed $bin_dir/reason-network ($("$bin_dir/reason-network" --version))"
case ":$PATH:" in
@@ -83,6 +86,9 @@ case ":$PATH:" in
say " export PATH=\"$bin_dir:\$PATH\"" ;;
esac
+rm -rf "$tmp"
+trap - EXIT INT TERM
+
# Hand over to reason-network: it asks a few questions (name, invite code, which agents) in your terminal. Under
# `curl | sh` our stdin is the script, so read answers from the terminal itself when there is one.
# (In a subshell: in dash, Ubuntu's sh, a failed redirection on `:` would end the whole script.)
diff --git a/src/daemon/mail.rs b/src/daemon/mail.rs
index 5aab6f2..fb6c38a 100644
--- a/src/daemon/mail.rs
+++ b/src/daemon/mail.rs
@@ -64,7 +64,8 @@ impl Inner {
}
}
-const UPGRADE: &str = "update Reason Network: messages go between agent sessions now";
+const UPGRADE: &str =
+ "update Reason Network (with the Reason CLI, `reason update`): messages go between agent sessions now";
const LOOP_NOTE: &str = "refused: these two agents have exchanged a lot of messages in the last few minutes, which \
looks like a loop. Check with your user before continuing.";
diff --git a/src/daemon/update.rs b/src/daemon/update.rs
index 9c3fe01..e827bde 100644
--- a/src/daemon/update.rs
+++ b/src/daemon/update.rs
@@ -29,8 +29,7 @@ impl Daemon {
/// Whether this binary may replace itself.
pub(super) fn allowed(enabled: bool) -> bool {
- let from_source = crate::util::current_exe().is_ok_and(|p| p.components().any(|c| c.as_os_str() == "target"));
- enabled && !from_source && !crate::managed() && crate::paths::env_var_os("NO_UPDATE").is_none()
+ enabled && !crate::util::from_source() && !crate::managed() && crate::paths::env_var_os("NO_UPDATE").is_none()
}
/// Installs the latest release if it is newer than this one; returns its version.
@@ -80,7 +79,7 @@ async fn update() -> Result<Option<String>> {
/// The newest release's version, from where GitHub's "latest release" link redirects.
async fn latest_version() -> Result<String> {
- let repo = crate::paths::env_var("REPO").unwrap_or_else(|_| crate::REPO.into());
+ let repo = crate::REPO;
let null = if cfg!(windows) { "NUL" } else { "/dev/null" };
let out = tokio::process::Command::new("curl")
.args([
diff --git a/src/main.rs b/src/main.rs
index 7001a61..3f0fa24 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -44,7 +44,8 @@ pub const REPO: &str = "reason-machines/reason-network";
pub fn managed() -> bool {
static MANAGED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*MANAGED.get_or_init(|| {
- util::current_exe().is_ok_and(|p| p.starts_with(paths::user_home().join(".reason").join("bin")))
+ let real = |p: std::path::PathBuf| p.canonicalize().unwrap_or(p);
+ util::current_exe().is_ok_and(|p| real(p).starts_with(real(paths::user_home().join(".reason").join("bin"))))
})
}
@@ -57,6 +58,19 @@ impl std::fmt::Display for Command {
}
}
+/// The engine as a command agents can run here: its full path where the Reason CLI manages it (whose `reason network`
+/// doesn't take every engine command and flag), `reason-network` on its own.
+pub struct Engine;
+pub const ENGINE: Engine = Engine;
+impl std::fmt::Display for Engine {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ match setup::exe() {
+ Ok(p) if managed() => write!(f, "{}", p.display()),
+ _ => f.write_str(AGENT_NAME),
+ }
+ }
+}
+
/// The one line that installs Reason Network on its own (no account needed) and runs `reason-network <args>`: for
/// macOS and Linux, and for Windows.
pub fn install_lines(args: &str) -> [String; 2] {
@@ -76,7 +90,7 @@ pub fn installer(dir: &std::path::Path) -> std::process::Command {
cmd.args(["-NoProfile", "-NonInteractive", "-Command", &format!("irm {base}/install.ps1 | iex")]);
} else {
cmd = std::process::Command::new("sh");
- cmd.arg("-c").arg(format!("curl -fsSL {base}/install.sh | sh"));
+ cmd.arg("-c").arg(format!("s=\"$(curl -fsSL {base}/install.sh)\" && printf '%s\\n' \"$s\" | sh"));
}
cmd.env("REASON_NETWORK_BIN_DIR", dir).env("REASON_NETWORK_NO_PROMPT", "1");
cmd
@@ -113,7 +127,7 @@ enum Cmd {
},
/// Send a message to an agent session (`person/session`), all of a person's (`person/*`), `repo:<name>` or `*`.
/// It comes from the agent session whose shell runs it, `--from <session>`, or from a plain terminal,
- /// `<you>/terminal` (read replies with `reason network listen --as terminal`)
+ /// `<you>/terminal` (read replies with `listen --as terminal`)
Send {
to: String,
/// The message; read from stdin when omitted or `-`
@@ -126,7 +140,7 @@ enum Cmd {
/// Also pop it up on the person's screen (then `<to>` may be your own name)
#[arg(long, conflicts_with = "fyi")]
notify: bool,
- /// Send as this agent session here (e.g. one made with `reason network listen --as <name>`)
+ /// Send as this agent session here (e.g. one made with `listen --as <name>`)
#[arg(long)]
from: Option<String>,
},
@@ -145,7 +159,7 @@ enum Cmd {
/// Don't configure agents or install the background service
#[arg(long)]
no_setup: bool,
- /// Your own iroh relay, from the start (see `reason network relay`)
+ /// Your own iroh relay, from the start (see `relay`)
#[arg(long)]
relay: Option<String>,
},
@@ -443,14 +457,17 @@ async fn cli(cmd: Cmd) -> Result<()> {
let who = if me { "another machine of yours" } else { "a teammate" };
println!("Invite code for {who}: {}\n", i.code);
let [unix, windows] = install_lines(&i.code);
- println!("They run this, which installs Reason Network and joins the team:\n");
+ if managed() {
+ println!("Teammates in your Reason workspace just run `reason network`. Anyone else:\n");
+ }
+ println!("They run this, which installs Reason Network (no account needed) and joins the team:\n");
println!(" {unix}\n");
println!("On Windows, in PowerShell:\n\n {windows}\n");
println!(
- "(or `{CLI} join {}` if it's installed). Works once, within {}h, while this machine is online.",
+ "(or `{AGENT_NAME} join {}` if it's installed). Works once, within {}h, while this machine is online.",
i.code, i.hours
);
- println!("If this machine will be offline, use the long form instead: {CLI} join {}", i.ticket);
+ println!("If this machine will be offline, use the long form instead: {AGENT_NAME} join {}", i.ticket);
if me {
println!(
"\nFor a cloud agent of yours (Grok Bot, Dots, Muse, …), send it: join my Reason Network team as {}: {}",
diff --git a/src/mcp.rs b/src/mcp.rs
index 20936d9..06b2fd3 100644
--- a/src/mcp.rs
+++ b/src/mcp.rs
@@ -27,7 +27,7 @@ use std::{
};
use tokio::sync::mpsc;
-/// How agents should use Reason Network, kept once: in the skill, which Reason Network serves to cloud agents.
+/// How agents should use Reason Network, kept once: in the skill, for agents with the tools and without.
const SKILL: &str = include_str!("skill.md");
fn instructions() -> String {
diff --git a/src/migrate.rs b/src/migrate.rs
index 9ccec17..23045ae 100644
--- a/src/migrate.rs
+++ b/src/migrate.rs
@@ -3,7 +3,7 @@
//! updater checking the version. `paths` has already moved the state; the daemon's first start here rewires the
//! agents and swaps the login service. Agent sessions started before keep working until they end.
-use crate::{AGENT_NAME, LEGACY_NAME, setup, util};
+use crate::{AGENT_NAME, LEGACY_NAME, paths, setup, util};
/// Started under the old name, runs as reason-network instead, so everything after this is our own binary.
pub fn as_ours() {
@@ -25,34 +25,54 @@ pub fn as_ours() {
/// Moves this machine's agents and login service over from the tincan beside us, if that hasn't happened yet.
/// Lines go to `log`.
pub async fn run(log: fn(&str)) {
- let from_source = util::current_exe().is_ok_and(|p| p.components().any(|c| c.as_os_str() == "target"));
let Ok(exe) = setup::exe() else { return };
let old = setup::legacy_exe(&exe);
- if from_source || crate::managed() || !old.exists() {
+ // Only tincan's last update leaves this: a copy of this very binary under the old name. Anything else called tincan
+ // (a tincan of its own, a script) isn't ours to move. Once moved, it's a link to us, or gone.
+ let copy = std::fs::symlink_metadata(&old).is_ok_and(|m| m.is_file())
+ && std::fs::read(&old).is_ok_and(|b| std::fs::read(&exe).is_ok_and(|o| o == b));
+ // Where the Reason CLI's engine is installed too, it owns the agents and the service.
+ let reason_cli = paths::user_home().join(".reason").join("bin").join(exe.file_name().unwrap_or_default()).exists();
+ if util::from_source() || crate::managed() || reason_cli || !copy {
return;
}
- #[cfg(unix)]
- let service = crate::paths::env_var_os("NO_SERVICE").is_none() && setup::unregister_legacy_service(&exe);
- #[cfg(windows)]
- setup::move_legacy_run_entry(&exe);
let out = setup::apply(&exe, &setup::legacy_wiring(&exe), &[], None, false).await;
for line in out.lines.iter().chain(&out.notes) {
log(&format!("moved over from {LEGACY_NAME}: {line}"));
}
+ // The login service: ours goes in first, and the old one only once it has (stopped last: it may be what runs this
+ // very process; ours takes over when it's gone).
+ let service = paths::env_var_os("NO_SERVICE").is_none();
#[cfg(unix)]
- if service {
- match setup::install_service_from_daemon(&exe).await {
- Ok(s) => log(&format!("moved over from {LEGACY_NAME}: service: {s}")),
- Err(e) => log(&format!("moved over from {LEGACY_NAME}: service not installed: {e:#}")),
- }
+ let swap = service
+ && setup::legacy_service(&exe)
+ && match setup::install_service_from_daemon(&exe).await {
+ Ok(s) => {
+ log(&format!("moved over from {LEGACY_NAME}: service: {s}"));
+ true
+ }
+ Err(e) => {
+ log(&format!("moved over from {LEGACY_NAME}: kept its service, ours didn't install: {e:#}"));
+ false
+ }
+ };
+ // (A Run entry can't carry an explicit home.)
+ #[cfg(windows)]
+ if service && paths::env_var_os("HOME").is_none() {
+ setup::move_legacy_run_entry(&exe);
}
- // The copy tincan's update left under the old name. (Windows keeps it while it still runs; the next start goes.)
- if std::fs::read(&old).is_ok_and(|b| std::fs::read(&exe).is_ok_and(|o| o == b)) {
- let _ = std::fs::remove_file(&old);
+ // The copy becomes a link to us, so `tincan` keeps working, once no agent still runs it. (Windows removes it
+ // instead, once nothing runs it: the next start.)
+ let left = setup::legacy_wiring(&exe);
+ if !left.is_empty() {
+ log(&format!("moved over from {LEGACY_NAME}: kept it for {} until they move over", left.join(", ")));
+ } else if std::fs::remove_file(&old).is_ok() {
+ #[cfg(unix)]
+ let _ = std::os::unix::fs::symlink(AGENT_NAME, &old);
}
- // Last: the old service may be what runs this very process. Ours takes over once it has gone.
#[cfg(unix)]
- if service {
+ if swap {
+ setup::unregister_legacy_service(&exe);
setup::stop_legacy_service();
}
}
diff --git a/src/render.rs b/src/render.rs
index ab038e8..fe5daa2 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -1,6 +1,6 @@
//! Text shown to agents (tool results, injected messages) and in the CLI.
-use crate::{CLI, proto::*, util};
+use crate::{ENGINE, proto::*, util};
use std::fmt::Write;
/// Terminal colours for people reading the CLI; agents, pipes and `NO_COLOR` get plain text.
@@ -242,7 +242,7 @@ pub fn for_agent(msgs: &[Message], agent: Option<&str>, cli: bool) -> String {
};
// No Reason Network tools (Reason's agent; a Claude session from before Reason Network), but commands run on this computer.
let reply = if cli || agent == Some("reason") {
- format!("Reply if useful: {CLI} send {} --from {} \"<reply>\"", last.from, last.to)
+ format!("Reply if useful: {ENGINE} send {} --from {} \"<reply>\"", last.from, last.to)
} else {
format!("Reply if useful with send_message to \"{}\".", last.from)
};
diff --git a/src/setup.rs b/src/setup.rs
index a5f280b..24ac92a 100644
--- a/src/setup.rs
+++ b/src/setup.rs
@@ -1,6 +1,6 @@
-//! `reason network setup`: wires reason network into every agent on this machine (MCP server, plus hooks where the agent
-//! has them) and installs the daemon as a login service. `reason network setup --remove` undoes it. Every file it edits
-//! is backed up once, as `<file>.bak-reason`. Also `reason network doctor`.
+//! `setup`: wires Reason Network into every agent on this machine (MCP server, plus hooks where the agent has them) and
+//! installs the daemon as a login service. `setup --remove` undoes it. Every file it edits
+//! is backed up once, as `<file>.bak-reason`. Also `doctor`.
//!
//! Earlier builds wired agents in under `LEGACY_NAME`. Each step here also takes out what this binary's path put
//! there under that name, so an update moves an agent over and leaves nothing behind; another program of that name
@@ -128,7 +128,7 @@ fn write_file(path: &Path, content: &str, dry: bool) -> Result<bool> {
}
fn write_json(path: &Path, v: &Value, dry: bool) -> Result<bool> {
- // Removing reason network from a config that never existed leaves an empty shell: don't create a file for that.
+ // Removing Reason Network from a config that never existed leaves an empty shell: don't create a file for that.
if !path.exists() && hollow(v) {
return Ok(false);
}
@@ -346,7 +346,7 @@ fn codex(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
let did = write_json(&hooks_path, &v, dry)?;
r.lines.push(changed(&hooks_path, did));
if did && !remove {
- r.notes.push("Codex asks once to trust reason network's hooks: choose \"Trust all and continue\".".into());
+ r.notes.push("Codex asks once to trust Reason Network's hooks: choose \"Trust all and continue\".".into());
}
Ok(Some(r))
}
@@ -423,7 +423,7 @@ fn gemini(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
let did = write_json(&path, &v, dry)?;
r.lines.push(changed(&path, did));
if did && !remove {
- r.notes.push("Gemini CLI only runs reason network in trusted folders (`/permissions trust`).".into());
+ r.notes.push("Gemini CLI only runs Reason Network in trusted folders (`/permissions trust`).".into());
}
Ok(Some(r))
}
@@ -485,7 +485,7 @@ fn opencode(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
let path = dir.join("opencode.json");
if dir.join("opencode.jsonc").exists() && !path.exists() {
r.notes.push(format!(
- "opencode: you use opencode.jsonc, which reason network doesn't edit. Add under \"mcp\": \"{AGENT_NAME}\": {{\"type\": \"local\", \"command\": [\"{}\", \"mcp\"], \"environment\": {{\"REASON_NETWORK_AGENT\": \"opencode\"}}}}",
+ "opencode: you use opencode.jsonc, which Reason Network doesn't edit. Add under \"mcp\": \"{AGENT_NAME}\": {{\"type\": \"local\", \"command\": [\"{}\", \"mcp\"], \"environment\": {{\"REASON_NETWORK_AGENT\": \"opencode\"}}}}",
exe.display()
));
} else {
@@ -521,7 +521,7 @@ fn opencode(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
// ---- pi ----
-/// One extension does it all: it adds reason network's MCP server to each session (deferred, so the tools stay out of
+/// One extension does it all: it adds Reason Network's MCP server to each session (deferred, so the tools stay out of
/// the model's context until it looks for them) and delivers messages.
fn pi(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
if !pi_home().exists() && agent::find_bin("pi").is_none() {
@@ -612,7 +612,7 @@ fn service_path_for(name: &str) -> PathBuf {
#[cfg(unix)]
fn remove_legacy_service(exe: &Path, dry: bool) -> bool {
if dry {
- return std::fs::read_to_string(service_path_for(&legacy_service_name())).is_ok_and(|t| ours(&t, exe));
+ return legacy_service(exe);
}
let had = unregister_legacy_service(exe);
if had {
@@ -621,13 +621,19 @@ fn remove_legacy_service(exe: &Path, dry: bool) -> bool {
had
}
+/// Whether that service is registered here, for this binary or the tincan it replaced.
+#[cfg(unix)]
+pub fn legacy_service(exe: &Path) -> bool {
+ std::fs::read_to_string(service_path_for(&legacy_service_name())).is_ok_and(|t| ours(&t, exe))
+}
+
/// Takes that service off the login items without stopping it: it may be what runs this very process. True if there
/// was one.
#[cfg(unix)]
pub fn unregister_legacy_service(exe: &Path) -> bool {
let name = legacy_service_name();
let path = service_path_for(&name);
- if !std::fs::read_to_string(&path).is_ok_and(|t| ours(&t, exe)) {
+ if !legacy_service(exe) {
return false;
}
let systemctl =
@@ -674,7 +680,7 @@ async fn service(exe: &Path, remove: bool, dry: bool) -> Result<String> {
install_service(exe, remove, dry, true).await
}
-/// Installs ours from the daemon the legacy service runs, without stopping that daemon (itself) first: it ends when
+/// Installs ours from the daemon the legacy service runs, leaving that service and daemon (itself) alone: it ends when
/// the legacy service is stopped, and ours takes over.
#[cfg(unix)]
pub async fn install_service_from_daemon(exe: &Path) -> Result<String> {
@@ -686,7 +692,7 @@ async fn install_service(exe: &Path, remove: bool, dry: bool, stop: bool) -> Res
let path = service_path();
let uid = unsafe { libc::getuid() };
let engine_home = crate::paths::env_var("HOME").ok();
- let legacy = remove_legacy_service(exe, dry);
+ let legacy = stop && remove_legacy_service(exe, dry);
if cfg!(target_os = "macos") {
let target = format!("gui/{uid}/{}", service_name());
if remove {
@@ -770,7 +776,7 @@ async fn install_service(exe: &Path, remove: bool, dry: bool, stop: bool) -> Res
}
let home_env = engine_home.map(|h| format!("Environment=\"REASON_NETWORK_HOME={h}\"\n")).unwrap_or_default();
let unit = format!(
- "[Unit]\nDescription=Reason network daemon (reason network)\n\n[Service]\nExecStart={} daemon --service\nRestart=always\nRestartSec=3\nEnvironment=\"PATH={}\"\n{home_env}StandardError=append:{}\n\n[Install]\nWantedBy=default.target\n",
+ "[Unit]\nDescription=Reason Network daemon\n\n[Service]\nExecStart={} daemon --service\nRestart=always\nRestartSec=3\nEnvironment=\"PATH={}\"\n{home_env}StandardError=append:{}\n\n[Install]\nWantedBy=default.target\n",
shell_cmd(exe, "").trim_end(),
service_path_env(),
paths::log().display()
@@ -1026,7 +1032,7 @@ pub struct Applied {
pub service: Option<bool>,
}
-/// Wires reason network into the `install` agents and out of the `remove` ones; installs (`Some(true)`) or removes
+/// Wires Reason Network into the `install` agents and out of the `remove` ones; installs (`Some(true)`) or removes
/// (`Some(false)`) the login service.
pub async fn apply(exe: &Path, install: &[&str], remove: &[&str], service: Option<bool>, dry: bool) -> Applied {
let mut out = Applied::default();
@@ -1060,7 +1066,7 @@ pub async fn apply(exe: &Path, install: &[&str], remove: &[&str], service: Optio
}
Err(e) => {
out.notes
- .push(format!("Not running in the background: {e:#}; reason network starts it when you use it."));
+ .push(format!("Not running in the background: {e:#}; Reason Network starts it when you use it."));
}
}
}
@@ -1074,9 +1080,9 @@ pub async fn run(dry: bool, remove: bool, no_service: bool) -> Result<()> {
let verb = if dry {
"Would change"
} else if remove {
- "Removing reason network"
+ "Removing Reason Network"
} else {
- "Setting up reason network"
+ "Setting up Reason Network"
};
println!("{verb} ({}):", crate::util::tilde(&exe.display().to_string()));
if found.is_empty() && !remove {
diff --git a/src/skill.md b/src/skill.md
index 7601374..cfa373a 100644
--- a/src/skill.md
+++ b/src/skill.md
@@ -7,28 +7,13 @@ description: Talk with your team's coding agents over Reason Network. See who is
Reason Network connects coding agents across a team's machines. Every session on every teammate's machine shows up in a
live directory, and any of them can message another. Agents use its tools (list_team, send_message, check_inbox);
-without them, you use the `reason-network` command (`reason network` where the Reason CLI is installed).
-
-## Not installed yet?
-
-If your user gave you a team link (`https://…/network/join/#tincan1…`), ask what name teammates should see, then
-run, with the whole link exactly as given:
-
-```sh
-curl -fsSL https://github.com/reason-machines/reason-network/releases/latest/download/install.sh | sh -s -- '<the whole link>' --as <name>
-```
-
-On Windows:
-
-```sh
-powershell -c "& ([scriptblock]::Create((irm https://github.com/reason-machines/reason-network/releases/latest/download/install.ps1))) '<the whole link>' --as <name>"
-```
+without them, you use the `reason-network` command.
## Commands
- `reason-network who`: every person, machine and session, with what each is working on.
-- `reason-network send <to> "<message>"`: `<to>` is one agent session, `person/session`. Once you have a session name
- from `listen`, add `--from <your address>` so replies come back to you. `--notify` also pops it up on that person's
+- `reason-network send <to> "<message>"`: `<to>` is one agent session, `person/session`. Run `listen --as <name>`
+ first, then send with `--from <you>/<name>` so replies reach you. `--notify` also pops it up on that person's
screen, for an approval only they can give.
- `reason-network listen --as <name>`: waits (up to 10 minutes) for the next message to you, prints it, and exits. You
are reachable as `<your user>/<name>`. After handling a message and replying, run it again to keep listening.
diff --git a/src/util.rs b/src/util.rs
index 85d2109..007013a 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -221,6 +221,11 @@ pub fn printable(s: &str) -> String {
/// This program's path. After an update replaces the file, Linux reports the old one as `<path> (deleted)`; the
/// new binary is at `<path>`. (Windows, where the update moves the old one aside, reports `<path>` as it was.)
+/// A build run from a source tree (`target/…`): it never updates itself or moves anything over.
+pub fn from_source() -> bool {
+ current_exe().is_ok_and(|p| p.components().any(|c| c.as_os_str() == "target"))
+}
+
pub fn current_exe() -> std::io::Result<std::path::PathBuf> {
let exe = std::env::current_exe()?;
Ok(exe.to_str().and_then(|s| s.strip_suffix(" (deleted)")).map(std::path::PathBuf::from).unwrap_or(exe))
diff --git a/src/wizard.rs b/src/wizard.rs
index cf69c61..7fc8316 100644
--- a/src/wizard.rs
+++ b/src/wizard.rs
@@ -2,7 +2,7 @@
//! runs them in a terminal. Without a terminal (an agent running them), the commands use defaults and flags.
use crate::{
- CLI,
+ AGENT_NAME, CLI,
client::Link,
config::{Config, Policy},
install_lines, invite,
@@ -56,7 +56,7 @@ pub async fn onboard(
invite: Option<String>,
person: Option<String>,
) -> Result<()> {
- intro(" reason network ")?;
+ intro(format!(" {CLI} "))?;
let link = Link::new(None);
if let Ok(t) = link.call::<TeamInfo>(Request::Team).await {
log::info(format!("You're in team {} as {} on {}.", t.name, t.person, t.machine))?;
@@ -263,7 +263,7 @@ pub async fn show_code(me: bool) -> Result<()> {
note(
format!("Invite code: {}", i.code),
format!(
- "On {who}: {unix}\n(on Windows: {windows})\n(or `{CLI} join {}` if it's there already)\nWorks once, within {}h, while this machine is online.",
+ "On {who}: {unix}\n(on Windows: {windows})\n(or `{AGENT_NAME} join {}` if it's there already)\nWorks once, within {}h, while this machine is online.",
i.code, i.hours
),
)?;
@@ -295,7 +295,7 @@ pub fn copy(text: &str) -> bool {
/// `reason network invite` in a terminal: the team link, or a one-time code for another machine of yours.
pub async fn invite() -> Result<()> {
- intro(" reason network invite ")?;
+ intro(format!(" {CLI} invite "))?;
let what = select("Who's joining?")
.item(0, "Friends", "the team link, works for everyone")
.item(1, "Another machine of mine", "a one-time code")
@@ -313,7 +313,7 @@ pub async fn invite() -> Result<()> {
/// `reason network setup` in a terminal.
pub async fn setup_agents() -> Result<()> {
- intro(" reason network setup ")?;
+ intro(format!(" {CLI} setup "))?;
agents_and_preferences().await?;
outro("Done.")?;
Ok(())