Fix: coding-helper detection and installation feedback

Fixed 3 bugs related to coding-helper detection and installation:

1. Detection Bug: Wizard and bilingual checks only looked for 'chelper'
   command, but the npm package @z_ai/coding-helper doesn't create this
   command - it's run via 'npx @z_ai/coding-helper'.

   Fixed by adding 'npm list -g @z_ai/coding-helper' check to both:
   - wizard detection (line 505)
   - bilingual detection (line 542)

2. Misleading Success Message: When npm install failed, the script said
   "Installation completed. You can run manually with:" which sounded
   like it succeeded.

   Fixed by:
   - Capturing both stdout and stderr
   - Checking actual exit code
   - Showing "Installation failed!" with error output
   - Providing clearer manual installation instructions

3. No Installation Verification: After npm install appeared to succeed,
   there was no verification that the package was actually installed.

   Fixed by:
   - Adding npm list -g verification after install
   - Showing "installed and verified!" on success
   - Warning if installation appeared to succeed but verification failed

Changes:
- detect_coding_helper_components(): Added npm list check to wizard
  and bilingual detection
- install_coding_helper(): Added error capture, exit code checking,
  verification step, and proper error messages
- Removed misleading "chelper" command from success message (it's
  npx @z_ai/coding-helper, not chelper)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-22 16:31:03 +00:00
Unverified
parent f852e986f4
commit 0312e600f2

View File

@@ -502,7 +502,7 @@ detect_coding_helper_components() {
fi fi
# 2. Interactive wizard (part of core, but check if wizard can run) # 2. Interactive wizard (part of core, but check if wizard can run)
if command -v chelper &> /dev/null; then if command -v chelper &> /dev/null || npm list -g @z_ai/coding-helper &> /dev/null 2>&1; then
status_json+='"wizard":true,' status_json+='"wizard":true,'
else else
status_json+='"wizard":false,' status_json+='"wizard":false,'
@@ -539,7 +539,7 @@ detect_coding_helper_components() {
fi fi
# 6. Bilingual interface (inherent to coding-helper) # 6. Bilingual interface (inherent to coding-helper)
if command -v chelper &> /dev/null; then if command -v chelper &> /dev/null || npm list -g @z_ai/coding-helper &> /dev/null 2>&1; then
status_json+='"bilingual":true,' status_json+='"bilingual":true,'
else else
status_json+='"bilingual":false,' status_json+='"bilingual":false,'
@@ -697,10 +697,16 @@ install_coding_helper() {
fi fi
# Install the helper # Install the helper
if npm install -g @z_ai/coding-helper 2>/dev/null; then local install_output
log_success "coding-helper installed successfully" install_output=$(npm install -g @z_ai/coding-helper 2>&1)
local install_exit_code=$?
if [ $install_exit_code -eq 0 ]; then
# Verify installation
if npm list -g @z_ai/coding-helper &> /dev/null 2>&1; then
log_success "coding-helper installed and verified!"
echo "" echo ""
echo -e "${CYAN}You can now run:${NC} ${YELLOW}chelper${NC} ${CYAN}or${NC} ${YELLOW}npx @z_ai/coding-helper${NC}" echo -e "${CYAN}You can now run:${NC} ${YELLOW}npx @z_ai/coding-helper${NC}"
echo "" echo ""
read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty
echo "" echo ""
@@ -708,7 +714,24 @@ install_coding_helper() {
launch_coding_helper launch_coding_helper
fi fi
else else
log_warn "Installation completed. You can run manually with:" log_warn "Installation appeared to succeed but verification failed"
echo ""
echo -e "${YELLOW}Installation output:${NC}"
echo "$install_output"
echo ""
echo -e "${CYAN}You can try running manually:${NC}"
echo -e " ${YELLOW}npx @z_ai/coding-helper${NC}"
fi
else
log_error "Installation failed!"
echo ""
echo -e "${YELLOW}Error output:${NC}"
echo "$install_output"
echo ""
echo -e "${CYAN}You can try installing manually:${NC}"
echo -e " ${YELLOW}npm install -g @z_ai/coding-helper${NC}"
echo ""
echo -e "${CYAN}Or run without installation:${NC}"
echo -e " ${YELLOW}npx @z_ai/coding-helper${NC}" echo -e " ${YELLOW}npx @z_ai/coding-helper${NC}"
fi fi
} }