If $f(x)=\cos(x)-1+\frac{x^2}2$, then
$\textbf{(A)}~f(x)\text{ is an increasing function on the real line}$
$\textbf{(B)}~f(x)\text{ is a decreasing function on the real line}$
$\textbf{(C)}~f(x)\text{ is increasing on }-\infty<x\le0\text{ and decreasing on }0\le x<\infty$
$\textbf{(D)}~f(x)\text{ is decreasing on }-\infty<x\le0\text{ and increasing on }0\le x<\infty$

To determine the behavior of the function \( f(x) = \cos(x) - 1 + \frac{x^2}{2} \), we need to analyze its first derivative \( f'(x) \).

1. **Compute the first derivative \( f'(x) \):**
   \[
   f(x) = \cos(x) - 1 + \frac{x^2}{2}
   \]
   Using the sum rule and the derivatives of the individual terms:
   \[
   f'(x) = \frac{d}{dx}[\cos(x)] + \frac{d}{dx}\left[-1\right] + \frac{d}{dx}\left[\frac{x^2}{2}\right]
   \]
   \[
   f'(x) = -\sin(x) + 0 + x
   \]
   Therefore,
   \[
   f'(x) = x - \sin(x)
   \]

2. **Analyze the sign of \( f'(x) \):**
   To determine where \( f(x) \) is increasing or decreasing, we need to find where \( f'(x) \) is positive or negative.

   - For \( x < 0 \):
     \[
     f'(x) = x - \sin(x)
     \]
     Since \( \sin(x) \) is negative for \( x < 0 \), \( -\sin(x) \) is positive. Therefore, \( x - \sin(x) \) is negative because \( x \) is negative and \( -\sin(x) \) is positive but less than \( |x| \). Hence, \( f'(x) < 0 \) for \( x < 0 \).

   - For \( x > 0 \):
     \[
     f'(x) = x - \sin(x)
     \]
     Since \( \sin(x) \) is positive for \( x > 0 \), \( x - \sin(x) \) is positive because \( x \) is positive and \( \sin(x) \) is less than \( x \). Hence, \( f'(x) > 0 \) for \( x > 0 \).

3. **Determine the behavior at \( x = 0 \):**
   \[
   f'(0) = 0 - \sin(0) = 0
   \]
   At \( x = 0 \), the derivative is zero, indicating a potential critical point. However, the behavior around \( x = 0 \) confirms the function is decreasing for \( x < 0 \) and increasing for \( x > 0 \).

Thus, \( f(x) \) is decreasing on \( -\infty < x \leq 0 \) and increasing on \( 0 \leq x < \infty \).

The final answer is \(\boxed{\textbf{(D)}}\)