As the new American commander in Afghanistan, Gen. David H. Petraeus, tries to reverse the lagging war effort, the WikiLeaks documents sketch a war hamstrung by an Afghan government, police force and army of questionable loyalty and competence, and by a Pakistani military that appears at best uncooperative and at worst to work from the shadows as an unspoken ally of the very insurgent forces the American-led coalition is trying to defeat.