@opengsd/gsd-pi 1.2.0-dev.d6c5343c → 1.2.0-dev.ddc97c10
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/dist/mcp-server.js +2 -1
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/gsd/auto/orchestrator.js +28 -10
- package/dist/resources/extensions/gsd/auto/phases.js +47 -4
- package/dist/resources/extensions/gsd/auto/session.js +3 -0
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +3 -2
- package/dist/resources/extensions/gsd/auto-dispatch.js +11 -2
- package/dist/resources/extensions/gsd/auto-model-selection.js +11 -7
- package/dist/resources/extensions/gsd/auto-post-unit.js +18 -6
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +45 -21
- package/dist/resources/extensions/gsd/auto-verification.js +14 -2
- package/dist/resources/extensions/gsd/auto.js +37 -1
- package/dist/resources/extensions/gsd/blocked-models.js +28 -0
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +26 -6
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +2 -2
- package/dist/resources/extensions/gsd/closeout-wizard.js +92 -0
- package/dist/resources/extensions/gsd/commands/context.js +16 -2
- package/dist/resources/extensions/gsd/commands-handlers.js +46 -3
- package/dist/resources/extensions/gsd/consent-question.js +16 -0
- package/dist/resources/extensions/gsd/crash-recovery.js +8 -3
- package/dist/resources/extensions/gsd/doctor-engine-checks.js +3 -3
- package/dist/resources/extensions/gsd/doctor-git-checks.js +2 -18
- package/dist/resources/extensions/gsd/gsd-command-home.js +22 -12
- package/dist/resources/extensions/gsd/gsd-db.js +2 -1
- package/dist/resources/extensions/gsd/guided-flow.js +6 -3
- package/dist/resources/extensions/gsd/milestone-closeout.js +73 -2
- package/dist/resources/extensions/gsd/milestone-planning-persistence.js +2 -2
- package/dist/resources/extensions/gsd/projection-flush.js +7 -0
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/execute-task.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -1
- package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
- package/dist/resources/extensions/gsd/prompts/refine-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
- package/dist/resources/extensions/gsd/prompts/run-uat.md +1 -1
- package/dist/resources/extensions/gsd/prompts/triage-captures.md +1 -1
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +1 -1
- package/dist/resources/extensions/gsd/roadmap-slices.js +25 -3
- package/dist/resources/extensions/gsd/session-lock.js +1 -1
- package/dist/resources/extensions/gsd/tool-contract.js +14 -3
- package/dist/resources/extensions/gsd/tools/complete-milestone.js +3 -2
- package/dist/resources/extensions/gsd/tools/complete-slice.js +2 -2
- package/dist/resources/extensions/gsd/tools/complete-task.js +3 -2
- package/dist/resources/extensions/gsd/tools/plan-slice.js +2 -2
- package/dist/resources/extensions/gsd/tools/plan-task.js +2 -2
- package/dist/resources/extensions/gsd/tools/reassess-roadmap.js +2 -2
- package/dist/resources/extensions/gsd/tools/reopen-milestone.js +2 -2
- package/dist/resources/extensions/gsd/tools/reopen-slice.js +2 -2
- package/dist/resources/extensions/gsd/tools/reopen-task.js +2 -2
- package/dist/resources/extensions/gsd/tools/replan-slice.js +2 -2
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +67 -2
- package/dist/resources/extensions/gsd/verification-verdict.js +2 -1
- package/dist/resources/extensions/shared/gsd-browser-cli.js +21 -2
- package/dist/resources/shared/gsd-browser-path-sync.js +214 -0
- package/dist/resources/shared/package-manager-detection.js +1 -1
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/update-check.d.ts +2 -0
- package/dist/update-check.js +24 -1
- package/dist/update-cmd.js +20 -3
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
- 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/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 +12 -12
- package/dist/web/standalone/.next/server/chunks/8357.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/package.json +1 -1
- package/packages/cloud-mcp-gateway/package.json +2 -2
- 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/package.json +7 -7
- package/packages/mcp-server/dist/cli.js +10 -5
- package/packages/mcp-server/dist/cli.js.map +1 -1
- package/packages/mcp-server/dist/moonshot-tool-schema.d.ts +29 -0
- package/packages/mcp-server/dist/moonshot-tool-schema.d.ts.map +1 -0
- package/packages/mcp-server/dist/moonshot-tool-schema.js +50 -0
- package/packages/mcp-server/dist/moonshot-tool-schema.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +4 -0
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts +18 -18
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +99 -38
- 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/package.json +1 -1
- package/packages/pi-ai/dist/index.d.ts +2 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +2 -0
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +12 -7
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.d.ts +5 -0
- package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js +12 -3
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +7 -3
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.d.ts +9 -0
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.js +34 -0
- package/packages/pi-ai/dist/utils/moonshot-tool-schema.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +6 -2
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-coding-agent/package.json +7 -7
- package/packages/pi-tui/package.json +2 -2
- package/packages/rpc-client/package.json +2 -2
- package/pkg/package.json +1 -1
- package/src/resources/extensions/browser-tools/tests/gsd-browser-launch-config.test.mjs +11 -0
- package/src/resources/extensions/gsd/auto/orchestrator.ts +28 -10
- package/src/resources/extensions/gsd/auto/phases.ts +63 -24
- package/src/resources/extensions/gsd/auto/session.ts +3 -0
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +10 -16
- package/src/resources/extensions/gsd/auto-dispatch.ts +11 -10
- package/src/resources/extensions/gsd/auto-model-selection.ts +16 -7
- package/src/resources/extensions/gsd/auto-post-unit.ts +21 -6
- package/src/resources/extensions/gsd/auto-unit-closeout.ts +83 -28
- package/src/resources/extensions/gsd/auto-verification.ts +18 -2
- package/src/resources/extensions/gsd/auto.ts +44 -1
- package/src/resources/extensions/gsd/blocked-models.ts +49 -0
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +34 -5
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +2 -2
- package/src/resources/extensions/gsd/closeout-wizard.ts +102 -0
- package/src/resources/extensions/gsd/commands/context.ts +16 -2
- package/src/resources/extensions/gsd/commands-handlers.ts +46 -3
- package/src/resources/extensions/gsd/consent-question.ts +15 -0
- package/src/resources/extensions/gsd/crash-recovery.ts +10 -2
- package/src/resources/extensions/gsd/doctor-engine-checks.ts +3 -3
- package/src/resources/extensions/gsd/doctor-git-checks.ts +2 -19
- package/src/resources/extensions/gsd/gsd-command-home.ts +13 -3
- package/src/resources/extensions/gsd/gsd-db.ts +4 -3
- package/src/resources/extensions/gsd/guided-flow.ts +21 -26
- package/src/resources/extensions/gsd/milestone-closeout.ts +97 -2
- package/src/resources/extensions/gsd/milestone-planning-persistence.ts +2 -2
- package/src/resources/extensions/gsd/projection-flush.ts +20 -0
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/execute-task.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/quick-task.md +1 -1
- package/src/resources/extensions/gsd/prompts/reassess-roadmap.md +1 -1
- package/src/resources/extensions/gsd/prompts/refine-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/replan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/rewrite-docs.md +1 -1
- package/src/resources/extensions/gsd/prompts/run-uat.md +1 -1
- package/src/resources/extensions/gsd/prompts/triage-captures.md +1 -1
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +1 -1
- package/src/resources/extensions/gsd/roadmap-slices.ts +28 -3
- package/src/resources/extensions/gsd/session-lock.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +69 -0
- package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +97 -0
- package/src/resources/extensions/gsd/tests/auto-remote-session-lock-cleanup.test.ts +65 -3
- package/src/resources/extensions/gsd/tests/blocked-models.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/consent-question.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/doctor-git-checks-terminal.test.ts +73 -0
- package/src/resources/extensions/gsd/tests/gsd-command-home.test.ts +120 -0
- package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +2 -6
- package/src/resources/extensions/gsd/tests/milestone-closeout.test.ts +95 -4
- package/src/resources/extensions/gsd/tests/parsers-legacy-importers.test.ts +0 -1
- package/src/resources/extensions/gsd/tests/phases-terminal-complete-idempotent.test.ts +242 -0
- package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +63 -2
- package/src/resources/extensions/gsd/tests/roadmap-slices.test.ts +68 -0
- package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +19 -1
- package/src/resources/extensions/gsd/tests/tool-unavailable-retry.test.ts +33 -0
- package/src/resources/extensions/gsd/tests/transport-gate-double-complete.test.ts +139 -0
- package/src/resources/extensions/gsd/tests/verification-verdict.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +273 -38
- package/src/resources/extensions/gsd/tool-contract.ts +38 -3
- package/src/resources/extensions/gsd/tools/complete-milestone.ts +3 -2
- package/src/resources/extensions/gsd/tools/complete-slice.ts +2 -2
- package/src/resources/extensions/gsd/tools/complete-task.ts +3 -2
- package/src/resources/extensions/gsd/tools/plan-slice.ts +2 -2
- package/src/resources/extensions/gsd/tools/plan-task.ts +2 -2
- package/src/resources/extensions/gsd/tools/reassess-roadmap.ts +2 -2
- package/src/resources/extensions/gsd/tools/reopen-milestone.ts +2 -2
- package/src/resources/extensions/gsd/tools/reopen-slice.ts +2 -2
- package/src/resources/extensions/gsd/tools/reopen-task.ts +2 -2
- package/src/resources/extensions/gsd/tools/replan-slice.ts +2 -2
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +81 -2
- package/src/resources/extensions/gsd/verification-verdict.ts +4 -2
- package/src/resources/extensions/shared/gsd-browser-cli.ts +23 -2
- package/src/resources/shared/gsd-browser-path-sync.ts +273 -0
- package/src/resources/shared/package-manager-detection.ts +1 -1
- /package/dist/web/standalone/.next/static/{jmTLg6xZmAuq_LIqKOxrH → McokybTayhff1xEVc-d3T}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{jmTLg6xZmAuq_LIqKOxrH → McokybTayhff1xEVc-d3T}/_ssgManifest.js +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Project/App: gsd-pi
|
|
2
2
|
// File Purpose: Host-owned verification verdict policy for auto-mode units.
|
|
3
|
+
export const NO_HOST_CHECKS_FAILURE_CONTEXT = "No runnable host-owned verification command was discovered. Add project verification_commands in .gsd/PREFERENCES.md or a runnable task-plan Verify command, then resume with /gsd next.";
|
|
3
4
|
export function decideVerificationVerdict(unitType, result) {
|
|
4
5
|
if (unitType === "execute-task" && result.discoverySource === "task-plan-prose" && result.checks.length === 0) {
|
|
5
6
|
return {
|
|
@@ -14,7 +15,7 @@ export function decideVerificationVerdict(unitType, result) {
|
|
|
14
15
|
passed: false,
|
|
15
16
|
reason: "no-host-checks",
|
|
16
17
|
retryable: false,
|
|
17
|
-
failureContext:
|
|
18
|
+
failureContext: NO_HOST_CHECKS_FAILURE_CONTEXT,
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
if (!result.passed) {
|
|
@@ -38,6 +38,22 @@ function compareSemverLocal(a, b) {
|
|
|
38
38
|
function parseGsdBrowserVersion(output) {
|
|
39
39
|
return output.match(/\b(\d+\.\d+\.\d+)\b/)?.[1] ?? null;
|
|
40
40
|
}
|
|
41
|
+
function splitCommandLine(commandLine) {
|
|
42
|
+
const parts = commandLine.match(/(?:"[^"]*"|'[^']*'|[^\s"']+)/g) ?? [];
|
|
43
|
+
return parts.map((part) => {
|
|
44
|
+
const quote = part[0];
|
|
45
|
+
if ((quote === '"' || quote === "'") && part.endsWith(quote)) {
|
|
46
|
+
return part.slice(1, -1);
|
|
47
|
+
}
|
|
48
|
+
return part;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function buildPathGsdBrowserVersionInvocation(platform) {
|
|
52
|
+
if (platform === "win32") {
|
|
53
|
+
return { command: "cmd", args: ["/d", "/s", "/c", "gsd-browser", "--version"] };
|
|
54
|
+
}
|
|
55
|
+
return { command: "gsd-browser", args: ["--version"] };
|
|
56
|
+
}
|
|
41
57
|
function isRecord(value) {
|
|
42
58
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
43
59
|
}
|
|
@@ -67,7 +83,8 @@ function resolvePathGsdBrowserVersion(env) {
|
|
|
67
83
|
if (cachedPathProbeVersion !== undefined)
|
|
68
84
|
return cachedPathProbeVersion;
|
|
69
85
|
try {
|
|
70
|
-
|
|
86
|
+
const invocation = buildPathGsdBrowserVersionInvocation(process.platform);
|
|
87
|
+
cachedPathProbeVersion = parseGsdBrowserVersion(execFileSync(invocation.command, invocation.args, {
|
|
71
88
|
encoding: "utf-8",
|
|
72
89
|
env,
|
|
73
90
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -176,7 +193,8 @@ export function resolveGsdBrowserMcpLaunchConfig(projectRoot, env = process.env,
|
|
|
176
193
|
const serverName = env.GSD_BROWSER_MCP_NAME?.trim() || GSD_BROWSER_MCP_SERVER_NAME;
|
|
177
194
|
const explicitArgs = parseJsonEnv(env, "GSD_BROWSER_MCP_ARGS");
|
|
178
195
|
const explicitEnv = parseJsonEnv(env, "GSD_BROWSER_MCP_ENV");
|
|
179
|
-
const
|
|
196
|
+
const explicitCommandLine = env.GSD_BROWSER_MCP_COMMAND?.trim();
|
|
197
|
+
const [explicitCommand, ...explicitCommandArgs] = explicitCommandLine ? splitCommandLine(explicitCommandLine) : [];
|
|
180
198
|
const explicitCliPath = resolveExplicitGsdBrowserCliPath(env);
|
|
181
199
|
const preferPathCli = !explicitCommand && !explicitCliPath && shouldPreferPathGsdBrowser(env);
|
|
182
200
|
const bundledCliPath = !explicitCommand && !explicitCliPath && !preferPathCli
|
|
@@ -198,6 +216,7 @@ export function resolveGsdBrowserMcpLaunchConfig(projectRoot, env = process.env,
|
|
|
198
216
|
const args = Array.isArray(explicitArgs) && explicitArgs.length > 0
|
|
199
217
|
? explicitArgs.map(String)
|
|
200
218
|
: [
|
|
219
|
+
...explicitCommandArgs,
|
|
201
220
|
...(bundledCliPath ? [bundledCliPath] : []),
|
|
202
221
|
"mcp",
|
|
203
222
|
"--session",
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { chmodSync, copyFileSync, existsSync, lstatSync, readlinkSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { dirname, isAbsolute, join, delimiter as pathDelimiter, resolve as resolvePath } from 'node:path';
|
|
5
|
+
import { isPnpmInstall, pathStartsWith } from './package-manager-detection.js';
|
|
6
|
+
function isBunGlobalInstall(argv1, env) {
|
|
7
|
+
if ('bun' in process.versions)
|
|
8
|
+
return true;
|
|
9
|
+
if (!argv1)
|
|
10
|
+
return false;
|
|
11
|
+
const bunBinDirs = [];
|
|
12
|
+
if (env.BUN_INSTALL)
|
|
13
|
+
bunBinDirs.push(join(env.BUN_INSTALL, 'bin'));
|
|
14
|
+
bunBinDirs.push(join(homedir(), '.bun', 'bin'));
|
|
15
|
+
return bunBinDirs.some((dir) => pathStartsWith(argv1, dir));
|
|
16
|
+
}
|
|
17
|
+
function gsdBrowserBinaryName(platform) {
|
|
18
|
+
return platform === 'win32' ? 'gsd-browser.cmd' : 'gsd-browser';
|
|
19
|
+
}
|
|
20
|
+
function tryResolveFromBinDir(binDir, platform) {
|
|
21
|
+
const primary = join(binDir, gsdBrowserBinaryName(platform));
|
|
22
|
+
if (existsSync(primary))
|
|
23
|
+
return primary;
|
|
24
|
+
if (platform === 'win32') {
|
|
25
|
+
const fallback = join(binDir, 'gsd-browser');
|
|
26
|
+
if (existsSync(fallback))
|
|
27
|
+
return fallback;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
function tryResolveFromPackageRoot(rootDir, platform) {
|
|
32
|
+
const candidate = join(rootDir, '@opengsd', 'gsd-browser', 'bin', gsdBrowserBinaryName(platform));
|
|
33
|
+
if (existsSync(candidate))
|
|
34
|
+
return candidate;
|
|
35
|
+
if (platform === 'win32') {
|
|
36
|
+
const fallback = join(rootDir, '@opengsd', 'gsd-browser', 'bin', 'gsd-browser');
|
|
37
|
+
if (existsSync(fallback))
|
|
38
|
+
return fallback;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function tryExecLookup(command, args, env, platform, resolve) {
|
|
43
|
+
try {
|
|
44
|
+
const dir = execFileSync(command, args, {
|
|
45
|
+
encoding: 'utf-8',
|
|
46
|
+
env,
|
|
47
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
48
|
+
timeout: 5000,
|
|
49
|
+
}).trim();
|
|
50
|
+
return resolve(dir, platform);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function resolvePathBinary(env, platform) {
|
|
57
|
+
if (platform === 'win32') {
|
|
58
|
+
try {
|
|
59
|
+
const out = execFileSync('where', ['gsd-browser'], {
|
|
60
|
+
encoding: 'utf-8',
|
|
61
|
+
env,
|
|
62
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
63
|
+
timeout: 5000,
|
|
64
|
+
}).trim();
|
|
65
|
+
const first = out.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
66
|
+
return first && existsSync(first) ? first : null;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const entry of (env.PATH ?? '').split(pathDelimiter)) {
|
|
73
|
+
if (!entry)
|
|
74
|
+
continue;
|
|
75
|
+
const candidate = join(entry, 'gsd-browser');
|
|
76
|
+
if (existsSync(candidate))
|
|
77
|
+
return candidate;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function resolveRealPath(pathValue) {
|
|
82
|
+
try {
|
|
83
|
+
return realpathSync(pathValue);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return resolvePath(pathValue);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function resolveSymlinkTarget(pathCli) {
|
|
90
|
+
try {
|
|
91
|
+
const stat = lstatSync(pathCli);
|
|
92
|
+
if (!stat.isSymbolicLink())
|
|
93
|
+
return pathCli;
|
|
94
|
+
const target = readlinkSync(pathCli);
|
|
95
|
+
return isAbsolute(target) ? target : resolvePath(dirname(pathCli), target);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// PATH entry vanished or is inaccessible between resolution and sync.
|
|
99
|
+
// Fall back to the original path; subsequent sync will surface a useful
|
|
100
|
+
// error rather than escaping as an unhandled throw.
|
|
101
|
+
return pathCli;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function resolveHomeDir(env) {
|
|
105
|
+
const fromEnv = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
106
|
+
return resolvePath(fromEnv || homedir());
|
|
107
|
+
}
|
|
108
|
+
function canAutoSyncTarget(targetPath, env) {
|
|
109
|
+
const home = resolveHomeDir(env);
|
|
110
|
+
const resolved = resolvePath(targetPath);
|
|
111
|
+
return pathStartsWith(resolved, home);
|
|
112
|
+
}
|
|
113
|
+
function syncBinary(installedCli, targetPath, platform) {
|
|
114
|
+
const source = resolveRealPath(installedCli);
|
|
115
|
+
copyFileSync(source, targetPath);
|
|
116
|
+
if (platform !== 'win32') {
|
|
117
|
+
chmodSync(targetPath, 0o755);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Resolve the gsd-browser binary installed by the active global package manager.
|
|
122
|
+
*/
|
|
123
|
+
export function resolveGlobalGsdBrowserCliPath(options = {}) {
|
|
124
|
+
const env = options.env ?? process.env;
|
|
125
|
+
const argv1 = options.argv1 ?? process.argv[1];
|
|
126
|
+
const platform = options.platform ?? process.platform;
|
|
127
|
+
if (isBunGlobalInstall(argv1, env)) {
|
|
128
|
+
return (tryExecLookup('bun', ['pm', 'bin', '-g'], env, platform, tryResolveFromBinDir)
|
|
129
|
+
?? (env.BUN_INSTALL ? tryResolveFromBinDir(join(env.BUN_INSTALL, 'bin'), platform) : null)
|
|
130
|
+
?? tryResolveFromBinDir(join(homedir(), '.bun', 'bin'), platform));
|
|
131
|
+
}
|
|
132
|
+
if (isPnpmInstall(argv1, env)) {
|
|
133
|
+
return (tryExecLookup('pnpm', ['bin', '-g'], env, platform, tryResolveFromBinDir)
|
|
134
|
+
?? tryExecLookup('pnpm', ['root', '-g'], env, platform, tryResolveFromPackageRoot));
|
|
135
|
+
}
|
|
136
|
+
return (tryExecLookup('npm', ['bin', '-g'], env, platform, tryResolveFromBinDir)
|
|
137
|
+
?? tryExecLookup('npm', ['root', '-g'], env, platform, tryResolveFromPackageRoot));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Resolve the gsd-browser binary that wins on PATH (`command -v` / `where`).
|
|
141
|
+
*/
|
|
142
|
+
export function resolveGsdBrowserOnPath(env = process.env, platform = process.platform) {
|
|
143
|
+
return resolvePathBinary(env, platform);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* After a global gsd-browser install, ensure the PATH-resolved binary matches
|
|
147
|
+
* the freshly installed global binary when an older copy is shadowing it.
|
|
148
|
+
*/
|
|
149
|
+
export function reconcileGsdBrowserPathAfterInstall(options) {
|
|
150
|
+
const env = options.env ?? process.env;
|
|
151
|
+
const argv1 = options.argv1 ?? process.argv[1];
|
|
152
|
+
const platform = options.platform ?? process.platform;
|
|
153
|
+
const installedCli = resolveGlobalGsdBrowserCliPath({ env, argv1, platform });
|
|
154
|
+
if (!installedCli) {
|
|
155
|
+
return { action: 'none' };
|
|
156
|
+
}
|
|
157
|
+
const pathCli = resolveGsdBrowserOnPath(env, platform);
|
|
158
|
+
const installedReal = resolveRealPath(installedCli);
|
|
159
|
+
if (pathCli && resolveRealPath(pathCli) === installedReal) {
|
|
160
|
+
return { action: 'none', pathCli, installedCli };
|
|
161
|
+
}
|
|
162
|
+
const pathVersion = options.resolvePathVersion(env);
|
|
163
|
+
if (pathVersion && options.compareSemver(pathVersion, options.latestVersion) >= 0) {
|
|
164
|
+
return { action: 'none', pathCli: pathCli ?? undefined, installedCli };
|
|
165
|
+
}
|
|
166
|
+
if (!pathCli) {
|
|
167
|
+
return {
|
|
168
|
+
action: 'shadowed',
|
|
169
|
+
installedCli,
|
|
170
|
+
message: 'Installed gsd-browser globally, but no gsd-browser was found on PATH. Add your package manager global bin directory to PATH.',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const syncTarget = resolveSymlinkTarget(pathCli);
|
|
174
|
+
if (!canAutoSyncTarget(syncTarget, env)) {
|
|
175
|
+
return {
|
|
176
|
+
action: 'shadowed',
|
|
177
|
+
pathCli,
|
|
178
|
+
installedCli,
|
|
179
|
+
syncTarget,
|
|
180
|
+
message: `PATH resolves gsd-browser to ${pathCli}, but the updated global install is at ${installedCli}. ` +
|
|
181
|
+
'Move your package manager global bin directory ahead of the stale location on PATH, or update the stale binary manually.',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
let syncSucceeded = false;
|
|
185
|
+
try {
|
|
186
|
+
syncBinary(installedCli, syncTarget, platform);
|
|
187
|
+
syncSucceeded = true;
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// Fall through to shadowed guidance.
|
|
191
|
+
}
|
|
192
|
+
if (syncSucceeded) {
|
|
193
|
+
const refreshedVersion = options.resolvePathVersion(env);
|
|
194
|
+
const verified = refreshedVersion !== null
|
|
195
|
+
&& options.compareSemver(refreshedVersion, options.latestVersion) >= 0;
|
|
196
|
+
return {
|
|
197
|
+
action: 'synced',
|
|
198
|
+
pathCli,
|
|
199
|
+
installedCli,
|
|
200
|
+
syncTarget,
|
|
201
|
+
message: verified
|
|
202
|
+
? `Synced PATH-resolved gsd-browser at ${syncTarget} to the updated global install.`
|
|
203
|
+
: `Synced PATH-resolved gsd-browser at ${syncTarget} to the updated global install. Could not verify the new version on PATH; restart your shell or rerun if it still reports the old version.`,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
action: 'shadowed',
|
|
208
|
+
pathCli,
|
|
209
|
+
installedCli,
|
|
210
|
+
syncTarget,
|
|
211
|
+
message: `PATH resolves gsd-browser to ${pathCli}, but the updated global install is at ${installedCli}. ` +
|
|
212
|
+
'Move your package manager global bin directory ahead of the stale location on PATH, or update the stale binary manually.',
|
|
213
|
+
};
|
|
214
|
+
}
|
|
@@ -9,7 +9,7 @@ function hasPnpmPath(value) {
|
|
|
9
9
|
normalized.endsWith('/pnpm.cjs') ||
|
|
10
10
|
normalized.endsWith('/pnpm.js'));
|
|
11
11
|
}
|
|
12
|
-
function pathStartsWith(pathValue, dir) {
|
|
12
|
+
export function pathStartsWith(pathValue, dir) {
|
|
13
13
|
if (!pathValue)
|
|
14
14
|
return false;
|
|
15
15
|
const resolvedPath = resolvePath(pathValue);
|