Commit Graph
74 Commits
Author SHA1 Message Date
weishu c35a5ce827 feat: add git worktree session support with improved UI
Implement comprehensive worktree session support allowing users to spawn sessions in temporary git worktrees. Includes backend worktree management, full-stack integration, and refined UI for session type selection.

Backend:
- Add worktree creation/removal utilities with branch management
- Track worktree metadata (basePath, branch, name, path) in session metadata
- Automatic cleanup of worktrees when sessions fail or exit
- Enhanced error handling with stderr tail logging

UI improvements:
- Redesign session type toggle with improved alignment and spacing
- Move worktree description inline with label for cleaner layout
- Add branch name input field that appears when worktree mode selected
- Auto-focus on worktree input when switching modes
- Reduce gap between radio options from gap-3 to gap-1.5
- Update descriptive text and placeholders for clarity

Integration:
- Thread worktree parameters through API client, RPC handlers, and daemon
- Add worktreeEnv utility to read worktree info from environment
- Update session spawning to support both simple and worktree modes
2025-12-28 13:17:58 +08:00
weishu 50d5c4fd35 fix: resolve TypeScript type inference issue in claudeLocal.ts
Remove unnecessary Promise wrapper and move args building outside try block
so cleanupMcpConfig becomes const with proper type inference instead of never
2025-12-28 13:12:15 +08:00
weishu 2ef7e0ec5f refactor: extract MCP config handling to use temp files on Windows 2025-12-28 11:36:56 +08:00
weishu 5d79a3f1ef refactor: extract spawn abort handling into shared utility 2025-12-26 18:18:12 +08:00
weishu b3499bb5ed fix: terminal state restoration and abort handling regression
Fixes regression introduced in 1a23bfa430.

- Add restoreTerminalState helper to disable kitty keyboard protocol and
  CSI u key release reporting when switching modes or cleaning up
- Improve claudeLocal abort handling with SIGINT → SIGTERM → SIGKILL
  escalation timeouts for graceful process termination
- Fix useSwitchControls to properly handle CSI u space sequences (0x20)
  and key.name/key.sequence detection for space key presses
- Fix typo: exutFuture → exitFuture in claudeLocalLauncher
2025-12-26 18:07:45 +08:00
weishu 3adaa0f77c refactor: use ref objects for session tracking in closures 2025-12-26 18:02:33 +08:00
weishu 702072e9ba refactor: extract process management utilities for cross-platform support
Consolidate process lifecycle management (kill, check alive) into a new
utility module with proper Windows/Unix handling, replacing scattered
process.kill() calls with consistent async APIs.
2025-12-26 16:12:03 +08:00
weishu eee7a249fa feat: implement unified local launch failure handling policy 2025-12-26 16:11:58 +08:00
weishu 3765cc539b refactor: update dependencies and fix TypeScript instantiation depth issues
Updates ModelContextProtocol SDK and multiple dependent libraries to latest versions. Refactors TypeScript schemas to avoid instantiation depth issues by widening Zod types and using explicit type parameters.
2025-12-25 22:56:08 +08:00
weishu 1a23bfa430 refactor: remove custom executable support and simplify Claude CLI resolution
Remove support for custom executable paths and bundled Claude versions, including
deprecated environment variables HAPI_USE_BUNDLED_CLAUDE and HAPI_USE_GLOBAL_CLAUDE.
This simplifies the codebase to rely only on the global Claude CLI installation.

Updates Claude Code spawning logic to remove special handling for .js/.cjs files,
adds configurable BUN_BE_BUN environment variable handling, and streamlines path
resolution to throw an error when Claude Code CLI is not found on PATH.
2025-12-24 13:20:06 +08:00
weishu 8f804c57bf refactor: remove client-side session ID management
Remove proactive session ID generation and onSessionFound callback. Let Claude
handle session creation automatically via the SessionStart hook instead. This
simplifies the API contract and delegates session lifecycle management to Claude.
2025-12-24 10:35:20 +08:00
weishu 7f9145b6de feat: add token-based authentication to session hooks
Implement hook token validation to secure session start requests.
Each hook server generates a unique token that must be provided
in the x-hapi-hook-token header. Updates hook-forwarder command
to support both positional and named arguments for port and token.
2025-12-23 16:02:04 +08:00
weishu 61d3a1bed1 feat: implement session tracking via Claude hooks
Adds a dedicated hook server infrastructure to receive Claude SessionStart
notifications. This allows the CLI to track session ID changes (new sessions,
resume, compact, fork, etc.) without relying on file watchers.

Changes:
- Add SessionFound callback system to AgentSessionBase for session tracking
- Create hook server that listens for POST requests from Claude's hooks
- Generate temporary settings files with hook command configuration
- Implement session hook forwarder CLI command to relay hook data
- Integrate hook server into runClaude with proper cleanup
- Pass hookSettingsPath through local and remote execution paths
- Update SDK query builder to support --settings flag
2025-12-23 16:02:04 +08:00
weishu 88cce9c28d refactor: remove CommonJS launchers and use claude command directly
Remove local Claude launcher scripts and refactor to invoke the global
claude command from PATH. This simplifies the launcher logic and removes
the need to maintain separate CommonJS entry points.

Changes:
- Delete cli/scripts/claude_local_launcher.cjs, claude_remote_launcher.cjs,
  and claude_version_utils.cjs
- Update claudeLocal to spawn 'claude' command directly instead of using
  a launcher script
- Remove runtimePath dependency and launcher existence checks
- Add DISABLE_AUTOUPDATER environment variable for local mode
- Improve error messages when claude command is not found
- Add shell option for Windows compatibility in process spawning
- Remove unused imports from claudeLocal and index files
2025-12-23 10:21:50 +08:00
weishu 0128792495 refactor: remove thinking state tracking from local launcher 2025-12-23 08:25:44 +08:00
weishu 360e3a9919 refactor: extract session and loop logic into reusable agent base classes 2025-12-22 23:12:24 +08:00
weishu bf72e0dc3b chore: remove unused test fixtures and disable dead test case 2025-12-21 19:16:24 +08:00
weishu 4f03f29ac3 docs: rebrand Happy to HAPI and add component documentation
This commit rebrands the project from "Happy" to "HAPI" throughout the codebase, including documentation, comments, logs, and tool references. It also adds comprehensive README files for the server and web components, clarifies the monorepo structure in AGENTS.md and root README.md, and removes the outdated roadmap.md file.

Changes include:
- Rebrand references from Happy to HAPI in CLI, server, and web components
- MCP tool names updated from mcp__happy__ to mcp__hapi__
- Process/service names updated consistently
- New server/README.md with deployment and configuration guide
- New web/README.md with stack and development instructions
- Updated root README.md with quickstart guide
- Updated AGENTS.md with cleaner structure documentation
- Removed cli/roadmap.md (now superseded by documentation)
2025-12-21 18:49:04 +08:00
weishu 17eeba10d6 feat(cli): add Bun single executable binary support
Enables building hapi as standalone Bun-compiled executables for macOS,
Linux, and Windows (x64/arm64). Adds build script, bootstrap entry point,
runtime asset management, and automatic deployment of bundled tools
(ripgrep, difftastic). Includes MCP stdio bridge support and proper
environment handling for compiled binaries. Updates documentation with
build and installation instructions for single executable distribution.
2025-12-20 21:41:11 +08:00
weishu f0493ce68d feat(cli): add Bun compiled binary runtime asset management
Introduce runtime path abstraction for Bun-compiled binaries that extracts
assets to ~/.happy/runtime/{version} instead of using project paths. This
enables proper distribution of CLI as a self-contained binary with embedded
tools (ripgrep, difftastic) and scripts that are extracted at runtime.
2025-12-20 16:44:58 +08:00
weishu ac67718ec0 feat: implement AskUserQuestion tool with interactive UI and question flow
Add comprehensive support for the AskUserQuestion tool including:
- New footer component for handling user responses with multi-step question flow
- Type definitions and parsing utilities for question and answer formats
- View component for displaying questions and options
- Integration with permission system to capture user answers
- Support for single and multi-select questions with optional text input
- Haptic feedback and error handling for better UX
2025-12-18 23:24:41 +08:00
weishu 1b99c9422b fix: handle underscores in project path generation
Add underscore to the regex pattern in getProjectPath to ensure underscores
are replaced with hyphens, along with existing handling for slashes, colons,
and dots. Includes test case for paths with underscores.
2025-12-17 20:00:35 +08:00
weishu a696cafdd4 refactor: remove macOS caffeinate sleep prevention functionality 2025-12-17 15:59:50 +08:00
weishu b4654acb92 init 2025-12-16 15:03:50 +08:00