diff --git a/Cargo.lock b/Cargo.lock index da25183..6142bea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -302,7 +302,7 @@ dependencies = [ [[package]] name = "github" -version = "0.14.0" +version = "0.15.0" dependencies = [ "anyhow", "pointman-extension", @@ -539,8 +539,8 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pointman-extension" -version = "0.5.0" -source = "git+https://github.com/pointman-ai/pointman-extension?tag=v0.5.0#91829c5b75f0336ad6f40ad43427204649a58787" +version = "0.7.0" +source = "git+https://github.com/pointman-ai/pointman-extension?rev=4d11f5027f2dab7aee81eb43524bbca85f9df1ba#4d11f5027f2dab7aee81eb43524bbca85f9df1ba" dependencies = [ "anyhow", "buffa", diff --git a/Cargo.toml b/Cargo.toml index 78cf04d..26b7092 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "github" -version = "0.14.0" +version = "0.15.0" edition = "2021" description = "GitHub on Pointman's nodes: gh on each machine, and agents' runs acting on GitHub as Pointman App." license = "MIT" @@ -9,7 +9,7 @@ publish = false [dependencies] anyhow = "1" -pointman-extension = { git = "https://github.com/pointman-ai/pointman-extension", tag = "v0.5.0" } +pointman-extension = { git = "https://github.com/pointman-ai/pointman-extension", rev = "4d11f5027f2dab7aee81eb43524bbca85f9df1ba" } serde_json = "1" sha2 = "0.10" tempfile = "3" diff --git a/README.md b/README.md index 5d55765..c45617a 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Pointman itself. | `cli` | empty | GitHub's CLI, when it isn't on the node's PATH or in /opt/homebrew/bin or /usr/local/bin; empty, the extension installs its own | | `coauthors` | `{}` | Pointman handles mapped to `Name ` commit authors | | `default_author` | empty | Who is credited in runs no person started: a handle from `coauthors`, `app` for no one, or empty for this machine's own GitHub account | -| `client_coauthors` | `{claude = "Claude "}` | Agent clients (by name) credited as co-authors after Pointman | +| `harness_coauthors` | `{claude = "Claude "}` | Agent harnesses (by name) credited as co-authors after Pointman | In runs no person started (agent handoffs, CI reports, timer wakes), an agent's commit names an author from `default_author`: a handle from `coauthors`, `app` for App-only, or, left empty, this machine's own GitHub @@ -63,8 +63,8 @@ A person directly starting a run is credited only with an entry in `coauthors`; stays App-only, never someone else, the machine's own account included. An unreadable run-person file, an unreadable or malformed `coauthors`, or an entry that isn't one `Name ` also stays App-only. -The run's client is a further co-author on those commits: the node names it in the run's `MB_RUN_CLIENT` -(`claude`, `codex`…), and `client_coauthors` gives its `Name `. A client that isn't listed gets no +The run's harness is a further co-author on those commits: the node names it in the run's `MB_RUN_HARNESS` +(`claude`, `codex`…), and `harness_coauthors` gives its `Name `. A harness that isn't listed gets no line. Agents never write these lines themselves. A pull request has one creator: the account whose token opens it. PRs opened with the App still show diff --git a/SKILL.md b/SKILL.md index 7c974b9..52ed3e2 100644 --- a/SKILL.md +++ b/SKILL.md @@ -5,13 +5,13 @@ description: Writing on GitHub (pull requests, issues, comments, reviews, commit # Writing on GitHub as Pointman App -Your commits are credited to a person, with Pointman and your client (Claude, for example) as co-authors: +Your commits are credited to a person, with Pointman and your harness (Claude, for example) as co-authors: the person whose post started the run, when the extension's `coauthors` names them; in runs no person started (agent handoffs, timer wakes), the machine's person (its own GitHub account, or a configured `default_author`). Anyone else's commits stay the App's. PRs themselves still have the App as their single creator. -In your runs, `gh` and git act on GitHub as **Pointman App**: PRs, issues, comments, reviews, pushes and commits all show as the App's bot (`[bot]`). The exception is a commit someone is credited on (above): it is authored as that person, with the App as committer and `Co-authored-by` lines for Pointman and your client, added by the `git` the extension gives you. Don't write those lines or set the author yourself. The extension gives each command a short-lived token for the repo's owner, so you never sign in, set a token, or change git's name and email. +In your runs, `gh` and git act on GitHub as **Pointman App**: PRs, issues, comments, reviews, pushes and commits all show as the App's bot (`[bot]`). The exception is a commit someone is credited on (above): it is authored as that person, with the App as committer and `Co-authored-by` lines for Pointman and your harness, added by the `git` the extension gives you. Don't write those lines or set the author yourself. The extension gives each command a short-lived token for the repo's owner, so you never sign in, set a token, or change git's name and email. Where the App can't act (it isn't installed on the repo's account, or GitHub refuses it), `gh` and git use this machine's own `gh` login instead, and say so in a line starting `github:`. What you do then shows on GitHub as that login's person, not the bot. diff --git a/extension.toml b/extension.toml index b365651..9dcb5ea 100644 --- a/extension.toml +++ b/extension.toml @@ -5,10 +5,10 @@ [extension] id = "github" name = "GitHub" -version = "0.14.0" +version = "0.15.0" publisher = "aurelio" summary = "GitHub's CLI on this machine, and agents' runs acting on GitHub as Pointman App, else as the machine's gh login." -node = ">=0.4.4" +node = ">=0.6,<1" platforms = ["macos-arm64", "macos-x86_64", "linux-x86_64", "linux-arm64"] [run] @@ -29,7 +29,7 @@ skill = "SKILL.md" # https, and commits are the App's bot's. Where the App can't act, both use the machine's own `gh` login (EXT-116; # James, Pointman thread 25602 [29623]), and say so. [sessions] -clients = ["claude", "codex", "opencode"] +harnesses = ["claude", "codex", "opencode"] path = ["app/bin"] # the runs' `gh` shim, put first on PATH by the node env = [ "GIT_TERMINAL_PROMPT", @@ -61,10 +61,10 @@ type = "string" default = "" description = "Who is credited on commits in runs no person started (an agent's mention, a timer, a workflow): a Pointman handle from coauthors (for example james), app for no one (App-only), or empty for this machine's own GitHub account (its gh login). A person who directly starts a run takes precedence. PRs are still opened by the App." -[settings.properties.client_coauthors] +[settings.properties.harness_coauthors] type = "object" default = { claude = "Claude " } -description = "The agent's client credited as a co-author after Pointman, by the client's name (claude, codex, gemini…), on the commits a person is credited on. A client not in it gets no line." +description = "The agent's harness credited as a co-author after Pointman, by the harness's name (claude, codex, gemini…), on the commits a person is credited on. A harness not in it gets no line." -[settings.properties.client_coauthors.additionalProperties] +[settings.properties.harness_coauthors.additionalProperties] type = "string" diff --git a/src/app.rs b/src/app.rs index cd017f3..a0ffbcf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -388,7 +388,7 @@ fn write_script(dir: &Path, name: &str, text: &str) -> anyhow::Result { Ok(path) } -/// Writes the runs' `gh` and `git` (see `shim` and `git_shim`), the people and clients who are credited on their +/// Writes the runs' `gh` and `git` (see `shim` and `git_shim`), the people and harnesses who are credited on their /// commits, and where GitHub's CLI is. pub fn write_shim( exe: &Path, @@ -396,14 +396,14 @@ pub fn write_shim( gh: Option<&Path>, coauthors: &serde_json::Value, default_author: &str, - client_coauthors: &serde_json::Value, + harness_coauthors: &serde_json::Value, ) -> anyhow::Result { let dir = shim_dir(state); std::fs::create_dir_all(&dir)?; write_script(&dir, "git", &git_shim(exe, state))?; write_script(&dir, "coauthors.json", &coauthors.to_string())?; write_script(&dir, "default-author", default_author)?; - write_script(&dir, "client-coauthors.json", &client_coauthors.to_string())?; + write_script(&dir, "harness-coauthors.json", &harness_coauthors.to_string())?; match gh { Some(gh) => { write_script(&state.join("app"), "cli", &gh.display().to_string())?; @@ -535,14 +535,14 @@ fn coauthor(state: &Path, person: &str) -> Option { } } -/// `Name ` for the client a run uses (`MB_RUN_CLIENT`: claude, codex…), as the `client_coauthors` setting -/// names it; none for a client it doesn't name. -pub fn client_coauthor(state: &Path, client: &str) -> Option { - let client = client.trim(); - let text = std::fs::read_to_string(shim_dir(state).join("client-coauthors.json")).ok()?; +/// `Name ` for the harness a run uses (`MB_RUN_HARNESS`: claude, codex…), as the `harness_coauthors` setting +/// names it; none for a harness it doesn't name. +pub fn harness_coauthor(state: &Path, harness: &str) -> Option { + let harness = harness.trim(); + let text = std::fs::read_to_string(shim_dir(state).join("harness-coauthors.json")).ok()?; let v: serde_json::Value = serde_json::from_str(&text).ok()?; - let who = v.get(client)?.as_str()?.trim(); - (!client.is_empty() && split_identity(who).is_some() && !who.contains('\n')).then(|| who.to_string()) + let who = v.get(harness)?.as_str()?.trim(); + (!harness.is_empty() && split_identity(who).is_some() && !who.contains('\n')).then(|| who.to_string()) } /// Where git's subcommand is in its arguments, past the options that come before it. @@ -575,14 +575,14 @@ pub fn talks_to_github(args: &[String]) -> bool { /// (the App's bot email shows as `pointman-app[bot]`), so this email is one no account has, and GitHub shows the name. pub const COAUTHOR: &str = "Pointman "; -/// git's arguments with Pointman credited as co-author (`COAUTHOR`), and after it the run's client (`client`, from -/// `client_coauthor`), when this is a `commit` someone is credited on (`coauthor`: they become the author, see +/// git's arguments with Pointman credited as co-author (`COAUTHOR`), and after it the run's harness (`harness`, from +/// `harness_coauthor`), when this is a `commit` someone is credited on (`coauthor`: they become the author, see /// `git_command`) and the App commits (`bot`); else the arguments as they are. -pub fn git_args(state: &Path, person: &str, client: Option<&str>, bot: &str, args: &[String]) -> Vec { +pub fn git_args(state: &Path, person: &str, harness: Option<&str>, bot: &str, args: &[String]) -> Vec { let mut out = args.to_vec(); if let (Some(at), Some(_), false) = (commit_at(args), coauthor(state, person), bot.is_empty()) { let trailers: Vec = - std::iter::once(COAUTHOR).chain(client).map(|who| format!("Co-authored-by: {who}")).collect(); + std::iter::once(COAUTHOR).chain(harness).map(|who| format!("Co-authored-by: {who}")).collect(); let mut place = at + 1; for trailer in trailers { if !args[at..].iter().any(|a| a == &format!("--trailer={trailer}")) { @@ -631,11 +631,11 @@ pub fn git_command(state: &Path, args: &[String], login: Login) -> anyhow::Resul (Ok(n), Ok(e)) if !n.is_empty() && !e.is_empty() => format!("{n} <{e}>"), _ => String::new(), }; - // the run's client as a co-author too, when the node says which it is (MB_RUN_CLIENT) and it's named - let client = std::env::var("MB_RUN_CLIENT").ok().and_then(|c| client_coauthor(state, &c)); + // the run's harness as a co-author too, when the node says which it is (MB_RUN_HARNESS) and it's named + let harness = std::env::var("MB_RUN_HARNESS").ok().and_then(|c| harness_coauthor(state, &c)); let args = person .as_deref() - .map(|person| git_args(state, person, client.as_deref(), &bot, args)) + .map(|person| git_args(state, person, harness.as_deref(), &bot, args)) .unwrap_or_else(|| args.to_vec()); let exe = std::env::current_exe().context("where this extension's binary is")?; let mut cmd = Command::new(git); @@ -1094,16 +1094,16 @@ mod tests { } #[test] - fn the_runs_client_is_a_co_author_after_pointman() { + fn the_runs_harness_is_a_co_author_after_pointman() { let who = "James <1+j@users.noreply.github.com>"; let dir = state_with(json!({"james": who})); - let clients = json!({"claude": "Claude ", "bad": "no email"}); - std::fs::write(shim_dir(dir.path()).join("client-coauthors.json"), clients.to_string()).unwrap(); - let claude = client_coauthor(dir.path(), "claude"); + let harnesses = json!({"claude": "Claude ", "bad": "no email"}); + std::fs::write(shim_dir(dir.path()).join("harness-coauthors.json"), harnesses.to_string()).unwrap(); + let claude = harness_coauthor(dir.path(), "claude"); assert_eq!(claude.as_deref(), Some("Claude ")); - assert_eq!(client_coauthor(dir.path(), "codex"), None); - assert_eq!(client_coauthor(dir.path(), "bad"), None); - assert_eq!(client_coauthor(dir.path(), ""), None); + assert_eq!(harness_coauthor(dir.path(), "codex"), None); + assert_eq!(harness_coauthor(dir.path(), "bad"), None); + assert_eq!(harness_coauthor(dir.path(), ""), None); let ours = "Co-authored-by: Pointman "; let theirs = "Co-authored-by: Claude "; let got = git_args(dir.path(), "james", claude.as_deref(), "bot ", &args("commit -m hi")); @@ -1116,8 +1116,8 @@ mod tests { git_args(dir.path(), "scene", claude.as_deref(), "bot ", &args("commit -m x")), args("commit -m x") ); - // and no client file at all: the client is no one - assert_eq!(client_coauthor(tempfile::tempdir().unwrap().path(), "claude"), None); + // and no harness file at all: the harness is no one + assert_eq!(harness_coauthor(tempfile::tempdir().unwrap().path(), "claude"), None); } fn args(s: &str) -> Vec { diff --git a/src/main.rs b/src/main.rs index e6f8d3b..5bd09e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,7 +102,7 @@ fn write_shim(h: &Handle) -> anyhow::Result<()> { cli(h).as_deref(), &h.settings()["coauthors"], h.settings()["default_author"].as_str().unwrap_or_default(), - &h.settings()["client_coauthors"], + &h.settings()["harness_coauthors"], ) .context("couldn't write the runs' gh")?; Ok(()) diff --git a/tests/github.rs b/tests/github.rs index c49d200..0574de7 100644 --- a/tests/github.rs +++ b/tests/github.rs @@ -66,7 +66,7 @@ fn before_the_board_has_the_app_runs_use_the_machines_own_login() { let state = node.state_dir_path().to_path_buf(); settled(&state); - let got = node.call("session.prepare", json!({"client": "claude", "handle": {"handle": "scene"}})).unwrap(); + let got = node.call("session.prepare", json!({"harness": "claude", "handle": {"handle": "scene"}})).unwrap(); let env = &got["env"]; assert!(env.get("GH_TOKEN").is_none(), "{got}"); assert!(env.get("GIT_AUTHOR_NAME").is_none(), "{got}"); @@ -129,13 +129,13 @@ fn configured_author_survives_automatic_wakes_but_never_replaces_another_person( .binary(env!("CARGO_BIN_EXE_github")) .settings(json!({"cli": fake_gh().to_string_lossy(), "default_author": "james", "coauthors": {"james": "James ", "sam": "Sam "}, - "client_coauthors": {"claude": "Claude "}})) + "harness_coauthors": {"claude": "Claude "}})) .method("core.call", board) .start() .unwrap(); let state = node.state_dir_path().to_path_buf(); settled(&state); - let got = node.call("session.prepare", json!({"client": "claude", "handle": {"handle": "scene"}})).unwrap(); + let got = node.call("session.prepare", json!({"harness": "claude", "handle": {"handle": "scene"}})).unwrap(); let shims = state.join("app/bin"); let person_file = dir.path().join("person"); let run = |person: &str, file: Option<&std::path::Path>| { @@ -146,7 +146,7 @@ fn configured_author_survives_automatic_wakes_but_never_replaces_another_person( command .env("PATH", std::env::join_paths([shims.as_path(), dir.path(), std::path::Path::new("/bin")]).unwrap()) .env("MB_RUN_PERSON", person) - .env("MB_RUN_CLIENT", "claude") + .env("MB_RUN_HARNESS", "claude") .env_remove("MB_RUN_PERSON_FILE"); if let Some(file) = file { command.env("MB_RUN_PERSON_FILE", file); @@ -162,7 +162,7 @@ fn configured_author_survives_automatic_wakes_but_never_replaces_another_person( assert!(output.contains("author:James "), "{output}"); assert!(output.contains("committer:pointman-app[bot]"), "{output}"); assert!(output.contains("arg:Co-authored-by: Pointman "), "{output}"); - // the run's client after Pointman (EXT-148) + // the run's harness after Pointman (EXT-148) assert!(output.contains("arg:Co-authored-by: Claude "), "{output}"); } assert!(run("sam", None).contains("author:Sam ")); @@ -188,7 +188,7 @@ fn runs_act_as_pointman_app_once_the_board_has_it() { let state = node.state_dir_path().to_path_buf(); settled(&state); - let got = node.call("session.prepare", json!({"client": "claude", "handle": {"handle": "scene"}})).unwrap(); + let got = node.call("session.prepare", json!({"harness": "claude", "handle": {"handle": "scene"}})).unwrap(); let env = &got["env"]; assert!(env.get("GH_TOKEN").is_none(), "{got}"); let shims = state.join("app/bin");