@opengsd/gsd-pi 1.0.2-dev.235ebf3 → 1.0.2-dev.29398d2
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.
- package/README.md +63 -12
- package/dist/onboarding.js +22 -3
- package/dist/resource-loader.d.ts +7 -0
- package/dist/resource-loader.js +42 -9
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/context7/index.js +12 -2
- package/dist/resources/extensions/google-cli/index.js +30 -0
- package/dist/resources/extensions/google-cli/models.js +55 -0
- package/dist/resources/extensions/google-cli/package.json +11 -0
- package/dist/resources/extensions/google-cli/readiness.js +12 -0
- package/dist/resources/extensions/google-cli/stream-adapter.js +191 -0
- package/dist/resources/extensions/gsd/auto/loop.js +19 -0
- package/dist/resources/extensions/gsd/auto/phases.js +1 -1
- package/dist/resources/extensions/gsd/auto/session.js +3 -0
- package/dist/resources/extensions/gsd/auto-start.js +232 -49
- package/dist/resources/extensions/gsd/auto-worktree.js +2 -54
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +4 -3
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +17 -15
- package/dist/resources/extensions/gsd/closeout-recovery.js +7 -1
- package/dist/resources/extensions/gsd/commands/handlers/auto.js +9 -1
- package/dist/resources/extensions/gsd/commands-handlers.js +3 -0
- package/dist/resources/extensions/gsd/doctor-providers.js +54 -24
- package/dist/resources/extensions/gsd/git-conflict-state.js +26 -1
- package/dist/resources/extensions/gsd/key-manager.js +45 -13
- package/dist/resources/extensions/gsd/tools/complete-task.js +9 -0
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +40 -1
- package/dist/resources/extensions/gsd/worktree-lifecycle.js +24 -3
- package/dist/resources/extensions/gsd/worktree-post-create-hook.js +117 -0
- package/dist/resources/extensions/search-the-web/native-search.js +57 -8
- package/dist/resources/shared/package-manager-detection.js +36 -0
- package/dist/update-check.d.ts +6 -2
- package/dist/update-check.js +7 -3
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +5 -5
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +5 -5
- package/dist/web/standalone/.next/server/chunks/1834.js +2 -2
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +1 -1
- package/dist/web/standalone/package.json +0 -1
- package/dist/worktree-cli.d.ts +0 -2
- package/dist/worktree-cli.js +21 -9
- package/package.json +5 -2
- package/packages/cloud-mcp-gateway/bin/gsd-cloud-mcp-gateway.js +14 -0
- package/packages/cloud-mcp-gateway/package.json +4 -3
- package/packages/contracts/package.json +1 -1
- package/packages/daemon/package.json +4 -4
- package/packages/gsd-agent-core/package.json +5 -5
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.js +2 -2
- package/packages/gsd-agent-modes/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/oauth-selector.d.ts +6 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/oauth-selector.js +9 -6
- package/packages/gsd-agent-modes/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js +3 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.js +0 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-class-constants.d.ts +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-class-constants.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-class-constants.js +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode-class-constants.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js +2 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.d.ts +3 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.js +144 -2
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-auth.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-session.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-session.js +2 -14
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-session.js.map +1 -1
- package/packages/gsd-agent-modes/package.json +7 -7
- package/packages/mcp-server/bin/gsd-mcp-server.js +14 -0
- package/packages/mcp-server/dist/workflow-tools.js +1 -1
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +5 -4
- package/packages/native/package.json +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +13 -13
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-ai/bin/pi-ai.js +14 -0
- package/packages/pi-ai/dist/models.generated.d.ts +40 -17
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.js +49 -30
- package/packages/pi-ai/dist/models.generated.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +50 -0
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +2 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/package.json +3 -2
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts +2 -2
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/read.js +5 -3
- package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -1
- package/packages/pi-coding-agent/package.json +8 -8
- package/packages/pi-tui/package.json +1 -1
- package/packages/rpc-client/package.json +2 -2
- package/pkg/package.json +1 -1
- package/scripts/install/deps.js +10 -0
- package/scripts/install/detect-existing.js +17 -3
- package/scripts/install/npm-global.js +103 -33
- package/scripts/install.js +1 -0
- package/src/resources/extensions/context7/index.ts +15 -2
- package/src/resources/extensions/google-cli/index.ts +34 -0
- package/src/resources/extensions/google-cli/models.ts +57 -0
- package/src/resources/extensions/google-cli/package.json +11 -0
- package/src/resources/extensions/google-cli/readiness.ts +15 -0
- package/src/resources/extensions/google-cli/stream-adapter.ts +245 -0
- package/src/resources/extensions/gsd/auto/loop.ts +22 -0
- package/src/resources/extensions/gsd/auto/phases.ts +1 -1
- package/src/resources/extensions/gsd/auto/session.ts +3 -0
- package/src/resources/extensions/gsd/auto-start.ts +307 -56
- package/src/resources/extensions/gsd/auto-worktree.ts +2 -56
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +4 -3
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +22 -15
- package/src/resources/extensions/gsd/closeout-recovery.ts +6 -1
- package/src/resources/extensions/gsd/commands/handlers/auto.ts +9 -1
- package/src/resources/extensions/gsd/commands-handlers.ts +2 -0
- package/src/resources/extensions/gsd/doctor-providers.ts +55 -27
- package/src/resources/extensions/gsd/git-conflict-state.ts +25 -1
- package/src/resources/extensions/gsd/key-manager.ts +57 -14
- package/src/resources/extensions/gsd/tests/auto-start-orphan-bootstrap.test.ts +436 -0
- package/src/resources/extensions/gsd/tests/closeout-recovery.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/commands-context.test.ts +5 -3
- package/src/resources/extensions/gsd/tests/commands-dispatcher-workspace-git.test.ts +15 -2
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +105 -0
- package/src/resources/extensions/gsd/tests/key-manager.test.ts +23 -4
- package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +70 -10
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +13 -2
- package/src/resources/extensions/gsd/tests/tool-param-optionality.test.ts +24 -1
- package/src/resources/extensions/gsd/tests/workflow-mcp-auto-prep.test.ts +60 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/workspace-git-preflight.test.ts +16 -1
- package/src/resources/extensions/gsd/tests/worktree-lifecycle.test.ts +28 -0
- package/src/resources/extensions/gsd/tests/worktree-post-create-hook.test.ts +141 -1
- package/src/resources/extensions/gsd/tests/zombie-gsd-state.test.ts +45 -1
- package/src/resources/extensions/gsd/tools/complete-task.ts +9 -0
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +56 -4
- package/src/resources/extensions/gsd/worktree-lifecycle.ts +37 -2
- package/src/resources/extensions/gsd/worktree-post-create-hook.ts +127 -0
- package/src/resources/extensions/search-the-web/native-search.ts +60 -8
- package/src/resources/shared/package-manager-detection.ts +39 -0
- package/dist/tsconfig.extensions.tsbuildinfo +0 -1
- /package/dist/web/standalone/.next/static/{-P554bKh56nzavKUmvFM2 → bukT6Ux1YchPm2XqjaexX}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{-P554bKh56nzavKUmvFM2 → bukT6Ux1YchPm2XqjaexX}/_ssgManifest.js +0 -0
|
@@ -507,6 +507,21 @@ function initSessionNotifications(ctx: ExtensionContext): void {
|
|
|
507
507
|
initNotificationWidget(ctx);
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
+
async function prepareWorkflowMcpForHookContext(
|
|
511
|
+
ctx: ExtensionContext,
|
|
512
|
+
basePath: string,
|
|
513
|
+
): Promise<void> {
|
|
514
|
+
// Skip MCP auto-prep when running inside an auto-worktree. The worktree
|
|
515
|
+
// already has .mcp.json from createAutoWorktree, and re-running the writer
|
|
516
|
+
// post-chdir rewrites the file mid-run (non-idempotent due to cwd-relative
|
|
517
|
+
// CLI path resolution), dirtying the tree and breaking the milestone merge.
|
|
518
|
+
const { isInAutoWorktree } = await import("../auto-worktree.js");
|
|
519
|
+
if (isInAutoWorktree(basePath)) return;
|
|
520
|
+
|
|
521
|
+
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
522
|
+
prepareWorkflowMcpForProject(ctx, basePath);
|
|
523
|
+
}
|
|
524
|
+
|
|
510
525
|
export function registerHooks(
|
|
511
526
|
pi: ExtensionAPI,
|
|
512
527
|
ecosystemHandlers: GSDEcosystemBeforeAgentStartHandler[],
|
|
@@ -532,12 +547,7 @@ export function registerHooks(
|
|
|
532
547
|
await syncServiceTierStatus(ctx);
|
|
533
548
|
await applyDisabledModelProviderPolicy(ctx);
|
|
534
549
|
await applyCompactionThresholdOverride(ctx);
|
|
535
|
-
|
|
536
|
-
const { isInAutoWorktree } = await import("../auto-worktree.js");
|
|
537
|
-
if (!isInAutoWorktree(basePath)) {
|
|
538
|
-
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
539
|
-
prepareWorkflowMcpForProject(ctx, basePath);
|
|
540
|
-
}
|
|
550
|
+
await prepareWorkflowMcpForHookContext(ctx, basePath);
|
|
541
551
|
|
|
542
552
|
// Apply show_token_cost preference (#1515)
|
|
543
553
|
try {
|
|
@@ -563,15 +573,7 @@ export function registerHooks(
|
|
|
563
573
|
await syncServiceTierStatus(ctx);
|
|
564
574
|
await applyDisabledModelProviderPolicy(ctx);
|
|
565
575
|
await applyCompactionThresholdOverride(ctx);
|
|
566
|
-
|
|
567
|
-
// already has .mcp.json from createAutoWorktree, and re-running the writer
|
|
568
|
-
// post-chdir rewrites the file mid-run (non-idempotent due to cwd-relative
|
|
569
|
-
// CLI path resolution), dirtying the tree and breaking the milestone merge.
|
|
570
|
-
const { isInAutoWorktree } = await import("../auto-worktree.js");
|
|
571
|
-
if (!isInAutoWorktree(basePath)) {
|
|
572
|
-
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
573
|
-
prepareWorkflowMcpForProject(ctx, basePath);
|
|
574
|
-
}
|
|
576
|
+
await prepareWorkflowMcpForHookContext(ctx, basePath);
|
|
575
577
|
await loadToolApiKeysForSession();
|
|
576
578
|
if (!isAutoActive()) {
|
|
577
579
|
ctx.ui.setWidget("gsd-progress", undefined);
|
|
@@ -608,6 +610,11 @@ export function registerHooks(
|
|
|
608
610
|
}
|
|
609
611
|
clearDeferredApprovalGate(beforeAgentBasePath);
|
|
610
612
|
|
|
613
|
+
// session_start can fire before the active provider has settled. By
|
|
614
|
+
// before_agent_start, Claude Code CLI sessions should get the same
|
|
615
|
+
// project MCP config that /gsd mcp init would write.
|
|
616
|
+
await prepareWorkflowMcpForHookContext(ctx, beforeAgentBasePath);
|
|
617
|
+
|
|
611
618
|
// GSD's own context injection (existing behavior — unchanged).
|
|
612
619
|
const { buildBeforeAgentStartResult } = await import("./system-context.js");
|
|
613
620
|
const gsdResult = await buildBeforeAgentStartResult(event, ctx);
|
|
@@ -205,7 +205,12 @@ export function getCloseoutManualResolveBlocker(basePath: string): string | null
|
|
|
205
205
|
return `Unmerged paths remain in ${basePath}: ${conflictProbe.unmerged.slice(0, 5).join(", ")}`;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
let status: string;
|
|
209
|
+
try {
|
|
210
|
+
status = runGit(basePath, ["status", "--porcelain"]);
|
|
211
|
+
} catch {
|
|
212
|
+
return `Could not inspect git status in ${basePath}.`;
|
|
213
|
+
}
|
|
209
214
|
if (status) {
|
|
210
215
|
return `Working tree still has uncommitted changes in ${basePath}. Commit, stash, or run /gsd closeout retry first.`;
|
|
211
216
|
}
|
|
@@ -208,7 +208,15 @@ export async function handleAutoCommand(trimmed: string, ctx: ExtensionCommandCo
|
|
|
208
208
|
|
|
209
209
|
if (trimmed === "") {
|
|
210
210
|
if (!(await guardRemoteSession(ctx, pi))) return true;
|
|
211
|
-
|
|
211
|
+
const basePath = projectRoot();
|
|
212
|
+
const { hasGsdBootstrapArtifacts } = await import("../../detection.js");
|
|
213
|
+
const { gsdRoot } = await import("../../paths.js");
|
|
214
|
+
if (!hasGsdBootstrapArtifacts(gsdRoot(basePath))) {
|
|
215
|
+
const { showSmartEntry } = await import("../../guided-flow.js");
|
|
216
|
+
await showSmartEntry(ctx, pi, basePath, { step: true });
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (await hasUnresolvedCloseoutBlocker(ctx, basePath)) return true;
|
|
212
220
|
const { showGsdHome } = await import("../../gsd-command-home.js");
|
|
213
221
|
await showGsdHome(ctx, pi, projectRoot());
|
|
214
222
|
return true;
|
|
@@ -26,6 +26,7 @@ import { isAutoActive, checkRemoteAutoSession } from "./auto.js";
|
|
|
26
26
|
import { getAutoWorktreePath } from "./auto-worktree.js";
|
|
27
27
|
import { currentDirectoryRoot, projectRoot } from "./commands/context.js";
|
|
28
28
|
import { loadPrompt } from "./prompt-loader.js";
|
|
29
|
+
import { isPnpmInstall } from "../../shared/package-manager-detection.js";
|
|
29
30
|
import {
|
|
30
31
|
buildDoctorHealIssuePayload,
|
|
31
32
|
buildDoctorHealSummary,
|
|
@@ -57,6 +58,7 @@ function isBunInstall(argv1: string | undefined = process.argv[1]): boolean {
|
|
|
57
58
|
|
|
58
59
|
function resolveInstallCommand(pkg: string): string {
|
|
59
60
|
if (isBunInstall()) return `bun add -g ${pkg}`;
|
|
61
|
+
if (isPnpmInstall()) return `pnpm add -g ${pkg}`;
|
|
60
62
|
return `npm install -g ${pkg}`;
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -16,7 +16,7 @@ import { delimiter, join } from "node:path";
|
|
|
16
16
|
import { AuthStorage } from "@gsd/pi-coding-agent";
|
|
17
17
|
import { getEnvApiKey } from "@gsd/pi-ai";
|
|
18
18
|
import { loadEffectiveGSDPreferences } from "./preferences.js";
|
|
19
|
-
import { getAuthPath, PROVIDER_REGISTRY, type ProviderCategory } from "./key-manager.js";
|
|
19
|
+
import { getAuthPath, PROVIDER_REGISTRY, supportsBrowserOAuth, type ProviderCategory } from "./key-manager.js";
|
|
20
20
|
import { homedir } from "node:os";
|
|
21
21
|
|
|
22
22
|
// ── Types ──────────────────────────────────────────────────────────────────────
|
|
@@ -42,11 +42,10 @@ export interface ProviderCheckResult {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Providers that use external CLI authentication (not API keys).
|
|
45
|
-
*
|
|
45
|
+
* When explicitly selected, the provider's own CLI/session owns auth.
|
|
46
46
|
*/
|
|
47
47
|
const CLI_AUTH_PROVIDERS = new Set([
|
|
48
48
|
"claude-code",
|
|
49
|
-
"openai-codex",
|
|
50
49
|
"google-gemini-cli",
|
|
51
50
|
"google-antigravity",
|
|
52
51
|
]);
|
|
@@ -156,26 +155,30 @@ interface KeyLookup {
|
|
|
156
155
|
* Map of CLI provider IDs to their binary names on disk.
|
|
157
156
|
* Used for lightweight binary-presence checks (PATH scan, no subprocess).
|
|
158
157
|
*/
|
|
159
|
-
const CLI_BINARY_MAP: Record<string, string> = {
|
|
160
|
-
"claude-code": "claude",
|
|
161
|
-
"
|
|
162
|
-
"google-
|
|
163
|
-
"google-antigravity": "antigravity",
|
|
158
|
+
const CLI_BINARY_MAP: Record<string, string[]> = {
|
|
159
|
+
"claude-code": ["claude", "claude-code"],
|
|
160
|
+
"google-gemini-cli": ["gemini"],
|
|
161
|
+
"google-antigravity": ["agy"],
|
|
164
162
|
};
|
|
165
163
|
|
|
164
|
+
const CLI_AUTH_PATH_CHECK_PROVIDERS = new Set([
|
|
165
|
+
"google-gemini-cli",
|
|
166
|
+
"google-antigravity",
|
|
167
|
+
]);
|
|
168
|
+
|
|
166
169
|
/**
|
|
167
170
|
* Check if a CLI provider's binary exists anywhere in PATH.
|
|
168
171
|
* Fast filesystem scan — no subprocess, no network, sub-1ms.
|
|
169
172
|
*/
|
|
170
173
|
function isCliBinaryInPath(providerId: string): boolean {
|
|
171
|
-
const
|
|
172
|
-
if (!
|
|
174
|
+
const binaries = CLI_BINARY_MAP[providerId];
|
|
175
|
+
if (!binaries) return false;
|
|
173
176
|
|
|
174
177
|
const pathDirs = (process.env.PATH ?? "").split(delimiter).filter(Boolean);
|
|
175
178
|
|
|
176
179
|
// On Windows, command shims are commonly installed as .cmd/.exe/.bat/.com.
|
|
177
180
|
// Scan PATHEXT candidates in addition to the bare binary name.
|
|
178
|
-
const executableNames: string[] = [
|
|
181
|
+
const executableNames: string[] = [...binaries];
|
|
179
182
|
if (process.platform === "win32") {
|
|
180
183
|
const rawPathExt = process.env.PATHEXT
|
|
181
184
|
?.split(";")
|
|
@@ -185,9 +188,11 @@ function isCliBinaryInPath(providerId: string): boolean {
|
|
|
185
188
|
ext.startsWith(".") ? ext.toLowerCase() : `.${ext.toLowerCase()}`,
|
|
186
189
|
);
|
|
187
190
|
const defaultExt = [".exe", ".cmd", ".bat", ".com"];
|
|
188
|
-
for (const
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
+
for (const binary of binaries) {
|
|
192
|
+
for (const ext of [...normalizedPathExt, ...defaultExt]) {
|
|
193
|
+
const candidate = `${binary}${ext}`;
|
|
194
|
+
if (!executableNames.includes(candidate)) executableNames.push(candidate);
|
|
195
|
+
}
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
198
|
|
|
@@ -224,12 +229,6 @@ function hasModelsJsonApiKey(providerId: string): boolean {
|
|
|
224
229
|
function resolveKey(providerId: string): KeyLookup {
|
|
225
230
|
const info = PROVIDER_REGISTRY.find(p => p.id === providerId);
|
|
226
231
|
|
|
227
|
-
// claude-code never stores credentials in auth.json — GSD delegates entirely to
|
|
228
|
-
// the local CLI binary. Presence of the binary in PATH is the only signal.
|
|
229
|
-
if (providerId === "claude-code") {
|
|
230
|
-
return { found: isCliBinaryInPath("claude-code"), source: "env", backedOff: false };
|
|
231
|
-
}
|
|
232
|
-
|
|
233
232
|
if (providerId === "anthropic-vertex" && process.env.ANTHROPIC_VERTEX_PROJECT_ID) {
|
|
234
233
|
return { found: true, source: "env", backedOff: false };
|
|
235
234
|
}
|
|
@@ -242,9 +241,15 @@ function resolveKey(providerId: string): KeyLookup {
|
|
|
242
241
|
const creds = auth.getCredentialsForProvider(providerId);
|
|
243
242
|
if (creds.length > 0) {
|
|
244
243
|
// Filter out empty placeholder keys (from skipped onboarding)
|
|
245
|
-
const hasRealKey = creds.some(c =>
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
const hasRealKey = creds.some(c => {
|
|
245
|
+
if (c.type === "oauth") return true;
|
|
246
|
+
if (c.type !== "api_key") return false;
|
|
247
|
+
|
|
248
|
+
const key = (c as { key?: string }).key?.trim();
|
|
249
|
+
if (!key) return false;
|
|
250
|
+
|
|
251
|
+
return !(CLI_AUTH_PROVIDERS.has(providerId) && key === "cli");
|
|
252
|
+
});
|
|
248
253
|
if (hasRealKey) {
|
|
249
254
|
return {
|
|
250
255
|
found: true,
|
|
@@ -275,6 +280,12 @@ function resolveKey(providerId: string): KeyLookup {
|
|
|
275
280
|
return { found: true, source: "models.json", backedOff: false };
|
|
276
281
|
}
|
|
277
282
|
|
|
283
|
+
// Cross-provider routes can use a local CLI when it is installed. Explicit
|
|
284
|
+
// external CLI provider selections are handled in checkLlmProviders() below.
|
|
285
|
+
if (CLI_AUTH_PROVIDERS.has(providerId) && isCliBinaryInPath(providerId)) {
|
|
286
|
+
return { found: true, source: "env", backedOff: false };
|
|
287
|
+
}
|
|
288
|
+
|
|
278
289
|
return { found: false, source: "none", backedOff: false };
|
|
279
290
|
}
|
|
280
291
|
|
|
@@ -285,15 +296,32 @@ function checkLlmProviders(): ProviderCheckResult[] {
|
|
|
285
296
|
const results: ProviderCheckResult[] = [];
|
|
286
297
|
|
|
287
298
|
for (const providerId of required) {
|
|
288
|
-
// CLI-authenticated providers don't need API keys
|
|
299
|
+
// CLI-authenticated providers don't need API keys. The provider's own
|
|
300
|
+
// request path validates CLI sessions when it is used.
|
|
289
301
|
if (CLI_AUTH_PROVIDERS.has(providerId)) {
|
|
290
302
|
const info = PROVIDER_REGISTRY.find(p => p.id === providerId);
|
|
303
|
+
const label = info?.label ?? providerId;
|
|
304
|
+
if (CLI_AUTH_PATH_CHECK_PROVIDERS.has(providerId) && !isCliBinaryInPath(providerId)) {
|
|
305
|
+
const binaries = CLI_BINARY_MAP[providerId]?.map(binary => `\`${binary}\``).join(" or ");
|
|
306
|
+
results.push({
|
|
307
|
+
name: providerId,
|
|
308
|
+
label,
|
|
309
|
+
category: "llm",
|
|
310
|
+
status: "error",
|
|
311
|
+
message: `${label} — CLI not found`,
|
|
312
|
+
detail: binaries
|
|
313
|
+
? `Install ${label} and ensure ${binaries} is on PATH`
|
|
314
|
+
: `Install ${label} and ensure its CLI is on PATH`,
|
|
315
|
+
required: true,
|
|
316
|
+
});
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
291
319
|
results.push({
|
|
292
320
|
name: providerId,
|
|
293
|
-
label
|
|
321
|
+
label,
|
|
294
322
|
category: "llm",
|
|
295
323
|
status: "ok",
|
|
296
|
-
message: `${
|
|
324
|
+
message: `${label} — CLI auth (no key needed)`,
|
|
297
325
|
required: true,
|
|
298
326
|
});
|
|
299
327
|
continue;
|
|
@@ -333,7 +361,7 @@ function checkLlmProviders(): ProviderCheckResult[] {
|
|
|
333
361
|
message: `${label} — not configured`,
|
|
334
362
|
detail: providerId === "anthropic-vertex"
|
|
335
363
|
? "Set ANTHROPIC_VERTEX_PROJECT_ID and authenticate with Google ADC"
|
|
336
|
-
: info
|
|
364
|
+
: info && supportsBrowserOAuth(info)
|
|
337
365
|
? `Run /gsd keys to authenticate`
|
|
338
366
|
: `Set ${envVar} or run /gsd keys`,
|
|
339
367
|
required: true,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
|
-
import { join } from "node:path";
|
|
6
|
+
import { dirname, join, resolve } from "node:path";
|
|
7
7
|
|
|
8
8
|
import { autoResolveSafeConflictPaths } from "./git-conflict-resolve.js";
|
|
9
9
|
import { GIT_NO_PROMPT_ENV } from "./git-constants.js";
|
|
@@ -14,6 +14,21 @@ function splitZeroDelimited(output: string): string[] {
|
|
|
14
14
|
return output.split("\0").filter(Boolean);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function hasGitMarker(basePath: string): boolean {
|
|
18
|
+
try {
|
|
19
|
+
let dir = resolve(basePath);
|
|
20
|
+
for (let i = 0; i < 30; i++) {
|
|
21
|
+
if (existsSync(join(dir, ".git"))) return true;
|
|
22
|
+
const parent = dirname(dir);
|
|
23
|
+
if (parent === dir) break;
|
|
24
|
+
dir = parent;
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
// Fall through to the git probes, which will report unknown on failure.
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
17
32
|
export function listUnmergedGitPaths(basePath: string): string[] | null {
|
|
18
33
|
try {
|
|
19
34
|
const output = spawnSync("git", ["diff", "--name-only", "--diff-filter=U", "-z"], {
|
|
@@ -75,6 +90,15 @@ export interface GitConflictProbeResult {
|
|
|
75
90
|
}
|
|
76
91
|
|
|
77
92
|
export function probeGitConflictState(basePath: string): GitConflictProbeResult {
|
|
93
|
+
if (!hasGitMarker(basePath)) {
|
|
94
|
+
return {
|
|
95
|
+
status: "clean",
|
|
96
|
+
unmerged: [],
|
|
97
|
+
checkFailures: [],
|
|
98
|
+
mergeStateBlockers: [],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
78
102
|
const unmerged = listUnmergedGitPaths(basePath);
|
|
79
103
|
if (unmerged === null) {
|
|
80
104
|
return {
|
|
@@ -22,6 +22,7 @@ import { gsdHome } from "./gsd-home.js";
|
|
|
22
22
|
// ─── Provider Registry ─────────────────────────────────────────────────────────
|
|
23
23
|
|
|
24
24
|
export type ProviderCategory = "llm" | "tool" | "search" | "remote";
|
|
25
|
+
export type ProviderAuthMode = "apiKey" | "browserOAuth" | "externalCli" | "cloudIdentity" | "none";
|
|
25
26
|
|
|
26
27
|
export interface ProviderInfo {
|
|
27
28
|
id: string;
|
|
@@ -29,24 +30,24 @@ export interface ProviderInfo {
|
|
|
29
30
|
category: ProviderCategory;
|
|
30
31
|
envVar?: string;
|
|
31
32
|
prefixes?: string[];
|
|
32
|
-
|
|
33
|
+
authMode?: ProviderAuthMode;
|
|
33
34
|
dashboardUrl?: string;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export const PROVIDER_REGISTRY: ProviderInfo[] = [
|
|
37
38
|
// LLM Providers
|
|
38
|
-
{ id: "anthropic", label: "Anthropic (Claude)", category: "llm", envVar: "ANTHROPIC_API_KEY", prefixes: ["sk-ant-"],
|
|
39
|
+
{ id: "anthropic", label: "Anthropic (Claude)", category: "llm", envVar: "ANTHROPIC_API_KEY", prefixes: ["sk-ant-"], authMode: "apiKey", dashboardUrl: "console.anthropic.com" },
|
|
39
40
|
// Claude Code CLI: routes through the local `claude` binary — no API key,
|
|
40
41
|
// authentication is handled by the CLI's own OAuth flow.
|
|
41
42
|
// Referenced by doctor-providers.ts, auto-model-selection.ts, and others;
|
|
42
43
|
// must be in the canonical registry so all consumers see the same catalog.
|
|
43
44
|
// See: https://github.com/open-gsd/gsd-pi/issues/4541
|
|
44
|
-
{ id: "claude-code", label: "Claude Code CLI", category: "llm",
|
|
45
|
+
{ id: "claude-code", label: "Claude Code CLI", category: "llm", authMode: "externalCli" },
|
|
45
46
|
{ id: "openai", label: "OpenAI", category: "llm", envVar: "OPENAI_API_KEY", prefixes: ["sk-"], dashboardUrl: "platform.openai.com/api-keys" },
|
|
46
|
-
{ id: "github-copilot", label: "GitHub Copilot", category: "llm", envVar: "GITHUB_TOKEN",
|
|
47
|
-
{ id: "openai-codex", label: "ChatGPT Plus/Pro (Codex)",category: "llm",
|
|
48
|
-
{ id: "google-gemini-cli",label: "Google Gemini CLI", category: "llm",
|
|
49
|
-
{ id: "google-antigravity",label: "Antigravity", category: "llm",
|
|
47
|
+
{ id: "github-copilot", label: "GitHub Copilot", category: "llm", envVar: "GITHUB_TOKEN", authMode: "browserOAuth" },
|
|
48
|
+
{ id: "openai-codex", label: "ChatGPT Plus/Pro (Codex)",category: "llm", authMode: "browserOAuth" },
|
|
49
|
+
{ id: "google-gemini-cli",label: "Google Gemini CLI", category: "llm", authMode: "externalCli" },
|
|
50
|
+
{ id: "google-antigravity",label: "Antigravity", category: "llm", authMode: "externalCli" },
|
|
50
51
|
{ id: "google", label: "Google (Gemini)", category: "llm", envVar: "GEMINI_API_KEY", dashboardUrl: "aistudio.google.com/apikey" },
|
|
51
52
|
{ id: "groq", label: "Groq", category: "llm", envVar: "GROQ_API_KEY", dashboardUrl: "console.groq.com" },
|
|
52
53
|
{ id: "xai", label: "xAI (Grok)", category: "llm", envVar: "XAI_API_KEY", dashboardUrl: "console.x.ai" },
|
|
@@ -77,6 +78,21 @@ export const PROVIDER_REGISTRY: ProviderInfo[] = [
|
|
|
77
78
|
|
|
78
79
|
// ─── Utilities ──────────────────────────────────────────────────────────────────
|
|
79
80
|
|
|
81
|
+
export function getProviderAuthMode(provider: ProviderInfo): ProviderAuthMode {
|
|
82
|
+
return provider.authMode ?? "apiKey";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function supportsBrowserOAuth(provider: ProviderInfo): boolean {
|
|
86
|
+
return getProviderAuthMode(provider) === "browserOAuth";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function supportsStoredApiKey(provider: ProviderInfo): boolean {
|
|
90
|
+
const mode = getProviderAuthMode(provider);
|
|
91
|
+
if (mode === "externalCli" || mode === "cloudIdentity" || mode === "none") return false;
|
|
92
|
+
if (mode === "browserOAuth") return Boolean(provider.envVar || provider.prefixes?.length);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
/**
|
|
81
97
|
* Mask an API key for display: show first 4 + last 4 chars.
|
|
82
98
|
* Keys shorter than 12 chars show only first 2 + last 2.
|
|
@@ -104,10 +120,13 @@ export function formatDuration(ms: number): string {
|
|
|
104
120
|
/**
|
|
105
121
|
* Describe a credential's type and status.
|
|
106
122
|
*/
|
|
107
|
-
export function describeCredential(cred: AuthCredential): string {
|
|
123
|
+
export function describeCredential(cred: AuthCredential, provider?: ProviderInfo): string {
|
|
108
124
|
if (cred.type === "api_key") {
|
|
109
125
|
const apiCred = cred as ApiKeyCredential;
|
|
110
126
|
if (!apiCred.key) return "empty key";
|
|
127
|
+
if (apiCred.key === "cli" && provider && getProviderAuthMode(provider) === "externalCli") {
|
|
128
|
+
return "external CLI";
|
|
129
|
+
}
|
|
111
130
|
return `API key (${maskKey(apiCred.key)})`;
|
|
112
131
|
}
|
|
113
132
|
if (cred.type === "oauth") {
|
|
@@ -171,7 +190,7 @@ export function getAllKeyStatuses(auth: AuthStorage): KeyStatus[] {
|
|
|
171
190
|
const desc =
|
|
172
191
|
creds.length > 1
|
|
173
192
|
? `${creds.length} keys (round-robin)`
|
|
174
|
-
: describeCredential(firstCred);
|
|
193
|
+
: describeCredential(firstCred, provider);
|
|
175
194
|
return {
|
|
176
195
|
provider,
|
|
177
196
|
configured: true,
|
|
@@ -289,9 +308,28 @@ export async function handleAddKey(
|
|
|
289
308
|
provider = PROVIDER_REGISTRY[idx];
|
|
290
309
|
}
|
|
291
310
|
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
|
|
311
|
+
const authMode = getProviderAuthMode(provider);
|
|
312
|
+
if (authMode === "externalCli") {
|
|
313
|
+
ctx.ui.notify(
|
|
314
|
+
`${provider.label} is authenticated by its own local CLI. ` +
|
|
315
|
+
`Sign in with that CLI first, then run /login to activate it in GSD.`,
|
|
316
|
+
"info",
|
|
317
|
+
);
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (authMode === "cloudIdentity") {
|
|
322
|
+
ctx.ui.notify(
|
|
323
|
+
`${provider.label} uses cloud identity credentials. Configure the provider's cloud CLI or environment, then restart GSD.`,
|
|
324
|
+
"info",
|
|
325
|
+
);
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (supportsBrowserOAuth(provider)) {
|
|
330
|
+
const methods = supportsStoredApiKey(provider)
|
|
331
|
+
? ["API token/key", "Browser login (OAuth)"]
|
|
332
|
+
: ["Browser login (OAuth)"];
|
|
295
333
|
const method = await ctx.ui.select(
|
|
296
334
|
`${provider.label} — how do you want to authenticate?`,
|
|
297
335
|
methods,
|
|
@@ -308,6 +346,11 @@ export async function handleAddKey(
|
|
|
308
346
|
}
|
|
309
347
|
}
|
|
310
348
|
|
|
349
|
+
if (!supportsStoredApiKey(provider)) {
|
|
350
|
+
ctx.ui.notify(`${provider.label} does not accept a GSD-stored API key. Use /login.`, "info");
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
|
|
311
354
|
// API key input
|
|
312
355
|
const input = await ctx.ui.input(
|
|
313
356
|
`API key for ${provider.label}:`,
|
|
@@ -387,7 +430,7 @@ export async function handleRemoveKey(
|
|
|
387
430
|
|
|
388
431
|
// Multi-key handling
|
|
389
432
|
if (creds.length > 1) {
|
|
390
|
-
const options = creds.map((c, i) => `[${i + 1}] ${describeCredential(c)}`);
|
|
433
|
+
const options = creds.map((c, i) => `[${i + 1}] ${describeCredential(c, provider)}`);
|
|
391
434
|
options.push("Remove all");
|
|
392
435
|
|
|
393
436
|
const choice = await ctx.ui.select(
|
|
@@ -411,7 +454,7 @@ export async function handleRemoveKey(
|
|
|
411
454
|
} else {
|
|
412
455
|
const confirmed = await ctx.ui.confirm(
|
|
413
456
|
"Remove key?",
|
|
414
|
-
`Remove ${describeCredential(creds[0])} for ${provider.label}?`,
|
|
457
|
+
`Remove ${describeCredential(creds[0], provider)} for ${provider.label}?`,
|
|
415
458
|
);
|
|
416
459
|
if (!confirmed) return false;
|
|
417
460
|
auth.remove(provider.id);
|