@geteigen/cli 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -131,6 +131,41 @@ async function persistGithubAuth(cwd, token) {
131
131
  await useStoredGithubCreds(cwd);
132
132
  await forgetRemoteToken(cwd);
133
133
  }
134
+ /** Commit as the GitHub user who owns the token — never “Eigen Agent”. */
135
+ async function githubIdentityFromToken(token) {
136
+ if (!token?.trim())
137
+ return null;
138
+ try {
139
+ const res = await fetch("https://api.github.com/user", {
140
+ headers: {
141
+ Authorization: `Bearer ${token.trim()}`,
142
+ Accept: "application/vnd.github+json",
143
+ "User-Agent": "eigen-cli",
144
+ },
145
+ });
146
+ if (!res.ok)
147
+ return null;
148
+ const user = (await res.json());
149
+ const login = String(user.login || "").trim();
150
+ if (!login)
151
+ return null;
152
+ const email = typeof user.email === "string" && user.email.includes("@")
153
+ ? user.email.trim()
154
+ : `${user.id ? `${user.id}+` : ""}${login}@users.noreply.github.com`;
155
+ return { name: String(user.name || "").trim() || login, email };
156
+ }
157
+ catch {
158
+ return null;
159
+ }
160
+ }
161
+ async function applyGithubCommitIdentity(cwd, token) {
162
+ const id = await githubIdentityFromToken(token);
163
+ if (!id || !existsSync(join(cwd, ".git")))
164
+ return id;
165
+ await git(cwd, ["config", "user.name", id.name]);
166
+ await git(cwd, ["config", "user.email", id.email]);
167
+ return id;
168
+ }
134
169
  /** Strip credentials so errors never echo a token. */
135
170
  function scrub(message, token) {
136
171
  let out = message.replace(/x-access-token:[^@\s]+@/g, "x-access-token:***@");
@@ -170,9 +205,8 @@ export async function prepareRepo(roots, input) {
170
205
  await git(dirname(target), ["clone", remote, target], 600_000);
171
206
  await git(target, ["checkout", ref]);
172
207
  }
173
- await git(target, ["config", "user.name", "Eigen Agent"]);
174
- await git(target, ["config", "user.email", "agent@users.noreply.github.com"]);
175
208
  }
209
+ await applyGithubCommitIdentity(target, input.token);
176
210
  if (input.branch) {
177
211
  await git(target, ["checkout", "-B", input.branch, `origin/${ref}`]).catch(() => git(target, ["checkout", "-B", input.branch]));
178
212
  }
@@ -194,16 +228,20 @@ export async function finalizeGit(roots, input) {
194
228
  const status = await git(cwd, ["status", "--porcelain"]);
195
229
  let committed = false;
196
230
  if (status.stdout.trim()) {
197
- await git(cwd, [
198
- "-c",
199
- "user.name=Eigen Agent",
200
- "-c",
201
- "user.email=agent@users.noreply.github.com",
202
- "commit",
203
- "-q",
204
- "-m",
205
- input.message || "Changes from Eigen agent",
206
- ]);
231
+ const author = await applyGithubCommitIdentity(cwd, input.token);
232
+ const commitArgs = author
233
+ ? [
234
+ "-c",
235
+ `user.name=${author.name}`,
236
+ "-c",
237
+ `user.email=${author.email}`,
238
+ "commit",
239
+ "-q",
240
+ "-m",
241
+ input.message || "Changes from Eigen agent",
242
+ ]
243
+ : ["commit", "-q", "-m", input.message || "Changes from Eigen agent"];
244
+ await git(cwd, commitArgs);
207
245
  committed = true;
208
246
  }
209
247
  if (input.token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geteigen/cli",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "CLI worker for Eigen — run local Cursor/ Claude Code/Codex AI agents for multiplayer sessions",
5
5
  "type": "module",
6
6
  "bin": {