This question came up as a side issue during the course of a research project and I am wondering whether the answer is yes or no.
A word is primitive if it is not a proper power of a shorter word. A prefix $p$ of a word $u$ is proper if it is different from $u$ and from the empty word.
Question. Given a primitive word $u$ of length $> 1$ on $A^*$, is there a monoid morphism $f: A^* \to \mathbb Z$ such that $f(u) = 0$ and $f(p) > 0$ for every proper prefix $p$ of $u$?
Note that a monoid morphism $f: A^* \to \Bbb Z$ is of the form $f(x) = \sum_{a \in A} n_a |x|_a$, where $|x|_a$ denotes the number of occurrences of $a$ in the word $x$ and each $n_a$ is a fix integer.
Examples
If $u= 0011$, one can take $f(x) = |x|_0 - |x|_1$.
If $u = 001$, one can take $f(x) = |x|_0 - 2|x|_1$.
If $u = 010212$, one can take $f(x) = |x|_0 + |x|_1 - 2|x|_2$.