Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

merge: sync main and preserve GitHub credential isolation

Dashbac34b43d03a
diff --cc apps/desktop/src/main/git-context/ghCliTokenSource.ts
index c41e734103,c959f895c5..1d291a9ab5
--- a/apps/desktop/src/main/git-context/ghCliTokenSource.ts
+++ b/apps/desktop/src/main/git-context/ghCliTokenSource.ts
@@@ -109,27 -104,24 +109,28 @@@ export function createGhCliTokenSource(
}
async function fetchToken(): Promise<GhCliTokenReadResult> {
- const bin = resolveGhBinary();
+ const bin = deps.resolveBinary ? await deps.resolveBinary() : resolveGhBinary();
return new Promise<GhCliTokenReadResult>((resolve) => {
try {
- // All consumers target public GitHub. Do not pick an enterprise token
- // when GH_HOST or the CLI's default host points elsewhere.
- execFileFn(bin, ['auth', 'token', '--hostname', 'github.com'], { timeout: GH_TIMEOUT_MS }, (err, stdout) => {
- if (err) {
- // 失败只 debug 级记录;原因分类留给 UI 决定引导动作。
- const reason = classifyExecError(err);
- log.debug('gh auth token unavailable', { bin, reason, err: String(err) });
- resolve({ ok: false, reason });
- return;
- }
- const token = stdout.trim();
- resolve(
- token.length > 0 ? { ok: true, token } : { ok: false, reason: 'gh-not-logged-in' },
- );
- });
++ // All consumers target public GitHub, regardless of GH_HOST or CLI defaults.
+ execFileFn(
+ bin,
+ ['auth', 'token', '--hostname', 'github.com'],
+ { timeout: GH_TIMEOUT_MS, env: ghAccountEnv() },
+ (err, stdout) => {
+ if (err) {
+ // 失败只 debug 级记录;原因分类留给 UI 决定引导动作。
+ const reason = classifyExecError(err);
+ log.debug('gh auth token unavailable', { reason });
+ resolve({ ok: false, reason });
+ return;
+ }
+ const token = stdout.trim();
+ resolve(
+ token.length > 0 ? { ok: true, token } : { ok: false, reason: 'gh-not-logged-in' },
+ );
+ },
+ );
} catch (err) {
log.debug('gh spawn threw', { err: String(err) });
resolve({ ok: false, reason: 'gh-missing' });