@commonlyai/cli 0.1.242 → 0.1.244

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.242",
3
+ "version": "0.1.244",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -60,6 +60,7 @@ import { detectMemorySources, composeImport, importMemory } from '../lib/memory-
60
60
  import { detectSkills, importSkills, parseSkillMeta } from '../lib/skills-import.js';
61
61
  import { compileServerSkills } from '../lib/server-skills.js';
62
62
  import {
63
+ effectiveSandboxTrust,
63
64
  environmentForServer,
64
65
  normalizeSandboxTrust,
65
66
  parseEnvironmentFile,
@@ -2200,6 +2201,12 @@ export const performRun = ({
2200
2201
  // The adapter also denies the memory tools for it (memoryWithheld).
2201
2202
  const memoryWithheld = Boolean(placement.reason);
2202
2203
  const memoryLongTerm = memoryWithheld ? undefined : await readLongTerm(client, { onError });
2204
+ // F118: a public seat reads its memory but never writes it. Its summary is
2205
+ // its own output, which a stranger in the pod can steer, so the wrapper does
2206
+ // not sync it back; the adapters withhold the memory-write tools the same
2207
+ // way. A workspace seat's public turn is covered by memoryWithheld too.
2208
+ const memoryWriteWithheld = memoryWithheld
2209
+ || effectiveSandboxTrust(placement.environment?.sandbox?.trust) === 'public';
2203
2210
 
2204
2211
  // TASK-129: focus is a turn-start read, not an enqueue-time
2205
2212
  // snapshot. Read through the authorized runtime context route immediately
@@ -2675,7 +2682,7 @@ export const performRun = ({
2675
2682
  }
2676
2683
  }
2677
2684
  turn.finish(turnOutcome);
2678
- if (result.memorySummary && !memoryWithheld) {
2685
+ if (result.memorySummary && !memoryWriteWithheld) {
2679
2686
  try {
2680
2687
  await syncBack(client, { summary: result.memorySummary });
2681
2688
  log(`[${event.type}] memory synced (${Buffer.byteLength(result.memorySummary)} bytes)`);
@@ -101,7 +101,7 @@ import { BACKGROUND_PROCESS_CUE, buildMemoryPreamble, ROW_SLICING_CUE } from '..
101
101
  import { claudeConfigDirFor, claudeContextTokens, claudeTranscriptPath } from '../session-recycle.js';
102
102
  import { skillsAsText } from '../skill-prompt.js';
103
103
  import { adapterFailure, redactKnownCredentials, spawnCredentials } from '../upstream-refusal.js';
104
- import { PUBLIC_WITHHELD_TOOLS } from '../public-withheld-tools.js';
104
+ import { PUBLIC_ONLY_WITHHELD_TOOLS, PUBLIC_WITHHELD_TOOLS } from '../public-withheld-tools.js';
105
105
  import { isShippedCommonlyMcpCommand } from '../declared-mcp-guard.js';
106
106
  import { isAnswerableToolError, PUBLIC_MCP_NOT_READY_CODE, PUBLIC_TOOL_FAILED_CODE } from '../public-tool-error.js';
107
107
  import { resolveLaunch, resolveMcpCommand, resolveWindowsCommandWithReason } from '../windows-command.js';
@@ -596,9 +596,17 @@ const buildPublicClaudePolicyArgs = (mcpToolPatterns, {
596
596
  ? MEMORY_TOOLS.flatMap((tool) => mcpToolPatterns.map((pattern) => pattern.replace(/\*$/, tool)))
597
597
  : [];
598
598
  // Nor, on any confined trust, the tools no public seat is offered
599
- // (public-withheld-tools.js).
600
- const withheldDenies = PUBLIC_WITHHELD_TOOLS
599
+ // (public-withheld-tools.js). A public seat also loses self-install and every
600
+ // memory write (F118). Only a workspace seat is called with its trust at
601
+ // every call site; the public ones pass none, so "not workspace" is public.
602
+ const withheldTools = trust === 'workspace'
603
+ ? PUBLIC_WITHHELD_TOOLS
604
+ : [...PUBLIC_WITHHELD_TOOLS, ...PUBLIC_ONLY_WITHHELD_TOOLS];
605
+ const withheldDenies = withheldTools
601
606
  .flatMap((tool) => mcpToolPatterns.map((pattern) => pattern.replace(/\*$/, tool)));
607
+ // A tool can be denied for two reasons (a withheld turn's memory write is
608
+ // also a public seat's); each deny is written once.
609
+ const toolDenies = [...new Set([...workspaceDenies, ...memoryDenies, ...withheldDenies])];
602
610
  return [
603
611
  // HOME points at an isolated, sanitized state directory. Ignore settings
604
612
  // from user/project/local sources and disable slash-command extensions;
@@ -610,7 +618,7 @@ const buildPublicClaudePolicyArgs = (mcpToolPatterns, {
610
618
  '--permission-mode', 'dontAsk',
611
619
  '--allowedTools', 'Read(./**)', ...granted, ...mcpToolPatterns,
612
620
  '--disallowedTools', ...PUBLIC_DENIED_TOOLS.filter((tool) => !granted.some((g) => g === tool || g.startsWith(`${tool}(`))),
613
- ...deniedReads, ...workspaceDenies, ...memoryDenies, ...withheldDenies,
621
+ ...deniedReads, ...toolDenies,
614
622
  ];
615
623
  };
616
624
 
@@ -1501,10 +1509,13 @@ export default {
1501
1509
  // there is a signal, not a leak.
1502
1510
  const witnessedMcp = ctx.environment?.sandbox?.trust === 'public' ? ctx.environment?.mcp : null;
1503
1511
  const workCues = publicTrust ? [] : WORK_CUES;
1512
+ // F118: a public seat reads its memory but is not offered a write.
1513
+ const memoryReadOnly = ctx.environment?.sandbox?.trust === 'public';
1504
1514
  const fullPrompt = buildPrompt(prompt, ctx.memoryLongTerm, {
1505
1515
  freshSession: !isResume,
1506
1516
  workCues,
1507
1517
  memoryWithheld: ctx.memoryWithheld === true,
1518
+ memoryReadOnly,
1508
1519
  });
1509
1520
  const sessionFlag = isResume ? '--resume' : '--session-id';
1510
1521
  // Model pin from the ADR-008 environment spec. Absent it, claude picks its
@@ -1729,6 +1740,7 @@ export default {
1729
1740
  freshSession: true,
1730
1741
  workCues,
1731
1742
  memoryWithheld: ctx.memoryWithheld === true,
1743
+ memoryReadOnly,
1732
1744
  });
1733
1745
  const retryBase = ['-p', freshPrompt,
1734
1746
  ...STREAM_ARGS, '--session-id', freshId, ...modelArgs];
@@ -78,7 +78,7 @@ import { BACKGROUND_PROCESS_CUE, buildMemoryPreamble, ROW_SLICING_CUE } from '..
78
78
  import { resolveSkillSource, skillsAsText } from '../skill-prompt.js';
79
79
  import { isLegacySandboxTrust, normalizeSandboxTrust, refuseWorkspaceTrust } from '../environment.js';
80
80
  import { adapterFailure, spawnCredentials } from '../upstream-refusal.js';
81
- import { PUBLIC_WITHHELD_TOOLS } from '../public-withheld-tools.js';
81
+ import { PUBLIC_SEAT_WITHHELD_TOOLS } from '../public-withheld-tools.js';
82
82
  import { resolveLaunch, resolveMcpCommand, resolveWindowsCommandWithReason } from '../windows-command.js';
83
83
 
84
84
  // Default timeout for a single codex spawn (exec mode).
@@ -227,9 +227,10 @@ const buildMcpOverrideArgs = (mcpServers, ctx = {}) => {
227
227
  '-c',
228
228
  `mcp_servers.${server.name}.default_tools_approval_mode="approve"`,
229
229
  );
230
- // ...except the tools no public seat is offered (public-withheld-tools.js).
230
+ // ...except the tools no public seat is offered (public-withheld-tools.js),
231
+ // self-install and the memory writes included (F118).
231
232
  if (ctx.publicSeat) {
232
- flags.push('-c', `mcp_servers.${server.name}.disabled_tools=[${PUBLIC_WITHHELD_TOOLS.map(toml).join(',')}]`);
233
+ flags.push('-c', `mcp_servers.${server.name}.disabled_tools=[${PUBLIC_SEAT_WITHHELD_TOOLS.map(toml).join(',')}]`);
233
234
  }
234
235
  if (rest.length) {
235
236
  flags.push('-c', `mcp_servers.${server.name}.args=[${rest.map(toml).join(',')}]`);
@@ -853,6 +854,8 @@ export default {
853
854
  const fullPrompt = buildPrompt(prompt, ctx.memoryLongTerm, {
854
855
  freshSession: !ctx.sessionId,
855
856
  workCues: sandbox?.trust === 'public' ? [] : [ROW_SLICING_CUE, BACKGROUND_PROCESS_CUE],
857
+ // F118: a public seat reads its memory but is not offered a write.
858
+ memoryReadOnly: sandbox?.trust === 'public',
856
859
  });
857
860
 
858
861
  // Per-spawn temp dir for --output-last-message. Cleaned up in `finally`
@@ -42,6 +42,8 @@ const templateLiteral = (value) => {
42
42
  // attach_file reads this process's filesystem, including its credential file.
43
43
  // catch_up is left out too: it moves the read cursor past history unread, so a
44
44
  // public seat past 50 unseen falls back to continueAnyway, which it keeps.
45
+ // Self-install and the memory writes (log_cycle included) are left out on every
46
+ // public seat (F118, PUBLIC_ONLY_WITHHELD_TOOLS); reading memory stays.
45
47
  export const PUBLIC_GOOSE_TOOLS = Object.freeze([
46
48
  'commonly_get_started', 'commonly_post_message', 'commonly_claim_message',
47
49
  'commonly_release_claim', 'commonly_get_messages', 'commonly_get_context',
@@ -49,8 +51,7 @@ export const PUBLIC_GOOSE_TOOLS = Object.freeze([
49
51
  'commonly_get_posts', 'commonly_post_thread_comment', 'commonly_get_tasks',
50
52
  'commonly_create_task', 'commonly_claim_task', 'commonly_watch_task',
51
53
  'commonly_complete_task', 'commonly_update_task', 'commonly_create_pod',
52
- 'commonly_list_pods', 'commonly_self_install_into_pod', 'commonly_read_agent_memory',
53
- 'commonly_write_agent_memory', 'commonly_save_my_memory', 'commonly_log_cycle',
54
+ 'commonly_list_pods', 'commonly_read_agent_memory',
54
55
  'commonly_dm_agent', 'commonly_ask_agent', 'commonly_request_decision',
55
56
  'commonly_respond_to_ask', 'commonly_react_to_message',
56
57
  ]);
@@ -324,7 +325,8 @@ export default {
324
325
  extensions: publicExtensions.map((extension) => ({ ...extension,
325
326
  envs: { ...extension.envs, OPENSSL_CONF: opensslConfig },
326
327
  })),
327
- prompt: buildMemoryPreamble(prompt, ctx.memoryLongTerm, { freshSession: true }),
328
+ // F118: a public seat reads its memory but is not offered a write.
329
+ prompt: buildMemoryPreamble(prompt, ctx.memoryLongTerm, { freshSession: true, memoryReadOnly: true }),
328
330
  })), { mode: 0o600 });
329
331
  const env = {
330
332
  ...safeEnv(sourceEnv),
@@ -59,7 +59,7 @@ import { resolveProviderKeyFile, startProviderProxy } from '../provider-proxy.js
59
59
  import { isShippedCommonlyMcpCommand } from '../declared-mcp-guard.js';
60
60
  import { isAnswerableToolError, PUBLIC_TOOL_FAILED_CODE } from '../public-tool-error.js';
61
61
  import { startInstanceProxy } from '../instance-proxy.js';
62
- import { PUBLIC_WITHHELD_TOOLS } from '../public-withheld-tools.js';
62
+ import { PUBLIC_SEAT_WITHHELD_TOOLS } from '../public-withheld-tools.js';
63
63
 
64
64
  const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
65
65
  const ISOLATED_PROXY_PORT = 8765;
@@ -249,8 +249,8 @@ const publicPermissions = (mode, mcpNames) => {
249
249
  lsp: 'allow',
250
250
  ...Object.fromEntries(mcpNames.map((name) => [`${permissionMcpName(name)}_*`, 'allow'])),
251
251
  // After the wildcard allow, since the last matching rule wins
252
- // (public-withheld-tools.js).
253
- ...Object.fromEntries(mcpNames.flatMap((name) => PUBLIC_WITHHELD_TOOLS
252
+ // (public-withheld-tools.js; self-install and memory writes, F118).
253
+ ...Object.fromEntries(mcpNames.flatMap((name) => PUBLIC_SEAT_WITHHELD_TOOLS
254
254
  .map((tool) => [`${permissionMcpName(name)}_${tool}`, 'deny']))),
255
255
  };
256
256
  };
@@ -749,6 +749,8 @@ export default {
749
749
 
750
750
  const fullPrompt = buildMemoryPreamble(prompt, ctx.memoryLongTerm, {
751
751
  freshSession: !ctx.sessionId,
752
+ // F118: a public seat reads its memory but is not offered a write.
753
+ memoryReadOnly: isPublic,
752
754
  });
753
755
  const tempDir = await mkdtemp(join(tmpdir(), 'commonly-opencode-'));
754
756
  await chmod(tempDir, 0o700);
@@ -16,7 +16,7 @@ import { detectBwrap, wrapArgvWithBwrap } from '../sandbox/bwrap.js';
16
16
  import { wrapArgvWithSeatbelt } from '../sandbox/seatbelt.js';
17
17
  import { resolveProviderKeyFile, startProviderProxy } from '../provider-proxy.js';
18
18
  import { adapterFailure, spawnCredentials } from '../upstream-refusal.js';
19
- import { PUBLIC_WITHHELD_TOOLS } from '../public-withheld-tools.js';
19
+ import { PUBLIC_SEAT_WITHHELD_TOOLS } from '../public-withheld-tools.js';
20
20
 
21
21
  // Add a version only with a passing real clean-box sandbox smoke that names it.
22
22
  const TESTED_QWEN_VERSIONS = Object.freeze(['0.25.1', '0.26.2']);
@@ -41,8 +41,8 @@ const EXCLUDED_TOOLS = [
41
41
  const PUBLIC_READ_TOOLS = [
42
42
  'read_file', 'grep_search', 'search_file_content', 'glob', 'list_directory', 'lsp',
43
43
  // Both spellings of a Commonly MCP tool, as with the aliases above
44
- // (public-withheld-tools.js).
45
- ...PUBLIC_WITHHELD_TOOLS.flatMap((tool) => [tool, `mcp__commonly__${tool}`]),
44
+ // (public-withheld-tools.js; self-install and memory writes, F118).
45
+ ...PUBLIC_SEAT_WITHHELD_TOOLS.flatMap((tool) => [tool, `mcp__commonly__${tool}`]),
46
46
  ];
47
47
 
48
48
  const parseVersion = (output) => {
@@ -315,6 +315,8 @@ export default {
315
315
  // be resumed. The kernel memory preamble supplies continuity instead.
316
316
  const fullPrompt = buildMemoryPreamble(prompt, ctx.memoryLongTerm, {
317
317
  freshSession: true,
318
+ // F118: a public seat reads its memory but is not offered a write.
319
+ memoryReadOnly: isPublic,
318
320
  });
319
321
  const args = [
320
322
  '--bare', '--safe-mode', '--auth-type', 'openai', '-m', seatModel,
@@ -35,6 +35,7 @@ import {
35
35
  readBinInPrefix, versionDirFor,
36
36
  } from './mcp-home.js';
37
37
  import { MCP_PACKAGE, exactVersion, parseVersion } from './mcp-server-version.js';
38
+ import { resolveLaunch } from './windows-command.js';
38
39
 
39
40
  export const PROBE_API_URL_PLACEHOLDER = 'http://127.0.0.1:1';
40
41
  export const PROBE_TOKEN_PLACEHOLDER = 'cm_agent_warm_probe';
@@ -106,8 +107,15 @@ export const acquireWarmLock = (home, {
106
107
  }
107
108
  };
108
109
 
109
- /** Default `npm` runner. Resolves `{ ok, stdout }`; never rejects. */
110
- export const runCommand = (bin, args, { timeout = REGISTRY_TIMEOUT_MS, cwd } = {}) => new Promise((resolve) => {
110
+ /**
111
+ * Default `npm` runner. Resolves `{ ok, stdout }`; never rejects. On Windows
112
+ * `npm` is npm.cmd, which Node cannot spawn without a shell, so the name goes
113
+ * through the resolver the adapters use (npm.cmd becomes node.exe npm-cli.js).
114
+ * Off Windows it is spawned as given. `resolution` is the resolver's test seam.
115
+ */
116
+ export const runCommand = (bin, args, {
117
+ timeout = REGISTRY_TIMEOUT_MS, cwd, resolution,
118
+ } = {}) => new Promise((resolve) => {
111
119
  let settled = false;
112
120
  let child;
113
121
  const done = (result) => {
@@ -116,7 +124,9 @@ export const runCommand = (bin, args, { timeout = REGISTRY_TIMEOUT_MS, cwd } = {
116
124
  resolve(result);
117
125
  };
118
126
  try {
119
- child = spawnChild(bin, args, { stdio: ['ignore', 'pipe', 'pipe'], env: process.env, cwd });
127
+ // The child runs in `cwd`, so a relative PATH entry is read there.
128
+ const launch = resolveLaunch(bin, args, { cwd, ...resolution });
129
+ child = spawnChild(launch.command, launch.args, { stdio: ['ignore', 'pipe', 'pipe'], env: process.env, cwd });
120
130
  } catch (error) {
121
131
  done({ ok: false, stdout: '', stderr: String(error && error.message) });
122
132
  return;
@@ -65,11 +65,15 @@ export const BACKGROUND_PROCESS_CUE = 'Background processes: anything you start
65
65
  * the memory cues and under the same once-per-session rule. An adapter passes
66
66
  * only the habits its CLI can act on; passing none leaves the preamble as it
67
67
  * was.
68
+ *
69
+ * `memoryReadOnly` is a public seat (F118): it reads its memory and is shown
70
+ * the long_term it read, but it is not offered the save tool, so no cue names
71
+ * one. `memoryWithheld` wins over it: that turn reads nothing either.
68
72
  */
69
73
  export const buildMemoryPreamble = (
70
74
  prompt,
71
75
  memoryLongTerm,
72
- { freshSession = false, workCues = [], memoryWithheld = false } = {},
76
+ { freshSession = false, workCues = [], memoryWithheld = false, memoryReadOnly = false } = {},
73
77
  ) => {
74
78
  // `null` is the UNREADABLE signal, and it is deliberately not the same value
75
79
  // as `''`. Telling a seat whose token was revoked that "nothing has ever been
@@ -91,6 +95,11 @@ export const buildMemoryPreamble = (
91
95
  + `state you may already hold.)`;
92
96
  } else if (memoryLongTerm) {
93
97
  context = `=== Context (your persistent memory) ===\n${memoryLongTerm}`;
98
+ } else if (memoryReadOnly) {
99
+ // F118: a public seat is not offered the save tool, so the cue that
100
+ // teaches it would name a tool the seat cannot call.
101
+ context = `=== Context (your persistent memory) ===\n`
102
+ + `(empty — nothing has ever been saved here)`;
94
103
  } else {
95
104
  context = `=== Context (your persistent memory) ===\n`
96
105
  + `(empty — nothing has ever been saved here)\n`
@@ -114,6 +123,8 @@ export const buildMemoryPreamble = (
114
123
  let sessionEndCue = '=== Before this session ends ===\n';
115
124
  if (memoryWithheld) {
116
125
  sessionEndCue += 'Memory is withheld this turn, so there is nothing to save.';
126
+ } else if (memoryReadOnly) {
127
+ sessionEndCue += 'Memory is read-only on this public seat, so there is nothing to save.';
117
128
  } else if (memoryLongTerm === null) {
118
129
  sessionEndCue += 'Memory was unreadable on this fresh session. Do not treat it as empty or '
119
130
  + 'write a replacement based on this cue.';
@@ -5,3 +5,25 @@
5
5
  // commonly_catch_up moves the read cursor past history unread; a wrapper seat
6
6
  // already catches up before each turn, so no seat on this list needs the tool.
7
7
  export const PUBLIC_WITHHELD_TOOLS = Object.freeze(['commonly_attach_file', 'commonly_catch_up']);
8
+
9
+ // F118 (Cofounder ruling, 11-04): public agents start from nothing and earn
10
+ // capabilities. A public seat answers strangers, so an injected message must
11
+ // not be able to spread the agent into other pods or rewrite its memory.
12
+ // Withheld on public trust only: a Claude workspace seat keeps its memory
13
+ // writes, and denies self-install itself (claude.js, workspaceDenies).
14
+ // commonly_log_cycle is a memory write too: it appends to the agent's
15
+ // `cycles[]` through POST /api/agents/runtime/memory/sync. Reading memory
16
+ // (commonly_read_agent_memory, and the long_term the wrapper puts in the
17
+ // prompt) stays offered.
18
+ export const PUBLIC_ONLY_WITHHELD_TOOLS = Object.freeze([
19
+ 'commonly_self_install_into_pod',
20
+ 'commonly_write_agent_memory',
21
+ 'commonly_save_my_memory',
22
+ 'commonly_log_cycle',
23
+ ]);
24
+
25
+ // Everything a public seat is not offered. Codex, OpenCode, Qwen and Goose
26
+ // confine on public trust only, so this is the whole list for them.
27
+ export const PUBLIC_SEAT_WITHHELD_TOOLS = Object.freeze([
28
+ ...PUBLIC_WITHHELD_TOOLS, ...PUBLIC_ONLY_WITHHELD_TOOLS,
29
+ ]);
@@ -42,7 +42,10 @@ const extOf = (file) => win32.extname(file).toLowerCase();
42
42
  // not: `{ ...process.env, PATH }` can carry both `Path` and `PATH`. Read
43
43
  // `Path` first (the casing Windows itself uses), then `PATH`, then any other
44
44
  // casing, and drop duplicates.
45
- const pathEntries = (env = {}) => {
45
+ // A relative entry (`.`, `bin`) names a folder relative to the working
46
+ // directory the child is spawned in, as Windows reads it there. Given `cwd`,
47
+ // it is resolved against that, never against this process's own directory.
48
+ const pathEntries = (env = {}, cwd) => {
46
49
  const keys = Object.keys(env).filter((key) => key.toLowerCase() === 'path');
47
50
  const rank = (key) => (key === 'Path' ? 0 : key === 'PATH' ? 1 : 2);
48
51
  keys.sort((a, b) => rank(a) - rank(b));
@@ -50,7 +53,8 @@ const pathEntries = (env = {}) => {
50
53
  const entries = [];
51
54
  for (const key of keys) {
52
55
  for (const raw of String(env[key] || '').split(';')) {
53
- const dir = raw.trim().replace(/^"(.*)"$/, '$1');
56
+ const entry = raw.trim().replace(/^"(.*)"$/, '$1');
57
+ const dir = entry && cwd && !win32.isAbsolute(entry) ? win32.resolve(cwd, entry) : entry;
54
58
  if (!dir || seen.has(dir.toLowerCase())) continue;
55
59
  seen.add(dir.toLowerCase());
56
60
  entries.push(dir);
@@ -251,6 +255,8 @@ const classify = (file, deps) => {
251
255
  * Resolve `name` to something spawnable without a shell, with the reason when
252
256
  * it cannot be. On anything but win32, `{ command: name, args: [] }`.
253
257
  * On win32, `source` is the file found on PATH (the shim, or the .exe).
258
+ * `cwd` is the child's working directory; relative PATH entries are read
259
+ * against it (unset: this process's, as before).
254
260
  *
255
261
  * @returns {{ command: string, args: string[], source?: string }
256
262
  * | { command: null, reason: string, source?: string }}
@@ -261,6 +267,7 @@ export const resolveWindowsCommandWithReason = (name, {
261
267
  existsSync = realExistsSync,
262
268
  readFileSync = realReadFileSync,
263
269
  execPath = process.execPath,
270
+ cwd,
264
271
  } = {}) => {
265
272
  if (platform !== 'win32') return { command: name, args: [] };
266
273
  const deps = { existsSync, readFileSync, execPath, env };
@@ -290,7 +297,7 @@ export const resolveWindowsCommandWithReason = (name, {
290
297
  // (a `.vbs`, a `.js`, a `.ps1` someone added to PATHEXT), the answer is a
291
298
  // refusal, never a later match, which would be a different program from the
292
299
  // one the person runs by typing the name.
293
- for (const dir of pathEntries(env)) {
300
+ for (const dir of pathEntries(env, cwd)) {
294
301
  for (const candidate of candidatesFor(win32.join(dir, name))) {
295
302
  if (!existsSync(candidate)) continue;
296
303
  return classify(candidate, deps) || {