MCPcopy Create free account
hub / github.com/arktypeio/arktype / resolveWindowsAgentCandidates

Function resolveWindowsAgentCandidates

ark/type/cli.ts:655–691  ·  view source on GitHub ↗
(
	cmd: string,
	env: NodeJS.ProcessEnv = process.env,
	nodeExecPath = process.execPath
)

Source from the content-addressed store, hash-verified

653}
654
655export const resolveWindowsAgentCandidates = (
656 cmd: string,
657 env: NodeJS.ProcessEnv = process.env,
658 nodeExecPath = process.execPath
659): AgentCommand[] => {
660 const rawPathExt = (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD")
661 .split(";")
662 .map(ext => ext.trim().toLowerCase())
663 .filter(ext => winRunnableExts.has(ext))
664 const exts = rawPathExt.length ? rawPathExt : [".exe", ".com", ".cmd", ".bat"]
665 const lowerCmd = cmd.toLowerCase()
666 const hasExt = [...winRunnableExts].some(ext => lowerCmd.endsWith(ext))
667 const paths: string[] = []
668 if (cmd.includes("/") || cmd.includes("\\")) {
669 const base = resolve(cmd)
670 if (hasExt) paths.push(base)
671 else for (const ext of exts) paths.push(`${base}${ext}`)
672 } else {
673 const pathEntries = (env.PATH ?? env.Path ?? "")
674 .split(";")
675 .map(entry => entry.trim().replace(/^"(.*)"$/, "$1"))
676 .filter(Boolean)
677 for (const dir of pathEntries) {
678 if (hasExt) paths.push(join(dir, cmd))
679 else for (const ext of exts) paths.push(join(dir, `${cmd}${ext}`))
680 }
681 }
682 const commands: AgentCommand[] = []
683 for (const candidate of paths) {
684 if (!statSync(candidate, { throwIfNoEntry: false })?.isFile()) continue
685 if (/\.(?:cmd|bat)$/i.test(candidate)) {
686 const unwrapped = unwrapWindowsCmdShim(candidate, nodeExecPath)
687 if (unwrapped) commands.push(unwrapped)
688 } else commands.push({ command: candidate, args: [] })
689 }
690 return commands
691}
692
693const findAgentBinary = (preferred?: string): AgentCommand | undefined => {
694 const candidates = preferred ? [preferred] : ["claude", "codex"]

Callers 2

cli.test.tsFile · 0.90
findAgentBinaryFunction · 0.85

Calls 9

joinFunction · 0.85
unwrapWindowsCmdShimFunction · 0.85
filterMethod · 0.80
replaceMethod · 0.80
testMethod · 0.80
resolveFunction · 0.70
mapMethod · 0.65
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected