6. $\frac{\sqrt{14}}{4}$.

Let $\frac{z-1}{z+1}=t \mathrm{i}, t \in \mathbf{R}, t \neq 0$, then $z=\frac{1+t \mathrm{i}}{1-t \mathrm{i}}$, thus $|z|=1, z \neq \pm 1$.
Let $z=\cos \theta+\mathrm{i} \sin \theta$, then
$$
\begin{aligned}
\left|z^{2}-z+2\right| & =|z(z-1+2 \bar{z})|=|z+2 \bar{z}-1| \\
& =|3 \cos \theta-1-\mathrm{i} \sin \theta|=\sqrt{8\left(\cos \theta-\frac{3}{8}\right)^{2}+\frac{7}{8}}
\end{aligned}
$$

Thus, when $\cos \theta=\frac{3}{8}$, $\left|z^{2}-z+2\right|$ reaches its minimum value $\frac{\sqrt{14}}{4}$.
6. If $\frac{z-1}{z+1}(z \in \mathbf{C})$ is a pure imaginary number, then the minimum value of $\left|z^{2}-z+2\right|$ is