From a9efc652ae0d2d17f7f6884dfcb12cd6d73b253d Mon Sep 17 00:00:00 2001 From: Roee Sanker Date: Tue, 15 Sep 2026 17:01:05 +0300 Subject: [PATCH 1/4] Align APR admin guide with current hooks product docs Co-authored-by: Cursor --- docs/package-resolution-admin-guide.md | 61 +++++++++++++++++--------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/docs/package-resolution-admin-guide.md b/docs/package-resolution-admin-guide.md index d0f97aa..33519eb 100644 --- a/docs/package-resolution-admin-guide.md +++ b/docs/package-resolution-admin-guide.md @@ -4,7 +4,7 @@ Route AI-assisted package installs through your JFrog Artifactory repositories w Agent Package Resolution runs at the start of each agent session. When enabled, it injects routing policy and resolved Artifactory URLs into the session so the agent prefers your repositories over public registries. Durable enforcement still comes from **package manager configuration** (`jf setup`) and **JFrog Curation** on the server. -This guide is for **platform administrators** and **developers** onboarding the JFrog coding-agent plugins. For installing the plugin itself, see the JFrog documentation for your IDE ([Cursor](https://docs.jfrog.com/ai-ml/docs/cursor), [Claude Code](https://docs.jfrog.com/ai-ml/docs/claude-code/), [VS Code](https://docs.jfrog.com/ai-ml/docs/vs-code)) or this repository's [README](../README.md) for **Codex**. +This guide is for **platform administrators** and **developers** onboarding the JFrog coding-agent plugins. For installing the plugin itself, see the JFrog documentation for your IDE ([Cursor](https://docs.jfrog.com/ai-ml/docs/cursor), [Claude Code](https://docs.jfrog.com/ai-ml/docs/claude-code/), [VS Code](https://docs.jfrog.com/ai-ml/docs/vs-code)) or the [Codex plugin README](https://github.com/jfrog/codex-plugin#installation) for Codex. > **Related:** [Use the MCP Registry with Agent Guard](https://docs.jfrog.com/ai-ml/docs/configure-coding-agents) covers MCP governance. Agent Package Resolution is a separate capability in the same JFrog plugin family and uses the same local configuration file for admin settings. @@ -12,14 +12,13 @@ This guide is for **platform administrators** and **developers** onboarding the ## Setup summary -| Step | Action | -| ---- | ---------------------------------------------------------------------------------------------------------- | -| 1 | Install the JFrog plugin in your coding assistant | -| 2 | Install and configure the JFrog CLI (`jf config add`) — required for **routing** mode | -| 3 | Confirm `~/.jfrog/agents-conf.json` (shipped template enables APR with empty bindings; or deploy your own) | -| 4 | **Codex:** restart, then `/hooks` and trust the SessionStart command (plugin install does not skip this) | -| 5 | Start a **new agent session** — policy and URLs are injected once per session | - +| Step | Action | +| ---- | ------------------------------------------------------------------------------------------------------------------------- | +| 1 | Install the JFrog plugin in your coding assistant | +| 2 | Install and configure the JFrog CLI (`jf config add`) — required for **routing** mode | +| 3 | If an administrator pre-deployed `.jfrog/agents-conf.json`, confirm it; otherwise continue—the first session creates it | +| 4 | **Codex:** after install, restart, then `/hooks` and trust the SessionStart command (plugin install does not skip this — see the [Codex plugin README](https://github.com/jfrog/codex-plugin#installation)) | +| 5 | Start a **new agent session** — missing config is created, then policy and URLs are injected once per session | ### Codex install and hook trust @@ -37,14 +36,12 @@ The hook command uses `${PLUGIN_ROOT}` (Codex also sets `CLAUDE_PLUGIN_ROOT` for The shipped template turns Agent Package Resolution **on** (`enabled: true`) with empty `defaultGlobalRepos`. Nothing is routed until Consent Enable or an administrator adds bindings. Set `enabled: false` or `JF_AGENT_PACKAGE_RESOLUTION_DISABLE=1` to keep it off. - **At a glance:** - **Default:** on, but routes nothing until you add repositories. - **To route installs:** add repository keys under `defaultGlobalRepos` (org config or Consent Enable). - **To turn it off org-wide:** deploy your own `agents-conf.json` with `"enabled": false` (see [Turning Agent Package Resolution off](#turning-agent-package-resolution-off-admins)). Setting `"enabled": false` on the plugin's **default file without also deploying your own** is not durable — the plugin re-enables it on the next session. - --- ## Prerequisites @@ -70,13 +67,12 @@ If `jf` is missing or has no usable configured server, the feature stays in **pe All Agent Package Resolution admin settings live in a single JSON file on the developer machine: -``` -~/.jfrog/agents-conf.json -``` +- macOS/Linux: `~/.jfrog/agents-conf.json` +- Windows: `%USERPROFILE%\.jfrog\agents-conf.json` | Property | Description | | --------------------- | -------------------------------------------------------------------------------- | -| **Scope** | Per user profile (`$HOME`) | +| **Scope** | Per user profile (`$HOME` or `%USERPROFILE%`) | | **Written by** | Administrators (MDM, golden image, manual edit) or auto-created on first session | | **Read by** | JFrog plugin session hooks on every agent session start | | **Never overwritten** | If the file already exists, the plugin does not replace it | @@ -101,6 +97,32 @@ This lets organizations **pre-deploy** their own `agents-conf.json` (via MDM, An Per-type durable declines live in `~/.jfrog/skills-cache/apr-onboarding-v1.json` (not in `agents-conf.json`). +Throughout this guide, `~/.jfrog/...` means the current user-profile `.jfrog` +directory. On Windows, substitute `%USERPROFILE%\.jfrog\...`; the JSON schema +and filenames are identical on every platform. + +### Windows verification (PowerShell) + +Confirm that the native executables and profile config are visible to the same +Windows user that launches the IDE: + +```powershell +Get-Command node.exe +Get-Command jf.exe +jf.exe --version +jf.exe config show +Test-Path "$env:USERPROFILE\.jfrog\agents-conf.json" +``` + +The resolver cache is +`%USERPROFILE%\.jfrog\skills-cache\package-resolution.json`, the eager-setup +receipt is +`%USERPROFILE%\.jfrog\skills-cache\package-setup-v2.json`, and hook logs are +written to `%USERPROFILE%\.jfrog\logs\agent-hooks.log`. After installing or +changing a hook, use `Ctrl+Shift+P` → **Developer: Reload Window** in Cursor, +start a new Claude Code or VS Code Copilot session, or restart Codex and +re-trust `/hooks` if the SessionStart command changed. + ### Consent Enable (developer chat flow) When the nudge fires, the agent walks the developer through enabling APR **in chat** (no hand-editing JSON): @@ -151,9 +173,6 @@ the `jfrog` skill + `verify-repo`, or manually — see With default `verifyRepos: true`, Consent Enable / `configure.mjs enable` accepts keys Artifactory confirms as virtual repositories of the requested package type. ---- - - ### Turning Agent Package Resolution off (admins) > **Why `enabled: false` alone may not stick.** Because the feature now ships **on**, the plugin re-enables its **own default file** if it finds it still turned off. "Default file" means the `agents-conf.json` the plugin auto-created and that no one has changed except (at most) the `enabled` flag. As soon as you deploy your **own** config, or add any other setting (like `onboardingPrompt`), the plugin treats it as yours and never re-enables it. @@ -179,6 +198,8 @@ keys Artifactory confirms as virtual repositories of the requested package type. Setting **only** `"onboardingPrompt": "off"` stops the Consent Enable prompts but does **not** turn the feature off — leave `enabled: false` in place for that. See also [emergency disable](#environment-variable-emergency-disable) for the environment variable. +--- + ## Admin control: deploy `agents-conf.json` across your organization Use standard endpoint management to place a consistent `agents-conf.json` on every developer machine. @@ -200,8 +221,6 @@ Use standard endpoint management to place a consistent `agents-conf.json` on eve | Auto-configure package managers at first session | Add types to `autoSetup` ([Zero-touch setup](#zero-touch-setup-autosetup)) | | Force all cached state to refresh | Set `"cacheTtlDays": 0` (this also re-runs eligible zero-touch `jf setup` each session), or edit `agents-conf.json` | | Support troubleshooting | Set `"logLevel": "debug"` temporarily; logs go to `~/.jfrog/logs/agent-hooks.log` | -| Keep APR **off** (durable) | Deploy your own file with `"enabled": false`, **or** set `"enabled": false` **and** `"onboardingPrompt": "off"` on the plugin's default file — see [Turning off](#turning-agent-package-resolution-off-admins) | -| Silence Consent Enable offers only | Set `"onboardingPrompt": "off"` (does not disable APR while `enabled` is `true`) | --- @@ -529,5 +548,5 @@ Workspace values win over `agents-conf.json` for matching types during that sess - [Install JFrog Plugin for Cursor](https://docs.jfrog.com/ai-ml/docs/install-jfrog-plugin-for-cursor) - [Install JFrog Plugin for Claude Code](https://docs.jfrog.com/ai-ml/docs/install-jfrog-plugin-for-claude-code) - [Install JFrog Plugin for VS Code](https://docs.jfrog.com/ai-ml/docs/install-jfrog-plugin-for-vs-code) -- [Install the JFrog plugin for Codex](../README.md#installation) +- [Install JFrog Plugin for Codex](https://github.com/jfrog/codex-plugin#installation) - [Use the MCP Registry with Agent Guard](https://docs.jfrog.com/ai-ml/docs/configure-coding-agents) From 9a3ae40de10aca16fe565b99d7d4d27dbc6ba076 Mon Sep 17 00:00:00 2001 From: Roee Sanker Date: Wed, 16 Sep 2026 10:08:11 +0300 Subject: [PATCH 2/4] Remove premature Windows support docs from admin guide Windows support (jfrog-agent-hooks 365afa3) hasn't been released or synced to this plugin's vendored modules/ yet (still pinned to jfrog-agent-hooks/v0.12.1, which predates it). Documenting it now would promise behavior the shipped plugin doesn't have. Re-add once a hooks release including that commit is tagged and Sync Plugins bumps the pin. Co-Authored-By: Claude Sonnet 5 --- docs/package-resolution-admin-guide.md | 33 ++++---------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/docs/package-resolution-admin-guide.md b/docs/package-resolution-admin-guide.md index 33519eb..9c2c5ff 100644 --- a/docs/package-resolution-admin-guide.md +++ b/docs/package-resolution-admin-guide.md @@ -67,12 +67,13 @@ If `jf` is missing or has no usable configured server, the feature stays in **pe All Agent Package Resolution admin settings live in a single JSON file on the developer machine: -- macOS/Linux: `~/.jfrog/agents-conf.json` -- Windows: `%USERPROFILE%\.jfrog\agents-conf.json` +``` +~/.jfrog/agents-conf.json +``` | Property | Description | | --------------------- | -------------------------------------------------------------------------------- | -| **Scope** | Per user profile (`$HOME` or `%USERPROFILE%`) | +| **Scope** | Per user profile (`$HOME`) | | **Written by** | Administrators (MDM, golden image, manual edit) or auto-created on first session | | **Read by** | JFrog plugin session hooks on every agent session start | | **Never overwritten** | If the file already exists, the plugin does not replace it | @@ -97,32 +98,6 @@ This lets organizations **pre-deploy** their own `agents-conf.json` (via MDM, An Per-type durable declines live in `~/.jfrog/skills-cache/apr-onboarding-v1.json` (not in `agents-conf.json`). -Throughout this guide, `~/.jfrog/...` means the current user-profile `.jfrog` -directory. On Windows, substitute `%USERPROFILE%\.jfrog\...`; the JSON schema -and filenames are identical on every platform. - -### Windows verification (PowerShell) - -Confirm that the native executables and profile config are visible to the same -Windows user that launches the IDE: - -```powershell -Get-Command node.exe -Get-Command jf.exe -jf.exe --version -jf.exe config show -Test-Path "$env:USERPROFILE\.jfrog\agents-conf.json" -``` - -The resolver cache is -`%USERPROFILE%\.jfrog\skills-cache\package-resolution.json`, the eager-setup -receipt is -`%USERPROFILE%\.jfrog\skills-cache\package-setup-v2.json`, and hook logs are -written to `%USERPROFILE%\.jfrog\logs\agent-hooks.log`. After installing or -changing a hook, use `Ctrl+Shift+P` → **Developer: Reload Window** in Cursor, -start a new Claude Code or VS Code Copilot session, or restart Codex and -re-trust `/hooks` if the SessionStart command changed. - ### Consent Enable (developer chat flow) When the nudge fires, the agent walks the developer through enabling APR **in chat** (no hand-editing JSON): From 3a5e2132932b9ca58f31c216ce32e9a69276124c Mon Sep 17 00:00:00 2001 From: Roee Sanker Date: Wed, 16 Sep 2026 12:00:25 +0300 Subject: [PATCH 3/4] Fix durable-off contradiction in admin guide setup summary Mirrors the same fix in jfrog-agent-hooks PR #145: the setup-summary sentence said plain "enabled: false" keeps APR off, contradicting the At a glance bullet two lines later, which correctly says the default file re-enables itself. Co-Authored-By: Claude Sonnet 5 --- docs/package-resolution-admin-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/package-resolution-admin-guide.md b/docs/package-resolution-admin-guide.md index 9c2c5ff..9ce651d 100644 --- a/docs/package-resolution-admin-guide.md +++ b/docs/package-resolution-admin-guide.md @@ -34,7 +34,7 @@ After `codex plugin add jfrog@codex-plugin`: The hook command uses `${PLUGIN_ROOT}` (Codex also sets `CLAUDE_PLUGIN_ROOT` for compatibility). Local `make install-codex` from `jfrog-agent-hooks` writes a different command into `~/.codex/hooks.json`; that trust hash does **not** cover the plugin definition. Uninstall the local hook before smoke-testing the plugin so you are not approving two SessionStart entries. -The shipped template turns Agent Package Resolution **on** (`enabled: true`) with empty `defaultGlobalRepos`. Nothing is routed until Consent Enable or an administrator adds bindings. Set `enabled: false` or `JF_AGENT_PACKAGE_RESOLUTION_DISABLE=1` to keep it off. +The shipped template turns Agent Package Resolution **on** (`enabled: true`) with empty `defaultGlobalRepos`. Nothing is routed until Consent Enable or an administrator adds bindings. `JF_AGENT_PACKAGE_RESOLUTION_DISABLE=1` always keeps it off; `enabled: false` alone only keeps it off if you deploy your own `agents-conf.json` — on the plugin's auto-created default file it is not durable (see below). **At a glance:** From 84172923e2d1db92168898ccb8236b3ac473bdd6 Mon Sep 17 00:00:00 2001 From: "jfrog-skills-release-bot[bot]" <276080306+jfrog-skills-release-bot[bot]@users.noreply.github.com> Date: Wed, 16 Sep 2026 11:42:02 +0000 Subject: [PATCH 4/4] [patch] chore: sync modules to v0.12.2 --- .codex-plugin/plugin.json | 2 +- .github/scripts/sync-modules-vendor.json | 2 +- modules/core/agent-guard-check.mjs | 11 +++- modules/core/jf-identity.mjs | 4 +- modules/core/jf-process.mjs | 50 +++++++++++++++++++ modules/core/jf-user-agent.mjs | 6 +-- modules/core/rewrite-mcp-json.mjs | 6 ++- .../scripts/apr-heartbeat.mjs | 10 +++- .../scripts/eager-setup.mjs | 11 ++-- .../package-resolution-unconfigured.md | 4 +- package.json | 2 +- 11 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 modules/core/jf-process.mjs diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index da116fe..e791016 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jfrog", - "version": "0.1.10", + "version": "0.1.11", "description": "JFrog skills and the JFrog MCP server for Codex \u2014 interact with the JFrog Platform.", "author": { "name": "JFrog", diff --git a/.github/scripts/sync-modules-vendor.json b/.github/scripts/sync-modules-vendor.json index 2af5584..42f4bad 100644 --- a/.github/scripts/sync-modules-vendor.json +++ b/.github/scripts/sync-modules-vendor.json @@ -1,6 +1,6 @@ { "repo": "JFROG/jfrog-agent-hooks", - "pin": "jfrog-agent-hooks/v0.12.1", + "pin": "jfrog-agent-hooks/v0.12.2", "paths": [ "modules" ] diff --git a/modules/core/agent-guard-check.mjs b/modules/core/agent-guard-check.mjs index e12a511..3284ed4 100644 --- a/modules/core/agent-guard-check.mjs +++ b/modules/core/agent-guard-check.mjs @@ -17,6 +17,7 @@ import { execFileSync } from "node:child_process"; import process from "node:process"; import { isMainEntry } from "./entry.mjs"; +import { jfInvocation } from "./jf-process.mjs"; import { skillsProductUserAgent } from "./jf-user-agent.mjs"; export const SETTINGS_PATH = @@ -88,6 +89,7 @@ export function resolveAgentGuardCredentials(opts = {}) { if (explicitServerId) { const fromCli = resolveFromCliConfig({ serverId: explicitServerId, + env, execFileSyncFn: execFn, debug, }); @@ -114,6 +116,7 @@ export function resolveAgentGuardCredentials(opts = {}) { if (explicitServerId) return null; return resolveFromCliConfig({ serverId: undefined, + env, execFileSyncFn: execFn, debug, }); @@ -122,22 +125,28 @@ export function resolveAgentGuardCredentials(opts = {}) { /** * @param {{ * serverId?: string, + * env?: NodeJS.ProcessEnv, * execFileSyncFn?: typeof execFileSync, * debug?: (message: string) => void, * }} opts */ function resolveFromCliConfig(opts) { const debug = opts.debug ?? (() => {}); + const env = opts.env ?? process.env; const execFn = opts.execFileSyncFn ?? execFileSync; const exportArgs = opts.serverId ? ["config", "export", opts.serverId] : ["config", "export"]; + const invocation = jfInvocation(exportArgs, { env }); let exported; try { - exported = execFn("jf", exportArgs, { + exported = execFn(invocation.command, invocation.args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 2000, + windowsHide: true, + shell: false, + env, }).trim(); } catch (error) { debug( diff --git a/modules/core/jf-identity.mjs b/modules/core/jf-identity.mjs index 6e2413b..57a7cb8 100644 --- a/modules/core/jf-identity.mjs +++ b/modules/core/jf-identity.mjs @@ -20,10 +20,10 @@ // async. import { createHash } from "node:crypto"; -import { spawnSync } from "node:child_process"; import process from "node:process"; import { createLogger } from "./logger.mjs"; +import { spawnJfSync } from "./jf-process.mjs"; import { skillsProductUserAgent } from "./jf-user-agent.mjs"; const log = createLogger("jf-identity"); @@ -82,7 +82,7 @@ function jfConfigIdentity(serverId) { let result; try { - result = spawnSync("jf", args, { + result = spawnJfSync(args, { encoding: "utf8", timeout: 2000, stdio: ["ignore", "pipe", "pipe"], diff --git a/modules/core/jf-process.mjs b/modules/core/jf-process.mjs new file mode 100644 index 0000000..8aca9e7 --- /dev/null +++ b/modules/core/jf-process.mjs @@ -0,0 +1,50 @@ +// Shell-free JFrog CLI process boundary shared by coding-agent hooks. +// +// Production invokes the native CLI directly (`jf.exe` on Windows, `jf` +// elsewhere). Tests may substitute the Node fake only when the explicit test +// harness gate is active; normal production environments ignore the driver. + +import { spawnSync } from "node:child_process"; +import process from "node:process"; + +/** + * Resolve the shell-free executable and argv for a JFrog CLI invocation. + * @param {string[]} args + * @param {{ env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform }} [options] + * @returns {{ command: string, args: string[] }} + */ +export function jfInvocation( + args, + { env = process.env, platform = process.platform } = {}, +) { + const testDriver = + env.JFROG_TEST_HARNESS === "1" ? env.JFROG_TEST_JF_DRIVER : undefined; + return testDriver + ? { command: process.execPath, args: [testDriver, ...args] } + : { command: platform === "win32" ? "jf.exe" : "jf", args }; +} + +/** + * Synchronously invoke the JFrog CLI without a shell. + * + * Test-only injection requires both: + * JFROG_TEST_HARNESS=1 + * JFROG_TEST_JF_DRIVER=/absolute/path/to/fake-jf.mjs + * + * @param {string[]} args + * @param {import("node:child_process").SpawnSyncOptionsWithStringEncoding} [options] + * @returns {import("node:child_process").SpawnSyncReturns} + */ +export function spawnJfSync(args, options = {}) { + const env = options.env ?? process.env; + const spawnSyncFn = options.spawnSyncFn ?? spawnSync; + const rest = { ...options }; + delete rest.spawnSyncFn; + const invocation = jfInvocation(args, { env }); + return spawnSyncFn(invocation.command, invocation.args, { + windowsHide: true, + shell: false, + ...rest, + env, + }); +} diff --git a/modules/core/jf-user-agent.mjs b/modules/core/jf-user-agent.mjs index 31367c9..d28c17c 100644 --- a/modules/core/jf-user-agent.mjs +++ b/modules/core/jf-user-agent.mjs @@ -15,12 +15,12 @@ // Spawn env is inherited so CLI DetectExecutionContext can append // ai-agent/ / ai-client/ / ai-model/ when those signals exist at jf start. -import { spawnSync } from "node:child_process"; +import { spawnJfSync } from "./jf-process.mjs"; // Plugin sync stamps this literal with the release semver (jfrog-sync-modules.py // stamp). Only `modules/` is vendored, so nothing outside this tree is readable // at runtime. Unstamped trees (this repo, local dev) report 0.0.0. -const PKG_VERSION = "0.12.1"; +const PKG_VERSION = "0.12.2"; /** Product UA for plugin `fetch()` (no trigger, no jfrog-cli-go). */ export function skillsProductUserAgent() { @@ -55,7 +55,7 @@ function resolveCliVersion(env = process.env) { try { // Keep process PATH/HOME even when callers pass a sparse env object // (unit tests often pass only UA-related keys). - const res = spawnSync("jf", ["--version"], { + const res = spawnJfSync(["--version"], { encoding: "utf8", timeout: 3000, env: { ...process.env, ...env }, diff --git a/modules/core/rewrite-mcp-json.mjs b/modules/core/rewrite-mcp-json.mjs index 8adcc47..3449b22 100644 --- a/modules/core/rewrite-mcp-json.mjs +++ b/modules/core/rewrite-mcp-json.mjs @@ -27,6 +27,7 @@ import path from "node:path"; import process from "node:process"; import { EXIT_ENABLED, runAgentGuardCheck } from "./agent-guard-check.mjs"; +import { jfInvocation } from "./jf-process.mjs"; import { createLogger } from "./logger.mjs"; const log = createLogger("rewrite-mcp-json"); @@ -285,13 +286,16 @@ export function pickDefaultJfCliServer(servers) { export function listJfCliServers(opts = {}) { const env = opts.env ?? process.env; const spawnSyncFn = opts.spawnSyncFn ?? spawnSync; + const invocation = jfInvocation(["config", "show", "--format=json"], { env }); let res; try { - res = spawnSyncFn("jf", ["config", "show", "--format=json"], { + res = spawnSyncFn(invocation.command, invocation.args, { encoding: "utf8", timeout: 5_000, env, stdio: ["ignore", "pipe", "pipe"], + windowsHide: true, + shell: false, }); } catch { return []; diff --git a/modules/package-resolution/scripts/apr-heartbeat.mjs b/modules/package-resolution/scripts/apr-heartbeat.mjs index 096f58f..f88926a 100644 --- a/modules/package-resolution/scripts/apr-heartbeat.mjs +++ b/modules/package-resolution/scripts/apr-heartbeat.mjs @@ -22,6 +22,7 @@ import path from "node:path"; import { createLogger } from "../../core/logger.mjs"; import { getPlatformIdentity } from "../../core/jf-identity.mjs"; import { envWithHookUserAgent } from "../../core/jf-user-agent.mjs"; +import { jfInvocation } from "../../core/jf-process.mjs"; const log = createLogger("apr-heartbeat"); @@ -183,12 +184,16 @@ export function tryAcquireHeartbeatLock(serverId, opts = {}) { * Detached `jf rt ping --server-id ` with hook User-Agent. * Waits for spawn success vs async error before unref. * @param {string} serverId - * @param {{ spawn?: typeof spawn, env?: NodeJS.ProcessEnv }} [opts] + * @param {{ spawn?: typeof spawn, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform }} [opts] * @returns {Promise} true if the process started */ export function spawnHeartbeatPing(serverId, opts = {}) { const spawnImpl = opts.spawn ?? spawn; const env = opts.env ?? process.env; + const invocation = jfInvocation(["rt", "ping", "--server-id", serverId], { + env, + platform: opts.platform, + }); return new Promise((resolve) => { let settled = false; const finish = (ok) => { @@ -198,8 +203,9 @@ export function spawnHeartbeatPing(serverId, opts = {}) { }; let child; try { - child = spawnImpl("jf", ["rt", "ping", "--server-id", serverId], { + child = spawnImpl(invocation.command, invocation.args, { detached: true, + windowsHide: true, stdio: "ignore", env: envWithHookUserAgent(env), }); diff --git a/modules/package-resolution/scripts/eager-setup.mjs b/modules/package-resolution/scripts/eager-setup.mjs index 40874c1..8d2f501 100644 --- a/modules/package-resolution/scripts/eager-setup.mjs +++ b/modules/package-resolution/scripts/eager-setup.mjs @@ -59,6 +59,8 @@ import { packageManagerBinaryOnPath, } from "./package-manager-family.mjs"; import { detectSetupConflict } from "./setup-conflict.mjs"; +import { isMainEntry } from "../../core/entry.mjs"; +import { spawnJfSync } from "../../core/jf-process.mjs"; import { envWithHookUserAgent } from "../../core/jf-user-agent.mjs"; const log = createLogger("eager-setup"); @@ -247,6 +249,7 @@ function spawnWorker(payloadB64, jobCount = 1) { if (process.env.JFROG_EAGER_SETUP_SYNC === "1") { spawnSync(process.execPath, [workerPath(), "--run", payloadB64], { stdio: "ignore", + windowsHide: true, env: process.env, timeout: syncWorkerTimeoutMs(jobCount), }); @@ -255,6 +258,7 @@ function spawnWorker(payloadB64, jobCount = 1) { try { const child = spawn(process.execPath, [workerPath(), "--run", payloadB64], { detached: true, + windowsHide: true, stdio: "ignore", env: process.env, }); @@ -643,7 +647,7 @@ export function releaseLock() { function supportedPackageManagers() { try { // --help is local (no Artifactory traffic); no UA needed for telemetry. - const res = spawnSync("jf", ["setup", "--help"], { + const res = spawnJfSync(["setup", "--help"], { encoding: "utf8", timeout: 5000, env: process.env, @@ -701,7 +705,7 @@ function runJfSetup(packageManager, serverId, repoKey) { "--repo", repoKey, ]; - const res = spawnSync("jf", args, { + const res = spawnJfSync(args, { encoding: "utf8", timeout: PER_PACKAGE_MANAGER_TIMEOUT_MS, env: envWithHookUserAgent(process.env), @@ -838,8 +842,7 @@ export async function runWorker(payload) { // CLI entry (worker mode) // --------------------------------------------------------------------------- -const isMain = import.meta.url === `file://${process.argv[1]}`; -if (isMain && process.argv[2] === "--run") { +if (isMainEntry(import.meta.url) && process.argv[2] === "--run") { const b64 = process.argv[3]; try { const payload = JSON.parse(Buffer.from(b64, "base64").toString("utf8")); diff --git a/modules/package-resolution/templates/package-resolution-unconfigured.md b/modules/package-resolution/templates/package-resolution-unconfigured.md index 83ddf57..8806ba3 100644 --- a/modules/package-resolution/templates/package-resolution-unconfigured.md +++ b/modules/package-resolution/templates/package-resolution-unconfigured.md @@ -27,9 +27,9 @@ Do not delegate governed installs to `agent -p` or another child while routing i ## After setup — load the routing policy Once `jf` is configured and `jfrog-setup-package-managers` has bound package -managers, load the current routing policy: +managers, load the current routing policy. Run this command: -```bash +```text {{REFRESH_COMMAND}} ``` diff --git a/package.json b/package.json index 91a1950..dcf83d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codex-plugin", - "version": "0.1.10", + "version": "0.1.11", "private": true, "type": "module", "description": "JFrog skills and MCP server plugin for OpenAI Codex.",