Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <email>` 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 <noreply@anthropic.com>"}` | Agent clients (by name) credited as co-authors after Pointman |
| `harness_coauthors` | `{claude = "Claude <noreply@anthropic.com>"}` | 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
Expand All @@ -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 <email>` 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 <email>`. 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 <email>`. 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
Expand Down
4 changes: 2 additions & 2 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (`<its name>[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 (`<its name>[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.

Expand Down
12 changes: 6 additions & 6 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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",
Expand Down Expand Up @@ -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 <noreply@anthropic.com>" }
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"
52 changes: 26 additions & 26 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,22 +388,22 @@ fn write_script(dir: &Path, name: &str, text: &str) -> anyhow::Result<PathBuf> {
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,
state: &Path,
gh: Option<&Path>,
coauthors: &serde_json::Value,
default_author: &str,
client_coauthors: &serde_json::Value,
harness_coauthors: &serde_json::Value,
) -> anyhow::Result<PathBuf> {
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())?;
Expand Down Expand Up @@ -535,14 +535,14 @@ fn coauthor(state: &Path, person: &str) -> Option<String> {
}
}

/// `Name <email>` 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<String> {
let client = client.trim();
let text = std::fs::read_to_string(shim_dir(state).join("client-coauthors.json")).ok()?;
/// `Name <email>` 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<String> {
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.
Expand Down Expand Up @@ -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 <noreply@pointman.ai>";

/// 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<String> {
pub fn git_args(state: &Path, person: &str, harness: Option<&str>, bot: &str, args: &[String]) -> Vec<String> {
let mut out = args.to_vec();
if let (Some(at), Some(_), false) = (commit_at(args), coauthor(state, person), bot.is_empty()) {
let trailers: Vec<String> =
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}")) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 <noreply@anthropic.com>", "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 <noreply@anthropic.com>", "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 <noreply@anthropic.com>"));
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 <noreply@pointman.ai>";
let theirs = "Co-authored-by: Claude <noreply@anthropic.com>";
let got = git_args(dir.path(), "james", claude.as_deref(), "bot <b@x>", &args("commit -m hi"));
Expand All @@ -1116,8 +1116,8 @@ mod tests {
git_args(dir.path(), "scene", claude.as_deref(), "bot <b@x>", &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<String> {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
12 changes: 6 additions & 6 deletions tests/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down Expand Up @@ -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 <j@example.com>", "sam": "Sam <s@example.com>"},
"client_coauthors": {"claude": "Claude <noreply@anthropic.com>"}}))
"harness_coauthors": {"claude": "Claude <noreply@anthropic.com>"}}))
.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>| {
Expand All @@ -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);
Expand All @@ -162,7 +162,7 @@ fn configured_author_survives_automatic_wakes_but_never_replaces_another_person(
assert!(output.contains("author:James <j@example.com>"), "{output}");
assert!(output.contains("committer:pointman-app[bot]"), "{output}");
assert!(output.contains("arg:Co-authored-by: Pointman <noreply@pointman.ai>"), "{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 <noreply@anthropic.com>"), "{output}");
}
assert!(run("sam", None).contains("author:Sam <s@example.com>"));
Expand All @@ -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");
Expand Down
Loading