a simple solution:
0. generate all substrings of the original string
1. for every substring
1.0. remove substring from current string (invert the insertion @xterm)
1.1. iterate until current string becomes empty or the substring can no longer be found
a better one:
0. can be enhanced by considering only substrings that
0.0 having length that divides that of the original string
0.1 contain all the characters of the original string
0.2 agreeing on the first and last character with the original string (@ali.koubeissi)
0.3 for every character, its count in the substring divides its count in the original string, and the quotient is equal for all characters
Timing[
s = "aaaaaaaaaaaaa";
d = Divisors[StringLength[s]];
c = Characters[s];
(*\[Rho]=Union@Subsets[c];*)
(*generate all substrings with length dividing that of the original string*)
\[Rho] = Union@Flatten[Partition[c, #, 1] & /@ d, 1];
(*substrings containing all the characters of the original string and agreeing on the first and last character*)
\[Lambda] = Select[\[Rho], Union[#] == Union[c] && #[[1]] == c[[1]] && #[[-1]] == c[[-1]] &];
(*character count divides that of the original string and the quotient is unique*)
\[Alpha] = Map[{Map[#[[2]] &, #[[1]]], #[[2]]} &, {Tally[#], #} & /@ \[Lambda]];
\[Beta] = #[[2]] & /@ Tally[c];
\[Chi] = StringJoin[#[[2]]] & /@ Select[{\[Beta]/#[[1]], #[[2]]} & /@ \[Alpha], Length@Union@#[[1]] == 1 && IntegerQ@#[[1, 1]] &];
\[Mu] = {s, #, {}} & /@ \[Chi];
(*no pruning*)
(*\[Mu]={s,StringJoin[#],{}}&/@\[Rho];*)
\[Nu] = {};
f[l_List] := If[
(*current string is empty, append substring and indices to the solution*)
l[[1]] == "", AppendTo[\[Nu], {l[[2]], l[[3]]}],
(*else, find position(s) of substring*)
\[Epsilon] = StringPosition[l[[1]], l[[2]]];
(*apply f to every position*)
f /@ ({StringReplacePart[l[[1]], "", #], l[[2]], Prepend[l[[3]], #[[1]] - 1]} & /@ \[Epsilon]);
];
(*apply f to substrings*)
f /@ \[Mu];
(*sort solutions*)
\[Nu] = SortBy[\[Nu], #[[2]] &];
(*for every solution, check if the sequence of insertions generates the original string*)
And @@ (#[[1]] == s & /@ (NestWhile[{StringInsert[#[[1]], #[[2]], First@#[[3]] + 1],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},{abaa,{0,3,1,7,7}},{abaa,{0,3,1,7,11}},{abaa,{0,3,1,7,15}},{abaa,{0,3,1,11,7}},{abaa,{0,3,1,11,11}},{abaa,{0,3,1,11,15}},{abaa,{0,3,3,1,7}},{abaa,{0,3,3,1,11}},{abaa,{0,3,3,1,15}},{abaa,{0,3,3,3,1}},{abaa,{0,3,3,7,1}},{abaa,{0,3,3,11,1}},{aaba,{0,3,6,6,6}},{aaba,{0,3,6,6,10}},{aaba,{0,3,6,6,14}},{aaba,{0,3,6,10,6}},{aaba,{0,3,6,10,10}},{aaba,{0,3,6,10,14}},{abaa,{0,3,7,1,7}},{abaa,{0,3,7,1,11}},{abaa,{0,3,7,1,15}},{abaa,{0,3,7,3,1}},{abaa,{0,3,7,7,1}},{abaa,{0,3,7,11,1}}}
"aababaababaaababaa" (0.04399s)
{{aababaababaaababaa,{0}},{ababaa,{0,0,1}},{ababaa,{0,1,6}},{ababaa,{0,1,12}},{aababa,{0,5,5}},{aababa,{0,5,11}},{ababaa,{0,6,1}},{aba,{0,0,0,1,8,14}},{aba,{0,0,0,1,11,8}},{aba,{0,0,0,5,1,14}},{aba,{0,0,0,5,11,1}},{aba,{0,0,0,8,1,8}},{aba,{0,0,0,8,5,1}},{aba,{0,0,1,3,8,14}},{aba,{0,0,1,3,11,8}},{aba,{0,0,1,5,3,14}},{aba,{0,0,1,5,6,14}},{aba,{0,0,1,5,11,3}},{aba,{0,0,1,5,11,6}},{aba,{0,0,1,6,8,14}},{aba,{0,0,1,6,11,8}},{aba,{0,0,1,8,3,8}},{aba,{0,0,1,8,5,3}},{aba,{0,0,1,8,5,6}},{aba,{0,0,1,8,6,8}},{aba,{0,0,1,8,8,12}},{aba,{0,0,1,8,9,8}},{aba,{0,0,1,8,11,12}},{aba,{0,0,1,8,12,14}},{aba,{0,0,1,9,8,14}},{aba,{0,0,1,9,11,8}},{aba,{0,0,2,0,1,14}},{aba,{0,0,2,0,11,1}},{aba,{0,0,2,1,3,14}},{aba,{0,0,2,1,6,14}},{aba,{0,0,2,1,11,3}},{aba,{0,0,2,1,11,6}},{aba,{0,0,2,3,1,14}},{aba,{0,0,2,3,11,1}},{aba,{0,0,2,8,0,1}},{aba,{0,0,2,8,1,3}},{aba,{0,0,2,8,1,6}},{aba,{0,0,2,8,3,1}},{aba,{0,0,3,1,8,14}},{aba,{0,0,3,1,11,8}},{aba,{0,0,3,5,1,14}},{aba,{0,0,3,5,11,1}},{aba,{0,0,3,8,1,8}},{aba,{0,0,3,8,5,1}},{aba,{0,0,5,0,1,8}},{aba,{0,0,5,0,5,1}},{aba,{0,0,5,1,3,8}},{aba,{0,0,5,1,5,3}},{aba,{0,0,5,1,5,6}},{aba,{0,0,5,1,6,8}},{aba,{0,0,5,1,8,12}},{aba,{0,0,5,1,9,8}},{aba,{0,0,5,1,11,12}},{aba,{0,0,5,1,12,14}},{aba,{0,0,5,2,0,1}},{aba,{0,0,5,2,1,3}},{aba,{0,0,5,2,1,6}},{aba,{0,0,5,2,3,1}},{aba,{0,0,5,3,1,8}},{aba,{0,0,5,3,5,1}},{aba,{0,0,5,5,1,12}},{aba,{0,0,5,5,9,1}},{aba,{0,0,5,6,1,8}},{aba,{0,0,5,6,5,1}},{aba,{0,0,5,8,1,12}},{aba,{0,0,5,8,9,1}},{aba,{0,0,5,9,1,14}},{aba,{0,0,5,9,11,1}},{aba,{0,0,6,1,8,14}},{aba,{0,0,6,1,11,8}},{aba,{0,0,6,5,1,14}},{aba,{0,0,6,5,11,1}},{aba,{0,0,6,8,1,8}},{aba,{0,0,6,8,5,1}},{aba,{0,1,3,3,8,14}},{aba,{0,1,3,3,11,8}},{aba,{0,1,3,5,3,14}},{aba,{0,1,3,5,6,14}},{aba,{0,1,3,5,11,3}},{aba,{0,1,3,5,11,6}},{aba,{0,1,3,6,8,14}},{aba,{0,1,3,6,11,8}},{aba,{0,1,3,8,3,8}},{aba,{0,1,3,8,5,3}},{aba,{0,1,3,8,5,6}},{aba,{0,1,3,8,6,8}},{aba,{0,1,3,8,8,12}},{aba,{0,1,3,8,9,8}},{aba,{0,1,3,8,11,12}},{aba,{0,1,3,8,12,14}},{aba,{0,1,3,9,8,14}},{aba,{0,1,3,9,11,8}},{aba,{0,1,5,3,3,8}},{aba,{0,1,5,3,5,3}},{aba,{0,1,5,3,5,6}},{aba,{0,1,5,3,6,8}},{aba,{0,1,5,3,8,12}},{aba,{0,1,5,3,9,8}},{aba,{0,1,5,3,11,12}},{aba,{0,1,5,3,12,14}},{aba,{0,1,5,5,3,12}},{aba,{0,1,5,5,6,12}},{aba,{0,1,5,5,9,3}},{aba,{0,1,5,5,9,6}},{aba,{0,1,5,6,3,8}},{aba,{0,1,5,6,5,3}},{aba,{0,1,5,6,5,6}},{aba,{0,1,5,6,6,8}},{aba,{0,1,5,6,8,12}},{aba,{0,1,5,6,9,8}},{aba,{0,1,5,6,11,12}},{aba,{0,1,5,6,12,14}},{aba,{0,1,5,8,3,12}},{aba,{0,1,5,8,6,12}},{aba,{0,1,5,8,9,3}},{aba,{0,1,5,8,9,6}},{aba,{0,1,5,9,3,14}},{aba,{0,1,5,9,6,14}},{aba,{0,1,5,9,11,3}},{aba,{0,1,5,9,11,6}},{aba,{0,1,6,3,8,14}},{aba,{0,1,6,3,11,8}},{aba,{0,1,6,5,3,14}},{aba,{0,1,6,5,6,14}},{aba,{0,1,6,5,11,3}},{aba,{0,1,6,5,11,6}},{aba,{0,1,6,6,8,14}},{aba,{0,1,6,6,11,8}},{aba,{0,1,6,8,3,8}},{aba,{0,1,6,8,5,3}},{aba,{0,1,6,8,5,6}},{aba,{0,1,6,8,6,8}},{aba,{0,1,6,8,8,12}},{aba,{0,1,6,8,9,8}},{aba,{0,1,6,8,11,12}},{aba,{0,1,6,8,12,14}},{aba,{0,1,6,9,8,14}},{aba,{0,1,6,9,11,8}},{aba,{0,2,0,0,1,8}},{aba,{0,2,0,0,5,1}},{aba,{0,2,0,1,3,8}},{aba,{0,2,0,1,5,3}},{aba,{0,2,0,1,5,6}},{aba,{0,2,0,1,6,8}},{aba,{0,2,0,1,8,12}},{aba,{0,2,0,1,9,8}},{aba,{0,2,0,1,11,12}},{aba,{0,2,0,1,12,14}},{aba,{0,2,0,2,0,1}},{aba,{0,2,0,2,1,3}},{aba,{0,2,0,2,1,6}},{aba,{0,2,0,2,3,1}},{aba,{0,2,0,3,1,8}},{aba,{0,2,0,3,5,1}},{aba,{0,2,0,5,1,12}},{aba,{0,2,0,5,9,1}},{aba,{0,2,0,6,1,8}},{aba,{0,2,0,6,5,1}},{aba,{0,2,0,8,1,12}},{aba,{0,2,0,8,9,1}},{aba,{0,2,0,9,1,14}},{aba,{0,2,0,9,11,1}},{aba,{0,2,1,3,3,8}},{aba,{0,2,1,3,5,3}},{aba,{0,2,1,3,5,6}},{aba,{0,2,1,3,6,8}},{aba,{0,2,1,3,8,12}},{aba,{0,2,1,3,9,8}},{aba,{0,2,1,3,11,12}},{aba,{0,2,1,3,12,14}},{aba,{0,2,1,5,3,12}},{aba,{0,2,1,5,6,12}},{aba,{0,2,1,5,9,3}},{aba,{0,2,1,5,9,6}},{aba,{0,2,1,6,3,8}},{aba,{0,2,1,6,5,3}},{aba,{0,2,1,6,5,6}},{aba,{0,2,1,6,6,8}},{aba,{0,2,1,6,8,12}},{aba,{0,2,1,6,9,8}},{aba,{0,2,1,6,11,12}},{aba,{0,2,1,6,12,14}},{aba,{0,2,1,8,3,12}},{aba,{0,2,1,8,6,12}},{aba,{0,2,1,8,9,3}},{aba,{0,2,1,8,9,6}},{aba,{0,2,1,9,3,14}},{aba,{0,2,1,9,6,14}},{aba,{0,2,1,9,11,3}},{aba,{0,2,1,9,11,6}},{aba,{0,2,2,0,1,12}},{aba,{0,2,2,0,9,1}},{aba,{0,2,2,1,3,12}},{aba,{0,2,2,1,6,12}},{aba,{0,2,2,1,9,3}},{aba,{0,2,2,1,9,6}},{aba,{0,2,2,3,1,12}},{aba,{0,2,2,3,9,1}},{aba,{0,2,2,6,0,1}},{aba,{0,2,2,6,1,3}},{aba,{0,2,2,6,1,6}},{aba,{0,2,2,6,3,1}},{aba,{0,2,3,0,1,8}},{aba,{0,2,3,0,5,1}},{aba,{0,2,3,1,3,8}},{aba,{0,2,3,1,5,3}},{aba,{0,2,3,1,5,6}},{aba,{0,2,3,1,6,8}},{aba,{0,2,3,1,8,12}},{aba,{0,2,3,1,9,8}},{aba,{0,2,3,1,11,12}},{aba,{0,2,3,1,12,14}},{aba,{0,2,3,2,0,1}},{aba,{0,2,3,2,1,3}},{aba,{0,2,3,2,1,6}},{aba,{0,2,3,2,3,1}},{aba,{0,2,3,3,1,8}},{aba,{0,2,3,3,5,1}},{aba,{0,2,3,5,1,12}},{aba,{0,2,3,5,9,1}},{aba,{0,2,3,6,1,8}},{aba,{0,2,3,6,5,1}},{aba,{0,2,3,8,1,12}},{aba,{0,2,3,8,9,1}},{aba,{0,2,3,9,1,14}},{aba,{0,2,3,9,11,1}},{aba,{0,2,5,0,1,12}},{aba,{0,2,5,0,9,1}},{aba,{0,2,5,1,3,12}},{aba,{0,2,5,1,6,12}},{aba,{0,2,5,1,9,3}},{aba,{0,2,5,1,9,6}},{aba,{0,2,5,3,1,12}},{aba,{0,2,5,3,9,1}},{aba,{0,2,5,6,0,1}},{aba,{0,2,5,6,1,3}},{aba,{0,2,5,6,1,6}},{aba,{0,2,5,6,3,1}},{aba,{0,2,6,0,1,14}},{aba,{0,2,6,0,11,1}},{aba,{0,2,6,1,3,14}},{aba,{0,2,6,1,6,14}},{aba,{0,2,6,1,11,3}},{aba,{0,2,6,1,11,6}},{aba,{0,2,6,3,1,14}},{aba,{0,2,6,3,11,1}},{aba,{0,2,6,8,0,1}},{aba,{0,2,6,8,1,3}},{aba,{0,2,6,8,1,6}},{aba,{0,2,6,8,3,1}},{aba,{0,3,0,1,8,14}},{aba,{0,3,0,1,11,8}},{aba,{0,3,0,5,1,14}},{aba,{0,3,0,5,11,1}},{aba,{0,3,0,8,1,8}},{aba,{0,3,0,8,5,1}},{aba,{0,3,1,3,8,14}},{aba,{0,3,1,3,11,8}},{aba,{0,3,1,5,3,14}},{aba,{0,3,1,5,6,14}},{aba,{0,3,1,5,11,3}},{aba,{0,3,1,5,11,6}},{aba,{0,3,1,6,8,14}},{aba,{0,3,1,6,11,8}},{aba,{0,3,1,8,3,8}},{aba,{0,3,1,8,5,3}},{aba,{0,3,1,8,5,6}},{aba,{0,3,1,8,6,8}},{aba,{0,3,1,8,8,12}},{aba,{0,3,1,8,9,8}},{aba,{0,3,1,8,11,12}},{aba,{0,3,1,8,12,14}},{aba,{0,3,1,9,8,14}},{aba,{0,3,1,9,11,8}},{aba,{0,3,2,0,1,14}},{aba,{0,3,2,0,11,1}},{aba,{0,3,2,1,3,14}},{aba,{0,3,2,1,6,14}},{aba,{0,3,2,1,11,3}},{aba,{0,3,2,1,11,6}},{aba,{0,3,2,3,1,14}},{aba,{0,3,2,3,11,1}},{aba,{0,3,2,8,0,1}},{aba,{0,3,2,8,1,3}},{aba,{0,3,2,8,1,6}},{aba,{0,3,2,8,3,1}},{aba,{0,3,3,1,8,14}},{aba,{0,3,3,1,11,8}},{aba,{0,3,3,5,1,14}},{aba,{0,3,3,5,11,1}},{aba,{0,3,3,8,1,8}},{aba,{0,3,3,8,5,1}},{aba,{0,3,5,0,1,8}},{aba,{0,3,5,0,5,1}},{aba,{0,3,5,1,3,8}},{aba,{0,3,5,1,5,3}},{aba,{0,3,5,1,5,6}},{aba,{0,3,5,1,6,8}},{aba,{0,3,5,1,8,12}},{aba,{0,3,5,1,9,8}},{aba,{0,3,5,1,11,12}},{aba,{0,3,5,1,12,14}},{aba,{0,3,5,2,0,1}},{aba,{0,3,5,2,1,3}},{aba,{0,3,5,2,1,6}},{aba,{0,3,5,2,3,1}},{aba,{0,3,5,3,1,8}},{aba,{0,3,5,3,5,1}},{aba,{0,3,5,5,1,12}},{aba,{0,3,5,5,9,1}},{aba,{0,3,5,6,1,8}},{aba,{0,3,5,6,5,1}},{aba,{0,3,5,8,1,12}},{aba,{0,3,5,8,9,1}},{aba,{0,3,5,9,1,14}},{aba,{0,3,5,9,11,1}},{aba,{0,3,6,1,8,14}},{aba,{0,3,6,1,11,8}},{aba,{0,3,6,5,1,14}},{aba,{0,3,6,5,11,1}},{aba,{0,3,6,8,1,8}},{aba,{0,3,6,8,5,1}}}
"abaabcdbcdcd" (0.000881s)
{{abaabcdbcdcd,{0}},{abcd,{0,2,3}}}
this becomes intractable as the length of the string increases; the search space grows exponentially.
probably there's a much better way involving automata and string matching.